configure.in
author Timo Sirainen <tss@iki.fi>
Tue Oct 06 10:53:34 2009 -0400 (2009-10-06)
branchHEAD
changeset 9416 4add5c3f13ea
parent 9413 5c5fc2aa299a
child 9444 a5d8d201bd39
permissions -rw-r--r--
Compiling fix for OpenSSL 0.9.7 and older.
tss@3784
     1
AC_PREREQ([2.59])
tss@9413
     2
AC_INIT([Dovecot],[1.2.6],[dovecot@dovecot.org])
tss@2796
     3
AC_CONFIG_SRCDIR([src])
tss@0
     4
tss@8523
     5
AM_INIT_AUTOMAKE([foreign])
tss@0
     6
tss@0
     7
AM_MAINTAINER_MODE
tss@0
     8
tss@8517
     9
dnl TEST_WITH(name, value, [plugin])
tss@8517
    10
AC_DEFUN([TEST_WITH], [
tss@8517
    11
  want=want_`echo $1|sed s/-/_/g`
tss@8517
    12
  if test $2 = yes || test $2 = no || test $2 = auto; then
tss@8517
    13
    eval $want=$2
tss@8517
    14
  elif test $2 = plugin; then
tss@8517
    15
    if test "$3" = plugin; then
tss@8517
    16
      eval $want=plugin
tss@8517
    17
    else
tss@8517
    18
      AC_ERROR([--with-$1=plugin not supported])
tss@8517
    19
    fi
tss@8517
    20
  elif `echo $2|grep '^/' >/dev/null`; then
tss@8517
    21
    AC_ERROR([--with-$1=path not supported. You may want to use instead:
tss@8517
    22
CPPFLAGS=-I$2/include LDFLAGS=-L$2/lib ./configure --with-$1])
tss@8517
    23
  else
tss@8517
    24
    AC_ERROR([--with-$1: Unknown value: $2])
tss@8517
    25
  fi
tss@8517
    26
])
tss@0
    27
tss@7929
    28
AC_ARG_ENABLE(devel-checks,
tss@7929
    29
[  --enable-devel-checks   Enable some extra expensive checks for developers],
tss@544
    30
	if test x$enableval = xyes; then
tss@742
    31
		AC_DEFINE(DEBUG,, Build with extra debugging checks)
tss@544
    32
	fi)
tss@544
    33
tss@546
    34
AC_ARG_ENABLE(asserts,
tss@546
    35
[  --enable-asserts        Enable asserts (default)],
tss@4057
    36
	if test x$enableval = xno; then
tss@742
    37
		AC_DEFINE(DISABLE_ASSERTS,, Disable asserts)
tss@546
    38
	fi)
tss@546
    39
tss@439
    40
AC_ARG_WITH(mem-align,
tss@1394
    41
[  --with-mem-align=BYTES  Set the memory alignment (default: 8)],
tss@439
    42
	mem_align=$withval,
tss@439
    43
	mem_align=8)
tss@439
    44
tss@2569
    45
AC_ARG_WITH(ioloop,
tss@3784
    46
[  --with-ioloop=IOLOOP    Specify the I/O loop method to use
tss@4482
    47
                          (epoll, kqueue, poll; best for the fastest available;
tss@7268
    48
			   default is best)],
tss@2569
    49
	ioloop=$withval,
tss@7268
    50
	ioloop=best)
tss@2569
    51
tss@3482
    52
AC_ARG_WITH(notify,
tss@4551
    53
[  --with-notify=NOTIFY    Specify the file system notification method to use
tss@4551
    54
                          (inotify, kqueue, dnotify, none;
tss@4551
    55
                           default is detected in the above order)],
tss@3482
    56
	notify=$withval,
tss@3482
    57
	notify=)
tss@3482
    58
tss@328
    59
AC_ARG_WITH(passwd,
tss@426
    60
[  --with-passwd           Build with /etc/passwd support (default)],
tss@8517
    61
  TEST_WITH(passwd, $withval),
tss@8517
    62
  want_passwd=yes)
tss@0
    63
tss@6111
    64
AC_ARG_WITH(nss,
tss@6974
    65
[  --with-nss              Build with NSS module support (auto)],
tss@8517
    66
  TEST_WITH(nss, $withval),
tss@8517
    67
  want_nss=auto)
tss@5870
    68
tss@328
    69
AC_ARG_WITH(passwd-file,
tss@328
    70
[  --with-passwd-file      Build with passwd-like file support (default)],
tss@8517
    71
  TEST_WITH(passwd-file, $withval),
tss@8517
    72
  want_passwd_file=yes)
tss@0
    73
tss@328
    74
AC_ARG_WITH(shadow,
tss@6974
    75
[  --with-shadow           Build with shadow password support (auto)],
tss@8517
    76
  TEST_WITH(shadow, $withval),
tss@8517
    77
  want_shadow=auto)
tss@0
    78
tss@328
    79
AC_ARG_WITH(pam,
tss@6974
    80
[  --with-pam              Build with PAM support (auto)],
tss@8517
    81
  TEST_WITH(pam, $withval),
tss@8517
    82
  want_pam=auto)
tss@0
    83
tss@2162
    84
AC_ARG_WITH(checkpassword,
tss@2162
    85
[  --with-checkpassword    Build with checkpassword support (default)],
tss@8517
    86
  TEST_WITH(checkpassword, $withval),
tss@8517
    87
  want_checkpassword=yes)
tss@2162
    88
tss@1851
    89
AC_ARG_WITH(bsdauth,
tss@6974
    90
[  --with-bsdauth          Build with BSD authentication support (auto)],
tss@8517
    91
  TEST_WITH(bsdauth, $withval),
tss@8517
    92
  want_bsdauth=auto)
tss@1851
    93
tss@3683
    94
AC_ARG_WITH(gssapi,
tss@6259
    95
[  --with-gssapi=yes|plugin Build with GSSAPI authentication support],
tss@8517
    96
  TEST_WITH(gssapi, $withval, plugin),
tss@8517
    97
  want_gssapi=no)
tss@3683
    98
tss@4638
    99
AC_ARG_WITH(sia,
tss@4638
   100
[  --with-sia              Build with Tru64 SIA support],
tss@8517
   101
  TEST_WITH(sia, $withval),
tss@8517
   102
  want_sia=no)
tss@4638
   103
tss@1057
   104
AC_ARG_WITH(ldap,
tss@6198
   105
[  --with-ldap=yes|plugin  Build with LDAP support],
tss@8517
   106
  TEST_WITH(ldap, $withval, plugin),
tss@8517
   107
  want_ldap=no)
tss@1057
   108
tss@280
   109
AC_ARG_WITH(vpopmail,
tss@6974
   110
[  --with-vpopmail         Build with vpopmail support (auto)],
tss@280
   111
	if test x$withval = xno; then
tss@280
   112
		want_vpopmail=no
tss@280
   113
	else
tss@6974
   114
		if test x$withval = xyes || test x$withval = xauto; then
tss@5035
   115
			vpopmail_home="`echo ~vpopmail`"
tss@6974
   116
			want_vpopmail=$withval
tss@5035
   117
		else
tss@5035
   118
			vpopmail_home="$withval"
tss@6974
   119
			want_vpopmail=yes
tss@5035
   120
		fi
tss@5035
   121
	fi, [
tss@6974
   122
		want_vpopmail=auto
tss@5035
   123
		vpopmail_home="`echo ~vpopmail`"
tss@5035
   124
	])
tss@280
   125
tss@1043
   126
AC_ARG_WITH(static-userdb,
tss@1043
   127
[  --with-static-userdb    Build with static userdb support (default)],
tss@8517
   128
  TEST_WITH(static-userdb, $withval),
tss@8517
   129
  want_static_userdb=yes)
tss@1043
   130
tss@3667
   131
AC_ARG_WITH(prefetch-userdb,
tss@3667
   132
[  --with-prefetch-userdb  Build with prefetch userdb support (default)],
tss@8517
   133
  TEST_WITH(prefetch-userdb, $withval),
tss@8517
   134
  want_prefetch_userdb=yes)
tss@3062
   135
timo@4517
   136
AC_ARG_WITH(db,
timo@4517
   137
[  --with-db               Build with Berkeley DB support],
tss@8517
   138
  TEST_WITH(db, $withval),
tss@8517
   139
  want_db=no)
timo@4517
   140
tss@4013
   141
dnl The --with-sql is useful only if Dovecot is being built with all the SQL
tss@4013
   142
dnl drivers as modules. If any SQL driver is built-in, this option is ignored.
tss@4013
   143
AC_ARG_WITH(sql,
tss@6196
   144
[  --with-sql=yes|plugin   Build with generic SQL support],
tss@8517
   145
  TEST_WITH(sql, $withval, plugin),
tss@8517
   146
  want_sql=no)
tss@4013
   147
tss@1283
   148
AC_ARG_WITH(pgsql,
tss@4013
   149
[  --with-pgsql            Build with PostgreSQL driver support],
tss@8517
   150
  TEST_WITH(pgsql, $withval),
tss@8517
   151
  want_pgsql=no)
tss@1283
   152
tss@1995
   153
AC_ARG_WITH(mysql,
tss@4013
   154
[  --with-mysql            Build with MySQL driver support],
tss@8517
   155
  TEST_WITH(mysql, $withval),
tss@8517
   156
  want_mysql=no)
tss@1995
   157
tss@3919
   158
AC_ARG_WITH(sqlite,
tss@4348
   159
[  --with-sqlite           Build with SQLite3 driver support],
tss@8517
   160
  TEST_WITH(sqlite, $withval),
tss@8517
   161
  want_sqlite=no)
tss@3919
   162
tss@4621
   163
AC_ARG_WITH(lucene,
tss@4621
   164
[  --with-lucene           Build with CLucene full text search support],
tss@8517
   165
  TEST_WITH(lucene, $withval),
tss@8517
   166
  want_lucene=no)
tss@4621
   167
AM_CONDITIONAL(BUILD_LUCENE, test "$want_lucene" = "yes")
tss@4621
   168
tss@7990
   169
AC_ARG_WITH(solr,
tss@7990
   170
[  --with-solr             Build with Solr full text search support],
tss@8517
   171
  TEST_WITH(solr, $withval),
tss@8517
   172
  want_solr=no)
tss@7990
   173
tss@8090
   174
AC_ARG_WITH(zlib,
tss@8090
   175
[  --with-zlib             Build with zlib compression support],
tss@8517
   176
  TEST_WITH(zlib, $withval),
tss@8517
   177
  want_zlib=auto)
tss@8090
   178
tss@8090
   179
AC_ARG_WITH(bzlib,
tss@8090
   180
[  --with-bzlib            Build with bzlib compression support],
tss@8517
   181
  TEST_WITH(bzlib, $withval),
tss@8517
   182
  want_bzlib=auto)
tss@8090
   183
impulze@9169
   184
AC_ARG_WITH(libcap,
impulze@9169
   185
[  --with-libcap           Build with libcap support (Dropping capabilities).],
impulze@9169
   186
  TEST_WITH(libcap, $withval),
impulze@9169
   187
  want_libcap=auto)
impulze@9169
   188
tss@622
   189
AC_ARG_WITH(ssl,
tss@6196
   190
[  --with-ssl=gnutls|openssl Build with GNUTLS or OpenSSL (default)],
tss@245
   191
	if test x$withval = xno; then
tss@244
   192
		want_gnutls=no
tss@622
   193
		want_openssl=no
tss@622
   194
	elif test x$withval = xgnutls; then
tss@622
   195
		want_gnutls=yes
tss@622
   196
		want_openssl=no
tss@622
   197
	elif test x$withval = xopenssl; then
tss@622
   198
		want_gnutls=no
tss@622
   199
		want_openssl=yes
tss@8517
   200
	elif test x$withval = xyes; then
tss@3004
   201
		want_gnutls=no
tss@622
   202
		want_openssl=yes
tss@8517
   203
	else
tss@8517
   204
		AC_ERROR([--with-ssl: Invalid value: $withval])
tss@622
   205
	fi, [
tss@3004
   206
		want_gnutls=no
tss@6974
   207
		want_openssl=auto
tss@622
   208
	])
tss@244
   209
tss@657
   210
AC_ARG_WITH(ssldir,
tss@657
   211
[  --with-ssldir=DIR       SSL base directory for certificates (/etc/ssl)],
tss@657
   212
	ssldir="$withval",
tss@657
   213
	ssldir=/etc/ssl
tss@657
   214
)
tss@712
   215
AC_SUBST(ssldir)
tss@657
   216
tss@3327
   217
AC_ARG_WITH(rundir,
tss@3327
   218
[  --with-rundir=DIR       Runtime data directory (LOCALSTATEDIR/run/dovecot)],
tss@3327
   219
	rundir="$withval",
tss@7914
   220
	rundir=$localstatedir/run/$PACKAGE
tss@3327
   221
)
tss@3327
   222
AC_SUBST(rundir)
tss@3327
   223
tss@4407
   224
AC_ARG_WITH(statedir,
tss@4407
   225
[  --with-statedir=DIR     Permanent data directory (LOCALSTATEDIR/lib/dovecot)],
tss@4407
   226
	statedir="$withval",
tss@7914
   227
	statedir=$localstatedir/lib/$PACKAGE
tss@4407
   228
)
tss@4407
   229
AC_SUBST(statedir)
tss@4407
   230
tss@1786
   231
AC_ARG_WITH(gc,
tss@4599
   232
[  --with-gc               Use Boehm garbage collector],
tss@8517
   233
  TEST_WITH(gc, $withval),
tss@8517
   234
  want_gc=no)
tss@1786
   235
tss@1404
   236
AC_ARG_WITH(storages,
tss@6894
   237
[  --with-storages         Build with specified mail storage formats
tss@9162
   238
                          (maildir mbox dbox cydir)], [
tss@8517
   239
	if test "$withval" = "yes" || test "$withval" = "no"; then
tss@4005
   240
		AC_MSG_ERROR([--with-storages needs storage list as parameter])
tss@4005
   241
	fi
tss@8398
   242
	mail_storages="shared `echo "$withval"|sed 's/,/ /g'`" ],
tss@9162
   243
	mail_storages="shared maildir mbox dbox cydir")
tss@2796
   244
AC_SUBST(mail_storages)
tss@1404
   245
tss@3943
   246
AC_ARG_WITH(sql-drivers,
tss@3943
   247
[  --with-sql-drivers      Build with specified SQL drivers (all)], [
tss@3943
   248
	sql_drivers=`echo "$withval"|sed 's/,/ /g'` ],
tss@3948
   249
	sql_drivers="all")
tss@3943
   250
tss@8517
   251
if test "$sql_drivers" = "all" || test "$sql_drivers" = "yes"; then
tss@3943
   252
  all_sql_drivers=yes
tss@3948
   253
  sql_drivers=
tss@3948
   254
elif test "$sql_drivers" = "no"; then
tss@3944
   255
  # --without-sql-drivers given
tss@3948
   256
  sql_drivers=
tss@3943
   257
fi
tss@9164
   258
not_sql_drivers=
tss@3943
   259
tss@2070
   260
AC_ARG_WITH(moduledir,
tss@2070
   261
[  --with-moduledir=DIR    Base directory for dynamically loadable modules],
tss@2070
   262
	moduledir="$withval",
tss@2070
   263
	moduledir=$libdir/dovecot
tss@2070
   264
)
tss@2070
   265
AC_SUBST(moduledir)
tss@2070
   266
tss@3779
   267
AC_ARG_WITH(docs,
tss@4348
   268
[  --with-docs             Install documentation (default)],
tss@3779
   269
	if test x$withval = xno; then
tss@3779
   270
		want_docs=no
tss@3779
   271
	else
tss@3779
   272
		want_docs=yes
tss@3779
   273
	fi,
tss@3779
   274
	want_docs=yes)
tss@3779
   275
AM_CONDITIONAL(BUILD_DOCS, test "$want_docs" = "yes")
tss@3779
   276
tss@5217
   277
AC_ARG_ENABLE(header-install,
tss@5217
   278
[  --enable-header-install Install development headers],
tss@5217
   279
	if test x$enableval = xno; then
tss@5197
   280
		want_headers=no
tss@5197
   281
	else
tss@5197
   282
		want_headers=yes
tss@5197
   283
	fi,
tss@5197
   284
	want_headers=no)
tss@5197
   285
AM_CONDITIONAL(INSTALL_HEADERS, test "$want_headers" = "yes")
tss@5197
   286
tss@8517
   287
AC_ISC_POSIX
tss@8517
   288
AC_PROG_CC
tss@8517
   289
AC_PROG_CPP
tss@8517
   290
AC_PROG_CXX # lucene plugin needs this
tss@8517
   291
AC_HEADER_STDC
tss@8517
   292
AC_C_INLINE
tss@8517
   293
AC_PROG_LIBTOOL
tss@8517
   294
AM_ICONV
tss@8517
   295
tss@8517
   296
AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h inttypes.h \
tss@8517
   297
  sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \
tss@8517
   298
  sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h sys/fs/quota_common.h \
tss@8517
   299
  mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h \
tss@9245
   300
  xfs/xqm.h execinfo.h ucontext.h malloc_np.h sys/utsname.h sys/vmount.h \
tss@9255
   301
  sys/utsname.h glob.h)
tss@8517
   302
tss@691
   303
dnl * gcc specific options
tss@2796
   304
if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
tss@4826
   305
	# -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings
tss@850
   306
	# -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems
tss@1043
   307
	# -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings
tss@4022
   308
	CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast"
tss@3091
   309
tss@4826
   310
	AC_TRY_COMPILE([
tss@4826
   311
	#if __GNUC__ < 4
tss@4826
   312
	#  error old gcc
tss@4826
   313
	#endif
tss@4826
   314
	],,[
tss@4826
   315
	  # gcc4
tss@4826
   316
	  CFLAGS="$CFLAGS -Wstrict-aliasing=2"
tss@4826
   317
	])
tss@4826
   318
tss@3097
   319
	# Use std=gnu99 if we have new enough gcc
tss@3097
   320
	old_cflags=$CFLAGS
tss@3097
   321
	CFLAGS="-std=gnu99"
tss@3097
   322
	AC_TRY_COMPILE([
tss@3097
   323
	],, [
tss@3097
   324
	  CFLAGS="$CFLAGS $old_cflags"
tss@3097
   325
	], [
tss@3097
   326
	  CFLAGS="$old_cflags"
tss@3097
   327
	])
tss@691
   328
fi
tss@691
   329
tss@0
   330
dnl **
tss@0
   331
dnl ** just some generic stuff...
tss@0
   332
dnl **
tss@0
   333
tss@5690
   334
AC_SEARCH_LIBS(socket, socket)
tss@5690
   335
AC_SEARCH_LIBS(inet_addr, nsl)
tss@5690
   336
AC_SEARCH_LIBS(fdatasync, rt, [
tss@5690
   337
  AC_DEFINE(HAVE_FDATASYNC,, Define if you have fdatasync())
tss@0
   338
])
tss@0
   339
impulze@9169
   340
if test $want_libcap != no; then
impulze@9169
   341
  AC_CHECK_LIB(cap, cap_init, [
impulze@9169
   342
    AC_DEFINE(HAVE_LIBCAP,, libcap is installed for cap_init())
impulze@9169
   343
    LIBCAP="-lcap"
impulze@9169
   344
    AC_SUBST(LIBCAP)
impulze@9169
   345
  ], [
impulze@9169
   346
    if test "$want_libcap" = "yes"; then
impulze@9169
   347
      AC_ERROR([Can't build with libcap support: libcap not found])
impulze@9169
   348
    fi
impulze@9169
   349
  ])
impulze@9169
   350
fi
tss@5201
   351
tss@7917
   352
AC_DEFINE(PACKAGE_WEBPAGE, "http://www.dovecot.org/", Support URL)
tss@7917
   353
tss@0
   354
dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
tss@2103
   355
AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
tss@8600
   356
               strcasecmp stricmp vsyslog writev pread uname unsetenv \
tss@3237
   357
	       setrlimit setproctitle seteuid setreuid setegid setresgid \
tss@7889
   358
	       strtoull strtoll strtouq strtoq \
tss@7847
   359
	       setpriority quotactl getmntent kqueue kevent backtrace_symbols \
tss@9255
   360
	       walkcontext dirfd clearenv malloc_usable_size glob)
tss@9243
   361
tss@9243
   362
AC_CHECK_LIB(rt, clock_gettime, [
tss@9243
   363
  AC_DEFINE(HAVE_CLOCK_GETTIME,, Define if you have the clock_gettime function)
tss@9266
   364
  LIBS="$LIBS -lrt"
tss@9243
   365
], [
tss@9243
   366
  # OpenBSD
tss@9243
   367
  AC_CHECK_FUNCS(clock_gettime)
tss@9243
   368
])
tss@0
   369
tss@7889
   370
dnl strtoimax and strtoumax are macros in HP-UX, so inttypes.h must be included
tss@8601
   371
dnl Link instead of just compiling since there's something wrong with Tru64
tss@7889
   372
AC_MSG_CHECKING([for strtoimax])
tss@8601
   373
AC_TRY_LINK([
tss@7889
   374
  #include <inttypes.h>
tss@7889
   375
], [
tss@7889
   376
  strtoimax(0, 0, 0);
tss@7889
   377
], [
tss@7889
   378
  AC_DEFINE(HAVE_STRTOIMAX,, Define if you have strtoimax function)
tss@7889
   379
  AC_MSG_RESULT(yes)
tss@7889
   380
], [
tss@7889
   381
  AC_MSG_RESULT(no)
tss@7889
   382
])
tss@7889
   383
tss@7889
   384
AC_MSG_CHECKING([for strtoumax])
tss@8601
   385
AC_TRY_LINK([
tss@7889
   386
  #include <inttypes.h>
tss@7889
   387
], [
tss@7889
   388
  strtoumax(0, 0, 0);
tss@7889
   389
], [
tss@7889
   390
  AC_DEFINE(HAVE_STRTOUMAX,, Define if you have strtoumax function)
tss@7889
   391
  AC_MSG_RESULT(yes)
tss@7889
   392
], [
tss@7889
   393
  AC_MSG_RESULT(no)
tss@7889
   394
])
tss@7889
   395
tss@2569
   396
dnl * I/O loop function
tss@2569
   397
have_ioloop=no
tss@0
   398
tss@4482
   399
if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then
tss@7555
   400
  AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[
tss@5165
   401
    AC_TRY_RUN([
tss@5165
   402
      #include <sys/epoll.h>
tss@5165
   403
  
tss@5165
   404
      int main()
tss@5165
   405
      {
tss@5165
   406
	return epoll_create(5) < 1;
tss@5165
   407
      }
tss@5165
   408
    ], [
tss@7555
   409
      i_cv_epoll_works=yes
tss@5165
   410
    ], [
tss@7555
   411
      i_cv_epoll_works=no
tss@5165
   412
    ])
tss@5165
   413
  ])
tss@7555
   414
  if test $i_cv_epoll_works = yes; then
tss@2569
   415
    AC_DEFINE(IOLOOP_EPOLL,, Implement I/O loop with Linux 2.6 epoll())
tss@2569
   416
    have_ioloop=yes
tss@4386
   417
    ioloop=epoll
tss@5165
   418
  else
tss@4478
   419
    if test "$ioloop" = "epoll" ; then
tss@4478
   420
      AC_MSG_ERROR([epoll ioloop requested but epoll_create() is not available])
tss@4386
   421
    fi
tss@5165
   422
  fi
tss@2569
   423
fi
tss@2569
   424
tss@4482
   425
if test "$ioloop" = "best" || test "$ioloop" = "kqueue"; then
tss@4433
   426
    if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes; then
tss@4386
   427
      AC_DEFINE(IOLOOP_KQUEUE,, [Implement I/O loop with BSD kqueue()])
tss@4386
   428
      ioloop=kqueue
tss@4386
   429
      have_ioloop=yes
tss@4386
   430
    elif test "$ioloop" = "kqueue"; then
tss@4478
   431
      AC_MSG_ERROR([kqueue ioloop requested but kqueue() is not available])
tss@4386
   432
    fi
tss@3749
   433
fi
tss@3749
   434
tss@4482
   435
if test "$ioloop" = "best" || test "$ioloop" = "poll"; then
tss@2569
   436
  AC_CHECK_FUNC(poll, [
tss@2569
   437
    AC_DEFINE(IOLOOP_POLL,, Implement I/O loop with poll())
tss@2569
   438
    ioloop=poll
tss@2569
   439
    have_ioloop=yes
tss@2569
   440
  ])
tss@2569
   441
fi
tss@2569
   442
tss@2569
   443
if test "$have_ioloop" = "no"; then
tss@2569
   444
  AC_DEFINE(IOLOOP_SELECT,, Implement I/O loop with select())
tss@2569
   445
  ioloop="select"
tss@2569
   446
fi
tss@0
   447
tss@3745
   448
have_notify=none
tss@3482
   449
tss@4386
   450
if test "$notify" = "" || test "$notify" = "inotify" ; then
tss@4386
   451
  dnl * inotify?
tss@7555
   452
  AC_CACHE_CHECK([whether we can use inotify],i_cv_inotify_works,[
tss@5165
   453
    AC_TRY_RUN([
tss@5165
   454
      #define _GNU_SOURCE
tss@5165
   455
      #include <sys/ioctl.h>
tss@5165
   456
      #include <fcntl.h>
tss@5165
   457
      #include <sys/inotify.h>
tss@5165
   458
      #include <stdio.h>
tss@5165
   459
    
tss@5165
   460
      int main()
tss@5165
   461
      {
tss@5165
   462
	int wd, fd;
tss@5165
   463
	char * fn = "/tmp";
tss@5165
   464
      
tss@5165
   465
	fd = inotify_init ();
tss@5165
   466
	if (fd < 0)
tss@5165
   467
	  {
tss@5165
   468
	    perror ("inotify_init");
tss@5165
   469
	    return 1;
tss@5165
   470
	  }
tss@4386
   471
  
tss@5165
   472
	wd = inotify_add_watch (fd, fn, IN_ALL_EVENTS);
tss@5165
   473
  
tss@5165
   474
	if (wd < 0)
tss@5165
   475
	  {
tss@5165
   476
	    perror ("inotify_add_watch");
tss@5165
   477
	    return 2;
tss@5165
   478
	  }
tss@5165
   479
  
tss@5165
   480
	inotify_rm_watch (fd, wd);
tss@5165
   481
  
tss@5165
   482
	close (fd);
tss@5165
   483
	return 0;
tss@5165
   484
      }
tss@5165
   485
    ], [
tss@7555
   486
      i_cv_inotify_works=yes
tss@5165
   487
    ], [
tss@7555
   488
      i_cv_inotify_works=no
tss@5165
   489
    ])
tss@5165
   490
  ])
tss@7555
   491
  if test $i_cv_inotify_works = yes; then
tss@4386
   492
    have_notify=inotify
tss@4386
   493
    notify=inotify
tss@4386
   494
    AC_DEFINE(IOLOOP_NOTIFY_INOTIFY,, Use Linux inotify)
tss@5165
   495
  else
tss@4386
   496
    if test "$notify" = "inotify"; then
tss@4478
   497
      AC_MSG_ERROR([inotify requested but not available])
tss@4423
   498
      notify=""
tss@4386
   499
    fi
tss@5165
   500
  fi
tss@4386
   501
fi
tss@4386
   502
tss@4572
   503
if (test "$notify" = "" && test "$ioloop" = kqueue) || test "$notify" = "kqueue"; then
tss@4423
   504
  AC_MSG_CHECKING([if we can use BSD kqueue() notify])
tss@4386
   505
  dnl * BSD kqueue() notify
tss@4442
   506
  if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes ; then
tss@4386
   507
    have_notify=kqueue
tss@4386
   508
    notify=kqueue
tss@4423
   509
    AC_MSG_RESULT("yes")
tss@4386
   510
    AC_DEFINE(IOLOOP_NOTIFY_KQUEUE,,
tss@4386
   511
      Use BSD kqueue directory changes notificaton)
tss@4386
   512
  else 
tss@4423
   513
    AC_MSG_RESULT("no")
tss@4386
   514
    if test "$notfify" = "kqueue" ; then
tss@4478
   515
      AC_MSG_ERROR([kqueue notify requested but kqueue() is not available])
tss@4423
   516
      notify=""
tss@4386
   517
    fi
tss@4386
   518
  fi
tss@4386
   519
fi
tss@4386
   520
tss@3482
   521
if test "$notify" = "" || test "$notify" = "dnotify"; then
tss@5165
   522
  AC_MSG_CHECKING([whether we can use dnotify])
tss@3482
   523
  dnl * dnotify?
tss@3482
   524
  AC_TRY_COMPILE([
tss@3482
   525
    #define _GNU_SOURCE
tss@3482
   526
    #include <fcntl.h>
tss@3482
   527
    #include <signal.h>
tss@3482
   528
    #include <unistd.h>
tss@3482
   529
  ], [
tss@3482
   530
    fcntl(0, F_SETSIG, SIGRTMIN);
tss@3482
   531
    fcntl(0, F_NOTIFY, DN_CREATE | DN_DELETE | DN_RENAME | DN_MULTISHOT);
tss@3482
   532
  ], [
tss@5165
   533
    AC_MSG_RESULT(yes)
tss@3482
   534
    AC_DEFINE(IOLOOP_NOTIFY_DNOTIFY,, Use Linux dnotify)
tss@3745
   535
    have_notify=dnotify
tss@4386
   536
    notify=dnotify
tss@3482
   537
  ], [
tss@5165
   538
    AC_MSG_RESULT(no)
tss@3482
   539
    if test "$notify" = "dnotify"; then
tss@4478
   540
      AC_MSG_ERROR([dnotify requested but not available])
tss@3482
   541
    fi
tss@3482
   542
  ])
tss@3745
   543
fi
tss@3745
   544
tss@3745
   545
if test "$have_notify" = "none"; then
tss@3745
   546
  AC_DEFINE(IOLOOP_NOTIFY_NONE,, No special notify support)
tss@3482
   547
fi
tss@1729
   548
tss@1989
   549
dnl * GLIBC?
tss@1989
   550
AC_TRY_COMPILE([
tss@1989
   551
  #include <stdlib.h>
tss@1989
   552
  #ifdef __GLIBC__
tss@1989
   553
    we have glibc
tss@1989
   554
  #endif
tss@1989
   555
],,, [
tss@1989
   556
  AC_DEFINE(PREAD_WRAPPERS,, Define if pread/pwrite needs _XOPEN_SOURCE 500)
tss@1989
   557
])
tss@1989
   558
tss@7164
   559
dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
tss@8227
   560
dnl * It may also be broken in AIX.
tss@8227
   561
AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[
tss@8227
   562
  AC_TRY_RUN([
tss@8227
   563
    #define _XOPEN_SOURCE 600
tss@8227
   564
    #include <stdio.h>
tss@8227
   565
    #include <stdlib.h>
tss@8227
   566
    #include <fcntl.h>
tss@8227
   567
    #include <unistd.h>
tss@8227
   568
    #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
tss@8227
   569
      possibly broken posix_fallocate
tss@8227
   570
    #endif
tss@8227
   571
    int main() {
tss@8227
   572
      int fd = creat("conftest.temp", 0600);
tss@8227
   573
      int ret;
tss@8227
   574
      if (fd == -1) {
tss@8227
   575
	perror("creat()");
tss@8227
   576
	return 2;
tss@8227
   577
      }
tss@8227
   578
      ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0;
tss@8227
   579
      unlink("conftest.temp");
tss@8227
   580
      return ret;
tss@8227
   581
    }
tss@8227
   582
  ], [
tss@8227
   583
    i_cv_posix_fallocate_works=yes
tss@8227
   584
  ], [
tss@8227
   585
    i_cv_posix_fallocate_works=no
tss@8227
   586
  ])
tss@8227
   587
])
tss@8227
   588
if test $i_cv_posix_fallocate_works = yes; then
tss@7164
   589
  AC_DEFINE(HAVE_POSIX_FALLOCATE,, Define if you have a working posix_fallocate())
tss@8227
   590
fi
tss@7164
   591
tss@0
   592
dnl * OS specific options
tss@0
   593
case "$host_os" in
tss@0
   594
	hpux*)
tss@7823
   595
		CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
tss@7823
   596
		# for getting fd_send/fd_recv working:
tss@7823
   597
		LDFLAGS="$LDFLAGS -Wl,+b,:"
tss@7823
   598
		LIBS="-lxnet $LIBS"
tss@7822
   599
		AC_DEFINE(PREAD_BROKEN,, Defint if pread/pwrite implementation is broken)
tss@0
   600
		;;
tss@0
   601
	*)
tss@0
   602
		;;
tss@0
   603
esac
tss@0
   604
tss@55
   605
AC_CHECK_SIZEOF(int)
tss@55
   606
AC_CHECK_SIZEOF(long)
tss@464
   607
AC_CHECK_SIZEOF(void *)
tss@55
   608
AC_CHECK_SIZEOF(long long)
tss@185
   609
tss@2036
   610
AC_DEFUN([AC_TYPEOF], [
tss@677
   611
  dnl * first check if we can get the size with redefining typedefs
tss@677
   612
tss@677
   613
  order="$2"
tss@677
   614
  if test "$2" = ""; then
tss@677
   615
    order="int long long-long"
tss@677
   616
  fi
tss@677
   617
tss@677
   618
  result=""
tss@677
   619
  visible="unknown"
tss@733
   620
  AC_MSG_CHECKING([type of $1])
tss@677
   621
tss@2796
   622
  if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
tss@733
   623
    dnl * try with printf() + -Werror
tss@733
   624
    old_CFLAGS="$CFLAGS"
tss@733
   625
    CFLAGS="$CFLAGS -Werror"
tss@733
   626
tss@733
   627
    for type in $order; do
tss@733
   628
      case "$type" in
tss@733
   629
        int)
tss@733
   630
	  fmt="%d"
tss@733
   631
	  ;;
tss@1630
   632
        unsigned-int)
tss@1630
   633
	  fmt="%u"
tss@1630
   634
	  ;;
tss@733
   635
        long)
tss@733
   636
	  fmt="%ld"
tss@733
   637
	  ;;
tss@1630
   638
        unsigned-long)
tss@1630
   639
	  fmt="%lu"
tss@1630
   640
	  ;;
tss@733
   641
        long-long)
tss@733
   642
	  fmt="%lld"
tss@733
   643
	  ;;
tss@1630
   644
        unsigned-long-long)
tss@1630
   645
	  fmt="%llu"
tss@1630
   646
	  ;;
tss@733
   647
	*)
tss@733
   648
	  fmt=""
tss@733
   649
	  ;;
tss@733
   650
      esac
tss@733
   651
tss@733
   652
      if test "$fmt" != ""; then
tss@2796
   653
	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@733
   654
	  #include <sys/types.h>
tss@733
   655
	  #include <stdio.h>
tss@2796
   656
	]], [[
tss@733
   657
	  printf("$fmt", ($1)0);
tss@2796
   658
	]])],[
tss@733
   659
	  if test "$result" != ""; then
tss@733
   660
	    dnl * warning check isn't working
tss@733
   661
	    result=""
tss@733
   662
	    visible="unknown"
tss@733
   663
	    break
tss@733
   664
	  fi
tss@733
   665
	  result="`echo $type|sed 's/-/ /g'`"
tss@733
   666
	  visible="$result"
tss@2796
   667
	],[])
tss@677
   668
      fi
tss@733
   669
    done
tss@733
   670
    CFLAGS="$old_CFLAGS"
tss@733
   671
  fi
tss@733
   672
tss@733
   673
  if test "$result" = ""; then
tss@733
   674
    for type in $order; do
tss@733
   675
      type="`echo $type|sed 's/-/ /g'`"
tss@2796
   676
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@733
   677
	#include <sys/types.h>
tss@733
   678
	typedef $type $1;
tss@2796
   679
      ]], [[]])],[
tss@733
   680
	if test "$result" != ""; then
tss@733
   681
	  dnl * compiler allows redefining to anything
tss@733
   682
	  result=""
tss@733
   683
	  visible="unknown"
tss@733
   684
	  break
tss@733
   685
	fi
tss@733
   686
	result="$type"
tss@733
   687
	visible="$type"
tss@2796
   688
      ],[])
tss@733
   689
    done
tss@733
   690
  fi
tss@677
   691
tss@677
   692
  if test "$result" = ""; then
tss@677
   693
    dnl * check with sizes
tss@677
   694
tss@677
   695
    dnl * older autoconfs don't include sys/types.h, so do it manually
tss@2796
   696
    AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@677
   697
      #include <stdio.h>
tss@677
   698
      #include <sys/types.h>
tss@677
   699
      int main() {
tss@677
   700
	FILE *f=fopen("conftestval", "w");
tss@677
   701
	if (!f) exit(1);
tss@677
   702
	fprintf(f, "%d\n", sizeof($1));
tss@677
   703
	exit(0);
tss@677
   704
      }
tss@2796
   705
    ]])],[
tss@677
   706
      size=`cat conftestval`
tss@677
   707
      rm -f conftestval
tss@677
   708
tss@677
   709
      for type in $order; do
tss@677
   710
        actype="ac_cv_sizeof_`echo $type|sed 's/-/_/g'`"
tss@4567
   711
        if test "$size" = "`eval echo \\$$actype`"; then
tss@677
   712
	  result="`echo $type|sed 's/-/ /g'`"
tss@677
   713
	  visible="`expr $size \* 8`bit (using $result)"
tss@677
   714
	  break
tss@677
   715
	fi
tss@677
   716
      done
tss@677
   717
      if test "$result" = ""; then
tss@4055
   718
        result=unknown
tss@4055
   719
	visible="`expr $size \* 8`bit (unknown type)"
tss@677
   720
      fi
tss@2796
   721
    ],[],[])
tss@677
   722
  fi
tss@677
   723
tss@677
   724
  typeof_$1=$result
tss@677
   725
  AC_MSG_RESULT($visible)
tss@185
   726
])
tss@55
   727
tss@6616
   728
AC_SYS_LARGEFILE
tss@3929
   729
AC_CHECK_TYPES(_Bool)
tss@3929
   730
tss@3929
   731
AC_CHECK_TYPE(uoff_t, [
tss@3931
   732
  have_uoff_t=yes
tss@3929
   733
  AC_DEFINE(HAVE_UOFF_T,, Define if you have a native uoff_t type)
tss@3929
   734
], [
tss@3931
   735
  have_uoff_t=no
tss@3931
   736
])
tss@3931
   737
tss@3931
   738
AC_TYPEOF(off_t, long int long-long)
tss@3931
   739
case "$typeof_off_t" in
tss@3931
   740
  int)
tss@3931
   741
    offt_max=INT_MAX
tss@3931
   742
    uofft_fmt="u"
tss@3931
   743
    if test "$have_uoff_t" != "yes"; then
tss@3929
   744
      AC_DEFINE(UOFF_T_INT,, Define if off_t is int)
tss@3931
   745
    fi
tss@3931
   746
    offt_bits=`expr 8 \* $ac_cv_sizeof_int`
tss@3931
   747
    ;;
tss@3931
   748
  long)
tss@3931
   749
    offt_max=LONG_MAX
tss@3931
   750
    uofft_fmt="lu"
tss@3931
   751
    if test "$have_uoff_t" != "yes"; then
tss@3929
   752
      AC_DEFINE(UOFF_T_LONG,, Define if off_t is long)
tss@3931
   753
    fi
tss@3931
   754
    offt_bits=`expr 8 \* $ac_cv_sizeof_long`
tss@3931
   755
    ;;
tss@3931
   756
  "long long")
tss@3931
   757
    offt_max=LLONG_MAX
tss@3931
   758
    uofft_fmt="llu"
tss@3931
   759
    if test "$have_uoff_t" != "yes"; then
tss@3929
   760
      AC_DEFINE(UOFF_T_LONG_LONG,, Define if off_t is long long)
tss@3931
   761
    fi
tss@3931
   762
    offt_bits=`expr 8 \* $ac_cv_sizeof_long_long`
tss@3931
   763
    ;;
tss@3931
   764
  *)
tss@3931
   765
    AC_MSG_ERROR([Unsupported off_t type])
tss@3931
   766
    ;;
tss@3931
   767
esac
tss@50
   768
tss@2078
   769
dnl * Do we have struct dirent->d_type
tss@2796
   770
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@2078
   771
  #include <dirent.h>
tss@2796
   772
]], [[
tss@2078
   773
  struct dirent d;
tss@2078
   774
  d.d_type = DT_DIR;
tss@2796
   775
]])],[
tss@2078
   776
  AC_DEFINE(HAVE_DIRENT_D_TYPE,, Define if you have struct dirent->d_type)
tss@2796
   777
],[])
tss@2078
   778
tss@1382
   779
dnl * Do we have OFF_T_MAX?
tss@2796
   780
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@1382
   781
  #include <limits.h>
tss@1382
   782
  #include <sys/types.h>
tss@2796
   783
]], [[
tss@1382
   784
  off_t i = OFF_T_MAX;
tss@2796
   785
]])],[
tss@1403
   786
  :
tss@2796
   787
],[
tss@1382
   788
  AC_DEFINE_UNQUOTED(OFF_T_MAX, $offt_max, Maximum value of off_t)
tss@1382
   789
])
tss@1382
   790
tss@742
   791
AC_DEFINE_UNQUOTED(PRIuUOFF_T, "$uofft_fmt", printf() format for uoff_t)
tss@742
   792
tss@750
   793
dnl * make sure size_t isn't signed. we'd probably work fine with it, but
tss@750
   794
dnl * it's more likely vulnerable to buffer overflows. Anyway, C99 specifies
tss@750
   795
dnl * that it's unsigned and only some old systems define it as signed.
tss@7555
   796
AC_CACHE_CHECK([whether size_t is signed],i_cv_signed_size_t,[
tss@5165
   797
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@5165
   798
    #include <sys/types.h>
tss@5165
   799
    int main() {
tss@5165
   800
      /* return 0 if we're signed */
tss@5165
   801
      exit((size_t)(int)-1 <= 0 ? 0 : 1);
tss@5165
   802
    }
tss@5165
   803
  ]])],[
tss@7555
   804
    i_cv_signed_size_t=yes
tss@750
   805
tss@5165
   806
    echo
tss@5165
   807
    echo "Your system's size_t is a signed integer, Dovecot isn't designed to"
tss@5165
   808
    echo "support it. It probably works just fine, but it's less resistant to"
tss@5165
   809
    echo "buffer overflows. If you're not worried about this and still want to"
tss@5165
   810
    echo "compile Dovecot, set ignore_signed_size=1 environment."
tss@5165
   811
  
tss@5165
   812
    if test "$ignore_signed_size" = ""; then
tss@5165
   813
      AC_MSG_ERROR([aborting])
tss@5165
   814
    fi
tss@5165
   815
    echo "..ignoring as requested.."
tss@5165
   816
  ],[
tss@7555
   817
    i_cv_signed_size_t=no
tss@5165
   818
  ],[])
tss@5165
   819
])
tss@1626
   820
dnl Note: we check size_t rather than ssize_t here, because on OSX 10.2
tss@1626
   821
dnl ssize_t = int and size_t = unsigned long. We're mostly concerned about
tss@1626
   822
dnl printf format here, so check the size_t one.
tss@1626
   823
AC_TYPEOF(size_t, unsigned-int unsigned-long unsigned-long-long)
tss@1626
   824
case "$typeof_size_t" in
tss@1626
   825
  "unsigned long")
tss@742
   826
    ssizet_max=LONG_MAX
tss@742
   827
    sizet_fmt="lu"
tss@677
   828
    ;;
tss@1626
   829
  "unsigned long long")
tss@742
   830
    ssizet_max=LLONG_MAX
tss@742
   831
    sizet_fmt="llu"
tss@677
   832
    ;;
tss@677
   833
  *)
tss@677
   834
    dnl older systems didn't have ssize_t, default to int
tss@742
   835
    ssizet_max=INT_MAX
tss@742
   836
    sizet_fmt="u"
tss@742
   837
tss@1626
   838
    if test "$typeof_size_t" = ""; then
tss@742
   839
      AC_DEFINE(size_t, unsigned int, Define to 'unsigned int' if you don't have it)
tss@742
   840
      AC_DEFINE(ssize_t, int, Define to 'int' if you don't have it)
tss@742
   841
    fi
tss@677
   842
    ;;
tss@677
   843
esac
tss@183
   844
tss@742
   845
AC_DEFINE_UNQUOTED(SSIZE_T_MAX, $ssizet_max, Maximum value of ssize_t)
tss@742
   846
AC_DEFINE_UNQUOTED(PRIuSIZE_T, "$sizet_fmt", printf() format for size_t)
tss@742
   847
tss@2036
   848
AC_DEFUN([AC_CHECKTYPE2], [
tss@678
   849
  AC_MSG_CHECKING([for $1])
tss@678
   850
  AC_CACHE_VAL(i_cv_type_$1,
tss@2796
   851
  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@678
   852
  #include <sys/types.h>
tss@2796
   853
  $2]], [[$1 t;]])],[i_cv_type_$1=yes],[i_cv_type_$1=no])])
tss@678
   854
  AC_MSG_RESULT($i_cv_type_$1)
tss@678
   855
])
tss@678
   856
tss@1660
   857
dnl some systems don't have stdint.h, but still have some of the types
tss@1660
   858
dnl defined elsewhere
tss@1660
   859
AC_CHECK_HEADER(stdint.h, [
tss@1660
   860
  stdint_include="#include <stdint.h>"
tss@1660
   861
])
tss@1660
   862
tss@1660
   863
AC_CHECKTYPE2(uintmax_t, [$stdint_include])
tss@678
   864
if test $i_cv_type_uintmax_t = yes; then
tss@742
   865
  AC_DEFINE(HAVE_UINTMAX_T,, Define if you have uintmax_t (C99 type))
tss@179
   866
fi
tss@179
   867
tss@908
   868
dnl use separate check, eg. Solaris 8 has uintmax_t but not uint_fast32_t
tss@1660
   869
AC_CHECKTYPE2(uint_fast32_t, [$stdint_include])
tss@908
   870
if test $i_cv_type_uint_fast32_t = yes; then
tss@908
   871
  AC_DEFINE(HAVE_UINT_FAST32_T,, Define if you have uint_fast32_t (C99 type))
tss@908
   872
fi
tss@908
   873
tss@678
   874
AC_CHECKTYPE2(socklen_t, [#include <sys/socket.h>])
tss@678
   875
if test $i_cv_type_socklen_t = yes; then
tss@742
   876
  AC_DEFINE(HAVE_SOCKLEN_T,, Define to 'int' if you don't have socklen_t)
tss@0
   877
fi
tss@0
   878
tss@1394
   879
AC_DEFINE_UNQUOTED(MEM_ALIGN_SIZE, $mem_align, Required memory alignment)
tss@1394
   880
tss@1335
   881
dnl * find random source
tss@9014
   882
AC_MSG_CHECKING([for OpenBSD /dev/arandom])
tss@9014
   883
if test -c /dev/arandom; then
tss@1335
   884
  AC_MSG_RESULT(yes)
tss@9014
   885
  AC_DEFINE(DEV_URANDOM_PATH, "/dev/arandom", Path to /dev/urandom)
tss@1335
   886
  have_random_source=yes
tss@1335
   887
else
tss@1335
   888
  AC_MSG_RESULT(no)
tss@9014
   889
  AC_MSG_CHECKING([for /dev/urandom])
tss@9014
   890
  if test -c /dev/urandom || test -s /dev/urandom; then
tss@9014
   891
    AC_MSG_RESULT(yes)
tss@9014
   892
    AC_DEFINE(DEV_URANDOM_PATH, "/dev/urandom", Path to /dev/urandom)
tss@9014
   893
    have_random_source=yes
tss@9014
   894
  else
tss@9014
   895
    AC_MSG_RESULT(no)
tss@9014
   896
  fi
tss@9014
   897
fi
tss@1335
   898
tss@9014
   899
if test "$have_random_source" != "yes"; then
tss@1335
   900
  AC_CHECK_HEADER(openssl/rand.h, [
tss@1335
   901
    AC_DEFINE(HAVE_OPENSSL_RAND_H,, Define if you have openssl/rand.h)
tss@7844
   902
    LIBS="$LIBS -lcrypto"
tss@1335
   903
  ])
tss@1335
   904
fi
tss@1335
   905
tss@0
   906
dnl * do we have tm_gmtoff
tss@0
   907
AC_MSG_CHECKING([for tm_gmtoff])
tss@0
   908
AC_CACHE_VAL(i_cv_field_tm_gmtoff,
tss@2796
   909
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@2796
   910
#include <time.h>]],
tss@2796
   911
[[struct tm *tm; return tm->tm_gmtoff;]])],
tss@2796
   912
[i_cv_field_tm_gmtoff=yes],
tss@2796
   913
[i_cv_field_tm_gmtoff=no])])
tss@0
   914
if test $i_cv_field_tm_gmtoff = yes; then
tss@742
   915
	AC_DEFINE(HAVE_TM_GMTOFF,, Define if you have struct tm->tm_gmtoff)
tss@0
   916
fi
tss@0
   917
AC_MSG_RESULT($i_cv_field_tm_gmtoff)
tss@0
   918
tss@1658
   919
dnl * how large time_t values does gmtime() accept?
tss@7555
   920
AC_CACHE_CHECK([how large time_t values gmtime() accepts],i_cv_gmtime_max_time_t,[
tss@5165
   921
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@5165
   922
    #include <stdio.h>
tss@5165
   923
    #include <time.h>
tss@5165
   924
    int main() {
tss@5165
   925
      FILE *f;
tss@5165
   926
      int bits;
tss@5165
   927
  
tss@6522
   928
      for (bits = 1; bits < sizeof(time_t)*8; bits++) {
tss@6483
   929
	time_t t = ((time_t)1 << bits) - 1;
tss@5165
   930
	if (gmtime(&t) == NULL) {
tss@5165
   931
	  bits--;
tss@5165
   932
	  break;
tss@5165
   933
	}
tss@1658
   934
      }
tss@5165
   935
      if (bits > 40) {
tss@5165
   936
	/* Solaris 9 breaks after 55 bits. Perhaps other systems break earlier.
tss@5165
   937
	   Let's just do the same as Cyrus folks and limit it to 40 bits. */
tss@5165
   938
	bits = 40;
tss@5165
   939
      }
tss@5165
   940
  
tss@5165
   941
      f = fopen("conftest.temp", "w");
tss@5165
   942
      if (f == NULL) {
tss@5165
   943
	perror("fopen()");
tss@5165
   944
	return 1;
tss@5165
   945
      }
tss@5165
   946
      fprintf(f, "%d", bits);
tss@5165
   947
      fclose(f);
tss@5165
   948
      return 0;
tss@1658
   949
    }
tss@5165
   950
  ]])],[
tss@7555
   951
    i_cv_gmtime_max_time_t=`cat conftest.temp`
tss@5165
   952
    rm -f conftest.temp
tss@5165
   953
  ], [
tss@5165
   954
    printf "check failed, assuming "
tss@7555
   955
    i_cv_gmtime_max_time_t=31
tss@5165
   956
  ],[])
tss@5165
   957
])
tss@7555
   958
AC_DEFINE_UNQUOTED(TIME_T_MAX_BITS, $i_cv_gmtime_max_time_t, max. time_t bits gmtime() can handle)
tss@1658
   959
tss@7555
   960
AC_CACHE_CHECK([whether time_t is signed],i_cv_signed_time_t,[
tss@6483
   961
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@6483
   962
    #include <sys/types.h>
tss@6483
   963
    int main() {
tss@6483
   964
      /* return 0 if we're signed */
tss@6483
   965
      exit((time_t)(int)-1 <= 0 ? 0 : 1);
tss@6483
   966
    }
tss@6483
   967
  ]])],[
tss@7555
   968
    i_cv_signed_time_t=yes
tss@6483
   969
  ], [
tss@7555
   970
    i_cv_signed_time_t=no
tss@6483
   971
  ])
tss@6483
   972
])
tss@7555
   973
if test $i_cv_signed_time_t = yes; then
tss@6483
   974
  AC_DEFINE(TIME_T_SIGNED,, Define if your time_t is signed)
tss@6483
   975
fi
tss@6483
   976
tss@7997
   977
dnl Our implementation of AC_C_FLEXIBLE_ARRAY_MEMBER.
tss@7997
   978
dnl Use it until autoconf 2.61+ becomes more widely used
tss@7997
   979
AC_MSG_CHECKING([if we can use C99-like flexible array members])
tss@7997
   980
AC_TRY_COMPILE([
tss@7997
   981
  struct foo {
tss@7997
   982
    int x;
tss@7997
   983
    char y[];
tss@7997
   984
  };
tss@7997
   985
], [
tss@7997
   986
  struct foo foo;
tss@7997
   987
], [
tss@7997
   988
  flexible_value=""
tss@7997
   989
  AC_MSG_RESULT(yes)
tss@7997
   990
], [
tss@7997
   991
  flexible_value=1
tss@7997
   992
  AC_MSG_RESULT(no)
tss@7997
   993
])
tss@7997
   994
AC_DEFINE_UNQUOTED(FLEXIBLE_ARRAY_MEMBER, $flexible_value, How to define flexible array members in structs)
tss@7997
   995
tss@411
   996
dnl * do we have struct iovec
tss@411
   997
AC_MSG_CHECKING([for struct iovec])
tss@411
   998
AC_CACHE_VAL(i_cv_struct_iovec,
tss@2796
   999
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@411
  1000
#include <sys/types.h>
tss@411
  1001
#include <sys/uio.h>
tss@2796
  1002
#include <unistd.h>]],
tss@2796
  1003
[[struct iovec *iovec;]])],
tss@2796
  1004
[i_cv_struct_iovec=yes],
tss@2796
  1005
[i_cv_struct_iovec=no])])
tss@411
  1006
tss@411
  1007
if test $i_cv_struct_iovec = yes; then
tss@742
  1008
	AC_DEFINE(HAVE_STRUCT_IOVEC,, Define if you have struct iovec)
tss@411
  1009
fi
tss@411
  1010
