#!/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.
nwjs-version := 0.12.0
-all:
-print-%: ; @echo $*=$($*)
+stampprefix := build/stamp/
-.DELETE_ON_ERROR:
-include rules/programs.mk
-include rules/javascript.mk
-include rules/icons.mk
-include rules/git.mk
-include rules/nwjs.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) $(nwjs-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