.nds文件的生成过程,libnds的工作原理



掌叔
2009-03-08 17:48:03

摘自:[url]http://blog.chinaunix.net/u/4774/[/url]
作者:u0u0

在example中有很多实例,每个实例下面都有MakeFile,这大大简化了我们的劳动。
我们可以直接使用它们来新建一个所谓的工程。
MakeFile里面已经有了详细的说明,大体上都能看懂。
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(shell basename $(CURDIR)) #输出到当前目录(makefile所在)下
BUILD := build #编译的中间文件将会放在这里。
SOURCES := source #源代码放在这里。
DATA := data #暂时不知道通途。
INCLUDES := include #额外的头文件,自定义的吧!

建立一个像这样的目录结构就可以开始我们自己的编码了。
mypg
mypgMakeFile
mypgsource
mypg是工程目录的名字,自己取吧!最后编译生成的文件名和这个目录名一致。
MakeFile直接拷一个到mypg,我们自己的源码文件放在source目录下。

再来看看输出。
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).ds.gba : $(OUTPUT).nds
$(OUTPUT).nds : $(OUTPUT).arm9
$(OUTPUT).arm9 : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
生成了4种目标.arm9和.elf用途不清楚,说一下.nds和.ds.gba,
我用G6L烧录卡,通过G6 U-DISK Manager烧.nds可以在游戏界面运行程序,
而直接U盘的方式拷贝.ds.gba进G6L,可以在“我的卡带”里面运行.ds.gba。