9 lib.throwIfNot (lib.versionAtLeast ocaml.version "4.03")
10 "camlidl is not available for OCaml ${ocaml.version}"
14 pname = "ocaml${ocaml.version}-camlidl";
17 src = fetchFromGitHub {
18 owner = "xavierleroy";
21 hash = "sha256-ONPQMDFaU2OzFa5jgMVKx+ZRKk8ZgBZyk42vDvbM7E0=";
24 nativeBuildInputs = [ ocaml ];
26 # build fails otherwise
27 enableParallelBuilding = false;
30 mv config/Makefile.unix config/Makefile
31 substituteInPlace config/Makefile --replace BINDIR=/usr/local/bin BINDIR=$out
32 substituteInPlace config/Makefile --replace 'OCAMLLIB=$(shell $(OCAMLC) -where)' OCAMLLIB=$out/lib/ocaml/${ocaml.version}/site-lib/camlidl
33 substituteInPlace config/Makefile --replace CPP=cpp CPP=${stdenv.cc}/bin/cpp
34 substituteInPlace lib/Makefile --replace '$(OCAMLLIB)/Makefile.config' "${ocaml}/lib/ocaml/Makefile.config"
35 mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/camlidl/caml
36 mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/camlidl/stublibs
40 cat >$out/lib/ocaml/${ocaml.version}/site-lib/camlidl/META <<EOF
42 description = "Stub generator"
43 version = "${version}"
44 archive(byte) = "com.cma"
45 archive(native) = "com.cmxa"
48 ln -s $out/camlidl $out/bin
51 setupHook = writeText "setupHook.sh" ''
52 export NIX_CFLAGS_COMPILE+=" -isystem $1/lib/ocaml/${ocaml.version}/site-lib/camlidl"
53 export NIX_LDFLAGS+=" -L $1/lib/ocaml/${ocaml.version}/site-lib/camlidl"
57 description = "Stub code generator and COM binding for Objective Caml";
58 mainProgram = "camlidl";
59 homepage = "https://xavierleroy.org/camlidl/";
60 license = lib.licenses.lgpl21;
61 maintainers = [ lib.maintainers.roconnor ];