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

 

posted on 2015-05-04 16:54  mengdie  阅读(132)  评论(0编辑  收藏  举报