avr-gcc_select?

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am looking at bundling both 4.1.1 and 3.4.6 with OSX-AVR has any one looked at gcc_select or integrating it into the chain?

I am fleshing out one but dont want to walk on work which is probably better done.

Don.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

oh heck.
Not even a nibble.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm. Never even heard of gcc_select.

Do you have a link?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Smacks forhead!

Its a mac thing.

Sorry,

Sometimes I forget that the osx folk actually occasionally add stuff instead of just making it a pain to use.

:twisted:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What the heck is it supposed to do, anyway?

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It allows you to select which version of gcc you want to compile with and links in the appropriate libraries and utilities.

It was so handy I assumed it was from the gcc side and not the darwin side. If you google it there is a man page in the first couple of links.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah, well, but that's only the system (i.e. native target's) compiler.

I guess it's not very magic, probably even only a shell script. I'm
assuming all they are doing is to move the frontend symlinks for the
individual compiler version around to the default name "cc". For
example, if I look into my tools directory, I see the following
versions of avr-gcc around there:

/tools/i386/bin/avr-gcc*
/tools/i386/bin/avr-gcc-3.4.4*
/tools/i386/bin/avr-gcc-3.4.6*
/tools/i386/bin/avr-gcc-4.1.0*
/tools/i386/bin/avr-gcc-4.1.1*

As it is now (by default), that avr-gcc is simply a hard link to the
latest (avr-gcc-4.1.1 in this case) version of the compiler. So in
order to switch compilers, something like the following might work:

#! /bin/sh

PREFIX=/tools/i386

usage()
{
	echo "usage: gcc_select [-l] [version_to_use]"
	exit 64
}

func=set

while getopts "l" o
do
	case "$o" in
	l)
		func=list
		;;
	*)
		usage
		;;
	esac
	shift
done

case $func in
list)
	set -- $(echo ${PREFIX}/bin/avr-gcc-*)
	echo "The following AVR-GCC versions are available:"
	while [ $# -ne 0 ]
	do
		echo ${1#${PREFIX}/bin/avr-gcc-}
		shift
	done
	exit 0
	;;

set)
	if [ $# -ne 1 ]
	then
		usage
	fi
	version="$1"
	if [ ! -x ${PREFIX}/bin/avr-gcc-$version ]
	then
		echo "AVR-GCC version $version is not available"
		exit 65
	fi
	ln -sf avr-gcc-$version ${PREFIX}/bin/avr-gcc || \
		{ echo "Link failed"; exit 71; }
	echo "Selected AVR-GCC version $version"
	;;
esac

Of course, if you'd also like to switch your *library* environment,
that would be more complicated.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.