From 84a7da0f72b480b0956c976aa9f45babf2b6c16f Mon Sep 17 00:00:00 2001 From: lvgenggeng Date: Wed, 19 Jul 2023 17:58:38 +0800 Subject: [PATCH] add %bcond_without clang for building with clang Signed-off-by: lvgenggeng --- busybox.spec | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/busybox.spec b/busybox.spec index 7cc53e2..b110deb 100644 --- a/busybox.spec +++ b/busybox.spec @@ -4,10 +4,12 @@ %endif %if "%{!?RELEASE:1}" -%define RELEASE 19 +%define RELEASE 20 %endif Epoch: 1 +%bcond_without clang + Name: busybox Version: %{VERSION} Release: %{RELEASE} @@ -27,7 +29,11 @@ Patch6003: backport-generalize-const-trick.patch BuildRoot: %_topdir/BUILDROOT #Dependency +%if %{with clang} +BuildRequires: clang < 13 +%else BuildRequires: gcc glibc-static +%endif BuildRequires: libselinux-devel >= 1.27.7-2 BuildRequires: libsepol-devel libselinux-static libsepol-static @@ -61,10 +67,16 @@ This package contains help documentation for busybox %build export CFLAGS="$RPM_OPT_FLAGS -fPIE" LDFLAGS="-Wl,-z,now" +%if %{with clang} +export CC=clang +%else +export CC=gcc +%endif + cp %{SOURCE3} .config yes "" | make oldconfig && \ cat .config && \ -make V=1 %{?_smp_mflags} CC="gcc $RPM_OPT_FLAGS" +make V=1 %{?_smp_mflags} CC="$CC $RPM_OPT_FLAGS" cp busybox_unstripped busybox.dynamic cp docs/busybox.1 docs/busybox.dynamic.1 @@ -73,7 +85,7 @@ make clean cp %{SOURCE2} .config yes "" | make oldconfig cat .config && \ -make V=1 %{?_smp_mflags} CC="%__cc $RPM_OPT_FLAGS" +make V=1 %{?_smp_mflags} CC="$CC $RPM_OPT_FLAGS" cp busybox_unstripped busybox.petitboot cp docs/busybox.1 docs/busybox.petitboot.1 @@ -99,6 +111,9 @@ install -m 644 docs/busybox.dynamic.1 $RPM_BUILD_ROOT/%{_mandir}/man1/busybox.1 %{_mandir}/man1/busybox.petitboot.1.gz %changelog +* Wed Jul 19 2023 lvgenggeng - 1:1.34.1-20 +- add %bcond_without clang for building with clang + * Fri Dec 16 2022 cf_zhao - 1:1.34.1-19 - Backport generalize "const trick" which commited in 1f925038ab9c6bd8f6b3cd40ed7aab0ef10d898e -- Gitee