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 # cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
66 # read-only files as non-root by passing -f.
71 # C Type Format data is required for DTrace
72 CTFFLAGS ?= -L VERSION
74 CTFCONVERT ?= ctfconvert
77 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
82 CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
83 PO_CXXFLAGS ?= ${CXXFLAGS}
86 DTRACEFLAGS ?= -C -x nolibs
88 .if empty(.MAKEFLAGS:M-s)
93 .if ${.MAKEFLAGS:M-s} == "-s"
100 .if defined(.PARSEDIR)
101 # _+_ appears to be a workaround for the special src .MAKE not working.
102 # setting it to + interferes with -N
104 .elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
105 # the check above matches only a single -n, so -n -n will result
127 LDFLAGS ?= # LDFLAGS is for CC,
128 _LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD
131 LINTFLAGS ?= -cghapbx
132 LINTKERNFLAGS ?= ${LINTFLAGS}
133 LINTOBJFLAGS ?= -cghapbxu -i
134 LINTOBJKERNFLAGS?= ${LINTOBJFLAGS}
135 LINTLIBFLAGS ?= -cghapbxu -C ${LIB}
143 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
171 # Posix 1003.2 mandated rules
173 # Quoted directly from the Posix 1003.2 draft, only the macros
174 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
177 # SINGLE SUFFIX RULES
179 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
182 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
185 cp -f ${.IMPSRC} ${.TARGET}
188 # DOUBLE SUFFIX RULES
191 ${CC} ${CFLAGS} -c ${.IMPSRC}
194 ${FC} ${FFLAGS} -c ${.IMPSRC}
197 ${YACC} ${YFLAGS} ${.IMPSRC}
198 ${CC} ${CFLAGS} -c y.tab.c
200 mv y.tab.o ${.TARGET}
203 ${LEX} ${LFLAGS} ${.IMPSRC}
204 ${CC} ${CFLAGS} -c lex.yy.c
206 mv lex.yy.o ${.TARGET}
209 ${YACC} ${YFLAGS} ${.IMPSRC}
210 mv y.tab.c ${.TARGET}
213 ${LEX} ${LFLAGS} ${.IMPSRC}
214 mv lex.yy.c ${.TARGET}
217 ${CC} ${CFLAGS} -c ${.IMPSRC}
218 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
222 ${FC} ${FFLAGS} -c ${.IMPSRC}
223 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
231 cp -fp ${.IMPSRC} ${.TARGET}
235 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
238 .cc.ln .C.ln .cpp.ln .cxx.ln:
239 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
243 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
247 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
251 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
253 .cc.o .cpp.o .cxx.o .C.o:
254 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
257 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
261 ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET}
265 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
269 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET}
272 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
276 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
281 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
286 ${YACC} ${YFLAGS} ${.IMPSRC}
287 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
292 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
293 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
294 rm -f ${.PREFIX}.tmp.c
299 ${YACC} ${YFLAGS} ${.IMPSRC}
300 mv y.tab.c ${.TARGET}
303 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
305 .s.out .c.out .o.out:
306 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
309 .f.out .F.out .r.out .e.out:
310 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
311 ${LDLIBS} -o ${.TARGET}
317 ${YACC} ${YFLAGS} ${.IMPSRC}
318 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
323 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
324 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
325 rm -f ${.PREFIX}.tmp.c
328 # Pull in global settings.
329 __MAKE_CONF?=/etc/make.conf
330 .if exists(${__MAKE_CONF})
331 .include "${__MAKE_CONF}"
334 # Setup anything for the FreeBSD source build, if we're building
335 # inside the source tree. Needs to be after make.conf, but before
337 .sinclude <src.sys.mk>
339 # Set any local definitions first. Place this early, but it needs
340 # MACHINE_CPUARCH to be defined.
341 .sinclude <local.sys.mk>
343 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
344 SHELL= ${__MAKE_SHELL}
345 .SHELL: path=${__MAKE_SHELL}
348 .if !defined(.PARSEDIR)
349 # We are not bmake, which is more aggressive about searching .PATH
350 # It is sometime necessary to curb its enthusiasm with .NOPATH
351 # The following allows us to quietly ignore .NOPATH when not using bmake.
358 # Tell bmake to expand -V VAR by default
359 .MAKE.EXPAND_VARIABLES= yes
361 # Tell bmake the makefile preference
362 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
364 # By default bmake does *not* use set -e
365 # when running target scripts, this is a problem for many makefiles here.
366 # So define a shell that will do what FreeBSD expects.
367 .ifndef WITHOUT_SHELL_ERRCTL
369 quiet="set -" echo="set -v" filter="set -" \
370 hasErrCtl=yes check="set -e" ignore="set +e" \
371 echoFlag=v errFlag=e \
372 path=${__MAKE_SHELL:U/bin/sh}
376 .include <bsd.cpu.mk>