1# Process this file with autoconf to produce a configure script.
2
3## --------------------- ##
4## Autoconf Requirements ##
5## --------------------- ##
6AC_PREREQ(2.59)
7
8## ---------------------------------- ##
9## Autoconf / Automake Initialization ##
10## ---------------------------------- ##
11AC_INIT([wcalc], [2.5], [kyle-wcalc@memoryhole.net])
12AC_CONFIG_AUX_DIR([config])
13AC_CONFIG_MACRO_DIR([config])
14AC_CONFIG_SRCDIR([src/cli/main.c])
15
16dnl Require at least AM 1.7.  Prior versions require AM_CONFIG_HEADER
17dnl and have no equivalent to AC_CONFIG_HEADERS (the plural version),
18dnl which is a pain.  AM 1.7 also added support for putting target
19dnl information in AM_CONDITIONAL blocks and using the += modifier.
20dnl ... removed "check-news" because of automatic version generation
21# Automake's silent rules were implemented in the same version that
22# color-tests was implemented, so we can use one to detect the other.
23# This nasty, dirty, unreliable trick is strongly discouraged by its author:
24# http://blog.flameeyes.eu/trackbacks?article_id=5155
25m4_ifdef([AM_SILENT_RULES],
26		 [m4_define([wc_color_tests], [color-tests])],
27		 [m4_define([wc_color_tests], [])])
28AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2 no-define 1.7 ]wc_color_tests)
29# If Automake supports silent rules, enable them
30m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
31
32
33AC_ARG_ENABLE([rpath],
34			  [AS_HELP_STRING([--enable-rpath],
35							  [Add -rpath arguments to LDFLAGS])])
36AC_ARG_ENABLE([picky],
37              [AS_HELP_STRING([--enable-picky],
38                              [turns on extra compiler warnings (for developers)])])
39AS_IF([test "x$enable_picky" = x],
40      [AS_IF([test -d "${srcdir}/.svn"],
41             [AC_MSG_NOTICE([--> developer override: enable picky compiler by default <--])
42             enable_picky=yes])])
43
44# Checks for programs.
45AC_PROG_CC
46AC_PROG_CC_C99
47AC_PROG_RANLIB
48AC_PROG_YACC
49AM_PROG_LEX
50AS_IF([test "x$LEX" == x],
51	  [AC_MSG_ERROR([A Lex/Flex program is required in order to compile wcalc.])],
52	  [AS_IF([test "x$LEX" != xflex],
53			 [LEX="$SHELL $missing_dir/missing flex"
54			  AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
55			  AC_SUBST([LEXLIB], [''])]
56			 )]
57	  )
58AC_PROG_CPP
59AC_PROG_INSTALL
60
61AS_IF([test "x$enable_picky" = xyes],
62	  [CFLAGS="$CFLAGS -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes"])
63
64CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200112L"
65
66AC_CHECK_HEADERS([limits.h])
67AC_CHECK_DECL([PATH_MAX],
68			  [AC_DEFINE([HAVE_PATH_MAX], [1], [Have PATH_MAX])],
69			  [],
70			  [#ifdef HAVE_LIMITS_H
71			   #include <limits.h>
72			   #endif
73			   ])
74
75# Checks for libraries.
76AC_CHECK_LIB([m], [acos])
77AC_ARG_WITH([readline],
78			[AS_HELP_STRING([--without-readline],
79							[do not try to find and use the readline library])],
80			[nc_cv_readline=$withval],
81			[nc_cv_readline=yes])
82AS_IF([test "x$nc_cv_readline" = xyes],
83	  [VL_LIB_READLINE])
84
85#==========================================================================================
86# GMP
87#==========================================================================================
88AC_ARG_WITH([gmp],
89			[AS_HELP_STRING([--with-gmp=[[PATH]]],
90							[specify the path to the gmp library])],
91			[AS_IF([test "x$enable_rpath" = xyes],
92				   [GMP_CPPFLAGS="-I$with_gmp/include"
93					GMP_LDFLAGS="-L$with_gmp/lib -Wl,-rpath,$with_gmp/lib"],
94				   [GMP_CPPFLAGS="-I$with_gmp/include"
95					GMP_LDFLAGS="-L$with_gmp/lib"])])
96saved_CPPFLAGS="$CPPFLAGS"
97saved_LDFLAGS="$LDFLAGS"
98CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
99LDFLAGS="$GMP_LDFLAGS $LDFLAGS"
100AC_CHECK_LIB([gmp], [__gmpz_init], [],
101			 [AC_CHECK_LIB([gmp], [mpz_init], [],
102						   [AC_CHECK_LIB([gmp2], [mpz_init])])])
103CPPFLAGS="$saved_CPPFLAGS"
104LDFFLAGS="$saved_LDFLAGS"
105AC_SUBST(GMP_CPPFLAGS)
106AC_SUBST(GMP_LDFLAGS)
107
108#==========================================================================================
109# MPFR
110#==========================================================================================
111AC_ARG_WITH([mpfr],
112			[AS_HELP_STRING([--with-mpfr=[[PATH]]],
113							[specify the path to the mpfr library])],
114			[AS_IF([test "x$enable_rpath" = xyes],
115				   [MPFR_CPPFLAGS="-I$with_mpfr/include"
116					MPFR_LDFLAGS="-L$with_mpfr/lib -Wl,-rpath,$with_mpfr/lib"],
117				   [MPFR_CPPFLAGS="-I$with_mpfr/include"
118					MPFR_LDFLAGS="-L$with_mpfr/lib"])])
119saved_CPPFLAGS="$CPPFLAGS"
120saved_LDFLAGS="$LDFLAGS"
121CPPFLAGS="$MPFR_CPPFLAGS $GMP_CPPFLAGS $CPPFLAGS"
122LDFLAGS="$MPFR_LDFLAGS $GMP_LDFLAGS $LDFLAGS"
123AC_SEARCH_LIBS([mpfr_free_str], [mpfr],
124			   [AC_DEFINE([HAVE_LIBMPFR], [1], [Have libmpfr])],
125			   [AC_MSG_ERROR([Need MPFR 2.1.x or better. see http://www.mpfr.org])])
126AC_CHECK_FUNC([mpfr_sec],
127			  [AC_DEFINE([HAVE_MPFR_22], [1], [MPFR version 2.2 or better])])
128AC_SUBST(MPFR_CPPFLAGS)
129AC_SUBST(MPFR_LDFLAGS)
130CPPFLAGS="$saved_CPPFLAGS"
131LDFFLAGS="$saved_LDFLAGS"
132# what version of mpfr
133#==========================================================================================
134
135# Checks for header files.
136AC_HEADER_STDC
137AC_HEADER_SYS_WAIT
138AC_HEADER_TIME
139AC_CHECK_HEADERS([fcntl.h float.h inttypes.h limits.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h stdio.h])
140
141# Checks for typedefs, structures, and compiler characteristics.
142AC_C_INLINE
143AC_C_CONST
144AC_TYPE_SIZE_T
145
146# Checks for library functions.
147AC_FUNC_MALLOC
148AC_FUNC_REALLOC
149AC_FUNC_VPRINTF
150AC_CHECK_FUNCS([gettimeofday memset modf pow stpcpy strchr strdup strerror strrchr strtoul])
151
152AC_CONFIG_HEADER([src/common/includes/config.h])
153AC_CONFIG_FILES([Makefile
154				 src/Makefile
155				 src/common/Makefile
156				 src/common/includes/Makefile
157				 src/gui/Makefile
158                 test/Makefile
159				 English.lproj/Makefile])
160AC_OUTPUT
161
162