summaryrefslogtreecommitdiff
path: root/configure.in
blob: 1eb5df745bd33266689af25c31768e16199bc867 (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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
dnl *******************************************
dnl *** Initialize automake and set version ***
dnl *******************************************

AC_INIT(src/libsoup/soup.h)

# Increment on interface addition. Reset on removal.
SOUP_AGE=0

# Increment on interface add, remove, or change.
SOUP_CURRENT=3

# Increment on source change. Reset when CURRENT changes.
SOUP_REVISION=0

AC_SUBST(SOUP_CURRENT)
AC_SUBST(SOUP_REVISION)
AC_SUBST(SOUP_AGE)

# Update in src/soup-core/soup-private.h for Windows
AM_INIT_AUTOMAKE(soup, 0.6.0)

AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
AC_PROG_MAKE_SET


dnl ***************************
dnl *** Set debugging flags ***
dnl ***************************

debug_default=minimum

# Declare --enable-* args and collect ac_help strings
AC_ARG_ENABLE(debug, 
	      [  --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,
	      enable_debug=$debug_default)

# Set the debug flags
if test "x$enable_debug" = "xyes"; then
	test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
	SOUP_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
else
	if test "x$enable_debug" = "xno"; then
		SOUP_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
	fi
fi

AC_SUBST(SOUP_DEBUG_FLAGS)


dnl ***************************
dnl *** Checks for programs ***
dnl ***************************

AC_PROG_CC
AM_PROG_CC_STDC
AC_PROG_INSTALL

# Set STDC_HEADERS
AC_HEADER_STDC

# Initialize libtool
AM_PROG_LIBTOOL

# This isn't a program, but it doesn't fit anywhere else...
AC_FUNC_ALLOCA


dnl ***************************
dnl *** Checks for glib 1.2 ***
dnl ***************************

AM_PATH_GLIB(1.2.0,,
             AC_MSG_ERROR([Cannot find GLIB: Is glib-config in path?]))

GLIB_CFLAGS=`glib-config --cflags glib`
GLIB_LIBS=`glib-config --libs glib`
GMODULE_LIBS=`glib-config --libs gmodule`

AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GMODULE_LIBS)


dnl ****************************
dnl *** Checks for gnome-xml ***
dnl ****************************

FAVOUR_LIBXML=1
AC_ARG_WITH(libxml,
	[  --with-libxml=[1/2] which version of libxml to use [default=$FAVOUR_LIBXML]],,
	with_libxml=$FAVOUR_LIBXML)

if test "x$with_libxml" = "x" -o "$with_libxml" = "yes"; then
	with_libxml=$FAVOUR_LIBXML
fi

if test "$with_libxml" = "1"; then
	AC_PATH_PROG(XML_CONFIG,xml-config,no)
	if test x$XML_CONFIG = xno; then
		AC_MSG_ERROR([Cannot find LIBXML: Is xml-config in path?])
	fi

	XML_MIN_VERSION=1.8.8
else
	if test "$with_libxml" = "2"; then
		AC_PATH_PROG(XML_CONFIG,xml2-config,no)
		if test x$XML_CONFIG = xno; then
			AC_MSG_ERROR([Cannot find LIBXML2: Is xml2-config in path?])
		fi

		XML_MIN_VERSION=2.3.10
	else
		AC_MSG_ERROR(Can't use libxml version $with_libxml)
	fi
fi

dnl Check version
XML_VERSION=`$XML_CONFIG --version`
ver=`echo $XML_VERSION | awk -F. '{printf("%d", ($1*1000+$2)*1000+$3);}'`
minver=`echo $XML_MIN_VERSION | awk -F. '{printf("%d", ($1*1000+$2)*1000+$3);}'`
if test "$minver" -gt "$ver"
then
	AC_MSG_ERROR(Found libxml version $XML_VERSION. You need $XML_MIN_VERSION or newer)
fi

XML_CFLAGS=`$XML_CONFIG --cflags`
XML_LIBS=`$XML_CONFIG --libs`

AC_SUBST(XML_CFLAGS)
AC_SUBST(XML_LIBS)


dnl ***********************
dnl *** Checks for poptl ***
dnl ***********************
AC_ARG_WITH(popt-includes,
	    [  --with-popt-includes     Specify location of popt headers],
	    [popt_inc_prefix=-I$withval])

AC_ARG_WITH(popt-libs,
	    [  --with-popt-libs         Specify location of popt libs],
	    [popt_prefix=$withval],
	    [popt_prefix=/usr/lib])
	
save_CPPFLAGS=$CPPFLAGS
save_LIBS=$LIBS
CPPFLAGS="$CPPFLAGS $popt_inc_prefix"
LIBS="$LIBS -L$prefix"

AC_CHECK_LIB(popt, 
	     poptGetContext, 
	     [POPT_LIBS="$LIBS -lpopt"] , 
	     AC_MSG_ERROR([popt is required]))
AC_CHECK_HEADERS(popt.h, [POPT_CFLAGS="$CFLAGS"], AC_MSG_ERROR([popt.h is required]))

CPPFLAGS=$save_CPPFLAGS
LIBS=$save_LIBS

AC_SUBST(POPT_CFLAGS)
AC_SUBST(POPT_LIBS)


dnl **********************************************
dnl *** Variable substitution for soup*Conf.sh ***
dnl **********************************************

### soupConf.sh
SOUP_LIBDIR='-L${libdir}'
SOUP_INCLUDEDIR=" -I${includedir}/soup $GLIB_CFLAGS $XML_CFLAGS"
SOUP_LIBS="-lsoup $GLIB_LIBS $XML_LIBS"

AC_SUBST(SOUP_LIBDIR)
AC_SUBST(SOUP_INCLUDEDIR)
AC_SUBST(SOUP_LIBS)

### soup-apacheConf.sh
SOUP_APACHE_LIBDIR='-L${libdir}'
SOUP_APACHE_INCLUDEDIR="$SOUP_INCLUDEDIR $APACHE_CFLAGS"
SOUP_APACHE_LIBS="$SOUP_LIBS -lsoup-apache $APACHE_LIBS"

AC_SUBST(SOUP_APACHE_LIBDIR)
AC_SUBST(SOUP_APACHE_INCLUDEDIR)
AC_SUBST(SOUP_APACHE_LIBS)

### soup-wsdlConf.sh
SOUP_WSDL_LIBDIR='-L${libdir}'
SOUP_WSDL_INCLUDEDIR=" -I${includedir}/soup $GLIB_CFLAGS $XML_CFLAGS"
SOUP_WSDL_LIBS="$SOUP_LIBS -lwsdl"

AC_SUBST(SOUP_WSDL_LIBDIR)
AC_SUBST(SOUP_WSDL_INCLUDEDIR)
AC_SUBST(SOUP_WSDL_LIBS)


dnl *********************************
dnl *** Networking library checks ***
dnl *********************************

AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h)
AC_CHECK_HEADERS(sys/socket.h sys/sockio.h sys/poll.h sys/param.h sys/wait.h)
AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)

AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))

AC_CHECK_FUNCS(inet_pton inet_aton)

### Check if we have gethostbyname_r (if so, assume gethostbyaddr_r).
AC_CHECK_FUNC(gethostbyname_r,
  [
  dnl  First check for the glibc variant of gethostbyname_r

  AC_MSG_CHECKING(for glibc gethostbyname_r)
  AC_TRY_LINK([	#include <netdb.h>],[
	  struct hostent result_buf;
	  char buf[1024];
	  struct hostent* result;
	  int h_errnop;

	  gethostbyname_r("localhost", &result_buf, buf, sizeof(buf),
	                  &result, &h_errnop);
	], [

	  dnl Have glibc gethostbyname_r

	  AC_MSG_RESULT(yes)
	  AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC)
	  HAVE_GETHOSTBYNAME_R=yes

        ], [

  dnl  If we don't have glibc gethostbyname_r, check
  dnl  for Solaris/Irix gethostbyname_r

  AC_MSG_RESULT(no)
  AC_MSG_CHECKING(for Solaris/Irix gethostbyname_r)
  AC_TRY_LINK([ #include <netdb.h>],[
	  struct hostent result;
	  char buf[1024];
	  int h_errnop;

	  gethostbyname_r("localhost", &result, buf, sizeof(buf), &h_errnop);

	], [

	  dnl Have Solaris/Irix gethostbyname_r

  	  AC_MSG_RESULT(yes)
	  AC_DEFINE(HAVE_GETHOSTBYNAME_R_SOLARIS)
	  HAVE_GETHOSTBYNAME_R=yes

	], [
  dnl  If don't have Solaris/Irix gethostbyname_r, check
  dnl  for HP-UX gethostbyname_r

  AC_MSG_RESULT(no)
  AC_MSG_CHECKING(for HP-UX gethostbyname_r)
  AC_TRY_LINK([ #include <netdb.h>],[
	  struct hostent result;
	  char buf[1024];
          gethostbyname_r("localhost", &result, buf);
        ], [
        
          dnl Have HP-UX gethostbyname_r

          AC_MSG_RESULT(yes)
	  AC_DEFINE(HAVE_GETHOSTBYNAME_R_HPUX)
	  HAVE_GETHOSTBYNAME_R=yes

	]
     )]
  )]
)])

### If we don't have gethostbyname_r, try to use Glib mutexes
if test -z "$HAVE_GETHOSTBYNAME_R"; then
	AM_PATH_GLIB(1.2.0, 
		     AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIB_MUTEX), [
      		     AC_MSG_WARN(You have neither Glib threads nor the function
				 gethostbyname_r.  This means that calls to
			    	 gethostbyname (called by the Soup address
				 functions) will not be thread safe so could
				 malfunction in programs that use threads.)
    		     ])
fi


dnl ****************************************************
dnl *** SSL Library checks (Mozilla NSS, or OpenSSL) ***
dnl ****************************************************

AC_ARG_ENABLE(ssl, 
	      [  --enable-ssl             Turn on Secure Sockets Layer support [default=yes]],,
	      enable_ssl=yes)

AC_ARG_WITH(nspr-includes,
	    [  --with-nspr-includes     Specify location of Netscape Portable Runtime headers],
	    [nspr_inc_prefix=-I$withval])

AC_ARG_WITH(nspr-libs,
	    [  --with-nspr-libs         Specify location of Netscape Portable Runtime libs],
	    [nspr_prefix=$withval],
	    [nspr_prefix=/usr/lib])

AC_ARG_WITH(nss-includes,
	    [  --with-nss-includes      Specify location of NSS header files],
	    [nss_inc_prefix=-I$withval])

AC_ARG_WITH(nss-libs,
	    [  --with-nss-libs          Specify location of NSS libs],
	    [nss_prefix=$withval],
	    [nss_prefix=/usr/lib])


AC_ARG_WITH(openssl-includes,
	    [  --with-openssl-includes  Specify location of OpenSSL header files],
	    [openssl_inc_prefix=-I$withval])

AC_ARG_WITH(openssl-libs,
	    [  --with-openssl-libs      Specify location of OpenSSL libs],
	    [openssl_prefix=$withval], 
	    [openssl_prefix=/usr/lib])

###
### Allow for a custom SSL proxy name
###
AC_ARG_WITH(ssl-proxy-name,
	    [  --with-ssl-proxy-name    Custom name for ssl proxy executable [default=soup-ssl-proxy]],
	    [SSL_PROXY_NAME=$withval],
	    [SSL_PROXY_NAME=soup-ssl-proxy])

AC_DEFINE_UNQUOTED(SSL_PROXY_NAME, "${SSL_PROXY_NAME}")
AC_SUBST(SSL_PROXY_NAME)

###
### Try to link statically with the SSL library
###
AC_ARG_ENABLE(ssl-link-static, 
	      [  --enable-static-ssl      Link with SSL library statically [default=no]],
	      [enable_static_ssl=yes])

