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 WWW=$DEVEL/WWW/lilypond/gnu-windows
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
90 #######################
91 # end of config section
92 #######################
102 string=`eval echo $\`eval echo "${1}${2}"\``
111 source_path=${2:-$SOURCE_PATH}
112 path_list=`echo $source_path | sed 's/:/ /g'`
115 for i in $path_list; do
116 found=`/bin/ls -d1 $i/$expr 2>/dev/null | head -1`
117 if [ "$found" != "" ] && [ -e $found ]; then
128 name=`echo $package | sed 's/-.*//'`
130 if [ $type = "cross" ]; then
131 target_arch=$CROSS_TARGET_ARCH
134 target_arch=$TARGET_ARCH
138 rpm_package=`find_path $name*.rpm "$topdir/RPMS/$cta:$topdir/RPMS/$ta"`
139 if [ "$rpm_package" != "" ]; then
140 echo "$rpm_package: package exists"
141 echo "$rpm_package: just updating db"
142 rpm -ivv --justdb --ignoreos --ignorearch --nodeps --force\
143 --dbpath $NATIVE_ROOT/var/lib/rpm \
144 $topdir/RPMS/$a/$name*.rpm
149 found=`find_path $package*src.rpm`
150 if [ "$found" != "" ]; then
151 rpm --root $NATIVE_ROOT -ivv $found || exit 1
152 rpm --target=$target_arch -ba SPECS/$name*.spec || exit 1
154 tarball=`/bin/ls -d1 SOURCES/$package*tar.gz 2>/dev/null | head -1`
155 if [ "SPECS/$name.spec" != "" ] && [ "$tarball" != "" ]; then
156 rpm --target=$target_arch -ba SPECS/$name.spec || exit 1
158 found=`find_path $package*tar.gz`
159 if [ "$found" != "" ]; then
160 rpm --target=$target_arch -ta $found || exit 1
162 echo "$package: no such rpm or tarball"
167 name=`echo $package | sed 's/-.*//'`
169 rpm -ivv --ignoreos --ignorearch --nodeps --force\
170 --dbpath $NATIVE_ROOT/var/lib/rpm \
171 $topdir/RPMS/$a/$name*.rpm
185 if [ ! -d $PREFIX/bin ]; then
189 mkdir -p $TARGET_ARCH
190 cd $TARGET_ARCH && ln -s ../include .
192 found=`find_path $cygwin_binary`
193 if [ "$found" = "" ]; then
194 echo "$cygwin_binary: no such tarball"
198 # urg, bug in gcc's cross-make configuration
199 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
201 echo "$PREFIX: already exists"
202 echo "$cygwin_binary: skipping"
206 if [ ! -d $PREFIX/$TARGET_ARCH ]; then
208 found=`find_path $mingw_binary`
209 if [ "$found" = "" ]; then
210 echo "$mingw_binary: no such tarball"
215 mkdir -p $PREFIX/lib/gcc-lib/$TARGET_ARCH/2.95.2
217 mkdir -p $PREFIX/i386-mingw32/include
218 ln -s $PREFIX/i386-mingw32 $TARGET_ARCH
219 ln -s $PREFIX/$TARGET_ARCH/include .
223 if [ ! -e $NATIVE_ROOT ]; then
224 ln -s $ROOT $NATIVE_ROOT || exit 1
227 #mv $PREFIX/bin/cygwin1.dll $PREFIX/bin/$CYGWIN_DLL
228 #mv $PREFIX/bin/mingwc10.dll $PREFIX/bin/$MINGW_DLL
230 mkdir -p $ROOT/var/redhat
231 mkdir -p $PREFIX/src/redhat
233 native_config_site='$PREFIX/share/native-config.site'
235 ncs=`eval echo $native_config_site`
237 mkdir -p `dirname $ncs`
241 ac_cv_sys_restartable_syscalls=yes
242 ac_cv_sprintf_count=yes
244 db_cv_sprintf_count=yes
248 cross_rpm_dir=$NATIVE_PREFIX/lib/rpm/$cta
249 cross_rpm_link=/usr/lib/rpm/$cta
250 mkdir -p $cross_rpm_dir
251 rm -f $cross_rpm_link
252 ln -s $NATIVE_PREFIX/lib/rpm/$cta $cross_rpm_link
254 native_rpm_dir=$NATIVE_PREFIX/lib/rpm/$ta
255 native_rpm_link=/usr/lib/rpm/$ta
256 mkdir -p $native_rpm_dir
257 rm -f $native_rpm_link
258 ln -s $NATIVE_PREFIX/lib/rpm/$ta $native_rpm_link
260 cross_macros=$cross_rpm_dir/macros
261 native_macros=$native_rpm_dir/macros
263 base_macros=$NATIVE_PREFIX/lib/rpm/base-macros
265 cat > $base_macros <<EOF
269 %native_prefix /Cygnus/usr
271 %_topdir %{native_prefix}/src/redhat
272 %_sourcedir %{native_prefix}/src/redhat/SOURCES
273 %_builddir %{native_prefix}/src/redhat/BUILD
274 %_srcrpmdir %{native_prefix}/src/redhat/SRPMS
275 %_rpmdir %{native_prefix}/src/redhat/RPMS
277 %DocDir %{native_prefix}/doc
279 %cygwin_dll %{native_prefix}/bin/cygwin1.dll
286 cp -f $base_macros $cross_macros
287 cat >> $cross_macros <<EOF
288 %_rpmfilename %%{ARCH}-x-cygwin/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-x-cygwin.rpm
292 %_target_platform $TARGET_ARCH
295 CFLAGS="%{cflags}" LDFLAGS="%{ldflags}" CONFIG_SITE=%{config_site} \
296 %{sourcedir}/configure \
297 --host=%{_host} --target=%{_target_platform} --prefix=%{native_prefix}
300 cp -f $base_macros $native_macros
301 cat >> $native_macros <<EOF
302 %config_site %{_prefix}/share/native-config.site
303 #%program_suffix .exe
304 %program_suffix %{nil}
310 %_rpmfilename %%{ARCH}-cygwin/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-cygwin.rpm
312 %__find_provides %{native_prefix}/lib/rpm/cygwin.prov
313 %__find_requires %{native_prefix}/lib/rpm/cygwin.req
315 %ldflags -L%{native_prefix}/lib %{cygwin_dll}
317 CFLAGS="%{cflags}" LDFLAGS="%{ldflags}" CONFIG_SITE=%{config_site} \
318 %{sourcedir}/configure --host=%{_host} --target=%{_target_platform} \
319 --prefix=%{native_prefix} --program-suffix=%{program_suffix}
322 rm -f $native_rpm_dir/cygwin.prov
323 cat > $native_rpm_dir/cygwin.prov <<EOF
326 f=\`echo $f | tr '[:upper:]' '[:lower:]'\`
333 chmod 755 $native_rpm_dir/cygwin.prov
335 rm -f $native_rpm_dir/cygwin.req
336 cat > $native_rpm_dir/cygwin.req <<EOF
341 *.dll|*.exe) objdump -p $f | grep "DLL Name:" | cut -f3 -d" " | tr '[
348 chmod 755 $native_rpm_dir/cygwin.req
353 rm -rf $NATIVE_ROOT/var/lib/rpm
354 mkdir -p $NATIVE_ROOT/var/lib/rpm
355 rpm --root $NATIVE_ROOT --initdb
357 topdir=$NATIVE_PREFIX/src/redhat
358 mkdir -p $topdir/{BUILD,RPMS/{$ta,$cta},SOURCES,SPECS,SRPMS}
365 PATH=$PREFIX/bin:$PATH
370 for i in $cross_rpm; do
374 echo "$i: rpm build failed"
379 # urg, bug in binutil's cross-make install
381 cd $PREFIX/$TARGET_ARCH/bin
382 ln -f ../../bin/$TARGET_ARCH-objdump objdump
383 ln -f ../../bin/$TARGET_ARCH-objcopy objcopy
385 # urg, bug in gcc's cross-make install
387 cd $PREFIX/$TARGET_ARCH/bin
388 ln -f ../../bin/$TARGET_ARCH-gcc cc
389 ln -f ../../bin/$TARGET_ARCH-gcc gcc
390 ln -f ../../bin/$TARGET_ARCH-c++ c++
391 ln -f ../../bin/$TARGET_ARCH-g++ g++
394 PATH=$PREFIX/$TARGET_ARCH/bin:$PATH
398 for i in $native_rpm; do
402 echo "$i: rpm build failed"
407 cd $NATIVE_PREFIX/src/redhat/BUILD
409 rm -f $WWW/$CYGWIN_DLL.gz
410 cd $WWW && cp -f $PREFIX/bin/$CYGWIN_DLL . && gzip -f $CYGWIN_DLL
412 rm -f $WWW/rpm2cpio.gz
413 cd $WWW && cp -f $PREFIX/bin/rpm2cpio . && gzip -f rpm2cpio
415 cat > $WWW/setup.sh <<EOF
419 gunzip rpm2cpio.gz || exit 1
420 # currently, the cygwin1.dll's conflict.
421 # it's been reported one can't have both in PATH
424 gzip -dc cygwin.dll.gz > \$dll/cygwin1.dll
426 cd \$ROOT/.. && (PATH=\$dll \$here/rpm2cpio \$here/rpm*.rpm ) | cpio -ivmd
427 PATH=\$dll rpm --root=\$ROOT --initdb
429 for i in redhat/RPMS/$ta/*.rpm; do
430 PATH=\$dll rpm -ivv --ignoreos --ignorearch --nodeps --force\
431 --dbpath \$ROOT/var/lib/rpm \
436 cat > $WWW/setup.bat <<EOF
438 if errorlevel 0 goto exit
439 @echo "setup.bat: can't find bash"
440 @echo "setup.bat: please install usertools from"
441 @echo "setup.bat: http://sourceware.cygnus.com/cygwin/"
445 cat > $WWW/lilypond.sh <<EOF
448 # currently, the cygwin1.dll's conflict.
449 # it's been reported one can't have both in PATH
451 PATH=\$dll \$ROOT/bin/lilypond \$*
454 cat > $WWW/midi2ly.sh <<EOF
457 # currently, the cygwin1.dll's conflict.
458 # it's been reported one can't have both in PATH
460 PATH=\$dll \$ROOT/bin/midi2ly \$*
463 cat > $WWW/lilypond.bat <<EOF
464 bash lilypond.sh %1 %2 %3 %4 %5 %6 %7 %8 %9
467 cat > $WWW/midi2ly.bat <<EOF
468 bash midi2ly.sh %1 %2 %3 %4 %5 %6 %7 %8 %9
471 for i in guile-1 rpm lilypond; do
472 rpm=`find_path $i*.rpm redhat/RPMS/$ta`
473 dist_rpms="$dist_rpms $rpm"
476 cd $WWW && zip -r setup.zip *.gz $dist_rpms *.bat *.sh