From 6bfdf86b252ed6b66890a1d4b7e40e2f0733e93e Mon Sep 17 00:00:00 2001 From: asami Date: Wed, 28 Aug 1996 06:26:38 +0000 Subject: [PATCH] Bring this up to match reality. Also, fix dozens of small bogons I noticed while translating this thing into Japanese. --- share/doc/handbook/porting.sgml | 201 ++++++++++++++++++-------------- 1 file changed, 111 insertions(+), 90 deletions(-) diff --git a/share/doc/handbook/porting.sgml b/share/doc/handbook/porting.sgml index 0ef05d2270af..cdaa38d5b2c2 100644 --- a/share/doc/handbook/porting.sgml +++ b/share/doc/handbook/porting.sgml @@ -1,4 +1,4 @@ - + Porting an existing piece of free software @@ -18,19 +18,18 @@ of the sources being ported, but merely those differences required for running under FreeBSD.

What follows are some guidelines for creating a new port for -FreeBSD 2.x . The ${..} variable names you will -see in this document all refer to various user-overrideable defaults -used (and documented) by /usr/share/mk/bsd.port.mk. +FreeBSD 2.x. The bulk of the work is done by +/usr/share/mk/bsd.port.mk, which all port Makefiles include. Please refer to that file for more details on the inner workings of the ports collection. Before Starting the Port -

Note: Only a fraction of the overrideable variables are - mentioned in this document. Most (if not all) are documented - at the start of the bsd.port.mk file which can be - found in /usr/share/mk. This file uses a non-standard tab +

Note: Only a fraction of the overridable variables + (${..}) are mentioned in this document. Most + (if not all) are documented at the start of + bsd.port.mk. This file uses a non-standard tab setting. Emacs should recognize the setting on loading the file. vi or ex can be set to using the correct value by typing `:set tabstop=4' @@ -125,7 +124,7 @@ The pattern is the year followed by the month. -

In the dozens of ports that have been done, there have +

In the hundreds of ports that have been done, there have only been one or two cases where __FreeBSD__ should have been used. Just because an earlier port screwed up and used it in the wrong place does not mean @@ -155,10 +154,10 @@ The pattern is the year followed by the month. # New ports collection makefile for: oneko # Version required: 1.1b - # Date created: 5 December 1994 - # Whom: asami + # Date created: 5 December 1994 + # Whom: asami # - # $Id: porting.sgml,v 1.25 1996/08/01 00:12:11 asami Exp $ + # $Id: porting.sgml,v 1.26 1996/08/20 09:51:02 asami Exp $ # DISTNAME= oneko-1.1b @@ -193,7 +192,7 @@ The pattern is the year followed by the month. recommended to not have the name of the package at the beginning, as in: -A cat chasing a mouse all over the screen +A cat chasing a mouse all over the screen. @@ -304,8 +303,13 @@ ftp://ftp.FreeBSD.ORG/pub/FreeBSD/incoming/ responsible for making sure that the tarball exists locally in ${DISTDIR}. If fetch cannot find the required files in ${DISTDIR} it - will look up the ftp-URL ${MASTER_SITES}, - which is set in the Makefile. It will then attempt to + will look up the URL ${MASTER_SITES}, + which is set in the Makefile, as well as our main ftp + site at + where we put sanctioned distfiles as backup. It will then + attempt to fetch the named distribution file with ${FETCH}, assuming that the requesting site has direct access to the Internet. If that succeeds, @@ -393,8 +397,8 @@ ftp://ftp.FreeBSD.ORG/pub/FreeBSD/incoming/ and copy it into ${DISTDIR}. Always use mainstream sources when and where you can. -

If you cannot find a ftp site that is well-connected to the - net, or can only find sites that have irritatingly +

If you cannot find a ftp/http site that is well-connected + to the net, or can only find sites that have irritatingly non-standard formats, we can `house' it ourselves by putting it on @@ -408,7 +412,8 @@ ftp://freefall.FreeBSD.ORG/pub/FreeBSD/LOCAL_PORTS/ ${DISTDIR}. Do not worry if they come from site other than where you got the the main source tarball, we have a way to handle these situations (see the - description of ${PATCHFILES} below). + description of below). Modifying the port @@ -435,9 +440,7 @@ ftp://freefall.FreeBSD.ORG/pub/FreeBSD/LOCAL_PORTS/

