configure.ac 10.9 KB
Newer Older
aymeric's avatar
aymeric committed
1
dnl Process this file with autoconf to produce a configure script.
2
AC_INIT([ortp],[1.0.1])
aymeric's avatar
aymeric committed
3 4
AC_CANONICAL_SYSTEM

5 6 7 8 9 10
case $INSTALL in
        *ginstall*)
                INSTALL="$INSTALL -C"
        ;;
esac

aymeric's avatar
aymeric committed
11 12 13 14 15 16
dnl Source packaging numbers
ORTP_MAJOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f1)
ORTP_MINOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f2)
ORTP_MICRO_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f3)
ORTP_EXTRA_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f4)

17
LIBORTP_SO_CURRENT=13 dnl increment this number when you add/change/remove an interface
aymeric's avatar
aymeric committed
18
LIBORTP_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
19
LIBORTP_SO_AGE=0 dnl increment this number when you add an interface, set to 0 if you remove an interface
aymeric's avatar
aymeric committed
20 21 22 23 24 25 26 27 28 29

LIBORTP_SO_VERSION=$LIBORTP_SO_CURRENT:$LIBORTP_SO_REVISION:$LIBORTP_SO_AGE
ORTP_VERSION=${ORTP_MAJOR_VERSION}.${ORTP_MINOR_VERSION}.${ORTP_MICRO_VERSION}

if test -n "$ORTP_EXTRA_VERSION" ; then
	ORTP_VERSION="${ORTP_VERSION}.${ORTP_EXTRA_VERSION}"
fi

ORTP_PKGCONFIG_VERSION=${ORTP_VERSION}

30
AC_SUBST(LIBORTP_SO_CURRENT, $LIBORTP_SO_CURRENT)
aymeric's avatar
aymeric committed
31 32 33 34 35 36 37
AC_SUBST(LIBORTP_SO_VERSION)
AC_SUBST(ORTP_VERSION)
AC_SUBST(ORTP_PKGCONFIG_VERSION)


PACKAGE=ortp

38
AM_INIT_AUTOMAKE([tar-ustar foreign])
39
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
Yann Diorcet's avatar
Yann Diorcet committed
40
AC_SUBST([docdir], [${datadir}/doc])
aymeric's avatar
aymeric committed
41
AC_CONFIG_HEADERS(ortp-config.h)
42
AC_CONFIG_MACRO_DIR([m4])
aymeric's avatar
aymeric committed
43 44 45 46 47
AC_DEFINE_UNQUOTED(ORTP_MAJOR_VERSION,$ORTP_MAJOR_VERSION, [major version])
AC_DEFINE_UNQUOTED(ORTP_MINOR_VERSION,$ORTP_MINOR_VERSION, [minor version])
AC_DEFINE_UNQUOTED(ORTP_MICRO_VERSION,$ORTP_MICRO_VERSION, [micro version])
AC_DEFINE_UNQUOTED(ORTP_VERSION,"$ORTP_VERSION",[ortp version number])

48 49 50 51
dnl Checks for programs.
AC_PROG_CC
LT_INIT([win32-dll shared disable-static])

52 53
gl_LD_OUTPUT_DEF

aymeric's avatar
aymeric committed
54
AC_MSG_CHECKING([warning make an error on compilation])
55

aymeric's avatar
aymeric committed
56
AC_ARG_ENABLE(strict,
57 58 59
	AC_HELP_STRING([--enable-strict], [Build with stricter options @<:@yes@:>@]),
	[strictness="${enableval}"],
	[strictness=yes]
aymeric's avatar
aymeric committed
60 61
)

62
STRICT_OPTIONS="-Wall -Wuninitialized"
63
STRICT_OPTIONS_CC="-Wdeclaration-after-statement -Wstrict-prototypes"
64
STRICT_OPTIONS_CXX=""
65 66 67 68 69 70 71 72 73

#for clang

case $CC in
	*clang*)
		STRICT_OPTIONS="$STRICT_OPTIONS -Qunused-arguments "
	;;
