xref: /freebsd/tools/build/mk/Makefile.boot (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1# $FreeBSD$
2
3CFLAGS+=	-I${WORLDTMP}/legacy/usr/include
4DPADD+=		${WORLDTMP}/legacy/usr/lib/libegacy.a
5LDADD+=		-legacy
6LDFLAGS+=	-L${WORLDTMP}/legacy/usr/lib
7
8.if ${.MAKE.OS} != "FreeBSD"
9# On MacOS using a non-mac ar will fail the build, similarly on Linux using
10# nm may not work as expected if the nm for the target architecture comes in
11# $PATH before a nm that supports the host architecture.
12# To ensure that host binary compile as expected we use the tools from /usr/bin.
13AR:=	/usr/bin/ar
14RANLIB:=	/usr/bin/ranlib
15NM:=	/usr/bin/nm
16
17# Avoid stale dependecy warnings:
18LIBC:=
19LIBZ:=
20LIBM:=
21LIBUTIL:=
22LIBCPLUSPLUS:=
23LIBARCHIVE:=
24LIBPTHREAD:=
25LIBMD:=${WORLDTMP}/legacy/usr/lib/libmd.a
26LIBNV:=${WORLDTMP}/legacy/usr/lib/libmd.a
27LIBSBUF:=${WORLDTMP}/legacy/usr/lib/libsbuf.a
28LIBY:=${WORLDTMP}/legacy/usr/lib/liby.a
29LIBL:=${WORLDTMP}/legacy/usr/lib/libl.a
30LIBROKEN:=${WORLDTMP}/legacy/usr/lib/libroken.a
31LIBDWARF:=${WORLDTMP}/legacy/usr/lib/libdwarf.a
32LIBELF:=${WORLDTMP}/legacy/usr/lib/libelf.a
33
34# Add various -Werror flags to catch missing function declarations
35CFLAGS+=	-Werror=implicit-function-declaration -Werror=implicit-int \
36		-Werror=return-type -Wundef
37CFLAGS+=	-DHAVE_NBTOOL_CONFIG_H=1
38CFLAGS+=	-I${SRCTOP}/tools/build/cross-build/include/common
39# This is needed for code that compiles for pre-C11 C standards
40CWARNFLAGS+=	-Wno-typedef-redefinition
41# bsd.sys.mk explicitly turns on -Wsystem-headers, but that's extremely
42# noisy when building on Linux.
43CWARNFLAGS+=	-Wno-system-headers
44
45# b64_pton and b64_ntop is in libresolv on MacOS and Linux:
46# TODO: only needed for uuencode and uudecode
47LDADD+=-lresolv
48
49.if ${.MAKE.OS} == "Linux"
50CFLAGS+=	-I${SRCTOP}/tools/build/cross-build/include/linux
51CFLAGS+=	-D_GNU_SOURCE=1
52# Needed for sem_init, etc. on Linux (used by usr.bin/sort)
53LDADD+=	-pthread
54
55.elif ${.MAKE.OS} == "Darwin"
56CFLAGS+=	-D_DARWIN_C_SOURCE=1
57CFLAGS+=	-I${SRCTOP}/tools/build/cross-build/include/mac
58# The macOS ar and ranlib don't understand all the flags supported by the
59# FreeBSD and Linux ar/ranlib
60ARFLAGS:=	-crs
61RANLIBFLAGS:=
62
63# to get libarchive (needed for elftoolchain)
64# MacOS ships /usr/lib/libarchive.dylib but doesn't provide the headers
65CFLAGS+=	-idirafter ${SRCTOP}/contrib/libarchive/libarchive
66.else
67.error "Unsupported build OS: ${.MAKE.OS}"
68.endif
69.endif # ${.MAKE.OS} != "FreeBSD"
70
71# we do not want to capture dependencies referring to the above
72UPDATE_DEPENDFILE= no
73
74# When building host tools we should never pull in headers from the source sys
75# directory to avoid any ABI issues that might cause the built binary to crash.
76# The only exceptions to this are sys/cddl/compat for dtrace bootstrap tools and
77# sys/crypto for libmd bootstrap.
78# We have to skip this check during make obj since bsd.crunchgen.mk will run
79# make obj on every directory during the build-tools phase.
80.if !make(obj)
81.if !empty(CFLAGS:M*${SRCTOP}/sys)
82.error Do not include $${SRCTOP}/sys when building bootstrap tools. \
83    Copy the header to $${WORLDTMP}/legacy in tools/build/Makefile instead. \
84    Error was caused by Makefile in ${.CURDIR}
85.endif
86
87# ${SRCTOP}/include should also never be used to avoid ABI issues
88.if !empty(CFLAGS:M*${SRCTOP}/include*)
89.error Do not include $${SRCTOP}/include when building bootstrap tools. \
90    Copy the header to $${WORLDTMP}/legacy in tools/build/Makefile instead. \
91    Error was caused by Makefile in ${.CURDIR}
92.endif
93.endif
94
95# GCC doesn't allow silencing warn_unused_result calls with (void) casts.
96CFLAGS.gcc+=-Wno-unused-result
97