Index: /trunk/thirds/cgic206/Makefile
===================================================================
--- /trunk/thirds/cgic206/Makefile	(revision 283)
+++ /trunk/thirds/cgic206/Makefile	(revision 284)
@@ -1,5 +1,5 @@
 OS:=$(shell uname -s)
 ifeq ($(OS),Darwin)
-	MACOS_CFLAGS=-arch i386 -arch ppc -arch x86_64
+	MACOS_CFLAGS=-arch $(shell uname -m)
 	LIBS= -L./ -lcgic /usr/lib/libfcgi.dylib
 else
Index: /trunk/zoo-kernel/Makefile.in
===================================================================
--- /trunk/zoo-kernel/Makefile.in	(revision 283)
+++ /trunk/zoo-kernel/Makefile.in	(revision 284)
@@ -2,5 +2,5 @@
 ifeq ($(OS),Darwin)
 	MACOS_LD_FLAGS=-lintl -framework SystemConfiguration -framework CoreFoundation
-	MACOS_CFLAGS=-arch i386 -arch ppc -arch x86_64
+	MACOS_CFLAGS=-arch $(shell uname -m)
 endif
 
Index: /trunk/zoo-kernel/ZOOMakefile.opts.in
===================================================================
--- /trunk/zoo-kernel/ZOOMakefile.opts.in	(revision 284)
+++ /trunk/zoo-kernel/ZOOMakefile.opts.in	(revision 284)
@@ -0,0 +1,25 @@
+OS:=$(shell uname -s)
+ifeq ($(OS),Darwin)
+	MACOS_LD_FLAGS=-lintl
+	MACOS_LD_NET_FLAGS=-framework SystemConfiguration -framework CoreFoundation
+	MACOS_CFLAGS=-arch $(shell uname -m)
+endif
+
+GDAL_CFLAGS=@GDAL_CFLAGS@
+GDAL_LIBS=@GDAL_LIBS@
+
+XML2CFLAGS=@XML2_CPPFLAGS@
+XML2LDFLAGS=@XML2_LDFLAGS@
+
+PYTHONCFLAGS=@PYTHON_CPPFLAGS@
+PYTHONLDFLAGS=@PYTHON_LDFLAGS@
+
+JS_ENABLED=@JS_ENABLED@
+JSCFLAGS=@JS_CPPFLAGS@
+JSLDFLAGS=@JS_LDFLAGS@
+ifeq ($(JS_ENABLED),-DUSE_JS)
+     JS_LDFLAGS=${ZRPATH}/zoo-kernel/ulinet.o ${ZRPATH}/zoo-kernel/service_internal_js.o -lcurl 
+endif
+
+ZOO_CFLAGS=-I${ZRPATH}/thirds/cgic206/ -I${ZRPATH}/zoo-kernel/
+ZOO_LDFLAGS=-lcrypto
Index: /trunk/zoo-kernel/configure.ac
===================================================================
--- /trunk/zoo-kernel/configure.ac	(revision 283)
+++ /trunk/zoo-kernel/configure.ac	(revision 284)
@@ -122,4 +122,8 @@
 	[PYTHON_PATH="$withval"; PYTHON_ENABLED="-DUSE_PYTHON"], [PYTHON_ENABLED=""])
 
+AC_ARG_WITH([python-version], 
+	[AS_HELP_STRING([--with-python-version=NUMBER], [To enable python support using a speficific version of python])], 
+	[PYTHON_VERS="$withval"], [PYTHON_VERS=""])
+
 
 if test -z "$PYTHON_ENABLED"
@@ -127,12 +131,12 @@
 	PYTHON_FILE=""
 else
-	PYTHONCONFIG="$PYTHON_PATH/bin/python-config"
+	PYTHONCONFIG="$PYTHON_PATH/bin/python${PYTHON_VERS}-config"
 	PYTHON_FILE="service_internal_python.o"
 	if test  "$PYTHON_PATH" = "yes"
 	then
 		# PHP was not specified, so search within the current path
