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 # * RPM distribution of the cygwin pre-release sources, from:
18 # http://appel.dyndns.org/lilypond/gnu-windows/redhat/SRPMS/
20 # The tarballs were fetched from:
22 # ftp://sourceware.cygnus.com/pub/cygwin/private/cygwin-net-485/
32 if [ $target = cygwin ]; then
33 ROOT=/usr/src/cygwin-net-485
34 TARGET_ARCH=i686-pc-cygwin
36 ROOT=/usr/src/mingw-net-485
37 TARGET_ARCH=i386-pc-mingw32
41 NATIVE_PREFIX=$NATIVE_ROOT/usr
45 distdir=$DEVEL/WWW/lilypond/gnu-windows/lily-w32
48 SOURCE_PATH=$DEVEL/usr/src/releases:$DEVEL/usr/src/redhat/SRPMS
51 OS=`uname -s | tr '[A-Z]' '[a-z]'`
53 CROSS_TARGET_ARCH=$ARCH-x-$TARGET_ARCH
57 cygwin_binary=cygwin-20000301.tar.gz
58 mingw_binary=bin-crtdll-2000-02-03.tar.gz
60 #CYGWIN_DLL=cygwin1-net-485.dll
61 CYGWIN_DLL=cygwin1.dll
62 MINWG_DLL=mingwc10-net-485.dll
76 #guile_after_rpm='ln -f $NATIVE_PREFIX/bin/i686-redhat-cygwin-guile-config $NATIVE_PREFIX/bin/i686-pc-cygwin-guile-config'
78 lilypond_version=@TOPLEVEL_VERSION@
86 lilypond-$lilypond_version
89 #######################
90 # end of config section
91 #######################
101 string=`eval echo $\`eval echo "${1}${2}"\``
110 source_path=${2:-$SOURCE_PATH}
111 path_list=`echo $source_path | sed 's/:/ /g'`
114 for i in $path_list; do
115 found=`/bin/ls -d1 $i/$expr 2>/dev/null | head -1`
116 if [ "$found" != "" ] && [ -e $found ]; then
127 name=`echo $package | sed 's/-.*//'`
129 if [ $type = "cross" ]; then
130 target_arch=$CROSS_TARGET_ARCH
133 target_arch=$TARGET_ARCH
137 rpm_package=`find_path $name*.rpm "$topdir/RPMS/$cta:$topdir/RPMS/$ta"`
138 if [ "$rpm_package" != "" ]; then
139 echo "$rpm_package: package exists"
140 echo "$rpm_package: just updating db"
141 rpm -ivv --justdb --ignoreos --ignorearch --nodeps --force\
142 --dbpath $NATIVE_ROOT/var/lib/rpm \
143 $topdir/RPMS/$a/$name*.rpm
148 found=`find_path $package*src.rpm`
149 if [ "$found" != "" ]; then
150 rpm --root $NATIVE_ROOT -ivv $found || exit 1
151 rpm --target=$target_arch -ba SPECS/$name*.spec || exit 1
153 tarball=`/bin/ls -d1 SOURCES/$package*tar.gz 2>/dev/null | head -1`
154 if [ "SPECS/$name.spec" != "" ] && [ "$tarball" != "" ]; then
155 rpm --target=$target_arch -ba SPECS/$name.spec || exit 1
157 found=`find_path $package*tar.gz`
158 if [ "$found" != "" ]; then
159 rpm --target=$target_arch -ta $found || exit 1
161 echo "$package: no such rpm or tarball"
166 name=`echo $package | sed 's/-.*//'`
168 rpm -ivv --ignoreos --ignorearch --nodeps --force\
169 --dbpath $NATIVE_ROOT/var/lib/rpm \
170 $topdir/RPMS/$a/$name*.rpm
184 if [ ! -d $PREFIX/bin ]; then
188 mkdir -p $TARGET_ARCH
189 cd $TARGET_ARCH && ln -s ../include .
191 found=`find_path $cygwin_binary`
192 if [ "$found" = "" ]; then
193 echo "$cygwin_binary: no such tarball"
197 # urg, bug in gcc's cross-make configuration
198 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
200 echo "$PREFIX: already exists"
201 echo "$cygwin_binary: skipping"
205 if [ ! -d $PREFIX/$TARGET_ARCH ]; then
207 found=`find_path $mingw_binary`
208 if [ "$found" = "" ]; then
209 echo "$mingw_binary: no such tarball"
214 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
216 mkdir -p $PREFIX/i386-mingw32/include
217 ln -s $PREFIX/i386-mingw32 $TARGET_ARCH
218 ln -s $PREFIX/$TARGET_ARCH/include .
222 if [ ! -e $NATIVE_ROOT ]; then
223 ln -s $ROOT $NATIVE_ROOT || exit 1
226 #mv $PREFIX/bin/cygwin1.dll $PREFIX/bin/$CYGWIN_DLL
227 #mv $PREFIX/bin/mingwc10.dll $PREFIX/bin/$MINGW_DLL
229 mkdir -p $ROOT/var/redhat
230 mkdir -p $PREFIX/src/redhat
232 native_config_site='$PREFIX/share/native-config.site'
234 ncs=`eval echo $native_config_site`
236 mkdir -p `dirname $ncs`
240 ac_cv_sys_restartable_syscalls=yes
241 ac_cv_sprintf_count=yes
243 db_cv_sprintf_count=yes
247 cross_rpm_dir=$NATIVE_PREFIX/lib/rpm/$cta
248 cross_rpm_link=/usr/lib/rpm/$cta
249 mkdir -p $cross_rpm_dir
250 rm -f $cross_rpm_link
251 ln -s $NATIVE_PREFIX/lib/rpm/$cta $cross_rpm_link
253 native_rpm_dir=$NATIVE_PREFIX/lib/rpm/$ta
254 native_rpm_link=/usr/lib/rpm/$ta
255 mkdir -p $native_rpm_dir
256 rm -f $native_rpm_link
257 ln -s $NATIVE_PREFIX/lib/rpm/$ta $native_rpm_link
259 cross_macros=$cross_rpm_dir/macros
260 native_macros=$native_rpm_dir/macros
262 base_macros=$NATIVE_PREFIX/lib/rpm/base-macros
264 cat > $base_macros <<EOF
268 %native_prefix /Cygnus/usr
270 %_topdir %{native_prefix}/src/redhat
271 %_sourcedir %{native_prefix}/src/redhat/SOURCES
272 %_builddir %{native_prefix}/src/redhat/BUILD
273 %_srcrpmdir %{native_prefix}/src/redhat/SRPMS
274 %_rpmdir %{native_prefix}/src/redhat/RPMS
276 #%DocDir %{native_prefix}/doc
277 %DocDir /Cygnus/usr/doc
278 %_defaultdocdir /Cygnus/usr/doc
280 %cygwin_dll %{native_prefix}/bin/cygwin1.dll
287 cp -f $base_macros $cross_macros
288 cat >> $cross_macros <<EOF
289 %_rpmfilename %%{ARCH}-x-cygwin/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-x-cygwin.rpm
293 %_target_platform $TARGET_ARCH
296 CFLAGS="%{cflags}" LDFLAGS="%{ldflags}" CONFIG_SITE=%{config_site} \
297 %{sourcedir}/configure \
298 --host=%{_host} --target=%{_target_platform} --prefix=%{native_prefix}
301 cp -f $base_macros $native_macros
302 cat >> $native_macros <<EOF
303 %config_site %{_prefix}/share/native-config.site
304 #%program_suffix .exe
305 %program_suffix %{nil}
311 %_rpmfilename %%{ARCH}-cygwin/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-cygwin.rpm
313 %__find_provides %{native_prefix}/lib/rpm/cygwin.prov
314 %__find_requires %{native_prefix}/lib/rpm/cygwin.req
316 %ldflags -L%{native_prefix}/lib %{cygwin_dll}
318 CFLAGS="%{cflags}" LDFLAGS="%{ldflags}" CONFIG_SITE=%{config_site} \
319 %{sourcedir}/configure --host=%{_host} --target=%{_target_platform} \
320 --prefix=%{native_prefix} --program-suffix=%{program_suffix}
323 rm -f $native_rpm_dir/cygwin.prov
324 cat > $native_rpm_dir/cygwin.prov <<EOF
327 f=\`echo $f | tr '[:upper:]' '[:lower:]'\`
334 chmod 755 $native_rpm_dir/cygwin.prov
336 rm -f $native_rpm_dir/cygwin.req
337 cat > $native_rpm_dir/cygwin.req <<EOF
342 *.dll|*.exe) objdump -p $f | grep "DLL Name:" | cut -f3 -d" " | tr '[
349 chmod 755 $native_rpm_dir/cygwin.req
354 rm -rf $NATIVE_ROOT/var/lib/rpm
355 mkdir -p $NATIVE_ROOT/var/lib/rpm
356 rpm --root $NATIVE_ROOT --initdb
358 topdir=$NATIVE_PREFIX/src/redhat
359 mkdir -p $topdir/{BUILD,RPMS/{$ta,$cta},SOURCES,SPECS,SRPMS}
366 PATH=$PREFIX/bin:$PATH
371 for i in $cross_rpm; do
375 echo "$i: rpm build failed"
380 # urg, bug in binutil's cross-make install
382 cd $PREFIX/$TARGET_ARCH/bin
383 ln -f ../../bin/$TARGET_ARCH-objdump objdump
384 ln -f ../../bin/$TARGET_ARCH-objcopy objcopy
386 # urg, bug in gcc's cross-make install
388 cd $PREFIX/$TARGET_ARCH/bin
389 ln -f ../../bin/$TARGET_ARCH-gcc cc
390 ln -f ../../bin/$TARGET_ARCH-gcc gcc
391 ln -f ../../bin/$TARGET_ARCH-c++ c++
392 ln -f ../../bin/$TARGET_ARCH-g++ g++
395 PATH=$PREFIX/$TARGET_ARCH/bin:$PATH
399 for i in $native_rpm; do
403 echo "$i: rpm build failed"
408 cd $NATIVE_PREFIX/src/redhat/BUILD
410 rm -f $distdir/$CYGWIN_DLL.gz
411 cd $distdir && cp -f $PREFIX/bin/$CYGWIN_DLL . && gzip -f $CYGWIN_DLL
413 rm -f $distdir/rpm2cpio.gz
414 cd $distdir && cp -f $PREFIX/bin/rpm2cpio . && gzip -f rpm2cpio
417 cat > $distdir/setup.sh <<EOF
422 gunzip rpm2cpio.gz || exit 1
423 # currently, the cygwin1.dll's conflict.
424 # it's been reported one can't have both in PATH
427 gzip -dc cygwin.dll.gz > \$dll/cygwin1.dll
429 cd \$ROOT/.. && (PATH=\$dll \$here/rpm2cpio \$here/rpm*.rpm ) | cpio -ivmd
430 PATH=\$dll rpm --root=\$ROOT --initdb
432 for i in RPMS/$ta/*.rpm; do
433 PATH=\$dll rpm -ivv --ignoreos --ignorearch --nodeps --force\
434 --dbpath \$ROOT/var/lib/rpm \
439 cat > $distdir/setup.bat <<EOF
441 if errorlevel 0 goto exit
442 @echo "setup.bat: can't find bash"
443 @echo "setup.bat: please install usertools from"
444 @echo "setup.bat: http://sourceware.cygnus.com/cygwin/"
448 cat > $distdir/lilypond.sh <<EOF
452 # currently, the cygwin1.dll's conflict.
453 # it's been reported one can't have both in PATH
455 PATH=\$dll \$ROOT/bin/lilypond \$*
458 cat > $distdir/midi2ly.sh <<EOF
462 # currently, the cygwin1.dll's conflict.
463 # it's been reported one can't have both in PATH
465 PATH=\$dll \$ROOT/bin/midi2ly \$*
468 cat > $distdir/lilypond.bat <<EOF
469 bash lilypond.sh %1 %2 %3 %4 %5 %6 %7 %8 %9
472 cat > $distdir/midi2ly.bat <<EOF
473 bash midi2ly.sh %1 %2 %3 %4 %5 %6 %7 %8 %9
476 distbase=`basename $distdir`
479 ln -s ../redhat/RPMS .
481 www=`dirname $distdir`
483 for i in guile-1 rpm lilypond; do
484 rpm=`find_path $i*.rpm $distbase/RPMS/$ta`
485 dist_rpms="$dist_rpms $rpm"
489 cd $www && zip setup.zip lily-w32 $distbase/* $dist_rpms