configure.ac 5 KB
Newer Older
Sylvain Berfini's avatar
Sylvain Berfini committed
1 2 3
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

4
AC_PREREQ([2.63])
5
AC_INIT([belcard], [1.0.0], [sylvain.berfini@belledonne-communications.com])
Sylvain Berfini's avatar
Sylvain Berfini committed
6 7 8 9 10 11 12 13 14 15

BELCARD_SO_CURRENT=0 dnl increment this number when you add/change/remove an interface
BELCARD_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
BELCARD_SO_AGE=1 dnl increment this number when you add an interface, set to 0 if you remove an interface

BELCARD_SO_VERSION=$BELCARD_SO_CURRENT:$BELCARD_SO_REVISION:$BELCARD_SO_AGE

AC_SUBST(BELCARD_SO_CURRENT, $BELCARD_SO_CURRENT)
AC_SUBST(BELCARD_SO_VERSION)

Sylvain Berfini's avatar
Sylvain Berfini committed
16
AC_CONFIG_SRCDIR([src/])
Sylvain Berfini's avatar
Sylvain Berfini committed
17 18 19

AC_CONFIG_MACRO_DIR([m4])

Sylvain Berfini's avatar
Sylvain Berfini committed
20 21
AC_CONFIG_HEADERS([config.h])

Sylvain Berfini's avatar
Sylvain Berfini committed
22 23 24 25 26 27 28 29
AC_CANONICAL_SYSTEM

LT_INIT([shared disable-static])

dnl initialize pkg-config so that we can use it within if else fi statements.
PKG_PROG_PKG_CONFIG()

AM_INIT_AUTOMAKE(subdir-objects)
Sylvain Berfini's avatar
Sylvain Berfini committed
30 31 32 33 34
AM_SILENT_RULES(yes)

# Checks for programs.
AC_PROG_CXX

35
CXXFLAGS="$CXXFLAGS -std=c++11 -Wall -Werror -Wextra -Wno-unused-parameter"
Sylvain Berfini's avatar
Sylvain Berfini committed
36 37

# Checks for libraries.
Sylvain Berfini's avatar
Sylvain Berfini committed
38 39 40 41
dnl ##################################################
dnl # Check for XXD
dnl ##################################################

42 43 44 45 46
AC_CHECK_PROG(xxd_found, xxd, yes)
if test "$xxd_found" != yes ;then
        AC_MSG_ERROR("xxd is required (provided by vim package)")
fi

Sylvain Berfini's avatar
Sylvain Berfini committed
47 48 49 50 51
dnl ##################################################
dnl # Check for BcToolbox
dnl ##################################################

dnl check bctoolbox
52 53 54 55 56 57 58 59 60 61 62 63 64 65
PKG_CHECK_MODULES(BCTOOLBOX, [bctoolbox],[libbctoolbox_found=yes],foo=bar)
if test "$libbctoolbox_found" != "yes" ; then
        dnl Check the lib presence in case the PKG-CONFIG version is not found
        AC_LANG_CPLUSPLUS
        AC_CHECK_LIB(bctoolbox, main, [BCTOOLBOX_LIBS+=" -lbctoolbox"; libbctoolbox_found=yes], [foo=bar])
        AC_LANG_C
fi
if test "$libbctoolbox_found" != "yes" ; then
        AC_MSG_ERROR([libbctoolbox not found. Install it and try again])
fi

AC_SUBST(BCTOOLBOX_LIBS)

dnl check bctoolbox-tester
66
PKG_CHECK_MODULES(BCTOOLBOXTESTER, [bctoolbox-tester],[libbctoolbox_tester_found=yes],foo=bar)
Sylvain Berfini's avatar
Sylvain Berfini committed
67 68 69 70 71 72 73 74 75 76 77 78
if test "$libbctoolbox_tester_found" != "yes" ; then
        dnl Check the lib presence in case the PKG-CONFIG version is not found
        AC_LANG_CPLUSPLUS
        AC_CHECK_LIB(bctoolbox-tester, main, [BCTOOLBOX_TESTER_LIBS+=" -lbctoolbox-tester"; libbctoolbox_tester_found=yes], [foo=bar])
        AC_LANG_C
fi
if test "$libbctoolbox_tester_found" != "yes" ; then
        AC_MSG_ERROR([libbctoolbox tester not found. Install it and try again])
fi

AC_SUBST(BCTOOLBOX_TESTER_LIBS)

79 80 81 82 83
dnl ##################################################
dnl # Check for Belr
dnl ##################################################

