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