xref: /dragonfly/share/mk/sys.mk (revision 9dbf638f)
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.2 2003/06/17 04:37:02 dillon Exp $
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
19.SUFFIXES:	.out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .s .cl .p .h .sh
20.endif
21
22.LIBS:		.a
23
24X11BASE		?=	/usr/X11R6
25
26AR		?=	ar
27.if defined(%POSIX)
28ARFLAGS		?=	-rv
29.else
30ARFLAGS		?=	rl
31.endif
32RANLIB		?=	ranlib
33
34AS		?=	as
35AFLAGS		?=
36
37.if defined(%POSIX)
38CC		?=	c89
39.else
40CC		?=	cc
41.endif
42CFLAGS		?=	-O -pipe
43
44CXX		?=	c++
45CXXFLAGS	?=	${CXXINCLUDES} ${CFLAGS}
46
47CPP		?=	cpp
48
49.if ${.MAKEFLAGS:M-s} == ""
50ECHO		?=	echo
51ECHODIR		?=	echo
52.else
53ECHO		?=	true
54.if ${.MAKEFLAGS:M-s} == "-s"
55ECHODIR		?=	echo
56.else
57ECHODIR		?=	true
58.endif
59.endif
60
61.if defined(%POSIX)
62FC		?=	fort77
63FFLAGS		?=	-O 1
64.else
65FC		?=	f77
66FFLAGS		?=	-O
67.endif
68EFLAGS		?=
69
70INSTALL		?=	install
71
72LEX		?=	lex
73LFLAGS		?=
74
75LD		?=	ld
76LDFLAGS		?=
77
78LINT		?=	lint
79LINTFLAGS	?=	-chapbx
80
81MAKE		?=	make
82
83OBJC		?=	cc
84OBJCFLAGS	?=	${OBJCINCLUDES} ${CFLAGS} -Wno-import
85
86PC		?=	pc
87PFLAGS		?=
88
89RC		?=	f77
90RFLAGS		?=
91
92SHELL		?=	sh
93
94YACC		?=	yacc
95.if defined(%POSIX)
96YFLAGS		?=
97.else
98YFLAGS		?=	-d
99.endif
100
101# FreeBSD/i386 has traditionally been built with a version of make
102# which knows MACHINE, but not MACHINE_ARCH. When building on other
103# architectures, assume that the version of make being used has an
104# explicit MACHINE_ARCH setting and treat a missing MACHINE_ARCH
105# as an i386 architecture.
106MACHINE_ARCH	?=	i386
107
108.if defined(%POSIX)
109# Posix 1003.2 mandated rules
110#
111# Quoted directly from the Posix 1003.2 draft, only the macros
112# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
113# ${.PREFIX}, resp.
114
115# SINGLE SUFFIX RULES
116.c:
117	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
118
119.f:
120	${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
121
122.sh:
123	cp ${.IMPSRC} ${.TARGET}
124	chmod a+x ${.TARGET}
125
126# DOUBLE SUFFIX RULES
127
128.c.o:
129	${CC} ${CFLAGS} -c ${.IMPSRC}
130
131.f.o:
132	${FC} ${FFLAGS} -c ${.IMPSRC}
133
134.y.o:
135	${YACC} ${YFLAGS} ${.IMPSRC}
136	${CC} ${CFLAGS} -c y.tab.c
137	rm -f y.tab.c
138	mv y.tab.o ${.TARGET}
139
140.l.o:
141	${LEX} ${LFLAGS} ${.IMPSRC}
142	${CC} ${CFLAGS} -c lex.yy.c
143	rm -f lex.yy.c
144	mv lex.yy.o ${.TARGET}
145
146.y.c:
147	${YACC} ${YFLAGS} ${.IMPSRC}
148	mv y.tab.c ${.TARGET}
149
150.l.c:
151	${LEX} ${LFLAGS} ${.IMPSRC}
152	mv lex.yy.c ${.TARGET}
153
154.c.a:
155	${CC} ${CFLAGS} -c ${.IMPSRC}
156	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
157	rm -f ${.PREFIX}.o
158
159.f.a:
160	${FC} ${FFLAGS} -c ${.IMPSRC}
161	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
162	rm -f ${.PREFIX}.o
163
164.else
165
166# non-Posix rule set
167
168.sh:
169	cp -p ${.IMPSRC} ${.TARGET}
170	chmod a+x ${.TARGET}
171
172.c:
173	${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
174
175.c.o:
176	${CC} ${CFLAGS} -c ${.IMPSRC}
177
178.cc .cpp .cxx .C:
179	${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
180
181.cc.o .cpp.o .cxx.o .C.o:
182	${CXX} ${CXXFLAGS} -c ${.IMPSRC}
183
184.m.o:
185	${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
186
187.p.o:
188	${PC} ${PFLAGS} -c ${.IMPSRC}
189
190.e .r .F .f:
191	${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \
192	    -o ${.TARGET}
193
194.e.o .r.o .F.o .f.o:
195	${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
196
197.S.o:
198	${CC} ${CFLAGS} -c ${.IMPSRC}
199
200.s.o:
201	${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
202
203# XXX not -j safe
204.y.o:
205	${YACC} ${YFLAGS} ${.IMPSRC}
206	${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
207	rm -f y.tab.c
208
209.l.o:
210	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
211	${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
212	rm -f ${.PREFIX}.tmp.c
213
214# XXX not -j safe
215.y.c:
216	${YACC} ${YFLAGS} ${.IMPSRC}
217	mv y.tab.c ${.TARGET}
218
219.l.c:
220	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
221
222.s.out .c.out .o.out:
223	${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
224
225.f.out .F.out .r.out .e.out:
226	${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \
227	    ${LDLIBS} -o ${.TARGET}
228	rm -f ${.PREFIX}.o
229
230# XXX not -j safe
231.y.out:
232	${YACC} ${YFLAGS} ${.IMPSRC}
233	${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
234	rm -f y.tab.c
235
236.l.out:
237	${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
238	${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
239	rm -f ${.PREFIX}.tmp.c
240
241.endif
242
243.if exists(/etc/defaults/make.conf)
244.include </etc/defaults/make.conf>
245.endif
246
247__MAKE_CONF?=/etc/make.conf
248.if exists(${__MAKE_CONF})
249.include "${__MAKE_CONF}"
250.endif
251
252.include <bsd.cpu.mk>
253
254.if exists(/etc/make.conf.local)
255.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.
256.include </etc/make.conf.local>
257.endif
258
259#
260# The build tools are indirected by /usr/bin/objformat which determines the
261# object format from the OBJFORMAT environment variable and if this is not
262# defined, it reads /etc/objformat.
263#
264.if exists(/etc/objformat) && !defined(OBJFORMAT)
265.include "/etc/objformat"
266.endif
267
268# Default executable format
269OBJFORMAT?=	elf
270