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