2017-06-13 21:56:56 +08:00
|
|
|
CC = g++
|
|
|
|
|
2017-07-17 10:10:46 +08:00
|
|
|
CFLAGS = -c -g -W -Wall -Wcast-qual \
|
2017-06-13 21:56:56 +08:00
|
|
|
-Wno-long-long \
|
|
|
|
-Wpointer-arith -Werror -Wshadow -O3 \
|
|
|
|
-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_USE_FAST_MACRO
|
2017-07-17 10:10:46 +08:00
|
|
|
#-Wcast-align
|
2017-06-13 21:56:56 +08:00
|
|
|
###########################################################
|
|
|
|
#Check system:
|
|
|
|
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
|
|
|
|
SYSLIB = -lpthread -lz
|
|
|
|
CHECKSYSRES = @echo "Unknow system type!";exit 1
|
2017-07-31 13:51:34 +08:00
|
|
|
OSNAME = $(shell uname -s)
|
|
|
|
OSTYPE = $(shell uname -m)
|
2017-06-13 21:56:56 +08:00
|
|
|
|
|
|
|
ifeq ($(CC),)
|
|
|
|
CC = gcc
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For FreeBSD
|
2017-07-31 13:51:34 +08:00
|
|
|
ifeq ($(findstring FreeBSD, $(OSNAME)), FreeBSD)
|
2017-06-13 21:56:56 +08:00
|
|
|
ifeq ($(findstring gcc, $(CC)), gcc)
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
CFLAGS += -DFREEBSD -D_REENTRANT
|
|
|
|
SYSLIB = -lcrypt -lpthread
|
2017-07-17 17:53:56 +08:00
|
|
|
RPATH = freebsd
|
2017-06-13 21:56:56 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# For Darwin
|
2017-07-31 13:51:34 +08:00
|
|
|
ifeq ($(findstring Darwin, $(OSNAME)), Darwin)
|
2017-06-13 21:56:56 +08:00
|
|
|
CFLAGS += -DMACOSX -Wno-invalid-source-encoding \
|
|
|
|
-Wno-extended-offsetof
|
|
|
|
UNIXTYPE = MACOSX
|
2017-07-17 17:53:56 +08:00
|
|
|
RPATH = macos
|
2017-06-13 21:56:56 +08:00
|
|
|
SYSLIB += -liconv -rdynamic
|
|
|
|
endif
|
|
|
|
|
|
|
|
#Path for Linux
|
2017-07-31 13:51:34 +08:00
|
|
|
ifeq ($(findstring Linux, $(OSNAME)), Linux)
|
|
|
|
ifeq ($(findstring i686, $(OSTYPE)), i686)
|
|
|
|
RPATH = linux32
|
|
|
|
endif
|
|
|
|
ifeq ($(findstring x86_64, $(OSTYPE)), x86_64)
|
|
|
|
RPATH = linux64
|
|
|
|
endif
|
2017-06-13 21:56:56 +08:00
|
|
|
ifeq ($CC, "gcc")
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
|
|
|
CFLAGS += -DLINUX2 -D_REENTRANT
|
|
|
|
SYSLIB += -lcrypt
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For MINGW
|
2017-07-31 13:51:34 +08:00
|
|
|
ifeq ($(findstring MINGW, $(OSNAME)), MINGW)
|
2017-06-13 21:56:56 +08:00
|
|
|
SYSLIB = -lpthread-2 -liconv -lz
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
2017-07-17 17:53:56 +08:00
|
|
|
RPATH = mingw
|
2017-06-13 21:56:56 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# For MSYS
|
2017-07-31 13:51:34 +08:00
|
|
|
ifeq ($(findstring MSYS, $(OSNAME)), MSYS)
|
2017-06-13 21:56:56 +08:00
|
|
|
SYSLIB = -lpthread-2 -liconv -lz
|
|
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
|
|
UNIXTYPE = LINUX
|
2017-07-17 17:53:56 +08:00
|
|
|
RPATH = msys
|
2017-06-13 21:56:56 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
#Path for SunOS
|
2017-07-31 13:51:34 +08:00
|
|
|
ifeq ($(findstring SunOS, $(OSNAME)), SunOS)
|
|
|
|
ifeq ($(findstring 86, $(OSTYPE)), 86)
|
2017-06-13 21:56:56 +08:00
|
|
|
SYSLIB += -lsocket -lnsl -lrt
|
|
|
|
endif
|
2017-07-31 13:51:34 +08:00
|
|
|
ifeq ($(findstring sun4u, $(OSTYPE)), sun4u)
|
2017-06-13 21:56:56 +08:00
|
|
|
SYSLIB += -lsocket -lnsl -lrt
|
|
|
|
endif
|
|
|
|
ifeq ($CC, "gcc")
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
endif
|
2017-07-17 17:53:56 +08:00
|
|
|
RPATH = sunos5_x86
|
2017-06-13 21:56:56 +08:00
|
|
|
CFLAGS += -DSUNOS5 -D_REENTRANT
|
|
|
|
endif
|
|
|
|
|
|
|
|
#Path for HP-UX
|
2017-07-31 13:51:34 +08:00
|
|
|
ifeq ($(findstring HP-UX, $(OSNAME)), HP-UX)
|
2017-06-13 21:56:56 +08:00
|
|
|
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
|
|
|
|
###########################################################
|
|
|
|
|
2017-06-14 17:41:12 +08:00
|
|
|
ACL_PATH = ../../..
|
|
|
|
|
|
|
|
CFLAGS += -I. \
|
|
|
|
-I$(ACL_PATH)/lib_acl/include \
|
|
|
|
-I$(ACL_PATH)/lib_acl_cpp/include \
|
|
|
|
-I$(ACL_PATH)/lib_protocol/include
|
|
|
|
|
|
|
|
LDFLAGS = -L$(ACL_PATH)/lib_acl_cpp/lib -lacl_cpp \
|
|
|
|
-L$(ACL_PATH)/lib_protocol/lib -lprotocol \
|
|
|
|
-L$(ACL_PATH)/lib_acl/lib -lacl $(SYSLIB)
|
2017-06-13 21:56:56 +08:00
|
|
|
|
|
|
|
COMPILE = $(CC) $(CFLAGS)
|
|
|
|
LINK = $(CC) $(OBJ) $(LDFLAGS)
|
|
|
|
###########################################################
|
|
|
|
OBJ_PATH = ./debug
|
|
|
|
|
|
|
|
$(shell mkdir -p $(OBJ_PATH))
|
|
|
|
|
|
|
|
#Project's objs
|
2017-06-16 17:00:49 +08:00
|
|
|
SRC = $(wildcard *.cpp) $(wildcard master/*.cpp) $(wildcard trigger/*.cpp) \
|
|
|
|
$(wildcard manage/*.cpp) $(wildcard manage/action/*.cpp) \
|
|
|
|
$(wildcard json/*.cpp)
|
2017-06-13 21:56:56 +08:00
|
|
|
OBJ = $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(notdir $(SRC)))
|
|
|
|
|
|
|
|
$(OBJ_PATH)/%.o: %.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
|
|
|
$(OBJ_PATH)/%.o: master/%.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
|
|
|
$(OBJ_PATH)/%.o: trigger/%.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
2017-06-16 17:00:49 +08:00
|
|
|
$(OBJ_PATH)/%.o: json/%.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
2017-06-14 17:41:12 +08:00
|
|
|
$(OBJ_PATH)/%.o: manage/%.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
2017-06-16 17:00:49 +08:00
|
|
|
$(OBJ_PATH)/%.o: manage/action/%.cpp
|
|
|
|
$(COMPILE) $< -o $@
|
2017-06-13 21:56:56 +08:00
|
|
|
|
|
|
|
.PHONY = all clean
|
|
|
|
all: RM $(OBJ)
|
|
|
|
$(LINK) -o $(PROG)
|
|
|
|
@echo ""
|
|
|
|
@echo "All ok! Output:$(PROG)"
|
|
|
|
@echo ""
|
|
|
|
RM:
|
|
|
|
rm -f $(PROG)
|
2017-10-10 10:19:59 +08:00
|
|
|
clean cl:
|
2017-06-13 21:56:56 +08:00
|
|
|
rm -f $(PROG)
|
|
|
|
rm -f $(OBJ)
|
|
|
|
rebuild rb: clean all
|
2017-07-31 13:51:34 +08:00
|
|
|
install:
|
2017-07-31 14:10:40 +08:00
|
|
|
@mkdir -p ../../../dist/master/libexec/$(RPATH)
|
|
|
|
@mkdir -p ../../../dist/master/conf
|
2017-07-31 13:51:34 +08:00
|
|
|
cp $(PROG) ../../../dist/master/libexec/$(RPATH)/
|
2017-11-16 11:37:57 +08:00
|
|
|
cp main.cf ../../../dist/master/conf/
|
2017-06-13 21:56:56 +08:00
|
|
|
###########################################################
|