[Prev][Next][Index][Thread]
Re: Compiling OS KIt Kernles
On Wed, 30 Dec 1998, Mike Ashley wrote:
> I managed to come up with
> the following sort of simplified makefile, and the examples I've looked
> at follow this same pattern.
>
A brief overview of makefiles: (note, I know GNU make, other makes may
behave differently)
A simple Makefile might look like so:
foo.o: foo.c
gcc -c foo.c
foo: foo.o
gcc -o foo foo.o
Now, let's start at the top. The first line starts with foo.o, which is
the target.(Try make bork in one of the oskit dirs, the error will now
make sense) After the colon, there's typically a tab and the dependancy,
i.e. foo.c. We're basically saying here that foo.c is needed for
producing foo.o, and if foo.c is newer than foo.o, we need to recompile
foo.o. The indented line directly below is the command that make should
run to produce foo.o. Next, we have the target foo - the end result
program. It needs foo.o, and if foo.o is newer than foo we want to
recompile foo. Again, the second line is the command needed to produce
the new copy of foo. Now, let's add variables to our simple makefile:
CC=gcc
foo: foo.o
$(CC) -o foo foo.o
foo.o: foo.c
$(CC) -c foo.c
In this case, we set the value of CC to gcc, and tell the makefile to use
the value of the CC variable in the compile command. Makefiles can get
very advanced, and incredibly useful on large projects(like oskit) along
with autoconf and automake. For those of you that already know how to
work with makefiles, sorry for using up the space to write this, but I
thought those of us that don't know how to use make would benefit
significantly. TTYL!
---
Paul Anderson - Self-employed Megalomaniac
paul@geeky1.ebtech.net
Member of the Sarnia Linux User's Group
http://www.sar-net.com/slug
http://zephyr.sellad.on.ca/~paul
http://www.freeworldbbs.org
" I call a device that uses heat transfer or internal energy changes
an "engine." Other devices are "motors." Example: my truck moves
down the road powered by a gasoline fueled engine, the engine is
started by a motor..."
References: