1dnl -------------------------------------------------------------------------
2dnl Autoconf startup.
3dnl -------------------------------------------------------------------------
4
5AC_PREREQ([2.63])
6AC_INIT([dateutils], [0.4.1], [https://github.com/hroptatyr/dateutils/issues])
7AC_CONFIG_AUX_DIR([build-aux])
8AC_CONFIG_HEADER([src/config.h])
9AC_CONFIG_MACRO_DIR([m4])
10AC_CONFIG_SRCDIR([src/])
11
12dnl -------------------------------------------------------------------------
13dnl Local copyright notices.
14dnl -------------------------------------------------------------------------
15
16AC_COPYRIGHT([dnl
17#### Configuration script for dateutils and friends.
18#### Copyright (C) 2011-2016 Sebastian Freundt
19
20### Don't edit this script!
21### This script was automatically generated by the `autoconf' program
22### from the file `./configure.ac'.
23### To rebuild it, execute the command
24###     autoreconf
25])
26
27AM_INIT_AUTOMAKE([foreign dist-xz color-tests parallel-tests subdir-objects])
28m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
29
30## the build chain
31AC_PROG_CC([icc gcc tcc cc])
32SXE_CHECK_CC([gnu11 c11 gnu1x c1x gnu99 c99])
33AC_C_BIGENDIAN
34SXE_CHECK_CFLAGS
35
36## check/generate version files
37AX_YUCK_SCMVER([version.mk])
38AC_CONFIG_LINKS([GNUmakefile:GNUmakefile])
39
40## check for clitosis helper
41AX_CHECK_CLITOSIS
42
43## check for byteorder utils
44AC_CHECK_HEADERS([endian.h sys/endian.h machine/endian.h byteorder.h])
45AC_CHECK_HEADERS([byteswap.h])
46AC_CHECK_HEADERS([sys/param.h])
47AC_CHECK_HEADERS([sys/types.h])
48
49## to make lintian happy
50AC_SYS_LARGEFILE
51
52## check for mmap and friends
53SXE_CHECK_MMAP
54
55## for getline()/fgetln() code (e.g. tzmap.c)
56AC_CHECK_FUNCS([getline])
57AC_CHECK_FUNCS([fgetln])
58
59## AIX' take on stdint
60AC_CHECK_HEADERS([sys/stdint.h])
61
62## check for tzfile.h
63AX_ZONEINFO([right])
64AM_CONDITIONAL([ZONEINFO_UTC_RIGHT], [test -n "${ax_cv_zoneinfo_utc_right}"])
65
66## check for strptime
67AC_CHECK_FUNCS([strptime])
68have_strptime="${ac_cv_func_strptime}"
69AM_CONDITIONAL([HAVE_STRPTIME], [test "${have_strptime}" = "yes"])
70
71## check for working c1x features
72SXE_CHECK_ANON_STRUCTS_DECL
73SXE_CHECK_ANON_STRUCTS_INIT
74SXE_CHECK_SLOPPY_STRUCTS_INIT
75
76if test "${sxe_cv_have_anon_structs_decl}" != "yes"; then
77	AC_MSG_ERROR([C compiler unusable
78
79dateutils make extensive use of c11 anonymous structs/unions but your
80compiler does not fully support them.
81Change either the CFLAGS or the compiler.
82Good day.
83])
84fi
85
86
87AM_PROG_LEX
88AC_PROG_YACC
89
90AC_PATH_PROG([GPERF], [gperf])
91if test -z "${GPERF}"; then
92	GPERF="gperf"
93fi
94AC_ARG_VAR([GPERF], [full path to the gperf tool])
95
96
97## check if we've got curl, necessary to d/l the tzmaps
98AC_PATH_PROG([CURL], [curl])
99AC_ARG_VAR([CURL], [full path to the curl tool])
100AM_CONDITIONAL([HAVE_CURL], [test -n "${CURL}"])
101
102AC_ARG_ENABLE([tzmap-fetch], [
103AS_HELP_STRING([--enable-tzmap-fetch], [Fetch tzmaps from github, default: no.])],
104        [dnl
105		enable_tzmap_fetch="${enableval}"
106                if test -z "${CURL}"; then
107                        enable_tzmap_fetch="no"
108                fi
109        ], [enable_tzmap_fetch="no"])
110AM_CONDITIONAL([FETCH_TZMAPS], [test "${enable_tzmap_fetch}" = "yes"])
111AM_CONDITIONAL([HAVE_TZMAPS],
112	[test `find "${srcdir}/lib" -name '*.tzmap' -print | wc -l` -gt 0])
113
114
115AC_PATH_PROG([GDATE], [date])
116AC_ARG_VAR([GDATE], [full path to the date tool])
117if test -n "${GDATE}"; then
118	## try and use -d
119	AC_MSG_CHECKING([if date is of GNU flavour])
120	if "${GDATE}" -d "2012-01-01" >/dev/null 2>/dev/null; then
121		have_gdate="yes"
122	else
123		have_gdate="no"
124	fi
125	AC_MSG_RESULT([${have_gdate}])
126fi
127if test -n "${GDATE}" -a "${have_gdate}" = "yes"; then
128	## try and use -d with a big year
129	AC_MSG_CHECKING([if date is immune to year 2038 problem])
130	if "${GDATE}" -d "4095-01-01" >/dev/null 2>/dev/null; then
131		have_gdate_2039="yes"
132	else
133		have_gdate_2039="no"
134	fi
135	AC_MSG_RESULT([${have_gdate_2039}])
136fi
137AC_ARG_VAR([have_gdate], [yes if GDATE is of GNU flavour])
138AC_ARG_VAR([have_gdate_2039], [yes if GDATE can handle years beyond 2038])
139AM_CONDITIONAL([HAVE_GDATE], [test "${have_gdate}" = "yes"])
140AM_CONDITIONAL([HAVE_GDATE_2039], [test "${have_gdate_2039}" = "yes"])
141
142
143AC_ARG_ENABLE([fast-arith],
144	[AS_HELP_STRING([--enable-fast-arith], [
145Whether to enable fast date handling and arithmetic routines at the cost
146of strictness.  For instance the leap year rule used is incorrect for
147years before 1901 and after 2100, or every month can have a 31st to
148denote the last day of the month.])
149AS_HELP_STRING([], [Default: disabled])],
150	[enable_fast_arith="${enableval}"], [enable_fast_arith="no"])
151
152AC_ARG_ENABLE([contrib], [
153AS_HELP_STRING([--enable-contrib], [Build contribs, default: no.])],
154        [enable_contrib="${enableval}"], [enable_contrib="no"])
155AM_CONDITIONAL([WITH_CONTRIB], [test "${enable_contrib}" != "no"])
156
157AC_ARG_WITH([old-names], [
158AS_HELP_STRING([--with-old-names], [Install old binary names only, default: no.])],
159        [with_old_names="${withval}"], [with_old_names="no"])
160AM_CONDITIONAL([WITH_OLD_NAMES], [test "${with_old_names}" != "no"])
161
162AC_ARG_WITH([old-links], [
163AS_HELP_STRING([--with-old-links], [Install compatibility symlinks, default: yes.])],
164	[with_old_links="${withval}"], [with_old_links="yes"])
165AM_CONDITIONAL([WITH_OLD_LINKS], [test "${with_old_links}" != "no"])
166
167## checks
168if test "${enable_fast_arith}" = "yes"; then
169	AC_DEFINE([WITH_FAST_ARITH], [1],
170		[whether to use fast but incorrect date routines])
171fi
172
173## always define this one for now
174AC_DEFINE([WITH_LEAP_SECONDS], [1], [Whether to use leap-second aware routines])
175AM_CONDITIONAL([WITH_LEAP_SECONDS], [test "1" = "1"])
176
177## trivial conditional so that the dexpr scanner and parser are built
178AM_CONDITIONAL([BUILD_DEXPR], [test "0" = "1"])
179
180AM_CONDITIONAL([BUILD_LTRCC], [test ! -f "${srcdir}/lib/leapseconds.def"])
181
182
183## check for contrib stuff
184if test "${enable_contrib}" != "no"; then
185	## check for matlab, then octave
186	SXE_CHECK_MATLAB
187	SXE_CHECK_OCTAVE
188fi
189AM_CONDITIONAL([BUILD_MEXCLI], [test "${sxe_cv_matlab_mex_h}" = "yes" -a -n "${MATLABPATH}"])
190AM_CONDITIONAL([BUILD_OCTCLI], [test "${sxe_cv_octave_mex_h}" = "yes" -a -n "${OCTAVEPATH}"])
191
192
193## prepare the summary page
194if test "${with_old_names}" = "no"; then
195	dut_apps="dateadd dateconv datediff dategrep dateround dateseq datesort datetest datezone"
196else
197	dut_apps="dadd dconv ddiff dgrep dround dseq dsort dtest dzone"
198fi
199if test "${have_strptime}" = "yes"; then
200	misc_apps="strptime"
201else
202	misc_apps="none"
203fi
204if test "${enable_contrib}" != "no"; then
205	if test "${sxe_cv_matlab_mex_h}" = "yes"; then
206		cntrb_apps="${cntrb_apps}${cntrb_apps:+ }tzconv.m(atlab)"
207	fi
208	if test "${sxe_cv_octave_mex_h}" = "yes"; then
209		cntrb_apps="${cntrb_apps}${cntrb_apps:+ }tzconv.m(octave)"
210	fi
211else
212	cntrb_apps="none"
213fi
214
215AX_CHECK_YUCK
216
217dnl must come after all AC_LINK_IFELSE clauses
218## check for the ldflags
219SXE_CHECK_LDFLAGS
220LT_INIT
221SXE_CHECK_LIBTOOL
222
223AC_CONFIG_FILES([Makefile])
224AC_CONFIG_FILES([build-aux/Makefile])
225AC_CONFIG_FILES([data/Makefile])
226AC_CONFIG_FILES([lib/Makefile])
227AC_CONFIG_FILES([src/Makefile])
228AC_CONFIG_FILES([info/Makefile])
229AC_CONFIG_FILES([test/Makefile])
230AC_CONFIG_FILES([contrib/Makefile])
231AC_OUTPUT
232
233cat <<EOF
234
235
236Build summary
237=============
238Build date/time apps:	${dut_apps}
239Build misc apps:	${misc_apps}
240Build contrib apps:	${cntrb_apps}
241
242EOF
243
244if test "${with_old_names}" = "no"; then
245	cat <<EOF
246New binary names will be used (compatibility symlinks: $with_old_links).
247See configure options --with-old-names and --with-old-links.
248EOF
249else
250	echo "Old binary names will be used."
251fi
252
253dnl configure.ac ends here
254