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

#
# 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@

#
# Flags.
#

XTRALIBS= @XTRALIBS@
RUNPATHS= @RPATHS@

FLAGS = @DEBUG_FLAGS@ @ALL_ENABLED@ @ALL_INC@ $(STRINGS) $(IGNORE_MISSING_DATA)

CCFLAGS   = @CFLAGS@ $(FLAGS)

# Link flags and shared libs only
SUP_LIBS =  @ALL_LIB@

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

LDFLAGS= $(RUNPATHS) -L../.. -lmapserver $(SUP_LIBS) $(STATIC_LIBS)

LIBMAPSCRIPT_SHARED= libmapscript.@SO_EXT@
LD_SHARED= @LD_SHARED@

# END OF CONFIGURE----

#
# SWIG Stuff
#
SWIG= swig

#
# CSHARP Stuff
#
CSC= mcs

CC= @CC@

#
# --- You shouldn't have to edit anything else. ---
#
all: interface mapscript_so mapscript_csharp

sign:
	sn -k mapscript.snk

interface: ../mapscript.i
	$(SWIG) -csharp -namespace OSGeo.MapServer $(FLAGS) -o mapscript_wrap.c ../mapscript.i

mapscript_so: mapscript_wrap.c
	$(CC) -fpic -c $(CCFLAGS) mapscript_wrap.c
	$(LD_SHARED) mapscript_wrap.o -o $(LIBMAPSCRIPT_SHARED) $(LDFLAGS)

mapscript_csharp::
	$(CSC) /t:library /out:mapscript_csharp.dll *.cs config/AssemblyInfo.cs
	$(CSC) /r:mapscript_csharp.dll /out:shpdump.exe examples/shpdump.cs
	$(CSC) /r:mapscript_csharp.dll /out:shapeinfo.exe examples/shapeinfo.cs
	$(CSC) /r:mapscript_csharp.dll /out:drawmap.exe examples/drawmap.cs
	$(CSC) /r:mapscript_csharp.dll /out:inline.exe examples/inline.cs
	$(CSC) /r:mapscript_csharp.dll /out:drawquery.exe examples/drawquery.cs
	$(CSC) /r:mapscript_csharp.dll /r:System.Drawing.dll /out:getbytes.exe examples/getbytes.cs
	$(CSC) /r:mapscript_csharp.dll /out:HTMLtemplate.exe examples/HTMLtemplate.cs
	$(CSC) /r:mapscript_csharp.dll /out:RFC24.exe examples/RFC24.cs

dll_config: Makefile
	rm -rf mapscript_csharp.dll.config
	echo "<configuration>" >> mapscript_csharp.dll.config
	echo "<dllmap dll=\"mapscript\" target=\""mapscript"\">" >> mapscript_csharp.dll.config
	echo "</configuration>" >> mapscript_csharp.dll.config

clean:
	rm -rf edu *.o *.c *.cs *.@SO_EXT@ *.dll *.dll.config

test:
	LC_ALL=C mono ./shpdump.exe ../../tests/point.shp
	LC_ALL=C mono ./shapeinfo.exe ../../tests/point.shp
	LC_ALL=C mono ./inline.exe png24 inline_test.png
	LC_ALL=C mono ./getbytes.exe ../../tests/test.map test_csharp2.png
	LC_ALL=C mono ./RFC24.exe ../../tests/test.map

