[Top][All Lists]

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

Make must be executed twice

From: lists
Subject: Make must be executed twice
Date: Wed, 10 Aug 2005 17:57:30 -0400
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

I'm working on completely eliminating recursion from our build system. One problem I've come up with is having to run make twice to start building anything. I've widdled down the makefile to the simplest version that still works.

We link all the source files into one folder and do the build there. The reason for this is long and complex but it's something we must maintain.

I'm guessing that the pattern substitution rule doesn't work unless the files are linked before make is executed. So make has to be run once to link all the files, and then again to start building. Here's my example, omitting the obvious definitions:

include /

BUILD_DIR := /build
CLUSTER_NAME := importers
SRCS_LIST := /importers/

EXECS := $(
DEP  := $(

bin: links import_e

import_e: import_e.o
   $(CXX) -o $@ $(FLAGS) $<

links: $(DIRS)
   @ln -sf $(SRCS_LIST) $(BUILD_DIR)

   @echo Creating install dir $@
   @$(INSTALL) -d $@

   $(CXX) $(MAKEDEPFLAGS) -c $(FLAGS) $<

.PHONY: clean bin links

# Include dependencies
ifdef DEP
ifneq ($(MAKECMDGOALS),clean)
-include $(DEP)
endif # DEP

When I execute the make command, either with an empty build directory or no build directory, I get an error that there's no target for import_e.o. If I run make twice, it's happy.

[user /build]$ make bin -n

ln -sf x /importers/ /build
make: *** No rule to make target `import_e.o', needed by `import_e'.  Stop.

[user /build]$ make bin

make: *** No rule to make target `import_e.o', needed by `import_e'.  Stop.

[user /build]$ make bin

g++ -MD -c -g -I/include

Is there a solution to this that still allows me to link into and build from a /build directory?


reply via email to

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