OUTPUT_DLL := libmy.so
LIBS :=-L../public/lib/x64/linux -lzookeeper_mt -lcurl \
-lfreetype -lopencv_core -lopencv_highgui -lopencv_imgproc \
-lsqlite3 -locilib \
-L../public/lib/x64/linux/librdkafka-V0.11.0 -lrdkafka \
-L../public/lib/x64/linux/pqxx -lpqxx -lpq \
#if make x64 or x32 YES or NO
MAKE64 := YES
#base
CC := gcc
CXX := g++
LD := g++
SHELL := /bin/sh
#path
ifeq (YES, $(MAKE64))
BIN_DIR := ../bin/x64/linux/
OBJ_DIR := ../obj/x64/linux/
else
BIN_DIR := ../bin/x86/linux/
OBJ_DIR := ../obj/x86/linux/
endif
#compile all .c .cpp files found in src dir
SRCS := $(wildcard *.c) $(wildcard *.cpp)\
$(wildcard ./database/*.c) $(wildcard ./database/*.cpp)\
$(wildcard ./kafka/*.c) $(wildcard ./kafka/*.cpp)\
$(wildcard ./ws/bigdata/*.c) $(wildcard ./ws/bigdata/*.cpp)\
$(wildcard ./ws/env/*.c) $(wildcard ./ws/env/*.cpp)\
$(wildcard ./ws/*.c) $(wildcard ./ws/*.cpp)\
OBJS := $(addsuffix .o,$(basename $(SRCS)))
VPATH := $(OBJ_DIR)
#include path
INCLUDE_BASE := ../public/include
INCLUDE += $(INCLUDE_BASE):\
$(INCLUDE_BASE)/my:\
$(INCLUDE_BASE)/my1:\
$(INCLUDE_BASE)/curl:\
$(INCLUDE_BASE)/my3:\
$(INCLUDE_BASE)/freetype:\
$(INCLUDE_BASE)/opencv:\
$(INCLUDE_BASE)/librdkafka-V0.11.0:\
$(INCLUDE_BASE)/ocilib:\
$(INCLUDE_BASE)/pqxx/linux:\
./database:\
./HTTPPlugin:\
./ws:\
#if debug
DEBUG := YES
PROFILE := NO
DEBUG_CFLAGS := -Wall -Wno-format -g -fvisibility=hidden
RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-format -O3 -D_CONSOLE -fvisibility=hidden
DEBUG_CXXFLAGS := $(DEBUG_CFLAGS)
RELEASE_CXXFLAGS := $(RELEASE_CFLAGS)
DEBUG_LDFLAGS := -g -Wl,-rpath=./
RELEASE_LDFLAGS := -Wl,-rpath=./
ifeq (YES, $(DEBUG))
CFLAGS := $(DEBUG_CFLAGS)
CXXFLAGS := $(DEBUG_CXXFLAGS)
LDFLAGS := $(DEBUG_LDFLAGS)
else
CFLAGS := $(RELEASE_CFLAGS)
CXXFLAGS := $(RELEASE_CXXFLAGS)
LDFLAGS := $(RELEASE_LDFLAGS)
endif
ifeq (YES, $(PROFILE))
CFLAGS := $(CFLAGS) -pg -O3
CXXFLAGS := $(CXXFLAGS) -pg -O3
LDFLAGS := $(LDFLAGS) -pg
endif
CFLAGS += $(patsubst %, -I%,$(subst :, ,$(INCLUDE)))
CXXFLAGS += $(patsubst %, -I%,$(subst :, ,$(INCLUDE)))
all: $(OUTPUT_DLL) $(OUTPUT_LIB)
lib:$(OUTPUT_LIB)
dll:$(OUTPUT_DLL)
$(OUTPUT_DLL):$(OBJS)
@echo ===================== Linking $(OUTPUT_DLL) in $(BIN_DIR) =========================
$(LD) -shared -fPIC -o $(BIN_DIR)$@ $(LDFLAGS) $(patsubst %, $(OBJ_DIR)%,$(OBJS)) $(LIBS)
$(OUTPUT_LIB):$(OBJS)
@echo ===================== Linking $(OUTPUT_LIB) in $(BIN_DIR) =========================
@ar -rsv -o $(BIN_DIR)$@ $(patsubst %, $(OBJ_DIR)%,$(OBJS))
%.o:%.cpp
@echo ===================== compiling $< =======================
$(CXX) -c $(CXXFLAGS) $< -fPIC -o $(OBJ_DIR)$@
%.o:%.c
@echo ===================== compiling $< ========================
$(CC) -c $(CFLAGS) $< -fPIC -o $(OBJ_DIR)$@
#
# @command clean
# @brief remove all output files and clear screen
#
clean:
-@rm $(patsubst %,$(OBJ_DIR)%,$(OBJS))
-@rm $(patsubst %,$(BIN_DIR)%,$(OUTPUT_LIB))
-@rm $(patsubst %,$(BIN_DIR)%,$(OUTPUT_DLL))
clear
手机扫一扫
移动阅读更方便
你可能感兴趣的文章