Reduce spurious recompilations for Linux 2.4 datapath.
authorBen Pfaff <blp@nicira.com>
Fri, 2 May 2008 22:51:08 +0000 (15:51 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 2 May 2008 22:51:08 +0000 (15:51 -0700)
We need object files to depend on the build directories, so that the
build directories get created before we try to output files into them.
But making them depend directly on the build directories means that
whenever a build directory changes (including any change to the set of
files inside it) all the source files get recompiled.  So, instead, make
them depend on dummy files inside the directories, which will only get
modified if someone does it intentionally.

datapath/Modules.mk
datapath/linux-2.4/Makefile.in

index c1b31b3..02970d9 100644 (file)
@@ -37,3 +37,4 @@ all_sources = $(foreach module,$(all_modules),$($(module)_sources))
 all_headers = $(foreach module,$(all_modules),$($(module)_headers))
 all_objects = $(patsubst %.c,%.o,$(all_sources))
 all_objdirs = $(addprefix $(builddir)/,$(sort $(dir $(all_objects))))
+all_dummies = $(addsuffix /.dummy,$(all_objdirs))
index 74f4c99..ef3a545 100644 (file)
@@ -20,7 +20,7 @@ distdir: clean
 install:
 all: default
 clean:
-       rm -f $(all_objects) *_mod.o
+       rm -f $(all_objects) *_mod.o $(all_dummies)
        for d in $(all_objdirs); do             \
                while                           \
                        rmdir $$d 2> /dev/null; \
@@ -82,9 +82,10 @@ CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
             echo "-DMODVERSIONS -DEXPORT_SYMTAB \
                   -include $(KSRC)/include/linux/modversions.h")
 
-$(all_objects): $(all_objdirs)
-$(all_objdirs):
-       mkdir -p $@
+$(all_objects): $(all_dummies)
+$(all_dummies):
+       mkdir -p $(@D)
+       touch $@
 
 default: $(patsubst %,%_mod.o,$(all_modules))