为PALM程序写的Makefile

荆学民
2023-12-01
使用 prc-tool开发 Palm 程序,makefile 是必不可少的,这和通用的 Makefile 没有什么大的区别,下面简要介绍一下。

如果不写Makefile, 需要依次输入以下命令:

1. Compile the .c file to .o file


m68k-palmos-gcc –O1 –c main.c –o main.o

m68k-palmos-gcc –O1 –c other.c –o other.o

2. Link into an executable file

m68k-palmos-gcc –O1 main.o other.o –o GNUSample.tmp

3. Split the object into application sections, produce a .grc file

m68k-palmos-obj-res GNUSample.tmp

4. Compile the resource (Use the pilrc to convert the static element to resource)

pilrc GNUSample.rcp

5. Build the application

Build-prc GUNSample.prc “GNU Sample” Eric *.bin *.GNUSample.grc

    最容易看懂的,低级的 Makefile 就是老老实实把要编译的命令敲进去,只当是一个批处理文件用。我还挺喜欢这样的,不过如果以后程序扩展,修改的话,需要修改多处地方,可维护性差一点

all : helloworld.prc clean

helloworld.prc : code0000.helloworld.grc tver0001.bin
build-prc helloworld.prc "Hello world" HeWo *.helloworld.grc *.bin
ls -l helloworld.prc

tver0001.bin : helloworld.rcp ../resources/icon.bmp ../resources/icon_s.bmp
pilrc helloworld.rcp

code0000.helloworld.grc : helloworld.c
m68k-palmos-gcc -O2 helloworld.c -o helloworld
m68k-palmos-obj-res helloworld

clean :
rm helloworld *.helloworld.grc *.bin


from: http://www.ligfiets.net/toni/palm/tutorial/uk/

复杂点的 Makefile,初学者不太容易看得懂,但是维护性比较高,比如下面这个,就需要一些 Makefile 的基础知识,如宏,依赖关系,规则等等。

推荐 《Linux程序设计》Chapter 8 系统学习。

 
 
APP = table ICONTEXT = " Table Example " APPID = LFtb RCP = $(APP).rcp PRC = $(APP).prc SRC = $(APP).c GRC = $(APP).grc BIN = $(APP).bin CC = m68k - palmos - gcc PILRC = pilrc OBJRES = m68k - palmos - obj - res BUILDPRC = build - prc # uncomment this if you want to build a gdb debuggable version # - On: n = Optimization - level ( 0 = none), - g: needed for debugging # CFLAGS = - O0 - g $(DEFINES) $(INCLUDES) CFLAGS = - O2 $(DEFINES) $(INCLUDES) all: $(PRC) $(PRC): grc.stamp bin.stamp; $(BUILDPRC) $(PRC) $(ICONTEXT) $(APPID) * .grc * .bin $(LINKFILES) ls - l * .prc grc.stamp: $(APP) ; $(OBJRES) $(APP) touch $@ $(APP): $(SRC:.c = .o) ; $(CC) $(CFLAGS) $ ^ - o $@ bin.stamp: $(RCP) ; $(PILRC) $ ^ $(BINDIR) touch $@ % .o: % .c ; $(CC) $(CFLAGS) - c $ < - o $@ # touch $ < # enable this line if you want to compile EVERY time. depend dep: ; $(CC) - M $(SRC) > .dependencies clean: rm - rf * .o $(APP) * .bin * .grc * .stamp veryclean: clean rm - rf * .prc * .bak *~

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9403012/viewspace-1642/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9403012/viewspace-1642/

 类似资料: