Commit 86bb270c authored by Guillaume Girol's avatar Guillaume Girol
Browse files

aiger: install pkg-config file

and build a proper library instead of installing an object file
parent 2bbdb6d3
Loading
Loading
Loading
Loading
+33 −2
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
  lib,
  stdenv,
  fetchFromGitHub,
  copyPkgconfigItems,
  makePkgconfigItem,
  picosat,
}:

@@ -18,6 +20,31 @@ stdenv.mkDerivation rec {

  enableParallelBuilding = true;

  nativeBuildInputs = [ copyPkgconfigItems ];

  pkgconfigItems = [
    (makePkgconfigItem {
      name = "aiger";
      inherit version;
      cflags = [ "-I\${includedir}" ];
      libs = [
        "-L\${libdir}"
        "-laiger"
      ];
      variables = {
        includedir = "@includedir@";
        libdir = "@libdir@";
      };
      inherit (meta) description;
    })
  ];

  env = {
    # copyPkgconfigItems will substitute these in the pkg-config file
    includedir = "${placeholder "dev"}/include";
    libdir = "${placeholder "lib"}/lib";
  };

  configurePhase = ''
    # Set up picosat, so we can build 'aigbmc'
    mkdir ../picosat
@@ -27,13 +54,17 @@ stdenv.mkDerivation rec {
    ./configure.sh
  '';

  postBuild = ''
    $AR rcs libaiger.a aiger.o
  '';

  installFlags = [ "PREFIX=${placeholder "out"}" ];
  postInstall = ''
    # test that installing picosat in configurePhase suceeded
    test -f $out/bin/aigbmc

    install -m 440 -Dt $lib/lib aiger.o
    install -m 440 -Dt $dev/include aiger.h
    install -m 444 -Dt $lib/lib libaiger.a
    install -m 444 -Dt $dev/include aiger.h
  '';

  outputs = [
+4 −4
Original line number Diff line number Diff line
@@ -24,10 +24,10 @@ stdenv.mkDerivation {
    # doesn't handle real build products very well (it works on a build-time
    # dir, not installed copy)... This is so we can build 'blimc'
    substituteInPlace ./makefile \
      --replace 'targets: liblgl.a' 'targets: liblgl.a blimc'      \
      --replace '$(AIGER)/aiger.o'  '${aiger.lib}/lib/aiger.o'     \
      --replace '$(AIGER)/aiger.h'  '${aiger.dev}/include/aiger.h' \
      --replace '-I$(AIGER)'        '-I${aiger.dev}/include'
      --replace-fail 'targets: liblgl.a' 'targets: liblgl.a blimc'      \
      --replace-fail '$(AIGER)/aiger.o'  '${aiger.lib}/lib/libaiger.a'     \
      --replace-fail '$(AIGER)/aiger.h'  '${aiger.dev}/include/aiger.h' \
      --replace-fail '-I$(AIGER)'        '-I${aiger.dev}/include'
  '';

  installPhase = ''