esac

74 75 76 77 78 79 80 81 82 83
# 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

84
if test "$strictness" = "yes" ; then
85
	STRICT_OPTIONS="$STRICT_OPTIONS -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers"
86 87 88
	CFLAGS="$CFLAGS -fno-strict-aliasing"
fi

89 90 91
AC_SUBST(STRICT_OPTIONS)
AC_SUBST(STRICT_OPTIONS_CC)
AC_SUBST(STRICT_OPTIONS_CXX)
92

aymeric's avatar
aymeric committed
93
AC_ARG_ENABLE(perf,
Yann Diorcet's avatar
Yann Diorcet committed
94 95 96
	[AS_HELP_STRING([--enable-perf], [Disable costly features to reduce cpu consumtion (default=no)])],
	[perf=$enableval],
	[perf=no]
aymeric's avatar
aymeric committed
97 98 99 100
)

ORTP_DEFS=

Ghislain MARY's avatar
Ghislain MARY committed
101
AC_DEFINE(__APPLE_USE_RFC_3542, 1, [ Apple wants you to declare what behavior you want by defining either __APPLE_USE_RFC_3542])
102

aymeric's avatar
aymeric committed
103

Yann Diorcet's avatar
Yann Diorcet committed
104
dnl enable timestamp support
105
AC_ARG_ENABLE(ntp-timestamp,
Yann Diorcet's avatar
Yann Diorcet committed
106 107 108 109 110 111 112 113
	[AS_HELP_STRING([--enable-ntp-timestamp], [Turn on NTP timestamping on received packet (default=no)])],
	[case "${enableval}" in
		yes)	ntptimestamp=true;;
		no)	ntptimestamp=false;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-ntp-timestamp) ;;
	esac],
	[ntptimestamp=false]
)
114
if test x$ntptimestamp = xtrue ; then
Yann Diorcet's avatar
Yann Diorcet committed
115 116 117
	ORTP_DEFS="$ORTP_DEFS -DORTP_TIMESTAMP"
fi

aymeric's avatar
aymeric committed
118
AC_ARG_ENABLE(mode64bit,
Yann Diorcet's avatar
Yann Diorcet committed
119 120 121 122 123 124 125 126
	[AS_HELP_STRING([--enable-mode64bit], [Produce a 64-bit library (default=no)])],
	[case "${enableval}" in
		yes)	mode64bit_enabled=yes;;
		no)	mode64bit_enabled=no;;
		*)	AC_MSG_ERROR("Bad value for --enable-mode64bit");;
	esac],
	[mode64bit_enabled=no]
)
aymeric's avatar
aymeric committed
127 128

AC_ARG_ENABLE(debug,
Yann Diorcet's avatar
Yann Diorcet committed
129 130 131 132 133 134 135 136
	[AS_HELP_STRING([--enable-debug], [Enable the display of traces showing the execution of the library (default=yes)])],
	[case "${enableval}" in
		yes)	debug_enabled=yes;;
		no)	debug_enabled=no;;
		*)	AC_MSG_ERROR("Bad value for --enable-debug");;
	esac],
	[debug_enabled=no]
)
aymeric's avatar
aymeric committed
137 138 139 140 141 142

hpux_host=no
posixtimer_interval=10000
PTHREAD_LDFLAGS=

case "$target_os" in
143
	*hpux*)
aymeric's avatar
aymeric committed
144 145 146 147
		hpux_host=yes
		AC_DEFINE(NOCONNECT,1,[Defined if we should not use connect() on udp sockets])
		CFLAGS="$CFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506L"
		LIBS="$LIBS -lxnet"
Yann Diorcet's avatar
Yann Diorcet committed
148
	;;
aymeric's avatar
aymeric committed
149 150 151
	*freebsd*)
		AC_DEFINE(NOCONNECT,1,[Defined if we should not use connect() on udp sockets])
		PTHREAD_LDFLAGS="-pthread"
Yann Diorcet's avatar
Yann Diorcet committed
152
	;;