AC_MSG_RESULT($i_cv_struct_iovec)
tss@411
  1011
tss@691
  1012
dnl * is dev_t an integer or something else?
tss@2796
  1013
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@691
  1014
  #include <sys/types.h>
tss@691
  1015
  struct test { dev_t a; };
tss@691
  1016
  static struct test t = { 0 };
tss@2796
  1017
]], [[]])],[],[
tss@742
  1018
  AC_DEFINE(DEV_T_STRUCT,, Define if your dev_t is a structure instead of integer type)
tss@691
  1019
tss@691
  1020
  dnl we can't initialize structures, so don't warn about them either
tss@2796
  1021
  if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
tss@691
  1022
    CFLAGS=`echo $CFLAGS|sed 's/ -W\b//'`
tss@691
  1023
  fi
tss@691
  1024
])
tss@691
  1025
tss@739
  1026
dnl * Do we have RLIMIT_AS?
tss@2796
  1027
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@739
  1028
  #include <sys/types.h>
tss@739
  1029
  #include <sys/time.h>
tss@739
  1030
  #include <sys/resource.h>
tss@2796
  1031
]], [[
tss@739
  1032
  struct rlimit r;
tss@739
  1033
  getrlimit(RLIMIT_AS, &r);
tss@2796
  1034
]])],[
tss@742
  1035
  AC_DEFINE(HAVE_RLIMIT_AS,, Define if you have RLIMIT_AS for setrlimit())
tss@2796
  1036
],[])
tss@739
  1037
tss@1065
  1038
dnl * Do we have RLIMIT_NPROC?
tss@2796
  1039
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@1065
  1040
  #include <sys/types.h>
tss@1065
  1041
  #include <sys/time.h>
tss@1065
  1042
  #include <sys/resource.h>
tss@2796
  1043
]], [[
tss@1065
  1044
  struct rlimit r;
tss@1065
  1045
  getrlimit(RLIMIT_NPROC, &r);
tss@2796
  1046
]])],[
tss@1065
  1047
  AC_DEFINE(HAVE_RLIMIT_NPROC,, Define if you have RLIMIT_NPROC for setrlimit())
tss@2796
  1048
],[])
tss@1065
  1049
tss@7946
  1050
dnl * Do we have RLIMIT_CORE?
tss@7946
  1051
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@7946
  1052
  #include <sys/types.h>
tss@7946
  1053
  #include <sys/time.h>
tss@7946
  1054
  #include <sys/resource.h>
tss@7946
  1055
]], [[
tss@7946
  1056
  struct rlimit r;
tss@7946
  1057
  getrlimit(RLIMIT_CORE, &r);
tss@7946
  1058
]])],[
tss@7946
  1059
  AC_DEFINE(HAVE_RLIMIT_CORE,, Define if you have RLIMIT_CORE for getrlimit())
tss@7946
  1060
],[])
tss@7946
  1061
tss@8798
  1062
AC_MSG_CHECKING([PR_SET_DUMPABLE])
tss@8798
  1063
AC_TRY_LINK([
tss@8798
  1064
  #include <sys/prctl.h>
tss@8798
  1065
], [
tss@8798
  1066
  prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
tss@8798
  1067
], [
tss@8798
  1068
  AC_DEFINE(HAVE_PR_SET_DUMPABLE,, Define if you have prctl(PR_SET_DUMPABLE))
tss@8798
  1069
  AC_MSG_RESULT(yes)
tss@8798
  1070
], [
tss@8798
  1071
  AC_MSG_RESULT(no)
tss@8798
  1072
])
tss@8798
  1073
tss@528
  1074
dnl * Linux compatible mremap()
tss@528
  1075
AC_MSG_CHECKING([Linux compatible mremap()])
tss@2181
  1076
AC_TRY_LINK([
tss@224
  1077
  #include <unistd.h>
tss@224
  1078
  #define __USE_GNU
tss@224
  1079
  #include <sys/mman.h>
tss@529
  1080
], [
tss@529
  1081
  mremap(0, 0, 0, MREMAP_MAYMOVE);
tss@224
  1082
], [
tss@742
  1083
  AC_DEFINE(HAVE_LINUX_MREMAP,, Define if you have Linux-compatible mremap())
tss@224
  1084
  AC_MSG_RESULT(yes)
tss@224
  1085
], [
tss@224
  1086
  AC_MSG_RESULT(no)
tss@224
  1087
])
tss@224
  1088
tss@1622
  1089
dnl * If mmap() plays nicely with write()
tss@7555
  1090
AC_CACHE_CHECK([whether shared mmaps get updated by write()s],i_cv_mmap_plays_with_write,[
tss@2349
  1091
  AC_TRY_RUN([
tss@5165
  1092
    #include <stdio.h>
tss@2349
  1093
    #include <sys/types.h>
tss@2349
  1094
    #include <sys/stat.h>
tss@2349
  1095
    #include <unistd.h>
tss@2349
  1096
    #include <fcntl.h>
tss@5165
  1097
    #include <sys/mman.h>
tss@5165
  1098
    int main() {
tss@5165
  1099
      /* return 0 if we're signed */
tss@8226
  1100
      int f = open("conftest.mmap", O_RDWR|O_CREAT|O_TRUNC, 0600);
tss@5165
  1101
      void *mem;
tss@5165
  1102
      if (f == -1) {
tss@5165
  1103
	perror("open()");
tss@5165
  1104
	return 1;
tss@5165
  1105
      }
tss@5165
  1106
      unlink("conftest.mmap");
tss@5165
  1107
  
tss@5165
  1108
      write(f, "1", 2);
tss@5165
  1109
      mem = mmap(NULL, 2, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0);
tss@5165
  1110
      if (mem == MAP_FAILED) {
tss@5165
  1111
	perror("mmap()");
tss@5165
  1112
	return 1;
tss@5165
  1113
      }
tss@5165
  1114
      strcpy(mem, "2");
tss@5165
  1115
      msync(mem, 2, MS_SYNC);
tss@5165
  1116
      lseek(f, 0, SEEK_SET);
tss@5165
  1117
      write(f, "3", 2);
tss@2349
  1118
    
tss@5165
  1119
      return strcmp(mem, "3") == 0 ? 0 : 1;
tss@2349
  1120
    }
tss@2349
  1121
  ], [
tss@7555
  1122
    i_cv_mmap_plays_with_write=yes
tss@5165
  1123
  ], [
tss@7555
  1124
    i_cv_mmap_plays_with_write=no
tss@5165
  1125
  ])
tss@5165
  1126
])
tss@7555
  1127
if test $i_cv_mmap_plays_with_write = no; then
tss@5165
  1128
  AC_DEFINE(MMAP_CONFLICTS_WRITE,, [Define if shared mmaps don't get updated by write()s])
tss@5165
  1129
fi
tss@5165
  1130
tss@5165
  1131
dnl * see if fd passing works
tss@7555
  1132
AC_CACHE_CHECK([whether fd passing works],i_cv_fd_passing,[
tss@5165
  1133
  for i in 1 2; do
tss@5165
  1134
    old_cflags="$CFLAGS"
tss@5165
  1135
    CFLAGS="$CFLAGS -I$srcdir/src/lib $srcdir/src/lib/fdpass.c"
tss@2349
  1136
    if test $i = 2; then
tss@5165
  1137
      CFLAGS="$CFLAGS -DBUGGY_CMSG_MACROS"
tss@2349
  1138
    fi
tss@5165
  1139
  
tss@5165
  1140
    AC_TRY_RUN([
tss@5165
  1141
      #include <sys/types.h>
tss@5165
  1142
      #include <sys/socket.h>
tss@5165
  1143
      #include <sys/wait.h>
tss@5165
  1144
      #include <sys/stat.h>
tss@5165
  1145
      #include <unistd.h>
tss@5165
  1146
      #include <fcntl.h>
tss@5165
  1147
      #include "fdpass.h"
tss@5165
  1148
      
tss@8578
  1149
      int nopen(void)
tss@8578
  1150
      {
tss@8578
  1151
	      int i, n;
tss@8578
  1152
	      struct stat sb;
tss@8578
  1153
	      for (i = n = 0; i < 256; i++)
tss@8578
  1154
		  if (fstat(i, &sb) == 0) n++;
tss@8578
  1155
	      return n;
tss@8578
  1156
      }
tss@5165
  1157
      int main(void)
tss@5165
  1158
      {
tss@8578
  1159
	      int fd[2], send_fd, recv_fd, status, n1, n2;
tss@5165
  1160
	      struct stat st, st2;
tss@5165
  1161
	      char data;
tss@5165
  1162
      
tss@8226
  1163
	      send_fd = creat("conftest.fdpass", 0600);
tss@5165
  1164
	      if (send_fd == -1) return 2;
tss@5165
  1165
	      unlink("conftest.fdpass");
tss@5165
  1166
	      if (fstat(send_fd, &st) < 0) return 2;
tss@5165
  1167
	      if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 2;
tss@8578
  1168
	      n1 = nopen();
tss@5165
  1169
      
tss@5165
  1170
	      switch (fork()) {
tss@5165
  1171
	      case -1:
tss@5165
  1172
		      return 2;
tss@5165
  1173
	      case 0:
tss@5165
  1174
		      alarm(1);
tss@5165
  1175
		      if (fd_send(fd[0], send_fd, &data, 1) != 1) return 2;
tss@5165
  1176
		      return 0;
tss@5165
  1177
	      default:
tss@5165
  1178
		      alarm(2);
tss@5165
  1179
		      if (wait(&status) == -1)
tss@5165
  1180
			return 2;
tss@5165
  1181
		      if (status != 0)
tss@5165
  1182
			return status;
tss@5165
  1183
		      if (fd_read(fd[1], &data, 1, &recv_fd) != 1) return 1;
tss@5165
  1184
		      if (fstat(recv_fd, &st2) < 0) return 2;
tss@8578
  1185
		      /* nopen check is for making sure that only a single fd
tss@8578
  1186
		         was received */
tss@8578
  1187
		      n2 = nopen();
tss@8578
  1188
		      return st.st_ino == st2.st_ino && n2 == n1 + 1 ? 0 : 1;
tss@5165
  1189
	      }
tss@5165
  1190
      }
tss@5165
  1191
    ], [
tss@5165
  1192
      CFLAGS=$old_cflags
tss@5165
  1193
      if test $i = 2; then
tss@7555
  1194
	i_cv_fd_passing=buggy_cmsg_macros
tss@5165
  1195
      else
tss@7555
  1196
        i_cv_fd_passing=yes
tss@5165
  1197
      fi
tss@5165
  1198
      break
tss@5165
  1199
    ], [
tss@5165
  1200
      dnl no, try with BUGGY_CMSG_MACROS
tss@5165
  1201
      CFLAGS=$old_cflags
tss@7555
  1202
      i_cv_fd_passing=no
tss@5165
  1203
    ])
tss@5165
  1204
  done
tss@5165
  1205
]);
tss@5165
  1206
tss@8578
  1207
case "$host_os" in
tss@8578
  1208
darwin[[1-9]].*)
tss@8578
  1209
	if test "$i_cv_fd_passing" = "yes"; then
tss@8578
  1210
		i_cv_fd_passing=buggy_cmsg_macros
tss@8578
  1211
	fi
tss@8578
  1212
	;;
tss@8578
  1213
esac
tss@8578
  1214
tss@7555
  1215
if test $i_cv_fd_passing = buggy_cmsg_macros; then
tss@5165
  1216
  AC_DEFINE(BUGGY_CMSG_MACROS,, Define if you have buggy CMSG macros)
tss@5165
  1217
fi
tss@1622
  1218
tss@2035
  1219
dnl * Solaris compatible sendfile()
tss@2035
  1220
AC_CHECK_LIB(sendfile, sendfile, [
tss@976
  1221
  LIBS="$LIBS -lsendfile"
tss@2035
  1222
  AC_DEFINE(HAVE_SOLARIS_SENDFILE,, Define if you have Solaris-compatible sendfile())
tss@976
  1223
], [
tss@981
  1224
  dnl * Linux compatible sendfile() - don't check if Solaris one was found.
tss@981
  1225
  dnl * This seems to pass with Solaris for some reason..
tss@981
  1226
  AC_MSG_CHECKING([Linux compatible sendfile()])
tss@2181
  1227
  AC_TRY_LINK([
tss@981
  1228
    #undef _FILE_OFFSET_BITS
tss@981
  1229
    #include <sys/types.h>
tss@981
  1230
    #include <sys/socket.h>
tss@981
  1231
    #include <sys/sendfile.h>
tss@981
  1232
  ], [
tss@981
  1233
    sendfile(0, 0, (void *) 0, 0);
tss@981
  1234
  ], [
tss@981
  1235
    AC_DEFINE(HAVE_LINUX_SENDFILE,, Define if you have Linux-compatible sendfile())
tss@981
  1236
    AC_MSG_RESULT(yes)
tss@981
  1237
  ], [
tss@981
  1238
    AC_MSG_RESULT(no)
tss@981
  1239
  ])
tss@981
  1240
tss@981
  1241
  dnl * FreeBSD compatible sendfile()
tss@981
  1242
  AC_MSG_CHECKING([FreeBSD compatible sendfile()])
tss@2181
  1243
  AC_TRY_LINK([
tss@981
  1244
    #include <sys/types.h>
tss@981
  1245
    #include <sys/socket.h>
tss@981
  1246
    #include <sys/uio.h>
tss@981
  1247
  ], [
tss@981
  1248
    struct sf_hdtr hdtr;
tss@981
  1249
    sendfile(0, 0, 0, 0, &hdtr, (void *) 0, 0);
tss@981
  1250
  ], [
tss@981
  1251
    AC_DEFINE(HAVE_FREEBSD_SENDFILE,, Define if you have FreeBSD-compatible sendfile())
tss@981
  1252
    AC_MSG_RESULT(yes)
tss@981
  1253
  ], [
tss@981
  1254
    AC_MSG_RESULT(no)
tss@981
  1255
  ])
tss@976
  1256
])
tss@976
  1257
tss@3590
  1258
dnl * Check for crypt() if unistd.h compiles with _XOPEN_SOURCE + _XPG6
tss@3590
  1259
dnl * Add other macros there too "just in case".
tss@3594
  1260
AC_MSG_CHECKING([if we should use _XPG6 macro for crypt()])
tss@3590
  1261
AC_TRY_COMPILE([
tss@3590
  1262
  #define _XOPEN_SOURCE 4
tss@3590
  1263
  #define _XOPEN_SOURCE_EXTENDED 1
tss@3590
  1264
  #define _XOPEN_VERSION 4
tss@3590
  1265
  #define _XPG4_2
tss@3590
  1266
  #define _XPG6
tss@3590
  1267
  #include <unistd.h>
tss@3590
  1268
], [
tss@3590
  1269
  crypt("a", "b");
tss@3590
  1270
], [
tss@3590
  1271
  AC_DEFINE(CRYPT_USE_XPG6,, Define if _XPG6 macro is needed for crypt())
tss@3594
  1272
  AC_MSG_RESULT(yes)
tss@3594
  1273
], [
tss@3594
  1274
  AC_MSG_RESULT(no)
tss@3590
  1275
])
tss@3590
  1276
tss@7526
  1277
AC_MSG_CHECKING([if struct stat has st_?tim timespec fields])
tss@5375
  1278
AC_TRY_COMPILE([
tss@5375
  1279
  #include <sys/types.h>
tss@5375
  1280
  #include <sys/stat.h>
tss@5375
  1281
  #include <unistd.h>
tss@5375
  1282
], [
tss@5375
  1283
  struct stat st;
tss@5375
  1284
  unsigned long x = st.st_mtim.tv_nsec;
tss@5375
  1285
tss@5375
  1286
  return 0;
tss@5375
  1287
], [
tss@7526
  1288
  AC_DEFINE(HAVE_STAT_XTIM,, Define if you have st_?tim timespec fields in struct stat)
tss@7526
  1289
  AC_MSG_RESULT(yes)
tss@7526
  1290
], [
tss@7526
  1291
  AC_MSG_RESULT(no)
tss@7526
  1292
])
tss@7526
  1293
tss@7526
  1294
AC_MSG_CHECKING([if struct stat has st_?timespec fields])
tss@7526
  1295
AC_TRY_COMPILE([
tss@7526
  1296
  #include <sys/types.h>
tss@7526
  1297
  #include <sys/stat.h>
tss@7526
  1298
  #include <unistd.h>
tss@7526
  1299
], [
tss@7526
  1300
  struct stat st;
tss@7526
  1301
  unsigned long x = st.st_mtimespec.tv_nsec;
tss@7526
  1302
tss@7526
  1303
  return 0;
tss@7526
  1304
], [
tss@7526
  1305
  AC_DEFINE(HAVE_STAT_XTIMESPEC,, Define if you have st_?timespec fields in struct stat)
tss@5375
  1306
  AC_MSG_RESULT(yes)
tss@5375
  1307
], [
tss@5375
  1308
  AC_MSG_RESULT(no)
tss@5375
  1309
])
tss@5375
  1310
tss@4736
  1311
dnl * Check if statvfs() can be used to find out block device for files
tss@4736
  1312
AC_MSG_CHECKING([if statvfs.f_mntfromname exists])
tss@4736
  1313
AC_TRY_COMPILE([
tss@4736
  1314
  #include <sys/types.h>
tss@4736
  1315
  #include <sys/statvfs.h>
tss@4736
  1316
], [
tss@4736
  1317
  struct statvfs buf;
tss@4736
  1318
  char *p = buf.f_mntfromname;
tss@4736
  1319
tss@4736
  1320
  statvfs(".", &buf);
tss@4736
  1321
], [
tss@4736
  1322
  AC_DEFINE(HAVE_STATVFS_MNTFROMNAME,, Define if you have statvfs.f_mntfromname)
tss@4736
  1323
  AC_MSG_RESULT(yes)
tss@4736
  1324
], [
tss@4736
  1325
  AC_MSG_RESULT(no)
tss@4736
  1326
])
tss@4736
  1327
tss@4736
  1328
dnl * Check if statvfs() can be used to find out block device for files
tss@4736
  1329
AC_MSG_CHECKING([if statvfs.f_mntfromname exists])
tss@4736
  1330
AC_TRY_COMPILE([
tss@4736
  1331
  #include <sys/types.h>
tss@4736
  1332
  #include <sys/statvfs.h>
tss@4736
  1333
], [
tss@4736
  1334
  struct statvfs buf;
tss@4736
  1335
  char *p = buf.f_mntfromname;
tss@4736
  1336
tss@4736
  1337
  statvfs(".", &buf);
tss@4736
  1338
], [
tss@4736
  1339
  AC_DEFINE(HAVE_STATVFS_MNTFROMNAME,, Define if you have statvfs.f_mntfromname)
tss@4736
  1340
  AC_MSG_RESULT(yes)
tss@4736
  1341
], [
tss@4736
  1342
  AC_MSG_RESULT(no)
tss@4736
  1343
])
tss@4736
  1344
tss@3745
  1345
dnl * Check if statfs() can be used to find out block device for files
tss@3745
  1346
AC_MSG_CHECKING([if statfs.f_mntfromname exists])
tss@3745
  1347
AC_TRY_COMPILE([
tss@3745
  1348
  #include <sys/param.h>
tss@3745
  1349
  #include <sys/mount.h>
tss@3745
  1350
], [
tss@3745
  1351
  struct statfs buf;
tss@3745
  1352
  char *p = buf.f_mntfromname;
tss@3745
  1353
tss@3745
  1354
  statfs(".", &buf);
tss@3745
  1355
], [
tss@3745
  1356
  AC_DEFINE(HAVE_STATFS_MNTFROMNAME,, Define if you have statfs.f_mntfromname)
tss@3745
  1357
  AC_MSG_RESULT(yes)
tss@3745
  1358
], [
tss@3745
  1359
  AC_MSG_RESULT(no)
tss@3745
  1360
])
tss@3745
  1361
tss@4552
  1362
dnl * Check if we have struct dqblk.dqb_curblocks
tss@4552
  1363
AC_MSG_CHECKING([if struct dqblk.dqb_curblocks exists])
tss@4552
  1364
AC_TRY_COMPILE([
tss@4552
  1365
  #include <sys/types.h>
tss@4552
  1366
  #include "$srcdir/src/plugins/quota/quota-fs.h"
tss@4552
  1367
], [
tss@4552
  1368
  struct dqblk dqblk;
tss@4552
  1369
  unsigned int x = dqblk.dqb_curblocks;
tss@4552
  1370
], [
tss@4552
  1371
  AC_DEFINE(HAVE_STRUCT_DQBLK_CURBLOCKS,, Define if struct sqblk.dqb_curblocks exists)
tss@4552
  1372
  AC_MSG_RESULT(yes)
tss@4552
  1373
], [
tss@4552
  1374
  AC_MSG_RESULT(no)
tss@4552
  1375
])
tss@4552
  1376
tss@4552
  1377
dnl * Check if we have struct dqblk.dqb_curspace
tss@4552
  1378
AC_MSG_CHECKING([if struct dqblk.dqb_curspace exists])
tss@4552
  1379
AC_TRY_COMPILE([
tss@4552
  1380
  #include <sys/types.h>
tss@4552
  1381
  #include "$srcdir/src/plugins/quota/quota-fs.h"
tss@4552
  1382
], [
tss@4552
  1383
  struct dqblk dqblk;
tss@4552
  1384
  unsigned int x = dqblk.dqb_curspace;
tss@4552
  1385
], [
tss@4552
  1386
  AC_DEFINE(HAVE_STRUCT_DQBLK_CURSPACE,, Define if struct sqblk.dqb_curspace exists)
tss@4552
  1387
  AC_MSG_RESULT(yes)
tss@4552
  1388
], [
tss@4552
  1389
  AC_MSG_RESULT(no)
tss@4552
  1390
])
tss@4552
  1391
tss@4063
  1392
dnl * Check if we have Q_QUOTACTL ioctl (Solaris)
tss@4063
  1393
AC_MSG_CHECKING([if struct Q_QUOTACTL ioctl exists])
tss@4063
  1394
AC_TRY_COMPILE([
tss@4065
  1395
  #include <sys/types.h>
tss@4063
  1396
  #include <sys/fs/ufs_quota.h>
tss@4063
  1397
], [
tss@4064
  1398
  struct quotctl ctl;
tss@4063
  1399
  ioctl(0, Q_QUOTACTL, &ctl);
tss@4063
  1400
], [
tss@4063
  1401
  AC_DEFINE(HAVE_Q_QUOTACTL,, Define if Q_QUOTACTL exists)
tss@4063
  1402
  AC_MSG_RESULT(yes)
tss@4063
  1403
], [
tss@4063
  1404
  AC_MSG_RESULT(no)
tss@4063
  1405
])
tss@4063
  1406
tss@859
  1407
dnl ***
tss@5681
  1408
dnl *** C99 vsnprintf()?
tss@5681
  1409
dnl ***
tss@5681
  1410
tss@7555
  1411
AC_CACHE_CHECK([for C99 vsnprintf()],i_cv_c99_vsnprintf,[
tss@5681
  1412
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@5681
  1413
  #include <stdio.h>
tss@5681
  1414
  #include <stdarg.h>
tss@5681
  1415
  static int f(const char *fmt, ...) {
tss@5681
  1416
    va_list args;
tss@5681
  1417
    char buf[13];
tss@5681
  1418
    int ret;
tss@5681
  1419
tss@5681
  1420
    va_start(args, fmt);
tss@5681
  1421
    ret = vsnprintf(buf, 11, fmt, args) != 12 || buf[11-1] != '\0';
tss@5681
  1422
    va_end(args);
tss@5681
  1423
    return ret;
tss@5681
  1424
  }
tss@5681
  1425
  int main() {
tss@5681
  1426
    return f("hello %s%d", "world", 1);
tss@5681
  1427
  }]])],
