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