1383a77f82810125d1b8932916097c0bf87b2211
[vlc.git] / extras / package / win32 / package.mak
1 if HAVE_WIN32
2 BUILT_SOURCES_distclean += \
3         extras/package/win32/NSIS/vlc.win32.nsi extras/package/win32/NSIS/spad.nsi
4 endif
5
6 win32_destdir=$(abs_top_builddir)/vlc-$(VERSION)
7 win32_debugdir=$(abs_top_builddir)/symbols-$(VERSION)
8 win32_xpi_destdir=$(abs_top_builddir)/vlc-plugin-$(VERSION)
9
10 7Z_OPTS=-t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on
11
12
13 if HAVE_WIN32
14 include extras/package/npapi.am
15 endif
16
17 if HAVE_WIN64
18 WINVERSION=vlc-$(VERSION)-win64
19 else
20 WINVERSION=vlc-$(VERSION)-win32
21 endif
22
23 package-win-install:
24         $(MAKE) install
25         touch $@
26
27
28 package-win-common: package-win-install build-npapi
29         mkdir -p "$(win32_destdir)"/
30
31 # Executables, major libs+manifests
32         find $(prefix) -maxdepth 4 \( -name "*$(LIBEXT)" -o -name "*$(EXEEXT)" \) -exec cp {} "$(win32_destdir)/" \;
33         cd $(top_srcdir)/extras/package/win32 && cp vlc$(EXEEXT).manifest libvlc$(LIBEXT).manifest "$(win32_destdir)/"
34
35 # Text files, clean them from mail addresses
36         for file in AUTHORS THANKS ; \
37                 do sed 's/@/_AT_/' < "$(srcdir)/$$file" > "$(win32_destdir)/$${file}.txt"; \
38         done
39         for file in NEWS COPYING README; \
40                 do cp "$(srcdir)/$$file" "$(win32_destdir)/$${file}.txt"; \
41         done
42
43         cp $(srcdir)/share/icons/vlc.ico $(win32_destdir)
44         cp -r $(prefix)/lib/vlc/plugins $(win32_destdir)
45         -cp -r $(prefix)/share/locale $(win32_destdir)
46
47 if BUILD_LUA
48         mkdir -p $(win32_destdir)/lua/
49         cp -r $(prefix)/lib/vlc/lua/* $(prefix)/share/vlc/lua/* $(win32_destdir)/lua/
50 endif
51
52 if BUILD_SKINS
53         rm -fr $(win32_destdir)/skins
54         cp -r $(prefix)/share/vlc/skins2 $(win32_destdir)/skins
55 endif
56
57         cp "$(top_builddir)/npapi-vlc/activex/axvlc.dll.manifest" "$(win32_destdir)/"
58         cp "$(top_builddir)/npapi-vlc/installed/lib/axvlc.dll" "$(win32_destdir)/"
59         cp "$(top_builddir)/npapi-vlc/npapi/package/npvlc.dll.manifest" "$(win32_destdir)/"
60         cp "$(top_builddir)/npapi-vlc/installed/lib/npvlc.dll" "$(win32_destdir)/"
61
62 # Compiler shared DLLs, when using compilers built with --enable-shared
63 # The shared DLLs may not necessarily be in the first LIBRARY_PATH, we
64 # should check them all.
65         -library_path_list=`$(CXX) -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2` ;\
66         IFS=':' ;\
67         for x in $$library_path_list ;\
68         do \
69                 test -f "$$x/libstdc++-6.dll" && cp "$$x/libstdc++-6.dll" "$(win32_destdir)/" ; \
70                 test -f "$$x/libgcc_s_sjlj-1.dll" && cp "$$x/libgcc_s_sjlj-1.dll" "$(win32_destdir)/" ; \
71                 test -f "$$x/libgcc_s_seh-1.dll" && cp "$$x/libgcc_s_seh-1.dll" "$(win32_destdir)/" ; \
72                 test -f "$$x/libwinpthread-1.dll" && cp "$$x/libwinpthread-1.dll" "$(win32_destdir)/" ; \
73                 test -f "$$x/../bin/libwinpthread-1.dll" && cp "$$x/../bin/libwinpthread-1.dll" "$(win32_destdir)/" ; \
74         done
75
76 # SDK
77         mkdir -p "$(win32_destdir)/sdk/lib/"
78         cp -r $(prefix)/include "$(win32_destdir)/sdk"
79         cp -r $(prefix)/lib/pkgconfig "$(win32_destdir)/sdk/lib"
80         cd $(prefix)/lib && cp -rv libvlc.la libvlccore.la "$(win32_destdir)/sdk/lib/"
81         cd $(prefix)/lib && cp -rv libvlc.dll.a "$(win32_destdir)/sdk/lib/libvlc.lib"
82         cd $(prefix)/lib && cp -rv libvlccore.dll.a "$(win32_destdir)/sdk/lib/libvlccore.lib"
83         $(DLLTOOL) -D libvlc.dll -l "$(win32_destdir)/sdk/lib/libvlc.lib" -d "$(top_builddir)/lib/.libs/libvlc.dll.def" "$(prefix)/bin/libvlc.dll"
84         echo "INPUT(libvlc.lib)" > "$(win32_destdir)/sdk/lib/vlc.lib"
85         $(DLLTOOL) -D libvlccore.dll -l "$(win32_destdir)/sdk/lib/libvlccore.lib" -d "$(top_builddir)/src/.libs/libvlccore.dll.def" "$(prefix)/bin/libvlccore.dll"
86         echo "INPUT(libvlccore.lib)" > "$(win32_destdir)/sdk/lib/vlccore.lib"
87
88         mkdir -p "$(win32_destdir)/sdk/activex/"
89         cd $(top_builddir)/npapi-vlc && cp activex/README.TXT share/test/test.html $(win32_destdir)/sdk/activex/
90
91 # Convert to DOS line endings
92         find $(win32_destdir) -type f \( -name "*xml" -or -name "*html" -or -name '*js' -or -name '*css' -or -name '*hosts' -or -iname '*txt' -or -name '*.cfg' -or -name '*.lua' \) -exec $(U2D) {} \;
93
94 # Remove cruft
95         find $(win32_destdir)/plugins/ -type f \( -name '*.a' -or -name '*.la' \) -exec rm -rvf {} \;
96
97
98 package-win-strip: package-win-common
99         mkdir -p "$(win32_debugdir)"/
100         cd $(win32_destdir); find . -type f \( -name '*$(LIBEXT)' -or -name '*$(EXEEXT)' \) | while read i; \
101         do if test -n "$$i" ; then \
102             $(OBJCOPY) --only-keep-debug "$$i" "$(win32_debugdir)/`basename $$i.dbg`"; \
103             $(OBJCOPY) --strip-all "$$i" ; \
104             $(OBJCOPY) --add-gnu-debuglink="$(win32_debugdir)/`basename $$i.dbg`" "$$i" ; \
105           fi ; \
106         done
107
108
109 package-win32-webplugin-common: package-win-strip
110         mkdir -p "$(win32_xpi_destdir)/plugins/"
111         cp -r $(win32_destdir)/plugins/ "$(win32_xpi_destdir)/plugins/"
112         cp "$(win32_destdir)/libvlc.dll" "$(win32_destdir)/libvlccore.dll" "$(win32_destdir)/npvlc.dll" "$(win32_xpi_destdir)/plugins/"
113         cp $(top_builddir)/npapi-vlc/npapi/package/npvlc.dll.manifest "$(win32_xpi_destdir)/plugins/"
114         cp "$(top_srcdir)/extras/package/win32/libvlc.dll.manifest" "$(win32_xpi_destdir)/plugins/"
115         rm -rf "$(win32_xpi_destdir)/plugins/plugins/gui/"
116
117
118 package-win32-xpi: package-win32-webplugin-common
119         cp $(top_builddir)/npapi-vlc/npapi/package/install.rdf "$(win32_xpi_destdir)/"
120         cd $(win32_xpi_destdir) && zip -r -9 "../$(WINVERSION).xpi" install.rdf plugins
121
122
123 package-win32-crx: package-win32-webplugin-common
124         cp $(top_builddir)/npapi-vlc/npapi/package/manifest.json "$(win32_xpi_destdir)/"
125         crxmake --pack-extension "$(win32_xpi_destdir)" \
126                 --extension-output "$(win32_destdir)/$(WINVERSION).crx" --ignore-file install.rdf
127
128
129 # nsis is a 32-bits installer, we need to build a 32bits DLL
130 $(win32_destdir)/NSIS/UAC.dll: extras/package/win32/NSIS/UAC/runas.cpp extras/package/win32/NSIS/UAC/uac.cpp
131         mkdir -p "$(win32_destdir)/NSIS/"
132 if HAVE_WIN64
133         i686-w64-mingw32-g++ $^ -shared -o $@ -lole32 -static-libstdc++ -static-libgcc
134         i686-w64-mingw32-strip $@
135 else
136         $(CXX) $^ -D_WIN32_IE=0x0601 -D__forceinline=inline -shared -o $@ -lole32 -static-libstdc++ -static-libgcc
137         $(STRIP) $@
138 endif
139 $(win32_destdir)/NSIS/nsProcess.dll: extras/package/win32/NSIS/nsProcess/nsProcess.c extras/package/win32/NSIS/nsProcess/pluginapi.c
140         mkdir -p "$(win32_destdir)/NSIS/"
141 if HAVE_WIN64
142         i686-w64-mingw32-gcc $^ -shared -o $@ -lole32 -static-libgcc
143         i686-w64-mingw32-strip $@
144 else
145         $(CC) $^ -D_WIN32_IE=0x0601 -shared -o $@ -lole32 -static-libgcc
146         $(STRIP) $@
147 endif
148
149
150 package-win32-exe: package-win-strip $(win32_destdir)/NSIS/UAC.dll $(win32_destdir)/NSIS/nsProcess.dll extras/package/win32/NSIS/vlc.win32.nsi
151 # Script installer
152         cp    $(top_builddir)/extras/package/win32/NSIS/vlc.win32.nsi "$(win32_destdir)/"
153         cp    $(top_builddir)/extras/package/win32/NSIS/spad.nsi      "$(win32_destdir)/"
154         cp -r $(srcdir)/extras/package/win32/NSIS/languages    "$(win32_destdir)/"
155         cp -r $(srcdir)/extras/package/win32/NSIS/helpers      "$(win32_destdir)/"
156         mkdir -p "$(win32_destdir)/NSIS/"
157         cp "$(top_srcdir)/extras/package/win32/NSIS/UAC.nsh" "$(win32_destdir)/NSIS/"
158         cp "$(top_srcdir)/extras/package/win32/NSIS/nsProcess.nsh" "$(win32_destdir)/NSIS/"
159
160 # Create package
161         if makensis -VERSION >/dev/null 2>&1; then \
162             MAKENSIS="makensis"; \
163         elif [ -x "/cygdrive/c/Program Files/NSIS/makensis" ]; then \
164             MAKENSIS="/cygdrive/c/Program\ Files/NSIS/makensis"; \
165         elif [ -x "$(PROGRAMFILES)/NSIS/makensis" ]; then \
166             MAKENSIS="$(PROGRAMFILES)/NSIS/makensis"; \
167         elif wine --version >/dev/null 2>&1; then \
168             MAKENSIS="wine C:/Program\ Files/NSIS/makensis.exe"; \
169         else \
170             echo 'Error: cannot locate makensis tool'; exit 1; \
171         fi; \
172         eval "$$MAKENSIS $(win32_destdir)/spad.nsi"; \
173         eval "$$MAKENSIS $(win32_destdir)/vlc.win32.nsi"
174
175 package-win32-zip: package-win-strip
176         rm -f -- $(WINVERSION).zip
177         zip -r -9 $(WINVERSION).zip vlc-$(VERSION) --exclude \*.nsi \*NSIS\* \*languages\* \*sdk\* \*helpers\* spad\*
178
179 package-win32-debug-zip: package-win-common
180         rm -f -- $(WINVERSION)-debug.zip
181         zip -r -9 $(WINVERSION)-debug.zip vlc-$(VERSION)
182
183 package-win32-7zip: package-win-strip
184         7z a $(7Z_OPTS) $(WINVERSION).7z vlc-$(VERSION)
185
186 package-win32-debug-7zip: package-win-common
187         7z a $(7Z_OPTS) $(WINVERSION)-debug.7z vlc-$(VERSION)
188
189 package-win32-cleanup:
190         rm -Rf $(win32_destdir) $(win32_debugdir) $(win32_xpi_destdir)
191
192 package-win32: package-win32-zip package-win32-7zip package-win32-exe package-win32-xpi
193
194 package-win32-debug: package-win32-debug-zip package-win32-debug-7zip
195
196
197 #######
198 # WinCE
199 #######
200 package-wince: package-win-strip
201         rm -f -- vlc-$(VERSION)-wince.zip
202         zip -r -9 vlc-$(VERSION)-wince.zip vlc-$(VERSION)
203
204 .PHONY: package-win-install package-win-common package-win-strip package-win32-webplugin-common package-win32-xpi package-win32-crx package-win32-exe package-win32-zip package-win32-debug-zip package-win32-7zip package-win32-debug-7zip package-win32-cleanup package-win32 package-win32-debug package-wince