xref: /freebsd/share/mk/bsd.sys.mk (revision 97ca2ada80b870edbbb4f66b26e274cf8e55e0bc)
1#
2# This file contains common settings used for building FreeBSD
3# sources.
4
5# Enable various levels of compiler warning checks.  These may be
6# overridden (e.g. if using a non-gcc compiler) by defining MK_WARNS=no.
7
8# for GCC:   https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
9# for clang: https://clang.llvm.org/docs/DiagnosticsReference.html
10
11.include <bsd.compiler.mk>
12
13CSTD?=		gnu17
14
15.if ${CSTD} == "c89" || ${CSTD} == "c90"
16CFLAGS+=	-std=iso9899:1990
17.elif ${CSTD} == "c94" || ${CSTD} == "c95"
18CFLAGS+=	-std=iso9899:199409
19.elif ${CSTD} == "c99"
20CFLAGS+=	-std=iso9899:1999
21.else # CSTD
22CFLAGS+=	-std=${CSTD}
23.endif # CSTD
24
25.if !empty(CXXSTD)
26CXXFLAGS+=	-std=${CXXSTD}
27.endif
28
29# This gives the Makefile we're evaluating at the top-level a chance to set
30# WARNS.  If it doesn't do so, we may freely pull a DEFAULTWARNS if it's set
31# and use that.  This allows us to default WARNS to 6 for src builds without
32# needing to set the default in various Makefile.inc.
33.if !defined(WARNS) && defined(DEFAULTWARNS)
34WARNS=	${DEFAULTWARNS}
35.endif
36
37# -pedantic is problematic because it also imposes namespace restrictions
38#CFLAGS+=	-pedantic
39.if defined(WARNS)
40.if ${WARNS} >= 1
41CWARNFLAGS+=	-Wsystem-headers
42.if ${MK_WERROR} != "no" && ${MK_WERROR.${COMPILER_TYPE}:Uyes} != "no"
43CWARNFLAGS+=	-Werror
44.endif # ${MK_WERROR} != "no" && ${MK_WERROR.${COMPILER_TYPE}:Uyes} != "no"
45.endif # WARNS >= 1
46.if ${WARNS} >= 2
47CWARNFLAGS+=	-Wall -Wno-format-y2k
48.endif # WARNS >= 2
49.if ${WARNS} >= 3
50CWARNFLAGS+=	-W -Wno-unused-parameter
51.if ${COMPILER_TYPE} == "clang"
52CWARNFLAGS+=	-Wstrict-prototypes
53.endif
54CWARNFLAGS+=	-Wmissing-prototypes -Wpointer-arith
55.endif # WARNS >= 3
56.if ${WARNS} >= 4
57CWARNFLAGS+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\
58		-Wunused-parameter
59.if !defined(NO_WCAST_ALIGN) && !defined(NO_WCAST_ALIGN.${COMPILER_TYPE})
60CWARNFLAGS+=	-Wcast-align
61.endif # !NO_WCAST_ALIGN !NO_WCAST_ALIGN.${COMPILER_TYPE}
62.endif # WARNS >= 4
63.if ${WARNS} >= 6
64CWARNFLAGS+=	-Wchar-subscripts -Wnested-externs \
65		-Wold-style-definition
66.if !defined(NO_WMISSING_VARIABLE_DECLARATIONS)
67CWARNFLAGS.clang+=	-Wmissing-variable-declarations
68.endif
69.if !defined(NO_WTHREAD_SAFETY)
70CWARNFLAGS.clang+=	-Wthread-safety
71.endif
72.endif # WARNS >= 6
73.if ${WARNS} >= 2 && ${WARNS} <= 4
74# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
75# XXX always get it right.
76CWARNFLAGS+=	-Wno-uninitialized
77.endif # WARNS >=2 && WARNS <= 4
78CWARNFLAGS+=	-Wno-pointer-sign
79.if !defined(NO_WDATE_TIME)
80CWARNFLAGS+=	-Wdate-time
81.endif # NO_WDATE_TIME
82# Clang has more warnings enabled by default, and when using -Wall, so if WARNS
83# is set to low values, these have to be disabled explicitly.
84.if ${WARNS} <= 6
85CWARNFLAGS.clang+=	-Wno-empty-body -Wno-string-plus-int
86CWARNFLAGS.clang+=	-Wno-unused-const-variable
87.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000
88CWARNFLAGS.clang+=	-Wno-error=unused-but-set-parameter
89.endif
90.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 190000
91# Similar to gcc >= 8.1 -Wno-error=cast-function-type below
92CWARNFLAGS.clang+=	-Wno-error=cast-function-type-mismatch
93.endif
94.endif # WARNS <= 6
95.if ${WARNS} <= 3
96CWARNFLAGS.clang+=	-Wno-tautological-compare -Wno-unused-value\
97		-Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion
98CWARNFLAGS.clang+=	-Wno-unused-local-typedef
99CWARNFLAGS.clang+=	-Wno-address-of-packed-member
100.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 90100
101CWARNFLAGS.gcc+=	-Wno-address-of-packed-member
102.endif
103.endif # WARNS <= 3
104.if ${WARNS} <= 2
105CWARNFLAGS.clang+=	-Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter
106.endif # WARNS <= 2
107.if ${WARNS} <= 1
108CWARNFLAGS.clang+=	-Wno-parentheses
109.endif # WARNS <= 1
110.if defined(NO_WARRAY_BOUNDS)
111CWARNFLAGS.clang+=	-Wno-array-bounds
112.endif # NO_WARRAY_BOUNDS
113.if defined(NO_WMISLEADING_INDENTATION) && \
114    ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 100000) || \
115      ${COMPILER_TYPE} == "gcc")
116CWARNFLAGS+=		-Wno-misleading-indentation
117.endif # NO_WMISLEADING_INDENTATION
118.if ${COMPILER_VERSION} >= 130000
119NO_WUNUSED_BUT_SET_VARIABLE=	-Wno-unused-but-set-variable
120.endif
121.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 140000
122NO_WBITWISE_INSTEAD_OF_LOGICAL=	-Wno-bitwise-instead-of-logical
123.endif
124.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000
125NO_WARRAY_PARAMETER=	-Wno-array-parameter
126NO_WSTRICT_PROTOTYPES=	-Wno-strict-prototypes
127NO_WDEPRECATED_NON_PROTOTYPE=-Wno-deprecated-non-prototype
128.endif
129.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50200
130NO_WUNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable
131.endif
132.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 100100
133NO_WZERO_LENGTH_BOUNDS=	-Wno-zero-length-bounds
134.endif
135.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 110100
136NO_WARRAY_PARAMETER=	-Wno-array-parameter
137.endif
138.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120100
139NO_WUSE_AFTER_FREE=	-Wno-use-after-free
140NO_WDANGLING_POINTER=	-Wno-dangling-pointer
141.endif
142.endif # WARNS
143
144.if defined(FORMAT_AUDIT)
145WFORMAT=	1
146.endif # FORMAT_AUDIT
147.if defined(WFORMAT)
148.if ${WFORMAT} > 0
149#CWARNFLAGS+=	-Wformat-nonliteral -Wformat-security -Wno-format-extra-args
150CWARNFLAGS+=	-Wformat=2 -Wno-format-extra-args
151.if ${WARNS:U0} <= 3
152CWARNFLAGS.clang+=	-Wno-format-nonliteral
153.endif # WARNS <= 3
154.if ${MK_WERROR} != "no" && ${MK_WERROR.${COMPILER_TYPE}:Uyes} != "no"
155CWARNFLAGS+=	-Werror
156.endif # ${MK_WERROR} != "no" && ${MK_WERROR.${COMPILER_TYPE}:Uyes} != "no"
157.endif # WFORMAT > 0
158.endif # WFORMAT
159.if defined(NO_WFORMAT) || defined(NO_WFORMAT.${COMPILER_TYPE})
160CWARNFLAGS+=	-Wno-format
161.endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE}
162
163# GCC
164# We should clean up warnings produced with these flags.
165# They were originally added as a quick hack to enable gcc5/6.
166# The base system requires at least GCC 6.4, but some ports
167# use this file with older compilers.  Request an exprun
168# before changing these.
169.if ${COMPILER_TYPE} == "gcc"
170# GCC 5.2.0
171.if ${COMPILER_VERSION} >= 50200
172CWARNFLAGS+=	-Wno-error=address			\
173		-Wno-error=array-bounds			\
174		-Wno-error=attributes			\
175		-Wno-error=bool-compare			\
176		-Wno-error=cast-align			\
177		-Wno-error=clobbered			\
178		-Wno-error=deprecated-declarations	\
179		-Wno-error=enum-compare			\
180		-Wno-error=extra			\
181		-Wno-error=logical-not-parentheses	\
182		-Wno-error=strict-aliasing		\
183		-Wno-error=uninitialized		\
184		-Wno-error=unused-function		\
185		-Wno-error=unused-value
186.endif
187
188# GCC 6.1.0
189.if ${COMPILER_VERSION} >= 60100
190CWARNFLAGS+=	-Wno-error=empty-body			\
191		-Wno-error=maybe-uninitialized		\
192		-Wno-error=nonnull-compare		\
193		-Wno-error=shift-negative-value		\
194		-Wno-error=tautological-compare		\
195		-Wno-error=unused-const-variable
196.endif
197
198# GCC 7.1.0
199.if ${COMPILER_VERSION} >= 70100
200CWARNFLAGS+=	-Wno-error=bool-operation		\
201		-Wno-error=deprecated			\
202		-Wno-error=expansion-to-defined		\
203		-Wno-error=format-overflow		\
204		-Wno-error=format-truncation		\
205		-Wno-error=implicit-fallthrough		\
206		-Wno-error=int-in-bool-context		\
207		-Wno-error=memset-elt-size		\
208		-Wno-error=noexcept-type		\
209		-Wno-error=nonnull			\
210		-Wno-error=pointer-compare		\
211		-Wno-error=stringop-overflow
212.endif
213
214# GCC 8.1.0
215.if ${COMPILER_VERSION} >= 80100
216CWARNFLAGS+=	-Wno-error=aggressive-loop-optimizations	\
217		-Wno-error=cast-function-type			\
218		-Wno-error=catch-value				\
219		-Wno-error=multistatement-macros		\
220		-Wno-error=restrict				\
221		-Wno-error=sizeof-pointer-memaccess		\
222		-Wno-error=stringop-truncation
223CXXWARNFLAGS+=	-Wno-error=class-memaccess
224.endif
225
226# GCC 9.2.0
227.if ${COMPILER_VERSION} >= 90200
228.if ${MACHINE_ARCH} == "i386"
229CWARNFLAGS+=	-Wno-error=overflow
230.endif
231.endif
232
233# GCC 12.1.0
234.if ${COMPILER_VERSION} >= 120100
235# These warnings are raised by headers in libc++ so are disabled
236# globally for all C++
237CXXWARNFLAGS+=	-Wno-literal-suffix 			\
238		-Wno-error=unknown-pragmas
239.endif
240
241# GCC 13.1.0
242.if ${COMPILER_VERSION} >= 130100
243# These warnings are raised by headers in libc++ so are disabled
244# globally for all C++
245CXXWARNFLAGS+=	-Wno-dangling-reference
246.endif
247
248# GCC produces false positives for functions that switch on an
249# enum (GCC bug 87950)
250CWARNFLAGS+=	-Wno-return-type
251
252# GCC's own arm_neon.h triggers various warnings
253.if ${MACHINE_CPUARCH} == "aarch64"
254CWARNFLAGS+=	-Wno-system-headers
255.endif
256.endif	# gcc
257
258# How to handle FreeBSD custom printf format specifiers.
259.if ${COMPILER_TYPE} == "clang" || \
260    (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120100)
261FORMAT_EXTENSIONS=	-D__printf__=__freebsd_kprintf__
262.else
263FORMAT_EXTENSIONS=	-fformat-extensions
264.endif
265
266.if defined(IGNORE_PRAGMA)
267CWARNFLAGS+=	-Wno-unknown-pragmas
268.endif # IGNORE_PRAGMA
269
270# This warning is utter nonsense
271CFLAGS+=	-Wno-format-zero-length
272
273.if ${COMPILER_TYPE} == "clang"
274# The headers provided by clang are incompatible with the FreeBSD headers.
275# If the version of clang is not one that has been patched to omit the
276# incompatible headers, we need to compile with -nobuiltininc and add the
277# resource dir to the end of the search paths. This ensures that headers such as
278# immintrin.h are still found but stddef.h, etc. are picked up from FreeBSD.
279#
280# XXX: This is a hack to support complete external installs of clang while
281# we work to synchronize our decleration guards with those in the clang tree.
282.if ${MK_CLANG_BOOTSTRAP:Uno} == "no" && \
283    ${COMPILER_RESOURCE_DIR} != "unknown" && !defined(BOOTSTRAPPING)
284CFLAGS+=-nobuiltininc -idirafter ${COMPILER_RESOURCE_DIR}/include
285.endif
286.endif
287
288CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3
289.if ${COMPILER_VERSION} < 130000
290CLANG_OPT_SMALL+= -mllvm -simplifycfg-dup-ret
291.endif
292CLANG_OPT_SMALL+= -mllvm -enable-load-pre=false
293CFLAGS.clang+=	 -Qunused-arguments
294# The libc++ headers use c++11 extensions.  These are normally silenced because
295# they are treated as system headers, but we explicitly disable that warning
296# suppression when building the base system to catch bugs in our headers.
297# Eventually we'll want to start building the base system C++ code as C++11,
298# but not yet.
299CXXFLAGS.clang+=	 -Wno-c++11-extensions
300
301# XXX This should be defaulted to 2 when WITH_SSP is in use after further
302# testing and soak time.
303FORTIFY_SOURCE?=	0
304.if ${MK_SSP} != "no"
305# Don't use -Wstack-protector as it breaks world with -Werror.
306.if ${COMPILER_FEATURES:Mstackclash}
307SSP_CFLAGS?=	-fstack-protector-strong -fstack-clash-protection
308.else
309SSP_CFLAGS?=	-fstack-protector-strong
310.endif
311CFLAGS+=	${SSP_CFLAGS}
312.endif # SSP
313.if ${FORTIFY_SOURCE} > 0
314CFLAGS+=	-D_FORTIFY_SOURCE=${FORTIFY_SOURCE}
315CXXFLAGS+=	-D_FORTIFY_SOURCE=${FORTIFY_SOURCE}
316.endif
317
318# Additional flags passed in CFLAGS and CXXFLAGS when MK_DEBUG_FILES is
319# enabled.
320DEBUG_FILES_CFLAGS?= -g -gz=zlib
321
322# Allow user-specified additional warning flags, plus compiler and file
323# specific flag overrides, unless we've overridden this...
324.if ${MK_WARNS} != "no"
325CFLAGS+=	${CWARNFLAGS:M*} ${CWARNFLAGS.${COMPILER_TYPE}}
326CFLAGS+=	${CWARNFLAGS.${.IMPSRC:T}}
327CXXFLAGS+=	${CXXWARNFLAGS:M*} ${CXXWARNFLAGS.${COMPILER_TYPE}}
328CXXFLAGS+=	${CXXWARNFLAGS.${.IMPSRC:T}}
329.endif
330
331CFLAGS+=	 ${CFLAGS.${COMPILER_TYPE}}
332CXXFLAGS+=	 ${CXXFLAGS.${COMPILER_TYPE}}
333
334AFLAGS+=	${AFLAGS.${.IMPSRC:T}}
335AFLAGS+=	${AFLAGS.${.TARGET:T}}
336ACFLAGS+=	${ACFLAGS.${.IMPSRC:T}}
337ACFLAGS+=	${ACFLAGS.${.TARGET:T}}
338CFLAGS+=	${CFLAGS.${.IMPSRC:T}}
339CXXFLAGS+=	${CXXFLAGS.${.IMPSRC:T}}
340
341LDFLAGS+=	${LDFLAGS.${LINKER_TYPE}}
342
343# Only allow .TARGET when not using PROGS as it has the same syntax
344# per PROG which is ambiguous with this syntax. This is only needed
345# for PROG_VARS vars.
346#
347# Some directories (currently just clang) also need to disable this since
348# CFLAGS.${COMPILER_TYPE}, CFLAGS.${.IMPSRC:T} and CFLAGS.${.TARGET:T} all live
349# in the same namespace, meaning that, for example, GCC builds of clang pick up
350# CFLAGS.clang via CFLAGS.${.TARGET:T} and thus try to pass Clang-specific
351# flags. Ideally the different sources of CFLAGS would be namespaced to avoid
352# collisions.
353.if !defined(_RECURSING_PROGS) && !defined(NO_TARGET_FLAGS)
354.if ${MK_WARNS} != "no"
355CFLAGS+=	${CWARNFLAGS.${.TARGET:T}}
356.endif
357CFLAGS+=	${CFLAGS.${.TARGET:T}}
358CXXFLAGS+=	${CXXFLAGS.${.TARGET:T}}
359LDFLAGS+=	${LDFLAGS.${.TARGET:T}}
360LDADD+=		${LDADD.${.TARGET:T}}
361LIBADD+=	${LIBADD.${.TARGET:T}}
362.endif
363
364.if defined(SRCTOP)
365# Prevent rebuilding during install to support read-only objdirs.
366.if ${.TARGETS:M*install*} == ${.TARGETS} && empty(.MAKE.MODE:Mmeta)
367CFLAGS+=	ERROR-tried-to-rebuild-during-make-install
368.endif
369.endif
370
371# Please keep this if in sync with kern.mk
372.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld")
373# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld".
374.if ${COMPILER_TYPE} == "clang"
375# Note: Clang does not like relative paths for ld so we map ld.lld -> lld.
376.if ${COMPILER_VERSION} >= 120000
377LDFLAGS+=	--ld-path=${LD:[1]:S/^ld.//1W}
378.else
379LDFLAGS+=	-fuse-ld=${LD:[1]:S/^ld.//1W}
380.endif
381.elif ${COMPILER_TYPE} == "gcc"
382# GCC does not support an absolute path for -fuse-ld so we just print this
383# warning instead and let the user add the required symlinks.
384# However, we can avoid this warning if -B is set appropriately (e.g. for
385# CROSS_TOOLCHAIN=...-gcc).
386.if !(${LD:[1]:T} == "ld" && ${CC:tw:M-B${LD:[1]:H}/})
387.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not supported
388.endif
389.endif
390.endif
391
392# Tell bmake not to mistake standard targets for things to be searched for
393# or expect to ever be up-to-date.
394PHONY_NOTMAIN = analyze afterdepend afterinstall all beforedepend beforeinstall \
395		beforelinking build build-tools buildconfig buildfiles \
396		buildincludes check checkdpadd clean cleandepend cleandir \
397		cleanobj configure depend distclean distribute exe \
398		files html includes install installconfig installdirs \
399		installfiles installincludes lint obj objlink objs objwarn \
400		realinstall tags whereobj
401
402# we don't want ${PROG} to be PHONY
403.PHONY: ${PHONY_NOTMAIN:N${PROG:U}}
404.NOTMAIN: ${PHONY_NOTMAIN:Nall}
405
406.if ${MK_STAGING} != "no"
407.if defined(_SKIP_BUILD) || (!make(all) && !make(clean*) && !make(*clean))
408_SKIP_STAGING?= yes
409.endif
410.if ${_SKIP_STAGING:Uno} == "yes"
411staging stage_libs stage_files stage_as stage_links stage_symlinks:
412.else
413# allow targets like beforeinstall to be leveraged
414DESTDIR= ${STAGE_OBJTOP}
415.export DESTDIR
416
417.if target(beforeinstall)
418.if !empty(_LIBS) || (${MK_STAGING_PROG} != "no" && !defined(INTERNALPROG))
419staging: beforeinstall
420.endif
421.endif
422
423# normally only libs and includes are staged
424.if ${MK_STAGING_PROG} != "no" && !defined(INTERNALPROG)
425STAGE_DIR.prog= ${STAGE_OBJTOP}${BINDIR}
426
427.if !empty(PROG)
428.if defined(PROGNAME)
429STAGE_AS_SETS+= prog
430STAGE_AS_${PROG}= ${PROGNAME}
431stage_as.prog: ${PROG}
432.else
433STAGE_SETS+= prog
434stage_files.prog: ${PROG}
435STAGE_TARGETS+= stage_files
436.endif
437.endif
438.endif
439
440.if !empty(_LIBS) && !defined(INTERNALLIB)
441.if defined(SHLIBDIR) && ${SHLIBDIR} != ${LIBDIR} && ${_LIBS:Uno:M*.so.*} != ""
442STAGE_SETS+= shlib
443STAGE_DIR.shlib= ${STAGE_OBJTOP}${SHLIBDIR}
444STAGE_FILES.shlib+= ${_LIBS:M*.so.*}
445stage_files.shlib: ${_LIBS:M*.so.*}
446.endif
447
448.if defined(SHLIB_LINK) && commands(${SHLIB_LINK:R}.ld)
449STAGE_AS_SETS+= ldscript
450STAGE_AS.ldscript+= ${SHLIB_LINK:R}.ld
451stage_as.ldscript: ${SHLIB_LINK:R}.ld
452STAGE_DIR.ldscript = ${STAGE_LIBDIR}
453STAGE_AS_${SHLIB_LINK:R}.ld:= ${SHLIB_LINK}
454NO_SHLIB_LINKS=
455.endif
456
457.if defined(STATIC_LDSCRIPT) && target(lib${LIB}.ald)
458STAGE_AS_SETS+= ald
459STAGE_DIR.ald = ${STAGE_LIBDIR}
460STAGE_AS.ald+= lib${LIB}.ald
461STAGE_AS_lib${LIB}.ald = lib${LIB}.a
462stage_as.ald: lib${LIB}.ald
463.endif
464
465.if target(stage_files.shlib)
466stage_libs: ${_LIBS}
467.if defined(DEBUG_FLAGS) && target(${SHLIB_NAME}.symbols)
468stage_files.shlib: ${SHLIB_NAME}.symbols
469.endif
470.else
471stage_libs: ${_LIBS}
472.endif
473.if defined(SHLIB_NAME) && defined(DEBUG_FLAGS) && target(${SHLIB_NAME}.symbols)
474stage_libs: ${SHLIB_NAME}.symbols
475.endif
476
477.endif
478
479.if !empty(INCS) || !empty(INCSGROUPS) && target(buildincludes)
480.if !defined(NO_BEFOREBUILD_INCLUDES)
481stage_includes: buildincludes
482beforebuild: stage_includes
483.endif
484.endif
485
486.for t in stage_libs stage_files stage_as
487.if target($t)
488STAGE_TARGETS+= $t
489.endif
490.endfor
491
492.if !empty(STAGE_AS_SETS)
493STAGE_TARGETS+= stage_as
494.endif
495
496.if !empty(STAGE_TARGETS) || (${MK_STAGING_PROG} != "no" && !defined(INTERNALPROG))
497
498.if !empty(LINKS)
499STAGE_TARGETS+= stage_links
500.if ${MAKE_VERSION} < 20131001
501stage_links.links: ${_LIBS} ${PROG}
502.endif
503STAGE_SETS+= links
504STAGE_LINKS.links= ${LINKS}
505.endif
506
507.if !empty(SYMLINKS)
508STAGE_TARGETS+= stage_symlinks
509STAGE_SETS+= links
510STAGE_SYMLINKS.links= ${SYMLINKS}
511.endif
512
513.endif
514
515.include <meta.stage.mk>
516.endif
517.endif
518
519.if defined(META_TARGETS)
520.for _tgt in ${META_TARGETS}
521.if target(${_tgt})
522${_tgt}: ${META_DEPS}
523.endif
524.endfor
525.endif
526
527# we are generally the last makefile read
528CFLAGS+= ${CFLAGS_LAST}
529CXXFLAGS+= ${CXXFLAGS_LAST}
530LDFLAGS+= ${LDFLAGS_LAST}
531