毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> linux >> 正文

模仿李云的Makefile添加include后死循环

更新时间:2016-8-7:  来源:毕业论文

源文件   ./src/main.c ./src/foo.c  ./src/foo.h
执行结果    在
$(DIR_DEPS)/%.dep:$(DIR_DEPS) $(DIR_SRCS)/%.c
        @echo "Making $@..."
        @set -e;\
        $(RM) $(RMFLAGS) $@.tmp;\
        $(CC) -E -MM $(filter %.c,$^) > $@.tmp;\
        sed 's,\(.*\)\.o[:]*,$(DIR_OBJS)/\1.o:,g' < $@.tmp > $@;\
        $(RM) $(RMFLAGS) $@.tmp
这里死循环了。。。Makefile源文件如下

Makefile[/color]
.PHONY:all clean

CC = gcc
RM = rm
RMFLAGS = -fr

MKDIR = mkdir
DIR_OBJS = objs
DIR_EXES = exes
DIR_SRCS = src
DIR_DEPS = deps
DIRS = $(DIR_OBJS) $(DIR_EXES) $(DIR_DEPS)

EXE = exe
EXE := $(addprefix $(DIR_EXES)/, $(EXE))

SRCS := $(wildcard $(DIR_SRCS)/*.c)
OBJS := $(patsubst $(DIR_SRCS)/%.c,$(DIR_OBJS)/%.o,$(SRCS))
DEPS := $(patsubst $(DIR_SRCS)/%.c,$(DIR_DEPS)/%.dep,$(SRCS))

all: $(EXE)

-include $(DEPS)
-include $(DEPS)

$(DIRS):
        $(MKDIR) $@

$(EXE): $(DIR_EXES) $(OBJS)
        @echo "This is EXE"
        @echo $@
        $(CC) -o $@ $(filter %.o,$^)
$(DIR_OBJS)/%.o:$(DIR_OBJS) $(DIR_SRCS)/%.c
        $(CC) -o $@ -c $(filter %.c,$^)
$(DIR_DEPS)/%.dep:$(DIR_DEPS) $(DIR_SRCS)/%.c
        @echo "Making $@..."
        @set -e;\
        $(RM) $(RMFLAGS) $@.tmp;\
        $(CC) -E -MM $(filter %.c,$^) > $@.tmp;\
        sed 's,\(.*\)\.o[:]*,$(DIR_OBJS)/\1.o:,g' < $@.tmp > $@;\
        $(RM) $(RMFLAGS) $@.tmp
clean:
        $(RM) $(RMFLAGS) $(DIRS)

[1] [2] [3] 下一页

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。