package/enscript: fix build issue with musl and gcc >= 15

enscript currently fails to build with musl with gcc >= 15. In order
to fix this, we need to bring a number of patches from upstream, and
add 2 others that were submitted upstream.

From upstream, we bring
0002-Add-CFLAG-std-c89-so-it-compiles-with-the-old-standa.patch, which
switches to -std=c89 to get the compiler back to "old" behavior.

However, as this commit patches configure.ac, we need to autoreconf,
but autoreconf is broken, so we also take
0003-Automake-1.12-and-up-no-longer-supports-pre-ANSI.patch from
upstream, which drops a problematic autoconf macro.

However, once you drop this problematic autoconf macro, the PROTOTYPES
define is never set by anything, causing the __P macro to no longer be
defined properly. This is fixed by
0004-Fix-prototype-detection-when-__STDC__-is-defined-but.patch that
we have submitted upstream.

Once you're there, you realize that switching to -std=c89 has the side
effect that musl's <limits.h> no longer defines PATH_MAX, because it
needs one of:

  #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
   || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)

and a side effect of -std=c89 is that none of these is defined
anymore. So we introduce 0005-Use-std-gnu89-instead-of-std-c89.patch,
which switches to -std=gnu89. This patch has also been submitted
upstream.

With all of these efforts, we get a successful build on musl with gcc
>= 15.

This commit needs to be backported to Buildroot versions that support
gcc 15.x, so that means the currently maintained 2026.x branches, but
not 2025.02 as only up to gcc 14.x was supported then.

Fixes:

  https://autobuild.buildroot.org/results/d39d14bbbb3a51d67fe962b877c7f66ff1204ecf/

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
Thomas Petazzoni
2026-08-22 23:13:10 +02:00
committed by Julien Olivain
parent 03757abfce
commit edffc0bc50
6 changed files with 203 additions and 19 deletions

View File

@@ -0,0 +1,29 @@
From c0c7e9ad51b2e9aebea46f0179446fcf896f8d63 Mon Sep 17 00:00:00 2001
From: Wim Stockman <wimstockman@gmail.com>
Date: Fri, 20 Feb 2026 10:51:37 +0100
Subject: [PATCH] Add CFLAG=-std=c89 so it compiles with the old standard,
modern standard gives problems
Upstream: https://git.savannah.gnu.org/cgit/enscript.git/commit/?id=111ad375a6e598c896441e10f4cf1e2fc1496c42
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
configure.ac | 3 +++
1 file changed, 3 insertions(+)
diff --git a/configure.ac b/configure.ac
index 465100a..b867912 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,9 @@ AC_PROG_INSTALL
AC_PROG_CC
+# Force C89 standard and fix modern GCC global variable handling
+CFLAGS="$CFLAGS -std=c89"
+
AC_USE_SYSTEM_EXTENSIONS
AM_C_PROTOTYPES
--
2.55.0

View File

