views:

42

answers:

1

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

+2  A: 

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) $< 
dcolish
The issue is not how to write the makefile for my documentation, nor how to call it specifically from command line. What I want is for the base directory's makefile to recognize that I am asking for the documentation rather than the executable, and it will go run the other makefile or not, as needed.
Larry Wang
a command in your top level makefile:docs: $(MAKE) -C docs allwill do the trick, I've revised the answer for more clarity
dcolish
That did exactly what I wanted, thanks.
Larry Wang