[project @ 1997-06-05 23:12:35 by sof]
[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 HASKELL_SPLIT_PRE= \
34  $(RM) $@ ; if [ ! -d $(basename $@) ]; then mkdir $(basename $@) ; else exit 0; fi; \
35  find $(basename $@) -name '*.$(way_)o' -print | xargs $(RM) __rm_food;
36 HASKELL_SPLIT_POST= touch $@
37 HASKELL_PRE_COMPILE=$(patsubst %,$(HASKELL_SPLIT_PRE),$(filter -split-objs,$(HC_OPTS)))
38 HASKELL_POST_COMPILE=$(patsubst %,$(HASKELL_SPLIT_POST),$(filter -split-objs,$(HC_OPTS)))
39
40 %.$(way_)o : %.hs
41         $(HASKELL_PRE_COMPILE)
42         $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
43         $(HASKELL_POST_COMPILE)
44                          
45 %.$(way_)o : %.lhs       
46         $(HASKELL_PRE_COMPILE)
47         $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
48         $(HASKELL_POST_COMPILE)
49                          
50 %.$(way_)hc : %.lhs      
51         $(RM) $@
52         $(HC) $(HC_OPTS) -C $< -o $@
53                          
54 %.$(way_)o : %.$(way_)hc 
55         $(HASKELL_PRE_COMPILE)
56         $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
57         $(HASKELL_POST_COMPILE)
58
59 %.$(way_)hc : %.lhc
60         @$(RM) $@
61         $(UNLIT) $< $@
62         @chmod 444 $@
63
64
65 # Here's an interesting rule!
66 # The .hi file depends on the .o file,
67 # so if the .hi file is dated earlier than the .o file (commonly the case,
68 # when interfaces are stable) this rule just makes sure that the .o file,
69 # is up to date.  Then it does nothing to generate the .hi file from the 
70 # .o file, because the act of making sure the .o file is up to date also
71 # updates the .hi file (if necessary).
72
73 %.$(way_)hi : %.$(way_)o
74         @if [ ! -f $@ ] ; then \
75             echo Panic! $< exists, but $@ does not. \
76             exit 1; \
77         else exit 0 ; \
78         fi                                                      
79
80 %.$(way_)hi : %.$(way_)hc
81         @if [ ! -f $@ ] ; then \
82             echo Panic! $< exists, but $@ does not. \
83             exit 1; \
84         else exit 0 ; \
85         fi
86
87 #-----------------------------------------------------------------------------
88 # Happy Suffix Rules
89 #
90 .PRECIOUS: %.hs
91
92 %.hs : %.ly
93         $(HAPPY) $(HAPPY_OPTS) -g $<
94
95 #-----------------------------------------------------------------------------
96 # Lx Suffix Rules
97 #
98
99 %.hs : %.lx
100         $(LX) $(LX_OPTS) $<
101
102 #-----------------------------------------------------------------------------
103 # C-related suffix rules
104
105 %.$(way_)o : %.$(way_)s
106         @$(RM) $@
107         $(AS) $(AS_OPTS) -o $@ $< || ( $(RM) $@ && exit 1 )
108
109 %.$(way_)o : %.c
110         @$(RM) $@
111         $(CC) $(CC_OPTS) -c $< -o $@
112
113 #%.$(way_)s : %.c
114 #       @$(RM) $@
115 #       $(CC) $(CC_OPTS) -S $< -o $@
116
117 %.c : %.flex
118         @$(RM) $@
119         $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
120 %.c : %.lex
121         @$(RM) $@
122         $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
123
124 #-----------------------------------------------------------------------------
125 # Yacc stuff
126
127 %.tab.c %.tab.h : %.y
128         @$(RM) $*.tab.h $*.tab.c y.tab.c y.tab.h y.output
129         $(YACC) $(YACC_OPTS) $<
130         $(MV) y.tab.c $*.tab.c
131         @chmod 444 $*.tab.c
132         $(MV) y.tab.h $*.tab.h
133         @chmod 444 $*.tab.h
134
135
136 #-----------------------------------------------------------------------------
137 # Runtest rules for calling $(HC) on a single-file Haskell program
138
139 %.hs : %.runtest
140         $(TIME) $(RUNTEST) $(HC) $(RUNTEST_FLAGS) -o2 $*.stderr $<
141
142
143 #-----------------------------------------------------------------------------
144 # Doc processing suffix rules
145
146 %.dvi : %.tex
147         @$(RM) $@
148         $(LTX) $<
149
150 %.ps : %.dvi
151         @$(RM) $@
152         dvips $< -o $@
153
154 %.tex : %.verb
155         @$(RM) $*.tex
156         expand $*.verb | $(VERBATIM) > $*.tex
157
158 %.tex : %.tib
159         @$(RM) $*.tex $*.verb-t.tex
160         $(TIB) $*.tib
161         expand $*.tib-t.tex | $(VERBATIM) > $*.tex
162         @$(RM) $*.tib-t.tex
163
164 %.ps : %.fig
165         @$(RM) $@
166         fig2dev -L ps $< $@
167
168 %.tex : %.fig
169         @$(RM) $@
170         fig2dev -L latex $< $@
171
172 #-----------------------------------------------------------------------------
173 # Literate suffix rules
174
175 # ToDo: somehow macroize this lot. (if only!)
176
177 %.itxi : %.lit
178         @$(RM) $@
179         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
180         @chmod 444 $@
181
182 %.txt : %.lit
183         @$(RM) $@
184         $(LIT2TEXT) -c $(LIT2TEXT_OPTS) -o $@ $<
185         @chmod 444 $@
186
187 %.ihtml : %.lit
188         @$(RM) $@
189         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
190         @chmod 444 $@
191
192 %.itex : %.lit
193         @$(RM) $@
194         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
195         @chmod 444 $@
196
197 #
198 # Produce stand-alone TEX documents
199 #
200 %.tex : %.itex
201         @$(RM) $@
202         $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
203         @chmod 444 $@
204
205 %.tex : %.lhs
206         @$(RM) $@
207         $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
208         @chmod 444 $@
209
210 %.texi : %.lhs
211         @$(RM) $@
212         $(LIT2TEXI) -S $(LIT2TEXI_OPTS) -o $@ $<
213         @chmod 444 $@
214
215 %.html : %.lhs
216         @$(RM) $@ 
217         $(LIT2TEXI) $(LIT2TEXI_OPTS) -o $(patsubst %.html,%.texi,$@) $<
218         $(TEXI2HTML) $(TEXI2HTML_OPTS) $(patsubst %.lhs,%.texi,$<) 
219         @touch $@
220
221 %.info:: %.texi
222         @$(RM) $@
223         $(MAKEINFO) $(MAKEINFO_OPTS) $< && $(POSTMAKEINFO) $@
224
225 %.hs : %.lhs
226         @$(RM) $@
227         $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
228         @chmod 444 $@
229
230 %.itxi : %.lhs
231         @$(RM) $@
232         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
233         @chmod 444 $@
234
235 %.ihtml : %.lhs
236         @$(RM) $@
237         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
238         @chmod 444 $@
239
240 %.itex : %.lhs
241         @$(RM) $@
242         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
243         @chmod 444 $@
244
245 %.tex : %.lhs
246         $(LIT2LATEX) -S -c $(LIT2LATEX_OPTS) -o $@ $<
247         $(HC) $(HC_OPTS) -c $< -o $@
248
249
250 %.itxi : %.lhc
251         @$(RM) $@
252         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
253         @chmod 444 $@
254
255 %.ihtml : %.lhc
256         @$(RM) $@
257         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
258         @chmod 444 $@
259
260 %.itex : %.lhc
261         @$(RM) $@
262         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
263         @chmod 444 $@
264
265 #
266 # Temporary, until either unlit is lifted out of ghc/
267 # or literate is properly set up locally -- SOF
268 #
269 %.prl : %.lprl
270         @$(RM) $@
271         $(UNLIT) $(UNLIT_OPTS) $< $@
272         @chmod 444 $@
273
274 %.itxi : %.lprl
275         @$(RM) $@
276         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
277         @chmod 444 $@
278
279 %.ihtml : %.lprl
280         @$(RM) $@
281         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
282         @chmod 444 $@
283
284 %.itex : %.lprl
285         @$(RM) $@
286         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
287         @chmod 444 $@
288
289 %.sh : %.lsh
290         @$(RM) $@
291         $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
292         @chmod 444 $@
293
294 %.itxi : %.lsh
295         @$(RM) $@
296         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
297         @chmod 444 $@
298
299 %.ihtml : %.lsh
300         @$(RM) $@
301         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
302         @chmod 444 $@
303
304 %.itex : %.lsh
305         @$(RM) $@
306         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
307         @chmod 444 $@
308
309 %.c : %.lc
310         @$(RM) $@
311         $(UNLIT) $< $@
312         @chmod 444 $@
313
314 %.itxi : %.lc
315         @$(RM) $@
316         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
317         @chmod 444 $@
318
319 %.ihtml : %.lc
320         @$(RM) $@
321         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
322         @chmod 444 $@
323
324 %.itex : %.lc
325         @$(RM) $@
326         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
327         @chmod 444 $@
328
329 %.h : %.lh
330         @$(RM) $@
331         $(UNLIT) $< $@
332         @chmod 444 $@
333
334 %.itxi : %.lh
335         @$(RM) $@
336         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
337         @chmod 444 $@
338
339 %.ihtml : %.lh
340         @$(RM) $@
341         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
342         @chmod 444 $@
343
344 %.itex : %.lh
345         @$(RM) $@
346         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
347         @chmod 444 $@
348
349 %.flex : %.lflex
350         @$(RM) $@
351         $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
352         @chmod 444 $@
353
354 %.itxi : %.lflex
355         @$(RM) $@
356         $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
357         @chmod 444 $@
358
359 %.ihtml : %.lflex
360         @$(RM) $@
361         $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
362         @chmod 444 $@
363
364 %.itex : %.lflex
365         @$(RM) $@
366         $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
367         @chmod 444 $@
368