# makefile for FictionBook2 parser

#CC=gcc
#LD=ld
# swig need for developer
SWIG=swig
PYTHON=python
#`pkg-config --libs glib-2.0` `xml2-config --libs`

PYTHON_INCLUDES=`$(PYTHON) -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_inc(),'`

LIBS=`xml2-config --libs`
CFLAGS=`xml2-config --cflags`


all: fb2wrap.so

# create module
fb2wrap.so: fb2parser_wrap.o fb2parser.o
	$(LD) -shared $(LIBS) fb2parser_wrap.o fb2parser.o -o fb2wrap.so

# generated wrapper module code
fb2parser_wrap.o: fb2parser_wrap.c fb2parser.h
	$(CC) fb2parser_wrap.c -I $(PYTHON_INCLUDES) -c -g -Wall

# generated wrapper source code
fb2parser_wrap.c: fb2parser.i
	$(SWIG) -python fb2parser.i

# main code hier
fb2parser.o: fb2parser.c fb2parser.h
	$(CC) fb2parser.c -Wall -c -g $(CFLAGS) -o fb2parser.o

# test program
fb2parser: fb2parser.c fb2parser.h
	$(CC) fb2parser.c -Wall -g $(CFLAGS) $(LIBS) -o fb2parser

clean:
	rm -f *.o *.so core*
clean-swig:
	rm -f *.o *.so core* fb2parser_wrap.c fb2parser_wrap.doc
