[DVDnav-discuss] parallel make problem

Dan Nicholson dbn.lists at gmail.com
Sat Aug 30 18:27:22 CEST 2008


On Sat, Aug 30, 2008 at 9:24 AM, Dominik 'Rathann' Mierzejewski
<dominik at greysector.net> wrote:
> 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?

That should work as long as we're sure all the objects are dependent
on version.h (I think we are).

--
Dan



More information about the DVDnav-discuss mailing list