1# $NetBSD: bsd.sys.mk,v 1.125 2005/12/02 21:34:50 christos 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.if !defined(HAVE_GCC3) || (${HAVE_GCC3} == "no") 20CFLAGS+= -Wno-uninitialized 21.endif 22.endif 23.if ${WARNS} > 1 24CFLAGS+= -Wreturn-type -Wswitch -Wshadow 25.endif 26.if ${WARNS} > 2 27CFLAGS+= -Wcast-qual -Wwrite-strings 28.if defined(HAVE_GCC3) && (${HAVE_GCC3} != "no") 29CXXFLAGS+= -Wabi 30.if (${MACHINE_CPU} != "sh3") 31CXXFLAGS+= -Wold-style-cast 32.endif 33.endif 34CXXFLAGS+= -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder \ 35 -Wno-deprecated -Wno-non-template-friend \ 36 -Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo -Wsynth 37.endif 38.if ${WARNS} > 3 && ${MACHINE_ARCH} != "vax" 39CFLAGS+= -std=gnu99 40.endif 41.endif 42 43.if defined(WFORMAT) && defined(FORMAT_AUDIT) 44.if ${WFORMAT} > 1 45CFLAGS+= -Wnetbsd-format-audit -Wno-format-extra-args 46.endif 47.endif 48 49CPPFLAGS+= ${AUDIT:D-D__AUDIT__} 50CFLAGS+= ${CWARNFLAGS} ${NOGCCERROR:D:U-Werror} 51LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include} 52 53.if defined(MKSOFTFLOAT) && (${MKSOFTFLOAT} != "no") 54COPTS+= -msoft-float 55FOPTS+= -msoft-float 56.endif 57 58.if defined(MKIEEEFP) && (${MKIEEEFP} != "no") 59.if ${MACHINE_ARCH} == "alpha" 60CFLAGS+= -mieee 61FFLAGS+= -mieee 62.endif 63.endif 64 65.if ${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc" 66CFLAGS+= -Wa,-Av8plus 67.endif 68 69CFLAGS+= ${CPUFLAGS} 70AFLAGS+= ${CPUFLAGS} 71 72# Helpers for cross-compiling 73HOST_CC?= cc 74HOST_CFLAGS?= -O 75HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c 76HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c 77.if defined(HOSTPROG_CXX) 78HOST_LINK.c?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} 79.else 80HOST_LINK.c?= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} 81.endif 82 83HOST_CXX?= c++ 84HOST_CXXFLAGS?= -O 85 86HOST_CPP?= cpp 87HOST_CPPFLAGS?= 88 89HOST_LD?= ld 90HOST_LDFLAGS?= 91 92HOST_AR?= ar 93HOST_RANLIB?= ranlib 94 95HOST_LN?= ln 96 97.if !empty(HOST_CYGWIN) 98HOST_SH?= /usr/bin/bash 99.else 100HOST_SH?= sh 101.endif 102 103ELF2ECOFF?= elf2ecoff 104MKDEP?= mkdep 105OBJCOPY?= objcopy 106OBJDUMP?= objdump 107STRIP?= strip 108 109AWK?= awk 110 111TOOL_ASN1_COMPILE?= asn1_compile 112TOOL_CAP_MKDB?= cap_mkdb 113TOOL_CAT?= cat 114TOOL_CKSUM?= cksum 115TOOL_COMPILE_ET?= compile_et 116TOOL_CONFIG?= config 117TOOL_CRUNCHGEN?= crunchgen 118TOOL_CTAGS?= ctags 119TOOL_DB?= db 120TOOL_EQN?= eqn 121TOOL_FGEN?= fgen 122TOOL_GENASSYM?= genassym 123TOOL_GENCAT?= gencat 124TOOL_GROFF?= groff 125TOOL_HEXDUMP?= hexdump 126TOOL_INDXBIB?= indxbib 127TOOL_INSTALLBOOT?= installboot 128TOOL_INSTALL_INFO?= install-info 129TOOL_M4?= m4 130TOOL_MAKEFS?= makefs 131TOOL_MAKEINFO?= makeinfo 132TOOL_MAKEWHATIS?= /usr/libexec/makewhatis 133TOOL_MDSETIMAGE?= mdsetimage 134TOOL_MENUC?= menuc 135TOOL_MKCSMAPPER?= mkcsmapper 136TOOL_MKESDB?= mkesdb 137TOOL_MKLOCALE?= mklocale 138TOOL_MKMAGIC?= file 139TOOL_MKTEMP?= mktemp 140TOOL_MSGC?= msgc 141TOOL_MTREE?= mtree 142TOOL_PAX?= pax 143TOOL_PIC?= pic 144TOOL_PREPMKBOOTIMAGE?= prep-mkbootimage 145TOOL_PWD_MKDB?= pwd_mkdb 146TOOL_REFER?= refer 147TOOL_ROFF_ASCII?= nroff 148TOOL_ROFF_DVI?= ${TOOL_GROFF} -Tdvi 149TOOL_ROFF_HTML?= ${TOOL_GROFF} -Tlatin1 -mdoc2html 150TOOL_ROFF_PS?= ${TOOL_GROFF} -Tps 151TOOL_ROFF_RAW?= ${TOOL_GROFF} -Z 152TOOL_RPCGEN?= rpcgen 153TOOL_SOELIM?= soelim 154TOOL_STAT?= stat 155TOOL_SPARKCRC?= sparkcrc 156TOOL_SUNLABEL?= sunlabel 157TOOL_TBL?= tbl 158TOOL_UUDECODE?= uudecode 159TOOL_VGRIND?= vgrind -f 160TOOL_ZIC?= zic 161 162.SUFFIXES: .o .ln .lo .c .cc .cpp .cxx .C .m ${YHEADER:D.h} 163 164# C 165.c.o: 166 ${_MKTARGET_COMPILE} 167 ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 168 169.c.ln: 170 ${_MKTARGET_COMPILE} 171 ${LINT} ${LINTFLAGS} \ 172 ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 173 ${CPPFLAGS.${.IMPSRC:T}:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 174 -i ${.IMPSRC} 175 176# C++ 177.cc.o .cpp.o .cxx.o .C.o: 178 ${_MKTARGET_COMPILE} 179 ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 180 181# Objective C 182# (Defined here rather than in <sys.mk> because `.m' is not just 183# used for Objective C source) 184.m.o: 185 ${_MKTARGET_COMPILE} 186 ${COMPILE.m} ${.IMPSRC} 187 188# Host-compiled C objects 189# The intermediate step is necessary for Sun CC, which objects to calling 190# object files anything but *.o 191.c.lo: 192 ${_MKTARGET_COMPILE} 193 ${HOST_COMPILE.c} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 194 mv ${.TARGET}.o ${.TARGET} 195 196# C++ 197.cc.lo .cpp.lo .cxx.lo .C.lo: 198 ${_MKTARGET_COMPILE} 199 ${HOST_COMPILE.cc} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 200 mv ${.TARGET}.o ${.TARGET} 201 202# Assembly 203.s.o: 204 ${_MKTARGET_COMPILE} 205 ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 206 207.S.o: 208 ${_MKTARGET_COMPILE} 209 ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 210 211# Lex 212LPREFIX?= yy 213LFLAGS+= -P${LPREFIX} 214 215.l.c: 216 ${_MKTARGET_LEX} 217 ${LEX.l} -o${.TARGET} ${.IMPSRC} 218 219# Yacc 220YFLAGS+= ${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d} 221 222.y.c: 223 ${_MKTARGET_YACC} 224 ${YACC.y} -o ${.TARGET} ${.IMPSRC} 225 226.ifdef YHEADER 227.y.h: ${.TARGET:.h=.c} 228.endif 229 230.endif # !defined(_BSD_SYS_MK_) 231