xref: /freebsd/share/mk/sys.mk (revision 35a04710d7286aa9538917fd7f8e417dbee95b82)
1#	from: @(#)sys.mk	8.2 (Berkeley) 3/21/94
2# $FreeBSD$
3
4unix		?=	We run FreeBSD, not UNIX.
5.FreeBSD	?=	true
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
19.SUFFIXES:	.out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
20.endif
21
22AR		?=	ar
23.if defined(%POSIX)
24ARFLAGS		?=	-rv
25.else
26ARFLAGS		?=	rl
27.endif
28RANLIB		?=	ranlib
29
30AS		?=	as
31AFLAGS		?=
32
33.if defined(%POSIX)
34CC		?=	c89
35CFLAGS		?=	-O
36.else
37CC		?=	cc
38.if ${MACHINE_ARCH} == "arm"
39CFLAGS		?=	-O -fno-strict-aliasing -pipe
40.else
41CFLAGS		?=	-O2 -fno-strict-aliasing -pipe
42.endif
43.if defined(NO_STRICT_ALIASING)
44CFLAGS		+=	-fno-strict-aliasing
45.endif
46.endif
47
48CXX		?=	c++
49CXXFLAGS	?=	${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign}
50
51CPP		?=	cpp
52
53.if empty(.MAKEFLAGS:M-s)
54ECHO		?=	echo
55ECHODIR		?=	echo
56.else
57ECHO		?=	true
58.if ${.MAKEFLAGS:M-s} == "-s"
59ECHODIR		?=	echo
60.else
61ECHODIR		?=	true
62.endif
63.endif
64
65.if !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
66_+_		?=
67.else
68_+_		?=	+
69.endif
70
71.if defined(%POSIX)
72FC		?=	fort77
73FFLAGS		?=	-O 1
74.else
75FC		?=	f77
76FFLAGS		?=	-O
77.endif
78EFLAGS		?=
79
80INSTALL		?=	install
81
82LEX		?=	lex
83LFLAGS		?=
84
85LD		?=	ld
86LDFLAGS		?=
87
88LINT		?=	lint
89LINTFLAGS	?=	-cghapbx
90LINTKERNFLAGS	?=	${LINTFLAGS}
91LINTOBJFLAGS	?=	-cghapbxu -i
92LINTOBJKERNFLAGS?=	${LINTOBJFLAGS}
93LINTLIBFLAGS	?=	-cghapbxu -C ${LIB}
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
115.if defined(%POSIX)
116
117# Posix 1003.2 mandated rules
118#
119# Quoted directly from the Posix 1003.2 draft, only the macros
120# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
121# ${.PREFIX}, resp.
122
123# SINGLE SUFFIX RULES
124.c:
125	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
126
127.f:
128	${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
129
130.sh:
131	cp ${.IMPSRC} ${.TARGET}
132	chmod a+x ${.TARGET}
133
134# DOUBLE SUFFIX RULES
135
136.c.o:
137	${CC} ${CFLAGS} -c ${.IMPSRC}
138
139.f.o:
140	${FC} ${FFLAGS} -c ${.IMPSRC}
141
142.y.o:
143	${YACC} ${YFLAGS} ${.IMPSRC}
144	${CC} ${CFLAGS} -c y.tab.c
145	rm -f y.tab.c
146	mv y.tab.o ${.TARGET}
147
148.l.o:
149	${LEX} ${LFLAGS} ${.IMPSRC}
150	${CC} ${CFLAGS} -c lex.yy.c
151	rm -f lex.yy.c
152	mv lex.yy.o ${.TARGET}
153
154.y.c:
155	${YACC} ${YFLAGS} ${.IMPSRC}
156	mv y.tab.c ${.TARGET}
157
158.l.c:
159	${LEX} ${LFLAGS} ${.IMPSRC}
160	mv lex.yy.c ${.TARGET}
161
162.c.a:
163	${CC} ${CFLAGS} -c ${.IMPSRC}
164	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
165	rm -f ${.PREFIX}.o
166
167.f.a:
168	${FC} ${FFLAGS} -c ${.IMPSRC}
169	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
170	rm -f ${.PREFIX}.o
171
172.else
173
174# non-Posix rule set
175
176.sh:
177	cp -p ${.IMPSRC} ${.TARGET}
178	chmod a+x ${.TARGET}
179
180.c.ln:
181	${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \
182	    touch ${.TARGET}
183
184.cc.ln .C.ln .cpp.ln .cxx.ln:
185	${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \
186	    touch ${.TARGET}
187
188.c:
189	${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
190
191.c.o:
192	${CC} ${CFLAGS} -c ${.IMPSRC}
193
194.cc .cpp .cxx .C:
195	${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
196
197.cc.o .cpp.o .cxx.o .C.o:
198	${CXX} ${CXXFLAGS} -c ${.IMPSRC}
199
200.m.o:
201	${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
202
203.p.o:
204	${PC} ${PFLAGS} -c ${.IMPSRC}
205
206.e .r .F .f:
207	${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
208	    -o ${.TARGET}
209
210.e.o .r.o .F.o .f.o:
211	${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
212
213.S.o:
214	${CC} ${CFLAGS} -c ${.IMPSRC}
215
216.asm.o:
217	${CC} -x assembler-with-cpp ${CFLAGS} -c ${.IMPSRC}
218
219.s.o:
220	${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
221
222# XXX not -j safe
223.y.o:
224	${YACC} ${YFLAGS} ${.IMPSRC}
225	${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
226	rm -f y.tab.c
227
228.l.o:
229	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
230	${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
231	rm -f ${.PREFIX}.tmp.c
232
233# XXX not -j safe
234.y.c:
235	${YACC} ${YFLAGS} ${.IMPSRC}
236	mv y.tab.c ${.TARGET}
237
238.l.c:
239	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
240
241.s.out .c.out .o.out:
242	${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
243
244.f.out .F.out .r.out .e.out:
245	${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
246	    ${LDLIBS} -o ${.TARGET}
247	rm -f ${.PREFIX}.o
248
249# XXX not -j safe
250.y.out:
251	${YACC} ${YFLAGS} ${.IMPSRC}
252	${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
253	rm -f y.tab.c
254
255.l.out:
256	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
257	${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
258	rm -f ${.PREFIX}.tmp.c
259
260# FreeBSD build pollution.  Hide it in the non-POSIX part of the ifdef.
261__MAKE_CONF?=/etc/make.conf
262.if exists(${__MAKE_CONF})
263.include "${__MAKE_CONF}"
264.endif
265
266.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
267SHELL=	${__MAKE_SHELL}
268.SHELL: path=${__MAKE_SHELL}
269.endif
270
271# Default executable format
272# XXX hint for bsd.port.mk
273OBJFORMAT?=	elf
274
275# Toggle on warnings
276.WARN: dirsyntax
277
278.endif
279
280.include <bsd.compat.mk>
281.include <bsd.cpu.mk>
282