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