File: configure.ac

package info (click to toggle)
libapache2-mod-rivet 3.2.6-1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 6,384 kB
  • sloc: tcl: 8,982; xml: 8,619; ansic: 7,074; sh: 5,039; makefile: 195; sql: 91; lisp: 78
file content (936 lines) | stat: -rw-r--r-- 32,974 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
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
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
#!/bin/sh 
dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run when building Rivet
dnl to configure the system for the local environment.
dnl
dnl You need at least autoconf 2.59
dnl
#
#-----------------------------------------------------------------------
# Sample configure.in for Tcl Extensions.  The only places you should
# need to modify this file are marked by the string __CHANGE__
#-----------------------------------------------------------------------

#-----------------------------------------------------------------------
# __CHANGE__
# Set your package name and version numbers here.
#
# This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION
# set as provided.  These will also be added as -D defs in your Makefile
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------

AC_INIT([Rivet],[m4_esyscmd_s([cat VERSION])],[rivet-dev@tcl.apache.org])
TEA_INIT([3.9])

# we are storing here the configure command line, as recursive
# invocations change the value of the shell variables $0 $*

CONFIGURE_CMD="$0 $*"

AC_CONFIG_AUX_DIR(tclconfig)
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])

# AX_PREFIX_CONFIG_H is a macro taken from the autotools macro archive.
# The typical configure generated 'config.h' can be renamed and 
# preprocessor symbols in it can be prefixed in order to avoid clashes 
# with Apache's config.h
# 
# As of today (27 Sept 2008) this macro is not part of autotools and
# it's in the 'm4' directory
#

AX_PREFIX_CONFIG_H([rivet_config.h],[rivet])

#--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
# This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
#--------------------------------------------------------------------

#
# Init automake stuff
#
AC_DISABLE_STATIC
AM_INIT_AUTOMAKE([foreign subdir-objects])

# establishing a landmark in the directory hierarchy as per 
# autotools design. This is what AC_CONFIG_SRCDIR is meant to do
# I arbitrarily choose src/rivet.h as landmark, moving this file
# to a different directory or deleting it implies this line has to
# change

AC_CONFIG_SRCDIR([src/rivet.h])

#--------------------------------------------------------------------
# Load the tclConfig.sh file
#--------------------------------------------------------------------

TEA_PATH_TCLCONFIG
TEA_LOAD_TCLCONFIG

#--------------------------------------------------------------------
# Load the tkConfig.sh file if necessary (Tk extension)
#--------------------------------------------------------------------

#TEA_PATH_TKCONFIG
#TEA_LOAD_TKCONFIG

#-----------------------------------------------------------------------
# Handle the --prefix=... option by defaulting to what Tcl gave.
# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER.
#-----------------------------------------------------------------------

TEA_PREFIX

#-----------------------------------------------------------------------
# Standard compiler checks.
# This sets up CC by using the CC env var, or looks for gcc otherwise.
# This also calls AC_PROG_CC, AC_PROG_INSTALL and a few others to create
# the basic setup necessary to compile executables.
#-----------------------------------------------------------------------

TEA_SETUP_COMPILER

#
# For automake to be happy, we also need LT_INIT
#
# the LIBTOOL_DEPS macro sets up for automatic updating of the
# libtool script if it becomes out of date, as per libtool docs
#
LT_INIT
AC_SUBST(LIBTOOL_DEPS)

#-----------------------------------------------------------------------
# __CHANGE__
# Specify the C source files to compile in TEA_ADD_SOURCES,
# public headers that need to be installed in TEA_ADD_HEADERS,
# stub library C source files to compile in TEA_ADD_STUB_SOURCES,
# and runtime Tcl library files in TEA_ADD_TCL_SOURCES.
# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS
# and PKG_TCL_SOURCES.
#-----------------------------------------------------------------------

# Unused: src/TclWeb.c

#TEA_ADD_SOURCES([src/TclWebcgi.c src/TclWebapache.c src/apache_multipart_buffer.c src/apache_request.c src/mod_rivet.c src/parserPkgInit.c src/rivetChannel.c src/rivetCore.c src/rivetCrypt.c src/rivetList.c src/rivetParser.c src/rivetPkgInit.c src/rivetWWW.c win/nmakehlp.c src/testing.c])
#TEA_ADD_HEADERS([src/TclWeb.h src/apache_multipart_buffer.h src/apache_request.h src/mod_rivet.h src/rivet.h src/rivetChannel.h src/rivetParser.h])
TEA_ADD_INCLUDES([])
TEA_ADD_LIBS([])
TEA_ADD_CFLAGS([])
TEA_ADD_STUB_SOURCES([])
TEA_ADD_TCL_SOURCES([])

