#	Makefile for bs, the Battleships game

VERSION=2.9

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

# DESTDIR support
DESTDIR = 

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

bs.6: bs.xml
	xmlto man bs.xml
bs.html: bs.xml
	xmlto html-nochunks bs.xml

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

cppcheck:
	cppcheck --template gcc --enable=all bs.c

install: bs.6 uninstall
	cp bs $(DESTDIR)/usr/bin
	cp bs.6 $(DESTDIR)/usr/share/man/man6/bs.6

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

SOURCES = README COPYING NEWS control bs.c Makefile bs.xml battleship.png 

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

release: bs-$(VERSION).tar.gz bs.html
	shipper -u -m -t; make clean

