1 # $NetBSD: bsd.prefs.mk,v 1.164 2004/07/30 20:59:08 jlam Exp $
3 # Make file, included to get the site preferences, if any. Should
4 # only be included by package Makefiles before any .if defined()
5 # statements or modifications to "passed" variables (CFLAGS, LDFLAGS, ...),
6 # to make sure any variables defined in /etc/mk.conf, $MAKECONF, or
7 # the system defaults (sys.mk and bsd.own.mk) are used.
9 # Do not recursively include mk.conf, redefine OPSYS, include bsd.own.mk, etc.
12 # Let mk.conf know that this is pkgsrc.
14 __PREFIX_SET__:=${PREFIX}
16 # Expand MAKE to a full path.
19 . for _dir_ in ${PATH:C/\:/ /g}
21 . if exists(${_dir_}/${MAKE})
22 _MAKE:= ${_dir_}/${MAKE}
26 . if !empty(_MAKE:M/*)
27 MAKEFLAGS+= _MAKE=${_MAKE:Q}
32 .if exists(/usr/bin/uname)
34 .elif exists(/bin/uname)
40 .if exists(/usr/bin/cut)
42 .elif exists(/bin/cut)
49 OPSYS!= ${UNAME} -s | tr -d /
51 MAKEFLAGS+= OPSYS=${OPSYS}
53 OS_VERSION!= ${UNAME} -r
55 .ifndef LOWER_OS_VERSION
56 LOWER_OS_VERSION!= echo ${OS_VERSION} | tr 'A-Z' 'a-z'
58 MAKEFLAGS+= OS_VERSION=${OS_VERSION}
60 # Preload these for architectures not in all variations of bsd.own.mk.
61 GNU_ARCH.alpha?= alpha
68 GNU_ARCH.m68000?= m68010
70 GNU_ARCH.mips?= mipsel
71 GNU_ARCH.mipseb?= mipseb
72 GNU_ARCH.mipsel?= mipsel
73 GNU_ARCH.ns32k?= ns32k
74 GNU_ARCH.powerpc?= powerpc
77 GNU_ARCH.sparc?= sparc
78 GNU_ARCH.sparc64?= sparc64
80 MACHINE_GNU_ARCH?= ${GNU_ARCH.${MACHINE_ARCH}}
82 .if ${OPSYS} == "NetBSD"
85 .elif ${OPSYS} == "BSDOS"
88 .elif ${OPSYS} == "FreeBSD"
90 LOWER_ARCH!= ${UNAME} -p
91 MACHINE_ARCH= ${LOWER_ARCH}
92 MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH}
93 LOWER_OPSYS_VERSUFFIX!= echo ${LOWER_OS_VERSION} | ${CUT} -c -1
94 . if ${LOWER_ARCH} == "i386"
97 LOWER_VENDOR?= unknown
100 .elif ${OPSYS} == "SunOS"
101 . if ${MACHINE_ARCH} == "sparc"
102 SPARC_TARGET_ARCH?= sparcv7
103 . elif ${MACHINE_ARCH} == "sun4"
105 SPARC_TARGET_ARCH?= sparcv7
106 . elif ${MACHINE_ARCH} == "i86pc"
108 . elif ${MACHINE_ARCH} == "unknown"
109 . if !defined(LOWER_ARCH)
110 LOWER_ARCH!= ${UNAME} -p
111 . endif # !defined(LOWER_ARCH)
112 MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH}
115 LOWER_OPSYS?= solaris
116 LOWER_OPSYS_VERSUFFIX= 2
118 .elif ${OPSYS} == "Linux"
120 MACHINE_ARCH:= ${MACHINE_ARCH:C/i.86/i386/}
121 . if !defined(LOWER_ARCH)
122 LOWER_ARCH!= ${UNAME} -m | sed -e 's/i.86/i386/'
123 . endif # !defined(LOWER_ARCH)
124 . if ${MACHINE_ARCH} == "unknown" || ${MACHINE_ARCH} == ""
125 MACHINE_ARCH= ${LOWER_ARCH}
126 MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH}
128 . if exists(/etc/debian_version)
129 LOWER_VENDOR?= debian
130 . elif exists(/etc/mandrake-release)
131 LOWER_VENDOR?= mandrake
132 . elif exists(/etc/redhat-version)
133 LOWER_VENDOR?= redhat
134 . elif exists(/etc/slackware-version)
135 LOWER_VENDOR?= slackware
136 . elif ${LOWER_ARCH} == "i386"
139 LOWER_VENDOR?= unknown
142 .elif ${OPSYS} == "Darwin"
144 LOWER_ARCH!= ${UNAME} -p
145 MACHINE_ARCH= ${LOWER_ARCH}
146 MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH}
149 .elif ${OPSYS:MIRIX*} != ""
150 LOWER_ARCH!= ${UNAME} -p
151 LOWER_OPSYS?= irix${OS_VERSION}
154 .elif ${OPSYS} == "Interix"
155 LOWER_OPSYS?= interix3
158 .elif !defined(LOWER_OPSYS)
159 LOWER_OPSYS!= echo ${OPSYS} | tr A-Z a-z
162 MAKEFLAGS+= LOWER_OPSYS=${LOWER_OPSYS}
165 LOWER_ARCH?= ${MACHINE_GNU_ARCH}
167 MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${MACHINE_ARCH}
168 MACHINE_GNU_PLATFORM?= ${LOWER_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}
170 # Needed to prevent an "install:" target from being created in bsd.own.mk.
171 NEED_OWN_INSTALL_TARGET=no
173 # This prevents default use of the cross-tool harness in the "src" tree,
174 # in the odd possible case of someone extracting "pkgsrc" underneath "src".
176 MAKE_ENV+= USETOOLS=no
178 # Set this before <bsd.own.mk> does, since it doesn't know about Darwin
179 .if ${OPSYS} == "Darwin"
183 .include <bsd.own.mk>
185 # /usr/share/mk/bsd.own.mk on NetBSD 1.3 does not define OBJECT_FMT
186 .if !empty(MACHINE_PLATFORM:MNetBSD-1.3*)
187 . if ${MACHINE_ARCH} == "alpha" || \
188 ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
189 ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64"
194 # override what bootstrap-pkgsrc sets, which isn't right for NetBSD
196 # XXX other ELF platforms in 1.4 need to be added to here.
197 .elif !empty(MACHINE_PLATFORM:MNetBSD-1.4*)
198 . if ${MACHINE_ARCH} == "alpha" || \
199 ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
200 ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64"
207 .if ${OPSYS} == "OpenBSD"
208 . if defined(ELF_TOOLCHAIN) && ${ELF_TOOLCHAIN} == "yes"
215 # include the defaults file
216 .if exists(${.CURDIR}/../../mk/bsd.pkg.defaults.mk)
217 . include "${.CURDIR}/../../mk/bsd.pkg.defaults.mk"
218 .elif exists(${.CURDIR}/../mk/bsd.pkg.defaults.mk)
219 . include "${.CURDIR}/../mk/bsd.pkg.defaults.mk"
220 .elif exists(${.CURDIR}/mk/bsd.pkg.defaults.mk)
221 . include "${.CURDIR}/mk/bsd.pkg.defaults.mk"
224 .if ${OPSYS} == "NetBSD"
225 . if ${OBJECT_FMT} == "ELF" && \
226 (${MACHINE_GNU_ARCH} == "arm" || \
227 ${MACHINE_ARCH} == "i386" || \
228 ${MACHINE_ARCH} == "m68k" || \
229 ${MACHINE_ARCH} == "m68000" || \
230 ${MACHINE_GNU_ARCH} == "sh" || \
231 ${MACHINE_GNU_ARCH} == "shle" || \
232 ${MACHINE_ARCH} == "sparc" || \
233 ${MACHINE_ARCH} == "vax")
240 SHAREMODE?= ${DOCMODE}
242 .if defined(PREFIX) && (${PREFIX} != ${__PREFIX_SET__})
244 @${ECHO_MSG} "You can NOT set PREFIX manually or in mk.conf. Set LOCALBASE or X11BASE"
245 @${ECHO_MSG} "depending on your needs. See the pkg system documentation for more info."
249 # Preload all default values for CFLAGS, LDFLAGS, etc. before bsd.pkg.mk
250 # or a pkg Makefile modifies them.
253 # Load the OS-specific definitions for program variables. Default to loading
254 # the NetBSD ones if an OS-specific file doesn't exist.
255 .if exists(${.CURDIR}/../../mk/defs.${OPSYS}.mk)
256 . include "${.CURDIR}/../../mk/defs.${OPSYS}.mk"
257 .elif exists(${.CURDIR}/../mk/defs.${OPSYS}.mk)
258 . include "${.CURDIR}/../mk/defs.${OPSYS}.mk"
259 .elif exists(${.CURDIR}/mk/defs.${OPSYS}.mk)
260 . include "${.CURDIR}/mk/defs.${OPSYS}.mk"
261 .elif exists(${.CURDIR}/../../mk/defs.NetBSD.mk)
262 . include "${.CURDIR}/../../mk/defs.NetBSD.mk"
263 .elif exists(${.CURDIR}/../mk/defs.NetBSD.mk)
264 . include "${.CURDIR}/../mk/defs.NetBSD.mk"
265 .elif exists(${.CURDIR}/mk/defs.NetBSD.mk)
266 . include "${.CURDIR}/mk/defs.NetBSD.mk"
272 # The PHASES_AFTER_<phase> variables list every phase "greater than or
275 PHASES_AFTER_FETCH= fetch ${PHASES_AFTER_EXTRACT}
276 PHASES_AFTER_EXTRACT= extract ${PHASES_AFTER_PATCH}
277 PHASES_AFTER_PATCH= patch ${PHASES_AFTER_TOOLS}
278 PHASES_AFTER_TOOLS= tools ${PHASES_AFTER_BUILDLINK}
279 PHASES_AFTER_BUILDLINK= buildlink ${PHASES_AFTER_CONFIGURE}
280 PHASES_AFTER_CONFIGURE= configure ${PHASES_AFTER_BUILD}
281 PHASES_AFTER_BUILD= build ${PHASES_AFTER_INSTALL}
282 PHASES_AFTER_INSTALL= install ${PHASES_AFTER_PACKAGE}
283 PHASES_AFTER_PACKAGE= package
285 # Set the style of installation to be performed for the package. The
286 # funky make variable modifiers just select the first word of the value
287 # stored in the referenced variable.
289 .for _pref_ in ${PKG_INSTALLATION_PREFS}
290 . if !empty(PKG_INSTALLATION_TYPES:M${_pref_})
291 PKG_INSTALLATION_TYPE?= ${PKG_INSTALLATION_TYPES:M${_pref_}:S/^/_pkginsttype_/1:M_pkginsttype_*:S/^_pkginsttype_//}
294 PKG_INSTALLATION_TYPE?= none
296 # if the system is IPv6-ready, compile with IPv6 support turned on.
297 .if defined(USE_INET6)
298 . if empty(USE_INET6:M[Yy][Ee][Ss]) || defined(USE_SOCKS)
301 PKG_DEFAULT_OPTIONS+= inet6
304 .elif empty(_OPSYS_HAS_INET6:M[nN][oO]) && !defined(USE_SOCKS)
305 PKG_DEFAULT_OPTIONS+= inet6
311 LOCALBASE?= ${DESTDIR}/usr/pkg
312 .if ${OPSYS} == "SunOS"
313 # On Solaris, we default to using OpenWindows for X11.
314 X11BASE?= ${DESTDIR}/usr/openwin
315 .elif !defined(X11_TYPE) || defined(X11_TYPE) && !empty(X11_TYPE:Mnative)
316 X11BASE?= ${DESTDIR}/usr/X11R6
318 CROSSBASE?= ${LOCALBASE}/cross
320 # If xpkgwedge.def is found, then clearly we're using xpkgwedge.
321 .if exists(${LOCALBASE}/lib/X11/config/xpkgwedge.def) || \
322 exists(${X11BASE}/lib/X11/config/xpkgwedge.def)
328 .if defined(_OPSYS_NEEDS_XPKGWEDGE) && \
329 !empty(_OPSYS_NEEDS_XPKGWEDGE:M[yY][eE][sS])
333 .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
340 # Set X11PREFIX to reflect the install directory of X11 packages.
341 # Set XMKMF_CMD properly if xpkgwedge is installed.
343 # The check for the existence of ${X11BASE}/lib/X11/config/xpkgwedge.def
344 # is to catch users of xpkgwedge<1.0.
346 XMKMF?= ${XMKMF_CMD} ${XMKMF_FLAGS} -a
347 XMKMF_FLAGS?= # empty
348 .if !empty(USE_XPKGWEDGE:M[Yy][Ee][Ss])
349 X11PREFIX= ${LOCALBASE}
350 XMKMF_CMD?= ${X11PREFIX}/bin/pkgxmkmf
352 X11PREFIX= ${X11BASE}
353 XMKMF_CMD?= ${X11PREFIX}/bin/xmkmf
356 DEPOT_SUBDIR?= packages
357 DEPOTBASE= ${LOCALBASE}/${DEPOT_SUBDIR}
359 # LINK_RPATH_FLAG publicly exports the linker flag used to set the
360 # run-time library search path.
362 .if defined(_OPSYS_LINKER_RPATH_FLAG)
363 LINKER_RPATH_FLAG= ${_OPSYS_LINKER_RPATH_FLAG}
365 LINKER_RPATH_FLAG?= ${_LINKER_RPATH_FLAG}
368 # COMPILER_RPATH_FLAG publicly exports the compiler flag used to pass
369 # run-time library search path directives to the linker.
371 .if defined(_OPSYS_COMPILER_RPATH_FLAG)
372 COMPILER_RPATH_FLAG= ${_OPSYS_COMPILER_RPATH_FLAG}
374 COMPILER_RPATH_FLAG?= ${_COMPILER_RPATH_FLAG}
377 # WHOLE_ARCHIVE_FLAG and NO_WHOLE_ARCHIVE_FLAG publically export the
378 # linker flags to extract all symbols from a static archive.
379 WHOLE_ARCHIVE_FLAG?= ${_OPSYS_WHOLE_ARCHIVE_FLAG}
380 NO_WHOLE_ARCHIVE_FLAG?= ${_OPSYS_NO_WHOLE_ARCHIVE_FLAG}
383 DIGEST:= ${LOCALBASE}/bin/digest
384 MAKEFLAGS+= DIGEST=${DIGEST}
387 # Only add the DIGEST_VERSION value to MAKEFLAGS when we know
388 # we've got a valid version number, retrieved from the digest(1)
389 # binary. This is different to PKGTOOLS_VERSION, since, in that
390 # case, the build dies when pkg_info(1) is out of date.
392 .if !exists(${DIGEST})
393 DIGEST_VERSION= 20010301
394 .elif !defined(DIGEST_VERSION)
395 DIGEST_VERSION!= ${DIGEST} -V 2>/dev/null
396 MAKEFLAGS+= DIGEST_VERSION=${DIGEST_VERSION}
399 # This is the package database directory for the default view.
400 PKG_DBDIR?= ${DESTDIR}/var/db/pkg
402 # _PKG_DBDIR is the actual packages database directory where we register
405 .if ${PKG_INSTALLATION_TYPE} == "overwrite"
406 _PKG_DBDIR= ${PKG_DBDIR}
407 .elif ${PKG_INSTALLATION_TYPE} == "pkgviews"
408 _PKG_DBDIR= ${DEPOTBASE}
411 PKG_ADD_CMD?= ${PKG_TOOLS_BIN}/pkg_add
412 PKG_ADMIN_CMD?= ${PKG_TOOLS_BIN}/pkg_admin
413 PKG_CREATE_CMD?= ${PKG_TOOLS_BIN}/pkg_create
414 PKG_DELETE_CMD?= ${PKG_TOOLS_BIN}/pkg_delete
415 PKG_INFO_CMD?= ${PKG_TOOLS_BIN}/pkg_info
416 PKG_VIEW_CMD?= ${PKG_TOOLS_BIN}/pkg_view
417 LINKFARM_CMD?= ${PKG_TOOLS_BIN}/linkfarm
419 .if !defined(PKGTOOLS_VERSION)
420 PKGTOOLS_VERSION!= ${PKG_INFO_CMD} -V 2>/dev/null || echo 20010302
421 MAKEFLAGS+= PKGTOOLS_VERSION=${PKGTOOLS_VERSION}
424 # The binary pkg_install tools all need to consistently to refer to the
425 # correct package database directory.
427 .if ${PKGTOOLS_VERSION} < 20030823
428 PKGTOOLS_ENV?= PKG_DBDIR=${_PKG_DBDIR}
429 PKGTOOLS_ARGS?= # empty
431 PKGTOOLS_ENV?= # empty
432 PKGTOOLS_ARGS?= -K ${_PKG_DBDIR}
435 # Views are rooted in ${LOCALBASE}, all packages are depoted in
436 # ${DEPOTBASE}, and the package database directory for the default view
437 # is in ${PKG_DBDIR}.
439 PKG_VIEW_ARGS?= -W ${LOCALBASE} -d ${DEPOTBASE} -k ${PKG_DBDIR}
441 PKG_ADD?= ${PKGTOOLS_ENV} ${PKG_ADD_CMD} ${PKGTOOLS_ARGS}
442 PKG_ADMIN?= ${PKGTOOLS_ENV} ${PKG_ADMIN_CMD} ${PKGTOOLS_ARGS}
443 PKG_CREATE?= ${PKGTOOLS_ENV} ${PKG_CREATE_CMD} ${PKGTOOLS_ARGS}
444 PKG_DELETE?= ${PKGTOOLS_ENV} ${PKG_DELETE_CMD} ${PKGTOOLS_ARGS}
445 PKG_INFO?= ${PKGTOOLS_ENV} ${PKG_INFO_CMD} ${PKGTOOLS_ARGS}
446 PKG_VIEW?= ${PKGTOOLS_ENV} ${PKG_VIEW_CMD} ${PKG_VIEW_ARGS}
447 LINKFARM?= ${LINKFARM_CMD}
449 # "${PKG_BEST_EXISTS} pkgpattern" prints out the name of the installed
450 # package that best matches pkgpattern. Use this instead of
451 # "${PKG_INFO} -e pkgpattern" if the latter would return more than one
454 PKG_BEST_EXISTS?= ${PKG_ADMIN} -b -d ${_PKG_DBDIR} -S lsbest
456 USE_BUILDLINK3?= no # default to not using buildlink3
457 .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
458 USE_BUILDLINK3= yes # pkgviews requires buildlink3
461 .if exists(${LOCALBASE}/bsd/share/mk/zoularis.mk)
462 PKG_FAIL_REASON+= 'You appear to have a deprecated Zoularis installation.'
463 PKG_FAIL_REASON+= 'Please update your system to bootstrap-pkgsrc and remove the'
464 PKG_FAIL_REASON+= '${LOCALBASE}/bsd directory.'
465 PKG_FAIL_REASON+= 'See http://mail-index.NetBSD.org/tech-pkg/2004/02/14/0004.html'
466 PKG_FAIL_REASON+= 'for more details.'
469 _PKGSRCDIR?= ${.CURDIR:C|/[^/]*/[^/]*$||}
470 PKGPATH?= ${.CURDIR:C|.*/([^/]*/[^/]*)$|\1|}
472 DISTDIR?= ${_PKGSRCDIR}/distfiles
473 PACKAGES?= ${_PKGSRCDIR}/packages
474 TEMPLATES?= ${_PKGSRCDIR}/templates
476 PATCHDIR?= ${.CURDIR}/patches
477 SCRIPTDIR?= ${.CURDIR}/scripts
478 FILESDIR?= ${.CURDIR}/files
481 _PKGSRC_DEPS?= # empty
483 # If WRKOBJDIR is set, use that tree to build
484 .if defined(WRKOBJDIR)
485 BUILD_DIR?= ${WRKOBJDIR}/${PKGPATH}
487 BUILD_DIR!= cd ${.CURDIR} && ${PWD_CMD}
490 # If OBJHOSTNAME is set, use first component of hostname in directory name.
491 # If OBJMACHINE is set, use ${MACHINE_ARCH} in the working directory name.
493 .if defined(OBJHOSTNAME)
494 . if !defined(_HOSTNAME)
495 _HOSTNAME!= ${UNAME} -n
496 MAKEFLAGS+= _HOSTNAME=${_HOSTNAME}
498 WRKDIR_BASENAME?= work.${_HOSTNAME:C|\..*||}
499 MAKEFLAGS+= OBJHOSTNAME=${OBJHOSTNAME}
500 .elif defined(OBJMACHINE)
501 WRKDIR_BASENAME?= work.${MACHINE_ARCH}
502 MAKEFLAGS+= OBJMACHINE=${OBJMACHINE}
504 WRKDIR_BASENAME?= work
507 WRKDIR?= ${BUILD_DIR}/${WRKDIR_BASENAME}
509 # There are many uses for a common log file, so define one that may be
510 # picked up and used by tools.mk, bsd.buildlink3.mk, etc.
512 WRKLOG?= ${WRKDIR}/.work.log
514 PKG_DEFAULT_OPTIONS?= # empty
515 PKG_OPTIONS?= # empty