Update URLs - mostly s/http/https/, a few moved.
[pwl6.git] / Makefile
1 #!/usr/bin/make -f
2 #
3 # This is free and unencumbered software released into the public
4 # domain. To the extent possible under law, the author of this file
5 # waives all copyright and related or neighboring rights to it.
6
7 nwjs-version := 0.12.1
8 stampprefix := build/stamp/
9
10 include rules/default.mk
11 $(call include-once,rules/*.mk)
12
13 .PHONY: all check clean distclean lint test dist
14
15 APPLICATION := pwl6
16 DISTDIR := build/dist/
17 VERSION := $(call git-describe)
18 DISTROOT := $(DISTDIR)$(APPLICATION)_$(VERSION)
19
20 MY_SOURCES := $(call find-js,src -path 'src/ext' -prune -o)
21 TEST_SOURCES := $(call find-js,test/spec)
22
23 VPATH := src
24
25 ICONS := $(call iconset>icons,$(call find-iconsets,src))
26 XCFS := $(call find-xcfs,src)
27 OBJPNGS := $(call xcf>png,$(XCFS))
28 PNGS := $(call find-files,src,-name '*.png') $(OBJPNGS)
29
30 BUILT := $(ICONS) $(OBJPNGS)
31 CRUSHABLE := $(call pngcrush-stampify,$(PNGS))
32 LINTABLE := $(call jshint-stampify,$(MY_SOURCES))
33 TESTABLE := $(call jstest-stampify,$(TEST_SOURCES))
34 DISTFILES := $(addprefix $(DISTROOT)-,$(nwjs-platforms))
35
36 all:: check $(BUILT) $(CRUSHABLE)
37
38 dist: $(DISTFILES)
39
40 test/spec/%.js:: %.js
41 touch $@
42
43 lint:: $(LINTABLE)
44 test:: $(TESTABLE)
45
46 check:: lint test
47
48 clean::
49 $(RM) $(DISTFILES)
50 $(RM) $(BUILT)
51 $(RM) $(LINTABLE)
52 $(RM) $(TESTABLE)
53 $(RM) $(CRUSHABLE)
54 $(call rmdir-r,build)
55
56 distclean:: clean
57 $(RM) -r node_modules
58
59 $(DISTROOT)-src.zip $(DISTROOT)-src.tar.gz: | .git
60 $(MKDIR) $(@D)
61 $(call git-archive,$@,$(notdir $(DISTROOT))/)
62
63 $(DISTROOT).bare.zip: | .git
64 $(RM) $@
65 $(RM) -r $@.tmp
66 $(MKDIR) $@.tmp
67 cd src && $(GIT) archive $(call git-describe) . | tar -x -C ../$@.tmp
68 $(MAKE) $(BUILT:src/%=$@.tmp/%)
69 $(RM) $(XCFS:src/%=$@.tmp/%)
70 cd $@.tmp && $(ZIP) ../$(@F) -r .
71 $(RM) -r $@.tmp
72
73 %.appcache: %.bare.zip tools/generate-appcache
74 $(RM) -r $@.tmp $@
75 $(UNZIP) -d $@.tmp $<
76 tools/generate-appcache $@.tmp
77 mv $@.tmp $@
78
79 # Python's zipfile module generates zipfiles that NW.js cannot read,
80 # so delegate to a real zip tool.
81 %.nw: %.bare.zip tools/generate-nw
82 $(RM) -r $@ $@.tmp
83 $(UNZIP) -d $@.tmp $<
84 tools/generate-nw $@.tmp `echo $(*F) | sed -E 's/.+_[^0-9]+//'`
85 cd $@.tmp && $(ZIP) -r ../$(@F) .
86 $(RM) -r $@.tmp