if test "x$enable_ssl" = xyes; then
	###
	### Check for OpenSSL
	###
	save_CPPFLAGS=$CPPFLAGS
	CPPFLAGS="$CPPFLAGS $openssl_inc_prefix"
	AC_CHECK_LIB(dl, dlopen, DL_LDFLAGS="-ldl", DL_LDFLAGS="")
	AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h,
			 [enable_openssl="yes"],
			 [enable_openssl="no"; break])

	if test "x$enable_openssl" = xyes; then
		if test "x$enable_static_ssl" = "xyes"; then
			OPENSSL_LIBS="$openssl_prefix/libssl.a $openssl_prefix/libcrypto.a"
		else
			OPENSSL_LIBS="-L$openssl_prefix -lssl -lcrypto $DL_LDFLAGS"
		fi
		OPENSSL_CFLAGS=$CPPFLAGS
		AC_DEFINE(HAVE_OPENSSL)
	else
		OPENSSL_LIBS=
		OPENSSL_CFLAGS=
	fi

	AC_SUBST(OPENSSL_CFLAGS)
	AC_SUBST(OPENSSL_LIBS)
	CPPFLAGS=$save_CPPFLAGS

	###
	### Check for Mozilla NSS
	###
	save_CPPFLAGS=$CPPFLAGS
	CPPFLAGS="$CPPFLAGS $nspr_inc_prefix $nss_inc_prefix"
	AC_CHECK_HEADERS(nss.h ssl.h pk11func.h,
			 [enable_nss="yes"],
			 [enable_nss="no"; break])

	if test "x$enable_nss" = xyes; then
		if test "x$enable_static_ssl" = "xyes"; then
			NSS_LIBS="-lpthread $nspr_prefix/libnspr4.a $nspr_prefix/libplc4.a $nspr_prefix/libplds4.a $nss_prefix/libnssb.a"
		else
			NSS_LIBS="-lpthread -L$nspr_prefix -lnspr4 -lplc4 -lplds4 $nss_prefix -lnss3 -lssl3"
		fi
		NSS_CFLAGS=$CPPFLAGS
		AC_DEFINE(HAVE_NSS)
	else
		NSS_LIBS=
		NSS_CFLAGS=
	fi

	AC_SUBST(NSS_CFLAGS)
	AC_SUBST(NSS_LIBS)
	CPPFLAGS=$save_CPPFLAGS
fi


dnl *************************
dnl *** Checks for Apache ***
dnl *************************

enable_apache="no"

AC_PATH_PROG(APXS,apxs,no)
if test x$APXS != xno; then
	APACHE_CFLAGS="-I`apxs -q INCLUDEDIR CFLAGS`"
	APACHE_LIBS=`apxs -q LDFLAGS_SHLIB LIBS_SHLIB`

	save_CPPFLAGS=$CPPFLAGS
	CPPFLAGS=$APACHE_CFLAGS
	AC_CHECK_HEADERS(httpd.h http_config.h http_core.h http_log.h http_main.h http_protocol.h,
			  [enable_apache="yes"],
			  [enable_apache="no"
			   break])
	CPPFLAGS=$save_CPPFLAGS

	AC_SUBST(APACHE_CFLAGS)
	AC_SUBST(APACHE_LIBS)
fi


dnl *********************************************
dnl *** Checks for gtk-doc (lifted from glib) ***
dnl *********************************************

AC_ARG_WITH(html-dir, [  --with-html-dir=PATH     Path to installed docs ])

if test "x$with_html_dir" = "x" ; then
  HTML_DIR='${datadir}/gtk-doc/html'
else
  HTML_DIR=$with_html_dir
fi

AC_SUBST(HTML_DIR)

AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
AC_SUBST(HAVE_GTK_DOC)

AC_CHECK_PROG(DB2HTML, db2html, true, false)
AM_CONDITIONAL(HAVE_DOCBOOK, $DB2HTML)

dnl Let people disable the gtk-doc stuff.
AC_ARG_ENABLE(gtk-doc, 
	      [  --enable-gtk-doc         Use gtk-doc to build documentation [default=auto]], 
	      enable_gtk_doc="$enableval", 
	      enable_gtk_doc=auto)

