# 04-Jan-00: adapted from:
# template Makefile for a trivial Swarm application. Copy and modify.
#   SWARMHOME points to the Swarm directory root
#   APPLICATION is the name of your program
#   OBJECTS are the .o files needed to link your program
#   APPLIBS are extra libs you need to link (-lspace, for instance)
# Then include Makefile.appl, and you're set!
# you should also write dependencies for each of your .o files to ensure
#   correct compilation.

ifeq ($(SWARMHOME),)
# please set your SWARMHOME in your environment or put it here:
SWARMHOME=
endif
BUGADDRESS=ralf@ark.in-berlin.de

APPLICATION=bell
OBJECTS=main.o Board.o Balls.o Nails.o Ball.o Nail.o Position.o StringRepresentation.o
APPLIBS=
APPDIR=$(APPLICATION)-0004

SOURCES=$(addsuffix .m, $(basename $(OBJECTS)))
HEADERS=$(addsuffix .h, $(basename $(OBJECTS)))
HEADERS:=$(filter-out main.h,$(HEADERS))
PATCHES:=$(shell noroots $(APPLICATION).nw | grep patch | sed 's/[<>]//g'\
| sort +1 -n -t-)

include $(SWARMHOME)/etc/Makefile.appl

#-include .depend

#.depend: $(SOURCES)
#	gcc -M -MG -D_GNU_SOURCE *.m >.depend 2>/dev/null

all: $(APPLICATION)

src:
	@echo extracting original source files
	@for i in $(SOURCES) $(HEADERS) $(PATCHES);\
		do notangle -R$$i $(APPLICATION).nw |cpif $$i;\
		done
	@for i in $(PATCHES); do echo $$i:; patch <$$i; done
	@echo done

dvi:
	@mkdir -p DVI
	rm -f $(APPLICATION).aux $(APPLICATION).toc
	noweave -n -x -latex $(APPLICATION).nw >body.tex
	latex $(APPLICATION).tex
	latex $(APPLICATION).tex
	latex $(APPLICATION).tex
	cp $(APPLICATION).dvi *.ps.gz *.ps.bb DVI

html:
	rm -rf $(APPLICATION) HTML
	mkdir HTML	
	noweave $(NOWEBOPTS) -latex+html $(APPLICATION).nw >body.tex
	latex2html -split 0 -no_navigation $(APPLICATION).tex
	cp $(APPLICATION)/$(APPLICATION).html $(APPLICATION)/*.png \
		$(APPLICATION)/$(APPLICATION).css HTML
	rm -rf $(APPLICATION)
	amaya HTML/$(APPLICATION).html

tarball:
	rm -rf $(APPDIR)
	mkdir $(APPDIR)
	cp *.h *.m *.png *.ps.* Makefile $(APPLICATION).tex\
		$(APPLICATION).nw README $(APPDIR)
	cp -dpR HTML DVI $(APPDIR)
	tar cvfz $(APPDIR).tar.gz $(APPDIR)
	rm -rf $(APPDIR)
