1AC_MSG_CHECKING(for extra modules)
2AC_ARG_WITH(module,
3  APACHE_HELP_STRING(--with-module=module-type:module-file,
4                     Enable module-file in the modules/<module-type> directory.),
5  [
6    withval=`echo $withval | sed -e 's/,/ /g'`
7    for mod in $withval
8    do
9      modtype=`echo $mod | sed -e's/\(.*\):.*/\1/'`
10      pkg=`echo $mod | sed -e's/.*:\(.*\)/\1/'`
11      modfilec=`echo $pkg | sed -e 's;^.*/;;'`
12      modfileo=`echo $pkg | sed -e 's;^.*/;;' -e 's;\.c$;.o;'`
13      modpath_current="modules/$modtype"
14      if test "x$mod" != "x$modpath_current/$modfilec"; then
15        if test ! -d "$modpath_current"; then
16          mkdir $modpath_current
17          echo 'include $(top_srcdir)/build/special.mk' > $modpath_current/Makefile.in
18        fi
19        cp $pkg $modpath_current/$modfilec
20      fi
21      module=`echo $pkg | sed -e 's;\(.*/\).*mod_\(.*\).c;\2;'`
22      objects="mod_$module.lo"
23      # The filename of a convenience library must have a "lib" prefix:
24      libname="libmod_$module.la"
25      BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
26      if test ! -s "$modpath_current/modules.mk"; then
27        cat >>$modpath_current/modules.mk<<EOF
28$libname: $objects
29	\$(MOD_LINK) $objects
30DISTCLEAN_TARGETS = modules.mk
31static = $libname
32shared =
33EOF
34      else
35        cat >>$modpath_current/modules.mk.tmp<<EOF
36$libname: $objects
37	\$(MOD_LINK) $objects
38EOF
39        cat $modpath_current/modules.mk >> $modpath_current/modules.mk.tmp
40        rm $modpath_current/modules.mk
41        mv $modpath_current/modules.mk.tmp $modpath_current/modules.mk
42        sed -e "s/\(static =.*\)/\1 $libname/" $modpath_current/modules.mk > $modpath_current/modules.mk.tmp
43        rm $modpath_current/modules.mk
44        mv $modpath_current/modules.mk.tmp $modpath_current/modules.mk
45      fi
46      MODLIST="$MODLIST $module"
47      EXTRA_MODLIST="$EXTRA_MODLIST $modtype:$modfilec"
48      MODULE_DIRS="$MODULE_DIRS $modtype"
49      APACHE_FAST_OUTPUT($modpath_current/Makefile)
50    done
51    if test ! -z "$EXTRA_MODLIST"; then
52      AC_MSG_RESULT(added:$EXTRA_MODLIST)
53    fi
54  ],
55  [ AC_MSG_RESULT(none) 
56  ])
57