aligned Patch file with new Praat version
[sgc2.git] / praat_module / makePraat.sh
blob1ebc42419faaf580c9bf856962073e2bc8d934fb
1 #!/bin/bash
3 APPLICATIONNAME=SpeakGoodChinese2
4 CURRENTWORKINGDIR=$(pwd)
5 UNAME=$(uname -s)
6 MAKECMD=make
7 EXECPATH=./praat
8 TARGETNAME=${APPLICATIONNAME}
10 PRAATSOURCES=./praat_sources
11 if [[ ${1:-Normal} == "MinGW" ]]; then
12 PRAATSOURCES=../../praat_mingw
13 if [[ ! -d ${PRAATSOURCES} ]]; then
14 exit
16 # Temporary cludge to recompile this file without -O2
17 touch ${PRAATSOURCES}/dwsys/regularExp.cpp
18 elif [[ -d ../praat_sources ]]; then
19 PRAATSOURCES=../praat_sources
20 elif [[ -d ../../demo_praat_sources ]]; then
21 PRAATSOURCES=../../demo_praat_sources
22 elif [[ -d ../../praat_sources ]]; then
23 PRAATSOURCES=../../praat_sources
26 if [[ -e ${PRAATSOURCES}/makefile.defs && -n `grep -l mingw32 ${PRAATSOURCES}/makefile.defs` ]]; then
27 EXECPATH=./Praat.exe
28 if [[ ${1:-Normal} == "MinGW" && ${2:-Normal} == "XP" ]]; then
29 TARGETNAME=${APPLICATIONNAME}XP.exe
30 else
31 TARGETNAME=${APPLICATIONNAME}.exe
33 UNAME=MinGW
34 elif [[ ${UNAME} == "Darwin" ]]; then
35 MAKECMD='xcodebuild -project praat.xcodeproj'
36 EXECPATH="./build/Configuration1/Praat.app"
37 TARGETNAME=${APPLICATIONNAME}.app
40 # Patch Praat
41 cd ${PRAATSOURCES}
42 if [[ -s ${CURRENTWORKINGDIR}/adaptPraat.patch ]]; then
43 patch --strip=1 < ${CURRENTWORKINGDIR}/adaptPraat.patch
46 # Add demopraatapplication.h
47 cd main/
48 rm -f demopraatapplication.h
49 if [[ ${1:-Normal} == "MinGW" && ${2:-Normal} == "XP" ]]; then
50 cat ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expanded.h | sed 's/\(\"build_SHA\$ \= \\\"[^\\]*\)/\1 XP/g' > ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expandedXP.h
51 ln -s ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expandedXP.h ./demopraatapplication.h
52 else
53 ln -s ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expanded.h ./demopraatapplication.h
55 # Create a file containing the Build number
56 grep 'build_SHA$ = "' ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expanded.praat | grep ':' | perl -ane '/\"([A-F0-9]+)\s+([\d\-]+)(.*)\"/;print "<i>$1</i> <b>$2</b>$3\n";' > ${CURRENTWORKINGDIR}/Build_SHA.html
58 # Get the manual into the tutorials manual
59 cp ../fon/manual_tutorials.cpp ../fon/manual_tutorials.cppORIGINAL
60 NUMLINES=$(grep -n '}' ../fon/manual_tutorials.cpp|tail -1|sed 's/\:.*//g'|perl -ane 'print $_-1;')
61 TAILLINES=$(wc -l ../fon/manual_tutorials.cpp|perl -ane "print \$_ - ${NUMLINES}")
62 head -n ${NUMLINES} ../fon/manual_tutorials.cppORIGINAL > ../fon/manual_tutorials.cpp
63 cat ${CURRENTWORKINGDIR}/manual_${APPLICATIONNAME}.cpp >> ../fon/manual_tutorials.cpp
64 tail -${TAILLINES} ../fon/manual_tutorials.cppORIGINAL >> ../fon/manual_tutorials.cpp
66 touch main_Praat.cpp
68 # Patch main_Praat
69 if [[ -s ${CURRENTWORKINGDIR}/main_Praat.patch ]]; then
70 patch main_Praat.cpp ${CURRENTWORKINGDIR}/main_Praat.patch
73 cd ../
74 if [[ ${UNAME} == "Darwin" ]]; then
75 ${MAKECMD} OTHER_CFLAGS='$OTHER_CFLAGS -DDEMOAPP' 2>&1
76 else
77 ${MAKECMD} 2>&1
80 # Undo patches
81 if [[ -s ${CURRENTWORKINGDIR}/adaptPraat.patch ]]; then
82 patch -R --strip=1 < ${CURRENTWORKINGDIR}/adaptPraat.patch
85 cd main/
86 rm -f demopraatapplication.h ../fon/manual_tutorials.cpp
87 mv ../fon/manual_tutorials.cppORIGINAL ../fon/manual_tutorials.cpp
88 if [[ -s ${CURRENTWORKINGDIR}/main_Praat.patch ]]; then
89 patch -R main_Praat.cpp ${CURRENTWORKINGDIR}/main_Praat.patch
91 cd -
93 # Move result to correct directory
94 if [[ -d ${CURRENTWORKINGDIR}/${TARGETNAME} ]]; then
95 rm -r ${CURRENTWORKINGDIR}/${TARGETNAME}
97 mv ${EXECPATH} ${CURRENTWORKINGDIR}/${TARGETNAME}
100 cd ${CURRENTWORKINGDIR}
101 zip -r ${TARGETNAME}.zip ${TARGETNAME}
103 # Create MD5SUM
104 if [[ -n `which md5` ]] ; then
105 if [[ -f ${CURRENTWORKINGDIR}/${TARGETNAME} ]]; then
106 md5 ${CURRENTWORKINGDIR}/${TARGETNAME} > ${CURRENTWORKINGDIR}/${TARGETNAME}.md5
108 md5 ${CURRENTWORKINGDIR}/${TARGETNAME}.zip > ${CURRENTWORKINGDIR}/${TARGETNAME}.zip.md5
110 if [[ -n `which md5sum` ]] ; then
111 if [[ -f ${CURRENTWORKINGDIR}/${TARGETNAME} ]]; then
112 md5sum ${CURRENTWORKINGDIR}/${TARGETNAME} > ${CURRENTWORKINGDIR}/${TARGETNAME}.md5
114 md5sum ${CURRENTWORKINGDIR}/${TARGETNAME}.zip > ${CURRENTWORKINGDIR}/${TARGETNAME}.zip.md5