configure.in 56.8 KB
Newer Older
1
dnl $OpenLDAP$
Kurt Zeilenga's avatar
Kurt Zeilenga committed
2

3
dnl Copyright 1998,1999 The OpenLDAP Foundation.  All Rights Reserved.
Kurt Zeilenga's avatar
Kurt Zeilenga committed
4
5
6
7
8
dnl 
dnl Redistribution and use in source and binary forms are permitted only
dnl as authorized by the OpenLDAP Public License.  A copy of this
dnl license is available at http://www.OpenLDAP.org/license.html or
dnl in file LICENSE in the top-level directory of the distribution.
9

10
11
12
13
dnl Disable config.cache!
define([AC_CACHE_LOAD], )dnl
define([AC_CACHE_SAVE], )dnl

Kurt Zeilenga's avatar
Kurt Zeilenga committed
14
dnl Configure.in for OpenLDAP
15
AC_INIT(build/version)dnl
16
AC_CONFIG_AUX_DIR(build)dnl
17
18
19
20
21
22

OL_VERSION=`cat $ac_aux_dir/version`
if test -z "$OL_VERSION"; then
	AC_MSG_ERROR([could not determine version])
fi

23
24
25
26
27
dnl ----------------------------------------------------------------
dnl Determine host platform
dnl		we try not to use this for much
AC_CANONICAL_SYSTEM

28
AM_INIT_AUTOMAKE(OpenLDAP,[$OL_VERSION], [no defines])dnl
29
30
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
31
32
AC_DEFINE_UNQUOTED(OPENLDAP_PACKAGE,"$PACKAGE",Package)
AC_DEFINE_UNQUOTED(OPENLDAP_VERSION,"$VERSION",Version)
33

34
dnl We use autoconf features new to 2.13.
35
36
dnl aclocal.m4 should be built using aclocal from automake 1.4
dnl libtool 1.3.3 should be installed.
37
AC_PREREQ(2.13)dnl Required Autoconf version
38

39
AC_CONFIG_HEADER(include/portable.h include/ldap_features.h include/lber_types.h)dnl
40

41
dnl ----------------------------------------------------------------
Kurt Zeilenga's avatar
Kurt Zeilenga committed
42
43
44
45
dnl Start Args
AC_MSG_CHECKING(configure arguments)
AC_PREFIX_DEFAULT(/usr/local)

46
47
48
top_builddir=`pwd`
AC_SUBST(top_builddir)dnl

49
ldap_subdir="/openldap"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
50

