Blame configure.ac

Packit 5e354d
# configure.ac                                          -*- Autoconf -*-
Packit 5e354d
# Copyright (C) 2011, 2012 g10 Code GmbH
Packit 5e354d
#
Packit 5e354d
# This file is part of nPth.
Packit 5e354d
#
Packit 5e354d
# nPth is free software; you can redistribute it and/or modify it
Packit 5e354d
# under the terms of the GNU Lesser General Public License as
Packit 5e354d
# published by the Free Software Foundation; either version 2.1 of the
Packit 5e354d
# License, or (at your option) any later version.
Packit 5e354d
#
Packit 5e354d
# nPth is distributed in the hope that it will be useful, but WITHOUT
Packit 5e354d
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5e354d
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
Packit 5e354d
# Public License for more details.
Packit 5e354d
#
Packit 5e354d
# You should have received a copy of the GNU Lesser General Public
Packit 5e354d
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
Packit 5e354d
Packit 5e354d
# Process this file with autoconf to produce a configure script.
Packit 5e354d
Packit 5e354d
AC_PREREQ([2.67])
Packit 5e354d
min_automake_version="1.14"
Packit 5e354d
Packit 5e354d
# To build a release you need to create a tag with the version number
Packit 5e354d
# (git tag -s npth-n.m) and run "./autogen.sh --force".  Please bump
Packit 5e354d
# the version number immediately after the release and do another
Packit 5e354d
# commit and push so that the git magic is able to work.
Packit 5e354d
# See below for the LT versions.
Packit 5e354d
m4_define(my_version, [1.5])
Packit 5e354d
Packit 5e354d
# Below is m4 magic to extract and compute the git revision number,
Packit 5e354d
# the decimalized short revision number, a beta version string and a
Packit 5e354d
# flag indicating a development version (my_isgit). The latter works
Packit 5e354d
# by requiring the final tag in the repository.
Packit 5e354d
m4_define([git_revision],
Packit 5e354d
          m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
Packit 5e354d
m4_define([git_revision_dec],
Packit 5e354d
          m4_esyscmd_s([echo $((0x$(echo ]git_revision[|head -c 4)))]))
Packit 5e354d
m4_define([git_betastring],
Packit 5e354d
          m4_esyscmd_s([git describe --match 'npth-[0-9].*[0-9]' --long|\
Packit 5e354d
                        awk -F- '$3!=0{print"-beta"$3}']))
Packit 5e354d
m4_define([my_isgit],m4_if(git_betastring,[],[no],[yes]))
Packit 5e354d
m4_define([my_full_version],[my_version[]git_betastring])
Packit 5e354d
Packit 5e354d
AC_INIT([npth],[my_full_version],[gnupg-devel@gnupg.org])
Packit 5e354d
Packit 5e354d
# LT Version numbers, remember to change them just *before* a release.
Packit 5e354d
#   (Code changed:			REVISION++)
Packit 5e354d
#   (Interfaces added/removed/changed:	CURRENT++, REVISION=0)
Packit 5e354d
#   (Interfaces added:			AGE++)
Packit 5e354d
#   (Interfaces removed/changed:	AGE=0)
Packit 5e354d
#
Packit 5e354d
LIBNPTH_LT_CURRENT=1
Packit 5e354d
LIBNPTH_LT_AGE=1
Packit 5e354d
LIBNPTH_LT_REVISION=1
Packit 5e354d
Packit 5e354d
# If the API is changed in an incompatible way: increment the next counter.
Packit 5e354d
NPTH_CONFIG_API_VERSION=1
Packit 5e354d
##############################################
Packit 5e354d
Packit 5e354d
PACKAGE=$PACKAGE_NAME
Packit 5e354d
VERSION=$PACKAGE_VERSION
Packit 5e354d
Packit 5e354d
AC_CONFIG_AUX_DIR([build-aux])
Packit 5e354d
AC_CONFIG_SRCDIR([src/npth.c])
Packit 5e354d
AC_CONFIG_HEADERS([config.h])
Packit 5e354d
AC_CONFIG_MACRO_DIR([m4])
Packit 5e354d
AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
Packit 5e354d
AM_MAINTAINER_MODE
Packit 5e354d
AC_CANONICAL_HOST
Packit 5e354d
AM_SILENT_RULES
Packit 5e354d
Packit 5e354d
# Enable GNU extensions on systems that have them.
Packit 5e354d
AC_GNU_SOURCE
Packit 5e354d
Packit 5e354d
AH_VERBATIM([_REENTRANT],
Packit 5e354d
[#ifndef _REENTRANT
Packit 5e354d
# define _REENTRANT 1
Packit 5e354d
#endif])
Packit 5e354d
Packit 5e354d
# Checks for programs.
Packit 5e354d
AC_PROG_CC
Packit 5e354d
Packit 5e354d
AC_SUBST(LIBNPTH_LT_CURRENT)
Packit 5e354d
AC_SUBST(LIBNPTH_LT_AGE)
Packit 5e354d
AC_SUBST(LIBNPTH_LT_REVISION)
Packit 5e354d
Packit 5e354d
AC_SUBST(PACKAGE)
Packit 5e354d
AC_SUBST(VERSION)
Packit 5e354d
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
Packit 5e354d
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
Packit 5e354d
Packit 5e354d
run_tests="yes"
Packit 5e354d
AC_ARG_ENABLE(tests,
Packit 5e354d
  AC_HELP_STRING([--disable-tests], [disable tests]),
Packit 5e354d
         run_tests=$enableval)
Packit 5e354d
AM_CONDITIONAL(RUN_TESTS, test "$run_tests" = "yes")
Packit 5e354d
Packit 5e354d
Packit 5e354d
# Don't default to build static libs.
Packit 5e354d
LT_PREREQ([2.2.6])
Packit 5e354d
LT_INIT([win32-dll disable-static])
Packit 5e354d
LT_LANG([Windows Resource])
Packit 5e354d
Packit 5e354d
Packit 5e354d
# For now we hardcode the use of version scripts.  It would be better
Packit 5e354d
# to write a test for this or even implement this within libtool.
Packit 5e354d
have_ld_version_script=no
Packit 5e354d
case "${host}" in
Packit 5e354d
    *-*-linux*)
Packit 5e354d
        have_ld_version_script=yes
Packit 5e354d
        ;;
Packit 5e354d
    *-*-gnu*)
Packit 5e354d
        have_ld_version_script=yes
Packit 5e354d
        ;;
Packit 5e354d
    *-apple-darwin*)
