Don't break buildworld for upgrading users: "i386" is no valid platorm
[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 $
c08b39fe 3# $DragonFly: src/share/mk/sys.mk,v 1.18 2006/11/15 03:27:10 corecode Exp $
984263bc
MD
4
5unix ?= We run FreeBSD, not UNIX.
6
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).
12#
13# The rules below use this macro to distinguish between Posix-compliant
14# and default behaviour.
15
16.if defined(%POSIX)
17.SUFFIXES: .o .c .y .l .a .sh .f
18.else
1397f94a 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
984263bc
MD
20.endif
21
22.LIBS: .a
23
437ea420 24X11BASE ?= /usr/pkg/xorg
984263bc
MD
25
26AR ?= ar
84531ef9 27NXAR ?= ${NXENV} ${AR}
984263bc
MD
28.if defined(%POSIX)
29ARFLAGS ?= -rv
30.else
31ARFLAGS ?= rl
32.endif
33RANLIB ?= ranlib
84531ef9 34NXRANLIB ?= ${NXENV} ${RANLIB}
984263bc
MD
35
36AS ?= as
37AFLAGS ?=
38
39.if defined(%POSIX)
40CC ?= c89
41.else
42CC ?= cc
43.endif
1397f94a
MD
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.
46#
8babcbeb 47NXENV ?= CCVER=${HOST_CCVER} OBJFORMAT_PATH=/ PATH=/usr/bin:/bin:/usr/sbin:/sbin
ac93d77b 48NXCC ?= ${NXENV} ${CC}
984263bc
MD
49CFLAGS ?= -O -pipe
50
51CXX ?= c++
c1a8415f 52NXCXX ?= ${NXENV} ${CXX}
984263bc
MD
53CXXFLAGS ?= ${CXXINCLUDES} ${CFLAGS}
54
55CPP ?= cpp
56
57.if ${.MAKEFLAGS:M-s} == ""
58ECHO ?= echo
59ECHODIR ?= echo
60.else
61ECHO ?= true
62.if ${.MAKEFLAGS:M-s} == "-s"
63ECHODIR ?= echo
64.else
65ECHODIR ?= true
66.endif
67.endif
68
69.if defined(%POSIX)
70FC ?= fort77
71FFLAGS ?= -O 1
72.else
73FC ?= f77
74FFLAGS ?= -O
75.endif
76EFLAGS ?=
77
78INSTALL ?= install
062db326 79LN ?= ln
984263bc
MD
80
81LEX ?= lex
82LFLAGS ?=
83
84LD ?= ld
84531ef9 85NXLD ?= ${NXENV} ${LD}
984263bc 86LDFLAGS ?=
4db2a28c 87NXCFLAGS ?= ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
f0897036 88NXCXXFLAGS ?= ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
1397f94a
MD
89NXLDLIBS ?= ${LDLIBS}
90NXLDFLAGS ?= -static ${LDFLAGS}
984263bc
MD
91
92LINT ?= lint
93LINTFLAGS ?= -chapbx
94
95MAKE ?= make
96
97OBJC ?= cc
98OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
99
100PC ?= pc
101PFLAGS ?=
102
103RC ?= f77
104RFLAGS ?=
105
106SHELL ?= sh
107
108YACC ?= yacc
109.if defined(%POSIX)
110YFLAGS ?=
111.else
112YFLAGS ?= -d
113.endif
114
e2ea6619
MD
115# The 'make' program is expected to define the following.
116#
117# MACHINE machine class
118# MACHINE_ARCH machine architecture (i386, amd64, vkernel, etc)
119# MACHINE_CPU cpu architecture (i386)
120#
121.if !defined(MACHINE)
122.error "MACHINE was not defined by make"
123.endif
124.if !defined(MACHINE_ARCH)
125.error "MACHINE_ARCH was not defined by make"
126.endif
2975831e
MD
127# I want to do this too, but bmake apparently uses these .mk files too.
128#
129#.if !defined(MACHINE_CPU)
130#.error "MACHINE_CPU was not defined by make"
131#.endif
984263bc 132
c08b39fe
SS
133# Backwards compat: old systems have hw.machine set to "i386", but it
134# is expected to be "pc32" in the build system. Try and don't break
135# build/installworld for upgrading users.
136.if ${MACHINE} == "i386"
137MACHINE=pc32
138.endif
139
984263bc
MD
140.if defined(%POSIX)
141# Posix 1003.2 mandated rules
142#
143# Quoted directly from the Posix 1003.2 draft, only the macros
144# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
145# ${.PREFIX}, resp.
146
147# SINGLE SUFFIX RULES
148.c:
149 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
150
151.f:
152 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
153
154.sh:
155 cp ${.IMPSRC} ${.TARGET}
156 chmod a+x ${.TARGET}
157
158# DOUBLE SUFFIX RULES
159
160.c.o:
161 ${CC} ${CFLAGS} -c ${.IMPSRC}
162
163.f.o:
164 ${FC} ${FFLAGS} -c ${.IMPSRC}
165
166.y.o:
167 ${YACC} ${YFLAGS} ${.IMPSRC}
168 ${CC} ${CFLAGS} -c y.tab.c
169 rm -f y.tab.c
170 mv y.tab.o ${.TARGET}
171
172.l.o:
173 ${LEX} ${LFLAGS} ${.IMPSRC}
174 ${CC} ${CFLAGS} -c lex.yy.c
175 rm -f lex.yy.c
176 mv lex.yy.o ${.TARGET}
177
178.y.c:
179 ${YACC} ${YFLAGS} ${.IMPSRC}
180 mv y.tab.c ${.TARGET}
181
182.l.c:
183 ${LEX} ${LFLAGS} ${.IMPSRC}
184 mv lex.yy.c ${.TARGET}
185
186.c.a:
187 ${CC} ${CFLAGS} -c ${.IMPSRC}
188 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
189 rm -f ${.PREFIX}.o
190
191.f.a:
192 ${FC} ${FFLAGS} -c ${.IMPSRC}
193 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
194 rm -f ${.PREFIX}.o
195
196.else
197
198# non-Posix rule set
199
200.sh:
201 cp -p ${.IMPSRC} ${.TARGET}
202 chmod a+x ${.TARGET}
203
204.c:
205 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
206
207.c.o:
208 ${CC} ${CFLAGS} -c ${.IMPSRC}
209
210.cc .cpp .cxx .C:
211 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
212
213.cc.o .cpp.o .cxx.o .C.o:
214 ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
215
216.m.o:
217 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
218
219.p.o:
220 ${PC} ${PFLAGS} -c ${.IMPSRC}
221
222.e .r .F .f:
223 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
224 -o ${.TARGET}
225
226.e.o .r.o .F.o .f.o:
227 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
228
229.S.o:
230 ${CC} ${CFLAGS} -c ${.IMPSRC}
231
232.s.o:
233 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
234
235# XXX not -j safe
236.y.o:
237 ${YACC} ${YFLAGS} ${.IMPSRC}
238 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
239 rm -f y.tab.c
240
241.l.o:
242 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
243 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
244 rm -f ${.PREFIX}.tmp.c
245
1397f94a
MD
246# .no == native object file, for helper code when cross building.
247#
248.c.no:
249 ${NXCC} ${NXCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
250
251.y.no:
252 ${YACC} ${YFLAGS} ${.IMPSRC}
4db2a28c 253 ${NXCC} ${NXCFLAGS} -c y.tab.c -o ${.TARGET}
1397f94a
MD
254 rm -f y.tab.c
255
256.l.no:
257 ${LEX} ${LFLAGS} -o${.TARGET}.c ${.IMPSRC}
4db2a28c 258 ${NXCC} ${NXCFLAGS} -c ${.TARGET}.c -o ${.TARGET}
1397f94a
MD
259 rm -f ${.TARGET}.c
260
261.no.nx .c.nx:
262 ${NXCC} ${NXCFLAGS} ${NXLDFLAGS} ${.IMPSRC} ${NXLDLIBS} -o ${.TARGET}
263
984263bc
MD
264# XXX not -j safe
265.y.c:
266 ${YACC} ${YFLAGS} ${.IMPSRC}
267 mv y.tab.c ${.TARGET}
268
269.l.c:
270 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
271
272.s.out .c.out .o.out:
273 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
274
275.f.out .F.out .r.out .e.out:
276 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
277 ${LDLIBS} -o ${.TARGET}
278 rm -f ${.PREFIX}.o
279
280# XXX not -j safe
281.y.out:
282 ${YACC} ${YFLAGS} ${.IMPSRC}
283 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
284 rm -f y.tab.c
285
286.l.out:
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
290
291.endif
292
293.if exists(/etc/defaults/make.conf)
294.include </etc/defaults/make.conf>
295.endif
296
297__MAKE_CONF?=/etc/make.conf
298.if exists(${__MAKE_CONF})
299.include "${__MAKE_CONF}"
300.endif
301
302.include <bsd.cpu.mk>
303
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>
307.endif
308
984263bc 309# Default executable format
aa8d5dcb 310# XXX hint for bsd.port.mk
984263bc 311OBJFORMAT?= elf
1397f94a 312