#--------------------------------------------------------------------
# __CHANGE__
# A few miscellaneous platform-specific items:
#
# Define a special symbol for Windows (BUILD_sample in this case) so
# that we create the export library with the dll.
#
# Windows creates a few extra files that need to be cleaned up.
# You can add more files to clean if your extension creates any extra
# files.
#
# TEA_ADD_* any platform specific compiler/build info here.
#--------------------------------------------------------------------

# removed AC_DEFINE(BUILD_rivet....) as per TEA 3.9 (Massimo Manghi 20100825)

if test "${TEA_PLATFORM}" = "windows" ; then
#   AC_DEFINE(BUILD_rivet,1,[Define to define the BUILD_rivet define (?)])
    CLEANFILES="pkgIndex.tcl *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
#   #TEA_ADD_SOURCES([win/winFile.c])
#   #TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"])
else
    CLEANFILES="pkgIndex.tcl"
#   #TEA_ADD_SOURCES([unix/unixFile.c])
#   #TEA_ADD_LIBS([-lsuperfly])
fi
AC_SUBST(CLEANFILES)

#--------------------------------------------------------------------
# __CHANGE__
# Choose which headers you need.  Extension authors should try very
# hard to only rely on the Tcl public header files.  Internal headers
# contain private data structures and are subject to change without
# notice.
# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG
#--------------------------------------------------------------------

TEA_PUBLIC_TCL_HEADERS
#TEA_PRIVATE_TCL_HEADERS

#TEA_PUBLIC_TK_HEADERS
#TEA_PRIVATE_TK_HEADERS
#TEA_PATH_X

#--------------------------------------------------------------------
# Check whether --enable-threads or --disable-threads was given.
# This auto-enables if Tcl was compiled threaded.
#--------------------------------------------------------------------

TEA_ENABLE_THREADS

#--------------------------------------------------------------------
# The statement below defines a collection of symbols related to
# building as a shared library instead of a static library.
#--------------------------------------------------------------------

TEA_ENABLE_SHARED

#--------------------------------------------------------------------
# This macro figures out what flags to use with the compiler/linker
# when building shared/static debug/optimized objects.  This information
# can be taken from the tclConfig.sh file, but this figures it all out.
#--------------------------------------------------------------------

TEA_CONFIG_CFLAGS

#--------------------------------------------------------------------
# Set the default compiler switches based on the --enable-symbols option.
#--------------------------------------------------------------------

TEA_ENABLE_SYMBOLS

#--------------------------------------------------------------------
# Everyone should be linking against the Tcl stub library.  If you
# can't for some reason, remove this definition.  If you aren't using
# stubs, you also need to modify the SHLIB_LD_LIBS setting below to
# link against the non-stubbed Tcl library.  Add Tk too if necessary.
#--------------------------------------------------------------------

#
# stubs are causing segmentation violations when mod_rivet is getting
# loaded into apache.  it would be nice if we did no stubs for this and
# still did stubs for librivet and librivetparser, which seem to be OK.
#
#AC_DEFINE(USE_TCL_STUBS,1,[Define to link against the Tcl stub library])
#AC_DEFINE(USE_TK_STUBS)

#--------------------------------------------------------------------
# This macro generates a line to use when building a library.  It
# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS,
# and TEA_LOAD_TCLCONFIG macros above.
#--------------------------------------------------------------------

TEA_MAKE_LIB

#--------------------------------------------------------------------
# Find tclsh so that we can run pkg_mkIndex to generate the pkgIndex.tcl
# file during the install process.  Don't run the TCLSH_PROG through
# ${CYGPATH} because it's being used directly by make.
# Require that we use a tclsh shell version 8.2 or later since earlier
# versions have bugs in the pkg_mkIndex routine.
# Add WISH as well if this is a Tk extension.
#--------------------------------------------------------------------

# We have to either find a working tclsh or be told where it is 
# using --with-tclsh
AC_ARG_WITH(tclsh, [  --with-tclsh=FILE location of a working tclsh executable], with_tclsh=${withval})

#
# allow them to override the tclsh we think we found
#
if test x"${with_tclsh}" != x ; then
    AC_MSG_CHECKING([for tclsh])
    if test -f "${with_tclsh}" ; then
        TCLSH_PROG=${with_tclsh}
        AC_MSG_RESULT([manually set by --with-tclsh=$TCLSH_PROG])
    else
        AC_MSG_ERROR([No tclsh at place specified by --with-tclsh (${with_tclsh})])
    fi
    AC_SUBST(TCLSH_PROG)
else
    TEA_PROG_TCLSH
fi

#TEA_PROG_WISH

# apache base directory

