diff -ur mapserver-5.0.2/configure.in mapserver-5.0.2-apache/configure.in
--- mapserver-5.0.2/configure.in	2007-10-20 01:13:46.000000000 +0200
+++ mapserver-5.0.2-apache/configure.in	2008-03-12 11:27:12.000000000 +0100
@@ -407,8 +407,13 @@
   dnl programs that don't need it, and saves us from having to figure some
   dnl black magic to detect what was used to build GD, etc.
   dnl Just doing the AC_CHECK_LIB(iconv ...) last does the trick.
-  AC_CHECK_LIB(c, iconv_open, ICONV_LIB="-L$ICONV_LIBDIR -lc",,"-L$ICONV_LIBDIR")
-  AC_CHECK_LIB(iconv, libiconv_open, ICONV_LIB="-L$ICONV_LIBDIR -liconv",,"-L$ICONV_LIBDIR")
+
+  if test -n "$ICONV_LIBDIR"; then
+    ICONV_LIBDIR="-L$ICONV_LIBDIR"
+  fi
+  AC_MSG_RESULT([ ICONV_LIBDIR zu "$ICONV_LIBDIR" gesetzt])
+  AC_CHECK_LIB(c, iconv_open, ICONV_LIB="$ICONV_LIBDIR -lc",,"$ICONV_LIBDIR")
+  AC_CHECK_LIB(iconv, libiconv_open, ICONV_LIB="$ICONV_LIBDIR -liconv",,"$ICONV_LIBDIR")
 
 fi
 
