Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 90 lines 3.7 kB view raw
1{ fetchurl, stdenv, lib 2, enableStatic ? stdenv.hostPlatform.isStatic 3, enableShared ? !stdenv.hostPlatform.isStatic 4, enableDarwinABICompat ? false 5}: 6 7# assert !stdenv.hostPlatform.isLinux || stdenv.hostPlatform != stdenv.buildPlatform; # TODO: improve on cross 8 9stdenv.mkDerivation rec { 10 pname = "libiconv"; 11 version = "1.17"; 12 13 src = fetchurl { 14 url = "mirror://gnu/libiconv/${pname}-${version}.tar.gz"; 15 sha256 = "sha256-j3QhO1YjjIWlClMp934GGYdx5w3Zpzl3n0wC9l2XExM="; 16 }; 17 18 enableParallelBuilding = true; 19 20 setupHooks = [ 21 ../../../build-support/setup-hooks/role.bash 22 ./setup-hook.sh 23 ]; 24 25 postPatch = 26 lib.optionalString ((stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isMinGW) || stdenv.cc.nativeLibc) 27 '' 28 sed '/^_GL_WARN_ON_USE (gets/d' -i srclib/stdio.in.h 29 '' 30 + lib.optionalString (!enableShared) '' 31 sed -i -e '/preload/d' Makefile.in 32 '' 33 # The system libiconv is based on libiconv 1.11 with some ABI differences. The following changes 34 # build a compatible libiconv on Darwin, allowing it to be sustituted in place of the system one 35 # using `install_name_tool`. This removes the need to for a separate, Darwin-specific libiconv 36 # derivation and allows Darwin to benefit from upstream updates and fixes. 37 + lib.optionalString enableDarwinABICompat '' 38 for iconv_h_in in iconv.h.in iconv.h.build.in; do 39 substituteInPlace "include/$iconv_h_in" \ 40 --replace-fail "#define iconv libiconv" "" \ 41 --replace-fail "#define iconv_close libiconv_close" "" \ 42 --replace-fail "#define iconv_open libiconv_open" "" \ 43 --replace-fail "#define iconv_open_into libiconv_open_into" "" \ 44 --replace-fail "#define iconvctl libiconvctl" "" \ 45 --replace-fail "#define iconvlist libiconvlist" "" 46 done 47 ''; 48 49 # This is hacky, but `libiconv.dylib` needs to reexport `libcharset.dylib` to match the behavior 50 # of the system libiconv on Darwin. Trying to do this by modifying the `Makefile` results in an 51 # error linking `iconv` because `libcharset.dylib` is not at its final path yet. Avoid the error 52 # by building without the reexport then clean and rebuild `libiconv.dylib` with the reexport. 53 # 54 # For an explanation why `libcharset.dylib` is reexported, see: 55 # https://github.com/apple-oss-distributions/libiconv/blob/a167071feb7a83a01b27ec8d238590c14eb6faff/xcodeconfig/libiconv.xcconfig 56 postBuild = lib.optionalString enableDarwinABICompat '' 57 make clean -C lib 58 NIX_CFLAGS_COMPILE+=" -Wl,-reexport-lcharset -L. " make -C lib -j$NIX_BUILD_CORES SHELL=$SHELL 59 ''; 60 61 configureFlags = [ 62 (lib.enableFeature enableStatic "static") 63 (lib.enableFeature enableShared "shared") 64 ] ++ lib.optional stdenv.isFreeBSD "--with-pic"; 65 66 passthru = { inherit setupHooks; }; 67 68 meta = { 69 description = "Iconv(3) implementation"; 70 71 longDescription = '' 72 Some programs, like mailers and web browsers, must be able to convert 73 between a given text encoding and the user's encoding. Other programs 74 internally store strings in Unicode, to facilitate internal processing, 75 and need to convert between internal string representation (Unicode) 76 and external string representation (a traditional encoding) when they 77 are doing I/O. GNU libiconv is a conversion library for both kinds of 78 applications. 79 ''; 80 81 homepage = "https://www.gnu.org/software/libiconv/"; 82 license = lib.licenses.lgpl2Plus; 83 84 maintainers = [ ]; 85 mainProgram = "iconv"; 86 87 # This library is not needed on GNU platforms. 88 hydraPlatforms = with lib.platforms; cygwin ++ darwin ++ freebsd; 89 }; 90}