# Run ./configure in the main MapServer directory to turn this Makefile.in
# into a proper Makefile

prefix		=	@prefix@
exec_prefix	=	@exec_prefix@
INST_PREFIX	=	@exec_prefix@
INST_LIB	=	@libdir@
INST_BIN	=	@bindir@

#
# MS_VERSION - Set by configure based in map.h
#
MS_VERSION=	@MS_VERSION@

#
# Name of static and shared libs to produce
#
LIBMAP_STATIC=	libmap.a
LIBMAP_SHARED=	libmap.so
LIBMAP_SH_VER=	libmap.so.$(MS_VERSION)

#
# mpatrol runtime memory debugger
#
MPATROL=  	@MPATROL_ENABLED@
MPATROL_INC=	@MPATROL_INC@
MPATROL_LIB=	@MPATROL_LIB@

#
# If you want to ignore missing datafile errors uncomment the following
# line. This is especially useful with large tiled datasets that may not
# have complete data for each tile.
#
#IGNORE_MISSING_DATA=-DIGNORE_MISSING_DATA
IGNORE_MISSING_DATA = @IGNORE_MISSING_DATA@

#
# Apparently these aren't as commonplace as I'd hoped. Edit the
# following line to reflect the missing functions on your platform.
#
# STRINGS=-DNEED_STRCASECMP -DNEED_STRNCASECMP -DNEED_STRDUP -DNEED_STRLCAT
STRINGS= @STRINGS@

# Proj.4 distribution (cartographic projection routines). Not required for normal use. (EXPERIMENTAL)
PROJ_INC= @PROJ_INC@
PROJ_LIB= @PROJ_LIB@
PROJ=     @PROJ_ENABLED@

# GD distribution (graphics library GIF and/or PNG support). (REQUIRED)
#
#   - Versions 1.3 to 1.5 write non-LZW GIF (-DUSE_GD_1_3).
#   - Versions 1.6 and greater write PNG (-DUSE_GD_1_6). Add -lpng -lz to GD_LIB line.
#
#
GDFONT_OBJ=gd-1.2/gdfontt.o gd-1.2/gdfonts.o gd-1.2/gdfontmb.o gd-1.2/gdfontl.o gd-1.2/gdfontg.o
GD_INC=  @GD_INC@
GD_LIB=  @GD_LIB@
GD=      @GD_DEF@
GD_STATIC = @GD_STATIC@

# PDFlib distribution (PDF library w/ PDF support). (EXPERIMENTAL)
#
#
#
PDF_INC=  @PDF_INC@
PDF_LIB=  @PDF_LIB@
PDF=      @PDF_ENABLED@

# TIFF distribution (raster support for TIFF and GEOTIFF imagery). (RECOMMENDED)
TIFF_INC= @TIFF_INC@
TIFF_LIB= @TIFF_LIB@
TIFF=     @TIFF_ENABLED@

# JPEG distribution (raster support for grayscale JPEG images, INPUT ONLY).
JPEG_INC= @JPEG_INC@
JPEG_LIB= @JPEG_LIB@
JPEG=     @JPEG_ENABLED@

# EPPL7 Support (this activates ERDAS as well) Included in the distribution. Probably the best raster alternative if
# you've got EPPL7 laying around. See http://www.lmic.state.mn.us/ for more information. (RECOMMENDED)
EPPL=     @EPPL_ENABLED@
EPPL_OBJ= @EPPL_OBJ@

# ESRI SDE Support. You MUST have the SDE Client libraries and include files
# on your system someplace. The actual SDE server you wish to connect to can
# be elsewhere.
SDE=	  @SDE_ENABLED@
SDERASTER= @SDERASTER_ENABLED@
SDE_LIB=  @SDE_LIB@
SDE_INC=  @SDE_INC@

# Optional OGR Support.  OGC Simple Feature inspired interface for vector
# formats.  See http://ogr.maptools.org/
# Note that since OGR is part of the GDAL library, it uses GDAL_LIB + GDAL_INC
OGR=	  @OGR_ENABLED@

# Optional GDAL Support (provides read access to a variety of raster formats)
# See http://www.remotesensing.org/gdal/
GDAL=	  @GDAL_ENABLED@
GDAL_LIB=  @GDAL_LIB@
GDAL_INC=  @GDAL_INC@

# Optional GEOS Support.
# See http://geos.refractions.net/
GEOS=     @GEOS_ENABLED@
GEOS_LIB=  @GEOS_LIB@
GEOS_INC=  @GEOS_INC@

# Optional PostGIS Support.  See http://postgis.refractions.net/
POSTGIS=      @POSTGIS_ENABLED@
POSTGIS_LIB=  @POSTGIS_LIB@
POSTGIS_INC=  @POSTGIS_INC@

