[PATCH] Common place for list-style -> old-style makefile adaption

From: Christoph Hellwig (hch@caldera.de)
Date: Thu Oct 26 2000 - 08:43:04 EST


Hi Linus,

in the current kernel versions we have a lot of new list-style makefiles
(find -name Makefile | xargs grep -l obj- | wc -l gives 48 in -pre5) and
the number increases all the time.
This patch adds a new makefile ($(TOPDIR])/Makefile.inc) that can be
included by the list-style makefiles, converts them to Rules.make syntax
and finally includes Rule.make.
This patch does also chnage a few makefile that comply 100% to the new
format to use Makefile.inc. The more difficult cases will follow soon if
this patch gets applied.

        Christoph

-- 
Always remember that you are unique.  Just like everyone else.

diff -uNr --exclude-from=dontdiff linux.orig/Makefile.inc linux/Makefile.inc --- linux.orig/Makefile.inc Thu Jan 1 01:00:00 1970 +++ linux/Makefile.inc Tue Oct 24 14:24:32 2000 @@ -0,0 +1,39 @@ +# +# Common makefile for inclusion in list-style subdirectory makefiles +# +# 24 October 2000, Christoph Hellwig <hch@caldera.de> +# Created from code in various subdirectory makefiles +# + + +# Subdirectories that should be entered when MAKING_MODULES=1, even if set to 'y'. +both-m := $(filter $(mod-subdirs), $(subdir-y)) + +# Extract lists of the multi-part drivers. +# The 'int-*' lists are the intermediate files used to build the multi's. +multi-y := $(filter $(list-multi), $(obj-y)) +multi-m := $(filter $(list-multi), $(obj-m)) +int-y := $(sort $(foreach m, $(multi-y), $($(basename $(m))-objs))) +int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs))) + +# Files that are both resident and modular: remove from modular. +obj-m := $(filter-out $(obj-y), $(obj-m)) +int-m := $(filter-out $(int-y), $(int-m)) + +# Take multi-part drivers out of obj-y and put components in. +obj-y := $(filter-out $(list-multi), $(obj-y)) $(int-y) + +# Translate to Rules.make lists. +O_OBJS := $(filter-out $(export-objs), $(obj-y)) +OX_OBJS := $(filter $(export-objs), $(obj-y)) +M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) +MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) +MI_OBJS := $(sort $(filter-out $(export-objs), $(int-m))) +MIX_OBJS := $(sort $(filter $(export-objs), $(int-m))) + +SUB_DIRS := $(subdir-y) +MOD_SUB_DIRS := $(sort $(subdir-m) $(both-m)) +ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-)) + +include $(TOPDIR)/Rules.make + diff -uNr --exclude-from=dontdiff linux.orig/arch/i386/kernel/Makefile linux/arch/i386/kernel/Makefile --- linux.orig/arch/i386/kernel/Makefile Thu Oct 19 13:21:16 2000 +++ linux/arch/i386/kernel/Makefile Tue Oct 24 14:35:28 2000 @@ -1,14 +1,9 @@ # # Makefile for the linux kernel. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are now in the main makefile... -.S.o: - $(CC) $(AFLAGS) -traditional -c $< -o $*.o +USE_STANDARD_AS_RULE := 1 +EXTRA_AFLAGS := -traditional all: kernel.o head.o init_task.o @@ -46,9 +41,4 @@ obj-$(CONFIG_ACPI) += acpi.o endif -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/drivers/i2c/Makefile linux/drivers/i2c/Makefile --- linux.orig/drivers/i2c/Makefile Wed Oct 18 15:54:52 2000 +++ linux/drivers/i2c/Makefile Tue Oct 24 14:28:34 2000 @@ -18,10 +18,5 @@ # This is needed for automatic patch generation: sensors code starts here # This is needed for automatic patch generation: sensors code ends here -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/drivers/i2o/Makefile linux/drivers/i2o/Makefile --- linux.orig/drivers/i2o/Makefile Wed Oct 18 15:53:19 2000 +++ linux/drivers/i2o/Makefile Tue Oct 24 14:28:46 2000 @@ -16,10 +16,5 @@ obj-$(CONFIG_I2O_SCSI) += i2o_scsi.o obj-$(CONFIG_I2O_PROC) += i2o_proc.o -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/drivers/ide/Makefile linux/drivers/ide/Makefile --- linux.orig/drivers/ide/Makefile Tue Oct 24 13:15:37 2000 +++ linux/drivers/ide/Makefile Tue Oct 24 14:29:10 2000 @@ -8,10 +8,6 @@ # In the future, some of these should be built conditionally. # -SUB_DIRS := -MOD_SUB_DIRS := $(SUB_DIRS) -ALL_SUB_DIRS := $(SUB_DIRS) - O_TARGET := idedriver.o obj-y := @@ -70,24 +66,7 @@ obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o -# Extract lists of the multi-part drivers. -# The 'int-*' lists are the intermediate files used to build the multi's. -multi-y := $(filter $(list-multi), $(obj-y)) -multi-m := $(filter $(list-multi), $(obj-m)) -int-y := $(sort $(foreach m, $(multi-y), $($(basename $(m))-objs))) -int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs))) - -# Take multi-part drivers out of obj-y and put components in. -obj-y := $(filter-out $(list-multi), $(obj-y)) $(int-y) - -# Translate to Rules.make lists. -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MI_OBJS := $(sort $(filter-out $(export-objs), $(int-m))) -MIX_OBJS := $(sort $(filter $(export-objs), $(int-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc ide-mod.o: $(ide-mod-objs) $(LD) -r -o $@ $(ide-mod-objs) diff -uNr --exclude-from=dontdiff linux.orig/drivers/input/Makefile linux/drivers/input/Makefile --- linux.orig/drivers/input/Makefile Wed Oct 18 15:55:16 2000 +++ linux/drivers/input/Makefile Tue Oct 24 14:29:33 2000 @@ -2,18 +2,9 @@ # Makefile for the input core drivers. # -# Subdirs. - -SUB_DIRS := -MOD_SUB_DIRS := $(SUB_DIRS) -MOD_IN_SUB_DIRS := $(SUB_DIRS) -ALL_SUB_DIRS := $(SUB_DIRS) - # The target object and module list name. O_TARGET := inputdrv.o -M_OBJS := -O_OBJS := # Objects that export symbols. @@ -34,18 +25,6 @@ obj-$(CONFIG_INPUT_JOYDEV) += joydev.o obj-$(CONFIG_INPUT_EVDEV) += evdev.o -# Files that are both resident and modular: remove from modular. - -obj-m := $(filter-out $(obj-y), $(obj-m)) -int-m := $(filter-out $(int-y), $(int-m)) - -# Translate to Rules.make lists. - -O_OBJS := $(sort $(filter-out $(export-objs), $(obj-y))) -OX_OBJS := $(sort $(filter $(export-objs), $(obj-y))) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -# The global Rules.make. +# The global Makefile.inc. -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/drivers/macintosh/Makefile linux/drivers/macintosh/Makefile --- linux.orig/drivers/macintosh/Makefile Thu Oct 19 13:21:26 2000 +++ linux/drivers/macintosh/Makefile Tue Oct 24 14:30:06 2000 @@ -1,27 +1,10 @@ # # Makefile for the Macintosh-specific device drivers. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are now inherited from the -# parent makes.. -# - -# Subdirs. - -SUB_DIRS := -MOD_SUB_DIRS := $(SUB_DIRS) -MOD_IN_SUB_DIRS := $(SUB_DIRS) -ALL_SUB_DIRS := $(SUB_DIRS) -# The target object and module list name. +# The target object name. O_TARGET := macintosh.o -M_OBJS := -O_OBJS := -MOD_LIST_NAME := MACINTOSH_MODULES # Objects that export symbols. @@ -57,19 +40,7 @@ obj-$(CONFIG_ADB_PMU68K) += via-pmu68k.o obj-$(CONFIG_ADB_MACIO) += macio-adb.o -# Files that are both resident and modular: remove from modular. - -obj-m := $(filter-out $(obj-y), $(obj-m)) -int-m := $(filter-out $(int-y), $(int-m)) - -# Translate to Rules.make lists. - -O_OBJS := $(sort $(filter-out $(export-objs), $(obj-y))) -OX_OBJS := $(sort $(filter $(export-objs), $(obj-y))) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - - # The global Rules.make. + # The global Makefile.inc -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/drivers/md/Makefile linux/drivers/md/Makefile --- linux.orig/drivers/md/Makefile Thu Oct 19 13:21:26 2000 +++ linux/drivers/md/Makefile Tue Oct 24 14:30:22 2000 @@ -3,9 +3,6 @@ # O_TARGET := mddev.o -SUB_DIRS := -ALL_SUB_DIRS := -MOD_SUB_DIRS := export-objs := md.o xor.o list-multi := lvm-mod.o @@ -23,13 +20,7 @@ obj-$(CONFIG_MD_RAID5) += raid5.o xor.o obj-$(CONFIG_BLK_DEV_LVM) += lvm-mod.o -# Translate to Rules.make lists. -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc lvm-mod.o: $(lvm-mod-objs) $(LD) -r -o $@ $(lvm-mod-objs) diff -uNr --exclude-from=dontdiff linux.orig/drivers/media/radio/Makefile linux/drivers/media/radio/Makefile --- linux.orig/drivers/media/radio/Makefile Thu Oct 19 13:21:26 2000 +++ linux/drivers/media/radio/Makefile Tue Oct 24 14:30:55 2000 @@ -1,18 +1,6 @@ # # Makefile for the kernel character device drivers. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are now inherited from the -# parent makes.. -# - -O_OBJS := -OX_OBJS := -M_OBJS := -MX_OBJS := # Object file lists. @@ -21,10 +9,6 @@ obj-n := obj- := -SUB_DIRS := -MOD_SUB_DIRS := $(SUB_DIRS) -ALL_SUB_DIRS := $(SUB_DIRS) - O_TARGET := radio.o # All of the (potential) objects that export symbols. @@ -47,30 +31,4 @@ obj-$(CONFIG_RADIO_TRUST) += radio-trust.o obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o -# Extract lists of the multi-part drivers. -# The 'int-*' lists are the intermediate files used to build the multi's. - -multi-y := $(filter $(list-multi), $(obj-y)) -multi-m := $(filter $(list-multi), $(obj-m)) -int-y := $(sort $(foreach m, $(multi-y), $($(basename $(m))-objs))) -int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs))) - -# Files that are both resident and modular: remove from modular. - -obj-m := $(filter-out $(obj-y), $(obj-m)) -int-m := $(filter-out $(int-y), $(int-m)) - -# Take multi-part drivers out of obj-y and put components in. - -obj-y := $(filter-out $(list-multi), $(obj-y)) $(int-y) - -# Translate to Rules.make lists. - -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) -MI_OBJS := $(sort $(filter-out $(export-objs), $(int-m))) -MIX_OBJS := $(sort $(filter $(export-objs), $(int-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/drivers/media/video/Makefile linux/drivers/media/video/Makefile --- linux.orig/drivers/media/video/Makefile Wed Oct 18 15:55:18 2000 +++ linux/drivers/media/video/Makefile Tue Oct 24 14:31:17 2000 @@ -1,18 +1,6 @@ # # Makefile for the kernel character device drivers. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are now inherited from the -# parent makes.. -# - -O_OBJS := -OX_OBJS := -M_OBJS := -MX_OBJS := # Object file lists. @@ -21,10 +9,6 @@ obj-n := obj- := -SUB_DIRS := -MOD_SUB_DIRS := $(SUB_DIRS) -ALL_SUB_DIRS := $(SUB_DIRS) - O_TARGET := video.o # All of the (potential) objects that export symbols. @@ -59,33 +43,7 @@ obj-$(CONFIG_VIDEO_CPIA_USB) += cpia_usb.o obj-$(CONFIG_TUNER_3036) += tuner-3036.o -# Extract lists of the multi-part drivers. -# The 'int-*' lists are the intermediate files used to build the multi's. - -multi-y := $(filter $(list-multi), $(obj-y)) -multi-m := $(filter $(list-multi), $(obj-m)) -int-y := $(sort $(foreach m, $(multi-y), $($(basename $(m))-objs))) -int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs))) - -# Files that are both resident and modular: remove from modular. - -obj-m := $(filter-out $(obj-y), $(obj-m)) -int-m := $(filter-out $(int-y), $(int-m)) - -# Take multi-part drivers out of obj-y and put components in. - -obj-y := $(filter-out $(list-multi), $(obj-y)) $(int-y) - -# Translate to Rules.make lists. - -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) -MI_OBJS := $(sort $(filter-out $(export-objs), $(int-m))) -MIX_OBJS := $(sort $(filter $(export-objs), $(int-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc fastdep: diff -uNr --exclude-from=dontdiff linux.orig/drivers/sbus/audio/Makefile linux/drivers/sbus/audio/Makefile --- linux.orig/drivers/sbus/audio/Makefile Tue Oct 24 13:15:44 2000 +++ linux/drivers/sbus/audio/Makefile Tue Oct 24 14:32:30 2000 @@ -15,9 +15,4 @@ obj-$(CONFIG_SPARCAUDIO_DBRI) += dbri.o obj-$(CONFIG_SPARCAUDIO_DUMMY) += dmy.o -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/drivers/telephony/Makefile linux/drivers/telephony/Makefile --- linux.orig/drivers/telephony/Makefile Thu Oct 19 13:21:35 2000 +++ linux/drivers/telephony/Makefile Tue Oct 24 14:33:08 2000 @@ -1,14 +1,6 @@ # # Makefile for drivers/telephony # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# - -SUB_DIRS := -MOD_SUB_DIRS := $(SUB_DIRS) -ALL_SUB_DIRS := $(SUB_DIRS) obj-y := obj-n := @@ -19,11 +11,5 @@ obj-$(CONFIG_PHONE) += phonedev.o obj-$(CONFIG_PHONE_IXJ) += ixj.o -O_TARGET := telephony.o -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/fs/Makefile linux/fs/Makefile --- linux.orig/fs/Makefile Thu Oct 19 13:21:36 2000 +++ linux/fs/Makefile Tue Oct 24 14:25:33 2000 @@ -74,18 +74,4 @@ # persistent filesystems obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o)) - -# Subdirectories that should be entered when MAKING_MODULES=1, even if set to 'y'. -both-m := $(filter $(mod-subdirs), $(subdir-y)) - -# Translate to Rules.make lists. -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -SUB_DIRS := $(subdir-y) -MOD_SUB_DIRS := $(sort $(subdir-m) $(both-m)) -ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-)) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/fs/nls/Makefile linux/fs/nls/Makefile --- linux.orig/fs/nls/Makefile Wed Oct 18 15:55:01 2000 +++ linux/fs/nls/Makefile Tue Oct 24 14:26:22 2000 @@ -2,6 +2,8 @@ # Makefile for native language support # +O_TARGET = nls.o + obj-y := nls_base.o obj-m := obj-n := @@ -52,9 +54,5 @@ obj-$(CONFIG_NLS_ABC) += nls_abc.o obj-$(CONFIG_NLS_UTF8) += nls_utf8.o -OX_OBJS = $(obj-y) -M_OBJS = $(obj-m) - -O_TARGET = nls.o -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/fs/partitions/Makefile linux/fs/partitions/Makefile --- linux.orig/fs/partitions/Makefile Wed Oct 18 15:54:38 2000 +++ linux/fs/partitions/Makefile Tue Oct 24 14:27:08 2000 @@ -1,14 +1,12 @@ # # Makefile for the linux kernel. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are now in the main makefile... -O_TARGET := partitions.o -OX_OBJS := check.o +O_TARGET := partitions.o + +export-objs := check.o +obj-y := check.o + obj-$(CONFIG_ACORN_PARTITION) += acorn.o obj-$(CONFIG_AMIGA_PARTITION) += amiga.o @@ -21,8 +19,5 @@ obj-$(CONFIG_ULTRIX_PARTITION) += ultrix.o obj-$(CONFIG_IBM_PARTITION) += ibm.o -O_OBJS += $(obj-y) -M_OBJS += $(obj-m) - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc diff -uNr --exclude-from=dontdiff linux.orig/net/Makefile linux/net/Makefile --- linux.orig/net/Makefile Tue Oct 24 13:15:58 2000 +++ linux/net/Makefile Tue Oct 24 14:24:52 2000 @@ -52,19 +52,4 @@ obj-$(CONFIG_SYSCTL) += sysctl_net.o endif - -# Subdirectories that should be entered when MAKING_MODULES=1, even if set to 'y'. -both-m := $(filter $(mod-subdirs), $(subdir-y)) - -# Translate to Rules.make lists. -O_OBJS := $(filter-out $(export-objs), $(obj-y)) -OX_OBJS := $(filter $(export-objs), $(obj-y)) -M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) -MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) - -SUB_DIRS := $(subdir-y) -MOD_SUB_DIRS := $(sort $(subdir-m) $(both-m)) -ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-)) - - -include $(TOPDIR)/Rules.make +include $(TOPDIR)/Makefile.inc - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Oct 31 2000 - 21:00:18 EST