bug 2450: Allow build of RELEASE 3.2 from master's bmake
[dragonfly.git] / share / mk / sys.mk
CommitLineData
984263bc
MD
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
4unix ?= We run FreeBSD, not UNIX.
5
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).
11#
12# The rules below use this macro to distinguish between Posix-compliant
13# and default behaviour.
14
15.if defined(%POSIX)
16.SUFFIXES: .o .c .y .l .a .sh .f
17.else
1397f94a 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
984263bc
MD
19.endif
20
21.LIBS: .a
22
d5faf822 23X11BASE ?= /usr/pkg
984263bc
MD
24
25AR ?= ar
84531ef9 26NXAR ?= ${NXENV} ${AR}
984263bc
MD
27.if defined(%POSIX)
28ARFLAGS ?= -rv
29.else
30ARFLAGS ?= rl
31.endif
32RANLIB ?= ranlib
84531ef9 33NXRANLIB ?= ${NXENV} ${RANLIB}
984263bc
MD
34
35AS ?= as
36AFLAGS ?=
37
838a06c1
SW
38AWK ?= awk
39
984263bc
MD
40.if defined(%POSIX)
41CC ?= c89
42.else
43CC ?= cc
44.endif
3c4543af 45CC_LINK ?= ${CC}
1397f94a
MD
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.
48#
21e43067 49NXENV ?= CCVER=${HOST_CCVER} BINUTILSVER=${HOST_BINUTILSVER} OBJFORMAT_PATH=/ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/pkg/bin
ac93d77b 50NXCC ?= ${NXENV} ${CC}
3c4543af 51NXCC_LINK ?= ${NXENV} ${CC_LINK}
984263bc
MD
52CFLAGS ?= -O -pipe
53
54CXX ?= c++
3c4543af 55CXX_LINK ?= ${CXX}
c1a8415f 56NXCXX ?= ${NXENV} ${CXX}
3c4543af 57NXCXX_LINK ?= ${NXENV} ${CXX_LINK}
9425e765 58CXXFLAGS ?= ${CXXINCLUDES} ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
984263bc
MD
59
60CPP ?= cpp
61
62.if ${.MAKEFLAGS:M-s} == ""
63ECHO ?= echo
64ECHODIR ?= echo
65.else
66ECHO ?= true
67.if ${.MAKEFLAGS:M-s} == "-s"
68ECHODIR ?= echo
69.else
70ECHODIR ?= true
71.endif
72.endif
73
74.if defined(%POSIX)
75FC ?= fort77
76FFLAGS ?= -O 1
77.else
78FC ?= f77
79FFLAGS ?= -O
80.endif
81EFLAGS ?=
82
83INSTALL ?= install
062db326 84LN ?= ln
984263bc
MD
85
86LEX ?= lex
87LFLAGS ?=
88
89LD ?= ld
84531ef9 90NXLD ?= ${NXENV} ${LD}
984263bc 91LDFLAGS ?=
4db2a28c 92NXCFLAGS ?= ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
f0897036 93NXCXXFLAGS ?= ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
1397f94a
MD
94NXLDLIBS ?= ${LDLIBS}
95NXLDFLAGS ?= -static ${LDFLAGS}
984263bc
MD
96
97LINT ?= lint
98LINTFLAGS ?= -chapbx
99
100MAKE ?= make
101
102OBJC ?= cc
103OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
104
105PC ?= pc
106PFLAGS ?=
107
108RC ?= f77
109RFLAGS ?=
110
111SHELL ?= sh
112
113YACC ?= yacc
114.if defined(%POSIX)
115YFLAGS ?=
116.else
117YFLAGS ?= -d
118.endif
119
e2ea6619
MD
120# The 'make' program is expected to define the following.
121#
0955fd91
MD
122# MACHINE_PLATFORM platform architecture (vkernel, pc32)
123# MACHINE machine architecture (i386, etc..)
b2b3ffcd 124# MACHINE_ARCH cpu architecture (i386, x86_64, etc)
e2ea6619
MD
125#
126.if !defined(MACHINE)
127.error "MACHINE was not defined by make"
128.endif
129.if !defined(MACHINE_ARCH)
130.error "MACHINE_ARCH was not defined by make"
131.endif
0955fd91
MD
132
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.
2975831e 137#
0955fd91 138.if !defined(MACHINE_PLATFORM)
59620cdf 139MACHINE_PLATFORM!=sysctl -n hw.platform
0955fd91
MD
140.endif
141.if ${MACHINE} == "pc32"
142MACHINE=i386
c08b39fe
SS
143.endif
144
984263bc
MD
145.if defined(%POSIX)
146# Posix 1003.2 mandated rules
147#
148# Quoted directly from the Posix 1003.2 draft, only the macros
149# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
150# ${.PREFIX}, resp.
151
152# SINGLE SUFFIX RULES
153.c:
154 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
155
156.f:
157 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
158
159.sh:
160 cp ${.IMPSRC} ${.TARGET}
161 chmod a+x ${.TARGET}
162
163# DOUBLE SUFFIX RULES
164
165.c.o:
166 ${CC} ${CFLAGS} -c ${.IMPSRC}
167
168.f.o:
169 ${FC} ${FFLAGS} -c ${.IMPSRC}
170
171.y.o:
172 ${YACC} ${YFLAGS} ${.IMPSRC}
173 ${CC} ${CFLAGS} -c y.tab.c
174 rm -f y.tab.c
175 mv y.tab.o ${.TARGET}
176
177.l.o:
178 ${LEX} ${LFLAGS} ${.IMPSRC}
179 ${CC} ${CFLAGS} -c lex.yy.c
180 rm -f lex.yy.c
181 mv lex.yy.o ${.TARGET}
182
183.y.c:
184 ${YACC} ${YFLAGS} ${.IMPSRC}
185 mv y.tab.c ${.TARGET}
186
187.l.c:
188 ${LEX} ${LFLAGS} ${.IMPSRC}
189 mv lex.yy.c ${.TARGET}
190
191.c.a:
192 ${CC} ${CFLAGS} -c ${.IMPSRC}
193 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
194 rm -f ${.PREFIX}.o
195
196.f.a:
197 ${FC} ${FFLAGS} -c ${.IMPSRC}
198 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
199 rm -f ${.PREFIX}.o
200
201.else
202
203# non-Posix rule set
204
205.sh:
206 cp -p ${.IMPSRC} ${.TARGET}
207 chmod a+x ${.TARGET}
208
209.c:
6d68f83f 210 ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
984263bc
MD
211
212.c.o:
6d68f83f 213 ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} -c ${.IMPSRC}
984263bc
MD
214
215.cc .cpp .cxx .C:
6d68f83f 216 ${CXX} ${_${.IMPSRC:T}_FLAGS} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
984263bc
MD
217
218.cc.o .cpp.o .cxx.o .C.o:
6d68f83f 219 ${CXX} ${_${.IMPSRC:T}_FLAGS} ${CXXFLAGS} -c ${.IMPSRC}
984263bc
MD
220
221.m.o:
6d68f83f 222 ${OBJC} ${_${.IMPSRC:T}_FLAGS} ${OBJCFLAGS} -c ${.IMPSRC}
984263bc
MD
223
224.p.o:
6d68f83f 225 ${PC} ${_${.IMPSRC:T}_FLAGS} ${PFLAGS} -c ${.IMPSRC}
984263bc
MD
226
227.e .r .F .f:
6d68f83f
SS
228 ${FC} ${_${.IMPSRC:T}_FLAGS} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} \
229 ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
984263bc
MD
230
231.e.o .r.o .F.o .f.o:
6d68f83f 232 ${FC} ${_${.IMPSRC:T}_FLAGS} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
984263bc
MD
233
234.S.o:
6d68f83f 235 ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} -c ${.IMPSRC}
984263bc
MD
236
237.s.o:
6d68f83f 238 ${AS} ${_${.IMPSRC:T}_FLAGS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
984263bc
MD
239
240# XXX not -j safe
241.y.o:
242 ${YACC} ${YFLAGS} ${.IMPSRC}
243 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
244 rm -f y.tab.c
245
246.l.o:
247 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
248 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
249 rm -f ${.PREFIX}.tmp.c
250
1397f94a
MD
251# .no == native object file, for helper code when cross building.
252#
253.c.no:
6d68f83f 254 ${NXCC} ${_${.IMPSRC:T}_FLAGS} ${NXCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
1397f94a
MD
255
256.y.no:
257 ${YACC} ${YFLAGS} ${.IMPSRC}
4db2a28c 258 ${NXCC} ${NXCFLAGS} -c y.tab.c -o ${.TARGET}
1397f94a
MD
259 rm -f y.tab.c
260
261.l.no:
262 ${LEX} ${LFLAGS} -o${.TARGET}.c ${.IMPSRC}
4db2a28c 263 ${NXCC} ${NXCFLAGS} -c ${.TARGET}.c -o ${.TARGET}
1397f94a
MD
264 rm -f ${.TARGET}.c
265
266.no.nx .c.nx:
6d68f83f
SS
267 ${NXCC} ${_${.IMPSRC:T}_FLAGS} ${NXCFLAGS} ${NXLDFLAGS} ${.IMPSRC} \
268 ${NXLDLIBS} -o ${.TARGET}
1397f94a 269
984263bc
MD
270# XXX not -j safe
271.y.c:
272 ${YACC} ${YFLAGS} ${.IMPSRC}
273 mv y.tab.c ${.TARGET}
274
275.l.c:
276 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
277
278.s.out .c.out .o.out:
6d68f83f 279 ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
984263bc
MD
280
281.f.out .F.out .r.out .e.out:
6d68f83f
SS
282 ${FC} ${_${.IMPSRC:T}_FLAGS} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} \
283 ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
984263bc
MD
284 rm -f ${.PREFIX}.o
285
286# XXX not -j safe
287.y.out:
288 ${YACC} ${YFLAGS} ${.IMPSRC}
289 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
290 rm -f y.tab.c
291
292.l.out:
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
296
297.endif
298
299.if exists(/etc/defaults/make.conf)
300.include </etc/defaults/make.conf>
301.endif
302
303__MAKE_CONF?=/etc/make.conf
304.if exists(${__MAKE_CONF})
305.include "${__MAKE_CONF}"
306.endif
307
308.include <bsd.cpu.mk>
309
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>
313.endif
314
984263bc 315# Default executable format
aa8d5dcb 316# XXX hint for bsd.port.mk
984263bc 317OBJFORMAT?= elf
1397f94a 318
59620cdf
JM
319# Tell bmake to expand -V VAR be default
320.MAKE.EXPAND_VARIABLES= yes
321
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.
326.NOTMAIN: .NOPATH
327.NOPATH:
328
329.endif