if test x$enable_gtk_doc = xauto ; then
  if test x$GTKDOC = xtrue ; then
    enable_gtk_doc=yes
  else
    enable_gtk_doc=no 
  fi
fi

dnl NOTE: We need to use a separate automake conditional for this
dnl       to make this work with the tarballs.
AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)


dnl *******************************************************
dnl *** Type alignment test (based on the one in ORBit) ***
dnl *******************************************************

AC_DEFUN(AC_CHECK_ALIGNOF,
[changequote(<<, >>)dnl
dnl The name to #define.
define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl
dnl The cache variable name.
define(<<AC_CV_NAME>>, translit(ac_cv_alignof_$1, [ *], [_p]))dnl
changequote([, ])dnl
AC_MSG_CHECKING(alignment of $1)
align_save_libs="$LIBS"
LIBS="$GLIB_LIBS $LIBS"
AC_CACHE_VAL(AC_CV_NAME,
[AC_TRY_RUN([
#include <stdio.h>
#include <glib.h>
typedef struct {char s1;} gstruct;
struct test {char s1; $1 s2;};
main()
{
  FILE *f=fopen("conftestval", "w");
  if (!f) exit(1);
  fprintf(f, "%d\n", &(((struct test*)0)->s2));
  exit(0);
}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, AC_CV_NAME=0)])dnl
AC_MSG_RESULT($AC_CV_NAME)
LIBS="$align_save_libs"
AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
undefine([AC_TYPE_NAME])dnl
undefine([AC_CV_NAME])dnl
])

orig_CPPFLAGS=$CPPFLAGS
CPPFLAGS=$GLIB_CFLAGS
AC_CHECK_ALIGNOF(gboolean)
AC_CHECK_ALIGNOF(gchar)
AC_CHECK_ALIGNOF(guchar)
AC_CHECK_ALIGNOF(gint)
AC_CHECK_ALIGNOF(guint)
AC_CHECK_ALIGNOF(gshort)
AC_CHECK_ALIGNOF(gushort)
AC_CHECK_ALIGNOF(glong)
AC_CHECK_ALIGNOF(gulong)
AC_CHECK_ALIGNOF(gint8)
AC_CHECK_ALIGNOF(guint8)
AC_CHECK_ALIGNOF(gint16)
AC_CHECK_ALIGNOF(guint16)
AC_CHECK_ALIGNOF(gint32)
AC_CHECK_ALIGNOF(guint32)
AC_CHECK_ALIGNOF(gfloat)
AC_CHECK_ALIGNOF(gdouble)
AC_CHECK_ALIGNOF(gpointer)
AC_CHECK_ALIGNOF(gstruct)
CPPFLAGS=$orig_CPPFLAGS


dnl *************************************
dnl *** Warnings to show if using GCC ***
dnl *************************************

AC_ARG_ENABLE(more-warnings,
	      [  --disable-more-warnings  Inhibit compiler warnings],
	      set_more_warnings=no)

if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
	CFLAGS="$CFLAGS \
		-Wall -Wstrict-prototypes -Wmissing-declarations \
		-Wmissing-prototypes -Wnested-externs -Wpointer-arith"
fi

# Use reentrant functions
CFLAGS="$CFLAGS -D_REENTRANT"


dnl *************************
dnl *** Output Everything ***
dnl *************************

AC_OUTPUT([
	soup-config
	soup.pc
	soup.spec
	Makefile
	docs/Makefile
	docs/reference/Makefile
	src/Makefile
	src/libsoup/Makefile
	src/libsoup-apache/Makefile
	src/libwsdl/Makefile
	src/soup-httpd/Makefile
	src/soup-ssl-proxy/Makefile
	src/soup-wsdl/Makefile
	tests/Makefile
	])

echo "

Configuration:

  Source code location:		${srcdir}
  Compiler:			${CC}
  Build flags:			${CFLAGS} ${SOUP_DEBUG_FLAGS}

  OpenSSL support:		${enable_openssl}
  Mozilla NSS support:		${enable_nss}

  Apache module support:	${enable_apache}

"