summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2023-05-03 12:29:00 +0200
committerRichard Levitte <levitte@openssl.org>2023-11-15 08:22:29 +0100
commit2ac569a67b9d0980efa2d8061a6a61e0645f37a7 (patch)
treed10a44241363b75c52cdc14c839ae6ee8ff77503
parentfe487609c17dac049f867f230e09ee090b65e966 (diff)
Clean up exporters, specifically those we have for pkg-config
The pkg-config exporters were a special hack, all in Configurations/unix-Makefile.tmpl, and this was well and good as long as that was the only main package interface configuration system that we cared about. Things have changed, though, so we move the pkg-config production to be templatable in a more flexible manner. Additional templates for other interface configuration systems can then be added fairly easily. Two variants of the .pc files are produced: - Those in 'exporters/' are installed in the location that 'pkg-config' itself prefers for installed packages. - Those in the top directory are to be used when it's desirable to build directly against an OpenSSL build tree. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20878)
-rw-r--r--.gitignore7
-rw-r--r--Configurations/unix-Makefile.tmpl90
-rw-r--r--build.info17
-rw-r--r--exporters/build.info16
-rw-r--r--exporters/pkg-config/libcrypto.pc.in11
-rw-r--r--exporters/pkg-config/libssl.pc.in9
-rw-r--r--exporters/pkg-config/openssl.pc.in7
-rw-r--r--util/mkinstallvars.pl63
8 files changed, 150 insertions, 70 deletions
diff --git a/.gitignore b/.gitignore
index 68522d40e7..97551e937b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,13 +6,18 @@
/Makefile
/MINFO
/TABLE
-/*.pc
/rehash.time
/inc.*
/makefile.*
/out.*
/tmp.*
/configdata.pm
+/builddata.pm
+/installdata.pm
+
+# Exporters
+/*.pc
+/exporters/*.pc
# Links under apps
/apps/CA.pl
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index 8ddb1282af..18c32d0bae 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -199,6 +199,12 @@ INSTALL_PROGRAMS={-
grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
@{$unified_info{programs}}))
-}
+INSTALL_EXPORTERS_PKGCONFIG={-
+ join(" \\\n" . ' ' x 28,
+ fill_lines(" ", $COLUMNS - 28,
+ grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'pkg-config'}
+ sort keys %{$unified_info{generate}}))
+-}
BIN_SCRIPTS={-
join(" \\\n" . ' ' x 12,
fill_lines(" ", $COLUMNS - 12,
@@ -320,6 +326,8 @@ BINDIR={- our $bindir = $config{bindir};
bindir={- file_name_is_absolute($bindir)
? $bindir : '$(INSTALLTOP)/$(BINDIR)' -}
+PKGCONFIGDIR=$(libdir)/pkgconfig
+
MANDIR=$(INSTALLTOP)/share/man
DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
HTMLDIR=$(DOCDIR)/html
@@ -521,7 +529,7 @@ build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) ## Create manpag
build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) ## Create HTML documentation
build_generated: $(GENERATED_MANDATORY)
-build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
+build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
build_modules_nodep: $(MODULES)
build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
@@ -606,7 +614,6 @@ clean: libclean ## Clean the workspace, keep the configuration
$(RM) tags TAGS doc-nits md-nits
$(RM) -r test/test-runs
$(RM) providers/fips*.new
- $(RM) openssl.pc libcrypto.pc libssl.pc
-find . -type l \! -name '.*' -exec $(RM) {} \;
distclean: clean ## Clean and remove the configuration
@@ -776,16 +783,13 @@ install_dev: install_runtime_libs
: {- output_off() if sharedaix(); output_on(); "" -}; \
done
@ : {- output_on() if $disabled{shared}; "" -}
- @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)/pkgconfig"
- @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
- @cp libcrypto.pc "$(DESTDIR)$(libdir)/pkgconfig"
- @chmod 644 "$(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
- @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
- @cp libssl.pc "$(DESTDIR)$(libdir)/pkgconfig"
- @chmod 644 "$(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
- @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
- @cp openssl.pc "$(DESTDIR)$(libdir)/pkgconfig"
- @chmod 644 "$(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
+ @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(PKGCONFIGDIR)"
+ @for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \
+ fn=`basename $$e`; \
+ $(ECHO) "install $$e -> $(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
+ cp $$e "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
+ chmod 644 "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
+ done
uninstall_dev: uninstall_runtime_libs
@$(ECHO) "*** Uninstalling development files"
@@ -829,10 +833,11 @@ uninstall_dev: uninstall_runtime_libs
: {- output_on() unless windowsdll(); "" -}; \
done
@ : {- output_on() if $disabled{shared}; "" -}
- $(RM) "$(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
- $(RM) "$(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
- $(RM) "$(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
- -$(RMDIR) "$(DESTDIR)$(libdir)/pkgconfig"
+ @for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \
+ fn=`basename "$$e"`; \
+ $(RM) "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
+ done
+ -$(RMDIR) "$(DESTDIR)$(PKGCONFIGDIR)"
-$(RMDIR) "$(DESTDIR)$(libdir)"
_install_modules_deps: install_runtime_libs build_modules
@@ -1435,59 +1440,6 @@ FORCE:
# Building targets ###################################################
-libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
-
-libcrypto.pc:
- @ ( echo 'prefix=$(INSTALLTOP)'; \
- echo 'exec_prefix=$${prefix}'; \
- if [ -n "$(LIBDIR)" ]; then \
- echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
- else \
- echo 'libdir=$(libdir)'; \
- fi; \
- echo 'includedir=$${prefix}/include'; \
- echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
- echo 'modulesdir=$${libdir}/ossl-modules'; \
- echo ''; \
- echo 'Name: OpenSSL-libcrypto'; \
- echo 'Description: OpenSSL cryptography library'; \
- echo 'Version: '$(VERSION); \
- echo 'Libs: -L$${libdir} -lcrypto'; \
- echo 'Libs.private: $(LIB_EX_LIBS)'; \
- echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
-
-libssl.pc:
- @ ( echo 'prefix=$(INSTALLTOP)'; \
- echo 'exec_prefix=$${prefix}'; \
- if [ -n "$(LIBDIR)" ]; then \
- echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
- else \
- echo 'libdir=$(libdir)'; \
- fi; \
- echo 'includedir=$${prefix}/include'; \
- echo ''; \
- echo 'Name: OpenSSL-libssl'; \
- echo 'Description: Secure Sockets Layer and cryptography libraries'; \
- echo 'Version: '$(VERSION); \
- echo 'Requires.private: libcrypto'; \
- echo 'Libs: -L$${libdir} -lssl'; \
- echo 'Cflags: -I$${includedir}' ) > libssl.pc
-
-openssl.pc:
- @ ( echo 'prefix=$(INSTALLTOP)'; \
- echo 'exec_prefix=$${prefix}'; \
- if [ -n "$(LIBDIR)" ]; then \
- echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
- else \
- echo 'libdir=$(libdir)'; \
- fi; \
- echo 'includedir=$${prefix}/include'; \
- echo ''; \
- echo 'Name: OpenSSL'; \
- echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
- echo 'Version: '$(VERSION); \
- echo 'Requires: libssl libcrypto' ) > openssl.pc
-
Makefile: configdata.pm \
{- join(" \\\n" . ' ' x 10,
fill_lines(" ", $COLUMNS - 10,
diff --git a/build.info b/build.info
index d9e3c904b2..7149c8cd3a 100644
--- a/build.info
+++ b/build.info
@@ -8,6 +8,7 @@ ENDIF
IF[{- !$disabled{'deprecated-3.0'} -}]
SUBDIRS=engines
ENDIF
+SUBDIRS=exporters
LIBS=libcrypto libssl
INCLUDE[libcrypto]=. include
@@ -99,3 +100,19 @@ IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-|BC-)/ -}]
SHARED_SOURCE[libcrypto]=libcrypto.rc
SHARED_SOURCE[libssl]=libssl.rc
ENDIF
+
+# This file sets the build directory up for pkg-config
+GENERATE[libcrypto.pc]=exporters/pkg-config/libcrypto.pc.in
+DEPEND[libcrypto.pc]=builddata.pm
+GENERATE[libssl.pc]=exporters/pkg-config/libssl.pc.in
+DEPEND[libssl.pc]=builddata.pm
+GENERATE[openssl.pc]=exporters/pkg-config/openssl.pc.in
+DEPEND[openssl.pc]=builddata.pm
+DEPEND[openssl.pc]=libcrypto.pc libssl.pc
+
+GENERATE[builddata.pm]=util/mkinstallvars.pl \
+ PREFIX=. BINDIR=apps LIBDIR= INCLUDEDIR=include APPLINKDIR=ms \
+ ENGINESDIR=engines MODULESDIR=providers \
+ "VERSION=$(VERSION)" "LDLIBS=$(LIB_EX_LIBS)"
+
+DEPEND[""]=openssl.pc
diff --git a/exporters/build.info b/exporters/build.info
new file mode 100644
index 0000000000..503e15e8e8
--- /dev/null
+++ b/exporters/build.info
@@ -0,0 +1,16 @@
+# For installation: libcrypto.pc, libssl.pc, and openssl.pc
+GENERATE[libcrypto.pc]{exporter=pkg-config}=pkg-config/libcrypto.pc.in
+DEPEND[libcrypto.pc]=../installdata.pm
+GENERATE[libssl.pc]{exporter=pkg-config}=pkg-config/libssl.pc.in
+DEPEND[libssl.pc]=../installdata.pm
+GENERATE[openssl.pc]{exporter=pkg-config}=pkg-config/openssl.pc.in
+DEPEND[openssl.pc]=../installdata.pm
+DEPEND[openssl.pc]=libcrypto.pc libssl.pc
+
+DEPEND[""]=openssl.pc
+
+GENERATE[../installdata.pm]=../util/mkinstallvars.pl \
+ "PREFIX=$(INSTALLTOP)" BINDIR=bin "LIBDIR=$(LIBDIR)" \
+ INCLUDEDIR=include APPLINKDIR=include/openssl \
+ "ENGINESDIR=$(ENGINESDIR)" "MODULESDIR=$(MODULESDIR)" \
+ "VERSION=$(VERSION)" "LDLIBS=$(LIB_EX_LIBS)"
diff --git a/exporters/pkg-config/libcrypto.pc.in b/exporters/pkg-config/libcrypto.pc.in
new file mode 100644
index 0000000000..14ed339f3c
--- /dev/null
+++ b/exporters/pkg-config/libcrypto.pc.in
@@ -0,0 +1,11 @@
+libdir={- $OpenSSL::safe::installdata::LIBDIR -}
+includedir={- $OpenSSL::safe::installdata::INCLUDEDIR -}
+enginesdir={- $OpenSSL::safe::installdata::ENGINESDIR -}
+modulesdir={- $OpenSSL::safe::installdata::MODULESDIR -}
+
+Name: OpenSSL-libcrypto
+Description: OpenSSL cryptography library
+Version: {- $OpenSSL::safe::installdata::VERSION -}
+Libs: -L${libdir} -lcrypto
+Libs.private: {- join(' ', @OpenSSL::safe::installdata::LDLIBS) -}
+Cflags: -I${includedir}
diff --git a/exporters/pkg-config/libssl.pc.in b/exporters/pkg-config/libssl.pc.in
new file mode 100644
index 0000000000..a7828b3cc6
--- /dev/null
+++ b/exporters/pkg-config/libssl.pc.in
@@ -0,0 +1,9 @@
+libdir={- $OpenSSL::safe::installdata::LIBDIR -}
+includedir={- $OpenSSL::safe::installdata::INCLUDEDIR -}
+
+Name: OpenSSL-libssl
+Description: Secure Sockets Layer and cryptography libraries
+Version: {- $OpenSSL::safe::installdata::VERSION -}
+Requires.private: libcrypto
+Libs: -L${libdir} -lssl
+Cflags: -I${includedir}
diff --git a/exporters/pkg-config/openssl.pc.in b/exporters/pkg-config/openssl.pc.in
new file mode 100644
index 0000000000..dbb77aa39a
--- /dev/null
+++ b/exporters/pkg-config/openssl.pc.in
@@ -0,0 +1,7 @@
+libdir={- $OpenSSL::safe::installdata::LIBDIR -}
+includedir={- $OpenSSL::safe::installdata::INCLUDEDIR -}
+
+Name: OpenSSL
+Description: Secure Sockets Layer and cryptography libraries and tools
+Version: {- $OpenSSL::safe::installdata::VERSION -}
+Requires: libssl libcrypto
diff --git a/util/mkinstallvars.pl b/util/mkinstallvars.pl
new file mode 100644
index 0000000000..d0688cfd0b
--- /dev/null
+++ b/util/mkinstallvars.pl
@@ -0,0 +1,63 @@
+#! /usr/bin/env perl
+# Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the Apache License 2.0 (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+# All variables are supposed to come from Makefile, in environment variable
+# form, or passed as variable assignments on the command line.
+# The result is a Perl module creating the package OpenSSL::safe::installdata.
+
+use File::Spec;
+
+# These are expected to be set up as absolute directories
+my @absolutes = qw(PREFIX);
+# These may be absolute directories, and if not, they are expected to be set up
+# as subdirectories to PREFIX
+my @subdirs = qw(BINDIR LIBDIR INCLUDEDIR ENGINESDIR MODULESDIR APPLINKDIR);
+
+my %keys = ();
+foreach (@ARGV) {
+ (my $k, my $v) = m|^([^=]*)=(.*)$|;
+ $keys{$k} = 1;
+ $ENV{$k} = $v;
+}
+foreach my $k (sort keys %keys) {
+ my $v = $ENV{$k};
+ $v = File::Spec->rel2abs($v) if $v && grep { $k eq $_ } @absolutes;
+ $ENV{$k} = $v;
+}
+foreach my $k (sort keys %keys) {
+ my $v = $ENV{$k} || '.';
+ $v = File::Spec->rel2abs($v, $ENV{PREFIX})
+ if ($v && !File::Spec->file_name_is_absolute($v)
+ && grep { $k eq $_ } @subdirs);
+ $ENV{$k} = $v;
+}
+
+print <<_____;
+package OpenSSL::safe::installdata;
+
+use strict;
+use warnings;
+use Exporter;
+our \@ISA = qw(Exporter);
+our \@EXPORT = qw(\$PREFIX \$BINDIR \$LIBDIR \$INCLUDEDIR \$APPLINKDIR
+ \$ENGINESDIR \$MODULESDIR \$VERSION \$LDLIBS);
+
+our \$PREFIX = '$ENV{PREFIX}';
+our \$BINDIR = '$ENV{BINDIR}';
+our \$LIBDIR = '$ENV{LIBDIR}';
+our \$INCLUDEDIR = '$ENV{INCLUDEDIR}';
+our \$ENGINESDIR = '$ENV{ENGINESDIR}';
+our \$MODULESDIR = '$ENV{MODULESDIR}';
+our \$APPLINKDIR = '$ENV{APPLINKDIR}';
+our \$VERSION = '$ENV{VERSION}';
+our \@LDLIBS =
+ # Unix and Windows use space separation, VMS uses comma separation
+ split(/ +| *, */, '$ENV{LDLIBS}');
+
+1;
+_____