Packit 5e354d
        AC_SEARCH_LIBS([dispatch_semaphore_create],[dispatch],
Packit 5e354d
        [AC_DEFINE([HAVE_LIB_DISPATCH],1,[Defined if we have libdispatch])])
Packit 5e354d
        ;;
Packit 5e354d
    *-*-aix*)
Packit 5e354d
        have_fork_unsafe_semaphore=yes
Packit 5e354d
        ;;
Packit 5e354d
    *-*-dragonfly*|*-*-freebsd*|*-*-netbsd*)
Packit 5e354d
        LIBS="-lpthread $LIBS"
Packit 5e354d
        AC_SEARCH_LIBS([sem_init],[rt])
Packit 5e354d
        ;;
Packit 5e354d
esac
Packit 5e354d
Packit 5e354d
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
Packit 5e354d
if test "$have_fork_unsafe_semaphore" = yes; then
Packit 5e354d
   AC_DEFINE(HAVE_FORK_UNSAFE_SEMAPHORE, 1, [Defined if we have fork-unsafe semaphore])
Packit 5e354d
fi
Packit 5e354d
Packit 5e354d
# Set some default values
Packit 5e354d
config_libs="-lnpth $LIBS"
Packit 5e354d
have_w32_system=no
Packit 5e354d
have_w32ce_system=no
Packit 5e354d
have_w64_system=no
Packit 5e354d
Packit 5e354d
# Define OS macros
Packit 5e354d
case "${host}" in
Packit 5e354d
    x86_64-*mingw32*)
Packit 5e354d
        have_w64_system=yes
