X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=mk%2Fsuffix.mk;h=b987bb830b9a33a61e99d9e66f95131f351fbde3;hb=c01ea09a334c91575916561452b2c391275daa93;hp=afe9f6c3c143462058e1fc70a8dd82c21a031f0b;hpb=1fb1ab5d53a09607e7f6d2450806760688396387;p=ghc-hetmet.git diff --git a/mk/suffix.mk b/mk/suffix.mk index afe9f6c..b987bb8 100644 --- a/mk/suffix.mk +++ b/mk/suffix.mk @@ -16,50 +16,62 @@ .SUFFIXES: -# However, if $(way) is set then we have to define $(way_) and $(_way) -# from it in the obvious fashion. -# This must be done here (or earlier), but not in target.mk with the other -# way management, because the pattern rules in this file take a snapshot of -# the value of $(way_) and $(_way), and it's no good setting them later! - -ifneq "$(way)" "" - way_ := $(way)_ - _way := _$(way) -endif +# This declaration tells GNU make to delete the target if it has +# changed and the command which created it exited with a non-zero exit +# code. + +.DELETE_ON_ERROR: #----------------------------------------------------------------------------- # Haskell Suffix Rules -HASKELL_SPLIT_PRE= \ - if [ ! -d $(basename $@) ]; then mkdir $(basename $@) ; else exit 0; fi; \ - find $(basename $@) -name '*.$(way_)o' -print | xargs $(RM) __rm_food; -HASKELL_SPLIT_POST= touch $@ -HASKELL_PRE_COMPILE=$(patsubst %,$(HASKELL_SPLIT_PRE),$(filter -split-objs,$(HC_OPTS))) -HASKELL_POST_COMPILE=$(patsubst %,$(HASKELL_SPLIT_POST),$(filter -split-objs,$(HC_OPTS))) +# Turn off all the Haskell suffix rules if we're booting from .hc +# files. The file bootstrap.mk contains alternative suffix rules in +# this case. +ifneq "$(BootingFromHc)" "YES" + +# The $(odir) support is for building GHC, where we need to build three +# different versions from the same sources. See ghc/compiler/Makefile. +ifneq "$(odir)" "" +odir_ = $(odir)/ +else +odir_ = +endif -%.$(way_)o : %.hs - $(RM) $@ - $(HASKELL_PRE_COMPILE) - $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@)) - $(HASKELL_POST_COMPILE) - -%.$(way_)o : %.lhs - $(RM) $@ - $(HASKELL_PRE_COMPILE) - $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@)) - $(HASKELL_POST_COMPILE) - -%.$(way_)hc : %.lhs +$(odir_)%.$(way_)o : %.hs + $(HC_PRE_OPTS) + $(HC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi + $(HC_POST_OPTS) + +$(odir_)%.$(way_)o : %.lhs + $(HC_PRE_OPTS) + $(HC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi + $(HC_POST_OPTS) + +$(odir_)%.$(way_)hc : %.lhs $(RM) $@ $(HC) $(HC_OPTS) -C $< -o $@ - -%.$(way_)o : %.$(way_)hc + +$(odir_)%.$(way_)hc : %.hs $(RM) $@ - $(HASKELL_PRE_COMPILE) - $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@)) - $(HASKELL_POST_COMPILE) + $(HC) $(HC_OPTS) -C $< -o $@ -%.$(way_)hc : %.lhc +$(odir_)%.$(way_)o : %.$(way_)hc + $(HC_PRE_OPTS) + $(HC) $(HC_OPTS) -c $< -o $@ + $(HC_POST_OPTS) + +$(odir_)%.$(way_)o : %.hc + $(HC_PRE_OPTS) + $(HC) $(HC_OPTS) -c $< -o $@ + $(HC_POST_OPTS) + +$(odir_)%.$(way_)s : %.$(way_)hc + $(HC_PRE_OPTS) + $(HC) $(HC_OPTS) -S $< -o $@ + $(HC_POST_OPTS) + +$(odir_)%.$(way_)hc : %.lhc @$(RM) $@ $(UNLIT) $< $@ @chmod 444 $@ @@ -75,52 +87,116 @@ HASKELL_POST_COMPILE=$(patsubst %,$(HASKELL_SPLIT_POST),$(filter -split-objs,$(H %.$(way_)hi : %.$(way_)o @if [ ! -f $@ ] ; then \ - echo Panic! $< exists, but $@ does not. \ + echo Panic! $< exists, but $@ does not.; \ exit 1; \ else exit 0 ; \ fi -%.$(way_)hi : %.$(way_)hc +$(odir_)%.$(way_)hi : %.$(way_)hc @if [ ! -f $@ ] ; then \ - echo Panic! $< exists, but $@ does not. \ + echo Panic! $< exists, but $@ does not.; \ exit 1; \ else exit 0 ; \ fi +endif # BootingViaC + #----------------------------------------------------------------------------- # Happy Suffix Rules # -.PRECIOUS: %.hs +.SECONDARY: %.hs %.hs : %.ly - $(HAPPY) $(HAPPY_OPTS) -g $< + $(HAPPY) $(HAPPY_OPTS) $< + +%.hs : %.y + $(HAPPY) $(HAPPY_OPTS) $< + +#----------------------------------------------------------------------------- +# hsc2hs Suffix Rules +# +ifneq "$(BootingFromHc)" "YES" +%_hsc.c %_hsc.h %.hs : %.hsc + $(HSC2HS) $(HSC2HS_OPTS) $< + @touch $(patsubst %.hsc,%_hsc.c,$<) +endif #----------------------------------------------------------------------------- # Lx Suffix Rules # -.PRECIOUS: %.hs %.hs : %.lx $(LX) $(LX_OPTS) $< #----------------------------------------------------------------------------- +# Green-card Suffix Rules +# + +.PRECIOUS: %.gc + +%.hs %_stub_ffi.c %_stub_ffi.h : %.gc + $(GREENCARD) $(GC_OPTS) $< + +%.lhs : %.gc + $(GREENCARD) $(GC_OPTS) $< -o $@ + +%.gc : %.pgc + $(CPP) $(GC_CPP_OPTS) $< | perl -pe 's#\\n#\n#g' > $@ + +#----------------------------------------------------------------------------- # C-related suffix rules -%.$(way_)o : %.$(way_)s +ifeq "$(UseGhcForCc)" "YES" + +$(odir_)%.$(way_)o : %.c + @$(RM) $@ + $(HC) $(GHC_CC_OPTS) -c $< -o $@ + +$(odir_)%.$(way_)o : %.$(way_)s + @$(RM) $@ + $(HC) $(GHC_CC_OPTS) -c $< -o $@ + +$(odir_)%.$(way_)o : %.S + @$(RM) $@ + $(HC) $(GHC_CC_OPTS) -c $< -o $@ + +$(odir_)%.$(way_)s : %.c + @$(RM) $@ + $(HC) $(GHC_CC_OPTS) -S $< -o $@ + +else + +$(odir_)%.$(way_)o : %.c @$(RM) $@ - $(AS) $(AS_OPTS) -o $@ $< || ( $(RM) $@ && exit 1 ) + $(CC) $(CC_OPTS) -c $< -o $@ + +$(odir_)%.$(way_)o : %.$(way_)s + @$(RM) $@ + $(AS) $(AS_OPTS) -o $@ $< -%.$(way_)o : %.c +$(odir_)%.$(way_)o : %.S @$(RM) $@ $(CC) $(CC_OPTS) -c $< -o $@ -#%.$(way_)s : %.c -# @$(RM) $@ -# $(CC) $(CC_OPTS) -S $< -o $@ +$(odir_)%.$(way_)s : %.c + @$(RM) $@ + $(CC) $(CC_OPTS) -S $< -o $@ + +endif + +# stubs are automatically generated and compiled by GHC +%_stub.$(way_)o: %.o + @: + +# ----------------------------------------------------------------------------- +# Flex/lex %.c : %.flex @$(RM) $@ - $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 ) + $(FLEX) -t $(FLEX_OPTS) $< > $@ +%.c : %.lex + @$(RM) $@ + $(FLEX) -t $(FLEX_OPTS) $< > $@ #----------------------------------------------------------------------------- # Yacc stuff @@ -137,25 +213,18 @@ HASKELL_POST_COMPILE=$(patsubst %,$(HASKELL_SPLIT_POST),$(filter -split-objs,$(H #----------------------------------------------------------------------------- # Runtest rules for calling $(HC) on a single-file Haskell program -%.hs : %.runtest - $(TIME) $(RUNTEST) $(HC) $(RUNTEST_FLAGS) -o2 $*.stderr $< - +%.runtest : %.hs + $(TIME) $(RUNTEST) $(HC) $(RUNTEST_OPTS) $< #----------------------------------------------------------------------------- # Doc processing suffix rules - -%.dvi : %.tex - @$(RM) $@ - $(LTX) $< - +# +# ToDo: make these more robust +# %.ps : %.dvi @$(RM) $@ dvips $< -o $@ -%.tex : %.verb - @$(RM) $*.tex - expand $*.verb | $(VERBATIM) > $*.tex - %.tex : %.tib @$(RM) $*.tex $*.verb-t.tex $(TIB) $*.tib @@ -171,195 +240,71 @@ HASKELL_POST_COMPILE=$(patsubst %,$(HASKELL_SPLIT_POST),$(filter -split-objs,$(H fig2dev -L latex $< $@ #----------------------------------------------------------------------------- -# Literate suffix rules - -# ToDo: somehow macroize this lot. (if only!) - -%.itxi : %.lit - @$(RM) $@ - $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ - -%.txt : %.lit - @$(RM) $@ - $(LIT2TEXT) -c $(LIT2TEXT_OPTS) -o $@ $< - @chmod 444 $@ - -%.ihtml : %.lit - @$(RM) $@ - $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $< - @chmod 444 $@ - -%.itex : %.lit - @$(RM) $@ - $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $< - @chmod 444 $@ - +# SGML suffix rules # -# Produce stand-alone TEX documents -# -%.tex : %.itex +%.dvi : %.sgml @$(RM) $@ - $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $< - @chmod 444 $@ + $(SGML2DVI) $(SGML2DVI_OPTS) $< -%.tex : %.lhs +%.ps : %.sgml @$(RM) $@ - $(LIT2LATEX) -S $(LIT2LATEX_OPTS) -o $@ $< - @chmod 444 $@ + $(SGML2PS) $(SGML2PS_OPTS) $< -%.texi : %.lhs +%.html : %.sgml @$(RM) $@ - $(LIT2TEXI) -S $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ - -%.html : %.lhs - @$(RM) $@ - $(LIT2TEXI) $(LIT2TEXI_OPTS) -o $(patsubst %.html,%.texi,$@) $< - $(TEXI2HTML) $(TEXI2HTML_OPTS) $(patsubst %.lhs,%.texi,$<) +# $(PERL) $(COLLATEINDEX) -N -o index.sgml +# $(JADE) -t sgml -V html-index -d $(SGMLSTYLESHEET) -c $(DOCBOOK_CATALOG) $< +# $(PERL) $(COLLATEINDEX) -N -o index.sgml + $(SGML2HTML) $(SGML2HTML_OPTS) $< +# touch the .html file so that it is seen to be built @touch $@ -%.hs : %.lhs - @$(RM) $@ - $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $< - @chmod 444 $@ - -%.itxi : %.lhs +%.html : %.tex @$(RM) $@ - $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ + $(HEVEA) $(HEVEA_OPTS) $(patsubst %.tex,%.hva,$<) $< + $(HEVEA) $(HEVEA_OPTS) $(patsubst %.tex,%.hva,$<) $< + $(HACHA) $(HACHA_OPTS) $(patsubst %.tex,%.html,$<) +# Run HeVeA twice to resolve labels -%.ihtml : %.lhs +%.rtf : %.sgml @$(RM) $@ - $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $< - @chmod 444 $@ + $(SGML2RTF) $(SGML2RTF_OPTS) $< -%.itex : %.lhs +%.pdf : %.sgml @$(RM) $@ - $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $< - @chmod 444 $@ + $(SGML2PDF) $(SGML2PDF_OPTS) $< -%.tex : %.lhs - $(LIT2LATEX) -S -c $(LIT2LATEX_OPTS) -o $@ $< - $(HC) $(HC_OPTS) -c $< -o $@ - - -%.itxi : %.lhc - @$(RM) $@ - $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ - -%.ihtml : %.lhc - @$(RM) $@ - $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $< - @chmod 444 $@ - -%.itex : %.lhc - @$(RM) $@ - $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $< - @chmod 444 $@ +#----------------------------------------------------------------------------- +# Literate suffix rules -# -# Temporary, until either unlit is lifted out of ghc/ -# or literate is properly set up locally -- SOF -# %.prl : %.lprl @$(RM) $@ $(UNLIT) $(UNLIT_OPTS) $< $@ @chmod 444 $@ -%.itxi : %.lprl - @$(RM) $@ - $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ - -%.ihtml : %.lprl - @$(RM) $@ - $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $< - @chmod 444 $@ - -%.itex : %.lprl - @$(RM) $@ - $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $< - @chmod 444 $@ - -%.sh : %.lsh - @$(RM) $@ - $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $< - @chmod 444 $@ - -%.itxi : %.lsh - @$(RM) $@ - $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ - -%.ihtml : %.lsh - @$(RM) $@ - $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $< - @chmod 444 $@ - -%.itex : %.lsh - @$(RM) $@ - $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $< - @chmod 444 $@ - %.c : %.lc @$(RM) $@ - $(UNLIT) $< $@ - @chmod 444 $@ - -%.itxi : %.lc - @$(RM) $@ - $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ - -%.ihtml : %.lc - @$(RM) $@ - $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $< - @chmod 444 $@ - -%.itex : %.lc - @$(RM) $@ - $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $< + $(UNLIT) $(UNLIT_OPTS) $< $@ @chmod 444 $@ %.h : %.lh @$(RM) $@ - $(UNLIT) $< $@ - @chmod 444 $@ - -%.itxi : %.lh - @$(RM) $@ - $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ - -%.ihtml : %.lh - @$(RM) $@ - $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $< - @chmod 444 $@ - -%.itex : %.lh - @$(RM) $@ - $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $< + $(UNLIT) $(UNLIT_OPTS) $< $@ @chmod 444 $@ -%.flex : %.lflex - @$(RM) $@ - $(LIT2PGM) $(LIT2PGM_OPTS) -o $@ $< - @chmod 444 $@ +#----------------------------------------------------------------------------- +# Win32 resource files +# +# The default is to use the GNU resource compiler. +# -%.itxi : %.lflex +%.$(way_)o : %.$(way_)rc @$(RM) $@ - $(LIT2TEXI) -c $(LIT2TEXI_OPTS) -o $@ $< - @chmod 444 $@ + windres $< $@ -%.ihtml : %.lflex - @$(RM) $@ - $(LIT2HTML) -c $(LIT2HTML_OPTS) -o $@ $< - @chmod 444 $@ +#----------------------------------------------------------------------------- +# Preprocessor suffix rule -%.itex : %.lflex +% : %.pp @$(RM) $@ - $(LIT2LATEX) -c $(LIT2LATEX_OPTS) -o $@ $< - @chmod 444 $@ - + $(CPP) $(CPP_OPTS) -x c $< | $(SED) -e '/^#/d' > $@