This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

My gcc build script (Was: Re: gcc-3.1 on Solaris 2.6 gets ld:libgcc/./libgcc.map:1: parseerror)


   William, it helps if you post the commands you used to configure & build
   GCC along with your problem report.
   Jeff
OK, here is my build script.
I've been adding to it for several years.
I ran it with no options yesterday.
Today, I added a -with-gnu option to follow Jeff's recommendation,
plus I made it automatically add --disable-multilib.
I am running it now with -with-gnu and -langc.
(I only plan on compiling C programs with gcc.)
William

:
# make.sh -- build gcc/egcs
#
#	Passes options to the make
#	no options = "bootstrap"
#	use "all" to build all languages
#
# 02Jun00 wb initial version, only tested under SuSE Linux 6.2
# 05Jun00 wb add more comments, add -bgcc to build with bounds checking
# 06Jun00 wb update to configure for C only
# 19Jul00 wb do not touch objc/objc-parse.y if it does not exist
# 13Aug01 wb add Linux release to the objdir name
# 03Sep01 wb update for FreeBSD
# 05Jun02 wb added -with-gnu option, do --disable-multilib on old Suns

#	Remove extra environment symbols

dir=`dirname $0`
if [ -f "$dir/unsetall.sh" ] ; then . $dir/unsetall.sh
elif [ -f "$HOME/bin/unsetall.sh" ] ; then . $HOME/bin/unsetall.sh
fi

#	Find out where we are

pwd=`pwd`
program="`basename $pwd`"
uname_s="`uname -s`"
uname_n="`uname -n`"
uname_r="`uname -r`"
uname_m="`uname -m`"

#	Parse the command line

cpu=i686
cc=
cflags=
mflags=
langvar=
cross=
coff=
as=
config_flags=
nice="nice nice"
with_gnu=

case "$program" in
*egcs*)	opt=no ;;
*)	opt=yes ;;
esac

case "$program" in
*egcs*|*gcc*) echo "Building $program" ;;
*)	echo "$0: Error: $pwd is not an egcs or gcc directory" ; exit 1 ;;
esac

while [ ! -z "$1" ]
do
	done=no

	case "$1" in
	-O0)	opt=no ;;			# No optimization
	-Od)	opt=def ;;			# Default optimization
	-Oy)	opt=yes ;;			# Enable optimization
	-g)	cflags="$cflags -g" ;;		# Add symbol tables
	-6)	cpu=i686 ;;			# Force 686 on SCO Unix
	-5)	cpu=i586 ;;			# Force 586 on SCO Unix
	-4)	cpu=i486 ;;			# Force 486 on SCO Unix
	-gcc)	cc=gcc ;;			# Build with gcc
	-bgcc)	cc=bgcc ;;			# Build with bgcc
	-cc)	cc=cc ;;			# Build with cc
	-rcc)	cc=rcc ;;			# Build with SCO rcc
	-cross)	cross=yes ;;			# Test SCO cross-compile
	-coff)	coff=yes ;;			# Build with COFF on SCO v5
	-langc)	langvar="LANGUAGES='c'"		# Build C compiler only
		config_flags="$config_flags --enable-languages=c" ;;
	-j2)	mflags="$mflags -j 2" ;;	# Make with 2 jobs
	-gas)	as=gas ;;			# Force gnu-as
	-with-gnu|-gnu) with_gnu=yes ;;		# Force gnu-as and gnu-ld
	-x)	set -x ;;			# Enable shell debugging
	--)	shift ; done=yes ;;		# Pass remaining args to make
	-*)	echo "$0: Unknown option $1" ;;	# Warning message
	*)	done=yes ;;			# Found make target
	esac

	if [ "$done" = yes ]
	then
		break
	fi

	shift
done

#	Do a bootstrap if no arguments

if [ -z "$*" ]
then
	set -- bootstrap
fi

#	Locate make

make=make
if [ -x /usr/local/bin/gmake ]
then
	make=/usr/local/bin/gmake
