unstack, sort: cleanup and improvement
[minix.git] / share / mk / bsd.sys.mk
blobb32b043e205cb6e7e381b5e29fd0ba34a9046c1f
1 # $NetBSD: bsd.sys.mk,v 1.186 2009/11/30 16:13:23 uebayasi Exp $
3 # Build definitions used for NetBSD source tree builds.
5 .if !defined(_MINIX_SYS_MK_)
6 _MINIX_SYS_MK_=1
8 .if defined(WARNS)
9 .if ${WARNS} > 0
10 CFLAGS+= -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.
18 CFLAGS+= -Wno-sign-compare
19 .if !empty(CC:Mgcc)
20 CFLAGS+= -Wno-traditional
21 .endif
22 .if !defined(NOGCCERROR) && !empty(CC:Mgcc)
23 # Set assembler warnings to be fatal
24 CFLAGS+= -Wa,--fatal-warnings
25 .endif
26 # Set linker warnings to be fatal
27 # XXX no proper way to avoid "FOO is a patented algorithm" warnings
28 # XXX on linking static libs
29 .if (!defined(MKPIC) || ${MKPIC} != "no") && \
30 (!defined(LDSTATIC) || ${LDSTATIC} != "-static") \
31 && !empty(CC:Mgcc)
32 LDFLAGS+= -Wl,--fatal-warnings
33 .endif
34 .endif
35 .if ${WARNS} > 1
36 CFLAGS+= -Wreturn-type -Wswitch -Wshadow
37 .endif
38 .if ${WARNS} > 2
39 CFLAGS+= -Wcast-qual -Wwrite-strings
40 CFLAGS+= -Wextra -Wno-unused-parameter
41 CXXFLAGS+= -Wabi
42 CXXFLAGS+= -Wold-style-cast
43 CXXFLAGS+= -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder \
44 -Wno-deprecated -Wno-non-template-friend \
45 -Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo -Wsynth
46 .endif
47 .if ${WARNS} > 3 && defined(HAVE_GCC) && ${HAVE_GCC} >= 3
48 CFLAGS+= -Wsign-compare
49 CFLAGS+= -std=gnu99
50 .endif
51 .endif
53 # XXX: Temporarily disabled for MINIX
54 # CPPFLAGS+= ${AUDIT:D-D__AUDIT__}
55 # CFLAGS+= ${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
56 # LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include}
58 .if (${MACHINE_ARCH} == "alpha") || \
59 (${MACHINE_ARCH} == "hppa") || \
60 (${MACHINE_ARCH} == "ia64") || \
61 (${MACHINE_ARCH} == "mipsel") || (${MACHINE_ARCH} == "mipseb") || \
62 (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
63 HAS_SSP= no
64 .else
65 HAS_SSP= yes
66 .endif
68 .if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no")
69 CPPFLAGS+= -D__NBSD_LIBC
70 .endif
72 .if defined(USE_FORT) && (${USE_FORT} != "no")
73 USE_SSP?= yes
74 .if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules
75 CPPFLAGS+= -D_FORTIFY_SOURCE=2
76 .endif
77 .endif
79 .if defined(USE_SSP) && (${USE_SSP} != "no") && (${BINDIR:Ux} != "/usr/mdec")
80 .if ${HAS_SSP} == "yes"
81 COPTS+= -fstack-protector -Wstack-protector --param ssp-buffer-size=1
82 .endif
83 .endif
85 .if defined(MKSOFTFLOAT) && (${MKSOFTFLOAT} != "no")
86 COPTS+= -msoft-float
87 FOPTS+= -msoft-float
88 .endif
90 .if defined(MKIEEEFP) && (${MKIEEEFP} != "no")
91 .if ${MACHINE_ARCH} == "alpha"
92 CFLAGS+= -mieee
93 FFLAGS+= -mieee
94 .endif
95 .endif
97 .if ${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc"
98 CFLAGS+= -Wa,-Av8plus
99 .endif
101 CFLAGS+= ${CPUFLAGS}
102 AFLAGS+= ${CPUFLAGS}
104 # Position Independent Executable flags
105 PIE_CFLAGS?= -fPIC -DPIC
106 PIE_LDFLAGS?= -Wl,-pie -shared-libgcc
107 PIE_AFLAGS?= -fPIC -DPIC
109 # Helpers for cross-compiling
110 HOST_CC?= cc
111 HOST_CFLAGS?= -O
112 HOST_CFLAGS?=
113 HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c
114 HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c
115 .if defined(HOSTPROG_CXX)
116 HOST_LINK.c?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
117 .else
118 HOST_LINK.c?= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
119 .endif
121 HOST_CXX?= c++
122 HOST_CXXFLAGS?= -O
123 HOST_CXXFLAGS?=
125 HOST_CPP?= cpp
126 HOST_CPPFLAGS?=
128 HOST_LD?= ld
129 HOST_LDFLAGS?=
131 HOST_AR?= ar
132 HOST_RANLIB?= ranlib
134 HOST_LN?= ln
136 # HOST_SH must be an absolute path
137 HOST_SH?= /bin/sh
139 ELF2ECOFF?= elf2ecoff
140 MKDEP?= mkdep
141 OBJCOPY?= objcopy
142 OBJDUMP?= objdump
143 PAXCTL?= paxctl
144 STRIP?= strip
146 # TOOL_* variables are defined in bsd.own.mk
148 .SUFFIXES: .o .ln .lo .c .cc .cpp .cxx .C .m ${YHEADER:D.h}
151 .c.o:
152 ${_MKTARGET_COMPILE}
153 ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
155 .c.ln:
156 ${_MKTARGET_COMPILE}
157 ${LINT} ${LINTFLAGS} \
158 ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
159 ${CPPFLAGS.${.IMPSRC:T}:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
160 -i ${.IMPSRC}
162 # C++
163 .cc.o .cpp.o .cxx.o .C.o:
164 ${_MKTARGET_COMPILE}
165 ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
167 # Objective C
168 # (Defined here rather than in <sys.mk> because `.m' is not just
169 # used for Objective C source)
170 .m.o:
171 ${_MKTARGET_COMPILE}
172 ${COMPILE.m} ${OBJCOPTS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC}
174 # Host-compiled C objects
175 # The intermediate step is necessary for Sun CC, which objects to calling
176 # object files anything but *.o
177 .c.lo:
178 ${_MKTARGET_COMPILE}
179 ${HOST_COMPILE.c} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
180 mv ${.TARGET}.o ${.TARGET}
182 # C++
183 .cc.lo .cpp.lo .cxx.lo .C.lo:
184 ${_MKTARGET_COMPILE}
185 ${HOST_COMPILE.cc} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
186 mv ${.TARGET}.o ${.TARGET}
188 # Assembly
189 .s.o:
190 ${_MKTARGET_COMPILE}
191 ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
193 .S.o:
194 ${_MKTARGET_COMPILE}
195 ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
197 # Lex
198 LFLAGS+= ${LPREFIX.${.IMPSRC:T}:D-P${LPREFIX.${.IMPSRC:T}}}
199 LFLAGS+= ${LPREFIX:D-P${LPREFIX}}
201 .l.c:
202 ${_MKTARGET_LEX}
203 ${LEX.l} -o${.TARGET} ${.IMPSRC}
205 # Yacc
206 YFLAGS+= ${YPREFIX.${.IMPSRC:T}:D-p${YPREFIX.${.IMPSRC:T}}} ${YHEADER.${.IMPSRC:T}:D-d}
207 YFLAGS+= ${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d}
209 .ifdef QUIET_YACC
210 .y.c:
211 ${_MKTARGET_YACC}
212 ${YACC.y} -o ${.TARGET} ${.IMPSRC} 2> /dev/null
213 .else
214 .y.c:
215 ${_MKTARGET_YACC}
216 ${YACC.y} -o ${.TARGET} ${.IMPSRC}
217 .endif
219 .ifdef YHEADER
220 .y.h: ${.TARGET:.h=.c}
221 .endif
223 .endif # !defined(_MINIX_SYS_MK_)