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 $@
54 %.$(way_)o : %.$(way_)hc
55 $(HASKELL_PRE_COMPILE)
56 $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
57 $(HASKELL_POST_COMPILE)
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).
73 %.$(way_)hi : %.$(way_)o
74 @if [ ! -f $@ ] ; then \
75 echo Panic! $< exists, but $@ does not. \
80 %.$(way_)hi : %.$(way_)hc
81 @if [ ! -f $@ ] ; then \
82 echo Panic! $< exists, but $@ does not. \
87 #-----------------------------------------------------------------------------
93 $(HAPPY) $(HAPPY_OPTS) -g $<
95 #-----------------------------------------------------------------------------
102 #-----------------------------------------------------------------------------
103 # C-related suffix rules
105 %.$(way_)o : %.$(way_)s
107 $(AS) $(AS_OPTS) -o $@ $< || ( $(RM) $@ && exit 1 )
111 $(CC) $(CC_OPTS) -c $< -o $@
115 # $(CC) $(CC_OPTS) -S $< -o $@
119 $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
122 $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
124 #-----------------------------------------------------------------------------
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
132 $(MV) y.tab.h $*.tab.h
136 #-----------------------------------------------------------------------------
137 # Runtest rules for calling $(HC) on a single-file Haskell program
140 $(TIME) $(RUNTEST) $(HC) $(RUNTEST_FLAGS) -o2 $*.stderr $<
143 #-----------------------------------------------------------------------------
144 # Doc processing suffix rules
156 expand $*.verb | $(VERBATIM) > $*.tex
159 @$(RM) $*.tex $*.verb-t.tex
161 expand $*.tib-t.tex | $(VERBATIM) > $*.tex
170 fig2dev -L latex $< $@
172 #-----------------------------------------------------------------------------
173 # Literate suffix rules
175 # ToDo: somehow macroize this lot. (if only!)
179 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
184 $(LIT2TEXT) -c $(LIT2TEXT_OPTS) -o $@ $<
189 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
194 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
198 # Produce stand-alone TEX documents
202 $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
207 $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
212 $(LIT2TEXI) -S $(LIT2TEXI_OPTS) -o $@ $<
217 $(LIT2TEXI) $(LIT2TEXI_OPTS) -o $(patsubst %.html,%.texi,$@) $<
218 $(TEXI2HTML) $(TEXI2HTML_OPTS) $(patsubst %.lhs,%.texi,$<)
223 $(MAKEINFO) $(MAKEINFO_OPTS) $< && $(POSTMAKEINFO) $@
227 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
232 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
237 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
242 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
246 $(LIT2LATEX) -S -c $(LIT2LATEX_OPTS) -o $@ $<
247 $(HC) $(HC_OPTS) -c $< -o $@
252 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
257 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
262 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
266 # Temporary, until either unlit is lifted out of ghc/
267 # or literate is properly set up locally -- SOF
271 $(UNLIT) $(UNLIT_OPTS) $< $@
276 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
281 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
286 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
291 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
296 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
301 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
306 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
316 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
321 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
326 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
336 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
341 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
346 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
351 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
356 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
361 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
366 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<