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