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


AC_CONFIG_AUX_DIR(./helpers)
echo "Configuring APR library"
OS=`./config.guess`
OS=`./config.sub $OS`
echo "Platform: ${OS}"

dnl # Some initial steps for configuration.  We setup the default directory
dnl # and which files are to be configured.

# These added to allow default directories to be used...
DEFAULT_OSDIR="unix"
echo "(Default will be ${DEFAULT_OSDIR})"
MODULES="file_io network_io threadproc misc locks time mmap shmem dso i18n"

dnl Process this file with autoconf to produce a configure script.
AC_INIT(configure.in)
AC_CONFIG_HEADER(include/apr_private.h)

# Most platforms use a prefix of 'lib' on their library files.
LIBPREFIX='lib'

dnl # Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB_NC
AC_PROG_MAKE_SET
AC_CHECK_PROG(RM, rm, rm)
AC_CHECK_PROG(AR, ar, ar)

# This macro needs to be here in case we are on an AIX box.
AC_AIX

# Use /bin/sh if it exists, otherwise go looking for sh in the path
if test ".$SH" = . -a -f /bin/sh; then
  SH="/bin/sh"
fi
AC_CHECK_PROG(SH, sh, sh)

dnl #----------------------------- Checks for compiler flags
nl='
'
echo $ac_n "${nl}Check for compiler flags..."
AC_ARG_WITH(optim,[  --with-optim="FLAGS"      compiler optimisation flags],
        [OPTIM="$withval"])

AC_ARG_WITH(debug,[  --with-debug              Turn on debugging and compile tim
e warnings],
        [if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -g -Wall"; else CFLAGS="$CFLAGS -g"; fi])

dnl # this is the place to put specific options for platform/compiler
dnl # combinations
case "$OS:$CC" in
    *-hp-hpux*:cc ) CFLAGS="$CFLAGS -Ae +DAportable" ;;
    powerpc-*-beos:mwcc* )
        CPP="mwcc -E"
        CC="mwcc"
        AR="ar"
        ;;
esac

case "$OS" in
   *-os2*)
       CFLAGS="$CFLAGS -DOS2 -Zmt"
       OSDIR="os2"
       LIBPREFIX=""
       enable_apr_threads="system_threads"
       ;;
   *beos*)
       OSDIR="beos"
       CFLAGS="$CFLAGS -DBEOS"
       enable_apr_threads="system_threads"
       config_subdirs="shmem/unix/mm"
       ;;
   *)
       OSDIR="unix"
       config_subdirs="shmem/unix/mm"
       ;;
esac

if test ".$SYS_SW" = ".AIX"; then
    CFLAGS="$CFLAGS -U__STR__"
    case "$SYS_KV" in
        [12]*)
            AC_DEFINE(USEBCOPY)
            OSDIR="aix"
            ;;
        3*)
            AC_DEFINE(NEED_RLIM_T)
            OSDIR="aix"
            ;;
        41*)
            AC_DEFINE(NEED_RLIM_T)
            OSDIR="aix"
            ;;
        42*)
            OSDIR="aix"
            ;;
    esac
fi

dnl #----------------------------- Checks for Any required Libraries
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(nsl,gethostbyname)
AC_CHECK_LIB(nsl,gethostname)
AC_CHECK_LIB(socket,socket)
AC_CHECK_LIB(crypt,crypt)
AC_CHECK_LIB(ufc,crypt)
AC_CHECK_LIB(truerand,main)

dnl #----------------------------- Checks for Any required Functions
dnl Checks for library functions.
AC_CHECK_FUNCS(pthread_sigmask)
AC_CHECK_FUNCS(strcasecmp stricmp poll setsid)
AC_CHECK_FUNCS(sigaction, [ have_sigaction="1" ], [ have_sigaction="0" ]) 
AC_CHECK_FUNCS(writev)
AC_CHECK_FUNCS(sendfile, [ sendfile="1" ], [ sendfile="0" ])
AC_CHECK_FUNCS(fork, [ fork="1" ], [ fork="0" ])
AC_CHECK_FUNCS(getpass)
AC_CHECK_FUNC(inet_addr, [ inet_addr="1" ], [ inet_addr="0" ])
AC_CHECK_FUNC(inet_network, [ inet_network="1" ], [ inet_network="0" ])
AC_CHECK_FUNC(_getch)
AC_CHECK_FUNCS(gmtime_r localtime_r)
AC_CHECK_FUNCS(iconv, [ iconv="1" ], [ iconv="0" ])
AC_SUBST(sendfile)
AC_SUBST(fork)
AC_SUBST(inet_addr)
AC_SUBST(inet_network)
AC_SUBST(have_sigaction)
AC_SUBST(iconv)


dnl #----------------------------- Checks for Any required Headers
AC_HEADER_STDC

