#	Makefile for bs, the Battleships game

VERSION=2.6

# Flags for use with the Linux ncurses package (recommended)
TERMLIB = -lncurses
CC = gcc

bs: bs.c
	$(CC) $(CFLAGS) -o bs bs.c $(TERMLIB)

bs.6: bs.xml
	xmlto man bs.xml

clean:
	rm -f bs bs.6 bs*.tar.gz bs*.rpm *~

install: bs.6 uninstall
	cp bs /usr/bin
	cp bs.6 /usr/share/man/man6/bs.6

uninstall:
	rm -f /usr/bin/bs /usr/share/man/man6/bs.6

SOURCES = READ.ME COPYING bs.c Makefile bs.xml bs.spec

bs-$(VERSION).tar.gz: $(SOURCES) bs.6
	@ls $(SOURCES) bs.6 | sed s:^:bs-$(VERSION)/: >MANIFEST
	@(cd ..; ln -s bs bs-$(VERSION))
	(cd ..; tar -czvf bs/bs-$(VERSION).tar.gz `cat bs/MANIFEST`)
	@(cd ..; rm bs-$(VERSION))

dist: bs-$(VERSION).tar.gz

RPMROOT=/usr/src/redhat
rpm: dist
	rpmbuild --define 'myversion $(VERSION)' -ta bs-$(VERSION).tar.gz
	cp $(RPMROOT)/RPMS/*/bs-$(VERSION)*.rpm .
	cp $(RPMROOT)/SRPMS/bs-$(VERSION)*.src.rpm .

