aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r--gnu/packages/patches/desmume-gcc6-fixes.patch59
-rw-r--r--gnu/packages/patches/desmume-gcc7-fixes.patch18
-rw-r--r--gnu/packages/patches/emacs-debbugs-keep-patch-subject.patch29
-rw-r--r--gnu/packages/patches/emacs-elpy-dup-test-name.patch60
-rw-r--r--gnu/packages/patches/emacs-next-exec-path.patch18
-rw-r--r--gnu/packages/patches/emacs-next-native-comp-driver-options.patch18
-rw-r--r--gnu/packages/patches/gklib-suitesparse.patch65
-rw-r--r--gnu/packages/patches/icu4c-fix-TestHebrewCalendarInTemporalLeapYear.patch33
-rw-r--r--gnu/packages/patches/scilab-hdf5-1.8-api.patch71
-rw-r--r--gnu/packages/patches/spectre-meltdown-checker-externalize-fwdb.patch109
-rw-r--r--gnu/packages/patches/spectre-meltdown-checker-find-kernel.patch26
-rw-r--r--gnu/packages/patches/transfig-gcc10-fno-common.patch33
-rw-r--r--gnu/packages/patches/wcstools-extend-makefiles.patch358
-rw-r--r--gnu/packages/patches/xfig-Enable-error-message-for-missing-libraries.patch39
-rw-r--r--gnu/packages/patches/xfig-Fix-double-free-when-requesting-MediaBox.patch58
-rw-r--r--gnu/packages/patches/xfig-Use-pkg-config-to-set-fontconfig-CFLAGS-and-LIBS.patch89
16 files changed, 928 insertions, 155 deletions
diff --git a/gnu/packages/patches/desmume-gcc6-fixes.patch b/gnu/packages/patches/desmume-gcc6-fixes.patch
deleted file mode 100644
index 6eb9576f64..0000000000
--- a/gnu/packages/patches/desmume-gcc6-fixes.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From: zeromus
-Origin: upstream, https://sourceforge.net/p/desmume/code/5514, https://sourceforge.net/p/desmume/code/5517, https://sourceforge.net/p/desmume/code/5430
-Subject: fix GCC6 issues
-Bug: https://sourceforge.net/p/desmume/bugs/1570/
-Bug-Debian: http://bugs.debian.org/811691
-
-Index: desmume/src/MMU_timing.h
-===================================================================
---- desmume/src/MMU_timing.h (revision 5513)
-+++ desmume/src/MMU_timing.h (revision 5517)
-@@ -155,8 +155,8 @@
- enum { ASSOCIATIVITY = 1 << ASSOCIATIVESHIFT };
- enum { BLOCKSIZE = 1 << BLOCKSIZESHIFT };
- enum { TAGSHIFT = SIZESHIFT - ASSOCIATIVESHIFT };
-- enum { TAGMASK = (u32)(~0 << TAGSHIFT) };
-- enum { BLOCKMASK = ((u32)~0 >> (32 - TAGSHIFT)) & (u32)(~0 << BLOCKSIZESHIFT) };
-+ enum { TAGMASK = (u32)(~0U << TAGSHIFT) };
-+ enum { BLOCKMASK = ((u32)~0U >> (32 - TAGSHIFT)) & (u32)(~0U << BLOCKSIZESHIFT) };
- enum { WORDSIZE = sizeof(u32) };
- enum { WORDSPERBLOCK = (1 << BLOCKSIZESHIFT) / WORDSIZE };
- enum { DATAPERWORD = WORDSIZE * ASSOCIATIVITY };
-Index: desmume/src/ctrlssdl.cpp
-===================================================================
---- desmume/src/ctrlssdl.cpp (revision 5513)
-+++ desmume/src/ctrlssdl.cpp (revision 5517)
-@@ -200,7 +200,7 @@
- break;
- case SDL_JOYAXISMOTION:
- /* Dead zone of 50% */
-- if( (abs(event.jaxis.value) >> 14) != 0 )
-+ if( ((u32)abs(event.jaxis.value) >> 14) != 0 )
- {
- key = ((event.jaxis.which & 15) << 12) | JOY_AXIS << 8 | ((event.jaxis.axis & 127) << 1);
- if (event.jaxis.value > 0) {
-@@ -370,7 +370,7 @@
- Note: button constants have a 1bit offset. */
- case SDL_JOYAXISMOTION:
- key_code = ((event->jaxis.which & 15) << 12) | JOY_AXIS << 8 | ((event->jaxis.axis & 127) << 1);
-- if( (abs(event->jaxis.value) >> 14) != 0 )
-+ if( ((u32)abs(event->jaxis.value) >> 14) != 0 )
- {
- if (event->jaxis.value > 0)
- key_code |= 1;
-Index: desmume/src/wifi.cpp
-===================================================================
---- desmume/src/wifi.cpp (revision 5429)
-+++ desmume/src/wifi.cpp (revision 5430)
-@@ -320,9 +320,9 @@
-
- #if (WIFI_LOGGING_LEVEL >= 1)
- #if WIFI_LOG_USE_LOGC
-- #define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: "__VA_ARGS__);
-+ #define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: " __VA_ARGS__);
- #else
-- #define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) printf("WIFI: "__VA_ARGS__);
-+ #define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) printf("WIFI: " __VA_ARGS__);
- #endif
- #else
- #define WIFI_LOG(level, ...) {}
diff --git a/gnu/packages/patches/desmume-gcc7-fixes.patch b/gnu/packages/patches/desmume-gcc7-fixes.patch
deleted file mode 100644
index a4934ff6e6..0000000000
--- a/gnu/packages/patches/desmume-gcc7-fixes.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-From e1f7039f1b06add4fb75b2f8774000b8f05574af Mon Sep 17 00:00:00 2001
-From: rogerman <rogerman@users.sf.net>
-Date: Mon, 17 Aug 2015 21:15:04 +0000
-Subject: Fix bug with libfat string handling.
-
-diff --git a/src/utils/libfat/directory.cpp b/src/utils/libfat/directory.cpp
-index 765d7ae5..b6d7f01f 100644
---- a/src/utils/libfat/directory.cpp
-+++ b/src/utils/libfat/directory.cpp
-@@ -139,7 +139,7 @@ static size_t _FAT_directory_mbstoucs2 (ucs2_t* dst, const char* src, size_t len
- int bytes;
- size_t count = 0;
-
-- while (count < len-1 && src != '\0') {
-+ while (count < len-1 && *src != '\0') {
- bytes = mbrtowc (&tempChar, src, MB_CUR_MAX, &ps);
- if (bytes > 0) {
- *dst = (ucs2_t)tempChar;
diff --git a/gnu/packages/patches/emacs-debbugs-keep-patch-subject.patch b/gnu/packages/patches/emacs-debbugs-keep-patch-subject.patch
new file mode 100644
index 0000000000..7a6cb642d0
--- /dev/null
+++ b/gnu/packages/patches/emacs-debbugs-keep-patch-subject.patch
@@ -0,0 +1,29 @@
+Preserve subject when replying to patch threads.
+Upstream status: likely to be in the next release (bug#66330)
+
+diff --git a/debbugs-gnu.el b/debbugs-gnu.el
+index f366fba11d..cd549e364d 100644
+--- a/debbugs-gnu.el
++++ b/debbugs-gnu.el
+@@ -1747,6 +1747,12 @@ MERGED is the list of bugs merged with this one."
+ (format "Re: bug#%d: %s" id (alist-get 'subject status)))
+ (debbugs-gnu-summary-mode 1)))
+
++(defcustom debbugs-gnu-summary-keep-subject
++ (rx "[PATCH" (? (0+ (not (any digit "/]"))) (1+ digit) "/" (1+ digit)) "]")
++ "Regular expression which keeps the original message subject in replies."
++ :version "29.1"
++ :type 'regexp)
++
+ (defvar debbugs-gnu-summary-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "C" #'debbugs-gnu-send-control-message)
+@@ -1778,6 +1784,8 @@ MERGED is the list of bugs merged with this one."
+ (cons new new))
+ address))))))
+ ,@(and debbugs-gnu-subject
++ (not (string-match-p debbugs-gnu-summary-keep-subject
++ debbugs-gnu-subject))
+ `((subject ,debbugs-gnu-subject)))))))
+
+ (defun debbugs-gnu-guess-current-id ()
diff --git a/gnu/packages/patches/emacs-elpy-dup-test-name.patch b/gnu/packages/patches/emacs-elpy-dup-test-name.patch
new file mode 100644
index 0000000000..02f3f45cec
--- /dev/null
+++ b/gnu/packages/patches/emacs-elpy-dup-test-name.patch
@@ -0,0 +1,60 @@
+Forwarded upstream: https://github.com/jorgenschaefer/elpy/pull/2031
+
+diff --git a/test/elpy-config--insert-help-test.el b/test/elpy-config--insert-help-test.el
+index bb293ff..2584fd4 100644
+--- a/test/elpy-config--insert-help-test.el
++++ b/test/elpy-config--insert-help-test.el
+@@ -2,6 +2,6 @@
+ ;; with output. We will test its constituent functions later, and just
+ ;; make sure it doesn't throw an error here.
+
+-(ert-deftest elpy-config-should-not-fail ()
++(ert-deftest elpy-config-should-not-fail-insert-help ()
+ (elpy-testcase ()
+ (elpy-config--insert-help)))
+diff --git a/test/elpy-library-root-test.el b/test/elpy-library-root-test.el
+index fdc88b2..2f7484c 100644
+--- a/test/elpy-library-root-test.el
++++ b/test/elpy-library-root-test.el
+@@ -4,7 +4,7 @@
+ (should (f-equal? (elpy-library-root)
+ project-root))))
+
+-(ert-deftest elpy-library-root-should-find-current-directory ()
++(ert-deftest elpy-library-root-should-find-current-directory-2 ()
+ (elpy-testcase ((:project project-root
+ "p1/p2/test.py"
+ "p1/p2/__init__.py"
+diff --git a/test/elpy-open-and-indent-line-above-test.el b/test/elpy-open-and-indent-line-above-test.el
+index d846712..790dd26 100644
+--- a/test/elpy-open-and-indent-line-above-test.el
++++ b/test/elpy-open-and-indent-line-above-test.el
+@@ -1,4 +1,4 @@
+-(ert-deftest elpy-open-and-indent-line-below ()
++(ert-deftest elpy-open-and-indent-line-above ()
+ (elpy-testcase ()
+ (elpy-enable)
+ (python-mode)
+diff --git a/test/elpy-rpc-get-usages-test.el b/test/elpy-rpc-get-usages-test.el
+index 85f0ad4..be5d7c5 100644
+--- a/test/elpy-rpc-get-usages-test.el
++++ b/test/elpy-rpc-get-usages-test.el
+@@ -1,4 +1,4 @@
+-(ert-deftest elpy-rpc-get-completions ()
++(ert-deftest elpy-rpc-get-completions-usages ()
+ (elpy-testcase ()
+ (mletf* ((called-args nil)
+ (elpy-rpc (&rest args) (setq called-args args)))
+diff --git a/test/elpy-rpc-test.el b/test/elpy-rpc-test.el
+index 8b5bdca..3ff6965 100644
+--- a/test/elpy-rpc-test.el
++++ b/test/elpy-rpc-test.el
+@@ -17,7 +17,7 @@
+ (should (equal error 'elpy-rpc--default-error-callback))))
+ (elpy-rpc "test-method" nil 'success))))
+
+-(ert-deftest elpy-rpc-should-use-default-without-error-callback ()
++(ert-deftest elpy-rpc-should-use-default-without-error-callback-2 ()
+ (elpy-testcase ()
+ (mletf* ((elpy-rpc--call-blocking
+ (method params)
diff --git a/gnu/packages/patches/emacs-next-exec-path.patch b/gnu/packages/patches/emacs-next-exec-path.patch
new file mode 100644
index 0000000000..6e33e25258
--- /dev/null
+++ b/gnu/packages/patches/emacs-next-exec-path.patch
@@ -0,0 +1,18 @@
+Do not capture the build-time value of $PATH in the 'emacs' executable
+since this can noticeably increase the size of the closure of Emacs
+with things like GCC being referenced.
+
+Index: emacs-next/lisp/loadup.el
+===================================================================
+--- emacs-next.orig/lisp/loadup.el
++++ emacs-next/lisp/loadup.el
+@@ -599,7 +599,8 @@ lost after dumping")))
+ ((equal dump-mode "dump") "emacs")
+ ((equal dump-mode "bootstrap") "emacs")
+ ((equal dump-mode "pbootstrap") "bootstrap-emacs.pdmp")
+- (t (error "Unrecognized dump mode %s" dump-mode)))))
++ (t (error "Unrecognized dump mode %s" dump-mode))))
++ (exec-path nil))
+ (when (and (featurep 'native-compile)
+ (equal dump-mode "pdump"))
+ ;; Don't enable this before bootstrap is completed, as the
diff --git a/gnu/packages/patches/emacs-next-native-comp-driver-options.patch b/gnu/packages/patches/emacs-next-native-comp-driver-options.patch
new file mode 100644
index 0000000000..e4ed5a48f1
--- /dev/null
+++ b/gnu/packages/patches/emacs-next-native-comp-driver-options.patch
@@ -0,0 +1,18 @@
+We substitute this anyway, so let's make it easier to substitute.
+
+--- a/lisp/emacs-lisp/comp.el
++++ b/lisp/emacs-lisp/comp.el
+@@ -203,9 +203,7 @@ and above."
+ :type '(repeat string)
+ :version "28.1")
+
+-(defcustom native-comp-driver-options
+- (cond ((eq system-type 'darwin) '("-Wl,-w"))
+- ((eq system-type 'cygwin) '("-Wl,-dynamicbase")))
++(defcustom native-comp-driver-options nil
+ "Options passed verbatim to the native compiler's back-end driver.
+ Note that not all options are meaningful; typically only the options
+ affecting the assembler and linker are likely to be useful.
+--
+2.38.0
+
diff --git a/gnu/packages/patches/gklib-suitesparse.patch b/gnu/packages/patches/gklib-suitesparse.patch
new file mode 100644
index 0000000000..8b6c708b6a
--- /dev/null
+++ b/gnu/packages/patches/gklib-suitesparse.patch
@@ -0,0 +1,65 @@
+This patch contains the relevant changes to GKlib made in SuiteSparse
+(CHOLMOD) for the version 7.2.0
+(https://github.com/DrTimothyAldenDavis/SuiteSparse/commit/8a7641cdb4809533c681417e94f98058c07c5da2).
+The disabling of signal handling when MATLAB_MEX_FILE is defined is omitted.
+
+diff -ur a/CMakeLists.txt b/CMakeLists.txt
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -3,6 +3,8 @@
+
+ option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)
+
++find_package ( SuiteSparse_config 7.1.0 REQUIRED )
++
+ get_filename_component(abs "." ABSOLUTE)
+ set(GKLIB_PATH ${abs})
+ unset(abs)
+diff -ur a/GKlib.h b/GKlib.h
+--- a/GKlib.h
++++ b/GKlib.h
+@@ -59,6 +59,24 @@
+ #include <omp.h>
+ #endif
+
++/* -------------------------------------------------------------------------- */
++/* Added for incorporation into SuiteSparse.
++ Tim Davis, Oct 31, 2022, Texas A&M University. */
++#include "SuiteSparse_config.h"
++#define malloc SuiteSparse_config_malloc
++#define calloc SuiteSparse_config_calloc
++#define realloc SuiteSparse_config_realloc
++#define free(p) \
++{ \
++ if ((p) != NULL) \
++ { \
++ SuiteSparse_config_free (p) ; \
++ (p) = NULL ; \
++ } \
++}
++
++/* -------------------------------------------------------------------------- */
++
+
+
+
+diff -ur a/memory.c b/memory.c
+--- a/memory.c
++++ b/memory.c
+@@ -108,6 +108,8 @@
+ /*************************************************************************/
+ int gk_malloc_init()
+ {
++ gkmcore = NULL;
++#if 0
+ if (gkmcore == NULL)
+ gkmcore = gk_gkmcoreCreate();
+
+@@ -115,6 +117,7 @@
+ return 0;
+
+ gk_gkmcorePush(gkmcore);
++#endif
+
+ return 1;
+ }
diff --git a/gnu/packages/patches/icu4c-fix-TestHebrewCalendarInTemporalLeapYear.patch b/gnu/packages/patches/icu4c-fix-TestHebrewCalendarInTemporalLeapYear.patch
new file mode 100644
index 0000000000..5d149d8f28
--- /dev/null
+++ b/gnu/packages/patches/icu4c-fix-TestHebrewCalendarInTemporalLeapYear.patch
@@ -0,0 +1,33 @@
+From b6b3e89231a623441940889b5badd90f74bdce2b Mon Sep 17 00:00:00 2001
+From: Frank Tang <ftang@chromium.org>
+Date: Mon, 18 Sep 2023 20:20:42 -0700
+Subject: [PATCH] ICU-22512 Fix broken TestHebrewCalendarInTemporalLeapYear
+
+Fix broken test mistakenly landed in
+https://github.com/unicode-org/icu/pull/2274
+
+Some important steps were missed in the last landing.
+---
+ icu4c/source/test/intltest/caltest.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/icu4c/source/test/intltest/caltest.cpp b/icu4c/source/test/intltest/caltest.cpp
+index 9d89f468eef0..18b96f231ba3 100644
+--- a/source/test/intltest/caltest.cpp
++++ b/source/test/intltest/caltest.cpp
+@@ -4028,6 +4028,7 @@ void CalendarTest::TestHebrewCalendarInTemporalLeapYear() {
+ for (gc.set(startYear, UCAL_JANUARY, 1);
+ gc.get(UCAL_YEAR, status) <= stopYear;
+ gc.add(UCAL_DATE, incrementDays, status)) {
++ cal->setTime(gc.getTime(status), status);
+ if (failure(status, "add/get/set/getTime/setTime incorrect")) return;
+
+ int32_t cal_year = cal->get(UCAL_EXTENDED_YEAR, status);
+@@ -4036,6 +4037,7 @@ void CalendarTest::TestHebrewCalendarInTemporalLeapYear() {
+ leapTest->set(UCAL_MONTH, 0);
+ leapTest->set(UCAL_DATE, 1);
+ // If 10 months after TISHRI is TAMUZ, then it is a leap year.
++ leapTest->add(UCAL_MONTH, 10, status);
+ hasLeapMonth = leapTest->get(UCAL_MONTH, status) == icu::HebrewCalendar::TAMUZ;
+ yearForHasLeapMonth = cal_year;
+ }
diff --git a/gnu/packages/patches/scilab-hdf5-1.8-api.patch b/gnu/packages/patches/scilab-hdf5-1.8-api.patch
new file mode 100644
index 0000000000..8b453e4720
--- /dev/null
+++ b/gnu/packages/patches/scilab-hdf5-1.8-api.patch
@@ -0,0 +1,71 @@
+This patch fixes the compilation with hdf5 version >= 1.10. Adapted from
+https://aur.archlinux.org/cgit/aur.git/plain/hdf5_18_api.patch?h=scilab-git.
+
+diff -ur a/scilab/modules/hdf5/includes/HDF5Objects.h b/scilab/modules/hdf5/includes/HDF5Objects.h
+--- a/scilab/modules/hdf5/includes/HDF5Objects.h
++++ b/scilab/modules/hdf5/includes/HDF5Objects.h
+@@ -16,14 +16,12 @@
+ #ifndef __HDF5OBJECTS_H__
+ #define __HDF5OBJECTS_H__
+
+-#define H5_NO_DEPRECATED_SYMBOLS
+ #undef H5_USE_16_API
++#define H5_USE_18_API
+
+-#define H5Eset_auto_vers 2
+ #include <hdf5.h>
+ #include <hdf5_hl.h>
+
+-#undef H5_NO_DEPRECATED_SYMBOLS
+
+ //#define __HDF5OBJECTS_DEBUG__
+ //#define __HDF5ERROR_PRINT__
+diff -ur a/scilab/modules/hdf5/Makefile.am b/scilab/modules/hdf5/Makefile.am
+--- a/scilab/modules/hdf5/Makefile.am
++++ b/scilab/modules/hdf5/Makefile.am
+@@ -104,8 +104,7 @@
+ -DH5Gopen_vers=2 \
+ -DH5Tget_array_dims_vers=2 \
+ -DH5Acreate_vers=2 \
+- -DH5Rdereference_vers=2 \
+- -DNO_DEPRECATED_SYMBOLS
++ -DH5Rdereference_vers=2
+
+
+ libscihdf5_la_CPPFLAGS = \
+diff -ur a/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_listvar_v3.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_listvar_v3.cpp
+--- a/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_listvar_v3.cpp
++++ b/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_listvar_v3.cpp
+@@ -13,6 +13,8 @@
+ *
+ */
+
++#define H5_USE_18_API
++
+ #include <vector>
+ #include "function.hxx"
+ #include "string.hxx"
+diff -ur a/scilab/modules/hdf5/src/c/h5_readDataFromFile.c b/scilab/modules/hdf5/src/c/h5_readDataFromFile.c
+--- a/scilab/modules/hdf5/src/c/h5_readDataFromFile.c
++++ b/scilab/modules/hdf5/src/c/h5_readDataFromFile.c
+@@ -13,7 +13,7 @@
+ *
+ */
+
+-#define H5_NO_DEPRECATED_SYMBOLS
++#define H5_USE_18_API
+
+ #ifndef _MSC_VER
+ #include <sys/time.h>
+diff -ur a/scilab/modules/hdf5/src/c/h5_readDataFromFile_v1.c b/scilab/modules/hdf5/src/c/h5_readDataFromFile_v1.c
+--- a/scilab/modules/hdf5/src/c/h5_readDataFromFile_v1.c
++++ b/scilab/modules/hdf5/src/c/h5_readDataFromFile_v1.c
+@@ -13,7 +13,7 @@
+ *
+ */
+
+-#define H5_NO_DEPRECATED_SYMBOLS
++#define H5_USE_18_API
+
+ #ifndef _MSC_VER
+ #include <sys/time.h>
diff --git a/gnu/packages/patches/spectre-meltdown-checker-externalize-fwdb.patch b/gnu/packages/patches/spectre-meltdown-checker-externalize-fwdb.patch
index cce70b880f..35673ceb91 100644
--- a/gnu/packages/patches/spectre-meltdown-checker-externalize-fwdb.patch
+++ b/gnu/packages/patches/spectre-meltdown-checker-externalize-fwdb.patch
@@ -1,27 +1,28 @@
-From 340b08737e552c3c186863d76d123808d853a159 Mon Sep 17 00:00:00 2001
+From 8caeb440a176cb7f8908403da51106c74e2b5cb8 Mon Sep 17 00:00:00 2001
From: Hilton Chain <hako@ultrarare.space>
-Date: Sat, 12 Nov 2022 22:45:24 +0800
+Date: Thu, 27 Jul 2023 14:45:14 +0800
Subject: [PATCH] Replace fwdb downloader with a local file option.
Also warn about non-free software.
---
- spectre-meltdown-checker.sh | 180 +++---------------------------------
- 1 file changed, 15 insertions(+), 165 deletions(-)
+ spectre-meltdown-checker.sh | 253 +++---------------------------------
+ 1 file changed, 17 insertions(+), 236 deletions(-)
diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh
-index 30f760c..ce46970 100755
+index e7b6b33..33bdf71 100755
--- a/spectre-meltdown-checker.sh
+++ b/spectre-meltdown-checker.sh
-@@ -22,8 +22,6 @@ exit_cleanup()
+@@ -23,9 +23,6 @@ exit_cleanup()
[ -n "${dumped_config:-}" ] && [ -f "$dumped_config" ] && rm -f "$dumped_config"
[ -n "${kerneltmp:-}" ] && [ -f "$kerneltmp" ] && rm -f "$kerneltmp"
[ -n "${kerneltmp2:-}" ] && [ -f "$kerneltmp2" ] && rm -f "$kerneltmp2"
- [ -n "${mcedb_tmp:-}" ] && [ -f "$mcedb_tmp" ] && rm -f "$mcedb_tmp"
- [ -n "${intel_tmp:-}" ] && [ -d "$intel_tmp" ] && rm -rf "$intel_tmp"
+- [ -n "${linuxfw_tmp:-}" ] && [ -f "$linuxfw_tmp" ] && rm -f "$linuxfw_tmp"
[ "${mounted_debugfs:-}" = 1 ] && umount /sys/kernel/debug 2>/dev/null
[ "${mounted_procfs:-}" = 1 ] && umount "$procfs" 2>/dev/null
[ "${insmod_cpuid:-}" = 1 ] && rmmod cpuid 2>/dev/null
-@@ -93,9 +91,9 @@ show_usage()
+@@ -97,9 +94,9 @@ show_usage()
--vmm [auto,yes,no] override the detection of the presence of a hypervisor, default: auto
--allow-msr-write allow probing for write-only MSRs, this might produce kernel logs or be blocked by your system
--cpu [#,all] interact with CPUID and MSR of CPU core number #, or all (default: CPU core 0)
@@ -34,10 +35,33 @@ index 30f760c..ce46970 100755
--dump-mock-data used to mimick a CPU on an other system, mainly used to help debugging this script
Return codes:
-@@ -837,147 +833,6 @@ show_header()
+@@ -858,217 +855,6 @@ show_header()
_info
}
+-# Family-Model-Stepping to CPUID
+-# prints CPUID in base-10 to stdout
+-fms2cpuid()
+-{
+- _family="$1"
+- _model="$2"
+- _stepping="$3"
+-
+- if [ "$(( _family ))" -le 15 ]; then
+- _extfamily=0
+- _lowfamily=$(( _family ))
+- else
+- # when we have a family > 0xF, then lowfamily is stuck at 0xF
+- # and extfamily is ADDED to it (as in "+"), to ensure old software
+- # never sees a lowfamily < 0xF for newer families
+- _lowfamily=15
+- _extfamily=$(( (_family) - 15 ))
+- fi
+- _extmodel=$(( (_model & 0xF0 ) >> 4 ))
+- _lowmodel=$(( (_model & 0x0F ) >> 0 ))
+- echo $(( (_stepping & 0x0F) | (_lowmodel << 4) | (_lowfamily << 8) | (_extmodel << 16) | (_extfamily << 20) ))
+-}
+-
-[ -z "$HOME" ] && HOME="$(getent passwd "$(whoami)" | cut -d: -f6)"
-mcedb_cache="$HOME/.mcedb"
-update_fwdb()
@@ -97,13 +121,15 @@ index 30f760c..ce46970 100755
- echo ERROR "please install the \`sqlite3\` program"
- return 1
- fi
-- mcedb_revision=$(sqlite3 "$mcedb_tmp" "select revision from MCE")
+- mcedb_revision=$(sqlite3 "$mcedb_tmp" "SELECT \"revision\" from \"MCE\"")
- if [ -z "$mcedb_revision" ]; then
- echo ERROR "downloaded file seems invalid"
- return 1
- fi
-- sqlite3 "$mcedb_tmp" "alter table Intel add column origin text"
-- sqlite3 "$mcedb_tmp" "update Intel set origin='mce'"
+- sqlite3 "$mcedb_tmp" "ALTER TABLE \"Intel\" ADD COLUMN \"origin\" TEXT"
+- sqlite3 "$mcedb_tmp" "ALTER TABLE \"AMD\" ADD COLUMN \"origin\" TEXT"
+- sqlite3 "$mcedb_tmp" "UPDATE \"Intel\" SET \"origin\"='mce'"
+- sqlite3 "$mcedb_tmp" "UPDATE \"AMD\" SET \"origin\"='mce'"
-
- echo OK "MCExtractor database revision $mcedb_revision"
-
@@ -141,7 +167,7 @@ index 30f760c..ce46970 100755
- _version=$(echo "$_line" | awk '{print $8}')
- _version=$(( _version ))
- _version=$(printf "0x%08X" "$_version")
-- _sqlstm="$(printf "INSERT INTO Intel (origin,cpuid,version,yyyymmdd) VALUES (\"%s\",\"%s\",\"%s\",\"%s\");" "intel" "$(printf "%08X" "$_cpuid")" "$(printf "%08X" "$_version")" "$_date")"
+- _sqlstm="$(printf "INSERT INTO \"Intel\" (\"origin\",\"cpuid\",\"version\",\"yyyymmdd\") VALUES ('%s','%s','%s','%s');" "intel" "$(printf "%08X" "$_cpuid")" "$(printf "%08X" "$_version")" "$_date")"
- sqlite3 "$mcedb_tmp" "$_sqlstm"
- done
- _intel_timestamp=$(stat -c %Y "$intel_tmp/Intel-Linux-Processor-Microcode-Data-Files-main/license" 2>/dev/null)
@@ -150,10 +176,52 @@ index 30f760c..ce46970 100755
- _intel_latest_date=$(date +%Y%m%d -d @"$_intel_timestamp")
- else
- echo "Falling back to the latest microcode date"
-- _intel_latest_date=$(sqlite3 "$mcedb_tmp" "SELECT yyyymmdd from Intel WHERE origin = 'intel' ORDER BY yyyymmdd DESC LIMIT 1;")
+- _intel_latest_date=$(sqlite3 "$mcedb_tmp" "SELECT \"yyyymmdd\" FROM \"Intel\" WHERE \"origin\"='intel' ORDER BY \"yyyymmdd\" DESC LIMIT 1;")
- fi
- echo DONE "(version $_intel_latest_date)"
-
+- # now parse the most recent linux-firmware amd-ucode README file
+- _info_nol "Fetching latest amd-ucode README from linux-firmware project... "
+- linuxfw_url="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/amd-ucode/README"
+- linuxfw_tmp=$(mktemp -t smc-linuxfw-XXXXXX)
+- if command -v wget >/dev/null 2>&1; then
+- wget -q "$linuxfw_url" -O "$linuxfw_tmp"; ret=$?
+- elif command -v curl >/dev/null 2>&1; then
+- curl -sL "$linuxfw_url" -o "$linuxfw_tmp"; ret=$?
+- elif command -v fetch >/dev/null 2>&1; then
+- fetch -q "$linuxfw_url" -o "$linuxfw_tmp"; ret=$?
+- else
+- echo ERROR "please install one of \`wget\`, \`curl\` of \`fetch\` programs"
+- return 1
+- fi
+- if [ "$ret" != 0 ]; then
+- echo ERROR "error $ret while downloading linux-firmware README"
+- return $ret
+- fi
+- echo DONE
+-
+- _info_nol "Parsing the README... "
+- nbfound=0
+- for line in $(grep -E 'Family=0x[0-9a-f]+ Model=0x[0-9a-f]+ Stepping=0x[0-9a-f]+: Patch=0x[0-9a-f]+' "$linuxfw_tmp" | tr " " ","); do
+- _debug "Parsing line $line"
+- _family=$( echo "$line" | grep -Eoi 'Family=0x[0-9a-f]+' | cut -d= -f2)
+- _model=$( echo "$line" | grep -Eoi 'Model=0x[0-9a-f]+' | cut -d= -f2)
+- _stepping=$(echo "$line" | grep -Eoi 'Stepping=0x[0-9a-f]+' | cut -d= -f2)
+- _version=$( echo "$line" | grep -Eoi 'Patch=0x[0-9a-f]+' | cut -d= -f2)
+- _version=$(printf "0x%08X" "$(( _version ))")
+- _cpuid=$(fms2cpuid "$_family" "$_model" "$_stepping")
+- _cpuid=$(printf "0x%08X" "$_cpuid")
+- _date="20000101"
+- _sqlstm="$(printf "INSERT INTO \"AMD\" (\"origin\",\"cpuid\",\"version\",\"yyyymmdd\") VALUES ('%s','%s','%s','%s');" "linux-firmware" "$(printf "%08X" "$_cpuid")" "$(printf "%08X" "$_version")" "$_date")"
+- _debug "family $_family model $_model stepping $_stepping cpuid $_cpuid"
+- _debug "$_sqlstm"
+- sqlite3 "$mcedb_tmp" "$_sqlstm"
+- nbfound=$((nbfound + 1))
+- unset _family _model _stepping _version _cpuid _date _sqlstm
+- done
+- echo "found $nbfound microcodes"
+- unset nbfound
+-
- dbversion="$mcedb_revision+i$_intel_latest_date"
-
- if [ "$1" != builtin ] && [ -n "$previous_dbversion" ] && [ "$previous_dbversion" = "v$dbversion" ]; then
@@ -165,8 +233,11 @@ index 30f760c..ce46970 100755
- {
- echo "# Spectre & Meltdown Checker";
- echo "# %%% MCEDB v$dbversion";
-- sqlite3 "$mcedb_tmp" "SELECT '# I,0x'||t1.cpuid||',0x'||MAX(t1.version)||','||t1.yyyymmdd FROM Intel AS t1 LEFT OUTER JOIN Intel AS t2 ON t2.cpuid=t1.cpuid AND t2.yyyymmdd > t1.yyyymmdd WHERE t2.yyyymmdd IS NULL GROUP BY t1.cpuid ORDER BY t1.cpuid ASC;" | grep -v '^# .,0x00000000,';
-- sqlite3 "$mcedb_tmp" "SELECT '# A,0x'||t1.cpuid||',0x'||MAX(t1.version)||','||t1.yyyymmdd FROM AMD AS t1 LEFT OUTER JOIN AMD AS t2 ON t2.cpuid=t1.cpuid AND t2.yyyymmdd > t1.yyyymmdd WHERE t2.yyyymmdd IS NULL GROUP BY t1.cpuid ORDER BY t1.cpuid ASC;" | grep -v '^# .,0x00000000,';
+- # ensure the official Intel DB always has precedence over mcedb, even if mcedb has seen a more recent fw
+- sqlite3 "$mcedb_tmp" "DELETE FROM \"Intel\" WHERE \"origin\"!='intel' AND \"cpuid\" IN (SELECT \"cpuid\" FROM \"Intel\" WHERE \"origin\"='intel' GROUP BY \"cpuid\" ORDER BY \"cpuid\" ASC);"
+- # we'll use the more recent fw for Intel and AMD
+- sqlite3 "$mcedb_tmp" "SELECT '# I,0x'||\"t1\".\"cpuid\"||',0x'||MAX(\"t1\".\"version\")||','||\"t1\".\"yyyymmdd\" FROM \"Intel\" AS \"t1\" LEFT OUTER JOIN \"Intel\" AS \"t2\" ON \"t2\".\"cpuid\"=\"t1\".\"cpuid\" AND \"t2\".\"yyyymmdd\" > \"t1\".\"yyyymmdd\" WHERE \"t2\".\"yyyymmdd\" IS NULL GROUP BY \"t1\".\"cpuid\" ORDER BY \"t1\".\"cpuid\" ASC;" | grep -v '^# .,0x00000000,';
+- sqlite3 "$mcedb_tmp" "SELECT '# A,0x'||\"t1\".\"cpuid\"||',0x'||MAX(\"t1\".\"version\")||','||\"t1\".\"yyyymmdd\" FROM \"AMD\" AS \"t1\" LEFT OUTER JOIN \"AMD\" AS \"t2\" ON \"t2\".\"cpuid\"=\"t1\".\"cpuid\" AND \"t2\".\"yyyymmdd\" > \"t1\".\"yyyymmdd\" WHERE \"t2\".\"yyyymmdd\" IS NULL GROUP BY \"t1\".\"cpuid\" ORDER BY \"t1\".\"cpuid\" ASC;" | grep -v '^# .,0x00000000,';
- } > "$mcedb_cache"
- echo DONE "(version $dbversion)"
-
@@ -182,7 +253,7 @@ index 30f760c..ce46970 100755
parse_opt_file()
{
# parse_opt_file option_name option_value
-@@ -1067,12 +922,15 @@ while [ -n "${1:-}" ]; do
+@@ -1158,12 +944,15 @@ while [ -n "${1:-}" ]; do
# deprecated, kept for compatibility
opt_explain=0
shift
@@ -204,7 +275,7 @@ index 30f760c..ce46970 100755
elif [ "$1" = "--dump-mock-data" ]; then
opt_mock=1
shift
-@@ -2033,21 +1891,11 @@ is_xen_domU()
+@@ -2192,21 +1981,11 @@ is_xen_domU()
fi
}
@@ -228,7 +299,7 @@ index 30f760c..ce46970 100755
fi
read_mcedb()
{
-@@ -2063,7 +1911,9 @@ is_latest_known_ucode()
+@@ -2222,7 +2001,9 @@ is_latest_known_ucode()
return 2
fi
ucode_latest="latest microcode version for your CPU model is unknown"
@@ -240,5 +311,5 @@ index 30f760c..ce46970 100755
elif is_amd; then
cpu_brand_prefix=A
--
-2.38.1
+2.41.0
diff --git a/gnu/packages/patches/spectre-meltdown-checker-find-kernel.patch b/gnu/packages/patches/spectre-meltdown-checker-find-kernel.patch
deleted file mode 100644
index c0e24d8eed..0000000000
--- a/gnu/packages/patches/spectre-meltdown-checker-find-kernel.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 5b757d930ec0cf102b03fb9817d17e06c72e74b3 Mon Sep 17 00:00:00 2001
-From: Hilton Chain <hako@ultrarare.space>
-Date: Sat, 5 Nov 2022 23:22:31 +0800
-Subject: [PATCH] Locate the kernel bzimage used by Guix System
-
----
- spectre-meltdown-checker.sh | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh
-index 248a444..855a090 100755
---- a/spectre-meltdown-checker.sh
-+++ b/spectre-meltdown-checker.sh
-@@ -2251,6 +2251,8 @@ if [ "$opt_live" = 1 ]; then
- [ -e "/boot/kernel-genkernel-$(uname -m)-$(uname -r)" ] && opt_kernel="/boot/kernel-genkernel-$(uname -m)-$(uname -r)"
- # NixOS:
- [ -e "/run/booted-system/kernel" ] && opt_kernel="/run/booted-system/kernel"
-+ # Guix System:
-+ [ -e "/run/booted-system/kernel/bzImage" ] && opt_kernel="/run/booted-system/kernel/bzImage"
- # systemd kernel-install:
- [ -e "/etc/machine-id" ] && [ -e "/boot/$(cat /etc/machine-id)/$(uname -r)/linux" ] && opt_kernel="/boot/$(cat /etc/machine-id)/$(uname -r)/linux"
- # Clear Linux:
-
-base-commit: a6c943d38f315f339697ec26e7374a09b88f2183
---
-2.38.0
diff --git a/gnu/packages/patches/transfig-gcc10-fno-common.patch b/gnu/packages/patches/transfig-gcc10-fno-common.patch
deleted file mode 100644
index ebe9236533..0000000000
--- a/gnu/packages/patches/transfig-gcc10-fno-common.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-Fixes "multiple definition" errors when building with GCC 10+.
-
-Based on <https://bugs.gentoo.org/show_bug.cgi?id=706706>.
---- a/fig2dev/dev/gensvg.c 2010-07-01 22:41:16.000000000 +0200
-+++ b/fig2dev/dev/gensvg.c 2022-02-27 20:02:33.379945500 +0100
-@@ -230,10 +230,12 @@
- };
-
- /* arrowhead arrays */
--Point points[50], fillpoints[50], clippoints[50];
--int npoints, nfillpoints, nclippoints;
--int arrowx1, arrowy1; /* first point of object */
--int arrowx2, arrowy2; /* second point of object */
-+Point fillpoints[50];
-+int nfillpoints;
-+extern Point points[50], clippoints[50];
-+extern int npoints, nclippoints;
-+extern int arrowx1, arrowy1; /* first point of object */
-+extern int arrowx2, arrowy2; /* second point of object */
-
- static int tileno=0; /* number of current tile */
-
---- a/fig2dev/fig2dev.h 2010-03-16 19:53:20.000000000 +0100
-+++ b/fig2dev/fig2dev.h 2022-02-27 19:56:06.072253991 +0100
-@@ -126,7 +126,7 @@
- extern char *prog, *from, *to;
- extern char *name;
- extern double font_size;
--Boolean correct_font_size; /* use correct font size */
-+extern Boolean correct_font_size; /* use correct font size */
- extern double mag, fontmag;
- extern FILE *tfp;
-
diff --git a/gnu/packages/patches/wcstools-extend-makefiles.patch b/gnu/packages/patches/wcstools-extend-makefiles.patch
new file mode 100644
index 0000000000..127bf0e670
--- /dev/null
+++ b/gnu/packages/patches/wcstools-extend-makefiles.patch
@@ -0,0 +1,358 @@
+From d702ed6d9da604e522625d08750636f680536743 Mon Sep 17 00:00:00 2001
+From: Sharlatan Hellseher <sharlatanus@gmail.com>
+Date: Mon, 11 Sep 2023 21:12:53 +0100
+Subject: [PATCH] wcstools: Extend makefiles.
+
+This patch was partly sourced from Debian Astro:
+- source: https://salsa.debian.org/debian-astro-team/wcstools/-/tree/master/
+ - file: debian/patches/Rename-libwcs-to-libwcstools-to-avoid-conflicts-with-Mark.patch
+ - commit: 91eb27654fa096d6adebb26dab8d94f5fc2fc721
+
+Additional changes applied:
+- do not rename library from libwcs to libwcstools
+- add 'install' target
+- add PREFIX and VERSION to ease packaging process
+---
+ Makefile | 146 ++++++++++++++++++++++++++----------------------
+ libwcs/Makefile | 22 ++++++--
+ 2 files changed, 96 insertions(+), 72 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index cdc8a46..caadd97 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,12 +1,13 @@
+-CFLAGS= -g -D_FILE_OFFSET_BITS=64
+-CC= cc
++CC = cc
+ LIBWCS = libwcs/libwcs.a
+ LIBS = $(LIBWCS) -lm
+-#LIBS = $(LIBWCS) -lm -lnsl -lsocket
++
++PREFIX ?= /usr
+ BIN = bin
++
+ .PRECIOUS: ${LIBWCS} ${LIBNED}
+ .c.o:
+- $(CC) -c $(CFLAGS) $(DEFS) $<
++ $(CC) -c $(CFLAGS) $(CPPFLAGS) $(DEFS) $<
+
+ all: cphead delwcs delhead edhead fixpix gethead i2f imcat imhead immatch \
+ imrot imsize imstar imwcs scat sethead addpix getpix setpix sky2xy \
+@@ -16,196 +17,205 @@ all: cphead delwcs delhead edhead fixpix gethead i2f imcat imhead immatch \
+ isfile simpos bincat
+
+ addpix: addpix.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/addpix addpix.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/addpix addpix.c $(LIBS)
+
+ bincat: bincat.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/bincat bincat.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/bincat bincat.c $(LIBS)
+
+ char2sp: char2sp.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/char2sp char2sp.c $(LIBWCS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/char2sp char2sp.c $(LIBWCS)
+
+ conpix: conpix.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/conpix conpix.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/conpix conpix.c $(LIBS)
+
+ cphead: cphead.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/cphead cphead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/cphead cphead.c $(LIBS)
+
+ crlf: crlf.c
+- $(CC) $(CFLAGS) -o $(BIN)/crlf crlf.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/crlf crlf.c
+
+ delwcs: delwcs.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/delwcs delwcs.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/delwcs delwcs.c $(LIBS)
+
+ delhead: delhead.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/delhead delhead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/delhead delhead.c $(LIBS)
+
+ edhead: edhead.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/edhead edhead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/edhead edhead.c $(LIBS)
+
+ filename: filename.c
+- $(CC) $(CFLAGS) -o $(BIN)/filename filename.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/filename filename.c
+
+ filedir: filedir.c
+- $(CC) $(CFLAGS) -o $(BIN)/filedir filedir.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/filedir filedir.c
+
+ fileroot: fileroot.c
+- $(CC) $(CFLAGS) -o $(BIN)/fileroot fileroot.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/fileroot fileroot.c
+
+ filext: filext.c
+- $(CC) $(CFLAGS) -o $(BIN)/filext filext.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/filext filext.c
+
+ fixhead: fixhead.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/fixhead fixhead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/fixhead fixhead.c $(LIBS)
+
+ fixpix: fixpix.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/fixpix fixpix.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/fixpix fixpix.c $(LIBS)
+
+ getcol: getcol.c $(LIBWCS) libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/getcol getcol.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/getcol getcol.c $(LIBS)
+
+ getdate: getdate.c $(LIBWCS) libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/getdate getdate.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/getdate getdate.c $(LIBS)
+
+ gethead: gethead.c $(LIBWCS) libwcs/wcs.h libwcs/fitsfile.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/gethead gethead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/gethead gethead.c $(LIBS)
+
+ getfits: getfits.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/getfits getfits.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/getfits getfits.c $(LIBS)
+
+ getpix: getpix.c $(LIBWCS) libwcs/wcs.h libwcs/fitsfile.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/getpix getpix.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/getpix getpix.c $(LIBS)
+
+ gettab: gettab.c $(LIBWCS) libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/gettab gettab.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/gettab gettab.c $(LIBS)
+
+ httpget: httpget.c $(LIBWCS) libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/httpget httpget.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/httpget httpget.c $(LIBS)
+
+ htmlsp: htmlsp.c
+- $(CC) $(CFLAGS) -o $(BIN)/htmlsp htmlsp.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/htmlsp htmlsp.c
+
+ i2f: i2f.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/i2f i2f.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/i2f i2f.c $(LIBS)
+
+ imcat: imcat.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/imcat imcat.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imcat imcat.c $(LIBS)
+
+ imfill: imfill.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/imfill imfill.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imfill imfill.c $(LIBS)
+
+ imresize: imresize.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/imresize imresize.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imresize imresize.c $(LIBS)
+
+ imsmooth: imsmooth.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/imsmooth imsmooth.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imsmooth imsmooth.c $(LIBS)
+
+ imhead: imhead.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/imhead imhead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imhead imhead.c $(LIBS)
+
+ imrot: imrot.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/imrot imrot.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imrot imrot.c $(LIBS)
+
+ imsize: imsize.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/imsize imsize.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imsize imsize.c $(LIBS)
+
+ imstack: imstack.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/imstack imstack.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imstack imstack.c $(LIBS)
+
+ imextract: imextract.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/imextract imextract.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imextract imextract.c $(LIBS)
+
+ imstar: imstar.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h libwcs/lwcs.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/imstar imstar.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imstar imstar.c $(LIBS)
+
+ isfile: isfile.c $(LIBWCS) libwcs/fitshead.h
+- $(CC) $(CFLAGS) -o $(BIN)/isfile isfile.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isfile isfile.c $(LIBS)
+
+ isfits: isfits.c $(LIBWCS) libwcs/fitshead.h
+- $(CC) $(CFLAGS) -o $(BIN)/isfits isfits.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isfits isfits.c $(LIBS)
+
+ isnum: isnum.c $(LIBWCS) libwcs/fitshead.h
+- $(CC) $(CFLAGS) -o $(BIN)/isnum isnum.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isnum isnum.c $(LIBS)
+
+ isdate: isdate.c $(LIBWCS) libwcs/fitshead.h
+- $(CC) $(CFLAGS) -o $(BIN)/isdate isdate.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isdate isdate.c $(LIBS)
+
+ isimlist: isimlist.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/isimlist isimlist.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isimlist isimlist.c $(LIBS)
+
+ isrange: isrange.c
+- $(CC) $(CFLAGS) -o $(BIN)/isrange isrange.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isrange isrange.c
+
+ imwcs: imwcs.c $(LIBWCS) libwcs/fitsfile.h libwcs/lwcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/imwcs imwcs.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imwcs imwcs.c $(LIBS)
+
+ immatch: immatch.c $(LIBWCS) libwcs/fitsfile.h libwcs/lwcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/immatch immatch.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/immatch immatch.c $(LIBS)
+
+ immwcs: immwcs.c $(LIBWCS) libwcs/fitsfile.h libwcs/lwcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/immwcs immwcs.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/immwcs immwcs.c $(LIBS)
+
+ keyhead: keyhead.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/keyhead keyhead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/keyhead keyhead.c $(LIBS)
+
+ matchcat: matchcat.c $(LIBWCS) libwcs/wcscat.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/matchcat matchcat.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/matchcat matchcat.c $(LIBS)
+
+ newfits: newfits.c $(LIBWCS) libwcs/fitshead.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/newfits newfits.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/newfits newfits.c $(LIBS)
+
+ remap: remap.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/remap remap.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/remap remap.c $(LIBS)
+
+ scat: scat.c $(LIBWCS) libwcs/wcscat.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/scat scat.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/scat scat.c $(LIBS)
+
+ sethead: sethead.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
+- $(CC) $(CFLAGS) -o $(BIN)/sethead sethead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/sethead sethead.c $(LIBS)
+
+ setpix: setpix.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/setpix setpix.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/setpix setpix.c $(LIBS)
+
+ sky2xy: sky2xy.c $(LIBWCS) libwcs/wcs.h libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/sky2xy sky2xy.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/sky2xy sky2xy.c $(LIBS)
+
+ skycoor: skycoor.c $(LIBWCS) libwcs/wcs.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/skycoor skycoor.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/skycoor skycoor.c $(LIBS)
+
+ sp2char: sp2char.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/sp2char sp2char.c $(LIBWCS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/sp2char sp2char.c $(LIBWCS)
+
+ subpix: subpix.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/subpix subpix.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/subpix subpix.c $(LIBS)
+
+ sumpix: sumpix.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/sumpix sumpix.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/sumpix sumpix.c $(LIBS)
+
+ wcshead: wcshead.c $(LIBWCS) libwcs/fitsfile.h
+- $(CC) $(CFLAGS) -o $(BIN)/wcshead wcshead.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/wcshead wcshead.c $(LIBS)
+
+ xy2sky: xy2sky.c $(LIBWCS) libwcs/wcs.h libwcs/wcscat.h
+- $(CC) $(CFLAGS) -o $(BIN)/xy2sky xy2sky.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/xy2sky xy2sky.c $(LIBS)
+
+ simpos: simpos.c libwcs/libwcs.a
+- $(CC) $(CFLAGS) -o $(BIN)/simpos simpos.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/simpos simpos.c $(LIBS)
+
+ gsc2cat: gsc2cat.c $(LIBWCS)
+- $(CC) $(CFLAGS) -o $(BIN)/gsc2cat gsc2cat.c $(LIBS)
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/gsc2cat gsc2cat.c $(LIBS)
+
+ tmcat: tmcat.c
+- $(CC) $(CFLAGS) -o $(BIN)/tmcat tmcat.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/tmcat tmcat.c
+
+ tmcate: tmcate.c
+- $(CC) $(CFLAGS) -o $(BIN)/tmcate tmcate.c
++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/tmcate tmcate.c
+
+ $(LIBWCS): libwcs/*.c libwcs/*.h
+- cd libwcs; make
++ $(MAKE) CC=$(CC) -C libwcs
++
++install:
++ test -e $(DESTDIR)$(PREFIX)/bin || mkdir -p $(DESTDIR)$(PREFIX)/bin
++ test -e $(DESTDIR)$(PREFIX)/include || mkdir -p $(DESTDIR)$(PREFIX)/include/wcstools
++ test -e $(DESTDIR)$(PREFIX)/lib/wcstools || mkdir -p $(DESTDIR)$(PREFIX)/lib/wcstools
++ test -e $(DESTDIR)$(PREFIX)/share/wcstools || mkdir -p $(DESTDIR)$(PREFIX)/share/wcstools
++ install ./bin/* $(DESTDIR)$(PREFIX)/bin
++ install ./libwcs/*.so $(DESTDIR)$(PREFIX)/lib/wcstools
++ install ./libwcs/*.so.* $(DESTDIR)$(PREFIX)/lib/wcstools
+
+ objclean:
+- cd libwcs; make clean
++ $(MAKE) -C libwcs clean
+
+ binclean:
+ rm -f ./bin/*
+
+ clean:
+- make objclean; make binclean
++ objclean binclean
+diff --git a/libwcs/Makefile b/libwcs/Makefile
+index ec2fae0..038ec61 100644
+--- a/libwcs/Makefile
++++ b/libwcs/Makefile
+@@ -1,5 +1,10 @@
+-CFLAGS= -g -D_FILE_OFFSET_BITS=64
+-CC= cc
++CFLAGS+= -fPIC
++
++VERSION?= 3.9.7
++VERSION_PARTS= $(subst ., ,$(VERSION))
++VERSION_MAJOR= $(word 1,$(VERSION_PARTS))
++VERSION_MINOR= $(word 2,$(VERSION_PARTS))
++VERSION_MICRO= $(word 3,$(VERSION_PARTS))
+
+ OBJS = imsetwcs.o imgetwcs.o matchstar.o findstar.o daoread.o wcscon.o \
+ fitswcs.o wcsinit.o wcs.o ty2read.o webread.o tmcread.o \
+@@ -11,10 +16,19 @@ OBJS = imsetwcs.o imgetwcs.o matchstar.o findstar.o daoread.o wcscon.o \
+ sortstar.o platefit.o iget.o fileutil.o \
+ wcslib.o lin.o cel.o proj.o sph.o wcstrig.o distort.o poly.o
+
+-libwcs.a: $(OBJS)
++all: libwcs.so.$(VERSION) libwcs.a
+ ar rv $@ $?
+ ranlib $@
+
++libwcs.a: $(OBJS)
++ ar rv $@ $?
++ ranlib $@
++
++libwcs.so.$(VERSION): $(OBJS)
++ $(CC) $(LDFLAGS) -shared -o $@ -Wl,-soname,libwcs.so.$(VERSION_MAJOR) $? -lm
++ ln -s libwcs.so.$(VERSION) libwcs.so.$(VERSION_MAJOR)
++ ln -s libwcs.so.$(VERSION) libwcs.so
++
+ actread.o: fitsfile.h wcscat.h wcs.h fitshead.h wcslib.h
+ binread.o: wcscat.h wcs.h fitshead.h wcslib.h
+ ctgread.o: wcscat.h wcs.h fitshead.h wcslib.h
+@@ -67,4 +81,4 @@ webread.o: wcscat.h
+ worldpos.o: wcs.h fitshead.h wcslib.h
+
+ clean:
+- rm -f *.a *.o
++ rm -f *.a *.o *.so *.so.*
+--
+2.41.0
+
diff --git a/gnu/packages/patches/xfig-Enable-error-message-for-missing-libraries.patch b/gnu/packages/patches/xfig-Enable-error-message-for-missing-libraries.patch
new file mode 100644
index 0000000000..a6c37e3353
--- /dev/null
+++ b/gnu/packages/patches/xfig-Enable-error-message-for-missing-libraries.patch
@@ -0,0 +1,39 @@
+From 84685930d5cfc7005f3414601230a23e28a18f59 Mon Sep 17 00:00:00 2001
+From: Thomas Loimer <thomas.loimer@tuwien.ac.at>
+Date: Tue, 5 Sep 2023 22:02:55 +0200
+Subject: [PATCH 1/3] Enable error message for missing libraries
+
+Move the check for missing libraries to a place where the queried
+variables are set.
+---
+ configure.ac | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 035b9d7..47452c5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -95,9 +95,6 @@ dnl AC_CHECK_PROG(XDG_MENU, [xdg-desktop-menu], [xdg-desktop-menu])
+ AC_SEARCH_LIBS([pow], [m])dnl
+ dnl AC_SEARCH_LIBS([deflate], [z]) # libz is not needed.
+ AC_SEARCH_LIBS([FcInit], [fontconfig])
+-AS_IF([test "x$ac_cv_search_pow" = xno \
+- || test "x$ac_cv_search_png_read_info" = xno],
+- [AC_MSG_ERROR([Necessary libraries not found.])])
+
+
+ # Checks for header files.
+@@ -187,6 +184,10 @@ PostScript files. To disable calling ghostscript, set to the empty string,
+ AC_SUBST([gsman])
+ AM_SUBST_NOTMAKE([gsman])
+
++AS_IF([test "x$ac_cv_search_pow" = xno \
++ || test "x$ac_cv_search_png_read_info" = xno],
++ [AC_MSG_ERROR([Necessary libraries not found.])])
++
+
+ # Checks for typedefs, structures, and compiler characteristics.
+ AC_C_BIGENDIAN
+--
+2.40.1
+
diff --git a/gnu/packages/patches/xfig-Fix-double-free-when-requesting-MediaBox.patch b/gnu/packages/patches/xfig-Fix-double-free-when-requesting-MediaBox.patch
new file mode 100644
index 0000000000..65b0ad8d36
--- /dev/null
+++ b/gnu/packages/patches/xfig-Fix-double-free-when-requesting-MediaBox.patch
@@ -0,0 +1,58 @@
+From a9181df87d78828318f2e9f8d4ea012bc06883b9 Mon Sep 17 00:00:00 2001
+From: Bruno Victal <mirai@makinata.eu>
+Date: Thu, 7 Sep 2023 16:51:23 +0100
+Subject: [PATCH 3/3] Fix double-free when requesting MediaBox.
+
+Explicitly close the Ghostscript PDF interpreter before calling quit.
+
+References:
+[1]: <https://bugs.ghostscript.com/show_bug.cgi?id=705855>
+[2]: <https://bugs.ghostscript.com/show_bug.cgi?id=705836>
+---
+ src/u_ghostscript.c | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/src/u_ghostscript.c b/src/u_ghostscript.c
+index 5974b31..d14674f 100644
+--- a/src/u_ghostscript.c
++++ b/src/u_ghostscript.c
+@@ -317,10 +317,10 @@ gsexe(FILE **out, bool *isnew, char *exenew, char *exeold)
+ * Call ghostscript to extract the /MediaBox from the pdf given in file.
+ * Command line, for gs >= 9.50,
+ * gs -q -dNODISPLAY --permit-file-read=in.pdf -c \
+- * "(in.pdf) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit"
++ * "(in.pdf) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == runpdfend quit"
+ * gs < 9.50:
+ * gs -q -dNODISPLAY -dNOSAFER -c \
+- * "(in.pdf) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit"
++ * "(in.pdf) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == runpdfend quit"
+ * The command line was found, and modified a bit, at
+ *https://stackoverflow.com/questions/2943281/using-ghostscript-to-get-page-size
+ * Beginning with gs 9.50, "-dSAFER" is the default, and permission to access
+@@ -349,9 +349,11 @@ gsexe_mediabox(char *file, int *llx, int *lly, int *urx, int *ury)
+ return -3;
+
+ exenew = "%s -q -dNODISPLAY \"--permit-file-read=%s\" -c \"(%s) (r) "
+- "file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit\"";
++ "file runpdfbegin 1 pdfgetpage /MediaBox pget pop == "
++ "runpdfend quit\"";
+ exeold = "%s -q -dNODISPLAY -c \"(%s) (r) "
+- "file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit\"";
++ "file runpdfbegin 1 pdfgetpage /MediaBox pget pop == "
++ "runpdfend quit\"";
+
+ /* malloc() buffers for the command line, if necessary */
+ fmt = exenew;
+@@ -445,7 +447,8 @@ gslib_mediabox(char *file, int *llx, int *lly, int *urx, int *ury)
+ argnew[3] = "--permit-file-read=%s"; /* file */
+ argnew[4] = "-c";
+ argnew[5] =
+- "(%s) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit";
++ "(%s) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == "
++ "runpdfend quit";
+
+ argold[0] = argnew[0];
+ argold[1] = argnew[1];
+--
+2.40.1
+
diff --git a/gnu/packages/patches/xfig-Use-pkg-config-to-set-fontconfig-CFLAGS-and-LIBS.patch b/gnu/packages/patches/xfig-Use-pkg-config-to-set-fontconfig-CFLAGS-and-LIBS.patch
new file mode 100644
index 0000000000..65158b901b
--- /dev/null
+++ b/gnu/packages/patches/xfig-Use-pkg-config-to-set-fontconfig-CFLAGS-and-LIBS.patch
@@ -0,0 +1,89 @@
+From 4320b1d82da1bfe1519800ae3ac35b6b59a9da56 Mon Sep 17 00:00:00 2001
+From: Thomas Loimer <thomas.loimer@tuwien.ac.at>
+Date: Fri, 8 Sep 2023 18:43:00 +0200
+Subject: [PATCH 2/3] Use pkg-config to set fontconfig CFLAGS and LIBS
+
+---
+ configure.ac | 16 +++++++++++++---
+ src/Makefile.am | 8 +++-----
+ tests/Makefile.am | 4 ++--
+ 3 files changed, 18 insertions(+), 10 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 47452c5..3113db8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -81,11 +81,23 @@ AC_PROG_SED
+ AM_PROG_AR
+
+ # Search for pkg-config and set PKG_CONFIG to the path found, else empty.
+-# PKG_PROG_PKG_CONFIG
++PKG_PROG_PKG_CONFIG
+ # On debian, pkg-config does not find xaw3d. On archlinux, pkg-config
+ # --libs xaw3d yields -lXaw3d -lXmu -lXt -lX11 -- but -lXmu is not
+ # strictly necessary. Use hard-coded paths instead of pkg-config.
+
++# First try pkg-config, as a side-effect this might set flags that are
++# useful later, e.g., for libpng.
++dnl Under archlinux, PKG_CHECK_MODULES(FT, fontconfig) would write during
++dnl ./configure "checking for FT...", under debian the line is
++dnl "checking for fontconfig...". Stay on the comprehensible side.
++AS_IF([test "x$PKG_CONFIG" != x],
++ [PKG_CHECK_MODULES([fontconfig], [fontconfig])],
++ [fontconfig_CFLAGS='-I$(oldincludedir)/freetype2 '
++ AC_SEARCH_LIBS([FcInit], [fontconfig])])
++AC_SUBST([fontconfig_CFLAGS])
++AC_SUBST([fontconfig_LIBS])
++
+ dnl Not useful for packagers.
+ dnl AC_CHECK_PROG(XDG_ICON, [xdg-icon-resource], [xdg-icon-resource])
+ dnl AC_CHECK_PROG(XDG_MENU, [xdg-desktop-menu], [xdg-desktop-menu])
+@@ -93,8 +105,6 @@ dnl AC_CHECK_PROG(XDG_MENU, [xdg-desktop-menu], [xdg-desktop-menu])
+
+ # Checks for libraries.
+ AC_SEARCH_LIBS([pow], [m])dnl
+-dnl AC_SEARCH_LIBS([deflate], [z]) # libz is not needed.
+-AC_SEARCH_LIBS([FcInit], [fontconfig])
+
+
+ # Checks for header files.
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 3cbd5ee..73d5132 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -23,13 +23,11 @@
+ # "`u' modifier ignored since `D' is the default...".
+ ARFLAGS = cr
+
+-# Xft #includes <ft2build.h>, not <freetype2/ft2build.h>, hence freetype2
+-# must be put into the search path.
+-
+-AM_CPPFLAGS = -I$(oldincludedir)/freetype2 $(XCPPFLAGS) -DNDEBUG -DXFIGLIBDIR="\"$(compkeydbdir)\"" \
++AM_CPPFLAGS = $(fontconfig_CFLAGS) $(XCPPFLAGS) -DNDEBUG \
++ -DXFIGLIBDIR="\"$(compkeydbdir)\"" \
+ -DOBJLIBDIR="\"$(pkgdatadir)/Libraries\"" -DXFIGDOCDIR="\"$(docdir)\""
+
+-AM_LDFLAGS = $(XLDFLAGS)
++AM_LDFLAGS = $(fontconfig_LIBS) $(XLDFLAGS)
+
+ # LIBOBJS must be placed in LDADD or xfig_LDADD - otherwise, the
+ # lib-dir is not distributed
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 2f529ac..c158806 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -39,9 +39,9 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
+ echo 'm4_define([AT_PACKAGE_URL], [@PACKAGE_URL@])'; \
+ } >'$(srcdir)/package.m4'
+
+-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(oldincludedir)/freetype2 $(XCPPFLAGS)
++AM_CPPFLAGS = -I$(top_srcdir)/src $(fontconfig_CFLAGS) $(XCPPFLAGS)
+
+-AM_LDFLAGS = $(XLDFLAGS)
++AM_LDFLAGS = $(fontconfig_LIBS) $(XLDFLAGS)
+ LDADD = $(top_builddir)/src/libxfig.a $(XLIBS)
+
+ check_PROGRAMS = test1 test2 test3 test4
+--
+2.40.1
+