-		AC_PATH_PROG([PYTHONCONFIG], [python-config])
-	else
-		PYTHONCONFIG="$PYTHON_PATH/bin/python-config"
+		AC_PATH_PROG([PYTHONCONFIG], [python${PYTHON_VERS}-config])
+	else
+		PYTHONCONFIG="$PYTHON_PATH/bin/python${PYTHON_VERS}-config"
 	fi
 
@@ -366,4 +370,4 @@
 
 AC_CONFIG_FILES([Makefile])
-#AC_CONFIG_FILES([ZOOMakefile.opts])
+AC_CONFIG_FILES([ZOOMakefile.opts])
 AC_OUTPUT
Index: /trunk/zoo-kernel/service.h
===================================================================
--- /trunk/zoo-kernel/service.h	(revision 283)
+++ /trunk/zoo-kernel/service.h	(revision 284)
@@ -502,5 +502,8 @@
     map* tmpMap=getMap(tmp,key);
     if(tmpMap==NULL){
-      addToMap(tmp,key,value);
+      if(tmp!=NULL)
+	addToMap(tmp,key,value);
+      else
+	tmp=createMap(key,value);
       tmpMap=getMap(tmp,key);
     }
Index: /trunk/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-kernel/service_internal.c	(revision 283)
+++ /trunk/zoo-kernel/service_internal.c	(revision 284)
@@ -1117,6 +1117,4 @@
       if(hasDefault!=true && strncmp(type,"Input",5)==0)
 	xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue"));
-      xmlFreeNodeList(nc5);
-      xmlFreeNodeList(nc4);
     }
     
@@ -2416,2 +2414,11 @@
 }
 
+int errorException(maps *m, const char *message, const char *errorcode) 
+{
+  map* errormap = createMap("text", message);
+  addToMap(errormap,"code", errorcode);
+  printExceptionReportResponse(m,errormap);
+  freeMap(&errormap);
+  free(errormap);
+  return -1;
+}
Index: /trunk/zoo-kernel/service_internal.h
===================================================================
--- /trunk/zoo-kernel/service_internal.h	(revision 283)
+++ /trunk/zoo-kernel/service_internal.h	(revision 284)
@@ -121,5 +121,4 @@
   char* addDefaultValues(maps**,elements*,maps*,int);
 
-  /*defined in zoo_loader.c*/ 
   int errorException(maps *m, const char *message, const char *errorcode);
 
Index: /trunk/zoo-kernel/zoo_loader.c
===================================================================
--- /trunk/zoo-kernel/zoo_loader.c	(revision 283)
+++ /trunk/zoo-kernel/zoo_loader.c	(revision 284)
@@ -54,19 +54,4 @@
 
 using namespace std;
-
-/* ************************************************************************* */
-
-int errorException(maps *m, const char *message, const char *errorcode) 
-{
-  map* errormap = createMap("text", message);
-  addToMap(errormap,"code", errorcode);
-  printExceptionReportResponse(m,errormap);
-  freeMap(&errormap);
-  free(errormap);
-  return -1;
-}
-
-/* ************************************************************************* */
-
 
 #define TRUE 1
Index: /trunk/zoo-services/cgal/Makefile
===================================================================
--- /trunk/zoo-services/cgal/Makefile	(revision 283)
+++ /trunk/zoo-services/cgal/Makefile	(revision 284)
@@ -1,9 +1,10 @@
-CFLAGS=-I../../zoo-kernel/ -I./ `xml2-config --cflags` `python-config --cflags` -DLINUX_FREE_ISSUE #-DDEBUG
+ZRPATH=../../..
+include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
+CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/cgal_service.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/cgal_service.zo ./service.c -lgdal -lCGAL
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/cgal_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -lCGAL
 
 clean:
