Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions pkgs/applications/graphics/ImageMagick/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, fetchurl, pkgconfig, libtool
{ lib, stdenv, fetchurl, fetchpatch, pkgconfig, libtool
, bzip2, zlib, libX11, libXext, libXt, fontconfig, freetype, ghostscript, libjpeg
, lcms2, openexr, libpng, librsvg, libtiff, libxml2
}:
Expand All @@ -9,20 +9,38 @@ let
else if stdenv.system == "x86_64-linux" || stdenv.system == "x86_64-darwin" then "x86-64"
else if stdenv.system == "armv7l-linux" then "armv7l"
else throw "ImageMagick is not supported on this platform.";

cfg = {
version = "6.9.3-8";
sha256 = "129s4cwp6cbhgsr3xr8186q5j02zpbk6kqfk4j7ayb563zsrdb4h";
patches = [];
}
# Freeze version on mingw so we don't need to port the patch too often.
// lib.optionalAttrs (stdenv.cross.libc or null == "msvcrt") {
version = "6.9.2-0";
sha256 = "17ir8bw1j7g7srqmsz3rx780sgnc21zfn0kwyj78iazrywldx8h7";
patches = (fetchpatch {
name = "mingw-build.patch";
url = "https://raw.githubusercontent.com/Alexpux/MINGW-packages/"
+ "01ca03b2a4ef/mingw-w64-imagemagick/002-build-fixes.patch";
sha256 = "1pypszlcx2sf7wfi4p37w1y58ck2r8cd5b2wrrwr9rh87p7fy1c0";
});
};
in

