1#! /bin/sh
2
3# BEGIN LICENSE BLOCK
4# Version: CMPL 1.1
5#
6# The contents of this file are subject to the Cisco-style Mozilla Public
7# License Version 1.1 (the "License"); you may not use this file except
8# in compliance with the License.  You may obtain a copy of the License
9# at www.eclipse-clp.org/license.
10# 
11# Software distributed under the License is distributed on an "AS IS"
12# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
13# the License for the specific language governing rights and limitations
14# under the License. 
15# 
16# The Original Code is  The ECLiPSe Constraint Logic Programming System. 
17# The Initial Developer of the Original Code is  Cisco Systems, Inc. 
18# Portions created by the Initial Developer are
19# Copyright (C) 2006 Cisco Systems, Inc.  All Rights Reserved.
20# 
21# Contributor(s): 
22# 
23# END LICENSE BLOCK
24
25DESTFILE = applications
26
27ROOTFILE = tutorial
28
29CHAPTERS = $(ROOTFILE).tex
30
31EPSFIGURES = htmlreport.eps profile.eps tracer.eps
32
33#-------------------  generic part -------------------
34
35# the files that are touched by latex as a side effect
36#CHAPAUX = $(CHAPTERS:%.tex=%.aux) $(ROOTFILE).toc $(ROOTFILE).idx
37CHAPAUX = $(ROOTFILE).aux $(ROOTFILE).toc $(ROOTFILE).idx
38
39
40all:	$(ROOTFILE).dvi $(ROOTFILE)/$(ROOTFILE).html
41	echo Do make install to install
42
43install:	../../doc/$(DESTFILE).pdf $(ROOTFILE)/$(ROOTFILE).html
44	rm -rf ../../doc/$(DESTFILE)
45	mv $(ROOTFILE) ../../doc/$(DESTFILE)
46
47../../doc/$(DESTFILE).pdf:	$(ROOTFILE).pdf
48	cp $(ROOTFILE).pdf ../../doc/$(DESTFILE).pdf
49	chmod 644 ../../doc/$(DESTFILE).pdf
50
51
52# tex -> dvi -> pdf
53
54$(ROOTFILE).dvi:	$(CHAPAUX) $(ROOTFILE).bbl $(ROOTFILE).ind
55	@echo ======== UPDATE-PASS =========
56	@for f in $(CHAPAUX); do \
57		mv $$f $$f.old; cp $$f.old $$f; \
58	    done
59	latex $(ROOTFILE)
60	# The touches below are supposed to work around nfs clock skew problems:
61	# The latex run may leave the dvi file with a modification time in the
62	# future. Touch it to make sure the time is right relative to the
63	# subsequent touches of the aux files. Sleep in between to make sure
64	# the dvi is strictly older than the touched aux files.
65	touch $(ROOTFILE).dvi 
66	sleep 1
67	@for f in $(CHAPAUX); do \
68		if cmp -s $$f $$f.old; then mv $$f.old $$f; \
69		else rm $$f.old; echo ==== $$f was modified ====; touch $$f; \
70		fi \
71	    done
72	$(MAKE) $(ROOTFILE).dvi
73
74$(ROOTFILE).aux:	$(CHAPTERS)
75	@echo ======== PASS 1 =========
76	latex $(ROOTFILE)
77
78$(ROOTFILE).idx:	$(ROOTFILE).aux
79	touch $(ROOTFILE).idx
80
81$(ROOTFILE).bbl:	$(ROOTFILE).aux
82	-bibtex $(ROOTFILE)
83
84$(ROOTFILE).ind:	$(ROOTFILE).idx
85	-makeindex $(ROOTFILE)
86
87$(ROOTFILE).pdf:	$(ROOTFILE).ps $(EPSFIGURES)
88	ps2pdf $(ROOTFILE).ps
89
90$(ROOTFILE).ps:	$(ROOTFILE).dvi $(EPSFIGURES)
91	dvips -Ppdf -t a4 -o $(ROOTFILE).ps $(ROOTFILE)
92
93$(ROOTFILE).ps.Z:	$(ROOTFILE).ps
94	compress -f $(ROOTFILE).ps
95
96# This preprocesses all *.tex files
97# to insert links to the bip pages
98biprefs:
99	eclipse -e "[makerefs],do" -- *.tex
100
101
102# HTML version
103
104$(ROOTFILE)/$(ROOTFILE).html:	$(CHAPTERS)
105	mkdir -p $(ROOTFILE)
106	hevea -fix underscore.hva url.hva $(ROOTFILE)
107	# replace the hard link index.html -> $(ROOTFILE).html by a soft link
108	# because of problems with tar on Windows
109	hacha -tocbis $(ROOTFILE).html
110        # copy the files needed for the html to $(ROOTFILE) directory
111	cp $(ROOTFILE)[0-9]??.* $(ROOTFILE)/
112	cp $(ROOTFILE).css $(ROOTFILE)/
113	cp contents_motif.gif next_motif.gif previous_motif.gif $(ROOTFILE)
114	cp index.html $(ROOTFILE)/$(ROOTFILE).html
115	ln -s $(ROOTFILE).html $(ROOTFILE)/index.html
116
117clean:
118	rm -f *.bak *.idx *.ind *.bbl *.aux *.dvi *.toc *.log *.ilg *.blg
119	rm -f *.hind *.haux *.hind *.htoc $(ROOTFILE).image.*
120	rm -f $(ROOTFILE)[0-9]??.*
121	rm -f $(ROOTFILE).ps $(ROOTFILE).ps.Z $(ROOTFILE).pdf $(ROOTFILE).html
122	rm -rf $(ROOTFILE)
123