mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-14 17:00:52 +08:00
114 lines
2.6 KiB
Makefile
114 lines
2.6 KiB
Makefile
CC = g++
|
|
|
|
CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \
|
|
-Wno-long-long \
|
|
-Wpointer-arith -Werror -O3 \
|
|
-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_USE_FAST_MACRO
|
|
|
|
#-Waggregate-return
|
|
###########################################################
|
|
#Check system:
|
|
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
|
|
SYSLIB = -lpthread
|
|
CHECKSYSRES = @echo "Unknow system type!";exit 1
|
|
OSNAME = $(shell uname -sm)
|
|
UNIXNAME = $(OSNAME)
|
|
RPATH =
|
|
|
|
ifeq ($(CC),)
|
|
CC = gcc
|
|
endif
|
|
|
|
OS_ENV=$(shell uname -a)
|
|
ifeq ($(findstring WSL, $(OS_ENV)), WSL)
|
|
SYSLIB += -liconv
|
|
endif
|
|
|
|
ifeq ($(findstring ubuntu, $(OS_ENV)), ubuntu)
|
|
SYSLIB += -liconv
|
|
endif
|
|
|
|
# For FreeBSD
|
|
ifeq ($(findstring FreeBSD, $(OSNAME)), FreeBSD)
|
|
ifeq ($(findstring gcc, $(CC)), gcc)
|
|
CFLAGS += -Wstrict-prototypes
|
|
endif
|
|
CFLAGS += -DFREEBSD -D_REENTRANT -Wshadow
|
|
SYSLIB = -lcrypt -lpthread
|
|
endif
|
|
|
|
#Path for Linux
|
|
ifeq ($(findstring Linux, $(OSNAME)), Linux)
|
|
ifeq ($CC, "gcc")
|
|
CFLAGS += -Wstrict-prototypes
|
|
endif
|
|
ifeq ($(findstring i686, $(OSNAME)), i686)
|
|
RPATH = linux32
|
|
endif
|
|
ifeq ($(findstring x86_64, $(OSNAME)), x86_64)
|
|
RPATH = linux64
|
|
endif
|
|
CFLAGS += -DLINUX2 -D_REENTRANT -Wshadow
|
|
endif
|
|
|
|
#Path for SunOS
|
|
ifeq ($(findstring SunOS, $(OSNAME)), SunOS)
|
|
ifeq ($(findstring 86, $(OSNAME)), 86)
|
|
SYSLIB += -lsocket -lnsl -lrt
|
|
endif
|
|
ifeq ($(findstring sun4u, $(OSNAME)), 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, $(OSNAME)), HP-UX)
|
|
ifeq ($CC, "gcc")
|
|
CFLAGS += -Wstrict-prototypes
|
|
endif
|
|
CFLAGS += -DHP_UX -DHPUX11 -Wshadow
|
|
PLAT_NAME=hp-ux
|
|
endif
|
|
|
|
#Find system type.
|
|
ifneq ($(SYSPATH),)
|
|
CHECKSYSRES = @echo "System is $(shell uname -sm)"
|
|
endif
|
|
###########################################################
|
|
|
|
CFLAGS += -I. -I../../../include -I../../../../lib_acl/include -I../../../../lib_protocol/include
|
|
EXTLIBS =
|
|
LDFLAGS = -L../../../lib -l_acl_cpp -L../../../../lib_protocol/lib -l_protocol -L../../../../lib_acl/lib -l_acl \
|
|
-L../../../../lib/$(RPATH) $(EXTLIBS) $(SYSLIB)
|
|
|
|
COMPILE = $(CC) $(CFLAGS)
|
|
LINK = $(CC) $(OBJ) $(LDFLAGS)
|
|
###########################################################
|
|
OBJ_PATH = .
|
|
|
|
#Project's objs
|
|
SRC = $(wildcard *.cpp) $(UTIL)
|
|
OBJ = $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(notdir $(SRC)))
|
|
|
|
$(OBJ_PATH)/%.o: %.cpp
|
|
$(COMPILE) $< -o $@
|
|
$(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)
|
|
###########################################################
|