@@ -2021,148 +2026,7 @@
 
 AC_ARG_ENABLE(gcov,
 [  --enable-gcov           Enable source code coverage testing using gcov],
-[CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
- PHP_LD_XTRAFLAGS="$PHP_LD_XTRAFLAGS -fprofile-arcs -ftest-coverage"])
-
-
-dnl ---------------------------------------------------------------------
-dnl PHP/MapScript module options
-dnl ---------------------------------------------------------------------
-
-AC_CHECKING(for PHP/MapScript module options)
-AC_ARG_WITH(php,
-[  --with-php=DIR          Specify directory where PHP4's include files are
-                          installed (or a pointer to the full source tree)
-                          Required in order to compile the PHP/MapScript 
-                          module.],,)
-
-AC_ARG_ENABLE(internal-ld-detect,
-[  --enable-perlv-ld-detect (applies to --with-php only) 
-                          Use perl -V output to figure the command to use to 
-                          link php_mapscript.so.  Try this only if the default
-                          internal macro didn't work.],,)
-
-if test -n "$with_php" -a -d "$with_php" ; then
-  AC_EXPAND_PATH($with_php, PHP_SRC_DIR)
-  dnl
-  dnl Checks for shared library linking.
-  dnl
-  dnl Default to internal AC_LD_SHARED macro, or use the the perl-based 
-  dnl if requested and perl is available... 
-  dnl (The perl-V macro was the default in 3.6 and before but this was
-  dnl  changed in 3.7 to use the internal AC_LD_SHARED macro by default)
-  dnl
-
-  if test "$enable_perlv_ld_detect" = "yes" ; then
-      AC_MSG_RESULT(Using perl -V macro to figure ld command to link php_mapscript.so)
-
-      AC_MSG_CHECKING([whether 'perl -V' works])
-      if  (perl -V > /dev/null 2>&1)  ; then
-        AC_MSG_RESULT(yes)
-        AC_LD_SHARED_FROM_PERL
-        PHP_CC="$PERL_CC"
-        PHP_LD="$PERL_LD $PHP_LD_XTRAFLAGS"
-      else
-        AC_MSG_RESULT(no)
-        AC_MSG_ERROR([ERROR: Cannot use --enable-perlv-ld-detect since Perl -V does not work on this system.])
-      fi
-  else
-    dnl The default: use the internal AC_LD_SHARED macro
-    dnl
-    AC_COMPILER_PIC
-    dnl AC_LD_SHARED
-    AC_PHP_LD_SHARED
-    PHP_CC="$CC $C_PIC"
-    PHP_LD="$PHP_LD_SHARED $PHP_LD_XTRAFLAGS"
-  fi
-
-  dnl
-  dnl Look for PHP3's config.h or PHP4's php_config.h.
-  dnl We'll need the config file to find info about the PHP configuration
-  dnl
-  AC_MSG_CHECKING([for location of config.h or php_config.h])
-  dnl In PHP3, it was called config.h
-  test -f "$PHP_SRC_DIR/config.h" && PHP_CONFIG_H="$PHP_SRC_DIR/config.h"
-
-  dnl In PHP 4.0.1 to 4.0.3, it was php-4.0.x/php_config.h
-  test -f "$PHP_SRC_DIR/php_config.h" && PHP_CONFIG_H="$PHP_SRC_DIR/php_config.h"
-
-  dnl Starting with PHP 4.0.4, it's php-4.0.x/main/php_config.h
-  test -f "$PHP_SRC_DIR/main/php_config.h" && PHP_CONFIG_H="$PHP_SRC_DIR/main/php_config.h"
-
-  dnl If php was installed, then the headers are under $prefix/include/php/*
-  test -f "$PHP_SRC_DIR/include/php/main/php_config.h" && PHP_SRC_DIR="$PHP_SRC_DIR/include/php/" && PHP_CONFIG_H="$PHP_SRC_DIR/main/php_config.h"
-
-  if test -n "$PHP_CONFIG_H" ; then
-    AC_MSG_RESULT([$PHP_CONFIG_H])
-  else
-    AC_MSG_ERROR([
-!!! Could not find config.h or php_config.h in $PHP_SRC_DIR.          !!!
-!!! Has PHP been configured yet?                                      !!!])
-  fi
-
-  dnl
-  dnl Check which PHP version we're using.
-  dnl Default is PHP3, and if ZEND_API is set then we assume that we have PHP4.
-  dnl
-  AC_MSG_CHECKING([whether we have PHP3 or PHP4])
-  if test -n "`grep 'ZEND_API' $PHP_CONFIG_H`"  ; then
-    PHP_VERSION_FLAG="-DPHP4"
-  else
-    PHP_VERSION_FLAG="-DPHP3"
-    AC_MSG_ERROR([
-!!! PHP MapScript now requires PHP 4.1.2 or more recent.              !!!
-!!! Support for PHP3 has been dropped after MapServer version 3.5.    !!!])
-  fi
-  AC_MSG_RESULT([$PHP_VERSION_FLAG])
-
-  dnl
-  dnl Check if PHP was compiled with the bundled regex, and if so then
-  dnl use the same version to compile MapServer.
-  dnl
-  AC_MSG_CHECKING([whether we should use PHP's regex])
-  if test -n "`grep 'define REGEX 1' $PHP_CONFIG_H`"  ; then
-    AC_MSG_RESULT(yes)
-
-    dnl We'll check for regex_extra.h - that might let use build
-    dnl without the source using libphp_common.so
-    test -f "$PHP_SRC_DIR/regex/regex_extra.h" && PHP_NO_SOURCE="1"
-        if test -n "$PHP_NO_SOURCE" ; then
-          dnl Found regex_extra.h
-          USE_PHP_REGEX="-DUSE_PHP_REGEX"
-          PHP_REGEX_OBJ=php_regex.o
-          AC_MSG_RESULT([        found regex_extra.h - building PHP MapScript with PHP's bundled regex ])
-        else
-          AC_MSG_ERROR([
-!!! PHP uses its bundled regex library but regex/regex_extra.h cannot be !!!
-!!! found.                                                               !!!])
-	fi
-
-  else
-    AC_MSG_RESULT(no)
-  fi
-
-  PHPMS_MAKEFILE=mapscript/php3/Makefile
-  MAKE_PHPMS=php3_mapscript
-  MAKE_PHPMS_CLEAN=php3_mapscript_clean
-
-  AC_SUBST(PHP_VERSION_FLAG, $PHP_VERSION_FLAG)
-  AC_SUBST(PHP_SRC_DIR, $PHP_SRC_DIR)
-  AC_SUBST(PHP_CC, $PHP_CC)
-  AC_SUBST(PHP_LD, $PHP_LD)
-  AC_SUBST(PHP_REGEX_INC, $PHP_REGEX_INC)
-  AC_SUBST(PHP_REGEX_OBJ, $PHP_REGEX_OBJ)
-  AC_SUBST(USE_PHP_REGEX, $USE_PHP_REGEX)
-
-  AC_MSG_RESULT([        PHP/MapScript module configured.])
-elif test -n "$with_php" -a "$with_php" != "no" ; then
-  AC_MSG_ERROR([Missing or invalid PHP source directory in --with-php=DIR.])
-else
-  AC_MSG_RESULT([        PHP/MapScript module not configured.])
-fi
-
-AC_SUBST(MAKE_PHPMS, $MAKE_PHPMS)
-AC_SUBST(MAKE_PHPMS_CLEAN, $MAKE_PHPMS_CLEAN)
+[CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"])
 
 dnl ---------------------------------------------------------------------
 dnl Shared library building.
@@ -2175,39 +2039,21 @@
   AC_LD_SHARED
 fi
 
-dnl ---------------------------------------------------------------------
-dnl 'apxs' option for PHP built as an Apache module (libphp3.so)
-dnl --with-apxs[=FILE] should be the exact same value that was passed
-dnl   to the PHP configure command.
-dnl
-dnl All we need is to add the Apache include files to the php module
-dnl include path.
-dnl
 dnl The APXS variable also affects the way AC_ADD_RUNPATH() works
 dnl ---------------------------------------------------------------------
 
 AC_ARG_WITH(apxs,
-[  --with-apxs[[=FILE]]      (CURRENTLY DISABLED) 
-                          Use this option only if building the PHP MapScript
+[  --with-apxs[[=FILE]]   Use this option only if building the PHP MapScript
                           on a system where PHP was built as a shared Apache
                           module.  FILE is the optional pathname to the
                           Apache apxs tool; defaults to apxs.],,)
 
 if test -n "$with_apxs" -a "$with_apxs" != "no" ; then
 
-  AC_MSG_ERROR([
-!!! The current version of PHP MapScript requires PHP4 configured as  !!!
-!!! a CGI and cannot be used with PHP4 configured as an Apache module,!!!
-!!! so you cannot use the --with-apxs option.                         !!!
-!!! See: http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScriptCGI !!!])
+  AC_MSG_CHECKING([for location of Apache headers using apxs2])
 
-
-  AC_MSG_CHECKING([for location of Apache headers using apxs])
-  if test -z "$MAKE_PHPMS" ; then
-    AC_MSG_ERROR([--with-apxs applies only if --with-php is used.])
-
-  elif test "$with_apxs" = "yes" ; then
-    APXS=apxs
+  if test "$with_apxs" = "yes" ; then
+    APXS=apxs2
   else
     APXS="$with_apxs"
   fi
@@ -2227,24 +2073,14 @@
 dnl ---------------------------------------------------------------------
 
 AC_ARG_WITH(apache,
-[  --with-apache=DIR       (CURRENTLY DISABLED) 
-                          Use this option only if building the PHP MapScript
+[  --with-apache=DIR      Use this option only if building the PHP MapScript
                           on a system where PHP was built as an Apache
                           module statically linked into the httpd executable.
                           DIR is the path to the apache include files.],,)
 
 if test -n "$with_apache" -a "$with_apache" != "no" ; then
 
-  AC_MSG_ERROR([
-!!! The current version of PHP MapScript requires PHP4 configured as  !!!
-!!! a CGI and cannot be used with PHP4 configured as an Apache module,!!!
-!!! so you cannot use the --with-apache option.                       !!!
-!!! See: http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScriptCGI !!!])
-
   AC_MSG_CHECKING([for location of Apache headers])
-  if test -z "$MAKE_PHPMS" ; then
-    AC_MSG_ERROR([--with-apache applies only if --with-php is used.])
-  fi
 
   AC_EXPAND_PATH($with_apache, APACHE_DIR)
   test -f $APACHE_DIR/httpd.h && APACHE_INC_DIR="$APACHE_DIR"
@@ -2260,6 +2096,30 @@
 
 AC_SUBST(APACHE_INC, $APACHE_INC)
 
+dnl ---------------------------------------------------------------------
+dnl '--with-apr' option for the Apache module build 
+dnl ---------------------------------------------------------------------
+
+AC_ARG_WITH(apr,
+[  --with-apr=DIR         Use this option to specify the location of the
+                          headers of Apache's portable runtime library
+                          configuration tool apr-config],,)
+
+if test -n "$with_apr" -a "$with_apr" != "no" ; then
+
+  AC_MSG_CHECKING([for apr-config])
+  AC_EXPAND_PATH($with_apr, APR_DIR)
+  if test -x "$APR_DIR"; then
+    APR_INC=`$APR_DIR --includes`
+    CFLAGS="$CFLAGS -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -DLINUX=2 -D_REENTRANT`$APR_DIR --cflags`"
+    AC_MSG_RESULT("$APR_DIR")
+  else
+    AC_MSG_ERROR("Could not find apr-config in $APR_DIR")
+  fi
+fi
+
+AC_SUBST(APR_INC, $APR_INC)
+dnl ALL_ENABLED="$USE_NINT $ALL_ENABLED"
 
 dnl ---------------------------------------------------------------------
 dnl Check --enable-runpath to request including -Wl,-R for runtime
@@ -2322,7 +2182,7 @@
 AC_SUBST(ALL_STATIC_LIB, $ALL_STATIC_LIB)
 AC_SUBST(RPATHS, [$RPATHS])
 
-AC_OUTPUT(Makefile $PHPMS_MAKEFILE mapscript/java/Makefile mapscript/csharp/Makefile)
+AC_OUTPUT(Makefile)
 
 dnl ---------------------------------------------------------------------------
 dnl Display configuration status
@@ -2372,11 +2232,7 @@
 AC_MSG_RESULT([  SOS Server:                ${SOS_SVR_ENABLED}])
 AC_MSG_RESULT()
 
-AC_MSG_RESULT([ -------------- MapScript ----------------- ])
-if test -n "${PHP_SRC_DIR}"; then
-  AC_MSG_RESULT([  PHP MapScript:             yes])
-else
-  AC_MSG_RESULT([  PHP MapScript:             no])
-fi
-
+AC_MSG_RESULT([ -------------- OGC Services -------------- ])
+AC_MSG_RESULT([  Apache found:                ${APACHE_INC}])
+AC_MSG_RESULT([  Portable Runtime found:      ${APR_INC}])
 AC_MSG_RESULT()
diff -ur mapserver-5.0.2/Makefile.in mapserver-5.0.2-apache/Makefile.in
--- mapserver-5.0.2/Makefile.in	2007-08-22 18:27:43.000000000 +0200
+++ mapserver-5.0.2-apache/Makefile.in	2008-03-12 11:30:52.000000000 +0100
@@ -163,10 +163,8 @@
 XML2_INC=@XML2_INC@
 XML2_LIB=@XML2_LIB@
 
-# Optional FastCGI
-FASTCGI=@FASTCGI_ENABLED@
-FASTCGI_INC=@FASTCGI_INC@
-FASTCGI_LIB=@FASTCGI_LIB@
+APACHE_INC=@APACHE_INC@
+APR_INC=@APR_INC@
 
 # OWS: OGC Web Services support
 # OGC WMS Server:  -DUSE_WMS_SVR (Requires PROJ4 support)
@@ -229,7 +227,7 @@
 INCLUDES = $(REGEX_INC) $(GD_INC) $(AGG_INC) $(PDF_INC) $(PROJ_INC) $(TIFF_INC) $(JPEG_INC) $(EGIS_INC) \
         $(SDE_INC) $(GDAL_INC) $(POSTGIS_INC) $(MYGIS_INC) \
         $(CURL_INC) $(MING_INC) $(ORACLESPATIAL_INC) $(GEOS_INC) $(ICONV_INC) \
-        $(FASTCGI_INC) $(ZLIB_INC) $(XML2_INC)
+        $(FASTCGI_INC) $(ZLIB_INC) $(XML2_INC) ${APACHE_INC} ${APR_INC}
 
 FLAGS = @DEBUG_FLAGS@ $(DEFINES) $(INCLUDES)
 
@@ -250,16 +248,12 @@
 
 RM= /bin/rm -f
 
-OBJS= maptemplate.o mapbits.o maphash.o mapshape.o mapxbase.o mapparser.o maplexer.o maptree.o mapsearch.o mapstring.o mapsymbol.o mapfile.o maplegend.o maputil.o mapscale.o mapquery.o maplabel.o maperror.o mapprimitive.o mapproject.o mapraster.o mapsde.o mapogr.o mappostgis.o mapmygis.o maplayer.o mapresample.o mapwms.o mapwmslayer.o maporaclespatial.o mapgml.o mapprojhack.o mapthread.o mapdraw.o mapgd.o mapagg.o mapoutput.o mapgdal.o mapswf.o mapimagemap.o mapows.o mapwfs.o mapwfslayer.o mapcontext.o maphttp.o mapdrawgdal.o mappdf.o mapjoin.o mapgraticule.o mapcopy.o mapogcfilter.o mapogcsld.o maptime.o mapwcs.o mapcpl.o cgiutil.o maprasterquery.o mapobject.o mapgeos.o classobject.o layerobject.o mapio.o mappool.o mapsvg.o mapregex.o mappluginlayer.o mapogcsos.o mappostgresql.o mapcrypto.o mapowscommon.o mapdebug.o mapchart.o maptclutf.o $(EPPL_OBJ) $(AGG_FT_OBJ)
-
-EXE_LIST = 	shp2img shp2pdf legend mapserv shptree shptreevis \
-		shptreetst scalebar sortshp mapscriptvars tile4ms \
-		msencrypt mapserver-config
+OBJS=maptemplate.o mapbits.o maphash.o mapshape.o mapxbase.o mapparser.o maplexer.o maptree.o mapsearch.o mapstring.o mapsymbol.o mapfile.o maplegend.o maputil.o mapscale.o mapquery.o maplabel.o maperror.o mapprimitive.o mapproject.o mapraster.o mapsde.o mapogr.o mappostgis.o mapmygis.o maplayer.o mapresample.o mapwms.o mapwmslayer.o maporaclespatial.o mapgml.o mapprojhack.o mapthread.o mapdraw.o mapgd.o mapagg.o mapoutput.o mapgdal.o mapswf.o mapimagemap.o mapows.o mapwfs.o mapwfslayer.o mapcontext.o maphttp.o mapdrawgdal.o mappdf.o mapjoin.o mapgraticule.o mapcopy.o mapogcfilter.o mapogcsld.o maptime.o mapwcs.o mapcpl.o cgiutil.o maprasterquery.o mapobject.o mapgeos.o classobject.o layerobject.o mapio.o mappool.o mapsvg.o mapregex.o mappluginlayer.o mapogcsos.o mappostgresql.o mapcrypto.o mapowscommon.o mapdebug.o mapchart.o maptclutf.o $(EPPL_OBJ) $(AGG_FT_OBJ)
 
 #
 # --- You shouldn't have to edit anything else. ---
 #
-all: $(MAKE_GD) libmapserver.a $(EXTRA_DEFAULT) $(EXE_LIST) @MAKE_PHPMS@ 
+all: $(MAKE_GD) mod_wms.la $(EXTRA_DEFAULT)
 
 #
 # Non-gnumake's don't seem to use this pattern rule, 
@@ -267,16 +261,16 @@
 # to change these, since the change is unlikely to stick.
 # 
 .c.o:
-	$(CC) -c $(CFLAGS) $< -o $@
+	libtool --silent --mode=compile $(CC) -c $(CFLAGS) $< -o $@
 
 mapogr.o:	mapogr.cpp
-	$(CXX) -c $(CXXFLAGS) mapogr.cpp -o mapogr.o
+	libtool --silent --mode=compile $(CXX) -c $(CXXFLAGS) mapogr.cpp -o mapogr.o
 
-agg_font_freetype.o: $(AGG_FT_DIR)/agg_font_freetype.cpp
-	$(CXX) -c $(CXXFLAGS) $(AGG_FT_DIR)/agg_font_freetype.cpp -o agg_font_freetype.o
+mapagg.o:       mapagg.cpp
+	libtool --silent --mode=compile $(CXX) -c $(CXXFLAGS) mapagg.cpp -o mapagg.o
 
-php3_mapscript:: $(LIBMAP_STATIC)
-	cd mapscript/php3; $(MAKE); cd ../..
+agg_font_freetype.o: $(AGG_FT_DIR)/agg_font_freetype.cpp
+	libtool --silent --mode=compile $(CXX) -c $(CXXFLAGS) $(AGG_FT_DIR)/agg_font_freetype.cpp -o agg_font_freetype.o
 
 maplexer.o: maplexer.c mapserver.h mapfile.h
 
@@ -288,127 +282,21 @@
 mapparser.c: mapparser.y
 	$(YACC) -p msyy -d -omapparser.c mapparser.y
 
-lib:    $(LIBMAP_STATIC)
-libmapserver: $(LIBMAP_STATIC)
-libmapserver.a: mapserver.h $(OBJS)
-	$(AR) $(LIBMAP_STATIC) $(OBJS)
-	$(RANLIB) $(LIBMAP_STATIC)
-	# We don't want to let the shared library get out of sync with the
-	# static library if it exists. 
-	if test -r $(LIBMAP_SHARED) ; then \
-	  make shared ; \
-	fi
-
-shared:	$(LIBMAP_SHARED)
-$(LIBMAP_SHARED):	$(LIBMAP_STATIC)
-	$(LD_SHARED) $(LD_SONAME_LIBMAP) -o $(LIBMAP_SH_VER) \
-		$(RUNPATHS) $(OBJS) $(SUP_LIBS) $(STATIC_LIBS) \
-	&& ln -f -s $(LIBMAP_SH_VER) $(LIBMAP_SHARED)
-
-shp2pdf: $(LIBMAP_STATIC) shp2pdf.o mapserver.h
-	$(LD) $(CFLAGS) shp2pdf.o $(EXE_LDFLAGS) -o shp2pdf
-
-shp2img: $(LIBMAP_STATIC)  shp2img.o mapserver.h
-	$(LD) $(CFLAGS) shp2img.o $(EXE_LDFLAGS) -o shp2img
-
-sym2img: $(LIBMAP_STATIC)   sym2img.o mapserver.h
-	$(LD) $(CFLAGS) sym2img.o $(EXE_LDFLAGS) -o sym2img
-
-legend: $(LIBMAP_STATIC)  legend.o mapserver.h
-	$(LD) $(CFLAGS) legend.o $(EXE_LDFLAGS) -o legend
-
-scalebar: $(LIBMAP_STATIC)  scalebar.o mapserver.h
-	$(LD) $(CFLAGS) scalebar.o $(EXE_LDFLAGS) -o scalebar
-
-mapserv: mapserv.h $(LIBMAP_STATIC)  mapserv.o cgiutil.o mapserver.h
-	$(LD) $(CFLAGS) mapserv.o cgiutil.o $(EXE_LDFLAGS) -o mapserv
-
-shpindex: $(LIBMAP_STATIC) shpindex.o mapserver.h
-	$(LD) $(CFLAGS) shpindex.o $(EXE_LDFLAGS) -o shpindex
-
-shptree: $(LIBMAP_STATIC) shptree.o mapserver.h
-	$(LD) $(CFLAGS) shptree.o $(EXE_LDFLAGS) -o shptree
-
-shptreevis: $(LIBMAP_STATIC) shptreevis.o mapserver.h
-	$(LD) $(CFLAGS) shptreevis.o $(EXE_LDFLAGS) -o shptreevis
-
-shptreetst: $(LIBMAP_STATIC) shptreetst.o mapserver.h
-	$(LD) $(CFLAGS) shptreetst.o $(EXE_LDFLAGS) -o shptreetst
-
-sortshp: sortshp.o
-	$(LD) $(CFLAGS) sortshp.o $(EXE_LDFLAGS) -o sortshp
-
-tile4ms: tile4ms.o
-	$(LD) $(CFLAGS) tile4ms.o $(EXE_LDFLAGS) -o tile4ms
-
-msencrypt: $(LIBMAP_STATIC) msencrypt.o mapserver.h
-	$(LD) $(CFLAGS) msencrypt.o $(EXE_LDFLAGS) -o msencrypt
-
-testexpr: testexpr.o mapparser.o maplexer.o
-	$(LD) $(CFLAGS) testexpr.o $(EXE_LDFLAGS) -o testexpr
-
-testcopy: $(LIBMAP_STATIC) testcopy.o mapcopy.o mapserver.h
-	$(LD) $(CFLAGS) testcopy.o $(EXE_LDFLAGS) -o testcopy
-
-test_mapcrypto: $(LIBMAP_STATIC) mapcrypto.c
-	$(CC) $(CFLAGS) mapcrypto.c -DTEST_MAPCRYPTO $(EXE_LDFLAGS) -o test_mapcrypto
-
-mapscriptvars:	Makefile
-	touch mapscriptvars
-	pwd > mapscriptvars
-	echo $(IGNORE_MISSING_DATA) $(USE_POINT_Z_M) $(STRINGS) $(EPPL) $(PROJ) $(TTF) $(TIFF) $(JPEG) $(GD) $(SDE) $(OGR) $(GDAL) $(GEOS) $(OWS) $(AGG) >> mapscriptvars
-	echo -I. $(PROJ_INC) $(GD_INC) $(TTF_INC) $(TIFF_INC) $(JPEG_INC) $(SDE_INC) $(OGR_INC) $(GDAL_INC) $(GEOS_INC) >> mapscriptvars
-	echo $(EXE_LDFLAGS) >> mapscriptvars
-	echo $(STATIC_LIBS) >> mapscriptvars
-	grep '#define MS_VERSION' mapserver.h >> mapscriptvars
-
-mapserver-config: Makefile
-	rm -f mapserver-config
-	echo '#!/bin/sh' > mapserver-config
-	echo 'CONFIG_LIBS="$(SUP_LIBS)"' >> mapserver-config
-	echo 'CONFIG_DEP_LIBS="$(LIBS)"' >> mapserver-config
-	echo 'CONFIG_CFLAGS="$(CFLAGS)"' >> mapserver-config
-	echo 'CONFIG_DEFINES="$(DEFINES)"' >> mapserver-config
-	echo 'CONFIG_INCLUDES="$(INCLUDES)"' >> mapserver-config
-	echo 'CONFIG_VERSION="'`grep '#define MS_VERSION' mapserver.h | sed 's/\"//g' | sed 's/#define MS_VERSION //'`'"' >> mapserver-config
-	cat mapserver-config.in >> mapserver-config
-	chmod a+x mapserver-config
+mod_wms.la: mapserver.h $(OBJS)
+	apxs -c -Wc,"${CFLAGS}" ${SUP_LIBS} ${STATIC_LIBS} mod_wms.c `echo ${OBJS}|sed 's/\.o/\.lo/g'`
 
-php3_mapscript_clean::
-	cd mapscript/php3; $(MAKE) clean; cd ../..
+#shared:	$(LIBMAP_SHARED)
+#$(LIBMAP_SHARED):	$(LIBMAP_STATIC)
+#	$(LD_SHARED) $(LD_SONAME_LIBMAP) -o $(LIBMAP_SH_VER) \
+#		$(RUNPATHS) $(OBJS) $(SUP_LIBS) $(STATIC_LIBS) \
+#	&& ln -f -s $(LIBMAP_SH_VER) $(LIBMAP_SHARED)
+#
+#mapserv: mapserv.h $(LIBMAP_STATIC)  mapserv.o cgiutil.o mapserver.h
+#	$(LD) $(CFLAGS) mapserv.o cgiutil.o $(EXE_LDFLAGS) -o mapserv
+#
 
 install:
-	@echo ""
-	@echo "***** MapServer Installation *****"
-	@echo "To install MapServer, copy the 'mapserv' file to your web server's cgi-bin "
-	@echo "directory."
-	@echo "If you use MapScript then see the documentation for your specific MapScript"
-	@echo "version for installation instructions."
-	@echo ""
-
-install-force:	all
-	cp $(EXE_LIST) $(INST_BIN)
-	if test -x $(LIBMAP_SHARED) ; then \
-	  cp $(LIBMAP_SH_VER) $(INST_LIB) ; \
-	  (cd $(INST_LIB) ; ln -f -s $(LIBMAP_SH_VER) $(LIBMAP_SHARED) ) ; \
-	fi
-
-uninstall:
-	(cd $(INST_BIN) && rm $(EXE_LIST) )
-	(cd $(INST_LIB) && rm $(LIBMAP_SH_VER) $(LIBMAP_SHARED) )
-
-clean: @MAKE_PHPMS_CLEAN@
-	rm -f $(LIBMAP_STATIC) $(LIBMAP_SHARED) $(LIBMAP_SH_VER) *.o $(EXE_LIST)
-
-exe-clean:
-	rm -f $(EXE_LIST)
-
-distclean:
-	$(MAKE) clean
-	rm config.*
-	if test -d autom4te.cache ; then \
-	  rm -f -r autom4te.cache ; \
-	fi
+	apxs -i mod_wms.la
 
-sorta-clean:
-	rm -f *.o
+clean:
+	rm -rf *.o *.lo *.la *.slo .libs
diff -ur mapserver-5.0.2/maperror.c mapserver-5.0.2-apache/maperror.c
--- mapserver-5.0.2/maperror.c	2007-08-31 05:30:07.000000000 +0200
+++ mapserver-5.0.2-apache/maperror.c	2008-03-11 14:18:08.000000000 +0100
@@ -26,6 +26,9 @@
  * DEALINGS IN THE SOFTWARE.
  ****************************************************************************/
 
+#include "httpd.h"
+#include "http_core.h"
+#include "http_log.h"
 #include "mapserver.h"
 #include "maperror.h"
 #include "mapthread.h"
@@ -42,6 +45,8 @@
 
 MS_CVSID("$Id: maperror.c 6757 2007-08-31 03:30:07Z tomkralidis $")
 
+#define msIO_setContentType( type ) ((request_rec*)(msIO_getHandler( stdout )->cbData))->content_type = type
+
 static char *ms_errorCodes[MS_NUMERRORCODES] = {"",
 						"Unable to access file.",
 						"Memory allocation error.",
@@ -461,7 +466,7 @@
 
   /* actually write the image */
   if(!filename) 
-      msIO_printf("Content-type: %s%c%c", MS_IMAGE_MIME_TYPE(format), 10,10);
+      msIO_setContentType( MS_IMAGE_MIME_TYPE(format) );
   msSaveImageGD(img, filename, format);
   gdImageDestroy(img);
 
diff -ur mapserver-5.0.2/mapobject.c mapserver-5.0.2-apache/mapobject.c
--- mapserver-5.0.2/mapobject.c	2008-01-07 16:43:27.000000000 +0100
+++ mapserver-5.0.2-apache/mapobject.c	2008-03-12 14:28:46.000000000 +0100
@@ -670,7 +670,7 @@
    
    Function to support mapscript mapObj::loadOWSParameters
    ========================================================================= */
-
+/*
 int msMapLoadOWSParameters(mapObj *map, cgiRequestObj *request,
                            const char *wmtver)
 {
@@ -687,3 +687,4 @@
 #endif
 }
 
+*/
diff -ur mapserver-5.0.2/maptemplate.c mapserver-5.0.2-apache/maptemplate.c
--- mapserver-5.0.2/maptemplate.c	2007-08-24 20:22:05.000000000 +0200
+++ mapserver-5.0.2-apache/maptemplate.c	2008-03-11 16:26:07.000000000 +0100
@@ -26,6 +26,9 @@
  * DEALINGS IN THE SOFTWARE.
  ****************************************************************************/
 
+#include "httpd.h"
+#include "http_core.h"
+#include "http_log.h"
 #include "maptemplate.h"
 #include "maphash.h"
 #include "mapserver.h"
@@ -38,6 +41,8 @@
 
 MS_CVSID("$Id: maptemplate.c 6698 2007-08-24 18:22:05Z tamas $")
 
+#define msIO_setContentType( type ) ((request_rec*)(msIO_getHandler( stdout )->cbData))->content_type = type
+
 char *processLine(mapservObj* msObj, char* instr, int mode);
 
 /*
@@ -3159,7 +3164,7 @@
   }
 
   if(papszBuffer && pszMimeType) {
-    sprintf(buffer, "Content-type: %s%c%c\n", pszMimeType, 10, 10);
+    msIO_setContentType( pszMimeType );
     /* sprintf(buffer, "<!-- %s -->\n",  msGetVersion());      */
 
     if(nBufferSize <= (int)(nCurrentSize + strlen(buffer) + 1)) {
@@ -3170,9 +3175,8 @@
     strcat((*papszBuffer), buffer);
     nCurrentSize += strlen(buffer);
   } else if(pszMimeType) {
-      msIO_printf("Content-type: %s%c%c", pszMimeType, 10, 10); /* write MIME header */
+      msIO_setContentType( pszMimeType ); /* write MIME header */
     /* printf("<!-- %s -->\n", msGetVersion()); */
-    fflush(stdout);
   }
 
   if(msObj->Map->web.header) {
diff -ur mapserver-5.0.2/mapwms.c mapserver-5.0.2-apache/mapwms.c
--- mapserver-5.0.2/mapwms.c	2008-01-23 15:27:25.000000000 +0100
+++ mapserver-5.0.2-apache/mapwms.c	2008-03-12 13:23:42.000000000 +0100
@@ -26,6 +26,9 @@
  * DEALINGS IN THE SOFTWARE.
  *****************************************************************************/
 
+#include "httpd.h"
+#include "http_core.h"
+#include "http_log.h"
 #include "mapserver.h"
 #include "maperror.h"
 #include "mapgml.h"
@@ -58,6 +61,8 @@
 int ogrEnabled = 0;
 #endif /* USE_OGR */
 
+#define msIO_setContentType( type ) ((request_rec*)(msIO_getHandler( stdout )->cbData))->content_type = type
+
 /*
 ** msWMSException()
 **
@@ -105,7 +110,7 @@
   }
   else if (strcasecmp(wms_exception_format, "WMS_XML") == 0) /* Only in V1.0.0 */
   {
-    msIO_printf("Content-type: text/xml%c%c",10,10);
+    msIO_setContentType( "text/xml" );
     msIO_printf("<WMTException version=\"1.0.0\">\n");
     msWriteErrorXML(stdout);
     msIO_printf("</WMTException>\n");
@@ -116,7 +121,7 @@
     if (nVersion <= OWS_1_0_7)
     {
       /* In V1.0.1 to 1.0.7, the MIME type was text/xml */
-      msIO_printf("Content-type: text/xml%c%c",10,10);
+      msIO_setContentType( "text/xml" );
 
       msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                                "MO", "encoding", OWS_NOERR,
@@ -130,7 +135,7 @@
     {
       /* In V1.1.0 and later, we have OGC-specific MIME types */
       /* we cannot return anything else than application/vnd.ogc.se_xml here. */
-      msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
+      msIO_setContentType( "application/vnd.ogc.se_xml" );
 
       msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                                "MO", "encoding", OWS_NOERR,
@@ -144,7 +149,7 @@
     }
     else /* 1.1.1 */
     {
-        msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
+        msIO_setContentType( "application/vnd.ogc.se_xml" );
 
         msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                                  "MO", "encoding", OWS_NOERR,
@@ -1068,7 +1073,7 @@
      msIO_fprintf(stdout, "<!-- WARNING: The layer name '%s' might contain spaces or "
                         "invalid characters or may start with a number. This could lead to potential problems. -->\n", 
                   lp->name);
-   msOWSPrintEncodeParam(stdout, "LAYER.NAME", lp->name, OWS_WARN,
+   msOWSPrintEncodeMetadata(stdout, &(lp->metadata), "MO", "name", OWS_NOERR,
                          "        <Name>%s</Name>\n", NULL);
 
    /* the majority of this section is dependent on appropriately named metadata in the LAYER object */
@@ -1544,9 +1549,9 @@
   }
 
   if (nVersion <= OWS_1_0_7)
-      msIO_printf("Content-type: text/xml%c%c",10,10);  /* 1.0.0 to 1.0.7 */
+      msIO_setContentType( "text/xml" ); /* 1.0.0 to 1.0.7 */
   else
-      msIO_printf("Content-type: application/vnd.ogc.wms_xml%c%c",10,10);  /* 1.1.0 and later */
+      msIO_setContentType( "application/vnd.ogc.wms_xml" ); /* 1.1.0 and later */
 
   msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                            "MO", "encoding", OWS_NOERR,
@@ -2071,9 +2076,7 @@
   if (img == NULL)
       return msWMSException(map, nVersion, NULL);
 
-  
-  msIO_printf("Content-type: %s%c%c",
-              MS_IMAGE_MIME_TYPE(map->outputformat), 10,10);
+  msIO_setContentType( MS_IMAGE_MIME_TYPE(map->outputformat) );
   if (msSaveImage(map, img, NULL) != MS_SUCCESS)
       return msWMSException(map, nVersion, NULL);
 
@@ -2296,7 +2299,7 @@
     /* MIME response... we're free to use any valid MIME type */
     int numresults = 0;
 
-    msIO_printf("Content-type: text/plain%c%c", 10,10);
+    msIO_setContentType( "text/plain" );
     msIO_printf("GetFeatureInfo results:\n");
 
     numresults = msDumpResult(map, 0, nVersion, feature_count);
@@ -2307,9 +2310,9 @@
              strcasecmp(info_format, "application/vnd.ogc.gml") == 0) {
 
     if (nVersion <= OWS_1_0_7)
-        msIO_printf("Content-type: text/xml%c%c", 10,10);
+        msIO_setContentType( "text/xml" );
     else
-        msIO_printf("Content-type: application/vnd.ogc.gml%c%c", 10,10);
+      msIO_setContentType( "application/vnd.ogc.gml" );
 
     msGMLWriteQuery(map, NULL, "GMO"); /* default is stdout */
 
@@ -2657,7 +2660,7 @@
      if (img == NULL)
       return msWMSException(map, nVersion, NULL);
 
-     msIO_printf("Content-type: %s%c%c", MS_IMAGE_MIME_TYPE(map->outputformat), 10,10);
+     msIO_setContentType( MS_IMAGE_MIME_TYPE(map->outputformat) );
      if (msSaveImage(map, img, NULL) != MS_SUCCESS)
        return msWMSException(map, nVersion, NULL);
 
@@ -2721,7 +2724,7 @@
         return msWMSException(map, nVersion, "LayerNotDefined");
     }
 
-    msIO_printf("Content-type: application/vnd.ogc.sld+xml%c%c",10,10);
+    msIO_setContentType( "application/vnd.ogc.sld+xml" );
     sld = msSLDGenerateSLD(map, -1);
     if (sld)
     {
@@ -2839,7 +2842,7 @@
 
       if ((status = msOWSMakeAllLayersUnique(map)) != MS_SUCCESS)
           return msWMSException(map, nVersion, NULL);
-      msIO_printf("Content-type: text/xml\n\n");
+      msIO_setContentType( "text/xml" );
       if ( msWriteMapContext(map, stdout) != MS_SUCCESS )
           return msWMSException(map, nVersion, NULL);
       /* Request completed */
@@ -2849,7 +2852,7 @@
            format && strcasecmp(format,  "image/txt") == 0)
   {
       /* Until someone adds full support for ASCII graphics this should do. ;) */
-      msIO_printf("Content-type: text/plain\n\n");
+      msIO_setContentType( "text/plain" );
       msIO_printf(".\n               ,,ggddY\"\"\"Ybbgg,,\n          ,agd888b,_ "
              "\"Y8, ___'\"\"Ybga,\n       ,gdP\"\"88888888baa,.\"\"8b    \""
              "888g,\n     ,dP\"     ]888888888P'  \"Y     '888Yb,\n   ,dP\""
@@ -2916,7 +2919,7 @@
     return msWMSFeatureInfo(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams);
   else if (strcasecmp(request, "DescribeLayer") == 0)
   {
-      msIO_printf("Content-type: text/xml\n\n");
+      msIO_setContentType( "text/xml" );
       return msWMSDescribeLayer(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams);
   }
 
