# VRML/PROGS/ray2vrml/Makefile
############################################################################

# use same configuration parameters as in parent directory
include ../../Config.common
include ../../Config.site

POOLSDIR = ../../POOLS
INCLUDIR = ../../include
LIBDIR = ../../lib
BINDIR = ../../bin

############################################################################
# No need to change anything below here
############################################################################
# the source files in this directory
CXXSOURCES = main.C scanner.C parser.C parser2.C
SOURCES = $(CXXSOURCES) $(CSOURCES)
OBJECTS = ${CXXSOURCES:.C=.o} ${CSOURCES:.c=.o}

THISDIRFLAGS = -I$(INCLUDIR) -I$(POOLSDIR)

#default target: compile
all: ray2vrml

# generate source file dependencies
depend: scanner.C parser.C
	$(MAKEDEPEND) $(MKDEPFLAGS) $(SOURCES) > deps

ray2vrml: $(OBJECTS)
	$(CXX) $(LDFLAGS) -o ray2vrml $(OBJECTS) \
		-L$(LIBDIR) -lxrml \
		-L$(POOLSDIR) -lpools \
		-lm
	-ln -sf `pwd`/ray2vrml $(BINDIR)

# Generate a C++ parser class that can coexist with other
# yacc/bison generated parsers in the same program.
parser.C: parser.bison
	bison -dyv  parser.bison
	mv y.tab.c parser.C
	mv y.tab.h tokens.H
	@echo "NOTE: Unless you tweaked bison, you need to manually edit the"
	@echo "bison generated parser.C file in order to get it compiled"
	@echo "without warnings or errors:"
	@echo "1) Delete the declaration of the YYSTYPE union"
	@echo "2) Delete the declaration of the global variables yylval, yychar and yynerrs"
	@echo "3) Delete the forward declaration of yyparse()"

# Generate a C++ lexical scanner class
scanner.C: scanner.flex parser.bison
	flex -p -Cfa -+ -oscanner.C scanner.flex

cleanhere: cleangen
	-${RM} ray2vrml y.* yy.*

clean: cleanhere

distclean: cleanhere

###############################################################################
# dependencies --- automatically generated with make depend !!
###############################################################################
-include deps