1# $FreeBSD$ 2 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 6 7# we need this until there is an alternative 8MK_INSTALL_AS_USER= yes 9 10.if !defined(HOST_TARGET) || !defined(HOST_MACHINE) 11# we need HOST_TARGET etc below. 12.include <host-target.mk> 13.export HOST_TARGET 14.endif 15 16# from src/Makefile (for universe) 17TARGET_ARCHES_arm?= arm armv6 armv7 18TARGET_ARCHES_arm64?= aarch64 19TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 mipsn32el 20TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpc64le powerpcspe 21TARGET_ARCHES_riscv?= riscv64 riscv64sf 22 23# some corner cases 24BOOT_MACHINE_DIR.amd64 = boot/i386 25MACHINE_ARCH.host = ${_HOST_ARCH} 26 27# the list of machines we support 28ALL_MACHINE_LIST?= amd64 arm arm64 i386 mips powerpc riscv 29.for m in ${ALL_MACHINE_LIST:O:u} 30MACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m} 31MACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]} 32BOOT_MACHINE_DIR.$m ?= boot/$m 33.endfor 34 35.ifndef _TARGET_SPEC 36.if empty(MACHINE_ARCH) 37.if !empty(TARGET_ARCH) 38MACHINE_ARCH= ${TARGET_ARCH} 39.else 40MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}} 41.endif 42.endif 43MACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}} 44MACHINE_ARCH:= ${MACHINE_ARCH} 45.else 46# we got here via dirdeps 47MACHINE_ARCH:= ${MACHINE_ARCH.${MACHINE}} 48.endif 49 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 53TARGET_SPEC_VARS= MACHINE MACHINE_ARCH 54# see dirdeps.mk 55.if ${TARGET_SPEC:Uno:M*,*} != "" 56_tspec := ${TARGET_SPEC:S/,/ /g} 57MACHINE := ${_tspec:[1]} 58MACHINE_ARCH := ${_tspec:[2]} 59# etc. 60# We need to stop that TARGET_SPEC affecting any submakes 61# and deal with MACHINE=${TARGET_SPEC} in the environment. 62TARGET_SPEC= 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} 67.if empty($v) 68.undef $v 69.endif 70.endfor 71.endif 72# make sure we know what TARGET_SPEC is 73# as we may need it to find Makefile.depend* 74TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} 75 76# to be consistent with src/Makefile just concatenate with '.'s 77TARGET_OBJ_SPEC:= ${TARGET_SPEC:S;,;.;g} 78OBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC} 79 80.if defined(MAKEOBJDIR) 81.if ${MAKEOBJDIR:M/*} == "" 82.error Cannot use MAKEOBJDIR=${MAKEOBJDIR}${.newline}Unset MAKEOBJDIR to get default: MAKEOBJDIR='${_default_makeobjdir}' 83.endif 84.endif 85 86HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET} 87 88.if ${OBJTOP} == ${HOST_OBJTOP} || ${REQUESTED_MACHINE:U${MACHINE}} == "host" 89MACHINE= host 90.if ${TARGET_MACHINE:Uno} == ${HOST_TARGET} 91# not what we want 92TARGET_MACHINE= host 93.endif 94.endif 95.if ${MACHINE} == "host" 96OBJTOP := ${HOST_OBJTOP} 97.endif 98 99.if ${.MAKE.LEVEL} == 0 || empty(PYTHON) 100PYTHON ?= /usr/local/bin/python 101.export PYTHON 102# _SKIP_BUILD is not 100% as it requires wrapping all 'all:' targets to avoid 103# building in MAKELEVEL0. Just prohibit 'all' entirely in this case to avoid 104# problems. 105.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} == 0 106.MAIN: dirdeps 107.if make(all) 108.error DIRDEPS_BUILD: Please run '${MAKE}' instead of '${MAKE} all'. 109.endif 110.endif 111.endif 112 113# we want to end up with a singe stage tree for all machines 114.if ${MK_STAGING} == "yes" 115.if empty(STAGE_ROOT) 116STAGE_ROOT?= ${OBJROOT}stage 117.export STAGE_ROOT 118.endif 119.endif 120 121.if ${MK_STAGING} == "yes" 122.if ${MACHINE} == "host" 123STAGE_MACHINE= ${HOST_TARGET} 124.else 125STAGE_MACHINE:= ${TARGET_OBJ_SPEC} 126.endif 127STAGE_OBJTOP:= ${STAGE_ROOT}/${STAGE_MACHINE} 128STAGE_COMMON_OBJTOP:= ${STAGE_ROOT}/common 129STAGE_TARGET_OBJTOP:= ${STAGE_ROOT}/${TARGET_OBJ_SPEC} 130STAGE_HOST_OBJTOP:= ${STAGE_ROOT}/${HOST_TARGET} 131# These are exported for hooking in out-of-tree builds. They will always 132# be overridden in sub-makes above when building in-tree. 133.if ${.MAKE.LEVEL} > 0 134.export STAGE_OBJTOP STAGE_TARGET_OBJTOP STAGE_HOST_OBJTOP 135.endif 136 137# Use tools/install.sh which can avoid the need for xinstall for simple cases. 138INSTALL?= sh ${SRCTOP}/tools/install.sh 139# This is for stage-install to pickup from the environment. 140REAL_INSTALL:= ${INSTALL} 141.export REAL_INSTALL 142STAGE_INSTALL= sh ${.PARSEDIR:tA}/stage-install.sh OBJDIR=${.OBJDIR:tA} 143 144STAGE_LIBDIR= ${STAGE_OBJTOP}${_LIBDIR:U${LIBDIR:U/lib}} 145STAGE_INCLUDEDIR= ${STAGE_OBJTOP}${INCLUDEDIR:U/usr/include} 146# this is not the same as INCLUDEDIR 147STAGE_INCSDIR= ${STAGE_OBJTOP}${INCSDIR:U/include} 148# the target is usually an absolute path 149STAGE_SYMLINKS_DIR= ${STAGE_OBJTOP} 150 151#LDFLAGS_LAST+= -Wl,-rpath-link,${STAGE_LIBDIR} 152.if ${MK_SYSROOT} == "yes" 153SYSROOT?= ${STAGE_OBJTOP} 154.else 155LDFLAGS_LAST+= -L${STAGE_LIBDIR} 156.endif 157 158.endif # MK_STAGING 159 160.-include "local.toolchain.mk" 161 162# this is sufficient for most of the tree. 163.MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX} 164 165# but if we have a machine qualified file it should be used in preference 166.MAKE.DEPENDFILE_PREFERENCE = \ 167 ${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \ 168 ${.MAKE.DEPENDFILE_PREFIX} 169 170.undef .MAKE.DEPENDFILE 171 172.include "sys.dependfile.mk" 173 174.if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host" 175# we can use this but should not update it. 176UPDATE_DEPENDFILE= NO 177.endif 178# Don't require filemon for makeman. 179.if make(showconfig) 180UPDATE_DEPENDFILE= NO 181.endif 182 183# define the list of places that contain files we are responsible for 184.MAKE.META.BAILIWICK = ${SB} ${OBJROOT} ${STAGE_ROOT} 185 186CSU_DIR.${MACHINE_ARCH} ?= csu/${MACHINE_ARCH} 187CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}} 188 189.if !empty(TIME_STAMP) 190TRACER= ${TIME_STAMP} ${:U} 191.endif 192.if !defined(_RECURSING_PROGS) && !defined(_RECURSING_CRUNCH) && \ 193 !make(print-dir) 194WITH_META_STATS= t 195.endif 196 197# toolchains can be a pain - especially bootstrappping them 198.if ${MACHINE} == "host" 199MK_SHARED_TOOLCHAIN= no 200.endif 201TOOLCHAIN_VARS= AS AR CC CLANG_TBLGEN CXX CPP LD NM OBJCOPY RANLIB \ 202 STRINGS SIZE LLVM_TBLGEN 203_toolchain_bin_CLANG_TBLGEN= /usr/bin/clang-tblgen 204_toolchain_bin_LLVM_TBLGEN= /usr/bin/llvm-tblgen 205_toolchain_bin_CXX= /usr/bin/c++ 206.ifdef WITH_TOOLSDIR 207TOOLSDIR?= ${HOST_OBJTOP}/tools 208.elif defined(STAGE_HOST_OBJTOP) 209TOOLSDIR?= ${STAGE_HOST_OBJTOP} 210.endif 211# Only define if it exists in case user didn't run bootstrap-tools. Otherwise 212# the tool will be built during the build. Building it assumes it is 213# TARGET==MACHINE. 214.if exists(${HOST_OBJTOP}/tools${.CURDIR}) 215BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR} 216.endif 217 218# Don't use the bootstrap tools logic on itself. 219.if ${.TARGETS:Mbootstrap-tools} == "" && \ 220 !make(test-system-*) && !make(showconfig) && !make(print-dir) && \ 221 !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0 222.for dir in /sbin /bin /usr/sbin /usr/bin 223PATH:= ${TOOLSDIR}${dir}:${PATH} 224.endfor 225.export PATH 226# Prefer the TOOLSDIR version of the toolchain if present vs the host version. 227.for var in ${TOOLCHAIN_VARS} 228_toolchain_bin.${var}= ${TOOLSDIR}${_toolchain_bin_${var}:U/usr/bin/${var:tl}} 229.if exists(${_toolchain_bin.${var}}) 230HOST_${var}?= ${_toolchain_bin.${var}} 231.export HOST_${var} 232.endif 233.endfor 234.endif 235 236.for var in ${TOOLCHAIN_VARS} 237HOST_${var}?= ${_toolchain_bin_${var}:U/usr/bin/${var:tl}} 238.endfor 239 240.if ${MACHINE} == "host" 241.for var in ${TOOLCHAIN_VARS} 242${var}= ${HOST_${var}} 243.endfor 244.endif 245 246.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE} 247# cross-building 248.if !defined(FREEBSD_REVISION) 249FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh 250.export FREEBSD_REVISION 251.endif 252CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION} 253CFLAGS+= ${CROSS_TARGET_FLAGS} 254ACFLAGS+= ${CROSS_TARGET_FLAGS} 255LDFLAGS+= -Wl,-m -Wl,elf_${MACHINE_ARCH}_fbsd 256.endif 257 258META_MODE+= missing-meta=yes 259.if empty(META_MODE:Mnofilemon) 260META_MODE+= missing-filemon=yes 261.endif 262