summaryrefslogtreecommitdiffstats
path: root/configure.in
blob: cb3710d8b1a2887c338572f199fca9af92b89122 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
AC_INIT(configure.in)
AM_INIT_AUTOMAKE(jrtplib,3.7.1)

RTP_FILIO="// Don't have <sys/filio.h>"
RTP_SOCKIO="// Don't have <sys/sockio.h>"
RTP_ENDIAN="// Little endian system"
RTP_SOCKLENTYPE_UINT="// socklen_t is int'"
RTP_HAVE_SOCKADDR_LEN="// No sa_len member in struct sockaddr"
RTP_SUPPORT_IPV4MULTICAST="// No IPv4 multicasting support"
RTP_SUPPORT_IPV6MULTICAST="// No IPv6 multicasting support"
RTP_SUPPORT_THREAD="// No support for jthread"
RTP_SUPPORT_SDESPRIV="// No support for SDES PRIV items"
RTP_SUPPORT_PROBATION="// Do not wait for a number of consecutive packets to validate source"
RTP_SUPPORT_GNUDRAND="// Not using drand48_r and srand48_r"
RTP_SUPPORT_RANDR="// Not using rand_r"
RTP_SUPPORT_GETLOGINR="// Not using getlogin_r"
RTP_SUPPORT_IPV6="// No IPv6 support"
RTP_SUPPORT_IFADDRS="// No ifaddrs support"
RTP_SUPPORT_SENDAPP="// No direct support for sending RTCP APP packets"
RTP_SUPPORT_MEMORYMANAGEMENT="// No memory management support"
RTP_LINKLIBS=""

RTP_CHECK_JTHREADLINK="no"

if test "BLA$CXXFLAGS" = "BLA" ; then
	dnl CXXFLAGS="-g -Werror -Wall"
	CXXFLAGS="-O2 "
fi

dnl ---------------------------------------------------------------------------
dnl Set language to C++ and do libtool stuff
dnl ---------------------------------------------------------------------------

AC_LANG(C++)

AM_PROG_LIBTOOL

dnl ---------------------------------------------------------------------------
dnl Check for the SDES PRIV support
dnl ---------------------------------------------------------------------------

AC_ARG_ENABLE(sdespriv,[  --disable-sdespriv      Disable support for SDES PRIV items],[
	if test "$enableval" = yes ; then
		privsupport="yes"
	else
		privsupport="no"
	fi],[
	privsupport="yes"
	])
	
if test "$privsupport" = "yes" ; then
	RTP_SUPPORT_SDESPRIV="#define RTP_SUPPORT_SDESPRIV"
fi

dnl ---------------------------------------------------------------------------
dnl Check for the probation support
dnl ---------------------------------------------------------------------------

AC_ARG_ENABLE(probation,[  --disable-probation     Disable support for probation of a new source],[
	if test "$enableval" = yes ; then
		probsupport="yes"
	else
		probsupport="no"
	fi],[
	probsupport="yes"
	])
	
if test "$probsupport" = "yes" ; then
	RTP_SUPPORT_PROBATION="#define RTP_SUPPORT_PROBATION"
fi

dnl ---------------------------------------------------------------------------
dnl Check for RTCP APP sending support
dnl ---------------------------------------------------------------------------

AC_ARG_ENABLE(sendapp,[  --disable-sendapp       Disable support for sending RTCP APP packets],[
	if test "$enableval" = yes ; then
		sendappupport="yes"
	else
		sendappsupport="no"
	fi],[
	sendappsupport="yes"
	])
	
if test "$sendappsupport" = "yes" ; then
	RTP_SUPPORT_SENDAPP="#define RTP_SUPPORT_SENDAPP"
fi

dnl ---------------------------------------------------------------------------
dnl Check for memory management support
dnl ---------------------------------------------------------------------------

