CPP=g++
LD=gcc 

LIBS= -L. -lp4vasp -L../odpdom -lODP `fltk-config --use-gl --ldstaticflags` \
	-lpthread /opt/local/lib/libpython.dylib /usr/lib/libc.dylib \
	/usr/lib/libstdc++.6.dylib /usr/lib/libgcc_s.1.dylib

FLAGS= -Wall -DPY_DOMEXC_MODULE="\"p4vasp.ODPdom.\"" \
       -DCHECK=1 \
       -DVERBOSE=0 \
       -DNO_GL_LISTS_S \
       -DNO_THREADS \

CFLAGS= -g -O0 -fpic  -Wall $(FLAGS) `fltk-config --cxxflags` \
	-I/opt/local/include/python2.4 -Iinclude -I../odpdom/include \
	-I/usr/X11R6/include

SWIGFLAGS= -python -c++  $(FLAGS) -I../odpdom/include -Iinclude

SWIG = swig

LDFLAGS= -flat_namespace -undefined suppress

OBJECTS= Exceptions.o \
	 AtomtypesRecord.o \
	 AtomInfo.o \
	 vecutils3d.o \
	 vecutils.o \
	 utils.o \
	 domutils.o \
	 FArray.o \
	 Structure.o \
	 Chgcar.o \
	 ChgcarSmear.o \
	 Process.o \
	 VisFLWindow.o \
	 VisMain.o \
	 VisWindow.o \
	 VisEvent.o \
	 VisDrawer.o \
	 VisNavDrawer.o \
	 VisStructureDrawer.o \
	 VisStructureArrowsDrawer.o \
	 VisIsosurfaceDrawer.o \
	 ClassInterface.o \
	 VisSlideDrawer.o \
	 VisPrimitiveDrawer.o \
	 VisBackEvent.o 

PYLIBOBJECTS = $(OBJECTS) cp4vasp_wrap.o

all: _cp4vasp.so

%.o: %.cpp
	$(CPP) $(CFLAGS) -c $< -o $@
%.o: %.c 
	$(CPP) $(CFLAGS) -c $< -o $@
#cp4vasp_wrap.cpp: cp4vasp.i
#	$(SWIG) $(SWIGFLAGS) -o cp4vasp_wrap.cpp cp4vasp.i 
	
_cp4vasp.so: libp4vasp.a cp4vasp_wrap.o
	$(LD) $(LDFLAGS) -o _cp4vasp.so cp4vasp_wrap.o -bundle $(LIBS) 

testprog1: testprog1.o libp4vasp.a
	$(LD) -o testprog1 testprog1.o $(LIBS)
testprog2: testprog2.o libp4vasp.a
	$(LD) -o testprog2 testprog2.o $(LIBS)
viewer1: viewer1.o libp4vasp.a
	$(LD) -o viewer1 viewer1.o $(LIBS)
viewer2: viewer2.o libp4vasp.a
	$(LD) -o viewer2 viewer2.o $(LIBS) -ldl
viewer3: viewer3.o libp4vasp.a
	$(LD) -o viewer3 viewer3.o $(LIBS)

libp4vasp.a: $(OBJECTS)
	ar -r libp4vasp.a $(OBJECTS)
	ranlib libp4vasp.a
doc:
	doxygen Doxyfile

cleanwrap:
	-rm *_wrap.cpp
	-rm *.py
	-rm *.pyc

clean:
	-rm *.o
cleanall: clean
	-rm *.so *.a
	-rm testprog*
	-rm viewer1
	-rm viewer2
