1WITH_INSTALL_AS_USER= yes 2 3.if defined(.PARSEDIR) # bmake 4.if !defined(_TARGETS) 5# some things we do only once 6_TARGETS := ${.TARGETS} 7.export _TARGETS 8.endif 9.if ${_TARGETS:Mbuildworld} 10WITHOUT_STAGING= 11WITHOUT_SYSROOT= 12UPDATE_DEPENDFILE=NO 13NO_AUTO_OBJ= 14.endif 15SRCCONF:= ${.PARSEDIR}/src.conf 16# ensure we are self contained 17__MAKE_CONF:= ${SRCCONF} 18.-include "src.conf" 19 20# some handy macros 21_this = ${.PARSEDIR:tA}/${.PARSEFILE} 22# some useful modifiers 23 24# A useful trick for testing multiple :M's against something 25# :L says to use the variable's name as its value - ie. literal 26# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}} 27M_ListToMatch = L:@m@$${V:M$$m}@ 28# match against our initial targets (see above) 29M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,} 30 31# turn a list into a set of :N modifiers 32# NskipFoo = ${Foo:${M_ListToSkip}} 33M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N, 34 35# type should be a builtin in any sh since about 1980, 36# AUTOCONF := ${autoconf:L:${M_whence}} 37M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g 38M_whence = ${M_type}:M/*:[1] 39 40# convert a path to a valid shell variable 41M_P2V = tu:C,[./-],_,g 42 43# absoulte path to what we are reading. 44_PARSEDIR = ${.PARSEDIR:tA} 45 46.if !empty(SB) 47SB_SRC ?= ${SB}/src 48SB_OBJROOT ?= ${SB}/obj/ 49# this is what we use below 50SRCTOP ?= ${SB_SRC} 51OBJROOT ?= ${SB_OBJROOT} 52.endif 53 54.if empty(SRCTOP) 55SRCTOP := ${_PARSEDIR:H:H} 56OBJROOT ?= ${SRCTOP:H}/obj/ 57OBJROOT := ${OBJROOT} 58.endif 59.export OBJROOT SRCTOP 60 61# we need HOST_TARGET etc below. 62.include <host-target.mk> 63 64# from src/Makefile (for universe) 65TARGET_ARCHES_arm?= arm armeb armv6 armv6eb 66TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 67TARGET_ARCHES_powerpc?= powerpc powerpc64 68TARGET_ARCHES_pc98?= i386 69 70# some corner cases 71CSU_DIR.i386 = csu/i386-elf 72BOOT_MACHINE_DIR.amd64 = boot/i386 73MACHINE_ARCH.host = ${_HOST_ARCH} 74 75# the list of machines we support 76ALL_MACHINE_LIST?= amd64 arm i386 ia64 mips pc98 powerpc sparc64 77.for m in ${ALL_MACHINE_LIST:O:u} 78MACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m} 79MACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]} 80BOOT_MACHINE_DIR.$m ?= boot/$m 81.endfor 82.ifndef _TARGET_SPEC 83.if empty(MACHINE_ARCH) 84.if !empty(TARGET_ARCH) 85MACHINE_ARCH= ${TARGET_ARCH} 86.else 87MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}} 88.endif 89.endif 90MACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}} 91MACHINE_ARCH:= ${MACHINE_ARCH} 92.else 93# we got here via dirdeps 94MACHINE_ARCH:= ${MACHINE_ARCH.${MACHINE}} 95.endif 96 97.if ${.MAKE.LEVEL} == 0 98# 1st time only 99.-include <sys.env.mk> 100.if !empty(OBJROOT) 101.if ${OBJROOT:M*/} != "" 102OBJROOT:= ${OBJROOT:tA}/ 103.else 104OBJROOT:= ${OBJROOT:H:tA}/${OBJROOT:T} 105.endif 106.export OBJROOT 107.endif 108.endif 109 110# now because for universe we want to potentially 111# build for multiple MACHINE_ARCH per MACHINE 112# we need more than MACHINE in TARGET_SPEC 113TARGET_SPEC_VARS= MACHINE MACHINE_ARCH 114# see dirdeps.mk 115.if ${TARGET_SPEC:Uno:M*,*} != "" 116_tspec := ${TARGET_SPEC:S/,/ /g} 117MACHINE := ${_tspec:[1]} 118MACHINE_ARCH := ${_tspec:[2]} 119# etc. 120# We need to stop that TARGET_SPEC affecting any submakes 121# and deal with MACHINE=${TARGET_SPEC} in the environment. 122TARGET_SPEC= 123# export but do not track 124.export-env TARGET_SPEC 125.export ${TARGET_SPEC_VARS} 126.for v in ${TARGET_SPEC_VARS:O:u} 127.if empty($v) 128.undef $v 129.endif 130.endfor 131.endif 132# make sure we know what TARGET_SPEC is 133# as we may need it to find Makefile.depend* 134TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} 135 136# to be consistent with src/Makefile just concatenate with '.'s 137TARGET_OBJ_SPEC:= ${TARGET_SPEC:S;,;.;g} 138OBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC} 139 140.if !empty(SRCTOP) 141.if ${.CURDIR} == ${SRCTOP} 142RELDIR = . 143.elif ${.CURDIR:M${SRCTOP}/*} 144RELDIR := ${.CURDIR:S,${SRCTOP}/,,} 145.endif 146.endif 147 148HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET} 149 150.if ${OBJTOP} == ${HOST_OBJTOP} || ${REQUESTED_MACHINE:U${MACHINE}} == "host" 151MACHINE= host 152.if ${TARGET_MACHINE:Uno} == ${HOST_TARGET} 153# not what we want 154TARGET_MACHINE= host 155.endif 156.endif 157.if ${MACHINE} == "host" 158OBJTOP := ${HOST_OBJTOP} 159.endif 160 161# if you want objdirs make them automatic 162# we need .OBJDIR made before we start populating .PATH 163.if ${MKOBJDIRS:Uno} == "auto" || defined(WITH_AUTO_OBJ) 164WITH_AUTO_OBJ= yes 165MKOBJDIRS=auto 166.include <auto.obj.mk> 167.endif 168 169# the logic in bsd.own.mk forces this dance 170.ifndef WITHOUT_META_MODE 171WITH_META_MODE= yes 172 173.ifndef WITHOUT_SYSROOT 174WITH_SYSROOT= yes 175.endif 176.ifndef WITHOUT_STAGING 177WITH_STAGING= yes 178.ifndef WITHOUT_STAGING_PROG 179WITH_STAGING_PROG= yes 180.endif 181.endif 182 183PYTHON ?= /usr/local/bin/python 184 185.if ${.MAKE.LEVEL} == 0 186# just in case -m, MAKESYSPATH or our default has .../ 187# export a sanitised version... 188# first any -m* from command line, 189# then any MAKESYSPATH and finally ${.PARSEDIR} 190_makesyspath:= ${.MAKEFLAGS:tW:S/ -m / -m/g:tw:M-m*:S,^-m,,} \ 191 ${MAKESYSPATH:U} \ 192 ${.PARSEDIR} 193# replace .../.* with ${.PARSEDIR}, not perfect but pretty close 194MAKESYSPATH:= ${_makesyspath:S,:, ,g:C,^\.\.\./.*,${.PARSEDIR},:u:ts:} 195.export MAKESYSPATH 196 197# this works best if share/mk is ready for it. 198BUILD_AT_LEVEL0= no 199# By default only MACHINE0 updates dependencies 200# see local.autodep.mk 201MACHINE0 := ${MACHINE} 202.export MACHINE0 203.export PYTHON 204.endif 205 206# we want to end up with a singe stage tree for all machines 207.ifndef WITHOUT_STAGING 208.if empty(STAGE_ROOT) 209STAGE_ROOT?= ${OBJROOT}stage 210.export STAGE_ROOT 211.endif 212.endif 213 214.if !empty(STAGE_ROOT) && !defined(WITHOUT_STAGING) 215.if ${MACHINE} == "host" 216STAGE_MACHINE= ${HOST_TARGET} 217.else 218STAGE_MACHINE:= ${TARGET_OBJ_SPEC} 219.endif 220STAGE_OBJTOP:= ${STAGE_ROOT}/${STAGE_MACHINE} 221STAGE_COMMON_OBJTOP:= ${STAGE_ROOT}/common 222STAGE_HOST_OBJTOP:= ${STAGE_ROOT}/${HOST_TARGET} 223 224STAGE_LIBDIR= ${STAGE_OBJTOP}${_LIBDIR:U${LIBDIR:U/lib}} 225# this is not the same as INCLUDEDIR 226STAGE_INCSDIR= ${STAGE_OBJTOP}${INCSDIR:U/include} 227# the target is usually an absolute path 228STAGE_SYMLINKS_DIR= ${STAGE_OBJTOP} 229 230.if ${MACHINE} == "host" && defined(EARLY_BUILD) 231# we literally want to build with host cc and includes 232.else 233.ifdef WITH_SYSROOT 234SYSROOT?= ${STAGE_OBJTOP}/ 235.endif 236LDFLAGS_LAST+= -Wl,-rpath-link -Wl,${STAGE_LIBDIR} 237STAGED_INCLUDE_DIR= ${STAGE_OBJTOP}/usr/include 238.endif 239.endif # EARLY_BUILD for host 240 241# this is sufficient for most of the tree. 242.MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX} 243 244# but if we have a machine qualified file it should be used in preference 245.MAKE.DEPENDFILE_PREFERENCE = \ 246 ${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \ 247 ${.MAKE.DEPENDFILE_PREFIX} 248 249.undef .MAKE.DEPENDFILE 250 251.include "sys.dependfile.mk" 252 253.include "meta.sys.mk" 254 255.if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host" 256# we can use this but should not update it. 257UPDATE_DEPENDFILE= NO 258.endif 259 260.MAKE.META.BAILIWICK = ${SB} ${OBJROOT} ${STAGE_ROOT} 261 262CSU_DIR.i386 = csu/i386-elf 263CSU_DIR.${MACHINE_ARCH} ?= csu/${MACHINE_ARCH} 264CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}} 265 266.endif # meta mode 267 268# ensure we have a value 269.MAKE.MODE ?= normal 270 271MAKE_PRINT_VAR_ON_ERROR+= \ 272 .CURDIR \ 273 .MAKE \ 274 .OBJDIR \ 275 .TARGETS \ 276 DESTDIR \ 277 LD_LIBRARY_PATH \ 278 MACHINE \ 279 MACHINE_ARCH \ 280 MAKEOBJDIRPREFIX \ 281 MAKESYSPATH \ 282 MAKE_VERSION\ 283 OBJTOP \ 284 ${MAKE_PRINT_VAR_ON_ERROR_XTRAS} 285 286.if ${.MAKE.LEVEL} > 0 287MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH 288.endif 289 290 291# these are handy 292# we can use this for a cheap timestamp at the start of a target's script, 293# but not at the end - since make will expand both at the same time. 294AnEmptyVar= 295TIME_STAMP_FMT = @ %s [%Y-%m-%d %T] 296TIME_STAMP = ${TIME_STAMP_FMT:localtime} 297# this will produce the same output but as of when date(1) is run. 298TIME_STAMP_DATE = `date '+${TIME_STAMP_FMT}'` 299TIME_STAMP_END?= ${TIME_STAMP_DATE} 300 301.ifdef WITH_TIMESTAMPS 302TRACER= ${TIME_STAMP} ${AnEmptyVar} 303.endif 304 305# toolchains can be a pain - especially bootstrappping them 306.if ${MACHINE} == "host" 307MK_SHARED_TOOLCHAIN= no 308.endif 309.ifdef WITH_TOOLSDIR 310TOOLSDIR?= ${HOST_OBJTOP}/tools 311.elif defined(STAGE_HOST_OBJTOP) && exists(${STAGE_HOST_OBJTOP}/usr/bin) 312TOOLSDIR?= ${STAGE_HOST_OBJTOP} 313.endif 314.if ${.MAKE.LEVEL} == 0 && exists(${TOOLSDIR}/usr/bin) 315PATH:= ${PATH:S,:, ,g:@d@${exists(${TOOLSDIR}$d):?${TOOLSDIR}$d:}@:ts:}:${PATH} 316.export PATH 317.if exists(${TOOLSDIR}/usr/bin/cc) 318HOST_CC?= ${TOOLSDIR}/usr/bin/cc 319.export HOST_CC 320.endif 321.endif 322 323.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE} 324# cross-building 325.if !defined(FREEBSD_REVISION) 326FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh 327.export FREEBSD_REVISION 328.endif 329CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION} 330CFLAGS+= ${CROSS_TARGET_FLAGS} 331ACFLAGS+= ${CROSS_TARGET_FLAGS} 332LDFLAGS+= -Wl,-m -Wl,elf_${MACHINE_ARCH}_fbsd 333.endif 334 335.endif # bmake 336