libiconv: add "enableShared" option

When false, shared libraries will be disabled.

also adds patch to *really* disable shared libiconv.
This commit is contained in:
Matthew Bauer 2018-06-22 21:49:41 -04:00
parent 6946361408
commit 73e2f60837
2 changed files with 16 additions and 7 deletions

View file

@ -1,6 +1,7 @@
{ fetchurl, stdenv, lib
, buildPlatform, hostPlatform
, enableStatic ? stdenv.hostPlatform.useAndroidPrebuilt
, enableShared ? !stdenv.hostPlatform.useAndroidPrebuilt
}:
# assert !stdenv.isLinux || hostPlatform != buildPlatform; # TODO: improve on cross
@ -23,10 +24,14 @@ stdenv.mkDerivation rec {
lib.optionalString ((hostPlatform != buildPlatform && hostPlatform.libc == "msvcrt") || stdenv.cc.nativeLibc)
''
sed '/^_GL_WARN_ON_USE (gets/d' -i srclib/stdio.in.h
'';
''
+ lib.optionalString (!enableShared) ''
sed -i -e '/preload/d' Makefile.in
'';
configureFlags = lib.optional stdenv.isFreeBSD "--with-pic"
++ lib.optional enableStatic "--enable-static";
++ lib.optional enableStatic "--enable-static"
++ lib.optional (!enableShared) "--disable-shared";
meta = {
description = "An iconv(3) implementation";

View file

@ -1,15 +1,19 @@
{ stdenv, appleDerivation, autoreconfHook, targetPlatform, enableStatic ? targetPlatform.isiOS }:
{ stdenv, appleDerivation, lib, autoreconfHook, targetPlatform
, enableStatic ? targetPlatform.isiOS
, enableShared ? !targetPlatform.isiOS
}:
appleDerivation {
postUnpack = "sourceRoot=$sourceRoot/libiconv";
preConfigure = stdenv.lib.optionalString stdenv.hostPlatform.isiOS ''
preConfigure = lib.optionalString stdenv.hostPlatform.isiOS ''
sed -i 's/darwin\*/ios\*/g' configure libcharset/configure
'';
configureFlags = stdenv.lib.optionals enableStatic [ "--enable-static" "--disable-shared" ];
configureFlags = lib.optional enableStatic "--enable-static"
++ lib.optional (!enableShared) "--disable-shared";
postInstall = stdenv.lib.optionalString (!enableStatic) ''
postInstall = lib.optionalString (!enableStatic) ''
mv $out/lib/libiconv.dylib $out/lib/libiconv-nocharset.dylib
${stdenv.cc.bintools.targetPrefix}install_name_tool -id $out/lib/libiconv-nocharset.dylib $out/lib/libiconv-nocharset.dylib
@ -26,6 +30,6 @@ appleDerivation {
];
meta = {
platforms = stdenv.lib.platforms.darwin;
platforms = lib.platforms.darwin;
};
}