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