#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Written (W) 2008 Fabio De Bona, Andre Noll, Gunnar Raetsch
# Copyright (C) 2008 Max-Planck-Society
#
#

PROJ=IntervalQuery

CFLAGS=-O3 -fPIC -g
CXXFLAGS=$(CFLAGS)
CC=g++

SRCS=IntervalQuery.cpp

OBJS = $(SRCS:%.cpp=%.o)

PY_INCL=`python-config --cflags`
PY_LIBS=`python-config --ldflags`

all: $(OBJS)
	@ echo "Creating swig interface..."
	swig -c++ -python ${PROJ}.i
	@ echo "Compiling sources..."
	$(CC) $(CFLAGS) $(PY_INCL) -c ${PROJ}_wrap.cxx -o ${PROJ}_wrap.o
	$(CC) $(CFLAGS) -shared $(PY_LIBS) $(OBJS) ${PROJ}_wrap.o -o _${PROJ}.so -dynamiclib
	python -c "import ${PROJ}" && echo "IntervalQuery was compiled sucessfully!"

test: all
	./make_test.sh

package:
	@ echo "Creating package..."
	rm -rf IntervalQuery/
	mkdir IntervalQuery
	cp $(SRCS) Makefile ${PROJ}.i IntervalQuery.h README IntervalQuery
	tar -cvf genefinding.tar IntervalQuery/
	gzip genefinding.tar

clean:
	rm -f *.o *.so *.cxx ${PROJ}.py *.pyc *.pyo