AC_ARG_ENABLE(memory,[  --disable-memory        Disable support for memory management],[
	if test "$enableval" = yes ; then
		memsupport="yes"
	else
		memsupport="no"
	fi],[
	memsupport="yes"
	])
	
if test "$memsupport" = "yes" ; then
	RTP_SUPPORT_MEMORYMANAGEMENT="#define RTP_SUPPORT_MEMORYMANAGEMENT"
fi

dnl ---------------------------------------------------------------------------
dnl Check for the jthread headers
dnl ---------------------------------------------------------------------------

AC_ARG_ENABLE(jthread,[  --disable-jthread       Disable support for JThread],[
	if test "$enableval" = yes ; then
		checkjthread="yes"
	else
		checkjthread="no"
	fi],[
	checkjthread="yes"
	])

if test "$checkjthread" = "yes" ; then
	searchdirs="/usr/include/jthread /usr/local/include/jthread"

	AC_MSG_CHECKING(for JThread include files)
	AC_ARG_WITH(jthread-includes,[  --with-jthread-includes Directory where JThread include files are located],
		[
		if test -e "$withval"/jthread.h && test -e "$withval"/jmutex.h ; then
			AC_MSG_RESULT(in "$withval")
			AC_MSG_CHECKING(JThread version)
			AC_COMPILE_IFELSE([ 
				#include "$withval/jthread.h"
				class MyThread : public JThread
				{
				public:
					void *Thread() { JThread::ThreadStarted(); return 0; }
				};],[
				RTP_JTHREADINCLUDES="-I $withval"
				RTP_SUPPORT_THREAD="#define RTP_SUPPORT_THREAD"
				RTP_CHECK_JTHREADLINK="yes"
dnl				RTP_LINKLIBS="$RTP_LINKLIBS -ljthread -lpthread"
				AC_MSG_RESULT(>= 1.1.0) ],[
				AC_MSG_RESULT(< 1.1.0)
				AC_MSG_WARN(You need at least JThread version 1.1.0. Support for JThread has been disabled)])
		else
			AC_MSG_RESULT(not found)
			AC_MSG_WARN(The JThread include files were not found in $withval. Support for JThread has been disabled)
		fi
		],
		[
			for i in $searchdirs ; do
				if test -e $i/jthread.h && test -e $i/jmutex.h ; then
					RTP_JTHREADINCLUDEDIR="$i"
					AC_MSG_RESULT($i)
					break
				fi
			done
			if test "BLAAI$RTP_JTHREADINCLUDEDIR" = "BLAAI" ; then
				AC_MSG_RESULT(not found)
				AC_MSG_WARN(Unable to locate the JThread include files. Please specify the include path with --with-jthread-includes if they exist on your system. JThread support has been disabled)
			else
				AC_MSG_CHECKING(JThread version)
				AC_COMPILE_IFELSE([ 
					#include "$RTP_JTHREADINCLUDEDIR/jthread.h"
					class MyThread : public JThread
					{
					public:
						void *Thread() { JThread::ThreadStarted(); return 0; }
					};],[
					RTP_JTHREADINCLUDES="-I $RTP_JTHREADINCLUDEDIR"
					RTP_SUPPORT_THREAD="#define RTP_SUPPORT_THREAD"
					RTP_CHECK_JTHREADLINK="yes"
dnl					RTP_LINKLIBS="$RTP_LINKLIBS -ljthread -lpthread"
					AC_MSG_RESULT(>= 1.1.0) ],[
					AC_MSG_RESULT(< 1.1.0)
					AC_MSG_WARN(You need at least JThread version 1.1.0. Support for JThread has been disabled)])
			fi
		])
fi

if test "$RTP_CHECK_JTHREADLINK" = "yes" ; then
	AC_MSG_CHECKING(if we can link against jthread and pthread)
	oldldflags="$LDFLAGS"
	LDFLAGS="$LDFLAGS -ljthread -lpthread"
	AC_LINK_IFELSE( [ int main(void) { } ] ,
	                [ RTP_LINKLIBS="$RTP_LINKLIBS -ljthread -lpthread"
			  AC_MSG_RESULT(yes) ] ,
			[ AC_MSG_RESULT(no) ] )
	LDFLAGS="$oldldflags"
