sys.mk revision 202807
1181743Semax#	from: @(#)sys.mk	8.2 (Berkeley) 3/21/94
2181743Semax# $FreeBSD: head/share/mk/sys.mk 202807 2010-01-22 14:05:48Z sepotvin $
3181743Semax
4181743Semaxunix		?=	We run FreeBSD, not UNIX.
5181743Semax.FreeBSD	?=	true
6181743Semax
7181743Semax# If the special target .POSIX appears (without prerequisites or
8181743Semax# commands) before the first noncomment line in the makefile, make shall
9181743Semax# process the makefile as specified by the Posix 1003.2 specification.
10181743Semax# make(1) sets the special macro %POSIX in this case (to the actual
11181743Semax# value "1003.2", for what it's worth).
12181743Semax#
13181743Semax# The rules below use this macro to distinguish between Posix-compliant
14181743Semax# and default behaviour.
15181743Semax
16181743Semax.if defined(%POSIX)
17181743Semax.SUFFIXES:	.o .c .y .l .a .sh .f
18181743Semax.else
19181743Semax.SUFFIXES:	.out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
20181743Semax.endif
21181743Semax
22181743SemaxAR		?=	ar
23181743Semax.if defined(%POSIX)
24181743SemaxARFLAGS		?=	-rv
25181743Semax.else
26181743SemaxARFLAGS		?=	rl
27181743Semax.endif
28181743SemaxRANLIB		?=	ranlib
29181743Semax
30181743SemaxAS		?=	as
31181743SemaxAFLAGS		?=
32181743Semax
33181743Semax.if defined(%POSIX)
34181743SemaxCC		?=	c89
35181743SemaxCFLAGS		?=	-O
36181743Semax.else
37181743SemaxCC		?=	cc
38181743Semax.if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "mips"
39181743SemaxCFLAGS		?=	-O -pipe
40181743Semax.else
41181743SemaxCFLAGS		?=	-O2 -pipe
42181743Semax.endif
43181743Semax.if defined(NO_STRICT_ALIASING)
44181743SemaxCFLAGS		+=	-fno-strict-aliasing
45181743Semax.endif
46181743Semax.endif
47181743SemaxPO_CFLAGS	?=	${CFLAGS}
48181743Semax
49181743Semax# Turn CTF conversion off by default for now. This default could be
50181743Semax# changed later if DTrace becomes popular.
51181743Semax.if !defined(WITH_CTF)
52181743SemaxNO_CTF		=	1
53181743Semax.endif
54181743Semax
55181743Semax# C Type Format data is required for DTrace
56181743SemaxCTFFLAGS	?=	-L VERSION
57181743Semax
58181743Semax.if !defined(NO_CTF)
59181743SemaxCTFCONVERT	?=	ctfconvert
60181743SemaxCTFMERGE	?=	ctfmerge
61181743Semax.if defined(CFLAGS) && (${CFLAGS:M-g} != "")
62181743SemaxCTFFLAGS	+=	-g
63181743Semax.else
64181743SemaxCFLAGS		+=	-g
65181743Semax.endif
66181743Semax.endif
67181743Semax
68181743SemaxCXX		?=	c++
69181743SemaxCXXFLAGS	?=	${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign}
70181743SemaxPO_CXXFLAGS	?=	${CXXFLAGS}
71181743Semax
72181743SemaxCPP		?=	cpp
73181743Semax
74181743Semax.if empty(.MAKEFLAGS:M-s)
75181743SemaxECHO		?=	echo
76181743SemaxECHODIR		?=	echo
77181743Semax.else
78181743SemaxECHO		?=	true
79181743Semax.if ${.MAKEFLAGS:M-s} == "-s"
80181743SemaxECHODIR		?=	echo
81181743Semax.else
82181743SemaxECHODIR		?=	true
83181743Semax.endif
84181743Semax.endif
85181743Semax
86181743Semax.if !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
87181743Semax_+_		?=
88181743Semax.else
89181743Semax_+_		?=	+
90181743Semax.endif
91181743Semax
92181743Semax.if defined(%POSIX)
93181743SemaxFC		?=	fort77
94181743SemaxFFLAGS		?=	-O 1
95181743Semax.else
96181743SemaxFC		?=	f77
97181743SemaxFFLAGS		?=	-O
98181743Semax.endif
99181743SemaxEFLAGS		?=
100181743Semax
101181743SemaxINSTALL		?=	install
102181743Semax
103181743SemaxLEX		?=	lex
104181743SemaxLFLAGS		?=
105181743Semax
106181743SemaxLD		?=	ld
107181743SemaxLDFLAGS		?=
108181743Semax
109181743SemaxLINT		?=	lint
110181743SemaxLINTFLAGS	?=	-cghapbx
111181743SemaxLINTKERNFLAGS	?=	${LINTFLAGS}
112181743SemaxLINTOBJFLAGS	?=	-cghapbxu -i
113181743SemaxLINTOBJKERNFLAGS?=	${LINTOBJFLAGS}
114LINTLIBFLAGS	?=	-cghapbxu -C ${LIB}
115
116MAKE		?=	make
117
118OBJC		?=	cc
119OBJCFLAGS	?=	${OBJCINCLUDES} ${CFLAGS} -Wno-import
120
121PC		?=	pc
122PFLAGS		?=
123
124RC		?=	f77
125RFLAGS		?=
126
127SHELL		?=	sh
128
129YACC		?=	yacc
130.if defined(%POSIX)
131YFLAGS		?=
132.else
133YFLAGS		?=	-d
134.endif
135
136.if defined(%POSIX)
137
138# Posix 1003.2 mandated rules
139#
140# Quoted directly from the Posix 1003.2 draft, only the macros
141# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
142# ${.PREFIX}, resp.
143
144# SINGLE SUFFIX RULES
145.c:
146	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
147.if defined(CTFCONVERT)
148	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
149.endif
150
151.f:
152	${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
153.if defined(CTFCONVERT)
154	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
155.endif
156
157.sh:
158	cp ${.IMPSRC} ${.TARGET}
159	chmod a+x ${.TARGET}
160
161# DOUBLE SUFFIX RULES
162
163.c.o:
164	${CC} ${CFLAGS} -c ${.IMPSRC}
165.if defined(CTFCONVERT)
166	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
167.endif
168
169.f.o:
170	${FC} ${FFLAGS} -c ${.IMPSRC}
171.if defined(CTFCONVERT)
172	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
173.endif
174
175.y.o:
176	${YACC} ${YFLAGS} ${.IMPSRC}
177	${CC} ${CFLAGS} -c y.tab.c
178	rm -f y.tab.c
179	mv y.tab.o ${.TARGET}
180.if defined(CTFCONVERT)
181	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
182.endif
183
184.l.o:
185	${LEX} ${LFLAGS} ${.IMPSRC}
186	${CC} ${CFLAGS} -c lex.yy.c
187	rm -f lex.yy.c
188	mv lex.yy.o ${.TARGET}
189.if defined(CTFCONVERT)
190	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
191.endif
192
193.y.c:
194	${YACC} ${YFLAGS} ${.IMPSRC}
195	mv y.tab.c ${.TARGET}
196
197.l.c:
198	${LEX} ${LFLAGS} ${.IMPSRC}
199	mv lex.yy.c ${.TARGET}
200
201.c.a:
202	${CC} ${CFLAGS} -c ${.IMPSRC}
203	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
204	rm -f ${.PREFIX}.o
205
206.f.a:
207	${FC} ${FFLAGS} -c ${.IMPSRC}
208	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
209	rm -f ${.PREFIX}.o
210
211.else
212
213# non-Posix rule set
214
215.sh:
216	cp -p ${.IMPSRC} ${.TARGET}
217	chmod a+x ${.TARGET}
218
219.c.ln:
220	${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
221	    touch ${.TARGET}
222
223.cc.ln .C.ln .cpp.ln .cxx.ln:
224	${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
225	    touch ${.TARGET}
226
227.c:
228	${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
229.if defined(CTFCONVERT)
230	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
231.endif
232
233.c.o:
234	${CC} ${CFLAGS} -c ${.IMPSRC}
235.if defined(CTFCONVERT)
236	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
237.endif
238
239.cc .cpp .cxx .C:
240	${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
241
242.cc.o .cpp.o .cxx.o .C.o:
243	${CXX} ${CXXFLAGS} -c ${.IMPSRC}
244
245.m.o:
246	${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
247.if defined(CTFCONVERT)
248	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
249.endif
250
251.p.o:
252	${PC} ${PFLAGS} -c ${.IMPSRC}
253.if defined(CTFCONVERT)
254	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
255.endif
256
257.e .r .F .f:
258	${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
259	    -o ${.TARGET}
260
261.e.o .r.o .F.o .f.o:
262	${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
263
264.S.o:
265	${CC} ${CFLAGS} -c ${.IMPSRC}
266.if defined(CTFCONVERT)
267	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
268.endif
269
270.asm.o:
271	${CC} -x assembler-with-cpp ${CFLAGS} -c ${.IMPSRC}
272.if defined(CTFCONVERT)
273	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
274.endif
275
276.s.o:
277	${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
278.if defined(CTFCONVERT)
279	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
280.endif
281
282# XXX not -j safe
283.y.o:
284	${YACC} ${YFLAGS} ${.IMPSRC}
285	${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
286	rm -f y.tab.c
287.if defined(CTFCONVERT)
288	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
289.endif
290
291.l.o:
292	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
293	${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
294	rm -f ${.PREFIX}.tmp.c
295.if defined(CTFCONVERT)
296	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
297.endif
298
299# XXX not -j safe
300.y.c:
301	${YACC} ${YFLAGS} ${.IMPSRC}
302	mv y.tab.c ${.TARGET}
303
304.l.c:
305	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
306
307.s.out .c.out .o.out:
308	${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
309.if defined(CTFCONVERT)
310	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
311.endif
312
313.f.out .F.out .r.out .e.out:
314	${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
315	    ${LDLIBS} -o ${.TARGET}
316	rm -f ${.PREFIX}.o
317.if defined(CTFCONVERT)
318	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
319.endif
320
321# XXX not -j safe
322.y.out:
323	${YACC} ${YFLAGS} ${.IMPSRC}
324	${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
325	rm -f y.tab.c
326.if defined(CTFCONVERT)
327	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
328.endif
329
330.l.out:
331	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
332	${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
333	rm -f ${.PREFIX}.tmp.c
334.if defined(CTFCONVERT)
335	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
336.endif
337
338# FreeBSD build pollution.  Hide it in the non-POSIX part of the ifdef.
339__MAKE_CONF?=/etc/make.conf
340.if exists(${__MAKE_CONF})
341.include "${__MAKE_CONF}"
342.endif
343
344.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
345SHELL=	${__MAKE_SHELL}
346.SHELL: path=${__MAKE_SHELL}
347.endif
348
349# Default executable format
350# XXX hint for bsd.port.mk
351OBJFORMAT?=	elf
352
353# Toggle on warnings
354.WARN: dirsyntax
355
356.endif
357
358.include <bsd.compat.mk>
359.include <bsd.cpu.mk>
360