请教下面makefile中的两个问题
发表于 : 2006-08-15 17:18
# ### Customising
# # 用户设定
# #
# # Adjust the following if necessary; EXECUTABLE is the target
# # executable's filename, and LIBS is a list of libraries to link in
# # (e.g. alleg, stdcx, iostr, etc). You can override these on make's
# # command line of course, if you prefer to do it that way.
# #
# # 如果需要,调整下面的东西。 EXECUTABLE 是目标的可执行文件名, LIBS
# # 是一个需要连接的程序包列表(例如 alleg, stdcx, iostr 等等)。当然你
# # 可以在 make 的命令行覆盖它们,你愿意就没问题。
# #
EXECUTABLE := test
#LIBS := alleg
# # Now alter any implicit rules' variables if you like, e.g.:
# #
# # 现在来改变任何你想改动的隐含规则中的变量,例如
CFLAGS := -g -Wall -O3 -m486
CXXFLAGS := $(CFLAGS)
# You shouldn't need to change anything below this point.
# #
# # 从这里开始,你应该不需要改动任何东西。(我是不太相信,太NB了!)
#vpath %.h ../headers # ### Customising
# # 用户设定
# #
# # Adjust the following if necessary; EXECUTABLE is the target
# # executable's filename, and LIBS is a list of libraries to link in
# # (e.g. alleg, stdcx, iostr, etc). You can override these on make's
# # command line of course, if you prefer to do it that way.
# #
# # 如果需要,调整下面的东西。 EXECUTABLE 是目标的可执行文件名, LIBS
# # 是一个需要连接的程序包列表(例如 alleg, stdcx, iostr 等等)。当然你
# # 可以在 make 的命令行覆盖它们,你愿意就没问题。
# #
EXECUTABLE := test
#LIBS := alleg # 要求 make 在“../headers”目录下搜索所有以“.h”结尾的文件。(如果在当前目录没有找到的话)
SOURCE := $(wildcard *.c) $(wildcard *.cc)
OBJS := $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(SOURCE)))
DEPS := $(patsubst %.o,%.d,$(OBJS))
MISSING_DEPS := $(filter-out $(wildcard $(DEPS)),$(DEPS))
MISSING_DEPS_SOURCES := $(wildcard $(patsubst %.d,%.c,$(MISSING_DEPS)) \
$(patsubst %.d,%.cc,$(MISSING_DEPS)))
CPPFLAGS += -MD
# 直接假定指定的目的需要更新
.PHONY : everything deps objs clean veryclean rebuild
everything : $(EXECUTABLE)
deps : $(DEPS)
objs : $(OBJS)
clean:
@$(RM-F) *.o
@$(RM-F) *.d
veryclean: clean
@$(RM-F) $(EXECUTABLE)
rebuild: veryclean everything
ifneq ($(MISSING_DEPS),)
$(MISSING_DEPS) :
@$(RM-F) $(patsubst %.d,%.o,$@)
endif
-include $(DEPS)
$(EXECUTABLE) : $(OBJS)
gcc -o $(EXECUTABLE) $(OBJS) $(addprefix -l,$(LIBS))
# addprefix的作用是把第二个参数列表的每一项加上第一个参数值作为前缀
# # 用户设定
# #
# # Adjust the following if necessary; EXECUTABLE is the target
# # executable's filename, and LIBS is a list of libraries to link in
# # (e.g. alleg, stdcx, iostr, etc). You can override these on make's
# # command line of course, if you prefer to do it that way.
# #
# # 如果需要,调整下面的东西。 EXECUTABLE 是目标的可执行文件名, LIBS
# # 是一个需要连接的程序包列表(例如 alleg, stdcx, iostr 等等)。当然你
# # 可以在 make 的命令行覆盖它们,你愿意就没问题。
# #
EXECUTABLE := test
#LIBS := alleg
# # Now alter any implicit rules' variables if you like, e.g.:
# #
# # 现在来改变任何你想改动的隐含规则中的变量,例如
CFLAGS := -g -Wall -O3 -m486
CXXFLAGS := $(CFLAGS)
# You shouldn't need to change anything below this point.
# #
# # 从这里开始,你应该不需要改动任何东西。(我是不太相信,太NB了!)
#vpath %.h ../headers # ### Customising
# # 用户设定
# #
# # Adjust the following if necessary; EXECUTABLE is the target
# # executable's filename, and LIBS is a list of libraries to link in
# # (e.g. alleg, stdcx, iostr, etc). You can override these on make's
# # command line of course, if you prefer to do it that way.
# #
# # 如果需要,调整下面的东西。 EXECUTABLE 是目标的可执行文件名, LIBS
# # 是一个需要连接的程序包列表(例如 alleg, stdcx, iostr 等等)。当然你
# # 可以在 make 的命令行覆盖它们,你愿意就没问题。
# #
EXECUTABLE := test
#LIBS := alleg # 要求 make 在“../headers”目录下搜索所有以“.h”结尾的文件。(如果在当前目录没有找到的话)
SOURCE := $(wildcard *.c) $(wildcard *.cc)
OBJS := $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(SOURCE)))
DEPS := $(patsubst %.o,%.d,$(OBJS))
MISSING_DEPS := $(filter-out $(wildcard $(DEPS)),$(DEPS))
MISSING_DEPS_SOURCES := $(wildcard $(patsubst %.d,%.c,$(MISSING_DEPS)) \
$(patsubst %.d,%.cc,$(MISSING_DEPS)))
CPPFLAGS += -MD
# 直接假定指定的目的需要更新
.PHONY : everything deps objs clean veryclean rebuild
everything : $(EXECUTABLE)
deps : $(DEPS)
objs : $(OBJS)
clean:
@$(RM-F) *.o
@$(RM-F) *.d
veryclean: clean
@$(RM-F) $(EXECUTABLE)
rebuild: veryclean everything
ifneq ($(MISSING_DEPS),)
$(MISSING_DEPS) :
@$(RM-F) $(patsubst %.d,%.o,$@)
endif
-include $(DEPS)
$(EXECUTABLE) : $(OBJS)
gcc -o $(EXECUTABLE) $(OBJS) $(addprefix -l,$(LIBS))
# addprefix的作用是把第二个参数列表的每一项加上第一个参数值作为前缀