forked from CTSRD-CHERI/cheribsd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.libcompat
145 lines (128 loc) · 4.79 KB
/
Makefile.libcompat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# $FreeBSD$
.if !targets(__<${_this:T}>__)
__<${_this:T}>__:
.include <src.libnames.mk>
# Makefile for the compatibility libraries.
# - 32-bit compat libraries on MIPS, PowerPC, and AMD64.
# - 64-bit compat on CHERI MIPS
_LC_LIBDIRS.yes= lib
_LC_LIBDIRS.yes+= gnu/lib
_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib
_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib
_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib
_lc_distribute _lc_install: .PHONY
.for _dir in ${_LC_LIBDIRS.yes}
${_+_}cd ${.CURDIR}/${_dir}; ${MAKE} ${.TARGET:S/^_lc_//}
.endfor
.if defined(_LIBCOMPAT)
.include <bsd.compat.mk>
# Yes, the flags are redundant.
LIBCOMPAT_COMPILERS= \
CC="${XCC} ${LIBCOMPATCFLAGS}" \
CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \
CPP="${XCPP} ${LIBCOMPATCFLAGS}"
LIBCOMPATWMAKEENV+= \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
PATH=${TMPPATH} \
SYSROOT=${WORLDTMP} \
LIBDIR=/usr/lib${libcompat} \
SHLIBDIR=/usr/lib${libcompat} \
DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
.if ${MK_META_MODE} != "no"
# Don't rebuild build-tools targets during normal build.
LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA
.endif
LIBCOMPATWMAKEFLAGS+= \
${LIBCOMPAT_COMPILERS} \
DESTDIR=${WORLDTMP} \
-DNO_CPU_CFLAGS \
MK_CTF=no \
-DNO_LINT \
MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} \
WORLDTMP_MTREE="${WORLDTMP_MTREE}"
# Avoid re-computing COMPILER_VERSION, etc. values:
# $CC is different in the libcompat case compared to the non-compat value.
# Since bsd.compiler.mk (and bsd.linker.mk) save the variables using a full
# hash of the compiler/link command, this means that the cached values for
# X_COMPILER_TYPE, etc. cannot be loaded.
# Instead set all the values, so that we can avoid including bsd.compiler.mk and
# bsd.linker.mk. This provides a noticeable speed-up as it avoids multiple
# processes from being spawned in each subdirectory.
.for _var in ${_TOOLCHAIN_METADATA_VARS}
LIBCOMPATWMAKEFLAGS+= ${_var}="${X_${_var}}"
.endfor
LIBCOMPATWMAKEFLAGS+=_NO_INCLUDE_LINKERMK=yes _NO_INCLUDE_COMPILERMK=yes
LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
OBJTOP=${LIBCOMPAT_OBJTOP} \
OBJROOT='$${OBJTOP}/' \
MAKEOBJDIRPREFIX= \
MK_MAN=no MK_HTML=no
LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \
${IMAKE_INSTALL} \
-DLIBRARIES_ONLY
.if ${MK_FILE} != "no"
_libmagic= lib/libmagic
.endif
.if ${MK_PMC} != "no" && ${TARGET_ARCH} == "amd64"
_jevents= lib/libpmc/pmu-events
.endif
# Shared logic
build${libcompat}: .PHONY
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4.3: building lib${libcompat} shim libraries"
@echo "--------------------------------------------------------------"
${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
-p ${WORLDTMP}/usr >/dev/null
.if ${MK_DEBUG_FILES} != "no"
${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
-p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
.endif
.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw ${_libmagic} ${_jevents}
.for _t in ${_obj} build-tools
${_+_}cd ${.CURDIR}/${_dir}; \
WORLDTMP=${WORLDTMP} \
MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
${MAKE} SSP_CFLAGS= DESTDIR= \
OBJTOP=${LIBCOMPAT_OBJTOP} \
OBJROOT='$${OBJTOP}/' \
MAKEOBJDIRPREFIX= \
DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \
MK_CTF=no MK_RETPOLINE=no MK_WARNS=no \
${_t}
.endfor
.endfor
${_+_}cd ${.CURDIR}; \
${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
.if ${MK_COMPAT_CHERIABI} == "yes" && ${MK_CHERI_PURE} == "yes"
# To build a purecap world against /usr/libcheri, we need internal libs.
# Skip amu because it needs unifdef which isn't available here and we
# don't build amd (and it's going away).
# We've locally removed gdb.
.for _lib in ${_INTERNALLIBS:Namu:Ngdb}
${_+_}cd ${.CURDIR}${LIB${_lib:tu}DIR:S|${_LIB_OBJTOP}||}; \
${LIBCOMPATWMAKE} all
.endfor
.endif
distribute${libcompat} install${libcompat}: .PHONY
${_+_}cd ${.CURDIR}; \
${LIBCOMPATIMAKE} -f Makefile.inc1 _lc_${.TARGET:S/${libcompat}$//}
.if ${.TARGETS:Mlib${libcompat}buildenv}
.if ${.MAKEFLAGS:M-j}
.error The lib${libcompat}buildenv target is incompatible with -j
.endif
BUILDENV_DIR?= ${.CURDIR}
lib${libcompat}buildenv: .PHONY
@echo "Entering world for lib${libcompat} on ${TARGET_ARCH}:${TARGET}"
.if ${BUILDENV_SHELL:M*zsh*}
@echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
.endif
# Note: we have to remove TARGET and TARGET_ARCH from MAKEFLAGS since
# otherwise src.opts.mk will pick the wrong MK_FOO values.
@cd ${BUILDENV_DIR} && \
env ${LIBCOMPATWMAKEENV} ${LIBCOMPAT_COMPILERS} BUILDENV=1 \
TARGET=${LIBCOMPAT_MACHINE} TARGET_ARCH=${LIBCOMPAT_MACHINE_ARCH} \
"MAKEFLAGS=${MAKEFLAGS:NTARGET*}" ${BUILDENV_SHELL} || true
.endif
.endif # defined(_LIBCOMPAT)
.endif # !targets(__<${_this:T}>__)