################################################################################################################
#
#通用Makefile模板
#自动将src目录下中的.c文件编译,生成所有.o文件保存在bin/objs下
#修改TARGETS和CC以及CFLAGS和LDFLAG即可完成工程的配置
#by zhanggh2013-6-6
#
#################################################################################################################
PROJECT_TOP_DIR=$(shell cd ../; pwd)
PROJECT_BIN_DIR=$(PROJECT_TOP_DIR)/bin
PROJECT_SRC_DIR=$(PROJECT_TOP_DIR)/src
PROJECT_INC_DIR=$(PROJECT_TOP_DIR)/inc
PROJECT_INC_DIR_MY=/home/zgh/cgi/mysql-5.6.11/include/
PROJECT_LIB_DIR=$(PROJECT_TOP_DIR)/lib
#PROJECT_LIB_DIR_MY=/home/zgh/cgi/mysql-5.6.11/lib/
PROJECT_OBJ_DIR=$(PROJECT_BIN_DIR)/objs
MKDIR := mkdir -p
#CC := gcc
CC := arm-none-linux-gnueabi-gcc
TARGETS = multi_smg_find.cgi
#CFLAGS := -g -I $(PROJECT_INC_DIR)
CFLAGS := -I $(PROJECT_INC_DIR) \
-I $(PROJECT_INC_DIR_MY)
LDFLAG := -L $(PROJECT_LIB_DIR) \
#-L $(PROJECT_LIB_DIR_MY)
LIBS := -l mysqlclient
src :=$(wildcard $(PROJECT_SRC_DIR)/*.c)
dir := $(notdir $(src))
PROJECT_OBJ := $(patsubst %.c,%.o,$(dir) )
PROJECT_ALL_OBJS := $(addprefix $(PROJECT_OBJ_DIR)/, $(PROJECT_OBJ))
all:$(PROJECT_SRC_DIR) $(PROJECT_ALL_OBJS)
$(CC) $(CFLAGS) $(PROJECT_ALL_OBJS) -o $(PROJECT_BIN_DIR)/$(TARGETS) $(LDFLAG) $(LIBS)
$(PROJECT_OBJ_DIR)/%.o : $(PROJECT_SRC_DIR)/%.c
$(MKDIR) $(PROJECT_OBJ_DIR)
$(CC) -c $(CFLAGS) $< -o $@
.PHONY:clean
clean:
-rm -rf $(PROJECT_OBJ_DIR)
-rm -rf $(PROJECT_BIN_DIR)/$(TARGETS)