I have the following Makefile:
OBJDIRS = Runtime/Core/Common Runtime/Core/Graphic/SymbolXLib Runtime/Core/Map Runtime/Core/SymbolDictionary \
Runtime/CoreClient/RuntimeCoreJava
OBJS = $(wildcard $(OBJDIRS:=/*.o))
TARGETA = libRuntimeCoreJava.a
TARGETD = libRuntimeCoreJava.so
TARGETD1 = $(TARGETD).1
TARGETD2 = $(TARGETD).1.0
TARGETD3 = $(TARGETD).1.0.0
AR = ar cqs
LINK = g++
SYMLINK = ln -f -s
LDFLAGS = -shared -Wl,-soname,libRuntimeCoreJava.so.1
all : $(TARGETD) $(TARGETA)
$(TARGETD) : $(OBJS)
echo "Building Dynamic Lib using "$(OBJS)
#$(CXX) $(LDFLAGS) $(OBJS)
#$(SYMLINK) $(TARGETD) $(TARGETD1)
#$(SYMLINK) $(TARGETD) $(TARGETD2)
#$(SYMLINK) $(TARGETD) $(TARGETD3)
$(TARGETA) : $(OBJS)
echo "Building Static Lib using "$(OBJS)
#$(AR) $(TARGETA) $(OBJS)
When I run make at the same level as the Makefile it appears to call another makefile unrelated to this one.
In file included from Runtime/Core/Common/JNICallback.cpp:16:
Runtime/Core/Common/stdafx.h:33:17: error: log.h: No such file or directory
Runtime/Core/Common/stdafx.h:34:23: error: Namespace.h: No such file or directory
Runtime/Core/Common/JNICallback.cpp:18:25: error: JNICallback.h: No such file or directory
make: *** [Runtime/Core/Common/JNICallback.o] Error 1
As you can see I am not even building any source, only taking object files that are already compiled and putting them into a static and dynamic library. Why is it trying to compile source? Below is my directory structure.
[matt6809@hogganz400 src]$ ls -l
drwxrwxr-x 2 matt6809 matt6809 4096 Mar 2 11:47 binDebug
drwxrwxr-x 2 matt6809 matt6809 4096 Feb 15 13:31 binRelease
drwxrwxr-x 2 matt6809 matt6809 4096 Feb 22 11:03 include
drwxrwxr-x 2 matt6809 matt6809 4096 Mar 5 10:55 libDebug
drwxrwxr-x 2 matt6809 matt6809 4096 Feb 15 11:25 libRelease
-rw-rw-r-- 1 matt6809 matt6809 824 Mar 6 15:48 Makefile
drwxrwxr-x 5 matt6809 matt6809 4096 Feb 14 16:03 Runtime
drwxrwxr-x 6 matt6809 matt6809 4096 Feb 14 16:43 System
I am 100% sure I am in the same directory as the makefile. What gives?
Your targets have object files as prerequisites (whatever object files happen to be in those directories at the time). The object files already exist, but Make will check them to see if they’re out of date and should be rebuilt. If it checks an object file, finds a corresponding source file that’s newer, tries to recompile the object and there’s a header file missing, you’ll get an error message like what you see. There is no evidence of another makefile in play.
There are a couple of ways to deal with it.
The easiest way is probably to move the source files away from the directory where you run Make (or vise-versa).EDIT:
@eriktous has pointed out a better way: use
make -rto disable the built-in rules.