Ai
1 Star 2 Fork 1

seldom/sqlite3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Makefile 4.93 KB
一键复制 编辑 原始数据 按行查看 历史
seldom 提交于 2023-11-26 13:28 +08:00 . v0.0.0.7
# 生成可执行文件名
exe_name=exec
# 编译库时加type参数,如:make staticlib type:=2
# 1:executable编译运行
# 2:将src编译成静态库
# 3:将src编译成动态库
# 4:编译实例
ifndef BUILD_TYPE
ifeq ($(type),)
BUILD_TYPE:=1
else
BUILD_TYPE:=$(type)
endif
endif
# 使用交叉编译
# USE_ARM_COMPILER=1
# 生成库文件名称
# (生成动态编译库需要将库存放在/usr/local/系统库目录下,否则编译的可执行文件无法找到动态库)
# (生成库文件在链接时需要先链接此库文件,在链接其他此库所依赖的库,否则编译无法通过!!!)
# (上一注释说明:编译器对库的链接顺序有严格要求,如:a文件依赖b文件,则编译时需要先编译a文件再编译b文件,链接库也是)
ifeq ($(BUILD_TYPE),1)
lib_name:=sqlite
else
lib_name:=wsqlite
endif
ifeq ($(BUILD_TYPE),2)
COMPILER_LIBRARY:=$(addsuffix .a,$(addprefix lib,$(lib_name)))
endif
ifeq ($(BUILD_TYPE),3)
COMPILER_LIBRARY:=$(addsuffix .so,$(addprefix lib,$(lib_name)))
endif
# 总编译参数
#CCXX_PARAM:=
# 使用动态编译生成库文件需要包含 -fPIC 选项
# C文件编译参数
CC_PARAM:=-c -g -Wall
#CC_PARAM:=-c -g -Wall -fPIC
# C++文件编译参数
CXX_PARAM:=-c -g -Wall
#COMPILER_PREFIX:=arm-linux-
ifdef USE_ARM_COMPILER
COMPILER_PREFIX:=arm-linux-gnueabihf-
endif
# COMPILER_PREFIX:=
# 编译器选择
# # .c文件编译器
MYCC=$(COMPILER_PREFIX)gcc
# # .cpp文件编译器
MYCXX=$(COMPILER_PREFIX)g++
# 生成可执行文件编译器
CCXX=$(MYCXX)
MYSTRIP=$(COMPILER_PREFIX)strip
# 源文件类型
FILE_TYPE:=.c .cpp
# 是否需要遍历源码目录的子目录,1:遍历,0:无需遍历
EACH_SRCDIR:=1
# 是否需要遍历头文件目录的子目录,1:遍历,0:无需遍历
EACH_INCDIR:=0
# 源文件路径
SRCDIR :=
ifdef COMPILER_LIBRARY
SRCDIR += src/
else
ifeq ($(BUILD_TYPE),1)
SRCDIR += executable/
else ifeq ($(BUILD_TYPE),4)
SRCDIR += samples/
endif
endif
ifeq ($(EACH_SRCDIR),1)
# 遍历所有子目录
SRCDIR := $(shell find $(SRCDIR) -type d)
endif
TMP_SRCDIR := $(filter-out %/, $(SRCDIR))
SRCDIR := $(filter %/, $(SRCDIR))
SRCDIR += $(addsuffix /,$(TMP_SRCDIR))
# 头文件路径
INCDIR:=
INCDIR+=inc/
ifeq ($(EACH_INCDIR),1)
INCDIR:=$(shell find $(INCDIR) -type d)
endif
# 编译链接库
CLIBS:=
ifdef COMPILER_LIBRARY
CLIBS+=pthread
CLIBS+=dl
# CLIBS+=Wdebug
else
CLIBS+=wsqlite
CLIBS+=pthread
CLIBS+=dl
# CLIBS+=Wdebug
endif
# 链接库路径
CLIBS_DIR:=
ifdef USE_ARM_COMPILER
CLIBS_DIR+=libARM/
else
CLIBS_DIR+=lib/
endif
# 编译中间文件保存路径
BUILD=build/
# 编译生成库保存路径
ifdef USE_ARM_COMPILER
MYLIBSDIR:=libARM/
else
MYLIBSDIR:=lib/
endif
ifneq ($(BUILD),)
BUILD_ALLDIR:=$(addprefix $(BUILD), $(SRCDIR))
endif
ifneq ($(INCDIR),)
INCDIR:=$(addprefix -I, $(INCDIR))
endif
ifneq ($(CLIBS),)
CLIBS:=$(addprefix -l,$(CLIBS))
endif
ifneq ($(CLIBS_DIR),)
CLIBS_DIR:=$(addprefix -L, $(CLIBS_DIR))
endif
ifneq ($(lib_name),)
static_lib_name:=$(addprefix lib,$(lib_name))
static_lib_name:=$(addsuffix .a,$(static_lib_name))
dynamic_lib_name:=$(addprefix lib,$(lib_name))
dynamic_lib_name:=$(addsuffix .so,$(dynamic_lib_name))
endif
#vpath %.c $(SRCDIR)
# 搜索源文件
SRC:=$(foreach j, $(FILE_TYPE), $(foreach i, \
$(SRCDIR), \
$(wildcard $(addprefix $(i)*, $(j)) ) \
) \
)
# 生成中间文件名
# OBJ :=
# OBJ_TMP := $(filter %.cpp, $(SRC))
# OBJ += $(OBJ_TMP:.cpp=.obj)
# OBJ_TMP := $(filter %.c, $(SRC))
# OBJ += $(OBJ_TMP:.c=.o)
OBJ := $(patsubst %.c, %.o, $(filter %.c, $(SRC))) $(patsubst %.cpp, %.obj, $(filter %.cpp, $(SRC)))
# $(warning $(OBJ))
# 生成依赖文件名
# DEPS :=
# DEPS += $(addprefix $(BUILD), $(addsuffix .d, $(basename $(SRC))))
DEPS := $(addprefix $(BUILD), $(OBJ))
DEPS := $(addsuffix .d, $(basename $(DEPS)))
#DEPS := $(addsuffix .d, $(basename $(DEPS)))
# 默认.o文件搜索路径
vpath %.o $(BUILD)
vpath %.obj $(BUILD)
# 默认库文件搜索路径
vpath %.a $(MYLIBSDIR)
vpath %.so $(MYLIBSDIR)
# .cpp文件编译规则
%.obj:%.cpp
@echo -e $(MYCXX)" \t \t "$<
@$(MYCXX) $(CXX_PARAM) $< $(CLIBS) -std=c++11 -o $@ -MMD -MF $(BUILD)$*.d -MP $(INCDIR) $(CLIBS_DIR) ; \
mv $@ $(BUILD)$@
# .c文件编译规则
%.o:%.c
@echo -e $(MYCC)" \t \t "$<
@$(MYCC) $(CC_PARAM) $< $(CLIBS) -o $@ -MMD -MF $(BUILD)$*.d -MP $(INCDIR) $(CLIBS_DIR) ; \
mv $@ $(BUILD)$@
%/:
@mkdir -p $@
.PHONY:all clean allclean
ifndef COMPILER_LIBRARY
all:$(BUILD_ALLDIR) $(exe_name)
endif
-include mkfile/libdynamic.mk
-include mkfile/libstatic.mk
$(exe_name):$(OBJ)
@echo -e ---------------------------[create $@]-[$(CCXX)]----------------------------------
@echo -e " "$(foreach i, $(addprefix $(BUILD), $(OBJ)), $(i)"\r\n ")
@$(CCXX) $(CCXX_PARAM) $(addprefix $(BUILD), $(OBJ)) $(CLIBS) -o $@ $(CLIBS_DIR)
-include $(DEPS)
clean:
rm -rf $(BUILD)
rm -f $(exe_name)
allclean:clean
rm -f $(MYLIBSDIR)lib$(lib_name).a
rm -f $(MYLIBSDIR)lib$(lib_name).so
-include install.mk
-include Update.mk
-include mkfile/chmod.mk
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Wseldom/sqlite3.git
git@gitee.com:Wseldom/sqlite3.git
Wseldom
sqlite3
sqlite3
release

搜索帮助