Build a shared library
This commit is contained in:
parent
7302a5ec69
commit
857c9212d3
6
.gitignore
vendored
6
.gitignore
vendored
@ -1 +1,5 @@
|
||||
*.o
|
||||
/hiredis-test
|
||||
/hiredis-example
|
||||
/*.o
|
||||
/*.so
|
||||
/*.dylib
|
||||
|
41
Makefile
41
Makefile
@ -2,25 +2,31 @@
|
||||
# Copyright (C) 2010 Salvatore Sanfilippo <antirez at gmail dot com>
|
||||
# This file is released under the BSD license, see the COPYING file
|
||||
|
||||
OBJ = anet.o hiredis.o sds.o
|
||||
BINS = hiredis-example hiredis-test
|
||||
|
||||
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
||||
OPTIMIZATION?=-O2
|
||||
ifeq ($(uname_S),SunOS)
|
||||
CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6
|
||||
CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -D__EXTENSIONS__ -D_XPG6
|
||||
CCLINK?= -ldl -lnsl -lsocket -lm -lpthread
|
||||
else
|
||||
CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -Wwrite-strings $(ARCH) $(PROF)
|
||||
DYLIBNAME?=libhiredis.so
|
||||
DYLIB_MAKE_CMD?=gcc -shared -Wl,-soname,${DYLIBNAME} -o ${DYLIBNAME} ${OBJ}
|
||||
else ifeq ($(uname_S),Darwin)
|
||||
CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wwrite-strings $(ARCH) $(PROF)
|
||||
CCLINK?= -lm -pthread
|
||||
DYLIBNAME?=libhiredis.dylib
|
||||
DYLIB_MAKE_CMD?=libtool -dynamic -o ${DYLIBNAME} -lm ${DEBUG} - ${OBJ}
|
||||
else
|
||||
CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wwrite-strings $(ARCH) $(PROF)
|
||||
CCLINK?= -lm -pthread
|
||||
DYLIBNAME?=libhiredis.so
|
||||
DYLIB_MAKE_CMD?=gcc -shared -Wl,-soname,${DYLIBNAME} -o ${DYLIBNAME} ${OBJ}
|
||||
endif
|
||||
CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
|
||||
DEBUG?= -g -rdynamic -ggdb
|
||||
DEBUG?= -g -ggdb
|
||||
|
||||
OBJ = anet.o hiredis.o sds.o example.o
|
||||
TESTOBJ = anet.o hiredis.o sds.o test.o
|
||||
|
||||
PRGNAME = hiredis-example
|
||||
TESTNAME = hiredis-test
|
||||
|
||||
all: hiredis-example hiredis-test
|
||||
all: ${DYLIBNAME} ${BINS}
|
||||
|
||||
# Deps (use make dep to generate this)
|
||||
anet.o: anet.c fmacros.h anet.h
|
||||
@ -30,18 +36,21 @@ hiredis.o: hiredis.c hiredis.h sds.h anet.h
|
||||
sds.o: sds.c sds.h
|
||||
hiredis.o: hiredis.c hiredis.h sds.h anet.h
|
||||
|
||||
hiredis-example: $(OBJ)
|
||||
$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ)
|
||||
${DYLIBNAME}: ${OBJ}
|
||||
${DYLIB_MAKE_CMD}
|
||||
|
||||
hiredis-test: $(TESTOBJ)
|
||||
$(CC) -o $(TESTNAME) $(CCOPT) $(DEBUG) $(TESTOBJ)
|
||||
# Binaries:
|
||||
hiredis-%: %.o ${DYLIBNAME}
|
||||
$(CC) -o $@ $(CCOPT) $(DEBUG) -L. -l hiredis -Wl,-rpath,. $<
|
||||
|
||||
test: hiredis-test
|
||||
./hiredis-test
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
|
||||
|
||||
clean:
|
||||
rm -rf $(PRGNAME) $(TESTNAME) *.o *.gcda *.gcno *.gcov
|
||||
rm -rf ${DYLIBNAME} $(BINS) *.o *.gcda *.gcno *.gcov
|
||||
|
||||
dep:
|
||||
$(CC) -MM *.c
|
||||
|
Loading…
Reference in New Issue
Block a user