X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=mk%2Fsuffix.mk;h=cdbefdd771c8e3cf72f8643d161c95327d1e36af;hb=145c7ebddb14323738902ad726cd339eb50e03d4;hp=96a04033f2df532abf23cb85f41f4d71bb21c65a;hpb=57c3ca2603ef0f2358d8d246bff1dd47ef97e843;p=ghc-hetmet.git diff --git a/mk/suffix.mk b/mk/suffix.mk index 96a0403..cdbefdd 100644 --- a/mk/suffix.mk +++ b/mk/suffix.mk @@ -16,6 +16,12 @@ .SUFFIXES: +# 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: + # 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 @@ -84,14 +90,14 @@ ifneq "$(BootingFromHc)" "YES" %.$(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 @if [ ! -f $@ ] ; then \ - echo Panic! $< exists, but $@ does not. \ + echo Panic! $< exists, but $@ does not.; \ exit 1; \ else exit 0 ; \ fi @@ -101,7 +107,7 @@ endif # BootingViaC #----------------------------------------------------------------------------- # Happy Suffix Rules # -.PRECIOUS: %.hs +.SECONDARY: %.hs %.hs : %.ly $(HAPPY) $(HAPPY_OPTS) $< @@ -114,7 +120,8 @@ endif # BootingViaC # ifneq "$(BootingFromHc)" "YES" %_hsc.c %_hsc.h %.hs : %.hsc - $(HSC2HS) $< + $(HSC2HS) $(HSC2HS_OPTS) $< + @touch $(patsubst %.hsc,%_hsc.c,$<) endif #----------------------------------------------------------------------------- @@ -142,33 +149,58 @@ endif #----------------------------------------------------------------------------- # C-related suffix rules +ifeq "$(UseGhcForCc)" "YES" + %.$(way_)o : %.$(way_)s @$(RM) $@ - $(AS) $(AS_OPTS) -o $@ $< || ( $(RM) $@ && exit 1 ) + $(HC) $(GHC_CC_OPTS) -c $< -o $@ %.$(way_)o : %.c @$(RM) $@ - $(CC) $(CC_OPTS) -c $< -o $@ + $(HC) $(GHC_CC_OPTS) -c $< -o $@ %.$(way_)o : %.S @$(RM) $@ - $(CC) $(CC_OPTS) -c $< -o $@ + $(HC) $(GHC_CC_OPTS) -c $< -o $@ + +%.$(way_)s : %.c + @$(RM) $@ + $(HC) $(GHC_CC_OPTS) -S $< -o $@ -#%.$(way_)s : %.c -# @$(RM) $@ -# $(CC) $(CC_OPTS) -S $< -o $@ +else -%.c : %.flex +%.$(way_)o : %.$(way_)s @$(RM) $@ - $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 ) -%.c : %.lex + $(AS) $(AS_OPTS) -o $@ $< + +%.$(way_)o : %.c + @$(RM) $@ + $(CC) $(CC_OPTS) -c $< -o $@ + +%.$(way_)o : %.S + @$(RM) $@ + $(CC) $(CC_OPTS) -c $< -o $@ + +%.$(way_)s : %.c @$(RM) $@ - $(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 ) + $(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) $< > $@ +%.c : %.lex + @$(RM) $@ + $(FLEX) -t $(FLEX_OPTS) $< > $@ + #----------------------------------------------------------------------------- # Yacc stuff @@ -227,6 +259,8 @@ endif # $(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 $@ %.html : %.tex @$(RM) $@ @@ -270,3 +304,10 @@ endif %.$(way_)o : %.$(way_)rc @$(RM) $@ windres $< $@ + +#----------------------------------------------------------------------------- +# Preprocessor suffix rule + +% : %.pp + rm -f $@ + $(CPP) $(CPP_OPTS) -x c $< | $(SED) -e '/^#/d' > $@