build,cpp: Support building C++ bindings as nested package of gpgme

* Makefile.am: Add variables languages, dist_languages,
distcheck_languages, release_languages, sign_release_languages,
distclean_languages. Add rules for nested language bindings.
(distclean-local, dist-all, distcheck-all, release-all,
sign-release-all): New rules.
(.PHONY): Add all new rules.
* autogen-all.sh: New.
* configure.ac: Add cpp to available languages if subdir exists. Add
cpp to nested languages if enabled to generate corresponding make
targets. Call configure script of nested cpp package recursively.
* lang/cpp/configure.ac: Check if gpgmepp is built as nested package
and set GPGME_CFLAGS and GPGME_LIBS accordingly.
--

This re-adds the ability to build the C++ bindings together with gpgme
with a single `configure && make` command (if building from git). It
also adds make targets for running dist, distcheck, release and
sign-release for gpgme and all enabled nested languages with a single
make command.

GnuPG-bug-id: 7110
This commit is contained in:
Ingo Klöcker 2024-06-04 14:34:46 +02:00
parent f87e23c512
commit 6334960bbe
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
4 changed files with 164 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# Makefile.am - Top level Makefile for GPGME.
# Copyright (C) 2000 Werner Koch (dd9jn)
# Copyright (C) 2001, 2002, 2004, 2005, 2008, 2009 g10 Code GmbH
# Copyright (C) 2001, 2002, 2004, 2005, 2008, 2009, 2024 g10 Code GmbH
#
# This file is part of GPGME.
#
@ -70,8 +70,6 @@ distcheck-hook:
esac;\
done ) | tee $(distdir).swdb
.PHONY: gen-ChangeLog release sign-release
gen_start_date = 2011-12-01T00:00:00
gen-ChangeLog:
if test -d $(top_srcdir)/.git; then \
@ -142,3 +140,58 @@ sign-release:
echo ' * All done; for checksums see dist/swdb.snippet' ;\
echo ' */' ;\
)
languages = $(NESTED_LANGUAGES)
dist_languages = $(languages:%=dist-%)
$(dist_languages):
+(set -e;\
lang=$$(echo "$@" | sed 's/.*-//');\
cd "lang/$$lang";\
$(MAKE) dist;\
)
distcheck_languages = $(languages:%=distcheck-%)
$(distcheck_languages):
+(set -e;\
lang=$$(echo "$@" | sed 's/.*-//');\
cd "lang/$$lang";\
$(MAKE) distcheck;\
)
release_languages = $(languages:%=release-%)
$(release_languages):
+(set -e;\
lang=$$(echo "$@" | sed 's/.*-//');\
cd "lang/$$lang";\
$(MAKE) release;\
)
sign_release_languages = $(languages:%=sign-release-%)
$(sign_release_languages):
+(set -e;\
lang=$$(echo "$@" | sed 's/.*-//');\
cd "lang/$$lang";\
$(MAKE) sign-release;\
)
distclean_languages = $(languages:%=distclean-%)
$(distclean_languages):
+(set -e;\
lang=$$(echo "$@" | sed 's/.*-//');\
cd "lang/$$lang";\
$(MAKE) distclean;\
)
distclean-local: $(distclean_languages)
dist-all: dist $(dist_languages)
distcheck-all: distcheck $(distcheck_languages)
release-all: release $(release_languages)
sign-release-all: sign-release $(sign_release_languages)
.PHONY: gen-ChangeLog release sign-release dist-all $(dist_languages) \
distcheck-all $(distcheck_languages) release-all $release_languages) \
sign-release-all $(sign_release_languages) $(distclean_languages)

67
autogen-all.sh Executable file
View File

