]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/local.meta.sys.mk
Remove spurious newline
[FreeBSD/FreeBSD.git] / share / mk / local.meta.sys.mk
1 # $FreeBSD$
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
8 MK_INSTALL_AS_USER= yes
9
10 .if !defined(HOST_TARGET) || !defined(HOST_MACHINE)
11 # we need HOST_TARGET etc below.
12 .include <host-target.mk>
13 .export HOST_TARGET
14 .endif
15
16 # from src/Makefile (for universe)
17 TARGET_ARCHES_arm?=     arm armv6 armv7
18 TARGET_ARCHES_arm64?=   aarch64
19 TARGET_ARCHES_mips?=    mipsel mips mips64el mips64 mipsn32 mipsn32el
20 TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpcspe
21 TARGET_ARCHES_riscv?=   riscv64 riscv64sf
22
23 # some corner cases
24 BOOT_MACHINE_DIR.amd64 = boot/i386
25 MACHINE_ARCH.host = ${_HOST_ARCH}
26
27 # the list of machines we support
28 ALL_MACHINE_LIST?= amd64 arm arm64 i386 mips powerpc riscv sparc64
29 .for m in ${ALL_MACHINE_LIST:O:u}
30 MACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m}
31 MACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]}
32 BOOT_MACHINE_DIR.$m ?= boot/$m
33 .endfor
34
35 .ifndef _TARGET_SPEC
36 .if empty(MACHINE_ARCH)
37 .if !empty(TARGET_ARCH)
38 MACHINE_ARCH= ${TARGET_ARCH}
39 .else
40 MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
41 .endif
42 .endif
43 MACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}}
44 MACHINE_ARCH:= ${MACHINE_ARCH}
45 .else
46 # we got here via dirdeps
47 MACHINE_ARCH:= ${MACHINE_ARCH.${MACHINE}}
48 .endif
49
50 # now because for universe we want to potentially
51 # build for multiple MACHINE_ARCH per MACHINE
52 # we need more than MACHINE in TARGET_SPEC
53 TARGET_SPEC_VARS= MACHINE MACHINE_ARCH
54 # see dirdeps.mk
55 .if ${TARGET_SPEC:Uno:M*,*} != ""
56 _tspec := ${TARGET_SPEC:S/,/ /g}
57 MACHINE := ${_tspec:[1]}
58 MACHINE_ARCH := ${_tspec:[2]}
59 # etc.
60 # We need to stop that TARGET_SPEC affecting any submakes
61 # and deal with MACHINE=${TARGET_SPEC} in the environment.
62 TARGET_SPEC=
63 # export but do not track
64 .export-env TARGET_SPEC 
65 .export ${TARGET_SPEC_VARS}
66 .for v in ${TARGET_SPEC_VARS:O:u}
67 .if empty($v)
68 .undef $v
69 .endif
70 .endfor
71 .endif
72 # make sure we know what TARGET_SPEC is
73 # as we may need it to find Makefile.depend*
74 TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
75
76 # to be consistent with src/Makefile just concatenate with '.'s
77 TARGET_OBJ_SPEC:= ${TARGET_SPEC:S;,;.;g}
78 OBJTOP:= ${OBJROOT}${TARGET_OBJ_SPEC}
79
80 .if defined(MAKEOBJDIR)
81 .if ${MAKEOBJDIR:M/*} == ""
82 .error Cannot use MAKEOBJDIR=${MAKEOBJDIR}${.newline}Unset MAKEOBJDIR to get default:  MAKEOBJDIR='${_default_makeobjdir}'
83 .endif
84 .endif
85
86 HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET}
87
88 .if ${OBJTOP} == ${HOST_OBJTOP} || ${REQUESTED_MACHINE:U${MACHINE}} == "host"
89 MACHINE= host
90 .if ${TARGET_MACHINE:Uno} == ${HOST_TARGET}
91 # not what we want
92 TARGET_MACHINE= host
93 .endif
94 .endif
95 .if ${MACHINE} == "host"
96 OBJTOP := ${HOST_OBJTOP}
97 .endif
98
99 .if ${.MAKE.LEVEL} == 0
100 PYTHON ?= /usr/local/bin/python
101 .export PYTHON
102 # this works best if share/mk is ready for it.
103 BUILD_AT_LEVEL0= no
104 # _SKIP_BUILD is not 100% as it requires wrapping all 'all:' targets to avoid
105 # building in MAKELEVEL0.  Just prohibit 'all' entirely in this case to avoid
106 # problems.
107 .if ${MK_DIRDEPS_BUILD} == "yes" && \
108     ${.MAKE.LEVEL} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
109 .MAIN: dirdeps
110 .if make(all)
111 .error DIRDEPS_BUILD: Please run '${MAKE}' instead of '${MAKE} all'.
112 .endif
113 .endif
114 .endif
115
116 # we want to end up with a singe stage tree for all machines
117 .if ${MK_STAGING} == "yes"
118 .if empty(STAGE_ROOT)
119 STAGE_ROOT?= ${OBJROOT}stage
120 .export STAGE_ROOT
121 .endif
122 .endif
123
124 .if ${MK_STAGING} == "yes"
125 .if ${MACHINE} == "host"
126 STAGE_MACHINE= ${HOST_TARGET}
127 .else
128 STAGE_MACHINE:= ${TARGET_OBJ_SPEC}
129 .endif
130 STAGE_OBJTOP:= ${STAGE_ROOT}/${STAGE_MACHINE}
131 STAGE_COMMON_OBJTOP:= ${STAGE_ROOT}/common
132 STAGE_TARGET_OBJTOP:= ${STAGE_ROOT}/${TARGET_OBJ_SPEC}
133 STAGE_HOST_OBJTOP:= ${STAGE_ROOT}/${HOST_TARGET}
134 # These are exported for hooking in out-of-tree builds.  They will always
135 # be overridden in sub-makes above when building in-tree.
136 .export STAGE_OBJTOP STAGE_TARGET_OBJTOP STAGE_HOST_OBJTOP
137
138 # Use tools/install.sh which can avoid the need for xinstall for simple cases.
139 INSTALL?=       sh ${SRCTOP}/tools/install.sh
140 # This is for stage-install to pickup from the environment.
141 REAL_INSTALL:=  ${INSTALL}
142 .export REAL_INSTALL
143 STAGE_INSTALL=  sh ${.PARSEDIR:tA}/stage-install.sh OBJDIR=${.OBJDIR:tA}
144
145 STAGE_LIBDIR= ${STAGE_OBJTOP}${_LIBDIR:U${LIBDIR:U/lib}}
146 STAGE_INCLUDEDIR= ${STAGE_OBJTOP}${INCLUDEDIR:U/usr/include}
147 # this is not the same as INCLUDEDIR
148 STAGE_INCSDIR= ${STAGE_OBJTOP}${INCSDIR:U/include}
149 # the target is usually an absolute path
150 STAGE_SYMLINKS_DIR= ${STAGE_OBJTOP}
151
152 #LDFLAGS_LAST+= -Wl,-rpath-link,${STAGE_LIBDIR}
153 .if ${MK_SYSROOT} == "yes"
154 SYSROOT?= ${STAGE_OBJTOP}
155 .else
156 LDFLAGS_LAST+= -L${STAGE_LIBDIR}
157 .endif
158
159 .endif                          # MK_STAGING
160
161 .-include "local.toolchain.mk"
162
163 # this is sufficient for most of the tree.
164 .MAKE.DEPENDFILE_DEFAULT = ${.MAKE.DEPENDFILE_PREFIX}
165
166 # but if we have a machine qualified file it should be used in preference
167 .MAKE.DEPENDFILE_PREFERENCE = \
168         ${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
169         ${.MAKE.DEPENDFILE_PREFIX}
170
171 .undef .MAKE.DEPENDFILE
172
173 .include "sys.dependfile.mk"
174
175 .if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host"
176 # we can use this but should not update it.
177 UPDATE_DEPENDFILE= NO
178 .endif
179
180 # define the list of places that contain files we are responsible for
181 .MAKE.META.BAILIWICK = ${SB} ${OBJROOT} ${STAGE_ROOT}
182
183 CSU_DIR.${MACHINE_ARCH} ?= csu/${MACHINE_ARCH}
184 CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}}
185
186 .if !empty(TIME_STAMP)
187 TRACER= ${TIME_STAMP} ${:U}
188 .endif
189 .if !defined(_RECURSING_PROGS) && !defined(_RECURSING_CRUNCH) && \
190     !make(print-dir)
191 WITH_META_STATS= t
192 .endif
193
194 # toolchains can be a pain - especially bootstrappping them
195 .if ${MACHINE} == "host"
196 MK_SHARED_TOOLCHAIN= no
197 .endif
198 TOOLCHAIN_VARS= AS AR CC CLANG_TBLGEN CXX CPP LD NM OBJCOPY RANLIB \
199                 STRINGS SIZE LLVM_TBLGEN
200 _toolchain_bin_CLANG_TBLGEN=    /usr/bin/clang-tblgen
201 _toolchain_bin_LLVM_TBLGEN=     /usr/bin/llvm-tblgen
202 _toolchain_bin_CXX=             /usr/bin/c++
203 .ifdef WITH_TOOLSDIR
204 TOOLSDIR?= ${HOST_OBJTOP}/tools
205 .elif defined(STAGE_HOST_OBJTOP)
206 TOOLSDIR?= ${STAGE_HOST_OBJTOP}
207 .endif
208 # Only define if it exists in case user didn't run bootstrap-tools.  Otherwise
209 # the tool will be built during the build.  Building it assumes it is
210 # TARGET==MACHINE.
211 .if exists(${HOST_OBJTOP}/tools${.CURDIR})
212 BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR}
213 .endif
214
215 # Don't use the bootstrap tools logic on itself.
216 .if ${.TARGETS:Mbootstrap-tools} == "" && \
217     !make(test-system-*) && !make(showconfig) && !make(print-dir) && \
218     !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0
219 .for dir in /sbin /bin /usr/sbin /usr/bin
220 PATH:= ${TOOLSDIR}${dir}:${PATH}
221 .endfor
222 .export PATH
223 # Prefer the TOOLSDIR version of the toolchain if present vs the host version.
224 .for var in ${TOOLCHAIN_VARS}
225 _toolchain_bin.${var}=  ${TOOLSDIR}${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
226 .if exists(${_toolchain_bin.${var}})
227 HOST_${var}?=   ${_toolchain_bin.${var}}
228 .export         HOST_${var}
229 .endif
230 .endfor
231 .endif
232
233 .for var in ${TOOLCHAIN_VARS}
234 HOST_${var}?=   ${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
235 .endfor
236
237 .if ${MACHINE} == "host"
238 .for var in ${TOOLCHAIN_VARS}
239 ${var}=         ${HOST_${var}}
240 .endfor
241 .endif
242
243 .if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
244 # cross-building
245 .if !defined(FREEBSD_REVISION)
246 FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh
247 .export FREEBSD_REVISION
248 .endif
249 CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION}
250 CFLAGS+= ${CROSS_TARGET_FLAGS}
251 ACFLAGS+= ${CROSS_TARGET_FLAGS}
252 LDFLAGS+= -Wl,-m -Wl,elf_${MACHINE_ARCH}_fbsd
253 .endif
254
255 META_MODE+=     missing-meta=yes
256 .if empty(META_MODE:Mnofilemon)
257 META_MODE+=     missing-filemon=yes
258 .endif