#Set project name
PRJ_NAME = FileSystem.a#set project type
PRJ_TYPE = ar rcs
#set Debug or Release
Compile_Flag = Debug
#set output path
Output := bin
#set source folder
SRC := Source
#add lib used
#combine output folder
FinalOutput := $(Output)/$(Compile_Flag)/
#filags in makefile
DEBUG_FLAG := -O0 -g -Wall -c
RELEASE_FLAG := -O3 -Wall -c
RM := rm $(FinalOutput)*
#set compile flag
#ifeq($(Compile_Flag),Debug)
CFLAGS := $(DEBUG_FLAG)
#else
#CFLAGS := $(RELEASE_FLAG)
#endif
#prepare files
CPP_SRCS := $(shell find ./$(SRC) -name *.cpp)
OBJS := $(CPP_SRCS:./$(SRC)/%.cpp = $(FinalOutput)%.o)
#all target
#.PHONY all
all: dir $(FinalOutput)$(PRJ_NAME)
dir:
mkdir -p $(FinalOutput)
#echo $(CPP_SRCS)
#echo $(OBJS)
$(FinalOutput)$(PRJ_NAME): $(OBJS)
$(PRJ_TYPE) $@ $^
g++ $(CFLAGS) $^ -o $@ -D _IPHONE
clean:
-$(RM)
说明:
1) 所有源文件放在FileSystem目录下的Source目录中.
2) 本makefile文件放在FileSystem目录中.
3) 生成的.o文件和静态库文件FileSystem.a放在FileSystem/bin/Debug/目录中.
4) 参考文章: http://hi.baidu.com/hawthorne/blog/item/39328cb3b5194fafd9335acd.html
在实际编写和运行时, 遇到一些问题, 故根据实际需要作出一些调整.