
EXTRA_DIST = pslib.i Makefile.PL example/phase2.pl example/data/*

clean-generic:
	rm -rf psLibModule

SRCDIR = $(shell cd $(top_srcdir) && pwd)
INCLUDES = -I$(SRCDIR)/src \
	-I$(SRCDIR)/src/astronomy \
	-I$(SRCDIR)/src/collections \
	-I$(SRCDIR)/src/dataManip \
	-I$(SRCDIR)/src/dataIO \
	-I$(SRCDIR)/src/image \
	-I$(SRCDIR)/src/sysUtils \
	-I/usr/include \
	-I/usr/local/include

####################################################
## PsLibModule swig build section.

CLEANFILES = psLibModule

psLibModule/Makefile.PL:
	if [ ! -d psLibModule ]; then mkdir psLibModule; fi
	cp -f $(srcdir)/Makefile.PL psLibModule/Makefile.PL

psLibModule/setup.txt:
	if [ ! -d psLibModule ]; then mkdir psLibModule; fi
	echo "includes=$(INCLUDES)" > psLibModule/setup.txt
	echo "ldflags=-L$(top_builddir)/src $(PSLIB_LIBS)" >> psLibModule/setup.txt
	echo "cflags=$(CFLAGS) -std=c99 -Wno-unused -Wno-strict-aliasing" >> psLibModule/setup.txt

psLibModule/pslib_wrap.c: $(srcdir)/pslib.i
	if [ ! -d psLibModule ]; then mkdir psLibModule; fi
	$(SWIG) -perl $(INCLUDES) -w451 -o $@ $(srcdir)/pslib.i

psLibModule/Makefile:psLibModule/Makefile.PL psLibModule/setup.txt
	cd psLibModule && $(PERL) Makefile.PL PREFIX=$(PERL_PREFIX)

all: swig

swig: psLibModule/pslib_wrap.c psLibModule/setup.txt psLibModule/Makefile
	cd psLibModule && make

swig-check: swig
	export PERLLIB=psLibModule:psLibModule/blib/arch/auto/pslib && perl -Mpslib -e 'print "pslib version = " . pslib::psLibVersion() . "\n";'

swig-install: swig
	cd psLibModule && make install

install-exec-hook: swig-install


