Commit | Line | Data |
---|---|---|
d0001215 TTN |
1 | dnl Autoconf macros for working with Guile. |
2 | dnl | |
3 | dnl Copyright (C) 1998,2001 Free Software Foundation, Inc. | |
4 | dnl | |
2b9fe19f JB |
5 | dnl This program is free software; you can redistribute it and/or modify |
6 | dnl it under the terms of the GNU General Public License as published by | |
7 | dnl the Free Software Foundation; either version 2, or (at your option) | |
8 | dnl any later version. | |
d0001215 | 9 | dnl |
2b9fe19f JB |
10 | dnl This program is distributed in the hope that it will be useful, |
11 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | dnl GNU General Public License for more details. | |
d0001215 | 14 | dnl |
2b9fe19f JB |
15 | dnl You should have received a copy of the GNU General Public License |
16 | dnl along with this software; see the file COPYING. If not, write to | |
17 | dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
18 | dnl Boston, MA 02111-1307 USA | |
d0001215 | 19 | dnl |
2b9fe19f JB |
20 | dnl As a special exception, the Free Software Foundation gives permission |
21 | dnl for additional uses of the text contained in its release of GUILE. | |
d0001215 | 22 | dnl |
2b9fe19f JB |
23 | dnl The exception is that, if you link the GUILE library with other files |
24 | dnl to produce an executable, this does not by itself cause the | |
25 | dnl resulting executable to be covered by the GNU General Public License. | |
26 | dnl Your use of that executable is in no way restricted on account of | |
27 | dnl linking the GUILE library code into it. | |
d0001215 | 28 | dnl |
2b9fe19f JB |
29 | dnl This exception does not however invalidate any other reasons why |
30 | dnl the executable file might be covered by the GNU General Public License. | |
d0001215 | 31 | dnl |
2b9fe19f JB |
32 | dnl This exception applies only to the code released by the |
33 | dnl Free Software Foundation under the name GUILE. If you copy | |
34 | dnl code from other Free Software Foundation releases into a copy of | |
35 | dnl GUILE, as the General Public License permits, the exception does | |
36 | dnl not apply to the code that you add in this way. To avoid misleading | |
37 | dnl anyone as to the status of such modified files, you must delete | |
38 | dnl this exception notice from them. | |
d0001215 | 39 | dnl |
2b9fe19f JB |
40 | dnl If you write modifications of your own for GUILE, it is your choice |
41 | dnl whether to permit this exception to apply to your modifications. | |
42 | dnl If you do not wish that, delete this exception notice. | |
43 | ||
44 | ||
d0001215 TTN |
45 | dnl INDEX |
46 | dnl ----- | |
47 | ||
48 | dnl GUILE_FLAGS --- set flags for compiling and linking with Guile | |
49 | dnl AC_GUILE_MODULE_CHECK --- check feature of a Guile Scheme module | |
50 | dnl AC_GUILE_MODULE_AVAILABLE --- check availability of a Guile Scheme module | |
51 | dnl AC_GUILE_MODULE_REQUIRED --- fail if a Guile Scheme module is unavailable | |
52 | ||
53 | ||
54 | dnl Code | |
55 | dnl ---- | |
56 | ||
2b9fe19f | 57 | dnl GUILE_FLAGS --- set flags for compiling and linking with Guile |
d0001215 | 58 | dnl |
2b9fe19f JB |
59 | dnl This macro runs the `guile-config' script, installed with Guile, |
60 | dnl to find out where Guile's header files and libraries are | |
61 | dnl installed. It sets two variables, marked for substitution, as | |
62 | dnl by AC_SUBST. | |
63 | dnl | |
64 | dnl GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build | |
65 | dnl code that uses Guile header files. This is almost | |
66 | dnl always just a -I flag. | |
67 | dnl | |
68 | dnl GUILE_LDFLAGS --- flags to pass to the linker to link a | |
69 | dnl program against Guile. This includes `-lguile' for | |
70 | dnl the Guile library itself, any libraries that Guile | |
71 | dnl itself requires (like -lqthreads), and so on. It may | |
72 | dnl also include a -L flag to tell the compiler where to | |
73 | dnl find the libraries. | |
74 | ||
75 | AC_DEFUN([GUILE_FLAGS],[ | |
76 | ## The GUILE_FLAGS macro. | |
77 | ## First, let's just see if we can find Guile at all. | |
78 | AC_MSG_CHECKING(for Guile) | |
79 | guile-config link > /dev/null || { | |
80 | echo "configure: cannot find guile-config; is Guile installed?" 1>&2 | |
81 | exit 1 | |
82 | } | |
83 | GUILE_CFLAGS="`guile-config compile`" | |
84 | GUILE_LDFLAGS="`guile-config link`" | |
85 | AC_SUBST(GUILE_CFLAGS) | |
86 | AC_SUBST(GUILE_LDFLAGS) | |
87 | AC_MSG_RESULT(yes) | |
88 | ]) | |
d0001215 TTN |
89 | |
90 | ||
91 | dnl AC_GUILE_MODULE_CHECK --- check feature of a Guile Scheme module | |
92 | dnl | |
93 | dnl AC_GUILE_MODULE_CHECK(var,module,featuretest,description) | |
94 | dnl $1 is a shell variable name to be set to "yes" or "no" | |
95 | dnl $2 is a list of symbols, like: (ice-9 common-list) | |
96 | dnl $3 is a thunk, like: (lambda () BODY ...) | |
97 | dnl which returns either 0 or #t to indicate the check passed. | |
98 | dnl avoid using the character "#" since that confuses autoconf. | |
99 | dnl $4 is a noun phrase passed to AC_MSG_CHECKING | |
100 | ||
101 | AC_DEFUN([AC_GUILE_MODULE_CHECK], | |
102 | [AC_MSG_CHECKING([$2 $4]) | |
103 | $1=no | |
104 | echo '(use-modules $2) (exit ($3))' > conftest | |
105 | guile -s conftest > /dev/null 2>&1 && $1=yes | |
106 | rm -f conftest | |
107 | AC_MSG_RESULT($[$1]) | |
108 | ]) | |
109 | ||
110 | dnl AC_GUILE_MODULE_AVAILABLE --- check availability of a Guile Scheme module | |
111 | dnl | |
112 | dnl AC_GUILE_MODULE_AVAILABLE(var,module) | |
113 | dnl $1 is a shell variable name to be set to "yes" or "no" | |
114 | dnl $2 is a list of symbols, like: (ice-9 common-list) | |
115 | ||
116 | AC_DEFUN([AC_GUILE_MODULE_AVAILABLE], | |
117 | [AC_GUILE_MODULE_CHECK($1,$2,(lambda () 0),availability) | |
118 | ]) | |
119 | ||
120 | dnl AC_GUILE_MODULE_REQUIRED --- fail if a Guile Scheme module is unavailable | |
121 | dnl | |
122 | dnl $1 is a list of symbols, WITHOUT the surrounding parens | |
123 | ||
124 | AC_DEFUN([AC_GUILE_MODULE_REQUIRED], | |
125 | [AC_GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1)) | |
126 | if test "$ac_guile_module_required" = "no" ; then | |
127 | AC_MSG_ERROR([required guile module not found: ($1)]) | |
128 | fi | |
129 | ]) | |
130 | ||
131 | ||
132 | dnl guile.m4 ends here |