Ok...事實上並不太可能這麼簡單,port 方面可能需要作些修改才能正常使用。 因此, 本節將一步一步來介紹如何修改上一章的樣本以正常使用。
First, this is the sequence of events which occurs when the
user first types make in the port's
directory. Having
bsd.port.mk in another window while
reading this really helps to understand it.
別太擔心,不是很多人都真的了解 bsd.port.mk 在做什麼... :-)
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 FTP mirrors where we put 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 the port's distribution file (typically a
gzipped 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 patch files named
patch- are
found in *PATCHDIR (defaults to the
files 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.
The build target is run.
This is responsible for descending into the port's private
working directory (WRKSRC) and building
it.
The stage target is run.
This puts the final set of built files into a temporary
directory (STAGEDIR, see
節 6.1, “Staging”). The hierarchy of this directory
mirrors that of the system on which the package will be
installed.
The package target is run.
This creates a package using the files from the temporary
directory created during the
stage target and the port's
pkg-plist.
The install target is run.
This installs the package created during the
package target into the host
system.
The above are the default actions. In addition,
define targets
pre-
or
somethingpost-,
or put scripts with those names, in the
somethingscripts subdirectory, and they will be
run before or after the default actions are done.
For example, if there is a
post-extract target defined in the
Makefile, and a file
pre-build in the
scripts subdirectory, the
post-extract target will be called
after the regular extraction actions, and
pre-build will be executed before
the default build rules are done. It is recommended to
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
do-
targets from somethingbsd.port.mk.
For example, the commands to extract a port are in the target
do-extract. If
the default target does not do the job right, redefine the
do-
target in the somethingMakefile.
The “main” targets (for example,
extract,
configure, etc.) do nothing more
than make sure all the stages up to that one are completed and
call the real targets or scripts, and they are not intended to
be changed. To fix the extraction, fix
do-extract, but never ever change
the way extract operates!
Additionally, the target
post-deinstall is invalid and is
not run by the ports infrastructure.
Now that what goes on when the user types make
install is better understood, let us go through the
recommended steps to create the perfect port.
本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。
若有 FreeBSD 方面疑問,請先閱讀
FreeBSD 相關文件,如不能解決的話,再洽詢
<questions@FreeBSD.org>。
關於本文件的問題,請洽詢
<doc@FreeBSD.org>。