372c14bc071b4c3ce214752e41efb1b8e48894e1
[sod] / sod.m4
1 dnl -*-autoconf-*-
2 dnl
3 dnl Autoconf machinery for packages using Sod
4 dnl
5 dnl (c) 2019 Straylight/Edgeware
6 dnl
7
8 dnl ----- Licensing notice --------------------------------------------------
9 dnl
10 dnl This file is part of the Sensible Object Design, an object system for C.
11 dnl
12 dnl SOD is free software: you can redistribute it and/or modify it under
13 dnl the terms of the GNU General Public License as published by the Free
14 dnl Software Foundation; either version 2 of the License, or (at your
15 dnl option) any later version.
16 dnl
17 dnl SOD is distributed in the hope that it will be useful, but WITHOUT ANY
18 dnl WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 dnl for more details.
21 dnl
22 dnl You should have received a copy of the GNU General Public License
23 dnl along with SOD. If not, write to the Free Software Foundation, Inc.,
24 dnl 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 #serial 1
27
28 ### SOD_CHECK([ACTION-IF-LIBRARY-FOUND], [ACTION-IF-LIBRARY-NOT-FOUND])
29 ###
30 ### Check that (a) the sod(1) translator and (b) the `libsod' library are
31 ### available.
32 ###
33 ### If sod(1) can't be found, this isn't a problem: we assume that the
34 ### generated output files are included in the distribution, and use a fake
35 ### definition which will report an error if the files need rebuilding, as a
36 ### poor person's version of the `missing' script.
37 ###
38 ### If the library can't be found, we have a more serious problem. The
39 ### default behaviour is to (let `PKG_CHECK_MODULES') report a fatal error,
40 ### but packages can override this behaviour by setting ACTION-IF-LIBRARY-
41 ### NOT-FOUND to something non-empty. If the library /is/ found then do
42 ### ACTION-IF-LIBRARY-FOUND; the default is to add the necessary compiler
43 ### flags to `AM_CFLAGS'. (You are expected to make your own arrangements to
44 ### link against `$SOD_LIBS'.)
45 AC_DEFUN([SOD_CHECK],
46 [AC_CHECK_PROGS([SOD], [sod], [none])
47 if test "$SOD" = "none"; then
48 AC_MSG_WARN([Sod translator not found: relying on distributed output files!])
49 SOD="echo >&2 \"Sod translator not found! Can't rebuild \\\`\$[]@'.\" && exit 2; \\#"
50 fi
51 PKG_CHECK_MODULES([SOD], [sod],
52 [AM_CFLAGS="$AM_CFLAGS $SOD_CFLAGS"
53 $1],
54 [$2])])
55
56 dnl ----- That's all, folks -------------------------------------------------