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 # cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
72 # read-only files as non-root by passing -f.
76 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
81 CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
82 PO_CXXFLAGS ?= ${CXXFLAGS}
86 .if empty(.MAKEFLAGS:M-s)
91 .if ${.MAKEFLAGS:M-s} == "-s"
98 .if defined(.PARSEDIR)
99 # _+_ appears to be a workaround for the special src .MAKE not working.
100 # setting it to + interferes with -N
102 .elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
103 # the check above matches only a single -n, so -n -n will result
125 LDFLAGS ?= # LDFLAGS is for CC,
126 _LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD
129 LINTFLAGS ?= -cghapbx
130 LINTKERNFLAGS ?= ${LINTFLAGS}
131 LINTOBJFLAGS ?= -cghapbxu -i
132 LINTOBJKERNFLAGS?= ${LINTOBJFLAGS}
133 LINTLIBFLAGS ?= -cghapbxu -C ${LIB}
141 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
169 # Posix 1003.2 mandated rules
171 # Quoted directly from the Posix 1003.2 draft, only the macros
172 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
175 # SINGLE SUFFIX RULES
177 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
180 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
183 cp -f ${.IMPSRC} ${.TARGET}
186 # DOUBLE SUFFIX RULES
189 ${CC} ${CFLAGS} -c ${.IMPSRC}
192 ${FC} ${FFLAGS} -c ${.IMPSRC}
195 ${YACC} ${YFLAGS} ${.IMPSRC}
196 ${CC} ${CFLAGS} -c y.tab.c
198 mv y.tab.o ${.TARGET}
201 ${LEX} ${LFLAGS} ${.IMPSRC}
202 ${CC} ${CFLAGS} -c lex.yy.c
204 mv lex.yy.o ${.TARGET}
207 ${YACC} ${YFLAGS} ${.IMPSRC}
208 mv y.tab.c ${.TARGET}
211 ${LEX} ${LFLAGS} ${.IMPSRC}
212 mv lex.yy.c ${.TARGET}
215 ${CC} ${CFLAGS} -c ${.IMPSRC}
216 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
220 ${FC} ${FFLAGS} -c ${.IMPSRC}
221 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
229 cp -fp ${.IMPSRC} ${.TARGET}
233 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
236 .cc.ln .C.ln .cpp.ln .cxx.ln:
237 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
241 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
245 ${CC} ${CFLAGS} -c ${.IMPSRC}
249 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
251 .cc.o .cpp.o .cxx.o .C.o:
252 ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
255 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
259 ${PC} ${PFLAGS} -c ${.IMPSRC}
263 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
267 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
270 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
274 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
278 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
283 ${YACC} ${YFLAGS} ${.IMPSRC}
284 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
289 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
290 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
291 rm -f ${.PREFIX}.tmp.c
296 ${YACC} ${YFLAGS} ${.IMPSRC}
297 mv y.tab.c ${.TARGET}
300 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
302 .s.out .c.out .o.out:
303 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
306 .f.out .F.out .r.out .e.out:
307 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
308 ${LDLIBS} -o ${.TARGET}
314 ${YACC} ${YFLAGS} ${.IMPSRC}
315 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
320 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
321 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
322 rm -f ${.PREFIX}.tmp.c
325 # Pull in global settings.
326 __MAKE_CONF?=/etc/make.conf
327 .if exists(${__MAKE_CONF})
328 .include "${__MAKE_CONF}"
331 # Setup anything for the FreeBSD source build, if we're building
332 # inside the source tree. Needs to be after make.conf, but before
334 .sinclude <src.sys.mk>
336 # Set any local definitions first. Place this early, but it needs
337 # MACHINE_CPUARCH to be defined.
338 .sinclude <local.sys.mk>
340 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
341 SHELL= ${__MAKE_SHELL}
342 .SHELL: path=${__MAKE_SHELL}
345 .if !defined(.PARSEDIR)
346 # We are not bmake, which is more aggressive about searching .PATH
347 # It is sometime necessary to curb its enthusiasm with .NOPATH
348 # The following allows us to quietly ignore .NOPATH when not using bmake.
355 # Tell bmake to expand -V VAR by default
356 .MAKE.EXPAND_VARIABLES= yes
358 # Tell bmake the makefile preference
359 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
361 # By default bmake does *not* use set -e
362 # when running target scripts, this is a problem for many makefiles here.
363 # So define a shell that will do what FreeBSD expects.
364 .ifndef WITHOUT_SHELL_ERRCTL
366 quiet="set -" echo="set -v" filter="set -" \
367 hasErrCtl=yes check="set -e" ignore="set +e" \
368 echoFlag=v errFlag=e \
369 path=${__MAKE_SHELL:U/bin/sh}
373 .include <bsd.cpu.mk>