#
# SellaNMS
# Id: Makefile.in,v 2.12 2002/03/25 10:18:29 sella Exp 
# Copyright (c) 2001,2002 Digital Genesis Software, LLC. All Rights Reserved.
# Released under the GPL Version 2 License.
# http://www.digitalgenesis.com
#

# --------------------------------------
#                Source
# --------------------------------------

OBJS				= storage.o connection_pool.o loader.o check.o
EXTOBJS			= ../common/storagedata.o
SUBDIRS			= 
TARGET			=
LIBRARY			= libstorage
LIBRARY_MAJOR	= 0

# --------------------------------------
#                Programs
# --------------------------------------

CC					= @CC@
CXX				= @CXX@
CPP				= @CPP@
AR					= @AR@
RANLIB			= @RANLIB@
INSTALL			= @INSTALL@
SHELL				= @SHELL@
LN_S				= @LN_S@
SED				= @SED@
STRIP				= @STRIP@

# --------------------------------------
#                Flags
# --------------------------------------

MFLAGS			= SRCDIR=${SRCDIR}/..
DEFINES			= @DEFINES@ @DEFS@ -I$(SRCDIR) -I$(SRCDIR)/include -I$(SRCDIR)/libs @STLPORT@ @DBI_INCDIR@
CPPFLAGS			= @CPPFLAGS@
CFLAGS			= @CFLAGS@ $(CPPFLAGS)
CXXFLAGS			= @CXXFLAGS@ $(CPPFLAGS)
LDFLAGS			= -Wl,-export-dynamic @LDFLAGS@
LIBS				= -nostartfiles @LIBS@ @DBI_LIBDIR@
VPATH				= .

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

.SUFFIXES: .c .cc .cxx .c++ .cpp .o
 
.c.o:
	$(CC) $(DEFINES) -c $(CFLAGS) $<
.cc.o:
	$(CXX) $(DEFINES) -c $(CXXFLAGS) $<
.cxx.o:
	$(CXX) $(DEFINES) -c $(CXXFLAGS) $<
.c++.o:
	$(CXX) $(DEFINES) -c $(CXXFLAGS) $<
.cpp.o:
	$(CPP) $(DEFINES) -c $(CPPFLAGS) $<

all: build

build: sanity $(OBJS) $(LIBRARY) $(TARGET)
	@SUBDIRS="$(SUBDIRS)"; \
	for DIR in $${SUBDIRS}; do \
		echo "@term_bold@==> $${DIR}@term_norm@"; \
		(cd $${DIR} && $(MAKE) $(MFLAGS) build) || exit 1; \
		echo "@term_bold@<== $${DIR}@term_norm@"; \
	done

$(TARGET): $(OBJS) $(EXTOBJS)
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(EXTOBJS) $(LIBS)
 
$(LIBRARY): $(LIBRARY).so $(LIBRARY).a
 
$(LIBRARY).so: $(LIBRARY).so.$(LIBRARY_MAJOR)
 
$(LIBRARY).so.$(LIBRARY_MAJOR): $(OBJS) $(EXTOBJS)
	$(CXX) -shared -Wall -Wl,-soname,$@ -o $@ $(OBJS) $(EXTOBJS) $(LIBS)
 
$(LIBRARY).a: $(OBJS) $(EXTOBJS)
	$(AR) cr $@ $(OBJS) $(EXTOBJS)
	$(RANLIB) $@

sanity:
	@test -z "$(SRCDIR)" && echo "Please build from the 'src' directory." && exit 1 || exit 0

docs:
	@echo "Not done yet.."

clean:
	rm -f $(TARGET) *.so.* *.a *.o
	-@SUBDIRS="$(SUBDIRS)"; \
	for DIR in $${SUBDIRS}; do \
		echo "@term_bold@==> $${DIR}@term_norm@"; \
		(cd $${DIR} && $(MAKE) $(MFLAGS) clean) || exit 1; \
	done

distclean:
	rm -f $(TARGET) *.so.* *.o Makefile
	-@SUBDIRS="$(SUBDIRS)"; \
	for DIR in $${SUBDIRS}; do \
		echo "@term_bold@==> $${DIR}@term_norm@"; \
		(cd $${DIR} && $(MAKE) $(MFLAGS) distclean) || exit 1; \
	done

depend:
	$(SED) -ne '1,/^# DEPENDENCIES/p' Makefile.in > Makefile.depend && \
	$(CXX) -MM ${OBJS:.o=.c*} $(DEFINES) >> Makefile.depend && \
	mv -f Makefile.depend Makefile.in || rm Makefile.depend
	-@SUBDIRS="$(SUBDIRS)"; \
	for DIR in $${SUBDIRS}; do \
		echo "@term_bold@==> $${DIR}@term_norm@"; \
		(cd $${DIR} && $(MAKE) $(MFLAGS) depend) || exit 1; \
		echo "@term_bold@<== $${DIR}@term_norm@"; \
	done

# --------------------------------------
#              Dependencies
# --------------------------------------

# DEPENDENCIES - DO NOT EDIT MANUALLY
storage.o: storage.cxx storage.h ../../config.h ../../include/defaults.h \
  ../../include/defines.h ../../include/stl.h ../../libs/common/trace.h \
  ../../include/stl/string ../../include/stl/vector \
  ../../include/stl/hash_map ../../libs/common/confignode.h \
  ../../include/stl/slist ../../include/stl/utility \
  ../../libs/common/storagedata.h connection_pool.h loader.h \
  ../../libs/common/util.h
connection_pool.o: connection_pool.cxx connection_pool.h ../../config.h \
  ../../include/defaults.h ../../include/defines.h ../../include/stl.h \
  ../../libs/common/trace.h ../../include/stl/string \
  ../../include/stl/vector ../../include/stl/hash_map \
  ../../libs/common/confignode.h ../../include/stl/slist \
  ../../include/stl/utility ../../libs/common/util.h
loader.o: loader.cxx loader.h ../../config.h ../../include/defaults.h \
  ../../include/defines.h ../../include/stl.h ../../libs/common/trace.h \
  ../../include/stl/string ../../include/stl/vector \
  ../../include/stl/hash_map connection_pool.h \
  ../../libs/common/confignode.h ../../include/stl/slist \
  ../../include/stl/utility
check.o: check.cxx check.h ../../config.h ../../include/defaults.h \
  ../../include/defines.h ../../include/stl.h ../../libs/common/trace.h \
  ../../include/stl/string ../../include/stl/vector \
  ../../include/stl/hash_map storage.h ../../libs/common/confignode.h \
  ../../include/stl/slist ../../include/stl/utility \
  ../../libs/common/storagedata.h connection_pool.h
