[DVDnav-discuss] parallel make problem

Dominik 'Rathann' Mierzejewski dominik at greysector.net
Sat Aug 30 18:24:11 CEST 2008


On Saturday, 30 August 2008 at 17:30, Dan Nicholson wrote:
> On Sat, Aug 30, 2008 at 7:05 AM, Dominik 'Rathann' Mierzejewski
> <dominik at greysector.net> wrote:
> > I'm experiencing a problem with make -j2:
[...]
> > But I'd rather have a proper fix instead of workarounds.
> > Ideas?
> 
> You really don't want to have a target dependent on a directory
> because make will always think the target is out of date.

Yeah, I thought there was something fundamentally wrong here.

> That prevents doing the right thing:
> 
> $(OBJS) $(DVDREAD_OBJS) $(SHOBJS) $(DVDREAD_SHOBJS): $(.OBJDIR)
> 
> I think the only way to handle this race free without polluting make's
> timestamp handling is to make the targets explicitly handle the mkdir
> on their own and get rid of the target for it (watch out for gmail
> wrapping):
>
> diff --git a/Makefile b/Makefile
> index cb1340e..ee2df97 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -75,20 +75,19 @@ $(SRCS) $(DVDREAD_SRCS): version.h
> 
>  # General targets
> 
> -$(.OBJDIR):
> -       mkdir $(.OBJDIR)
> -
> -${DVDREAD_LIB}: version.h $(.OBJDIR) $(DVDREAD_OBJS) $(BUILDDEPS)
> +${DVDREAD_LIB}: version.h $(DVDREAD_OBJS) $(BUILDDEPS)
>         cd $(.OBJDIR) && $(AR) rc $@ $(DVDREAD_OBJS)
>         cd $(.OBJDIR) && $(RANLIB) $@
> 
> -${DVDREAD_SHLIB}: version.h $(.OBJDIR) $(DVDREAD_SHOBJS) $(BUILDDEPS)
> +${DVDREAD_SHLIB}: version.h $(DVDREAD_SHOBJS) $(BUILDDEPS)
>         cd $(.OBJDIR) && $(CC) $(SHLDFLAGS) $(LDFLAGS) -ldl -Wl,-soname=$(DVDREA
> 
>  .c.so: $(BUILDDEPS)
> +       @[ -d $(.OBJDIR) ] || mkdir -p $(.OBJDIR)
>         cd $(.OBJDIR) && $(CC) -fPIC -DPIC -MD $(CFLAGS) -c -o $@ $<
> 
>  .c.o:  $(BUILDDEPS)
> +       @[ -d $(.OBJDIR) ] || mkdir -p $(.OBJDIR)
>         cd $(.OBJDIR) && $(CC) -MD $(CFLAGS) -c -o $@ $<
> 
> 
> @@ -133,7 +132,8 @@ distclean: clean
>         find . -name "*~" | xargs rm -rf
>         rm -rf config.mak
> 
> -dvdread-config: $(.OBJDIR)
> +dvdread-config:
> +       @[ -d $(.OBJDIR) ] || mkdir -p $(.OBJDIR)
>         @echo '#!/bin/sh' > $(.OBJDIR)/dvdread-config
>         @echo 'prefix='$(PREFIX) >> $(.OBJDIR)/dvdread-config
>         @echo 'libdir='$(shlibdir) >> $(.OBJDIR)/dvdread-config

This is very ugly IMHO. How about sneaking mkdir obj into version.sh rule?
Index: Makefile
===================================================================
--- Makefile    (revision 1122)
+++ Makefile    (working copy)
@@ -68,6 +68,7 @@
 endif
 
 version.h:
+       [ -d $(.OBJDIR) ] || mkdir -p $(.OBJDIR)
        sh $(SRC_PATH)/version.sh $(SRC_PATH) "$(SHLIB_VERSION)"
 
 $(SRCS) $(DVDREAD_SRCS): version.h
@@ -75,14 +76,11 @@
 
 # General targets
 
-$(.OBJDIR):
-       mkdir $(.OBJDIR)
-
-${DVDREAD_LIB}: version.h $(.OBJDIR) $(DVDREAD_OBJS) $(BUILDDEPS)
+${DVDREAD_LIB}: version.h $(DVDREAD_OBJS) $(BUILDDEPS)
        cd $(.OBJDIR) && $(AR) rc $@ $(DVDREAD_OBJS)
        cd $(.OBJDIR) && $(RANLIB) $@
 
-${DVDREAD_SHLIB}: version.h $(.OBJDIR) $(DVDREAD_SHOBJS) $(BUILDDEPS)
+${DVDREAD_SHLIB}: version.h $(DVDREAD_SHOBJS) $(BUILDDEPS)
        cd $(.OBJDIR) && $(CC) $(SHLDFLAGS) $(LDFLAGS) -ldl -Wl,-soname=$(DVDREAD_SHLIB).$(SHLIB_MAJOR) -o $@ $(DVDREAD_SHOBJS)
 
 .c.so: $(BUILDDEPS)
@@ -133,7 +131,7 @@
        find . -name "*~" | xargs rm -rf
        rm -rf config.mak
 
-dvdread-config: $(.OBJDIR)
+dvdread-config:
        @echo '#!/bin/sh' > $(.OBJDIR)/dvdread-config
        @echo 'prefix='$(PREFIX) >> $(.OBJDIR)/dvdread-config
        @echo 'libdir='$(shlibdir) >> $(.OBJDIR)/dvdread-config

Regards,
R.

-- 
Fedora http://fedoraproject.org/wiki/User:Rathann
Livna http://rpm.livna.org | MPlayer http://mplayerhq.hu
"Faith manages."
        -- Delenn to Lennier in Babylon 5:"Confessions and Lamentations"



More information about the DVDnav-discuss mailing list