AC_DEFUN([APACHE],[
    AC_MSG_CHECKING(for Apache base)
    AC_ARG_WITH(
        apache,
        [  --with-apache[=DIR] Apache server base directory],, 
        [with_apache="/usr/local/apache2"]
    )
    apache_base="${with_apache}"
    AC_MSG_RESULT([$apache_base])
])

#
# We have to either find apxs or be told where it is using --with-apxs 
#
AC_DEFUN([CHECK_APXS],[
    AC_MSG_CHECKING(for Apache apxs)
    AC_ARG_WITH(
        apxs,
        [  --with-apxs=FILE        location of Apache apxs tool],  
        [if test -x "${with_apxs}" ; then
            apxs_found="${with_apxs}"
            AC_MSG_RESULT([$apxs_found])
         fi]
        ,
        [ 
            APXS_NAMES=apxs
            for apxs_file in ${APXS_NAMES}; do 
                for apxs_path in bin sbin; do 
                     if test -x "${apache_base}"/"${apxs_path}"/"${apxs_file}"; then
                            apxs_found="${apache_base}"/"${apxs_path}"/"${apxs_file}" 
                            break 2
                      fi
                done
            done
            if test x"$apxs_found" = x; then
                AC_PATH_PROGS(with_apxs, apxs)
                if test "${with_apxs+set}" = set ; then
                    apxs_found="${with_apxs}"
                fi
            fi
            if test x"${apxs_found}" = x; then
                AC_MSG_ERROR([Could not find apxs.  apxs must be in your PATH or you must specify the location of the apxs script using --with-apxs])
            else
                AC_MSG_RESULT([$apxs_found])
            fi
        ]
    )
    if test "${apxs_found+set}" = set ; then
        dnl At this point we already have apr sorted out
        export PATH=$PATH:`dirname $apxs_found`
        APXS_CPPFLAGS=`${apxs_found} -q CFLAGS`
        AC_SUBST(APXS_CPPFLAGS)
        APXS_LDFLAGS=`${apxs_found} -q LDFLAGS_SHLIB`
        AC_SUBST(APXS_LDFLAGS)
        APXS_LIBS=`${apxs_found} -q LIBS_SHLIB`
        AC_SUBST(APXS_LIBS)
        APXS_INCLUDES=-I`${apxs_found} -q INCLUDEDIR`
        AC_SUBST(APXS_INCLUDES)
        APXS_CPPFLAGS_SHLIB=`${apxs_found} -q CFLAGS_SHLIB`
        AC_SUBST(APXS_CPPFLAGS_SHLIB)
        APXS_LD_SHLIB=`${apxs_found} -q LD_SHLIB`
        AC_SUBST(APXS_LD_SHLIB)
        APXS_LIBEXECDIR=`${apxs_found} -q LIBEXECDIR`
        AC_SUBST(APXS_LIBEXECDIR)
        APXS_SYSCONFDIR=`${apxs_found} -q SYSCONFDIR`
        AC_SUBST(APXS_SYSCONFDIR)
        APXS_PREFIX=`${apxs_found} -q PREFIX`
        AC_SUBST(APXS_PREFIX)
    else 
        AC_MSG_ERROR([Could not find apxs.  apxs must be in your PATH or you must specify the location of the apxs script using --with-apxs])
    fi
])


AC_DEFUN([APACHE_INCLUDES],[
  AC_ARG_WITH(
    apache_include,
    [  --with-apache-include[=DIR]     Apache server directory],
     [apache_include="${with_apache_include}"] 
    ,[apache_include="${APXS_INCLUDES}"]
  )
    AC_SUBST(apache_include)
])

AC_DEFUN([APR_HANDLING],[
  AC_MSG_CHECKING(for Apache apr)
  AC_ARG_WITH(
   apr_config,
    [  --with-apr-config=FILE     apr portable apr-1-config path],
     [if test -x "${with_apr_config}"; then
         apr_found="${with_apr_config}"
     fi]
         ,
    [if test -x "${apache_base}/bin/apr-1-config" ; then
         apr_found="${apache_base}/bin/apr-1-config" 
    elif test -x "${apache_base}/sbin/apr-1-config" ; then
         apr_found="${apache_base}/sbin/apr-1-config" 
    elif test "${apache_base+set}" = set; then 
        AC_PATH_PROGS(with_apr_config, apr-1-config)
        if test "${with_apr_config+set}" = set ; then
            apr_found="${with_apr_config}"
        fi
    else 
        AC_MSG_ERROR( Specify the apr-1-config path using --with-apr-config, 1)
    fi]
)
    if test "${apr_found+set}" = set ; then
        AC_MSG_RESULT([$apr_found])
        dnl At this point we already have apr sorted out
        dnl It actually calls another script, so the PATH needs to be set.
        export PATH=$PATH:`dirname ${apr_found}`
        APR_CPPFLAGS=`${apr_found} --cppflags`
        AC_SUBST(APR_CPPFLAGS)
        APR_INCLUDES=`${apr_found} --includes`
        AC_SUBST(APR_INCLUDES)
        APR_LDLFAGS=`${apr_found} --link-libtool --libs`
        AC_SUBST(APR_LDFLAGS)
    else
        AC_MSG_ERROR([Could not find apr-1-config. apr-1-config must be in your PATH or you must specify the location of the apr script using --with-apr-config])
    fi
])

