Skip to content

Commit

Permalink
make: remake TG-BUILD-SETTINGS and TG-TEST-SETTINGS on config mods
Browse files Browse the repository at this point in the history
If config.sh and/or config.mak are changed be sure to rebuild
TG-BUILD-SETTINGS and TG-TEST-SETTINGS (of course only changing the
mod date on them if anything actually ended up changing).

And make `make settings` work at the top-level too.

Signed-off-by: Kyle J. McKay <[email protected]>
  • Loading branch information
mackyle committed Jun 21, 2017
1 parent 55c198d commit c6c5694
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Anything explicitly listed here will always avoid a bogus "up to date" result
TARGETS = \
all clean tg awk hooks helpers doc html \
precheck TG-BUILD-SETTINGS \
precheck TG-BUILD-SETTINGS settings \
install install-doc install-html \
tg--awksome tg-tg.txt topgit.html \
shell_compatibility_test \
Expand Down
7 changes: 5 additions & 2 deletions Makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ all: \
tg $(commands_out) $(utils_out) $(awk_out) $(hooks_out) $(helpers_out) \
bin-wrappers/tg bin-wrappers/pre-commit $(help_out) tg-tg.txt

settings: TG-BUILD-SETTINGS FORCE
+$(Q)cd t && $(MAKE) settings

awk: $(awk_out)
hooks: $(hooks_out)
helpers: $(helpers_out)
Expand Down Expand Up @@ -185,11 +188,11 @@ bs() { printf "%s\\n" \
# make -f Makefile.mak TG-BUILD-SETTINGS thus avoiding this always
# causing the targets that depend on it to build while still forcing
# a rebuild if any settings actually change.
TG-BUILD-SETTINGS: $(FORCE_SETTINGS_BUILD)
TG-BUILD-SETTINGS: $(CONFIGDEPS) $(FORCE_SETTINGS_BUILD)
$(Q)$(BUILD_SETTINGS);if test x"$$(bs)" != x"`cat \"$@\" 2>/dev/null`"; then \
echo "* new build settings"; \
bs >"$@"; \
fi
elif test z"$(FORCE_SETTINGS_BUILD)" = z; then touch "$@"; fi

test: all FORCE
+$(Q)cd t && $(MAKE) all
Expand Down
17 changes: 14 additions & 3 deletions gnomake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,24 @@ set -e
# If MKTOP is set, they are looked for there instead of in
# the current directory.
#
# The CONFIGDEPS variable will be set to the ones that exist
# (for use in dependency lines).
#
# wrap it up for safety
configsh() {
! [ -f "${MKTOP:+$MKTOP/}config.sh" ] ||
. ./"${MKTOP:+$MKTOP/}config.sh"
[ z"$MKTOP" = z"/" ] || MKTOP="${MKTOP%/}"
CONFIGDEPS=
! [ -f "${MKTOP:+$MKTOP/}config.sh" ] || {
. ./"${MKTOP:+$MKTOP/}config.sh"
CONFIGDEPS="${CONFIGDEPS:+$CONFIGDEPS }${MKTOP:+$MKTOP/}config.sh"
}
# now set CONFIGMAK and make it an absolute path
[ -n "$CONFIGMAK" ] || CONFIGMAK="${MKTOP:+$MKTOP/}config.mak"
[ -f "$CONFIGMAK" ] || CONFIGMAK="${MKTOP:+$MKTOP/}Makefile.mt"
if [ -f "$CONFIGMAK" ]; then
CONFIGDEPS="${CONFIGDEPS:+$CONFIGDEPS }$CONFIGMAK"
else
CONFIGMAK="${MKTOP:+$MKTOP/}Makefile.mt"
fi
case "$CONFIGMAK" in */?*);;*) CONFIGMAK="./$CONFIGMAK"; esac
CONFIGMAK="$(cd "${CONFIGMAK%/*}" && pwd)/${CONFIGMAK##*/}"
}
Expand Down
5 changes: 3 additions & 2 deletions t/Makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ TEST_TARGET = $(TEST_TARGET_$(DEFAULT_TEST_TARGET_))
all: $(TEST_TARGET)

settings: TG-TEST-SETTINGS
-@true # avoids the "Nothing to be done" message

test: pre-clean TG-TEST-SETTINGS $(TEST_LINT) FORCE
$(Q)set -m && $(CACHE_SETUP_TTY) $(MAKE) $${GNO_PD_OPT} -f Makefile.mak aggregate-results-and-cleanup
Expand Down Expand Up @@ -197,11 +198,11 @@ ts() { printf "%s\\n" \
': "$${GIT_MINIMUM_VERSION:=$$TG_GIT_MINIMUM_VERSION}"' \
;}

TG-TEST-SETTINGS: $(FORCE_SETTINGS_BUILD)
TG-TEST-SETTINGS: $(CONFIGDEPS) $(FORCE_SETTINGS_BUILD)
$(Q)$(TEST_SETTINGS);if test x"$$(ts)" != x"`cat \"$@\" 2>/dev/null`"; then \
echo "* new test settings"; \
ts >"$@"; \
fi
elif test z"$(FORCE_SETTINGS_BUILD)" = z; then touch "$@"; fi

FORCE: __file_which_should_not_exist

Expand Down

0 comments on commit c6c5694

Please sign in to comment.