configure.ac 6.97 KB
Newer Older
1 2 3 4
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.61])
5
AC_INIT([belle-sip], [1.1.0], [jehan.monnier@linphone.org])
6 7 8 9
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

jehan's avatar
jehan committed
12 13 14
dnl initialize pkg-config so that we can use it within if else fi statements.
PKG_PROG_PKG_CONFIG()

15
AM_INIT_AUTOMAKE
Simon Morlat's avatar
Simon Morlat committed
16
AM_SILENT_RULES(yes)
17 18 19

# Checks for programs.
AC_PROG_CC
20
dnl because of tunnel library wrapper, C++ is required.
Ghislain MARY's avatar
Ghislain MARY committed
21
AC_PROG_CXX
jehan's avatar
jehan committed
22
AM_PROG_CC_C_O
23

24
dnl AC_PROG_CC_C99
jehan's avatar
jehan committed
25
LT_INIT(win32-dll)
26

27 28 29
dnl Workaround for mingw, whose compiler doesn't check in /usr/include ...
case "$target_os" in
	*mingw*)
30 31 32
		if test "$cross_compiling" = "yes"; then
			CPPFLAGS="$CPPFLAGS -DUSE_FIXED_NAMESERVERS"
		else
33 34 35 36
			if test "$prefix" = "/usr" ; then
				CPPFLAGS="$CPPFLAGS -I/usr/include"
				LDFLAGS="$LDFLAGS -L/usr/lib"
			fi
37 38 39 40
		fi
	;;
esac

41 42 43 44 45 46
if test -f /etc/debian_version ; then
	use_deb=true;
else
	use_rpm=true;
fi

Simon Morlat's avatar
Simon Morlat committed
47
AC_ARG_ENABLE(debug,
48
		[  --enable-debug    Turn on debug mode (default=no)],
Simon Morlat's avatar
Simon Morlat committed
49 50 51 52
		[case "${enableval}" in
		yes) debug=true ;;
		no)  debug=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
53
		esac],[debug=false])
Simon Morlat's avatar
Simon Morlat committed
54

55
CFLAGS="$CFLAGS -fms-extensions"
Simon Morlat's avatar
Simon Morlat committed
56
if test "$debug" = "no" ; then
57
	CFLAGS="$CFLAGS -g -O2"
Simon Morlat's avatar
Simon Morlat committed
58
else
59
	CFLAGS="$CFLAGS -g"
Simon Morlat's avatar
Simon Morlat committed
60
fi
61

Simon Morlat's avatar
Simon Morlat committed
62
STRICT_OPTIONS=" -Wall -Werror -Wno-unknown-pragmas -Wno-error=unknown-pragmas"
63
dnl because of antlr3 we must accept a few warnings...
Simon Morlat's avatar
Simon Morlat committed
64 65 66 67 68
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 "
69 70 71 72 73 74 75

AC_SUBST(STRICT_OPTIONS)
AC_SUBST(LESS_STRICT_OPTIONS)

# Checks for libraries.

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

found_antlr3=no
81
if test "$antlr_prefix" != "NONE" ; then
82 83 84 85 86
	ANTLR_CFLAGS="-I${antlr_prefix}/include"
	ANTLR_LIBS="-L${antlr_prefix}/lib"
fi

ANTLR_LIBS="$ANTLR_LIBS -lantlr3c"
jehan's avatar
jehan committed
87 88 89 90

