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

4
AC_PREREQ([2.63])
5

Ghislain MARY's avatar
Ghislain MARY committed
6
AC_INIT([belle-sip],[1.3.1],[jehan.monnier@linphone.org])
7

8 9
AC_CONFIG_SRCDIR([src/belle_sip_utils.c])

10 11
AC_CONFIG_MACRO_DIR([m4])

12 13
AC_CONFIG_HEADERS([config.h])

Simon Morlat's avatar
Simon Morlat committed
14 15
AC_CANONICAL_SYSTEM

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

19
AM_INIT_AUTOMAKE([subdir-objects])
Simon Morlat's avatar
Simon Morlat committed
20
AM_SILENT_RULES(yes)
21 22

# Checks for programs.
23 24 25
dnl don't put anythingelse before AC_PROG_CC unless checking if macro still work for clang
AC_PROG_CXX(["xcrun clang++" g++]) 
AC_PROG_CC(["xcrun clang" gcc])
26
dnl because of tunnel library wrapper, C++ is required.
jehan's avatar
jehan committed
27
AM_PROG_CC_C_O
28

29
dnl AC_PROG_CC_C99
30
LT_INIT(win32-dll)
31

jehan's avatar
jehan committed
32 33 34 35 36 37 38
case "$target" in
	#macosx 64 bits
        x86_64-apple-darwin*)
                LIBS="$LIBS -mmacosx-version-min=10.6"
                CXXFLAGS="$CXXFLAGS -mmacosx-version-min=10.6"
                CFLAGS="$CFLAGS -mmacosx-version-min=10.6"
        ;;
39 40 41
        i386-apple*|armv6-apple*|armv7-apple*|armv7s-apple*)
			LIBS="$LIBS -framework CoreFoundation -framework CFNetwork "
		;;
jehan's avatar
jehan committed
42 43
esac

44 45 46
dnl Workaround for mingw, whose compiler doesn't check in /usr/include ...
case "$target_os" in
	*mingw*)
47 48 49 50 51
		if test "$cross_compiling" != "yes"; then
			if test "$prefix" = "/usr" ; then
				CPPFLAGS="$CPPFLAGS -I/usr/include"
				LDFLAGS="$LDFLAGS -L/usr/lib"
			fi
52 53
		fi
	;;
jehan's avatar
jehan committed
54

55 56
esac

57 58 59 60 61 62
if test -f /etc/debian_version ; then
	use_deb=true;
else
	use_rpm=true;
fi

Simon Morlat's avatar
Simon Morlat committed
63
AC_ARG_ENABLE(debug,
64
		[  --enable-debug    Turn on debug mode (default=no)],
Simon Morlat's avatar
Simon Morlat committed
65 66 67 68
		[case "${enableval}" in
		yes) debug=true ;;
		no)  debug=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
69
		esac],[debug=false])
Simon Morlat's avatar
Simon Morlat committed
70

71
CFLAGS="$CFLAGS -fms-extensions"
Simon Morlat's avatar
Simon Morlat committed
72
if test "$debug" = "no" ; then
73
	CFLAGS="$CFLAGS -g -O2"
Simon Morlat's avatar
Simon Morlat committed
74
else
75
	CFLAGS="$CFLAGS -g"
Simon Morlat's avatar
Simon Morlat committed
76
fi
77

jehan's avatar
jehan committed
78
STRICT_OPTIONS=" -Wall -Werror -Wno-error=unknown-pragmas"
Simon Morlat's avatar
Simon Morlat committed
79 80

case "$CC" in
81
	*clang*)
Simon Morlat's avatar
Simon Morlat committed
82 83 84 85 86 87 88
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-error=unknown-warning-option"
	;;
	gcc*)
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-error=pragmas"
	;;
esac

89
dnl because of antlr3 we must accept a few warnings...
Simon Morlat's avatar
Simon Morlat committed
90 91 92 93 94
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 "
95 96 97 98 99 100 101

AC_SUBST(STRICT_OPTIONS)
AC_SUBST(LESS_STRICT_OPTIONS)

# Checks for libraries.

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

found_antlr3=no
107
if test "$antlr_prefix" != "NONE" ; then
108 109 110 111 112
	ANTLR_CFLAGS="-I${antlr_prefix}/include"
	ANTLR_LIBS="-L${antlr_prefix}/lib"
fi

ANTLR_LIBS="$ANTLR_LIBS -lantlr3c"
jehan's avatar
jehan committed
113 114 115