Packit 5e354d
        ;;
Packit 5e354d
    *-mingw32ce*)
Packit 5e354d
        have_w32ce_system=yes
Packit 5e354d
        ;;
Packit 5e354d
esac
Packit 5e354d
case "${host}" in
Packit 5e354d
    *-mingw32ce*|*-mingw32*)
Packit 5e354d
        have_w32_system=yes
Packit 5e354d
        ;;
Packit 5e354d
    *)
Packit 5e354d
        ;;
Packit 5e354d
esac
Packit 5e354d
Packit 5e354d
if test "$have_w32_system" = yes; then
Packit 5e354d
   AC_DEFINE(HAVE_W32_SYSTEM,1,
Packit 5e354d
             [Defined if we run on any kind of W32 API based system])
Packit 5e354d
fi
Packit 5e354d
AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
Packit 5e354d
Packit 5e354d
if test "$have_w64_system" = yes; then
Packit 5e354d
   AC_DEFINE(HAVE_W64_SYSTEM,1,
Packit 5e354d
             [Defined if we run on a 64 bit W32 API based system])
Packit 5e354d
fi
Packit 5e354d
AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Generate values for the DLL version info
Packit 5e354d
#
Packit 5e354d
if test "$have_w32_system" = yes; then
Packit 5e354d
    BUILD_ISODATE=`date --iso-8601`
Packit 5e354d
    changequote(,)dnl
Packit 5e354d
    BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
Packit 5e354d
    changequote([,])dnl
Packit 5e354d
    BUILD_FILEVERSION="${BUILD_FILEVERSION}git_revision_dec"
Packit 5e354d
fi
Packit 5e354d
AC_SUBST(BUILD_ISODATE)
Packit 5e354d
AC_SUBST(BUILD_FILEVERSION)
Packit 5e354d
AC_ARG_ENABLE([build-timestamp],
Packit 5e354d
  AC_HELP_STRING([--enable-build-timestamp],
Packit 5e354d
                 [set an explicit build timestamp for reproducibility.
Packit 5e354d
                  (default is the current time in ISO-8601 format)]),
Packit 5e354d
     [if test "$enableval" = "yes"; then
Packit 5e354d
        BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
Packit 5e354d
      else
Packit 5e354d
        BUILD_TIMESTAMP="$enableval"
Packit 5e354d
      fi],
Packit 5e354d
     [BUILD_TIMESTAMP="<none>"])
Packit 5e354d
AC_SUBST(BUILD_TIMESTAMP)
Packit 5e354d
AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
Packit 5e354d
                   [The time this package was configured for a build])
Packit 5e354d
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Checks for header files.
Packit 5e354d
#
Packit 5e354d
# fixme: For what do we need the sys/socket test?
Packit 5e354d
AC_CHECK_HEADERS([sys/socket.h sys/select.h unistd.h sys/time.h time.h \
Packit 5e354d
                  signal.h])
Packit 5e354d
INSERT_SYS_SELECT_H=
Packit 5e354d
if test x"$ac_cv_header_sys_select_h" = xyes; then
Packit 5e354d
  INSERT_SYS_SELECT_H="include <sys/select.h>"
Packit 5e354d
fi
Packit 5e354d
AC_SUBST(INSERT_SYS_SELECT_H)
Packit 5e354d
Packit 5e354d
if test x"$ac_cv_header_sys_time_h" = xyes; then
Packit 5e354d
  INSERT_SYS_TIME_H="include <sys/time.h>"
Packit 5e354d
fi
Packit 5e354d
AC_SUBST(INSERT_SYS_TIME_H)
Packit 5e354d
Packit 5e354d
if test x"$ac_cv_header_time_h" = xyes; then
Packit 5e354d
  INSERT_TIME_H="include <time.h>"
Packit 5e354d
fi
Packit 5e354d
AC_SUBST(INSERT_TIME_H)
Packit 5e354d
Packit 5e354d
if test x"$ac_cv_header_signal_h" = xyes; then
Packit 5e354d
  INSERT_SIGNAL_H="include <signal.h>"
