CXX = g++
CXXFLAGS = -std=c++11 -Wall
all: main
main: main.o
$(CXX) $(CXXFLAGS) -o main main.o
main.o: main.cpp
$(CXX) $(CXXFLAGS) -c main.cpp
clean:
rm -f main main.o
- CXX = g++: Defines the variable CXX as the g++ compiler.
- CXXFLAGS = -std=c++11 -Wall: Defines the variable CXXFLAGS as the compilation flags, including the C++11 standard and enabling all compiler warnings.
- all: main: Declares the target "all" as dependent on the target "main".
- main: main.o: Declares the target "main" as dependent on the file "main.o".
- $(CXX) $(CXXFLAGS) -o main main.o: Specifies the command to link the object file "main.o" into the executable "main" using the g++ compiler with the defined compilation flags.
- main.o: main.cpp: Declares the target "main.o" as dependent on the source file "main.cpp".
- $(CXX) $(CXXFLAGS) -c main.cpp: Specifies the command to compile the source file "main.cpp" into the object file "main.o" using the g++ compiler with the defined compilation flags.
- clean: Declares the target "clean" as a phony target, which removes the executable "main" and the object file "main.o" when invoked using the command "make clean".