summaryrefslogtreecommitdiff
path: root/configure.in
blob: 6e079741b564fd9357d9f0241bb44d9c38c125a5 (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
dnl Process this file with autoconf to produce a configure script.
AC_INIT(configure.in)
AM_CONFIG_HEADER(config.h)

# In the following, there are a the following variants
# of GLib cflags and libs variables
#
# GLIB_CFLAGS:  cflags for compiling libraries and example progs
# GLIB_LIBS:    libraries for linking example programs
# glib_cflags:  cflags to store in gmime-config
# glib_libs:    libs to store in gmime-config

GMIME_MAJOR_VERSION=2
GMIME_MINOR_VERSION=4
GMIME_MICRO_VERSION=33
GMIME_VERSION=$GMIME_MAJOR_VERSION.$GMIME_MINOR_VERSION.$GMIME_MICRO_VERSION
GMIME_VERSION_INFO=`expr $GMIME_MAJOR_VERSION + $GMIME_MINOR_VERSION`:$GMIME_MICRO_VERSION:$GMIME_MINOR_VERSION

AC_SUBST(GMIME_MAJOR_VERSION)
AC_SUBST(GMIME_MINOR_VERSION)
AC_SUBST(GMIME_MICRO_VERSION)
AC_SUBST(GMIME_VERSION)
AC_SUBST(GMIME_VERSION_INFO)

dnl GMIME_API_VERSION does not necessarily reflect GMime's major.minor version
GMIME_API_VERSION=2.4
AC_SUBST(GMIME_API_VERSION)

VERSION=$GMIME_VERSION

AM_INIT_AUTOMAKE(gmime, $VERSION)

AC_CANONICAL_HOST

dnl Check for win32 platforms
AC_MSG_CHECKING([if building for Win32])
case "$host" in
  *-*-mingw*)
    platform_win32="yes"
    native_win32="yes"
    ;;
  *-*-cygwin*)
    platform_win32="yes"
    native_win32="no"
    ;;
  *)
    platform_win32="no"
    native_win32="no"
    ;;
esac
AC_MSG_RESULT($platform_win32)
AM_CONDITIONAL(PLATFORM_WIN32, test "x$platform_win32" = "xyes")
AM_CONDITIONAL(OS_WIN32, test "$native_win32" = "xyes")

if test "$glib_native_win32" = "yes"; then
  if test "X$enable_static" = "xyes" -o "x$enable_static" = "x"; then
    AC_MSG_WARN([Disabling static library build, must build as DLL on Windows])
    enable_static="no"
  fi
  if test "x$enable_shared" = "xno"; then
    AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows])
    enable_shared="yes"
  fi
fi

dnl Checks for programs.
AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_C_INLINE
dnl AC_HEADER_STDC
AC_STDC_HEADERS
dnl AC_ARG_PROGRAM
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PATH_PROG(RM, rm, /bin/rm)
AC_PATH_PROG(MV, mv, /bin/mv)
AC_PATH_PROG(TAR, tar, /bin/tar)

AC_EXEEXT
AC_PROG_LIBTOOL
DOLT

AM_MAINTAINER_MODE

dnl Checks for header files.
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(winsock2.h)
AC_CHECK_HEADERS(string.h)
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(regex.h)
AC_CHECK_HEADERS(time.h)
AC_CHECK_HEADERS(poll.h)

AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