dnl check antlr headers
CPPFLAGS_save=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $ANTLR_CFLAGS"
91
AC_CHECK_HEADERS([antlr3.h], [found_antlr3=yes])
92 93 94 95 96 97 98 99
AC_CHECK_DECL(	[antlr3StringStreamNew]
		,[AC_DEFINE(HAVE_ANTLR_STRING_STREAM_NEW,1,[Defined when antlr 3.4 api is detected])]
		,[foo=bar]
		,[#include <antlr3.h>])
AC_CHECK_DECL(	[res_ndestroy]
		,[AC_DEFINE(HAVE_RESINIT,1,[Defined when res_ninit api is available])  LIBS="$LIBS -lresolv"]
		,[foo=bar]
		,[#include <resolv.h>])
jehan's avatar
jehan committed
100
				
jehan's avatar
jehan committed
101
CPPFLAGS=$CPPFLAGS_save
102

jehan's avatar
jehan committed
103
if test "$found_antlr3" != "yes" ; then
104
	AC_MSG_ERROR([Could not find antlr3 development files. Please install antlr3 version > 3.2 (libantlr3c-dev on debian/ubuntu systems)])
jehan's avatar
jehan committed
105 106 107
	ANTLR_CFLAGS=
	ANTLR_LIBS=
fi
Simon Morlat's avatar
Simon Morlat committed
108
AC_PATH_PROG([ANTLR],[antlr3],[no],[$antlr_prefix/bin /usr/bin])
jehan's avatar
jehan committed
109 110 111 112 113 114 115

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
jehan's avatar
jehan committed
116 117 118 119
		if test -f $antlr_jar ; then
			break
		else
			antlr_jar=no
120 121 122 123 124 125 126
		fi
		antlr_jar=$antlr_java_prefix/antlr3.jar
		if test -f $antlr_jar ; then
			break
		else
			antlr_jar=no
		fi
jehan's avatar
jehan committed
127 128 129 130
	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
131
	AC_PATH_PROG([JAVA],[java],[no])
jehan's avatar
jehan committed
132 133 134 135 136
	if test $JAVA = "no" ; then
		AC_MSG_ERROR([Could not find java prog. Please install java ])
	else	
		ANTLR="$JAVA -jar $antlr_jar"
	fi
137
fi
jehan's avatar
jehan committed
138 139 140
AC_SUBST(ANTLR_CFLAGS)
AC_SUBST(ANTLR_LIBS)

Simon Morlat's avatar
Simon Morlat committed
141 142 143 144 145 146 147 148
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])

149
AC_ARG_WITH( polarssl,
jehan's avatar
jehan committed
150
      [  --with-polarssl      Set prefix where polarssl can be found (ex:/usr, /usr/local)[default=PREFIX] ],
151 152
      [ polarssl_prefix=${withval}],[ polarssl_prefix=${prefix} ])

153
if test "$polarssl_prefix" != "NONE" ; then
154 155 156 157 158 159 160
	POLARSSL_CFLAGS="-I${polarssl_prefix}/include"
	POLARSSL_LIBS="-L${polarssl_prefix}/lib"
fi

POLARSSL_LIBS="$POLARSSL_LIBS -lpolarssl"
found_polarssl=no

Simon Morlat's avatar
Simon Morlat committed
161
if test "$use_tls" = "true" ; then
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
	CPPFLAGS_save=$CPPFLAGS
	LIBS_save=$LIBS

	CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
	LIBS="$LIBS $POLARSSL_LIBS"
	AC_CHECK_HEADERS(polarssl/ssl.h,
		[
			AC_CHECK_LIB(polarssl,x509parse_crtpath,[
				found_polarssl=yes
				POLARSSL_LIBS=" -lpolarssl"
			])
			
	])
	CPPFLAGS=$CPPFLAGS_save
	LIBS=$LIBS_save
Simon Morlat's avatar
Simon Morlat committed
177
fi
jehan's avatar
jehan committed
178

179
AM_CONDITIONAL([BUILD_TLS], [test "x$found_polarssl" = "xyes"])
180 181
TLS_CFLAGS=""
TLS_LIBS=""
jehan's avatar
jehan committed
182
TLS_PC=""
183 184 185 186
if test "x$found_polarssl" = "xyes" ; then
	AC_DEFINE(HAVE_POLARSSL,1,[Defined when polarssl api is available])
	TLS_CFLAGS=$POLARSSL_CFLAGS
	TLS_LIBS=$POLARSSL_LIBS
jehan's avatar
jehan committed
187
fi
188 189
AC_SUBST(TLS_CFLAGS)
AC_SUBST(TLS_LIBS)	
jehan's avatar
jehan committed
190
AC_SUBST(TLS_PC)
191

Ghislain MARY's avatar
Ghislain MARY committed
192 193 194 195 196 197 198 199
AC_ARG_ENABLE(tunnel,
	[AS_HELP_STRING([--enable-tunnel], [Enable tunnel support (default=no)])])
if test "$enable_tunnel" = "yes" ; then
	PKG_CHECK_MODULES(TUNNEL, tunnel, [found_tunnel=yes], [found_tunnel=no])
	if test "$found_tunnel" = "yes" ; then
		AC_DEFINE(HAVE_TUNNEL, 1, [Defined when tunnel is enabled and available])
	fi
fi
200
AM_CONDITIONAL(BUILD_TUNNEL, test "$found_tunnel" = "yes")
Ghislain MARY's avatar
Ghislain MARY committed
201

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

204 205 206
if test "$found_cunit" = "no" ; then
	AC_CHECK_HEADERS(CUnit/CUnit.h,
		[
Simon Morlat's avatar
Simon Morlat committed
207 208 209 210
			AC_CHECK_LIB(cunit,CU_add_suite,[
				found_cunit=yes
				CUNIT_LIBS+=" -lcunit"
			])
211
			
212 213
		])
fi
Simon Morlat's avatar
Simon Morlat committed
214 215 216 217 218
case "$target_os" in
	*darwin*)
		#hack for macport
		CUNIT_LIBS+=" -lncurses"
	;;
Simon Morlat's avatar
Simon Morlat committed
219
	*mingw*)