# -- APU_HANDLING
#
# calling apu-1-config to determine where apr-utils includes
# and library are
#

AC_DEFUN([APU_HANDLING],[
  AC_MSG_CHECKING(for Apache apu)
  AC_ARG_WITH(
   apu_config,
    [  --with-apu-config=FILE     apu portable apu-1-config path],
    [if "${with_apu_config}" --version; then
         apu_found="${with_apu_config}"
    fi]
     ,
    [if apu-1-config --version; then
         apu_found=apu-1-config
    elif test -x "${apache_base}/bin/apu-1-config" ; then
         apu_found="${apache_base}/bin/apu-1-config" 
    elif test -x "${apache_base}/sbin/apu-1-config" ; then
         apu_found="${apache_base}/sbin/apu-1-config" 
    elif test "${apache_base+set}" = set; then 
        AC_PATH_PROGS(with_apu_config, apu-1-config)
        if test "${with_apu_config+set}" = set ; then
            apu_found="${with_apu_config}"
        fi
    else 
        AC_MSG_ERROR( Specify the apu-1-config path or program name using --with-apu-config, 1)
    fi]
)
    if test "${apu_found+set}" = set ; then
        AC_MSG_RESULT([$apu_found_])
        dnl At this point we already have apu sorted out
        dnl It actually calls another script, so the PATH needs to be set.
        export PATH=$PATH:`dirname ${apu_found}`
        APU_INCLUDES=`${apu_found} --includes`
        AC_SUBST(APU_INCLUDES)
        APU_LDLFAGS=`${apu_found} --link-libtool --libs`
        AC_SUBST(APU_LDFLAGS)
    else
        AC_MSG_ERROR([Could not find apu-1-config. apu-1-config must be in your PATH or you must specify the location of the apu script using --with-apu-config])
    fi
])

#--------------------------------------------------------------------
# 6-Dec-2011: Introducing new ::rivet namespace. Some components 
# (namely RivetTcl, providing Tcl level initialization) are required 
# within mod_rivet.c. Unfortunalely Tcl < 8.5.10 shared
# libs exporting names could clash with Apache's binary own names. 
# Hence we have to make sure we are running a Tcl compatible version.
# (See Tcl bug #3216070). 
# 
# Effect: If you're running Tcl < 8.5.10 we refuse to build Rivet...

AX_COMPARE_VERSION([$TCL_VERSION$TCL_PATCH_LEVEL],[lt],[8.5.10],[
    AC_MSG_ERROR([Rivet 2.1 requires Tcl > 8.5.10 (current is $TCL_VERSION$TCL_PATCH_LEVEL)])
] , [
    AC_MSG_NOTICE([we are building Rivet with Tcl $TCL_VERSION$TCL_PATCH_LEVEL])
])


print_fileevent_msg="0"
AX_COMPARE_VERSION([$TCL_VERSION$TCL_PATCH_LEVEL],[lt],[8.5.15],[
    print_fileevent_msg="1"
] , )


AX_COMPARE_VERSION([$TCL_VERSION],[eq],[8.6],[
    if test "$TCL_PATCH_LEVEL" = ".0" ; then
        print_fileevent_msg="1"
    fi
] , )

# MOD_RIVET_CORE
#
# Determining the path to the mod_rivet.* source files
#

AC_DEFUN([MOD_RIVET_CORE],[
    AC_ARG_WITH(
       rivet_core,
       [  --with-rivet-core[=path] mod_rivet core directory],,
       [with_rivet_core="mod_rivet_ng"]
    )

    AC_MSG_CHECKING([mod_rivet core])

    #if [[ -d "src/${with_rivet_core}" ]]; then
    #    rivet_core=$(pwd)/src/${with_rivet_core}
    #else
    #    rivet_core=${with_rivet_core}
    #fi
    
    rivet_core=${with_rivet_core}
   
    # by default we search the channel and core commands
    # implementation in the same directory. This can
    # be superseded by other macros

    default_rivet_commands=${rivet_core}
    default_rivet_channel=${rivet_core}

    #AC_CONFIG_FILES([src/${rivet_core}/Makefile])
    AC_SUBST(rivet_core)
    AC_MSG_RESULT([$rivet_core])
])

