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 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 sparc64
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
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 .export STAGE_OBJTOP STAGE_TARGET_OBJTOP STAGE_HOST_OBJTOP
138 # Use tools/install.sh which can avoid the need for xinstall for simple cases.
139 INSTALL?= sh ${SRCTOP}/tools/install.sh
140 # This is for stage-install to pickup from the environment.
141 REAL_INSTALL:= ${INSTALL}
143 STAGE_INSTALL= sh ${.PARSEDIR:tA}/stage-install.sh OBJDIR=${.OBJDIR:tA}
145 STAGE_LIBDIR= ${STAGE_OBJTOP}${_LIBDIR:U${LIBDIR:U/lib}}
146 STAGE_INCLUDEDIR= ${STAGE_OBJTOP}${INCLUDEDIR:U/usr/include}
147 # this is not the same as INCLUDEDIR
148 STAGE_INCSDIR= ${STAGE_OBJTOP}${INCSDIR:U/include}
149 # the target is usually an absolute path
150 STAGE_SYMLINKS_DIR= ${STAGE_OBJTOP}
152 #LDFLAGS_LAST+= -Wl,-rpath-link,${STAGE_LIBDIR}
153 .if ${MK_SYSROOT} == "yes"
154 SYSROOT?= ${STAGE_OBJTOP}
156 LDFLAGS_LAST+= -L${STAGE_LIBDIR}
161 .-include "local.toolchain.mk"
163 # this is sufficient for most of the tree.
164 .MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX}
166 # but if we have a machine qualified file it should be used in preference
167 .MAKE.DEPENDFILE_PREFERENCE = \
168 ${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
169 ${.MAKE.DEPENDFILE_PREFIX}
171 .undef .MAKE.DEPENDFILE
173 .include "sys.dependfile.mk"
175 .if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host"
176 # we can use this but should not update it.
177 UPDATE_DEPENDFILE= NO
180 # define the list of places that contain files we are responsible for
181 .MAKE.META.BAILIWICK = ${SB} ${OBJROOT} ${STAGE_ROOT}
183 CSU_DIR.${MACHINE_ARCH} ?= csu/${MACHINE_ARCH}
184 CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}}
186 .if !empty(TIME_STAMP)
187 TRACER= ${TIME_STAMP} ${:U}
189 .if !defined(_RECURSING_PROGS) && !defined(_RECURSING_CRUNCH) && \
194 # toolchains can be a pain - especially bootstrappping them
195 .if ${MACHINE} == "host"
196 MK_SHARED_TOOLCHAIN= no
198 TOOLCHAIN_VARS= AS AR CC CLANG_TBLGEN CXX CPP LD NM OBJCOPY RANLIB \
199 STRINGS SIZE LLVM_TBLGEN
200 _toolchain_bin_CLANG_TBLGEN= /usr/bin/clang-tblgen
201 _toolchain_bin_LLVM_TBLGEN= /usr/bin/llvm-tblgen
202 _toolchain_bin_CXX= /usr/bin/c++
204 TOOLSDIR?= ${HOST_OBJTOP}/tools
205 .elif defined(STAGE_HOST_OBJTOP)
206 TOOLSDIR?= ${STAGE_HOST_OBJTOP}
208 # Only define if it exists in case user didn't run bootstrap-tools. Otherwise
209 # the tool will be built during the build. Building it assumes it is
211 .if exists(${HOST_OBJTOP}/tools${.CURDIR})
212 BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR}
215 # Don't use the bootstrap tools logic on itself.
216 .if ${.TARGETS:Mbootstrap-tools} == "" && \
217 !make(test-system-*) && !make(showconfig) && !make(print-dir) && \
218 !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0
219 .for dir in /sbin /bin /usr/sbin /usr/bin
220 PATH:= ${TOOLSDIR}${dir}:${PATH}
223 # Prefer the TOOLSDIR version of the toolchain if present vs the host version.
224 .for var in ${TOOLCHAIN_VARS}
225 _toolchain_bin.${var}= ${TOOLSDIR}${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
226 .if exists(${_toolchain_bin.${var}})
227 HOST_${var}?= ${_toolchain_bin.${var}}
233 .for var in ${TOOLCHAIN_VARS}
234 HOST_${var}?= ${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
237 .if ${MACHINE} == "host"
238 .for var in ${TOOLCHAIN_VARS}
239 ${var}= ${HOST_${var}}
243 .if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
245 .if !defined(FREEBSD_REVISION)
246 FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh
247 .export FREEBSD_REVISION
249 CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION}
250 CFLAGS+= ${CROSS_TARGET_FLAGS}
251 ACFLAGS+= ${CROSS_TARGET_FLAGS}
252 LDFLAGS+= -Wl,-m -Wl,elf_${MACHINE_ARCH}_fbsd
255 META_MODE+= missing-meta=yes
256 .if empty(META_MODE:Mnofilemon)
257 META_MODE+= missing-filemon=yes