tss@7555
  1428
  [i_cv_c99_vsnprintf=yes],
tss@7850
  1429
  [i_cv_c99_vsnprintf=no])
tss@5681
  1430
])
tss@7555
  1431
if test $i_cv_c99_vsnprintf = no; then
tss@7850
  1432
  AC_DEFINE(HAVE_OLD_VSNPRINTF,, Define if you don't have C99 compatible vsnprintf() call)
tss@5681
  1433
fi
tss@5681
  1434
tss@5681
  1435
dnl ***
tss@859
  1436
dnl *** va_copy checks (from GLIB)
tss@859
  1437
dnl ***
tss@859
  1438
tss@859
  1439
AC_CACHE_CHECK([for an implementation of va_copy()],lib_cv_va_copy,[
tss@2796
  1440
	AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@859
  1441
	#include <stdarg.h>
tss@859
  1442
	void f (int i, ...) {
tss@859
  1443
	va_list args1, args2;
tss@859
  1444
	va_start (args1, i);
tss@859
  1445
	va_copy (args2, args1);
tss@859
  1446
	if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
tss@859
  1447
	  exit (1);
tss@859
  1448
	va_end (args1); va_end (args2);
tss@859
  1449
	}
tss@859
  1450
	int main() {
tss@859
  1451
	  f (0, 42);
tss@859
  1452
	  return 0;
tss@2796
  1453
	}]])],
tss@859
  1454
	[lib_cv_va_copy=yes],
tss@2796
  1455
	[lib_cv_va_copy=no],[])
tss@859
  1456
])
tss@859
  1457
AC_CACHE_CHECK([for an implementation of __va_copy()],lib_cv___va_copy,[
tss@2796
  1458
	AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@859
  1459
	#include <stdarg.h>
tss@859
  1460
	void f (int i, ...) {
tss@859
  1461
	va_list args1, args2;
tss@859
  1462
	va_start (args1, i);
tss@859
  1463
	__va_copy (args2, args1);
tss@859
  1464
	if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
tss@859
  1465
	  exit (1);
tss@859
  1466
	va_end (args1); va_end (args2);
tss@859
  1467
	}
tss@859
  1468
	int main() {
tss@859
  1469
	  f (0, 42);
tss@859
  1470
	  return 0;
tss@2796
  1471
	}]])],
tss@859
  1472
	[lib_cv___va_copy=yes],
tss@2796
  1473
	[lib_cv___va_copy=no],[])
tss@859
  1474
])
tss@859
  1475
tss@859
  1476
if test "x$lib_cv_va_copy" = "xyes"; then
tss@859
  1477
  va_copy_func=va_copy
tss@859
  1478
else if test "x$lib_cv___va_copy" = "xyes"; then
tss@859
  1479
  va_copy_func=__va_copy
tss@859
  1480
fi
tss@859
  1481
fi
tss@859
  1482
tss@859
  1483
if test -n "$va_copy_func"; then
tss@859
  1484
  AC_DEFINE_UNQUOTED(VA_COPY,$va_copy_func,[A 'va_copy' style function])
tss@859
  1485
fi
tss@859
  1486
tss@859
  1487
AC_CACHE_CHECK([whether va_lists can be copied by value],lib_cv_va_val_copy,[
tss@2796
  1488
	AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@859
  1489
	#include <stdarg.h>
tss@859
  1490
	void f (int i, ...) {
tss@859
  1491
	va_list args1, args2;
tss@859
  1492
	va_start (args1, i);
tss@859
  1493
	args2 = args1;
tss@859
  1494
	if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
tss@859
  1495
	  exit (1);
tss@859
  1496
	va_end (args1); va_end (args2);
tss@859
  1497
	}
tss@859
  1498
	int main() {
tss@859
  1499
	  f (0, 42);
tss@859
  1500
	  return 0;
tss@2796
  1501
	}]])],
tss@859
  1502
	[lib_cv_va_val_copy=yes],
tss@2796
  1503
	[lib_cv_va_val_copy=no],[])
tss@859
  1504
])
tss@859
  1505
tss@859
  1506
if test "x$lib_cv_va_val_copy" = "xno"; then
tss@859
  1507
  AC_DEFINE(VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
tss@859
  1508
fi
tss@859
  1509
tss@7958
  1510
dnl * dynamic modules?
tss@7958
  1511
have_modules=no
tss@7958
  1512
AC_CHECK_FUNC(dlopen, [
tss@7958
  1513
  have_modules=yes
tss@7958
  1514
  MODULE_LIBS="-export-dynamic"
tss@7958
  1515
], [
tss@7958
  1516
  AC_CHECK_LIB(dl, dlopen, [
tss@7958
  1517
    have_modules=yes
tss@7958
  1518
    MODULE_LIBS="-export-dynamic -ldl"
tss@7958
  1519
    DLLIB=-ldl
tss@7958
  1520
  ])
tss@7958
  1521
])
tss@7958
  1522
tss@0
  1523
dnl **
tss@8022
  1524
dnl ** AIX mntctl
tss@8022
  1525
dnl **
tss@8022
  1526
tss@8022
  1527
if test $ac_cv_header_sys_vmount_h = yes; then
tss@8022
  1528
  AC_MSG_CHECKING([for reasonable mntctl buffer size])
tss@8022
  1529
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
tss@8022
  1530
    #include <stdio.h>
tss@8022
  1531
    #include <stdlib.h>
tss@8022
  1532
    #include <sys/vmount.h>
tss@8022
  1533
    int main() {
tss@8022
  1534
      int size,count; char *m;
tss@8022
  1535
      FILE *f=fopen("conftestval", "w");
tss@8022
  1536
      if (!f) exit(1);
tss@8022
  1537
      if ((count=mntctl(MCTL_QUERY,sizeof(size),&size))!=0 || !(m=malloc(size)) ||
tss@8022
  1538
          (count=mntctl(MCTL_QUERY,size,m))<=0) exit(1);
tss@8022
  1539
        fprintf(f, "%d\n",(size * (count + 5))/count & ~1); /* 5 mounts more */
tss@8022
  1540
        exit(0);
tss@8022
  1541
    }
tss@8022
  1542
  ]])],[
tss@8022
  1543
    size=`cat conftestval`
tss@8022
  1544
    rm -f conftestval
tss@8022
  1545
    AC_DEFINE_UNQUOTED(STATIC_MTAB_SIZE,$size, reasonable mntctl buffer size)
tss@8022
  1546
    AC_MSG_RESULT($size)
tss@8022
  1547
  ],[
tss@8022
  1548
    AC_MSG_RESULT(default)
tss@8022
  1549
  ])
tss@8022
  1550
fi
tss@8022
  1551
tss@8022
  1552
tss@8022
  1553
dnl **
tss@622
  1554
dnl ** SSL
tss@0
  1555
dnl **
tss@0
  1556
tss@623
  1557
have_ssl=no
tss@623
  1558
tss@6974
  1559
if test $want_openssl != no && test $have_ssl = no; then
tss@4049
  1560
  if pkg-config --exists openssl 2>/dev/null; then
tss@1565
  1561
    PKG_CHECK_MODULES(SSL, openssl)
tss@1565
  1562
    CFLAGS="$CFLAGS $SSL_CFLAGS"
tss@1565
  1563
    have_openssl=yes
tss@1565
  1564
  else
tss@7958
  1565
    # openssl 0.9.8 wants -ldl and it's required if there's only .a lib
