make/meson: Generate a `version.h'
Using a header file allows us to keep the version string out of the
compiler command line. This should heavily increase direct hits with
ccache. Specifying the compiler argument for a single source file is
rather clumsy with Meson, hence the more pompous header file.
Change-Id: If6c4e33e4944d2b264252dbcd2fd69ecf7bd8905
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/355
Reviewed-by: Felix Singer <felixsinger@posteo.net>
diff --git a/Makefile b/Makefile
index 12adf61..2d94afe 100644
--- a/Makefile
+++ b/Makefile
@@ -409,8 +409,6 @@
VERSION := $(shell ./util/getversion.sh --version)
MAN_DATE := $(shell ./util/getversion.sh --man-date)
-SCMDEF := -D'FLASHPROG_VERSION="$(VERSION)"'
-
# Inform user of the version string
ifeq ($(filter branch tag,$(MAKECMDGOALS)), )
$(info Replacing all version templates with $(VERSION).)
@@ -1003,8 +1001,13 @@
exit 1; \
fi
+include/version.h: %.h: %.h.in
+ sed 's/@VERSION@/$(VERSION)/' $< >$@
+
+flashprog.o: include/version.h
+
%.o: %.c | config
- $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHPROG_CFLAGS) $(FEATURE_FLAGS) $(SCMDEF) -o $@ -c $<
+ $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHPROG_CFLAGS) $(FEATURE_FLAGS) -o $@ -c $<
$(PROGRAM)$(EXEC_SUFFIX): $(CLI_OBJS) libflashprog.a
$(CC) -o $@ $^ $(LDFLAGS)
@@ -1028,7 +1031,7 @@
# We don't use EXEC_SUFFIX here because we want to clean everything.
clean:
rm -f $(PROGRAM) $(PROGRAM).exe libflashprog.a $(filter-out Makefile.d, $(wildcard *.d *.o platform/*.d platform/*.o)) \
- $(MANS) $(MANS:.8=.8.html) $(BUILD_DETAILS_FILE)
+ include/version.h $(MANS) $(MANS:.8=.8.html) $(BUILD_DETAILS_FILE)
@+$(MAKE) -C util/ich_descriptors_tool/ clean
install: $(PROGRAM)$(EXEC_SUFFIX) $(MANS)