DIRECTORY=PYTHON/EXTENSIONS/VIEW

# allow processing of SIP files
.SUFFIXES: .sip

# default target: the BALL Python extensions in BALLmodule.so
all: VIEWmodule.so

include ../../../common.mak

#A workaround for sip 4.8
CPP_MODE_FLAGS=${CPP_MODE_FLAGS/-pedantic/}

-include VIEW.sbf

SIP_SOURCES=\
	$(sources)

SIP_OBJECTS	=	\
	$(sources:.C=.$(OBJECT_EXTENSION))

SIP_HEADERS = \
	$(PYBALL_SOURCES:.C=.h) \

SIP_HEADER_FILES =\
	$(headers)

SIP_DIR=sip_files
SIP_OPTS=-c $(SIP_DIR) -e -I .. -s ".C"
SIPFLAGS = $(PYTHON_INCLUDES) $(SIP_INCLUDES)

ifndef (BALL_HAS_ASIO)
  SIP_OPTS+=-x BALL_HAS_ASIO
endif

SIP_OPTS+=-b VIEW.sbf

ADD_INCLUDES=$(SIPFLAGS) -I..

PYBALL_SOURCES = \
	pyCompositeList.C\
	pyBALLSipHelper.C\
	pyColorRGBAVector.C \
	pyDatasetVector.C

PYBALL_OBJECTS  = $(PYBALL_SOURCES:.C=.$(OBJECT_EXTENSION))

CPP_SOURCES = $(SIP_SOURCES:.h=.C) $(PYBALL_SOURCES)
CPP_OBJECTS = $(SIP_OBJECTS) $(PYBALL_OBJECTS)

LIBS=-lBALL -lVIEW $(QT_VIEW_LIBOPTS) $(OPENGL_LIBS)

VIEWmodule.so: sipVIEWcmodule.$(OBJECT_EXTENSION)

sip:
	@if test ! -d $(SIP_DIR) ; then mkdir $(SIP_DIR) 2>/dev/null ; fi
	@echo "running SIP..."
	@$(SIP) $(SIP_OPTS) VIEW.sip
	@echo "removing SIP headers..."
	@-$(RM) -f $(SIP_DIR)/tmp 2>/dev/null
	@for i in $(SIP_DIR)/*; do mv $$i $(SIP_DIR)/tmp ; cat $(SIP_DIR)/tmp |sed '/.*Generated by SIP /d' > $$i ; rm -rf $(SIP_DIR)/tmp 2>/dev/null ; done
	@echo "updating modified files..."
	@for i in $(SIP_DIR)/*; do if cmp -s $$i `basename $$i`; then true ; else echo " - $$i"; cp $$i . ; fi ; done

VIEWmodule.so:  $(CPP_OBJECTS)
	$(DYNAR) -L$(PREFIX)/lib -L$(BALL_PATH)/lib $(DYNAROPTS_PYMODULE) VIEWmodule.so $(CPP_OBJECTS) $(SIP_LIB) $(LIBS) $(PYTHON_LIBS)

install:	VIEWmodule.so
	$(CP) VIEWmodule.so  $(PREFIX)/lib

CLEAN_FILES = \
	VIEWmodule.so\
	$(CPP_OBJECTS) \
	$(PYBALL_LIBTOOL_OBJECTS) \
	$(SIP_LIBTOOL_OBJECTS) \
	$(SIP_SOURCES) \
	$(SIP_HEADERS) \
	$(SIP_HEADER_FILES) \
	$(SIP_OBJECTS)

clean:
	@echo "removing object files, libraries, and source/header files produced by SIP..."
	@-$(RM) -f $(CLEAN_FILES) 2>/dev/null
	@-$(RM) -f .libs/*
	@-$(RM) -fr $(SIP_DIR)

depend: sip

-include .Dependencies
