mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-16 01:40:52 +08:00
119 lines
2.3 KiB
Makefile
119 lines
2.3 KiB
Makefile
SHELL = /bin/sh
|
|
CC = $(MY_ENV_CC)
|
|
#CC = gcc
|
|
|
|
CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \
|
|
-Waggregate-return -Wmissing-prototypes \
|
|
-Wpointer-arith -Werror -Wshadow -pedantic -O2 \
|
|
-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_USE_FAST_MACRO \
|
|
-Wno-long-long
|
|
###########################################################
|
|
#Check system:
|
|
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
|
|
SYSLIB =
|
|
CHECKSYSRES = @echo "Unknow system type!";exit 1
|
|
UNIXNAME = $(shell uname -sm)
|
|
|
|
ifeq ($(CC),)
|
|
CC = gcc
|
|
endif
|
|
|
|
ifeq ($(findstring gcc, $(CC)), gcc)
|
|
CFLAGS += -Wstrict-prototypes
|
|
endif
|
|
|
|
# For Darwin
|
|
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
|
CFLAGS += -DMACOSX
|
|
endif
|
|
|
|
# For FreeBSD
|
|
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
|
CFLAGS += -DFREEBSD -D_REENTRANT -pedantic
|
|
SYSLIB = -lpthread
|
|
endif
|
|
|
|
#Path for Linux
|
|
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
|
CFLAGS += -DLINUX2
|
|
SYSLIB = -lpthread
|
|
endif
|
|
|
|
# For MINGW
|
|
ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW)
|
|
SYSLIB = -lpthread-2
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
UNIXTYPE = LINUX
|
|
endif
|
|
|
|
# For MSYS
|
|
ifeq ($(findstring MSYS, $(UNIXNAME)), MSYS)
|
|
SYSLIB = -lpthread-2
|
|
CFLAGS += -DLINUX2 -DMINGW
|
|
UNIXTYPE = LINUX
|
|
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
|
|
CFLAGS += -DSUNOS5
|
|
endif
|
|
|
|
#Path for HP-UX
|
|
ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX)
|
|
SYSLIB = -lpthread
|
|
CFLAGS += -DHP_UX -DHPUX11
|
|
PLAT_NAME=hp-ux
|
|
endif
|
|
|
|
#Find system type.
|
|
ifneq ($(SYSPATH),)
|
|
CHECKSYSRES = @echo "System is $(shell uname -sm)"
|
|
endif
|
|
###########################################################
|
|
|
|
ACL_PATH = ../../../../lib_acl
|
|
ACL_LIB = $(ACL_PATH)/lib
|
|
ACL_INC = $(ACL_PATH)/include
|
|
|
|
CFLAGS += -I. -I$(ACL_INC)
|
|
COMPILE = $(CC) $(CFLAGS)
|
|
|
|
EXTLIBS =
|
|
LDFLAGS = -L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
|
LINKS = $(CC) -o $(PROG) $(OBJS) $(LDFLAGS)
|
|
|
|
OUT_PATH = ./
|
|
OBJ_PATH = $(OUT_PATH)
|
|
|
|
#Project's objs
|
|
SRCS = $(wildcard *.c)
|
|
OBJS = $(patsubst %.c,$(OBJ_PATH)%.o,$(SRCS))
|
|
|
|
###########################################################
|
|
|
|
.PHONY = all RM clean
|
|
|
|
PROG =
|
|
|
|
all: RM $(PROG)
|
|
|
|
RM:
|
|
rm -f $(PROG)
|
|
|
|
all: $(OBJS)
|
|
$(LINKS)
|
|
|
|
$(OBJ_PATH)%.o: %.c *.h
|
|
$(COMPILE) -o $@ $<
|
|
|
|
clean:
|
|
rm -f $(OBJS) $(PROG)
|
|
|
|
rebuild: clean all
|