2001-05-19 23:18:21 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
# This file contains common settings used for building FreeBSD
|
|
|
|
# sources.
|
|
|
|
|
|
|
|
# Enable various levels of compiler warning checks. These may be
|
2014-05-10 16:37:53 +00:00
|
|
|
# overridden (e.g. if using a non-gcc compiler) by defining MK_WARNS=no.
|
2001-05-19 23:18:21 +00:00
|
|
|
|
2020-05-12 15:22:40 +00:00
|
|
|
# for GCC: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
|
2018-05-23 07:54:58 +00:00
|
|
|
# for clang: https://clang.llvm.org/docs/DiagnosticsReference.html
|
2002-05-10 01:58:16 +00:00
|
|
|
|
2012-09-13 16:00:46 +00:00
|
|
|
.include <bsd.compiler.mk>
|
|
|
|
|
2009-03-14 17:55:16 +00:00
|
|
|
# the default is gnu99 for now
|
2012-03-16 23:19:45 +00:00
|
|
|
CSTD?= gnu99
|
2009-03-14 17:55:16 +00:00
|
|
|
|
2018-05-23 07:54:58 +00:00
|
|
|
.if ${CSTD} == "c89" || ${CSTD} == "c90"
|
2012-03-16 23:19:45 +00:00
|
|
|
CFLAGS+= -std=iso9899:1990
|
2011-04-19 18:09:21 +00:00
|
|
|
.elif ${CSTD} == "c94" || ${CSTD} == "c95"
|
2012-03-16 23:19:45 +00:00
|
|
|
CFLAGS+= -std=iso9899:199409
|
2011-04-19 18:09:21 +00:00
|
|
|
.elif ${CSTD} == "c99"
|
2012-03-16 23:19:45 +00:00
|
|
|
CFLAGS+= -std=iso9899:1999
|
|
|
|
.else # CSTD
|
|
|
|
CFLAGS+= -std=${CSTD}
|
|
|
|
.endif # CSTD
|
Standardize `-std=c++* as `CXXSTD`
CXXSTD was added as the C++ analogue to CSTD.
CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`,
otherwise for older versions of g++.
This change standardizes the CXXSTD variable, originally added to
googletest.test.inc.mk as part of r345203.
As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`.
Notes:
This value is not sanity checked in bsd.sys.mk, however, given the two
most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is
likely to work with both toolchains. This method will be refined in the future
to support more variants of C++, as not all versions of clang++ and g++ (for
instance) support C++14, C++17, etc.
Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD.
Example:
Before this commit:
```
CXXFLAGS+= -std=c++14
```
After this commit:
```
CXXSTD= c++14
```
Reviewed by: asomers
Approved by: emaste (mentor)
MFC after: 1 month
MFC with: r345203, r345704, r345705
Relnotes: yes
Tested with: make tinderbox
Differential Revision: https://reviews.freebsd.org/D19732
2019-03-29 18:45:27 +00:00
|
|
|
|
2019-04-22 18:40:46 +00:00
|
|
|
.if !empty(CXXSTD)
|
Standardize `-std=c++* as `CXXSTD`
CXXSTD was added as the C++ analogue to CSTD.
CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`,
otherwise for older versions of g++.
This change standardizes the CXXSTD variable, originally added to
googletest.test.inc.mk as part of r345203.
As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`.
Notes:
This value is not sanity checked in bsd.sys.mk, however, given the two
most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is
likely to work with both toolchains. This method will be refined in the future
to support more variants of C++, as not all versions of clang++ and g++ (for
instance) support C++14, C++17, etc.
Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD.
Example:
Before this commit:
```
CXXFLAGS+= -std=c++14
```
After this commit:
```
CXXSTD= c++14
```
Reviewed by: asomers
Approved by: emaste (mentor)
MFC after: 1 month
MFC with: r345203, r345704, r345705
Relnotes: yes
Tested with: make tinderbox
Differential Revision: https://reviews.freebsd.org/D19732
2019-03-29 18:45:27 +00:00
|
|
|
CXXFLAGS+= -std=${CXXSTD}
|
2019-04-22 18:40:46 +00:00
|
|
|
.endif
|
Standardize `-std=c++* as `CXXSTD`
CXXSTD was added as the C++ analogue to CSTD.
CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`,
otherwise for older versions of g++.
This change standardizes the CXXSTD variable, originally added to
googletest.test.inc.mk as part of r345203.
As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`.
Notes:
This value is not sanity checked in bsd.sys.mk, however, given the two
most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is
likely to work with both toolchains. This method will be refined in the future
to support more variants of C++, as not all versions of clang++ and g++ (for
instance) support C++14, C++17, etc.
Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD.
Example:
Before this commit:
```
CXXFLAGS+= -std=c++14
```
After this commit:
```
CXXSTD= c++14
```
Reviewed by: asomers
Approved by: emaste (mentor)
MFC after: 1 month
MFC with: r345203, r345704, r345705
Relnotes: yes
Tested with: make tinderbox
Differential Revision: https://reviews.freebsd.org/D19732
2019-03-29 18:45:27 +00:00
|
|
|
|
2006-08-11 17:28:59 +00:00
|
|
|
# -pedantic is problematic because it also imposes namespace restrictions
|
2012-03-16 23:19:45 +00:00
|
|
|
#CFLAGS+= -pedantic
|
|
|
|
.if defined(WARNS)
|
|
|
|
.if ${WARNS} >= 1
|
2018-05-23 21:26:33 +00:00
|
|
|
CWARNFLAGS+= -Wsystem-headers
|
2014-04-25 19:25:57 +00:00
|
|
|
.if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE})
|
2012-03-16 23:19:45 +00:00
|
|
|
CWARNFLAGS+= -Werror
|
2014-04-25 19:25:57 +00:00
|
|
|
.endif # !NO_WERROR && !NO_WERROR.${COMPILER_TYPE}
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # WARNS >= 1
|
|
|
|
.if ${WARNS} >= 2
|
|
|
|
CWARNFLAGS+= -Wall -Wno-format-y2k
|
|
|
|
.endif # WARNS >= 2
|
|
|
|
.if ${WARNS} >= 3
|
|
|
|
CWARNFLAGS+= -W -Wno-unused-parameter -Wstrict-prototypes\
|
|
|
|
-Wmissing-prototypes -Wpointer-arith
|
|
|
|
.endif # WARNS >= 3
|
|
|
|
.if ${WARNS} >= 4
|
|
|
|
CWARNFLAGS+= -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\
|
|
|
|
-Wunused-parameter
|
2014-04-25 19:25:57 +00:00
|
|
|
.if !defined(NO_WCAST_ALIGN) && !defined(NO_WCAST_ALIGN.${COMPILER_TYPE})
|
2012-03-16 23:19:45 +00:00
|
|
|
CWARNFLAGS+= -Wcast-align
|
2014-04-25 19:25:57 +00:00
|
|
|
.endif # !NO_WCAST_ALIGN !NO_WCAST_ALIGN.${COMPILER_TYPE}
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # WARNS >= 4
|
|
|
|
.if ${WARNS} >= 6
|
|
|
|
CWARNFLAGS+= -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls\
|
|
|
|
-Wold-style-definition
|
2014-05-05 22:03:08 +00:00
|
|
|
.if !defined(NO_WMISSING_VARIABLE_DECLARATIONS)
|
2014-05-05 22:03:01 +00:00
|
|
|
CWARNFLAGS.clang+= -Wmissing-variable-declarations
|
2013-04-19 19:45:00 +00:00
|
|
|
.endif
|
2014-09-01 20:18:09 +00:00
|
|
|
.if !defined(NO_WTHREAD_SAFETY)
|
|
|
|
CWARNFLAGS.clang+= -Wthread-safety
|
|
|
|
.endif
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # WARNS >= 6
|
|
|
|
.if ${WARNS} >= 2 && ${WARNS} <= 4
|
2002-01-05 20:17:50 +00:00
|
|
|
# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
|
|
|
|
# XXX always get it right.
|
2012-03-16 23:19:45 +00:00
|
|
|
CWARNFLAGS+= -Wno-uninitialized
|
|
|
|
.endif # WARNS >=2 && WARNS <= 4
|
|
|
|
CWARNFLAGS+= -Wno-pointer-sign
|
2011-12-15 22:08:08 +00:00
|
|
|
# Clang has more warnings enabled by default, and when using -Wall, so if WARNS
|
|
|
|
# is set to low values, these have to be disabled explicitly.
|
2012-04-16 21:23:25 +00:00
|
|
|
.if ${WARNS} <= 6
|
2014-05-10 16:37:44 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-empty-body -Wno-string-plus-int
|
2017-12-24 16:34:54 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-unused-const-variable
|
2012-04-16 21:23:25 +00:00
|
|
|
.endif # WARNS <= 6
|
2012-03-16 23:19:45 +00:00
|
|
|
.if ${WARNS} <= 3
|
2014-05-05 22:03:01 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-tautological-compare -Wno-unused-value\
|
2013-12-07 22:30:07 +00:00
|
|
|
-Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion
|
2015-01-28 07:29:38 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-unused-local-typedef
|
2017-01-08 14:49:50 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-address-of-packed-member
|
2019-12-21 02:43:49 +00:00
|
|
|
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 90100
|
|
|
|
CWARNFLAGS.gcc+= -Wno-address-of-packed-member
|
|
|
|
.endif
|
2018-08-05 18:27:36 +00:00
|
|
|
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 70000 && \
|
|
|
|
${MACHINE_CPUARCH} == "arm" && !${MACHINE_ARCH:Marmv[67]*}
|
|
|
|
CWARNFLAGS.clang+= -Wno-atomic-alignment
|
|
|
|
.endif
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # WARNS <= 3
|
|
|
|
.if ${WARNS} <= 2
|
2014-05-05 22:03:01 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # WARNS <= 2
|
|
|
|
.if ${WARNS} <= 1
|
2014-05-05 22:03:01 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-parentheses
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # WARNS <= 1
|
|
|
|
.if defined(NO_WARRAY_BOUNDS)
|
2014-05-05 22:03:01 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-array-bounds
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # NO_WARRAY_BOUNDS
|
2020-01-31 19:02:53 +00:00
|
|
|
.if defined(NO_WMISLEADING_INDENTATION) && \
|
|
|
|
((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 100000) || \
|
2020-05-12 15:22:40 +00:00
|
|
|
${COMPILER_TYPE} == "gcc")
|
2020-01-31 19:02:53 +00:00
|
|
|
CWARNFLAGS+= -Wno-misleading-indentation
|
|
|
|
.endif # NO_WMISLEADING_INDENTATION
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # WARNS
|
2001-05-19 23:18:21 +00:00
|
|
|
|
2012-03-16 23:19:45 +00:00
|
|
|
.if defined(FORMAT_AUDIT)
|
|
|
|
WFORMAT= 1
|
|
|
|
.endif # FORMAT_AUDIT
|
|
|
|
.if defined(WFORMAT)
|
|
|
|
.if ${WFORMAT} > 0
|
|
|
|
#CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
|
|
|
|
CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args
|
2012-04-16 21:23:25 +00:00
|
|
|
.if ${WARNS} <= 3
|
2014-05-05 22:03:01 +00:00
|
|
|
CWARNFLAGS.clang+= -Wno-format-nonliteral
|
2012-04-16 21:23:25 +00:00
|
|
|
.endif # WARNS <= 3
|
2014-04-25 19:25:57 +00:00
|
|
|
.if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE})
|
2012-03-16 23:19:45 +00:00
|
|
|
CWARNFLAGS+= -Werror
|
2014-04-25 19:25:57 +00:00
|
|
|
.endif # !NO_WERROR && !NO_WERROR.${COMPILER_TYPE}
|
2012-03-16 23:19:45 +00:00
|
|
|
.endif # WFORMAT > 0
|
|
|
|
.endif # WFORMAT
|
2014-04-25 19:25:57 +00:00
|
|
|
.if defined(NO_WFORMAT) || defined(NO_WFORMAT.${COMPILER_TYPE})
|
2012-03-16 23:19:45 +00:00
|
|
|
CWARNFLAGS+= -Wno-format
|
2014-04-25 19:25:57 +00:00
|
|
|
.endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE}
|
2001-05-19 23:18:21 +00:00
|
|
|
|
2020-05-12 15:22:40 +00:00
|
|
|
# GCC
|
|
|
|
# We should clean up warnings produced with these flags.
|
|
|
|
# They were originally added as a quick hack to enable gcc5/6.
|
2020-05-28 21:56:31 +00:00
|
|
|
# The base system requires at least GCC 6.4, but some ports
|
|
|
|
# use this file with older compilers. Request an exprun
|
|
|
|
# before changing these.
|
2020-05-12 15:22:40 +00:00
|
|
|
.if ${COMPILER_TYPE} == "gcc"
|
2020-05-28 21:56:31 +00:00
|
|
|
# GCC 5.2.0
|
|
|
|
.if ${COMPILER_VERSION} >= 50200
|
2016-07-24 18:04:12 +00:00
|
|
|
CWARNFLAGS+= -Wno-error=address \
|
|
|
|
-Wno-error=array-bounds \
|
|
|
|
-Wno-error=attributes \
|
|
|
|
-Wno-error=bool-compare \
|
|
|
|
-Wno-error=cast-align \
|
|
|
|
-Wno-error=clobbered \
|
2019-09-14 19:16:28 +00:00
|
|
|
-Wno-error=deprecated-declarations \
|
2016-07-24 18:04:12 +00:00
|
|
|
-Wno-error=enum-compare \
|
|
|
|
-Wno-error=extra \
|
|
|
|
-Wno-error=inline \
|
|
|
|
-Wno-error=logical-not-parentheses \
|
|
|
|
-Wno-error=strict-aliasing \
|
|
|
|
-Wno-error=uninitialized \
|
|
|
|
-Wno-error=unused-but-set-variable \
|
|
|
|
-Wno-error=unused-function \
|
|
|
|
-Wno-error=unused-value
|
2020-05-28 21:56:31 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# GCC 6.1.0
|
|
|
|
.if ${COMPILER_VERSION} >= 60100
|
2020-08-04 18:19:29 +00:00
|
|
|
CWARNFLAGS+= -Wno-error=maybe-uninitialized \
|
|
|
|
-Wno-error=nonnull-compare \
|
2020-05-28 21:56:31 +00:00
|
|
|
-Wno-error=shift-negative-value \
|
|
|
|
-Wno-error=tautological-compare \
|
|
|
|
-Wno-error=unused-const-variable
|
|
|
|
.endif
|
2016-07-22 15:00:38 +00:00
|
|
|
|
2017-07-21 14:50:32 +00:00
|
|
|
# GCC 7.1.0
|
2020-05-12 15:22:40 +00:00
|
|
|
.if ${COMPILER_VERSION} >= 70100
|
2018-06-04 16:21:18 +00:00
|
|
|
CWARNFLAGS+= -Wno-error=bool-operation \
|
|
|
|
-Wno-error=deprecated \
|
|
|
|
-Wno-error=expansion-to-defined \
|
|
|
|
-Wno-error=format-overflow \
|
2017-07-21 14:50:32 +00:00
|
|
|
-Wno-error=format-truncation \
|
|
|
|
-Wno-error=implicit-fallthrough \
|
|
|
|
-Wno-error=int-in-bool-context \
|
|
|
|
-Wno-error=memset-elt-size \
|
2018-07-19 12:56:54 +00:00
|
|
|
-Wno-error=noexcept-type \
|
2018-06-04 16:21:18 +00:00
|
|
|
-Wno-error=nonnull \
|
|
|
|
-Wno-error=pointer-compare \
|
|
|
|
-Wno-error=stringop-overflow
|
2017-07-21 14:50:32 +00:00
|
|
|
.endif
|
|
|
|
|
2018-07-03 10:51:59 +00:00
|
|
|
# GCC 8.1.0
|
2020-05-12 15:22:40 +00:00
|
|
|
.if ${COMPILER_VERSION} >= 80100
|
2018-07-03 10:51:59 +00:00
|
|
|
CWARNFLAGS+= -Wno-error=aggressive-loop-optimizations \
|
|
|
|
-Wno-error=cast-function-type \
|
2018-07-18 11:31:15 +00:00
|
|
|
-Wno-error=catch-value \
|
2018-07-03 10:51:59 +00:00
|
|
|
-Wno-error=multistatement-macros \
|
|
|
|
-Wno-error=restrict \
|
|
|
|
-Wno-error=sizeof-pointer-memaccess \
|
|
|
|
-Wno-error=stringop-truncation
|
|
|
|
.endif
|
2020-05-12 15:22:40 +00:00
|
|
|
.endif # gcc
|
2018-07-03 10:51:59 +00:00
|
|
|
|
2015-01-28 18:36:33 +00:00
|
|
|
# How to handle FreeBSD custom printf format specifiers.
|
2020-05-12 15:22:40 +00:00
|
|
|
.if ${COMPILER_TYPE} == "clang"
|
2015-01-28 18:36:33 +00:00
|
|
|
FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__
|
|
|
|
.else
|
|
|
|
FORMAT_EXTENSIONS= -fformat-extensions
|
|
|
|
.endif
|
|
|
|
|
2006-11-04 04:39:05 +00:00
|
|
|
.if defined(IGNORE_PRAGMA)
|
2012-03-16 23:19:45 +00:00
|
|
|
CWARNFLAGS+= -Wno-unknown-pragmas
|
|
|
|
.endif # IGNORE_PRAGMA
|
2006-11-04 04:39:05 +00:00
|
|
|
|
2019-08-08 03:27:46 +00:00
|
|
|
# This warning is utter nonsense
|
2019-08-08 04:29:46 +00:00
|
|
|
CFLAGS+= -Wno-format-zero-length
|
2019-08-08 03:27:46 +00:00
|
|
|
|
2020-04-06 23:38:46 +00:00
|
|
|
.if ${COMPILER_TYPE} == "clang"
|
|
|
|
# The headers provided by clang are incompatible with the FreeBSD headers.
|
|
|
|
# If the version of clang is not one that has been patched to omit the
|
|
|
|
# incompatible headers, we need to compile with -nobuiltininc and add the
|
|
|
|
# resource dir to the end of the search paths. This ensures that headers such as
|
|
|
|
# immintrin.h are still found but stddef.h, etc. are picked up from FreeBSD.
|
|
|
|
#
|
|
|
|
# XXX: This is a hack to support complete external installs of clang while
|
|
|
|
# we work to synchronize our decleration guards with those in the clang tree.
|
2020-04-07 15:10:04 +00:00
|
|
|
.if ${MK_CLANG_BOOTSTRAP:Uno} == "no" && \
|
|
|
|
${COMPILER_RESOURCE_DIR} != "unknown" && !defined(BOOTSTRAPPING)
|
2020-04-06 23:38:46 +00:00
|
|
|
CFLAGS+=-nobuiltininc -idirafter ${COMPILER_RESOURCE_DIR}/include
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2012-04-16 21:23:25 +00:00
|
|
|
CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\
|
2015-03-21 19:13:13 +00:00
|
|
|
-mllvm -simplifycfg-dup-ret
|
2015-03-28 12:23:15 +00:00
|
|
|
CLANG_OPT_SMALL+= -mllvm -enable-load-pre=false
|
2014-05-05 22:03:01 +00:00
|
|
|
CFLAGS.clang+= -Qunused-arguments
|
2014-02-21 22:38:25 +00:00
|
|
|
# The libc++ headers use c++11 extensions. These are normally silenced because
|
|
|
|
# they are treated as system headers, but we explicitly disable that warning
|
|
|
|
# suppression when building the base system to catch bugs in our headers.
|
|
|
|
# Eventually we'll want to start building the base system C++ code as C++11,
|
|
|
|
# but not yet.
|
2014-05-05 22:03:01 +00:00
|
|
|
CXXFLAGS.clang+= -Wno-c++11-extensions
|
2012-02-28 18:30:18 +00:00
|
|
|
|
2014-07-07 00:27:09 +00:00
|
|
|
.if ${MK_SSP} != "no" && \
|
2011-04-19 18:09:21 +00:00
|
|
|
${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
|
2008-06-25 21:33:28 +00:00
|
|
|
# Don't use -Wstack-protector as it breaks world with -Werror.
|
2015-10-04 18:54:02 +00:00
|
|
|
SSP_CFLAGS?= -fstack-protector-strong
|
2015-10-18 04:07:40 +00:00
|
|
|
CFLAGS+= ${SSP_CFLAGS}
|
2014-07-07 00:27:09 +00:00
|
|
|
.endif # SSP && !ARM && !MIPS
|
2008-06-25 21:33:28 +00:00
|
|
|
|
2017-08-23 23:30:25 +00:00
|
|
|
# Additional flags passed in CFLAGS and CXXFLAGS when MK_DEBUG_FILES is
|
|
|
|
# enabled.
|
|
|
|
DEBUG_FILES_CFLAGS?= -g
|
|
|
|
|
2016-01-14 10:09:05 +00:00
|
|
|
# Allow user-specified additional warning flags, plus compiler and file
|
2018-07-27 10:44:38 +00:00
|
|
|
# specific flag overrides, unless we've overridden this...
|
2014-05-10 16:37:53 +00:00
|
|
|
.if ${MK_WARNS} != "no"
|
2016-07-28 17:18:02 +00:00
|
|
|
CFLAGS+= ${CWARNFLAGS:M*} ${CWARNFLAGS.${COMPILER_TYPE}}
|
2016-01-14 10:09:05 +00:00
|
|
|
CFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
|
2019-07-30 19:34:39 +00:00
|
|
|
CXXFLAGS+= ${CXXWARNFLAGS:M*} ${CXXWARNFLAGS.${COMPILER_TYPE}}
|
|
|
|
CXXFLAGS+= ${CXXWARNFLAGS.${.IMPSRC:T}}
|
2014-05-05 22:03:08 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
CFLAGS+= ${CFLAGS.${COMPILER_TYPE}}
|
|
|
|
CXXFLAGS+= ${CXXFLAGS.${COMPILER_TYPE}}
|
2012-10-06 20:01:05 +00:00
|
|
|
|
2016-06-22 20:31:49 +00:00
|
|
|
AFLAGS+= ${AFLAGS.${.IMPSRC:T}}
|
2019-06-15 17:08:24 +00:00
|
|
|
AFLAGS+= ${AFLAGS.${.TARGET:T}}
|
2016-03-26 03:46:12 +00:00
|
|
|
ACFLAGS+= ${ACFLAGS.${.IMPSRC:T}}
|
2019-06-15 17:08:24 +00:00
|
|
|
ACFLAGS+= ${ACFLAGS.${.TARGET:T}}
|
2016-03-26 03:46:12 +00:00
|
|
|
CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
|
|
|
|
CXXFLAGS+= ${CXXFLAGS.${.IMPSRC:T}}
|
|
|
|
|
2018-04-19 20:58:09 +00:00
|
|
|
LDFLAGS+= ${LDFLAGS.${LINKER_TYPE}}
|
2019-06-19 19:19:37 +00:00
|
|
|
|
|
|
|
# Only allow .TARGET when not using PROGS as it has the same syntax
|
|
|
|
# per PROG which is ambiguous with this syntax. This is only needed
|
|
|
|
# for PROG_VARS vars.
|
|
|
|
.if !defined(_RECURSING_PROGS)
|
|
|
|
.if ${MK_WARNS} != "no"
|
|
|
|
CFLAGS+= ${CWARNFLAGS.${.TARGET:T}}
|
|
|
|
.endif
|
|
|
|
CFLAGS+= ${CFLAGS.${.TARGET:T}}
|
|
|
|
CXXFLAGS+= ${CXXFLAGS.${.TARGET:T}}
|
2019-06-15 17:08:24 +00:00
|
|
|
LDFLAGS+= ${LDFLAGS.${.TARGET:T}}
|
|
|
|
LDADD+= ${LDADD.${.TARGET:T}}
|
|
|
|
LIBADD+= ${LIBADD.${.TARGET:T}}
|
2019-06-19 19:19:37 +00:00
|
|
|
.endif
|
2018-04-19 20:58:09 +00:00
|
|
|
|
2016-04-18 18:14:02 +00:00
|
|
|
.if defined(SRCTOP)
|
|
|
|
# Prevent rebuilding during install to support read-only objdirs.
|
2016-11-13 00:11:09 +00:00
|
|
|
.if ${.TARGETS:M*install*} == ${.TARGETS} && empty(.MAKE.MODE:Mmeta)
|
2016-04-18 18:14:02 +00:00
|
|
|
CFLAGS+= ERROR-tried-to-rebuild-during-make-install
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2012-10-06 20:01:05 +00:00
|
|
|
# Tell bmake not to mistake standard targets for things to be searched for
|
|
|
|
# or expect to ever be up-to-date.
|
2016-02-26 22:14:00 +00:00
|
|
|
PHONY_NOTMAIN = analyze afterdepend afterinstall all beforedepend beforeinstall \
|
2015-10-14 20:38:51 +00:00
|
|
|
beforelinking build build-tools buildconfig buildfiles \
|
2016-02-07 18:40:04 +00:00
|
|
|
buildincludes check checkdpadd clean cleandepend cleandir \
|
2016-02-26 22:13:35 +00:00
|
|
|
cleanobj configure depend distclean distribute exe \
|
2018-09-17 22:14:53 +00:00
|
|
|
files html includes install installconfig installdirs \
|
|
|
|
installfiles installincludes lint obj objlink objs objwarn \
|
2016-02-26 22:13:35 +00:00
|
|
|
realinstall tags whereobj
|
2012-10-06 20:01:05 +00:00
|
|
|
|
2013-10-12 23:51:00 +00:00
|
|
|
# we don't want ${PROG} to be PHONY
|
|
|
|
.PHONY: ${PHONY_NOTMAIN:N${PROG:U}}
|
2014-05-16 14:51:19 +00:00
|
|
|
.NOTMAIN: ${PHONY_NOTMAIN:Nall}
|
2013-03-04 21:36:34 +00:00
|
|
|
|
|
|
|
.if ${MK_STAGING} != "no"
|
2019-07-04 14:51:44 +00:00
|
|
|
.if defined(_SKIP_BUILD) || (!make(all) && !make(clean*) && !make(*clean))
|
2013-10-12 23:51:00 +00:00
|
|
|
_SKIP_STAGING?= yes
|
|
|
|
.endif
|
|
|
|
.if ${_SKIP_STAGING:Uno} == "yes"
|
2013-03-08 22:02:08 +00:00
|
|
|
staging stage_libs stage_files stage_as stage_links stage_symlinks:
|
2013-03-04 21:36:34 +00:00
|
|
|
.else
|
|
|
|
# allow targets like beforeinstall to be leveraged
|
|
|
|
DESTDIR= ${STAGE_OBJTOP}
|
2016-03-11 23:45:05 +00:00
|
|
|
.export DESTDIR
|
2013-03-04 21:36:34 +00:00
|
|
|
|
2016-03-11 23:45:02 +00:00
|
|
|
.if target(beforeinstall)
|
2015-11-20 00:22:55 +00:00
|
|
|
.if !empty(_LIBS) || (${MK_STAGING_PROG} != "no" && !defined(INTERNALPROG))
|
2013-03-08 22:02:08 +00:00
|
|
|
staging: beforeinstall
|
2013-03-04 21:36:34 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# normally only libs and includes are staged
|
2015-11-20 00:22:55 +00:00
|
|
|
.if ${MK_STAGING_PROG} != "no" && !defined(INTERNALPROG)
|
2013-03-04 21:36:34 +00:00
|
|
|
STAGE_DIR.prog= ${STAGE_OBJTOP}${BINDIR}
|
|
|
|
|
2016-03-09 03:22:20 +00:00
|
|
|
.if !empty(PROG)
|
2013-03-04 21:36:34 +00:00
|
|
|
.if defined(PROGNAME)
|
|
|
|
STAGE_AS_SETS+= prog
|
|
|
|
STAGE_AS_${PROG}= ${PROGNAME}
|
|
|
|
stage_as.prog: ${PROG}
|
|
|
|
.else
|
|
|
|
STAGE_SETS+= prog
|
|
|
|
stage_files.prog: ${PROG}
|
2015-10-07 00:24:27 +00:00
|
|
|
STAGE_TARGETS+= stage_files
|
2013-03-04 21:36:34 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(_LIBS) && !defined(INTERNALLIB)
|
2014-05-16 14:51:19 +00:00
|
|
|
.if defined(SHLIBDIR) && ${SHLIBDIR} != ${LIBDIR} && ${_LIBS:Uno:M*.so.*} != ""
|
|
|
|
STAGE_SETS+= shlib
|
|
|
|
STAGE_DIR.shlib= ${STAGE_OBJTOP}${SHLIBDIR}
|
|
|
|
STAGE_FILES.shlib+= ${_LIBS:M*.so.*}
|
|
|
|
stage_files.shlib: ${_LIBS:M*.so.*}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if defined(SHLIB_LINK) && commands(${SHLIB_LINK:R}.ld)
|
|
|
|
STAGE_AS_SETS+= ldscript
|
|
|
|
STAGE_AS.ldscript+= ${SHLIB_LINK:R}.ld
|
|
|
|
stage_as.ldscript: ${SHLIB_LINK:R}.ld
|
|
|
|
STAGE_DIR.ldscript = ${STAGE_LIBDIR}
|
|
|
|
STAGE_AS_${SHLIB_LINK:R}.ld:= ${SHLIB_LINK}
|
|
|
|
NO_SHLIB_LINKS=
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if target(stage_files.shlib)
|
|
|
|
stage_libs: ${_LIBS}
|
|
|
|
.if defined(DEBUG_FLAGS) && target(${SHLIB_NAME}.symbols)
|
|
|
|
stage_files.shlib: ${SHLIB_NAME}.symbols
|
|
|
|
.endif
|
|
|
|
.else
|
2013-03-04 21:36:34 +00:00
|
|
|
stage_libs: ${_LIBS}
|
2014-05-16 14:51:19 +00:00
|
|
|
.endif
|
2013-10-12 23:51:00 +00:00
|
|
|
.if defined(SHLIB_NAME) && defined(DEBUG_FLAGS) && target(${SHLIB_NAME}.symbols)
|
|
|
|
stage_libs: ${SHLIB_NAME}.symbols
|
|
|
|
.endif
|
2014-05-16 14:51:19 +00:00
|
|
|
|
2013-03-04 21:36:34 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(INCS) || !empty(INCSGROUPS) && target(buildincludes)
|
2014-05-16 14:51:19 +00:00
|
|
|
.if !defined(NO_BEFOREBUILD_INCLUDES)
|
|
|
|
stage_includes: buildincludes
|
|
|
|
beforebuild: stage_includes
|
|
|
|
.endif
|
2013-03-04 21:36:34 +00:00
|
|
|
.endif
|
|
|
|
|
2013-03-08 00:23:21 +00:00
|
|
|
.for t in stage_libs stage_files stage_as
|
|
|
|
.if target($t)
|
2015-10-07 00:24:27 +00:00
|
|
|
STAGE_TARGETS+= $t
|
2013-03-08 00:23:21 +00:00
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
|
2013-03-04 21:36:34 +00:00
|
|
|
.if !empty(STAGE_AS_SETS)
|
2015-10-07 00:24:27 +00:00
|
|
|
STAGE_TARGETS+= stage_as
|
2013-03-04 21:36:34 +00:00
|
|
|
.endif
|
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.if !empty(STAGE_TARGETS) || (${MK_STAGING_PROG} != "no" && !defined(INTERNALPROG))
|
2013-03-04 21:36:34 +00:00
|
|
|
|
|
|
|
.if !empty(LINKS)
|
2015-10-07 00:24:27 +00:00
|
|
|
STAGE_TARGETS+= stage_links
|
2013-10-12 23:51:00 +00:00
|
|
|
.if ${MAKE_VERSION} < 20131001
|
|
|
|
stage_links.links: ${_LIBS} ${PROG}
|
|
|
|
.endif
|
2013-03-04 21:36:34 +00:00
|
|
|
STAGE_SETS+= links
|
|
|
|
STAGE_LINKS.links= ${LINKS}
|
|
|
|
.endif
|
|
|
|
|
2015-11-13 20:25:30 +00:00
|
|
|
.if !empty(SYMLINKS)
|
2015-10-07 00:24:27 +00:00
|
|
|
STAGE_TARGETS+= stage_symlinks
|
2013-03-04 21:36:34 +00:00
|
|
|
STAGE_SETS+= links
|
|
|
|
STAGE_SYMLINKS.links= ${SYMLINKS}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.include <meta.stage.mk>
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2016-04-14 21:04:42 +00:00
|
|
|
.if defined(META_TARGETS)
|
|
|
|
.for _tgt in ${META_TARGETS}
|
|
|
|
.if target(${_tgt})
|
|
|
|
${_tgt}: ${META_DEPS}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.endif
|