dnl Check for nfds_t - used by poll()
AC_MSG_CHECKING(for nfds_t)
AC_TRY_COMPILE([
	#include <sys/types.h>
	#include <poll.h>
	], [
	nfds_t nfds = 1;
	return nfds;
	]
,
	AC_MSG_RESULT(yes)
,
	AC_DEFINE(nfds_t, unsigned long int, [Define to `unsigned long int' if <poll.h> does not define.])
	AC_MSG_RESULT(no)
)

dnl Check for some time functions
AC_CHECK_FUNCS(strftime localtime gmtime_r gmtime_s)

dnl Check for working mmap
AC_FUNC_MMAP
AC_CHECK_FUNCS(munmap msync)

dnl Check for select() and poll()
AC_CHECK_FUNCS(select poll)

dnl ************************************
dnl Checks for gtk-doc and docbook-tools
dnl ************************************

GTK_DOC_CHECK([1.8])

AC_PATH_PROGS([DB2HTML], [db2html docbook2html])
AM_CONDITIONAL(HAVE_DOCBOOK, [test -n "$DB2HTML"])

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 Check for profiling options
AC_ARG_ENABLE(profiling,
              AC_HELP_STRING([--enable-profiling],[enable profiling compile flags [[default=no]]]),,
              enable_profiling=no)
if test "x$enable_profiling" = "xyes"; then
# CFLAGS="-O0 -g -pg -fprofile-arcs -ftest-coverage"
  CFLAGS="-O0 -g -pg"
fi

dnl Enable warning spewage on the console
AC_ARG_ENABLE(warnings,
              AC_HELP_STRING([--enable-warnings],
	      [enable g_warning output when invalid MIME is encountered [[default=no]]]),,
	      enable_warnings=no)
if test "x$enable_warnings" = "xyes"; then
  AC_DEFINE(ENABLE_WARNINGS, 1, [Define if GMime should enable warning output.])
fi

dnl Disable cryptography support
AC_ARG_ENABLE(cryptography,
              AC_HELP_STRING([--disable-cryptography],
              [disables cryptography support in GMIME [[default=no]]]),,
              enable_cryptography=yes)
AM_CONDITIONAL(ENABLE_CRYPTOGRAPHY, test "x$enable_cryptography" = "xyes")
if test "x$enable_cryptography" = "xyes"; then
  AC_DEFINE(ENABLE_CRYPTOGRAPHY, 1, [Define if cryptography in GMime is enabled.])
fi

dnl We need at *least* glib 2.12.0 for g_hash_table_remove_all()
AM_PATH_GLIB_2_0(2.12.0, ,
		 AC_MSG_ERROR(Cannot find GLIB: Is pkg-config in your path?),
		 gobject gmodule gthread)

glib_cflags="$GLIB_CFLAGS"
glib_libs="$GLIB_LIBS"
AC_SUBST(glib_cflags)
AC_SUBST(glib_libs)

dnl *****************************
dnl *** Checks for zlib       ***
dnl *****************************
AC_CHECK_HEADERS(zlib.h)
AC_CHECK_LIB(z, inflate, ZLIB="-lz")

dnl Check for libiconv
AM_ICONV()

CFLAGS_save="$CFLAGS"
CFLAGS="$CFLAGS -I$srcdir"
LIBS_save="$LIBS"
LIBS="$LIBS $LIBICONV"

AC_CACHE_CHECK([preferred charset formats for system iconv], [ac_cv_have_iconv_detect_h], [
	AC_RUN_IFELSE([AC_LANG_SOURCE([
		#define CONFIGURE_IN
		#include "iconv-detect.c"
		])],
	[ac_cv_have_iconv_detect_h=yes], [ac_cv_have_iconv_detect_h=no],
	[
		AC_MSG_RESULT([cannot run test program while cross compiling])
		AC_MSG_ERROR([Copy target system's iconv-detect.h to . and configure with ac_cv_have_iconv_detect_h=yes])
	])
])
if test "x$ac_cv_have_iconv_detect_h" = xyes; then
	AC_MSG_RESULT([found])
	AC_DEFINE(HAVE_ICONV_DETECT_H, 1, [Define to 1 to use auto-detected iconv-friendly charset names.])
else
	AC_MSG_RESULT([not found
	*** The iconv-detect program was unable to determine the
	*** preferred charset formats recognized by your system
	*** iconv library. It is suggested that you install a
	*** working iconv library such as the one found at
	*** ftp://ftp.gnu.org/pub/gnu/libiconv
	*** 
	*** Default charset formats will be used.
	])
fi

CFLAGS="$CFLAGS_save"
LIBS="$LIBS_save"

dnl Check for GNU getopt
AC_CHECK_HEADER(getopt.h)
AC_MSG_CHECKING(for GNU getopt_long)
AC_TRY_LINK([
	#include <string.h>
	#include <unistd.h>
	#define _GNU_SOURCE
	#include <getopt.h>
	], [
	return getopt_long (0, NULL, NULL, NULL, NULL);
	]
,
	AC_MSG_RESULT([yes])
	AC_DEFINE(HAVE_GETOPT_H, 1, [Define to 1 if you have the <getopt.h> header with the GNU `getopt_long' function.])
	have_getopt="yes"
,
	AC_MSG_RESULT([no])
	have_getopt="no"
)
AM_CONDITIONAL(SYSTEM_GETOPT, test "x$have_getopt" = "xyes")

dnl Check for fsync (native win32 doesn't have this)
AC_MSG_CHECKING(for fsync)
AC_TRY_LINK([
	#include <unistd.h>
	], [
	fsync(0);
	]
,
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_FSYNC, 1, [Define to 1 if you have the `fsync' function.])
,
	AC_MSG_RESULT(no)
)

dnl Check for MAXHOSTNAMELEN
AC_MSG_CHECKING(for MAXHOSTNAMELEN)
AC_TRY_COMPILE([
	#include <sys/param.h>
	], [
	return MAXHOSTNAMELEN;
	]
,
	AC_MSG_RESULT(yes)
,
	AC_DEFINE(MAXHOSTNAMELEN, 64, [Define with a value if your <sys/param.h> does not define MAXHOSTNAMELEN])
	AC_MSG_RESULT(no; defined as 64)
)

dnl Check for domainname member in struct utsname from uname(2)
AC_MSG_CHECKING(for domainname in struct utsname)
AC_TRY_COMPILE([
	#define _GNU_SOURCE
	#include <sys/utsname.h>
	], [
	struct utsname unam;
		
	unam.domainname[0] = '\0';

	return unam.domainname[0];
	],
	AC_MSG_RESULT(yes)
   	AC_DEFINE(HAVE_UTSNAME_DOMAINNAME, 1, [Define if struct utsname has a domainname member])
,
	AC_MSG_RESULT(no)
)

dnl Timezone checks
AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
	AC_TRY_COMPILE([
		#include <time.h>
		], [
		struct tm tm;
		tm.tm_gmtoff = 1;
		return tm.tm_gmtoff;
		], ac_cv_struct_tm_gmtoff="yes", ac_cv_struct_tm_gmtoff="no"))
if test "$ac_cv_struct_tm_gmtoff" = "yes"; then
	AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if struct tm has a tm_gmtoff member])
else
	AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
		AC_TRY_COMPILE([
			#include <time.h>
		], [
			timezone = 1;
		], ac_cv_var_timezone="yes", ac_cv_var_timezone="no"))
	if test "$ac_cv_var_timezone" = "yes"; then
		AC_DEFINE(HAVE_TIMEZONE, 1, [Define if libc defines a timezone variable])
		AC_CACHE_CHECK(for altzone variable, ac_cv_var_altzone,
			AC_TRY_COMPILE([
				#include <time.h>
			], [
				altzone = 1;
			], ac_cv_var_altzone="yes", ac_cv_var_altzone="no"))
		if test "$ac_cv_var_altzone" = "yes"; then
			AC_DEFINE(HAVE_ALTZONE, 1, [Define if libc defines an altzone variable])
		fi
	else
		AC_CACHE_CHECK(for _timezone variable, ac_cv_var__timezone,
			AC_TRY_COMPILE([
				#include <time.h>
			], [
				_timezone = 1;
			], ac_cv_var__timezone="yes", ac_cv_var__timezone="no"))
		if test "$ac_cv_var__timezone" = "yes"; then
			AC_DEFINE(HAVE__TIMEZONE, 1, [Define if libc defines a _timezone variable])
		else
			AC_ERROR(unable to find a way to determine timezone)
		fi
	fi
fi

dnl *************************************
dnl *** Checks for large file support ***
dnl *************************************
AC_ARG_ENABLE(largefile,
	      AC_HELP_STRING([--enable-largefile],
	      [enable support for large files [[default=yes]]]),,
	      enable_largefile="yes")
if test "x$enable_largefile" != "xno"; then
    AC_SYS_LARGEFILE
    AC_CACHE_CHECK([for _LARGEFILE64_SOURCE value needed for large files], ac_cv_largefile64_source,
    [
	AC_TRY_COMPILE([
		#include <sys/types.h>
		#include <sys/stat.h>
		#include <fcntl.h>
	],[
		return open ("__o_largefile", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
	],[
		ac_cv_largefile64_source="no"
	],[
		AC_TRY_COMPILE([
			#define _LARGEFILE64_SOURCE
			#include <sys/types.h>
			#include <sys/stat.h>
			#include <fcntl.h>
		],[
			return open ("__o_largefile", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
		],[
			ac_cv_largefile64_source="yes"
		],[
			ac_cv_largefile64_source="unknown"
		])
	])
    ])
    
    enable_largefile="no"
    
    if test "x$ac_cv_largefile64_source" = "xyes"; then
        GMIME_CFLAGS="-D_LARGEFILE64_SOURCE"
        enable_largefile="yes"
    elif test "x$ac_cv_largefile64_source" = "xunknown"; then
        AC_DEFINE(O_LARGEFILE, 0, [Define to 0 if your system does not have the O_LARGEFILE flag])
    fi
    
    if test -n "$ac_cv_sys_large_files" -a "x$ac_cv_sys_large_files" != "xno"; then
        GMIME_CFLAGS="$GMIME_CFLAGS -D_LARGE_FILES"
        enable_largefile="yes"
    fi
    
    if test "x$ac_cv_sys_file_offset_bits" != "xno"; then
        GMIME_CFLAGS="$GMIME_CFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
        enable_largefile="yes"
    fi
else
    GMIME_CFLAGS=""
fi
AM_CONDITIONAL(ENABLE_LARGEFILE, test "x$enable_largefile" = "xyes")

dnl Check type sizes
CFLAGS_save="$CFLAGS"
CFLAGS="$CFLAGS $GMIME_CFLAGS"
AC_CHECK_SIZEOF(ssize_t)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(off_t)
CFLAGS="$CFLAGS_save"

dnl Check for some network functions
AC_CHECK_FUNCS(gethostname getdomainname getaddrinfo)

dnl ****************************
dnl *** Checks for libsocket ***
dnl ****************************
LIBSOCKET=""
AC_CHECK_LIB(socket, getaddrinfo, LIBSOCKET="-lsocket")

dnl *************************
dnl *** Checks for libnsl ***
dnl *************************
LIBNSL=""
AC_CHECK_LIB(nsl, getaddrinfo, LIBNSL="-lnsl")

dnl ****************************
dnl *** Enable Mono bindings ***
dnl ****************************
AC_ARG_ENABLE(mono,
	      AC_HELP_STRING([--enable-mono],
	      [enable Mono bindings [[default=auto]]]),,
	      enable_mono="auto")
if test "x$enable_mono" != "xno"; then
	AC_PATH_PROG(CSC, mcs, no)
	# if we found mcs, make sure it's mono and not something else named
	# mcs, such as Tru64's /usr/bin/mcs, for manipulating object file
	# comment sections of eCOFF object files.
	if test "x$CSC" != "xno"; then
		AC_MSG_CHECKING([whether $CSC is Mono])
		$CSC --version > /dev/null 2>&1
		if test $? -ne 0; then
			CSC=no
			AC_MSG_RESULT([no])
		else
			AC_MSG_RESULT([yes])
		fi
	fi
else
	CSC="no"
fi

if test "x$CSC" = "xno"; then
	dnl error out if the user has explicitly requested mono bindings
	if test "x$enable_mono" = "xyes"; then
		AC_MSG_ERROR([Could not find mcs])
	fi
	
	enable_mono="no"
	AM_CONDITIONAL(ENABLE_MONO, false)
else
	enable_mono="yes"
	AM_CONDITIONAL(ENABLE_MONO, true)
fi

if test "x$enable_mono" = "xyes"; then
	AC_PATH_PROG(GACUTIL, gacutil, no)
	if test "x$GACUTIL" = "xno"; then
		AC_MSG_ERROR([Your mono installation doesn't expose gacutil])
	fi
	
	AC_SUBST(CSC)
	AC_SUBST(GACUTIL)
	
	PKG_CHECK_MODULES(GLIB_SHARP, glib-sharp-2.0 >= 2.4.0)
	AC_SUBST(GLIB_SHARP_LIBS)
	
	PKG_CHECK_MODULES(GAPI_TOOLS, gapi-2.0)
	AC_PATH_PROG(GAPI_CODEGEN, gapi2-codegen, no)
	if test "x$GAPI_CODEGEN" = "xno"; then
        	AC_MSG_ERROR([You need to install gtk-sharp2-gapi])
	fi
	
	AC_PATH_PROG(GAPI_FIXUP, gapi2-fixup, no)
	if test "x$GAPI_FIXUP" = "xno"; then
        	AC_MSG_ERROR([You need to install gtk-sharp2-gapi])
	fi
	
	AC_PATH_PROG(GAPI_PARSER, gapi2-parser, no)
	if test "x$GAPI_PARSER" = "xno"; then
        	AC_MSG_ERROR([You need to install gtk-sharp2-gapi])
	fi
	
	dnl The version should be along the lines of
	dnl "<major>.<minor>.0.<interface count>", where major and minor are
	dnl the current major and minor gmime versions, and interface count is
	dnl incremented any time the mono API changes, which should really
	dnl only happen within development series.
	MONO_INTERFACE_VERSION=0
	API_VERSION="$GMIME_MAJOR_VERSION.$GMIME_MINOR_VERSION.0.$MONO_INTERFACE_VERSION"
	AC_SUBST(API_VERSION)
fi

AC_ARG_WITH([gacdir], AC_HELP_STRING([--with-gacdir], [Specify the Global Assembly Cache root directory]),
            [[with_gacdir=$withval]],
            [[with_gacdir=\${prefix}/lib]])
gacdir=$with_gacdir
AC_SUBST(gacdir)

dnl Extra libs
EXTRA_LIBS="$ZLIB"
if test "x$LIBSOCKET" != "x"; then
	EXTRA_LIBS="$EXTRA_LIBS $LIBSOCKET"
fi
if test "x$LIBNSL" != "x"; then
	EXTRA_LIBS="$EXTRA_LIBS $LIBNSL"
fi
if test "x$LIBICONV" != "x"; then
	EXTRA_LIBS="$EXTRA_LIBS $LIBICONV"
fi

CFLAGS="$CFLAGS -fno-strict-aliasing"
AC_SUBST(CFLAGS)

LIBS="$LIBS $EXTRA_LIBS"
AC_SUBST(LIBS)

GMIME_LIBDIR="-L${libdir}"
GMIME_INCLUDEDIR="-I${includedir}/gmime-2.4"
GMIME_LIBS_PRIVATE="$EXTRA_LIBS"
GMIME_LIBS="-lgmime-2.4"

AC_SUBST(GMIME_LIBDIR)
AC_SUBST(GMIME_INCLUDEDIR)
AC_SUBST(GMIME_LIBS_PRIVATE)
AC_SUBST(GMIME_CFLAGS)
AC_SUBST(GMIME_LIBS)


AC_OUTPUT(
Makefile
build/Makefile
build/vs2008/Makefile
docs/Makefile
docs/reference/Makefile
docs/tutorial/Makefile
examples/Makefile
util/Makefile
gmime/Makefile
mono/Makefile
mono/AssemblyInfo.cs
mono/gmime-sharp.dll.config
mono/gmime-sharp-2.4.pc
tests/Makefile
tools/Makefile
gmime-2.4.pc
gmime.spec
)

echo "

Configuration:

  Source code location: ${srcdir}
  Install prefix:       ${prefix}
  Compiler:             ${CC}

  Profiling enabled:    ${enable_profiling}

  Large file support:   ${enable_largefile}
  Console warnings:     ${enable_warnings}
  PGP/MIME support:     ${enable_cryptography}

  Mono bindings:        ${enable_mono}
"