1dnl -*- Autoconf -*-
2
3AC_PREREQ(2.61)
4
5AC_INIT([g-wrap], [1.9.15], [g-wrap-dev at nongnu.org])
6
7AC_CONFIG_AUX_DIR([build-aux])
8AC_CONFIG_MACRO_DIR([m4])
9
10dnl Use `serial-tests' (`parallel-tests' is the default in Automake
11dnl 1.13.)  `serial-tests' was introduced in Automake 1.12.
12AM_INIT_AUTOMAKE([1.12 no-define -Wno-portability serial-tests])
13AM_MAINTAINER_MODE([enable])
14AM_SILENT_RULES([yes])
15
16AC_CONFIG_HEADERS(config.h g-wrap/ffi-support.h)
17
18dnl Branch number, e.g. for pkg-config
19GW_BRANCH=2.0
20AC_SUBST(GW_BRANCH)
21
22AC_SUBST(ACLOCAL_FLAGS,$ACLOCAL_FLAGS)
23
24dnl Shared library versions
25GW_RUNTIME_VINFO(CORE, 2, 0, 0)
26GW_RUNTIME_VINFO(GUILE, 2, 0, 0)
27
28dnl
29dnl Checks for user options
30dnl
31
32AC_ARG_WITH(modules-dir,
33[  --with-modules-dir=<dir>  Base directory for contributed Guile modules ],
34  GUILEMODDIR=$withval,
35  GUILEMODDIR='${prefix}/share/guile/site')
36AC_SUBST(GUILEMODDIR)
37
38dnl
39dnl Checks for programs.
40dnl
41AC_PROG_CC
42gl_EARLY
43AC_PROG_INSTALL
44AC_LIBTOOL_DLOPEN
45AM_PROG_LIBTOOL
46
47dnl Checks for header files.
48
49dnl Checks for typedefs, structures, and compiler characteristics.
50STD_CFLAGS=""
51
52dnl Checks for types
53AC_CHECK_SIZEOF(long)
54AC_C_BIGENDIAN
55
56dnl Checks for standard functions
57gl_INIT
58gl_FUNC_ALLOCA
59gl_FUNC_VASPRINTF
60
61dnl
62dnl Checks for required libraries
63dnl
64
65dnl libffi
66PKG_CHECK_MODULES(LIBFFI, libffi)
67AC_SUBST(LIBFFI_CFLAGS)
68AC_SUBST(LIBFFI_LIBS)
69
70dnl figure out approriate ffi type for size_t
71AC_CHECK_SIZEOF(size_t)
72AC_CHECK_SIZEOF(ssize_t)
73ffi_size_type=uint$(($ac_cv_sizeof_size_t*8))
74ffi_ssize_type=sint$(($ac_cv_sizeof_ssize_t*8))
75AC_DEFINE_UNQUOTED(ffi_type_size_t, ffi_type_${ffi_size_type},
76		   [ffi type for size_t])
77AC_DEFINE_UNQUOTED(ffi_type_ssize_t, ffi_type_${ffi_ssize_type},
78		   [ffi type for ssize_t])
79
80dnl Guile
81GUILE_PKG([2.2 2.0])
82GUILE_PROGS
83GUILE_FLAGS
84GUILE_VERSION="`guile-config info guileversion | sed -r 's,\\.[[0-9]]+$,,'`"
85AC_PATH_PROG(GUILE_VERSIONED, guile-$GUILE_VERSION)
86if test "$GUILE_VERSIONED" != ""; then
87  GUILE="$GUILE_VERSIONED"
88fi
89AC_MSG_NOTICE([Using $GUILE])
90
91dnl Allow --with-imp flag
92GW_LANGUAGES=guile
93
94AC_DEFUN([GW_ALLOW_LANG],
95[AC_ARG_ENABLE([$1],
96               AS_HELP_STRING([--enable-$1], [support $1 (default is $2)]),
97               [if test "$enableval" = yes; then
98                  GW_LANGUAGES="$GW_LANGUAGES $1"
99	        else
100	          GW_LANGUAGES=$(echo "$GW_LANGUAGES" | sed s/[ ]?$1//)
101	        fi])])
102
103GW_ALLOW_LANG(guile, YES)
104GW_ALLOW_LANG(scheme48, NO)
105
106AC_SUBST(GW_LANGUAGES)
107
108dnl Check for optional libraries
109AC_ARG_WITH([glib], AS_HELP_STRING([--without-glib], [Build without glib-2 (default: test)]))
110GLIB=no
111if test "x$with_glib" != "xno"; then
112  PKG_CHECK_MODULES([GLIB], [glib-2.0],
113                    [AC_MSG_NOTICE([building GLib 2.0 support])
114		     GLIB=yes],
115                    [AC_MSG_NOTICE([Not building GLib 2.0 support])])
116fi
117AM_CONDITIONAL(HAVE_GLIB, test "$GLIB" = yes)
118
119dnl Check for compiler flags and warnings. This should be last, since
120dnl it can infere with other checks due to changed CFLAGS.
121if test "$GCC" = yes; then
122  dnl Add the warnings we want
123  CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
124  dnl -Werror ?
125  AC_ARG_ENABLE([Werror], AC_HELP_STRING([--disable-Werror],
126					 [Don't stop the build on warnings]),
127                [], CFLAGS="$CFLAGS -Werror")
128
129  AC_MSG_CHECKING([whether $CC accepts -std=gnu99])
130  save_CFLAGS="$CFLAGS"
131  CFLAGS="-std=gnu99"
132  AC_COMPILE_IFELSE(AC_LANG_PROGRAM(), cc_std_gnu99=yes, cc_std_gnu99=no)
133  if test "$cc_std_gnu99" = yes; then
134    STD_CFLAGS="$STD_CFLAGS -std=gnu99"
135    CFLAGS="$save_CFLAGS -std=gnu99"
136    AC_MSG_RESULT(yes)
137  else
138    CFLAGS="$save_CFLAGS"
139    AC_MSG_RESULT(no)
140  fi
141fi
142
143AC_SUBST(STD_CFLAGS)
144
145AC_CONFIG_FILES([Makefile
146	   lib/Makefile
147           g-wrap/Makefile
148	   test/Makefile
149           guile/Makefile
150	   guile/g-wrap-2.0-guile.pc
151	   guile/g-wrap/Makefile
152	   guile/g-wrap/gw/Makefile
153	   guile/test/Makefile
154	   guile/run-guile
155	   guile/examples/Makefile
156	   scheme48/Makefile
157	   scheme48/g-wrap/Makefile
158	   scheme48/g-wrap/gw/Makefile
159	   scheme48/test/Makefile
160	   doc/Makefile
161	   g-wrap-config
162])
163
164AC_CONFIG_COMMANDS([run-guile-exec], [chmod +x guile/run-guile])
165
166AC_OUTPUT
167