diff options
Diffstat (limited to 'share/mk')
-rw-r--r-- | share/mk/Makefile | 1 | ||||
-rw-r--r-- | share/mk/bsd.README | 1 | ||||
-rw-r--r-- | share/mk/bsd.compat.mk | 1 | ||||
-rw-r--r-- | share/mk/bsd.debug.mk | 68 | ||||
-rw-r--r-- | share/mk/bsd.endian.mk | 13 | ||||
-rw-r--r-- | share/mk/bsd.lib.mk | 101 | ||||
-rw-r--r-- | share/mk/bsd.man.mk | 18 | ||||
-rw-r--r-- | share/mk/bsd.mkopt.mk | 68 | ||||
-rw-r--r-- | share/mk/bsd.opts.mk | 1 | ||||
-rw-r--r-- | share/mk/bsd.own.mk | 7 | ||||
-rw-r--r-- | share/mk/bsd.prog.mk | 55 | ||||
-rw-r--r-- | share/mk/local.dirdeps.mk | 2 | ||||
-rw-r--r-- | share/mk/src.init.mk | 2 | ||||
-rw-r--r-- | share/mk/src.opts.mk | 10 | ||||
-rw-r--r-- | share/mk/src.sys.mk | 2 |
15 files changed, 223 insertions, 127 deletions
diff --git a/share/mk/Makefile b/share/mk/Makefile index 4ab5c8cc314b..0e786b381fe2 100644 --- a/share/mk/Makefile +++ b/share/mk/Makefile @@ -22,6 +22,7 @@ FILES= \ bsd.confs.mk \ bsd.cpu.mk \ bsd.crunchgen.mk \ + bsd.debug.mk \ bsd.dep.mk \ bsd.dirs.mk \ bsd.doc.mk \ diff --git a/share/mk/bsd.README b/share/mk/bsd.README index 4820bf12c72d..89ee8527895e 100644 --- a/share/mk/bsd.README +++ b/share/mk/bsd.README @@ -20,6 +20,7 @@ bsd.compiler.mk - defined based on current compiler bsd.confs.mk - install of configuration files bsd.cpu.mk - sets CPU/arch-related variables (included from sys.mk) bsd.crunchgen.mk - building crunched binaries using crunchgen(1) +bsd.debug.mk - handling debug options for bsd.{prog,lib}.mk bsd.dep.mk - handle Makefile dependencies bsd.dirs.mk - handle directory creation bsd.doc.mk - building troff system documents diff --git a/share/mk/bsd.compat.mk b/share/mk/bsd.compat.mk index 6fa732fd730b..bad68d1ebd8e 100644 --- a/share/mk/bsd.compat.mk +++ b/share/mk/bsd.compat.mk @@ -74,6 +74,7 @@ LIB32WMAKEFLAGS= \ LIB32WMAKEFLAGS+= NM="${XNM}" LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}" +LIB32WMAKEFLAGS+= STRIPBIN="${XSTRIPBIN}" LIB32DTRACE= ${DTRACE} -32 LIB32_MACHINE_ABI= ${MACHINE_ABI:N*64} long32 ptr32 diff --git a/share/mk/bsd.debug.mk b/share/mk/bsd.debug.mk new file mode 100644 index 000000000000..cf2fb4356aef --- /dev/null +++ b/share/mk/bsd.debug.mk @@ -0,0 +1,68 @@ +# +# This file configures debug options for compiled targets. It is meant +# to consolidate common logic in bsd.prog.mk and bsd.lib.mk. It should +# not be included directly by Makefiles. +# + +.include <bsd.opts.mk> + +.if ${MK_ASSERT_DEBUG} == "no" +CFLAGS+= -DNDEBUG +# XXX: shouldn't we ensure that !asserts marks potentially unused variables as +# __unused instead of disabling -Werror globally? +MK_WERROR= no +.endif + +# If reproducible build mode is enabled, map the root of the source +# directory to /usr/src and the root of the object directory to +# /usr/obj. +.if ${MK_REPRODUCIBLE_BUILD} != "no" && !defined(DEBUG_PREFIX) +.if defined(SRCTOP) +DEBUG_PREFIX+= ${SRCTOP:S,/$,,}=/usr/src +.endif +.if defined(OBJROOT) +# Strip off compat subdirectories, e.g., /usr/obj/usr/src/amd64.amd64/obj-lib32 +# becomes /usr/obj/usr/src/amd64.amd64, since object files compiled there might +# refer to something outside the root. +DEBUG_PREFIX+= ${OBJROOT:S,/$,,:C,/obj-[^/]*$,,}=/usr/obj +.endif +.endif + +.if defined(DEBUG_PREFIX) +.for map in ${DEBUG_PREFIX} +CFLAGS+= -ffile-prefix-map=${map} +CXXFLAGS+= -ffile-prefix-map=${map} +.endfor +.endif + +.if defined(DEBUG_FLAGS) +CFLAGS+=${DEBUG_FLAGS} +CXXFLAGS+=${DEBUG_FLAGS} + +.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" +CTFFLAGS+= -g +.endif +.else +STRIP?= -s +.endif + +.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ + empty(DEBUG_FLAGS:M-gdwarf*) +.if !${COMPILER_FEATURES:Mcompressed-debug} +CFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*} +CXXFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*} +.else +CFLAGS+= ${DEBUG_FILES_CFLAGS} +CXXFLAGS+= ${DEBUG_FILES_CFLAGS} +.endif +CTFFLAGS+= -g +.endif + +_debuginstall: +.if ${MK_DEBUG_FILES} != "no" && defined(DEBUGFILE) +.if defined(DEBUGMKDIR) + ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -d ${DESTDIR}${DEBUGFILEDIR}/ +.endif + ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \ + ${DEBUGFILE} ${DESTDIR}${DEBUGFILEDIR}/${DEBUGFILE} +.endif diff --git a/share/mk/bsd.endian.mk b/share/mk/bsd.endian.mk index ba662ffc7439..24da57954b5a 100644 --- a/share/mk/bsd.endian.mk +++ b/share/mk/bsd.endian.mk @@ -20,10 +20,17 @@ LOCALEDEF_ENDIAN= -b # # During bootstrapping on !FreeBSD OSes, we need to define some value. Short of # having an exhaustive list for all variants of Linux and MacOS we simply do not -# set TARGET_ENDIANNESS and poison the other variables. They should be unused -# during the bootstrap phases (apart from one place that's adequately protected -# in bsd.compiler.mk) where we're building the bootstrap tools. +# set TARGET_ENDIANNESS (on Linux) and poison the other variables. They should +# be unused during the bootstrap phases (apart from one place that's adequately +# protected in bsd.compiler.mk) where we're building the bootstrap tools. # +.if ${.MAKE.OS} == "Darwin" +# We do assume the endianness on macOS because Apple's modern hardware is all +# little-endian. This might need revisited in the far future, but for the time +# being Apple Silicon's reign of terror continues. We only set this one up +# because libcrypto is now built in bootstrap. +TARGET_ENDIANNESS= 1234 +.endif CAP_MKDB_ENDIAN= -B # Poisoned value, invalid flags for both cap_mkdb LOCALEDEF_ENDIAN= -B # and localedef. .endif diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 3013f32c2b36..6caad8956c14 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -1,4 +1,3 @@ - .include <bsd.init.mk> .include <bsd.compiler.mk> .include <bsd.linker.mk> @@ -45,23 +44,6 @@ SONAME?= ${SHLIB_NAME} CFLAGS+= ${CRUNCH_CFLAGS} .endif -.if ${MK_ASSERT_DEBUG} == "no" -CFLAGS+= -DNDEBUG -# XXX: shouldn't we ensure that !asserts marks potentially unused variables as -# __unused instead of disabling -Werror globally? -MK_WERROR= no -.endif - -.if defined(DEBUG_FLAGS) -CFLAGS+= ${DEBUG_FLAGS} - -.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" -CTFFLAGS+= -g -.endif -.else -STRIP?= -s -.endif - .for _libcompat in ${_ALL_libcompats} .if ${SHLIBDIR:M*/lib${_libcompat}} || ${SHLIBDIR:M*/lib${_libcompat}/*} TAGS+= lib${_libcompat} @@ -70,11 +52,31 @@ TAGS+= lib${_libcompat} .if defined(NO_ROOT) .if !defined(TAGS) || ! ${TAGS:Mpackage=*} -TAGS+= package=${PACKAGE:Uutilities} +TAGS+= package=${PACKAGE:Uutilities} .endif -TAG_ARGS= -T ${TAGS:ts,:[*]} + +# By default, if PACKAGE=foo, then the native runtime libraries will go into +# the FreeBSD-foo package, and subpackages will be created for -dev, -lib32, +# and so on. If LIB_PACKAGE is set, then we also create a subpackage for +# runtime libraries with a -lib suffix. This is used when a package has +# libraries and some other content (e.g., executables) to allow consumers to +# depend on the libraries. +.if defined(LIB_PACKAGE) && ! ${TAGS:Mlib*} +.if !defined(PACKAGE) +.error LIB_PACKAGE cannot be used without PACKAGE +.endif + +LIB_TAG_ARGS= ${TAG_ARGS},lib +.else +LIB_TAG_ARGS= ${TAG_ARGS} .endif +TAG_ARGS= -T ${TAGS:ts,:[*]} + +DBG_TAG_ARGS= ${TAG_ARGS},dbg +DEV_TAG_ARGS= ${TAG_ARGS},dev +.endif # !defined(NO_ROOT) + # ELF hardening knobs .if ${MK_BIND_NOW} != "no" LDFLAGS+= -Wl,-znow @@ -130,18 +132,6 @@ CXXFLAGS+= -fzero-call-used-regs=${ZEROREG_TYPE} # bsd.sanitizer.mk is not installed, so don't require it (e.g. for ports). .sinclude "bsd.sanitizer.mk" -.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ - empty(DEBUG_FLAGS:M-gdwarf*) -.if !${COMPILER_FEATURES:Mcompressed-debug} -CFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*} -CXXFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*} -.else -CFLAGS+= ${DEBUG_FILES_CFLAGS} -CXXFLAGS+= ${DEBUG_FILES_CFLAGS} -.endif -CTFFLAGS+= -g -.endif - .if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == "" CFLAGS += -mno-relax .endif @@ -156,6 +146,7 @@ _SHLIBDIR:=${SHLIBDIR} .if defined(SHLIB_NAME) .if ${MK_DEBUG_FILES} != "no" SHLIB_NAME_FULL=${SHLIB_NAME}.full +DEBUGFILE= ${SHLIB_NAME}.debug # Use ${DEBUGDIR} for base system debug files, else .debug subdirectory .if ${_SHLIBDIR} == "/boot" ||\ ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\ @@ -272,16 +263,16 @@ ${SHLIB_NAME_FULL}: ${SOBJS} .endif .if ${MK_DEBUG_FILES} != "no" -CLEANFILES+= ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug -${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug - ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \ +CLEANFILES+= ${SHLIB_NAME_FULL} ${DEBUGFILE} +${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${DEBUGFILE} + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${DEBUGFILE} \ ${SHLIB_NAME_FULL} ${.TARGET} .if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) # Note: This uses ln instead of ${INSTALL_LIBSYMLINK} since we are in OBJDIR @${LN:Uln} -fs ${SHLIB_NAME} ${SHLIB_LINK} .endif -${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL} +${DEBUGFILE}: ${SHLIB_NAME_FULL} ${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET} .endif .endif #defined(SHLIB_NAME) @@ -384,7 +375,7 @@ _SHLINSTALLFLAGS:= ${_SHLINSTALLFLAGS${ie}} installpcfiles: installpcfiles-${pcfile} installpcfiles-${pcfile}: ${pcfile} - ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${INSTALL} ${DEV_TAG_ARGS} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} \ ${.ALLSRC} ${DESTDIR}${LIBDATADIR}/pkgconfig/ .endfor @@ -392,49 +383,42 @@ installpcfiles-${pcfile}: ${pcfile} installpcfiles: .PHONY .if !defined(INTERNALLIB) -realinstall: _libinstall installpcfiles -.ORDER: beforeinstall _libinstall +realinstall: _libinstall installpcfiles _debuginstall +.ORDER: beforeinstall _libinstall _debuginstall _libinstall: .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" - ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${INSTALL} ${DEV_TAG_ARGS} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}${_STATICLIB_SUFFIX}.a ${DESTDIR}${_LIBDIR}/ .endif .if defined(SHLIB_NAME) - ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${INSTALL} ${LIB_TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/ -.if ${MK_DEBUG_FILES} != "no" -.if defined(DEBUGMKDIR) - ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -d ${DESTDIR}${DEBUGFILEDIR}/ -.endif - ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -o ${LIBOWN} -g ${LIBGRP} -m ${DEBUGMODE} \ - ${_INSTALLFLAGS} \ - ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR}/ -.endif .if defined(SHLIB_LINK) .if commands(${SHLIB_LINK:R}.ld) - ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -S -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${INSTALL} ${DEV_TAG_ARGS} -S -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} .for _SHLIB_LINK_LINK in ${SHLIB_LDSCRIPT_LINKS} - ${INSTALL_LIBSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} ${SHLIB_LINK} \ - ${DESTDIR}${_LIBDIR}/${_SHLIB_LINK_LINK} + ${INSTALL_LIBSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${LIB_TAG_ARGS} \ + ${SHLIB_LINK} ${DESTDIR}${_LIBDIR}/${_SHLIB_LINK_LINK} .endfor .else .if ${_SHLIBDIR} == ${_LIBDIR} .if ${SHLIB_LINK:Mlib*} - ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS:D${TAG_ARGS},dev} \ + ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${DEV_TAG_ARGS} \ ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} .else - ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \ + ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${LIB_TAG_ARGS} \ + ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} .endif .else .if ${SHLIB_LINK:Mlib*} - ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS:D${TAG_ARGS},dev} \ + ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${DEV_TAG_ARGS} \ ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} .else - ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} \ + ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${LIB_TAG_ARGS} \ ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} .endif .if exists(${DESTDIR}${_LIBDIR}/${SHLIB_NAME}) @@ -446,7 +430,7 @@ _libinstall: .endif # SHLIB_LINK .endif # SHIB_NAME .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) - ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${INSTALL} ${DEV_TAG_ARGS} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}/ .endif .endif # !defined(INTERNALLIB) @@ -466,7 +450,7 @@ LINKGRP?= ${LIBGRP} LINKMODE?= ${LIBMODE} SYMLINKOWN?= ${LIBOWN} SYMLINKGRP?= ${LIBGRP} -LINKTAGS= dev +LINKTAGS= dev${_COMPAT_TAG} .include <bsd.links.mk> .if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY) @@ -501,6 +485,7 @@ SUBDIR_TARGETS+= check TESTS_LD_LIBRARY_PATH+= ${.OBJDIR} .endif +.include <bsd.debug.mk> .include <bsd.dep.mk> .include <bsd.clang-analyze.mk> .include <bsd.obj.mk> diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk index f44048b4e453..66155d1b4cd9 100644 --- a/share/mk/bsd.man.mk +++ b/share/mk/bsd.man.mk @@ -288,11 +288,11 @@ manlinksinstall-${__group}: .endif .endfor -manlint: +manlint: .PHONY checkmanlinks .if defined(${__group}) && !empty(${__group}) .for __page in ${${__group}} manlint: ${__page:S/:/\:/g}lint -${__page:S/:/\:/g}lint: ${__page} +${__page:S/:/\:/g}lint: .PHONY ${__page} .if defined(MANFILTER) ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} -Tlint .else @@ -301,4 +301,18 @@ ${__page:S/:/\:/g}lint: ${__page} .endfor .endif +checkmanlinks: .PHONY +.if defined(${__group}LINKS) +checkmanlinks: checkmanlinks-${__group} +checkmanlinks-${__group}: .PHONY +.for __page __link in ${${__group}LINKS} +checkmanlinks-${__group}: checkmanlinks-${__group}-${__link} +checkmanlinks-${__group}-${__link}: .PHONY ${__page} + @if ! egrep -q "^(\.\\\\\" )?\.Nm ${__link:R}( ,)?$$" ${.ALLSRC}; then \ + echo "${__group}LINKS: '.Nm ${__link:R}' not found in ${__page}"; \ + exit 1; \ + fi >&2 +.endfor # __page __link in ${${__group}LINKS} +.endif # defined(${__group}LINKS) + .endfor # __group in ${MANGROUPS} diff --git a/share/mk/bsd.mkopt.mk b/share/mk/bsd.mkopt.mk index f93101544bf7..4d67ba04294d 100644 --- a/share/mk/bsd.mkopt.mk +++ b/share/mk/bsd.mkopt.mk @@ -19,14 +19,6 @@ # If both WITH_FOO and WITHOUT_FOO are defined, WITHOUT_FOO wins and # MK_FOO is set to "no" regardless of which list it was in. # -# All of __DEFAULT_YES_OPTIONS, __DEFAULT_NO_OPTIONS and -# __DEFAULT_DEPENDENT_OPTIONS are undef'd after all this processing, -# allowing this file to be included multiple times with different lists. -# -# Other parts of the build system will set BROKEN_OPTIONS to a list -# of options that are broken on this platform. This will not be unset -# before returning. Clients are expected to always += this variable. -# # Users should generally define WITH_FOO or WITHOUT_FOO, but the build # system should use MK_FOO={yes,no} when it needs to override the # user's desires or default behavior. @@ -35,6 +27,19 @@ # defined and __FOO_DEFAULT if not. Valid values for FOO are specified # by __FOO_OPTIONS. # +# All of __REQUIRED_OPTIONS, __DEFAULT_DEPENDENT_OPTIONS, +# __DEFAULT_YES_OPTIONS, __DEFAULT_NO_OPTIONS, and __SINGLE_OPTIONS +# are undef'd after all this processing, allowing this file to be +# included multiple times with different lists. However, we keep +# deduplicated lists of these options in similarly-named variables +# without the leading underscores (i.e. FOO_OPTIONS is the complete +# deduplicated list of all values of __FOO_OPTIONS across all +# invokations of this file). +# +# Other parts of the build system will set BROKEN_OPTIONS to a list +# of options that are broken on this platform. This will not be unset +# before returning. Clients are expected to always += this variable. +# # Other parts of the build system will set BROKEN_SINGLE_OPTIONS to a # list of 3-tuples of the form: "OPTION broken_value replacment_value". # This will not be unset before returning. Clients are expected to @@ -42,6 +47,33 @@ # # +# These variables accumulate all the options from our possibly +# multiple callers so they're available to build tools such as +# tools/build/options/makeman. +# +DEFAULT_NO_OPTIONS+=${__DEFAULT_NO_OPTIONS} +DEFAULT_NO_OPTIONS:=${DEFAULT_NO_OPTIONS:O:u} +DEFAULT_YES_OPTIONS+=${__DEFAULT_YES_OPTIONS} +DEFAULT_YES_OPTIONS:=${DEFAULT_YES_OPTIONS:O:u} +DEFAULT_DEPENDENT_OPTIONS+=${__DEFAULT_DEPENDENT_OPTIONS} +DEFAULT_DEPENDENT_OPTIONS:=${DEFAULT_DEPENDENT_OPTIONS:O:u} +REQUIRED_OPTIONS+=${__REQUIRED_OPTIONS} +REQUIRED_OPTIONS:=${REQUIRED_OPTIONS:O:u} +SINGLE_OPTIONS+=${__SINGLE_OPTIONS} +SINGLE_OPTIONS:=${SINGLE_OPTIONS:O:u} + +# +# All options defined by our caller; we will undef this before +# returning. +# +__ALL_OPTIONS:= \ + ${__DEFAULT_NO_OPTIONS} \ + ${__DEFAULT_YES_OPTIONS} \ + ${__REQUIRED_OPTIONS} \ + ${__DEFAULT_DEPENDENT_OPTIONS:H} \ + ${__SINGLE_OPTIONS} + +# # MK_* options which default to "yes". # .for var in ${__DEFAULT_YES_OPTIONS} @@ -72,6 +104,7 @@ MK_${var}:= yes .endif MK_${var}:= yes .endfor +.undef __REQUIRED_OPTIONS # # MK_* options which default to "no". @@ -142,3 +175,22 @@ MK_${vv:H}?= ${MK_${vv:T}} MK_${vv:H}:= ${MK_${vv:H}} .endfor .undef __DEFAULT_DEPENDENT_OPTIONS + +# +# Define SRC_OPT_DEFS and SRC_OPT_LIST +# +SRC_OPT_DEFS?=-D__${MACHINE_ARCH}__ +SRC_OPT_LIST?=TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} +.for option in ${__ALL_OPTIONS:O:u} +.if defined(OPT_${option}) +SRC_OPT_DEFS+=-D${option}=${OPT_${option}:Q} +SRC_OPT_LIST+=${option}=${OPT_${option}:Q} +.elif ${MK_${option}} == yes +SRC_OPT_DEFS+=-D${option} +SRC_OPT_LIST+=WITH_${option}=1 +.elif ${MK_${option}} == no +SRC_OPT_DEFS+=-U${option} +SRC_OPT_LIST+=WITHOUT_${option}=1 +.endif +.endfor +.undef __ALL_OPTIONS diff --git a/share/mk/bsd.opts.mk b/share/mk/bsd.opts.mk index 85247d733a14..439924d0d596 100644 --- a/share/mk/bsd.opts.mk +++ b/share/mk/bsd.opts.mk @@ -78,6 +78,7 @@ __DEFAULT_NO_OPTIONS = \ CCACHE_BUILD \ CTF \ INSTALL_AS_USER \ + REPRODUCIBLE_BUILD \ RETPOLINE \ RUN_TESTS \ STALE_STAGED \ diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 00a048fedc1d..4dffe9723a9e 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -44,6 +44,10 @@ # # DEBUGMODE Mode for debug files. [${NOBINMODE}] # +# DEBUGOWN Owner for debug info files. [root] +# +# DEBUGGRP Group for debug info files. [wheel] +# # # KMODDIR Base path for loadable kernel modules # (see kld(4)). [/boot/modules] @@ -197,7 +201,8 @@ LIBMODE?= ${NOBINMODE} DEBUGDIR?= /usr/lib/debug DEBUGMODE?= ${NOBINMODE} - +DEBUGOWN?= ${BINOWN} +DEBUGGRP?= ${BINGRP} # Share files SHAREDIR?= /usr/share diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 9350d4786cec..10e1c177e2b2 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -12,22 +12,6 @@ CFLAGS+=${COPTS} .endif -.if ${MK_ASSERT_DEBUG} == "no" -CFLAGS+= -DNDEBUG -# XXX: shouldn't we ensure that !asserts marks potentially unused variables as -# __unused instead of disabling -Werror globally? -MK_WERROR= no -.endif - -.if defined(DEBUG_FLAGS) -CFLAGS+=${DEBUG_FLAGS} -CXXFLAGS+=${DEBUG_FLAGS} - -.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" -CTFFLAGS+= -g -.endif -.endif - .if defined(PROG_CXX) PROG= ${PROG_CXX} .endif @@ -109,20 +93,6 @@ CFLAGS += -mno-relax .if defined(CRUNCH_CFLAGS) CFLAGS+=${CRUNCH_CFLAGS} -.else -.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ - empty(DEBUG_FLAGS:M-gdwarf-*) -.if !${COMPILER_FEATURES:Mcompressed-debug} -CFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*} -.else -CFLAGS+= ${DEBUG_FILES_CFLAGS} -.endif -CTFFLAGS+= -g -.endif -.endif - -.if !defined(DEBUG_FLAGS) -STRIP?= -s .endif .if defined(NO_ROOT) @@ -159,6 +129,9 @@ PROG_FULL= ${PROG} .if defined(PROG) PROGNAME?= ${PROG} +.if ${MK_DEBUG_FILES} != "no" +DEBUGFILE= ${PROGNAME}.debug +.endif .if defined(SRCS) @@ -223,11 +196,12 @@ ${PROG_FULL}: ${OBJS} .endif # !defined(SRCS) .if ${MK_DEBUG_FILES} != "no" -${PROG}: ${PROG_FULL} ${PROGNAME}.debug - ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME}.debug \ +CLEANFILES+= ${PROG_FULL} ${DEBUGFILE} +${PROG}: ${PROG_FULL} ${DEBUGFILE} + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${DEBUGFILE} \ ${PROG_FULL} ${.TARGET} -${PROGNAME}.debug: ${PROG_FULL} +${DEBUGFILE}: ${PROG_FULL} ${OBJCOPY} --only-keep-debug ${PROG_FULL} ${.TARGET} .endif @@ -266,9 +240,6 @@ all: all-man .if defined(PROG) CLEANFILES+= ${PROG} ${PROG}.bc ${PROG}.ll -.if ${MK_DEBUG_FILES} != "no" -CLEANFILES+= ${PROG_FULL} ${PROGNAME}.debug -.endif .endif .if defined(OBJS) @@ -308,19 +279,12 @@ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} .endfor .if !target(realinstall) && !defined(INTERNALPROG) -realinstall: _proginstall -.ORDER: beforeinstall _proginstall +realinstall: _proginstall _debuginstall +.ORDER: beforeinstall _proginstall _debuginstall _proginstall: .if defined(PROG) ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} -.if ${MK_DEBUG_FILES} != "no" -.if defined(DEBUGMKDIR) - ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -d ${DESTDIR}${DEBUGFILEDIR}/ -.endif - ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \ - ${PROGNAME}.debug ${DESTDIR}${DEBUGFILEDIR}/${PROGNAME}.debug -.endif .endif .endif # !target(realinstall) @@ -391,6 +355,7 @@ TESTS_PATH+= ${.OBJDIR} OBJS_DEPEND_GUESS+= ${SRCS:M*.h} .endif +.include <bsd.debug.mk> .include <bsd.dep.mk> .include <bsd.clang-analyze.mk> .include <bsd.obj.mk> diff --git a/share/mk/local.dirdeps.mk b/share/mk/local.dirdeps.mk index a92539689a31..bdc7242d4bfd 100644 --- a/share/mk/local.dirdeps.mk +++ b/share/mk/local.dirdeps.mk @@ -185,7 +185,7 @@ C_DIRDEPS= \ # libgcc is needed as well but is added later. -.if ${MK_GSSAPI} != "no" +.if ${MK_KERBEROS} != "no" && ${MK_MITKRB5} == "no" C_DIRDEPS+= include/gssapi .endif diff --git a/share/mk/src.init.mk b/share/mk/src.init.mk index 01ea5437e5a7..fd3f3501f609 100644 --- a/share/mk/src.init.mk +++ b/share/mk/src.init.mk @@ -3,7 +3,7 @@ __<src.init.mk>__: .NOTMAIN .if !target(buildenv) -buildenv: .PHONY +buildenv: .PHONY .NOTMAIN ${_+_}@env BUILDENV_DIR=${.CURDIR} ${MAKE} -C ${SRCTOP} buildenv .endif diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index ef43d3c939b2..85a003eb4eaf 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -296,9 +296,9 @@ __DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF LLVM_TARGET_MIPS .include <bsd.compiler.mk> .if ${__T} == "i386" || ${__T} == "amd64" -__DEFAULT_NO_OPTIONS += FDT +__DEFAULT_NO_OPTIONS+=FDT .else -__DEFAULT_YES_OPTIONS += FDT +__DEFAULT_YES_OPTIONS+=FDT .endif .if ${__T:Marm*} == "" && ${__T:Mriscv64*} == "" @@ -508,7 +508,7 @@ MK_LOADER_VERIEXEC_PASS_MANIFEST := no # MK_* options whose default value depends on another option. # .for vv in \ - GSSAPI/KERBEROS \ + KERBEROS_SUPPORT/KERBEROS \ MAN_UTILS/MAN .if defined(WITH_${vv:H}) MK_${vv:H}:= yes @@ -519,8 +519,4 @@ MK_${vv:H}:= ${MK_${vv:T}} .endif .endfor -# -# Set defaults for the MK_*_SUPPORT variables. -# - .endif # !target(__<src.opts.mk>__) diff --git a/share/mk/src.sys.mk b/share/mk/src.sys.mk index d5c2af0c559d..2b9fc255a26d 100644 --- a/share/mk/src.sys.mk +++ b/share/mk/src.sys.mk @@ -42,7 +42,7 @@ CFLAGS+= ${CFCOMMONFLAG} CFLAGS+= -fmacro-prefix-map=${SRCTOP}=/usr/src -fdebug-prefix-map=${SRCTOP}=/usr/src .endif -DEFAULTWARNS= 6 +DEFAULTWARNS?= 6 # tempting, but bsd.compiler.mk causes problems this early # probably need to remove dependence on bsd.own.mk |