From: Pierre Lindenbaum <pierre.lindenbaum@univ-nantes.fr>
To: guile-user@gnu.org
Subject: how to write a 'configure.ac' for an* optional* support of libguile.
Date: Fri, 15 Dec 2017 09:40:37 +0100 [thread overview]
Message-ID: <a4687d53-22e8-89f8-d06a-c4db86048a0c@univ-nantes.fr> (raw)
(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.
next reply other threads:[~2017-12-15 8:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 8:40 Pierre Lindenbaum [this message]
2017-12-15 22:51 ` how to write a 'configure.ac' for an* optional* support of libguile Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a4687d53-22e8-89f8-d06a-c4db86048a0c@univ-nantes.fr \
--to=pierre.lindenbaum@univ-nantes.fr \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).