Dune and dependencies for C files

I have (library (c_names a)), which will process an a.c. This a.c does #include "a.h". Dune already has a rule to generate this a.h with (rule (target a.h) (deps a.input) (action (with-stdout-to %{target} (system "some-command < a.input")))).

How do I tell dune to process the rule to generate a.h before it starts processing a.c?

Isn’t that the behaviour already? By default, Dune considers that .c files depend on all .h files in the same directory, including generated ones.

Unfortunately it does not work for me in my attempt to convert lablgl to dune. One C file includes other, generated C files. Maybe this makes a difference?

Ah yes, that’s why. Renaming the generated file to .h would make it work. We are also preparing a change to make compilation of C sources more flexible: https://github.com/ocaml/dune/pull/2659. With this, you will be able to declare additional dependencies for .c files. However, it is not fine grained, i.e. the dependencies are for all .c files so the generated file would still have to be renamed, for instance to .c-gen.

Do you know that LablGL only provides deprecated features of OpenGL?
It is not possible to make forward compatible programming with it in its current state. Are you planning to make evolve it to handle the modern OpenGL?

I wrote this tutorial in 2010 about how to use forward compatible OpenGL in ocaml:
http://www.linux-nantes.org/~fmonnier/ocaml/GL/ocaml-opengl-howto-fc.html
This tutorial uses glMLite but you can use tgls in the same way.

It is a build dependency of other packages, so I have little choice. Fortunately the current make(1) based build happens to work, so converting to dune is just a learning exercise.