> but when you write configure.ac to generate configure.in to generate configure to generate Makefile.in to generate Makefile to generate the final product ...
AFAIK, configure.ac is just the modern name for configure.in. You will not have both at the same time, and both are used to generate configure.
Usually, you do not use configure to generate Makefile.in. Instead, you use automake to generate Makefile.in from Makefile.am, and configure to generate Makefile from Makefile.in.
So, what you have is that you write configure.ac to generate configure, Makefile.am to generate Makefile.in, and configure and Makefile.in together generate Makefile. But that is simplifying things, there is also config.h.in to generate config.h together with configure, and some stamp.h.in/stamp-h thing.