fi

dnl ---------------------------------------------------------------------------
dnl Check if sys/filio.h exists (used on solaris)
dnl ---------------------------------------------------------------------------

AC_CHECK_HEADER(sys/filio.h,[RTP_FILIO="#define RTP_HAVE_SYS_FILIO"])

dnl ---------------------------------------------------------------------------
dnl Check if sys/sockio.h exists (used on solaris)
dnl ---------------------------------------------------------------------------

AC_CHECK_HEADER(sys/sockio.h,[RTP_SOCKIO="#define RTP_HAVE_SYS_SOCKIO"])

dnl ---------------------------------------------------------------------------
dnl Check if it's a big endian or little endian system
dnl Note that we must be careful when a cross-compiler is being used...
dnl ---------------------------------------------------------------------------

if test "$cross_compiling" = yes  ; then
	cat << EOF

ASSUMING TARGET IS BIG ENDIAN:

  The script detected a cross-compiler on your system. This can mean that
  there really is a cross-compiler installed, or that for some other reason,
  a simple program could not be run. You should check the config.log file
  to verify this.
  Since we are assuming a cross-compiler, we won't be able to actually test
  any program. More important, we cannot test if the system is big or little
  endian.
  For now, big endian is assumed. If this assumption should be wrong, you will
  have to comment the appropriate line in 'rtpconfig_unix.h'

EOF
	RTP_ENDIAN="#define RTP_BIG_ENDIAN // comment this if the target is a little endian system"
else
	AC_C_BIGENDIAN
	if test "$ac_cv_c_bigendian" = yes; then
		RTP_ENDIAN="#define RTP_BIG_ENDIAN"
	fi
fi

dnl ---------------------------------------------------------------------------
dnl Check if compiler supports -Werror -Wall
dnl ---------------------------------------------------------------------------
oldcxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror -Wall"
AC_MSG_CHECKING(if compiler supports -Werror -Wall)
AC_TRY_COMPILE([
	#include <stdio.h>],[
	printf("Hello world\n");],
	AC_MSG_RESULT(yes),[
	AC_MSG_RESULT(no)
	CXXFLAGS="$oldcxxflags"])

