summary refs log tree commit diff
path: root/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix
blob: b49c0f0f60ca09b95d5960f6e0f84422039c3577 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ stdenv
, lib
, gfortran
, flex
, bison
, jre8
, blas
, lapack
, curl
, readline
, expat
, pkg-config
, buildPackages
, targetPackages
, libffi
, binutils
, mkOpenModelicaDerivation
}:
let
  isCross = stdenv.buildPlatform != stdenv.hostPlatform;
  nativeOMCompiler = buildPackages.openmodelica.omcompiler;
in
mkOpenModelicaDerivation ({
  pname = "omcompiler";
  omtarget = "omc";
  omdir = "OMCompiler";
  omdeps = [ ];
  omautoconf = true;

  nativeBuildInputs = [
    jre8
    gfortran
    flex
    bison
    pkg-config
  ] ++ lib.optional isCross nativeOMCompiler;

  buildInputs = [ targetPackages.stdenv.cc.cc blas lapack curl readline expat libffi binutils ];

  postPatch = ''
    sed -i -e '/^\s*AR=ar$/ s/ar/${stdenv.cc.targetPrefix}ar/
               /^\s*ar / s/ar /${stdenv.cc.targetPrefix}ar /
               /^\s*ranlib/ s/ranlib /${stdenv.cc.targetPrefix}ranlib /' \
        $(find ./OMCompiler -name 'Makefile*')
  '';

  preFixup = ''
    for entry in $(find $out -name libipopt.so); do
      patchelf --shrink-rpath --allowed-rpath-prefixes /nix/store $entry
      patchelf --set-rpath '$ORIGIN':"$(patchelf --print-rpath $entry)" $entry
    done
  '';

  meta = with lib; {
    description = "Modelica compiler from OpenModelica suite";
    homepage = "https://openmodelica.org";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ smironov ];
    platforms = platforms.linux;
  };
} // lib.optionalAttrs isCross {
  configureFlags = [ "--with-omc=${nativeOMCompiler}/bin/omc" ];
})