In the preparation of the port, files that have been added or changed can be picked up with a recursive diff for later - feeding to patch. This is the easiest kind of change to - make as it does not involve any mucking around with - configuration files. Each set of patches you wish to apply + feeding to patch. Each set of patches you wish to apply should be collected into a file named `patch-<xx>' where <xx> denotes the sequence in which the patches will be applied -- @@ -495,7 +498,7 @@ ftp://freefall.FreeBSD.ORG/pub/FreeBSD/LOCAL_PORTS/ ${EXTRACT_BEFORE_ARGS}, ${EXTRACT_AFTER_ARGS}, ${EXTRACT_SUFX}, or - ${DISTFILE} variables, depending on how + ${DISTFILES} variables, depending on how alien a format your port's distribution file is. (The most common case is `EXTRACT_SUFX=.tar.Z', when the tarball is condensed by regular compress, not gzip.) @@ -506,6 +509,7 @@ ftp://freefall.FreeBSD.ORG/pub/FreeBSD/LOCAL_PORTS/ DISTNAME +

You should set ${DISTNAME} to be the base name of your port. The default rules expect the distribution file list (${DISTFILES}) to be @@ -537,6 +541,7 @@ work/foozolix-1.0/ CATEGORIES +

When a package is created, it is put under /usr/ports/packages/All and links are made from one or more subdirectories of /usr/ports/packages. The @@ -544,19 +549,19 @@ work/foozolix-1.0/ ${CATEGORIES}. It is intended to make life easier for the user when he is wading through the pile of packages on the ftp site or the CD-ROM. Please take a look - at the existing categories (some of them have different - names from subdirectories of /usr/ports) and pick - the ones that are suitable for your port. If your port - truly belongs to something that is different from all the - existing ones, you can even create a new category name. + at the existing categories (you can find them in ) and pick the ones that are suitable for your port. + If your port truly belongs to something that is different + from all the existing ones, you can even create a new + category name. MASTER_SITES -

If you have a ftp-URL pointing at the the original tarball, - record the directory containing the tarball in - ${MASTER_SITES}. This will provide a backup - site, as well as a direct pointer to the original source - location. Do not forget the trailing slash (/)! + +

Record the directory part of the ftp/http-URL pointing at + the the original tarball in ${MASTER_SITES}. + Do not forget the trailing slash (/)!

The make macros will try to use this specification for grabbing the distribution file with ${FETCH} @@ -569,12 +574,13 @@ work/foozolix-1.0/ master site and fetching from there! - PATCHFILES + PATCHFILES +

If your port requires some additional patches that are - available by ftp, set ${PATCHFILES} to the - names of the files and ${PATCH_SITES} to the - URL of the directory that contains them (the format is the - same as ${MASTER_SITES}). + available by ftp or http, set ${PATCHFILES} + to the names of the files and ${PATCH_SITES} + to the URL of the directory that contains them (the format + is the same as ${MASTER_SITES}).

If the patch is not relative to the top of the source tree (i.e., ${WKRSRC}) because it contains some @@ -589,15 +595,19 @@ work/foozolix-1.0/ MAINTAINER +

Set your mail-address here. Please. :) Dependencies +

Many ports depend on other ports. There are five variables that you can use to ensure that all the required bits will be on the user's machine. + LIB_DEPENDS +

This variable specifies the shared libraries this port depends on. It is a list of `lib:dir' pairs where lib is the name of the shared library, and @@ -614,8 +624,15 @@ LIB_DEPENDS= jpeg\\.6\\.:${PORTSDIR}/graphics/jpeg Note that the lib part is just an argument given to `ldconfig -r | grep', so periods should be escaped by two backslashes like in the example above. + + The dependency is checked from within the extract + target. Also, the name of the dependency is put in to the + package so that pkg_add will automatically + install it if it is not on the user's system. + RUN_DEPENDS +

This variable specifies executables or files this port depends on during run-time. It is a list of `path:dir' pairs where path is the name @@ -648,13 +665,15 @@ RUN_DEPENDS= ${PREFIX}/etc/innd:${PORTSDIR}/news/inn \ target. Also, the name of the dependency is put in to the package so that pkg_add will automatically install it if it is not on the user's system. + BUILD_DEPENDS -

This variable specifies executables this port requires to - build. Like RUN_DEPENDS, it is a list of - `path:dir' pairs. For example, + +

