Page 1 of 1

Auto Compile a Cross-Compiler

Posted: Fri Feb 05, 2010 8:51 am
by Nekroze
Hello, first up i got sick of sticking around for the break in compiling an cross-compiler just to start the next compile process.
so i made a very simple little bash script that will automatically setup and compile a cross-compiler for you.

this is designed to be used with: binutils | gcc | gmp | mpfr
all that is needed is those files in the same directory as the bash script and run it and voila it sets everything up for ya just come back in a few hours and enjoy.

currently the script is setup for a i586 cross-compiler and the above versions of the core utils but it is very easy to alter the little script to fit your versioning needs.

just wanted to help everyone who hasn't the time to await the ability to start the next compilation and then the next.

Download Here The CCC or 4C script version 1.3 by Nekroze.
place in a directory ready for compiling, cd to that directory and run ./CrossCompiler-Compiler.sh

the new version works with cygwin perfectly aswell as Linux host OS (theoretically (untested)) requires a few more setup steps before running the script all detailed in the comment header of the script and here as well:

Code: Select all

#CrossCompiler-Compile.sh 1.2 by Nekroze
#This script makes compiling a cross-compiler easy as hell
#this script is designed to be in the same directory as the sources needed
#Variables need to be set for the files and options that may differ between
#compilations. the following vars need be exported before this script is run.
#PREFIX - the prefix to the location to compile to [default = /usr/cross]
#TARGET - the target platform of the cross-compiler [default = i586-elf]
#VGMP - the version of GMP as in file title of eg. "gmp-5.0.0.tar.bz2"
#		then this variable would be VGMP=5.0.0
#CGMP - the tar compression of GMP as in file title eg "gmp-5.0.0.tar.bz2"
#		then this would be CGMP=bz2 or CGMP=gz or CGMP=tar for plain .tar
#VMPFR - the version of MPFR as in file title of eg. "mpfr-2.4.2.tar.bz2"
#		then this variable would be VMPFR=2.4.2
#CMPFR - the tar compression of MPFR in file title eg "mpfr-2.4.2.tar.bz2"
#		then this would be CMPFR=bz2 or CMPFR=gz or CMPFR=tar for plain .tar
#VBIN - the version of binutils in file title of eg. "binutils-2.20.tar.bz2"
#		then this variable would be VBIN=2.20
#CBIN - the tar compression of binutils in file title eg "binutils-2.20.tar.bz2"
#		then this would be CBIN=bz2 or CBIN=gz or CBIN=tar for plain .tar
#VGCC - the version of GCC in file title of eg. "gcc-4.4.3.tar.bz2"
#		then this variable would be VGCC=4.4.3
#CGCC - the tar compression of GCC in file title eg "gcc-4.4.3.tar.bz2"
#		then this would be CGCC=bz2 or CGCC=gz or CGCC=tar for plain .tar
enjoy all,
Nekroze

Re: Auto Compile a Cross-Compiler

Posted: Fri Feb 05, 2010 10:16 am
by AndrewBuckley
thanks. I plan to look this over tonight.

Re: Auto Compile a Cross-Compiler

Posted: Fri Feb 05, 2010 10:39 am
by fronty
Check your shebang. Also I don't see any things that require bash (which are bad anyway). Also it would be better if that script wouldn't contain hardcoded values for versions but would search for source package and use latest/first found.

Re: Auto Compile a Cross-Compiler

Posted: Fri Feb 05, 2010 9:32 pm
by Nekroze
i have updated the script download to version 1.0

it has some better updating text output. and makes the libgcc now as well.

also fixed a typo in the gcc configure.

will be making version 1.2 latter should be done in a day or two, that version will be much more dynamic with auto version and compression method detection.

thanks for the support and help,
Nekroze

Re: Auto Compile a Cross-Compiler

Posted: Fri Feb 05, 2010 11:00 pm
by Love4Boobies
Another suggestion (although I think you should also follow fronty's): don't use predefined targets, use environment variables instead (e.g., TARGET) which the user will have to set prior to running the script. Alternatively, the user could set the target (or other options) through flags.

Re: Auto Compile a Cross-Compiler

Posted: Sat Feb 06, 2010 5:30 am
by Nekroze
OK I've found a bit of a problem with using the script under cygwin so i fixed that up with a little conversion.

I've also made the script much more dynamic but it requires a fair bit of exporting variables before it can be used, i will after this post, update the OP with the new download and variables needed to setup the script to compile for you.

Re: Auto Compile a Cross-Compiler

Posted: Sat Feb 06, 2010 6:34 am
by whowhatwhere

Re: Auto Compile a Cross-Compiler

Posted: Sat Feb 06, 2010 7:13 am
by fronty
I got Cygwin version working with FreeBSD's /bin/sh (Almquist-based) when I replaced == in test's parameters with single = (didn't test if it could compile, though).

The Cygwin version doesn't make sense. You completely ignore values user /must/ give and use hardcoded values whatever user gives in those variables. I could tell it to compile from package gcc-banana-split.bz3 and it would use gcc-4.4.3.tar.bz2. It doesn't check make's return value either.

Wishlist:
  • Use versions given by user
  • Versions etc. as command line parameters, I prefer "./foo --kewl 10" to "KEWL=10 ./foo".
  • If version (or maybe full package name) isn't given on command line, try to find package in wd.
  • Possibly automatic downloading.

Re: Auto Compile a Cross-Compiler

Posted: Sat Feb 06, 2010 11:53 am
by Solar

Re: Auto Compile a Cross-Compiler

Posted: Sat Feb 06, 2010 6:21 pm
by Nekroze
ok i will work on those suggestions today at some point, i am also learning bash scripting while I'm doing this so sorry.

Re: Auto Compile a Cross-Compiler

Posted: Mon Feb 08, 2010 2:31 am
by Solar
Nekroze wrote:i am also learning bash scripting while I'm doing this so sorry.
Don't be. Your script is fine. We're just keeping in character as the disgruntled old farts. 8)

Hint: "\\\\\\" is about the worst character sequence for printing horizontal separators to screen. Aside from the "\" character not creating as good a visible seperator as "-" or "#" do, it's also the escape character. If you know what I mean, you will understand what I am hinting at. If you don't know what I mean, just don't do it, and look up "escaping" ASAP. :wink:

Re: Auto Compile a Cross-Compiler

Posted: Mon Feb 08, 2010 9:45 am
by whowhatwhere
Solar wrote:
NIH.

!!

;-)
OT: And those poor GNU-folk wonder why people say their stuff stinks....jeeze...

Re: Auto Compile a Cross-Compiler

Posted: Mon Feb 08, 2010 8:10 pm
by Nekroze
oh, i didn't know that bash script's took escape characters i will fix that up aswell. thanks mate, and i understand for betterment there mast always be criticism. :lol:

thanks again, will update,
Nekroze

Re: Auto Compile a Cross-Compiler

Posted: Mon Feb 08, 2010 10:42 pm
by Nekroze
i have fixed up the above mentioned issue and i think everything should be pretty darn good now.

edited download links in OP, thanks for support,
Nekroze