3 CFLAGS+= -I${WORLDTMP}/legacy/usr/include
4 DPADD+= ${WORLDTMP}/legacy/usr/lib/libegacy.a
6 LDFLAGS+= -L${WORLDTMP}/legacy/usr/lib
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.
14 RANLIB:= /usr/bin/ranlib
17 # Don't use lorder and tsort since lorder is not installed by default on most
18 # Linux systems and the FreeBSD lorder does not work on Linux. For the bootstrap
19 # tools the order of the .o files should not matter since we only care about
20 # a few individual files (and might soon require linking with lld anyway)
23 # When using cat as tsort we can't pass -q:
26 # Avoid stale dependecy warnings:
34 LIBMD:=${WORLDTMP}/legacy/usr/lib/libmd.a
35 LIBNV:=${WORLDTMP}/legacy/usr/lib/libmd.a
36 LIBSBUF:=${WORLDTMP}/legacy/usr/lib/libsbuf.a
37 LIBY:=${WORLDTMP}/legacy/usr/lib/liby.a
38 LIBL:=${WORLDTMP}/legacy/usr/lib/libl.a
39 LIBROKEN:=${WORLDTMP}/legacy/usr/lib/libroken.a
40 LIBDWARF:=${WORLDTMP}/legacy/usr/lib/libdwarf.a
41 LIBELF:=${WORLDTMP}/legacy/usr/lib/libelf.a
43 # Add various -Werror flags to catch missing function declarations
44 CFLAGS+= -Werror=implicit-function-declaration -Werror=implicit-int \
45 -Werror=return-type -Wundef
46 CFLAGS+= -DHAVE_NBTOOL_CONFIG_H=1
47 CFLAGS+= -D__BSD_VISIBLE=1
48 CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/common
50 # b64_pton and b64_ntop is in libresolv on MacOS and Linux:
51 # TODO: only needed for uuencode and uudecode
54 .if ${.MAKE.OS} == "Linux"
55 CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux
56 CFLAGS+= -std=gnu99 -D_GNU_SOURCE=1
57 # Needed for sem_init, etc. on Linux (used by usr.bin/sort)
60 .elif ${.MAKE.OS} == "Darwin"
61 CFLAGS+= -D_DARWIN_C_SOURCE=1
62 CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/mac
63 # The macOS ar and ranlib don't understand all the flags supported by the
64 # FreeBSD and Linux ar/ranlib
68 # to get libarchive (needed for elftoolchain)
69 # MacOS ships /usr/lib/libarchive.dylib but doesn't provide the headers
70 CFLAGS+= -idirafter ${SRCTOP}/contrib/libarchive/libarchive
72 .error "Unsupported build OS: ${.MAKE.OS}"
74 .endif # ${.MAKE.OS} != "FreeBSD"
76 # we do not want to capture dependencies referring to the above
79 # When building host tools we should never pull in headers from the source sys
80 # directory to avoid any ABI issues that might cause the built binary to crash.
81 # The only exceptions to this are sys/cddl/compat for dtrace bootstrap tools and
82 # sys/crypto for libmd bootstrap.
83 # We have to skip this check during make obj since bsd.crunchgen.mk will run
84 # make obj on every directory during the build-tools phase.
86 .if !empty(CFLAGS:M*${SRCTOP}/sys)
87 .error Do not include $${SRCTOP}/sys when building bootstrap tools. \
88 Copy the header to $${WORLDTMP}/legacy in tools/build/Makefile instead. \
89 Error was caused by Makefile in ${.CURDIR}
92 # ${SRCTOP}/include should also never be used to avoid ABI issues
93 .if !empty(CFLAGS:M*${SRCTOP}/include*)
94 .error Do not include $${SRCTOP}/include when building bootstrap tools. \
95 Copy the header to $${WORLDTMP}/legacy in tools/build/Makefile instead. \
96 Error was caused by Makefile in ${.CURDIR}