mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-09 21:53:24 +00:00
Merge pull request #254516 from Strum355/http-parser-static
http-parser: fix copying outputs for static build
This commit is contained in:
commit
e4d8cfb2b1
@ -1,30 +0,0 @@
|
||||
diff -Naur http-parser-2.1-orig/http_parser.gyp http-parser-2.1/http_parser.gyp
|
||||
--- http-parser-2.1-orig/http_parser.gyp 2013-03-26 18:35:20.000000000 -0400
|
||||
+++ http-parser-2.1/http_parser.gyp 2013-05-23 16:47:49.280488341 -0400
|
||||
@@ -21,7 +21,7 @@
|
||||
},
|
||||
'Release': {
|
||||
'defines': [ 'NDEBUG' ],
|
||||
- 'cflags': [ '-Wall', '-Wextra', '-O3' ],
|
||||
+ 'cflags': [ '-Wall', '-Wextra', '-O3', '-fPIC' ],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'RuntimeLibrary': 0, # static release
|
||||
@@ -50,7 +50,7 @@
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'http_parser',
|
||||
- 'type': 'static_library',
|
||||
+ 'type': 'shared_library',
|
||||
'include_dirs': [ '.' ],
|
||||
'direct_dependent_settings': {
|
||||
'defines': [ 'HTTP_PARSER_STRICT=0' ],
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
{
|
||||
'target_name': 'http_parser_strict',
|
||||
- 'type': 'static_library',
|
||||
+ 'type': 'shared_library',
|
||||
'include_dirs': [ '.' ],
|
||||
'direct_dependent_settings': {
|
||||
'defines': [ 'HTTP_PARSER_STRICT=1' ],
|
@ -1,4 +1,7 @@
|
||||
{ lib, stdenv, fetchFromGitHub, fetchpatch }:
|
||||
{ lib, stdenv, fetchFromGitHub, fetchpatch
|
||||
, enableShared ? !stdenv.hostPlatform.isStatic
|
||||
, enableStatic ? stdenv.hostPlatform.isStatic
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "http-parser";
|
||||
@ -14,7 +17,7 @@ stdenv.mkDerivation rec {
|
||||
env.NIX_CFLAGS_COMPILE = "-Wno-error";
|
||||
|
||||
patches = [
|
||||
./build-shared.patch
|
||||
./enable-static-shared.patch
|
||||
] ++ lib.optionals stdenv.isAarch32 [
|
||||
# https://github.com/nodejs/http-parser/pull/510
|
||||
(fetchpatch {
|
||||
@ -26,16 +29,23 @@ stdenv.mkDerivation rec {
|
||||
makeFlags = [
|
||||
"DESTDIR="
|
||||
"PREFIX=$(out)"
|
||||
"SOEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.sharedLibrary}"
|
||||
"BINEXT=${stdenv.hostPlatform.extensions.executable}"
|
||||
"Platform=${lib.toLower stdenv.hostPlatform.uname.system}"
|
||||
] ++ lib.optionals stdenv.hostPlatform.isWindows [
|
||||
"AEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.staticLibrary}"
|
||||
"ENABLE_SHARED=${if enableShared then "1" else "0"}"
|
||||
"ENABLE_STATIC=${if enableStatic then "1" else "0"}"
|
||||
] ++ lib.optionals enableShared [
|
||||
"SOEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.sharedLibrary}"
|
||||
] ++ lib.optionals enableStatic [
|
||||
"AEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.staticLibrary}"
|
||||
] ++ lib.optionals (enableShared && stdenv.hostPlatform.isWindows) [
|
||||
"SONAME=$(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOEXT)"
|
||||
"LIBNAME=$(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOREV).$(SOEXT)"
|
||||
"LDFLAGS=-Wl,--out-implib=$(LIBNAME).a"
|
||||
];
|
||||
|
||||
buildFlags = [ "library" ];
|
||||
buildFlags = lib.optional enableShared "library"
|
||||
++ lib.optional enableStatic "package";
|
||||
|
||||
doCheck = true;
|
||||
checkTarget = "test";
|
||||
|
@ -0,0 +1,93 @@
|
||||
commit abcb3cca9452779e91380b7636f32745166af3de
|
||||
Author: John Ericson <John.Ericson@Obsidian.Systems>
|
||||
Date: Wed Nov 29 23:55:38 2023 -0500
|
||||
|
||||
Make build system: enable/disable shared/static support
|
||||
|
||||
This allows building this package in static-lib-only distros.
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 5d21221..cbc7914 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -18,6 +18,9 @@
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
|
||||
+ENABLE_SHARED ?= 1
|
||||
+ENABLE_STATIC ?=
|
||||
+
|
||||
PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
|
||||
HELPER ?=
|
||||
BINEXT ?=
|
||||
@@ -25,6 +28,8 @@ SOLIBNAME = libhttp_parser
|
||||
SOMAJOR = 2
|
||||
SOMINOR = 9
|
||||
SOREV = 4
|
||||
+AEXT = a
|
||||
+STATICLIBNAME = $(SOLIBNAME).$(AEXT)
|
||||
ifeq (darwin,$(PLATFORM))
|
||||
SOEXT ?= dylib
|
||||
SONAME ?= $(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOEXT)
|
||||
@@ -109,11 +114,17 @@ test-valgrind: test_g
|
||||
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) $(LDFLAGS_LIB) -o $(LIBNAME) $<
|
||||
+.PHONY: library
|
||||
+library: $(LIBNAME)
|
||||
+
|
||||
+$(LIBNAME): libhttp_parser.o
|
||||
+ $(CC) $(LDFLAGS_LIB) -o $@ $<
|
||||
|
||||
-package: http_parser.o
|
||||
- $(AR) rcs libhttp_parser.a http_parser.o
|
||||
+.PHONY: package
|
||||
+package: $(STATICLIBNAME)
|
||||
+
|
||||
+$(STATICLIBNAME): http_parser.o
|
||||
+ $(AR) rcs $@ $<
|
||||
|
||||
url_parser: http_parser.o contrib/url_parser.c
|
||||
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o $@
|
||||
@@ -130,12 +141,30 @@ parsertrace_g: http_parser_g.o contrib/parsertrace.c
|
||||
tags: http_parser.c http_parser.h test.c
|
||||
ctags $^
|
||||
|
||||
-install: library
|
||||
+.PHONY: install-headers
|
||||
+install-headers:
|
||||
$(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
|
||||
+
|
||||
+.PHONY: install-library
|
||||
+install-library: library
|
||||
$(INSTALL) -D $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
|
||||
ln -sf $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
|
||||
ln -sf $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)
|
||||
|
||||
+.PHONY: install-package
|
||||
+install-package: package
|
||||
+ $(INSTALL) -D $(STATICLIBNAME) $(DESTDIR)$(LIBDIR)/$(STATICLIBNAME)
|
||||
+
|
||||
+.PHONY: install
|
||||
+install: install-headers
|
||||
+ifeq ($(ENABLE_SHARED),1)
|
||||
+install: install-library
|
||||
+endif
|
||||
+ifeq ($(ENABLE_STATIC),1)
|
||||
+install: install-package
|
||||
+endif
|
||||
+
|
||||
+.PHONY: install-strip
|
||||
install-strip: library
|
||||
$(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
|
||||
$(INSTALL) -D -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
|
||||
@@ -147,6 +176,7 @@ uninstall:
|
||||
rm $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)
|
||||
rm $(DESTDIR)$(LIBDIR)/$(SONAME)
|
||||
rm $(DESTDIR)$(LIBDIR)/$(LIBNAME)
|
||||
+ rm $(DESTDIR)$(LIBDIR)/$(STATICLIBNAME)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a tags test test_fast test_g \
|
Loading…
Reference in New Issue
Block a user