public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jerry Cooperstein <coop@axian.com>
To: linux-kernel@vger.kernel.org
Cc: sam@ravnborg.org
Subject: Re: no version magic, tainting kernel.
Date: Mon, 27 Jan 2003 11:35:04 -0800	[thread overview]
Message-ID: <20030127193504.GA9720@p3.attbi.com> (raw)
In-Reply-To: <20030127191225.GA3707@mars.ravnborg.org>

On Mon, Jan 27, 2003 at 08:12:25PM +0100, Sam Ravnborg wrote:
> 
> 1) You do not need any targets like all: or mmodules:
> 2) The clean: rule will not be used in 2.5, use clean-files instead.
> 3) No reason to special case on .ko or not. .ko will not harm on 2.4
> 4) I cannot see any reason to declare all OBJS as .PHONY
> 5) It looks like you try to enable the use of make in the directory
>    where the module exists.
>    This is an unusual extension, which will clutter up the makefile
>    a bit.
>    I would prefer a mmake script or similar that did the make -c ... trick.
> 
> 	Sam

on 4): yep, no need for PHONY stuff (simplified script attached)

The reason for this cropping in is that I had a more complex script
that reflected my actual situation; I have a directory that contains
some kernel modules, some testing programs and other junk, and I 
build a complete Makefile that has rules for all these guys, not
just the kernel modules.  Which is why I violated your sensibilties
about the other points I guess.  I didn't just want to pass the
work off to the kernel building stuff.

If you want to do this I agree all you need is the part to generate
a objs-m list and the Rules.make stuff for 2.4, and that is 
simpler.  You could indeed remove all the targets etc, but then
as you note, you can't just say make, but have to do the 
     make -C KERNEL_SOURCE SUBDIRS=$PWD modules 
 business.

 I've attached that one too.

 coop

======================================================================
 Jerry Cooperstein,  Senior Consultant,  <coop@axian.com>
 Axian, Inc., Software Consulting and Training
 4800 SW Griffith Dr., Ste. 202,  Beaverton, OR  97005 USA
 http://www.axian.com/               
======================================================================

#(FULL SCRIPT, NO PHONY):
######################################################################
#!/bin/bash

# script for generating external Makefile for kernel modules
# Jerry Cooperstein, Axian Inc 2003_01_27
# Too trivial to GPL; use as desired.

# do either "makeit"; assumes kernel source at /usr/src/linux-`uname -r`
#    or     "makeit /usr/src/linux-2.5.59 or makeit /usr/src/linux-2.4.20" etc.

# Should work on all 2.4, 2.5 kernels.
# assumes all .c files in current directory are modules

if [ "$1" == "" ] ; then
    KROOT=/usr/src/linux-`uname -r`
else
    KROOT="$1"
fi

if [ `echo $KROOT | grep 2.5` ] ; then
    VERSION=2.5
else
    VERSION=2.4
fi

OBJS=""
for names in *.c ; do 
    OBJS=$OBJS" `basename $names .c`.o"
done

rm -f Makefile

cat <<EOF > Makefile
obj-m += $OBJS
KROOT=$KROOT
all: mmodules
EOF

if [ $VERSION == 2.5 ] ; then
CLEANSTUFF="*.o *.ko .*cmd"

cat <<EOF >> Makefile
EOF

else

CLEANSTUFF="*.o .*flags"

cat <<EOF >> Makefile
TOPDIR=\$(KROOT)
include \$(TOPDIR)/Rules.make
EOF
fi

cat <<EOF >> Makefile
mmodules:
	\$(MAKE) -C \$(KROOT) SUBDIRS=$PWD modules
clean:
	rm $CLEANSTUFF
EOF

######################################################################
#(SHORT SCRIPT: no local make targets)

#!/bin/bash

# script for generating external Makefile for kernel modules
# Jerry Cooperstein, Axian Inc 2003_01_27
# Too trivial to GPL; use as desired.

# do either "makeit"; assumes kernel source at /usr/src/linux-`uname -r`
#    or     "makeit /usr/src/linux-2.5.59 or makeit /usr/src/linux-2.4.20" etc.

# Should work on all 2.4, 2.5 kernels.
# assumes all .c files in current directory are modules

if [ "$1" == "" ] ; then
    KROOT=/usr/src/linux-`uname -r`
else
    KROOT="$1"
fi

if [ `echo $KROOT | grep 2.5` ] ; then
    VERSION=2.5
else
    VERSION=2.4
fi

OBJS=""
for names in *.c ; do 
    OBJS=$OBJS" `basename $names .c`.o"
done

rm -f Makefile

cat <<EOF > Makefile
obj-m += $OBJS
KROOT=$KROOT
EOF

if [ $VERSION == 2.5 ] ; then

cat <<EOF >> Makefile
EOF

else

cat <<EOF >> Makefile
TOPDIR=\$(KROOT)
include \$(TOPDIR)/Rules.make
EOF
fi


  reply	other threads:[~2003-01-27 19:27 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-23 13:59 no version magic, tainting kernel Thomas Schlichter
2003-01-23 16:29 ` Randy.Dunlap
2003-01-23 16:52 ` Sam Ravnborg
2003-01-23 17:32   ` Thomas Schlichter
2003-01-23 18:22     ` Sam Ravnborg
2003-01-23 19:35       ` Mark Fasheh
2003-01-26 13:29         ` Christian Zander
2003-01-26 13:33           ` Keith Owens
2003-01-26 18:02             ` Kai Germaschewski
2003-01-26 17:51           ` Kai Germaschewski
2003-01-26 21:57             ` Christian Zander
2003-01-26 21:46               ` Kai Germaschewski
2003-01-26 23:12                 ` Christian Zander
2003-01-26 22:55                   ` David Woodhouse
2003-01-27  0:07                     ` Christian Zander
2003-01-26 23:16                       ` David Woodhouse
2003-01-27  0:24                         ` Christian Zander
2003-01-27 16:25                         ` Kai Germaschewski
2003-01-27 16:29                           ` David Woodhouse
2003-01-27 16:39                             ` Kai Germaschewski
2003-01-27  6:17                 ` Petr Vandrovec
2003-01-27  9:02                   ` David Woodhouse
2003-01-27  9:24                     ` Petr Vandrovec
2003-01-27 17:59                 ` Joel Becker
2003-01-27 18:31                   ` Kai Germaschewski
2003-01-27 22:15                     ` Joel Becker
2003-01-27 23:08                       ` Kai Germaschewski
2003-01-27 23:37                         ` Joel Becker
2003-01-28 15:43                       ` David Woodhouse
2003-01-28 17:03                         ` Joel Becker
2003-01-26 22:23               ` Christian Zander
2003-01-26 17:43         ` Kai Germaschewski
2003-01-26 22:08           ` Christian Zander
2003-01-26 21:29             ` Sam Ravnborg
2003-01-26 23:03               ` Christian Zander
2003-01-26 21:40             ` David Woodhouse
2003-01-26 23:28               ` Christian Zander
2003-01-26 22:46                 ` David Woodhouse
2003-01-26 23:56                   ` Christian Zander
2003-01-26 23:04                     ` David Woodhouse
2003-01-28  1:58         ` Rusty Russell
2003-01-28 19:10           ` Mark Fasheh
2003-01-28 19:17             ` Kai Germaschewski
2003-01-27 18:52 ` Jerry Cooperstein
2003-01-27 19:12   ` Sam Ravnborg
2003-01-27 19:35     ` Jerry Cooperstein [this message]
2003-01-27 19:54   ` Gerd Knorr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030127193504.GA9720@p3.attbi.com \
    --to=coop@axian.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox