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