]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/sys.mk
Add initial testcases for bin/ls
[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
20 # Some options we need now
21 __DEFAULT_NO_OPTIONS= \
22         DIRDEPS_CACHE \
23         META_MODE \
24         META_FILES \
25
26
27 __DEFAULT_DEPENDENT_OPTIONS= \
28         AUTO_OBJ/META_MODE \
29         STAGING/META_MODE \
30         SYSROOT/META_MODE
31
32 __ENV_ONLY_OPTIONS:= \
33         ${__DEFAULT_NO_OPTIONS} \
34         ${__DEFAULT_YES_OPTIONS} \
35         ${__DEFAULT_DEPENDENT_OPTIONS:H}
36
37 # early include for customization
38 # see local.sys.mk below
39 # Not included when building in fmake compatibility mode (still needed
40 # for older system support)
41 .if defined(.PARSEDIR)
42 .sinclude <local.sys.env.mk>
43
44 .include <bsd.mkopt.mk>
45
46 .if ${MK_META_MODE} == "yes"
47 .sinclude <meta.sys.mk>
48 .elif ${MK_META_FILES} == "yes" && defined(.MAKEFLAGS)
49 .if ${.MAKEFLAGS:M-B} == ""
50 .MAKE.MODE= meta verbose
51 .endif
52 .endif
53 .if ${MK_AUTO_OBJ} == "yes"
54 # This needs to be done early - before .PATH is computed
55 # Don't do this if just running 'make -V' (but do when inspecting .OBJDIR) or
56 # 'make showconfig' (during makeman which enables all options when meta mode
57 # is not expected)
58 .if (${.MAKEFLAGS:M-V} == "" || ${.MAKEFLAGS:M.OBJDIR} != "") && \
59     !make(showconfig)
60 .sinclude <auto.obj.mk>
61 .endif
62 .endif
63 .else # bmake
64 .include <bsd.mkopt.mk>
65 .endif
66
67 # If the special target .POSIX appears (without prerequisites or
68 # commands) before the first noncomment line in the makefile, make shall
69 # process the makefile as specified by the Posix 1003.2 specification.
70 # make(1) sets the special macro %POSIX in this case (to the actual
71 # value "1003.2", for what it's worth).
72 #
73 # The rules below use this macro to distinguish between Posix-compliant
74 # and default behaviour.
75
76 .if defined(%POSIX)
77 .SUFFIXES:      .o .c .y .l .a .sh .f
78 .else
79 .SUFFIXES:      .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
80 .endif
81
82 AR              ?=      ar
83 .if defined(%POSIX)
84 ARFLAGS         ?=      -rv
85 .else
86 ARFLAGS         ?=      -crD
87 .endif
88 RANLIB          ?=      ranlib
89 .if !defined(%POSIX)
90 RANLIBFLAGS     ?=      -D
91 .endif
92
93 AS              ?=      as
94 AFLAGS          ?=
95 ACFLAGS         ?=
96
97 .if defined(%POSIX)
98 CC              ?=      c89
99 CFLAGS          ?=      -O
100 .else
101 CC              ?=      cc
102 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
103 CFLAGS          ?=      -O -pipe
104 .else
105 CFLAGS          ?=      -O2 -pipe
106 .endif
107 .if defined(NO_STRICT_ALIASING)
108 CFLAGS          +=      -fno-strict-aliasing
109 .endif
110 .endif
111 PO_CFLAGS       ?=      ${CFLAGS}
112
113 # cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
114 # read-only files as non-root by passing -f.
115 CP              ?=      cp -f
116
117 CPP             ?=      cpp
118
119 # C Type Format data is required for DTrace
120 CTFFLAGS        ?=      -L VERSION
121
122 CTFCONVERT      ?=      ctfconvert
123 CTFMERGE        ?=      ctfmerge
124
125 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
126 CTFFLAGS        +=      -g
127 .endif
128
129 CXX             ?=      c++
130 CXXFLAGS        ?=      ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
131 PO_CXXFLAGS     ?=      ${CXXFLAGS}
132
133 DTRACE          ?=      dtrace
134 DTRACEFLAGS     ?=      -C -x nolibs
135
136 .if empty(.MAKEFLAGS:M-s)
137 ECHO            ?=      echo
138 ECHODIR         ?=      echo
139 .else
140 ECHO            ?=      true
141 .if ${.MAKEFLAGS:M-s} == "-s"
142 ECHODIR         ?=      echo
143 .else
144 ECHODIR         ?=      true
145 .endif
146 .endif
147
148 .if defined(.PARSEDIR)
149 # _+_ appears to be a workaround for the special src .MAKE not working.
150 # setting it to + interferes with -N
151 _+_             ?=
152 .elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
153 # the check above matches only a single -n, so -n -n will result
154 # in _+_ = +
155 _+_             ?=
156 .else
157 _+_             ?=      +
158 .endif
159
160 .if defined(%POSIX)
161 FC              ?=      fort77
162 FFLAGS          ?=      -O 1
163 .else
164 FC              ?=      f77
165 FFLAGS          ?=      -O
166 .endif
167 EFLAGS          ?=
168
169 INSTALL         ?=      install
170
171 LEX             ?=      lex
172 LFLAGS          ?=
173
174 LD              ?=      ld
175 LDFLAGS         ?=                              # LDFLAGS is for CC, 
176 _LDFLAGS        =       ${LDFLAGS:S/-Wl,//g}    # strip -Wl, for LD
177
178 LINT            ?=      lint
179 LINTFLAGS       ?=      -cghapbx
180 LINTKERNFLAGS   ?=      ${LINTFLAGS}
181 LINTOBJFLAGS    ?=      -cghapbxu -i
182 LINTOBJKERNFLAGS?=      ${LINTOBJFLAGS}
183 LINTLIBFLAGS    ?=      -cghapbxu -C ${LIB}
184
185 MAKE            ?=      make
186
187 .if !defined(%POSIX)
188 NM              ?=      nm
189 NMFLAGS         ?=
190
191 OBJC            ?=      cc
192 OBJCFLAGS       ?=      ${OBJCINCLUDES} ${CFLAGS} -Wno-import
193
194 OBJCOPY         ?=      objcopy
195
196 OBJDUMP         ?=      objdump
197
198 PC              ?=      pc
199 PFLAGS          ?=
200
201 RC              ?=      f77
202 RFLAGS          ?=
203 .endif
204
205 SHELL           ?=      sh
206
207 .if !defined(%POSIX)
208 SIZE            ?=      size
209 .endif
210
211 YACC            ?=      yacc
212 .if defined(%POSIX)
213 YFLAGS          ?=
214 .else
215 YFLAGS          ?=      -d
216 .endif
217
218 .if defined(%POSIX)
219
220 # Posix 1003.2 mandated rules
221 #
222 # Quoted directly from the Posix 1003.2 draft, only the macros
223 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
224 # ${.PREFIX}, resp.
225
226 # SINGLE SUFFIX RULES
227 .c:
228         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
229
230 .f:
231         ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
232
233 .sh:
234         cp -f ${.IMPSRC} ${.TARGET}
235         chmod a+x ${.TARGET}
236
237 # DOUBLE SUFFIX RULES
238
239 .c.o:
240         ${CC} ${CFLAGS} -c ${.IMPSRC}
241
242 .f.o:
243         ${FC} ${FFLAGS} -c ${.IMPSRC}
244
245 .y.o:
246         ${YACC} ${YFLAGS} ${.IMPSRC}
247         ${CC} ${CFLAGS} -c y.tab.c
248         rm -f y.tab.c
249         mv y.tab.o ${.TARGET}
250
251 .l.o:
252         ${LEX} ${LFLAGS} ${.IMPSRC}
253         ${CC} ${CFLAGS} -c lex.yy.c
254         rm -f lex.yy.c
255         mv lex.yy.o ${.TARGET}
256
257 .y.c:
258         ${YACC} ${YFLAGS} ${.IMPSRC}
259         mv y.tab.c ${.TARGET}
260
261 .l.c:
262         ${LEX} ${LFLAGS} ${.IMPSRC}
263         mv lex.yy.c ${.TARGET}
264
265 .c.a:
266         ${CC} ${CFLAGS} -c ${.IMPSRC}
267         ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
268         rm -f ${.PREFIX}.o
269
270 .f.a:
271         ${FC} ${FFLAGS} -c ${.IMPSRC}
272         ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
273         rm -f ${.PREFIX}.o
274
275 .else
276
277 # non-Posix rule set
278
279 .sh:
280         cp -fp ${.IMPSRC} ${.TARGET}
281         chmod a+x ${.TARGET}
282
283 .c.ln:
284         ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
285             touch ${.TARGET}
286
287 .cc.ln .C.ln .cpp.ln .cxx.ln:
288         ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
289             touch ${.TARGET}
290
291 .c:
292         ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
293         ${CTFCONVERT_CMD}
294
295 .c.o:
296         ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
297         ${CTFCONVERT_CMD}
298
299 .cc .cpp .cxx .C:
300         ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
301
302 .cc.o .cpp.o .cxx.o .C.o:
303         ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
304
305 .m.o:
306         ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
307         ${CTFCONVERT_CMD}
308
309 .p.o:
310         ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET}
311         ${CTFCONVERT_CMD}
312
313 .e .r .F .f:
314         ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
315             -o ${.TARGET}
316
317 .e.o .r.o .F.o .f.o:
318         ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET}
319
320 .S.o:
321         ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
322         ${CTFCONVERT_CMD}
323
324 .asm.o:
325         ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
326             -o ${.TARGET}
327         ${CTFCONVERT_CMD}
328
329 .s.o:
330         ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
331         ${CTFCONVERT_CMD}
332
333 # XXX not -j safe
334 .y.o:
335         ${YACC} ${YFLAGS} ${.IMPSRC}
336         ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
337         rm -f y.tab.c
338         ${CTFCONVERT_CMD}
339
340 .l.o:
341         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
342         ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
343         rm -f ${.PREFIX}.tmp.c
344         ${CTFCONVERT_CMD}
345
346 # XXX not -j safe
347 .y.c:
348         ${YACC} ${YFLAGS} ${.IMPSRC}
349         mv y.tab.c ${.TARGET}
350
351 .l.c:
352         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
353
354 .s.out .c.out .o.out:
355         ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
356         ${CTFCONVERT_CMD}
357
358 .f.out .F.out .r.out .e.out:
359         ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
360             ${LDLIBS} -o ${.TARGET}
361         rm -f ${.PREFIX}.o
362         ${CTFCONVERT_CMD}
363
364 # XXX not -j safe
365 .y.out:
366         ${YACC} ${YFLAGS} ${.IMPSRC}
367         ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
368         rm -f y.tab.c
369         ${CTFCONVERT_CMD}
370
371 .l.out:
372         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
373         ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
374         rm -f ${.PREFIX}.tmp.c
375         ${CTFCONVERT_CMD}
376
377 # Pull in global settings.
378 __MAKE_CONF?=/etc/make.conf
379 .if exists(${__MAKE_CONF})
380 .include "${__MAKE_CONF}"
381 .endif
382
383 # late include for customization
384 .sinclude <local.sys.mk>
385
386 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
387 SHELL=  ${__MAKE_SHELL}
388 .SHELL: path=${__MAKE_SHELL}
389 .endif
390
391 # Tell bmake to expand -V VAR by default
392 .MAKE.EXPAND_VARIABLES= yes
393
394 # Tell bmake the makefile preference
395 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
396
397 # Tell bmake to always pass job tokens, regardless of target depending on
398 # .MAKE or looking like ${MAKE}/${.MAKE}/$(MAKE)/$(.MAKE)/make.
399 .MAKE.ALWAYS_PASS_JOB_QUEUE= yes
400
401 # By default bmake does *not* use set -e
402 # when running target scripts, this is a problem for many makefiles here.
403 # So define a shell that will do what FreeBSD expects.
404 .ifndef WITHOUT_SHELL_ERRCTL
405 __MAKE_SHELL?=/bin/sh
406 .SHELL: name=sh \
407         quiet="set -" echo="set -v" filter="set -" \
408         hasErrCtl=yes check="set -e" ignore="set +e" \
409         echoFlag=v errFlag=e \
410         path=${__MAKE_SHELL}
411 .endif
412
413 .include <bsd.cpu.mk>
414
415 .endif # ! Posix