Re: Various patches - makedepend

  • From: Andre Majorel <amajorel@xxxxxxxxx>
  • To: yadex@xxxxxxxxxxxxx
  • Date: Sat, 4 Sep 2010 08:32:19 +0200

Oh look, there's still someone out there. Hello Ingo.

On 2010-09-03 22:56 +0200, Ingo van Lil wrote:
>  On 09/03/2010 12:39 AM, Ingo van Lil wrote:
> >* yadex-makedepend.patch:
> >I couldn't find the "makedepend" tool in F13, so the yadex.dep
> >rule always silently created an empty file (the error messages
> >were hidden by the redirection of stderr). So I've added an
> >alternative way to create the dependencies using gcc.

They call it the way forward ; I call it the war against
portability.

> commit 3621e296bee37e1f575edea7448986b2d0dba563
> Author: Ingo van Lil <inguin@xxxxxx>
> Date:   Tue Aug 31 21:08:37 2010 +0200
> 
>     Use gcc (if available) to generate yadex.dep file.
> 
> diff --git a/GNUmakefile b/GNUmakefile
> index 61c4652..06b2ee2 100644
> --- a/GNUmakefile
> +++ b/GNUmakefile
> @@ -767,6 +767,12 @@ $(OBJDIR)/files_share.man: $(OBJDIR)/config.share 
> $(MAKEFILE)
>  cache/yadex.dep: $(SRC_NON_GEN) src/config.h
>       @echo "Generating $@"
>       @test -d cache || mkdir cache
> +ifeq ($(CC), gcc)
> +     @gcc -MM $(CFLAGS) $(SRC_NON_GEN) >$(@D)/.$(@F)
> +     @sed 's,^.*\.o:,$(OBJDIR)/&,' $(@D)/.$(@F) >$@
> +     @sed 's,^.*\.o:,$(DOBJDIR)/&,' $(@D)/.$(@F) >>$@
> +     @rm $(@D)/.$(@F)
> +else
>       @makedepend -f- -Y -Iatclib $(SRC_NON_GEN) 2>/dev/null          \
>               | $(AWK) 'sub (/^src/, "") == 1 {                       \
>                               print "'$(OBJDIR)'" $$0;                \
> @@ -774,6 +780,7 @@ cache/yadex.dep: $(SRC_NON_GEN) src/config.h
>                               next;                                   \
>                       }' >$(@D)/.$(@F)
>       @mv -f $(@D)/.$(@F) $@
> +endif

Looks good. Only nitpick, it appends to yadex.dep so if an error
occurs, you're left with a yadex.dep that is truncated but
recent, so never rebuilt.

If possible, always write to a temporary file and mv it to $@ at
the end of the recipe. If the temporary is in the same
directory it will normally be rename(2)'d, which is atomic
(mostly).

> -include cache/yadex.dep
> +-include cache/yadex.dep

Can you tell me the reasoning behind this change ?

-- 
André Majorel http://www.teaser.fr/~amajorel/

Other related posts: