20 # Determine version and revision from:
21 # https://sourceforge.net/p/netpbm/code/HEAD/log/?path=/advanced
25 outputs = [ "bin" "out" "dev" ];
28 url = "https://svn.code.sf.net/p/netpbm/code/advanced";
30 sha256 = "sha256-Vy7aKyMn3C2P3N9jdRayDu35+8jzvQv4rYIEsKdyWDU=";
47 ] ++ lib.optional enableX11 libX11;
52 enableParallelBuilding = true;
54 # Environment variables
55 STRIPPROG = "${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}strip";
58 # Install libnetpbm.so symlink to correct destination
59 substituteInPlace lib/Makefile \
60 --replace '/sharedlink' '/lib'
66 cp config.mk.in config.mk
68 # Disable building static library
69 echo "STATICLIB_TOO = N" >> config.mk
71 # Enable cross-compilation
72 echo 'AR = ${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ar' >> config.mk
73 echo 'CC = ${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc' >> config.mk
74 echo 'CC_FOR_BUILD = ${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc' >> config.mk
75 echo 'LD_FOR_BUILD = $(CC_FOR_BUILD)' >> config.mk
76 echo 'PKG_CONFIG = ${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config' >> config.mk
77 echo 'RANLIB = ${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ranlib' >> config.mk
79 # Use libraries from Nixpkgs
80 echo "TIFFLIB = libtiff.so" >> config.mk
81 echo "TIFFLIB_NEEDS_JPEG = N" >> config.mk
82 echo "TIFFLIB_NEEDS_Z = N" >> config.mk
83 echo "JPEGLIB = libjpeg.so" >> config.mk
84 echo "JBIGLIB = libjbig.a" >> config.mk
86 echo "JASPERLIB = NONE" >> config.mk
89 echo "RGB_DB_PATH = $out/share/netpbm/misc/rgb.txt" >> config.mk
90 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
91 echo "LDSHLIB=-dynamiclib -install_name $out/lib/libnetpbm.\$(MAJ).dylib" >> config.mk
92 echo "NETPBMLIBTYPE = dylib" >> config.mk
93 echo "NETPBMLIBSUFFIX = dylib" >> config.mk
98 env = lib.optionalAttrs stdenv.cc.isClang {
99 NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
105 make package pkgdir=$out
107 rm -rf $out/*_template $out/{pkginfo,README,VERSION} $out/man/web
109 mkdir -p $out/share/netpbm
110 mv $out/misc $out/share/netpbm/
112 moveToOutput bin "''${!outputBin}"
114 # wrap any scripts that expect other programs in the package to be in their PATH
115 for prog in ppmquant; do
116 wrapProgram "''${!outputBin}/bin/$prog" --prefix PATH : "''${!outputBin}/bin"
122 passthru.updateScript = ./update.sh;
125 homepage = "https://netpbm.sourceforge.net/";
126 description = "Toolkit for manipulation of graphic images";
127 license = lib.licenses.free; # http://netpbm.svn.code.sourceforge.net/p/netpbm/code/trunk/doc/copyright_summary
128 platforms = with lib.platforms; linux ++ darwin;