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

4
AC_PREREQ([2.63])
5

gbi's avatar
V1.3.3  
gbi committed
6
AC_INIT([belle-sip],[1.3.3],[jehan.monnier@linphone.org])
7 8 9 10 11 12 13 14 15

BELLESIP_SO_CURRENT=0 dnl increment this number when you add/change/remove an interface
BELLESIP_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
BELLESIP_SO_AGE=0 dnl increment this number when you add an interface, set to 0 if you remove an interface

BELLESIP_SO_VERSION=$BELLESIP_SO_CURRENT:$BELLESIP_SO_REVISION:$BELLESIP_SO_AGE

AC_SUBST(BELLESIP_SO_CURRENT, $BELLESIP_SO_CURRENT)
AC_SUBST(BELLESIP_SO_VERSION)
16

17 18
AC_CONFIG_SRCDIR([src/belle_sip_utils.c])

19 20
AC_CONFIG_MACRO_DIR([m4])

21 22
AC_CONFIG_HEADERS([config.h])

Simon Morlat's avatar
Simon Morlat committed
23 24
AC_CANONICAL_SYSTEM

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

28
AM_INIT_AUTOMAKE([subdir-objects])
Simon Morlat's avatar
Simon Morlat committed
29
AM_SILENT_RULES(yes)
30 31

# Checks for programs.
32
dnl do not put anythingelse before AC_PROG_CC unless checking if macro still work for clang
33
dnl because of tunnel library wrapper, C++ is required.
34
AC_PROG_CXX(["xcrun clang++" g++])
35
AC_PROG_CC(["xcrun clang" gcc])
36 37
AC_PROG_OBJC(["xcrun clang" gcc])

jehan's avatar
jehan committed
38
AM_PROG_CC_C_O
jehan's avatar
jehan committed
39 40 41 42 43
case $INSTALL in
	*ginstall*)
		INSTALL="$INSTALL -C"
	;;
esac
44
dnl AC_PROG_CC_C99
45
LT_INIT(win32-dll)
46

jehan's avatar
jehan committed
47 48 49
case "$target" in
	#macosx 64 bits
        x86_64-apple-darwin*)
50
                LIBS="$LIBS -mmacosx-version-min=10.6 -framework Foundation"
jehan's avatar
jehan committed
51 52
                CXXFLAGS="$CXXFLAGS -mmacosx-version-min=10.6"
                CFLAGS="$CFLAGS -mmacosx-version-min=10.6"
53
                OBJCFLAGS="$OBJCFLAGS  -fmodules"
54
                build_apple=yes
jehan's avatar
jehan committed
55
        ;;
56
        i386-apple*|armv6-apple*|armv7-apple*|armv7s-apple*|arm64-apple*|aarch64-apple*)
57
		LIBS="$LIBS -framework Foundation -framework CoreFoundation -framework CFNetwork -framework UIKit"
58
		build_apple=yes
59
	;;
jehan's avatar
jehan committed
60 61
esac

62
AM_CONDITIONAL([BUILD_APPLE], [test "x$build_apple" = "xyes"])
63

64
dnl Workaround for mingw, whose compiler does not check in /usr/include ...
65 66
case "$target_os" in
	*mingw*)
67 68 69 70 71
		if test "$cross_compiling" != "yes"; then
			if test "$prefix" = "/usr" ; then
				CPPFLAGS="$CPPFLAGS -I/usr/include"
				LDFLAGS="$LDFLAGS -L/usr/lib"
			fi
72 73 74 75
		fi
	;;
esac

76

77 78 79 80 81 82
if test -f /etc/debian_version ; then
	use_deb=true;
else
	use_rpm=true;
fi

Simon Morlat's avatar
Simon Morlat committed
83
AC_ARG_ENABLE(debug,
84
		[  --enable-debug    Turn on debug mode (default=no)],
Simon Morlat's avatar
Simon Morlat committed
85 86 87 88
		[case "${enableval}" in
		yes) debug=true ;;
		no)  debug=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
89
		esac],[debug=false])
Simon Morlat's avatar
Simon Morlat committed
90

91
CFLAGS="$CFLAGS -fms-extensions"
Simon Morlat's avatar
Simon Morlat committed
92
if test "$debug" = "no" ; then
93
	CFLAGS="$CFLAGS -g -O2"
Simon Morlat's avatar
Simon Morlat committed
94
else
95
	CFLAGS="$CFLAGS -g"
Simon Morlat's avatar
Simon Morlat committed
96
fi
97

Simon Morlat's avatar
Simon Morlat committed
98
AC_ARG_ENABLE(strict,
99
		[  --enable-strict    Turn on strict mode compilation, no warnings allowed (default=yes)],
Simon Morlat's avatar
Simon Morlat committed
100 101 102 103 104
		[case "${enableval}" in
		yes) strict=true ;;
		no)  strict=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-strict) ;;
		esac],[strict=true])
Simon Morlat's avatar
Simon Morlat committed
105

