[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parallel gmake problem

From: Paul D. Smith
Subject: Re: Parallel gmake problem
Date: Tue, 5 Nov 2002 21:50:37 -0500

%% address@hidden writes:

  xh> I have a makefile taht works well in normal execution.
  xh> But I try in parallel (-j) , I have sometimes some problem.

  xh> lib: build_dir_setup $(DEST_DIR)/$(LIB)

  xh> build_dir_setup :
  xh>   mkdir -p $(DEST_DIR)

  xh> The problem with that is the "build_dir_setup" target.  This is
  xh> here to only build the directories where the final objs and the
  xh> lib will be.  So it's mandatory that these 2 directories exists
  xh> before to do the link or the compilation.

A line like this:

  foo: bar baz boz

tells make _only_ that bar, baz, and boz must all be built and completed
before it can start building foo.

This line tells make _nothing_ about the relative order that bar, baz,
and boz must be built in.

During a serial build make convention says that the prerequisites will
be built in the order in which they appear in the prerequisites list.

During a parallel build, they will all be built at the same time (or as
many as can be given your -j setting) unless you tell make that there
are further dependencies between them.

  xh> however, if I build in parallel, it seems that it's trying to
  xh> build some objects before the build_dir_setup completed so
  xh> bringing error message like :
  xh>   "Cannot open dir/toto.o"

  xh> how can I enforce this target to be processed before.

You have to tell make that the other targets _also_ depend on that
directory being built.

In other words, every target that requires the build_dir_setup target to
be run before it is run must say explicitly:

  <sometarget>: build_dir_setup

But, the short answer is you _never_ want to create directories like
this.  There are many reasons why it's broken.  Search the archives for
this mailing list if you want to see them all.  Instead, use $(shell
...) to do it:

  __dummy := $(shell [ -d $(DEST_DIR) ] || mkdir -p $(DEST_DIR))

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

[Prev in Thread] Current Thread [Next in Thread]