Replace legacy make with bmake
[dragonfly.git] / share / mk / sys.mk
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
4 unix            ?=      We run FreeBSD, not UNIX.
5
6 # Set any local definitions first.  Place this early, it needs
7 # MACHINE_CPUARCH to be defined
8 .if defined(.PARSEDIR)
9 .sinclude <local.sys.mk>
10 .endif
11
12 # If the special target .POSIX appears (without prerequisites or
13 # commands) before the first noncomment line in the makefile, make shall
14 # process the makefile as specified by the Posix 1003.2 specification.
15 # make(1) sets the special macro %POSIX in this case (to the actual
16 # value "1003.2", for what it's worth).
17 #
18 # The rules below use this macro to distinguish between Posix-compliant
19 # and default behaviour.
20
21 .if defined(%POSIX)
22 .SUFFIXES:      .o .c .y .l .a .sh .f
23 .else
24 .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
25 .endif
26
27 .LIBS:          .a
28
29 X11BASE         ?=      /usr/pkg
30
31 AR              ?=      ar
32 NXAR            ?=      ${NXENV} ${AR}
33 .if defined(%POSIX)
34 ARFLAGS         ?=      -rv
35 .else
36 ARFLAGS         ?=      rl
37 .endif
38 RANLIB          ?=      ranlib
39 NXRANLIB        ?=      ${NXENV} ${RANLIB}
40
41 AS              ?=      as
42 AFLAGS          ?=
43
44 AWK             ?=      awk
45
46 .if defined(%POSIX)
47 CC              ?=      c89
48 .else
49 CC              ?=      cc
50 .endif
51 CC_LINK         ?=      ${CC}
52 # The system cc frontend is not subject to the path, e.g. when buildworld
53 # is doing cross compiles it may still need the native compiler for things.
54 #
55 NXENV           ?=      CCVER=${HOST_CCVER} BINUTILSVER=${HOST_BINUTILSVER} OBJFORMAT_PATH=/ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/pkg/bin
56 NXCC            ?=      ${NXENV} ${CC}
57 NXCC_LINK       ?=      ${NXENV} ${CC_LINK}
58 CFLAGS          ?=      -O -pipe
59
60 CXX             ?=      c++
61 CXX_LINK        ?=      ${CXX}
62 NXCXX           ?=      ${NXENV} ${CXX}
63 NXCXX_LINK      ?=      ${NXENV} ${CXX_LINK}
64 CXXFLAGS        ?=      ${CXXINCLUDES} ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
65
66 CPP             ?=      cpp
67
68 .if ${.MAKEFLAGS:M-s} == ""
69 ECHO            ?=      echo
70 ECHODIR         ?=      echo
71 .else
72 ECHO            ?=      true
73 .if ${.MAKEFLAGS:M-s} == "-s"
74 ECHODIR         ?=      echo
75 .else
76 ECHODIR         ?=      true
77 .endif
78 .endif
79
80 .if defined(%POSIX)
81 FC              ?=      fort77
82 FFLAGS          ?=      -O 1
83 .else
84 FC              ?=      f77
85 FFLAGS          ?=      -O
86 .endif
87 EFLAGS          ?=
88
89 INSTALL         ?=      install
90 LN              ?=      ln
91
92 LEX             ?=      lex
93 LFLAGS          ?=
94
95 LD              ?=      ld
96 NXLD            ?=      ${NXENV} ${LD}
97 LDFLAGS         ?=
98 NXCFLAGS        ?=      ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
99 NXCXXFLAGS      ?=      ${CFLAGS:N-mtune*:N-mcpu*:N-march*}
100 NXLDLIBS        ?=      ${LDLIBS}
101 NXLDFLAGS       ?=      -static ${LDFLAGS}
102
103 LINT            ?=      lint
104 LINTFLAGS       ?=      -chapbx
105
106 MAKE            ?=      make
107
108 OBJC            ?=      cc
109 OBJCFLAGS       ?=      ${OBJCINCLUDES} ${CFLAGS} -Wno-import
110
111 PC              ?=      pc
112 PFLAGS          ?=
113
114 RC              ?=      f77
115 RFLAGS          ?=
116
117 SHELL           ?=      sh
118
119 YACC            ?=      yacc
120 .if defined(%POSIX)
121 YFLAGS          ?=
122 .else
123 YFLAGS          ?=      -d
124 .endif
125
126 # The 'make' program is expected to define the following.
127 #
128 # MACHINE_PLATFORM      platform architecture (vkernel, pc32)
129 # MACHINE               machine architecture (i386, etc..)
130 # MACHINE_ARCH          cpu architecture (i386, x86_64, etc)
131 #
132 .if !defined(MACHINE)
133 .error "MACHINE was not defined by make"
134 .endif
135 .if !defined(MACHINE_ARCH)
136 .error "MACHINE_ARCH was not defined by make"
137 .endif
138
139 # Backwards compatibility.  There was a time during 1.7 development
140 # where we tried to rename MACHINE.  This failed and was reverted,
141 # and MACHINE_PLATFORM was added to make the distinction.  These shims
142 # prevent buildworld from breaking.
143 #
144 .if !defined(MACHINE_PLATFORM)
145 MACHINE_PLATFORM=pc32
146 .endif
147 .if ${MACHINE} == "pc32"
148 MACHINE=i386
149 .endif
150
151 .if defined(%POSIX)
152 # Posix 1003.2 mandated rules
153 #
154 # Quoted directly from the Posix 1003.2 draft, only the macros
155 # $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and
156 # ${.PREFIX}, resp.
157
158 # SINGLE SUFFIX RULES
159 .c:
160         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
161
162 .f:
163         ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC}
164
165 .sh:
166         cp ${.IMPSRC} ${.TARGET}
167         chmod a+x ${.TARGET}
168
169 # DOUBLE SUFFIX RULES
170
171 .c.o:
172         ${CC} ${CFLAGS} -c ${.IMPSRC}
173
174 .f.o:
175         ${FC} ${FFLAGS} -c ${.IMPSRC}
176
177 .y.o:
178         ${YACC} ${YFLAGS} ${.IMPSRC}
179         ${CC} ${CFLAGS} -c y.tab.c
180         rm -f y.tab.c
181         mv y.tab.o ${.TARGET}
182
183 .l.o:
184         ${LEX} ${LFLAGS} ${.IMPSRC}
185         ${CC} ${CFLAGS} -c lex.yy.c
186         rm -f lex.yy.c
187         mv lex.yy.o ${.TARGET}
188
189 .y.c:
190         ${YACC} ${YFLAGS} ${.IMPSRC}
191         mv y.tab.c ${.TARGET}
192
193 .l.c:
194         ${LEX} ${LFLAGS} ${.IMPSRC}
195         mv lex.yy.c ${.TARGET}
196
197 .c.a:
198         ${CC} ${CFLAGS} -c ${.IMPSRC}
199         ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
200         rm -f ${.PREFIX}.o
201
202 .f.a:
203         ${FC} ${FFLAGS} -c ${.IMPSRC}
204         ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
205         rm -f ${.PREFIX}.o
206
207 .else
208
209 # non-Posix rule set
210
211 .sh:
212         cp -p ${.IMPSRC} ${.TARGET}
213         chmod a+x ${.TARGET}
214
215 .c:
216         ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
217
218 .c.o:
219         ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} -c ${.IMPSRC}
220
221 .cc .cpp .cxx .C:
222         ${CXX} ${_${.IMPSRC:T}_FLAGS} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
223
224 .cc.o .cpp.o .cxx.o .C.o:
225         ${CXX} ${_${.IMPSRC:T}_FLAGS} ${CXXFLAGS} -c ${.IMPSRC}
226
227 .m.o:
228         ${OBJC} ${_${.IMPSRC:T}_FLAGS} ${OBJCFLAGS} -c ${.IMPSRC}
229
230 .p.o:
231         ${PC} ${_${.IMPSRC:T}_FLAGS} ${PFLAGS} -c ${.IMPSRC}
232
233 .e .r .F .f:
234         ${FC} ${_${.IMPSRC:T}_FLAGS} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} \
235             ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
236
237 .e.o .r.o .F.o .f.o:
238         ${FC} ${_${.IMPSRC:T}_FLAGS} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
239
240 .S.o:
241         ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} -c ${.IMPSRC}
242
243 .s.o:
244         ${AS} ${_${.IMPSRC:T}_FLAGS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
245
246 # XXX not -j safe
247 .y.o:
248         ${YACC} ${YFLAGS} ${.IMPSRC}
249         ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET}
250         rm -f y.tab.c
251
252 .l.o:
253         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
254         ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET}
255         rm -f ${.PREFIX}.tmp.c
256
257 # .no == native object file, for helper code when cross building.
258 #
259 .c.no:
260         ${NXCC} ${_${.IMPSRC:T}_FLAGS} ${NXCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
261
262 .y.no:
263         ${YACC} ${YFLAGS} ${.IMPSRC}
264         ${NXCC} ${NXCFLAGS} -c y.tab.c -o ${.TARGET}
265         rm -f y.tab.c
266
267 .l.no:
268         ${LEX} ${LFLAGS} -o${.TARGET}.c ${.IMPSRC}
269         ${NXCC} ${NXCFLAGS} -c ${.TARGET}.c -o ${.TARGET}
270         rm -f ${.TARGET}.c
271
272 .no.nx .c.nx:
273         ${NXCC} ${_${.IMPSRC:T}_FLAGS} ${NXCFLAGS} ${NXLDFLAGS} ${.IMPSRC} \
274             ${NXLDLIBS} -o ${.TARGET}
275
276 # XXX not -j safe
277 .y.c:
278         ${YACC} ${YFLAGS} ${.IMPSRC}
279         mv y.tab.c ${.TARGET}
280
281 .l.c:
282         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
283
284 .s.out .c.out .o.out:
285         ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
286
287 .f.out .F.out .r.out .e.out:
288         ${FC} ${_${.IMPSRC:T}_FLAGS} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} \
289             ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
290         rm -f ${.PREFIX}.o
291
292 # XXX not -j safe
293 .y.out:
294         ${YACC} ${YFLAGS} ${.IMPSRC}
295         ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
296         rm -f y.tab.c
297
298 .l.out:
299         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
300         ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
301         rm -f ${.PREFIX}.tmp.c
302
303 .endif
304
305 .if exists(/etc/defaults/make.conf)
306 .include </etc/defaults/make.conf>
307 .endif
308
309 __MAKE_CONF?=/etc/make.conf
310 .if exists(${__MAKE_CONF})
311 .include "${__MAKE_CONF}"
312 .endif
313
314 .include <bsd.cpu.mk>
315
316 .if exists(/etc/make.conf.local)
317 .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.
318 .include </etc/make.conf.local>
319 .endif
320
321 # Default executable format
322 # XXX hint for bsd.port.mk
323 OBJFORMAT?=     elf
324
325 # Tell bmake to expand -V VAR be default
326 .MAKE.EXPAND_VARIABLES= yes
327
328 .if !defined(.PARSEDIR)
329 # Not using bmake, which is aggressive about search .PATH
330 # It is sometimes necessary to curb its enthusiam with .NOPATH
331 # The following allows us to quietly ignore .NOPATH when no using bmake.
332 .NOTMAIN: .NOPATH
333 .NOPATH:
334
335 .endif