42bbf793fcb195539f1250eaac0b41b68c48f1ea
[pwl6.git] / rules / nwjs.mk
1 # This is free and unencumbered software released into the public
2 # domain. To the extent possible under law, the author of this file
3 # waives all copyright and related or neighboring rights to it.
4
5 .DELETE_ON_ERROR:
6
7 include $(dir $(realpath $(lastword $(MAKEFILE_LIST))))programs.mk
8
9 nwjs-platforms := \
10 osx-x64.zip osx-ia32.zip \
11 linux-x64.tar.gz linux-ia32.tar.gz \
12 win-ia32.zip
13
14 nwjs-pattern := \
15 $(addprefix nwjs-v%-,$(nwjs-platforms))
16
17 # These are like 30MB, don't download them every time.
18 .PRECIOUS: $(nwjs-pattern)
19
20 $(nwjs-pattern):
21 mkdir -p $(@D)
22 wget -O $@ http://dl.nwjs.io/v$(*F)/$(@F) || ($(RM) $@ && exit 1)
23
24 nwjs-version ?= 0.10.2
25 nwjs-prefix ?= nwjs/
26 nwjs-directx = $(addprefix $(nwjs-prefix),d3dcompiler_43.dll d3dcompiler_46.dll)
27
28 nwjs = $(nwjs-prefix)nwjs-v$(firstword $(value nwjs-version-$1) $(nwjs-version))-$1
29
30 nwjs-archives = $(foreach p,$(nwjs-platforms),$(call nwjs,$(p)))
31
32 define nwjs-package-osx
33 $(RM) $@
34 $(RM) -r $(@:.zip=)
35 $(UNZIP) -d $(@D) $2
36 mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=)
37 tools/generate-osx-app $(@:.zip=) $1
38 $(RM) $(@:.zip=)/nwjc
39 mv $(@:.zip=)/credits.html $(@:.zip=)/nwjs\ credits.html
40 cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=)
41 $(RM) -r $(@:.zip=)
42 endef
43
44 %-osx-ia32.zip: %.nw $(call nwjs,osx-ia32.zip)
45 $(call nwjs-package-osx,$<,$(word 2,$^))
46
47 %-osx-x64.zip: %.nw $(call nwjs,osx-x64.zip)
48 $(call nwjs-package-osx,$<,$(word 2,$^))
49
50 define nwjs-package-linux
51 $(RM) $@
52 $(RM) -r $(@:.tar.gz=)
53 tar -C $(@D) -xzf $2
54 mkdir -p $(@:.tar.gz=)
55 mv $(@D)/$(notdir $(2:.tar.gz=)) $(@:.tar.gz=)/nw
56 cp -a $1 $(@:.tar.gz=)/nw/package.nw
57 cp -a tools/nw-linux-wrapper $(@:.tar.gz=)/`echo $(notdir $1) | sed -E 's/_.+//'`
58 $(RM) $(@:.tar.gz=)/nw/nwjc
59 mv $(@:.tar.gz=)/nw/credits.html $(@:.tar.gz=)/nw/nwjs\ credits.html
60 tar -czf $@ -C $(@D) $(@F:.tar.gz=)
61 $(RM) -r $(@:.tar.gz=)
62 endef
63
64 %-linux-ia32.tar.gz: %.nw $(call nwjs,linux-ia32.tar.gz)
65 $(call nwjs-package-linux,$<,$(word 2,$^))
66
67 %-linux-x64.tar.gz: %.nw $(call nwjs,linux-x64.tar.gz)
68 $(call nwjs-package-linux,$<,$(word 2,$^))
69
70 WINE ?= wine
71
72 nwjs-icon = $(shell $(UNZIP) -p $1 package.json | grep -Eo '"[^"]+.ico"' -m 1)
73
74 define nwjs-package-win
75 $(RM) $@
76 $(RM) -r $(@:.zip=)
77 if $(UNZIP) -l $2 credits.html > /dev/null; then $(UNZIP) -d $(@D)/$(notdir $(2:.zip=)) $2; else $(UNZIP) -d $(@D) $2; fi
78 mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=)
79 $(RM) $(@:.zip=)/nwjc.exe
80 $(UNZIP) -p $< $(call nwjs-icon,$<) > $(@D)/icon.ico
81 $(WINE) tools/rcedit.exe $(@:.zip=)/nw.exe --set-icon $(@D)/icon.ico
82 $(RM) $(@D)/icon.ico
83 mv $(@:.zip=)/credits.html $(@:.zip=)/nwjs\ credits.html
84 cp -a $< $(@:.zip=)/package.nw
85 cp -a $(nwjs-directx) $(@:.zip=)
86 mv $(@:.zip=)/nw.exe $(@:.zip=)/`echo $(notdir $1) | sed -E 's/_.+/.exe/'`
87 cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=)
88 $(RM) -r $(@:.zip=)
89 endef
90
91 %-win-ia32.zip: %.nw $(call nwjs,win-ia32.zip) $(nwjs-directx)
92 $(call nwjs-package-win,$<,$(word 2,$^))
93
94 $(nwjs-directx):
95 wget -O $@ 'https://github.com/cefsharp/cef-binary/raw/1e51255cf77d267899bf7834768b8774affaad2d/cef_binary_3.y.z_windows32/Release/'$(notdir $@)
96
97 $(nwjs-prefix)dxwebsetup.exe:
98 wget -O $@ http://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe