Skip to contentSkip to conversation

package/cryptopp: add a target build configuration

PATCH Superseded Kamel Bouhara 3 participants 5 messages Jul 27, 2020 – Jul 28, 2020

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/cryptopp: add a target build configuration

Currently only a host build is supported for cryptopp, this add a new configuration and build support for the make target.

---
Changes in v2:
- Fixed indentations issue
- Removed unrequired Config.in.host
- Added a depends on !BR2_STATIC_LIBS to build only in dynamic configuration.
- Fixed inconsistency between TARGET_INSTALL and STAGING_INSTALL

---
 package/Config.in                             |  1 +
 ...ied-SONAME-to-shared-object-for-Linu.patch | 27 +++++++++++++++++++
 package/cryptopp/Config.in                    |  8 ++++++
 package/cryptopp/cryptopp.mk                  | 24 +++++++++++++++++
 4 files changed, 60 insertions(+)
 create mode 100644 package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch
 create mode 100644 package/cryptopp/Config.in
package/Config.in +1 -0
index 9c4843be07..014f57a54a 100644
@@ -1279,6 +1279,7 @@ menu "Crypto"
 	source "package/botan/Config.in"
 	source "package/ca-certificates/Config.in"
 	source "package/cryptodev/Config.in"
+	source "package/cryptopp/Config.in"
 	source "package/gcr/Config.in"
 	source "package/gnutls/Config.in"
 	source "package/libargon2/Config.in"
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +27 -0
new file mode 100644
index 0000000000..e7edc76313
@@ -0,0 +1,27 @@
+From 78eb43f50978ffd780cf31b1cea6736dadc6b155 Mon Sep 17 00:00:00 2001
+From: Kamel Bouhara <[email protected]>
+Date: Mon, 6 Jul 2020 17:10:55 +0200
+Subject: [PATCH] Add fully-qualified SONAME to shared object for Linux
+
+From: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
+
+Signed-off-by: Kamel Bouhara <[email protected]>
+---
+ GNUmakefile | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/GNUmakefile b/GNUmakefile
+index e7b7b3a6..730e2a6f 100755
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -1256,6 +1256,7 @@ ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
+ 	$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
+ ifeq ($(HAS_SOLIB_VERSION),1)
+ 	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
++	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
+ 	$(LDCONF) $(DESTDIR)$(LIBDIR)
+ endif
+ endif
+--
+2.26.2
+
package/cryptopp/Config.in new file +8 -0
new file mode 100644
index 0000000000..4ead5339ab
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_CRYPTOPP
+	bool "cryptopp"
+	depends on !BR2_STATIC_LIBS
+	help
+	  A free C++ class library of cryptographic schemes
+
+comment "cryptopp needs a toolchain w/ dynamic library"
+	depends on BR2_STATIC_LIBS
package/cryptopp/cryptopp.mk +24 -0
index f1d19386ab..d83c362b0b 100644
@@ -34,4 +34,28 @@ define HOST_CRYPTOPP_INSTALL_CMDS
 	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=$(HOST_DIR) install-lib
 endef
 
+define CRYPTOPP_EXTRACT_CMDS
+	$(UNZIP) $(CRYPTOPP_DL_DIR)/$(CRYPTOPP_SOURCE) -d $(@D)
+endef
+
+CRYPTOPP_CXXFLAGS = $(TARGET_CFLAGS) -fPIC
+
+CRYPTOPP_MAKE_OPTS = \
+	$(TARGET_CONFIGURE_OPTS) \
+	CXXFLAGS="$(CRYPTOPP_CXXFLAGS)"
+
+define CRYPTOPP_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(CRYPTOPP_MAKE_OPTS) shared
+endef
+
+define CRYPTOPP_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=$(TARGET_DIR) install-lib
+endef
+
+define CRYPTOPP_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=$(STAGING_DIR) libcryptopp.pc
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=$(STAGING_DIR) install-lib
+endef
+
+$(eval $(generic-package))
 $(eval $(host-generic-package))

--
2.27.0

#1 lore raw

PATCH v2 1/1 package/cryptopp: add a target build configuration

Kamel, All,

On 2020-07-27 14:23 +0200, Kamel Bouhara spake thusly:

Quoted 10 lines

Currently only a host build is supported for cryptopp, this add a new configuration and build support for the make target.

---
Changes in v2:
- Fixed indentations issue
- Removed unrequired Config.in.host
- Added a depends on !BR2_STATIC_LIBS to build only in dynamic configuration.

Why can't we build a static library?

[--SNIP--]

Quoted 17 lines
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +11 -0
new file mode 100644
index 0000000000..e7edc76313
@@ -0,0 +1,27 @@
+From 78eb43f50978ffd780cf31b1cea6736dadc6b155 Mon Sep 17 00:00:00 2001
+From: Kamel Bouhara <[email protected]>
+Date: Mon, 6 Jul 2020 17:10:55 +0200
+Subject: [PATCH] Add fully-qualified SONAME to shared object for Linux
+
+From: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
+
+Signed-off-by: Kamel Bouhara <[email protected]>
+---
+ GNUmakefile | 1 +
+ 1 file changed, 1 insertion(+)

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 21

Quoted 10 lines
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +10 -0
+
+diff --git a/GNUmakefile b/GNUmakefile
+index e7b7b3a6..730e2a6f 100755
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -1256,6 +1256,7 @@ ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
+ 	$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
+ ifeq ($(HAS_SOLIB_VERSION),1)
+ 	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
++	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)

Why do we need that?

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 22

Quoted 1 line
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +1 -0
+ 	$(LDCONF) $(DESTDIR)$(LIBDIR)

Note that in corss-compilation, running ldconfig is flawed, and we have explcitly idable its use. See commit 9c4072348 (Makefile: drop ldconfig handling).

As a consequence, you want to explcitly configure with LDCONF=/bin/true, see for example package/e2fsprogs/e2fsprogs.mk (for the target variant) (Nothe that a few other packages do something similar as well)

Which means that with your patch and without a call to ldconfig, the .so symlink will no longer exist, and so it will no longer be possible to link against the library.

Note that the host variant is not OK either, because not all systems have ldconfig on the host either... See 64d4b34073 (e2fsprogs: do not use ldconfig when building the host variant).

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH v2 1/1 package/cryptopp: add a target build configuration

Quoted 11 lines · On Mon, 27 Jul 2020 14:42:32 +0200 "Yann E. MORIN" <[email protected]>…

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 21

Quoted 9 lines
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +9 -0
+diff --git a/GNUmakefile b/GNUmakefile
+index e7b7b3a6..730e2a6f 100755
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -1256,6 +1256,7 @@ ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
+ 	$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
+ ifeq ($(HAS_SOLIB_VERSION),1)
+ 	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
++	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)  

Why do we need that?

Because on the target you need a symlink from the SONAME to the actual library. Right now, the Makefile only:

* Installs the library as libcryptopp.so.8.2.0. It has a SONAME of libcryptopp.so.8.

* Creates a symlink libcryptopp.so -> libcryptopp.so.8.2.0, which allows to link new applications

* Does NOT create the libcryptopp.so.8 -> libcryptopp.so.8.2.0 which would allow using the library at runtime.

Quoted 1 line

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 22

Quoted 1 line
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +1 -0
+ 	$(LDCONF) $(DESTDIR)$(LIBDIR)  

And it is this invocation of ldconfig that creates it!

Quoted 3 lines

Note that in corss-compilation, running ldconfig is flawed, and we have explcitly idable its use. See commit 9c4072348 (Makefile: drop ldconfig handling).

Yes.

Quoted 3 lines

As a consequence, you want to explcitly configure with LDCONF=/bin/true, see for example package/e2fsprogs/e2fsprogs.mk (for the target variant) (Nothe that a few other packages do something similar as well)

Yes.

Quoted 3 lines

Which means that with your patch and without a call to ldconfig, the .so symlink will no longer exist, and so it will no longer be possible to link against the library.

No correct: the .so symlink still exists. Re-read the patch from Kamel, it creates the .so.8 symlink in *addition* to creating the .so symlink, which was already there.

Quoted 3 lines

Note that the host variant is not OK either, because not all systems have ldconfig on the host either... See 64d4b34073 (e2fsprogs: do not use ldconfig when building the host variant).

Yes, agreed.

So all what we need is:

(1) LDCONF=/bin/true
(2) An improved commit description for the patch that adds the symlink

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH v2 1/1 package/cryptopp: add a target build configuration

Thomas, Kamel, Al,

On 2020-07-27 15:03 +0200, Thomas Petazzoni spake thusly:

Quoted 13 lines
Quoted 10 lines · On Mon, 27 Jul 2020 14:42:32 +0200 "Yann E. MORIN" <[email protected]>…

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 21

Quoted 9 lines
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +9 -0
+diff --git a/GNUmakefile b/GNUmakefile
+index e7b7b3a6..730e2a6f 100755
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -1256,6 +1256,7 @@ ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
+ 	$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
+ ifeq ($(HAS_SOLIB_VERSION),1)
+ 	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
++	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)  

Why do we need that?

Quoted 8 lines

Because on the target you need a symlink from the SONAME to the actual library. Right now, the Makefile only:
* Installs the library as libcryptopp.so.8.2.0. It has a SONAME of libcryptopp.so.8.
* Creates a symlink libcryptopp.so -> libcryptopp.so.8.2.0, which allows to link new applications
* Does NOT create the libcryptopp.so.8 -> libcryptopp.so.8.2.0 which would allow using the library at runtime.

Ah, I see.

Quoted 2 lines
Quoted 1 line

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 22

Quoted 1 line
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +1 -0
+ 	$(LDCONF) $(DESTDIR)$(LIBDIR)  

And it is this invocation of ldconfig that creates it!

Yes, I would know that. ;-)

[--SNIP--]

Quoted 6 lines
Quoted 3 lines

Which means that with your patch and without a call to ldconfig, the .so symlink will no longer exist, and so it will no longer be possible to link against the library.

No correct: the .so symlink still exists. Re-read the patch from Kamel, it creates the .so.8 symlink in *addition* to creating the .so symlink, which was already there.

Right. Not sure why, but I saw a 'minus sign' in front of the previous line. There is no such minus sign, so the line is not removed, so yes, that's OK. Sorry.

Quoted 7 lines
Quoted 3 lines

Note that the host variant is not OK either, because not all systems have ldconfig on the host either... See 64d4b34073 (e2fsprogs: do not use ldconfig when building the host variant).

Yes, agreed.
So all what we need is:
(1) LDCONF=/bin/true
(2) An improved commit description for the patch that adds the symlink

(3) same as (1), but for the host variant.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH v2 1/1 package/cryptopp: add a target build configuration

Quoted 2 lines · Yann E. MORIN

Thomas, Kamel, Al,

Hello,

Thanks for you comment, I've just sent a v3 that I hope will fixes issues below.

Regards,
Kamel

Quoted 55 lines

On 2020-07-27 15:03 +0200, Thomas Petazzoni spake thusly:

Quoted 13 lines
Quoted 10 lines · On Mon, 27 Jul 2020 14:42:32 +0200 "Yann E. MORIN" <[email protected]>…

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 21

Quoted 9 lines
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +9 -0
+diff --git a/GNUmakefile b/GNUmakefile
+index e7b7b3a6..730e2a6f 100755
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -1256,6 +1256,7 @@ ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
+ 	$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
+ ifeq ($(HAS_SOLIB_VERSION),1)
+ 	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
++	-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)

Why do we need that?

Quoted 8 lines

Because on the target you need a symlink from the SONAME to the actual library. Right now, the Makefile only:
* Installs the library as libcryptopp.so.8.2.0. It has a SONAME of libcryptopp.so.8.
* Creates a symlink libcryptopp.so -> libcryptopp.so.8.2.0, which allows to link new applications
* Does NOT create the libcryptopp.so.8 -> libcryptopp.so.8.2.0 which would allow using the library at runtime.

Ah, I see.

Quoted 2 lines
Quoted 1 line

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 22

Quoted 1 line
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +1 -0
+ 	$(LDCONF) $(DESTDIR)$(LIBDIR)

And it is this invocation of ldconfig that creates it!

Yes, I would know that. ;-)

[--SNIP--]

Quoted 6 lines
Quoted 3 lines

Which means that with your patch and without a call to ldconfig, the .so symlink will no longer exist, and so it will no longer be possible to link against the library.

No correct: the .so symlink still exists. Re-read the patch from Kamel, it creates the .so.8 symlink in *addition* to creating the .so symlink, which was already there.

Right. Not sure why, but I saw a 'minus sign' in front of the previous line. There is no such minus sign, so the line is not removed, so yes, that's OK. Sorry.

Quoted 7 lines
Quoted 3 lines

Note that the host variant is not OK either, because not all systems have ldconfig on the host either... See 64d4b34073 (e2fsprogs: do not use ldconfig when building the host variant).

Yes, agreed.
So all what we need is:
(1) LDCONF=/bin/true
(2) An improved commit description for the patch that adds the symlink

(3) same as (1), but for the host variant.

Regards,
Yann E. MORIN.

Quoted 7 lines

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

--
Kamel Bouhara, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com