acl/unit_test/Makefile

149 lines
3.2 KiB
Makefile
Raw Normal View History

SHELL = /bin/sh
2015-02-07 23:44:41 +08:00
#CC = gcc
#CC = g++
2015-02-07 23:44:41 +08:00
CC = ${MY_ENV_CC}
AR = ar
ARFL = rv
#ARFL = cru
RANLIB = ranlib
2015-01-06 23:24:02 +08:00
CFLAGS = -c -g -W \
-O3 \
-Wall \
-Werror \
-Wshadow \
-Wcast-qual \
2015-01-05 17:25:09 +08:00
-D_REENTRANT \
-D_POSIX_PTHREAD_SEMANTICS \
-D_USE_FAST_MACRO \
-Wpointer-arith \
-Waggregate-return \
-Wmissing-prototypes \
2015-02-08 00:18:29 +08:00
-Wno-long-long
#-Wno-invalid-source-encoding
2015-01-05 17:25:09 +08:00
# -Wcast-align
###########################################################
#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),)
CC = gcc
endif
2015-01-06 23:24:02 +08:00
ifeq ($(findstring gcc, $(CC)), gcc)
CFLAGS += -Wstrict-prototypes
endif
# For FreeBSD
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
2015-01-06 23:24:02 +08:00
CFLAGS += -DFREEBSD -pedantic
SYSLIB = -lcrypt -lpthread
endif
2015-01-05 17:25:09 +08:00
# For Darwin
2015-01-06 23:24:02 +08:00
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
# CC += -arch x86_64 -arch arm64
CFLAGS += -DMACOSX -Wno-invalid-source-encoding -Wno-invalid-offsetof
2015-01-06 23:24:02 +08:00
UNIXTYPE = MACOSX
2015-01-05 17:25:09 +08:00
endif
#Path for Linux
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
2015-01-06 23:24:02 +08:00
CFLAGS += -DLINUX2 -pedantic
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
2015-01-06 23:24:02 +08:00
CFLAGS += -DSUNOS5 -pedantic
endif
#Path for HP-UX
ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX)
CFLAGS += -DHP_UX -DHPUX11
PLAT_NAME=hp-ux
endif
#Find system type.
ifneq ($(SYSPATH),)
CHECKSYSRES = @echo "System is $(shell uname -sm)"
endif
###########################################################
ACL_HOME = ../lib_acl
ACL_INC_PATH = $(ACL_HOME)/include
ACL_LIB_PATH = $(ACL_HOME)/lib
CFLAGS += -I$(ACL_INC_PATH)
LINK_LIBS = -L$(ACL_LIB_PATH) -lacl $(SYSLIB)
###########################################################
OUT_PATH = .
OBJ_PATH_DST = $(OUT_PATH)/debug
PROG_PATH_DST = $(OUT_PATH)/bin
BASE_PATH = .
SRC_PATH_SRC = $(BASE_PATH)
INC_COMPILE = -I. -I./stdlib -I./net -I./unit_test
CFLAGS += $(INC_COMPILE)
#Project's source
BASE_SRC = $(wildcard *.c)
STDLIB_SRC = $(wildcard $(SRC_PATH_SRC)/stdlib/*.c)
UNIT_TEST_SRC = $(wildcard $(SRC_PATH_SRC)/unit_test/*.c)
NET_SRC = $(wildcard $(SRC_PATH_SRC)/net/*.c)
SOURCES_SRC = $(BASE_SRC) $(STDLIB_SRC) $(UNIT_TEST_SRC) $(NET_SRC)
#Project's obj
OBJS_DST = $(patsubst %.c, $(OBJ_PATH_DST)/%.o, $(notdir $(SOURCES_SRC)))
###########################################################
.PHONY = all clean myecho
PROG_NAME = test_main
COMPILE = $(CC) $(CFLAGS)
LINK = $(CC) -o $(PROG_PATH_DST)/$(PROG_NAME) $(OBJS_DST) $(LINK_LIBS)
all: $(PROG_NAME)
$(PROG_NAME): $(OBJS_DST)
$(LINK)
$(OBJ_PATH_DST)/%.o: %.c *.h
$(COMPILE) $< -o $@
$(OBJ_PATH_DST)/%.o: stdlib/%.c stdlib/*.h
$(COMPILE) $< -o $@
$(OBJ_PATH_DST)/%.o: unit_test/%.c unit_test/*.h
$(COMPILE) $< -o $@
$(OBJ_PATH_DST)/%.o: net/%.c net/*.h
$(COMPILE) $< -o $@
clean:
rm -f $(PROG_PATH_DST)/$(PROG_NAME)
rm -f $(OBJS_DST)
myecho:
@(echo "STDLIB_SRC: $(STDLIB_SRC)")
@(echo "UNIT_TEST_SRC: $(UNIT_TEST_SRC)")
@(echo "SOURCES_SRC: $(SOURCES_SRC)")
@(echo "OBJS_DST: $(OBJS_DST)")
@(echo "OBJ_PATH_DST: $(OBJ_PATH_DST)")