]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - share/mk/sys.mk
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / share / mk / sys.mk
1 #       from: @(#)sys.mk        8.2 (Berkeley) 3/21/94
2 # $FreeBSD$
3
4 unix            ?=      We run FreeBSD, not UNIX.
5 .FreeBSD        ?=      true
6
7 .if !defined(%POSIX)
8 #
9 # MACHINE_CPUARCH defines a collection of MACHINE_ARCH.  Machines with
10 # the same MACHINE_ARCH can run each other's binaries, so it necessarily
11 # has word size and endian swizzled in.  However, support files for
12 # these machines often are shared amongst all combinations of size
13 # and/or endian.  This is called MACHINE_CPU in NetBSD, but that's used
14 # for something different in FreeBSD.
15 #
16 MACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc64/powerpc/}
17 .endif
18
19 # Set any local definitions first. Place this early, but it needs
20 # MACHINE_CPUARCH to be defined.
21 .sinclude <local.sys.mk>
22
23 # If the special target .POSIX appears (without prerequisites or
24 # commands) before the first noncomment line in the makefile, make shall
25 # process the makefile as specified by the Posix 1003.2 specification.
26 # make(1) sets the special macro %POSIX in this case (to the actual
27 # value "1003.2", for what it's worth).
28 #
29 # The rules below use this macro to distinguish between Posix-compliant
30 # and default behaviour.
31
32 .if defined(%POSIX)
33 .SUFFIXES:      .o .c .y .l .a .sh .f
34 .else
35 .SUFFIXES:      .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
36 .endif
37
38 AR              ?=      ar
39 .if defined(%POSIX)
40 ARFLAGS         ?=      -rv
41 .else
42 ARFLAGS         ?=      -crD
43 .endif
44 RANLIB          ?=      ranlib
45 .if !defined(%POSIX)
46 RANLIBFLAGS     ?=      -D
47 .endif
48
49 AS              ?=      as
50 AFLAGS          ?=
51 ACFLAGS         ?=
52
53 .if defined(%POSIX)
54 CC              ?=      c89
55 CFLAGS          ?=      -O
56 .else
57 CC              ?=      cc
58 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
59 CFLAGS          ?=      -O -pipe
60 .else
61 CFLAGS          ?=      -O2 -pipe
62 .endif
63 .if defined(NO_STRICT_ALIASING)
64 CFLAGS          +=      -fno-strict-aliasing
65 .endif
66 .endif
67 PO_CFLAGS       ?=      ${CFLAGS}
68
69 # C Type Format data is required for DTrace
70 CTFFLAGS        ?=      -L VERSION
71
72 CTFCONVERT      ?=      ctfconvert
73 CTFMERGE        ?=      ctfmerge
74 DTRACE          ?=      dtrace
75 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
76 CTFFLAGS        +=      -g
77 .else
78 # XXX: What to do here? Is removing the CFLAGS part completely ok here?
79 # For now comment it out to not compile with -g unconditionally.
80 #CFLAGS         +=      -g
81 .endif
82
83 CXX             ?=      c++
84 CXXFLAGS        ?=      ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
85 PO_CXXFLAGS     ?=      ${CXXFLAGS}
86
87 CPP             ?=      cpp
88
89 .if empty(.MAKEFLAGS:M-s)
90 ECHO            ?=      echo
91 ECHODIR         ?=      echo
92 .else
93 ECHO            ?=      true
94 .if ${.MAKEFLAGS:M-s} == "-s"
95 ECHODIR         ?=      echo
96 .else
97 ECHODIR         ?=      true
98 .endif
99 .endif
100
101 .if defined(.PARSEDIR)
102 # _+_ appears to be a workaround for the special src .MAKE not working.
103 # setting it to + interferes with -N
104 _+_             ?=
105 .elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
106 # the check above matches only a single -n, so -n -n will result
107 # in _+_ = +
108 _+_             ?=
109 .else
110 _+_             ?=      +
111 .endif
112
113 .if defined(%POSIX)
114 FC              ?=      fort77
115 FFLAGS          ?=      -O 1
116 .else
117 FC              ?=      f77
118 FFLAGS          ?=      -O
119 .endif
120 EFLAGS          ?=
121
122 INSTALL         ?=      install
123
124 LEX             ?=      lex
125 LFLAGS          ?=
126
127 LD              ?=      ld
128 LDFLAGS         ?=
129
130 LINT            ?=      lint
131 LINTFLAGS       ?=      -cghapbx
132 LINTKERNFLAGS   ?=      ${LINTFLAGS}
133 LINTOBJFLAGS    ?=      -cghapbxu -i
134 LINTOBJKERNFLAGS?=      ${LINTOBJFLAGS}
135 LINTLIBFLAGS    ?=      -cghapbxu -C ${LIB}
136
137 MAKE            ?=      make
138
139 .if !defined(%POSIX)
140 NM              ?=      nm
141
142 OBJC            ?=      cc
143 OBJCFLAGS       ?=      ${OBJCINCLUDES} ${CFLAGS} -Wno-import
144
145 OBJCOPY         ?=      objcopy
146
147 PC              ?=      pc
148 PFLAGS          ?=
149
150 RC              ?=      f77
151 RFLAGS          ?=
152 .endif
153
154 SHELL           ?=      sh
155
156 YACC            ?=      yacc
157 .if defined(%POSIX)
158 YFLAGS          ?=
159 .else
160 YFLAGS          ?=      -d
161 .endif
162
163 .if defined(%POSIX)
164
165 # Posix 1003.2 mandated rules
166 #
167 # Quoted directly from the Posix 1003.2 draft, only the macros
168 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
169 # ${.PREFIX}, resp.
170
171 # SINGLE SUFFIX RULES
172 .c:
173         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
174         ${CTFCONVERT_CMD}
175
176 .f:
177         ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
178         ${CTFCONVERT_CMD}
179
180 .sh:
181         cp -f ${.IMPSRC} ${.TARGET}
182         chmod a+x ${.TARGET}
183
184 # DOUBLE SUFFIX RULES
185
186 .c.o:
187         ${CC} ${CFLAGS} -c ${.IMPSRC}
188         ${CTFCONVERT_CMD}
189
190 .f.o:
191         ${FC} ${FFLAGS} -c ${.IMPSRC}
192         ${CTFCONVERT_CMD}
193
194 .y.o:
195         ${YACC} ${YFLAGS} ${.IMPSRC}
196         ${CC} ${CFLAGS} -c y.tab.c
197         rm -f y.tab.c
198         mv y.tab.o ${.TARGET}
199         ${CTFCONVERT_CMD}
200
201 .l.o:
202         ${LEX} ${LFLAGS} ${.IMPSRC}
203         ${CC} ${CFLAGS} -c lex.yy.c
204         rm -f lex.yy.c
205         mv lex.yy.o ${.TARGET}
206         ${CTFCONVERT_CMD}
207
208 .y.c:
209         ${YACC} ${YFLAGS} ${.IMPSRC}
210         mv y.tab.c ${.TARGET}
211
212 .l.c:
213         ${LEX} ${LFLAGS} ${.IMPSRC}
214         mv lex.yy.c ${.TARGET}
215
216 .c.a:
217         ${CC} ${CFLAGS} -c ${.IMPSRC}
218         ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
219         rm -f ${.PREFIX}.o
220
221 .f.a:
222         ${FC} ${FFLAGS} -c ${.IMPSRC}
223         ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
224         rm -f ${.PREFIX}.o
225
226 .else
227
228 # non-Posix rule set
229
230 .sh:
231         cp -fp ${.IMPSRC} ${.TARGET}
232         chmod a+x ${.TARGET}
233
234 .c.ln:
235         ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
236             touch ${.TARGET}
237
238 .cc.ln .C.ln .cpp.ln .cxx.ln:
239         ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
240             touch ${.TARGET}
241
242 .c:
243         ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
244         ${CTFCONVERT_CMD}
245
246 .c.o:
247         ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
248         ${CTFCONVERT_CMD}
249
250 .cc .cpp .cxx .C:
251         ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
252
253 .cc.o .cpp.o .cxx.o .C.o:
254         ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
255
256 .m.o:
257         ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
258         ${CTFCONVERT_CMD}
259
260 .p.o:
261         ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET}
262         ${CTFCONVERT_CMD}
263
264 .e .r .F .f:
265         ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
266             -o ${.TARGET}
267
268 .e.o .r.o .F.o .f.o:
269         ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET}
270
271 .S.o:
272         ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
273         ${CTFCONVERT_CMD}
274
275 .asm.o:
276         ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
277             -o ${.TARGET}
278         ${CTFCONVERT_CMD}
279
280 .s.o:
281         ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
282         ${CTFCONVERT_CMD}
283
284 # XXX not -j safe
285 .y.o:
286         ${YACC} ${YFLAGS} ${.IMPSRC}
287         ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
288         rm -f y.tab.c
289         ${CTFCONVERT_CMD}
290
291 .l.o:
292         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
293         ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
294         rm -f ${.PREFIX}.tmp.c
295         ${CTFCONVERT_CMD}
296
297 # XXX not -j safe
298 .y.c:
299         ${YACC} ${YFLAGS} ${.IMPSRC}
300         mv y.tab.c ${.TARGET}
301
302 .l.c:
303         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
304
305 .s.out .c.out .o.out:
306         ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
307         ${CTFCONVERT_CMD}
308
309 .f.out .F.out .r.out .e.out:
310         ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
311             ${LDLIBS} -o ${.TARGET}
312         rm -f ${.PREFIX}.o
313         ${CTFCONVERT_CMD}
314
315 # XXX not -j safe
316 .y.out:
317         ${YACC} ${YFLAGS} ${.IMPSRC}
318         ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
319         rm -f y.tab.c
320         ${CTFCONVERT_CMD}
321
322 .l.out:
323         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
324         ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
325         rm -f ${.PREFIX}.tmp.c
326         ${CTFCONVERT_CMD}
327
328 # FreeBSD build pollution.  Hide it in the non-POSIX part of the ifdef.
329 __MAKE_CONF?=/etc/make.conf
330 .if exists(${__MAKE_CONF})
331 .include "${__MAKE_CONF}"
332 .endif
333
334 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
335 SHELL=  ${__MAKE_SHELL}
336 .SHELL: path=${__MAKE_SHELL}
337 .endif
338
339 .if !defined(.PARSEDIR)
340 # We are not bmake, which is more aggressive about searching .PATH
341 # It is sometime necessary to curb its enthusiasm with .NOPATH
342 # The following allows us to quietly ignore .NOPATH when not using bmake.
343 .NOTMAIN: .NOPATH
344 .NOPATH:
345
346 # Toggle on warnings
347 .WARN: dirsyntax
348 .endif
349
350 .endif
351
352 .if defined(.PARSEDIR)
353 # Tell bmake to expand -V VAR by default
354 .MAKE.EXPAND_VARIABLES= yes
355
356 # Tell bmake the makefile preference
357 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
358
359 # By default bmake does *not* use set -e
360 # when running target scripts, this is a problem for many makefiles here.
361 # So define a shell that will do what FreeBSD expects.
362 .ifndef WITHOUT_SHELL_ERRCTL
363 .SHELL: name=sh \
364         quiet="set -" echo="set -v" filter="set -" \
365         hasErrCtl=yes check="set -e" ignore="set +e" \
366         echoFlag=v errFlag=e \
367         path=${__MAKE_SHELL:U/bin/sh}
368 .endif
369
370 .endif
371
372 .include <bsd.cpu.mk>