Auto Compile a Cross-Compiler

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Auto Compile a Cross-Compiler

Post 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
Last edited by Nekroze on Tue Feb 09, 2010 12:18 am, edited 3 times in total.
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
AndrewBuckley
Member
Member
Posts: 95
Joined: Thu Jan 29, 2009 9:13 am

Re: Auto Compile a Cross-Compiler

Post by AndrewBuckley »

thanks. I plan to look this over tonight.
fronty
Member
Member
Posts: 188
Joined: Mon Jan 14, 2008 5:53 am
Location: Helsinki

Re: Auto Compile a Cross-Compiler

Post 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.
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: Auto Compile a Cross-Compiler

Post 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
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Auto Compile a Cross-Compiler

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: Auto Compile a Cross-Compiler

Post 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.
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
whowhatwhere
Member
Member
Posts: 199
Joined: Sat Jun 28, 2008 6:44 pm

Re: Auto Compile a Cross-Compiler

Post by whowhatwhere »

fronty
Member
Member
Posts: 188
Joined: Mon Jan 14, 2008 5:53 am
Location: Helsinki

Re: Auto Compile a Cross-Compiler

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Auto Compile a Cross-Compiler

Post by Solar »

Every good solution is obvious once you've found it.
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: Auto Compile a Cross-Compiler

Post 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.
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Auto Compile a Cross-Compiler

Post 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:
Every good solution is obvious once you've found it.
whowhatwhere
Member
Member
Posts: 199
Joined: Sat Jun 28, 2008 6:44 pm

Re: Auto Compile a Cross-Compiler

Post by whowhatwhere »

Solar wrote:
NIH.

!!

;-)
OT: And those poor GNU-folk wonder why people say their stuff stinks....jeeze...
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: Auto Compile a Cross-Compiler

Post 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
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: Auto Compile a Cross-Compiler

Post 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
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
Post Reply