Page 1 of 1
tutorials on porting BASH?
Posted: Sat Mar 19, 2011 7:23 am
by puneet
Hi All,
Is there a tutorial on porting BASH? I have most of the required things done for my OS. I have just started with BASH-4.2. Lets see how long it goes.
JamesM - Dude you got it ported in 2007, and since you also have a complete tutorial on writing an OS, so I was expecting that there must be something you might have written for it. It could be google's mistake that I couldn't find it
.
Thanks in Advance,
Puneet
Re: tutorials on porting BASH?
Posted: Sat Mar 19, 2011 12:33 pm
by piranha
It's not too difficult. You need a
http://wiki.osdev.org/OS_Specific_Toolchain that will allow you to cross-compile Bash for your OS to load. That wiki article is extremely easy to follow.
Next, compile bash with --host=<your cross compiler>, and run make with CC_FOR_BUILD=gcc and it should work...that is, if you've got the proper include files and library functions written. You'll need more function than are presented in that article. If you get compile errors, you're probably missing include files that define whats missing, or you need to implement what it can't find yourself. Functions you need to implement will become apparent at link time. If your OS is pretty close to linux, in the libc/sys/linux directory there are plenty of functions that will do everything bash needs; you can add them to your libc/sys/<os> (other directories of interest here would be libc/posix and libc/unix) directory.
This is the procedure I followed to make a tool chain for my OS, and I do have a port of bash (some things don't work, but I'm working on that). That said, I have just started with porting over, and I am still trying to muck through it all myself.
Good luck.
-JL
Re: tutorials on porting BASH?
Posted: Sat Mar 19, 2011 1:42 pm
by puneet
Hi piranha,
Thanks a lot for you help!!
I already have my cross compiler and newlib done. I can run small programs compiled with cross compiler and linked with newlib.
I am a little confused about the args to configure of BASH.
../bash-4.2/configure --prefix=/usr/local/cross/bash --host=$TARGET --enable-static-link --without-bash-malloc --disable-nls
I have also added env var CC, LD and LFLAGS.
After this I checked the Makefile but ar, runlib are still pointing to the native binaries.
While compiling I am getting a good number of compilation errors, which I guess can be fixed with modifying config.h, which means my configure script didn't work right. Something like if "JOB_CONTROL" is not defined then BASH won't compile.
Please let me know if you have any pointers on how to run configure.
Thanks,
Puneet
Re: tutorials on porting BASH?
Posted: Sat Mar 19, 2011 7:29 pm
by pcmattman
Is $TARGET-gcc in your PATH? If not, --host will not work as it will be unable to find the compiler.
Setting up your environment for autotools-based cross-compilation is crucial if you want any sort of success.
Re: tutorials on porting BASH?
Posted: Mon Mar 21, 2011 10:32 am
by piranha
Getting things to compile is usually the biggest problem. At least, it is for me. I have successfully ported programs and had to modify the config.h scripts, and you can set AR and such when you run make, "make AR=i586-...-..." or whatever. I mean, if I have to modify my config.h, then possibly mine isn't set up right either, but I think that its more that you're cross-compiling to an OS that the package doesn't know about at all.
Another way to test out your cross-compiler and OS tool chain is to port something easier than bash: fileutils, binutils...at least, I found them easier to port than bash.
-JL
Re: tutorials on porting BASH?
Posted: Tue Mar 22, 2011 5:57 am
by puneet
Humm good idea - I should start with something small, let me start with coreutils first and then move to much complicated ones.
For compiling gcc and binutils to run on my OS "--target" won't help, right? As it will create the cross compiler, I need to use --host for that, I guess. And this should be same with any other code I am trying to port.
Thanks for your help JL!!
Re: tutorials on porting BASH?
Posted: Tue Mar 22, 2011 6:16 am
by gerryg400
If you think bash is too difficult, try dash. It was a lot easier to port to my OS than coreutils.