Replace Makefile with new version

This commit is contained in:
Bob Polis 2024-09-11 16:42:54 +02:00
parent e33824355b
commit 1fdbf7831a

View File

@ -1,34 +1,31 @@
LDLIBS := -lscterm -lm -lscscreensaver LDLIBS :=
BIN := $(shell basename $$(pwd)) BIN := $(shell basename $$(pwd))
SRCS := $(wildcard *.cpp) SRCS := $(wildcard *.cpp)
OBJS := $(SRCS:.cpp=.o) OBJS := $(SRCS:.cpp=.o)
DEPS := $(SRCS:.cpp=.d) DEPS := $(SRCS:.cpp=.dep)
CXX ?= g++ CXX ?= g++
RM := /bin/rm -f
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17 CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -Wno-unused-parameter
CXXFLAGS += -g3 -std=c++20
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
CXXFLAGS += -D DEBUG -O0 CXXFLAGS += -D DEBUG -O0
else else
CXXFLAGS += -D NDEBUG -O3 CXXFLAGS += -D NDEBUG -O3
endif endif
.PHONY: all clean %.o: %.cpp
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.dep -c $<
all: $(BIN) %.dep: ;
$(BIN): $(OBJS) $(DEPS) $(BIN): $(OBJS)
$(CXX) $(LDFLAGS) -o $(BIN) $(OBJS) $(LDLIBS) $(CXX) $(LDFLAGS) -o $(BIN) $(OBJS) $(LDLIBS)
%.o: %.cpp %.d -include $(DEPS)
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
-include *.d
%.d: ;
.PHONY: clean
clean: clean:
$(RM) $(OBJS) $(DEPS) $(BIN) rm -f $(OBJS) $(DEPS) $(BIN)