Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No local rpath settings #36

Closed
shakthimaan opened this issue Apr 20, 2011 · 3 comments
Closed

No local rpath settings #36

shakthimaan opened this issue Apr 20, 2011 · 3 comments

Comments

@shakthimaan
Copy link

When packaging software, the installed executables will obtain the library paths from the environment. Hence, it is not recommended to use a local rpath. The patch below removes hard-coding of the same, and also creates versioned shared libraries.

diff -up antirez-hiredis-0fbfa45/Makefile.fix antirez-hiredis-0fbfa45/Makefile
--- antirez-hiredis-0fbfa45/Makefile.fix 2011-04-19 13:06:43.214439002 +0530
+++ antirez-hiredis-0fbfa45/Makefile 2011-04-19 13:12:52.137439004 +0530
@@ -27,9 +27,12 @@ else ifeq ($(uname_S),Darwin)
else
CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wwrite-strings $(ARCH) $(PROF)
CCLINK?=-lm -pthread

  • LDFLAGS?=-L. -Wl,-rpath,.
  • LDFLAGS?=-L.
    DYLIBNAME?=libhiredis.so
  • DYLIB_MAKE_CMD?=gcc -shared -Wl,-soname,${DYLIBNAME} -o ${DYLIBNAME} ${OBJ}
  • VERSION?=1
  • DYLIB_MAKE_CMD?=gcc -shared -Wl,-soname,${DYLIBNAME}.${VERSION} -o ${DYLIBNAME}.${VERSION}.0 ${OBJ}
  • DYLIB_LINK_NAME?=ln -sf ${DYLIBNAME}.${VERSION}.0 ${DYLIBNAME}
  • DYLIB_LINK_VERSION?=ln -sf ${DYLIBNAME}.${VERSION}.0 ${DYLIBNAME}.1
    STLIBNAME?=libhiredis.a
    STLIB_MAKE_CMD?=ar rcs ${STLIBNAME} ${OBJ}
    endif
    @@ -53,6 +56,8 @@ test.o: test.c hiredis.h

${DYLIBNAME}: ${OBJ}
${DYLIB_MAKE_CMD}

  • ${DYLIB_LINK_NAME}
  • ${DYLIB_LINK_VERSION}

${STLIBNAME}: ${OBJ}
${STLIB_MAKE_CMD}

@pietern
Copy link
Contributor

pietern commented Apr 21, 2011

Thanks for sending this as a pull request, much easier to keep track of things :-)

I've removed the rpath flag in 4feec1f. However, I don't agree with the install target: when you're packaging, you a) know the version and b) know where to install the libraries, so why do this as well in the Makefile? When hiredis is compiled and installed from source, the person using it is aware that upgrades overwrite the existing library...

@pietern pietern closed this as completed Apr 21, 2011
@shakthimaan
Copy link
Author

Thanks for removing the rpath! The reasons for the versionto be included are that:

(1) When a new release is made, just the VERSION is increased, and it reflects in your original sources.
(2) We could possibly still have multiple shared libraries installed, and the users can choose which versioned library that they want to use, as against having just libhiredis.so getting overwritten across multiple releases.

You can also refer 3.4 Creating a Shared Library from:

http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN95

@pietern
Copy link
Contributor

pietern commented Apr 22, 2011

Ok, I'm convinced :-). Added this in 81c00aa. Note that I use both the major and minor version in the soname because the API may change between minors (but not between patch versions), in contrary to what I believe the convention is (use only the major version in the soname).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants