xref: /minix/external/gpl3/gcc/fetch.sh (revision e39e890e)
1#!/bin/sh
2
3set -e
4
5# Make sure we're in our directory (i.e., where this shell script is)
6echo $0
7cd `dirname $0`
8
9# Default sed: whatever's in $PATH; set by the buildsystem to be the
10# host-built sed tool we know supports the syntax we use
11: ${SED=sed}
12
13# Configure fetch method
14URL="http://www.minix3.org/distfiles-minix/gcc-4.5.3.tar.bz2"
15BACKUP_URL="ftp://ftp.gwdg.de/pub/misc/gcc/releases/gcc-4.5.3/gcc-4.5.3.tar.bz2"
16FETCH=ftp
17if which curl >/dev/null
18then
19	FETCH="curl -O -f"
20fi
21
22# Remove a few directories from the start, so we do not end up with a 165MB patch...
23DELETEDIRS="include/elf
24	libada libjava libffi libgfortran
25	boehm-gc gnattools
26	gcc/ada gcc/fortran gcc/java
27	gcc/testsuite/ada  gcc/testsuite/gnat gcc/testsuite/gnat.dg
28	gcc/testsuite/gfortran.dg  gcc/testsuite/gfortran.fortran-torture
29"
30# Fetch sources if not available
31if [ ! -d dist ];
32then
33	if [ ! -f gcc-4.5.3.tar.bz2 ];
34	then
35		$FETCH $URL
36		if [ $? -ne 0 ]; then
37			$FETCH $BACKUP_URL
38		fi
39	fi
40
41	tar -oxjf gcc-4.5.3.tar.bz2
42	mv gcc-4.5.3 dist
43	cd dist
44	rm -rf $DELETEDIRS
45	for f in gcc/doc/gccinstall.info gcc/doc/gccint.info
46	do	# This is a hack to remove NUL characters in these .info
47		# files. They make some patch(1)es fail.
48		$SED 's/^..\[index..\]$/[index]/' <$f >k && mv k $f
49	done
50	cat ../patches/* | patch -p1
51	cp ../files/minix.h gcc/config/
52	cp ../files/t-minix gcc/config/
53	cp ../files/minix-spec.h gcc/config/
54	cp ../files/arm-minix.h gcc/config/arm/minix.h
55	cp ../files/i386-minix.h gcc/config/i386/minix.h
56	cp ../files/gcov-minix-fs-wrapper.h gcc/
57fi
58
59