码迷,mamicode.com
首页 > 其他好文 > 详细

Embedded之Makefile

时间:2015-05-04 17:19:57      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

1  Header files  

The header files are empty, so you can create them with touch:

$ touch a.h
$ touch b.h
$ touch c.h

 

2  Source files

 1 /* main.c */
 2 #include <stdlib.h>
 3 #include "a.h"
 4 
 5 extern void function_ab();
 6 extern void function_bc();
 7 
 8 int main()
 9 {
10   function_ab();
11   function_bc();
12   exit (EXIT_SUCCESS);
13 }
1 /* ab.c */
2 #include "a.h"
3 #include "b.h"
4 
5 void function_ab()
6 {
7 }
1 /* bc.c */
2 #include "b.h"
3 #include "c.h"
4 
5 void function_bc()
6 {
7 }

 

3  A simple makefile

 1 myapp: main.o ab.o bc.o
 2   gcc -o myapp main.o ab.o bc.o
 3 
 4 main.o: main.c a.h
 5   gcc -c main.c
 6 
 7 ab.o: ab.c a.h b.h
 8   gcc -c ab.c
 9 
10 bc.o: bc.c b.h c.h
11   gcc -c bc.c

 

4  make

$ make -f Makefile1

 

Embedded之Makefile

标签:

原文地址:http://www.cnblogs.com/mengdie/p/4476604.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!