2016-06-11 23:18:06 +08:00
|
|
|
CC = g++
|
|
|
|
|
|
|
|
CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \
|
2023-01-11 10:22:33 +08:00
|
|
|
-Wno-long-long -Wpointer-arith -Werror -Wshadow -O3 \
|
2016-06-11 23:18:06 +08:00
|
|
|
-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_USE_FAST_MACRO
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
#Check system:
|
|
|
|
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
|
|
|
|
SYSLIB = -ldl -lpthread -lz
|
|
|
|
CHECKSYSRES = @echo "Unknow system type!";exit 1
|
|
|
|
UNIXNAME = $(shell uname -sm)
|
|
|
|
OSTYPE = $(shell uname -p)
|
|
|
|
RPATH = linux64
|
|
|
|
|
|
|
|
ifeq ($(CC),)
|
2017-08-09 11:25:10 +08:00
|
|
|
CC = g++
|
|
|
|
endif
|
|
|
|
|
2022-01-28 12:28:21 +08:00
|
|
|
OS_ENV=$(shell uname -a)
|
|
|
|
ifeq ($(findstring WSL, $(OS_ENV)), WSL)
|
|
|
|
SYSLIB += -liconv
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(findstring ubuntu, $(OS_ENV)), ubuntu)
|
|
|
|
SYSLIB += -liconv
|
|
|
|
endif
|
|
|
|
|
2022-01-28 03:37:10 +08:00
|
|
|
ifeq ($(findstring Alpine, $(shell uname -a)), Alpine)
|
|
|
|
SYSLIB += -lucontext
|
|
|
|
endif
|
|
|
|
|
2017-08-09 11:25:10 +08:00
|
|
|
ifeq ($(findstring g++, $(CC)), g++)
|
|
|
|
GCC_VERSION:=$(shell echo `gcc --version|grep ^gcc|cut -d' ' -f3`)
|
|
|
|
GCC_MAJOR:=$(shell echo "$(GCC_VERSION)" | cut -d'.' -f1)
|
|
|
|
GCC_MINOR:=$(shell echo "$(GCC_VERSION)" | cut -d'.' -f2)
|
|
|
|
GCC_VER:=$(shell [ $(GCC_MAJOR) -gt 4 -o \( $(GCC_MAJOR) -eq 4 -a $(GCC_MINOR) -ge 7 \) ] && echo true)
|
|
|
|
ifeq ($(GCC_VER), true)
|
|
|
|
CFLAGS += -std=c++11 -DACL_USE_CPP11
|
|
|
|
endif
|
2016-06-11 23:18:06 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# For FreeBSD
|
|
|
|
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
|
|
|
ifeq ($(findstring gcc, $(CC)), gcc)
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
CFLAGS += -DFREEBSD -D_REENTRANT
|
|
|
|
SYSLIB = -lcrypt -lpthread -lz
|
|
|
|
RPATH = freebsd
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For Darwin
|
|
|
|
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
2022-04-11 19:09:39 +08:00
|
|
|
# CC += -arch x86_64 -arch arm64
|
2016-06-11 23:18:06 +08:00
|
|
|
CFLAGS += -DMACOSX -Wno-invalid-source-encoding \
|
2018-04-17 16:42:26 +08:00
|
|
|
-Wno-invalid-offsetof
|
2016-06-11 23:18:06 +08:00
|
|
|
UNIXTYPE = MACOSX
|
|
|
|
SYSLIB += -liconv -rdynamic
|
|
|
|
RPATH = macos
|
|
|
|
endif
|
|
|
|
|
|
|
|
#Path for Linux
|
|
|
|
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
|
|
|
ifeq ($CC, "gcc")
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
ifeq ($(findstring i686, $(OSTYPE)), i686)
|
|
|
|
RPATH = linux32
|
|
|
|
endif
|
|
|
|
ifeq ($(findstring x86_64, $(OSTYPE)), x86_64)
|
|
|
|
RPATH = linux64
|
|
|
|
endif
|
2022-11-02 22:28:00 +08:00
|
|
|
ifeq ($(HAS_IO_URING), yes)
|
|
|
|
SYSLIB += -luring
|
|
|
|
endif
|
2022-10-27 18:14:15 +08:00
|
|
|
ifeq ($(has_io_uring), yes)
|
|
|
|
SYSLIB += -luring
|
|
|
|
endif
|
2017-02-12 21:39:38 +08:00
|
|
|
# CFLAGS += -DLINUX2 -D_REENTRANT
|
|
|
|
CFLAGS += -D_REENTRANT
|
2023-04-11 15:59:13 +08:00
|
|
|
SYSLIB += -lcrypt -lrt
|
2016-06-11 23:18:06 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
#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
|
|
|
|
RPATH = sunos_x86
|
|
|
|
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
|
|
|
|
|
2022-08-06 20:03:51 +08:00
|
|
|
# For CYGWIN
|
|
|
|
ifeq ($(findstring CYGWIN, $(UNIXNAME)), CYGWIN)
|
|
|
|
SYSLIB = -lpthread -rdynamic
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For MINGW
|
|
|
|
ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW)
|
|
|
|
SYSLIB = -lpthread -rdynamic
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For MSYS
|
|
|
|
ifeq ($(findstring MSYS, $(UNIXNAME)), MSYS)
|
|
|
|
SYSLIB = -lpthread -rdynamic
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
|
|
|
endif
|
|
|
|
|
2016-06-11 23:18:06 +08:00
|
|
|
#Find system type.
|
|
|
|
ifneq ($(SYSPATH),)
|
|
|
|
CHECKSYSRES = @echo "System is $(shell uname -sm)"
|
|
|
|
endif
|
|
|
|
###########################################################
|
|
|
|
|
2016-06-30 22:20:30 +08:00
|
|
|
CFLAGS += -I.. -I../../../lib_acl/include -I../../../lib_protocol/include -I../../../lib_acl_cpp/include \
|
2016-06-24 10:39:05 +08:00
|
|
|
-I../../../lib_fiber/c/include -I../../../lib_fiber/cpp/include
|
2016-06-11 23:18:06 +08:00
|
|
|
EXTLIBS =
|
2017-12-20 23:01:58 +08:00
|
|
|
LDFLAGS = -L../../../lib_fiber/lib -lfiber_cpp \
|
2017-03-25 23:05:44 +08:00
|
|
|
-L../../../lib_acl_cpp/lib -lacl_cpp \
|
|
|
|
-L../../../lib_protocol/lib -lprotocol \
|
|
|
|
-L../../../lib_acl/lib -lacl \
|
2017-12-20 23:01:58 +08:00
|
|
|
-lfiber $(EXTLIBS) $(SYSLIB)
|
2016-06-11 23:18:06 +08:00
|
|
|
|
|
|
|
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)
|
2016-07-18 22:07:31 +08:00
|
|
|
clean cl:
|
2016-06-11 23:18:06 +08:00
|
|
|
rm -f $(PROG)
|
|
|
|
rm -f $(OBJ)
|
2016-07-18 22:07:31 +08:00
|
|
|
|
|
|
|
rebuild rb: clean all
|
|
|
|
|
2016-06-11 23:18:06 +08:00
|
|
|
install:
|
|
|
|
cp $(PROG) ../../../dist/master/libexec/$(RPATH)/
|
|
|
|
cp $(PROG).cf ../../../dist/master/conf/service/
|
|
|
|
###########################################################
|