# Optional MyGIS Support.  See http://postgis.refractions.net/
MYGIS=      @MYGIS_ENABLED@
MYGIS_LIB=  @MYGIS_LIB@
MYGIS_INC=  @MYGIS_INC@

# Optional ORACLESPATIAL Support. Contact: cabral@cttmar.univali.br
ORACLESPATIAL=@ORACLESPATIAL_ENABLED@
ORACLESPATIAL_LIB=@ORACLESPATIAL_LIB@
ORACLESPATIAL_INC=@ORACLESPATIAL_INC@

# Optional MING/SWF/FLASH Support. Contact: assefa@dmsolutions.ca
MING=@MING_ENABLED@
MING_LIB=@MING_LIB@
MING_INC=@MING_INC@

# libcurl ... required for WMS/WFS Client Connections
CURL_INC=@CURL_INC@
CURL_LIB=@CURL_LIB@

# Optional FastCGI
FASTCGI=@FASTCGI_ENABLED@
FASTCGI_INC=@FASTCGI_INC@
FASTCGI_LIB=@FASTCGI_LIB@

# OWS: OGC Web Services support
# OGC WMS Server:  -DUSE_WMS_SVR (Requires PROJ4 support)
# OGC WMS Client Connections:  -DUSE_WMS_LYR (Requires PROJ4 and libcurl)
# OGC WFS Server: -DUSE_WFS_SVR (Requires OGR, PROJ4 recommended)
# OGC WFS Client: -DUSE_WFS_LYR (Requires OGR, PROJ4 and libcurl)
# OGC WCS Server: -DUSE_WCS_SVR (Requires GDAL and PROJ4)
OWS=@WMS_SVR_ENABLED@ @WMS_LYR_ENABLED@ @WFS_SVR_ENABLED@ @WFS_LYR_ENABLED@ @WCS_SVR_ENABLED@

#
# IMPORTANT NOTE ABOUT REGEX FOR PHP_MAPSCRIPT USERS:
#
# In order to compile the PHP_MAPSCRIPT module, we have to make MapServer
# uses the same version of the REGEX library that PHP was compiled with:
#
PHP_REGEX=@USE_PHP_REGEX@
REGEX_OBJ=@PHP_REGEX_OBJ@
REGEX_INC=@PHP_REGEX_INC@

#
# Multithreading support.
#
THREAD=@THREAD_FLAG@
THREAD_LIB=@THREAD_LIB@

#
# libiconv - Enables Internationalization
#
ICONV=@ICONV_ENABLED@
ICONV_LIB=@ICONV_LIB@
ICONV_INC=@ICONV_INC@

#
# Pick a compiler, etc. Flex and bison are only required if you need to modify the mapserver lexer (maplexer.l) or expression parser (mapparser.y).
#
CXX=	@CXX@
CC=     @CC@
LD=     @CC@
AR= ar rc
RANLIB= @RANLIB@
LEX=    @LEX@
YACC=   @YACC@

#
# This should really be figured out by configure
#
LD_SHARED = g++ -shared
LD_SONAME_LIBMAP= -Wl,-soname,$(LIBMAP_SH_VER)

XTRALIBS= @XTRALIBS@
RUNPATHS= @RPATHS@

CFLAGS= @CFLAGS@ @DEBUG_FLAGS@ \
        $(IGNORE_MISSING_DATA) $(STRINGS) $(EPPL) $(PROJ) $(OWS) $(MING) \
	$(ORACLESPATIAL) $(TIFF) $(JPEG) $(GD) $(PDF) $(SDE) $(SDERASTER) \
	$(OGR) $(GDAL) $(GEOS) $(ICONV) $(FASTCGI) $(PHP_REGEX) $(REGEX_INC) \
	$(POSTGIS) $(MYGIS) $(MPATROL) $(THREAD) $(GD_INC) $(PDF_INC) \
	$(PROJ_INC) $(TIFF_INC) $(JPEG_INC) $(EGIS_INC) $(SDE_INC) \
	$(MPATROL_INC) $(GDAL_INC) $(POSTGIS_INC) $(MYGIS_INC) \
	$(CURL_INC) $(MING_INC) $(ORACLESPATIAL_INC) $(GEOS_INC) $(ICONV_INC) \
	$(FASTCGI_INC)

# Link flags and shared libs only
SUP_LIBS =  $(GD_LIB) $(PDF_LIB) $(TIFF_LIB) $(PROJ_LIB) \
          $(JPEG_LIB) $(SDE_LIB) $(GDAL_LIB) $(MING_LIB) $(POSTGIS_LIB) \
	  $(MYGIS_LIB) $(CURL_LIB) $(ORACLESPATIAL_LIB) $(GEOS_LIB) \
	  $(MPATROL_LIB) $(THREAD_LIB) $(ICONV_LIB) $(FASTCGI_LIB) \
	  $(XTRALIBS)

