]> git.donarmstrong.com Git - lilypond.git/blob - cygwin/mknetrel
(dos_to_posix)[__CYGWIN__]: Return
[lilypond.git] / cygwin / mknetrel
1 # -*- shell-script -*-
2
3 sub_packages="doc"
4
5 [ "$cygwin" == "mingw" ] && sub_packages="doc extra"
6
7 depends="libfontconfig1 libfreetype6 libguile16 libintl3 libpango1"
8 build_depends="mingw-devel gettext-devel guile-devel pango-devel"
9
10 v=$(expr "$ver" : "\(.*\)-[0-9]*")
11
12 save_PATH="$PATH"
13
14 # copy and include extra mknetrel stuff
15 . $src/$cygwin/mknetrel.extras || . $mknetrel/extras
16
17 doc () {
18     # doc works, but take too long to build each time
19     [ "$cygwin" == "mingw" ] && return 1
20     return 0
21 }
22
23 preconfig () {
24     extras_preconfig
25
26     [ "$cygwin" == "mingw" ] && if grep 'PYTHON_DEVEL(REQUIRED)' $src/configure.in; then
27         sed -i~ -e 's/PYTHON_DEVEL(REQUIRED)/PYTHON_DEVEL(OPTIONAL)/' \
28             $src/configure.in
29     fi
30     [ "$cygwin" == "mingw" ] && cd $src && ./autogen.sh --noconfigure
31     
32     cd $build || exit 1
33     # cross-compiling: configure for build-host
34     if ! iscygwin; then
35         rm -f config.cache
36         export HOST_CC=${HOST_CC:-gcc}
37         export HOST_CXX=${HOST_CXX:-g++}
38         export HOST_PKG_CONFIG=${HOST_PKG_CONFIG:-pkg-config}
39         export HOST_PKG_CONFIG_PATH=${HOST_PKG_CONFIG_PATH:-}
40         export HOST_FREETYPE_CONFIG=${HOST_FREETYPE_CONFIG:-freetype-config}
41         (PATH="$build:$save_PATH" \
42             CFLAGS="-O2 -g" \
43             CPPFLAGS="" \
44             CC=$HOST_CC \
45             CXX=$HOST_CXX \
46             LDFLAGS="" \
47             PKG_CONFIG=$HOST_PKG_CONFIG \
48             PKG_CONFIG_PATH=$HOST_PKG_CONFIG_PATH \
49             FREETYPE_CONFIG=$HOST_FREETYPE_CONFIG \
50             $src/configure --prefix=$prefix --enable-config=for-build)
51     fi
52
53     GUILE=$(GUILE_LOAD_PATH=$cygwin_prefix/share/guile/* $cygwin_prefix/bin/guile-config --version 2>&1 | awk '{print $NF}')
54     cat > $target-guile-config <<EOF
55 [ "\$1" == "--version" ] && echo "$target-guile-config - Guile version $GUILE"
56 [ "\$1" == "compile" ] && echo "-I$cygwin_prefix/include"
57 [ "\$1" == "link" ] && echo "-L$cygwin_prefix/lib -lguile -lgmp"
58 exit 0
59 EOF
60     chmod 755 $target-guile-config
61     export PATH=.:$PATH
62     build_cxx="$build_cxx -I$(pwd)"
63     if [ "$cygwin" == "mingw" ]; then
64         CONFIGOPTS="--without-kpathsea $CONFIGOPTS"
65         #CPPFLAGS="-DARGV0_RELOCATION=1 $CPPFLAGS"
66         CONFIGOPTS="--enable-relocation $CONFIGOPTS"
67         # There's a problem with inlining the string utils.
68         # The -O2 flag is still passed by default through opt.
69         CONFIGOPTS="--disable-optimising $CONFIGOPTS"
70         ## debugging
71         ##opt='-g'
72     fi
73     
74     if [ "$cygwin" == "mingw" ]; then
75         cp /usr/include/FlexLexer.h .
76         mkdir python2.3
77         cp /usr/include/python2.3/Python.h python2.3
78
79         CXX="$(echo $build_cxx | sed 's/ -mwindows//')" \
80             CXX_FOR_TARGET="${build_cxx}" \
81             CC="${build_cc}" \
82             CC_FOR_TARGET="${build_cc}" \
83             GCC_FOR_TARGET="${build_cc}" \
84             RANLIB="${build_ranlib}" \
85             RANLIB_FOR_TARGET="${build_ranlib}" \
86             DLLWRAP="${build_dllwrap}" \
87             AR="${build_ar}" NM="${build_nm}" \
88             LD=$(${build_cc} -print-prog-name=ld) \
89             $src/configure --enable-config=console $CONFIGOPTS
90
91         rm -f config.cache
92         iscygwin || crosscache
93     fi
94
95     :
96 }
97
98 prebuild () {
99     extras_prebuild
100
101     # shortcircuit python for mingw
102     if [ "$cygwin" == "mingw" ]; then
103         #sed -e s/-mwindows// < config.make > config-console.make
104         #cp config.hh config-console.hh
105
106         mkdir -p python/out python/out-console
107         touch python/out/midi.lo python/out/midi.so python/out/midi.dll
108         touch python/out-console/midi.lo python/out-console/midi.so python/out-console/midi.dll
109     fi
110
111     # cross-compiling: build for build-host, generate doc
112     if ! iscygwin; then
113         cd $build || exit 1
114
115         if doc; then
116             args="all doc web"
117         else
118             args="all"
119         fi
120         (PATH="$build:$save_PATH" \
121             CFLAGS="-O2 -g" \
122             CPPFLAGS="" \
123             CC=$HOST_CC \
124             CXX=$HOST_CXX \
125             LDFLAGS="" \
126             eval make conf=for-build $args) || exit 1
127
128         # fake mf and texi
129         mkdir -p mf/out
130         cp -pv mf/out-for-build/* mf/out
131         mkdir -p Documentation/user/out
132         cp -pv Documentation/user/out-for-build/*{tely,texi} Documentation/user/out
133     fi
134
135     if [ "$cygwin" == "mingw" ]; then
136         # fake mf and texi
137         mkdir -p mf/out-console
138         cp -pv mf/out-for-build/* mf/out-console
139         mkdir -p Documentation/user/out-console
140         cp -pv Documentation/user/out-for-build/*{tely,texi} Documentation/user/out-console
141         # fake manual pages, only works without --enable-config
142         mkdir -p scripts/out-console
143         cp scripts/out-for-build/*.1 scripts/out-console
144         mkdir -p lily/out-console
145         cp lily/out-for-build/*.1 lily/out-console
146         make conf=console || exit 1
147     fi
148
149     addmakeflags "target=$target" ' '
150     if [ -f "$cygwin_prefix/bin/libpython2.4.dll" ]; then
151         addmakeflags LDFLAGS="$cygwin_prefix/bin/libpython2.4.dll" ' '
152     fi
153
154     if iscygwin && doc; then
155         addmakeflags all ' ' doc ' ' web ' '
156     fi
157 }
158
159 preinstall () {
160     extras_preinstall
161     if iscygwin && doc; then
162         addmakeflags webdir="$inst-doc/$packagedocdir" ' ' web-install
163     fi
164 }
165
166 postinstall () {
167     if [ "$cygwin" == "mingw" ]; then
168         cp $inst/usr/share/lilypond/$v/python/* $inst/usr/bin
169         install -m755 $build/lily/out/lilypond $inst/usr/bin/lilypond-windows
170         install -m755 $build/lily/out-console/lilypond $inst/usr/bin/
171     fi
172     
173     extras_postinstall
174
175     if [ "$cygwin" == "mingw" ]; then
176         for i in $inst/usr/bin/*; do
177             m=$(file -b $i)
178             if echo "$m" | grep "guile"; then
179                 mv $i $i.scm
180             elif echo "$m" | grep "python"; then
181                 mv $i $i.py
182             fi
183         done
184     fi
185
186     cd $build || exit 1
187     if ! iscygwin && doc; then
188         make conf=for-build webdir=$inst-doc/$packagedocdir web-install
189     fi
190
191     # txt files reside elsewhere
192     cd $build/Documentation/topdocs/out
193     install -m644 AUTHORS.txt INSTALL.txt NEWS.txt README.txt $inst/$packagedocdir
194     ## copy examples
195     cd $src || exit 1
196     cp -prv input $inst/$packagedocdir
197     rm -rf $(find $inst/$packagedocdir -name 'CVS')
198     rm -f $(find $inst/$packagedocdir -name 'SCons*')
199     rm -f $(find $inst/$packagedocdir -name 'GNUmakefile*')
200
201     rm -rf $(find $inst/usr/share/lilypond -name '*.pyc')
202     rm -f $inst/usr/share/lilypond/$v/tex/texinfo.tex
203
204     if [ "$cygwin" == "mingw" ]; then
205         find $inst -name '*ly' | xargs unix2dos
206     fi
207
208     install -d -m755 $inst-doc/$infodir/lilypond
209     if doc; then
210         cd $inst-doc/$infodir/lilypond && ln -sf ../../doc/$base-$ver/Documentation/user/out-www/*png .
211     fi
212 }
213
214 doc_split () {
215     extras_doc_split
216     mkdir -p ./$packagedocdir/input
217     mv $inst/$packagedocdir/input/{no-notation,regression,test,tutorial} ./$packagedocdir/input
218     mkdir -p ./$prefix/share/lilypond/$v/fonts
219     mv $inst/$prefix/share/lilypond/$v/fonts/source ./$prefix/share/lilypond/$v/fonts
220 }
221
222 extra_name () {
223     echo lilypond-extra
224 }
225
226 extra_split () {
227     # should be in devel...
228     mkdir -p ./$prefix/share/lilypond/$v
229     for i in make python tex vim; do
230     #for i in make tex vim; do
231         mv $inst/$prefix/share/lilypond/$v/$i ./$prefix/share/lilypond/$v
232     done
233     mkdir -p ./$prefix/share/lilypond/$v/fonts
234     for i in source svg tfm; do
235         mv $inst/$prefix/share/lilypond/$v/fonts/$i ./$prefix/share/lilypond/$v/fonts
236     done
237
238     mkdir -p ./$prefix/share
239     for i in locale omf; do
240         mv $inst/$prefix/share/$i ./$prefix/share
241     done
242 }