AC_CHECK_HEADERS(conio.h)
AC_CHECK_HEADERS(crypt.h)
AC_CHECK_HEADERS(ctype.h)
AC_CHECK_HEADERS(dir.h)
AC_CHECK_HEADERS(dirent.h, direnth="1", dirent="0")
AC_CHECK_HEADERS(errno.h, errnoh="1", errnoh="0")
AC_CHECK_HEADERS(net/errno.h)
AC_CHECK_HEADERS(fcntl.h, fcntlh="1", fcntl="0")
AC_CHECK_HEADERS(features.h)
AC_CHECK_HEADERS(grp.h)
AC_CHECK_HEADERS(io.h)
AC_CHECK_HEADERS(limits.h)
AC_CHECK_HEADERS(malloc.h)
AC_CHECK_HEADERS(math.h)
AC_CHECK_HEADERS(memory.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(osreldate.h)
AC_CHECK_HEADERS(process.h)
AC_CHECK_HEADERS(pwd.h)
AC_CHECK_HEADERS(sys/sem.h)
AC_CHECK_HEADERS(setjmp.h)
AC_CHECK_HEADERS(signal.h, signalh="1", signalh="0")
AC_CHECK_HEADERS(stdarg.h, stdargh="1", stdargh="0")
AC_CHECK_HEADERS(stddef.h)
AC_CHECK_HEADERS(stdio.h, stdioh="1", stdioh"0")
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_HEADERS(string.h)
AC_CHECK_HEADERS(sysapi.h)
AC_CHECK_HEADERS(sysgtime.h)
AC_CHECK_HEADERS(termios.h)
AC_CHECK_HEADERS(time.h)
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(sys/times.h)
AC_CHECK_HEADERS(tpfeq.h)
AC_CHECK_HEADERS(tpfio.h)
AC_CHECK_HEADERS(sys/uio.h, sys_uioh="1", sys_uioh="0")
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(poll.h)
AC_CHECK_HEADERS(unix.h)
AC_CHECK_HEADERS(arpa/inet.h)
AC_CHECK_HEADERS(netinet/in.h, netinet_inh="1", netinet_inh="0")
AC_CHECK_HEADERS(netinet/tcp.h)
AC_CHECK_HEADERS(iconv.h)

AC_CHECK_HEADERS(sys/file.h)
AC_CHECK_HEADERS(sys/ioctl.h)
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_HEADERS(sys/select.h)
AC_CHECK_HEADERS(sys/sendfile.h)
AC_CHECK_HEADERS(sys/signal.h)
AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(sys/stat.h)
AC_CHECK_HEADERS(sys/types.h, sys_typesh="1", sys_typesh="0")
AC_CHECK_HEADERS(sys/wait.h)
AC_CHECK_HEADERS(dlfcn.h)
AC_CHECK_HEADERS(dl.h)

AC_CHECK_HEADERS(kernel/OS.h)

AC_SUBST(errnoh)
AC_SUBST(direnth)
AC_SUBST(fcntlh)
AC_SUBST(netinet_inh)
AC_SUBST(stdargh)
AC_SUBST(stdioh)
AC_SUBST(sys_typesh)
AC_SUBST(sys_uioh)
AC_SUBST(signalh)
AC_SUBST(pthreadh)

dnl #----------------------------- Checks for standard typedefs
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPE(ssize_t, int)
AC_C_INLINE
AC_C_CONST
AC_TYPE_SIZE_T
AC_FUNC_SETPGRP

APR_CHECK_SOCKLEN_T

dnl # Checks for integer size
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long double, 12)
AC_CHECK_SIZEOF(long long, 8)

if test "$ac_cv_sizeof_short" = "2"; then
    short_value=short
fi
if test "$ac_cv_sizeof_int" = "4"; then
    int_value=int
fi
if test "$ac_cv_sizeof_long" = "8"; then
    long_value=long
fi
if test "$ac_cv_sizeof_long_double" = "8"; then
    long_value="long double"
fi
if test "$ac_cv_sizeof_long_long" = "8"; then
    long_value="long long"
fi
if test "$ac_cv_sizeof_longlong" = "8"; then
    long_value="__int64"
fi

if test "$ac_cv_type_off_t" = "yes"; then
    off_t_value="off_t"
else
    off_t_value="ap_int32_t"
fi
if test "$ac_cv_type_size_t" = "yes"; then
    size_t_value="size_t"
else
    size_t_value="ap_int32_t"
fi
if test "$ac_cv_type_ssize_t" = "yes"; then
    ssize_t_value="ssize_t"
else
    ssize_t_value="ap_int32_t"
fi

AC_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], ssize_t, 8)

if test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
    ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
    ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
else
    ssize_t_fmt='#error Can not determine the proper size for ssize_t'
fi

AC_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], off_t, 8)

