1 # from: @(#)sys.mk 8.2 (Berkeley) 3/21/94
4 unix ?= We run FreeBSD, not UNIX.
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.
16 MACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/powerpc64/powerpc/}
20 # Some options we need now
21 __DEFAULT_NO_OPTIONS= \
27 __DEFAULT_DEPENDENT_OPTIONS= \
32 __ENV_ONLY_OPTIONS:= \
33 ${__DEFAULT_NO_OPTIONS} \
34 ${__DEFAULT_YES_OPTIONS} \
35 ${__DEFAULT_DEPENDENT_OPTIONS:H}
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>
44 .include <bsd.mkopt.mk>
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
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
58 .if (${.MAKEFLAGS:M-V} == "" || ${.MAKEFLAGS:M.OBJDIR} != "") && \
60 .sinclude <auto.obj.mk>
64 .include <bsd.mkopt.mk>
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).
73 # The rules below use this macro to distinguish between Posix-compliant
74 # and default behaviour.
77 .SUFFIXES: .o .c .y .l .a .sh .f
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
102 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
107 .if defined(NO_STRICT_ALIASING)
108 CFLAGS += -fno-strict-aliasing
111 PO_CFLAGS ?= ${CFLAGS}
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.
119 # C Type Format data is required for DTrace
120 CTFFLAGS ?= -L VERSION
122 CTFCONVERT ?= ctfconvert
125 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
130 CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
131 PO_CXXFLAGS ?= ${CXXFLAGS}
134 DTRACEFLAGS ?= -C -x nolibs
136 .if empty(.MAKEFLAGS:M-s)
141 .if ${.MAKEFLAGS:M-s} == "-s"
148 .if defined(.PARSEDIR)
149 # _+_ appears to be a workaround for the special src .MAKE not working.
150 # setting it to + interferes with -N
152 .elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
153 # the check above matches only a single -n, so -n -n will result
175 LDFLAGS ?= # LDFLAGS is for CC,
176 _LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD
179 LINTFLAGS ?= -cghapbx
180 LINTKERNFLAGS ?= ${LINTFLAGS}
181 LINTOBJFLAGS ?= -cghapbxu -i
182 LINTOBJKERNFLAGS?= ${LINTOBJFLAGS}
183 LINTLIBFLAGS ?= -cghapbxu -C ${LIB}
192 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
220 # Posix 1003.2 mandated rules
222 # Quoted directly from the Posix 1003.2 draft, only the macros
223 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
226 # SINGLE SUFFIX RULES
228 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
231 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
234 cp -f ${.IMPSRC} ${.TARGET}
237 # DOUBLE SUFFIX RULES
240 ${CC} ${CFLAGS} -c ${.IMPSRC}
243 ${FC} ${FFLAGS} -c ${.IMPSRC}
246 ${YACC} ${YFLAGS} ${.IMPSRC}
247 ${CC} ${CFLAGS} -c y.tab.c
249 mv y.tab.o ${.TARGET}
252 ${LEX} ${LFLAGS} ${.IMPSRC}
253 ${CC} ${CFLAGS} -c lex.yy.c
255 mv lex.yy.o ${.TARGET}
258 ${YACC} ${YFLAGS} ${.IMPSRC}
259 mv y.tab.c ${.TARGET}
262 ${LEX} ${LFLAGS} ${.IMPSRC}
263 mv lex.yy.c ${.TARGET}
266 ${CC} ${CFLAGS} -c ${.IMPSRC}
267 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
271 ${FC} ${FFLAGS} -c ${.IMPSRC}
272 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
280 cp -fp ${.IMPSRC} ${.TARGET}
284 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
287 .cc.ln .C.ln .cpp.ln .cxx.ln:
288 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
292 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
296 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
300 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
302 .cc.o .cpp.o .cxx.o .C.o:
303 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
306 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
310 ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET}
314 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
318 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET}
321 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
325 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
330 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
335 ${YACC} ${YFLAGS} ${.IMPSRC}
336 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
341 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
342 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
343 rm -f ${.PREFIX}.tmp.c
348 ${YACC} ${YFLAGS} ${.IMPSRC}
349 mv y.tab.c ${.TARGET}
352 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
354 .s.out .c.out .o.out:
355 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
358 .f.out .F.out .r.out .e.out:
359 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
360 ${LDLIBS} -o ${.TARGET}
366 ${YACC} ${YFLAGS} ${.IMPSRC}
367 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
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
377 # Pull in global settings.
378 __MAKE_CONF?=/etc/make.conf
379 .if exists(${__MAKE_CONF})
380 .include "${__MAKE_CONF}"
383 # late include for customization
384 .sinclude <local.sys.mk>
386 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
387 SHELL= ${__MAKE_SHELL}
388 .SHELL: path=${__MAKE_SHELL}
391 # Tell bmake to expand -V VAR by default
392 .MAKE.EXPAND_VARIABLES= yes
394 # Tell bmake the makefile preference
395 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
397 # By default bmake does *not* use set -e
398 # when running target scripts, this is a problem for many makefiles here.
399 # So define a shell that will do what FreeBSD expects.
400 .ifndef WITHOUT_SHELL_ERRCTL
401 __MAKE_SHELL?=/bin/sh
403 quiet="set -" echo="set -v" filter="set -" \
404 hasErrCtl=yes check="set -e" ignore="set +e" \
405 echoFlag=v errFlag=e \
409 .include <bsd.cpu.mk>