您的位置:首页 > 其它

应用程序的makefile编写例程

2015-08-13 23:11 260 查看
假设应用程序源程序有三个文件main.c,printf.c,printf.h,生成执行文件为helloworld

假如main.c,printf.c,printf.h与makefile在同一目录,则makefile可以如下编写:

helloworld : main.o printf.o
gcc -o helloworld main.o printf.o
main.o : main.c
gcc -c main.c
printf.o : printf.c
gcc -c printf.c
clean:
rm main.o printf.o helloworld


假如main.c,printf.c与makefile在同一目录,而printf.h在当前目录的/include下,则makefile可如下编写:

helloworld : main.o printf.o
gcc -o helloworld main.o printf.o
CFLAGS := -I$(shell pwd)/include
main.o : main.c
gcc -c main.c $(CFLAGS)
printf.o : printf.c
gcc -c printf.c $(CFLAGS)
clean:
rm main.o printf.o helloworld
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: