Blame configure.ac

Packit eed199
#                                               -*- Autoconf -*-
Packit eed199
# Process this file with autoconf to produce a configure script.
Packit eed199
Packit eed199
AC_PREREQ([2.63])
Packit eed199
AC_INIT([libmaxminddb], [1.2.0], [support@maxmind.com])
Packit eed199
AC_CONFIG_SRCDIR([include/maxminddb.h])
Packit eed199
AC_CONFIG_HEADERS([config.h include/maxminddb_config.h])
Packit eed199
Packit eed199
PKG_PROG_PKG_CONFIG
Packit eed199
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_SUBST([pkgconfigdir], [${libdir}/pkgconfig])])
Packit eed199
AC_CONFIG_FILES([src/libmaxminddb.pc])
Packit eed199
Packit eed199
LT_INIT
Packit eed199
AM_INIT_AUTOMAKE(foreign m4_esyscmd([case `automake --version | head -n 1` in
Packit eed199
                                     *1.14*) echo subdir-objects;;
Packit eed199
                                     *1.11*);;
Packit eed199
                                     *) echo serial-tests;;
Packit eed199
                                     esac]))
Packit eed199
AC_PROG_LIBTOOL
Packit eed199
# Checks for programs.
Packit eed199
AC_PROG_CC_C99
Packit eed199
Packit eed199
# Copied from http://stackoverflow.com/a/10682813/9832 and tweaked for C (as
Packit eed199
# opposed to C++)
Packit eed199
#
Packit eed199
# AX_CHECK_CFLAGS(ADDITIONAL-CFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
Packit eed199
#
Packit eed199
# checks whether the $(CC) compiler accepts the ADDITIONAL-CFLAGS
Packit eed199
# if so, they are added to the CXXFLAGS
Packit eed199
AC_DEFUN([AX_CHECK_CFLAGS],
Packit eed199
[
Packit eed199
  AC_MSG_CHECKING([whether compiler accepts "$1"])
Packit eed199
  cat > conftest.c << EOF
Packit eed199
  int main(){
Packit eed199
    return 0;
Packit eed199
  }
Packit eed199
EOF
Packit eed199
  if $CC $CFLAGS -o conftest.o conftest.c [$1] > /dev/null 2>&1
Packit eed199
  then
Packit eed199
    AC_MSG_RESULT([yes])
Packit eed199
    CFLAGS="${CFLAGS} [$1]"
Packit eed199
    [$2]
Packit eed199
  else
Packit eed199
    AC_MSG_RESULT([no])
Packit eed199
   [$3]
Packit eed199
  fi
Packit eed199
])dnl AX_CHECK_CFLAGS
Packit eed199
Packit eed199
AX_CHECK_CFLAGS([-fms-extensions])
Packit eed199
Packit eed199
# We will add this back for non-debug builds in the common.mk file
Packit eed199
CFLAGS=`echo ${CFLAGS} | sed 's/-O2//'`
Packit eed199
CXXFLAGS=`echo ${CXXFLAGS} | sed 's/-O2//'`
Packit eed199
Packit eed199
# autoconf insists on giving us gnu99 if it's available
Packit eed199
CC=`echo ${CC} | sed 's/-std=gnu99/-std=c99/'`
Packit eed199
Packit eed199
AC_C_RESTRICT
Packit eed199
Packit eed199
AC_CHECK_HEADERS([arpa/inet.h assert.h fcntl.h inttypes.h libgen.h math.h netdb.h netinet/in.h stdarg.h stdbool.h stdint.h stdio.h stdlib.h string.h sys/mman.h sys/socket.h sys/stat.h sys/time.h sys/types.h unistd.h])
Packit eed199
Packit eed199
# configure generates an invalid config for MinGW because of the type checks
Packit eed199
# so we only run them on non MinGW-Systems. For MinGW we also need to link
Packit eed199
# against ws2_32.
Packit eed199
AC_CANONICAL_HOST
Packit eed199
case $host_os in
Packit eed199
        mingw*)
Packit eed199
                LDFLAGS="-lws2_32"
Packit eed199
        ;;
Packit eed199
        *)
Packit eed199
                AC_TYPE_OFF_T
Packit eed199
                AC_TYPE_SIZE_T
Packit eed199
                AC_TYPE_SSIZE_T
Packit eed199
                AC_TYPE_UINT8_T
Packit eed199
                AC_TYPE_UINT32_T
Packit eed199
                AC_TYPE_UINT64_T
Packit eed199
        ;;
Packit eed199
esac
Packit eed199
Packit eed199
Packit eed199
# This check is backwards in order to make life easier for people writing
Packit eed199
# extensions in other languages that link to this library. If they want to
Packit eed199
# simply assume that they are using a newish compiler, they don't need to
Packit eed199
# check for this type nor do they need to define anything on the CLI. They'll
Packit eed199
# just get code that assumes this type exists.
Packit eed199
AC_CHECK_TYPE(
Packit eed199
        [unsigned __int128],
Packit eed199
        [AC_DEFINE([MMDB_UINT128_IS_BYTE_ARRAY], [0], [Missing the unsigned __int128 type])],
Packit eed199
        [AC_CHECK_TYPE(
Packit eed199
                [unsigned int __attribute__((mode(TI)))],
Packit eed199
                [AC_DEFINE([MMDB_UINT128_IS_BYTE_ARRAY], [0], [Missing the unsigned __int128 type])
Packit eed199
                 AC_DEFINE([MMDB_UINT128_USING_MODE], [1], [int128 types are available with __attribute__((mode(TI)))])],
Packit eed199
                [AC_DEFINE([MMDB_UINT128_IS_BYTE_ARRAY], [1], [Missing the unsigned __int128 type])])])
Packit eed199
Packit eed199
AC_CHECK_TYPES([boolean])
Packit eed199
Packit eed199
AC_CHECK_FUNC(
Packit eed199
        [open_memstream],
Packit eed199
        [AC_DEFINE([HAVE_OPEN_MEMSTREAM], [1], [Has an open_memstream() function])])
Packit eed199
Packit eed199
AC_FUNC_MALLOC
Packit eed199
AC_FUNC_MMAP
Packit eed199
Packit eed199
AC_SEARCH_LIBS([fabs], [m])
Packit eed199
AC_SEARCH_LIBS([fabsf], [m])
Packit eed199
AC_SEARCH_LIBS([getaddrinfo], [socket])
Packit eed199
Packit eed199
AC_ARG_ENABLE(
Packit eed199
        [debug],
Packit eed199
        [  --enable-debug    Turn on debugging],
Packit eed199
        [case "${enableval}" in
Packit eed199
          yes) debug=true ;;
Packit eed199
          no)  debug=false ;;
Packit eed199
          *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
Packit eed199
        esac],[debug=false])
Packit eed199
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
Packit eed199
Packit eed199
AC_CONFIG_FILES([Makefile
Packit eed199
                 src/Makefile
Packit eed199
                 bin/Makefile
Packit eed199
                 t/Makefile])
Packit eed199
AC_OUTPUT