@@ -1,19 +0,0 @@
Fix build with gcc 15.x
Upstream: https://savannah.gnu.org/bugs/?66845
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
diff --git a/compat/regex.c b/compat/regex.c
index c6907f3..87f2840 100644
--- a/compat/regex.c
+++ b/compat/regex.c
@@ -336,7 +336,7 @@ typedef char boolean;
#define false 0
#define true 1
-static int re_match_2_internal ();
+static int re_match_2_internal (struct re_pattern_buffer*, const char*, int, const char*, int, int, struct re_registers*, int);
/* These are the command codes that appear in compiled regular
expressions. Some opcodes are followed by argument bytes. A

View File

@@ -0,0 +1,28 @@
From d74ef70aec3fe9e5e27468f31532eb41188707cf Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de>
Date: Tue, 23 Jan 2018 15:26:45 +0100
Subject: [PATCH] Automake 1.12 and up no longer supports pre-ANSI
Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: James Cloos <cloos@jhcloos.com>
Upstream: https://git.savannah.gnu.org/cgit/enscript.git/commit/?id=a356d343aa9db52b75432cde927b6f9bad6a7c44
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
configure.ac | 1 -
1 file changed, 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index b867912..4431cb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,7 +14,6 @@ AC_PROG_CC
CFLAGS="$CFLAGS -std=c89"
AC_USE_SYSTEM_EXTENSIONS
-AM_C_PROTOTYPES
AC_C_CONST
AC_FUNC_ALLOCA
--
2.55.0

View File

@@ -0,0 +1,107 @@
From 83238ba35f966bb35a065e6d141f3ccf714f4324 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Date: Sat, 22 Aug 2026 14:50:56 +0200
Subject: [PATCH] Fix prototype detection when __STDC__ is defined but
PROTOTYPES is not
Commit a356d343aa9db52b75432cde927b6f9bad6a7c44 ("Automake 1.12 and up
no longer supports pre-ANSI") dropped the AM_C_PROTOTYPES call from
configure.ac, so PROTOTYPES is no longer defined by configure. The
headers' fallback to K&R-style prototypes breaks compilation with
modern compilers.
Check for __STDC__ directly as a fallback, which is defined by all
conforming C89/C99 compilers.
Upstream: https://savannah.gnu.org/bugs/index.php?68633
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
afmlib/afm.h | 2 +-
afmlib/afmint.h | 2 +-
afmlib/strhash.h | 2 +-
compat/xalloc.h | 2 +-
src/gsint.h | 2 +-
states/defs.h | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/afmlib/afm.h b/afmlib/afm.h
index 19855ce..a79648d 100644
--- a/afmlib/afm.h
+++ b/afmlib/afm.h
@@ -24,7 +24,7 @@
#define AFM_H
#ifndef ___P
-#if PROTOTYPES
+#if defined(__STDC__) || defined(PROTOTYPES)
#define ___P(protos) protos
#else /* no PROTOTYPES */
#define ___P(protos) ()
diff --git a/afmlib/afmint.h b/afmlib/afmint.h
index 7995ae5..aee449a 100644
--- a/afmlib/afmint.h
+++ b/afmlib/afmint.h
@@ -34,7 +34,7 @@
#include <stdio.h>
#ifndef ___P
-#if PROTOTYPES
+#if defined(__STDC__) || defined(PROTOTYPES)
#define ___P(protos) protos
#else /* no PROTOTYPES */
#define ___P(protos) ()
diff --git a/afmlib/strhash.h b/afmlib/strhash.h
index 938b2de..a91c0a9 100644
--- a/afmlib/strhash.h
+++ b/afmlib/strhash.h
@@ -24,7 +24,7 @@
#define STRHASH_H
#ifndef ___P
-#if PROTOTYPES
+#if defined(__STDC__) || defined(PROTOTYPES)
#define ___P(protos) protos
#else /* no PROTOTYPES */
#define ___P(protos) ()
diff --git a/compat/xalloc.h b/compat/xalloc.h
index 203bcb8..fd50b68 100644
--- a/compat/xalloc.h
+++ b/compat/xalloc.h
@@ -28,7 +28,7 @@
#define XALLOC_H
#ifndef ___P
-#if PROTOTYPES
+#if defined(__STDC__) || defined(PROTOTYPES)
#define ___P(protos) protos
#else /* no PROTOTYPES */
#define ___P(protos) ()
diff --git a/src/gsint.h b/src/gsint.h
index 3c2527a..001961c 100644
--- a/src/gsint.h
+++ b/src/gsint.h
@@ -39,7 +39,7 @@
#include <sys/stat.h>
#ifndef ___P
-#if PROTOTYPES
+#if defined(__STDC__) || defined(PROTOTYPES)
#define ___P(protos) protos
#else /* no PROTOTYPES */
#define ___P(protos) ()
diff --git a/states/defs.h b/states/defs.h
index 2808900..63155a9 100644
--- a/states/defs.h
+++ b/states/defs.h
@@ -37,7 +37,7 @@
#include <ctype.h>
#ifndef ___P
-#if PROTOTYPES
+#if defined(__STDC__) || defined(PROTOTYPES)
#define ___P(protos) protos
#else /* no PROTOTYPES */
#define ___P(protos) ()
--
2.55.0

View File

@@ -0,0 +1,35 @@
From be920933dbe1fb73c27fecb280200f6f06abfdc2 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Date: Sat, 22 Aug 2026 15:19:17 +0200
Subject: [PATCH] Use -std=gnu89 instead of -std=c89
-std=c89 suppresses feature test macros, which causes <limits.h> to
not define PATH_MAX on certain C libraries (e.g. musl). Using
-std=gnu89 enables _GNU_SOURCE and other extensions, ensuring
PATH_MAX and other POSIX constants are available.
This most notably fixes the build with the musl C library.
Upstream: https://savannah.gnu.org/bugs/index.php?68634
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
configure.ac | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 4431cb1..46ea59d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,7 +11,8 @@ AC_PROG_INSTALL
AC_PROG_CC
# Force C89 standard and fix modern GCC global variable handling
-CFLAGS="$CFLAGS -std=c89"
+# Use GNU89 to access PATH_MAX in <limits.h>
+CFLAGS="$CFLAGS -std=gnu89"
AC_USE_SYSTEM_EXTENSIONS
--
2.55.0

View File

@@ -9,6 +9,10 @@ ENSCRIPT_SITE = $(BR2_GNU_MIRROR)/enscript
ENSCRIPT_LICENSE = GPL-3.0+
ENSCRIPT_LICENSE_FILES = COPYING
ENSCRIPT_CPE_ID_VENDOR = gnu
# 0002-Add-CFLAG-std-c89-so-it-compiles-with-the-old-standa.patch
# 0003-Automake-1.12-and-up-no-longer-supports-pre-ANSI.patch
# 0005-Use-std-gnu89-instead-of-std-c89.patch
ENSCRIPT_AUTORECONF = YES
# Enable pthread threads if toolchain supports threads
ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)