Makfile 模板
时间:2006-12-31 来源:hempel
前段时间学习了一些关于makefile的知识,后来自己写了一个Makefile模板,然后在每个具体的项目中包含这个makefile,定义一下输出结果就行,如下:
这个makefile模版适合中小规模的项目,适当修改后可以支持C,C++,ASM等语言的编译和连接。
多的不说了,看看maiefle就知道了。
我也是刚刚学习自己写makefile,如果有什么建议和指教,请留言,大家切磋切磋!
Makefile模版:
(Hempel世界:http://hempel.cublog.cn)
TARGET := Alert include /usr/local/lib/Makefile.tempalte |
# Copyright Hempel.Chen 2006, Sel. Inc # # This is a template for makefile w, and you can take usage it freely and modify it according to # your requiremtnt, the only thing you need to to is to keep this copyright statement. # # Any problem or advice, please contact me though the following information: # MSN: [email protected] # Email: [email protected] #This is the makefile defines for commonent project compile and link # --------------------------------------------------------------------------- # commands # --------------------------------------------------------------------------- CC := gcc LINK := gcc RM := rm -rf MV := mv TAR := tar MKDIR := mkdir # --------------------------------------------------------------------------- # settings # --------------------------------------------------------------------------- SRC_SUFFIX := .c OBJ_SUFFIX := .o LIB_SUFFIX := .a BIN_SUFFIX := .exe DLL_SUFFIX := .so INC_PREFIX := -I LIB_PREFIX := -L OPT_C := -c OPT_OUT := -o OPT_LINKOUT := -o CFLAGS := $(OPT_C) LIBFLAGS := -Debug # --------------------------------------------------------------------------- # directories # --------------------------------------------------------------------------- SRC_DIR := ./src OBJ_DIR := ./obj INC_DIR := ./inc LIB_DIR := ./lib /usr/local/lib /lib /usr/lib # --------------------------------------------------------------------------- # common settings # --------------------------------------------------------------------------- SRCS := $(wildcard $(SRC_DIR)/*$(SRC_SUFFIX)) OBJS := $(patsubst $(SRC_DIR)/%$(SRC_SUFFIX),$(OBJ_DIR)/%$(OBJ_SUFFIX),$(SRCS)) INCS := $(addprefix $(INC_PREFIX), $(INC_DIR)) LIBS := $(addprefix $(LIB_PREFIX), $(LIB_DIR)) $(LIBFLAGS) TEMPFILES := core core.* *$(OBJ_SUFFIX) temp.* *.out typescript* # --------------------------------------------------------------------------- # make rule # --------------------------------------------------------------------------- .PHONY: all clean all: $(TARGET) clean: $(RM) $(TARGET)$(BIN_SUFFIX) $(OBJS) $(TARGET):$(OBJS) $(LINK) $(OPT_LINKOUT)$(TARGET)$(BIN_SUFFIX) $(LIBS) $(OBJS) $(OBJS):$(OBJ_DIR)/%$(OBJ_SUFFIX):$(SRC_DIR)/%$(SRC_SUFFIX) $(CC) $(CFLAGS) $(INCS) $(OPT_OUT)$@ $< |
|
相关阅读 更多 +