diff options
author | Christopher Baines <cb15g11@soton.ac.uk> | 2015-05-02 10:36:03 +0100 |
---|---|---|
committer | Christopher Baines <cb15g11@soton.ac.uk> | 2015-05-02 11:58:01 +0100 |
commit | e7e1494e3384cc5904fb79a7f6c0f5a8776f1718 (patch) | |
tree | c07af64606c0148878c92f34dcc77afe6671de73 /Makefile | |
parent | c0da98f318a637a91df6655b1c63385adb41e5ab (diff) | |
download | maps.southampton.ac.uk-e7e1494e3384cc5904fb79a7f6c0f5a8776f1718.tar maps.southampton.ac.uk-e7e1494e3384cc5904fb79a7f6c0f5a8776f1718.tar.gz |
Change build system to make
This is shorter, simpler, and works without random hacky javascript. The
Makefile also now incorporates the download-libraries script, and will either
use the system versions of leaflet and jquery if available, or attempt to
download them from the web.
The following web pages were helpful:
http://aeflash.com/2014-10/make.html
http://vmrob.com/colorized-makefiles/
Diffstat (limited to 'Makefile')
-rwxr-xr-x | Makefile | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..aead42b --- /dev/null +++ b/Makefile @@ -0,0 +1,122 @@ + +NO_COLOR=\033[0m +OK_COLOR=\033[32;01m +#ERROR_COLOR=\033[31;01m +#WARN_COLOR=\033[33;01m + +OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR) +#ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR) +#WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR) + +AWK_CMD = awk '{ printf "%-30s %-10s\n",$$1, $$2; }' +#PRINT_ERROR = printf "$@ $(ERROR_STRING)\n" | $(AWK_CMD) && printf "$(CMD)\n$$LOG\n" && false +#PRINT_WARNING = printf "$@ $(WARN_STRING)\n" | $(AWK_CMD) && printf "$(CMD)\n$$LOG\n" +PRINT_OK = printf "$@ $(OK_STRING)\n" | $(AWK_CMD) +#BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -eq 1 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi; + +build: clean dist/scripts.js dist/css/style.css dist/index.html dist/fonts dist/images dist/images/logos dist/css/images dist/data.json + @$(PRINT_OK) + +release: clean build uglify cssmin + @$(PRINT_OK) + +clean: + @rm -fr dist + @mkdir dist + @rm -f libraries/jquery/dist/jquery.js + @rm -f libraries/leaflet-soton/resources/leaflet/dist/leaflet.js + @$(PRINT_OK) + +stats: + ls -lh dist + +.PHONY: all clean stats release debug + +SYSTEM_JQUERY=/usr/share/javascript/jquery/jquery.js + +libraries/jquery/dist/jquery.js: +ifneq ("$(wildcard $(SYSTEM_JQUERY))","") + @echo "Using system version of jquery" + cp $(SYSTEM_JQUERY) libraries/jquery/dist/jquery.js; + @$(PRINT_OK) +else + @echo "System version of jquery does not exist, downloading...\n" + @mkdir -p libraries/jquery/dist/ + wget http://code.jquery.com/jquery-2.1.1.js -O libraries/jquery/dist/jquery.js + @$(PRINT_OK) +endif + +SYSTEM_LEAFLET=/usr/share/javascript/leaflet/leaflet-src.js + +libraries/leaflet-soton/resources/leaflet/dist/leaflet.js: +ifneq ("$(wildcard $(SYSTEM_LEAFLET))","") + @echo "Using system version of leaflet" + cp $(SYSTEM_LEAFLET) libraries/leaflet-soton/resources/leaflet/dist/leaflet.js; +else + @echo "System version of leaflet does not exist, downloading...\n" + wget http://leaflet-cdn.s3.amazonaws.com/build/leaflet-0.7.3.zip -O libraries/leaflet-0.7.3.zip + unzip -o libraries/leaflet-0.7.3.zip -d libraries/leaflet-soton/resources/leaflet/dist + @$(PRINT_OK) +endif + +dist/scripts.js: libraries/jquery/dist/jquery.js libraries/leaflet-soton/resources/leaflet/dist/leaflet.js + @cat libraries/jquery/dist/jquery.js \ + libraries/bootstrap/dist/js/bootstrap.js \ + libraries/typeahead.js/dist/typeahead.bundle.js libraries/list.js/dist/list.js \ + libraries/leaflet-soton/resources/leaflet/dist/leaflet.js \ + libraries/leaflet-soton/resources/leaflet-markercluster/dist/leaflet.markercluster.js \ + libraries/leaflet-soton/resources/leaflet-locatecontrol/src/L.Control.Locate.js \ + libraries/leaflet-soton/resources/leaflet-hash/leaflet-hash.js \ + libraries/leaflet-soton/resources/leaflet-indoor/leaflet-indoor.js \ + libraries/leaflet-soton/resources/leaflet-route/leaflet-route.js \ + libraries/leaflet-soton/resources/leaflet-textpath/leaflet.textpath.js \ + libraries/leaflet-soton/resources/uos-live.js/uos-live.js \ + libraries/leaflet-soton/resources/uos-live.js/libraries/pollymer/pollymer.js \ + libraries/leaflet-soton/src/leaflet-soton.js \ + scripts.js > dist/scripts.js + @$(PRINT_OK) + +uglify: dist/scripts.js + @uglifyjs dist/scripts.js --mangle toplevel --compress > dist/scripts.min.js + @mv dist/scripts.min.js dist/scripts.js + @$(PRINT_OK) + +cssmin: dist/css/style.css + @cssmin --wrap 1000 < dist/css/style.css > dist/css/style.min.css + @mv dist/css/style.min.css dist/css/style.css + @$(PRINT_OK) + +dist/css/style.css: + @mkdir dist/css + @cat libraries/bootstrap/dist/css/bootstrap.css \ + libraries/leaflet-soton/resources/leaflet/dist/leaflet.css \ + libraries/leaflet-soton/resources/leaflet-markercluster/dist/MarkerCluster.css \ + libraries/leaflet-soton/resources/leaflet-locatecontrol/src/L.Control.Locate.css \ + libraries/leaflet-soton/src/leaflet-soton.css \ + style.css > dist/css/style.css + @$(PRINT_OK) + +dist/index.html: + @cp index.html dist/index.html + @$(PRINT_OK) + +dist/fonts: + @cp -r libraries/bootstrap/dist/fonts dist/fonts + @$(PRINT_OK) + +dist/images: + @cp -r libraries/leaflet-soton/resources/images dist/images + @$(PRINT_OK) + +dist/images/logos: + @cp -r libraries/leaflet-soton/resources/images/logos dist/images/logos + @$(PRINT_OK) + +dist/css/images: + @cp -r libraries/leaflet-soton/resources/leaflet-locatecontrol/src/images dist/css/images + @$(PRINT_OK) + +dist/data.json: + @cp libraries/leaflet-soton/data.json dist/data.json + @$(PRINT_OK) + |