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