fi

#	Set the object directory and build flags

objdir=objdir

case "${uname_n}-${uname_s}" in
*-SCO_SV)
	if [ -z "$cc" ] ; then cc=cc ; fi
	objdir="${objdir}v5"
	;;
*-Linux)
	if [ -z "$cc" ] ; then cc=gcc ; fi
	objdir="${objdir}lin"
	case "$uname_r" in
	[0-9].[0-9]*)	objdir="$objdir`echo $uname_r | awk -F . '{ print $1.$2 }'`"
	esac
	cflags="$cflags -pipe"
	;;
*-FreeBSD)
	if [ -z "$cc" ] ; then cc=gcc ; fi
	cflags="$cflags -pipe"
	;;
*-SunOS)
	if [ -z "$cc" ]
	then
		if [ -x /usr/local/bin/gcc -o -x /usr/bin/gcc ]
		then
			cc=gcc
		else
			cc=cc
		fi
	fi
	case "$cc" in
	*gcc*)
		if [ -x /usr/local/bin/as ]
		then
			cflags="$cflags -pipe"
		fi
		;;
	esac
	case "$uname_m" in
	sun4c)
		# disable-multilib is required on 32-bit Solaris builds
		config_flags="$config_flags --disable-multilib"
		;;
	esac
	;;
*)
	if [ -z "$cc" ]
	then
		if [ -x /usr/local/bin/gcc -o -x /usr/bin/gcc ]
		then
			cc=gcc
		else
			cc=cc
		fi
	fi
	case "$cc" in
	*gcc*)
		if [ -x /usr/local/bin/as ]
		then
			cflags="$cflags -pipe"
		fi
		;;
	esac
	#	Check for sco 3.2v4 which has limited environment space
	if [ "$uname_n" = "$uname_s" ]
	then
		mflags="$mflags -e"
		echo "If this fails, try expmake.sh and rerun with make -e"
	fi
	;;
esac

case "$cc" in
*bgcc*)	objdir="${objdir}bgcc" ;;
*gcc*)	objdir="${objdir}gcc" ;;
*rcc)	objdir="${objdir}rcc" ;;
esac

#	Check for sco 3.2v4, the configuration sometimes guesses wrong

if [ "$uname_n" = "$uname_s" ]
then
	name="$cpu-pc-sco3.2v4.0"
	config_flags="$config_flags --build=$name --host=$name --target=$name --verbose"
fi

#	Try to build a sco 3.2v4 cross-compiler hosted on sco v5

if [ "$cross" = yes ]
then
	name="$cpu-pc-sco3.2v4.0"
	config_flags="$config_flags --build=$cpu-pc-sco3.2v5.0.5 --host=$name --target=$name --verbose"
	objdir="${objdir}x"
fi

#	Try to build a sco v5 compiler that generates coff instead of elf

if [ "$coff" = yes ]
then
	if [ "$cc" = gcc ]
	then
		cflags="$cflags -mcoff"		# coff option for gcc
		objdir="${objdir}gc"
	else
		cflags="$cflags -b coff"	# coff option for sco cc
		objdir="${objdir}sc"
	fi
fi

#	Locate the assembler

case "$as" in
*gas)
	objdir="${objdir}gas"
	config_flags="$config_flags --with-gnu-as"
	if [ "$as" = gas -a \
		-x /usr/local/bin/as -a \
		! -x /usr/local/bin/gas ]
	then
		as=/usr/local/bin/as
	fi
	;;
esac

if [ "$with_gnu" = yes -a -z "$as" ]
then
	gas=/usr/local/bin/as
	if [ -x "$gas" ]
	then
		as="$gas"
		config_flags="$config_flags --with-gnu-as --with-as=$as"
	fi
	unset gas
fi

if [ -z "$as" ]
then
	as=as
fi

for dir in /usr/local/bin /bin /usr/bin
do
	if [ -x "$dir/$as" ]
	then
		as="$dir/$as"
		break
	fi
done

