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 https://code.jquery.com/jquery-1.7.2.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://cdn.leafletjs.com/downloads/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)