I cant seem to get a simple makefile up to use for my OS. I have spent a couple hours reading various makefile tutorials and the GNU make documentation, but I have no idea what Im doing wrong.
Anytime I run 'make kernel.o' or 'make loader.o', it always runs cc and as, rather than my cross compiler tools. Also when I try to make kernel.bin, it always says "Nothing to be done for 'kernel.bin'.". Obviously it isnt reading my recipes correctly and is using the defaults, but I have no idea why or how to fix this. Im sure the problem is obvious to someone. I have never used make up until now, so Im pretty clueless.
Rudster816 wrote:Turns out that Notepadd++ was saving it in Macintosh format instead of Unix
Set it to Unix and everything works now. Thanks for your help.
Nice! About the = vs. := thing: It doesn't have to be :=. I forgot about = because I never use it. Be careful with =, the variables stored with it aren't evaluated until the variable defined with it are used. Whereas with the :=, it saves the current value of the variables.
May I advertise the Makefile tutorial at this point?
Note that = not only defers evaluation to the first use, but re-evaluates on every use, which - given a sufficiently badly-written Makefile - can result in surprising performance penalties.
Every good solution is obvious once you've found it.
Hobbes wrote:The GNU make manual is pretty good. You'll find anything you need to know there.
Aaahhhh... not really. They describe every single feature of GNU make in there, but fall woefully short of teaching you how to put it all together into a good Makefile. Especially automatic dependency handling isn't handled well (if at all) in the make manual, because it requires co-operation between make and the compiler used.
Every good solution is obvious once you've found it.