1AC_INIT
2AC_CONFIG_SRCDIR([src/gts.h])
3
4dnl we to AC_DIVERT_PUSH/AC_DIVERT_POP these variable definitions so they
5dnl are available for $ac_help expansion (don't we all *love* autoconf?)
6#AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
7# Making releases:
8#   GTS_MICRO_VERSION += 1;
9#   GTS_INTERFACE_AGE += 1;
10#   GTS_BINARY_AGE += 1;
11# if any functions have been added, set GTS_INTERFACE_AGE to 0.
12# if backwards compatibility has been broken,
13# set GTS_BINARY_AGE and GTS_INTERFACE_AGE to 0.
14#
15GTS_MAJOR_VERSION=0
16GTS_MINOR_VERSION=7
17GTS_MICRO_VERSION=4
18GTS_INTERFACE_AGE=0
19GTS_BINARY_AGE=0
20GTS_VERSION=$GTS_MAJOR_VERSION.$GTS_MINOR_VERSION.$GTS_MICRO_VERSION
21dnl
22#AC_DIVERT_POP()dnl
23
24AC_SUBST(GTS_MAJOR_VERSION)
25AC_SUBST(GTS_MINOR_VERSION)
26AC_SUBST(GTS_MICRO_VERSION)
27AC_SUBST(GTS_VERSION)
28
29# libtool versioning
30LT_RELEASE=$GTS_MAJOR_VERSION.$GTS_MINOR_VERSION
31LT_CURRENT=`expr $GTS_MICRO_VERSION - $GTS_INTERFACE_AGE`
32LT_REVISION=$GTS_INTERFACE_AGE
33LT_AGE=`expr $GTS_BINARY_AGE - $GTS_INTERFACE_AGE`
34AC_SUBST(LT_RELEASE)
35AC_SUBST(LT_CURRENT)
36AC_SUBST(LT_REVISION)
37AC_SUBST(LT_AGE)
38
39# For automake.
40VERSION=$GTS_VERSION
41PACKAGE=gts
42
43AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
44
45# Specify a configuration file
46AM_CONFIG_HEADER(config.h)
47
48AC_DEFINE_UNQUOTED(GTS_MAJOR_VERSION, $GTS_MAJOR_VERSION, [Major version])
49AC_DEFINE_UNQUOTED(GTS_MINOR_VERSION, $GTS_MINOR_VERSION, [Minor version])
50AC_DEFINE_UNQUOTED(GTS_MICRO_VERSION, $GTS_MICRO_VERSION, [Micro version])
51AC_DEFINE_UNQUOTED(GTS_INTERFACE_AGE, $GTS_INTERFACE_AGE, [Interface age])
52AC_DEFINE_UNQUOTED(GTS_BINARY_AGE, $GTS_BINARY_AGE, [Binary age])
53
54dnl Initialize libtool
55AM_PROG_LIBTOOL
56
57dnl Initialize maintainer mode
58AM_MAINTAINER_MODE
59
60AC_PROG_CC
61
62if test x$GCC = xyes ; then
63  CFLAGS="$CFLAGS -Wall -Werror-implicit-function-declaration -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations"
64fi
65
66AC_PROG_AWK
67AC_ISC_POSIX
68AC_HEADER_STDC
69
70AC_CHECK_LIB(netpbm, pgm_init, netpbm="true",
71  AC_MSG_WARN([libnetpbm not found. Some programs will not be available.]))
72AM_CONDITIONAL(HAS_NETPBM, test x$netpbm = xtrue)
73
74AM_PATH_GLIB_2_0(2.4.0, has_glib2=yes, has_glib2=no, gthread gmodule)
75if test x$has_glib2 = xyes; then
76  glib_cflags=`$PKG_CONFIG glib-2.0 --cflags`
77  glib_thread_cflags=`$PKG_CONFIG glib-2.0 --cflags gthread-2.0`
78  glib_module_cflags=`$PKG_CONFIG glib-2.0 --cflags gmodule-2.0`
79  glib_libs=`$PKG_CONFIG glib-2.0 --libs`
80  glib_thread_libs=`$PKG_CONFIG glib-2.0 --libs gthread-2.0`
81  glib_module_libs=`$PKG_CONFIG glib-2.0 --libs gmodule-2.0`
82  GLIB_LIBS="$glib_libs"
83  GLIB_DEPLIBS="$glib_libs"
84else
85  if test x$with_glib = xyes ; then
86    AC_MSG_ERROR([
87*** Directory must be specified for --with-glib])
88  fi
89
90  if test x$with_glib = x ; then
91    # Look for separately installed glib
92
93    GLIB_REQUIRED_VERSION=1.2.8
94    AM_PATH_GLIB($GLIB_REQUIRED_VERSION,,
95      AC_MSG_ERROR([
96*** GLIB $GLIB_REQUIRED_VERSION or better is required. The latest version of GLIB
97*** is always available from ftp://ftp.gtk.org/.]),
98      gmodule gthread)
99
100    glib_cflags=`$GLIB_CONFIG --cflags`
101    glib_thread_cflags=`$GLIB_CONFIG --cflags gthread`
102    glib_module_cflags=`$GLIB_CONFIG --cflags gmodule`
103    glib_libs=`$GLIB_CONFIG --libs`
104    glib_thread_libs=`$GLIB_CONFIG --libs gthread`
105    glib_module_libs=`$GLIB_CONFIG --libs gmodule`
106    GLIB_LIBS="$glib_libs"
107    GLIB_DEPLIBS="$glib_libs"
108  else
109    # Use uninstalled glib (assume they got the version right)
110
111    GLIB_CONFIG=$with_glib/glib-config
112    if test -x $GLIB_CONFIG ; then
113      :
114    else
115      AC_MSG_ERROR([GLIB directory ($with_glib) not present or not configured])
116    fi
117
118    # For use in gts-config
119    glib_cflags=`$GLIB_CONFIG --cflags`
120    glib_thread_cflags=`$GLIB_CONFIG --cflags gthread`
121    glib_module_cflags=`$GLIB_CONFIG --cflags gmodule`
122    glib_libs=`$GLIB_CONFIG --libs`
123    glib_thread_libs=`$GLIB_CONFIG --libs gthread`
124    glib_module_libs=`$GLIB_CONFIG --libs gmodule`
125
126    glib_release=`$GLIB_CONFIG --version | sed 's%\\.[[0-9]]*$%%'`
127
128    # canonicalize relative paths
129    case $with_glib in
130      /*)
131        glib_dir=$with_glib
132        ;;
133      *)
134        glib_dir="\$(top_builddir)/$with_glib"
135        ;;
136    esac
137
138    GLIB_CFLAGS="-I$glib_dir -I$glib_dir/gmodule"
139    GLIB_LIBS="$glib_dir/libglib.la $glib_dir/gmodule.la"
140    GLIB_DEPLIBS=
141
142    AC_SUBST(GLIB_CFLAGS)
143    AC_SUBST(GLIB_LIBS)
144  fi
145fi
146
147AC_SUBST(glib_cflags)
148AC_SUBST(glib_libs)
149AC_SUBST(glib_thread_cflags)
150AC_SUBST(glib_thread_libs)
151AC_SUBST(glib_module_cflags)
152AC_SUBST(glib_module_libs)
153AC_SUBST(GLIB_DEPLIBS)
154
155CFLAGS="$CFLAGS $glib_cflags"
156LDFLAGS="$LDFLAGS $glib_libs"
157
158AC_SUBST(CFLAGS)
159AC_SUBST(CPPFLAGS)
160AC_SUBST(LDFLAGS)
161
162dnl generate `src/gtsconfig.h'
163AC_CONFIG_COMMANDS([default-1],[[
164	echo creating src/gtsconfig.h
165	cat >src/gtsconfig.h <<\__EOF
166/* gtsconfig.h
167 *
168 * This is a generated file.  Please modify `configure.in'
169 */
170
171#ifndef GTSCONFIG_H
172#define GTSCONFIG_H
173
174__EOF
175	case "$build" in
176	*-cray-unicos*)
177	  echo "/* CRAY inlining directives */" >> src/gtsconfig.h
178	  awk '
179BEGIN {
180  nc = 10;
181  nf = 0;
182}
183{
184  if ($1 == "G_INLINE_FUNC") {
185    nc = 0;
186    start = 2;
187  }
188  else
189    start = 1;
190  for (i = start; i <= NF; i++) {
191    if (nc == 1) {
192      if (substr ($i, 1, 1) != "*") {
193	in_list = 0;
194	for (j = 0; j < nf && !inlist; j++)
195	  if ($i == f[j])
196	    inlist = 1;
197	if (!inlist)
198          f[nf++] = $i;
199	nc = 10;
200      }
201    }
202    else
203      nc++;
204  }
205}
206END {
207  if (nf > 0) {
208    printf ("#pragma _CRI inline %s", f[0]);
209    for (i = 1; i < nf; i++)
210      printf (", %s", f[i]);
211    printf ("\n");
212  }
213}
214' < src/gts.h >> src/gtsconfig.h
215	;;
216	esac
217	cat >>src/gtsconfig.h <<__EOF
218$gts_defines
219
220#endif /* GTSCONFIG_H */
221__EOF
222]],[[
223	gts_defines="
224#define GTS_MAJOR_VERSION $GTS_MAJOR_VERSION
225#define GTS_MINOR_VERSION $GTS_MINOR_VERSION
226#define GTS_MICRO_VERSION $GTS_MICRO_VERSION"
227	build="$build"
228]])
229
230dnl checking for #warning cpp directive
231AC_TRY_COMPILE(,
232       "{
233           #warning test
234	}",
235	AC_DEFINE(CPP_HAS_WARNING, 1,
236	[Define if C preprocessor supports warning directive.]),
237	AC_MSG_WARN(["C preprocessor does not support warning directive."]))
238
239
240dnl header file checks
241AC_CHECK_HEADERS(fpu_control.h, AC_DEFINE(HAVE_FPU_CONTROL_H))
242AC_CHECK_HEADERS(floatingpoint.h, AC_DEFINE(HAVE_FLOATINGPOINT_H))
243AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
244AC_CHECK_HEADERS(getopt.h, AC_DEFINE(HAVE_GETOPT_H))
245
246dnl functions checks
247AC_CHECK_FUNCS(getopt_long)
248
249AC_CONFIG_FILES([
250Makefile
251gts.pc
252gts.spec
253src/Makefile
254src/gts-config
255tools/Makefile
256doc/Makefile
257examples/Makefile
258test/Makefile
259test/boolean/Makefile
260test/delaunay/Makefile
261test/coarsen/Makefile
262])
263AC_OUTPUT
264