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)?/arm/:C/powerpc64/powerpc/}
19 # Set any local definitions first. Place this early, but it needs
20 # MACHINE_CPUARCH to be defined.
21 .sinclude <local.sys.mk>
23 # If the special target .POSIX appears (without prerequisites or
24 # commands) before the first noncomment line in the makefile, make shall
25 # process the makefile as specified by the Posix 1003.2 specification.
26 # make(1) sets the special macro %POSIX in this case (to the actual
27 # value "1003.2", for what it's worth).
29 # The rules below use this macro to distinguish between Posix-compliant
30 # and default behaviour.
33 .SUFFIXES: .o .c .y .l .a .sh .f
35 .SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
55 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
60 .if defined(NO_STRICT_ALIASING)
61 CFLAGS += -fno-strict-aliasing
64 PO_CFLAGS ?= ${CFLAGS}
66 # C Type Format data is required for DTrace
67 CTFFLAGS ?= -L VERSION
69 CTFCONVERT ?= ctfconvert
72 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
75 # XXX: What to do here? Is removing the CFLAGS part completely ok here?
76 # For now comment it out to not compile with -g unconditionally.
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 !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
122 LINTFLAGS ?= -cghapbx
123 LINTKERNFLAGS ?= ${LINTFLAGS}
124 LINTOBJFLAGS ?= -cghapbxu -i
125 LINTOBJKERNFLAGS?= ${LINTOBJFLAGS}
126 LINTLIBFLAGS ?= -cghapbxu -C ${LIB}
135 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
154 # Posix 1003.2 mandated rules
156 # Quoted directly from the Posix 1003.2 draft, only the macros
157 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
160 # SINGLE SUFFIX RULES
162 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
166 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
170 cp -f ${.IMPSRC} ${.TARGET}
173 # DOUBLE SUFFIX RULES
176 ${CC} ${CFLAGS} -c ${.IMPSRC}
180 ${FC} ${FFLAGS} -c ${.IMPSRC}
184 ${YACC} ${YFLAGS} ${.IMPSRC}
185 ${CC} ${CFLAGS} -c y.tab.c
187 mv y.tab.o ${.TARGET}
191 ${LEX} ${LFLAGS} ${.IMPSRC}
192 ${CC} ${CFLAGS} -c lex.yy.c
194 mv lex.yy.o ${.TARGET}
198 ${YACC} ${YFLAGS} ${.IMPSRC}
199 mv y.tab.c ${.TARGET}
202 ${LEX} ${LFLAGS} ${.IMPSRC}
203 mv lex.yy.c ${.TARGET}
206 ${CC} ${CFLAGS} -c ${.IMPSRC}
207 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
211 ${FC} ${FFLAGS} -c ${.IMPSRC}
212 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
220 cp -fp ${.IMPSRC} ${.TARGET}
224 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
227 .cc.ln .C.ln .cpp.ln .cxx.ln:
228 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
232 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
236 ${CC} ${CFLAGS} -c ${.IMPSRC}
240 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
242 .cc.o .cpp.o .cxx.o .C.o:
243 ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
246 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
250 ${PC} ${PFLAGS} -c ${.IMPSRC}
254 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
258 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
261 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
265 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
269 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
274 ${YACC} ${YFLAGS} ${.IMPSRC}
275 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
280 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
281 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
282 rm -f ${.PREFIX}.tmp.c
287 ${YACC} ${YFLAGS} ${.IMPSRC}
288 mv y.tab.c ${.TARGET}
291 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
293 .s.out .c.out .o.out:
294 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
297 .f.out .F.out .r.out .e.out:
298 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
299 ${LDLIBS} -o ${.TARGET}
305 ${YACC} ${YFLAGS} ${.IMPSRC}
306 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
311 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
312 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
313 rm -f ${.PREFIX}.tmp.c
316 # FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef.
317 __MAKE_CONF?=/etc/make.conf
318 .if exists(${__MAKE_CONF})
319 .include "${__MAKE_CONF}"
322 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
323 SHELL= ${__MAKE_SHELL}
324 .SHELL: path=${__MAKE_SHELL}
327 # Default executable format
328 # XXX hint for bsd.port.mk
331 # Tell bmake to expand -V VAR by default
332 .MAKE.EXPAND_VARIABLES= yes
334 .if !defined(.PARSEDIR)
335 # We are not bmake, which is more aggressive about searching .PATH
336 # It is sometime necessary to curb its enthusiasm with .NOPATH
337 # The following allows us to quietly ignore .NOPATH when not using bmake.
347 .include <bsd.compat.mk>
348 .include <bsd.cpu.mk>