kumquat-buildroot/package/libest/0003-Add-with-system-libsafec-flag-to-link-against-system.patch
Aleksandr Makarov f6f0e1e581 package/libest: new package
libest is a C implementation of RFC 7030 (Enrollment over
Secure Transport).

It can be used to provision public key certificates from
a certificate authority (CA) or registration authority (RA)
to end-user devices and network infrastructure devices.

https://github.com/cisco/libest

Notes on patches included in this package:

- libest bundles a stubbed version of libsafec, and has no provision
  to build against a system-installed full (non-stubbed) libsafec.
  We add a patch to make that possible.

- Added a configuration option --{enable,disable}-examples to toggle
  examples build by a separate patch.

- There's a configuration option `--enable-jni` which allows to build
  a JNI library for binding libest to Java programs. And that library
  would be using an outdated version of OpenSSL 1.0.
  We fix that by adding support for OpenSSL 1.1 API for that library.

- Fixed a bug when specifying either `--enable-FEATURE` or `--disable-FEATURE`
  has always been enabling the feature.

Signed-off-by: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
[Thomas:
- Added comments about the upstream status in existing patches
- Added a patch fixing an autoreconf issue
- Added a patch adding a missing "extern" on a variable to fix build
  with gcc 10
- Removed the glibc dependency by using the new libexecinfo package
- Drastically simplified the complex libcoap disabling and client-only
  mode vs. OpenJDK issue. libcoap support is now forcefully disabled,
  and client-mode only option is made invisible when OpenJDK is
  enabled.
- Fixed the license information;
- Added missing host-pkgconf
]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2022-01-08 14:29:27 +01:00

110 lines
3.7 KiB
Diff

From 017155b98ff3722816a52953b1079c9c8704d2ff Mon Sep 17 00:00:00 2001
From: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
Date: Tue, 14 Jul 2020 10:03:14 +0000
Subject: [PATCH] Add --with-system-libsafec flag to link against system
libsafec
Specifying the --with-system-libsafec flag shall allow the configuration
program to search for and, if found, to link against the libsafec library
that is installed in the system.
Upstream: https://github.com/cisco/libest/pull/81/. It was merged
upstream in commit 4fd7e74dc556519132b9ea4c8a0f022bd1254a31, but this
commit mixes multiple patches in one.
Signed-off-by: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
---
Makefile.am | 6 +++++-
configure.ac | 41 +++++++++++++++++++++++++++++++----------
2 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index e2561e7..d53b0d5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,5 +12,9 @@ examples = example/client example/client-simple example/client-brski example/ser
endif
endif
-SUBDIRS = safe_c_stub src $(libest_jni) $(examples)
+if ! WITH_SYSTEM_LIBSAFEC
+builtin_libsafec = safe_c_stub
+endif
+
+SUBDIRS = $(builtin_libsafec) src $(libest_jni) $(examples)
EXTRA_DIST = autogen.sh example/util LICENSE README.brski $(srcdir)/build.gradle $(srcdir)/example/build_examples.gradle
diff --git a/configure.ac b/configure.ac
index 95b3223..048aa3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,7 @@ AM_INIT_AUTOMAKE([subdir-objects])
AC_PROG_CC
AM_PROG_CC_C_O
+PKG_PROG_PKG_CONFIG
LT_INIT
AC_CANONICAL_HOST
case $host in
@@ -187,22 +188,39 @@ AC_ARG_WITH([libcoap-dir],
]
)
-SAFEC_STUB_DIR='$(abs_top_builddir)/safe_c_stub'
-AC_SUBST(SAFEC_STUB_DIR)
-safecdir="$SAFEC_STUB_DIR"
-AC_SUBST([SAFEC_DIR], "$safecdir")
-AC_SUBST([SAFEC_CFLAGS], "$safecdir/include")
-AC_SUBST([SAFEC_LDFLAGS], "$safecdir/lib")
+AC_ARG_WITH(system-libsafec,
+ AS_HELP_STRING([--with-system-libsafec],
+ [select to use libsafec installed in the system]),
+ [],
+ [with_system_libsafec="no"])
-CFLAGS="$CFLAGS -Wall -I$safecdir/include"
-LDFLAGS="$LDFLAGS -L$safecdir/lib"
-LIBS="$LIBS -lsafe_lib"
+AC_MSG_CHECKING(which libsafec to use)
+AM_CONDITIONAL([WITH_SYSTEM_LIBSAFEC], [test "$with_system_libsafec" = "yes"])
+AM_COND_IF([WITH_SYSTEM_LIBSAFEC], AC_MSG_RESULT([system]), AC_MSG_RESULT([built-in]))
+AM_COND_IF([WITH_SYSTEM_LIBSAFEC],
+[
+ PKG_CHECK_MODULES([libsafec], [libsafec])
+ LIBS="$LIBS $libsafec_LIBS"
+ CFLAGS="$CFLAGS $libsafec_CFLAGS"
+ CPPFLAGS="$CPPFLAGS $libsafec_CFLAGS"
+],[
+ SAFEC_STUB_DIR='$(abs_top_builddir)/safe_c_stub'
+ AC_SUBST(SAFEC_STUB_DIR)
+ safecdir="$SAFEC_STUB_DIR"
+ AC_SUBST([SAFEC_DIR], "$safecdir")
+ AC_SUBST([SAFEC_CFLAGS], "$safecdir/include")
+ AC_SUBST([SAFEC_LDFLAGS], "$safecdir/lib")
+
+ CFLAGS="$CFLAGS -Wall -I$safecdir/include"
+ LDFLAGS="$LDFLAGS -L$safecdir/lib"
+ LIBS="$LIBS -lsafe_lib"
+])
AC_PREFIX_DEFAULT([/usr/local/est])
cp confdefs.h est_config.h
-AC_CONFIG_FILES([Makefile version safe_c_stub/Makefile safe_c_stub/lib/Makefile src/Makefile src/est/Makefile])
+AC_CONFIG_FILES([Makefile version src/Makefile src/est/Makefile])
AM_COND_IF([ENABLE_JNI],
[AC_CONFIG_FILES([java/jni/Makefile])])
AM_COND_IF([ENABLE_EXAMPLES],
@@ -212,5 +230,8 @@ AM_COND_IF([ENABLE_EXAMPLES],
[],
[AC_CONFIG_FILES([example/server/Makefile example/proxy/Makefile])])
])
+AM_COND_IF([WITH_SYSTEM_LIBSAFEC],
+ [],
+ [AC_CONFIG_FILES([safe_c_stub/Makefile safe_c_stub/lib/Makefile])])
AC_OUTPUT
--
2.17.1