1{ lib, stdenv, fetchFromGitHub, fetchpatch }:
2
3stdenv.mkDerivation rec {
4 pname = "libb64";
5 version = "2.0.0.1";
6
7 src = fetchFromGitHub {
8 owner = "libb64";
9 repo = "libb64";
10 rev = "v${version}";
11 sha256 = "sha256-9loDftr769qnIi00MueO86kjha2EiG9pnCLogp0Iq3c=";
12 };
13
14 patches = [
15 # Fix parallel build failure: https://github.com/libb64/libb64/pull/9
16 # make[1]: *** No rule to make target 'libb64.a', needed by 'c-example1'. Stop.
17 (fetchpatch {
18 name = "parallel-make.patch";
19 url = "https://github.com/libb64/libb64/commit/4fe47c052e9123da8f751545deb48be08c3411f6.patch";
20 sha256 = "18b3np3gpyzimqmk6001riqv5n70wfbclky6zzsrvj5zl1dj4ljf";
21 })
22 ] ++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) (fetchpatch {
23 name = "0001-example-Do-not-run-the-tests.patch";
24 url = "https://cgit.openembedded.org/meta-openembedded/plain/meta-oe/recipes-support/libb64/libb64/0001-example-Do-not-run-the-tests.patch?id=484e0de1e4ee107f21ae2a5c5f976ed987978baf";
25 sha256 = "sha256-KTsiIWJe66BKlu/A43FWfW0XAu4E7lWX/RY4NITRrm4=";
26 });
27
28 enableParallelBuilding = true;
29
30 installPhase = ''
31 mkdir -p $out $out/lib $out/bin $out/include
32 cp -r include/* $out/include/
33 cp base64/base64 $out/bin/
34 cp src/libb64.a src/cencode.o src/cdecode.o $out/lib/
35 '';
36
37 meta = {
38 description = "ANSI C routines for fast base64 encoding/decoding";
39 homepage = "https://github.com/libb64/libb64";
40 license = lib.licenses.publicDomain;
41 mainProgram = "base64";
42 platforms = lib.platforms.unix;
43 };
44}