[12/42] unzip: Fix build with GCC 15

Message ID 20250502101632.1082010-12-michael.tremer@ipfire.org
State New
Headers
Series [01/42] gcc: Update to 15 |

Commit Message

Michael Tremer May 2, 2025, 10:16 a.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/unzip                           |  8 ++++++--
 src/patches/unzip-gnu89-build.patch | 15 +++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 src/patches/unzip-gnu89-build.patch
  

Patch

diff --git a/lfs/unzip b/lfs/unzip
index 418ea7444..87ff9a3c7 100644
--- a/lfs/unzip
+++ b/lfs/unzip
@@ -32,6 +32,9 @@  DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
+# Fix build with GCC 15
+CFLAGS += -std=gnu17
+
 ###############################################################################
 # Top-level Rules
 ###############################################################################
@@ -70,10 +73,11 @@  $(subst %,%_BLAKE2,$(objects)) :
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	@$(PREBUILD)
 	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/unzip-gnu89-build.patch
 	cd $(DIR_APP) && make -f unix/Makefile clean
-	cd $(DIR_APP)/unix && ./configure
+	cd $(DIR_APP)/unix && CFLAGS="$(CFLAGS)" ./configure
 	# ARM/x86_64 cannot use the x86 32 bit assembly code.
-	cd $(DIR_APP) && make -f unix/Makefile LOCAL_UNZIP=-D_FILE_OFFSET_BITS=64 linux_noasm
+	cd $(DIR_APP) && make -f unix/Makefile LOCAL_UNZIP=-D_FILE_OFFSET_BITS=64 generic_gcc
 	cd $(DIR_APP) && make prefix=/usr MANDIR=/usr/share/man/man1 -f unix/Makefile install
 	@rm -rf $(DIR_APP)
 	@$(POSTBUILD)
diff --git a/src/patches/unzip-gnu89-build.patch b/src/patches/unzip-gnu89-build.patch
new file mode 100644
index 000000000..706f12531
--- /dev/null
+++ b/src/patches/unzip-gnu89-build.patch
@@ -0,0 +1,15 @@ 
+unzip uses C89-only features, so it needs to be built in C89 mode.
+
+diff --git a/unix/Makefile b/unix/Makefile
+index ab32270cf4b9b2cf..5eabbe13095e1f58 100644
+--- a/unix/Makefile
++++ b/unix/Makefile
+@@ -545,7 +545,7 @@ generic:	flags	   # now try autoconfigure first
+ #	make $(MAKEF) unzips CF="${CF} `cat flags`"
+ 
+ generic_gcc:
+-	$(MAKE) $(MAKEF) generic CC=gcc IZ_BZIP2="$(IZ_BZIP2)"
++	$(MAKE) $(MAKEF) generic CC="gcc -std=gnu89" IZ_BZIP2="$(IZ_BZIP2)"
+ 
+ # extensions to perform SVR4 package-creation after compilation
+ generic_pkg:	generic svr4package