jsnyder / avr32-toolchain

Makefile & supporting patches/scripts to build an AVR32 toolchain.
29 stars 30 forks source link

Suggestion: accommodate multiple simultaneous toolchain versions #4

Open ilg-ul opened 13 years ago

ilg-ul commented 13 years ago

In order to be able to maintain older versions of my projects, I sometimes need to keep older versions of the toolchains around.

The way I do this is to append the current date to the folder name of the toolchain.

For example, for the avr32 toolchain I used avr32-tools-20110702 instead of avr32-tools.

I also prefer to organise all my cross compiling toolchains in a folder named Cross.

Since my Cross compiling toolchains are not alone, my development environment also includes multiple Eclipse instances (located in a folder call Eclipses), so I keep everything in $HOME/Developer.

The patch I applied to your Makefile is:

PREFIX = $(HOME)/avr32-tools/

TODAY = date "+%Y%m%d" PREFIX = $(HOME)/Developer/Cross/avr32-tools-$(TODAY)/

If you think such a more structured folder hierarchy is useful, I would be happy to see it used in your Makefile too (same for the ARM build).

Thank you,

Liviu

ilg-ul commented 13 years ago

Regardless if you agree to change the Makefile PREFIX, could you change the syntax to do not overwrite previously defined environment variables?

PREFIX ?= $(HOME)/avr32-tools/

I did try such a definition, and together with the following lines before calling make, I think I obtained both simplicity in the Makefile and enough configurability of the build process.

Liviu

Numeric representation of today, like 20110704

TODAY=date "+%Y%m%d"

Keep different versions in different folders

TODAY_DIR=$HOME/Developer/Cross/avr32-tools-$TODAY

Remove the destination folder, in case it exists

if [ -d $TODAY_DIR ] then echo "Remove $TODAY_DIR" rm -rf $TODAY_DIR fi

Pass the custom destination folder to the make process

export PREFIX=$TODAY_DIR/

jsnyder commented 13 years ago

This sounds good. I could also do this by git revision for those who have checked out from the repository: GIT_REV = git rev-parse --verify HEAD --short PREFIX = $(HOME)/avr32-tools-$(GIT_REV)/

This way the generated versions would be particular to the version the repo is at. The only major downside is that they're SHA-1 hashes so they don't really convey any sort of progression through time, but the file creation dates should provide that info.

It could also symlink avr32-tools to whatever the latest version is that's been installed with either scheme. I'll need to work out the logic for this a bit maybe. Tarball downloads don't have revision info except in the directory that gets created when unzipping/untarring...

ilg-ul commented 13 years ago

Could you try the suggested question mark syntax?

PREFIX ?= $(HOME)/avr32-tools-$(GIT_REV)/

This would allow to export through the environment any custom folder.

Liviu

jsnyder commented 13 years ago

I've now adjusted it to use a git revision, falling back to date if there is not .git directory or git is not installed. One can also specify prefix at the command line. It doesn't yet do any symlinking automatically, but I suppose I could add that to the message at the end as a suggestion for the user (a message is displayed on successful build showing the install location and providing a suggested export PATH=.. line)