tss@1565
  1566
    AC_CHECK_LIB(ssl, SSL_read, [
tss@1565
  1567
      AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h, [
tss@7958
  1568
        SSL_LIBS="-lssl -lcrypto $DLLIB"
tss@1565
  1569
        AC_SUBST(SSL_LIBS)
tss@1565
  1570
	have_openssl=yes
tss@6974
  1571
      ], [
tss@6974
  1572
	if test $want_openssl = yes; then
tss@6974
  1573
	  AC_ERROR([Can't build with OpenSSL: openssl/ssl.h or openssl/err.h not found])
tss@6974
  1574
	fi
tss@1565
  1575
      ])
tss@6974
  1576
    ], [
tss@6974
  1577
      if test $want_openssl = yes; then
tss@6974
  1578
        AC_ERROR([Can't build with OpenSSL: libssl not found])
tss@6974
  1579
      fi
tss@7958
  1580
    ], -lcrypto $DLLIB)
tss@1565
  1581
  fi
tss@1566
  1582
  if test "$have_openssl" = "yes"; then
tss@1566
  1583
    AC_DEFINE(HAVE_OPENSSL,, Build with OpenSSL support)
tss@1566
  1584
    have_ssl="yes (OpenSSL)"
tss@9416
  1585
tss@9416
  1586
    AC_CHECK_LIB(ssl, SSL_get_current_compression, [
tss@9416
  1587
      AC_DEFINE(HAVE_SSL_COMPRESSION,, Build with OpenSSL compression)
tss@9416
  1588
    ],, $SSL_LIBS)
tss@1566
  1589
  fi
tss@622
  1590
fi
tss@622
  1591
tss@6974
  1592
if test $want_gnutls != no && test $have_ssl = no; then
tss@6974
  1593
  AC_CHECK_LIB(gnutls, gnutls_global_init, [
tss@6974
  1594
    AC_CHECK_HEADER(gnutls/gnutls.h, [
tss@6974
  1595
      AC_DEFINE(HAVE_GNUTLS,, Build with GNUTLS support)
tss@6974
  1596
      SSL_LIBS="-lgnutls -lgcrypt"
tss@6974
  1597
      AC_SUBST(SSL_LIBS)
tss@6974
  1598
      have_ssl="yes (GNUTLS)"
tss@6974
  1599
      have_gnutls=yes
tss@6974
  1600
    ], [
tss@6974
  1601
      if test $want_gnutls = yes; then
tss@6974
  1602
	AC_ERROR([Can't build with GNUTLS: gnutls/gnutls.h not found])
tss@6974
  1603
      fi
tss@6974
  1604
    ])
tss@6974
  1605
  ], [
tss@6974
  1606
    if test $want_gnutls = yes; then
tss@6974
  1607
      AC_ERROR([Can't build with GNUTLS: libgnutls not found])
tss@6974
  1608
    fi
tss@6974
  1609
  ], -lgcrypt)
tss@1948
  1610
fi
tss@1948
  1611
tss@742
  1612
if test "$have_ssl" != "no"; then
tss@742
  1613
	AC_DEFINE(HAVE_SSL,, Build with SSL/TLS support)
tss@742
  1614
fi
tss@742
  1615
tss@0
  1616
dnl **
tss@1786
  1617
dnl ** Garbage Collector
tss@1786
  1618
dnl ** 
tss@1786
  1619
tss@6974
  1620
if test $want_gc != no; then
tss@1786
  1621
  AC_CHECK_LIB(gc, GC_malloc, [
tss@1786
  1622
    AC_CHECK_HEADERS(gc/gc.h gc.h)
tss@1786
  1623
    AC_DEFINE(USE_GC,, Define if you want to use Boehm GC)
tss@1786
  1624
    LIBS="$LIBS -lgc"
tss@1786
  1625
  ], [
tss@6974
  1626
    if test $want_gc = yes; then
tss@6974
  1627
      AC_ERROR([Can't build with GC: libgc not found])
tss@6974
  1628
    fi
tss@1786
  1629
  ])
tss@1786
  1630
fi
tss@1786
  1631
tss@1786
  1632
dnl **
tss@1043
  1633
dnl ** userdb and passdb checks
tss@0
  1634
dnl **
tss@0
  1635
tss@1043
  1636
userdb=""
tss@1043
  1637
passdb=""
tss@9164
  1638
not_userdb=""
tss@9164
  1639
not_passdb=""
tss@1043
  1640
tss@6974
  1641
if test $want_static_userdb != no; then
tss@1043
  1642
        AC_DEFINE(USERDB_STATIC,, Build with static userdb support)
tss@1043
  1643
	userdb="$userdb static"
tss@9164
  1644
else
tss@9164
  1645
	not_userdb="$not_userdb static"
tss@1043
  1646
fi
tss@0
  1647
tss@6974
  1648
if test $want_prefetch_userdb != no; then
tss@3667
  1649
        AC_DEFINE(USERDB_PREFETCH,, Build with prefetch userdb support)
tss@3667
  1650
	userdb="$userdb prefetch"
tss@9164
  1651
else
tss@9164
  1652
	not_userdb="$not_userdb prefetch"
tss@3062
  1653
fi
tss@3062
  1654
tss@6974
  1655
if test $want_passwd != no; then
tss@1043
  1656
        AC_DEFINE(USERDB_PASSWD,, Build with passwd support)
tss@1043
  1657
        AC_DEFINE(PASSDB_PASSWD,, Build with passwd support)
tss@1043
  1658
	userdb="$userdb passwd"
tss@1043
  1659
	passdb="$passdb passwd"
tss@9164
  1660
else
tss@9164
  1661
	not_passdb="$not_passdb passwd"
tss@9164
  1662
	not_userdb="$not_userdb passwd"
tss@0
  1663
fi
tss@0
  1664
tss@6974
  1665
if test $want_passwd_file != no; then
tss@1043
  1666
        AC_DEFINE(USERDB_PASSWD_FILE,, Build with passwd-file support)
tss@1043
  1667
        AC_DEFINE(PASSDB_PASSWD_FILE,, Build with passwd-file support)
tss@1043
  1668
	userdb="$userdb passwd-file"
tss@1043
  1669
	passdb="$passdb passwd-file"
tss@9164
  1670
else
tss@9164
  1671
	not_passdb="$not_passdb passwd-file"
tss@9164
  1672
	not_userdb="$not_userdb passwd-file"
tss@0
  1673
fi
tss@0
  1674
tss@9164
  1675
have_shadow=no
tss@6974
  1676
if test $want_shadow != no; then
tss@6974
  1677
  AC_CHECK_FUNC(getspnam, [
tss@6974
  1678
    AC_CHECK_HEADER(shadow.h, [
tss@6974
  1679
      AC_DEFINE(PASSDB_SHADOW,, Build with shadow support)
tss@9164
  1680
      have_shadow=yes
tss@6974
  1681
    ], [
tss@6974
  1682
      if test $want_shadow = yes; then
tss@6974
  1683
        AC_ERROR([Can't build with shadow support: shadow.h not found])
tss@6974
  1684
      fi
tss@6974
  1685
    ])
tss@6974
  1686
  ], [
tss@6974
  1687
    if test $want_shadow = yes; then
tss@6974
  1688
      AC_ERROR([Can't build with shadow support: getspnam() not found])
tss@6974
  1689
    fi
tss@6974
  1690
  ])
tss@0
  1691
fi
tss@9164
  1692
if test $have_shadow = no; then
tss@9164
  1693
  not_passdb="$not_passdb shadow"
tss@9164
  1694
else
tss@9164
  1695
  passdb="$passdb shadow"
tss@9164
  1696
fi
tss@0
  1697
tss@6974
  1698
if test $want_pam != no; then
tss@0
  1699
	AC_CHECK_LIB(pam, pam_start, [
tss@706
  1700
		have_pam=no
tss@0
  1701
		AC_CHECK_HEADER(security/pam_appl.h, [
tss@742
  1702
			AC_DEFINE(HAVE_SECURITY_PAM_APPL_H,,
tss@742
  1703
				  Define if you have security/pam_appl.h)
tss@706
  1704
			have_pam=yes
tss@706
  1705
		])
tss@706
  1706
tss@706
  1707
		AC_CHECK_HEADER(pam/pam_appl.h, [
tss@742
  1708
			AC_DEFINE(HAVE_PAM_PAM_APPL_H,,
tss@742
  1709
				  Define if you have pam/pam_appl.h)
tss@706
  1710
			have_pam=yes
tss@706
  1711
		])
tss@6974
  1712
	], [
tss@6974
  1713
	  if test $want_pam = yes; then
tss@6974
  1714
	    AC_ERROR([Can't build with PAM support: libpam not found])
tss@6974
  1715
	  fi
tss@0
  1716
	])
tss@0
  1717
fi
tss@0
  1718
tss@9164
  1719
if test "$have_pam" = "yes"; then
tss@9164
  1720
  AUTH_LIBS="$AUTH_LIBS -lpam"
tss@9164
  1721
  AC_DEFINE(PASSDB_PAM,, Build with PAM support)
tss@9164
  1722
  passdb="$passdb pam"
tss@9164
  1723
tss@9164
  1724
  AC_CHECK_LIB(pam, pam_setcred, [
tss@9164
  1725
    AC_DEFINE(HAVE_PAM_SETCRED,, Define if you have pam_setcred())
tss@9164
  1726
  ])
tss@9164
  1727
elif test $want_pam = yes; then
tss@9164
  1728
  AC_ERROR([Can't build with PAM support: pam_appl.h not found])
tss@9164
  1729
else
tss@9164
  1730
  not_passdb="$not_passdb pam"
tss@9164
  1731
fi
tss@9164
  1732
tss@6974
  1733
if test $want_checkpassword != no; then
tss@2162
  1734
        AC_DEFINE(PASSDB_CHECKPASSWORD,, Build with checkpassword passdb support)
tss@8307
  1735
        AC_DEFINE(USERDB_CHECKPASSWORD,, Build with checkpassword userdb support)
tss@2162
  1736
	passdb="$passdb checkpassword"
tss@8307
  1737
	userdb="$userdb checkpassword"
tss@9164
  1738
else
tss@9164
  1739
	not_passdb="$not_passdb checkpassword"
tss@9164
  1740
	not_userdb="$not_userdb checkpassword"
tss@2162
  1741
fi
tss@2162
  1742
tss@9164
  1743
have_bsdauth=no
tss@6974
  1744
if test $want_bsdauth != no; then
tss@1851
  1745
	AC_CHECK_FUNC(auth_userokay, [
tss@1851
  1746
		AC_DEFINE(PASSDB_BSDAUTH,, Build with BSD authentication support)
tss@9164
  1747
		have_bsdauth=yes
tss@6974
  1748
	], [
tss@6974
  1749
	  if test $want_bsdauth = yes; then
tss@6974
  1750
	    AC_ERROR([Can't build with BSD authentication support: auth_userokay() not found])
tss@6974
  1751
	  fi
tss@1851
  1752
	])
tss@1851
  1753
fi
tss@9164
  1754
if test $have_bsdauth = no; then
tss@9164
  1755
  not_passdb="$not_passdb bsdauth"
tss@9164
  1756
else
tss@9164
  1757
  passdb="$passdb bsdauth"
tss@9164
  1758
fi
tss@1851
  1759
tss@3683
  1760
have_gssapi=no
tss@6974
  1761
if test $want_gssapi != no; then
tss@3683
  1762
	AC_CHECK_PROG(KRB5CONFIG, krb5-config, YES, NO)
tss@3683
  1763
	if test $KRB5CONFIG = YES; then
tss@7548
  1764
		if ! krb5-config --version gssapi 2>/dev/null > /dev/null; then
tss@7548
  1765
		  # krb5-config doesn't support gssapi.
tss@7548
  1766
		  KRB5_LIBS="`krb5-config --libs`"
tss@7548
  1767
		  KRB5_CFLAGS=`krb5-config --cflags`
tss@7548
  1768
		  AC_CHECK_LIB(gss, gss_acquire_cred, [
tss@7548
  1769
		    # Solaris
tss@7548
  1770
		    KRB5_LIBS="$KRB5_LIBS -lgss"
tss@7548
  1771
		  ], [
tss@7548
  1772
		    # failed
tss@7548
  1773
		    KRB5_LIBS=
tss@7548
  1774
		  ], $KRB5_LIBS)
tss@7548
  1775
		else
tss@7548
  1776
		  KRB5_LIBS=`krb5-config --libs gssapi`
tss@7548
  1777
		  KRB5_CFLAGS=`krb5-config --cflags gssapi`
tss@7548
  1778
		fi
tss@7548
  1779
		if test "$KRB5_LIBS" != ""; then
tss@6199
  1780
			AC_SUBST(KRB5_LIBS)
tss@6199
  1781
			AC_SUBST(KRB5_CFLAGS)
tss@3780
  1782
			
tss@3780
  1783
			# Although krb5-config exists, all systems still don't
tss@3780
  1784
			# have gssapi.h
tss@3780
  1785
			old_CFLAGS=$CFLAGS
tss@7548
  1786
			CFLAGS="$CFLAGS $KRB5_CFLAGS"
tss@3780
  1787
			AC_CHECK_HEADER([gssapi/gssapi.h], [
tss@4862
  1788
				AC_DEFINE(HAVE_GSSAPI_GSSAPI_H,, GSSAPI headers in gssapi/gssapi.h)
tss@3780
  1789
				have_gssapi=yes
tss@3780
  1790
			])
tss@4862
  1791
			AC_CHECK_HEADER([gssapi.h], [
tss@4862
  1792
				AC_DEFINE(HAVE_GSSAPI_H,, GSSAPI headers in gssapi.h)
tss@4862
  1793
				have_gssapi=yes
tss@4862
  1794
			])
tss@8517
  1795
			if test $have_gssapi != no; then
tss@8517
  1796
				if test $want_gssapi = plugin; then
tss@8517
  1797
					have_gssapi=plugin
tss@8517
  1798
				fi
tss@4862
  1799
				AC_DEFINE(HAVE_GSSAPI,, Build with GSSAPI support)
tss@7610
  1800
				AC_CHECK_HEADERS(gssapi/gssapi_ext.h gssapi_krb5.h gssapi/gssapi_krb5.h)
tss@5859
  1801
				AC_CHECK_LIB(gss, __gss_userok, [
tss@5859
  1802
					AC_DEFINE(HAVE___GSS_USEROK,,
tss@5859
  1803
						Define if you have __gss_userok())
tss@7261
  1804
					KRB5_LIBS="$KRB5_LIBS -lgss"
tss@6199
  1805
				],, $KRB5_LIBS)
tss@6501
  1806
tss@8068
  1807
				# MIT has a #define for Heimdal acceptor_identity, but it's way too
tss@8068
  1808
				# difficult to test for it..
tss@8068
  1809
				old_LIBS=$LIBS
tss@8068
  1810
				LIBS="$LIBS $KRB5_LIBS"
tss@8068
  1811
				AC_CHECK_FUNCS(gsskrb5_register_acceptor_identity krb5_gss_register_acceptor_identity)
tss@8094
  1812
tss@8094
  1813
				# does the kerberos library support SPNEGO?
tss@8094
  1814
				AC_CACHE_CHECK([whether GSSAPI supports SPNEGO],i_cv_gssapi_spnego,[
tss@8094
  1815
				  AC_TRY_RUN([
tss@8094
  1816
				    #ifdef HAVE_GSSAPI_H
tss@8094
  1817
				    #  include <gssapi.h>
tss@8094
  1818
				    #else
tss@8094
  1819
				    #  include <gssapi/gssapi.h>
tss@8094
  1820
				    #endif
tss@8094
  1821
				    #include <krb5.h>
tss@8094
  1822
				    #include <string.h>
tss@8094
  1823
				    int main(void) {
tss@8094
  1824
				      OM_uint32 minor_status;
tss@8094
  1825
				      gss_OID_set mech_set;
tss@8094
  1826
				      unsigned char spnego_oid[] = { 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 };
tss@8094
  1827
				      unsigned int i;
tss@8094
  1828
    
tss@8094
  1829
				      gss_indicate_mechs(&minor_status, &mech_set);
tss@8094
  1830
				      for (i = 0; i < mech_set->count; i++) {
tss@8094
  1831
					if (mech_set->elements[i].length == 6 &&
tss@8094
  1832
					    memcmp(mech_set->elements[i].elements,
tss@8094
  1833
						   spnego_oid, 6) == 0)
tss@8094
  1834
					      return 0;
tss@8094
  1835
				      }
tss@8094
  1836
				      return 1;
tss@8094
  1837
				    }
tss@8094
  1838
				  ], [
tss@8094
  1839
				    i_cv_gssapi_spnego=yes
tss@8094
  1840
				  ], [
tss@8094
  1841
				    i_cv_gssapi_spnego=no
tss@8094
  1842
				  ])
tss@8094
  1843
				])
tss@8094
  1844
				if test "$i_cv_gssapi_spnego" = "yes"; then
tss@8094
  1845
				  AC_DEFINE(HAVE_GSSAPI_SPNEGO,, GSSAPI supports SPNEGO)
tss@8094
  1846
				fi
tss@8068
  1847
				LIBS=$old_LIBS
tss@8068
  1848
tss@8517
  1849
				if test $want_gssapi != plugin; then
tss@6501
  1850
				  AUTH_LIBS="$AUTH_LIBS $KRB5_LIBS"
tss@7554
  1851
				  AUTH_CFLAGS="$AUTH_CFLAGS $KRB5_CFLAGS"
tss@6501
  1852
				  AC_DEFINE(BUILTIN_GSSAPI,, GSSAPI support is built in)
tss@6501
  1853
				else
tss@6501
  1854
				  have_gssapi_plugin=yes
tss@6501
  1855
				fi
tss@6974
  1856
			else
tss@8517
  1857
			  if test $want_gssapi != auto; then
tss@6974
  1858
			    AC_ERROR([Can't build with GSSAPI support: gssapi.h not found])
tss@6974
  1859
			  fi
tss@4862
  1860
			fi
tss@3780
  1861
			CFLAGS=$old_CFLAGS
tss@3705
  1862
		fi
tss@6974
  1863
	else
tss@8517
  1864
	  if test $want_gssapi != auto; then
tss@6974
  1865
	    AC_ERROR([Can't build with GSSAPI support: krb5-config not found])
tss@6974
  1866
	  fi
tss@3683
  1867
	fi
tss@3683
  1868
fi
tss@6199
  1869
AM_CONDITIONAL(GSSAPI_PLUGIN, test "$have_gssapi_plugin" = "yes")
tss@3683
  1870
tss@9164
  1871
have_sia=no
tss@6974
  1872
if test $want_sia != no; then
tss@4638
  1873
	AC_CHECK_FUNC(sia_validate_user, [
tss@4638
  1874
		AC_DEFINE(PASSDB_SIA,, Build with Tru64 SIA support)
tss@4638
  1875
		AUTH_LIBS="$AUTH_LIBS -depth_ring_search"
tss@9164
  1876
		have_sia=yes
tss@6974
  1877
	], [
tss@6974
  1878
	  if test $want_sia = yes; then
tss@6974
  1879
	    AC_ERROR([Can't build with SIA support: sia_validate_user() not found])
tss@6974
  1880
	  fi
tss@4638
  1881
	])
tss@4638
  1882
fi
tss@4638
  1883
tss@9164
  1884
if test $have_sia = no; then
tss@9164
  1885
  not_passdb="$not_passdb sia"
tss@9164
  1886
else
tss@9164
  1887
  passdb="$passdb sia"
tss@9164
  1888
fi
tss@9164
  1889
tss@9164
  1890
have_ldap=no
tss@6974
  1891
if test $want_ldap != no; then
tss@1057
  1892
	AC_CHECK_LIB(ldap, ldap_init, [
tss@1057
  1893
		AC_CHECK_HEADER(ldap.h, [
tss@2325
  1894
			AC_CHECK_LIB(ldap, ldap_initialize, [
tss@2325
  1895
				AC_DEFINE(LDAP_HAVE_INITIALIZE,, Define if you have ldap_initialize)
tss@2325
  1896
			])
tss@4415
  1897
			AC_CHECK_LIB(ldap, ldap_start_tls_s, [
tss@4415
  1898
				AC_DEFINE(LDAP_HAVE_START_TLS_S,, Define if you have ldap_start_tls_s)
tss@4415
  1899
			])
tss@6198
  1900
			LDAP_LIBS=-lldap
tss@6198
  1901
			AC_SUBST(LDAP_LIBS)
tss@8517
  1902
			if test $want_ldap != plugin; then
tss@6198
  1903
				AUTH_LIBS="$AUTH_LIBS $LDAP_LIBS"
tss@6198
  1904
		        	AC_DEFINE(BUILTIN_LDAP,, LDAP support is built in)
tss@6198
  1905
			fi
tss@1057
  1906
tss@1057
  1907
        		AC_DEFINE(USERDB_LDAP,, Build with LDAP support)
tss@1057
  1908
		        AC_DEFINE(PASSDB_LDAP,, Build with LDAP support)
tss@9245
  1909
			AC_CHECK_HEADERS(sasl.h sasl/sasl.h)
tss@9164
  1910
			have_ldap=yes
tss@6974
  1911
		], [
tss@8517
  1912
		  if test $want_ldap != auto; then
tss@6974
  1913
		    AC_ERROR([Can't build with LDAP support: ldap.h not found])
tss@6974
  1914
		  fi
tss@1057
  1915
		])
tss@6974
  1916
	], [
tss@8517
  1917
	  if test $want_ldap != auto; then
tss@6974
  1918
	    AC_ERROR([Can't build with LDAP support: libldap not found])
tss@6974
  1919
	  fi
tss@1057
  1920
	])
tss@1057
  1921
fi
tss@1057
  1922
tss@9164
  1923
if test $have_ldap = no; then
tss@9164
  1924
  not_passdb="$not_passdb ldap"
tss@9164
  1925
  not_userdb="$not_userdb ldap"
tss@9164
  1926
else
tss@9164
  1927
  userdb="$userdb ldap"
tss@9164
  1928
  passdb="$passdb ldap"
tss@9164
  1929
  if test $want_ldap = plugin; then
tss@9164
  1930
    have_ldap_plugin=yes
tss@9164
  1931
    userdb="$userdb (plugin)"
tss@9164
  1932
    passdb="$passdb (plugin)"
tss@9164
  1933
  fi
tss@9164
  1934
fi
tss@9181
  1935
AM_CONDITIONAL(LDAP_PLUGIN, test "$have_ldap_plugin" = "yes")
tss@9164
  1936
timo@4517
  1937
dict_drivers=client
timo@4517
  1938
tss@6974
  1939
if test $want_db != no; then
timo@4517
  1940
	AC_MSG_CHECKING([db_env_create in -ldb])
timo@4517
  1941
	old_LIBS=$LIBS
timo@4517
  1942
	LIBS="$LIBS -ldb"
timo@4517
  1943
	AC_TRY_LINK([
timo@4517
  1944
		#include <db.h>
timo@4517
  1945
	], [
timo@4517
  1946
		db_env_create(0, 0);
timo@4517
  1947
	], [
timo@4517
  1948
		AC_MSG_RESULT(yes)
timo@4517
  1949
		AC_CHECK_HEADER(db.h, [
timo@4517
  1950
        		DICT_LIBS="$DICT_LIBS -ldb"
timo@4517
  1951
			dict_drivers="$dict_drivers db"
timo@4517
  1952
			AC_DEFINE(BUILD_DB,, Build with Berkeley DB support)
tss@6974
  1953
		], [
tss@6974
  1954
		  if test $want_db = yes; then
tss@6974
  1955
		    AC_ERROR([Can't build with db support: db.h not found])
tss@6974
  1956
		  fi
timo@4517
  1957
		])
timo@4517
  1958
	], [
timo@4517
  1959
		AC_MSG_RESULT(no)
tss@6974
  1960
		if test $want_db = yes; then
tss@6974
  1961
		  AC_ERROR([Can't build with db support: libdb not found])
tss@6974
  1962
		fi
timo@4517
  1963
	])
timo@4517
  1964
	LIBS=$old_LIBS
timo@4517
  1965
fi
timo@4517
  1966
tss@6974
  1967
if test $want_pgsql != no; then
tss@9231
  1968
  AC_CHECK_PROG(PG_CONFIG, pg_config, YES, NO)
tss@9231
  1969
  if test $PG_CONFIG = NO; then
tss@9240
  1970
    # based on code from PHP
tss@9240
  1971
    for i in /usr /usr/local /usr/local/pgsql; do
tss@9240
  1972
      for j in include include/pgsql include/postgres include/postgresql ""; do
tss@9240
  1973
	if test -r "$i/$j/libpq-fe.h"; then
tss@9240
  1974
	  PGSQL_INCLUDE=$i/$j
tss@9240
  1975
	fi
tss@9240
  1976
      done
tss@9240
  1977
      for lib in lib lib64; do
tss@9240
  1978
	for j in $lib $lib/pgsql $lib/postgres $lib/postgresql ""; do
tss@9240
  1979
	  if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
tss@9240
  1980
	    PGSQL_LIBDIR=$i/$j
tss@9231
  1981
	  fi
tss@9240
  1982
	done
tss@9240
  1983
      done
tss@9240
  1984
    done
tss@9231
  1985
  else
tss@9240
  1986
    PGSQL_INCLUDE="`pg_config --includedir`"
tss@9240
  1987
    PGSQL_LIBDIR="`pg_config --libdir`"  
tss@9240
  1988
  fi
tss@1283
  1989
tss@9240
  1990
  old_LIBS=$LIBS
tss@9240
  1991
  if test "$PGSQL_LIBDIR" != ""; then
tss@9240
  1992
    LIBS="$LIBS -L$PGSQL_LIBDIR"
tss@9240
  1993
  fi
tss@1283
  1994
tss@9240
  1995
  AC_CHECK_LIB(pq, PQconnectdb, [
tss@9240
  1996
	  AC_CHECK_LIB(pq, PQescapeStringConn, [
tss@9240
  1997
		  AC_DEFINE(HAVE_PQESCAPE_STRING_CONN,, Define if libpq has PQescapeStringConn function)
tss@9240
  1998
	  ])
tss@9240
  1999
	  old_CPPFLAGS=$CPPFLAGS
tss@9240
  2000
	  if test "$PGSQL_INCLUDE" != ""; then
tss@9240
  2001
		  CPPFLAGS="$CPPFLAGS -I $PGSQL_INCLUDE"
tss@9240
  2002
	  fi
tss@9240
  2003
	  AC_CHECK_HEADER(libpq-fe.h, [
tss@9240
  2004
		  if test "$PGSQL_INCLUDE" != ""; then
tss@9240
  2005
			  PGSQL_CFLAGS="$PGSQL_CFLAGS -I$PGSQL_INCLUDE"
tss@9240
  2006
		  fi
tss@9240
  2007
		  if test "$PGSQL_LIBDIR" != ""; then
tss@9240
  2008
			  PGSQL_LIBS="$PGSQL_LIBS -L$PGSQL_LIBDIR"
tss@9240
  2009
		  fi
tss@9240
  2010
		  PGSQL_LIBS="$PGSQL_LIBS -lpq"
tss@9240
  2011
		  AC_DEFINE(HAVE_PGSQL,, Build with PostgreSQL support)
tss@9240
  2012
		  found_sql_drivers="$found_sql_drivers pgsql"
tss@3943
  2013
tss@9240
  2014
		  if test "$all_sql_drivers" = "yes"; then
tss@9240
  2015
		    sql_drivers="$sql_drivers pgsql"
tss@6974
  2016
		  fi
tss@9240
  2017
	  ], [
tss@9240
  2018
	    if test $want_pgsql = yes; then
tss@9240
  2019
	      AC_ERROR([Can't build with PostgreSQL support: libpq-fe.h not found])
tss@9240
  2020
	    fi
tss@9240
  2021
	  ])
tss@9240
  2022
	  CPPFLAGS=$old_CPPFLAGS
tss@9240
  2023
  ], [
tss@9240
  2024
    if test $want_pgsql = yes; then
tss@9240
  2025
      AC_ERROR([Can't build with PostgreSQL support: libpq not found])
tss@9240
  2026
    fi
tss@9240
  2027
  ])
tss@9240
  2028
  LIBS=$old_LIBS
tss@1283
  2029
fi
tss@1283
  2030
tss@6974
  2031
if test $want_mysql != no; then
tss@2384
  2032
	# based on code from PHP
tss@2384
  2033
	for i in /usr /usr/local /usr/local/mysql; do
tss@2384
  2034
		for j in include include/mysql ""; do
tss@2384
  2035
			if test -r "$i/$j/mysql.h"; then
tss@2384
  2036
				MYSQL_INCLUDE=$i/$j
tss@2384
  2037
			fi
tss@2384
  2038
		done
tss@4142
  2039
		for j in lib lib/mysql lib64 lib64/mysql ""; do
tss@2384
  2040
			if test -f "$i/$j/libmysqlclient.so" || test -f "$i/$j/libmysqlclient.a"; then
tss@2384
  2041
				MYSQL_LIBDIR=$i/$j
tss@2384
  2042
			fi
tss@2384
  2043
		done
tss@2384
  2044
	done
tss@2384
  2045
tss@2384
  2046
	old_LIBS=$LIBS
tss@2384
  2047
	if test "$MYSQL_LIBDIR" != ""; then
tss@2384
  2048
		LIBS="$LIBS -L$MYSQL_LIBDIR"
tss@2384
  2049
	fi
tss@2384
  2050
tss@2416
  2051
	mysql_lib=""
tss@4159
  2052
	LIBS="$LIBS -lz -lm"
tss@1995
  2053
	AC_CHECK_LIB(mysqlclient, mysql_init, [
tss@2384
  2054
		old_CPPFLAGS=$CPPFLAGS
tss@2384
  2055
		if test "$MYSQL_INCLUDE" != ""; then
tss@2384
  2056
			CPPFLAGS="$CPPFLAGS -I $MYSQL_INCLUDE"
tss@2384
  2057
		fi
tss@2384
  2058
		AC_CHECK_HEADER(mysql.h, [
tss@2384
  2059
			if test "$MYSQL_INCLUDE" != ""; then
tss@6194
  2060
				MYSQL_CFLAGS="$MYSQL_CFLAGS -I$MYSQL_INCLUDE"
tss@2384
  2061
			fi
tss@2384
  2062
			if test "$MYSQL_LIBDIR" != ""; then
tss@6194
  2063
				MYSQL_LIBS="$MYSQL_LIBS -L$MYSQL_LIBDIR"
tss@2384
  2064
			fi
tss@6974
  2065
			MYSQL_LIBS="$MYSQL_LIBS -lmysqlclient -lz -lm"
tss@2384
  2066
tss@2384
  2067
			AC_CHECK_LIB(mysqlclient, mysql_ssl_set, [
tss@2384
  2068
				AC_DEFINE(HAVE_MYSQL_SSL,, Define if your MySQL library has SSL functions)
tss@2384
  2069
				if test "x$have_openssl" = "yes"; then
tss@2384
  2070
				  ssl_define="#define HAVE_OPENSSL"
tss@2384
  2071
				else
tss@2384
  2072
				  ssl_define=""
tss@2384
  2073
				fi
tss@2384
  2074
				AC_TRY_COMPILE([
tss@2384
  2075
				  $ssl_define
tss@2403
  2076
				  #include <mysql.h>
tss@2384
  2077
				], [
tss@2384
  2078
				  mysql_set_ssl(0, 0, 0, 0, 0, 0);
tss@2384
  2079
				], [
tss@2384
  2080
					AC_DEFINE(HAVE_MYSQL_SSL_CIPHER,, Define if your MySQL library supports setting cipher)
tss@2384
  2081
				])
tss@2384
  2082
			])
tss@2384
  2083
			
tss@2754
  2084
			AC_DEFINE(HAVE_MYSQL,, Build with MySQL support)
tss@3943
  2085
			found_sql_drivers="$found_sql_drivers mysql"
tss@6974
  2086
		], [
tss@6974
  2087
		  if test $want_mysql = yes; then
tss@6974
  2088
		    AC_ERROR([Can't build with MySQL support: mysql.h not found])
tss@6974
  2089
		  fi
tss@1995
  2090
		])
tss@2384
  2091
		CPPFLAGS=$old_CPPFLAGS
tss@6974
  2092
	], [
tss@6974
  2093
	  if test $want_mysql = yes; then
tss@6974
  2094
	    AC_ERROR([Can't build with MySQL support: libmysqlclient not found])
tss@6974
  2095
	  fi
tss@6974
  2096
	])
tss@1995
  2097
tss@2384
  2098
	LIBS=$old_LIBS
tss@1995
  2099
fi
tss@1995
  2100
tss@6974
  2101
if test $want_sqlite != no; then
tss@3919
  2102
	AC_CHECK_LIB(sqlite3, sqlite3_open, [
tss@3919
  2103
		AC_CHECK_HEADER(sqlite3.h, [
tss@6194
  2104
			SQLITE_LIBS="$SQLITE_LIBS -lsqlite3 -lz"
tss@3919
  2105
tss@3919
  2106
			AC_DEFINE(HAVE_SQLITE,, Build with SQLite3 support)
tss@3943
  2107
			found_sql_drivers="$found_sql_drivers sqlite"
tss@6974
  2108
		], [
tss@6974
  2109
		  if test $want_sqlite = yes; then
tss@6974
  2110
		    AC_ERROR([Can't build with SQLite support: sqlite3.h not found])
tss@6974
  2111
		  fi
tss@3919
  2112
		])
tss@6974
  2113
	], [
tss@6974
  2114
	  if test $want_sqlite = yes; then
tss@6974
  2115
	    AC_ERROR([Can't build with SQLite support: libsqlite3 not found])
tss@6974
  2116
	  fi
tss@4144
  2117
	])
tss@3919
  2118
fi
tss@6194
  2119
	
tss@6194
  2120
SQL_CFLAGS="$MYSQL_CFLAGS $PGSQL_CFLAGS $SQLITE_CFLAGS"
tss@8517
  2121
if test "$want_sql" != "plugin"; then
tss@6194
  2122
	SQL_LIBS="$MYSQL_LIBS $PGSQL_LIBS $SQLITE_LIBS"
tss@9064
  2123
else
tss@9064
  2124
	AC_DEFINE(SQL_DRIVER_PLUGINS,, Build SQL drivers as plugins)
tss@6194
  2125
fi
tss@3919
  2126
tss@8517
  2127
if test "$found_sql_drivers" != "" || test "$want_sql" != "no"; then
tss@3943
  2128
	if test "$all_sql_drivers" = "yes"; then
tss@3943
  2129
	  sql_drivers="$found_sql_drivers"
tss@3943
  2130
	fi
tss@3943
  2131
tss@2754
  2132
	AC_DEFINE(PASSDB_SQL,, Build with SQL support)
tss@2754
  2133
	AC_DEFINE(USERDB_SQL,, Build with SQL support)
tss@2754
  2134
	AUTH_LIBS="$AUTH_LIBS $SQL_LIBS"
timo@4012
  2135
	passdb="$passdb sql"
tss@3943
  2136
	userdb="$userdb sql"
tss@9164
  2137
else
tss@9164
  2138
	not_passdb="$not_passdb sql"
tss@9164
  2139
	not_userdb="$not_userdb sql"
tss@2754
  2140
fi
tss@2754
  2141
tss@9164
  2142
have_vpopmail=no
tss@6974
  2143
if test $want_vpopmail != no; then
tss@8828
  2144
	vpop_etc="$vpopmail_home/etc"
tss@8828
  2145
	AC_MSG_CHECKING([for vpopmail configuration at $vpop_etc/lib_deps])
tss@8828
  2146
	if ! test -f $vpop_etc/lib_deps; then
tss@8829
  2147
		AC_MSG_RESULT(not found)
tss@8828
  2148
		vpop_etc="$vpopmail_home"
tss@8828
  2149
		AC_MSG_CHECKING([for vpopmail configuration at $vpop_etc/lib_deps])
tss@8828
  2150
	fi
tss@8828
  2151
	if test -f $vpop_etc/lib_deps; then
tss@8828
  2152
		AUTH_CFLAGS="$AUTH_CFLAGS `cat $vpop_etc/inc_deps` $CFLAGS"
tss@8828
  2153
		AUTH_LIBS="$AUTH_LIBS `cat $vpop_etc/lib_deps`"
tss@1043
  2154
		AC_DEFINE(USERDB_VPOPMAIL,, Build with vpopmail support)
tss@1043
  2155
		AC_DEFINE(PASSDB_VPOPMAIL,, Build with vpopmail support)
tss@281
  2156
		AC_MSG_RESULT(found)
tss@9164
  2157
		have_vpopmail=yes
tss@280
  2158
	else
tss@281
  2159
		AC_MSG_RESULT(not found)
tss@6974
  2160
		if test $want_vpopmail = yes; then
tss@8828
  2161
		  AC_ERROR([Can't build with vpopmail support: $vpop_etc/lib_deps not found])
tss@6974
  2162
		fi
tss@280
  2163
	fi
tss@280
  2164
fi
tss@280
  2165
tss@9164
  2166
if test $have_vpopmail = no; then
tss@9164
  2167
  not_passdb="$not_passdb vpopmail"
tss@9164
  2168
  not_userdb="$not_userdb vpopmail"
tss@9164
  2169
else
tss@9164
  2170
  userdb="$userdb vpopmail"
tss@9164
  2171
  passdb="$passdb vpopmail"
tss@9164
  2172
fi
tss@9164
  2173
tss@5692
  2174
AC_CHECK_FUNC(crypt,, [
tss@5692
  2175
  AC_CHECK_LIB(crypt, crypt, [
tss@5692
  2176
    AUTH_LIBS="-lcrypt $AUTH_LIBS"
tss@5692
  2177
  ], [
tss@5692
  2178
    AC_MSG_ERROR([crypt() wasn't found])
tss@5692
  2179
  ])
tss@5346
  2180
])
tss@0
  2181
tss@1511
  2182
if test $have_modules = yes; then
tss@1465
  2183
  AC_DEFINE(HAVE_MODULES,, Define if you have dynamic module support)
tss@1465
  2184
  AC_SUBST(MODULE_LIBS)
tss@7826
  2185
tss@7826
  2186
  # shrext_cmds comes from libtool.m4
tss@7867
  2187
  module=yes eval MODULE_SUFFIX=$shrext_cmds
tss@7869
  2188
  if test "$MODULE_SUFFIX" = ""; then
tss@7869
  2189
    # too old libtool?
tss@7869
  2190
    MODULE_SUFFIX=.so
tss@7869
  2191
  fi
tss@7826
  2192
  AC_DEFINE_UNQUOTED(MODULE_SUFFIX,"$MODULE_SUFFIX",Dynamic module suffix)
tss@7826
  2193
  AC_SUBST(MODULE_SUFFIX)
tss@1511
  2194
fi
tss@1150
  2195
tss@6974
  2196
have_nss=no
tss@6974
  2197
if test $want_nss != no; then
tss@6974
  2198
  if test $have_modules != yes; then
tss@6974
  2199
    if test $want_nss = yes; then
tss@6974
  2200
      AC_ERROR([Can't build with NSS support: Dynamic modules not supported])
tss@6974
  2201
    fi
tss@6974
  2202
  else
tss@6974
  2203
    AC_TRY_COMPILE([
tss@6974
  2204
      #include <nss.h>
tss@6974
  2205
    ], [
tss@6974
  2206
      enum nss_status status = NSS_STATUS_TRYAGAIN;
tss@6974
  2207
    ], [
tss@6974
  2208
      AC_DEFINE(USERDB_NSS,, Build with NSS module support)
tss@6974
  2209
      have_nss=yes
tss@6974
  2210
    ], [
tss@6974
  2211
      if test $want_nss = yes; then
tss@6974
  2212
        AC_ERROR([Can't build with NSS support: nss.h not found or not usable])
tss@6974
  2213
      fi
tss@6974
  2214
    ])
tss@6974
  2215
  fi
tss@5870
  2216
fi
tss@5870
  2217
tss@9164
  2218
if test $have_nss = no; then
tss@9164
  2219
  not_userdb="$not_userdb nss"
tss@9164
  2220
else
tss@9164
  2221
  userdb="$userdb nss"
tss@9164
  2222
fi
tss@9164
  2223
tss@1283
  2224
AC_SUBST(AUTH_CFLAGS)
tss@1284
  2225
AC_SUBST(AUTH_LIBS)
tss@2754
  2226
AC_SUBST(SQL_CFLAGS)
tss@2754
  2227
AC_SUBST(SQL_LIBS)
tss@6194
  2228
AC_SUBST(MYSQL_CFLAGS)
tss@6194
  2229
AC_SUBST(MYSQL_LIBS)
tss@6194
  2230
AC_SUBST(PGSQL_CFLAGS)
tss@6194
  2231
AC_SUBST(PGSQL_LIBS)
tss@6194
  2232
AC_SUBST(SQLITE_CFLAGS)
tss@6194
  2233
AC_SUBST(SQLITE_LIBS)
tss@0
  2234
timo@4517
  2235
AC_SUBST(DICT_LIBS)
timo@4517
  2236
AC_SUBST(dict_drivers)
timo@4517
  2237
tss@0
  2238
dnl **
tss@8572
  2239
dnl ** Endianess
tss@0
  2240
dnl **
tss@0
  2241
tss@8572
  2242
dnl At least Apple's gcc supports __BIG_ENDIAN__ and __LITTLE_ENDIAN__
tss@8572
  2243
dnl defines. Use them if possible to allow cross-compiling.
tss@8572
  2244
AC_MSG_CHECKING([if __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined])
tss@8572
  2245
AC_TRY_COMPILE([
tss@8572
  2246
  #if !(__BIG_ENDIAN__ || __LITTLE_ENDIAN__)
tss@8572
  2247
  #error nope
tss@8572
  2248
  #endif
tss@8572
  2249
], [
tss@8572
  2250
], [
tss@8572
  2251
  AC_DEFINE(WORDS_BIGENDIAN, __BIG_ENDIAN__, Define if your CPU is big endian)
tss@8572
  2252
  AC_MSG_RESULT(yes)
tss@8572
  2253
], [
tss@8572
  2254
  AC_MSG_RESULT(no)
tss@8572
  2255
  AC_C_BIGENDIAN
tss@8572
  2256
])
tss@0
  2257
tss@0
  2258
dnl **
tss@0
  2259
dnl ** IPv6 support
tss@0
  2260
dnl **
tss@0
  2261
tss@6974
  2262
have_ipv6=no
tss@9163
  2263
AC_MSG_CHECKING([for IPv6])
tss@9163
  2264
AC_CACHE_VAL(i_cv_type_in6_addr,
tss@9163
  2265
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
tss@9163
  2266
#include <sys/types.h>
tss@9163
  2267
#include <sys/socket.h>
tss@9163
  2268
#include <netinet/in.h>
tss@9163
  2269
#include <netdb.h>
tss@9163
  2270
#include <arpa/inet.h>]],
tss@9163
  2271
[[struct in6_addr i;]])],
tss@9163
  2272
[i_cv_type_in6_addr=yes],
tss@9163
  2273
[i_cv_type_in6_addr=no])])
tss@9163
  2274
if test $i_cv_type_in6_addr = yes; then
tss@9163
  2275
	AC_DEFINE(HAVE_IPV6,, Build with IPv6 support)
tss@9163
  2276
	have_ipv6=yes
tss@0
  2277
fi
tss@9163
  2278
AC_MSG_RESULT($i_cv_type_in6_addr)
tss@0
  2279
tss@0
  2280
dnl **
tss@1404
  2281
dnl ** storage classes
tss@1404
  2282
dnl **
tss@1404
  2283
tss@3997
  2284
maildir_libs='$(top_builddir)/src/lib-storage/index/maildir/libstorage_maildir.a'
tss@3997
  2285
mbox_libs='$(top_builddir)/src/lib-storage/index/mbox/libstorage_mbox.a'
tss@3997
  2286
dbox_libs='$(top_builddir)/src/lib-storage/index/dbox/libstorage_dbox.a'
tss@5458
  2287
cydir_libs='$(top_builddir)/src/lib-storage/index/cydir/libstorage_cydir.a'
tss@6748
  2288
raw_libs='$(top_builddir)/src/lib-storage/index/raw/libstorage_raw.a'
tss@8173
  2289
shared_libs='$(top_builddir)/src/lib-storage/index/shared/libstorage_shared.a'
tss@8376
  2290
tss@8376
  2291
REGISTER_LIBS='$(top_builddir)/src/lib-storage/register/libstorage-register.a '\
tss@8376
  2292
'$(top_builddir)/src/lib-storage/list/libstorage_list.a'
tss@8376
  2293
tss@8376
  2294
CORE_LIBS='$(top_builddir)/src/lib-storage/index/libstorage_index.a '\
tss@8376
  2295
'$(top_builddir)/src/lib-storage/libstorage.a '\
tss@8376
  2296
'$(top_builddir)/src/lib-index/libindex.a '\
tss@8376
  2297
'$(top_builddir)/src/lib-imap/libimap.a '\
tss@8376
  2298
'$(top_builddir)/src/lib-mail/libmail.a '\
tss@8376
  2299
'$(top_builddir)/src/lib-auth/libauth.a '\
tss@8376
  2300
'$(top_builddir)/src/lib-charset/libcharset.a '\
tss@8376
  2301
'$(top_builddir)/src/lib/liblib.a'
tss@1404
  2302
tss@9162
  2303
mail_storages="$mail_storages raw"
tss@9172
  2304
# drop duplicates
tss@9172
  2305
mail_storages=`(for i in $mail_storages; do echo $i; done)|sort|uniq|xargs echo`
tss@8398
  2306
STORAGE_LIBS=
tss@1404
  2307
for storage in $mail_storages; do
tss@4567
  2308
  STORAGE_LIBS="$STORAGE_LIBS `eval echo \\$${storage}_libs`"
tss@1404
  2309
done
tss@8376
  2310
STORAGE_LIBS="$REGISTER_LIBS $STORAGE_LIBS $CORE_LIBS"
tss@1404
  2311
AC_SUBST(STORAGE_LIBS)
tss@6635
  2312
AC_DEFINE_UNQUOTED(MAIL_STORAGES, "$mail_storages", List of compiled in mail storages)
tss@1404
  2313
tss@1404
  2314
dnl **
tss@3943
  2315
dnl ** SQL drivers
tss@3943
  2316
dnl **
tss@3943
  2317
tss@6194
  2318
build_pgsql=no
tss@6194
  2319
build_mysql=no
tss@6194
  2320
build_sqlite=no
tss@3943
  2321
for driver in $sql_drivers; do
tss@3943
  2322
  if test "$driver" = "pgsql"; then
tss@3943
  2323
    AC_DEFINE(BUILD_PGSQL,, Built-in PostgreSQL support)
tss@6194
  2324
    build_pgsql=yes
tss@3943
  2325
  elif test "$driver" = "mysql"; then
tss@3943
  2326
    AC_DEFINE(BUILD_MYSQL,, Built-in MySQL support)
tss@6194
  2327
    build_mysql=yes
tss@3943
  2328
  elif test "$driver" = "sqlite"; then
tss@3943
  2329
    AC_DEFINE(BUILD_SQLITE,, Built-in SQLite support)
tss@6194
  2330
    build_sqlite=yes
tss@3943
  2331
  fi
tss@3943
  2332
done
tss@9164
  2333
if test $build_pgsql = no; then
tss@9164
  2334
  not_sql_drivers="$not_sql_drivers pgsql"
tss@9164
  2335
fi
tss@9164
  2336
if test $build_mysql = no; then
tss@9164
  2337
  not_sql_drivers="$not_sql_drivers mysql"
tss@9164
  2338
fi
tss@9164
  2339
if test $build_sqlite = no; then
tss@9164
  2340
  not_sql_drivers="$not_sql_drivers sqlite"
tss@9164
  2341
fi
tss@3943
  2342
tss@3943
  2343
AC_SUBST(sql_drivers)
tss@6194
  2344
AM_CONDITIONAL(BUILD_PGSQL, test "$build_pgsql" = "yes")
tss@6194
  2345
AM_CONDITIONAL(BUILD_MYSQL, test "$build_mysql" = "yes")
tss@6194
  2346
AM_CONDITIONAL(BUILD_SQLITE, test "$build_sqlite" = "yes")
tss@8517
  2347
AM_CONDITIONAL(SQL_PLUGINS, test "$want_sql" = "plugin")
tss@3943
  2348
tss@3943
  2349
dnl **
tss@3969
  2350
dnl ** Plugins
tss@3969
  2351
dnl **
tss@3969
  2352
tss@8090
  2353
if test "$want_zlib" != "no"; then
tss@8090
  2354
  AC_CHECK_HEADER(zlib.h, [
tss@8090
  2355
    have_zlib=yes
tss@8090
  2356
    have_zlib_plugin=yes
tss@8090
  2357
    AC_DEFINE(HAVE_ZLIB,, Define if you have zlib library)
tss@8090
  2358
  ], [
tss@8090
  2359
    if test "$want_zlib" = "yes"; then
tss@8090
  2360
      AC_ERROR([Can't build with zlib support: zlib.h not found])
tss@8090
  2361
    fi
tss@8090
  2362
  ])
tss@8090
  2363
fi
tss@3969
  2364
AM_CONDITIONAL(BUILD_ZLIB, test "$have_zlib" = "yes")
tss@3969
  2365
tss@8090
  2366
if test "$want_bzlib" != "no"; then
tss@8090
  2367
  AC_CHECK_HEADER(bzlib.h, [
tss@8090
  2368
    AC_CHECK_LIB(bz2, BZ2_bzdopen, [
tss@8090
  2369
      have_bzlib=yes
tss@8090
  2370
      have_zlib_plugin=yes
tss@8090
  2371
      AC_DEFINE(HAVE_BZLIB,, Define if you have bzlib library)
tss@8090
  2372
    ], [
tss@8090
  2373
      if test "$want_bzlib" = "yes"; then
tss@8090
  2374
	AC_ERROR([Can't build with bzlib support: libbz2 not found])
tss@8090
  2375
      fi
tss@8090
  2376
    ])
tss@8090
  2377
  ], [
tss@8090
  2378
    if test "$want_bzlib" = "yes"; then
tss@8090
  2379
      AC_ERROR([Can't build with bzlib support: bzlib.h not found])
tss@8090
  2380
    fi
tss@8046
  2381
  ])
tss@8090
  2382
fi
tss@7981
  2383
AM_CONDITIONAL(BUILD_BZLIB, test "$have_bzlib" = "yes")
tss@7981
  2384
AM_CONDITIONAL(BUILD_ZLIB_PLUGIN, test "$have_zlib_plugin" = "yes")
tss@7981
  2385
tss@6177
  2386
RPCGEN=${RPCGEN-rpcgen}
tss@6177
  2387
if ! $RPCGEN -c /dev/null > /dev/null; then
tss@6177
  2388
  RPCGEN=
tss@6177
  2389
fi
tss@6177
  2390
AC_SUBST(RPCGEN)
tss@6177
  2391
tss@6159
  2392
have_rquota=no
tss@6177
  2393
if test -f /usr/include/rpcsvc/rquota.x && test -n "$RPCGEN"; then
tss@6159
  2394
  AC_DEFINE(HAVE_RQUOTA,, Define if you wish to retrieve quota of NFS mounted mailboxes)
tss@6159
  2395
  have_rquota=yes
tss@6177
  2396
fi
tss@6159
  2397
AM_CONDITIONAL(HAVE_RQUOTA, test "$have_rquota" = "yes")
tss@6159
  2398
tss@7990
  2399
if test "$want_solr" != "no"; then
tss@7990
  2400
  AC_CHECK_PROG(CURLCONFIG, curl-config, YES, NO)
tss@7990
  2401
  if test $CURLCONFIG = YES; then
tss@7990
  2402
    CURL_CFLAGS=`curl-config --cflags`
tss@7990
  2403
    CURL_LIBS=`curl-config --libs`
tss@7990
  2404
    
tss@7990
  2405
    dnl libcurl found, also need libexpat
tss@7990
  2406
    AC_CHECK_LIB(expat, XML_Parse, [
tss@7990
  2407
      AC_CHECK_HEADER(expat.h, [
tss@7990
  2408
        AC_SUBST(CURL_CFLAGS)
tss@7990
  2409
        AC_SUBST(CURL_LIBS)
tss@7990
  2410
	have_solr=yes
tss@7990
  2411
      ], [
tss@7990
  2412
	if test $want_solr = yes; then
tss@7990
  2413
	  AC_ERROR([Can't build with Solr support: expat.h not found])
tss@7990
  2414
	fi
tss@7990
  2415
      ])
tss@7990
  2416
    ], [
tss@7990
  2417
      if test $want_solr = yes; then
tss@7990
  2418
	AC_ERROR([Can't build with Solr support: libexpat not found])
tss@7990
  2419
      fi
tss@7990
  2420
    ])
tss@7990
  2421
  else
tss@7990
  2422
    if test $want_solr = yes; then
tss@7990
  2423
      AC_ERROR([Can't build with Solr support: curl-config not found])
tss@7990
  2424
    fi
tss@7990
  2425
  fi
tss@7990
  2426
fi
tss@7990
  2427
AM_CONDITIONAL(BUILD_SOLR, test "$have_solr" = "yes")
tss@7990
  2428
tss@3969
  2429
dnl **
tss@0
  2430
dnl ** capabilities
tss@0
  2431
dnl **
tss@0
  2432
tss@7924
  2433
capability_banner="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE"
tss@8903
  2434
capability="$capability_banner SORT THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH"
tss@742
  2435
AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", IMAP capabilities)
tss@7922
  2436
AC_DEFINE_UNQUOTED(CAPABILITY_BANNER_STRING, "$capability_banner", IMAP capabilities advertised in banner) 
tss@0
  2437
tss@843
  2438
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
tss@843
  2439
tss@7297
  2440
if test "$docdir" = ""; then
tss@7297
  2441
  dnl docdir supported only by autoconf v2.59c and later
tss@7298
  2442
  docdir='${datadir}/doc/${PACKAGE_TARNAME}'
tss@7297
  2443
fi
tss@7297
  2444
AC_SUBST(docdir)
tss@7297
  2445
tss@3782
  2446
AC_CONFIG_HEADERS([config.h])
tss@2796
  2447
AC_CONFIG_FILES([
tss@0
  2448
Makefile
tss@0
  2449
doc/Makefile
tss@5441
  2450
doc/wiki/Makefile
tss@0
  2451
src/Makefile
tss@0
  2452
src/lib/Makefile
tss@2754
  2453
src/lib-sql/Makefile
tss@1702
  2454
src/lib-auth/Makefile
tss@568
  2455
src/lib-charset/Makefile
tss@3737
  2456
src/lib-dict/Makefile
tss@0
  2457
src/lib-imap/Makefile
tss@0
  2458
src/lib-index/Makefile
tss@0
  2459
src/lib-mail/Makefile
tss@2377
  2460
src/lib-ntlm/Makefile
tss@4798
  2461
src/lib-otp/Makefile
tss@1058
  2462
src/lib-settings/Makefile
tss@0
  2463
src/lib-storage/Makefile
tss@4808
  2464
src/lib-storage/list/Makefile
tss@0
  2465
src/lib-storage/index/Makefile
tss@0
  2466
src/lib-storage/index/maildir/Makefile
tss@0
  2467
src/lib-storage/index/mbox/Makefile
tss@3720
  2468
src/lib-storage/index/dbox/Makefile
tss@5458
  2469
src/lib-storage/index/cydir/Makefile
tss@6748
  2470
src/lib-storage/index/raw/Makefile
tss@8173
  2471
src/lib-storage/index/shared/Makefile
tss@761
  2472
src/lib-storage/register/Makefile
tss@0
  2473
src/auth/Makefile
tss@4349
  2474
src/deliver/Makefile
tss@3779
  2475
src/dict/Makefile
tss@0
  2476
src/imap/Makefile
tss@1049
  2477
src/imap-login/Makefile
tss@1049
  2478
src/login-common/Makefile
tss@0
  2479
src/master/Makefile
tss@1043
  2480
src/pop3/Makefile
tss@1049
  2481
src/pop3-login/Makefile
tss@6718
  2482
src/tests/Makefile
tss@1694
  2483
src/util/Makefile
tss@3738
  2484
src/plugins/Makefile
timo@4082
  2485
src/plugins/acl/Makefile
tss@8418
  2486
src/plugins/imap-acl/Makefile
tss@8295
  2487
src/plugins/autocreate/Makefile
tss@3972
  2488
src/plugins/convert/Makefile
timo@4523
  2489
src/plugins/expire/Makefile
tss@4609
  2490
src/plugins/fts/Makefile
tss@4621
  2491
src/plugins/fts-lucene/Makefile
tss@7990
  2492
src/plugins/fts-solr/Makefile
tss@4855
  2493
src/plugins/fts-squat/Makefile
timo@4913
  2494
src/plugins/lazy-expunge/Makefile
tss@8297
  2495
src/plugins/listescape/Makefile
tss@5034
  2496
src/plugins/mail-log/Makefile
tss@5633
  2497
src/plugins/mbox-snarf/Makefile
tss@3738
  2498
src/plugins/quota/Makefile
tss@3738
  2499
src/plugins/imap-quota/Makefile
tss@3738
  2500
src/plugins/trash/Makefile
tss@7663
  2501
src/plugins/virtual/Makefile
tss@3800
  2502
src/plugins/zlib/Makefile
tss@1418
  2503
stamp.h
tss@4343
  2504
dovecot-config.in])
tss@0
  2505
tss@2796
  2506
AC_OUTPUT
tss@1096
  2507
tss@8517
  2508
if test "$want_sql" = "plugin"; then
tss@6194
  2509
  sql_drivers="$sql_drivers (plugins)"
tss@6194
  2510
fi
tss@6194
  2511
tss@9164
  2512
not_passdb=`echo "$not_passdb"|sed 's/ / -/g'`
tss@9164
  2513
not_userdb=`echo "$not_userdb"|sed 's/ / -/g'`
tss@9164
  2514
not_sql_drivers=`echo "$not_sql_drivers"|sed 's/ / -/g'`
tss@9164
  2515
tss@0
  2516
echo
tss@9164
  2517
echo "Install prefix . : $prefix"
tss@9164
  2518
echo "File offsets ... : ${offt_bits}bit"
tss@9164
  2519
echo "I/O polling .... : $ioloop"
tss@9164
  2520
echo "I/O notifys .... : $have_notify"
tss@9164
  2521
echo "SSL ............ : $have_ssl"
tss@9164
  2522
echo "GSSAPI ......... : $have_gssapi"
tss@9164
  2523
echo "passdbs ........ :$passdb"
tss@9164
  2524
if test "$not_passdb" != ""; then
tss@9164
  2525
  echo "                 :$not_passdb"
tss@9164
  2526
fi
tss@9164
  2527
echo "userdbs ........ :$userdb"
tss@9164
  2528
if test "$not_userdb" != ""; then
tss@9164
  2529
  echo "                 :$not_userdb"
tss@9164
  2530
fi
tss@9164
  2531
echo "SQL drivers .... :$sql_drivers"
tss@9164
  2532
if test "$not_sql_drivers" != ""; then
tss@9164
  2533
  echo "                 :$not_sql_drivers"
tss@9164
  2534
fi