# 

AC_DEFUN([HANDLE_TCL_PACKAGE_PATH],[
    # shamelessly stolen from TEA_LOAD_TCLCONFIG
    AC_MSG_CHECKING([Debian TCL_PACKAGE_PATH workaround])
        if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
           AC_MSG_RESULT([loading])
           . "${TCL_BIN_DIR}/tclConfig.sh"
        else
           AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
        fi
    # If we have multiple paths, pull the first one, add end slash if needed
    res=`echo ${TCL_PACKAGE_PATH} | \
             grep '[[^\]] ' | \
             sed -e 's/\([[^\]]\)\( \)\(.*\)$/\1/'  -e 's/\([[^\/]]\)$/\1\//' `
    if test x"${res}" != x; then
        TCL_PACKAGE_PATH=${res}
        AC_SUBST(TCL_PACKAGE_PATH)
    fi
])

AC_DEFUN([GET_RIVET_BASE], [
    RIVET_BASE_INCLUDE=`pwd`/src    
    AC_SUBST(RIVET_BASE_INCLUDE)
    RIVET_SOURCE_BASE=`pwd`/src    
    AC_SUBST(RIVET_SOURCE_BASE)
])

# APACHE_REQUEST
#
# Choosing where is located the code for handling Apache request data (like
# form data etc). Default: 'request'  

AC_DEFUN([APACHE_REQUEST],[
    AC_ARG_WITH(
        apache_request,
        [  --with-apache-request=DIR path to rivet HTML form and urlencoded data handler],,
        [with_apache_request="request"]
    )

    AC_MSG_CHECKING([code for HTML form and urlencoded data handling])
    apache_request=${with_apache_request}
    AC_SUBST(apache_request)
    AC_MSG_RESULT([$apache_request])
])

# RIVET_CORE_CMDS
#
# selecting non default directory for Rivet code commands core
#

AC_DEFUN([RIVET_CORE_CMDS],[
    AC_ARG_WITH(
        rivet_commands,
        [  --with-rivet-commands[=dir] path to Rivet core commands code],,
        [with_rivet_commands=$default_rivet_commands]
    )

    AC_MSG_CHECKING([for Rivet core commands code])
    rivet_commands=${with_rivet_commands}
    AC_SUBST(rivet_commands)
    AC_MSG_RESULT([$rivet_commands])

])

# RIVET_CHANNEL
#
# selecting the Rivet channel code directory

AC_DEFUN([RIVET_CHANNEL],[
    AC_ARG_WITH(
        rivet_channel,
        [  --with-rivet-channel=DIR Rivet channel code path ],,
        [with_rivet_channel=$default_rivet_channel]
    )

    AC_MSG_CHECKING([for Rivet channel code path])
    rivet_channel=${with_rivet_channel}

    AC_SUBST(rivet_channel)
    AC_MSG_RESULT([$rivet_channel])
])

# RIVET_TCL_LIB
#
#

AC_DEFUN([RIVET_TCL_LIB],[
    AC_ARG_WITH(
        rivet_target_dir,
        [  --with-rivet-target-dir=DIR  Rivet tcl and binary libraries target dir ],,
        with_rivet_target_dir="${apache_base}/lib/rivet${PACKAGE_VERSION}"
    )
    AC_MSG_CHECKING([for Rivet libraries target])
    RIVET_TCL_TARGET=${with_rivet_target_dir}
    AC_SUBST(RIVET_TCL_TARGET)
    AC_MSG_RESULT([$with_rivet_target_dir])
])

# DISPLAY_RIVET_VERSION
#
# --enable-version-display=[yes|no] (default: no)
# switches on version number display in Apache's signature.
#

AC_DEFUN([DISPLAY_RIVET_VERSION],[
    AC_ARG_ENABLE(
        version_display,
    [  --enable-version-display  Display Rivet version in Apache signature],
    [ signature_version_display=$enable_version_display ],
    [ signature_version_display="no" ]
    )

    AC_MSG_CHECKING([whether rivet version is printed in Apache signature])
    if test "$signature_version_display" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(DISPLAY_VERSION,1,[Display Rivet version in Apache signature])
    else
        AC_MSG_RESULT([no, Rivet version will be hidden])
        AC_DEFINE(DISPLAY_VERSION,0,[Display Rivet version in Apache signature])
    fi
])

