

# CFLAGS=-O2 -march=i586 -Wall 
CC=gcc

all:	hecalc

parser.tab.o:	parser.y
	bison -d parser.y
	$(CC) $(CFLAGS) -c parser.tab.c 

lex.yy.o: scanner.l
	flex scanner.l
	$(CC) $(CFLAGS) -c lex.yy.c 

interpreter: interpreter.o 
	$(CC) $(CFLAGS) -c interpreter.c

hecalc:	lex.yy.o parser.tab.o interpreter 
	$(CC) lex.yy.o parser.tab.o interpreter.o -o hecalc -lfl -lm

clean:
	rm -f parser.tab.c lex.yy.c *.o *~ hecalc 


tests:	hecalc
	strip hecalc
	./maketests.pl
	hecalc -b < testin > testerg
	diff -Bw testdiff testerg


install:	clean	all	
	install -d /usr/local/bin
	cp hecalc /usr/local/bin
	install -d /usr/share/doc/packages/hecalc
	cp README /usr/share/doc/packages/hecalc
	rm -f parser.tab.c lex.yy.c *.o *~ hecalc 
	

lsm:
	(export VERSION=`perl -n -e '/"(.*)"/ && print $$1' hecalc-version.h` ; \
	export DATUM=`date +%D`; \
	cd ..; \
	echo "Begin3" > hecalc.lsm ; \
	echo "Title:          Application" >> hecalc.lsm ; \
	echo "Version:        $$VERSION" >> hecalc.lsm ; \
	echo "Entered-date:   $$DATUM" >> hecalc.lsm ; \
	echo "Description:    Taschenrechner fuer ausgeschriebene Zahlen, von eins bis centillion!, mit vielen eingebauten Funktionen." >> hecalc.lsm ; \
	echo "Keywords:       Rechner Calc Ausgeschriebene Zahlen centillion" >> hecalc.lsm ; \
	echo "Author:         Helmut Fahrion hefa@gmx.net" >> hecalc.lsm ; \
	echo "Maintained-by:  author" >> hecalc.lsm ; \
	echo "Primary-site:   ftp://hefa.gmxhome.de/linux/" >> hecalc.lsm ; \
	echo "Alternate-site: ftp://sunsite.unc.edu/pub/linux/apps/math/calc" >> hecalc.lsm ; \
	echo "Original-site:  ftp://hefa.gmxhome.de/linux/" >> hecalc.lsm ; \
	echo "Platforms:      Linux, Posix" >> hecalc.lsm ; \
	echo "Copying-policy: GPL" >> hecalc.lsm ; \
	echo "End" >> hecalc.lsm ; )



	
paket:	lsm
	(export CFLAGS="-O3 -march=i586"; make; \
	strip hecalc ; )
	rm -f parser.tab.c lex.yy.c *.o *~
	(export VERSION=`perl -n -e '/"(.*)"/ && print $$1' hecalc-version.h`;\
	cd ..; \
	tar jcf hecalc-$$VERSION.tar.bz2 hecalc-$$VERSION ; )

