# shellcheck source=/dev/null
. /etc/makepkg.conf
-CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
+MKOSI_CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
if ((LLVM)); then
# TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed.
- CFLAGS="$CFLAGS -shared-libasan -fno-sanitize=function"
+ MKOSI_CFLAGS="$MKOSI_CFLAGS -shared-libasan -fno-sanitize=function"
fi
-LDFLAGS=""
+MKOSI_LDFLAGS=""
if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then
- LDFLAGS="$LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
+ MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
fi
# Override the default options. Disable FORTIFY_SOURCE because it doesn't work with O0. We specifically
export CXX="$( ((LLVM)) && echo clang++ || echo g++)"
export CC_LD="$( ((LLVM)) && echo lld)"
export CXX_LD="$( ((LLVM)) && echo lld)"
-export CFLAGS="\$CFLAGS $CFLAGS"
-export CXXFLAGS="\$CXXFLAGS $CFLAGS"
-export LDFLAGS="\$LDFLAGS $LDFLAGS"
+export CFLAGS="\$CFLAGS $MKOSI_CFLAGS $CFLAGS"
+export CXXFLAGS="\$CXXFLAGS $MKOSI_CFLAGS $CFLAGS"
+export LDFLAGS="\$LDFLAGS $MKOSI_LDFLAGS $LDFLAGS"
OPTIONS=(
docs
!libtool
)
# TODO: Drop -U_FORTIFY_SOURCE when we switch to CentOS Stream 10.
-CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
+MKOSI_CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
if ((WITH_DEBUG)); then
- CFLAGS="$CFLAGS -fdebug-prefix-map=../src=$SRCDEST"
+ MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=$SRCDEST"
fi
if ((LLVM)); then
# TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed.
- CFLAGS="$CFLAGS -shared-libasan -fno-sanitize=function"
+ MKOSI_CFLAGS="$MKOSI_CFLAGS -shared-libasan -fno-sanitize=function"
fi
-LDFLAGS=""
+MKOSI_LDFLAGS=""
if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then
- LDFLAGS="$LDFLAGS -Wl,-rpath=$(dirname "$(clang --print-file-name=libclang_rt.asan.so)")"
+ MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(dirname "$(clang --print-file-name=libclang_rt.asan.so)")"
fi
IFS=
# https://github.com/mesonbuild/meson/pull/12835 is available.
# shellcheck disable=SC2046
env \
+--unset=CFLAGS \
+--unset=CXXFLAGS \
+--unset=LDFLAGS \
ANNOBIN="no-active-checks" \
CC_LD="$( ((LLVM)) && echo lld)" \
CXX_LD="$( ((LLVM)) && echo lld)" \
--define "version_override $VERSION" \
--define "release_override $RELEASE" \
"${COMMON_MACRO_OVERRIDES[@]}" \
- --define "build_cflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_cflags}") $CFLAGS" \
- --define "build_cxxflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_cxxflags}") $CFLAGS" \
- --define "build_ldflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_ldflags}") $LDFLAGS" \
+ --define "build_cflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_cflags}") $MKOSI_CFLAGS $CFLAGS" \
+ --define "build_cxxflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_cxxflags}") $MKOSI_CFLAGS $CFLAGS" \
+ --define "build_ldflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_ldflags}") $MKOSI_LDFLAGS $LDFLAGS" \
--define "meson_build %{shrink:%{__meson} compile -C %{_vpath_builddir} -j %{_smp_build_ncpus} %{nil}}" \
--define "meson_install %{shrink:DESTDIR=%{buildroot} %{__meson} install -C %{_vpath_builddir} --no-rebuild --quiet %{nil}}" \
--define "meson_extra_configure_options -D mode=developer -D b_sanitize=${SANITIZERS:-none}" \
cat debian/changelog >>debian/changelog.new
mv debian/changelog.new debian/changelog
-CFLAGS="-O${OPTIMIZATION:-0}"
+MKOSI_CFLAGS="-O${OPTIMIZATION:-0}"
if ((LLVM)); then
# TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed.
- CFLAGS="$CFLAGS -shared-libasan -fno-sanitize=function"
+ MKOSI_CFLAGS="$MKOSI_CFLAGS -shared-libasan -fno-sanitize=function"
fi
-LDFLAGS=""
+MKOSI_LDFLAGS=""
if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then
- LDFLAGS="$LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
+ MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
fi
# TODO: Drop GENSYMBOLS_LEVEL once https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=986746 is fixed.
$( ((WITH_DOCS)) || echo nodoc) \
pkg.systemd.upstream \
")" \
- DEB_CFLAGS_APPEND="$CFLAGS" \
- DEB_CXXFLAGS_APPEND="$CFLAGS" \
- DEB_LDFLAGS_APPEND="$LDFLAGS" \
+ DEB_CFLAGS_APPEND="$MKOSI_CFLAGS $CFLAGS" \
+ DEB_CXXFLAGS_APPEND="$MKOSI_CFLAGS $CFLAGS" \
+ DEB_LDFLAGS_APPEND="$MKOSI_LDFLAGS $LDFLAGS" \
DPKG_FORCE="unsafe-io" \
DPKG_DEB_COMPRESSOR_TYPE="none" \
DH_MISSING="--fail-missing" \
ARCH="$(rpm --eval %_arch)"
SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH"
-CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
+MKOSI_CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
if ((WITH_DEBUG)); then
- CFLAGS="$CFLAGS -fdebug-prefix-map=../src=$SRCDEST"
+ MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=$SRCDEST"
fi
if ((LLVM)); then
# TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed.
- CFLAGS="$CFLAGS -shared-libasan -fno-sanitize=function"
+ MKOSI_CFLAGS="$MKOSI_CFLAGS -shared-libasan -fno-sanitize=function"
fi
-LDFLAGS="$(rpm --eval "%{?build_ldflags}") $LDFLAGS"
+MKOSI_LDFLAGS="$(rpm --eval "%{?build_ldflags}")"
if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then
- LDFLAGS="$LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
+ MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux"
fi
# A macro can't have an empty body and currently opensuse does not specify any of its own linker flags so
# set LDFLAGS to %{nil} if there are no linker flags.
-if [[ -z "${LDFLAGS// }" ]]; then
- LDFLAGS="%{nil}"
+if [[ -z "${MKOSI_LDFLAGS// }" ]]; then
+ MKOSI_LDFLAGS="%{nil}"
fi
build() {
# starts to use it.
# shellcheck disable=SC2046
env \
+ --unset CFLAGS \
+ --unset CXXFLAGS \
+ --unset LDFLAGS \
CC="$( ((LLVM)) && echo clang || echo gcc)" \
CXX="$( ((LLVM)) && echo clang++ || echo g++)" \
CC_LD="$( ((LLVM)) && echo lld)" \
--define "version_override $VERSION" \
--define "release_override $RELEASE" \
--define "__check_files sh -c '$(rpm --define "_topdir /var/tmp" --eval %__check_files) | tee /tmp/unpackaged-files'" \
- --define "build_cflags $(rpm --eval "%{?build_cflags}") $CFLAGS" \
- --define "build_cxxflags $(rpm --eval "%{?build_cxxflags}") $CFLAGS" \
- --define "build_ldflags $LDFLAGS" \
+ --define "build_cflags $(rpm --eval "%{?build_cflags}") $MKOSI_CFLAGS $CFLAGS" \
+ --define "build_cxxflags $(rpm --eval "%{?build_cxxflags}") $MKOSI_CFLAGS $CFLAGS" \
+ --define "build_ldflags $MKOSI_LDFLAGS $LDFLAGS" \
--define "meson_build %{shrink:%{__meson} compile -C %{_vpath_builddir} -j %{_smp_build_ncpus} %{nil}}" \
--define "meson_install %{shrink:DESTDIR=%{buildroot} %{__meson} install -C %{_vpath_builddir} --no-rebuild --quiet %{nil}}" \
--define "__meson_auto_features auto -D mode=developer -D b_sanitize=${SANITIZERS:-none}" \