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