# src/bsd/jhs/bin/public/xearth4/Makefile Julian H. Stacey 1994 01 06
# See also ../tidy/
# See also ../xearth1/
# xearth4 was written years before xearth1, the numbers refer to images,
#	not some version number.

NAME=	time
PROG=   ${NAME}
.include <berklix_no_man.mk>

all:	# check

cleandir obj:
	true

clean:
	rm -f  test.tmp fixed.tmp

# APACHE_XEARTH_DIR  See comment in xearth4.sh
APACHE_XEARTH_DIR=/usr/local/www/data/virtual/berklix.net/tmp

FILES=
FILES+=	xearth_mercator_day.gif
FILES+= xearth_mercator_night.gif
FILES+= xearth_orthographic_day.gif
FILES+= xearth_orthographic_night.gif

install:
.if !exists(/site)	#{	Public & CDROM targets
	echo "No /site , probably within a chroot."
.endif                  #}
	-install -c -m 755 ${.CURDIR}/xearth4.sh \
		${DESTDIR}/usr/local/www/cgi-bin/${NAME}
	-install -c -m 755 ${.CURDIR}/xearth4.sh \
		${DESTDIR}/usr/local/www/cgi-bin/date
	@echo "JJLATER cgi-bin/date cludge till i figure why date to time alias doesnt work"
	mkdir -p	  ${DESTDIR}/${APACHE_XEARTH_DIR}
	chown www:www	  ${DESTDIR}/${APACHE_XEARTH_DIR}
	chmod 755	  ${DESTDIR}/${APACHE_XEARTH_DIR}
	for f in ${FILES} ; do					  \
	  touch		  ${DESTDIR}/${APACHE_XEARTH_DIR}/$$f	; \
	  chmod 644	  ${DESTDIR}/${APACHE_XEARTH_DIR}/$$f	; \
	  echo "JJLATER Why currently do both servers have 664" ; \
	  chown www:www	  ${DESTDIR}/${APACHE_XEARTH_DIR}/$$f	; \
	  done

# Not needed, kept as shell syntax example:
# APACHE_XEARTH_DIRV=/usr/local/www/data/virtual
# host=disp: /usr/local/www/data/virtual -> LN/virtual LN -> /site/usr/local/www/data
# DOMAINS=
# DOMAINS+= berklix.com
# DOMAINS+= berklix.de
# DOMAINS+= berklix.eu
# DOMAINS+= berklix.net
# DOMAINS+= berklix.org
# DOMAINS+= berklix.uk
# DOMAINS+= bsdpie.eu
# DOMAINS+= geoffharries.com
# DOMAINS+= surfacevision
# DOMAINS+= the-phoney-photon.com

#	  for d in ${DOMAINS} ; do					  \
#	    mkdir -p      ${DESTDIR}/${APACHE_XEARTH_DIRV}/$$d/tmp	; \
#	    chmod 775     ${DESTDIR}/${APACHE_XEARTH_DIRV}/$$d/tmp	; \
#	    chown www:www ${DESTDIR}/${APACHE_XEARTH_DIRV}/$$d/tmp	; \
#	    touch         ${DESTDIR}/${APACHE_XEARTH_DIRV}/$$d/tmp/$$f	; \
#	    chmod 664     ${DESTDIR}/${APACHE_XEARTH_DIRV}/$$d/tmp/$$f	; \
#	    chown www:www ${DESTDIR}/${APACHE_XEARTH_DIRV}/$$d/tmp/$$f	; \
#	    done ; \

# Before considering changing install, consider all these limitations:
#	- Although it would be nice to have one common tmp/ for xearth images,
#	  whichever domain called from, to ensure they get updated more often,
#	  I haven't found a way to do that. As:
#	- There are lots of things in top dir of eg
#		/site/usr/local/www/data/virtual/berklix.com,
#	  too many to want to link them all from
#		/usr/local/www/data/virtual/berklix.com.
#	- A collection of dirs data/virtual/*/tmp/ + data/tmp  with hard
#	  linked xearth images between each tmp/ will not work, as
#	  rdist6 will not transfer hard link links from host=disp,
#	  through gate to servers.
#	- symbolic links from each data/virtual/tmp/* to data/tmp would be
#	  ignored by httpd virtual domains.
#	- hard`links wont work on host=fire as /site != physical device of
#	  /usr/local/www/data/tmp

check:	${TIDY} ${XEARTH} Makefile /usr/local/bin/brackets
	@echo "Ensuring tmp/ exists for ./xearth4.sh"
	@# -./xearth4.sh | grep -v Content-type: | \
	@#	grep -v \\'^$\\' > ${.CURDIR}/test.tmp
	-./xearth4.sh | grep -v Content-type: > ${.CURDIR}/test.tmp
	@# - to avoid failing 4 x error on
	@#   ${APACHE_XEARTH_DIR}/tmp/day_orthographic.gif: Permission denied
	-${TIDY} -errors test.tmp
	@#echo -n  "JJLATER 9.1 gives a lot of warnings that 8.2 did not,"
	@#echo " so - added above."
	brackets test.tmp > /dev/null
	rm test.tmp

/usr/local/bin/brackets:
	cd ../brackets ; make install

debug:
	-make check
	cp test.tmp ${.CURDIR}/fixed.tmp
	-tidy -modify fixed.tmp
	@# fixed.tmp is to see where tidy would install things,
	@# but this file cannot be use, the shell must be hand edited.
.include <berklix.mk>	# Needed to support recursive make html from above.
