#!/usr/bin/make -f node-webkit-version := 0.10.2 node-webkit-version-win-ia32.zip := 0.8.6 .DELETE_ON_ERROR: include rules/programs.mk include rules/javascript.mk include rules/icons.mk include rules/git.mk include rules/node-webkit.mk include rules/pngcrush.mk .PHONY: all check distclean lint test dist clean serve APPLICATION := pwl6 DISTDIR := build/dist VERSION := $(call git-describe) DISTROOT := $(DISTDIR)/$(APPLICATION)-$(VERSION) FIND_FILES := -type f ! -name '.*' FIND_JS := -type f -name '*.js' SOURCES := $(shell cd src && find . $(FIND_FILES)) MY_SOURCES := $(shell cd src && find . $(FIND_JS) -not -path './ext/*') TEST_SOURCES := $(shell find test/spec $(FIND_JS)) LINT_TARGETS := $(call jshint-stampify,$(MY_SOURCES)) TEST_TARGETS := $(call jstest-stampify,$(TEST_SOURCES)) JSHINTCONFIG := test/jshint.config JSTEST_NODE_PATH := src VPATH := src ICONSETS := $(shell find src -type d -name '*.iconset') ICONS := $(ICONSETS:.iconset=.icns) $(ICONSETS:.iconset=.ico) IMAGEGZSRC := $(shell find src -type f -name '*.xcf.gz') IMAGESRC := $(shell find src -type f -name '*.xcf') IMAGES := $(IMAGEGZSRC:.xcf.gz=.png) $(IMAGESRC:.xcf=.png) BUILT := $(ICONS) $(IMAGES) HTTP_SERVER_PORT ?= 8000 all: check $(BUILT) $(call pngcrush-stampify,$(IMAGES)) $(DISTDIR): mkdir -p $@ dist: $(addprefix $(DISTROOT),-src.zip -src.tar.gz .appcache .nw -osx-ia32.zip -osx-x64.zip -linux-ia32.tar.gz -linux-x64.tar.gz -win-ia32.zip) test/spec/%.js: %.js touch $@ lint: $(LINT_TARGETS) test: $(TEST_TARGETS) check: lint test serve: | $(npmbindir)/http-server $(npmbindir)/http-server $(@D) -p $(HTTP_SERVER_PORT) -c-1 clean: $(RM) $(IMAGES) $(RM) $(ICONS) $(RM) -r build distclean: clean $(RM) -r node_modules $(RM) $(node-webkit-archives) $(DISTROOT)-src.zip $(DISTROOT)-src.tar.gz: | .git mkdir -p $(@D) $(call git-archive,$@,$(notdir $(DISTROOT))/) $(DISTROOT).bare.zip: | .git $(RM) $@ $(RM) -r $@.tmp mkdir -p $@.tmp cd src && $(GIT) archive $(call git-describe) . | tar -x -C ../$@.tmp $(MAKE) $(BUILT:src/%=$@.tmp/%) $(RM) $(IMAGESRC:src/%=$@.tmp/%) $(IMAGEGZSRC:src/%=$@.tmp/%) cd $@.tmp && $(ZIP) ../$(@F) -r . $(RM) -r $@.tmp %.appcache: %.bare.zip tools/generate-appcache $(RM) -r $@.tmp $@ $(UNZIP) -d $@.tmp $< tools/generate-appcache $@.tmp mv $@.tmp $@ # Python's zipfile module generates zipfiles that node-webkit cannot # read, so delegate to a real zip tool. %.nw: %.bare.zip tools/generate-nw $(RM) -r $@ $@.tmp $(UNZIP) -d $@.tmp $< tools/generate-nw $@.tmp cd $@.tmp && $(ZIP) -r ../$(@F) . $(RM) -r $@.tmp