Page 1 of 2
Linux MakeFile Help, Devolupment Order?
Posted: Sun Jan 25, 2009 6:33 pm
by GeniusCobyWalker
I want it to scan subdirectories also how would I do that?
Tried Google, cd Source\, tried Source before wildcard.
Any advice?
Heres my makefile:
Code: Select all
CC = gcc
CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -m32
ASM = nasm
ASMFLAGS =
LD = ld
LDFLAGS = -T linker.ld -m elf_i386
BIN = Bin/
OUTPUT = Kernel.bin
CSOURCES = $(wildcard *.c)
CHEADERS = $(wildcard *.h)
ASMSOURCES = $(wildcard *.s)
COBJECTS = $(patsubst %.c,%.o, $(CSOURCES))
ASMOBJECTS = $(patsubst %,%.o, $(ASMSOURCES))
.PHONY : all clean
rm Bin/Kernel.bin
all: $(BIN)$(OUTPUT)
clean:
rm -f *.o
rm Bin/Floppy.img
rm Bin/Kernel.bin
$(ASMOBJECTS) : $(ASMSOURCES)
$(ASM) -f elf32 $(ASMFLAGS) -o $@ $(patsubst %.o,%, $@)
$(COBJECTS) : $(CSOURCES) $(CHEADERS)
$(CC) -c $(CFLAGS) -o $@ $(patsubst %.o,%.c, $@)
$(BIN)$(OUTPUT): $(COBJECTS) $(ASMOBJECTS)
$(LD) $(LDFLAGS) -o $(BIN)$(OUTPUT) $(COBJECTS) $(ASMOBJECTS)
cat stage1 stage2 pad Bin/Kernel.bin > Bin/Floppy.img
rm -f *.o
$(CSOURCES) :
$(ASMSOURCES) :
$(CHEADERS) :
Re: Linux MakeFile Help
Posted: Sun Jan 25, 2009 6:51 pm
by JohnnyTheDon
Replace
Code: Select all
CSOURCES = $(wildcard *.c)
CHEADERS = $(wildcard *.h)
ASMSOURCES = $(wildcard *.s)
with
Code: Select all
CSOURCES = $(shell find ./Source -name "*.c" | xargs)
CHEADERS = $(shell find ./Source -name "*.h" | xargs)
ASMSOURCES = $(shell find ./Source -name "*.s" | xargs)
Replace Source with the root directory you want to search. Eg. everything in source or in a subfoler of source will get compiled.
And don't use backslashes in Linux. Bad idea.
Re: Linux MakeFile Help
Posted: Sun Jan 25, 2009 8:09 pm
by GeniusCobyWalker
What about deleting all .o files in Source Folder?
Tried:
Code: Select all
rm Source/*.o,rm -f *.o, rm Source/-f *.o
Re: Linux MakeFile Help
Posted: Sun Jan 25, 2009 8:28 pm
by JohnnyTheDon
You really don't have a clue what you're doing, do you? -f is an option, not part of the path.
Do
Code: Select all
find ./Source -name "*.o" | xargs rm -f
Re: Linux MakeFile Help
Posted: Sun Jan 25, 2009 9:38 pm
by gzaloprgm
Doesn't make support something like **/*.c for all c files in subdirectories?
gcc -c kernel/*/*.c works perfectly on gcc, on mingw doesn't.
Re: Linux MakeFile Help
Posted: Sun Jan 25, 2009 10:18 pm
by Hangin10
There is a very well written tutorial on the wiki:
makefile.
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 11:08 am
by Craze Frog
gzaloprgm wrote:Doesn't make support something like **/*.c for all c files in subdirectories?
gcc -c kernel/*/*.c works perfectly on gcc, on mingw doesn't.
Don't use forward slashes on Windows. Bad idea.
And also the practices for wildcard expansion are different on Windows and Linux. On Linux it's usually done by the shell. In Windows it's usually done by the program.
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 11:20 am
by Solar
1) Don't use MinGW in a DOS box, use a
GCC Cross-Compiler in Cygwin. Trust us. It's less painfull that way.
2) The
Makefile tutorial covers finding of sources, deleting of sources, scanning of subdirectories plus several other things.
3) Don't copy & paste solutions found somewhere. Understand why something works and something else doesn't. It's worth the time if you don't focus solely on your subject (getting your Makefile to work), but try to take in the bigger picture (why bash style path expansion cannot work in a DOS box, for example).
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 3:32 pm
by GeniusCobyWalker
Im not using MingW in DOSBox.
Besides i'm on Ubuntu.
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 3:41 pm
by AJ
GeniusCobyWalker wrote:Im not using MingW in DOSBox.
Besides i'm on Ubuntu.
You use the Minimalist GNU for Windows on Ubuntu? If that's really true, are you trying to use it with WINE? That sounds like a Bad Idea. Alternatively, you are just very confused about your toolchain. I suggest following Solar's advice and building a Cross-Compiler. For the original question, see his Makefile tutorial on the wiki (that was pointed out by Hangin10).
Cheers,
Adam
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 3:47 pm
by GeniusCobyWalker
I'm using GEdit, Gcc, Nasm, Ld and Bochs
All Programs for Ubuntu. Why did you think i'm emulating Windows?
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 6:18 pm
by gzaloprgm
That was me
I just said cobywalker could simplify his makefile by using the double wildcard (he's using ubuntu and there the double wildcard method works).
Someone missunderstood everything (Mingw on Wine on Gnu/linux (?)).
Cheers,
Gonzalo
BTW, why you insist in creating a cross compiler? What's the problem of compiling my kernel with mingw, I'm using my own bootloader and I can link as a plain binary file w/o the need of making a cross-compiler or anything.
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 6:42 pm
by neon
BTW, why you insist in creating a cross compiler? What's the problem of compiling my kernel with mingw, I'm using my own bootloader and I can link as a plain binary file w/o the need of making a cross-compiler or anything.
There is nothing "wrong" with any type of tool chain used when creating executive software. As long as your tool chain and project is designed in a way to easily work with large scale software, it will work fine. Everything else (portability and the like) depends on your design.
In other words, if it works for you, stick with it
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 7:09 pm
by GeniusCobyWalker
I have another question.
I'm going to drop everything with my Kernel (cut-pasted-edited tutorial code) and
start-over making a kernel along with tutorials instead of coping and pasting.
What order should I do this in?
1) Bootloader, Kernel,TUI, GUI
2)Kernel, Bootloader, TUI, GUI
1) Bootloader, Kernel, GUI
2)Kernel, Bootloader, GUI
Re: Linux MakeFile Help
Posted: Mon Jan 26, 2009 7:16 pm
by piranha
GeniusCobyWalker wrote:I have another question.
I'm going to drop everything with my Kernel (cut-pasted-edited tutorial code) and
start-over making a kernel along with tutorials instead of coping and pasting.
What order should I do this in?
1) Bootloader, Kernel,TUI, GUI
2)Kernel, Bootloader, TUI, GUI
1) Bootloader, Kernel, GUI
2)Kernel, Bootloader, GUI
*Starts Crying*
Firstly, whats with 1,2,1,2? Learn to count first, but I'm gonna assume you mean 1,2,3,4. Edit, No, TUI/GUI are not different options enough to repeat numbers. They're both interfaces and are therefor the same idea.
Bootloader, Kernel, MM, tasking, syscalls, VFS, FS drivers, more drivers, etc, etc, program loading, etc, etc, and then from there the TUI/GUI thing is your choice.
However, don't even think about making an interface until you get MM, tasking, VFS, syscalls, and program loading going. Then make your interface as a loadable program to test out your kernel.
This ought to keep you busy for 2-4 years at your rate.
-JL