This variable specifies executables or files this port + requires to build. Like RUN_DEPENDS, it is a + list of `path:dir' pairs. For example, -BUILD_DEPENDS= unzip:${PORTSDIR}/archivers/unzip +BUILD_DEPENDS= unzip:${PORTSDIR}/archivers/unzip will check for an executable called `unzip', and descend into the archivers/unzip subdirectory of @@ -663,10 +682,12 @@ BUILD_DEPENDS= unzip:${PORTSDIR}/archivers/unzip Note that `build' here means everything from extracting to compilation. The dependency is checked from within the extract target. + FETCH_DEPENDS -

This variable specifies executables this port requires to - fetch. Like the previous two, it is a list of + +

This variable specifies executables or files this port + requires to fetch. Like the previous two, it is a list of `path:dir' pairs. For example, FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 @@ -677,8 +698,10 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 The dependency is checked from within the fetch target. + DEPENDS +

If there is a dependency that does not fall into either of the above four categories, or your port requires to have the source of the other port extracted (i.e., having them @@ -688,16 +711,18 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 Building mechanisms +

If your package uses GNU make, set `USE_GMAKE=yes'. If your package uses GNU configure, set `GNU_CONFIGURE=yes'. If - you want to override the default GNU configure - arguments from `--prefix=${PREFIX}' to - something else, set those arguments in + you want to give some extra arguments to GNU + configure (other than the default + `--prefix=${PREFIX}'), + set those extra arguments in ${CONFIGURE_ARGS}. -

If your package uses imake (e.g. is an X - application that has an Imakefile), then set +

If your package is an X application that creates Makefiles + from Imakefiles using imake, then set `USE_IMAKE=yes'. This will cause the configure stage to automatically do an xmkmf -a. If the `-a' flag is a problem for your port, set @@ -710,13 +735,16 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 NO_INSTALL_MANPAGES +

If the port uses imake but does not understand the `install.man' target, `NO_INSTALL_MANPAGES=yes' should be set. In - addition, the author of the original port should be shot. + addition, the author of the original port should be + shot. :> Ports that require Motif +

There are many programs that require a Motif library (available from several commercial vendors, while there is (at least) one effort to create a free clone) to compile. Since @@ -728,12 +756,14 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 REQUIRES_MOTIF +

If your port requires Motif, define this variable in the Makefile. This will prevent people who don't own a copy of Motif from even attempting to build it. ${MOTIFLIB} +

This variable will be set by bsd.port.mk to be the appropriate reference to the Motif library. Please patch the source to use this wherever the Motif library is @@ -757,11 +787,12 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 Licensing Problems +

Some software packages have restrictive licenses or are in - violation to the law (PKP's patent on public key crypto, - ITAR (export of crypto software) to name just two of them). - What we can do with them vary a lot, depending on the exact - wordings of the respective licenses. + violation to the law (PKP's patent on public key crypto, + ITAR (export of crypto software) to name just two of them). + What we can do with them vary a lot, depending on the exact + wordings of the respective licenses.

Note that it is your responsibility as a porter to read the licensing terms of the software and make sure that the FreeBSD @@ -794,6 +825,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 Upgrading +

When you notice that a port is out of date compared to the latest version from the original authors, first make sure you have the latest port. You can find them in the @@ -825,15 +857,17 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 WRKDIR +

Do not leave anything valuable lying around in the - `work' subdirectory, `make clean' will + work subdirectory, `make clean' will nuke it completely! If you need auxiliary files that are not scripts or patches, put them in the subdirectory - `files' and use the post-extract target to - copy them to the `work' subdirectory. + files and use the post-extract target to + copy them to the work subdirectory. Package information +

Do install package information, i.e., the three files in pkg. Note that these files are not used only for packaging anymore, and are mandatory now, even if @@ -841,6 +875,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 Compress manpages, strip binaries +

Do compress manpages and strip binaries. If the original source already does that, fine; otherwise, you can add a post-install rule to do it yourself. Make sure @@ -861,6 +896,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 Install additional documentation +

If your software has some documentation other than the standard man and info pages that you think is useful for the user, install it under ${PREFIX}/share/doc. @@ -871,7 +907,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 should reflect what the port is. This usually means ${PKGNAME} minus the version part. However, if you think the user might want different versions of the - port to be installed at the same time (e.g., tcl/tk), you + port to be installed at the same time, you can use the whole ${PKGNAME}.

Make the installation dependent to the variable @@ -892,8 +928,9 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 DIST_SUBDIR +