# UPLOAD_DIRECTORY
# 
# Adds '--with-upload-dir=DIR' to configure's arguments
#
# let's make configuration of the upload directory more flexible for windows builds
# (in case someone steps forward and takes up the Windows port)
# The upload directory can be changed in the configuration, but we give the 
# user/packager the chance to set a default at compile time.
# Default: /tmp

AC_DEFUN([UPLOAD_DIRECTORY],[
    AC_ARG_WITH(
    upload_dir,
    [  --with-upload-dir=DIR Default directory for uploads],,
        with_upload_dir="/tmp"
    )
    AC_MSG_CHECKING(where Rivet will save uploads)
    RIVET_UPLOAD_DIR=${with_upload_dir}
    AC_SUBST(RIVET_UPLOAD_DIR)
    AC_MSG_RESULT([$with_upload_dir])
])

# HONOR_HEAD_REQUESTS (--enable-head-requests)
# Rivet answers to HEAD requests with a standard response to avoid the whole workload
# of generating the content of a page with to the sole purpose of returning the HTTP 
# headers.To test the configuration or scripts that manipulate the headers it 
# can be useful to let Rivet honor a HEAD request as if the whole content was 
# generated so that the real headers are returned (this can be set in configuration 
# by adding "RivetServerConf HonorHeaderOnlyRequests yes" to the server configuration)
#
# Default: no

AC_DEFUN([HONOR_HEAD_REQUESTS],[
    AC_ARG_ENABLE(
    head_requests,
    [  --enable-head-requests Returns real headers in response to a HEAD request],
    [ honor_head_requests=$enable_head_requests ],
    [ honor_head_requests="yes"]
    )

    AC_MSG_CHECKING([if Rivet has to honor HEAD requests])
    if test "$honor_head_requests" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(HEAD_REQUESTS,1,[Honor HEAD requests])
    else
        AC_MSG_RESULT([no, Rivet will shunt HEAD requests])
        AC_DEFINE(HEAD_REQUESTS,0,[Honor HEAD requests])
    fi
])

# SINGLE_WORKER_TCL_THREAD 
#
# This options is used by the worker MPM bridge for debugging.
# When enabled rivet_worker_bridge will create a single Tcl interp thread instead 
# of the a whole pool of them
# 
# Defautl: no

AC_DEFUN([SINGLE_WORKER_TCL_THREAD],[
    AC_ARG_ENABLE(
    single_thread,
    [  --enable-single-thread forces the worker brigde to create a single thread (debug)],
    [ single_thread=$enable_single_thread ],
    [ single_thread="no"]
    )

    AC_MSG_CHECKING([if the worker MPM bridge will run in single thread mode])
    if test "$single_thread" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(MPM_SINGLE_TCL_THREAD,1,[yes, MPM worker single thread])
    else
        AC_MSG_RESULT([no, maximal number of Tcl threads])
    fi
])

# -- SERIALIZE_HTTP_REQUEST
#
# The macro defines the symbol SERIALIZE_HTTP_REQUESTS and cooperates 
# with macro HTTP_REQUESTS_PROC. This option is useful only 
# for debugging (avoids threads concurrency). See the code of the
# worker bridge to see the preprocessor macros cooperating to
# attain this feature
#
# Default: no

AC_DEFUN([HTTP_REQUESTS_MUTEX],[
    AC_ARG_ENABLE(
        requests_serialization,
        [  --enable-requests-serialization Forces HTTP requests serialization among threads(debug)],
        [ requests_serialization=$enable_requests_serialization ],
        [ requests_serialization="no" ]
    )

    AC_MSG_CHECKING([if we want the worker bridge to serialize HTTP requests])
    if test "$requests_serialization" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(SERIALIZE_HTTP_REQUESTS,1,[requests will be serialized])
    else
        AC_MSG_RESULT([no, HTTP requests will not be serialized])
    fi
])

# -- RIVET_DEBUG_BUILD
#
# Defining a symbol for conditional inclusion of code for debugging purposes
#
# Default: no
#

AC_DEFUN([BUILD_DEBUG_CODE],[
    AC_ARG_ENABLE(
        rivet_debug_build,
        [  --enable-rivet-debug-build Includes optional debugging code],
        [ rivet_debug_build=$enable_rivet_debug_build ],
        [ rivet_debug_build="no" ]
    )

    AC_MSG_CHECKING([if we are building mod_rivet for debugging])
    if test "$rivet_debug_build" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(DEBUG_BUILD,1,[we are building mod_rivet with optional code])
    else
        AC_MSG_RESULT([no, ordinary build])
    fi
])

# RIVET_COMMANDS_EXPORT (--enable-rivet-commands-export).
# Enable export of commands in Rivet's namespace. Definining this symbols
# sets the boolean configuration variable rivet_commands_export 
# Default: yes

