GIT 94fb89c040d3a8557b00f042a05901f362bf4c1c git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild.git commit 94fb89c040d3a8557b00f042a05901f362bf4c1c Author: Sam Ravnborg Date: Sun Jan 13 22:21:31 2008 +0100 kbuild: simplify section mismatch check in modpost Change the logic in modpost so we identify all the bad combinations of sections that refer to other sections. Compared to the previous approach we are much less dependent on knowledge of what additional sections the tool chain uses and thus we can keep the false positives low. The implmentation is changed to use a table based lookup and we now check all combinations in first pass so we no longer need separate passed for init and exit sections. Tested that the same warnings are generated for a allyesconfig build without CONFIG_HOTPLUG. Signed-off-by: Sam Ravnborg Cc: Randy Dunlap Cc: Adrian Bunk commit aed26daefacc658f32d24834b6e9a03702b2f7f2 Author: Valdis.Kletnieks@vt.edu Date: Fri Dec 28 21:22:48 2007 -0500 kbuild: document 'make prepare' in 'make help' The output of 'make help' covers a lot of options, but doesn't include a listing for 'make prepare'. Here's a one-liner to fix that... Signed-off-by: Valdis Kletnieks Signed-off-by: Sam Ravnborg commit 6f14defdc0124c61d10f2fbae9f63090f6bf45b3 Author: EGRY Gabor Date: Fri Jan 11 23:55:20 2008 +0100 kconfig: whitespace removing This patch removes the unnecessary whitespaces from end of help lines of Kconfig files. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 897c2ce48d50ece2bb49592dbecfb548fc692346 Author: EGRY Gabor Date: Fri Jan 11 23:53:43 2008 +0100 kconfig: macro fix in menu.c This patch removes the indirect I18N support for config file. Signed-off-by: Egry Gabor Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 5fd68e72c7a5a233d3b3218fae872cee4988185d Author: EGRY Gabor Date: Fri Jan 11 23:52:07 2008 +0100 kconfig: gettext support for xconfig Full gettext support for xconfig. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 126352fc485e08ca19b070c3d1eec12faebc9fdb Author: EGRY Gabor Date: Fri Jan 11 23:50:37 2008 +0100 kconfig: gettext support for menuconfig Full gettext support for menuconfig. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit bb2e0512be2cd30c62e245be3b55bf408f9aad4a Author: EGRY Gabor Date: Fri Jan 11 23:49:12 2008 +0100 kconfig: gconfig: symbol fix Gettext support for symbol names are unnecessary. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit c854cdfbccab1b3612886e0893189d24e0d736e7 Author: EGRY Gabor Date: Fri Jan 11 23:47:58 2008 +0100 kconfig: missing macros in gconfig This patch adds missing gettext macros. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 9cca6e909af622efde587c02c9396c11ec72520f Author: EGRY Gabor Date: Fri Jan 11 23:46:11 2008 +0100 kconfig: gettext support for gconfig Gettext support for menu and toolbar. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 6e7048f186565ba5f2a1bbde807c88d2f509f971 Author: EGRY Gabor Date: Fri Jan 11 23:44:39 2008 +0100 kconfig: gettext support for config Gettext support for conf.c . Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 15a44f1f85ac86a8b1ca7b99e27b6e99b77949ac Author: EGRY Gabor Date: Fri Jan 11 23:42:54 2008 +0100 kconfig: gettext support for lxdialog Gettext support for lxdialog. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 66b5795978bf9c86b2dbb6e2686ff18676c24b00 Author: EGRY Gabor Date: Fri Jan 11 23:40:00 2008 +0100 kconfig: update-po-config info This patch adds tracking messages. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 148677dec70f0510ef71b750eb5396b4c1dbd6da Author: Jan Beulich Date: Fri Jan 11 09:09:00 2008 +0000 kbuild: scripts/mkmakefile: dynamic determination of output directory Rather than fixing the output directory in the generated Makefile, determine it from the placement of Makefile. This allows moving the build tree around or accessing it through different mount paths. (The lastword definition is a compatibility one for make prior to 3.81; newer make will simply ignore it and use the [faster] built-in.) Signed-off-by: Jan Beulich Signed-off-by: Sam Ravnborg commit f5ce1dd64a6aaf5f5dbc99aa139a6b7059ba54ba Author: Sam Ravnborg Date: Fri Jan 11 19:17:15 2008 +0100 kbuild: clean up modpost.c akpm complained about overly long lines in modpost.c and when started additional style issues were fixed: o Updated my copyright o Removed unneeded {} o Drop assignments in if () o Spaces around operators o Break long lines o locate * near variable not type o Fix a format specifier for sizeof() o Corrected placement of '{' and '}' o spaces to tabs (but use tabs only for indention) modpost.c is not checkpatch clean. Readability were favoured on top of checkpatch compliance. But checkpatch were used to find additional stuff to clean up. Signed-off-by: Sam Ravnborg commit 14310dae30157b6124bb1a07da52a2525a18f4a5 Author: Ladislav Michl Date: Wed Jan 9 16:36:19 2008 +0100 kconfig: use C89 random functions in conf.c rand and srand functions conform also to C89 in addition to POSIX.1-2001, which makes them a bit more portable (work also on MinGW host). Linux man page also says: "The versions of rand() and srand() in the Linux C Library use the same random number generator as random() and srandom()". * Use C89 conformant functions rand() and srand() Signed-off-by: Ladislav Michl Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 8445ec19b7f4c44f14603b2b65f9296d2ce04d2b Author: Ladislav Michl Date: Wed Jan 9 16:36:19 2008 +0100 kconfig: fix whitespace and sort includes in conf.c Sort includes and remove leading whitespace. Signed-off-by: Ladislav Michl Signed-off-by: Sam Ravnborg Cc: Roman Zippel Date: Tue Jan 8 15:16:24 2008 +0100 kbuild: ignore cache modifiers for generating the tags files With this patch I'm able to find the definition of _xmit_lock defined in include/linux/netdevice.h as follows: struct net_device { ... spinlock_t _xmit_lock ____cacheline_aligned_in_smp; } Otherwise this counts as definition of ____cacheline_aligned_in_smp. Signed-off-by: Uwe Kleine-König Signed-off-by: Sam Ravnborg commit f49e13e6f12f29dd0b860d158f7f95db8fb2a7b5 Author: Sam Ravnborg Date: Mon Jan 7 21:13:04 2008 +0100 kconfig: delete unused FILE_ and SYMBOL_ flags The *_PRINTED flags were never used - so delete them. Do we need them later then we can re-add them. Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 53c21c0dd0ade99366ce18f1208b4a1baf4c87eb Author: Sam Ravnborg Date: Mon Jan 7 21:09:55 2008 +0100 kconfig: rename E_OR & friends to avoid name clash We had macros named the same as a set of enumeration values. It is legal code but very confusing to read - so rename the macros from E_* to EXPR_* Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 10cc78f0f6b8f396879f988863f9a1de208e6487 Author: Josh Boyer Date: Thu Jan 3 16:05:30 2008 -0600 Remove mkuboot.sh script Now that the mkubootimg tool is merged into the kernel, we can remove the unused mkuboot.sh script. Signed-off-by: Josh Boyer commit 2671c99a2e0caa1e6b298ca2e4af0e838fd6df30 Author: Josh Boyer Date: Thu Jan 3 16:04:06 2008 -0600 kbuild: rework arch specific Makefiles to use mkubootimg Rework the architecture specific Makefiles to use the in-kernel version of the mkubootimg tool. Signed-off-by: Josh Boyer Acked-by: Paul Mundt (SH) Acked-by: Russell King (ARM) Acked-by: Haavard Skinnemoen (AVR) Acked-by: Bryan Wu (BLACKFIN) Cc: Paul Mackerras (POWERPC) Signed-off-by: Sam Ravnborg commit 34c389124576e0bd3c5fb75fbb3cfae96902b5f6 Author: Josh Boyer Date: Fri Jan 4 11:26:09 2008 -0600 kbuild: merge mkubootimg tool for building U-Boot images Several platforms require the mkimage tool to generate a uImage file that is used with U-Boot. This brings the mkimage tool in-kernel to enable building those platforms without having mkimage externally provided. The tool is named mkubootimg for better clarity. This is currently based off of the version found in U-Boot 1.3.1. Note: This patchs trigger followings output from checkpatch.pl: total: 45 errors, 144 warnings, 1097 lines checked As this is based on a copy of SW from U-boot this is accepted as an exception. Signed-off-by: Josh Boyer Signed-off-by: Sam Ravnborg Cc: Wolfgang Denk commit 5e68ba962c570209646231175c162bc58f4f8022 Author: Jan Engelhardt Date: Thu Jan 3 23:33:44 2008 +0100 kconfig: allow overriding symbols Allow config variables in .config to override earlier ones in the same file. In other words, # CONFIG_SECURITY is not defined CONFIG_SECURITY=y will activate it. This makes it a bit easier to do cat original-config myconfig myconfig2 ... >.config; and run *config as expected. Signed-off-by: Jan Engelhardt Signed-off-by: Sam Ravnborg Cc: Roman Zippel Cc: Randy Dunlap commit b31624fd979bd85314e3252cf3b9d8a9f06f71c9 Author: Ladislav Michl Date: Mon Dec 17 19:07:41 2007 +0100 kconfig: make kconfig MinGW friendly Kconfig is powerfull tool. So powerfull that more and more software projects are using it for configuration. So instead of fixing some of them one by one, lets fix it in kernel and wait for sync. This work was originaly done for PTXdist - GPL licensed build system for userlands and cross-compilers, but it will not hurt kernel kconfig either. PTXdist menuconfig now works on Windows linked with PDCurses and compiled using MinGW - there is no termios and signals. * Do not include and (comes from times when lxdialog was separate process) * Do not mess with termios directly and let curses tell screen size. Comment to commit c8dc68ad0fbd934e78e913b8a8d7b45945db4930 says check for screen size could be removed later, but because it didn't happen for more than year I left it here as well. * Save cursor position added by Sam Signed-off-by: Ladislav Michl Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 58e9113b8d96a635d4027b0bdcbb79bd65dc8a7b Author: Randy Dunlap Date: Mon Nov 12 16:17:55 2007 -0800 kconfig: add hints/tips/tricks to Documentation/kbuild/kconfig-language.txt Add a section on kconfig hints: how to do in Kconfig files. Fix a few typos/spellos. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg commit 310c3d0a95ac53976c2cf188c27ce2596651ec0c Author: Theodore Ts'o Date: Fri Nov 2 21:53:01 2007 -0400 kbuild: fix false positive -dirty tag caused by make-kpkg make-kpkg modifies scripts/package/Makefile and deletes scripts/package/builddeb as part of its build process. Ignore these changes so the tree isn't marked as -dirty, when it is just an artifact of make-kpkg. (make-kpkg clean restores the files to their original state, and these helper scripts won't affect the final compiled kernel in any way.) Signed-off-by: "Theodore Ts'o" Signed-off-by: Sam Ravnborg commit d5f24ea43702e90994a609963e2099e61748b176 Author: Theodore Ts'o Date: Fri Nov 2 21:53:00 2007 -0400 kbuild: fix scripts/setlocalversion to avoid erroneous -dirty tag If git's index file is out of date, and some files have been touched such that their timestamp doesn't what is in the index, "git diff-index HEAD" may show that a particular file is dirty, when in fact it really isn't. Running "git update-index" will update the index to avoid these false positives. Replacing 'git status' with 'git update-index' suggested by Uwe Kleine-König. Signed-off-by: "Theodore Ts'o" Signed-off-by: Sam Ravnborg Acked-By: Uwe Kleine-König commit cc02875b634e48b483c56ea5e4a5441ac63f1729 Author: Theodore Ts'o Date: Fri Nov 2 21:52:59 2007 -0400 kbuild: change CONFIG_LOCALVERSION_AUTO to use a git-describe-ish format Change the automatic local version to have the form -nnnnn-gSHA1SUMID, where 'nnnnn' is the number of commits since the last tag (i.e., 2.6.21-rc7). This makes it much more likely that the package names created for the kernel will look "newer" to a package manager. Signed-off-by: "Theodore Ts'o" Signed-off-by: Sam Ravnborg commit 72cf2253f55312030d52c676ea86f02faea7a29c Author: Andreas Mohr Date: Sat Nov 17 21:51:25 2007 +0100 kbuild: eradicate bashisms in scripts/patch-kernel Make the patch-kernel shell script sufficiently compatible with POSIX shells, i.e., remove bashisms from scripts/patch-kernel. This means that it now also works on dash 0.5.3-5 and still works on bash 3.1dfsg-8. Full changelog: - replaced non-standard "==" by standard "=" - replaced non-standard "source" statement by POSIX "dot" command - use leading ./ on mktemp filename to force the tempfile to a local directory, so that the search path is not used - replace bash syntax to remove leading dot by similar POSIX syntax - added missing (optional/not required) $ signs to shell variable names Signed-off-by: Andreas Mohr Acked-by: Randy Dunlap Signed-off-by: Sam Ravnborg commit 23530cd73efcc3f3d1c257724e0bb480e2db789c Author: WANG Cong Date: Wed Jan 2 13:55:33 2008 +0800 FS: Remove dead code Remove dead code in smbfs makefile. Cc: Al Viro Cc: Tim Shimmin Signed-off-by: WANG Cong Signed-off-by: Sam Ravnborg commit 524938e9b1528b5e49a5c15255ee8b353d5d78d5 Author: WANG Cong Date: Tue Jan 1 22:00:04 2008 +0800 FRV: Drop 'TOPDIR' from Makefiles This patch drops TOPDIR from frv Makefiles. Cc: David Howells Signed-off-by: WANG Cong Signed-off-by: Sam Ravnborg commit bc683c6a48615312a56c5fcb1f0b807da5e8f4f8 Author: WANG Cong Date: Tue Jan 1 21:41:08 2008 +0800 INFINIBAND: Remove 'TOPDIR' from Makefiles This patch removes TOPDIR from infiniband Makefile and delete one include statement pointing to a non-existing directory Cc: Roland Dreier Cc: Sean Hefty Cc: Hal Rosenstock Signed-off-by: WANG Cong Signed-off-by: Sam Ravnborg commit 6b62fae1113de4755bd5d99fec25c595a55d4f6e Author: WANG Cong Date: Wed Jan 2 14:27:59 2008 +0800 CRIS: Remove 'TOPDIR' from Makefiles This patch removes TOPDIR from Cris Makefiles. Cc: Mikael Starvik Cc: Jesper Nilsson Cc: Andreas Schwab Signed-off-by: WANG Cong Signed-off-by: Sam Ravnborg Tested-by: Jesper Nilsson commit 71a5c32d456e8a738fc2361fd10ec4cbea73bdb9 Author: Sam Ravnborg Date: Tue Jan 1 13:40:28 2008 +0100 kbuild: fix installing external modules Eric Sandeen reported: Installing external modules is supposed to put them in some path under /lib/modules//extra/subdir/, but this change: http://linux.bkbits.net:8080/linux-2.6/?PAGE=cset&REV=1.1982.9.23 makes them go under /lib/modules//extrasubdir (for example, make M=fs/ext3 modules_install puts ext3.ko in /lib/modules//extrafs/ext3.ko) This was the case only when specifying a trailing slash to M=.. Fixed by removing trailing slash if present so we correctly match dir part of target. Signed-off-by: Sam Ravnborg Cc: Eric Sandeen commit 01f84ca9b7e5f8f0358469723ce83c6775c35479 Author: Robert P. J. Day Date: Mon Dec 31 14:58:38 2007 +0100 A few corrections to include/linux/Kbuild auxvec.h, i2c-dev.h and vt.h *should* be unifdef'ed i2o-dev.h does not need unifdef'ing Signed-off-by: Robert P. J. Day Cc: David Woodhouse Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg commit 60761cef5c2b4037b13059823f74e06d96d3afe9 Author: Adrian Bunk Date: Sun Nov 11 07:48:25 2007 +0100 Remove references to "make dep" "make dep" is no longer required in kernel 2.6, but was still mentioned in some places. Signed-off-by: Adrian Bunk Signed-off-by: Sam Ravnborg commit fa16036fece0d343ac4b61e33599696468f2d881 Author: Mike Frysinger Date: Sat Nov 10 09:32:20 2007 -0500 kbuild: fixup genksyms usage/getopt The usage does not mention the "-a,--arch" or "-T,--dump-types" options, so add them. The calls to getopt() seem to mention options that no longer exist (some "k" and "p" thingy) but omits the "h" option which means using '-h' actually triggers the error code path, so update those as well. Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg commit 77207c59d921afec1e3c18f62992554a031d3691 Author: Sam Ravnborg Date: Mon Dec 31 14:26:12 2007 +0100 kbuild: ignore *.order files Introducing the new modules.order patch created a number of additional files. Teach git to ignore them. Signed-off-by: Sam Ravnborg Cc: Tejun Heo commit 28fc178f1351b2f7090a4e81cab28be4ccf2d187 Author: Sam Ravnborg Date: Mon Dec 31 14:22:55 2007 +0100 kbuild: fix buglet in gcc-version.sh Greg Schafer reported: ==== $make mrproper scripts/gcc-version.sh: [[: command not found This is on a very old host with an ancient bash as /bin/sh. But I have CONFIG_SHELL set and pointing to a modern bash. Something is wrong. This doesn't happen with 2.6.23 ==== Fixed using a more common string equality test. Signed-off-by: Sam Ravnborg Cc: Greg Schafer Cc: Jesper Juhl commit 7ee739dcddcb3f7af6158301d1c2c69ad7c57670 Author: Robert P. J. Day Date: Thu Nov 29 10:46:38 2007 -0500 Kbuild: Clarify the rpm-related make packaging targets Signed-off-by: Robert P. J. Day Signed-off-by: Sam Ravnborg commit d92850c1c02777f748c749a6f69e9bf89b52925c Author: Aron Griffis Date: Wed Nov 28 16:55:44 2007 -0500 kbuild: support mercurial in setlocalversion This represents mercurial changesets similarly to git. For untagged revisions, append the changeset id. If there are uncommitted changes, append -dirty. For example, -hgc60016ba6237-dirty Signed-off-by: Aron Griffis Signed-off-by: Sam Ravnborg commit 2d94c7f78b33865e6a7edc39ba6ada1aad85fbd0 Author: Andres Salomon Date: Mon Dec 17 01:34:58 2007 -0500 kconfig: use getopt() in conf.c for handling command line arguments Switch from doing our own parsing of command line arguments to using getopt(3) to do it. Aside from simplifying things, this allows us to specify multiple arguments; the old code could only accept two arguments (input_mode and kconfig name). Note some subtle changes: - The argument '-?' is no longer supported. - '-h' is not treated as an error, so output goes to stdout, and we exit with '0'. - There is no compatibility checking amongst arguments; the last option will simply override earlier options. For example, 'conf -n -y foo' is perfectly valid now (input_mode will be set_yes). Previously, that would have been an error ("can't find file -y"). Signed-off-by: Andres Salomon Signed-off-by: Sam Ravnborg Cc: Roman Zippel commit 260f0accd6f64691b36980c4ad234693d1ab3cde Author: Andi Kleen Date: Thu Nov 22 03:43:10 2007 +0100 kbuild: fix a buffer overflow in modpost When passing an file name > 1k the stack could be overflowed. Not really a security issue, but still better plugged. Signed-off-by: Andi Kleen Signed-off-by: Sam Ravnborg commit 459654f380cfe7a5abdb5f93d50e77cc263457d8 Author: Andi Kleen Date: Thu Nov 22 03:43:09 2007 +0100 kbuild: fix format string warnings in modpost Fix wrong format strings in modpost exposed by the previous patch. Including one missing argument -- some random data was printed instead. Signed-off-by: Andi Kleen Signed-off-by: Sam Ravnborg commit 1d06439a21b80746e5e671eb0bc6aaf37ef50220 Author: Andi Kleen Date: Thu Nov 22 03:43:08 2007 +0100 kbuild: declare the modpost error functions as printf like This way gcc can warn for wrong format strings Signed-off-by: Andi Kleen Signed-off-by: Sam Ravnborg commit cee6bde22f6b21a9a75f49641f64ced5f71fa249 Author: Sam Ravnborg Date: Sun Dec 9 20:11:15 2007 +0100 kconfig: if ncurses-devel is missing then say so With this patch when ncurses-devel (or whatever it is named) is missing trying to run menuconfig will result in this: $ make menuconfig HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/kxgettext.o *** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1 make: *** [menuconfig] Error 2 Much better than before where we just listed some build errors. The other *config targets will work indepenednt on ncurses being present or not. Includes improvements suggested by: Frans Pop Signed-off-by: Sam Ravnborg Cc: Frans Pop commit 91916216a5acf1e7d5534862e3634e5c961bfdc7 Author: Tejun Heo Date: Fri Dec 7 21:04:30 2007 +0900 kbuild: implement modules.order When multiple built-in modules (especially drivers) provide the same capability, they're prioritized by link order specified by the order listed in Makefile. This implicit ordering is lost for loadable modules. When driver modules are loaded by udev, what comes first in modules.alias file is selected. However, the order in this file is indeterministic (depends on filesystem listing order of installed modules). This causes confusion. The solution is two-parted. This patch updates kbuild such that it generates and installs modules.order which contains the name of modules ordered according to Makefile. The second part is update to depmod such that it generates output files according to this file. Note that both obj-y and obj-m subdirs can contain modules and ordering information between those two are lost from beginning. Currently obj-y subdirs are put before obj-m subdirs. Sam Ravnborg cleaned up Makefile modifications and suggested using awk to remove duplicate lines from modules.order instead of using separate C program. Signed-off-by: Tejun Heo Cc: Bill Nottingham Cc: Rusty Russell Cc: Greg Kroah-Hartman Cc: Kay Sievers Signed-off-by: Sam Ravnborg commit 359f44c886bfe65e042e1a7404e0df38a1b5c006 Author: Vegard Nossum Date: Fri Oct 26 13:31:13 2007 +0200 aic7(3*x): fix firmware build This patch adds the proper $(obj) and $(src) prefixes to dependency rules in aic7xxx makefile. Without this patch, there is a remote possibility that parallel make with a different output directory can fail. Also changed the deprecated EXTRA_CFLAGS construct to ccflags-y syntax. Fixed up patch to survive "make drivers/scsi/ -j" with BUILD_FIRMWARE enable. /Sam Signed-off-by: Vegard Nossum Signed-off-by: Sam Ravnborg Acked-by: Hannes Reinecke Cc: linux-scsi@vger.kernel.org commit 6b4ce1155813e63ebc5ddc6dfd351a7e853b3ba4 Author: Johannes Berg Date: Thu Nov 8 12:59:13 2007 +0100 convert drivers/base/power/Makefile to ccflags This patch converts drivers/base/power/Makefile to use ccflags instead of EXTRA_CFLAGS. Signed-off-by: Johannes Berg Signed-off-by: Sam Ravnborg commit 850eac6daf749a277e556af71e65bc505e3e8cfd Author: Geert Uytterhoeven Date: Mon Nov 5 11:51:44 2007 +0100 kbuild: Add missing srctree prefix for includecheck and versioncheck Add missing $(srctree)/ prefix for scripts used by the includecheck and versioncheck make targets Signed-off-by: Geert Uytterhoeven Signed-off-by: Sam Ravnborg commit 80af13aa3ac980c4ea2ddc4b1cab6c7b50f25c9c Author: Sam Ravnborg Date: Wed Nov 14 21:34:55 2007 +0100 kbuild: document versioncheck in make help Signed-off-by: Sam Ravnborg commit 97613a58297a551ccd32cf830fea67766dc51e56 Author: Randy Dunlap Date: Sun Nov 4 12:01:55 2007 -0800 kbuild: add 'includecheck' help text Add 'includecheck' to the Static analyzers help list. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg commit 941483530e17ec7d9e6285b58acd00e5832c3910 Author: Johannes Berg Date: Wed Oct 24 15:08:48 2007 -0700 kernel-doc: new P directive for DOC: sections The !P directive includes the contents of a DOC: section given by title, e.g. !Pfilename Title of the section Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg commit efac333f4ce368f75d9adc29656ac317420f786c Author: Johannes Berg Date: Wed Oct 24 15:08:48 2007 -0700 kernel-doc: use no-doc option When asked by a template to include all functions from a file, it will also include DOC: sections wreaking havoc in the generated docbook file. This patch makes it use the new -no-doc-sections flag for kernel-doc to avoid this. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg commit bda4f0ec7979093f9bda1d98618f3366315dd744 Author: Johannes Berg Date: Wed Oct 24 15:08:48 2007 -0700 kernel-doc: process functions, not DOC: This flag is necessary for the next patch for docproc to output only the functions and not DOC: sections when a function list is requested. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg commit c9bbc80b310315ef7a6f9380046dab2742337109 Author: Johannes Berg Date: Wed Oct 24 15:08:48 2007 -0700 kernel-doc: single DOC: selection Currently, DOC: sections are always output even if only a single function is requested, fix this and also make it possible to just output a single DOC: section by giving its title as the function name to output. Also fixes docbook XML well-formedness for sections with examples. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg commit 75df571aa26d41167d341b3992bbfcbf80d56c62 Author: Johannes Berg Date: Wed Oct 24 15:08:48 2007 -0700 kernel-doc: init kernel version The kernel-doc script triggers a perl warning when invoked without KERNELVERSION in the environment, rather make it use the string "unknown kernel version" instead. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg commit 3a115084632ffcbfa36bdf1e1da22ef3f885efb3 Author: Johannes Berg Date: Wed Oct 24 15:08:48 2007 -0700 kernel-doc: fix xml output mode After Randy's patch fixing the HTML output in DOC: sections (6b5b55f6c404fa730a09a8254eb19f5a038afcc2) the same bug remained in XML mode, this fixes it. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg Signed-off-by: Andrew Morton --- .gitignore | 1 Documentation/kbuild/kconfig-language.txt | 54 + Makefile | 17 arch/arm/boot/Makefile | 4 arch/arm/mach-imx/Makefile | 3 arch/arm/mach-netx/Makefile | 3 arch/avr32/boot/images/Makefile | 4 arch/blackfin/boot/Makefile | 4 arch/cris/arch-v32/boot/compressed/Makefile | 2 arch/frv/boot/Makefile | 8 arch/frv/kernel/gdb-stub.c | 2 arch/mips/tx4927/common/Makefile | 4 arch/mips/tx4938/common/Makefile | 4 arch/mips/tx4938/toshiba_rbtx4938/Makefile | 4 arch/ppc/boot/images/Makefile | 4 arch/sh/boot/Makefile | 4 arch/sh64/kernel/Makefile | 4 arch/sh64/lib/Makefile | 4 arch/sh64/mach-cayman/Makefile | 4 arch/sh64/mm/Makefile | 4 arch/xtensa/mm/Makefile | 4 arch/xtensa/platform-iss/Makefile | 5 drivers/base/power/Makefile | 8 drivers/infiniband/hw/cxgb3/Makefile | 3 drivers/scsi/aic7xxx/Makefile | 45 - fs/smbfs/Makefile | 20 include/linux/Kbuild | 8 scripts/Makefile | 1 scripts/Makefile.build | 17 scripts/Makefile.lib | 6 scripts/Makefile.modinst | 2 scripts/basic/docproc.c | 44 + scripts/gcc-version.sh | 5 scripts/genksyms/genksyms.c | 10 scripts/kconfig/Makefile | 39 scripts/kconfig/POTFILES.in | 7 scripts/kconfig/conf.c | 64 - scripts/kconfig/confdata.c | 16 scripts/kconfig/expr.c | 6 scripts/kconfig/expr.h | 8 scripts/kconfig/gconf.c | 16 scripts/kconfig/lex.zconf.c_shipped | 5 scripts/kconfig/lxdialog/check-lxdialog.sh | 16 scripts/kconfig/lxdialog/checklist.c | 4 scripts/kconfig/lxdialog/dialog.h | 11 scripts/kconfig/lxdialog/inputbox.c | 4 scripts/kconfig/lxdialog/menubox.c | 6 scripts/kconfig/lxdialog/textbox.c | 2 scripts/kconfig/lxdialog/util.c | 32 scripts/kconfig/lxdialog/yesno.c | 4 scripts/kconfig/mconf.c | 112 -- scripts/kconfig/menu.c | 4 scripts/kconfig/qconf.cc | 93 +- scripts/kconfig/symbol.c | 6 scripts/kconfig/zconf.l | 5 scripts/kernel-doc | 85 +- scripts/mkmakefile | 10 scripts/mkuboot.sh | 19 scripts/mkubootimg/Makefile | 6 scripts/mkubootimg/crc32.c | 196 ++++ scripts/mkubootimg/mkimage.c | 727 ++++++++++++++++++ scripts/mkubootimg/uimage.h | 161 +++ scripts/mod/modpost.c | 477 +++++------ scripts/package/Makefile | 5 scripts/patch-kernel | 22 scripts/setlocalversion | 29 66 files changed, 1841 insertions(+), 672 deletions(-) diff -puN .gitignore~git-kbuild .gitignore --- a/.gitignore~git-kbuild +++ a/.gitignore @@ -17,6 +17,7 @@ *.i *.lst *.symtypes +*.order # # Top-level generic files diff -puN Documentation/kbuild/kconfig-language.txt~git-kbuild Documentation/kbuild/kconfig-language.txt --- a/Documentation/kbuild/kconfig-language.txt~git-kbuild +++ a/Documentation/kbuild/kconfig-language.txt @@ -24,7 +24,7 @@ visible if its parent entry is also visi Menu entries ------------ -Most entries define a config option, all other entries help to organize +Most entries define a config option; all other entries help to organize them. A single configuration option is defined like this: config MODVERSIONS @@ -50,7 +50,7 @@ applicable everywhere (see syntax). - type definition: "bool"/"tristate"/"string"/"hex"/"int" Every config option must have a type. There are only two basic types: - tristate and string, the other types are based on these two. The type + tristate and string; the other types are based on these two. The type definition optionally accepts an input prompt, so these two examples are equivalent: @@ -108,7 +108,7 @@ applicable everywhere (see syntax). equal to 'y' without visiting the dependencies. So abusing select you are able to select a symbol FOO even if FOO depends on BAR that is not set. In general use select only for - non-visible symbols (no promts anywhere) and for symbols with + non-visible symbols (no prompts anywhere) and for symbols with no dependencies. That will limit the usefulness but on the other hand avoid the illegal configurations all over. kconfig should one day warn about such things. @@ -162,9 +162,9 @@ An expression can have a value of 'n', ' respectively for calculations). A menu entry becomes visible when it's expression evaluates to 'm' or 'y'. -There are two types of symbols: constant and nonconstant symbols. -Nonconstant symbols are the most common ones and are defined with the -'config' statement. Nonconstant symbols consist entirely of alphanumeric +There are two types of symbols: constant and non-constant symbols. +Non-constant symbols are the most common ones and are defined with the +'config' statement. Non-constant symbols consist entirely of alphanumeric characters or underscores. Constant symbols are only part of expressions. Constant symbols are always surrounded by single or double quotes. Within the quote, any @@ -301,3 +301,45 @@ mainmenu: This sets the config program's title bar if the config program chooses to use it. + + +Kconfig hints +------------- +This is a collection of Kconfig tips, most of which aren't obvious at +first glance and most of which have become idioms in several Kconfig +files. + +Build as module only +~~~~~~~~~~~~~~~~~~~~ +To restrict a component build to module-only, qualify its config symbol +with "depends on m". E.g.: + +config FOO + depends on BAR && m + +limits FOO to module (=m) or disabled (=n). + + +Build limited by a third config symbol which may be =y or =m +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +A common idiom that we see (and sometimes have problems with) is this: + +When option C in B (module or subsystem) uses interfaces from A (module +or subsystem), and both A and B are tristate (could be =y or =m if they +were independent of each other, but they aren't), then we need to limit +C such that it cannot be built statically if A is built as a loadable +module. (C already depends on B, so there is no dependency issue to +take care of here.) + +If A is linked statically into the kernel image, C can be built +statically or as loadable module(s). However, if A is built as loadable +module(s), then C must be restricted to loadable module(s) also. This +can be expressed in kconfig language as: + +config C + depends on A = y || A = B + +or for real examples, use this command in a kernel tree: + +$ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig + diff -puN Makefile~git-kbuild Makefile --- a/Makefile~git-kbuild +++ a/Makefile @@ -1021,9 +1021,14 @@ ifdef CONFIG_MODULES all: modules # Build modules +# +# A module can be listed more than once in obj-m resulting in +# duplicate lines in modules.order files. Those are removed +# using awk while concatenating to the final file. PHONY += modules modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) + $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order @echo ' Building modules, stage 2.'; $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost @@ -1051,6 +1056,7 @@ _modinst_: rm -f $(MODLIB)/build ; \ ln -s $(objtree) $(MODLIB)/build ; \ fi + @cp -f $(objtree)/modules.order $(MODLIB)/ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst # This depmod is only for convenience to give the initial @@ -1110,7 +1116,7 @@ clean: archclean $(clean-dirs) @find . $(RCS_FIND_IGNORE) \ \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ - -o -name '*.symtypes' \) \ + -o -name '*.symtypes' -o -name 'modules.order' \) \ -type f -print | xargs rm -f # mrproper - Delete all generated files, including .config @@ -1175,7 +1181,7 @@ help: @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[ois] - Build specified target only' @echo ' dir/file.ko - Build module including final link' - @echo ' rpm - Build a kernel as an RPM package' + @echo ' prepare - Set up for building external modules' @echo ' tags/TAGS - Generate tags file for editors' @echo ' cscope - Generate cscope index' @echo ' kernelrelease - Output the release version string' @@ -1188,6 +1194,8 @@ help: @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs' @echo ' namespacecheck - Name space analysis on compiled kernel' + @echo ' versioncheck - Sanity check on version.h usage' + @echo ' includecheck - Check for duplicate included header files' @echo ' export_report - List the usages of all exported symbols' @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ echo ' headers_check - Sanity check on exported headers'; \ @@ -1371,6 +1379,7 @@ define xtags if $1 --version 2>&1 | grep -iq exuberant; then \ $(all-sources) | xargs $1 -a \ -I __initdata,__exitdata,__acquires,__releases \ + -I __read_mostly,____cacheline_aligned,____cacheline_aligned_in_smp,____cacheline_internodealigned_in_smp \ -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ --extra=+f --c-kinds=+px \ --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'; \ @@ -1428,12 +1437,12 @@ tags: FORCE includecheck: find * $(RCS_FIND_IGNORE) \ -name '*.[hcS]' -type f -print | sort \ - | xargs $(PERL) -w scripts/checkincludes.pl + | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl versioncheck: find * $(RCS_FIND_IGNORE) \ -name '*.[hcS]' -type f -print | sort \ - | xargs $(PERL) -w scripts/checkversion.pl + | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl namespacecheck: $(PERL) $(srctree)/scripts/namespace.pl diff -puN arch/arm/boot/Makefile~git-kbuild arch/arm/boot/Makefile --- a/arch/arm/boot/Makefile~git-kbuild +++ a/arch/arm/boot/Makefile @@ -11,7 +11,7 @@ # Copyright (C) 1995-2002 Russell King # -MKIMAGE := $(srctree)/scripts/mkuboot.sh +MKIMAGE := $(objtree)/scripts/mkubootimg/mkubootimg ifneq ($(MACHINE),) include $(srctree)/$(MACHINE)/Makefile.boot @@ -60,7 +60,7 @@ $(obj)/zImage: $(obj)/compressed/vmlinux endif quiet_cmd_uimage = UIMAGE $@ - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A arm -O linux -T kernel \ + cmd_uimage = $(MKIMAGE) -A arm -O linux -T kernel \ -C none -a $(ZRELADDR) -e $(ZRELADDR) \ -n 'Linux-$(KERNELRELEASE)' -d $< $@ diff -puN arch/arm/mach-imx/Makefile~git-kbuild arch/arm/mach-imx/Makefile --- a/arch/arm/mach-imx/Makefile~git-kbuild +++ a/arch/arm/mach-imx/Makefile @@ -1,9 +1,6 @@ # # Makefile for the linux kernel. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). # Object file lists. diff -puN arch/arm/mach-netx/Makefile~git-kbuild arch/arm/mach-netx/Makefile --- a/arch/arm/mach-netx/Makefile~git-kbuild +++ a/arch/arm/mach-netx/Makefile @@ -1,9 +1,6 @@ # # Makefile for the linux kernel. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). # Object file lists. diff -puN arch/avr32/boot/images/Makefile~git-kbuild arch/avr32/boot/images/Makefile --- a/arch/avr32/boot/images/Makefile~git-kbuild +++ a/arch/avr32/boot/images/Makefile @@ -6,7 +6,7 @@ # for more details. # -MKIMAGE := $(srctree)/scripts/mkuboot.sh +MKIMAGE := $(objtree)/scripts/mkubootimg/mkubootimg extra-y := vmlinux.bin vmlinux.gz @@ -18,7 +18,7 @@ $(obj)/vmlinux.gz: $(obj)/vmlinux.bin FO $(call if_changed,gzip) quiet_cmd_uimage = UIMAGE $@ - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A avr32 -O linux -T kernel \ + cmd_uimage = $(MKIMAGE) -A avr32 -O linux -T kernel \ -C gzip -a $(CONFIG_LOAD_ADDRESS) -e $(CONFIG_ENTRY_ADDRESS) \ -n 'Linux-$(KERNELRELEASE)' -d $< $@ diff -puN arch/blackfin/boot/Makefile~git-kbuild arch/blackfin/boot/Makefile --- a/arch/blackfin/boot/Makefile~git-kbuild +++ a/arch/blackfin/boot/Makefile @@ -6,13 +6,13 @@ # for more details. # -MKIMAGE := $(srctree)/scripts/mkuboot.sh +MKIMAGE := $(objtree)/scripts/mkubootimg/mkubootimg targets := vmImage extra-y += vmlinux.bin vmlinux.gz quiet_cmd_uimage = UIMAGE $@ - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(ARCH) -O linux -T kernel \ + cmd_uimage = $(MKIMAGE) -A $(ARCH) -O linux -T kernel \ -C gzip -n 'Linux-$(KERNELRELEASE)' -a $(CONFIG_BOOT_LOAD) \ -e $(shell $(NM) vmlinux | awk '$$NF == "__start" {print $$1}') \ -d $< $@ diff -puN arch/cris/arch-v32/boot/compressed/Makefile~git-kbuild arch/cris/arch-v32/boot/compressed/Makefile --- a/arch/cris/arch-v32/boot/compressed/Makefile~git-kbuild +++ a/arch/cris/arch-v32/boot/compressed/Makefile @@ -7,7 +7,7 @@ target = $(target_compressed_dir) src = $(src_compressed_dir) -CC = gcc-cris -mlinux -march=v32 -I $(TOPDIR)/include +CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE) CFLAGS = -O2 LD = gcc-cris -mlinux -march=v32 -nostdlib OBJCOPY = objcopy-cris diff -puN arch/frv/boot/Makefile~git-kbuild arch/frv/boot/Makefile --- a/arch/frv/boot/Makefile~git-kbuild +++ a/arch/frv/boot/Makefile @@ -10,7 +10,7 @@ targets := Image zImage bootpImage -SYSTEM =$(TOPDIR)/$(LINUX) +SYSTEM =$(LINUX) ZTEXTADDR = 0x02080000 PARAMS_PHYS = 0x0207c000 @@ -45,7 +45,7 @@ zImage: $(CONFIGURE) compressed/$(LINUX) bootpImage: bootp/bootp $(OBJCOPY) -O binary -R .note -R .comment -S bootp/bootp $@ -compressed/$(LINUX): $(TOPDIR)/$(LINUX) dep +compressed/$(LINUX): $(LINUX) dep @$(MAKE) -C compressed $(LINUX) bootp/bootp: zImage initrd @@ -59,10 +59,10 @@ initrd: # installation # install: $(CONFIGURE) Image - sh ./install.sh $(KERNELRELEASE) Image $(TOPDIR)/System.map "$(INSTALL_PATH)" + sh ./install.sh $(KERNELRELEASE) Image System.map "$(INSTALL_PATH)" zinstall: $(CONFIGURE) zImage - sh ./install.sh $(KERNELRELEASE) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)" + sh ./install.sh $(KERNELRELEASE) zImage System.map "$(INSTALL_PATH)" # # miscellany diff -puN arch/frv/kernel/gdb-stub.c~git-kbuild arch/frv/kernel/gdb-stub.c --- a/arch/frv/kernel/gdb-stub.c~git-kbuild +++ a/arch/frv/kernel/gdb-stub.c @@ -87,7 +87,7 @@ * Example: * $ cd ~/linux * $ make menuconfig - * $ make dep; make vmlinux + * $ make vmlinux * * Step 3: * Download the kernel to the remote target and start diff -puN arch/mips/tx4927/common/Makefile~git-kbuild arch/mips/tx4927/common/Makefile --- a/arch/mips/tx4927/common/Makefile~git-kbuild +++ a/arch/mips/tx4927/common/Makefile @@ -1,10 +1,6 @@ # # Makefile for common code for Toshiba TX4927 based systems # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y += tx4927_prom.o tx4927_setup.o tx4927_irq.o diff -puN arch/mips/tx4938/common/Makefile~git-kbuild arch/mips/tx4938/common/Makefile --- a/arch/mips/tx4938/common/Makefile~git-kbuild +++ a/arch/mips/tx4938/common/Makefile @@ -1,10 +1,6 @@ # # Makefile for common code for Toshiba TX4927 based systems # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y += prom.o setup.o irq.o obj-$(CONFIG_KGDB) += dbgio.o diff -puN arch/mips/tx4938/toshiba_rbtx4938/Makefile~git-kbuild arch/mips/tx4938/toshiba_rbtx4938/Makefile --- a/arch/mips/tx4938/toshiba_rbtx4938/Makefile~git-kbuild +++ a/arch/mips/tx4938/toshiba_rbtx4938/Makefile @@ -1,10 +1,6 @@ # # Makefile for common code for Toshiba TX4927 based systems # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y += prom.o setup.o irq.o spi_eeprom.o diff -puN arch/ppc/boot/images/Makefile~git-kbuild arch/ppc/boot/images/Makefile --- a/arch/ppc/boot/images/Makefile~git-kbuild +++ a/arch/ppc/boot/images/Makefile @@ -2,7 +2,7 @@ # This dir holds all of the images for PPC machines. # Tom Rini January 2001 -MKIMAGE := $(srctree)/scripts/mkuboot.sh +MKIMAGE := $(objtree)/scripts/mkubootimg/mkubootimg extra-y := vmlinux.bin vmlinux.gz @@ -19,7 +19,7 @@ $(obj)/vmlinux.gz: $(obj)/vmlinux.bin FO $(call if_changed,mygzip) quiet_cmd_uimage = UIMAGE $@ - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A ppc -O linux -T kernel \ + cmd_uimage = $(MKIMAGE) -A ppc -O linux -T kernel \ -C gzip -a 00000000 -e 00000000 -n 'Linux-$(KERNELRELEASE)' \ -d $< $@ diff -puN arch/sh/boot/Makefile~git-kbuild arch/sh/boot/Makefile --- a/arch/sh/boot/Makefile~git-kbuild +++ a/arch/sh/boot/Makefile @@ -8,7 +8,7 @@ # Copyright (C) 1999 Stuart Menefy # -MKIMAGE := $(srctree)/scripts/mkuboot.sh +MKIMAGE := $(objtree)/scripts/mkubootimg/mkubootimg # # Assign safe dummy values if these variables are not defined, @@ -38,7 +38,7 @@ KERNEL_LOAD := $(shell /bin/bash -c 'pri $(CONFIG_ZERO_PAGE_OFFSET)+0x1000]') quiet_cmd_uimage = UIMAGE $@ - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sh -O linux -T kernel \ + cmd_uimage = $(MKIMAGE) -A sh -O linux -T kernel \ -C none -a $(KERNEL_LOAD) -e $(KERNEL_LOAD) \ -n 'Linux-$(KERNELRELEASE)' -d $< $@ diff -puN arch/sh64/kernel/Makefile~git-kbuild arch/sh64/kernel/Makefile --- a/arch/sh64/kernel/Makefile~git-kbuild +++ a/arch/sh64/kernel/Makefile @@ -8,10 +8,6 @@ # # Makefile for the Linux sh64 kernel. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# extra-y := head.o init_task.o vmlinux.lds diff -puN arch/sh64/lib/Makefile~git-kbuild arch/sh64/lib/Makefile --- a/arch/sh64/lib/Makefile~git-kbuild +++ a/arch/sh64/lib/Makefile @@ -8,10 +8,6 @@ # # Makefile for the SH-5 specific library files.. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# # Panic should really be compiled as PIC lib-y := udelay.o c-checksum.o dbg.o io.o panic.o memcpy.o copy_user_memcpy.o \ diff -puN arch/sh64/mach-cayman/Makefile~git-kbuild arch/sh64/mach-cayman/Makefile --- a/arch/sh64/mach-cayman/Makefile~git-kbuild +++ a/arch/sh64/mach-cayman/Makefile @@ -1,10 +1,6 @@ # # Makefile for the Hitachi Cayman specific parts of the kernel # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y := setup.o irq.o iomap.o obj-$(CONFIG_HEARTBEAT) += led.o diff -puN arch/sh64/mm/Makefile~git-kbuild arch/sh64/mm/Makefile --- a/arch/sh64/mm/Makefile~git-kbuild +++ a/arch/sh64/mm/Makefile @@ -8,10 +8,6 @@ # # Makefile for the sh64-specific parts of the Linux memory manager. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y := cache.o consistent.o extable.o fault.o init.o ioremap.o \ tlbmiss.o tlb.o diff -puN arch/xtensa/mm/Makefile~git-kbuild arch/xtensa/mm/Makefile --- a/arch/xtensa/mm/Makefile~git-kbuild +++ a/arch/xtensa/mm/Makefile @@ -1,9 +1,5 @@ # # Makefile for the Linux/Xtensa-specific parts of the memory manager. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y := init.o fault.o tlb.o misc.o cache.o diff -puN arch/xtensa/platform-iss/Makefile~git-kbuild arch/xtensa/platform-iss/Makefile --- a/arch/xtensa/platform-iss/Makefile~git-kbuild +++ a/arch/xtensa/platform-iss/Makefile @@ -3,11 +3,6 @@ # Makefile for the Xtensa Instruction Set Simulator (ISS) # "prom monitor" library routines under Linux. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are in the main makefile... obj-y = io.o console.o setup.o network.o diff -puN drivers/base/power/Makefile~git-kbuild drivers/base/power/Makefile --- a/drivers/base/power/Makefile~git-kbuild +++ a/drivers/base/power/Makefile @@ -2,9 +2,5 @@ obj-$(CONFIG_PM) += sysfs.o obj-$(CONFIG_PM_SLEEP) += main.o obj-$(CONFIG_PM_TRACE_RTC) += trace.o -ifeq ($(CONFIG_DEBUG_DRIVER),y) -EXTRA_CFLAGS += -DDEBUG -endif -ifeq ($(CONFIG_PM_VERBOSE),y) -EXTRA_CFLAGS += -DDEBUG -endif +ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +ccflags-$(CONFIG_PM_VERBOSE) += -DDEBUG diff -puN drivers/infiniband/hw/cxgb3/Makefile~git-kbuild drivers/infiniband/hw/cxgb3/Makefile --- a/drivers/infiniband/hw/cxgb3/Makefile~git-kbuild +++ a/drivers/infiniband/hw/cxgb3/Makefile @@ -1,5 +1,4 @@ -EXTRA_CFLAGS += -I$(TOPDIR)/drivers/net/cxgb3 \ - -I$(TOPDIR)/drivers/infiniband/hw/cxgb3/core +EXTRA_CFLAGS += -Idrivers/net/cxgb3 obj-$(CONFIG_INFINIBAND_CXGB3) += iw_cxgb3.o diff -puN drivers/scsi/aic7xxx/Makefile~git-kbuild drivers/scsi/aic7xxx/Makefile --- a/drivers/scsi/aic7xxx/Makefile~git-kbuild +++ a/drivers/scsi/aic7xxx/Makefile @@ -33,11 +33,10 @@ aic79xx-y += aic79xx_osm.o \ aic79xx_proc.o \ aic79xx_osm_pci.o -EXTRA_CFLAGS += -Idrivers/scsi +ccflags-y += -Idrivers/scsi ifdef WARNINGS_BECOME_ERRORS -EXTRA_CFLAGS += -Werror +ccflags-y += -Werror endif -#EXTRA_CFLAGS += -g # Files generated that shall be removed upon make clean clean-files := aic7xxx_seq.h aic7xxx_reg.h aic7xxx_reg_print.c @@ -46,53 +45,45 @@ clean-files += aic79xx_seq.h aic79xx_reg # Dependencies for generated files need to be listed explicitly $(obj)/aic7xxx_core.o: $(obj)/aic7xxx_seq.h +$(obj)/aic7xxx_core.o: $(obj)/aic7xxx_reg.h $(obj)/aic79xx_core.o: $(obj)/aic79xx_seq.h -$(obj)/aic79xx_reg_print.c: $(src)/aic79xx_reg_print.c_shipped -$(obj)/aic7xxx_reg_print.c: $(src)/aic7xxx_reg_print.c_shipped +$(obj)/aic79xx_core.o: $(obj)/aic79xx_reg.h -$(addprefix $(obj)/,$(aic7xxx-y)): $(obj)/aic7xxx_reg.h -$(addprefix $(obj)/,$(aic79xx-y)): $(obj)/aic79xx_reg.h +$(addprefix $(obj)/,$(aic7xxx-y)): $(obj)/aic7xxx_seq.h +$(addprefix $(obj)/,$(aic79xx-y)): $(obj)/aic79xx_seq.h -aic7xxx-gen-$(CONFIG_AIC7XXX_BUILD_FIRMWARE) := $(obj)/aic7xxx_seq.h \ - $(obj)/aic7xxx_reg.h +aic7xxx-gen-$(CONFIG_AIC7XXX_BUILD_FIRMWARE) := $(obj)/aic7xxx_reg.h aic7xxx-gen-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) += $(obj)/aic7xxx_reg_print.c aicasm-7xxx-opts-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) := \ -p $(obj)/aic7xxx_reg_print.c -i aic7xxx_osm.h ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y) -# Create a dependency chain in generated files -# to avoid concurrent invocations of the single -# rule that builds them all. -aic7xxx_seq.h: aic7xxx_reg.h -ifeq ($(CONFIG_AIC7XXX_REG_PRETTY_PRINT),y) -aic7xxx_reg.h: aic7xxx_reg_print.c -endif -$(aic7xxx-gen-y): $(src)/aic7xxx.seq $(src)/aic7xxx.reg $(obj)/aicasm/aicasm +$(obj)/aic7xxx_seq.h: $(src)/aic7xxx.seq $(src)/aic7xxx.reg $(obj)/aicasm/aicasm $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic7xxx_reg.h \ $(aicasm-7xxx-opts-y) -o $(obj)/aic7xxx_seq.h \ $(src)/aic7xxx.seq + +$(aic7xxx-gen-y): $(obj)/aic7xxx_seq.h +else +$(obj)/aic7xxx_reg_print.c: $(src)/aic7xxx_reg_print.c_shipped endif -aic79xx-gen-$(CONFIG_AIC79XX_BUILD_FIRMWARE) := $(obj)/aic79xx_seq.h \ - $(obj)/aic79xx_reg.h +aic79xx-gen-$(CONFIG_AIC79XX_BUILD_FIRMWARE) := $(obj)/aic79xx_reg.h aic79xx-gen-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) += $(obj)/aic79xx_reg_print.c aicasm-79xx-opts-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) := \ -p $(obj)/aic79xx_reg_print.c -i aic79xx_osm.h ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y) -# Create a dependency chain in generated files -# to avoid concurrent invocations of the single -# rule that builds them all. -aic79xx_seq.h: aic79xx_reg.h -ifeq ($(CONFIG_AIC79XX_REG_PRETTY_PRINT),y) -aic79xx_reg.h: aic79xx_reg_print.c -endif -$(aic79xx-gen-y): $(src)/aic79xx.seq $(src)/aic79xx.reg $(obj)/aicasm/aicasm +$(obj)/aic79xx_seq.h: $(src)/aic79xx.seq $(src)/aic79xx.reg $(obj)/aicasm/aicasm $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic79xx_reg.h \ $(aicasm-79xx-opts-y) -o $(obj)/aic79xx_seq.h \ $(src)/aic79xx.seq + +$(aic79xx-gen-y): $(obj)/aic79xx_seq.h +else +$(obj)/aic79xx_reg_print.c: $(src)/aic79xx_reg_print.c_shipped endif $(obj)/aicasm/aicasm: $(src)/aicasm/*.[chyl] diff -puN fs/smbfs/Makefile~git-kbuild fs/smbfs/Makefile --- a/fs/smbfs/Makefile~git-kbuild +++ a/fs/smbfs/Makefile @@ -16,23 +16,3 @@ EXTRA_CFLAGS += -DSMBFS_PARANOIA #EXTRA_CFLAGS += -DDEBUG_SMB_TIMESTAMP #EXTRA_CFLAGS += -Werror -# -# Maintainer rules -# - -# getopt.c not included. It is intentionally separate -SRC = proc.c dir.c cache.c sock.c inode.c file.c ioctl.c smbiod.c request.c \ - symlink.c - -proto: - -rm -f proto.h - @echo > proto2.h "/*" - @echo >> proto2.h " * Autogenerated with cproto on: " `date` - @echo >> proto2.h " */" - @echo >> proto2.h "" - @echo >> proto2.h "struct smb_request;" - @echo >> proto2.h "struct sock;" - @echo >> proto2.h "struct statfs;" - @echo >> proto2.h "" - cproto -E "gcc -E" -e -v -I $(TOPDIR)/include -DMAKING_PROTO -D__KERNEL__ $(SRC) >> proto2.h - mv proto2.h proto.h diff -puN include/linux/Kbuild~git-kbuild include/linux/Kbuild --- a/include/linux/Kbuild~git-kbuild +++ a/include/linux/Kbuild @@ -34,7 +34,6 @@ header-y += atmsap.h header-y += atmsvc.h header-y += atm_zatm.h header-y += auto_fs4.h -header-y += auxvec.h header-y += ax25.h header-y += b1lli.h header-y += baycom.h @@ -72,7 +71,7 @@ header-y += gen_stats.h header-y += gigaset_dev.h header-y += hdsmart.h header-y += hysdn_if.h -header-y += i2c-dev.h +header-y += i2o-dev.h header-y += i8k.h header-y += if_arcnet.h header-y += if_bonding.h @@ -158,7 +157,6 @@ header-y += veth.h header-y += video_decoder.h header-y += video_encoder.h header-y += videotext.h -header-y += vt.h header-y += x25.h unifdef-y += acct.h @@ -173,6 +171,7 @@ unifdef-y += atm.h unifdef-y += atm_tcp.h unifdef-y += audit.h unifdef-y += auto_fs.h +unifdef-y += auxvec.h unifdef-y += binfmts.h unifdef-y += capability.h unifdef-y += capi.h @@ -214,7 +213,7 @@ unifdef-y += hdreg.h unifdef-y += hiddev.h unifdef-y += hpet.h unifdef-y += i2c.h -unifdef-y += i2o-dev.h +unifdef-y += i2c-dev.h unifdef-y += icmp.h unifdef-y += icmpv6.h unifdef-y += if_addr.h @@ -349,6 +348,7 @@ unifdef-y += videodev.h unifdef-y += virtio_config.h unifdef-y += virtio_blk.h unifdef-y += virtio_net.h +unifdef-y += vt.h unifdef-y += wait.h unifdef-y += wanrouter.h unifdef-y += watchdog.h diff -puN scripts/Makefile~git-kbuild scripts/Makefile --- a/scripts/Makefile~git-kbuild +++ a/scripts/Makefile @@ -20,6 +20,7 @@ hostprogs-y += unifdef subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-y += mod +subdir-y += mkubootimg # Let clean descend into subdirs subdir- += basic kconfig package diff -puN scripts/Makefile.build~git-kbuild scripts/Makefile.build --- a/scripts/Makefile.build~git-kbuild +++ a/scripts/Makefile.build @@ -83,10 +83,12 @@ ifneq ($(strip $(obj-y) $(obj-m) $(obj-n builtin-target := $(obj)/built-in.o endif +modorder-target := $(obj)/modules.order + # We keep a list of all modules in $(MODVERDIR) __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ - $(if $(KBUILD_MODULES),$(obj-m)) \ + $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \ $(subdir-ym) $(always) @: @@ -276,6 +278,19 @@ targets += $(builtin-target) endif # builtin-target # +# Rule to create modules.order file +# +# Create commands to either record .ko file or cat modules.order from +# a subdirectory +modorder-cmds = \ + $(foreach m, $(modorder), \ + $(if $(filter %/modules.order, $m), \ + cat $m;, echo kernel/$m;)) + +$(modorder-target): $(subdir-ym) FORCE + $(Q)(cat /dev/null; $(modorder-cmds)) > $@ + +# # Rule to compile a set of .o files into one .a file # ifdef lib-target diff -puN scripts/Makefile.lib~git-kbuild scripts/Makefile.lib --- a/scripts/Makefile.lib~git-kbuild +++ a/scripts/Makefile.lib @@ -25,6 +25,11 @@ lib-y := $(filter-out $(obj-y), $(sort $ # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) # and add the directory to the list of dirs to descend into: $(subdir-m) +# Determine modorder. +# Unfortunately, we don't have information about ordering between -y +# and -m subdirs. Just put -y's first. +modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) + __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) subdir-y += $(__subdir-y) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) @@ -64,6 +69,7 @@ real-objs-m := $(foreach m, $(obj-m), $( extra-y := $(addprefix $(obj)/,$(extra-y)) always := $(addprefix $(obj)/,$(always)) targets := $(addprefix $(obj)/,$(targets)) +modorder := $(addprefix $(obj)/,$(modorder)) obj-y := $(addprefix $(obj)/,$(obj-y)) obj-m := $(addprefix $(obj)/,$(obj-m)) lib-y := $(addprefix $(obj)/,$(lib-y)) diff -puN scripts/Makefile.modinst~git-kbuild scripts/Makefile.modinst --- a/scripts/Makefile.modinst~git-kbuild +++ a/scripts/Makefile.modinst @@ -21,7 +21,7 @@ quiet_cmd_modules_install = INSTALL $@ # Modules built outside the kernel source tree go into extra by default INSTALL_MOD_DIR ?= extra -ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(KBUILD_EXTMOD),,$(@D)) +ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) diff -puN scripts/basic/docproc.c~git-kbuild scripts/basic/docproc.c --- a/scripts/basic/docproc.c~git-kbuild +++ a/scripts/basic/docproc.c @@ -30,6 +30,7 @@ * !Ifilename * !Dfilename * !Ffilename + * !Pfilename * */ @@ -57,6 +58,7 @@ FILEONLY *symbolsonly; typedef void FILELINE(char * file, char * line); FILELINE * singlefunctions; FILELINE * entity_system; +FILELINE * docsection; #define MAXLINESZ 2048 #define MAXFILES 250 @@ -65,6 +67,7 @@ FILELINE * entity_system; #define DOCBOOK "-docbook" #define FUNCTION "-function" #define NOFUNCTION "-nofunction" +#define NODOCSECTIONS "-no-doc-sections" char *srctree; @@ -231,13 +234,14 @@ void docfunctions(char * filename, char for (i=0; i <= symfilecnt; i++) symcnt += symfilelist[i].symbolcnt; - vec = malloc((2 + 2 * symcnt + 2) * sizeof(char*)); + vec = malloc((2 + 2 * symcnt + 3) * sizeof(char *)); if (vec == NULL) { perror("docproc: "); exit(1); } vec[idx++] = KERNELDOC; vec[idx++] = DOCBOOK; + vec[idx++] = NODOCSECTIONS; for (i=0; i < symfilecnt; i++) { struct symfile * sym = &symfilelist[i]; for (j=0; j < sym->symbolcnt; j++) { @@ -287,12 +291,36 @@ void singfunc(char * filename, char * li } /* + * Insert specific documentation section from a file. + * Call kernel-doc with the following parameters: + * kernel-doc -docbook -function "doc section" filename + */ +void docsect(char *filename, char *line) +{ + char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */ + char *s; + + for (s = line; *s; s++) + if (*s == '\n') + *s = '\0'; + + vec[0] = KERNELDOC; + vec[1] = DOCBOOK; + vec[2] = FUNCTION; + vec[3] = line; + vec[4] = filename; + vec[5] = NULL; + exec_kernel_doc(vec); +} + +/* * Parse file, calling action specific functions for: * 1) Lines containing !E * 2) Lines containing !I * 3) Lines containing !D * 4) Lines containing !F - * 5) Default lines - lines not matching the above + * 5) Lines containing !P + * 6) Default lines - lines not matching the above */ void parse_file(FILE *infile) { @@ -326,6 +354,15 @@ void parse_file(FILE *infile) s++; singlefunctions(line +2, s); break; + case 'P': + /* filename */ + while (*s && !isspace(*s)) s++; + *s++ = '\0'; + /* DOC: section name */ + while (isspace(*s)) + s++; + docsection(line + 2, s); + break; default: defaultline(line); } @@ -372,6 +409,7 @@ int main(int argc, char *argv[]) externalfunctions = find_export_symbols; symbolsonly = find_export_symbols; singlefunctions = noaction2; + docsection = noaction2; parse_file(infile); /* Rewind to start from beginning of file again */ @@ -381,6 +419,7 @@ int main(int argc, char *argv[]) externalfunctions = extfunc; symbolsonly = printline; singlefunctions = singfunc; + docsection = docsect; parse_file(infile); } @@ -394,6 +433,7 @@ int main(int argc, char *argv[]) externalfunctions = adddep; symbolsonly = adddep; singlefunctions = adddep2; + docsection = adddep2; parse_file(infile); printf("\n"); } diff -puN scripts/gcc-version.sh~git-kbuild scripts/gcc-version.sh --- a/scripts/gcc-version.sh~git-kbuild +++ a/scripts/gcc-version.sh @@ -9,7 +9,10 @@ # gcc-2.95.3, `030301' for gcc-3.3.1, etc. # -if [[ $1 = "-p" ]] ; then with_patchlevel=1; shift; fi +if [ "$1" = "-p" ] ; then + with_patchlevel=1; + shift; +fi compiler="$*" diff -puN scripts/genksyms/genksyms.c~git-kbuild scripts/genksyms/genksyms.c --- a/scripts/genksyms/genksyms.c~git-kbuild +++ a/scripts/genksyms/genksyms.c @@ -440,17 +440,21 @@ void error_with_pos(const char *fmt, ... static void genksyms_usage(void) { - fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n" + fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" #ifdef __GNU_LIBRARY__ + " -a, --arch Select architecture\n" " -d, --debug Increment the debug level (repeatable)\n" " -D, --dump Dump expanded symbol defs (for debugging only)\n" + " -T, --dump-types file Dump expanded types into file (for debugging only)\n" " -w, --warnings Enable warnings\n" " -q, --quiet Disable warnings (default)\n" " -h, --help Print this message\n" " -V, --version Print the release version\n" #else /* __GNU_LIBRARY__ */ + " -a Select architecture\n" " -d Increment the debug level (repeatable)\n" " -D Dump expanded symbol defs (for debugging only)\n" + " -T file Dump expanded types into file (for debugging only)\n" " -w Enable warnings\n" " -q Disable warnings (default)\n" " -h Print this message\n" @@ -477,10 +481,10 @@ int main(int argc, char **argv) {0, 0, 0, 0} }; - while ((o = getopt_long(argc, argv, "a:dwqVDT:k:p:", + while ((o = getopt_long(argc, argv, "a:dwqVDT:h", &long_opts[0], NULL)) != EOF) #else /* __GNU_LIBRARY__ */ - while ((o = getopt(argc, argv, "a:dwqVDT:k:p:")) != EOF) + while ((o = getopt(argc, argv, "a:dwqVDT:h")) != EOF) #endif /* __GNU_LIBRARY__ */ switch (o) { case 'a': diff -puN scripts/kconfig/Makefile~git-kbuild scripts/kconfig/Makefile --- a/scripts/kconfig/Makefile~git-kbuild +++ a/scripts/kconfig/Makefile @@ -24,22 +24,25 @@ oldconfig: $(obj)/conf silentoldconfig: $(obj)/conf $< -s $(Kconfig) -# Create new linux.po file +# Create new linux.pot file # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files # The symlink is used to repair a deficiency in arch/um -update-po-config: $(obj)/kxgettext - xgettext --default-domain=linux \ +update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h + $(Q)echo " GEN config" + $(Q)xgettext --default-domain=linux \ --add-comments --keyword=_ --keyword=N_ \ --from-code=UTF-8 \ --files-from=scripts/kconfig/POTFILES.in \ --output $(obj)/config.pot $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch - (for i in `ls arch/`; \ - do \ - $(obj)/kxgettext arch/$$i/Kconfig; \ - done ) >> $(obj)/config.pot - msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ + $(Q)(for i in `ls arch/`; \ + do \ + echo " GEN $$i"; \ + $(obj)/kxgettext arch/$$i/Kconfig \ + >> $(obj)/config.pot; \ + done ) + $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ --output $(obj)/linux.pot $(Q)rm -f arch/um/Kconfig.arch $(Q)rm -f $(obj)/config.pot @@ -93,12 +96,6 @@ HOST_LOADLIBES = $(shell $(CONFIG_SHEL HOST_EXTRACFLAGS += -DLOCALE -PHONY += $(obj)/dochecklxdialog -$(obj)/dochecklxdialog: - $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) - -always := dochecklxdialog - # =========================================================================== # Shared Makefile for the various kconfig executables: @@ -142,8 +139,17 @@ gconf-objs := gconf.o kconfig_load.o zco endif clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ - .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c + .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h clean-files += mconf qconf gconf +clean-files += config.pot linux.pot + +# Check that we have the required ncurses stuff installed for lxdialog (menuconfig) +PHONY += $(obj)/dochecklxdialog +$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog +$(obj)/dochecklxdialog: + $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES) + +always := dochecklxdialog # Add environment specific flags HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) @@ -248,6 +254,9 @@ $(obj)/%.moc: $(src)/%.h $(obj)/lkc_defs.h: $(src)/lkc_proto.h sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' +# Extract gconf menu items for I18N support +$(obj)/gconf.glade.h: $(obj)/gconf.glade + intltool-extract --type=gettext/glade $(obj)/gconf.glade ### # The following requires flex/bison/gperf diff -puN scripts/kconfig/POTFILES.in~git-kbuild scripts/kconfig/POTFILES.in --- a/scripts/kconfig/POTFILES.in~git-kbuild +++ a/scripts/kconfig/POTFILES.in @@ -1,5 +1,12 @@ +scripts/kconfig/lxdialog/checklist.c +scripts/kconfig/lxdialog/inputbox.c +scripts/kconfig/lxdialog/menubox.c +scripts/kconfig/lxdialog/textbox.c +scripts/kconfig/lxdialog/util.c +scripts/kconfig/lxdialog/yesno.c scripts/kconfig/mconf.c scripts/kconfig/conf.c scripts/kconfig/confdata.c scripts/kconfig/gconf.c +scripts/kconfig/gconf.glade.h scripts/kconfig/qconf.cc diff -puN scripts/kconfig/conf.c~git-kbuild scripts/kconfig/conf.c --- a/scripts/kconfig/conf.c~git-kbuild +++ a/scripts/kconfig/conf.c @@ -4,11 +4,11 @@ */ #include -#include #include +#include #include -#include #include +#include #include #define LKC_DIRECT_LINK @@ -40,7 +40,7 @@ static char nohelp_text[] = N_("Sorry, n static const char *get_help(struct menu *menu) { if (menu_has_help(menu)) - return menu_get_help(menu); + return _(menu_get_help(menu)); else return nohelp_text; } @@ -78,7 +78,7 @@ static int conf_askvalue(struct symbol * tristate val; if (!sym_has_value(sym)) - printf("(NEW) "); + printf(_("(NEW) ")); line[0] = '\n'; line[1] = 0; @@ -160,7 +160,7 @@ static int conf_askvalue(struct symbol * } case set_random: do { - val = (tristate)(random() % 3); + val = (tristate)(rand() % 3); } while (!sym_tristate_within_range(sym, val)); switch (val) { case no: line[0] = 'n'; break; @@ -183,7 +183,7 @@ int conf_string(struct menu *menu) const char *def; while (1) { - printf("%*s%s ", indent - 1, "", menu->prompt->text); + printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); printf("(%s) ", sym->name); def = sym_get_string_value(sym); if (sym_get_string_value(sym)) @@ -216,7 +216,7 @@ static int conf_sym(struct menu *menu) tristate oldval, newval; while (1) { - printf("%*s%s ", indent - 1, "", menu->prompt->text); + printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); if (sym->name) printf("(%s) ", sym->name); type = sym_get_type(sym); @@ -306,7 +306,7 @@ static int conf_choice(struct menu *menu case no: return 1; case mod: - printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); + printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); return 0; case yes: break; @@ -316,7 +316,7 @@ static int conf_choice(struct menu *menu while (1) { int cnt, def; - printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); + printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); def_sym = sym_get_choice_value(sym); cnt = def = 0; line[0] = 0; @@ -324,7 +324,7 @@ static int conf_choice(struct menu *menu if (!menu_is_visible(child)) continue; if (!child->sym) { - printf("%*c %s\n", indent, '*', menu_get_prompt(child)); + printf("%*c %s\n", indent, '*', _(menu_get_prompt(child))); continue; } cnt++; @@ -333,14 +333,14 @@ static int conf_choice(struct menu *menu printf("%*c", indent, '>'); } else printf("%*c", indent, ' '); - printf(" %d. %s", cnt, menu_get_prompt(child)); + printf(" %d. %s", cnt, _(menu_get_prompt(child))); if (child->sym->name) printf(" (%s)", child->sym->name); if (!sym_has_value(child->sym)) - printf(" (NEW)"); + printf(_(" (NEW)")); printf("\n"); } - printf("%*schoice", indent - 1, ""); + printf(_("%*schoice"), indent - 1, ""); if (cnt == 1) { printf("[1]: 1\n"); goto conf_childs; @@ -375,7 +375,7 @@ static int conf_choice(struct menu *menu break; case set_random: if (is_new) - def = (random() % cnt) + 1; + def = (rand() % cnt) + 1; case set_default: case set_yes: case set_mod: @@ -433,7 +433,7 @@ static void conf(struct menu *menu) if (prompt) printf("%*c\n%*c %s\n%*c\n", indent, '*', - indent, '*', prompt, + indent, '*', _(prompt), indent, '*'); default: ; @@ -495,12 +495,16 @@ static void check_conf(struct menu *menu int main(int ac, char **av) { - int i = 1; + int opt; const char *name; struct stat tmpstat; - if (ac > i && av[i][0] == '-') { - switch (av[i++][1]) { + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { + switch (opt) { case 'o': input_mode = ask_new; break; @@ -513,12 +517,7 @@ int main(int ac, char **av) break; case 'D': input_mode = set_default; - defconfig_file = av[i++]; - if (!defconfig_file) { - printf(_("%s: No default config file specified\n"), - av[0]); - exit(1); - } + defconfig_file = optarg; break; case 'n': input_mode = set_no; @@ -531,19 +530,22 @@ int main(int ac, char **av) break; case 'r': input_mode = set_random; - srandom(time(NULL)); + srand(time(NULL)); break; case 'h': - case '?': - fprintf(stderr, "See README for usage info\n"); + printf(_("See README for usage info\n")); exit(0); + break; + default: + fprintf(stderr, _("See README for usage info\n")); + exit(1); } } - name = av[i]; - if (!name) { + if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); exit(1); } + name = av[optind]; conf_parse(name); //zconfdump(stdout); switch (input_mode) { @@ -551,9 +553,9 @@ int main(int ac, char **av) if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { - printf("***\n" + printf(_("***\n" "*** Can't find default configuration \"%s\"!\n" - "***\n", defconfig_file); + "***\n"), defconfig_file); exit(1); } break; diff -puN scripts/kconfig/confdata.c~git-kbuild scripts/kconfig/confdata.c --- a/scripts/kconfig/confdata.c~git-kbuild +++ a/scripts/kconfig/confdata.c @@ -232,8 +232,7 @@ load: sym->type = S_BOOLEAN; } if (sym->flags & def_flags) { - conf_warning("trying to reassign symbol %s", sym->name); - break; + conf_warning("override: reassigning to symbol %s", sym->name); } switch (sym->type) { case S_BOOLEAN: @@ -272,8 +271,7 @@ load: sym->type = S_OTHER; } if (sym->flags & def_flags) { - conf_warning("trying to reassign symbol %s", sym->name); - break; + conf_warning("override: reassigning to symbol %s", sym->name); } if (conf_set_sym_val(sym, def, def_flags, p)) continue; @@ -297,14 +295,12 @@ load: } break; case yes: - if (cs->def[def].tri != no) { - conf_warning("%s creates inconsistent choice state", sym->name); - cs->flags &= ~def_flags; - } else - cs->def[def].val = sym; + if (cs->def[def].tri != no) + conf_warning("override: %s changes choice state", sym->name); + cs->def[def].val = sym; break; } - cs->def[def].tri = E_OR(cs->def[def].tri, sym->def[def].tri); + cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); } } fclose(in); diff -puN scripts/kconfig/expr.c~git-kbuild scripts/kconfig/expr.c --- a/scripts/kconfig/expr.c~git-kbuild +++ a/scripts/kconfig/expr.c @@ -955,14 +955,14 @@ tristate expr_calc_value(struct expr *e) case E_AND: val1 = expr_calc_value(e->left.expr); val2 = expr_calc_value(e->right.expr); - return E_AND(val1, val2); + return EXPR_AND(val1, val2); case E_OR: val1 = expr_calc_value(e->left.expr); val2 = expr_calc_value(e->right.expr); - return E_OR(val1, val2); + return EXPR_OR(val1, val2); case E_NOT: val1 = expr_calc_value(e->left.expr); - return E_NOT(val1); + return EXPR_NOT(val1); case E_EQUAL: sym_calc_value(e->left.sym); sym_calc_value(e->right.sym); diff -puN scripts/kconfig/expr.h~git-kbuild scripts/kconfig/expr.h --- a/scripts/kconfig/expr.h~git-kbuild +++ a/scripts/kconfig/expr.h @@ -25,7 +25,6 @@ struct file { #define FILE_BUSY 0x0001 #define FILE_SCANNED 0x0002 -#define FILE_PRINTED 0x0004 typedef enum tristate { no, mod, yes @@ -45,9 +44,9 @@ struct expr { union expr_data left, right; }; -#define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) -#define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) -#define E_NOT(dep) (2-(dep)) +#define EXPR_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) +#define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) +#define EXPR_NOT(dep) (2-(dep)) struct expr_value { struct expr *expr; @@ -86,7 +85,6 @@ struct symbol { #define SYMBOL_CHECK 0x0008 #define SYMBOL_CHOICE 0x0010 #define SYMBOL_CHOICEVAL 0x0020 -#define SYMBOL_PRINTED 0x0040 #define SYMBOL_VALID 0x0080 #define SYMBOL_OPTIONAL 0x0100 #define SYMBOL_WRITE 0x0200 diff -puN scripts/kconfig/gconf.c~git-kbuild scripts/kconfig/gconf.c --- a/scripts/kconfig/gconf.c~git-kbuild +++ a/scripts/kconfig/gconf.c @@ -119,8 +119,6 @@ const char *dbg_print_flags(int val) strcat(buf, "choice/"); if (val & SYMBOL_CHOICEVAL) strcat(buf, "choiceval/"); - if (val & SYMBOL_PRINTED) - strcat(buf, "printed/"); if (val & SYMBOL_VALID) strcat(buf, "valid/"); if (val & SYMBOL_OPTIONAL) @@ -457,14 +455,18 @@ static void text_insert_help(struct menu { GtkTextBuffer *buffer; GtkTextIter start, end; - const char *prompt = menu_get_prompt(menu); + const char *prompt = _(menu_get_prompt(menu)); gchar *name; const char *help; - help = _(menu_get_help(menu)); + help = menu_get_help(menu); + + /* Gettextize if the help text not empty */ + if ((help != 0) && (help[0] != 0)) + help = _(help); if (menu->sym && menu->sym->name) - name = g_strdup_printf(_(menu->sym->name)); + name = g_strdup_printf(menu->sym->name); else name = g_strdup(""); @@ -1171,7 +1173,7 @@ static gchar **fill_row(struct menu *men bzero(row, sizeof(row)); row[COL_OPTION] = - g_strdup_printf("%s %s", menu_get_prompt(menu), + g_strdup_printf("%s %s", _(menu_get_prompt(menu)), sym && sym_has_value(sym) ? "(NEW)" : ""); if (show_all && !menu_is_visible(menu)) @@ -1221,7 +1223,7 @@ static gchar **fill_row(struct menu *men if (def_menu) row[COL_VALUE] = - g_strdup(menu_get_prompt(def_menu)); + g_strdup(_(menu_get_prompt(def_menu))); } if (sym->flags & SYMBOL_CHOICEVAL) row[COL_BTNRAD] = GINT_TO_POINTER(TRUE); diff -puN scripts/kconfig/lex.zconf.c_shipped~git-kbuild scripts/kconfig/lex.zconf.c_shipped --- a/scripts/kconfig/lex.zconf.c_shipped~git-kbuild +++ a/scripts/kconfig/lex.zconf.c_shipped @@ -1275,6 +1275,11 @@ YY_RULE_SETUP case 32: YY_RULE_SETUP { + while (zconfleng) { + if ((zconftext[zconfleng-1] != ' ') && (zconftext[zconfleng-1] != '\t')) + break; + zconfleng--; + } append_string(zconftext, zconfleng); if (!first_ts) first_ts = last_ts; diff -puN scripts/kconfig/lxdialog/check-lxdialog.sh~git-kbuild scripts/kconfig/lxdialog/check-lxdialog.sh --- a/scripts/kconfig/lxdialog/check-lxdialog.sh~git-kbuild +++ a/scripts/kconfig/lxdialog/check-lxdialog.sh @@ -36,14 +36,16 @@ trap "rm -f $tmp" 0 1 2 3 15 # Check if we can link to ncurses check() { - echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null + echo -e " #include CURSES_LOC \n main() {}" | + $cc -xc - -o $tmp 2> /dev/null if [ $? != 0 ]; then - echo " *** Unable to find the ncurses libraries." 1>&2 - echo " *** make menuconfig require the ncurses libraries" 1>&2 - echo " *** " 1>&2 - echo " *** Install ncurses (ncurses-devel) and try again" 1>&2 - echo " *** " 1>&2 - exit 1 + echo " *** Unable to find the ncurses libraries or the" 1>&2 + echo " *** required header files." 1>&2 + echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2 + echo " *** " 1>&2 + echo " *** Install ncurses (ncurses-devel) and try again." 1>&2 + echo " *** " 1>&2 + exit 1 fi } diff -puN scripts/kconfig/lxdialog/checklist.c~git-kbuild scripts/kconfig/lxdialog/checklist.c --- a/scripts/kconfig/lxdialog/checklist.c~git-kbuild +++ a/scripts/kconfig/lxdialog/checklist.c @@ -97,8 +97,8 @@ static void print_buttons(WINDOW * dialo int x = width / 2 - 11; int y = height - 2; - print_button(dialog, "Select", y, x, selected == 0); - print_button(dialog, " Help ", y, x + 14, selected == 1); + print_button(dialog, gettext("Select"), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); wmove(dialog, y, x + 1 + 14 * selected); wrefresh(dialog); diff -puN scripts/kconfig/lxdialog/dialog.h~git-kbuild scripts/kconfig/lxdialog/dialog.h --- a/scripts/kconfig/lxdialog/dialog.h~git-kbuild +++ a/scripts/kconfig/lxdialog/dialog.h @@ -26,6 +26,12 @@ #include #include +#ifndef KBUILD_NO_NLS +# include +#else +# define gettext(Msgid) ((const char *) (Msgid)) +#endif + #ifdef __sun__ #define CURS_MACROS #endif @@ -187,10 +193,9 @@ int item_is_tag(char tag); int on_key_esc(WINDOW *win); int on_key_resize(void); -void init_dialog(const char *backtitle); +int init_dialog(const char *backtitle); void set_dialog_backtitle(const char *backtitle); -void reset_dialog(void); -void end_dialog(void); +void end_dialog(int x, int y); void attr_clear(WINDOW * win, int height, int width, chtype attr); void dialog_clear(void); void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); diff -puN scripts/kconfig/lxdialog/inputbox.c~git-kbuild scripts/kconfig/lxdialog/inputbox.c --- a/scripts/kconfig/lxdialog/inputbox.c~git-kbuild +++ a/scripts/kconfig/lxdialog/inputbox.c @@ -31,8 +31,8 @@ static void print_buttons(WINDOW * dialo int x = width / 2 - 11; int y = height - 2; - print_button(dialog, " Ok ", y, x, selected == 0); - print_button(dialog, " Help ", y, x + 14, selected == 1); + print_button(dialog, gettext(" Ok "), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); wmove(dialog, y, x + 1 + 14 * selected); wrefresh(dialog); diff -puN scripts/kconfig/lxdialog/menubox.c~git-kbuild scripts/kconfig/lxdialog/menubox.c --- a/scripts/kconfig/lxdialog/menubox.c~git-kbuild +++ a/scripts/kconfig/lxdialog/menubox.c @@ -157,9 +157,9 @@ static void print_buttons(WINDOW * win, int x = width / 2 - 16; int y = height - 2; - print_button(win, "Select", y, x, selected == 0); - print_button(win, " Exit ", y, x + 12, selected == 1); - print_button(win, " Help ", y, x + 24, selected == 2); + print_button(win, gettext("Select"), y, x, selected == 0); + print_button(win, gettext(" Exit "), y, x + 12, selected == 1); + print_button(win, gettext(" Help "), y, x + 24, selected == 2); wmove(win, y, x + 1 + 12 * selected); wrefresh(win); diff -puN scripts/kconfig/lxdialog/textbox.c~git-kbuild scripts/kconfig/lxdialog/textbox.c --- a/scripts/kconfig/lxdialog/textbox.c~git-kbuild +++ a/scripts/kconfig/lxdialog/textbox.c @@ -114,7 +114,7 @@ do_resize: print_title(dialog, title, width); - print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE); + print_button(dialog, gettext(" Exit "), height - 2, width / 2 - 4, TRUE); wnoutrefresh(dialog); getyx(dialog, cur_y, cur_x); /* Save cursor position */ diff -puN scripts/kconfig/lxdialog/util.c~git-kbuild scripts/kconfig/lxdialog/util.c --- a/scripts/kconfig/lxdialog/util.c~git-kbuild +++ a/scripts/kconfig/lxdialog/util.c @@ -266,31 +266,41 @@ void dialog_clear(void) /* * Do some initialization for dialog */ -void init_dialog(const char *backtitle) +int init_dialog(const char *backtitle) { - dlg.backtitle = backtitle; - color_setup(getenv("MENUCONFIG_COLOR")); -} + int height, width; + + initscr(); /* Init curses */ + getmaxyx(stdscr, height, width); + if (height < 19 || width < 80) { + endwin(); + return -ERRDISPLAYTOOSMALL; + } -void set_dialog_backtitle(const char *backtitle) -{ dlg.backtitle = backtitle; -} + color_setup(getenv("MENUCONFIG_COLOR")); -void reset_dialog(void) -{ - initscr(); /* Init curses */ keypad(stdscr, TRUE); cbreak(); noecho(); dialog_clear(); + + return 0; +} + +void set_dialog_backtitle(const char *backtitle) +{ + dlg.backtitle = backtitle; } /* * End using dialog functions. */ -void end_dialog(void) +void end_dialog(int x, int y) { + /* move cursor back to original position */ + move(y, x); + refresh(); endwin(); } diff -puN scripts/kconfig/lxdialog/yesno.c~git-kbuild scripts/kconfig/lxdialog/yesno.c --- a/scripts/kconfig/lxdialog/yesno.c~git-kbuild +++ a/scripts/kconfig/lxdialog/yesno.c @@ -29,8 +29,8 @@ static void print_buttons(WINDOW * dialo int x = width / 2 - 10; int y = height - 2; - print_button(dialog, " Yes ", y, x, selected == 0); - print_button(dialog, " No ", y, x + 13, selected == 1); + print_button(dialog, gettext(" Yes "), y, x, selected == 0); + print_button(dialog, gettext(" No "), y, x + 13, selected == 1); wmove(dialog, y, x + 1 + 13 * selected); wrefresh(dialog); diff -puN scripts/kconfig/mconf.c~git-kbuild scripts/kconfig/mconf.c --- a/scripts/kconfig/mconf.c~git-kbuild +++ a/scripts/kconfig/mconf.c @@ -8,17 +8,13 @@ * i18n, 2005, Arnaldo Carvalho de Melo */ -#include -#include #include #include #include #include -#include #include #include #include -#include #include #include @@ -275,8 +271,6 @@ search_help[] = N_( "\n"); static int indent; -static struct termios ios_org; -static int rows = 0, cols = 0; static struct menu *current_menu; static int child_count; static int single_menu_mode; @@ -290,51 +284,16 @@ static void show_textbox(const char *tit static void show_helptext(const char *title, const char *text); static void show_help(struct menu *menu); -static void init_wsize(void) -{ - struct winsize ws; - char *env; - - if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { - rows = ws.ws_row; - cols = ws.ws_col; - } - - if (!rows) { - env = getenv("LINES"); - if (env) - rows = atoi(env); - if (!rows) - rows = 24; - } - if (!cols) { - env = getenv("COLUMNS"); - if (env) - cols = atoi(env); - if (!cols) - cols = 80; - } - - if (rows < 19 || cols < 80) { - fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); - fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); - exit(1); - } - - rows -= 4; - cols -= 5; -} - static void get_prompt_str(struct gstr *r, struct property *prop) { int i, j; struct menu *submenu[8], *menu; - str_printf(r, "Prompt: %s\n", prop->text); - str_printf(r, " Defined at %s:%d\n", prop->menu->file->name, + str_printf(r, _("Prompt: %s\n"), _(prop->text)); + str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, prop->menu->lineno); if (!expr_is_yes(prop->visible.expr)) { - str_append(r, " Depends on: "); + str_append(r, _(" Depends on: ")); expr_gstr_print(prop->visible.expr, r); str_append(r, "\n"); } @@ -342,13 +301,13 @@ static void get_prompt_str(struct gstr * for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) submenu[i++] = menu; if (i > 0) { - str_printf(r, " Location:\n"); + str_printf(r, _(" Location:\n")); for (j = 4; --i >= 0; j += 2) { menu = submenu[i]; - str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); + str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu))); if (menu->sym) { str_printf(r, " (%s [=%s])", menu->sym->name ? - menu->sym->name : "", + menu->sym->name : _(""), sym_get_string_value(menu->sym)); } str_append(r, "\n"); @@ -378,7 +337,7 @@ static void get_symbol_str(struct gstr * if (hit) str_append(r, "\n"); if (sym->rev_dep.expr) { - str_append(r, " Selected by: "); + str_append(r, _(" Selected by: ")); expr_gstr_print(sym->rev_dep.expr, r); str_append(r, "\n"); } @@ -394,7 +353,7 @@ static struct gstr get_relations_str(str for (i = 0; sym_arr && (sym = sym_arr[i]); i++) get_symbol_str(&res, sym); if (!i) - str_append(&res, "No matches found.\n"); + str_append(&res, _("No matches found.\n")); return res; } @@ -474,6 +433,7 @@ static void build_conf(struct menu *menu switch (prop->type) { case P_MENU: child_count++; + prompt = _(prompt); if (single_menu_mode) { item_make("%s%*c%s", menu->data ? "-->" : "++>", @@ -489,7 +449,7 @@ static void build_conf(struct menu *menu case P_COMMENT: if (prompt) { child_count++; - item_make(" %*c*** %s ***", indent + 1, ' ', prompt); + item_make(" %*c*** %s ***", indent + 1, ' ', _(prompt)); item_set_tag(':'); item_set_data(menu); } @@ -497,7 +457,7 @@ static void build_conf(struct menu *menu default: if (prompt) { child_count++; - item_make("---%*c%s", indent + 1, ' ', prompt); + item_make("---%*c%s", indent + 1, ' ', _(prompt)); item_set_tag(':'); item_set_data(menu); } @@ -541,10 +501,10 @@ static void build_conf(struct menu *menu item_set_data(menu); } - item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + item_add_str("%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); if (val == yes) { if (def_menu) { - item_add_str(" (%s)", menu_get_prompt(def_menu)); + item_add_str(" (%s)", _(menu_get_prompt(def_menu))); item_add_str(" --->"); if (def_menu->list) { indent += 2; @@ -556,7 +516,7 @@ static void build_conf(struct menu *menu } } else { if (menu == current_menu) { - item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + item_make("---%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); item_set_tag(':'); item_set_data(menu); goto conf_childs; @@ -599,17 +559,17 @@ static void build_conf(struct menu *menu tmp = indent - tmp + 4; if (tmp < 0) tmp = 0; - item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu), + item_add_str("%*c%s%s", tmp, ' ', _(menu_get_prompt(menu)), (sym_has_value(sym) || !sym_is_changable(sym)) ? - "" : " (NEW)"); + "" : _(" (NEW)")); item_set_tag('s'); item_set_data(menu); goto conf_childs; } } - item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), + item_add_str("%*c%s%s", indent + 1, ' ', _(menu_get_prompt(menu)), (sym_has_value(sym) || !sym_is_changable(sym)) ? - "" : " (NEW)"); + "" : _(" (NEW)")); if (menu->prompt->type == P_MENU) { item_add_str(" --->"); return; @@ -647,7 +607,7 @@ static void conf(struct menu *menu) item_set_tag('S'); } dialog_clear(); - res = dialog_menu(prompt ? prompt : _("Main Menu"), + res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), _(menu_instructions), active_menu, &s_scroll); if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) @@ -694,7 +654,7 @@ static void conf(struct menu *menu) if (sym) show_help(submenu); else - show_helptext("README", _(mconf_readme)); + show_helptext(_("README"), _(mconf_readme)); break; case 3: if (item_is_tag('t')) { @@ -752,13 +712,13 @@ static void show_help(struct menu *menu) str_append(&help, nohelp_text); } get_symbol_str(&help, sym); - show_helptext(menu_get_prompt(menu), str_get(&help)); + show_helptext(_(menu_get_prompt(menu)), str_get(&help)); str_free(&help); } static void conf_choice(struct menu *menu) { - const char *prompt = menu_get_prompt(menu); + const char *prompt = _(menu_get_prompt(menu)); struct menu *child; struct symbol *active; @@ -772,7 +732,7 @@ static void conf_choice(struct menu *men for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; - item_make("%s", menu_get_prompt(child)); + item_make("%s", _(menu_get_prompt(child))); item_set_data(child); if (child->sym == active) item_set_selected(1); @@ -780,7 +740,7 @@ static void conf_choice(struct menu *men item_set_tag('X'); } dialog_clear(); - res = dialog_checklist(prompt ? prompt : _("Main Menu"), + res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), _(radiolist_instructions), 15, 70, 6); selected = item_activate_selected(); @@ -826,10 +786,10 @@ static void conf_string(struct menu *men heading = _(inputbox_instructions_string); break; default: - heading = "Internal mconf error!"; + heading = _("Internal mconf error!"); } dialog_clear(); - res = dialog_inputbox(prompt ? prompt : _("Main Menu"), + res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"), heading, 10, 75, sym_get_string_value(menu->sym)); switch (res) { @@ -900,13 +860,9 @@ static void conf_save(void) } } -static void conf_cleanup(void) -{ - tcsetattr(1, TCSAFLUSH, &ios_org); -} - int main(int ac, char **av) { + int saved_x, saved_y; char *mode; int res; @@ -923,11 +879,13 @@ int main(int ac, char **av) single_menu_mode = 1; } - tcgetattr(1, &ios_org); - atexit(conf_cleanup); - init_wsize(); - reset_dialog(); - init_dialog(NULL); + getyx(stdscr, saved_y, saved_x); + if (init_dialog(NULL)) { + fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); + fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); + return 1; + } + set_config_filename(conf_get_configname()); do { conf(&rootmenu); @@ -941,7 +899,7 @@ int main(int ac, char **av) else res = -1; } while (res == KEY_ESC); - end_dialog(); + end_dialog(saved_x, saved_y); switch (res) { case 0: diff -puN scripts/kconfig/menu.c~git-kbuild scripts/kconfig/menu.c --- a/scripts/kconfig/menu.c~git-kbuild +++ a/scripts/kconfig/menu.c @@ -394,9 +394,9 @@ bool menu_is_visible(struct menu *menu) const char *menu_get_prompt(struct menu *menu) { if (menu->prompt) - return _(menu->prompt->text); + return menu->prompt->text; else if (menu->sym) - return _(menu->sym->name); + return menu->sym->name; return NULL; } diff -puN scripts/kconfig/qconf.cc~git-kbuild scripts/kconfig/qconf.cc --- a/scripts/kconfig/qconf.cc~git-kbuild +++ a/scripts/kconfig/qconf.cc @@ -114,7 +114,7 @@ void ConfigItem::updateMenu(void) sym = menu->sym; prop = menu->prompt; - prompt = QString::fromLocal8Bit(menu_get_prompt(menu)); + prompt = _(menu_get_prompt(menu)); if (prop) switch (prop->type) { case P_MENU: @@ -208,7 +208,7 @@ void ConfigItem::updateMenu(void) break; } if (!sym_has_value(sym) && visible) - prompt += " (NEW)"; + prompt += _(" (NEW)"); set_prompt: setText(promptColIdx, prompt); } @@ -346,7 +346,7 @@ ConfigList::ConfigList(ConfigView* p, co for (i = 0; i < colNr; i++) colMap[i] = colRevMap[i] = -1; - addColumn(promptColIdx, "Option"); + addColumn(promptColIdx, _("Option")); reinit(); } @@ -360,14 +360,14 @@ void ConfigList::reinit(void) removeColumn(nameColIdx); if (showName) - addColumn(nameColIdx, "Name"); + addColumn(nameColIdx, _("Name")); if (showRange) { addColumn(noColIdx, "N"); addColumn(modColIdx, "M"); addColumn(yesColIdx, "Y"); } if (showData) - addColumn(dataColIdx, "Value"); + addColumn(dataColIdx, _("Value")); updateListAll(); } @@ -803,7 +803,7 @@ void ConfigList::contextMenuEvent(QConte QAction *action; headerPopup = new QPopupMenu(this); - action = new QAction(NULL, "Show Name", 0, this); + action = new QAction(NULL, _("Show Name"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowName(bool))); @@ -811,7 +811,7 @@ void ConfigList::contextMenuEvent(QConte action, SLOT(setOn(bool))); action->setOn(showName); action->addTo(headerPopup); - action = new QAction(NULL, "Show Range", 0, this); + action = new QAction(NULL, _("Show Range"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowRange(bool))); @@ -819,7 +819,7 @@ void ConfigList::contextMenuEvent(QConte action, SLOT(setOn(bool))); action->setOn(showRange); action->addTo(headerPopup); - action = new QAction(NULL, "Show Data", 0, this); + action = new QAction(NULL, _("Show Data"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowData(bool))); @@ -1041,7 +1041,12 @@ void ConfigInfoView::menuInfo(void) if (showDebug()) debug = debug_info(sym); - help = print_filter(_(menu_get_help(menu))); + help = menu_get_help(menu); + /* Gettextize if the help text not empty */ + if (help.isEmpty()) + help = print_filter(menu_get_help(menu)); + else + help = print_filter(_(menu_get_help(menu))); } else if (menu->prompt) { head += ""; head += print_filter(_(menu->prompt->text)); @@ -1167,7 +1172,7 @@ void ConfigInfoView::expr_print_help(voi QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) { QPopupMenu* popup = Parent::createPopupMenu(pos); - QAction* action = new QAction(NULL,"Show Debug Info", 0, popup); + QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); @@ -1189,11 +1194,11 @@ ConfigSearchWindow::ConfigSearchWindow(C QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6); QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6); - layout2->addWidget(new QLabel("Find:", this)); + layout2->addWidget(new QLabel(_("Find:"), this)); editField = new QLineEdit(this); connect(editField, SIGNAL(returnPressed()), SLOT(search())); layout2->addWidget(editField); - searchButton = new QPushButton("Search", this); + searchButton = new QPushButton(_("Search"), this); searchButton->setAutoDefault(FALSE); connect(searchButton, SIGNAL(clicked()), SLOT(search())); layout2->addWidget(searchButton); @@ -1313,58 +1318,58 @@ ConfigMainWindow::ConfigMainWindow(void) menu = menuBar(); toolBar = new QToolBar("Tools", this); - backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); + backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this); connect(backAction, SIGNAL(activated()), SLOT(goBack())); backAction->setEnabled(FALSE); - QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); + QAction *quitAction = new QAction("Quit", _("&Quit"), CTRL+Key_Q, this); connect(quitAction, SIGNAL(activated()), SLOT(close())); - QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); + QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), CTRL+Key_L, this); connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); - saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); + saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), CTRL+Key_S, this); connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); conf_set_changed_callback(conf_changed); // Set saveAction's initial state conf_changed(); - QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); + QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this); connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); - QAction *searchAction = new QAction("Find", "&Find", CTRL+Key_F, this); + QAction *searchAction = new QAction("Find", _("&Find"), CTRL+Key_F, this); connect(searchAction, SIGNAL(activated()), SLOT(searchConfig())); - QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); + QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this); connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); - QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); + QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this); connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); - QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); + QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this); connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); - QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); + QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this); showNameAction->setToggleAction(TRUE); connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool))); showNameAction->setOn(configView->showName()); - QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); + QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this); showRangeAction->setToggleAction(TRUE); connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); showRangeAction->setOn(configList->showRange); - QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); + QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this); showDataAction->setToggleAction(TRUE); connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); showDataAction->setOn(configList->showData); - QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); + QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this); showAllAction->setToggleAction(TRUE); connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool))); connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool))); showAllAction->setOn(configList->showAll); - QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); + QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); showDebugAction->setToggleAction(TRUE); connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool))); showDebugAction->setOn(helpText->showDebug()); - QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); + QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this); connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); - QAction *showAboutAction = new QAction(NULL, "About", 0, this); + QAction *showAboutAction = new QAction(NULL, _("About"), 0, this); connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); // init tool bar @@ -1379,7 +1384,7 @@ ConfigMainWindow::ConfigMainWindow(void) // create config menu QPopupMenu* config = new QPopupMenu(this); - menu->insertItem("&File", config); + menu->insertItem(_("&File"), config); loadAction->addTo(config); saveAction->addTo(config); saveAsAction->addTo(config); @@ -1388,12 +1393,12 @@ ConfigMainWindow::ConfigMainWindow(void) // create edit menu QPopupMenu* editMenu = new QPopupMenu(this); - menu->insertItem("&Edit", editMenu); + menu->insertItem(_("&Edit"), editMenu); searchAction->addTo(editMenu); // create options menu QPopupMenu* optionMenu = new QPopupMenu(this); - menu->insertItem("&Option", optionMenu); + menu->insertItem(_("&Option"), optionMenu); showNameAction->addTo(optionMenu); showRangeAction->addTo(optionMenu); showDataAction->addTo(optionMenu); @@ -1404,7 +1409,7 @@ ConfigMainWindow::ConfigMainWindow(void) // create help menu QPopupMenu* helpMenu = new QPopupMenu(this); menu->insertSeparator(); - menu->insertItem("&Help", helpMenu); + menu->insertItem(_("&Help"), helpMenu); showIntroAction->addTo(helpMenu); showAboutAction->addTo(helpMenu); @@ -1452,14 +1457,14 @@ void ConfigMainWindow::loadConfig(void) if (s.isNull()) return; if (conf_read(QFile::encodeName(s))) - QMessageBox::information(this, "qconf", "Unable to load configuration!"); + QMessageBox::information(this, "qconf", _("Unable to load configuration!")); ConfigView::updateListAll(); } void ConfigMainWindow::saveConfig(void) { if (conf_write(NULL)) - QMessageBox::information(this, "qconf", "Unable to save configuration!"); + QMessageBox::information(this, "qconf", _("Unable to save configuration!")); } void ConfigMainWindow::saveConfigAs(void) @@ -1468,7 +1473,7 @@ void ConfigMainWindow::saveConfigAs(void if (s.isNull()) return; if (conf_write(QFile::encodeName(s))) - QMessageBox::information(this, "qconf", "Unable to save configuration!"); + QMessageBox::information(this, "qconf", _("Unable to save configuration!")); } void ConfigMainWindow::searchConfig(void) @@ -1612,11 +1617,11 @@ void ConfigMainWindow::closeEvent(QClose e->accept(); return; } - QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, + QMessageBox mb("qconf", _("Save configuration?"), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); - mb.setButtonText(QMessageBox::Yes, "&Save Changes"); - mb.setButtonText(QMessageBox::No, "&Discard Changes"); - mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); + mb.setButtonText(QMessageBox::Yes, _("&Save Changes")); + mb.setButtonText(QMessageBox::No, _("&Discard Changes")); + mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); switch (mb.exec()) { case QMessageBox::Yes: conf_write(NULL); @@ -1631,7 +1636,7 @@ void ConfigMainWindow::closeEvent(QClose void ConfigMainWindow::showIntro(void) { - static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" + static const QString str = _("Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" "For each option, a blank box indicates the feature is disabled, a check\n" "indicates it is enabled, and a dot indicates that it is to be compiled\n" "as a module. Clicking on the box will cycle through the three states.\n\n" @@ -1641,15 +1646,15 @@ void ConfigMainWindow::showIntro(void) "options must be enabled to support the option you are interested in, you can\n" "still view the help of a grayed-out option.\n\n" "Toggling Show Debug Info under the Options menu will show the dependencies,\n" - "which you can then match by examining other options.\n\n"; + "which you can then match by examining other options.\n\n"); QMessageBox::information(this, "qconf", str); } void ConfigMainWindow::showAbout(void) { - static char str[] = "qconf is Copyright (C) 2002 Roman Zippel .\n\n" - "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; + static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel .\n\n" + "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"); QMessageBox::information(this, "qconf", str); } @@ -1707,7 +1712,7 @@ static const char *progname; static void usage(void) { - printf("%s \n", progname); + printf(_("%s \n"), progname); exit(0); } diff -puN scripts/kconfig/symbol.c~git-kbuild scripts/kconfig/symbol.c --- a/scripts/kconfig/symbol.c~git-kbuild +++ a/scripts/kconfig/symbol.c @@ -199,7 +199,7 @@ static void sym_calc_visibility(struct s tri = no; for_all_prompts(sym, prop) { prop->visible.tri = expr_calc_value(prop->visible.expr); - tri = E_OR(tri, prop->visible.tri); + tri = EXPR_OR(tri, prop->visible.tri); } if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) tri = yes; @@ -303,7 +303,7 @@ void sym_calc_value(struct symbol *sym) if (sym_is_choice_value(sym) && sym->visible == yes) { prop = sym_get_choice_prop(sym); newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; - } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) { + } else if (EXPR_OR(sym->visible, sym->rev_dep.tri) != no) { sym->flags |= SYMBOL_WRITE; if (sym_has_value(sym)) newval.tri = sym->def[S_DEF_USER].tri; @@ -312,7 +312,7 @@ void sym_calc_value(struct symbol *sym) if (prop) newval.tri = expr_calc_value(prop->expr); } - newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri); + newval.tri = EXPR_OR(EXPR_AND(newval.tri, sym->visible), sym->rev_dep.tri); } else if (!sym_is_choice(sym)) { prop = sym_get_default_prop(sym); if (prop) { diff -puN scripts/kconfig/zconf.l~git-kbuild scripts/kconfig/zconf.l --- a/scripts/kconfig/zconf.l~git-kbuild +++ a/scripts/kconfig/zconf.l @@ -217,6 +217,11 @@ n [A-Za-z0-9_] append_string("\n", 1); } [^ \t\n].* { + while (yyleng) { + if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t')) + break; + yyleng--; + } append_string(yytext, yyleng); if (!first_ts) first_ts = last_ts; diff -puN scripts/kernel-doc~git-kbuild scripts/kernel-doc --- a/scripts/kernel-doc~git-kbuild +++ a/scripts/kernel-doc @@ -46,21 +46,24 @@ use strict; # Note: This only supports 'c'. # usage: -# kernel-doc [ -docbook | -html | -text | -man ] +# kernel-doc [ -docbook | -html | -text | -man ] [ -no-doc-sections ] # [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile # or # [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile # # Set output format using one of -docbook -html -text or -man. Default is man. # +# -no-doc-sections +# Do not output DOC: sections +# # -function funcname -# If set, then only generate documentation for the given function(s). All -# other functions are ignored. +# If set, then only generate documentation for the given function(s) or +# DOC: section titles. All other functions and DOC: sections are ignored. # # -nofunction funcname -# If set, then only generate documentation for the other function(s). -# Cannot be used together with -function -# (yes, that's a bug -- perl hackers can fix it 8)) +# If set, then only generate documentation for the other function(s)/DOC: +# sections. Cannot be used together with -function (yes, that's a bug -- +# perl hackers can fix it 8)) # # c files - list of 'c' files to process # @@ -182,10 +185,10 @@ my $blankline_html = $local_lt . "p" . $ my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1\$2", $type_constant, "\$1", $type_func, "\$1", - $type_struct, "\$1", + $type_struct_xml, "\$1", $type_env, "\$1", $type_param, "\$1" ); -my $blankline_xml = "\n"; +my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; # gnome, docbook format my %highlights_gnome = ( $type_constant, "\$1", @@ -211,7 +214,7 @@ my $blankline_text = ""; sub usage { - print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ]\n"; + print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ] [ -no-doc-sections ]\n"; print " [ -function funcname [ -function funcname ...] ]\n"; print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; print " c source file(s) > outputfile\n"; @@ -225,6 +228,7 @@ if ($#ARGV==-1) { my $verbose = 0; my $output_mode = "man"; +my $no_doc_sections = 0; my %highlights = %highlights_man; my $blankline = $blankline_man; my $modulename = "Kernel API"; @@ -329,12 +333,14 @@ while ($ARGV[0] =~ m/^-(.*)/) { usage(); } elsif ($cmd eq '-filelist') { $filelist = shift @ARGV; + } elsif ($cmd eq '-no-doc-sections') { + $no_doc_sections = 1; } } # get kernel version from env sub get_kernel_version() { - my $version; + my $version = 'unknown kernel version'; if (defined($ENV{'KERNELVERSION'})) { $version = $ENV{'KERNELVERSION'}; @@ -374,6 +380,29 @@ sub dump_section { } ## +# dump DOC: section after checking that it should go out +# +sub dump_doc_section { + my $name = shift; + my $contents = join "\n", @_; + + if ($no_doc_sections) { + return; + } + + if (($function_only == 0) || + ( $function_only == 1 && defined($function_table{$name})) || + ( $function_only == 2 && !defined($function_table{$name}))) + { + dump_section $name, $contents; + output_blockhead({'sectionlist' => \@sectionlist, + 'sections' => \%sections, + 'module' => $modulename, + 'content-only' => ($function_only != 0), }); + } +} + +## # output function # # parameterdescs, a hash. @@ -394,7 +423,7 @@ sub output_highlight { # confess "output_highlight got called with no args?\n"; # } - if ($output_mode eq "html") { + if ($output_mode eq "html" || $output_mode eq "xml") { $contents = local_unescape($contents); # convert data read & converted thru xml_escape() into &xyz; format: $contents =~ s/\\\\\\/&/g; @@ -564,8 +593,8 @@ sub output_function_html(%) { print "
\n"; } -# output intro in html -sub output_intro_html(%) { +# output DOC: block header in html +sub output_blockhead_html(%) { my %args = %{$_[0]}; my ($parameter, $section); my $count; @@ -871,7 +900,7 @@ sub output_typedef_xml(%) { } # output in XML DocBook -sub output_intro_xml(%) { +sub output_blockhead_xml(%) { my %args = %{$_[0]}; my ($parameter, $section); my $count; @@ -882,15 +911,23 @@ sub output_intro_xml(%) { # print out each section $lineprefix=" "; foreach $section (@{$args{'sectionlist'}}) { - print "\n $section\n \n"; + if (!$args{'content-only'}) { + print "\n $section\n"; + } if ($section =~ m/EXAMPLE/i) { print "\n"; + } else { + print "\n"; } output_highlight($args{'sections'}{$section}); if ($section =~ m/EXAMPLE/i) { print "\n"; + } else { + print ""; + } + if (!$args{'content-only'}) { + print "\n\n"; } - print "
\n\n"; } print "\n\n"; @@ -1137,7 +1174,7 @@ sub output_typedef_man(%) { } } -sub output_intro_man(%) { +sub output_blockhead_man(%) { my %args = %{$_[0]}; my ($parameter, $section); my $count; @@ -1294,7 +1331,7 @@ sub output_struct_text(%) { output_section_text(@_); } -sub output_intro_text(%) { +sub output_blockhead_text(%) { my %args = %{$_[0]}; my ($parameter, $section); @@ -1325,9 +1362,9 @@ sub output_declaration { ## # generic output function - calls the right one based on current output mode. -sub output_intro { +sub output_blockhead { no strict 'refs'; - my $func = "output_intro_".$output_mode; + my $func = "output_blockhead_".$output_mode; &$func(@_); $section_counter++; } @@ -1926,9 +1963,7 @@ sub process_file($) { } elsif ($state == 4) { # Documentation block if (/$doc_block/) { - dump_section($section, xml_escape($contents)); - output_intro({'sectionlist' => \@sectionlist, - 'sections' => \%sections }); + dump_doc_section($section, xml_escape($contents)); $contents = ""; $function = ""; %constants = (); @@ -1946,9 +1981,7 @@ sub process_file($) { } elsif (/$doc_end/) { - dump_section($section, xml_escape($contents)); - output_intro({'sectionlist' => \@sectionlist, - 'sections' => \%sections }); + dump_doc_section($section, xml_escape($contents)); $contents = ""; $function = ""; %constants = (); diff -puN scripts/mkmakefile~git-kbuild scripts/mkmakefile --- a/scripts/mkmakefile~git-kbuild +++ a/scripts/mkmakefile @@ -25,8 +25,11 @@ cat << EOF > $2/Makefile VERSION = $3 PATCHLEVEL = $4 -KERNELSRC := $1 -KERNELOUTPUT := $2 +lastword = \$(word \$(words \$(1)),\$(1)) +makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) + +MAKEARGS := -C $1 +MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) MAKEFLAGS += --no-print-directory @@ -35,10 +38,11 @@ MAKEFLAGS += --no-print-directory all := \$(filter-out all Makefile,\$(MAKECMDGOALS)) all: - \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$(all) + \$(MAKE) \$(MAKEARGS) \$(all) Makefile:; \$(all) %/: all @: + EOF diff -puN scripts/mkuboot.sh~git-kbuild /dev/null --- a/scripts/mkuboot.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# -# Build U-Boot image when `mkimage' tool is available. -# - -MKIMAGE=$(type -path "${CROSS_COMPILE}mkimage") - -if [ -z "${MKIMAGE}" ]; then - MKIMAGE=$(type -path mkimage) - if [ -z "${MKIMAGE}" ]; then - # Doesn't exist - echo '"mkimage" command not found - U-Boot images will not be built' >&2 - exit 0; - fi -fi - -# Call "mkimage" to create U-Boot image -${MKIMAGE} "$@" diff -puN /dev/null scripts/mkubootimg/Makefile --- /dev/null +++ a/scripts/mkubootimg/Makefile @@ -0,0 +1,6 @@ +hostprogs-y := mkubootimg +always := $(hostprogs-y) + +mkubootimg-objs := mkimage.o crc32.o + +HOSTCFLAGS_crc32.o := -DUSE_HOSTCC diff -puN /dev/null scripts/mkubootimg/crc32.c --- /dev/null +++ a/scripts/mkubootimg/crc32.c @@ -0,0 +1,196 @@ +/* + * This file is derived from crc32.c from the zlib-1.1.3 distribution + * by Jean-loup Gailly and Mark Adler. + */ + +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#ifndef USE_HOSTCC /* Shut down "ANSI does not permit..." warnings */ +#include +#endif + +#include "zlib.h" + +#define local static +#define ZEXPORT /* empty */ +unsigned long crc32 (unsigned long, const unsigned char *, unsigned int); + +#ifdef DYNAMIC_CRC_TABLE + +local int crc_table_empty = 1; +local uLongf crc_table[256]; +local void make_crc_table OF((void)); + +/* + Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The table is simply the CRC of all possible eight bit values. This is all + the information needed to generate CRC's on data a byte at a time for all + combinations of CRC register values and incoming bytes. +*/ +local void make_crc_table() +{ + uLong c; + int n, k; + uLong poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* make exclusive-or pattern from polynomial (0xedb88320L) */ + poly = 0L; + for (n = 0; n < sizeof(p)/sizeof(Byte); n++) + poly |= 1L << (31 - p[n]); + + for (n = 0; n < 256; n++) + { + c = (uLong)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[n] = c; + } + crc_table_empty = 0; +} +#else +/* ======================================================================== + * Table of CRC-32's of all single-byte values (made by make_crc_table) + */ +local const uLongf crc_table[256] = { + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; +#endif + +#if 0 +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const uLongf * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) make_crc_table(); +#endif + return (const uLongf *)crc_table; +} +#endif + +/* ========================================================================= */ +#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define DO2(buf) DO1(buf); DO1(buf); +#define DO4(buf) DO2(buf); DO2(buf); +#define DO8(buf) DO4(buf); DO4(buf); + +/* ========================================================================= */ +uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len) +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif + crc = crc ^ 0xffffffffL; + while (len >= 8) + { + DO8(buf); + len -= 8; + } + if (len) do { + DO1(buf); + } while (--len); + return crc ^ 0xffffffffL; +} + +#if defined(CONFIG_CMD_JFFS2) || \ + (defined(CONFIG_CMD_NAND) \ + && !defined(CFG_NAND_LEGACY)) + +/* No ones complement version. JFFS2 (and other things ?) + * don't use ones compliment in their CRC calculations. + */ +uLong ZEXPORT crc32_no_comp(uLong crc, const Bytef *buf, uInt len) +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif + while (len >= 8) + { + DO8(buf); + len -= 8; + } + if (len) do { + DO1(buf); + } while (--len); + + return crc; +} + +#endif diff -puN /dev/null scripts/mkubootimg/mkimage.c --- /dev/null +++ a/scripts/mkubootimg/mkimage.c @@ -0,0 +1,727 @@ +/* + * (C) Copyright 2000-2004 + * DENX Software Engineering + * Wolfgang Denk, wd@denx.de + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include /* for host / network byte order conversions */ +#include +#include +#include +#include + +#ifndef O_BINARY /* should be define'd on __WIN32__ */ +#define O_BINARY 0 +#endif + +#include "uimage.h" + +#ifndef MAP_FAILED +#define MAP_FAILED (-1) +#endif + +static char *cmdname; + +extern unsigned long crc32 (unsigned long crc, const char *buf, unsigned int len); + +typedef struct table_entry { + int val; /* as defined in image.h */ + char *sname; /* short (input) name */ + char *lname; /* long (output) name */ +} table_entry_t; + +static table_entry_t arch_name[] = { + { IH_CPU_INVALID, NULL, "Invalid CPU", }, + { IH_CPU_ALPHA, "alpha", "Alpha", }, + { IH_CPU_ARM, "arm", "ARM", }, + { IH_CPU_I386, "x86", "Intel x86", }, + { IH_CPU_IA64, "ia64", "IA64", }, + { IH_CPU_M68K, "m68k", "MC68000", }, + { IH_CPU_MICROBLAZE, "microblaze", "MicroBlaze", }, + { IH_CPU_MIPS, "mips", "MIPS", }, + { IH_CPU_MIPS64, "mips64", "MIPS 64 Bit", }, + { IH_CPU_NIOS, "nios", "NIOS", }, + { IH_CPU_NIOS2, "nios2", "NIOS II", }, + { IH_CPU_PPC, "ppc", "PowerPC", }, + { IH_CPU_S390, "s390", "IBM S390", }, + { IH_CPU_SH, "sh", "SuperH", }, + { IH_CPU_SPARC, "sparc", "SPARC", }, + { IH_CPU_SPARC64, "sparc64", "SPARC 64 Bit", }, + { IH_CPU_BLACKFIN, "blackfin", "Blackfin", }, + { IH_CPU_AVR32, "avr32", "AVR32", }, + { -1, "", "", }, +}; + +static table_entry_t os_name[] = { + { IH_OS_INVALID, NULL, "Invalid OS", }, + { IH_OS_4_4BSD, "4_4bsd", "4_4BSD", }, + { IH_OS_ARTOS, "artos", "ARTOS", }, + { IH_OS_DELL, "dell", "Dell", }, + { IH_OS_ESIX, "esix", "Esix", }, + { IH_OS_FREEBSD, "freebsd", "FreeBSD", }, + { IH_OS_IRIX, "irix", "Irix", }, + { IH_OS_LINUX, "linux", "Linux", }, + { IH_OS_LYNXOS, "lynxos", "LynxOS", }, + { IH_OS_NCR, "ncr", "NCR", }, + { IH_OS_NETBSD, "netbsd", "NetBSD", }, + { IH_OS_OPENBSD, "openbsd", "OpenBSD", }, + { IH_OS_PSOS, "psos", "pSOS", }, + { IH_OS_QNX, "qnx", "QNX", }, + { IH_OS_RTEMS, "rtems", "RTEMS", }, + { IH_OS_SCO, "sco", "SCO", }, + { IH_OS_SOLARIS, "solaris", "Solaris", }, + { IH_OS_SVR4, "svr4", "SVR4", }, + { IH_OS_U_BOOT, "u-boot", "U-Boot", }, + { IH_OS_VXWORKS, "vxworks", "VxWorks", }, + { -1, "", "", }, +}; + +static table_entry_t type_name[] = { + { IH_TYPE_INVALID, NULL, "Invalid Image", }, + { IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", }, + { IH_TYPE_FIRMWARE, "firmware", "Firmware", }, + { IH_TYPE_KERNEL, "kernel", "Kernel Image", }, + { IH_TYPE_MULTI, "multi", "Multi-File Image", }, + { IH_TYPE_RAMDISK, "ramdisk", "RAMDisk Image", }, + { IH_TYPE_SCRIPT, "script", "Script", }, + { IH_TYPE_STANDALONE, "standalone", "Standalone Program", }, + { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", }, + { -1, "", "", }, +}; + +static table_entry_t comp_name[] = { + { IH_COMP_NONE, "none", "uncompressed", }, + { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", }, + { IH_COMP_GZIP, "gzip", "gzip compressed", }, + { -1, "", "", }, +}; + +static void copy_file (int, const char *, int); +static void usage (void); +static void print_header (image_header_t *); +static void print_type (image_header_t *); +static char *put_table_entry (table_entry_t *, char *, int); +static char *put_arch (int); +static char *put_type (int); +static char *put_os (int); +static char *put_comp (int); +static int get_table_entry (table_entry_t *, char *, char *); +static int get_arch(char *); +static int get_comp(char *); +static int get_os (char *); +static int get_type(char *); + + +static char *datafile; +static char *imagefile; + +static int dflag = 0; +static int eflag = 0; +static int lflag = 0; +static int vflag = 0; +static int xflag = 0; +static int opt_os = IH_OS_LINUX; +static int opt_arch = IH_CPU_PPC; +static int opt_type = IH_TYPE_KERNEL; +static int opt_comp = IH_COMP_GZIP; + +static image_header_t header; +static image_header_t *hdr = &header; + +int +main (int argc, char **argv) +{ + int ifd; + uint32_t checksum; + uint32_t addr; + uint32_t ep; + struct stat sbuf; + unsigned char *ptr; + char *endptr; + char *name = ""; + + cmdname = *argv; + + addr = ep = 0; + + while (--argc > 0 && **++argv == '-') { + while (*++*argv) { + switch (**argv) { + case 'l': + lflag = 1; + break; + case 'A': + if ((--argc <= 0) || + (opt_arch = get_arch(*++argv)) < 0) + usage (); + goto NXTARG; + case 'C': + if ((--argc <= 0) || + (opt_comp = get_comp(*++argv)) < 0) + usage (); + goto NXTARG; + case 'O': + if ((--argc <= 0) || + (opt_os = get_os(*++argv)) < 0) + usage (); + goto NXTARG; + case 'T': + if ((--argc <= 0) || + (opt_type = get_type(*++argv)) < 0) + usage (); + goto NXTARG; + + case 'a': + if (--argc <= 0) + usage (); + addr = strtoul ((char *) *++argv, &endptr, 16); + if (*endptr) { + fprintf (stderr, + "%s: invalid load address %s\n", + cmdname, *argv); + exit (EXIT_FAILURE); + } + goto NXTARG; + case 'd': + if (--argc <= 0) + usage (); + datafile = *++argv; + dflag = 1; + goto NXTARG; + case 'e': + if (--argc <= 0) + usage (); + ep = strtoul (*++argv, &endptr, 16); + if (*endptr) { + fprintf (stderr, + "%s: invalid entry point %s\n", + cmdname, *argv); + exit (EXIT_FAILURE); + } + eflag = 1; + goto NXTARG; + case 'n': + if (--argc <= 0) + usage (); + name = *++argv; + goto NXTARG; + case 'v': + vflag++; + break; + case 'x': + xflag++; + break; + default: + usage (); + } + } +NXTARG: ; + } + + if ((argc != 1) || ((lflag ^ dflag) == 0)) + usage(); + + if (!eflag) { + ep = addr; + /* If XIP, entry point must be after the U-Boot header */ + if (xflag) + ep += sizeof(image_header_t); + } + + /* + * If XIP, ensure the entry point is equal to the load address plus + * the size of the U-Boot header. + */ + if (xflag) { + if (ep != addr + sizeof(image_header_t)) { + fprintf (stderr, + "%s: For XIP, the entry point must be the load addr + %lu\n", + cmdname, + (unsigned long)sizeof(image_header_t)); + exit (EXIT_FAILURE); + } + } + + imagefile = *argv; + + if (lflag) { + ifd = open(imagefile, O_RDONLY|O_BINARY); + } else { + ifd = open(imagefile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); + } + + if (ifd < 0) { + fprintf (stderr, "%s: Can't open %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (lflag) { + int len; + char *data; + /* + * list header information of existing image + */ + if (fstat(ifd, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if ((unsigned)sbuf.st_size < sizeof(image_header_t)) { + fprintf (stderr, + "%s: Bad size: \"%s\" is no valid image\n", + cmdname, imagefile); + exit (EXIT_FAILURE); + } + + ptr = (unsigned char *)mmap(NULL, sbuf.st_size, + PROT_READ, MAP_SHARED, ifd, 0); + if ((caddr_t)ptr == (caddr_t)-1) { + fprintf (stderr, "%s: Can't read %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + /* + * create copy of header so that we can blank out the + * checksum field for checking - this can't be done + * on the PROT_READ mapped data. + */ + memcpy (hdr, ptr, sizeof(image_header_t)); + + if (ntohl(hdr->ih_magic) != IH_MAGIC) { + fprintf (stderr, + "%s: Bad Magic Number: \"%s\" is no valid image\n", + cmdname, imagefile); + exit (EXIT_FAILURE); + } + + data = (char *)hdr; + len = sizeof(image_header_t); + + checksum = ntohl(hdr->ih_hcrc); + hdr->ih_hcrc = htonl(0); /* clear for re-calculation */ + + if (crc32 (0, data, len) != checksum) { + fprintf (stderr, + "%s: ERROR: \"%s\" has bad header checksum!\n", + cmdname, imagefile); + exit (EXIT_FAILURE); + } + + data = (char *)(ptr + sizeof(image_header_t)); + len = sbuf.st_size - sizeof(image_header_t) ; + + if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) { + fprintf (stderr, + "%s: ERROR: \"%s\" has corrupted data!\n", + cmdname, imagefile); + exit (EXIT_FAILURE); + } + + /* for multi-file images we need the data part, too */ + print_header ((image_header_t *)ptr); + + (void) munmap((void *)ptr, sbuf.st_size); + (void) close (ifd); + + exit (EXIT_SUCCESS); + } + + /* + * Must be -w then: + * + * write dummy header, to be fixed later + */ + memset (hdr, 0, sizeof(image_header_t)); + + if (write(ifd, hdr, sizeof(image_header_t)) != sizeof(image_header_t)) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (opt_type == IH_TYPE_MULTI || opt_type == IH_TYPE_SCRIPT) { + char *file = datafile; + uint32_t size; + + for (;;) { + char *sep = NULL; + + if (file) { + if ((sep = strchr(file, ':')) != NULL) { + *sep = '\0'; + } + + if (stat (file, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + cmdname, file, strerror(errno)); + exit (EXIT_FAILURE); + } + size = htonl(sbuf.st_size); + } else { + size = 0; + } + + if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (!file) { + break; + } + + if (sep) { + *sep = ':'; + file = sep + 1; + } else { + file = NULL; + } + } + + file = datafile; + + for (;;) { + char *sep = strchr(file, ':'); + if (sep) { + *sep = '\0'; + copy_file (ifd, file, 1); + *sep++ = ':'; + file = sep; + } else { + copy_file (ifd, file, 0); + break; + } + } + } else { + copy_file (ifd, datafile, 0); + } + + /* We're a bit of paranoid */ +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__) + (void) fdatasync (ifd); +#else + (void) fsync (ifd); +#endif + + if (fstat(ifd, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + ptr = (unsigned char *)mmap(NULL, sbuf.st_size, + PROT_READ|PROT_WRITE, MAP_SHARED, ifd, 0); + if (ptr == (unsigned char *)MAP_FAILED) { + fprintf (stderr, "%s: Can't map %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + hdr = (image_header_t *)ptr; + + checksum = crc32 (0, + (const char *)(ptr + sizeof(image_header_t)), + sbuf.st_size - sizeof(image_header_t) + ); + + /* Build new header */ + hdr->ih_magic = htonl(IH_MAGIC); + hdr->ih_time = htonl(sbuf.st_mtime); + hdr->ih_size = htonl(sbuf.st_size - sizeof(image_header_t)); + hdr->ih_load = htonl(addr); + hdr->ih_ep = htonl(ep); + hdr->ih_dcrc = htonl(checksum); + hdr->ih_os = opt_os; + hdr->ih_arch = opt_arch; + hdr->ih_type = opt_type; + hdr->ih_comp = opt_comp; + + strncpy((char *)hdr->ih_name, name, IH_NMLEN); + + checksum = crc32(0,(const char *)hdr,sizeof(image_header_t)); + + hdr->ih_hcrc = htonl(checksum); + + print_header (hdr); + + (void) munmap((void *)ptr, sbuf.st_size); + + /* We're a bit of paranoid */ +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__) + (void) fdatasync (ifd); +#else + (void) fsync (ifd); +#endif + + if (close(ifd)) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + exit (EXIT_SUCCESS); +} + +static void +copy_file (int ifd, const char *datafile, int pad) +{ + int dfd; + struct stat sbuf; + unsigned char *ptr; + int tail; + int zero = 0; + int offset = 0; + int size; + + if (vflag) { + fprintf (stderr, "Adding Image %s\n", datafile); + } + + if ((dfd = open(datafile, O_RDONLY|O_BINARY)) < 0) { + fprintf (stderr, "%s: Can't open %s: %s\n", + cmdname, datafile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (fstat(dfd, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + cmdname, datafile, strerror(errno)); + exit (EXIT_FAILURE); + } + + ptr = (unsigned char *)mmap(NULL, sbuf.st_size, + PROT_READ, MAP_SHARED, dfd, 0); + if (ptr == (unsigned char *)MAP_FAILED) { + fprintf (stderr, "%s: Can't read %s: %s\n", + cmdname, datafile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (xflag) { + unsigned char *p = NULL; + /* + * XIP: do not append the image_header_t at the + * beginning of the file, but consume the space + * reserved for it. + */ + + if ((unsigned)sbuf.st_size < sizeof(image_header_t)) { + fprintf (stderr, + "%s: Bad size: \"%s\" is too small for XIP\n", + cmdname, datafile); + exit (EXIT_FAILURE); + } + + for (p=ptr; p < ptr+sizeof(image_header_t); p++) { + if ( *p != 0xff ) { + fprintf (stderr, + "%s: Bad file: \"%s\" has invalid buffer for XIP\n", + cmdname, datafile); + exit (EXIT_FAILURE); + } + } + + offset = sizeof(image_header_t); + } + + size = sbuf.st_size - offset; + if (write(ifd, ptr + offset, size) != size) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (pad && ((tail = size % 4) != 0)) { + + if (write(ifd, (char *)&zero, 4-tail) != 4-tail) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + } + + (void) munmap((void *)ptr, sbuf.st_size); + (void) close (dfd); +} + +static void +usage (void) +{ + fprintf (stderr, "Usage: %s -l image\n" + " -l ==> list image header information\n" + " %s [-x] -A arch -O os -T type -C comp " + "-a addr -e ep -n name -d data_file[:data_file...] image\n", + cmdname, cmdname); + fprintf (stderr, " -A ==> set architecture to 'arch'\n" + " -O ==> set operating system to 'os'\n" + " -T ==> set image type to 'type'\n" + " -C ==> set compression type 'comp'\n" + " -a ==> set load address to 'addr' (hex)\n" + " -e ==> set entry point to 'ep' (hex)\n" + " -n ==> set image name to 'name'\n" + " -d ==> use image data from 'datafile'\n" + " -x ==> set XIP (execute in place)\n" + ); + exit (EXIT_FAILURE); +} + +static void +print_header (image_header_t *hdr) +{ + time_t timestamp; + uint32_t size; + + timestamp = (time_t)ntohl(hdr->ih_time); + size = ntohl(hdr->ih_size); + + printf ("Image Name: %.*s\n", IH_NMLEN, hdr->ih_name); + printf ("Created: %s", ctime(×tamp)); + printf ("Image Type: "); print_type(hdr); + printf ("Data Size: %d Bytes = %.2f kB = %.2f MB\n", + size, (double)size / 1.024e3, (double)size / 1.048576e6 ); + printf ("Load Address: 0x%08X\n", ntohl(hdr->ih_load)); + printf ("Entry Point: 0x%08X\n", ntohl(hdr->ih_ep)); + + if (hdr->ih_type == IH_TYPE_MULTI || hdr->ih_type == IH_TYPE_SCRIPT) { + int i, ptrs; + uint32_t pos; + uint32_t *len_ptr = (uint32_t *) ( + (unsigned long)hdr + sizeof(image_header_t) + ); + + /* determine number of images first (to calculate image offsets) */ + for (i=0; len_ptr[i]; ++i) /* null pointer terminates list */ + ; + ptrs = i; /* null pointer terminates list */ + + pos = sizeof(image_header_t) + ptrs * sizeof(long); + printf ("Contents:\n"); + for (i=0; len_ptr[i]; ++i) { + size = ntohl(len_ptr[i]); + + printf (" Image %d: %8d Bytes = %4d kB = %d MB\n", + i, size, size>>10, size>>20); + if (hdr->ih_type == IH_TYPE_SCRIPT && i > 0) { + /* + * the user may need to know offsets + * if planning to do something with + * multiple files + */ + printf (" Offset = %08X\n", pos); + } + /* copy_file() will pad the first files to even word align */ + size += 3; + size &= ~3; + pos += size; + } + } +} + + +static void +print_type (image_header_t *hdr) +{ + printf ("%s %s %s (%s)\n", + put_arch (hdr->ih_arch), + put_os (hdr->ih_os ), + put_type (hdr->ih_type), + put_comp (hdr->ih_comp) + ); +} + +static char *put_arch (int arch) +{ + return (put_table_entry(arch_name, "Unknown Architecture", arch)); +} + +static char *put_os (int os) +{ + return (put_table_entry(os_name, "Unknown OS", os)); +} + +static char *put_type (int type) +{ + return (put_table_entry(type_name, "Unknown Image", type)); +} + +static char *put_comp (int comp) +{ + return (put_table_entry(comp_name, "Unknown Compression", comp)); +} + +static char *put_table_entry (table_entry_t *table, char *msg, int type) +{ + for (; table->val>=0; ++table) { + if (table->val == type) + return (table->lname); + } + return (msg); +} + +static int get_arch(char *name) +{ + return (get_table_entry(arch_name, "CPU", name)); +} + + +static int get_comp(char *name) +{ + return (get_table_entry(comp_name, "Compression", name)); +} + + +static int get_os (char *name) +{ + return (get_table_entry(os_name, "OS", name)); +} + + +static int get_type(char *name) +{ + return (get_table_entry(type_name, "Image", name)); +} + +static int get_table_entry (table_entry_t *table, char *msg, char *name) +{ + table_entry_t *t; + int first = 1; + + for (t=table; t->val>=0; ++t) { + if (t->sname && strcasecmp(t->sname, name)==0) + return (t->val); + } + fprintf (stderr, "\nInvalid %s Type - valid names are", msg); + for (t=table; t->val>=0; ++t) { + if (t->sname == NULL) + continue; + fprintf (stderr, "%c %s", (first) ? ':' : ',', t->sname); + first = 0; + } + fprintf (stderr, "\n"); + return (-1); +} diff -puN /dev/null scripts/mkubootimg/uimage.h --- /dev/null +++ a/scripts/mkubootimg/uimage.h @@ -0,0 +1,161 @@ +/* + * (C) Copyright 2000-2005 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ******************************************************************** + * NOTE: This header file defines an interface to U-Boot. Including + * this (unmodified) header file in another file is considered normal + * use of U-Boot, and does *not* fall under the heading of "derived + * work". + ******************************************************************** + */ + +#ifndef __IMAGE_H__ +#define __IMAGE_H__ + +/* + * Operating System Codes + */ +#define IH_OS_INVALID 0 /* Invalid OS */ +#define IH_OS_OPENBSD 1 /* OpenBSD */ +#define IH_OS_NETBSD 2 /* NetBSD */ +#define IH_OS_FREEBSD 3 /* FreeBSD */ +#define IH_OS_4_4BSD 4 /* 4.4BSD */ +#define IH_OS_LINUX 5 /* Linux */ +#define IH_OS_SVR4 6 /* SVR4 */ +#define IH_OS_ESIX 7 /* Esix */ +#define IH_OS_SOLARIS 8 /* Solaris */ +#define IH_OS_IRIX 9 /* Irix */ +#define IH_OS_SCO 10 /* SCO */ +#define IH_OS_DELL 11 /* Dell */ +#define IH_OS_NCR 12 /* NCR */ +#define IH_OS_LYNXOS 13 /* LynxOS */ +#define IH_OS_VXWORKS 14 /* VxWorks */ +#define IH_OS_PSOS 15 /* pSOS */ +#define IH_OS_QNX 16 /* QNX */ +#define IH_OS_U_BOOT 17 /* Firmware */ +#define IH_OS_RTEMS 18 /* RTEMS */ +#define IH_OS_ARTOS 19 /* ARTOS */ +#define IH_OS_UNITY 20 /* Unity OS */ + +/* + * CPU Architecture Codes (supported by Linux) + */ +#define IH_CPU_INVALID 0 /* Invalid CPU */ +#define IH_CPU_ALPHA 1 /* Alpha */ +#define IH_CPU_ARM 2 /* ARM */ +#define IH_CPU_I386 3 /* Intel x86 */ +#define IH_CPU_IA64 4 /* IA64 */ +#define IH_CPU_MIPS 5 /* MIPS */ +#define IH_CPU_MIPS64 6 /* MIPS 64 Bit */ +#define IH_CPU_PPC 7 /* PowerPC */ +#define IH_CPU_S390 8 /* IBM S390 */ +#define IH_CPU_SH 9 /* SuperH */ +#define IH_CPU_SPARC 10 /* Sparc */ +#define IH_CPU_SPARC64 11 /* Sparc 64 Bit */ +#define IH_CPU_M68K 12 /* M68K */ +#define IH_CPU_NIOS 13 /* Nios-32 */ +#define IH_CPU_MICROBLAZE 14 /* MicroBlaze */ +#define IH_CPU_NIOS2 15 /* Nios-II */ +#define IH_CPU_BLACKFIN 16 /* Blackfin */ +#define IH_CPU_AVR32 17 /* AVR32 */ +#define IH_CPU_ST200 18 /* STMicroelectronics ST200 */ + +/* + * Image Types + * + * "Standalone Programs" are directly runnable in the environment + * provided by U-Boot; it is expected that (if they behave + * well) you can continue to work in U-Boot after return from + * the Standalone Program. + * "OS Kernel Images" are usually images of some Embedded OS which + * will take over control completely. Usually these programs + * will install their own set of exception handlers, device + * drivers, set up the MMU, etc. - this means, that you cannot + * expect to re-enter U-Boot except by resetting the CPU. + * "RAMDisk Images" are more or less just data blocks, and their + * parameters (address, size) are passed to an OS kernel that is + * being started. + * "Multi-File Images" contain several images, typically an OS + * (Linux) kernel image and one or more data images like + * RAMDisks. This construct is useful for instance when you want + * to boot over the network using BOOTP etc., where the boot + * server provides just a single image file, but you want to get + * for instance an OS kernel and a RAMDisk image. + * + * "Multi-File Images" start with a list of image sizes, each + * image size (in bytes) specified by an "uint32_t" in network + * byte order. This list is terminated by an "(uint32_t)0". + * Immediately after the terminating 0 follow the images, one by + * one, all aligned on "uint32_t" boundaries (size rounded up to + * a multiple of 4 bytes - except for the last file). + * + * "Firmware Images" are binary images containing firmware (like + * U-Boot or FPGA images) which usually will be programmed to + * flash memory. + * + * "Script files" are command sequences that will be executed by + * U-Boot's command interpreter; this feature is especially + * useful when you configure U-Boot to use a real shell (hush) + * as command interpreter (=> Shell Scripts). + */ + +#define IH_TYPE_INVALID 0 /* Invalid Image */ +#define IH_TYPE_STANDALONE 1 /* Standalone Program */ +#define IH_TYPE_KERNEL 2 /* OS Kernel Image */ +#define IH_TYPE_RAMDISK 3 /* RAMDisk Image */ +#define IH_TYPE_MULTI 4 /* Multi-File Image */ +#define IH_TYPE_FIRMWARE 5 /* Firmware Image */ +#define IH_TYPE_SCRIPT 6 /* Script file */ +#define IH_TYPE_FILESYSTEM 7 /* Filesystem Image (any type) */ +#define IH_TYPE_FLATDT 8 /* Binary Flat Device Tree Blob */ + +/* + * Compression Types + */ +#define IH_COMP_NONE 0 /* No Compression Used */ +#define IH_COMP_GZIP 1 /* gzip Compression Used */ +#define IH_COMP_BZIP2 2 /* bzip2 Compression Used */ + +#define IH_MAGIC 0x27051956 /* Image Magic Number */ +#define IH_NMLEN 32 /* Image Name Length */ + +/* + * all data in network byte order (aka natural aka bigendian) + */ + +typedef struct image_header { + uint32_t ih_magic; /* Image Header Magic Number */ + uint32_t ih_hcrc; /* Image Header CRC Checksum */ + uint32_t ih_time; /* Image Creation Timestamp */ + uint32_t ih_size; /* Image Data Size */ + uint32_t ih_load; /* Data Load Address */ + uint32_t ih_ep; /* Entry Point Address */ + uint32_t ih_dcrc; /* Image Data CRC Checksum */ + uint8_t ih_os; /* Operating System */ + uint8_t ih_arch; /* CPU architecture */ + uint8_t ih_type; /* Image Type */ + uint8_t ih_comp; /* Compression Type */ + uint8_t ih_name[IH_NMLEN]; /* Image Name */ +} image_header_t; + + +#endif /* __IMAGE_H__ */ diff -puN scripts/mod/modpost.c~git-kbuild scripts/mod/modpost.c --- a/scripts/mod/modpost.c~git-kbuild +++ a/scripts/mod/modpost.c @@ -2,7 +2,7 @@ * * Copyright 2003 Kai Germaschewski * Copyright 2002-2004 Rusty Russell, IBM Corporation - * Copyright 2006 Sam Ravnborg + * Copyright 2006-2008 Sam Ravnborg * Based in part on module-init-tools/depmod.c,file2alias * * This software may be used and distributed according to the terms @@ -33,7 +33,9 @@ enum export { export_unused_gpl, export_gpl_future, export_unknown }; -void fatal(const char *fmt, ...) +#define PRINTF __attribute__ ((format (printf, 1, 2))) + +PRINTF void fatal(const char *fmt, ...) { va_list arglist; @@ -46,7 +48,7 @@ void fatal(const char *fmt, ...) exit(1); } -void warn(const char *fmt, ...) +PRINTF void warn(const char *fmt, ...) { va_list arglist; @@ -57,7 +59,7 @@ void warn(const char *fmt, ...) va_end(arglist); } -void merror(const char *fmt, ...) +PRINTF void merror(const char *fmt, ...) { va_list arglist; @@ -72,7 +74,8 @@ static int is_vmlinux(const char *modnam { const char *myname; - if ((myname = strrchr(modname, '/'))) + myname = strrchr(modname, '/'); + if (myname) myname++; else myname = modname; @@ -83,14 +86,13 @@ static int is_vmlinux(const char *modnam void *do_nofail(void *ptr, const char *expr) { - if (!ptr) { + if (!ptr) fatal("modpost: Memory allocation failure: %s.\n", expr); - } + return ptr; } /* A list of all modules we processed */ - static struct module *modules; static struct module *find_module(char *modname) @@ -113,7 +115,8 @@ static struct module *new_module(char *m p = NOFAIL(strdup(modname)); /* strip trailing .o */ - if ((s = strrchr(p, '.')) != NULL) + s = strrchr(p, '.'); + if (s != NULL) if (strcmp(s, ".o") == 0) *s = '\0'; @@ -154,7 +157,7 @@ static inline unsigned int tdb_hash(cons unsigned i; /* Used to cycle through random values. */ /* Set the initial value from the key size. */ - for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++) + for (value = 0x238F13AF * strlen(name), i = 0; name[i]; i++) value = (value + (((unsigned char *)name)[i] << (i*5 % 24))); return (1103515243 * value + 12345); @@ -198,7 +201,7 @@ static struct symbol *find_symbol(const if (name[0] == '.') name++; - for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s=s->next) { + for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s = s->next) { if (strcmp(s->name, name) == 0) return s; } @@ -223,9 +226,10 @@ static const char *export_str(enum expor return export_list[ex].str; } -static enum export export_no(const char * s) +static enum export export_no(const char *s) { int i; + if (!s) return export_unknown; for (i = 0; export_list[i].export != export_unknown; i++) { @@ -315,7 +319,7 @@ void *grab_file(const char *filename, un * spaces in the beginning of the line is trimmed away. * Return a pointer to a static buffer. **/ -char* get_next_line(unsigned long *pos, void *file, unsigned long size) +char *get_next_line(unsigned long *pos, void *file, unsigned long size) { static char line[4096]; int skip = 1; @@ -323,8 +327,7 @@ char* get_next_line(unsigned long *pos, signed char *p = (signed char *)file + *pos; char *s = line; - for (; *pos < size ; (*pos)++) - { + for (; *pos < size ; (*pos)++) { if (skip && isspace(*p)) { p++; continue; @@ -386,7 +389,9 @@ static int parse_elf(struct elf_info *in /* Check if file offset is correct */ if (hdr->e_shoff > info->size) { - fatal("section header offset=%u in file '%s' is bigger then filesize=%lu\n", hdr->e_shoff, filename, info->size); + fatal("section header offset=%lu in file '%s' is bigger than " + "filesize=%lu\n", (unsigned long)hdr->e_shoff, + filename, info->size); return 0; } @@ -407,7 +412,10 @@ static int parse_elf(struct elf_info *in const char *secname; if (sechdrs[i].sh_offset > info->size) { - fatal("%s is truncated. sechdrs[i].sh_offset=%u > sizeof(*hrd)=%ul\n", filename, (unsigned int)sechdrs[i].sh_offset, sizeof(*hdr)); + fatal("%s is truncated. sechdrs[i].sh_offset=%lu > " + "sizeof(*hrd)=%zu\n", filename, + (unsigned long)sechdrs[i].sh_offset, + sizeof(*hdr)); return 0; } secname = secstrings + sechdrs[i].sh_name; @@ -434,9 +442,9 @@ static int parse_elf(struct elf_info *in info->strtab = (void *)hdr + sechdrs[sechdrs[i].sh_link].sh_offset; } - if (!info->symtab_start) { + if (!info->symtab_start) fatal("%s has no symtab?\n", filename); - } + /* Fix endianness in symbols */ for (sym = info->symtab_start; sym < info->symtab_stop; sym++) { sym->st_shndx = TO_NATIVE(sym->st_shndx); @@ -505,11 +513,13 @@ static void handle_modversions(struct mo #endif if (memcmp(symname, MODULE_SYMBOL_PREFIX, - strlen(MODULE_SYMBOL_PREFIX)) == 0) - mod->unres = alloc_symbol(symname + - strlen(MODULE_SYMBOL_PREFIX), - ELF_ST_BIND(sym->st_info) == STB_WEAK, - mod->unres); + strlen(MODULE_SYMBOL_PREFIX)) == 0) { + mod->unres = + alloc_symbol(symname + + strlen(MODULE_SYMBOL_PREFIX), + ELF_ST_BIND(sym->st_info) == STB_WEAK, + mod->unres); + } break; default: /* All exported symbols */ @@ -578,21 +588,153 @@ static char *get_modinfo(void *modinfo, **/ static int strrcmp(const char *s, const char *sub) { - int slen, sublen; + int slen, sublen; if (!s || !sub) return 1; slen = strlen(s); - sublen = strlen(sub); + sublen = strlen(sub); if ((slen == 0) || (sublen == 0)) return 1; - if (sublen > slen) - return 1; + if (sublen > slen) + return 1; + + return memcmp(s + slen - sublen, sub, sublen); +} + +/* + * Simple pattern matching. + * If sym matches one of the patterns then return 1 - otherwise 0. + * The patterns most be terminated with a NULL. + * Simple wildcard functionality is implemented. + * A '*' may be used as wildcard in start and/or end of string + * to match anything. + */ +static int pattern_cmp(const char *sym, const char * const pat[]) +{ + const char *p; + while (*pat) { + p = *pat++; + const char *endp = p + strlen(p) - 1; + + /* "*foo" */ + if (*p == '*') { + if (strrcmp(sym, p + 1) == 0) + return 1; + } + /* "foo*" */ + else if (*endp == '*') { + if (strncmp(sym, p, strlen(p) - 1) == 0) + return 1; + } + /* "*foo*" */ + else if ((*p == '*') && (*endp == '*')) { + char *str = strdup(p + 1); + int len = strlen(str); + if (len) + *(str + len - 1) = '\0'; + if (strstr(sym, str)) + return 1; + } + /* no wildcards */ + else { + if (strcmp(p, sym) == 0) + return 1; + } + } + /* no match */ + return 0; +} + + +struct sectioncheck { + const char *fromsec[10]; + const char *tosec[10]; +}; + +const struct sectioncheck sectioncheck[] = { +/* Do not reference init/exit code/data from + * normal code and data + */ +{ + .fromsec = { + ".text", + ".text.*", + ".data", + ".data.*", + NULL + }, + .tosec = { + "*init.text", + "*init.data", + "*exit.text", + "*exit.data", + NULL + }, +}, +/* Do not use exit code/data from init code */ +{ + .fromsec = { + ".init.text", + ".init.data", + NULL + }, + .tosec = { + ".exit.text", + ".exit.data", + NULL + }, +}, +/* Do not use init code/data from exit code */ +{ + .fromsec = { + ".exit.text", + ".exit.data", + NULL + }, + .tosec = { + ".init.text", + ".init.data", + NULL + }, +}, +/* Do not export init/exit functions or data */ +{ + .fromsec = { + "__ksymtab*", + NULL + }, + .tosec = { + ".init.*", + ".exit*", + NULL + }, +} +}; + +/* + * Check if the reference fromsec => tosec is a potential + * candidate for a section mismatch. + * Find only the combinations we know are candidates and ignore + * the others. + * Returns 1 if we have found a potential section mismatch reference. + */ +static int bad_section_ref(const char *fromsec, const char *tosec) +{ + int i; + int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck); + const struct sectioncheck *check = §ioncheck[0]; - return memcmp(s + slen - sublen, sub, sublen); + for (i = 0; i < elems; i++) { + if (pattern_cmp(fromsec, check->fromsec) && + pattern_cmp(tosec, check->tosec)) + return 1; + check++; + } + return 0; } /* @@ -669,7 +811,8 @@ static int data_section(const char *name * the pattern is identified by: * tosec = init or exit section * fromsec = data section - * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer + * atsym = *driver, *_template, *_sht, *_ops, *_probe, + * *probe_one, *_console, *_timer * * Pattern 3: * Whitelist all refereces from .text.head to .init.data @@ -729,15 +872,16 @@ static int secref_whitelist(const char * return 1; /* Check for pattern 2 */ - if ((init_section(tosec) || exit_section(tosec)) && data_section(fromsec)) + if ((init_section(tosec) || exit_section(tosec)) + && data_section(fromsec)) for (s = pat2sym; *s; s++) if (strrcmp(atsym, *s) == 0) return 1; /* Check for pattern 3 */ if ((strcmp(fromsec, ".text.head") == 0) && - ((strcmp(tosec, ".init.data") == 0) || - (strcmp(tosec, ".init.text") == 0))) + ((strcmp(tosec, ".init.data") == 0) || + (strcmp(tosec, ".init.text") == 0))) return 1; /* Check for pattern 4 */ @@ -814,7 +958,7 @@ static inline int is_valid_name(struct e **/ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, const char *sec, - Elf_Sym **before, Elf_Sym **after) + Elf_Sym **before, Elf_Sym **after) { Elf_Sym *sym; Elf_Ehdr *hdr = elf->hdr; @@ -840,20 +984,15 @@ static void find_symbols_between(struct if ((addr - sym->st_value) < beforediff) { beforediff = addr - sym->st_value; *before = sym; - } - else if ((addr - sym->st_value) == beforediff) { + } else if ((addr - sym->st_value) == beforediff) { *before = sym; } - } - else - { + } else { if ((sym->st_value - addr) < afterdiff) { afterdiff = sym->st_value - addr; *after = sym; - } - else if ((sym->st_value - addr) == afterdiff) { + } else if ((sym->st_value - addr) == afterdiff) *after = sym; - } } } } @@ -905,7 +1044,8 @@ static void warn_sec_mismatch(const char "before '%s' (at offset -0x%llx)\n", modname, fromsec, (unsigned long long)r.r_offset, secname, refsymname, - elf->strtab + after->st_name); + elf->strtab + after->st_name, + (unsigned long long)r.r_offset); } else { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s\n", modname, fromsec, (unsigned long long)r.r_offset, @@ -949,12 +1089,14 @@ static int addend_arm_rel(struct elf_inf switch (r_typ) { case R_ARM_ABS32: /* From ARM ABI: (S + A) | T */ - r->r_addend = (int)(long)(elf->symtab_start + ELF_R_SYM(r->r_info)); + r->r_addend = (int)(long) + (elf->symtab_start + ELF_R_SYM(r->r_info)); break; case R_ARM_PC24: /* From ARM ABI: ((S + A) | T) - P */ - r->r_addend = (int)(long)(elf->hdr + elf->sechdrs[rsection].sh_offset + - (r->r_offset - elf->sechdrs[rsection].sh_addr)); + r->r_addend = (int)(long)(elf->hdr + + elf->sechdrs[rsection].sh_offset + + (r->r_offset - elf->sechdrs[rsection].sh_addr)); break; default: return 1; @@ -998,9 +1140,7 @@ static int addend_mips_rel(struct elf_in * be discarded and warns about it. **/ static void check_sec_ref(struct module *mod, const char *modname, - struct elf_info *elf, - int section(const char*), - int section_ref_ok(const char *)) + struct elf_info *elf) { int i; Elf_Sym *sym; @@ -1019,10 +1159,8 @@ static void check_sec_ref(struct module if (sechdrs[i].sh_type == SHT_RELA) { Elf_Rela *rela; Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset; - Elf_Rela *stop = (void*)start + sechdrs[i].sh_size; + Elf_Rela *stop = (void *)start + sechdrs[i].sh_size; name += strlen(".rela"); - if (section_ref_ok(name)) - continue; for (rela = start; rela < stop; rela++) { r.r_offset = TO_NATIVE(rela->r_offset); @@ -1049,17 +1187,15 @@ static void check_sec_ref(struct module secname = secstrings + sechdrs[sym->st_shndx].sh_name; - if (section(secname)) + if (bad_section_ref(name, secname)) warn_sec_mismatch(modname, name, elf, sym, r); } } else if (sechdrs[i].sh_type == SHT_REL) { Elf_Rel *rel; Elf_Rel *start = (void *)hdr + sechdrs[i].sh_offset; - Elf_Rel *stop = (void*)start + sechdrs[i].sh_size; + Elf_Rel *stop = (void *)start + sechdrs[i].sh_size; name += strlen(".rel"); - if (section_ref_ok(name)) - continue; for (rel = start; rel < stop; rel++) { r.r_offset = TO_NATIVE(rel->r_offset); @@ -1085,7 +1221,7 @@ static void check_sec_ref(struct module continue; break; case EM_ARM: - if(addend_arm_rel(elf, i, &r)) + if (addend_arm_rel(elf, i, &r)) continue; break; case EM_MIPS: @@ -1100,7 +1236,7 @@ static void check_sec_ref(struct module secname = secstrings + sechdrs[sym->st_shndx].sh_name; - if (section(secname)) + if (bad_section_ref(name, secname)) warn_sec_mismatch(modname, name, elf, sym, r); } @@ -1108,147 +1244,6 @@ static void check_sec_ref(struct module } } -/* - * Identify sections from which references to either a - * .init or a .exit section is OK. - * - * [OPD] Keith Ownes commented: - * For our future {in}sanity, add a comment that this is the ppc .opd - * section, not the ia64 .opd section. - * ia64 .opd should not point to discarded sections. - * [.rodata] like for .init.text we ignore .rodata references -same reason - */ -static int initexit_section_ref_ok(const char *name) -{ - const char **s; - /* Absolute section names */ - const char *namelist1[] = { - "__bug_table", /* used by powerpc for BUG() */ - "__ex_table", - ".altinstructions", - ".cranges", /* used by sh64 */ - ".fixup", - ".machvec", /* ia64 + powerpc uses these */ - ".machine.desc", - ".opd", /* See comment [OPD] */ - "__dbe_table", - ".parainstructions", - ".pdr", - ".plt", /* seen on ARCH=um build on x86_64. Harmless */ - ".smp_locks", - ".stab", - ".m68k_fixup", - ".xt.prop", /* xtensa informational section */ - ".xt.lit", /* xtensa informational section */ - NULL - }; - /* Start of section names */ - const char *namelist2[] = { - ".debug", - ".eh_frame", - ".note", /* ignore ELF notes - may contain anything */ - ".got", /* powerpc - global offset table */ - ".toc", /* powerpc - table of contents */ - NULL - }; - /* part of section name */ - const char *namelist3 [] = { - ".unwind", /* Sample: IA_64.unwind.exit.text */ - NULL - }; - - for (s = namelist1; *s; s++) - if (strcmp(*s, name) == 0) - return 1; - for (s = namelist2; *s; s++) - if (strncmp(*s, name, strlen(*s)) == 0) - return 1; - for (s = namelist3; *s; s++) - if (strstr(name, *s) != NULL) - return 1; - return 0; -} - - -/* - * Identify sections from which references to a .init section is OK. - * - * Unfortunately references to read only data that referenced .init - * sections had to be excluded. Almost all of these are false - * positives, they are created by gcc. The downside of excluding rodata - * is that there really are some user references from rodata to - * init code, e.g. drivers/video/vgacon.c: - * - * const struct consw vga_con = { - * con_startup: vgacon_startup, - * - * where vgacon_startup is __init. If you want to wade through the false - * positives, take out the check for rodata. - */ -static int init_section_ref_ok(const char *name) -{ - const char **s; - /* Absolute section names */ - const char *namelist1[] = { - "__dbe_table", /* MIPS generate these */ - "__ftr_fixup", /* powerpc cpu feature fixup */ - "__fw_ftr_fixup", /* powerpc firmware feature fixup */ - "__param", - ".data.rel.ro", /* used by parisc64 */ - ".init", - ".text.lock", - NULL - }; - /* Start of section names */ - const char *namelist2[] = { - ".init.", - ".pci_fixup", - ".rodata", - NULL - }; - - if (initexit_section_ref_ok(name)) - return 1; - - for (s = namelist1; *s; s++) - if (strcmp(*s, name) == 0) - return 1; - for (s = namelist2; *s; s++) - if (strncmp(*s, name, strlen(*s)) == 0) - return 1; - - /* If section name ends with ".init" we allow references - * as is the case with .initcallN.init, .early_param.init, .taglist.init etc - */ - if (strrcmp(name, ".init") == 0) - return 1; - return 0; -} - -/* - * Identify sections from which references to a .exit section is OK. - */ -static int exit_section_ref_ok(const char *name) -{ - const char **s; - /* Absolute section names */ - const char *namelist1[] = { - ".exit.data", - ".exit.text", - ".exitcall.exit", - ".rodata", - NULL - }; - - if (initexit_section_ref_ok(name)) - return 1; - - for (s = namelist1; *s; s++) - if (strcmp(*s, name) == 0) - return 1; - return 0; -} - static void read_symbols(char *modname) { const char *symname; @@ -1288,10 +1283,8 @@ static void read_symbols(char *modname) handle_modversions(mod, &info, sym, symname); handle_moddevtable(mod, &info, sym, symname); } - if (is_vmlinux(modname) && vmlinux_section_warnings) { - check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok); - check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok); - } + if (is_vmlinux(modname) && vmlinux_section_warnings) + check_sec_ref(mod, modname, &info); version = get_modinfo(info.modinfo, info.modinfo_len, "version"); if (version) @@ -1365,7 +1358,7 @@ static void check_for_gpl_usage(enum exp } } -static void check_for_unused(enum export exp, const char* m, const char* s) +static void check_for_unused(enum export exp, const char *m, const char *s) { const char *e = is_vmlinux(m) ?"":".ko"; @@ -1398,7 +1391,7 @@ static void check_exports(struct module if (!mod->gpl_compatible) check_for_gpl_usage(exp->export, basename, exp->name); check_for_unused(exp->export, basename, exp->name); - } + } } /** @@ -1462,9 +1455,8 @@ static int add_versions(struct buffer *b buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n"); for (s = mod->unres; s; s = s->next) { - if (!s->module) { + if (!s->module) continue; - } if (!s->crc_valid) { warn("\"%s\" [%s.ko] has no CRC!\n", s->name, mod->name); @@ -1485,9 +1477,8 @@ static void add_depends(struct buffer *b struct module *m; int first = 1; - for (m = modules; m; m = m->next) { + for (m = modules; m; m = m->next) m->seen = is_vmlinux(m->name); - } buf_printf(b, "\n"); buf_printf(b, "static const char __module_depends[]\n"); @@ -1503,7 +1494,8 @@ static void add_depends(struct buffer *b continue; s->module->seen = 1; - if ((p = strrchr(s->module->name, '/')) != NULL) + p = strrchr(s->module->name, '/'); + if (p) p++; else p = s->module->name; @@ -1575,7 +1567,7 @@ static void read_dump(const char *fname, void *file = grab_file(fname, &size); char *line; - if (!file) + if (!file) /* No symbol versions, silently ignore */ return; @@ -1598,11 +1590,10 @@ static void read_dump(const char *fname, crc = strtoul(line, &d, 16); if (*symname == '\0' || *modname == '\0' || *d != '\0') goto fail; - - if (!(mod = find_module(modname))) { - if (is_vmlinux(modname)) { + mod = find_module(modname); + if (!mod) { + if (is_vmlinux(modname)) have_vmlinux = 1; - } mod = new_module(NOFAIL(strdup(modname))); mod->skip = 1; } @@ -1653,38 +1644,37 @@ int main(int argc, char **argv) { struct module *mod; struct buffer buf = { }; - char fname[SZ]; char *kernel_read = NULL, *module_read = NULL; char *dump_write = NULL; int opt; int err; while ((opt = getopt(argc, argv, "i:I:mso:aw")) != -1) { - switch(opt) { - case 'i': - kernel_read = optarg; - break; - case 'I': - module_read = optarg; - external_module = 1; - break; - case 'm': - modversions = 1; - break; - case 'o': - dump_write = optarg; - break; - case 'a': - all_versions = 1; - break; - case 's': - vmlinux_section_warnings = 0; - break; - case 'w': - warn_unresolved = 1; - break; - default: - exit(1); + switch (opt) { + case 'i': + kernel_read = optarg; + break; + case 'I': + module_read = optarg; + external_module = 1; + break; + case 'm': + modversions = 1; + break; + case 'o': + dump_write = optarg; + break; + case 'a': + all_versions = 1; + break; + case 's': + vmlinux_section_warnings = 0; + break; + case 'w': + warn_unresolved = 1; + break; + default: + exit(1); } } @@ -1693,9 +1683,8 @@ int main(int argc, char **argv) if (module_read) read_dump(module_read, 0); - while (optind < argc) { + while (optind < argc) read_symbols(argv[optind++]); - } for (mod = modules; mod; mod = mod->next) { if (mod->skip) @@ -1706,6 +1695,8 @@ int main(int argc, char **argv) err = 0; for (mod = modules; mod; mod = mod->next) { + char fname[strlen(mod->name) + 10]; + if (mod->skip) continue; diff -puN scripts/package/Makefile~git-kbuild scripts/package/Makefile --- a/scripts/package/Makefile~git-kbuild +++ a/scripts/package/Makefile @@ -89,9 +89,8 @@ clean-dirs += $(objtree)/tar-install/ # Help text displayed when executing 'make help' # --------------------------------------------------------------------------- help: FORCE - @echo ' rpm-pkg - Build the kernel as an RPM package' - @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel' - @echo ' and modules' + @echo ' rpm-pkg - Build both source and binary RPM kernel packages' + @echo ' binrpm-pkg - Build only the binary kernel package' @echo ' deb-pkg - Build the kernel as an deb package' @echo ' tar-pkg - Build the kernel as an uncompressed tarball' @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' diff -puN scripts/patch-kernel~git-kbuild scripts/patch-kernel --- a/scripts/patch-kernel~git-kbuild +++ a/scripts/patch-kernel @@ -65,7 +65,7 @@ sourcedir=${1-/usr/src/linux} patchdir=${2-.} stopvers=${3-default} -if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then +if [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then cat << USAGE usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ] source directory defaults to /usr/src/linux, @@ -182,10 +182,12 @@ reversePatch () { } # set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION -TMPFILE=`mktemp .tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; } +# force $TMPFILEs below to be in local directory: a slash character prevents +# the dot command from using the search path. +TMPFILE=`mktemp ./.tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; } grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE tr -d [:blank:] < $TMPFILE > $TMPFILE.1 -source $TMPFILE.1 +. $TMPFILE.1 rm -f $TMPFILE* if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ] then @@ -202,11 +204,7 @@ echo "Current kernel version is $VERSION EXTRAVER= if [ x$EXTRAVERSION != "x" ] then - if [ ${EXTRAVERSION:0:1} == "." ]; then - EXTRAVER=${EXTRAVERSION:1} - else - EXTRAVER=$EXTRAVERSION - fi + EXTRAVER=${EXTRAVERSION#.} EXTRAVER=${EXTRAVER%%[[:punct:]]*} #echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER" fi @@ -251,16 +249,16 @@ while : # incrementing SUBLEVEL (s in do CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" EXTRAVER= - if [ $stopvers == $CURRENTFULLVERSION ]; then + if [ $stopvers = $CURRENTFULLVERSION ]; then echo "Stopping at $CURRENTFULLVERSION base as requested." break fi - SUBLEVEL=$((SUBLEVEL + 1)) + SUBLEVEL=$(($SUBLEVEL + 1)) FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" #echo "#___ trying $FULLVERSION ___" - if [ $((SUBLEVEL)) -gt $((STOPSUBLEVEL)) ]; then + if [ $(($SUBLEVEL)) -gt $(($STOPSUBLEVEL)) ]; then echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)" exit 1 fi @@ -297,7 +295,7 @@ fi if [ x$gotac != x ]; then # Out great user wants the -ac patches # They could have done -ac (get latest) or -acxx where xx=version they want - if [ $gotac == "-ac" ]; then + if [ $gotac = "-ac" ]; then # They want the latest version HIGHESTPATCH=0 for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.* diff -puN scripts/setlocalversion~git-kbuild scripts/setlocalversion --- a/scripts/setlocalversion~git-kbuild +++ a/scripts/setlocalversion @@ -12,11 +12,36 @@ cd "${1:-.}" || usage if head=`git rev-parse --verify HEAD 2>/dev/null`; then # Do we have an untagged version? if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then - printf '%s%s' -g `echo "$head" | cut -c1-8` + git describe | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' fi # Are there uncommitted changes? - if git diff-index HEAD | read dummy; then + git update-index --refresh --unmerged > /dev/null + if git diff-index --name-only HEAD | grep -v "^scripts/package" \ + | read dummy; then printf '%s' -dirty fi + + # All done with git + exit +fi + +# Check for mercurial and a mercurial repo. +if hgid=`hg id 2>/dev/null`; then + tag=`printf '%s' "$hgid" | cut -d' ' -f2` + + # Do we have an untagged version? + if [ -z "$tag" -o "$tag" = tip ]; then + id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` + printf '%s%s' -hg "$id" + fi + + # Are there uncommitted changes? + # These are represented by + after the changeset id. + case "$hgid" in + *+|*+\ *) printf '%s' -dirty ;; + esac + + # All done with mercurial + exit fi _