Ghislain MARY's avatar
Ghislain MARY committed
220
		LIBBELLESIP_CFLAGS="-DBELLESIP_EXPORTS"
Simon Morlat's avatar
Simon Morlat committed
221
		CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
222
		LIBS="$LIBS -lws2_32 -liphlpapi"
Ghislain MARY's avatar
Ghislain MARY committed
223
		LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
Simon Morlat's avatar
Simon Morlat committed
224
	;;
Simon Morlat's avatar
Simon Morlat committed
225
esac
Ghislain MARY's avatar
Ghislain MARY committed
226
AC_SUBST(LIBBELLESIP_CFLAGS)
Simon Morlat's avatar
Simon Morlat committed
227

228
if test "$found_cunit" = "no" ; then
229
	AC_MSG_WARN([Could not find cunit framework, tests are not compiled.])
230 231 232 233
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])
234 235 236
	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])
237
fi
jehan's avatar
jehan committed
238 239 240 241 242 243 244 245 246 247
AC_ARG_ENABLE(tests,
        [AS_HELP_STRING([--disable-tests], [Disable compilation of tests])],
        [case "${enableval}" in
                yes)    tests_enabled=true ;;
                no)     tests_enabled=false ;;
                *)      AC_MSG_ERROR(bad value ${enableval} for --disable-tests) ;;
        esac],
        [tests_enabled=yes]
)
AM_CONDITIONAL(ENABLE_TESTS, test x$tests_enabled = xyes && test x$found_cunit = xyes)
248 249 250 251 252

# Checks for typedefs, structures, and compiler characteristics.


# Checks for library functions.
253
AC_CHECK_LIB(rt, clock_gettime)
Simon Morlat's avatar
Simon Morlat committed
254
AC_CHECK_LIB(dl, dlopen)
255 256 257 258 259 260 261 262 263


AC_CONFIG_FILES(
[
Makefile
include/Makefile
include/belle-sip/Makefile
src/Makefile
tester/Makefile
jehan's avatar
jehan committed
264
belle-sip.pc
jehan's avatar
jehan committed
265
belle-sip.spec
266 267
])
AC_OUTPUT