# Choose the compiler you need

# Sun C++ 2.1
#C++      = /usr/lang/CC-2.1
#CPPFLAGS = -DYYERROR_VERBOSE -DSUPPORT_X11 
#C++FLAGS = -O
#LDLIBS   = -lX11 -lm

# Sun C++ 3.0
#C++      = /usr/lang/CC
#CPPFLAGS = -DYYERROR_VERBOSE -DSUPPORT_X11 
#C++FLAGS = -O
#LDLIBS   = -lX11 -lm

# Sun C++ AT&T 2.0
#C++      = CC2
#CPPFLAGS = -DYYERROR_VERBOSE -DSUPPORT_X11 -DOLD_STYLE_CPP
#C++FLAGS = -O 
#LDLIBS   = -lX11 -lm

# Sun C++ AT&T 3.0
C++      = CC 
CPPFLAGS = -DYYERROR_VERBOSE -DSUPPORT_X11
C++FLAGS = -O
LDLIBS   = -lX11 -lm

# GNU g++ 2.2.2
#C++      = g++ 
#CPPFLAGS = -DYYERROR_VERBOSE -DSUPPORT_X11
#C++FLAGS = -O -finline-functions
#LDLIBS   = -lX11 -lm
 
# RS/6000 AIX 3.2, C++AT&T 2.0
#C++      = CC
#CPPFLAGS = -DYYERROR_VERBOSE -DSUPPORT_X11 -DOLD_STYLE_CPP 
#C++FLAGS = -O
#LDLIBS   = -lX11 -lm

# DEC C++ 1.0
#C++      = cxx
#CPPFLAGS = -DSUPPORT_X11
#C++FLAGS = -O
#LDLIBS   = -lX11 -lm

# DEC & g++ 2.2.2. You may need to compile yacc.C without the -O option.
#C++      = g++
#CPPFLAGS = -DYYERROR_VERBOSE -DSUPPORT_X11 -D__DECCXX
#C++FLAGS = -O
#LDLIBS   = -lX11 -lm

DEPEND   = mkdep
TARGET   = graphtal
PURIFY   = purify
YACC     = bison
YFLAGS   = -dt
LEX      = flex
LFLAGS   = -t

OTHERS = \
	X11_Window_icon rgb2rayshade.awk \
	colors.def colors.ray.def \
	graphtal.1 graphtal.cat mkdep \
	COPYRIGHT MANIFEST README \
	globals.h mathutilities.h boolean.h table.h \
	Primitives.h

GENSRCS = \
	yacc.C lex.C
NOHDR = \
	main.C
SRCS = 	\
	Hull.C Ray.C transform.C \
	Sphere.C Polygon.C Triangle.C Plane.C \
	Cone.C Cylinder.C \
	BaseWindow.C X11_Window.C \
	BBoxDevice.C Z_Buffer.C \
	LineDevice.C WireDevice.C FlatDevice.C ExampleDevice.C \
	Value.C Expression.C ExprItems.C Hash.C Color.C \
	Options.C DeviceDriver.C ViewTransform.C \
	Vector.C TransMatrix.C Turtle.C Interpreter.C \
	GeoObject.C \
	RayshadeDevice.C Error.C BoundingBox.C \
	ValueStack.C yyerror.C \
	LSystem.C Name.C Module.C \
	Predecessor.C Successor.C Production.C \
	list.C rcString.C 

OBJS     = $(GENSRCS:.C=.o) $(SRCS:.C=.o) $(NOHDR:.C=.o)
HEADERS  = $(SRCS:.C=.h)
TARFILES = \
	$(SRCS:%=graphtal/%) \
	$(HEADERS:%=graphtal/%) \
	$(NOHDR:%=graphtal/%) \
	$(OTHERS:%=graphtal/%)

#_________________________________________________________________ production

.SUFFIXES:	.C

$(TARGET): $(OBJS)
	$(C++) $(C++FLAGS) $(OBJS) -o $(TARGET) $(LDLIBS)

purify: $(OBJS)
	$(PURIFY) $(C++) $(C++FLAGS) $(OBJS) -o $(TARGET) $(LDLIBS)
     
.C.o:
	$(C++) -c $(CPPFLAGS) $(C++FLAGS) $< -o $@

#________________________________________________________________ housekeeping

clean:
	rm -f *~ $(OBJS) $(TARGET)

wc:    
	wc yacc.y lex.l $(SRCS) $(HEADERS) $(OTHERS) Makefile

tar:
	{ cd .. ; \
	  tar cvf graphtal.tar $(TARFILES) graphtal/lex.l \
		graphtal/yacc.y graphtal/Makefile \
		graphtal/Examples/* ;\
	}

tar2:
	{ cp Makefile Makefile.tmp ; \
	  cp Makefile2 Makefile ; \
	  cd .. ; \
	  tar cvf graphtal_no_bison_no_flex.tar $(TARFILES) \
		graphtal/lex.C graphtal/yacc.tab.h \
		graphtal/yacc.C graphtal/Makefile \
		graphtal/Examples/* ;\
	  cd graphtal ; \
	  mv Makefile.tmp Makefile ;\
	}

#	generate a list  of module dependencies, based on #include
#	and append them at the end of this Makefile.
depend:
	(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
	 $(DEPEND) yacc.C lex.C $(SRCS) $(NOHDR) | \
		sed 's/: \.\//: /; /\/usr\/include/d' \
	) >Makefile.new
	cp Makefile Makefile.bak
	cp Makefile.new Makefile
	rm -f Makefile.new

# DO NOT DELETE THIS LINE