Packit 5e354d
fi
Packit 5e354d
AC_SUBST(INSERT_SIGNAL_H)
Packit 5e354d
Packit 5e354d
Packit 5e354d
# Some systems lack socklen_t - provide a replacement.
Packit 5e354d
gl_TYPE_SOCKLEN_T
Packit 5e354d
case "${host}" in
Packit 5e354d
  *-*-mingw32*)
Packit 5e354d
    # socklen_t may or may not be defined depending on what headers
Packit 5e354d
    # are included.  To be safe we use int as this is the actual type.
Packit 5e354d
    INSERT_SOCKLEN_T="define _npth_socklen_t int"
Packit 5e354d
    ;;
Packit 5e354d
  *)
Packit 5e354d
    if test ".$gl_cv_socklen_t_equiv" = "."; then
Packit 5e354d
      INSERT_SOCKLEN_T="define _npth_socklen_t socklen_t"
Packit 5e354d
    else
Packit 5e354d
      INSERT_SOCKLEN_T="define _npth_socklen_t ${gl_cv_socklen_t_equiv}"
Packit 5e354d
    fi
Packit 5e354d
esac
Packit 5e354d
AC_SUBST(INSERT_SOCKLEN_T)
Packit 5e354d
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Checks for typedefs, structures, and compiler characteristics.
Packit 5e354d
#
Packit 5e354d
AC_TYPE_PID_T
Packit 5e354d
AC_TYPE_SIZE_T
Packit 5e354d
AC_TYPE_SSIZE_T
Packit 5e354d
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Checks for libraries and functions.
Packit 5e354d
#
Packit 5e354d
#   We test for pthread_detach because glibc 2.22 includes
Packit 5e354d
#   pthread_create but not pthread_detach.
Packit 5e354d
if test "$have_w32_system" = no; then
Packit 5e354d
  AC_SEARCH_LIBS([pthread_detach],[pthread])
Packit 5e354d
  case "x$ac_cv_search_pthread_detach" in
Packit 5e354d
    xno)
Packit 5e354d
      have_pthread=no
Packit 5e354d
      ;;
Packit 5e354d
    xnone\ required)
Packit 5e354d
      have_pthread=yes
Packit 5e354d
      ;;
Packit 5e354d
    *)
Packit 5e354d
      have_pthread=yes
Packit 5e354d
      config_libs="$config_libs $ac_cv_search_pthread_detach"
Packit 5e354d
      ;;
Packit 5e354d
  esac
Packit 5e354d
  if test "$have_pthread" != no; then
Packit 5e354d
    AC_DEFINE(HAVE_PTHREAD,1,[Define if we have pthread.])
Packit 5e354d
    AC_CHECK_FUNCS([pthread_tryjoin_np pthread_setname_np pthread_getname_np])
Packit 5e354d
    AC_CHECK_FUNCS([pthread_mutex_timedlock])
Packit 5e354d
    AC_CHECK_FUNCS([pthread_rwlock_rdlock pthread_rwlock_wrlock])
Packit 5e354d
    AC_CHECK_FUNCS([pthread_rwlock_timedrdlock pthread_rwlock_timedwrlock])
Packit 5e354d
    AC_CHECK_FUNCS([pthread_rwlock_tryrdlock pthread_rwlock_trywrlock])
Packit 5e354d
    AC_CHECK_FUNCS([pthread_atfork])
Packit 5e354d
  fi
