OFILES = \
OFILES is a definition that is a list of all the object files needed for this project. The \ is used to denote that the definition isn't finished (normally the carriage return would mark the end of it). You can see we don't have a \ after jag.o
So basically we have two object files in our project. statup.o and jag.o
jag : $(OFILES)
aln -c jag.lnk
This tells us in order to build jag we need all the object files defined above. If they all exist then the linker (aln) is called as noted.
GAS2OBJ = mac -i/jaguar/include -fb -g $?
C2OBJ = gccjag -b m68k -B/jaguar/bin/ -V2.6 -Wall -DJAGUAR -O2 -c -o $@ $?
These two lines define command line parameters for generating object files from c and assembly source.
GAS2OBJ tell how to use the assembler "mac" to assemble and assembly source code into and object file.
C2OBJ tells how to compile a C file into an object file.
startup.o : startup.s
These two lines show how to build startup.o
If the make utility doesn't see a startup.o file in the project (or the source code file is newer than the .o file denoting changes were made) it assembles the file into an object file.
So if startup.o is missing the makefile executes the GAS2OBJ command with startup.s as the source file. This will generate the startup.o if the assembly is ok (i.e. no errors in the code). This is what the make utility would do if it needed to generate the startup.o file
mac -i/jaguar/include -fb -g startup.s
jag.o : jag.c
This is the same as the above example but tells the make utility how to build jag.o . If jag.o doesn't exist the C2OBJ command line is executed with jag.c as a parameter.
this is what happens if you type "make clean" from the command line.
It removes all the *.o and *.abs files. This will probably fail on DOS systems since the rm command doesn't exist. So you should edit and change the rm to del.
That is a quick run through. Please ask if you have more questions.
A makefile greatly simplifies building a project. Especially with large numbers of files.
You can see it basically tells how to build the program in stages. I.E.
In order to build jag I need object files I will link with aln
In order to build object files I need to either assemble or compile the .s and .c files into object files
It is also nice because the make utility looks at whatever it is building (and object file, the abs file) and it compares the file date of the two items.
So if the jag.abs is older than the object files, it knows it has to re-link.
If an assembly file is newer than its object file, it knows it has to re-assemble that file
So if you have a large project with lots of C and assembly files and you make a change to one file it will only recompile or assemble that file, and relink the project. It wont recompile and re-assemble all the other source files.