Make the build script actually work on rpi1/wheezy.
1 files changed, 38 insertions(+), 29 deletions(-)

M build-avr-ada-environment.sh
M build-avr-ada-environment.sh +38 -29
@@ 15,14 15,14 @@ 
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #
 
-GNATPREFIX=$HOME/programs64/gnat-native-49
-AVRADAPREFIX=$HOME/programs64/avr-ada-49
+GNATPREFIX=$HOME/programs/gnat-native-47
+AVRADAPREFIX=$HOME/programs/avr-ada-47
 TOPDIR=$PWD
 
-GCC_VERSION=4.9.2
-AVR_GCC_VERSION=4.9.2
+GCC_VERSION=4.7.4
+AVR_GCC_VERSION=4.7.4
 
-LSB_REL=`lsb_release -i|tr "\t" " "|tr -s " "|cut -f3 -d" "`
+LSB_REL=Debian
 if [ x"$LSB_REL" != x"" ]; then
   DISTRO=$LSB_REL;
 else

          
@@ 42,8 42,8 @@ fetch_avrada()
 	fi
 }
 
-# GCC 4.[79].x is required for building AVR-Ada 1.2.
-build_gcc4()
+# GCC 4.7.x is required for building AVR-Ada 1.2.
+build_gcc47()
 {
 	fetch_avrada
         

          
@@ 57,21 57,33 @@ build_gcc4()
 	fi
 
 	tar zxf gcc-${GCC_VERSION}.tar.gz
+	if [ -f texinfo.patch ]; then
+		# cd gcc-${GCC_VERSION} && patch -p0 < ../texinfo.patch || fail "gcc texinfo patch"
+		# patch -p0 < ../texinfo2.patch || fail "gcc texinfo2 patch"
+		echo cd ..
+	elif [ -f ../texinfo.patch ]; then
+		# cd gcc-${GCC_VERSION} && patch -p0 < ../../texinfo.patch || fail "gcc texinfo patch"
+		# patch -p0 < ../../texinfo2.patch || fail "gcc texinfo2 patch"
+		echo cd ..
+	fi
 
 	rm -rf gcc-obj-${GCC_VERSION}
 	mkdir gcc-obj-${GCC_VERSION} && cd gcc-obj-${GCC_VERSION} || fail "cd gcc-obj-${GCC_VERSION}"
 	if [ -d /usr/lib/x86_64-linux-gnu/ ]; then
 		export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
 	fi
-	if [ -d /usr/include/x86_64-linux-gnu ]; then
-		export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
-		export CPATH=/usr/include/x86_64-linux-gnu
-		export CPLUS_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
+	if [ -d /usr/lib/arm-linux-gnueabihf/ ]; then
+		export LIBRARY_PATH=/usr/lib/arm-linux-gnueabihf
+	fi
+	if [ -d /usr/include/arm-linux-gnueabihf ]; then
+		export C_INCLUDE_PATH=/usr/include/arm-linux-gnueabihf
+		export CPATH=/usr/include/arm-linux-gnueabihf
+		export CPLUS_INCLUDE_PATH=/usr/include/arm-linux-gnueabihf
 	fi
 
 	case "$DISTRO" in
 		Debian|Ubuntu)
-			ADAC=gcc-4.6 CC=gcc-4.6 ../gcc-${GCC_VERSION}/configure --enable-languages=c,ada --prefix=$GNATPREFIX --disable-multilib --without-cloog --without-ppl || fail "gcc: configure"
+			LDFLAGS=-L/usr/lib/arm-linux-gnueabihf/ ADAC=gcc-4.6 CC=gcc-4.6 ../gcc-${GCC_VERSION}/configure --enable-languages=c,ada --prefix=$GNATPREFIX --enable-multilib --without-cloog --without-ppl --disable-sjlj-exceptions --with-fpu=vfp --with-float=hard --with-arch=armv6|| fail "gcc: configure"
 			;;
 		*)
 			../gcc-${GCC_VERSION}/configure --enable-languages=c,ada --prefix=$GNATPREFIX || fail "gcc: configure"

          
@@ 86,8 98,8 @@ build_gcc4()
 build_avrbinutils()
 {
 	cd $TOPDIR
-	if [ ! -f binutils-2.24.tar.bz2 ]; then
-		wget http://ftp.uni-kl.de/pub/gnu/binutils/binutils-2.24.tar.bz2
+	if [ ! -f binutils-2.20.1a.tar.bz2 ]; then
+		wget http://ftp.uni-kl.de/pub/gnu/binutils/binutils-2.20.1a.tar.bz2
 	fi
 	if [ -f $AVRADAPREFIX/bin/avr-as ]; then
 		echo "avr-binutils already installed, skipping"

          
@@ 95,29 107,27 @@ build_avrbinutils()
 	fi
 	fetch_avrada
 
-	rm -rf binutils-2.24
-	tar jxf binutils-2.24.tar.bz2 || fail "binutils: tar"
-	cd binutils-2.24
-	for a in ../avr-ada/patches/binutils/2.24/*.patch;
+	rm -rf binutils-2.20.1
+	tar jxf binutils-2.20.1a.tar.bz2 || fail "binutils: tar"
+	cd binutils-2.20.1
+	for a in ../avr-ada/patches/binutils/2.20.1/*.patch;
 	do
 		patch -p0 < $a || fail "avr-binutils: patch $a"
 	done
-	# sed -i -e 's/@colophon/@@colophon/' \
-	#	-e 's/doc@cygnus.com/doc@@cygnus.com/' bfd/doc/bfd.texinfo
+	sed -i -e 's/@colophon/@@colophon/' \
+		-e 's/doc@cygnus.com/doc@@cygnus.com/' bfd/doc/bfd.texinfo
 
 	cd ..
-        # sed -i.bak -e 's/\@colophon/\@\@colophon/' -e 's/doc\@cygnus.com/doc\@\@cygnus.com/' binutils-2.20.1/bfd/doc/bfd.texinfo
-	# sed -i.back -e 's/SUBDIRS = doc po/SUBDIRS = po/' binutils-2.20.1/gas/Makefile.in
 
 	rm -rf binutils-obj
 	mkdir binutils-obj && cd binutils-obj || fail "binutils: mkdir/cd"
-	../binutils-2.24/configure --target=avr --program-prefix=avr- \
+	../binutils-2.20.1/configure --target=avr --program-prefix=avr- \
 		--disable-shared --disable-nls --enable-commonbfdlib=no \
 		--disable-werror \
 		--prefix=$AVRADAPREFIX || fail "binutils: configure"
         sed -i -e 's/SUBDIRS = doc po/SUBDIRS = po/' gas/Makefile
-        sed -i -e 's/SUBDIRS = doc po/SUBDIRS = po/' ../binutils-2.24/gas/Makefile.am
-        sed -i -e 's/SUBDIRS = /SUBDIRS = #/' ../binutils-2.24/gas/Makefile.in
+        sed -i -e 's/SUBDIRS = doc po/SUBDIRS = po/' ../binutils-2.20.1/gas/Makefile.am
+        sed -i -e 's/SUBDIRS = /SUBDIRS = #/' ../binutils-2.20.1/gas/Makefile.in
 	make || fail "binutils: make"
 	make install || fail "binutils: make install"
 }

          
@@ 125,7 135,7 @@ build_avrbinutils()
 build_avrgcc()
 {
 	cd $TOPDIR
-	# export PATH="$GNATPREFIX/bin":"$AVRADAPREFIX/bin":$PATH
+	export PATH="$GNATPREFIX/bin":"$AVRADAPREFIX/bin":$PATH
 	export PATH="$AVRADAPREFIX/bin":$PATH
 	mkdir avr
 	if [ -d gcc-${AVR_GCC_VERSION} ]; then

          
@@ 150,9 160,8 @@ build_avrgcc()
 	fi
 
 	tar zxf $TOPDIR/gcc-${AVR_GCC_VERSION}.tar.gz || fail "avr-gcc: tar"
-
 	cd gcc-${AVR_GCC_VERSION} || fail "avr-gcc: cd"
-	for a in ../../avr-ada/patches/gcc/4.9.2/*.patch;do patch -p0 < $a;done
+	for a in ../../avr-ada/patches/gcc/4.7.2/*.patch;do patch -p0 < $a;done
 	cd ..
 	rm -rf avr-gcc-obj
 	mkdir avr-gcc-obj && cd avr-gcc-obj || fail "avr-gcc: mkdir/cd"

          
@@ 218,7 227,7 @@ build_avrada()
 	cd ..
 }
 
-# build_gcc47
+build_gcc47
 build_avrbinutils
 build_avrgcc
 build_avrlibc