1# $NetBSD: bsd.sys.mk,v 1.156 2007/11/12 14:54:43 jmmv Exp $ 2# 3# Build definitions used for NetBSD source tree builds. 4 5.if !defined(_BSD_SYS_MK_) 6_BSD_SYS_MK_=1 7 8.if defined(WARNS) 9.if ${WARNS} > 0 10CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 11#CFLAGS+= -Wmissing-declarations -Wredundant-decls -Wnested-externs 12# Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3, 13# but our sources aren't up for it yet. Also, add -Wno-traditional because 14# gcc includes #elif in the warnings, which is 'this code will not compile 15# in a traditional environment' warning, as opposed to 'this code behaves 16# differently in traditional and ansi environments' which is the warning 17# we wanted, and now we don't get anymore. 18CFLAGS+= -Wno-sign-compare -Wno-traditional 19.endif 20.if ${WARNS} > 1 21CFLAGS+= -Wreturn-type -Wswitch -Wshadow 22.endif 23.if ${WARNS} > 2 24CFLAGS+= -Wcast-qual -Wwrite-strings 25CFLAGS+= -Wextra -Wno-unused-parameter 26CXXFLAGS+= -Wabi 27CXXFLAGS+= -Wold-style-cast 28CXXFLAGS+= -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder \ 29 -Wno-deprecated -Wno-non-template-friend \ 30 -Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo -Wsynth 31.endif 32.if ${WARNS} > 3 && ${HAVE_GCC} >= 3 33CFLAGS+= -std=gnu99 34.endif 35.endif 36 37CPPFLAGS+= ${AUDIT:D-D__AUDIT__} 38CFLAGS+= ${CWARNFLAGS} ${NOGCCERROR:D:U-Werror} 39LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include} 40 41.if (${MACHINE_ARCH} == "alpha") || (${MACHINE_ARCH} == "hppa") || \ 42 (${MACHINE_ARCH} == "mipsel") || (${MACHINE_ARCH} == "mipseb") 43HAS_SSP= no 44.else 45HAS_SSP= yes 46.endif 47 48.if defined(USE_FORT) && (${USE_FORT} != "no") 49USE_SSP?= yes 50.if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules 51CPPFLAGS+= -D_FORTIFY_SOURCE=2 52.endif 53.endif 54 55.if defined(USE_SSP) && (${USE_SSP} != "no") && (${BINDIR:Ux} != "/usr/mdec") 56.if ${HAS_SSP} == "yes" 57COPTS+= -fstack-protector -Wstack-protector --param ssp-buffer-size=1 58.endif 59.endif 60 61.if defined(MKSOFTFLOAT) && (${MKSOFTFLOAT} != "no") 62COPTS+= -msoft-float 63FOPTS+= -msoft-float 64.endif 65 66.if defined(MKIEEEFP) && (${MKIEEEFP} != "no") 67.if ${MACHINE_ARCH} == "alpha" 68CFLAGS+= -mieee 69FFLAGS+= -mieee 70.endif 71.endif 72 73.if ${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc" 74CFLAGS+= -Wa,-Av8plus 75.endif 76 77.if ${MACHINE_ARCH} == "ns32k" 78CFLAGS+= -Wno-uninitialized 79.endif 80 81CFLAGS+= ${CPUFLAGS} 82AFLAGS+= ${CPUFLAGS} 83 84# Helpers for cross-compiling 85HOST_CC?= cc 86HOST_CFLAGS?= -O 87HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c 88HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c 89.if defined(HOSTPROG_CXX) 90HOST_LINK.c?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} 91.else 92HOST_LINK.c?= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} 93.endif 94 95HOST_CXX?= c++ 96HOST_CXXFLAGS?= -O 97 98HOST_CPP?= cpp 99HOST_CPPFLAGS?= 100 101HOST_LD?= ld 102HOST_LDFLAGS?= 103 104HOST_AR?= ar 105HOST_RANLIB?= ranlib 106 107HOST_LN?= ln 108 109HOST_SED?= sed 110 111.if !empty(HOST_CYGWIN) 112HOST_SH?= /usr/bin/bash 113.else 114HOST_SH?= sh 115.endif 116 117ELF2ECOFF?= elf2ecoff 118MKDEP?= mkdep 119OBJCOPY?= objcopy 120OBJDUMP?= objdump 121PAXCTL?= paxctl 122STRIP?= strip 123 124AWK?= awk 125 126TOOL_ASN1_COMPILE?= asn1_compile 127TOOL_ATF_COMPILE?= atf-compile 128TOOL_CAP_MKDB?= cap_mkdb 129TOOL_CAT?= cat 130TOOL_CKSUM?= cksum 131TOOL_COMPILE_ET?= compile_et 132TOOL_CONFIG?= config 133TOOL_CRUNCHGEN?= crunchgen 134TOOL_CTAGS?= ctags 135TOOL_DB?= db 136TOOL_EQN?= eqn 137TOOL_FGEN?= fgen 138TOOL_GENASSYM?= genassym 139TOOL_GENCAT?= gencat 140TOOL_GROFF?= groff 141TOOL_HEXDUMP?= hexdump 142TOOL_INDXBIB?= indxbib 143TOOL_INSTALLBOOT?= installboot 144TOOL_INSTALL_INFO?= install-info 145TOOL_JOIN?= join 146TOOL_M4?= m4 147TOOL_MAKEFS?= makefs 148TOOL_MAKEINFO?= makeinfo 149TOOL_MAKEWHATIS?= /usr/libexec/makewhatis 150TOOL_MDSETIMAGE?= mdsetimage 151TOOL_MENUC?= menuc 152TOOL_MKCSMAPPER?= mkcsmapper 153TOOL_MKESDB?= mkesdb 154TOOL_MKLOCALE?= mklocale 155TOOL_MKMAGIC?= file 156TOOL_MKTEMP?= mktemp 157TOOL_MSGC?= msgc 158TOOL_MTREE?= mtree 159TOOL_PAX?= pax 160TOOL_PIC?= pic 161TOOL_PREPMKBOOTIMAGE?= prep-mkbootimage 162TOOL_PWD_MKDB?= pwd_mkdb 163TOOL_REFER?= refer 164TOOL_ROFF_ASCII?= nroff 165TOOL_ROFF_DVI?= ${TOOL_GROFF} -Tdvi 166TOOL_ROFF_HTML?= ${TOOL_GROFF} -Tlatin1 -mdoc2html 167TOOL_ROFF_PS?= ${TOOL_GROFF} -Tps 168TOOL_ROFF_RAW?= ${TOOL_GROFF} -Z 169TOOL_RPCGEN?= rpcgen 170TOOL_SED?= sed 171TOOL_SOELIM?= soelim 172TOOL_STAT?= stat 173TOOL_SPARKCRC?= sparkcrc 174TOOL_SUNLABEL?= sunlabel 175TOOL_TBL?= tbl 176TOOL_UUDECODE?= uudecode 177TOOL_VGRIND?= vgrind -f 178TOOL_ZIC?= zic 179 180.SUFFIXES: .o .ln .lo .c .cc .cpp .cxx .C .m ${YHEADER:D.h} 181 182# C 183.c.o: 184 ${_MKTARGET_COMPILE} 185 ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 186 187.c.ln: 188 ${_MKTARGET_COMPILE} 189 ${LINT} ${LINTFLAGS} \ 190 ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 191 ${CPPFLAGS.${.IMPSRC:T}:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 192 -i ${.IMPSRC} 193 194# C++ 195.cc.o .cpp.o .cxx.o .C.o: 196 ${_MKTARGET_COMPILE} 197 ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 198 199# Objective C 200# (Defined here rather than in <sys.mk> because `.m' is not just 201# used for Objective C source) 202.m.o: 203 ${_MKTARGET_COMPILE} 204 ${COMPILE.m} ${OBJCOPTS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} 205 206# Host-compiled C objects 207# The intermediate step is necessary for Sun CC, which objects to calling 208# object files anything but *.o 209.c.lo: 210 ${_MKTARGET_COMPILE} 211 ${HOST_COMPILE.c} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 212 mv ${.TARGET}.o ${.TARGET} 213 214# C++ 215.cc.lo .cpp.lo .cxx.lo .C.lo: 216 ${_MKTARGET_COMPILE} 217 ${HOST_COMPILE.cc} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 218 mv ${.TARGET}.o ${.TARGET} 219 220# Assembly 221.s.o: 222 ${_MKTARGET_COMPILE} 223 ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 224 225.S.o: 226 ${_MKTARGET_COMPILE} 227 ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 228 229# Lex 230LPREFIX?= yy 231LFLAGS+= -P${LPREFIX} 232 233.l.c: 234 ${_MKTARGET_LEX} 235 ${LEX.l} -o${.TARGET} ${.IMPSRC} 236 237# Yacc 238YFLAGS+= ${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d} 239 240.y.c: 241 ${_MKTARGET_YACC} 242 ${YACC.y} -o ${.TARGET} ${.IMPSRC} 243 244.ifdef YHEADER 245.y.h: ${.TARGET:.h=.c} 246.endif 247 248.endif # !defined(_BSD_SYS_MK_) 249