Page 2 of 2

Re: Build File Help Ubuntu (Linux)

Posted: Sun Jan 18, 2009 10:46 pm
by Love4Boobies
You need to have tab characters not spaces where you need to execute shell instructions (such as rm).

Re: Build File Help Ubuntu (Linux)

Posted: Sun Jan 18, 2009 10:50 pm
by JohnnyTheDon
Way to take a good makefile and destory it...

Code: Select all

[img]gcc[/img]
Get rid of the img tags. Why are they there?

Code: Select all

kernel.bin
That is supposed to be the directory where you want to output your file. Make sure it ends with a / (ie bin/). If you want it to ouput the file in the same directory as the makefile, leave it blank.

Code: Select all

WalkerOS
Make this kernel.bin (or whatever you want the filename for your output to be).

You need to make a linker script. The one from bare bones will suffice. Call it linkerscript.ld.

I really recommend giving up on making an OS right now. Like others have said, you lack sufficient experience. Try programming some regular user mode programs. We don't need another person who copies tutorials and then asks how to write a function in C.

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 11:38 am
by GeniusCobyWalker
Fixed everything both of y'all said,
Same Error :(

!!!!!!!!!
Look at main post! Updated makefile and Error

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 11:58 am
by Firestryke31
I am confused as to what these are for:

Code: Select all

$(CSOURCES) :
$(ASMSOURCES) :
$(CHEADERS) :
What happens if you remove them?

Also, try looking around line 24, to see if something's missing. Unfortunately I don't know if it counts empty lines or not, so try looking at both. Hint: With newlines it's at the 'rm' statement in clean, and without it's the statements coded above.

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 12:57 pm
by JamesM
You lie. You didn't fix everything we said, because if you did, it would work.

I know this, because I just copy-pasted from your post into a new file, changed the spaces to tabs where they should be, and ran it.

Code: Select all

[18:54:02] ~/tmp $ make
ld -T linkerscript.ld --strip-all -nostdlib -nodefaultlibs -o bin/kernel.bin
ld: cannot open linker script file linkerscript.ld: No such file or directory
make: *** [bin/kernel.bin] Error 1
[18:54:03] ~/tmp
There should be one tab character before the "rm", before the "$(LD)", "$(CC)" and "$(ASM)" on lines 24, 26, 28 and 30.

Make sure your editor isn't set up to convert tabs to spaces (most unset this functionality when they see a Makefile, but you decided not to captialise your filename correctly, so they may not have picked it up.)

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 1:32 pm
by JohnnyTheDon
Firestryke31 wrote:I am confused as to what these are for:

Code: Select all

$(CSOURCES) :
$(ASMSOURCES) :
$(CHEADERS) :
What happens if you remove them?
I had some problems with my makefiles not checking timestamps. I added these and it fixed it. I'm not sure if the makefile docs say they're required, but they worked for me.

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 1:41 pm
by stephenj
You know the annoying Z80 processor, and trust me, this isn't remotely as difficult to learn.

I've read this tutorial and it explains the mistakes you've made this far. Now don't skim it, read it carefully.

Also, your makefile is pretty complex at the moment. I advise you temporarily rename it, and write a simpler, more fragile version for the sake of learning. Build it piecemeal, not all at once. Your goal, for the moment, shouldn't be to build a kernel, but learning how to use make.

I've written a base, to get you started.

Code: Select all

ASM = nasm
ASMFLAGS = -f elf32

.PHONY : all clean

all: loader.o

clean:
<TAB ONCE>rm -f *.o

loader.o: loader.s
<TAB ONCE>$(ASM) $(ASMFLAGS) -o loader.o loader.s
Good luck.

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 2:50 pm
by GeniusCobyWalker
I figured out what the commands meant.
So I just wrote a basic Makefile that
Assembles,Compiles, Links,Makes a Floppy, Erases O/Bin files and Runs my OS.

I'll write a more advanced one as I need it.

Makefile:
all: kernel.c
rm -f *.o
nasm -f elf -o loader.o loader.s
gcc -o kernel.o -c kernel.c -nostdlib -nostartfiles -nodefaultlibs -m32
ld -T linker.ld -o kernel.bin loader.o kernel.o -m elf_i386
cat stage1 stage2 pad kernel.bin > floppy.img
rm -f *.o
rm -f *.bin
bochs

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 3:12 pm
by stephenj
The "all" label should have all the files it requires after it (not just kernel.c).

"rm -f *.o *.bin" is also legal. You should put it under a label named "clean" at the very least (it can be called by all).

That is a REALLY pointless makefile though. You're never going to need something more complex. But both you and your computer are going to have to do extra work that could easily be automated. Your loss though.

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 3:42 pm
by GeniusCobyWalker
Finished Makefile
all: Source/kernel.c
rm -f *.o
nasm -f elf -o loader.o Source/loader.s
gcc -o kernel.o -c Source/kernel.c -nostdlib -nostartfiles -nodefaultlibs -m32
ld -T linker.ld -o Kernel/Kernel.bin loader.o kernel.o -m elf_i386
cat stage1 stage2 pad Kernel/Kernel.bin > Floppy/Floppy.img
rm -f *.o
bochs

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 3:47 pm
by JohnnyTheDon
What are stage1 and stage2?

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 3:56 pm
by neon
What are stage1 and stage2?
Probably based off of GRUBs naming conventions of its bootloader. ie; Stage1 is the boot strap program / MBR and Stage 2 is the "second stage loader" or "OS loader" that actually loads the OS kernel.

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 3:58 pm
by JohnnyTheDon
neon wrote:
What are stage1 and stage2?
Probably based off of GRUBs naming conventions of its bootloader. ie; Stage1 is the boot strap program / MBR and Stage 2 is the "second stage loader" or "OS loader" that actually loads the OS kernel.
I know that, I meant what are they for his OS? The makefile isn't creating them.

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 4:05 pm
by GeniusCobyWalker
Should I be making them?

If I did, would that omit the "Kernel 200+18" and "Boot" required by GRUB?

Re: Build File Help Ubuntu (Linux)

Posted: Mon Jan 19, 2009 4:25 pm
by JohnnyTheDon
Oh, okay stage1 and stage2 are from grub. That make sense then.