makefile 调用其他makefile文件

 
 
.
|-- Makefile
|-- test1
|   |-- Makefile
|   |-- bin
|   |   `-- test
|   |-- hello.o
|   |-- include
|   |   `-- hello.h
|   `-- src
|       `-- hello.c
`
-- test2
    
|-- Makefile
    
|-- bin
    
|   `-- test
    
|-- hello.o
    
|-- include
    
|   `-- hello.h
    
|-- obj
    `
-- src
        `
-- hello.c
 根目录下的Makefile文件调用test2中的Makefile文件:
根目录下的Makefile文件
SUBDIR = ./test2
MAKE 
= make
subsystem:
        cd $(SUBDIR) 
&& $(MAKE)
test2中的Makefile文件:
all: ./bin/test

CC 
= gcc
INCLUDE 
= ./include
vpath 
%.c ./src
vpath 
%.h ./include

.
/bin/test: hello.o
        $(CC) 
-o $@ $^
hello.o: hello.c hello.h
        $(CC) 
-c $< -I$(INCLUDE)
.PHONY: clean
clean:
        
-rm *.o

posted on 2014-05-24 17:35  Red_Point  阅读(2056)  评论(0)    收藏  举报

导航