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