3 # we assume this script is <ardour-src>/tools/x-win/package.sh
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
8 # Defaults (overridden by environment)
9 : ${XARCH=i686} # or x86_64
10 : ${ROOT=/home/ardour}
13 : ${SRCDIR=/var/tmp/winsrc} # source-code tgz cache
15 # TODO: grep from build/config.log instead
16 while [ $# -gt 0 ] ; do
25 # see also wscript, video_tool_paths.cc, bundle_env_mingw.cc
30 LOWERCASE_DIRNAME=ardour3 # see wscript 'lwrcase_dirname' used for lib/ardour3 and share/ardour3
31 STATEFILE_SUFFIX=ardour # see filename_extensions.cc
33 if test -n "$MIXBUS"; then
39 PRODUCT_ID=${PROGRAM_NAME}${PROGRAM_VERSION}
40 PRODUCT_EXE=${PRODUCT_NAME}.exe
41 PRODUCT_ICON=${PRODUCT_NAME}.ico
43 ###############################################################################
45 if test "$XARCH" = "x86_64" -o "$XARCH" = "amd64"; then
46 echo "Target: 64bit Windows (x86_64)"
47 XPREFIX=x86_64-w64-mingw32
50 echo "Target: 32 Windows (i686)"
51 XPREFIX=i686-w64-mingw32
55 : ${PREFIX=${ROOT}/win-stack-$WARCH}
58 if [ "$(id -u)" = "0" ]; then
59 apt-get -y install nsis curl
64 echo "--- Downloading.. $2"
65 test -f ${SRCDIR}/$1 || curl -k -L -o ${SRCDIR}/$1 $2
68 ################################################################################
71 ARDOURVERSION=$(git describe | sed 's/-g.*$//')
73 BINVERSION=$(git describe | sed 's/-g.*$//;s/\-rc\([^-]*\)-/-rc\1./;s/-/./;s/-.*$//')
74 if ! test -f build/gtk2_ardour/ardour-${BINVERSION}.exe; then
75 echo "*** Please compile ardour ${ARDOURVERSION} first."
80 ################################################################################
82 if test -z "$DESTDIR"; then
84 trap 'rm -rf $DESTDIR' exit SIGINT SIGTERM
87 echo " === bundle to $DESTDIR"
89 ALIBDIR=$DESTDIR/lib/${LOWERCASE_DIRNAME}
93 mkdir -p $DESTDIR/share/
94 mkdir -p $ALIBDIR/surfaces
95 mkdir -p $ALIBDIR/backends
96 mkdir -p $ALIBDIR/panners
97 mkdir -p $ALIBDIR/vamp
98 mkdir -p $ALIBDIR/suil
100 cp build/libs/gtkmm2ext/gtkmm2ext-*.dll $DESTDIR/bin/
101 cp build/libs/midi++2/midipp-*.dll $DESTDIR/bin/
102 cp build/libs/evoral/evoral-*.dll $DESTDIR/bin/
103 cp build/libs/ardour/ardour-*.dll $DESTDIR/bin/
104 cp build/libs/timecode/timecode.dll $DESTDIR/bin/
105 cp build/libs/qm-dsp/qmdsp-*.dll $DESTDIR/bin/
106 cp build/libs/canvas/canvas-*.dll $DESTDIR/bin/
107 cp build/libs/pbd/pbd-*.dll $DESTDIR/bin/
108 cp build/libs/audiographer/audiographer-*.dll $DESTDIR/bin/
109 cp build/libs/fst/ardour-vst-scanner.exe $DESTDIR/bin/ || true
110 cp `ls -t build/gtk2_ardour/ardour-*.exe | head -n1` $DESTDIR/bin/${PRODUCT_EXE}
112 mkdir -p $DESTDIR/lib/gtk-2.0/engines
113 cp build/libs/clearlooks-newer/clearlooks.dll $DESTDIR/lib/gtk-2.0/engines/libclearlooks.la
115 cp $PREFIX/bin/*dll $DESTDIR/bin/
116 cp $PREFIX/lib/*dll $DESTDIR/bin/
117 rm -rf $DESTDIR/bin/libjack*.dll
119 cp `find build/libs/surfaces/ -iname "*.dll"` $ALIBDIR/surfaces/
120 cp `find build/libs/backends/ -iname "*.dll"` $ALIBDIR/backends/
121 cp `find build/libs/panners/ -iname "*.dll"` $ALIBDIR/panners/
123 cp -r build/libs/LV2 $ALIBDIR/
124 cp -r build/libs/vamp-plugins/*ardourvampplugins*.dll $ALIBDIR/vamp/libardourvampplugins.dll
125 cp $PREFIX/lib/suil-*/*.dll $ALIBDIR/suil/ || true
127 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
128 if test -d $PREFIX/lib/lv2/lv2core.lv2 ; then
129 cp -R $PREFIX/lib/lv2/lv2core.lv2 $ALIBDIR/LV2/
132 mv $ALIBDIR/surfaces/ardourcp-*.dll $DESTDIR/bin/
134 # TODO use -static-libgcc -static-libstdc++ -- but for .exe files only
135 if update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q win32; then
136 cp /usr/lib/gcc/${XPREFIX}/*-win32/libgcc_s_*.dll $DESTDIR/bin/
137 cp /usr/lib/gcc/${XPREFIX}/*-win32/libstdc++-6.dll $DESTDIR/bin/
138 elif update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q posix; then
139 cp /usr/lib/gcc/${XPREFIX}/*-posix/libgcc_s_*.dll $DESTDIR/bin/
140 cp /usr/lib/gcc/${XPREFIX}/*-posix/libstdc++-6.dll $DESTDIR/bin/
142 cp /usr/lib/gcc/${XPREFIX}/*/libgcc_s_sjlj-1.dll $DESTDIR/bin/
143 cp /usr/lib/gcc/${XPREFIX}/*/libstdc++-6.dll $DESTDIR/bin/
145 #Ubuntu's 14.04's mingw needs this one for the std libs above
146 if test -f /usr/${XPREFIX}/lib/libwinpthread-1.dll; then
147 cp /usr/${XPREFIX}/lib/libwinpthread-1.dll $DESTDIR/bin/
150 cp -r $PREFIX/share/${LOWERCASE_DIRNAME} $DESTDIR/share/
151 cp -r $PREFIX/etc/${LOWERCASE_DIRNAME}/* $DESTDIR/share/${LOWERCASE_DIRNAME}/
153 cp COPYING $DESTDIR/share/
154 cp gtk2_ardour/icons/${PRODUCT_ICON} $DESTDIR/share/
155 cp gtk2_ardour/icons/ardour_bug.ico $DESTDIR/share/
157 # replace default cursor with square version (sans hotspot file)
158 cp gtk2_ardour/icons/cursor_square/* $DESTDIR/share/${LOWERCASE_DIRNAME}/icons/
160 # clean build-dir after depoyment
165 ################################################################################
167 if test -z "$NOVIDEOTOOLS"; then
168 echo " === Including video-tools"
169 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
170 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
172 rsync -a -q --partial \
173 rsync://ardour.org/video-tools/harvid_win-${HARVID_VERSION}.tar.xz \
174 "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz"
176 rsync -a -q --partial \
177 rsync://ardour.org/video-tools/xjadeo_win-${XJADEO_VERSION}.tar.xz \
178 "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz"
181 tar -xf "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz" -C "$DESTDIR/video/"
182 tar -xf "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz" -C "$DESTDIR/video/"
185 du -sh $DESTDIR/video
189 ################################################################################
190 ### include static gdb - re-zipped binaries from
191 ### http://sourceforge.net/projects/mingw/files/MinGW/Extension/gdb/gdb-7.6.1-1/gdb-7.6.1-1-mingw32-bin.tar.lzma
192 ### 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
193 if ! grep " using ./waf configure" build/config.log | grep -q -- "--optimize"; then
194 download gdb-static-win3264.tar.xz http://robin.linuxaudio.org/gdb-static-win3264.tar.xz
196 tar xf gdb-static-win3264.tar.xz
199 echo " === Creating debug.bat"
200 cp -r ${SRCDIR}/gdb_$WARCH $DESTDIR/gdb
201 cat > $DESTDIR/debug.bat << EOF
203 START ..\\gdb\\bin\\gdb.exe -iex "set logging overwrite on" -iex "set height 0" -iex "set logging on %UserProfile%\\${PRODUCT_NAME}-debug.log" ${PRODUCT_EXE}
205 OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-dbg-${WARCH}-Setup.exe"
206 VERSIONINFO="Debug Version."
208 OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-${WARCH}-Setup.exe"
209 VERSIONINFO="Optimized Version."
212 ################################################################################
213 echo " === Preparing Windows Installer"
214 NSISFILE=$DESTDIR/a3.nsis
216 if test "$WARCH" = "w64"; then
222 if test -n "$QUICKZIP" ; then
223 cat > $NSISFILE << EOF
227 cat > $NSISFILE << EOF
228 SetCompressor /SOLID lzma
229 SetCompressorDictSize 32
233 cat >> $NSISFILE << EOF
234 !addincludedir "${this_script_dir}\\nsis"
236 !include FileAssociation.nsh
238 Name "${PROGRAM_NAME}${PROGRAM_VERSION}"
240 RequestExecutionLevel admin
241 InstallDir "\$${PGF}\\${PRODUCT_ID}"
242 InstallDirRegKey HKLM "Software\\${PROGRAM_NAME}\\${PRODUCT_ID}\\$WARCH" "Install_Dir"
243 !define MUI_ICON "share\\${PRODUCT_ICON}"
247 if test -n "$MIXBUS"; then
249 # TODO: proper welcome/finish text.
250 cat >> $NSISFILE << EOF
251 !define MUI_FINISHPAGE_TITLE "Welcome to Mixbus"
252 !define MUI_FINISHPAGE_TEXT "Thank you for choosing Harrison Mixbus."
253 !define MUI_FINISHPAGE_LINK "Harrison Consoles Website"
254 !define MUI_FINISHPAGE_LINK_LOCATION "http://harrisonconsoles.com"
255 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
260 cat >> $NSISFILE << EOF
261 !define MUI_FINISHPAGE_TITLE "Welcome to Ardour"
262 !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."
263 !define MUI_FINISHPAGE_LINK "Ardour Manual"
264 !define MUI_FINISHPAGE_LINK_LOCATION "http://manual.ardour.org"
265 #this would run as admin - see http://forums.winamp.com/showthread.php?t=353366
266 #!define MUI_FINISHPAGE_RUN "\$INSTDIR\\bin\\${PRODUCT_EXE}"
267 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
272 cat >> $NSISFILE << EOF
273 !define MUI_ABORTWARNING
274 !insertmacro MUI_PAGE_LICENSE "share\\COPYING"
275 !insertmacro MUI_PAGE_COMPONENTS
276 !insertmacro MUI_PAGE_DIRECTORY
277 !insertmacro MUI_PAGE_INSTFILES
278 !insertmacro MUI_PAGE_FINISH
279 !insertmacro MUI_UNPAGE_CONFIRM
280 !insertmacro MUI_UNPAGE_INSTFILES
281 !insertmacro MUI_LANGUAGE "English"
283 Section "${PROGRAM_NAME}${PROGRAM_VERSION} (required)" SecMainProg
289 File /nonfatal debug.bat
290 File /nonfatal /r gdb
291 WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\$WARCH" "Install_Dir" "\$INSTDIR"
292 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" "DisplayName" "${PROGRAM_NAME}${PROGRAM_VERSION}"
293 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" "UninstallString" '"\$INSTDIR\\uninstall.exe"'
294 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" "NoModify" 1
295 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" "NoRepair" 1
296 WriteUninstaller "\$INSTDIR\uninstall.exe"
297 CreateShortCut "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
298 \${registerExtension} "\$INSTDIR\\bin\\${STATEFILE_SUFFIX}" ".${PRODUCT_NAME}" "${PROGRAM_NAME} Session"
302 if test -z "$NOVIDEOTOOLS"; then
304 cat >> $NSISFILE << EOF
305 Section "Videotimeline Tools" SecVideo
306 WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\video" "Install_Dir" "\$INSTDIR\\video"
314 cat >> $NSISFILE << EOF
315 Section "Start Menu Shortcuts" SecMenu
316 SetShellVarContext all
317 CreateDirectory "\$SMPROGRAMS\\${PRODUCT_ID}"
318 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
321 if test -f "$DESTDIR/debug.bat"; then
322 cat >> $NSISFILE << EOF
323 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}\\${PROGRAM_NAME}${PROGRAM_VERSION} GDB.lnk" "\$INSTDIR\\debug.bat" "" "\$INSTDIR\\share\\ardour_bug.ico" 0
327 if test -z "$NOVIDEOTOOLS"; then
328 cat >> $NSISFILE << EOF
329 IfFileExists "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0 +2
330 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}\\Video Monitor.lnk" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" "" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0
334 cat >> $NSISFILE << EOF
335 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
337 LangString DESC_SecMainProg \${LANG_ENGLISH} "${PROGRAM_NAME} ${ARDOURVERSION}\$\\r\$\\n${VERSIONINFO}\$\\r\$\\n${ARDOURDATE}"
340 if test -z "$NOVIDEOTOOLS"; then
341 cat >> $NSISFILE << EOF
342 LangString DESC_SecVideo \${LANG_ENGLISH} "Video Tools\$\\r\$\\nxjadeo-${XJADEO_VERSION}\$\\r\$\\nharvid-${HARVID_VERSION}"
346 cat >> $NSISFILE << EOF
347 LangString DESC_SecMenu \${LANG_ENGLISH} "Create Start-Menu Shortcuts (recommended)."
348 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
349 !insertmacro MUI_DESCRIPTION_TEXT \${SecMainProg} \$(DESC_SecMainProg)
352 if test -z "$NOVIDEOTOOLS"; then
353 cat >> $NSISFILE << EOF
354 !insertmacro MUI_DESCRIPTION_TEXT \${SecVideo} \$(DESC_SecVideo)
358 cat >> $NSISFILE << EOF
359 !insertmacro MUI_DESCRIPTION_TEXT \${SecMenu} \$(DESC_SecMenu)
360 !insertmacro MUI_FUNCTION_DESCRIPTION_END
362 SetShellVarContext all
363 DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}"
364 DeleteRegKey HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}"
366 # TODO: remove the following line before release. But for now, clean up old version agnnstic registry
367 DeleteRegKey HKLM "Software\\${PROGRAM_NAME}"
369 RMDir /r "\$INSTDIR\\bin"
370 RMDir /r "\$INSTDIR\\lib"
371 RMDir /r "\$INSTDIR\\share"
372 RMDir /r "\$INSTDIR\\gdb"
373 RMDir /r "\$INSTDIR\\video"
374 Delete "\$INSTDIR\\debug.bat"
375 Delete "\$INSTDIR\\uninstall.exe"
376 Delete "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk"
378 Delete "\$SMPROGRAMS\\${PRODUCT_ID}\\*.*"
379 RMDir "\$SMPROGRAMS\\${PRODUCT_ID}"
380 \${unregisterExtension} ".${STATEFILE_SUFFIX}" "${PROGRAM_NAME} Session"
385 echo " === OutFile: $OUTFILE"
387 if test -n "$QUICKZIP" ; then
388 echo " === Building Windows Installer (fast zip)"
390 echo " === Building Windows Installer (lzma compression takes ages)"
392 time makensis -V2 $NSISFILE