# //@C Copyright Notice
# //@C ================
# //@C This file is part of CPSW. It is subject to the license terms in the LICENSE.txt
# //@C file found in the top-level directory of this distribution and at
# //@C https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# //@C
# //@C No part of CPSW, including this file, may be copied, modified, propagated, or
# //@C distributed except according to the terms contained in the LICENSE.txt file.

# Makefile template for CPSW software:

# Locate CPSW:

CPSW_DIR=../../api/sw

# from 'release.mak' CPSW_DIR and other variables
# which define package locations may be overridden.
# Note: must include from $(SRCDIR) (which is redefined
#       when recursing into subdirs).
SRCDIR=.

-include $(SRCDIR)/release.mak
include $(CPSW_DIR)/defs.mak

# Sources which are generated by the makefile process. These
# end up in the source directory (and are cleaned):

# A rule is already present for generating a header containing
# the git version string
GENERATED_SRCS += O.Common/gitversion.tex
GENERATED_SRCS += O.Common/cpswTutorial.pdf

include $(CPSW_DIR)/rules.mak

# include your own rules here

O.Common/cpswTutorial.pdf: cpswTutorial.tex O.Common/gitversion.tex O.Common $(patsubst %.fig,O.Common/%.pdf,$(wildcard *.fig))

O.Common:
	mkdir -p $@

O.Common/%.pdf: %.tex O.Common
	pdflatex -output-directory O.Common $<
	pdflatex -output-directory O.Common $<

O.Common/%.pdf: %.fig O.Common
	fig2dev -Lpdf $< $@

O.Common/gitversion.tex: O.Common
	$(RM) $@
	echo "$(GIT_VERSION_STRING)" > $@

install_local: $(SRCDIR)/O.Common/cpswTutorial.pdf
	@if [ -n "$(INSTALL_DIR)" ]; then \
		mkdir -p $(INSTALL_DIR)/doc; \
		$(INSTALL) $(SRCDIR)/O.Common/cpswTutorial.pdf $(INSTALL_DIR)/doc; \
	fi
