#	Makefile for bs, the Battleships game

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

# 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

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

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 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