jehan monnier's avatar
jehan monnier committed
153
	*mingw32ce)
154 155 156
		CFLAGS="$CFLAGS -D_WIN32_WCE -D_WIN32_WINNT=0x0501 -DORTP_STATIC"
		LIBS="$LIBS -lws2 -liphlpapi"
		mingw_found=yes
Yann Diorcet's avatar
Yann Diorcet committed
157
	;;
158 159 160
	*mingw*)
		CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0501 -DORTP_STATIC"
		LIBS="$LIBS -lws2_32 -liphlpapi -lwinmm"
161
		mingw_found=yes
Yann Diorcet's avatar
Yann Diorcet committed
162
	;;
aymeric's avatar
aymeric committed
163 164
esac

165
AM_CONDITIONAL(BUILD_WIN32, test "$mingw_found" = "yes")
Yann Diorcet's avatar
Yann Diorcet committed
166 167 168 169 170 171 172 173 174
AC_CONFIG_COMMANDS([libtool-hacking],
	[if test "$mingw_found" = "yes" ; then
		echo "Hacking libtool to work with mingw..."
		sed -e 's/\*\" \$a_deplib \"\*/\*/' < ./libtool > libtool.tmp
		cp -f ./libtool.tmp ./libtool
		rm -f ./libtool.tmp
	fi],
	[mingw_found=$mingw_found]
)
175

aymeric's avatar
aymeric committed
176 177 178 179 180 181 182 183 184
if test "$GCC" != "yes" ; then
	if test "$hpux_host" = "yes" ; then
		dnl we are probably using HPUX cc compiler, so add a +O2 to CFLAGS
			CFLAGS="$CFLAGS +O2 -g "
		if test x$mode64bit_enabled = xyes ; then
			CFLAGS="$CFLAGS +DA2.0W +DS2.0"
		fi
	fi
else
185
	CFLAGS="$CFLAGS -Wall"
aymeric's avatar
aymeric committed
186 187 188 189 190 191 192
fi

build_scheduler=yes

dnl Check if we have seteuid system call
AC_CHECK_FUNCS(seteuid)

193 194 195
dnl Check if we have arc4random family routines available
AC_CHECK_FUNCS(arc4random)

aymeric's avatar
aymeric committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209

dnl check if we can use the pthread_library
AC_CHECK_LIB(pthread, pthread_mutex_init, [pthread_enabled=yes], [pthread_enabled=no])
if test $pthread_enabled = "no" ; then
	build_scheduler=no
else
	PTHREAD_LIBS="-lpthread"
	PTHREAD_CFLAGS="-D_REENTRANT"
	AC_SUBST(PTHREAD_CFLAGS)
	AC_SUBST(PTHREAD_LIBS)
	AC_SUBST(PTHREAD_LDFLAGS)
fi
AC_ARG_WITH(thread-stack-size,
	AC_HELP_STRING([--with-thread-stack-size=SIZE-IN-BYTES],[Set thread stack size [[default=os-default]]]),
Yann Diorcet's avatar
Yann Diorcet committed
210 211 212
	[thread_stack_size=$withval],
	[thread_stack_size=0]
)
Yann Diorcet's avatar
Yann Diorcet committed
213
AC_DEFINE_UNQUOTED(ORTP_DEFAULT_THREAD_STACK_SIZE, $thread_stack_size, [Default thread stack size (0 = let uperating system decide)])
aymeric's avatar
aymeric committed
214 215


216 217
dnl check if we can use the rt library
AC_CHECK_LIB(rt, clock_gettime, [rt_enabled=yes])
Simon Morlat's avatar
Simon Morlat committed
218
if test "$rt_enabled" = "yes" ; then
219 220 221 222 223
	RT_LIBS="-lrt"
	AC_SUBST(RT_LIBS)
fi


aymeric's avatar
aymeric committed
224
if test $debug_enabled = "yes"; then
225
	ORTP_DEFS="$ORTP_DEFS -DORTP_DEBUG_MODE"
aymeric's avatar
aymeric committed
226
	CFLAGS=`echo $CFLAGS | sed 's/-O.//'`
