2016-06-28 07:41:24 +01:00
|
|
|
{ stdenv
|
2017-06-20 06:51:34 +01:00
|
|
|
, fetchFromGitHub
|
2016-06-28 07:41:24 +01:00
|
|
|
, libtool
|
|
|
|
, automake
|
|
|
|
, autoconf
|
2016-11-09 15:03:28 +00:00
|
|
|
, python2 # Needed for tests
|
2016-06-28 07:41:24 +01:00
|
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "libcpuid-${version}";
|
2017-06-20 06:51:34 +01:00
|
|
|
version = "0.4.0";
|
2016-06-28 07:41:24 +01:00
|
|
|
|
2017-06-20 06:51:34 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "anrieff";
|
|
|
|
repo = "libcpuid";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "136kv6m666f7s18mim0vdbzqvs4s0wvixa12brj9p3kmfbx48bw7";
|
2016-06-28 07:41:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
libtoolize
|
|
|
|
autoreconf --install
|
2017-06-20 06:51:34 +01:00
|
|
|
'';
|
2016-06-28 07:41:24 +01:00
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
mkdir -p Install
|
|
|
|
./configure --prefix=$(pwd)/Install
|
|
|
|
substituteInPlace Makefile --replace "/usr/local" "$out"
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
make all
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
pushd Install
|
2016-11-09 15:03:28 +00:00
|
|
|
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/lib ${python2.interpreter} ../tests/run_tests.py ./bin/cpuid_tool ../tests/
|
2016-06-28 07:41:24 +01:00
|
|
|
popd
|
|
|
|
|
|
|
|
function fixRunPath {
|
|
|
|
p0=$(patchelf --print-rpath $1)
|
|
|
|
p1=$(echo $p0 | sed -re 's#.*Install/lib:##g')
|
|
|
|
patchelf --set-rpath $p1 $1
|
|
|
|
}
|
|
|
|
|
|
|
|
fixRunPath Install/bin/cpuid_tool
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
sed -i -re "s#(prefix=).*Install#\1$out#g" Install/lib/pkgconfig/libcpuid.pc
|
2017-06-20 06:51:34 +01:00
|
|
|
|
2016-06-28 07:41:24 +01:00
|
|
|
cp -r Install/* $out
|
|
|
|
cp -r tests $out
|
|
|
|
'';
|
|
|
|
|
2017-06-20 06:51:34 +01:00
|
|
|
nativeBuildInputs = [
|
2016-06-28 07:41:24 +01:00
|
|
|
libtool
|
|
|
|
automake
|
|
|
|
autoconf
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = http://libcpuid.sourceforge.net/;
|
|
|
|
description = "a small C library for x86 CPU detection and feature extraction";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ artuuge ];
|
|
|
|
};
|
|
|
|
}
|