DIR = graph

.SUFFIXES : .cpp

.cpp.o:
	(cd ..; $(LINK_COMPILE.cpp) $(GNUFLAGS) $(DIR)/$<; mv $@ $(DIR))
STK_OBJECTS   = autogenSTkMethods/graphInitSTkFiles.o  \
		manualSTkMethods/graphManualSTkFiles.o  
## order established by lorder() and tsort().  cycles exist:
## tsort: cycle in data
## tsort: attrMethods.o
## tsort: graphTemplate.o
## tsort: Edge.o
## tsort: cycle in data
## tsort: attrMethods.o
## tsort: Graph.o
## tsort: Edge.o
SOURCES.cpp = \
	AdjacencyMatrix.cpp \
	Buckets.cpp \
	IncidenceMatrix.cpp \
	DBinGraph.cpp \
	DHyperGraph.cpp \
	UBinGraph.cpp \
	BinGraph.cpp \
	UHyperGraph.cpp \
	HyperGraph.cpp \
	Edge.cpp \
	attrMethods.cpp \
	Graph.cpp \
	Vertex.cpp \
	GraphObject.cpp \
	GraphBuild.cpp \
        LoadDimacsGraph.cpp \
        SaveDimacsGraph.cpp \
        parser.cpp \
        scanner.cpp \
        parseGraph.cpp \
	graphSpecializations.cpp \
	graphExplicitInstantiations.cpp

SOURCES.c = \
	nauty.c \
	nautil.c 
COBJECTS = \
	$(SOURCES.c:%.c=%.o)
OBJECTS = \
	$(SOURCES.cpp:%.cpp=%.o)
all:	objects
make_extra_stk:
	cd manualSTkMethods;  $(MAKE) -f Make.graphmanualSTkMethods init
	cd autogenSTkMethods; $(MAKE) -f Make.graphautogenSTkMethods \
		LINK_COMPILE.cpp="$(LINK_COMPILE.cpp)"\
		GNUFLAGS="$(GNUFLAGS)" all
	cd manualSTkMethods;  $(MAKE) -f Make.graphmanualSTkMethods \
		LINK_COMPILE.cpp="$(LINK_COMPILE.cpp)"\
		GNUFLAGS="$(GNUFLAGS)" all
parser.cpp y.tab.h: parser.y
	$(PARSE) --yacc -t -d parser.y
	mv y.tab.c parser.cpp
parser.o:	y.tab.h	parser.cpp
	(cd ..; $(LINK_COMPILE.cpp) -DYYDEBUG $(DIR)/parser.cpp; \
	mv $@ $(DIR))
scanner.cpp: scanner.l y.tab.h
	$(FLEX) scanner.l
	sed --file=win32.sed lex.yy.c > scanner.cpp
scanner.o:	y.tab.h	scanner.cpp
	(cd ..; $(LINK_COMPILE.cpp) -Igraph $(DIR)/scanner.cpp; \
	mv $@ $(DIR))
nauty.o:	nauty.c
	(cd ..; $(LINK_COMPILE.c) -Igraph $(DIR)/nauty.c; \
	mv $@ $(DIR))
nautil.o:	nautil.c
	(cd ..; $(LINK_COMPILE.c) -Igraph $(DIR)/nautil.c; \
	mv $@ $(DIR))
#scanner.o:	y.tab.h	scanner.cpp
#	(cd ..; $(LINK_COMPILE.cpp) -Igraph -D__EXTERN_C__ $(DIR)/scanner.cpp; \
#	mv $@ $(DIR))
../libLINKgraph.a: $(OBJECTS) $(COBJECTS) 
	ar cr ../libLINKgraph.a $(OBJECTS) $(COBJECTS)
	ranlib ../libLINKgraph.a
../libLINKgui.a: make_extra_stk
	ar cr ../libLINKgui.a $(STK_OBJECTS) 
	ranlib ../libLINKgui.a
objects: $(SOURCES.cpp) $(OBJECTS) $(COBJECTS)

win32-init:
	cd manualSTkMethods;  $(MAKE) -f Make.graphmanualSTkMethods init

clean:
	-$(RM) $(OBJECTS) $(COBJECTS)  $(STK_OBJECTS) 
	cd autogenSTkMethods; make -f Make.graphautogenSTkMethods clean
	cd manualSTkMethods; make -f Make.graphmanualSTkMethods clean
print:
	hsp -p $(SOURCES.cpp)
wc:
	wc $(SOURCES.cpp)
depend:
	makedepend -fMake.graph $(DEPENDFLAGS) $(SOURCES.cpp)
# DO NOT DELETE THIS LINE -- make depend depends on it.
