Larry Wang
Larry Wang

Reputation: 1006

makefile option to generate latex documentation

I have a project that can be built via makefile, and I would like to add the ability for someone in the base directory to not only be able to build the executable via make, but also to build the documentation pdfs from LaTeX in a separate directory by typing make docs or something similar.
I only need one pass to generate the documentation, and there are no dependencies in the .tex files.
I don't have any experience with recursive makefiles, so any general resources would also be appreciated.

PS. I am not using noweb or similar systems, I simply have some source files and some separate .tex files.

Desired behavior:
$ ls
docs/
Makefile
source1.cpp
source1.h
source2.cpp
source2.h
$ ls docs
Makefile
doc1.tex
$ make
=my program gets compiled=
$ make docs
$ ls docs
Makefile
doc1.tex
doc1.pdf

Upvotes: 0

Views: 1038

Answers (1)

Dan
Dan

Reputation: 23667

I think you could easily just specify a command to execute the Makefile in the docs dir and run pdflatex -output-directory=DIR. So it would end up looking something like this:

In your toplevel Makefile add the rule

  docs:  
      $(MAKE) -C doc all

Then inside the doc dir you can add a Makefile with a rule like

%.pdf: %.tex 
      $(PDFLATEX PATH) --output-dir=$(DIR) $< 

Upvotes: 2

Related Questions