* how to write a 'configure.ac' for an* optional* support of libguile.
@ 2017-12-15 8:40 Pierre Lindenbaum
2017-12-15 22:51 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Pierre Lindenbaum @ 2017-12-15 8:40 UTC (permalink / raw)
To: guile-user
(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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: how to write a 'configure.ac' for an* optional* support of libguile.
2017-12-15 8:40 how to write a 'configure.ac' for an* optional* support of libguile Pierre Lindenbaum
@ 2017-12-15 22:51 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2017-12-15 22:51 UTC (permalink / raw)
To: guile-user
Hello,
Pierre Lindenbaum <pierre.lindenbaum@univ-nantes.fr> skribis:
> 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])])
‘guile-config’ is deprecated. ‘PKG_CHECK_MODULES’ works, but the
recommended approach is to use the ‘GUILE_PKG’ Autoconf macro, as in:
dnl Try Guile 2.2, then 2.0.
dnl https://www.gnu.org/software/guile/manual/html_node/Autoconf-Macros.html
GUILE_PKG([2.2 2.0])
When you do that you can omit ‘AC_CHECK_HEADERS’ and ‘AC_CHECK_LIB’.
For more details I’d suggest looking at existing code such as
guile-ncurses, GnuTLS, etc.
HTH!
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-12-15 22:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-15 8:40 how to write a 'configure.ac' for an* optional* support of libguile Pierre Lindenbaum
2017-12-15 22:51 ` Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).