In the previous example, we usually do not put all the source code and makefile in the same directory, especially for larger projects. This is assumed to have led this project, in the LED this project directory has a main directory, the main directory of files for the previous main.c, delay.c and Delay.h,main directory under the makefile as follows:
CC = SDCC
all:delay.rel main.rel
delay.rel:delay.c
$ (cc)-C delay.c
main.rel:main.c delay.h
$ (CC)-C main.c
. Phony:clean clean
:
-rm delay.asm delay.lst delay.rel delay.sym delay.rst\
main.asm main.lst Main.rel Main.sym Main.rst
In the main directory, just compile the. c file, do not make the final link, and make the last link under the project root of the previous layer, makefile as follows:
CC = SDCC
all:led.bin
led.bin:led.ihx
makebin led.ihx led.bin
Led.ihx:main/delay.rel Main /main.rel
$ (CC)-O led.ihx main/delay.rel main/main.rel
main/delay.rel main/main.rel:
CD Main & & Make
. Phony:clean clean
:
-rm led.bin led.ihx led.lk led.map led.mem
CD main && do clean
The entire project can be downloaded from here: http://download.csdn.net/detail/mcgrady_tracy/6845081