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 #-----------------------------------------------------------------------------
26 # Haskell Suffix Rules
28 # Turn off all the Haskell suffix rules if we're booting from .hc
29 # files. The file bootstrap.mk contains alternative suffix rules in
31 ifneq "$(BootingFromHc)" "YES"
33 # The $(odir) support is for building GHC, where we need to build three
34 # different versions from the same sources. See ghc/compiler/Makefile.
41 $(odir_)%.$(way_)o : %.hs
43 $(HC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi
46 $(odir_)%.$(way_)o : %.lhs
48 $(HC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi
51 $(odir_)%.$(way_)hc : %.lhs
53 $(HC) $(HC_OPTS) -C $< -o $@
55 $(odir_)%.$(way_)hc : %.hs
57 $(HC) $(HC_OPTS) -C $< -o $@
59 $(odir_)%.$(way_)o : %.$(way_)hc
61 $(HC) $(HC_OPTS) -c $< -o $@
64 $(odir_)%.$(way_)o : %.hc
66 $(HC) $(HC_OPTS) -c $< -o $@
69 $(odir_)%.$(way_)s : %.$(way_)hc
71 $(HC) $(HC_OPTS) -S $< -o $@
74 $(odir_)%.$(way_)hc : %.lhc
80 # Here's an interesting rule!
81 # The .hi file depends on the .o file,
82 # so if the .hi file is dated earlier than the .o file (commonly the case,
83 # when interfaces are stable) this rule just makes sure that the .o file,
84 # is up to date. Then it does nothing to generate the .hi file from the
85 # .o file, because the act of making sure the .o file is up to date also
86 # updates the .hi file (if necessary).
88 %.$(way_)hi : %.$(way_)o
89 @if [ ! -f $@ ] ; then \
90 echo Panic! $< exists, but $@ does not.; \
95 $(odir_)%.$(way_)hi : %.$(way_)hc
96 @if [ ! -f $@ ] ; then \
97 echo Panic! $< exists, but $@ does not.; \
104 #-----------------------------------------------------------------------------
110 $(HAPPY) $(HAPPY_OPTS) $<
113 $(HAPPY) $(HAPPY_OPTS) $<
115 #-----------------------------------------------------------------------------
116 # hsc2hs Suffix Rules
118 ifneq "$(BootingFromHc)" "YES"
119 %_hsc.c %_hsc.h %.hs : %.hsc
120 $(HSC2HS) $(HSC2HS_OPTS) $<
121 @touch $(patsubst %.hsc,%_hsc.c,$<)
124 #-----------------------------------------------------------------------------
131 #-----------------------------------------------------------------------------
132 # Green-card Suffix Rules
137 %.hs %_stub_ffi.c %_stub_ffi.h : %.gc
138 $(GREENCARD) $(GC_OPTS) $< -o $@
141 $(GREENCARD) $(GC_OPTS) $< -o $@
144 $(CPP) $(GC_CPP_OPTS) $< | perl -pe 's#\\n#\n#g' > $@
146 #-----------------------------------------------------------------------------
147 # C-related suffix rules
149 ifeq "$(UseGhcForCc)" "YES"
151 $(odir_)%.$(way_)o : %.$(way_)s
153 $(HC) $(GHC_CC_OPTS) -c $< -o $@
155 $(odir_)%.$(way_)o : %.c
157 $(HC) $(GHC_CC_OPTS) -c $< -o $@
159 $(odir_)%.$(way_)o : %.S
161 $(HC) $(GHC_CC_OPTS) -c $< -o $@
163 $(odir_)%.$(way_)s : %.c
165 $(HC) $(GHC_CC_OPTS) -S $< -o $@
169 $(odir_)%.$(way_)o : %.$(way_)s
171 $(AS) $(AS_OPTS) -o $@ $<
173 $(odir_)%.$(way_)o : %.c
175 $(CC) $(CC_OPTS) -c $< -o $@
177 $(odir_)%.$(way_)o : %.S
179 $(CC) $(CC_OPTS) -c $< -o $@
181 $(odir_)%.$(way_)s : %.c
183 $(CC) $(CC_OPTS) -S $< -o $@
187 # stubs are automatically generated and compiled by GHC
191 # -----------------------------------------------------------------------------
196 $(FLEX) -t $(FLEX_OPTS) $< > $@
199 $(FLEX) -t $(FLEX_OPTS) $< > $@
201 #-----------------------------------------------------------------------------
204 %.tab.c %.tab.h : %.y
205 @$(RM) $*.tab.h $*.tab.c y.tab.c y.tab.h y.output
206 $(YACC) $(YACC_OPTS) $<
207 $(MV) y.tab.c $*.tab.c
209 $(MV) y.tab.h $*.tab.h
213 #-----------------------------------------------------------------------------
214 # Runtest rules for calling $(HC) on a single-file Haskell program
217 $(TIME) $(RUNTEST) $(HC) $(RUNTEST_OPTS) $<
219 #-----------------------------------------------------------------------------
220 # Doc processing suffix rules
222 # ToDo: make these more robust
229 @$(RM) $*.tex $*.verb-t.tex
231 expand $*.tib-t.tex | $(VERBATIM) > $*.tex
240 fig2dev -L latex $< $@
242 #-----------------------------------------------------------------------------
247 $(SGML2DVI) $(SGML2DVI_OPTS) $<
251 $(SGML2PS) $(SGML2PS_OPTS) $<
255 # $(PERL) $(COLLATEINDEX) -N -o index.sgml
256 # $(JADE) -t sgml -V html-index -d $(SGMLSTYLESHEET) -c $(DOCBOOK_CATALOG) $<
257 # $(PERL) $(COLLATEINDEX) -N -o index.sgml
258 $(SGML2HTML) $(SGML2HTML_OPTS) $<
259 # touch the .html file so that it is seen to be built
264 $(HEVEA) $(HEVEA_OPTS) $(patsubst %.tex,%.hva,$<) $<
265 $(HEVEA) $(HEVEA_OPTS) $(patsubst %.tex,%.hva,$<) $<
266 $(HACHA) $(HACHA_OPTS) $(patsubst %.tex,%.html,$<)
267 # Run HeVeA twice to resolve labels
271 $(SGML2RTF) $(SGML2RTF_OPTS) $<
275 $(SGML2PDF) $(SGML2PDF_OPTS) $<
277 #-----------------------------------------------------------------------------
278 # Literate suffix rules
282 $(UNLIT) $(UNLIT_OPTS) $< $@
287 $(UNLIT) $(UNLIT_OPTS) $< $@
292 $(UNLIT) $(UNLIT_OPTS) $< $@
295 #-----------------------------------------------------------------------------
296 # Win32 resource files
298 # The default is to use the GNU resource compiler.
301 %.$(way_)o : %.$(way_)rc
305 #-----------------------------------------------------------------------------
306 # Preprocessor suffix rule
310 $(CPP) $(CPP_OPTS) -x c $< | $(SED) -e '/^#/d' > $@