
#   Author: Paul Fitzpatrick, paulfitz@ai.mit.edu
#   Copyright (c) 2003 Paul Fitzpatrick
#
#   This file is part of CosmicOS.
#
#   CosmicOS is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   CosmicOS is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with CosmicOS; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

BASEDIR = $(shell pwd|sed "s|.*/||")
BASEFILE = $(shell pwd|sed "s|.*/||"|sed "s|\.|\-|g")

all: message-stripped.txt index.html

message-stripped.txt: cosmic.pl Makefile
	./cosmic.pl | tee cosmic.tmp.txt
	grep "\*\*\* " cosmic.tmp.txt | sed "s/\*\*\* //" | tee message-stripped.txt
	grep -v "\*\*\* " cosmic.tmp.txt | tee message-verbose.txt
	@rm -f cosmic.tmp.txt

index.html: Makefile COMMENTS.TXT makedoc.pl template.html cosmic.pl
	./makedoc.pl $(BASEDIR) $(BASEFILE) | tee index.html


install: message-stripped.txt index.html tar
        # copy to web page
	cp cosmic.pl $(HOME)/www/cosmic.pl.txt
	cp message-stripped.txt message-verbose.txt cosmic.tgz $(HOME)/www/
	cp COPYING $(HOME)/www/gnu.txt
	mkdir -p $(HOME)/www/cosmic/$(BASEDIR)
	cp $(BASEFILE).tgz index.html message-stripped.txt message-verbose.txt message-verbose.html $(HOME)/www/cosmic/$(BASEDIR)
	cp cosmic.pl $(HOME)/www/cosmic/$(BASEDIR)/cosmic.pl.txt


tar:
	rm -f *.tar *.tgz
	( cd ..; tar -cvvf $(BASEFILE).tar $(BASEDIR) )
	mv ../$(BASEFILE).tar .
	gzip $(BASEFILE).tar
	mv $(BASEFILE).tar.gz $(BASEFILE).tgz
	cp $(BASEFILE).tgz cosmic.tgz

clean:
	rm -f message-verbose.txt message-stripped.txt
	rm -f *.tar *.tgz *.gz

