2016-01-17 13:35:12 +08:00
|
|
|
CC = ${ENV_CPP}
|
2015-11-20 23:29:10 +08:00
|
|
|
FLAGS = ${ENV_FLAGS}
|
2013-08-18 17:42:25 +08:00
|
|
|
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS = -c -g -W \
|
|
|
|
-Wall \
|
|
|
|
-Werror \
|
|
|
|
-Wshadow \
|
2013-08-18 17:42:25 +08:00
|
|
|
-Wno-long-long \
|
2015-01-06 23:24:02 +08:00
|
|
|
-Wpointer-arith \
|
|
|
|
-D_REENTRANT \
|
|
|
|
-D_POSIX_PTHREAD_SEMANTICS \
|
2015-02-08 00:18:29 +08:00
|
|
|
-D_USE_FAST_MACRO
|
|
|
|
#-Wno-invalid-source-encoding
|
2013-08-18 17:42:25 +08:00
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
#-Wcast-qual
|
2015-01-04 22:51:01 +08:00
|
|
|
# -Wcast-align
|
2013-08-18 17:42:25 +08:00
|
|
|
#-Waggregate-return
|
|
|
|
###########################################################
|
|
|
|
#Check system:
|
|
|
|
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
|
2017-08-07 12:04:56 +08:00
|
|
|
SYSLIB = -lpthread -ldl
|
2015-11-20 23:29:10 +08:00
|
|
|
EXTLIBS =
|
2013-08-18 17:42:25 +08:00
|
|
|
CHECKSYSRES = @echo "Unknow system type!";exit 1
|
2013-12-27 22:38:17 +08:00
|
|
|
OSNAME = $(shell uname -sm)
|
2014-01-13 21:27:38 +08:00
|
|
|
UNIXNAME = $(OSNAME)
|
2013-12-27 22:38:17 +08:00
|
|
|
RPATH =
|
2013-08-18 17:42:25 +08:00
|
|
|
|
|
|
|
ifeq ($(CC),)
|
2015-01-04 22:51:01 +08:00
|
|
|
CC = g++
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
2015-11-20 23:29:10 +08:00
|
|
|
ifeq ($(findstring HAS_LIBICONV, $(FLAGS)), HAS_LIBICONV)
|
|
|
|
EXTLIBS += -liconv
|
|
|
|
endif
|
|
|
|
|
2015-02-10 17:23:24 +08:00
|
|
|
ifeq ($(findstring clang++, $(CC)), clang++)
|
|
|
|
CFLAGS += -Wno-invalid-source-encoding \
|
|
|
|
-Wno-extended-offsetof
|
|
|
|
endif
|
|
|
|
|
2013-08-18 17:42:25 +08:00
|
|
|
# For FreeBSD
|
2013-12-27 22:38:17 +08:00
|
|
|
ifeq ($(findstring FreeBSD, $(OSNAME)), FreeBSD)
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS += -DFREEBSD
|
2015-05-21 21:49:35 +08:00
|
|
|
SYSLIB = -lcrypt -lpthread -rdynamic
|
2015-12-20 15:27:55 +08:00
|
|
|
RPATH = freebsd
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
2015-01-05 17:25:09 +08:00
|
|
|
# For Darwin
|
|
|
|
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
2015-02-10 17:23:24 +08:00
|
|
|
CFLAGS += -DMACOSX -Wno-invalid-source-encoding \
|
|
|
|
-Wno-extended-offsetof
|
2015-05-21 21:49:35 +08:00
|
|
|
SYSLIB += -rdynamic
|
2015-08-26 20:45:40 +08:00
|
|
|
UNIXTYPE = MACOSX
|
2015-12-20 15:27:55 +08:00
|
|
|
RPATH = macos
|
2015-01-05 17:25:09 +08:00
|
|
|
endif
|
|
|
|
|
2013-08-18 17:42:25 +08:00
|
|
|
#Path for Linux
|
2013-12-27 22:38:17 +08:00
|
|
|
ifeq ($(findstring Linux, $(OSNAME)), Linux)
|
|
|
|
ifeq ($(findstring i686, $(OSNAME)), i686)
|
|
|
|
RPATH = linux32
|
|
|
|
endif
|
|
|
|
ifeq ($(findstring x86_64, $(OSNAME)), x86_64)
|
|
|
|
RPATH = linux64
|
|
|
|
endif
|
2017-02-12 21:39:38 +08:00
|
|
|
# CFLAGS += -DLINUX2
|
2015-08-26 20:45:40 +08:00
|
|
|
SYSLIB += -rdynamic
|
2015-05-21 21:49:35 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# For MINGW
|
|
|
|
ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW)
|
|
|
|
SYSLIB = -lpthread-2 -liconv
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
2017-02-21 22:35:31 +08:00
|
|
|
# For MSYS
|
|
|
|
ifeq ($(findstring MSYS, $(UNIXNAME)), MSYS)
|
|
|
|
SYSLIB = -lpthread-2 -liconv
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
2013-08-18 17:42:25 +08:00
|
|
|
#Path for SunOS
|
2013-12-27 22:38:17 +08:00
|
|
|
ifeq ($(findstring SunOS, $(OSNAME)), SunOS)
|
|
|
|
ifeq ($(findstring 86, $(OSNAME)), 86)
|
2013-08-18 17:42:25 +08:00
|
|
|
SYSLIB += -lsocket -lnsl -lrt
|
|
|
|
endif
|
2013-12-27 22:38:17 +08:00
|
|
|
ifeq ($(findstring sun4u, $(OSNAME)), sun4u)
|
2013-08-18 17:42:25 +08:00
|
|
|
SYSLIB += -lsocket -lnsl -lrt
|
|
|
|
endif
|
|
|
|
ifeq ($CC, "gcc")
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS += -DSUNOS5
|
2015-12-20 15:27:55 +08:00
|
|
|
RPATH = solaris
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
#Path for HP-UX
|
2013-12-27 22:38:17 +08:00
|
|
|
ifeq ($(findstring HP-UX, $(OSNAME)), HP-UX)
|
2013-12-07 20:31:59 +08:00
|
|
|
CFLAGS += -DHP_UX -DHPUX11 -Wshadow
|
2013-08-18 17:42:25 +08:00
|
|
|
PLAT_NAME=hp-ux
|
2015-12-20 15:27:55 +08:00
|
|
|
RPATH = hpux
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
#Find system type.
|
|
|
|
ifneq ($(SYSPATH),)
|
|
|
|
CHECKSYSRES = @echo "System is $(shell uname -sm)"
|
|
|
|
endif
|
|
|
|
###########################################################
|
2015-01-04 22:51:01 +08:00
|
|
|
SRC =
|
2014-07-29 21:48:23 +08:00
|
|
|
BASE_PATH =
|
2015-01-04 22:51:01 +08:00
|
|
|
UTIL_PATH =
|
2014-07-29 21:48:23 +08:00
|
|
|
ifneq ($(base_path),)
|
|
|
|
BASE_PATH = $(base_path)
|
2015-01-04 22:51:01 +08:00
|
|
|
UTIL_PATH = $(base_path)/samples
|
|
|
|
CFLAGS += -I$(base_path)/samples
|
|
|
|
SRC = $(wildcard $(UTIL_PATH)/*.cpp)
|
2014-07-29 21:48:23 +08:00
|
|
|
else
|
|
|
|
BASE_PATH = ../..
|
|
|
|
endif
|
|
|
|
|
2015-01-04 22:51:01 +08:00
|
|
|
#ifneq ($(util_path),)
|
|
|
|
# UTIL_PATH = $(util_path)
|
|
|
|
#else
|
|
|
|
# UTIL_PATH = ..
|
|
|
|
#endif
|
2014-12-07 23:48:11 +08:00
|
|
|
|
2014-07-29 21:48:23 +08:00
|
|
|
CFLAGS += -I. -I$(BASE_PATH)/include -I$(BASE_PATH)/../lib_acl/include -I$(BASE_PATH)/../lib_protocol/include
|
2017-03-25 23:05:44 +08:00
|
|
|
LDFLAGS = -L$(BASE_PATH)/lib -lacl_cpp -L$(BASE_PATH)/../lib_protocol/lib -lprotocol -L$(BASE_PATH)/../lib_acl/lib -lacl \
|
2015-05-21 21:49:35 +08:00
|
|
|
-L$(BASE_PATH)/../lib/$(RPATH) $(EXTLIBS) $(SYSLIB)
|
2013-08-18 17:42:25 +08:00
|
|
|
|
|
|
|
COMPILE = $(CC) $(CFLAGS)
|
|
|
|
LINK = $(CC) $(OBJ) $(LDFLAGS)
|
|
|
|
###########################################################
|
|
|
|
OBJ_PATH = .
|
|
|
|
|
|
|
|
#Project's objs
|
2014-12-07 23:48:11 +08:00
|
|
|
#UTIL = $(wildcard $(UTIL_PATH)/*.cpp)
|
2015-01-04 22:51:01 +08:00
|
|
|
SRC += $(wildcard *.cpp)
|
2014-12-07 23:48:11 +08:00
|
|
|
#SRC = $(wildcard *.cpp)
|
2013-08-18 17:42:25 +08:00
|
|
|
OBJ = $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(notdir $(SRC)))
|
|
|
|
|
|
|
|
$(OBJ_PATH)/%.o: %.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
2014-12-07 23:48:11 +08:00
|
|
|
$(OBJ_PATH)/%.o: $(UTIL_PATH)/%.cpp
|
2013-08-18 17:42:25 +08:00
|
|
|
$(COMPILE) $< -o $@
|
|
|
|
|
|
|
|
.PHONY = all clean
|
|
|
|
all: RM $(OBJ)
|
|
|
|
$(LINK) -o $(PROG)
|
|
|
|
@echo ""
|
|
|
|
@echo "All ok! Output:$(PROG)"
|
|
|
|
@echo ""
|
2015-09-27 20:59:21 +08:00
|
|
|
rebuild rb: clean all
|
2013-08-18 17:42:25 +08:00
|
|
|
RM:
|
|
|
|
rm -f $(PROG)
|
2015-09-27 20:59:21 +08:00
|
|
|
clean cl:
|
2013-08-18 17:42:25 +08:00
|
|
|
rm -f $(PROG)
|
|
|
|
rm -f $(OBJ)
|
2015-09-27 20:59:21 +08:00
|
|
|
|
|
|
|
rebuild rb: clean all
|
2013-08-18 17:42:25 +08:00
|
|
|
###########################################################
|