]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.port.mk
Invoke install.man if USE_IMAKE is set.
[FreeBSD/FreeBSD.git] / share / mk / bsd.port.mk
1 # -*- mode: Fundamental; tab-width: 4; -*-
2 #
3 #       bsd.port.mk - 940820 Jordan K. Hubbard.
4 #       This file is in the public domain.
5 #
6 # $Id: bsd.port.mk,v 1.57 1994/10/14 21:58:09 ache Exp $
7 #
8 # Please view me with 4 column tabs!
9
10
11 # Supported Variables and their behaviors:
12 #
13 # Variables that typically apply to all ports:
14
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
20 #                                 locally.
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).
25 #
26 # Variables that typically apply to an individual port:
27 #
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
36 #                               actually extract.
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.
41 #
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
57 #                               INTERACTIVE.
58 # DEPENDS               - A list of other ports this package depends on being
59 #                                 made first, relative to ${PORTSDIR} (e.g. x11/tk, lang/tcl,
60 #                                 etc).
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).
64 #
65 # NCFTP                 - Full path to ncftp command if not in $PATH (default: ncftp).
66 # NCFTP_ARGS    - Arguments to ${NCFTP} (default: -N).
67 #
68 #
69 # Default targets and their behaviors:
70 #
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
75 #                                 what's available.
76 # build                 - Actually compile the sources.
77 # install               - Install the results of a build.
78 # package               - Create a package from a build.
79 #
80 # Default sequence for "all" is:  fetch extract configure build
81
82 .if exists(${.CURDIR}/../Makefile.inc)
83 .include "${.CURDIR}/../Makefile.inc"
84 .endif
85
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)
95 WRKSRC?=                ${WRKDIR}
96 .else
97 WRKSRC?=                ${WRKDIR}/${DISTNAME}
98 .endif
99 PATCHDIR?=              ${.CURDIR}/patches
100 SCRIPTDIR?=             ${.CURDIR}/scripts
101 FILESDIR?=              ${.CURDIR}/files
102 PKGDIR?=                ${.CURDIR}/pkg
103
104 .if exists(${PORTSDIR}/../Makefile.inc)
105 .include "${PORTSDIR}/../Makefile.inc"
106 .endif
107
108
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
113
114 # How to do nothing.  Override if you, for some strange reason, would rather
115 # do something.
116 DO_NADA?=               echo -n
117
118 # Miscellaneous overridable commands:
119 GMAKE?=                 gmake
120 XMKMF?=                 xmkmf
121 MAKE_FLAGS?=    -f
122 MAKEFILE?=              Makefile
123
124 NCFTP?=                 ncftp
125 NCFTPFLAGS?=    -N
126
127 PATCH?=                 patch
128 PATCH_STRIP?=   -p0
129 PATCH_ARGS?=     -d ${WRKSRC} --quiet -E ${PATCH_STRIP}
130
131 EXTRACT_CMD?=   tar
132 EXTRACT_SUFX?=  .tar.gz
133 EXTRACT_ARGS?=  -C ${WRKDIR} -xzf
134
135 PKG_CMD?=               pkg_create
136 PKG_ARGS?=              -v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST -p ${PREFIX}
137 PKG_SUFX?=              .tgz
138
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/
142
143 # Derived names so that they're easily overridable.
144 DISTFILES?=             ${DISTNAME}${EXTRACT_SUFX}
145
146 .if exists(${PACKAGES})
147 PKGFILE?=               ${PACKAGES}/${DISTNAME}${PKG_SUFX}
148 .else
149 PKGFILE?=               ${DISTNAME}${PKG_SUFX}
150 .endif
151
152 .if defined(GNU_CONFIGURE)
153 CONFIGURE_ARGS?=        --prefix=${PREFIX}
154 HAS_CONFIGURE=          yes
155 .endif
156
157 .MAIN: all
158
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.
165 #
166 .if (defined(IS_INTERACTIVE) && defined(BATCH)) || (!defined(IS_INTERACTIVE) && defined(INTERACTIVE))
167 all:
168         @${DO_NADA}
169 pre-build:
170         @${DO_NADA}
171 build:
172         @${DO_NADA}
173 pre-install:
174         @${DO_NADA}
175 install:
176         @${DO_NADA}
177 pre-fetch:
178         @${DO_NADA}
179 fetch:
180         @${DO_NADA}
181 pre-configure:
182         @${DO_NADA}
183 configure:
184         @${DO_NADA}
185 .endif
186
187 .if !target(all)
188 all: extract configure build
189 .endif
190
191 .if !target(is_depended)
192 is_depended:    all install
193 .endif
194
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)
202 extract:
203         @touch -f ${EXTRACT_COOKIE}
204 .endif
205 .if defined(NO_CONFIGURE) && !target(configure)
206 configure:
207         @touch -f ${CONFIGURE_COOKIE}
208 .endif
209 .if defined(NO_BUILD) && !target(build)
210 build:
211         @${DO_NADA}
212 .endif
213 .if defined(NO_PACKAGE) && !target(package)
214 package:
215         @${DO_NADA}
216 .endif
217 .if defined(NO_INSTALL) && !target(install)
218 install:
219         @touch -f ${INSTALL_COOKIE}
220 .endif
221
222 # More standard targets start here.
223
224 .if !target(pre-install)
225 pre-install:
226         @${DO_NADA}
227 .endif
228
229 .if !target(install)
230 install: ${INSTALL_COOKIE}
231
232 ${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)
241 .endif
242 .endif
243         @touch -f ${INSTALL_COOKIE}
244 .endif
245
246 .if !target(pre-package)
247 pre-package:
248         @${DO_NADA}
249 .endif
250
251 .if !target(package)
252 package: 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}; \
259         fi
260 .endif
261
262 .if !target(pre-build)
263 pre-build:
264         @${DO_NADA}
265 .endif
266
267 .if !target(build)
268 build: configure pre-build
269         @echo "===>  Building for ${DISTNAME}"
270 .if defined(DEPENDS)
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.."; \
277                 else \
278                         (cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
279                 fi \
280         done
281         @echo "===>  Returning to build of ${DISTNAME}"
282 .endif
283 .endif
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)
288 .endif
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; \
295         fi
296 .endif
297
298 .if !target(pre-configure)
299 pre-configure:
300         @${DO_NADA}
301 .endif
302
303 .if !target(configure)
304 configure: extract ${CONFIGURE_COOKIE}
305
306 ${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; \
313         done; \
314         fi
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; \
321         fi
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; \
328         fi
329 .if defined(HAS_CONFIGURE)
330         @(cd ${WRKSRC}; ./configure ${CONFIGURE_ARGS})
331 .endif
332 .if defined(USE_IMAKE)
333         @(cd ${WRKSRC}; ${XMKMF} && ${MAKE} Makefiles)
334 .endif
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; \
341         fi
342         @touch -f ${CONFIGURE_COOKIE}
343 .endif
344
345 .if !target(pre-fetch)
346 pre-fetch:
347         @${DO_NADA}
348 .endif
349
350 .if !target(fetch)
351 fetch: pre-fetch
352         @if [ ! -d ${DISTDIR} ]; then mkdir -p ${DISTDIR}; fi
353         @(cd ${DISTDIR}; \
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 \
360                                         break; \
361                                 fi \
362                         done; \
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."; \
366                                 exit 1; \
367                         fi; \
368             fi \
369          done)
370 .endif
371
372 .if !target(pre-extract)
373 pre-extract:
374         @${DO_NADA}
375 .endif
376
377 .if !target(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
381 # in ${WRKDIR}.
382 extract: fetch pre-extract ${EXTRACT_COOKIE}
383
384 ${EXTRACT_COOKIE}:
385         @echo "===>  Extracting for ${DISTNAME}"
386         @rm -rf ${WRKDIR}
387         @mkdir -p ${WRKDIR}
388 .if defined(EXTRACT_ONLY)
389         @for file in ${EXTRACT_ONLY}; do \
390                 ${EXTRACT_CMD} ${EXTRACT_ARGS} ${DISTDIR}/$$file ; \
391         done
392 .else
393         @for file in ${DISTFILES}; do \
394                 ${EXTRACT_CMD} ${EXTRACT_ARGS} ${DISTDIR}/$$file ; \
395         done
396 .endif
397         @touch -f ${EXTRACT_COOKIE}
398 .endif
399
400 .if !target(pre-clean)
401 pre-clean:
402         @${DO_NADA}
403 .endif
404
405 .if !target(clean)
406 clean: pre-clean
407         @echo "===>  Cleaning for ${DISTNAME}"
408         @rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} ${INSTALL_COOKIE}
409         @rm -rf ${WRKDIR}
410 .endif
411
412 # No pre-targets for depend or tags.  It would be silly.
413
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.
417 #
418 .if !target(depend)
419 depend:
420 .endif
421
422 # Same goes for tags
423 .if !target(tags)
424 tags:
425 .endif