0

I thought about playing around with m4's extra macro processing features (over the regular cpp preprocessor) by merely, simply including it in the invoked chain of tools during the GCC compilation (rather right before cpp, so looks like as the first invoked command), however I don't know how to do it, i.e.: how to make m4 invoked as the (apparently) first stage of C gcc compilation of each of the input .c files. Is there some elegant method of achieving this?

Update: Apparently, the question might be more about build tools like autotools and CMake. I would be more interested in autotools.

psprint
  • 349
  • 1
  • 10
  • 3
    Don't do this in GCC, do it in your Makefile. – Barmar Oct 07 '21 at 19:28
  • @Barmar: You might be right. I've updated the question. – psprint Oct 07 '21 at 19:37
  • `I would be more interested in autotools` Just add it to makefile.am, literally `file.c: file.c.m4 m4 $< > $@` , make will pick it up. As for cmake, just `add_custom_command` it, I did [some more work](https://gitlab.com/Kamcuk/kcmakelib/-/blob/master/cmake/k/m4.cmake) with GNU m4 and CMake to track `m4_include(dependencies)` from m4 and automatically recompile if dependencies changes, but I doubt the library is "user ready". – KamilCuk Nov 16 '21 at 10:13

0 Answers0