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