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)
32 # * guile-1.3.4.tar.gz
34 # * lilypond-1.3.38.jcn1.tar.gz
36 # * lots of disk space, ca 353MB
46 if [ $target = cygwin ]; then
47 ROOT=/usr/src/cygwin-net-485
48 TARGET_ARCH=i686-pc-cygwin
50 ROOT=/usr/src/mingw-net-485
51 TARGET_ARCH=i386-pc-mingw32
54 NATIVE_PREFIX=/Cygnus/usr
58 WWW=$DEVEL/WWW/lilypond/gnu-windows
61 CYGWIN_SOURCE=$DEVEL/sourceware.cygnus.com/pub/cygwin/private/cygwin-net-485
62 MINGW_SOURCE=$DEVEL/ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/runtime
63 SOURCE_PATH=$DEVEL/usr/src/releases:$DEVEL/usr/src/patches:$DEVEL/usr/src/lilypond/Documentation/ntweb:$MINGW_SOURCE:/usr/src/redhat/SOURCES
65 HOST=`uname -m`-gnu-`uname -s | tr '[A-Z]' '[a-z]'`
67 cygwin_binary=cygwin-20000301.tar.gz
68 mingw_binary=bin-crtdll-2000-02-03.tar.gz
70 #CYGWIN_DLL=cygwin1-net-485.dll
71 CYGWIN_DLL=cygwin1.dll
72 MINWG_DLL=mingwc10-net-485.dll
91 cross_configure='--prefix=$PREFIX --target=$TARGET_ARCH'
92 gcc_make='LANGUAGES="c++"'
93 cygwin_make='-k || true'
95 rpm_patch='patchm.ring.diff'
101 # Typically, we install native packages under
103 # /Cygnus/usr/package-x.y.z
105 # so that's how we configure them.
107 native_configure='--target=$TARGET_ARCH --build=$TARGET_ARCH --host=$HOST --oldincludedir=$PREFIX/include --prefix=$NATIVE_PREFIX/$package --program-suffix='
108 native_config_site='$PREFIX/share/native-config.site'
110 rx_install='prefix=$PREFIX'
112 guile_patch='guile-1.3.4-gnu-windows.patch'
113 if [ $target = mingw ]; then
114 guile_patch1='guile-1.3.4-mingw.patch'
115 guile_cflags='-I $PREFIX/$TARGET_ARCH/include -I $PREFIX/i686-pc-cygwin/include'
117 guile_ldflags='-L$PREFIX/lib $PREFIX/bin/$CYGWIN_DLL'
118 guile_make='oldincludedir=$PREFIX/include'
120 # We need to get guile properly installed for cross-development, ie
121 # at our prefix: $PREFIX. When packaging, the prefix we configured
124 guile_install='prefix=$PREFIX'
126 lilypond_version=@TOPLEVEL_VERSION@
127 if [ $target = mingw ]; then
128 lilypond_cflags='-I $PREFIX/$TARGET_ARCH/include -I $PREFIX/i686-pc-cygwin/include'
130 lilypond_ldflags='-L$PREFIX/lib -lguile $PREFIX/bin/$CYGWIN_DLL'
131 lilypond_configure='--enable-tex-tfmdir=/texmf/fonts/tfm/public/cm'
132 ## URG, help2man: doesn't know about cross-compilation.
133 #lilypond_make='-k || make -k || true'
134 lilypond_patch=lilypond-manpages.patch
135 # Don't install lilypond
136 lilypond_install='--just-print'
137 lilypond_before_zip='cp -pr $PREFIX/src/$package/input $install_prefix \; cp -p \`find $PREFIX/src/$package -type f -maxdepth 1\` $install_prefix'
142 lilypond-$lilypond_version
149 #######################
150 # end of config section
151 #######################
153 cygwin_dirs=`/bin/ls -d1 $CYGWIN_SOURCE/*`
154 cygwin_source_path=`echo $CYGWIN_SOURCE $cygwin_dirs`
155 source_path=`echo $SOURCE_PATH:$cygwin_source_path | sed 's/:/ /g'`
167 first_dir=`tar tzf $tarball | head -1`
168 src_dir=`dirname $first_dir`
170 if [ "$src_dir" = "src" -o "$src_dir" = "./src" \
171 -o "$src_dir" = "." ]; then
177 if [ "$src_dir" != "$dest_dir" -a "$src_dir" != "$dest_dir/" ]; then
178 mv $src_dir $dest_dir
188 string=`eval echo $\`eval echo "${1}${2}"\``
198 for i in $source_path; do
199 found=`/bin/ls -d1 $i/$expr 2>/dev/null | head -1`
200 if [ -e "$found" ]; then
213 base=`basename $file $ext`
214 if [ $base$ext != $i ]; then
216 if expr "$type" : "$expr"; then
217 mv -f $file $base$ext
226 if [ -d $package ]; then
227 echo "$package: directory exists"
228 echo "$package: skipping"
232 name=`echo $package | sed 's/-.*//'`
233 name_cflags=`expand $name _cflags`
234 name_ldflags=`expand $name _ldflags`
235 name_configure=`expand $name _configure`
236 type_config_site=`expand $type _config_site`
237 type_configure=`expand $type _configure`
238 name_make=`expand $name _make`
239 name_before_install="`expand $name _before_install`"
240 name_install=`expand $name _install`
242 found=`find_path $package*src.tar.gz`
243 if [ "$found" = "" ]; then
244 found=`find_path $package.tar.gz`
246 if [ "$found" = "" ]; then
247 found=`find_path $name*tar.gz`
249 if [ "$found" = "" ]; then
250 echo "$package: no such tarball"
254 untar $found $package
255 patch=`expand $name _patch`
257 while [ "x$patch" != "x" ]; do
261 found=`find_path $patch`
262 if [ "$found" = "" ]; then
263 echo "$patch: no such file"
266 patch -p1 -E < $found
268 count=`expr $count + 1`
269 patch=`expand $name _patch$count`
275 CONFIG_SITE="$type_config_site" CFLAGS="$name_cflags" LDFLAGS="$name_ldflags" ../$package/configure $type_configure $name_configure || exit 1
276 make $name_make || exit 1
277 `eval $name_before_install` || exit 1
278 make install $name_install || exit 1
282 ## urg, let's hope Cygnus uses rpm for packaging its next release
288 zip=$WWW/$package.zip
290 echo "$zip: package exists"
291 echo "$zip: skipping"
295 name=`echo $package | sed 's/-.*//'`
296 name_pack_install=`expand $name _pack_install`
297 install_root=/tmp/$package-install
298 install_prefix=$install_root/$NATIVE_PREFIX/$package
299 name_before_zip=`expand $name _before_zip`
303 mkdir -p $install_prefix
305 cd $PREFIX/src/$type-$package || exit 1
306 make install prefix=$install_prefix $name_pack_install
308 ## duh, rename executables,
309 ## for people that use a dumb shell instead of bash
310 cd $install_prefix/bin &&
311 for i in `/bin/ls -d1 *`; do
312 fix_extension $i .exe '.*Windows.*\(executable\).*'
313 fix_extension $i .py '.*\(python\).*'
317 `eval $name_before_zip` || exit 1
318 cd $install_root && zip -ry $zip .$NATIVE_PREFIX
331 if [ ! -d $PREFIX ]; then
333 found=`find_path $cygwin_binary`
334 if [ "$found" = "" ]; then
335 echo "$cygwin_binary: no such tarball"
339 # urg, bug in gcc's cross-make configuration
340 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
344 # urg, bug in gcc's cross-make configuration
346 ln -s $PREFIX/$TARGET_ARCH/include .
348 echo "$PREFIX: already exists"
349 echo "$cygwin_binary: skipping"
353 if [ ! -d $PREFIX/$TARGET_ARCH ]; then
355 found=`find_path $mingw_binary`
356 if [ "$found" = "" ]; then
357 echo "$mingw_binary: no such tarball"
362 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
364 mkdir -p $PREFIX/i386-mingw32/include
365 ln -s $PREFIX/i386-mingw32 $TARGET_ARCH
366 ln -s $PREFIX/$TARGET_ARCH/include .
369 if [ ! -e $NATIVE_PREFIX ]; then
370 ln -s $ROOT /Cygnus || exit 1
375 PATH=$PATH:$PREFIX/bin
378 for i in $cross_packages; do
382 echo "$i: build failed"
387 # urg, bug in gcc's cross-make install
388 mv $PREFIX/bin/cygwin1.dll $PREFIX/bin/$CYGWIN_DLL
389 mv $PREFIX/bin/mingwc10.dll $PREFIX/bin/$MINGW_DLL
390 ln -f $PREFIX/bin/$TARGET_ARCH-gcc $PREFIX/$TARGET_ARCH/bin/cc
391 ln -f $PREFIX/bin/$TARGET_ARCH-c++ $PREFIX/$TARGET_ARCH/bin/c++
392 ln -f $PREFIX/bin/$TARGET_ARCH-g++ $PREFIX/$TARGET_ARCH/bin/g++
394 PATH=$PREFIX/$TARGET_ARCH/bin:$PREFIX/bin:$PATH
399 ncs=`eval echo $native_config_site`
401 mkdir -p `dirname $ncs`
405 ac_cv_sys_restartable_syscalls=yes
410 for i in $native_packages; do
418 rm -f $WWW/$CYGWIN_DLL.zip
419 cd $PREFIX/bin && zip $WWW/$CYGWIN_DLL.zip $CYGWIN_DLL