Packit 5e354d
fi
Packit 5e354d
Packit 5e354d
AC_CHECK_FUNCS([select pselect gettimeofday])
Packit 5e354d
Packit 5e354d
npth_LIBSOCKET
Packit 5e354d
config_libs="$config_libs $LIBSOCKET"
Packit 5e354d
Packit 5e354d
# Save and restore LIBS so e.g., -lrt, isn't added to it.  Otherwise, *all*
Packit 5e354d
# programs in the package would end up linked with that potentially-shared
Packit 5e354d
# library, inducing unnecessary run-time overhead.
Packit 5e354d
LIB_CLOCK_GETTIME=
Packit 5e354d
AC_SUBST([LIB_CLOCK_GETTIME])
Packit 5e354d
gl_saved_libs=$LIBS
Packit 5e354d
AC_SEARCH_LIBS([clock_gettime], [rt posix4],
Packit 5e354d
               [if test "$ac_cv_search_clock_gettime" != "none required"; then
Packit 5e354d
                  LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime
Packit 5e354d
                  config_libs="$config_libs $LIB_CLOCK_GETTIME"
Packit 5e354d
                fi
Packit 5e354d
                AC_DEFINE([HAVE_CLOCK_GETTIME],1,
Packit 5e354d
                  [Define to 1 if you have the `clock_gettime' function.])
Packit 5e354d
                ])
Packit 5e354d
LIBS=$gl_saved_libs
Packit 5e354d
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Set NETLIBS
Packit 5e354d
#
Packit 5e354d
if test "$have_w32ce_system" = yes; then
Packit 5e354d
   NETLIBS="-lws2 $NETLIBS"
Packit 5e354d
elif test "$have_w32_system" = yes; then
Packit 5e354d
   NETLIBS="-lws2_32 $NETLIBS"
Packit 5e354d
fi
Packit 5e354d
AC_SUBST(NETLIBS)
Packit 5e354d
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Substitutions to set generated files in a Emacs buffer to read-only.
Packit 5e354d
#
Packit 5e354d
AC_SUBST(emacs_local_vars_begin, [['Local][ ][Variables:']])
Packit 5e354d
AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
Packit 5e354d
AC_SUBST(emacs_local_vars_end, ['End:'])
Packit 5e354d
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Substitution used for npth-config
Packit 5e354d
#
Packit 5e354d
NPTH_CONFIG_LIBS="$config_libs"
Packit 5e354d
NPTH_CONFIG_CFLAGS=""
Packit 5e354d
NPTH_CONFIG_HOST="$host"
Packit 5e354d
AC_SUBST(NPTH_CONFIG_API_VERSION)
Packit 5e354d
AC_SUBST(NPTH_CONFIG_LIBS)
Packit 5e354d
AC_SUBST(NPTH_CONFIG_CFLAGS)
Packit 5e354d
AC_SUBST(NPTH_CONFIG_HOST)
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Last check.
Packit 5e354d
#
Packit 5e354d
die=no
Packit 5e354d
if test "$have_w32_system" = no; then
Packit 5e354d
  if test "$have_pthread" = "no"; then
Packit 5e354d
     die=yes
Packit 5e354d
     AC_MSG_NOTICE([[
Packit 5e354d
***
Packit 5e354d
*** You need Pthread to build this program.
Packit 5e354d
*** Normally, this library comes with your system.  On Windows, you can use:
Packit 5e354d
***   http://sourceware.org/pthreads-win32/
Packit 5e354d
***]])
Packit 5e354d
  fi
Packit 5e354d
fi
Packit 5e354d
Packit 5e354d
if test "$die" = "yes"; then
Packit 5e354d
    AC_MSG_ERROR([[
Packit 5e354d
***
Packit 5e354d
*** Required libraries not found. Please consult the above messages
Packit 5e354d
*** and install them before running configure again.
Packit 5e354d
***]])
Packit 5e354d
fi
Packit 5e354d
Packit 5e354d
#
Packit 5e354d
# Write output
Packit 5e354d
#
Packit 5e354d
AC_CONFIG_FILES([Makefile
Packit 5e354d
src/npth.h
Packit 5e354d
src/Makefile
Packit 5e354d
w32/Makefile
Packit 5e354d
tests/Makefile])
Packit 5e354d
AC_CONFIG_FILES(npth-config, chmod +x npth-config)
Packit 5e354d
AC_OUTPUT
Packit 5e354d
Packit 5e354d
echo "
Packit 5e354d
        $PACKAGE_NAME-$PACKAGE_VERSION prepared for make
Packit 5e354d
Packit 5e354d
        Revision: git_revision  (git_revision_dec)
Packit 5e354d
        Platform: $host
Packit 5e354d
"