/[guile]/guile/guile-core/guile-config/guile.m4
ViewVC logotype

Diff of /guile/guile-core/guile-config/guile.m4

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by ttn, Fri Dec 28 10:18:39 2001 UTC revision 1.3 by ttn, Sat Dec 29 03:55:52 2001 UTC
# Line 1  Line 1 
1  dnl   Autoconf macros for working with Guile.  ## Autoconf macros for working with Guile.
2  dnl  ##
3  dnl     Copyright (C) 1998,2001 Free Software Foundation, Inc.  ##   Copyright (C) 1998,2001 Free Software Foundation, Inc.
4  dnl  ##
5  dnl   This program is free software; you can redistribute it and/or modify  ## 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  ## 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)  ## the Free Software Foundation; either version 2, or (at your option)
8  dnl   any later version.  ## any later version.
9  dnl  ##
10  dnl   This program is distributed in the hope that it will be useful,  ## This program is distributed in the hope that it will be useful,
11  dnl   but WITHOUT ANY WARRANTY; without even the implied warranty of  ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12  dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  dnl   GNU General Public License for more details.  ## GNU General Public License for more details.
14  dnl  ##
15  dnl   You should have received a copy of the GNU General Public License  ## 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  ## along with this software; see the file COPYING.  If not, write to
17  dnl   the Free Software Foundation, Inc., 59 Temple Place, Suite 330,  ## the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  dnl   Boston, MA 02111-1307 USA  ## Boston, MA 02111-1307 USA
19  dnl  ##
20  dnl   As a special exception, the Free Software Foundation gives permission  ## As a special exception, the Free Software Foundation gives permission
21  dnl   for additional uses of the text contained in its release of GUILE.  ## for additional uses of the text contained in its release of GUILE.
22  dnl  ##
23  dnl   The exception is that, if you link the GUILE library with other files  ## 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  ## to produce an executable, this does not by itself cause the
25  dnl   resulting executable to be covered by the GNU General Public License.  ## 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  ## Your use of that executable is in no way restricted on account of
27  dnl   linking the GUILE library code into it.  ## linking the GUILE library code into it.
28  dnl  ##
29  dnl   This exception does not however invalidate any other reasons why  ## This exception does not however invalidate any other reasons why
30  dnl   the executable file might be covered by the GNU General Public License.  ## the executable file might be covered by the GNU General Public License.
31  dnl  ##
32  dnl   This exception applies only to the code released by the  ## This exception applies only to the code released by the
33  dnl   Free Software Foundation under the name GUILE.  If you copy  ## Free Software Foundation under the name GUILE.  If you copy
34  dnl   code from other Free Software Foundation releases into a copy of  ## code from other Free Software Foundation releases into a copy of
35  dnl   GUILE, as the General Public License permits, the exception does  ## 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  ## 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  ## anyone as to the status of such modified files, you must delete
38  dnl   this exception notice from them.  ## this exception notice from them.
39  dnl  ##
40  dnl   If you write modifications of your own for GUILE, it is your choice  ## 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.  ## whether to permit this exception to apply to your modifications.
42  dnl   If you do not wish that, delete this exception notice.  ## If you do not wish that, delete this exception notice.
43    
44    ## Index
45  dnl   INDEX  ## -----
46  dnl   -----  ##
47    ## GUILE_PROGS -- set paths to Guile interpreter, config and tool programs
48  dnl   GUILE_FLAGS --- set flags for compiling and linking with Guile  ## GUILE_FLAGS -- set flags for compiling and linking with Guile
49  dnl   AC_GUILE_MODULE_CHECK --- check feature of a Guile Scheme module  ## GUILE_SITE_DIR -- find path to Guile "site" directory
50  dnl   AC_GUILE_MODULE_AVAILABLE --- check availability of a Guile Scheme module  ## GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
51  dnl   AC_GUILE_MODULE_REQUIRED --- fail if a Guile Scheme module is unavailable  ## GUILE_MODULE_CHECK -- check feature of a Guile Scheme module
52    ## GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module
53    ## GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable
54  dnl   Code  ## GUILE_MODULE_EXPORTS -- check if a module exports a variable
55  dnl   ----  ## GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable
56    
57  dnl   GUILE_FLAGS --- set flags for compiling and linking with Guile  ## Code
58  dnl  ## ----
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  # GUILE_PROGS -- set paths to Guile interpreter, config and tool programs
61  dnl   installed.  It sets two variables, marked for substitution, as  #
62  dnl   by AC_SUBST.  # Usage: GUILE_PROGS
63  dnl  #
64  dnl     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build  # This macro looks for programs `guile', `guile-config' and `guile-tools',
65  dnl             code that uses Guile header files.  This is almost  # and sets variables GUILE, GUILE_CONFIG and GUILE_TOOLS, to their paths,
66  dnl             always just a -I flag.  # respectively.  If either of the first two are not found, signal error.
67  dnl  #
68  dnl     GUILE_LDFLAGS --- flags to pass to the linker to link a  # The variables are marked for substitution, as by AC_SUBST.
69  dnl             program against Guile.  This includes `-lguile' for  #
70  dnl             the Guile library itself, any libraries that Guile  AC_DEFUN([GUILE_PROGS],
71  dnl             itself requires (like -lqthreads), and so on.  It may   [AC_PATH_PROG(GUILE,guile)
72  dnl             also include a -L flag to tell the compiler where to    if test "$GUILE" = "" ; then
73  dnl             find the libraries.        AC_MSG_ERROR([guile required but not found])
74      fi
75      AC_SUBST(GUILE)
76      AC_PATH_PROG(GUILE_CONFIG,guile-config)
77      if test "$GUILE_CONFIG" = "" ; then
78          AC_MSG_ERROR([guile-config required but not found])
79      fi
80      AC_SUBST(GUILE_CONFIG)
81      AC_PATH_PROG(GUILE_TOOLS,guile-tools)
82      AC_SUBST(GUILE_TOOLS)
83     ])
84    
85    # GUILE_FLAGS -- set flags for compiling and linking with Guile
86    #
87    # Usage: GUILE_FLAGS
88    #
89    # This macro runs the `guile-config' script, installed with Guile,
90    # to find out where Guile's header files and libraries are
91    # installed.  It sets two variables, GUILE_CFLAGS and GUILE_LDFLAGS.
92    #
93    # GUILE_CFLAGS: flags to pass to a C or C++ compiler to build code that
94    # uses Guile header files.  This is almost always just a -I flag.
95    #
96    # GUILE_LDFLAGS: flags to pass to the linker to link a program against
97    # Guile.  This includes `-lguile' for the Guile library itself, any
98    # libraries that Guile itself requires (like -lqthreads), and so on.  It
99    # may also include a -L flag to tell the compiler where to find the
100    # libraries.
101    #
102    # The variables are marked for substitution, as by AC_SUBST.
103    #
104  AC_DEFUN([GUILE_FLAGS],[  AC_DEFUN([GUILE_FLAGS],[
105  ## The GUILE_FLAGS macro.  ## The GUILE_FLAGS macro.
106    ## First, let's just see if we can find Guile at all.    ## First, let's just see if we can find Guile at all.
# Line 87  AC_DEFUN([GUILE_FLAGS],[ Line 116  AC_DEFUN([GUILE_FLAGS],[
116    AC_MSG_RESULT(yes)    AC_MSG_RESULT(yes)
117  ])  ])
118    
119    # GUILE_SITE_DIR -- find path to Guile "site" directory
120  dnl   AC_GUILE_MODULE_CHECK --- check feature of a Guile Scheme module  #
121  dnl  # Usage: GUILE_SITE_DIR
122  dnl   AC_GUILE_MODULE_CHECK(var,module,featuretest,description)  #
123  dnl   $1 is a shell variable name to be set to "yes" or "no"  # This looks for Guile's "site" directory, usually something like
124  dnl   $2 is a list of symbols, like: (ice-9 common-list)  # PREFIX/share/guile/site, and sets var GUILE_SITE to the path.
125  dnl   $3 is a thunk, like: (lambda () BODY ...)  # Note that the var name is different from the macro name.
126  dnl      which returns either 0 or #t to indicate the check passed.  #
127  dnl      avoid using the character "#" since that confuses autoconf.  # The variable is marked for substitution, as by AC_SUBST.
128  dnl   $4 is a noun phrase passed to AC_MSG_CHECKING  #
129    AC_DEFUN([GUILE_SITE_DIR],
130  AC_DEFUN([AC_GUILE_MODULE_CHECK],   [AC_REQUIRE([GUILE_PROGS])dnl
131           [AC_MSG_CHECKING([$2 $4])    AC_MSG_CHECKING(for Guile site directory)
132            $1=no    GUILE_SITE=`[$GUILE_CONFIG] info pkgdatadir`/site
133            echo '(use-modules $2) (exit ($3))' > conftest    AC_MSG_RESULT($GUILE_SITE)
134            guile -s conftest > /dev/null 2>&1 && $1=yes    AC_SUBST(GUILE_SITE)
135            rm -f conftest   ])
136            AC_MSG_RESULT($[$1])  
137    # GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
138    #
139    # Usage: GUILE_CHECK_RETVAL(var,check)
140    #
141    # $1 is a shell variable name to be set to the return value
142    # $2 is a Guile Scheme expression, evaluated with "$GUILE -c", and
143    #    returning either 0 or non-#f to indicate the check passed.
144    #    Non-0 number or #f indicates failure.
145    #    Avoid using the character "#" since that confuses autoconf.
146    #
147    AC_DEFUN([GUILE_CHECK],
148     [AC_REQUIRE([GUILE_PROGS])
149      $GUILE -c "$2" > /dev/null 2>&1
150      $1=$?
151     ])
152    
153    # GUILE_MODULE_CHECK -- check feature of a Guile Scheme module
154    #
155    # Usage: GUILE_MODULE_CHECK(var,module,featuretest,description)
156    #
157    # $1 is a shell variable name to be set to "yes" or "no"
158    # $2 is a list of symbols, like: (ice-9 common-list)
159    # $3 is an expression acceptable to GUILE_CHECK, q.v.
160    # $4 is a present-tense verb phrase (passed to AC_MSG_CHECKING)
161    #
162    AC_DEFUN([GUILE_MODULE_CHECK],
163             [AC_MSG_CHECKING([if $2 $4])
164              GUILE_CHECK($1,(use-modules $2) (exit ((lambda () $3))))
165              if test "$$1" = "0" ; then $1=yes ; else $1=no ; fi
166              AC_MSG_RESULT($$1)
167           ])           ])
168    
169  dnl   AC_GUILE_MODULE_AVAILABLE --- check availability of a Guile Scheme module  # GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module
170  dnl  #
171  dnl   AC_GUILE_MODULE_AVAILABLE(var,module)  # Usage: GUILE_MODULE_AVAILABLE(var,module)
172  dnl   $1 is a shell variable name to be set to "yes" or "no"  #
173  dnl   $2 is a list of symbols, like: (ice-9 common-list)  # $1 is a shell variable name to be set to "yes" or "no"
174    # $2 is a list of symbols, like: (ice-9 common-list)
175  AC_DEFUN([AC_GUILE_MODULE_AVAILABLE],  #
176           [AC_GUILE_MODULE_CHECK($1,$2,(lambda () 0),availability)  AC_DEFUN([GUILE_MODULE_AVAILABLE],
177             [GUILE_MODULE_CHECK($1,$2,0,is available)
178           ])           ])
179    
180  dnl   AC_GUILE_MODULE_REQUIRED --- fail if a Guile Scheme module is unavailable  # GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable
181  dnl  #
182  dnl   $1 is a list of symbols, WITHOUT the surrounding parens  # Usage: GUILE_MODULE_REQUIRED(symlist)
183    #
184  AC_DEFUN([AC_GUILE_MODULE_REQUIRED],  # $1 is a list of symbols, WITHOUT surrounding parens, like: ice-9 common-list
185           [AC_GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1))  #
186    AC_DEFUN([GUILE_MODULE_REQUIRED],
187             [GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1))
188            if test "$ac_guile_module_required" = "no" ; then            if test "$ac_guile_module_required" = "no" ; then
189                AC_MSG_ERROR([required guile module not found: ($1)])                AC_MSG_ERROR([required guile module not found: ($1)])
190            fi            fi
191           ])           ])
192    
193    # GUILE_MODULE_EXPORTS -- check if a module exports a variable
194    #
195    # Usage: GUILE_MODULE_EXPORTS(var,module,modvar)
196    #
197    # $1 is a shell variable to be set to "yes" or "no"
198    # $2 is a list of symbols, like: (ice-9 common-list)
199    # $3 is the Guile Scheme variable to check
200    #
201    AC_DEFUN([GUILE_MODULE_EXPORTS],
202     [GUILE_MODULE_CHECK($1,$2,$3,exports `$3')
203     ])
204    
205    # GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable
206    #
207    # Usage: GUILE_MODULE_REQUIRED_EXPORT(module,modvar)
208    #
209    # $1 is a list of symbols, like: (ice-9 common-list)
210    # $2 is the Guile Scheme variable to check
211    #
212    AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT],
213     [GUILE_MODULE_EXPORTS(guile_module_required_export,$1,$2)
214      if test "$guile_module_required_export" = "no" ; then
215          AC_MSG_ERROR([module $1 does not export $2; required])
216      fi
217     ])
218    
219  dnl   guile.m4 ends here  ## guile.m4 ends here

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26