4 # Build and install cross-development tools for cygwin package
5 # (binutils, compiler, flex, bison).
6 # Using this cross-development enviroment, build and install
7 # native cygwin packages (guile, lilypond).
9 # Besides being a handy script for me, currently this mainly serves
10 # as documentation for cross-building lilypond.
12 # To use this script, you need
14 # * all development tools to build a native LilyPond, see INSTALL.txt
16 # * pre-release cygnus sources (and a binary) from:
18 # ftp://sourceware.cygnus.com/pub/cygwin/private/cygwin-net-485/
20 # binutils/binutils-19990818-1-src.tar.gz
21 # bison/bison-src.tar.gz
22 # cygwin/cygwin-20000301.tar.gz
23 # flex/flex-src.tar.gz
24 # gcc/gcc-2.95.2-1-src.tar.gz
26 # ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/runtime/
28 # bin-crtdll-2000-02-03.tar.gz (mingw only)
30 # * guile-1.3.4.tar.gz
32 # * lilypond-1.3.38.jcn1.tar.gz
34 # * lots of disk space, ca 353MB
44 if [ $target = cygwin ]; then
45 ROOT=/usr/src/cygwin-net-485
46 TARGET_ARCH=i686-pc-cygwin
48 ROOT=/usr/src/mingw-net-485
49 TARGET_ARCH=i386-pc-mingw32
52 NATIVE_PREFIX=/Cygnus/usr
56 WWW=$DEVEL/WWW/lilypond/gnu-windows
59 CYGWIN_SOURCE=$DEVEL/sourceware.cygnus.com/pub/cygwin/private/cygwin-net-485
60 MINGW_SOURCE=$DEVEL/ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/runtime
61 SOURCE_PATH=$DEVEL/usr/src/releases:$DEVEL/usr/src/patches:$DEVEL/usr/src/lilypond/Documentation/ntweb:$MINGW_SOURCE
63 HOST=`uname -m`-gnu-`uname -s | tr '[A-Z]' '[a-z]'`
65 cygwin_binary=cygwin-20000301.tar.gz
66 mingw_binary=bin-crtdll-2000-02-03.tar.gz
68 #CYGWIN_DLL=cygwin1-net-485.dll
69 CYGWIN_DLL=cygwin1.dll
70 MINWG_DLL=mingwc10-net-485.dll
87 cross_configure='--prefix=$PREFIX --target=$TARGET_ARCH'
88 gcc_make='LANGUAGES="c++"'
89 cygwin_make='-k || true'
96 # Typically, we install native packages under
98 # /Cygnus/usr/package-x.y.z
100 # so that's how we configure them.
102 native_configure='--target=$TARGET_ARCH --build=$TARGET_ARCH --host=$HOST --oldincludedir=$PREFIX/include --prefix=$NATIVE_PREFIX/$package --program-suffix='
104 guile_patch='guile-1.3.4-gnu-windows.patch'
105 if [ $target = mingw ]; then
106 guile_patch1='guile-1.3.4-mingw.patch'
107 guile_cflags='-I $PREFIX/$TARGET_ARCH/include -I $PREFIX/i686-pc-cygwin/include'
109 guile_ldflags='-L$PREFIX/lib $PREFIX/bin/$CYGWIN_DLL'
110 guile_configure='--enable-sizeof-int=4 --enable-sizeof-long=4 --enable-restartable-syscalls=yes'
111 guile_make='oldincludedir=$PREFIX/include'
113 # We need to get guile properly installed for cross-development, ie
114 # at our prefix: $PREFIX. When packaging, the prefix we configured
117 guile_install='prefix=$PREFIX'
119 lilypond_version=@TOPLEVEL_VERSION@
120 if [ $target = mingw ]; then
121 lilypond_cflags='-I $PREFIX/$TARGET_ARCH/include -I $PREFIX/i686-pc-cygwin/include'
123 lilypond_ldflags='-L$PREFIX/lib -lguile $PREFIX/bin/$CYGWIN_DLL'
124 #lilypond_configure='--prefix=$lilypond_prefix'
125 ## URG, help2man: doesn't know about cross-compilation.
126 #lilypond_make='-k || make -k || true'
127 lilypond_patch=lilypond-manpages.patch
128 # Don't install lilypond
129 lilypond_install='--just-print'
133 lilypond-$lilypond_version
136 #######################
137 # end of config section
138 #######################
140 cygwin_dirs=`/bin/ls -d1 $CYGWIN_SOURCE/*`
141 cygwin_source_path=`echo $CYGWIN_SOURCE $cygwin_dirs`
142 source_path=`echo $SOURCE_PATH:$cygwin_source_path | sed 's/:/ /g'`
154 first_dir=`tar tzf $tarball | head -1`
155 src_dir=`dirname $first_dir`
157 if [ "$src_dir" = "src" -o "$src_dir" = "./src" \
158 -o "$src_dir" = "." ]; then
164 if [ "$src_dir" != "$dest_dir" -a "$src_dir" != "$dest_dir/" ]; then
165 mv $src_dir $dest_dir
175 string=`eval echo $\`eval echo ${1}${2}\``
185 for i in $source_path; do
186 found=`/bin/ls -d1 $i/$expr 2>/dev/null | head -1`
187 if [ -e "$found" ]; then
200 base=`basename $file $ext`
201 if [ $base$ext != $i ]; then
203 if expr "$type" : "$expr"; then
204 mv -f $file $base$ext
213 if [ -d $package ]; then
214 echo "$package: directory exists"
215 echo "$package: skipping"
219 name=`echo $package | sed 's/-.*//'`
220 name_cflags=`expand $name _cflags`
221 name_ldflags=`expand $name _ldflags`
222 name_configure=`expand $name _configure`
223 type_configure=`expand $type _configure`
224 name_make=`expand $name _make`
225 name_install=`expand $name _install`
227 found=`find_path $package*src.tar.gz`
228 if [ "$found" = "" ]; then
229 found=`find_path $package.tar.gz`
231 if [ "$found" = "" ]; then
232 found=`find_path $name*tar.gz`
234 if [ "$found" = "" ]; then
235 echo "$package: no such tarball"
239 untar $found $package
240 patch=`expand $name _patch`
242 while [ "x$patch" != "x" ]; do
245 found=`find_path $patch`
246 if [ "$found" = "" ]; then
247 echo "$patch: no such file"
250 patch -p1 -E < $found
252 count=`expr $count + 1`
253 patch=`expand $name _patch$count`
260 CFLAGS="$name_cflags" LDFLAGS="$name_ldflags" ../$package/configure $type_configure $name_configure || exit 1
261 make $name_make || exit 1
262 make install $name_install || exit 1
266 ## urg, let's hope Cygnus uses rpm for packaging its next release
272 zip=$WWW/$package.zip
274 echo "$zip: package exists"
275 echo "$zip: skipping"
279 name=`echo $package | sed 's/-.*//'`
280 name_pack_install=`expand $name _pack_install`
281 install_root=/tmp/$package-install
282 install_prefix=$install_root/$NATIVE_PREFIX/$package
286 mkdir -p $install_prefix
288 cd $PREFIX/src/$type-$package || exit 1
289 make install prefix=$install_prefix $name_pack_install
291 ## duh, rename executables,
292 ## for people that use a dumb shell instead of bash
293 cd $install_prefix/bin &&
294 for i in `/bin/ls -d1 *`; do
295 fix_extension $i .exe '.*Windows.*\(executable\).*'
296 fix_extension $i .py '.*\(python\).*'
300 cd $install_root && zip -r $zip .$NATIVE_PREFIX
313 if [ ! -d $PREFIX ]; then
315 found=`find_path $cygwin_binary`
316 if [ "$found" = "" ]; then
317 echo "$cygwin_binary: no such tarball"
321 # urg, bug in gcc's cross-make configuration
322 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
326 # urg, bug in gcc's cross-make configuration
328 ln -s $PREFIX/$TARGET_ARCH/include .
330 echo "$PREFIX: already exists"
331 echo "$cygwin_binary: skipping"
335 if [ ! -d $PREFIX/$TARGET_ARCH ]; then
337 found=`find_path $mingw_binary`
338 if [ "$found" = "" ]; then
339 echo "$mingw_binary: no such tarball"
344 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
346 mkdir -p $PREFIX/i386-mingw32/include
347 ln -s $PREFIX/i386-mingw32 $TARGET_ARCH
348 ln -s $PREFIX/$TARGET_ARCH/include .
351 if [ ! -e $NATIVE_PREFIX ]; then
352 ln -s $ROOT /Cygnus || exit 1
357 PATH=$PATH:$PREFIX/bin
360 for i in $cross_packages; do
364 echo "$i: build failed"
369 # urg, bug in gcc's cross-make install
370 mv $PREFIX/bin/cygwin1.dll $PREFIX/bin/$CYGWIN_DLL
371 mv $PREFIX/bin/mingwc10.dll $PREFIX/bin/$MINGW_DLL
372 ln -f $PREFIX/bin/$TARGET_ARCH-gcc $PREFIX/$TARGET_ARCH/bin/cc
373 ln -f $PREFIX/bin/$TARGET_ARCH-c++ $PREFIX/$TARGET_ARCH/bin/c++
374 ln -f $PREFIX/bin/$TARGET_ARCH-g++ $PREFIX/$TARGET_ARCH/bin/g++
376 PATH=$PREFIX/$TARGET_ARCH/bin:$PREFIX/bin:$PATH
383 for i in $native_packages; do
391 rm -f $WWW/$CYGWIN_DLL.zip
392 cd $PREFIX/bin && zip $WWW/$CYGWIN_DLL.zip $CYGWIN_DLL