1 Star 0 Fork 320

jhkwei/gear-lib

forked from gozfree/gear-lib 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Makefile 2.97 KB
一键复制 编辑 原始数据 按行查看 历史
gozfree 提交于 2020-03-14 19:53 . fix compile error
###############################################################################
# common
###############################################################################
#ARCH: linux/arm/android/ios/win
ARCH ?= linux
CROSS_PREFIX ?=
OUTPUT ?= /usr/local
BUILD_DIR := $(shell pwd)/../build/
ARCH_INC := $(BUILD_DIR)/$(ARCH).inc
COLOR_INC := $(BUILD_DIR)/color.inc
ifeq ($(ARCH_INC), $(wildcard $(ARCH_INC)))
include $(ARCH_INC)
endif
CC = $(CROSS_PREFIX)gcc
CXX = $(CROSS_PREFIX)g++
LD = $(CROSS_PREFIX)ld
AR = $(CROSS_PREFIX)ar
STRIP = $(CROSS_PREFIX)strip
ifeq ($(COLOR_INC), $(wildcard $(COLOR_INC)))
include $(COLOR_INC)
else
CC_V = $(CC)
CXX_V = $(CXX)
LD_V = $(LD)
AR_V = $(AR)
CP_V = $(CP)
RM_V = $(RM)
endif
###############################################################################
# target and object
###############################################################################
LIBNAME = libgear
VERSION_SH = $(shell pwd)/src/version.sh $(LIBNAME)
VER = $(shell $(VERSION_SH); awk '/define\ $(LIBNAME)_version/{print $$3}' version.h)
TGT_LIB_H = $(LIBNAME).h
TGT_LIB_A = $(LIBNAME).a
TGT_LIB_SO = $(LIBNAME).so
TGT_LIB_SO_VER = $(TGT_LIB_SO).${VER}
OBJS_LIB := $(patsubst %.c,%.o,$(wildcard src/*.c))
###############################################################################
# cflags and ldflags
###############################################################################
ifeq ($(MODE), release)
CFLAGS := -O2 -Wall -Werror -fPIC
LTYPE := release
else
CFLAGS := -g -Wall -Werror -fPIC
LTYPE := debug
endif
ifeq ($(OUTPUT),/usr/local)
OUTLIBPATH := /usr/local
else
OUTLIBPATH := $(OUTPUT)/$(LTYPE)
endif
CFLAGS += $($(ARCH)_CFLAGS)
CFLAGS += -I./include
CFLAGS += -I$(OUTPUT)/include
CFLAGS += -DNO_CRYPTO
SHARED := -shared
LDFLAGS := $($(ARCH)_LDFLAGS)
LDFLAGS += -pthread
###############################################################################
# target
###############################################################################
.PHONY : all clean
TGT := $(TGT_LIB_A)
TGT += $(TGT_LIB_SO)
OBJS := $(OBJS_LIB)
all: $(TGT)
%.o:%.c
$(CC_V) -c $(CFLAGS) $< -o $@
$(TGT_LIB_A): $(OBJS_LIB)
$(AR_V) rcs $@ $^
$(TGT_LIB_SO): $(OBJS_LIB)
$(CC_V) -o $@ $^ $(SHARED)
@mv $(TGT_LIB_SO) $(TGT_LIB_SO_VER)
@ln -sf $(TGT_LIB_SO_VER) $(TGT_LIB_SO)
clean:
$(RM_V) -f $(OBJS)
$(RM_V) -f $(TGT)
$(RM_V) -f version.h
$(RM_V) -f $(TGT_LIB_SO)*
$(RM_V) -f $(TGT_LIB_SO_VER)
install:
$(MAKEDIR_OUTPUT)
@if [ "$(MODE)" = "release" ];then $(STRIP) $(TGT); fi
@mkdir -p ${OUTPUT}/include/gear-lib
@mkdir -p ${OUTPUT}/lib/gear-lib
$(CP_V) -r include/$(TGT_LIB_H) $(OUTPUT)/include/gear-lib
$(CP_V) -r $(TGT_LIB_A) $(OUTLIBPATH)/lib/gear-lib
$(CP_V) -r $(TGT_LIB_SO) $(OUTLIBPATH)/lib/gear-lib
$(CP_V) -r $(TGT_LIB_SO_VER) $(OUTLIBPATH)/lib/gear-lib
uninstall:
cd $(OUTPUT)/include/gear-lib && rm -f $(TGT_LIB_H)
$(RM_V) -f $(OUTLIBPATH)/lib/gear-lib/$(TGT_LIB_A)
$(RM_V) -f $(OUTLIBPATH)/lib/gear-lib/$(TGT_LIB_SO)
$(RM_V) -f $(OUTLIBPATH)/lib/gear-lib/$(TGT_LIB_SO_VER)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/jhkwei/gear-lib.git
git@gitee.com:jhkwei/gear-lib.git
jhkwei
gear-lib
gear-lib
master

搜索帮助