*** empty log message ***
[bpt/guile.git] / doc / ref / autoconf.texi
CommitLineData
d928d47f
TTN
1@page
2@node Autoconf Support
3@chapter Autoconf Support
4
5When Guile is installed, a set of autoconf macros is also installed as
6PREFIX/share/aclocal/guile.m4. This chapter documents the macros provided in
7that file. @xref{Top,The GNU Autoconf Manual,,autoconf}, for more info.
8
9@menu
10* Autoconf Background:: Why use autoconf?
11* Autoconf Macros:: The GUILE_* macros.
12* Using Autoconf Macros:: How to use them, plus examples.
13@end menu
14
15
16@node Autoconf Background
17@section Autoconf Background
18
19As explained elsewhere (@pxref{Top,The GNU Autoconf Manual,,autoconf}), any
20package needs configuration at build-time. If your package uses Guile (or
21uses a package that in turn uses Guile), you probably need to know what
22specific Guile features are available and details about them.
23
24The way to do this is to write feature tests and arrange for their execution
25by the @file{configure} script, typically by adding the tests to
26@file{configure.ac}, and running @code{autoconf} to create @file{configure}.
27Users of your package then run @file{configure} in the normal way.
28
29Macros are a way to make common feature tests easy to express. Autoconf
30provides a wide range macros (@pxref{Existing Tests,,,autoconf}), and Guile
31installation provides Guile-specific tests in the areas of: program detection,
32compilation flags reporting, and Scheme module checks.
33
34
35@node Autoconf Macros
36@section Autoconf Macros
37
38The macro names all begin with "GUILE_".
39
40@c see Makefile.am
41@include autoconf-macros.texi
42
43
44@node Using Autoconf Macros
45@section Using Autoconf Macros
46
47Using the autoconf macros is straightforward: Add the macro "calls" (actually
48instantiations) to @file{configure.ac}, run @code{aclocal}, and finally,
49run @code{autoconf}. If your system doesn't have guile.m4 installed, place
50the desired macro definitions (@code{AC_DEFUN} forms) in @file{acinclude.m4},
51and @code{aclocal} will do the right thing.
52
53Some of the macros can be used inside normal shell constructs: @code{if foo ;
54then GUILE_BAZ ; fi}, but this is not guaranteed. It's probably a good idea
55to instantiate macros at top-level.
56
57We now include two examples, one simple and one complicated.
58
59The first example is for a package that uses libguile, and thus needs to know
60how to compile and link against it. So we use @code{GUILE_FLAGS} to set the
61vars @code{GUILE_CFLAGS} and @code{GUILE_LDFLAGS}, which are automatically
62substituted in the Makefile.
63
64@example
65In configure.ac:
66
67 GUILE_FLAGS
68
69In Makefile.in:
70
71 GUILE_CFLAGS = @@GUILE_CFLAGS@@
72 GUILE_LDFLAGS = @@GUILE_LDFLAGS@@
73
74 myprog.o: myprog.c
75 $(CC) -o $@ $(GUILE_CFLAGS) $<
76 myprog: myprog.o
77 $(CC) -o $@ $< $(GUILE_LDFLAGS)
78@end example
79
80The second example is for a package of Guile Scheme modules that uses an
81external program and other Guile Scheme modules (some might call this a "pure
82scheme" package). So we use the @code{GUILE_SITE_DIR} macro, a regular
83@code{AC_PATH_PROG} macro, and the @code{GUILE_MODULE_AVAILABLE} macro.
84
85@example
86In configure.ac:
87
88 GUILE_SITE_DIR
89
90 probably_wont_work=""
91
92 # pgtype pgtable
93 GUILE_MODULE_AVAILABLE(have_guile_pg, (database postgres))
94 test $have_guile_pg = no &&
95 probably_wont_work="(my pgtype) (my pgtable) $probably_wont_work"
96
97 # gpgutils
98 AC_PATH_PROG(GNUPG,gpg)
99 test x"$GNUPG" = x &&
100 probably_wont_work="(my gpgutils) $probably_wont_work"
101
102 if test ! "$probably_wont_work" = "" ; then
103 p=" ***"
104 echo
105 echo "$p"
106 echo "$p NOTE:"
107 echo "$p The following modules probably won't work:"
108 echo "$p $probably_wont_work"
109 echo "$p They can be installed anyway, and will work if their"
110 echo "$p dependencies are installed later. Please see README."
111 echo "$p"
112 echo
113 fi
114
115In Makefile.in:
116
117 instdir = @@GUILE_SITE@@/my
118
119 install:
120 $(INSTALL) my/*.scm $(instdir)
121@end example
122
123@c autoconf.texi ends here