1VPATH  = @srcdir@
2srcdir = @srcdir@
3
4LYX        = @LYX@
5LATEX      = @LATEX@
6LATEX2HTML = @LATEX2HTML@
7PDFLATEX   = @PDFLATEX@
8MAKEINDEX  = @MAKEINDEX@
9DVIPDFM    = @DVIPDFM@
10
11PDFLATEXARGS = -file-line-error -halt-on-error
12
13include ../Makefile.common
14
15MANUAL = sdccman
16
17all: $(MANUAL).pdf $(MANUAL).html/index.html $(MANUAL).txt
18
19install:
20	$(INSTALL) -d $(DESTDIR)$(docdir)
21	cp -rf $(srcdir)/*.txt $(DESTDIR)$(docdir)
22	txtfiles=`echo *.txt | grep -v '\*\.txt' || true`
23	if [    $(txtfiles)               ]; then cp     $(txtfiles)    $(DESTDIR)$(docdir); fi
24	if [ -f $(MANUAL).html/index.html ]; then cp -rf $(MANUAL).html $(DESTDIR)$(docdir); fi
25	if [ -f $(MANUAL).pdf             ]; then cp -rf $(MANUAL).pdf  $(DESTDIR)$(docdir); fi
26	rm -rf `find $(DESTDIR)$(docdir) -name .svn -type d`
27	rm -f $(DESTDIR)$(docdir)/*/images.*
28
29uninstall:
30	rm -rf $(DESTDIR)$(docdir)
31
32$(MANUAL).html/index.html: $(MANUAL).tex $(MANUAL).aux ;#$(MANUAL).ind $(MANUAL).glo
33	mkdir -p $(dir $@)
34	@# fixes $(LATEX2HTML) problems with two consecutive dashes for long-options: --stack-auto
35	@# fixes $(LATEX2HTML) problems with \tabularnewline
36	sed -e 's,-\\/-,-\\/-\\/-,g' \
37	    -e 's,\\tabularnewline$$,\\\\,g' < $< > $(dir $@)$(notdir $<)
38	cp $(MANUAL).aux $(dir $@)
39	-cd $(dir $@); $(LATEX2HTML) -split 5 -show_section_numbers -local_icons -info "" -nosubdir $(MANUAL) $(QUIET)
40	rm -f $(dir $@)WARNINGS $(dir $@)labels.pl $(dir $@)$(notdir $<) $(dir $@)$*.aux
41
42%.html/index.html: %.tex %.aux
43	mkdir -p $(dir $@)
44	@# fixes $(LATEX2HTML) problems with two consecutive dashes for long-options: --stack-auto
45	@# fixes $(LATEX2HTML) problems with \tabularnewline
46	sed -e 's,-\\/-,-\\/-\\/-,g' \
47	    -e 's,\\tabularnewline$$,\\\\,g' < $< > $(dir $@)$(notdir $<)
48	cp $*.aux $(dir $@)
49	-cd $(dir $@); $(LATEX2HTML) -split 0 -local_icons -info "" -nosubdir $* $(QUIET)
50	rm -f $(dir $@)WARNINGS $(dir $@)labels.pl $(dir $@)$(notdir $<) $(dir $@)$*.aux
51
52%.txt: %.lyx
53	@# $(LYX) will export the file in the directory of the $(LYX) file
54	@# if VPATH is used the $(LYX) file is copied first
55	if [ "$(srcdir)" != "." ]; then \
56	  cp -f $(srcdir)/$(notdir $<) $(srcdir)/*.svg . ; \
57	fi
58	$(LYX) -e text $(notdir $<);
59
60%.pdf %.aux: %.tex %.dvi %.ind
61	which $(PDFLATEX) > /dev/null && $(PDFLATEX) $* || $(DVIPDFM) $*
62
63#%.ps:  %.pdf
64#	$(DVIPS) $*
65
66%.dvi: %.tex
67	$(LATEX) $<
68	@# rerun to in include aux
69	$(LATEX) $<
70
71%.tex: %.lyx
72	if [ "$(srcdir)" != "." ] ; then \
73	  cp -f $(srcdir)/$(notdir $^) $(srcdir)/*.svg . ; \
74	fi
75	echo $(VERSION) > sdcc_version
76	$(LYX) -e latex $(notdir $<);
77
78%.ind: %.dvi
79	$(LATEX) $*
80	# is there an index?
81	if [ -f $*.idx ] ; then \
82	  $(MAKEINDEX) -q $*; \
83	  $(LATEX) $*; \
84	  $(LATEX) $*; \
85	fi
86#	  -$(MAKEINDEX) -s l2hidx.ist $*; \
87
88#%.glo: %.dvi
89#	# the glossary, not implemented yet
90#	# $(MAKEINDEX) -s l2hglo.ist -o $@ $<
91
92#%.pdf %.aux: %.tex
93#	$(PDFLATEX) $* $(PDFLATEXARGS)
94#	[ ! -e "$*.idx" ] || $(MAKEINDEX) $* $(QUIET)
95#	$(PDFLATEX) $* $(PDFLATEXARGS)
96#	[ ! -e "$*.idx" ] || $(MAKEINDEX) $* $(QUIET)
97#	$(PDFLATEX) $* $(PDFLATEXARGS)
98
99archive: all
100	rm -rf sdcc-doc sdcc-doc.tar.bz2
101	mkdir sdcc-doc
102	rsync -rCt *.pdf *.txt $(srcdir)/*.txt sdcc-doc
103
104	for doc in $(MANUAL); do \
105	  rsync -Rt $$doc.html/*.html $$doc.html/*.png $$doc.html/*.css sdcc-doc/; \
106	done
107
108	mkdir sdcc-doc/as
109	rsync -rCt $(top_srcdir)/sdas/doc/* sdcc-doc/as/
110
111	mkdir sdcc-doc/ucsim
112	cd $(top_srcdir)/sim/ucsim/doc; rsync *.html *.jpg *.fig ../../../doc/sdcc-doc/ucsim/
113
114	tar -c sdcc-doc | bzip2 -9 > sdcc-doc.tar.bz2
115
116include $(srcdir)/clean.mk
117