Description: set SONAME in shared object file Author: Ben Noordhuis Bug: https://github.com/joyent/http-parser/issues/151 Origin: https://github.com/joyent/http-parser/commit/1b96c76.patch Last-Update: 2013-06-13 --- .gitignore | 2 +- Makefile | 34 ++++++++++++++++++++++++++++++++-- http_parser.h | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) --- a/Makefile +++ b/Makefile @@ -1,3 +1,26 @@ +# Copyright Joyent, Inc. and other Node contributors. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') +SONAME ?= libhttp_parser.so.2.1 + CC?=gcc AR?=ar @@ -12,6 +35,13 @@ CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA) CFLAGS_LIB = $(CFLAGS_FAST) -fPIC +LDFLAGS_LIB = -shared + +ifneq (darwin,$(PLATFORM)) +# TODO(bnoordhuis) The native SunOS linker expects -h rather than -soname... +LDFLAGS_LIB += -Wl,-soname=$(SONAME) +endif + test: test_g test_fast ./test_g ./test_fast @@ -44,7 +74,7 @@ $(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o libhttp_parser.o library: libhttp_parser.o - $(CC) -shared -o libhttp_parser.so libhttp_parser.o + $(CC) $(LDFLAGS_LIB) -o $(SONAME) $< package: http_parser.o $(AR) rcs libhttp_parser.a http_parser.o @@ -66,7 +96,7 @@ clean: rm -f *.o *.a tags test test_fast test_g \ - http_parser.tar libhttp_parser.so \ + http_parser.tar libhttp_parser.so.* \ url_parser url_parser_g parsertrace parsertrace_g contrib/url_parser.c: http_parser.h --- a/http_parser.h +++ b/http_parser.h @@ -24,6 +24,7 @@ extern "C" { #endif +/* Also update SONAME in the Makefile whenever you change these. */ #define HTTP_PARSER_VERSION_MAJOR 2 #define HTTP_PARSER_VERSION_MINOR 1