local.meta.sys.mk revision 288159
1164032Srwatson# $FreeBSD: head/share/mk/local.meta.sys.mk 288159 2015-09-23 23:30:57Z bdrewery $
2164032Srwatson
3164032Srwatson# local configuration specific to meta mode
4164032Srwatson# XXX some of this should be in meta.sys.mk
5164032Srwatson# we assume that MK_META_MODE=yes
6164032Srwatson
7164032Srwatson# we need this until there is an alternative
8164032SrwatsonMK_INSTALL_AS_USER= yes
9164032Srwatson
10164032Srwatson_default_makeobjdir=$${.CURDIR:S,^$${SRCTOP},$${OBJTOP},}
11164032Srwatson
12164032Srwatson.if empty(OBJROOT) || ${.MAKE.LEVEL} == 0
13164032Srwatson.if defined(MAKEOBJDIRPREFIX)
14164032Srwatson# put things approximately where they want
15164032SrwatsonOBJROOT:=${MAKEOBJDIRPREFIX}${SRCTOP}/
16164032SrwatsonMAKEOBJDIRPREFIX=
17164032Srwatson.export MAKEOBJDIRPREFIX
18164032Srwatson.endif
19164032Srwatson.if empty(MAKEOBJDIR)
20164032Srwatson# OBJTOP set below
21164032SrwatsonMAKEOBJDIR=${_default_makeobjdir}
22164032Srwatson# export but do not track
23164032Srwatson.export-env MAKEOBJDIR
24164032Srwatson# Expand for our own use
25164032SrwatsonMAKEOBJDIR:= ${MAKEOBJDIR}
26164032Srwatson.endif
27164032Srwatson.if !empty(SB)
28164032SrwatsonSB_OBJROOT ?= ${SB}/obj/
29164032Srwatson# this is what we use below
30164032SrwatsonOBJROOT ?= ${SB_OBJROOT}
31164032Srwatson.endif
32164037SruOBJROOT ?= /usr/obj${SRCTOP}/
33164032Srwatson.if ${OBJROOT:M*/} != ""
34164032SrwatsonOBJROOT:= ${OBJROOT:H:tA}/
35164032Srwatson.else
36164032SrwatsonOBJROOT:= ${OBJROOT:H:tA}/${OBJROOT:T}
37164032Srwatson.endif
38164032Srwatson.export OBJROOT SRCTOP
39164032Srwatson
40164032Srwatson# we need HOST_TARGET etc below.
41164032Srwatson.include <host-target.mk>
42164032Srwatson.export HOST_TARGET
43164032Srwatson.endif
44164032Srwatson
45164037Sru# from src/Makefile (for universe)
46164032SrwatsonTARGET_ARCHES_arm?=     arm armeb armv6 armv6hf
47164032SrwatsonTARGET_ARCHES_arm64?=   aarch64
48164037SruTARGET_ARCHES_mips?=    mipsel mips mips64el mips64 mipsn32 mipsn32el
49164032SrwatsonTARGET_ARCHES_powerpc?= powerpc powerpc64
50164037SruTARGET_ARCHES_pc98?=    i386
51183113Sattilio
52164032Srwatson# some corner cases
53164032SrwatsonBOOT_MACHINE_DIR.amd64 = boot/i386
54164032SrwatsonMACHINE_ARCH.host = ${_HOST_ARCH}
55164032Srwatson
56164032Srwatson# the list of machines we support
57164032SrwatsonALL_MACHINE_LIST?= amd64 arm arm64 i386 ia64 mips pc98 powerpc sparc64
58164032Srwatson.for m in ${ALL_MACHINE_LIST:O:u}
59164032SrwatsonMACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m}
60171058SrwatsonMACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]}
61171058SrwatsonBOOT_MACHINE_DIR.$m ?= boot/$m
62171058Srwatson.endfor
63164032Srwatson
64164032Srwatson.ifndef _TARGET_SPEC
65164032Srwatson.if empty(MACHINE_ARCH)
66164037Sru.if !empty(TARGET_ARCH)
67164032SrwatsonMACHINE_ARCH= ${TARGET_ARCH}
68164032Srwatson.else
69164032SrwatsonMACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
70164032Srwatson.endif
71164032Srwatson.endif
72164032SrwatsonMACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}}
73164032SrwatsonMACHINE_ARCH:= ${MACHINE_ARCH}
74164032Srwatson.else
75164032Srwatson# we got here via dirdeps
76164032SrwatsonMACHINE_ARCH:= ${MACHINE_ARCH.${MACHINE}}
77164032Srwatson.endif
78164032Srwatson
79164032Srwatson# now because for universe we want to potentially
80166867Srwatson# build for multiple MACHINE_ARCH per MACHINE
81166867Srwatson# we need more than MACHINE in TARGET_SPEC
82166867SrwatsonTARGET_SPEC_VARS= MACHINE MACHINE_ARCH
83166867Srwatson# see dirdeps.mk
84166867Srwatson.if ${TARGET_SPEC:Uno:M*,*} != ""
85166867Srwatson_tspec := ${TARGET_SPEC:S/,/ /g}
86166867SrwatsonMACHINE := ${_tspec:[1]}
87167574SbruefferMACHINE_ARCH := ${_tspec:[2]}
88164032Srwatson# etc.
89164032Srwatson# We need to stop that TARGET_SPEC affecting any submakes
90164032Srwatson# and deal with MACHINE=${TARGET_SPEC} in the environment.
91164032SrwatsonTARGET_SPEC=
92164032Srwatson# export but do not track
93164032Srwatson.export-env TARGET_SPEC 
94164032Srwatson.export ${TARGET_SPEC_VARS}
95164037Sru.for v in ${TARGET_SPEC_VARS:O:u}
96164032Srwatson.if empty($v)
97164032Srwatson.undef $v
98164037Sru.endif
99164032Srwatson.endfor
100164032Srwatson.endif
101164032Srwatson# make sure we know what TARGET_SPEC is
102164032Srwatson# as we may need it to find Makefile.depend*
103164032SrwatsonTARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
104164032Srwatson
105164032Srwatson# to be consistent with src/Makefile just concatenate with '.'s
106164032SrwatsonTARGET_OBJ_SPEC:= ${TARGET_SPEC:S;,;.;g}
107164032SrwatsonOBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC}
108167574Sbrueffer
109167574Sbrueffer.if defined(MAKEOBJDIR)
110164032Srwatson.if ${MAKEOBJDIR:M*/*} == ""
111165213Smpp.error Cannot use MAKEOBJDIR=${MAKEOBJDIR}${.newline}Unset MAKEOBJDIR to get default:  MAKEOBJDIR='${_default_makeobjdir}'
112164032Srwatson.endif
113164032Srwatson.endif
114164032Srwatson
115164032SrwatsonHOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET}
116164032Srwatson
117164032Srwatson.if ${OBJTOP} == ${HOST_OBJTOP} || ${REQUESTED_MACHINE:U${MACHINE}} == "host"
118164037SruMACHINE= host
119164037Sru.if ${TARGET_MACHINE:Uno} == ${HOST_TARGET}
120164037Sru# not what we want
121164037SruTARGET_MACHINE= host
122164032Srwatson.endif
123.endif
124.if ${MACHINE} == "host"
125OBJTOP := ${HOST_OBJTOP}
126.endif
127
128.if ${.MAKE.LEVEL} == 0
129PYTHON ?= /usr/local/bin/python
130.export PYTHON
131# this works best if share/mk is ready for it.
132BUILD_AT_LEVEL0= no
133
134# we want to end up with a singe stage tree for all machines
135.if ${MK_STAGING} == "yes"
136.if empty(STAGE_ROOT)
137STAGE_ROOT?= ${OBJROOT}stage
138.export STAGE_ROOT
139.endif
140.endif
141.endif
142
143.if ${MK_STAGING} == "yes"
144.if ${MACHINE} == "host"
145STAGE_MACHINE= ${HOST_TARGET}
146.else
147STAGE_MACHINE:= ${TARGET_OBJ_SPEC}
148.endif
149STAGE_OBJTOP:= ${STAGE_ROOT}/${STAGE_MACHINE}
150STAGE_COMMON_OBJTOP:= ${STAGE_ROOT}/common
151STAGE_HOST_OBJTOP:= ${STAGE_ROOT}/${HOST_TARGET}
152
153STAGE_LIBDIR= ${STAGE_OBJTOP}${_LIBDIR:U${LIBDIR:U/lib}}
154STAGE_INCLUDEDIR= ${STAGE_OBJTOP}${INCLUDEDIR:U/usr/include}
155# this is not the same as INCLUDEDIR
156STAGE_INCSDIR= ${STAGE_OBJTOP}${INCSDIR:U/include}
157# the target is usually an absolute path
158STAGE_SYMLINKS_DIR= ${STAGE_OBJTOP}
159
160LDFLAGS_LAST+= -Wl,-rpath-link -Wl,${STAGE_LIBDIR}
161.if ${MK_SYSROOT} == "yes"
162SYSROOT?= ${STAGE_OBJTOP}
163.else
164LDFLAGS_LAST+= -L${STAGE_LIBDIR}
165.endif
166
167.endif				# MK_STAGING
168
169# this is sufficient for most of the tree.
170.MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX}
171
172# but if we have a machine qualified file it should be used in preference
173.MAKE.DEPENDFILE_PREFERENCE = \
174	${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
175	${.MAKE.DEPENDFILE_PREFIX}
176
177.undef .MAKE.DEPENDFILE
178
179.include "sys.dependfile.mk"
180
181.if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host"
182# we can use this but should not update it.
183UPDATE_DEPENDFILE= NO
184.endif
185
186# define the list of places that contain files we are responsible for
187.MAKE.META.BAILIWICK = ${SB} ${OBJROOT} ${STAGE_ROOT}
188
189.if defined(CCACHE_DIR)
190CCACHE_DIR := ${CCACHE_DIR:tA}
191.MAKE.META.IGNORE_PATHS += ${CCACHE_DIR}
192.export CCACHE_DIR
193.endif
194
195CSU_DIR.${MACHINE_ARCH} ?= csu/${MACHINE_ARCH}
196CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}}
197
198.if !empty(TIME_STAMP)
199TRACER= ${TIME_STAMP} ${:U}
200.endif
201
202# toolchains can be a pain - especially bootstrappping them
203.if ${MACHINE} == "host"
204MK_SHARED_TOOLCHAIN= no
205.endif
206.ifdef WITH_TOOLSDIR
207TOOLSDIR?= ${HOST_OBJTOP}/tools
208.elif defined(STAGE_HOST_OBJTOP) && exists(${STAGE_HOST_OBJTOP}/usr/bin)
209TOOLSDIR?= ${STAGE_HOST_OBJTOP}
210.endif
211.if !empty(TOOLSDIR)
212.if ${.MAKE.LEVEL} == 0 && exists(${TOOLSDIR}/usr/bin)
213PATH:= ${PATH:S,:, ,g:@d@${exists(${TOOLSDIR}$d):?${TOOLSDIR}$d:}@:ts:}:${PATH}
214.export PATH
215.if exists(${TOOLSDIR}/usr/bin/cc)
216HOST_CC?= ${TOOLSDIR}/usr/bin/cc
217CC?= ${TOOLSDIR}/usr/bin/cc
218CXX?= ${TOOLSDIR}/usr/bin/c++
219.export HOST_CC CC CXX
220.endif
221.endif
222.endif
223
224.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
225# cross-building
226.if !defined(FREEBSD_REVISION)
227FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh
228.export FREEBSD_REVISION
229.endif
230CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION}
231CFLAGS+= ${CROSS_TARGET_FLAGS}
232ACFLAGS+= ${CROSS_TARGET_FLAGS}
233LDFLAGS+= -Wl,-m -Wl,elf_${MACHINE_ARCH}_fbsd
234.endif
235