bin_PROGRAMS = pswarp

if HAVE_SVNVERSION
PSWARP_VERSION=`$(SVNVERSION) ..`
else
PSWARP_VERSION="UNKNOWN"
endif

if HAVE_SVN
PSWARP_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`
PSWARP_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
else
PSWARP_BRANCH="UNKNOWN"
PSWARP_SOURCE="UNKNOWN"
endif

# Force recompilation of pswarpVersion.c, since it gets the version information
pswarpVersion.c: pswarpVersionDefinitions.h
pswarpVersionDefinitions.h: pswarpVersionDefinitions.h.in FORCE
	-$(RM) pswarpVersionDefinitions.h
	$(SED) -e "s|@PSWARP_VERSION@|\"$(PSWARP_VERSION)\"|" -e "s|@PSWARP_BRANCH@|\"$(PSWARP_BRANCH)\"|" -e "s|@PSWARP_SOURCE@|\"$(PSWARP_SOURCE)\"|" pswarpVersionDefinitions.h.in > pswarpVersionDefinitions.h
FORCE: ;

pswarp_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PSWARP_CFLAGS)
pswarp_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSWARP_LIBS)

pswarp_SOURCES = \
	pswarp.c			\
	pswarpArguments.c		\
	pswarpExit.c			\
	pswarpLoop.c			\
	pswarpDefine.c			\
	pswarpDefineSkycell.c		\
	pswarpErrorCodes.c		\
	pswarpMapGrid.c			\
	pswarpMatchRange.c		\
	pswarpParseCamera.c		\
	pswarpPixelsLit.c		\
	pswarpSetMaskBits.c		\
	pswarpSetThreads.c	        \
	pswarpTransformReadout.c	\
	pswarpTransformSources.c 	\
	pswarpTransformTile.c		\
	pswarpVersion.c            	\
	pswarpFiles.c

noinst_HEADERS = \
	pswarp.h \
	pswarpErrorCodes.h

clean-local:
	-rm -f TAGS

# Tags for emacs
tags:
	etags `find . -name \*.[ch] -print`

### Error codes.
BUILT_SOURCES = pswarpErrorCodes.h pswarpErrorCodes.c
CLEANFILES = pswarpErrorCodes.h pswarpErrorCodes.c

pswarpErrorCodes.h : pswarpErrorCodes.dat pswarpErrorCodes.h.in
	$(ERRORCODES) --data=pswarpErrorCodes.dat --outdir=. pswarpErrorCodes.h

pswarpErrorCodes.c : pswarpErrorCodes.dat pswarpErrorCodes.c.in pswarpErrorCodes.h
	$(ERRORCODES) --data=pswarpErrorCodes.dat --outdir=. pswarpErrorCodes.c
