diff --git a/handbook/porting.sgml b/handbook/porting.sgml index 2beff5805d..3de16c95ba 100644 --- a/handbook/porting.sgml +++ b/handbook/porting.sgml @@ -1,2571 +1,2571 @@ - + Making a port yourself

Contributed by &a.jkh;, &a.gpalmer;, &a.asami;, &a.obrien; and &a.hoek;.28 August 1996.

So, now you are interested in making your own port? Great! What follows are some guidelines for creating a new port for FreeBSD. 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. Even if you don't hack Makefiles daily, it is well commented, and you will still gain much knowledge from it.

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 and Vim should recognize the setting on loading the file. vi or ex can be set to using the correct value by typing `:set tabstop=4' once the file has been loaded. Quick Porting

This section tells you how to do a quick port. In many cases, it is not enough, but we will see.

First, get the original tarball and put it into ${DISTDIR}, which defaults to /usr/ports/distfiles.

Note: The following assumes that the software compiled out-of-the-box, i.e., there was absolutely no change required for the port to work on your FreeBSD box. If you needed to change something, you will have to refer to the next section too. Writing the Makefile

The minimal Makefile would look something like this: # New ports collection makefile for: oneko # Version required: 1.1b # Date created: 5 December 1994 # Whom: asami # # $Id$ # DISTNAME= oneko-1.1b CATEGORIES= games MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/ MAINTAINER= asami@FreeBSD.ORG MAN1= oneko.1 MANCOMPRESSED= yes USE_IMAKE= yes .include

See if you can figure it out. Do not worry about the contents of the $Id$ line, it will be filled in automatically by CVS when the port is imported to our main ports tree. You can find a more detailed example in the section. Writing the description files

There are three description files that are required for any port, whether they actually package or not. They are COMMENT, DESCR, and PLIST, and reside in the pkg subdirectory. COMMENT

This is the one-line description of the port. Please do not include the package name (or version number of the software) in the comment. Here is an example: A cat chasing a mouse all over the screen. DESCR

This is a longer description of the port. One to a few paragraphs concisely explaining what the port does is sufficient. This is not a manual or an in-depth description on how to use or compile the port! Please be careful if you are copying from the README or manpage; too often they are not a concise description of the port or are in an awkward format (e.g. manpages have justified spacing). If the ported software has an official WWW homepage, you should list in here.

It is recommended that you sign the name at the end of this file, as in: This is a port of oneko, in which a cat chases a poor mouse all over the screen. : (etc.) http://www.oneko.org/ - Satoshi asami@cs.berkeley.edu PLIST

This file lists all the files installed by the port. It is also called the `packing list' because the package is generated by packing the files listed here. The pathnames are relative to the installation prefix (usually /usr/local or /usr/X11R6). If you are using the Here is a small example: bin/oneko lib/X11/app-defaults/Oneko lib/X11/oneko/cat1.xpm lib/X11/oneko/cat2.xpm lib/X11/oneko/mouse.xpm @dirrm lib/X11/oneko

Refer to the pkg_create(1) man page for details on the packing list. Note that you should list all the files, but not the name directories, in the list. Also, if the port creates directories for itself during installation, make sure to add It is recommended you keep all the filenames in this file sorted alphabetically. It will make verifying the changes when you upgrade the port much easier. Creating the checksum file

Just type `make makesum'. The ports make rules will automatically generate the file files/md5. Testing the port

You should make sure that the port rules do exactly what you want it to do, including packaging up the port. These are the important points you need to verify: your port can be installed multiple times using the your port after itself upon deinstall

The recommended ordering of tests is: make install make package make deinstall pkg_add `make package-name` make deinstall make reinstall make package Make sure there aren't any warnings issued in any of the Checking your port with portlint

Please use portlint to see if your port conforms to our guidelines. The program is part of the ports collection. In particular, you may want to check if the is in the right shape and the is named appropriately. Submitting the port

First, make sure you have read the section.

Now that you are happy with your port, the only thing remaining is to put it in the main FreeBSD ports tree and make everybody else happy about it too. We do not need your work/ directory or the pkgname.tgz package, so delete them now. Next, simply include the output of `shar `find port_dir`' in a bug report and send it with the send-pr(1) program (see for more information about send-pr). If the uncompressed port is larger than 20KB, you should compress it into a tarfile and use uuencode(1) before including it in the bug report (uuencoded tarfiles are acceptable even if the report is smaller than 20KB but are not preferred). Be sure to classify the bug report as category `ports' and class `change-request'. (Do not mark the report `confidential'!)

One more time, do not include the original source distfile, the work/ directory, or the package you built with `make package'!

Note: in the past, we asked you to upload new port submissions in our ftp site (:<

We will look at your port, get back to you if necessary, and put it in the tree. Your name will also appear in the list of `Additional FreeBSD contributors' on the FreeBSD Handbook and other files. Isn't that great?!? :) Slow Porting

Ok, so it was not that simple, and the port required some modifications to get it to work. In this section, we will explain, step by step, how to modify it to get it to work with the ports paradigm. How things work

First, this is the sequence of events which occurs when the user first types `make' in your port's directory, and you may find that having bsd.port.mk in another window while you read this really helps to understand it.

But do not worry if you do not really understand what bsd.port.mk is doing, not many people do... :> The fetch target is run. The fetch target is 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 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, it will save the file in ${DISTDIR} for future use and proceed. The extract target is run. It looks for your port's distribution file (typically a gzip'd tarball) in ${DISTDIR} and unpacks it into a temporary subdirectory specified by ${WRKDIR} (defaults to work). The patch target is run. First, any patches defined in ${PATCHFILES} are applied. Second, if any patches are found in ${PATCHDIR} (defaults to the patches subdirectory), they are applied at this time in alphabetical order. The configure target is run. This can do any one of many different things. If it exists, scripts/configure is run. If ${HAS_CONFIGURE} or ${GNU_CONFIGURE} is set, ${WRKSRC}/configure is run. If ${USE_IMAKE} is set, ${XMKMF} (default: `xmkmf -a') is run. The build target is run. This is responsible for descending into the ports' private working directory (${WRKSRC}) and building it. If ${USE_GMAKE} is set, GNU make will be used, otherwise the system make will be used.

The above are the default actions. In addition, you can define targets `pre-<something>' or `post-<something>', or put scripts with those names, in the scripts subdirectory, and they will be run before or after the default actions are done.

For example, if you have a post-extract target defined in your Makefile, and a file pre-build in the scripts subdirectory, the post-extract target will be called after the regular extraction actions, and the pre-build script will be executed before the default build rules are done. It is recommended that you use Makefile targets if the actions are simple enough, because it will be easier for someone to figure out what kind of non-default action the port requires.

The default actions are done by the bsd.port.mk targets `do-<something>'. For example, the commands to extract a port are in the target `do-extract'. If you are not happy with the default target, you can fix it by redefining the `do-<something>' target in your Makefile.

Note that the `main' targets (e.g., extract, configure, etc.) do nothing more than make sure all the stages up to that one is completed and call the real targets or scripts, and they are not intended to be changed. If you want to fix the extraction, fix do-extract, but never ever touch extract!

Now that you understand what goes on when the user types `make', let us go through the recommended steps to create the perfect port. Getting the original sources

Get the original sources (normally) as a compressed tarball (<foo>.tar.gz or <foo>.tar.Z) and copy it into ${DISTDIR}. Always use mainstream sources when and where you can.

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, you might want to put a copy on a reliable ftp or http server that you control (e.g., your home page). Make sure you set MASTER_SITES to reflect your choice.

If you cannot find somewhere convenient and reliable to put the distfile (note that if you are a FreeBSD committer, you can just put it in the public_html directory on freefall), we can `house' it ourselves by putting it on ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/LOCAL_PORTS/ as the last resort. Please refer to this location as ${MASTER_SITE_LOCAL}. Send mail to the &a.ports if you are not sure what to do.

If your port's distfile changes all the time for no good reason, consider putting the distfile in your home page and listing it as the first MASTER_SITES. This will prevent users from getting `checksum mismatch' errors, and also reduce the workload of maintainers of our ftp site. Also, if there is only one master site for the port, it is recommended that you house a backup at your site and list it as the second MASTER_SITES.

If your port requires some additional `patches' that are available on the Internet, fetch them too and put them in ${DISTDIR}. Do not worry if they come from site other than where you got the main source tarball, we have a way to handle these situations (see the description of below). Modifying the port

Unpack a copy of the tarball in a private directory and make whatever changes are necessary to get the port to compile properly under the current version of FreeBSD. Keep careful track of everything you do, as you will be automating the process shortly. Everything, including the deletion, addition or modification of files should be doable using an automated script or patch file when your port is finished.

If your port requires significant user interaction/customization to compile or install, you should take a look at one of Larry Wall's classic Configure scripts and perhaps do something similar yourself. The goal of the new ports collection is to make each port as `plug-and-play' as possible for the end-user while using a minimum of disk space.

Note: Unless explicitly stated, patch files, scripts, and other files you have created and contributed to the FreeBSD ports collection are assumed to be covered by the standard BSD copyright conditions. Patching

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. 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 -- these are done in alphabetical order, thus `aa' first, `ab' second and so on. These files should be stored in ${PATCHDIR}, from where they will be automatically applied. All patches should be relative to ${WRKSRC} (generally the directory your port's tarball unpacks itself into, that being where the build is done). To make fixes and upgrades easier, you should avoid having more than one patch fix the same file (e.g., patch-aa and patch-ab both changing ${WRKSRC}/foobar.c). Configuring

Include any additional customization commands to your configure script and save it in the `scripts' subdirectory. As mentioned above, you can also do this as Makefile targets and/or scripts with the name pre-configure or post-configure. Handling user input

If your port requires user input to build, configure or install, then set IS_INTERACTIVE in your Makefile. This will allow `overnight builds' to skip your port if the user sets the variable BATCH in his environment (and if the user sets the variable INTERACTIVE, then only those ports requiring interaction are built).

It is also recommended that if there are reasonable default answers to the questions, you check the Configuring the Makefile

Configuring the Makefile is pretty simple, and again we suggest that you look at existing examples before starting. Also, there is a in this handbook, so take a look and please follow the ordering of variables and sections in that template to make your port easier for others to read.

Now, consider the following problems in sequence as you design your new Makefile: The original source

Does it live in ${DISTDIR} as a standard gzip'd tarball? If so, you can go on to the next step. If not, you should look at overriding any of the ${EXTRACT_CMD}, ${EXTRACT_BEFORE_ARGS}, ${EXTRACT_AFTER_ARGS}, ${EXTRACT_SUFX}, or ${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.)

In the worst case, you can simply create your own `do-extract' target to override the default, though this should be rarely, if ever, necessary. DISTNAME

You should set ${DISTNAME} to be the base name of your port. The default rules expect the distribution file list (${DISTFILES}) to be named ${DISTNAME}${EXTRACT_SUFX} which, if it is a normal tarball, is going to be something like: foozolix-1.0.tar.gz for a setting of `DISTNAME=foozolix-1.0'. The default rules also expect the tarball(s) to extract into a subdirectory called work/${DISTNAME}, e.g. work/foozolix-1.0/ All this behavior can be overridden, of course; it simply represents the most common time-saving defaults. For a port requiring multiple distribution files, simply set ${DISTFILES} explicitly. If only a subset of ${DISTFILES} are actual extractable archives, then set them up in ${EXTRACT_ONLY}, which will override the ${DISTFILES} list when it comes to extraction, and the rest will be just left in ${DISTDIR} for later use. PKGNAME

If ${DISTNAME} does not conform to our , you should set the ${PKGNAME} variable to something better. See the abovementioned guideline for more details. 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 names of these subdirectories are specified by the variable ${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 and pick the ones that are suitable for your port.

This list also determines where in the ports tree the port is imported. If you put more than one category here, it is assumed that the port files will be put in the subdirectory with the name in the first category. See the section for more discussion about how to pick the right categories.

If your port truly belongs to something that is different from all the existing ones, you can even create a new category name. In that case, please send mail to the &a.ports; to propose a new category.

Note that there is no error checking for category names; `make package' will happily create a new directory if you mistype the category name, so be careful! MASTER_SITES

Record the directory part of the ftp/http-URL pointing at 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} if they cannot find it already on the system.

It is recommended that you put multiple sites on this list, preferably from different continents. This will safeguard against wide-area network problems, and we are even planning to add support for automatically determining the closest master site and fetching from there!

If the original tarball is part of one of the following popular archives: X-contrib, GNU, Perl CPAN, TeX CTAN, or Linux Sunsite, you refer to those sites in an easy compact form using MASTER_SITE_XCONTRIB, MASTER_SITE_GNU, MASTER_SITE_PERL_CPAN, MASTER_SITE_TEX_CTAN, and MASTER_SITE_SUNSITE. Simply set MASTER_SITE_SUBDIR to the path with in the archive. Here is an example: MASTER_SITES= ${MASTER_SITE_XCONTRIB} MASTER_SITE_SUBDIR= applications

The user can also set the MASTER_SITE_* variables in /etc/make.conf to override our choices, and use their favorite mirrors of these popular archives instead. PATCHFILES

If your port requires some additional patches that are 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 extra pathnames, set ${PATCH_DIST_STRIP} accordingly. For instance, if all the pathnames in the patch has an extra `foozolix-1.0/' in front of the filenames, then set `PATCH_DIST_STRIP=-p1'.

Do not worry if the patches are compressed, they will be decompressed automatically if the filenames end with `.gz' or `.Z'.

If the patch is distributed with some other files, such as documentation, in a gzip'd tarball, you can't just use ${PATCHFILES}. If that is the case, add the name and the location of the patch tarball to ${DISTFILES} and ${MASTER_SITES}. Then, from the pre-patch target, apply the patch either by running the patch command from there, or copying the patch file into the ${PATCHDIR} directory and calling it patch-<xx>. (Note the tarball will have been extracted alongside the regular source by then, so there is no need to explicitly extract it if it is a regular gzip'd or compress'd tarball.) If you do the latter, take extra care not to overwrite something that already exists in that directory. Also do not forget to add a command to remove the copied patch in the pre-clean target. MAINTAINER

Set your mail-address here. Please. :)

For detailed description of the responsibility of maintainers, refer to section. 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. There are also some pre-supported dependency variables for common cases, plus a few more to control the behavior of dependencies. LIB_DEPENDS

This variable specifies the shared libraries this port depends on. It is a list of `lib:dir[:target]' tuples where lib is the name of the shared library, and dir is the directory in which to find it in case it is not available, and LIB_DEPENDS= jpeg.9:${PORTSDIR}/graphics/jpeg:install will check for a shared jpeg library with major version 9, and descend into the graphics/jpeg subdirectory - of your ports tree to build and package it if it is not + of your ports tree to build and install it if it is not found. The `${DEPENDS_TARGET} (which defaults to `lib part is an argument given to `ldconfig -r | grep -wF'. There shall be no regular expressions in this variable. The dependency is checked twice, once from within the 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[:target]' tuples where path is the name of the executable or file, and dir is the directory in which to find it in case it is not available, and `path starts with a slash (/), it is treated as a file or directory and its existence is tested with `test -e'; otherwise, it is assumed to be an executable, and `which -s' is used to determine if the program exists in the user's search path.

For example, RUN_DEPENDS= ${PREFIX}/etc/innd:${PORTSDIR}/news/inn \ wish8.0:${PORTSDIR}/x11-toolkits/tk80 will check if the file or directory `/usr/local/etc/innd' exists, and build and install it from the news/inn subdirectory of the ports tree if it is not found. It will also see if an executable called `wish8.0' is in your search path, and descend into the x11-toolkits/tk80 subdirectory of your ports tree to build and install it if it is not found. (Note that in this case, `innd' is actually an executable; if an executable is in a place that is not expected to be in a normal user's search path, you should use the full pathname.) The dependency is checked from within the install 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. The `${DEPENDS_TARGET}. BUILD_DEPENDS

This variable specifies executables or files this port requires to build. Like RUN_DEPENDS, it is a list of `path:dir[:target]' tuples. For example, BUILD_DEPENDS= unzip:${PORTSDIR}/archivers/unzip will check for an executable called `unzip', and descend into the archivers/unzip subdirectory of your ports tree to build and install it if it is not found. Note that `build' here means everything from extracting to compilation. The dependency is checked from within the extract target. The `${DEPENDS_TARGET}. FETCH_DEPENDS

This variable specifies executables or files this port requires to fetch. Like the previous two, it is a list of `path:dir[:target]' pairs. For example, FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 will check for an executable called `ncftp2', and descend into the net/ncftp2 subdirectory of your ports tree to build and install it if it is not found. The dependency is checked from within the fetch target. The `${DEPENDS_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 in addition to having them installed, then use this variable. This is a list of `dir[:target]', as there is nothing to check, unlike the previous four. The `${DEPENDS_TARGET}. Common dependency variables

Define `USE_XLIB=yes' if your port requires the X Window System to be installed (it is implied by USE_IMAKE). Define `USE_GMAKE=yes' if your port requires GNU USE_AUTOCONF=yes' if your port requires GNU autoconf to be run. Define `USE_QT=yes' if your port uses the latest qt toolkit. Use `USE_PERL5=yes' if your port requires version 5 of the perl language. (The last is especially important since some versions of FreeBSD has perl5 as part of the base system while others don't.) Notes on dependencies

As mentioned above, the default target to call when a dependency is required is ${DEPENDS_TARGET}. It defaults to `*_DEPENDS variables instead of redefining ${DEPENDS_TARGET}.

When you type `make clean', its dependencies are automatically cleaned too. If you do not wish this to happen, define the variable To depend on another port unconditionally, it is customary to use the string ` BUILD_DEPENDS= /nonexistent:${PORTSDIR}/graphics/jpeg:extract will always descend to the JPEG port and extract it.

