summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-02-29 19:39:09 +1100
committerMaxime Coste <mawww@kakoune.org>2024-02-29 19:53:39 +1100
commit10b6b7eb7143a8b4a8082825b2df76a503292c48 (patch)
treeb5c3a25083ec2647c21fc9225cffb6b65e09d261
parent165cdba67ce703e3ce22a7224ff574e303c918ff (diff)
Rework Makefile compile type tag handling
Rename suffix to tag as it ends up not being the filename suffix, apply that tag to .o and .d files so that changing the build type does not wipe/reuse files from another build type. Make .d file hidden files, this does not seem possible for the .o files as they are targets and posix support inference rules when only the suffix changes. This is not a big issue as Kakoune ignores those files by default.
-rw-r--r--Makefile33
1 files changed, 17 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 37501679..d08f77ad 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,5 @@
.POSIX:
.SUFFIXES:
-.SUFFIXES: .o .cc
CXX = c++
@@ -15,28 +14,24 @@ compress-suffix-zstd = zst
CPPFLAGS-debug-yes = -DKAK_DEBUG
CXXFLAGS-debug-yes = -O0 -g
-suffix-debug-yes = .debug
+tag-debug-yes = .debug
CXXFLAGS-debug-no = -O3
-suffix-debug-no = .opt
+tag-debug-no = .opt
CXXFLAGS-sanitize-address = -fsanitize=address
LDFLAGS-sanitize-address = -lasan
-suffix-sanitize-address = .san_a
+tag-sanitize-address = .san_a
CXXFLAGS-sanitize-undefined = -fsanitize=undefined
LDFLAGS-sanitize-undefined = -lubsan
-suffix-sanitize-undefined = .san_u
+tag-sanitize-undefined = .san_u
LDFLAGS-static-yes = -static -pthread
version != cat .version 2>/dev/null || git describe --tags HEAD 2>/dev/null || echo unknown
-sources != find src -type f -name '*.cc' | sed -e '/\.version\.cc/d'
-deps != find src -type f -name '*.d'
-objects = $(sources:.cc=.o)
-
PREFIX = /usr/local
DESTDIR = # root dir
@@ -98,20 +93,26 @@ KAK_LIBS = \
$(LIBS-os-$(os)) \
$(LIBS)
-suffix = $(suffix-debug-$(debug))$(suffix-sanitize-$(sanitize))
+tag = $(tag-debug-$(debug))$(tag-sanitize-$(sanitize))
+
+.SUFFIXES: $(tag).o .cc
+
+sources != find src -type f -name '*.cc' | sed -e '/\.version\.cc/d'
+objects = $(sources:.cc=$(tag).o)
+deps != find src -type f -name '.*$(tag).d'
all: src/kak
-src/kak: src/kak$(suffix)
- ln -sf kak$(suffix) $@
+src/kak: src/kak$(tag)
+ ln -sf kak$(tag) $@
-src/kak$(suffix): src/.version.o $(objects)
+src/kak$(tag): src/.version.o $(objects)
$(CXX) $(KAK_LDFLAGS) $(KAK_CXXFLAGS) $(KAK_LIBS) $(objects) src/.version.o -o $@
include $(deps)
-.cc.o:
- $(CXX) $(KAK_CPPFLAGS) $(KAK_CXXFLAGS) -MD -MP -MF $*.d -c -o $@ $<
+.cc$(tag).o:
+ $(CXX) $(KAK_CPPFLAGS) $(KAK_CXXFLAGS) -MD -MP -MF $(*D)/.$(*F)$(tag).d -c -o $@ $<
src/.version.cc:
echo 'namespace Kakoune { const char *version = "$(version)"; }' > $@
@@ -153,7 +154,7 @@ kakoune-$(version).tar:
rm -f src/.version
distclean: clean
- rm -f src/kak src/kak$(suffix)
+ rm -f src/kak src/kak$(suffix) src/.*.d src/*.o
find doc -type f -name '*.gz' -exec rm -f '{}' +
installdirs: installdirs-debug-$(debug)