# Makefile for gnatsweb
#
# $Id: Makefile,v 2.7 1999/07/27 16:03:23 kenstir Exp $

INSTALL_CGI =	gnatsweb.pl \
		gnatsweb-site-sente.pl
OTHER_FILES =	ChangeLog INSTALL Makefile README TODO \
		test.pl gnatsweb.html
INSTALL_ALL =	$(INSTALL_CGI) $(OTHER_FILES)

default:
	@echo "usage:"
	@echo
	@echo '    make test'
	@echo '    make install CGI_DIR=/home/httpd/cgi-bin'
	@echo
	@false

test:
	perl test.pl

install:
	if [ -z "$(CGI_DIR)" ]; then \
		echo 'The CGI_DIR macro is required:'; \
		echo ''; \
		echo '    make install CGI_DIR=/home/httpd/cgi-bin'; \
		echo ''; \
		exit 1; \
	else \
		tar -cf - $(INSTALL_CGI) \
			| (cd $(CGI_DIR); tar xvf -); \
	fi

#-----------------------------------------------------------------------------
# targets I use for development

# Extract the revision string from gnatsweb.pl into VERSION.
VERSION := $(shell perl -e '$$suppress_main=1; do "gnatsweb.pl"; print $$VERSION;')

no-debug-statements:
	if egrep -s 'debug = 1' gnatsweb.pl; then \
		echo '*** get rid of those debugging stmts, bonehead ***'; \
		exit 1; \
	else :; \
	fi

tarball: no-debug-statements
	rm -rf gnatsweb-$(VERSION)
	mkdir gnatsweb-$(VERSION)
	tar -cvf - $(INSTALL_CGI) $(OTHER_FILES) \
		| (cd gnatsweb-$(VERSION); tar xf -)
	tar -czf $$HOME/gnatsweb-$(VERSION).tar.gz gnatsweb-$(VERSION)
	rm -rf gnatsweb-$(VERSION)
	# now upload
	#ncftp -u ultranet

contrib: no-debug-statements test
	tar -cvf - $(INSTALL_CGI) $(OTHER_FILES) \
		| (cd $$HOME/src/gnats/gnats/contrib/gnatsweb; tar xf -)

TAGS: $(INSTALL_CGI)
	etags $(INSTALL_CGI)

install-snapshot: TAGS no-debug-statements
	$(MAKE) install CGI_DIR=..

install-tarball: TAGS tarball
	zcat gnatsweb-$(VERSION).tar.gz | (cd ..; tar xvf -)

link:
	rm -f gnatsweb-site.pl
	ln -s gnatsweb-site-sente.pl gnatsweb-site.pl
