summaryrefslogtreecommitdiff
path: root/configure.in
blob: 88acb260875958865fe1546812c318b7b71a88a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(ledger, 2.5, johnw@newartisans.com)
AM_INIT_AUTOMAKE(ledger, 2.5)
AC_CONFIG_SRCDIR([main.cc])
AC_CONFIG_HEADER([acconf.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
AM_PROG_LIBTOOL

# Checks for emacs lisp path
AM_PATH_LISPDIR

# check if UNIX pipes are available
AC_CACHE_CHECK(
  [if pipes can be used],
  [pipes_avail],
  [AC_LANG_PUSH(C++)
   AC_TRY_LINK(
     [#include <sys/types.h>
      #include <sys/wait.h>
      #include <unistd.h>
      #include <stdlib.h>
      #include <string.h>
      #include <stdio.h>],
     [int status, pfd[2];
      status = pipe(pfd);
      status = fork();
      if (status < 0) {
	;
      } else if (status == 0) {
	char *arg0;

	status = dup2(pfd[0], STDIN_FILENO);

	close(pfd[1]);
	close(pfd[0]);

	execlp("", arg0, (char *)0);
	perror("execl");
	exit(1);
      } else {
	close(pfd[0]);
      }],
     [pipes_avail=true],
     [pipes_avail=false])
   AC_LANG_POP])

if [test x$pipes_avail = xtrue ]; then
  AC_DEFINE([HAVE_UNIX_PIPES], [1], [Whether UNIX pipes are available])
fi

# check for gmp
AC_CACHE_CHECK(
  [if libgmp is available],
  [libgmp_avail],
  [libgmp_save_libs=$LIBS
   LIBS="-lgmp $LIBS"
   AC_LANG_PUSH(C++)
   AC_TRY_LINK(
     [#include <gmp.h>],
     [mpz_t bar;
      mpz_init(bar);
      mpz_clear(bar);],
     [libgmp_avail=true],
     [libgmp_avail=false])
   AC_LANG_POP
   LIBS=$libgmp_save_libs])

if [test x$libgmp_avail = xtrue ]; then
  AM_CONDITIONAL(HAVE_GMP, true)
  LIBS="-lgmp $LIBS"
else
  AC_MSG_FAILURE("Could not find gmp library (set CPPFLAGS and LDFLAGS?)")
fi

# check for pcre
AC_CACHE_CHECK(
  [if libpcre is available],
  [libpcre_avail],
  [libpcre_save_libs=$LIBS
   LIBS="-lpcre $LIBS"
   AC_LANG_PUSH(C++)
   AC_TRY_LINK(
     [#include <pcre.h>],
     [pcre_free((pcre *)NULL);],
     [libpcre_avail=true],
     [libpcre_avail=false])
   AC_LANG_POP
   LIBS=$libpcre_save_libs])

if [test x$libpcre_avail = xtrue ]; then
  AM_CONDITIONAL(HAVE_PCRE, true)
  LIBS="-lpcre $LIBS"
else
  AC_MSG_FAILURE("Could not find pcre library (set CPPFLAGS and LDFLAGS?)")
fi

# check for expat or xmlparse
AC_ARG_ENABLE(xml,
  [  --enable-xml            Turn on support for XML parsing],
  [case "${enableval}" in
    yes) xml=true ;;
    no)  xml=false ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-xml) ;;
  esac],[xml=true])
AM_CONDITIONAL(USE_XML, test x$xml = xtrue)

if [test x$xml = xtrue ]; then
  AC_CACHE_CHECK(
    [if libexpat is available],
    [libexpat_avail],
    [libexpat_save_libs=$LIBS
     LIBS="-lexpat $LIBS"
     AC_LANG_PUSH(C++)
     AC_TRY_LINK(
       [#include <stdio.h>
	extern "C" {
	#include <expat.h>           // expat XML parser
	}],
       [XML_Parser parser = XML_ParserCreate(NULL);
	return parser != NULL;],
       [libexpat_avail=true],
       [libexpat_avail=false])
     AC_LANG_POP
     LIBS=$libexpat_save_libs])
  AM_CONDITIONAL(HAVE_EXPAT, test x$libexpat_avail = xtrue)
else
  AM_CONDITIONAL(HAVE_EXPAT, false)
fi

if [test x$xml = xtrue ]; then
  if [test x$libexpat_avail = xfalse ]; then
    AC_CACHE_CHECK(
      [if libxmlparse is available],
      [libxmlparse_avail],
      [libxmlparse_save_libs=$LIBS
       LIBS="-lxmlparse -lxmltok $LIBS"
       AC_LANG_PUSH(C++)
       AC_TRY_LINK(
	 [#include <stdio.h>
	extern "C" {
	#include <xmlparse.h>           // expat XML parser
	}],
	 [XML_Parser parser = XML_ParserCreate(NULL);
	return parser != NULL;],
	 [libxmlparse_avail=true],
	 [libxmlparse_avail=false])
       AC_LANG_POP
       LIBS=$libxmlparse_save_libs])
    AM_CONDITIONAL(HAVE_XMLPARSE, test x$libxmlparse_avail = xtrue)
  else
    AM_CONDITIONAL(HAVE_XMLPARSE, false)
  fi
else
  AM_CONDITIONAL(HAVE_XMLPARSE, false)
fi

# check for libofx
AC_ARG_ENABLE(ofx,
  [  --enable-ofx            Turn on support for OFX/OCF parsing],
  [case "${enableval}" in
    yes) ofx=true ;;
    no)  ofx=false ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-ofx) ;;
  esac],[ofx=true])
AM_CONDITIONAL(USE_OFX, test x$ofx = xtrue)

if [test x$ofx = xtrue ]; then
  AC_CACHE_CHECK(
    [if libofx is available],
    [libofx_avail],
    [libofx_save_libs=$LIBS
     LIBS="-lofx $LIBS"
     AC_LANG_PUSH(C++)
     AC_TRY_LINK(
       [#include <libofx.h>],
       [  LibofxContextPtr libofx_context = libofx_get_new_context();],
       [libofx_avail=true],
       [libofx_avail=false])
     AC_LANG_POP
     LIBS=$libofx_save_libs])
  AM_CONDITIONAL(HAVE_LIBOFX, test x$libofx_avail = xtrue)
else
  AM_CONDITIONAL(HAVE_LIBOFX, false)
fi

# Check for options
AC_ARG_ENABLE(debug,
  [  --enable-debug          Turn on debugging],
  [case "${enableval}" in
    yes) debug=true ;;
    no)  debug=false ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
  esac],[debug=false])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)

# Checks for header files.
AC_STDC_HEADERS
AC_HAVE_HEADERS(sys/stat.h)

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
AC_STRUCT_TM

# Checks for library functions.
#AC_FUNC_ERROR_AT_LINE
AC_HEADER_STDC
AC_CHECK_FUNCS([access mktime realpath stat strftime strptime])

AC_CONFIG_FILES([Makefile])
AC_OUTPUT