From 9270528a26cfd9f19d79519a61712c9d2f426106 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 12 Jun 2024 20:16:46 +0200 Subject: build system improvements --- .gitignore | 1 + NodeInput.cpp | 2 +- makefile | 23 ++++++++++++----------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 1707139..31a3d9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ main *.o +*.d .vscode .cache compile_commands.json diff --git a/NodeInput.cpp b/NodeInput.cpp index ea328e3..2fae505 100644 --- a/NodeInput.cpp +++ b/NodeInput.cpp @@ -14,7 +14,7 @@ NodeInput * NodeInput::clone() const { SignalLevel NodeInput::level() { prutprint("BaseInput"); - return HIGH; + return UNDEFINED; } SignalLevel NodeInputLow::level() { prutprint("LOW"); diff --git a/makefile b/makefile index cbdba7f..1cb47c3 100644 --- a/makefile +++ b/makefile @@ -1,24 +1,25 @@ -CC = g++ -LD = g++ -RM = rm -f -CFLAGS = -g -std=c++20 -LFLAGS = +CXXFLAGS += -g +CXXFLAGS += -std=c++20 TARGET = main + SRCS := $(wildcard *.cpp) -OBJS := $(patsubst %.cpp,%.o, $(SRCS)) +OBJS := $(SRCS:.cpp=.o) +DEPS := $(SRCS:.cpp=.d) all: $(TARGET) -%.o: %.cpp - $(CC) -c $(CFLAGS) $< -o $@ +-include $(wildcard *.d) +all: $(DEPS) $(TARGET): $(OBJS) - $(LD) $^ $(LFLAGS) -o $@ + $(CXX) $^ $(LFLAGS) -o $@ + +%.d: %.cpp + $(CXX) -M $< -o $@ clean: - $(RM) $(TARGET) $(OBJS) + $(RM) $(TARGET) $(OBJS) $(DEPS) compile_commands.json: compiledb make -Bn -_Bj: ; $(MAKE) -C . -Bj -- cgit v1.2.3