nrelease - fix/improve livecd
[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 DragonFly, 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         ?=      rc
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 CFLAGS          ?=      -pipe -O${WORLD_CCOPTLEVEL}
47 .else
48 CC              ?=      cc
49 CFLAGS          ?=      -pipe -O${WORLD_CCOPTLEVEL} ${WORLD_CFLAGS}
50 .endif
51 CC_LINK         ?=      ${CC}
52
53 # The system cc frontend is not subject to the path, e.g. when buildworld
54 # is doing cross compiles it may still need the native compiler for things.
55 #
56 NXENV           ?=      CCVER=${HOST_CCVER} BINUTILSVER=${HOST_BINUTILSVER} OBJFORMAT_PATH=/ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/pkg/bin
57 NXCC            ?=      ${NXENV} ${CC}
58 NXCC_LINK       ?=      ${NXENV} ${CC_LINK}
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 .if !defined(SYSBUILD) && defined(.MAKE.BUILT.BY) && ${.MAKE.BUILT.BY:Mgcc47}
66 CXXFLAGS        +=      -D_GLIBCXX_USE_CXX11_ABI=0
67 .endif
68
69 CPP             ?=      cpp
70
71 .if ${.MAKEFLAGS:M-s} == ""
72 ECHO            ?=      echo
73 ECHODIR         ?=      echo
74 .else
75 ECHO            ?=      true
76 .if ${.MAKEFLAGS:M-s} == "-s"
77 ECHODIR         ?=      echo
78 .else
79 ECHODIR         ?=      true
80 .endif
81 .endif
82
83 .if defined(%POSIX)
84 FC              ?=      fort77
85 FFLAGS          ?=      -O 1
86 .else
87 FC              ?=      f77
88 FFLAGS          ?=      -O
89 .endif
90 EFLAGS          ?=
91
92 INSTALL         ?=      install
93 LN              ?=      ln
94
95 LEX             ?=      lex
96 LFLAGS          ?=
97
98 LD              ?=      ld
99 NXLD            ?=      ${NXENV} ${LD}
100 LDFLAGS         ?=
101 NXCFLAGS        ?=      ${CROSS_CFLAGS} ${CFLAGS:N-mtune*:N-mcpu*:N-march*:N-flto}
102 NXCXXFLAGS      ?=      ${CROSS_CFLAGS} ${CFLAGS:N-mtune*:N-mcpu*:N-march*:N-flto:N-std=*}
103 NXLDLIBS        ?=      ${LDLIBS}
104 NXLDFLAGS       ?=      -static ${LDFLAGS}
105
106 LINT            ?=      lint
107 LINTFLAGS       ?=      -chapbx
108
109 MAKE            ?=      make
110
111 OBJC            ?=      cc
112 OBJCFLAGS       ?=      ${OBJCINCLUDES} ${CFLAGS} -Wno-import
113
114 PC              ?=      pc
115 PFLAGS          ?=
116
117 RC              ?=      f77
118 RFLAGS          ?=
119
120 SHELL           ?=      sh
121
122 YACC            ?=      yacc
123 .if defined(%POSIX)
124 YFLAGS          ?=
125 .else
126 YFLAGS          ?=      -d
127 .endif
128
129 # The 'make' program is expected to define the following.
130 #
131 # MACHINE_PLATFORM      platform architecture (pc64, vkernel64, etc.)
132 # MACHINE               machine architecture (x86_64, etc.)
133 # MACHINE_ARCH          cpu architecture (x86_64, etc.)
134 #
135 .if !defined(MACHINE)
136 .error "MACHINE was not defined by make"
137 .endif
138 .if !defined(MACHINE_ARCH)
139 .error "MACHINE_ARCH was not defined by make"
140 .endif
141
142 # Backwards compatibility.  There was a time during 1.7 development
143 # where we tried to rename MACHINE.  This failed and was reverted,
144 # and MACHINE_PLATFORM was added to make the distinction.  These shims
145 # prevent buildworld from breaking.
146 #
147 .if !defined(MACHINE_PLATFORM)
148 MACHINE_PLATFORM!=/sbin/sysctl -n hw.platform
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:N-flto} -c ${.IMPSRC} -o ${.TARGET}
261
262 .cc.no .C.no .cpp.no .cxx.no:
263         ${NXCXX} ${_${.IMPSRC:T}_FLAGS} ${NXCXXFLAGS:N-flto} -c ${.IMPSRC} -o ${.TARGET}
264
265 .y.no:
266         ${YACC} ${YFLAGS} ${.IMPSRC}
267         ${NXCC} ${NXCFLAGS} -c y.tab.c -o ${.TARGET}
268         rm -f y.tab.c
269
270 .l.no:
271         ${LEX} ${LFLAGS} -o${.TARGET}.c ${.IMPSRC}
272         ${NXCC} ${NXCFLAGS} -c ${.TARGET}.c -o ${.TARGET}
273         rm -f ${.TARGET}.c
274
275 .no.nx .c.nx:
276         ${NXCC} ${_${.IMPSRC:T}_FLAGS} ${NXCFLAGS} ${NXLDFLAGS} ${.IMPSRC} \
277             ${NXLDLIBS} -o ${.TARGET}
278
279 # XXX not -j safe
280 .y.c:
281         ${YACC} ${YFLAGS} ${.IMPSRC}
282         mv y.tab.c ${.TARGET}
283
284 .l.c:
285         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET}
286
287 .s.out .c.out .o.out:
288         ${CC} ${_${.IMPSRC:T}_FLAGS} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
289
290 .f.out .F.out .r.out .e.out:
291         ${FC} ${_${.IMPSRC:T}_FLAGS} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} \
292             ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
293         rm -f ${.PREFIX}.o
294
295 # XXX not -j safe
296 .y.out:
297         ${YACC} ${YFLAGS} ${.IMPSRC}
298         ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET}
299         rm -f y.tab.c
300
301 .l.out:
302         ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c
303         ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET}
304         rm -f ${.PREFIX}.tmp.c
305
306 .endif
307
308 # Include base system defaults.
309 .if exists(/etc/defaults/make.conf)
310 .include </etc/defaults/make.conf>
311 .endif
312
313 # XXX we should some how include src tree etc/defaults/make.conf too. Changes
314 # to default/make.conf only applies after installworld so might produce world
315 # that no longer can bootstrap itself.
316
317 # Private helper for handling alternative compilers and Makefile.inc1 tester.
318 WORLD_ALTCOMPILER?= gcc47
319
320 # Include global user settings.
321 __MAKE_CONF?=/etc/make.conf
322 .if exists(${__MAKE_CONF})
323 .include "${__MAKE_CONF}"
324 .endif
325
326 # Helper for bootstrapping in makefiles.
327 .if !defined(WORLD_VERSION)
328 .if defined(.MAKE.DF.VERSION)
329 WORLD_VERSION=  ${.MAKE.DF.VERSION}
330 .else
331 .if exists(/usr/include/sys/param.h)
332 WORLD_VERSION!= ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < /usr/include/sys/param.h
333 .endif
334 .endif
335 # Export it to ensure it will stay constant from initial make invoke.
336 .MAKEFLAGS: WORLD_VERSION=${WORLD_VERSION}
337 .endif
338
339 .include <bsd.cpu.mk>
340
341 .if exists(/etc/make.conf.local)
342 .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.
343 .include </etc/make.conf.local>
344 .endif
345
346 # Default executable format
347 # XXX hint for bsd.port.mk
348 OBJFORMAT?=     elf
349
350 # Tell bmake to expand -V VAR by default
351 .MAKE.EXPAND_VARIABLES= yes
352
353 .if !defined(.PARSEDIR)
354 # Not using bmake, which is aggressive about search .PATH
355 # It is sometimes necessary to curb its enthusiam with .NOPATH
356 # The following allows us to quietly ignore .NOPATH when no using bmake.
357 .NOTMAIN: .NOPATH
358 .NOPATH:
359
360 .endif