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