1 OUTPUT_DLL := libmy.so 2 LIBS :=-L../public/lib/x64/linux -lzookeeper_mt -lcurl \ 3 -lfreetype -lopencv_core -lopencv_highgui -lopencv_imgproc \ 4 -lsqlite3 -locilib \ 5 -L../public/lib/x64/linux/librdkafka-V0.11.0 -lrdkafka \ 6 -L../public/lib/x64/linux/pqxx -lpqxx -lpq \ 7 8 #if make x64 or x32 YES or NO 9 MAKE64 := YES 10 11 #base 12 CC := gcc 13 CXX := g++ 14 LD := g++ 15 SHELL := /bin/sh 16 17 #path 18 ifeq (YES, $(MAKE64)) 19 BIN_DIR := ../bin/x64/linux/ 20 OBJ_DIR := ../obj/x64/linux/ 21 else 22 BIN_DIR := ../bin/x86/linux/ 23 OBJ_DIR := ../obj/x86/linux/ 24 endif 25 26 #compile all .c .cpp files found in src dir 27 SRCS := $(wildcard *.c) $(wildcard *.cpp)\ 28 $(wildcard ./database/*.c) $(wildcard ./database/*.cpp)\ 29 $(wildcard ./kafka/*.c) $(wildcard ./kafka/*.cpp)\ 30 $(wildcard ./ws/bigdata/*.c) $(wildcard ./ws/bigdata/*.cpp)\ 31 $(wildcard ./ws/env/*.c) $(wildcard ./ws/env/*.cpp)\ 32 $(wildcard ./ws/*.c) $(wildcard ./ws/*.cpp)\ 33 34 OBJS := $(addsuffix .o,$(basename $(SRCS))) 35 VPATH := $(OBJ_DIR) 36 37 #include path 38 INCLUDE_BASE := ../public/include 39 INCLUDE += $(INCLUDE_BASE):\ 40 $(INCLUDE_BASE)/my:\ 41 $(INCLUDE_BASE)/my1:\ 42 $(INCLUDE_BASE)/curl:\ 43 $(INCLUDE_BASE)/my3:\ 44 $(INCLUDE_BASE)/freetype:\ 45 $(INCLUDE_BASE)/opencv:\ 46 $(INCLUDE_BASE)/librdkafka-V0.11.0:\ 47 $(INCLUDE_BASE)/ocilib:\ 48 $(INCLUDE_BASE)/pqxx/linux:\ 49 ./database:\ 50 ./HTTPPlugin:\ 51 ./ws:\ 52 53 #if debug 54 DEBUG := YES 55 PROFILE := NO 56 57 DEBUG_CFLAGS := -Wall -Wno-format -g -fvisibility=hidden 58 RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-format -O3 -D_CONSOLE -fvisibility=hidden 59 DEBUG_CXXFLAGS := $(DEBUG_CFLAGS) 60 RELEASE_CXXFLAGS := $(RELEASE_CFLAGS) 61 DEBUG_LDFLAGS := -g -Wl,-rpath=./ 62 RELEASE_LDFLAGS := -Wl,-rpath=./ 63 64 ifeq (YES, $(DEBUG)) 65 CFLAGS := $(DEBUG_CFLAGS) 66 CXXFLAGS := $(DEBUG_CXXFLAGS) 67 LDFLAGS := $(DEBUG_LDFLAGS) 68 else 69 CFLAGS := $(RELEASE_CFLAGS) 70 CXXFLAGS := $(RELEASE_CXXFLAGS) 71 LDFLAGS := $(RELEASE_LDFLAGS) 72 endif 73 74 ifeq (YES, $(PROFILE)) 75 CFLAGS := $(CFLAGS) -pg -O3 76 CXXFLAGS := $(CXXFLAGS) -pg -O3 77 LDFLAGS := $(LDFLAGS) -pg 78 endif 79 80 CFLAGS += $(patsubst %, -I%,$(subst :, ,$(INCLUDE))) 81 CXXFLAGS += $(patsubst %, -I%,$(subst :, ,$(INCLUDE))) 82 83 all: $(OUTPUT_DLL) $(OUTPUT_LIB) 84 85 lib:$(OUTPUT_LIB) 86 87 dll:$(OUTPUT_DLL) 88 89 $(OUTPUT_DLL):$(OBJS) 90 @echo ===================== Linking $(OUTPUT_DLL) in $(BIN_DIR) ========================= 91 $(LD) -shared -fPIC -o $(BIN_DIR)$@ $(LDFLAGS) $(patsubst %, $(OBJ_DIR)%,$(OBJS)) $(LIBS) 92 93 $(OUTPUT_LIB):$(OBJS) 94 @echo ===================== Linking $(OUTPUT_LIB) in $(BIN_DIR) ========================= 95 @ar -rsv -o $(BIN_DIR)$@ $(patsubst %, $(OBJ_DIR)%,$(OBJS)) 96 97 %.o:%.cpp 98 @echo ===================== compiling $< ======================= 99 $(CXX) -c $(CXXFLAGS) $< -fPIC -o $(OBJ_DIR)$@ 100 %.o:%.c 101 @echo ===================== compiling $< ======================== 102 $(CC) -c $(CFLAGS) $< -fPIC -o $(OBJ_DIR)$@ 103 # 104 # @command clean 105 # @brief remove all output files and clear screen 106 # 107 clean: 108 -@rm $(patsubst %,$(OBJ_DIR)%,$(OBJS)) 109 -@rm $(patsubst %,$(BIN_DIR)%,$(OUTPUT_LIB)) 110 -@rm $(patsubst %,$(BIN_DIR)%,$(OUTPUT_DLL)) 111 clear