local.meta.sys.mk revision 297438
1# $FreeBSD: head/share/mk/local.meta.sys.mk 297438 2016-03-31 00:26:40Z 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 armv6hf 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 -Wl,${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) 218WITH_META_STATS= t 219.endif 220 221# toolchains can be a pain - especially bootstrappping them 222.if ${MACHINE} == "host" 223MK_SHARED_TOOLCHAIN= no 224.endif 225TOOLCHAIN_VARS= AS AR CC CLANG_TBLGEN CXX CPP LD NM OBJDUMP OBJCOPY RANLIB \ 226 STRINGS SIZE LLVM_TBLGEN 227_toolchain_bin_CLANG_TBLGEN= /usr/bin/clang-tblgen 228_toolchain_bin_LLVM_TBLGEN= /usr/bin/llvm-tblgen 229_toolchain_bin_CXX= /usr/bin/c++ 230.ifdef WITH_TOOLSDIR 231TOOLSDIR?= ${HOST_OBJTOP}/tools 232.elif defined(STAGE_HOST_OBJTOP) 233TOOLSDIR?= ${STAGE_HOST_OBJTOP} 234.endif 235# Don't use the bootstrap tools logic on itself. 236.if ${.TARGETS:Mbootstrap-tools} == "" && \ 237 !make(showconfig) && \ 238 !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0 239.for dir in /sbin /bin /usr/sbin /usr/bin 240PATH:= ${TOOLSDIR}${dir}:${PATH} 241.endfor 242.export PATH 243# Prefer the TOOLSDIR version of the toolchain if present vs the host version. 244.for var in ${TOOLCHAIN_VARS} 245_toolchain_bin.${var}= ${TOOLSDIR}${_toolchain_bin_${var}:U/usr/bin/${var:tl}} 246.if exists(${_toolchain_bin.${var}}) 247HOST_${var}?= ${_toolchain_bin.${var}} 248.export HOST_${var} 249.endif 250.endfor 251.endif 252 253.for var in ${TOOLCHAIN_VARS} 254HOST_${var}?= ${_toolchain_bin_${var}:U/usr/bin/${var:tl}} 255.endfor 256 257.if ${MACHINE} == "host" 258.for var in ${TOOLCHAIN_VARS} 259${var}= ${HOST_${var}} 260.endfor 261.endif 262 263.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE} 264# cross-building 265.if !defined(FREEBSD_REVISION) 266FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh 267.export FREEBSD_REVISION 268.endif 269CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION} 270CFLAGS+= ${CROSS_TARGET_FLAGS} 271ACFLAGS+= ${CROSS_TARGET_FLAGS} 272LDFLAGS+= -Wl,-m -Wl,elf_${MACHINE_ARCH}_fbsd 273.endif 274