From 0fafa094cfea42277f4e9447b77503191b6ad26f Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 20 Aug 2019 19:35:08 +0100 Subject: [PATCH 1/1] sod.m4: Provide an Autoconf snippet for dependent packages. --- Makefile.am | 6 +++++ debian/libsod-dev.install | 1 + sod.m4 | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 sod.m4 diff --git a/Makefile.am b/Makefile.am index 84f652c..a41b175 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,6 +39,12 @@ sod.pc: sod.pc.in Makefile $(SUBST) $(srcdir)/sod.pc.in >$@.new $(SUBSTITUTIONS) && mv $@.new $@ ###-------------------------------------------------------------------------- +### Autoconf machinery. + +aclocaldir = $(datadir)/aclocal +dist_aclocal_DATA = sod.m4 + +###-------------------------------------------------------------------------- ### Subdirectories to build ## The SOD translator. diff --git a/debian/libsod-dev.install b/debian/libsod-dev.install index 01d14b0..159fd2e 100644 --- a/debian/libsod-dev.install +++ b/debian/libsod-dev.install @@ -3,6 +3,7 @@ /usr/lib/*/libsod.la /usr/lib/*/libsod.so /usr/lib/*/pkgconfig +/usr/share/aclocal /usr/share/man/man3/keyword.3 /usr/share/man/man3/sod.3 /usr/share/man/man3/sod-structs.3 diff --git a/sod.m4 b/sod.m4 new file mode 100644 index 0000000..372c14b --- /dev/null +++ b/sod.m4 @@ -0,0 +1,56 @@ +dnl -*-autoconf-*- +dnl +dnl Autoconf machinery for packages using Sod +dnl +dnl (c) 2019 Straylight/Edgeware +dnl + +dnl ----- Licensing notice -------------------------------------------------- +dnl +dnl This file is part of the Sensible Object Design, an object system for C. +dnl +dnl SOD is free software: you can redistribute it and/or modify it under +dnl the terms of the GNU General Public License as published by the Free +dnl Software Foundation; either version 2 of the License, or (at your +dnl option) any later version. +dnl +dnl SOD is distributed in the hope that it will be useful, but WITHOUT ANY +dnl WARRANTY; without even the implied warranty of MERCHANTABILITY or +dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with SOD. If not, write to the Free Software Foundation, Inc., +dnl 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#serial 1 + +### SOD_CHECK([ACTION-IF-LIBRARY-FOUND], [ACTION-IF-LIBRARY-NOT-FOUND]) +### +### Check that (a) the sod(1) translator and (b) the `libsod' library are +### available. +### +### If sod(1) can't be found, this isn't a problem: we assume that the +### generated output files are included in the distribution, and use a fake +### definition which will report an error if the files need rebuilding, as a +### poor person's version of the `missing' script. +### +### If the library can't be found, we have a more serious problem. The +### default behaviour is to (let `PKG_CHECK_MODULES') report a fatal error, +### but packages can override this behaviour by setting ACTION-IF-LIBRARY- +### NOT-FOUND to something non-empty. If the library /is/ found then do +### ACTION-IF-LIBRARY-FOUND; the default is to add the necessary compiler +### flags to `AM_CFLAGS'. (You are expected to make your own arrangements to +### link against `$SOD_LIBS'.) +AC_DEFUN([SOD_CHECK], + [AC_CHECK_PROGS([SOD], [sod], [none]) + if test "$SOD" = "none"; then + AC_MSG_WARN([Sod translator not found: relying on distributed output files!]) + SOD="echo >&2 \"Sod translator not found! Can't rebuild \\\`\$[]@'.\" && exit 2; \\#" + fi + PKG_CHECK_MODULES([SOD], [sod], + [AM_CFLAGS="$AM_CFLAGS $SOD_CFLAGS" + $1], + [$2])]) + +dnl ----- That's all, folks ------------------------------------------------- -- 2.11.0