一个还不成熟的makefile工程

思路:分为根makefile和各个文件夹下的rules.mak文件组成。
 
/* 根makefile */
TARGET=libmid.a
#
#增加目录
#
SRC :=
obj-y :=
subdir-y :=

subdir-y += $(MID_PATH)/mid_main
subdir-y += $(MID_PATH)/mid_app
 
VPATH += $(subdir-y)
VPATH += $(moddir-y)
 
#CFLAGS += $(subdir-y)
 
include $(patsubst %, %/rules.mak, $(subdir-y))
 
OBJ   := $(obj-f)
OBJ   += $(obj-y)
 
SRC   += $(patsubst %.o, %.c, $(OBJ))
 
all:$(TARGET)
 
xtar:$(mod-y)
 -$(AR) xv $<
$(TARGET): xtar $(OBJ)
 -rm $@
 $(AR) rcv $@ $(OBJ)
 $(AR) ruv $@ $(filter-out $(OBJ),*.o)
 
clean:
 -rm -f $(TARGET) *.o .depend
 
.PHONY:all clean $(TARGET)
 
 
/* rules.mak */

BROWSER_DIR :=
obj-y += mid_browser.o
 
ifeq "$(USE)" "__TEST__"
 BROWSER_DIR += $(MID_PATH)/mid_browser/mid_browser_test
endif
 
subdir-y += $(BROWSER_DIR)
include $(patsubst %, %/rules.mak, $(BROWSER_DIR)) /* 其下又是一个目录,可以递归 */

你可能感兴趣的:(一个还不成熟的makefile工程)