2014-03-03 17:28:08 +00:00
|
|
|
include ../../libr/config.mk
|
2015-10-09 19:24:15 +00:00
|
|
|
include ../../mk/platform.mk
|
2016-04-26 23:52:35 +00:00
|
|
|
include ../../mk/$(COMPILER).mk
|
2015-06-18 00:14:24 +00:00
|
|
|
include ../../shlr/zip/deps.mk
|
2014-03-03 17:28:08 +00:00
|
|
|
EDITOR?=vim
|
|
|
|
CC?=gcc
|
2017-05-09 12:25:57 +00:00
|
|
|
CC_AR?=ar
|
|
|
|
AR?=$(CC_AR)
|
2014-03-03 17:57:21 +00:00
|
|
|
RANLIB?=ranlib
|
2014-03-03 17:28:08 +00:00
|
|
|
LIBNAME=libgdbr
|
|
|
|
LIBFILE=$(LIBNAME).$(EXT_SO)
|
2015-10-09 19:24:15 +00:00
|
|
|
CFLAGS+=-I$(LIBR)/include $(PIC_CFLAGS)
|
2014-07-16 19:35:29 +00:00
|
|
|
CFLAGS+=-Iinclude -I${LIBR}/include
|
2014-03-03 17:28:08 +00:00
|
|
|
MAJOR=0
|
|
|
|
MINOR=1
|
|
|
|
LD=$(CC)
|
2017-05-09 12:25:57 +00:00
|
|
|
ifeq ($(LD),cccl)
|
|
|
|
LDFLAGS+=-L${LIBR}/socket -llibr_socket
|
|
|
|
LDFLAGS+=-L${LIBR}/util -llibr_util
|
|
|
|
EXT_AR?=lib
|
|
|
|
else
|
2015-04-14 15:11:52 +00:00
|
|
|
LDFLAGS+=-L${LIBR}/socket -lr_socket
|
|
|
|
LDFLAGS+=-L${LIBR}/util -lr_util
|
2017-05-09 12:25:57 +00:00
|
|
|
EXT_AR?=a
|
|
|
|
endif
|
2016-04-26 23:52:35 +00:00
|
|
|
|
2016-06-06 14:20:03 +00:00
|
|
|
ifeq (${OSTYPE},darwin)
|
2016-04-26 23:52:35 +00:00
|
|
|
LDFLAGS_SHARED=-dynamiclib
|
|
|
|
else
|
|
|
|
LDFLAGS_SHARED=-shared
|
|
|
|
endif
|
|
|
|
|
2014-03-03 17:57:21 +00:00
|
|
|
#OSTYPE=windows
|
|
|
|
include ../../libr/socket/deps.mk
|
2014-02-21 14:19:50 +00:00
|
|
|
|
|
|
|
# Test variables
|
2014-03-03 17:28:08 +00:00
|
|
|
TEST_D= $(PWD)/test
|
|
|
|
BIN=$(PWD)/bin
|
|
|
|
UNIT_TEST=$(TEST_D)/unit.c
|
|
|
|
CLIENT=$(TEST_D)/client.c
|
2014-02-21 14:19:50 +00:00
|
|
|
|
2014-03-03 17:28:08 +00:00
|
|
|
PWD=$(shell pwd)
|
2014-03-03 17:57:21 +00:00
|
|
|
TEST=test
|
|
|
|
LIB=lib
|
2014-02-21 14:19:50 +00:00
|
|
|
|
|
|
|
TEST_INCLUDES += $(INCLUDES) -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
|
|
|
|
|
2014-03-07 01:00:27 +00:00
|
|
|
SRC_D=src
|
2017-05-07 09:53:17 +00:00
|
|
|
SRC_C=$(wildcard $(SRC_D)/*.c) $(wildcard $(SRC_D)/*/*.c)
|
2014-03-03 17:28:08 +00:00
|
|
|
SRC_O=$(SRC_C:.c=.o)
|
2014-02-21 14:19:50 +00:00
|
|
|
|
2014-03-03 17:28:08 +00:00
|
|
|
TEST_C=$(wildcard $(TEST_D)/*.c)
|
|
|
|
TEST_O=$(TEST_C:.c=.o)
|
2014-02-21 14:19:50 +00:00
|
|
|
|
2017-05-09 12:25:57 +00:00
|
|
|
all: $(LIB)/$(LIBNAME).${EXT_AR}
|
2014-03-07 01:00:27 +00:00
|
|
|
# make
|
2014-02-21 14:19:50 +00:00
|
|
|
|
|
|
|
default: make
|
|
|
|
|
|
|
|
prepare:
|
|
|
|
mkdir -p $(LIB)
|
|
|
|
|
2014-03-07 01:00:27 +00:00
|
|
|
$(LIB):
|
|
|
|
mkdir -p $(LIB)
|
|
|
|
|
2017-05-09 12:25:57 +00:00
|
|
|
$(LIB)/$(LIBNAME).${EXT_AR}: $(LIB) $(SRC_O)
|
2018-01-10 15:52:50 +00:00
|
|
|
ifeq ($(WITHPIC),1)
|
2016-04-26 23:52:35 +00:00
|
|
|
$(LD) $(PIC_CFLAGS) $(LDFLAGS_SHARED) -o $(LIB)/$(LIBFILE) $(CFLAGS) $(SRC_O) $(LDFLAGS) $(LINK)
|
2018-01-10 15:52:50 +00:00
|
|
|
endif
|
2017-05-09 12:25:57 +00:00
|
|
|
$(AR) rvs $(LIB)/$(LIBNAME).${EXT_AR} $(SRC_O)
|
2014-03-03 17:57:21 +00:00
|
|
|
# required for solaris and w32
|
2017-05-09 12:25:57 +00:00
|
|
|
$(RANLIB) $(LIB)/$(LIBNAME).${EXT_AR}
|
2014-02-21 14:19:50 +00:00
|
|
|
|
|
|
|
clean:
|
2014-03-03 17:57:21 +00:00
|
|
|
-rm -f $(SRC_O)
|
|
|
|
-rm -rf lib
|
2014-02-21 14:19:50 +00:00
|
|
|
|
2017-05-07 09:53:17 +00:00
|
|
|
unit: lib
|
2014-02-21 14:19:50 +00:00
|
|
|
$(CC) $(CFLAGS) $(TEST_INCLUDES) -c $(UNIT_TEST) -o $(TEST_D)/unit.o
|
|
|
|
$(LD) $(TEST_D)/unit.o -o $(TEST_D)/unit -L$(LIB) -lgdbr -lglib-2.0
|
|
|
|
|
|
|
|
run_unit: unit
|
|
|
|
LD_LIBRARY_PATH=./lib ./test/unit
|
|
|
|
|
|
|
|
client: lib
|
|
|
|
$(CC) $(CFLAGS) $(INCLUDES) -c $(CLIENT) -o $(TEST_D)/client.o
|
|
|
|
$(LD) $(TEST_D)/client.o -o $(TEST_D)/client -L$(LIB) -lgdbr
|
|
|
|
|
|
|
|
run_test: client
|
2014-03-03 17:28:08 +00:00
|
|
|
rarun2 libpath=./lib program=./test/client
|
2014-02-21 14:19:50 +00:00
|
|
|
|
|
|
|
gdb_test: client
|
2014-03-03 17:28:08 +00:00
|
|
|
rarun2 libpath=./lib system="gdb ./test/client"
|
2014-02-21 14:19:50 +00:00
|
|
|
|
|
|
|
valgrind_test: client
|
2014-03-03 17:28:08 +00:00
|
|
|
rarun2 libpath=./lib system="valgrind --track-origins=yes -v --leak-check=full ./test/client"
|
2014-02-21 14:19:50 +00:00
|
|
|
|
|
|
|
edit:
|
2014-03-03 17:28:08 +00:00
|
|
|
$(EDITOR) -c "args **/*.h **/*.c"
|