diff options
| author | Mina Naguib <mina.git@naguib.ca> | 2010-06-03 11:33:54 -0400 | 
|---|---|---|
| committer | Mina Naguib <mina.git@naguib.ca> | 2010-06-03 11:33:54 -0400 | 
| commit | 857c9212d31f4487b570c8adef15ca37a755a1b5 (patch) | |
| tree | 619ec9ef4a238dbc02ff037ec5a6a94c0cefcdba | |
| parent | 7302a5ec69b498f4f04beb4534f6ba33c7bc38be (diff) | |
| download | hiredict-857c9212d31f4487b570c8adef15ca37a755a1b5.tar.xz | |
Build a shared library
| -rw-r--r-- | .gitignore | 6 | ||||
| -rw-r--r-- | Makefile | 39 | 
2 files changed, 29 insertions, 16 deletions
| @@ -1 +1,5 @@ -*.o +/hiredis-test +/hiredis-example +/*.o +/*.so +/*.dylib @@ -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 +  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) -Wall -W -Wwrite-strings $(ARCH) $(PROF) +  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  - -OBJ = anet.o hiredis.o sds.o example.o -TESTOBJ = anet.o hiredis.o sds.o test.o +DEBUG?= -g -ggdb  -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} + +# Binaries: +hiredis-%: %.o ${DYLIBNAME} +	$(CC) -o $@ $(CCOPT) $(DEBUG) -L. -l hiredis -Wl,-rpath,. $< -hiredis-test: $(TESTOBJ) -	$(CC) -o $(TESTNAME) $(CCOPT) $(DEBUG) $(TESTOBJ) +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 | 
