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 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)))
42 $(HASKELL_PRE_COMPILE)
43 $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
44 $(HASKELL_POST_COMPILE)
48 $(HASKELL_PRE_COMPILE)
49 $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
50 $(HASKELL_POST_COMPILE)
54 $(HC) $(HC_OPTS) -C $< -o $@
56 %.$(way_)o : %.$(way_)hc
58 $(HASKELL_PRE_COMPILE)
59 $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
60 $(HASKELL_POST_COMPILE)
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).
76 %.$(way_)hi : %.$(way_)o
77 @if [ ! -f $@ ] ; then \
78 echo Panic! $< exists, but $@ does not. \
83 %.$(way_)hi : %.$(way_)hc
84 @if [ ! -f $@ ] ; then \
85 echo Panic! $< exists, but $@ does not. \
90 #-----------------------------------------------------------------------------
96 $(HAPPY) $(HAPPY_OPTS) -g $<
98 #-----------------------------------------------------------------------------
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 )
125 #-----------------------------------------------------------------------------
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
133 $(MV) y.tab.h $*.tab.h
137 #-----------------------------------------------------------------------------
138 # Runtest rules for calling $(HC) on a single-file Haskell program
141 $(TIME) $(RUNTEST) $(HC) $(RUNTEST_FLAGS) -o2 $*.stderr $<
144 #-----------------------------------------------------------------------------
145 # Doc processing suffix rules
157 expand $*.verb | $(VERBATIM) > $*.tex
160 @$(RM) $*.tex $*.verb-t.tex
162 expand $*.tib-t.tex | $(VERBATIM) > $*.tex
171 fig2dev -L latex $< $@
173 #-----------------------------------------------------------------------------
174 # Literate suffix rules
176 # ToDo: somehow macroize this lot. (if only!)
180 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
185 $(LIT2TEXT) -c $(LIT2TEXT_OPTS) -o $@ $<
190 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
195 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
199 # Produce stand-alone TEX documents
203 $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
208 $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $<
213 $(LIT2TEXI) -S $(LIT2TEXI_OPTS) -o $@ $<
218 $(LIT2TEXI) $(LIT2TEXI_OPTS) -o $(patsubst %.html,%.texi,$@) $<
219 $(TEXI2HTML) $(TEXI2HTML_OPTS) $(patsubst %.lhs,%.texi,$<)
224 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
229 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
234 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
239 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
243 $(LIT2LATEX) -S -c $(LIT2LATEX_OPTS) -o $@ $<
244 $(HC) $(HC_OPTS) -c $< -o $@
249 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
254 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
259 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
263 # Temporary, until either unlit is lifted out of ghc/
264 # or literate is properly set up locally -- SOF
268 $(UNLIT) $(UNLIT_OPTS) $< $@
273 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
278 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
283 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
288 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
293 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
298 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
303 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
313 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
318 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
323 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
333 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
338 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
343 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
348 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
353 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
358 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
363 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<