all: units.rb

units.rb: units.racc
	racc units.racc -o units.rb
	(( echo ; echo '####################' ; echo 'if $$0 == __FILE__' ; tail -n +2 test.rb | ruby -p -e 'print "  "' ; echo 'end' )  >> units.rb)

test: units.rb
	ruby test.rb

backup: units.shar
	scp units.shar toyoda@www.gfd-dennou.org:tmp/
	scp units.shar toyoda@pandora0.sytes.net:tmp/

RSRCS = rules.rb version.rb node.rb namenode.rb utab.rb numbernode.rb \
   timenode.rb pownode.rb mulnode.rb shiftnode.rb lex.rb

utab.rb: makeutab.rb dcunits.txt
	ruby makeutab.rb dcunits.txt > $@.tmp
	mv $@.tmp $@

units.racc: $(RSRCS)
	cat $(RSRCS) > $@.tmp
	mv $@.tmp $@

edit:
	$${EDITOR:-vi} $(RSRCS)

SRCS = Makefile units.rb dcunits.txt makeutab.rb $(RSRCS) test.rb units.rd

shar: units.shar

units.shar: $(SRCS)
	shar $(SRCS) > units.shar
