I have these files
- test.cpp
- Point.h
- Point.cpp
- Triangle.h
- Triangle.cpp
and I want to have a make file, which allows me to create each of the classes Pointand Triangleindividually, calling if necessary make Point, or make Triangle(a header file, or the source file has changed). make allmust compile everything and, if necessary, create an output program Test.
This is what I came up with so far:
CXX=g++
CXXFLAGS=-std=c++11 -Wall -pedantic
OBJS=Test.o Point.o Triangle.o
all : $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) -o Test
Point.o : Point.cpp Point.h
$(CXX) $(CXXFLAGS) -c Point.cpp
Point : Point.o
Triangle.o : Triangle.h Triangle.cpp Point.h
$(CXX) $(CXXFLAGS) -c Triangle.cpp
Triangle : Triangle.o
clean:
\rm *.o Test
.PHONY : Point Triangle
This seems to work, but the problem is that when I run make all(or just make) several times, it runs the command, even if nothing has changed, giving the following output:
g++ -std=c++11 -Wall -pedantic Test.o Point.o Triangle.o -o Test
, - " ". - , , . ?