xref: /freebsd/contrib/libxo/configure.ac (revision 788ca347b816afd83b2885e0c79aeeb88649b2ab)
1#
2# $Id$
3#
4# See ./INSTALL for more info
5#
6
7#
8# Release numbering: even numbered dot releases are official ones, and
9# odd numbers are development ones.  The svn version of this file will
10# only (ONLY!) ever (EVER!) contain odd numbers, so I'll always know if
11# a particular user has the dist or svn release.
12#
13
14AC_PREREQ(2.2)
15AC_INIT([libxo], [0.3.2], [phil@juniper.net])
16AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
17
18# Support silent build rules.  Requires at least automake-1.11.
19# Disable with "configure --disable-silent-rules" or "make V=1"
20m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
21
22AC_PROG_CC
23AM_PROG_AR
24AC_PROG_INSTALL
25AC_CONFIG_MACRO_DIR([m4])
26AC_PROG_LN_S
27
28# Must be after AC_PROG_AR
29LT_INIT([dlopen shared])
30
31AC_PATH_PROG(BASENAME, basename, /usr/bin/basename)
32AC_PATH_PROG(BISON, bison, /usr/bin/bison)
33AC_PATH_PROG(CAT, cat, /bin/cat)
34AC_PATH_PROG(CHMOD, chmod, /bin/chmod)
35AC_PATH_PROG(CP, cp, /bin/cp)
36AC_PATH_PROG(DIFF, diff, /usr/bin/diff)
37AC_PATH_PROG(MKDIR, mkdir, /bin/mkdir)
38AC_PATH_PROG(MV, mv, /bin/mv)
39AC_PATH_PROG(RM, rm, /bin/rm)
40AC_PATH_PROG(SED, sed, /bin/sed)
41
42AC_STDC_HEADERS
43
44# Checks for typedefs, structures, and compiler characteristics.
45AC_C_INLINE
46AC_TYPE_SIZE_T
47
48# Checks for library functions.
49AC_FUNC_ALLOCA
50AC_FUNC_MALLOC
51AC_FUNC_REALLOC
52AC_CHECK_FUNCS([bzero memmove strchr strcspn strerror strspn])
53AC_CHECK_FUNCS([sranddev srand strlcpy])
54AC_CHECK_FUNCS([fdopen getrusage])
55AC_CHECK_FUNCS([gettimeofday ctime])
56AC_CHECK_FUNCS([getpass])
57AC_CHECK_FUNCS([sysctlbyname])
58AC_CHECK_FUNCS([flock])
59AC_CHECK_FUNCS([asprintf])
60AC_CHECK_FUNCS([__flbf])
61
62AC_CHECK_HEADERS([dlfcn.h])
63AC_CHECK_HEADERS([stdio_ext.h])
64AC_CHECK_HEADERS([tzfile.h])
65AC_CHECK_HEADERS([stdtime/tzfile.h])
66AC_CHECK_FUNCS([dlfunc])
67
68AC_CHECK_HEADERS([sys/time.h])
69AC_CHECK_HEADERS([ctype.h errno.h stdio.h stdlib.h])
70AC_CHECK_HEADERS([string.h sys/param.h unistd.h ])
71AC_CHECK_HEADERS([sys/sysctl.h])
72
73AC_CHECK_LIB([crypto], [MD5_Init])
74AM_CONDITIONAL([HAVE_LIBCRYPTO], [test "$HAVE_LIBCRYPTO" != "no"])
75
76dnl
77dnl Some packages need to be checked against version numbers so we
78dnl define a function here for later use
79dnl
80AC_DEFUN([VERSION_TO_NUMBER],
81[`$1 | sed -e 's/lib.* //' | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`])
82
83LIBSLAX_CONFIG_PREFIX=""
84LIBSLAX_SRC=""
85
86AC_ARG_WITH(libslax-prefix,
87        [  --with-libslax-prefix=[PFX]           Specify location of libslax config],
88        LIBSLAX_CONFIG_PREFIX=$withval
89)
90
91AC_MSG_CHECKING(for libslax)
92if test "x$LIBSLAX_CONFIG_PREFIX" != "x"
93then
94        SLAX_CONFIG=${LIBSLAX_CONFIG_PREFIX}/bin/slax-config
95else
96        SLAX_CONFIG=slax-config
97fi
98
99dnl
100dnl make sure slax-config is executable,
101dnl test version and init our variables
102dnl
103
104if ${SLAX_CONFIG} --libs > /dev/null 2>&1
105then
106	LIBSLAX_VERSION=`$SLAX_CONFIG --version`
107	SLAX_BINDIR="`$SLAX_CONFIG --bindir | head -1`"
108	SLAX_OXTRADOCDIR="`$SLAX_CONFIG --oxtradoc | head -1`"
109	AC_MSG_RESULT($LIBSLAX_VERSION found)
110else
111	LIBSLAX_VERSION=
112	SLAX_BINDIR=
113	SLAX_OXTRADOCDIR=
114	AC_MSG_RESULT([no])
115fi
116
117AC_SUBST(SLAX_BINDIR)
118AC_SUBST(SLAX_OXTRADOCDIR)
119
120AC_MSG_CHECKING([whether to build with warnings])
121AC_ARG_ENABLE([warnings],
122    [  --enable-warnings    Turn on compiler warnings],
123    [LIBXO_WARNINGS=$enableval],
124    [LIBXO_WARNINGS=no])
125AC_MSG_RESULT([$LIBXO_WARNINGS])
126AM_CONDITIONAL([LIBXO_WARNINGS_HIGH], [test "$LIBXO_WARNINGS" != "no"])
127
128AC_MSG_CHECKING([whether to build with debugging])
129AC_ARG_ENABLE([debug],
130    [  --enable-debug    Turn on debugging],
131    [LIBXO_DEBUG=yes; AC_DEFINE([LIBXO_DEBUG], [1], [Enable debugging])],
132    [LIBXO_DEBUG=no])
133AC_MSG_RESULT([$LIBXO_DEBUG])
134AM_CONDITIONAL([LIBXO_DEBUG], [test "$LIBXO_DEBUG" != "no"])
135
136AC_MSG_CHECKING([whether to build with text-only rendering])
137AC_ARG_ENABLE([text-only],
138    [  --enable-text-only    Turn on text-only rendering],
139    [LIBXO_TEXT_ONLY=yes; AC_DEFINE([LIBXO_TEXT_ONLY], [1], [Enable text-only rendering])],
140    [LIBXO_TEXT_ONLY=no])
141AC_MSG_RESULT([$LIBXO_TEXT_ONLY])
142AM_CONDITIONAL([LIBXO_TEXT_ONLY], [test "$LIBXO_TEXT_ONLY" != "no"])
143
144AC_CHECK_LIB([m], [lrint])
145AM_CONDITIONAL([HAVE_LIBM], [test "$HAVE_LIBM" != "no"])
146
147AC_MSG_CHECKING([compiler for gcc])
148HAVE_GCC=no
149if test "${CC}" != ""; then
150    HAVE_GCC=`${CC} --version 2>&1 | grep GCC`
151    if test "${HAVE_GCC}" != ""; then
152        HAVE_GCC=yes
153    else
154        HAVE_GCC=no
155    fi
156fi
157AC_MSG_RESULT([$HAVE_GCC])
158AM_CONDITIONAL([HAVE_GCC], [test "$HAVE_GCC" = "yes"])
159
160AC_MSG_CHECKING([whether to build with printflike])
161AC_ARG_ENABLE([printflike],
162    [  --enable-printflike    Enable use of GCC __printflike attribute],
163    [HAVE_PRINTFLIKE=yes;
164           AC_DEFINE([HAVE_PRINTFLIKE], [1], [Support printflike])],
165    [HAVE_PRINTFLIKE=no])
166AC_MSG_RESULT([$HAVE_PRINTFLIKE])
167AM_CONDITIONAL([HAVE_PRINTFLIKE], [test "$HAVE_PRINTFLIKE" != ""])
168
169AC_MSG_CHECKING([whether to build with LIBXO_OPTIONS])
170AC_ARG_ENABLE([libxo-options],
171    [  --disable-libxo-options  Turn off support for LIBXO_OPTIONS],
172    [LIBXO_OPTS=$enableval],
173    [LIBXO_OPTS=yes])
174AC_MSG_RESULT([$LIBXO_OPTS])
175AM_CONDITIONAL([NO_LIBXO_OPTIONS], [test "$LIBXO_OPTS" != "yes"])
176
177case $host_os in
178     darwin*)
179        LIBTOOL=glibtool
180	;;
181     Linux*|linux*)
182        CFLAGS="-D_GNU_SOURCE $CFLAGS"
183	LDFLAGS=-ldl
184	;;
185     cygwin*|CYGWIN*)
186	LDFLAGS=-no-undefined
187	;;
188esac
189
190case $prefix in
191     NONE)
192	prefix=/usr/local
193	;;
194esac
195
196XO_LIBS=-lxo
197XO_SRCDIR=${srcdir}
198XO_LIBDIR=${libdir}
199XO_BINDIR=${bindir}
200XO_INCLUDEDIR=${includedir}
201
202AC_SUBST(XO_SRCDIR)
203AC_SUBST(XO_LIBDIR)
204AC_SUBST(XO_BINDIR)
205AC_SUBST(XO_INCLUDEDIR)
206
207AC_ARG_WITH(share-dir,
208        [  --with-share-dir=[DIR]           Specify location of shared files],
209        [XO_SHAREDIR=$withval],
210        [XO_SHAREDIR=$datarootdir/libxo]
211)
212XO_SHAREDIR=`echo $XO_SHAREDIR | sed "s;\\${prefix};$prefix;"`
213AC_SUBST(XO_SHAREDIR)
214
215dnl for the spec file
216RELDATE=`date +'%Y-%m-%d%n'`
217AC_SUBST(RELDATE)
218
219AC_MSG_RESULT(Using configure dir $ac_abs_confdir)
220
221if test -d $ac_abs_confdir/.git ; then
222  extra=`git branch | awk '/\*/ { print $2 }'`
223  if test "$extra" != "" -a "$extra" != "master"
224  then
225      LIBXO_VERSION_EXTRA="-git-$extra"
226  fi
227fi
228
229LIBXO_VERSION=$PACKAGE_VERSION
230LIBXO_VERSION_NUMBER=VERSION_TO_NUMBER(echo $PACKAGE_VERSION)
231AC_SUBST(LIBXO_VERSION)
232AC_SUBST(LIBXO_VERSION_NUMBER)
233AC_SUBST(LIBXO_VERSION_EXTRA)
234
235AC_CONFIG_HEADERS([libxo/xoconfig.h])
236AC_CONFIG_FILES([
237  Makefile
238  libxo-config
239  xohtml/xohtml.sh
240  libxo/Makefile
241  libxo/xoversion.h
242  xo/Makefile
243  xolint/Makefile
244  xohtml/Makefile
245  packaging/libxo.pc
246  doc/Makefile
247  tests/Makefile
248  tests/core/Makefile
249  tests/xo/Makefile
250  packaging/libxo.spec
251  packaging/libxo.rb.base
252])
253AC_OUTPUT
254
255AC_MSG_NOTICE([summary of build options:
256
257  libxo version:    ${VERSION} ${LIBXO_VERSION_EXTRA}
258  host type:        ${host} / ${host_os}
259  install prefix:   ${prefix}
260  srcdir:           ${XO_SRCDIR}
261  libdir:           ${XO_LIBDIR}
262  bindir:           ${XO_BINDIR}
263  includedir:       ${XO_INCLUDEDIR}
264  share dir:        ${XO_SHAREDIR}
265  oxtradoc dir:     ${SLAX_OXTRADOCDIR}
266
267  compiler:         ${CC} (${HAVE_GCC:-no})
268  compiler flags:   ${CFLAGS}
269  library types:    Shared=${enable_shared}, Static=${enable_static}
270
271  warnings:         ${LIBXO_WARNINGS:-no}
272  debug:            ${LIBXO_DEBUG:-no}
273  printf-like:      ${HAVE_PRINTFLIKE:-no}
274  libxo-options:    ${LIBXO_OPTS:-no}
275  text-only:        ${LIBXO_TEXT_ONLY:-no}
276])
277