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