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