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.4.5], [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([getprogname]) 58AC_CHECK_FUNCS([sysctlbyname]) 59AC_CHECK_FUNCS([flock]) 60AC_CHECK_FUNCS([asprintf]) 61AC_CHECK_FUNCS([__flbf]) 62AC_CHECK_FUNCS([sysctlbyname]) 63 64 65AC_CHECK_HEADERS([dlfcn.h]) 66AC_CHECK_HEADERS([dlfcn.h]) 67AC_CHECK_HEADERS([stdio_ext.h]) 68AC_CHECK_HEADERS([tzfile.h]) 69AC_CHECK_HEADERS([stdtime/tzfile.h]) 70AC_CHECK_FUNCS([dlfunc]) 71 72AC_CHECK_HEADERS([sys/time.h]) 73AC_CHECK_HEADERS([ctype.h errno.h stdio.h stdlib.h]) 74AC_CHECK_HEADERS([string.h sys/param.h unistd.h ]) 75AC_CHECK_HEADERS([sys/sysctl.h]) 76AC_CHECK_HEADERS([threads.h]) 77 78dnl humanize_number(3) is a great function, but it's not standard. 79dnl Note Macosx has the function in libutil.a but doesn't ship the 80dnl header file, so I'll need to carry my own implementation. See: 81dnl https://devforums.apple.com/thread/271121 82AC_CHECK_HEADERS([libutil.h]) 83AC_CHECK_LIB([util], [humanize_number], 84 [HAVE_HUMANIZE_NUMBER=$ac_cv_header_libutil_h], 85 [HAVE_HUMANIZE_NUMBER=no]) 86 87AC_MSG_RESULT(humanize_number results: :${HAVE_HUMANIZE_NUMBER}:${ac_cv_header_libutil_h}:) 88 89if test "$HAVE_HUMANIZE_NUMBER" = "yes"; then 90 AC_DEFINE([HAVE_HUMANIZE_NUMBER], [1], [humanize_number(3)]) 91fi 92 93AM_CONDITIONAL([HAVE_HUMANIZE_NUMBER], [test "$HAVE_HUMANIZE_NUMBER" = "yes"]) 94 95AC_ARG_ENABLE([gettext], 96 [ --disable-gettext Turn off support for gettext], 97 [GETTEXT_ENABLE=$enableval], 98 [GETTEXT_ENABLE=yes]) 99 100dnl Looking for gettext(), assumably in libintl 101AC_ARG_WITH(gettext, 102 [ --with-gettext=[PFX] Specify location of gettext installation], 103 [GETTEXT_PREFIX=$withval], 104 [GETTEXT_PREFIX=/usr], 105) 106 107HAVE_GETTEXT=no 108 109if test "$GETTEXT_ENABLE" != "no"; then 110 111 AC_MSG_CHECKING([gettext in ${GETTEXT_PREFIX}]) 112 113 _save_cflags="$CFLAGS" 114 CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl" 115 AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <libintl.h>] 116 [int main() {char *cp = dgettext(NULL, "xx"); return 0; }]])], 117 [HAVE_GETTEXT=yes], 118 [HAVE_GETTEXT=no]) 119 CFLAGS="$_save_cflags" 120 121 AC_MSG_RESULT([$HAVE_GETTEXT]) 122 123 if test "$HAVE_GETTEXT" != "yes"; then 124 GETTEXT_PREFIX=/opt/local 125 AC_MSG_CHECKING([gettext in ${GETTEXT_PREFIX}]) 126 127 _save_cflags="$CFLAGS" 128 CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl" 129 AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <libintl.h>] 130 [int main() {char *cp = dgettext(NULL, "xx"); return 0; }]])], 131 [HAVE_GETTEXT=yes], 132 [HAVE_GETTEXT=no]) 133 CFLAGS="$_save_cflags" 134 135 AC_MSG_RESULT([$HAVE_GETTEXT]) 136 fi 137fi 138 139if test "$HAVE_GETTEXT" = "yes"; then 140 AC_DEFINE([HAVE_GETTEXT], [1], [gettext(3)]) 141 GETTEXT_CFLAGS="-I${GETTEXT_PREFIX}/include" 142 GETTEXT_LIBS="-L${GETTEXT_PREFIX}/lib -lintl" 143else 144 GETTEXT_PREFIX=none 145 GETTEXT_CFLAGS= 146 GETTEXT_LIBS= 147fi 148AC_SUBST(GETTEXT_CFLAGS) 149AC_SUBST(GETTEXT_LIBS) 150 151GETTEXT_BINDIR=${GETTEXT_PREFIX}/bin 152AC_SUBST(GETTEXT_BINDIR) 153GETTEXT_LIBDIR=${GETTEXT_PREFIX}/lib 154AC_SUBST(GETTEXT_LIBDIR) 155 156AM_CONDITIONAL([HAVE_GETTEXT], [test "$HAVE_GETTEXT" = "yes"]) 157 158dnl Looking for how to do thread-local variables 159AC_ARG_WITH(threads, 160 [ --with-threads=[STYLE] Specify style of thread-local support (none)], 161 [THREAD_LOCAL=$withval], 162 [THREAD_LOCAL=unknown], 163) 164 165AC_MSG_CHECKING([thread-locals are ${THREAD_LOCAL}]) 166 167if test "$THREAD_LOCAL" = "unknown"; then 168 AC_LINK_IFELSE([AC_LANG_SOURCE([[] 169 [__thread int foo; int main() { foo++; return foo; }]])], 170 [THREAD_LOCAL=before], 171 [THREAD_LOCAL=unknown]) 172 173 AC_MSG_RESULT([$THREAD_LOCAL]) 174fi 175 176if test "$THREAD_LOCAL" = "unknown"; then 177 AC_LINK_IFELSE([AC_LANG_SOURCE([[] 178 [int __thread foo; int main() { foo++; return foo; }]])], 179 [THREAD_LOCAL=after], 180 [THREAD_LOCAL=unknown]) 181 AC_MSG_RESULT([$THREAD_LOCAL]) 182fi 183 184if test "$THREAD_LOCAL" = "unknown"; then 185 AC_LINK_IFELSE([AC_LANG_SOURCE([[] 186 [__declspec(int) foo; int main() { foo++; return foo; }]])], 187 [THREAD_LOCAL=declspec], 188 [THREAD_LOCAL=unknown]) 189 AC_MSG_RESULT([$THREAD_LOCAL]) 190fi 191 192if test "$THREAD_LOCAL" != "unknown"; then 193 AC_DEFINE_UNQUOTED([HAVE_THREAD_LOCAL], 194 THREAD_LOCAL_${THREAD_LOCAL}, [thread-local setting]) 195fi 196 197dnl Looking for libcrypto.... 198AC_CHECK_LIB([crypto], [MD5_Init]) 199AM_CONDITIONAL([HAVE_LIBCRYPTO], [test "$HAVE_LIBCRYPTO" != "no"]) 200 201AC_CHECK_MEMBER([struct sockaddr_un.sun_len], 202 [HAVE_SUN_LEN=yes ; 203 AC_DEFINE([HAVE_SUN_LEN], [1], [Have struct sockaddr_un.sun_len])], 204 [HAS_SUN_LEN=no], [[#include <sys/un.h>]]) 205 206AC_CHECK_DECLS([__isthreaded], [], [], [#include <stdio.h>]) 207HAVE_ISTHREADED=${ac_cv_have_decl___isthreaded} 208 209dnl 210dnl Some packages need to be checked against version numbers so we 211dnl define a function here for later use 212dnl 213AC_DEFUN([VERSION_TO_NUMBER], 214[`$1 | sed -e 's/lib.* //' | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`]) 215 216LIBSLAX_CONFIG_PREFIX="" 217LIBSLAX_SRC="" 218 219AC_ARG_WITH(libslax-prefix, 220 [ --with-libslax-prefix=[PFX] Specify location of libslax config], 221 LIBSLAX_CONFIG_PREFIX=$withval 222) 223 224AC_MSG_CHECKING(for libslax) 225if test "x$LIBSLAX_CONFIG_PREFIX" != "x" 226then 227 SLAX_CONFIG=${LIBSLAX_CONFIG_PREFIX}/bin/slax-config 228else 229 SLAX_CONFIG=slax-config 230fi 231 232dnl 233dnl make sure slax-config is executable, 234dnl test version and init our variables 235dnl 236 237if ${SLAX_CONFIG} --libs > /dev/null 2>&1 238then 239 LIBSLAX_VERSION=`$SLAX_CONFIG --version` 240 SLAX_BINDIR="`$SLAX_CONFIG --bindir | head -1`" 241 SLAX_OXTRADOCDIR="`$SLAX_CONFIG --oxtradoc | head -1`" 242 AC_MSG_RESULT($LIBSLAX_VERSION found) 243 HAVE_OXTRADOC=yes 244else 245 LIBSLAX_VERSION= 246 SLAX_BINDIR= 247 SLAX_OXTRADOCDIR= 248 AC_MSG_RESULT([no]) 249 HAVE_OXTRADOC=no 250fi 251AM_CONDITIONAL([HAVE_OXTRADOC], [test "$HAVE_OXTRADOC" != "no"]) 252 253AC_SUBST(SLAX_BINDIR) 254AC_SUBST(SLAX_OXTRADOCDIR) 255 256AC_MSG_CHECKING([whether to build with warnings]) 257AC_ARG_ENABLE([warnings], 258 [ --enable-warnings Turn on compiler warnings], 259 [LIBXO_WARNINGS=$enableval], 260 [LIBXO_WARNINGS=no]) 261AC_MSG_RESULT([$LIBXO_WARNINGS]) 262AM_CONDITIONAL([LIBXO_WARNINGS_HIGH], [test "$LIBXO_WARNINGS" != "no"]) 263 264AC_MSG_CHECKING([whether to build with debugging]) 265AC_ARG_ENABLE([debug], 266 [ --enable-debug Turn on debugging], 267 [LIBXO_DEBUG=yes; AC_DEFINE([LIBXO_DEBUG], [1], [Enable debugging])], 268 [LIBXO_DEBUG=no]) 269AC_MSG_RESULT([$LIBXO_DEBUG]) 270AM_CONDITIONAL([LIBXO_DEBUG], [test "$LIBXO_DEBUG" != "no"]) 271 272AC_MSG_CHECKING([whether to build with text-only rendering]) 273AC_ARG_ENABLE([text-only], 274 [ --enable-text-only Turn on text-only rendering], 275 [LIBXO_TEXT_ONLY=yes; AC_DEFINE([LIBXO_TEXT_ONLY], [1], [Enable text-only rendering])], 276 [LIBXO_TEXT_ONLY=no]) 277AC_MSG_RESULT([$LIBXO_TEXT_ONLY]) 278AM_CONDITIONAL([LIBXO_TEXT_ONLY], [test "$LIBXO_TEXT_ONLY" != "no"]) 279 280AC_MSG_CHECKING([whether to build with local wcwidth implementation]) 281AC_ARG_ENABLE([wcwidth], 282 [ --disable-wcwidth Disable local wcwidth implementation], 283 [LIBXO_WCWIDTH=$enableval], 284 [LIBXO_WCWIDTH=yes]) 285AC_MSG_RESULT([$LIBXO_WCWIDTH]) 286if test "${LIBXO_WCWIDTH}" != "no"; then 287 AC_DEFINE([LIBXO_WCWIDTH], [1], [Enable local wcwidth implementation]) 288fi 289 290AC_CHECK_LIB([m], [lrint]) 291AM_CONDITIONAL([HAVE_LIBM], [test "$HAVE_LIBM" != "no"]) 292 293AC_MSG_CHECKING([compiler for gcc]) 294HAVE_GCC=no 295if test "${CC}" != ""; then 296 HAVE_GCC=`${CC} --version 2>&1 | grep GCC` 297 if test "${HAVE_GCC}" != ""; then 298 HAVE_GCC=yes 299 else 300 HAVE_GCC=no 301 fi 302fi 303AC_MSG_RESULT([$HAVE_GCC]) 304AM_CONDITIONAL([HAVE_GCC], [test "$HAVE_GCC" = "yes"]) 305 306AC_MSG_CHECKING([whether to build with printflike]) 307AC_ARG_ENABLE([printflike], 308 [ --enable-printflike Enable use of GCC __printflike attribute], 309 [HAVE_PRINTFLIKE=yes; 310 AC_DEFINE([HAVE_PRINTFLIKE], [1], [Support printflike])], 311 [HAVE_PRINTFLIKE=no]) 312AC_MSG_RESULT([$HAVE_PRINTFLIKE]) 313AM_CONDITIONAL([HAVE_PRINTFLIKE], [test "$HAVE_PRINTFLIKE" != ""]) 314 315AC_MSG_CHECKING([whether to build with LIBXO_OPTIONS]) 316AC_ARG_ENABLE([libxo-options], 317 [ --disable-libxo-options Turn off support for LIBXO_OPTIONS], 318 [LIBXO_OPTS=$enableval], 319 [LIBXO_OPTS=yes]) 320AC_MSG_RESULT([$LIBXO_OPTS]) 321AM_CONDITIONAL([NO_LIBXO_OPTIONS], [test "$LIBXO_OPTS" != "yes"]) 322 323case $host_os in 324 darwin*) 325 LIBTOOL=glibtool 326 XO_LIBEXT=dylib 327 ;; 328 Linux*|linux*) 329 CFLAGS="-D_GNU_SOURCE $CFLAGS" 330 LDFLAGS=-ldl 331 XO_LIBEXT=so 332 ;; 333 cygwin*|CYGWIN*) 334 LDFLAGS=-no-undefined 335 XO_LIBEXT=ddl 336 ;; 337esac 338 339case $prefix in 340 NONE) 341 prefix=/usr/local 342 ;; 343esac 344 345XO_LIBS=-lxo 346XO_SRCDIR=${srcdir} 347XO_LIBDIR=${libdir} 348XO_BINDIR=${bindir} 349XO_INCLUDEDIR=${includedir} 350 351AC_SUBST(XO_SRCDIR) 352AC_SUBST(XO_LIBDIR) 353AC_SUBST(XO_BINDIR) 354AC_SUBST(XO_INCLUDEDIR) 355AC_SUBST(XO_LIBEXT) 356 357AC_ARG_WITH(encoder-dir, 358 [ --with-encoder-dir=[DIR] Specify location of encoder libraries], 359 [XO_ENCODERDIR=$withval], 360 [XO_ENCODERDIR=$libdir/libxo/encoder] 361) 362AC_SUBST(XO_ENCODERDIR) 363 364AC_ARG_WITH(share-dir, 365 [ --with-share-dir=[DIR] Specify location of shared files], 366 [XO_SHAREDIR=$withval], 367 [XO_SHAREDIR=$datarootdir/libxo] 368) 369XO_SHAREDIR=`echo $XO_SHAREDIR | sed "s;\\${prefix};$prefix;"` 370AC_SUBST(XO_SHAREDIR) 371 372dnl for the spec file 373RELDATE=`date +'%Y-%m-%d%n'` 374AC_SUBST(RELDATE) 375 376AC_MSG_RESULT(Using configure dir $ac_abs_confdir) 377 378if test -d $ac_abs_confdir/.git ; then 379 extra=`git branch | awk '/\*/ { print $2 }'` 380 if test "$extra" != "" -a "$extra" != "master" 381 then 382 LIBXO_VERSION_EXTRA="-git-$extra" 383 fi 384fi 385 386LIBXO_VERSION=$PACKAGE_VERSION 387LIBXO_VERSION_NUMBER=VERSION_TO_NUMBER(echo $PACKAGE_VERSION) 388AC_SUBST(LIBXO_VERSION) 389AC_SUBST(LIBXO_VERSION_NUMBER) 390AC_SUBST(LIBXO_VERSION_EXTRA) 391 392AC_DEFINE_UNQUOTED(LIBXO_VERSION, ["$LIBXO_VERSION"], 393 [Version number as dotted value]) 394AC_DEFINE_UNQUOTED(LIBXO_VERSION_NUMBER, [$LIBXO_VERSION_NUMBER], 395 [Version number as a number]) 396AC_DEFINE_UNQUOTED(LIBXO_VERSION_STRING, ["$LIBXO_VERSION_NUMBER"], 397 [Version number as string]) 398AC_DEFINE_UNQUOTED(LIBXO_VERSION_EXTRA, ["$LIBXO_VERSION_EXTRA"], 399 [Version number extra information]) 400 401AC_CONFIG_HEADERS([libxo/xo_config.h]) 402AC_CONFIG_FILES([ 403 Makefile 404 libxo-config 405 xohtml/xohtml.sh 406 libxo/Makefile 407 libxo/add.man 408 encoder/Makefile 409 encoder/cbor/Makefile 410 encoder/test/Makefile 411 xo/Makefile 412 xolint/Makefile 413 xohtml/Makefile 414 xopo/Makefile 415 packaging/libxo.pc 416 doc/Makefile 417 tests/Makefile 418 tests/core/Makefile 419 tests/gettext/Makefile 420 tests/xo/Makefile 421 packaging/libxo.spec 422 packaging/libxo.rb.base 423]) 424AC_OUTPUT 425 426AC_MSG_NOTICE([summary of build options: 427 428 libxo version: ${VERSION} ${LIBXO_VERSION_EXTRA} 429 host type: ${host} / ${host_os} 430 install prefix: ${prefix} 431 srcdir: ${XO_SRCDIR} 432 libdir: ${XO_LIBDIR} 433 bindir: ${XO_BINDIR} 434 includedir: ${XO_INCLUDEDIR} 435 share dir: ${XO_SHAREDIR} 436 extensions dir: ${XO_ENCODERDIR} 437 oxtradoc dir: ${SLAX_OXTRADOCDIR} 438 439 compiler: ${CC} (${HAVE_GCC:-no}) 440 compiler flags: ${CFLAGS} 441 library types: Shared=${enable_shared}, Static=${enable_static} 442 443 warnings: ${LIBXO_WARNINGS:-no} 444 debug: ${LIBXO_DEBUG:-no} 445 printf-like: ${HAVE_PRINTFLIKE:-no} 446 libxo-options: ${LIBXO_OPTS:-no} 447 text-only: ${LIBXO_TEXT_ONLY:-no} 448 gettext: ${HAVE_GETTEXT:-no} (${GETTEXT_PREFIX}) 449 isthreaded: ${HAVE_ISTHREADED:-no} 450 thread-local: ${THREAD_LOCAL:-no} 451 local wcwidth: ${LIBXO_WCWIDTH:-no} 452]) 453