xfstests: some refinements on "make depend"
authorAlex Elder <aelder@sgi.com>
Fri, 4 Mar 2011 19:37:41 +0000 (19:37 +0000)
committerAlex Elder <aelder@sgi.com>
Fri, 11 Mar 2011 12:45:19 +0000 (06:45 -0600)
Make it so "make depend" is a generic target, like "make clean".

Each Makefile has a "depend" target that indicates whether making
dependencies means creating ".dep" or creating ".ltdep" (or, I
suppose, both, though none do that right now).  Both files get
created even if there are no CFILES to scan (to ensure the target
up-to-date).  The "default" target now depends on "depend" (there is
no "ltdepend" any more).

Remove the "depend" and "ltdepend" definitions from the "buildrules"
file; only the actual generated files (".dep" and ".ltdep") remain
as generic targets.  The "depend' target is still defined as phony.

Do a shell trick when expanding the value of CFILES, to avoid a
problem that occurs if it is created by "make" by concatentating two
empty strings.  The problem was that in that case CFILES will
contain a space, and that wasn't getting treated as empty as
desired.

Make the rule for tool/lib dependencies more generic, to reflect the
general desire that "lib" subdirectories need to be built before
things in the "tool" subdirectories.

Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Makefile
include/buildrules
lib/Makefile
ltp/Makefile
src/Makefile
src/aio-dio-regress/Makefile

index 574e9bd531f4e8d3067e0e32fa5b4d9c13f73e24..c504e19ce218cab963e636460d98e2636ba2bca4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -52,7 +52,7 @@ endif
 endif
 
 # tool/lib dependencies
 endif
 
 # tool/lib dependencies
-src ltp: lib
+$(TOOL_SUBDIRS): $(LIB_SUBDIRS)
 
 ifeq ($(HAVE_BUILDDEFS), yes)
 include $(BUILDRULES)
 
 ifeq ($(HAVE_BUILDDEFS), yes)
 include $(BUILDRULES)
@@ -77,6 +77,8 @@ endif
 aclocal.m4::
        aclocal --acdir=`pwd`/m4 --output=$@
 
 aclocal.m4::
        aclocal --acdir=`pwd`/m4 --output=$@
 
+depend: include/builddefs $(addsuffix -depend,$(SUBDIRS))
+
 install: default $(addsuffix -install,$(SUBDIRS))
        $(INSTALL) -m 755 -d $(PKG_LIB_DIR)
        $(INSTALL) -m 755 check $(PKG_LIB_DIR)
 install: default $(addsuffix -install,$(SUBDIRS))
        $(INSTALL) -m 755 -d $(PKG_LIB_DIR)
        $(INSTALL) -m 755 check $(PKG_LIB_DIR)
index d8ef6b1eae50e3bf1ed4a7efe4c1e1bd7d1125c5..c8a7c474726e2cbf8816e4b6949c8acee4fc24e3 100644 (file)
@@ -6,13 +6,20 @@ _BUILDRULES_INCLUDED_ = 1
 
 include $(TOPDIR)/include/builddefs
 
 
 include $(TOPDIR)/include/builddefs
 
+depend: $(addsuffix -depend,$(SUBDIRS))
+
+%-depend:
+       $(Q)$(MAKE) $(MAKEOPTS) -q -C $* depend || \
+           $(MAKE) $(MAKEOPTS) -C $* depend
+
 clean clobber : $(addsuffix -clean,$(SUBDIRS))
        $(Q)rm -f $(DIRT)
        $(Q)rm -fr .libs .ltdep .dep
 
 %-clean:
        @echo "Cleaning $*"
 clean clobber : $(addsuffix -clean,$(SUBDIRS))
        $(Q)rm -f $(DIRT)
        $(Q)rm -fr .libs .ltdep .dep
 
 %-clean:
        @echo "Cleaning $*"
-       $(Q)$(MAKE) $(MAKEOPTS) -q -C $* clean || $(MAKE) $(MAKEOPTS) -C $* clean
+       $(Q)$(MAKE) $(MAKEOPTS) -q -C $* clean || \
+           $(MAKE) $(MAKEOPTS) -C $* clean
 
 # Never blow away subdirs
 ifdef SUBDIRS
 
 # Never blow away subdirs
 ifdef SUBDIRS
