configure.ac 4.56 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
CPPFLAGS=$CPPFLAGS_save
74

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

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
93
	AC_PATH_PROG([JAVA],[java],[no])
jehan's avatar
jehan committed
94 95 96 97 98
	if test $JAVA = "no" ; then
		AC_MSG_ERROR([Could not find java prog. Please install java ])
	else	
		ANTLR="$JAVA -jar $antlr_jar"
	fi
99
fi
jehan's avatar
jehan committed
100 101 102
AC_SUBST(ANTLR_CFLAGS)
AC_SUBST(ANTLR_LIBS)

jehan's avatar
jehan committed
103
PKG_CHECK_MODULES(GNUTLS, gnutls, [found_gnutls=yes],foo=bar)
jehan's avatar
jehan committed
104
#PKG_CHECK_MODULES(OPENSSL, openssl, [found_openssl=yes],foo=bar)
jehan's avatar
jehan committed
105

106 107 108
AM_CONDITIONAL([BUILD_TLS], [test "x$found_gnutls" = "xyes" || test "x$found_openssl" = "xyes"])
TLS_CFLAGS=""
TLS_LIBS=""
jehan's avatar
jehan committed
109
TLS_PC=""
jehan's avatar
jehan committed
110
if test "x$found_gnutls" = "xyes" ; then
jehan's avatar
jehan committed
111
	GNUTLS_LIBS+="$GNUTLS_LIBS -lgnutls-openssl "
112 113 114
	AC_DEFINE(HAVE_GNUTLS,1,[Defined when gnutls api is available])
	TLS_CFLAGS=$GNUTLS_CFLAGS
	TLS_LIBS=$GNUTLS_LIBS
jehan's avatar
jehan committed
115
	TLS_PC=gnutls
116 117 118 119
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
120
fi
121 122
AC_SUBST(TLS_CFLAGS)
AC_SUBST(TLS_LIBS)	
jehan's avatar
jehan committed
123
AC_SUBST(TLS_PC)
124

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

127 128 129
if test "$found_cunit" = "no" ; then
	AC_CHECK_HEADERS(CUnit/CUnit.h,
		[
Simon Morlat's avatar
Simon Morlat committed
130 131 132 133
			AC_CHECK_LIB(cunit,CU_add_suite,[
				found_cunit=yes
				CUNIT_LIBS+=" -lcunit"
			])
134
			
135 136
		])
fi
Simon Morlat's avatar
Simon Morlat committed
137 138 139 140 141
case "$target_os" in
	*darwin*)
		#hack for macport
		CUNIT_LIBS+=" -lncurses"
	;;
Simon Morlat's avatar
Simon Morlat committed
142 143
	*mingw*)
		CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
144
		LIBS="$LIBS -lws2_32 -liphlpapi"
Ghislain MARY's avatar
Ghislain MARY committed
145
		LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
Simon Morlat's avatar
Simon Morlat committed
146
	;;
Simon Morlat's avatar
Simon Morlat committed
147 148
esac

149
if test "$found_cunit" = "no" ; then
150
	AC_MSG_WARN([Could not find cunit framework, tests are not compiled.])
151 152 153 154
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])
155 156 157
	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])
158 159
fi

jehan's avatar
jehan committed
160
AM_CONDITIONAL(BUILD_TESTS,test x$found_cunit = xyes)
161 162 163 164
# Checks for typedefs, structures, and compiler characteristics.


# Checks for library functions.
165
AC_CHECK_LIB(rt, clock_gettime)
Simon Morlat's avatar
Simon Morlat committed
166
AC_CHECK_LIB(dl, dlopen)
167 168 169 170 171 172 173 174 175


AC_CONFIG_FILES(
[
Makefile
include/Makefile
include/belle-sip/Makefile
src/Makefile
tester/Makefile
jehan's avatar
jehan committed
176
belle-sip.pc
177 178
])
AC_OUTPUT