dnl check antlr headers
CPPFLAGS_save=$CPPFLAGS
116
CPPFLAGS="$ANTLR_CFLAGS $CPPFLAGS"
117
AC_CHECK_HEADERS([antlr3.h], [found_antlr3=yes])
118 119 120 121
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>])
122 123
libresolv_have_res_get_servers=no
resolv_h_hav_res_ndestroy=no
124 125 126 127 128 129 130 131 132 133 134
LIBS_save=$LIBS

LIBS="$LIBS -lresolv"
	
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <resolv.h>]],
                      			[[res_getservers(NULL,NULL,0)]])]
								,[libresolv_have_res_get_servers=yes
									AC_MSG_NOTICE([res_getservers usable])]
								,[LIBS=$LIBS_save
									AC_MSG_WARN([res_getservers not usable])])
			
135 136 137 138
AC_CHECK_DECL([res_ndestroy],
		[resolv_h_hav_res_ndestroy=yes],
		[foo=bar],
		[#include <resolv.h>])
139 140 141
if test "${libresolv_have_res_get_servers}${resolv_h_hav_res_ndestroy}" == "yesyes" ; then
	AC_DEFINE(HAVE_RESINIT,1,[Defined when res_ninit api is available])
fi
jehan's avatar
jehan committed
142
CPPFLAGS=$CPPFLAGS_save
143

jehan's avatar
jehan committed
144
if test "$found_antlr3" != "yes" ; then
145
	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
146 147 148
	ANTLR_CFLAGS=
	ANTLR_LIBS=
fi
Simon Morlat's avatar
Simon Morlat committed
149
AC_PATH_PROG([ANTLR],[antlr3],[no],[$antlr_prefix/bin /usr/bin])
jehan's avatar
jehan committed
150 151 152 153 154 155 156

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
157 158 159 160
		if test -f $antlr_jar ; then
			break
		else
			antlr_jar=no
161 162 163 164 165 166 167
		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
168 169 170 171
	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
172
	AC_PATH_PROG([JAVA],[java],[no])
jehan's avatar
jehan committed
173 174 175 176 177
	if test $JAVA = "no" ; then
		AC_MSG_ERROR([Could not find java prog. Please install java ])
	else	
		ANTLR="$JAVA -jar $antlr_jar"
	fi
178
fi
jehan's avatar
jehan committed
179 180 181
AC_SUBST(ANTLR_CFLAGS)
AC_SUBST(ANTLR_LIBS)

Simon Morlat's avatar
Simon Morlat committed
182 183 184 185 186 187 188 189
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])

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

194
if test "$polarssl_prefix" != "NONE" ; then
195 196 197 198 199 200 201
	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
202
if test "$use_tls" = "true" ; then
203 204 205 206 207 208 209
	CPPFLAGS_save=$CPPFLAGS
	LIBS_save=$LIBS

	CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
	LIBS="$LIBS $POLARSSL_LIBS"
	AC_CHECK_HEADERS(polarssl/ssl.h,
		[
210
		AC_LINK_IFELSE([AC_LANG_PROGRAM([[	
Guillaume Beraudo's avatar
Guillaume Beraudo committed
211 212
			#include <polarssl/version.h>
			#include <polarssl/x509.h>
213 214 215 216 217 218 219 220 221
			#if POLARSSL_VERSION_NUMBER >= 0x01030000
			#include <polarssl/compat-1.2.h>
			#endif
			]],
                      	[[x509parse_crtpath(0,0)]])]
			,[found_polarssl=yes
			POLARSSL_LIBS=" -lpolarssl"
			AC_MSG_NOTICE([polarssl usable])]
			,[AC_MSG_WARN([polarssl not usable])])
222
			
223
		])
224 225
	CPPFLAGS=$CPPFLAGS_save
	LIBS=$LIBS_save
Simon Morlat's avatar
Simon Morlat committed
226
fi
jehan's avatar
jehan committed
227

228
AM_CONDITIONAL([BUILD_TLS], [test "x$found_polarssl" = "xyes"])
229 230
TLS_CFLAGS=""
TLS_LIBS=""
jehan's avatar
jehan committed
231
TLS_PC=""
232 233 234 235
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
236
fi
237 238
AC_SUBST(TLS_CFLAGS)
AC_SUBST(TLS_LIBS)	
jehan's avatar
jehan committed
239
AC_SUBST(TLS_PC)
240

