Build File Help Ubuntu (Linux)
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Build File Help Ubuntu (Linux)
You need to have tab characters not spaces where you need to execute shell instructions (such as rm).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Build File Help Ubuntu (Linux)
Way to take a good makefile and destory it...
Get rid of the img tags. Why are they there?
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.
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.
Code: Select all
[img]gcc[/img]
Code: Select all
kernel.bin
Code: Select all
WalkerOS
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.
- GeniusCobyWalker
- Member
- Posts: 65
- Joined: Mon Jan 12, 2009 4:17 pm
Re: Build File Help Ubuntu (Linux)
Fixed everything both of y'all said,
Same Error
!!!!!!!!!
Look at main post! Updated makefile and Error
Same Error
!!!!!!!!!
Look at main post! Updated makefile and Error
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Build File Help Ubuntu (Linux)
I am confused as to what these are for:
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.
Code: Select all
$(CSOURCES) :
$(ASMSOURCES) :
$(CHEADERS) :
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.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: Build File Help Ubuntu (Linux)
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.
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.)
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
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.)
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Build File Help Ubuntu (Linux)
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.Firestryke31 wrote:I am confused as to what these are for:What happens if you remove them?Code: Select all
$(CSOURCES) : $(ASMSOURCES) : $(CHEADERS) :
Re: Build File Help Ubuntu (Linux)
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.
Good luck.
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
- GeniusCobyWalker
- Member
- Posts: 65
- Joined: Mon Jan 12, 2009 4:17 pm
Re: Build File Help Ubuntu (Linux)
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:
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
Full Knowledge in:
GML, Ti-Basic, Zilog Z80 Assembly, SX28 Assembly and Blender
Experience in:
C++,OpenGl,NDS C++,Dark Basic,Dark Basic Pro,Dark Gdk and PSP Coding
Using:
Ubuntu ,GEdit ,NASM ,GCC ,LD ,Bochs
GML, Ti-Basic, Zilog Z80 Assembly, SX28 Assembly and Blender
Experience in:
C++,OpenGl,NDS C++,Dark Basic,Dark Basic Pro,Dark Gdk and PSP Coding
Using:
Ubuntu ,GEdit ,NASM ,GCC ,LD ,Bochs
Re: Build File Help Ubuntu (Linux)
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.
"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.
- GeniusCobyWalker
- Member
- Posts: 65
- Joined: Mon Jan 12, 2009 4:17 pm
Re: Build File Help Ubuntu (Linux)
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
Full Knowledge in:
GML, Ti-Basic, Zilog Z80 Assembly, SX28 Assembly and Blender
Experience in:
C++,OpenGl,NDS C++,Dark Basic,Dark Basic Pro,Dark Gdk and PSP Coding
Using:
Ubuntu ,GEdit ,NASM ,GCC ,LD ,Bochs
GML, Ti-Basic, Zilog Z80 Assembly, SX28 Assembly and Blender
Experience in:
C++,OpenGl,NDS C++,Dark Basic,Dark Basic Pro,Dark Gdk and PSP Coding
Using:
Ubuntu ,GEdit ,NASM ,GCC ,LD ,Bochs
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Build File Help Ubuntu (Linux)
What are stage1 and stage2?
Re: Build File Help Ubuntu (Linux)
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.What are stage1 and stage2?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Build File Help Ubuntu (Linux)
I know that, I meant what are they for his OS? The makefile isn't creating them.neon wrote: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.What are stage1 and stage2?
- GeniusCobyWalker
- Member
- Posts: 65
- Joined: Mon Jan 12, 2009 4:17 pm
Re: Build File Help Ubuntu (Linux)
Should I be making them?
If I did, would that omit the "Kernel 200+18" and "Boot" required by GRUB?
If I did, would that omit the "Kernel 200+18" and "Boot" required by GRUB?
Full Knowledge in:
GML, Ti-Basic, Zilog Z80 Assembly, SX28 Assembly and Blender
Experience in:
C++,OpenGl,NDS C++,Dark Basic,Dark Basic Pro,Dark Gdk and PSP Coding
Using:
Ubuntu ,GEdit ,NASM ,GCC ,LD ,Bochs
GML, Ti-Basic, Zilog Z80 Assembly, SX28 Assembly and Blender
Experience in:
C++,OpenGl,NDS C++,Dark Basic,Dark Basic Pro,Dark Gdk and PSP Coding
Using:
Ubuntu ,GEdit ,NASM ,GCC ,LD ,Bochs
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Build File Help Ubuntu (Linux)
Oh, okay stage1 and stage2 are from grub. That make sense then.