dnl ---------------------------------------------------------------------------
dnl Check what the last argument for getsockname is
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(last argument of getsockname)
AC_TRY_COMPILE([#include <sys/types.h>
	#include <sys/socket.h>],
	[int param;
	int sock = 0;
	struct sockaddr addr;
	getsockname(sock,&addr,&param);],
	AC_MSG_RESULT(int),
	[
	AC_MSG_RESULT(unsigned int)
	RTP_SOCKLENTYPE_UINT="#define RTP_SOCKLENTYPE_UINT"
	])

CXXFLAGS="$oldcxxflags"

dnl ---------------------------------------------------------------------------
dnl Check if multicast options are known
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(if necessary options for IPv4 multicasting are available)
AC_TRY_COMPILE([
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>],[
	int testval;
	struct ip_mreq mreq,mreq2;
	mreq = mreq2; // avoid 'unused variable'
	testval = IP_MULTICAST_TTL;
	testval = IP_ADD_MEMBERSHIP;
	testval = IP_DROP_MEMBERSHIP;],[
	AC_MSG_RESULT(yes)
	RTP_SUPPORT_IPV4MULTICAST="#define RTP_SUPPORT_IPV4MULTICAST"],
	AC_MSG_RESULT(no))

dnl ---------------------------------------------------------------------------
dnl Check if sockaddr has a length field (sa_len)
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(if struct sockaddr has sa_len member)
AC_TRY_COMPILE([
	#include <sys/types.h>
	#include <sys/socket.h>],[
	struct sockaddr sa;
	sa.sa_len = 0;],[
	AC_MSG_RESULT(yes)
	RTP_HAVE_SOCKADDR_LEN="#define RTP_HAVE_SOCKADDR_LEN"],
	AC_MSG_RESULT(no))

dnl ---------------------------------------------------------------------------
dnl Check if compiler needs -LANG:std (needed on Irix)
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(if compiler can compile programs with STL)
AC_TRY_COMPILE([
	#include <iostream>],[
	std::cout << "Bla" << std::endl; ],
	AC_MSG_RESULT(yes),
	[AC_MSG_RESULT(no)
		AC_MSG_CHECKING(if compiler can compile STL programs with option -LANG:std)
		CXXFLAGS="$CXXFLAGS -LANG:std"
		AC_TRY_COMPILE([
			#include <iostream>],[
			std::cout << "Bla" << std::endl; ],
			AC_MSG_RESULT(yes),[
			AC_MSG_RESULT(no)
			AC_MSG_ERROR(Unable to compile a trivial STL program)]
			)
	])

dnl ---------------------------------------------------------------------------
dnl Check for uint32_t etc
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(if types like uint32_t exist)
AC_TRY_COMPILE([
	#include <inttypes.h>],[
	uint32_t x;
	x = 0;],
	[AC_MSG_RESULT(yes)
	echo -e "#include <inttypes.h>\n#include <sys/types.h>" >src/rtptypes_unix.h
	],[
	AC_MSG_RESULT(no)
	echo "Generating src/rtptypes.h ..."
	if ! ( $CXX $CFLAGS -o tools/gettypes tools/gettypes.cpp >/dev/null 2>/dev/null ) ; then
		AC_MSG_ERROR(Unable to create src/rtptypes_unix.h)
	fi
	if ! ( tools/gettypes >src/rtptypes_unix.h ) ; then
		AC_MSG_ERROR(Unable to create src/rtptypes_unix.h)
	fi
	])

dnl ---------------------------------------------------------------------------
dnl Check random functions
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(for drand48_r and srand48_r)
AC_COMPILE_IFELSE([
	#include <stdlib.h>
	int main(void)
	{
		struct drand48_data drandbuffer;
		double x;
		srand48_r(12345,&drandbuffer);
		drand48_r(&drandbuffer,&x);
		return 0;
	}
	],
	[AC_MSG_RESULT(yes)
		RTP_SUPPORT_GNUDRAND="#define RTP_SUPPORT_GNUDRAND"],
	[
	AC_MSG_RESULT(no)
	AC_MSG_CHECKING(for rand_r)
	AC_COMPILE_IFELSE([
		#include <stdlib.h>
		int main(void)
		{
			unsigned int x;
			x = 12345;
			rand_r(&x);
			return 0;
		}
		],
		[ AC_MSG_RESULT(yes)
			RTP_SUPPORT_RANDR="#define RTP_SUPPORT_RANDR"],
		[ AC_MSG_RESULT(no)])
	])

dnl ---------------------------------------------------------------------------
dnl Check getlogin_r functions
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(for getlogin_r)
AC_COMPILE_IFELSE([
	#include <unistd.h>
	int main(void)
	{
		char buf[[256]];
		getlogin_r(buf,256);
		return 0;
	}
	],
	[AC_MSG_RESULT(yes)
		RTP_SUPPORT_GETLOGINR="#define RTP_SUPPORT_GETLOGINR"],
	[
	AC_MSG_RESULT(no)
	])
 
dnl ---------------------------------------------------------------------------
dnl Check IPv6 support
dnl ---------------------------------------------------------------------------

AC_ARG_ENABLE(IPv6,[  --disable-IPv6          Disable support for IPv6],[
	if test "$enableval" = yes ; then
		ipv6support="yes"
	else
		ipv6support="no"
	fi],[
	ipv6support="yes"
	])

if test "$ipv6support" = "yes" ; then

	if test "$cross_compiling" = yes  ; then
		cat << EOF

ABOUT IPv6 SUPPORT:

  Can't check if IPv6 support is possible when cross-compiling. For now, lets
  assume that you want IPv6 support enabled. To disable it, comment the two
  appropriate lines in src/rtpconfig_unix.h before running make.

EOF
	else
	
		AC_MSG_CHECKING(IPv6 support)
		AC_RUN_IFELSE([
			#include <sys/types.h>
			#include <sys/socket.h>
			int main(void)
			{
			int s;
		
			s = socket(PF_INET6,SOCK_DGRAM,0);
			if (s < 0)
				return -1;
			return 0;
			}
			],
			[AC_MSG_RESULT(enabled)
				RTP_SUPPORT_IPV6="#define RTP_SUPPORT_IPV6"
				
			dnl ---------------------------------------------------------------------------
			dnl Check if multicast options are known
			dnl ---------------------------------------------------------------------------
			
			AC_MSG_CHECKING(if necessary options for IPv6 multicasting are available)
			AC_COMPILE_IFELSE([
				#include <sys/types.h>
				#include <sys/socket.h>
				#include <netinet/in.h>
		
				int main(void)
				{
					int testval;
					struct ipv6_mreq mreq,mreq2;
					mreq = mreq2; // avoid 'unused variable'
					testval = IPV6_MULTICAST_HOPS;
					testval = IPV6_JOIN_GROUP;
					testval = IPV6_LEAVE_GROUP;
					return 0;
				}
				],[
				AC_MSG_RESULT(yes)
				RTP_SUPPORT_IPV6MULTICAST="#define RTP_SUPPORT_IPV6MULTICAST"],
				AC_MSG_RESULT(no))],
			[
			AC_MSG_RESULT(disabled)
			])
	fi
fi

dnl ---------------------------------------------------------------------------
dnl Check if ifaddrs.h exists so we can use getifaddrs
dnl ---------------------------------------------------------------------------

AC_CHECK_HEADER(ifaddrs.h,[RTP_SUPPORT_IFADDRS="#define RTP_SUPPORT_IFADDRS"])

dnl ---------------------------------------------------------------------------
dnl Finish up...
dnl ---------------------------------------------------------------------------

AC_SUBST(RTP_FILIO)
AC_SUBST(RTP_SOCKIO)
AC_SUBST(RTP_ENDIAN)
AC_SUBST(RTP_SOCKLENTYPE_UINT)
AC_SUBST(RTP_JTHREADINCLUDES)
AC_SUBST(RTP_HAVE_SOCKADDR_LEN)
AC_SUBST(RTP_SUPPORT_IPV4MULTICAST)
AC_SUBST(RTP_SUPPORT_THREAD)
AC_SUBST(RTP_SUPPORT_SDESPRIV)
AC_SUBST(RTP_SUPPORT_INLINETEMPLATEPARAM)
AC_SUBST(RTP_SUPPORT_PROBATION)
AC_SUBST(RTP_SUPPORT_GNUDRAND)
AC_SUBST(RTP_SUPPORT_RANDR)
AC_SUBST(RTP_SUPPORT_GETLOGINR)
AC_SUBST(RTP_SUPPORT_IPV6)
AC_SUBST(RTP_SUPPORT_IPV6MULTICAST)
AC_SUBST(RTP_SUPPORT_IFADDRS)
AC_SUBST(RTP_SUPPORT_SENDAPP)
AC_SUBST(RTP_SUPPORT_MEMORYMANAGEMENT)
AC_SUBST(RTP_LINKLIBS)
AC_OUTPUT(Makefile \
	  src/Makefile \
	  src/rtpconfig_unix.h \
	  doc/Makefile \
	  tools/Makefile \
	  examples/Makefile \
          pkgconfig/Makefile \
          pkgconfig/jrtplib.pc \
          pkgconfig/jrtplib-uninstalled.pc \
          )