2002-10-03 02:53:51

by Kai Germaschewski

[permalink] [raw]
Subject: RfC: Don't cd into subdirs during kbuild


Hi,

I'd appreciate to get comments on the appended patch. It's mostly cleanups
and the like, but the interesting part is the last cset, which is actually
fairly small:

14 files changed, 64 insertions(+), 47 deletions(-)

The build process remains recursive, but it changes the recursion
from

make -C subdir

to

make -f subdir/Makefile

i.e. the current working directory remains the top dir for all times. So
gcc/ld/.. are now called from the topdir, allowing to closer resemble
a non-recursive build. Some Makefiles may need a little additional
tweaking (in particular arch/*), but generally, the changes required are
pretty small.

I'd appreciate comments and/or testing, if I hear no complaints, it'll go
to Linus soon ;)

--Kai


Pull from http://linux-isdn.bkbits.net/linux-2.5.make

(Merging changesets omitted for clarity)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:23:38-05:00, [email protected]
kbuild: Small cleanups

o Use a function "descend" for descending into subdirectories
o Remove unused (?) "boot" target
o Remove unnecessary intermediate "sub_dirs" target from Rules.make
o Use /bin/true instead of echo -n to suppress spurious
"nothing to be done for ..." output from make

----------------------------------------------------------------------------
Makefile | 53 +++++++++++++++++++++++++----------------------------
Rules.make | 27 +++++++++++++++------------
2 files changed, 40 insertions(+), 40 deletions(-)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:42:00-05:00, [email protected]
kbuild: Remove xfs vpath hack

xfs.o is built as one modules out of objects distributed into
multiple subdirs. That is okay with the current kbuild, you just
have to include the path for objects which reside in a subdir, then.

xfs used vpath instead of explicitly adding the paths, which is
inconsistent and conflicts e.g. with proper module version generation.

----------------------------------------------------------------------------
Rules.make | 3 +--
fs/xfs/Makefile | 27 +++++++++++++--------------
2 files changed, 14 insertions(+), 16 deletions(-)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:46:16-05:00, [email protected]
kbuild: Standardize ACPI Makefiles

ACPI was a bit lazy and just said compile all .c files in this directory,
which is different from all other Makefiles and will not work very
well e.g. bk, where a .c file may not be checked out yet, or separate
obj/src dirs. So just explicitly list the files we want to compile.

----------------------------------------------------------------------------
dispatcher/Makefile | 3 ++-
events/Makefile | 3 ++-
executer/Makefile | 5 ++++-
hardware/Makefile | 2 +-
namespace/Makefile | 4 +++-
parser/Makefile | 3 ++-
resources/Makefile | 3 ++-
tables/Makefile | 3 ++-
utilities/Makefile | 3 ++-
9 files changed, 20 insertions(+), 9 deletions(-)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:54:37-05:00, [email protected]
kbuild: Small quirks for separate obj / src trees

Add a couple of missing $(obj) and the like.

Also, remove the __chmod hack which made some files in the source tree
executable - hopefully, everybody's copy is by now ;)

----------------------------------------------------------------------------
drivers/isdn/hisax/Makefile | 2 +-
drivers/pci/Makefile | 2 +-
drivers/zorro/Makefile | 2 +-
scripts/Makefile | 11 +++--------
scripts/lxdialog/Makefile | 6 +++++-
5 files changed, 11 insertions(+), 12 deletions(-)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:59:28-05:00, [email protected]
kbuild: Add some bug traps

Makefiles which still use obsolete 2.4 constructs now give a warning.

----------------------------------------------------------------------------
Rules.make | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 16:29:37-05:00, [email protected]
kbuild: Handle $(core-y) the same way as $(init-y), $(drivers-y) etc

$(CORE_FILES) did not quite follow the way the other vmlinux parts where
handled, due to potential init order dependencies. However, it seems
everybody is putting arch specific stuff in front, so we keep doing
this and nothing should break ;)

----------------------------------------------------------------------------
Makefile | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 16:57:45-05:00, [email protected]
kbuild: Use $(core-y) and friends directly

The capitalized aliases $(CORE_FILES) etc are basically superfluous now,
move the remaining users to $(core-y) and the like.

----------------------------------------------------------------------------
Makefile | 42 +++++++++++++++++++-----------------------
arch/alpha/Makefile | 2 ++
arch/alpha/boot/Makefile | 2 +-
arch/sparc/Makefile | 3 +--
arch/sparc/boot/Makefile | 5 ++---
drivers/isdn/i4l/isdn_ppp.h | 2 +-
6 files changed, 26 insertions(+), 30 deletions(-)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 17:52:22-05:00, [email protected]
kbuild: Always build helpers in script/

As noticed by Sam Ravnborg, we need the targets in scripts (fixdep,
in particular) considered always, i.e. also when compiling modules.

----------------------------------------------------------------------------
Makefile | 5 +++++
1 files changed, 5 insertions(+)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 21:51:28-05:00, [email protected]
kbuild: Don't cd into subdirs during build

Instead of using make -C <subdir>, just use make -f <subdir>/Makefile.
This means we now call gcc/ld/... always from the topdir.

Advantages are:
o We don't need to use -I$(TOPDIR)/include and the like, just
-Iinclude works.
o __FILE__ gives the correct relative path from the topdir instead
of an absolute path, as it did before for included headers
o gcc errors/warnings give the correct relative path from the topdir
o takes us a step closer to a non-recursive build (though that's probably
as close as it gets)

The changes to Rules.make were done in a way which only uses the new way
for the standard recursive build (which remains recursive, just without
cd), all the archs do make -C arch/$(ARCH)/boot ..., which should keep
working as before. However, of course this should be converted eventually,
it's possible to do so piecemeal arch by arch.

It seems to work fine for most of the standard kernel. Potential places
which need changing are added -I flags to the command line, which now
need to have the path relative to the topdir and explicit rules for
generating files, which need to properly use $(obj) / $(src) to work
correctly.

----------------------------------------------------------------------------
Rules.make | 79 +++++++++++++++++++++++---------------
arch/i386/Makefile | 4 -
arch/i386/boot/Makefile | 2
drivers/acpi/Makefile | 2
drivers/ide/arm/Makefile | 2
drivers/ide/legacy/Makefile | 2
drivers/ide/pci/Makefile | 2
drivers/ide/ppc/Makefile | 2
drivers/message/fusion/Makefile | 2
drivers/net/sk98lin/Makefile | 2
drivers/net/skfp/Makefile | 2
drivers/scsi/sym53c8xx_2/Makefile | 2
drivers/usb/storage/Makefile | 2
fs/xfs/Makefile | 6 +-
14 files changed, 64 insertions(+), 47 deletions(-)





=============================================================================
unified diffs follow for reference
=============================================================================

-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:23:38-05:00, [email protected]
kbuild: Small cleanups

o Use a function "descend" for descending into subdirectories
o Remove unused (?) "boot" target
o Remove unnecessary intermediate "sub_dirs" target from Rules.make
o Use /bin/true instead of echo -n to suppress spurious
"nothing to be done for ..." output from make

---------------------------------------------------------------------------

diff -Nru a/Makefile b/Makefile
--- a/Makefile Wed Oct 2 21:51:56 2002
+++ b/Makefile Wed Oct 2 21:51:56 2002
@@ -52,13 +52,6 @@

all: vmlinux

-# Print entire command lines instead of short version
-# For now, leave the default
-
-ifndef KBUILD_VERBOSE
- KBUILD_VERBOSE = 1
-endif
-
# Decide whether to build built-in, modular, or both.
# Normally, just do built-in.

@@ -105,6 +98,12 @@
# If it is set to "silent_", nothing wil be printed at all, since
# the variable $(silent_cmd_cc_o_c) doesn't exist.

+# For now, leave verbose as default
+
+ifndef KBUILD_VERBOSE
+ KBUILD_VERBOSE = 1
+endif
+
# If the user wants quiet mode, echo short versions of the commands
# only and suppress the 'Entering/Leaving directory' messages

@@ -120,7 +119,7 @@
quiet=silent_
endif

-export quiet
+export quiet KBUILD_VERBOSE

#
# Include the make variables (CC, etc...)
@@ -183,7 +182,7 @@

.PHONY: scripts
scripts:
- @$(MAKE) -C scripts
+ @$(call descend,scripts,)

ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)

@@ -276,12 +275,6 @@

export NETWORKS DRIVERS LIBS HEAD LDFLAGS MAKEBOOT

-# boot target
-# ---------------------------------------------------------------------------
-
-boot: vmlinux
- @$(MAKE) -C arch/$(ARCH)/boot
-
# Build vmlinux
# ---------------------------------------------------------------------------

@@ -314,7 +307,7 @@
echo ' Generating build number'
. scripts/mkversion > .tmp_version
mv -f .tmp_version .version
- +$(MAKE) -C init
+ +$(call descend,init,)
$(call cmd,link_vmlinux)
echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd
$(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
@@ -363,7 +356,7 @@

.PHONY: $(SUBDIRS)
$(SUBDIRS): .hdepend prepare
- @$(MAKE) -C $@
+ @$(call descend,$@,)

# Things we need done before we descend to build or make
# module versions are listed in "prepare"
@@ -386,17 +379,17 @@
# ---------------------------------------------------------------------------

%.s: %.c FORCE
- @$(MAKE) -C $(@D) $(@F)
+ @$(call descend,$(@D),$(@F))
%.i: %.c FORCE
- @$(MAKE) -C $(@D) $(@F)
+ @$(call descend,$(@D),$(@F))
%.o: %.c FORCE
- @$(MAKE) -C $(@D) $(@F)
+ @$(call descend,$(@D),$(@F))
%.lst: %.c FORCE
- @$(MAKE) -C $(@D) $(@F)
+ @$(call descend,$(@D),$(@F))
%.s: %.S FORCE
- @$(MAKE) -C $(@D) $(@F)
+ @$(call descend,$(@D),$(@F))
%.o: %.S FORCE
- @$(MAKE) -C $(@D) $(@F)
+ @$(call descend,$(@D),$(@F))

# FIXME: The asm symlink changes when $(ARCH) changes. That's
# hard to detect, but I suppose "make mrproper" is a good idea
@@ -481,7 +474,7 @@
$(update-if-changed)

$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE
- @$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep
+ @$(call descend,$(patsubst _sfdep_%,%,$@),fastdep)

else # !CONFIG_MODVERSIONS

@@ -533,7 +526,7 @@

.PHONY: $(patsubst %, _modinst_%, $(SUBDIRS))
$(patsubst %, _modinst_%, $(SUBDIRS)) :
- @$(MAKE) -C $(patsubst _modinst_%, %, $@) modules_install
+ $(descend,$(patsubst _modinst_%,%,$@),modules_install)

else # CONFIG_MODULES

@@ -631,11 +624,11 @@
make_with_config

xconfig:
- @$(MAKE) -C scripts kconfig.tk
+ @$(call descend,scripts,kconfig.tk)
wish -f scripts/kconfig.tk

menuconfig:
- @$(MAKE) -C scripts lxdialog
+ @$(call descend,scripts,lxdialog)
$(CONFIG_SHELL) $(src)/scripts/Menuconfig arch/$(ARCH)/config.in

config:
@@ -734,7 +727,7 @@
-type f -print | xargs rm -f
@rm -rf $(MRPROPER_DIRS)
@rm -f $(MRPROPER_FILES)
- @$(MAKE) -C scripts mrproper
+ @$(call descend,scripts,mrproper)
@$(MAKE) -f Documentation/DocBook/Makefile mrproper

distclean: mrproper
@@ -909,5 +902,9 @@
fi
endef

+# $(call descend,<dir>,<target>)
+# Recursively call a sub-make in <dir> with target <target>
+
+descend = $(MAKE) -C $(1) $(2)

FORCE:
diff -Nru a/Rules.make b/Rules.make
--- a/Rules.make Wed Oct 2 21:51:56 2002
+++ b/Rules.make Wed Oct 2 21:51:56 2002
@@ -136,8 +136,8 @@
# If we don't export any symbols in this dir, just descend
# ---------------------------------------------------------------------------

-fastdep: sub_dirs
- @echo -n
+fastdep: $(subdir-ym)
+ @/bin/true

else

@@ -206,7 +206,7 @@

targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))

-fastdep: $(targets) sub_dirs
+fastdep: $(targets) $(subdir-ym)
@mkdir -p $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)
@touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver))

@@ -221,13 +221,13 @@

.PHONY: modules_install

-modules_install: sub_dirs
+modules_install: $(subdir-ym)
ifneq ($(obj-m),)
@echo Installing modules in $(MODLIB)/kernel/$(RELDIR)
@mkdir -p $(MODLIB)/kernel/$(RELDIR)
@cp $(obj-m) $(MODLIB)/kernel/$(RELDIR)
else
- @echo -n
+ @/bin/true
endif

else # ! modules_install
@@ -248,8 +248,8 @@
# The echo suppresses the "Nothing to be done for first_rule"
first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
$(if $(KBUILD_MODULES),$(obj-m)) \
- sub_dirs
- @echo -n
+ $(subdir-ym)
+ @/bin/true

# Compile C sources (.c)
# ---------------------------------------------------------------------------
@@ -324,7 +324,7 @@
# ---------------------------------------------------------------------------

# To build objects in subdirs, we need to descend into the directories
-$(sort $(subdir-obj-y)): sub_dirs ;
+$(sort $(subdir-obj-y)): $(subdir-ym) ;

#
# Rule to compile a set of .o files into one .o file
@@ -454,12 +454,10 @@
# Descending
# ---------------------------------------------------------------------------

-.PHONY: sub_dirs $(subdir-ym)
-
-sub_dirs: $(subdir-ym)
+.PHONY: $(subdir-ym)

$(subdir-ym):
- @$(MAKE) -C $@ $(MAKECMDGOALS)
+ @$(call descend,$@,$(MAKECMDGOALS))

# Add FORCE to the prequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------
@@ -573,4 +571,9 @@
echo "$(2)" &&)) \
$(2)
endef
+
+# $(call descend,<dir>,<target>)
+# Recursively call a sub-make in <dir> with target <target>
+
+descend = $(MAKE) -C $(1) $(2)


-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:42:00-05:00, [email protected]
kbuild: Remove xfs vpath hack

xfs.o is built as one modules out of objects distributed into
multiple subdirs. That is okay with the current kbuild, you just
have to include the path for objects which reside in a subdir, then.

xfs used vpath instead of explicitly adding the paths, which is
inconsistent and conflicts e.g. with proper module version generation.

---------------------------------------------------------------------------

diff -Nru a/Rules.make b/Rules.make
--- a/Rules.make Wed Oct 2 21:51:58 2002
+++ b/Rules.make Wed Oct 2 21:51:58 2002
@@ -207,7 +207,7 @@
targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))

fastdep: $(targets) $(subdir-ym)
- @mkdir -p $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)
+ @mkdir -p $(dir $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR),$(export-objs:.o=.ver)))
@touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver))

endif # export-objs
@@ -245,7 +245,6 @@
endif
endif

-# The echo suppresses the "Nothing to be done for first_rule"
first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
$(if $(KBUILD_MODULES),$(obj-m)) \
$(subdir-ym)
diff -Nru a/fs/xfs/Makefile b/fs/xfs/Makefile
--- a/fs/xfs/Makefile Wed Oct 2 21:51:58 2002
+++ b/fs/xfs/Makefile Wed Oct 2 21:51:58 2002
@@ -32,11 +32,6 @@
# Makefile for XFS on Linux.
#

-
-# we also have source in the subdirectories..
-vpath %.c = . linux pagebuf support
-
-
# This needs -I. because everything does #include <xfs.h> instead of "xfs.h".
# The code is wrong, local files should be included using "xfs.h", not <xfs.h>
# but I am not going to change every file at the moment.
@@ -49,7 +44,8 @@
EXTRA_CFLAGS += -DPAGEBUF_TRACE
endif

-export-objs := page_buf.o ktrace.o xfs_globals.o
+export-objs := pagebuf/page_buf.o support/ktrace.o \
+ linux/xfs_globals.o

obj-$(CONFIG_XFS_FS) += xfs.o

@@ -65,8 +61,8 @@
xfs-obj-$(CONFIG_FS_POSIX_ACL) += xfs_acl.o
xfs-obj-$(CONFIG_FS_POSIX_CAP) += xfs_cap.o
xfs-obj-$(CONFIG_FS_POSIX_MAC) += xfs_mac.o
-xfs-obj-$(CONFIG_PROC_FS) += xfs_stats.o
-xfs-obj-$(CONFIG_SYSCTL) += xfs_sysctl.o
+xfs-obj-$(CONFIG_PROC_FS) += linux/xfs_stats.o
+xfs-obj-$(CONFIG_SYSCTL) += linux/xfs_sysctl.o


xfs-objs += $(xfs-obj-y) \
@@ -118,11 +114,13 @@
xfs_rw.o

# Objects in pagebuf/
-xfs-objs += page_buf.o \
- page_buf_locking.o
+xfs-objs += $(addprefix pagebuf/, \
+ page_buf.o \
+ page_buf_locking.o)

# Objects in linux/
-xfs-objs += xfs_aops.o \
+xfs-objs += $(addprefix linux/, \
+ xfs_aops.o \
xfs_behavior.o \
xfs_file.o \
xfs_fs_subr.o \
@@ -131,16 +129,17 @@
xfs_iops.o \
xfs_lrw.o \
xfs_super.o \
- xfs_vnode.o
+ xfs_vnode.o)

# Objects in support/
-xfs-objs += debug.o \
+xfs-objs += $(addprefix support/, \
+ debug.o \
kmem.o \
ktrace.o \
move.o \
mrlock.o \
qsort.o \
- uuid.o
+ uuid.o)

# If both xfs and kdb modules are built in then xfsidbg is built in. If xfs is
# a module and kdb modules are being compiled then xfsidbg must be a module, to

-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:46:16-05:00, [email protected]
kbuild: Standardize ACPI Makefiles

ACPI was a bit lazy and just said compile all .c files in this directory,
which is different from all other Makefiles and will not work very
well e.g. bk, where a .c file may not be checked out yet, or separate
obj/src dirs. So just explicitly list the files we want to compile.

---------------------------------------------------------------------------

diff -Nru a/drivers/acpi/dispatcher/Makefile b/drivers/acpi/dispatcher/Makefile
--- a/drivers/acpi/dispatcher/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/dispatcher/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,8 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
+ dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)

diff -Nru a/drivers/acpi/events/Makefile b/drivers/acpi/events/Makefile
--- a/drivers/acpi/events/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/events/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,8 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := evevent.o evregion.o evsci.o evxfevnt.o \
+ evmisc.o evrgnini.o evxface.o evxfregn.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)

diff -Nru a/drivers/acpi/executer/Makefile b/drivers/acpi/executer/Makefile
--- a/drivers/acpi/executer/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/executer/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,10 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\
+ exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\
+ excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \
+ exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)

diff -Nru a/drivers/acpi/hardware/Makefile b/drivers/acpi/hardware/Makefile
--- a/drivers/acpi/hardware/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/hardware/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,7 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := hwacpi.o hwgpe.o hwregs.o hwsleep.o hwtimer.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)

diff -Nru a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile
--- a/drivers/acpi/namespace/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/namespace/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,9 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := nsaccess.o nsdumpdv.o nsload.o nssearch.o nsxfeval.o \
+ nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
+ nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)

diff -Nru a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile
--- a/drivers/acpi/parser/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/parser/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,8 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := psargs.o psparse.o pstree.o pswalk.o \
+ psopcode.o psscope.o psutils.o psxface.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)

diff -Nru a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile
--- a/drivers/acpi/resources/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/resources/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,8 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := rsaddr.o rscreate.o rsio.o rslist.o rsmisc.o rsxface.o \
+ rscalc.o rsdump.o rsirq.o rsmemory.o rsutils.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)

diff -Nru a/drivers/acpi/tables/Makefile b/drivers/acpi/tables/Makefile
--- a/drivers/acpi/tables/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/tables/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,8 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := tbconvrt.o tbget.o tbrsdt.o tbxface.o \
+ tbgetall.o tbinstal.o tbutils.o tbxfroot.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)

diff -Nru a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
--- a/drivers/acpi/utilities/Makefile Wed Oct 2 21:52:00 2002
+++ b/drivers/acpi/utilities/Makefile Wed Oct 2 21:52:00 2002
@@ -2,7 +2,8 @@
# Makefile for all Linux ACPI interpreter subdirectories
#

-obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
+ utcopy.o utdelete.o utglobal.o utmath.o utobject.o

EXTRA_CFLAGS += $(ACPI_CFLAGS)


-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:54:37-05:00, [email protected]
kbuild: Small quirks for separate obj / src trees

Add a couple of missing $(obj) and the like.

Also, remove the __chmod hack which made some files in the source tree
executable - hopefully, everybody's copy is by now ;)

---------------------------------------------------------------------------

diff -Nru a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
--- a/drivers/isdn/hisax/Makefile Wed Oct 2 21:52:01 2002
+++ b/drivers/isdn/hisax/Makefile Wed Oct 2 21:52:01 2002
@@ -63,7 +63,7 @@

hisax-objs += $(hisax-objs-y)

-CERT := $(shell md5sum -c md5sums.asc >> /dev/null;echo $$?)
+CERT := $(shell cd $(src); md5sum -c md5sums.asc > /dev/null 2> /dev/null ;echo $$?)
CFLAGS_cert.o := -DCERTIFICATION=$(CERT)

include $(TOPDIR)/Rules.make
diff -Nru a/drivers/pci/Makefile b/drivers/pci/Makefile
--- a/drivers/pci/Makefile Wed Oct 2 21:52:01 2002
+++ b/drivers/pci/Makefile Wed Oct 2 21:52:01 2002
@@ -40,6 +40,6 @@
# And that's how to generate them

$(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist
- $(obj)/gen-devlist < $<
+ ( cd $(obj); ./gen-devlist ) < $<

$(obj)/classlist.h: $(obj)/devlist.h
diff -Nru a/drivers/zorro/Makefile b/drivers/zorro/Makefile
--- a/drivers/zorro/Makefile Wed Oct 2 21:52:01 2002
+++ b/drivers/zorro/Makefile Wed Oct 2 21:52:01 2002
@@ -18,4 +18,4 @@
# And that's how to generate them

$(obj)/devlist.h: $(src)/zorro.ids $(obj)/gen-devlist
- $(obj)/gen-devlist < $<
+ ( cd $(obj); ./gen-devlist ) < $<
diff -Nru a/scripts/Makefile b/scripts/Makefile
--- a/scripts/Makefile Wed Oct 2 21:52:01 2002
+++ b/scripts/Makefile Wed Oct 2 21:52:01 2002
@@ -9,18 +9,13 @@
# conmakehash: Create arrays for initializing the kernel console tables
# tkparse: Used by xconfig

-all: fixdep split-include docproc conmakehash __chmod
+EXTRA_TARGETS := fixdep split-include docproc conmakehash

# The following temporary rule will make sure that people's
# trees get updated to the right permissions, since patch(1)
# can't do it
# ---------------------------------------------------------------------------

-.PHONY: __chmod
-
-__chmod: kernel-doc mkcompile_h makelst
- @chmod a+x $^
-
host-progs := fixdep split-include conmakehash docproc tkparse
tkparse-objs := tkparse.o tkcond.o tkgen.o

@@ -30,7 +25,7 @@
# but it is not worth the effort to generate the dependencies.
# The alternative solution to always generate it is fairly fast.
# FORCE it to remake
-$(obj)/kconfig.tk: $(srctree)/arch/$(ARCH)/config.in tkparse FORCE
+$(obj)/kconfig.tk: $(srctree)/arch/$(ARCH)/config.in $(obj)/tkparse FORCE
@echo ' Generating $@'
@( \
if [ -f /usr/local/bin/wish ]; then \
@@ -51,7 +46,7 @@
# Targets hardcoded and wellknow in top-level makefile
.PHONY: lxdialog
lxdialog:
- $(MAKE) -C lxdialog all
+ $(call descend,lxdialog,)

# fixdep is needed to compile other host programs
$(obj)/split-include $(obj)/docproc $(addprefix $(obj)/,$(tkparse-objs)) \
diff -Nru a/scripts/lxdialog/Makefile b/scripts/lxdialog/Makefile
--- a/scripts/lxdialog/Makefile Wed Oct 2 21:52:01 2002
+++ b/scripts/lxdialog/Makefile Wed Oct 2 21:52:01 2002
@@ -20,9 +20,13 @@
lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \
util.o lxdialog.o msgbox.o

-all: ncurses lxdialog
+EXTRA_TARGETS := lxdialog
+
+first_rule: ncurses

include $(TOPDIR)/Rules.make
+
+.PHONY: ncurses

ncurses:
@echo "main() {}" > lxtemp.c

-----------------------------------------------------------------------------
[email protected], 2002-10-02 14:59:28-05:00, [email protected]
kbuild: Add some bug traps

Makefiles which still use obsolete 2.4 constructs now give a warning.

---------------------------------------------------------------------------

diff -Nru a/Rules.make b/Rules.make
--- a/Rules.make Wed Oct 2 21:52:03 2002
+++ b/Rules.make Wed Oct 2 21:52:03 2002
@@ -8,6 +8,23 @@
empty :=
space := $(empty) $(empty)

+# Some bug traps
+# ---------------------------------------------------------------------------
+
+ifdef O_TARGET
+$(warning kbuild: Usage of O_TARGET is obsolete in 2.5. Please fix!
+endif
+
+ifdef L_TARGET
+ifneq ($(L_TARGET),lib.a)
+$(warning kbuild: L_TARGET ($(L_TARGET)) should be renamed to lib.a. Please fix!)
+endif
+endif
+
+ifdef list-multi
+$(warning kbuild: list-multi ($(list-multi)) is obsolete in 2.5. Please fix!)
+endif
+
# Figure out paths
# ---------------------------------------------------------------------------
# Find the path relative to the toplevel dir, $(RELDIR), and express
@@ -84,16 +101,8 @@
__obj-m = $(filter-out export.o,$(obj-m))

# if $(foo-objs) exists, foo.o is a composite object
-__multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $($(m:.o=-objs)), $(m))))
-__multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $($(m:.o=-objs)), $(m))))
-
-# FIXME: Rip this out later
-# 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))
+multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $($(m:.o=-objs)), $(m))))
+multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $($(m:.o=-objs)), $(m))))

# Build list of the parts of our composite objects, our composite
# objects depend on those (obviously)

-----------------------------------------------------------------------------
[email protected], 2002-10-02 16:29:37-05:00, [email protected]
kbuild: Handle $(core-y) the same way as $(init-y), $(drivers-y) etc

$(CORE_FILES) did not quite follow the way the other vmlinux parts where
handled, due to potential init order dependencies. However, it seems
everybody is putting arch specific stuff in front, so we keep doing
this and nothing should break ;)

---------------------------------------------------------------------------

diff -Nru a/Makefile b/Makefile
--- a/Makefile Wed Oct 2 21:52:05 2002
+++ b/Makefile Wed Oct 2 21:52:05 2002
@@ -252,17 +252,15 @@
networks-y := net/
libs-y := lib/

-CORE_FILES := kernel/built-in.o mm/built-in.o fs/built-in.o \
- ipc/built-in.o security/built-in.o
-SUBDIRS += kernel mm fs ipc security
-
include arch/$(ARCH)/Makefile

+core-y += kernel/ mm/ fs/ ipc/ security/
+
SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m)))
INIT += $(patsubst %/, %/built-in.o, $(init-y))

SUBDIRS += $(patsubst %/,%,$(filter %/, $(core-y) $(core-m)))
-CORE_FILES := $(patsubst %/, %/built-in.o, $(core-y)) $(CORE_FILES)
+CORE_FILES += $(patsubst %/, %/built-in.o, $(core-y))

SUBDIRS += $(patsubst %/,%,$(filter %/, $(drivers-y) $(drivers-m)))
DRIVERS += $(patsubst %/, %/built-in.o, $(drivers-y))

-----------------------------------------------------------------------------
[email protected], 2002-10-02 16:57:45-05:00, [email protected]
kbuild: Use $(core-y) and friends directly

The capitalized aliases $(CORE_FILES) etc are basically superfluous now,
move the remaining users to $(core-y) and the like.

---------------------------------------------------------------------------

diff -Nru a/Makefile b/Makefile
--- a/Makefile Wed Oct 2 21:52:06 2002
+++ b/Makefile Wed Oct 2 21:52:06 2002
@@ -151,7 +151,7 @@
CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL

-export CPPFLAGS EXPORT_FLAGS NOSTDINC_FLAGS OBJCOPYFLAGS
+export CPPFLAGS EXPORT_FLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE

@@ -249,29 +249,25 @@

init-y := init/
drivers-y := drivers/ sound/
-networks-y := net/
+net-y := net/
libs-y := lib/
+core-y :=
+SUBDIRS :=

include arch/$(ARCH)/Makefile

core-y += kernel/ mm/ fs/ ipc/ security/

-SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m)))
-INIT += $(patsubst %/, %/built-in.o, $(init-y))
+SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
+ $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
+ $(net-y) $(net-m) $(libs-y) $(libs-m)))
+init-y := $(patsubst %/, %/built-in.o, $(init-y))
+core-y := $(patsubst %/, %/built-in.o, $(core-y))
+drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y))
+net-y := $(patsubst %/, %/built-in.o, $(net-y))
+libs-y := $(patsubst %/, %/lib.a, $(libs-y))

-SUBDIRS += $(patsubst %/,%,$(filter %/, $(core-y) $(core-m)))
-CORE_FILES += $(patsubst %/, %/built-in.o, $(core-y))
-
-SUBDIRS += $(patsubst %/,%,$(filter %/, $(drivers-y) $(drivers-m)))
-DRIVERS += $(patsubst %/, %/built-in.o, $(drivers-y))
-
-SUBDIRS += $(patsubst %/,%,$(filter %/, $(networks-y) $(networks-m)))
-NETWORKS += $(patsubst %/, %/built-in.o, $(networks-y))
-
-SUBDIRS += $(patsubst %/,%,$(filter %/, $(libs-y) $(libs-m)))
-LIBS += $(patsubst %/, %/lib.a, $(libs-y))
-
-export NETWORKS DRIVERS LIBS HEAD LDFLAGS MAKEBOOT
+$(warning $(SUBDIRS))

# Build vmlinux
# ---------------------------------------------------------------------------
@@ -283,16 +279,16 @@
# we cannot yet know if we will need to relink vmlinux.
# So we descend into init/ inside the rule for vmlinux again.

-vmlinux-objs := $(HEAD) $(INIT) $(CORE_FILES) $(LIBS) $(DRIVERS) $(NETWORKS)
+vmlinux-objs := $(HEAD) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y)

quiet_cmd_link_vmlinux = LD $@
define cmd_link_vmlinux
- $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(HEAD) $(INIT) \
+ $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(HEAD) $(init-y) \
--start-group \
- $(CORE_FILES) \
- $(LIBS) \
- $(DRIVERS) \
- $(NETWORKS) \
+ $(core-y) \
+ $(libs-y) \
+ $(drivers-y) \
+ $(net-y) \
--end-group \
$(filter $(kallsyms.o),$^) \
-o $@
diff -Nru a/arch/alpha/Makefile b/arch/alpha/Makefile
--- a/arch/alpha/Makefile Wed Oct 2 21:52:06 2002
+++ b/arch/alpha/Makefile Wed Oct 2 21:52:06 2002
@@ -95,6 +95,8 @@
core-$(CONFIG_MATHEMU) += arch/alpha/math-emu/
libs-y += arch/alpha/lib/

+export libs-y
+
MAKEBOOT = $(MAKE) -C arch/alpha/boot

rawboot:
diff -Nru a/arch/alpha/boot/Makefile b/arch/alpha/boot/Makefile
--- a/arch/alpha/boot/Makefile Wed Oct 2 21:52:06 2002
+++ b/arch/alpha/boot/Makefile Wed Oct 2 21:52:06 2002
@@ -20,7 +20,7 @@
TARGETS = vmlinux.gz tools/objstrip # also needed by aboot & milo
VMLINUX = $(TOPDIR)/vmlinux
OBJSTRIP = tools/objstrip
-LIBS := $(patsubst lib/%,$(TOPDIR)/lib/%,$(LIBS))
+LIBS := $(addprefix $(TOPDIR)/,$(libs-y))

all: $(TARGETS)
@echo Ready to install kernel in $(shell pwd)/vmlinux.gz
diff -Nru a/arch/sparc/Makefile b/arch/sparc/Makefile
--- a/arch/sparc/Makefile Wed Oct 2 21:52:06 2002
+++ b/arch/sparc/Makefile Wed Oct 2 21:52:06 2002
@@ -41,8 +41,7 @@
libs-y += arch/sparc/prom/ arch/sparc/lib/

# Export what is needed by arch/sparc/boot/Makefile
-export CORE_FILES
-export INIT
+export init-y core-y drivers-y net-y libs-y HEAD

image: vmlinux
$(MAKE) -C arch/sparc/boot image
diff -Nru a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile
--- a/arch/sparc/boot/Makefile Wed Oct 2 21:52:06 2002
+++ b/arch/sparc/boot/Makefile Wed Oct 2 21:52:06 2002
@@ -22,9 +22,8 @@
clean:
rm -f btfixupprep piggyback tftpboot.img btfix.o btfix.s image

-BTOBJS := $(HEAD) $(INIT)
-BTLIBS := $(CORE_FILES) $(LIBS) \
- $(DRIVERS) $(NETWORKS)
+BTOBJS := $(HEAD) $(init-y)
+BTLIBS := $(core-y) $(LIBS) $(drivers-y) $(net-y)

# Actual linking
image: btfix.o
diff -Nru a/drivers/isdn/i4l/isdn_ppp.h b/drivers/isdn/i4l/isdn_ppp.h
--- a/drivers/isdn/i4l/isdn_ppp.h Wed Oct 2 21:52:06 2002
+++ b/drivers/isdn/i4l/isdn_ppp.h Wed Oct 2 21:52:06 2002
@@ -27,7 +27,7 @@
#else

static inline int
-isdn_ppp_xmit(struct sk_buff *, struct net_device *);
+isdn_ppp_xmit(struct sk_buff *, struct net_device *)
{
return 0;
}

-----------------------------------------------------------------------------
[email protected], 2002-10-02 17:52:22-05:00, [email protected]
kbuild: Always build helpers in script/

As noticed by Sam Ravnborg, we need the targets in scripts (fixdep,
in particular) considered always, i.e. also when compiling modules.

---------------------------------------------------------------------------

diff -Nru a/scripts/Makefile b/scripts/Makefile
--- a/scripts/Makefile Wed Oct 2 21:52:08 2002
+++ b/scripts/Makefile Wed Oct 2 21:52:08 2002
@@ -11,6 +11,11 @@

EXTRA_TARGETS := fixdep split-include docproc conmakehash

+# Yikes. We need to build this stuff here even if the user only wants
+# modules.
+
+KBUILD_BUILTIN := 1
+
# The following temporary rule will make sure that people's
# trees get updated to the right permissions, since patch(1)
# can't do it

-----------------------------------------------------------------------------
[email protected], 2002-10-02 21:51:28-05:00, [email protected]
kbuild: Don't cd into subdirs during build

Instead of using make -C <subdir>, just use make -f <subdir>/Makefile.
This means we now call gcc/ld/... always from the topdir.

Advantages are:
o We don't need to use -I$(TOPDIR)/include and the like, just
-Iinclude works.
o __FILE__ gives the correct relative path from the topdir instead
of an absolute path, as it did before for included headers
o gcc errors/warnings give the correct relative path from the topdir
o takes us a step closer to a non-recursive build (though that's probably
as close as it gets)

The changes to Rules.make were done in a way which only uses the new way
for the standard recursive build (which remains recursive, just without
cd), all the archs do make -C arch/$(ARCH)/boot ..., which should keep
working as before. However, of course this should be converted eventually,
it's possible to do so piecemeal arch by arch.

It seems to work fine for most of the standard kernel. Potential places
which need changing are added -I flags to the command line, which now
need to have the path relative to the topdir and explicit rules for
generating files, which need to properly use $(obj) / $(src) to work
correctly.

---------------------------------------------------------------------------

diff -Nru a/Rules.make b/Rules.make
--- a/Rules.make Wed Oct 2 21:52:10 2002
+++ b/Rules.make Wed Oct 2 21:52:10 2002
@@ -25,22 +25,20 @@
$(warning kbuild: list-multi ($(list-multi)) is obsolete in 2.5. Please fix!)
endif

-# Figure out paths
+# Some paths for the Makefiles to use
# ---------------------------------------------------------------------------
-# Find the path relative to the toplevel dir, $(RELDIR), and express
-# the toplevel dir as a relative path from this dir, $(TOPDIR_REL)

-ifeq ($(findstring $(TOPDIR),$(CURDIR)),)
- # Can only happen when something is built out of tree
- RELDIR := $(CURDIR)
- TOPDIR_REL := $(TOPDIR)
-else
- RELDIR := $(subst $(TOPDIR)/,,$(CURDIR))
- TOPDIR_REL := $(subst $(space),,$(foreach d,$(subst /, ,$(RELDIR)),../))
+# FIXME. For now, we leave it possible to use make -C or make -f
+# to do work in subdirs.
+
+ifndef obj
+obj = .
+CFLAGS := $(patsubst -I%,-I$(TOPDIR)/%,$(patsubst -I$(TOPDIR)/%,-I%,$(CFLAGS)))
+AFLAGS := $(patsubst -I%,-I$(TOPDIR)/%,$(patsubst -I$(TOPDIR)/%,-I%,$(AFLAGS)))
endif

-# Some paths for the Makefiles to use
-# ---------------------------------------------------------------------------
+# For use in the quiet output
+echo_target = $@

# Usage:
#
@@ -58,12 +56,7 @@
# We don't support separate source / object yet, so these are just
# placeholders for now

-obj := .
-src := .
-
-# For use in the quiet output
-
-echo_target = $(RELDIR)/$@
+src := $(obj)

# Figure out what we need to build from the various variables
# ===========================================================================
@@ -120,6 +113,21 @@
# Only build module versions for files which are selected to be built
export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m))

+# Add subdir path
+
+EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS))
+obj-y := $(addprefix $(obj)/,$(obj-y))
+obj-m := $(addprefix $(obj)/,$(obj-m))
+export-objs := $(addprefix $(obj)/,$(export-objs))
+subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
+real-objs-y := $(addprefix $(obj)/,$(real-objs-y))
+real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
+multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
+multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
+multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
+multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
+subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
+
# The temporary file to save gcc -MD generated dependencies must not
# contain a comma
depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
@@ -153,7 +161,7 @@
# This sets version suffixes on exported symbols
# ---------------------------------------------------------------------------

-MODVERDIR := $(TOPDIR)/include/linux/modules/$(RELDIR)
+MODVERDIR := include/linux/modules/$(obj)

#
# Added the SMP separator to stop module accidents between uniprocessor
@@ -183,7 +191,7 @@
# files (fix-dep filters them), so touch modversions.h if any of the .ver
# files changes

-quiet_cmd_cc_ver_c = MKVER include/linux/modules/$(RELDIR)/$*.ver
+quiet_cmd_cc_ver_c = MKVER include/linux/modules/$(obj)/$*.ver
cmd_cc_ver_c = $(CPP) $(c_flags) $< | $(GENKSYMS) $(genksyms_smp_prefix) \
-k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > [email protected]

@@ -216,8 +224,8 @@
targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))

fastdep: $(targets) $(subdir-ym)
- @mkdir -p $(dir $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR),$(export-objs:.o=.ver)))
- @touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver))
+ @mkdir -p $(dir $(addprefix .tmp_export-objs/modules/,$(export-objs:.o=.ver)))
+ @touch $(addprefix .tmp_export-objs/modules/,$(export-objs:.o=.ver))

endif # export-objs

@@ -228,13 +236,15 @@
# Installing modules
# ==========================================================================

+quiet_cmd_modules_install = INSTALL $(obj-m)
+cmd_modules_install = mkdir -p $(MODLIB)/kernel/$(obj); \
+ cp $(obj-m) $(MODLIB)/kernel/$(obj)
+
.PHONY: modules_install

modules_install: $(subdir-ym)
ifneq ($(obj-m),)
- @echo Installing modules in $(MODLIB)/kernel/$(RELDIR)
- @mkdir -p $(MODLIB)/kernel/$(RELDIR)
- @cp $(obj-m) $(MODLIB)/kernel/$(RELDIR)
+ $(call cmd,modules_install)
else
@/bin/true
endif
@@ -250,8 +260,12 @@

ifndef O_TARGET
ifndef L_TARGET
-O_TARGET := built-in.o
+O_TARGET := $(obj)/built-in.o
+endif
endif
+
+ifdef L_TARGET
+L_TARGET := $(obj)/$(L_TARGET)
endif

first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
@@ -368,7 +382,7 @@
#

quiet_cmd_link_multi = LD $(echo_target)
-cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs),$^)
+cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs)))),$^)

# We would rather have a list of rules like
# foo.o: $(foo-objs)
@@ -388,6 +402,9 @@
host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m)))
host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m)))
host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs))
+host-progs-single := $(addprefix $(obj)/,$(host-progs-single))
+host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi))
+host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs))

quiet_cmd_host_cc__c = HOSTCC $(echo_target)
cmd_host_cc__c = $(HOSTCC) -Wp,-MD,$(depfile) \
@@ -405,7 +422,7 @@
$(call if_changed_dep,host_cc_o_c)

quiet_cmd_host_cc__o = HOSTLD $(echo_target)
-cmd_host_cc__o = $(HOSTCC) $(HOSTLDFLAGS) -o $@ $($@-objs) \
+cmd_host_cc__o = $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(subst $(obj)/,,$@)-objs)) \
$(HOST_LOADLIBES)

$(host-progs-multi): %: $(host-progs-multi-objs) FORCE
@@ -583,5 +600,7 @@
# $(call descend,<dir>,<target>)
# Recursively call a sub-make in <dir> with target <target>

-descend = $(MAKE) -C $(1) $(2)
-
+ifeq ($(KBUILD_VERBOSE),1)
+descend = echo '$(MAKE) -f $(1)/Makefile $(2)';
+endif
+descend += $(MAKE) -f $(1)/Makefile obj=$(1) $(2)
diff -Nru a/arch/i386/Makefile b/arch/i386/Makefile
--- a/arch/i386/Makefile Wed Oct 2 21:52:10 2002
+++ b/arch/i386/Makefile Wed Oct 2 21:52:10 2002
@@ -98,8 +98,8 @@
drivers-$(CONFIG_MATH_EMULATION) += arch/i386/math-emu/
drivers-$(CONFIG_PCI) += arch/i386/pci/

-CFLAGS += -I$(TOPDIR)/arch/i386/$(MACHINE)
-AFLAGS += -I$(TOPDIR)/arch/i386/$(MACHINE)
+CFLAGS += -Iarch/i386/$(MACHINE)
+AFLAGS += -Iarch/i386/$(MACHINE)

MAKEBOOT = +$(MAKE) -C arch/$(ARCH)/boot

diff -Nru a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
--- a/arch/i386/boot/Makefile Wed Oct 2 21:52:10 2002
+++ b/arch/i386/boot/Makefile Wed Oct 2 21:52:10 2002
@@ -44,7 +44,7 @@
bzImage: EXTRA_AFLAGS := -traditional $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
bzImage: BUILDFLAGS := -b

-quiet_cmd_image = BUILD $(RELDIR)/$@
+quiet_cmd_image = BUILD $(echo_target)
cmd_image = tools/build $(BUILDFLAGS) bootsect setup vmlinux.bin \
$(ROOT_DEV) > $@

diff -Nru a/drivers/acpi/Makefile b/drivers/acpi/Makefile
--- a/drivers/acpi/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/acpi/Makefile Wed Oct 2 21:52:10 2002
@@ -4,7 +4,7 @@

export ACPI_CFLAGS

-ACPI_CFLAGS := -D_LINUX -I$(CURDIR)/include
+ACPI_CFLAGS := -D_LINUX -Idrivers/acpi/include

ifdef CONFIG_ACPI_DEBUG
ACPI_CFLAGS += -DACPI_DEBUG_OUTPUT
diff -Nru a/drivers/ide/arm/Makefile b/drivers/ide/arm/Makefile
--- a/drivers/ide/arm/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/ide/arm/Makefile Wed Oct 2 21:52:10 2002
@@ -2,6 +2,6 @@
obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o
obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o

-EXTRA_CFLAGS := -I../
+EXTRA_CFLAGS := -Idrivers/ide

include $(TOPDIR)/Rules.make
diff -Nru a/drivers/ide/legacy/Makefile b/drivers/ide/legacy/Makefile
--- a/drivers/ide/legacy/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/ide/legacy/Makefile Wed Oct 2 21:52:10 2002
@@ -17,6 +17,6 @@
# Last of all
obj-$(CONFIG_BLK_DEV_HD) += hd.o

-EXTRA_CFLAGS := -I../
+EXTRA_CFLAGS := -Idrivers/ide

include $(TOPDIR)/Rules.make
diff -Nru a/drivers/ide/pci/Makefile b/drivers/ide/pci/Makefile
--- a/drivers/ide/pci/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/ide/pci/Makefile Wed Oct 2 21:52:10 2002
@@ -31,6 +31,6 @@
# Must appear at the end of the block
obj-$(CONFIG_BLK_DEV_GENERIC) += generic.o

-EXTRA_CFLAGS := -I../
+EXTRA_CFLAGS := -Idrivers/ide

include $(TOPDIR)/Rules.make
diff -Nru a/drivers/ide/ppc/Makefile b/drivers/ide/ppc/Makefile
--- a/drivers/ide/ppc/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/ide/ppc/Makefile Wed Oct 2 21:52:10 2002
@@ -3,6 +3,6 @@
obj-$(CONFIG_BLK_DEV_IDE_PMAC) += pmac.o
obj-$(CONFIG_BLK_DEV_IDE_SWARM) += swarm.o

-EXTRA_CFLAGS := -I../
+EXTRA_CFLAGS := -Idrivers/ide

include $(TOPDIR)/Rules.make
diff -Nru a/drivers/message/fusion/Makefile b/drivers/message/fusion/Makefile
--- a/drivers/message/fusion/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/message/fusion/Makefile Wed Oct 2 21:52:10 2002
@@ -13,7 +13,7 @@
# # sparc64
#EXTRA_CFLAGS += -gstabs+

-EXTRA_CFLAGS += -I. ${MPT_CFLAGS}
+EXTRA_CFLAGS += ${MPT_CFLAGS}

# Fusion MPT drivers; recognized debug defines...
# MPT general:
diff -Nru a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
--- a/drivers/net/sk98lin/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/net/sk98lin/Makefile Wed Oct 2 21:52:10 2002
@@ -55,7 +55,7 @@
# SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources
# SK_DBGCAT_DRV_EVENT 0x08000000 driver events

-EXTRA_CFLAGS += -I. -DSK_USE_CSUM $(DBGDEF)
+EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_USE_CSUM $(DBGDEF)

include $(TOPDIR)/Rules.make

diff -Nru a/drivers/net/skfp/Makefile b/drivers/net/skfp/Makefile
--- a/drivers/net/skfp/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/net/skfp/Makefile Wed Oct 2 21:52:10 2002
@@ -17,7 +17,7 @@
# projects. To keep the source common for all those drivers (and
# thus simplify fixes to it), please do not clean it up!

-EXTRA_CFLAGS += -I. -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes
+EXTRA_CFLAGS += -Idrivers/net/skfp -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes

include $(TOPDIR)/Rules.make

diff -Nru a/drivers/scsi/sym53c8xx_2/Makefile b/drivers/scsi/sym53c8xx_2/Makefile
--- a/drivers/scsi/sym53c8xx_2/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/scsi/sym53c8xx_2/Makefile Wed Oct 2 21:52:10 2002
@@ -3,7 +3,5 @@
sym53c8xx-objs := sym_fw.o sym_glue.o sym_hipd.o sym_malloc.o sym_misc.o sym_nvram.o
obj-$(CONFIG_SCSI_SYM53C8XX_2) := sym53c8xx.o

-EXTRA_CFLAGS += -I.
-
include $(TOPDIR)/Rules.make

diff -Nru a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
--- a/drivers/usb/storage/Makefile Wed Oct 2 21:52:10 2002
+++ b/drivers/usb/storage/Makefile Wed Oct 2 21:52:10 2002
@@ -5,7 +5,7 @@
# Rewritten to use lists instead of if-statements.
#

-EXTRA_CFLAGS := -I../../scsi/
+EXTRA_CFLAGS := -Idrivers/scsi

obj-$(CONFIG_USB_STORAGE) += usb-storage.o

diff -Nru a/fs/xfs/Makefile b/fs/xfs/Makefile
--- a/fs/xfs/Makefile Wed Oct 2 21:52:10 2002
+++ b/fs/xfs/Makefile Wed Oct 2 21:52:10 2002
@@ -32,10 +32,10 @@
# Makefile for XFS on Linux.
#

-# This needs -I. because everything does #include <xfs.h> instead of "xfs.h".
+# This needs -I because everything does #include <xfs.h> instead of "xfs.h".
# The code is wrong, local files should be included using "xfs.h", not <xfs.h>
# but I am not going to change every file at the moment.
-EXTRA_CFLAGS += -I. -funsigned-char
+EXTRA_CFLAGS += -Ifs/xfs -funsigned-char

ifeq ($(CONFIG_XFS_DEBUG),y)
EXTRA_CFLAGS += -g -DSTATIC="" -DDEBUG -DXFSDEBUG
@@ -154,6 +154,6 @@
endif
endif

-CFLAGS_xfsidbg.o += -I $(TOPDIR)/arch/$(ARCH)/kdb
+CFLAGS_xfsidbg.o += -Iarch/$(ARCH)/kdb

include $(TOPDIR)/Rules.make



2002-10-03 03:29:19

by Andreas Dilger

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Oct 02, 2002 21:59 -0500, Kai Germaschewski wrote:
> The build process remains recursive, but it changes the recursion
> from
> make -C subdir
> to
> make -f subdir/Makefile
>
> i.e. the current working directory remains the top dir for all times. So
> gcc/ld/.. are now called from the topdir, allowing to closer resemble
> a non-recursive build. Some Makefiles may need a little additional
> tweaking (in particular arch/*), but generally, the changes required are
> pretty small.

This is nice, because if you are doing "make -j[n]" you currently get
dumped into the wrong file (or just some non-existent file in the wrong
directory) on build warnings and errors (when compiling under vim/emacs)
because e.g. the "make[1]: entering directory fs/ext3" message was
followed by "make[1]: entering directory fs/msdos", while still
compiling files in fs/ext3.

Granted, this isn't a great reason to change, but it bugs me every
day.

Cheers, Andreas
--
Andreas Dilger
http://www-mddsp.enel.ucalgary.ca/People/adilger/
http://sourceforge.net/projects/ext2resize/

2002-10-03 05:14:13

by Peter Samuelson

[permalink] [raw]
Subject: Re: [kbuild-devel] RfC: Don't cd into subdirs during kbuild


Random thoughts. I haven't actually tested the patch yet, so feel
free to ignore me. (:


[Kai Germaschewski]
> i.e. the current working directory remains the top dir for all
> times.

Which top dir, src or obj? Most end users will expect obj topdir.
More on that below.

> So gcc/ld/.. are now called from the topdir, allowing to
> closer resemble a non-recursive build.

I still think it's more intuitive to have $(obj) == '.', but you do
make some good arguments in the cset comment.

> - @$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep
> + @$(call descend,$(patsubst _sfdep_%,%,$@),fastdep)
>
> else # !CONFIG_MODVERSIONS
>
> @@ -533,7 +526,7 @@
>
> .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS))
> $(patsubst %, _modinst_%, $(SUBDIRS)) :
> - @$(MAKE) -C $(patsubst _modinst_%, %, $@) modules_install
> + $(descend,$(patsubst _modinst_%,%,$@),modules_install)

$(call descend,
for consistency.

> -fastdep: sub_dirs
> - @echo -n
> +fastdep: $(subdir-ym)
> + @/bin/true

@:
Seriously. You can assume ':' is built in to your /bin/sh. If not,
you've got bigger problems, like perhaps a /bin/sh -> csh link.

> -# we also have source in the subdirectories..
> -vpath %.c = . linux pagebuf support

Good riddance! This is worse than $(MAKEFILES) abuse. (:

> # Objects in pagebuf/
> -xfs-objs += page_buf.o \
> - page_buf_locking.o
> +xfs-objs += $(addprefix pagebuf/, \
> + page_buf.o \
> + page_buf_locking.o)
> # Objects in linux/
> # Objects in support/

Go ahead and delete those comments as well.

> ACPI was a bit lazy and just said compile all .c files in this directory,

Yeah, I always felt this was "too clever for its own good". Same
category as fs/smbfs/proto.h...

> $(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist
> - $(obj)/gen-devlist < $<
> + ( cd $(obj); ./gen-devlist ) < $<

cd $(obj); ./gen-devlist < $<

No need for parentheses - $(src) is an absolute path.

Really gen-devlist should output to stdout instead of a fixed file.

> $(obj)/devlist.h: $(src)/zorro.ids $(obj)/gen-devlist
> - $(obj)/gen-devlist < $<
> + ( cd $(obj); ./gen-devlist ) < $<

ditto

> lxdialog:
> - $(MAKE) -C lxdialog all
> + $(call descend,lxdialog,)

$(call descend,scripts/lxdialog,)
I didn't actually test this but isn't $(descend) relative to
$(TOPDIR)? At least in your later changeset.

> diff -Nru a/drivers/isdn/i4l/isdn_ppp.h b/drivers/isdn/i4l/isdn_ppp.h
> --- a/drivers/isdn/i4l/isdn_ppp.h Wed Oct 2 21:52:06 2002
> +++ b/drivers/isdn/i4l/isdn_ppp.h Wed Oct 2 21:52:06 2002
> @@ -27,7 +27,7 @@
> #else
>
> static inline int
> -isdn_ppp_xmit(struct sk_buff *, struct net_device *);
> +isdn_ppp_xmit(struct sk_buff *, struct net_device *)

Obviously correct, but was that supposed to be part of your changeset?
I suppose it relates to "kbuild" in that "I can't compile my
kernel". (:

> +# Add subdir path
> +
> +EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS))
> +obj-y := $(addprefix $(obj)/,$(obj-y))
> +obj-m := $(addprefix $(obj)/,$(obj-m))
> +export-objs := $(addprefix $(obj)/,$(export-objs))
> +subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
> +real-objs-y := $(addprefix $(obj)/,$(real-objs-y))
> +real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
> +multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
> +multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
> +multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
> +multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
> +subdir-ym := $(addprefix $(obj)/,$(subdir-ym))

add_obj_prefix = $1 := $(addprefix $(obj)/,$($1))
$(call add_obj_prefix EXTRA_TARGETS)

or something like that?

> ifndef O_TARGET
> ifndef L_TARGET
> -O_TARGET := built-in.o
> +O_TARGET := $(obj)/built-in.o
> +endif
> endif
> +
> +ifdef L_TARGET
> +L_TARGET := $(obj)/$(L_TARGET)
> endif

Hey, why not make life exciting. Don't ifndef the O_TARGET. Just
break the existing O_TARGET users.

> +host-progs-single := $(addprefix $(obj)/,$(host-progs-single))
> +host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi))
> +host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs))

$(call add_obj_prefix host-progs-single)

> +ifeq ($(KBUILD_VERBOSE),1)
> +descend = echo '$(MAKE) -f $(1)/Makefile $(2)';
> +endif
> +descend += $(MAKE) -f $(1)/Makefile obj=$(1) $(2)

Heh, clever.

> -ACPI_CFLAGS := -D_LINUX -I$(CURDIR)/include
> +ACPI_CFLAGS := -D_LINUX -Idrivers/acpi/include

ACPI_CFLAGS := -D_LINUX -I$(src)/include

or do you require '.' to be source TOPDIR? If so, this is the
opposite of what most projects do. Normally the user expects to build
from the top of $(obj). Why not do the same here, even if it's a bit
more work?

> +++ b/drivers/ide/arm/Makefile Wed Oct 2 21:52:10 2002
> @@ -2,6 +2,6 @@
> obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o
> obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o
>
> -EXTRA_CFLAGS := -I../
> +EXTRA_CFLAGS := -Idrivers/ide

again (and 3 more cases below)..

> +++ b/drivers/message/fusion/Makefile Wed Oct 2 21:52:10 2002
> @@ -13,7 +13,7 @@
> # # sparc64
> #EXTRA_CFLAGS += -gstabs+
>
> -EXTRA_CFLAGS += -I. ${MPT_CFLAGS}
> +EXTRA_CFLAGS += ${MPT_CFLAGS}

So can we assume -I$(src) is always part of the cflags?

> +++ b/drivers/net/sk98lin/Makefile Wed Oct 2 21:52:10 2002
> @@ -55,7 +55,7 @@
> # SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources
> # SK_DBGCAT_DRV_EVENT 0x08000000 driver events
>
> -EXTRA_CFLAGS += -I. -DSK_USE_CSUM $(DBGDEF)
> +EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_USE_CSUM $(DBGDEF)

...because if so, this isn't needed.

> +++ b/drivers/net/skfp/Makefile Wed Oct 2 21:52:10 2002
> @@ -17,7 +17,7 @@
> # projects. To keep the source common for all those drivers (and
> # thus simplify fixes to it), please do not clean it up!
>
> -EXTRA_CFLAGS += -I. -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes
> +EXTRA_CFLAGS += -Idrivers/net/skfp -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes

...or this.

> +++ b/drivers/usb/storage/Makefile Wed Oct 2 21:52:10 2002
> @@ -5,7 +5,7 @@
> # Rewritten to use lists instead of if-statements.
> #
>
> -EXTRA_CFLAGS := -I../../scsi/
> +EXTRA_CFLAGS := -Idrivers/scsi

once again is '.' always directly below $(src) or below $(obj)?

> -# This needs -I. because everything does #include <xfs.h> instead of "xfs.h".
> +# This needs -I because everything does #include <xfs.h> instead of "xfs.h".

This implies that -I$(src) is *not* implicit - right?

I hope this is intended to be temporary - xfs should just be changed
to #include "" like everybody else.

Peter

2002-10-03 08:15:25

by Xavier Bestel

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

Le jeu 03/10/2002 ? 04:59, Kai Germaschewski a ?crit :
>
> Hi,
>
> I'd appreciate to get comments on the appended patch. It's mostly cleanups
> and the like, but the interesting part is the last cset, which is actually
> fairly small:
>
> 14 files changed, 64 insertions(+), 47 deletions(-)
>
> The build process remains recursive, but it changes the recursion
> from
>
> make -C subdir
>
> to
>
> make -f subdir/Makefile

Could you do instead:

include subdir/Makefile
?

This would avoid recursive make, which isn't really a good idea (even if
it's used widely). Here is a good agument about that:
http://www.cse.iitb.ac.in/~soumen/teach/cs699a1999/make.html


2002-10-03 14:00:30

by John Levon

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Wed, Oct 02, 2002 at 09:59:00PM -0500, Kai Germaschewski wrote:

> [email protected], 2002-10-02 14:42:00-05:00, [email protected]
> kbuild: Remove xfs vpath hack

Why is it a hack ?

> xfs.o is built as one modules out of objects distributed into
> multiple subdirs. That is okay with the current kbuild, you just
> have to include the path for objects which reside in a subdir, then.
>
> xfs used vpath instead of explicitly adding the paths, which is
> inconsistent and conflicts e.g. with proper module version generation.

So I must name the full path for each object in drivers/oprofile/ I
include from arch/i386/oprofile/ then ?

regards
john

2002-10-03 14:22:26

by Kai Germaschewski

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Thu, 3 Oct 2002, John Levon wrote:

> On Wed, Oct 02, 2002 at 09:59:00PM -0500, Kai Germaschewski wrote:
>
> > [email protected], 2002-10-02 14:42:00-05:00, [email protected]
> > kbuild: Remove xfs vpath hack
>
> Why is it a hack ?

Since it gives Rules.make the wrong file names in $(obj-[ym]), and relies
on implementation details inside of Rules.make in combination with the
vpath statement to make things work despite those wrong names.

> > xfs.o is built as one modules out of objects distributed into
> > multiple subdirs. That is okay with the current kbuild, you just
> > have to include the path for objects which reside in a subdir, then.
> >
> > xfs used vpath instead of explicitly adding the paths, which is
> > inconsistent and conflicts e.g. with proper module version generation.
>
> So I must name the full path for each object in drivers/oprofile/ I
> include from arch/i386/oprofile/ then ?

So did you decide to move things from drivers/oprofile/$(ARCH) to
arch/$(ARCH)/oprofile? It's possible to make it work, but not pretty. As I
said before, kbuild actually expects to have all parts of a single module
to be in a single dir. This can be lifted a little bit as done for xfs,
but spreading parts all over the tree is not very desirable IMO.

--Kai


2002-10-03 14:40:29

by John Levon

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Thu, Oct 03, 2002 at 09:27:49AM -0500, Kai Germaschewski wrote:

> Since it gives Rules.make the wrong file names in $(obj-[ym]), and relies
> on implementation details inside of Rules.make in combination with the
> vpath statement to make things work despite those wrong names.

This sounds like kbuild's problem not mine. That is, I don't see
anything particularly ugly in using vpath.

> So did you decide to move things from drivers/oprofile/$(ARCH) to
> arch/$(ARCH)/oprofile? It's possible to make it work, but not pretty. As I
> said before, kbuild actually expects to have all parts of a single module
> to be in a single dir. This can be lifted a little bit as done for xfs,
> but spreading parts all over the tree is not very desirable IMO.

Can the kernel people decide amongst themselves what they want, then
I'll just do it ?

Personally, the arch/ drivers/ split seems perfectly natural for
oprofile.

regards
john
--
"Me and my friends are so smart, we invented this new kind of art:
Post-modernist throwing darts"
- the Moldy Peaches

2002-10-03 14:49:41

by Kai Germaschewski

[permalink] [raw]
Subject: Re: [kbuild-devel] RfC: Don't cd into subdirs during kbuild

On Thu, 3 Oct 2002, Peter Samuelson wrote:

> Which top dir, src or obj? Most end users will expect obj topdir.
> More on that below.

Yes, I think obj topdir is the way to go - and you're right, it can be
made work mostly with vpath and does not need much more.

> > So gcc/ld/.. are now called from the topdir, allowing to
> > closer resemble a non-recursive build.
>
> I still think it's more intuitive to have $(obj) == '.', but you do
> make some good arguments in the cset comment.

The most important argument is that a none-recursive make of course cannot
change dirs, so there it is definitely needed to have the right paths
relative to the top dir. However, that's not really relevant, since we're
not doing a none-recursive make (though it's a step into that direction).

> > - @$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep
> > + @$(call descend,$(patsubst _sfdep_%,%,$@),fastdep)
> >
> > else # !CONFIG_MODVERSIONS
> >
> > @@ -533,7 +526,7 @@
> >
> > .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS))
> > $(patsubst %, _modinst_%, $(SUBDIRS)) :
> > - @$(MAKE) -C $(patsubst _modinst_%, %, $@) modules_install
> > + $(descend,$(patsubst _modinst_%,%,$@),modules_install)
>
> $(call descend,
> for consistency.

Duh, I found that during testing. - Looks like I forgot checking in my
last cset.

>
> > -fastdep: sub_dirs
> > - @echo -n
> > +fastdep: $(subdir-ym)
> > + @/bin/true
>
> @:
> Seriously. You can assume ':' is built in to your /bin/sh. If not,
> you've got bigger problems, like perhaps a /bin/sh -> csh link.

Alright, if you're sure about this, send me a patch (later).

> Yeah, I always felt this was "too clever for its own good". Same
> category as fs/smbfs/proto.h...
>
> > $(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist
> > - $(obj)/gen-devlist < $<
> > + ( cd $(obj); ./gen-devlist ) < $<
>
> cd $(obj); ./gen-devlist < $<
>
> No need for parentheses - $(src) is an absolute path.

No, $(src) is a relative path - I really don't want to use an absolute
path anywhere anymore.

> Really gen-devlist should output to stdout instead of a fixed file.

That's what I was thinking, but actually it generates two files at a time,
so that wouldn't quite work.

> > lxdialog:
> > - $(MAKE) -C lxdialog all
> > + $(call descend,lxdialog,)
>
> $(call descend,scripts/lxdialog,)
> I didn't actually test this but isn't $(descend) relative to
> $(TOPDIR)? At least in your later changeset.

You're right. Fixed.

> > diff -Nru a/drivers/isdn/i4l/isdn_ppp.h b/drivers/isdn/i4l/isdn_ppp.h
> > --- a/drivers/isdn/i4l/isdn_ppp.h Wed Oct 2 21:52:06 2002
> > +++ b/drivers/isdn/i4l/isdn_ppp.h Wed Oct 2 21:52:06 2002
> > @@ -27,7 +27,7 @@
> > #else
> >
> > static inline int
> > -isdn_ppp_xmit(struct sk_buff *, struct net_device *);
> > +isdn_ppp_xmit(struct sk_buff *, struct net_device *)
>
> Obviously correct, but was that supposed to be part of your changeset?
> I suppose it relates to "kbuild" in that "I can't compile my
> kernel". (:

Grrh. That happens to me all the time...

> > +# Add subdir path
> > +
> > +EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS))
> > +obj-y := $(addprefix $(obj)/,$(obj-y))
> > +obj-m := $(addprefix $(obj)/,$(obj-m))
> > +export-objs := $(addprefix $(obj)/,$(export-objs))
> > +subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
> > +real-objs-y := $(addprefix $(obj)/,$(real-objs-y))
> > +real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
> > +multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
> > +multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
> > +multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
> > +multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
> > +subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
>
> add_obj_prefix = $1 := $(addprefix $(obj)/,$($1))
> $(call add_obj_prefix EXTRA_TARGETS)

I don't think that works - make is not always pretty, that's life.

> Hey, why not make life exciting. Don't ifndef the O_TARGET. Just
> break the existing O_TARGET users.

I added a $(warning ) for this case somewhere above. I'll break it
eventually ;)

> ACPI_CFLAGS := -D_LINUX -I$(src)/include
>
> or do you require '.' to be source TOPDIR? If so, this is the
> opposite of what most projects do. Normally the user expects to build
> from the top of $(obj). Why not do the same here, even if it's a bit
> more work?

I'm planning on doing the same. I think for $(src) != $(obj), I'll do
a $(patsubst -I%,-I% -I$(src)/%) on the [AC]FLAGS. (BTW, in this case, of
course $(src) would probably be an absolute path). We also have generated
files which need to be included, so we basically need both $(src) and
$(obj) in the include path.

> > -EXTRA_CFLAGS += -I. ${MPT_CFLAGS}
> > +EXTRA_CFLAGS += ${MPT_CFLAGS}
>
> So can we assume -I$(src) is always part of the cflags?

I think (need to check), gcc automatically seaches the path of the source
for includes. If not we'll have to add it.

Anyway, the case above worked fine without the -I.

> > +++ b/drivers/net/sk98lin/Makefile Wed Oct 2 21:52:10 2002
> > @@ -55,7 +55,7 @@
> > # SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources
> > # SK_DBGCAT_DRV_EVENT 0x08000000 driver events
> >
> > -EXTRA_CFLAGS += -I. -DSK_USE_CSUM $(DBGDEF)
> > +EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_USE_CSUM $(DBGDEF)
>
> ...because if so, this isn't needed.

In this case someones including "h/header.h", and this did not work
without the -I.

Well, you see, some issues still need tackling for $(src) != $(obj), but
that's not what I was aiming for with this patch, anyway.

--Kai

2002-10-03 14:51:32

by Kai Germaschewski

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On 3 Oct 2002, Xavier Bestel wrote:

> Could you do instead:
>
> include subdir/Makefile
> ?

It's not quite that easy, unfortunately ;(

> This would avoid recursive make, which isn't really a good idea (even if
> it's used widely). Here is a good agument about that:
> http://www.cse.iitb.ac.in/~soumen/teach/cs699a1999/make.html

I think I heard that before, but I would argue that recursive builds if
done right are just fine from the correctness point of view.

--Kai


2002-10-03 15:26:54

by Xavier Bestel

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

Le jeu 03/10/2002 ? 16:56, Kai Germaschewski a ?crit :

> > This would avoid recursive make, which isn't really a good idea (even if
> > it's used widely). Here is a good agument about that:
> > http://www.cse.iitb.ac.in/~soumen/teach/cs699a1999/make.html
>
> I think I heard that before, but I would argue that recursive builds if
> done right are just fine from the correctness point of view.

Then I would argue that recursive builds are a tradeoff between
speed/maintainability and correctness. Perhaps you should re-read this
paper then. Your patches go in the right direction, though.

2002-10-03 19:22:06

by Sam Ravnborg

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Wed, Oct 02, 2002 at 09:59:00PM -0500, Kai Germaschewski wrote:
>
> Hi,
>
> I'd appreciate to get comments on the appended patch. It's mostly cleanups
> and the like, but the interesting part is the last cset, which is actually
> fairly small:

Tried out what I pulled from linux-2.5.make

1) warning present in Makefile
2) Annoying /././ when doing make dep
3) Did a ld built-in.o in scripts, despite obj-y is empty
- When i changed "=" to ":=" to fix next error ar failed.

ifdef O_TARGET replaced with ifdef obj-y to make it work

4) Could not link, no *.o file were used as parameters to ld

cmd_link_o_target := $(if $(strip $(obj-y)),\
$(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^),\
rm -f $@; $(AR) rcs $@)

$(O_TARGET): $(obj-y) FORCE
@echo XXXXX $^
@echo $(obj-y) - $@


Result:
make[1]: Entering directory `/home/sam/src/linux/kernel/bk/kai-make/init'
Generating /home/sam/src/linux/kernel/bk/kai-make/include/linux/compile.h (unchanged)
XXXXX main.o version.o do_mounts.o FORCE
./main.o ./version.o ./do_mounts.o - built-in.o
ld -m elf_i386 -r -o
ld: unrecognized option '-o'
ld: use the --help option for usage information

It seems that make strips "./" in front of all .o files listed in obj-y
Utilising $(filter-out FORCE,$(obj-y) did the trick for me.

[sam@mars kai-make]$ make -v
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.


Hmmm, was the stuff present at bkbits incomplete?

Sam

2002-10-03 19:28:18

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [kbuild-devel] Re: RfC: Don't cd into subdirs during kbuild

On Thu, Oct 03, 2002 at 09:26:18PM +0200, Sam Ravnborg wrote:
>
> Hmmm, was the stuff present at bkbits incomplete?

Just checked, yes the attached patch was never. And fixes I think all the
above.

A new round of testing needed....

Sam

2002-10-03 19:56:39

by Sam Ravnborg

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Wed, Oct 02, 2002 at 09:59:00PM -0500, Kai Germaschewski wrote:
>
> Hi,
>
> I'd appreciate to get comments on the appended patch.

> -obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
> +obj-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
> + dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o

Should that have been:
obj-$(CONFIG_ACPI_INTERPRETER) := dsfield.o dsmthdat.o dsopcode.o...

Looks wrong to me that you remove the CONFIG_ dependency.
Same is true for the rest of this cset.

> +ifdef list-multi
> +$(warning kbuild: list-multi ($(list-multi)) is obsolete in 2.5. Please fix!)
> +endif
Since kbuild no longer support list-multi this should be $(error ....)

> -multi-used-y := $(filter-out $(list-multi),$(__multi-used-y))
Here is list-multi removed.


> SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m)))
I prefer first assignment to be := not +=
This is true for several places including several makefiles as well.


> -export CPPFLAGS EXPORT_FLAGS NOSTDINC_FLAGS OBJCOPYFLAGS
> +export CPPFLAGS EXPORT_FLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
Did not see this change justified.

> -export NETWORKS DRIVERS LIBS HEAD LDFLAGS MAKEBOOT
> +$(warning $(SUBDIRS))

Warning shall be deleted

> ifndef O_TARGET
> ifndef L_TARGET
> -O_TARGET := built-in.o
> +O_TARGET := $(obj)/built-in.o
> +endif
> endif
This change result in ld being called for directories like:
$(TOPDIR)/scripts
$(TOPDIR)/scripts/lxdialog
$(TOPDIR)/Documentation/DocBook
If obj-y is empty then do not define O_TARGET?

Another more general comment.
There seem to no consistency in the variables used in the first section of
the makefile. There is a mixture of lower and upper case variables:
O_TARGET, host-progs etc. This is confusing.
Furthermore the construct:
obj-y := some.o dot.o .o module.o
Seems illogical to me. What does obj-y mean to me??
mandatory-objs := some.o dot.o .o module.o
It a litte longer, but occur only once (typical) per makefile.
Thats not something I propose for now, more to be seen as a general comment
about striving for consistency in the interface to rules.make.

>
> first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
Where comes the requirement that EXTRA_TARGETS needs to be buildin?

> -cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs),$^)
> +cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs)))),$^)
Keep a variable without obj appended would make this readable I think.

Now it's testing time..

Sam

2002-10-03 20:14:36

by Kai Germaschewski

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Thu, 3 Oct 2002, Sam Ravnborg wrote:

> > -obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
> > +obj-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
> > + dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o
>
> Should that have been:
> obj-$(CONFIG_ACPI_INTERPRETER) := dsfield.o dsmthdat.o dsopcode.o...
>
> Looks wrong to me that you remove the CONFIG_ dependency.
> Same is true for the rest of this cset.

No, that's fine. We only enter this subdirectory if
CONFIG_ACPI_INTERPRETER is set, so we do not need to repeat the variable
here. A lot of places rely on this behavior to persist, so why not use it?

> > +ifdef list-multi
> > +$(warning kbuild: list-multi ($(list-multi)) is obsolete in 2.5. Please fix!)
> > +endif
> Since kbuild no longer support list-multi this should be $(error ....)

Well, since it will still work fine (throwing an additional warning
later on), I think a warning is okay here. I should have made the O_TARGET
one an error now, though, since that stopped working. Anyway,
I'll make both of them an error in a little bit, so...

> > SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m)))
> I prefer first assignment to be := not +=
> This is true for several places including several makefiles as well.

Well, really mostly a matter of taste. Using += everywhere has the
advantage that you can add another line before that line without changing
out. Kinda the same thing as adding a comma after the last element of a
struct / enum.

> > -export CPPFLAGS EXPORT_FLAGS NOSTDINC_FLAGS OBJCOPYFLAGS
> > +export CPPFLAGS EXPORT_FLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
> Did not see this change justified.

The export LDFLAGS just moved to a place where it's more logical.

> > -export NETWORKS DRIVERS LIBS HEAD LDFLAGS MAKEBOOT
> > +$(warning $(SUBDIRS))
>
> Warning shall be deleted

Right. I overlooked it first, but it's deleted in a later cset.

> > ifndef O_TARGET
> > ifndef L_TARGET
> > -O_TARGET := built-in.o
> > +O_TARGET := $(obj)/built-in.o
> > +endif
> > endif
> This change result in ld being called for directories like:
> $(TOPDIR)/scripts
> $(TOPDIR)/scripts/lxdialog
> $(TOPDIR)/Documentation/DocBook
> If obj-y is empty then do not define O_TARGET?

Well, it's rather that I used EXTRA_TARGETS in those subdirs now. You're
right that the standard rules do not apply in those dirs, so I'll think
of a way to fix it there. Not defining O_TARGET when obj-y is empty is not
an option, we rely on that case working elsewhere.

> Another more general comment.
> There seem to no consistency in the variables used in the first section of
> the makefile. There is a mixture of lower and upper case variables:
> O_TARGET, host-progs etc. This is confusing.

Well, the whole thing is moving away from capitalized letters (in
particular in the per-subdir Makefiles), as it is moving from old-style
to new-style. The only common variables which are capitalized are
CFLAGS, CC and the like, and I think they'll stay since that's standard
make. kbuild-specific variables should really be basically all lower-case
by now, I can only think of L_TARGET as an exception.

> Furthermore the construct:
> obj-y := some.o dot.o .o module.o
> Seems illogical to me. What does obj-y mean to me??
> mandatory-objs := some.o dot.o .o module.o

No, I think once you've understood obj-$(CONFIG_FOO), the meaning
of obj-y is perfectly clear. Giving multiple names to the samt thing is
not good, next thing would be people wondering what the difference
between obj-y and mandatory-objs is.

> > first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
> Where comes the requirement that EXTRA_TARGETS needs to be buildin?

Initially, it was for built-in targets in addition to the standard
O_TARGET, like arch/i386/kernel/head.o.
I've been abusing it for scripts/, and I shouldn't be doing that.

> > -cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs),$^)
> > +cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs)))),$^)
> Keep a variable without obj appended would make this readable I think.

I agree that it is not particularly readable, but I'm limited to what make
offers. What do you suggest?

--Kai


2002-10-03 20:25:43

by Sam Ravnborg

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Thu, Oct 03, 2002 at 10:01:20PM +0200, Sam Ravnborg wrote:
> Now it's testing time..

1)
In order to make it link I had to change the following in rules.make:
# If the list of objects to link is empty, just create an empty O_TARGET
cmd_link_o_target = $(if $(strip $(obj-y)),\
- $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^),\
+ $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter-out FORCE,$(obj-y)),\
rm -f $@; $(AR) rcs $@)

Otherwise no objects were on the commandline because make strips ./

2)
Top-level Makefile still uses make -C therefore apths are relative to first
subdirectory as seen here:
CC udf/balloc.o
CC udf/dir.o
CC udf/file.o
CC udf/ialloc.o


3) acpi failed to compile due to -Idrivers/acpi/include, but current
directory is drivers.

Sam

2002-10-03 20:16:34

by Peter Samuelson

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild


[Sam Ravnborg]
> > +ifdef list-multi
> > +$(warning kbuild: list-multi ($(list-multi)) is obsolete in 2.5. Please fix!)
> > +endif
> Since kbuild no longer support list-multi this should be $(error ....)

Except that it is harmless. list-multi is a hint which the kbuild
system no longer needs. Code with list-multi is (I believe) still
compatible with today's kbuild, so there's no need to *force* a
cleanup.

Peter

2002-10-03 20:37:14

by Peter Samuelson

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild


[Xavier Bestel]
> > make -f subdir/Makefile
>
> Could you do instead:
>
> include subdir/Makefile
> ?

Unfortunately, no. Not without changing the entire architecture of
the kernel build system. The current system depends on each Makefile
maintaining an independent state (think "stack frame") by means of a
lot of local variables. These variables have standard names and
functions, so you can't flatten the recursion without clobbering them.

> This would avoid recursive make, which isn't really a good idea
> (even if it's used widely).

Yes, we know recursive make is considered harmful - that's why Keith
Owens designed a nonrecursive solution last year. (And quite a nice
piece of work it was, too.) But to achieve his solution he basically
redesigned the whole system from scratch. Pretty much the *only*
thing kbuild2.5 has in common with current kbuild is a minimal set of
functional requirements.

Peter

2002-10-03 20:33:00

by Kai Germaschewski

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Thu, 3 Oct 2002, Sam Ravnborg wrote:

> On Thu, Oct 03, 2002 at 10:01:20PM +0200, Sam Ravnborg wrote:
> > Now it's testing time..

[...]

You must be missing some of the changes (My first push to bkbits was
incomplete, since I did inadvertently edit Makefile without checking it
out, I do that mistake all the time...). It's fixed in the current repo.

--Kai


2002-10-03 20:40:25

by Sam Ravnborg

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Thu, Oct 03, 2002 at 03:19:57PM -0500, Kai Germaschewski wrote:
> > Furthermore the construct:
> > obj-y := some.o dot.o .o module.o
> > Seems illogical to me. What does obj-y mean to me??
> > mandatory-objs := some.o dot.o .o module.o
>
> No, I think once you've understood obj-$(CONFIG_FOO), the meaning
> of obj-y is perfectly clear. Giving multiple names to the samt thing is
> not good, next thing would be people wondering what the difference
> between obj-y and mandatory-objs is.

I disagree here. To me it looks like obj-y is a misuse of the
obj-$(CONFIG_XXX) rule.
It looks much more intuitive to have a separate rule. But common practice
today differ so it should stay.
Another argument is that we should keep the way to express things down
only one way.

> Initially, it was for built-in targets in addition to the standard
> O_TARGET, like arch/i386/kernel/head.o.
> I've been abusing it for scripts/, and I shouldn't be doing that.

You used EXTRA_TARGETS to make sure host-progs programs got compiled.
In general the way to use host-progs is not nice.

Typical usage:

host-progs := gentbl
include $(TOPDIR)/Rules.make
%tbl: %data: $(obj)/somefile.data $(obj)/gentbl
gentbl $< $@

In other words you need to make an explicit prerequisite to the host-progs
to get it build, which is what you did with EXTRA_TARGETS.

I would advocate for another solution:
Let programs listed in host-progs be compiled always.
Then the makefile could assign host-progs conditionally instead.
find -name Makefile | xargs grep host-progs | wc -l
12

A doable task, that I'm ready to do.


We could also define
force-host-progs :=
or something similar.


>
> > > -cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs),$^)
> > > +cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs)))),$^)
> > Keep a variable without obj appended would make this readable I think.
>
> I agree that it is not particularly readable, but I'm limited to what make
> offers. What do you suggest?

Untested:
$(notdir $(@:.o=-objs))

Sam

2002-10-03 20:46:52

by Sam Ravnborg

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Thu, Oct 03, 2002 at 03:38:22PM -0500, Kai Germaschewski wrote:
> On Thu, 3 Oct 2002, Sam Ravnborg wrote:
>
> > On Thu, Oct 03, 2002 at 10:01:20PM +0200, Sam Ravnborg wrote:
> > > Now it's testing time..
>
> [...]
>
> You must be missing some of the changes (My first push to bkbits was
> incomplete, since I did inadvertently edit Makefile without checking it
> out, I do that mistake all the time...). It's fixed in the current repo.

This time I applied the patch you sent in the mail.
Checking bkbits....
Yep, the latest csets on bkbits fixes some of this.

Sam

2002-10-04 19:01:36

by Sam Ravnborg

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Thu, Oct 03, 2002 at 03:38:22PM -0500, Kai Germaschewski wrote:
> You must be missing some of the changes (My first push to bkbits was
> incomplete, since I did inadvertently edit Makefile without checking it
> out, I do that mistake all the time...). It's fixed in the current repo.

Did a pull from bkbits at 18:30 CET, something like 09:30 pacific I think.

In general.
I like where you are heading, both the make -f, but also the cleanup done
in the top-level Makefile.
It makes it much easier to integrate my (ours) new make clean stuff -
but that shall wait until this is in the kernel.

Comments looking at the two new csets:
1)
In the descend macro you test for
ifeq ($(KBUILD_VERBOSE),1)
To make it consistent I suggest to use
ifneq ($(KBUILD_VERBOSE),0)
As done earlier in the Makefile

2) Needed the following to make my kernel compile (make mrproper defconfig all)
===== Rules.make 1.76 vs edited =====
--- 1.76/Rules.make Thu Oct 3 04:51:25 2002
+++ edited/Rules.make Fri Oct 4 20:38:37 2002
@@ -161,7 +161,7 @@
# This sets version suffixes on exported symbols
# ---------------------------------------------------------------------------

-MODVERDIR := include/linux/modules/$(obj)
+MODVERDIR := include/linux/modules

#
# Added the SMP separator to stop module accidents between uniprocessor
@@ -191,7 +191,7 @@
# files (fix-dep filters them), so touch modversions.h if any of the .ver
# files changes

-quiet_cmd_cc_ver_c = MKVER include/linux/modules/$(obj)/$*.ver
+quiet_cmd_cc_ver_c = MKVER include/linux/modules/$*.ver
cmd_cc_ver_c = $(CPP) $(c_flags) $< | $(GENKSYMS) $(genksyms_smp_prefix) \
-k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > [email protected]

Otherwise if failed first time it included modversions.h

3) This is just to make output nicer with KBUILD_VERBOSE=0
===== drivers/pci/Makefile 1.15 vs edited =====
--- 1.15/drivers/pci/Makefile Wed Oct 2 21:54:34 2002
+++ edited/drivers/pci/Makefile Fri Oct 4 20:59:55 2002
@@ -29,7 +29,9 @@
obj-y += syscall.o
endif

-host-progs := gen-devlist
+host-progs := gen-devlist
+quiet_cmd_gendevlist = DEVLIST $<
+cmd_gendevlist = ( cd $(obj); ./gen-devlist ) < $<

include $(TOPDIR)/Rules.make

@@ -40,6 +42,6 @@
# And that's how to generate them

$(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist
- ( cd $(obj); ./gen-devlist ) < $<
+ $(call cmd,gendevlist)

$(obj)/classlist.h: $(obj)/devlist.h


And the same for zorro:
===== drivers/zorro/Makefile 1.6 vs edited =====
--- 1.6/drivers/zorro/Makefile Wed Oct 2 21:54:34 2002
+++ edited/drivers/zorro/Makefile Fri Oct 4 21:05:54 2002
@@ -7,7 +7,9 @@
obj-$(CONFIG_ZORRO) += zorro.o names.o
obj-$(CONFIG_PROC_FS) += proc.o

-host-progs := gen-devlist
+host-progs := gen-devlist
+quiet_cmd_gendevlist = DEVLIST $<
+cmd_gendevlist = ( cd $(obj); ./gen-devlist ) < $<

include $(TOPDIR)/Rules.make

@@ -18,4 +20,4 @@
# And that's how to generate them

$(obj)/devlist.h: $(src)/zorro.ids $(obj)/gen-devlist
- ( cd $(obj); ./gen-devlist ) < $<
+ $(call cmd,gendevlist)

2002-10-04 20:14:04

by Sam Ravnborg

[permalink] [raw]
Subject: Re: RfC: Don't cd into subdirs during kbuild

On Fri, Oct 04, 2002 at 09:07:01PM +0200, Sam Ravnborg wrote:
> On Thu, Oct 03, 2002 at 03:38:22PM -0500, Kai Germaschewski wrote:
> > You must be missing some of the changes (My first push to bkbits was
> > incomplete, since I did inadvertently edit Makefile without checking it
> > out, I do that mistake all the time...). It's fixed in the current repo.
>
> Did a pull from bkbits at 18:30 CET, something like 09:30 pacific I think.

make xconfig is broken.
The following fixes this:

===== scripts/Makefile 1.18 vs edited =====
--- 1.18/scripts/Makefile Thu Oct 3 20:20:25 2002
+++ edited/scripts/Makefile Fri Oct 4 22:13:32 2002
@@ -30,6 +30,8 @@
# but it is not worth the effort to generate the dependencies.
# The alternative solution to always generate it is fairly fast.
# FORCE it to remake
+kconfig.tk: $(obj)/kconfig.tk
+
$(obj)/kconfig.tk: $(srctree)/arch/$(ARCH)/config.in $(obj)/tkparse FORCE
@echo ' Generating $@'
@( \