3 # local configuration specific to meta mode
4 # XXX some of this should be in meta.sys.mk
5 # we assume that MK_DIRDEPS_BUILD=yes
7 # we need this until there is an alternative
8 MK_INSTALL_AS_USER= yes
10 .if !defined(HOST_TARGET) || !defined(HOST_MACHINE)
11 # we need HOST_TARGET etc below.
12 .include <host-target.mk>
16 # from src/Makefile (for universe)
17 TARGET_ARCHES_arm?= arm armv6 armv7
18 TARGET_ARCHES_arm64?= aarch64
19 TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 mipsn32el
20 TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpc64le powerpcspe
21 TARGET_ARCHES_riscv?= riscv64 riscv64sf
24 BOOT_MACHINE_DIR.amd64 = boot/i386
25 MACHINE_ARCH.host = ${_HOST_ARCH}
27 # the list of machines we support
28 ALL_MACHINE_LIST?= amd64 arm arm64 i386 mips powerpc riscv
29 .for m in ${ALL_MACHINE_LIST:O:u}
30 MACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m}
31 MACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]}
32 BOOT_MACHINE_DIR.$m ?= boot/$m
36 .if empty(MACHINE_ARCH)
37 .if !empty(TARGET_ARCH)
38 MACHINE_ARCH= ${TARGET_ARCH}
40 MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
43 MACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}}
44 MACHINE_ARCH:= ${MACHINE_ARCH}
46 # we got here via dirdeps
47 MACHINE_ARCH:= ${MACHINE_ARCH.${MACHINE}}
50 # now because for universe we want to potentially
51 # build for multiple MACHINE_ARCH per MACHINE
52 # we need more than MACHINE in TARGET_SPEC
53 TARGET_SPEC_VARS= MACHINE MACHINE_ARCH
55 .if ${TARGET_SPEC:Uno:M*,*} != ""
56 _tspec := ${TARGET_SPEC:S/,/ /g}
57 MACHINE := ${_tspec:[1]}
58 MACHINE_ARCH := ${_tspec:[2]}
60 # We need to stop that TARGET_SPEC affecting any submakes
61 # and deal with MACHINE=${TARGET_SPEC} in the environment.
63 # export but do not track
64 .export-env TARGET_SPEC
65 .export ${TARGET_SPEC_VARS}
66 .for v in ${TARGET_SPEC_VARS:O:u}
72 # make sure we know what TARGET_SPEC is
73 # as we may need it to find Makefile.depend*
74 TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
76 # to be consistent with src/Makefile just concatenate with '.'s
77 TARGET_OBJ_SPEC:= ${TARGET_SPEC:S;,;.;g}
78 OBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC}
80 .if defined(MAKEOBJDIR)
81 .if ${MAKEOBJDIR:M/*} == ""
82 .error Cannot use MAKEOBJDIR=${MAKEOBJDIR}${.newline}Unset MAKEOBJDIR to get default: MAKEOBJDIR='${_default_makeobjdir}'
86 HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET}
88 .if ${OBJTOP} == ${HOST_OBJTOP} || ${REQUESTED_MACHINE:U${MACHINE}} == "host"
90 .if ${TARGET_MACHINE:Uno} == ${HOST_TARGET}
95 .if ${MACHINE} == "host"
96 OBJTOP := ${HOST_OBJTOP}
99 .if ${.MAKE.LEVEL} == 0 || empty(PYTHON)
100 PYTHON ?= /usr/local/bin/python
102 # this works best if share/mk is ready for it.
104 # _SKIP_BUILD is not 100% as it requires wrapping all 'all:' targets to avoid
105 # building in MAKELEVEL0. Just prohibit 'all' entirely in this case to avoid
107 .if ${MK_DIRDEPS_BUILD} == "yes" && \
108 ${.MAKE.LEVEL} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
111 .error DIRDEPS_BUILD: Please run '${MAKE}' instead of '${MAKE} all'.
116 # we want to end up with a singe stage tree for all machines
117 .if ${MK_STAGING} == "yes"
118 .if empty(STAGE_ROOT)
119 STAGE_ROOT?= ${OBJROOT}stage
124 .if ${MK_STAGING} == "yes"
125 .if ${MACHINE} == "host"
126 STAGE_MACHINE= ${HOST_TARGET}
128 STAGE_MACHINE:= ${TARGET_OBJ_SPEC}
130 STAGE_OBJTOP:= ${STAGE_ROOT}/${STAGE_MACHINE}
131 STAGE_COMMON_OBJTOP:= ${STAGE_ROOT}/common
132 STAGE_TARGET_OBJTOP:= ${STAGE_ROOT}/${TARGET_OBJ_SPEC}
133 STAGE_HOST_OBJTOP:= ${STAGE_ROOT}/${HOST_TARGET}
134 # These are exported for hooking in out-of-tree builds. They will always
135 # be overridden in sub-makes above when building in-tree.
136 .if ${.MAKE.LEVEL} > 0
137 .export STAGE_OBJTOP STAGE_TARGET_OBJTOP STAGE_HOST_OBJTOP
140 # Use tools/install.sh which can avoid the need for xinstall for simple cases.
141 INSTALL?= sh ${SRCTOP}/tools/install.sh
142 # This is for stage-install to pickup from the environment.
143 REAL_INSTALL:= ${INSTALL}
145 STAGE_INSTALL= sh ${.PARSEDIR:tA}/stage-install.sh OBJDIR=${.OBJDIR:tA}
147 STAGE_LIBDIR= ${STAGE_OBJTOP}${_LIBDIR:U${LIBDIR:U/lib}}
148 STAGE_INCLUDEDIR= ${STAGE_OBJTOP}${INCLUDEDIR:U/usr/include}
149 # this is not the same as INCLUDEDIR
150 STAGE_INCSDIR= ${STAGE_OBJTOP}${INCSDIR:U/include}
151 # the target is usually an absolute path
152 STAGE_SYMLINKS_DIR= ${STAGE_OBJTOP}
154 #LDFLAGS_LAST+= -Wl,-rpath-link,${STAGE_LIBDIR}
155 .if ${MK_SYSROOT} == "yes"
156 SYSROOT?= ${STAGE_OBJTOP}
158 LDFLAGS_LAST+= -L${STAGE_LIBDIR}
163 .-include "local.toolchain.mk"
165 # this is sufficient for most of the tree.
166 .MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX}
168 # but if we have a machine qualified file it should be used in preference
169 .MAKE.DEPENDFILE_PREFERENCE = \
170 ${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
171 ${.MAKE.DEPENDFILE_PREFIX}
173 .undef .MAKE.DEPENDFILE
175 .include "sys.dependfile.mk"
177 .if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host"
178 # we can use this but should not update it.
179 UPDATE_DEPENDFILE= NO
182 # define the list of places that contain files we are responsible for
183 .MAKE.META.BAILIWICK = ${SB} ${OBJROOT} ${STAGE_ROOT}
185 CSU_DIR.${MACHINE_ARCH} ?= csu/${MACHINE_ARCH}
186 CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}}
188 .if !empty(TIME_STAMP)
189 TRACER= ${TIME_STAMP} ${:U}
191 .if !defined(_RECURSING_PROGS) && !defined(_RECURSING_CRUNCH) && \
196 # toolchains can be a pain - especially bootstrappping them
197 .if ${MACHINE} == "host"
198 MK_SHARED_TOOLCHAIN= no
200 TOOLCHAIN_VARS= AS AR CC CLANG_TBLGEN CXX CPP LD NM OBJCOPY RANLIB \
201 STRINGS SIZE LLVM_TBLGEN
202 _toolchain_bin_CLANG_TBLGEN= /usr/bin/clang-tblgen
203 _toolchain_bin_LLVM_TBLGEN= /usr/bin/llvm-tblgen
204 _toolchain_bin_CXX= /usr/bin/c++
206 TOOLSDIR?= ${HOST_OBJTOP}/tools
207 .elif defined(STAGE_HOST_OBJTOP)
208 TOOLSDIR?= ${STAGE_HOST_OBJTOP}
210 # Only define if it exists in case user didn't run bootstrap-tools. Otherwise
211 # the tool will be built during the build. Building it assumes it is
213 .if exists(${HOST_OBJTOP}/tools${.CURDIR})
214 BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR}
217 # Don't use the bootstrap tools logic on itself.
218 .if ${.TARGETS:Mbootstrap-tools} == "" && \
219 !make(test-system-*) && !make(showconfig) && !make(print-dir) && \
220 !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0
221 .for dir in /sbin /bin /usr/sbin /usr/bin
222 PATH:= ${TOOLSDIR}${dir}:${PATH}
225 # Prefer the TOOLSDIR version of the toolchain if present vs the host version.
226 .for var in ${TOOLCHAIN_VARS}
227 _toolchain_bin.${var}= ${TOOLSDIR}${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
228 .if exists(${_toolchain_bin.${var}})
229 HOST_${var}?= ${_toolchain_bin.${var}}
235 .for var in ${TOOLCHAIN_VARS}
236 HOST_${var}?= ${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
239 .if ${MACHINE} == "host"
240 .for var in ${TOOLCHAIN_VARS}
241 ${var}= ${HOST_${var}}
245 .if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
247 .if !defined(FREEBSD_REVISION)
248 FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh
249 .export FREEBSD_REVISION
251 CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION}
252 CFLAGS+= ${CROSS_TARGET_FLAGS}
253 ACFLAGS+= ${CROSS_TARGET_FLAGS}
254 LDFLAGS+= -Wl,-m -Wl,elf_${MACHINE_ARCH}_fbsd
257 META_MODE+= missing-meta=yes
258 .if empty(META_MODE:Mnofilemon)
259 META_MODE+= missing-filemon=yes