Annotation of src/share/mk/bsd.sys.mk, Revision 1.225
1.225 ! martin 1: # $NetBSD: bsd.sys.mk,v 1.224 2013/07/16 17:48:52 christos Exp $
1.1 christos 2: #
1.58 tv 3: # Build definitions used for NetBSD source tree builds.
1.2 cgd 4:
1.94 lukem 5: .if !defined(_BSD_SYS_MK_)
6: _BSD_SYS_MK_=1
1.96 lukem 7:
1.193 joerg 8: .if ${MKREPRO:Uno} == "yes"
9: CPPFLAGS+= -Wp,-iremap,${NETBSDSRCDIR}:/usr/src
10: CPPFLAGS+= -Wp,-iremap,${DESTDIR}/:/
1.218 riz 11: CPPFLAGS+= -Wp,-iremap,${X11SRCDIR}:/usr/xsrc
1.193 joerg 12: .endif
13:
1.194 christos 14: # Enable c99 mode by default.
15: # This has the side effect of complaining for missing prototypes
16: # implicit type declarations and missing return statements.
1.212 joerg 17: .if defined(HAVE_GCC) || defined(HAVE_LLVM)
1.194 christos 18: CFLAGS+= -std=gnu99
19: .endif
20:
1.35 christos 21: .if defined(WARNS)
1.201 joerg 22: CFLAGS+= ${${ACTIVE_CC} == "clang":? -Wno-sign-compare -Wno-pointer-sign :}
1.35 christos 23: .if ${WARNS} > 0
1.60 tv 24: CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
25: #CFLAGS+= -Wmissing-declarations -Wredundant-decls -Wnested-externs
1.82 thorpej 26: # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
1.95 christos 27: # but our sources aren't up for it yet. Also, add -Wno-traditional because
28: # gcc includes #elif in the warnings, which is 'this code will not compile
29: # in a traditional environment' warning, as opposed to 'this code behaves
30: # differently in traditional and ansi environments' which is the warning
31: # we wanted, and now we don't get anymore.
1.195 joerg 32: CFLAGS+= -Wno-sign-compare
33: CFLAGS+= ${${ACTIVE_CC} != "clang":? -Wno-traditional :}
1.164 lukem 34: .if !defined(NOGCCERROR)
35: # Set assembler warnings to be fatal
1.220 joerg 36: CFLAGS+= -Wa,--fatal-warnings
1.164 lukem 37: .endif
1.159 lukem 38: # Set linker warnings to be fatal
1.162 tsutsui 39: # XXX no proper way to avoid "FOO is a patented algorithm" warnings
40: # XXX on linking static libs
41: .if (!defined(MKPIC) || ${MKPIC} != "no") && \
42: (!defined(LDSTATIC) || ${LDSTATIC} != "-static")
1.205 mrg 43: # XXX there are some strange problems not yet resolved
1.217 joerg 44: . if !defined(HAVE_GCC) || defined(HAVE_LLVM)
1.159 lukem 45: LDFLAGS+= -Wl,--fatal-warnings
1.205 mrg 46: . endif
1.119 lukem 47: .endif
1.162 tsutsui 48: .endif
1.35 christos 49: .if ${WARNS} > 1
1.79 msaitoh 50: CFLAGS+= -Wreturn-type -Wswitch -Wshadow
1.56 lukem 51: .endif
52: .if ${WARNS} > 2
1.60 tv 53: CFLAGS+= -Wcast-qual -Wwrite-strings
1.137 christos 54: CFLAGS+= -Wextra -Wno-unused-parameter
1.201 joerg 55: # Readd -Wno-sign-compare to override -Wextra with clang
56: CFLAGS+= -Wno-sign-compare
1.123 he 57: CXXFLAGS+= -Wabi
58: CXXFLAGS+= -Wold-style-cast
1.122 he 59: CXXFLAGS+= -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder \
1.200 joerg 60: -Wno-deprecated -Woverloaded-virtual -Wsign-promo -Wsynth
61: CXXFLAGS+= ${${ACTIVE_CXX} == "gcc":? -Wno-non-template-friend -Wno-pmf-conversions :}
1.35 christos 62: .endif
1.212 joerg 63: .if ${WARNS} > 3 && (defined(HAVE_GCC) || defined(HAVE_LLVM))
1.215 matt 64: .if ${WARNS} > 4
65: CFLAGS+= -Wold-style-definition
66: .endif
1.225 ! martin 67: .if ${WARNS} > 5 && !(defined(HAVE_GCC) && ${HAVE_GCC} <= 45)
1.224 christos 68: CFLAGS+= -Wconversion
69: .endif
1.208 christos 70: CFLAGS+= -Wsign-compare -Wformat=2
1.213 joerg 71: CFLAGS+= ${${ACTIVE_CC} == "clang":? -Wno-error=format-nonliteral :}
1.212 joerg 72: CFLAGS+= ${${ACTIVE_CC} == "gcc":? -Wno-format-zero-length :}
1.209 joerg 73: .endif
74: .if ${WARNS} > 3 && defined(HAVE_LLVM)
75: CFLAGS+= ${${ACTIVE_CC} == "clang":? -Wpointer-sign -Wmissing-noreturn :}
1.115 matt 76: .endif
1.207 uwe 77: .if (defined(HAVE_GCC) && ${HAVE_GCC} == 45 \
1.210 chs 78: && (${MACHINE_ARCH} == "sh3eb" || \
79: ${MACHINE_ARCH} == "sh3el" || \
80: ${MACHINE_ARCH} == "m68k" || \
81: ${MACHINE_ARCH} == "m68000"))
82: # XXX GCC 4.5 for sh3 and m68k (which we compile with -Os) is extra noisy for
1.207 uwe 83: # cases it should be better with
1.206 mrg 84: CFLAGS+= -Wno-uninitialized
85: .endif
1.9 christos 86: .endif
1.41 sommerfe 87:
1.199 joerg 88: CWARNFLAGS+= ${CWARNFLAGS.${ACTIVE_CC}}
89:
1.61 tv 90: CPPFLAGS+= ${AUDIT:D-D__AUDIT__}
1.202 joerg 91: _NOWERROR= ${defined(NOGCCERROR) || (${ACTIVE_CC} == "clang" && defined(NOCLANGERROR)):?yes:no}
1.203 joerg 92: CFLAGS+= ${${_NOWERROR} == "no" :?-Werror:} ${CWARNFLAGS}
1.53 tv 93: LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include}
1.47 simonb 94:
1.223 christos 95: .if (${USE_SSP:Uno} != "no") && (${BINDIR:Ux} != "/usr/mdec")
1.142 tls 96: .if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules
1.151 tls 97: CPPFLAGS+= -D_FORTIFY_SOURCE=2
1.142 tls 98: .endif
1.196 joerg 99: COPTS+= -fstack-protector -Wstack-protector
1.219 joerg 100: COPTS+= ${${ACTIVE_CC} == "clang":? --param ssp-buffer-size=1 :}
1.196 joerg 101: COPTS+= ${${ACTIVE_CC} == "gcc":? --param ssp-buffer-size=1 :}
1.143 tls 102: .endif
1.145 tls 103:
1.197 joerg 104: .if ${MKSOFTFLOAT:Uno} != "no"
1.47 simonb 105: COPTS+= -msoft-float
106: FOPTS+= -msoft-float
1.70 ross 107: .endif
108:
1.197 joerg 109: .if ${MKIEEEFP:Uno} != "no"
1.70 ross 110: .if ${MACHINE_ARCH} == "alpha"
111: CFLAGS+= -mieee
112: FFLAGS+= -mieee
113: .endif
1.81 mrg 114: .endif
115:
116: .if ${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc"
117: CFLAGS+= -Wa,-Av8plus
1.3 scottr 118: .endif
1.87 thorpej 119:
1.189 mrg 120: .if !defined(NOGCCERROR)
1.188 matt 121: .if (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
1.220 joerg 122: CPUFLAGS+= -Wa,--fatal-warnings
1.188 matt 123: .endif
1.189 mrg 124: .endif
1.188 matt 125:
126: #.if ${MACHINE} == "sbmips"
127: #CFLAGS+= -mips64 -mtune=sb1
128: #.endif
129:
130: #.if (${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb") && \
131: # (defined(MKPIC) && ${MKPIC} == "no")
132: #CPUFLAGS+= -mno-abicalls -fno-PIC
133: #.endif
1.87 thorpej 134: CFLAGS+= ${CPUFLAGS}
1.114 simonb 135: AFLAGS+= ${CPUFLAGS}
1.4 thorpej 136:
1.192 pooka 137: .if !defined(LDSTATIC) || ${LDSTATIC} != "-static"
1.174 christos 138: # Position Independent Executable flags
1.175 christos 139: PIE_CFLAGS?= -fPIC -DPIC
1.174 christos 140: PIE_LDFLAGS?= -Wl,-pie -shared-libgcc
1.175 christos 141: PIE_AFLAGS?= -fPIC -DPIC
1.192 pooka 142: .endif
1.174 christos 143:
1.4 thorpej 144: # Helpers for cross-compiling
145: HOST_CC?= cc
146: HOST_CFLAGS?= -O
147: HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c
1.124 jwise 148: HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c
149: .if defined(HOSTPROG_CXX)
150: HOST_LINK.c?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
151: .else
1.4 thorpej 152: HOST_LINK.c?= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
1.124 jwise 153: .endif
1.49 tv 154:
155: HOST_CXX?= c++
156: HOST_CXXFLAGS?= -O
1.4 thorpej 157:
158: HOST_CPP?= cpp
159: HOST_CPPFLAGS?=
160:
161: HOST_LD?= ld
162: HOST_LDFLAGS?=
1.60 tv 163:
164: HOST_AR?= ar
165: HOST_RANLIB?= ranlib
1.108 matt 166:
167: HOST_LN?= ln
1.84 christos 168:
1.178 apb 169: # HOST_SH must be an absolute path
170: HOST_SH?= /bin/sh
1.28 tv 171:
1.77 simonb 172: ELF2ECOFF?= elf2ecoff
1.74 lukem 173: MKDEP?= mkdep
174: OBJCOPY?= objcopy
1.117 riz 175: OBJDUMP?= objdump
1.139 christos 176: PAXCTL?= paxctl
1.74 lukem 177: STRIP?= strip
1.109 matt 178:
1.179 apb 179: # TOOL_* variables are defined in bsd.own.mk
1.13 lukem 180:
1.124 jwise 181: .SUFFIXES: .o .ln .lo .c .cc .cpp .cxx .C .m ${YHEADER:D.h}
1.93 lukem 182:
183: # C
184: .c.o:
1.104 lukem 185: ${_MKTARGET_COMPILE}
1.93 lukem 186: ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
1.190 darran 187: .if defined(CTFCONVERT)
188: ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
189: .endif
1.112 lukem 190:
1.93 lukem 191: .c.ln:
1.104 lukem 192: ${_MKTARGET_COMPILE}
1.214 christos 193: ${LINT} ${LINTFLAGS} ${LINTFLAGS.${.IMPSRC:T}} \
1.111 lukem 194: ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
195: ${CPPFLAGS.${.IMPSRC:T}:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
196: -i ${.IMPSRC}
1.29 tv 197:
1.103 lukem 198: # C++
199: .cc.o .cpp.o .cxx.o .C.o:
1.104 lukem 200: ${_MKTARGET_COMPILE}
1.103 lukem 201: ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
202:
1.13 lukem 203: # Objective C
204: # (Defined here rather than in <sys.mk> because `.m' is not just
205: # used for Objective C source)
206: .m.o:
1.104 lukem 207: ${_MKTARGET_COMPILE}
1.129 mrg 208: ${COMPILE.m} ${OBJCOPTS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC}
1.190 darran 209: .if defined(CTFCONVERT)
210: ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
211: .endif
1.29 tv 212:
213: # Host-compiled C objects
1.76 bjh21 214: # The intermediate step is necessary for Sun CC, which objects to calling
215: # object files anything but *.o
1.29 tv 216: .c.lo:
1.104 lukem 217: ${_MKTARGET_COMPILE}
1.110 lukem 218: ${HOST_COMPILE.c} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
1.76 bjh21 219: mv ${.TARGET}.o ${.TARGET}
1.98 lukem 220:
1.124 jwise 221: # C++
222: .cc.lo .cpp.lo .cxx.lo .C.lo:
223: ${_MKTARGET_COMPILE}
224: ${HOST_COMPILE.cc} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
225: mv ${.TARGET}.o ${.TARGET}
226:
1.98 lukem 227: # Assembly
228: .s.o:
1.104 lukem 229: ${_MKTARGET_COMPILE}
1.98 lukem 230: ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
1.190 darran 231: .if defined(CTFCONVERT)
232: ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
233: .endif
1.107 lukem 234:
1.98 lukem 235: .S.o:
1.104 lukem 236: ${_MKTARGET_COMPILE}
1.98 lukem 237: ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
1.190 darran 238: .if defined(CTFCONVERT)
239: ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
240: .endif
1.13 lukem 241:
1.52 tv 242: # Lex
1.167 christos 243: LFLAGS+= ${LPREFIX.${.IMPSRC:T}:D-P${LPREFIX.${.IMPSRC:T}}}
244: LFLAGS+= ${LPREFIX:D-P${LPREFIX}}
1.1 christos 245:
246: .l.c:
1.104 lukem 247: ${_MKTARGET_LEX}
1.1 christos 248: ${LEX.l} -o${.TARGET} ${.IMPSRC}
249:
250: # Yacc
1.167 christos 251: YFLAGS+= ${YPREFIX.${.IMPSRC:T}:D-p${YPREFIX.${.IMPSRC:T}}} ${YHEADER.${.IMPSRC:T}:D-d}
1.52 tv 252: YFLAGS+= ${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d}
253:
1.33 lukem 254: .y.c:
1.104 lukem 255: ${_MKTARGET_YACC}
1.33 lukem 256: ${YACC.y} -o ${.TARGET} ${.IMPSRC}
1.55 tv 257:
258: .ifdef YHEADER
1.187 christos 259: .if empty(.MAKEFLAGS:M-n)
1.55 tv 260: .y.h: ${.TARGET:.h=.c}
261: .endif
1.187 christos 262: .endif
1.64 thorpej 263:
1.211 christos 264: # Objcopy
265: OBJCOPYLIBFLAGS?=${"${.TARGET:M*.po}" != "":?-X:-x}
266:
1.94 lukem 267: .endif # !defined(_BSD_SYS_MK_)
CVSweb <webmaster@jp.NetBSD.org>