###########################################################################
#
# Makefile -- common-src/src/lib
# A component of the Greenstone digital library software
# from the New Zealand Digital Library Project at the
# University of Waikato, New Zealand.
#
# Copyright (C) 1999-2008  The New Zealand Digital Library Project
#
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
###########################################################################

#GSDL_DIR = ../../..
COMMON_DIR = ../..

INDEXERS_DIR = $(COMMON_DIR)/indexers
COMMON_PACKAGES_DIR = $(COMMON_DIR)/packages


USE_SQLITE = @USE_SQLITE@
ifeq ($(USE_SQLITE), 1)
SQLITE_INCLUDES = -I$(COMMON_PACKAGES_DIR)/sqlite/include
SQLITE_SOURCES = sqlitedbclass.cpp
SQLITE_OBJECTS = sqlitedbclass.o
SQLITE_DEFINES = -DUSE_SQLITE
else
SQLITE_INCLUDES = 
SQLITE_SOURCES = 
SQLITE_OBJECTS = 
SQLITE_DEFINES =
endif

USE_GDBM=@USE_GDBM@
ifeq ($(USE_GDBM), 1)
GDBM_SOURCES = gdbmclass.cpp
GDBM_OBJECTS = gdbmclass.o
GDBM_INCLUDES = -I$(COMMON_PACKAGES_DIR)/gdbm/include
GDBM_DEFINES = -DUSE_GDBM
else
GDBM_SOURCES = 
GDBM_OBJECTS =
GDBM_INCLUDES = 
GDBM_DEFINES =
endif

USE_JDBM=@USE_JDBM@
ifeq ($(USE_JDBM), 1)
JDBM_SOURCES = jdbmnaiveclass.cpp
JDBM_OBJECTS = jdbmnaiveclass.o
JDBM_DEFINES = -DUSE_JDBM
else
JDBM_SOURCES = 
JDBM_OBJECTS = 
JDBM_DEFINES =
endif

# Populated as neccesary by Extention projects
EXT_INCLUDES =
EXT_SOURCES =
EXT_OBJECTS =
EXT_DEFINES =

AR = ar
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ @ARCH_DEP_FLAGS@
DEFS = @DEFS@ $(GDBM_DEFINES) $(JDBM_DEFINES) $(SQLITE_DEFINES) $(EXT_DEFINES)
INCLUDES = -I. -I$(COMMON_DIR) $(GDBM_INCLUDES) $(SQLITE_INCLUDES) $(EXT_INCLUDES)
RANLIB = @RANLIB@


CXXCOMPILE = $(CXX) -c $(CXXFLAGS) $(DEFS) $(INCLUDES)


.SUFFIXES:
.SUFFIXES: .cpp .o
.cpp.o:
	$(CXXCOMPILE) $< 


SOURCES = \
	cfgread.cpp \
	cnfgable.cpp \
	cnfgator.cpp \
	dbclass.cpp \
	display.cpp \
	fileutil.cpp \
	$(GDBM_SOURCES) \
	$(JDBM_SOURCES) \
	gsdlsitecfg.cpp \
	gsdltimes.cpp \
	gsdltools.cpp \
	gsdlunicode.cpp \
	infodbclass.cpp \
	OIDtools.cpp \
	phrases.cpp \
	sqldbclass.cpp \
	$(SQLITE_SOURCES) \
	text_t.cpp \
	unitool.cpp \
	$(EXT_SOURCES)

OBJECTS = \
	cfgread.o \
	cnfgable.o \
	cnfgator.o \
	dbclass.o \
	display.o \
	fileutil.o \
	$(GDBM_OBJECTS) \
	$(JDBM_OBJECTS) \
	gsdlsitecfg.o \
	gsdltimes.o \
	gsdltools.o \
	gsdlunicode.o \
	infodbclass.o \
	OIDtools.o \
	phrases.o \
	sqldbclass.o \
	$(SQLITE_OBJECTS) \
	text_t.o \
	unitool.o \
	$(EXT_OBJECTS)

LIBRARY = gsdllib.a


# Default target: make gsdllib.a
all: $(LIBRARY)

gsdllib.a: $(OBJECTS)
	rm -f $(LIBRARY)
	$(AR) cru $(LIBRARY) $(OBJECTS)
	$(RANLIB) $(LIBRARY)

install:

clean:
	rm -f $(OBJECTS) $(LIBRARY)

distclean:
	rm -f $(OBJECTS) $(LIBRARY) Makefile

depend:
	makedepend -Y -- $(DEFS) $(INCLUDES) $(CXXFLAGS) -- $(SOURCES)
