有没有人知道我的Makefile有什么问题?
CXX = g++ # compiler
CXXFLAGS = -g -Wall -MMD # compiler flags
MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}} # makefile name
OBJECTS1 = utf.o # object files forming executable
EXEC1 = utf # executable name
OBJECTS2 = driver.o rational.o # object files forming executable
EXEC2 = rational # executable name
OBJECTS3 = da.o qa.o pa.o ua.o # object files forming executable
EXEC3 = ho # executable name
OBJECTS = ${OBJECTS1} ${OBJECTS2} ${OBJECTS3}
EXECS = ${EXEC1} ${EXEC2} ${EXEC3}
DEPENDS = ${OBJECTS:.o=.d} # substitute ".o" with ".d"
.PHONY : all clean
all : ${EXECS}
${EXEC1} : ${OBJECTS1} # link step
${CXX} $^ -o $@
${EXEC2} : ${OBJECTS2} # link step
${CXX} $^ -o $@
${EXEC3} : ${OBJECTS3} # link step
${CXX} $^ -o $@
${OBJECTS} : ${MAKEFILE_NAME} # OPTIONAL : changes to this file => recompile
-include ${DEPENDS} # include *.d files containing program dependences
clean : # remove files that can be regenerated
rm -f ${DEPENDS} ${OBJECTS} ${EXECS}
错误:
./Makefile: 1: CXX: not found
./Makefile: 2: CXXFLAGS: not found
./Makefile: 3: Bad substitution
答案 0 :(得分:7)
使用make
命令运行Makefile。您可以为make指定目标,例如make all
。
答案 1 :(得分:2)
不要自己执行makefile。你的shell试图把它当作某种shell脚本。
运行make
,使用生成文件。