xref: /freebsd/share/mk/local.sys.dirdeps.mk (revision a57ca37dd1848cd42844d9082c4a74c2ed57f68a)
1# $FreeBSD$
2
3# local configuration specific to meta mode
4# we assume that MK_DIRDEPS_BUILD=yes
5
6# we need this until there is an alternative
7MK_INSTALL_AS_USER= yes
8
9.-include <site.sys.dirdeps.mk>
10# previously only included for DIRDEPS_BUILD anyway
11.-include <site.meta.sys.mk>
12
13.if ${MK_STAGING} == "yes"
14
15STAGE_TARGET_OBJTOP:= ${STAGE_ROOT}/${TARGET_OBJ_SPEC}
16# These are exported for hooking in out-of-tree builds.  They will always
17# be overridden in sub-makes above when building in-tree.
18.if ${.MAKE.LEVEL} > 0
19.export STAGE_OBJTOP STAGE_TARGET_OBJTOP STAGE_HOST_OBJTOP
20.endif
21
22# Use tools/install.sh which can avoid the need for xinstall for simple cases.
23INSTALL?=	sh ${SRCTOP}/tools/install.sh
24# This is for stage-install to pickup from the environment.
25REAL_INSTALL:=	${INSTALL}
26.export REAL_INSTALL
27STAGE_INSTALL=	sh ${.PARSEDIR:tA}/stage-install.sh OBJDIR=${.OBJDIR:tA}
28
29STAGE_LIBDIR= ${STAGE_OBJTOP}${_LIBDIR:U${LIBDIR:U/lib}}
30STAGE_INCLUDEDIR= ${STAGE_OBJTOP}${INCLUDEDIR:U/usr/include}
31# this is not the same as INCLUDEDIR
32STAGE_INCSDIR= ${STAGE_OBJTOP}${INCSDIR:U/include}
33# the target is usually an absolute path
34STAGE_SYMLINKS_DIR= ${STAGE_OBJTOP}
35
36#LDFLAGS_LAST+= -Wl,-rpath-link,${STAGE_LIBDIR}
37.if ${MK_SYSROOT} == "yes"
38SYSROOT?= ${STAGE_OBJTOP}
39.else
40LDFLAGS_LAST+= -L${STAGE_LIBDIR}
41.endif
42
43.endif				# MK_STAGING
44
45.-include "local.toolchain.mk"
46
47.if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host"
48# we can use this but should not update it.
49UPDATE_DEPENDFILE?= NO
50.endif
51
52# define the list of places that contain files we are responsible for
53.MAKE.META.BAILIWICK = ${SB} ${OBJROOT} ${STAGE_ROOT}
54
55CSU_DIR.${MACHINE_ARCH} ?= csu/${MACHINE_ARCH}
56CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}}
57
58.if !empty(TIME_STAMP)
59TRACER= ${TIME_STAMP} ${:U}
60.endif
61.if !defined(_RECURSING_PROGS) && !defined(_RECURSING_CRUNCH) && \
62    !make(print-dir)
63WITH_META_STATS= t
64.endif
65
66# toolchains can be a pain - especially bootstrappping them
67.if ${MACHINE} == "host"
68MK_SHARED_TOOLCHAIN= no
69.endif
70TOOLCHAIN_VARS=	AS AR CC CLANG_TBLGEN CXX CPP LD NM OBJCOPY RANLIB \
71		STRINGS SIZE LLVM_TBLGEN
72_toolchain_bin_CLANG_TBLGEN=	/usr/bin/clang-tblgen
73_toolchain_bin_LLVM_TBLGEN=	/usr/bin/llvm-tblgen
74_toolchain_bin_CXX=		/usr/bin/c++
75.ifdef WITH_TOOLSDIR
76TOOLSDIR?= ${HOST_OBJTOP}/tools
77.elif defined(STAGE_HOST_OBJTOP)
78TOOLSDIR?= ${STAGE_HOST_OBJTOP}
79.endif
80.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
81# ideally tools needed by makefiles like sh,csh,tinfo
82# would be built in their own directories but for now
83# this works well enough.
84BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR}
85.else
86# Only define if it exists in case user didn't run bootstrap-tools.  Otherwise
87# the tool will be built during the build.  Building it assumes it is
88# TARGET==MACHINE.
89.if exists(${HOST_OBJTOP}/tools${.CURDIR})
90BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR}
91.endif
92.endif
93
94# Don't use the bootstrap tools logic on itself.
95.if ${.TARGETS:Mbootstrap-tools} == "" && \
96    !make(test-system-*) && !make(showconfig) && !make(print-dir) && \
97    !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0
98.for dir in /sbin /bin /usr/sbin /usr/bin
99PATH:= ${TOOLSDIR}${dir}:${PATH}
100.endfor
101.export PATH
102# Prefer the TOOLSDIR version of the toolchain if present vs the host version.
103.for var in ${TOOLCHAIN_VARS}
104_toolchain_bin.${var}=	${TOOLSDIR}${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
105.if exists(${_toolchain_bin.${var}})
106HOST_${var}?=	${_toolchain_bin.${var}}
107.export		HOST_${var}
108.endif
109.endfor
110.endif
111
112.for var in ${TOOLCHAIN_VARS}
113HOST_${var}?=	${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
114.endfor
115
116.if ${MACHINE} == "host"
117.for var in ${TOOLCHAIN_VARS}
118${var}=		${HOST_${var}}
119.endfor
120.endif
121
122.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
123# cross-building
124.if !defined(FREEBSD_REVISION)
125FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh
126.export FREEBSD_REVISION
127.endif
128CROSS_TARGET_FLAGS= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION}
129CFLAGS+= ${CROSS_TARGET_FLAGS}
130ACFLAGS+= ${CROSS_TARGET_FLAGS}
131.endif
132
133# we set these here, rather than local.gendirdeps.mk
134# so we can ensure any DEP_* values that might be used in
135# conditionals do not cause syntax errors when Makefile.depend
136# is included at level 1+
137
138# order of this list matters!
139GENDIRDEPS_FILTER_DIR_VARS+= \
140       CSU_DIR \
141       BOOT_MACHINE_DIR
142
143# order of this list matters!
144GENDIRDEPS_FILTER_VARS+= \
145       KERNEL_NAME \
146       DEP_MACHINE_CPUARCH \
147       DEP_MACHINE_ARCH \
148       DEP_MACHINE
149
150.if ${.MAKE.LEVEL} > 0
151.for V in ${GENDIRDEPS_FILTER_DIR_VARS:MDEP_*:O:u} \
152	${GENDIRDEPS_FILTER_VARS:MDEP_*:O:u}
153$V?= ${${V:S,DEP_,,}}
154.endfor
155.endif
156
157.if ${MACHINE} == "host" && ${.MAKE.OS} != "FreeBSD"
158# some makefiles expect this
159BOOTSTRAPPING= 0
160.endif
161