
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.  

psLibModule:
	mkdir psLibModule

psLibModule/Makefile.PL: psLibModule
	cp -f $(srcdir)/Makefile.PL psLibModule/Makefile.PL

psLibModule/setup.txt:psLibModule Makefile
	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: psLibModule pslib.i
	$(SWIG) -perl $(INCLUDES) -w451 -o $@ $(srcdir)/pslib.i 

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

all: psLibModule psLibModule/pslib_wrap.c psLibModule/setup.txt psLibModule/Makefile.PL

swig: all 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
