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 #-----------------------------------------------------------------------------
103 #-----------------------------------------------------------------------------
104 # C-related suffix rules
106 %.$(way_)o : %.$(way_)s
108 $(AS) $(AS_OPTS) -o $@ $< || ( $(RM) $@ && exit 1 )
112 $(CC) $(CC_OPTS) -c $< -o $@
116 # $(CC) $(CC_OPTS) -S $< -o $@
120 $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
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 $(MAKEINFO) $(MAKEINFO_OPTS) $< && $(POSTMAKEINFO) $@
228 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
233 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
238 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
243 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
247 $(LIT2LATEX) -S -c $(LIT2LATEX_OPTS) -o $@ $<
248 $(HC) $(HC_OPTS) -c $< -o $@
253 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
258 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
263 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
267 # Temporary, until either unlit is lifted out of ghc/
268 # or literate is properly set up locally -- SOF
272 $(UNLIT) $(UNLIT_OPTS) $< $@
277 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
282 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
287 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
292 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
297 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
302 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
307 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
317 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
322 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
327 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
337 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
342 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
347 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<
352 $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $<
357 $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $<
362 $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $<
367 $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $<