这是我的第一个 Makefile,所以我剪切并粘贴了我在网上找到的垃圾。我的目录结构非常平坦,并没有考虑到 Makefile。它是:Project/Project/Control Project/NodeMgmt Project/Common Project/Interfaces
我正在为 Control 编写 Makefile,并希望它在 Control 内部独立。它需要包含来自 Common & Interfaces 的编译和包含。这是我的Makefile:
CC = g++
CFLAGS = -Wall -c
INCLUDES = -I/usr/local/include -I/SuperCool/Ion-1.0.0-snapshot-1/include -I/SuperCool/FastrakSDK-4.0.1-snapshot-1/include/Fastrak/Engine/Core/CoreIpc -I/Projects/Common -I/Projects/Interfaces -I/Projects/NodeMgmt -I/Projects/Controller
LFLAGS = -L/usr/local/lib -L/SuperCool/FastrakSDK-4.0.1-snapshot-1/lib
LIBS = -lCoreIpc4 -lIonOs
VPATH = ../Interfaces/
VPATH = ../Common/
VPATH = ../NodeMgmt/
SRCS = *.cc
OBJS = $(SRCS:.cc=.o)
MAIN = controller
.PHONY: clean
all: $(MAIN)
@echo Built Controller
$(MAIN): $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LFLAGS) $(LIBS)
.cc.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
$(RM) *.o $(MAIN)
它正在编译它找到的第一个 .cc 文件“-c Controller.cc -o *.o”,这是有道理的,但这就是它正在编译的全部内容,我得到一个 *.o 输出文件,而不是 Controller.o 文件。它不编译任何其他文件。