]> git.neil.brown.name Git - history.git/commitdiff
Small Rules.make cleanup
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Sun, 12 May 2002 08:54:07 +0000 (03:54 -0500)
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Sun, 12 May 2002 08:54:07 +0000 (03:54 -0500)
Add some comments to explain the magic, use $(if), which will
be needed for other places anyway.

That means we up the make requirements to 3.78, which is a couple of
years old, so basically anybody should have it already.

Documentation/Changes
Rules.make

index 35bead6192eb09bcb7b9cb597451b0ae54960880..ba95d5482e41847686cdeb1e026f82b694eccf10 100644 (file)
@@ -49,7 +49,7 @@ Card) hardware, for example, you probably needn't concern yourself
 with pcmcia-cs.
 
 o  Gnu C                  2.95.3                  # gcc --version
-o  Gnu make               3.77                    # make --version
+o  Gnu make               3.78                    # make --version
 o  binutils               2.9.5.0.25              # ld -v
 o  util-linux             2.10o                   # fdformat --version
 o  modutils               2.4.2                   # insmod -V
index 8d93f2ba4e8d9c0237bf6991c05d237e51cf7119..583674a9bebba5080f296ca20951de7bba053961 100644 (file)
@@ -129,18 +129,32 @@ endif
 # Rule to link composite objects
 #
 
-# for make >= 3.78 the following is cleaner:
-# multi-used := $(foreach m,$(obj-y) $(obj-m), $(if $($(basename $(m))-objs), $(m)))
+# export.o is never a composite object, since $(export-objs) has a
+# fixed meaning (== objects which EXPORT_SYMBOL())
 __obj-y = $(filter-out export.o,$(obj-y))
 __obj-m = $(filter-out export.o,$(obj-m))
-multi-used-y := $(sort $(foreach m,$(__obj-y),$(patsubst %,$(m),$($(basename $(m))-objs))))
-multi-used-m := $(sort $(foreach m,$(__obj-m),$(patsubst %,$(m),$($(basename $(m))-objs))))
-ld-multi-used-y := $(filter-out $(list-multi),$(multi-used-y))
-ld-multi-used-m := $(filter-out $(list-multi),$(multi-used-m))
-ld-multi-objs-y := $(foreach m, $(ld-multi-used-y), $($(basename $(m))-objs))
-ld-multi-objs-m := $(foreach m, $(ld-multi-used-m), $($(basename $(m))-objs))
-
-$(ld-multi-used-y) : %.o: $(ld-multi-objs-y)
+
+# if $(foo-objs) exists, foo.o is a composite object 
+__multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $($(basename $(m))-objs), $(m))))
+__multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $($(basename $(m))-objs), $(m))))
+
+# Backwards compatibility: if a composite object is listed in
+# $(list-multi), skip it here, since the Makefile will have an explicit
+# link rule for it
+
+multi-used-y := $(filter-out $(list-multi),$(__multi-used-y))
+multi-used-m := $(filter-out $(list-multi),$(__multi-used-m))
+
+# Build list of the parts of our composite objects, our composite
+# objects depend on those (obviously)
+multi-objs-y := $(foreach m, $(multi-used-y), $($(basename $(m))-objs))
+multi-objs-m := $(foreach m, $(multi-used-m), $($(basename $(m))-objs))
+
+# We would rather have a list of rules like
+#      foo.o: $(foo-objs)
+# but that's not so easy, so we rather make all composite objects depend
+# on the set of all their parts
+$(multi-used-y) : %.o: $(multi-objs-y)
        rm -f $@
        $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs), $^)
        @ ( \
@@ -149,7 +163,7 @@ $(ld-multi-used-y) : %.o: $(ld-multi-objs-y)
            echo 'endif' \
        ) > $(dir $@)/.$(notdir $@).flags
 
-$(ld-multi-used-m) : %.o: $(ld-multi-objs-m)
+$(multi-used-m) : %.o: $(multi-objs-m)
        rm -f $@
        $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs), $^)
        @ ( \