@@ -71,21 +78,25 @@ endif # _BUILDRULES_INCLUDED_
 $(_FORCE):
 
 # dependency build is automatic, relies on gcc -MM to generate.
 $(_FORCE):
 
 # dependency build is automatic, relies on gcc -MM to generate.
-.PHONY : depend ltdepend
+.PHONY : depend
 
 MAKEDEP := $(MAKEDEPEND) $(CFLAGS)
 
 
 MAKEDEP := $(MAKEDEPEND) $(CFLAGS)
 
-ltdepend: .ltdep
-
 .ltdep: $(CFILES) $(HFILES)
        @echo "    [LTDEP]"
 .ltdep: $(CFILES) $(HFILES)
        @echo "    [LTDEP]"
-       $(Q)[ -n "$(CFILES)" ] && \
-           $(MAKEDEP) $(CFILES) | $(SED) -e 's,^\([^:]*\)\.o,\1.lo,' > .ltdep
-
-depend: .dep
+       $(Q)if [ -n "$$( echo $(CFILES))" ]; then \
+           $(MAKEDEP) $(CFILES) | \
+           $(SED) -e 's,^\([^:]*\)\.o,\1.lo,' > .ltdep; \
+       else \
+           cp /dev/null .ltdep; \
+       fi
 
 .dep: $(CFILES) $(HFILES)
        @echo "    [DEP]"
 
 .dep: $(CFILES) $(HFILES)
        @echo "    [DEP]"
-       $(Q)[ -n "$(CFILES)" ] && \
-           $(MAKEDEP) $(CFILES) | $(SED) -e 's,^\([^:]*\)\.o,\1,' > .dep
+       $(Q)if [ -n "$$( echo $(CFILES))" ]; then \
+           $(MAKEDEP) $(CFILES) | \
+           $(SED) -e 's,^\([^:]*\)\.o,\1,' > .dep; \
+       else \
+           cp /dev/null .dep; \
+       fi
 
 
index 094167c8b0f6efe9b8cf3c4e5e68d2a5778a1a3d..c7348ce15f1c08c6d004a0be7cc00395cb11fde6 100644 (file)
@@ -19,10 +19,12 @@ CFILES = dataascii.c databin.c datapid.c file_lock.c forker.c \
        str_to_bytes.c tlibio.c write_log.c \
        random.c
 
        str_to_bytes.c tlibio.c write_log.c \
        random.c
 
-default: ltdepend $(LTLIBRARY)
+default: depend $(LTLIBRARY)
 
 include $(BUILDRULES)
 
 
 include $(BUILDRULES)
 
+depend: .ltdep
+
 install install-dev: default
 
 -include .ltdep
 install install-dev: default
 
 -include .ltdep
index f3899e1cf8042071d77966bb0a4aa761f9a9dd16..32cd380db945e6407be56de59901603dce71087e 100644 (file)
@@ -33,6 +33,8 @@ endif
 
 default: depend $(TARGETS)
 
 
 default: depend $(TARGETS)
 
+depend: .dep
+
 include $(BUILDRULES)
 
 $(TARGETS): $(LIBTEST)
 include $(BUILDRULES)
 
 $(TARGETS): $(LIBTEST)
index 3d35e260b1e5373e1023102e3fc04dbe5cbd85b6..1162ee08dfa1474faeca10d45ca338ffaff22356 100644 (file)
@@ -61,6 +61,8 @@ LDIRT = $(TARGETS)
 
 default: depend $(TARGETS) $(SUBDIRS)
 
 
 default: depend $(TARGETS) $(SUBDIRS)
 
+depend: .dep
+
 include $(BUILDRULES)
 
 $(TARGETS): $(LIBTEST)
 include $(BUILDRULES)
 
 $(TARGETS): $(LIBTEST)
index 3f9d1c266b3151efcf5f1309f092b2fed5075d75..79dd55d81fbc3869144482b5c0ee5f03816655cf 100644 (file)
@@ -10,6 +10,8 @@ LLDLIBS = -laio -lpthread
 
 default: depend $(TARGETS)
 
 
 default: depend $(TARGETS)
 
+depend: .dep
+
 include $(BUILDRULES)
 
 $(TARGETS):
 include $(BUILDRULES)
 
 $(TARGETS):