I'm using ocamlbuild to build my OCaml project that uses an external C library "cstub". I found a very solution online to include the C library in the compilation process using ocamlbuild in http://l-lang.blogspot.com/2012/08/incorporating-c-code-in-ocaml-project.html (adding the pdep ["link";] "linkdep" (fun param -> [param]); line to myocamlbuild.ml).
However, my C library has an external ASM dependency itself, and the solution above is not able to capture it. It fails to link with the ASM functions because it is not compiled together with the ASM file. Therefore, my question is: is there a way to tweak the suggestion given above to add the support to the ASM file when compiling the C program? For example, is there an additional parameter to be added to the pdep command to support additional compilation features?
Thank you very much in advance!
The default preamble for all build-related questions. Consider using dune if you have that option. OCamlBuild is retiring so don't expect too much help on it or good modern documentation. With that said, I understand that it is not always an option and I am myself using
ocamlbuildfor my main project.So the
pdeprule that you added to your ocamlbuild plugin is taking a parameter, e.g.,This
toto_c.o(or anything between the parens) is passed asparamand you need to translate it to a list of paths, so if your asm file is compiled tofoo.o, you can write it asand your
pdeprule should beIf you want ocamlbuild to build
foo.ofrom filefoo.s, you will also need to write a rule for assembling files, (ocamlbuild -documentationwill show you all rules known toocamlbuild, I didn't find any rules for the*.s -> *.opattern).Totally untested, but the rule should look something like this,
Then add it on
dispatchin theBefore_rulesstage, e.g.,