AC_DEFUN([RIVET_COMMANDS_EXPORT],[
    AC_ARG_ENABLE(
        rivet-commands-export,
        [  --disable-rivet-commands-export to prevent export from ::rivet namespace],
        [ rivet_commands_export=$enable_rivet_commands_export ],
        [ rivet_commands_export="yes"]
    )

    AC_MSG_CHECKING([if the commands in ::rivet namespace will be exported])
    if test "$rivet_commands_export" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(NAMESPACE_EXPORT,1,[commands will be exported])
    else
        AC_MSG_RESULT([no])
        AC_DEFINE(NAMESPACE_EXPORT,0,[commands will not be exported])
    fi
])

# IMPORT_RIVET_COMMANDS (--enable-import-rivet-commands).
# For compatibility the module can be compiled and installed forcing rivet
# to import commands from ::rivet into the global namespace.
# Default: no

AC_DEFUN([IMPORT_RIVET_COMMANDS],[
    AC_ARG_ENABLE(
        import-rivet-commands,
        [  --enable-import-rivet-commands requires explicit namespace import],
        [ import_rivet_commands=$enable_import_rivet_commands],
        [ import_rivet_commands="no"]
    )

    AC_MSG_CHECKING([if ::rivet namespace will be automatically imported for compatibility])
    if test "$import_rivet_commands" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(NAMESPACE_IMPORT,1,[commands will be imported into the global namespace])
    else
        AC_MSG_RESULT([no])
        AC_DEFINE(NAMESPACE_IMPORT,0,[good, no automatic import will be done])
    fi
])


# SEPARATE_VIRTUAL_INTERPS (--enable-virtual-interps-separation)
# Virtual hosts get their own interpreter and configuration. Different
# applications running on different virtual hosts don't mix up variables
# and namespaces, avoiding conflicts.
# Default: no

AC_DEFUN([VIRTUAL_INTERPS_SEPARATION],[
    AC_ARG_ENABLE(
    virtual-interps-separation,
    [  --enable-virtual-interps-separation to turn on virtual host separation],
    [ separate_virtual_interps=$enable_virtual_interps_separation ],
    [ separate_virtual_interps="no"]
    )

    AC_MSG_CHECKING([whether Rivet will create an interpreter for each virtual host])
    if test "$separate_virtual_interps" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(SEPARATE_VIRTUAL_INTERPS,1,[virtual hosts will have their own interp])
    else
        AC_MSG_RESULT([no])
        AC_DEFINE(SEPARATE_VIRTUAL_INTERPS,0,[one interpreter per child])
    fi
])

# POST_MAX_SIZE (--with-post-max)
# Maximum size of data posted by a form
# Default: 0=unlimited

AC_DEFUN([POST_MAX_SIZE],[
    AC_ARG_WITH(
    post_max,
    [  --with-post-max=BYTES Maximum size of data to be sent with a POST],,
        with_post_max=0
    )
    
    AC_MSG_CHECKING([maximum size of a POST])
    MAX_POST=${with_post_max}
    AC_SUBST(MAX_POST)
    if test $with_post_max = 0; then
        AC_MSG_RESULT([unlimited size])
    else
        AC_MSG_RESULT([$with_post_max])
    fi
])

# UPLOAD_TO_VAR (--enable-upload-var)
# Enables upload of files into Tcl variables
# Default: 1=enabled

AC_DEFUN([UPLOAD_TO_VAR],[
    AC_ARG_ENABLE(
    upload-var,
    [  --disable-upload-var to disable automatic upload to variables ],
    [ upload_var=$enable_upload_var ],
    [ upload_var="yes"]
    )

    AC_MSG_CHECKING([whether files are uploaded to Tcl variables])
    if test "$upload_var" = "yes"; then
        AC_MSG_RESULT([yes])
        AC_DEFINE(UPLOAD_FILES_TO_VAR,1,[Files are uploaded to Tcl variables])
    else
        AC_MSG_RESULT([no])
        AC_DEFINE(UPLOAD_FILES_TO_VAR,0,[uploads go to files])
    fi

])

#APACHE_VERSION
MOD_RIVET_CORE
GET_RIVET_BASE
APACHE
CHECK_APXS
APACHE_INCLUDES
APR_HANDLING
APU_HANDLING
RIVET_TCL_LIB
DISPLAY_RIVET_VERSION
UPLOAD_DIRECTORY
HONOR_HEAD_REQUESTS
VIRTUAL_INTERPS_SEPARATION
POST_MAX_SIZE
UPLOAD_TO_VAR
IMPORT_RIVET_COMMANDS
APACHE_REQUEST
RIVET_CORE_CMDS
RIVET_CHANNEL
SINGLE_WORKER_TCL_THREAD
HTTP_REQUESTS_MUTEX
BUILD_DEBUG_CODE
AC_HEADER_STDBOOL

