mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Keith Owens <kaos@ocs.com.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: kbuild-2.5
Date: Thu, 01 Nov 2001 11:19:02 +0000	[thread overview]
Message-ID: <22644.1004613542@warthog.cambridge.redhat.com> (raw)
In-Reply-To: Your message of "Thu, 11 Oct 2001 07:16:05 +1000." <16055.1002748565@ocs3.intra.ocs.com.au>


> David Howells <dhowells@redhat.com> wrote:
> >Will kbuild get Makefiles in each subdirectory that allow 
> >it to build just the things in that subdirectory tree?
> 
> Documentation/kbuild/kbuild-2.5.txt, KBUILD TARGETS.

Okay... for users of emacs, here's an elisp function that looks to see if it's
in a subdirectory of a kernel tree (and if so whether it's kbuild or
traditional), and if so invents an appropriate command line for compiling just
in that subdir:-) Otherwise it just falls back to the usual compile function.

This can be put in a .emacs file, and can bound to a key:

	(global-set-key [f5] 'kernel-compile)

David


(defun kernel-compile ()
  "Attempt to compile the current directory as if it's part of a kernel tree,
otherwise default to normal compile."
  (interactive)
  (let ((buffile (buffer-file-name))
	(bufbits)
	(curdir)
	(topdir)
	(subdir)
	(slasher)
	(cmdline)
	(pos))
    (if (not buffile)
	;; no buffer file name
	(progn
	  (setq cmdline (read-from-minibuffer "Compile command: "
					      compile-command nil nil
					      '(compile-history . 1)))
	  (compile cmdline)
	  )
      ;; got a buffer filename, split into directory name chunks
      (progn
	(setq bufbits (split-string (buffer-file-name) "/"))

	;; create a function to interpose slash characters between all the
	;; elements of a string list, but not to add leading of trailing
	;; slashes
	(setq slasher
	      (lambda (lst slasher)
		(if (not (cdr lst))
		    lst
		  (append (list (concat (car lst) "/"))
			  (apply slasher (list (cdr lst) slasher))
			  ))))

	;; iteratively work up the directory tree from the current directory
	;; looking for various marker files
	(setq topdir nil)
	(setq pos (length bufbits))
	(while (and (> pos 1) (not topdir))
	  (setq pos (- pos 1))
	  (setq curdir (subseq bufbits 0 pos))
	  (setq curdir (apply slasher (list curdir slasher)))
	  (setq curdir (eval (append '(concat) (list "/") curdir)))
	  (if (and
	       (file-readable-p (concat curdir "/COPYING"))
	       (file-readable-p (concat curdir "/CREDITS"))
	       (file-readable-p (concat curdir "/README"))
	       (file-readable-p (concat curdir "/MAINTAINERS"))
	       (file-readable-p (concat curdir "/Makefile"))
	       (file-readable-p (concat curdir "/kernel/sched.c"))
	       )
	      (setq topdir curdir)
	      )
	  )

	(if topdir
	    ;; deal with the markers being found
	    (progn
	      (if (not (file-symlink-p (concat curdir "/include/asm")))
		  (error "The %s/include/asm symlink appears to be missing"
			 topdir))

	      (setq subdir (subseq bufbits pos(- (length bufbits) 1)))
	      (setq subdir (apply slasher (list subdir slasher)))
	      (setq subdir (eval (append '(concat) subdir)))

	      ;; determine whether using kbuild or not
	      (if (file-readable-p (concat curdir "/scripts/shadow.pl"))
		  ;; kbuild
		  (setq cmdline (concat "make -C " topdir " " subdir))
		;; traditional
		(setq cmdline (concat "make -C " topdir " SUBDIRS=" subdir))
		)
	      (setq cmdline (read-from-minibuffer "Kernel compile: "
						  cmdline nil nil
						  '(compile-history . 1)))
	      (compile cmdline)
	      )

	  ;; deal with the markers not being found
	  (setq cmdline (read-from-minibuffer "Compile command: "
					      compile-command nil nil
					      '(compile-history . 1)))
	  (compile cmdline)
	  )

	))
    )
  )

       reply	other threads:[~2001-11-01 11:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <16055.1002748565@ocs3.intra.ocs.com.au>
2001-11-01 11:19 ` David Howells [this message]
2001-11-01 12:21   ` kbuild-2.5 Keith Owens

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=22644.1004613542@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=kaos@ocs.com.au \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®