dnl check belr
Sylvain Berfini's avatar
Sylvain Berfini committed
84
PKG_CHECK_MODULES(BELR, [belr],[libbelr_found=yes],foo=bar)
85 86 87 88 89 90 91 92 93
if test "$libbelr_found" != "yes" ; then
	dnl Check the lib presence in case the PKG-CONFIG version is not found
	AC_LANG_CPLUSPLUS
	AC_CHECK_LIB(belr, main, [BELR_LIBS+=" -lbelr"; libbelr_found=yes], [foo=bar])
	AC_LANG_C
fi
if test "$libbelr_found" != "yes" ; then
	AC_MSG_ERROR([libbelr not found. Install it and try again])
fi
94 95

AC_SUBST(BELR_CFLAGS)
96 97
AC_SUBST(BELR_LIBS)

Sylvain Berfini's avatar
Sylvain Berfini committed
98
dnl ##################################################
99
dnl # Check for BCUnit
Sylvain Berfini's avatar
Sylvain Berfini committed
100 101
dnl ##################################################

102
PKG_CHECK_MODULES(BCUNIT, bcunit, [found_bcunit=yes],[found_bcunit=no])
Sylvain Berfini's avatar
Sylvain Berfini committed
103

104 105
if test "$found_bcunit" = "no" ; then
	AC_CHECK_HEADERS(BCUnit/BCUnit.h,
Sylvain Berfini's avatar
Sylvain Berfini committed
106
		[
107 108 109
			AC_CHECK_LIB(bcunit,CU_add_suite,[
				found_bcunit=yes
				BCUNIT_LIBS+=" -lbcunit"
Sylvain Berfini's avatar
Sylvain Berfini committed
110 111 112 113 114 115
			])
		])
fi
case "$target_os" in
	*darwin*)
		#hack for macport
116
		BCUNIT_LIBS+=" -lncurses"
Sylvain Berfini's avatar
Sylvain Berfini committed
117 118 119 120 121 122 123 124
	;;
	*mingw*)
		CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
		LIBS="$LIBS -lws2_32 -liphlpapi"
		LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
	;;
esac

125 126
if test "$found_bcunit" = "no" ; then
	AC_MSG_WARN([Could not find bcunit framework, tests are not compiled.])
Sylvain Berfini's avatar
Sylvain Berfini committed
127
else
128
	AC_CHECK_LIB(bcunit,CU_get_suite,[
Sylvain Berfini's avatar
Sylvain Berfini committed
129
					AC_DEFINE(HAVE_CU_GET_SUITE,1,[defined when CU_get_suite is available])
130 131
					],[foo=bar],[$BCUNIT_LIBS])
	AC_CHECK_LIB(bcunit,CU_curses_run_tests,[
Sylvain Berfini's avatar
Sylvain Berfini committed
132
					AC_DEFINE(HAVE_CU_CURSES,1,[defined when CU_curses_run_tests is available])
133
					],[foo=bar],[$BCUNIT_LIBS])
Sylvain Berfini's avatar
Sylvain Berfini committed
134 135
fi

136
AM_CONDITIONAL(BUILD_TESTS,test x$found_bcunit = xyes)
Sylvain Berfini's avatar
Sylvain Berfini committed
137 138 139 140 141 142

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SSIZE_T

Sylvain Berfini's avatar
Sylvain Berfini committed
143 144 145 146 147 148 149 150 151
dnl substitute variables used by .pc files
if test "$prefix" = "NONE" ; then
	install_prefix=/usr
else
	install_prefix=$prefix
fi

PROJECT_VERSION=$VERSION
CMAKE_INSTALL_PREFIX=$install_prefix
152
CMAKE_INSTALL_FULL_LIBDIR=${libdir}
Sylvain Berfini's avatar
Sylvain Berfini committed
153 154 155 156 157 158 159 160
CMAKE_INSTALL_FULL_INCLUDEDIR=${install_prefix}/include

AC_SUBST(PROJECT_VERSION)
AC_SUBST(CMAKE_INSTALL_PREFIX)
AC_SUBST(CMAKE_INSTALL_FULL_LIBDIR)
AC_SUBST(CMAKE_INSTALL_FULL_INCLUDEDIR)
AC_SUBST(TESTER_REQUIRES_PRIVATE)

Sylvain Berfini's avatar
Sylvain Berfini committed
161 162 163 164
# Checks for library functions.
AC_CONFIG_FILES(
Makefile
src/Makefile
Sylvain Berfini's avatar
Sylvain Berfini committed
165
tester/Makefile
Sylvain Berfini's avatar
Sylvain Berfini committed
166
tools/Makefile
Sylvain Berfini's avatar
Sylvain Berfini committed
167 168
include/Makefile
include/belcard/Makefile
169
cmake/BelcardConfig.cmake
Sylvain Berfini's avatar
Sylvain Berfini committed
170
belcard.pc
Sylvain Berfini's avatar
Sylvain Berfini committed
171 172 173
)

AC_OUTPUT