1m4_define([jq_version], 2 m4_esyscmd_s([(git rev-parse --verify -q jq-1.0 > /dev/null && 3 (git describe --tags --dirty --match 'jq-*'|sed 's/^jq-//')) || 4 echo `git rev-parse --abbrev-ref HEAD`-`git describe --always --dirty`]))) 5 6AC_INIT([jq], [jq_version], [https://github.com/stedolan/jq/issues], 7 [jq], [https://stedolan.github.io/jq]) 8 9m4_include([m4/ax_compare_version.m4]) 10m4_include([m4/ax_prog_bison_version.m4]) 11 12dnl Created autoconf implementation thompson@dtosolutions, 26NOV12 13AC_PREREQ([2.64]) 14AC_CONFIG_AUX_DIR([config]) 15AM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall]) 16AM_SILENT_RULES([yes]) 17AM_PROG_AR 18AM_MAINTAINER_MODE([enable]) 19AC_PROG_CC 20AC_PROG_CC_STDC 21AC_PROG_CPP_WERROR 22AC_PROG_YACC 23AC_OBJEXT 24AC_EXEEXT 25LT_INIT([shared static win32-dll]) 26AM_PROG_CC_C_O 27 28 29dnl couldn't use AM_PROG_LEX as it doesn't support header files like the 30dnl AC_PROG_YACC macros... 31 32dnl check bison version 33 34if test "$USE_MAINTAINER_MODE" = yes; then 35 if test "$YACC" != "bison -y"; then 36 AC_MSG_CHECKING([bison version]) 37 AC_MSG_RESULT([not bison]) 38 else 39 AX_PROG_BISON_VERSION([3], 40 [], 41 [AC_MSG_ERROR([You need bison version 3.0 or greater, or use --disable-maintainer-mode.])]) 42 fi 43 44 AC_CHECK_PROGS(LEX, flex lex) 45fi 46 47dnl Check for valgrind 48AC_CHECK_PROGS(valgrind_cmd, valgrind) 49if test "x$valgrind_cmd" = "x" ; then 50 AC_MSG_WARN([valgrind is required to test jq.]) 51fi 52AC_CHECK_FUNCS(memmem) 53AC_CHECK_FUNCS(mkstemp) 54 55AC_CHECK_HEADER("shlwapi.h",[have_win32=1;]) 56AM_CONDITIONAL([WIN32], [test "x$have_win32" = x1]) 57 58dnl Running tests with Valgrind is slow. It is faster to iterate on 59dnl code without Valgrind until tests pass, then enable Valgrind and 60dnl fix leaks. 61AC_ARG_ENABLE([valgrind], 62 AC_HELP_STRING([--disable-valgrind], [do not run tests under Valgrind])) 63 64dnl Running tests with Valgrind is slow; address sanitizer (ASAN) is 65dnl faster. 66AC_ARG_ENABLE([asan], 67 AC_HELP_STRING([--enable-asan], [enable address sanitizer])) 68 69dnl Undefined Behavior Sanitizer 70AC_ARG_ENABLE([ubsan], 71 AC_HELP_STRING([--enable-ubsan], [enable undefined behavior sanitizer])) 72 73dnl Code coverage 74AC_ARG_ENABLE([gcov], 75 AC_HELP_STRING([--enable-gcov], [enable gcov code coverage tool])) 76 77dnl Don't attempt to build docs if there's no Ruby lying around 78AC_ARG_ENABLE([docs], 79 AC_HELP_STRING([--disable-docs], [don't build docs])) 80 81dnl Don't attempt to build the error injection object (if there is no LD_PRELOAD support) 82AC_ARG_ENABLE([error-injection], 83 AC_HELP_STRING([--enable-error-injection], [build and test with error injection])) 84 85dnl Enable building all static 86AC_ARG_ENABLE([all-static], 87 AC_HELP_STRING([--enable-all-static], [link jq with static libraries only])) 88 89AS_IF([test "x$enable_docs" != "xno"],[ 90 AC_CHECK_PROGS(bundle_cmd, bundle) 91 92 AC_CACHE_CHECK([for Ruby dependencies], [jq_cv_ruby_deps], 93 [jq_cv_ruby_deps=yes; 94 AS_IF([test "x$bundle_cmd" = "x" || \ 95 ! bmsg="`cd ${srcdir}/docs; "$bundle_cmd" check 2>/dev/null`"],[ 96 AC_MSG_WARN([$bmsg]) 97 cat <<EOF 98***************************************************************** 99* Ruby dependencies for building jq documentation not found. * 100* You can still build, install and hack on jq, but the manpage * 101* will not be rebuilt and some of the tests will not run. * 102* See docs/README.md for how to install the docs dependencies. * 103***************************************************************** 104EOF 105 jq_cv_ruby_deps=no 106 ])]) 107 108 if test "x$jq_cv_ruby_deps" != "xyes"; then 109 enable_docs=no 110 fi 111]) 112 113AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" != xno]) 114AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes]) 115AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = xyes]) 116AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes]) 117AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno]) 118AM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test "x$enable_error_injection" = xyes]) 119AM_CONDITIONAL([ENABLE_ALL_STATIC], [test "x$enable_all_static" = xyes]) 120 121AC_FUNC_ALLOCA 122 123AC_FIND_FUNC([isatty], [c], [#include <unistd.h>], [0]) 124AC_FIND_FUNC([_isatty], [c], [#include <io.h>], [0]) 125AC_FIND_FUNC([strptime], [c], [#include <time.h>], [0, 0, 0]) 126AC_FIND_FUNC([strftime], [c], [#include <time.h>], [0, 0, 0, 0]) 127AC_FIND_FUNC([timegm], [c], [#include <time.h>], [0]) 128AC_FIND_FUNC([gmtime_r], [c], [#include <time.h>], [0, 0]) 129AC_FIND_FUNC([gmtime], [c], [#include <time.h>], [0]) 130AC_FIND_FUNC([localtime_r], [c], [#include <time.h>], [0, 0]) 131AC_FIND_FUNC([localtime], [c], [#include <time.h>], [0]) 132AC_FIND_FUNC([gettimeofday], [c], [#include <time.h>], [0, 0]) 133AC_CHECK_MEMBER([struct tm.tm_gmtoff], [AC_DEFINE([HAVE_TM_TM_GMT_OFF],1,[Define to 1 if the system has the tm_gmt_off field in struct tm])], 134 [], [[#include <time.h>]]) 135AC_CHECK_MEMBER([struct tm.__tm_gmtoff], [AC_DEFINE([HAVE_TM___TM_GMT_OFF],1,[Define to 1 if the system has the __tm_gmt_off field in struct tm])], 136 [], [[#include <time.h>]]) 137 138AC_ARG_ENABLE([pthread-tls], 139 [AC_HELP_STRING([--enable-pthread-tls], 140 [Enable use of pthread thread local storage])], 141 [], 142 [enable_pthread_tls=no]) 143 144if test $enable_pthread_tls = yes; then 145 AC_FIND_FUNC([pthread_key_create], [pthread], [#include <pthread.h>], [NULL, NULL]) 146 AC_FIND_FUNC([pthread_once], [pthread], [#include <pthread.h>], [NULL, NULL]) 147 AC_FIND_FUNC([atexit], [pthread], [#include <stdlib.h>], [NULL]) 148fi 149 150dnl libm math.h functions 151AC_CHECK_MATH_FUNC(acos) 152AC_CHECK_MATH_FUNC(acosh) 153AC_CHECK_MATH_FUNC(asin) 154AC_CHECK_MATH_FUNC(asinh) 155AC_CHECK_MATH_FUNC(atan2) 156AC_CHECK_MATH_FUNC(atan) 157AC_CHECK_MATH_FUNC(atanh) 158AC_CHECK_MATH_FUNC(cbrt) 159AC_CHECK_MATH_FUNC(ceil) 160AC_CHECK_MATH_FUNC(copysign) 161AC_CHECK_MATH_FUNC(cos) 162AC_CHECK_MATH_FUNC(cosh) 163AC_CHECK_MATH_FUNC(drem) 164AC_CHECK_MATH_FUNC(erf) 165AC_CHECK_MATH_FUNC(erfc) 166AC_CHECK_MATH_FUNC(exp10) 167AC_CHECK_MATH_FUNC(exp2) 168AC_CHECK_MATH_FUNC(exp) 169AC_CHECK_MATH_FUNC(expm1) 170AC_CHECK_MATH_FUNC(fabs) 171AC_CHECK_MATH_FUNC(fdim) 172AC_CHECK_MATH_FUNC(floor) 173AC_CHECK_MATH_FUNC(fma) 174AC_CHECK_MATH_FUNC(fmax) 175AC_CHECK_MATH_FUNC(fmin) 176AC_CHECK_MATH_FUNC(fmod) 177AC_CHECK_MATH_FUNC(frexp) 178AC_CHECK_MATH_FUNC(gamma) 179AC_CHECK_MATH_FUNC(hypot) 180AC_CHECK_MATH_FUNC(j0) 181AC_CHECK_MATH_FUNC(j1) 182AC_CHECK_MATH_FUNC(jn) 183AC_CHECK_MATH_FUNC(ldexp) 184AC_CHECK_MATH_FUNC(lgamma) 185AC_CHECK_MATH_FUNC(log10) 186AC_CHECK_MATH_FUNC(log1p) 187AC_CHECK_MATH_FUNC(log2) 188AC_CHECK_MATH_FUNC(log) 189AC_CHECK_MATH_FUNC(logb) 190AC_CHECK_MATH_FUNC(modf) 191AC_CHECK_MATH_FUNC(lgamma_r) 192AC_CHECK_MATH_FUNC(nearbyint) 193AC_CHECK_MATH_FUNC(nextafter) 194AC_CHECK_MATH_FUNC(nexttoward) 195AC_CHECK_MATH_FUNC(pow10) # Not available with glibc version >= 2.27 196AC_CHECK_MATH_FUNC(pow) 197AC_CHECK_MATH_FUNC(remainder) 198AC_CHECK_MATH_FUNC(rint) 199AC_CHECK_MATH_FUNC(round) 200AC_CHECK_MATH_FUNC(scalb) 201AC_CHECK_MATH_FUNC(scalbln) 202AC_CHECK_MATH_FUNC(significand) 203AC_CHECK_MATH_FUNC(sin) 204AC_CHECK_MATH_FUNC(sinh) 205AC_CHECK_MATH_FUNC(sqrt) 206AC_CHECK_MATH_FUNC(tan) 207AC_CHECK_MATH_FUNC(tanh) 208AC_CHECK_MATH_FUNC(tgamma) 209AC_CHECK_MATH_FUNC(trunc) 210AC_CHECK_MATH_FUNC(y0) 211AC_CHECK_MATH_FUNC(y1) 212AC_CHECK_MATH_FUNC(yn) 213 214dnl Thread local storage 215have___thread=no 216AC_MSG_CHECKING(for thread-local storage) 217AC_LINK_IFELSE([AC_LANG_SOURCE([ 218static __thread int x ; 219int main () { x = 123; return x; } 220])], have___thread=yes) 221if test $have___thread = yes; then 222 AC_DEFINE([HAVE___THREAD],1,[Define to 1 if the system supports __thread]) 223fi 224AC_MSG_RESULT($have___thread) 225 226AC_C_BIGENDIAN( 227 AC_DEFINE([IEEE_MC68k], 1, [machine is bigendian]), 228 AC_DEFINE([IEEE_8087], 1, [machine is littleendian]), 229 AC_MSG_ERROR(unknown endianess), 230 AC_MSG_ERROR(universial endianess not supported) 231) 232 233dnl Oniguruma 234AC_ARG_WITH([oniguruma], 235 [AS_HELP_STRING([--with-oniguruma=prefix], 236 [try this for a non-standard install prefix of the oniguruma library])], , 237 [with_oniguruma=yes]) 238 239onig_CFLAGS= 240onig_LDFLAGS= 241build_oniguruma=no 242AS_IF([test "x$with_oniguruma" != xno], [ 243 save_CFLAGS="$CFLAGS" 244 save_LDFLAGS="$LDFLAGS" 245 AS_IF([test "x$with_oniguruma" != xyes], [ 246 AS_IF([test "x$with_oniguruma" = xbuiltin], [ 247 build_oniguruma=yes 248 ], [ 249 onig_CFLAGS="-I${with_oniguruma}/include" 250 onig_LDFLAGS="-L${with_oniguruma}/lib" 251 ]) 252 ]) 253 AS_IF([test "x$build_oniguruma" = xno], [ 254 # check for ONIGURUMA library, either in /usr or where requested 255 CFLAGS="$CFLAGS $onig_CFLAGS" 256 LDFLAGS="$LDFLAGS $onig_LDFLAGS" 257 AC_CHECK_HEADER("oniguruma.h", 258 AC_CHECK_LIB([onig],[onig_version])) 259 # handle check results 260 AS_IF([test "x$ac_cv_lib_onig_onig_version" != "xyes"], [ 261 build_oniguruma=yes 262 AC_MSG_NOTICE([Oniguruma was not found. Will use the packaged oniguruma.]) 263 ]) 264 ]) 265 AS_IF([test "x$build_oniguruma" = xyes -a -f "${srcdir}/modules/oniguruma/configure.ac" ], [ 266 onig_CFLAGS="-I${srcdir}/modules/oniguruma/src" 267 onig_LDFLAGS="-L${srcdir}/modules/oniguruma/src -Wl,-rpath,${libdir}" 268 AC_CONFIG_SUBDIRS([modules/oniguruma]) 269 AC_DEFINE([HAVE_LIBONIG],1,[Define to 1 if the system includes libonig]) 270 ]) 271 CFLAGS="$save_CFLAGS" 272 LDFLAGS="$save_LDFLAGS" 273]) 274AC_SUBST(onig_CFLAGS) 275AC_SUBST(onig_LDFLAGS) 276 277AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes]) 278AC_SUBST([BUNDLER], ["$bundle_cmd"]) 279 280AC_CONFIG_MACRO_DIR([config/m4]) 281AC_CONFIG_FILES([Makefile]) 282AC_OUTPUT 283 284