diff --git a/.gitignore b/.gitignore index 238e9cb..5d12d15 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,5 @@ parsertrace parsertrace_g *.mk *.Makefile -*.so +*.so.* *.a diff --git a/Makefile b/Makefile index 64e5c2f..02182b1 100644 --- 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_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA) CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA) CFLAGS_LIB = $(CFLAGS_FAST) -fPIC +LDFLAGS_LIB = $(LDFLAGS) -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 @@ libhttp_parser.o: http_parser.c http_parser.h Makefile $(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 @@ tags: http_parser.c http_parser.h test.c 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 diff --git a/http_parser.h b/http_parser.h index f7030c4..f624f86 100644 --- 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