如何显示特定gcc Makefile目标变量的值?

时间:2016-04-12 19:32:35

标签: c++ linux ubuntu gcc makefile

我试图调试来自ChatScript开源chat-bot项目的gcc Makefile中的问题:

http://chatscript.sourceforge.net/

以下是我的相关版本号:

Ubuntu 14.04
make version 3.81
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

我似乎无法在当前工作目录旁边的另一个目录中找到源文件。如果我将源文件移动到当前目录,它可以正常工作,但如果我把文件放回旧目录,它会抱怨它无法找到它:

make: *** No rule to make target `privatesrc.cpp', needed by `all'.  Stop.

执行 make 时我所在的当前目录是SRC,即 Makefile 所在的目录。 privatesrc.cpp 驻留在一个兄弟目录中, 可以通过此相对路径从SRC访问>

../ privatecode / privatesrc.cpp

为了调试这个问题,我想确切地看到每个make目标变量的文件是什么。我使用这两个SO帖子来尝试转储这些值:

How to print out a variable in makefile

Jim Nisby的回答。和

gnu make: list the values of all variables (or "macros") in a particular run

接受的答案。

我创建了这个名为 server_dry_run 的新制作目标,以实现此目的:

server_dry_run: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDDATABASE=1
server_dry_run: PGLOAD= -pthread
server_dry_run: INCLUDEDIRS=-Ievserver
server_dry_run: all
server_dry_run: EXECUTABLE=../BINARIES/ChatScript
server_dry_run: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 
# Uncomment this line if you want to filter out variables already defined.
# VARS_OLD := $(.VARIABLES)
CUR-DIR := $(shell pwd)
LOG-DIR := $(CUR-DIR)/make-logs
$(info INCLUDEDIRS="$(INCLUDEDIRS)")
$(foreach v,$(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)),$(info $(v) = $($(v))))

但是,INCLUDEDIRS始终显示为空:

INCLUDEDIRS=""

如何查看INCLUDEDIRS的值以便解决此问题?

以下是我的Makefile的全部内容。注意,我确实尝试删除了我在INCLUDEDIRS 分配的值附近添加的引号,但这没有帮助。另外一点数据。如果我做"干净"我收到错误" rm:无法删除`../':是一个目录",这似乎表明EXECUTABLE目标变量可能不是右

MAKEFILE:

debugserver: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDDATABASE=1 -DDEBUG
debugserver: PGLOAD= -pthread
debugserver: INCLUDEDIRS="-Ievserver -I../privatecode"
debugserver: all
debugserver: EXECUTABLE=../BINARIES/ChatScriptDebug
debugserver: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing -g

debugpgserver: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1  -DDEBUG
debugpgserver: PGLOAD= -lpq -pthread
debugpgserver: INCLUDEDIRS="-Ievserver -I../privatecode"
debugpgserver: all
debugpgserver: EXECUTABLE=../BINARIES/ChatScriptpgDebug
debugpgserver: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing -g

server: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDDATABASE=1
server: PGLOAD= -pthread
server: INCLUDEDIRS="-Ievserver -I../privatecode"
server: all
server: EXECUTABLE=../BINARIES/ChatScript
server: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 

standalone: DEFINES+= -DPRIVATE_CODE  -DDISCARDSERVER=1 -DDISCARDDATABASE=1 
standalone: PGLOAD= -pthread
standalone: INCLUDEDIRS="-Ievserver -I../privatecode"
standalone: all
standalone: EXECUTABLE=../BINARIES/ChatScript
standalone: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 

pgserver: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 
pgserver: PGLOAD= -lpq -pthread
pgserver: all
pgserver: EXECUTABLE=../BINARIES/ChatScriptpg
pgserver: INCLUDEDIRS="-Ievserver -Ipostgres -I../privatecode"
pgserver: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 


mongoserver: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 
mongoserver: PGLOAD= -lpq -pthread
mongoserver: all
mongoserver: EXECUTABLE=../BINARIES/ChatScriptmongo
mongoserver: INCLUDEDIRS="-Ievserver -I../privatecode"
mongoserver: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 

server_dry_run: DEFINES+= -DPRIVATE_CODE -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDDATABASE=1
server_dry_run: PGLOAD= -pthread
server_dry_run: INCLUDEDIRS=-Ievserver -I../privatecode
server_dry_run: all
server_dry_run: EXECUTABLE=../BINARIES/ChatScript
server_dry_run: CFLAGS=-c -Wall  -funsigned-char  -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing 
# Uncomment this line if you want to filter out variables already defined.
# VARS_OLD := $(.VARIABLES)
CUR-DIR := $(shell pwd)
LOG-DIR := $(CUR-DIR)/make-logs
$(info INCLUDEDIRS="$(INCLUDEDIRS)")
$(foreach v,$(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)),$(info $(v) = $($(v))))

UNAME := $(shell uname)

CC=g++

ifeq ($(UNAME), Linux)
$(info ************ LINUX VERSION ************)
LDFLAGS= -lrt -lcurl --verbose $(PGLOAD) 
endif

ifeq ($(UNAME), Darwin)
$(info ************ MAC VERSION ************)
LDFLAGS=-mmacosx-version-min=10.7 $(PGLOAD)  
CFLAGS=-mmacosx-version-min=10.7 -c -Wall  -funsigned-char -Wno-write-strings -Wno-char-subscripts 
endif

SOURCES=constructCode.cpp evserver.cpp csocket.cpp cs_ev.c dictionarySystem.cpp englishTagger.cpp factSystem.cpp  functionExecute.cpp english.cpp infer.cpp javascript.cpp jsmn.cpp markSystem.cpp os.cpp outputSystem.cpp patternSystem.cpp privatesrc.cpp scriptCompile.cpp spellcheck.cpp secure.cpp systemVariables.cpp tagger.cpp testing.cpp textUtilities.cpp tokenSystem.cpp topicSystem.cpp userCache.cpp userSystem.cpp variableSystem.cpp mainSystem.cpp 
OBJECTS=$(SOURCES:.cpp=.o)

all: $(SOURCES) binary

clean:
    -rm -f $(EXECUTABLE)
    -rm -f ../$(EXECUTABLE)
    -rm -f *.o

binary: $(OBJECTS)
    $(CC) $(OBJECTS) $(LDFLAGS) $(DEFINES) $(INCLUDEDIRS) -o $(EXECUTABLE)

.cpp.o:
    $(CC) $(CFLAGS) $(DEFINES) $(INCLUDEDIRS) $< -o $@

0 个答案:

没有答案