Do not use ` Building mechanisms

If your package uses GNU make, set `USE_GMAKE=yes'. If your package uses configure, set `HAS_CONFIGURE=yes'. If your package uses GNU GNU_CONFIGURE=yes' (this implies --prefix=${PREFIX}' for GNU ${CONFIGURE_ARGS}. If your package uses GNU USE_AUTOCONF=yes'. This implies 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 `XMKMF=xmkmf'. 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. :>

If your port's source Makefile has something else than `all' as the main build target, set ${ALL_TARGET} accordingly. Same goes for `install' and ${INSTALL_TARGET}. Special Considerations

There are some more things you have to take into account when you create a port. This section explains the most common of those.

If your port installs a shared library, add a post-install target to your Makefile that runs `${LDCONFIG} -m' on the directory where the new library is installed (usually ${PREFIX}/lib) to register it into the shared library cache.

Also, add a matching `@exec /sbin/ldconfig -m'/`@unexec /sbin/ldconfig -R' pair to your pkg/PLIST file so that a user who installed the package can start using the shared library immediately and deinstallation will not cause the system to still believe the library is there. These lines should immediately follow the line for the shared library itself, as in: lib/libtcl80.so.1 @exec /sbin/ldconfig -m %D/lib @unexec /sbin/ldconfig -R

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 the contents of /usr/lib only, and will royally screw up the user's machine ("Help, xinit does not run anymore after I install this port!"). Anybody who does this will be shot and cut into 65,536 pieces by a rusty knife and have his liver chopped out by a bunch of crows and will eternally rot to death in the deepest bowels of hell (not necessarily in that order).... ELF support

Since FreeBSD is moving to ELF from 3.0-release onwards, we need to convert many ports that build shared libraries to support ELF. Complicating this task is that a 3.0 system can run as both ELF and a.out, and that there will be one more release (2.2.8) from the 2.2 branch. Below are the guidelines on how to convert a.out only ports to support both a.out and ELF compilation.

Some part of this list is only applicable during the conversion, but will be left here for awhile for reference in case you have come across some old port you wish to upgrade. Moving a.out libraries out of the way

A.out libraries should be moved out of /usr/local/lib and similar to an `src/Makefile (called from ` Format

The ports tree will build packages in the format the machine is in. This means a.out for 2.2 and a.out or ELF for 3.0 depending on what `objformat` returns. Also, once users move a.out libraries to a subdirectory, building a.out libraries will be unsupported. (I.e., it may still work if you know what you are doing, but you are on your own.)

Note: if a port only works for a.out, set PORTOBJFORMAT

PORTOBJFORMAT=${PORTOBJFORMAT}'. (See comment on The variable is set using this line: PORTOBJFORMAT!= test -x /usr/bin/objformat && /usr/bin/objformat || echo aout in Ports' make processes should use this variable to decide what to do. However, if the port's Building shared libraries

The following are differences in handling shared libraries for a.out and ELF. Shared library versionsAn ELF shared library should be called "Linker command linesAssuming `cc -shared' is used rather than `-Wl,-soname,libfoo.so.M' on the command line for ELF.

You need to install a symlink libfoo.so -> libfoo.so.N to make ELF linkers happy. Since it should be listed in

All port Makefiles are edited to remove minor numbers from foo\\.1\\.\\(33|40\\)' -> `foo.2'.) They will be matched using `grep -wF'.

In cases where you really need to install shlibs with two versions on an ELF system or those with one version on an a.out system (for instance, ports that install compatibility libraries for other operating systems), define the variable

The ${SETENV} OBJFORMAT=${PORTOBJFORMAT} ${LDCONFIG} -m .... and in @exec /usr/bin/env OBJFORMAT=%%PORTOBJFORMAT%% /sbin/ldconfig -m ... @unexec /usr/bin/env OBJFORMAT=%%PORTOBJFORMAT%% /sbin/ldconfig -R This is to ensure that the correct

If your port needs to build slightly different versions of packages by having a variable (for instance, resolution or paper size) take different values, create one subdirectory per package to make it easier for users to see what to do, but try to share as many files as possible between ports. Typically you only need a very short Makefile in all but one of the directories if you use variables cleverly. In the sole Makefiles, you can use ${MASTERDIR} to specify the directory where the rest of the files are. Also, use a variable as part of so the packages will have different names.

This will be best demostrated by an example. This is part of japanese/xdvi300/Makefile: : PKGNAME= ja-xdvi${RESOLUTION}-17 : # default RESOLUTION?= 300 .if ${RESOLUTION} != 118 && ${RESOLUTION} != 240 && \ ${RESOLUTION} != 300 && ${RESOLUTION} != 400 @${ECHO} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\"" @${ECHO} "Possible values are: 118, 240, 300 (default) and 400." @${FALSE} .endif japanese/xdvi300 also has all the regular patches, package files, etc. If you type `As for other resolutions, this is the xdvi118/Makefile (minus the comments): RESOLUTION= 118 MASTERDIR= ${.CURDIR}/../xdvi300 .include "${MASTERDIR}/Makefile" (xdvi240/Makefile and xdvi400/Makefile are similar). The ${MASTERDIR} definition tells ${PATCHDIR} and ${PKGDIR} are to be found under xdvi300/Makefile and the port will be built with resolution set to 118. Shared library versions

