Make always recompiles every sourcefile

Hi
I'm pretty new to Make and im trying to construct a Makefile that only compiles the files that have been modified since last

this is what i have:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
OBJECTS = $(wildcard src/*.cpp)
HEADERS = $(wildcard include/*.h)

OUTPUT = bin/a.exe

CXX = g++
CXXFLAGS = -Wall -std=c++11 -I./include/

%.o: %.cpp $(HEADERS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

default: $(OBJECTS) $(HEADERS)
	$(CXX) $(OBJECTS) $(CXXFLAGS) -o $(OUTPUT)
 */


The problem with this is that it reocmpiles every single cpp file every time i type make?

But dont i tell it, on line 9, to only create the .o files if the corresponding cpp, or one of the header files, have been changed?

I dont understand what im doing wrong, could somebody help me?
Last edited on
Nothing depends on the .o files.
The first rule is for a file called "default". So it runs the rule, which creates a different file. Next time it recompiles everything again.
Topic archived. No new replies allowed.