1 # $Id: sys.mk,v 1.51 2020/08/19 17:51:53 sjg Exp $
3 # @(#) Copyright (c) 2003-2009, Simon J. Gerraty
5 # This file is provided in the hope that it will
6 # be of use. There is absolutely NO WARRANTY.
7 # Permission to copy, redistribute or otherwise
8 # use this file is hereby granted provided that
9 # the above copyright notice and this notice are
12 # Please send copies of changes and bug-fixes to:
16 # Avoid putting anything platform specific in here.
18 # _DEBUG_MAKE_FLAGS etc.
19 .include <sys.debug.mk>
21 .if !empty(_DEBUG_MAKE_FLAGS)
22 .if ${_DEBUG_MAKE_SYS_DIRS:Uno:@x@${.CURDIR:M$x}@} != ""
23 .MAKEFLAGS: ${_DEBUG_MAKE_FLAGS}
28 .include <sys.vars.mk>
30 # we expect a recent bmake
31 .if !defined(_TARGETS)
32 # some things we do only once
33 _TARGETS := ${.TARGETS}
34 .-include <sys.env.mk>
37 # we need HOST_TARGET etc below.
38 .include <host-target.mk>
40 # early customizations
41 .-include <local.sys.env.mk>
43 # Popular suffixes for C++
44 CXX_SUFFIXES += .cc .cpp .cxx .C
45 CXX_SUFFIXES := ${CXX_SUFFIXES:O:u}
47 # find the OS specifics
48 .if defined(SYS_OS_MK)
49 .include <${SYS_OS_MK}>
52 .for x in ${HOST_OSTYPE} ${HOST_TARGET} ${HOST_OS} ${MACHINE} Generic
55 _sys_mk := ${.MAKE.MAKEFILES:M*/$x.mk}
57 _sys_mk := sys/${_sys_mk:T}
61 # might be an old style
63 _sys_mk := ${.MAKE.MAKEFILES:M*/$x.sys.mk:T}
67 SYS_OS_MK := ${_sys_mk}
71 # some options we need to know early
72 OPTIONS_DEFAULT_NO += \
76 OPTIONS_DEFAULT_DEPENDENT += \
77 AUTO_OBJ/DIRDEPS_BUILD \
78 META_MODE/DIRDEPS_BUILD \
79 STAGING/DIRDEPS_BUILD \
80 STATIC_DIRDEPS_CACHE/DIRDEPS_CACHE \
82 .-include <options.mk>
84 .if ${MK_DIRDEPS_BUILD:Uno} == "yes"
86 .-include <meta.sys.mk>
87 .elif ${MK_META_MODE:Uno} == "yes"
88 .MAKE.MODE = meta verbose ${META_MODE}
90 # make sure we have a harmless value
93 # if you want objdirs make them automatic
94 # and do it early before we compute .PATH
95 .if ${MK_AUTO_OBJ:Uno} == "yes" || ${MKOBJDIRS:Uno} == "auto"
96 .include <auto.obj.mk>
100 .if ${.CURDIR} == ${SRCTOP}
102 .elif ${.CURDIR:M${SRCTOP}/*}
103 RELDIR := ${.CURDIR:S,${SRCTOP}/,,}
107 MACHINE_ARCH.host ?= ${_HOST_ARCH}
108 MACHINE_ARCH.${MACHINE} ?= ${MACHINE}
109 .if empty(MACHINE_ARCH)
110 MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}}
114 ROOT_GROUP != sed -n /:0:/s/:.*//p /etc/group
118 unix ?= We run ${_HOST_OSNAME}.
120 # We need a Bourne/POSIX shell
122 SHELL ?= ${MAKE_SHELL}
124 # A race condition in mkdir, means that it can bail if another
125 # process made a dir that mkdir expected to.
126 # We repeat the mkdir -p a number of times to try and work around this.
127 # We stop looping as soon as the dir exists.
128 # If we get to the end of the loop, a plain mkdir will issue an error.
131 for i in 1 2 3 4 5 6; do \
133 test -d $$d && return 0; \
135 mkdir $$d || exit $$?; \
138 # this often helps with debugging
142 @${COMPILE.c:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$'
144 ${CXX_SUFFIXES:%=%.cpp-out}:
145 @${COMPILE.cc:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$'
147 # late customizations
148 .-include <local.sys.mk>
150 # if .CURDIR is matched by any entry in DEBUG_MAKE_DIRS we
151 # will apply DEBUG_MAKE_FLAGS, now.
152 .if !empty(_DEBUG_MAKE_FLAGS)
153 .if ${_DEBUG_MAKE_DIRS:Uno:@x@${.CURDIR:M$x}@} != ""
154 .MAKEFLAGS: ${_DEBUG_MAKE_FLAGS}