makefile调用其他makefile

来源:互联网 发布:mac rar解压 编辑:程序博客网 时间:2024/06/05 04:24
|-- 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
原创粉丝点击