Added new wordlist
[sgc2.git] / praat_module / makePraat.sh
bloba3c6e08b0c421200c461af714227eacf430ce71d
1 #!/bin/bash
3 APPLICATIONNAME=SpeakGoodChinese2
4 CURRENTWORKINGDIR=$(pwd)
5 UNAME=$(uname -s)
6 MAKECMD=make
7 EXECPATH=./praat
8 TARGETNAME=${APPLICATIONNAME}
9 ZIPNAME=${TARGETNAME}
11 PRAATSOURCES=./praat_sources
12 if [[ ${1:-Normal} == "MinGW" ]]; then
13 PRAATSOURCES=../../praat_mingw
14 if [[ ! -d ${PRAATSOURCES} ]]; then
15 exit
17 # Temporary cludge to recompile this file without -O2
18 touch ${PRAATSOURCES}/dwsys/regularExp.cpp
19 elif [[ -d ../praat_sources ]]; then
20 PRAATSOURCES=../praat_sources
21 elif [[ -d ../../demo_praat_sources ]]; then
22 PRAATSOURCES=../../demo_praat_sources
23 elif [[ -d ../../praat_sources ]]; then
24 PRAATSOURCES=../../praat_sources
27 if [[ -e ${PRAATSOURCES}/makefile.defs && -n `grep -l mingw32 ${PRAATSOURCES}/makefile.defs` ]]; then
28 EXECPATH=./Praat.exe
29 if [[ ${1:-Normal} == "MinGW" && ${2:-Normal} == "XP" ]]; then
30 TARGETNAME=${APPLICATIONNAME}XP.exe
31 else
32 TARGETNAME=${APPLICATIONNAME}.exe
34 ZIPNAME=${TARGETNAME}
35 UNAME=MinGW
36 elif [[ ${UNAME} == "Darwin" ]]; then
37 MAKECMD="xcodebuild -project praat64.xcodeproj"
38 echo ${2:-Normal}
39 if [[ -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk ]]; then
40 SDK=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
41 MAKECMD="xcodebuild -project praat64.xcodeproj -sdk ${SDK}"
42 EXECPATH="./build/Configuration64/Praat.app"
43 ZIPNAME=${ZIPNAME}_64.app
44 elif [[ -d ${PRAATSOURCES}/praat32.xcodeproj && ${1:-Normal} != "OSX64" ]]; then
45 if [[ -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs ]]; then
46 SDK=`ls -1d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/*|grep 10.6`
47 else
48 SDK=`ls -1d /Developer/SDKs/*|grep 10.6`
50 MAKECMD="xcodebuild -project praat32.xcodeproj -sdk ${SDK}"
51 EXECPATH="./build/Configuration1/Praat.app"
52 ZIPNAME=${ZIPNAME}_32.app
53 else
54 MAKECMD="xcodebuild -project praat64.xcodeproj"
55 EXECPATH="./build/Configuration64/Praat.app"
56 ZIPNAME=${ZIPNAME}_64.app
58 TARGETNAME=${APPLICATIONNAME}.app
61 # Patch Praat
62 cd ${PRAATSOURCES}
63 if [[ -s ${CURRENTWORKINGDIR}/adaptPraat.patch ]]; then
64 patch --strip=1 < ${CURRENTWORKINGDIR}/adaptPraat.patch
66 if [[ -s ${CURRENTWORKINGDIR}/sys_praat_name.patch ]]; then
67 patch --strip=1 < ${CURRENTWORKINGDIR}/sys_praat_name.patch
70 # Add demopraatapplication.h
71 cd main/
72 rm -f demopraatapplication.h
73 if [[ ${1:-Normal} == "MinGW" && ${2:-Normal} == "XP" ]]; then
74 cat ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expanded.h | sed 's/\(\"build_SHA\$ \= \\\"[^\\]*\)/\1 XP/g' > ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expandedXP.h
75 ln -s ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expandedXP.h ./demopraatapplication.h
76 else
77 ln -s ${CURRENTWORKINGDIR}/${APPLICATIONNAME}expanded.h ./demopraatapplication.h
79 # Create a file containing the Build number
80 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
82 # Get the manual into the tutorials manual
83 cp ../fon/manual_tutorials.cpp ../fon/manual_tutorials.cppORIGINAL
84 NUMLINES=$(grep -n '}' ../fon/manual_tutorials.cpp|tail -1|sed 's/\:.*//g'|perl -ane 'print $_-1;')
85 TAILLINES=$(wc -l ../fon/manual_tutorials.cpp|perl -ane "print \$_ - ${NUMLINES}")
86 head -n ${NUMLINES} ../fon/manual_tutorials.cppORIGINAL > ../fon/manual_tutorials.cpp
87 cat ${CURRENTWORKINGDIR}/manual_${APPLICATIONNAME}.cpp >> ../fon/manual_tutorials.cpp
88 tail -${TAILLINES} ../fon/manual_tutorials.cppORIGINAL >> ../fon/manual_tutorials.cpp
90 touch main_Praat.cpp
92 # Patch main_Praat
93 if [[ -s ${CURRENTWORKINGDIR}/main_Praat.patch ]]; then
94 patch main_Praat.cpp ${CURRENTWORKINGDIR}/main_Praat.patch
97 cd ../
98 if [[ ${UNAME} == "Darwin" ]]; then
99 ${MAKECMD} OTHER_CFLAGS='$OTHER_CFLAGS -DDEMOAPP' 2>&1
100 else
101 ${MAKECMD} 2>&1
104 # Undo patches
105 if [[ -s ${CURRENTWORKINGDIR}/adaptPraat.patch ]]; then
106 patch -R --strip=1 < ${CURRENTWORKINGDIR}/adaptPraat.patch
108 if [[ -s ${CURRENTWORKINGDIR}/sys_praat_name.patch ]]; then
109 patch -R --strip=1 < ${CURRENTWORKINGDIR}/sys_praat_name.patch
112 cd main/
113 rm -f demopraatapplication.h ../fon/manual_tutorials.cpp
114 mv ../fon/manual_tutorials.cppORIGINAL ../fon/manual_tutorials.cpp
115 if [[ -s ${CURRENTWORKINGDIR}/main_Praat.patch ]]; then
116 patch -R main_Praat.cpp ${CURRENTWORKINGDIR}/main_Praat.patch
118 cd -
120 # Move result to correct directory
121 if [[ -d ${CURRENTWORKINGDIR}/${TARGETNAME} ]]; then
122 rm -r ${CURRENTWORKINGDIR}/${TARGETNAME}
124 mv ${EXECPATH} ${CURRENTWORKINGDIR}/${TARGETNAME}
127 cd ${CURRENTWORKINGDIR}
128 zip -r ${ZIPNAME}.zip ${TARGETNAME}
130 # Create MD5SUM
131 if [[ -n `which md5` ]] ; then
132 if [[ -f ${CURRENTWORKINGDIR}/${TARGETNAME} ]]; then
133 md5 ${CURRENTWORKINGDIR}/${TARGETNAME} > ${CURRENTWORKINGDIR}/${TARGETNAME}.md5
135 md5 ${CURRENTWORKINGDIR}/${ZIPNAME}.zip > ${CURRENTWORKINGDIR}/${ZIPNAME}.zip.md5
137 if [[ -n `which md5sum` ]] ; then
138 if [[ -f ${CURRENTWORKINGDIR}/${TARGETNAME} ]]; then
139 md5sum ${CURRENTWORKINGDIR}/${TARGETNAME} > ${CURRENTWORKINGDIR}/${TARGETNAME}.md5
141 md5sum ${CURRENTWORKINGDIR}/${ZIPNAME}.zip > ${CURRENTWORKINGDIR}/${ZIPNAME}.zip.md5