Re: Problem with dependencies and readonly files

Andreas Schwab (schwab@lamothe.informatik.uni-dortmund.de)
Thu, 11 Apr 96 12:55:36 +0200


"Marty Leisner" <leisner@sdsp.mc.xerox.com> writes:

|> While we're talking about dependencies, I personally prefer
|> .d files, which automatically get regenerated if the source is modified.

For those who prefer automagically generated dependencies here's a
patch for 1.3.85. Advantage: dependencies are always uptodate and
correct, no need to explicitly do a make dep; no absolute file names
in dependencies, they remain valid when the sources are moved.
Disadvantages: slower than the current scheme; if headers are
renamed/removed you'll have to remove *.d files manually (but make
will tell you which are affected).

--- linux-1.3/Makefile.~1~ Wed Apr 10 00:19:03 1996
+++ linux-1.3/Makefile Thu Apr 11 00:16:03 1996
@@ -48,14 +48,15 @@
#
ifeq (.config,$(wildcard .config))
include .config
-ifeq (.depend,$(wildcard .depend))
-include .depend
+#ifeq (.depend,$(wildcard .depend))
+#include .depend
do-it-all: Version vmlinux
+#else
+#CONFIGURATION = depend
+#do-it-all: depend
+#endif
else
-CONFIGURATION = depend
-do-it-all: depend
-endif
-else
+no_deps = t
CONFIGURATION = config
do-it-all: config
endif
@@ -231,6 +232,8 @@
init/version.o: init/version.c include/linux/compile.h
$(CC) $(CFLAGS) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c

+O_OBJS = init/main.o
+
init/main.o: init/main.c
$(CC) $(CFLAGS) $(PROFILING) -c -o $*.o $<

@@ -323,6 +326,7 @@
rm -f include/asm
rm -f .depend `find . -name .depend -print`
rm -f .hdepend
+ rm -f `find . -name '*.d' -print`
rm -f $(TOPDIR)/include/linux/modversions.h
rm -f $(TOPDIR)/include/linux/modules/*

@@ -341,7 +345,7 @@

dep-files: archdep .hdepend include/linux/version.h
$(AWK) -f scripts/depend.awk init/*.c > .tmpdepend
- set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep; done
+ set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i no_deps=t fastdep; done
mv .tmpdepend .depend

MODVERFILE :=
--- linux-1.3/Rules.make.~1~ Wed Apr 3 22:58:47 1996
+++ linux-1.3/Rules.make Thu Apr 11 00:18:30 1996
@@ -85,9 +85,23 @@
if [ -n "$(wildcard *.[chS])" ]; then \
$(AWK) -f $(TOPDIR)/scripts/depend.awk *.[chS] > .depend; fi
ifdef ALL_SUB_DIRS
- set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i fastdep; done
+ set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i no_deps=t fastdep; done
endif

+up := $(shell echo $(patsubst $(TOPDIR)/%,%,$(shell pwd)/) | \
+ sed -e 's,[^/]*/,../,g')
+define make-deps
+$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -M $< | \
+ sed -e 's,$(patsubst init/%,%,$(subst .,\.,$*))\.o,$*.o $@,' \
+ -e 's, $(subst .,\.,$(TOPDIR))/, $(up),' > $*.D
+mv -f $*.D $@
+endef
+
+%.d: %.c
+ $(make-deps)
+%.d: %.S
+ $(make-deps)
+
#
# A rule to make subdirectories
#
@@ -185,6 +199,7 @@

endif

+ifneq ($(no_deps),t)
#
# include dependency files they exist
#
@@ -194,4 +209,14 @@

ifeq ($(TOPDIR)/.hdepend,$(wildcard $(TOPDIR)/.hdepend))
include $(TOPDIR)/.hdepend
+endif
+
+DEPEND_FILES = $(patsubst %.o,%.d,$(L_OBJS) $(LX_OBJS) $(O_OBJS) $(OX_OBJS))
+ifdef MAKING_MODULES
+DEPEND_FILES += $(patsubst %.o,%.d,$(M_OBJS) $(MX_OBJS))
+endif
+DEPEND_FILES := $(sort $(DEPEND_FILES))
+ifneq "$(DEPEND_FILES)" ""
+-include $(DEPEND_FILES)
+endif
endif

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"