]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/sys.mk
MFV r277782:
[FreeBSD/FreeBSD.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|hf)?/arm/:C/powerpc64/powerpc/}
17 .endif
18
19 # If the special target .POSIX appears (without prerequisites or
20 # commands) before the first noncomment line in the makefile, make shall
21 # process the makefile as specified by the Posix 1003.2 specification.
22 # make(1) sets the special macro %POSIX in this case (to the actual
23 # value "1003.2", for what it's worth).
24 #
25 # The rules below use this macro to distinguish between Posix-compliant
26 # and default behaviour.
27
28 .if defined(%POSIX)
29 .SUFFIXES:      .o .c .y .l .a .sh .f
30 .else
31 .SUFFIXES:      .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
32 .endif
33
34 AR              ?=      ar
35 .if defined(%POSIX)
36 ARFLAGS         ?=      -rv
37 .else
38 ARFLAGS         ?=      -crD
39 .endif
40 RANLIB          ?=      ranlib
41 .if !defined(%POSIX)
42 RANLIBFLAGS     ?=      -D
43 .endif
44
45 AS              ?=      as
46 AFLAGS          ?=
47 ACFLAGS         ?=
48
49 .if defined(%POSIX)
50 CC              ?=      c89
51 CFLAGS          ?=      -O
52 .else
53 CC              ?=      cc
54 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
55 CFLAGS          ?=      -O -pipe
56 .else
57 CFLAGS          ?=      -O2 -pipe
58 .endif
59 .if defined(NO_STRICT_ALIASING)
60 CFLAGS          +=      -fno-strict-aliasing
61 .endif
62 .endif
63 PO_CFLAGS       ?=      ${CFLAGS}
64
65 # C Type Format data is required for DTrace
66 CTFFLAGS        ?=      -L VERSION
67
68 CTFCONVERT      ?=      ctfconvert
69 CTFMERGE        ?=      ctfmerge
70
71 # cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
72 # read-only files as non-root by passing -f.
73 CP              ?=      cp -f
74
75 DTRACE          ?=      dtrace
76 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
77 CTFFLAGS        +=      -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         ?=                              # LDFLAGS is for CC, 
126 _LDFLAGS        =       ${LDFLAGS:S/-Wl,//g}    # strip -Wl, for LD
127
128 LINT            ?=      lint
129 LINTFLAGS       ?=      -cghapbx
130 LINTKERNFLAGS   ?=      ${LINTFLAGS}
131 LINTOBJFLAGS    ?=      -cghapbxu -i
132 LINTOBJKERNFLAGS?=      ${LINTOBJFLAGS}
133 LINTLIBFLAGS    ?=      -cghapbxu -C ${LIB}
134
135 MAKE            ?=      make
136
137 .if !defined(%POSIX)
138 NM              ?=      nm
139
140 OBJC            ?=      cc
141 OBJCFLAGS       ?=      ${OBJCINCLUDES} ${CFLAGS} -Wno-import
142
143 OBJCOPY         ?=      objcopy
144
145 OBJDUMP         ?=      objdump
146
147 PC              ?=      pc
148 PFLAGS          ?=
149
150 RC              ?=      f77
151 RFLAGS          ?=
152 .endif
153
154 SHELL           ?=      sh
155
156 .if !defined(%POSIX)
157 SIZE            ?=      size
158 .endif
159
160 YACC            ?=      yacc
161 .if defined(%POSIX)
162 YFLAGS          ?=
163 .else
164 YFLAGS          ?=      -d
165 .endif
166
167 .if defined(%POSIX)
168
169 # Posix 1003.2 mandated rules
170 #
171 # Quoted directly from the Posix 1003.2 draft, only the macros
172 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
173 # ${.PREFIX}, resp.
174
175 # SINGLE SUFFIX RULES
176 .c:
177         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
178
179 .f:
180         ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
181
182 .sh:
183         cp -f ${.IMPSRC} ${.TARGET}
184         chmod a+x ${.TARGET}
185
186 # DOUBLE SUFFIX RULES
187
188 .c.o:
189         ${CC} ${CFLAGS} -c ${.IMPSRC}
190
191 .f.o:
192         ${FC} ${FFLAGS} -c ${.IMPSRC}
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
200 .l.o:
201         ${LEX} ${LFLAGS} ${.IMPSRC}
202         ${CC} ${CFLAGS} -c lex.yy.c
203         rm -f lex.yy.c
204         mv lex.yy.o ${.TARGET}
205
206 .y.c:
207         ${YACC} ${YFLAGS} ${.IMPSRC}
208         mv y.tab.c ${.TARGET}
209
210 .l.c:
211         ${LEX} ${LFLAGS} ${.IMPSRC}
212         mv lex.yy.c ${.TARGET}
213
214 .c.a:
215         ${CC} ${CFLAGS} -c ${.IMPSRC}
216         ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
217         rm -f ${.PREFIX}.o
218
219 .f.a:
220         ${FC} ${FFLAGS} -c ${.IMPSRC}
221         ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
222         rm -f ${.PREFIX}.o
223
224 .else
225
226 # non-Posix rule set
227
228 .sh:
229         cp -fp ${.IMPSRC} ${.TARGET}
230         chmod a+x ${.TARGET}
231
232 .c.ln:
233         ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
234             touch ${.TARGET}
235
236 .cc.ln .C.ln .cpp.ln .cxx.ln:
237         ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
238             touch ${.TARGET}
239
240 .c:
241         ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
242         ${CTFCONVERT_CMD}
243
244 .c.o:
245         ${CC} ${CFLAGS} -c ${.IMPSRC}
246         ${CTFCONVERT_CMD}
247
248 .cc .cpp .cxx .C:
249         ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
250
251 .cc.o .cpp.o .cxx.o .C.o:
252         ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
253
254 .m.o:
255         ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
256         ${CTFCONVERT_CMD}
257
258 .p.o:
259         ${PC} ${PFLAGS} -c ${.IMPSRC}
260         ${CTFCONVERT_CMD}
261
262 .e .r .F .f:
263         ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
264             -o ${.TARGET}
265
266 .e.o .r.o .F.o .f.o:
267         ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
268
269 .S.o:
270         ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
271         ${CTFCONVERT_CMD}
272
273 .asm.o:
274         ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
275         ${CTFCONVERT_CMD}
276
277 .s.o:
278         ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
279         ${CTFCONVERT_CMD}
280
281 # XXX not -j safe
282 .y.o:
283         ${YACC} ${YFLAGS} ${.IMPSRC}
284         ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
285         rm -f y.tab.c
286         ${CTFCONVERT_CMD}
287
288 .l.o:
289         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
290         ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
291         rm -f ${.PREFIX}.tmp.c
292         ${CTFCONVERT_CMD}
293
294 # XXX not -j safe
295 .y.c:
296         ${YACC} ${YFLAGS} ${.IMPSRC}
297         mv y.tab.c ${.TARGET}
298
299 .l.c:
300         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
301
302 .s.out .c.out .o.out:
303         ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
304         ${CTFCONVERT_CMD}
305
306 .f.out .F.out .r.out .e.out:
307         ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
308             ${LDLIBS} -o ${.TARGET}
309         rm -f ${.PREFIX}.o
310         ${CTFCONVERT_CMD}
311
312 # XXX not -j safe
313 .y.out:
314         ${YACC} ${YFLAGS} ${.IMPSRC}
315         ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
316         rm -f y.tab.c
317         ${CTFCONVERT_CMD}
318
319 .l.out:
320         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
321         ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
322         rm -f ${.PREFIX}.tmp.c
323         ${CTFCONVERT_CMD}
324
325 # Pull in global settings.
326 __MAKE_CONF?=/etc/make.conf
327 .if exists(${__MAKE_CONF})
328 .include "${__MAKE_CONF}"
329 .endif
330
331 # Setup anything for the FreeBSD source build, if we're building
332 # inside the source tree. Needs to be after make.conf, but before
333 # local stuff.
334 .sinclude <src.sys.mk>
335
336 # Set any local definitions first. Place this early, but it needs
337 # MACHINE_CPUARCH to be defined.
338 .sinclude <local.sys.mk>
339
340 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
341 SHELL=  ${__MAKE_SHELL}
342 .SHELL: path=${__MAKE_SHELL}
343 .endif
344
345 .if !defined(.PARSEDIR)
346 # We are not bmake, which is more aggressive about searching .PATH
347 # It is sometime necessary to curb its enthusiasm with .NOPATH
348 # The following allows us to quietly ignore .NOPATH when not using bmake.
349 .NOTMAIN: .NOPATH
350 .NOPATH:
351
352 # Toggle on warnings
353 .WARN: dirsyntax
354 .else # is bmake
355 # Tell bmake to expand -V VAR by default
356 .MAKE.EXPAND_VARIABLES= yes
357
358 # Tell bmake the makefile preference
359 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
360
361 # By default bmake does *not* use set -e
362 # when running target scripts, this is a problem for many makefiles here.
363 # So define a shell that will do what FreeBSD expects.
364 .ifndef WITHOUT_SHELL_ERRCTL
365 .SHELL: name=sh \
366         quiet="set -" echo="set -v" filter="set -" \
367         hasErrCtl=yes check="set -e" ignore="set +e" \
368         echoFlag=v errFlag=e \
369         path=${__MAKE_SHELL:U/bin/sh}
370 .endif
371 .endif # bmake
372
373 .include <bsd.cpu.mk>
374
375 .endif # ! Posix