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'
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_configure='--enable-sizeof-int=4 --enable-sizeof-long=4 --enable-restartable-syscalls=yes'
110 guile_make='oldincludedir=$PREFIX/include'
112 # We need to get guile properly installed for cross-development, ie
113 # at our prefix: $PREFIX. When packaging, the prefix we configured
116 guile_install='prefix=$PREFIX'
118 lilypond_version=@TOPLEVEL_VERSION@
119 if [ $target = mingw ]; then
120 lilypond_cflags='-I $PREFIX/$TARGET_ARCH/include -I $PREFIX/i686-pc-cygwin/include'
122 lilypond_ldflags='-L$PREFIX/lib -lguile $PREFIX/bin/$CYGWIN_DLL'
123 #lilypond_configure='--prefix=$lilypond_prefix'
124 ## URG, help2man: doesn't know about cross-compilation.
125 #lilypond_make='-k || make -k || true'
126 lilypond_patch=lilypond-manpages.patch
127 # Don't install lilypond
128 lilypond_install='--just-print'
132 lilypond-$lilypond_version
135 #######################
136 # end of config section
137 #######################
139 cygwin_dirs=`/bin/ls -d1 $CYGWIN_SOURCE/*`
140 cygwin_source_path=`echo $CYGWIN_SOURCE $cygwin_dirs`
141 source_path=`echo $SOURCE_PATH:$cygwin_source_path | sed 's/:/ /g'`
153 first_dir=`tar tzf $tarball | head -1`
154 src_dir=`dirname $first_dir`
156 if [ "$src_dir" = "src" -o "$src_dir" = "./src" \
157 -o "$src_dir" = "." ]; then
163 if [ "$src_dir" != "$dest_dir" -a "$src_dir" != "$dest_dir/" ]; then
164 mv $src_dir $dest_dir
174 string=`eval echo $\`eval echo ${1}${2}\``
184 for i in $source_path; do
185 found=`/bin/ls -d1 $i/$expr 2>/dev/null | head -1`
186 if [ -e "$found" ]; then
199 base=`basename $file $ext`
200 if [ $base$ext != $i ]; then
202 if expr "$type" : "$expr"; then
203 mv -f $file $base$ext
212 if [ -d $package ]; then
213 echo "$package: directory exists"
214 echo "$package: skipping"
218 name=`echo $package | sed 's/-.*//'`
219 name_cflags=`expand $name _cflags`
220 name_ldflags=`expand $name _ldflags`
221 name_configure=`expand $name _configure`
222 type_configure=`expand $type _configure`
223 name_make=`expand $name _make`
224 name_install=`expand $name _install`
226 found=`find_path $package*src.tar.gz`
227 if [ "$found" = "" ]; then
228 found=`find_path $package.tar.gz`
230 if [ "$found" = "" ]; then
231 found=`find_path $name*tar.gz`
233 if [ "$found" = "" ]; then
234 echo "$package: no such tarball"
238 untar $found $package
239 patch=`expand $name _patch`
241 while [ "x$patch" != "x" ]; do
244 found=`find_path $patch`
245 if [ "$found" = "" ]; then
246 echo "$patch: no such file"
249 patch -p1 -E < $found
251 count=`expr $count + 1`
252 patch=`expand $name _patch$count`
259 CFLAGS="$name_cflags" LDFLAGS="$name_ldflags" ../$package/configure $type_configure $name_configure || exit 1
260 make $name_make || exit 1
261 make install $name_install || exit 1
265 ## urg, let's hope Cygnus uses rpm for packaging its next release
270 name=`echo $package | sed 's/-.*//'`
271 name_pack_install=`expand $name _pack_install`
272 install_root=/tmp/$package-install
273 install_prefix=$install_root/$NATIVE_PREFIX/$package
277 mkdir -p $install_prefix
279 cd $PREFIX/src/$type-$package || exit 1
280 make install prefix=$install_prefix $name_pack_install
282 ## duh, rename executables,
283 ## for people that use a dumb shell instead of bash
284 cd $install_prefix/bin &&
285 for i in `/bin/ls -d1 *`; do
286 fix_extension $i .exe '.*Windows.*\(executable\).*'
287 fix_extension $i .py '.*\(python\).*'
290 rm -f $WWW/$package.zip
291 cd $install_root && zip -r $WWW/$package.zip .$NATIVE_PREFIX
304 if [ ! -d $PREFIX ]; then
306 found=`find_path $cygwin_binary`
307 if [ "$found" = "" ]; then
308 echo "$cygwin_binary: no such tarball"
312 # urg, bug in gcc's cross-make configuration
313 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
317 # urg, bug in gcc's cross-make configuration
319 ln -s $PREFIX/$TARGET_ARCH/include .
321 echo "$PREFIX: already exists"
322 echo "$cygwin_binary: skipping"
326 if [ ! -d $PREFIX/$TARGET_ARCH ]; then
328 found=`find_path $mingw_binary`
329 if [ "$found" = "" ]; then
330 echo "$mingw_binary: no such tarball"
335 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
337 mkdir -p $PREFIX/i386-mingw32/include
338 ln -s $PREFIX/i386-mingw32 $TARGET_ARCH
339 ln -s $PREFIX/$TARGET_ARCH/include .
342 if [ ! -e $NATIVE_PREFIX ]; then
343 ln -s $ROOT /Cygnus || exit 1
348 PATH=$PATH:$PREFIX/bin
351 for i in $cross_packages; do
355 echo "$i: build failed"
360 # urg, bug in gcc's cross-make install
361 mv $PREFIX/bin/cygwin1.dll $PREFIX/bin/$CYGWIN_DLL
362 mv $PREFIX/bin/mingwc10.dll $PREFIX/bin/$MINGW_DLL
363 ln -f $PREFIX/bin/$TARGET_ARCH-gcc $PREFIX/$TARGET_ARCH/bin/cc
364 ln -f $PREFIX/bin/$TARGET_ARCH-c++ $PREFIX/$TARGET_ARCH/bin/c++
365 ln -f $PREFIX/bin/$TARGET_ARCH-g++ $PREFIX/$TARGET_ARCH/bin/g++
367 PATH=$PREFIX/$TARGET_ARCH/bin:$PREFIX/bin:$PATH
374 for i in $native_packages; do
382 rm -f $WWW/$CYGWIN_DLL.zip
383 cd $PREFIX/bin && zip $WWW/$CYGWIN_DLL.zip $CYGWIN_DLL