Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
857c9212
Commit
857c9212
authored
Jun 03, 2010
by
Mina Naguib
Browse files
Build a shared library
parent
7302a5ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
857c9212
*.o
/hiredis-test
/hiredis-example
/*.o
/*.so
/*.dylib
Makefile
View file @
857c9212
...
@@ -2,25 +2,31 @@
...
@@ -2,25 +2,31 @@
# Copyright (C) 2010 Salvatore Sanfilippo <antirez at gmail dot com>
# Copyright (C) 2010 Salvatore Sanfilippo <antirez at gmail dot com>
# This file is released under the BSD license, see the COPYING file
# 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'
)
uname_S
:=
$(
shell
sh
-c
'uname -s 2>/dev/null || echo not'
)
OPTIMIZATION
?=
-O2
OPTIMIZATION
?=
-O2
ifeq
($(uname_S),SunOS)
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
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
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
CCLINK
?=
-lm
-pthread
DYLIBNAME
?=
libhiredis.so
DYLIB_MAKE_CMD
?=
gcc
-shared
-Wl
,-soname,
${DYLIBNAME}
-o
${DYLIBNAME}
${OBJ}
endif
endif
CCOPT
=
$(CFLAGS)
$(CCLINK)
$(ARCH)
$(PROF)
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
all
:
${DYLIBNAME} ${BINS}
TESTNAME
=
hiredis-test
all
:
hiredis-example hiredis-test
# Deps (use make dep to generate this)
# Deps (use make dep to generate this)
anet.o
:
anet.c fmacros.h anet.h
anet.o
:
anet.c fmacros.h anet.h
...
@@ -30,18 +36,21 @@ hiredis.o: hiredis.c hiredis.h sds.h anet.h
...
@@ -30,18 +36,21 @@ hiredis.o: hiredis.c hiredis.h sds.h anet.h
sds.o
:
sds.c sds.h
sds.o
:
sds.c sds.h
hiredis.o
:
hiredis.c hiredis.h sds.h anet.h
hiredis.o
:
hiredis.c hiredis.h sds.h anet.h
hiredis-example
:
$(OBJ)
${DYLIBNAME}
:
${OBJ}
$(CC)
-o
$(PRGNAME)
$(CCOPT)
$(DEBUG)
$(OBJ)
${DYLIB_MAKE_CMD}
# Binaries:
hiredis-%
:
%.o ${DYLIBNAME}
$(CC)
-o
$@
$(CCOPT)
$(DEBUG)
-L
.
-l
hiredis
-Wl
,-rpath,.
$<
hiredis-test
:
$(TESTOBJ)
test
:
hiredis-test
$(CC)
-o
$(TESTNAME)
$(CCOPT)
$(DEBUG)
$(TESTOBJ)
./hiredis-test
./hiredis-test
.c.o
:
.c.o
:
$(CC)
-c
$(CFLAGS)
$(DEBUG)
$(COMPILE_TIME)
$<
$(CC)
-c
$(CFLAGS)
$(DEBUG)
$(COMPILE_TIME)
$<
clean
:
clean
:
rm
-rf
$
(PRG
NAME
)
$(
TESTNAME
)
*
.o
*
.gcda
*
.gcno
*
.gcov
rm
-rf
$
{DYLIB
NAME
}
$(
BINS
)
*
.o
*
.gcda
*
.gcno
*
.gcov
dep
:
dep
:
$(CC)
-MM
*
.c
$(CC)
-MM
*
.c
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment