From 988d1fe445cb5c1a5b61d0a17d1aff239c2b5664 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 9 Oct 2020 13:40:31 -0700 Subject: [PATCH] pkg-config support for urcrypt, update urbit build --- nix/pkgs/default.nix | 5 ++--- nix/pkgs/urbit/default.nix | 2 +- nix/pkgs/urcrypt/builder.sh | 7 +++++-- nix/pkgs/urcrypt/default.nix | 15 ++++++++++----- nix/pkgs/urcrypt/shell.nix | 6 ++---- pkg/urbit/configure | 22 +++++++++++++--------- pkg/urcrypt/.gitignore | 17 ----------------- pkg/urcrypt/Makefile.am | 2 ++ pkg/urcrypt/configure.ac | 6 +++++- pkg/urcrypt/liburcrypt.pc.in | 13 +++++++++++++ 10 files changed, 53 insertions(+), 42 deletions(-) delete mode 100644 pkg/urcrypt/.gitignore create mode 100644 pkg/urcrypt/liburcrypt.pc.in diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index 12318534c..66267712e 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -14,9 +14,8 @@ let }; urcrypt = import ./urcrypt { - inherit libaes_siv; - inherit (pkgs) stdenv pkgconfig openssl gmp; - inherit (deps) scrypt secp256k1; + inherit pkgs; + inherit deps; }; mkUrbit = { debug }: diff --git a/nix/pkgs/urbit/default.nix b/nix/pkgs/urbit/default.nix index 2aee0514c..bd168d60f 100644 --- a/nix/pkgs/urbit/default.nix +++ b/nix/pkgs/urbit/default.nix @@ -32,7 +32,7 @@ let inherit name meta; exename = name; src = ../../../pkg/urbit; - nativeBuildInputs = deps ++ vendor; + nativeBuildInputs = [ pkgs.pkgconfig ] ++ deps ++ vendor; configurePhase = '' bash ./configure diff --git a/nix/pkgs/urcrypt/builder.sh b/nix/pkgs/urcrypt/builder.sh index 5a0404377..495f92869 100644 --- a/nix/pkgs/urcrypt/builder.sh +++ b/nix/pkgs/urcrypt/builder.sh @@ -2,6 +2,9 @@ source $stdenv/setup cp -r $src ./src chmod -R u+w ./src -cd ./src +cd src -PREFIX=$out make install +./autogen.sh +./configure --prefix=$out $configureFlags +make +make install diff --git a/nix/pkgs/urcrypt/default.nix b/nix/pkgs/urcrypt/default.nix index d037846c3..5d00d1b66 100644 --- a/nix/pkgs/urcrypt/default.nix +++ b/nix/pkgs/urcrypt/default.nix @@ -1,11 +1,16 @@ -{ stdenv, pkgconfig, openssl, gmp, secp256k1, scrypt, libaes_siv }: +{ pkgs, deps }: -stdenv.mkDerivation rec { +pkgs.stdenv.mkDerivation rec { name = "urcrypt"; builder = ./builder.sh; src = ../../../pkg/urcrypt; - buildInputs = [ - pkgconfig openssl gmp secp256k1 scrypt libaes_siv - ]; + nativeBuildInputs = + with pkgs; + [ autoconf automake libtool m4 pkgconfig ]; + + buildInputs = + with pkgs; + with deps; + [ openssl gmp secp256k1 scrypt libaes_siv ]; } diff --git a/nix/pkgs/urcrypt/shell.nix b/nix/pkgs/urcrypt/shell.nix index db71bf97c..40db282fe 100644 --- a/nix/pkgs/urcrypt/shell.nix +++ b/nix/pkgs/urcrypt/shell.nix @@ -4,8 +4,6 @@ let in import ./default.nix { - inherit (pkgs) - stdenv openssl gmp pkgconfig; - inherit (deps) - libaes_siv scrypt secp256k1; + inherit pkgs; + inherit deps; } diff --git a/pkg/urbit/configure b/pkg/urbit/configure index a0758fcf0..597665808 100755 --- a/pkg/urbit/configure +++ b/pkg/urbit/configure @@ -4,9 +4,11 @@ set -e URBIT_VERSION="0.10.8" -deps=" \ - curl gmp sigsegv argon2 ed25519 ent h2o scrypt uv murmur3 secp256k1 \ - softfloat3 ssl crypto z lmdb aes_siv urcrypt pthread \ +pkg_config_deps="liburcrypt" + +extra_libs="\ + urcrypt curl gmp sigsegv ent h2o scrypt uv murmur3 \ + softfloat3 ssl z lmdb pthread \ " headers=" \ @@ -65,7 +67,7 @@ case $(tr A-Z a-z <<< $os) in ;; *freebsd*) defmacro U3_OS_bsd 1 - osdeps="kvm" + extra_libs="${extra_libs} kvm" ;; *openbsd*) defmacro U3_OS_bsd 1 @@ -76,13 +78,15 @@ case $(tr A-Z a-z <<< $os) in ;; esac -for dep in ${osdeps-} $deps -do LDFLAGS="${LDFLAGS-} -l$dep" - ${PKG_CONFIG-pkg-config} --cflags --libs $dep 2>/dev/null || true +CFLAGS="${CFLAGS-} $(${PKG_CONFIG-pkg-config} --cflags $pkg_config_deps)" +LDFLAGS="${LDFLAGS-} $(${PKG_CONFIG-pkg-config} --libs --static $pkg_config_deps)" + +for lib in ${extra_libs}; do + LDFLAGS="${LDFLAGS-} -l$lib" done -for header in $headers -do LDFLAGS="${LDFLAGS-} -I$header" +for header in $headers; do + CFLAGS="${CFLAGS-} -I$header" done cat >config.mk <