1 # -*- mode: Fundamental; tab-width: 4; -*-
3 # bsd.port.mk - 940820 Jordan K. Hubbard.
4 # This file is in the public domain.
6 # $Id: bsd.port.mk,v 1.57 1994/10/14 21:58:09 ache Exp $
8 # Please view me with 4 column tabs!
11 # Supported Variables and their behaviors:
13 # Variables that typically apply to all ports:
15 # PORTSDIR - The root of the ports tree (default: /usr/ports).
16 # DISTDIR - Where to get gzip'd, tarballed copies of original sources
17 # (default: ${PORTSDIR}/distfiles).
18 # PREFIX - Where to install things in general (default: /usr/local).
19 # MASTER_SITES - Primary location(s) for distribution files if not found
21 # PACKAGES - A top level directory where all packages go (rather than
22 # going locally to each port). (default: ${PORTSDIR}/packages).
23 # GMAKE - Set to path of GNU make if not in $PATH (default: gmake).
24 # XMKMF - Set to path of `xmkmf' if not in $PATH (default: xmkmf).
26 # Variables that typically apply to an individual port:
28 # WRKDIR - A temporary working directory that gets *clobbered* on clean.
29 # WRKSRC - A subdirectory of ${WRKDIR} where the distribution actually
30 # unpacks to. (Default: ${WRKDIR}/${DISTNAME} unless
31 # NO_WRKSUBDIR is set, in which case simply ${WRKDIR}).
32 # DISTNAME - Name of port or distribution.
33 # DISTFILES - Name(s) of archive file(s) containing distribution
34 # (default: ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX}).
35 # EXTRACT_ONLY - If defined, a subset of ${DISTFILES} you want to
37 # PATCHDIR - A directory containing any required patches.
38 # SCRIPTDIR - A directory containing any auxilliary scripts.
39 # FILESDIR - A directory containing any miscellaneous additional files.
40 # PKGDIR - A direction containing any package creation files.
42 # NO_EXTRACT - Use a dummy (do-nothing) extract target.
43 # NO_CONFIGURE - Use a dummy (do-nothing) configure target.
44 # NO_BUILD - Use a dummy (do-nothing) build target.
45 # NO_PACKAGE - Use a dummy (do-nothing) package target.
46 # NO_INSTALL - Use a dummy (do-nothing) install target.
47 # NO_WRKSUBDIR - Assume port unpacks directly into ${WRKDIR}.
48 # NO_DEPENDS - Don't verify build of dependencies.
49 # USE_GMAKE - Says that the port uses gmake.
50 # USE_IMAKE - Says that the port uses imake.
51 # HAS_CONFIGURE - Says that the port has its own configure script.
52 # GNU_CONFIGURE - Set if you are using GNU configure (optional).
53 # CONFIGURE_ARGS - Pass these args to configure, if $HAS_CONFIGURE.
54 # IS_INTERACTIVE - Set this if your port needs to interact with the user
55 # during a build. User can then decide to skip this port by
56 # setting BATCH, or compile ONLY interactive ports by setting
58 # DEPENDS - A list of other ports this package depends on being
59 # made first, relative to ${PORTSDIR} (e.g. x11/tk, lang/tcl,
61 # EXTRACT_CMD - Command for extracting archive (default: tar).
62 # EXTRACT_SUFX - Suffix for archive names (default: .tar.gz).
63 # EXTRACT_ARGS - Arguments to ${EXTRACT_CMD} (default: -C ${WRKDIR} -xzf).
65 # NCFTP - Full path to ncftp command if not in $PATH (default: ncftp).
66 # NCFTP_ARGS - Arguments to ${NCFTP} (default: -N).
69 # Default targets and their behaviors:
71 # fetch - Retrieves ${DISTFILES} into ${DISTDIR} as necessary.
72 # extract - Unpacks ${DISTFILES} into ${WRKDIR}.
73 # configure - Applies patches, if any, and runs either GNU configure, one
74 # or more local configure scripts or nothing, depending on
76 # build - Actually compile the sources.
77 # install - Install the results of a build.
78 # package - Create a package from a build.
80 # Default sequence for "all" is: fetch extract configure build
82 .if exists(${.CURDIR}/../Makefile.inc)
83 .include "${.CURDIR}/../Makefile.inc"
86 # These need to be absolute since we don't know how deep in the ports
87 # tree we are and thus can't go relative. They can, of course, be overridden
88 # by individual Makefiles.
89 PORTSDIR?= ${DESTDIR}/usr/ports
90 PREFIX?= ${DESTDIR}/usr/local
91 DISTDIR?= ${PORTSDIR}/distfiles
92 PACKAGES?= ${PORTSDIR}/packages
93 WRKDIR?= ${.CURDIR}/work
94 .if defined(NO_WRKSUBDIR)
97 WRKSRC?= ${WRKDIR}/${DISTNAME}
99 PATCHDIR?= ${.CURDIR}/patches
100 SCRIPTDIR?= ${.CURDIR}/scripts
101 FILESDIR?= ${.CURDIR}/files
102 PKGDIR?= ${.CURDIR}/pkg
104 .if exists(${PORTSDIR}/../Makefile.inc)
105 .include "${PORTSDIR}/../Makefile.inc"
109 # Change these if you'd prefer to keep the cookies someplace else.
110 EXTRACT_COOKIE?= ${WRKDIR}/.extract_done
111 CONFIGURE_COOKIE?= ${WRKDIR}/.configure_done
112 INSTALL_COOKIE?= ${WRKDIR}/.install_done
114 # How to do nothing. Override if you, for some strange reason, would rather
118 # Miscellaneous overridable commands:
129 PATCH_ARGS?= -d ${WRKSRC} --quiet -E ${PATCH_STRIP}
132 EXTRACT_SUFX?= .tar.gz
133 EXTRACT_ARGS?= -C ${WRKDIR} -xzf
136 PKG_ARGS?= -v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST -p ${PREFIX}
139 # I guess we're in the master distribution business! :) As we gain mirror
140 # sites for distfiles, add them to this list.
141 MASTER_SITES+= ftp://freebsd.cdrom.com/pub/FreeBSD/FreeBSD-current/ports/distfiles/
143 # Derived names so that they're easily overridable.
144 DISTFILES?= ${DISTNAME}${EXTRACT_SUFX}
146 .if exists(${PACKAGES})
147 PKGFILE?= ${PACKAGES}/${DISTNAME}${PKG_SUFX}
149 PKGFILE?= ${DISTNAME}${PKG_SUFX}
152 .if defined(GNU_CONFIGURE)
153 CONFIGURE_ARGS?= --prefix=${PREFIX}
159 # If we're in BATCH mode and the port is interactive, or we're in
160 # interactive mode and the port is non-interactive, skip all the important
161 # targets. The reason we have two modes is that one might want to leave
162 # a build in BATCH mode running overnight, then come back in the morning
163 # and do _only_ the interactive ones that required your intervention.
164 # This allows you to do both.
166 .if (defined(IS_INTERACTIVE) && defined(BATCH)) || (!defined(IS_INTERACTIVE) && defined(INTERACTIVE))
188 all: extract configure build
191 .if !target(is_depended)
192 is_depended: all install
195 # The following are used to create easy dummy targets for disabling some
196 # bit of default target behavior you don't want. They still check to see
197 # if the target exists, and if so don't do anything, since you might want
198 # to set this globally for a group of ports in a Makefile.inc, but still
199 # be able to override from an individual Makefile (since you can't _undefine_
200 # a variable in make!).
201 .if defined(NO_EXTRACT) && !target(extract)
203 @touch -f ${EXTRACT_COOKIE}
205 .if defined(NO_CONFIGURE) && !target(configure)
207 @touch -f ${CONFIGURE_COOKIE}
209 .if defined(NO_BUILD) && !target(build)
213 .if defined(NO_PACKAGE) && !target(package)
217 .if defined(NO_INSTALL) && !target(install)
219 @touch -f ${INSTALL_COOKIE}
222 # More standard targets start here.
224 .if !target(pre-install)
230 install: ${INSTALL_COOKIE}
233 @echo "===> Installing for ${DISTNAME}"
234 @${MAKE} ${.MAKEFLAGS} pre-install
235 .if defined(USE_GMAKE)
236 @(cd ${WRKSRC}; ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install)
237 .else defined(USE_GMAKE)
238 @(cd ${WRKSRC}; ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install)
239 .if defined(USE_IMAKE)
240 @(cd ${WRKSRC}; ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
243 @touch -f ${INSTALL_COOKIE}
246 .if !target(pre-package)
253 # Makes some gross assumptions about a fairly simple package with no
254 # install, require or deinstall scripts. Override the arguments with
255 # PKG_ARGS if your package is anything but run-of-the-mill.
256 @if [ -d ${PKGDIR} ]; then \
257 echo "===> Building package for ${DISTNAME}"; \
258 ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; \
262 .if !target(pre-build)
268 build: configure pre-build
269 @echo "===> Building for ${DISTNAME}"
271 @echo "===> ${DISTNAME} depends on: ${DEPENDS}"
272 .if !defined(NO_DEPENDS)
273 @for i in ${DEPENDS}; do \
274 echo "===> Verifying build for $$i"; \
275 if [ ! -d $$i ]; then \
276 echo ">> No directory for $$i. Skipping.."; \
278 (cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
281 @echo "===> Returning to build of ${DISTNAME}"
284 .if defined(USE_GMAKE)
285 @(cd ${WRKSRC}; ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} all)
286 .else defined(USE_GMAKE)
287 @(cd ${WRKSRC}; ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} all)
289 @if [ -f ${SCRIPTDIR}/post-build ]; then \
290 env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
291 WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
292 FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
293 DEPENDS="${DEPENDS}" \
294 sh ${SCRIPTDIR}/post-build; \
298 .if !target(pre-configure)
303 .if !target(configure)
304 configure: extract ${CONFIGURE_COOKIE}
307 @echo "===> Configuring for ${DISTNAME}"
308 @${MAKE} ${.MAKEFLAGS} pre-configure
309 @if [ -d ${PATCHDIR} ]; then \
310 echo "===> Applying patches for ${DISTNAME}" ; \
311 for i in ${PATCHDIR}/patch-*; do \
312 ${PATCH} ${PATCH_ARGS} < $$i; \
315 @if [ -f ${SCRIPTDIR}/pre-configure ]; then \
316 env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
317 WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
318 FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
319 DEPENDS="${DEPENDS}" \
320 sh ${SCRIPTDIR}/pre-configure; \
322 @if [ -f ${SCRIPTDIR}/configure ]; then \
323 env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
324 WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
325 FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
326 DEPENDS="${DEPENDS}" \
327 sh ${SCRIPTDIR}/configure; \
329 .if defined(HAS_CONFIGURE)
330 @(cd ${WRKSRC}; ./configure ${CONFIGURE_ARGS})
332 .if defined(USE_IMAKE)
333 @(cd ${WRKSRC}; ${XMKMF} && ${MAKE} Makefiles)
335 @if [ -f ${SCRIPTDIR}/post-configure ]; then \
336 env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
337 WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
338 FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
339 DEPENDS="${DEPENDS}" \
340 sh ${SCRIPTDIR}/post-configure; \
342 @touch -f ${CONFIGURE_COOKIE}
345 .if !target(pre-fetch)
352 @if [ ! -d ${DISTDIR} ]; then mkdir -p ${DISTDIR}; fi
354 for file in ${DISTFILES}; do \
355 if [ ! -f $$file ]; then \
356 echo ">> $$file doesn't seem to exist on this system."; \
357 echo ">> Attempting to fetch it from a master site."; \
358 for site in ${MASTER_SITES}; do \
359 if ${NCFTP} ${NCFTPFLAGS} $${site}$${file}; then \
363 if [ ! -f $$file ]; then \
364 echo ">> Couldn't fetch it - please try to retreive this";\
365 echo ">> port manually into ${DISTDIR} and try again."; \
372 .if !target(pre-extract)
378 # We need to depend on .extract_done rather than the presence of ${WRKDIR}
379 # because if the user interrupts the extract in the middle (and it's often
380 # a long procedure), we get tricked into thinking that we've got a good dist
382 extract: fetch pre-extract ${EXTRACT_COOKIE}
385 @echo "===> Extracting for ${DISTNAME}"
388 .if defined(EXTRACT_ONLY)
389 @for file in ${EXTRACT_ONLY}; do \
390 ${EXTRACT_CMD} ${EXTRACT_ARGS} ${DISTDIR}/$$file ; \
393 @for file in ${DISTFILES}; do \
394 ${EXTRACT_CMD} ${EXTRACT_ARGS} ${DISTDIR}/$$file ; \
397 @touch -f ${EXTRACT_COOKIE}
400 .if !target(pre-clean)
407 @echo "===> Cleaning for ${DISTNAME}"
408 @rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} ${INSTALL_COOKIE}
412 # No pre-targets for depend or tags. It would be silly.
414 # Depend is generally meaningless for arbitrary ports, but if someone wants
415 # one they can override this. This is just to catch people who've gotten into
416 # the habit of typing `make depend all install' as a matter of course.