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