1 # from: @(#)sys.mk 8.2 (Berkeley) 3/21/94
2 # $FreeBSD: src/share/mk/sys.mk,v 1.45.2.6 2002/12/23 16:33:37 ru Exp $
4 unix ?= We run FreeBSD, not UNIX.
6 # If the special target .POSIX appears (without prerequisites or
7 # commands) before the first noncomment line in the makefile, make shall
8 # process the makefile as specified by the Posix 1003.2 specification.
9 # make(1) sets the special macro %POSIX in this case (to the actual
10 # value "1003.2", for what it's worth).
12 # The rules below use this macro to distinguish between Posix-compliant
13 # and default behaviour.
16 .SUFFIXES: .o .c .y .l .a .sh .f
18 .SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .s .cl .p .h .sh .no .nx
26 NXAR ?= ${NXENV} ${AR}
33 NXRANLIB ?= ${NXENV} ${RANLIB}
46 # The system cc frontend is not subject to the path, e.g. when buildworld
47 # is doing cross compiles it may still need the native compiler for things.
49 NXENV ?= CCVER=${HOST_CCVER} BINUTILSVER=${HOST_BINUTILSVER} OBJFORMAT_PATH=/ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/pkg/bin
50 NXCC ?= ${NXENV} ${CC}
51 NXCC_LINK ?= ${NXENV} ${CC_LINK}
56 NXCXX ?= ${NXENV} ${CXX}
57 NXCXX_LINK ?= ${NXENV} ${CXX_LINK}
58 CXXFLAGS ?= ${CXXINCLUDES} ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
62 .if ${.MAKEFLAGS:M-s} == ""
67 .if ${.MAKEFLAGS:M-s} == "-s"
90 NXLD ?= ${NXENV} ${LD}
92 NXCFLAGS ?= ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
93 NXCXXFLAGS ?= ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
95 NXLDFLAGS ?= -static ${LDFLAGS}
103 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
120 # The 'make' program is expected to define the following.
122 # MACHINE_PLATFORM platform architecture (vkernel, pc32)
123 # MACHINE machine architecture (i386, etc..)
124 # MACHINE_ARCH cpu architecture (i386, x86_64, etc)
126 .if !defined(MACHINE)
127 .error "MACHINE was not defined by make"
129 .if !defined(MACHINE_ARCH)
130 .error "MACHINE_ARCH was not defined by make"
133 # Backwards compatibility. There was a time during 1.7 development
134 # where we tried to rename MACHINE. This failed and was reverted,
135 # and MACHINE_PLATFORM was added to make the distinction. These shims
136 # prevent buildworld from breaking.
138 .if !defined(MACHINE_PLATFORM)
139 MACHINE_PLATFORM!=sysctl -n hw.platform
141 .if ${MACHINE} == "pc32"
146 # Posix 1003.2 mandated rules
148 # Quoted directly from the Posix 1003.2 draft, only the macros
149 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
152 # SINGLE SUFFIX RULES
154 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
157 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
160 cp ${.IMPSRC} ${.TARGET}
163 # DOUBLE SUFFIX RULES
166 ${CC} ${CFLAGS} -c ${.IMPSRC}
169 ${FC} ${FFLAGS} -c ${.IMPSRC}
172 ${YACC} ${YFLAGS} ${.IMPSRC}
173 ${CC} ${CFLAGS} -c y.tab.c
175 mv y.tab.o ${.TARGET}
178 ${LEX} ${LFLAGS} ${.IMPSRC}
179 ${CC} ${CFLAGS} -c lex.yy.c
181 mv lex.yy.o ${.TARGET}
184 ${YACC} ${YFLAGS} ${.IMPSRC}
185 mv y.tab.c ${.TARGET}
188 ${LEX} ${LFLAGS} ${.IMPSRC}
189 mv lex.yy.c ${.TARGET}
192 ${CC} ${CFLAGS} -c ${.IMPSRC}
193 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
197 ${FC} ${FFLAGS} -c ${.IMPSRC}
198 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
206 cp -p ${.IMPSRC} ${.TARGET}
210 ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
213 ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} -c ${.IMPSRC}
216 ${CXX} ${_${.IMPSRC:T}_FLAGS} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
218 .cc.o .cpp.o .cxx.o .C.o:
219 ${CXX} ${_${.IMPSRC:T}_FLAGS} ${CXXFLAGS} -c ${.IMPSRC}
222 ${OBJC} ${_${.IMPSRC:T}_FLAGS} ${OBJCFLAGS} -c ${.IMPSRC}
225 ${PC} ${_${.IMPSRC:T}_FLAGS} ${PFLAGS} -c ${.IMPSRC}
228 ${FC} ${_${.IMPSRC:T}_FLAGS} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} \
229 ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
232 ${FC} ${_${.IMPSRC:T}_FLAGS} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
235 ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} -c ${.IMPSRC}
238 ${AS} ${_${.IMPSRC:T}_FLAGS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
242 ${YACC} ${YFLAGS} ${.IMPSRC}
243 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
247 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
248 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
249 rm -f ${.PREFIX}.tmp.c
251 # .no == native object file, for helper code when cross building.
254 ${NXCC} ${_${.IMPSRC:T}_FLAGS} ${NXCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
257 ${YACC} ${YFLAGS} ${.IMPSRC}
258 ${NXCC} ${NXCFLAGS} -c y.tab.c -o ${.TARGET}
262 ${LEX} ${LFLAGS} -o${.TARGET}.c ${.IMPSRC}
263 ${NXCC} ${NXCFLAGS} -c ${.TARGET}.c -o ${.TARGET}
267 ${NXCC} ${_${.IMPSRC:T}_FLAGS} ${NXCFLAGS} ${NXLDFLAGS} ${.IMPSRC} \
268 ${NXLDLIBS} -o ${.TARGET}
272 ${YACC} ${YFLAGS} ${.IMPSRC}
273 mv y.tab.c ${.TARGET}
276 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
278 .s.out .c.out .o.out:
279 ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
281 .f.out .F.out .r.out .e.out:
282 ${FC} ${_${.IMPSRC:T}_FLAGS} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} \
283 ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
288 ${YACC} ${YFLAGS} ${.IMPSRC}
289 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
293 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
294 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
295 rm -f ${.PREFIX}.tmp.c
299 .if exists(/etc/defaults/make.conf)
300 .include </etc/defaults/make.conf>
303 __MAKE_CONF?=/etc/make.conf
304 .if exists(${__MAKE_CONF})
305 .include "${__MAKE_CONF}"
308 .include <bsd.cpu.mk>
310 .if exists(/etc/make.conf.local)
311 .error Error, original /etc/make.conf should be moved to the /etc/defaults/ directory and /etc/make.conf.local should be renamed to /etc/make.conf.
312 .include </etc/make.conf.local>
315 # Default executable format
316 # XXX hint for bsd.port.mk
319 # Tell bmake to expand -V VAR be default
320 .MAKE.EXPAND_VARIABLES= yes
322 .if !defined(.PARSEDIR)
323 # Not using bmake, which is aggressive about search .PATH
324 # It is sometimes necessary to curb its enthusiam with .NOPATH
325 # The following allows us to quietly ignore .NOPATH when no using bmake.