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.2.0], [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_CHECK_LIB([m], [lrint]) 137AM_CONDITIONAL([HAVE_LIBM], [test "$HAVE_LIBM" != "no"]) 138 139AC_MSG_CHECKING([compiler for gcc]) 140HAVE_GCC=no 141if 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 148fi 149AC_MSG_RESULT([$HAVE_GCC]) 150AM_CONDITIONAL([HAVE_GCC], [test "$HAVE_GCC" = "yes"]) 151 152AC_MSG_CHECKING([whether to build with printflike]) 153AC_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]) 158AC_MSG_RESULT([$HAVE_PRINTFLIKE]) 159AM_CONDITIONAL([HAVE_PRINTFLIKE], [test "$HAVE_PRINTFLIKE" != ""]) 160 161AC_MSG_CHECKING([whether to build with LIBXO_OPTIONS]) 162AC_ARG_ENABLE([libxo-options], 163 [ --disable-libxo-options Turn off support for LIBXO_OPTIONS], 164 [LIBXO_OPTS=$enableval], 165 [LIBXO_OPTS=yes]) 166AC_MSG_RESULT([$LIBXO_OPTS]) 167AM_CONDITIONAL([NO_LIBXO_OPTIONS], [test "$LIBXO_OPTS" != "yes"]) 168 169case $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 ;; 180esac 181 182case $prefix in 183 NONE) 184 prefix=/usr/local 185 ;; 186esac 187 188XO_LIBS=-lxo 189XO_SRCDIR=${srcdir} 190XO_LIBDIR=${libdir} 191XO_BINDIR=${bindir} 192XO_INCLUDEDIR=${includedir} 193 194AC_SUBST(XO_SRCDIR) 195AC_SUBST(XO_LIBDIR) 196AC_SUBST(XO_BINDIR) 197AC_SUBST(XO_INCLUDEDIR) 198 199AC_ARG_WITH(share-dir, 200 [ --with-share-dir=[DIR] Specify location of shared files], 201 [XO_SHAREDIR=$withval], 202 [XO_SHAREDIR=$datarootdir/libxo] 203) 204XO_SHAREDIR=`echo $XO_SHAREDIR | sed "s;\\${prefix};$prefix;"` 205AC_SUBST(XO_SHAREDIR) 206 207dnl for the spec file 208RELDATE=`date +'%Y-%m-%d%n'` 209AC_SUBST(RELDATE) 210 211AC_MSG_RESULT(Using configure dir $ac_abs_confdir) 212 213if 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 219fi 220 221LIBXO_VERSION=$PACKAGE_VERSION 222LIBXO_VERSION_NUMBER=VERSION_TO_NUMBER(echo $PACKAGE_VERSION) 223AC_SUBST(LIBXO_VERSION) 224AC_SUBST(LIBXO_VERSION_NUMBER) 225AC_SUBST(LIBXO_VERSION_EXTRA) 226 227AC_CONFIG_HEADERS([libxo/xoconfig.h]) 228AC_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]) 244AC_OUTPUT 245 246AC_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]) 266