2016-01-17 13:35:12 +08:00
|
|
|
CC = $(ENV_CPP)
|
2014-01-19 23:59:13 +08:00
|
|
|
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS = -c -g -W \
|
|
|
|
-Wall \
|
|
|
|
-Wcast-qual \
|
|
|
|
-Waggregate-return \
|
|
|
|
-Wno-long-long \
|
|
|
|
-Wpointer-arith \
|
|
|
|
-Werror \
|
|
|
|
-Wshadow \
|
|
|
|
-O2 \
|
|
|
|
-D_REENTRANT \
|
|
|
|
-D_POSIX_PTHREAD_SEMANTICS \
|
2015-02-08 00:18:29 +08:00
|
|
|
-D_USE_FAST_MACRO
|
2015-01-06 23:24:02 +08:00
|
|
|
|
|
|
|
#-Wcast-align
|
2014-01-19 23:59:13 +08:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
#Check system:
|
|
|
|
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
|
|
|
|
SYSLIB = -lpthread
|
|
|
|
CHECKSYSRES = @echo "Unknow system type!";exit 1
|
|
|
|
UNIXNAME = $(shell uname -sm)
|
|
|
|
|
|
|
|
ifeq ($(CC),)
|
2015-01-04 22:51:01 +08:00
|
|
|
CC = g++
|
2014-01-19 23:59:13 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(findstring gcc, $(CC)), gcc)
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
|
2015-02-10 17:23:24 +08:00
|
|
|
ifeq ($(findstring clang, $(CC)), clang)
|
|
|
|
CFLAGS += -Wstrict-prototypes \
|
|
|
|
-Wno-invalid-source-encoding \
|
2020-05-19 09:28:57 +08:00
|
|
|
-Wno-invalid-offsetof
|
2015-02-10 17:23:24 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(findstring clang++, $(CC)), clang++)
|
|
|
|
CFLAGS += -Wno-invalid-source-encoding \
|
2020-05-19 09:28:57 +08:00
|
|
|
-Wno-invalid-offsetof
|
2015-02-10 17:23:24 +08:00
|
|
|
endif
|
|
|
|
|
2014-01-19 23:59:13 +08:00
|
|
|
# For FreeBSD
|
|
|
|
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS += -DFREEBSD -pedantic
|
2014-01-19 23:59:13 +08:00
|
|
|
SYSLIB += -lcrypt
|
|
|
|
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
|
2015-02-10 17:23:24 +08:00
|
|
|
CFLAGS += -DMACOSX -Wno-invalid-source-encoding \
|
2020-05-19 09:28:57 +08:00
|
|
|
-Wno-invalid-offsetof
|
2015-01-05 17:25:09 +08:00
|
|
|
UNIXTYPE = MACOSX
|
|
|
|
endif
|
|
|
|
|
2014-01-19 23:59:13 +08:00
|
|
|
#Path for Linux
|
|
|
|
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
2017-02-12 21:39:38 +08:00
|
|
|
# CFLAGS += -DLINUX2 -pedantic
|
|
|
|
CFLAGS += -pedantic
|
2014-01-19 23:59:13 +08:00
|
|
|
SYSLIB += -lcrypt
|
|
|
|
endif
|
|
|
|
|
2015-05-21 21:49:35 +08:00
|
|
|
# For MINGW
|
|
|
|
ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW)
|
|
|
|
SYSLIB = -lpthread-2
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
2017-02-21 22:35:31 +08:00
|
|
|
# For MSYS
|
|
|
|
ifeq ($(findstring MSYS, $(UNIXNAME)), MSYS)
|
|
|
|
SYSLIB = -lpthread-2
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
2014-01-19 23:59:13 +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
|
2015-01-06 23:24:02 +08:00
|
|
|
CFLAGS += -DSUNOS5 -pedantic
|
2014-01-19 23:59:13 +08:00
|
|
|
SYSLIB += -lcrypt
|
|
|
|
endif
|
|
|
|
|
|
|
|
#Path for HP-UX
|
|
|
|
ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX)
|
|
|
|
CFLAGS += -DHP_UX -DHPUX11
|
|
|
|
PLAT_NAME=hp-ux
|
|
|
|
SYSLIB += -lcrypt
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For Darwin
|
|
|
|
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
2022-04-11 19:09:39 +08:00
|
|
|
# CC += -arch x86_64 -arch arm64
|
2014-01-19 23:59:13 +08:00
|
|
|
CFLAGS += -DMACOSX
|
|
|
|
endif
|
|
|
|
|
|
|
|
#Find system type.
|
|
|
|
ifneq ($(SYSPATH),)
|
|
|
|
CHECKSYSRES = @echo "System is $(shell uname -sm)"
|
|
|
|
endif
|
|
|
|
###########################################################
|
|
|
|
|
2014-12-14 18:26:52 +08:00
|
|
|
BASE_PATH =
|
|
|
|
ifneq ($(base_path),)
|
|
|
|
BASE_PATH = $(base_path)
|
|
|
|
else
|
|
|
|
BASE_PATH = ../..
|
|
|
|
endif
|
|
|
|
|
|
|
|
ACL_PATH = $(BASE_PATH)
|
2014-01-19 23:59:13 +08:00
|
|
|
ACL_INC = $(ACL_PATH)/include
|
|
|
|
ACL_LIB = $(ACL_PATH)/lib
|
|
|
|
|
|
|
|
EXTLIBS =
|
2014-11-30 21:15:35 +08:00
|
|
|
#CFLAGS += -I$(ACL_INC) -I$(PROTO_INC)
|
2017-03-25 23:05:44 +08:00
|
|
|
#LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -lacl $(EXTLIBS) $(SYSLIB)
|
2014-11-30 21:15:35 +08:00
|
|
|
CFLAGS += -I$(ACL_INC)
|
2017-03-25 23:05:44 +08:00
|
|
|
LDFLAGS = -L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
2014-11-30 21:15:35 +08:00
|
|
|
|
2014-01-19 23:59:13 +08:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
OUT_PATH = .
|
|
|
|
OBJ_PATH = $(OUT_PATH)
|
|
|
|
|
|
|
|
#Project's objs
|
|
|
|
SRC = $(wildcard *.cpp)
|
|
|
|
OBJ = $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(notdir $(SRC)))
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
.PHONY = all clean
|
|
|
|
PROG =
|
|
|
|
|
|
|
|
COMPILE = $(CC) $(CFLAGS)
|
|
|
|
|
|
|
|
# -Wl,-rpath,$(ACL_LIB) -Wl,-rpath,$(PROTO_LIB) -o $(OBJ_PATH)/$(PROG)
|
|
|
|
all: RM $(OBJ)
|
|
|
|
$(CC) $(OBJ) $(LDFLAGS) -o $(OBJ_PATH)/$(PROG)
|
|
|
|
@echo ""
|
|
|
|
@echo "All ok! Output:$(PROG)"
|
|
|
|
@echo ""
|
|
|
|
$(OBJ_PATH)/%.o: %.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
|
|
|
RM:
|
|
|
|
rm -f $(PROG)
|
|
|
|
clean:
|
|
|
|
rm -f $(PROG)
|
|
|
|
rm -f $(OBJ)
|
|
|
|
###########################################################
|