Skip to contentSkip to conversation

kbuild-2.5

DISCUSSION David Howells 2 participants 2 messages Nov 1, 2001 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 6 lines
Quoted 2 lines · David Howells

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)
)

))
)
)

#2 lore raw
Quoted 8 lines · David Howells

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. (defun kernel-compile ()
....
(if (and
(file-readable-p (concat curdir "/COPYING"))

Won't work with separate source and object trees in kbuild 2.5.

export KBUILD_SRCTREE_000=/build/kaos/2.4.13-kbuild-2.5 export KBUILD_OBJTREE=/build/kaos/object-2.4.13 cd /anywhere/you/like
make -f $KBUILD_SRCTREE_000/Makefile-2.5

If you define the kbuild tree variables then you can be in any directory when you issue the make command. If you are using shadow trees then you can be in a sparse source tree which only contains of the files.

Quoted 2 lines

;; determine whether using kbuild or not
(if (file-readable-p (concat curdir "/scripts/shadow.pl"))

grep CONFIG_KBUILD_2_5 .config is better, you can still build using kbuild 2.4 even after applying the 2.5 patch. The presence of a kbuild 2.5 file is not definitive. Of course the .config is in $KBUILD_OBJTREE which might not be the current directory.