#	PACKAGE:	SpatialIndex
#
# os: linux
# LN add/modif
# --- Macros -----------------------------------------------------------------

CCXX =		g++
LD = 		g++
INCLUDE =	-I../include
CCFLAGS =	${INCLUDE} -O2 -DLINKAGE= -fPIC
ARFLAGS = 	-rlcs
CP      =       cp
RM      =       rm -f
LIBNAME =	libSpatialIndex

LIBOBJS =       BitList.o\
                SpatialVector.o\
                SpatialIndex.o\
                SpatialInterface.o\
                SpatialEdge.o\
                SpatialException.o\
                SpatialConstraint.o\
                SpatialConvex.o\
                SpatialDomain.o\
		sqlInterface.o\
		VarCmp.o\
                instances.o

LIBDIR =	../lib
LINKLIB = 	$(LIBDIR)/${LIBNAME}.a

# --- Targets ----------------------------------------------------------------

# Build and install the library.

all : chklibd ${LINKLIB} share
lib : ${LINKLIB}

chklibd:
	@if test -d $(LIBDIR); then echo Library goes into $(LIBDIR); \
	else echo Creating library dir. $(LIBDIR) && mkdir $(LIBDIR); \
	fi

share:
#$(LD) -shared -o $(LIBDIR)/${LIBNAME}.so $(LIBOBJS)
	$(LD) -shared -o ${LIBNAME}.so $(LIBOBJS)

${LINKLIB} : ${LIBOBJS}
	${AR} ${ARFLAGS} $@ $?
#	rm -f *.o

# Clean without removing installed products.

tidy :
	- ${RM} ${LIBOBJS}

# Remove all files generated or installed by make.  

clean :	tidy
	- cd $(LIBDIR); ${RM} ${LIBNAME}.*


# --- Suffix Rules -----------------------------------------------------------

# First clear out the default suffixes, then declare our own and
# define the rules.

.SUFFIXES:
.SUFFIXES: .o .cpp

# Compiling C++ code.  The command lines are so long as to be useless.
# Use 'sxmake -terse' to suppress the echo of the compile command.

.cpp.o:
	@ echo compiling $<
	@ ${CCXX} -c ${CCFLAGS} $<

