From 1c47c433ba2c391dc0367edf16b3138afb3e8af1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 27 Mar 2015 19:21:50 -0700 Subject: [PATCH] build: always attempt to update util/build_version.cc Summary: This fixes two bugs: "make clean" would never remove the generated file, util/build_version.cc, and since D33591, would be regenerated only if it were absent. * Makefile (clean): Remove the generated file. (util/build_version.cc): Depend on the no-prereq FORCE target, so that this target's rules are always run. Since this is a generated file, make it read-only. Also, be sure to remove the temporary file when it is the same as the original. Test Plan: Ensure that we attempt regeneration every time. Make it empty with an up-to-date time stamp and demonstrate that it is rebuilt with the expected content: $ : > util/build_version.cc $ make util/build_version.o GEN util/build_version.cc GEN util/build_version.d GEN util/build_version.cc CC util/build_version.o $ cat util/build_version.cc #include "build_version.h" const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:v3.10-2-gb30e72a"; const char* rocksdb_build_git_date = "rocksdb_build_git_date:2015-03-27"; const char* rocksdb_build_compile_date = __DATE__; Reviewers: igor.sugak, sdong, ljin, igor, rven Reviewed By: rven Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D36087 --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b6a247ab3..95546fc75 100644 --- a/Makefile +++ b/Makefile @@ -163,10 +163,13 @@ gen_build_version = \ # as a regular source file as part of the compilation process. # One can run "strings executable_filename | grep _build_" to find # the version of the source that we used to build the executable file. -util/build_version.cc: - $(AM_V_GEN)$(gen_build_version) > $@.tmp - $(AM_V_at)if test -f $@; then \ - cmp -s $@.tmp $@ && : || mv -f $@.tmp $@; else mv -f $@.tmp $@; fi +FORCE: +util/build_version.cc: FORCE + $(AM_V_GEN)rm -f $@-t + $(AM_V_at)$(gen_build_version) > $@-t + $(AM_V_at)if test -f $@; then \ + cmp -s $@-t $@ && rm -f $@-t || mv -f $@-t $@; \ + else mv -f $@-t $@; fi LIBOBJECTS = $(LIB_SOURCES:.cc=.o) MOCKOBJECTS = $(MOCK_SOURCES:.cc=.o) @@ -396,6 +399,7 @@ unity: unity.o clean: rm -f $(PROGRAMS) $(TESTS) $(LIBRARY) $(SHARED) make_config.mk unity.cc + rm -f util/build_version.cc rm -rf ios-x86 ios-arm scan_build_report find . -name "*.[oda]" -exec rm {} \; find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;