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 .include <bsd.mkopt.mk>
34 # Pull in global settings.
35 __MAKE_CONF?=/etc/make.conf
36 .if exists(${__MAKE_CONF})
37 .include "${__MAKE_CONF}"
40 # Set any local definitions first. Place this early, but it needs
41 # MACHINE_CPUARCH to be defined.
42 .-include <local.sys.mk>
44 .if ${MK_META_MODE} == "yes"
45 .-include <meta.sys.mk>
46 .elif ${MK_META_FILES} == "yes" && ${.MAKEFLAGS:U:M-B} == ""
47 .MAKE.MODE= meta verbose
49 .if ${MK_AUTO_OBJ} == "yes"
50 # This needs to be done early - before .PATH is computed
51 .-include <auto.obj.mk>
54 # If the special target .POSIX appears (without prerequisites or
55 # commands) before the first noncomment line in the makefile, make shall
56 # process the makefile as specified by the Posix 1003.2 specification.
57 # make(1) sets the special macro %POSIX in this case (to the actual
58 # value "1003.2", for what it's worth).
60 # The rules below use this macro to distinguish between Posix-compliant
61 # and default behaviour.
64 .SUFFIXES: .o .c .y .l .a .sh .f
66 .SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
89 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
94 .if defined(NO_STRICT_ALIASING)
95 CFLAGS += -fno-strict-aliasing
98 PO_CFLAGS ?= ${CFLAGS}
100 # cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
101 # read-only files as non-root by passing -f.
106 # C Type Format data is required for DTrace
107 CTFFLAGS ?= -L VERSION
109 CTFCONVERT ?= ctfconvert
112 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
117 CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
118 PO_CXXFLAGS ?= ${CXXFLAGS}
121 DTRACEFLAGS ?= -C -x nolibs
123 .if empty(.MAKEFLAGS:M-s)
128 .if ${.MAKEFLAGS:M-s} == "-s"
135 .if defined(.PARSEDIR)
136 # _+_ appears to be a workaround for the special src .MAKE not working.
137 # setting it to + interferes with -N
139 .elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
140 # the check above matches only a single -n, so -n -n will result
162 LDFLAGS ?= # LDFLAGS is for CC,
163 _LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD
166 LINTFLAGS ?= -cghapbx
167 LINTKERNFLAGS ?= ${LINTFLAGS}
168 LINTOBJFLAGS ?= -cghapbxu -i
169 LINTOBJKERNFLAGS?= ${LINTOBJFLAGS}
170 LINTLIBFLAGS ?= -cghapbxu -C ${LIB}
178 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
206 # Posix 1003.2 mandated rules
208 # Quoted directly from the Posix 1003.2 draft, only the macros
209 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
212 # SINGLE SUFFIX RULES
214 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
217 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
220 cp -f ${.IMPSRC} ${.TARGET}
223 # DOUBLE SUFFIX RULES
226 ${CC} ${CFLAGS} -c ${.IMPSRC}
229 ${FC} ${FFLAGS} -c ${.IMPSRC}
232 ${YACC} ${YFLAGS} ${.IMPSRC}
233 ${CC} ${CFLAGS} -c y.tab.c
235 mv y.tab.o ${.TARGET}
238 ${LEX} ${LFLAGS} ${.IMPSRC}
239 ${CC} ${CFLAGS} -c lex.yy.c
241 mv lex.yy.o ${.TARGET}
244 ${YACC} ${YFLAGS} ${.IMPSRC}
245 mv y.tab.c ${.TARGET}
248 ${LEX} ${LFLAGS} ${.IMPSRC}
249 mv lex.yy.c ${.TARGET}
252 ${CC} ${CFLAGS} -c ${.IMPSRC}
253 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
257 ${FC} ${FFLAGS} -c ${.IMPSRC}
258 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
266 cp -fp ${.IMPSRC} ${.TARGET}
270 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
273 .cc.ln .C.ln .cpp.ln .cxx.ln:
274 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
278 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
282 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
286 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
288 .cc.o .cpp.o .cxx.o .C.o:
289 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
292 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
296 ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET}
300 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
304 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET}
307 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
311 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
316 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
321 ${YACC} ${YFLAGS} ${.IMPSRC}
322 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
327 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
328 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
329 rm -f ${.PREFIX}.tmp.c
334 ${YACC} ${YFLAGS} ${.IMPSRC}
335 mv y.tab.c ${.TARGET}
338 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
340 .s.out .c.out .o.out:
341 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
344 .f.out .F.out .r.out .e.out:
345 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
346 ${LDLIBS} -o ${.TARGET}
352 ${YACC} ${YFLAGS} ${.IMPSRC}
353 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
358 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
359 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
360 rm -f ${.PREFIX}.tmp.c
364 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
365 SHELL= ${__MAKE_SHELL}
366 .SHELL: path=${__MAKE_SHELL}
369 # Tell bmake to expand -V VAR by default
370 .MAKE.EXPAND_VARIABLES= yes
372 # Tell bmake the makefile preference
373 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
375 # By default bmake does *not* use set -e
376 # when running target scripts, this is a problem for many makefiles here.
377 # So define a shell that will do what FreeBSD expects.
378 .ifndef WITHOUT_SHELL_ERRCTL
380 quiet="set -" echo="set -v" filter="set -" \
381 hasErrCtl=yes check="set -e" ignore="set +e" \
382 echoFlag=v errFlag=e \
383 path=${__MAKE_SHELL:U/bin/sh}
386 .include <bsd.cpu.mk>