Makefiles can be used on linux and windows and they are powerful
makefiles are good because they only compile files that have changed, this saves a lot of time
here is mine for xdev/zxdev
Цитата:
all: $(targetname).tap
OBJECTS = Globals.lib MapSquares.lib Spiral.lib Rsrc.lib path.lib UnitFunctions.lib Graphics.lib line.lib Helper.lib Dungeon.lib EnemyAI.lib
$(targetname).tap: $(targetname).bin
Bin/bin2tap -b -a 25000 -c 24999 -r 25000 -o $(targetname).tap $(targetname).bin
fuse-gtk $(targetname).tap
$(targetname).bin: $(targetname).ihx
Bin/hex2bin $(targetname).ihx
$(targetname).ihx: $(targetname).c
/root/sdcc/bin/sdcc $(targetname).c -mz80 --code-loc 25000 --data-loc 49000 --no-std-crt0 --opt-code-size --funsigned-char --disable-warning 126 -I Lib -I Obj Lib/z80/Basic.lib Lib/z80/XDev.lib $(OBJECTS)
$(targetname).c :$(OBJECTS) $(targetname).mod
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/$(targetname).mod -m
%.lib: %.rel
/root/sdcc/bin/sdcclib $@ $<
%.rel:%.c
/root/sdcc/bin/sdcc -mz80 -c $< -I Lib
%.c %.sym:%.mod
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/$< -e -s
clean:
rm *.lib *.rel *.c *.h *.ihx *.bin
it looks complicated but its not
lets start at the bottom:
Цитата:
clean:
rm *.lib *.rel *.c *.h *.ihx *.bin
when you type in 'make clean' this will be executed
rm means remove
*.lib means all files that end in .lib
this just cleans up all the files you dont need, so you can recompile everything later.
Цитата:
%.c %.sym:%.mod
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/$< -e -s
Цитата:
%.c %.sym:%.mod
this means that you want a file that ends in .c and one that ends in .sym
then there is the colon :
then %.mod means that you need files that begin with .mod to get the files that end in .c
the next line needs a tab
this tells the makefile how to get the .c files
Цитата:
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/$< -e -s
$< is the name of the file on the right of the colon, something.mod
so if I type in 'make' this will happen:
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/hi.mod -e -s
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/basic.mod -e -s
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/line.mod -e -s
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/path.mod -e -s
makefiles only compile files that have changed remember,
if basic.mod is newer than basic.c it will compile basic.mod again,
because you put this in the makefile
Цитата:
%.c %.sym:%.mod
it will compare the file dates of the files ending in .c and .sym to see if they are older than the .mod files and compile the .mod files if they are newer.
the next 2 lines are similar:
Цитата:
%.lib: %.rel
/root/sdcc/bin/sdcclib $@ $<
%.rel:%.c
/root/sdcc/bin/sdcc -mz80 -c $< -I Lib
they tell the makefile that to get .rel files you need a .c file
and underneath is the command to get it
$< gives the name of all the .c files to the makefile
Цитата:
%.lib: %.rel
/root/sdcc/bin/sdcclib $@ $<
this says to get a .lib file you need a .rel file
$< is the .rel file
and $@ is the .lib file
the makefile will execute this command
/root/sdcc/bin/sdcclib basic.lib basic.rel
if basic .rel is newer than basic.lib
but this will happen to every .rel file in the same folder as the makefile
Цитата:
$(targetname).c :$(OBJECTS) $(targetname).mod
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/$(targetname).mod -m
$(targetname) is a word that is passed to the makefile
if I type in
make targetname=basic
then the line will look like this:
basic.c :$(OBJECTS) basic.mod
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/basic.mod -m
$(OBJECTS) is a list of all the files I am using
Цитата:
OBJECTS = Globals.lib MapSquares.lib Spiral.lib Rsrc.lib path.lib UnitFunctions.lib Graphics.lib line.lib Helper.lib Dungeon.lib EnemyAI.lib
so really it looks like this
Цитата:
basic.c :Globals.lib MapSquares.lib Spiral.lib Rsrc.lib path.lib UnitFunctions.lib Graphics.lib line.lib Helper.lib Dungeon.lib EnemyAI.lib basic.mod
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/basic.mod -m
this tells the makefile that I want basic.c
but before trying to get basic.c for me I need basic.mod and all those lib files
the other line we looked at tell the makefile how to get lib files
Цитата:
%.lib: %.rel
/root/sdcc/bin/sdcclib $@ $<
so the makefile will compile lib files first because they are needed by this line:
Цитата:
basic.c :Globals.lib MapSquares.lib Spiral.lib Rsrc.lib path.lib UnitFunctions.lib Graphics.lib line.lib Helper.lib Dungeon.lib EnemyAI.lib basic.mod
"/root/ofront/linux2/bin/ofront" /root/Dropbox/oberon/basic.mod -m
Цитата:
$(targetname).ihx: $(targetname).c
/root/sdcc/bin/sdcc $(targetname).c -mz80 --code-loc 25000 --data-loc 49000 --no-std-crt0 --opt-code-size --funsigned-char --disable-warning 126 -I Lib -I Obj Lib/z80/Basic.lib Lib/z80/XDev.lib $(OBJECTS)
this line means we want basic.ihx
we need basic.c to get it
below that is the command to get basic.ihx
notice I put the libs in the right order so they will compile:
OBJECTS = Globals.lib MapSquares.lib Spiral.lib Rsrc.lib path.lib UnitFunctions.lib Graphics.lib line.lib Helper.lib Dungeon.lib EnemyAI.lib
Globals doesnt import anything so it goes first, Mapsquares imports Globals so it has to go after Globals etc.