configure.ac 5.02 KB
Newer Older
1 2 3 4 5 6 7 8 9
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.61])
AC_INIT([belle-sip], [0.0.1], [jehan.monnier@linphone.org])
AC_CONFIG_SRCDIR([src/belle_sip_utils.c])

AC_CONFIG_HEADERS([config.h])

Simon Morlat's avatar
Simon Morlat committed
10 11
AC_CANONICAL_SYSTEM

12 13 14 15 16 17
AC_PREFIX_DEFAULT(/usr/local)

if test "$prefix" = "NONE"; then
	prefix=$ac_default_prefix
fi

18
AM_INIT_AUTOMAKE
Simon Morlat's avatar
Simon Morlat committed
19
AM_SILENT_RULES(yes)
20 21 22

# Checks for programs.
AC_PROG_CC
jehan's avatar
jehan committed
23
AM_PROG_CC_C_O
24
dnl AC_PROG_CC_C99
25 26 27 28 29 30 31 32
LT_INIT(disable-static win32-dll)

if test -f /etc/debian_version ; then
	use_deb=true;
else
	use_rpm=true;
fi

Simon Morlat's avatar
Simon Morlat committed
33 34 35 36 37 38 39 40 41 42 43 44 45
AC_ARG_ENABLE(debug,
		[  --enable-debug    Turn on debug mode (default=yes)],
		[case "${enableval}" in
		yes) debug=true ;;
		no)  debug=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
		esac],[debug=true])

if test "$debug" = "no" ; then
	CFLAGS="-g -O2"
else
	CFLAGS="-g"
fi
46

Simon Morlat's avatar
Simon Morlat committed
47
STRICT_OPTIONS=" -Wall -Werror -Wno-unknown-pragmas -Wno-error=unknown-pragmas"
48
dnl because of antlr3 we must accept a few warnings...
Simon Morlat's avatar
Simon Morlat committed
49 50 51 52 53
dnl more portable for the moment
       LESS_STRICT_OPTIONS= 
dnl       LESS_STRICT_OPTIONS="$STRICT_OPTIONS -Wno-error=unused-function \
dnl        -Wno-error=uninitialized -Wno-error=unused-variable \
dnl        -Wno-error=unused-but-set-variable "
54 55 56 57 58 59 60

AC_SUBST(STRICT_OPTIONS)
AC_SUBST(LESS_STRICT_OPTIONS)

# Checks for libraries.

# Checks for header files.
jehan's avatar
jehan committed
61
AC_ARG_WITH( antlr,
62 63
      [  --with-antlr      Set prefix where libantlr3c can be found (ex:/usr or /usr/local)[default=PREFIX] ],
      [ antlr_prefix=${withval}],[ antlr_prefix=${prefix} ])
64 65

found_antlr3=no
jehan's avatar
jehan committed
66 67 68 69 70 71
ANTLR_CFLAGS="-I${antlr_prefix}/include"
ANTLR_LIBS="-L${antlr_prefix}/lib -lantlr3c"

dnl check antlr headers
CPPFLAGS_save=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $ANTLR_CFLAGS"
72
AC_CHECK_HEADERS([antlr3.h], [found_antlr3=yes])
jehan's avatar
jehan committed
73
AC_CHECK_DECL([antlr3StringStreamNew], [found_antlr3=yes], [found_antlr3=no],[#include <antlr3.h>])
jehan's avatar
jehan committed
74
CPPFLAGS=$CPPFLAGS_save
75

jehan's avatar
jehan committed
76
if test "$found_antlr3" != "yes" ; then
jehan's avatar
jehan committed
77
	AC_MSG_ERROR([Could not find antlr3 development files. Please install antlr3 version > 3.4 (libantlr3c-dev on debian/ubuntu systems)])
jehan's avatar
jehan committed
78 79 80
	ANTLR_CFLAGS=
	ANTLR_LIBS=
fi
Simon Morlat's avatar
Simon Morlat committed
81
AC_PATH_PROG([ANTLR],[antlr3],[no],[$antlr_prefix/bin /usr/bin])
jehan's avatar
jehan committed
82 83 84 85 86 87 88 89 90 91 92 93

if test $ANTLR = "no" ; then
antlr_java_prefixes="$antlr_prefix/share/java /usr/local/share/java /usr/share/java /opt/local/share/java"

	for antlr_java_prefix in $antlr_java_prefixes
	do
		antlr_jar=$antlr_java_prefix/antlr.jar
		AC_CHECK_FILE([$antlr_jar],[break],[antlr_jar=no])
	done
	if test $antlr_jar = "no" ; then
		AC_MSG_ERROR([Could not find antlr.jar. Please install antlr3 ])
	fi
Ghislain MARY's avatar
Ghislain MARY committed
94
	AC_PATH_PROG([JAVA],[java],[no])
jehan's avatar
jehan committed
95 96 97 98 99
	if test $JAVA = "no" ; then
		AC_MSG_ERROR([Could not find java prog. Please install java ])
	else	
		ANTLR="$JAVA -jar $antlr_jar"
	fi
100
fi
jehan's avatar
jehan committed
101 102 103
AC_SUBST(ANTLR_CFLAGS)
AC_SUBST(ANTLR_LIBS)

Simon Morlat's avatar
Simon Morlat committed
104 105 106 107 108 109 110 111 112 113 114 115
AC_ARG_ENABLE(	tls,
		[  --enable-tls		Enable TLS support (default=yes)],
		[case "${enableval}" in
		yes) use_tls=true ;;
		no)  use_tls=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-tls) ;;
		esac],[use_tls=true])

