Pierre Lindenbaum
2017-12-15 08:40:37 UTC
(Cross-posted https://stackoverflow.com/questions/47819563/how-to-configure-ac-with-optional-gnu-guile-library-with-guile )
Hi all,
I'm looking for a simple example of configure.ac for an optional support of libguile
I'm a complete beginner with configure.ac, I'm trying to create a simple program that would only use the GNU guile library if the user invokes:
```
configure --with-guile
```
so the C program would be something like:
```
#include "config.h"
#include <stdio.h>
#ifdef HAVE_GUILE
#include <libguile.h>
#endif
int main(int argc,char** argv) {
#ifdef HAVE_GUILE
printf("Guile supported\n");
scm_init_guile();
#else
printf("Guile not supported\n");
#endif
return 0;
}
``````
GNU guile uses guile-config compile and guile-config link to obtain the path to the include directory and the libraries.
I've not found a tutorial where the paths above are obtained via an external program.
So far my `configure.ac` is
```
AC_INIT(program, 1.0)
AC_PROG_CC
AC_CONFIG_HEADERS(config.h)
with_guile=no
AC_ARG_WITH(guile, [AS_HELP_STRING([--with-guile], [use gnu guile])],[],[with_guile=yes])
if test "x$with_guile" != no
then
AC_MSG_CHECKING(for Guile)
guile-config link > /dev/null || {
echo "configure: cannot find guile-config; is Guile installed?" 1>&2
exit 1
}
CFLAGS="$CFLAGS `guile-config compile`"
LDFLAGS="$LDFLAGS `guile-config link`"
AC_DEFINE([HAVE_GUILE],[1],[Guile supported])
#PKG_CHECK_MODULES([GUILE],[guile-2.0])
#AC_CHECK_HEADERS([libguile.h], [], [AC_MSG_ERROR([guile include files not found])])
#AC_CHECK_LIB([guile], [scm_with_guile], [AC_MSG_ERROR([guile library files not found])])
fi
dnl Process Makefile.in to create Makefile
AC_OUTPUT(Makefile)
```
I've removed AC_CHECK_HEADERS and AC_CHECK_LIB because they doesn't work (the files are not found).
Here I'm lost: how can I add the guile paths to CFLAGS and LDFLAGS, how can I generate HAVE_GUILE in config.h
current Makefile.in:
```
CC=@CC@
LD=@CC@
program: program.o
$(LD) -o $@ $^
.PHONY: clean
clean:
rm -f program *.o
```
Thanks in advance for your help,
P.
Hi all,
I'm looking for a simple example of configure.ac for an optional support of libguile
I'm a complete beginner with configure.ac, I'm trying to create a simple program that would only use the GNU guile library if the user invokes:
```
configure --with-guile
```
so the C program would be something like:
```
#include "config.h"
#include <stdio.h>
#ifdef HAVE_GUILE
#include <libguile.h>
#endif
int main(int argc,char** argv) {
#ifdef HAVE_GUILE
printf("Guile supported\n");
scm_init_guile();
#else
printf("Guile not supported\n");
#endif
return 0;
}
``````
GNU guile uses guile-config compile and guile-config link to obtain the path to the include directory and the libraries.
I've not found a tutorial where the paths above are obtained via an external program.
So far my `configure.ac` is
```
AC_INIT(program, 1.0)
AC_PROG_CC
AC_CONFIG_HEADERS(config.h)
with_guile=no
AC_ARG_WITH(guile, [AS_HELP_STRING([--with-guile], [use gnu guile])],[],[with_guile=yes])
if test "x$with_guile" != no
then
AC_MSG_CHECKING(for Guile)
guile-config link > /dev/null || {
echo "configure: cannot find guile-config; is Guile installed?" 1>&2
exit 1
}
CFLAGS="$CFLAGS `guile-config compile`"
LDFLAGS="$LDFLAGS `guile-config link`"
AC_DEFINE([HAVE_GUILE],[1],[Guile supported])
#PKG_CHECK_MODULES([GUILE],[guile-2.0])
#AC_CHECK_HEADERS([libguile.h], [], [AC_MSG_ERROR([guile include files not found])])
#AC_CHECK_LIB([guile], [scm_with_guile], [AC_MSG_ERROR([guile library files not found])])
fi
dnl Process Makefile.in to create Makefile
AC_OUTPUT(Makefile)
```
I've removed AC_CHECK_HEADERS and AC_CHECK_LIB because they doesn't work (the files are not found).
Here I'm lost: how can I add the guile paths to CFLAGS and LDFLAGS, how can I generate HAVE_GUILE in config.h
current Makefile.in:
```
CC=@CC@
LD=@CC@
program: program.o
$(LD) -o $@ $^
.PHONY: clean
clean:
rm -f program *.o
```
Thanks in advance for your help,
P.