1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(dreadnaut.c)
3
4dnl AC_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
5dnl Check if $CC supports a given set of cflags
6AC_DEFUN([AC_TRY_CFLAGS],
7    [AC_MSG_CHECKING([if $CC supports $1 flags])
8    SAVE_CFLAGS="$CFLAGS"
9    CFLAGS="$1"
10    AC_TRY_RUN([main(){exit(0);}],[ac_cv_try_cflags_ok=yes],
11	[ac_cv_try_cflags_ok=no],[ac_cv_try_cflags_ok=no])
12    CFLAGS="$SAVE_CFLAGS"
13    AC_MSG_RESULT([$ac_cv_try_cflags_ok])
14    if test x"$ac_cv_try_cflags_ok" = x"yes"; then
15        ifelse([$2],[],[:],[$2])
16    else
17        ifelse([$3],[],[:],[$3])
18    fi])
19
20dnl CVT_YESNO([YES-NO VARIABLE],[0-1 VARIABLE])
21dnl Make a 0-1 output variable from a yes/no shell variable
22AC_DEFUN(CVT_YESNO,[if test x"$$1" = x"yes"; then
23$2=1
24else
25$2=0
26fi
27AC_SUBST($2)])
28
29dnl Checks for system features
30AC_CANONICAL_HOST
31
32dnl Checks for C compiler and sets CFLAGS if not set by user
33user_cflags="$CFLAGS"
34AC_PROG_CC
35CFLAGS=$user_cflags
36MORECFLAGS=""
37
38if test x"$user_cflags" = x"" ; then
39  AC_TRY_CFLAGS([-O4],[CFLAGS="$CFLAGS -O4"]);
40  if test x"$ac_cv_try_cflags_ok" = x"no"; then
41     AC_TRY_CFLAGS([-O3],[CFLAGS="$CFLAGS -O3"]);
42     if test x"$ac_cv_try_cflags_ok" = x"no"; then
43         AC_TRY_CFLAGS([-O2],[CFLAGS="$CFLAGS -O2"],[CFLAGS="$CFLAGS -O"]);
44     fi
45  fi
46
47  case "$host" in
48   *pentium*solaris*)
49	;;
50   *pentium3*|*i686*|*athlon*)
51	AC_TRY_CFLAGS([-march=i686],[CFLAGS="$CFLAGS -march=i686"]);;
52   *pentium2*|*i586*)
53	AC_TRY_CFLAGS([-march=i586],[CFLAGS="$CFLAGS -march=i586"]);;
54   *powerpc*)
55	AC_TRY_CFLAGS([-mpowerpc],[CFLAGS="$CFLAGS -mpowerpc"])
56	AC_TRY_CFLAGS([-fast],[MORECFLAGS="$MORECFLAGS -fast"]);;
57   *osf*)
58	AC_TRY_CFLAGS([-fast],[CFLAGS="$CFLAGS -fast"]);;
59   *sparcv8*|*sparcv9*)
60	AC_TRY_CFLAGS([-msupersparc],[CFLAGS="$CFLAGS -msupersparc"])
61	if test x"$ac_cv_try_cflags_ok" = x"no"; then
62	    AC_TRY_CFLAGS([-cg92],[CFLAGS="$CFLAGS -cg92"])
63	    if test x"$ac_cv_try_cflags_ok" = x"no"; then
64		AC_TRY_CFLAGS([-xcg92],[CFLAGS="$CFLAGS -xcg92"])
65	    fi
66	fi;;
67  esac
68fi
69
70echo CFLAGS=$CFLAGS
71
72dnl Checks for header files.
73dnl AC_HEADER_STDC
74AC_HEADER_SYS_WAIT
75AC_CHECK_HEADERS(stddef.h unistd.h sys/types.h stdlib.h string.h errno.h)
76CVT_YESNO(ac_cv_header_stddef_h,header_stddef_h)
77CVT_YESNO(ac_cv_header_unistd_h,header_unistd_h)
78CVT_YESNO(ac_cv_header_stdlib_h,header_stdlib_h)
79CVT_YESNO(ac_cv_header_string_h,header_string_h)
80CVT_YESNO(ac_cv_header_signal_h,header_signal_h)
81CVT_YESNO(ac_cv_header_sys_wait_h,header_sys_wait_h)
82CVT_YESNO(ac_cv_header_sys_types_h,header_sys_types_h)
83CVT_YESNO(ac_cv_header_errno_h,header_errno_h)
84
85AC_TYPE_PID_T
86CVT_YESNO(ac_cv_type_pid_t,have_pid_t)
87
88AC_MSG_CHECKING(if malloc is declared in stdlib.h or malloc.h)
89AC_EGREP_HEADER([(^|[^a-zA-Z_0-9])malloc[^a-zA-Z_0-9]],stdlib.h,
90  malloc_dec=1,malloc_dec=0)
91if test $malloc_dec -eq 0; then
92  AC_EGREP_HEADER([(^|[^a-zA-Z_0-9])malloc[^a-zA-Z_0-9]],malloc.h,
93  malloc_dec=2,malloc_dec=0)
94fi
95AC_SUBST(malloc_dec)
96AC_MSG_RESULT($malloc_dec)
97
98AC_MSG_CHECKING(if ftell is declared in stdio.h)
99AC_EGREP_HEADER([(^|[^a-zA-Z_0-9])ftell[^a-zA-Z_0-9]],stdio.h,
100  ftell_dec=1,ftell_dec=0)
101AC_SUBST(ftell_dec)
102AC_MSG_RESULT($ftell_dec)
103
104AC_MSG_CHECKING(if fdopen is declared in stdio.h)
105AC_EGREP_HEADER([(^|[^a-zA-Z_0-9])fdopen[^a-zA-Z_0-9]],stdio.h,
106  fdopen_dec=1,fdopen_dec=0)
107AC_SUBST(fdopen_dec)
108AC_MSG_RESULT($fdopen_dec)
109
110AC_MSG_CHECKING(if popen is declared in stdio.h)
111AC_EGREP_HEADER([(^|[^a-zA-Z_0-9])popen[^a-zA-Z_0-9]],stdio.h,
112  popen_dec=1,popen_dec=0)
113AC_SUBST(popen_dec)
114AC_MSG_RESULT($popen_dec)
115
116AC_MSG_CHECKING(if INFINITY is declared in math.h)
117AC_EGREP_CPP(yes,
118[#include <math.h>
119#ifdef INFINITY
120  yes
121#endif
122], has_math_inf=1, has_math_inf=0)
123AC_SUBST(has_math_inf)
124AC_MSG_RESULT($has_math_inf)
125
126dnl Checks for sizes of integer types; avoid 64-bit if necessary
127AC_CHECK_SIZEOF(int,4)
128AC_SUBST(ac_cv_sizeof_int)
129AC_CHECK_SIZEOF(long,4)
130AC_SUBST(ac_cv_sizeof_long)
131AC_CHECK_SIZEOF(long long,0)
132AC_SUBST(ac_cv_sizeof_long_long)
133lok=0
134testprogs="dreadtest dreadtestB dreadtestS dreadtestS1 dreadtest4K"
135testprogs="$testprogs dreadtest1 dreadtestW1"
136AC_SUBST(MORECFLAGS)
137
138if test $ac_cv_sizeof_long_long -eq 8; then
139   lok=1
140   testprogs="$testprogs dreadtestL1 dreadtestL"
141else
142   if test $ac_cv_sizeof_long -eq 8; then
143      lok=1
144   fi
145fi
146AC_SUBST(lok)
147AC_SUBST(testprogs)
148
149dnl Checks for typedefs, structures, and compiler characteristics.
150AC_C_CONST
151CVT_YESNO(ac_cv_c_const,have_const)
152
153dnl Checks for library functions.
154AC_CHECK_FUNC(isatty,have_isatty=1,have_isatty=0)
155AC_SUBST(have_isatty)
156AC_CHECK_FUNC(times,have_times=1,have_times=0)
157AC_SUBST(have_times)
158AC_CHECK_FUNC(time,have_time=1,have_time=0)
159AC_SUBST(have_time)
160AC_CHECK_FUNC(gettimeofday,have_gettimeofday=1,have_gettimeofday=0)
161AC_SUBST(have_gettimeofday)
162AC_CHECK_FUNC(times,have_times=1,have_times=0)
163AC_SUBST(have_times)
164AC_CHECK_FUNC(getrusage,have_getrusage=1,have_getrusage=0)
165AC_SUBST(have_getrusage)
166AC_CHECK_FUNC(perror,have_perror=1,have_perror=0)
167AC_SUBST(have_perror)
168AC_CHECK_FUNC(pipe,have_pipe=1,have_pipe=0)
169AC_SUBST(have_pipe)
170AC_CHECK_FUNC(wait,have_wait=1,have_wait=0)
171AC_SUBST(have_wait)
172AC_CHECK_FUNC(popen,have_popen=1,have_popen=0)
173AC_SUBST(have_popen)
174
175AC_CHECK_PROGS(sort_prog,gsort sort,no_sort_found)
176
177AC_OUTPUT(makefile nauty.h:nauty-h.in
178    naututil.h:naututil-h.in gtools.h:gtools-h.in)
179