# $Id: $

# We need to install the .config file ourselves because of a gacutil
# bug (https://bugzilla.novell.com/show_bug.cgi?id=363341)
monodir = $(libdir)/mono/pipi-sharp-0.0
if USE_CSHARP
noinst_DATA = pipi-sharp.dll pipi-sharp.dll.config test.exe
endif

pipi_sources = \
	$(srcdir)/AssemblyInfo.cs \
	$(srcdir)/Pipi.cs \
	$(srcdir)/Picture.cs

test_sources = \
	$(srcdir)/test.cs

EXTRA_DIST = $(pipi_sources) $(test_sources) \
	pipi-sharp.snk pipi-sharp.pc.in pipi-sharp.dll.config.in

pipi-sharp.dll: $(pipi_sources)
	$(GMCS) -debug -unsafe $(pipi_sources) -out:$@ -target:library \
	  -keyfile:$(srcdir)/pipi-sharp.snk

test.exe: $(test_sources) pipi-sharp.dll
	$(GMCS) -debug $(test_sources) -out:$@ -lib:./ \
	  -r:./pipi-sharp.dll

if USE_CSHARP
install-data-local:
	MONO_SHARED_DIR=$$HOME $(GACUTIL) -i pipi-sharp.dll \
	  -package pipi-sharp-0.0 -f -root $(DESTDIR)$(libdir)
	$(mkinstalldirs) $(DESTDIR)$(monodir)
	sed -e 's@target="[^"]*/@target="@' < pipi-sharp.dll.config > $(DESTDIR)$(monodir)/pipi-sharp.dll.config

uninstall-local:
	MONO_SHARED_DIR=$$HOME $(GACUTIL) -u pipi-sharp.dll, Version=0.0 \
	  -package pipi-sharp-0.0 || true
	rm -f $(DESTDIR)$(monodir)/pipi-sharp.dll.config
	rmdir $(DESTDIR)$(monodir) 2>/dev/null || true
endif

clean-local:
	rm -f *.exe *.dll *.mdb