Do not let your port clutter /usr/ports/distfiles. If - your port requires a lot of files (including patchfiles) to be + your port requires a lot of files to be fetched, or contains a file that has a name that might conflict with other ports (e.g., `Makefile'), set ${DIST_SUBDIR} to the name of the port @@ -912,29 +949,9 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2

Note this does not affect the ${MASTER_SITES} you define in your Makefile. - - Custom utilities -

Do not rely on custom utilities in your local configure - script or anything -- they may not be there on the user's - system! If you really need something else to be installed - before you can work, detect this from your configure script, - print a helpful message and exit with a non-zero status! At - least you will have given the user some idea of what is needed. - If the custom utility or package is actually part of the - ports tree, this should be dealt by the dependency mechanism - of ports. - -

Actually, if this utility is not part of the ports tree you - should probably make a port of this utility (this is how - many of the ports made it into the tree!). Depending on - something that is not part of the main FreeBSD distribution - or the ports tree is a bad idea, and the user should be able - to go to any subdirectory of /usr/ports and type - `make' and have that port, as well as everything it - requires, built automatically. - Feedback +

Do send applicable changes/patches to the original author/maintainer for inclusion in next release of the code. This will only make your job that much easier for the next @@ -942,6 +959,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 RCS strings +

Do not put RCS strings in patches. CVS will mangle them when we put the files into the ports tree, and when we check them out again, they will come out different and the patch @@ -951,6 +969,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 Recursive diff +

Using the recurse (`-r') option to diff to generate patches is fine, but please take a look at the resulting patches to make sure you don't have any @@ -963,6 +982,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 PREFIX +

Do try to make your port install relative to ${PREFIX}. (The value of this variable will be set to ${LOCALBASE} (default @@ -1000,6 +1020,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 Subdirectories +

Try to let the port put things in the right subdirectories of ${PREFIX}. Some ports lump everything and put it in the subdirectory with the port's name, which is @@ -1017,6 +1038,7 @@ FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 ldconfig +

If your port installs a shared library, add a post-install target to your Makefile that runs `/sbin/ldconfig -m' on the directory where the new @@ -1033,10 +1055,6 @@ lib/libtcl.so.7.3 @exec /sbin/ldconfig -m %D/lib -

Note: the `-m' option is new since 2.0.5 and - 2.1.0-950726-SNAP, so do not be alarmed if it does not work on - your machine. -

Never, ever, ever add a line that says `ldconfig' without any arguments to your Makefile or pkg/PLIST. This will reset the shared library cache to @@ -1050,6 +1068,7 @@ lib/libtcl.so.7.3 If you are stuck.... +

Do look at existing examples and the bsd.port.mk file before asking us questions! ;) @@ -1058,6 +1077,7 @@ lib/libtcl.so.7.3 A Sample Makefile +

Here is a sample Makefile that you can use to create a new port. Make sure you remove all the extra comments (ones between brackets)! @@ -1078,12 +1098,13 @@ lib/libtcl.so.7.3 person who wrote this Makefile] # Whom: Satoshi Asami # - # $Id: porting.sgml,v 1.25 1996/08/01 00:12:11 asami Exp $ - [ ^^^^ do not worry about this...it will be automatically filled in by CVS - when it is committed to our repository] + # $Id: porting.sgml,v 1.26 1996/08/20 09:51:02 asami Exp $ + [ ^^^^ do not worry about this, I know it says "porting.sgml"...it + will be automatically filled in by CVS when it is committed to our + repository] # - [section to describe the package itself and main ftp site - DISTNAME + [section to describe the port itself and the master site - DISTNAME is always first, followed by PKGNAME (if necessary), CATEGORIES, and then MASTER_SITES, and optionally EXTRACT_SUFX or DISTFILES] DISTNAME= xdvi @@ -1151,7 +1172,7 @@ lib/libtcl.so.7.3

The package name should look like -[-][-]-; +[-][[-]]-; If your ${DISTNAME} doesn't look like that, @@ -1171,11 +1192,11 @@ lib/libtcl.so.7.3 category. Otherwise, convert the name (or at least the first letter) to lowercase. If the software in question really is called that way, you can have numbers, hyphens and - underscores in the name too. + underscores in the name too (like `kinput2'). If the port can be built with different hardcoded defaults (usually specified as environment variables or on - the `make' command line), the + the make command line), the `<compiled.specifics>' part should state the compiled-in defaults (the hyphen is optional). Examples are papersize and font units.