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 reach-other's binaries, so it
11 # necessarily has word size and endian swizzled in. However, support
12 # files for these machines often are shared amongst all combinations
13 # of size and/or endian. This is called MACHINE_CPU in NetBSD, but
14 # that's used for something different in FreeBSD.
16 MACHINE_CPUARCH=${MACHINE_ARCH:C/mipse[lb]/mips/:C/armeb/arm/}
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
50 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
55 .if defined(NO_STRICT_ALIASING)
56 CFLAGS += -fno-strict-aliasing
59 PO_CFLAGS ?= ${CFLAGS}
61 # Turn CTF conversion off by default for now. This default could be
62 # changed later if DTrace becomes popular.
63 .if !defined(WITH_CTF)
67 # C Type Format data is required for DTrace
68 CTFFLAGS ?= -L VERSION
70 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}
131 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
150 # Posix 1003.2 mandated rules
152 # Quoted directly from the Posix 1003.2 draft, only the macros
153 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
156 # SINGLE SUFFIX RULES
158 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
159 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
162 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
163 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
166 cp ${.IMPSRC} ${.TARGET}
169 # DOUBLE SUFFIX RULES
172 ${CC} ${CFLAGS} -c ${.IMPSRC}
173 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
176 ${FC} ${FFLAGS} -c ${.IMPSRC}
177 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
180 ${YACC} ${YFLAGS} ${.IMPSRC}
181 ${CC} ${CFLAGS} -c y.tab.c
183 mv y.tab.o ${.TARGET}
184 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
187 ${LEX} ${LFLAGS} ${.IMPSRC}
188 ${CC} ${CFLAGS} -c lex.yy.c
190 mv lex.yy.o ${.TARGET}
191 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
194 ${YACC} ${YFLAGS} ${.IMPSRC}
195 mv y.tab.c ${.TARGET}
198 ${LEX} ${LFLAGS} ${.IMPSRC}
199 mv lex.yy.c ${.TARGET}
202 ${CC} ${CFLAGS} -c ${.IMPSRC}
203 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
207 ${FC} ${FFLAGS} -c ${.IMPSRC}
208 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
216 cp -p ${.IMPSRC} ${.TARGET}
220 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
223 .cc.ln .C.ln .cpp.ln .cxx.ln:
224 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
228 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
229 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
232 ${CC} ${CFLAGS} -c ${.IMPSRC}
233 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
236 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
238 .cc.o .cpp.o .cxx.o .C.o:
239 ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
242 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
243 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
246 ${PC} ${PFLAGS} -c ${.IMPSRC}
247 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
250 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
254 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
257 ${CC} ${CFLAGS} -c ${.IMPSRC}
258 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
261 ${CC} -x assembler-with-cpp ${CFLAGS} -c ${.IMPSRC}
262 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
265 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
266 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
270 ${YACC} ${YFLAGS} ${.IMPSRC}
271 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
273 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
276 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
277 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
278 rm -f ${.PREFIX}.tmp.c
279 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
283 ${YACC} ${YFLAGS} ${.IMPSRC}
284 mv y.tab.c ${.TARGET}
287 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
289 .s.out .c.out .o.out:
290 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
291 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
293 .f.out .F.out .r.out .e.out:
294 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
295 ${LDLIBS} -o ${.TARGET}
297 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
301 ${YACC} ${YFLAGS} ${.IMPSRC}
302 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
304 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
307 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
308 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
309 rm -f ${.PREFIX}.tmp.c
310 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
312 # FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef.
313 __MAKE_CONF?=/etc/make.conf
314 .if exists(${__MAKE_CONF})
315 .include "${__MAKE_CONF}"
318 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
319 SHELL= ${__MAKE_SHELL}
320 .SHELL: path=${__MAKE_SHELL}
323 # Default executable format
324 # XXX hint for bsd.port.mk
332 .include <bsd.compat.mk>
333 .include <bsd.cpu.mk>