Release 1.2
[npth.git] / configure.ac
index 6314476..16150d5 100644 (file)
@@ -1,5 +1,5 @@
 # configure.ac                                          -*- Autoconf -*-
-# Copyright (C) 2011 g10 Code GmbH
+# Copyright (C) 2011, 2012 g10 Code GmbH
 # This file is part of NPTH.
 #
 # NPTH is free software; you can redistribute it and/or modify it
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.67])
-min_automake_version="1.11"
-
-# Version number: Remember to change it immediately *after* a release.
-#                 Make sure to run  "svn up" and "./autogen.sh --force"
-#                  before a "make dist".  See below for the LT versions.
-#
-# The SVN version is usually the next intended release version with
-# the string "-svnNNN" appended.  The reason for this is that tests for a
-# specific feature can already be done under the assumption that the
-# SVN version is the most recent one in a branch.  To disable the SVN
-# version for the real release, set the my_issvn macro to no.
-m4_define(my_version, [0.0])
-m4_define(my_issvn, [yes])
-
-m4_define([git_revision], m4_esyscmd([git branch -v 2>/dev/null \
-          | awk '/^\* / {printf "%s",$3}']))
-AC_INIT([npth],
-        [my_version[]m4_if(my_issvn,[yes],[-git[]git_revision])],
-        [gnupg-devel@gnupg.org])
+min_automake_version="1.14"
+
+# To build a release you need to create a tag with the version number
+# (git tag -s npth-n.m) and run "./autogen.sh --force".  Please bump
+# the version number immediately after the release and do another
+# commit and push so that the git magic is able to work.
+# See below for the LT versions.
+m4_define(my_version, [1.2])
+
+# Below is m4 magic to extract and compute the git revision number,
+# the decimalized short revision number, a beta version string and a
+# flag indicating a development version (my_isgit). The latter works
+# by requiring the final tag in the repository.
+m4_define([git_revision],
+          m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
+m4_define([git_revision_dec],
+          m4_esyscmd_s([echo $((0x$(echo ]git_revision[|head -c 4)))]))
+m4_define([git_betastring],
+          m4_esyscmd_s([git describe --match 'npth-[0-9].*[0-9]' --long|\
+                        awk -F- '$3!=0{print"-beta"$3}']))
+m4_define([my_isgit],m4_if(git_betastring,[],[no],[yes]))
+m4_define([my_full_version],[my_version[]git_betastring])
+
+AC_INIT([npth],[my_full_version],[gnupg-devel@gnupg.org])
 
 # LT Version numbers, remember to change them just *before* a release.
 #   (Code changed:                     REVISION++)
@@ -56,23 +61,23 @@ AC_INIT([npth],
 #
 LIBNPTH_LT_CURRENT=0
 LIBNPTH_LT_AGE=0
-LIBNPTH_LT_REVISION=0
+LIBNPTH_LT_REVISION=5
 
 # If the API is changed in an incompatible way: increment the next counter.
 NPTH_CONFIG_API_VERSION=1
 ##############################################
 
-m4_define([git_brevis],m4_esyscmd(printf "%u" 0x[]m4_substr(git_revision,0,4)))
-BUILD_REVISION=m4_if(git_revision,[],[svn_revision],[git_brevis])
 PACKAGE=$PACKAGE_NAME
 VERSION=$PACKAGE_VERSION
 
-AC_CONFIG_SRCDIR([src/npth.h])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_SRCDIR([src/npth.c])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
-AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
 AM_MAINTAINER_MODE
 AC_CANONICAL_HOST
+AM_SILENT_RULES
 
 # Enable GNU extensions on systems that have them.
 AC_GNU_SOURCE
@@ -94,20 +99,6 @@ AC_SUBST(VERSION)
 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
 
-#
-# Generate values for the DLL version info
-#
-if test "$have_w32_system" = yes; then
-    BUILD_TIMESTAMP=`date --iso-8601=minutes`
-    changequote(,)dnl
-    BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
-    changequote([,])dnl
-    BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
-fi
-AC_SUBST(BUILD_REVISION)
-AC_SUBST(BUILD_TIMESTAMP)
-AC_SUBST(BUILD_FILEVERSION)
-
 run_tests="yes"
 AC_ARG_ENABLE(tests,
   AC_HELP_STRING([--disable-tests], [disable tests]),
@@ -164,7 +155,6 @@ esac
 if test "$have_w32_system" = yes; then
    AC_DEFINE(HAVE_W32_SYSTEM,1,
              [Defined if we run on any kind of W32 API based system])
-   ACSUBST
 fi
 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
 
@@ -174,11 +164,67 @@ if test "$have_w64_system" = yes; then
 fi
 AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
 
+#
+# Generate values for the DLL version info
+#
+if test "$have_w32_system" = yes; then
+    BUILD_TIMESTAMP=`date --iso-8601=minutes`
+    BUILD_ISODATE=`date --iso-8601`
+    changequote(,)dnl
+    BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
+    changequote([,])dnl
+    BUILD_FILEVERSION="${BUILD_FILEVERSION}git_revision_dec"
+fi
+AC_SUBST(BUILD_TIMESTAMP)
+AC_SUBST(BUILD_ISODATE)
+AC_SUBST(BUILD_FILEVERSION)
+
 
 #
 # Checks for header files.
 #
-AC_CHECK_HEADERS([sys/socket.h])
+# fixme: For what do we need the sys/socket test?
+AC_CHECK_HEADERS([sys/socket.h sys/select.h unistd.h sys/time.h time.h \
+                  signal.h])
+INSERT_SYS_SELECT_H=
+if test x"$ac_cv_header_sys_select_h" = xyes; then
+  INSERT_SYS_SELECT_H="include <sys/select.h>"
+fi
+AC_SUBST(INSERT_SYS_SELECT_H)
+
+if test x"$ac_cv_header_sys_time_h" = xyes; then
+  INSERT_SYS_TIME_H="include <sys/time.h>"
+fi
+AC_SUBST(INSERT_SYS_TIME_H)
+
+if test x"$ac_cv_header_time_h" = xyes; then
+  INSERT_TIME_H="include <time.h>"
+fi
+AC_SUBST(INSERT_TIME_H)
+
+if test x"$ac_cv_header_signal_h" = xyes; then
+  INSERT_SIGNAL_H="include <signal.h>"
+fi
+AC_SUBST(INSERT_SIGNAL_H)
+
+
+# Some systems lack socklen_t - provide a replacement.
+gl_TYPE_SOCKLEN_T
+case "${host}" in
+  *-*-mingw32*)
+    # socklen_t may or may not be defined depending on what headers
+    # are included.  To be safe we use int as this is the actual type.
+    INSERT_SOCKLEN_T="define _npth_socklen_t int"
+    ;;
+  *)
+    if test ".$gl_cv_socklen_t_equiv" = "."; then
+      INSERT_SOCKLEN_T="define _npth_socklen_t socklen_t"
+    else
+      INSERT_SOCKLEN_T="define _npth_socklen_t ${gl_cv_socklen_t_equiv}"
+    fi
+esac
+AC_SUBST(INSERT_SOCKLEN_T)
+
 
 #
 # Checks for typedefs, structures, and compiler characteristics.
@@ -208,21 +254,18 @@ if test "$have_w32_system" = no; then
   if test "$have_pthread" != no; then
     AC_DEFINE(HAVE_PTHREAD,1,[Define if we have pthread.])
     AC_CHECK_FUNCS([pthread_tryjoin_np pthread_setname_np pthread_getname_np])
+    AC_CHECK_FUNCS([pthread_mutex_timedlock])
+    AC_CHECK_FUNCS([pthread_rwlock_rdlock pthread_rwlock_wrlock])
+    AC_CHECK_FUNCS([pthread_rwlock_timedrdlock pthread_rwlock_timedwrlock])
+    AC_CHECK_FUNCS([pthread_rwlock_tryrdlock pthread_rwlock_trywrlock])
+    AC_CHECK_FUNCS([pthread_atfork])
   fi
 fi
 
-NETLIBS=
-if test "$have_w32_system" = yes; then
-   if test "$have_w32ce_system" = yes; then
-     NETLIBS="-lws2 $NETLIBS"
-   else
-     # FIXME: Check why we need to use ws2_32 and document that.
-     NETLIBS="-lws2_32 $NETLIBS"
-   fi
-fi
-AC_SUBST(NETLIBS)
+AC_CHECK_FUNCS([select pselect gettimeofday])
 
-AC_CHECK_FUNCS([select])
+npth_LIBSOCKET
+config_libs="$config_libs $LIBSOCKET"
 
 AC_SEARCH_LIBS([clock_gettime],[rt posix4])
 if test "x$ac_cv_search_clock_gettime" != no; then
@@ -232,6 +275,25 @@ fi
 
 
 #
+# Set NETLIBS
+#
+if test "$have_w32ce_system" = yes; then
+   NETLIBS="-lws2 $NETLIBS"
+elif test "$have_w32_system" = yes; then
+   NETLIBS="-lws2_32 $NETLIBS"
+fi
+AC_SUBST(NETLIBS)
+
+
+#
+# Substitutions to set generated files in a Emacs buffer to read-only.
+#
+AC_SUBST(emacs_local_vars_begin, [['Local][ ][Variables:']])
+AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
+AC_SUBST(emacs_local_vars_end, ['End:'])
+
+
+#
 # Substitution used for npth-config
 #
 NPTH_CONFIG_LIBS="$config_libs"
@@ -269,7 +331,17 @@ fi
 #
 # Write output
 #
-AC_CONFIG_FILES([Makefile src/Makefile w32/Makefile tests/Makefile])
-AC_CONFIG_FILES(src/npth-config, chmod +x src/npth-config)
-AC_CONFIG_FILES(w32/npth-config, chmod +x w32/npth-config)
+AC_CONFIG_FILES([Makefile
+src/npth.h
+src/Makefile
+w32/Makefile
+tests/Makefile])
+AC_CONFIG_FILES(npth-config, chmod +x npth-config)
 AC_OUTPUT
+
+echo "
+        $PACKAGE_NAME-$PACKAGE_VERSION prepared for make
+
+        Revision: git_revision  (git_revision_dec)
+        Platform: $host
+"