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 # This declaration tells GNU make to delete the target if it has
20 # changed and the command which created it exited with a non-zero exit
25 # However, if $(way) is set then we have to define $(way_) and $(_way)
26 # from it in the obvious fashion.
27 # This must be done here (or earlier), but not in target.mk with the other
28 # way management, because the pattern rules in this file take a snapshot of
29 # the value of $(way_) and $(_way), and it's no good setting them later!
36 #-----------------------------------------------------------------------------
37 # Haskell Suffix Rules
39 # Turn off all the Haskell suffix rules if we're booting from .hc
40 # files. The file bootstrap.mk contains alternative suffix rules in
42 ifneq "$(BootingFromHc)" "YES"
44 # The $(odir) support is for building GHC, where we need to build three
45 # different versions from the same sources. See ghc/compiler/Makefile.
52 $(odir_)%.$(way_)o : %.hs
54 $(HC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi
57 $(odir_)%.$(way_)o : %.lhs
59 $(HC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi
62 $(odir_)%.$(way_)hc : %.lhs
64 $(HC) $(HC_OPTS) -C $< -o $@
66 $(odir_)%.$(way_)hc : %.hs
68 $(HC) $(HC_OPTS) -C $< -o $@
70 $(odir_)%.$(way_)o : %.$(way_)hc
72 $(HC) $(HC_OPTS) -c $< -o $@
75 $(odir_)%.$(way_)o : %.hc
77 $(HC) $(HC_OPTS) -c $< -o $@
80 $(odir_)%.$(way_)s : %.$(way_)hc
82 $(HC) $(HC_OPTS) -S $< -o $@
85 $(odir_)%.$(way_)hc : %.lhc
91 # Here's an interesting rule!
92 # The .hi file depends on the .o file,
93 # so if the .hi file is dated earlier than the .o file (commonly the case,
94 # when interfaces are stable) this rule just makes sure that the .o file,
95 # is up to date. Then it does nothing to generate the .hi file from the
96 # .o file, because the act of making sure the .o file is up to date also
97 # updates the .hi file (if necessary).
99 %.$(way_)hi : %.$(way_)o
100 @if [ ! -f $@ ] ; then \
101 echo Panic! $< exists, but $@ does not.; \
106 $(odir_)%.$(way_)hi : %.$(way_)hc
107 @if [ ! -f $@ ] ; then \
108 echo Panic! $< exists, but $@ does not.; \
115 #-----------------------------------------------------------------------------
121 $(HAPPY) $(HAPPY_OPTS) $<
124 $(HAPPY) $(HAPPY_OPTS) $<
126 #-----------------------------------------------------------------------------
127 # hsc2hs Suffix Rules
129 ifneq "$(BootingFromHc)" "YES"
130 %_hsc.c %_hsc.h %.hs : %.hsc
131 $(HSC2HS) $(HSC2HS_OPTS) $<
132 @touch $(patsubst %.hsc,%_hsc.c,$<)
135 #-----------------------------------------------------------------------------
142 #-----------------------------------------------------------------------------
143 # Green-card Suffix Rules
149 $(GREENCARD) $(GC_OPTS) $< -o $@
152 $(GREENCARD) $(GC_OPTS) $< -o $@
155 $(CPP) $(GC_CPP_OPTS) $< | perl -pe 's#\\n#\n#g' > $@
157 #-----------------------------------------------------------------------------
158 # C-related suffix rules
160 ifeq "$(UseGhcForCc)" "YES"
162 $(odir_)%.$(way_)o : %.$(way_)s
164 $(HC) $(GHC_CC_OPTS) -c $< -o $@
166 $(odir_)%.$(way_)o : %.c
168 $(HC) $(GHC_CC_OPTS) -c $< -o $@
170 $(odir_)%.$(way_)o : %.S
172 $(HC) $(GHC_CC_OPTS) -c $< -o $@
174 $(odir_)%.$(way_)s : %.c
176 $(HC) $(GHC_CC_OPTS) -S $< -o $@
180 $(odir_)%.$(way_)o : %.$(way_)s
182 $(AS) $(AS_OPTS) -o $@ $<
184 $(odir_)%.$(way_)o : %.c
186 $(CC) $(CC_OPTS) -c $< -o $@
188 $(odir_)%.$(way_)o : %.S
190 $(CC) $(CC_OPTS) -c $< -o $@
192 $(odir_)%.$(way_)s : %.c
194 $(CC) $(CC_OPTS) -S $< -o $@
198 # stubs are automatically generated and compiled by GHC
202 # -----------------------------------------------------------------------------
207 $(FLEX) -t $(FLEX_OPTS) $< > $@
210 $(FLEX) -t $(FLEX_OPTS) $< > $@
212 #-----------------------------------------------------------------------------
215 %.tab.c %.tab.h : %.y
216 @$(RM) $*.tab.h $*.tab.c y.tab.c y.tab.h y.output
217 $(YACC) $(YACC_OPTS) $<
218 $(MV) y.tab.c $*.tab.c
220 $(MV) y.tab.h $*.tab.h
224 #-----------------------------------------------------------------------------
225 # Runtest rules for calling $(HC) on a single-file Haskell program
228 $(TIME) $(RUNTEST) $(HC) $(RUNTEST_OPTS) $<
230 #-----------------------------------------------------------------------------
231 # Doc processing suffix rules
233 # ToDo: make these more robust
240 @$(RM) $*.tex $*.verb-t.tex
242 expand $*.tib-t.tex | $(VERBATIM) > $*.tex
251 fig2dev -L latex $< $@
253 #-----------------------------------------------------------------------------
258 $(SGML2DVI) $(SGML2DVI_OPTS) $<
262 $(SGML2PS) $(SGML2PS_OPTS) $<
266 # $(PERL) $(COLLATEINDEX) -N -o index.sgml
267 # $(JADE) -t sgml -V html-index -d $(SGMLSTYLESHEET) -c $(DOCBOOK_CATALOG) $<
268 # $(PERL) $(COLLATEINDEX) -N -o index.sgml
269 $(SGML2HTML) $(SGML2HTML_OPTS) $<
270 # touch the .html file so that it is seen to be built
275 $(HEVEA) $(HEVEA_OPTS) $(patsubst %.tex,%.hva,$<) $<
276 $(HEVEA) $(HEVEA_OPTS) $(patsubst %.tex,%.hva,$<) $<
277 $(HACHA) $(HACHA_OPTS) $(patsubst %.tex,%.html,$<)
278 # Run HeVeA twice to resolve labels
282 $(SGML2RTF) $(SGML2RTF_OPTS) $<
286 $(SGML2PDF) $(SGML2PDF_OPTS) $<
288 #-----------------------------------------------------------------------------
289 # Literate suffix rules
293 $(UNLIT) $(UNLIT_OPTS) $< $@
298 $(UNLIT) $(UNLIT_OPTS) $< $@
303 $(UNLIT) $(UNLIT_OPTS) $< $@
306 #-----------------------------------------------------------------------------
307 # Win32 resource files
309 # The default is to use the GNU resource compiler.
312 %.$(way_)o : %.$(way_)rc
316 #-----------------------------------------------------------------------------
317 # Preprocessor suffix rule
321 $(CPP) $(CPP_OPTS) -x c $< | $(SED) -e '/^#/d' > $@