[project @ 1998-01-28 12:08:45 by simonm]
[ghc-hetmet.git] / mk / suffix.mk
1 #################################################################################
2 #
3 #                           suffix.mk
4 #
5 #               Suffix rules for fptools
6 #
7 #################################################################################
8
9
10 # This file contain the default suffix rules for all the fptools projects.
11 #
12
13
14 # No need to define .SUFFIXES because we don't use any suffix rules
15 # Instead we use gmake's pattern rules exlusively
16
17 .SUFFIXES:
18
19 # However, if $(way) is set then we have to define $(way_) and $(_way)
20 # from it in the obvious fashion.
21 # This must be done here (or earlier), but not in target.mk with the other
22 # way management, because the pattern rules in this file take a snapshot of
23 # the value of $(way_) and $(_way), and it's no good setting them later!
24
25 ifneq "$(way)" ""
26   way_ := $(way)_
27   _way := _$(way)
28 endif
29
30 #-----------------------------------------------------------------------------
31 # Haskell Suffix Rules
32
33 HC_SPLIT_PRE= \
34  $(RM) $@ ; if [ ! -d $(basename $@) ]; then mkdir $(basename $@); else \
35  find $(basename $@) -name '*.$(way_)o' -print | xargs $(RM) __rm_food ; fi
36 HC_SPLIT_POST  = touch $@
37
38 HC_PRE__       = $(patsubst %,$(HC_SPLIT_PRE) ; ,$(filter -split-objs,$(HC_OPTS)))
39 HC_POST__      = $(patsubst %,$(HC_SPLIT_POST) ; ,$(filter -split-objs,$(HC_OPTS)))
40
41 SRC_HC_POST += $(HC_POST__)
42 SRC_HC_PRE  += $(HC_PRE__)
43
44 %.$(way_)o : %.hs
45         $(SRC_HC_PRE)
46         $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
47         $(SRC_HC_POST)
48                          
49 %.$(way_)o : %.lhs       
50         $(SRC_HC_PRE)
51         $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
52         $(SRC_HC_POST)
53                          
54 %.$(way_)hc : %.lhs      
55         $(RM) $@
56         $(HC) $(HC_OPTS) -C $< -o $@
57                          
58 %.$(way_)hc : %.hs       
59         $(RM) $@
60         $(HC) $(HC_OPTS) -C $< -o $@
61                          
62 %.$(way_)o : %.$(way_)hc 
63         $(SRC_HC_PRE)
64         $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
65         $(SRC_HC_POST)
66
67 %.$(way_)hc : %.lhc
68         @$(RM) $@
69         $(UNLIT) $< $@
70         @chmod 444 $@
71
72
73 # Here's an interesting rule!
74 # The .hi file depends on the .o file,
75 # so if the .hi file is dated earlier than the .o file (commonly the case,
76 # when interfaces are stable) this rule just makes sure that the .o file,
77 # is up to date.  Then it does nothing to generate the .hi file from the 
78 # .o file, because the act of making sure the .o file is up to date also
79 # updates the .hi file (if necessary).
80
81 %.$(way_)hi : %.$(way_)o
82         @if [ ! -f $@ ] ; then \
83             echo Panic! $< exists, but $@ does not. \
84             exit 1; \
85         else exit 0 ; \
86         fi                                                      
87
88 %.$(way_)hi : %.$(way_)hc
89         @if [ ! -f $@ ] ; then \
90             echo Panic! $< exists, but $@ does not. \
91             exit 1; \
92         else exit 0 ; \
93         fi
94
95 #-----------------------------------------------------------------------------
96 # Happy Suffix Rules
97 #
98 .PRECIOUS: %.hs
99
100 %.hs : %.ly
101         $(HAPPY) $(HAPPY_OPTS) -g $<
102
103 #-----------------------------------------------------------------------------
104 # Lx Suffix Rules
105 #
106
107 %.hs : %.lx
108         $(LX) $(LX_OPTS) $<
109
110 #-----------------------------------------------------------------------------
111 # Green-card Suffix Rules
112 #
113
114 %.hs : %.gc
115         $(GREENCARD) $(GREENCARD_OPTS) $<
116
117 #-----------------------------------------------------------------------------
118 # C-related suffix rules
119
120 %.$(way_)o : %.$(way_)s
121         @$(RM) $@
122         $(AS) $(AS_OPTS) -o $@ $< || ( $(RM) $@ && exit 1 )
123
124 %.$(way_)o : %.c
125         @$(RM) $@
126         $(CC) $(CC_OPTS) -c $< -o $@
127
128 #%.$(way_)s : %.c
129 #       @$(RM) $@
130 #       $(CC) $(CC_OPTS) -S $< -o $@
131
132 %.c : %.flex
133         @$(RM) $@
134         $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
135 %.c : %.lex
136         @$(RM) $@
137         $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
138
139 #-----------------------------------------------------------------------------
140 # Yacc stuff
141
142 %.tab.c %.tab.h : %.y
143         @$(RM) $*.tab.h $*.tab.c y.tab.c y.tab.h y.output
144         $(YACC) $(YACC_OPTS) $<
145         $(MV) y.tab.c $*.tab.c
146         @chmod 444 $*.tab.c
147         $(MV) y.tab.h $*.tab.h
148         @chmod 444 $*.tab.h
149
150
151 #-----------------------------------------------------------------------------
152 # Runtest rules for calling $(HC) on a single-file Haskell program
153
154 %.runtest : %.hs
155         $(TIME) $(RUNTEST) $(HC) $(RUNTEST_OPTS) $<
156
157 #-----------------------------------------------------------------------------
158 # Doc processing suffix rules
159 #
160 # ToDo: make these more robust
161 #
162 %.dvi : %.tex
163         @$(RM) $@
164         $(LTX) $<
165
166 %.ps : %.dvi
167         @$(RM) $@
168         dvips $< -o $@
169
170 %.tex : %.verb
171         @$(RM) $*.tex
172         expand $*.verb | $(VERBATIM) > $*.tex
173
174 %.tex : %.tib
175         @$(RM) $*.tex $*.verb-t.tex
176         $(TIB) $*.tib
177         expand $*.tib-t.tex | $(VERBATIM) > $*.tex
178         @$(RM) $*.tib-t.tex
179
180 %.ps : %.fig
181         @$(RM) $@
182         fig2dev -L ps $< $@
183
184 %.tex : %.fig
185         @$(RM) $@
186         fig2dev -L latex $< $@
187
188 #-----------------------------------------------------------------------------
189 # SGML suffix rules
190 #
191 # make sure these don't conflict with the literate rules!
192
193 %.sgml : %.vsgml
194         @$(RM) $@
195         expand $*.vsgml | $(SGMLVERB) > $@
196
197 %.tex : %.sgml
198         @$(RM) $@
199         $(SGML2LATEX) -m --output=tex $<
200
201 %.dvi : %.sgml
202         @$(RM) $@
203         $(SGML2LATEX) -m --output=dvi $<
204
205 # Not yet: we already have a %.ps : %.dvi rule, this one would conflict.
206 #%,ps : %.sgml
207 #       @$(RM) $@
208 #       $(SGML2LATEX) -m --output=ps $<
209
210 %.html : %.sgml
211         @$(RM) $@
212         $(SGML2HTML) $<
213
214 %.info : %.sgml
215         @$(RM) $@
216         $(SGML2INFO) $<
217
218 %.txt : %.sgml
219         @$(RM) $@
220         $(SGML2TXT) $<
221
222 #-----------------------------------------------------------------------------
223 # Literate suffix rules
224
225 # ToDo: somehow macroize this lot. (if only!)
226
227 %.itxi : %.lit
228         @$(RM) $@
229         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
230         @chmod 444 $@
231
232 %.txt : %.lit
233         @$(RM) $@
234         $(LIT2TEXT) $(LIT2TEXT_OPTS) -o $@ $<
235         @chmod 444 $@
236
237 %.ihtml : %.lit
238         @$(RM) $@
239         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
240         @chmod 444 $@
241
242 %.itex : %.lit
243         @$(RM) $@
244         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
245         @chmod 444 $@
246
247 #
248 # Produce stand-alone TEX documents
249 #
250 %.tex : %.itex
251         @$(RM) $@
252         $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
253         @chmod 444 $@
254
255 %.tex : %.lhs
256         @$(RM) $@
257         $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
258         @chmod 444 $@
259
260 %.texi : %.lhs
261         @$(RM) $@
262         $(LIT2TEXI) -S $(LIT2TEXI_OPTS) -o $@ $<
263         @chmod 444 $@
264
265 %.html : %.lhs
266         @$(RM) $@ 
267         $(LIT2TEXI) $(LIT2TEXI_OPTS) -o $(patsubst %.html,%.texi,$@) $<
268         $(TEXI2HTML) $(TEXI2HTML_OPTS) $(patsubst %.lhs,%.texi,$<) 
269         @touch $@
270
271 %.info:: %.texi
272         @$(RM) $@
273         $(MAKEINFO) $(MAKEINFO_OPTS) $< && $(POSTMAKEINFO) $@
274
275 %.hs : %.lhs
276         @$(RM) $@
277         $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
278         @chmod 444 $@
279
280 %.itxi : %.lhs
281         @$(RM) $@
282         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
283         @chmod 444 $@
284
285 %.ihtml : %.lhs
286         @$(RM) $@
287         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
288         @chmod 444 $@
289
290 %.itex : %.lhs
291         @$(RM) $@
292         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
293         @chmod 444 $@
294
295 %.tex : %.lhs
296         $(LIT2LATEX) -S -c $(LIT2LATEX_OPTS) -o $@ $<
297         $(HC) $(HC_OPTS) -c $< -o $@
298
299
300 %.itxi : %.lhc
301         @$(RM) $@
302         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
303         @chmod 444 $@
304
305 %.ihtml : %.lhc
306         @$(RM) $@
307         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
308         @chmod 444 $@
309
310 %.itex : %.lhc
311         @$(RM) $@
312         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
313         @chmod 444 $@
314
315 #
316 # Temporary, until either unlit is lifted out of ghc/
317 # or literate is properly set up locally -- SOF
318 #
319 %.prl : %.lprl
320         @$(RM) $@
321         $(UNLIT) $(UNLIT_OPTS) $< $@
322         @chmod 444 $@
323
324 %.itxi : %.lprl
325         @$(RM) $@
326         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
327         @chmod 444 $@
328
329 %.ihtml : %.lprl
330         @$(RM) $@
331         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
332         @chmod 444 $@
333
334 %.itex : %.lprl
335         @$(RM) $@
336         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
337         @chmod 444 $@
338
339 %.sh : %.lsh
340         @$(RM) $@
341         $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
342         @chmod 444 $@
343
344 %.itxi : %.lsh
345         @$(RM) $@
346         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
347         @chmod 444 $@
348
349 %.ihtml : %.lsh
350         @$(RM) $@
351         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
352         @chmod 444 $@
353
354 %.itex : %.lsh
355         @$(RM) $@
356         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
357         @chmod 444 $@
358
359 %.c : %.lc
360         @$(RM) $@
361         $(UNLIT) $< $@
362         @chmod 444 $@
363
364 %.itxi : %.lc
365         @$(RM) $@
366         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
367         @chmod 444 $@
368
369 %.ihtml : %.lc
370         @$(RM) $@
371         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
372         @chmod 444 $@
373
374 %.itex : %.lc
375         @$(RM) $@
376         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
377         @chmod 444 $@
378
379 %.h : %.lh
380         @$(RM) $@
381         $(UNLIT) $< $@
382         @chmod 444 $@
383
384 %.itxi : %.lh
385         @$(RM) $@
386         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
387         @chmod 444 $@
388
389 %.ihtml : %.lh
390         @$(RM) $@
391         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
392         @chmod 444 $@
393
394 %.itex : %.lh
395         @$(RM) $@
396         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
397         @chmod 444 $@
398
399 %.flex : %.lflex
400         @$(RM) $@
401         $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
402         @chmod 444 $@
403
404 %.itxi : %.lflex
405         @$(RM) $@
406         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
407         @chmod 444 $@
408
409 %.ihtml : %.lflex
410         @$(RM) $@
411         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
412         @chmod 444 $@
413
414 %.itex : %.lflex
415         @$(RM) $@
416         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
417         @chmod 444 $@
418