Makefile 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. LATEX_CMD?=pdflatex
  2. MKIDX_CMD?=makeindex
  3. BIBTEX_CMD?=bibtex
  4. LATEX_COUNT?=8
  5. MANUAL_FILE?=refman
  6. all: $(MANUAL_FILE).pdf
  7. pdf: $(MANUAL_FILE).pdf
  8. $(MANUAL_FILE).pdf: clean $(MANUAL_FILE).tex
  9. $(LATEX_CMD) $(MANUAL_FILE) || \
  10. if [ $$? != 0 ] ; then \
  11. \echo "Please consult $(MANUAL_FILE).log to see the error messages" ; \
  12. false; \
  13. fi
  14. $(MKIDX_CMD) $(MANUAL_FILE).idx
  15. $(LATEX_CMD) $(MANUAL_FILE) || \
  16. if [ $$? != 0 ] ; then \
  17. \echo "Please consult $(MANUAL_FILE).log to see the error messages" ; \
  18. false; \
  19. fi
  20. latex_count=$(LATEX_COUNT) ; \
  21. while grep -E -s 'Rerun (LaTeX|to get cross-references right|to get bibliographical references right)' $(MANUAL_FILE).log && [ $$latex_count -gt 0 ] ;\
  22. do \
  23. echo "Rerunning latex...." ;\
  24. $(LATEX_CMD) $(MANUAL_FILE) || \
  25. if [ $$? != 0 ] ; then \
  26. \echo "Please consult $(MANUAL_FILE).log to see the error messages" ; \
  27. false; \
  28. fi; \
  29. latex_count=`expr $$latex_count - 1` ;\
  30. done
  31. $(MKIDX_CMD) $(MANUAL_FILE).idx
  32. $(LATEX_CMD) $(MANUAL_FILE) || \
  33. if [ $$? != 0 ] ; then \
  34. \echo "Please consult $(MANUAL_FILE).log to see the error messages" ; \
  35. false; \
  36. fi
  37. clean:
  38. rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl $(MANUAL_FILE).pdf