1# Process this file with autoconf to produce a configure script.
2AC_INIT(liblscp, 0.9.4, rncbc@rncbc.org, liblscp)
3
4AC_CONFIG_SRCDIR(src/client.c)
5AC_CONFIG_HEADERS([src/config.h])
6AC_CONFIG_MACRO_DIRS([.m4])
7
8AM_INIT_AUTOMAKE
9
10#------------------------------------------------------------------------------------
11# Rules for library version information:
12#
13#  1. Start with version information of `0:0:0' for each libtool library.
14#  2. Update the version information only immediately before a public release of
15#     your software. More frequent updates are unnecessary, and only guarantee
16#     that the current interface number gets larger faster.
17#  3. If the library source code has changed at all since the last update, then
18#     increment revision (`c:r:a' becomes `c:r+1:a').
19#  4. If any interfaces have been added, removed, or changed since the last update,
20#     increment current, and set revision to 0.
21#  5. If any interfaces have been added since the last public release, then increment
22#     age.
23#  6. If any interfaces have been removed since the last public release, then set age
24#     to 0.
25
26SHARED_VERSION_INFO="6:4:0"
27
28AC_SUBST(SHARED_VERSION_INFO)
29
30# Build version string.
31AC_CACHE_VAL([ac_cv_build_version], [
32   ac_cv_build_version=$(git describe --tags --dirty --abbrev=6 2>/dev/null)
33   if test -n "$ac_cv_build_version"; then
34      ac_cv_build_version=$(echo $ac_cv_build_version | sed 's/^[[^0-9]]\+//')
35      ac_cv_build_version=$(echo $ac_cv_build_version | sed 's/^1_//')
36      ac_cv_build_version=$(echo $ac_cv_build_version | sed 's/^[[_vV]]\+//')
37      ac_cv_build_version=$(echo $ac_cv_build_version | sed 's/-g/git./')
38      ac_cv_build_version=$(echo $ac_cv_build_version | sed 's/[[_|-]]/./g')
39      ac_cv_build_version_extra=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
40      if test "x$ac_cv_build_version_extra" != "xmaster"; then
41         ac_cv_build_version="$ac_cv_build_version [[$ac_cv_build_version_extra]]"
42      fi
43   else
44      ac_cv_build_version=$PACKAGE_VERSION
45   fi
46])
47ac_build_version="$ac_cv_build_version"
48AC_DEFINE_UNQUOTED(CONFIG_BUILD_VERSION, ["$ac_build_version"], [Build version string.])
49
50# Sanitized version string.
51AC_CACHE_VAL([ac_cv_version], [
52   ac_cv_version=$(echo $PACKAGE_VERSION | sed -r 's/^([[0-9|\.]]+).*$/\1/')
53])
54ac_version="$ac_cv_version"
55AC_DEFINE_UNQUOTED(CONFIG_VERSION, ["$ac_version"], [Version string.])
56AC_SUBST(ac_version)
57
58# Set default installation prefix.
59AC_PREFIX_DEFAULT(/usr/local)
60if test "x$prefix" = "xNONE"; then
61   prefix=$ac_default_prefix
62fi
63if test "x$exec_prefix" = "xNONE"; then
64   exec_prefix=$prefix
65fi
66eval ac_prefix=$prefix
67AC_SUBST(ac_prefix)
68AC_DEFINE_UNQUOTED(CONFIG_PREFIX, ["$ac_prefix"], [Default installation prefix.])
69
70# Set default installation directories.
71eval ac_libdir=$libdir
72AC_SUBST(ac_libdir)
73AC_DEFINE_UNQUOTED(CONFIG_LIBDIR, ["$ac_libdir"], [Default object library path.])
74
75eval ac_includedir=$includedir
76AC_SUBST(ac_includedir)
77AC_DEFINE_UNQUOTED(CONFIG_INCLUDEDIR, ["$ac_includedir"], [Default headers include path.])
78
79# Enable debugging argument option.
80AC_ARG_ENABLE(debug,
81   AS_HELP_STRING([--enable-debug], [enable debugging (default=no)]),
82   [ac_debug="$enableval"])
83if test "x$ac_debug" = "xyes"; then
84   AC_DEFINE(CONFIG_DEBUG, 1, [Define if debugging is enabled.])
85fi
86
87# Checks for programs.
88AC_PROG_CC
89AC_LIBTOOL_WIN32_DLL
90AC_PROG_LIBTOOL
91AM_PROG_LIBTOOL
92
93# Checks for typedefs, structures, and compiler characteristics.
94AC_C_CONST
95AC_TYPE_SIZE_T
96
97# Check for a windows build.
98case $host in
99   *mingw*|*cygwin*) windows=yes ;;
100   *)                windows=no  ;;
101esac
102AM_CONDITIONAL(WINDOWS, test "x$windows" = "xyes")
103
104# Checks for standard header files.
105AC_HEADER_STDC
106
107# Checks for standard headers and functions.
108if test "x$windows" = "xno"; then
109   AC_CHECK_HEADERS(
110      [netdb.h arpa/inet.h netinet/tcp.h netinet/in.h sys/socket.h unistd.h],
111      [], [ac_headers_h="no"])
112   if test "x$ac_headers_h" = "xno"; then
113      AC_MSG_ERROR([*** Standard headers not found.])
114   fi
115   AC_CHECK_FUNCS(
116      [socket connect bind listen setsockopt getsockopt getsockname gethostbyname],
117      [], [ac_funcs_c="no"])
118   if test "x$ac_funcs_c" = "xno"; then
119      AC_MSG_ERROR([*** Standard functions not found.])
120   fi
121fi
122
123# Checks for pthread library.
124AC_CHECK_LIB(pthread, pthread_create)
125
126AC_ENABLE_STATIC(no)
127AC_ENABLE_SHARED(yes)
128
129# Checks for doxygen.
130AC_CHECK_PROG(ac_doxygen, doxygen, [doc], [])
131AC_SUBST(ac_doxygen)
132
133AC_OUTPUT(Makefile src/Makefile lscp/Makefile examples/Makefile doc/Makefile doc/liblscp.doxygen lscp.pc liblscp.spec lscp/version.h)
134
135