Simon Morlat's avatar
Simon Morlat committed
106
STRICT_OPTIONS="-Wall"
107 108
STRICT_OPTIONS_CC=""
STRICT_OPTIONS_CXX=""
Simon Morlat's avatar
Simon Morlat committed
109

110 111
case "$CC" in
	*clang*)
112
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-error=unknown-warning-option -Qunused-arguments -Wno-tautological-compare -Wno-builtin-requires-header -Wno-unused-function -Wno-gnu-designator "
113 114 115 116 117 118 119 120
	#disabled due to wrong optimization false positive with small string
	#(cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903)
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-array-bounds "
	;;
	gcc*)
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-error=pragmas"
	;;
esac
Simon Morlat's avatar
Simon Morlat committed
121

122 123 124 125 126 127 128 129 130
# because Darwin's gcc is actually clang, we need to check it...
case "$target_os" in
	*darwin*)
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-error=unknown-warning-option -Qunused-arguments -Wno-tautological-compare -Wno-unused-function "
	#disabled due to wrong optimization false positive with small string
	#(cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903)
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-array-bounds "
	;;
esac
Simon Morlat's avatar
Simon Morlat committed
131

132
if test "$strict" = "true"; then
133 134
	STRICT_OPTIONS="$STRICT_OPTIONS -Werror -Wno-error=unknown-pragmas -Wuninitialized"
	STRICT_OPTIONS_CC="$STRICT_OPTIONS_CC -Wdeclaration-after-statement"
Simon Morlat's avatar
Simon Morlat committed
135
fi
Simon Morlat's avatar
Simon Morlat committed
136

137
dnl because of antlr3 we must accept a few warnings...
Simon Morlat's avatar
Simon Morlat committed
138
dnl more portable for the moment
139
       LESS_STRICT_OPTIONS=
Simon Morlat's avatar
Simon Morlat committed
140 141 142
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 "
143 144

AC_SUBST(STRICT_OPTIONS)
145
AC_SUBST(STRICT_OPTIONS_CC)
146
AC_SUBST(STRICT_OPTIONS_CXX)
147 148 149 150 151
AC_SUBST(LESS_STRICT_OPTIONS)

# Checks for libraries.

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

found_antlr3=no
Simon Morlat's avatar
Simon Morlat committed
157
if test "$antlr_prefix" != "NONE" && test "$antlr_prefix" != "/usr" ; then
158 159 160 161 162
	ANTLR_CFLAGS="-I${antlr_prefix}/include"
	ANTLR_LIBS="-L${antlr_prefix}/lib"
fi

ANTLR_LIBS="$ANTLR_LIBS -lantlr3c"
jehan's avatar
jehan committed
163 164 165

dnl check antlr headers
CPPFLAGS_save=$CPPFLAGS
166
CPPFLAGS="$ANTLR_CFLAGS $CPPFLAGS"
167
AC_CHECK_HEADERS([antlr3.h], [found_antlr3=yes])
168 169 170 171
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>])
172 173
libresolv_have_res_get_servers=no
resolv_h_hav_res_ndestroy=no
174 175 176
LIBS_save=$LIBS

LIBS="$LIBS -lresolv"
177

178 179 180 181 182 183
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])])
184

185 186 187 188
AC_CHECK_DECL([res_ndestroy],
		[resolv_h_hav_res_ndestroy=yes],
		[foo=bar],
		[#include <resolv.h>])
189 190 191
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
192
CPPFLAGS=$CPPFLAGS_save
193

jehan's avatar
jehan committed
194
if test "$found_antlr3" != "yes" ; then
195
	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
196 197 198
	ANTLR_CFLAGS=
	ANTLR_LIBS=
fi
Simon Morlat's avatar
Simon Morlat committed
199
AC_PATH_PROG([ANTLR],[antlr3],[no],[$antlr_prefix/bin /usr/bin])
jehan's avatar
jehan committed
200 201 202 203 204 205 206

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
207 208 209 210
		if test -f $antlr_jar ; then
			break
		else
			antlr_jar=no
211 212 213 214 215 216 217
		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
218 219 220 221
	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
222
	AC_PATH_PROG([JAVA],[java],[no])
jehan's avatar
jehan committed
223 224
	if test $JAVA = "no" ; then
		AC_MSG_ERROR([Could not find java prog. Please install java ])
225
	else
226
		ANTLR="$JAVA -Xmx256m -jar $antlr_jar"
jehan's avatar
jehan committed
227
	fi
228
fi
jehan's avatar
jehan committed
229 230 231
AC_SUBST(ANTLR_CFLAGS)
AC_SUBST(ANTLR_LIBS)

Simon Morlat's avatar
Simon Morlat committed
232 233 234 235 236 237 238 239
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])

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

Simon Morlat's avatar
Simon Morlat committed
244
if test "$polarssl_prefix" != "NONE" && test "$polarssl_prefix" != "/usr"; then
245 246 247 248 249 250 251
	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
