acl/unit_test/Makefile.glib
2017-03-25 23:05:44 +08:00

139 lines
3.3 KiB
Makefile

SHELL = /bin/sh
CC = gcc
#CC = g++
#CC = ${MY_ENV_CC}
AR = ar
ARFL = rv
#ARFL = cru
RANLIB = ranlib
CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \
-Waggregate-return -Wmissing-prototypes \
-Wpointer-arith -Werror -Wshadow -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 = -lpthread
CHECKSYSRES = @echo "Unknow system type!";exit 1
UNIXNAME = $(shell uname -sm)
ifeq ($(CC),)
CC = gcc
endif
# For FreeBSD
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
ifeq ($(findstring gcc, $(CC)), gcc)
CFLAGS += -Wstrict-prototypes
endif
CFLAGS += -DFREEBSD -D_REENTRANT -pedantic
SYSLIB = -lcrypt -lpthread
endif
#Path for Linux
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
ifeq ($CC, "gcc")
CFLAGS += -Wstrict-prototypes
endif
CFLAGS += -DLINUX2 -D_REENTRANT -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
CFLAGS += -DSUNOS5 -D_REENTRANT -pedantic
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
#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 -L/opt/messenger/lib/glib/linux/lib -lglib-2.0 $(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)
LD_RUN_PATH=-Wl,-rpath,/opt/messenger/lib/glib/linux/lib,-rpath,/opt/messenger/lib/mysql/linux/lib
LINK = $(CC) -o $(PROG_PATH_DST)/$(PROG_NAME) $(OBJS_DST) $(LINK_LIBS) $(LD_RUN_PATH)
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)")