Introduction
If you use Doxygen to document your source code, you can integrate it into Autotools so that you can simple type:
$ make doc
to create your code’s documentation.
Adding Doxygen Support
In the top-level Makefile.am, add:
EXTRA_DIST = bootstrap \
Doxyfile \
m4/gnulib-cache.m4 \
makedoc.sh \
README.md
DOCS_DIR = docs
doc docs:
./makedoc.sh $(PACKAGE) $(DOCS_DIR)
clean-local:
rm -fr $(DOCS_DIR)
Specifically, add:
Doxyfile(your Doxygen configuration file) andmakedoc.sh(a shell script that calls Doxygen) toEXTRA_DISTso they will be included when you typemake distto create a distribution tarball.A
DOCS_DIRvariable containing the name of the subdirectory into which Doxygen should build the documentation (because using a variable is generally better than hard-coding).Targets
docanddocs(so the user can type either and have it work).A
clean-localtarget that allows you to add commands to what happens when the user typesmake clean. In this case, deletes the generated documentation.
The makedoc.sh script isn’t needed — you could simply run doxygen directly, but it does give a better user experience. When running on macOS, it’ll add the instruction that the user can use macOS’s open command to open the top-level index.html file to view the documentation.
Conclusion
Adding Doxygen support into Autotools is fairly straightforward and makes it easy to generate documentation.
Top comments (0)