1 #################################################################################
5 # Suffix rules for fptools
7 #################################################################################
10 # This file contain the default suffix rules for all the fptools projects.
14 # No need to define .SUFFIXES because we don't use any suffix rules
15 # Instead we use gmake's pattern rules exlusively
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!
30 #-----------------------------------------------------------------------------
31 # Haskell Suffix Rules
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)))
41 $(HASKELL_PRE_COMPILE)
42 $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
43 $(HASKELL_POST_COMPILE)
46 $(HASKELL_PRE_COMPILE)
47 $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
48 $(HASKELL_POST_COMPILE)
52 $(HC) $(HC_OPTS) -C $< -o $@
56 $(HC) $(HC_OPTS) -C $< -o $@
58 %.$(way_)o : %.$(way_)hc
59 $(HASKELL_PRE_COMPILE)
60 $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
61 $(HASKELL_POST_COMPILE)
69 # Here's an interesting rule!
70 # The .hi file depends on the .o file,
71 # so if the .hi file is dated earlier than the .o file (commonly the case,
72 # when interfaces are stable) this rule just makes sure that the .o file,
73 # is up to date. Then it does nothing to generate the .hi file from the
74 # .o file, because the act of making sure the .o file is up to date also
75 # updates the .hi file (if necessary).
77 %.$(way_)hi : %.$(way_)o
78 @if [ ! -f $@ ] ; then \
79 echo Panic! $< exists, but $@ does not. \
84 %.$(way_)hi : %.$(way_)hc
85 @if [ ! -f $@ ] ; then \
86 echo Panic! $< exists, but $@ does not. \
91 #-----------------------------------------------------------------------------
97 $(HAPPY) $(HAPPY_OPTS) -g $<
99 #-----------------------------------------------------------------------------
106 #-----------------------------------------------------------------------------
107 # C-related suffix rules
109 %.$(way_)o : %.$(way_)s
111 $(AS) $(AS_OPTS) -o $@ $< || ( $(RM) $@ && exit 1 )
115 $(CC) $(CC_OPTS) -c $< -o $@
119 # $(CC) $(CC_OPTS) -S $< -o $@
123 $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
126 $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
128 #-----------------------------------------------------------------------------
131 %.tab.c %.tab.h : %.y
132 @$(RM) $*.tab.h $*.tab.c y.tab.c y.tab.h y.output
133 $(YACC) $(YACC_OPTS) $<
134 $(MV) y.tab.c $*.tab.c
136 $(MV) y.tab.h $*.tab.h
140 #-----------------------------------------------------------------------------
141 # Runtest rules for calling $(HC) on a single-file Haskell program
144 $(TIME) $(RUNTEST) $(HC) $(RUNTEST_FLAGS) -o2 $*.stderr $<
147 #-----------------------------------------------------------------------------
148 # Doc processing suffix rules
160 expand $*.verb | $(VERBATIM) > $*.tex
163 @$(RM) $*.tex $*.verb-t.tex
165 expand $*.tib-t.tex | $(VERBATIM) > $*.tex
174 fig2dev -L latex $< $@
176 #-----------------------------------------------------------------------------
177 # Literate suffix rules
179 # ToDo: somehow macroize this lot. (if only!)
183 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
188 $(LIT2TEXT) $(LIT2TEXT_OPTS) -o $@ $<
193 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
198 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
202 # Produce stand-alone TEX documents
206 $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
211 $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
216 $(LIT2TEXI) -S $(LIT2TEXI_OPTS) -o $@ $<
221 $(LIT2TEXI) $(LIT2TEXI_OPTS) -o $(patsubst %.html,%.texi,$@) $<
222 $(TEXI2HTML) $(TEXI2HTML_OPTS) $(patsubst %.lhs,%.texi,$<)
227 $(MAKEINFO) $(MAKEINFO_OPTS) $< && $(POSTMAKEINFO) $@
231 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
236 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
241 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
246 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
250 $(LIT2LATEX) -S -c $(LIT2LATEX_OPTS) -o $@ $<
251 $(HC) $(HC_OPTS) -c $< -o $@
256 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
261 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
266 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
270 # Temporary, until either unlit is lifted out of ghc/
271 # or literate is properly set up locally -- SOF
275 $(UNLIT) $(UNLIT_OPTS) $< $@
280 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
285 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
290 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
295 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
300 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
305 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
310 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
320 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
325 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
330 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
340 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
345 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
350 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
355 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
360 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
365 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
370 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<