diff mbox series

[bug#62916,v2,1/1] gnu: p11-kit: fix build on mingw.

Message ID a99229ce9b42800614b8a9976b24261ecc464d9e.1682439400.git.vivien@planete-kraus.eu
State New
Headers show
Series Fix p11-kit build system for mingw | expand

Commit Message

Vivien Kraus April 25, 2023, 3:50 p.m. UTC
* gnu/packages/patches/p11-kit-fix-build-system-for-mingw.patch: New patch. It
makes sure that all symbols are defined when linking objects.
* gnu/packages/tls.scm (p11-kit) [on target-mingw?] [phase
'apply-mingw-patch]: New phase, similar to what’s done with hurd.
* gnu/packages/tls.scm (p11-kit) [native-inputs]: also add the autotools on mingw.
---
 gnu/local.mk                                  |   3 +-
 .../p11-kit-fix-build-system-for-mingw.patch  | 108 ++++++++++++++++++
 gnu/packages/tls.scm                          |  14 ++-
 3 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/p11-kit-fix-build-system-for-mingw.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 66dd240ba9..355c09caa4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1696,7 +1696,8 @@  dist_patch_DATA =						\
   %D%/packages/patches/sqlite-hurd.patch			\
   %D%/packages/patches/strace-readlink-tests.patch		\
   %D%/packages/patches/sunxi-tools-remove-sys-io.patch	\
-  %D%/packages/patches/p11-kit-hurd.patch			\
+  %D%/packages/patches/p11-kit-hurd.patch		        \
+  %D%/packages/patches/p11-kit-fix-build-system-for-mingw.patch \
   %D%/packages/patches/patch-hurd-path-max.patch		\
   %D%/packages/patches/perl-5.14-autosplit-default-time.patch	\
   %D%/packages/patches/perl-5.14-module-pluggable-search.patch	\
diff --git a/gnu/packages/patches/p11-kit-fix-build-system-for-mingw.patch b/gnu/packages/patches/p11-kit-fix-build-system-for-mingw.patch
new file mode 100644
index 0000000000..cc02fdf1b3
--- /dev/null
+++ b/gnu/packages/patches/p11-kit-fix-build-system-for-mingw.patch
@@ -0,0 +1,108 @@ 
+From e350540c9e2259e2f66cbaf7c6dc347f03acac40 Mon Sep 17 00:00:00 2001
+From: Vivien Kraus <vivien@planete-kraus.eu>
+Date: Tue, 25 Apr 2023 17:41:47 +0200
+Subject: [PATCH] Fix the build system to avoid undefined references on mingw.
+
+---
+ p11-kit/Makefile.am | 23 ++++++++++++-----------
+ trust/Makefile.am   |  5 ++---
+ 2 files changed, 14 insertions(+), 14 deletions(-)
+
+diff --git a/p11-kit/Makefile.am b/p11-kit/Makefile.am
+index 7fe7a6c..017edd3 100644
+--- a/p11-kit/Makefile.am
++++ b/p11-kit/Makefile.am
+@@ -13,6 +13,7 @@ COMMON_SRCS = \
+ 	p11-kit/conf.c p11-kit/conf.h \
+ 	p11-kit/iter.c \
+ 	p11-kit/log.c p11-kit/log.h \
++	p11-kit/lists.c \
+ 	p11-kit/filter.c p11-kit/filter.h \
+ 	p11-kit/modules.c p11-kit/modules.h \
+ 	p11-kit/pkcs11.h \
+@@ -80,6 +81,7 @@ COMMON_CFLAGS = \
+ COMMON_LIBS = \
+ 	libp11-common.la \
+ 	libp11-library.la \
++	libp11-tool.la \
+ 	$(LIBFFI_LIBS) \
+ 	$(LTLIBINTL) \
+ 	$(NULL)
+@@ -125,7 +127,8 @@ libp11_kit_testable_la_SOURCES = \
+ 	$(libp11_kit_internal_la_SOURCES) \
+ 	$(libp11_kit_la_SOURCES) \
+ 	$(NULL)
+-libp11_kit_testable_la_LIBADD = $(COMMON_LIBS)
++libp11_kit_testable_la_LIBADD = $(COMMON_LIBS) \
++	libp11-tool.la
+ 
+ pkcs11_gnu_sources = \
+ 	p11-kit/uri.gnu.c \
+@@ -238,14 +241,12 @@ EXTRA_DIST += \
+ bin_PROGRAMS += p11-kit/p11-kit
+ 
+ p11_kit_p11_kit_SOURCES = \
+-	p11-kit/lists.c \
+ 	p11-kit/p11-kit.c \
+ 	$(NULL)
+ 
+ p11_kit_p11_kit_LDADD = \
+-	libp11-kit.la \
+-	libp11-tool.la \
+-	libp11-common.la \
++	libp11-kit-internal.la \
++        $(COMMON_LIBS) \
+ 	$(LTLIBINTL) \
+ 	$(NULL)
+ 
+@@ -257,12 +258,12 @@ private_PROGRAMS += p11-kit/p11-kit-remote
+ 
+ p11_kit_p11_kit_remote_SOURCES = \
+ 	p11-kit/remote.c \
++	$(libp11_kit_la_SOURCES) \
+ 	$(NULL)
+ 
+ p11_kit_p11_kit_remote_LDADD = \
+-	libp11-tool.la \
+-	libp11-common.la \
+-	libp11-kit.la \
++	libp11-kit-internal.la \
++        $(COMMON_LIBS) \
+ 	$(NULL)
+ 
+ check_PROGRAMS += p11-kit/p11-kit-remote-testable
+@@ -278,12 +279,12 @@ private_PROGRAMS += p11-kit/p11-kit-server
+ 
+ p11_kit_p11_kit_server_SOURCES = \
+ 	p11-kit/server.c \
++	$(libp11_kit_la_SOURCES) \
+ 	$(NULL)
+ 
+ p11_kit_p11_kit_server_LDADD = \
+-	libp11-tool.la \
+-	libp11-common.la \
+-	libp11-kit.la \
++	libp11-kit-internal.la \
++        $(COMMON_LIBS) \
+ 	$(LIBSYSTEMD_LIBS) \
+ 	$(NULL)
+ 
+diff --git a/trust/Makefile.am b/trust/Makefile.am
+index 6ff5d12..f5d87f5 100644
+--- a/trust/Makefile.am
++++ b/trust/Makefile.am
+@@ -84,9 +84,8 @@ bin_PROGRAMS += trust/trust
+ 
+ trust_trust_LDADD = \
+ 	libtrust-data.la \
+-	libp11-kit.la \
+-	libp11-common.la \
+-	libp11-tool.la \
++	libp11-kit-internal.la \
++        $(COMMON_LIBS) \
+ 	$(LTLIBINTL) \
+ 	$(LIBTASN1_LIBS) \
+ 	$(HASH_LIBS) \
+-- 
+2.39.2
+
diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index e0da7757e0..2cd43c6957 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -153,7 +153,7 @@  (define-public p11-kit
     (build-system gnu-build-system)
     (native-inputs
      (append (list pkg-config)
-             (if (hurd-target?)
+             (if (or (target-mingw?) (hurd-target?))
                  (list autoconf automake gettext-minimal libtool)
                  '())))
     (inputs
@@ -179,6 +179,18 @@  (define patch
                                     (lambda _
                                       (invoke "autoreconf" "-fiv"))))
                                #~())
+                        #$@(if (target-mingw?)
+                               #~((add-after 'unpack 'apply-mingw-patch
+                                    (lambda* (#:key inputs #:allow-other-keys)
+                                      (define patch
+                                        #$(local-file
+                                           (search-patch "p11-kit-fix-build-system-for-mingw.patch")))
+                                      (invoke "patch" "-p1" "--batch" "-i"
+                                              patch)))
+                                  (replace 'bootstrap
+                                    (lambda _
+                                      (invoke "autoreconf" "-fiv"))))
+                               #~())
                         (add-before 'check 'prepare-tests
                           (lambda _
                             ;; "test-runtime" expects XDG_RUNTIME_DIR to be set up