2013-08-18 17:42:25 +08:00
|
|
|
SHELL = /bin/sh
|
|
|
|
CC = g++
|
|
|
|
AR = ar
|
|
|
|
ARFL = rv
|
|
|
|
#ARFL = cru
|
|
|
|
RANLIB = ranlib
|
|
|
|
|
|
|
|
#-Wcast-qual
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS = -c -g -W \
|
|
|
|
-Wall \
|
|
|
|
-Wcast-align \
|
|
|
|
-Wpointer-arith \
|
|
|
|
-Werror \
|
|
|
|
-Wshadow \
|
|
|
|
-O3 \
|
|
|
|
-D_REENTRANT \
|
|
|
|
-D_POSIX_PTHREAD_SEMANTICS \
|
2013-08-18 17:42:25 +08:00
|
|
|
-Wno-long-long \
|
|
|
|
-fPIC \
|
|
|
|
-Wformat \
|
|
|
|
-DDEBUG
|
|
|
|
#-DHAS_POLARSSL
|
|
|
|
#-DUSE_DYNAMIC
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
#Check system:
|
|
|
|
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
|
|
|
|
SYSLIB =
|
|
|
|
CHECKSYSRES = @echo "Unknow system type!";exit 1
|
|
|
|
UNIXNAME = $(shell uname -sm)
|
|
|
|
|
|
|
|
ifeq ($(CC),)
|
|
|
|
CC = g++
|
|
|
|
endif
|
|
|
|
|
2015-01-06 23:24:02 +08:00
|
|
|
ifeq ($(findstring gcc, $(CC)), gcc)
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
|
2013-08-18 17:42:25 +08:00
|
|
|
# For FreeBSD
|
|
|
|
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS += -DFREEBSD
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
2015-01-05 17:25:09 +08:00
|
|
|
# For Darwin
|
|
|
|
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
2022-04-11 19:09:39 +08:00
|
|
|
# CC += -arch x86_64 -arch arm64
|
2020-05-19 09:28:57 +08:00
|
|
|
CFLAGS += -DMACOSX -Wno-invalid-source-encoding -Wno-invalid-offsetof
|
2015-01-05 17:25:09 +08:00
|
|
|
UNIXTYPE = MACOSX
|
|
|
|
endif
|
|
|
|
|
2013-08-18 17:42:25 +08:00
|
|
|
# For Linux
|
|
|
|
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
|
|
|
ifeq ($CC, "gcc")
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS += -DLINUX2
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# For SunOS
|
|
|
|
ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
|
|
|
ifeq ($(findstring 86, $(UNIXNAME)), 86)
|
|
|
|
SYSLIB = -lsocket -lnsl -lrt
|
|
|
|
endif
|
|
|
|
ifeq ($(findstring sun4u, $(UNIXNAME)), sun4u)
|
|
|
|
SYSLIB = -lsocket -lnsl -lrt
|
|
|
|
endif
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS += -DSUNOS5
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# For HP-UX
|
|
|
|
ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX)
|
|
|
|
ifeq ($CC, "gcc")
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
CFLAGS += -DHP_UX -DHPUX11
|
|
|
|
PLAT_NAME=hp-ux
|
|
|
|
endif
|
|
|
|
|
2022-08-06 23:32:00 +08:00
|
|
|
# For CYGWIN
|
|
|
|
ifeq ($(findstring CYGWIN, $(UNIXNAME)), CYGWIN)
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For MINGW
|
|
|
|
ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW)
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For MSYS
|
|
|
|
ifeq ($(findstring MSYS, $(UNIXNAME)), MSYS)
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2013-08-18 17:42:25 +08:00
|
|
|
#Find system type.
|
|
|
|
ifneq ($(SYSPATH),)
|
|
|
|
CHECKSYSRES = @echo "System is $(shell uname -sm)"
|
|
|
|
endif
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
OBJ_PATH_DST = ./Debug
|
|
|
|
LIB_PATH_DST = .
|
|
|
|
DEF_PATH_DST = ./Debug
|
|
|
|
|
|
|
|
CFLAGS += -I./include -I../lib_acl_cpp/include -I../lib_acl/include -I../include
|
|
|
|
|
|
|
|
#Project's objs
|
|
|
|
OBJS_DST = $(patsubst %.cpp, $(OBJ_PATH_DST)/%.o, $(notdir $(wildcard src/*.cpp)))
|
|
|
|
|
|
|
|
OBJS_DEF = $(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/*.cpp)))
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
.PHONY = static clean
|
|
|
|
VERSION = 1.0
|
|
|
|
DATE_NOW = 20`date +%y`.`date +%m`.`date +%d`
|
|
|
|
|
|
|
|
all: static
|
|
|
|
|
|
|
|
$(shell mkdir -p $(DEF_PATH_DST))
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
-include $(OBJS_DEF)
|
|
|
|
endif
|
|
|
|
|
|
|
|
COMPILE = $(CC) $(CFLAGS)
|
|
|
|
COMPILE_OBJ = @(echo 'building $<'; $(COMPILE) $< -o $@)
|
|
|
|
CREATE_DEF = @(echo 'creating $@'; rm -f $@; \
|
|
|
|
$(COMPILE) -MM $< > $@.$$$$; \
|
|
|
|
sed 's,.*.o\( \)*:,$(patsubst %.inc,%.o,$@) $@ :,g' < $@.$$$$ > $@; \
|
|
|
|
rm -f $@.$$$$)
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
static: depends $(OBJS_DST)
|
|
|
|
@echo 'creating $(LIB_PATH_DST)/lib_rpc.a'
|
|
|
|
@$(AR) $(ARFL) $(LIB_PATH_DST)/lib_rpc.a $(OBJS_DST)
|
|
|
|
@$(RANLIB) $(LIB_PATH_DST)/lib_rpc.a
|
|
|
|
@echo 'create $(LIB_PATH_DST)/lib_rpc.a ok!'
|
|
|
|
|
|
|
|
depends: $(OBJS_DEF)
|
|
|
|
|
|
|
|
# src
|
|
|
|
$(OBJ_PATH_DST)/%.o: ./src/%.cpp
|
|
|
|
$(COMPILE_OBJ)
|
|
|
|
|
|
|
|
$(DEF_PATH_DST)/%.inc: ./src/%.cpp
|
|
|
|
$(CREATE_DEF)
|
|
|
|
|
|
|
|
samples: $(lib_rpc.a)
|
|
|
|
@(cd samples; make)
|
|
|
|
clean:
|
|
|
|
rm -f $(LIB_PATH_DST)/lib_rpc.a
|
|
|
|
rm -f $(OBJS_DST)
|
|
|
|
rm -f $(OBJS_DEF)
|
|
|
|
@(cd samples; make clean)
|