# Makefile.in for installing WWW server calendar scripts
# This file is part of REMIND.
# Copyright (C) 1992-1997 by David F. Skoll
# Copyright (C) 1999-2007 by Roaring Penguin Software Inc.

# The complete path to where the scripts actually live, as seen by
# the UNIX operating system.
SCRIPTDIR = /var/www/cgi-bin

# Where the scripts live as seen by the web browser.
CGIDIR = /cgi-bin

# The complete path to the directory containing the HTML file "calendar.html".
#  This is a sample file containing links to all the scripts.  This path
# should be the path as seen by the UNIX operating system
HTMLDIR = /var/www/remind

# Where you stick images and CSS files, as seen by UNIX
IMAGEDIR = /var/www/remind/resources

# Where images are, as seen by web browers
IMAGEBASE = /remind/resources

# Set by configure - don't touch.
srcdir=@srcdir@
prefix=@prefix@
exec_prefix=@exec_prefix@
mandir=@mandir@
bindir=@bindir@
datadir=@datadir@
datarootdir=@datarootdir@

# Where do Remind and Rem2PS executables live?
REMIND = $(bindir)/remind
REM2PS = $(bindir)/rem2ps

# If your Web server requires CGI programs to have a .cgi suffix, use
# the next line.  Otherwise, comment it out
CGISUFFIX=.cgi

# Don't change stuff below here.
# --------------------------------------------------------------------

# Construct a rotten mean nasty sed script to do the dirty work
SEDSCRIPT = -e 's@%CGIDIR%@$(CGIDIR)@g' \
	    -e 's@%SCRIPTDIR%@$(SCRIPTDIR)@g' \
	    -e 's@%REMIND%@$(REMIND)@g' \
	    -e 's@%IMAGEBASE%@$(IMAGEBASE)@g' \
	    -e 's@%REM2PS%@$(REM2PS)@g' \
	    -e 's@cal_dispatch@cal_dispatch$(CGISUFFIX)@g' \
	    -e 's@rem2html@rem2html$(CGISUFFIX)@g'

SEDSCRIPT2 = -e 's@%CGIDIR%@$(CGIDIR)@g' \
	     -e 's@%SCRIPTDIR%@$(SCRIPTDIR)@g' \
	     -e 's@%REMIND%@$(REMIND)@g' \
	     -e 's@%IMAGEBASE%@$(IMAGEBASE)@g' \
	     -e 's@%REM2PS%@$(REM2PS)@g'

all:
	@echo "Edit the Makefile; then type 'make install' to install"
	@echo "the www server scripts."

# OK, it's abominable.  But it works...
install:
	-mkdir -p $(DESTDIR)$(SCRIPTDIR)
	-mkdir -p $(DESTDIR)$(HTMLDIR)
	cp calps hebdate hebps hebhtml moon sunrise sunset $(DESTDIR)$(SCRIPTDIR)
	sed $(SEDSCRIPT) < cal_dispatch-DIST  > $(DESTDIR)$(SCRIPTDIR)/cal_dispatch$(CGISUFFIX)
	sed $(SEDSCRIPT)  < hebdate.rem-DIST   > $(DESTDIR)$(SCRIPTDIR)/hebdate.rem
	sed $(SEDSCRIPT)  < moon.rem-DIST      > $(DESTDIR)$(SCRIPTDIR)/moon.rem
	sed $(SEDSCRIPT)  < sunrise.rem-DIST   > $(DESTDIR)$(SCRIPTDIR)/sunrise.rem
	sed $(SEDSCRIPT)  < sunset.rem-DIST    > $(DESTDIR)$(SCRIPTDIR)/sunset.rem
	sed $(SEDSCRIPT)  < calendar.html-DIST > $(DESTDIR)$(HTMLDIR)/calendar.html
	sed $(SEDSCRIPT)  < hebhtml  > $(DESTDIR)$(SCRIPTDIR)/hebhtml
	sed $(SEDSCRIPT2) < rem2html > $(DESTDIR)$(SCRIPTDIR)/rem2html$(CGISUFFIX)
	chmod 644 $(DESTDIR)$(SCRIPTDIR)/sunrise.rem
	chmod 644 $(DESTDIR)$(SCRIPTDIR)/moon.rem
	chmod 644 $(DESTDIR)$(SCRIPTDIR)/hebdate.rem
	chmod 644 $(DESTDIR)$(SCRIPTDIR)/sunset.rem
	chmod 644 $(DESTDIR)$(HTMLDIR)/calendar.html
	chmod 755 $(DESTDIR)$(SCRIPTDIR)/cal_dispatch$(CGISUFFIX)
	chmod 755 $(DESTDIR)$(SCRIPTDIR)/rem2html$(CGISUFFIX)
	chmod 755 $(DESTDIR)$(SCRIPTDIR)/calps $(DESTDIR)$(SCRIPTDIR)/hebdate \
	$(DESTDIR)$(SCRIPTDIR)/hebps $(DESTDIR)$(SCRIPTDIR)/moon \
	$(DESTDIR)$(SCRIPTDIR)/sunrise $(DESTDIR)$(SCRIPTDIR)/sunset \
        $(DESTDIR)$(SCRIPTDIR)/hebhtml \
        $(DESTDIR)$(SCRIPTDIR)/rem2html$(CGISUFFIX)

	-mkdir -p $(DESTDIR)$(IMAGEDIR)
	cp firstquarter.png fullmoon.png lastquarter.png newmoon.png rem-default.css $(DESTDIR)$(IMAGEDIR)
	chmod 644 $(DESTDIR)$(IMAGEDIR)/firstquarter.png \
        $(DESTDIR)$(IMAGEDIR)/fullmoon.png \
        $(DESTDIR)$(IMAGEDIR)/lastquarter.png \
        $(DESTDIR)$(IMAGEDIR)/newmoon.png \
	$(DESTDIR)$(IMAGEDIR)/rem-default.css