241 242 243 244 245 246 247 248 249 250 251 252 253
AC_ARG_ENABLE(server_sockets,
	[AS_HELP_STRING([--disable-server-sockets], [Disable server sockets creation])],
	[case "${enableval}" in
		yes) server_sockets_enabled=true ;;
		no) server_sockets_enabled=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --disable-server-sockets) ;;
	esac],
	[server_sockets_enabled=yes]
)
if test "x$server_sockets_enabled" = "xyes" ; then
	AC_DEFINE(ENABLE_SERVER_SOCKETS,1,[Defined when server sockets are enabled])
fi

Ghislain MARY's avatar
Ghislain MARY committed
254 255 256 257 258 259 260 261
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
262
AM_CONDITIONAL(BUILD_TUNNEL, test "$found_tunnel" = "yes")
Ghislain MARY's avatar
Ghislain MARY committed
263

264
PKG_CHECK_MODULES(CUNIT, cunit, [found_pkg_config_cunit=yes],[found_pkg_config_cunit=no])
jehan's avatar
jehan committed
265

266
if test "$found_pkg_config_cunit" = "no" ; then
267 268
	AC_CHECK_HEADERS(CUnit/CUnit.h,
		[
Simon Morlat's avatar
Simon Morlat committed
269 270 271 272
			AC_CHECK_LIB(cunit,CU_add_suite,[
				found_cunit=yes
				CUNIT_LIBS+=" -lcunit"
			])
273
			
274
		])
275 276
else
	found_cunit=yes
277
fi
Simon Morlat's avatar
Simon Morlat committed
278 279 280 281 282
case "$target_os" in
	*darwin*)
		#hack for macport
		CUNIT_LIBS+=" -lncurses"
	;;
Simon Morlat's avatar
Simon Morlat committed
283
	*mingw*)
Ghislain MARY's avatar
Ghislain MARY committed
284
		LIBBELLESIP_CFLAGS="-DBELLESIP_EXPORTS"
Simon Morlat's avatar
Simon Morlat committed
285
		CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
286
		LIBS="$LIBS -lws2_32 -liphlpapi"
Ghislain MARY's avatar
Ghislain MARY committed
287
		LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
Simon Morlat's avatar
Simon Morlat committed
288
	;;
Simon Morlat's avatar
Simon Morlat committed
289
esac
Ghislain MARY's avatar
Ghislain MARY committed
290
AC_SUBST(LIBBELLESIP_CFLAGS)
Simon Morlat's avatar
Simon Morlat committed
291

292
if test "$found_cunit" = "no" ; then
293
	AC_MSG_WARN([Could not find cunit framework, tests are not compiled.])
294 295 296 297
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])
298 299 300
	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])
301
fi
jehan's avatar
jehan committed
302 303 304 305 306 307 308 309 310 311
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)
312

313
REQUIRES_PRIVATE=""
314 315
LIBS_PRIVATE=""
if test "$found_pkg_config_cunit" = "yes" ; then
316
	REQUIRES_PRIVATE="$REQUIRES_PRIVATE cunit"
317 318 319 320
else
	if test "$found_cunit" = "yes" ; then
		LIBS_PRIVATE="$LIBS_PRIVATE $CUNIT_LIBS"
	fi
321
fi
322
LIBS_PRIVATE="$LIBS_PRIVATE $ANTLR_LIBS $POLARSSL_LIBS"
323 324 325
AC_SUBST(REQUIRES_PRIVATE)
AC_SUBST(LIBS_PRIVATE)

326 327 328
# Checks for typedefs, structures, and compiler characteristics.


329 330
# Eliminate -lstdc++ addition to postdeps for cross compiles.
postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
331 332


333
# Checks for library functions.
334
AC_CHECK_LIB(rt, clock_gettime)
Simon Morlat's avatar
Simon Morlat committed
335
AC_CHECK_LIB(dl, dlopen)
336 337
AC_CHECK_LIB(pthread, pthread_getspecific,,
    [AC_MSG_ERROR([pthread library not found])])
338 339 340 341 342 343 344

AC_CONFIG_FILES(
[
Makefile
include/Makefile
include/belle-sip/Makefile
src/Makefile
345
src/grammars/Makefile
346
tester/Makefile
jehan's avatar
jehan committed
347
belle-sip.pc
jehan's avatar
jehan committed
348
belle-sip.spec
349 350
])
AC_OUTPUT