if test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_int"; then
    off_t_fmt='#define APR_OFF_T_FMT "d"'
elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long"; then
    off_t_fmt='#define APR_OFF_T_FMT "ld"'
elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long_long"; then
    off_t_fmt='#define APR_OFF_T_FMT "qd"'
else
    off_t_fmt='#error Can not determine the proper size for off_t'
fi

AC_SUBST(short_value)
AC_SUBST(int_value)
AC_SUBST(long_value)
AC_SUBST(off_t_value)
AC_SUBST(size_t_value)
AC_SUBST(ssize_t_value)
AC_SUBST(ssize_t_fmt) 
AC_SUBST(off_t_fmt) 

dnl #----------------------------- Checking for Threads
echo $ac_n "${nl}Checking for Threads...${nl}"
AC_CACHE_CHECK([for threads], ac_cv_enable_threads,
  [ AC_ARG_ENABLE(threads,
    [  --enable-threads  Enable threading support in APR.],
    [ ac_cv_enable_threads=$enableval] ,
    [ AC_CHECK_HEADERS(pthread.h,
                   [ ac_cv_enable_threads="pthread" ] ,
                   [ ac_cv_enable_threads="no" ] ) ] ) ] )

if test "$ac_cv_enable_threads" = "no"; then
    threads="0"
    pthreadh="0"
else
    REENTRANCY_FLAGS
    if test "$ac_cv_enable_threads" = "pthread"; then
# We have specified pthreads for our threading library, just make sure
# that we have everything we need
      PTHREADS_CHECK
      AC_CHECK_HEADERS(pthread.h, [
          threads="1"
          pthreadh="1"
          AC_DEFINE(USE_THREADS) ], [
          threads="0"
          pthreadh="0" ] )
    elif test "$enable_apr_threads" = "system_threads"; then
          threads="1"
          pthreadh="0"
    else
# We basically specified that we wanted threads, but not how to implement
# them.  In this case, just look for pthreads.  In the future, we can check
# for other threading libraries as well.
      PTHREADS_CHECK
      AC_CHECK_HEADERS(pthread.h, [
          threads="1"
          pthreadh="1"
          AC_DEFINE(USE_THREADS) ], [
          threads="0"
          pthreadh="0" ] )
    fi
fi

ac_cv_define_READDIR_IS_THREAD_SAFE=no
AC_CHECK_LIB(c_r, readdir, AC_DEFINE(READDIR_IS_THREAD_SAFE))

if test "$threads" = "1"; then
    echo "APR will use threads"
else
    echo "APR will be non-threaded"
fi

AC_SUBST(threads)

dnl #----------------------------- Checking for MMAP 
echo $ac_n "${nl}Checking for MMAP...${nl}"
AC_FUNC_MMAP
if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
    mmap="1"
else
    mmap="0"
fi
AC_SUBST(mmap)

dnl #----------------------------- Checking for Locking Characteristics 
echo $ac_n "${nl}Checking for Locking..."

# It's stupid, but not all platforms have union semun, even those that need it.
AC_MSG_CHECKING(looking for union semun in sys/sem.h)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
],[
union semun arg;
semctl(0, 0, 0, arg);
], [have_union_semun="1" union_semun=yes ]
msg=yes, [
have_union_semun="0"
msg=no ] )
AC_MSG_RESULT([$msg])
AC_SUBST(have_union_semun)

dnl Checks for libraries.
AC_CHECK_DEFINE(LOCK_EX, sys/file.h)
AC_CHECK_DEFINE(F_SETLK, fcntl.h)

pthreadser="0"
if test "$threads" = "1"; then
    AC_CHECK_DEFINE(PTHREAD_PROCESS_SHARED, pthread.h)
    AC_CHECK_FUNC(pthread_mutex_init, [
        AC_DEFINE(USE_PTHREAD_SERIALIZE)
        pthreadser="1" ])
fi
AC_BEGIN_DECISION([lock implementation method])
AC_IFALLYES(custom:union_semun,
            AC_DECIDE(USE_SYSVSEM_SERIALIZE, [SysV IPC semget()]))
AC_IFALLYES(header:sys/file.h define:LOCK_EX,
            AC_DECIDE(USE_FLOCK_SERIALIZE, [4.2BSD-style flock()]))
AC_IFALLYES(header:fcntl.h define:F_SETLK,
            AC_DECIDE(USE_FCNTL_SERIALIZE, [SVR4-style fcntl()]))
AC_IFALLYES(header:pthread.h define:PTHREAD_PROCESS_SHARED dnl
            custom:with_pthread_cross,
            AC_DECIDE(USE_PROC_PTHREAD_SERIALIZE, [pthread mutex]))
dnl AC_DECISION_FORCE(USE_FCNTL_SERIALIZE)
AC_END_DECISION
AC_DEFINE_UNQUOTED($ac_decision)

