On Sunday 16 November 2003 15:45, Svetoslav Slavtchev wrote:
> > On Sunday 16 November 2003 06:20, Svetoslav Slavtchev wrote:
> > > my current patch tarball is uploading
> > > linux-test9s5.tar.bz2
> >
> > I tried 3rdparty but it won't work as is. Dynamically generating Makefile
> > and
> > Kconfig highly confuses build system; BTW it won't even compile if all
> > 3rdparty are modules.
>
> strange,
> i never compiled smth in 3rdparty built in, always as modules,
> and never had problems
>
all of this in build != src. after make vmlinux:
ld -m elf_i386 -T arch/i386/kernel/vmlinux.lds.s
arch/i386/kernel/head.o arch/i386/kernel/init_task.o init/built-in.o
--start-group usr/built-in.o arch/i386/kernel/built-in.o
arch/i386/mm/built-in.o arch/i386/mach-default/built-in.o kernel/built-in.o
mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o
crypto/built-in.o lib/lib.a arch/i386/lib/lib.a lib/built-in.o
arch/i386/lib/built-in.o drivers/built-in.o sound/built-in.o
3rdparty/built-in.o arch/i386/pci/built-in.o arch/i386/power/built-in.o
net/built-in.o --end-group -o .tmp_vmlinux1
ld: cannot open 3rdparty/built-in.o: No such file or directory
make[1]: *** [.tmp_vmlinux1] Error 1
make: *** [vmlinux] Error 2
make: Leaving directory `/home/bor/src/linux-2.6.0-test9'
> > I suggest you use mkbuild.pl to generate static Makefile and Kconfig. How
> > often is it going to change? It could be done as part of making RPM.
>
> i tried to follow the 2.4 way, and i had no problems so far
> except that "make mrproper" breaks "make clean" cause it deletes
> 3rdparty/Makefile
>
> but it's pretty trivial to build it only once
>
using patch below there is no need to remove files; they should be updated if
you change subdirs (add or remove).
> > Setting 3rdparty as part of drivers-y forces it to expect
> > 3rdparty/built-in.o
> > but it is not built unless something in 3rdparty is compiled as builtin.
> > I
> >
> > was about to initialize SUBDIRS but then it prevents from overriding it
> > on
> >
> > command line .... probably something like
> >
> > ifeq ($(origin SUBDIRS),file)
> > SUBDIRS+=3rdparty
> > endif
>
> may be adding to the Kconfig's in each 3rdparty tarball "select 3rdparty"
> and
> -----------------------------
> drivers-y := drivers/ sound/
> if $(CONFIG_3RDPARTY)
> drivers-y += 3rdparty/
> endif
>
> would fix it
>
it is not condition. The problem is "-y". It means you are going to build
subdir contents in kernel. But 3rdparty/Makefile does not build
3rdparty/built-in.o itself nor has it any dependencies to build it. If
everything is module it will get only obj-m += ...; and no built-in.o is
generated. I do not know if it a bug or feature.
setting SUBDIRS means kbuild just descends and makes modules as expected. I do
not like this much but I am not sure how to do it differently. check other
top-level makefiles, all of them has unconditional obj-y.
> > of course neither Makefile nor Kconfig should be removed by mrproper
> > then.
> >
> > BTW your current setup obviously does not work if srctree != buildtree. I
> > attempted to fix it but hopelessly failed :)
> >
> :(
>
> never tried that
>
> what were the errors,
> not finding some of the headers ?
>
{pts/0}% ./makelinux V=1 oldconfig
make: Entering directory `/home/bor/src/linux-2.6.0-test9'
make -C /home/bor/build/linux-2.6.0-test9 \
KBUILD_SRC=/home/bor/src/linux-2.6.0-test9 KBUILD_VERBOSE=1 \
KBUILD_CHECK= -f /home/bor/src/linux-2.6.0-test9/Makefile oldconfig
(cd 3rdparty ; perl ./mkbuild.pl)
Can't open perl script "./mkbuild.pl": No such file or directory
make[1]: *** [3rdparty/Makefile] Error 2
make: *** [oldconfig] Error 2
make: Leaving directory `/home/bor/src/linux-2.6.0-test9'
this is for a start :)
attached simple diff for this but that is not what I like very much.
if you are going to do it this way, here is diff against Makefile that
correctly automatically rebuilds Makefile and Kconfig when you add or change
subdirs in 3rdparty. and slightly modified mkbuild.pl
it was useful exercise :) still I ask myself if it does make sense to generate
them dynamically.
--- ../tmp/linux-2.6.0-test9/Makefile 2003-10-27 19:02:59.000000000 +0300
+++ linux-2.6.0-test9/Makefile 2003-11-16 22:07:49.576939032 +0300
@@ -314,6 +314,18 @@
scripts/fixdep:
$(Q)$(MAKE) $(build)=scripts $@
+# Create Makefile/Kconfig for all the 3rdparty stuff
+$(srctree)/3rdparty/Makefile $(srctree)/3rdparty/Kconfig: FORCE $(srctree)/3rdparty/mkbuild.pl
+ @set -e; \
+ echo ' CHK $@'; \
+ mkdir -p $(dir $@); \
+ (cd $(@D) && ./mkbuild.pl $(@F) > [EMAIL PROTECTED]); \
+ if [ -r $@ ] && cmp -s $@ [EMAIL PROTECTED]; then \
+ rm -f [EMAIL PROTECTED]; \
+ else \
+ echo ' UPD $@'; \
+ mv -f [EMAIL PROTECTED] $@; \
+ fi
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
@@ -357,9 +369,9 @@
# *config targets only - make sure prerequisites are updated, and descend
# in scripts/kconfig to make the *config target
-%config: scripts/fixdep FORCE
+%config: $(srctree)/3rdparty/Makefile $(srctree)/3rdparty/Kconfig scripts/fixdep FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
-config : scripts/fixdep FORCE
+config : $(srctree)/3rdparty/Makefile $(srctree)/3rdparty/Kconfig scripts/fixdep FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
else
@@ -375,7 +387,7 @@
# Objects we will link into vmlinux / subdirs we need to visit
init-y := init/
-drivers-y := drivers/ sound/
+drivers-y := drivers/ sound/ 3rdparty/
net-y := net/
libs-y := lib/
core-y := usr/
@@ -578,7 +590,7 @@
$(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
endif
-prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
+prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER $(srctree)/3rdparty/Makefile
ifdef KBUILD_MODULES
ifeq ($(origin SUBDIRS),file)
$(Q)rm -rf $(MODVERDIR)
@@ -761,6 +773,7 @@
include/asm \
.hdepend include/linux/modversions.h \
tags TAGS cscope* kernel.spec \
+ $(srctree)/3rdparty/Makefile.meta $(srctree)/3rdparty/Makefile $(srctree)/3rdparty/Kconfig \
.tmp*
# Directories removed with 'make mrproper'
#!/usr/bin/perl -w
#
# Version 1.0
#
# Copyright 2001 Jeff Garzik <[EMAIL PROTECTED]>
# Copyright 2002 Juan Quintela <[EMAIL PROTECTED]>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
#
#
# Run "mkbuild.pl"
#
# This program generates the following files
# Makefile
# Makefile.drivers
# Config.in
# using the information in the subdirs of this directory.
#
# subdirs need to have:
# a Config.in file
# a Makefile with a O_TARGET/L_TARGET targets
# The config.in should set a CONFIG_<module_dir_name> to m/y.
use strict;
opendir(THISDIR, ".");
# get dirs without . and .. garbage
my (@modules) = grep(!/\.\.?$/,grep(-d, readdir(THISDIR)));
closedir(THISDIR);
if ($ARGV[0] eq "Kconfig") {
generate_kconfig(@modules);
} elsif ($ARGV[0] eq "Makefile") {
generate_makefile(@modules);
} else {
die "Unknown build file!"
}
exit(0);
##########################################################################
sub generate_makefile {
my (@modules) = @_;
print <<'EOM';
#
# THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT.
#
EOM
printf "obj-\$(%s) += %s/\n", to_CONFIG($_), $_ foreach @modules;
}
sub generate_kconfig {
my (@modules) = @_;
print <<"EOM";
#
# THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT.
#
#menu_option next_comment
menu 'Unofficial 3rd party kernel additions'
EOM
foreach (@modules) {
die "No Kconfig in $_.\n" if ! -r "$_/Kconfig";
print "source 3rdparty/$_/Kconfig\n";
}
print "\n\nendmenu\n";
}
sub to_CONFIG {
local $_ = $_[0];
tr/a-z/A-Z/;
s/[\-\. ]/_/g;
"CONFIG_$_";
}