efc6a6e93f9d980348838585ac63785cd2dc63db
[ardour.git] / tools / x-win / package.sh
1 #!/bin/bash
2
3 # we assuem this script is <ardour-src>/tools/x-win/package
4 pushd "`/usr/bin/dirname \"$0\"`" > /dev/null; this_script_dir="`pwd`"; popd > /dev/null
5 cd $this_script_dir/../..
6 test -f gtk2_ardour/wscript || exit 1
7
8 : ${XARCH=i686} # or x86_64
9 : ${ROOT=/home/ardour}
10 : ${MAKEFLAGS=-j4}
11 : ${TMPDIR=/var/tmp}
12 : ${SRCDIR=/var/tmp/winsrc}  # source-code tgz cache
13
14 if test "$XARCH" = "x86_64" -o "$XARCH" = "amd64"; then
15         echo "Target: 64bit Windows (x86_64)"
16         XPREFIX=x86_64-w64-mingw32
17         WARCH=w64
18 else
19         echo "Target: 32 Windows (i686)"
20         XPREFIX=i686-w64-mingw32
21         WARCH=w32
22 fi
23
24 : ${PREFIX=${ROOT}/win-stack-$WARCH}
25 export SRCDIR
26
27 if [ "$(id -u)" = "0" ]; then
28         apt-get -y install nsis curl
29 fi
30
31
32 function download {
33 echo "--- Downloading.. $2"
34 test -f ${SRCDIR}/$1 || curl -k -L -o ${SRCDIR}/$1 $2
35 }
36
37 ################################################################################
38 set -e
39
40 ARDOURVERSION=$(git describe | sed 's/-g.*$//')
41 ARDOURDATE=$(date -R)
42 BINVERSION=$(git describe | sed 's/-g.*$//' | sed 's/-/./')
43 if ! test -f build/gtk2_ardour/ardour-${BINVERSION}.exe; then
44         echo "*** Please compile ardour ${ARDOURVERSION} first."
45         exit 1
46 fi
47 ./waf install
48
49 ################################################################################
50
51 if test -z "$DESTDIR"; then
52         DESTDIR=`mktemp -d`
53         trap 'rm -rf $DESTDIR' exit SIGINT SIGTERM
54 fi
55
56 echo " === bundle to $DESTDIR"
57
58 ALIBDIR=$DESTDIR/lib/ardour3
59
60 rm -rf $DESTDIR
61 mkdir -p $DESTDIR/bin
62 mkdir -p $DESTDIR/share/
63 mkdir -p $ALIBDIR/surfaces
64 mkdir -p $ALIBDIR/backends
65 mkdir -p $ALIBDIR/panners
66 mkdir -p $ALIBDIR/vamp
67
68 cp build/libs/gtkmm2ext/gtkmm2ext-*.dll $DESTDIR/bin/
69 cp build/libs/midi++2/midipp-*.dll $DESTDIR/bin/
70 cp build/libs/evoral/evoral-*.dll $DESTDIR/bin/
71 cp build/libs/ardour/ardour-*.dll $DESTDIR/bin/
72 cp build/libs/timecode/timecode.dll $DESTDIR/bin/
73 cp build/libs/qm-dsp/qmdsp-*.dll $DESTDIR/bin/
74 cp build/libs/canvas/canvas-*.dll $DESTDIR/bin/
75 cp build/libs/pbd/pbd-*.dll $DESTDIR/bin/
76 cp build/libs/audiographer/audiographer-*.dll $DESTDIR/bin/
77 cp build/libs/fst/ardour-vst-scanner.exe $DESTDIR/bin/ || true
78 cp `ls -t build/gtk2_ardour/ardour-*.exe | head -n1` $DESTDIR/bin/ardour.exe
79
80 mkdir -p $DESTDIR/lib/gtk-2.0/engines
81 cp build/libs/clearlooks-newer/clearlooks.dll $DESTDIR/lib/gtk-2.0/engines/libclearlooks.la
82
83 cp $PREFIX/bin/*dll $DESTDIR/bin/
84 cp $PREFIX/lib/*dll $DESTDIR/bin/
85 rm -rf $DESTDIR/bin/libjack*.dll
86
87 cp `find build/libs/surfaces/ -iname "*.dll"` $ALIBDIR/surfaces/
88 cp `find build/libs/backends/ -iname "*.dll"` $ALIBDIR/backends/
89 cp `find build/libs/panners/ -iname "*.dll"` $ALIBDIR/panners/
90
91 cp -r build/libs/LV2 $ALIBDIR/
92 cp -r build/libs/vamp-plugins/*ardourvampplugins*.dll $ALIBDIR/vamp/libardourvampplugins.dll
93
94 mv $ALIBDIR/surfaces/ardourcp-*.dll $DESTDIR/bin/
95
96 # TODO use -static-libgcc -static-libstdc++ -- but for .exe files only
97 if update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q win32; then
98         cp /usr/lib/gcc/${XPREFIX}/*-win32/libgcc_s_*.dll $DESTDIR/bin/
99         cp /usr/lib/gcc/${XPREFIX}/*-win32/libstdc++-6.dll $DESTDIR/bin/
100 elif update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q posix; then
101         cp /usr/lib/gcc/${XPREFIX}/*-posix/libgcc_s_*.dll $DESTDIR/bin/
102         cp /usr/lib/gcc/${XPREFIX}/*-posix/libstdc++-6.dll $DESTDIR/bin/
103 else
104         cp /usr/lib/gcc/${XPREFIX}/*/libgcc_s_sjlj-1.dll $DESTDIR/bin/
105         cp /usr/lib/gcc/${XPREFIX}/*/libstdc++-6.dll $DESTDIR/bin/
106 fi
107 #Ubuntu's 14.04's mingw needs this one for the std libs above
108 if test -f /usr/${XPREFIX}/lib/libwinpthread-1.dll; then
109         cp /usr/${XPREFIX}/lib/libwinpthread-1.dll $DESTDIR/bin/
110 fi
111
112 cp -r $PREFIX/share/ardour3 $DESTDIR/share/
113 cp -r $PREFIX/etc/ardour3/* $DESTDIR/share/ardour3/
114
115 cp COPYING $DESTDIR/share/
116 cp gtk2_ardour/icons/ardour.ico $DESTDIR/share/
117
118 # replace default cursor with square version (sans hotspot file)
119 cp gtk2_ardour/icons/cursor_square/* $DESTDIR/share/ardour3/icons/
120
121 # clean build-dir after depoyment
122 ./waf uninstall
123 echo " === complete"
124 du -sh $DESTDIR
125
126 ################################################################################
127 ### get video tools
128 if test -z "$NOVIDEOTOOLS"; then
129         echo " === Including video-tools"
130         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
131         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
132
133         rsync -Pa \
134                 rsync://ardour.org/video-tools/harvid_win-${HARVID_VERSION}.tar.xz \
135                 "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz"
136
137         rsync -Pa \
138                 rsync://ardour.org/video-tools/xjadeo_win-${XJADEO_VERSION}.tar.xz \
139                 "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz"
140
141         mkdir $DESTDIR/video
142         tar -xf "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz" -C "$DESTDIR/video/"
143         tar -xf "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz" -C "$DESTDIR/video/"
144 fi
145
146 ################################################################################
147 ### include static gdb - re-zipped binaries from
148 ### http://sourceforge.net/projects/mingw/files/MinGW/Extension/gdb/gdb-7.6.1-1/gdb-7.6.1-1-mingw32-bin.tar.lzma
149 ### http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.1/threads-win32/sjlj/x86_64-4.9.1-release-win32-sjlj-rt_v3-rev1.7z
150 if ! grep " using ./waf configure" build/config.log | grep -q -- "--optimize"; then
151         download gdb-static-win3264.tar.xz http://robin.linuxaudio.org/gdb-static-win3264.tar.xz
152         cd ${SRCDIR}
153         tar xf gdb-static-win3264.tar.xz
154         cd - > /dev/null
155
156         echo " === Creating ardbg.bat"
157         cp -r ${SRCDIR}/gdb_$WARCH $DESTDIR/gdb
158         cat > $DESTDIR/ardbg.bat << EOF
159 cd bin
160 START ..\\gdb\\bin\\gdb.exe ardour.exe
161 EOF
162         OUTFILE="${TMPDIR}/ardour-${ARDOURVERSION}-dbg-${WARCH}-Setup.exe"
163         VERSIONINFO="Debug Version."
164 else
165         OUTFILE="${TMPDIR}/ardour-${ARDOURVERSION}-${WARCH}-Setup.exe"
166         VERSIONINFO="Optimized Version."
167 fi
168
169 ################################################################################
170 echo " === Preparing Windows Installer"
171 NSISFILE=$DESTDIR/a3.nsis
172
173 if test "$WARCH" = "w64"; then
174         PGF=PROGRAMFILES64
175 else
176         PGF=PROGRAMFILES
177 fi
178
179 if test -n "$QUICKZIP" ; then
180         cat > $NSISFILE << EOF
181 SetCompressor zlib
182 EOF
183 else
184         cat > $NSISFILE << EOF
185 SetCompressor /SOLID lzma
186 SetCompressorDictSize 32
187 EOF
188 fi
189
190 cat >> $NSISFILE << EOF
191 !include MUI2.nsh
192 Name "Ardour3"
193 OutFile "${OUTFILE}"
194 RequestExecutionLevel admin
195 InstallDir "\$${PGF}\\ardour3"
196 InstallDirRegKey HKLM "Software\\Ardour\\ardour3\\$WARCH" "Install_Dir"
197
198 !define MUI_ICON "share\\ardour.ico"
199 !define MUI_FINISHPAGE_TITLE "Welcome to Ardour"
200 !define MUI_FINISHPAGE_TEXT "This windows versions or Ardour is provided as-is.\$\\r\$\\nThe ardour community currently has no expertise in supporting windows users, and there are no developers focusing on windows specific issues either.\$\\r\$\\nIf you like Ardour, please consider helping out."
201 !define MUI_FINISHPAGE_LINK "Ardour Manual"
202 !define MUI_FINISHPAGE_LINK_LOCATION "http://manual.ardour.org"
203 #this would run as admin - see http://forums.winamp.com/showthread.php?t=353366
204 #!define MUI_FINISHPAGE_RUN "\$INSTDIR\\bin\\ardour.exe"
205 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
206
207 !define MUI_ABORTWARNING
208 !insertmacro MUI_PAGE_LICENSE "share\\COPYING"
209 !insertmacro MUI_PAGE_COMPONENTS
210 !insertmacro MUI_PAGE_DIRECTORY
211 !insertmacro MUI_PAGE_INSTFILES
212 !insertmacro MUI_PAGE_FINISH
213 !insertmacro MUI_UNPAGE_CONFIRM
214 !insertmacro MUI_UNPAGE_INSTFILES
215 !insertmacro MUI_LANGUAGE "English"
216
217 Section "Ardour3 (required)" SecArdour
218   SectionIn RO
219   SetOutPath \$INSTDIR
220   File /r bin
221   File /r lib
222   File /r share
223   File /nonfatal ardbg.bat
224   File /nonfatal /r gdb
225   WriteRegStr HKLM SOFTWARE\\Ardour\\ardour3\\$WARCH "Install_Dir" "\$INSTDIR"
226   WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ardour3" "DisplayName" "Ardour3"
227   WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ardour3" "UninstallString" '"\$INSTDIR\\uninstall.exe"'
228   WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ardour3" "NoModify" 1
229   WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ardour3" "NoRepair" 1
230   WriteUninstaller "\$INSTDIR\uninstall.exe"
231   CreateShortCut "\$INSTDIR\\Ardour3.lnk" "\$INSTDIR\\bin\\ardour.exe" "" "\$INSTDIR\\bin\\ardour.exe" 0
232 SectionEnd
233 EOF
234
235 if test -z "$NOVIDEOTOOLS"; then
236
237         cat >> $NSISFILE << EOF
238 Section "Videotimeline Tools" SecVideo
239   WriteRegStr HKLM SOFTWARE\\Ardour\\video "Install_Dir" "\$INSTDIR\\video"
240   SetOutPath \$INSTDIR
241   File /r video
242 SectionEnd
243 EOF
244
245 fi
246
247 cat >> $NSISFILE << EOF
248 Section "Start Menu Shortcuts" SecMenu
249   SetShellVarContext all
250   CreateDirectory "\$SMPROGRAMS\\ardour3"
251   CreateShortCut "\$SMPROGRAMS\\ardour3\\Ardour3.lnk" "\$INSTDIR\\bin\\ardour.exe" "" "\$INSTDIR\\bin\\ardour.exe" 0
252 EOF
253
254 if test -f "$DESTDIR/ardbg.bat"; then
255         cat >> $NSISFILE << EOF
256   CreateShortCut "\$SMPROGRAMS\\ardour3\\Ardour3 GDB.lnk" "\$INSTDIR\\ardbg.bat" "" "\$INSTDIR\\ardbg.bat" 0
257 EOF
258 fi
259
260 cat >> $NSISFILE << EOF
261   CreateShortCut "\$SMPROGRAMS\\ardour3\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
262 SectionEnd
263 LangString DESC_SecArdour \${LANG_ENGLISH} "Ardour ${ARDOURVERSION}\$\\r\$\\n${VERSIONINFO}\$\\r\$\\n${ARDOURDATE}"
264 EOF
265
266 if test -z "$NOVIDEOTOOLS"; then
267         cat >> $NSISFILE << EOF
268 LangString DESC_SecVideo \${LANG_ENGLISH} "Video Tools\$\\r\$\\nxjadeo-${XJADEO_VERSION}\$\\r\$\\nharvid-${HARVID_VERSION}"
269 EOF
270 fi
271
272 cat >> $NSISFILE << EOF
273 LangString DESC_SecMenu \${LANG_ENGLISH} "Create Start-Menu Shortcuts (recommended)."
274 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
275 !insertmacro MUI_DESCRIPTION_TEXT \${SecArdour} \$(DESC_SecArdour)
276 EOF
277
278 if test -z "$NOVIDEOTOOLS"; then
279         cat >> $NSISFILE << EOF
280 !insertmacro MUI_DESCRIPTION_TEXT \${SecVideo} \$(DESC_SecVideo)
281 EOF
282 fi
283
284 cat >> $NSISFILE << EOF
285 !insertmacro MUI_DESCRIPTION_TEXT \${SecMenu} \$(DESC_SecMenu)
286 !insertmacro MUI_FUNCTION_DESCRIPTION_END
287 Section "Uninstall"
288   SetShellVarContext all
289   DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ardour"
290   DeleteRegKey HKLM SOFTWARE\\Ardour\\ardour3
291   RMDir /r "\$INSTDIR\\bin"
292   RMDir /r "\$INSTDIR\\lib"
293   RMDir /r "\$INSTDIR\\share"
294   RMDir /r "\$INSTDIR\\gdb"
295   RMDir /r "\$INSTDIR\\video"
296   Delete "\$INSTDIR\\ardbg.bat"
297   Delete "\$INSTDIR\\uninstall.exe"
298   Delete "\$INSTDIR\\Ardour3.lnk"
299   RMDir "\$INSTDIR"
300   Delete "\$SMPROGRAMS\\ardour3\\*.*"
301   RMDir "\$SMPROGRAMS\\ardour3"
302 SectionEnd
303 EOF
304
305 rm -f ${OUTFILE}
306 echo " === OutFile: $OUTFILE"
307
308 if test -n "$QUICKZIP" ; then
309 echo " === Building Windows Installer (fast zip)"
310 else
311 echo " === Building Windows Installer (lzma compression takes ages)"
312 fi
313 time makensis -V2 $NSISFILE
314 rm -rf $DESTDIR
315 ls -lh "$OUTFILE"