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