CC = @cc@
CXX = @cc@

ROOTDIR = @rootdir@
PREFIX = $(ROOTDIR)
INCDIR = $(PREFIX)/include
LIBDIR = $(PREFIX)/lib

CPPFLAGS =	-I. -I$(INCDIR)
#CXXFLAGS =	-g -Wall
CXXFLAGS =	-O2
LDFLAGS =	-L.

CP = @cp@
ECHO = @echo@
MKDEP = @mkdep@
MKDIR = @mkdir@
RANLIB = @ranlib@
RM = @rm@
TAR = @tar@

VERSION = @version@

MODULE =	c++
TESTOBJS =	array.t.o graph.t.o dynamic_pq.t.o dijkstra.t.o \
		singleton.t.o reference_pair.t.o auto_ptr.t.o limits.t.o
LIBOBJS =	GTL_connectivity.o
OBJS =	$(TESTOBJS) $(LIBOBJS)
SRCS =	$(OBJS:.o=.cc)
PROGS =	graph.t dynamic_pq.t dijkstra.t \
	singleton.t reference_pair.t auto_ptr.t limits.t
LIBCXXUTIL =	libcxxutil.a

INCLUDES =	GTL_connectivity.h \
		std_config.h \
		limits std_limits.h \
		auto_vector dp_auto_vector.h dp_auto_vector_inline.h \
		dp_auto_vector.cc \
		singleton dp_singleton.h dp_singleton_inline.h \
		array stl_array.h \
		refcount stl_refcount.h stl_refcount_inline.h \
		reference_pair stl_reference_pair.h \
		triplet stl_triplet.h \
		iterator_utility stl_iterator_utility.h \
		memory \
		dynamic_priority_queue stl_dynamic_priority_queue.h \
		graph stl_graph.h stl_graph_inline.h stl_graph.cc \
		stl_graph_stream.h stl_graph_stream.cc stl_graph_traits.h \
		stl_graph_tree.h stl_graph_tree_inline.h stl_graph_tree.cc \
		graphalg stl_graphalg.h

all:	$(LIBCXXUTIL)

$(LIBCXXUTIL):	$(LIBCXXUTIL)( $(LIBOBJS) )

install:	$(LIBCXXUTIL)
	$(MKDIR) $(INCDIR) $(LIBDIR)
	for f in $(INCLUDES); do \
		$(CP) $$f $(INCDIR)/$$f; \
	done
	$(CP) $(LIBCXXUTIL) $(LIBDIR)
	$(RANLIB) $(LIBDIR)/$(LIBCXXUTIL)

test:	all $(PROGS)

depend:
	@$(ECHO) "Depending source files."
	@$(MKDEP) -- $(CPPFLAGS) -- $(SRCS) 2> /dev/null
	@$(RM) Makefile.bak

graph.t:	graph.t.o $(LIBCXXUTIL) $(LIBDIR)/libGTL.a
dynamic_pq.t:	dynamic_pq.t.o
dijkstra.t:	dijkstra.t.o $(LIBCXXUTIL) $(LIBDIR)/libGTL.a
singleton.t:	singleton.t.o
reference_pair.t:	reference_pair.t.o
auto_ptr.t:	auto_ptr.t.o
limits.t:	limits.t.o
array.t:	array.t.o

clean:
	$(RM) *.out core *.core *~ \#*\# *.bak $(PROGS) $(LIBCXXUTIL) $(OBJS)

distclean:	clean
	$(RM) Makefile

dist:	distclean
	( cd ..; \
	  $(RM) $(MODULE)-$(VERSION).tar.gz; \
	  $(TAR) zcvf $(MODULE)-$(VERSION).tar.gz $(MODULE) )

snapshot:	distclean
	( cd ..; \
	  date=`date +'%y%m%d'`; \
	  $(RM) $(MODULE)-$${date}.tar.gz; \
	  $(TAR) zcvf $(MODULE)-$${date}.tar.gz $(MODULE) )
