Drop main() prototype. Syncs with NetBSD-8
[minix.git] / share / mk / sys.mk
blobdc031d23ee7600c0809ba0e9350d84ba97fa3a01
1 # $NetBSD: sys.mk,v 1.128 2015/07/06 00:21:51 chs Exp $
2 # @(#)sys.mk 8.2 (Berkeley) 3/21/94
4 # This file contains the basic rules for make(1) and is read first
5 # Do not put conditionals that are set on different files here and
6 # expect them to work.
8 # This variable should be used to differentiate Minix builds in Makefiles.
9 __MINIX= yes
11 .if !defined(__MINIX)
12 unix?= We run NetBSD.
14 .SUFFIXES: .a .o .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh
15 .else
16 unix?= We run MINIX.
18 .SUFFIXES: .a .o .bc .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh
20 .if ${MKSMALL:U} == "yes"
21 CPPFLAGS+= -DNDEBUG
22 DBG= -Os
23 .endif
25 .if ${MKMAGIC:Uno} == "yes" || ${MKASR:Uno} == "yes"
26 CPPFLAGS+= -D_MINIX_MAGIC=1
27 STRIPFLAG= -s
28 DBG=-g
29 .endif
31 #LSC: Be a bit smarter about the default compiler
32 .if exists(/usr/pkg/bin/clang) || exists(/usr/bin/clang)
33 CC?= clang
34 .endif
36 .if exists(/usr/pkg/bin/gcc) || exists(/usr/bin/gcc)
37 CC?= gcc
38 .endif
39 .endif # defined(__MINIX)
41 .LIBS: .a
43 AR?= ar
44 ARFLAGS?= rl
45 RANLIB?= ranlib
47 AS?= as
48 AFLAGS?=
49 COMPILE.s?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} -c
50 LINK.s?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${LDFLAGS}
51 _ASM_TRADITIONAL_CPP= -x assembler-with-cpp
52 COMPILE.S?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${_ASM_TRADITIONAL_CPP} -c
53 LINK.S?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${LDFLAGS}
55 CC?= cc
56 .if ${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb"
57 # -O2 is too -falign-* zealous for low-memory sh3 machines
58 DBG?= -Os -freorder-blocks
59 .elif ${MACHINE_ARCH} == "m68k" || ${MACHINE_ARCH} == "m68000"
60 # -freorder-blocks (enabled by -O2) produces much bigger code
61 DBG?= -O2 -fno-reorder-blocks
62 .elif ${MACHINE_ARCH} == "coldfire"
63 DBG?= -O1
64 .elif !empty(MACHINE_ARCH:Maarch64*)
65 DBG?= -O2 ${"${.TARGET:M*.po}" == "":? -fomit-frame-pointer:}
66 .elif ${MACHINE_ARCH} == "vax"
67 DBG?= -O1 -fgcse -fstrength-reduce -fgcse-after-reload
68 .else
69 DBG?= -O2
70 .endif
71 .if !defined(__MINIX)
72 CFLAGS?= ${DBG}
73 .else
74 CFLAGS+= ${DBG}
75 .endif # !defined(__MINIX)
76 LDFLAGS?=
77 COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
78 LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
80 # C Type Format data is required for DTrace
81 CTFFLAGS ?= -g -L VERSION
82 CTFMFLAGS ?= -t -g -L VERSION
84 CXX?= c++
85 CXXFLAGS?= ${CFLAGS:N-Wno-traditional:N-Wstrict-prototypes:N-Wmissing-prototypes:N-Wno-pointer-sign:N-ffreestanding:N-std=gnu[0-9][0-9]:N-Wold-style-definition:N-Wno-format-zero-length}
87 __ALLSRC1= ${empty(DESTDIR):?${.ALLSRC}:${.ALLSRC:S|^${DESTDIR}|^destdir|}}
88 __ALLSRC2= ${empty(MAKEOBJDIR):?${__ALLSRC1}:${__ALLSRC1:S|^${MAKEOBJDIR}|^obj|}}
89 __ALLSRC3= ${empty(NETBSDSRCDIR):?${__ALLSRC2}:${__ALLSRC2:S|^${NETBSDSRCDIR}|^src|}}
90 __BUILDSEED= ${BUILDSEED}/${__ALLSRC3:O}/${.TARGET}
91 _CXXSEED?= ${BUILDSEED:D-frandom-seed=${__BUILDSEED:hash}}
93 COMPILE.cc?= ${CXX} ${_CXXSEED} ${CXXFLAGS} ${CPPFLAGS} -c
94 LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
96 OBJC?= ${CC}
97 OBJCFLAGS?= ${CFLAGS}
98 COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
99 LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
101 CPP?= cpp
102 CPPFLAGS?=
104 FC?= f77
105 FFLAGS?= -O
106 RFLAGS?=
107 COMPILE.f?= ${FC} ${FFLAGS} -c
108 LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
109 COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
110 LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
111 COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
112 LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
114 INSTALL?= install
116 LD?= ld
118 LEX?= lex
119 LFLAGS?=
120 LEX.l?= ${LEX} ${LFLAGS}
122 LINT?= lint
123 LINTFLAGS?= -chapbxzgFS
125 LORDER?= lorder
127 MAKE?= make
129 NM?= nm
131 PC?= pc
132 PFLAGS?=
133 COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
134 LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
136 SHELL?= sh
138 SIZE?= size
140 TSORT?= tsort -q
142 YACC?= yacc
143 YFLAGS?=
144 YACC.y?= ${YACC} ${YFLAGS}
148 ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
149 # XXX: disable for now
150 # ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
151 .c.o:
152 ${COMPILE.c} ${.IMPSRC}
153 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
154 .c.a:
155 ${COMPILE.c} ${.IMPSRC}
156 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
157 rm -f ${.PREFIX}.o
158 .c.ln:
159 ${LINT} ${LINTFLAGS} \
160 ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
161 -i ${.IMPSRC}
163 # C++
164 .cc .cpp .cxx .C:
165 ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
166 .cc.o .cpp.o .cxx.o .C.o:
167 ${COMPILE.cc} ${.IMPSRC}
168 .cc.a .cpp.a .cxx.a .C.a:
169 ${COMPILE.cc} ${.IMPSRC}
170 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
171 rm -f ${.PREFIX}.o
173 # Fortran/Ratfor
175 ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
176 .f.o:
177 ${COMPILE.f} ${.IMPSRC}
178 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
179 .f.a:
180 ${COMPILE.f} ${.IMPSRC}
181 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
182 rm -f ${.PREFIX}.o
185 ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
186 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
187 .F.o:
188 ${COMPILE.F} ${.IMPSRC}
189 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
190 .F.a:
191 ${COMPILE.F} ${.IMPSRC}
192 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
193 rm -f ${.PREFIX}.o
196 ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
197 .r.o:
198 ${COMPILE.r} ${.IMPSRC}
199 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
200 .r.a:
201 ${COMPILE.r} ${.IMPSRC}
202 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
203 rm -f ${.PREFIX}.o
205 # Pascal
207 ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
208 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
209 .p.o:
210 ${COMPILE.p} ${.IMPSRC}
211 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
212 .p.a:
213 ${COMPILE.p} ${.IMPSRC}
214 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
215 rm -f ${.PREFIX}.o
217 # Assembly
219 ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
220 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
221 .s.o:
222 ${COMPILE.s} ${.IMPSRC}
223 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
224 .s.a:
225 ${COMPILE.s} ${.IMPSRC}
226 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
227 rm -f ${.PREFIX}.o
229 ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
230 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
231 .S.o:
232 ${COMPILE.S} ${.IMPSRC}
233 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
234 .S.a:
235 ${COMPILE.S} ${.IMPSRC}
236 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
237 rm -f ${.PREFIX}.o
239 # Lex
241 ${LEX.l} ${.IMPSRC}
242 ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
243 rm -f lex.yy.c
244 .l.c:
245 ${LEX.l} ${.IMPSRC}
246 mv lex.yy.c ${.TARGET}
247 .l.o:
248 ${LEX.l} ${.IMPSRC}
249 ${COMPILE.c} -o ${.TARGET} lex.yy.c
250 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
251 rm -f lex.yy.c
253 # Yacc
255 ${YACC.y} ${.IMPSRC}
256 ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
257 rm -f y.tab.c
258 .y.c:
259 ${YACC.y} ${.IMPSRC}
260 mv y.tab.c ${.TARGET}
261 .y.o:
262 ${YACC.y} ${.IMPSRC}
263 ${COMPILE.c} -o ${.TARGET} y.tab.c
264 ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
265 rm -f y.tab.c
267 # Shell
268 .sh:
269 rm -f ${.TARGET}
270 cp ${.IMPSRC} ${.TARGET}
271 chmod a+x ${.TARGET}