#
#  This makefile was generated by genmake for sandro@babylon.roads.org
#  on Wed Mar 28 10:21:45 EST 2001.   You probably shouldn't edit it, but
#  it is organized so you can, if you don't have the corresponding
#  genmake script.
#

# These are automatic defaults.   Change them if you want.  You may
# need to add/remove comment characters if you make these (non)null. 
PROGRAM = yacc-n3
LIBRARY = 

# some -l parameters, if you need any, on the program
LDLIBS = 

# some .o and .a files to include in the program or archive, but
# which aren't handled normally by this makefile
LOCAL_LIBRARIES = 

EXTRA_INCLUDES = -I/home/sandro/src

CXXFLAGS = -g -Wall -Wno-unused $(EXTRA_INCLUDES)
CXXFLAGS_FAST = -g -O3 -Wall -DNDEBUG $(EXTRA_INCLUDES)
CFLAGS  += -g -pg $(EXTRA_INCLUDES)

SRCS=main.cc    parser.h  lexer.l  parser.y
OBJS= lexer.o main.o parser.o 
OBJS_FAST=lexer.fast.o main.fast.o parser.fast.o 

TARGET_ARCH=
SUFFIXES=.out .a .ln .o .c .cc .p .f .F .r .y .l .s .S .mod .sym .def .h .in         fo .dvi .tex .texinfo .cweb .web .sh .elc .el .cxx .fast.o
.SUFFIXES: $(SUFFIXES)
CXX = g++
CC = gcc
RM = rm -f
# LINK.cxx = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# COMPILE.cxx = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
# STANDARD: COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
COMPILE_FAST.cc = $(CXX) $(CXXFLAGS_FAST) $(CPPFLAGS) $(TARGET_ARCH) -c
COMPILE.c = $(CC) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
YACC = yacc
YFLAGS = -d
LEX = lex
TESTS = test*

# Something (g++ linking?) needs this!
#VIRTUAL_ROOT=/ 

# Sun Make wants this, I think
#
#.cxx:
#	$(LINK.cxx) -o $@@ $< $(LDLIBS)
#.cxx.o:
#	$(COMPILE.cxx) $(OUTPUT_OPTION) $<
#


# GNU Make wants this, I think

#  [ commented out until I see it wants it back again... ]
#%.cxx:
#
#%: %.cxx
#	$(LINK.cxx) $^ $(LOADLIBES) $(LDLIBS) -o $@@
#%.o: %.cxx
#	$(COMPILE.cxx) $< $(OUTPUT_OPTION)
#
#

#%.lex.c: %.l
#	$(LEX) $< -o $@@
#%.tab.c: %.y
#	$(YACC) -b % $<
#%.tab.h: %.y
#	$(YACC) -b % -d $<

#%.cc: %.y
#	$(YACC) -d -v $< 
#	mv -f y.tab.c $@

# done explicitely below

#
#%.cc: %.l
#	$(LEX) -o$@ $<

%.fast.o: %.cc
	$(COMPILE_FAST.cc) $< $(OUTPUT_OPTION)


################################################################

all:: $(PROGRAM) $(LIBRARY)
library:: $(LIBRARY)
program:: $(PROGRAM)
fast:: $(PROGRAM).fast

################################################################
$(PROGRAM): $(OBJS) $(LOCAL_LIBRARIES) 
	$(CXX) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS)  $(EXTRA_LOAD_FLAGS)

$(PROGRAM).fast: $(OBJS_FAST) $(LOCAL_LIBRARIES) 
	$(CXX) -o $@ $(OBJS_FAST) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS)  $(EXTRA_LOAD_FLAGS)


#
# The approach assumes that the module with main just will never bother
# to be linked in, because main will already be defined.  You could set up
# your modules in ways where this wont work...
#
#$(LIBRARY): $(OBJS)
#	$(RM) $@
#	ar crv $@ $(OBJS)
#	ranlib $@


clean::
	$(RM) *~ core print.ps Makefile.bak y.output y.tab.h 
	$(RM) $(PROGRAM) $(OBJS)
	$(RM) $(PROGRAM).fast $(OBJS_FAST)
	# total hack: we shouldn't be hard coding these!
	$(RM) _generated_*.cc

run: $(PROGRAM)
	$(PROGRAM)

print.ps: $(SRCS)
	sh -c '> print.ps; for x in $(SRCS) Makefile ; do pstext --title "" --scale 0.80 --font Courier-Bold >> print.ps < $$x; done'

wc::
	wc $(SRCS)

################################################################
#################   VERY P16-SPECIFIC HACKS ####################

backup::
	find . -name core -exec rm {} \;
	rm -rf doc/auto-html doc/public-auto-html
	sh -c 'SNAP=.snapshots/$(PROGRAM)-`date +%Y-%m-%d-%H%M%S`.tz; tar czf $$SNAP Makefile $(SRCS) $(TESTS) doc; scp $$SNAP al1:.snapshots; scp $$SNAP roads@roads.org:.snapshots; ssh al1 tar tzvf $$SNAP'

pubserv: $(PROGRAM)
	scp -p $(PROGRAM) babylon:/usr/local/src/gammaspace/installed-cgi

doc::	doc/auto-html/Home.html

doc/auto-html/Home.html: doc/doc.sod.m4
	cd doc; make

pubdoc:
	cd doc; make publish

y.tab.h: parser.o

parser.o: parser.y
	$(YACC) -d -v $< 
	mv -f y.tab.c _generated_parser.cc
	g++ -c -g _generated_parser.cc -o $@

lexer.o: lexer.l y.tab.h
	$(LEX) -t lexer.l > _generated_lexer.cc
	gcc -g -c _generated_lexer.cc -o lexer.o

parser.fast.o: parser.y
	$(YACC) -d -v $< 
	mv -f y.tab.c _generated_parser.fast.cc
	g++ $(CXXFLAGS_FAST) -c _generated_parser.fast.cc -o $@

lexer.fast.o: lexer.l y.tab.h
	$(LEX) -t lexer.l > _generated_lexer.fast.cc
	gcc $(CXXFLAGS_FAST) -c _generated_lexer.fast.cc -o lexer.fast.o

test: test-swap

test-swap: all
	(date; for x in ../../../2000/10/swap/test/*.n3; do  echo -n '** FILE' $$x '  '; ./$(PROGRAM) < $$x | wc -l; done; date)

# The rest is dependencies, but we don't use makedepend.

main.o: main.cc parser.h
main.fast.o: main.cc parser.h
