Replace Makefile with current simple Makefile

This commit is contained in:
Bob Polis 2024-10-09 11:07:21 +02:00
parent 3ee79437fe
commit 73a844d64a

View File

@ -1,46 +1,31 @@
BIN := $(shell basename $$(pwd)) LDLIBS := -lscstring
PROJ := $(shell basename $$(pwd))
SRCS := $(wildcard *.cpp) SRCS := $(wildcard *.cpp)
OBJS := $(subst .cpp,.o,$(SRCS)) OBJS := $(SRCS:.cpp=.o)
DEPS := $(subst .cpp,.d,$(SRCS)) DEPS := $(SRCS:.cpp=.dep)
CXX ?= g++ CXX ?= g++
PKG_CONFIG ?= pkg-config
PREFIX ?= /usr/local CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -Wno-unused-parameter
BINDIR ?= $(PREFIX)/bin CXXFLAGS += -g3 -std=c++20
DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man
RM := /bin/rm -f
INSTALL := /usr/bin/install -c
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
CXXFLAGS += -D DEBUG -O0 CXXFLAGS += -DDEBUG -O0
else else
CXXFLAGS += -O3 CXXFLAGS += -DNDEBUG -O3
endif endif
LDLIBS := -lm -lpthread -lscstring %.o: %.cpp
LDFLAGS := $(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.dep -c $<
all: $(BIN) %.dep: ;
$(BIN): $(OBJS) $(DEPS) $(PROJ): $(OBJS)
$(CXX) $(OBJS) $(LDFLAGS) -o $(BIN) $(LDLIBS) $(CXX) $(LDFLAGS) -o $(PROJ) $(OBJS) $(LDLIBS)
%.o: %.cpp %.d Makefile -include $(DEPS)
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
-include *.d
%.d: ;
.PHONY: clean install
.PHONY: clean
clean: clean:
$(RM) $(OBJS) $(DEPS) $(BIN) rm -f $(OBJS) $(DEPS) $(PROJ)
install: $(BIN)
$(INSTALL) $(BIN) $(DESTDIR)$(BINDIR)