if test "$use_tls" = "true" ; then
	PKG_CHECK_MODULES(GNUTLS, gnutls, [found_gnutls=yes],
		[AC_MSG_ERROR([Gnutls not found. You can use --disable-tls to turn tls support off.])] )
fi
jehan's avatar
jehan committed
116

117 118 119
AM_CONDITIONAL([BUILD_TLS], [test "x$found_gnutls" = "xyes" || test "x$found_openssl" = "xyes"])
TLS_CFLAGS=""
TLS_LIBS=""
jehan's avatar
jehan committed
120
TLS_PC=""
jehan's avatar
jehan committed
121
if test "x$found_gnutls" = "xyes" ; then
122
	GNUTLS_LIBS+="$GNUTLS_LIBS -lgnutls "
123 124 125
	AC_DEFINE(HAVE_GNUTLS,1,[Defined when gnutls api is available])
	TLS_CFLAGS=$GNUTLS_CFLAGS
	TLS_LIBS=$GNUTLS_LIBS
jehan's avatar
jehan committed
126
	TLS_PC=gnutls
127 128 129 130
elif test "x$found_openssl" = "xyes" ; then
	AC_DEFINE(HAVE_OPENSSL,1,[Defined when openssl api is available])
	TLS_CFLAGS=$OPENSSL_CFLAGS
	TLS_LIBS=$OPENSSL_LIBS
jehan's avatar
jehan committed
131
fi
132 133
AC_SUBST(TLS_CFLAGS)
AC_SUBST(TLS_LIBS)	
jehan's avatar
jehan committed
134
AC_SUBST(TLS_PC)
135

jehan's avatar
jehan committed
136
PKG_CHECK_MODULES(CUNIT, cunit, [found_cunit=yes],[found_cunit=no])
jehan's avatar
jehan committed
137

138 139 140
if test "$found_cunit" = "no" ; then
	AC_CHECK_HEADERS(CUnit/CUnit.h,
		[
Simon Morlat's avatar
Simon Morlat committed
141 142 143 144
			AC_CHECK_LIB(cunit,CU_add_suite,[
				found_cunit=yes
				CUNIT_LIBS+=" -lcunit"
			])
145
			
146 147
		])
fi
Simon Morlat's avatar
Simon Morlat committed
148 149 150 151 152
case "$target_os" in
	*darwin*)
		#hack for macport
		CUNIT_LIBS+=" -lncurses"
	;;
Simon Morlat's avatar
Simon Morlat committed
153
	*mingw*)
Ghislain MARY's avatar
Ghislain MARY committed
154
		LIBBELLESIP_CFLAGS="-DBELLESIP_EXPORTS"
Simon Morlat's avatar
Simon Morlat committed
155
		CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
156
		LIBS="$LIBS -lws2_32 -liphlpapi"
Ghislain MARY's avatar
Ghislain MARY committed
157
		LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
Simon Morlat's avatar
Simon Morlat committed
158
	;;
Simon Morlat's avatar
Simon Morlat committed
159
esac
Ghislain MARY's avatar
Ghislain MARY committed
160
AC_SUBST(LIBBELLESIP_CFLAGS)
Simon Morlat's avatar
Simon Morlat committed
161

162
if test "$found_cunit" = "no" ; then
163
	AC_MSG_WARN([Could not find cunit framework, tests are not compiled.])
164 165 166 167
else 
	AC_CHECK_LIB(cunit,CU_get_suite,[
					AC_DEFINE(HAVE_CU_GET_SUITE,1,[defined when CU_get_suite is available])
					],[foo=bar],[$CUNIT_LIBS])
168 169 170
	AC_CHECK_LIB(cunit,CU_curses_run_tests,[
					AC_DEFINE(HAVE_CU_CURSES,1,[defined when CU_curses_run_tests is available])
					],[foo=bar],[$CUNIT_LIBS])
171 172
fi

jehan's avatar
jehan committed
173
AM_CONDITIONAL(BUILD_TESTS,test x$found_cunit = xyes)
174 175 176 177
# Checks for typedefs, structures, and compiler characteristics.


# Checks for library functions.
178
AC_CHECK_LIB(rt, clock_gettime)
Simon Morlat's avatar
Simon Morlat committed
179
AC_CHECK_LIB(dl, dlopen)
180 181 182 183 184 185 186 187 188


AC_CONFIG_FILES(
[
Makefile
include/Makefile
include/belle-sip/Makefile
src/Makefile
tester/Makefile
jehan's avatar
jehan committed
189
belle-sip.pc
190 191
])
AC_OUTPUT