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