252
if test "$use_tls" = "true" ; then
253 254 255 256 257 258 259
	CPPFLAGS_save=$CPPFLAGS
	LIBS_save=$LIBS

	CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
	LIBS="$LIBS $POLARSSL_LIBS"
	AC_CHECK_HEADERS(polarssl/ssl.h,
		[
260
		AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Guillaume Beraudo's avatar
Guillaume Beraudo committed
261 262
			#include <polarssl/version.h>
			#include <polarssl/x509.h>
263 264 265 266 267 268 269 270
			#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])]
271
			,[AC_MSG_ERROR([polarssl not found or usable but TLS support required.])])
272

273
		])
274 275
	CPPFLAGS=$CPPFLAGS_save
	LIBS=$LIBS_save
Simon Morlat's avatar
Simon Morlat committed
276
fi
jehan's avatar
jehan committed
277

278
AM_CONDITIONAL([BUILD_TLS], [test "x$found_polarssl" = "xyes"])
279 280
TLS_CFLAGS=""
TLS_LIBS=""
jehan's avatar
jehan committed
281
TLS_PC=""
282 283 284 285
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
286
fi
287
AC_SUBST(TLS_CFLAGS)
288
AC_SUBST(TLS_LIBS)
jehan's avatar
jehan committed
289
AC_SUBST(TLS_PC)
290

291 292 293 294 295 296 297 298 299 300 301 302 303
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
304 305 306 307 308 309 310 311
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
312
AM_CONDITIONAL(BUILD_TUNNEL, test "$found_tunnel" = "yes")
Ghislain MARY's avatar
Ghislain MARY committed
313

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

316
if test "$found_pkg_config_cunit" = "no" ; then
317 318
	AC_CHECK_HEADERS(CUnit/CUnit.h,
		[
Simon Morlat's avatar
Simon Morlat committed
319 320 321 322
			AC_CHECK_LIB(cunit,CU_add_suite,[
				found_cunit=yes
				CUNIT_LIBS+=" -lcunit"
			])
323

324
		])
325 326
else
	found_cunit=yes
327
fi
Simon Morlat's avatar
Simon Morlat committed
328 329 330 331 332
case "$target_os" in
	*darwin*)
		#hack for macport
		CUNIT_LIBS+=" -lncurses"
	;;
Simon Morlat's avatar
Simon Morlat committed
333
	*mingw*)
Ghislain MARY's avatar
Ghislain MARY committed
334
		LIBBELLESIP_CFLAGS="-DBELLESIP_EXPORTS"
Simon Morlat's avatar
Simon Morlat committed
335
		CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
336
		LIBS="$LIBS -lws2_32 -liphlpapi"
Ghislain MARY's avatar
Ghislain MARY committed
337
		LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
Simon Morlat's avatar
Simon Morlat committed
338
	;;
Simon Morlat's avatar
Simon Morlat committed
339
esac
Ghislain MARY's avatar
Ghislain MARY committed
340
AC_SUBST(LIBBELLESIP_CFLAGS)
Simon Morlat's avatar
Simon Morlat committed
341

342
if test "$found_cunit" = "no" ; then
343
	AC_MSG_WARN([Could not find cunit framework, tests are not compiled.])
344
else
345 346 347
	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])
348 349 350
	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])
351
fi
jehan's avatar
jehan committed
352 353 354 355 356 357 358 359 360 361
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)
362

363
REQUIRES_PRIVATE=""
364 365
LIBS_PRIVATE=""
if test "$found_pkg_config_cunit" = "yes" ; then
366
	REQUIRES_PRIVATE="$REQUIRES_PRIVATE cunit"
367 368 369 370
else
	if test "$found_cunit" = "yes" ; then
		LIBS_PRIVATE="$LIBS_PRIVATE $CUNIT_LIBS"
	fi
371
fi
372
LIBS_PRIVATE="$LIBS_PRIVATE $ANTLR_LIBS $POLARSSL_LIBS"
373 374 375
AC_SUBST(REQUIRES_PRIVATE)
AC_SUBST(LIBS_PRIVATE)

376 377 378
# Checks for typedefs, structures, and compiler characteristics.


379 380
# Eliminate -lstdc++ addition to postdeps for cross compiles.
postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
381 382


383
# Checks for library functions.
384
AC_CHECK_LIB(rt, clock_gettime)
Simon Morlat's avatar
Simon Morlat committed
385
AC_CHECK_LIB(dl, dlopen)
386 387
AC_CHECK_LIB(pthread, pthread_getspecific,,
    [AC_MSG_ERROR([pthread library not found])])
388 389 390 391 392 393 394

AC_CONFIG_FILES(
[
Makefile
include/Makefile
include/belle-sip/Makefile
src/Makefile
395
src/grammars/Makefile
396
tester/Makefile
jehan's avatar
jehan committed
397
belle-sip.pc
jehan's avatar
jehan committed
398
belle-sip.spec
399 400
])
AC_OUTPUT