我知道在Makefile中这有点不寻常,但我真的很想这样做。我想这样做,如果我运行Makefile它打开程序(已经完成),但如果没有任何事情要做,它也运行:/。我怎么能这样做?
Makefile =
#Compiler to use
CC = g++
#LUA STUFF
LUAHOME = /usr/local/Cellar/lua/5.3.2/src
#Boost Paths
BOOST_LIB = /usr/local/Cellar/boost/1.59.0/lib
BOOST_INCLUDE = /usr/local/Cellar/boost/1.59.0/include
#Steam Paths
STEAM_LIB = libs/steam/redistributable_bin/osx32
STEAM_INCLUDE = libs/steam/public/steam
#Flags for the compiler
LFLAGS = -L$(LUAHOME) -I$(LUAHOME) -llua -L$(STEAM_LIB) -I$(STEAM_INCLUDE) -L$(BOOST_LIB) -I$(BOOST_INCLUDE) -lboost_system -lboost_filesystem -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lglew -lglfw3 -w -o Relieved
OFLAGS = -c -Wall
#Name of the Compiled Program
NAME = Relieved
#All CPPs
CPP = main.cpp jelly/lua_manager.cpp jelly/keysManager.cpp
#Objects
OBJECTS = $(CPP:.cpp=.o)
all: $(CPP) $(NAME)
$(NAME): $(OBJECTS)
$(CC) $(LFLAGS) $(OBJECTS) -o $@
./$(NAME)
.cpp.o:
$(CC) $(OFLAGS) $< -o $@
clean:
rm $(OBJECTS) $(NAME)
答案 0 :(得分:2)
你有点错误的做法。如果没有什么可做的,那么什么都不会做。
使用命令在二进制文件的构建配方中运行程序没有帮助。
您的目标是创建一个始终需要构建的目标,并将运行命令放在那里。虽然您可以使用任何不存在的文件,但关键字PHONY
会使这些伪目标更有效,因为那时make甚至不必检查文件是否存在。
all: RUN-IT
.PHONY: RUN-IT
RUN-IT : $(NAME)
# run the program here, remember to use TABs when defining build steps