[DVDnav-discuss] [PATCH] Fix parallel jobs; sources need version.h

Dan Nicholson dbn.lists at gmail.com
Wed Apr 30 14:55:06 CEST 2008


On Wed, Apr 30, 2008 at 12:57 AM, Nico Sabbi <Nicola.Sabbi at poste.it> wrote:
>
> On Monday 28 April 2008 23:53:38 Dan Nicholson wrote:
>  > ---
>  >  Makefile |    2 ++
>  >  1 files changed, 2 insertions(+), 0 deletions(-)
>  >
>  > diff --git a/Makefile b/Makefile
>  > index fcc3940..85108e5 100644
>  > --- a/Makefile
>  > +++ b/Makefile
>  > @@ -81,6 +81,8 @@ endif
>  >  version.h:
>  >       sh $(SRC_PATH)/version.sh $(SRC_PATH)
>  >
>  > +$(SRCS) $(DVDREAD_SRCS): version.h
>  > +
>  >
>  >  # General targets
>
>  can you explain, please?
>  If I read the dependencies all .c files already depend on version.h

They don't. The library $(SHLIB) depends on version.h. Since that's
the first target, version.h gets built immediately. However, if you
have multiple jobs (-j3 or whatever), make will also begin building
the .c files without waiting for version.h to be built. This causes a
race condition if any .c file including config.h or version.h is built
before version.h is created.

You can see if the .c files depend on version.h pretty easily. Run
`make -d dvdnav.o' and redirect the log somewhere. It will show in
detail the prerequisites for the target dvdnav.o. For me, version.h
never comes up until after the patch above. If this is a clean
checkout (i.e., you've only run configure2), `mkdir obj && make
dvdnav.o' will bomb like this:

cd obj && gcc -MD -g -O2 -march=i686 -pipe  -Wall -funsigned-char
-I/home/dan/scm/libdvdnav -I"/home/dan/scm/libdvdnav"/src
-I"/home/dan/scm/libdvdnav"/src/vm -DDVDNAV_COMPILE
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DHAVE_CONFIG_H
-DHAVE_DLFCN_H -I"/home/dan/scm/libdvdnav"/src/dvdread -c -o dvdnav.o
/home/dan/scm/libdvdnav/src/dvdnav.c
In file included from /home/dan/scm/libdvdnav/src/dvdnav.c:25:
/home/dan/scm/libdvdnav/config.h:2:21: error: version.h: No such file
or directory

With the patch, it properly generates version.h first, and this works.

--
Dan



More information about the DVDnav-discuss mailing list