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/}
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).
25 # The rules below use this macro to distinguish between Posix-compliant
26 # and default behaviour.
29 .SUFFIXES: .o .c .y .l .a .sh .f
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
54 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
59 .if defined(NO_STRICT_ALIASING)
60 CFLAGS += -fno-strict-aliasing
63 PO_CFLAGS ?= ${CFLAGS}
65 # C Type Format data is required for DTrace
66 CTFFLAGS ?= -L VERSION
68 CTFCONVERT ?= ctfconvert
71 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
76 CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
77 PO_CXXFLAGS ?= ${CXXFLAGS}
81 .if empty(.MAKEFLAGS:M-s)
86 .if ${.MAKEFLAGS:M-s} == "-s"
93 .if defined(.PARSEDIR)
94 # _+_ appears to be a workaround for the special src .MAKE not working.
95 # setting it to + interferes with -N
97 .elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
98 # the check above matches only a single -n, so -n -n will result
120 LDFLAGS ?= # LDFLAGS is for CC,
121 _LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD
124 LINTFLAGS ?= -cghapbx
125 LINTKERNFLAGS ?= ${LINTFLAGS}
126 LINTOBJFLAGS ?= -cghapbxu -i
127 LINTOBJKERNFLAGS?= ${LINTOBJFLAGS}
128 LINTLIBFLAGS ?= -cghapbxu -C ${LIB}
136 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
164 # Posix 1003.2 mandated rules
166 # Quoted directly from the Posix 1003.2 draft, only the macros
167 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
170 # SINGLE SUFFIX RULES
172 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
175 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
178 cp -f ${.IMPSRC} ${.TARGET}
181 # DOUBLE SUFFIX RULES
184 ${CC} ${CFLAGS} -c ${.IMPSRC}
187 ${FC} ${FFLAGS} -c ${.IMPSRC}
190 ${YACC} ${YFLAGS} ${.IMPSRC}
191 ${CC} ${CFLAGS} -c y.tab.c
193 mv y.tab.o ${.TARGET}
196 ${LEX} ${LFLAGS} ${.IMPSRC}
197 ${CC} ${CFLAGS} -c lex.yy.c
199 mv lex.yy.o ${.TARGET}
202 ${YACC} ${YFLAGS} ${.IMPSRC}
203 mv y.tab.c ${.TARGET}
206 ${LEX} ${LFLAGS} ${.IMPSRC}
207 mv lex.yy.c ${.TARGET}
210 ${CC} ${CFLAGS} -c ${.IMPSRC}
211 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
215 ${FC} ${FFLAGS} -c ${.IMPSRC}
216 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
224 cp -fp ${.IMPSRC} ${.TARGET}
228 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
231 .cc.ln .C.ln .cpp.ln .cxx.ln:
232 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
236 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
240 ${CC} ${CFLAGS} -c ${.IMPSRC}
244 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
246 .cc.o .cpp.o .cxx.o .C.o:
247 ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
250 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
254 ${PC} ${PFLAGS} -c ${.IMPSRC}
258 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
262 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
265 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
269 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
273 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
278 ${YACC} ${YFLAGS} ${.IMPSRC}
279 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
284 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
285 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
286 rm -f ${.PREFIX}.tmp.c
291 ${YACC} ${YFLAGS} ${.IMPSRC}
292 mv y.tab.c ${.TARGET}
295 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
297 .s.out .c.out .o.out:
298 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
301 .f.out .F.out .r.out .e.out:
302 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
303 ${LDLIBS} -o ${.TARGET}
309 ${YACC} ${YFLAGS} ${.IMPSRC}
310 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
315 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
316 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
317 rm -f ${.PREFIX}.tmp.c
320 # Pull in global settings.
321 __MAKE_CONF?=/etc/make.conf
322 .if exists(${__MAKE_CONF})
323 .include "${__MAKE_CONF}"
326 # Setup anything for the FreeBSD source build, if we're building
327 # inside the source tree. Needs to be after make.conf, but before
329 .sinclude <src.sys.mk>
331 # Set any local definitions first. Place this early, but it needs
332 # MACHINE_CPUARCH to be defined.
333 .sinclude <local.sys.mk>
335 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
336 SHELL= ${__MAKE_SHELL}
337 .SHELL: path=${__MAKE_SHELL}
340 .if !defined(.PARSEDIR)
341 # We are not bmake, which is more aggressive about searching .PATH
342 # It is sometime necessary to curb its enthusiasm with .NOPATH
343 # The following allows us to quietly ignore .NOPATH when not using bmake.
350 # Tell bmake to expand -V VAR by default
351 .MAKE.EXPAND_VARIABLES= yes
353 # Tell bmake the makefile preference
354 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
356 # By default bmake does *not* use set -e
357 # when running target scripts, this is a problem for many makefiles here.
358 # So define a shell that will do what FreeBSD expects.
359 .ifndef WITHOUT_SHELL_ERRCTL
361 quiet="set -" echo="set -v" filter="set -" \
362 hasErrCtl=yes check="set -e" ignore="set +e" \
363 echoFlag=v errFlag=e \
364 path=${__MAKE_SHELL:U/bin/sh}
368 .include <bsd.cpu.mk>