help-make
[Top][All Lists]
Advanced

[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 /obvious_definitions.mk

DIRS := $(BUILD_DIR)
BUILD_DIR := /build
CLUSTER_NAME := importers
EXEC_SRCS := import_e.cc
SRCS_LIST := /importers/import_e.cc

EXECS := $(EXEC_SRCS:.cc=)
DEP  := $(SRCS:.cc=.d)

bin: links import_e

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

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

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

%.o: %.cc
   $(CXX) $(MAKEDEPFLAGS) -c $(FLAGS) $<

.PHONY: clean bin links

# Include dependencies
ifdef DEP
ifneq ($(MAKECMDGOALS),clean)
-include $(DEP)
endif
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/import_e.cc /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 import_e.cc
-

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

-
natch




reply via email to

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