tutorials on porting BASH?

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
puneet
Posts: 7
Joined: Thu Jan 07, 2010 7:29 am

tutorials on porting BASH?

Post 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
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: tutorials on porting BASH?

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
puneet
Posts: 7
Joined: Thu Jan 07, 2010 7:29 am

Re: tutorials on porting BASH?

Post 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
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: tutorials on porting BASH?

Post 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.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: tutorials on porting BASH?

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
puneet
Posts: 7
Joined: Thu Jan 07, 2010 7:29 am

Re: tutorials on porting BASH?

Post 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!!
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: tutorials on porting BASH?

Post by gerryg400 »

If you think bash is too difficult, try dash. It was a lot easier to port to my OS than coreutils.
If a trainstation is where trains stop, what is a workstation ?
Post Reply