stdenv.mkDerivation rec {
name = "imagemagick-${version}";
version = "6.9.3-8";
inherit (cfg) version;

src = fetchurl {
urls = [
"mirror://imagemagick/releases/ImageMagick-${version}.tar.xz"
# the original source above removes tarballs quickly
"http://distfiles.macports.org/ImageMagick/ImageMagick-${version}.tar.xz"
];
sha256 = "129s4cwp6cbhgsr3xr8186q5j02zpbk6kqfk4j7ayb563zsrdb4h";
inherit (cfg) sha256;
};
inherit (cfg) patches;

outputs = [ "out" "doc" ];

Expand All @@ -35,15 +53,26 @@ stdenv.mkDerivation rec {
++ lib.optionals (ghostscript != null)
[ "--with-gs-font-dir=${ghostscript}/share/ghostscript/fonts"
"--with-gslib"
];
]
++ lib.optionals (stdenv.cross.libc or null == "msvcrt")
[ "--enable-static" "--disable-shared" ] # due to libxml2 being without DLLs ATM
;

nativeBuildInputs = [ pkgconfig libtool ];

buildInputs =
[ pkgconfig libtool zlib fontconfig freetype ghostscript libjpeg
openexr libpng librsvg libtiff libxml2
];
[ zlib fontconfig freetype ghostscript
libpng libtiff libxml2
]
++ lib.optionals (stdenv.cross.libc or null != "msvcrt")
[ openexr librsvg ]
;

propagatedBuildInputs =
[ bzip2 freetype libjpeg libX11 libXext libXt lcms2 ];
[ bzip2 freetype libjpeg lcms2 ]
++ lib.optionals (stdenv.cross.libc or null != "msvcrt")
[ libX11 libXext libXt ]
;

postInstall = ''
(cd "$out/include" && ln -s ImageMagick* ImageMagick)
Expand Down
45 changes: 45 additions & 0 deletions pkgs/build-support/setup-hooks/win-dll-link.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

fixupOutputHooks+=(_linkDLLs)

# For every *.{exe,dll} in $output/bin/ we try to find all (potential)
# transitive dependencies and symlink those DLLs into $output/bin
# so they are found on invocation.
# (DLLs are first searched in the directory of the running exe file.)
# The links are relative, so relocating whole /nix/store won't break them.
_linkDLLs() {
(
if [ ! -d "$prefix/bin" ]; then exit; fi
cd "$prefix/bin"

# Compose path list where DLLs should be located:
# prefix $PATH by currently-built outputs
local DLLPATH=""
local outName
for outName in $outputs; do
addToSearchPath DLLPATH "${!outName}/bin"
done
DLLPATH="$DLLPATH:$PATH"

echo DLLPATH="'$DLLPATH'"

linkCount=0
# Iterate over any DLL that we depend on.
local dll
for dll in $(objdump -p *.{exe,dll} | sed -n 's/.*DLL Name: \(.*\)/\1/p' | sort -u); do
if [ -e "./$dll" ]; then continue; fi
# Locate the DLL - it should be an *executable* file on $DLLPATH.
local dllPath="$(PATH="$DLLPATH" type -P "$dll")"
if [ -z "$dllPath" ]; then continue; fi
# That DLL might have its own (transitive) dependencies,
# so add also all DLLs from its directory to be sure.
local dllPath2
for dllPath2 in "$dllPath" "$(dirname "$dllPath")"/*.dll; do
if [ -e ./"$(basename "$dllPath2")" ]; then continue; fi
ln -sr "$dllPath2" .
linkCount=$(($linkCount+1))
done
done
echo "Created $linkCount DLL link(s) in $prefix/bin"
)
}

40 changes: 26 additions & 14 deletions pkgs/development/libraries/boost/generic.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{ stdenv, icu, expat, zlib, bzip2, python, fixDarwinDylibNames
{ stdenv, fetchurl, icu, expat, zlib, bzip2, python, fixDarwinDylibNames, libiconv
, toolset ? if stdenv.cc.isClang then "clang" else null
, enableRelease ? true
, enableDebug ? false
, enableSingleThreaded ? false
, enableMultiThreaded ? true
, enableShared ? true
, enableStatic ? false
, enableShared ? !(stdenv.cross.libc or null == "msvcrt") # problems for now
, enableStatic ? !enableShared
, enablePIC ? false
, enableExceptions ? false
, taggedLayout ? ((enableRelease && enableDebug) || (enableSingleThreaded && enableMultiThreaded) || (enableShared && enableStatic))
Expand Down Expand Up @@ -76,8 +76,14 @@ let
"--user-config=user-config.jam"
"toolset=gcc-cross"
"--without-python"
] ++ optionals (stdenv.cross.libc == "msvcrt") [
"target-os=windows"
"threadapi=win32"
"binary-format=pe"
"address-model=${if hasPrefix "x86_64-" stdenv.cross.config then "64" else "32"}"
"architecture=x86"
];
crossB2Args = concatMapStringsSep " " (genericB2Flags ++ crossB2Flags);
crossB2Args = concatStringsSep " " (genericB2Flags ++ crossB2Flags);

builder = b2Args: ''
./b2 ${b2Args}
Expand Down Expand Up @@ -108,6 +114,8 @@ let
find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \
-exec sed '1i#line 1 "{}"' -i '{}' \;
)
'' + optionalString (stdenv.cross.libc or null == "msvcrt") ''
${stdenv.cross.config}-ranlib "$lib"/lib/*.a
'';

in
Expand Down Expand Up @@ -143,14 +151,15 @@ stdenv.mkDerivation {

enableParallelBuilding = true;

buildInputs = [ icu expat zlib bzip2 python ]
buildInputs = [ expat zlib bzip2 libiconv ]
++ stdenv.lib.optionals (! stdenv ? cross) [ python icu ]
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;

configureScript = "./bootstrap.sh";
configureFlags = commonConfigureFlags ++ [
"--with-icu=${icu.dev}"
"--with-python=${python.interpreter}"
] ++ optional (toolset != null) "--with-toolset=${toolset}";
configureFlags = commonConfigureFlags
++ [ "--with-python=${python.interpreter}" ]
++ optional (! stdenv ? cross) "--with-icu=${icu.dev}"
++ optional (toolset != null) "--with-toolset=${toolset}";

buildPhase = builder nativeB2Args;

Expand All @@ -162,21 +171,24 @@ stdenv.mkDerivation {
setOutputFlags = false;

crossAttrs = rec {
buildInputs = [ expat.crossDrv zlib.crossDrv bzip2.crossDrv ];
# all buildInputs set previously fell into propagatedBuildInputs, as usual, so we have to
# override them.
propagatedBuildInputs = buildInputs;
# We want to substitute the contents of configureFlags, removing thus the
# usual --build and --host added on cross building.
preConfigure = ''
export configureFlags="--without-icu ${concatStringsSep " " commonConfigureFlags}"
set -x
cat << EOF > user-config.jam
using gcc : cross : $crossConfig-g++ ;
EOF
'';
buildPhase = builder crossB2Args;
installPhase = installer crossB2Args;
postFixup = fixup;
} // optionalAttrs (stdenv.cross.libc == "msvcrt") {
patches = fetchurl {
url = "https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/"
+ "boost-mingw.patch";
sha256 = "0s32kwll66k50w6r5np1y5g907b7lcpsjhfgr7rsw7q5syhzddyj";
};

patchFlags = "-p0";
};
}
7 changes: 4 additions & 3 deletions pkgs/development/libraries/freetype/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ stdenv.mkDerivation rec {
};

patches = []
++ optionals useEncumberedCode [
# mingw: these patches use `strcasestr` which isn't available on windows
++ optionals (useEncumberedCode && stdenv.cross.libc or null != "msvcrt" ) [
(fetchbohoomil "01-freetype-2.6.2-enable-valid.patch"
"1szq0zha7n41f4pq179wgfkam034mp2xn0xc36sdl5sjp9s9hv08")
(fetchbohoomil "02-upstream-2015.12.05.patch"
Expand All @@ -39,7 +40,7 @@ stdenv.mkDerivation rec {

propagatedBuildInputs = [ zlib bzip2 libpng ]; # needed when linking against freetype
# dependence on harfbuzz is looser than the reverse dependence
buildInputs = [ pkgconfig which ]
nativeBuildInputs = [ pkgconfig which ]
# FreeType requires GNU Make, which is not part of stdenv on FreeBSD.
++ optional (!stdenv.isLinux) gnumake;

Expand All @@ -56,7 +57,7 @@ stdenv.mkDerivation rec {

postInstall = glib.flattenInclude;

crossAttrs = {
crossAttrs = stdenv.lib.optionalAttrs (stdenv.cross.libc or null != "msvcrt") {
# Somehow it calls the unwrapped gcc, "i686-pc-linux-gnu-gcc", instead
# of gcc. I think it's due to the unwrapped gcc being in the PATH. I don't
# know why it's on the PATH.
Expand Down
7 changes: 0 additions & 7 deletions pkgs/development/libraries/gettext/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ stdenv.mkDerivation rec {

enableParallelBuilding = true;

crossAttrs = {
buildInputs = lib.optional (stdenv ? ccCross && stdenv.ccCross.libc ? libiconv)
stdenv.ccCross.libc.libiconv.crossDrv;
# Gettext fails to guess the cross compiler
configureFlags = "CXX=${stdenv.cross.config}-g++";
};

meta = {
description = "Well integrated set of translation tools and documentation";

Expand Down
8 changes: 7 additions & 1 deletion pkgs/development/libraries/libiconv/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ fetchurl, stdenv, lib }:

assert (!stdenv.isLinux);
assert !stdenv.isLinux || stdenv ? cross; # TODO: improve on cross

stdenv.mkDerivation rec {
name = "libiconv-1.14";
Expand All @@ -15,6 +15,12 @@ stdenv.mkDerivation rec {
./libiconv-1.14-wchar.patch
];

postPatch =
lib.optionalString (stdenv.cross.libc or null == "msvcrt")
''
sed '/^_GL_WARN_ON_USE (gets/d' -i srclib/stdio.in.h
'';

configureFlags =
# On Cygwin, Libtool produces a `.dll.a', which is not a "real" DLL
# (Windows' linker would need to be used somehow to produce an actual
Expand Down
4 changes: 4 additions & 0 deletions pkgs/development/libraries/libjpeg-turbo/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
sha256 = "0gi349hp1x7mb98s4mf66sb2xay2kjjxj9ihrriw0yiy0k9va6sj";
};

patches =
stdenv.lib.optional (stdenv.cross.libc or null == "msvcrt")
./mingw-boolean.patch;

outputs = [ "dev" "out" "doc" "bin" ];

nativeBuildInputs = [ nasm ];
Expand Down
19 changes: 19 additions & 0 deletions pkgs/development/libraries/libjpeg-turbo/mingw-boolean.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Ported to updated libjpeg-turbo from
https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-libjpeg-turbo/jpeg-typedefs.patch
--- a/jmorecfg.h 2012-02-10 06:47:55 +0300
+++ b/jmorecfg.h 2012-05-03 10:29:13 +0400
@@ -224,7 +224,13 @@
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
*/

-#ifndef HAVE_BOOLEAN
+#if defined(_WIN32) && !defined(HAVE_BOOLEAN)
+#ifndef __RPCNDR_H__
+typedef unsigned char boolean;
+#endif
+#define HAVE_BOOLEAN
+#endif
+#if !defined(HAVE_BOOLEAN) && !defined(__RPCNDR_H__)
typedef int boolean;
#endif
#ifndef FALSE /* in case these macros already exist */
4 changes: 3 additions & 1 deletion pkgs/development/libraries/libpng/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ in stdenv.mkDerivation rec {

preConfigure = "export bin=$dev";

doCheck = true;
# it's hard to cross-run tests and some check programs didn't compile anyway
makeFlags = stdenv.lib.optional (!doCheck) "check_PROGRAMS=";
doCheck = ! stdenv ? cross;

postInstall = ''mv "$out/bin" "$dev/bin"'';

Expand Down
35 changes: 24 additions & 11 deletions pkgs/development/libraries/libxml2/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ stdenv, fetchurl, zlib, xz, python, findXMLCatalogs }:
{ stdenv, lib, fetchurl, zlib, xz, python, findXMLCatalogs, libiconv
, supportPython ? (! stdenv ? cross) }:

stdenv.mkDerivation rec {
name = "libxml2-${version}";
Expand All @@ -9,37 +10,49 @@ stdenv.mkDerivation rec {
sha256 = "0bd17g6znn2r98gzpjppsqjg33iraky4px923j3k8kdl8qgy7sad";
};

outputs = [ "dev" "out" "bin" "doc" "py" ];
propagatedBuildOutputs = "out bin py";
outputs = [ "dev" "out" "bin" "doc" ]
++ lib.optional supportPython "py";
propagatedBuildOutputs = "out bin" + lib.optionalString supportPython " py";

buildInputs = [ python ]
buildInputs = lib.optional supportPython python
# Libxml2 has an optional dependency on liblzma. However, on impure
# platforms, it may end up using that from /usr/lib, and thus lack a
# RUNPATH for that, leading to undefined references for its users.
++ stdenv.lib.optional stdenv.isFreeBSD xz;
++ lib.optional stdenv.isFreeBSD xz;

propagatedBuildInputs = [ zlib findXMLCatalogs ];

configureFlags = "--with-python=${python}";
configureFlags = lib.optional supportPython "--with-python=${python}";

enableParallelBuilding = true;

preInstall = ''substituteInPlace python/libxml2mod.la --replace "${python}" "$py"'';
installFlags = ''pythondir="$(py)/lib/${python.libPrefix}/site-packages"'';
crossAttrs = lib.optionalAttrs (stdenv.cross.libc == "msvcrt") {
# creating the DLL is broken ATM
dontDisableStatic = true;
configureFlags = configureFlags ++ [ "--disable-shared" ];

# libiconv is a header dependency - propagating is enough
propagatedBuildInputs = [ findXMLCatalogs libiconv ];
};

preInstall = lib.optionalString supportPython
''substituteInPlace python/libxml2mod.la --replace "${python}" "$py"'';
installFlags = lib.optionalString supportPython
''pythondir="$(py)/lib/${python.libPrefix}/site-packages"'';

postFixup = ''
moveToOutput bin/xml2-config "$dev"
moveToOutput lib/xml2Conf.sh "$dev"
moveToOutput share/man/man1 "$bin"
'';

passthru = { inherit version; pythonSupport = true; };
passthru = { inherit version; pythonSupport = supportPython; };

meta = {
homepage = http://xmlsoft.org/;
description = "An XML parsing library for C";
license = "bsd";
platforms = stdenv.lib.platforms.unix;
maintainers = [ stdenv.lib.maintainers.eelco ];
platforms = lib.platforms.unix;
maintainers = [ lib.maintainers.eelco ];
};
}
Loading