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 $
3 # $DragonFly: src/share/mk/sys.mk,v 1.19 2007/01/19 07:23:41 dillon Exp $
5 unix ?= We run FreeBSD, not UNIX.
7 # If the special target .POSIX appears (without prerequisites or
8 # commands) before the first noncomment line in the makefile, make shall
9 # process the makefile as specified by the Posix 1003.2 specification.
10 # make(1) sets the special macro %POSIX in this case (to the actual
11 # value "1003.2", for what it's worth).
13 # The rules below use this macro to distinguish between Posix-compliant
14 # and default behaviour.
17 .SUFFIXES: .o .c .y .l .a .sh .f
19 .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
24 X11BASE ?= /usr/pkg/xorg
27 NXAR ?= ${NXENV} ${AR}
34 NXRANLIB ?= ${NXENV} ${RANLIB}
44 # The system cc frontend is not subject to the path, e.g. when buildworld
45 # is doing cross compiles it may still need the native compiler for things.
47 NXENV ?= CCVER=${HOST_CCVER} OBJFORMAT_PATH=/ PATH=/usr/bin:/bin:/usr/sbin:/sbin
48 NXCC ?= ${NXENV} ${CC}
52 NXCXX ?= ${NXENV} ${CXX}
53 CXXFLAGS ?= ${CXXINCLUDES} ${CFLAGS}
57 .if ${.MAKEFLAGS:M-s} == ""
62 .if ${.MAKEFLAGS:M-s} == "-s"
85 NXLD ?= ${NXENV} ${LD}
87 NXCFLAGS ?= ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
88 NXCXXFLAGS ?= ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
90 NXLDFLAGS ?= -static ${LDFLAGS}
98 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
115 # The 'make' program is expected to define the following.
117 # MACHINE_PLATFORM platform architecture (vkernel, pc32)
118 # MACHINE machine architecture (i386, etc..)
119 # MACHINE_ARCH cpu architecture (i386, amd64, etc)
121 .if !defined(MACHINE)
122 .error "MACHINE was not defined by make"
124 .if !defined(MACHINE_ARCH)
125 .error "MACHINE_ARCH was not defined by make"
128 # Backwards compatibility. There was a time during 1.7 development
129 # where we tried to rename MACHINE. This failed and was reverted,
130 # and MACHINE_PLATFORM was added to make the distinction. These shims
131 # prevent buildworld from breaking.
133 .if !defined(MACHINE_PLATFORM)
134 MACHINE_PLATFORM=pc32
136 .if ${MACHINE} == "pc32"
141 # Posix 1003.2 mandated rules
143 # Quoted directly from the Posix 1003.2 draft, only the macros
144 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
147 # SINGLE SUFFIX RULES
149 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
152 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
155 cp ${.IMPSRC} ${.TARGET}
158 # DOUBLE SUFFIX RULES
161 ${CC} ${CFLAGS} -c ${.IMPSRC}
164 ${FC} ${FFLAGS} -c ${.IMPSRC}
167 ${YACC} ${YFLAGS} ${.IMPSRC}
168 ${CC} ${CFLAGS} -c y.tab.c
170 mv y.tab.o ${.TARGET}
173 ${LEX} ${LFLAGS} ${.IMPSRC}
174 ${CC} ${CFLAGS} -c lex.yy.c
176 mv lex.yy.o ${.TARGET}
179 ${YACC} ${YFLAGS} ${.IMPSRC}
180 mv y.tab.c ${.TARGET}
183 ${LEX} ${LFLAGS} ${.IMPSRC}
184 mv lex.yy.c ${.TARGET}
187 ${CC} ${CFLAGS} -c ${.IMPSRC}
188 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
192 ${FC} ${FFLAGS} -c ${.IMPSRC}
193 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
201 cp -p ${.IMPSRC} ${.TARGET}
205 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
208 ${CC} ${CFLAGS} -c ${.IMPSRC}
211 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
213 .cc.o .cpp.o .cxx.o .C.o:
214 ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
217 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
220 ${PC} ${PFLAGS} -c ${.IMPSRC}
223 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
227 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
230 ${CC} ${CFLAGS} -c ${.IMPSRC}
233 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
237 ${YACC} ${YFLAGS} ${.IMPSRC}
238 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
242 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
243 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
244 rm -f ${.PREFIX}.tmp.c
246 # .no == native object file, for helper code when cross building.
249 ${NXCC} ${NXCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
252 ${YACC} ${YFLAGS} ${.IMPSRC}
253 ${NXCC} ${NXCFLAGS} -c y.tab.c -o ${.TARGET}
257 ${LEX} ${LFLAGS} -o${.TARGET}.c ${.IMPSRC}
258 ${NXCC} ${NXCFLAGS} -c ${.TARGET}.c -o ${.TARGET}
262 ${NXCC} ${NXCFLAGS} ${NXLDFLAGS} ${.IMPSRC} ${NXLDLIBS} -o ${.TARGET}
266 ${YACC} ${YFLAGS} ${.IMPSRC}
267 mv y.tab.c ${.TARGET}
270 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
272 .s.out .c.out .o.out:
273 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
275 .f.out .F.out .r.out .e.out:
276 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
277 ${LDLIBS} -o ${.TARGET}
282 ${YACC} ${YFLAGS} ${.IMPSRC}
283 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
287 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
288 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
289 rm -f ${.PREFIX}.tmp.c
293 .if exists(/etc/defaults/make.conf)
294 .include </etc/defaults/make.conf>
297 __MAKE_CONF?=/etc/make.conf
298 .if exists(${__MAKE_CONF})
299 .include "${__MAKE_CONF}"
302 .include <bsd.cpu.mk>
304 .if exists(/etc/make.conf.local)
305 .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.
306 .include </etc/make.conf.local>
309 # Default executable format
310 # XXX hint for bsd.port.mk