Remove unused cache.
[pwl6.git] / Makefile
index 06f7e3f..7a611e9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,88 +1,72 @@
 #!/usr/bin/make -f
+#
+# This is free and unencumbered software released into the public
+# domain. To the extent possible under law, the author of this file
+# waives all copyright and related or neighboring rights to it.
 
-node-webkit-version := 0.10.2
-node-webkit-version-win-ia32.zip := 0.8.6
+nwjs-version := 0.12.1
+stampprefix := build/stamp/
 
-.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
+include rules/default.mk
+$(call include-once,rules/*.mk)
 
-.PHONY: all check distclean lint test dist clean serve
+.PHONY: all check clean distclean lint test dist
 
 APPLICATION := pwl6
-DISTDIR := build/dist
+DISTDIR := build/dist/
 VERSION := $(call git-describe)
-DISTROOT := $(DISTDIR)/$(APPLICATION)-$(VERSION)
+DISTROOT := $(DISTDIR)$(APPLICATION)_$(VERSION)
 
-FIND_FILES := -type f ! -name '.*'
-FIND_JS := -type f -name '*.js'
+MY_SOURCES := $(call find-js,src -path 'src/ext' -prune -o)
+TEST_SOURCES := $(call find-js,test/spec)
 
-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)
+ICONS := $(call iconset>icons,$(call find-iconsets,src))
+XCFS := $(call find-xcfs,src)
+OBJPNGS := $(call xcf>png,$(XCFS))
+PNGS := $(call find-files,src,-name '*.png') $(OBJPNGS)
 
-BUILT := $(ICONS) $(IMAGES)
+BUILT := $(ICONS) $(OBJPNGS)
+CRUSHABLE := $(call pngcrush-stampify,$(PNGS))
+LINTABLE := $(call jshint-stampify,$(MY_SOURCES))
+TESTABLE := $(call jstest-stampify,$(TEST_SOURCES))
+DISTFILES := $(addprefix $(DISTROOT)-,$(nwjs-platforms))
 
-HTTP_SERVER_PORT ?= 8000
+all:: check $(BUILT) $(CRUSHABLE)
 
-all: check $(BUILT) $(call pngcrush-stampify,$(IMAGES))
+dist: $(DISTFILES)
 
-$(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
+test/spec/%.js:: %.js
        touch $@
 
-lint: $(LINT_TARGETS)
-
-test: $(TEST_TARGETS)
-
-check: lint test
+lint:: $(LINTABLE)
+test:: $(TESTABLE)
 
-serve: | $(npmbindir)/http-server
-       $(npmbindir)/http-server $(@D) -p $(HTTP_SERVER_PORT) -c-1
+check:: lint test
 
-clean:
-       $(RM) $(IMAGES)
-       $(RM) $(ICONS)
-       $(RM) -r build
+clean::
+       $(RM) $(DISTFILES)
+       $(RM) $(BUILT)
+       $(RM) $(LINTABLE)
+       $(RM) $(TESTABLE)
+       $(RM) $(CRUSHABLE)
+       $(call rmdir-r,build)
 
-distclean: clean
+distclean:: clean
        $(RM) -r node_modules
-       $(RM) $(node-webkit-archives)
 
 $(DISTROOT)-src.zip $(DISTROOT)-src.tar.gz: | .git
-       mkdir -p $(@D)
+       $(MKDIR) $(@D)
        $(call git-archive,$@,$(notdir $(DISTROOT))/)
 
 $(DISTROOT).bare.zip: | .git
        $(RM) $@
        $(RM) -r $@.tmp
-       mkdir -p $@.tmp
+       $(MKDIR) $@.tmp
        cd src && $(GIT) archive $(call git-describe) . | tar -x -C ../$@.tmp
        $(MAKE) $(BUILT:src/%=$@.tmp/%)
-       $(RM) $(IMAGESRC:src/%=$@.tmp/%) $(IMAGEGZSRC:src/%=$@.tmp/%)
+       $(RM) $(XCFS:src/%=$@.tmp/%)
        cd $@.tmp && $(ZIP) ../$(@F) -r .
        $(RM) -r $@.tmp
 
@@ -92,11 +76,11 @@ $(DISTROOT).bare.zip: | .git
        tools/generate-appcache $@.tmp
        mv $@.tmp $@
 
-# Python's zipfile module generates zipfiles that node-webkit cannot
-# read, so delegate to a real zip tool.
+# Python's zipfile module generates zipfiles that NW.js 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
+       tools/generate-nw $@.tmp `echo $(*F) | sed -E 's/.+_[^0-9]+//'`
        cd $@.tmp && $(ZIP) -r ../$(@F) .
        $(RM) -r $@.tmp