# STATIC_LIBS is full filename with path of libs that will be statically linked
STATIC_LIBS= $(GD_STATIC)

EXE_LDFLAGS =	$(RUNPATHS) -L. -lmap $(SUP_LIBS) $(STATIC_LIBS)

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 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 $(EPPL_OBJ) $(REGEX_OBJ)

EXE_LIST = 	shp2img shp2pdf legend mapserv shptree shptreevis \
		shptreetst scalebar sortshp mapscriptvars tile4ms

#
# --- You shouldn't have to edit anything else. ---
#
.c.o:
	$(CC) -c $(CFLAGS) $< -o $@

all: $(MAKE_GD) libmap.a $(EXTRA_DEFAULT) $(EXE_LIST) @MAKE_PHPMS@ 

php3_mapscript:: $(LIBMAP_STATIC)
	cd mapscript/php3; $(MAKE); cd ../..

maplexer.o: maplexer.c map.h mapfile.h

maplexer.c: maplexer.l
	$(LEX) -Pmsyy -i -omaplexer.c maplexer.l

mapparser.o: mapparser.c map.h

mapparser.c: mapparser.y
	$(YACC) -p msyy -d -omapparser.c mapparser.y

mapogr.o: mapogr.cpp
	$(CXX) -c $(CFLAGS) mapogr.cpp -o mapogr.o

mapgeos.o: mapgeos.cpp
	$(CXX) -c $(CFLAGS) mapgeos.cpp -o mapgeos.o

lib:    $(LIBMAP_STATIC)
libmap: $(LIBMAP_STATIC)
libmap.a: map.h $(OBJS) map.h
	$(AR) $(LIBMAP_STATIC) $(OBJS)
	$(RANLIB) $(LIBMAP_STATIC)

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 map.h
	$(LD) $(CFLAGS) shp2pdf.o $(EXE_LDFLAGS) -o shp2pdf

shp2img: $(LIBMAP_STATIC)  shp2img.o map.h
	$(LD) $(CFLAGS) shp2img.o $(EXE_LDFLAGS) -o shp2img

sym2img: $(LIBMAP_STATIC)   sym2img.o map.h
	$(LD) $(CFLAGS) sym2img.o $(EXE_LDFLAGS) -o sym2img

legend: $(LIBMAP_STATIC)  legend.o map.h
	$(LD) $(CFLAGS) legend.o $(EXE_LDFLAGS) -o legend

scalebar: $(LIBMAP_STATIC)  scalebar.o map.h
	$(LD) $(CFLAGS) scalebar.o $(EXE_LDFLAGS) -o scalebar

mapserv: mapserv.h $(LIBMAP_STATIC)  mapserv.o cgiutil.o map.h
	$(LD) $(CFLAGS) mapserv.o cgiutil.o  $(EXE_LDFLAGS) -o mapserv

mapserv.fcgi: mapserv.h $(LIBMAP_STATIC)  mapserv_fcgi.o cgiutil.o map.h
	$(LD) $(CFLAGS) mapserv_fcgi.o cgiutil.o  \
		$(EXE_LDFLAGS) -lfcgi -o mapserv.fcgi

shpindex: $(LIBMAP_STATIC) shpindex.o map.h
	$(LD) $(CFLAGS) shpindex.o $(EXE_LDFLAGS) -o shpindex

shptree: $(LIBMAP_STATIC) shptree.o map.h
	$(LD) $(CFLAGS) shptree.o $(EXE_LDFLAGS) -o shptree

shptreevis: $(LIBMAP_STATIC) shptreevis.o map.h
	$(LD) $(CFLAGS) shptreevis.o $(EXE_LDFLAGS) -o shptreevis

shptreetst: $(LIBMAP_STATIC) shptreetst.o map.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

testexpr: testexpr.o mapparser.o maplexer.o
	$(LD) $(CFLAGS) testexpr.o $(EXE_LDFLAGS) -o testexpr

testcopy: $(LIBMAP_STATIC) testcopy.o mapcopy.o map.h
	$(LD) $(CFLAGS) testcopy.o $(EXE_LDFLAGS) -o testcopy

mapscriptvars:	Makefile
	touch mapscriptvars
	pwd > mapscriptvars
	echo $(IGNORE_MISSING_DATA) $(STRINGS) $(EPPL) $(PROJ) $(TTF) $(TIFF) $(JPEG) $(GD) $(SDE) $(OGR) $(GDAL) $(OWS) >> 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 MS_VERSION map.h >> mapscriptvars

php3_mapscript_clean::
	cd mapscript/php3; $(MAKE) clean; cd ../..

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

sorta-clean:
	rm -f *.o
