2013-08-18 17:42:25 +08:00
|
|
|
CC = g++
|
|
|
|
|
|
|
|
CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \
|
2016-10-07 19:11:41 +08:00
|
|
|
-Wno-long-long \
|
2013-08-18 17:42:25 +08:00
|
|
|
-Wpointer-arith -Werror -Wshadow -O3 \
|
|
|
|
-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_USE_FAST_MACRO
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
#Check system:
|
|
|
|
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
|
2017-08-07 11:29:19 +08:00
|
|
|
SYSLIB = -lpthread -lz -ldl
|
2013-08-18 17:42:25 +08:00
|
|
|
CHECKSYSRES = @echo "Unknow system type!";exit 1
|
|
|
|
UNIXNAME = $(shell uname -sm)
|
|
|
|
|
|
|
|
ifeq ($(CC),)
|
|
|
|
CC = gcc
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For FreeBSD
|
|
|
|
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
|
|
|
ifeq ($(findstring gcc, $(CC)), gcc)
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
CFLAGS += -DFREEBSD -D_REENTRANT
|
|
|
|
SYSLIB = -lcrypt -lpthread
|
|
|
|
endif
|
|
|
|
|
2015-08-14 21:18:00 +08:00
|
|
|
# For Darwin
|
|
|
|
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
|
|
|
CFLAGS += -DMACOSX -Wno-invalid-source-encoding \
|
2020-05-19 09:28:57 +08:00
|
|
|
-Wno-invalid-offsetof
|
2015-08-14 21:18:00 +08:00
|
|
|
UNIXTYPE = MACOSX
|
|
|
|
SYSLIB += -liconv -rdynamic
|
|
|
|
endif
|
|
|
|
|
2013-08-18 17:42:25 +08:00
|
|
|
#Path for Linux
|
|
|
|
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
|
|
|
ifeq ($CC, "gcc")
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
CFLAGS += -DLINUX2 -D_REENTRANT
|
2015-08-14 21:18:00 +08:00
|
|
|
SYSLIB += -lcrypt
|
2013-08-18 17:42:25 +08:00
|
|
|
endif
|
|
|
|
|
2017-02-21 22:35:31 +08:00
|
|
|
# For MINGW
|
|
|
|
ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW)
|
|
|
|
SYSLIB = -lpthread-2 -liconv -lz
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For MSYS
|
|
|
|
ifeq ($(findstring MSYS, $(UNIXNAME)), MSYS)
|
|
|
|
SYSLIB = -lpthread-2 -liconv -lz
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
2013-08-18 17:42:25 +08:00
|
|
|
#Path 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
|
|
|
|
ifeq ($CC, "gcc")
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
CFLAGS += -DSUNOS5 -D_REENTRANT
|
|
|
|
endif
|
|
|
|
|
|
|
|
#Path 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
|
|
|
|
|
|
|
|
#Find system type.
|
|
|
|
ifneq ($(SYSPATH),)
|
|
|
|
CHECKSYSRES = @echo "System is $(shell uname -sm)"
|
|
|
|
endif
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
CFLAGS += -I../../lib_acl/include -I../../lib_protocol/include -I../../lib_acl_cpp/include
|
|
|
|
EXTLIBS =
|
2017-03-25 23:05:44 +08:00
|
|
|
LDFLAGS = -L../../lib_acl_cpp/lib -lacl_cpp -L../../lib_protocol/lib -lprotocol -L../../lib_acl/lib -lacl \
|
2013-08-18 17:42:25 +08:00
|
|
|
$(EXTLIBS) $(SYSLIB)
|
|
|
|
|
|
|
|
COMPILE = $(CC) $(CFLAGS)
|
|
|
|
LINK = $(CC) $(OBJ) $(LDFLAGS)
|
|
|
|
###########################################################
|
|
|
|
OBJ_PATH = .
|
|
|
|
|
|
|
|
#Project's objs
|
|
|
|
SRC = $(wildcard *.cpp)
|
|
|
|
OBJ = $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(notdir $(SRC)))
|
|
|
|
|
|
|
|
$(OBJ_PATH)/%.o: %.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
|
|
|
|
|
|
|
.PHONY = all clean
|
|
|
|
all: RM $(OBJ)
|
|
|
|
$(LINK) -o $(PROG)
|
|
|
|
@echo ""
|
|
|
|
@echo "All ok! Output:$(PROG)"
|
|
|
|
@echo ""
|
|
|
|
RM:
|
|
|
|
rm -f $(PROG)
|
|
|
|
clean:
|
|
|
|
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
|
|
|
###########################################################
|