Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I am sick to death of using batch files to build my OS. They are slow, there is no way of not compiling already compiled objects that haven't changed (etc...). The problem is, the makefile tutorials I've read have not helped at all. I still don't understand them.
What I need is a makefile that will compile all the '.c' files in the directory, then link them into the final ELF file (using GCC, ld etc...). Any help would be greatly appreciated.
pcmattman wrote:I am sick to death of using batch files to build my OS. They are slow, there is no way of not compiling already compiled objects that haven't changed (etc...). The problem is, the makefile tutorials I've read have not helped at all. I still don't understand them.
What I need is a makefile that will compile all the '.c' files in the directory, then link them into the final ELF file (using GCC, ld etc...). Any help would be greatly appreciated.
The CFLAGS should work when compiling objects, you can leave them out if you just want a working makefile. The rest is pretty generic. If you have a more specific question about a bit of any makefile, just ask.
How can I tell it to do this on all the objects (like a *.o or something like that)? Or do I have to type it in myself? Because I have about 20 different files and to put all of them into the makefile won't be fun.
pcmattman wrote:How can I tell it to do this on all the objects (like a *.o or something like that)? Or do I have to type it in myself? Because I have about 20 different files and to put all of them into the makefile won't be fun.
Well... you need to either type in the list of objects once or you need to change this to automatically take the directory worth of contents for object outputs. I prefer the first, but you may prefer the second.
Short & simple: put all the objects behind OBJECTS= and it'll just work.
# all of the directories that contain code
PROJDIRS := includes libs asm
# get the source files
SRCFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.c")
then you could do something like this to get a list of the object files
Just one thing, I'm on a Windows box... Also, I've tried to go through the tutorial and also tried the suggestions presented here. None of them work. I need help!
Cygwin does a good job at running unix stuff. I run make that way and it works wonders
As for non-makefile methods:
Perl, anyone?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
pcmattman wrote:Just one thing, I'm on a Windows box... Also, I've tried to go through the tutorial and also tried the suggestions presented here. None of them work. I need help!
Have you tried Cygwin? I use cygwin on windows and most of the stuff that I see in makefile tutorials works.