# ascii -- interactive ASCII reference

VERS=$(shell sed <ascii.spec -n -e '/Version: \(.*\)/s//\1/p')

CFLAGS = -O

ascii: ascii.c splashscreen.h nametable.h
	$(CC) -DREVISION=$(VERS) ascii.c -o ascii

splashscreen.h: splashscreen
	sed <splashscreen >splashscreen.h -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/.*/P("&");/' 

nametable.h: nametable
	sed <nametable >nametable.h -e '/^#/d' -e 's/^[A-Za-z ]*: */	/' -e 's/%%/    }, {/'

ascii.1: ascii.xml
	xmlto man ascii.xml 

ascii.html: ascii.xml
	xmlto html-nochunks ascii.xml 

clean:
	rm -f ascii ascii.o splashscreen.h nametable.h *.rpm *.tar.gz MANIFEST

install: ascii ascii.1
	cp ascii $(DESTDIR)/usr/bin/ascii
	cp ascii.1 $(DESTDIR)/usr/share/man/man1

uninstall:
	rm $(DESTDIR)/usr/bin/ascii
	rm $(DESTDIR)/usr/share/man/man1/ascii.1

SOURCES = README COPYING Makefile ascii.c ascii.xml ascii.spec splashscreen nametable ascii.cgi

# Assumes this is the trubnk of a Subversion repository
ascii-$(VERS).tar.gz: $(SOURCES) ascii.1
	@ls $(SOURCES) ascii.1 | sed s:^:ascii-$(VERS)/: >MANIFEST
	@(cd ..; ln -s trunk ascii-$(VERS))
	(cd ..; tar -czvf trunk/ascii-$(VERS).tar.gz `cat trunk/MANIFEST`)
	@(cd ..; rm ascii-$(VERS))

dist: ascii-$(VERS).tar.gz

release: ascii-$(VERS).tar.gz ascii.html
	shipper; rm -f CHANGES ANNOUNCE* ascii.html *.1 *.html *.rpm *.lsm
