Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / bsd.pkg.mk
blobaad01b4c1db913e0b3bd82f7952fbaa7e2435437
1 # $NetBSD: bsd.pkg.mk,v 1.1987 2013/02/22 13:35:27 obache Exp $
3 # This file is in the public domain.
5 # Please see the pkgsrc/doc/guide manual for details on the
6 # variables used in this make file template.
8 # Default sequence for "all" is:
10 # bootstrap-depends
11 # fetch
12 # checksum
13 # depends
14 # tools
15 # extract
16 # patch
17 # wrapper
18 # configure
19 # build
22 .include "misc/common.mk"
24 ############################################################################
25 # Transform package Makefile variables and set defaults
26 # This is the early set used directly or indirectly in
27 # the phase variables.
28 ############################################################################
30 ##### PKGBASE, PKGNAME[_NOREV], PKGVERSION
32 PKGBASE?= ${PKGNAME:C/-[^-]*$//}
33 PKGVERSION?= ${PKGNAME:C/^.*-//}
34 .if defined(PKGREVISION) && !empty(PKGREVISION) && (${PKGREVISION} != "0")
35 . if defined(PKGNAME)
36 PKGNAME_NOREV:= ${PKGNAME}
37 PKGNAME:= ${PKGNAME}nb${PKGREVISION}
38 . else
39 PKGNAME?= ${DISTNAME}nb${PKGREVISION}
40 PKGNAME_NOREV= ${DISTNAME}
41 . endif
42 .else
43 PKGNAME?= ${DISTNAME}
44 PKGNAME_NOREV= ${PKGNAME}
45 .endif
46 PKGVERSION_NOREV= ${PKGNAME_NOREV:C/^.*-//}
48 # Fail-safe in the case of circular dependencies
49 .if defined(_PKGSRC_DEPS) && defined(PKGNAME) && !empty(_PKGSRC_DEPS:M${PKGNAME})
50 PKG_FAIL_REASON+= "Circular dependency detected"
51 .endif
53 ####
55 ############################################################################
56 # Allow various phases to define the default variables
57 ############################################################################
58 .if defined(EMUL_PLATFORMS) && !empty(EMUL_PLATFORMS)
59 . include "emulator/emulator.mk"
60 .endif
62 .include "features/features.mk"
64 .include "pkgformat/bsd.pkgformat-vars.mk"
65 .include "check/bsd.check-vars.mk"
66 .include "depends/bsd.depends-vars.mk"
67 .include "fetch/bsd.fetch-vars.mk"
68 .include "checksum/bsd.checksum-vars.mk"
69 .include "extract/bsd.extract-vars.mk"
70 .include "patch/bsd.patch-vars.mk"
71 .include "configure/bsd.configure-vars.mk"
72 .include "build/bsd.build-vars.mk"
73 .include "install/bsd.install-vars.mk"
75 .include "bsd.pkg.error.mk"
77 .include "bsd.hacks.mk"
79 ############################################################################
80 # Transform package Makefile variables and set defaults
81 ############################################################################
83 MKCRYPTO?= YES # build crypto packages by default
85 ##### Others
87 BUILD_DEPENDS?= # empty
88 COMMENT?= (no description)
89 DEPENDS?= # empty
90 DESCR_SRC?= ${PKGDIR}/DESCR
91 INTERACTIVE_STAGE?= none
92 .if defined(OWNER)
93 MAINTAINER=${OWNER}
94 .else
95 MAINTAINER?= pkgsrc-users@NetBSD.org
96 .endif
97 PKGWILDCARD?= ${PKGBASE}-[0-9]*
98 SVR4_PKGNAME?= ${PKGNAME}
99 WRKSRC?= ${WRKDIR}/${DISTNAME}
101 # Override for SU_CMD user check
102 _IS_ROOT_CMD?= ${TEST} `${ID} -u` = `${ID} -u ${_SU_ROOT_USER}`
103 _SU_ROOT_USER?= ${ROOT_USER}
104 REAL_ROOT_USER?= ${ROOT_USER}
105 REAL_ROOT_GROUP?= ${ROOT_GROUP}
107 .if (defined(INSTALL_UNSTRIPPED) && !empty(INSTALL_UNSTRIPPED:M[yY][eE][sS])) || defined(DEBUG_FLAGS)
108 _INSTALL_UNSTRIPPED= # set (flag used by platform/*.mk)
109 .endif
111 ##### Transform USE_* into dependencies
113 .include "bsd.pkg.use.mk"
115 ############################################################################
116 # Sanity checks
117 ############################################################################
119 .if defined(BUILDLINK_DEPTH) || defined(BUILDLINK_PACKAGES) || \
120 defined(BUILDLINK_DEPENDS) || defined(BUILDLINK_ORDER)
121 PKG_FAIL_REASON+= "Out-dated buildlink3.mk detected, please update"
122 .endif
124 # PKG_INSTALLATION_TYPE can only be one of two values: "pkgviews" or
125 # "overwrite".
126 .if (${PKG_INSTALLATION_TYPE} != "pkgviews") && \
127 (${PKG_INSTALLATION_TYPE} != "overwrite")
128 PKG_FAIL_REASON+= "PKG_INSTALLATION_TYPE must be \`\`pkgviews'' or \`\`overwrite''."
129 .endif
131 .if empty(PKG_INSTALLATION_TYPES:M${PKG_INSTALLATION_TYPE})
132 PKG_FAIL_REASON+= "This package doesn't support PKG_INSTALLATION_TYPE=${PKG_INSTALLATION_TYPE}."
133 .endif
135 .if !defined(CATEGORIES) || !defined(DISTNAME)
136 PKG_FAIL_REASON+='CATEGORIES and DISTNAME are mandatory.'
137 .endif
139 .if defined(PKG_PATH)
140 PKG_FAIL_REASON+='Please unset PKG_PATH before doing pkgsrc work!'
141 .endif
143 # Allow variables to be set on a per-OS basis
144 OPSYSVARS+= CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS
145 .for _var_ in ${OPSYSVARS:O}
146 . if defined(${_var_}.${OPSYS})
147 ${_var_}+= ${${_var_}.${OPSYS}}
148 . elif defined(${_var_}.*)
149 ${_var_}+= ${${_var_}.*}
150 . endif
151 .endfor
153 CPPFLAGS+= ${CPP_PRECOMP_FLAGS}
155 # To sanitise environment set PKGSRC_SETENV=${SETENV} -i
156 PKGSRC_SETENV?= ${SETENV}
158 ALL_ENV+= CC=${CC:Q}
159 ALL_ENV+= CFLAGS=${CFLAGS:M*:Q}
160 ALL_ENV+= CPPFLAGS=${CPPFLAGS:M*:Q}
161 ALL_ENV+= CXX=${CXX:Q}
162 ALL_ENV+= CXXFLAGS=${CXXFLAGS:M*:Q}
163 ALL_ENV+= COMPILER_RPATH_FLAG=${COMPILER_RPATH_FLAG:Q}
164 ALL_ENV+= F77=${FC:Q}
165 ALL_ENV+= FC=${FC:Q}
166 ALL_ENV+= FFLAGS=${FFLAGS:M*:Q}
167 ALL_ENV+= LANG=C
168 ALL_ENV+= LC_ALL=C
169 ALL_ENV+= LC_COLLATE=C
170 ALL_ENV+= LC_CTYPE=C
171 ALL_ENV+= LC_MESSAGES=C
172 ALL_ENV+= LC_MONETARY=C
173 ALL_ENV+= LC_NUMERIC=C
174 ALL_ENV+= LC_TIME=C
175 ALL_ENV+= LDFLAGS=${LDFLAGS:M*:Q}
176 ALL_ENV+= LINKER_RPATH_FLAG=${LINKER_RPATH_FLAG:Q}
177 ALL_ENV+= PATH=${PATH:Q}:${LOCALBASE}/bin:${X11BASE}/bin
178 ALL_ENV+= PREFIX=${PREFIX}
180 # This variable can be added to MAKE_ENV to ease installation of packages
181 # that use BSD-style Makefiles.
182 BSD_MAKE_ENV= BINOWN=${BINOWN} BINGRP=${BINGRP}
183 BSD_MAKE_ENV+= GAMEOWN=${GAMEOWN} GAMEGRP=${GAMEGRP}
184 BSD_MAKE_ENV+= MANOWN=${MANOWN} MANGRP=${MANGRP}
185 BSD_MAKE_ENV+= SHAREOWN=${SHAREOWN} SHAREGRP=${SHAREGRP}
186 BSD_MAKE_ENV+= DOCOWN=${DOCOWN} DOCGRP=${DOCGRP}
187 BSD_MAKE_ENV+= BINMODE=${BINMODE} NONBINMODE=${NONBINMODE}
188 BSD_MAKE_ENV+= BINDIR=${PREFIX}/bin
189 BSD_MAKE_ENV+= INCSDIR=${PREFIX}/include
190 BSD_MAKE_ENV+= LIBDIR=${PREFIX}/lib
191 BSD_MAKE_ENV+= MANDIR=${PREFIX}/${PKGMANDIR}
192 BSD_MAKE_ENV+= STRIPFLAG=${_STRIPFLAG_INSTALL:Q}
193 BSD_MAKE_ENV+= MANINSTALL=${MANINSTALL:Q}
194 BSD_MAKE_ENV+= MKCATPAGES=${MKCATPAGES:Q}
195 BSD_MAKE_ENV+= MKHTML=no
197 _BUILD_DEFS= ${BUILD_DEFS}
198 _BUILD_DEFS+= LOCALBASE
199 _BUILD_DEFS+= PKGGNUDIR
200 _BUILD_DEFS+= PKGINFODIR
201 _BUILD_DEFS+= PKGMANDIR
202 _BUILD_DEFS+= _USE_DESTDIR
204 # Store the result in the +BUILD_INFO file so we can query for the build
205 # options using "pkg_info -Q PKG_OPTIONS <pkg>".
207 .if defined(PKG_SUPPORTED_OPTIONS) && defined(PKG_OPTIONS)
208 _BUILD_DEFS+= PKG_OPTIONS
209 .endif
211 .if empty(DEPOT_SUBDIR)
212 PKG_FAIL_REASON+= "DEPOT_SUBDIR may not be empty."
213 .endif
215 # Store the build options for multi-packages, i.e. packages that can
216 # be built with multiple versions of Apache, Python, Ruby, PHP etc.
218 .if defined(MULTI)
219 _BUILD_DEFS+= MULTI
220 .endif
222 # ZERO_FILESIZE_P exits with a successful return code if the given file
223 # has zero length.
224 # NONZERO_FILESIZE_P exits with a successful return code if the given file
225 # has nonzero length.
227 _ZERO_FILESIZE_P= ${AWK} 'END { exit (NR > 0) ? 1 : 0; }'
228 _NONZERO_FILESIZE_P= ${AWK} 'END { exit (NR > 0) ? 0 : 1; }'
230 # Automatically increase process limit where necessary for building.
231 _ULIMIT_CMD= ${UNLIMIT_RESOURCES:@_lim_@${ULIMIT_CMD_${_lim_}};@}
233 _NULL_COOKIE= ${WRKDIR}/.null
235 # Miscellaneous overridable commands:
236 SHCOMMENT?= ${ECHO_MSG} >/dev/null '***'
238 LIBABISUFFIX?=
240 TOUCH_FLAGS?= -f
242 # A few aliases for *-install targets
243 INSTALL= ${TOOLS_INSTALL} # XXX override sys.mk
244 INSTALL_PROGRAM?= \
245 ${INSTALL} ${COPY} ${_STRIPFLAG_INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
246 INSTALL_GAME?= \
247 ${INSTALL} ${COPY} ${_STRIPFLAG_INSTALL} -o ${GAMEOWN} -g ${GAMEGRP} -m ${GAMEMODE}
248 INSTALL_SCRIPT?= \
249 ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
250 INSTALL_LIB?= \
251 ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
252 INSTALL_DATA?= \
253 ${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE}
254 INSTALL_GAME_DATA?= \
255 ${INSTALL} ${COPY} -o ${GAMEOWN} -g ${GAMEGRP} -m ${GAMEDATAMODE}
256 INSTALL_MAN?= \
257 ${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
258 INSTALL_PROGRAM_DIR?= \
259 ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m ${PKGDIRMODE}
260 INSTALL_GAME_DIR?= \
261 ${INSTALL} -d -o ${GAMEOWN} -g ${GAMEGRP} -m ${GAMEDIRMODE}
262 INSTALL_SCRIPT_DIR?= \
263 ${INSTALL_PROGRAM_DIR}
264 INSTALL_LIB_DIR?= \
265 ${INSTALL_PROGRAM_DIR}
266 INSTALL_DATA_DIR?= \
267 ${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m ${PKGDIRMODE}
268 INSTALL_MAN_DIR?= \
269 ${INSTALL} -d -o ${MANOWN} -g ${MANGRP} -m ${PKGDIRMODE}
271 INSTALL_MACROS= BSD_INSTALL_PROGRAM=${INSTALL_PROGRAM:Q} \
272 BSD_INSTALL_SCRIPT=${INSTALL_SCRIPT:Q} \
273 BSD_INSTALL_LIB=${INSTALL_LIB:Q} \
274 BSD_INSTALL_DATA=${INSTALL_DATA:Q} \
275 BSD_INSTALL_MAN=${INSTALL_MAN:Q} \
276 BSD_INSTALL=${INSTALL:Q} \
277 BSD_INSTALL_PROGRAM_DIR=${INSTALL_PROGRAM_DIR:Q} \
278 BSD_INSTALL_SCRIPT_DIR=${INSTALL_SCRIPT_DIR:Q} \
279 BSD_INSTALL_LIB_DIR=${INSTALL_LIB_DIR:Q} \
280 BSD_INSTALL_DATA_DIR=${INSTALL_DATA_DIR:Q} \
281 BSD_INSTALL_MAN_DIR=${INSTALL_MAN_DIR:Q} \
282 BSD_INSTALL_GAME=${INSTALL_GAME:Q} \
283 BSD_INSTALL_GAME_DATA=${INSTALL_GAME_DATA:Q} \
284 BSD_INSTALL_GAME_DIR=${INSTALL_GAME_DIR:Q}
285 MAKE_ENV+= ${INSTALL_MACROS:M*}
286 SCRIPTS_ENV+= ${INSTALL_MACROS:M*}
288 # If pkgsrc is supposed to ensure that tests are run before installation
289 # of the package, then the build targets should be "build test", otherwise
290 # just "build" suffices.
292 .if !empty(PKGSRC_RUN_TEST:M[yY][eE][sS])
293 _PKGSRC_BUILD_TARGETS= build test
294 .else
295 _PKGSRC_BUILD_TARGETS= build
296 .endif
298 # OVERRIDE_DIRDEPTH represents the common directory depth under
299 # ${WRKSRC} up to which we find the files that need to be
300 # overridden. By default, we search two levels down, i.e.,
301 # */*/file.
303 OVERRIDE_DIRDEPTH?= 2
305 # Handle alternatives
307 .include "alternatives.mk"
309 # Define SMART_MESSAGES in /etc/mk.conf for messages giving the tree
310 # of dependencies for building, and the current target.
311 _PKGSRC_IN?= ===${SMART_MESSAGES:D> ${.TARGET} [${PKGNAME}${_PKGSRC_DEPS}] ===}
313 # Used to print all the '===>' style prompts - override this to turn them off.
314 ECHO_MSG?= ${ECHO}
315 PHASE_MSG?= ${ECHO_MSG} ${_PKGSRC_IN:Q}\>
316 STEP_MSG?= ${ECHO_MSG} "=>"
317 INFO_MSG?= ${ECHO_MSG} "INFO:"
318 WARNING_MSG?= ${ECHO_MSG} 1>&2 "WARNING:"
319 ERROR_MSG?= ${ECHO_MSG} 1>&2 "ERROR:"
320 FAIL_MSG?= ${FAIL} ${ERROR_MSG}
322 WARNING_CAT?= ${SED} -e "s|^|WARNING: |" 1>&2
323 ERROR_CAT?= ${SED} -e "s|^|ERROR: |" 1>&2
325 # How to do nothing. Override if you, for some strange reason, would rather
326 # do something.
327 DO_NADA?= ${TRUE}
329 # the FAIL command executes its arguments and then exits with a non-zero
330 # status.
331 FAIL?= ${SH} ${PKGSRCDIR}/mk/scripts/fail
334 # Config file related settings - see doc/pkgsrc.txt
336 PKG_SYSCONFVAR?= ${PKGBASE}
337 PKG_SYSCONFSUBDIR?= # empty
338 .if ${PKG_INSTALLATION_TYPE} == "overwrite"
339 PKG_SYSCONFDEPOTBASE= # empty
340 PKG_SYSCONFBASEDIR= ${PKG_SYSCONFBASE}
341 .else
342 . if !empty(PKG_SYSCONFBASE:M${PREFIX}) || \
343 !empty(PKG_SYSCONFBASE:M${PREFIX}/*)
344 PKG_SYSCONFDEPOTBASE= # empty
345 PKG_SYSCONFBASEDIR= ${PKG_SYSCONFBASE}
346 . else
347 PKG_SYSCONFDEPOTBASE= ${PKG_SYSCONFBASE}/${DEPOT_SUBDIR}
348 PKG_SYSCONFBASEDIR= ${PKG_SYSCONFDEPOTBASE}/${PKGNAME}
349 . endif
350 .endif
351 .if empty(PKG_SYSCONFSUBDIR)
352 DFLT_PKG_SYSCONFDIR:= ${PKG_SYSCONFBASEDIR}
353 .else
354 DFLT_PKG_SYSCONFDIR:= ${PKG_SYSCONFBASEDIR}/${PKG_SYSCONFSUBDIR}
355 .endif
356 PKG_SYSCONFDIR= ${DFLT_PKG_SYSCONFDIR}
357 .if defined(PKG_SYSCONFDIR.${PKG_SYSCONFVAR})
358 PKG_SYSCONFDIR= ${PKG_SYSCONFDIR.${PKG_SYSCONFVAR}}
359 PKG_SYSCONFBASEDIR= ${PKG_SYSCONFDIR.${PKG_SYSCONFVAR}}
360 PKG_SYSCONFDEPOTBASE= # empty
361 .endif
362 PKG_SYSCONFDIR_PERMS?= ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 755
364 ALL_ENV+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR:Q}
365 _BUILD_DEFS+= PKG_SYSCONFBASEDIR PKG_SYSCONFDIR
367 # These are all of the tools use by pkgsrc Makefiles. This should
368 # eventually be split up into lists of tools required by different
369 # phases of a pkgsrc build.
371 USE_TOOLS+= \
372 [ awk basename cat chgrp chmod chown cmp cp cut dirname echo \
373 egrep env false file find grep head hostname id install ln ls \
374 mkdir mv printf pwd rm rmdir sed sh sort \
375 tail test touch tr true wc xargs
377 # bsd.wrapper.mk
378 USE_TOOLS+= expr
380 # bsd.bulk-pkg.mk uses certain tools
381 .if defined(BATCH)
382 USE_TOOLS+= tee tsort
383 .endif
385 # INSTALL/DEINSTALL script framework
386 .include "pkginstall/bsd.pkginstall.mk"
388 # Locking
389 .include "internal/locking.mk"
391 # Tools
392 .include "tools/bsd.tools.mk"
394 # Barrier
395 .include "bsd.pkg.barrier.mk"
397 # Unprivileged builds
398 .include "unprivileged.mk"
400 # If NO_BUILD is defined, default to not needing a compiler.
401 .if defined(NO_BUILD)
402 USE_LANGUAGES?= # empty
403 .endif
405 # Get the proper dependencies and set the PATH to use the compiler
406 # named in PKGSRC_COMPILER.
408 .include "compiler.mk"
410 #Fake up a home directory
411 WRAPPER_TARGETS+= fake-home
412 FAKEHOMEDIR= ${WRKDIR}/.home
413 ALL_ENV+= HOME=${FAKEHOMEDIR}
414 .PHONY: fake-home
415 fake-home: ${FAKEHOMEDIR}
416 ${FAKEHOMEDIR}:
417 ${RUN} ${MKDIR} ${.TARGET}
419 .include "wrapper/bsd.wrapper.mk"
421 .if defined(ABI_DEPENDS) || defined(BUILD_ABI_DEPENDS)
422 . if !empty(USE_ABI_DEPENDS:M[yY][eE][sS])
423 DEPENDS+= ${ABI_DEPENDS}
424 BUILD_DEPENDS+= ${BUILD_ABI_DEPENDS}
425 . else
426 _BUILD_DEFS+= USE_ABI_DEPENDS
427 . endif
428 .endif
430 # Find out the PREFIX of dependencies where the PREFIX is needed at build time.
431 .if defined(EVAL_PREFIX)
432 FIND_PREFIX:= ${EVAL_PREFIX}
433 . include "find-prefix.mk"
434 .endif
436 .if !defined(_PATH_ORIG)
437 _PATH_ORIG:= ${PATH}
438 MAKEFLAGS+= _PATH_ORIG=${_PATH_ORIG:Q}
439 .endif
441 .if !empty(PREPEND_PATH:M*)
442 # This is very Special. Because PREPEND_PATH is set with += in reverse order,
443 # this command reverses the order again (since bootstrap bmake doesn't
444 # yet support the :[-1..1] construct).
445 _PATH_CMD= \
446 path=${_PATH_ORIG:Q}; \
447 for i in ${PREPEND_PATH}; do path="$$i:$$path"; done; \
448 ${ECHO} "$$path"
449 PATH= ${_PATH_CMD:sh} # DOES NOT use :=, to defer evaluation
450 .endif
452 ################################################################
453 # Many ways to disable a package.
455 # Ignore packages that can't be resold if building for a CDROM.
457 # Don't build a package if it's restricted and we don't want to
458 # get into that.
460 # Don't build any package that utilizes strong cryptography, for
461 # when the law of the land forbids it.
463 # Don't attempt to build packages against X if we don't have X.
465 # Don't build a package if it's broken.
466 ################################################################
467 .if ${X11_TYPE} == "xorg"
468 PKG_FAIL_REASON+= "Support for X11_TYPE=xorg was removed."
469 PKG_FAIL_REASON+= "Please switch to X11_TYPE=modular."
470 X11_TYPE:= native
471 X11BASE:= /usr
472 .endif
474 .if !defined(NO_SKIP)
475 . if (defined(NO_BIN_ON_CDROM) && defined(FOR_CDROM))
476 PKG_FAIL_REASON+= "${PKGNAME} may not be placed in binary form on a CDROM:" \
477 " "${NO_BIN_ON_CDROM:Q}
478 . endif
479 . if (defined(NO_SRC_ON_CDROM) && defined(FOR_CDROM))
480 PKG_FAIL_REASON+= "${PKGNAME} may not be placed in source form on a CDROM:" \
481 " "${NO_SRC_ON_CDROM:Q}
482 . endif
483 . if (defined(RESTRICTED) && defined(NO_RESTRICTED))
484 PKG_FAIL_REASON+= "${PKGNAME} is restricted:" \
485 " "${RESTRICTED:Q}
486 . endif
487 . if !(${MKCRYPTO} == "YES" || ${MKCRYPTO} == yes)
488 . if defined(CRYPTO)
489 PKG_FAIL_REASON+= "${PKGNAME} may not be built, because it utilizes strong cryptography"
490 . endif
491 . endif
492 . if defined(USE_X11) && (${X11_TYPE} == "native") && !exists(${X11BASE})
493 PKG_FAIL_REASON+= "${PKGNAME} uses X11, but ${X11BASE} not found"
494 . endif
495 . if defined(BROKEN)
496 PKG_FAIL_REASON+= "${PKGNAME} is marked as broken:" ${BROKEN:Q}
497 . endif
499 .include "license.mk"
501 # Define __PLATFORM_OK only if the OS matches the pkg's allowed list.
502 . if defined(ONLY_FOR_PLATFORM) && !empty(ONLY_FOR_PLATFORM)
503 . for __tmp__ in ${ONLY_FOR_PLATFORM}
504 . if ${MACHINE_PLATFORM:M${__tmp__}} != ""
505 __PLATFORM_OK?= yes
506 . endif # MACHINE_PLATFORM
507 . endfor # __tmp__
508 . else # !ONLY_FOR_PLATFORM
509 __PLATFORM_OK?= yes
510 . endif # ONLY_FOR_PLATFORM
511 . for __tmp__ in ${NOT_FOR_PLATFORM}
512 . if ${MACHINE_PLATFORM:M${__tmp__}} != ""
513 . undef __PLATFORM_OK
514 . endif # MACHINE_PLATFORM
515 . endfor # __tmp__
516 . if !defined(__PLATFORM_OK)
517 PKG_FAIL_REASON+= "${PKGNAME} is not available for ${MACHINE_PLATFORM}"
518 . endif # !__PLATFORM_OK
519 .endif
521 # Add these defs to the ones dumped into +BUILD_DEFS
522 _BUILD_DEFS+= PKGPATH
523 _BUILD_DEFS+= OPSYS OS_VERSION MACHINE_ARCH MACHINE_GNU_ARCH
524 _BUILD_DEFS+= ABI
525 _BUILD_DEFS+= CPPFLAGS CFLAGS FFLAGS LDFLAGS
526 _BUILD_DEFS+= OBJECT_FMT LICENSE RESTRICTED
527 _BUILD_DEFS+= NO_SRC_ON_FTP NO_SRC_ON_CDROM
528 _BUILD_DEFS+= NO_BIN_ON_FTP NO_BIN_ON_CDROM
530 .if defined(OSVERSION_SPECIFIC)
531 _BUILD_DEFS+= OSVERSION_SPECIFIC
532 DEPENDS+= osabi-${OPSYS}-${OS_VERSION}:../../pkgtools/osabi
533 .endif # OSVERSION_SPECIFIC
535 .for _pkg_ in ${_BUILTIN_PKGS}
536 . if defined(USE_BUILTIN.${_pkg_}) && \
537 !empty(USE_BUILTIN.${_pkg_}:M[yY][eE][sS]) && \
538 defined(BUILTIN_PKG.${_pkg_}) && !empty(BUILTIN_PKG.${_pkg_})
539 BUILTIN_PKGS+= ${BUILTIN_PKG.${_pkg_}}
540 . endif
541 .endfor
542 .if defined(BUILTIN_PKGS)
543 _BUILD_DEFS+= BUILTIN_PKGS
544 .endif
546 .if defined(GLIBC_VERSION)
547 _BUILD_DEFS+= GLIBC_VERSION
548 .endif # GLIBC_VERSION
550 .PHONY: all
551 .if !target(all)
552 all: ${_PKGSRC_BUILD_TARGETS}
553 .endif
555 .PHONY: makedirs
556 makedirs: ${WRKDIR}
558 ${WRKDIR}:
559 .if !defined(KEEP_WRKDIR)
560 . if ${WRKDIR_LOCKTYPE} != "none"
561 ${RUN} ${TEST} -f ${_WRKDIR_LOCKFILE} || ${RM} -fr ${WRKDIR}
562 . endif
563 .endif
564 ${RUN} umask 077 && ${MKDIR} ${WRKDIR}
566 # Create a symlink from ${WRKDIR} to the package directory if
567 # CREATE_WRKDIR_SYMLINK is "yes".
569 CREATE_WRKDIR_SYMLINK?= no
571 .if defined(WRKOBJDIR) && !empty(CREATE_WRKDIR_SYMLINK:M[Yy][Ee][Ss])
572 makedirs: ${.CURDIR}/${WRKDIR_BASENAME}
573 ${.CURDIR}/${WRKDIR_BASENAME}:
574 . if ${WRKDIR_LOCKTYPE} != "none"
575 ${RUN} ${TEST} -f ${_WRKDIR_LOCKFILE} || ${RM} -f ${.TARGET}
576 . endif
577 ${RUN} \
578 if ${LN} -s ${WRKDIR} ${.TARGET} 2>/dev/null; then \
579 ${ECHO_MSG} "${.TARGET:T} -> ${WRKDIR}"; \
581 .endif
583 .include "pkgformat/bsd.pkgformat.mk"
585 .include "depends/bsd.depends.mk"
586 .include "check/bsd.check.mk"
587 .include "fetch/bsd.fetch.mk"
588 .include "checksum/bsd.checksum.mk"
589 .include "extract/bsd.extract.mk"
590 .include "patch/bsd.patch.mk"
591 .include "configure/bsd.configure.mk"
592 .include "build/bsd.build.mk"
593 .include "install/bsd.install.mk"
594 .include "package/bsd.package.mk"
596 .include "bsd.pkg.clean.mk"
597 .include "bsd.pkg.update.mk"
599 # su-target is a macro target that does just-in-time su-to-root before
600 # reinvoking the make process as root. It acquires root privileges and
601 # invokes a new make process with the target named "su-${.TARGET}".
603 # MAKEFLAGS.su-${.TARGET}
604 # The additional flags that are passed to the make process.
607 _ROOT_CMD= cd ${.CURDIR} && \
608 ${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} \
609 PATH=${_PATH_ORIG:Q}:${SU_CMD_PATH_APPEND:Q} \
610 ${MAKE} ${MAKEFLAGS} _PKGSRC_BARRIER=yes \
611 PKG_DEBUG_LEVEL=${PKG_DEBUG_LEVEL:Q} \
612 su-${.TARGET} ${MAKEFLAGS.su-${.TARGET}}
614 .PHONY: su-target
615 su-target: .USE
616 ${RUN} \
617 case ${PRE_CMD.su-${.TARGET}:Q}"" in \
618 "") ;; \
619 *) ${PRE_CMD.su-${.TARGET}} ;; \
620 esac; \
621 if ${_IS_ROOT_CMD}; then \
622 ${_ROOT_CMD}; \
623 else \
624 case ${PRE_ROOT_CMD:Q}"" in \
625 ${TRUE:Q}"") ;; \
626 *) ${WARNING_MSG} "Running: "${PRE_ROOT_CMD:Q} ;; \
627 esac; \
628 ${PRE_ROOT_CMD}; \
629 ${STEP_MSG} "Becoming \`\`${_SU_ROOT_USER}'' to make su-${.TARGET} (`${ECHO} ${SU_CMD} | ${AWK} '{ print $$1 }'`)"; \
630 ${SU_CMD} ${_ROOT_CMD:Q}; \
631 ${STEP_MSG} "Dropping \`\`${_SU_ROOT_USER}'' privileges."; \
634 ################################################################
635 # Some more targets supplied for users' convenience
636 ################################################################
638 # Run pkglint:
639 .PHONY: lint
640 lint:
641 ${RUN} ${LOCALBASE}/bin/pkglint
643 # List of flags to pass to pkg_add(1) for bin-install:
645 BIN_INSTALL_FLAGS?= # -v
646 .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
647 PKG_ARGS_ADD= -W ${LOCALBASE} -w ${DEFAULT_VIEW}
648 .endif
649 _BIN_INSTALL_FLAGS= ${BIN_INSTALL_FLAGS}
650 .if defined(_AUTOMATIC) && !empty(_AUTOMATIC:M[Yy][Ee][Ss])
651 _BIN_INSTALL_FLAGS+= -A
652 .endif
653 _BIN_INSTALL_FLAGS+= ${PKG_ARGS_ADD}
655 _SHORT_UNAME_R= ${:!${UNAME} -r!:C@\.([0-9]*)[_.-].*@.\1@} # n.n[_.]anything => n.n
657 .include "install/bin-install.mk"
659 .PHONY: show-pkgtools-version
660 .if !target(show-pkgtools-version)
661 show-pkgtools-version:
662 @${ECHO} ${PKGTOOLS_VERSION}
663 .endif
665 # convenience target, to display make variables from command line
666 # i.e. "make show-var VARNAME=var", will print var's value
668 # See also:
669 # show-vars, show-subdir-var
671 .PHONY: show-var
672 show-var:
673 @${ECHO} ${${VARNAME}:Q}
675 # enhanced version of target above, to display multiple variables
676 .PHONY: show-vars
677 show-vars:
678 .for VARNAME in ${VARNAMES}
679 @${ECHO} ${${VARNAME}:Q}
680 .endfor
682 # displays multiple variables as shell expressions
683 # VARS is space separated list of VARNAME:shellvarname
684 .PHONY: show-vars-eval
685 show-vars-eval:
686 .for var in ${VARS}
687 @${ECHO} ${var:C/^.*://}="${${var:C/:.*$//}:Q}"
688 .endfor
690 LICENSE_FILE?= ${PKGSRCDIR}/licenses/${LICENSE}
692 .if !target(show-license)
693 show-license show-licence: .PHONY
694 @license=${LICENSE:Q}; \
695 license_file=${LICENSE_FILE:Q}; \
696 pager=${PAGER:Q}; \
697 case "$$pager" in "") pager=${CAT:Q};; esac; \
698 case "$$license" in "") exit 0;; esac; \
699 if ${TEST} -f "$$license_file"; then \
700 $$pager "$$license_file"; \
701 else \
702 ${ECHO} "Generic $$license information not available"; \
703 ${ECHO} "See the package description (pkg_info -d ${PKGNAME}) for more information."; \
705 .endif
707 # This target is defined in bsd.options.mk for packages that use
708 # the options framework.
709 .if !target(show-options)
710 .PHONY: show-options
711 show-options:
712 @${ECHO} This package does not use the options framework.
713 .endif
715 # Depend is generally meaningless for arbitrary packages, but if someone wants
716 # one they can override this. This is just to catch people who've gotten into
717 # the habit of typing `${MAKE} depend all install' as a matter of course.
719 .PHONY: depend
720 .if !target(depend)
721 depend:
722 .endif
724 # Same goes for tags
725 .PHONY: tags
726 .if !target(tags)
727 tags:
728 .endif
730 .include "plist/bsd.plist.mk"
732 .include "bsd.utils.mk"
734 .include "subst.mk"
737 # For bulk build targets (bulk-install, bulk-package), the
738 # BATCH variable must be set in /etc/mk.conf:
740 .if defined(BATCH)
741 . include "bulk/bsd.bulk-pkg.mk"
742 .endif
744 # README generation code.
745 .include "bsd.pkg.readme.mk"
747 # Create a PKG_ERROR_HANDLER shell command for each class listed in
748 # PKG_ERROR_CLASSES. The error handler is meant to be invoked within
749 # a make target.
751 .for _class_ in ${PKG_ERROR_CLASSES}
752 PKG_ERROR_HANDLER.${_class_}?= { \
753 ec=$$?; \
754 for str in ${PKG_ERROR_MSG.${_class_}}; do \
755 ${PHASE_MSG} "$$str"; \
756 done; \
757 exit $$ec; \
759 .endfor
761 # Cache variables listed in MAKEVARS in a phase-specific "makevars.mk"
762 # file. These variables are effectively passed to sub-make processes
763 # that are invoked on the same Makefile.
765 .for _phase_ in ${_ALL_PHASES}
766 ${_MAKEVARS_MK.${_phase_}}: ${WRKDIR}
767 ${RUN}${RM} -f ${.TARGET}.tmp
768 . for _var_ in ${MAKEVARS:O:u}
769 . if defined(${_var_})
770 ${RUN} \
771 ${ECHO} ${_var_}"= "${${_var_}:Q} >> ${.TARGET}.tmp
772 . endif
773 . endfor
774 ${RUN} \
775 if ${TEST} -f ${.TARGET}.tmp; then \
776 ( ${ECHO} ".if !defined(_MAKEVARS_MK)"; \
777 ${ECHO} "_MAKEVARS_MK= defined"; \
778 ${ECHO} ""; \
779 ${CAT} ${.TARGET}.tmp; \
780 ${ECHO} ""; \
781 ${ECHO} ".endif # _MAKEVARS_MK"; \
782 ) > ${.TARGET}; \
783 ${RM} -f ${.TARGET}.tmp; \
785 ${RUN}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
786 .endfor
788 .if make(pbulk-index) || make(pbulk-index-item) || make(pbulk-save-wrkdir)
789 .include "pbulk/pbulk-index.mk"
790 .endif
792 .if defined(_OPSYS_REQUIRE_UAC_MANIFEST) && !empty(_OPSYS_REQUIRE_UAC_MANIFEST:M[Yy][Ee][Ss])
793 . if defined(UAC_REQD_EXECS) && !empty(UAC_REQD_EXECS)
794 .include "misc/uac-manifest.mk"
795 . endif
796 .endif
798 .if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
799 . include "misc/developer.mk"
800 .endif
801 .include "misc/show.mk"
802 .if make(debug)
803 . include "bsd.pkg.debug.mk"
804 .endif
805 .include "misc/warnings.mk"
806 .if make(import)
807 .include "misc/import.mk"
808 .endif
809 .include "misc/can-be-built-here.mk"