R
R
Rag'n' Code Man2021-12-02 23:30:33
GNU Make
Rag'n' Code Man, 2021-12-02 23:30:33

Why does the message "make: 'build' does not need to be updated" pop up?

I have this Makefile

PROJECT=GameOfLife

CXX=clang++-13
STD=c++2a
STDLIB=libstdc++
FLAGS=-Wall -Wextra

LINKARGS=-lsfml-graphics -lsfml-window -lsfml-system

SOURCES=src/main.cpp
OBJECTS=$(wildcard build/*.o)

build: $(SOURCES)
  $(CXX) -c -std=$(STD) -stdlib=$(STDLIB) $(FLAGS) $(SOURCES)
  mv *.o ./build

link: $(OBJECTS)
  $(CXX) $(OBJECTS) -o bin/$(PROJECT) $(LINKARGS)

clean:
  rm -rf bin/*
  rm -rf build/*

compile: 
  make build
  make link

run:
  make compile
  ./bin/$(PROJECT)

.PHONY: clean compile run

If I run it for make buildthe first time, then everything works. When I run it a second time, I get this message:

➜  make build 
make: «build» не требует обновления.

Before that, I ran the make clean command. As a result, this tax only works if you constantly rename it.

Project structure:

GOL
 ┣ bin
 ┣ build
 ┣ include
 ┣ lib
 ┣ src
 ┃ ┗ main.cpp
 ┗ Makefile

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2021-12-03
@iDmitriyWinX

Why does the message "make: 'build' does not need to be updated" pop up?

well, to answer the original question: because the rule
build: $(SOURCES)

says that the build directory only depends on the source files. mv *.o ./buildThe and commands rm -rf build/*make it newer than the source, so make thinks it doesn't need to be updated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question