CC=@CC@
CFLAGS=@CFLAGS@ @DEFS@
LDFLAGS=@LDFLAGS@ @LIBS@

prefix=@prefix@
exec_prefix=@exec_prefix@
LOGDIR=@localstatedir@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
CGIDIR=@cgibindir@
HTMLDIR=@webdir@
datarootdir=@datarootdir@
INSTALL=@INSTALL@
INSTALL_OPTS=@INSTALL_OPTS@
COMMAND_OPTS=@COMMAND_OPTS@

CP=@CP@

all html:
	(cd angularjs && unzip -u angular-1.3.9.zip)
	(cd angularjs && unzip -u ui-utils-0.2.3.zip)
	if [ ! -d bootstrap-3.3.7 ] ; then mkdir -p bootstrap-3.3.7 && ( cd bootstrap-3.3.7 && unzip -u ../bootstrap-3.3.7-dist.zip && mv dist/* . && rmdir dist ) ; fi
	mkdir -p d3
	(cd d3 && unzip -u ../d3-3.5.17.zip)

clean:
	rm -f *.cfg *.sub core
	rm -f *~
	rm -f images/*.jbf
	rm -f images/logos/*.jbf
	rm -f contexthelp/*~
	rm -f docs/*~
	rm -f docs/images/*.jbf
	rm -f stylesheets/*~
	rm -f js/*~
	rm -rf angularjs/angular-1.3.9
	rm -rf angularjs/ui-utils-0.2.3
	rm -rf bootstrap-3.3.7
	rm -rf d3

distclean: clean
	rm -f Makefile config.inc.php

devclean: distclean

install:
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/media
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/stylesheets
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/contexthelp
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/docs
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/docs/images
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/js
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/images
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/images/logos
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/includes
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/ssi
# Directories for new CGI pages
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/angularjs
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/angularjs/angular-1.3.9
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/angularjs/ui-utils-0.2.3
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.7
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.7/css
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/d3
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/spin
# End of directories for new CGI pages
	$(INSTALL) -m 664 $(INSTALL_OPTS) robots.txt $(DESTDIR)$(HTMLDIR)
#	$(INSTALL) -m 664 $(INSTALL_OPTS) docs/robots.txt $(DESTDIR)$(HTMLDIR)/docs
# Remove old files
	rm -f $(DESTDIR)$(HTMLDIR)/index.html
	rm -f $(DESTDIR)$(HTMLDIR)/main.html
	rm -f $(DESTDIR)$(HTMLDIR)/side.html
	rm -f $(DESTDIR)$(HTMLDIR)/map.html
	rm -f $(DESTDIR)$(HTMLDIR)/rss-*
	rm -rf $(DESTDIR)$(HTMLDIR)/include/rss
	$(INSTALL) -m 664 $(INSTALL_OPTS) jsonquery.html $(DESTDIR)$(HTMLDIR)
# New graphical CGI pages
	$(INSTALL) -m 664 $(INSTALL_OPTS) graph-header.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) histogram.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) histogram-form.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) histogram-graph.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) histogram-links.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) infobox.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) map.php $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) map-directive.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) map-form.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) map-links.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) map-popup.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) trends.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) trends-form.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) trends-graph.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) trends-host-yaxis.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) trends-links.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) trends-service-yaxis.html $(DESTDIR)$(HTMLDIR)
# End of new graphical CGI pages
	for file in *.php; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR); done
#	for file in media/*.wav; \
#	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/media; done
	for file in stylesheets/*.css; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/stylesheets; done
	for file in contexthelp/*.html; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/contexthelp; done
	for file in js/*.js; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/js; done
#	for file in docs/*.html; \
#	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/docs; done
#	for file in docs/images/*.*; \
#	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/docs/images; done
	for file in images/*.gif; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/images; done
	for file in images/*.jpg; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/images; done
	for file in images/*.png; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/images; done
	for file in images/*.ico; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/images; done
	for file in images/logos/*.*; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/images/logos; done
	for file in includes/*.*; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/includes; done
# Support files for new graphical CGIs
	$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/angular-1.3.9/angular.min.js  $(DESTDIR)$(HTMLDIR)/angularjs/angular-1.3.9
	$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/angular-1.3.9/angular.min.js.map  $(DESTDIR)$(HTMLDIR)/angularjs/angular-1.3.9
	$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/ui-bootstrap-tpls-0.14.3.min.js  $(DESTDIR)$(HTMLDIR)/angularjs
	$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/ui-utils-0.2.3/ui-utils.js   $(DESTDIR)$(HTMLDIR)/angularjs/ui-utils-0.2.3
	$(INSTALL) -m 664 $(INSTALL_OPTS) bootstrap-3.3.7/css/bootstrap.min.css $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.7/css
	$(INSTALL) -m 664 $(INSTALL_OPTS) bootstrap-3.3.7/css/bootstrap-theme.min.css $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.7/css
	$(INSTALL) -m 664 $(INSTALL_OPTS) d3/d3.min.js $(DESTDIR)$(HTMLDIR)/d3
	$(INSTALL) -m 664 $(INSTALL_OPTS) spin/spin.min.js $(DESTDIR)$(HTMLDIR)/spin
# End of support files for new graphical CGIs

install-unstripped:
	$(MAKE) install