227
	CFLAGS="$CFLAGS -g"
aymeric's avatar
aymeric committed
228 229
fi

230

aymeric's avatar
aymeric committed
231
AC_ARG_ENABLE(memcheck,
Yann Diorcet's avatar
Yann Diorcet committed
232 233 234 235 236 237 238 239
	[AS_HELP_STRING([--enable-memcheck], [Enable memory leak detection (HPUX only)])],
	[case "${enableval}" in
		yes)	memcheck_enabled=yes;;
		no)	memcheck_enabled=no;;
		*)	AC_MSG_ERROR("Bad value for --enable-memcheck");;
	esac],
	[memcheck_enabled=no]
)
240

aymeric's avatar
aymeric committed
241 242 243 244 245 246 247 248
if test "$memcheck_enabled" = "yes" ; then
	if test "$hpux_host" = "yes" ; then
		AC_DEFINE(ENABLE_MEMCHECK,1,[Defined when memory leak checking if enabled])
	else
		echo "WARNING ************ : the memory check option is only available for HPUX."
	fi
fi

249

aymeric's avatar
aymeric committed
250 251
dnl Checks for header files.
AC_HEADER_STDC
252
AC_CHECK_HEADERS(poll.h sys/poll.h sys/uio.h fcntl.h sys/time.h unistd.h sys/audio.h linux/soundcard.h sys/shm.h stdatomic.h)
aymeric's avatar
aymeric committed
253 254 255 256 257 258 259 260 261 262 263 264 265 266

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME
AC_WORDS_BIGENDIAN
if test x$ac_cv_c_bigendian = xyes ; then
	ORTP_DEFS="$ORTP_DEFS -DORTP_BIGENDIAN"
fi

dnl Checks for library functions.
AC_CHECK_FUNCS(select socket strerror)

if test $hpux_host = "yes" ; then
267
dnl it seems 10 ms is too fast on hpux and it causes trouble
aymeric's avatar
aymeric committed
268 269 270 271 272 273 274 275 276
		posixtimer_interval=20000
fi

AC_DEFINE_UNQUOTED(POSIXTIMER_INTERVAL,$posixtimer_interval,[Defines the periodicity of the rtp scheduler in microseconds])

if test "$perf" = "yes" ; then
	CFLAGS="$CFLAGS -DPERF"
fi

277

278 279 280
PKG_CHECK_MODULES(BCTOOLBOX, bctoolbox, [found_bctoolbox=yes],[found_bctoolbox=no])
if test "x$found_bctoolbox" != "xyes" ; then
	AC_MSG_ERROR(["Could not find bctoolbox (required dependency)"])
281 282 283
fi


284
ORTPDEPS_LIBS="$ORTPDEPS_LIBS $PTHREAD_LDFLAGS $BCTOOLBOX_LIBS"
285
ORTPDEPS_CFLAGS="$ORTPDEPS_CFLAGS $PTHREAD_CFLAGS $ORTP_DEFS $BCTOOLBOX_CFLAGS"
aymeric's avatar
aymeric committed
286 287 288 289
CFLAGS="$CFLAGS $ORTP_DEFS"
echo "$ORTPDEPS_CFLAGS" > ortp.defs


290
AC_ARG_ENABLE(tests,
Yann Diorcet's avatar
Yann Diorcet committed
291 292 293 294 295 296 297 298
	[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=false]
)
299
AM_CONDITIONAL(ENABLE_TESTS, test x$tests_enabled = xtrue)
300

301 302 303 304 305 306 307
case "$target_os" in
	*linux*)
		# Eliminate -lstdc++ addition to postdeps for cross compiles.
		postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
	;;
esac

aymeric's avatar
aymeric committed
308
dnl ##################################################
smorlat's avatar
smorlat committed
309
dnl # Check for doxygen
aymeric's avatar
aymeric committed
310
dnl ##################################################
311 312
AC_ARG_ENABLE(documentation,
	[AS_HELP_STRING([--enable-documentation], [Documentation generation using doxygen (default=yes)])],
313 314 315
	[case "${enableval}" in
		yes)	documentation_enabled=yes;;
		no)		documentation_enabled=no;;
