init-projects/cpp/Makefile

30 lines
528 B
Makefile
Raw Normal View History

2024-02-01 15:16:54 +01:00
CXX = g++
RM = rm
2023-09-19 11:39:57 +02:00
2024-02-01 15:16:54 +01:00
SOURCES = $(wildcard src/*.cpp)
2024-04-03 15:38:54 +02:00
OBJECTS = $(patsubst %.cpp,%.o,$(notdir $(SOURCES)))
2023-09-19 11:39:57 +02:00
2024-04-20 14:56:15 +02:00
CXXFLAGS = -std=c++17 -pedantic
2023-11-25 21:18:30 +01:00
2024-02-01 15:16:54 +01:00
EXE = example
EXE_EXT = out
2023-09-19 11:39:57 +02:00
%.o: src/%.cpp
2023-11-12 16:23:10 +01:00
$(CXX) -c -o $@ $< $(CXXFLAGS)
2023-09-19 11:39:57 +02:00
2024-04-03 15:38:54 +02:00
release: CXXFLAGS += -O3
release: compilation
2024-04-20 14:46:44 +02:00
debug: CXXFLAGS += -Wall -Wextra -Wshadow -Wnon-virtual-dtor -g
2024-04-03 15:38:54 +02:00
debug: CXXFLAGS += -Wold-style-cast -Wsign-conversion
debug: compilation
2023-09-19 11:39:57 +02:00
2024-04-03 15:38:54 +02:00
compilation: $(OBJECTS)
$(CXX) -o $(EXE).$(EXE_EXT) $(OBJECTS)
2023-09-19 11:39:57 +02:00
all:
2024-04-03 15:38:54 +02:00
release
2023-09-19 11:39:57 +02:00
clean:
2024-04-03 15:38:54 +02:00
$(RM) $(OBJECTS) $(EXE).$(EXE_EXT)