Skip to content

Commit

Permalink
[sb2] Avoid rebuilds when configure.ac changes but not it's output
Browse files Browse the repository at this point in the history
When configure.ac or config.mak.in change but not their output their
will be repeated rebuilds as the timestamp their output files such as
config.mak stay older than their dependency.

The timestamp file's timestamp will always update after the targets
dependency changed.

Signed-off-by: Björn Bidar <[email protected]>
  • Loading branch information
Thaodan committed Nov 25, 2024
1 parent 9970be1 commit 5dc216e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
config.log
include/config.h
include/config.h.in
stamp-h
stamp-h.in
configure
config.guess
config.status
Expand All @@ -17,6 +19,8 @@ autom4te.cache
aclocal.*
*.a
config.mak
stamp-mak
stamp-mak.in
preload/exported.h
preload/ldexportlist
preload/wrappers.c
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,23 @@ do-all: $(targets)
# Don't erase these files if make is interrupted while refreshing them.
.PRECIOUS: $(OBJDIR)/config.status
.NOTPARALLEL: $(DIST_FILES)
$(DIST_FILES): $(SRCDIR)/configure $(SRCDIR)/config.mak.in
# Use a proxy timestamp file here since config.mak and config.h
# don't update unless their contents change when the dependencies
# that generate them change, avoid repeated rebuilds after changing
# files such as configure.ac e.g. after checking out a new branch
$(DIST_FILES): $(OBJDIR)/stamp-mak
$(OBJDIR)/stamp-mak: $(SRCDIR)/configure $(SRCDIR)/config.mak.in
$(OBJDIR)/config.status --recheck
echo > $(OBJDIR)/stamp-mak

$(SRCDIR)/configure: $(SRCDIR)/configure.ac
cd $(SRCDIR); \
./autogen.sh

$(OBJDIR)/include/config.h: $(SRCDIR)/include/config.h.in $(OBJDIR)/config.status
$(OBJDIR)/config.status config.h
$(OBJDDIR)/include/config.h: $(OBJDIR)/stamp-h
$(OBJDIR)/stamp-h: $(SRCDIR)/include/config.h.in $(OBJDIR)/config.status
$(OBJDIR)/config.status include/config.h
echo > $(OBJDIR)/stamp-h

$(OBJDIR)/include/scratchbox2_version.h: $(OBJDIR)/config.mak
mkdir -p $(OBJDIR)/include
Expand Down Expand Up @@ -209,9 +217,11 @@ ifeq ($(OS),Linux)
endif

CLEAN_FILES += $(targets) \
$(SRCDIR)/stamp-h \
$(OBJDIR)/include/config.h \
$(OBJDIR)/include/scratchbox2_version.h
DISTCLEAN_FILES += $(DIST_FILES) \
$(OBJDIR)/stamp-mak \
$(OBJDIR)/config.log \
$(SRCDIR)/configure \
$(SRCDIR)/include/config.h.in
Expand Down
3 changes: 3 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@

rm -rf configure autom4te.cache
autoreconf --verbose --force --install

echo > stamp-h.in
echo > stamp-mak.in
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ AC_CONFIG_AUX_DIR([build-aux])
#AC_CONFIG_SRCDIR([src/libfakechroot.c])
AC_CONFIG_HEADERS([include/config.h])
AC_CONFIG_FILES([config.mak])
dnl Generate timestamp so that configure output files timestamps are in sync
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
AC_CONFIG_FILES([stamp-mak], [echo timestamp > stamp-mak])
AC_PROG_CC
AC_PROG_CXX

Expand Down

0 comments on commit 5dc216e

Please sign in to comment.