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