-	rm -f cgi-env/*.zo *.o *.tab.c *.tab.h *.sr.c* service_loader lex.* *.lreg *.sibling
-	rm -rf service_loader.dSYM
+	rm -f cgi-env/*.zo
Index: /trunk/zoo-services/gdal/grid/Makefile
===================================================================
--- /trunk/zoo-services/gdal/grid/Makefile	(revision 283)
+++ /trunk/zoo-services/gdal/grid/Makefile	(revision 284)
@@ -1,7 +1,9 @@
-CFLAGS=-I../../../zoo-kernel-svn/ -I./ `xml2-config --cflags` `python-config --cflags` -DLINUX_FREE_ISSUE #-DDEBUG
+ZRPATH=../../..
+include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
+CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/service.zo: service.c
-	g++  -DZOO_SERVICE ${CFLAGS} -shared -fpic -o cgi-env/gdal_grid_service.zo ./service.c -lgdal
+	g++  -DZOO_SERVICE ${CFLAGS} -shared -fpic -o cgi-env/gdal_grid_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS}
 
 clean:
Index: /trunk/zoo-services/gdal/grid/service.c
===================================================================
--- /trunk/zoo-services/gdal/grid/service.c	(revision 283)
+++ /trunk/zoo-services/gdal/grid/service.c	(revision 284)
@@ -879,14 +879,14 @@
       char *ext=new char[4];
       ext="tif";
-      if(strcmp(mtoupper((char*)pszFormat),"AAIGRID")==0)
+      if(strncasecmp(pszFormat,"AAIGRID",7)==0)
         ext="csv";
       else 
-        if(strcmp(mtoupper((char*)pszFormat),"PNG")==0)
+        if(strncasecmp(pszFormat,"PNG",3)==0)
           ext="png";
         else
-          if(strcmp(mtoupper((char*)pszFormat),"GIF")==0)
+          if(strncasecmp(pszFormat,"GIF",3)==0)
             ext="gif";
           else
-            if(strcmp(mtoupper((char*)pszFormat),"JPEG")==0)
+            if(strncasecmp(pszFormat,"JPEG",4)==0)
               ext="jpg";
       sprintf((char*)pszDest,"%s/%s.%s",tempPath,tmpMap->value,ext);
Index: /trunk/zoo-services/gdal/profile/Makefile
===================================================================
--- /trunk/zoo-services/gdal/profile/Makefile	(revision 283)
+++ /trunk/zoo-services/gdal/profile/Makefile	(revision 284)
@@ -1,7 +1,9 @@
-CFLAGS=-I../../../zoo-kernel/ -I./ `xml2-config --cflags` `python-config --cflags` -DLINUX_FREE_ISSUE #-DDEBUG
+ZRPATH=../../..
+include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
+CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/gdal_profile_service.zo: service.c
-	g++  -DZOO_SERVICE ${CFLAGS} -shared -fpic -o cgi-env/gdal_profile_service.zo ./service.c -lgdal
+	g++  -DZOO_SERVICE ${CFLAGS} -shared -fpic -o cgi-env/gdal_profile_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS}
 
 clean:
Index: /trunk/zoo-services/gdal/translate/Makefile
===================================================================
--- /trunk/zoo-services/gdal/translate/Makefile	(revision 283)
+++ /trunk/zoo-services/gdal/translate/Makefile	(revision 284)
@@ -1,9 +1,10 @@
-CFLAGS=-I../../../zoo-kernel-svn/ -I./ `xml2-config --cflags` `python-config --cflags` -DLINUX_FREE_ISSUE #-DDEBUG
+ZRPATH=../../..
+include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
+CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/service.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/service.zo ./service.c -lgdal
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS}
 
 clean:
-	rm -f *.zo *.o *.tab.c *.tab.h *.sr.c* service_loader lex.* *.lreg *.sibling
-	rm -rf service_loader.dSYM
+	rm -f cgi-env/*.zo
Index: /trunk/zoo-services/gdal/translate/service.c
===================================================================
--- /trunk/zoo-services/gdal/translate/service.c	(revision 283)
+++ /trunk/zoo-services/gdal/translate/service.c	(revision 284)
@@ -133,14 +133,14 @@
       char *ext=new char[4];
       ext="tif";
-      if(strcmp(mtoupper((char*)pszFormat),"AAIGRID")==0)
+      if(strncasecmp(pszFormat,"AAIGRID",7)==0)
 	ext="csv";
       else 
-	if(strcmp(mtoupper((char*)pszFormat),"PNG")==0)
+	if(strncasecmp(pszFormat,"PNG",3)==0)
 	  ext="png";
 	else
-	  if(strcmp(mtoupper((char*)pszFormat),"GIF")==0)
+	  if(strncasecmp(pszFormat,"GIF",3)==0)
 	    ext="gif";
 	  else
-	    if(strcmp(mtoupper((char*)pszFormat),"JPEG")==0)
+	    if(strncasecmp(pszFormat,"JPEG",4)==0)
 	      ext="jpg";
       sprintf((char*)pszDest,"%s/%s.%s",tempPath,tmpMap->value,ext);
Index: /trunk/zoo-services/ogr/base-vect-ops/Makefile
===================================================================
--- /trunk/zoo-services/ogr/base-vect-ops/Makefile	(revision 283)
+++ /trunk/zoo-services/ogr/base-vect-ops/Makefile	(revision 284)
@@ -1,9 +1,8 @@
-CFLAGS=-I../../../zoo-kernel/ -I./ `geos-config --cflags` `xml2-config --cflags`  `gdal-config --cflags`  -DLINUX_FREE_ISSUE #-DDEBUG
-# if JS_ENABLED flag is set to true in your ZOO-Kernel Makefile then you'll have
-# uncomment the following line
-# JS_LDFLAGS=../../../zoo-kernel/ulinet.o ../../../zoo-kernel/service_internal_js.o
+ZRPATH=../../..
+include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
+CFLAGS=${ZOO_CFLAGS} ${JSCFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} `geos-config --cflags` -DLINUX_FREE_ISSUE #-DDEBUG
 
 cgi-env/ogr_service.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/ogr_service.zo ./service.c ../../../zoo-kernel/service_internal.o ${JS_LDFLAGS} `xml2-config --libs` `gdal-config --libs` `geos-config --libs`
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/ogr_service.zo ./service.c ../../../zoo-kernel/service_internal.o ${JS_LDFLAGS} ${JSLDFLAGS} ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} `geos-config --libs`
 
 clean:
Index: /trunk/zoo-services/ogr/base-vect-ops/service.c
===================================================================
--- /trunk/zoo-services/ogr/base-vect-ops/service.c	(revision 283)
+++ /trunk/zoo-services/ogr/base-vect-ops/service.c	(revision 284)
@@ -44,4 +44,5 @@
   void printExceptionReportResponse(maps*,map*);
   char *base64(const char *input, int length);
+  int errorException(maps *m, const char *message, const char *errorcode);
 
   OGRGeometryH createGeometryFromGML(maps* conf,char* inputStr){
Index: /trunk/zoo-services/utils/status/Makefile
===================================================================
--- /trunk/zoo-services/utils/status/Makefile	(revision 283)
+++ /trunk/zoo-services/utils/status/Makefile	(revision 284)
@@ -1,9 +1,8 @@
-CFLAGS=-I../../../thirds/cgic206/ -I../../../zoo-kernel/ -I./ `xslt-config --cflags` `xml2-config --cflags` -lintl -lfcgi -lcrypto -DLINUX_FREE_ISSUE #-DDEBUG
-# if JS_ENABLED flag is set to true in your ZOO-Kernel Makefile then you'll have
-# uncomment the following line
-# JS_LDFLAGS=../../../zoo-kernel/ulinet.o ../../../zoo-kernel/service_internal_js.o
+ZRPATH=../../..
+include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
+CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 
 cgi-env/wps_status.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ../../../zoo-kernel/service_internal.o ${JS_LDFLAGS} `xml2-config --libs` `xslt-config --libs`
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ../../../zoo-kernel/service_internal.o ${JS_LDFLAGS} ${JSLDFLAGS} ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} `xslt-config --libs` -lfcgi
 
 clean:
