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 # * guile-1.3.4.tar.gz
28 # * lilypond-1.3.38.jcn1.tar.gz
30 # * lots of disk space, ca 353MB
37 ROOT=/usr/src/cygwin-net-485
39 NATIVE_PREFIX=/Cygnus/usr
43 WWW=$DEVEL/WWW/lilypond/gnu-windows
46 CYGWIN_SOURCE=$DEVEL/sourceware.cygnus.com/pub/cygwin/private/cygwin-net-485
47 SOURCE_PATH=$DEVEL/usr/src/releases:$DEVEL/usr/src/patches:$DEVEL/usr/src/lilypond/Documentation/ntweb
49 HOST=`uname -m`-gnu-`uname -s | tr '[A-Z]' '[a-z]'`
51 cygwin_binary=cygwin-20000301.tar.gz
52 TARGET_ARCH=i686-pc-cygwin
53 CYGWIN_DLL=cygwin1-net-485.dll
62 not_yet_needed=cygwin-2000301
64 cross_configure='--prefix=$PREFIX --target=$TARGET_ARCH'
65 ##native_configure='--prefix=$NATIVE_PREFIX --target=$TARGET_ARCH'
66 gcc_make='LANGUAGES="c++"'
67 cygwin_make='-k || true'
69 native_configure='--target=$TARGET_ARCH --build=$TARGET_ARCH --host=$HOST --oldincludedir=$PREFIX/include --prefix=$NATIVE_PREFIX'
71 guile_patch='guile-1.3.4-gnu-windows.patch'
72 guile_configure='--enable-sizeof-int=4 --enable-sizeof-long=4 --enable-restartable-syscalls=yes'
73 guile_make='oldincludedir=$PREFIX/include'
75 lilypond_version=@TOPLEVEL_VERSION@
76 #lilypond_prefix="$NATIVE_PREFIX/lilypond-$lilypond_version"
77 lilypond_ldflags='-L$PREFIX/lib -lguile $PREFIX/bin/$CYGWIN_DLL'
78 #lilypond_configure='--prefix=$lilypond_prefix'
79 ## URG, help2man: doesn't know about cross-compilation.
80 #lilypond_make='-k || make -k || true'
81 lilypond_patch=lilypond-manpages.patch
82 lilypond_install='--just-print'
86 lilypond-$lilypond_version
90 #######################
91 # end of config section
92 #######################
94 cygwin_dirs=`/bin/ls -d1 $CYGWIN_SOURCE/*`
95 cygwin_source_path=`echo $CYGWIN_SOURCE $cygwin_dirs`
96 source_path=`echo $SOURCE_PATH:$cygwin_source_path | sed 's/:/ /g'`
98 # mingw doesn't work yet.
99 #TARGET_ARCH=i686-pc-mingw32
101 # building cross-compiler i686-pc-mingw32-gcc exists on:
103 # /usr/src/cygwin-mingw/usr/src/cross-gcc-2.95.2/gcc/xgcc -B/usr/src/cygwin-mingw/usr/src/cross-gcc-2.95.2/gcc/ -B/usr/src/cygwin-mingw/usr/i686-pc-mingw32/bin/ -I/usr/src/cygwin-mingw/usr/i686-pc-mingw32/include -O2 -I../../gcc-2.95.2/gcc/../winsup/include -DCROSS_COMPILE -DIN_GCC -g -O2 -I./include -g1 -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I../../gcc-2.95.2/gcc -I../../gcc-2.95.2/gcc/config -I../../gcc-2.95.2/gcc/../include -c
107 # ../../gcc-2.95.2/gcc/libgcc2.c:2582: conflicting types for `getpagesize'
108 #/usr/src/cygwin-mingw/usr/i686-pc-mingw32/include/sys/unistd.h:43: previous declaration of `getpagesize'
109 # it seems that __CYGWIN__ is not defined in mingw compiler/or compiler isn't
110 # fully ported to mingw
122 first_dir=`tar tzf $tarball | head -1`
123 src_dir=`dirname $first_dir`
125 if [ "$src_dir" = "src" -o "$src_dir" = "./src" \
126 -o "$src_dir" = "." ]; then
132 if [ "$src_dir" != "$dest_dir" -a "$src_dir" != "$dest_dir/" ]; then
133 mv $src_dir $dest_dir
143 string=`eval echo $\`eval echo ${1}${2}\``
152 if [ -d $package ]; then
153 echo "$package: directory exists"
154 echo "$package: skipping"
158 name=`echo $package | sed 's/-.*//'`
159 name_patch=`expand $name _patch`
160 name_ldflags=`expand $name _ldflags`
161 name_configure=`expand $name _configure`
162 type_configure=`expand $type _configure`
163 name_make=`expand $name _make`
164 name_install=`expand $name _install`
166 found=`find_path $package*src.tar.gz`
167 if [ "$found" = "" ]; then
168 found=`find_path $package.tar.gz`
170 if [ "$found" = "" ]; then
171 found=`find_path $name*tar.gz`
173 if [ "$found" = "" ]; then
174 echo "$package: no such tarball"
178 untar $found $package
179 if [ "x$name_patch" != "x" ]; then
182 found=`find_path $name_patch`
183 if [ "$found" = "" ]; then
184 echo "$name_patch: no such file"
187 patch -p1 -E < $found
195 LDFLAGS="$name_ldflags" ../$package/configure $type_configure $name_configure || exit 1
196 make $name_make || exit 1
197 make install $name_install || exit 1
201 ## urg, let's hope Cygnus uses rpm for packaging its next release
206 name=`echo $package | sed 's/-.*//'`
207 name_pack_install=`expand $name _pack_install`
208 install_root=/tmp/$package-install
209 install_prefix=$install_root/$NATIVE_PREFIX
213 mkdir -p $install_prefix
215 cd $PREFIX/src/$type-$package || exit 1
216 make install prefix=$install_prefix $name_pack_install
218 ## duh, rename executables,
219 ## for people that use a dumb shell instead of bash
220 cd $install_prefix/bin &&
221 for i in `/bin/ls -d1 *`; do
222 base=`basename $i .exe`
223 if [ $base.exe != $i ]; then
225 if expr "$type" : '.*Windows.*\(executable\).*'; then
230 rm -f $WWW/$package.zip
231 cd $install_root && zip -r $WWW/$package.zip .$NATIVE_PREFIX
240 for i in $source_path; do
241 found=`/bin/ls -d1 $i/$expr 2>/dev/null | head -1`
242 if [ -e "$found" ]; then
259 if [ ! -d $PREFIX ]; then
261 found=`find_path $cygwin_binary`
262 if [ "$found" = "" ]; then
263 echo "$cygwin_binary: no such tarball"
267 # urg, bug in gcc's cross-make configuration
268 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
271 # urg, bug in gcc's cross-make configuration
272 if [ ! -e include ]; then
273 #mv include huh-include
274 # not target-arch, but [i686-]pc-cygwin!
275 ln -s $PREFIX/i686-pc-cygwin/include .
276 # these necessary only for mingw32
277 ln -s $PREFIX/i686-pc-cygwin/include $TARGET_ARCH
278 ln -s $PREFIX/include $PREFIX/$TARGET_ARCH/include
281 echo "$PREFIX: already exists"
282 echo "$cygwin_binary: skipping"
285 if [ ! -e $NATIVE_PREFIX ]; then
286 ln -s $ROOT /Cygnus || exit 1
291 PATH=$PATH:$PREFIX/bin
294 for i in $cross_packages; do
298 echo "$i: build failed"
303 # urg, bug in gcc's cross-make install
304 mv -f $PREFIX/bin/cygwin1.dll $PREFIX/bin/$CYGWIN_DLL
305 ln -f $PREFIX/bin/$TARGET_ARCH-gcc $PREFIX/$TARGET_ARCH/bin/cc
306 ln -f $PREFIX/bin/$TARGET_ARCH-c++ $PREFIX/$TARGET_ARCH/bin/c++
307 ln -f $PREFIX/bin/$TARGET_ARCH-g++ $PREFIX/$TARGET_ARCH/bin/g++
309 PATH=$PREFIX/$TARGET_ARCH/bin:$PREFIX/bin:$PATH
316 for i in $native_packages; do
324 rm -f $WWW/$CYGWIN_DLL.zip
325 cd $PREFIX/bin && zip $WWW/$CYGWIN_DLL.zip $CYGWIN_DLL