1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-21 12:10:26 +02:00

update examples in manual to use PKG_CHECK_MODULES

* doc/ref/autoconf.texi (Using Autoconf Macros): Switch example to use
  PKG_CHECK_MODULES.
* doc/ref/libguile-linking.texi (A Sample Guile Main Program): Likewise,
  and change from configure.in to configure.ac, and recommend
  autoreconf.
This commit is contained in:
Andy Wingo 2011-02-20 22:08:27 +01:00
parent 097a793b22
commit 0e8a11c49a
2 changed files with 33 additions and 28 deletions

View file

@ -1,6 +1,6 @@
@c -*-texinfo-*- @c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual. @c This is part of the GNU Guile Reference Manual.
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009 @c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 2011
@c Free Software Foundation, Inc. @c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions. @c See the file guile.texi for copying conditions.
@ -97,25 +97,25 @@ to instantiate macros at top-level.
We now include two examples, one simple and one complicated. We now include two examples, one simple and one complicated.
The first example is for a package that uses libguile, and thus needs to know The first example is for a package that uses libguile, and thus needs to
how to compile and link against it. So we use @code{GUILE_FLAGS} to set the know how to compile and link against it. So we use
vars @code{GUILE_CFLAGS} and @code{GUILE_LDFLAGS}, which are automatically @code{PKG_CHECK_MODULES} to set the vars @code{GUILE_CFLAGS} and
substituted in the Makefile. @code{GUILE_LIBS}, which are automatically substituted in the Makefile.
@example @example
In configure.ac: In configure.ac:
GUILE_FLAGS PKG_CHECK_MODULES([GUILE], [guile-@value{EFFECTIVE-VERSION}])
In Makefile.in: In Makefile.in:
GUILE_CFLAGS = @@GUILE_CFLAGS@@ GUILE_CFLAGS = @@GUILE_CFLAGS@@
GUILE_LDFLAGS = @@GUILE_LDFLAGS@@ GUILE_LIBS = @@GUILE_LIBS@@
myprog.o: myprog.c myprog.o: myprog.c
$(CC) -o $@ $(GUILE_CFLAGS) $< $(CC) -o $@ $(GUILE_CFLAGS) $<
myprog: myprog.o myprog: myprog.o
$(CC) -o $@ $< $(GUILE_LDFLAGS) $(CC) -o $@ $< $(GUILE_LIBS)
@end example @end example
The second example is for a package of Guile Scheme modules that uses an The second example is for a package of Guile Scheme modules that uses an

View file

@ -128,13 +128,11 @@ simple-guile.o: simple-guile.c
If you are using the GNU Autoconf package to make your application more If you are using the GNU Autoconf package to make your application more
portable, Autoconf will settle many of the details in the Makefile above portable, Autoconf will settle many of the details in the Makefile above
automatically, making it much simpler and more portable; we recommend automatically, making it much simpler and more portable; we recommend
using Autoconf with Guile. Guile also provides the @code{GUILE_FLAGS} using Autoconf with Guile. Here is a @file{configure.ac} file for
macro for autoconf that performs all necessary checks. Here is a @code{simple-guile} that uses the standard @code{PKG_CHECK_MODULES}
@file{configure.in} file for @code{simple-guile} that uses this macro. macro to check for Guile. Autoconf will process this file into a
Autoconf can use this file as a template to generate a @code{configure} @code{configure} script. We recommend invoking Autoconf via the
script. In order for Autoconf to find the @code{GUILE_FLAGS} macro, you @code{autoreconf} utility.
will need to run @code{aclocal} first (@pxref{Invoking aclocal,,,
automake, GNU Automake}).
@example @example
AC_INIT(simple-guile.c) AC_INIT(simple-guile.c)
@ -143,19 +141,21 @@ AC_INIT(simple-guile.c)
AC_PROG_CC AC_PROG_CC
# Check for Guile # Check for Guile
GUILE_FLAGS PKG_CHECK_MODULES([GUILE], [guile-@value{EFFECTIVE-VERSION}])
# Generate a Makefile, based on the results. # Generate a Makefile, based on the results.
AC_OUTPUT(Makefile) AC_OUTPUT(Makefile)
@end example @end example
Run @code{autoreconf -vif} to generate @code{configure}.
Here is a @code{Makefile.in} template, from which the @code{configure} Here is a @code{Makefile.in} template, from which the @code{configure}
script produces a Makefile customized for the host system: script produces a Makefile customized for the host system:
@example @example
# The configure script fills in these values. # The configure script fills in these values.
CC=@@CC@@ CC=@@CC@@
CFLAGS=@@GUILE_CFLAGS@@ CFLAGS=@@GUILE_CFLAGS@@
LIBS=@@GUILE_LDFLAGS@@ LIBS=@@GUILE_LIBS@@
simple-guile: simple-guile.o simple-guile: simple-guile.o
$@{CC@} simple-guile.o $@{LIBS@} -o simple-guile $@{CC@} simple-guile.o $@{LIBS@} -o simple-guile
@ -164,23 +164,28 @@ simple-guile.o: simple-guile.c
@end example @end example
The developer should use Autoconf to generate the @file{configure} The developer should use Autoconf to generate the @file{configure}
script from the @file{configure.in} template, and distribute script from the @file{configure.ac} template, and distribute
@file{configure} with the application. Here's how a user might go about @file{configure} with the application. Here's how a user might go about
building the application: building the application:
@example @example
$ ls $ ls
Makefile.in configure* configure.in simple-guile.c Makefile.in configure* configure.ac simple-guile.c
$ ./configure $ ./configure
creating cache ./config.cache checking for gcc... ccache gcc
checking for gcc... (cached) gcc checking whether the C compiler works... yes
checking whether the C compiler (gcc ) works... yes checking for C compiler default output file name... a.out
checking whether the C compiler (gcc ) is a cross-compiler... no checking for suffix of executables...
checking whether we are using GNU C... (cached) yes checking whether we are cross compiling... no
checking whether gcc accepts -g... (cached) yes checking for suffix of object files... o
checking for Guile... yes checking whether we are using the GNU C compiler... yes
creating ./config.status checking whether ccache gcc accepts -g... yes
creating Makefile checking for ccache gcc option to accept ISO C89... none needed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GUILE... yes
configure: creating ./config.status
config.status: creating Makefile
$ make $ make
[...] [...]
$ ./simple-guile $ ./simple-guile