From 34cfc9e26125727e4fed0c5ca4d2aa9c99ea3db1 Mon Sep 17 00:00:00 2001 From: annalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com> Date: Sun, 3 Dec 2023 07:46:29 +0000 Subject: [PATCH] enscript: use system getopt for all builds; fix darwin --- .../enscript/0001-use-system-getopt.patch | 68 +++++++++++++++++++ pkgs/tools/text/enscript/default.nix | 20 ++++-- 2 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 pkgs/tools/text/enscript/0001-use-system-getopt.patch diff --git a/pkgs/tools/text/enscript/0001-use-system-getopt.patch b/pkgs/tools/text/enscript/0001-use-system-getopt.patch new file mode 100644 index 000000000000..0ae8776f361e --- /dev/null +++ b/pkgs/tools/text/enscript/0001-use-system-getopt.patch @@ -0,0 +1,68 @@ +From 4c5cbf6db71cf2981fc836ed370c82149748d8ea Mon Sep 17 00:00:00 2001 +From: annalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com> +Date: Wed, 6 Dec 2023 22:57:19 +0000 +Subject: [PATCH] use system getopt + +the file compat/getopt.h also needs to be removed otherwise it will +create conflicts with the system includes +--- + compat/Makefile.am | 4 ++-- + compat/Makefile.in | 6 +++--- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/compat/Makefile.am b/compat/Makefile.am +index aefc06f..23aaf81 100644 +--- a/compat/Makefile.am ++++ b/compat/Makefile.am +@@ -25,7 +25,7 @@ + AUTOMAKE_OPTIONS = no-dependencies + + noinst_LIBRARIES = libcompat.a +-libcompat_a_SOURCES = getopt.c getopt1.c xalloc.c regex.c ++libcompat_a_SOURCES = xalloc.c regex.c + libcompat_a_LIBADD = @LIBOBJS@ @ALLOCA@ + libcompat_a_DEPENDENCIES = @LIBOBJS@ @ALLOCA@ + +@@ -34,7 +34,7 @@ libcompat_a_SOURCES_windelta = \ + +../w32/getpwd.c \ + +../w32/getuid.c + +-noinst_HEADERS = getopt.h regex.h xalloc.h ++noinst_HEADERS = regex.h xalloc.h + + EXTRA_DIST = ChangeLog.old strerror.c memmove.c memcpy.c strtol.c \ + strtoul.c gettext.h +diff --git a/compat/Makefile.in b/compat/Makefile.in +index edfc620..dee05d7 100644 +--- a/compat/Makefile.in ++++ b/compat/Makefile.in +@@ -137,7 +137,7 @@ am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) + am__v_AR_0 = @echo " AR " $@; + am__v_AR_1 = + libcompat_a_AR = $(AR) $(ARFLAGS) +-am_libcompat_a_OBJECTS = getopt.$(OBJEXT) getopt1.$(OBJEXT) \ ++am_libcompat_a_OBJECTS = \ + xalloc.$(OBJEXT) regex.$(OBJEXT) + libcompat_a_OBJECTS = $(am_libcompat_a_OBJECTS) + AM_V_P = $(am__v_P_@AM_V@) +@@ -326,7 +326,7 @@ top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + AUTOMAKE_OPTIONS = no-dependencies + noinst_LIBRARIES = libcompat.a +-libcompat_a_SOURCES = getopt.c getopt1.c xalloc.c regex.c ++libcompat_a_SOURCES = xalloc.c regex.c + libcompat_a_LIBADD = @LIBOBJS@ @ALLOCA@ + libcompat_a_DEPENDENCIES = @LIBOBJS@ @ALLOCA@ + libcompat_a_SOURCES_windelta = \ +@@ -334,7 +334,7 @@ libcompat_a_SOURCES_windelta = \ + +../w32/getpwd.c \ + +../w32/getuid.c + +-noinst_HEADERS = getopt.h regex.h xalloc.h ++noinst_HEADERS = regex.h xalloc.h + EXTRA_DIST = ChangeLog.old strerror.c memmove.c memcpy.c strtol.c \ + strtoul.c gettext.h + +-- +2.42.0 + diff --git a/pkgs/tools/text/enscript/default.nix b/pkgs/tools/text/enscript/default.nix index 1299ef78679c..e5aeb75ca626 100644 --- a/pkgs/tools/text/enscript/default.nix +++ b/pkgs/tools/text/enscript/default.nix @@ -9,12 +9,20 @@ stdenv.mkDerivation rec { sha256 = "1fy0ymvzrrvs889zanxcaxjfcxarm2d3k43c9frmbl1ld7dblmkd"; }; - preBuild = - '' - # Fix building on Darwin with GCC. - substituteInPlace compat/regex.c --replace \ - __private_extern__ '__attribute__ ((visibility ("hidden")))' - ''; + patches = [ + # fix compile failure on macos. use system getopt like linux + # requires that compat/getopt.h is also removed + # https://savannah.gnu.org/bugs/?64307 + ./0001-use-system-getopt.patch + ]; + + postPatch = '' + # the delete component of 0001-use-system-getopt.patch + rm compat/getopt.h + # Fix building on Darwin with GCC. + substituteInPlace compat/regex.c --replace \ + __private_extern__ '__attribute__ ((visibility ("hidden")))' + ''; buildInputs = [ gettext ];