#	Check for the gnu linker

if [ "$with_gnu" = yes ]
then
	gld=/usr/local/bin/ld
	if [ -x "$gld" ]
	then
		config_flags="$config_flags --with-gnu-ld --with-ld=$gld"
	fi
	unset gld
fi

#	Check for a configure script

if [ ! -f configure ]
then
	echo "$0: Error: Not the egcs root directory"
	exit 1
fi

#	Check to touch input files after applying bounds checking patches
#	Check to make extra scripts executable

if [ -d gcc/bounds ]
then
	chmod +x gcc/bounds/bgcc gcc/bounds/*.sh

	if [ ! -d "$objdir" -o ! -f "$objdir/Makefile" ]
	then
		for name in gcc/c-parse.in gcc/objc/objc-parse.y
		do
			if [ -f "$name" ]
			then
				echo "Touching $name"
				touch "$name"
			fi
		done
	fi
fi

#	Check for the object directory

if [ -d "$objdir" ]
then
	echo "$0: Warning: objdir $objdir exists"
else
	mkdir "$objdir"
fi

if [ ! -d "$objdir" ]
then
	echo "$0: objdir $objdir does not exist"
	exit 1
fi

#	Add shell tracing

set -x

#	Move to the work area

cd "$objdir"

#	Set more flags
#		The GCC installation notes used to recommend
#		setting -fno-implicit-templates

case "$cc" in
*bgcc*)
	# Turn off the welcome message, it can mess things up that see stderr
	GCC_BOUNDS_OPTS="$GCC_BOUNDS_OPTS -no-message"
	# Turn off the statistics message, it can mess things up that see stderr
	GCC_BOUNDS_OPTS="$GCC_BOUNDS_OPTS -no-statistics"
	# Continue after bad accesses
	GCC_BOUNDS_OPTS="$GCC_BOUNDS_OPTS -never-fatal"
	export GCC_BOUNDS_OPTS
	;;
esac

case "$cc" in
*egcs*|*gcc*)
	case "$opt" in
	no)
		cflags="-O0 $cflags"
		libcflags="-O0 $libcflags"
		libcxxflags="-O0 -fno-implicit-templates $libcxxflags"
		;;
	yes)
		cflags="-O $cflags"
		libcflags="-O2 $libcflags"
		libcxxflags="-O2 -fno-implicit-templates $libcxxflags"
		;;
	*)
		cflags="$cflags"
		libcflags="$libcflags"
		libcxxflags="-fno-implicit-templates $libcxxflags"
		;;
	esac
esac

echo "CC     is $cc"
echo "CFLAGS is $cflags"

#	Run configure

echo ; beep ; date

if [ -f "Makefile" ]
then
	echo "Makefile exists, remove $objdir for a clean build"
elif [ ! -f "$pwd/configure" ]
then
	echo "$pwd/configure not found"
else
	echo "Running $pwd/configure $config_flags at `date`"

	CC="$cc" \
		CFLAGS="$cflags" \
		LIBCFLAGS="$libcflags" \
		LIBCXXFLAGS="$libcxxflags" \
		AS="$as" \
		$pwd/configure $config_flags
fi

#	Check that configure made a Makefile

if [ ! -f Makefile ]
then
	echo
	echo "no Makefile"
	beep
else
	echo ; echo "Running $make $mflags $* in $objdir at `date`" ; echo
	$nice $make $mflags \
		CC="$cc" \
		CFLAGS="$cflags" \
		LIBCFLAGS="$libcflags" \
		LIBCXXFLAGS="$libcxxflags" \
		AS="$as" \
		$langvar \
		"$@"
fi

#	Write a message and send mail

message="Finished $make $* for $program on $uname_n at `date`"

echo "${message}"

if [ -z "$LOGNAME" ]
then
	LOGNAME=`logname`
fi

if [ ! -z "$LOGNAME" ]
then
	echo "$message" | mail -s "$make $* for $program on $uname_n" "$LOGNAME"
fi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]