From 97bc26ce7f4327734184bf48a8e1339293a66a5b Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Sat, 25 Jun 2022 13:57:12 +0200 Subject: [PATCH] Move source files to subdirectory --- Makefile | 21 ++++++++++++++++----- recgen.cpp => src/recgen.cpp | 0 sortbin.cpp => src/sortbin.cpp | 0 3 files changed, 16 insertions(+), 5 deletions(-) rename recgen.cpp => src/recgen.cpp (100%) rename sortbin.cpp => src/sortbin.cpp (100%) diff --git a/Makefile b/Makefile index 0d09724..b748433 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,23 @@ CXX = g++ CXXFLAGS = -Wall -O2 # -fsanitize=address -fsanitize=undefined -.PHONY: all -all: sortbin recgen +SRCDIR = src +BUILDDIR = build -sortbin: sortbin.cpp -recgen: recgen.cpp +TOOLS = sortbin recgen +BINFILES = $(patsubst %,$(BUILDDIR)/%,$(TOOLS)) + +.PHONY: all +all: $(BINFILES) + +$(BUILDDIR)/sortbin: $(SRCDIR)/sortbin.cpp +$(BUILDDIR)/recgen: $(SRCDIR)/recgen.cpp + +$(BUILDDIR)/%: $(SRCDIR)/%.cpp + @mkdir -p $(BUILDDIR) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $< $(LDLIBS) -o $@ .PHONY: clean clean: - $(RM) sortbin recgen + $(RM) $(BINFILES) + diff --git a/recgen.cpp b/src/recgen.cpp similarity index 100% rename from recgen.cpp rename to src/recgen.cpp diff --git a/sortbin.cpp b/src/sortbin.cpp similarity index 100% rename from sortbin.cpp rename to src/sortbin.cpp