@ -0,0 +1,67 @@
#! /bin/sh
# autogen-all.sh
# Copyright (C) 2024 g10 Code GmbH
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# This script is a helper to run the autogen.sh script for gpgme and the
# nested packages of the C++, Qt, and Python bindings.
prog=$(basename "$0")
packages=". lang/cpp"
fatal () {
echo "${prog}:" "$*" >&2
DIE=yes
}
info () {
if [ -z "${SILENT}" ]; then
echo "${prog}:" "$*" >&2
fi
}
die_p () {
if [ "$DIE" = "yes" ]; then
echo "autogen.sh: Stop." >&2
exit 1
fi
}
DIE=no
SILENT=
tmp=$(dirname "$0")
tsdir=$(cd "${tmp}"; pwd)
am_lf='
'
if test x"$1" = x"--help"; then
tmp="$(pwd)"
cd "$tsdir" || fatal "error cd-ing to $tsdir"
die_p
./autogen.sh --help | sed "s/autogen.sh/${prog}/" || fatal "error running ./autogen.sh --help"
die_p
exit 0
fi
if test x"$1" = x"--silent"; then
SILENT=" --silent"
fi
for p in $packages; do
info Running ./autogen.sh "$@" in $p ...
curdir="$(pwd)"
cd "$tsdir/$p" || fatal "error cd-ing to $tsdir/$p"
die_p
./autogen.sh "$@" | sed "s/autogen.sh/${prog}/" || fatal "error running ./autogen.sh $@"
die_p
cd "$curdir" || fatal "error cd-ing back to $curdir"
die_p
done

View File

@ -238,6 +238,11 @@ have_macos_system=no
build_w32_glib=no
available_languages="cl"
default_languages="cl"
for lang in cpp; do
if test -d $srcdir/lang/$lang; then
available_languages="$available_languages $lang"
fi
done
case "${host}" in
x86_64-*mingw32*)
have_w64_system=yes
@ -323,8 +328,7 @@ fi
# lang/Makefile.am's DIST_SUBDIRS.
AC_ARG_ENABLE([languages],
AS_HELP_STRING([--enable-languages=languages],
[enable only specific language bindings:
cl]),
[enable only specific language bindings]),
[enabled_languages=`echo $enableval | \
tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
[enabled_languages="maybe"])
@ -351,6 +355,14 @@ done
AC_SUBST(ENABLED_LANGUAGES, $enabled_languages)
nested_languages=
LIST_MEMBER("cpp", $enabled_languages)
if test "$found" = "1"; then
nested_languages="$nested_languages cpp"
fi
AC_SUBST(NESTED_LANGUAGES, $nested_languages)
#
# Provide information about the build.
#
@ -825,6 +837,13 @@ AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
AC_CONFIG_FILES([lang/js/Makefile lang/js/src/Makefile
lang/js/BrowserTestExtension/Makefile
lang/js/DemoExtension/Makefile])
# Call ./configure scripts of nested packages recursively.
LIST_MEMBER("cpp", $enabled_languages)
if test "$found" = "1"; then
AC_CONFIG_SUBDIRS([lang/cpp])
fi
AC_OUTPUT
echo "

View File

@ -354,8 +354,26 @@ AM_CONDITIONAL(USE_GPGRT_CONFIG, [test -n "$GPGRT_CONFIG" \
# And for gpgme.
have_gpgme=no
AM_PATH_GPGME("$NEED_GPGME_VERSION",
builddir=`pwd`
# Check if gpgmepp is built as nested package of gpgme
if test "${srcdir%/lang/cpp}/lang/cpp" == "$srcdir" -a \
"${builddir%/lang/cpp}/lang/cpp" == "$builddir"; then
AC_MSG_CHECKING(for GpgME - assuming nested build)
gpgme_build_dir=${builddir%/lang/cpp}
if test -f "$gpgme_build_dir/src/gpgme.h"; then
GPGME_CFLAGS="-I$gpgme_build_dir/src"
GPGME_LIBS="$gpgme_build_dir/src/libgpgme.la"
have_gpgme=yes
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
if test "$have_gpgme" = "no"; then
AM_PATH_GPGME("$NEED_GPGME_VERSION",
have_gpgme=yes, have_gpgme=no)
fi
# Substitution used for gpgmepp.pc