flockser="0"
sysvser="0"
procpthreadser="0"
fcntlser="0"
case $ac_decision in
    USE_FLOCK_SERIALIZE )
        flockser="1"
        ;;
    USE_SYSVSEM_SERIALIZE )
        sysvser="1"
        ;;
    USE_FCNTL_SERIALIZE )
        fcntlser="1"
        ;;
    USE_PROC_PTHREAD_SERIALIZE )
        procpthreadser="1"
        ;;
esac

AC_SUBST(flockser)
AC_SUBST(sysvser)
AC_SUBST(fcntlser)
AC_SUBST(procpthreadser)
AC_SUBST(pthreadser)

dnl #----------------------------- Checking for Shared Memory Support 
echo $ac_n "${nl}Checking for Shared Memory Support...${nl}"

# run the MM config script regardless of whether we are going to use
# it or not.  When we have a much better idea of who is using MM, we can
# run this on a more conditional basis.
AC_CONFIG_SUBDIRS($config_subdirs)

AC_MSG_CHECKING(Checking for Shared memory support)
AC_ARG_ENABLE(shmem,
  [ --enable-shmem  Enable shared memory support in APR. ],
  [ ],
  ac_cv_enable_shmem="mm" )

sharedmem="0"
anonymous_shm="0"
filebased_shm="0"
keybased_shm="0"
if test "$ac_cv_enable_shmem" = "mm"; then
  sharedmem="1"
  anonymous_shm="1"
  AC_MSG_RESULT(anonymous)
elif test "$ac_cv_enable_shmem" = "file"; then
  sharedmem="1"
  filebased_shm="1"
  AC_MSG_RESULT(file based)
elif test "$ac_cv_enable_shmem" = "key"; then
  sharedmem="1"
  keybased_shm="1"
  AC_MSG_RESULT(key based)
else
  AC_MSG_RESULT(no)
fi
AC_SUBST(sharedmem)
AC_SUBST(anonymous_shm)
AC_SUBST(filebased_shm)
AC_SUBST(keybased_shm)
 
dnl #----------------------------- Checking for /dev/random 
AC_MSG_CHECKING(for /dev/random)

if test -r "/dev/random"; then
    AC_DEFINE(DEV_RANDOM, [/dev/random])
    AC_MSG_RESULT(/dev/random)
    rand="1"
elif test -f "/dev/urandom"; then
    AC_DEFINE(DEV_RANDOM, [/dev/urandom])
    AC_MSG_RESULT(/dev/urandom)
    rand="1"
else
    AC_MSG_RESULT(not found);
    if test "$ac_cv_lib_truerand_main" = "yes"; then
        rand="1"
    else
        rand="0"
    fi
fi

AC_SUBST(rand)
dnl #----------------------------- Checking for Time Support 
echo $ac_n "${nl}Checking for Time Support...${nl}"
AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])

if test "$ac_cv_struct_tm_gmtoff" = "yes"; then
    AC_DEFINE(HAVE_GMTOFF)
fi

dnl #----------------------------- Checking for Networking Support 
echo $ac_n "${nl}Checking for Networking support..."
AC_MSG_CHECKING(looking for in_addr in netinet/in.h)
AC_TRY_COMPILE([
#include <netinet/in.h>
],[
struct in_addr arg;
arg.s_addr = htonl(INADDR_ANY);
], [ have_in_addr="1" 
msg=yes ] , [ have_in_addr="0"
msg=no ])
AC_MSG_RESULT([$msg])

AC_SUBST(have_in_addr)

dnl #----------------------------- Construct the files
AC_SUBST(LDLIBS)
AC_SUBST(OPTIM)
AC_SUBST(RANLIB)
AC_SUBST(AR)
AC_SUBST(RM)
AC_SUBST(OSDIR)
AC_SUBST(DEFAULT_OSDIR)
AC_SUBST(LIBPREFIX)
AC_SUBST(EXEEXT)

echo "Construct Makefiles and header files."
MAKEFILE1="Makefile lib/Makefile "
SUBDIRS="lib "
for dir in $MODULES
do
    if test -f $dir/$OSDIR/Makefile.in; then
        MAKEFILE2="$MAKEFILE2 $dir/$OSDIR/Makefile "
        SUBDIRS="$SUBDIRS $dir/$OSDIR "
    else
        MAKEFILE2="$MAKEFILE2 $dir/$DEFAULT_OSDIR/Makefile "
        SUBDIRS="$SUBDIRS $dir/$DEFAULT_OSDIR "
    fi
done

MAKEFILE3="test/Makefile"
AC_SUBST(SUBDIRS)
AC_SUBST(MODULES)
AC_OUTPUT($MAKEFILE1 $MAKEFILE2 $MAKEFILE3 include/apr.h)