Remove building with NOCRYPTO option
[minix.git] / share / mk / bsd.sys.mk
blob322fc2dc5bb8583936ff3c1a556c4b0404f42702
1 # $NetBSD: bsd.sys.mk,v 1.245 2014/09/03 19:22:53 matt Exp $
3 # Build definitions used for NetBSD source tree builds.
5 .if !defined(_BSD_SYS_MK_)
6 _BSD_SYS_MK_=1
8 .if !empty(.INCLUDEDFROMFILE:MMakefile*)
9 error1:
10 @(echo "bsd.sys.mk should not be included from Makefiles" >& 2; exit 1)
11 .endif
12 .if !defined(_BSD_OWN_MK_)
13 error2:
14 @(echo "bsd.own.mk must be included before bsd.sys.mk" >& 2; exit 1)
15 .endif
17 .if defined(__MINIX)
18 #LSC: Be a bit smarter about the default compiler
19 .if exists(/usr/pkg/bin/clang) || exists(/usr/bin/clang)
20 CC?= clang
21 .endif
23 .if exists(/usr/pkg/bin/gcc) || exists(/usr/bin/gcc)
24 CC?= gcc
25 .endif
27 MKDEP?= CC=${CC:Q} mkdep
28 MKDEPCXX?= CC=${CXX:Q} mkdep
29 .endif # defined(__MINIX)
31 .if ${MKREPRO:Uno} == "yes"
32 CPPFLAGS+= -Wp,-iremap,${NETBSDSRCDIR}:/usr/src
33 CPPFLAGS+= -Wp,-iremap,${DESTDIR}/:/
34 CPPFLAGS+= -Wp,-iremap,${X11SRCDIR}:/usr/xsrc
35 .endif
37 # NetBSD sources use C99 style, with some GCC extensions.
38 CFLAGS+= ${${ACTIVE_CC} == "clang":? -std=gnu99 :}
39 CFLAGS+= ${${ACTIVE_CC} == "gcc":? -std=gnu99 :}
40 CFLAGS+= ${${ACTIVE_CC} == "pcc":? -std=gnu99 :}
42 .if defined(WARNS)
43 CFLAGS+= ${${ACTIVE_CC} == "clang":? -Wno-sign-compare -Wno-pointer-sign :}
44 .if ${WARNS} > 0
45 CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
46 #CFLAGS+= -Wmissing-declarations -Wredundant-decls -Wnested-externs
47 # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
48 # but our sources aren't up for it yet. Also, add -Wno-traditional because
49 # gcc includes #elif in the warnings, which is 'this code will not compile
50 # in a traditional environment' warning, as opposed to 'this code behaves
51 # differently in traditional and ansi environments' which is the warning
52 # we wanted, and now we don't get anymore.
53 CFLAGS+= -Wno-sign-compare
54 CFLAGS+= ${${ACTIVE_CC} == "gcc" :? -Wno-traditional :}
55 .if !defined(NOGCCERROR) && !defined(USE_BITCODE)
56 # Set assembler warnings to be fatal
57 CFLAGS+= -Wa,--fatal-warnings
58 .endif
59 # Set linker warnings to be fatal
60 # XXX no proper way to avoid "FOO is a patented algorithm" warnings
61 # XXX on linking static libs
62 .if (!defined(MKPIC) || ${MKPIC} != "no") && \
63 (!defined(LDSTATIC) || ${LDSTATIC} != "-static")
64 # XXX there are some strange problems not yet resolved
65 . if defined(HAVE_LLVM) && !defined(USE_BITCODE)
66 LDFLAGS+= -Wl,--fatal-warnings
67 . endif
68 .endif
69 .endif
70 .if ${WARNS} > 1
71 CFLAGS+= -Wreturn-type -Wswitch -Wshadow
72 .endif
73 .if ${WARNS} > 2
74 CFLAGS+= -Wcast-qual -Wwrite-strings
75 CFLAGS+= -Wextra -Wno-unused-parameter
76 # Readd -Wno-sign-compare to override -Wextra with clang
77 CFLAGS+= -Wno-sign-compare
78 CXXFLAGS+= -Wabi
79 CXXFLAGS+= -Wold-style-cast
80 CXXFLAGS+= -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder \
81 -Wno-deprecated -Woverloaded-virtual -Wsign-promo -Wsynth
82 CXXFLAGS+= ${${ACTIVE_CXX} == "gcc":? -Wno-non-template-friend -Wno-pmf-conversions :}
83 .endif
84 .if ${WARNS} > 3 && (defined(HAVE_GCC) || defined(HAVE_LLVM))
85 .if ${WARNS} > 4
86 CFLAGS+= -Wold-style-definition
87 .endif
88 .if ${WARNS} > 5 && !(defined(HAVE_GCC) && ${HAVE_GCC} <= 45)
89 CFLAGS+= -Wconversion
90 .endif
91 CFLAGS+= -Wsign-compare -Wformat=2
92 CFLAGS+= ${${ACTIVE_CC} == "gcc":? -Wno-format-zero-length :}
93 .endif
94 .if ${WARNS} > 3 && defined(HAVE_LLVM)
95 CFLAGS+= ${${ACTIVE_CC} == "clang":? -Wpointer-sign -Wmissing-noreturn :}
96 .endif
97 .if (defined(HAVE_GCC) \
98 && (${MACHINE_ARCH} == "coldfire" || \
99 ${MACHINE_ARCH} == "sh3eb" || \
100 ${MACHINE_ARCH} == "sh3el" || \
101 ${MACHINE_ARCH} == "m68k" || \
102 ${MACHINE_ARCH} == "m68000"))
103 # XXX GCC 4.5 for sh3 and m68k (which we compile with -Os) is extra noisy for
104 # cases it should be better with
105 CFLAGS+= -Wno-uninitialized
106 .if ${HAVE_GCC} >= 48
107 CFLAGS+= -Wno-maybe-uninitialized
108 .endif
109 .endif
110 .endif
112 CWARNFLAGS+= ${CWARNFLAGS.${ACTIVE_CC}}
114 CPPFLAGS+= ${AUDIT:D-D__AUDIT__}
115 _NOWERROR= ${defined(NOGCCERROR) || (${ACTIVE_CC} == "clang" && defined(NOCLANGERROR)):?yes:no}
116 .if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
117 _NOWERROR= yes
118 .endif # defined(__MINIX) && ${USE_BITCODE} == "yes"
119 CFLAGS+= ${${_NOWERROR} == "no" :?-Werror:} ${CWARNFLAGS}
120 LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include}
122 .if (${USE_SSP:Uno} != "no") && (${BINDIR:Ux} != "/usr/mdec")
123 .if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules
124 CPPFLAGS+= -D_FORTIFY_SOURCE=2
125 .endif
126 COPTS+= -fstack-protector -Wstack-protector
128 # gcc 4.8 on m68k erroneously does not protect functions with
129 # variables needing special alignement, see
130 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59674
131 # (the underlying issue for sh and vax may be different, needs more
132 # investigation, symptoms are similar but for different sources)
133 .if "${ACTIVE_CC}" == "gcc" && "${HAVE_GCC}" == "48" && \
134 ( ${MACHINE_CPU} == "sh3" || \
135 ${MACHINE_ARCH} == "vax" || \
136 ${MACHINE_CPU} == "m68k" || \
137 ${MACHINE_CPU} == "or1k" )
138 COPTS+= -Wno-error=stack-protector
139 .endif
141 COPTS+= ${${ACTIVE_CC} == "clang":? --param ssp-buffer-size=1 :}
142 COPTS+= ${${ACTIVE_CC} == "gcc":? --param ssp-buffer-size=1 :}
143 .endif
145 .if ${MKSOFTFLOAT:Uno} != "no"
146 COPTS+= ${${ACTIVE_CC} == "gcc":? -msoft-float :}
147 FOPTS+= -msoft-float
148 .elif ${MACHINE_ARCH} == "coldfire"
149 COPTS+= -mhard-float
150 FOPTS+= -mhard-float
151 .endif
153 .if ${MKIEEEFP:Uno} != "no"
154 .if ${MACHINE_ARCH} == "alpha"
155 CFLAGS+= -mieee
156 FFLAGS+= -mieee
157 .endif
158 .endif
160 .if ${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc"
161 CFLAGS+= -Wa,-Av8plus
162 .endif
164 .if !defined(NOGCCERROR)
165 .if (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
166 CPUFLAGS+= -Wa,--fatal-warnings
167 .endif
168 .endif
170 #.if ${MACHINE} == "sbmips"
171 #CFLAGS+= -mips64 -mtune=sb1
172 #.endif
174 #.if (${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb") && \
175 # (defined(MKPIC) && ${MKPIC} == "no")
176 #CPUFLAGS+= -mno-abicalls -fno-PIC
177 #.endif
178 CFLAGS+= ${CPUFLAGS}
179 AFLAGS+= ${CPUFLAGS}
181 .if !defined(LDSTATIC) || ${LDSTATIC} != "-static"
182 # Position Independent Executable flags
183 PIE_CFLAGS?= -fPIC
184 PIE_LDFLAGS?= -Wl,-pie ${${ACTIVE_CC} == "gcc":? -shared-libgcc :}
185 PIE_AFLAGS?= -fPIC
186 .endif
188 ELF2ECOFF?= elf2ecoff
189 MKDEP?= mkdep
190 MKDEPCXX?= mkdep
191 OBJCOPY?= objcopy
192 OBJDUMP?= objdump
193 PAXCTL?= paxctl
194 STRIP?= strip
196 .SUFFIXES: .o .ln .lo .c .cc .cpp .cxx .C .m ${YHEADER:D.h}
199 .c.o:
200 ${_MKTARGET_COMPILE}
201 ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
202 .if defined(CTFCONVERT)
203 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
204 .endif
206 .c.ln:
207 ${_MKTARGET_COMPILE}
208 ${LINT} ${LINTFLAGS} ${LINTFLAGS.${.IMPSRC:T}} \
209 ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
210 ${CPPFLAGS.${.IMPSRC:T}:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
211 -i ${.IMPSRC}
213 # C++
214 .cc.o .cpp.o .cxx.o .C.o:
215 ${_MKTARGET_COMPILE}
216 ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
218 # Objective C
219 # (Defined here rather than in <sys.mk> because `.m' is not just
220 # used for Objective C source)
221 .m.o:
222 ${_MKTARGET_COMPILE}
223 ${COMPILE.m} ${OBJCOPTS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC}
224 .if defined(CTFCONVERT)
225 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
226 .endif
228 # Host-compiled C objects
229 # The intermediate step is necessary for Sun CC, which objects to calling
230 # object files anything but *.o
231 .c.lo:
232 ${_MKTARGET_COMPILE}
233 ${HOST_COMPILE.c} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
234 mv ${.TARGET}.o ${.TARGET}
236 # C++
237 .cc.lo .cpp.lo .cxx.lo .C.lo:
238 ${_MKTARGET_COMPILE}
239 ${HOST_COMPILE.cc} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
240 mv ${.TARGET}.o ${.TARGET}
242 # Assembly
243 .s.o:
244 ${_MKTARGET_COMPILE}
245 ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
246 .if defined(CTFCONVERT)
247 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
248 .endif
250 .S.o:
251 ${_MKTARGET_COMPILE}
252 ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
253 .if defined(CTFCONVERT)
254 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
255 .endif
257 # Lex
258 LFLAGS+= ${LPREFIX.${.IMPSRC:T}:D-P${LPREFIX.${.IMPSRC:T}}}
259 LFLAGS+= ${LPREFIX:D-P${LPREFIX}}
261 .l.c:
262 ${_MKTARGET_LEX}
263 ${LEX.l} -o${.TARGET} ${.IMPSRC}
265 # Yacc
266 YFLAGS+= ${YPREFIX.${.IMPSRC:T}:D-p${YPREFIX.${.IMPSRC:T}}} ${YHEADER.${.IMPSRC:T}:D-d}
267 YFLAGS+= ${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d}
269 .y.c:
270 ${_MKTARGET_YACC}
271 ${YACC.y} -o ${.TARGET} ${.IMPSRC}
273 .ifdef YHEADER
274 .if empty(.MAKEFLAGS:M-n)
275 .y.h: ${.TARGET:.h=.c}
276 .endif
277 .endif
279 # Objcopy
280 .if ${MACHINE_ARCH} == aarch64eb
281 # AARCH64 big endian needs to preserve $x/$d symbols for the linker.
282 OBJCOPYLIBFLAGS_EXTRA=-w -K '[$$][dx]' -K '[$$][dx]\.*'
283 .elif !empty(MACHINE_ARCH:M*arm*eb)
284 # ARM big endian needs to preserve $a/$d/$t symbols for the linker.
285 OBJCOPYLIBFLAGS_EXTRA=-w -K '[$$][adt]' -K '[$$][adt]\.*'
286 .endif
287 OBJCOPYLIBFLAGS?=${"${.TARGET:M*.po}" != "":?-X:-x} ${OBJCOPYLIBFLAGS_EXTRA}
289 .endif # !defined(_BSD_SYS_MK_)