51
52
53
54
55
56
57
58
AC_ARG_WITH(subdir,
[  --with-subdir=DIR change default subdirectory used for installs],
[case "$withval" in
	no) ldap_subdir=""
		;;
	yes)
		;;
	/*|\\*)
59
		ldap_subdir="$withval"
60
61
62
63
64
		;;
	*)
		ldap_subdir="/$withval"
		;;
esac
65
66
])dnl

67
68
AC_SUBST(ldap_subdir)dnl

69
OL_ARG_ENABLE(debug,[  --enable-debug 	enable debugging], yes)dnl
70
71
dnl ol_enable_syslog=no
OL_ARG_ENABLE(syslog,[  --enable-syslog	enable syslog support], auto)dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
72
OL_ARG_ENABLE(proctitle,[  --enable-proctitle	enable proctitle support], yes)dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
73
OL_ARG_ENABLE(cache,[  --enable-cache	enable caching], yes)dnl
74
OL_ARG_ENABLE(dns,[  --enable-dns		enable V2 DX Referrals extension], no)dnl
75
OL_ARG_ENABLE(referrals,[  --enable-referrals	enable V2 Referrals extension], yes)dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
76
OL_ARG_ENABLE(cldap,[  --enable-cldap	enable connectionless ldap], no)dnl
77
78
OL_ARG_ENABLE(x_compile,[  --enable-x-compile	enable cross compiling],
	no, [yes no])dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
79
80

dnl General "with" options
81
82
OL_ARG_ENABLE(dmalloc,[  --enable-dmalloc	enable debug malloc support], no)dnl

Kurt Zeilenga's avatar
Kurt Zeilenga committed
83
OL_ARG_WITH(cyrus_sasl,[  --with-cyrus-sasl	with Cyrus SASL support],
84
	auto, [auto yes no] )
Kurt Zeilenga's avatar
Kurt Zeilenga committed
85
OL_ARG_WITH(fetch,[  --with-fetch		with fetch URL support],
86
	auto, [auto yes no] )
87
OL_ARG_WITH(kerberos,[  --with-kerberos	with Kerberos support],
Kurt Zeilenga's avatar
Kurt Zeilenga committed
88
	auto, [auto k5 k4 afs yes no])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
89
OL_ARG_WITH(readline,[  --with-readline	with readline support],
90
	auto, [auto yes no] )
Kurt Zeilenga's avatar
Kurt Zeilenga committed
91
OL_ARG_WITH(threads,[  --with-threads	use threads],
92
	auto, [auto posix mach pth lwp yes no manual] )
Kurt Zeilenga's avatar
Kurt Zeilenga committed
93
OL_ARG_WITH(tls,[  --with-tls		with TLS/SSL support],
Bart Hartgers's avatar
   
Bart Hartgers committed
94
	auto, [auto ssleay openssl yes no] )
95
96
OL_ARG_WITH(yielding_select,[  --with-yielding-select	with implicitly yielding select],
	auto, [auto yes no manual] )
Kurt Zeilenga's avatar
Kurt Zeilenga committed
97
98
99
100

dnl Server options

dnl LDAPD OPTIONS
101
AC_ARG_WITH(xxldapdoptions,[LDAPD (X.500-to-LDAP Gateway) Options:])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
102
103
104
OL_ARG_ENABLE(ldapd,[  --enable-ldapd	enable building ldapd], no)dnl

dnl SLAPD OPTIONS
105
AC_ARG_WITH(xxslapdoptions,[SLAPD (Standalone LDAP Daemon) Options:])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
106
OL_ARG_ENABLE(slapd,[  --enable-slapd	enable building slapd], yes)dnl
107
OL_ARG_ENABLE(cleartext,[    --enable-cleartext	enable cleartext passwords], yes)dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
108
OL_ARG_ENABLE(crypt,[    --enable-crypt	enable crypt(3) passwords], auto)dnl
109
OL_ARG_ENABLE(modules,[    --enable-modules	enable dynamic module support], no)dnl
110
OL_ARG_ENABLE(multimaster,[    --enable-multimaster	enable multimaster replication], no)dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
111
OL_ARG_ENABLE(phonetic,[    --enable-phonetic	enable phonetic/soundex], no)dnl
112
OL_ARG_ENABLE(quipu,[    --enable-quipu	build quipu migration tools], no)dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
113
OL_ARG_ENABLE(rlookups,[    --enable-rlookups	enable reverse lookups], auto)dnl
114
115
OL_ARG_ENABLE(aci,[    --enable-aci	enable per-object ACIs], no)dnl
OL_ARG_ENABLE(discreteaci,[    --enable-discreteaci	enable discrete rights in ACIs], no)dnl
116
OL_ARG_ENABLE(wrappers,[    --enable-wrappers	enable tcp wrapper support], no)dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
117
118

dnl SLAPD Backend options
119
OL_ARG_ENABLE(bdb2,[    --enable-bdb2	enable bdb2 backend], no)dnl
120
121
OL_ARG_WITH(bdb2_module,[      --with-bdb2-module	module type], static,
	[static dynamic])
122
OL_ARG_ENABLE(ldap,[    --enable-ldap	enable ldap backend], no)dnl
123
124
OL_ARG_WITH(ldap_module,[      --with-ldap-module	module type], static,
	[static dynamic])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
125
126
OL_ARG_ENABLE(ldbm,[    --enable-ldbm	enable ldbm backend], yes)dnl
OL_ARG_WITH(ldbm_api,[      --with-ldbm-api	use LDBM API], auto,
127
	[auto db2 db mdbm gdbm ndbm manual])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
128
129
OL_ARG_WITH(ldbm_module,[      --with-ldbm-module	module type], static,
	[static dynamic])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
130
131
132
133
OL_ARG_WITH(ldbm_type,[      --with-ldbm-type	use LDBM type], auto,
	[auto btree hash])

OL_ARG_ENABLE(passwd,[    --enable-passwd	enable passwd backend], no)dnl
134
135
OL_ARG_WITH(passwd_module,[      --with-passwd-module	module type], static,
	[static dynamic])
136
OL_ARG_ENABLE(perl,[    --enable-perl	enable perl backend], no)dnl
137
138
OL_ARG_WITH(perl_module,[      --with-perl-module	module type], static,
	[static dynamic])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
139
OL_ARG_ENABLE(shell,[    --enable-shell	enable shell backend], no)dnl
140
141
OL_ARG_WITH(shell_module,[      --with-shell-module	module type], static,
	[static dynamic])
142
OL_ARG_ENABLE(tcl,[    --enable-tcl	enable tcl backend], no)dnl
143
144
OL_ARG_WITH(tcl_module,[      --with-tcl-module	module type], static,
	[static dynamic])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
145
146

dnl SLURPD OPTIONS
Kurt Zeilenga's avatar
Kurt Zeilenga committed
147
AC_ARG_WITH(xxslurpdoptions,[SLURPD (Replication Daemon) Options:])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
148
149
OL_ARG_ENABLE(slurpd,[  --enable-slurpd	enable building slurpd], auto)dnl

150
AC_ARG_WITH(xxliboptions,[Library Generation & Linking Options])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
151
152
153
AC_ENABLE_STATIC
dnl AC_DISABLE_SHARED
AC_ENABLE_SHARED
154
155

dnl General "enable" options
156
# validate options
157
158
159
160
161
162
163
if test $ol_enable_dns = yes ; then
	if test $ol_enable_referrals = no ; then
		AC_MSG_ERROR([DNS requires --enable-referrals])
	fi
	if test $ol_enable_referrals = auto ; then
		AC_MSG_WARN([DNS requires referrals, adding --enable-referrals])
		ol_enable_referrals=yes
164
165
166
	fi
fi

Kurt Zeilenga's avatar
Kurt Zeilenga committed
167
168
if test $ol_enable_slapd = no ; then
	dnl SLAPD was specificallly disabled
169
	if test $ol_enable_bdb2 = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
170
		AC_MSG_WARN([slapd disabled, ignoring --enable-bdb2 argument])
171
	fi
172
	if test $ol_enable_ldap = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
173
		AC_MSG_WARN([slapd disabled, ignoring --enable-ldap argument])
174
	fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
175
	if test $ol_enable_ldbm = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
176
		AC_MSG_WARN([slapd disabled, ignoring --enable-ldbm argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
177
178
	fi
	if test $ol_enable_passwd = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
179
		AC_MSG_WARN([slapd disabled, ignoring --enable-passwd argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
180
	fi
181
	if test $ol_enable_perl = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
182
		AC_MSG_WARN([slapd disabled, ignoring --enable-perl argument])
183
	fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
184
	if test $ol_enable_shell = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
185
		AC_MSG_WARN([slapd disabled, ignoring --enable-shell argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
186
	fi
187
	if test $ol_enable_tcl = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
188
		AC_MSG_WARN([slapd disabled, ignoring --enable-tcl argument])
189
	fi
190
	if test $ol_enable_modules = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
191
		AC_MSG_WARN([slapd disabled, ignoring --enable-modules argument])
192
	fi
193
194
195
	if test $ol_enable_multimaster = yes ; then
		AC_MSG_WARN([slapd disabled, ignoring --enable-multimaster argument])
	fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
196
	if test $ol_enable_wrappers = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
197
		AC_MSG_WARN([slapd disabled, ignoring --enable-wrappers argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
198
199
	fi
	if test $ol_enable_phonetic = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
200
		AC_MSG_WARN([slapd disabled, ignoring --enable-phonetic argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
201
	fi
202
203
204
	if test $ol_enable_quipu = yes ; then
		AC_MSG_WARN([slapd disabled, ignoring --enable-quipu argument])
	fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
205
	if test $ol_enable_rlookups = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
206
		AC_MSG_WARN([slapd disabled, ignoring --enable-rlookups argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
207
	fi
208
209
210
211
212
213
	if test $ol_enable_aci = yes ; then
		AC_MSG_WARN([slapd disabled, ignoring --enable-aci argument])
	fi
	if test $ol_enable_discreteaci = yes ; then
		AC_MSG_WARN([slapd disabled, ignoring --enable-discreteaci argument])
	fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
214
	if test $ol_with_ldbm_api != auto ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
215
		AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-api argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
216
217
	fi
	if test $ol_with_ldbm_type != auto ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
218
		AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-type argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
219
	fi
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
	if test $ol_with_bdb2_module != static ; then
		AC_MSG_WARN([slapd disabled, ignoring --with-bdb2-module argument])
	fi
	if test $ol_with_ldap_module != static ; then
		AC_MSG_WARN([slapd disabled, ignoring --with-ldap-module argument])
	fi
	if test $ol_with_ldbm_module != static ; then
		AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-module argument])
	fi
	if test $ol_with_passwd_module != static ; then
		AC_MSG_WARN([slapd disabled, ignoring --with-passwd-module argument])
	fi
	if test $ol_with_perl_module != static ; then
		AC_MSG_WARN([slapd disabled, ignoring --with-perl-module argument])
	fi
	if test $ol_with_shell_module != static ; then
		AC_MSG_WARN([slapd disabled, ignoring --with-shell-module argument])
	fi
	if test $ol_with_tcl_module != static ; then
		AC_MSG_WARN([slapd disabled, ignoring --with-tcl-module argument])
	fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
241
	if test $ol_enable_slurpd = yes ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
242
		AC_MSG_ERROR([slurpd requires slapd])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
243
244
245
	fi

	# force settings to no
246
	ol_enable_bdb2=no
247
	ol_enable_ldap=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
248
249
	ol_enable_ldbm=no
	ol_enable_passwd=no
250
251
	ol_enable_perl=no
	ol_enable_shell=no
252
	ol_enable_tcl=no
253
254

	ol_enable_modules=no
255
	ol_enable_multimaster=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
256
	ol_enable_phonetic=no
257
	ol_enable_quipu=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
258
	ol_enable_rlookups=no
259
260
	ol_enable_aci=no
	ol_enable_discreteaci=no
261
262
	ol_enable_wrappers=no

Kurt Zeilenga's avatar
Kurt Zeilenga committed
263
264
	ol_with_ldbm_api=no
	ol_with_ldbm_type=no
265

266
267
268
269
270
271
272
273
	ol_with_bdb2_module=static
	ol_with_ldap_module=static
	ol_with_ldbm_module=static
	ol_with_passwd_module=static
	ol_with_perl_module=static
	ol_with_shell_module=static
	ol_with_tcl_module=static

Kurt Zeilenga's avatar
Kurt Zeilenga committed
274
275
276
277
278
279
	ol_enable_slurpd=no

elif test $ol_enable_ldbm = no ; then
	dnl SLAPD without LDBM

	if test $ol_with_ldbm_api != auto ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
280
		AC_MSG_WARN([LDBM disabled, ignoring --with-ldbm-api argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
281
282
283
	fi

	if test $ol_with_ldbm_type != auto ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
284
		AC_MSG_WARN([LDBM disabled, ignoring --with-ldbm-type argument])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
285
286
	fi

287
288
289
290
	if test $ol_with_ldbm_module != static ; then
		AC_MSG_WARN([LDBM disabled, ignoring --with-ldbm-module argument])
	fi

291
	if test $ol_enable_bdb2 = yes ; then
292
293
294
		AC_MSG_ERROR([BDB2 requires --enable-ldbm])
	fi

295
	if test $ol_enable_modules != yes -a \
296
		$ol_enable_ldap = no -a \
297
		$ol_enable_passwd = no -a \
298
		$ol_enable_perl = no -a \
299
300
		$ol_enable_shell = no -a \
		$ol_enable_tcl = no ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
301
		AC_MSG_ERROR([slapd requires a backend])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
302
303
304
305
	fi

	ol_with_ldbm_api=no
	ol_with_ldbm_type=no
306
	ol_with_ldbm_module=static
Kurt Zeilenga's avatar
Kurt Zeilenga committed
307

308
309
310
311
312
313
314
315
316
317
elif test $ol_enable_bdb2 = yes ; then
	dnl SLAPD with BDB2

	if test $ol_with_ldbm_api != auto -a \
		$ol_with_ldbm_api != db2 ; then
		AC_MSG_ERROR([BDB2 requires LDBM API DB2])
	fi

	ol_with_ldbm_api=db2

Kurt Zeilenga's avatar
Kurt Zeilenga committed
318
319
320
else
	dnl SLAPD with LDBM

321
322
323
324
325
326
327
328
	if test $ol_enable_bdb2 != no ; then
		if test $ol_with_ldbm_api != auto -a \
			$ol_with_ldbm_api != db2 ; then
			AC_MSG_WARN([BDB2 requires LDBM api db2 or auto])
			ol_enable_bdb2=no
		fi
	fi

Kurt Zeilenga's avatar
Kurt Zeilenga committed
329
330
	if test $ol_with_ldbm_api = gdbm -a \
		$ol_with_ldbm_type = btree ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
331
		AC_MSG_ERROR([GDBM only supports LDBM type hash])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
332
	fi
Juan Gomez's avatar
Juan Gomez committed
333
334
335
336
	if test $ol_with_ldbm_api = mdbm -a \
		$ol_with_ldbm_type = btree ; then
		AC_MSG_ERROR([MDBM only supports LDBM type hash])
	fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
337
338
	if test $ol_with_ldbm_api = ndbm -a \
		$ol_with_ldbm_type = btree ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
339
		AC_MSG_ERROR([NDBM only supports LDBM type hash])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
340
341
342
343
344
345
	fi
fi

if test $ol_enable_slurpd = yes ; then
	dnl SLURPD was specifically enabled
	if test $ol_with_threads = no ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
346
		AC_MSG_ERROR([slurpd requires threads])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
347
348
349
350
351
352
353
	fi
fi

AC_MSG_RESULT(done)

## Initialize vars
LDAP_LIBS=
354
LDIF_LIBS=
Kurt Zeilenga's avatar
Kurt Zeilenga committed
355
356
357
358
359
360
361
362
363
364
365
366
LDBM_LIBS=
LTHREAD_LIBS=
LUTIL_LIBS=

LDAPD_LIBS=
SLAPD_LIBS=
SLURPD_LIBS=

BUILD_LDAPD=no
BUILD_SLAPD=no
BUILD_SLURPD=no

367
BUILD_BDB2=no
368
BUILD_LDAP=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
369
370
BUILD_LDBM=no
BUILD_PASSWD=no
371
BUILD_PERL=no
372
BUILD_QUIPU=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
373
BUILD_SHELL=no
374
BUILD_TCL=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
375
BUILD_THREAD=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
376

Howard Chu's avatar
Howard Chu committed
377
378
379
380
381
382
383
BUILD_BDB2_DYNAMIC=static
BUILD_LDAP_DYNAMIC=static
BUILD_LDBM_DYNAMIC=static
BUILD_PASSWD_DYNAMIC=static
BUILD_PERL_DYNAMIC=static
BUILD_SHELL_DYNAMIC=static
BUILD_TCL_DYNAMIC=static
384

385
386
SLAPD_MODULES_LDFLAGS=
SLAPD_MODULES_CPPFLAGS=
387
SLAPD_MODULES_LIST=
388

389
390
391
SLAPD_PERL_LDFLAGS=
SLAPD_PERL_CPPFLAGS=

Kurt Zeilenga's avatar
Kurt Zeilenga committed
392
KRB_LIBS=
393
READLINE_LIBS=
394
SASL_LIBS=
Kurt Zeilenga's avatar
Kurt Zeilenga committed
395
TERMCAP_LIBS=
Bart Hartgers's avatar
   
Bart Hartgers committed
396
TLS_LIBS=
397
MODULES_LIBS=
Kurt Zeilenga's avatar
Kurt Zeilenga committed
398
399
400
401

dnl ----------------------------------------------------------------
dnl Checks for programs

402
dnl AC_PROG_INSTALL
403

404
405
406
407
408
409
AC_DEFINE(HAVE_MKVERSION, 1, [define this if you have mkversion])

dnl
dnl Determine which C translator to use
dnl

410
dnl AIX Thread requires we use cc_r or xlc_r.
Kurt Zeilenga's avatar
Kurt Zeilenga committed
411
412
dnl But only do this IF AIX and CC is not set
dnl and threads are auto|yes|posix.
413
dnl
414
dnl If we find cc_r|xlc_r, force pthreads and assume
415
416
dnl		pthread_create is in $LIBS (ie: don't bring in
dnl		any additional thread libraries)
417
dnl If we do not find cc_r|xlc_r, disable threads
418
419

ol_aix_threads=no
420
case "$target" in
Kurt Zeilenga's avatar
Kurt Zeilenga committed
421
*-*-aix*) dnl all AIX is not a good idea.
422
	if test -z "$CC" ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
423
		case "$ol_with_threads" in
424
		auto | yes |  posix) ol_aix_threads=yes ;;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
425
426
427
428
		esac
	fi
;;
esac
429

430
431
432
433
434
435
436
437
438
439
440
441
442
443
if test $ol_aix_threads = yes ; then
	if test -z "${CC}" ; then
		AC_CHECK_PROGS(CC,cc_r xlc_r cc)

		if test "$CC" = cc ; then
			dnl no CC! don't allow --with-threads
			if test $ol_with_threads != auto ; then
				AC_MSG_ERROR([--with-threads requires cc_r (or other suitable compiler) on AIX])
			else
				AC_MSG_WARN([disabling threads, no cc_r on AIX])
			fi
			ol_with_threads=no
  		fi
	fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
444

445
	if test "${CC}" = "cc_r" -o "${CC}" = "xlc_r" ; then
446
447
448
449
450
		ol_with_threads=posix
		ol_cv_pthread_create=yes
	fi
fi

Kurt Zeilenga's avatar
Kurt Zeilenga committed
451
452
453
454
455
456
457
458
if test -z "${CC}"; then
	AC_CHECK_PROGS(CC,cc)
fi

dnl The default CFLAGS is empty NOT whatever AC_PROG_CC sets.
dnl (for now, let autoconf sort this out)
dnl CFLAGS=${CFLAGS-""}

459
AC_LIBTOOL_DLOPEN
Kurt Zeilenga's avatar
Kurt Zeilenga committed
460
AC_PROG_LIBTOOL
461
dnl AC_PROG_MAKE_SET
Kurt Zeilenga's avatar
Kurt Zeilenga committed
462

463
AC_PROG_AWK
464
OL_PROG_LN_H
465
466
AC_PROG_LN_S

467
468
469
470
if test "$LN_H" = "cp" -a "$LN_S" = "ln"; then
	LN_S="$LN_H"
fi

Kurt Zeilenga's avatar
Kurt Zeilenga committed
471
472
473
474
475
AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
	$PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:/etc)
AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi, $PATH:/usr/ucb)
AC_PATH_PROG(FINGER, finger, /usr/ucb/finger, $PATH:/usr/ucb)

476
477
ol_link_perl=no
if test $ol_enable_perl != no ; then
478
479
480
	AC_PATH_PROG(PERLBIN, perl, /usr/bin/perl)

	if test "no$PERLBIN" = "no" ; then
481
482
483
		if test $ol_enable_perl = yes ; then
			AC_MSG_ERROR([could not locate perl])
		fi
484

485
486
487
488
489
490
491
	else
		SLAPD_PERL_LDFLAGS="`$PERLBIN -MExtUtils::Embed -e ldopts|sed -e s/-lc//`"
		SLAPD_PERL_CPPFLAGS="`$PERLBIN -MExtUtils::Embed -e ccopts`"

		dnl should check perl version
		ol_link_perl=yes
	fi
492
493
fi

494
AC_PROG_CPP
495
496

if test $cross_compiling = yes -a $ol_enable_x_compile = yes; then
497
	AC_MSG_WARN([cross compiling....  some functionality will be removed.])
498
499

elif test $cross_compiling = no -a $ol_enable_x_compile = yes; then
500
501
	AC_MSG_WARN([programs compiled here do run here...])
	AC_MSG_ERROR([  if not cross compiling, use --disable-x-compile.])
502
503

elif test $cross_compiling = yes -a $ol_enable_x_compile = no; then
504
505
	AC_MSG_WARN([programs compiled here do not run here...])
	AC_MSG_ERROR([  if cross compiling,  add --enable-x-compile.])
506
507
fi

508
dnl Checks for UNIX Variants
Kurt Zeilenga's avatar
Kurt Zeilenga committed
509
510
511
512
AC_AIX
AC_ISC_POSIX
AC_MINIX

513
514
515
516
517
518
dnl Checks for system services
AC_CYGWIN
AC_MINGW32
AC_EXEEXT
AC_OBJEXT

519
520
AC_DEFINE_UNQUOTED( EXEEXT, "${EXEEXT}", [defined to be the EXE extension])

521
522
523
dnl BeOS requires -lbe -lroot -lnet
AC_CHECK_LIB(be, be_app, [LIBS="$LIBS -lbe -lroot -lnet"], :, [-lroot -lnet])

524
525
526
dnl OpenLDAP requires STDC features
AM_PROG_CC_STDC
if test "X${am_cv_prog_cc_stdc}" = "Xno" ; then
527
	AC_MSG_ERROR([OpenLDAP requires compiler to support STDC constructs.])
528
529
fi

530
dnl Check cc depend flags
Kurt Zeilenga's avatar
Kurt Zeilenga committed
531
532
533
534
535
OL_MKDEPEND
if test "${ol_cv_mkdep}" = no ; then
	# this will soon become an error
	AC_MSG_WARN([do not know how to generate dependencies])
fi
536

537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
dnl
dnl Check for module support
dnl
ol_link_modules=no
if test $ol_enable_modules != no ; then
	AC_CHECK_HEADERS(ltdl.h)

	if test $ac_cv_header_ltdl_h = no ; then
		AC_MSG_ERROR([could not locate libtool ltdl.h])

	fi

	AC_CHECK_LIB(ltdl, lt_dlinit)
	if test "$ac_cv_lib_ltdl_lt_dlinit" = no ; then
		AC_MSG_ERROR([could not locate libtool -lltdl])
	fi
	ol_link_modules=yes
else
	ol_with_bdb2_module=static
	ol_with_ldap_module=static
	ol_with_ldbm_module=static
	ol_with_passwd_module=static
	ol_with_perl_module=static
	ol_with_shell_module=static
	ol_with_tcl_module=static
fi

564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
dnl ----------------------------------------------------------------
dnl Checks for header files.
OL_HEADER_STDC

if test $ol_cv_header_stdc != yes; then
	AC_MSG_WARN([could not locate Standard C compliant headers])
fi

AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
if test $am_cv_sys_posix_termios = yes ; then
	AC_DEFINE(HAVE_POSIX_TERMIOS,1,
		[define if you have POSIX termios])
fi

AC_CHECK_HEADERS(	\
	arpa/inet.h		\
	arpa/nameser.h	\
	assert.h		\
	crypt.h			\
	errno.h			\
	fcntl.h			\
	filio.h			\
	getopt.h		\
	grp.h			\
	libutil.h		\
	limits.h		\
	locale.h		\
	netinet/tcp.h	\
	malloc.h		\
	memory.h		\
	psap.h			\
	pwd.h			\
	resolv.h		\
	sgtty.h			\
	shadow.h		\
	stddef.h		\
	string.h		\
	strings.h		\
	sysexits.h		\
	sys/file.h		\
	sys/filio.h		\
	sys/errno.h		\
	sys/ioctl.h		\
	sys/param.h		\
	sys/resource.h	\
	sys/select.h	\
	sys/socket.h	\
	sys/syslog.h	\
	sys/time.h		\
	sys/types.h		\
	syslog.h		\
	termios.h		\
	unistd.h		\
)

621
dnl ----------------------------------------------------------------
Kurt Zeilenga's avatar
Kurt Zeilenga committed
622
623
624
625
626
627
628
dnl Checks for libraries

dnl Find socket()
dnl Likely combinations:
dnl		-lsocket [ -lnsl_s | -lnsl ]
dnl		-linet

Kurt Zeilenga's avatar
Kurt Zeilenga committed
629
AC_CHECK_FUNC(socket, :, [	
Kurt Zeilenga's avatar
Kurt Zeilenga committed
630
631
632
dnl hopefully we won't include too many libraries
	AC_CHECK_LIB(socket, main)
	AC_CHECK_LIB(net, main)
633
	AC_CHECK_LIB(net, socket)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
634
635
636
637
638
639
	AC_CHECK_LIB(nsl_s, main)
	AC_CHECK_LIB(nsl, main)
	AC_CHECK_LIB(inet, socket)
	AC_CHECK_LIB(gen, main)
])

Kurt Zeilenga's avatar
Kurt Zeilenga committed
640
dnl require select
641
642
643
644
645
646
647
648
AC_CHECK_FUNC(select, :, AC_MSG_ERROR([select() required.]))

dnl Select arg types
dnl (if this detection becomes permenent, it and the select() detection
dnl should be done before the yielding select test) 
AC_FUNC_SELECT_ARGTYPES


Kurt Zeilenga's avatar
Kurt Zeilenga committed
649
dnl require POSIX regex
650
651
652
653
654
655
656
657
658
659
660
661
662
663
AC_CHECK_HEADERS( regex.h )
if test "$ac_cv_header_regex_h" != yes ; then
	AC_MSG_ERROR([POSIX regex.h required.])
fi
AC_CHECK_FUNC(regfree, :, AC_MSG_ERROR([POSIX regex required.]))

OL_POSIX_REGEX
if test "$ol_cv_c_posix_regex" = no ; then
	AC_MSG_ERROR([broken POSIX regex!])
fi

dnl HP-UX requires -lV3
AC_CHECK_LIB(V3, sigset)

664
665
666
667
668
669
dnl Check for resolver routines
AC_CHECK_FUNC(res_search,:)
if test $ac_cv_func_res_search = no ; then 
	AC_CHECK_LIB(bind, res_search)
	ac_cv_func_res_search=$ac_cv_lib_bind_res_search
fi
670

671
672
673
674
if test $ac_cv_func_res_search = no ; then 
	AC_CHECK_LIB(bind, __res_search)
	ac_cv_func_res_search=$ac_cv_lib_bind___res_search
fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
675

676
677
678
679
680
681
682
683
684
685
686
687
if test $ac_cv_func_res_search = no ; then 
	AC_CHECK_LIB(resolv, res_search)
	ac_cv_func_res_search=$ac_cv_lib_resolv_res_search
fi

if test "$ac_cv_func_res_search" = yes ; then
	AC_DEFINE(HAVE_RES_SEARCH,1,
		[define if you have res_search()])
elif test $ol_enable_dns = yes ; then
	AC_MSG_ERROR([--enable-dns requires res_search])
elif test $ol_enable_dns != no ; then
	AC_MSG_WARN([no res_search, disabling DNS support])
688
fi
689

Kurt Zeilenga's avatar
Kurt Zeilenga committed
690

691
692
# ISODE tests
ol_link_isode=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
693
if test $ol_enable_ldapd != no ; then
694
	AC_MSG_WARN([ldapd is not supported and may suffer from bit rot.])
695

Kurt Zeilenga's avatar
Kurt Zeilenga committed
696
	dnl look for ISODE libraries
697
698
	AC_CHECK_LIB(xtpp, main, [
		ol_link_isode=yes
699
		AC_DEFINE(HAVE_XTPP,1, [define if you have -lxttp])
700
701
		LDAPD_LIBS="$LDAPD_LIBS -lxtpp -lxtdsap -lxtisode -losi"
		],:,[-lxtdsap -lxtisode -losi])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
702
	AC_CHECK_LIB(dsap, main, [
703
		ol_link_isode=yes
704
		AC_DEFINE(HAVE_DSAP,1, [define if you have -ldsap])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
705
		LDAPD_LIBS="$LDAPD_LIBS -ldsap"
706
		],:,[-lisode])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
707
	AC_CHECK_LIB(isode, main, [
708
		ol_link_isode=yes
709
		AC_DEFINE(HAVE_ISODE,1, [define if you have -lisode])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
710
711
712
713
		LDAPD_LIBS="$LDAPD_LIBS -lisode"
		],:)
fi

714
715
if test $ol_link_isode != no; then
	AC_CHECK_LIB(pp, main, [
716
		AC_DEFINE(HAVE_PP,1, [define if you have -lpp])
717
718
719
720
721
		LDAPD_LIBS="-lpp $LDAPD_LIBS"
		],:)

	AC_PATH_PROG(PEPSY, pepsy)
fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
722

723
724
725
726
727
728
729
730
731
732
733
734
if test $ol_enable_quipu != no ; then
	AC_CHECK_HEADERS(quipu/commonarg.h)

	if test $ac_cv_header_quipu_commonarg_h = yes ; then
		BUILD_QUIPU=yes
	elif test $ol_enable_quipu = auto ; then
		AC_MSG_WARN([no quipu for --enable-quipu=auto, disabling])
	else
		AC_MSG_ERROR(no quipu for --enable-quipu=$ol_enable_quipu)
	fi
fi

Kurt Zeilenga's avatar
Kurt Zeilenga committed
735
736
737
738
739
dnl
dnl check for kerberos
dnl
ol_link_kerberos=no

Kurt Zeilenga's avatar
Kurt Zeilenga committed
740
741
742
743
744
745
746
747
748
749
750
751
if test $ol_with_kerberos = auto -o $ol_with_kerberos = k5 ; then
	AC_CHECK_HEADERS(kerberosIV/krb.h kerberosIV/des.h)

	if test $ac_cv_header_kerberosIV_krb_h = yes ; then
		AC_CHECK_LIB(krb4, main, [have_k5=yes], [have_k5=no],
			[-lkrb5 -ldes425])

		if test $have_k5 = yes ; then
			ol_with_kerberos=found
			ol_link_kerberos=yes

			KRB_LIBS="-lkrb4 -lkrb5 -ldes425"
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770

			LIBS="$KRB_LIBS $LIBS"

			AC_CACHE_CHECK([for des_debug in Kerberos libraries],
				[ol_cv_var_des_debug], [
				dnl save the flags
				save_LIBS="$LIBS"
				LIBS="$KRB_LIBS $LIBS"
				AC_TRY_LINK([
#include <kerberosIV/krb.h>
#include <kerberosIV/des.h>
extern int des_debug;
],[
des_debug = 1;
],				ol_cv_var_des_debug=yes, ol_cv_var_des_debug=no)
				dnl restore the LIBS
				LIBS="$save_LIBS"
			])

Kurt Zeilenga's avatar
Kurt Zeilenga committed
771
			if test $ol_cv_var_des_debug = yes ; then
772
773
774
775
776
				AC_DEFINE(HAVE_DES_DEBUG,1,
					[define if you have Kerberos des_debug])
			fi

			LIBS="$save_LIBS"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
777
778
779
		fi
	fi
fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
780

Kurt Zeilenga's avatar
Kurt Zeilenga committed
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
if test $ol_with_kerberos = auto -o $ol_with_kerberos = k4 ; then
	AC_CHECK_HEADERS(krb.h des.h)

	if test $ac_cv_header_krb_h = yes ; then
		AC_CHECK_LIB(krb, main, [have_k4=yes], [have_k4=no], [-ldes])

		if test $have_k4 = yes ; then
			ol_with_kerberos=found
			ol_link_kerberos=yes

			KRB_LIBS="-lkrb -ldes"
		fi
	fi
fi

796
797
798
if test $ol_link_kerberos = yes ; then
	AC_DEFINE(HAVE_KERBEROS, 1, [define if you have Kerberos])
fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
799

Bart Hartgers's avatar
   
Bart Hartgers committed
800
801
802
803
dnl
dnl Check for SSL/TLS
dnl
ol_link_tls=no
804
if test $ol_with_tls != no ; then
Bart Hartgers's avatar
   
Bart Hartgers committed
805
	
806
	AC_CHECK_HEADERS(openssl/ssl.h ssl.h)
Bart Hartgers's avatar
   
Bart Hartgers committed
807
	
808
	if test $ac_cv_header_openssl_ssl_h = yes -o $ac_cv_header_ssl_h = yes ; then
809
810
811
812
813
		AC_CHECK_LIB(ssl, SSLeay_add_ssl_algorithms, 
			[have_ssleay=yes
			need_rsaref=no],
			[have_ssleay=no],
			[-lcrypto])
Bart Hartgers's avatar
   
Bart Hartgers committed
814
			
Julio Sánchez Fernández's avatar
   
Julio Sánchez Fernández committed
815
816
817
818
819
820
821
		if test $have_ssleay = no ; then
			AC_CHECK_LIB(ssl, SSL_library_init,
				[have_ssleay=yes
				need_rsaref=no], [have_ssleay=no],
				[-lcrypto])
		fi

822
		if test $have_ssleay = no ; then
823
824
825
826
			AC_CHECK_LIB(ssl, ssl3_accept, 
				[have_ssleay=yes
				need_rsaref=yes], [have_ssleay=no],
				[-lcrypto -lRSAglue -lrsaref])
827
828
		fi

Bart Hartgers's avatar
   
Bart Hartgers committed
829
830
831
832
		if test $have_ssleay = yes ; then
			ol_with_tls=found
			ol_link_tls=yes

833
834
			AC_DEFINE(HAVE_SSLEAY, 1, 
				[define if you have SSLeay or OpenSSL])
Bart Hartgers's avatar
   
Bart Hartgers committed
835

836
			if test $need_rsaref = yes; then
837
838
839
				AC_DEFINE(HAVE_RSAREF, 1, 
					[define if you have RSAref])

840
841
842
843
				TLS_LIBS="-lssl -lcrypto -lRSAglue -lrsaref"
			else
				TLS_LIBS="-lssl -lcrypto"
			fi
Bart Hartgers's avatar
   
Bart Hartgers committed
844
845
846
847
848
		fi
	fi
fi

if test $ol_link_tls = yes ; then
849
	AC_DEFINE(HAVE_TLS, 1, [define if you have TLS])
Bart Hartgers's avatar
   
Bart Hartgers committed
850
851
fi	

852
853
854
855
dnl Tests for reentrant functions necessary to build a
dnl thread_safe -lldap.
AC_CHECK_FUNCS(		\
	ctime_r			\
856
	gethostbyname_r	gethostbyaddr_r \
857
858
)

859
860
861
if test "$ac_cv_func_ctime_r" = no ; then
	ol_cv_func_ctime_r_nargs=0
else
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
	OL_FUNC_CTIME_R_NARGS
dnl	OL_FUNC_CTIME_R_TYPE
fi

if test "$ac_cv_func_gethostbyname_r" = yes ; then
 	OL_FUNC_GETHOSTBYNAME_R_NARGS
else
 	ol_cv_func_gethostbyname_r_nargs=0
fi
 
if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
 	OL_FUNC_GETHOSTBYADDR_R_NARGS
else
 	ol_cv_func_gethostbyaddr_r_nargs=0
fi

if test "$ac_cv_func_ctime_r" = yes \
879
880
	-a "$ol_cv_func_ctime_r_nargs" -ge 2 \
	-a "$ol_cv_func_ctime_r_nargs" -le 3 \
881
	-a "$ac_cv_func_gethostbyname_r" = yes \
882
883
884
885
886
887
888
889
	-a "$ol_cv_func_gethostbyname_r_nargs" -ge 5 \
	-a "$ol_cv_func_gethostbyname_r_nargs" -le 6 \
 	-a "$ac_cv_func_gethostbyaddr_r" = yes \
 	-a "$ol_cv_func_gethostbyaddr_r_nargs" -ge 5 \
	-a "$ol_cv_func_gethostbyaddr_r_nargs" -le 6 \
 	; then
 
 	AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT,1)
890
891
fi

Kurt Zeilenga's avatar
Kurt Zeilenga committed
892
ol_link_threads=no
Kurt Zeilenga's avatar
Kurt Zeilenga committed
893
894
895
if test $ol_with_threads = auto -o $ol_with_threads = yes \
	-o $ol_with_threads = posix ; then

896
	AC_CHECK_HEADERS(pthread.h)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
897
898
899
900
901

	if test $ac_cv_header_pthread_h = yes ; then
		OL_POSIX_THREAD_VERSION

		if test $ol_cv_pthread_version = final ; then
902
903
			AC_DEFINE(HAVE_PTHREADS_FINAL,1,
				[define if pthreads API compatible with final spec])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
904
		elif test $ol_cv_pthread_version = draft4 ; then
905
906
			AC_DEFINE(HAVE_PTHREADS_D4,1,
				[define if pthreads API compatible with draft4 spec])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
907
908
909
910
911
912
913
		else
			AC_MSG_ERROR([unknown pthread version])
		fi

		# consider threads found
		ol_with_threads=found

914
		OL_HEADER_LINUX_THREADS
915
916
917
918
919
		OL_HEADER_GNU_PTH_PTHREAD_H

		if test $ol_cv_header_gnu_pth_pthread_h = no ; then
			AC_CHECK_HEADERS(sched.h)
		fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
920

921
922
923
924
		dnl Now the hard part, how to link?
		dnl
		dnl currently supported checks:
		dnl
Kurt Zeilenga's avatar
Kurt Zeilenga committed
925
926
		dnl Check for no flags 
		dnl 	pthread_create() in $LIBS
927
928
		dnl
		dnl Check special pthread (final) flags
929
		dnl 	[skipped] pthread_create() with -mt (Solaris) [disabled]
Kurt Zeilenga's avatar
Kurt Zeilenga committed
930
		dnl 	pthread_create() with -kthread (FreeBSD)
931
932
		dnl 	pthread_create() with -pthread (FreeBSD/Digital Unix)
		dnl 	pthread_create() with -pthreads (?)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
933
		dnl 	pthread_create() with -mthreads (AIX)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
934
		dnl 	pthread_create() with -thread (?)
935
936
		dnl
		dnl Check pthread (final) libraries
Kurt Zeilenga's avatar
Kurt Zeilenga committed
937
938
		dnl 	pthread_mutex_unlock() in -lpthread -lmach -lexc -lc_r (OSF/1)
		dnl 	pthread_mutex_lock() in -lpthread -lmach -lexc (OSF/1)
939
		dnl 	[skipped] pthread_mutex_trylock() in -lpthread -lexc (OSF/1)
940
		dnl 	pthread_join() -Wl,-woff,85 -lpthread (IRIX)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
941
942
		dnl 	pthread_create() in -lpthread (many)
		dnl 	pthread_create() in -lc_r (FreeBSD)
943
		dnl
944
		dnl Check pthread (draft4) flags (depreciated)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
945
		dnl 	pthread_create() with -threads (OSF/1)
946
		dnl
947
		dnl Check pthread (draft4) libraries (depreciated)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
948
949
950
		dnl 	pthread_mutex_unlock() in -lpthreads -lmach -lexc -lc_r (OSF/1)
		dnl 	pthread_mutex_lock() in -lpthreads -lmach -lexc (OSF/1)
		dnl 	pthread_mutex_trylock() in -lpthreads -lexc (OSF/1)
951
		dnl 	pthread_create() in -lpthreads (many)
952
953
954
		dnl

		dnl pthread_create in $LIBS
955
956
		AC_CACHE_CHECK([for pthread_create in default libraries],
			ol_cv_pthread_create,[
Kurt Zeilenga's avatar
Kurt Zeilenga committed
957
		AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
958
959
			[ol_cv_pthread_create=yes],
			[ol_cv_pthread_create=no],
Kurt Zeilenga's avatar
Kurt Zeilenga committed
960
961
962
			[AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
				[ol_cv_pthread_create=yes],
				[ol_cv_pthread_create=no])])])
963
964
965

		if test $ol_cv_pthread_create != no ; then
			ol_link_threads=posix
966
			ol_link_pthreads=""
967
		fi
968
		
969
dnl		OL_PTHREAD_TRY([-mt],		[ol_cv_pthread_mt])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
970
971
972
973
974
975
976
		OL_PTHREAD_TRY([-kthread],	[ol_cv_pthread_kthread])
		OL_PTHREAD_TRY([-pthread],	[ol_cv_pthread_pthread])
		OL_PTHREAD_TRY([-pthreads],	[ol_cv_pthread_pthreads])
		OL_PTHREAD_TRY([-mthreads],	[ol_cv_pthread_mthreads])
		OL_PTHREAD_TRY([-thread],	[ol_cv_pthread_thread])

		OL_PTHREAD_TRY([-lpthread -lmach -lexc -lc_r],
977
			[ol_cv_pthread_lpthread_lmach_lexc_lc_r])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
978
		OL_PTHREAD_TRY([-lpthread -lmach -lexc],
979
			[ol_cv_pthread_lpthread_lmach_lexc])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
980
dnl		OL_PTHREAD_TRY([-lpthread -lexc],
981
dnl			[ol_cv_pthread_lpthread_lexc])
982

Kurt Zeilenga's avatar
Kurt Zeilenga committed
983
		OL_PTHREAD_TRY([-lpthread -Wl,-woff,85],
984
			[ol_cv_pthread_lib_lpthread_woff])
985

Kurt Zeilenga's avatar
Kurt Zeilenga committed
986
987
		OL_PTHREAD_TRY([-lpthread],	[ol_cv_pthread_lpthread])
		OL_PTHREAD_TRY([-lc_r],		[ol_cv_pthread_lc_r])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
988

Kurt Zeilenga's avatar
Kurt Zeilenga committed
989
		OL_PTHREAD_TRY([-threads],	[ol_cv_pthread_threads])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
990

Kurt Zeilenga's avatar
Kurt Zeilenga committed
991
		OL_PTHREAD_TRY([-lpthreads -lmach -lexc -lc_r],
992
			[ol_cv_pthread_lpthreads_lmach_lexc_lc_r])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
993
		OL_PTHREAD_TRY([-lpthreads -lmach -lexc],
994
			[ol_cv_pthread_lpthreads_lmach_lexc])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
995
		OL_PTHREAD_TRY([-lpthreads -lexc],
996
			[ol_cv_pthread_lpthreads_lexc])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
997

Kurt Zeilenga's avatar
Kurt Zeilenga committed
998
		OL_PTHREAD_TRY([-lpthreads],[ol_cv_pthread_lib_lpthreads])
999

Kurt Zeilenga's avatar
Kurt Zeilenga committed
1000
		if test $ol_link_threads != no ; then
1001
1002
			AC_DEFINE(HAVE_PTHREADS,1,
				[define if you have POSIX Threads])
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1003

1004
1005
			LTHREAD_LIBS="$LTHREAD_LIBS $ol_link_pthreads"

1006
			dnl save flags
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
			save_CPPFLAGS="$CPPFLAGS"
			save_LIBS="$LIBS"
			LIBS="$LTHREAD_LIBS $LIBS"

			dnl All POSIX Thread (final) implementations should have
			dnl sched_yield instead of pthread yield.
			dnl check for both
			AC_CHECK_FUNCS(sched_yield pthread_yield)

			if test $ac_cv_func_sched_yield = no -a \
				$ac_cv_func_pthread_yield = no ; then
1018
1019
1020
				dnl Digital UNIX has sched_yield() in -lrt
				AC_CHECK_LIB(rt, sched_yield,
					[LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
1021
1022
					AC_DEFINE(HAVE_SCHED_YIELD,1,
						[Define if you have the sched_yield function.])
1023
1024
1025
1026
1027
					ac_cv_func_sched_yield=yes],
					[ac_cv_func_sched_yield=no])
			fi
			if test $ac_cv_func_sched_yield = no -a \
				$ac_cv_func_pthread_yield = no ; then
1028
				dnl Solaris has sched_yield() stub in -lposix4
1029
1030
				dnl but we'll use thr_yield instead.
				AC_CHECK_FUNCS(thr_yield)
1031
1032
			fi
			if test $ac_cv_func_sched_yield = no -a \
1033
1034
				$ac_cv_func_pthread_yield = no -a \
				"$ac_cv_func_thr_yield" = no ; then
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1035
1036
1037
1038
				AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
			fi

			dnl Check functions for compatibility
1039
			AC_CHECK_FUNCS(pthread_kill)
1040

1041
1042
1043
1044
1045
			dnl Check for pthread_detach with <pthread.h> inclusion
			dnl as it's symbol may have been mangled.
			AC_CACHE_CHECK([for pthread_detach with <pthread.h>],
				[ol_cv_func_pthread_detach], [
				dnl save the flags
1046
1047
1048
1049
1050
1051
				AC_TRY_LINK([
#include <pthread.h>
#ifndef NULL
#define NULL (void*)0
#endif
],
1052
1053
1054
1055
1056
1057
					[pthread_detach(NULL);],
					[ol_cv_func_pthread_detach=yes],
					[ol_cv_func_pthread_detach=no])
			])

			if test $ol_cv_func_pthread_detach = no ; then
1058
1059
				AC_MSG_ERROR([could not locate pthread_detach()])
			fi
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1060

1061
1062
1063
			AC_DEFINE(HAVE_PTHREAD_DETACH,1,
				[define if you have pthread_detach function])

1064
1065
1066
			dnl Check for setconcurreny functions
			AC_CHECK_FUNCS(	\
				pthread_setconcurrency \
1067
				pthread_getconcurrency \
1068
				thr_setconcurrency \
1069
				thr_getconcurrency \
1070
1071
			)

1072
1073
1074
			OL_SYS_LINUX_THREADS
			OL_LINUX_THREADS

1075
1076
			if test $ol_cv_linux_threads = error; then
				AC_MSG_ERROR([LinuxThreads header/library mismatch]);
1077
1078
			fi

1079
1080
			AC_CACHE_CHECK([if pthread_create() works],
				ol_cv_pthread_create_works,[
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1081
			AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
1082
1083
1084
1085
1086
1087
				[ol_cv_pthread_create_works=yes],
				[ol_cv_pthread_create_works=no],
				[dnl assume yes
				ol_cv_pthread_create_works=yes])])

			if test $ol_cv_pthread_create_works = no ; then
1088
				AC_MSG_ERROR([pthread_create is not usable, check environment settings])
1089
1090
			fi

1091
1092
			dnl Check if select causes an yield
			if test $ol_with_yielding_select = auto ; then
1093
1094
				AC_CACHE_CHECK([if select yields when using pthreads],
					ol_cv_pthread_select_yields,[
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1095
1096
1097
1098
1099
1100
				AC_TRY_RUN([
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#ifndef NULL
1101
#define NULL (void*) 0
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1102
1103
#endif

1104
static int fildes[2];
1105

1106
1107
static void *task(p)
	void *p;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1108
{
1109
	int i;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1110
1111
	struct timeval tv;

1112
1113
1114
	fd_set rfds;

	tv.tv_sec=10;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1115
1116
	tv.tv_usec=0;

1117
1118
1119
	FD_ZERO(&rfds);
	FD_SET(fildes[0], &rfds);

1120
	/* we're not interested in any fds */
1121
	i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
1122
1123
1124

	if(i < 0) {
		perror("select");
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1125
		exit(10);
1126
	}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1127

Kurt Zeilenga's avatar
Kurt Zeilenga committed
1128
	exit(0); /* if we exit here, the select blocked the whole process */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1129
1130
}

1131
1132
1133
int main(argc, argv)
	int argc;
	char **argv;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1134
1135
{
	pthread_t t;
1136

1137
1138
1139
	/* create a pipe to select */
	if(pipe(&fildes[0])) {
		perror("select");
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1140
		exit(1);
1141
1142
	}

1143
1144
#ifdef HAVE_PTHREAD_SETCONCURRENCY
	(void) pthread_setconcurrency(2);
1145
1146
#else
#ifdef HAVE_THR_SETCONCURRENCY
1147
1148
	/* Set Solaris LWP concurrency to 2 */
	thr_setconcurrency(2);