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
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
89 cross_configure='--prefix=$PREFIX --target=$TARGET_ARCH'
90 gcc_make='LANGUAGES="c++"'
91 cygwin_make='-k || true'
98 # Typically, we install native packages under
100 # /Cygnus/usr/package-x.y.z
102 # so that's how we configure them.
104 native_configure='--target=$TARGET_ARCH --build=$TARGET_ARCH --host=$HOST --oldincludedir=$PREFIX/include --prefix=$NATIVE_PREFIX/$package --program-suffix='
105 native_config_site='$PREFIX/share/native-config.site'
107 # urg: avoid making doc dir
108 regex_make='subdirs=test'
109 regex_before_install='ar -ru libregex.a regex.o \; mkdir -p $PREFIX/{include,lib} \; cp ../$package/regex.h $PREFIX/include \; cp libregex.a $PREFIX/lib'
110 regex_install='subdirs=test'
111 regex_before_zip='mkdir -p $install_prefix/{include,lib} \; cp ../$package/regex.h $install_prefix/include \; cp libregex.a $install_prefix/lib'
113 guile_patch='guile-1.3.4-gnu-windows.patch'
114 if [ $target = mingw ]; then
115 guile_patch1='guile-1.3.4-mingw.patch'
116 guile_cflags='-I $PREFIX/$TARGET_ARCH/include -I $PREFIX/i686-pc-cygwin/include'
118 guile_ldflags='-L$PREFIX/lib $PREFIX/bin/$CYGWIN_DLL'
119 guile_make='oldincludedir=$PREFIX/include'
121 # We need to get guile properly installed for cross-development, ie
122 # at our prefix: $PREFIX. When packaging, the prefix we configured
125 guile_install='prefix=$PREFIX'
127 lilypond_version=@TOPLEVEL_VERSION@
128 if [ $target = mingw ]; then
129 lilypond_cflags='-I $PREFIX/$TARGET_ARCH/include -I $PREFIX/i686-pc-cygwin/include'
131 lilypond_ldflags='-L$PREFIX/lib -lguile $PREFIX/bin/$CYGWIN_DLL'
132 #lilypond_configure='--enable-tex-tfmdir=miktex/usr/share/texmf/fonts/tfm/public/cm/'
133 ## URG, help2man: doesn't know about cross-compilation.
134 #lilypond_make='-k || make -k || true'
135 lilypond_patch=lilypond-manpages.patch
136 # Don't install lilypond
137 lilypond_install='--just-print'
138 lilypond_before_zip='cp -pr $PREFIX/src/$package/input $install_prefix \; cp -p \`find $PREFIX/src/$package -type f -maxdepth 1\` $install_prefix'
143 lilypond-$lilypond_version
146 #######################
147 # end of config section
148 #######################
150 cygwin_dirs=`/bin/ls -d1 $CYGWIN_SOURCE/*`
151 cygwin_source_path=`echo $CYGWIN_SOURCE $cygwin_dirs`
152 source_path=`echo $SOURCE_PATH:$cygwin_source_path | sed 's/:/ /g'`
164 first_dir=`tar tzf $tarball | head -1`
165 src_dir=`dirname $first_dir`
167 if [ "$src_dir" = "src" -o "$src_dir" = "./src" \
168 -o "$src_dir" = "." ]; then
174 if [ "$src_dir" != "$dest_dir" -a "$src_dir" != "$dest_dir/" ]; then
175 mv $src_dir $dest_dir
185 string=`eval echo $\`eval echo "${1}${2}"\``
195 for i in $source_path; do
196 found=`/bin/ls -d1 $i/$expr 2>/dev/null | head -1`
197 if [ -e "$found" ]; then
210 base=`basename $file $ext`
211 if [ $base$ext != $i ]; then
213 if expr "$type" : "$expr"; then
214 mv -f $file $base$ext
223 if [ -d $package ]; then
224 echo "$package: directory exists"
225 echo "$package: skipping"
229 name=`echo $package | sed 's/-.*//'`
230 name_cflags=`expand $name _cflags`
231 name_ldflags=`expand $name _ldflags`
232 name_configure=`expand $name _configure`
233 type_config_site=`expand $type _config_site`
234 type_configure=`expand $type _configure`
235 name_make=`expand $name _make`
236 name_before_install="`expand $name _before_install`"
237 name_install=`expand $name _install`
239 found=`find_path $package*src.tar.gz`
240 if [ "$found" = "" ]; then
241 found=`find_path $package.tar.gz`
243 if [ "$found" = "" ]; then
244 found=`find_path $name*tar.gz`
246 if [ "$found" = "" ]; then
247 echo "$package: no such tarball"
251 untar $found $package
252 patch=`expand $name _patch`
254 while [ "x$patch" != "x" ]; do
258 found=`find_path $patch`
259 if [ "$found" = "" ]; then
260 echo "$patch: no such file"
263 patch -p1 -E < $found
265 count=`expr $count + 1`
266 patch=`expand $name _patch$count`
272 CONFIG_SITE="$type_config_site" CFLAGS="$name_cflags" LDFLAGS="$name_ldflags" ../$package/configure $type_configure $name_configure || exit 1
273 make $name_make || exit 1
274 `eval $name_before_install` || exit 1
275 make install $name_install || exit 1
279 ## urg, let's hope Cygnus uses rpm for packaging its next release
285 zip=$WWW/$package.zip
287 echo "$zip: package exists"
288 echo "$zip: skipping"
292 name=`echo $package | sed 's/-.*//'`
293 name_pack_install=`expand $name _pack_install`
294 install_root=/tmp/$package-install
295 install_prefix=$install_root/$NATIVE_PREFIX/$package
296 name_before_zip=`expand $name _before_zip`
300 mkdir -p $install_prefix
302 cd $PREFIX/src/$type-$package || exit 1
303 make install prefix=$install_prefix $name_pack_install
305 ## duh, rename executables,
306 ## for people that use a dumb shell instead of bash
307 cd $install_prefix/bin &&
308 for i in `/bin/ls -d1 *`; do
309 fix_extension $i .exe '.*Windows.*\(executable\).*'
310 fix_extension $i .py '.*\(python\).*'
314 `eval $name_before_zip` || exit 1
315 cd $install_root && zip -ry $zip .$NATIVE_PREFIX
328 if [ ! -d $PREFIX ]; then
330 found=`find_path $cygwin_binary`
331 if [ "$found" = "" ]; then
332 echo "$cygwin_binary: no such tarball"
336 # urg, bug in gcc's cross-make configuration
337 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
341 # urg, bug in gcc's cross-make configuration
343 ln -s $PREFIX/$TARGET_ARCH/include .
345 echo "$PREFIX: already exists"
346 echo "$cygwin_binary: skipping"
350 if [ ! -d $PREFIX/$TARGET_ARCH ]; then
352 found=`find_path $mingw_binary`
353 if [ "$found" = "" ]; then
354 echo "$mingw_binary: no such tarball"
359 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
361 mkdir -p $PREFIX/i386-mingw32/include
362 ln -s $PREFIX/i386-mingw32 $TARGET_ARCH
363 ln -s $PREFIX/$TARGET_ARCH/include .
366 if [ ! -e $NATIVE_PREFIX ]; then
367 ln -s $ROOT /Cygnus || exit 1
372 PATH=$PATH:$PREFIX/bin
375 for i in $cross_packages; do
379 echo "$i: build failed"
384 # urg, bug in gcc's cross-make install
385 mv $PREFIX/bin/cygwin1.dll $PREFIX/bin/$CYGWIN_DLL
386 mv $PREFIX/bin/mingwc10.dll $PREFIX/bin/$MINGW_DLL
387 ln -f $PREFIX/bin/$TARGET_ARCH-gcc $PREFIX/$TARGET_ARCH/bin/cc
388 ln -f $PREFIX/bin/$TARGET_ARCH-c++ $PREFIX/$TARGET_ARCH/bin/c++
389 ln -f $PREFIX/bin/$TARGET_ARCH-g++ $PREFIX/$TARGET_ARCH/bin/g++
391 PATH=$PREFIX/$TARGET_ARCH/bin:$PREFIX/bin:$PATH
396 ncs=`eval echo $native_config_site`
398 mkdir -p `dirname $ncs`
402 ac_cv_sys_restartable_syscalls=yes
407 for i in $native_packages; do
415 rm -f $WWW/$CYGWIN_DLL.zip
416 cd $PREFIX/bin && zip $WWW/$CYGWIN_DLL.zip $CYGWIN_DLL