# Let's separate the point version from the major and minor version
# to build a Rivet version to be substituted as basic version for 
# package Rivet, central initialization of the Tcl environment

VERSION=${PACKAGE_VERSION}
AX_SPLIT_VERSION
AC_DEFINE_UNQUOTED(INIT_VERSION,"${AX_MAJOR_VERSION}.${AX_MINOR_VERSION}",[Rivet Tcl package version])
AC_MSG_NOTICE([Rivet package version is ${AX_MAJOR_VERSION}.${AX_MINOR_VERSION}])
AC_SUBST(INIT_VERSION,"${AX_MAJOR_VERSION}.${AX_MINOR_VERSION}")
AC_SUBST(RIVETLIB_PACKAGE,"rivetlib",[rivetlib package name])
AC_SUBST(RIVETLIB_PACKAGE_VERSION,"${AX_MAJOR_VERSION}.${AX_MINOR_VERSION}")

if test $import_rivet_commands = "yes"; then
    AC_MSG_NOTICE([forcing Rivet to export commands from ::rivet namespace])
    AC_DEFINE(NAMESPACE_EXPORT,1,[commands will be exported])
else
    RIVET_COMMANDS_EXPORT
fi
AC_C_INLINE

#AC_SUBST(apache_version_dir)
AC_SUBST(MOD_RIVET_INCLUDES)

AC_DEFINE_UNQUOTED(RIVETLIB_DESTDIR,"${RIVET_TCL_TARGET}",[The path to the rivet tcl library])
AC_DEFINE_UNQUOTED(NAMEOFEXECUTABLE,"${TCLSH_PROG}",[The path to a working tclsh executable])
AC_DEFINE_UNQUOTED(UPLOAD_DIR,"${RIVET_UPLOAD_DIR}",[Path to the disk directory where uploads are saved])
AC_DEFINE_UNQUOTED(MAX_POST,[$MAX_POST],[Max size of data in POST operations])
AC_DEFINE_UNQUOTED(SEPARATE_CHANNELS,0,[Separate Channels for virtual hosts])
AC_DEFINE_UNQUOTED(CONFIGURE_CMD,"${CONFIGURE_CMD}",[configure command string])
AC_DEFINE_UNQUOTED(RIVET_CORE,"${rivet_core}",[mod_rivet core])

# We need to use the package path for the installation procedure.  On
#Debian linux TCL_PACKAGE_PATH may have more than one path in the
#TCL_PACKAGE_PATH variable, so we have to handle this
HANDLE_TCL_PACKAGE_PATH
AC_SUBST(TCL_PACKAGE_PATH)


# Finally, substitute all of the various values into the Makefile.
# You may alternatively have a special pkgIndex.tcl.in or other files
# which require substituting the AC variables in.  Include these here.
#--------------------------------------------------------------------
AC_CONFIG_FILES([Makefile src/Makefile rivet/init.tcl])

#case $apache_version_dir in
#    apache-1) AC_CONFIG_FILES([Makefile src/Makefile src/apache-1/Makefile doc/Makefile]) ;;
#    apache-2) AC_CONFIG_FILES([Makefile src/Makefile src/apache-2/Makefile doc/Makefile]) ;;
#esac
AC_OUTPUT

if test "$print_fileevent_msg" = "1"; then
    AC_MSG_NOTICE([========================================================================])
    AC_MSG_NOTICE([                             WARNING!])
    AC_MSG_NOTICE([========================================================================])
    AC_MSG_NOTICE([The Tcl notifier (and consequently the event loop) does not work with])
    AC_MSG_NOTICE([Rivet running Tcl $TCL_VERSION$TCL_PATCH_LEVEL and the 'prefork' MPM of Apache.])
    AC_MSG_NOTICE([In order to have asynchronous I/O working the required versions are:])
    AC_MSG_NOTICE([   - threaded builds: Tcl >= 8.5.15 (8.5 version) or Tcl >= 8.6.1])
    AC_MSG_NOTICE([   - any non-threaded build of Tcl >= 8.5.10])
    AC_MSG_NOTICE([])
    AC_MSG_NOTICE([Nonetheless Rivet scripts work with Tcl >= 8.5.10 provided])
    AC_MSG_NOTICE([you do not have to rely on the event loop to do I/O (e.g. you])
    AC_MSG_NOTICE([cannot use the 'fileevent' command to set up callbacks)])
    AC_MSG_NOTICE([see https://issues.apache.org/bugzilla/show_bug.cgi?id=55153])
    AC_MSG_NOTICE([========================================================================])
fi