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

prefix=@prefix@
exec_prefix=@exec_prefix@
LOGDIR=@localstatedir@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
CGIDIR=@sbindir@
HTMLDIR=@datadir@
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.1.zip)
	if [ ! -d bootstrap-3.3.0 ] ; then mkdir -p bootstrap-3.3.0 && ( cd bootstrap-3.3.0 && unzip -u ../bootstrap-3.3.0-dist.zip && mv dist/* . && rmdir dist ) ; fi
	mkdir -p d3
	(cd d3 && unzip -u ../d3-3.5.3.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.1
	rm -rf bootstrap-3.3.0
	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)/includes/rss
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/includes/rss/extlib
	$(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.1
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.0
	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.0/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 HTML files (PHP files are used now)
	rm -f $(DESTDIR)$(HTMLDIR)/index.html
	rm -f $(DESTDIR)$(HTMLDIR)/main.html
	rm -f $(DESTDIR)$(HTMLDIR)/side.html
	$(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.html $(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
	$(INSTALL) -m 664 $(INSTALL_OPTS) rss-corefeed.html $(DESTDIR)$(HTMLDIR)
	$(INSTALL) -m 664 $(INSTALL_OPTS) rss-newsfeed.html $(DESTDIR)$(HTMLDIR)
	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
	for file in includes/rss/*.*; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/includes/rss; done
	for file in includes/rss/extlib/*.*; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/includes/rss/extlib; 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.12.0.min.js  $(DESTDIR)$(HTMLDIR)/angularjs
	$(INSTALL) -m 664 $(INSTALL_OPTS) angularjs/ui-utils-0.2.1/ui-utils.js   $(DESTDIR)$(HTMLDIR)/angularjs/ui-utils-0.2.1
	$(INSTALL) -m 664 $(INSTALL_OPTS) bootstrap-3.3.0/css/bootstrap.min.css $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.0/css
	$(INSTALL) -m 664 $(INSTALL_OPTS) bootstrap-3.3.0/css/bootstrap-theme.min.css $(DESTDIR)$(HTMLDIR)/bootstrap-3.3.0/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




