xref: /freebsd/share/mk/local.sys.dirdeps.mk (revision 535af610)
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
67TOOLCHAIN_VARS=	AS AR CC CLANG_TBLGEN CXX CPP LD NM OBJCOPY RANLIB \
68		STRINGS SIZE LLVM_TBLGEN
69_toolchain_bin_CLANG_TBLGEN=	/usr/bin/clang-tblgen
70_toolchain_bin_LLVM_TBLGEN=	/usr/bin/llvm-tblgen
71_toolchain_bin_CXX=		/usr/bin/c++
72.ifdef WITH_TOOLSDIR
73TOOLSDIR?= ${HOST_OBJTOP}/tools
74.elif defined(STAGE_HOST_OBJTOP)
75TOOLSDIR?= ${STAGE_HOST_OBJTOP}
76.endif
77.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
78# ideally tools needed by makefiles like sh,csh,tinfo
79# would be built in their own directories but for now
80# this works well enough.
81BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR}
82.else
83# Only define if it exists in case user didn't run bootstrap-tools.  Otherwise
84# the tool will be built during the build.  Building it assumes it is
85# TARGET==MACHINE.
86.if exists(${HOST_OBJTOP}/tools${.CURDIR})
87BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR}
88.endif
89.endif
90
91# Don't use the bootstrap tools logic on itself.
92.if ${.TARGETS:Mbootstrap-tools} == "" && \
93    !make(test-system-*) && !make(showconfig) && !make(print-dir) && \
94    !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0
95.for dir in /sbin /bin /usr/sbin /usr/bin
96PATH:= ${TOOLSDIR}${dir}:${PATH}
97.endfor
98.export PATH
99# Prefer the TOOLSDIR version of the toolchain if present vs the host version.
100.for var in ${TOOLCHAIN_VARS}
101_toolchain_bin.${var}=	${TOOLSDIR}${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
102.if exists(${_toolchain_bin.${var}})
103HOST_${var}?=	${_toolchain_bin.${var}}
104.export		HOST_${var}
105.endif
106.endfor
107.endif
108
109.for var in ${TOOLCHAIN_VARS}
110HOST_${var}?=	${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
111.endfor
112
113.if ${MACHINE} == "host"
114.for var in ${TOOLCHAIN_VARS}
115${var}=		${HOST_${var}}
116.endfor
117.endif
118
119.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
120# cross-building
121.if !defined(FREEBSD_REVISION)
122FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh
123.export FREEBSD_REVISION
124.endif
125CROSS_TARGET_FLAGS?= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION}
126CFLAGS+= ${CROSS_TARGET_FLAGS}
127ACFLAGS+= ${CROSS_TARGET_FLAGS}
128.endif
129
130# we set these here, rather than local.gendirdeps.mk
131# so we can ensure any DEP_* values that might be used in
132# conditionals do not cause syntax errors when Makefile.depend
133# is included at level 1+
134
135# order of this list matters!
136GENDIRDEPS_FILTER_DIR_VARS+= \
137       CSU_DIR \
138       BOOT_MACHINE_DIR
139
140# order of this list matters!
141GENDIRDEPS_FILTER_VARS+= \
142       KERNEL_NAME \
143       DEP_MACHINE_CPUARCH \
144       DEP_MACHINE_ARCH \
145       DEP_MACHINE
146
147.if ${.MAKE.LEVEL} > 0
148.for V in ${GENDIRDEPS_FILTER_DIR_VARS:MDEP_*:O:u} \
149	${GENDIRDEPS_FILTER_VARS:MDEP_*:O:u}
150$V?= ${${V:S,DEP_,,}}
151.endfor
152.endif
153
154.if ${MACHINE} == "host" && ${.MAKE.OS} != "FreeBSD"
155# some makefiles expect this
156BOOTSTRAPPING= 0
157.endif
158