316
		*)		AC_MSG_ERROR("Bad value for --enable-documentation");;
317 318 319 320 321 322 323 324 325
	esac],
	[documentation_enabled=yes]
)
if test "$documentation_enabled" = "yes" ; then
	AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,false)
else
	DOXYGEN=false
fi
AM_CONDITIONAL(HAVE_DOXYGEN, test "$DOXYGEN" != "false")
aymeric's avatar
aymeric committed
326 327 328 329 330 331 332 333 334 335 336 337

dnl ##################################################
dnl # Check for ESP Packager
dnl ##################################################

AC_PATH_PROG(EPM,epm,false)
AC_PATH_PROG(MKEPMLIST,mkepmlist,false)
AC_PATH_PROG(EPMINSTALL,epminstall,false)
AM_CONDITIONAL(WITH_EPM,test $EPM != false && test $MKEPMLIST != false && test $EPMINSTALL != false)

# Preferred packaging system, as per EPM terminology
case $target in
Yann Diorcet's avatar
Yann Diorcet committed
338 339 340 341 342 343 344 345 346 347 348 349 350
	*-*-linux*)
		if test -f /etc/debian_version ; then
			EPM_PKG_EXT=deb
		else
			EPM_PKG_EXT=rpm
		fi
	;;
	*-hp-hpux*)
		EPM_PKG_EXT=depot.gz
	;;
	*-dec-osf*)
		EPM_PKG_EXT=setld
	;;
aymeric's avatar
aymeric committed
351 352 353 354 355
esac
AC_SUBST(EPM_PKG_EXT)

# System software User & Group names
case $target in
Yann Diorcet's avatar
Yann Diorcet committed
356 357 358
	*-*-linux*)
		SYS_USER=root
		SYS_GROUP=root
aymeric's avatar
aymeric committed
359
	;;
Yann Diorcet's avatar
Yann Diorcet committed
360 361 362
	*-*-hpux*|*-dec-osf*)
		SYS_USER=bin
		SYS_GROUP=bin
aymeric's avatar
aymeric committed
363 364 365 366 367 368 369
	;;
esac
AC_SUBST(SYS_USER)
AC_SUBST(SYS_GROUP)

# CPU Architecture
case $target_cpu in
Yann Diorcet's avatar
Yann Diorcet committed
370 371 372 373 374
	i?86)
		ARCH=i386
	;;
	*)	ARCH=$target_cpu
	;;
aymeric's avatar
aymeric committed
375 376 377 378 379
esac
AC_SUBST(ARCH)

# Various other packaging variables, that can be over-ridden ad `make
# package' time
380
SUMMARY="Implementation of RTP - RFC3550"
aymeric's avatar
aymeric committed
381 382 383
AC_SUBST(SUMMARY)
PACKAGER=anonymous
AC_SUBST(PACKAGER)
384
LICENSE=GPLv2+
aymeric's avatar
aymeric committed
385 386 387 388 389 390 391 392 393 394 395
AC_SUBST(LICENSE)
VENDOR=Linphone
AC_SUBST(VENDOR)
RELEASE=1
AC_SUBST(RELEASE)

AC_SUBST(ORTPDEPS_CFLAGS)
AC_SUBST(ORTPDEPS_LIBS)
AC_SUBST(ORTPDEPS_LDFLAGS)

AC_OUTPUT(
Yann Diorcet's avatar
Yann Diorcet committed
396 397 398 399 400 401 402 403 404 405 406 407
	Makefile
	include/Makefile
	include/ortp/Makefile
	m4/Makefile
	src/Makefile
	src/tests/Makefile
	src/tests/win_receiver/Makefile
	src/tests/win_sender/Makefile
	build/Makefile
	ortp.pc
	ortp.spec
	ortp.doxygen
aymeric's avatar
aymeric committed
408 409
)