1AC_PREREQ(2.60)
2AC_INIT(libpst,0.6.76,carl@five-ten-sg.com)
3AC_CONFIG_SRCDIR([src/libpst.c])
4AC_CONFIG_HEADER([config.h])
5AC_CONFIG_MACRO_DIR([m4])
6AM_INIT_AUTOMAKE
7AC_CANONICAL_HOST
8AC_USE_SYSTEM_EXTENSIONS
9
10#
11#  1. Remember that version-info is current:revision:age, and age <= current.
12#  2. If the source code has changed at all since the last public release,
13#     then increment revision (`c:r:a' becomes `c:r+1:a').
14#  3. If any interfaces have been added, removed, or changed since the last
15#     update, increment current, and set revision to 0.
16#  4. If any interfaces have been added since the last public release, then
17#     increment age, since we should be backward compatible with the previous
18#     version.
19#  5. If any interfaces have been removed or changed since the last public
20#     release, then set age to 0, since we are not backward compatible.
21#  6. libtool will build libpst.so.x.y.z where the SONAME is libpst.so.x
22#     and x=current-age, y=age, z=revision
23
24libpst_version_info='5:18:1'
25AC_SUBST(LIBPST_VERSION_INFO, [$libpst_version_info])
26libpst_so_major='4'
27AC_SUBST(LIBPST_SO_MAJOR, [$libpst_so_major])
28
29# libpst
30# version   soname          so library name
31# 0.6.35    libpst.so.2     libpst.so.2.0.0
32# 0.6.37    libpst.so.2     libpst.so.2.1.0
33# 0.6.38    libpst.so.2     libpst.so.2.1.0
34# 0.6.40    libpst.so.4     libpst.so.4.0.0
35# 0.6.43    libpst.so.4     libpst.so.4.0.1
36# 0.6.47    libpst.so.4     libpst.so.4.0.2
37# 0.6.48    libpst.so.4     libpst.so.4.0.3
38# 0.6.49    libpst.so.4     libpst.so.4.0.4
39# 0.6.50    libpst.so.4     libpst.so.4.1.0
40# 0.6.51    libpst.so.4     libpst.so.4.1.1
41# 0.6.52    libpst.so.4     libpst.so.4.1.2
42# 0.6.53    libpst.so.4     libpst.so.4.1.3
43# 0.6.54    libpst.so.4     libpst.so.4.1.4
44# 0.6.55    libpst.so.4     libpst.so.4.1.5
45# 0.6.56    libpst.so.4     libpst.so.4.1.6
46# 0.6.57    libpst.so.4     libpst.so.4.1.6
47# 0.6.58    libpst.so.4     libpst.so.4.1.7
48# 0.6.59    libpst.so.4     libpst.so.4.1.8
49# 0.6.60    libpst.so.4     libpst.so.4.1.9
50# 0.6.61    libpst.so.4     libpst.so.4.1.9
51# 0.6.62    libpst.so.4     libpst.so.4.1.9
52# 0.6.63    libpst.so.4     libpst.so.4.1.10
53# 0.6.66    libpst.so.4     libpst.so.4.1.11
54# 0.6.67    libpst.so.4     libpst.so.4.1.12
55# 0.6.68    libpst.so.4     libpst.so.4.1.13
56# 0.6.69    libpst.so.4     libpst.so.4.1.14
57# 0.6.73    libpst.so.4     libpst.so.4.1.15
58# 0.6.74    libpst.so.4     libpst.so.4.1.16
59# 0.6.75    libpst.so.4     libpst.so.4.1.17
60# 0.6.76    libpst.so.4     libpst.so.4.1.18
61
62
63
64# Check for solaris
65AC_MSG_CHECKING([for Solaris])
66case "$host" in
67    *solaris*)
68        os_solaris=yes
69        ;;
70    *)
71        os_solaris=no
72        ;;
73esac
74AC_MSG_RESULT($os_solaris)
75AM_CONDITIONAL(OS_SOLARIS, [test "$os_solaris" = "yes"])
76
77
78# Check for win32
79AC_MSG_CHECKING([for Win32])
80case "$host" in
81    *-mingw*)
82        os_win32=yes
83        ;;
84    *)
85        os_win32=no
86        ;;
87esac
88AC_MSG_RESULT($os_win32)
89AM_CONDITIONAL(OS_WIN32, [test "$os_win32" = "yes"])
90
91
92# Check for Win32 platform
93AC_MSG_CHECKING([for Win32 platform in general])
94case "$host" in
95    *-cygwin*)
96        platform_win32=yes
97        ;;
98    *)
99        platform_win32=$os_win32
100        ;;
101esac
102AC_MSG_RESULT($platform_win32)
103AM_CONDITIONAL(PLATFORM_WIN32, [test "$platform_win32" = "yes"])
104
105
106# Checks for programs.
107# The following lines adds the --enable-dii option to configure:
108#
109# Give the user the choice to enter one of these:
110# --enable-dii
111# --enable-dii=yes
112# --enable-dii=no
113#
114AC_MSG_CHECKING([whether we are enabling dii utility])
115AC_ARG_ENABLE(dii,
116    AC_HELP_STRING([--enable-dii], [enable dii utility]),
117    [
118        case "${enableval}" in
119          yes) ;;
120          no)  ;;
121          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-dii) ;;
122        esac
123    ],
124    # default if not specified
125    enable_dii=yes
126    )
127AC_MSG_RESULT([$enable_dii])
128AC_PATH_PROG(CONVERT, convert)
129if test "x$CONVERT" = "x" ; then
130    if test "$enable_dii" = "yes"; then
131        enable_dii=no
132        AC_MSG_WARN([convert program not found. pst2dii disabled])
133    fi
134else
135    if test "x`$CONVERT --version 2>&1 | grep -i imagemagick >/dev/null ; echo $?`" != "x0"; then
136        if test "$enable_dii" = "yes"; then
137            enable_dii=no
138            AC_MSG_WARN([wrong convert program found. pst2dii disabled])
139        fi
140    fi
141fi
142AC_CHECK_HEADER([gd.h],
143                [
144                    AC_DEFINE([HAVE_GD_H], [1], [Define to 1 if you have the <gd.h> header file.])
145                ],
146                [
147                    if test "$enable_dii" = "yes"; then
148                        enable_dii=no
149                        AC_MSG_WARN([gd.h not found. pst2dii disabled])
150                    fi
151                ])
152AM_CONDITIONAL(BUILD_DII, [test "$enable_dii" = "yes"])
153
154
155# Checks for programs.
156AC_PROG_CXX
157AC_PROG_CC
158AM_PROG_CC_C_O
159AC_PROG_CPP
160AC_PROG_INSTALL
161AC_PROG_LN_S
162AC_PROG_LIBTOOL
163AC_PROG_MAKE_SET
164
165
166# make sure we get large file support
167AC_SYS_LARGEFILE
168AC_CHECK_SIZEOF(off_t)
169
170
171# Checks for header files.
172AC_CHECK_HEADER([unistd.h],
173    AM_CONDITIONAL(NEED_XGETOPT, [test yes = no]),
174    AM_CONDITIONAL(NEED_XGETOPT, [test yes = yes])
175    )
176AC_HEADER_DIRENT
177AC_HEADER_STDC
178AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h regex.h semaphore.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/shm.h sys/stat.h sys/types.h time.h unistd.h wchar.h])
179save_libs="$LIBS" ; LIBS=""
180AC_SEARCH_LIBS([sem_init], [pthread rt], [SEM_LIBS="$LIBS"], [AC_MSG_ERROR([sem_init missing])])
181AC_SUBST([SEM_LIBS])
182LIBS="$save_libs"
183
184
185# Checks for typedefs, structures, and compiler characteristics.
186AC_HEADER_STDBOOL
187AC_HEADER_SYS_WAIT
188AC_C_CONST
189AC_C_INLINE
190AC_TYPE_OFF_T
191AC_TYPE_SIZE_T
192AC_TYPE_PID_T
193AC_STRUCT_TM
194
195
196# Checks for library functions.
197AC_FUNC_FORK
198AC_FUNC_FSEEKO
199AC_FUNC_STAT
200AC_FUNC_LSTAT
201AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
202if test "$cross_compiling" != "yes"; then
203    AC_FUNC_MALLOC
204    AC_FUNC_MKTIME
205    AC_FUNC_REALLOC
206fi
207AC_FUNC_STRFTIME
208AC_FUNC_VPRINTF
209AC_CHECK_FUNCS([chdir getcwd memchr memmove memset regcomp strcasecmp strncasecmp strchr strdup strerror strpbrk strrchr strstr strtol get_current_dir_name])
210AM_GNU_GETTEXT
211AM_GNU_GETTEXT_VERSION([0.17])
212AM_ICONV
213if test "$am_cv_func_iconv" != "yes"; then
214    AC_MSG_ERROR([libpst requires iconv which is missing])
215fi
216
217
218AC_CHECK_FUNCS(regexec,,[AC_CHECK_LIB(regex,regexec,
219               [REGEXLIB=-lregex
220                AC_DEFINE(HAVE_REGEXEC,1,[Define to 1 if you have the regexec function.])],
221               [AC_MSG_ERROR([No regex library found])])])
222AC_SUBST(REGEXLIB)
223
224
225# The following lines adds the --enable-pst-debug option to configure:
226#
227# Give the user the choice to enter one of these:
228# --enable-pst-debug
229# --enable-pst-debug=yes
230# --enable-pst-debug=no
231#
232AC_MSG_CHECKING([whether we are forcing debug dump file creation])
233AC_ARG_ENABLE(pst-debug,
234    AC_HELP_STRING([--enable-pst-debug], [force debug dump file creation]),
235    [
236        case "${enableval}" in
237          yes) ;;
238          no)  ;;
239          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-pst-debug) ;;
240        esac
241    ],
242    # default if not specified
243    enable_pst_debug=no
244    )
245AC_MSG_RESULT([$enable_pst_debug])
246if test "$enable_pst_debug" = "yes"; then
247    AC_DEFINE(DEBUG_ALL, 1, Define to 1 to force debug dump file creation)
248fi
249
250
251# The following lines adds the --enable-libpst-shared option to configure:
252#
253# Give the user the choice to enter one of these:
254# --enable-libpst-shared
255# --enable-libpst-shared=yes
256# --enable-libpst-shared=no
257#
258AC_MSG_CHECKING([whether we are building libpst shared object])
259AC_ARG_ENABLE(libpst-shared,
260    AC_HELP_STRING([--enable-libpst-shared], [build libpst shared object]),
261    [
262        case "${enableval}" in
263          yes) ;;
264          no)  ;;
265          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-libpst-shared) ;;
266        esac
267    ],
268    # default if not specified
269    enable_libpst_shared=no
270    )
271AC_MSG_RESULT([$enable_libpst_shared])
272enable_static_tools=yes
273if test "$enable_libpst_shared" = "yes"; then
274    enable_shared=yes
275    enable_static_tools=no
276fi
277
278# needed by STATIC_TOOLS in src/Makefile.am
279AC_SUBST(PST_OBJDIR, [$objdir])
280
281
282# The following lines adds the --enable-static-tools option to configure:
283#
284# Give the user the choice to enter one of these:
285# --enable-static-tools
286# --enable-static-tools=yes
287# --enable-static-tools=no
288#
289AC_MSG_CHECKING([whether to link command line tools with libpst statically])
290AC_ARG_ENABLE([static-tools],
291    AC_HELP_STRING([--enable-static-tools], [link command line tools with libpst statically]),
292    [
293        case "${enableval}" in
294          yes) ;;
295          no)  ;;
296          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-static-tools) ;;
297        esac
298    ],
299    [
300        enable_static_tools=no
301    ])
302AC_MSG_RESULT([$enable_static_tools])
303AM_CONDITIONAL(STATIC_TOOLS, [test "$enable_static_tools" = "yes"])
304if test "$enable_static_tools" = "yes"; then
305	enable_static="yes"
306fi
307
308
309# The following lines adds the --enable-python option to configure:
310#
311# Give the user the choice to enter one of these:
312# --enable-python
313# --enable-python=yes
314# --enable-python=no
315#
316AC_MSG_CHECKING([whether to build the libpst python interface])
317AC_ARG_ENABLE([python],
318    AC_HELP_STRING([--enable-python], [build libpst python interface]),
319    [
320        case "${enableval}" in
321          yes) ;;
322          no)  ;;
323          *)   AC_MSG_ERROR(bad value ${enableval} for --python) ;;
324        esac
325    ],
326    [
327        enable_python=yes
328    ])
329AC_MSG_RESULT([$enable_python])
330AM_CONDITIONAL(PYTHON_INTERFACE, [test "$enable_python" = "yes"])
331if test "$enable_python" = "yes"; then
332	enable_shared="yes"
333    # get the version of installed python
334    AX_PYTHON
335    if test "$ax_python_bin" = "no"; then
336        AC_MSG_ERROR(python binary not found)
337    fi
338    PYTHON_VERSION=`echo $ax_python_bin | cut -c7-`
339
340    # find the flags for that version
341    AX_PYTHON_DEVEL([$PYTHON_VERSION])
342
343    # do we have Boost Python?
344    AX_BOOST_PYTHON
345    if test "$ac_cv_boost_python" = "no"; then
346        AC_MSG_ERROR(Boost Python not found)
347    fi
348    AC_SUBST(PYTHON_VERSION, [$ax_python_bin])
349fi
350
351
352# The following lines adds the --enable-profiling option to configure:
353#
354# Give the user the choice to enter one of these:
355# --enable-profiling
356# --enable-profiling=yes
357# --enable-profiling=no
358#
359AC_MSG_CHECKING([whether to link with gprof profiling])
360AC_ARG_ENABLE([profiling],
361    AC_HELP_STRING([--enable-profiling], [link with gprof profiling]),
362    [
363        case "${enableval}" in
364          yes)
365              CFLAGS="$CFLAGS -pg"
366              CPPFLAGS="$CPPFLAGS -pg"
367              CXXFLAGS="$CXXFLAGS -pg"
368              ;;
369          no)
370              ;;
371          *)   AC_MSG_ERROR(bad value ${enableval} for --profiling) ;;
372        esac
373    ],
374    [
375        enable_profiling=no
376    ])
377AC_MSG_RESULT([$enable_profiling])
378AM_CONDITIONAL(GPROF_PROFILING, [test "$enable_profiling" = "yes"])
379
380PKG_CHECK_MODULES([GSF], [libgsf-1])
381
382PKG_CHECK_MODULES([ZLIB], [zlib])
383
384AC_OUTPUT(                  \
385    Makefile                \
386    html/Makefile           \
387    libpst.pc               \
388    libpst.spec             \
389    man/Makefile            \
390    src/Makefile            \
391    src/pst2dii.cpp         \
392    python/Makefile         \
393    xml/Makefile            \
394    xml/libpst              \
395    )
396