2012-08-22 19:25:57 +00:00
|
|
|
WITH_INSTALL_AS_USER= yes
|
|
|
|
|
|
|
|
.if defined(.PARSEDIR) # bmake
|
2014-08-19 06:50:54 +00:00
|
|
|
.if !defined(_TARGETS)
|
|
|
|
# some things we do only once
|
|
|
|
_TARGETS := ${.TARGETS}
|
|
|
|
.export _TARGETS
|
|
|
|
.endif
|
|
|
|
.if ${_TARGETS:Mbuildworld}
|
|
|
|
WITHOUT_STAGING=
|
|
|
|
WITHOUT_SYSROOT=
|
|
|
|
UPDATE_DEPENDFILE=NO
|
|
|
|
NO_AUTO_OBJ=
|
|
|
|
.endif
|
2014-05-05 18:15:18 +00:00
|
|
|
SRCCONF:= ${.PARSEDIR}/src.conf
|
|
|
|
# ensure we are self contained
|
|
|
|
__MAKE_CONF:= ${SRCCONF}
|
2014-05-16 14:58:48 +00:00
|
|
|
.-include "src.conf"
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# some handy macros
|
|
|
|
_this = ${.PARSEDIR:tA}/${.PARSEFILE}
|
|
|
|
# some useful modifiers
|
|
|
|
|
|
|
|
# A useful trick for testing multiple :M's against something
|
|
|
|
# :L says to use the variable's name as its value - ie. literal
|
|
|
|
# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
|
|
|
|
M_ListToMatch = L:@m@$${V:M$$m}@
|
|
|
|
# match against our initial targets (see above)
|
|
|
|
M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
|
|
|
|
|
|
|
|
# turn a list into a set of :N modifiers
|
|
|
|
# NskipFoo = ${Foo:${M_ListToSkip}}
|
|
|
|
M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
|
|
|
|
|
|
|
|
# type should be a builtin in any sh since about 1980,
|
|
|
|
# AUTOCONF := ${autoconf:L:${M_whence}}
|
|
|
|
M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g
|
2014-05-10 00:23:12 +00:00
|
|
|
M_whence = ${M_type}:M/*:[1]
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# convert a path to a valid shell variable
|
|
|
|
M_P2V = tu:C,[./-],_,g
|
|
|
|
|
|
|
|
# absoulte path to what we are reading.
|
2013-05-11 01:03:29 +00:00
|
|
|
_PARSEDIR = ${.PARSEDIR:tA}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
.if !empty(SB)
|
|
|
|
SB_SRC ?= ${SB}/src
|
2013-05-11 01:03:29 +00:00
|
|
|
SB_OBJROOT ?= ${SB}/obj/
|
2012-08-22 19:25:57 +00:00
|
|
|
# this is what we use below
|
|
|
|
SRCTOP ?= ${SB_SRC}
|
|
|
|
OBJROOT ?= ${SB_OBJROOT}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if empty(SRCTOP)
|
|
|
|
SRCTOP := ${_PARSEDIR:H:H}
|
|
|
|
OBJROOT ?= ${SRCTOP:H}/obj/
|
2014-05-16 14:58:48 +00:00
|
|
|
OBJROOT := ${OBJROOT}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
2014-05-16 14:58:48 +00:00
|
|
|
.export OBJROOT SRCTOP
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# we need HOST_TARGET etc below.
|
|
|
|
.include <host-target.mk>
|
|
|
|
|
2013-05-11 01:03:29 +00:00
|
|
|
# from src/Makefile (for universe)
|
|
|
|
TARGET_ARCHES_arm?= arm armeb armv6 armv6eb
|
|
|
|
TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32
|
|
|
|
TARGET_ARCHES_powerpc?= powerpc powerpc64
|
|
|
|
TARGET_ARCHES_pc98?= i386
|
|
|
|
|
2013-10-12 23:46:41 +00:00
|
|
|
# some corner cases
|
|
|
|
CSU_DIR.i386 = csu/i386-elf
|
|
|
|
BOOT_MACHINE_DIR.amd64 = boot/i386
|
|
|
|
MACHINE_ARCH.host = ${_HOST_ARCH}
|
|
|
|
|
2013-05-11 01:03:29 +00:00
|
|
|
# the list of machines we support
|
|
|
|
ALL_MACHINE_LIST?= amd64 arm i386 ia64 mips pc98 powerpc sparc64
|
|
|
|
.for m in ${ALL_MACHINE_LIST:O:u}
|
|
|
|
MACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m}
|
|
|
|
MACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]}
|
2013-10-12 23:46:41 +00:00
|
|
|
BOOT_MACHINE_DIR.$m ?= boot/$m
|
2013-05-11 01:03:29 +00:00
|
|
|
.endfor
|
2013-10-16 16:05:12 +00:00
|
|
|
.ifndef _TARGET_SPEC
|
|
|
|
.if empty(MACHINE_ARCH)
|
|
|
|
.if !empty(TARGET_ARCH)
|
|
|
|
MACHINE_ARCH= ${TARGET_ARCH}
|
|
|
|
.else
|
|
|
|
MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
MACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}}
|
|
|
|
MACHINE_ARCH:= ${MACHINE_ARCH}
|
|
|
|
.else
|
|
|
|
# we got here via dirdeps
|
|
|
|
MACHINE_ARCH:= ${MACHINE_ARCH.${MACHINE}}
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2014-08-19 06:50:54 +00:00
|
|
|
.if ${.MAKE.LEVEL} == 0
|
|
|
|
# 1st time only
|
2012-08-22 19:25:57 +00:00
|
|
|
.-include <sys.env.mk>
|
|
|
|
.if !empty(OBJROOT)
|
|
|
|
.if ${OBJROOT:M*/} != ""
|
|
|
|
OBJROOT:= ${OBJROOT:tA}/
|
|
|
|
.else
|
|
|
|
OBJROOT:= ${OBJROOT:H:tA}/${OBJROOT:T}
|
|
|
|
.endif
|
|
|
|
.export OBJROOT
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2013-05-11 01:03:29 +00:00
|
|
|
# now because for universe we want to potentially
|
|
|
|
# build for multiple MACHINE_ARCH per MACHINE
|
|
|
|
# we need more than MACHINE in TARGET_SPEC
|
|
|
|
TARGET_SPEC_VARS= MACHINE MACHINE_ARCH
|
|
|
|
# see dirdeps.mk
|
|
|
|
.if ${TARGET_SPEC:Uno:M*,*} != ""
|
|
|
|
_tspec := ${TARGET_SPEC:S/,/ /g}
|
|
|
|
MACHINE := ${_tspec:[1]}
|
|
|
|
MACHINE_ARCH := ${_tspec:[2]}
|
|
|
|
# etc.
|
|
|
|
# We need to stop that TARGET_SPEC affecting any submakes
|
|
|
|
# and deal with MACHINE=${TARGET_SPEC} in the environment.
|
|
|
|
TARGET_SPEC=
|
|
|
|
# export but do not track
|
|
|
|
.export-env TARGET_SPEC
|
|
|
|
.export ${TARGET_SPEC_VARS}
|
|
|
|
.for v in ${TARGET_SPEC_VARS:O:u}
|
|
|
|
.if empty($v)
|
|
|
|
.undef $v
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
# make sure we know what TARGET_SPEC is
|
|
|
|
# as we may need it to find Makefile.depend*
|
|
|
|
TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
|
|
|
|
|
|
|
|
# to be consistent with src/Makefile just concatenate with '.'s
|
|
|
|
TARGET_OBJ_SPEC:= ${TARGET_SPEC:S;,;.;g}
|
|
|
|
OBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC}
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.if !empty(SRCTOP)
|
|
|
|
.if ${.CURDIR} == ${SRCTOP}
|
|
|
|
RELDIR = .
|
|
|
|
.elif ${.CURDIR:M${SRCTOP}/*}
|
|
|
|
RELDIR := ${.CURDIR:S,${SRCTOP}/,,}
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET}
|
|
|
|
|
|
|
|
.if ${OBJTOP} == ${HOST_OBJTOP} || ${REQUESTED_MACHINE:U${MACHINE}} == "host"
|
|
|
|
MACHINE= host
|
2013-03-12 17:21:03 +00:00
|
|
|
.if ${TARGET_MACHINE:Uno} == ${HOST_TARGET}
|
|
|
|
# not what we want
|
|
|
|
TARGET_MACHINE= host
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
.if ${MACHINE} == "host"
|
|
|
|
OBJTOP := ${HOST_OBJTOP}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# if you want objdirs make them automatic
|
2013-03-17 01:53:47 +00:00
|
|
|
# we need .OBJDIR made before we start populating .PATH
|
|
|
|
.if ${MKOBJDIRS:Uno} == "auto" || defined(WITH_AUTO_OBJ)
|
2012-08-22 19:25:57 +00:00
|
|
|
WITH_AUTO_OBJ= yes
|
2013-03-17 01:53:47 +00:00
|
|
|
MKOBJDIRS=auto
|
2012-08-22 19:25:57 +00:00
|
|
|
.include <auto.obj.mk>
|
|
|
|
.endif
|
|
|
|
|
2013-01-29 00:11:21 +00:00
|
|
|
# the logic in bsd.own.mk forces this dance
|
2012-08-22 19:25:57 +00:00
|
|
|
.ifndef WITHOUT_META_MODE
|
|
|
|
WITH_META_MODE= yes
|
|
|
|
|
2014-08-19 06:50:54 +00:00
|
|
|
.ifndef WITHOUT_SYSROOT
|
|
|
|
WITH_SYSROOT= yes
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.ifndef WITHOUT_STAGING
|
|
|
|
WITH_STAGING= yes
|
2013-01-29 00:11:21 +00:00
|
|
|
.ifndef WITHOUT_STAGING_PROG
|
|
|
|
WITH_STAGING_PROG= yes
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
PYTHON ?= /usr/local/bin/python
|
|
|
|
|
|
|
|
.if ${.MAKE.LEVEL} == 0
|
2014-06-25 00:19:58 +00:00
|
|
|
# just in case -m, MAKESYSPATH or our default has .../
|
|
|
|
# export a sanitised version...
|
|
|
|
# first any -m* from command line,
|
|
|
|
# then any MAKESYSPATH and finally ${.PARSEDIR}
|
|
|
|
_makesyspath:= ${.MAKEFLAGS:tW:S/ -m / -m/g:tw:M-m*:S,^-m,,} \
|
|
|
|
${MAKESYSPATH:U} \
|
|
|
|
${.PARSEDIR}
|
|
|
|
# replace .../.* with ${.PARSEDIR}, not perfect but pretty close
|
|
|
|
MAKESYSPATH:= ${_makesyspath:S,:, ,g:C,^\.\.\./.*,${.PARSEDIR},:u:ts:}
|
2013-02-16 01:19:18 +00:00
|
|
|
.export MAKESYSPATH
|
2014-06-25 00:19:58 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
# this works best if share/mk is ready for it.
|
|
|
|
BUILD_AT_LEVEL0= no
|
|
|
|
# By default only MACHINE0 updates dependencies
|
|
|
|
# see local.autodep.mk
|
|
|
|
MACHINE0 := ${MACHINE}
|
|
|
|
.export MACHINE0
|
|
|
|
.export PYTHON
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# we want to end up with a singe stage tree for all machines
|
|
|
|
.ifndef WITHOUT_STAGING
|
|
|
|
.if empty(STAGE_ROOT)
|
|
|
|
STAGE_ROOT?= ${OBJROOT}stage
|
|
|
|
.export STAGE_ROOT
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2014-08-19 06:50:54 +00:00
|
|
|
.if !empty(STAGE_ROOT) && !defined(WITHOUT_STAGING)
|
2012-08-22 19:25:57 +00:00
|
|
|
.if ${MACHINE} == "host"
|
|
|
|
STAGE_MACHINE= ${HOST_TARGET}
|
|
|
|
.else
|
2013-05-11 01:03:29 +00:00
|
|
|
STAGE_MACHINE:= ${TARGET_OBJ_SPEC}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
2013-05-11 01:03:29 +00:00
|
|
|
STAGE_OBJTOP:= ${STAGE_ROOT}/${STAGE_MACHINE}
|
|
|
|
STAGE_COMMON_OBJTOP:= ${STAGE_ROOT}/common
|
|
|
|
STAGE_HOST_OBJTOP:= ${STAGE_ROOT}/${HOST_TARGET}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2014-05-16 14:58:48 +00:00
|
|
|
STAGE_LIBDIR= ${STAGE_OBJTOP}${_LIBDIR:U${LIBDIR:U/lib}}
|
2012-08-22 19:25:57 +00:00
|
|
|
# this is not the same as INCLUDEDIR
|
|
|
|
STAGE_INCSDIR= ${STAGE_OBJTOP}${INCSDIR:U/include}
|
2013-01-29 00:11:21 +00:00
|
|
|
# the target is usually an absolute path
|
|
|
|
STAGE_SYMLINKS_DIR= ${STAGE_OBJTOP}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2014-05-10 00:23:12 +00:00
|
|
|
.if ${MACHINE} == "host" && defined(EARLY_BUILD)
|
|
|
|
# we literally want to build with host cc and includes
|
|
|
|
.else
|
2014-05-16 14:58:48 +00:00
|
|
|
.ifdef WITH_SYSROOT
|
|
|
|
SYSROOT?= ${STAGE_OBJTOP}/
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
2014-07-25 20:44:04 +00:00
|
|
|
LDFLAGS_LAST+= -Wl,-rpath-link -Wl,${STAGE_LIBDIR}
|
2013-04-19 18:45:03 +00:00
|
|
|
STAGED_INCLUDE_DIR= ${STAGE_OBJTOP}/usr/include
|
2013-10-16 16:05:12 +00:00
|
|
|
.endif
|
2014-05-10 00:23:12 +00:00
|
|
|
.endif # EARLY_BUILD for host
|
2013-10-16 16:05:12 +00:00
|
|
|
|
2013-03-08 01:51:32 +00:00
|
|
|
# this is sufficient for most of the tree.
|
|
|
|
.MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX}
|
|
|
|
|
|
|
|
# but if we have a machine qualified file it should be used in preference
|
2012-08-22 19:25:57 +00:00
|
|
|
.MAKE.DEPENDFILE_PREFERENCE = \
|
2013-03-08 01:51:32 +00:00
|
|
|
${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
|
|
|
|
${.MAKE.DEPENDFILE_PREFIX}
|
|
|
|
|
|
|
|
.undef .MAKE.DEPENDFILE
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
.include "sys.dependfile.mk"
|
|
|
|
|
2014-08-19 06:50:54 +00:00
|
|
|
.include "meta.sys.mk"
|
|
|
|
|
2013-03-17 03:09:08 +00:00
|
|
|
.if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host"
|
|
|
|
# we can use this but should not update it.
|
|
|
|
UPDATE_DEPENDFILE= NO
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.MAKE.META.BAILIWICK = ${SB} ${OBJROOT} ${STAGE_ROOT}
|
|
|
|
|
|
|
|
CSU_DIR.i386 = csu/i386-elf
|
|
|
|
CSU_DIR.${MACHINE_ARCH} ?= csu/${MACHINE_ARCH}
|
|
|
|
CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}}
|
|
|
|
|
2013-06-04 15:25:57 +00:00
|
|
|
.endif # meta mode
|
|
|
|
|
|
|
|
# ensure we have a value
|
|
|
|
.MAKE.MODE ?= normal
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
MAKE_PRINT_VAR_ON_ERROR+= \
|
|
|
|
.CURDIR \
|
|
|
|
.MAKE \
|
|
|
|
.OBJDIR \
|
|
|
|
.TARGETS \
|
|
|
|
DESTDIR \
|
|
|
|
LD_LIBRARY_PATH \
|
|
|
|
MACHINE \
|
|
|
|
MACHINE_ARCH \
|
|
|
|
MAKEOBJDIRPREFIX \
|
2012-11-04 02:52:03 +00:00
|
|
|
MAKESYSPATH \
|
2012-08-22 19:25:57 +00:00
|
|
|
MAKE_VERSION\
|
|
|
|
OBJTOP \
|
|
|
|
${MAKE_PRINT_VAR_ON_ERROR_XTRAS}
|
|
|
|
|
2013-02-16 01:19:18 +00:00
|
|
|
.if ${.MAKE.LEVEL} > 0
|
|
|
|
MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
2012-11-09 05:43:15 +00:00
|
|
|
# these are handy
|
|
|
|
# we can use this for a cheap timestamp at the start of a target's script,
|
|
|
|
# but not at the end - since make will expand both at the same time.
|
2014-05-10 00:23:12 +00:00
|
|
|
AnEmptyVar=
|
2012-11-09 05:43:15 +00:00
|
|
|
TIME_STAMP_FMT = @ %s [%Y-%m-%d %T]
|
|
|
|
TIME_STAMP = ${TIME_STAMP_FMT:localtime}
|
|
|
|
# this will produce the same output but as of when date(1) is run.
|
|
|
|
TIME_STAMP_DATE = `date '+${TIME_STAMP_FMT}'`
|
|
|
|
TIME_STAMP_END?= ${TIME_STAMP_DATE}
|
|
|
|
|
2014-05-10 00:23:12 +00:00
|
|
|
.ifdef WITH_TIMESTAMPS
|
|
|
|
TRACER= ${TIME_STAMP} ${AnEmptyVar}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# toolchains can be a pain - especially bootstrappping them
|
2014-05-16 14:58:48 +00:00
|
|
|
.if ${MACHINE} == "host"
|
|
|
|
MK_SHARED_TOOLCHAIN= no
|
|
|
|
.endif
|
2014-05-10 00:23:12 +00:00
|
|
|
.ifdef WITH_TOOLSDIR
|
|
|
|
TOOLSDIR?= ${HOST_OBJTOP}/tools
|
|
|
|
.elif defined(STAGE_HOST_OBJTOP) && exists(${STAGE_HOST_OBJTOP}/usr/bin)
|
|
|
|
TOOLSDIR?= ${STAGE_HOST_OBJTOP}
|
|
|
|
.endif
|
|
|
|
.if ${.MAKE.LEVEL} == 0 && exists(${TOOLSDIR}/usr/bin)
|
|
|
|
PATH:= ${PATH:S,:, ,g:@d@${exists(${TOOLSDIR}$d):?${TOOLSDIR}$d:}@:ts:}:${PATH}
|
|
|
|
.export PATH
|
2014-05-16 14:58:48 +00:00
|
|
|
.if exists(${TOOLSDIR}/usr/bin/cc)
|
|
|
|
HOST_CC?= ${TOOLSDIR}/usr/bin/cc
|
|
|
|
.export HOST_CC
|
|
|
|
.endif
|
2014-05-10 00:23:12 +00:00
|
|
|
.endif
|
|
|
|
|
2014-07-25 20:44:04 +00:00
|
|
|
.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
|
|
|
|
# cross-building
|
|
|
|
.if !defined(FREEBSD_REVISION)
|
|
|
|
FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh
|
|
|
|
.export FREEBSD_REVISION
|
|
|
|
.endif
|
|
|
|
CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION}
|
|
|
|
CFLAGS+= ${CROSS_TARGET_FLAGS}
|
|
|
|
ACFLAGS+= ${CROSS_TARGET_FLAGS}
|
|
|
|
LDFLAGS+= -Wl,-m -Wl,elf_${MACHINE_ARCH}_fbsd
|
|
|
|
.endif
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif # bmake
|