First, please read our to understand what to do with shared library versions in general. Do not blindly assume software authors know what they are doing; many of them do not. It is very important that these details are carefully considered, as we have quite a unique situation where we are trying to have dozens of potentially incompatible software pairs co-exist. Careless port imports have caused great trouble regarding shared libraries in the past (ever wondered why the port However, if there is a port which is a different version of the same software already in the tree, the situation is much more complex. In short, the FreeBSD implementation does not allow the user to specify to the linker which version of shared library to link against (the linker will always pick the highest numbered version). This means, if there is a Manpages

The pkg/PLIST (this means you must for more). It also makes the install stage automatically compress or uncompress manpages depending on the setting of /etc/make.conf.

To specify whether the manpages are compressed upon installation, use the If your port anchors its man tree somewhere other than PREFIX, you can use the MANPREFIX to set it. Also, if only manpages in certain sections go in a non-standard place, such as some Perl modules ports, you can set individual man paths using MANsectPREFIX (where sect is one of 1-9, L or N).

If your manpages go to language-specific subdirectories, set the name of the languages to "" (i.e., English only).

Here is an example that puts it all together. MAN1= foo.1 MAN3= bar.3 MAN4= baz.4 MANLANG= "" ja MAN3PREFIX= ${PREFIX}/share/foobar MANCOMPRESSED= yes states that six files ${PREFIX}/man/man1/foo.1.gz ${PREFIX}/man/ja/man1/foo.1.gz ${PREFIX}/share/foobar/man/man3/bar.3.gz ${PREFIX}/share/foobar/man/ja/man3/bar.3.gz ${PREFIX}/man/man4/baz.4.gz ${PREFIX}/man/ja/man4/baz.4.gz are installed by this port. Ports that require Motif

There are many programs that require a Motif library (available from several commercial vendors, while there is a free clone reported to be able to run many applications in x11-toolkits/lesstif) to compile. Since it is a popular toolkit and their licenses usually permit redistribution of statically linked binaries, we have made special provisions for handling ports that require Motif in a way that we can easily compile binaries linked either dynamically (for people who are compiling from the port) or statically (for people who distribute packages). 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 referenced in the Makefile or Imakefile.

There are two common cases: If the port refers to the Motif library as `-lXm' in its Makefile or Imakefile, simply substitute `${MOTIFLIB}' for it. If the port uses `XmClientLibs' in its Imakefile, change it to `${MOTIFLIB} ${XTOOLLIB} ${XLIB}'.

Note that ${MOTIFLIB} (usually) expands to `-L/usr/X11R6/lib -lXm' or `/usr/X11R6/lib/libXm.a', so there is no need to add `-L' or `-l' in front. X11 fonts

If your port installs fonts for the X window system, put them in ${X11BASE}/lib/X11/fonts/local. This directory is new to XFree86 release 3.3.3. If it does not exist, please create it, and print out a message urging the user to update their XFree86 to 3.3.3 or newer, or at least add this directory to the font path in /etc/XF86Config. Info files

The new version of texinfo (included in 2.2.2-RELEASE and onwards) contains a utility called `&dollar{PREFIX}/info/dir file. (Sorry for the length of this section, but it is imperative to weave all the info files together. If done correctly, it will produce a beautiful listing, so please bear with me! First, this is what you (as a porter) need to know: % install-info --help install-info [OPTION]... [INFO-FILE [DIR-FILE]] Install INFO-FILE in the Info directory file DIR-FILE. Options: --delete Delete existing entries in INFO-FILE; don't insert any new entries. : --entry=TEXT Insert TEXT as an Info directory entry. : --section=SEC Put this file's entries in section SEC of the directory. :

Note that this program will not actually Here's a seven-step procedure to convert ports to use editors/emacs as an example. Look at the texinfo sources and make a patch to insert --- ./man/vip.texi.org Fri Jun 16 15:31:11 1995 +++ ./man/vip.texi Tue May 20 01:28:33 1997 @@ -2,6 +2,10 @@ @setfilename ../info/vip @settitle VIP +@dircategory The Emacs editor and associated tools +@direntry +* VIP: (vip). A VI-emulation for Emacs. +@end direntry @iftex @finalout :

The format should be self-explanatory. Many authors leave a Note that you can put only one info entry per file because of a bug in `install-info --delete' that deletes only the first entry if you specify multiple entries in the You can give the three places (japanese/skk for examples on how to do this). Go back to the port directory and do a `make clean; make' and verify that the info files are regenerated from the texinfo sources. Since the texinfo sources are newer than the info files, they should be rebuilt when you type --- ./Makefile.in.org Mon Aug 19 21:12:19 1996 +++ ./Makefile.in Tue Apr 15 00:15:28 1997 @@ -184,7 +184,7 @@ # Subdirectories to make recursively. `lisp' is not included # because the compiled lisp files are part of the distribution # and you cannot remake them without installing Emacs first. -SUBDIR = lib-src src +SUBDIR = lib-src src man # The makefiles of the directories in $SUBDIR. SUBDIR_MAKEFILES = lib-src/Makefile man/Makefile src/Makefile oldXMenu/Makefile lwlib/Makefile --- ./man/Makefile.in.org Thu Jun 27 15:27:19 1996 +++ ./man/Makefile.in Tue Apr 15 00:29:52 1997 @@ -66,6 +66,7 @@ ${srcdir}/gnu1.texi \ ${srcdir}/glossary.texi +all: info info: $(INFO_TARGETS) dvi: $(DVI_TARGETS)

The second hunk was necessary because the default target in the /usr/share/info (that patch is not shown here). If there is a place in the --- ./Makefile.in.org Mon Aug 19 21:12:19 1996 +++ ./Makefile.in Mon Apr 14 23:38:07 1997 @@ -368,14 +368,8 @@ if [ `(cd ${srcdir}/info && /bin/pwd)` != `(cd ${infodir} && /bin/pwd)` ]; \ then \ (cd ${infodir}; \ - if [ -f dir ]; then \ - if [ ! -f dir.old ]; then mv -f dir dir.old; \ - else mv -f dir dir.bak; fi; \ - fi; \ cd ${srcdir}/info ; \ - (cd $${thisdir}; ${INSTALL_DATA} ${srcdir}/info/dir ${infodir}/dir); \ - (cd $${thisdir}; chmod a+r ${infodir}/dir); \ for f in ccmode* cl* dired-x* ediff* emacs* forms* gnus* info* message* mh-e* sc* vip*; do \ (cd $${thisdir}; \ ${INSTALL_DATA} ${srcdir}/info/$$f ${infodir}/$$f; \ chmod a+r ${infodir}/$$f); \ (This step is only necessary if you are modifying an existing port.) Take a look at pkg/PLIST and delete anything that is trying to patch up info/dir. They may be in pkg/INSTALL or some other file, so search extensively. Index: pkg/PLIST =================================================================== RCS file: /usr/cvs/ports/editors/emacs/pkg/PLIST,v retrieving revision 1.15 diff -u -r1.15 PLIST --- PLIST 1997/03/04 08:04:00 1.15 +++ PLIST 1997/04/15 06:32:12 @@ -15,9 +15,6 @@ man/man1/emacs.1.gz man/man1/etags.1.gz man/man1/ctags.1.gz -@unexec cp %D/info/dir %D/info/dir.bak -info/dir -@unexec cp %D/info/dir.bak %D/info/dir info/cl info/cl-1 info/cl-2 Add a Index: Makefile =================================================================== RCS file: /usr/cvs/ports/editors/emacs/Makefile,v retrieving revision 1.26 diff -u -r1.26 Makefile --- Makefile 1996/11/19 13:14:40 1.26 +++ Makefile 1997/05/20 10:25:09 1.28 @@ -20,5 +20,11 @@ post-install: .for file in emacs-19.34 emacsclient etags ctags b2m strip ${PREFIX}/bin/${file} .endfor + if [ ! -f ${PREFIX}/info/dir ]; then \ + ${SED} -ne '1,/Menu:/p' /usr/share/info/dir > ${PREFIX}/info/dir; \ + fi +.for info in emacs vip viper forms gnus mh-e cl sc dired-x ediff ccmode + install-info ${PREFIX}/info/${info} ${PREFIX}/info/dir +.endfor .include

Do not use anything other than /usr/share/info/dir and the above command to create a new info file. In fact, I'd add the first three lines of the above patch to Edit info/dir with Index: pkg/PLIST =================================================================== RCS file: /usr/cvs/ports/editors/emacs/pkg/PLIST,v retrieving revision 1.15 diff -u -r1.15 PLIST --- PLIST 1997/03/04 08:04:00 1.15 +++ PLIST 1997/05/20 10:25:12 1.17 @@ -16,7 +14,15 @@ man/man1/etags.1.gz man/man1/ctags.1.gz +@unexec install-info --delete %D/info/emacs %D/info/dir : +@unexec install-info --delete %D/info/ccmode %D/info/dir info/cl info/cl-1 @@ -87,6 +94,18 @@ info/viper-3 info/viper-4 +@exec [ -f %D/info/dir ] || sed -ne '1,/Menu:/p' /usr/share/info/dir > %D/info/dir +@exec install-info %D/info/emacs %D/info/dir : +@exec install-info %D/info/ccmode %D/info/dir libexec/emacs/19.34/i386--freebsd/cvtmail libexec/emacs/19.34/i386--freebsd/digest-doc

Note that the `@unexec install-info --delete' commands have to be listed before the info files themselves so they can read the files. Also, the `@exec install-info' commands have to be after the info files and the and admire your work. The

There are some tricks we haven't mentioned yet about the

If your port needs execute commands when the binary package is installed with INSTALL ${PKGNAME} PRE-INSTALL' and the second time as `INSTALL ${PKGNAME} POST-INSTALL'. `$2' can be tested to determine which mode the script is being run in. The `PKG_PREFIX' environmental variable will be set to the package installation directory. See man pkg_add(1) for additional information. Note, that this script is not run automatically if you install the port with `make install'. If you are depending on it being run, you will have to explicitly call it on your port's Makefile.

If your port needs to determine if it should install or not, you can create a pkg/REQ ``requirements'' script. It will be invoked automatically at installation/deinstallation time to determine whether or not installation/deinstallation should proceed. Changing

Some ports, particularly the p5- ports, need to change their If you need to make other substitutions, you can set the PLIST_SUB variable with a list of VAR=VALUE pairs and instances of `%%VAR%%' will be substituted with ` OCTAVE_VERSION= 2.0.13 PLIST_SUB= OCTAVE_VERSION=${OCTAVE_VERSION} in the %%OCTAVE_VERSION%% wherever the version shows up in This substitution (as well as addition of any ) will be done between the ${PLIST} and writing to ${TMPPLIST} (default: ${WRKDIR}/.PLIST.mktmp). So if your port builds ${PLIST} on the fly, do so in or before Licensing Problems

Some software packages have restrictive licenses or can be 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.

Note that it is your responsibility as a porter to read the licensing terms of the software and make sure that the FreeBSD project will not be held accountable of violating them by redistributing the source or compiled binaries either via ftp or CD-ROM. If in doubt, please contact the &a.ports;.

There are two variables you can set in the Makefile to handle the situations that arise frequently: If the port has a `do not sell for profit' type of license, set the variable NO_CDROM to the string describing the reason why. We will make sure such ports won't go into the CD-ROM come release time. The distfile and package will still be available via ftp. If the resulting package needs to be built uniquely for each site, or the resulting binary package can't be distributed due to licensing, set the variable NO_PACKAGE to the string describing the reason why. We will make sure such packages won't go on the ftp site, nor into the CD-ROM come release time. The distfile will still be included on both however. If the port has legal restrictions on who can use it (e.g., crypto stuff) or has a `no commercial use' license, set the variable RESTRICTED to be the string describing the reason why. For such ports, the distfiles/packages will not be available even from our ftp sites.

Note: The GNU General Public License (GPL), both version 1 and 2, should not be a problem for ports.

Note: If you are a committer, make sure you update the ports/LEGAL file too. 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 ports-current directory of the ftp mirror sites.

The next step is to send a mail to the maintainer, if one is listed in the port's Makefile. That person may already be working on an upgrade, or have a reason to not upgrade the port right now (because of, for example, stability problems of the new version).

If the maintainer asks you to do the upgrade or there isn't any such person to begin with, please make the upgrade and send the recursive diff (either unified or context diff is fine, but port committers appear to prefer unified diff more) of the new and old ports directories to us (e.g., if your modified port directory is called `superedit' and the original as in our tree is `superedit.bak', then send us the result of `diff -ruN superedit.bak superedit'). Please examine the output to make sure all the changes make sense. The best way to send us the diff is by including it to send-pr(1) (category `ports'). Please mention any added or deleted files in the message, as they have to be explicitly specified to CVS when doing a commit. If the diff is more than about 20KB, please compress and uuencode it; otherwise, just include it in as is in the PR. Do's and Dont's

Here is a list of common do's and dont's that you encounter during the porting process. You should check your own port against this list, but you can also check ports in the PR database that others have submitted. Submit any comments on ports you check as described in . Checking ports in the PR database will both make it faster for us to commit them, and prove that you know what you are doing. Strip Binaries

Do strip binaries. If the original source already strips the binaries, fine; otherwise you should add a post-install rule to do it yourself. Here is an example: post-install: strip ${PREFIX}/bin/xdl

Use the file command on the installed executable to check whether the binary is stripped or not. If it does not say `not stripped', it is stripped. INSTALL_* macros

Do use the macros provided in bsd.port.mk to ensure correct modes and ownership of files in your own *-install targets. They are: ${INSTALL_PROGRAM} is a command to install binary executables. ${INSTALL_SCRIPT} is a command to install executable scripts. ${INSTALL_DATA} is a command to install sharable data. ${INSTALL_MAN} is a command to install manpages and other documentation (it doesn't compress anything).

These are basically the install command with all the appropriate flags. See below for an example on how to use them. Differentiating operating systems and OS versions

You may come across code that needs modifications or conditional compilation based upon what version of UNIX it is running under. If you need to make such changes to the code for conditional compilation, make sure you make the changes as general as possible so that we can back-port code to FreeBSD 1.x systems and cross-port to other BSD systems such as 4.4BSD from CSRG, BSD/386, 386BSD, NetBSD, and OpenBSD.

The preferred way to tell 4.3BSD/Reno (1990) and newer versions of the BSD code apart is by using the `BSD' macro defined in <sys/param.h>. Hopefully that file is already included; if not, add the code: #if (defined(__unix__) || defined(unix)) && !defined(USG) #include #endif

to the proper place in the .c file. We believe that every system that defines these to symbols has sys/param.h. If you find a system that doesn't, we would like to know. Please send mail to the &a.ports;.

Another way is to use the GNU Autoconf style of doing this: #ifdef HAVE_SYS_PARAM_H #include #endif Don't forget to add -DHAVE_SYS_PARAM_H to the CFLAGS in the Makefile for this method. Once you have <sys/param.h> included, you may use: #if (defined(BSD) && (BSD >= 199103)) to detect if the code is being compiled on a 4.3 Net2 code base or newer (e.g. FreeBSD 1.x, 4.3/Reno, NetBSD 0.9, 386BSD, BSD/386 1.1 and below). Use: #if (defined(BSD) && (BSD >= 199306)) to detect if the code is being compiled on a 4.4 code base or newer (e.g. FreeBSD 2.x, 4.4, NetBSD 1.0, BSD/386 2.0 or above). The value of the BSD macro is 199506 for the 4.4BSD-Lite2 code base. This is stated for informational purposes only. It should not be used to distinguish between version of FreeBSD based only on 4.4-Lite vs. versions that have merged in changes from 4.4-Lite2. The __FreeBSD__ macro should be used instead.

Use sparingly: __FreeBSD__ is defined in all versions of FreeBSD. Use it if the change you are making ONLY affects FreeBSD. Porting gotchas like the use of sys_errlist[] vs strerror() are Berkeleyisms, not FreeBSD changes. In FreeBSD 2.x, __FreeBSD__ is defined to be 2. In earlier versions, it is 1. Later versions will bump it to match their major version number. If you need to tell the difference between a FreeBSD 1.x system and a FreeBSD 2.x or 3.x system, usually the right answer is to use the BSD macros described above. If there actually is a FreeBSD specific change (such as special shared library options when using `ld') then it is OK to use __FreeBSD__ and `#if __FreeBSD__ > 1' to detect a FreeBSD 2.x and later system. If you need more granularity in detecting FreeBSD systems since 2.0-RELEASE you can use the following: #if __FreeBSD__ >= 2 #include # if __FreeBSD_version >= 199504 /* 2.0.5+ release specific code here */ # endif #endif __FreeBSD_version values: 2.0-RELEASE: 199411 2.1-current's: 199501, 199503 2.0.5-RELEASE: 199504 2.2-current before 2.1: 199508 2.1.0-RELEASE: 199511 2.2-current before 2.1.5: 199512 2.1.5-RELEASE: 199607 2.2-current before 2.1.6: 199608 2.1.6-RELEASE: 199612 2.1.7-RELEASE: 199612 2.2-RELEASE: 220000 2.2.1-RELEASE: 220000 (yes, no change) 2.2-STABLE after 2.2.1-RELEASE: 220000 (yes, still no change) 2.2-STABLE after texinfo-3.9: 221001 2.2-STABLE after top: 221002 2.2.2-RELEASE: 222000 2.2-STABLE after 2.2.2-RELEASE: 222001 2.2.5-RELEASE: 225000 2.2-STABLE after 2.2.5-RELEASE: 225001 2.2-STABLE after ldconfig -R merge: 225002 2.2.6-RELEASE: 226000 2.2.7-RELEASE: 227000 2.2-STABLE after 2.2.7-RELEASE: 227001 2.2-STABLE after semctl(2) change: 227002 2.2.8-RELEASE: 228000 2.2-STABLE after 2.2.8-RELEASE: 228001 3.0-current before mount(2) change: 300000 3.0-current after mount(2) change: 300001 3.0-current after semctl(2) change: 300002 3.0-current after ioctl arg changes: 300003 3.0-current after ELF conversion: 300004 3.0-RELEASE: 300005 3.0-current after 3.0-RELEASE: 300006 (Note that 2.2-STABLE sometimes identifies itself as "2.2.[5678]-STABLE" after the 2.2.5-RELEASE.) The pattern used to be year followed by the month, but we decided to change it to a more straightforward major/minor system starting from 2.2. This is because the parallel development on several branches made it infeasible to classify the releases simply by their real release dates. (Note that if you are making a port now, you don't have to worry about old -current's; they are listed here just for your reference.)

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 you should do so too. Writing something after

Do not write anything after the `.include <bsd.port.mk>' line. It usually can be avoided by including &dollar{ARCH} The archetecture, as returned by `uname -m' (e.g., `i386'). &dollar{OPSYS} The operating system type, as returned by `uname -s' (e.g., `FreeBSD'). &dollar{OSREL} The release version of the operating system (e.g., `2.1.5', `2.2.7'). &dollar{OSVERSION} The numeric version of the operating system, same as above. &dollar{PORTOBJFORMAT} The object format of the system (`aout' or `elf'). &dollar{LOCALBASE} The base of the `local' tree (e.g., `/usr/local/'). &dollar{X11BASE} The base of the `X11' tree (e.g., `/usr/X11R6/'). &dollar{PREFIX} Where the port installs itself (see ).

Note: if you have to define the variables # no need to compile lang/perl5 if perl5 is already in system .if ${OSVERSION} > 300003 BROKEN= perl is in system .endif # only one shlib version number for ELF .if ${PORTOBJFORMAT} == "elf" TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR} .else TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR}.${SHLIB_MINOR} .endif # software already makes link for ELF, but not for a.out post-install: .if ${PORTOBJFORMAT} == "aout" ${LN} -sf liblinpack.so.1.0 ${PREFIX}/lib/liblinpack.so .endif 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. This can be done, like the previous item, in the post-install target.

Create a new directory for your port. The directory name 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, you can use the whole ${PKGNAME}.

Make the installation dependent to the variable NOPORTDOCS so that users can disable it in /etc/make.conf, like this: post-install: .if !defined(NOPORTDOCS) ${MKDIR} ${PREFIX}/share/doc/xv ${INSTALL_MAN} ${WRKSRC}/docs/xvdocs.ps ${PREFIX}/share/doc/xv .endif

Do not forget to add them to pkg/PLIST too! (Do not worry about NOPORTDOCS here; there is currently no way for the packages to read variables from /etc/make.conf.)

Also, you can use the pkg/MESSAGE file to display messages upon installation. See the section for details. DIST_SUBDIR

Do not let your port clutter /usr/ports/distfiles. If 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 (${PKGNAME} without the version part should work fine). This will change ${DISTDIR} from the default /usr/ports/distfiles to /usr/ports/distfiles/${DIST_SUBDIR}, and in effect puts everything that is required for your port into that subdirectory.

It will also look at the subdirectory with the same name on the backup master site at ftp.freebsd.org. (Setting ${DISTDIR} explicitly in your Makefile will not accomplish this, so please use ${DIST_SUBDIR}.)

Note this does not affect the ${MASTER_SITES} you define in your Makefile. 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 will fail. RCS strings are surrounded by dollar (`$') signs, and typically start with `$Id' or `$RCS'. 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 unnecessary junk in there. In particular, diffs between two backup files, Makefiles when the port uses Imake or GNU Also, if you had to delete a file, then you can do it in the post-extract target rather than as part of the patch. Once you are happy with the resulting diff, please split it up into one source file per patch file. PREFIX

Do try to make your port install relative to ${PREFIX}. (The value of this variable will be set to ${LOCALBASE} (default /usr/local), unless ${USE_X_PREFIX} or ${USE_IMAKE} is set, in which case it will be ${X11BASE} (default /usr/X11R6).)

Not hard-coding `/usr/local' or `/usr/X11R6' anywhere in the source will make the port much more flexible and able to cater to the needs of other sites. For X ports that use imake, this is automatic; otherwise, this can often be done by simply replacing the occurrences of `/usr/local' (or `/usr/X11R6' for X ports that do not use imake) in the various scripts/Makefiles in the port to read `${PREFIX}', as this variable is automatically passed down to every stage of the build and install processes.

Do not set USE_X_PREFIX unless your port truly requires it (i.e. it links against X libs or it needs to reference files in ${X11BASE}).

The variable ${PREFIX} can be reassigned in your Makefile or in the user's environment. However, it is strongly discouraged for individual ports to set this variable explicitly in the Makefiles.

Also, refer to programs/files from other ports with the variables mentioned above, not explicit pathnames. For instance, if your port requires a macro PAGER to be the full pathname of less, use the compiler flag: -DPAGER=\"${PREFIX}/bin/less\" or -DPAGER=\"${LOCALBASE}/bin/less\" if this is an X port, instead of -DPAGER=\"/usr/local/bin/less\". This way it will have a better chance of working if the system administrator has moved the whole `/usr/local' tree somewhere else. 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 incorrect. Also, many ports put everything except binaries, header files and manual pages in the a subdirectory of `lib', which does not bode well with the BSD paradigm. Many of the files should be moved to one of the following: `etc' (setup/configuration files), `libexec' (executables started internally), `sbin' (executables for superusers/managers), `info' (documentation for info browser) or `share' (architecture independent files). See man hier(7) for details, the rule governing /usr pretty much applies to /usr/local too. The exception are ports dealing with USENET `news'. They may use ${PREFIX}/news as a destination for their files. Cleaning up empty directories

Do make your ports clean up after themselves when they are deinstalled. This is usually accomplished by adding : lib/X11/oneko/pixmaps/cat.xpm lib/X11/oneko/sounds/cat.au : @dirrm lib/X11/oneko/pixmaps @dirrm lib/X11/oneko/sounds @dirrm lib/X11/oneko

However, sometimes : @unexec rmdir %D/share/doc/gimp 2>/dev/null || true This will neither print any error messages nor cause ${PREFIX}/share/doc/gimp is not empty due to other ports installing some files in there. UIDs

If your port requires a certain user to be on the installed system, let the pkg/INSTALL script call pw to create it automatically. Look at net/cvsup-mirror for an example.

If your port must use the same user/group ID number when it is installed as a binary package as when it was compiled, then you must choose a free UID from 50 to 99 and register it below. Look at japanese/Wnn for an example.

Make sure you don't use a UID already used by the system or other ports. This is the current list of UIDs between 50 and 99. majordom:*:54:54:Majordomo Pseudo User:/usr/local/majordomo:/nonexistent cyrus:*:60:60:the cyrus mail server:/nonexistent:/nonexistent gnats:*:61:1:GNATS database owner:/usr/local/share/gnats/gnats-db:/bin/sh uucp:*:66:66:UUCP pseudo-user:/var/spool/uucppublic:/usr/libexec/uucp/uucico xten:*:67:67:X-10 daemon:/usr/local/xten:/nonexistent pop:*:68:6:Post Office Owner (popper):/nonexistent:/nonexistent wnn:*:69:7:Wnn:/nonexistent:/nonexistent ifmail:*:70:66:Ifmail user:/nonexistent:/nonexistent pgsql:*:70:70:PostgreSQL pseudo-user:/usr/local/pgsql:/bin/sh ircd:*:72:72:IRCd hybrid:/nonexistent:/nonexistent alias:*:81:81:QMail user:/var/qmail/alias:/nonexistent qmaill:*:83:81:QMail user:/var/qmail:/nonexistent qmaild:*:82:81:QMail user:/var/qmail:/nonexistent qmailq:*:85:82:QMail user:/var/qmail:/nonexistent qmails:*:87:82:QMail user:/var/qmail:/nonexistent qmailp:*:84:81:QMail user:/var/qmail:/nonexistent qmailr:*:86:82:QMail user:/var/qmail:/nonexistent msql:*:87:87:mSQL-2 pseudo-user:/var/db/msqldb:/bin/sh

Please include a notice when you submit a port (or an upgrade) that reserves a new UID or GID in this range. This allows us to keep the list of reserved IDs up to date. Do things rationally

The Makefile should do things simply and reasonably. If you can make it a couple of lines shorter or more readable, then do so. Examples include using a make `.if' construct instead of a shell `if' construct, not redefining do-extract if you can redefine ${EXTRACT*} instead, and using $GNU_CONFIGURE instead of `CONFIGURE_ARGS += --prefix=${PREFIX}'. Respect CFLAGS

The port should respect the ${CFLAGS} variable. If it doesn't, please add `NO_PACKAGE=ignores cflags' to the Makefile. Configuration files

If your port requires some configuration files in ${PREFIX}/etc, do pkg/PLIST. That will cause Instead, install sample files with a suffix (`<filename>.sample' will work well) and print out a pointing out that the user has to copy and edit the file before the software can be made to work. Portlint

Do check your port with before you submit or commit it. 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 release. Miscellanea

The files pkg/DESCR, pkg/COMMENT, and pkg/PLIST should each be double-checked. If you are reviewing a port and feel they can be worded better, do so.

Don't copy more copies of the GNU General Public License into our system, please.

Please be careful to note any legal issues! Don't let us illegally distribute software! If you are stuck....

Do look at existing examples and the bsd.port.mk file before asking us questions! ;)

Do ask us questions if you have any trouble! Do not just beat your head against a wall! :) 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)!

It is recommended that you follow this format (ordering of variables, empty lines between sections, etc.). This format is designed so that the most important information is easy to locate. We recommend that you use to check the Makefile. [the header...just to make it easier for us to identify the ports.] # New ports collection makefile for: xdvi [the version required header should updated when upgrading a port.] # Version required: pl18 [things like "1.5alpha" are fine here too] [this is the date when the first version of this Makefile was created. Never change this when doing an update of the port.] # Date created: 26 May 1995 [this is the person who did the original port to FreeBSD, in particular, the person who wrote the first version of this Makefile. Remember, this should not be changed when upgrading the port later.] # Whom: Satoshi Asami # # $Id$ [ ^^^^ This will be automatically replaced with RCS ID string by CVS when it is committed to our repository.] # [section to describe the port itself and the master site - DISTNAME is always first, followed by PKGNAME (if necessary), CATEGORIES, and then MASTER_SITES, which can be followed by MASTER_SITE_SUBDIR. After those, one of EXTRACT_SUFX or DISTFILES can be specified too.] DISTNAME= xdvi PKGNAME= xdvi-pl18 CATEGORIES= print [do not forget the trailing slash ("/")! if you aren't using MASTER_SITE_* macros] MASTER_SITES= ${MASTER_SITE_XCONTRIB} MASTER_SITE_SUBDIR= applications [set this if the source is not in the standard ".tar.gz" form] EXTRACT_SUFX= .tar.Z [section for distributed patches -- can be empty] PATCH_SITES= ftp://ftp.sra.co.jp/pub/X11/japanese/ PATCHFILES= xdvi-18.patch1.gz xdvi-18.patch2.gz [maintainer; *mandatory*! This is the person (preferably with commit privileges) who a user can contact for questions and bug reports - this person should be the porter or someone who can forward questions to the original porter reasonably promptly. If you really do not want to have your address here, set it to "ports@FreeBSD.ORG".] MAINTAINER= asami@FreeBSD.ORG [dependencies -- can be empty] RUN_DEPENDS= gs:${PORTSDIR}/print/ghostscript LIB_DEPENDS= Xpm.5:${PORTSDIR}/graphics/xpm [this section is for other standard bsd.port.mk variables that do not belong to any of the above] [If it asks questions during configure, build, install...] IS_INTERACTIVE= yes [If it extracts to a directory other than ${DISTNAME}...] WRKSRC= ${WRKDIR}/xdvi-new [If the distributed patches were not made relative to ${WRKSRC}, you may need to tweak this] PATCH_DIST_STRIP= -p1 [If it requires a "configure" script generated by GNU autoconf to be run] GNU_CONFIGURE= yes [If it requires GNU make, not /usr/bin/make, to build...] USE_GMAKE= yes [If it is an X application and requires "xmkmf -a" to be run...] USE_IMAKE= yes [et cetera.] [non-standard variables to be used in the rules below] MY_FAVORITE_RESPONSE= "yeah, right" [then the special rules, in the order they are called] pre-fetch: i go fetch something, yeah post-patch: i need to do something after patch, great pre-install: and then some more stuff before installing, wow [and then the epilogue] .include Package Names

The following are the conventions you should follow in naming your packages. This is to have our package directory easy to scan, as there are already lots and lots of packages and users are going to turn away if they hurt their eyes!

The package name should look like [-][[-]]-; If your ${DISTNAME} doesn't look like that, set ${PKGNAME} to something in that format. FreeBSD strives to support the native language of its users. The `<language>' part should be a two letter abbreviation of the natural language defined by ISO-639 if the port is specific to a certain language. Examples are `ja' for Japanese, `ru' for Russian, `vi' for Vietnamese, `zh' for Chinese, `ko' for Korean and `de' for German. The `<name>' part should be all lowercases, except for a really large package (with lots of programs in it). Things like XFree86 (yes there really is a port of it, check it out) and ImageMagick fall into this category. Otherwise, convert the name (or at least the first letter) to lowercase. If the capital letters are important to the name (for example, with one-letter names like R or V) you may use capital letters at your discretion. There is a tradition of naming Perl 5 modules by prepending `p5-' and converting the double-colon separator to a hyphen; for example, the `Data::Dumper' module becomes `p5-Data-Dumper'. If the software in question has numbers, hyphens, or underscores in its name, you may include them as well (like `kinput2'). If the port can be built with different (usually part of the directory name in a family of ports), the `<compiled.specifics>' part should state the compiled-in defaults (the hyphen is optional). Examples are papersize and font units. The version string should be a period-separated list of integers and single lowercase alphabetics. The only exception is the string `pl' (meaning `patchlevel'), which can be used only when there are no major and minor version numbers in the software.

Here are some (real) examples on how to convert a ${DISTNAME} into a suitable ${PKGNAME}: DISTNAME PKGNAME Reason mule-2.2.2 mule-2.2.2 no prob at all XFree86-3.1.2 XFree86-3.1.2 ditto EmiClock-1.0.2 emiclock-1.0.2 no uppercase names for single programs gmod1.4 gmod-1.4 need hyphen after `' xmris.4.02 xmris-4.02 ditto rdist-1.3alpha rdist-1.3a no strings like `alpha' allowed es-0.9-beta1 es-0.9b1 ditto v3.3beta021.src tiff-3.3 what the heck was that anyway? ;) tvtwm tvtwm-pl11 version string always required piewm piewm-1.0 ditto xvgr-2.10pl1 xvgr-2.10.1 `pl' allowed only when no maj/minor numbers gawk-2.15.6 ja-gawk-2.15.6 Japanese language version psutils-1.13 psutils-letter-1.13 papersize hardcoded at package build time pkfonts pkfonts300-1.0 package for 300dpi fonts

If there is absolutely no trace of version information in the original source and it is unlikely that the original author will ever release another version, just set the version string to `1.0' (like the piewm example above). Otherwise, ask the original author or use the date string (`yy.mm.dd') as the version. Categories

As you already know, ports are classified in several categories. But for this to work, it is important that porters and users understand what each category is and how we decide what to put in each category. Current list of categories

First, this is the current list of port categories. Those marked with an asterisk (pkg/COMMENT file in that subdirectory (e.g., archivers/pkg/COMMENT). Archiving tools. Astronomical ports. Sound support. Benchmarking utilities. Biology-related software. Computer aided design tools. Chinese language support. Communication software. Mostly software to talk to your serial port. Character code converters. Databases. Things that used to be on the desktop before computers were invented. Development utilities. Do not put libraries here just because they are libraries -- unless they truly don't belong to anywhere else, they shouldn't be in this category. General editors. Specialized editors go in the section for those tools (e.g., a mathematical-formula editor will go in Emacs-lisp ports. Emulators for other operating systems. Terminal emulators do Games. German language support. Graphics utilities. Japanese language support. Ports that form the K Desktop Environment (kde). Korean language support. Programming languages. Mail software. Numerical computation software and other utilities for mathematics. MBone applications. Miscellaneous utilities -- basically things that doesn't belong to anywhere else. This is the only category that should not appear with any other non-virtual category. If you have Miscellaneous networking software. USENET news software. Ports from the OffiX suite. Ports that require perl version 5 to run. Software to use with the 3Com PalmPilot. Various programs from Plan9. Printing software. Desktop publishing tools (previewers, etc.) belong here too. Software written in python. Russian language support. Security utilities. Command line shells. System utilities. Ports that use tcl version 7.5 to run. Ports that use tcl version 7.6 to run. Ports that use tcl version 8.0 to run. Ports that use tcl version 8.1 to run. Text processing utilities. It does not include desktop publishing tools, which go to Ports that use tk version 4.1 to run. Ports that use tk version 4.2 to run. Ports that use tk version 8.0 to run. Ports that use tk version 8.1 to run. Vietnamese language support. Software related to the World Wide Web. HTML language support belong here too. The X window system and friends. This category is only for software that directly support the window system. Do not put regular X applications here. If your port is an X application, define X11 clocks. X11 file managers. X11 fonts and font utilities. X11 toolkits. X11 window managers. Choosing the right category

As many of the categories overlap, you often have to choose which of the categories should be the `primary' category of your port. There are several rules that govern this issue. Here is the list of priorities, in decreasing order of precedence. Language specific categories always come first. For example, if your port installs Japanese X11 fonts, then your japanese x11-fonts'. Specific categories win over less-specific ones. For instance, an HTML editor should be listed as `www editors', not the other way around. Also, you don't need to list If your port truly doesn't belong to anywhere else, put it in

If you are not sure about the category, please put a comment to that effect in your Changes to this document and the ports system

If you maintain a lot of ports, you should consider following the &a.ports;. Important changes to the way ports work will be announced there. You can always find more detailed information on the latest changes by looking at . That is It, Folks!

Boy, this sure was a long tutorial, wasn't it? Thanks for following us to here, really.

Well, now that you know how to do a port, let us go at it and convert everything in the world into ports! That is the easiest way to start contributing to the FreeBSD Project! :) diff --git a/ja/handbook/porting.sgml b/ja/handbook/porting.sgml index e198886291..12fde852d3 100644 --- a/ja/handbook/porting.sgml +++ b/ja/handbook/porting.sgml @@ -1,2582 +1,2582 @@ - + - + 自分で port を作る

原作: &a.jkh;, &a.gpalmer;, &a.asami;, &a.obrien; and &a.hoek;. 28 August 1996..

訳: &a.simokawa;, &a.asami;. 10 November 1996.

自分で port を作ることに興味がありますか, すばらしい! これから, FreeBSD用のportを作る際の, いくつかのガイドラインを 説明します. 実際にportをコンパイルするときのほとんどの仕事は /usr/share/mk/bsd.port.mkというファイルでおこないます. Portsコレクションについてのさらに細かい内部の働きについては, そちらの ファイルを参照してください. これにはコメントが細かく書いてありますので, Makefile を読むのにあまり慣れていない人でも, 得るものはとても大きいで しょう.

注意: ここでは, 変更可能な変数の一部についてのみ記述してい ます. ほとんどの変数はbsd.port.mkの始めに記述があり ます. また, このファイルは非標準のタブの設定になっていま す. EmacsVim はファイルのロード時にこれ を認識しますが, viexでは, ファイルをロード したら `:set tabstop=4'のようにして正しい値を設定する ことができます. 3分porting

この節では, 簡単なportの方法について説明します. 多くの場合これ では不十分ですが, まあうまくいくかどうか試してみて損はないでしょ う.

まず, 元のtarファイルを${DISTDIR}に置きます. デフォルトは/usr/ports/distfilesです.

注: 以下では, ソフトウェアはそのままコンパイルされるとします. つまり, FreeBSDのマシンで動かすために, 変更がまったく必要ない とします. もしなにか変更が必要な場合には次の節も参照する必要 があります. Makefileの作成

最小限のMakefileは次のようなものです: # New ports collection makefile for: oneko # Version required: 1.1b # Date created: 5 December 1994 # Whom: asami # # $Id$ # DISTNAME= oneko-1.1b CATEGORIES= games MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/ MAINTAINER= asami@FreeBSD.ORG MAN1= oneko.1 MANCOMPRESSED= yes USE_IMAKE= yes .include

おわかりになりますでしょうか. $Id$があ る行の内容については, 気にしないでください. これはこのファイル がportsツリーに書き込まれるときにCVSによって自動的に書 き込まれます. もっと詳しい例が見たければ, の節をご覧ください. Package記述ファイルの作成

どのようなportでも, packageにするしないに関わらず, 3つ の記述ファイルが必要です. pkgサブディレクトリにある, COMMENT, DESCR, それにPLISTです. COMMENT

これには, そのportについての説明を1行で書きます. Package の名前, バージョン番号等は含めないでください. たとえば, こんな具合です: A cat chasing a mouse all over the screen DESCR

これは, そのソフトウェアについての, すこし長い説明を記述 します. その port が何をするのかについての数段落程度の簡潔 な解説があれば十分です. このファイルはマニュアルでもなけれ ば, 使用方法やコンパイル方法についての細かい説明書でもあり ません. 特に, README ファイルや manpage をコ ピーしようとしてしている場合には注意してください. こ れらは多くの場合, そのポートの簡潔な説明になっていなかった り, 扱いにくい形式(manpage の場合, 行を揃えるために空白が 調整されます)になっていたりします. もしこのソフトウエアに 公式の WWW のホームページがあれば, ここに書いて下さい.

このファイルの最後にあなたの名前を書くことが推奨されています. たとえば, こんな具合です. This is a port of oneko, in which a cat chases a poor mouse all over the screen. : (うんぬん.) http://www.oneko.org/ - Satoshi asami@cs.berkeley.edu PLIST

このファイルには, このportによってインストールされるファ イルが列挙されます. このファイルはpackageを作る際のリス トとして使われるため, `packing list' とも呼ばれます. ここ に書かれているファイル名は, インストール時のプレフィックス (普通は /usr/local/usr/X11R6) からの 相対パスです. 簡単な例を載せておきましょう: bin/oneko lib/X11/app-defaults/Oneko lib/X11/oneko/cat1.xpm lib/X11/oneko/cat2.xpm lib/X11/oneko/mouse.xpm @dirrm lib/X11/oneko

'Packing list'の詳細については, pkg_create(1)の マニュアルを参照してください. すべてファイルを列挙しなければ なりませんが, ディレクトリ名は必要ありません. また, ports が インストール時にディレクトリを作成する場合には, このファイルには, ファイル名をアルファベット順に並べるよう にしてください. port のアップグレートのとき, 楽に確認ができ るようになります. チェックサムファイルの作成

ただ, `make makesum' と入力するだけです. bsd.port.mkにルールがあるので, 自動的にfiles/md5が 生成されます. Portのテスト

そのportが正しく動くことを, package化を含めて確認してく ださい. 以下の重要なポイントを確認してください. deintall の際に をすること.

推奨されるテストの手順: make install make package make deinstall pkg_add `make package-name` make deinstall make reinstall make package portlint でチェック

portlintを使って, あなたの port が我々のガイドライン そっているかを確認してください. プログラムは ports コレクション に含まれています. 特に, が正しい形式になっているか, の名前が正しいか, をチェックするのに良いでしょう. Portの送付

まず, についての節を読んでください.

さあ, あなたのportに満足したら, あとはそれをFreeBSDのメイ ンの ports ツリーに置いて, 皆に使ってもらうだけです. いまある work/ ディレクトリや pkgname.tgz パッケージは必要ありませんから, まず消去してください. あとは, バグレポートの中に `shar `find port_dir`' の出力を, send-pr(1) プログラムを使用して送ってくだ さい. (send-pr についての詳細は, を参照してください.) もし, 圧縮していない状態で, 20KB以上あるようなポートで あれば, 圧縮して tar ファイルにして, バグレポートに入れる前に uuencode(1) を使用してください. (20KB以下のものでも, tar ファイルにして送ってもよいですが, あまり歓迎されません). バクレポートの category は `ports', class は `change-request' を必ず使用してください. (レポートを `confidential'(内密) に しないようにしてください!)

もう一度, オリジナルのソースファイル, work/ ディレクトリ, `make package'で作成したパッケージが 含まれていないことを確認してください.

注: 以前, 新しい port をわれわれの ftp サイト (:<

私たちは, 何か不明な点があったらあなたに確認したのち, それをツリーへ置きます. あなたの名前は, FreeBSD ハンドブックやその他のファイルの `Additional FreeBSD contributors' のリストにも載るでしょう. う〜ん, 素晴らし い. :) 本格的なport

残念ながら, 移植がそう簡単ではなく, 動かすために多少の変更が 必要な場合も多いでしょう. この節では, portsコレクション の方法論にのっとって, そのような場合にどのように変更を施し, 動 くようにしたらよいかを順を追って説明します. port構築の詳細

まず, あなたがportのディレクトリで `make' とタイ プしてから起こる一連の出来事について,順を追って説明しま す. ここを読むときには, 他のウィンドウで同時に bsd.port.mkも開いておくとよいかもしれません.

しかし, bsd.port.mkが何をしているのか, 完全に理解 できなくても心配する必要はありません. そう多くの人が理解して いるわけではないですから... f(^_^;) まず, fetchというターゲットが実行されます. このfetchターゲッ トはローカルディスクの${DISTDIR}に配布ファ イルがあるようにするのが役目です. もし, fetchが必要なファ イルを${DISTDIR}に見つけることができなけ れば, Makefileに指定されているURL ${MASTER_SITES}, そして私たちのFTPサイトで ある (ここ には, 私たちが取ってきたファイルをバックアップとして置いてあ ります) に探しにいきます. そして, ユーザのサイトがインター ネットに直接接続されている場合には, ${FETCH} を使って, その名前のファイルを取っ てきて, ${DISTDIR}に保存します. 次に実行されるのはextractターゲットです. これは, ${DISTDIR}にある, 配布ファイル (普通は gzipされたtarファイル) を読み, ソースを一時的な作業ディレ クトリ${WRKDIR} (デフォルトは work) に展開します. 次に, patchというターゲットが実行されます. まず, ${PATCHFILES}に定義されている, すべてのパッ チをあてます. 次にもし${PATCHDIR} (デフォ ルトはpatches サブディレクトリ) にパッチが存在す れば, これらをアルファベット順にあてます. 次に実行されるターゲットはconfigureです. これには, い ろいろな場合があります. もし存在すれば, scripts/configure が実行されます. もし, ${HAS_CONFIGURE} あるいは ${GNU_CONFIGURE} がセットされていれば, ${WRKSRC}/configure が実行されます. もし, ${USE_IMAKE} がセットされていれば, ${XMKMF} (デフォルト: `xmkmf -a') が実行されます. 最後に, buildというターゲットが実行されます. これは, そのport の専用の作業ディレクトリ (${WRKSRC}) にい き, コンパイルするのが役目です. もし ${USE_GMAKE} がセットされていれば, GNU makeが使用されます. さもなければFreeBSDの makeが使用されます.

上記はデフォルトのルールです. さらに, `pre-<何とか >や `post-<何とか>' というターゲット が定義してあったり, そのような名前のスクリプトが scripts サブディレクトリに置いてある場合には, それ らはデフォルトの動作の前後に実行されます.

たとえば, post-extractというターゲットがMakefile で定義されていて, pre-buildというファイルが, scriptsサブディレクトリにあるとすると, post-extractターゲットは, 通常の展開動作のあとに呼 び出され, pre-buildスクリプトはデフォルトのコンパイ ルのルールが実行される前に実行されます. もし動作が簡単であれ ば, Makefileのターゲットを使用することが推奨されています. な ぜならば, そのportが何らかのデフォルトではない動作を必要とす るのかどうかが一箇所にまとめて書いてあった方が他の人に理解しやす いからです.

デフォルトの動作はbsd.port.mk の `do-<何とか>' というターゲットでおこなわれます. たとえば, portを展開するコマンドは, `do-extract' というターゲットにあります. もし, デフォルトのターゲットに 不満があれば, `do-<something>' というターゲッ トを再定義することによって, どのようにでも直すことができます.

「メイン」のターゲット (例えば, extract, configure等) は, すべての前段階が実行されていること を確認して, 実際のターゲットやスクリプトを呼び出す以外のこと はしません. bsd.port.mkはこれらが変更されることは仮定してい ませんので, もし, 例えば, 展開の仕方を直したいときには, do-extract を直し, 絶対にextractには手を 触れないでください.

これで, ユーザが `make' と入力したときに何が起こ るのかが理解できたと思います. では, 完璧なportを手順を追っ て作ってみましょう. オリジナルのソースの入手

オリジナルのソースを, (普通は) 圧縮されたtarファイルの形 (<foo>.tar.gzあるいは <foo>.tar.Z) で入手して, それを ${DISTDIR} にコピーします. 可能なかぎり, 広 く使われている主流のソースを使用するようにしてください.

もし, ネットワークへの接続のよい FTP/HTTP サイトを見つけるこ とができなかったり, 頭にくるような非標準的な形式しか持ってい ないサイトしか見つけられないときには, 自分で管理する確実な ftp か http サーバ (たとえば, あなたのホームページ)に置くこと ができます. MASTER_SITES に正しく反映されていること を確認してください.

もしも, そのような都合の良く, 安心な置き場所が見つけられない 場合(あなたが FreeBSD の committer であれば, 自分の public_html ディレクトリに置けます), 私たちが, ftp://ftp.FreeBSD.ORG/pub/FreeBSD/distfiles/LOCAL_PORTS/ に置き場所を提供できます. この場所は, 変数 ${MASTER_SITE_LOCAL} を使って参照してくださ い. これについての問い合わせのメールは &a.ports へお願いしま す.

その port の配布ファイルが特に理由もなく, しょっちゅう 変る場合には, 配布ファイルをあなたのホームページに置いて MASTER_SITESの最初に入れてください. こうすること によって, ユーザ利用する場合に `checksum mismatch' エラー が起るのを防ぎ, 我々の ftp サイトの保守の負担を 減らすことができます. もし, master site がたった一つ しかない場合には, あなたのサイトにバックアップを置いて MASTER_SITES の2番目に加えてください.

もし, あなたのportに必要ないくつかの追加パッチがインター ネット上で手に入るのならば, それらも取ってきて, ${DISTDIR} に置きます. もし, それらがメイン のソースのtarファイルとは別のサイトにあっても, 心配する必要 はありません. そのような状況にはちゃんと対応できるようになっ ています. (以下のをご覧ください). Portの修正

適当なディレクトリにtarファイルを展開して, FreeBSDの最新の バージョン上で, 正しくコンパイルできるために必要なあらゆる変 更を施します. 最終的に処理は自動化するわけですから, 何をおこなっ たかを注意深く記録しておきましょう. あなたのport が完成した暁には, ファイルの削除, 追加, 修正を含むすべての処 理が, 自動化されたスクリプトやパッチファイルでおこなえるようになっ ていないといけません.

もし, あなたのportのコンパイルやインストールのために必要 な手作業があまりに多いようならば, Larry Wallの模範的な Configureスクリプトでも参考にしたほうがいいかもしれませ ん. 新しいportsコレクションは, 最小のディスクスペースで, 個々のportがエンドユーザにできるだけ「プラグ & プレ イ」の状態でmakeできることをめざしています.

注意: あなたが作成しFreeBSDのportsに寄付されたパッチファイル, スクリプトおよびその他のファイルは,明示的に記述されている場合 を除いては, BSDの標準的な著作権条件によりカバーされていると見な されます. パッチをあてる

portの過程で追加されたり変更されたファイルは再帰的diffで変 更点を取り出すことができます. パッチは適当にまとめて, `patch-<xx>' という名前のファイルに入れてくだ さい. <xx>はパッチが適用される順番を示します -- これらは, アルファベット順, つまり `aa' が 最初, つぎに `ab' などとなります. これらのファイル を${PATCHDIR}に置いておくと, 自動的に適用さ れるようになっています. すべてのパッチは ${WRKSRC} (通常は, portのtarファイルが展 開されるところで, makeが実行されるところと同じです) からの相 対パスになります. 修正やアップグレードを容易にするため, 2つ 以上のパッチが同じファイルを修正するのは避けてください. (例, patch-aaとpatch-abが共に${WRKSRC}/foobar.c を修正する, など.) コンフィグレーション

カスタマイズのために追加したいコマンドがあれば, configureという名前のスクリプトに入れて `scripts' サブディレクトリに置きます. 上で述べたよ うに, pre-configure あるいはpost-configure というMakefileのターゲットおよび/あるいはスクリプトで処理す ることもできます. ユーザからの入力の扱い

もし, そのportがビルド, コンフィグレーション, インストー ルの際にユーザからの入力を必要とするならば, Makefileで IS_INTERACTIVEをセットしてください. これによって, 深夜, 自動的にたくさんのportをコンパイルすることが可能にな ります. 環境変数BATCHがセットされていると IS_INTERACTIVEの定義されているportはスキップされ ます (そして, ユーザがINTERACTIVEという変数をセッ トすると入力を必要とするportのみコンパイルされま す).

もし, 適切なデフォルト設定があるのであれば, Makefileの作成

Makefileの作成は非常に単純です. 繰り返しになりますが, 始める まえに, すでにある例を見てみることをお奨めします. またこのハ ンドブックには があります. それを見て, Makefile内の変数の順番や空行を入れると ころなどの参考にしてください. そうすると他の人々にも読みやすい ものとなります.

では, Makefileをデザインするときに問題となるところを順に追っ て見てみましょう. オリジナルのソース

ソースは${DISTDIR}に, 標準的なgzipされた tarファイルとして置かれていますか? そうであれば, 次のステッ プに進めます. そうでなければ, 変数 ${EXTRACT_CMD}, ${EXTRACT_BEFORE_ARGS}, ${EXTRACT_AFTER_ARGS}, ${EXTRACT_SUFX}, ${DISTFILES}を適当に書き換えないといけません. どれだけ変更しないといけないかは, あなたのportの 配布ファイルがどの程度標準からかけはなれているかによりま す. (最もよくある場合は, gzipではなく普通のcompressコマンド でtarファイルが圧縮されている場合で, `EXTRACT_SUFX=.tar.Z' とするだけです.)

最悪の場合には, 自分で `do-extract' ターゲットを作 成して, デフォルトを上書きすることもできます. しかし, そこま でする必要があることはめったにないでしょう. DISTNAME

${DISTNAME}にはportの名前の基幹部分を入れ ます. デフォルトのルールでは, 配布ファイルのリスト (${DISTFILES}) は ${DISTNAME}${EXTRACT_SUFX}という名前 になっています. 例えば, `DISTNAME=foozolix-1.0'の場 合, 通常のtarファイルだと, foozolix-1.0.tar.gz のようになります. さらにデフォルトのルールでは, tarファイルは work/${DISTNAME}というサブディレクトリ に展開されることを仮定しています, 例えば work/foozolix-1.0/ といった具合いです. これらの動作はもちろんすべて変更可能です. デフォルトのルー ルは最も標準的な場合を仮定しているだけです. まず, portが複 数の配布ファイルを必要とするときには, 単に明示的に ${DISTFILES}を設定してください. もし, ${DISTFILES}の一部だけが実際に展開される場合 には, それらを${EXTRACT_ONLY} に設定してくだ さい. この変数が定義されている場合には, 展開時に ${DISTFILES}に優先して利用されます. 残りのファ イルも${DISTDIR}に取ってきますが, 展開時に はなにもせずに後で使うためにそのまま置いておかれます. PKGNAME

もし, ${DISTNAME} が我々の に沿ったものでない場合には, ${PKGNAME} にもっと良い 名前を設定してください. 詳細は上記のガイドラインを参照してください. CATEGORIES (分類)

完成したpackageの実体は/usr/ports/packages/All に置かれます. また, 1つかそれ以上の /usr/ports/packagesのサブディレクトリからのシンボリッ クリンクが作られます. それらのサブディレクトリの名前が ${CATEGORIES}という変数によって指定されます. これは, ユーザがFTPサイトやCD-ROMのpackageの山を渡り歩 くことを容易にするためです. 現在存在する を見て, そ のportに適したもを選んでください.

このリストは, この port が port tree のどこに import されるかも決定します. 2つ以上のカテゴリを指定した場合には 最初のカテゴリで指定されるサブディレクトリに置かれること になります. 適切なカテゴリを選ぶ方法については, の節を 参照してください.

もしそのportが本当に現在存在するすべてのものとは異なって いる場合には, 新しいカテゴリ名を作ることもできます. その際には, &a.ports 宛てに新しいカテゴリ名を提案する メールを送ってください.

カテゴリ名については, なんのエラーチェックも行なわれません. ミスタイプがあっても`make package' はなにも考えずに 新しいディレクトリを作ってしまいますので, 注意してください. MASTER_SITES

オリジナルの配布ファイルを指し示すFTPまたはHTTPのURLのディ レクトリ部分までを${MASTER_SITES}に記録しま す. スラッシュ (/) を最後につけることをお忘れなく. 配布ファイルがシステム上に存在しないときに, makeマクロは ${FETCH}でこの変数に指定されたサイトから取っ てきます.

複数の, できれば異なる大陸のサイトをこのリストに入れておく ことが推奨されています. これによって, 広域ネットワークにトラ ブルがあった場合でも成功する可能性が高くなります. 私たちはさら に, 自動的に最も近いマスタサイトを検出して, そこから取って くるメカニズムの導入を計画しています.

オリジナルのtar ファイルが, X-contrib, GNU, Perl CPAN, TeX CTAN または Linux Sunsite などの有名なアーカイブにある場合には, MASTER_SITE_XCONTRIB, MASTER_SITE_GNU, MASTER_SITE_PERL_CPAN, MASTER_SITE_TEX_CTAN および MASTER_SITE_SUNSITE を利用することで, 簡単にこれらのサイトを 指定することができます. あとは MASTER_SITE_SUBDIR にアーカイ ブ内でのパスを指定するだけです. 以下に例を示します. MASTER_SITES= ${MASTER_SITE_XCONTRIB} MASTER_SITE_SUBDIR= applications

ユーザは/etc/make.conf中で MASTER_SITE_* 変数を設定 することによって, デフォルトの FTP サイトではなく, これらの 有名なアーカイブのミラーの中で好みのものを使用することが可能 です. PATCHFILES

もし, オリジナルの配布ファイル以外にもFTPかHTTPで手に入る パッチが必要な場合には, ${PATCHFILES}にファ イル名を, ${PATCH_SITES}にサイトとディレクト リの名前を${MASTER_SITES}と同様に設定してく ださい.

そのパッチ内のファイル名ががソースツリーの一番上のディレク トリ (${WKRSRC}) からの相対パスになっていな い場合には, ${PATCH_DIST_STRIP}を指定してく ださい. 例えば, パッチ内のファイル名にすべて余計な `foozolix-1.0/' がついている場合には, `PATCH_DIST_STRIP=-p1'としてください.

これらのパッチは圧縮されていても大丈夫です. ファイル名が `.gz' か `.Z' で終わる場合には自動的に復元 されるようになっています.

もしパッチが, 文書などその他のファイルと一緒にgzipされた tarファイルで配布されている場合には,単純に ${PATCHFILES} を使うことはできません. このような場合には, このパッチの tar ファイルの名前と場所を ${DISTFILES}${MASTER_SITES} に加えます. それから, pre-patch ターゲットで, パッチコマンドを走らせるか, パッチファイルを ${PATCHDIR} ディレクトリに patch-<xx>という名前でコピーするかして, パッチを適用するようにします.(普通の gzip か compress された tar ファイルであれば,通常のソースファイルと一緒にその時までに 展開されていますので,明示的に展開する必要はありません.) もし,後者の方法を使用する場合には,すでにそのディレクトリにある なにかを上書きしないように, 注意する必要があります. さらに, pre-clean ターゲットにコピーしたパッチファイル を削除するコマンドを追加するのを忘れないでください. MAINTAINER

あなたのメールアドレスをここに入れてください. お願いします. :)

保守担当者(maintainer)の責任についての詳細は, の節をご覧ください. 依存関係

このプログラムが他のportに依存する場合には, 必要なものが 自動的に作られるようにすることができます. そのために, 以下の 5つの変数が用意されています. よくあるケースのために あらかじめ設定された依存変数や, いくつかの依存関係の制御のため の変数があります. LIB_DEPENDS

Portが必要とする非標準の共有ライブラリをこの変数で指定 します. これは `lib:dir[:target]' という組のリストで, lib が共有ライブラリの名前, そしてdir がそのライブラリが見つからない場合にインストールするport のあるディレクトリで, LIB_DEPENDS= jpeg.9:${PORTSDIR}/graphics/jpeg:install と指定してあれば, まずメジャーバージョンが9のjpegライブ ラリがあるかどうか確認し, ない場合にはportsツリーの中の graphics/jpeg というサブディレクトリに移動し, そこ - で作成と package 作成を行ないます. `${DEPENDS_TARGET} (デフォルトは `lib 部分は `ldconfig -r | grep -wF' への引数になります. この変数には正規表現を入れられません. この依存関係は2度チェックされます. まず pkg_add が自動的にインストールします. RUN_DEPENDS

Portを使用する際に必要となるファイルまたはプログラムがある ときにはこの変数で指定します. これは`path:dir[:target]' という組のリストで, path がファイルまたはプログラムの 名前, そしてdir がそれが見つからない場合に作成する ためのディレクトリ名で, 'Path の最初の文字がスラッ シュ (/) の場合にはファイルかディレクトリとみなし, その存在を `test -e' でチェックします; そうでない 場合には実行可能であると仮定し, `which -s' を使って そのプログラムがユーザのサーチパス上にあるかどうか確認します.

例えばMakefileに以下のように書いてあるとします. RUN_DEPENDS= ${PREFIX}/etc/innd:${PORTSDIR}/news/inn \ wish8.0:${PORTSDIR}/x11-toolkits/tk80 まず, `/usr/local/etc/innd' というファイルか ディレクトリが存在するか確認し, ない場合にはportsツリーの中の news/inn というサブディレクトリから作られます. ま た, `wish8.0' というプログラムがユーザのサーチパス中 にあるかどうか探し, ない場合には同じくportsツリーの x11-toolkit/tk80 というサブディレクトリから作られます. (この例で, `innd' は実際にはプログラムです; この ように, プログラムであっても標準のサーチパス以外のところに あるようなものの場合には, 絶対パスで指定してください.) この依存関係はinstall ステージのはじめでチェック されます. また, packageを作る際に必要となるportのpackage名 が記録され, pkg_addを使用するとユーザのシステム に存在しない場合には自動的にそちらのpackageもインストール されるようになります. `${DEPENDS_TARGET} と同じ場合には省略可能 です. BUILD_DEPENDS

Portのコンパイルに必要なファイルまたはプログラムがある ときは, この変数で指定してください. RUN_DEPENDSと同 様に, これは `path:dir[:target]' という組のリストです. 例えば, BUILD_DEPENDS= unzip:${PORTSDIR}/archivers/unzip は `unzip' という名前のプログラムを探し, 見つから ない場合にはarchivers/unzip サブディレクトリで作 れという意味になります. ここでは「コンパイル」と一口にいいましたが, この変数は実際 にはファイルの展開から実際のコンパイル・リンクまで全部をま とめて面倒を見てくれます. この依存関係はextract ステージからチェックされます. `${DEPENDS_TARGET} と同じ場合には省略可能です. FETCH_DEPENDS

この変数は, portを取ってくるのに必要なファイルまたはプロ グラムを指定するのに使います. 上の二つと同様に, これは `path:dir[:target]' という組のリストです. 例えば, FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 としておけば, `ncftp2' という名前のプログラムを探 し, 見つからない場合にはnet/ncftp2 サブディレク トリにいってインストールします. この依存関係はfetchステージからチェックされます. `${DEPENDS_TARGET} と同じ場合には省略可能です. DEPENDS

上記の四つのいずれにもあてはまらないような依存関係がある場 合, または他の port がインストールされれているだけではなく, ソースが展開されている必要がある場合にはこの変数 を使います. これは `dir[:target]' という形式のリスト になります. 上記の四つと違って特に「確認」するものがありませ んので. よくある依存関係を表す変数

もし ports が X Window System を必要とするのであれば, `USE_XLIB=yes' を定義してください. (これは USE_IMAKE も意味します) BSD USE_GMAKE=yes' を定義. 動作するのに GNU autoconf を必要とする場合には, `USE_AUTOCONF=yes' を定義. 最新の qt toolkit を使用 する場合には `USE_QT=yes' を定義. perl 言語の バージョン5 を必要とする場合には, `USE_PERL5=yes' を定義してください. (特に最後のは重要で, FreeBSD のいくつかの バージョンでは基本システムに perl5 を含みますが, 他のものは 含んでいません.) 依存関係に関する注意

上で述べたように, 依存する ports が必要になったときに 呼ばれるデフォルトのターゲットは ${DEPENDS_TARGET} で, そのデフォルトは `${DEPENDS_TARGET} を再定義 するのではなく, *_DEPENDS 変数の ``make clean' とタイプしたときには, 依存する port も自動的に clean されます. もしそうしたくない場合 には, 無条件に他の port に依存させるには, 特別に ` BUILD_DEPENDS= /nonexistent:${PORTSDIR}/graphics/jpeg:extract これは, 常に JPEG port の directory に行きソースの展開 を行ないます.

あなたがやりたいことが他の方法ではできない場合以外は, ` コンパイル時の特別な指定

GNUのmakeを使う場合には, `USE_GMAKE=yes' と指定してください. Portに GNU configureが含まれ ている場合には, `GNU_CONFIGURE=yes' を使います (これは, configureに追加の引数 (デフォルトでは, GNU の --prefix=${PREFIX}', GNUでない${CONFIGURE_ARGS}で指定してください. そのパッケージが USE_AUTOCONF=yes' を使います. これは, X Window Systemのアプリケーションなど, imakeを 使ってImakefileからMakefileを作成するportの場合には `USE_IMAKE=yes' を指定してください. コンフィグレー ションステージで自動的にxmkmf -a が実行されます. も し `-a' フラグが問題をもたらすなら, さらに `XMKMF=xmkmf'としてください. もし, port が imake を使用するけれども, `install.man' ターゲットがない場合には, `NO_INSTALL_MANPAGES=yes' を指定してください. ついでに, その port のオリジナルの 作者を探し出して八つ裂きにするといいでしょう. :>

PortのMakefileが `all' 以外のものをメインのター ゲットとしている場合には, ${ALL_TARGET} でそ れを指定してください. `install' と ${INSTALL_TARGET} も同様です.

もし, port の元の Makefile が `all' 以外のターゲット をメインのターゲットとしている場合には, ${ALL_TARGET} をそれに合わせて設定してください. `install' と ${INSTALL_TARGET} に ついても同様です. 特別な配慮

Portを作成する場合, 考慮しなくてはいけないことがさらにいくつか あります. この節では, それらのうちもっともありがちなものに ついて説明します. ldconfig

共有ライブラリをインストールするときには, 共有ライブラリのキャッ シュを更新するためにportのMakefileのpost-install target から`${LDCONFIG} -m' を走らせてください. このコマンドの引数は共有ライブラリのインストールしてあるディ レクトリ (通常 ${PREFIX}/lib) です.

また, pkg/PLIST@exec /sbin/ldconfig -m '/`@unexec /sbin/ldconfig -R' の組を入れて, package をインストールした場合にも共有ライブラリがすぐ使え, 削除の際 にも, システムがまだライブラリが存在すると誤認しないようにし てください. この行は共有ライブラリを指定する行のすぐ後に書く のがよいでしょう: lib/libtcl80.so.1 @exec /sbin/ldconfig -m %D/lib @unexec /sbin/ldconfig -R

絶対に引数なしでただ `ldconfig'とだけ書い てある行をMakefileやpkg/PLISTファイルに入れないでください. このコマンドを実行すると, 共有ライブラリのキャッシュが /usr/libの内容のみとなり, ユーザのマシンにさまざま な問題をもたらします (「ぎゃぁ! このportをインストールした らxinitが使えなくなっちゃった!」). この掟を破った者は, 永久 に地獄の底で苦しみ続けるように, 閻魔様に頼んでおきます. ELF 対応

FreeBSD は 3.0-release 以後, ELF に移行しますので, シェアードライブラリを作成するたくさんの port を ELF 対応 にする必要があります. 3.0 システムは ELF も a.out も 実行できますし, 2.2 ブランチからのもう一つのリリース (2.2.8) もあるので, 複雑な状況です. 以下は a.out のみに対応している port をどのように a.out と ELF 両方に対応させるかのガイドライ ンです.

このリストの一部は, 移行時にしかあてはまらないものもあります が, 古い port をアップグレードしたい場合に参考になるように, しばらくのあいだは残しておきます. a.out ライブラリの退避

a.out ライブラリは, /usr/local/lib から, `src/Makefile にある ` フォーマット

port ツリーは package をそのマシンのフォーマットで作成しま す. つまり, 2.2 では a.out, また 3.0 では `objformat` の結果によって, a.out か ELF になります. また, いったん a.out ライブラリをサブディレクトリに移動すると a.out ライブラリの作成はサポートされません. (つまり, あなたがな にをすれば良いのかを理解しているのならば, うまく作成できるかもし れませんが, 自力でやらなければならないということです)

注: もし port が aout でしか動作しないのなら, PORTOBJFORMAT

PORTOBJFORMAT=${PORTOBJFORMAT}' とし て この変数は, 以下のようにして PORTOBJFORMAT!= test -x /usr/bin/objformat && /usr/bin/objformat || echo aout

この変数を使って, port の make の過程で何をすべきかを決定す べきですが, もし port の 共有ライブラリの作成

以下は, a.out と ELF での共有ライブラリの扱いの違いです. 共有ライブラリのバージョンELF の共有ライブラリ は, "リンカコマンドライン直接 'cc -shared' を使用してください. たった一つの違いは, ELF には, `-Wl,-soname,libfoo.so.M' コマンドライ ンにを加える必要があることです.

ELF のリンカを満足させるためには, libfoo.so -> libfoo.so.N というシンボリックリンクを作る必要があり ます. これは,

すべての port の Makefile を編集して, foo\\.1\\.\\(33|40\\)' -> `foo.2'.) マッチングは `grep -wF' 使って行われます.

ELF システムで 2 つのバージョン番号を持つ共有ライブラリをイ ンストールしたり, aout システムで 1 つのバージョン番号しか持 たない共有ライブラリをインストールするのが避けられない場合 (例えば他のオペレーティングシステム用の互換ライブラリをイン ストールする port など),

Makefile 中の ${SETENV} OBJFORMAT=${PORTOBJFORMAT} ${LDCONFIG} -m .... また @exec /usr/bin/env OBJFORMAT=%%PORTOBJFORMAT%% /sbin/ldconfig -m ... @unexec /usr/bin/env OBJFORMAT=%%PORTOBJFORMAT%% /sbin/ldconfig -R となります. これは, システムのデフォルトフォーマットではなく パッケージのフォーマットに応じて, 正しい

もし, あなたの port が 変数(例えば 解像度とか紙のサイズなど) を変えたりした, ちょっと違うバージョンを作成する必要があるとき には, ユーザが分りやすいように, package ごとに別々のサブ ディレクトリを作成し, ただし, できるだけ port 間でファイル を共有するようにしてください. 典型的な例では, うまく変数を 使えば, とても短いMakefileだけ, 1つ以外のすべてのディレクトリ に置くだけで済みます. その短い Makefile には ${MASTERDIR} を使って, 残りのファイルがある ディレクトリを指定できます. また の一部に変数に使って, package が別々の 名前を持つようにしてください.

以下が, とても良い例になるでしょう. これは japanese/xdvi300/Makefileの一部です: : PKGNAME= ja-xdvi${RESOLUTION}-17 : # default RESOLUTION?= 300 .if ${RESOLUTION} != 118 && ${RESOLUTION} != 240 && \ ${RESOLUTION} != 300 && ${RESOLUTION} != 400 @${ECHO} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\"" @${ECHO} "Possible values are: 118, 240, 300 (default) and 400." @${FALSE} .endif japanese/xdvi300 は通常のパッチ, package ファイルも もっています. そこで, `他の解像度に関してですが, これが, xdvi118/Makefile の(コメントを除いた) RESOLUTION= 118 MASTERDIR= ${.CURDIR}/../xdvi300 .include "${MASTERDIR}/Makefile" (xdvi240/Makefilexdvi400/Makefile も 同様です). ${MASTERDIR}${PATCHDIR}${PKGDIR} などの通常のサブディレクトリが xdvi300/Makefile 共有ライブラリのバージョン

まず, を読んで, 共有ライブラリのバージョンを一般的にどうすれば良いかを 理解してください. 盲目的に, ソフトウエアの作者がちゃんと理解 していると信じててはいけません, 多くの場合違います. 細い点まで考慮することは大変重要なことです, なぜなら我々は 互換性がないかもしれない大量のソフトウェアを共存させようと する, 特殊な状況にあるからです. 不注意な port の導入が 共有ライブラリに関して, 多大な問題を引き起したことが過去にあ ります (今まで, しかしながら, が同じソフトウェアの違ったバージョンのソフト ウェアが既にツリーにあるばあいには, 状況は非常に複雑です. つまり, FreeBSD では, ユーザがリンカにどのバージョンの 共有ライブラリを使用するかを指定できないからです(リンカは 常にもっとも高いバージョンを選びます). これは, もし, マニュアル

MAN[1-9LN] 変数を使用すると, 自動的にすべてのマニュアルを pkg/PLIST に加えます (つまり, マニュアルを を参照してください). またマニュアルを /etc/make.conf 中の NOMANCOMPRESSの設定に応じて, install時に自動的に 圧縮したり伸長したりします.

マニュアルをインストール時に圧縮するかどうかを指定するには, PREFIX以外のディレクトリの下にマニュアルを置く ようなportではMANPREFIXを指定することが できます. さらに, 特定のセクションのマニュアルだけ, 標準では ない場所にインストールする場合, 例えばいくつかの Perl のモ ジュールの ports など, には個々のマニュアルのパスを MANsectPREFIX (sectは, 1 から 9 または, L か N を表わします) によって指定できます. ができます.

マニュアルが, 言語特有のサブディレクトリに置かれる場合には, 言語名を "" になっています (つまり, 英語のみ).

これは, 全部をまとめた例です. MAN1= foo.1 MAN3= bar.3 MAN4= baz.4 MANLANG= "" ja MAN3PREFIX= ${PREFIX}/share/foobar MAN8COMPRESSED= yes 以下の6個のファイルがこの port でインストールされます. ${PREFIX}/man/man1/foo.1.gz ${PREFIX}/man/ja/man1/foo.1.gz ${PREFIX}/share/foobar/man/man3/bar.3.gz ${PREFIX}/share/foobar/man/ja/man3/bar.3.gz ${PREFIX}/man/man4/baz.4.gz ${PREFIX}/man/ja/man4/baz.4.gz Motifを必要とするport

最近はコンパイルにMotifを必要とするアプリケーションが増えて きました. (Motif自体は有料のものがいくつかの会社から手に入りま すし, 多くのアプリケーションがコンパイル可能な無料の互換ライブラリ が x11-toolkits/lesstifにあります) Motifはかなり広く使われていますし, 製品のライ センスではライブラリを静的にリンクした実行形式は再配布が認めら れている場合が多いので, Motifを必要とするソフトウェアを簡単に 動的(port からコンパイルする人々のために)/静的(package を配布 する人々のために)にリンクできるようなしくみが用意されています. REQUIRES_MOTIF

MotifがないとコンパイルできないportのMakefileではこの変 数を指定してください. これによって, Motifを持っていない人が このportをコンパイルしようとするのを未然に防ぎます. ${MOTIFLIB}

この変数はbsd.port.mkによってMotifライブラリの指 定に置き換えられます. ソース内のMakefileやImakefileで Motifライブラリを指定しているところをこの変数に置き換えるよ うにパッチをあててください.

代表的な例としては以下の二つがあげられます: MakefileかImakefileの中でMotifライブラリが `-lXm' として使われている場合には, かわりに `${MOTIFLIB}' と書いてください. Imakefileの中で `XmClientLibs' が使われている 場合には, それを `${MOTIFLIB} ${XTOOLLIB} ${XLIB}' と書きかえてください.

${MOTIFLIB} は通常 `-L/usr/X11R6/lib -lXm' か `/usr/X11R6/lib/libXm.a' に置き換えら れます. したがって前に `-L' や `-l' をつけ る必要はありません. X11 のフォント

もし, あなたの port が X window system のフォントをインストール するのであれば, それらを ${X11BASE}/lib/X11/fonts/local に置くようにして ください. このディレクトリは XFree86 release 3.3.3 で新設された ものです. もし, それが存在しなければ作成し, ユーザに XFree86 を 3.3.3 かそれより新しいものに更新か, すくなくとも, このディレクトリを /etc/XF86Config の font path に加えるように促すメッセージを出力するようにしてください. Info ファイル

新しい版の texinfo(2.2.2-RELEASE およびそれ以降に入っています) には, `&dollar{PREFIX}/info/dir ファイル を更新するようにしてください. (この節は, とても長くてすいません, しかし info ファイルを作りあげるためには, これらは不可欠 です. 正しく行なえば, 美しい リストができますので, 辛抱してください! まず, これを知っておかなければなりません: % install-info --help install-info [OPTION]... [INFO-FILE [DIR-FILE]] Install INFO-FILE in the Info directory file DIR-FILE. (訳注: Info ディレクトリの INO-FILE を DIR-FILE にインストールする) Options: --delete Delete existing entries in INFO-FILE; don't insert any new entries. (訳注: INFO-FILE の中の項目を削除, 新しい項目は一切追加しない.) : --entry=TEXT Insert TEXT as an Info directory entry. (訳注: TEXT を Info ディレクトリの項目として追加する.) : --section=SEC Put this file's entries in section SEC of the directory. (訳注: このファイルの項目を Info ディレクトリの SEC という節に置く.) :

このプログラムは, 実際には info ファイルをこれから, editors/emacsを 使用します. まず, texinfo のソースを見て, --- ./man/vip.texi.org Fri Jun 16 15:31:11 1995 +++ ./man/vip.texi Tue May 20 01:28:33 1997 @@ -2,6 +2,10 @@ @setfilename ../info/vip @settitle VIP +@dircategory The Emacs editor and associated tools +@direntry +* VIP: (vip). A VI-emulation for Emacs. +@end direntry @iftex @finalout :

フォーマットについては見ればわかると思います. 1つのファイルに対して1つの info の項目しか書けないことに注 意してください, これは, `install-info --delete' が, そのバグにより, texinfo のソースにパッチをあてるかわりに, japanese/skkportのディレクトリに戻って, `make clean; make' をして, info ファイルが texinfo ソースファイルから再び生成さ れることを確認してください. texinfo ソースファイルのほうが info ファイルよりも新しいので, --- ./Makefile.in.org Mon Aug 19 21:12:19 1996 +++ ./Makefile.in Tue Apr 15 00:15:28 1997 @@ -184,7 +184,7 @@ # Subdirectories to make recursively. `lisp' is not included # because the compiled lisp files are part of the distribution # and you cannot remake them without installing Emacs first. -SUBDIR = lib-src src +SUBDIR = lib-src src man # The makefiles of the directories in $SUBDIR. SUBDIR_MAKEFILES = lib-src/Makefile man/Makefile src/Makefile oldXMenu/Makefile lwlib/Makefile --- ./man/Makefile.in.org Thu Jun 27 15:27:19 1996 +++ ./man/Makefile.in Tue Apr 15 00:29:52 1997 @@ -66,6 +66,7 @@ ${srcdir}/gnu1.texi \ ${srcdir}/glossary.texi +all: info info: $(INFO_TARGETS) dvi: $(DVI_TARGETS)

/usr/share/info にあるからです. (このパッチはここにはありません.) もし, --- ./Makefile.in.org Mon Aug 19 21:12:19 1996 +++ ./Makefile.in Mon Apr 14 23:38:07 1997 @@ -368,14 +368,8 @@ if [ `(cd ${srcdir}/info && /bin/pwd)` != `(cd ${infodir} && /bin/pwd)` ]; \ then \ (cd ${infodir}; \ - if [ -f dir ]; then \ - if [ ! -f dir.old ]; then mv -f dir dir.old; \ - else mv -f dir dir.bak; fi; \ - fi; \ cd ${srcdir}/info ; \ - (cd $${thisdir}; ${INSTALL_DATA} ${srcdir}/info/dir ${infodir}/dir); \ - (cd $${thisdir}; chmod a+r ${infodir}/dir); \ for f in ccmode* cl* dired-x* ediff* emacs* forms* gnus* info* message* mh-e* sc* vip*; do \ (cd $${thisdir}; \ ${INSTALL_DATA} ${srcdir}/info/$$f ${infodir}/$$f; \ chmod a+r ${infodir}/$$f); \ (これは, 既存のportを修正するときのみ必要です.) pkg/PLIST を見て, info/dir にパッチをあて ようとするものすべてを削除します. これらは, pkg/INSTALL やその他のファイルにもあるかもしれない ので, いろいろさがしてみてください. Index: pkg/PLIST =================================================================== RCS file: /usr/cvs/ports/editors/emacs/pkg/PLIST,v retrieving revision 1.15 diff -u -r1.15 PLIST --- PLIST 1997/03/04 08:04:00 1.15 +++ PLIST 1997/04/15 06:32:12 @@ -15,9 +15,6 @@ man/man1/emacs.1.gz man/man1/etags.1.gz man/man1/ctags.1.gz -@unexec cp %D/info/dir %D/info/dir.bak -info/dir -@unexec cp %D/info/dir.bak %D/info/dir info/cl info/cl-1 info/cl-2 Index: Makefile =================================================================== RCS file: /usr/cvs/ports/editors/emacs/Makefile,v retrieving revision 1.26 diff -u -r1.26 Makefile --- Makefile 1996/11/19 13:14:40 1.26 +++ Makefile 1997/05/20 10:25:09 1.28 @@ -20,5 +20,11 @@ post-install: .for file in emacs-19.34 emacsclient etags ctags b2m strip ${PREFIX}/bin/${file} .endfor + if [ ! -f ${PREFIX}/info/dir ]; then \ + ${SED} -ne '1,/Menu:/p' /usr/share/info/dir > ${PREFIX}/info/dir; \ + fi +.for info in emacs vip viper forms gnus mh-e cl sc dired-x ediff ccmode + install-info ${PREFIX}/info/${info} ${PREFIX}/info/dir +.endfor .include

新しい info ファイルを作成するのに, /usr/share/info/dir と上のコマンド, 以外は使用しな いでください. 実際のところ, もし port する人がこれに関して info/dir を削除する必 要はありません. Index: pkg/PLIST =================================================================== RCS file: /usr/cvs/ports/editors/emacs/pkg/PLIST,v retrieving revision 1.15 diff -u -r1.15 PLIST --- PLIST 1997/03/04 08:04:00 1.15 +++ PLIST 1997/05/20 10:25:12 1.17 @@ -16,7 +14,15 @@ man/man1/etags.1.gz man/man1/ctags.1.gz +@unexec install-info --delete %D/info/emacs %D/info/dir : +@unexec install-info --delete %D/info/ccmode %D/info/dir info/cl info/cl-1 @@ -87,6 +94,18 @@ info/viper-3 info/viper-4 +@exec [ -f %D/info/dir ] || sed -ne '1,/Menu:/p' /usr/share/info/dir > %D/info/dir +@exec install-info %D/info/emacs %D/info/dir : +@exec install-info %D/info/ccmode %D/info/dir libexec/emacs/19.34/i386--freebsd/cvtmail libexec/emacs/19.34/i386--freebsd/digest-doc

@unexec install-info --delete' コマンドは, info ファイル自身より先に置き, コマンドがファイルを読めるようにし ておかなければならないことに注意してください. また, `@exec install-info' コマンドは info ファイルおよび をして 出来栄えに感服しましょう

まだ触れていない, いくつかのこつが

バイナリパッケージが INSTALL ${PKGNAME} PRE-INSTALL' と実行され, 2度目には, '`INSTALL ${PKGNAME} POST-INSTALL' と実行されます. どちらのモードで実行されているかは, `$2' を調べることによってわかります. 環境変数 `PKG_PREFIX' には package がインストールさ れるディレクトリが設定されます. 詳細は man pkg_add(1) を見てください. 注意すべきことは, port を `make install' で インストールするときには, このスクリプトは自動的に実行されな いということです. もし, 実行される必要があるならば, port の Makefile で明示的に呼ぶ必要があります.

port が(インストールされるシステムの状態によって) インストールされるべきか, されないべきか区別する必要があると きには, 「要件(requirements)」スクリプト pkg/REQ を作ること ができます. これは, インストール及びデインストール (package の削除)の時に自動的に実行され, それらが処理されるべ きかを決定します. makeの変数にあわせた

いくつかの port, 特に p5- portsなど, は configure のオプション (あるいは, p5- ports の場合は perl のバージョン)によって, %%PERL_VERSION%% は, 適切に置き換えられるようになって います. 他の置き換えが必要であれば, PLIST_SUB 変数に VAR=VALUE という形式のペアのリストを設定することに よって, %%VAR%%' は ` OCTAVE_VERSION= 2.0.13 PLIST_SUB= OCTAVE_VERSION=${OCTAVE_VERSION} と書いて, %%OCTAVE_VERSION%% と書きます. このようにしておけば, port をアップグレードするときに, 何十行(ときとして, 何百行)も この書き換えは ( の追加も) ${PLIST} を読み ${TMPPLIST} (デフォルトは, ${WRKDIR}/.PLIST.mktmp) に書き込むことによって 行なわれます. もし, あなたの port が ${PLIST} を実行時に生成するのであれば, ライセンス上の問題

ソフトウェアによっては制限の厳しいライセンスがついてきたり, 法律的に問題があるかもしれません. (PKPの公開鍵暗号化, ITAR (暗 号化ソフトウェアの輸出) などが例としてあげられます). それらを どう扱えばいいかはライセンスの文面によってさまざまな場合があり ます.

ソフトウェア移植者として, あなたにはライセンスをよく読み, FreeBSDプロジェクトがFTPまたはCD-ROMで配布してはいけないソフ トウェアを配布してしまうことのないよう, 注意する義務があります. なにか疑問がある場合には, &a.ports;に聞いてみてください.

よく見られるケースに対処するために, 二つの変数が用意されてい ます: ソフトウェアに「有償再配布を禁ずる」という趣旨のライセン スがついてきた場合にはNO_CDROMという変数にその理由 を記述してください. 私たちはこれがついている port は CD-ROM リリースに入れないようにしますが, オリジナルのソースファイル とpackageはFTPでは取れるようにしておきます. もしも, 生成される package が個々のサイトで独自に構築さ れる必要があったり, ライセンスによって生成されるバイナリが 配布できない場合には, NO_PACKAGE 変数にその理由を 記述してください. そのような package が FTP サイトに置かれ たり, リリース時の CD-ROM へ入らないようにします. ただし, いずれの場合も distfile は(FTP や CD-ROM に)含まれるように なります. Portが, 使用者によっては法律上の問題が生じる時 (暗号化ソフ トウェアなど), または「商用利用を禁ずる」とライセンスに書い てある場合にはRESTRICTEDという変数にその理由を入れ てください. この場合には, ソースファイルやpackageは私たちの FTPサイトにも置かれません.

注: GNU一般公有使用許諾書 (GPL) はバージョン1, 2とも port作成上は何ら問題にはなりません.

注: もしあなたが,ソースツリー管理者 (committer) であれば, ソースツリーにこのようなportを入れる際に, ports/LEGALファイルを書き換えるのを忘れないようにし てください. アップグレード

Portのバージョンが原作者からのものに比べて古いことに気がつ いたら, まずはあなたの持っているportが私たちの最新のもの (ミラー サイトのports-currentというディレクトリにあります) であることを確認してください.

次に, portのMakefileにMAINTAINER (保守担当者) の アドレスが書いてある場合には, その人にメールを出してみましょう. 保守担当者の人がすでにアップグレードの準備をしているかもしれま せんし, (新しいバージョンの安定度に問題があるなど) あえてアッ プグレードをしない理由があるのかもしれません.

保守担当者にアップグレードをしてくれと頼まれた場合, あるいは そもそもportのMakefileに保守担当者が書いてない場合などは, あ なたがアップグレードをしてくださると助かります. その場合にはアッ プグレードをしたのち, 変更前と変更後のディレクトリの再帰的diff (unified diff と context diff のどちらでもいいのですが, port のコミッター達は unified diff のほうを好むようです) をとって送ってください. (例えば, 変更前のディレクトリが `superedit.bak' という名前でとってあり, 変更後のもの が `superedit' に入っているなら, `diff -ruN superedit.bak superedit' の結果を送ってください. ) diff の出力を見て, すべての変更が正しくなされているか確認して ください. 変更箇所については, send-pr (カテゴリーは, `ports')に diff の出力結果を添えて, 私たちに送ってもらうのが一 番よいです. commit する際に CVS に明確に記述しなければならない ので, 付け加えたり削除したりしたファイルがあったら, それについ て書いておいてください. もし diff の大きさが 20 KB 程度を 超えるようであれば, 圧縮したものを uuencode して下さい. そうでなければそのまま PR に入れるだけでいいです. やってよいことといけないこと

この節では, ソフトウェアをportする上でよくある落し穴などにつ いて説明します. このリストを使って, あなた自身が作成した port のチェックはもとより, PR データベースにある, 他の人が作成した port のチェックもできます. あなたがチェックした port について のコメントを にしたがって, 送ってください. PR データベースにある port を チェックすることによって, 私達がそれらを commit するのを早くし, あなたが何をしているか理解していることも示します. バイナリのstrip

バイナリはstripしてください. オリジナルのソースがバイナリを stripしてくれる場合は良いですが, そうでない場合には post-installターゲットを指定して strip するようにする とよいでしょう. 例えば, こんな風になります: post-install: strip ${PREFIX}/bin/xdl

インストールされた実行形式がすでにstripされているかどうか はfileコマンドで確認できます. これが`not stripped' と言わなければ, stripされているということです. INSTALL_* マクロ

あなた自身の *-install ターゲットでファイルの正しいモードと オーナを保証するために, 必ずbsd.port.mkで提供されて いるマクロを使用してください. マクロは以下のようなものがあります. ${INSTALL_PROGRAM} は実行可能なバイナリを インストールするコマンドです. ${INSTALL_SCRIPT} は実行可能なスクリプトを インストールするコマンドです. ${INSTALL_DATA} は共有可能なデータを インストールするコマンドです. ${INSTALL_MAN} はマニュアルとその他のドキュメ ントをインストールするコマンドです.(圧縮はしません)

これらは基本的にinstallコマンドに適当なフラグを与え たものです. どのようにこれらを使用するかは以下の例を見てください. OS や OS のバージョンの区別

Portの過程で, 修正や, どのバージョンのUNIXで動くかによる条件 つきコンパイルなどが必要なコードに出会うかもしれません. その ような条件つきコンパイルなどのための変更をおこなうときには, FreeBSD 1.x システムへの移植や, CSRGの4.4BSD, BSD/386, 386BSD, NetBSD, OpenBSD などの他のBSDシステムへの移植が可能な ように, できるだけ普遍的な変更をおこなうことを心がけてください.

4.3BSD/Reno (1990) およびそれより新しいBSD版を古いバージョン と区別するには `BSD' マクロを利用するのがよいでしょう. これは <sys/param.h> で定義されています. このファ イルがすでにインクルードされていればよいのですが, もしそうでな い場合には以下のコードを, その.c ファイルの適当な場所 に加えてください. #if (defined(__unix__) || defined(unix)) && !defined(USG) #include #endif

これらのシンボルが定義されているすべてのシステムには sys/param.h があるはずです. もし, そうでないシステムを発見した ら我々にも教えてください. &a.ports; までメールを送ってください.

あるいは, GNU の Autoconf のスタイルを使用することもできます, #ifdef HAVE_SYS_PARAM_H #include #endif この方法を使用するときには, Makefile 中のCFLAGS-DHAVE_SYS_PARAM_H を加えることを忘れないようにしてく ださい. いったん<sys/param.h>がインクルードされると, #if (defined(BSD) && (BSD >= 199103)) このようにしてそのコードが4.3 Net2コードベース, または それより新しいもの (例: FreeBSD 1.x, 4.3/Reno, NetBSD 0.9, 386BSD, BSD/386 1.1とそれ以前) の上でコンパイルされているかを検出できます. #if (defined(BSD) && (BSD >= 199306)) これは, 4.4コードベース, またはそれより新しいもの (例: FreeBSD 2.x, 4.4, NetBSD 1.0, BSD/386 2.0とそれ以後) の上でコンパイルさ れているかどうかを検出するために使用します. 4.4BSD-Lite2 コードベースでは, BSD マクロの値は 199506 になっ ています. これは参考程度の意味合いしかありません. 4.4-Lite ベースの FreeBSD と 4.4-Lite2 での変更がマージされた バージョンとを区別するのに使用するべきものではありません. この目的のためには, __FreeBSD__ マクロをかわりに使用してくださ い.

以下は控え目に使ってください. __FreeBSD__ はFreeBSDのすべての版で定義されてい ます. 変更がFreeBSDだけに適用されるとき以外は使用しないでく ださい. Portでよくある, strerror() ではなく sys_errlist[] を使うなどは, FreeBSDでの変更ではなく, BSDの流儀です. FreeBSD 2.xでは__FreeBSD__が2と定義されていま す. それ以前の版では1になっています. その後の版では, そのメジャー番号に合うように上がっていきます. もし, FreeBSD 1.x システムと FreeBSD 2.x あるいは FreeBSD 3.x システムを区別する必要があれば, 上で述べた BSDマクロを使用するのが, 大抵の場合において正しい答です. もし, FreeBSD特有の変更であ れば (`ld' を使うときのシェアードライブラリ用のな オプションなど), __FreeBSD__を使い `#if __FreeBSD__ > 1' のようにFreeBSD 2.x および, それ以降のシステムを検出するのはかまいません. もし, 2.0-RELEASE以降のFreeBSDシステムを細かく検出したけれ ば, 以下を使用することができます. #if __FreeBSD__ >= 2 #include # if __FreeBSD_version >= 199504 /* 2.0.5+ release specific code here */ # endif #endif __FreeBSD_version の値は以下の通りです: 2.0-RELEASE: 199411 2.1-current's: 199501, 199503 2.0.5-RELEASE: 199504 2.2-current (2.1以前): 199508 2.1.0-RELEASE: 199511 2.2-current (2.1.5以前): 199512 2.1.5-RELEASE: 199607 2.2-current (2.1.6以前): 199608 2.1.6-RELEASE: 199612 2.1.7-RELEASE: 199612 2.2-RELEASE: 220000 2.2.1-RELEASE: 220000 (2.2-RELEASE と同じです) 2.2-STABLE (2.2.1-RELEASE 以後): 220000 (これも同じです) 2.2-STABLE (texinfo-3.9 以後): 221001 2.2-STABLE (top 導入以後): 221002 2.2.2-RELEASE: 222000 2.2-STABLE (2.2.2-RELEASE 以後): 222001 2.2.5-RELEASE: 225000 2.2-STABLE (2.2.5-RELEASE 以後): 225001 2.2-STABLE (ldconfig -R 以後): 225002 2.2.6-RELEASE: 226000 2.2.7-RELEASE: 227000 2.2-STABLE (2.2.7-RELEASE 以後): 227001 2.2-STABLE (semctl(2) 変更後): 227002 2.2.8-RELEASE: 228000 2.2-STABLE (2.2.8-RELEASE 以後): 228001 3.0-current (mount(2) 変更以前): 300000 3.0-current (mount(2) 変更後): 300001 3.0-current (semctl(2) 変更後): 300002 3.0-current (ioctl 引数変更後): 300003 3.0-current (ELF(2) 移行後): 300004 3.0-RELEASE: 300005 3.0-current (3.0-RELEASE 以後): 300005 (2.2-STABLEは, 2.2.5-RELESE 以後, "2.2.[5678]-STABLE" と呼ばれ ることがあります.) 見ての通り, これは年・月というフォーマットになっていましたが, バージョン 2.2 から, より直接的にメジャー/マイナー番号を使う ように変更になりました. 並行していくつかのブランチ(枝分かれし たバージョン)を開発する場合には, リリースされた日付でそれらの リリースを分類することが不可能だからです. (あなたが今 port を作成するときに, 古い -current 達について心配 する必要はありません. これは参考のために挙げられているにすぎま せん.)

これまで, 何百ものportが作られてきましたが, __FreeBSD__が正しく使われたのは, 1つか2つの場合だけで しょう. 以前のportが誤った場所でそのマクロを使っているからと いって, それをまねする理由はありません.

`.include <bsd.port.mk>' の行の後には なにも書かないようにしてください. 大抵の場合は Makefile の 中程のどこかで, &dollar{ARCH} `uname -m' で返される アーキテクチャ. (例, `i386'). &dollar{OPSYS}`uname -s' で返される オペレーティングシステム (例, `FreeBSD'). &dollar{OSREL} オペレーティングシステムの リリースバージョン (例., `2.1.5', `2.2.7'). &dollar{OSVERSION} 数字形式のオペレーティングシステム のバージョン, 上記の と同じです. &dollar{PORTOBJFORMAT} システムのオブジェクト フォーマット (`aout' あるいは `elf'). &dollar{LOCALBASE} 'local' ツリーのベース. (例, `/usr/local/'). &dollar{X11BASE} `X11' ツリーのベース. (例, `/usr/X11R6/'). &dollar{PREFIX} portsのインストール先 (を参照).

# no need to compile lang/perl5 if perl5 is already in system .if ${OSVERSION} > 300003 BROKEN= perl is in system .endif # only one shlib version number for ELF .if ${PORTOBJFORMAT} == "elf" TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR} .else TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR}.${SHLIB_MINOR} .endif # software already makes link for ELF, but not for a.out post-install: .if ${PORTOBJFORMAT} == "aout" ${LN} -sf liblinpack.so.1.0 ${PREFIX}/lib/liblinpack.so .endif 付加的ドキュメント

普通のマニュアルやinfoファイルのほかにユーザにとって有用だ と思えるようなドキュメントがある場合には, ${PREFIX}/share/docの下にインストールしてく ださい. これは前記と同様, post-installターゲットの 中からするのがいいでしょう.

まず, あなたのportのために新しいディレクトリを作りま す. どのportのドキュメントか簡単にわかるような名前にする必 要がありますので, 普通は${PKGNAME}からバージョ ン番号を除いた部分を使うといいでしょう. もちろん, ユーザが異 なるバージョンのものを同時に使うことが予想されるportの場合 には, ${PKGNAME}をそのまま使ってかまいません.

ユーザが/etc/make.confでこの部分を禁止するために NOPORTDOCSという変数をセットしている場合には, これらのドキュメントがインストールされないようにしてください. こんな具合です. post-install: .if !defined(NOPORTDOCS) ${MKDIR} -p ${PREFIX}/share/doc/xv ${INSTALL_MAN} ${WRKSRC}/docs/xvdocs.ps ${PREFIX}/share/doc/xv .endif

これらのファイルをpkg/PLISTに入れるのを忘れないよ うにしてください. (packageが/etc/make.conf内の 変数を読む方法は今のところ存在しませんので, NOPORTDOCSについては気にしないでください.)

インストール時に pkg/MESSAGE ファイルを利用して, メッセージを表示することができます. 詳細は の節を参照してください. DIST_SUBDIR

/usr/ports/distfilesディレクトリ内をあまり散らかさ ないようにしてください. たくさんのファイルを取ってくるport や, 数は少なくてもほかのportのファイルと混同されるおそれが あるファイル (`Makefile' など) がある場合には, ${DIST_SUBDIR}にportの名前 (${PKGNAME}からバージョン番号を取った部分を 使うといいでしょう) を入れてください. すると, ${DISTDIR}がデフォルトの /usr/ports/distfilesから /usr/ports/distfiles/${DIST_SUBDIR}に変更さ れ, 取ってきたファイルはすべてそのサブディレクトリの中に置か れるようになります.

また, ファイルを取ってくるときにバックアップサイトとして使わ れるftp.freebsd.orgのディレクトリ名にもこの変数の 値が使われます. (${DISTDIR}を明示的に指定し た場合には, ローカルのファイルを置くところは変わりますが, こ のサイトのディレクトリ名は変わりませんので, 必ず ${DIST_SUBDIR}を使うようにしてください.)

この変数はMakefile中で明示的に指定された ${MASTER_SITES}には影響しないことに注意して ください. RCS文字列

RCSが特別な意味を与えている文字列をパッチ内に入れないように してください. ファイルを私たちのソースツリーに入れる時にこれら の文字列はCVSによって書き換えられてしまい, あとでまたパッチ を使おうとした時にうまくいかないことがあります. RCS文字列は ドル記号 (`$') で囲まれており, `$Id' や `$RCS' などで始まり ます. パッチ作成上の注意

diffの再帰 (`-r') フラグを使って再帰的なパッ チを作るのは大変結構なのですが, でき上がったパッチは必ず目で チェックして余計なゴミが入っていないことを確認してくださ い. よくあるのはバックアップファイル同士の変更点, あるいは Imake や GNU ファイルをまるごと消す場合にはパッチを使わずに post-extractターゲットで消す方が簡単です. できあがった 差分に満足したら, それらをソースのファイルごとに別々の パッチファイルに分割してください. PREFIX

なるべくportは${PREFIX}に対する相対パス にインストールすることができるように心がけてください. (この変数の値は ${USE_X_PREFIX}${USE_IMAKE} が指定してある時には ${X11BASE} (デフォルト/usr/X11R6), そうでない場合には${LOCALBASE} (デフォルト/usr/local) にセットされます.)

サイトによってフリーソフトウェアがインストールされる場所が 違いますので, ソース内で `/usr/local' や `/usr/X11R6' を明示的に書かないようにしてくださ い. Xのプログラムでimakeを使うものについては, これは問題に はなりません. それ以外の場合には, ソース中のMakefileやスク リプトで `/usr/local' (imakeを使わないXのプログラ ムは `/usr/X11R6') と書いてあるところを `${PREFIX}' に書き換えてください. この値は portのコンパイル, およびインストール時に自動的に環境変数として 下位makeに渡されます.

USE_X_PREFIXは本当に必要な時(つまり, X のライブラ リなどとリンクしたり, ${X11BASE} 以下にある ファイルを参照したりする必要がある時)以外には設定しないでく ださい.

変数${PREFIX}の値はportのMakefileやユー ザの環境で変更することもできます. しかし, 個々のportが Makefileでこの変数の値を明示的に設定することはなるべくしない でください.

また, 他のportからインストールされるプログラムやファイル を指定するときには, 上で述べた変数を使用してください. 例えば, lessのフルパスをPAGERというマクロに入れた い場合は, コンパイラに -DPAGER=\"/usr/local/bin/less\"と渡すかわりに -DPAGER=\"${PREFIX}/bin/less\" (Xを使う portの時は -DPAGER=\"${LOCALBASE}/bin/less\") を渡し てください. こうしておけば, `/usr/local' がまるごとどこか他 の場所に移してあるサイトでも, あなたのportがそのまま使える 可能性が高くなります. ディレクトリ構成

インストール時には${PREFIX}の正しいサブディ レクトリにファイルを置くように心がけてください. ソフトウェア によっては新しいディレクトリを一つ作ってファイルを全部それに 入れてしまうものがありますが, それはよくありません. また, バ イナリ, ヘッダファイルとマニュアル以外のすべてを `lib'というディレクトリに入れてしまうportもあります が, これもBSD的なファイルシステム構成からいうと正しくありま せん. これは以下のように分散すべきです. `etc' にセッ トアップ/コンフィグレーションファイル, `libexec' に 内部で使用されるプログラム (コマンドラインから呼ばれることの ないコマンド), `sbin' に管理者用のコマンド, `info' に GNU Info 用のドキュメント, そして `share' にアーキテクチャに依存しないファイルが入り ます. 詳細については man hier(7) を見てくださ い. /usrの構成方針はほとんどそのまま /usr/localにもあてはまります. USENET ニュースを 扱う ports は例外です. これらは, ファイルのインストール先として ${PREFIX}/news を使用します. 空のディレクトリの除去

ports は デインストール(削除) の際には, 自分自身を消去した あとに, (ディレクトリの)除去をするようにしてください. これは, 大抵の場合 : lib/X11/oneko/pixmaps/cat.xpm lib/X11/oneko/sounds/cat.au : @dirrm lib/X11/oneko/pixmaps @dirrm lib/X11/oneko/sounds @dirrm lib/X11/oneko といった感じです.

しかし, ときとして, 他の port をディレクトリを共有している ために : @unexec rmdir %D/share/doc/gimp 2>/dev/null || true これを使えば, たとえ, 他の port がファイルをインストールして いて, ${PREFIX}/share/doc/gimp が空でない場合でも エラーメッセージは表示されませんし, UID

もしあなたの portがインストールされるシステム上に特定のユー ザを必要とする場合は, pkg/INSTALL スクリプトから pwコマンドを実行して自動的にそのユーザを追加するよ うにしてください. net/cvsup-mirror の portが参考になるでしょう.

もしあなたの port が, バイナリのパッケージとして としてインストールされるときにも, コンパイルされたときと同じ ユーザー/グループ ID を使わなければならないのなら, 50 から 99 の間で空いている UID を選んで登録してください. japanese/Wnn の port が参考になるでしょう.

既にシステムや他の portで利用されている UIDを使わないように 十分注意してください. 現在の 50から 99までの間の UIDは以下の とおりです. majordom:*:54:54:Majordomo Pseudo User:/usr/local/majordomo:/nonexistent cyrus:*:60:60:the cyrus mail server:/nonexistent:/nonexistent gnats:*:61:1:GNATS database owner:/usr/local/share/gnats/gnats-db:/bin/sh uucp:*:66:66:UUCP pseudo-user:/var/spool/uucppublic:/usr/libexec/uucp/uucico xten:*:67:67:X-10 daemon:/usr/local/xten:/nonexistent pop:*:68:6:Post Office Owner (popper):/nonexistent:/nonexistent wnn:*:69:7:Wnn:/nonexistent:/nonexistent ifmail:*:70:66:Ifmail user:/nonexistent:/nonexistent pgsql:*:70:70:PostgreSQL pseudo-user:/usr/local/pgsql:/bin/sh ircd:*:72:72:IRCd hybrid:/nonexistent:/nonexistent alias:*:81:81:QMail user:/var/qmail/alias:/nonexistent qmaill:*:83:81:QMail user:/var/qmail:/nonexistent qmaild:*:82:81:QMail user:/var/qmail:/nonexistent qmailq:*:85:82:QMail user:/var/qmail:/nonexistent qmails:*:87:82:QMail user:/var/qmail:/nonexistent qmailp:*:84:81:QMail user:/var/qmail:/nonexistent qmailr:*:86:82:QMail user:/var/qmail:/nonexistent msql:*:87:87:mSQL-2 pseudo-user:/var/db/msqldb:/bin/sh

このリストを最新の状態に保つためにも, この範囲の UID や GID を予約するような port を作ったり, 既存の port にそのような改変を行って我々に送るときには, UID の予約に関する注意書きをつけてください. 合理的な port

Makefile は単純かつ適切であるべきです. もし, Makefile を 数行短かくできたり, もっと読みやすくできるのであれば, そうし てください. 例えば, shell の `if' 構文を使う代りに, make の `.if' 構文を使う, ${EXTRACT*}の再定義で代用できるのであれば, do-extractを再定義しない, `CONFIGURE_ARGS += --prefix=${PREFIX}' とするかわりに, $GNU_CONFIGURE とする, などです. CFLAGS の尊重

${CFLAGS} 変数は尊重すべきです. その port がこれを無視するのであれば, `NO_PACKAGE=ignores cflags' を Makefile に加えてください. コンフィグレーション(設定)ファイル

もしあなたの port が設定ファイルを ${PREFIX}/etc に置く必要がある場合には, それを単純にインストールしたり, pkg/PLIST に加え ては代りに, 見本となるファイルを suffix ( `<filename>.sample' が良いでしょう) を付けて インストールして, を表示して, ソフトウエアを動かす前に, ユーザがそのファイル をコピーして編集をしなければならないことを知らせましょう. Portlint

送付や commit をする前に を使ってチェック しましょう. フィードバック

Portを作るためにソフトウェアに変更を加えたら, なるべく原 作者にその旨を伝えてパッチ等を送ってください. これらが次のリ リースに取り入れられれば, アップグレードが楽になります. その他諸々

pkg/DESCR, pkg/COMMENT, pkg/PLIST などのファイルは, それぞれ2重にチェックし てください. 再検討してもっと良い記述があれば, それに置きかえ てください.

GNU General Public License(GNU一般公有使用許諾)のコピーは (すでにあるので)コピーしないでください, おねがいします.

法律に関することには, 十分注意をはらってください. 私達に法律に反するような形でソフトフェアの配布をさせない でください! 困ったら....

私たちに質問を送る前に, 既存のportの例とbsd.port.mkを ちゃんと読んでください! ;)

それでもわからないことがあったら, 一人で悩まないでどんどん 質問してください! :) Makefileのお手本

これはportのMakefileを作る際のお手本です. かぎかっこ ([])内のコメントは忘れずに取ってください.

変数の順番, 段落の間の空行など, Makefileを作るときはなるべくこ の形式にしたがってください. この形式は重要な情報が簡単に見つけら れるように設計されています. を使って Makefile をチェックすることが 推奨されています. [ヘッダ -- どのようなportのMakefileかすぐにわかるようになっています] # New ports collection makefile for: xdvi # Version required: pl18 ["1.5alpha" みたいなのでも結構です] [この Makefile の最初の版が作成された日付です. この port をアップグ レードするときには変えないでください.] # Date created: 26 May 1995 [このソフトウェアを最初に FreeBSD に port した人の名前, つまり, この Makefile の最初の版を書いた人です. この port をアップグレー ドするとき, この行も変えないでください.] # Whom: Satoshi Asami # # $Id$ [ ^^^^ この部分は, CVS ツリーに入れる時に自動的に RCS の ID 文字列に 置き換えられます.] # [Port自体, およびオリジナルのソースを取ってくるところを記述する部分. 最初は必ずDISTNAME, そして必要ならPKGNAME, CATEGORIES, 続いて MASTER_SITESがおかれ, さらに MASTER_SITE_SUBDIR がおかれることもあり ます. そのあと, EXTRACT_SUFX か DISTFILES を指定することも可能です] DISTNAME= xdvi PKGNAME= xdvi-pl18 CATEGORIES= print [MASTER_SITE_* マクロを使用しない場合は, 最後のスラッシュを忘れないように ("/")!] MASTER_SITES= ${MASTER_SITE_XCONTRIB} MASTER_SITE_SUBDIR= applications [ソースファイルが標準の ".tar.gz" 形式でない時にこれを使いましょう] EXTRACT_SUFX= .tar.Z [配布パッチのセクション -- ない場合もあります] PATCH_SITES= ftp://ftp.sra.co.jp/pub/X11/japanese/ PATCHFILES= xdvi-18.patch1.gz xdvi-18.patch2.gz [保守責任者 -- これは *必ず* 必要です. 担当者 (あなた) 自身, あるいは 担当者に素早く連絡をとれる人のアドレスを書いてください. どうしてもこ こに自分のアドレスを書くのがいやな人は "ports@FreeBSD.ORG" と書いて もいいです] MAINTAINER= asami@FreeBSD.ORG [依存するport -- ない場合もあります] RUN_DEPENDS= gs:${PORTSDIR}/print/ghostscript LIB_DEPENDS= Xpm.5:${PORTSDIR}/graphics/xpm [ここには標準のbsd.port.mkの変数で, 上のどれにもあてはまらないものを 書きます] [コンフィグレーション, コンパイル, インストールなどの時に質問をする なら...] IS_INTERACTIVE=yes [${DISTNAME}以外のディレクトリにソースが展開されるなら...] WRKSRC= ${WRKDIR}/xdvi-new [配布されているパッチが ${WRKSRC} に対する相対パスで作られてい ない場合にこの変数の指定が必要かも...] PATCH_DIST_STRIP= -p1 [GNU autoconfによって生成された "configure" スクリプトを走らせたいなら...] GNU_CONFIGURE= yes [/usr/bin/makeでなく, GNU makeを使わないといけないなら...] USE_GMAKE= yes [これがXのアプリケーションで "xmkmf -a" を走らせたいなら...] USE_IMAKE= yes [などなど] [下の方のルールで使う非標準の変数] MY_FAVORITE_RESPONSE= "yeah, right" [そして, 特別なターゲット, 使用順に] pre-fetch: i go fetch something, yeah post-patch: i need to do something after patch, great pre-install: and then some more stuff before installing, wow [最後には必ず] .include Packageの名前

Packageの名前は以下のルールにしたがってつけてください. こ れはpackageのディレクトリを見やすくするためで, 無秩序な名前 がたくさん並んでいるとユーザが使いづらくなるのではという心配か らです. (FTPサイトなどにはたくさんpackageがありますからね.)

Packageの名前は以下のようにしてください. [<言語>-]<名前>[[-]<オプション>]-<バージョン.番号>; ${DISTNAME} が上記の形式になっていない場合に は, ${PKGNAME} をそのようにしてください. FreeBSDはユーザの慣れ親しんだ言語のサポートに力を入れて います. 特定の言語のためのportのpackage名には `<言語>' に ISO-639 で定義されている言語名の略称を入れ てください. 例えば, 日本語なら `ja', ロシア語なら `ru', ベト ナム語なら `vi', 中国語なら `zh', 韓国語ならば `ko', ドイツ 語なら `de', といった具合です. `<名前>' の部分は原則的にはすべて英小文字 を使います. 例外はたくさんのプログラムが入っている巨大なport の場合で, XFree86 (ほんとにあるんですよ) やImageMagickな どがこれにあたります. そうでない場合には, 名前の大文字を小文 字に (少なくとも最初の一字だけは) 変えてください. もし, 大文字であることが重要な場合(例えば, 1文字の名前, R とか V)には, あなたの裁量で大文字を使うのも良いでしょう. Perl 5 のモジュールでは, 頭に `p5-' を付け, 2重コロン(::) のセパレータをハイフン(-)に置きかえるしきたりになっています. 例えば, `Data::Dumper' は `p5-Data-Dumper' になります. また, その ソフトウェアの名前として通常使われるものに番号, ハイフン, あ るいは下線が入っている場合には, それらを使うことも構いません (`kinput2' など). コンパイル時に環境変数やmakeの引数などで を変えてコンパイルできる場合, `<compiled.specifics>' にそのコンパイル時のデフォルトを入れてください (ハイフンはあってもなくてもかまいません). 用紙のサイズ, あるいはフォントの解像度などがこれにあたります. バージョン番号は数字とアルファベットからなり, ピリオド (.) で区切ります. アルファベットは二文字以上続けてはいけませ ん. ただ一つの例外は「パッチレベル」を意味する `pl' で, それ 以外にバージョン番号がまったくついていない場合にのみ使うことがで きます.

では, ${DISTNAME}を正しい ${PKGNAME}に直す例を見てみましょう: DISTNAME PKGNAME 理由 mule-2.2.2 mule-2.2.2 まったく問題なし XFree86-3.1.2 XFree86-3.1.2 同上 EmiClock-1.0.2 emiclock-1.0.2 プログラム一つだけの時は小文字のみ gmod1.4 gmod-1.4 `<名前>' のあとにハイフンが必要 xmris.4.02 xmris-4.02 同上 rdist-1.3alpha rdist-1.3a `alpha'のような文字列は使えない es-0.9-beta1 es-0.9b1 同上 v3.3beta021.src tiff-3.3 なんなんでしょう ;) tvtwm tvtwm-pl11 バージョン番号は必ず必要 piewm piewm-1.0 同上 xvgr-2.10pl1 xvgr-2.10.1 `pl' が使えるのは他にバージョン番号がない場合のみ gawk-2.15.6 ja-gawk-2.15.6 日本語バージョン psutils-1.13 psutils-letter-1.13 コンパイル時に用紙のサイズを指定 pkfonts pkfonts300-1.0 300dpiフォント用のpackage

オリジナルのソースにまったくバージョン情報が見当たらず, また原作 者が新しいバージョンをリリースする可能性が低いときには, バージョ ン番号として `1.0' を使えばいいでしょう (上記のpiewmの例がこ れにあたります). そうでない場合には, 原作者に聞くか, 日付 (`年. 月.日') を使うなどしてください. カテゴリ

すでに御存知のように, ports はいくつかのカテゴリに 分類されています. これを有効に利用するためには, port を 行う人々とユーザが, そろぞれのカテゴリーが何であるか, どのようにしてカテゴリに分類するかを理解する必要があります. 現在のカテゴリのリスト

まず, これが現在の port のカテゴリーのリストです. アスタリスク(pkg/COMMENT に1行の記述 があります(例, archivers/pkg/COMMENT). Archiving tools. Astronomical ports. Sound support. Benchmarking utilities. Biology-related software. Computer aided design tools. Chinese language support. Communication software. Mostly software to talk to your serial port. Character code converters. Databases. Things that used to be on the desktop before computers were invented. Development utilities. Do not put libraries here just because they are libraries -- unless they truly don't belong to anywhere else, they shouldn't be in this category. General editors. Specialized editors go in the section for those tools (e.g., a mathematical-formula editor will go in Emacs-lisp ports. Emulators for other operating systems. Terminal emulators do Games. German language support. Graphics utilities. Japanese language support. Ports that form the K Desktop Environment (kde). Korean language support. Programming languages. Mail software. Numerical computation software and other utilities for mathematics. MBone applications. Miscellaneous utilities -- basically things that doesn't belong to anywhere else. This is the only category that should not appear with any other non-virtual category. If you have Miscellaneous networking software. USENET news software. Ports from the OffiX suite. Ports that require perl version 5 to run. Software to use with the 3Com PalmPilot. Various programs from Plan9. Printing software. Desktop publishing tools (previewers, etc.) belong here too. Software written in python. Russian language support. Security utilities. Command line shells. System utilities. Ports that use tcl version 7.5 to run. Ports that use tcl version 7.6 to run. Ports that use tcl version 8.0 to run. Ports that use tcl version 8.1 to run. Text processing utilities. It does not include desktop publishing tools, which go to Ports that use tk version 4.1 to run. Ports that use tk version 4.2 to run. Ports that use tk version 8.0 to run. Ports that use tk version 8.1 to run. Vietnamese language support. Software related to the World Wide Web. HTML language support belong here too. The X window system and friends. This category is only for software that directly support the window system. Do not put regular X applications here. If your port is an X application, define X11 clocks. X11 file managers. X11 fonts and font utilities. X11 toolkits. X11 window managers. 適切なカテゴリの選択

多くのカテゴリーに重なるので, どれを '第一'カテゴリにするか を決めなければならないことがたびたびあるでしょう. これを うまく決めるルールがいくつかあります. 以下はその優先順の リストで, 優先度の高いものから低いものの順に書いてあります. 言語特有のカテゴリがまず最初です. 例えば日本語の X11 のフォントをインストールする port の場合, japanese x11-fonts' となるでしょう. より特徴的なカテゴリーが, 一般的なカテゴリーより優先さ れます. 例えば, HTML エディタの場合は `www editors' となり, 逆順にはしないでください. また, port が もし, あなたの port が他のどのカテゴリにも属しないばあい には,

もし, あなたがカテゴリについて自信が持てない場合には, そのこと を このドキュメントと ports システムの変更

もしあなたが, たくさんの ports の保守をしているのであれば, &a.ports メーリングリストの内容をフォロウすることを 考えてください. Ports のしくみについての重要な変更点はここに アナウンスされます. 最新の変更点については, いつでも, で詳細な情報を得ることができま す. やっとおしまい!

いやはや, 長い文章ですみません. ここまで読んでくださった方に は感謝, 感謝でございます. (_ _)

さあ, portの作り方がわかったところで, 世界中のソフトウェア をport化しましょう. FreeBSDプロジェクトに貢献するには, それ がもっとも簡単な方法です! :)