aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Config.in104
-rw-r--r--Makefile1620
-rw-r--r--Makefile.custom131
-rw-r--r--Makefile.flags19
-rw-r--r--Makefile.help88
-rw-r--r--Rules.mak436
-rw-r--r--applets/Kbuild9
-rw-r--r--applets/Makefile23
-rw-r--r--applets/Makefile.in26
-rw-r--r--applets/applets.c2
-rw-r--r--archival/Config.in100
-rw-r--r--archival/Kbuild22
-rw-r--r--archival/Makefile23
-rw-r--r--archival/Makefile.in41
-rw-r--r--archival/libunarchive/Kbuild59
-rw-r--r--archival/libunarchive/Makefile36
-rw-r--r--archival/libunarchive/Makefile.in83
-rw-r--r--console-tools/Config.in26
-rw-r--r--console-tools/Kbuild18
-rw-r--r--console-tools/Makefile23
-rw-r--r--console-tools/Makefile.in38
-rw-r--r--coreutils/Config.in300
-rw-r--r--coreutils/Kbuild81
-rw-r--r--coreutils/Makefile23
-rw-r--r--coreutils/Makefile.in102
-rw-r--r--coreutils/diff.c5
-rw-r--r--coreutils/id.c1
-rw-r--r--coreutils/libcoreutils/Kbuild12
-rw-r--r--coreutils/libcoreutils/Makefile37
-rw-r--r--coreutils/libcoreutils/Makefile.in39
-rw-r--r--debianutils/Config.in28
-rw-r--r--debianutils/Kbuild13
-rw-r--r--debianutils/Makefile23
-rw-r--r--debianutils/Makefile.in33
-rw-r--r--e2fsprogs/Config.in20
-rw-r--r--e2fsprogs/Kbuild27
-rw-r--r--e2fsprogs/Makefile22
-rw-r--r--e2fsprogs/Makefile.in86
-rw-r--r--e2fsprogs/blkid/Kbuild18
-rw-r--r--e2fsprogs/blkid/blkid_getsize.c2
-rw-r--r--e2fsprogs/blkid/devname.c2
-rw-r--r--e2fsprogs/blkid/devno.c2
-rw-r--r--e2fsprogs/e2p/Kbuild10
-rw-r--r--e2fsprogs/e2p/fgetsetflags.c2
-rw-r--r--e2fsprogs/ext2fs/Kbuild18
-rw-r--r--e2fsprogs/tune2fs.c2
-rw-r--r--e2fsprogs/uuid/Kbuild9
-rw-r--r--e2fsprogs/uuid/gen_uuid.c1
-rw-r--r--editors/Config.in54
-rw-r--r--editors/Kbuild12
-rw-r--r--editors/Makefile23
-rw-r--r--editors/Makefile.in40
-rw-r--r--findutils/Config.in70
-rw-r--r--findutils/Kbuild10
-rw-r--r--findutils/Makefile23
-rw-r--r--findutils/Makefile.in31
-rw-r--r--include/bb_config.h142
-rw-r--r--include/busybox.h2
-rw-r--r--include/grp_.h2
-rw-r--r--include/libbb.h1
-rw-r--r--init/Config.in32
-rw-r--r--init/Kbuild12
-rw-r--r--init/Makefile23
-rw-r--r--init/Makefile.in43
-rw-r--r--libbb/Config.in4
-rw-r--r--libbb/Kbuild61
-rw-r--r--libbb/Makefile29
-rw-r--r--libbb/Makefile.in155
-rw-r--r--libbb/bb_pwd.c46
-rw-r--r--libbb/llist.c8
-rw-r--r--libbb/messages.c107
-rw-r--r--libbb/printf.c8
-rw-r--r--libbb/safe_strtol.c13
-rw-r--r--libbb/xfuncs.c67
-rw-r--r--libbb/xgetularg.c12
-rw-r--r--libpwdgrp/Kbuild7
-rw-r--r--libpwdgrp/Makefile23
-rw-r--r--libpwdgrp/Makefile.in51
-rw-r--r--libpwdgrp/pwd_grp.c131
-rw-r--r--libpwdgrp/pwd_grp_internal.c87
-rw-r--r--loginutils/Config.in68
-rw-r--r--loginutils/Kbuild17
-rw-r--r--loginutils/Makefile23
-rw-r--r--loginutils/Makefile.in52
-rw-r--r--miscutils/Config.in128
-rw-r--r--miscutils/Kbuild27
-rw-r--r--miscutils/Makefile23
-rw-r--r--miscutils/Makefile.in55
-rw-r--r--miscutils/rx.c5
-rw-r--r--modutils/Config.in62
-rw-r--r--modutils/Kbuild11
-rw-r--r--modutils/Makefile23
-rw-r--r--modutils/Makefile.in32
-rw-r--r--networking/Config.in326
-rw-r--r--networking/Kbuild38
-rw-r--r--networking/Makefile23
-rw-r--r--networking/Makefile.in70
-rw-r--r--networking/libiproute/Kbuild58
-rw-r--r--networking/libiproute/Makefile36
-rw-r--r--networking/libiproute/Makefile.in83
-rw-r--r--networking/udhcp/Config.in18
-rw-r--r--networking/udhcp/Kbuild17
-rw-r--r--networking/udhcp/Makefile23
-rw-r--r--networking/udhcp/Makefile.in53
-rw-r--r--procps/Config.in42
-rw-r--r--procps/Kbuild16
-rw-r--r--procps/Makefile23
-rw-r--r--procps/Makefile.in37
-rw-r--r--runit/Config.in10
-rw-r--r--runit/Kbuild8
-rw-r--r--runit/Makefile23
-rw-r--r--runit/Makefile.in42
-rw-r--r--scripts/Kbuild11
-rw-r--r--scripts/Kbuild.include148
-rw-r--r--scripts/Makefile.build338
-rw-r--r--scripts/Makefile.host156
-rw-r--r--scripts/Makefile.lib165
-rw-r--r--scripts/basic/Makefile18
-rw-r--r--scripts/basic/docproc.c398
-rw-r--r--scripts/basic/fixdep.c393
-rw-r--r--scripts/basic/split-include.c226
-rw-r--r--scripts/config/Kconfig-language.txt255
-rw-r--r--scripts/config/Makefile122
-rw-r--r--scripts/config/lex.zconf.c_shipped3688
-rw-r--r--scripts/config/lxdialog/checklist.c373
-rw-r--r--scripts/config/lxdialog/inputbox.c241
-rw-r--r--scripts/config/lxdialog/menubox.c439
-rw-r--r--scripts/config/lxdialog/msgbox.c86
-rw-r--r--scripts/config/lxdialog/textbox.c557
-rw-r--r--scripts/config/lxdialog/util.c376
-rw-r--r--scripts/config/lxdialog/yesno.c119
-rw-r--r--scripts/config/zconf.tab.h_shipped125
-rw-r--r--scripts/kconfig/Makefile254
-rw-r--r--scripts/kconfig/POTFILES.in5
-rw-r--r--scripts/kconfig/conf.c (renamed from scripts/config/conf.c)70
-rw-r--r--scripts/kconfig/confdata.c (renamed from scripts/config/confdata.c)321
-rw-r--r--scripts/kconfig/expr.c (renamed from scripts/config/expr.c)3
-rw-r--r--scripts/kconfig/expr.h (renamed from scripts/config/expr.h)2
-rw-r--r--scripts/kconfig/gconf.c1645
-rw-r--r--scripts/kconfig/gconf.glade648
-rw-r--r--scripts/kconfig/images.c326
-rw-r--r--scripts/kconfig/kconfig_load.c35
-rw-r--r--scripts/kconfig/kxgettext.c227
-rw-r--r--scripts/kconfig/lex.zconf.c_shipped2317
-rw-r--r--scripts/kconfig/lkc.h (renamed from scripts/config/lkc.h)31
-rw-r--r--scripts/kconfig/lkc_proto.h (renamed from scripts/config/lkc_proto.h)2
-rw-r--r--scripts/kconfig/lxdialog/BIG.FAT.WARNING (renamed from scripts/config/lxdialog/BIG.FAT.WARNING)2
-rw-r--r--scripts/kconfig/lxdialog/Makefile21
-rw-r--r--scripts/kconfig/lxdialog/check-lxdialog.sh84
-rw-r--r--scripts/kconfig/lxdialog/checklist.c333
-rw-r--r--scripts/kconfig/lxdialog/colors.h (renamed from scripts/config/lxdialog/colors.h)8
-rw-r--r--scripts/kconfig/lxdialog/dialog.h (renamed from scripts/config/lxdialog/dialog.h)81
-rw-r--r--scripts/kconfig/lxdialog/inputbox.c224
-rw-r--r--scripts/kconfig/lxdialog/lxdialog.c204
-rw-r--r--scripts/kconfig/lxdialog/menubox.c426
-rw-r--r--scripts/kconfig/lxdialog/msgbox.c71
-rw-r--r--scripts/kconfig/lxdialog/textbox.c533
-rw-r--r--scripts/kconfig/lxdialog/util.c362
-rw-r--r--scripts/kconfig/lxdialog/yesno.c102
-rw-r--r--scripts/kconfig/mconf.c (renamed from scripts/config/mconf.c)576
-rw-r--r--scripts/kconfig/menu.c (renamed from scripts/config/menu.c)26
-rw-r--r--scripts/kconfig/qconf.cc1426
-rw-r--r--scripts/kconfig/qconf.h263
-rw-r--r--scripts/kconfig/symbol.c (renamed from scripts/config/symbol.c)96
-rw-r--r--scripts/kconfig/util.c (renamed from scripts/config/util.c)11
-rw-r--r--scripts/kconfig/zconf.gperf43
-rw-r--r--scripts/kconfig/zconf.hash.c_shipped231
-rw-r--r--scripts/kconfig/zconf.l (renamed from scripts/config/zconf.l)96
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped (renamed from scripts/config/zconf.tab.c_shipped)1175
-rw-r--r--scripts/kconfig/zconf.y (renamed from scripts/config/zconf.y)323
-rwxr-xr-xscripts/mkconfigs (renamed from scripts/config/mkconfigs)0
-rwxr-xr-xscripts/trylink18
-rw-r--r--scripts/usage.c8
-rwxr-xr-x[-rw-r--r--]scripts/usage_compressed14
-rw-r--r--shell/Config.in148
-rw-r--r--shell/Kbuild12
-rw-r--r--shell/Makefile23
-rw-r--r--shell/Makefile.in33
-rw-r--r--shell/ash.c2
-rw-r--r--shell/cmdedit.c5
-rw-r--r--sysklogd/Config.in36
-rw-r--r--sysklogd/Kbuild11
-rw-r--r--sysklogd/Makefile22
-rw-r--r--sysklogd/Makefile.in32
-rw-r--r--util-linux/Config.in156
-rw-r--r--util-linux/Kbuild32
-rw-r--r--util-linux/Makefile22
-rw-r--r--util-linux/Makefile.in62
188 files changed, 16367 insertions, 11752 deletions
diff --git a/Config.in b/Config.in
index d61b6ff89..f888be9ad 100644
--- a/Config.in
+++ b/Config.in
@@ -13,7 +13,7 @@ menu "Busybox Settings"
13 13
14menu "General Configuration" 14menu "General Configuration"
15 15
16config CONFIG_NITPICK 16config NITPICK
17 bool "See lots more (probably unnecessary) configuration options." 17 bool "See lots more (probably unnecessary) configuration options."
18 default n 18 default n
19 help 19 help
@@ -29,7 +29,7 @@ config CONFIG_NITPICK
29 29
30 You have been warned. 30 You have been warned.
31 31
32config CONFIG_DESKTOP 32config DESKTOP
33 bool "Enable options for full-blown desktop systems." 33 bool "Enable options for full-blown desktop systems."
34 default n 34 default n
35 help 35 help
@@ -39,8 +39,8 @@ config CONFIG_DESKTOP
39 39
40choice 40choice
41 prompt "Buffer allocation policy" 41 prompt "Buffer allocation policy"
42 default CONFIG_FEATURE_BUFFERS_USE_MALLOC 42 default FEATURE_BUFFERS_USE_MALLOC
43 depends on CONFIG_NITPICK 43 depends on NITPICK
44 help 44 help
45 There are 3 ways BusyBox can handle buffer allocations: 45 There are 3 ways BusyBox can handle buffer allocations:
46 - Use malloc. This costs code size for the call to xmalloc. 46 - Use malloc. This costs code size for the call to xmalloc.
@@ -51,18 +51,18 @@ choice
51 behavior was the only one available for BusyBox versions 0.48 and 51 behavior was the only one available for BusyBox versions 0.48 and
52 earlier. 52 earlier.
53 53
54config CONFIG_FEATURE_BUFFERS_USE_MALLOC 54config FEATURE_BUFFERS_USE_MALLOC
55 bool "Allocate with Malloc" 55 bool "Allocate with Malloc"
56 56
57config CONFIG_FEATURE_BUFFERS_GO_ON_STACK 57config FEATURE_BUFFERS_GO_ON_STACK
58 bool "Allocate on the Stack" 58 bool "Allocate on the Stack"
59 59
60config CONFIG_FEATURE_BUFFERS_GO_IN_BSS 60config FEATURE_BUFFERS_GO_IN_BSS
61 bool "Allocate in the .bss section" 61 bool "Allocate in the .bss section"
62 62
63endchoice 63endchoice
64 64
65config CONFIG_SHOW_USAGE 65config SHOW_USAGE
66 bool "Show terse applet usage messages" 66 bool "Show terse applet usage messages"
67 default y 67 default y
68 help 68 help
@@ -71,20 +71,20 @@ config CONFIG_SHOW_USAGE
71 messages if you say no here. 71 messages if you say no here.
72 This will save you up to 7k. 72 This will save you up to 7k.
73 73
74config CONFIG_FEATURE_VERBOSE_USAGE 74config FEATURE_VERBOSE_USAGE
75 bool "Show verbose applet usage messages" 75 bool "Show verbose applet usage messages"
76 default n 76 default n
77 select CONFIG_SHOW_USAGE 77 select SHOW_USAGE
78 help 78 help
79 All BusyBox applets will show more verbose help messages when 79 All BusyBox applets will show more verbose help messages when
80 busybox is invoked with --help. This will add a lot of text to the 80 busybox is invoked with --help. This will add a lot of text to the
81 busybox binary. In the default configuration, this will add about 81 busybox binary. In the default configuration, this will add about
82 13k, but it can add much more depending on your configuration. 82 13k, but it can add much more depending on your configuration.
83 83
84config CONFIG_FEATURE_COMPRESS_USAGE 84config FEATURE_COMPRESS_USAGE
85 bool "Store applet usage messages in compressed form" 85 bool "Store applet usage messages in compressed form"
86 default y 86 default y
87 depends on CONFIG_SHOW_USAGE 87 depends on SHOW_USAGE
88 help 88 help
89 Store usage messages in compressed form, uncompress them on-the-fly 89 Store usage messages in compressed form, uncompress them on-the-fly
90 when <applet> --help is called. 90 when <applet> --help is called.
@@ -95,7 +95,7 @@ config CONFIG_FEATURE_COMPRESS_USAGE
95 and have very little memory, this might not be a win. Otherwise, 95 and have very little memory, this might not be a win. Otherwise,
96 you probably want this. 96 you probably want this.
97 97
98config CONFIG_FEATURE_INSTALLER 98config FEATURE_INSTALLER
99 bool "Support --install [-s] to install applet links at runtime" 99 bool "Support --install [-s] to install applet links at runtime"
100 default n 100 default n
101 help 101 help
@@ -104,14 +104,14 @@ config CONFIG_FEATURE_INSTALLER
104 applets that are compiled into busybox. This feature requires the 104 applets that are compiled into busybox. This feature requires the
105 /proc filesystem. 105 /proc filesystem.
106 106
107config CONFIG_LOCALE_SUPPORT 107config LOCALE_SUPPORT
108 bool "Enable locale support (system needs locale for this to work)" 108 bool "Enable locale support (system needs locale for this to work)"
109 default n 109 default n
110 help 110 help
111 Enable this if your system has locale support and you would like 111 Enable this if your system has locale support and you would like
112 busybox to support locale settings. 112 busybox to support locale settings.
113 113
114config CONFIG_GETOPT_LONG 114config GETOPT_LONG
115 bool 115 bool
116 default y 116 default y
117# bool "Enable support for --long-options" 117# bool "Enable support for --long-options"
@@ -120,7 +120,7 @@ config CONFIG_GETOPT_LONG
120# Enable this if you want busybox applets to use the gnu --long-option 120# Enable this if you want busybox applets to use the gnu --long-option
121# style, in addition to single character -a -b -c style options. 121# style, in addition to single character -a -b -c style options.
122 122
123config CONFIG_FEATURE_DEVPTS 123config FEATURE_DEVPTS
124 bool "Use the devpts filesystem for Unix98 PTYs" 124 bool "Use the devpts filesystem for Unix98 PTYs"
125 default y 125 default y
126 help 126 help
@@ -130,10 +130,10 @@ config CONFIG_FEATURE_DEVPTS
130 /dev/ttyp<number> will be used. To use this option, you should have 130 /dev/ttyp<number> will be used. To use this option, you should have
131 devpts mounted. 131 devpts mounted.
132 132
133config CONFIG_FEATURE_CLEAN_UP 133config FEATURE_CLEAN_UP
134 bool "Clean up all memory before exiting (usually not needed)" 134 bool "Clean up all memory before exiting (usually not needed)"
135 default n 135 default n
136 depends on CONFIG_NITPICK 136 depends on NITPICK
137 help 137 help
138 As a size optimization, busybox normally exits without explicitly 138 As a size optimization, busybox normally exits without explicitly
139 freeing dynamically allocated memory or closing files. This saves 139 freeing dynamically allocated memory or closing files. This saves
@@ -143,7 +143,7 @@ config CONFIG_FEATURE_CLEAN_UP
143 Don't enable this unless you have a really good reason to clean 143 Don't enable this unless you have a really good reason to clean
144 things up manually. 144 things up manually.
145 145
146config CONFIG_FEATURE_SUID 146config FEATURE_SUID
147 bool "Support for SUID/SGID handling" 147 bool "Support for SUID/SGID handling"
148 default n 148 default n
149 help 149 help
@@ -158,17 +158,17 @@ config CONFIG_FEATURE_SUID
158 are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs, 158 are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
159 and vlock. 159 and vlock.
160 160
161config CONFIG_FEATURE_SYSLOG 161config FEATURE_SYSLOG
162 bool "Support for syslog" 162 bool "Support for syslog"
163 default n 163 default n
164 help 164 help
165 This option is auto-selected when you select any applet which may 165 This option is auto-selected when you select any applet which may
166 send its output to syslog. You do not need to select it manually. 166 send its output to syslog. You do not need to select it manually.
167 167
168config CONFIG_FEATURE_SUID_CONFIG 168config FEATURE_SUID_CONFIG
169 bool "Runtime SUID/SGID configuration via /etc/busybox.conf" 169 bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
170 default n if CONFIG_FEATURE_SUID 170 default n if FEATURE_SUID
171 depends on CONFIG_FEATURE_SUID 171 depends on FEATURE_SUID
172 help 172 help
173 Allow the SUID / SGID state of an applet to be determined at runtime 173 Allow the SUID / SGID state of an applet to be determined at runtime
174 by checking /etc/busybox.conf. (This is sort of a poor man's sudo.) 174 by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
@@ -197,15 +197,15 @@ config CONFIG_FEATURE_SUID_CONFIG
197 Robert 'sandman' Griebl has more information here: 197 Robert 'sandman' Griebl has more information here:
198 <url: http://www.softforge.de/bb/suid.html >. 198 <url: http://www.softforge.de/bb/suid.html >.
199 199
200config CONFIG_FEATURE_SUID_CONFIG_QUIET 200config FEATURE_SUID_CONFIG_QUIET
201 bool "Suppress warning message if /etc/busybox.conf is not readable" 201 bool "Suppress warning message if /etc/busybox.conf is not readable"
202 default y 202 default y
203 depends on CONFIG_FEATURE_SUID_CONFIG 203 depends on FEATURE_SUID_CONFIG
204 help 204 help
205 /etc/busybox.conf should be readable by the user needing the SUID, check 205 /etc/busybox.conf should be readable by the user needing the SUID, check
206 this option to avoid users to be notified about missing permissions. 206 this option to avoid users to be notified about missing permissions.
207 207
208config CONFIG_SELINUX 208config SELINUX
209 bool "Support NSA Security Enhanced Linux" 209 bool "Support NSA Security Enhanced Linux"
210 default n 210 default n
211 help 211 help
@@ -225,7 +225,7 @@ config CONFIG_SELINUX
225 225
226 Most people will leave this set to 'N'. 226 Most people will leave this set to 'N'.
227 227
228config CONFIG_BUSYBOX_EXEC_PATH 228config BUSYBOX_EXEC_PATH
229 string "Path to BusyBox executable" 229 string "Path to BusyBox executable"
230 default "/proc/self/exe" 230 default "/proc/self/exe"
231 help 231 help
@@ -239,7 +239,7 @@ endmenu
239 239
240menu 'Build Options' 240menu 'Build Options'
241 241
242config CONFIG_STATIC 242config STATIC
243 bool "Build BusyBox as a static binary (no shared libs)" 243 bool "Build BusyBox as a static binary (no shared libs)"
244 default n 244 default n
245 help 245 help
@@ -253,7 +253,7 @@ config CONFIG_STATIC
253 253
254 Most people will leave this set to 'N'. 254 Most people will leave this set to 'N'.
255 255
256config CONFIG_BUILD_LIBBUSYBOX 256config BUILD_LIBBUSYBOX
257 bool "Build shared libbusybox" 257 bool "Build shared libbusybox"
258 default n 258 default n
259 help 259 help
@@ -265,10 +265,10 @@ config CONFIG_BUILD_LIBBUSYBOX
265 binary serves no purpose (and increases the size). You should 265 binary serves no purpose (and increases the size). You should
266 almost certainly say "no" to this right now. 266 almost certainly say "no" to this right now.
267 267
268config CONFIG_FEATURE_FULL_LIBBUSYBOX 268config FEATURE_FULL_LIBBUSYBOX
269 bool "Feature-complete libbusybox" 269 bool "Feature-complete libbusybox"
270 default n if !CONFIG_FEATURE_SHARED_BUSYBOX 270 default n if !FEATURE_SHARED_BUSYBOX
271 depends on CONFIG_BUILD_LIBBUSYBOX 271 depends on BUILD_LIBBUSYBOX
272 help 272 help
273 Build a libbusybox with the complete feature-set, disregarding 273 Build a libbusybox with the complete feature-set, disregarding
274 the actually selected config. 274 the actually selected config.
@@ -284,15 +284,15 @@ config CONFIG_FEATURE_FULL_LIBBUSYBOX
284 284
285 Say 'N' if in doubt. 285 Say 'N' if in doubt.
286 286
287config CONFIG_FEATURE_SHARED_BUSYBOX 287config FEATURE_SHARED_BUSYBOX
288 bool "Use shared libbusybox for busybox" 288 bool "Use shared libbusybox for busybox"
289 default y if CONFIG_BUILD_LIBBUSYBOX 289 default y if BUILD_LIBBUSYBOX
290 depends on !CONFIG_STATIC && CONFIG_BUILD_LIBBUSYBOX 290 depends on !STATIC && BUILD_LIBBUSYBOX
291 help 291 help
292 Use libbusybox.so also for busybox itself. 292 Use libbusybox.so also for busybox itself.
293 You need to have a working dynamic linker to use this variant. 293 You need to have a working dynamic linker to use this variant.
294 294
295config CONFIG_LFS 295config LFS
296 bool "Build with Large File Support (for accessing files > 2 GB)" 296 bool "Build with Large File Support (for accessing files > 2 GB)"
297 default n 297 default n
298 select FDISK_SUPPORT_LARGE_DISKS 298 select FDISK_SUPPORT_LARGE_DISKS
@@ -304,7 +304,7 @@ config CONFIG_LFS
304 cp, mount, tar, and many others. If you want to access files larger 304 cp, mount, tar, and many others. If you want to access files larger
305 than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'. 305 than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
306 306
307config CONFIG_BUILD_AT_ONCE 307config BUILD_AT_ONCE
308 bool "Compile all sources at once" 308 bool "Compile all sources at once"
309 default n 309 default n
310 help 310 help
@@ -327,7 +327,7 @@ endmenu
327 327
328menu 'Debugging Options' 328menu 'Debugging Options'
329 329
330config CONFIG_DEBUG 330config DEBUG
331 bool "Build BusyBox with extra Debugging symbols" 331 bool "Build BusyBox with extra Debugging symbols"
332 default n 332 default n
333 help 333 help
@@ -338,10 +338,10 @@ config CONFIG_DEBUG
338 338
339 Most people should answer N. 339 Most people should answer N.
340 340
341config CONFIG_DEBUG_PESSIMIZE 341config DEBUG_PESSIMIZE
342 bool "Disable compiler optimizations." 342 bool "Disable compiler optimizations."
343 default n 343 default n
344 depends on CONFIG_DEBUG 344 depends on DEBUG
345 help 345 help
346 The compiler's optimization of source code can eliminate and reorder 346 The compiler's optimization of source code can eliminate and reorder
347 code, resulting in an executable that's hard to understand when 347 code, resulting in an executable that's hard to understand when
@@ -351,8 +351,8 @@ config CONFIG_DEBUG_PESSIMIZE
351 351
352choice 352choice
353 prompt "Additional debugging library" 353 prompt "Additional debugging library"
354 default CONFIG_NO_DEBUG_LIB 354 default NO_DEBUG_LIB
355 depends on CONFIG_DEBUG 355 depends on DEBUG
356 help 356 help
357 Using an additional debugging library will make BusyBox become 357 Using an additional debugging library will make BusyBox become
358 considerable larger and will cause it to run more slowly. You 358 considerable larger and will cause it to run more slowly. You
@@ -380,18 +380,18 @@ choice
380 you are hunting a hard to find memory problem. 380 you are hunting a hard to find memory problem.
381 381
382 382
383config CONFIG_NO_DEBUG_LIB 383config NO_DEBUG_LIB
384 bool "None" 384 bool "None"
385 385
386config CONFIG_DMALLOC 386config DMALLOC
387 bool "Dmalloc" 387 bool "Dmalloc"
388 388
389config CONFIG_EFENCE 389config EFENCE
390 bool "Electric-fence" 390 bool "Electric-fence"
391 391
392endchoice 392endchoice
393 393
394config CONFIG_DEBUG_YANK_SUSv2 394config DEBUG_YANK_SUSv2
395 bool "Disable obsolete features removed before SUSv3?" 395 bool "Disable obsolete features removed before SUSv3?"
396 default y 396 default y
397 help 397 help
@@ -404,7 +404,7 @@ endmenu
404 404
405menu 'Installation Options' 405menu 'Installation Options'
406 406
407config CONFIG_INSTALL_NO_USR 407config INSTALL_NO_USR
408 bool "Don't use /usr" 408 bool "Don't use /usr"
409 default n 409 default n
410 help 410 help
@@ -413,27 +413,27 @@ config CONFIG_INSTALL_NO_USR
413 413
414choice 414choice
415 prompt "Applets links" 415 prompt "Applets links"
416 default CONFIG_INSTALL_APPLET_SYMLINKS 416 default INSTALL_APPLET_SYMLINKS
417 help 417 help
418 Choose how you install applets links. 418 Choose how you install applets links.
419 419
420config CONFIG_INSTALL_APPLET_SYMLINKS 420config INSTALL_APPLET_SYMLINKS
421 bool "as soft-links" 421 bool "as soft-links"
422 help 422 help
423 Install applets as soft-links to the busybox binary. This needs some 423 Install applets as soft-links to the busybox binary. This needs some
424 free inodes on the filesystem, but might help with filesystem 424 free inodes on the filesystem, but might help with filesystem
425 generators that can't cope with hard-links. 425 generators that can't cope with hard-links.
426 426
427config CONFIG_INSTALL_APPLET_HARDLINKS 427config INSTALL_APPLET_HARDLINKS
428 bool "as hard-links" 428 bool "as hard-links"
429 help 429 help
430 Install applets as hard-links to the busybox binary. This might count 430 Install applets as hard-links to the busybox binary. This might count
431 on a filesystem with few inodes. 431 on a filesystem with few inodes.
432 432
433config CONFIG_INSTALL_APPLET_DONT 433config INSTALL_APPLET_DONT
434 bool 434 bool
435 prompt "not installed" 435 prompt "not installed"
436 depends on CONFIG_FEATURE_INSTALLER || CONFIG_FEATURE_SH_STANDALONE_SHELL 436 depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE_SHELL
437 help 437 help
438 Do not install applets links. Usefull when using the -install feature 438 Do not install applets links. Usefull when using the -install feature
439 or a standalone shell for rescue pruposes. 439 or a standalone shell for rescue pruposes.
diff --git a/Makefile b/Makefile
index 83da80c47..4b49208d1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,521 +1,1281 @@
1# Makefile for busybox 1VERSION = 1
2PATCHLEVEL = 2
3SUBLEVEL = 1
4EXTRAVERSION = .svn
5NAME=Unnamed
6
7# *DOCUMENTATION*
8# To see a list of typical targets execute "make help"
9# More info can be located in ./README
10# Comments in this file are targeted only to the developer, do not
11# expect to learn how to build the kernel reading this file.
12
13# Do not print "Entering directory ..."
14MAKEFLAGS += --no-print-directory
15
16# We are using a recursive build, so we need to do a little thinking
17# to get the ordering right.
2# 18#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 19# Most importantly: sub-Makefiles should only ever modify files in
4# 20# their own directory. If in some directory we have a dependency on
5# Licensed under GPLv2, see the file LICENSE in this tarball for details. 21# a file in another dir (which doesn't happen often, but it's often
22# unavoidable when linking the built-in.o targets which finally
23# turn into busybox), we will call a sub make in that other dir, and
24# after that we are sure that everything which is in that other dir
25# is now up to date.
6# 26#
27# The only cases where we need to modify files which have global
28# effects are thus separated out and done before the recursive
29# descending is started. They are now explicitly listed as the
30# prepare rule.
7 31
8# You shouldn't have to edit anything in this file for configuration 32# To put more focus on warnings, be less verbose as default
9# purposes, try "make help" or read http://busybox.net/FAQ.html. 33# Use 'make V=1' to see the full commands
10 34
11.PHONY: dummy subdirs release distclean clean config oldconfig menuconfig \ 35ifdef V
12 tags check test depend dep buildtree hosttools _all checkhelp \ 36 ifeq ("$(origin V)", "command line")
13 sizes bloatcheck baseline objsizes 37 KBUILD_VERBOSE = $(V)
38 endif
39endif
40ifndef KBUILD_VERBOSE
41 KBUILD_VERBOSE = 0
42endif
14 43
15noconfig_targets := menuconfig config oldconfig randconfig hosttools \ 44# Call sparse as part of compilation of C files
16 defconfig allyesconfig allnoconfig allbareconfig \ 45# Use 'make C=1' to enable sparse checking
17 clean distclean help \
18 release tags
19 46
20nocheck_targets := clean distclean help release tags 47ifdef C
48 ifeq ("$(origin C)", "command line")
49 KBUILD_CHECKSRC = $(C)
50 endif
51endif
52ifndef KBUILD_CHECKSRC
53 KBUILD_CHECKSRC = 0
54endif
21 55
22# the toplevel sourcedir 56# Use make M=dir to specify directory of external module to build
23ifndef top_srcdir 57# Old syntax make ... SUBDIRS=$PWD is still supported
24top_srcdir=$(CURDIR) 58# Setting the environment variable KBUILD_EXTMOD take precedence
59ifdef SUBDIRS
60 KBUILD_EXTMOD ?= $(SUBDIRS)
25endif 61endif
26# toplevel directory of the object-tree 62ifdef M
27ifndef top_builddir 63 ifeq ("$(origin M)", "command line")
28top_builddir=$(CURDIR) 64 KBUILD_EXTMOD := $(M)
65 endif
29endif 66endif
30 67
31export srctree=$(top_srcdir)
32vpath %/Config.in $(srctree)
33 68
34DIRS:=applets archival archival/libunarchive coreutils console-tools \ 69# kbuild supports saving output files in a separate directory.
35 debianutils editors findutils init miscutils modutils networking \ 70# To locate output files in a separate directory two syntaxes are supported.
36 networking/libiproute networking/udhcp procps loginutils shell \ 71# In both cases the working directory must be the root of the kernel src.
37 sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils \ 72# 1) O=
38 runit libbb 73# Use "make O=dir/to/store/output/files/"
74#
75# 2) Set KBUILD_OUTPUT
76# Set the environment variable KBUILD_OUTPUT to point to the directory
77# where the output files shall be placed.
78# export KBUILD_OUTPUT=dir/to/store/output/files/
79# make
80#
81# The O= assignment takes precedence over the KBUILD_OUTPUT environment
82# variable.
39 83
40SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
41 84
42# That's our default target when none is given on the command line 85# KBUILD_SRC is set on invocation of make in OBJ directory
43_all: 86# KBUILD_SRC is not intended to be used by the regular user (for now)
44 87ifeq ($(KBUILD_SRC),)
45CONFIG_CONFIG_IN = $(top_srcdir)/Config.in
46 88
47ifeq ($(BUILD_SRC),) 89# OK, Make called in directory where kernel src resides
90# Do we want to locate output files in a separate directory?
48ifdef O 91ifdef O
49 ifeq ("$(origin O)", "command line") 92 ifeq ("$(origin O)", "command line")
50 BUILD_OUTPUT := $(O) 93 KBUILD_OUTPUT := $(O)
51 top_builddir := $(O)
52 endif 94 endif
95endif
96
97# That's our default target when none is given on the command line
98PHONY := _all
99_all:
100
101ifneq ($(KBUILD_OUTPUT),)
102# Invoke a second make in the output directory, passing relevant variables
103# check that the output directory actually exists
104saved-output := $(KBUILD_OUTPUT)
105KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
106$(if $(KBUILD_OUTPUT),, \
107 $(error output directory "$(saved-output)" does not exist))
108
109PHONY += $(MAKECMDGOALS)
110
111$(filter-out _all,$(MAKECMDGOALS)) _all:
112 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
113 KBUILD_SRC=$(CURDIR) \
114 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@
115
116# Leave processing to above invocation of make
117skip-makefile := 1
118endif # ifneq ($(KBUILD_OUTPUT),)
119endif # ifeq ($(KBUILD_SRC),)
120
121# We process the rest of the Makefile if this is the final invocation of make
122ifeq ($(skip-makefile),)
123
124# If building an external module we do not care about the all: rule
125# but instead _all depend on modules
126PHONY += all
127ifeq ($(KBUILD_EXTMOD),)
128_all: all
53else 129else
54# If no alternate output-dir was specified, we build in cwd 130_all: modules
55# We are using BUILD_OUTPUT nevertheless to make sure that we create
56# Rules.mak and the toplevel Makefile, in case they don't exist.
57 BUILD_OUTPUT := $(top_builddir)
58endif 131endif
59 132
60# see if we are in verbose mode 133srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
61BUILD_VERBOSE := 134TOPDIR := $(srctree)
62ifdef V 135# FIXME - TOPDIR is obsolete, use srctree/objtree
63 ifeq ("$(origin V)", "command line") 136objtree := $(CURDIR)
64 BUILD_VERBOSE := $(V) 137src := $(srctree)
65 endif 138obj := $(objtree)
139
140VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
141
142export srctree objtree VPATH TOPDIR
143
144
145# SUBARCH tells the usermode build what the underlying arch is. That is set
146# first, and if a usermode build is happening, the "ARCH=um" on the command
147# line overrides the setting of ARCH below. If a native build is happening,
148# then ARCH is assigned, getting whatever value it gets normally, and
149# SUBARCH is subsequently ignored.
150
151SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
152 -e s/arm.*/arm/ -e s/sa110/arm/ \
153 -e s/s390x/s390/ -e s/parisc64/parisc/ \
154 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
155
156# Cross compiling and selecting different set of gcc/bin-utils
157# ---------------------------------------------------------------------------
158#
159# When performing cross compilation for other architectures ARCH shall be set
160# to the target architecture. (See arch/* for the possibilities).
161# ARCH can be set during invocation of make:
162# make ARCH=ia64
163# Another way is to have ARCH set in the environment.
164# The default ARCH is the host where make is executed.
165
166# CROSS_COMPILE specify the prefix used for all executables used
167# during compilation. Only gcc and related bin-utils executables
168# are prefixed with $(CROSS_COMPILE).
169# CROSS_COMPILE can be set on the command line
170# make CROSS_COMPILE=ia64-linux-
171# Alternatively CROSS_COMPILE can be set in the environment.
172# Default value for CROSS_COMPILE is not to prefix executables
173# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
174
175ARCH ?= $(SUBARCH)
176CROSS_COMPILE ?=
177
178# Architecture as present in compile.h
179UTS_MACHINE := $(ARCH)
180
181# SHELL used by kbuild
182CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
183 else if [ -x /bin/bash ]; then echo /bin/bash; \
184 else echo sh; fi ; fi)
185
186HOSTCC = gcc
187HOSTCXX = g++
188HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
189HOSTCXXFLAGS = -O2
190
191# Decide whether to build built-in, modular, or both.
192# Normally, just do built-in.
193
194KBUILD_MODULES :=
195KBUILD_BUILTIN := 1
196
197# If we have only "make modules", don't compile built-in objects.
198# When we're building modules with modversions, we need to consider
199# the built-in objects during the descend as well, in order to
200# make sure the checksums are uptodate before we record them.
201
202ifeq ($(MAKECMDGOALS),modules)
203 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
66endif 204endif
67ifdef VERBOSE 205
68 ifeq ("$(origin VERBOSE)", "command line") 206# If we have "make <whatever> modules", compile modules
69 BUILD_VERBOSE := $(VERBOSE) 207# in addition to whatever we do anyway.
70 endif 208# Just "make" or "make all" shall build modules as well
209
210ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
211 KBUILD_MODULES := 1
212endif
213
214ifeq ($(MAKECMDGOALS),)
215 KBUILD_MODULES := 1
71endif 216endif
72 217
73ifneq ($(strip $(BUILD_VERBOSE)),) 218export KBUILD_MODULES KBUILD_BUILTIN
74 export BUILD_VERBOSE 219export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
75 CHECK_VERBOSE := -v 220
76# ARFLAGS+=v 221# Beautify output
222# ---------------------------------------------------------------------------
223#
224# Normally, we echo the whole command before executing it. By making
225# that echo $($(quiet)$(cmd)), we now have the possibility to set
226# $(quiet) to choose other forms of output instead, e.g.
227#
228# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
229# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
230#
231# If $(quiet) is empty, the whole command will be printed.
232# If it is set to "quiet_", only the short version will be printed.
233# If it is set to "silent_", nothing wil be printed at all, since
234# the variable $(silent_cmd_cc_o_c) doesn't exist.
235#
236# A simple variant is to prefix commands with $(Q) - that's useful
237# for commands that shall be hidden in non-verbose mode.
238#
239# $(Q)ln $@ :<
240#
241# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
242# If KBUILD_VERBOSE equals 1 then the above command is displayed.
243
244ifeq ($(KBUILD_VERBOSE),1)
245 quiet =
246 Q =
247else
248 quiet=quiet_
249 Q = @
77endif 250endif
78 251
79ifneq ($(strip $(HAVE_DOT_CONFIG)),y) 252# If the user is running make -s (silent mode), suppress echoing of
80# pull in settings early 253# commands
81-include $(top_srcdir)/Rules.mak 254
255ifneq ($(findstring s,$(MAKEFLAGS)),)
256 quiet=silent_
82endif 257endif
83 258
84# All object directories. 259export quiet Q KBUILD_VERBOSE
85OBJ_DIRS := $(DIRS) 260
86all_tree := $(patsubst %,$(top_builddir)/%,$(OBJ_DIRS) scripts scripts/config include) 261
87all_tree: $(all_tree) 262# Look for make include files relative to root of kernel src
88$(all_tree): 263MAKEFLAGS += --include-dir=$(srctree)
89 @mkdir -p "$@" 264
265# We need some generic definitions
266include $(srctree)/scripts/Kbuild.include
267
268# For maximum performance (+ possibly random breakage, uncomment
269# the following)
270
271MAKEFLAGS += -rR
272
273# Make variables (CC, etc...)
274
275AS = $(CROSS_COMPILE)as
276LD = $(CROSS_COMPILE)ld
277CC = $(CROSS_COMPILE)gcc
278CPP = $(CC) -E
279AR = $(CROSS_COMPILE)ar
280NM = $(CROSS_COMPILE)nm
281STRIP = $(CROSS_COMPILE)strip
282OBJCOPY = $(CROSS_COMPILE)objcopy
283OBJDUMP = $(CROSS_COMPILE)objdump
284AWK = awk
285GENKSYMS = scripts/genksyms/genksyms
286DEPMOD = /sbin/depmod
287KALLSYMS = scripts/kallsyms
288PERL = perl
289CHECK = sparse
290
291CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
292MODFLAGS = -DMODULE
293CFLAGS_MODULE = $(MODFLAGS)
294AFLAGS_MODULE = $(MODFLAGS)
295LDFLAGS_MODULE = -r
296CFLAGS_KERNEL =
297AFLAGS_KERNEL =
298
299
300# Use LINUXINCLUDE when you must reference the include/ directory.
301# Needed to be compatible with the O= option
302CFLAGS :=
303CPPFLAGS :=
304AFLAGS :=
305include $(srctree)/Makefile.flags
306
307# Read KERNELRELEASE from .kernelrelease (if it exists)
308KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)
309KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
310
311export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \
312 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
313 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
314 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
315
316export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
317export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
318export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
319
320# When compiling out-of-tree modules, put MODVERDIR in the module
321# tree rather than in the kernel tree. The kernel tree might
322# even be read-only.
323export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
324
325# Files to ignore in find ... statements
326
327RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
328export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
329
330# ===========================================================================
331# Rules shared between *config targets and build targets
332
333# Basic helpers built in scripts/
334PHONY += scripts_basic
335scripts_basic:
336 $(Q)$(MAKE) $(build)=scripts/basic
337
338# To avoid any implicit rule to kick in, define an empty command.
339scripts/basic/%: scripts_basic ;
340
341PHONY += outputmakefile
342# outputmakefile generates a Makefile in the output directory, if using a
343# separate output directory. This allows convenient use of make in the
344# output directory.
345outputmakefile:
346ifneq ($(KBUILD_SRC),)
347 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
348 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
349endif
90 350
91ifneq ($(BUILD_OUTPUT),) 351# To make sure we do not include .config for any of the *config targets
92# Invoke a second make in the output directory, passing relevant variables 352# catch them early, and hand them over to scripts/kconfig/Makefile
93# Check that the output directory actually exists 353# It is allowed to specify more targets when calling make, including
94saved-output := $(BUILD_OUTPUT) 354# mixing *config targets and build targets.
95BUILD_OUTPUT := $(shell cd $(BUILD_OUTPUT) && /bin/pwd) 355# For example 'make oldconfig all'.
96$(if $(wildcard $(BUILD_OUTPUT)),, \ 356# Detect when mixed targets is specified, and make a second invocation
97 $(error output directory "$(saved-output)" does not exist)) 357# of make so .config is not included in this case either (for *config).
358
359no-dot-config-targets := clean mrproper distclean \
360 cscope TAGS tags help %docs check%
361
362config-targets := 0
363mixed-targets := 0
364dot-config := 1
365
366ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
367 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
368 dot-config := 0
369 endif
370endif
98 371
99.PHONY: $(MAKECMDGOALS) 372ifeq ($(KBUILD_EXTMOD),)
373 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
374 config-targets := 1
375 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
376 mixed-targets := 1
377 endif
378 endif
379endif
100 380
101$(filter-out _all,$(MAKECMDGOALS)) _all: $(BUILD_OUTPUT)/Rules.mak $(BUILD_OUTPUT)/Makefile all_tree 381ifeq ($(mixed-targets),1)
102 $(Q)$(MAKE) -C $(BUILD_OUTPUT) \ 382# ===========================================================================
103 top_srcdir=$(top_srcdir) \ 383# We're called with mixed targets (*config and build targets).
104 top_builddir=$(top_builddir) \ 384# Handle them one by one.
105 BUILD_SRC=$(top_srcdir) \
106 -f $(CURDIR)/Makefile $@
107 385
108$(BUILD_OUTPUT)/Rules.mak: 386%:: FORCE
109 @echo > $@ 387 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
110 @echo top_srcdir=$(top_srcdir) >> $@
111 @echo top_builddir=$(BUILD_OUTPUT) >> $@
112 @echo include $(top_srcdir)/Rules.mak >> $@
113 388
114$(BUILD_OUTPUT)/Makefile: 389else
115 @echo > $@ 390ifeq ($(config-targets),1)
116 @echo top_srcdir=$(top_srcdir) >> $@ 391# ===========================================================================
117 @echo top_builddir=$(BUILD_OUTPUT) >> $@ 392# *config targets only - make sure prerequisites are updated, and descend
118 @echo BUILD_SRC='$$(top_srcdir)' >> $@ 393# in scripts/kconfig to make the *config target
119 @echo include '$$(BUILD_SRC)'/Makefile >> $@ 394
395# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
396# KBUILD_DEFCONFIG may point out an alternative default configuration
397# used for 'make defconfig'
398-include $(srctree)/arch/$(ARCH)/Makefile
399export KBUILD_DEFCONFIG
400
401config %config: scripts_basic outputmakefile FORCE
402 $(Q)mkdir -p include/linux
403 $(Q)$(MAKE) $(build)=scripts/kconfig $@
404 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
120 405
121# Leave processing to above invocation of make 406else
122skip-makefile := 1 407# ===========================================================================
123endif # ifneq ($(BUILD_OUTPUT),) 408# Build targets only - this includes busybox, arch specific targets, clean
124endif # ifeq ($(BUILD_SRC),) 409# targets and others. In general all targets except *config targets.
410
411ifeq ($(KBUILD_EXTMOD),)
412# Additional helpers built in scripts/
413# Carefully list dependencies so we do not try to build scripts twice
414# in parrallel
415PHONY += scripts
416scripts: scripts_basic include/config/MARKER
417 $(Q)$(MAKE) $(build)=$(@)
418
419scripts_basic: include/autoconf.h
420
421# Objects we will link into busybox / subdirs we need to visit
422core-y := \
423 applets/ \
424
425libs-y := \
426 archival/ \
427 archival/libunarchive/ \
428 console-tools/ \
429 coreutils/ \
430 coreutils/libcoreutils/ \
431 debianutils/ \
432 e2fsprogs/ \
433 e2fsprogs/blkid/ \
434 e2fsprogs/e2p/ \
435 e2fsprogs/ext2fs/ \
436 e2fsprogs/uuid/ \
437 editors/ \
438 findutils/ \
439 init/ \
440 libbb/ \
441 libpwdgrp/ \
442 loginutils/ \
443 miscutils/ \
444 modutils/ \
445 networking/ \
446 networking/libiproute/ \
447 networking/udhcp/ \
448 procps/ \
449 runit/ \
450 shell/ \
451 sysklogd/ \
452 util-linux/ \
453
454endif # KBUILD_EXTMOD
455
456ifeq ($(dot-config),1)
457# In this section, we need .config
125 458
126ifeq ($(skip-makefile),) 459# Read in dependencies to all Kconfig* files, make sure to run
460# oldconfig if changes are detected.
461-include .kconfig.d
127 462
128# We only need a copy of the Makefile for the config targets and reuse 463include .config
129# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
130scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile
131 cp $< $@
132 464
133_all: all 465# If .config needs to be updated, it will be done via the dependency
466# that autoconf has on .config.
467# To avoid any implicit rule to kick in, define an empty command
468.config .kconfig.d: ;
134 469
135help: 470# If .config is newer than include/autoconf.h, someone tinkered
136 @echo 'Cleaning:' 471# with it and forgot to run make oldconfig.
137 @echo ' clean - delete temporary files created by build' 472# If kconfig.d is missing then we are probarly in a cleaned tree so
138 @echo ' distclean - delete all non-source files (including .config)' 473# we execute the config step to be sure to catch updated Kconfig files
139 @echo 474include/autoconf.h: .kconfig.d .config
140 @echo 'Build:' 475 $(Q)mkdir -p include/linux
141 @echo ' all - Executable and documentation' 476 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
142 @echo ' busybox - the swiss-army executable'
143 @echo ' doc - docs/BusyBox.{txt,html,1}'
144 @echo ' html - create html-based cross-reference'
145 @echo
146 @echo 'Configuration:'
147 @echo ' allnoconfig - disable all symbols in .config'
148 @echo ' allyesconfig - enable all symbols in .config (see defconfig)'
149 @echo ' allbareconfig - enable all applets without any sub-features'
150 @echo ' config - text based configurator (of last resort)'
151 @echo ' defconfig - set .config to largest generic configuration'
152 @echo ' menuconfig - interactive curses-based configurator'
153 @echo ' oldconfig - resolve any unresolved symbols in .config'
154 @echo ' hosttools - build sed for the host.'
155 @echo ' You can use these commands if the commands on the host'
156 @echo ' is unusable. Afterwards use it like:'
157 @echo ' make SED="$(top_builddir)/sed"'
158 @echo
159 @echo 'Installation:'
160 @echo ' install - install busybox into $(PREFIX)'
161 @echo ' uninstall'
162 @echo
163 @echo 'Development:'
164 @echo ' baseline - create busybox_old for bloatcheck.'
165 @echo ' bloatcheck - show size difference between old and new versions'
166 @echo ' check - run the test suite for all applets'
167 @echo ' checkhelp - check for missing help-entries in Config.in'
168 @echo ' randconfig - generate a random configuration'
169 @echo ' release - create a distribution tarball'
170 @echo ' sizes - show size of all enabled busybox symbols'
171 @echo ' objsizes - show size of each .o object built'
172 @echo
173 477
478else
479# Dummy target needed, because used as prerequisite
480include/autoconf.h: ;
481endif
174 482
175include $(top_srcdir)/Rules.mak 483# The all: target is the default when no target is given on the
484# command line.
485# This allow a user to issue only 'make' to build a kernel including modules
486# Defaults busybox but it is usually overriden in the arch makefile
487all: busybox
176 488
177ifneq ($(strip $(HAVE_DOT_CONFIG)),y) 489-include $(srctree)/arch/$(ARCH)/Makefile
178 490
179# Default target if none was requested explicitly 491# arch Makefile may override CC so keep this after arch Makefile is included
180all: menuconfig 492#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
493CHECKFLAGS += $(NOSTDINC_FLAGS)
181 494
182# warn if no configuration exists and we are asked to build a non-config target 495# warn about C99 declaration after statement
183.config: 496CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
184 @echo "" 497
185 @echo "No $(top_builddir)/$@ found!" 498# disable pointer signedness warnings in gcc 4.0
186 @echo "Please refer to 'make help', section Configuration." 499CFLAGS += $(call cc-option,-Wno-pointer-sign,)
187 @echo "" 500
188 @exit 1 501# Default kernel image to build when no specific target is given.
502# KBUILD_IMAGE may be overruled on the commandline or
503# set in the environment
504# Also any assignments in arch/$(ARCH)/Makefile take precedence over
505# this default value
506export KBUILD_IMAGE ?= busybox
507
508#
509# INSTALL_PATH specifies where to place the updated kernel and system map
510# images. Default is /boot, but you can set it to other values
511export INSTALL_PATH ?= /boot
512
513#
514# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
515# relocations required by build roots. This is not defined in the
516# makefile but the arguement can be passed to make if needed.
517#
518
519MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
520export MODLIB
521
522
523ifeq ($(KBUILD_EXTMOD),)
524busybox-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(core-m) $(libs-y) $(libs-m)))
525
526busybox-alldirs := $(sort $(busybox-dirs) $(patsubst %/,%,$(filter %/, \
527 $(core-n) $(core-) $(libs-n) $(libs-) \
528 )))
529
530core-y := $(patsubst %/, %/built-in.o, $(core-y))
531libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
532libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
533libs-y := $(libs-y1) $(libs-y2)
189 534
190# configuration 535
536# Build busybox
191# --------------------------------------------------------------------------- 537# ---------------------------------------------------------------------------
538# busybox is build from the objects selected by $(busybox-init) and
539# $(busybox-main). Most are built-in.o files from top-level directories
540# in the kernel tree, others are specified in arch/$(ARCH)Makefile.
541# Ordering when linking is important, and $(busybox-init) must be first.
542#
543# busybox
544# ^
545# |
546# +-< $(busybox-init)
547# | +--< init/version.o + more
548# |
549# +--< $(busybox-main)
550# | +--< driver/built-in.o mm/built-in.o + more
551# |
552# +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
553#
554# busybox version (uname -v) cannot be updated during normal
555# descending-into-subdirs phase since we do not yet know if we need to
556# update busybox.
557# Therefore this step is delayed until just before final link of busybox -
558# except in the kallsyms case where it is done just before adding the
559# symbols to the kernel.
560#
561# System.map is generated to document addresses of all kernel symbols
562
563busybox-all := $(core-y) $(libs-y)
564
565# Rule to link busybox - also used during CONFIG_KALLSYMS
566# May be overridden by arch/$(ARCH)/Makefile
567quiet_cmd_busybox__ ?= LINK $@
568 cmd_busybox__ ?= scripts/trylink $(CC) -o $@ \
569 -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
570 -Wl,--start-group $(busybox-all) -Wl,--end-group \
571
572# Generate System.map
573quiet_cmd_sysmap = SYSMAP
574 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
575
576# Link of busybox
577# If CONFIG_KALLSYMS is set .version is already updated
578# Generate System.map and verify that the content is consistent
579# Use + in front of the busybox_version rule to silent warning with make -j2
580# First command is ':' to allow us to use + in front of the rule
581define rule_busybox__
582 :
583 $(call cmd,busybox__)
584 $(Q)echo 'cmd_$@ := $(cmd_busybox__)' > $(@D)/.$(@F).cmd
585endef
586
587
588ifdef CONFIG_KALLSYMS
589# Generate section listing all symbols and add it into busybox $(kallsyms.o)
590# It's a three stage process:
591# o .tmp_busybox1 has all symbols and sections, but __kallsyms is
592# empty
593# Running kallsyms on that gives us .tmp_kallsyms1.o with
594# the right size - busybox version (uname -v) is updated during this step
595# o .tmp_busybox2 now has a __kallsyms section of the right size,
596# but due to the added section, some addresses have shifted.
597# From here, we generate a correct .tmp_kallsyms2.o
598# o The correct .tmp_kallsyms2.o is linked into the final busybox.
599# o Verify that the System.map from busybox matches the map from
600# .tmp_busybox2, just in case we did not generate kallsyms correctly.
601# o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
602# .tmp_busybox3 and .tmp_kallsyms3.o. This is only meant as a
603# temporary bypass to allow the kernel to be built while the
604# maintainers work out what went wrong with kallsyms.
605
606ifdef CONFIG_KALLSYMS_EXTRA_PASS
607last_kallsyms := 3
608else
609last_kallsyms := 2
610endif
192 611
193scripts/config/conf: scripts/config/Makefile 612kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
194 $(Q)$(MAKE) -C scripts/config conf
195 -@if [ ! -f .config ] ; then \
196 touch .config; \
197 fi
198 613
199scripts/config/mconf: scripts/config/Makefile 614define verify_kallsyms
200 $(Q)$(MAKE) -C scripts/config ncurses conf mconf 615 $(Q)$(if $($(quiet)cmd_sysmap), \
201 -@if [ ! -f .config ] ; then \ 616 echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \
202 touch .config; \ 617 $(cmd_sysmap) .tmp_busybox$(last_kallsyms) .tmp_System.map
203 fi 618 $(Q)cmp -s System.map .tmp_System.map || \
619 (echo Inconsistent kallsyms data; \
620 echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \
621 rm .tmp_kallsyms* ; /bin/false )
622endef
204 623
205menuconfig: scripts/config/mconf 624# Update busybox version before link
206 @[ -f .config ] || $(MAKE) $(MAKEFLAGS) defconfig 625# Use + in front of this rule to silent warning about make -j1
207 @./scripts/config/mconf $(CONFIG_CONFIG_IN) 626# First command is ':' to allow us to use + in front of this rule
627cmd_ksym_ld = $(cmd_busybox__)
628define rule_ksym_ld
629 :
630 +$(call cmd,busybox_version)
631 $(call cmd,busybox__)
632 $(Q)echo 'cmd_$@ := $(cmd_busybox__)' > $(@D)/.$(@F).cmd
633endef
208 634
209config: scripts/config/conf 635# Generate .S file with all kernel symbols
210 @./scripts/config/conf $(CONFIG_CONFIG_IN) 636quiet_cmd_kallsyms = KSYM $@
637 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \
638 $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@
211 639
212oldconfig: scripts/config/conf 640.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
213 @./scripts/config/conf -o $(CONFIG_CONFIG_IN) 641 $(call if_changed_dep,as_o_S)
214 642
215randconfig: scripts/config/conf 643.tmp_kallsyms%.S: .tmp_busybox% $(KALLSYMS)
216 @./scripts/config/conf -r $(CONFIG_CONFIG_IN) 644 $(call cmd,kallsyms)
217 645
218allyesconfig: scripts/config/conf 646# .tmp_busybox1 must be complete except kallsyms, so update busybox version
219 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null 647.tmp_busybox1: $(busybox-lds) $(busybox-all) FORCE
648 $(call if_changed_rule,ksym_ld)
220 649
221allnoconfig: scripts/config/conf 650.tmp_busybox2: $(busybox-lds) $(busybox-all) .tmp_kallsyms1.o FORCE
222 @./scripts/config/conf -n $(CONFIG_CONFIG_IN) > /dev/null 651 $(call if_changed,busybox__)
223 652
224# defconfig is allyesconfig minus any features that are specialized enough 653.tmp_busybox3: $(busybox-lds) $(busybox-all) .tmp_kallsyms2.o FORCE
225# or cause enough behavior change that the user really should switch them on 654 $(call if_changed,busybox__)
226# manually if that's what they want. Sort of "maximum sane config".
227 655
228defconfig: scripts/config/conf 656# Needs to visit scripts/ before $(KALLSYMS) can be used.
229 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null 657$(KALLSYMS): scripts ;
230 @$(SED) -i -r -e "s/^(CONFIG_(DEBUG.*|STATIC|SELINUX|NITPICK|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config
231 @./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
232 658
659# Generate some data for debugging strange kallsyms problems
660debug_kallsyms: .tmp_map$(last_kallsyms)
233 661
234allbareconfig: scripts/config/conf 662.tmp_map%: .tmp_busybox% FORCE
235 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null 663 ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
236 @$(SED) -i -r -e "s/^(CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config
237 @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
238 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
239 @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
240 664
241hosttools: 665.tmp_map3: .tmp_map2
242 $(Q)cp .config .config.bak || noold=yea
243 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" allnoconfig
244 $(Q)mv .config .config.in
245 $(Q)(grep -v CONFIG_SED .config.in ; \
246 echo "CONFIG_SED=y" ; ) > .config
247 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" oldconfig include/bb_config.h
248 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" busybox
249 $(Q)[ -f .config.bak ] && mv .config.bak .config || rm .config
250 mv busybox sed
251 @echo "Now do: $(MAKE) SED=$(top_builddir)/sed <target>"
252 666
253else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) 667.tmp_map2: .tmp_map1
254 668
255all: busybox busybox.links doc 669endif # ifdef CONFIG_KALLSYMS
256 670
257# In this section, we need .config 671# busybox image - including updated kernel symbols
258-include $(top_builddir)/.config.cmd 672busybox_unstripped: $(busybox-all) FORCE
259include $(patsubst %,%/Makefile.in, $(SRC_DIRS)) 673 $(call if_changed_rule,busybox__)
260 674 $(Q)rm -f .old_version
261endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) 675
262 676busybox: busybox_unstripped
263-include $(top_builddir)/.config 677 $(Q)strip -s --remove-section=.note --remove-section=.comment \
264-include $(top_builddir)/.depend 678 busybox_unstripped -o $@
265 679
266 680# The actual objects are generated when descending,
267ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) 681# make sure no implicit rule kicks in
268libraries-y:= 682$(sort $(busybox-all)): $(busybox-dirs) ;
269# Which parts of the internal libs are requested? 683
270# Per default we only want what was actually selected. 684# Handle descending into subdirectories listed in $(busybox-dirs)
271# -a denotes all while -y denotes the selected ones. 685# Preset locale variables to speed up the build process. Limit locale
272ifeq ($(strip $(CONFIG_FEATURE_FULL_LIBBUSYBOX)),y) 686# tweaks to this spot to avoid wrong language settings when running
273LIBRARY_DEFINE:=$(LIBRARY_DEFINE-a) 687# make menuconfig etc.
274LIBRARY_SRC :=$(LIBRARY_SRC-a) 688# Error messages still appears in the original language
275else # CONFIG_FEATURE_FULL_LIBBUSYBOX 689
276LIBRARY_DEFINE:=$(LIBRARY_DEFINE-y) 690PHONY += $(busybox-dirs)
277LIBRARY_SRC :=$(LIBRARY_SRC-y) 691$(busybox-dirs): prepare scripts
278endif # CONFIG_FEATURE_FULL_LIBBUSYBOX 692 $(Q)$(MAKE) $(build)=$@
279APPLET_SRC:=$(APPLET_SRC-y) 693
280APPLETS_DEFINE:=$(APPLETS_DEFINE-y) 694# Build the kernel release string
281else # CONFIG_BUILD_AT_ONCE 695# The KERNELRELEASE is stored in a file named .kernelrelease
282APPLET_SRC:= 696# to be used when executing for example make install or make modules_install
283# no --combine, build archives out of the individual .o 697#
284# This was the old way the binary was built. 698# Take the contents of any files called localversion* and the config
285libbusybox-obj:=archival/libunarchive/libunarchive.a \ 699# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE.
286 networking/libiproute/libiproute.a \ 700# LOCALVERSION from the command line override all of this
287 libpwdgrp/libpwdgrp.a \ 701
288 coreutils/libcoreutils/libcoreutils.a \ 702nullstring :=
289 libbb/libbb.a 703space := $(nullstring) # end of line
290libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj)) 704
291 705___localver = $(objtree)/localversion* $(srctree)/localversion*
292ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) 706__localver = $(sort $(wildcard $(___localver)))
293# linking against libbusybox, so don't build the .a already contained in the .so 707# skip backup files (containing '~')
294libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y)) 708_localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))
295endif # CONFIG_FEATURE_SHARED_BUSYBOX 709
296endif # CONFIG_BUILD_AT_ONCE 710localver = $(subst $(space),, \
297 711 $(shell cat /dev/null $(_localver)) \
298 712 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
299ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) 713
300LD_LIBBUSYBOX:=libbusybox.so 714# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called
301LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION) 715# and if the SCM is know a tag from the SCM is appended.
302DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \ 716# The appended tag is determinded by the SCM used.
303 $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ 717#
304 $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION) 718# Currently, only git is supported.
305endif # CONFIG_BUILD_LIBBUSYBOX 719# Other SCMs can edit scripts/setlocalversion and add the appropriate
306 720# checks as needed.
307ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) 721ifdef CONFIG_LOCALVERSION_AUTO
308ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) 722 _localver-auto = $(shell $(CONFIG_SHELL) \
309# --combine but not linking against libbusybox, so compile all 723 $(srctree)/scripts/setlocalversion $(srctree))
310BUSYBOX_SRC := $(LIBRARY_SRC) 724 localver-auto = $(LOCALVERSION)$(_localver-auto)
311BUSYBOX_DEFINE:= $(LIBRARY_DEFINE)
312endif # !CONFIG_FEATURE_SHARED_BUSYBOX
313$(LIBBUSYBOX_SONAME): $(LIBRARY_SRC)
314else # CONFIG_BUILD_AT_ONCE
315$(LIBBUSYBOX_SONAME): $(libbusybox-obj)
316endif # CONFIG_BUILD_AT_ONCE
317
318ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
319LDBUSYBOX:=-L$(top_builddir) -lbusybox
320endif 725endif
321 726
322ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) 727localver-full = $(localver)$(localver-auto)
323$(LIBBUSYBOX_SONAME): 728
324ifndef MAJOR_VERSION 729# Store (new) KERNELRELASE string in .kernelrelease
325 $(error MAJOR_VERSION needed for $@ is not defined) 730kernelrelease = $(KERNELVERSION)$(localver-full)
731.kernelrelease: FORCE
732 $(Q)rm -f $@
733 $(Q)echo $(kernelrelease) > $@
734
735
736# Things we need to do before we recursively start building the kernel
737# or the modules are listed in "prepare".
738# A multi level approach is used. prepareN is processed before prepareN-1.
739# archprepare is used in arch Makefiles and when processed asm symlink,
740# version.h and scripts_basic is processed / created.
741
742# Listed in dependency order
743PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
744
745# prepare-all is deprecated, use prepare as valid replacement
746PHONY += prepare-all
747
748# prepare3 is used to check if we are building in a separate output directory,
749# and if so do:
750# 1) Check that make has not been executed in the kernel src $(srctree)
751# 2) Create the include2 directory, used for the second asm symlink
752prepare3: .kernelrelease
753ifneq ($(KBUILD_SRC),)
754 @echo ' Using $(srctree) as source for kernel'
755 $(Q)if [ -f $(srctree)/.config ]; then \
756 echo " $(srctree) is not clean, please run 'make mrproper'";\
757 echo " in the '$(srctree)' directory.";\
758 /bin/false; \
759 fi;
760 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
761 $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
326endif 762endif
327 $(do_link.so) \
328 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
329 -Wl,-z,combreloc
330 @rm -f $(DO_INSTALL_LIBS)
331 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
332 $(do_strip)
333 763
334endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) 764# prepare2 creates a makefile if using a separate output directory
765prepare2: prepare3 outputmakefile
766
767prepare1: prepare2 include/config/MARKER
768ifneq ($(KBUILD_MODULES),)
769 $(Q)mkdir -p $(MODVERDIR)
770 $(Q)rm -f $(MODVERDIR)/*
771endif
335 772
336busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y) 773archprepare: prepare1 scripts_basic
337 $(do_link)
338 774
339busybox: busybox_unstripped 775prepare0: archprepare FORCE
340 $(Q)cp busybox_unstripped busybox 776 $(Q)$(MAKE) $(build)=.
341 $(do_strip)
342 777
343%.bflt: %_unstripped 778# All the preparing..
344 $(do_elf2flt) 779prepare prepare-all: prepare0
345 780
346busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h 781# Leave this as default for preprocessing busybox.lds.S, which is now
347 $(Q)-$(SHELL) $^ >$@ 782# done in arch/$(ARCH)/kernel/Makefile
348 783
349install: $(top_srcdir)/applets/install.sh busybox busybox.links 784export CPPFLAGS_busybox.lds += -P -C -U$(ARCH)
350 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \ 785
351 $(SHELL) $< $(PREFIX) $(INSTALL_OPTS) 786# FIXME: The asm symlink changes when $(ARCH) changes. That's
352ifeq ($(strip $(CONFIG_FEATURE_SUID)),y) 787# hard to detect, but I suppose "make mrproper" is a good idea
353 @echo 788# before switching between archs anyway.
789
790#bbox# include/asm:
791#bbox# @echo ' SYMLINK $@ -> include/asm-$(ARCH)'
792#bbox# $(Q)if [ ! -d include ]; then mkdir -p include; fi;
793#bbox# @ln -fsn asm-$(ARCH) $@
794
795# Split autoconf.h into include/linux/config/*
796#bbox# piggybacked generation of few .h files
797include/config/MARKER: scripts/basic/split-include include/autoconf.h
798 @echo ' SPLIT include/autoconf.h -> include/config/*'
799 @scripts/basic/split-include include/autoconf.h include/config
800 @echo ' GEN include/bbconfigopts.h'
801 @scripts/mkconfigs >include/bbconfigopts.h
802 @$(MAKE) $(build)=scripts
803 @echo ' GEN include/usage_compressed.h'
804 @scripts/usage_compressed include/usage_compressed.h scripts
805 @touch $@
806
807# Generate some files
808# ---------------------------------------------------------------------------
809
810# KERNELRELEASE can change from a few different places, meaning version.h
811# needs to be updated, so this check is forced on all builds
812
813uts_len := 64
814
815define filechk_version.h
816 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
817 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
818 exit 1; \
819 fi; \
820 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
821 echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
822 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
823 )
824endef
825
826# ---------------------------------------------------------------------------
827
828PHONY += depend dep
829depend dep:
830 @echo '*** Warning: make $@ is unnecessary now.'
831
832# ---------------------------------------------------------------------------
833# Modules
834
835ifdef CONFIG_MODULES
836
837# By default, build modules as well
838
839all: modules
840
841# Build modules
842
843PHONY += modules
844modules: $(busybox-dirs) $(if $(KBUILD_BUILTIN),busybox)
845 @echo ' Building modules, stage 2.';
846 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
847
848
849# Target to prepare building external modules
850PHONY += modules_prepare
851modules_prepare: prepare scripts
852
853# Target to install modules
854PHONY += modules_install
855modules_install: _modinst_ _modinst_post
856
857PHONY += _modinst_
858_modinst_:
859 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
860 echo "Warning: you may need to install module-init-tools"; \
861 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
862 sleep 1; \
863 fi
864 @rm -rf $(MODLIB)/kernel
865 @rm -f $(MODLIB)/source
866 @mkdir -p $(MODLIB)/kernel
867 @ln -s $(srctree) $(MODLIB)/source
868 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
869 rm -f $(MODLIB)/build ; \
870 ln -s $(objtree) $(MODLIB)/build ; \
871 fi
872 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
873
874# If System.map exists, run depmod. This deliberately does not have a
875# dependency on System.map since that would run the dependency tree on
876# busybox. This depmod is only for convenience to give the initial
877# boot a modules.dep even before / is mounted read-write. However the
878# boot script depmod is the master version.
879ifeq "$(strip $(INSTALL_MOD_PATH))" ""
880depmod_opts :=
881else
882depmod_opts := -b $(INSTALL_MOD_PATH) -r
883endif
884PHONY += _modinst_post
885_modinst_post: _modinst_
886 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
887
888else # CONFIG_MODULES
889
890# Modules not configured
891# ---------------------------------------------------------------------------
892
893modules modules_install: FORCE
354 @echo 894 @echo
355 @echo -------------------------------------------------- 895 @echo "The present kernel configuration has modules disabled."
356 @echo You will probably need to make your busybox binary 896 @echo "Type 'make config' and enable loadable module support."
357 @echo setuid root to ensure all configured applets will 897 @echo "Then build a kernel with module support enabled."
358 @echo work properly.
359 @echo --------------------------------------------------
360 @echo 898 @echo
361endif 899 @exit 1
362 900
363uninstall: busybox.links 901endif # CONFIG_MODULES
364 rm -f $(PREFIX)/bin/busybox
365 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
366ifneq ($(strip $(DO_INSTALL_LIBS)),n)
367 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
368 rm -f $(PREFIX)$$i; \
369 done
370endif
371 902
372check test: busybox 903###
373 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite SED="$(SED)" \ 904# Cleaning is done on three levels.
374 $(SHELL) $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE) 905# make clean Delete most generated files
906# Leave enough to build external modules
907# make mrproper Delete the current configuration, and all generated files
908# make distclean Remove editor backup files, patch leftover files and the like
909
910# Directories & files removed with 'make clean'
911CLEAN_DIRS += $(MODVERDIR)
912CLEAN_FILES += busybox System.map \
913 .tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
914
915# Directories & files removed with 'make mrproper'
916MRPROPER_DIRS += include/config include2
917MRPROPER_FILES += .config .config.old include/asm .version .old_version \
918 include/autoconf.h \
919 .kernelrelease Module.symvers tags TAGS cscope*
920
921# clean - Delete most, but leave enough to build external modules
922#
923clean: rm-dirs := $(CLEAN_DIRS)
924clean: rm-files := $(CLEAN_FILES)
925clean-dirs := $(addprefix _clean_,$(srctree) $(busybox-alldirs))
926
927PHONY += $(clean-dirs) clean archclean
928$(clean-dirs):
929 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
930
931clean: archclean $(clean-dirs)
932 $(call cmd,rmdirs)
933 $(call cmd,rmfiles)
934 @find . $(RCS_FIND_IGNORE) \
935 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
936 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
937 -type f -print | xargs rm -f
938
939# mrproper - Delete all generated files, including .config
940#
941mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
942mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
943mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts)
375 944
376checkhelp: 945PHONY += $(mrproper-dirs) mrproper archmrproper
377 $(Q)$(top_srcdir)/scripts/checkhelp.awk \ 946$(mrproper-dirs):
378 $(wildcard $(patsubst %,%/Config.in,$(SRC_DIRS) ./)) 947 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
379 948
380sizes: busybox_unstripped 949mrproper: clean archmrproper $(mrproper-dirs)
381 $(NM) --size-sort $(<) 950 $(call cmd,rmdirs)
951 $(call cmd,rmfiles)
382 952
383bloatcheck: busybox_old busybox_unstripped 953# distclean
384 @$(top_srcdir)/scripts/bloat-o-meter busybox_old busybox_unstripped 954#
955PHONY += distclean
385 956
386baseline: busybox_unstripped 957distclean: mrproper
387 @mv busybox_unstripped busybox_old 958 @find $(srctree) $(RCS_FIND_IGNORE) \
959 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
960 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
961 -o -name '.*.rej' -o -size 0 \
962 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
963 -type f -print | xargs rm -f
388 964
389objsizes: busybox_unstripped
390 $(SHELL) $(top_srcdir)/scripts/objsizes
391 965
392# Documentation Targets 966# Packaging of the kernel to various formats
393doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html 967# ---------------------------------------------------------------------------
968# rpm target kept for backward compatibility
969package-dir := $(srctree)/scripts/package
394 970
395docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod $(top_srcdir)/docs/autodocifier.pl 971%pkg: FORCE
396 $(disp_doc) 972 $(Q)$(MAKE) $(build)=$(package-dir) $@
397 $(Q)-mkdir -p docs 973rpm: FORCE
398 $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \ 974 $(Q)$(MAKE) $(build)=$(package-dir) $@
399 $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \
400 cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod
401 975
402docs/BusyBox.txt: docs/busybox.pod
403 $(disp_doc)
404 $(Q)-mkdir -p docs
405 $(Q)-pod2text $< > $@
406 976
407docs/BusyBox.1: docs/busybox.pod 977# Brief documentation of the typical targets used
408 $(disp_doc) 978# ---------------------------------------------------------------------------
409 $(Q)-mkdir -p docs
410 $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
411 $< > $@
412 979
413docs/BusyBox.html: docs/busybox.net/BusyBox.html 980boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig)
414 $(disp_doc) 981boards := $(notdir $(boards))
415 $(Q)-mkdir -p docs
416 $(Q)-rm -f docs/BusyBox.html
417 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
418 982
419docs/busybox.net/BusyBox.html: docs/busybox.pod 983-include Makefile.help
420 $(Q)-mkdir -p docs/busybox.net
421 $(Q)-pod2html --noindex $< > \
422 docs/busybox.net/BusyBox.html
423 $(Q)-rm -f pod2htm*
424 984
425# The nifty new dependency stuff 985# Documentation targets
426scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c 986# ---------------------------------------------------------------------------
427 $(do_link.h) 987%docs: scripts_basic FORCE
988 $(Q)$(MAKE) $(build)=Documentation/DocBook $@
989
990else # KBUILD_EXTMOD
991
992###
993# External module support.
994# When building external modules the kernel used as basis is considered
995# read-only, and no consistency checks are made and the make
996# system is not used on the basis kernel. If updates are required
997# in the basis kernel ordinary make commands (without M=...) must
998# be used.
999#
1000# The following are the only valid targets when building external
1001# modules.
1002# make M=dir clean Delete all automatically generated files
1003# make M=dir modules Make all modules in specified dir
1004# make M=dir Same as 'make M=dir modules'
1005# make M=dir modules_install
1006# Install the modules build in the module directory
1007# Assumes install directory is already created
1008
1009# We are always building modules
1010KBUILD_MODULES := 1
1011PHONY += crmodverdir
1012crmodverdir:
1013 $(Q)mkdir -p $(MODVERDIR)
1014 $(Q)rm -f $(MODVERDIR)/*
1015
1016PHONY += $(objtree)/Module.symvers
1017$(objtree)/Module.symvers:
1018 @test -e $(objtree)/Module.symvers || ( \
1019 echo; \
1020 echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \
1021 echo " is missing; modules will have no dependencies and modversions."; \
1022 echo )
1023
1024module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
1025PHONY += $(module-dirs) modules
1026$(module-dirs): crmodverdir $(objtree)/Module.symvers
1027 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
1028
1029modules: $(module-dirs)
1030 @echo ' Building modules, stage 2.';
1031 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1032
1033PHONY += modules_install
1034modules_install: _emodinst_ _emodinst_post
1035
1036install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1037PHONY += _emodinst_
1038_emodinst_:
1039 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1040 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
1041
1042# Run depmod only is we have System.map and depmod is executable
1043quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1044 cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \
1045 $(DEPMOD) -ae -F System.map \
1046 $(if $(strip $(INSTALL_MOD_PATH)), \
1047 -b $(INSTALL_MOD_PATH) -r) \
1048 $(KERNELRELEASE); \
1049 fi
1050
1051PHONY += _emodinst_post
1052_emodinst_post: _emodinst_
1053 $(call cmd,depmod)
1054
1055clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
1056
1057PHONY += $(clean-dirs) clean
1058$(clean-dirs):
1059 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1060
1061clean: rm-dirs := $(MODVERDIR)
1062clean: $(clean-dirs)
1063 $(call cmd,rmdirs)
1064 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
1065 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1066 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
1067 -type f -print | xargs rm -f
428 1068
429DEP_INCLUDES := include/bb_config.h 1069help:
1070 @echo ' Building external modules.'
1071 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1072 @echo ''
1073 @echo ' modules - default target, build the module(s)'
1074 @echo ' modules_install - install the module'
1075 @echo ' clean - remove generated files in module directory only'
1076 @echo ''
1077
1078# Dummies...
1079PHONY += prepare scripts
1080prepare: ;
1081scripts: ;
1082endif # KBUILD_EXTMOD
1083
1084# Generate tags for editors
1085# ---------------------------------------------------------------------------
430 1086
431ifeq ($(strip $(CONFIG_BBCONFIG)),y) 1087#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
432DEP_INCLUDES += include/bbconfigopts.h 1088#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
1089#Adding $(srctree) adds about 20M on i386 to the size of the output file!
433 1090
434include/bbconfigopts.h: .config $(top_srcdir)/scripts/config/mkconfigs 1091ifeq ($(src),$(obj))
435 $(disp_gen) 1092__srctree =
436 $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@ 1093else
1094__srctree = $(srctree)/
437endif 1095endif
438 1096
439ifeq ($(strip $(CONFIG_FEATURE_COMPRESS_USAGE)),y) 1097ifeq ($(ALLSOURCE_ARCHS),)
440USAGE_BIN:=scripts/usage 1098ifeq ($(ARCH),um)
441$(USAGE_BIN): $(top_srcdir)/scripts/usage.c .config \ 1099ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
442 $(top_srcdir)/include/usage.h 1100else
443 $(do_link.h) 1101ALLINCLUDE_ARCHS := $(ARCH)
444 1102endif
445DEP_INCLUDES += include/usage_compressed.h 1103else
446 1104#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
447include/usage_compressed.h: .config $(USAGE_BIN) \ 1105ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
448 $(top_srcdir)/scripts/usage_compressed 1106endif
449 $(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed \ 1107
450 "$(top_builddir)/scripts" > $@ 1108ALLSOURCE_ARCHS := $(ARCH)
451endif # CONFIG_FEATURE_COMPRESS_USAGE 1109
452 1110define all-sources
453depend dep: .depend 1111 ( find $(__srctree) $(RCS_FIND_IGNORE) \
454.depend: scripts/bb_mkdep $(USAGE_BIN) $(DEP_INCLUDES) 1112 \( -name include -o -name arch \) -prune -o \
455 $(disp_gen) 1113 -name '*.[chS]' -print; \
456 $(Q)rm -f .depend 1114 for ARCH in $(ALLSOURCE_ARCHS) ; do \
457 $(Q)mkdir -p include/config 1115 find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \
458 $(Q)scripts/bb_mkdep -I $(top_srcdir)/include $(top_srcdir) > $@.tmp 1116 -name '*.[chS]' -print; \
459 $(Q)mv $@.tmp $@ 1117 done ; \
460 1118 find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
461include/bb_config.h: .config 1119 -name '*.[chS]' -print; \
462 @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \ 1120 find $(__srctree)include $(RCS_FIND_IGNORE) \
463 $(MAKE) -C scripts/config conf; \ 1121 \( -name config -o -name 'asm-*' \) -prune \
464 fi; 1122 -o -name '*.[chS]' -print; \
465 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN) 1123 for ARCH in $(ALLINCLUDE_ARCHS) ; do \
466 1124 find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \
467clean: 1125 -name '*.[chS]' -print; \
468 - $(MAKE) -C scripts/config $@ 1126 done ; \
469 - rm -f docs/busybox.dvi docs/busybox.ps \ 1127 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
470 docs/busybox.pod docs/busybox.net/busybox.html \ 1128 -name '*.[chS]' -print )
471 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \ 1129endef
472 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \ 1130
473 docs/busybox.net/BusyBox.html busybox.links \ 1131quiet_cmd_cscope-file = FILELST cscope.files
474 libbusybox.so* \ 1132 cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
475 .config.old busybox busybox_unstripped \ 1133
476 include/usage_compressed.h scripts/usage 1134quiet_cmd_cscope = MAKE cscope.out
477 - rm -r -f _install testsuite/links 1135 cmd_cscope = cscope -b
478 - find . -name .\*.flags -o -name \*.o -o -name \*.om -o -name \*.syn \ 1136
479 -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f 1137cscope: FORCE
480 1138 $(call cmd,cscope-file)
481distclean: clean 1139 $(call cmd,cscope)
482 rm -f scripts/bb_mkdep scripts/usage 1140
483 rm -r -f include/config include/config.h $(DEP_INCLUDES) 1141quiet_cmd_TAGS = MAKE $@
484 find . -name .depend'*' -print0 | xargs -0 rm -f 1142define cmd_TAGS
485 find . -name '*.rej' -print0 | xargs -0 rm -f 1143 rm -f $@; \
486 rm -f .hdepend busybox_old .config .config.old .config.cmd 1144 ETAGSF=`etags --version | grep -i exuberant >/dev/null && \
487 1145 echo "-I __initdata,__exitdata,__acquires,__releases \
488release: distclean #doc 1146 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
489 cd ..; \ 1147 --extra=+f --c-kinds=+px"`; \
490 rm -r -f $(PROG)-$(VERSION); \ 1148 $(all-sources) | xargs etags $$ETAGSF -a
491 cp -a busybox $(PROG)-$(VERSION); \ 1149endef
492 \ 1150
493 find $(PROG)-$(VERSION)/ -type d \ 1151TAGS: FORCE
494 -name .svn \ 1152 $(call cmd,TAGS)
495 -print \ 1153
496 -exec rm -r -f {} \; ; \ 1154
497 \ 1155quiet_cmd_tags = MAKE $@
498 find $(PROG)-$(VERSION)/ -type f \ 1156define cmd_tags
499 -name .\#* \ 1157 rm -f $@; \
500 -print \ 1158 CTAGSF=`ctags --version | grep -i exuberant >/dev/null && \
501 -exec rm -f {} \; ; \ 1159 echo "-I __initdata,__exitdata,__acquires,__releases \
502 \ 1160 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
503 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/; 1161 --extra=+f --c-kinds=+px"`; \
504 1162 $(all-sources) | xargs ctags $$CTAGSF -a
505tags: 1163endef
506 ctags -R . 1164
507 1165tags: FORCE
508# documentation, cross-reference 1166 $(call cmd,tags)
509# Modern distributions already ship synopsis packages (e.g. debian) 1167
510# If you have an old distribution go to http://synopsis.fresco.org/ 1168
511syn_tgt := $(wildcard $(patsubst %,%/*.c,$(SRC_DIRS))) 1169# Scripts to check various things for consistency
512syn := $(patsubst %.c, %.syn, $(syn_tgt)) 1170# ---------------------------------------------------------------------------
513 1171
514%.syn: %.c 1172includecheck:
515 synopsis -p C -l Comments.SSDFilter,Comments.Previous $(INCS) -Wp,verbose,debug,preprocess,cppflags="'$(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) $(APPLETS_DEFINE) $(BUSYBOX_DEFINE)'" -o $@ $< 1173 find * $(RCS_FIND_IGNORE) \
516html: $(syn) 1174 -name '*.[hcS]' -type f -print | sort \
517 synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^ 1175 | xargs $(PERL) -w scripts/checkincludes.pl
518 1176
519 1177versioncheck:
520endif # ifeq ($(skip-makefile),) 1178 find * $(RCS_FIND_IGNORE) \
1179 -name '*.[hcS]' -type f -print | sort \
1180 | xargs $(PERL) -w scripts/checkversion.pl
1181
1182namespacecheck:
1183 $(PERL) $(srctree)/scripts/namespace.pl
1184
1185endif #ifeq ($(config-targets),1)
1186endif #ifeq ($(mixed-targets),1)
1187
1188PHONY += checkstack
1189checkstack:
1190 $(OBJDUMP) -d busybox $$(find . -name '*.ko') | \
1191 $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
1192
1193kernelrelease:
1194 $(if $(wildcard .kernelrelease), $(Q)echo $(KERNELRELEASE), \
1195 $(error kernelrelease not valid - run 'make *config' to update it))
1196kernelversion:
1197 @echo $(KERNELVERSION)
1198
1199# Single targets
1200# ---------------------------------------------------------------------------
1201# Single targets are compatible with:
1202# - build whith mixed source and output
1203# - build with separate output dir 'make O=...'
1204# - external modules
1205#
1206# target-dir => where to store outputfile
1207# build-dir => directory in kernel source tree to use
1208
1209ifeq ($(KBUILD_EXTMOD),)
1210 build-dir = $(patsubst %/,%,$(dir $@))
1211 target-dir = $(dir $@)
1212else
1213 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1214 build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1215 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
1216endif
1217
1218%.s: %.c prepare scripts FORCE
1219 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1220%.i: %.c prepare scripts FORCE
1221 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1222%.o: %.c prepare scripts FORCE
1223 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1224%.lst: %.c prepare scripts FORCE
1225 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1226%.s: %.S prepare scripts FORCE
1227 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1228%.o: %.S prepare scripts FORCE
1229 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1230
1231# Modules
1232/ %/: prepare scripts FORCE
1233 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1234 $(build)=$(build-dir)
1235%.ko: prepare scripts FORCE
1236 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1237 $(build)=$(build-dir) $(@:.ko=.o)
1238 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1239
1240# FIXME Should go into a make.lib or something
1241# ===========================================================================
1242
1243quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
1244 cmd_rmdirs = rm -rf $(rm-dirs)
1245
1246quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
1247 cmd_rmfiles = rm -f $(rm-files)
1248
1249
1250a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
1251 $(NOSTDINC_FLAGS) $(CPPFLAGS) \
1252 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
1253
1254quiet_cmd_as_o_S = AS $@
1255cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
1256
1257# read all saved command lines
1258
1259targets := $(wildcard $(sort $(targets)))
1260cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
1261
1262ifneq ($(cmd_files),)
1263 $(cmd_files): ; # Do not try to update included dependency files
1264 include $(cmd_files)
1265endif
1266
1267# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1268# Usage:
1269# $(Q)$(MAKE) $(clean)=dir
1270clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1271
1272endif # skip-makefile
1273
1274PHONY += FORCE
1275FORCE:
1276
1277-include Makefile.custom
521 1278
1279# Declare the contents of the .PHONY variable as phony. We keep that
1280# information in a variable se we can use it in if_changed and friends.
1281.PHONY: $(PHONY)
diff --git a/Makefile.custom b/Makefile.custom
new file mode 100644
index 000000000..6880b97d6
--- /dev/null
+++ b/Makefile.custom
@@ -0,0 +1,131 @@
1### # defconfig is allyesconfig minus any features that are specialized enough
2### # or cause enough behavior change that the user really should switch them on
3### # manually if that's what they want. Sort of "maximum sane config".
4
5### defconfig: scripts/config/conf
6### @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
7### @$(SED) -i -r -e "s/^(CONFIG_(DEBUG.*|STATIC|SELINUX|NITPICK|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config
8### @./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
9
10### allbareconfig: scripts/config/conf
11### @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
12### @$(SED) -i -r -e "s/^(CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config
13### @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
14### @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
15### @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
16
17### hosttools:
18### $(Q)cp .config .config.bak || noold=yea
19### $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" allnoconfig
20### $(Q)mv .config .config.in
21### $(Q)(grep -v CONFIG_SED .config.in ; \
22### echo "CONFIG_SED=y" ; ) > .config
23### $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" oldconfig include/bb_config.h
24### $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" busybox
25### $(Q)[ -f .config.bak ] && mv .config.bak .config || rm .config
26### mv busybox sed
27### @echo "Now do: $(MAKE) SED=$(objtree)/sed <target>"
28
29%.bflt: %_unstripped
30 $(CROSS_COMPILE)elf2flt $(ELF2FLTFLAGS) $< -o $@
31
32busybox.links: $(srctree)/applets/busybox.mkll include/bb_config.h $(srctree)/include/applets.h
33 $(Q)-$(SHELL) $^ >$@
34
35.PHONY: install
36install: $(srctree)/applets/install.sh busybox busybox.links
37 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
38 $(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
39ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
40 @echo
41 @echo
42 @echo --------------------------------------------------
43 @echo You will probably need to make your busybox binary
44 @echo setuid root to ensure all configured applets will
45 @echo work properly.
46 @echo --------------------------------------------------
47 @echo
48endif
49
50uninstall: busybox.links
51 rm -f $(CONFIG_PREFIX)/bin/busybox
52 for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
53ifneq ($(strip $(DO_INSTALL_LIBS)),n)
54 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
55 rm -f $(CONFIG_PREFIX)$$i; \
56 done
57endif
58
59check test: busybox
60 bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
61 $(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:1=),-v)
62
63### checkhelp:
64### $(Q)$(srctree)/scripts/checkhelp.awk \
65### $(wildcard $(patsubst %,%/Config.in,$(SRC_DIRS) ./))
66
67.PHONY: sizes
68sizes: busybox_unstripped
69 $(NM) --size-sort $(<)
70
71.PHONY: bloatcheck
72bloatcheck: busybox_old busybox_unstripped
73 @$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
74
75.PHONY: baseline
76baseline: busybox_unstripped
77 @mv busybox_unstripped busybox_old
78
79.PHONY: objsizes
80objsizes: busybox_unstripped
81 $(SHELL) $(srctree)/scripts/objsizes
82
83# Documentation Targets
84.PHONY: doc
85doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
86
87docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
88 $(srctree)/include/usage.h \
89 $(srctree)/docs/busybox_footer.pod \
90 $(srctree)/docs/autodocifier.pl
91 $(disp_doc)
92 $(Q)-mkdir -p docs
93 $(Q)-( cat $(srctree)/docs/busybox_header.pod ; \
94 $(srctree)/docs/autodocifier.pl $(srctree)/include/usage.h ; \
95 cat $(srctree)/docs/busybox_footer.pod ; ) > docs/busybox.pod
96
97docs/BusyBox.txt: docs/busybox.pod
98 $(disp_doc)
99 $(Q)-mkdir -p docs
100 $(Q)-pod2text $< > $@
101
102docs/BusyBox.1: docs/busybox.pod
103 $(disp_doc)
104 $(Q)-mkdir -p docs
105 $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
106 $< > $@
107
108docs/BusyBox.html: docs/busybox.net/BusyBox.html
109 $(disp_doc)
110 $(Q)-mkdir -p docs
111 $(Q)-rm -f docs/BusyBox.html
112 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
113
114docs/busybox.net/BusyBox.html: docs/busybox.pod
115 $(Q)-mkdir -p docs/busybox.net
116 $(Q)-pod2html --noindex $< > \
117 docs/busybox.net/BusyBox.html
118 $(Q)-rm -f pod2htm*
119
120# documentation, cross-reference
121# Modern distributions already ship synopsis packages (e.g. debian)
122# If you have an old distribution go to http://synopsis.fresco.org/
123syn_tgt := $(wildcard $(patsubst %,%/*.c,$(SRC_DIRS)))
124syn := $(patsubst %.c, %.syn, $(syn_tgt))
125
126%.syn: %.c
127 synopsis -p C -l Comments.SSDFilter,Comments.Previous $(INCS) -Wp,verbose,debug,preprocess,cppflags="'$(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) $(APPLETS_DEFINE) $(BUSYBOX_DEFINE)'" -o $@ $<
128
129.PHONY: html
130html: $(syn)
131 synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
diff --git a/Makefile.flags b/Makefile.flags
new file mode 100644
index 000000000..39c544e60
--- /dev/null
+++ b/Makefile.flags
@@ -0,0 +1,19 @@
1# ==========================================================================
2# Building
3# ==========================================================================
4
5BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
6
7CPPFLAGS += \
8 -Iinclude -Ilibbb \
9 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
10 -include include/autoconf.h \
11 -D_GNU_SOURCE -DNDEBUG \
12 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 \
13 -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP \
14 -Wall -Wstrict-prototypes -Wshadow -Werror \
15 -funsigned-char -fno-builtin-strlen -finline-limit=0 -static-libgcc \
16 -Os -march=i386 -mpreferred-stack-boundary=2 \
17 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
18 -fomit-frame-pointer -ffunction-sections -fdata-sections \
19 -funsigned-char -fno-builtin-strlen \
diff --git a/Makefile.help b/Makefile.help
new file mode 100644
index 000000000..3ba68d1e4
--- /dev/null
+++ b/Makefile.help
@@ -0,0 +1,88 @@
1### Kernel's one:
2### help:
3### @echo 'Cleaning targets:'
4### @echo ' clean - remove most generated files but keep the config'
5### @echo ' mrproper - remove all generated files + config + various backup files'
6### @echo ''
7### @echo 'Configuration targets:'
8### @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
9### @echo ''
10### @echo 'Other generic targets:'
11### @echo ' all - Build all targets marked with [*]'
12### @echo '* busybox - Build the bare kernel'
13### @echo '* modules - Build all modules'
14### @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
15### @echo ' dir/ - Build all files in dir and below'
16### @echo ' dir/file.[ois] - Build specified target only'
17### @echo ' dir/file.ko - Build module including final link'
18### @echo ' rpm - Build a kernel as an RPM package'
19### @echo ' tags/TAGS - Generate tags file for editors'
20### @echo ' cscope - Generate cscope index'
21### @echo ' kernelrelease - Output the release version string'
22### @echo ' kernelversion - Output the version stored in Makefile'
23### @echo ''
24### @echo 'Static analysers'
25### @echo ' checkstack - Generate a list of stack hogs'
26### @echo ' namespacecheck - Name space analysis on compiled kernel'
27### @echo ''
28### @echo 'Kernel packaging:'
29### @$(MAKE) $(build)=$(package-dir) help
30### @echo ''
31### @echo 'Documentation targets:'
32### @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
33### @echo ''
34### @echo 'Architecture specific targets ($(ARCH)):'
35### @$(if $(archhelp),$(archhelp),\
36### echo ' No architecture specific help defined for $(ARCH)')
37### @echo ''
38### @$(if $(boards), \
39### $(foreach b, $(boards), \
40### printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
41### echo '')
42###
43### @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
44### @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
45### @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse)'
46### @echo ' make C=2 [targets] Force check of all c source with $$CHECK (sparse)'
47### @echo ''
48### @echo 'Execute "make" or "make all" to build all targets marked with [*] '
49### @echo 'For further info see the ./README file'
50
51help:
52 @echo 'Cleaning:'
53 @echo ' clean - delete temporary files created by build'
54 @echo ' distclean - delete all non-source files (including .config)'
55 @echo
56 @echo 'Build:'
57 @echo ' all - Executable and documentation'
58 @echo ' busybox - the swiss-army executable'
59 @echo ' doc - docs/BusyBox.{txt,html,1}'
60 @echo ' html - create html-based cross-reference'
61 @echo
62 @echo 'Configuration:'
63 @echo ' allnoconfig - disable all symbols in .config'
64 @echo ' allyesconfig - enable all symbols in .config (see defconfig)'
65 @echo ' allbareconfig - enable all applets without any sub-features'
66 @echo ' config - text based configurator (of last resort)'
67 @echo ' defconfig - set .config to largest generic configuration'
68 @echo ' menuconfig - interactive curses-based configurator'
69 @echo ' oldconfig - resolve any unresolved symbols in .config'
70 @echo ' hosttools - build sed for the host.'
71 @echo ' You can use these commands if the commands on the host'
72 @echo ' is unusable. Afterwards use it like:'
73 @echo ' make SED="$(objtree)/sed"'
74 @echo
75 @echo 'Installation:'
76 @echo ' install - install busybox into $(PREFIX)'
77 @echo ' uninstall'
78 @echo
79 @echo 'Development:'
80 @echo ' baseline - create busybox_old for bloatcheck.'
81 @echo ' bloatcheck - show size difference between old and new versions'
82 @echo ' check - run the test suite for all applets'
83 @echo ' checkhelp - check for missing help-entries in Config.in'
84 @echo ' randconfig - generate a random configuration'
85 @echo ' release - create a distribution tarball'
86 @echo ' sizes - show size of all enabled busybox symbols'
87 @echo ' objsizes - show size of each .o object built'
88 @echo
diff --git a/Rules.mak b/Rules.mak
deleted file mode 100644
index e0704989b..000000000
--- a/Rules.mak
+++ /dev/null
@@ -1,436 +0,0 @@
1# Rules.make for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under GPLv2, see the file LICENSE in this tarball for details.
6#
7
8# Pull in the user's busybox configuration
9ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
10-include $(top_builddir)/.config
11endif
12
13#--------------------------------------------------------
14PROG := busybox
15MAJOR_VERSION :=1
16MINOR_VERSION :=2
17SUBLEVEL_VERSION:=0
18EXTRAVERSION :=-svn
19VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
20BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
21
22
23#--------------------------------------------------------
24# With a modern GNU make(1) (highly recommended, that's what all the
25# developers use), all of the following configuration values can be
26# overridden at the command line. For example:
27# make CROSS_COMPILE=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
28#--------------------------------------------------------
29
30# If you are running a cross compiler, you will want to set CROSS_COMPILE
31# to something more interesting... Target architecture is determined
32# by asking the CC compiler what arch it compiles things for, so unless
33# your compiler is broken, you should not need to specify TARGET_ARCH
34CC = $(CROSS_COMPILE)gcc
35AR = $(CROSS_COMPILE)ar
36AS = $(CROSS_COMPILE)as
37LD = $(CROSS_COMPILE)ld
38NM = $(CROSS_COMPILE)nm
39STRIP = $(CROSS_COMPILE)strip
40ELF2FLT = $(CROSS_COMPILE)elf2flt
41CPP = $(CC) -E
42SED ?= sed
43BZIP2 ?= bzip2
44
45
46# What OS are you compiling busybox for? This allows you to include
47# OS specific things, syscall overrides, etc.
48TARGET_OS=linux
49
50# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
51LC_ALL:= C
52
53# This must bind late because srcdir is reset for every source subdirectory.
54INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include
55CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE
56CFLAGS+=$(CHECKED_CFLAGS)
57ARFLAGS=cru
58
59# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
60# get the CC MAJOR/MINOR version
61CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
62CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
63
64#--------------------------------------------------------
65export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS_COMPILE CC AR AS LD NM STRIP CPP
66ifeq ($(strip $(TARGET_ARCH)),)
67TARGET_ARCH:=$(shell $(CC) -dumpmachine | $(SED) -e s'/-.*//' \
68 -e 's/i.86/i386/' \
69 -e 's/sparc.*/sparc/' \
70 -e 's/arm.*/arm/g' \
71 -e 's/m68k.*/m68k/' \
72 -e 's/ppc/powerpc/g' \
73 -e 's/v850.*/v850/g' \
74 -e 's/sh[234]/sh/' \
75 -e 's/mips-.*/mips/' \
76 -e 's/mipsel-.*/mipsel/' \
77 -e 's/cris.*/cris/' \
78 )
79endif
80
81# A nifty macro to make testing gcc features easier, but note that everything
82# that uses this _must_ use := or it will be re-evaluated everytime it is
83# referenced.
84ifeq ($(strip $(BUILD_VERBOSE)),2)
85VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2;
86endif
87check_cc=$(shell \
88 $(VERBOSE_CHECK_CC) \
89 if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
90 echo "int i;" > ./conftest.c; \
91 if $(1) $(2) -c -o conftest.o conftest.c > /dev/null 2>&1; \
92 then echo "$(2)"; else echo "$(3)"; fi ; \
93 rm -f conftest.c conftest.o; \
94 fi)
95
96ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
97check_cc:=
98endif
99
100# A not very robust macro to check for available ld flags
101ifeq ($(strip $(BUILD_VERBOSE)),2)
102VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2;
103endif
104check_ld=$(shell \
105 $(VERBOSE_CHECK_LD) \
106 if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
107 $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && \
108 echo "-Wl,$(2)" ; \
109 fi)
110
111ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
112check_ld:=
113endif
114
115# A not very robust macro to check for available strip flags
116ifeq ($(strip $(BUILD_VERBOSE)),2)
117VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2;
118endif
119check_strip=$(shell \
120 $(VERBOSE_CHECK_STRIP) \
121 if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
122 echo "int i;" > ./conftest.c ; \
123 $(CC) -c -o conftest.o conftest.c > /dev/null 2>&1 ; \
124 $(1) $(2) conftest.o > /dev/null 2>&1 && \
125 echo "$(1) $(2)" || echo "$(3)"; \
126 rm -f conftest.c conftest.o > /dev/null 2>&1 ; \
127 fi)
128
129ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
130check_strip:=
131endif
132
133
134# Select the compiler needed to build binaries for your development system
135HOSTCC = gcc
136HOSTCFLAGS:=$(call check_cc,$(HOSTCC),-Wall,)
137HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-Wstrict-prototypes,)
138HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-O2,)
139HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-fomit-frame-pointer,)
140
141LD_WHOLE_ARCHIVE:=$(shell echo "int i;" > conftest.c ; \
142 $(CC) -c -o conftest.o conftest.c ; \
143 echo "int main(void){return 0;}" > conftest_main.c ; \
144 $(CC) -c -o conftest_main.o conftest_main.c ; \
145 $(AR) $(ARFLAGS) conftest.a conftest.o ; \
146 $(CC) -Wl,--whole-archive conftest.a -Wl,--no-whole-archive \
147 conftest_main.o -o conftest > /dev/null 2>&1 \
148 && echo "-Wl,--whole-archive" ; \
149 rm conftest_main.o conftest_main.c conftest.o conftest.c \
150 conftest.a conftest > /dev/null 2>&1 ; )
151ifneq ($(findstring whole-archive,$(LD_WHOLE_ARCHIVE)),)
152LD_NO_WHOLE_ARCHIVE:= -Wl,--no-whole-archive
153endif
154
155LD_START_GROUP:=$(shell echo "int bar(void){return 0;}" > conftest.c ; \
156 $(CC) -c -o conftest.o conftest.c ; \
157 echo "int main(void){return bar();}" > conftest_main.c ; \
158 $(CC) -c -o conftest_main.o conftest_main.c ; \
159 $(AR) $(ARFLAGS) conftest.a conftest.o ; \
160 $(CC) -Wl,--start-group conftest.a conftest_main.o -Wl,--end-group \
161 -o conftest > /dev/null 2>&1 && echo "-Wl,--start-group" ; \
162 rm conftest_main.o conftest_main.c conftest.o conftest.c \
163 conftest.a conftest > /dev/null 2>&1 ; )
164ifneq ($(findstring start-group,$(LD_START_GROUP)),)
165LD_END_GROUP:= -Wl,--end-group
166endif
167
168CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,)
169#CHECKED_LDFLAGS := $(call check_ld,$(LD),-static-libgcc,)
170
171# Pin CHECKED_CFLAGS with := so it's only evaluated once.
172CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,)
173CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
174CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
175CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,)
176CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen,)
177CHECKED_CFLAGS+=$(call check_cc,$(CC),-finline-limit=0,)
178
179# gcc 2.95 exits with 0 for "unrecognized option"
180ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
181 CHECKED_CFLAGS+=$(call check_cc,$(CC),-static-libgcc,)
182endif
183
184# Preemptively pin this too.
185PROG_CFLAGS:=
186
187
188#--------------------------------------------------------
189# Arch specific compiler optimization stuff should go here.
190# Unless you want to override the defaults, do not set anything
191# for OPTIMIZATION...
192
193# use '-Os' optimization if available, else use -O2
194OPTIMIZATION:=$(call check_cc,$(CC),-Os,-O2)
195
196ifeq ($(CONFIG_BUILD_AT_ONCE),y)
197# gcc 2.95 exits with 0 for "unrecognized option"
198ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
199 CFLAGS_COMBINE:=$(call check_cc,$(CC),--combine,)
200endif
201OPTIMIZATION+=$(call check_cc,$(CC),-funit-at-a-time,)
202OPTIMIZATION+=$(call check_cc,$(CC),-fgcse-after-reload,)
203ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y)
204# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
205# This prevents us from using -fwhole-program when we build the lib
206PROG_CFLAGS+=$(call check_cc,$(CC),-fwhole-program,)
207endif # CONFIG_BUILD_LIBBUSYBOX
208endif # CONFIG_BUILD_AT_ONCE
209
210LIB_LDFLAGS:=$(call check_ld,$(LD),--enable-new-dtags,)
211#LIB_LDFLAGS+=$(call check_ld,$(LD),--reduce-memory-overheads,)
212#LIB_LDFLAGS+=$(call check_ld,$(LD),--as-needed,)
213#LIB_LDFLAGS+=$(call check_ld,$(LD),--warn-shared-textrel,)
214
215
216# Some nice architecture specific optimizations
217ifeq ($(strip $(TARGET_ARCH)),arm)
218 OPTIMIZATION+=-fstrict-aliasing
219endif
220ifeq ($(strip $(TARGET_ARCH)),i386)
221 OPTIMIZATION+=$(call check_cc,$(CC),-march=i386,)
222# gcc-4.0 and older seem to benefit from these
223ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
224 OPTIMIZATION+=$(call check_cc,$(CC),-mpreferred-stack-boundary=2,)
225 OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1, -malign-functions=0 -malign-jumps=0 -malign-loops=0,)
226
227 # gcc 4.1 produces many broken, totally invalid warnings
228 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Werror,)
229endif # gcc-4.0 and older
230
231# gcc-4.1 and beyond seem to benefit from these
232ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
233 # turn off flags which hurt -Os
234 OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-loop-optimize,)
235 OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-dominator-opts,)
236 OPTIMIZATION+=$(call check_cc,$(CC),-fno-strength-reduce,)
237
238 OPTIMIZATION+=$(call check_cc,$(CC),-fno-branch-count-reg,)
239endif # gcc-4.1 and beyond
240endif
241OPTIMIZATION+=$(call check_cc,$(CC),-fomit-frame-pointer,)
242CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,)
243
244#
245#--------------------------------------------------------
246# If you're going to do a lot of builds with a non-vanilla configuration,
247# it makes sense to adjust parameters above, so you can type "make"
248# by itself, instead of following it by the same half-dozen overrides
249# every time. The stuff below, on the other hand, is probably less
250# prone to casual user adjustment.
251#
252
253ifeq ($(strip $(CONFIG_LFS)),y)
254 # For large file summit support
255 CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
256endif
257ifeq ($(strip $(CONFIG_DMALLOC)),y)
258 # For testing mem leaks with dmalloc
259 CFLAGS+=-DDMALLOC
260 LIBRARIES:=-ldmalloc
261else
262 ifeq ($(strip $(CONFIG_EFENCE)),y)
263 LIBRARIES:=-lefence
264 endif
265endif
266
267# Debugging info
268
269ifeq ($(strip $(CONFIG_DEBUG)),y)
270 CFLAGS +=-g
271else
272 CFLAGS +=-DNDEBUG
273endif
274
275ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y)
276 CFLAGS += $(OPTIMIZATION)
277endif
278
279# warn a bit more verbosely for non-release versions
280ifneq ($(EXTRAVERSION),)
281 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
282 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-prototypes,)
283 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-declarations,)
284 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wunused,)
285 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Winit-self,)
286 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
287 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wcast-align,)
288endif
289STRIPCMD:=$(call check_strip,$(STRIP),-s --remove-section=.note --remove-section=.comment,$(STRIP))
290ifeq ($(strip $(CONFIG_STATIC)),y)
291 PROG_CFLAGS += $(call check_cc,$(CC),-static,)
292else
293 ifneq ($(strip $(CONFIG_DEBUG)),y)
294 OPTIMIZATION+=$(call check_cc,$(CC),-ffunction-sections -fdata-sections,)
295 CHECKED_LDFLAGS += $(call check_ld,$(LD),--gc-sections,)
296 endif
297endif
298CFLAGS_SHARED := $(call check_cc,$(CC),-shared,)
299LIB_CFLAGS+=$(CFLAGS_SHARED)
300
301ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
302 CFLAGS_PIC:= $(call check_cc,$(CC),-fPIC,)
303 LIB_CFLAGS+=$(CFLAGS_PIC)
304endif
305
306ifeq ($(strip $(CONFIG_SELINUX)),y)
307 LIBRARIES += -lselinux -lsepol
308endif
309
310ifeq ($(strip $(PREFIX)),)
311 PREFIX:=`pwd`/_install
312endif
313
314ifneq ($(strip $(CONFIG_GETOPT_LONG)),y)
315 CFLAGS += -D__need_getopt
316endif
317
318# Additional complications due to support for pristine source dir.
319# Include files in the build directory should take precedence over
320# the copy in top_srcdir, both during the compilation phase and the
321# shell script that finds the list of object files.
322# Work in progress by <ldoolitt@recycle.lbl.gov>.
323
324
325OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
326CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS)
327LDFLAGS += $(CHECKED_LDFLAGS)
328
329ifdef BB_INIT_SCRIPT
330 CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
331endif
332
333# Put user-supplied flags at the end, where they
334# have a chance of winning.
335-include $(top_builddir)/.config.mak
336
337#------------------------------------------------------------
338# Installation options
339ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y)
340INSTALL_OPTS=--hardlinks
341endif
342ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y)
343INSTALL_OPTS=--symlinks
344endif
345ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
346INSTALL_OPTS=
347endif
348
349#------------------------------------------------------------
350# Make the output nice and tight
351MAKEFLAGS += --no-print-directory
352export MAKE_IS_SILENT=n
353ifneq ($(findstring s,$(MAKEFLAGS)),)
354export MAKE_IS_SILENT=y
355SECHO := @-false
356DISP := sil
357Q := @
358else
359ifneq ($(BUILD_VERBOSE),)
360SECHO := @-false
361DISP := ver
362Q :=
363else
364SECHO := @echo
365DISP := pur
366Q := @
367endif
368endif
369
370show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@))
371pur_disp_compile.c = echo " "CC $(show_objs) ;
372pur_disp_compile.h = echo " "HOSTCC $(show_objs) ;
373pur_disp_strip = echo " "STRIP $(show_objs) ;
374pur_disp_link = echo " "LINK $(show_objs) ;
375pur_disp_link.h = echo " "HOSTLINK $(show_objs) ;
376pur_disp_ar = echo " "AR $(ARFLAGS) $(show_objs) ;
377pur_disp_elf2flt = echo " "ELF2FLT $(ELF2FLTFLAGS) $(show_objs) ;
378sil_disp_compile.c =
379sil_disp_compile.h =
380sil_disp_strip =
381sil_disp_link =
382sil_disp_link.h =
383sil_disp_ar =
384sil_disp_elf2flt =
385ver_disp_compile.c =
386ver_disp_compile.h =
387ver_disp_strip =
388ver_disp_link =
389ver_disp_link.h =
390ver_disp_ar =
391ver_disp_elf2flt =
392disp_compile.c = $(Q)$($(DISP)_disp_compile.c)
393disp_compile.h = $(Q)$($(DISP)_disp_compile.h)
394disp_strip = $(Q)$($(DISP)_disp_strip)
395disp_link = $(Q)$($(DISP)_disp_link)
396disp_link.h = $(Q)$($(DISP)_disp_link.h)
397disp_ar = $(Q)$($(DISP)_disp_ar)
398disp_elf2flt = $(Q)$($(DISP)_disp_elf2flt)
399disp_gen = $(SECHO) " "GEN $@ ; true
400disp_doc = $(SECHO) " "DOC $(subst docs/,,$@) ; true
401cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
402cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) -c -o $@ $<
403cmd_strip = $(STRIPCMD) $@
404cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
405 $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
406 -o $@ $(LD_START_GROUP) \
407 $(APPLETS_DEFINE) $(APPLET_SRC) \
408 $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
409 $(LDBUSYBOX) $(LIBRARIES) \
410 $(LD_END_GROUP)
411cmd_link.so = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
412 $(LIB_CFLAGS) $(CFLAGS_COMBINE) $(LIB_LDFLAGS) \
413 -o $(@) $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \
414 $(LIBRARY_DEFINE) $(^) \
415 $(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP)
416cmd_link.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) $< -o $@
417cmd_ar = $(AR) $(ARFLAGS) $@ $^
418cmd_elf2flt = $(ELF2FLT) $(ELF2FLTFLAGS) $< -o $@
419compile.c = $(disp_compile.c) $(cmd_compile.c)
420compile.h = $(disp_compile.h) $(cmd_compile.h)
421do_strip = $(disp_strip) $(cmd_strip)
422do_link = $(disp_link) $(cmd_link)
423do_link.so = $(disp_link) $(cmd_link.so)
424do_link.h = $(disp_link.h) $(cmd_link.h)
425do_ar = $(disp_ar) $(cmd_ar)
426do_elf2flt = $(disp_elf2flt) $(cmd_elf2flt)
427
428uppercase = $(shell echo $1 | $(SED) -e "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/")
429%.a:
430 @if test -z "$($(call uppercase,$*)_DIR)" ; then \
431 echo "Invalid target $@" ; \
432 exit 1 ; \
433 fi
434 $(Q)$(MAKE) $($(call uppercase,$*)_DIR)$@
435
436.PHONY: dummy
diff --git a/applets/Kbuild b/applets/Kbuild
new file mode 100644
index 000000000..04932eec4
--- /dev/null
+++ b/applets/Kbuild
@@ -0,0 +1,9 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7obj-y:=
8obj-y += applets.o
9obj-y += busybox.o
diff --git a/applets/Makefile b/applets/Makefile
deleted file mode 100644
index 0d892f5e5..000000000
--- a/applets/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/applets
14APPLETS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include $(srcdir)/Makefile.in
18all: $(libraries-y)
19-include $(top_builddir).depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/applets/Makefile.in b/applets/Makefile.in
deleted file mode 100644
index 05580b9b4..000000000
--- a/applets/Makefile.in
+++ /dev/null
@@ -1,26 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7APPLETS_AR:=applets.a
8ifndef $(APPLETS_DIR)
9APPLETS_DIR:=$(top_builddir)/applets/
10endif
11srcdir=$(top_srcdir)/applets
12
13APPLET_SRC:= $(patsubst %,$(srcdir)/%,applets.c busybox.c)
14APPLET_OBJ:= $(patsubst $(srcdir)/%.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
15
16APPLET_SRC-y+=$(APPLET_SRC)
17APPLET_SRC-a+=$(APPLET_SRC)
18
19libraries-y+=$(APPLETS_DIR)$(APPLETS_AR)
20
21$(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
22 $(do_ar)
23
24$(APPLET_OBJ): $(top_builddir)/.config
25$(APPLET_OBJ): $(APPLETS_DIR)%.o: $(srcdir)/%.c
26 $(compile.c)
diff --git a/applets/applets.c b/applets/applets.c
index d615ffcd8..b1f580953 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -42,8 +42,6 @@ const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
42#ifdef CONFIG_FEATURE_SUID_CONFIG 42#ifdef CONFIG_FEATURE_SUID_CONFIG
43 43
44#include <ctype.h> 44#include <ctype.h>
45#include "pwd_.h"
46#include "grp_.h"
47 45
48#define CONFIG_FILE "/etc/busybox.conf" 46#define CONFIG_FILE "/etc/busybox.conf"
49 47
diff --git a/archival/Config.in b/archival/Config.in
index ea8076403..bc87573b1 100644
--- a/archival/Config.in
+++ b/archival/Config.in
@@ -5,7 +5,7 @@
5 5
6menu "Archival Utilities" 6menu "Archival Utilities"
7 7
8config CONFIG_AR 8config AR
9 bool "ar" 9 bool "ar"
10 default n 10 default n
11 help 11 help
@@ -28,17 +28,17 @@ config CONFIG_AR
28 Unless you have a specific application which requires ar, you should 28 Unless you have a specific application which requires ar, you should
29 probably say N here. 29 probably say N here.
30 30
31config CONFIG_FEATURE_AR_LONG_FILENAMES 31config FEATURE_AR_LONG_FILENAMES
32 bool "Enable support for long filenames (not need for debs)" 32 bool "Enable support for long filenames (not need for debs)"
33 default n 33 default n
34 depends on CONFIG_AR 34 depends on AR
35 help 35 help
36 By default the ar format can only store the first 15 characters of the 36 By default the ar format can only store the first 15 characters of the
37 filename, this option removes that limitation. 37 filename, this option removes that limitation.
38 It supports the GNU ar long filename method which moves multiple long 38 It supports the GNU ar long filename method which moves multiple long
39 filenames into a the data section of a new ar entry. 39 filenames into a the data section of a new ar entry.
40 40
41config CONFIG_BUNZIP2 41config BUNZIP2
42 bool "bunzip2" 42 bool "bunzip2"
43 default n 43 default n
44 help 44 help
@@ -54,7 +54,7 @@ config CONFIG_BUNZIP2
54 Unless you have a specific application which requires bunzip2, you 54 Unless you have a specific application which requires bunzip2, you
55 should probably say N here. 55 should probably say N here.
56 56
57config CONFIG_CPIO 57config CPIO
58 bool "cpio" 58 bool "cpio"
59 default n 59 default n
60 help 60 help
@@ -68,7 +68,7 @@ config CONFIG_CPIO
68 Unless you have a specific application which requires cpio, you should 68 Unless you have a specific application which requires cpio, you should
69 probably say N here. 69 probably say N here.
70 70
71config CONFIG_DPKG 71config DPKG
72 bool "dpkg" 72 bool "dpkg"
73 default n 73 default n
74 help 74 help
@@ -77,7 +77,7 @@ config CONFIG_DPKG
77 This implementation of dpkg has a number of limitations, you should use the 77 This implementation of dpkg has a number of limitations, you should use the
78 official dpkg if possible. 78 official dpkg if possible.
79 79
80config CONFIG_DPKG_DEB 80config DPKG_DEB
81 bool "dpkg_deb" 81 bool "dpkg_deb"
82 default n 82 default n
83 help 83 help
@@ -88,16 +88,16 @@ config CONFIG_DPKG_DEB
88 Unless you have a specific application which requires dpkg-deb, you should 88 Unless you have a specific application which requires dpkg-deb, you should
89 probably say N here. 89 probably say N here.
90 90
91config CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY 91config FEATURE_DPKG_DEB_EXTRACT_ONLY
92 bool "extract only (-x)" 92 bool "extract only (-x)"
93 default n 93 default n
94 depends on CONFIG_DPKG_DEB 94 depends on DPKG_DEB
95 help 95 help
96 This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx". 96 This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
97 However it saves space as none of the extra dpkg-deb, ar or tar options are 97 However it saves space as none of the extra dpkg-deb, ar or tar options are
98 needed, they are linked to internally. 98 needed, they are linked to internally.
99 99
100config CONFIG_GUNZIP 100config GUNZIP
101 bool "gunzip" 101 bool "gunzip"
102 default n 102 default n
103 help 103 help
@@ -105,35 +105,35 @@ config CONFIG_GUNZIP
105 You can use the `-t' option to test the integrity of 105 You can use the `-t' option to test the integrity of
106 an archive, without decompressing it. 106 an archive, without decompressing it.
107 107
108config CONFIG_FEATURE_GUNZIP_UNCOMPRESS 108config FEATURE_GUNZIP_UNCOMPRESS
109 bool "Uncompress support" 109 bool "Uncompress support"
110 default n 110 default n
111 depends on CONFIG_GUNZIP 111 depends on GUNZIP
112 help 112 help
113 Enable if you want gunzip to have the ability to decompress 113 Enable if you want gunzip to have the ability to decompress
114 archives created by the program compress (not much 114 archives created by the program compress (not much
115 used anymore). 115 used anymore).
116 116
117config CONFIG_GZIP 117config GZIP
118 bool "gzip" 118 bool "gzip"
119 default n 119 default n
120 help 120 help
121 gzip is used to compress files. 121 gzip is used to compress files.
122 It's probably the most widely used UNIX compression program. 122 It's probably the most widely used UNIX compression program.
123 123
124config CONFIG_RPM2CPIO 124config RPM2CPIO
125 bool "rpm2cpio" 125 bool "rpm2cpio"
126 default n 126 default n
127 help 127 help
128 Converts an RPM file into a CPIO archive. 128 Converts an RPM file into a CPIO archive.
129 129
130config CONFIG_RPM 130config RPM
131 bool "rpm" 131 bool "rpm"
132 default n 132 default n
133 help 133 help
134 Mini RPM applet - queries and extracts 134 Mini RPM applet - queries and extracts
135 135
136config CONFIG_TAR 136config TAR
137 bool "tar" 137 bool "tar"
138 default n 138 default n
139 help 139 help
@@ -141,86 +141,86 @@ config CONFIG_TAR
141 create compressed archives. It's probably the most widely used 141 create compressed archives. It's probably the most widely used
142 UNIX archive program. 142 UNIX archive program.
143 143
144config CONFIG_FEATURE_TAR_CREATE 144config FEATURE_TAR_CREATE
145 bool "Enable archive creation" 145 bool "Enable archive creation"
146 default y 146 default y
147 depends on CONFIG_TAR 147 depends on TAR
148 help 148 help
149 If you enable this option you'll be able to create 149 If you enable this option you'll be able to create
150 tar archives using the `-c' option. 150 tar archives using the `-c' option.
151 151
152config CONFIG_FEATURE_TAR_BZIP2 152config FEATURE_TAR_BZIP2
153 bool "Enable -j option to handle .tar.bz2 files" 153 bool "Enable -j option to handle .tar.bz2 files"
154 default n 154 default n
155 depends on CONFIG_TAR 155 depends on TAR
156 help 156 help
157 If you enable this option you'll be able to extract 157 If you enable this option you'll be able to extract
158 archives compressed with bzip2. 158 archives compressed with bzip2.
159 159
160config CONFIG_FEATURE_TAR_LZMA 160config FEATURE_TAR_LZMA
161 bool "Enable -a option to handle .tar.lzma files" 161 bool "Enable -a option to handle .tar.lzma files"
162 default n 162 default n
163 depends on CONFIG_TAR 163 depends on TAR
164 help 164 help
165 If you enable this option you'll be able to extract 165 If you enable this option you'll be able to extract
166 archives compressed with lzma. 166 archives compressed with lzma.
167 167
168config CONFIG_FEATURE_TAR_FROM 168config FEATURE_TAR_FROM
169 bool "Enable -X (exclude from) and -T (include from) options)" 169 bool "Enable -X (exclude from) and -T (include from) options)"
170 default n 170 default n
171 depends on CONFIG_TAR 171 depends on TAR
172 help 172 help
173 If you enable this option you'll be able to specify 173 If you enable this option you'll be able to specify
174 a list of files to include or exclude from an archive. 174 a list of files to include or exclude from an archive.
175 175
176config CONFIG_FEATURE_TAR_GZIP 176config FEATURE_TAR_GZIP
177 bool "Enable -z option" 177 bool "Enable -z option"
178 default y 178 default y
179 depends on CONFIG_TAR 179 depends on TAR
180 help 180 help
181 If you enable this option tar will be able to call gzip, 181 If you enable this option tar will be able to call gzip,
182 when creating or extracting tar gziped archives. 182 when creating or extracting tar gziped archives.
183 183
184config CONFIG_FEATURE_TAR_COMPRESS 184config FEATURE_TAR_COMPRESS
185 bool "Enable -Z option" 185 bool "Enable -Z option"
186 default n 186 default n
187 depends on CONFIG_TAR 187 depends on TAR
188 help 188 help
189 If you enable this option tar will be able to call uncompress, 189 If you enable this option tar will be able to call uncompress,
190 when extracting .tar.Z archives. 190 when extracting .tar.Z archives.
191 191
192config CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY 192config FEATURE_TAR_OLDGNU_COMPATIBILITY
193 bool "Enable support for old tar header format" 193 bool "Enable support for old tar header format"
194 default N 194 default N
195 depends on CONFIG_TAR 195 depends on TAR
196 help 196 help
197 This option is required to unpack archives created in 197 This option is required to unpack archives created in
198 the old GNU format; help to kill this old format by 198 the old GNU format; help to kill this old format by
199 repacking your ancient archives with the new format. 199 repacking your ancient archives with the new format.
200 200
201config CONFIG_FEATURE_TAR_GNU_EXTENSIONS 201config FEATURE_TAR_GNU_EXTENSIONS
202 bool "Enable support for some GNU tar extensions" 202 bool "Enable support for some GNU tar extensions"
203 default y 203 default y
204 depends on CONFIG_TAR 204 depends on TAR
205 help 205 help
206 With this option busybox supports GNU long filenames and 206 With this option busybox supports GNU long filenames and
207 linknames. 207 linknames.
208 208
209config CONFIG_FEATURE_TAR_LONG_OPTIONS 209config FEATURE_TAR_LONG_OPTIONS
210 bool "Enable long options" 210 bool "Enable long options"
211 default n 211 default n
212 depends on CONFIG_TAR && CONFIG_GETOPT_LONG 212 depends on TAR && GETOPT_LONG
213 help 213 help
214 Enable use of long options, increases size by about 400 Bytes 214 Enable use of long options, increases size by about 400 Bytes
215 215
216config CONFIG_UNCOMPRESS 216config UNCOMPRESS
217 bool "uncompress" 217 bool "uncompress"
218 default n 218 default n
219 help 219 help
220 uncompress is used to decompress archives created by compress. 220 uncompress is used to decompress archives created by compress.
221 Not much used anymore, replaced by gzip/gunzip. 221 Not much used anymore, replaced by gzip/gunzip.
222 222
223config CONFIG_UNLZMA 223config UNLZMA
224 bool "unlzma" 224 bool "unlzma"
225 default n 225 default n
226 help 226 help
@@ -235,15 +235,15 @@ config CONFIG_UNLZMA
235 Unless you have a specific application which requires unlzma, you 235 Unless you have a specific application which requires unlzma, you
236 should probably say N here. 236 should probably say N here.
237 237
238config CONFIG_FEATURE_LZMA_FAST 238config FEATURE_LZMA_FAST
239 bool "Optimze unlzma for speed" 239 bool "Optimze unlzma for speed"
240 default n 240 default n
241 depends on CONFIG_UNLZMA 241 depends on UNLZMA
242 help 242 help
243 This option reduces decompression time by about 33% at the cost of 243 This option reduces decompression time by about 33% at the cost of
244 a 2K bigger binary. 244 a 2K bigger binary.
245 245
246config CONFIG_UNZIP 246config UNZIP
247 bool "unzip" 247 bool "unzip"
248 default n 248 default n
249 help 249 help
@@ -254,31 +254,31 @@ config CONFIG_UNZIP
254 directory of your choice. 254 directory of your choice.
255 255
256comment "Common options for cpio and tar" 256comment "Common options for cpio and tar"
257 depends on CONFIG_CPIO || CONFIG_TAR 257 depends on CPIO || TAR
258 258
259config CONFIG_FEATURE_UNARCHIVE_TAPE 259config FEATURE_UNARCHIVE_TAPE
260 bool "Enable tape drive support" 260 bool "Enable tape drive support"
261 default n 261 default n
262 depends on CONFIG_CPIO || CONFIG_TAR 262 depends on CPIO || TAR
263 help 263 help
264 I don't think this is needed anymore. 264 I don't think this is needed anymore.
265 265
266comment "Common options for dpkg and dpkg_deb" 266comment "Common options for dpkg and dpkg_deb"
267 depends on CONFIG_DPKG || CONFIG_DPKG_DEB 267 depends on DPKG || DPKG_DEB
268 268
269config CONFIG_FEATURE_DEB_TAR_GZ 269config FEATURE_DEB_TAR_GZ
270 bool "gzip debian packages (normal)" 270 bool "gzip debian packages (normal)"
271 default y if CONFIG_DPKG || CONFIG_DPKG_DEB 271 default y if DPKG || DPKG_DEB
272 depends on CONFIG_DPKG || CONFIG_DPKG_DEB 272 depends on DPKG || DPKG_DEB
273 help 273 help
274 This is the default compression method inside the debian ar file. 274 This is the default compression method inside the debian ar file.
275 275
276 If you want compatibility with standard .deb's you should say yes here. 276 If you want compatibility with standard .deb's you should say yes here.
277 277
278config CONFIG_FEATURE_DEB_TAR_BZ2 278config FEATURE_DEB_TAR_BZ2
279 bool "bzip2 debian packages" 279 bool "bzip2 debian packages"
280 default n 280 default n
281 depends on CONFIG_DPKG || CONFIG_DPKG_DEB 281 depends on DPKG || DPKG_DEB
282 help 282 help
283 This allows dpkg and dpkg-deb to extract deb's that are compressed internally 283 This allows dpkg and dpkg-deb to extract deb's that are compressed internally
284 with bzip2 instead of gzip. 284 with bzip2 instead of gzip.
@@ -286,10 +286,10 @@ config CONFIG_FEATURE_DEB_TAR_BZ2
286 You only want this if you are creating your own custom debian packages that 286 You only want this if you are creating your own custom debian packages that
287 use an internal control.tar.bz2 or data.tar.bz2. 287 use an internal control.tar.bz2 or data.tar.bz2.
288 288
289config CONFIG_FEATURE_DEB_TAR_LZMA 289config FEATURE_DEB_TAR_LZMA
290 bool "lzma debian packages" 290 bool "lzma debian packages"
291 default n 291 default n
292 depends on CONFIG_DPKG || CONFIG_DPKG_DEB 292 depends on DPKG || DPKG_DEB
293 help 293 help
294 This allows dpkg and dpkg-deb to extract deb's that are compressed 294 This allows dpkg and dpkg-deb to extract deb's that are compressed
295 internally with lzma instead of gzip. 295 internally with lzma instead of gzip.
diff --git a/archival/Kbuild b/archival/Kbuild
new file mode 100644
index 000000000..f85e0c2a7
--- /dev/null
+++ b/archival/Kbuild
@@ -0,0 +1,22 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7libs-y += libunarchive/
8
9lib-y:=
10lib-$(CONFIG_AR) += ar.o
11lib-$(CONFIG_BUNZIP2) += bunzip2.o
12lib-$(CONFIG_UNLZMA) += unlzma.o
13lib-$(CONFIG_CPIO) += cpio.o
14lib-$(CONFIG_DPKG) += dpkg.o
15lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
16lib-$(CONFIG_GUNZIP) += gunzip.o
17lib-$(CONFIG_GZIP) += gzip.o
18lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
19lib-$(CONFIG_RPM) += rpm.o
20lib-$(CONFIG_TAR) += tar.o
21lib-$(CONFIG_UNCOMPRESS) += uncompress.o
22lib-$(CONFIG_UNZIP) += unzip.o
diff --git a/archival/Makefile b/archival/Makefile
deleted file mode 100644
index 66da4afc1..000000000
--- a/archival/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13ARCHIVAL_DIR:=./
14srcdir=$(top_srcdir)/archival
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include $(srcdir)/Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/archival/Makefile.in b/archival/Makefile.in
deleted file mode 100644
index 276ef4127..000000000
--- a/archival/Makefile.in
+++ /dev/null
@@ -1,41 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ARCHIVAL_AR:=archival.a
8ifndef $(ARCHIVAL_DIR)
9ARCHIVAL_DIR:=$(top_builddir)/archival/
10endif
11srcdir=$(top_srcdir)/archival
12
13ARCHIVAL-y:=
14ARCHIVAL-$(CONFIG_AR) += ar.o
15ARCHIVAL-$(CONFIG_BUNZIP2) += bunzip2.o
16ARCHIVAL-$(CONFIG_UNLZMA) += unlzma.o
17ARCHIVAL-$(CONFIG_CPIO) += cpio.o
18ARCHIVAL-$(CONFIG_DPKG) += dpkg.o
19ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o
20ARCHIVAL-$(CONFIG_GUNZIP) += gunzip.o
21ARCHIVAL-$(CONFIG_GZIP) += gzip.o
22ARCHIVAL-$(CONFIG_RPM2CPIO) += rpm2cpio.o
23ARCHIVAL-$(CONFIG_RPM) += rpm.o
24ARCHIVAL-$(CONFIG_TAR) += tar.o
25ARCHIVAL-$(CONFIG_UNCOMPRESS) += uncompress.o
26ARCHIVAL-$(CONFIG_UNZIP) += unzip.o
27
28ifneq ($(strip $(ARCHIVAL-y)),)
29libraries-y+=$(ARCHIVAL_DIR)$(ARCHIVAL_AR)
30endif
31
32ARCHIVAL_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(ARCHIVAL-y))
33ARCHIVAL_SRC-a:=$(wildcard $(srcdir)/*.c)
34APPLET_SRC-y+=$(ARCHIVAL_SRC-y)
35APPLET_SRC-a+=$(ARCHIVAL_SRC-a)
36
37$(ARCHIVAL_DIR)$(ARCHIVAL_AR): $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
38 $(do_ar)
39
40$(ARCHIVAL_DIR)%.o: $(srcdir)/%.c
41 $(compile.c)
diff --git a/archival/libunarchive/Kbuild b/archival/libunarchive/Kbuild
new file mode 100644
index 000000000..c5f1bfbfe
--- /dev/null
+++ b/archival/libunarchive/Kbuild
@@ -0,0 +1,59 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6
7lib-y:= \
8\
9 data_skip.o \
10 data_extract_all.o \
11 data_extract_to_stdout.o \
12 data_extract_to_buffer.o \
13\
14 filter_accept_all.o \
15 filter_accept_list.o \
16 filter_accept_reject_list.o \
17\
18 header_skip.o \
19 header_list.o \
20 header_verbose_list.o \
21\
22 archive_xread_all_eof.o \
23\
24 seek_by_char.o \
25 seek_by_jump.o \
26\
27 data_align.o \
28 find_list_entry.o \
29 open_transformer.o \
30 init_handle.o
31
32GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
33DPKG_FILES:= \
34 get_header_ar.o \
35 unpack_ar_archive.o \
36 get_header_tar.o \
37 filter_accept_list_reassign.o
38
39lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
40lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
41lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
42lib-$(CONFIG_CPIO) += get_header_cpio.o
43lib-$(CONFIG_DPKG) += $(DPKG_FILES)
44lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
45lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
46lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
47lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
48lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
49lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
50lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
51lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
52lib-$(CONFIG_TAR) += get_header_tar.o
53lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
54lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
55lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
56lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
57lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
58lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
59lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
diff --git a/archival/libunarchive/Makefile b/archival/libunarchive/Makefile
deleted file mode 100644
index 9ab1cac81..000000000
--- a/archival/libunarchive/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19
20ifndef top_srcdir
21top_srcdir=../..
22endif
23ifndef top_builddir
24top_builddir=../..
25endif
26srcdir=$(top_srcdir)/archival/libunarchive
27LIBUNARCHIVE_DIR:=./
28include $(top_srcdir)/Rules.mak
29include $(top_builddir)/.config
30include $(srcdir)/Makefile.in
31all: $(libraries-y)
32-include $(top_builddir)/.depend
33
34clean:
35 rm -f *.o *.a $(AR_TARGET)
36
diff --git a/archival/libunarchive/Makefile.in b/archival/libunarchive/Makefile.in
deleted file mode 100644
index 46c50f81d..000000000
--- a/archival/libunarchive/Makefile.in
+++ /dev/null
@@ -1,83 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6
7LIBUNARCHIVE_AR:=libunarchive.a
8ifndef $(LIBUNARCHIVE_DIR)
9LIBUNARCHIVE_DIR:=$(top_builddir)/archival/libunarchive
10endif
11srcdir=$(top_srcdir)/archival/libunarchive
12
13LIBUNARCHIVE-obj:=$(LIBUNARCHIVE_DIR)/$(LIBUNARCHIVE_AR)
14
15libraries-y+=$(LIBUNARCHIVE-obj)
16
17LIBUNARCHIVE-y:= \
18\
19 data_skip.o \
20 data_extract_all.o \
21 data_extract_to_stdout.o \
22 data_extract_to_buffer.o \
23\
24 filter_accept_all.o \
25 filter_accept_list.o \
26 filter_accept_reject_list.o \
27\
28 header_skip.o \
29 header_list.o \
30 header_verbose_list.o \
31\
32 archive_xread_all_eof.o \
33\
34 seek_by_char.o \
35 seek_by_jump.o \
36\
37 data_align.o \
38 find_list_entry.o \
39 open_transformer.o \
40 init_handle.o
41
42GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
43DPKG_FILES:= \
44 get_header_ar.o \
45 unpack_ar_archive.o \
46 get_header_tar.o \
47 filter_accept_list_reassign.o
48
49LIBUNARCHIVE-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
50LIBUNARCHIVE-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
51LIBUNARCHIVE-$(CONFIG_UNLZMA) += decompress_unlzma.o
52LIBUNARCHIVE-$(CONFIG_CPIO) += get_header_cpio.o
53LIBUNARCHIVE-$(CONFIG_DPKG) += $(DPKG_FILES)
54LIBUNARCHIVE-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
55LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
56LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
57LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
58LIBUNARCHIVE-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
59LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
60LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
61LIBUNARCHIVE-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
62LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
63LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
64LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
65LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
66LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
67LIBUNARCHIVE-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
68LIBUNARCHIVE-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
69LIBUNARCHIVE-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
70
71
72LIBUNARCHIVE-y:=$(sort $(LIBUNARCHIVE-y))
73
74LIBUNARCHIVE_SRC-y:=$(patsubst %,$(srcdir)/%,$(subst .o,.c,$(LIBUNARCHIVE-y)))
75LIBUNARCHIVE_SRC-a:=$(wildcard $(srcdir)/*.c)
76LIBRARY_SRC-y+=$(LIBUNARCHIVE_SRC-y)
77LIBRARY_SRC-a+=$(LIBUNARCHIVE_SRC-a)
78
79$(LIBUNARCHIVE_DIR)/$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)/%,$(LIBUNARCHIVE-y))
80 $(do_ar)
81
82$(LIBUNARCHIVE_DIR)/%.o: $(srcdir)/%.c
83 $(compile.c)
diff --git a/console-tools/Config.in b/console-tools/Config.in
index ec2273c35..f1dbac531 100644
--- a/console-tools/Config.in
+++ b/console-tools/Config.in
@@ -5,81 +5,81 @@
5 5
6menu "Console Utilities" 6menu "Console Utilities"
7 7
8config CONFIG_CHVT 8config CHVT
9 bool "chvt" 9 bool "chvt"
10 default n 10 default n
11 help 11 help
12 This program is used to change to another terminal. 12 This program is used to change to another terminal.
13 Example: chvt 4 (change to terminal /dev/tty4) 13 Example: chvt 4 (change to terminal /dev/tty4)
14 14
15config CONFIG_CLEAR 15config CLEAR
16 bool "clear" 16 bool "clear"
17 default n 17 default n
18 help 18 help
19 This program clears the terminal screen. 19 This program clears the terminal screen.
20 20
21config CONFIG_DEALLOCVT 21config DEALLOCVT
22 bool "deallocvt" 22 bool "deallocvt"
23 default n 23 default n
24 help 24 help
25 This program deallocates unused virtual consoles. 25 This program deallocates unused virtual consoles.
26 26
27config CONFIG_DUMPKMAP 27config DUMPKMAP
28 bool "dumpkmap" 28 bool "dumpkmap"
29 default n 29 default n
30 help 30 help
31 This program dumps the kernel's keyboard translation table to 31 This program dumps the kernel's keyboard translation table to
32 stdout, in binary format. You can then use loadkmap to load it. 32 stdout, in binary format. You can then use loadkmap to load it.
33 33
34config CONFIG_LOADFONT 34config LOADFONT
35 bool "loadfont" 35 bool "loadfont"
36 default n 36 default n
37 help 37 help
38 This program loads a console font from standard input. 38 This program loads a console font from standard input.
39 39
40config CONFIG_LOADKMAP 40config LOADKMAP
41 bool "loadkmap" 41 bool "loadkmap"
42 default n 42 default n
43 help 43 help
44 This program loads a keyboard translation table from 44 This program loads a keyboard translation table from
45 standard input. 45 standard input.
46 46
47config CONFIG_OPENVT 47config OPENVT
48 bool "openvt" 48 bool "openvt"
49 default n 49 default n
50 help 50 help
51 This program is used to start a command on an unused 51 This program is used to start a command on an unused
52 virtual terminal. 52 virtual terminal.
53 53
54config CONFIG_RESET 54config RESET
55 bool "reset" 55 bool "reset"
56 default n 56 default n
57 help 57 help
58 This program is used to reset the terminal screen, if it 58 This program is used to reset the terminal screen, if it
59 gets messed up. 59 gets messed up.
60 60
61config CONFIG_SETCONSOLE 61config SETCONSOLE
62 bool "setconsole" 62 bool "setconsole"
63 default n 63 default n
64 help 64 help
65 This program redirects the system console to another device, 65 This program redirects the system console to another device,
66 like the current tty while logged in via telnet. 66 like the current tty while logged in via telnet.
67 67
68config CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS 68config FEATURE_SETCONSOLE_LONG_OPTIONS
69 bool "Enable long options" 69 bool "Enable long options"
70 default n 70 default n
71 depends on CONFIG_SET_CONSOLE && CONFIG_GETOPT_LONG 71 depends on SET_CONSOLE && GETOPT_LONG
72 help 72 help
73 Support long options for the setconsole applet. 73 Support long options for the setconsole applet.
74 74
75config CONFIG_SETKEYCODES 75config SETKEYCODES
76 bool "setkeycodes" 76 bool "setkeycodes"
77 default n 77 default n
78 help 78 help
79 This program loads entries into the kernel's scancode-to-keycode 79 This program loads entries into the kernel's scancode-to-keycode
80 map, allowing unusual keyboards to generate usable keycodes. 80 map, allowing unusual keyboards to generate usable keycodes.
81 81
82config CONFIG_SETLOGCONS 82config SETLOGCONS
83 bool "setlogcons" 83 bool "setlogcons"
84 default n 84 default n
85 help 85 help
diff --git a/console-tools/Kbuild b/console-tools/Kbuild
new file mode 100644
index 000000000..8e377c559
--- /dev/null
+++ b/console-tools/Kbuild
@@ -0,0 +1,18 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_CHVT) += chvt.o
9lib-$(CONFIG_CLEAR) += clear.o
10lib-$(CONFIG_DEALLOCVT) += deallocvt.o
11lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
12lib-$(CONFIG_SETCONSOLE) += setconsole.o
13lib-$(CONFIG_LOADFONT) += loadfont.o
14lib-$(CONFIG_LOADKMAP) += loadkmap.o
15lib-$(CONFIG_OPENVT) += openvt.o
16lib-$(CONFIG_RESET) += reset.o
17lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
18lib-$(CONFIG_SETLOGCONS) += setlogcons.o
diff --git a/console-tools/Makefile b/console-tools/Makefile
deleted file mode 100644
index 87a242b51..000000000
--- a/console-tools/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/console/tools
14CONSOLETOOLS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include $(srcdir)/Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/console-tools/Makefile.in b/console-tools/Makefile.in
deleted file mode 100644
index 437bcd0ec..000000000
--- a/console-tools/Makefile.in
+++ /dev/null
@@ -1,38 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7CONSOLETOOLS_AR:=console-tools.a
8ifndef $(CONSOLETOOLS_DIR)
9CONSOLETOOLS_DIR:=$(top_builddir)/console-tools/
10endif
11srcdir=$(top_srcdir)/console-tools
12
13CONSOLETOOLS-y:=
14CONSOLETOOLS-$(CONFIG_CHVT) += chvt.o
15CONSOLETOOLS-$(CONFIG_CLEAR) += clear.o
16CONSOLETOOLS-$(CONFIG_DEALLOCVT) += deallocvt.o
17CONSOLETOOLS-$(CONFIG_DUMPKMAP) += dumpkmap.o
18CONSOLETOOLS-$(CONFIG_SETCONSOLE) += setconsole.o
19CONSOLETOOLS-$(CONFIG_LOADFONT) += loadfont.o
20CONSOLETOOLS-$(CONFIG_LOADKMAP) += loadkmap.o
21CONSOLETOOLS-$(CONFIG_OPENVT) += openvt.o
22CONSOLETOOLS-$(CONFIG_RESET) += reset.o
23CONSOLETOOLS-$(CONFIG_SETKEYCODES) += setkeycodes.o
24CONSOLETOOLS-$(CONFIG_SETLOGCONS) += setlogcons.o
25
26ifneq ($(strip $(CONSOLETOOLS-y)),)
27libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
28endif
29CONSOLETOOLS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(CONSOLETOOLS-y))
30CONSOLETOOLS_SRC-a:=$(wildcard $(srcdir)/*.c)
31APPLET_SRC-y+=$(CONSOLETOOLS_SRC-y)
32APPLET_SRC-a+=$(CONSOLETOOLS_SRC-a)
33
34$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS-y))
35 $(do_ar)
36
37$(CONSOLETOOLS_DIR)%.o: $(srcdir)/%.c
38 $(compile.c)
diff --git a/coreutils/Config.in b/coreutils/Config.in
index 6598a8d9c..000f3a8af 100644
--- a/coreutils/Config.in
+++ b/coreutils/Config.in
@@ -5,7 +5,7 @@
5 5
6menu "Coreutils" 6menu "Coreutils"
7 7
8config CONFIG_BASENAME 8config BASENAME
9 bool "basename" 9 bool "basename"
10 default n 10 default n
11 help 11 help
@@ -13,101 +13,101 @@ config CONFIG_BASENAME
13 leaving just the filename itself. Enable this option if you wish 13 leaving just the filename itself. Enable this option if you wish
14 to enable the 'basename' utility. 14 to enable the 'basename' utility.
15 15
16config CONFIG_CAL 16config CAL
17 bool "cal" 17 bool "cal"
18 default n 18 default n
19 help 19 help
20 cal is used to display a monthly calender. 20 cal is used to display a monthly calender.
21 21
22config CONFIG_CAT 22config CAT
23 bool "cat" 23 bool "cat"
24 default n 24 default n
25 help 25 help
26 cat is used to concatenate files and print them to the standard 26 cat is used to concatenate files and print them to the standard
27 output. Enable this option if you wish to enable the 'cat' utility. 27 output. Enable this option if you wish to enable the 'cat' utility.
28 28
29config CONFIG_CATV 29config CATV
30 bool "catv" 30 bool "catv"
31 default n 31 default n
32 help 32 help
33 Display nonprinting characters as escape sequences (like some 33 Display nonprinting characters as escape sequences (like some
34 implementations' cat -v option). 34 implementations' cat -v option).
35 35
36config CONFIG_CHGRP 36config CHGRP
37 bool "chgrp" 37 bool "chgrp"
38 default n 38 default n
39 help 39 help
40 chgrp is used to change the group ownership of files. 40 chgrp is used to change the group ownership of files.
41 41
42config CONFIG_CHMOD 42config CHMOD
43 bool "chmod" 43 bool "chmod"
44 default n 44 default n
45 help 45 help
46 chmod is used to change the access permission of files. 46 chmod is used to change the access permission of files.
47 47
48config CONFIG_CHOWN 48config CHOWN
49 bool "chown" 49 bool "chown"
50 default n 50 default n
51 help 51 help
52 chown is used to change the user and/or group ownership 52 chown is used to change the user and/or group ownership
53 of files. 53 of files.
54 54
55config CONFIG_CHROOT 55config CHROOT
56 bool "chroot" 56 bool "chroot"
57 default n 57 default n
58 help 58 help
59 chroot is used to change the root directory and run a command. 59 chroot is used to change the root directory and run a command.
60 The default command is `/bin/sh'. 60 The default command is `/bin/sh'.
61 61
62config CONFIG_CKSUM 62config CKSUM
63 bool "cksum" 63 bool "cksum"
64 default n 64 default n
65 help 65 help
66 cksum is used to calculate the CRC32 checksum of a file. 66 cksum is used to calculate the CRC32 checksum of a file.
67 67
68config CONFIG_CMP 68config CMP
69 bool "cmp" 69 bool "cmp"
70 default n 70 default n
71 help 71 help
72 cmp is used to compare two files and returns the result 72 cmp is used to compare two files and returns the result
73 to standard output. 73 to standard output.
74 74
75config CONFIG_COMM 75config COMM
76 bool "comm" 76 bool "comm"
77 default n 77 default n
78 help 78 help
79 comm is used to compare two files line by line and return 79 comm is used to compare two files line by line and return
80 a three-column output. 80 a three-column output.
81 81
82config CONFIG_CP 82config CP
83 bool "cp" 83 bool "cp"
84 default n 84 default n
85 help 85 help
86 cp is used to copy files and directories. 86 cp is used to copy files and directories.
87 87
88config CONFIG_CUT 88config CUT
89 bool "cut" 89 bool "cut"
90 default n 90 default n
91 help 91 help
92 cut is used to print selected parts of lines from 92 cut is used to print selected parts of lines from
93 each file to stdout. 93 each file to stdout.
94 94
95config CONFIG_DATE 95config DATE
96 bool "date" 96 bool "date"
97 default n 97 default n
98 help 98 help
99 date is used to set the system date or display the 99 date is used to set the system date or display the
100 current time in the given format. 100 current time in the given format.
101 101
102config CONFIG_FEATURE_DATE_ISOFMT 102config FEATURE_DATE_ISOFMT
103 bool "Enable ISO date format output (-I)" 103 bool "Enable ISO date format output (-I)"
104 default y 104 default y
105 depends on CONFIG_DATE 105 depends on DATE
106 help 106 help
107 Enable option (-I) to output an ISO-8601 compliant 107 Enable option (-I) to output an ISO-8601 compliant
108 date/time string. 108 date/time string.
109 109
110config CONFIG_DD 110config DD
111 bool "dd" 111 bool "dd"
112 default n 112 default n
113 help 113 help
@@ -115,10 +115,10 @@ config CONFIG_DD
115 by default) using specific input and output blocksizes, 115 by default) using specific input and output blocksizes,
116 while optionally performing conversions on it. 116 while optionally performing conversions on it.
117 117
118config CONFIG_FEATURE_DD_SIGNAL_HANDLING 118config FEATURE_DD_SIGNAL_HANDLING
119 bool "Enable DD signal handling for status reporting" 119 bool "Enable DD signal handling for status reporting"
120 default y 120 default y
121 depends on CONFIG_DD 121 depends on DD
122 help 122 help
123 sending a SIGUSR1 signal to a running `dd' process makes it 123 sending a SIGUSR1 signal to a running `dd' process makes it
124 print to standard error the number of records read and written 124 print to standard error the number of records read and written
@@ -127,22 +127,22 @@ config CONFIG_FEATURE_DD_SIGNAL_HANDLING
127 $ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid 127 $ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
128 10899206+0 records in 10899206+0 records out 128 10899206+0 records in 10899206+0 records out
129 129
130config CONFIG_FEATURE_DD_IBS_OBS 130config FEATURE_DD_IBS_OBS
131 bool "Enable ibs, obs and conv options" 131 bool "Enable ibs, obs and conv options"
132 default n 132 default n
133 depends on CONFIG_DD 133 depends on DD
134 help 134 help
135 Enables support for writing a certain number of bytes in and out, 135 Enables support for writing a certain number of bytes in and out,
136 at a time, and performing conversions on the data stream. 136 at a time, and performing conversions on the data stream.
137 137
138config CONFIG_DF 138config DF
139 bool "df" 139 bool "df"
140 default n 140 default n
141 help 141 help
142 df reports the amount of disk space used and available 142 df reports the amount of disk space used and available
143 on filesystems. 143 on filesystems.
144 144
145config CONFIG_DIFF 145config DIFF
146 bool "diff" 146 bool "diff"
147 default n 147 default n
148 help 148 help
@@ -150,81 +150,81 @@ config CONFIG_DIFF
150 differences between them in a form that can be given to 150 differences between them in a form that can be given to
151 the patch command. 151 the patch command.
152 152
153config CONFIG_FEATURE_DIFF_BINARY 153config FEATURE_DIFF_BINARY
154 bool "Enable checks for binary files" 154 bool "Enable checks for binary files"
155 default y 155 default y
156 depends on CONFIG_DIFF 156 depends on DIFF
157 help 157 help
158 This option enables support for checking for binary files 158 This option enables support for checking for binary files
159 before a comparison is carried out. 159 before a comparison is carried out.
160 160
161config CONFIG_FEATURE_DIFF_DIR 161config FEATURE_DIFF_DIR
162 bool "Enable directory support" 162 bool "Enable directory support"
163 default y 163 default y
164 depends on CONFIG_DIFF 164 depends on DIFF
165 help 165 help
166 This option enables support for directory and subdirectory 166 This option enables support for directory and subdirectory
167 comparison. 167 comparison.
168 168
169config CONFIG_FEATURE_DIFF_MINIMAL 169config FEATURE_DIFF_MINIMAL
170 bool "Enable -d option to find smaller sets of changes" 170 bool "Enable -d option to find smaller sets of changes"
171 default n 171 default n
172 depends on CONFIG_DIFF 172 depends on DIFF
173 help 173 help
174 Enabling this option allows the use of -d to make diff 174 Enabling this option allows the use of -d to make diff
175 try hard to find the smallest possible set of changes. 175 try hard to find the smallest possible set of changes.
176 176
177config CONFIG_DIRNAME 177config DIRNAME
178 bool "dirname" 178 bool "dirname"
179 default n 179 default n
180 help 180 help
181 dirname is used to strip a non-directory suffix from 181 dirname is used to strip a non-directory suffix from
182 a file name. 182 a file name.
183 183
184config CONFIG_DOS2UNIX 184config DOS2UNIX
185 bool "dos2unix/unix2dos" 185 bool "dos2unix/unix2dos"
186 default n 186 default n
187 help 187 help
188 dos2unix is used to convert a text file from DOS format to 188 dos2unix is used to convert a text file from DOS format to
189 UNIX format, and vice versa. 189 UNIX format, and vice versa.
190 190
191config CONFIG_UNIX2DOS 191config UNIX2DOS
192 bool 192 bool
193 default y 193 default y
194 depends on CONFIG_DOS2UNIX 194 depends on DOS2UNIX
195 help 195 help
196 unix2dos is used to convert a text file from UNIX format to 196 unix2dos is used to convert a text file from UNIX format to
197 DOS format, and vice versa. 197 DOS format, and vice versa.
198 198
199config CONFIG_DU 199config DU
200 bool "du (default blocksize of 512 bytes)" 200 bool "du (default blocksize of 512 bytes)"
201 default n 201 default n
202 help 202 help
203 du is used to report the amount of disk space used 203 du is used to report the amount of disk space used
204 for specified files. 204 for specified files.
205 205
206config CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K 206config FEATURE_DU_DEFAULT_BLOCKSIZE_1K
207 bool "Use a default blocksize of 1024 bytes (1K)" 207 bool "Use a default blocksize of 1024 bytes (1K)"
208 default y 208 default y
209 depends on CONFIG_DU 209 depends on DU
210 help 210 help
211 Use a blocksize of (1K) instead of the default 512b. 211 Use a blocksize of (1K) instead of the default 512b.
212 212
213config CONFIG_ECHO 213config ECHO
214 bool "echo (basic SuSv3 version taking no options)" 214 bool "echo (basic SuSv3 version taking no options)"
215 default n 215 default n
216 help 216 help
217 echo is used to print a specified string to stdout. 217 echo is used to print a specified string to stdout.
218 218
219# this entry also appears in shell/Config.in, next to the echo builtin 219# this entry also appears in shell/Config.in, next to the echo builtin
220config CONFIG_FEATURE_FANCY_ECHO 220config FEATURE_FANCY_ECHO
221 bool "Enable echo options (-n and -e)" 221 bool "Enable echo options (-n and -e)"
222 default y 222 default y
223 depends on CONFIG_ECHO 223 depends on ECHO
224 help 224 help
225 This adds options (-n and -e) to echo. 225 This adds options (-n and -e) to echo.
226 226
227config CONFIG_ENV 227config ENV
228 bool "env" 228 bool "env"
229 default n 229 default n
230 help 230 help
@@ -232,158 +232,158 @@ config CONFIG_ENV
232 a command; without options it displays the current 232 a command; without options it displays the current
233 environment. 233 environment.
234 234
235config CONFIG_FEATURE_ENV_LONG_OPTIONS 235config FEATURE_ENV_LONG_OPTIONS
236 bool "Enable long options" 236 bool "Enable long options"
237 default n 237 default n
238 depends on CONFIG_ENV && CONFIG_GETOPT_LONG 238 depends on ENV && GETOPT_LONG
239 help 239 help
240 Support long options for the env applet. 240 Support long options for the env applet.
241 241
242config CONFIG_EXPR 242config EXPR
243 bool "expr" 243 bool "expr"
244 default n 244 default n
245 help 245 help
246 expr is used to calculate numbers and print the result 246 expr is used to calculate numbers and print the result
247 to standard output. 247 to standard output.
248 248
249config CONFIG_EXPR_MATH_SUPPORT_64 249config EXPR_MATH_SUPPORT_64
250 bool "Extend Posix numbers support to 64 bit" 250 bool "Extend Posix numbers support to 64 bit"
251 default n 251 default n
252 depends on CONFIG_EXPR 252 depends on EXPR
253 help 253 help
254 Enable 64-bit math support in the expr applet. This will make 254 Enable 64-bit math support in the expr applet. This will make
255 the applet slightly larger, but will allow computation with very 255 the applet slightly larger, but will allow computation with very
256 large numbers. 256 large numbers.
257 257
258config CONFIG_FALSE 258config FALSE
259 bool "false" 259 bool "false"
260 default n 260 default n
261 help 261 help
262 false returns an exit code of FALSE (1). 262 false returns an exit code of FALSE (1).
263 263
264config CONFIG_FOLD 264config FOLD
265 bool "fold" 265 bool "fold"
266 default n 266 default n
267 help 267 help
268 Wrap text to fit a specific width. 268 Wrap text to fit a specific width.
269 269
270config CONFIG_HEAD 270config HEAD
271 bool "head" 271 bool "head"
272 default n 272 default n
273 help 273 help
274 head is used to print the first specified number of lines 274 head is used to print the first specified number of lines
275 from files. 275 from files.
276 276
277config CONFIG_FEATURE_FANCY_HEAD 277config FEATURE_FANCY_HEAD
278 bool "Enable head options (-c, -q, and -v)" 278 bool "Enable head options (-c, -q, and -v)"
279 default n 279 default n
280 depends on CONFIG_HEAD 280 depends on HEAD
281 help 281 help
282 This enables the head options (-c, -q, and -v). 282 This enables the head options (-c, -q, and -v).
283 283
284config CONFIG_HOSTID 284config HOSTID
285 bool "hostid" 285 bool "hostid"
286 default n 286 default n
287 help 287 help
288 hostid prints the numeric identifier (in hexadecimal) for 288 hostid prints the numeric identifier (in hexadecimal) for
289 the current host. 289 the current host.
290 290
291config CONFIG_ID 291config ID
292 bool "id" 292 bool "id"
293 default n 293 default n
294 help 294 help
295 id displays the current user and group ID names. 295 id displays the current user and group ID names.
296 296
297config CONFIG_INSTALL 297config INSTALL
298 bool "install" 298 bool "install"
299 default n 299 default n
300 help 300 help
301 Copy files and set attributes. 301 Copy files and set attributes.
302 302
303config CONFIG_FEATURE_INSTALL_LONG_OPTIONS 303config FEATURE_INSTALL_LONG_OPTIONS
304 bool "Enable long options" 304 bool "Enable long options"
305 default n 305 default n
306 depends on CONFIG_INSTALL && CONFIG_GETOPT_LONG 306 depends on INSTALL && GETOPT_LONG
307 help 307 help
308 Support long options for the install applet. 308 Support long options for the install applet.
309 309
310config CONFIG_LENGTH 310config LENGTH
311 bool "length" 311 bool "length"
312 default n 312 default n
313 help 313 help
314 length is used to print out the length of a specified string. 314 length is used to print out the length of a specified string.
315 315
316config CONFIG_LN 316config LN
317 bool "ln" 317 bool "ln"
318 default n 318 default n
319 help 319 help
320 ln is used to create hard or soft links between files. 320 ln is used to create hard or soft links between files.
321 321
322config CONFIG_LOGNAME 322config LOGNAME
323 bool "logname" 323 bool "logname"
324 default n 324 default n
325 help 325 help
326 logname is used to print the current user's login name. 326 logname is used to print the current user's login name.
327 327
328config CONFIG_LS 328config LS
329 bool "ls" 329 bool "ls"
330 default n 330 default n
331 help 331 help
332 ls is used to list the contents of directories. 332 ls is used to list the contents of directories.
333 333
334config CONFIG_FEATURE_LS_FILETYPES 334config FEATURE_LS_FILETYPES
335 bool "Enable filetyping options (-p and -F)" 335 bool "Enable filetyping options (-p and -F)"
336 default y 336 default y
337 depends on CONFIG_LS 337 depends on LS
338 help 338 help
339 Enable the ls options (-p and -F). 339 Enable the ls options (-p and -F).
340 340
341config CONFIG_FEATURE_LS_FOLLOWLINKS 341config FEATURE_LS_FOLLOWLINKS
342 bool "Enable symlinks dereferencing (-L)" 342 bool "Enable symlinks dereferencing (-L)"
343 default y 343 default y
344 depends on CONFIG_LS 344 depends on LS
345 help 345 help
346 Enable the ls option (-L). 346 Enable the ls option (-L).
347 347
348config CONFIG_FEATURE_LS_RECURSIVE 348config FEATURE_LS_RECURSIVE
349 bool "Enable recursion (-R)" 349 bool "Enable recursion (-R)"
350 default y 350 default y
351 depends on CONFIG_LS 351 depends on LS
352 help 352 help
353 Enable the ls option (-R). 353 Enable the ls option (-R).
354 354
355config CONFIG_FEATURE_LS_SORTFILES 355config FEATURE_LS_SORTFILES
356 bool "Sort the file names" 356 bool "Sort the file names"
357 default y 357 default y
358 depends on CONFIG_LS 358 depends on LS
359 help 359 help
360 Allow ls to sort file names alphabetically. 360 Allow ls to sort file names alphabetically.
361 361
362config CONFIG_FEATURE_LS_TIMESTAMPS 362config FEATURE_LS_TIMESTAMPS
363 bool "Show file timestamps" 363 bool "Show file timestamps"
364 default y 364 default y
365 depends on CONFIG_LS 365 depends on LS
366 help 366 help
367 Allow ls to display timestamps for files. 367 Allow ls to display timestamps for files.
368 368
369config CONFIG_FEATURE_LS_USERNAME 369config FEATURE_LS_USERNAME
370 bool "Show username/groupnames" 370 bool "Show username/groupnames"
371 default y 371 default y
372 depends on CONFIG_LS 372 depends on LS
373 help 373 help
374 Allow ls to display username/groupname for files. 374 Allow ls to display username/groupname for files.
375 375
376config CONFIG_FEATURE_LS_COLOR 376config FEATURE_LS_COLOR
377 bool "Allow use of color to identify file types" 377 bool "Allow use of color to identify file types"
378 default y 378 default y
379 depends on CONFIG_LS && CONFIG_GETOPT_LONG 379 depends on LS && GETOPT_LONG
380 help 380 help
381 This enables the --color option to ls. 381 This enables the --color option to ls.
382 382
383config CONFIG_FEATURE_LS_COLOR_IS_DEFAULT 383config FEATURE_LS_COLOR_IS_DEFAULT
384 bool "Produce colored ls output by default" 384 bool "Produce colored ls output by default"
385 default n 385 default n
386 depends on CONFIG_FEATURE_LS_COLOR 386 depends on FEATURE_LS_COLOR
387 help 387 help
388 Saying yes here will turn coloring on by default, 388 Saying yes here will turn coloring on by default,
389 even if no "--color" option is given to the ls command. 389 even if no "--color" option is given to the ls command.
@@ -391,143 +391,143 @@ config CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
391 configurable, and the output may not be legible on 391 configurable, and the output may not be legible on
392 many output screens. 392 many output screens.
393 393
394config CONFIG_MD5SUM 394config MD5SUM
395 bool "md5sum" 395 bool "md5sum"
396 default n 396 default n
397 help 397 help
398 md5sum is used to print or check MD5 checksums. 398 md5sum is used to print or check MD5 checksums.
399 399
400config CONFIG_MKDIR 400config MKDIR
401 bool "mkdir" 401 bool "mkdir"
402 default n 402 default n
403 help 403 help
404 mkdir is used to create directories with the specified names. 404 mkdir is used to create directories with the specified names.
405 405
406config CONFIG_FEATURE_MKDIR_LONG_OPTIONS 406config FEATURE_MKDIR_LONG_OPTIONS
407 bool "Enable long options" 407 bool "Enable long options"
408 default n 408 default n
409 depends on CONFIG_MKDIR && CONFIG_GETOPT_LONG 409 depends on MKDIR && GETOPT_LONG
410 help 410 help
411 Support long options for the mkdir applet. 411 Support long options for the mkdir applet.
412 412
413config CONFIG_MKFIFO 413config MKFIFO
414 bool "mkfifo" 414 bool "mkfifo"
415 default n 415 default n
416 help 416 help
417 mkfifo is used to create FIFOs (named pipes). 417 mkfifo is used to create FIFOs (named pipes).
418 The `mknod' program can also create FIFOs. 418 The `mknod' program can also create FIFOs.
419 419
420config CONFIG_MKNOD 420config MKNOD
421 bool "mknod" 421 bool "mknod"
422 default n 422 default n
423 help 423 help
424 mknod is used to create FIFOs or block/character special 424 mknod is used to create FIFOs or block/character special
425 files with the specified names. 425 files with the specified names.
426 426
427config CONFIG_MV 427config MV
428 bool "mv" 428 bool "mv"
429 default n 429 default n
430 help 430 help
431 mv is used to move or rename files or directories. 431 mv is used to move or rename files or directories.
432 432
433config CONFIG_FEATURE_MV_LONG_OPTIONS 433config FEATURE_MV_LONG_OPTIONS
434 bool "Enable long options" 434 bool "Enable long options"
435 default n 435 default n
436 depends on CONFIG_MV && CONFIG_GETOPT_LONG 436 depends on MV && GETOPT_LONG
437 help 437 help
438 Support long options for the mv applet. 438 Support long options for the mv applet.
439 439
440config CONFIG_NICE 440config NICE
441 bool "nice" 441 bool "nice"
442 default n 442 default n
443 help 443 help
444 nice runs a program with modified scheduling priority. 444 nice runs a program with modified scheduling priority.
445 445
446config CONFIG_NOHUP 446config NOHUP
447 bool "nohup" 447 bool "nohup"
448 default n 448 default n
449 help 449 help
450 run a command immune to hangups, with output to a non-tty. 450 run a command immune to hangups, with output to a non-tty.
451 451
452config CONFIG_OD 452config OD
453 bool "od" 453 bool "od"
454 default n 454 default n
455 help 455 help
456 od is used to dump binary files in octal and other formats. 456 od is used to dump binary files in octal and other formats.
457 457
458config CONFIG_PRINTENV 458config PRINTENV
459 bool "printenv" 459 bool "printenv"
460 default n 460 default n
461 help 461 help
462 printenv is used to print all or part of environment. 462 printenv is used to print all or part of environment.
463 463
464config CONFIG_PRINTF 464config PRINTF
465 bool "printf" 465 bool "printf"
466 default n 466 default n
467 help 467 help
468 printf is used to format and print specified strings. 468 printf is used to format and print specified strings.
469 It's similar to `echo' except it has more options. 469 It's similar to `echo' except it has more options.
470 470
471config CONFIG_PWD 471config PWD
472 bool "pwd" 472 bool "pwd"
473 default n 473 default n
474 help 474 help
475 pwd is used to print the current directory. 475 pwd is used to print the current directory.
476 476
477config CONFIG_REALPATH 477config REALPATH
478 bool "realpath" 478 bool "realpath"
479 default n 479 default n
480 help 480 help
481 Return the canonicalized absolute pathname. 481 Return the canonicalized absolute pathname.
482 This isn't provided by GNU shellutils, but where else does it belong. 482 This isn't provided by GNU shellutils, but where else does it belong.
483 483
484config CONFIG_RM 484config RM
485 bool "rm" 485 bool "rm"
486 default n 486 default n
487 help 487 help
488 rm is used to remove files or directories. 488 rm is used to remove files or directories.
489 489
490config CONFIG_RMDIR 490config RMDIR
491 bool "rmdir" 491 bool "rmdir"
492 default n 492 default n
493 help 493 help
494 rmdir is used to remove empty directories. 494 rmdir is used to remove empty directories.
495 495
496config CONFIG_SEQ 496config SEQ
497 bool "seq" 497 bool "seq"
498 default n 498 default n
499 help 499 help
500 print a sequence of numbers 500 print a sequence of numbers
501 501
502config CONFIG_SHA1SUM 502config SHA1SUM
503 bool "sha1sum" 503 bool "sha1sum"
504 default n 504 default n
505 help 505 help
506 Compute and check SHA1 message digest 506 Compute and check SHA1 message digest
507 507
508config CONFIG_SLEEP 508config SLEEP
509 bool "sleep (single integer arg with no suffix)" 509 bool "sleep (single integer arg with no suffix)"
510 default n 510 default n
511 help 511 help
512 sleep is used to pause for a specified number of seconds, 512 sleep is used to pause for a specified number of seconds,
513 513
514config CONFIG_FEATURE_FANCY_SLEEP 514config FEATURE_FANCY_SLEEP
515 bool "Enable multiple integer args and optional time suffixes" 515 bool "Enable multiple integer args and optional time suffixes"
516 default n 516 default n
517 depends on CONFIG_SLEEP 517 depends on SLEEP
518 help 518 help
519 Allow sleep to pause for specified minutes, hours, and days. 519 Allow sleep to pause for specified minutes, hours, and days.
520 520
521config CONFIG_SORT 521config SORT
522 bool "sort" 522 bool "sort"
523 default n 523 default n
524 help 524 help
525 sort is used to sort lines of text in specified files. 525 sort is used to sort lines of text in specified files.
526 526
527config CONFIG_FEATURE_SORT_BIG 527config FEATURE_SORT_BIG
528 bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)" 528 bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
529 default y 529 default y
530 depends on CONFIG_SORT 530 depends on SORT
531 help 531 help
532 Without this, sort only supports -r, -u, and an integer version 532 Without this, sort only supports -r, -u, and an integer version
533 of -n. Selecting this adds sort keys, floating point support, and 533 of -n. Selecting this adds sort keys, floating point support, and
@@ -536,69 +536,69 @@ config CONFIG_FEATURE_SORT_BIG
536 The SuSv3 sort standard is available at: 536 The SuSv3 sort standard is available at:
537 http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html 537 http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
538 538
539config CONFIG_STAT 539config STAT
540 bool "stat" 540 bool "stat"
541 default n 541 default n
542 help 542 help
543 display file or filesystem status. 543 display file or filesystem status.
544 544
545config CONFIG_FEATURE_STAT_FORMAT 545config FEATURE_STAT_FORMAT
546 bool "Enable custom formats (-c)" 546 bool "Enable custom formats (-c)"
547 default n 547 default n
548 depends on CONFIG_STAT 548 depends on STAT
549 help 549 help
550 Without this, stat will not support the '-c format' option where 550 Without this, stat will not support the '-c format' option where
551 users can pass a custom format string for output. This adds about 551 users can pass a custom format string for output. This adds about
552 7k to a nonstatic build on amd64. 552 7k to a nonstatic build on amd64.
553 553
554config CONFIG_STTY 554config STTY
555 bool "stty" 555 bool "stty"
556 default n 556 default n
557 help 557 help
558 stty is used to change and print terminal line settings. 558 stty is used to change and print terminal line settings.
559 559
560config CONFIG_SUM 560config SUM
561 bool "sum" 561 bool "sum"
562 default n 562 default n
563 help 563 help
564 checksum and count the blocks in a file 564 checksum and count the blocks in a file
565 565
566config CONFIG_SYNC 566config SYNC
567 bool "sync" 567 bool "sync"
568 default n 568 default n
569 help 569 help
570 sync is used to flush filesystem buffers. 570 sync is used to flush filesystem buffers.
571 571
572config CONFIG_TAIL 572config TAIL
573 bool "tail" 573 bool "tail"
574 default n 574 default n
575 help 575 help
576 tail is used to print the last specified number of lines 576 tail is used to print the last specified number of lines
577 from files. 577 from files.
578 578
579config CONFIG_FEATURE_FANCY_TAIL 579config FEATURE_FANCY_TAIL
580 bool "Enable extra tail options (-q, -s, and -v)" 580 bool "Enable extra tail options (-q, -s, and -v)"
581 default y 581 default y
582 depends on CONFIG_TAIL 582 depends on TAIL
583 help 583 help
584 The options (-q, -s, and -v) are provided by GNU tail, but 584 The options (-q, -s, and -v) are provided by GNU tail, but
585 are not specific in the SUSv3 standard. 585 are not specific in the SUSv3 standard.
586 586
587config CONFIG_TEE 587config TEE
588 bool "tee" 588 bool "tee"
589 default n 589 default n
590 help 590 help
591 tee is used to read from standard input and write 591 tee is used to read from standard input and write
592 to standard output and files. 592 to standard output and files.
593 593
594config CONFIG_FEATURE_TEE_USE_BLOCK_IO 594config FEATURE_TEE_USE_BLOCK_IO
595 bool "Enable block i/o (larger/faster) instead of byte i/o." 595 bool "Enable block i/o (larger/faster) instead of byte i/o."
596 default n 596 default n
597 depends on CONFIG_TEE 597 depends on TEE
598 help 598 help
599 Enable this option for a faster tee, at expense of size. 599 Enable this option for a faster tee, at expense of size.
600 600
601config CONFIG_TEST 601config TEST
602 bool "test" 602 bool "test"
603 default n 603 default n
604 help 604 help
@@ -606,39 +606,39 @@ config CONFIG_TEST
606 returning an appropriate exit code. The bash shell 606 returning an appropriate exit code. The bash shell
607 has test built in, ash can build it in optionally. 607 has test built in, ash can build it in optionally.
608 608
609config CONFIG_FEATURE_TEST_64 609config FEATURE_TEST_64
610 bool "Extend test to 64 bit" 610 bool "Extend test to 64 bit"
611 default n 611 default n
612 depends on CONFIG_TEST 612 depends on TEST
613 help 613 help
614 Enable 64-bit support in test. 614 Enable 64-bit support in test.
615 615
616config CONFIG_TOUCH 616config TOUCH
617 bool "touch" 617 bool "touch"
618 default n 618 default n
619 help 619 help
620 touch is used to create or change the access and/or 620 touch is used to create or change the access and/or
621 modification timestamp of specified files. 621 modification timestamp of specified files.
622 622
623config CONFIG_TR 623config TR
624 bool "tr" 624 bool "tr"
625 default n 625 default n
626 help 626 help
627 tr is used to squeeze, and/or delete characters from standard 627 tr is used to squeeze, and/or delete characters from standard
628 input, writing to standard output. 628 input, writing to standard output.
629 629
630config CONFIG_FEATURE_TR_CLASSES 630config FEATURE_TR_CLASSES
631 bool "Enable character classes (such as [:upper:])" 631 bool "Enable character classes (such as [:upper:])"
632 default n 632 default n
633 depends on CONFIG_TR 633 depends on TR
634 help 634 help
635 Enable character classes, enabling commands such as: 635 Enable character classes, enabling commands such as:
636 tr [:upper:] [:lower:] to convert input into lowercase. 636 tr [:upper:] [:lower:] to convert input into lowercase.
637 637
638config CONFIG_FEATURE_TR_EQUIV 638config FEATURE_TR_EQUIV
639 bool "Enable equivalence classes" 639 bool "Enable equivalence classes"
640 default n 640 default n
641 depends on CONFIG_TR 641 depends on TR
642 help 642 help
643 Enable equivalence classes, which essentially add the enclosed 643 Enable equivalence classes, which essentially add the enclosed
644 character to the current set. For instance, tr [=a=] xyz would 644 character to the current set. For instance, tr [=a=] xyz would
@@ -646,86 +646,86 @@ config CONFIG_FEATURE_TR_EQUIV
646 useful for cases when no other way of expressing a character 646 useful for cases when no other way of expressing a character
647 is possible. 647 is possible.
648 648
649config CONFIG_TRUE 649config TRUE
650 bool "true" 650 bool "true"
651 default n 651 default n
652 help 652 help
653 true returns an exit code of TRUE (0). 653 true returns an exit code of TRUE (0).
654 654
655config CONFIG_TTY 655config TTY
656 bool "tty" 656 bool "tty"
657 default n 657 default n
658 help 658 help
659 tty is used to print the name of the current terminal to 659 tty is used to print the name of the current terminal to
660 standard output. 660 standard output.
661 661
662config CONFIG_UNAME 662config UNAME
663 bool "uname" 663 bool "uname"
664 default n 664 default n
665 help 665 help
666 uname is used to print system information. 666 uname is used to print system information.
667 667
668config CONFIG_UNIQ 668config UNIQ
669 bool "uniq" 669 bool "uniq"
670 default n 670 default n
671 help 671 help
672 uniq is used to remove duplicate lines from a sorted file. 672 uniq is used to remove duplicate lines from a sorted file.
673 673
674config CONFIG_USLEEP 674config USLEEP
675 bool "usleep" 675 bool "usleep"
676 default n 676 default n
677 help 677 help
678 usleep is used to pause for a specified number of microseconds. 678 usleep is used to pause for a specified number of microseconds.
679 679
680config CONFIG_UUDECODE 680config UUDECODE
681 bool "uudecode" 681 bool "uudecode"
682 default n 682 default n
683 help 683 help
684 uudecode is used to decode a uuencoded file. 684 uudecode is used to decode a uuencoded file.
685 685
686config CONFIG_UUENCODE 686config UUENCODE
687 bool "uuencode" 687 bool "uuencode"
688 default n 688 default n
689 help 689 help
690 uuencode is used to uuencode a file. 690 uuencode is used to uuencode a file.
691 691
692config CONFIG_WATCH 692config WATCH
693 bool "watch" 693 bool "watch"
694 default n 694 default n
695 select CONFIG_DATE 695 select DATE
696 help 696 help
697 watch is used to execute a program periodically, showing 697 watch is used to execute a program periodically, showing
698 output to the screen. 698 output to the screen.
699 699
700config CONFIG_WC 700config WC
701 bool "wc" 701 bool "wc"
702 default n 702 default n
703 help 703 help
704 wc is used to print the number of bytes, words, and lines, 704 wc is used to print the number of bytes, words, and lines,
705 in specified files. 705 in specified files.
706 706
707config CONFIG_FEATURE_WC_LARGE 707config FEATURE_WC_LARGE
708 bool "Support very large files in wc" 708 bool "Support very large files in wc"
709 default n 709 default n
710 depends on CONFIG_WC 710 depends on WC
711 help 711 help
712 Use "unsigned long long" in wc for count variables 712 Use "unsigned long long" in wc for count variables
713 713
714config CONFIG_WHO 714config WHO
715 bool "who" 715 bool "who"
716 default n 716 default n
717 select CONFIG_FEATURE_UTMP 717 select FEATURE_UTMP
718 help 718 help
719 who is used to show who is logged on. 719 who is used to show who is logged on.
720 720
721config CONFIG_WHOAMI 721config WHOAMI
722 bool "whoami" 722 bool "whoami"
723 default n 723 default n
724 help 724 help
725 whoami is used to print the username of the current 725 whoami is used to print the username of the current
726 user id (same as id -un). 726 user id (same as id -un).
727 727
728config CONFIG_YES 728config YES
729 bool "yes" 729 bool "yes"
730 default n 730 default n
731 help 731 help
@@ -733,22 +733,22 @@ config CONFIG_YES
733 the default string `y'. 733 the default string `y'.
734 734
735comment "Common options for cp and mv" 735comment "Common options for cp and mv"
736 depends on CONFIG_CP || CONFIG_MV 736 depends on CP || MV
737 737
738config CONFIG_FEATURE_PRESERVE_HARDLINKS 738config FEATURE_PRESERVE_HARDLINKS
739 bool "Preserve hard links" 739 bool "Preserve hard links"
740 default n 740 default n
741 depends on CONFIG_CP || CONFIG_MV 741 depends on CP || MV
742 help 742 help
743 Allow cp and mv to preserve hard links. 743 Allow cp and mv to preserve hard links.
744 744
745comment "Common options for ls, more and telnet" 745comment "Common options for ls, more and telnet"
746 depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET 746 depends on LS || MORE || TELNET
747 747
748config CONFIG_FEATURE_AUTOWIDTH 748config FEATURE_AUTOWIDTH
749 bool "Calculate terminal & column widths" 749 bool "Calculate terminal & column widths"
750 default y 750 default y
751 depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET 751 depends on LS || MORE || TELNET
752 help 752 help
753 This option allows utilities such as 'ls', 'more' and 'telnet' 753 This option allows utilities such as 'ls', 'more' and 'telnet'
754 to determine the width of the screen, which can allow them to 754 to determine the width of the screen, which can allow them to
@@ -757,22 +757,22 @@ config CONFIG_FEATURE_AUTOWIDTH
757 primitive and will be unable to determine the current screen width. 757 primitive and will be unable to determine the current screen width.
758 758
759comment "Common options for df, du, ls" 759comment "Common options for df, du, ls"
760 depends on CONFIG_DF || CONFIG_DU || CONFIG_LS 760 depends on DF || DU || LS
761 761
762config CONFIG_FEATURE_HUMAN_READABLE 762config FEATURE_HUMAN_READABLE
763 bool "Support for human readable output (example 13k, 23M, 235G)" 763 bool "Support for human readable output (example 13k, 23M, 235G)"
764 default n 764 default n
765 depends on CONFIG_DF || CONFIG_DU || CONFIG_LS 765 depends on DF || DU || LS
766 help 766 help
767 Allow df, du, and ls to have human readable output. 767 Allow df, du, and ls to have human readable output.
768 768
769comment "Common options for md5sum, sha1sum" 769comment "Common options for md5sum, sha1sum"
770 depends on CONFIG_MD5SUM || CONFIG_SHA1SUM 770 depends on MD5SUM || SHA1SUM
771 771
772config CONFIG_FEATURE_MD5_SHA1_SUM_CHECK 772config FEATURE_MD5_SHA1_SUM_CHECK
773 bool "Enable -c, -s and -w options" 773 bool "Enable -c, -s and -w options"
774 default n 774 default n
775 depends on CONFIG_MD5SUM || CONFIG_SHA1SUM 775 depends on MD5SUM || SHA1SUM
776 help 776 help
777 Enabling the -c options allows files to be checked 777 Enabling the -c options allows files to be checked
778 against pre-calculated hash values. 778 against pre-calculated hash values.
diff --git a/coreutils/Kbuild b/coreutils/Kbuild
new file mode 100644
index 000000000..cf1718419
--- /dev/null
+++ b/coreutils/Kbuild
@@ -0,0 +1,81 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7libs-y += libcoreutils/
8
9lib-y:=
10lib-$(CONFIG_BASENAME) += basename.o
11lib-$(CONFIG_CAL) += cal.o
12lib-$(CONFIG_CAT) += cat.o
13lib-$(CONFIG_CATV) += catv.o
14lib-$(CONFIG_CHGRP) += chgrp.o
15lib-$(CONFIG_CHMOD) += chmod.o
16lib-$(CONFIG_CHOWN) += chown.o
17lib-$(CONFIG_CHROOT) += chroot.o
18lib-$(CONFIG_CKSUM) += cksum.o
19lib-$(CONFIG_CMP) += cmp.o
20lib-$(CONFIG_COMM) += comm.o
21lib-$(CONFIG_CP) += cp.o
22lib-$(CONFIG_CUT) += cut.o
23lib-$(CONFIG_DATE) += date.o
24lib-$(CONFIG_DD) += dd.o
25lib-$(CONFIG_DF) += df.o
26lib-$(CONFIG_DIFF) += diff.o
27lib-$(CONFIG_DIRNAME) += dirname.o
28lib-$(CONFIG_DOS2UNIX) += dos2unix.o
29lib-$(CONFIG_DU) += du.o
30lib-$(CONFIG_ECHO) += echo.o
31lib-$(CONFIG_ENV) += env.o
32lib-$(CONFIG_EXPR) += expr.o
33lib-$(CONFIG_FALSE) += false.o
34lib-$(CONFIG_FOLD) += fold.o
35lib-$(CONFIG_HEAD) += head.o
36lib-$(CONFIG_HOSTID) += hostid.o
37lib-$(CONFIG_ID) += id.o
38lib-$(CONFIG_INSTALL) += install.o
39lib-$(CONFIG_LENGTH) += length.o
40lib-$(CONFIG_LN) += ln.o
41lib-$(CONFIG_LOGNAME) += logname.o
42lib-$(CONFIG_LS) += ls.o
43lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o
44lib-$(CONFIG_MKDIR) += mkdir.o
45lib-$(CONFIG_MKFIFO) += mkfifo.o
46lib-$(CONFIG_MKNOD) += mknod.o
47lib-$(CONFIG_MV) += mv.o
48lib-$(CONFIG_NICE) += nice.o
49lib-$(CONFIG_NOHUP) += nohup.o
50lib-$(CONFIG_OD) += od.o
51lib-$(CONFIG_PRINTENV) += printenv.o
52lib-$(CONFIG_PRINTF) += printf.o
53lib-$(CONFIG_PWD) += pwd.o
54lib-$(CONFIG_REALPATH) += realpath.o
55lib-$(CONFIG_RM) += rm.o
56lib-$(CONFIG_RMDIR) += rmdir.o
57lib-$(CONFIG_SEQ) += seq.o
58lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
59lib-$(CONFIG_SLEEP) += sleep.o
60lib-$(CONFIG_SORT) += sort.o
61lib-$(CONFIG_STAT) += stat.o
62lib-$(CONFIG_STTY) += stty.o
63lib-$(CONFIG_SUM) += sum.o
64lib-$(CONFIG_SYNC) += sync.o
65lib-$(CONFIG_TAIL) += tail.o
66lib-$(CONFIG_TEE) += tee.o
67lib-$(CONFIG_TEST) += test.o
68lib-$(CONFIG_TOUCH) += touch.o
69lib-$(CONFIG_TR) += tr.o
70lib-$(CONFIG_TRUE) += true.o
71lib-$(CONFIG_TTY) += tty.o
72lib-$(CONFIG_UNAME) += uname.o
73lib-$(CONFIG_UNIQ) += uniq.o
74lib-$(CONFIG_USLEEP) += usleep.o
75lib-$(CONFIG_UUDECODE) += uudecode.o
76lib-$(CONFIG_UUENCODE) += uuencode.o
77lib-$(CONFIG_WATCH) += watch.o
78lib-$(CONFIG_WC) += wc.o
79lib-$(CONFIG_WHO) += who.o
80lib-$(CONFIG_WHOAMI) += whoami.o
81lib-$(CONFIG_YES) += yes.o
diff --git a/coreutils/Makefile b/coreutils/Makefile
deleted file mode 100644
index c29f3a934..000000000
--- a/coreutils/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/coreutils
14SHELLUTILS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include $(srcdir)/Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/coreutils/Makefile.in b/coreutils/Makefile.in
deleted file mode 100644
index 50c090f8d..000000000
--- a/coreutils/Makefile.in
+++ /dev/null
@@ -1,102 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7COREUTILS_AR:=coreutils.a
8ifndef $(COREUTILS_DIR)
9COREUTILS_DIR:=$(top_builddir)/coreutils/
10endif
11srcdir=$(top_srcdir)/coreutils
12
13COREUTILS-y:=
14COREUTILS-$(CONFIG_BASENAME) += basename.o
15COREUTILS-$(CONFIG_CAL) += cal.o
16COREUTILS-$(CONFIG_CAT) += cat.o
17COREUTILS-$(CONFIG_CATV) += catv.o
18COREUTILS-$(CONFIG_CHGRP) += chgrp.o
19COREUTILS-$(CONFIG_CHMOD) += chmod.o
20COREUTILS-$(CONFIG_CHOWN) += chown.o
21COREUTILS-$(CONFIG_CHROOT) += chroot.o
22COREUTILS-$(CONFIG_CKSUM) += cksum.o
23COREUTILS-$(CONFIG_CMP) += cmp.o
24COREUTILS-$(CONFIG_COMM) += comm.o
25COREUTILS-$(CONFIG_CP) += cp.o
26COREUTILS-$(CONFIG_CUT) += cut.o
27COREUTILS-$(CONFIG_DATE) += date.o
28COREUTILS-$(CONFIG_DD) += dd.o
29COREUTILS-$(CONFIG_DF) += df.o
30COREUTILS-$(CONFIG_DIFF) += diff.o
31COREUTILS-$(CONFIG_DIRNAME) += dirname.o
32COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
33COREUTILS-$(CONFIG_DU) += du.o
34COREUTILS-$(CONFIG_ECHO) += echo.o
35COREUTILS-$(CONFIG_ENV) += env.o
36COREUTILS-$(CONFIG_EXPR) += expr.o
37COREUTILS-$(CONFIG_FALSE) += false.o
38COREUTILS-$(CONFIG_FOLD) += fold.o
39COREUTILS-$(CONFIG_HEAD) += head.o
40COREUTILS-$(CONFIG_HOSTID) += hostid.o
41COREUTILS-$(CONFIG_ID) += id.o
42COREUTILS-$(CONFIG_INSTALL) += install.o
43COREUTILS-$(CONFIG_LENGTH) += length.o
44COREUTILS-$(CONFIG_LN) += ln.o
45COREUTILS-$(CONFIG_LOGNAME) += logname.o
46COREUTILS-$(CONFIG_LS) += ls.o
47COREUTILS-$(CONFIG_MD5SUM) += md5_sha1_sum.o
48COREUTILS-$(CONFIG_MKDIR) += mkdir.o
49COREUTILS-$(CONFIG_MKFIFO) += mkfifo.o
50COREUTILS-$(CONFIG_MKNOD) += mknod.o
51COREUTILS-$(CONFIG_MV) += mv.o
52COREUTILS-$(CONFIG_NICE) += nice.o
53COREUTILS-$(CONFIG_NOHUP) += nohup.o
54COREUTILS-$(CONFIG_OD) += od.o
55COREUTILS-$(CONFIG_PRINTENV) += printenv.o
56COREUTILS-$(CONFIG_PRINTF) += printf.o
57COREUTILS-$(CONFIG_PWD) += pwd.o
58COREUTILS-$(CONFIG_REALPATH) += realpath.o
59COREUTILS-$(CONFIG_RM) += rm.o
60COREUTILS-$(CONFIG_RMDIR) += rmdir.o
61COREUTILS-$(CONFIG_SEQ) += seq.o
62COREUTILS-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
63COREUTILS-$(CONFIG_SLEEP) += sleep.o
64COREUTILS-$(CONFIG_SORT) += sort.o
65COREUTILS-$(CONFIG_STAT) += stat.o
66COREUTILS-$(CONFIG_STTY) += stty.o
67COREUTILS-$(CONFIG_SUM) += sum.o
68COREUTILS-$(CONFIG_SYNC) += sync.o
69COREUTILS-$(CONFIG_TAIL) += tail.o
70COREUTILS-$(CONFIG_TEE) += tee.o
71COREUTILS-$(CONFIG_TEST) += test.o
72COREUTILS-$(CONFIG_TOUCH) += touch.o
73COREUTILS-$(CONFIG_TR) += tr.o
74COREUTILS-$(CONFIG_TRUE) += true.o
75COREUTILS-$(CONFIG_TTY) += tty.o
76COREUTILS-$(CONFIG_UNAME) += uname.o
77COREUTILS-$(CONFIG_UNIQ) += uniq.o
78COREUTILS-$(CONFIG_USLEEP) += usleep.o
79COREUTILS-$(CONFIG_UUDECODE) += uudecode.o
80COREUTILS-$(CONFIG_UUENCODE) += uuencode.o
81COREUTILS-$(CONFIG_WATCH) += watch.o
82COREUTILS-$(CONFIG_WC) += wc.o
83COREUTILS-$(CONFIG_WHO) += who.o
84COREUTILS-$(CONFIG_WHOAMI) += whoami.o
85COREUTILS-$(CONFIG_YES) += yes.o
86
87COREUTILS-y:=$(sort $(COREUTILS-y))
88
89ifneq ($(strip $(COREUTILS-y)),)
90libraries-y+=$(COREUTILS_DIR)$(COREUTILS_AR)
91endif
92
93COREUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(COREUTILS-y))
94COREUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
95APPLET_SRC-y+=$(COREUTILS_SRC-y)
96APPLET_SRC-a+=$(COREUTILS_SRC-a)
97
98$(COREUTILS_DIR)$(COREUTILS_AR): $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
99 $(do_ar)
100
101$(COREUTILS_DIR)%.o: $(srcdir)/%.c
102 $(compile.c)
diff --git a/coreutils/diff.c b/coreutils/diff.c
index 2edcd96ca..b30aad5a7 100644
--- a/coreutils/diff.c
+++ b/coreutils/diff.c
@@ -1165,9 +1165,8 @@ int diff_main(int argc, char **argv)
1165 llist_t *L_arg = NULL; 1165 llist_t *L_arg = NULL;
1166 1166
1167 opt_complementary = "L::"; 1167 opt_complementary = "L::";
1168 cmd_flags = 1168 cmd_flags = getopt32(argc, argv, "abdiL:NqrsS:tTU:wu",
1169 getopt32(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start, 1169 &L_arg, &start, &U_opt);
1170 &U_opt);
1171 1170
1172 if (cmd_flags & FLAG_L) { 1171 if (cmd_flags & FLAG_L) {
1173 while (L_arg) { 1172 while (L_arg) {
diff --git a/coreutils/id.c b/coreutils/id.c
index dd825ab3c..9e49999cd 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -13,7 +13,6 @@
13 */ 13 */
14 14
15#include "busybox.h" 15#include "busybox.h"
16#include "pwd_.h"
17#include <stdio.h> 16#include <stdio.h>
18#include <unistd.h> 17#include <unistd.h>
19#include <sys/types.h> 18#include <sys/types.h>
diff --git a/coreutils/libcoreutils/Kbuild b/coreutils/libcoreutils/Kbuild
new file mode 100644
index 000000000..755d01f86
--- /dev/null
+++ b/coreutils/libcoreutils/Kbuild
@@ -0,0 +1,12 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_MKFIFO) += getopt_mk_fifo_nod.o
9lib-$(CONFIG_MKNOD) += getopt_mk_fifo_nod.o
10lib-$(CONFIG_INSTALL) += cp_mv_stat.o
11lib-$(CONFIG_CP) += cp_mv_stat.o
12lib-$(CONFIG_MV) += cp_mv_stat.o
diff --git a/coreutils/libcoreutils/Makefile b/coreutils/libcoreutils/Makefile
deleted file mode 100644
index fabde2d0e..000000000
--- a/coreutils/libcoreutils/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19
20ifndef top_srcdir
21top_srcdir=../..
22endif
23ifndef top_builddir
24top_builddir=../..
25endif
26srcdir=$(top_srcdir)/coreutils/libcoreutils
27LIBCOREUTILS_DIR:=./
28include $(top_srcdir)/Rules.mak
29include $(top_builddir)/.config
30include $(srcdir)/Makefile.in
31
32all: $(libraries-y)
33-include $(top_builddir)/.depend
34
35clean:
36 rm -f *.o *.a $(AR_TARGET)
37
diff --git a/coreutils/libcoreutils/Makefile.in b/coreutils/libcoreutils/Makefile.in
deleted file mode 100644
index 30a38c9d9..000000000
--- a/coreutils/libcoreutils/Makefile.in
+++ /dev/null
@@ -1,39 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6
7LIBCOREUTILS_AR:=libcoreutils.a
8ifndef $(LIBCOREUTILS_DIR)
9LIBCOREUTILS_DIR:=$(top_builddir)/coreutils/libcoreutils
10endif
11srcdir=$(top_srcdir)/coreutils/libcoreutils
12
13LIBCOREUTILS_ALL_SRC:= cp_mv_stat.c getopt_mk_fifo_nod.c
14
15LIBCOREUTILS-y:=
16LIBCOREUTILS-$(CONFIG_MKFIFO) += getopt_mk_fifo_nod.o
17LIBCOREUTILS-$(CONFIG_MKNOD) += getopt_mk_fifo_nod.o
18LIBCOREUTILS-$(CONFIG_INSTALL) += cp_mv_stat.o
19LIBCOREUTILS-$(CONFIG_CP) += cp_mv_stat.o
20LIBCOREUTILS-$(CONFIG_MV) += cp_mv_stat.o
21
22LIBCOREUTILS-y:=$(sort $(LIBCOREUTILS-y))
23
24LIBCOREUTILS_SRC-y:=$(patsubst %,$(srcdir)/%,$(subst .o,.c,$(LIBCOREUTILS-y)))
25LIBCOREUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
26LIBRARY_SRC-y+=$(LIBCOREUTILS_SRC-y)
27LIBRARY_SRC-a+=$(LIBCOREUTILS_SRC-a)
28
29ifneq ($(strip $(LIBCOREUTILS-y)),)
30libraries-y+=$(LIBCOREUTILS_DIR)/$(LIBCOREUTILS_AR)
31endif
32
33LIBCOREUTILS_OBJS=$(patsubst %,$(LIBCOREUTILS_DIR)/%, $(LIBCOREUTILS-y))
34
35$(LIBCOREUTILS_DIR)/$(LIBCOREUTILS_AR): $(patsubst %,$(LIBCOREUTILS_DIR)/%,$(LIBCOREUTILS-y))
36 $(do_ar)
37
38$(LIBCOREUTILS_DIR)/%.o: $(srcdir)/%.c
39 $(compile.c)
diff --git a/debianutils/Config.in b/debianutils/Config.in
index 3dd2ef61b..3d85999ff 100644
--- a/debianutils/Config.in
+++ b/debianutils/Config.in
@@ -5,33 +5,33 @@
5 5
6menu "Debian Utilities" 6menu "Debian Utilities"
7 7
8config CONFIG_MKTEMP 8config MKTEMP
9 bool "mktemp" 9 bool "mktemp"
10 default n 10 default n
11 help 11 help
12 mktemp is used to create unique temporary files 12 mktemp is used to create unique temporary files
13 13
14config CONFIG_PIPE_PROGRESS 14config PIPE_PROGRESS
15 bool "pipe_progress" 15 bool "pipe_progress"
16 default n 16 default n
17 help 17 help
18 Display a dot to indicate pipe activity. 18 Display a dot to indicate pipe activity.
19 19
20config CONFIG_READLINK 20config READLINK
21 bool "readlink" 21 bool "readlink"
22 default n 22 default n
23 help 23 help
24 This program reads a symbolic link and returns the name 24 This program reads a symbolic link and returns the name
25 of the file it points to 25 of the file it points to
26 26
27config CONFIG_FEATURE_READLINK_FOLLOW 27config FEATURE_READLINK_FOLLOW
28 bool "Enable canonicalization by following all symlinks (-f)" 28 bool "Enable canonicalization by following all symlinks (-f)"
29 default n 29 default n
30 depends on CONFIG_READLINK 30 depends on READLINK
31 help 31 help
32 Enable the readlink option (-f). 32 Enable the readlink option (-f).
33 33
34config CONFIG_RUN_PARTS 34config RUN_PARTS
35 bool "run-parts" 35 bool "run-parts"
36 default n 36 default n
37 help 37 help
@@ -46,14 +46,14 @@ config CONFIG_RUN_PARTS
46 Unless you know that run-parts is used in some of your scripts 46 Unless you know that run-parts is used in some of your scripts
47 you can safely say N here. 47 you can safely say N here.
48 48
49config CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS 49config FEATURE_RUN_PARTS_LONG_OPTIONS
50 bool "Enable long options" 50 bool "Enable long options"
51 default n 51 default n
52 depends on CONFIG_RUN_PARTS && CONFIG_GETOPT_LONG 52 depends on RUN_PARTS && GETOPT_LONG
53 help 53 help
54 Support long options for the run-parts applet. 54 Support long options for the run-parts applet.
55 55
56config CONFIG_START_STOP_DAEMON 56config START_STOP_DAEMON
57 bool "start-stop-daemon" 57 bool "start-stop-daemon"
58 default y 58 default y
59 help 59 help
@@ -61,23 +61,23 @@ config CONFIG_START_STOP_DAEMON
61 termination of system-level processes, usually the ones 61 termination of system-level processes, usually the ones
62 started during the startup of the system. 62 started during the startup of the system.
63 63
64config CONFIG_FEATURE_START_STOP_DAEMON_FANCY 64config FEATURE_START_STOP_DAEMON_FANCY
65 bool "Support additional arguments" 65 bool "Support additional arguments"
66 default y 66 default y
67 depends on CONFIG_START_STOP_DAEMON 67 depends on START_STOP_DAEMON
68 help 68 help
69 Support additional arguments. 69 Support additional arguments.
70 -o|--oknodo ignored since we exit with 0 anyway 70 -o|--oknodo ignored since we exit with 0 anyway
71 -v|--verbose 71 -v|--verbose
72 72
73config CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS 73config FEATURE_START_STOP_DAEMON_LONG_OPTIONS
74 bool "Enable long options" 74 bool "Enable long options"
75 default n 75 default n
76 depends on CONFIG_START_STOP_DAEMON && CONFIG_GETOPT_LONG 76 depends on START_STOP_DAEMON && GETOPT_LONG
77 help 77 help
78 Support long options for the start-stop-daemon applet. 78 Support long options for the start-stop-daemon applet.
79 79
80config CONFIG_WHICH 80config WHICH
81 bool "which" 81 bool "which"
82 default n 82 default n
83 help 83 help
diff --git a/debianutils/Kbuild b/debianutils/Kbuild
new file mode 100644
index 000000000..99df6a536
--- /dev/null
+++ b/debianutils/Kbuild
@@ -0,0 +1,13 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_MKTEMP) += mktemp.o
9lib-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o
10lib-$(CONFIG_READLINK) += readlink.o
11lib-$(CONFIG_RUN_PARTS) += run_parts.o
12lib-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
13lib-$(CONFIG_WHICH) += which.o
diff --git a/debianutils/Makefile b/debianutils/Makefile
deleted file mode 100644
index 3d240b7bc..000000000
--- a/debianutils/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/debianutils
14DEBIANUTILS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include $(srcdir)/Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/debianutils/Makefile.in b/debianutils/Makefile.in
deleted file mode 100644
index 2983565b8..000000000
--- a/debianutils/Makefile.in
+++ /dev/null
@@ -1,33 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7DEBIANUTILS_AR:=debianutils.a
8ifndef $(DEBIANUTILS_DIR)
9DEBIANUTILS_DIR:=$(top_builddir)/debianutils/
10endif
11srcdir=$(top_srcdir)/debianutils
12
13DEBIANUTILS-y:=
14DEBIANUTILS-$(CONFIG_MKTEMP) += mktemp.o
15DEBIANUTILS-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o
16DEBIANUTILS-$(CONFIG_READLINK) += readlink.o
17DEBIANUTILS-$(CONFIG_RUN_PARTS) += run_parts.o
18DEBIANUTILS-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
19DEBIANUTILS-$(CONFIG_WHICH) += which.o
20
21ifneq ($(strip $(DEBIANUTILS-y)),)
22libraries-y+=$(DEBIANUTILS_DIR)$(DEBIANUTILS_AR)
23endif
24DEBIANUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(DEBIANUTILS-y))
25DEBIANUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
26APPLET_SRC-y+=$(DEBIANUTILS_SRC-y)
27APPLET_SRC-a+=$(DEBIANUTILS_SRC-a)
28
29$(DEBIANUTILS_DIR)$(DEBIANUTILS_AR): $(patsubst %,$(DEBIANUTILS_DIR)%, $(DEBIANUTILS-y))
30 $(do_ar)
31
32$(DEBIANUTILS_DIR)%.o: $(srcdir)/%.c
33 $(compile.c)
diff --git a/e2fsprogs/Config.in b/e2fsprogs/Config.in
index 91e873e3a..0062b2fe3 100644
--- a/e2fsprogs/Config.in
+++ b/e2fsprogs/Config.in
@@ -5,13 +5,13 @@
5 5
6menu "Linux Ext2 FS Progs" 6menu "Linux Ext2 FS Progs"
7 7
8config CONFIG_CHATTR 8config CHATTR
9 bool "chattr" 9 bool "chattr"
10 default n 10 default n
11 help 11 help
12 chattr changes the file attributes on a second extended file system. 12 chattr changes the file attributes on a second extended file system.
13 13
14config CONFIG_E2FSCK 14config E2FSCK
15 bool "e2fsck" 15 bool "e2fsck"
16 default n 16 default n
17 help 17 help
@@ -20,7 +20,7 @@ config CONFIG_E2FSCK
20 The normal compat symlinks 'fsck.ext2' and 'fsck.ext3' are also 20 The normal compat symlinks 'fsck.ext2' and 'fsck.ext3' are also
21 provided. 21 provided.
22 22
23config CONFIG_FSCK 23config FSCK
24 bool "fsck" 24 bool "fsck"
25 default n 25 default n
26 help 26 help
@@ -28,38 +28,38 @@ config CONFIG_FSCK
28 In actuality, fsck is simply a front-end for the various file system 28 In actuality, fsck is simply a front-end for the various file system
29 checkers (fsck.fstype) available under Linux. 29 checkers (fsck.fstype) available under Linux.
30 30
31config CONFIG_LSATTR 31config LSATTR
32 bool "lsattr" 32 bool "lsattr"
33 default n 33 default n
34 help 34 help
35 lsattr lists the file attributes on a second extended file system. 35 lsattr lists the file attributes on a second extended file system.
36 36
37config CONFIG_MKE2FS 37config MKE2FS
38 bool "mke2fs" 38 bool "mke2fs"
39 default n 39 default n
40 help 40 help
41 mke2fs is used to create an ext2/ext3 filesystem. The normal compat 41 mke2fs is used to create an ext2/ext3 filesystem. The normal compat
42 symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided. 42 symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided.
43 43
44config CONFIG_TUNE2FS 44config TUNE2FS
45 bool "tune2fs" 45 bool "tune2fs"
46 default n 46 default n
47 help 47 help
48 tune2fs allows the system administrator to adjust various tunable 48 tune2fs allows the system administrator to adjust various tunable
49 filesystem parameters on Linux ext2/ext3 filesystems. 49 filesystem parameters on Linux ext2/ext3 filesystems.
50 50
51config CONFIG_E2LABEL 51config E2LABEL
52 bool "e2label" 52 bool "e2label"
53 default n 53 default n
54 depends on CONFIG_TUNE2FS 54 depends on TUNE2FS
55 help 55 help
56 e2label will display or change the filesystem label on the ext2 56 e2label will display or change the filesystem label on the ext2
57 filesystem located on device. 57 filesystem located on device.
58 58
59config CONFIG_FINDFS 59config FINDFS
60 bool "findfs" 60 bool "findfs"
61 default n 61 default n
62 depends on CONFIG_TUNE2FS 62 depends on TUNE2FS
63 help 63 help
64 findfs will search the disks in the system looking for a filesystem 64 findfs will search the disks in the system looking for a filesystem
65 which has a label matching label or a UUID equal to uuid. 65 which has a label matching label or a UUID equal to uuid.
diff --git a/e2fsprogs/Kbuild b/e2fsprogs/Kbuild
new file mode 100644
index 000000000..f35a1ae32
--- /dev/null
+++ b/e2fsprogs/Kbuild
@@ -0,0 +1,27 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8
9lib-$(CONFIG_CHATTR) += chattr.o
10libs-$(CONFIG_CHATTR) += e2p/
11
12lib-$(CONFIG_E2FSCK) += e2fsck.o util.o
13libs-$(CONFIG_E2FSCK) += blkid/ ext2fs/ uuid/
14
15lib-$(CONFIG_FSCK) += fsck.o util.o
16libs-$(CONFIG_FSCK) += blkid/ ext2fs/ uuid/
17
18lib-$(CONFIG_LSATTR) += lsattr.o
19libs-$(CONFIG_LSATTR) += e2p/
20
21lib-$(CONFIG_MKE2FS) += mke2fs.o util.o
22libs-$(CONFIG_MKE2FS) += e2p/ blkid/ ext2fs/ uuid/
23
24lib-$(CONFIG_TUNE2FS) += tune2fs.o util.o
25libs-$(CONFIG_TUNE2FS) += e2p/ blkid/ ext2fs/ uuid/
26
27CFLAGS += -include e2fsprogs/e2fsbb.h
diff --git a/e2fsprogs/Makefile b/e2fsprogs/Makefile
deleted file mode 100644
index 0efa9bb3b..000000000
--- a/e2fsprogs/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/e2fsprogs
14E2FSPROGS_DIR:=./
15include $(top_builddir)/.config
16include $(top_srcdir)/Rules.mak
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a */*.o $(AR_TARGET)
diff --git a/e2fsprogs/Makefile.in b/e2fsprogs/Makefile.in
deleted file mode 100644
index 160271686..000000000
--- a/e2fsprogs/Makefile.in
+++ /dev/null
@@ -1,86 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7E2FSPROGS_AR:=e2fsprogs.a
8
9E2FSPROGS_DIR:=$(top_builddir)/e2fsprogs
10E2FSPROGS_SRC:=$(top_srcdir)/e2fsprogs
11
12E2FSPROGS_CFLAGS := -include $(E2FSPROGS_SRC)/e2fsbb.h
13
14BLKID_SRC := cache.c dev.c devname.c devno.c blkid_getsize.c \
15 probe.c read.c resolve.c save.c tag.c list.c
16BLKID_SRCS := $(patsubst %,blkid/%, $(BLKID_SRC))
17BLKID_OBJS := $(patsubst %.c,%.o, $(BLKID_SRCS))
18
19E2P_SRC := fgetsetflags.c fgetsetversion.c pf.c iod.c mntopts.c \
20 feature.c ls.c uuid.c pe.c ostype.c ps.c hashstr.c \
21 parse_num.c
22E2P_SRCS := $(patsubst %,e2p/%, $(E2P_SRC))
23E2P_OBJS := $(patsubst %.c,%.o, $(E2P_SRCS))
24
25EXT2FS_SRC := gen_bitmap.c bitops.c ismounted.c mkjournal.c unix_io.c \
26 rw_bitmaps.c initialize.c bitmaps.c block.c \
27 ind_block.c inode.c freefs.c alloc_stats.c closefs.c \
28 openfs.c io_manager.c finddev.c read_bb.c alloc.c badblocks.c \
29 getsize.c getsectsize.c alloc_tables.c read_bb_file.c mkdir.c \
30 bb_inode.c newdir.c alloc_sb.c lookup.c dirblock.c expanddir.c \
31 dir_iterate.c link.c res_gdt.c icount.c get_pathname.c dblist.c \
32 dirhash.c version.c flushb.c unlink.c check_desc.c valid_blk.c \
33 ext_attr.c bmap.c dblist_dir.c ext2fs_inline.c swapfs.c
34EXT2FS_SRCS := $(patsubst %,ext2fs/%, $(EXT2FS_SRC))
35EXT2FS_OBJS := $(patsubst %.c,%.o, $(EXT2FS_SRCS))
36
37UUID_SRC := compare.c gen_uuid.c pack.c parse.c unpack.c unparse.c \
38 uuid_time.c
39UUID_SRCS := $(patsubst %,uuid/%, $(UUID_SRC))
40UUID_OBJS := $(patsubst %.c,%.o, $(UUID_SRCS))
41
42E2FSPROGS-y:=
43E2FSPROGS-$(CONFIG_CHATTR) += chattr.o $(E2P_OBJS)
44E2FSPROGS-$(CONFIG_E2FSCK) += e2fsck.o util.o $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
45E2FSPROGS-$(CONFIG_FSCK) += fsck.o util.o $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
46E2FSPROGS-$(CONFIG_LSATTR) += lsattr.o $(E2P_OBJS)
47E2FSPROGS-$(CONFIG_MKE2FS) += mke2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
48E2FSPROGS-$(CONFIG_TUNE2FS) += tune2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
49
50E2FSPROGS-y:=$(sort $(E2FSPROGS-y))
51
52ifneq ($(strip $(E2FSPROGS-y)),)
53libraries-y+=$(E2FSPROGS_DIR)/$(E2FSPROGS_AR)
54endif
55
56E2FSPROGS_SRC-y:=$(patsubst %.o,$(E2FSPROGS_SRC)/%.c,$(E2FSPROGS-y))
57E2FSPROGS_SRC-a:=$(wildcard $(E2FSPROGS_SRC)/*.c) $(patsubst %,$(E2FSPROGS_SRC)/%,$(BLKID_SRCS) $(E2P_SRCS) $(EXT2FS_SRCS) $(UUID_SRCS))
58APPLET_SRC-y+=$(E2FSPROGS_SRC-y)
59APPLET_SRC-a+=$(E2FSPROGS_SRC-a)
60
61# XXX: FIXME: change .c to include their stuff relative to $(E2FSPROGS_SRC)
62E2FSPROGS_TMP_KLUDGE:=$(patsubst %,-I$(E2FSPROGS_SRC)/%,blkid e2fsck e2p ext2fs uuid)
63
64APPLETS_DEFINE-y+=$(E2FSPROGS_CFLAGS) -I$(E2FSPROGS_SRC) $(E2FSPROGS_TMP_KLUDGE)
65APPLETS_DEFINE-a+=$(E2FSPROGS_CFLAGS) -I$(E2FSPROGS_SRC) $(E2FSPROGS_TMP_KLUDGE)
66
67$(E2FSPROGS_DIR)/$(E2FSPROGS_AR): $(patsubst %,$(E2FSPROGS_DIR)/%, $(E2FSPROGS-y))
68 $(do_ar)
69
70$(E2FSPROGS_DIR)/%.o: $(subst $(top_builddir),$(top_srcdir),$(E2FSPROGS_DIR)/%.c)
71 $(compile.c) $(E2FSPROGS_CFLAGS)
72
73# for building out-of-tree we need to make sure that the directories to hold
74# the object tree are created
75$(patsubst %,$(E2FSPROGS_DIR)/%, blkid e2fsck e2p ext2fs uuid):
76 @mkdir -p "$@"
77
78# make sure that the directories are order-only prerequisites. Otherwise we
79# may have object files created after the timestamp of the directory was
80# updated which would lead to spurious rebuilds (as some of the dentries
81# may be older than the dir itself).
82$(patsubst %,$(E2FSPROGS_DIR)/%, $(BLKID_OBJS)):|$(E2FSPROGS_DIR)/blkid
83$(patsubst %,$(E2FSPROGS_DIR)/%, $(E2FSCK_OBJS)):|$(E2FSPROGS_DIR)/e2fsck
84$(patsubst %,$(E2FSPROGS_DIR)/%, $(E2P_OBJS)):|$(E2FSPROGS_DIR)/e2p
85$(patsubst %,$(E2FSPROGS_DIR)/%, $(EXT2FS_OBJS)):|$(E2FSPROGS_DIR)/ext2fs
86$(patsubst %,$(E2FSPROGS_DIR)/%, $(UUID_OBJS)):|$(E2FSPROGS_DIR)/uuid
diff --git a/e2fsprogs/blkid/Kbuild b/e2fsprogs/blkid/Kbuild
new file mode 100644
index 000000000..ba0bee03d
--- /dev/null
+++ b/e2fsprogs/blkid/Kbuild
@@ -0,0 +1,18 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-y += cache.o dev.o devname.o devno.o blkid_getsize.o \
9 probe.o read.o resolve.o save.o tag.o list.o
10
11CFLAGS_dev.o := -include include/busybox.h
12CFLAGS_devname.o := -include include/busybox.h
13CFLAGS_devno.o := -include include/busybox.h
14CFLAGS_blkid_getsize.o := -include include/busybox.h
15CFLAGS_probe.o := -include include/busybox.h
16CFLAGS_save.o := -include include/busybox.h
17CFLAGS_tag.o := -include include/busybox.h
18CFLAGS_list.o := -include include/busybox.h
diff --git a/e2fsprogs/blkid/blkid_getsize.c b/e2fsprogs/blkid/blkid_getsize.c
index 7a2133f0a..3c5ec5b76 100644
--- a/e2fsprogs/blkid/blkid_getsize.c
+++ b/e2fsprogs/blkid/blkid_getsize.c
@@ -14,9 +14,7 @@
14#include "blkidP.h" 14#include "blkidP.h"
15 15
16#include <stdio.h> 16#include <stdio.h>
17#if HAVE_UNISTD_H
18#include <unistd.h> 17#include <unistd.h>
19#endif
20#if HAVE_ERRNO_H 18#if HAVE_ERRNO_H
21#include <errno.h> 19#include <errno.h>
22#endif 20#endif
diff --git a/e2fsprogs/blkid/devname.c b/e2fsprogs/blkid/devname.c
index b5c1bc9a8..7606e400d 100644
--- a/e2fsprogs/blkid/devname.c
+++ b/e2fsprogs/blkid/devname.c
@@ -23,9 +23,7 @@
23#if HAVE_SYS_TYPES_H 23#if HAVE_SYS_TYPES_H
24#include <sys/types.h> 24#include <sys/types.h>
25#endif 25#endif
26#if HAVE_SYS_STAT_H
27#include <sys/stat.h> 26#include <sys/stat.h>
28#endif
29#if HAVE_ERRNO_H 27#if HAVE_ERRNO_H
30#include <errno.h> 28#include <errno.h>
31#endif 29#endif
diff --git a/e2fsprogs/blkid/devno.c b/e2fsprogs/blkid/devno.c
index 065761fb4..be93666be 100644
--- a/e2fsprogs/blkid/devno.c
+++ b/e2fsprogs/blkid/devno.c
@@ -21,9 +21,7 @@
21#if HAVE_SYS_TYPES_H 21#if HAVE_SYS_TYPES_H
22#include <sys/types.h> 22#include <sys/types.h>
23#endif 23#endif
24#if HAVE_SYS_STAT_H
25#include <sys/stat.h> 24#include <sys/stat.h>
26#endif
27#include <dirent.h> 25#include <dirent.h>
28#if HAVE_ERRNO_H 26#if HAVE_ERRNO_H
29#include <errno.h> 27#include <errno.h>
diff --git a/e2fsprogs/e2p/Kbuild b/e2fsprogs/e2p/Kbuild
new file mode 100644
index 000000000..24a692ea1
--- /dev/null
+++ b/e2fsprogs/e2p/Kbuild
@@ -0,0 +1,10 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-y += fgetsetflags.o fgetsetversion.o pf.o iod.o mntopts.o \
9 feature.o ls.o uuid.o pe.o ostype.o ps.o hashstr.o \
10 parse_num.o
diff --git a/e2fsprogs/e2p/fgetsetflags.c b/e2fsprogs/e2p/fgetsetflags.c
index 86bf65d50..34e40551f 100644
--- a/e2fsprogs/e2p/fgetsetflags.c
+++ b/e2fsprogs/e2p/fgetsetflags.c
@@ -63,8 +63,8 @@ int fgetsetflags (const char * name, unsigned long * get_flags, unsigned long se
63 if (save_errno) 63 if (save_errno)
64 errno = save_errno; 64 errno = save_errno;
65 return r; 65 return r;
66#endif /* HAVE_EXT2_IOCTLS */
67notsupp: 66notsupp:
67#endif /* HAVE_EXT2_IOCTLS */
68 errno = EOPNOTSUPP; 68 errno = EOPNOTSUPP;
69 return -1; 69 return -1;
70} 70}
diff --git a/e2fsprogs/ext2fs/Kbuild b/e2fsprogs/ext2fs/Kbuild
new file mode 100644
index 000000000..dc499348d
--- /dev/null
+++ b/e2fsprogs/ext2fs/Kbuild
@@ -0,0 +1,18 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-y += gen_bitmap.o bitops.o ismounted.o mkjournal.o unix_io.o \
9 rw_bitmaps.o initialize.o bitmaps.o block.o \
10 ind_block.o inode.o freefs.o alloc_stats.o closefs.o \
11 openfs.o io_manager.o finddev.o read_bb.o alloc.o badblocks.o \
12 getsize.o getsectsize.o alloc_tables.o read_bb_file.o mkdir.o \
13 bb_inode.o newdir.o alloc_sb.o lookup.o dirblock.o expanddir.o \
14 dir_iterate.o link.o res_gdt.o icount.o get_pathname.o dblist.o \
15 dirhash.o version.o flushb.o unlink.o check_desc.o valid_blk.o \
16 ext_attr.o bmap.o dblist_dir.o ext2fs_inline.o swapfs.o
17
18CFLAGS += -include e2fsprogs/e2fsbb.h
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c
index 9bd6f4c7e..01ba31c68 100644
--- a/e2fsprogs/tune2fs.c
+++ b/e2fsprogs/tune2fs.c
@@ -45,8 +45,6 @@
45#include "blkid/blkid.h" 45#include "blkid/blkid.h"
46 46
47#include "busybox.h" 47#include "busybox.h"
48#include "grp_.h"
49#include "pwd_.h"
50 48
51static char * device_name = NULL; 49static char * device_name = NULL;
52static char * new_label, *new_last_mounted, *new_UUID; 50static char * new_label, *new_last_mounted, *new_UUID;
diff --git a/e2fsprogs/uuid/Kbuild b/e2fsprogs/uuid/Kbuild
new file mode 100644
index 000000000..0ae74aed3
--- /dev/null
+++ b/e2fsprogs/uuid/Kbuild
@@ -0,0 +1,9 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-y += compare.o gen_uuid.o pack.o parse.o unpack.o unparse.o \
9 uuid_time.o
diff --git a/e2fsprogs/uuid/gen_uuid.c b/e2fsprogs/uuid/gen_uuid.c
index e5c0f0d53..9d700a015 100644
--- a/e2fsprogs/uuid/gen_uuid.c
+++ b/e2fsprogs/uuid/gen_uuid.c
@@ -41,6 +41,7 @@
41#include <sys/types.h> 41#include <sys/types.h>
42#include <sys/stat.h> 42#include <sys/stat.h>
43#include <sys/file.h> 43#include <sys/file.h>
44#include <sys/time.h>
44#ifdef HAVE_SYS_IOCTL_H 45#ifdef HAVE_SYS_IOCTL_H
45#include <sys/ioctl.h> 46#include <sys/ioctl.h>
46#endif 47#endif
diff --git a/editors/Config.in b/editors/Config.in
index 14c316c08..4ba009019 100644
--- a/editors/Config.in
+++ b/editors/Config.in
@@ -5,22 +5,22 @@
5 5
6menu "Editors" 6menu "Editors"
7 7
8config CONFIG_AWK 8config AWK
9 bool "awk" 9 bool "awk"
10 default n 10 default n
11 help 11 help
12 Awk is used as a pattern scanning and processing language. This is 12 Awk is used as a pattern scanning and processing language. This is
13 the BusyBox implementation of that programming language. 13 the BusyBox implementation of that programming language.
14 14
15config CONFIG_FEATURE_AWK_MATH 15config FEATURE_AWK_MATH
16 bool "Enable math functions (requires libm)" 16 bool "Enable math functions (requires libm)"
17 default y 17 default y
18 depends on CONFIG_AWK 18 depends on AWK
19 help 19 help
20 Enable math functions of the Awk programming language. 20 Enable math functions of the Awk programming language.
21 NOTE: This will require libm to be present for linking. 21 NOTE: This will require libm to be present for linking.
22 22
23config CONFIG_ED 23config ED
24 bool "ed" 24 bool "ed"
25 default n 25 default n
26 help 26 help
@@ -28,20 +28,20 @@ config CONFIG_ED
28 Small, simple, evil. Part of SUSv3. If you're not already using 28 Small, simple, evil. Part of SUSv3. If you're not already using
29 this, you don't need it. 29 this, you don't need it.
30 30
31config CONFIG_PATCH 31config PATCH
32 bool "patch" 32 bool "patch"
33 default n 33 default n
34 help 34 help
35 Apply a unified diff formatted patch. 35 Apply a unified diff formatted patch.
36 36
37config CONFIG_SED 37config SED
38 bool "sed" 38 bool "sed"
39 default n 39 default n
40 help 40 help
41 sed is used to perform text transformations on a file 41 sed is used to perform text transformations on a file
42 or input from a pipeline. 42 or input from a pipeline.
43 43
44config CONFIG_VI 44config VI
45 bool "vi" 45 bool "vi"
46 default n 46 default n
47 help 47 help
@@ -50,79 +50,79 @@ config CONFIG_VI
50 learning curve. If you are not already comfortable with 'vi' 50 learning curve. If you are not already comfortable with 'vi'
51 you may wish to use something else. 51 you may wish to use something else.
52 52
53config CONFIG_FEATURE_VI_COLON 53config FEATURE_VI_COLON
54 bool "Enable \":\" colon commands (no \"ex\" mode)" 54 bool "Enable \":\" colon commands (no \"ex\" mode)"
55 default y 55 default y
56 depends on CONFIG_VI 56 depends on VI
57 help 57 help
58 Enable a limited set of colon commands for vi. This does not 58 Enable a limited set of colon commands for vi. This does not
59 provide an "ex" mode. 59 provide an "ex" mode.
60 60
61config CONFIG_FEATURE_VI_YANKMARK 61config FEATURE_VI_YANKMARK
62 bool "Enable yank/put commands and mark cmds" 62 bool "Enable yank/put commands and mark cmds"
63 default y 63 default y
64 depends on CONFIG_VI 64 depends on VI
65 help 65 help
66 This will enable you to use yank and put, as well as mark in 66 This will enable you to use yank and put, as well as mark in
67 busybox vi. 67 busybox vi.
68 68
69config CONFIG_FEATURE_VI_SEARCH 69config FEATURE_VI_SEARCH
70 bool "Enable search and replace cmds" 70 bool "Enable search and replace cmds"
71 default y 71 default y
72 depends on CONFIG_VI 72 depends on VI
73 help 73 help
74 Select this if you wish to be able to do search and replace in 74 Select this if you wish to be able to do search and replace in
75 busybox vi. 75 busybox vi.
76 76
77config CONFIG_FEATURE_VI_USE_SIGNALS 77config FEATURE_VI_USE_SIGNALS
78 bool "Catch signals" 78 bool "Catch signals"
79 default y 79 default y
80 depends on CONFIG_VI 80 depends on VI
81 help 81 help
82 Selecting this option will make busybox vi signal aware. This will 82 Selecting this option will make busybox vi signal aware. This will
83 make busybox vi support SIGWINCH to deal with Window Changes, catch 83 make busybox vi support SIGWINCH to deal with Window Changes, catch
84 Ctrl-Z and Ctrl-C and alarms. 84 Ctrl-Z and Ctrl-C and alarms.
85 85
86config CONFIG_FEATURE_VI_DOT_CMD 86config FEATURE_VI_DOT_CMD
87 bool "Remember previous cmd and \".\" cmd" 87 bool "Remember previous cmd and \".\" cmd"
88 default y 88 default y
89 depends on CONFIG_VI 89 depends on VI
90 help 90 help
91 Make busybox vi remember the last command and be able to repeat it. 91 Make busybox vi remember the last command and be able to repeat it.
92 92
93config CONFIG_FEATURE_VI_READONLY 93config FEATURE_VI_READONLY
94 bool "Enable -R option and \"view\" mode" 94 bool "Enable -R option and \"view\" mode"
95 default y 95 default y
96 depends on CONFIG_VI 96 depends on VI
97 help 97 help
98 Enable the read-only command line option, which allows the user to 98 Enable the read-only command line option, which allows the user to
99 open a file in read-only mode. 99 open a file in read-only mode.
100 100
101config CONFIG_FEATURE_VI_SETOPTS 101config FEATURE_VI_SETOPTS
102 bool "Enable set-able options, ai ic showmatch" 102 bool "Enable set-able options, ai ic showmatch"
103 default y 103 default y
104 depends on CONFIG_VI 104 depends on VI
105 help 105 help
106 Enable the editor to set some (ai, ic, showmatch) options. 106 Enable the editor to set some (ai, ic, showmatch) options.
107 107
108config CONFIG_FEATURE_VI_SET 108config FEATURE_VI_SET
109 bool "Support for :set" 109 bool "Support for :set"
110 default y 110 default y
111 depends on CONFIG_VI 111 depends on VI
112 help 112 help
113 Support for ":set". 113 Support for ":set".
114 114
115config CONFIG_FEATURE_VI_WIN_RESIZE 115config FEATURE_VI_WIN_RESIZE
116 bool "Handle window resize" 116 bool "Handle window resize"
117 default y 117 default y
118 depends on CONFIG_VI 118 depends on VI
119 help 119 help
120 Make busybox vi behave nicely with terminals that get resized. 120 Make busybox vi behave nicely with terminals that get resized.
121 121
122config CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 122config FEATURE_VI_OPTIMIZE_CURSOR
123 bool "Optimize cursor movement" 123 bool "Optimize cursor movement"
124 default y 124 default y
125 depends on CONFIG_VI 125 depends on VI
126 help 126 help
127 This will make the cursor movement faster, but requires more memory 127 This will make the cursor movement faster, but requires more memory
128 and it makes the applet a tiny bit larger. 128 and it makes the applet a tiny bit larger.
diff --git a/editors/Kbuild b/editors/Kbuild
new file mode 100644
index 000000000..d991e1faf
--- /dev/null
+++ b/editors/Kbuild
@@ -0,0 +1,12 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_AWK) += awk.o
9lib-$(CONFIG_ED) += ed.o
10lib-$(CONFIG_PATCH) += patch.o
11lib-$(CONFIG_SED) += sed.o
12lib-$(CONFIG_VI) += vi.o
diff --git a/editors/Makefile b/editors/Makefile
deleted file mode 100644
index 22790095a..000000000
--- a/editors/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/editors
14EDITOR_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include $(srcdir)/Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/editors/Makefile.in b/editors/Makefile.in
deleted file mode 100644
index 9a46e32c2..000000000
--- a/editors/Makefile.in
+++ /dev/null
@@ -1,40 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7EDITOR_AR:=editors.a
8ifndef $(EDITOR_DIR)
9EDITOR_DIR:=$(top_builddir)/editors/
10endif
11srcdir=$(top_srcdir)/editors
12
13EDITOR-y:=
14EDITOR-$(CONFIG_AWK) += awk.o
15EDITOR-$(CONFIG_ED) += ed.o
16EDITOR-$(CONFIG_PATCH) += patch.o
17EDITOR-$(CONFIG_SED) += sed.o
18EDITOR-$(CONFIG_VI) += vi.o
19
20ifneq ($(strip $(EDITOR-y)),)
21libraries-y+=$(EDITOR_DIR)$(EDITOR_AR)
22endif
23
24EDITOR_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(EDITOR-y))
25EDITOR_SRC-a:=$(wildcard $(srcdir)/*.c)
26APPLET_SRC-y+=$(EDITOR_SRC-y)
27APPLET_SRC-a+=$(EDITOR_SRC-a)
28
29needlibm-y:=
30needlibm-$(CONFIG_FEATURE_AWK_MATH) := y
31
32ifeq ($(needlibm-y),y)
33 LIBRARIES := -lm $(filter-out -lm,$(LIBRARIES))
34endif
35
36$(EDITOR_DIR)$(EDITOR_AR): $(patsubst %,$(EDITOR_DIR)%, $(EDITOR-y))
37 $(do_ar)
38
39$(EDITOR_DIR)%.o: $(srcdir)/%.c
40 $(compile.c)
diff --git a/findutils/Config.in b/findutils/Config.in
index 12387a44e..5a4476a98 100644
--- a/findutils/Config.in
+++ b/findutils/Config.in
@@ -5,152 +5,152 @@
5 5
6menu "Finding Utilities" 6menu "Finding Utilities"
7 7
8config CONFIG_FIND 8config FIND
9 bool "find" 9 bool "find"
10 default n 10 default n
11 help 11 help
12 find is used to search your system to find specified files. 12 find is used to search your system to find specified files.
13 13
14config CONFIG_FEATURE_FIND_PRINT0 14config FEATURE_FIND_PRINT0
15 bool "Enable -print0 option" 15 bool "Enable -print0 option"
16 default y 16 default y
17 depends on CONFIG_FIND 17 depends on FIND
18 help 18 help
19 Causes output names to be separated by a null character 19 Causes output names to be separated by a null character
20 rather than a newline. This allows names that contain 20 rather than a newline. This allows names that contain
21 newlines and other whitespace to be more easily 21 newlines and other whitespace to be more easily
22 interpreted by other programs. 22 interpreted by other programs.
23 23
24config CONFIG_FEATURE_FIND_MTIME 24config FEATURE_FIND_MTIME
25 bool "Enable modified time matching (-mtime) option" 25 bool "Enable modified time matching (-mtime) option"
26 default y 26 default y
27 depends on CONFIG_FIND 27 depends on FIND
28 help 28 help
29 Allow searching based on the modification time of 29 Allow searching based on the modification time of
30 files, in days. 30 files, in days.
31 31
32config CONFIG_FEATURE_FIND_MMIN 32config FEATURE_FIND_MMIN
33 bool "Enable modified time matching (-min) option" 33 bool "Enable modified time matching (-min) option"
34 default y 34 default y
35 depends on CONFIG_FIND 35 depends on FIND
36 help 36 help
37 Allow searching based on the modification time of 37 Allow searching based on the modification time of
38 files, in minutes. 38 files, in minutes.
39 39
40config CONFIG_FEATURE_FIND_PERM 40config FEATURE_FIND_PERM
41 bool "Enable permissions matching (-perm) option" 41 bool "Enable permissions matching (-perm) option"
42 default y 42 default y
43 depends on CONFIG_FIND 43 depends on FIND
44 help 44 help
45 Enable searching based on file permissions. 45 Enable searching based on file permissions.
46 46
47config CONFIG_FEATURE_FIND_TYPE 47config FEATURE_FIND_TYPE
48 bool "Enable filetype matching (-type) option" 48 bool "Enable filetype matching (-type) option"
49 default y 49 default y
50 depends on CONFIG_FIND 50 depends on FIND
51 help 51 help
52 Enable searching based on file type (file, 52 Enable searching based on file type (file,
53 directory, socket, device, etc.). 53 directory, socket, device, etc.).
54 54
55config CONFIG_FEATURE_FIND_XDEV 55config FEATURE_FIND_XDEV
56 bool "Enable stay in filesystem (-xdev) option" 56 bool "Enable stay in filesystem (-xdev) option"
57 default y 57 default y
58 depends on CONFIG_FIND 58 depends on FIND
59 help 59 help
60 This option will allow find to restrict searches to a single 60 This option will allow find to restrict searches to a single
61 filesystem. 61 filesystem.
62 62
63config CONFIG_FEATURE_FIND_NEWER 63config FEATURE_FIND_NEWER
64 bool "Enable -newer option for comparing file mtimes" 64 bool "Enable -newer option for comparing file mtimes"
65 default y 65 default y
66 depends on CONFIG_FIND 66 depends on FIND
67 help 67 help
68 Support the 'find -newer' option for finding any files which have 68 Support the 'find -newer' option for finding any files which have
69 a modified time that is more recent than the specified FILE. 69 a modified time that is more recent than the specified FILE.
70 70
71config CONFIG_FEATURE_FIND_INUM 71config FEATURE_FIND_INUM
72 bool "Enable inode number matching (-inum) option" 72 bool "Enable inode number matching (-inum) option"
73 default y 73 default y
74 depends on CONFIG_FIND 74 depends on FIND
75 help 75 help
76 Support the 'find -inum' option for searching by inode number. 76 Support the 'find -inum' option for searching by inode number.
77 77
78config CONFIG_FEATURE_FIND_EXEC 78config FEATURE_FIND_EXEC
79 bool "Enable (-exec) option allowing execution of commands" 79 bool "Enable (-exec) option allowing execution of commands"
80 default y 80 default y
81 depends on CONFIG_FIND 81 depends on FIND
82 help 82 help
83 Support the 'find -exec' option for executing commands based upon 83 Support the 'find -exec' option for executing commands based upon
84 the files matched. 84 the files matched.
85 85
86config CONFIG_GREP 86config GREP
87 bool "grep" 87 bool "grep"
88 default n 88 default n
89 help 89 help
90 grep is used to search files for a specified pattern. 90 grep is used to search files for a specified pattern.
91 91
92config CONFIG_FEATURE_GREP_EGREP_ALIAS 92config FEATURE_GREP_EGREP_ALIAS
93 bool "Support extended regular expressions (egrep & grep -E)" 93 bool "Support extended regular expressions (egrep & grep -E)"
94 default y 94 default y
95 depends on CONFIG_GREP 95 depends on GREP
96 help 96 help
97 Enabled support for extended regular expressions. Extended 97 Enabled support for extended regular expressions. Extended
98 regular expressions allow for alternation (foo|bar), grouping, 98 regular expressions allow for alternation (foo|bar), grouping,
99 and various repetition operators. 99 and various repetition operators.
100 100
101config CONFIG_FEATURE_GREP_FGREP_ALIAS 101config FEATURE_GREP_FGREP_ALIAS
102 bool "Alias fgrep to grep -F" 102 bool "Alias fgrep to grep -F"
103 default y 103 default y
104 depends on CONFIG_GREP 104 depends on GREP
105 help 105 help
106 fgrep sees the search pattern as a normal string rather than 106 fgrep sees the search pattern as a normal string rather than
107 regular expressions. 107 regular expressions.
108 grep -F is always builtin, this just creates the fgrep alias. 108 grep -F is always builtin, this just creates the fgrep alias.
109 109
110config CONFIG_FEATURE_GREP_CONTEXT 110config FEATURE_GREP_CONTEXT
111 bool "Enable before and after context flags (-A, -B and -C)" 111 bool "Enable before and after context flags (-A, -B and -C)"
112 default y 112 default y
113 depends on CONFIG_GREP 113 depends on GREP
114 help 114 help
115 Print the specified number of leading (-B) and/or trailing (-A) 115 Print the specified number of leading (-B) and/or trailing (-A)
116 context surrounding our matching lines. 116 context surrounding our matching lines.
117 Print the specified number of context lines (-C). 117 Print the specified number of context lines (-C).
118 118
119config CONFIG_XARGS 119config XARGS
120 bool "xargs" 120 bool "xargs"
121 default n 121 default n
122 help 122 help
123 xargs is used to execute a specified command on 123 xargs is used to execute a specified command on
124 every item from standard input. 124 every item from standard input.
125 125
126config CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION 126config FEATURE_XARGS_SUPPORT_CONFIRMATION
127 bool "Enable prompt and confirmation option -p" 127 bool "Enable prompt and confirmation option -p"
128 default n 128 default n
129 depends on CONFIG_XARGS 129 depends on XARGS
130 help 130 help
131 Support prompt the user about whether to run each command 131 Support prompt the user about whether to run each command
132 line and read a line from the terminal. 132 line and read a line from the terminal.
133 133
134config CONFIG_FEATURE_XARGS_SUPPORT_QUOTES 134config FEATURE_XARGS_SUPPORT_QUOTES
135 bool "Enable support single and double quotes and backslash" 135 bool "Enable support single and double quotes and backslash"
136 default n 136 default n
137 depends on CONFIG_XARGS 137 depends on XARGS
138 help 138 help
139 Default xargs unsupport single and double quotes 139 Default xargs unsupport single and double quotes
140 and backslash for can use aruments with spaces. 140 and backslash for can use aruments with spaces.
141 141
142config CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT 142config FEATURE_XARGS_SUPPORT_TERMOPT
143 bool "Enable support options -x" 143 bool "Enable support options -x"
144 default n 144 default n
145 depends on CONFIG_XARGS 145 depends on XARGS
146 help 146 help
147 Enable support exit if the size (see the -s or -n option) 147 Enable support exit if the size (see the -s or -n option)
148 is exceeded. 148 is exceeded.
149 149
150config CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM 150config FEATURE_XARGS_SUPPORT_ZERO_TERM
151 bool "Enable null terminated option -0" 151 bool "Enable null terminated option -0"
152 default n 152 default n
153 depends on CONFIG_XARGS 153 depends on XARGS
154 help 154 help
155 Enable input filenames are terminated by a null character 155 Enable input filenames are terminated by a null character
156 instead of by whitespace, and the quotes and backslash 156 instead of by whitespace, and the quotes and backslash
diff --git a/findutils/Kbuild b/findutils/Kbuild
new file mode 100644
index 000000000..7b504bacf
--- /dev/null
+++ b/findutils/Kbuild
@@ -0,0 +1,10 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_FIND) += find.o
9lib-$(CONFIG_GREP) += grep.o
10lib-$(CONFIG_XARGS) += xargs.o
diff --git a/findutils/Makefile b/findutils/Makefile
deleted file mode 100644
index f152c8126..000000000
--- a/findutils/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/findutils
14FINDUTILS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include $(srcdir)/Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/findutils/Makefile.in b/findutils/Makefile.in
deleted file mode 100644
index 25a2d38d3..000000000
--- a/findutils/Makefile.in
+++ /dev/null
@@ -1,31 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7FINDUTILS_AR:=findutils.a
8ifndef $(FINDUTILS_DIR)
9FINDUTILS_DIR:=$(top_builddir)/findutils/
10endif
11srcdir=$(top_srcdir)/findutils
12
13FINDUTILS-y:=
14FINDUTILS-$(CONFIG_FIND) += find.o
15FINDUTILS-$(CONFIG_GREP) += grep.o
16FINDUTILS-$(CONFIG_XARGS) += xargs.o
17
18ifneq ($(strip $(FINDUTILS-y)),)
19libraries-y+=$(FINDUTILS_DIR)$(FINDUTILS_AR)
20endif
21
22FINDUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(FINDUTILS-y))
23FINDUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
24APPLET_SRC-y+=$(FINDUTILS_SRC-y)
25APPLET_SRC-a+=$(FINDUTILS_SRC-a)
26
27$(FINDUTILS_DIR)$(FINDUTILS_AR): $(patsubst %,$(FINDUTILS_DIR)%, $(FINDUTILS-y))
28 $(do_ar)
29
30$(FINDUTILS_DIR)%.o: $(srcdir)/%.c
31 $(compile.c)
diff --git a/include/bb_config.h b/include/bb_config.h
new file mode 100644
index 000000000..beec07cba
--- /dev/null
+++ b/include/bb_config.h
@@ -0,0 +1,142 @@
1/* Hack. kbuild will not define needed macros for config symbols
2 * which depend on other symbols, which themself are off.
3 * Provide them here by hand. Need a better idea. */
4
5#ifndef ENABLE_KILLALL5
6#define ENABLE_KILLALL5 0
7#define USE_KILLALL5(...)
8#define SKIP_KILLALL5(...) __VA_ARGS__
9#endif
10
11#ifndef ENABLE_FEATURE_QUERY_MODULE_INTERFACE
12#define ENABLE_FEATURE_QUERY_MODULE_INTERFACE 0
13#define USE_FEATURE_QUERY_MODULE_INTERFACE(...)
14#define SKIP_FEATURE_QUERY_MODULE_INTERFACE(...) __VA_ARGS__
15#endif
16
17#ifndef ENABLE_FEATURE_CLEAN_UP
18#define ENABLE_FEATURE_CLEAN_UP 0
19#define USE_FEATURE_CLEAN_UP(...)
20#define SKIP_FEATURE_CLEAN_UP(...) __VA_ARGS__
21#endif
22
23#ifndef ENABLE_FEATURE_SH_STANDALONE_SHELL
24#define ENABLE_FEATURE_SH_STANDALONE_SHELL 0
25#define USE_FEATURE_SH_STANDALONE_SHELL(...)
26#define SKIP_FEATURE_SH_STANDALONE_SHELL(...) __VA_ARGS__
27#endif
28
29#ifndef ENABLE_FEATURE_MTAB_SUPPORT
30#define ENABLE_FEATURE_MTAB_SUPPORT 0
31#define USE_FEATURE_MTAB_SUPPORT(...)
32#define SKIP_FEATURE_MTAB_SUPPORT(...) __VA_ARGS__
33#endif
34
35#ifndef ENABLE_FEATURE_PRESERVE_HARDLINKS
36#define ENABLE_FEATURE_PRESERVE_HARDLINKS 0
37#define USE_FEATURE_PRESERVE_HARDLINKS(...)
38#define SKIP_FEATURE_PRESERVE_HARDLINKS(...) __VA_ARGS__
39#endif
40
41#ifndef ENABLE_FEATURE_AUTOWIDTH
42#define ENABLE_FEATURE_AUTOWIDTH 0
43#define USE_FEATURE_AUTOWIDTH(...)
44#define SKIP_FEATURE_AUTOWIDTH(...) __VA_ARGS__
45#endif
46
47#ifndef ENABLE_FEATURE_SUID_CONFIG
48#define ENABLE_FEATURE_SUID_CONFIG 0
49#define USE_FEATURE_SUID_CONFIG(...)
50#define SKIP_FEATURE_SUID_CONFIG(...) __VA_ARGS__
51#endif
52
53#ifndef ENABLE_APP_DUMPLEASES
54#define ENABLE_APP_DUMPLEASES 0
55#define USE_APP_DUMPLEASES(...)
56#define SKIP_APP_DUMPLEASES(...) __VA_ARGS__
57#endif
58
59#ifndef ENABLE_E2LABEL
60#define ENABLE_E2LABEL 0
61#define USE_E2LABEL(...)
62#define SKIP_E2LABEL(...) __VA_ARGS__
63#endif
64
65#ifndef ENABLE_FEATURE_GREP_EGREP_ALIAS
66#define ENABLE_FEATURE_GREP_EGREP_ALIAS 0
67#define USE_FEATURE_GREP_EGREP_ALIAS(...)
68#define SKIP_FEATURE_GREP_EGREP_ALIAS(...) __VA_ARGS__
69#endif
70
71#ifndef ENABLE_FEATURE_GREP_FGREP_ALIAS
72#define ENABLE_FEATURE_GREP_FGREP_ALIAS 0
73#define USE_FEATURE_GREP_FGREP_ALIAS(...)
74#define SKIP_FEATURE_GREP_FGREP_ALIAS(...) __VA_ARGS__
75#endif
76
77#ifndef ENABLE_FINDFS
78#define ENABLE_FINDFS 0
79#define USE_FINDFS(...)
80#define SKIP_FINDFS(...) __VA_ARGS__
81#endif
82
83#ifndef ENABLE_IPADDR
84#define ENABLE_IPADDR 0
85#define USE_IPADDR(...)
86#define SKIP_IPADDR(...) __VA_ARGS__
87#endif
88
89#ifndef ENABLE_IPLINK
90#define ENABLE_IPLINK 0
91#define USE_IPLINK(...)
92#define SKIP_IPLINK(...) __VA_ARGS__
93#endif
94
95#ifndef ENABLE_IPROUTE
96
97#define ENABLE_IPROUTE 0
98#define USE_IPROUTE(...)
99#define SKIP_IPROUTE(...) __VA_ARGS__
100#endif
101
102#ifndef ENABLE_IPTUNNEL
103#define ENABLE_IPTUNNEL 0
104#define USE_IPTUNNEL(...)
105#define SKIP_IPTUNNEL(...) __VA_ARGS__
106#endif
107
108#ifndef ENABLE_KILLALL
109#define ENABLE_KILLALL 0
110#define USE_KILLALL(...)
111#define SKIP_KILLALL(...) __VA_ARGS__
112#endif
113
114#ifndef ENABLE_KLOGD
115#define ENABLE_KLOGD 0
116#define USE_KLOGD(...)
117#define SKIP_KLOGD(...) __VA_ARGS__
118#endif
119
120#ifndef ENABLE_FEATURE_INITRD
121#define ENABLE_FEATURE_INITRD 0
122#define USE_FEATURE_INITRD(...)
123#define SKIP_FEATURE_INITRD(...) __VA_ARGS__
124#endif
125
126#ifndef ENABLE_LOGREAD
127#define ENABLE_LOGREAD 0
128#define USE_LOGREAD(...)
129#define SKIP_LOGREAD(...) __VA_ARGS__
130#endif
131
132#ifndef ENABLE_PING6
133#define ENABLE_PING6 0
134#define USE_PING6(...)
135#define SKIP_PING6(...) __VA_ARGS__
136#endif
137
138#ifndef ENABLE_UNIX2DOS
139#define ENABLE_UNIX2DOS 0
140#define USE_UNIX2DOS(...)
141#define SKIP_UNIX2DOS(...) __VA_ARGS__
142#endif
diff --git a/include/busybox.h b/include/busybox.h
index fbda6efcb..d20337ff1 100644
--- a/include/busybox.h
+++ b/include/busybox.h
@@ -7,8 +7,6 @@
7#ifndef _BB_INTERNAL_H_ 7#ifndef _BB_INTERNAL_H_
8#define _BB_INTERNAL_H_ 1 8#define _BB_INTERNAL_H_ 1
9 9
10#include "bb_config.h"
11
12#include "libbb.h" 10#include "libbb.h"
13 11
14/* order matters: used as index into "install_dir[]" in busybox.c */ 12/* order matters: used as index into "install_dir[]" in busybox.c */
diff --git a/include/grp_.h b/include/grp_.h
index 3ac5c8461..b34addfa2 100644
--- a/include/grp_.h
+++ b/include/grp_.h
@@ -30,12 +30,10 @@
30#ifndef _GRP_H 30#ifndef _GRP_H
31#define _GRP_H 1 31#define _GRP_H 1
32 32
33
34#include <sys/types.h> 33#include <sys/types.h>
35#include <features.h> 34#include <features.h>
36#include <stdio.h> 35#include <stdio.h>
37 36
38
39/* The group structure. */ 37/* The group structure. */
40struct group 38struct group
41{ 39{
diff --git a/include/libbb.h b/include/libbb.h
index 88847ac59..ed1d780fd 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -377,7 +377,6 @@ extern const char *applet_name;
377extern const char bb_msg_full_version[]; 377extern const char bb_msg_full_version[];
378extern const char bb_msg_memory_exhausted[]; 378extern const char bb_msg_memory_exhausted[];
379extern const char bb_msg_invalid_date[]; 379extern const char bb_msg_invalid_date[];
380extern const char bb_msg_io_error[];
381extern const char bb_msg_read_error[]; 380extern const char bb_msg_read_error[];
382extern const char bb_msg_write_error[]; 381extern const char bb_msg_write_error[];
383extern const char bb_msg_name_longer_than_foo[]; 382extern const char bb_msg_name_longer_than_foo[];
diff --git a/init/Config.in b/init/Config.in
index 2a39d50e5..c0ad5263d 100644
--- a/init/Config.in
+++ b/init/Config.in
@@ -5,32 +5,32 @@
5 5
6menu "Init Utilities" 6menu "Init Utilities"
7 7
8config CONFIG_INIT 8config INIT
9 bool "init" 9 bool "init"
10 default n 10 default n
11 select CONFIG_FEATURE_SYSLOG 11 select FEATURE_SYSLOG
12 help 12 help
13 init is the first program run when the system boots. 13 init is the first program run when the system boots.
14 14
15config CONFIG_DEBUG_INIT 15config DEBUG_INIT
16 bool "debugging aid" 16 bool "debugging aid"
17 default n 17 default n
18 depends on CONFIG_INIT 18 depends on INIT
19 help 19 help
20 Turn this on to disable all the dangerous 20 Turn this on to disable all the dangerous
21 rebooting stuff when debugging. 21 rebooting stuff when debugging.
22 22
23config CONFIG_FEATURE_USE_INITTAB 23config FEATURE_USE_INITTAB
24 bool "Support reading an inittab file" 24 bool "Support reading an inittab file"
25 default y 25 default y
26 depends on CONFIG_INIT 26 depends on INIT
27 help 27 help
28 Allow init to read an inittab file when the system boot. 28 Allow init to read an inittab file when the system boot.
29 29
30config CONFIG_FEATURE_INIT_SCTTY 30config FEATURE_INIT_SCTTY
31 bool "Support running commands with a controlling-tty" 31 bool "Support running commands with a controlling-tty"
32 default n 32 default n
33 depends on CONFIG_INIT 33 depends on INIT
34 help 34 help
35 If this option is enabled a command starting with hyphen (-) 35 If this option is enabled a command starting with hyphen (-)
36 is run in its own session (setsid(2)) and possibly with a 36 is run in its own session (setsid(2)) and possibly with a
@@ -38,17 +38,17 @@ config CONFIG_FEATURE_INIT_SCTTY
38 behavour, but is often what you want in an embedded system where 38 behavour, but is often what you want in an embedded system where
39 the console is only accessed during development or for maintenance. 39 the console is only accessed during development or for maintenance.
40 40
41config CONFIG_FEATURE_EXTRA_QUIET 41config FEATURE_EXTRA_QUIET
42 bool "Be _extra_ quiet on boot" 42 bool "Be _extra_ quiet on boot"
43 default y 43 default y
44 depends on CONFIG_INIT 44 depends on INIT
45 help 45 help
46 Prevent init from logging some messages to the console during boot. 46 Prevent init from logging some messages to the console during boot.
47 47
48config CONFIG_FEATURE_INIT_COREDUMPS 48config FEATURE_INIT_COREDUMPS
49 bool "Support dumping core for child processes (debugging only)" 49 bool "Support dumping core for child processes (debugging only)"
50 default n 50 default n
51 depends on CONFIG_INIT 51 depends on INIT
52 help 52 help
53 If this option is enabled and the file /.init_enable_core 53 If this option is enabled and the file /.init_enable_core
54 exists, then init will call setrlimit() to allow unlimited 54 exists, then init will call setrlimit() to allow unlimited
@@ -57,10 +57,10 @@ config CONFIG_FEATURE_INIT_COREDUMPS
57 57
58 58
59 59
60config CONFIG_FEATURE_INITRD 60config FEATURE_INITRD
61 bool "Support running init from within an initrd (not initramfs)" 61 bool "Support running init from within an initrd (not initramfs)"
62 default y 62 default y
63 depends on CONFIG_INIT 63 depends on INIT
64 help 64 help
65 Legacy support for running init under the old-style initrd. Allows 65 Legacy support for running init under the old-style initrd. Allows
66 the name linuxrc to act as init, and it doesn't assume init is PID 1. 66 the name linuxrc to act as init, and it doesn't assume init is PID 1.
@@ -68,13 +68,13 @@ config CONFIG_FEATURE_INITRD
68 This does not apply to initramfs, which runs /init as PID 1 and 68 This does not apply to initramfs, which runs /init as PID 1 and
69 requires no special support. 69 requires no special support.
70 70
71config CONFIG_HALT 71config HALT
72 bool "poweroff, halt, and reboot" 72 bool "poweroff, halt, and reboot"
73 default y 73 default y
74 help 74 help
75 Stop all processes and either halt, reboot, or power off the system. 75 Stop all processes and either halt, reboot, or power off the system.
76 76
77config CONFIG_MESG 77config MESG
78 bool "mesg" 78 bool "mesg"
79 default y 79 default y
80 help 80 help
diff --git a/init/Kbuild b/init/Kbuild
new file mode 100644
index 000000000..e99360241
--- /dev/null
+++ b/init/Kbuild
@@ -0,0 +1,12 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_HALT) += halt.o
9lib-$(CONFIG_INIT) += init.o
10lib-$(CONFIG_MESG) += mesg.o
11lib-$(CONFIG_INIT) += init_shared.o
12lib-$(CONFIG_HALT) += init_shared.o
diff --git a/init/Makefile b/init/Makefile
deleted file mode 100644
index 63816f6aa..000000000
--- a/init/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/init
14INIT_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include $(srcdir)/Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/init/Makefile.in b/init/Makefile.in
deleted file mode 100644
index a48ead446..000000000
--- a/init/Makefile.in
+++ /dev/null
@@ -1,43 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7INIT_AR:=init.a
8ifndef $(INIT_DIR)
9INIT_DIR:=$(top_builddir)/init/
10endif
11srcdir=$(top_srcdir)/init
12
13INIT-y:=
14INIT-$(CONFIG_HALT) += halt.o
15INIT-$(CONFIG_INIT) += init.o
16INIT-$(CONFIG_MESG) += mesg.o
17
18ifeq ($(strip $(CONFIG_HALT)),y)
19CONFIG_INIT_SHARED=y
20else
21ifeq ($(strip $(CONFIG_INIT)),y)
22CONFIG_INIT_SHARED=y
23else
24CONFIG_INIT_SHARED=n
25endif
26endif
27
28INIT-$(CONFIG_INIT_SHARED) += init_shared.o
29
30ifneq ($(strip $(INIT-y)),)
31libraries-y+=$(INIT_DIR)$(INIT_AR)
32endif
33
34INIT_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(INIT-y))
35INIT_SRC-a:=$(wildcard $(srcdir)/*.c)
36APPLET_SRC-y+=$(INIT_SRC-y)
37APPLET_SRC-a+=$(INIT_SRC-a)
38
39$(INIT_DIR)$(INIT_AR): $(patsubst %,$(INIT_DIR)%, $(INIT-y))
40 $(do_ar)
41
42$(INIT_DIR)%.o: $(srcdir)/%.c
43 $(compile.c)
diff --git a/libbb/Config.in b/libbb/Config.in
index c5406cbb9..92ee55cbc 100644
--- a/libbb/Config.in
+++ b/libbb/Config.in
@@ -5,14 +5,14 @@
5 5
6menu "Busybox Library Tuning" 6menu "Busybox Library Tuning"
7 7
8config CONFIG_PASSWORD_MINLEN 8config PASSWORD_MINLEN
9 int "Minimum password length" 9 int "Minimum password length"
10 default 6 10 default 6
11 range 5 32 11 range 5 32
12 help 12 help
13 Minimum allowable password length. 13 Minimum allowable password length.
14 14
15config CONFIG_MD5_SIZE_VS_SPEED 15config MD5_SIZE_VS_SPEED
16 int " MD5: Trade Bytes for Speed" 16 int " MD5: Trade Bytes for Speed"
17 default 2 17 default 2
18 range 0 3 18 range 0 3
diff --git a/libbb/Kbuild b/libbb/Kbuild
new file mode 100644
index 000000000..909f527ba
--- /dev/null
+++ b/libbb/Kbuild
@@ -0,0 +1,61 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:= \
8 ask_confirmation.o change_identity.o chomp.o \
9 compare_string_array.o concat_path_file.o copy_file.o copyfd.o \
10 crc32.o create_icmp_socket.o create_icmp6_socket.o \
11 device_open.o dump.o error_msg.o error_msg_and_die.o \
12 find_pid_by_name.o find_root_device.o fgets_str.o full_read.o \
13 full_write.o get_last_path_component.o get_line_from_file.o \
14 herror_msg.o herror_msg_and_die.o \
15 human_readable.o inet_common.o inode_hash.o isdirectory.o \
16 kernel_version.o last_char_is.o login.o \
17 make_directory.o md5.o mode_string.o mtab_file.o \
18 obscure.o parse_mode.o parse_number.o perror_msg.o \
19 perror_msg_and_die.o get_console.o \
20 process_escape_sequence.o procps.o \
21 recursive_action.o remove_file.o \
22 restricted_shell.o run_parts.o run_shell.o safe_read.o safe_write.o \
23 safe_strncpy.o setup_environment.o sha1.o simplify_path.o \
24 trim.o u_signal_names.o vdprintf.o verror_msg.o \
25 vherror_msg.o vperror_msg.o wfopen.o xconnect.o xgetcwd.o \
26 xgethostbyname.o xgethostbyname2.o xreadlink.o xgetlarg.o \
27 fclose_nonstdin.o fflush_stdout_and_exit.o \
28 getopt32.o default_error_retval.o wfopen_input.o speed_table.o \
29 perror_nomsg_and_die.o perror_nomsg.o skip_whitespace.o bb_askpass.o \
30 warn_ignoring_args.o concat_subpath_file.o vfork_daemon_rexec.o \
31 bb_do_delay.o uuencode.o info_msg.o vinfo_msg.o
32
33# conditionally compiled objects:
34lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o
35lib-$(CONFIG_LOSETUP) += loop.o
36lib-$(CONFIG_FEATURE_MTAB_SUPPORT) += mtab.o
37lib-$(CONFIG_PASSWD) += pw_encrypt.o
38lib-$(CONFIG_SULOGIN) += pw_encrypt.o
39lib-$(CONFIG_FEATURE_HTTPD_AUTH_MD5) += pw_encrypt.o
40lib-$(CONFIG_VLOCK) += correct_password.o
41lib-$(CONFIG_SU) += correct_password.o
42lib-$(CONFIG_LOGIN) += correct_password.o
43lib-$(CONFIG_DF) += find_mount_point.o
44lib-$(CONFIG_EJECT) += find_mount_point.o
45
46# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
47# require regex.h to be in the include dir even if we don't need it thereby
48# allowing us to build busybox even if uclibc regex support is disabled.
49
50lib-$(CONFIG_AWK) += xregcomp.o
51lib-$(CONFIG_SED) += xregcomp.o
52lib-$(CONFIG_LESS) += xregcomp.o
53lib-$(CONFIG_DEVFSD) += xregcomp.o
54
55lib-y += messages.o
56lib-y += xfuncs.o
57lib-y += printf.o
58lib-y += xgetularg.o
59lib-y += safe_strtol.o
60lib-y += bb_pwd.o
61lib-y += llist.o
diff --git a/libbb/Makefile b/libbb/Makefile
deleted file mode 100644
index 336398641..000000000
--- a/libbb/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/libbb
14LIBBB_DIR:=./
15
16# Ensure "all" is still the default target when make is run by itself in
17# libbb, even if the files we include define rules for targets.
18
19all:
20
21include $(top_srcdir)/Rules.mak
22include $(top_builddir)/.config
23include Makefile.in
24all: $(libraries-y)
25-include $(top_builddir)/.depend
26
27clean:
28 rm -f *.o *.a $(AR_TARGET)
29
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
deleted file mode 100644
index ef5c6b97a..000000000
--- a/libbb/Makefile.in
+++ /dev/null
@@ -1,155 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef $(LIBBB_DIR)
8LIBBB_DIR:=$(top_builddir)/libbb
9endif
10srcdir=$(top_srcdir)/libbb
11
12LIBBB-n:=
13LIBBB-y:= \
14 ask_confirmation.c change_identity.c chomp.c \
15 compare_string_array.c concat_path_file.c copy_file.c copyfd.c \
16 crc32.c create_icmp_socket.c create_icmp6_socket.c \
17 device_open.c dump.c error_msg.c error_msg_and_die.c \
18 find_pid_by_name.c find_root_device.c fgets_str.c full_read.c \
19 full_write.c get_last_path_component.c get_line_from_file.c \
20 herror_msg.c herror_msg_and_die.c \
21 human_readable.c inet_common.c inode_hash.c isdirectory.c \
22 kernel_version.c last_char_is.c login.c \
23 make_directory.c md5.c mode_string.c mtab_file.c \
24 obscure.c parse_mode.c parse_number.c perror_msg.c \
25 perror_msg_and_die.c get_console.c process_escape_sequence.c procps.c \
26 recursive_action.c remove_file.c info_msg.c vinfo_msg.c \
27 restricted_shell.c run_parts.c run_shell.c safe_read.c safe_write.c \
28 safe_strncpy.c setup_environment.c sha1.c simplify_path.c \
29 trim.c u_signal_names.c vdprintf.c verror_msg.c \
30 vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
31 xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
32 fclose_nonstdin.c fflush_stdout_and_exit.c \
33 getopt32.c default_error_retval.c wfopen_input.c speed_table.c \
34 perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
35 warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
36 bb_do_delay.c
37
38# conditionally compiled objects:
39LIBBB-$(CONFIG_FEATURE_MOUNT_LOOP)+= loop.c
40LIBBB-$(CONFIG_LOSETUP)+= loop.c
41LIBBB-$(CONFIG_FEATURE_MTAB_SUPPORT)+= mtab.c
42LIBBB-$(CONFIG_PASSWD)+= pw_encrypt.c
43LIBBB-$(CONFIG_SULOGIN)+= pw_encrypt.c
44LIBBB-$(CONFIG_FEATURE_HTTPD_AUTH_MD5)+= pw_encrypt.c
45LIBBB-$(CONFIG_VLOCK)+= correct_password.c
46LIBBB-$(CONFIG_SU)+= correct_password.c
47LIBBB-$(CONFIG_LOGIN)+= correct_password.c
48LIBBB-$(CONFIG_DF)+= find_mount_point.c
49LIBBB-$(CONFIG_EJECT)+= find_mount_point.c
50LIBBB-$(CONFIG_UUENCODE)+= uuencode.c
51LIBBB-$(CONFIG_WGET)+= uuencode.c
52
53# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
54# require regex.h to be in the include dir even if we don't need it thereby
55# allowing us to build busybox even if uclibc regex support is disabled.
56
57regex-y:=
58regex-$(CONFIG_AWK) += xregcomp.c
59regex-$(CONFIG_SED) += xregcomp.c
60regex-$(CONFIG_LESS) += xregcomp.c
61regex-$(CONFIG_DEVFSD) += xregcomp.c
62regex-$(CONFIG_MDEV) += xregcomp.c
63regex-$(CONFIG_GREP) += xregcomp.c
64
65# Sort has the happy side efect of returning a unique list
66LIBBB-y += $(sort $(regex-y))
67
68LIBBB-y:=$(patsubst %,$(srcdir)/%,$(LIBBB-y))
69
70get-file-subparts = $(addsuffix .o,$(shell sed -n -e "s/^\#ifdef L_//p" ${1}))
71
72# 1:N objects
73LIBBB_MSRC0:=$(srcdir)/messages.c
74LIBBB_MOBJ0:=$(call get-file-subparts, ${LIBBB_MSRC0})
75LIBBB_MOBJ0:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ0))
76$(LIBBB_MOBJ0):$(LIBBB_MSRC0)
77 $(compile.c) -DL_$(notdir $*)
78
79LIBBB_MSRC1:=$(srcdir)/xfuncs.c
80LIBBB_MOBJ1:=$(call get-file-subparts, ${LIBBB_MSRC1})
81LIBBB_MOBJ1:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ1))
82$(LIBBB_MOBJ1):$(LIBBB_MSRC1)
83 $(compile.c) -DL_$(notdir $*)
84
85LIBBB_MSRC2:=$(srcdir)/printf.c
86LIBBB_MOBJ2:=$(call get-file-subparts, ${LIBBB_MSRC2})
87LIBBB_MOBJ2:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ2))
88$(LIBBB_MOBJ2):$(LIBBB_MSRC2)
89 $(compile.c) -DL_$(notdir $*)
90
91LIBBB_MSRC3:=$(srcdir)/xgetularg.c
92LIBBB_MOBJ3:=$(call get-file-subparts, ${LIBBB_MSRC3})
93LIBBB_MOBJ3:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ3))
94$(LIBBB_MOBJ3):$(LIBBB_MSRC3)
95 $(compile.c) -DL_$(notdir $*)
96
97LIBBB_MSRC4:=$(srcdir)/safe_strtol.c
98LIBBB_MOBJ4:=$(call get-file-subparts, ${LIBBB_MSRC4})
99LIBBB_MOBJ4:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ4))
100$(LIBBB_MOBJ4):$(LIBBB_MSRC4)
101 $(compile.c) -DL_$(notdir $*)
102
103LIBBB_MSRC5:=$(srcdir)/bb_pwd.c
104LIBBB_MOBJ5:=$(call get-file-subparts, ${LIBBB_MSRC5})
105LIBBB_MOBJ5:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ5))
106$(LIBBB_MOBJ5):$(LIBBB_MSRC5)
107 $(compile.c) -DL_$(notdir $*)
108
109LIBBB_MSRC6:=$(srcdir)/llist.c
110LIBBB_MOBJ6:=$(call get-file-subparts, ${LIBBB_MSRC6})
111LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6))
112$(LIBBB_MOBJ6):$(LIBBB_MSRC6)
113 $(compile.c) -DL_$(notdir $*)
114
115# We need the names of the object files built from MSRC for the L_ defines
116LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) \
117 $(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6)
118
119LIBBB_ALL_MSRC:=$(LIBBB_MSRC0) $(LIBBB_MSRC1) $(LIBBB_MSRC2) $(LIBBB_MSRC3) \
120 $(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6)
121
122LIBBB-y:=$(sort $(LIBBB-y) $(LIBBB_ALL_MSRC))
123
124LIBBB_AR:=$(LIBBB_DIR)/libbb.a
125libraries-y+=$(LIBBB_AR)
126
127needcrypt-y:=
128ifneq ($(filter $(srcdir)/pw_encrypt.c,$(LIBBB-y)),)
129needcrypt-y:=y
130else
131ifneq ($(filter $(srcdir)/correct_password.c,$(LIBBB-y)),)
132needcrypt-y:=y
133endif
134endif
135
136ifeq ($(needcrypt-y),y)
137 LIBRARIES := -lcrypt $(filter-out -lcrypt,$(LIBRARIES))
138endif
139
140# all 1:1 objects
141LIBBB_OBJS:=$(patsubst $(srcdir)/%.c,$(LIBBB_DIR)/%.o, $(LIBBB-y))
142$(LIBBB_DIR)/%.o: $(srcdir)/%.c
143 $(compile.c)
144
145LIBBB_SRC-a:=$(wildcard $(srcdir)/*.c)
146LIBRARY_SRC-y+=$(LIBBB-y)
147LIBRARY_SRC-a+=$(LIBBB_SRC-a)
148
149# all defines needed for 1:N objects
150LIBBB_DEFINE-y:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(LIBBB_ALL_MOBJ))))
151LIBRARY_DEFINE-y+=$(LIBBB_DEFINE-y)
152LIBRARY_DEFINE-a+=$(LIBBB_DEFINE-y)
153
154$(LIBBB_AR): $(LIBBB_OBJS) $(LIBBB_ALL_MOBJ)
155 $(do_ar)
diff --git a/libbb/bb_pwd.c b/libbb/bb_pwd.c
index e4d327340..3a214ca33 100644
--- a/libbb/bb_pwd.c
+++ b/libbb/bb_pwd.c
@@ -7,8 +7,11 @@
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <string.h>
12#include <assert.h>
13#include "libbb.h"
10 14
11#ifdef L_bb_getgrgid
12 /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more 15 /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more
13 * flexible : 16 * flexible :
14 * 17 *
@@ -26,9 +29,6 @@
26 * the program exits. 29 * the program exits.
27 */ 30 */
28 31
29#include "libbb.h"
30#include "grp_.h"
31
32/* gets a groupname given a gid */ 32/* gets a groupname given a gid */
33char * bb_getgrgid(char *group, long gid, int bufsize) 33char * bb_getgrgid(char *group, long gid, int bufsize)
34{ 34{
@@ -37,15 +37,6 @@ char * bb_getgrgid(char *group, long gid, int bufsize)
37 return bb_getug(group, (mygroup) ? 37 return bb_getug(group, (mygroup) ?
38 mygroup->gr_name : (char *)mygroup, gid, bufsize, 'g'); 38 mygroup->gr_name : (char *)mygroup, gid, bufsize, 'g');
39} 39}
40#endif /* L_bb_getgrgid */
41
42#ifdef L_bb_xgetgrnam
43#include <stdio.h>
44#include <string.h>
45#include "libbb.h"
46#include "pwd_.h"
47#include "grp_.h"
48
49 40
50/* returns a gid given a group name */ 41/* returns a gid given a group name */
51long bb_xgetgrnam(const char *name) 42long bb_xgetgrnam(const char *name)
@@ -58,15 +49,6 @@ long bb_xgetgrnam(const char *name)
58 49
59 return (mygroup->gr_gid); 50 return (mygroup->gr_gid);
60} 51}
61#endif /* L_bb_xgetgrnam */
62
63#ifdef L_bb_xgetpwnam
64#include <stdio.h>
65#include <string.h>
66#include "libbb.h"
67#include "pwd_.h"
68#include "grp_.h"
69
70 52
71/* returns a uid given a username */ 53/* returns a uid given a username */
72long bb_xgetpwnam(const char *name) 54long bb_xgetpwnam(const char *name)
@@ -79,9 +61,7 @@ long bb_xgetpwnam(const char *name)
79 61
80 return myuser->pw_uid; 62 return myuser->pw_uid;
81} 63}
82#endif /* L_bb_xgetpwnam */
83 64
84#ifdef L_bb_getpwuid
85 /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more 65 /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more
86 * flexible : 66 * flexible :
87 * 67 *
@@ -99,9 +79,6 @@ long bb_xgetpwnam(const char *name)
99 * the program exits. 79 * the program exits.
100 */ 80 */
101 81
102#include "libbb.h"
103#include "pwd_.h"
104
105/* gets a username given a uid */ 82/* gets a username given a uid */
106char * bb_getpwuid(char *name, long uid, int bufsize) 83char * bb_getpwuid(char *name, long uid, int bufsize)
107{ 84{
@@ -110,9 +87,7 @@ char * bb_getpwuid(char *name, long uid, int bufsize)
110 return bb_getug(name, (myuser) ? 87 return bb_getug(name, (myuser) ?
111 myuser->pw_name : (char *)myuser , uid, bufsize, 'u'); 88 myuser->pw_name : (char *)myuser , uid, bufsize, 'u');
112} 89}
113#endif /* L_bb_getpwuid */
114 90
115#ifdef L_bb_getug
116 /* 91 /*
117 * if bufsize is > 0 char *buffer can not be set to NULL. 92 * if bufsize is > 0 char *buffer can not be set to NULL.
118 * If idname is not NULL it is written on the static 93 * If idname is not NULL it is written on the static
@@ -127,11 +102,6 @@ char * bb_getpwuid(char *name, long uid, int bufsize)
127 * else an error message is printed and the program exits. 102 * else an error message is printed and the program exits.
128 */ 103 */
129 104
130#include <stdio.h>
131#include <assert.h>
132#include "libbb.h"
133
134
135/* internal function for bb_getpwuid and bb_getgrgid */ 105/* internal function for bb_getpwuid and bb_getgrgid */
136char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix) 106char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix)
137{ 107{
@@ -146,13 +116,6 @@ char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix)
146 } 116 }
147 return idname; 117 return idname;
148} 118}
149#endif /* L_bb_getug */
150
151
152#ifdef L_get_ug_id
153/* indirect dispatcher for pwd helpers. */
154#include <stdlib.h>
155#include "libbb.h"
156 119
157unsigned long get_ug_id(const char *s, 120unsigned long get_ug_id(const char *s,
158 long (*__bb_getxxnam)(const char *)) 121 long (*__bb_getxxnam)(const char *))
@@ -167,4 +130,3 @@ unsigned long get_ug_id(const char *s,
167 130
168 return r; 131 return r;
169} 132}
170#endif /* L_get_ug_id */
diff --git a/libbb/llist.c b/libbb/llist.c
index 0e727c496..8bf89a595 100644
--- a/libbb/llist.c
+++ b/libbb/llist.c
@@ -13,7 +13,6 @@
13#include <stdlib.h> 13#include <stdlib.h>
14#include "libbb.h" 14#include "libbb.h"
15 15
16#ifdef L_llist_add_to
17/* Add data to the start of the linked list. */ 16/* Add data to the start of the linked list. */
18void llist_add_to(llist_t **old_head, void *data) 17void llist_add_to(llist_t **old_head, void *data)
19{ 18{
@@ -22,9 +21,7 @@ void llist_add_to(llist_t **old_head, void *data)
22 new_head->link = *old_head; 21 new_head->link = *old_head;
23 *old_head = new_head; 22 *old_head = new_head;
24} 23}
25#endif
26 24
27#ifdef L_llist_add_to_end
28/* Add data to the end of the linked list. */ 25/* Add data to the end of the linked list. */
29void llist_add_to_end(llist_t **list_head, void *data) 26void llist_add_to_end(llist_t **list_head, void *data)
30{ 27{
@@ -39,9 +36,7 @@ void llist_add_to_end(llist_t **list_head, void *data)
39 tail->link = new_item; 36 tail->link = new_item;
40 } 37 }
41} 38}
42#endif
43 39
44#ifdef L_llist_pop
45/* Remove first element from the list and return it */ 40/* Remove first element from the list and return it */
46void *llist_pop(llist_t **head) 41void *llist_pop(llist_t **head)
47{ 42{
@@ -57,9 +52,7 @@ void *llist_pop(llist_t **head)
57 52
58 return data; 53 return data;
59} 54}
60#endif
61 55
62#ifdef L_llist_free
63/* Recursively free all elements in the linked list. If freeit != NULL 56/* Recursively free all elements in the linked list. If freeit != NULL
64 * call it on each datum in the list */ 57 * call it on each datum in the list */
65void llist_free(llist_t *elm, void (*freeit)(void *data)) 58void llist_free(llist_t *elm, void (*freeit)(void *data))
@@ -69,4 +62,3 @@ void llist_free(llist_t *elm, void (*freeit)(void *data))
69 if (freeit) freeit(data); 62 if (freeit) freeit(data);
70 } 63 }
71} 64}
72#endif
diff --git a/libbb/messages.c b/libbb/messages.c
index 5aba7e693..bd41216a5 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -7,7 +7,6 @@
7 7
8#include "libbb.h" 8#include "libbb.h"
9 9
10#ifdef L_full_version
11#ifndef BB_EXTRA_VERSION 10#ifndef BB_EXTRA_VERSION
12#define BANNER "BusyBox v" BB_VER " (" BB_BT ")" 11#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
13#else 12#else
@@ -15,92 +14,30 @@
15#endif 14#endif
16const char BB_BANNER[] = BANNER; 15const char BB_BANNER[] = BANNER;
17const char bb_msg_full_version[] = BANNER " multi-call binary"; 16const char bb_msg_full_version[] = BANNER " multi-call binary";
18#endif
19
20#ifdef L_memory_exhausted
21 const char bb_msg_memory_exhausted[] = "memory exhausted";
22#endif
23#ifdef L_invalid_date
24 const char bb_msg_invalid_date[] = "invalid date `%s'";
25#endif
26#ifdef L_io_error
27 const char bb_msg_io_error[] = "%s: input/output error -- %m";
28#endif
29#ifdef L_write_error
30 const char bb_msg_write_error[] = "write error";
31#endif
32#ifdef L_read_error
33 const char bb_msg_read_error[] = "read error";
34#endif
35#ifdef L_name_longer_than_foo
36 const char bb_msg_name_longer_than_foo[] = "names longer than %d chars not supported";
37#endif
38#ifdef L_unknown
39 const char bb_msg_unknown[] = "(unknown)";
40#endif
41#ifdef L_can_not_create_raw_socket
42 const char bb_msg_can_not_create_raw_socket[] = "can't create raw socket";
43#endif
44#ifdef L_perm_denied_are_you_root
45 const char bb_msg_perm_denied_are_you_root[] = "permission denied. (are you root?)";
46#endif
47#ifdef L_msg_requires_arg
48 const char bb_msg_requires_arg[] = "%s requires an argument";
49#endif
50#ifdef L_msg_invalid_arg
51 const char bb_msg_invalid_arg[] = "invalid argument `%s' to `%s'";
52#endif
53#ifdef L_msg_standard_input
54 const char bb_msg_standard_input[] = "standard input";
55#endif
56#ifdef L_msg_standard_output
57 const char bb_msg_standard_output[] = "standard output";
58#endif
59
60#ifdef L_passwd_file
61#define PASSWD_FILE "/etc/passwd"
62const char bb_path_passwd_file[] = PASSWD_FILE;
63#endif
64 17
65#ifdef L_shadow_file 18const char bb_msg_memory_exhausted[] = "memory exhausted";
66#define SHADOW_FILE "/etc/shadow" 19const char bb_msg_invalid_date[] = "invalid date '%s'";
67const char bb_path_shadow_file[] = SHADOW_FILE; 20const char bb_msg_write_error[] = "write error";
68#endif 21const char bb_msg_read_error[] = "read error";
69 22const char bb_msg_name_longer_than_foo[] = "names longer than %d chars not supported";
70#ifdef L_group_file 23const char bb_msg_unknown[] = "(unknown)";
71#define GROUP_FILE "/etc/group" 24const char bb_msg_can_not_create_raw_socket[] = "can't create raw socket";
72const char bb_path_group_file[] = GROUP_FILE; 25const char bb_msg_perm_denied_are_you_root[] = "permission denied. (are you root?)";
73#endif 26const char bb_msg_requires_arg[] = "%s requires an argument";
74 27const char bb_msg_invalid_arg[] = "invalid argument '%s' to '%s'";
75#ifdef L_gshadow_file 28const char bb_msg_standard_input[] = "standard input";
76#define GSHADOW_FILE "/etc/gshadow" 29const char bb_msg_standard_output[] = "standard output";
77const char bb_path_gshadow_file[] = GSHADOW_FILE; 30
78#endif 31const char bb_path_passwd_file[] = "/etc/passwd";
79 32const char bb_path_shadow_file[] = "/etc/shadow";
80#ifdef L_nologin_file 33const char bb_path_group_file[] = "/etc/group";
81#define NOLOGIN_FILE "/etc/nologin" 34const char bb_path_gshadow_file[] = "/etc/gshadow";
82const char bb_path_nologin_file[] = NOLOGIN_FILE; 35const char bb_path_nologin_file[] = "/etc/nologin";
83#endif 36const char bb_path_securetty_file[] = "/etc/securetty";
84 37const char bb_path_motd_file[] = "/etc/motd";
85#ifdef L_securetty_file
86#define SECURETTY_FILE "/etc/securetty"
87const char bb_path_securetty_file[] = SECURETTY_FILE;
88#endif
89
90#ifdef L_motd_file
91#define MOTD_FILE "/etc/motd"
92const char bb_path_motd_file[] = MOTD_FILE;
93#endif
94
95#ifdef L_shell_file
96const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; 38const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL;
97#endif
98
99#ifdef L_bb_dev_null
100const char bb_dev_null[] = "/dev/null"; 39const char bb_dev_null[] = "/dev/null";
101#endif
102 40
103#ifdef L_bb_path_wtmp_file
104#include <utmp.h> 41#include <utmp.h>
105/* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ 42/* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */
106const char bb_path_wtmp_file[] = 43const char bb_path_wtmp_file[] =
@@ -111,9 +48,5 @@ WTMP_FILE;
111#else 48#else
112# error unknown path to wtmp file 49# error unknown path to wtmp file
113#endif 50#endif
114#endif
115 51
116
117#ifdef L_bb_common_bufsiz1
118char bb_common_bufsiz1[BUFSIZ+1]; 52char bb_common_bufsiz1[BUFSIZ+1];
119#endif
diff --git a/libbb/printf.c b/libbb/printf.c
index 2e79555b5..f0ddb862e 100644
--- a/libbb/printf.c
+++ b/libbb/printf.c
@@ -37,7 +37,6 @@
37#include <errno.h> 37#include <errno.h>
38#include "libbb.h" 38#include "libbb.h"
39 39
40#ifdef L_bb_vfprintf
41int bb_vfprintf(FILE * __restrict stream, 40int bb_vfprintf(FILE * __restrict stream,
42 const char * __restrict format, 41 const char * __restrict format,
43 va_list arg) 42 va_list arg)
@@ -65,16 +64,12 @@ int bb_vfprintf(FILE * __restrict stream,
65 64
66 return rv; 65 return rv;
67} 66}
68#endif
69 67
70#ifdef L_bb_vprintf
71int bb_vprintf(const char * __restrict format, va_list arg) 68int bb_vprintf(const char * __restrict format, va_list arg)
72{ 69{
73 return bb_vfprintf(stdout, format, arg); 70 return bb_vfprintf(stdout, format, arg);
74} 71}
75#endif
76 72
77#ifdef L_bb_fprintf
78int bb_fprintf(FILE * __restrict stream, 73int bb_fprintf(FILE * __restrict stream,
79 const char * __restrict format, ...) 74 const char * __restrict format, ...)
80{ 75{
@@ -87,9 +82,7 @@ int bb_fprintf(FILE * __restrict stream,
87 82
88 return rv; 83 return rv;
89} 84}
90#endif
91 85
92#ifdef L_bb_printf
93int bb_printf(const char * __restrict format, ...) 86int bb_printf(const char * __restrict format, ...)
94{ 87{
95 va_list arg; 88 va_list arg;
@@ -101,4 +94,3 @@ int bb_printf(const char * __restrict format, ...)
101 94
102 return rv; 95 return rv;
103} 96}
104#endif
diff --git a/libbb/safe_strtol.c b/libbb/safe_strtol.c
index 2e8fa9558..027fc1e62 100644
--- a/libbb/safe_strtol.c
+++ b/libbb/safe_strtol.c
@@ -12,7 +12,6 @@
12#include <assert.h> 12#include <assert.h>
13#include "libbb.h" 13#include "libbb.h"
14 14
15#ifdef L_safe_strtoi
16int safe_strtoi(char *arg, int* value) 15int safe_strtoi(char *arg, int* value)
17{ 16{
18 int error; 17 int error;
@@ -21,9 +20,7 @@ int safe_strtoi(char *arg, int* value)
21 *value = (int) lvalue; 20 *value = (int) lvalue;
22 return error; 21 return error;
23} 22}
24#endif
25 23
26#ifdef L_safe_strtod
27int safe_strtod(char *arg, double* value) 24int safe_strtod(char *arg, double* value)
28{ 25{
29 char *endptr; 26 char *endptr;
@@ -38,9 +35,7 @@ int safe_strtod(char *arg, double* value)
38 errno = errno_save; 35 errno = errno_save;
39 return 0; 36 return 0;
40} 37}
41#endif
42 38
43#ifdef L_safe_strtol
44int safe_strtol(char *arg, long* value) 39int safe_strtol(char *arg, long* value)
45{ 40{
46 char *endptr; 41 char *endptr;
@@ -55,9 +50,7 @@ int safe_strtol(char *arg, long* value)
55 errno = errno_save; 50 errno = errno_save;
56 return 0; 51 return 0;
57} 52}
58#endif
59 53
60#ifdef L_safe_strtoul
61int safe_strtoul(char *arg, unsigned long* value) 54int safe_strtoul(char *arg, unsigned long* value)
62{ 55{
63 char *endptr; 56 char *endptr;
@@ -72,9 +65,7 @@ int safe_strtoul(char *arg, unsigned long* value)
72 errno = errno_save; 65 errno = errno_save;
73 return 0; 66 return 0;
74} 67}
75#endif
76 68
77#ifdef L_safe_strtoll
78int safe_strtoll(char *arg, long long* value) 69int safe_strtoll(char *arg, long long* value)
79{ 70{
80 char *endptr; 71 char *endptr;
@@ -89,9 +80,7 @@ int safe_strtoll(char *arg, long long* value)
89 errno = errno_save; 80 errno = errno_save;
90 return 0; 81 return 0;
91} 82}
92#endif
93 83
94#ifdef L_safe_strtoull
95int safe_strtoull(char *arg, unsigned long long* value) 84int safe_strtoull(char *arg, unsigned long long* value)
96{ 85{
97 char *endptr; 86 char *endptr;
@@ -106,5 +95,3 @@ int safe_strtoull(char *arg, unsigned long long* value)
106 errno = errno_save; 95 errno = errno_save;
107 return 0; 96 return 0;
108} 97}
109#endif
110
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index f1d4486c3..de765a32d 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -20,7 +20,6 @@
20 * Since dmalloc's prototypes overwrite the impls here as they are 20 * Since dmalloc's prototypes overwrite the impls here as they are
21 * included after these prototypes in libbb.h, all is well. 21 * included after these prototypes in libbb.h, all is well.
22 */ 22 */
23#ifdef L_xmalloc
24// Die if we can't allocate size bytes of memory. 23// Die if we can't allocate size bytes of memory.
25void *xmalloc(size_t size) 24void *xmalloc(size_t size)
26{ 25{
@@ -29,9 +28,7 @@ void *xmalloc(size_t size)
29 bb_error_msg_and_die(bb_msg_memory_exhausted); 28 bb_error_msg_and_die(bb_msg_memory_exhausted);
30 return ptr; 29 return ptr;
31} 30}
32#endif
33 31
34#ifdef L_xrealloc
35// Die if we can't resize previously allocated memory. (This returns a pointer 32// Die if we can't resize previously allocated memory. (This returns a pointer
36// to the new memory, which may or may not be the same as the old memory. 33// to the new memory, which may or may not be the same as the old memory.
37// It'll copy the contents to a new chunk and free the old one if necessary.) 34// It'll copy the contents to a new chunk and free the old one if necessary.)
@@ -42,11 +39,8 @@ void *xrealloc(void *ptr, size_t size)
42 bb_error_msg_and_die(bb_msg_memory_exhausted); 39 bb_error_msg_and_die(bb_msg_memory_exhausted);
43 return ptr; 40 return ptr;
44} 41}
45#endif
46#endif /* DMALLOC */ 42#endif /* DMALLOC */
47 43
48
49#ifdef L_xzalloc
50// Die if we can't allocate and zero size bytes of memory. 44// Die if we can't allocate and zero size bytes of memory.
51void *xzalloc(size_t size) 45void *xzalloc(size_t size)
52{ 46{
@@ -54,9 +48,7 @@ void *xzalloc(size_t size)
54 memset(ptr, 0, size); 48 memset(ptr, 0, size);
55 return ptr; 49 return ptr;
56} 50}
57#endif
58 51
59#ifdef L_xstrdup
60// Die if we can't copy a string to freshly allocated memory. 52// Die if we can't copy a string to freshly allocated memory.
61char * xstrdup(const char *s) 53char * xstrdup(const char *s)
62{ 54{
@@ -72,9 +64,7 @@ char * xstrdup(const char *s)
72 64
73 return t; 65 return t;
74} 66}
75#endif
76 67
77#ifdef L_xstrndup
78// Die if we can't allocate n+1 bytes (space for the null terminator) and copy 68// Die if we can't allocate n+1 bytes (space for the null terminator) and copy
79// the (possibly truncated to length n) string into it. 69// the (possibly truncated to length n) string into it.
80char * xstrndup(const char *s, int n) 70char * xstrndup(const char *s, int n)
@@ -88,9 +78,7 @@ char * xstrndup(const char *s, int n)
88 78
89 return safe_strncpy(t,s,n); 79 return safe_strncpy(t,s,n);
90} 80}
91#endif
92 81
93#ifdef L_xfopen
94// Die if we can't open a file and return a FILE * to it. 82// Die if we can't open a file and return a FILE * to it.
95// Notice we haven't got xfread(), This is for use with fscanf() and friends. 83// Notice we haven't got xfread(), This is for use with fscanf() and friends.
96FILE *xfopen(const char *path, const char *mode) 84FILE *xfopen(const char *path, const char *mode)
@@ -100,9 +88,7 @@ FILE *xfopen(const char *path, const char *mode)
100 bb_perror_msg_and_die("%s", path); 88 bb_perror_msg_and_die("%s", path);
101 return fp; 89 return fp;
102} 90}
103#endif
104 91
105#ifdef L_xopen
106// Die if we can't open an existing file and return an fd. 92// Die if we can't open an existing file and return an fd.
107int xopen(const char *pathname, int flags) 93int xopen(const char *pathname, int flags)
108{ 94{
@@ -111,9 +97,7 @@ int xopen(const char *pathname, int flags)
111 97
112 return xopen3(pathname, flags, 0777); 98 return xopen3(pathname, flags, 0777);
113} 99}
114#endif
115 100
116#ifdef L_xopen3
117// Die if we can't open a new file and return an fd. 101// Die if we can't open a new file and return an fd.
118int xopen3(const char *pathname, int flags, int mode) 102int xopen3(const char *pathname, int flags, int mode)
119{ 103{
@@ -125,9 +109,7 @@ int xopen3(const char *pathname, int flags, int mode)
125 } 109 }
126 return ret; 110 return ret;
127} 111}
128#endif
129 112
130#ifdef L_xread
131// Die with an error message if we can't read the entire buffer. 113// Die with an error message if we can't read the entire buffer.
132void xread(int fd, void *buf, size_t count) 114void xread(int fd, void *buf, size_t count)
133{ 115{
@@ -140,9 +122,7 @@ void xread(int fd, void *buf, size_t count)
140 buf = ((char *) buf) + size; 122 buf = ((char *) buf) + size;
141 } 123 }
142} 124}
143#endif
144 125
145#ifdef L_xwrite
146// Die with an error message if we can't write the entire buffer. 126// Die with an error message if we can't write the entire buffer.
147void xwrite(int fd, void *buf, size_t count) 127void xwrite(int fd, void *buf, size_t count)
148{ 128{
@@ -155,17 +135,13 @@ void xwrite(int fd, void *buf, size_t count)
155 buf = ((char *) buf) + size; 135 buf = ((char *) buf) + size;
156 } 136 }
157} 137}
158#endif
159 138
160#ifdef L_xlseek
161// Die with an error message if we can't lseek to the right spot. 139// Die with an error message if we can't lseek to the right spot.
162void xlseek(int fd, off_t offset, int whence) 140void xlseek(int fd, off_t offset, int whence)
163{ 141{
164 if (offset != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek"); 142 if (offset != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek");
165} 143}
166#endif
167 144
168#ifdef L_xread_char
169// Die with an error message if we can't read one character. 145// Die with an error message if we can't read one character.
170unsigned char xread_char(int fd) 146unsigned char xread_char(int fd)
171{ 147{
@@ -175,9 +151,7 @@ unsigned char xread_char(int fd)
175 151
176 return(tmp); 152 return(tmp);
177} 153}
178#endif
179 154
180#ifdef L_xferror
181// Die with supplied error message if this FILE * has ferror set. 155// Die with supplied error message if this FILE * has ferror set.
182void xferror(FILE *fp, const char *fn) 156void xferror(FILE *fp, const char *fn)
183{ 157{
@@ -185,17 +159,13 @@ void xferror(FILE *fp, const char *fn)
185 bb_error_msg_and_die("%s", fn); 159 bb_error_msg_and_die("%s", fn);
186 } 160 }
187} 161}
188#endif
189 162
190#ifdef L_xferror_stdout
191// Die with an error message if stdout has ferror set. 163// Die with an error message if stdout has ferror set.
192void xferror_stdout(void) 164void xferror_stdout(void)
193{ 165{
194 xferror(stdout, bb_msg_standard_output); 166 xferror(stdout, bb_msg_standard_output);
195} 167}
196#endif
197 168
198#ifdef L_xfflush_stdout
199// Die with an error message if we have trouble flushing stdout. 169// Die with an error message if we have trouble flushing stdout.
200void xfflush_stdout(void) 170void xfflush_stdout(void)
201{ 171{
@@ -203,9 +173,7 @@ void xfflush_stdout(void)
203 bb_perror_msg_and_die(bb_msg_standard_output); 173 bb_perror_msg_and_die(bb_msg_standard_output);
204 } 174 }
205} 175}
206#endif
207 176
208#ifdef L_spawn
209// This does a fork/exec in one call, using vfork(). Return PID of new child, 177// This does a fork/exec in one call, using vfork(). Return PID of new child,
210// -1 for failure. Runs argv[0], searching path if that has no / in it. 178// -1 for failure. Runs argv[0], searching path if that has no / in it.
211pid_t spawn(char **argv) 179pid_t spawn(char **argv)
@@ -230,9 +198,7 @@ pid_t spawn(char **argv)
230 } 198 }
231 return failed ? failed : pid; 199 return failed ? failed : pid;
232} 200}
233#endif
234 201
235#ifdef L_xspawn
236// Die with an error message if we can't spawn a child process. 202// Die with an error message if we can't spawn a child process.
237pid_t xspawn(char **argv) 203pid_t xspawn(char **argv)
238{ 204{
@@ -240,9 +206,7 @@ pid_t xspawn(char **argv)
240 if (pid < 0) bb_perror_msg_and_die("%s", *argv); 206 if (pid < 0) bb_perror_msg_and_die("%s", *argv);
241 return pid; 207 return pid;
242} 208}
243#endif
244 209
245#ifdef L_wait4
246// Wait for the specified child PID to exit, returning child's error return. 210// Wait for the specified child PID to exit, returning child's error return.
247int wait4pid(int pid) 211int wait4pid(int pid)
248{ 212{
@@ -253,17 +217,13 @@ int wait4pid(int pid)
253 if (WIFSIGNALED(status)) return WTERMSIG(status); 217 if (WIFSIGNALED(status)) return WTERMSIG(status);
254 return 0; 218 return 0;
255} 219}
256#endif
257 220
258#ifdef L_xsetenv
259void xsetenv(const char *key, const char *value) 221void xsetenv(const char *key, const char *value)
260{ 222{
261 if(setenv(key, value, 1)) 223 if(setenv(key, value, 1))
262 bb_error_msg_and_die(bb_msg_memory_exhausted); 224 bb_error_msg_and_die(bb_msg_memory_exhausted);
263} 225}
264#endif
265 226
266#ifdef L_itoa
267// Convert unsigned integer to ascii, writing into supplied buffer. A 227// Convert unsigned integer to ascii, writing into supplied buffer. A
268// truncated result is always null terminated (unless buflen is 0), and 228// truncated result is always null terminated (unless buflen is 0), and
269// contains the first few digits of the result ala strncpy. 229// contains the first few digits of the result ala strncpy.
@@ -319,9 +279,7 @@ char *itoa(int n)
319 279
320 return local_buf; 280 return local_buf;
321} 281}
322#endif
323 282
324#ifdef L_setuid
325// Die with an error message if we can't set gid. (Because resource limits may 283// Die with an error message if we can't set gid. (Because resource limits may
326// limit this user to a given number of processes, and if that fills up the 284// limit this user to a given number of processes, and if that fills up the
327// setgid() will fail and we'll _still_be_root_, which is bad.) 285// setgid() will fail and we'll _still_be_root_, which is bad.)
@@ -335,9 +293,7 @@ void xsetuid(uid_t uid)
335{ 293{
336 if (setuid(uid)) bb_error_msg_and_die("setuid"); 294 if (setuid(uid)) bb_error_msg_and_die("setuid");
337} 295}
338#endif
339 296
340#ifdef L_fdlength
341// Return how long the file at fd is, if there's any way to determine it. 297// Return how long the file at fd is, if there's any way to determine it.
342off_t fdlength(int fd) 298off_t fdlength(int fd)
343{ 299{
@@ -375,9 +331,7 @@ off_t fdlength(int fd)
375 331
376 return pos + 1; 332 return pos + 1;
377} 333}
378#endif
379 334
380#ifdef L_xasprintf
381// Die with an error message if we can't malloc() enough space and do an 335// Die with an error message if we can't malloc() enough space and do an
382// sprintf() into that space. 336// sprintf() into that space.
383char *xasprintf(const char *format, ...) 337char *xasprintf(const char *format, ...)
@@ -405,9 +359,7 @@ char *xasprintf(const char *format, ...)
405 if (r < 0) bb_error_msg_and_die(bb_msg_memory_exhausted); 359 if (r < 0) bb_error_msg_and_die(bb_msg_memory_exhausted);
406 return string_ptr; 360 return string_ptr;
407} 361}
408#endif
409 362
410#ifdef L_xprint_and_close_file
411// Die with an error message if we can't copy an entire FILE * to stdout, then 363// Die with an error message if we can't copy an entire FILE * to stdout, then
412// close that file. 364// close that file.
413void xprint_and_close_file(FILE *file) 365void xprint_and_close_file(FILE *file)
@@ -418,18 +370,14 @@ void xprint_and_close_file(FILE *file)
418 370
419 fclose(file); 371 fclose(file);
420} 372}
421#endif
422 373
423#ifdef L_xchdir
424// Die if we can't chdir to a new path. 374// Die if we can't chdir to a new path.
425void xchdir(const char *path) 375void xchdir(const char *path)
426{ 376{
427 if (chdir(path)) 377 if (chdir(path))
428 bb_perror_msg_and_die("chdir(%s)", path); 378 bb_perror_msg_and_die("chdir(%s)", path);
429} 379}
430#endif
431 380
432#ifdef L_warn_opendir
433// Print a warning message if opendir() fails, but don't die. 381// Print a warning message if opendir() fails, but don't die.
434DIR *warn_opendir(const char *path) 382DIR *warn_opendir(const char *path)
435{ 383{
@@ -441,9 +389,7 @@ DIR *warn_opendir(const char *path)
441 } 389 }
442 return dp; 390 return dp;
443} 391}
444#endif
445 392
446#ifdef L_xopendir
447// Die with an error message if opendir() fails. 393// Die with an error message if opendir() fails.
448DIR *xopendir(const char *path) 394DIR *xopendir(const char *path)
449{ 395{
@@ -453,9 +399,7 @@ DIR *xopendir(const char *path)
453 bb_perror_msg_and_die("unable to open `%s'", path); 399 bb_perror_msg_and_die("unable to open `%s'", path);
454 return dp; 400 return dp;
455} 401}
456#endif
457 402
458#ifdef L_xdaemon
459#ifndef BB_NOMMU 403#ifndef BB_NOMMU
460// Die with an error message if we can't daemonize. 404// Die with an error message if we can't daemonize.
461void xdaemon(int nochdir, int noclose) 405void xdaemon(int nochdir, int noclose)
@@ -463,9 +407,7 @@ void xdaemon(int nochdir, int noclose)
463 if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon"); 407 if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon");
464} 408}
465#endif 409#endif
466#endif
467 410
468#ifdef L_xsocket
469// Die with an error message if we can't open a new socket. 411// Die with an error message if we can't open a new socket.
470int xsocket(int domain, int type, int protocol) 412int xsocket(int domain, int type, int protocol)
471{ 413{
@@ -475,34 +417,26 @@ int xsocket(int domain, int type, int protocol)
475 417
476 return r; 418 return r;
477} 419}
478#endif
479 420
480#ifdef L_xbind
481// Die with an error message if we can't bind a socket to an address. 421// Die with an error message if we can't bind a socket to an address.
482void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) 422void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
483{ 423{
484 if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind"); 424 if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind");
485} 425}
486#endif
487 426
488#ifdef L_xlisten
489// Die with an error message if we can't listen for connections on a socket. 427// Die with an error message if we can't listen for connections on a socket.
490void xlisten(int s, int backlog) 428void xlisten(int s, int backlog)
491{ 429{
492 if (listen(s, backlog)) bb_perror_msg_and_die("listen"); 430 if (listen(s, backlog)) bb_perror_msg_and_die("listen");
493} 431}
494#endif
495 432
496#ifdef L_xstat
497// xstat() - a stat() which dies on failure with meaningful error message 433// xstat() - a stat() which dies on failure with meaningful error message
498void xstat(char *name, struct stat *stat_buf) 434void xstat(char *name, struct stat *stat_buf)
499{ 435{
500 if (stat(name, stat_buf)) 436 if (stat(name, stat_buf))
501 bb_perror_msg_and_die("can't stat '%s'", name); 437 bb_perror_msg_and_die("can't stat '%s'", name);
502} 438}
503#endif
504 439
505#ifdef L_get_terminal_width_height
506/* It is perfectly ok to pass in a NULL for either width or for 440/* It is perfectly ok to pass in a NULL for either width or for
507 * * height, in which case that value will not be set. */ 441 * * height, in which case that value will not be set. */
508int get_terminal_width_height(int fd, int *width, int *height) 442int get_terminal_width_height(int fd, int *width, int *height)
@@ -524,4 +458,3 @@ int get_terminal_width_height(int fd, int *width, int *height)
524 458
525 return ret; 459 return ret;
526} 460}
527#endif
diff --git a/libbb/xgetularg.c b/libbb/xgetularg.c
index 21b0d12f7..17ba581f7 100644
--- a/libbb/xgetularg.c
+++ b/libbb/xgetularg.c
@@ -15,7 +15,6 @@
15#include <assert.h> 15#include <assert.h>
16#include "libbb.h" 16#include "libbb.h"
17 17
18#ifdef L_xgetularg_bnd_sfx
19unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base, 18unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base,
20 unsigned long lower, 19 unsigned long lower,
21 unsigned long upper, 20 unsigned long upper,
@@ -75,9 +74,7 @@ unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base,
75 74
76 return r; 75 return r;
77} 76}
78#endif
79 77
80#ifdef L_xgetlarg_bnd_sfx
81long bb_xgetlarg_bnd_sfx(const char *arg, int base, 78long bb_xgetlarg_bnd_sfx(const char *arg, int base,
82 long lower, 79 long lower,
83 long upper, 80 long upper,
@@ -104,36 +101,27 @@ long bb_xgetlarg_bnd_sfx(const char *arg, int base,
104 101
105 return r; 102 return r;
106} 103}
107#endif
108 104
109#ifdef L_getlarg10_sfx
110long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes) 105long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes)
111{ 106{
112 return bb_xgetlarg_bnd_sfx(arg, 10, LONG_MIN, LONG_MAX, suffixes); 107 return bb_xgetlarg_bnd_sfx(arg, 10, LONG_MIN, LONG_MAX, suffixes);
113} 108}
114#endif
115 109
116#ifdef L_xgetularg_bnd
117unsigned long bb_xgetularg_bnd(const char *arg, int base, 110unsigned long bb_xgetularg_bnd(const char *arg, int base,
118 unsigned long lower, 111 unsigned long lower,
119 unsigned long upper) 112 unsigned long upper)
120{ 113{
121 return bb_xgetularg_bnd_sfx(arg, base, lower, upper, NULL); 114 return bb_xgetularg_bnd_sfx(arg, base, lower, upper, NULL);
122} 115}
123#endif
124 116
125#ifdef L_xgetularg10_bnd
126unsigned long bb_xgetularg10_bnd(const char *arg, 117unsigned long bb_xgetularg10_bnd(const char *arg,
127 unsigned long lower, 118 unsigned long lower,
128 unsigned long upper) 119 unsigned long upper)
129{ 120{
130 return bb_xgetularg_bnd(arg, 10, lower, upper); 121 return bb_xgetularg_bnd(arg, 10, lower, upper);
131} 122}
132#endif
133 123
134#ifdef L_xgetularg10
135unsigned long bb_xgetularg10(const char *arg) 124unsigned long bb_xgetularg10(const char *arg)
136{ 125{
137 return bb_xgetularg10_bnd(arg, 0, ULONG_MAX); 126 return bb_xgetularg10_bnd(arg, 0, ULONG_MAX);
138} 127}
139#endif
diff --git a/libpwdgrp/Kbuild b/libpwdgrp/Kbuild
new file mode 100644
index 000000000..36a6ce393
--- /dev/null
+++ b/libpwdgrp/Kbuild
@@ -0,0 +1,7 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=pwd_grp.o
diff --git a/libpwdgrp/Makefile b/libpwdgrp/Makefile
deleted file mode 100644
index 630a7688f..000000000
--- a/libpwdgrp/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/libpwgrp
14LIBPWDGRP_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/libpwdgrp/Makefile.in b/libpwdgrp/Makefile.in
deleted file mode 100644
index 2511d34ef..000000000
--- a/libpwdgrp/Makefile.in
+++ /dev/null
@@ -1,51 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7LIBPWDGRP_AR:=libpwdgrp.a
8ifndef $(LIBPWDGRP_DIR)
9LIBPWDGRP_DIR:=$(top_builddir)/libpwdgrp
10endif
11srcdir=$(top_srcdir)/libpwdgrp
12
13LIBPWDGRP-obj:=$(LIBPWDGRP_DIR)/$(LIBPWDGRP_AR)
14
15libraries-y+=$(LIBPWDGRP_DIR)/$(LIBPWDGRP_AR)
16
17LIBPWDGRP_MSRC0:=$(srcdir)/pwd_grp.c
18LIBPWDGRP_MOBJ0-$(CONFIG_USE_BB_PWD_GRP):= fgetpwent_r.o fgetgrent_r.o \
19 fgetpwent.o fgetgrent.o getpwnam_r.o getgrnam_r.o getpwuid_r.o \
20 getgrgid_r.o getpwuid.o getgrgid.o getpwnam.o getgrnam.o getpw.o \
21 getpwent_r.o getgrent_r.o getpwent.o getgrent.o \
22 initgroups.o putpwent.o putgrent.o
23LIBPWDGRP_MOBJS0=$(patsubst %,$(LIBPWDGRP_DIR)/%, $(LIBPWDGRP_MOBJ0-y))
24
25LIBPWDGRP_MSRC1:=$(srcdir)/pwd_grp.c
26LIBPWDGRP_MOBJ1-$(CONFIG_USE_BB_PWD_GRP):= __parsepwent.o __parsegrent.o \
27 __pgsreader.o fgetspent_r.o fgetspent.o sgetspent_r.o getspnam_r.o \
28 getspnam.o getspent_r.o getspent.o sgetspent.o \
29 putspent.o __parsespent.o # getspuid_r.o getspuid.o
30LIBPWDGRP_MOBJS1=$(patsubst %,$(LIBPWDGRP_DIR)/%, $(LIBPWDGRP_MOBJ1-y))
31
32LIBPWDGRP_DEFINE0-y:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(LIBPWDGRP_MOBJS0))))
33LIBPWDGRP_DEFINE1-y:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(LIBPWDGRP_MOBJS1))))
34
35LIBPWDGRP_SRC-y:=$(LIBPWDGRP_MSRC0)
36
37LIBRARY_SRC-y+=$(LIBPWDGRP_SRC-y)
38LIBRARY_SRC-a+=$(LIBPWDGRP_SRC-y)
39
40LIBRARY_DEFINE-y+=$(LIBPWDGRP_DEFINE0-y) $(LIBPWDGRP_DEFINE1-y)
41LIBRARY_DEFINE-a+=$(LIBPWDGRP_DEFINE0-y) $(LIBPWDGRP_DEFINE1-y)
42
43
44$(LIBPWDGRP_DIR)/$(LIBPWDGRP_AR): $(LIBPWDGRP_MOBJS0) $(LIBPWDGRP_MOBJS1)
45 $(do_ar)
46
47$(LIBPWDGRP_MOBJS0): $(LIBPWDGRP_MSRC0)
48 $(compile.c) -DL_$(notdir $*)
49
50$(LIBPWDGRP_MOBJS1): $(LIBPWDGRP_MSRC1)
51 $(compile.c) -DL_$(notdir $*)
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c
index 132ec60be..ac65d4c5b 100644
--- a/libpwdgrp/pwd_grp.c
+++ b/libpwdgrp/pwd_grp.c
@@ -29,8 +29,6 @@
29#include <assert.h> 29#include <assert.h>
30#include <ctype.h> 30#include <ctype.h>
31 31
32#include "shadow_.h"
33
34#ifndef _PATH_SHADOW 32#ifndef _PATH_SHADOW
35#define _PATH_SHADOW "/etc/shadow" 33#define _PATH_SHADOW "/etc/shadow"
36#endif 34#endif
@@ -57,7 +55,7 @@ extern int __parsegrent(void *gr, char *line);
57extern int __parsespent(void *sp, char *line); 55extern int __parsespent(void *sp, char *line);
58 56
59extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, 57extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,
60 char *__restrict line_buff, size_t buflen, FILE *f); 58 char *__restrict line_buff, size_t buflen, FILE *f);
61 59
62/**********************************************************************/ 60/**********************************************************************/
63/* For the various fget??ent_r funcs, return 61/* For the various fget??ent_r funcs, return
@@ -75,8 +73,6 @@ extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,
75 */ 73 */
76/**********************************************************************/ 74/**********************************************************************/
77 75
78#ifdef L_fgetpwent_r
79
80int fgetpwent_r(FILE *__restrict stream, struct passwd *__restrict resultbuf, 76int fgetpwent_r(FILE *__restrict stream, struct passwd *__restrict resultbuf,
81 char *__restrict buffer, size_t buflen, 77 char *__restrict buffer, size_t buflen,
82 struct passwd **__restrict result) 78 struct passwd **__restrict result)
@@ -92,10 +88,6 @@ int fgetpwent_r(FILE *__restrict stream, struct passwd *__restrict resultbuf,
92 return rv; 88 return rv;
93} 89}
94 90
95#endif
96/**********************************************************************/
97#ifdef L_fgetgrent_r
98
99int fgetgrent_r(FILE *__restrict stream, struct group *__restrict resultbuf, 91int fgetgrent_r(FILE *__restrict stream, struct group *__restrict resultbuf,
100 char *__restrict buffer, size_t buflen, 92 char *__restrict buffer, size_t buflen,
101 struct group **__restrict result) 93 struct group **__restrict result)
@@ -111,10 +103,6 @@ int fgetgrent_r(FILE *__restrict stream, struct group *__restrict resultbuf,
111 return rv; 103 return rv;
112} 104}
113 105
114#endif
115/**********************************************************************/
116#ifdef L_fgetspent_r
117
118int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf, 106int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
119 char *__restrict buffer, size_t buflen, 107 char *__restrict buffer, size_t buflen,
120 struct spwd **__restrict result) 108 struct spwd **__restrict result)
@@ -130,13 +118,11 @@ int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
130 return rv; 118 return rv;
131} 119}
132 120
133#endif
134/**********************************************************************/ 121/**********************************************************************/
135/* For the various fget??ent funcs, return NULL on failure and a 122/* For the various fget??ent funcs, return NULL on failure and a
136 * pointer to the appropriate struct (statically allocated) on success. 123 * pointer to the appropriate struct (statically allocated) on success.
137 */ 124 */
138/**********************************************************************/ 125/**********************************************************************/
139#ifdef L_fgetpwent
140 126
141struct passwd *fgetpwent(FILE *stream) 127struct passwd *fgetpwent(FILE *stream)
142{ 128{
@@ -148,10 +134,6 @@ struct passwd *fgetpwent(FILE *stream)
148 return result; 134 return result;
149} 135}
150 136
151#endif
152/**********************************************************************/
153#ifdef L_fgetgrent
154
155struct group *fgetgrent(FILE *stream) 137struct group *fgetgrent(FILE *stream)
156{ 138{
157 static char buffer[GRP_BUFFER_SIZE]; 139 static char buffer[GRP_BUFFER_SIZE];
@@ -162,10 +144,6 @@ struct group *fgetgrent(FILE *stream)
162 return result; 144 return result;
163} 145}
164 146
165#endif
166/**********************************************************************/
167#ifdef L_fgetspent
168
169extern int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf, 147extern int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
170 char *__restrict buffer, size_t buflen, 148 char *__restrict buffer, size_t buflen,
171 struct spwd **__restrict result); 149 struct spwd **__restrict result);
@@ -179,10 +157,6 @@ struct spwd *fgetspent(FILE *stream)
179 return result; 157 return result;
180} 158}
181 159
182#endif
183/**********************************************************************/
184#ifdef L_sgetspent_r
185
186int sgetspent_r(const char *string, struct spwd *result_buf, 160int sgetspent_r(const char *string, struct spwd *result_buf,
187 char *buffer, size_t buflen, struct spwd **result) 161 char *buffer, size_t buflen, struct spwd **result)
188{ 162{
@@ -211,65 +185,53 @@ int sgetspent_r(const char *string, struct spwd *result_buf,
211 return rv; 185 return rv;
212} 186}
213 187
214#endif
215/**********************************************************************/ 188/**********************************************************************/
216 189
217#ifdef GETXXKEY_R_FUNC 190#ifdef GETXXKEY_R_FUNC
218#error GETXXKEY_R_FUNC is already defined! 191#error GETXXKEY_R_FUNC is already defined!
219#endif 192#endif
220 193
221#ifdef L_getpwnam_r 194#define GETXXKEY_R_FUNC getpwnam_R
222#define GETXXKEY_R_FUNC getpwnam_r
223#define GETXXKEY_R_PARSER __parsepwent 195#define GETXXKEY_R_PARSER __parsepwent
224#define GETXXKEY_R_ENTTYPE struct passwd 196#define GETXXKEY_R_ENTTYPE struct passwd
225#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key)) 197#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key))
226#define DO_GETXXKEY_R_KEYTYPE const char *__restrict 198#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
227#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD 199#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD
228#include "pwd_grp_internal.c" 200#include "pwd_grp_internal.c"
229#endif
230 201
231#ifdef L_getgrnam_r 202#define GETXXKEY_R_FUNC getgrnam_R
232#define GETXXKEY_R_FUNC getgrnam_r
233#define GETXXKEY_R_PARSER __parsegrent 203#define GETXXKEY_R_PARSER __parsegrent
234#define GETXXKEY_R_ENTTYPE struct group 204#define GETXXKEY_R_ENTTYPE struct group
235#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key)) 205#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key))
236#define DO_GETXXKEY_R_KEYTYPE const char *__restrict 206#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
237#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP 207#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP
238#include "pwd_grp_internal.c" 208#include "pwd_grp_internal.c"
239#endif
240 209
241#ifdef L_getspnam_r 210#define GETXXKEY_R_FUNC getspnam_R
242#define GETXXKEY_R_FUNC getspnam_r
243#define GETXXKEY_R_PARSER __parsespent 211#define GETXXKEY_R_PARSER __parsespent
244#define GETXXKEY_R_ENTTYPE struct spwd 212#define GETXXKEY_R_ENTTYPE struct spwd
245#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key)) 213#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key))
246#define DO_GETXXKEY_R_KEYTYPE const char *__restrict 214#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
247#define DO_GETXXKEY_R_PATHNAME _PATH_SHADOW 215#define DO_GETXXKEY_R_PATHNAME _PATH_SHADOW
248#include "pwd_grp_internal.c" 216#include "pwd_grp_internal.c"
249#endif
250 217
251#ifdef L_getpwuid_r 218#define GETXXKEY_R_FUNC getpwuid_R
252#define GETXXKEY_R_FUNC getpwuid_r
253#define GETXXKEY_R_PARSER __parsepwent 219#define GETXXKEY_R_PARSER __parsepwent
254#define GETXXKEY_R_ENTTYPE struct passwd 220#define GETXXKEY_R_ENTTYPE struct passwd
255#define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key) 221#define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key)
256#define DO_GETXXKEY_R_KEYTYPE uid_t 222#define DO_GETXXKEY_R_KEYTYPE uid_t
257#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD 223#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD
258#include "pwd_grp_internal.c" 224#include "pwd_grp_internal.c"
259#endif
260 225
261#ifdef L_getgrgid_r 226#define GETXXKEY_R_FUNC getgrgid_R
262#define GETXXKEY_R_FUNC getgrgid_r
263#define GETXXKEY_R_PARSER __parsegrent 227#define GETXXKEY_R_PARSER __parsegrent
264#define GETXXKEY_R_ENTTYPE struct group 228#define GETXXKEY_R_ENTTYPE struct group
265#define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key) 229#define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key)
266#define DO_GETXXKEY_R_KEYTYPE gid_t 230#define DO_GETXXKEY_R_KEYTYPE gid_t
267#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP 231#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP
268#include "pwd_grp_internal.c" 232#include "pwd_grp_internal.c"
269#endif
270 233
271/**********************************************************************/ 234/**********************************************************************/
272#ifdef L_getpwuid
273 235
274struct passwd *getpwuid(uid_t uid) 236struct passwd *getpwuid(uid_t uid)
275{ 237{
@@ -281,10 +243,6 @@ struct passwd *getpwuid(uid_t uid)
281 return result; 243 return result;
282} 244}
283 245
284#endif
285/**********************************************************************/
286#ifdef L_getgrgid
287
288struct group *getgrgid(gid_t gid) 246struct group *getgrgid(gid_t gid)
289{ 247{
290 static char buffer[GRP_BUFFER_SIZE]; 248 static char buffer[GRP_BUFFER_SIZE];
@@ -295,10 +253,6 @@ struct group *getgrgid(gid_t gid)
295 return result; 253 return result;
296} 254}
297 255
298#endif
299/**********************************************************************/
300#ifdef L_getspuid_r
301
302/* This function is non-standard and is currently not built. It seems 256/* This function is non-standard and is currently not built. It seems
303 * to have been created as a reentrant version of the non-standard 257 * to have been created as a reentrant version of the non-standard
304 * functions getspuid. Why getspuid was added, I do not know. */ 258 * functions getspuid. Why getspuid was added, I do not know. */
@@ -320,10 +274,6 @@ int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
320 return rv; 274 return rv;
321} 275}
322 276
323#endif
324/**********************************************************************/
325#ifdef L_getspuid
326
327/* This function is non-standard and is currently not built. 277/* This function is non-standard and is currently not built.
328 * Why it was added, I do not know. */ 278 * Why it was added, I do not know. */
329 279
@@ -337,10 +287,6 @@ struct spwd *getspuid(uid_t uid)
337 return result; 287 return result;
338} 288}
339 289
340#endif
341/**********************************************************************/
342#ifdef L_getpwnam
343
344struct passwd *getpwnam(const char *name) 290struct passwd *getpwnam(const char *name)
345{ 291{
346 static char buffer[PWD_BUFFER_SIZE]; 292 static char buffer[PWD_BUFFER_SIZE];
@@ -351,10 +297,6 @@ struct passwd *getpwnam(const char *name)
351 return result; 297 return result;
352} 298}
353 299
354#endif
355/**********************************************************************/
356#ifdef L_getgrnam
357
358struct group *getgrnam(const char *name) 300struct group *getgrnam(const char *name)
359{ 301{
360 static char buffer[GRP_BUFFER_SIZE]; 302 static char buffer[GRP_BUFFER_SIZE];
@@ -365,10 +307,6 @@ struct group *getgrnam(const char *name)
365 return result; 307 return result;
366} 308}
367 309
368#endif
369/**********************************************************************/
370#ifdef L_getspnam
371
372struct spwd *getspnam(const char *name) 310struct spwd *getspnam(const char *name)
373{ 311{
374 static char buffer[PWD_BUFFER_SIZE]; 312 static char buffer[PWD_BUFFER_SIZE];
@@ -379,10 +317,6 @@ struct spwd *getspnam(const char *name)
379 return result; 317 return result;
380} 318}
381 319
382#endif
383/**********************************************************************/
384#ifdef L_getpw
385
386int getpw(uid_t uid, char *buf) 320int getpw(uid_t uid, char *buf)
387{ 321{
388 struct passwd resultbuf; 322 struct passwd resultbuf;
@@ -406,10 +340,8 @@ int getpw(uid_t uid, char *buf)
406 return -1; 340 return -1;
407} 341}
408 342
409#endif
410/**********************************************************************/ 343/**********************************************************************/
411 344
412#if defined(L_getpwent_r) || defined(L_getgrent_r) || defined(L_getspent_r)
413#if defined CONFIG_USE_BB_THREADSAFE_SHADOW && defined PTHREAD_MUTEX_INITIALIZER 345#if defined CONFIG_USE_BB_THREADSAFE_SHADOW && defined PTHREAD_MUTEX_INITIALIZER
414static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; 346static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
415# define LOCK pthread_mutex_lock(&mylock) 347# define LOCK pthread_mutex_lock(&mylock)
@@ -418,9 +350,7 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
418# define LOCK ((void) 0) 350# define LOCK ((void) 0)
419# define UNLOCK ((void) 0) 351# define UNLOCK ((void) 0)
420#endif 352#endif
421#endif
422 353
423#ifdef L_getpwent_r
424static FILE *pwf /*= NULL*/; 354static FILE *pwf /*= NULL*/;
425void setpwent(void) 355void setpwent(void)
426{ 356{
@@ -468,10 +398,6 @@ int getpwent_r(struct passwd *__restrict resultbuf,
468 return rv; 398 return rv;
469} 399}
470 400
471#endif
472/**********************************************************************/
473#ifdef L_getgrent_r
474
475static FILE *grf /*= NULL*/; 401static FILE *grf /*= NULL*/;
476void setgrent(void) 402void setgrent(void)
477{ 403{
@@ -518,10 +444,6 @@ int getgrent_r(struct group *__restrict resultbuf,
518 return rv; 444 return rv;
519} 445}
520 446
521#endif
522/**********************************************************************/
523#ifdef L_getspent_r
524
525static FILE *spf /*= NULL*/; 447static FILE *spf /*= NULL*/;
526void setspent(void) 448void setspent(void)
527{ 449{
@@ -567,10 +489,6 @@ int getspent_r(struct spwd *resultbuf, char *buffer,
567 return rv; 489 return rv;
568} 490}
569 491
570#endif
571/**********************************************************************/
572#ifdef L_getpwent
573
574struct passwd *getpwent(void) 492struct passwd *getpwent(void)
575{ 493{
576 static char line_buff[PWD_BUFFER_SIZE]; 494 static char line_buff[PWD_BUFFER_SIZE];
@@ -581,10 +499,6 @@ struct passwd *getpwent(void)
581 return result; 499 return result;
582} 500}
583 501
584#endif
585/**********************************************************************/
586#ifdef L_getgrent
587
588struct group *getgrent(void) 502struct group *getgrent(void)
589{ 503{
590 static char line_buff[GRP_BUFFER_SIZE]; 504 static char line_buff[GRP_BUFFER_SIZE];
@@ -595,10 +509,6 @@ struct group *getgrent(void)
595 return result; 509 return result;
596} 510}
597 511
598#endif
599/**********************************************************************/
600#ifdef L_getspent
601
602struct spwd *getspent(void) 512struct spwd *getspent(void)
603{ 513{
604 static char line_buff[PWD_BUFFER_SIZE]; 514 static char line_buff[PWD_BUFFER_SIZE];
@@ -609,10 +519,6 @@ struct spwd *getspent(void)
609 return result; 519 return result;
610} 520}
611 521
612#endif
613/**********************************************************************/
614#ifdef L_sgetspent
615
616struct spwd *sgetspent(const char *string) 522struct spwd *sgetspent(const char *string)
617{ 523{
618 static char line_buff[PWD_BUFFER_SIZE]; 524 static char line_buff[PWD_BUFFER_SIZE];
@@ -623,10 +529,6 @@ struct spwd *sgetspent(const char *string)
623 return result; 529 return result;
624} 530}
625 531
626#endif
627/**********************************************************************/
628#ifdef L_initgroups
629
630int initgroups(const char *user, gid_t gid) 532int initgroups(const char *user, gid_t gid)
631{ 533{
632 FILE *grfile; 534 FILE *grfile;
@@ -679,10 +581,6 @@ int initgroups(const char *user, gid_t gid)
679 return rv; 581 return rv;
680} 582}
681 583
682#endif
683/**********************************************************************/
684#ifdef L_putpwent
685
686int putpwent(const struct passwd *__restrict p, FILE *__restrict f) 584int putpwent(const struct passwd *__restrict p, FILE *__restrict f)
687{ 585{
688 int rv = -1; 586 int rv = -1;
@@ -704,10 +602,6 @@ int putpwent(const struct passwd *__restrict p, FILE *__restrict f)
704 return rv; 602 return rv;
705} 603}
706 604
707#endif
708/**********************************************************************/
709#ifdef L_putgrent
710
711int putgrent(const struct group *__restrict p, FILE *__restrict f) 605int putgrent(const struct group *__restrict p, FILE *__restrict f)
712{ 606{
713 static const char format[] = ",%s"; 607 static const char format[] = ",%s";
@@ -749,10 +643,6 @@ int putgrent(const struct group *__restrict p, FILE *__restrict f)
749 return rv; 643 return rv;
750} 644}
751 645
752#endif
753/**********************************************************************/
754#ifdef L_putspent
755
756static const unsigned char _sp_off[] = { 646static const unsigned char _sp_off[] = {
757 offsetof(struct spwd, sp_lstchg), /* 2 - not a char ptr */ 647 offsetof(struct spwd, sp_lstchg), /* 2 - not a char ptr */
758 offsetof(struct spwd, sp_min), /* 3 - not a char ptr */ 648 offsetof(struct spwd, sp_min), /* 3 - not a char ptr */
@@ -799,11 +689,9 @@ DO_UNLOCK:
799 return rv; 689 return rv;
800} 690}
801 691
802#endif
803/**********************************************************************/ 692/**********************************************************************/
804/* Internal uClibc functions. */ 693/* Internal uClibc functions. */
805/**********************************************************************/ 694/**********************************************************************/
806#ifdef L___parsepwent
807 695
808static const unsigned char pw_off[] = { 696static const unsigned char pw_off[] = {
809 offsetof(struct passwd, pw_name), /* 0 */ 697 offsetof(struct passwd, pw_name), /* 0 */
@@ -860,9 +748,7 @@ int __parsepwent(void *data, char *line)
860 return -1; 748 return -1;
861} 749}
862 750
863#endif
864/**********************************************************************/ 751/**********************************************************************/
865#ifdef L___parsegrent
866 752
867static const unsigned char gr_off[] = { 753static const unsigned char gr_off[] = {
868 offsetof(struct group, gr_name), /* 0 */ 754 offsetof(struct group, gr_name), /* 0 */
@@ -958,9 +844,7 @@ int __parsegrent(void *data, char *line)
958 return -1; 844 return -1;
959} 845}
960 846
961#endif
962/**********************************************************************/ 847/**********************************************************************/
963#ifdef L___parsespent
964 848
965static const unsigned char sp_off[] = { 849static const unsigned char sp_off[] = {
966 offsetof(struct spwd, sp_namp), /* 0 */ 850 offsetof(struct spwd, sp_namp), /* 0 */
@@ -1017,9 +901,7 @@ int __parsespent(void *data, char * line)
1017 return EINVAL; 901 return EINVAL;
1018} 902}
1019 903
1020#endif
1021/**********************************************************************/ 904/**********************************************************************/
1022#ifdef L___pgsreader
1023 905
1024/* Reads until if EOF, or until if finds a line which fits in the buffer 906/* Reads until if EOF, or until if finds a line which fits in the buffer
1025 * and for which the parser function succeeds. 907 * and for which the parser function succeeds.
@@ -1084,5 +966,4 @@ int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,
1084 return rv; 966 return rv;
1085} 967}
1086 968
1087#endif
1088/**********************************************************************/ 969/**********************************************************************/
diff --git a/libpwdgrp/pwd_grp_internal.c b/libpwdgrp/pwd_grp_internal.c
index 39c11f677..866ed3699 100644
--- a/libpwdgrp/pwd_grp_internal.c
+++ b/libpwdgrp/pwd_grp_internal.c
@@ -18,96 +18,45 @@
18 * 18 *
19 */ 19 */
20 20
21#include <features.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <stdint.h>
25#include <string.h>
26#include <stddef.h>
27#include <errno.h>
28#include <assert.h>
29#include <ctype.h>
30
31#include "pwd_.h"
32#include "grp_.h"
33#include "shadow_.h"
34#include "libbb.h"
35
36#ifndef _PATH_SHADOW
37#define _PATH_SHADOW "/etc/shadow"
38#endif
39#ifndef _PATH_PASSWD
40#define _PATH_PASSWD "/etc/passwd"
41#endif
42#ifndef _PATH_GROUP
43#define _PATH_GROUP "/etc/group"
44#endif
45
46/**********************************************************************/
47/* Sizes for statically allocated buffers. */
48
49/* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
50 * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
51#define PWD_BUFFER_SIZE 256
52#define GRP_BUFFER_SIZE 256
53
54/**********************************************************************/
55/* Prototypes for internal functions. */
56
57extern int __parsepwent(void *pw, char *line);
58extern int __parsegrent(void *gr, char *line);
59extern int __parsespent(void *sp, char *line);
60
61extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,
62 char *__restrict line_buff, size_t buflen, FILE *f);
63
64
65#ifndef GETXXKEY_R_FUNC 21#ifndef GETXXKEY_R_FUNC
66#error GETXXKEY_R_FUNC is not defined! 22#error GETXXKEY_R_FUNC is not defined!
67#endif 23#endif
68/**********************************************************************/
69#ifdef GETXXKEY_R_FUNC
70 24
71int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key, 25int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
72 GETXXKEY_R_ENTTYPE *__restrict resultbuf, 26 GETXXKEY_R_ENTTYPE *__restrict resultbuf,
73 char *__restrict buffer, size_t buflen, 27 char *__restrict buffer, size_t buflen,
74 GETXXKEY_R_ENTTYPE **__restrict result) 28 GETXXKEY_R_ENTTYPE **__restrict result)
75{ 29{
76 FILE *stream; 30 FILE *stream;
77 int rv; 31 int rv;
78 32
79 *result = NULL; 33 *result = NULL;
80 34
81 if (!(stream = fopen(DO_GETXXKEY_R_PATHNAME, "r"))) { 35 stream = fopen(DO_GETXXKEY_R_PATHNAME, "r");
82 rv = errno; 36 if (!stream)
83 } else { 37 return errno;
84 do { 38 while (1) {
85 if (!(rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf, 39 rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf, buffer, buflen, stream);
86 buffer, buflen, stream)) 40 if (!rv) {
87 ) { 41 if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */
88 if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */ 42 *result = resultbuf;
89 *result = resultbuf;
90 break;
91 }
92 } else {
93 if (rv == ENOENT) { /* end-of-file encountered. */
94 rv = 0;
95 }
96 break; 43 break;
97 } 44 }
98 } while (1); 45 } else {
99 fclose(stream); 46 if (rv == ENOENT) { /* end-of-file encountered. */
47 rv = 0;
48 }
49 break;
50 }
100 } 51 }
52 fclose(stream);
101 53
102 return rv; 54 return rv;
103} 55}
104 56
105#endif
106/**********************************************************************/
107#undef GETXXKEY_R_FUNC 57#undef GETXXKEY_R_FUNC
108#undef GETXXKEY_R_PARSER 58#undef GETXXKEY_R_PARSER
109#undef GETXXKEY_R_ENTTYPE 59#undef GETXXKEY_R_ENTTYPE
110#undef GETXXKEY_R_TEST 60#undef GETXXKEY_R_TEST
111#undef DO_GETXXKEY_R_KEYTYPE 61#undef DO_GETXXKEY_R_KEYTYPE
112#undef DO_GETXXKEY_R_PATHNAME 62#undef DO_GETXXKEY_R_PATHNAME
113
diff --git a/loginutils/Config.in b/loginutils/Config.in
index 6e45b706a..f434585ef 100644
--- a/loginutils/Config.in
+++ b/loginutils/Config.in
@@ -5,7 +5,7 @@
5 5
6menu "Login/Password Management Utilities" 6menu "Login/Password Management Utilities"
7 7
8config CONFIG_FEATURE_SHADOWPASSWDS 8config FEATURE_SHADOWPASSWDS
9 bool "Support for shadow passwords" 9 bool "Support for shadow passwords"
10 default n 10 default n
11 help 11 help
@@ -13,10 +13,10 @@ config CONFIG_FEATURE_SHADOWPASSWDS
13 readable by root and thus the encrypted passwords are no longer 13 readable by root and thus the encrypted passwords are no longer
14 publicly readable. 14 publicly readable.
15 15
16config CONFIG_USE_BB_SHADOW 16config USE_BB_SHADOW
17 bool " Use busybox shadow password functions" 17 bool " Use busybox shadow password functions"
18 default y 18 default y
19 depends on CONFIG_USE_BB_PWD_GRP && CONFIG_FEATURE_SHADOWPASSWDS 19 depends on USE_BB_PWD_GRP && FEATURE_SHADOWPASSWDS
20 help 20 help
21 If you leave this disabled, busybox will use the system's shadow 21 If you leave this disabled, busybox will use the system's shadow
22 password handling functions. And if you are using the GNU C library 22 password handling functions. And if you are using the GNU C library
@@ -32,7 +32,7 @@ config CONFIG_USE_BB_SHADOW
32 able to use PAM to access shadow passwords from remote LDAP 32 able to use PAM to access shadow passwords from remote LDAP
33 password servers and whatnot. 33 password servers and whatnot.
34 34
35config CONFIG_USE_BB_PWD_GRP 35config USE_BB_PWD_GRP
36 bool "Use internal password and group functions rather than system functions" 36 bool "Use internal password and group functions rather than system functions"
37 default n 37 default n
38 help 38 help
@@ -53,86 +53,86 @@ config CONFIG_USE_BB_PWD_GRP
53 53
54 If you enable this option, it will add about 1.5k to busybox. 54 If you enable this option, it will add about 1.5k to busybox.
55 55
56config CONFIG_ADDGROUP 56config ADDGROUP
57 bool "addgroup" 57 bool "addgroup"
58 default n 58 default n
59 help 59 help
60 Utility for creating a new group account. 60 Utility for creating a new group account.
61 61
62config CONFIG_DELGROUP 62config DELGROUP
63 bool "delgroup" 63 bool "delgroup"
64 default n 64 default n
65 help 65 help
66 Utility for deleting a group account. 66 Utility for deleting a group account.
67 67
68config CONFIG_ADDUSER 68config ADDUSER
69 bool "adduser" 69 bool "adduser"
70 default n 70 default n
71 help 71 help
72 Utility for creating a new user account. 72 Utility for creating a new user account.
73 73
74config CONFIG_DELUSER 74config DELUSER
75 bool "deluser" 75 bool "deluser"
76 default n 76 default n
77 help 77 help
78 Utility for deleting a user account. 78 Utility for deleting a user account.
79 79
80config CONFIG_GETTY 80config GETTY
81 bool "getty" 81 bool "getty"
82 default n 82 default n
83 select CONFIG_FEATURE_SYSLOG 83 select FEATURE_SYSLOG
84 help 84 help
85 getty lets you log in on a tty, it is normally invoked by init. 85 getty lets you log in on a tty, it is normally invoked by init.
86 86
87config CONFIG_FEATURE_UTMP 87config FEATURE_UTMP
88 bool "Support utmp file" 88 bool "Support utmp file"
89 depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_WHO 89 depends on GETTY || LOGIN || SU || WHO
90 default n 90 default n
91 help 91 help
92 The file /var/run/utmp is used to track who is currently logged in. 92 The file /var/run/utmp is used to track who is currently logged in.
93 93
94config CONFIG_FEATURE_WTMP 94config FEATURE_WTMP
95 bool "Support wtmp file" 95 bool "Support wtmp file"
96 depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_LAST 96 depends on GETTY || LOGIN || SU || LAST
97 default n 97 default n
98 select CONFIG_FEATURE_UTMP 98 select FEATURE_UTMP
99 help 99 help
100 The file /var/run/wtmp is used to track when user's have logged into 100 The file /var/run/wtmp is used to track when user's have logged into
101 and logged out of the system. 101 and logged out of the system.
102 102
103config CONFIG_LOGIN 103config LOGIN
104 bool "login" 104 bool "login"
105 default n 105 default n
106 select CONFIG_FEATURE_SUID 106 select FEATURE_SUID
107 select CONFIG_FEATURE_SYSLOG 107 select FEATURE_SYSLOG
108 help 108 help
109 login is used when signing onto a system. 109 login is used when signing onto a system.
110 110
111 Note that Busybox binary must be setuid root for this applet to 111 Note that Busybox binary must be setuid root for this applet to
112 work properly. 112 work properly.
113 113
114config CONFIG_LOGIN_SCRIPTS 114config LOGIN_SCRIPTS
115 bool "Support for login scripts" 115 bool "Support for login scripts"
116 depends on CONFIG_LOGIN 116 depends on LOGIN
117 default n 117 default n
118 help 118 help
119 Enable this if you want login to execute $LOGIN_PRE_SUID_SCRIPT 119 Enable this if you want login to execute $LOGIN_PRE_SUID_SCRIPT
120 just prior to swithching from root to logged-in user. 120 just prior to swithching from root to logged-in user.
121 121
122config CONFIG_FEATURE_SECURETTY 122config FEATURE_SECURETTY
123 bool "Support for /etc/securetty" 123 bool "Support for /etc/securetty"
124 default y 124 default y
125 depends on CONFIG_LOGIN 125 depends on LOGIN
126 help 126 help
127 The file /etc/securetty is used by (some versions of) login(1). 127 The file /etc/securetty is used by (some versions of) login(1).
128 The file contains the device names of tty lines (one per line, 128 The file contains the device names of tty lines (one per line,
129 without leading /dev/) on which root is allowed to login. 129 without leading /dev/) on which root is allowed to login.
130 130
131config CONFIG_PASSWD 131config PASSWD
132 bool "passwd" 132 bool "passwd"
133 default n 133 default n
134 select CONFIG_FEATURE_SUID 134 select FEATURE_SUID
135 select CONFIG_FEATURE_SYSLOG 135 select FEATURE_SYSLOG
136 help 136 help
137 passwd changes passwords for user and group accounts. A normal user 137 passwd changes passwords for user and group accounts. A normal user
138 may only change the password for his/her own account, the super user 138 may only change the password for his/her own account, the super user
@@ -142,11 +142,11 @@ config CONFIG_PASSWD
142 Note that Busybox binary must be setuid root for this applet to 142 Note that Busybox binary must be setuid root for this applet to
143 work properly. 143 work properly.
144 144
145config CONFIG_SU 145config SU
146 bool "su" 146 bool "su"
147 default n 147 default n
148 select CONFIG_FEATURE_SUID 148 select FEATURE_SUID
149 select CONFIG_FEATURE_SYSLOG 149 select FEATURE_SYSLOG
150 help 150 help
151 su is used to become another user during a login session. 151 su is used to become another user during a login session.
152 Invoked without a username, su defaults to becoming the super user. 152 Invoked without a username, su defaults to becoming the super user.
@@ -154,25 +154,25 @@ config CONFIG_SU
154 Note that Busybox binary must be setuid root for this applet to 154 Note that Busybox binary must be setuid root for this applet to
155 work properly. 155 work properly.
156 156
157config CONFIG_SU_SYSLOG 157config SU_SYSLOG
158 bool "Support for syslog in su" 158 bool "Support for syslog in su"
159 default y 159 default y
160 depends on CONFIG_SU 160 depends on SU
161 help 161 help
162 Enables support for syslog in su. 162 Enables support for syslog in su.
163 163
164config CONFIG_SULOGIN 164config SULOGIN
165 bool "sulogin" 165 bool "sulogin"
166 default n 166 default n
167 select CONFIG_FEATURE_SYSLOG 167 select FEATURE_SYSLOG
168 help 168 help
169 sulogin is invoked when the system goes into single user 169 sulogin is invoked when the system goes into single user
170 mode (this is done through an entry in inittab). 170 mode (this is done through an entry in inittab).
171 171
172config CONFIG_VLOCK 172config VLOCK
173 bool "vlock" 173 bool "vlock"
174 default n 174 default n
175 select CONFIG_FEATURE_SUID 175 select FEATURE_SUID
176 help 176 help
177 Build the "vlock" applet which allows you to lock (virtual) terminals. 177 Build the "vlock" applet which allows you to lock (virtual) terminals.
178 178
diff --git a/loginutils/Kbuild b/loginutils/Kbuild
new file mode 100644
index 000000000..6c9d193e1
--- /dev/null
+++ b/loginutils/Kbuild
@@ -0,0 +1,17 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_ADDGROUP) += addgroup.o
9lib-$(CONFIG_ADDUSER) += adduser.o
10lib-$(CONFIG_GETTY) += getty.o
11lib-$(CONFIG_LOGIN) += login.o
12lib-$(CONFIG_PASSWD) += passwd.o
13lib-$(CONFIG_SU) += su.o
14lib-$(CONFIG_SULOGIN) += sulogin.o
15lib-$(CONFIG_VLOCK) += vlock.o
16lib-$(CONFIG_DELUSER) += deluser.o
17lib-$(CONFIG_DELGROUP) += deluser.o
diff --git a/loginutils/Makefile b/loginutils/Makefile
deleted file mode 100644
index b81f42964..000000000
--- a/loginutils/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/loginutils
14LOGINUTILS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/loginutils/Makefile.in b/loginutils/Makefile.in
deleted file mode 100644
index 0063762ab..000000000
--- a/loginutils/Makefile.in
+++ /dev/null
@@ -1,52 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7LOGINUTILS_AR:=loginutils.a
8ifndef LOGINUTILS_DIR
9LOGINUTILS_DIR:=$(top_builddir)/loginutils/
10endif
11srcdir=$(top_srcdir)/loginutils
12
13LOGINUTILS-y:=
14LOGINUTILS-$(CONFIG_ADDGROUP) += addgroup.o
15LOGINUTILS-$(CONFIG_ADDUSER) += adduser.o
16LOGINUTILS-$(CONFIG_GETTY) += getty.o
17LOGINUTILS-$(CONFIG_LOGIN) += login.o
18LOGINUTILS-$(CONFIG_PASSWD) += passwd.o
19LOGINUTILS-$(CONFIG_SU) += su.o
20LOGINUTILS-$(CONFIG_SULOGIN) += sulogin.o
21LOGINUTILS-$(CONFIG_VLOCK) += vlock.o
22LOGINUTILS-$(CONFIG_DELUSER) += deluser.o
23LOGINUTILS-$(CONFIG_DELGROUP) += deluser.o
24
25LOGINUTILS-y:=$(sort $(LOGINUTILS-y))
26
27ifneq ($(strip $(LOGINUTILS-y)),)
28libraries-y+=$(LOGINUTILS_DIR)$(LOGINUTILS_AR)
29endif
30
31LOGINUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(LOGINUTILS-y))
32LOGINUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
33APPLET_SRC-y+=$(LOGINUTILS_SRC-y)
34APPLET_SRC-a+=$(LOGINUTILS_SRC-a)
35
36needcrypt-y:=
37needcrypt-$(CONFIG_LOGIN) := y
38needcrypt-$(CONFIG_PASSWD) := y
39needcrypt-$(CONFIG_SU) := y
40needcrypt-$(CONFIG_SULOGIN) := y
41needcrypt-$(CONFIG_VLOCK) := y
42
43
44ifeq ($(needcrypt-y),y)
45 LIBRARIES := -lcrypt $(filter-out -lcrypt,$(LIBRARIES))
46endif
47
48$(LOGINUTILS_DIR)$(LOGINUTILS_AR): $(patsubst %,$(LOGINUTILS_DIR)%, $(LOGINUTILS-y))
49 $(do_ar)
50
51$(LOGINUTILS_DIR)%.o: $(srcdir)/%.c
52 $(compile.c)
diff --git a/miscutils/Config.in b/miscutils/Config.in
index 50ed4df99..311c7135c 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -5,25 +5,25 @@
5 5
6menu "Miscellaneous Utilities" 6menu "Miscellaneous Utilities"
7 7
8config CONFIG_ADJTIMEX 8config ADJTIMEX
9 bool "adjtimex" 9 bool "adjtimex"
10 default n 10 default n
11 help 11 help
12 Adjtimex reads and optionally sets adjustment parameters for 12 Adjtimex reads and optionally sets adjustment parameters for
13 the Linux clock adjustment algorithm. 13 the Linux clock adjustment algorithm.
14 14
15config CONFIG_BBCONFIG 15config BBCONFIG
16 bool "bbconfig" 16 bool "bbconfig"
17 default n 17 default n
18 help 18 help
19 The bbconfig applet will print the config file with which 19 The bbconfig applet will print the config file with which
20 busybox was built. 20 busybox was built.
21 21
22config CONFIG_CROND 22config CROND
23 bool "crond" 23 bool "crond"
24 default n 24 default n
25 select CONFIG_FEATURE_SUID 25 select FEATURE_SUID
26 select CONFIG_FEATURE_SYSLOG 26 select FEATURE_SYSLOG
27 help 27 help
28 Crond is a background daemon that parses individual crontab 28 Crond is a background daemon that parses individual crontab
29 files and executes commands on behalf of the users in question. 29 files and executes commands on behalf of the users in question.
@@ -35,39 +35,39 @@ config CONFIG_CROND
35 Note that Busybox binary must be setuid root for this applet to 35 Note that Busybox binary must be setuid root for this applet to
36 work properly. 36 work properly.
37 37
38config CONFIG_DEBUG_CROND_OPTION 38config DEBUG_CROND_OPTION
39 bool "Support debug option -d" 39 bool "Support debug option -d"
40 depends on CONFIG_CROND 40 depends on CROND
41 default n 41 default n
42 help 42 help
43 Support option -d to enter debug mode. 43 Support option -d to enter debug mode.
44 44
45config CONFIG_FEATURE_CROND_CALL_SENDMAIL 45config FEATURE_CROND_CALL_SENDMAIL
46 bool "Using /usr/sbin/sendmail?" 46 bool "Using /usr/sbin/sendmail?"
47 default n 47 default n
48 depends on CONFIG_CROND 48 depends on CROND
49 help 49 help
50 Support calling /usr/sbin/sendmail for send cmd outputs. 50 Support calling /usr/sbin/sendmail for send cmd outputs.
51 51
52config CONFIG_CRONTAB 52config CRONTAB
53 bool "crontab" 53 bool "crontab"
54 default n 54 default n
55 select CONFIG_FEATURE_SUID 55 select FEATURE_SUID
56 help 56 help
57 Crontab manipulates the crontab for a particular user. Only 57 Crontab manipulates the crontab for a particular user. Only
58 the superuser may specify a different user and/or crontab directory. 58 the superuser may specify a different user and/or crontab directory.
59 59
60config CONFIG_DC 60config DC
61 bool "dc" 61 bool "dc"
62 default n 62 default n
63 help 63 help
64 Dc is a reverse-polish desk calculator which supports unlimited 64 Dc is a reverse-polish desk calculator which supports unlimited
65 precision arithmetic. 65 precision arithmetic.
66 66
67config CONFIG_DEVFSD 67config DEVFSD
68 bool "devfsd (obsolete)" 68 bool "devfsd (obsolete)"
69 default n 69 default n
70 select CONFIG_FEATURE_SYSLOG 70 select FEATURE_SYSLOG
71 help 71 help
72 This is deprecated, and will be removed at the end of 2008. 72 This is deprecated, and will be removed at the end of 2008.
73 73
@@ -80,30 +80,30 @@ config CONFIG_DEVFSD
80 80
81 But only if they are written UPPERCASE!!!!!!!! 81 But only if they are written UPPERCASE!!!!!!!!
82 82
83config CONFIG_DEVFSD_MODLOAD 83config DEVFSD_MODLOAD
84 bool "Adds support for MODLOAD keyword in devsfd.conf" 84 bool "Adds support for MODLOAD keyword in devsfd.conf"
85 default n 85 default n
86 depends on CONFIG_DEVFSD 86 depends on DEVFSD
87 help 87 help
88 This actually doesn't work with busybox modutils but needs 88 This actually doesn't work with busybox modutils but needs
89 the external modutils. 89 the external modutils.
90 90
91config CONFIG_DEVFSD_FG_NP 91config DEVFSD_FG_NP
92 bool "Enables the -fg and -np options" 92 bool "Enables the -fg and -np options"
93 default n 93 default n
94 depends on CONFIG_DEVFSD 94 depends on DEVFSD
95 help 95 help
96 -fg Run the daemon in the foreground. 96 -fg Run the daemon in the foreground.
97 -np Exit after parsing the configuration file. Do not poll for events. 97 -np Exit after parsing the configuration file. Do not poll for events.
98 98
99config CONFIG_DEVFSD_VERBOSE 99config DEVFSD_VERBOSE
100 bool "Increases logging (and size)" 100 bool "Increases logging (and size)"
101 default n 101 default n
102 depends on CONFIG_DEVFSD 102 depends on DEVFSD
103 help 103 help
104 Increases logging to stderr or syslog. 104 Increases logging to stderr or syslog.
105 105
106config CONFIG_FEATURE_DEVFS 106config FEATURE_DEVFS
107 bool " Use devfs names for all devices (obsolete)" 107 bool " Use devfs names for all devices (obsolete)"
108 default n 108 default n
109 help 109 help
@@ -113,126 +113,126 @@ config CONFIG_FEATURE_DEVFS
113 /dev/loop0. If your /dev directory has normal names instead of 113 /dev/loop0. If your /dev directory has normal names instead of
114 devfs names, you don't want this. 114 devfs names, you don't want this.
115 115
116config CONFIG_EJECT 116config EJECT
117 bool "eject" 117 bool "eject"
118 default n 118 default n
119 help 119 help
120 Used to eject cdroms. (defaults to /dev/cdrom) 120 Used to eject cdroms. (defaults to /dev/cdrom)
121 121
122config CONFIG_LAST 122config LAST
123 bool "last" 123 bool "last"
124 default n 124 default n
125 select CONFIG_FEATURE_WTMP 125 select FEATURE_WTMP
126 help 126 help
127 'last' displays a list of the last users that logged into the system. 127 'last' displays a list of the last users that logged into the system.
128 128
129config CONFIG_LESS 129config LESS
130 bool "less" 130 bool "less"
131 default n 131 default n
132 help 132 help
133 'less' is a pager, meaning that it displays text files. It possesses 133 'less' is a pager, meaning that it displays text files. It possesses
134 a wide array of features, and is an improvement over 'more'. 134 a wide array of features, and is an improvement over 'more'.
135 135
136config CONFIG_FEATURE_LESS_BRACKETS 136config FEATURE_LESS_BRACKETS
137 bool "Enable bracket searching" 137 bool "Enable bracket searching"
138 default y 138 default y
139 depends on CONFIG_LESS 139 depends on LESS
140 help 140 help
141 This option adds the capability to search for matching left and right 141 This option adds the capability to search for matching left and right
142 brackets, facilitating programming. 142 brackets, facilitating programming.
143 143
144config CONFIG_FEATURE_LESS_FLAGS 144config FEATURE_LESS_FLAGS
145 bool "Enable extra flags" 145 bool "Enable extra flags"
146 default y 146 default y
147 depends on CONFIG_LESS 147 depends on LESS
148 help 148 help
149 The extra flags provided do the following: 149 The extra flags provided do the following:
150 150
151 The -M flag enables a more sophisticated status line. 151 The -M flag enables a more sophisticated status line.
152 The -m flag enables a simpler status line with a percentage. 152 The -m flag enables a simpler status line with a percentage.
153 153
154config CONFIG_FEATURE_LESS_FLAGCS 154config FEATURE_LESS_FLAGCS
155 bool "Enable flag changes" 155 bool "Enable flag changes"
156 default n 156 default n
157 depends on CONFIG_LESS 157 depends on LESS
158 help 158 help
159 This enables the ability to change command-line flags within 159 This enables the ability to change command-line flags within
160 less itself. 160 less itself.
161 161
162config CONFIG_FEATURE_LESS_MARKS 162config FEATURE_LESS_MARKS
163 bool "Enable marks" 163 bool "Enable marks"
164 default n 164 default n
165 depends on CONFIG_LESS 165 depends on LESS
166 help 166 help
167 Marks enable positions in a file to be stored for easy reference. 167 Marks enable positions in a file to be stored for easy reference.
168 168
169config CONFIG_FEATURE_LESS_REGEXP 169config FEATURE_LESS_REGEXP
170 bool "Enable regular expressions" 170 bool "Enable regular expressions"
171 default n 171 default n
172 depends on CONFIG_LESS 172 depends on LESS
173 help 173 help
174 Enable regular expressions, allowing complex file searches. 174 Enable regular expressions, allowing complex file searches.
175 175
176config CONFIG_HDPARM 176config HDPARM
177 bool "hdparm" 177 bool "hdparm"
178 default n 178 default n
179 help 179 help
180 Get/Set hard drive parameters. Primarily intended for ATA 180 Get/Set hard drive parameters. Primarily intended for ATA
181 drives. Adds about 13k (or around 30k if you enable the 181 drives. Adds about 13k (or around 30k if you enable the
182 CONFIG_FEATURE_HDPARM_GET_IDENTITY option).... 182 FEATURE_HDPARM_GET_IDENTITY option)....
183 183
184config CONFIG_FEATURE_HDPARM_GET_IDENTITY 184config FEATURE_HDPARM_GET_IDENTITY
185 bool "Support obtaining detailed information directly from drives" 185 bool "Support obtaining detailed information directly from drives"
186 default y 186 default y
187 depends on CONFIG_HDPARM 187 depends on HDPARM
188 help 188 help
189 Enables the -I and -i options to obtain detailed information 189 Enables the -I and -i options to obtain detailed information
190 directly from drives about their capabilities and supported ATA 190 directly from drives about their capabilities and supported ATA
191 feature set. If no device name is specified, hdparm will read 191 feature set. If no device name is specified, hdparm will read
192 identify data from stdin. Enabling this option will add about 16k... 192 identify data from stdin. Enabling this option will add about 16k...
193 193
194config CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF 194config FEATURE_HDPARM_HDIO_SCAN_HWIF
195 bool "Register an IDE interface (DANGEROUS)" 195 bool "Register an IDE interface (DANGEROUS)"
196 default n 196 default n
197 depends on CONFIG_HDPARM 197 depends on HDPARM
198 help 198 help
199 Enables the 'hdparm -R' option to register an IDE interface. 199 Enables the 'hdparm -R' option to register an IDE interface.
200 This is dangerous stuff, so you should probably say N. 200 This is dangerous stuff, so you should probably say N.
201 201
202config CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF 202config FEATURE_HDPARM_HDIO_UNREGISTER_HWIF
203 bool "Un-register an IDE interface (DANGEROUS)" 203 bool "Un-register an IDE interface (DANGEROUS)"
204 default n 204 default n
205 depends on CONFIG_HDPARM 205 depends on HDPARM
206 help 206 help
207 Enables the 'hdparm -U' option to un-register an IDE interface. 207 Enables the 'hdparm -U' option to un-register an IDE interface.
208 This is dangerous stuff, so you should probably say N. 208 This is dangerous stuff, so you should probably say N.
209 209
210config CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET 210config FEATURE_HDPARM_HDIO_DRIVE_RESET
211 bool "perform device reset (DANGEROUS)" 211 bool "perform device reset (DANGEROUS)"
212 default n 212 default n
213 depends on CONFIG_HDPARM 213 depends on HDPARM
214 help 214 help
215 Enables the 'hdparm -w' option to perform a device reset. 215 Enables the 'hdparm -w' option to perform a device reset.
216 This is dangerous stuff, so you should probably say N. 216 This is dangerous stuff, so you should probably say N.
217 217
218config CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF 218config FEATURE_HDPARM_HDIO_TRISTATE_HWIF
219 bool "tristate device for hotswap (DANGEROUS)" 219 bool "tristate device for hotswap (DANGEROUS)"
220 default n 220 default n
221 depends on CONFIG_HDPARM 221 depends on HDPARM
222 help 222 help
223 Enables the 'hdparm -x' option to tristate device for hotswap, 223 Enables the 'hdparm -x' option to tristate device for hotswap,
224 and the '-b' option to get/set bus state. This is dangerous 224 and the '-b' option to get/set bus state. This is dangerous
225 stuff, so you should probably say N. 225 stuff, so you should probably say N.
226 226
227config CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA 227config FEATURE_HDPARM_HDIO_GETSET_DMA
228 bool "get/set using_dma flag (DANGEROUS)" 228 bool "get/set using_dma flag (DANGEROUS)"
229 default n 229 default n
230 depends on CONFIG_HDPARM 230 depends on HDPARM
231 help 231 help
232 Enables the 'hdparm -d' option to get/set using_dma flag. 232 Enables the 'hdparm -d' option to get/set using_dma flag.
233 This is dangerous stuff, so you should probably say N. 233 This is dangerous stuff, so you should probably say N.
234 234
235config CONFIG_MAKEDEVS 235config MAKEDEVS
236 bool "makedevs" 236 bool "makedevs"
237 default n 237 default n
238 help 238 help
@@ -253,24 +253,24 @@ config CONFIG_MAKEDEVS
253 253
254choice 254choice
255 prompt "Choose makedevs behaviour" 255 prompt "Choose makedevs behaviour"
256 depends CONFIG_MAKEDEVS 256 depends MAKEDEVS
257 default CONFIG_FEATURE_MAKEDEVS_TABLE 257 default FEATURE_MAKEDEVS_TABLE
258 258
259config CONFIG_FEATURE_MAKEDEVS_LEAF 259config FEATURE_MAKEDEVS_LEAF
260 bool "leaf" 260 bool "leaf"
261 261
262config CONFIG_FEATURE_MAKEDEVS_TABLE 262config FEATURE_MAKEDEVS_TABLE
263 bool "table" 263 bool "table"
264 264
265endchoice 265endchoice
266 266
267config CONFIG_MOUNTPOINT 267config MOUNTPOINT
268 bool "mountpoint" 268 bool "mountpoint"
269 default n 269 default n
270 help 270 help
271 mountpoint checks if the directory is a mountpoint. 271 mountpoint checks if the directory is a mountpoint.
272 272
273config CONFIG_MT 273config MT
274 bool "mt" 274 bool "mt"
275 default n 275 default n
276 help 276 help
@@ -278,7 +278,7 @@ config CONFIG_MT
278 to advance or rewind a tape past a specified number of archive 278 to advance or rewind a tape past a specified number of archive
279 files on the tape. 279 files on the tape.
280 280
281config CONFIG_READAHEAD 281config READAHEAD
282 bool "readahead" 282 bool "readahead"
283 default n 283 default n
284 help 284 help
@@ -294,7 +294,7 @@ config CONFIG_READAHEAD
294 As readahead(2) blocks until each file has been read, it is best to 294 As readahead(2) blocks until each file has been read, it is best to
295 run this applet as a background job. 295 run this applet as a background job.
296 296
297config CONFIG_RUNLEVEL 297config RUNLEVEL
298 bool "runlevel" 298 bool "runlevel"
299 default n 299 default n
300 help 300 help
@@ -303,32 +303,32 @@ config CONFIG_RUNLEVEL
303 This applet uses utmp but does not rely on busybox supporing 303 This applet uses utmp but does not rely on busybox supporing
304 utmp on purpose. It is used by e.g. emdebian via /etc/init.d/rc. 304 utmp on purpose. It is used by e.g. emdebian via /etc/init.d/rc.
305 305
306config CONFIG_RX 306config RX
307 bool "rx" 307 bool "rx"
308 default n 308 default n
309 help 309 help
310 Receive files using the Xmodem protocol. 310 Receive files using the Xmodem protocol.
311 311
312config CONFIG_STRINGS 312config STRINGS
313 bool "strings" 313 bool "strings"
314 default n 314 default n
315 help 315 help
316 strings prints the printable character sequences for each file 316 strings prints the printable character sequences for each file
317 specified. 317 specified.
318 318
319config CONFIG_SETSID 319config SETSID
320 bool "setsid" 320 bool "setsid"
321 default n 321 default n
322 help 322 help
323 setsid runs a program in a new session 323 setsid runs a program in a new session
324 324
325config CONFIG_TASKSET 325config TASKSET
326 bool "taskset" 326 bool "taskset"
327 default n 327 default n
328 help 328 help
329 Retrieve or set a processes's CPU affinity. 329 Retrieve or set a processes's CPU affinity.
330 330
331config CONFIG_TIME 331config TIME
332 bool "time" 332 bool "time"
333 default n 333 default n
334 help 334 help
@@ -336,7 +336,7 @@ config CONFIG_TIME
336 When the command finishes, time writes a message to standard output 336 When the command finishes, time writes a message to standard output
337 giving timing statistics about this program run. 337 giving timing statistics about this program run.
338 338
339config CONFIG_WATCHDOG 339config WATCHDOG
340 bool "watchdog" 340 bool "watchdog"
341 default n 341 default n
342 help 342 help
diff --git a/miscutils/Kbuild b/miscutils/Kbuild
new file mode 100644
index 000000000..1c9e9fded
--- /dev/null
+++ b/miscutils/Kbuild
@@ -0,0 +1,27 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_ADJTIMEX) += adjtimex.o
9lib-$(CONFIG_CROND) += crond.o
10lib-$(CONFIG_CRONTAB) += crontab.o
11lib-$(CONFIG_BBCONFIG) += bbconfig.o
12lib-$(CONFIG_DC) += dc.o
13lib-$(CONFIG_DEVFSD) += devfsd.o
14lib-$(CONFIG_EJECT) += eject.o
15lib-$(CONFIG_HDPARM) += hdparm.o
16lib-$(CONFIG_LAST) += last.o
17lib-$(CONFIG_LESS) += less.o
18lib-$(CONFIG_MAKEDEVS) += makedevs.o
19lib-$(CONFIG_MOUNTPOINT) += mountpoint.o
20lib-$(CONFIG_MT) += mt.o
21lib-$(CONFIG_READAHEAD) += readahead.o
22lib-$(CONFIG_RUNLEVEL) += runlevel.o
23lib-$(CONFIG_RX) += rx.o
24lib-$(CONFIG_SETSID) += setsid.o
25lib-$(CONFIG_STRINGS) += strings.o
26lib-$(CONFIG_TIME) += time.o
27lib-$(CONFIG_WATCHDOG) += watchdog.o
diff --git a/miscutils/Makefile b/miscutils/Makefile
deleted file mode 100644
index 91b31ec9e..000000000
--- a/miscutils/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/miscutils
14MISCUTILS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/miscutils/Makefile.in b/miscutils/Makefile.in
deleted file mode 100644
index d32d7714e..000000000
--- a/miscutils/Makefile.in
+++ /dev/null
@@ -1,55 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7MISCUTILS_AR:=miscutils.a
8ifndef $(MISCUTILS_DIR)
9MISCUTILS_DIR:=$(top_builddir)/miscutils/
10endif
11srcdir=$(top_srcdir)/miscutils
12
13MISCUTILS-y:=
14MISCUTILS-$(CONFIG_ADJTIMEX) += adjtimex.o
15MISCUTILS-$(CONFIG_CROND) += crond.o
16MISCUTILS-$(CONFIG_CRONTAB) += crontab.o
17MISCUTILS-$(CONFIG_BBCONFIG) += bbconfig.o
18MISCUTILS-$(CONFIG_DC) += dc.o
19MISCUTILS-$(CONFIG_DEVFSD) += devfsd.o
20MISCUTILS-$(CONFIG_EJECT) += eject.o
21MISCUTILS-$(CONFIG_HDPARM) += hdparm.o
22MISCUTILS-$(CONFIG_LAST) += last.o
23MISCUTILS-$(CONFIG_LESS) += less.o
24MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o
25MISCUTILS-$(CONFIG_MOUNTPOINT) += mountpoint.o
26MISCUTILS-$(CONFIG_MT) += mt.o
27MISCUTILS-$(CONFIG_READAHEAD) += readahead.o
28MISCUTILS-$(CONFIG_RUNLEVEL) += runlevel.o
29MISCUTILS-$(CONFIG_RX) += rx.o
30MISCUTILS-$(CONFIG_SETSID) += setsid.o
31MISCUTILS-$(CONFIG_STRINGS) += strings.o
32MISCUTILS-$(CONFIG_TIME) += time.o
33MISCUTILS-$(CONFIG_WATCHDOG) += watchdog.o
34
35ifneq ($(strip $(MISCUTILS-y)),)
36libraries-y+=$(MISCUTILS_DIR)$(MISCUTILS_AR)
37endif
38
39MISCUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(MISCUTILS-y))
40MISCUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
41APPLET_SRC-y+=$(MISCUTILS_SRC-y)
42APPLET_SRC-a+=$(MISCUTILS_SRC-a)
43
44needlibm-y:=
45needlibm-$(CONFIG_DC) := y
46
47ifeq ($(needlibm-y),y)
48 LIBRARIES := -lm $(filter-out -lm,$(LIBRARIES))
49endif
50
51$(MISCUTILS_DIR)$(MISCUTILS_AR): $(patsubst %,$(MISCUTILS_DIR)%, $(MISCUTILS-y))
52 $(do_ar)
53
54$(MISCUTILS_DIR)%.o: $(srcdir)/%.c
55 $(compile.c)
diff --git a/miscutils/rx.c b/miscutils/rx.c
index 52a76bfd9..00951b711 100644
--- a/miscutils/rx.c
+++ b/miscutils/rx.c
@@ -266,7 +266,7 @@ int rx_main(int argc, char **argv)
266 filefd = xopen3(fn, O_RDWR|O_CREAT|O_TRUNC, 0666); 266 filefd = xopen3(fn, O_RDWR|O_CREAT|O_TRUNC, 0666);
267 267
268 if (tcgetattr(ttyfd, &tty) < 0) 268 if (tcgetattr(ttyfd, &tty) < 0)
269 bb_perror_msg_and_die("%s: tcgetattr failed", argv[0]); 269 bb_perror_msg_and_die("tcgetattr");
270 270
271 orig_tty = tty; 271 orig_tty = tty;
272 272
@@ -284,8 +284,7 @@ int rx_main(int argc, char **argv)
284 tcsetattr(ttyfd, TCSAFLUSH, &orig_tty); 284 tcsetattr(ttyfd, TCSAFLUSH, &orig_tty);
285 285
286 if (n < 0) 286 if (n < 0)
287 bb_error_msg_and_die("\n%s: receive failed:\n %s", 287 bb_error_msg_and_die("\nreceive failed:\n %s", error_buf);
288 argv[0], error_buf);
289 288
290 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 289 bb_fflush_stdout_and_exit(EXIT_SUCCESS);
291} 290}
diff --git a/modutils/Config.in b/modutils/Config.in
index 8974fb795..b28c66d24 100644
--- a/modutils/Config.in
+++ b/modutils/Config.in
@@ -5,24 +5,24 @@
5 5
6menu "Linux Module Utilities" 6menu "Linux Module Utilities"
7 7
8config CONFIG_INSMOD 8config INSMOD
9 bool "insmod" 9 bool "insmod"
10 default n 10 default n
11 help 11 help
12 insmod is used to load specified modules in the running kernel. 12 insmod is used to load specified modules in the running kernel.
13 13
14config CONFIG_FEATURE_INSMOD_VERSION_CHECKING 14config FEATURE_INSMOD_VERSION_CHECKING
15 bool "Module version checking" 15 bool "Module version checking"
16 default n 16 default n
17 depends on CONFIG_INSMOD && CONFIG_FEATURE_2_4_MODULES 17 depends on INSMOD && FEATURE_2_4_MODULES
18 help 18 help
19 Support checking of versions for modules. This is used to 19 Support checking of versions for modules. This is used to
20 ensure that the kernel and module are made for each other. 20 ensure that the kernel and module are made for each other.
21 21
22config CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS 22config FEATURE_INSMOD_KSYMOOPS_SYMBOLS
23 bool "Add module symbols to kernel symbol table" 23 bool "Add module symbols to kernel symbol table"
24 default n 24 default n
25 depends on CONFIG_INSMOD && CONFIG_FEATURE_2_4_MODULES 25 depends on INSMOD && FEATURE_2_4_MODULES
26 help 26 help
27 By adding module symbols to the kernel symbol table, Oops messages 27 By adding module symbols to the kernel symbol table, Oops messages
28 occuring within kernel modules can be properly debugged. By enabling 28 occuring within kernel modules can be properly debugged. By enabling
@@ -30,20 +30,20 @@ config CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
30 table for properly debugging support. If you are not interested in 30 table for properly debugging support. If you are not interested in
31 Oops messages from kernel modules, say N. 31 Oops messages from kernel modules, say N.
32 32
33config CONFIG_FEATURE_INSMOD_LOADINKMEM 33config FEATURE_INSMOD_LOADINKMEM
34 bool "In kernel memory optimization (uClinux only)" 34 bool "In kernel memory optimization (uClinux only)"
35 default n 35 default n
36 depends on CONFIG_INSMOD && CONFIG_FEATURE_2_4_MODULES 36 depends on INSMOD && FEATURE_2_4_MODULES
37 help 37 help
38 This is a special uClinux only memory optimization that lets insmod 38 This is a special uClinux only memory optimization that lets insmod
39 load the specified kernel module directly into kernel space, reducing 39 load the specified kernel module directly into kernel space, reducing
40 memory usage by preventing the need for two copies of the module 40 memory usage by preventing the need for two copies of the module
41 being loaded into memory. 41 being loaded into memory.
42 42
43config CONFIG_FEATURE_INSMOD_LOAD_MAP 43config FEATURE_INSMOD_LOAD_MAP
44 bool "Enable load map (-m) option" 44 bool "Enable load map (-m) option"
45 default n 45 default n
46 depends on CONFIG_INSMOD && CONFIG_FEATURE_2_4_MODULES 46 depends on INSMOD && FEATURE_2_4_MODULES
47 help 47 help
48 Enabling this, one would be able to get a load map 48 Enabling this, one would be able to get a load map
49 output on stdout. This makes kernel module debugging 49 output on stdout. This makes kernel module debugging
@@ -51,36 +51,36 @@ config CONFIG_FEATURE_INSMOD_LOAD_MAP
51 If you don't plan to debug kernel modules, you 51 If you don't plan to debug kernel modules, you
52 don't need this option. 52 don't need this option.
53 53
54config CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL 54config FEATURE_INSMOD_LOAD_MAP_FULL
55 bool "Symbols in load map" 55 bool "Symbols in load map"
56 default y 56 default y
57 depends on CONFIG_FEATURE_INSMOD_LOAD_MAP 57 depends on FEATURE_INSMOD_LOAD_MAP
58 help 58 help
59 Without this option, -m will only output section 59 Without this option, -m will only output section
60 load map. With this option, -m will also output 60 load map. With this option, -m will also output
61 symbols load map. 61 symbols load map.
62 62
63config CONFIG_RMMOD 63config RMMOD
64 bool "rmmod" 64 bool "rmmod"
65 default n 65 default n
66 help 66 help
67 rmmod is used to unload specified modules from the kernel. 67 rmmod is used to unload specified modules from the kernel.
68 68
69config CONFIG_LSMOD 69config LSMOD
70 bool "lsmod" 70 bool "lsmod"
71 default n 71 default n
72 help 72 help
73 lsmod is used to display a list of loaded modules. 73 lsmod is used to display a list of loaded modules.
74 74
75config CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT 75config FEATURE_LSMOD_PRETTY_2_6_OUTPUT
76 bool "lsmod pretty output for 2.6.x Linux kernels " 76 bool "lsmod pretty output for 2.6.x Linux kernels "
77 default n 77 default n
78 depends on CONFIG_LSMOD 78 depends on LSMOD
79 help 79 help
80 This option makes output format of lsmod adjusted to 80 This option makes output format of lsmod adjusted to
81 the format of module-init-tools for Linux kernel 2.6. 81 the format of module-init-tools for Linux kernel 2.6.
82 82
83config CONFIG_MODPROBE 83config MODPROBE
84 bool "modprobe" 84 bool "modprobe"
85 default n 85 default n
86 help 86 help
@@ -90,11 +90,11 @@ config CONFIG_MODPROBE
90 Note that in the state, modprobe does not understand multiple 90 Note that in the state, modprobe does not understand multiple
91 module options from the configuration file. See option below. 91 module options from the configuration file. See option below.
92 92
93config CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS 93config FEATURE_MODPROBE_MULTIPLE_OPTIONS
94 bool 94 bool
95 prompt "Multiple options parsing" if CONFIG_NITPICK 95 prompt "Multiple options parsing" if NITPICK
96 default y 96 default y
97 depends on CONFIG_MODPROBE 97 depends on MODPROBE
98 help 98 help
99 Allow modprobe to understand more than one option to pass to 99 Allow modprobe to understand more than one option to pass to
100 modules. 100 modules.
@@ -107,51 +107,51 @@ config CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS
107 Saying Y here is not a bad idea if you're not that short 107 Saying Y here is not a bad idea if you're not that short
108 on storage capacity. 108 on storage capacity.
109 109
110config CONFIG_FEATURE_MODPROBE_FANCY_ALIAS 110config FEATURE_MODPROBE_FANCY_ALIAS
111 bool 111 bool
112 prompt "Fancy alias parsing" if CONFIG_NITPICK 112 prompt "Fancy alias parsing" if NITPICK
113 default y 113 default y
114 depends on CONFIG_MODPROBE && CONFIG_FEATURE_2_6_MODULES 114 depends on MODPROBE && FEATURE_2_6_MODULES
115 help 115 help
116 Say 'y' here to enable parsing of aliases with underscore/dash 116 Say 'y' here to enable parsing of aliases with underscore/dash
117 mismatch between module name and file name, along with bus-specific 117 mismatch between module name and file name, along with bus-specific
118 aliases (such as pci:... or usb:... aliases). 118 aliases (such as pci:... or usb:... aliases).
119 119
120comment "Options common to multiple modutils" 120comment "Options common to multiple modutils"
121 depends on CONFIG_INSMOD || CONFIG_RMMOD || CONFIG_MODPROBE || CONFIG_LSMOD 121 depends on INSMOD || RMMOD || MODPROBE || LSMOD
122 122
123config CONFIG_FEATURE_CHECK_TAINTED_MODULE 123config FEATURE_CHECK_TAINTED_MODULE
124 # Simulate indentation 124 # Simulate indentation
125 bool "Support tainted module checking with new kernels" 125 bool "Support tainted module checking with new kernels"
126 default y 126 default y
127 depends on CONFIG_INSMOD || CONFIG_LSMOD 127 depends on INSMOD || LSMOD
128 help 128 help
129 Support checking for tainted modules. These are usually binary 129 Support checking for tainted modules. These are usually binary
130 only modules that will make the linux-kernel list ignore your 130 only modules that will make the linux-kernel list ignore your
131 support request. 131 support request.
132 This option is required to support GPLONLY modules. 132 This option is required to support GPLONLY modules.
133 133
134config CONFIG_FEATURE_2_4_MODULES 134config FEATURE_2_4_MODULES
135 # Simulate indentation 135 # Simulate indentation
136 bool "Support version 2.2.x to 2.4.x Linux kernels" 136 bool "Support version 2.2.x to 2.4.x Linux kernels"
137 default y 137 default y
138 depends on CONFIG_INSMOD || CONFIG_RMMOD 138 depends on INSMOD || RMMOD
139 help 139 help
140 Support module loading for 2.2.x and 2.4.x Linux kernels. 140 Support module loading for 2.2.x and 2.4.x Linux kernels.
141 141
142config CONFIG_FEATURE_2_6_MODULES 142config FEATURE_2_6_MODULES
143 # Simulate indentation 143 # Simulate indentation
144 bool "Support version 2.6.x Linux kernels" 144 bool "Support version 2.6.x Linux kernels"
145 default y 145 default y
146 depends on CONFIG_INSMOD || CONFIG_RMMOD || CONFIG_MODPROBE 146 depends on INSMOD || RMMOD || MODPROBE
147 help 147 help
148 Support module loading for newer 2.6.x Linux kernels. 148 Support module loading for newer 2.6.x Linux kernels.
149 149
150 150
151config CONFIG_FEATURE_QUERY_MODULE_INTERFACE 151config FEATURE_QUERY_MODULE_INTERFACE
152 bool 152 bool
153 default y 153 default y
154 depends on CONFIG_FEATURE_2_4_MODULES && !CONFIG_FEATURE_2_6_MODULES 154 depends on FEATURE_2_4_MODULES && !FEATURE_2_6_MODULES
155 155
156 156
157endmenu 157endmenu
diff --git a/modutils/Kbuild b/modutils/Kbuild
new file mode 100644
index 000000000..cff02b4f2
--- /dev/null
+++ b/modutils/Kbuild
@@ -0,0 +1,11 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_INSMOD) += insmod.o
9lib-$(CONFIG_LSMOD) += lsmod.o
10lib-$(CONFIG_MODPROBE) += modprobe.o
11lib-$(CONFIG_RMMOD) += rmmod.o
diff --git a/modutils/Makefile b/modutils/Makefile
deleted file mode 100644
index 65090c5a2..000000000
--- a/modutils/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/modutils
14MODUTILS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/modutils/Makefile.in b/modutils/Makefile.in
deleted file mode 100644
index 5c7c9238e..000000000
--- a/modutils/Makefile.in
+++ /dev/null
@@ -1,32 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7MODUTILS_AR:=modutils.a
8ifndef $(MODUTILS_DIR)
9MODUTILS_DIR:=$(top_builddir)/modutils/
10endif
11srcdir=$(top_srcdir)/modutils
12
13MODUTILS-y:=
14MODUTILS-$(CONFIG_INSMOD) += insmod.o
15MODUTILS-$(CONFIG_LSMOD) += lsmod.o
16MODUTILS-$(CONFIG_MODPROBE) += modprobe.o
17MODUTILS-$(CONFIG_RMMOD) += rmmod.o
18
19ifneq ($(strip $(MODUTILS-y)),)
20libraries-y+=$(MODUTILS_DIR)$(MODUTILS_AR)
21endif
22
23MODUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(MODUTILS-y))
24MODUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
25APPLET_SRC-y+=$(MODUTILS_SRC-y)
26APPLET_SRC-a+=$(MODUTILS_SRC-a)
27
28$(MODUTILS_DIR)$(MODUTILS_AR): $(patsubst %,$(MODUTILS_DIR)%, $(MODUTILS-y))
29 $(do_ar)
30
31$(MODUTILS_DIR)%.o: $(srcdir)/%.c
32 $(compile.c)
diff --git a/networking/Config.in b/networking/Config.in
index b78ae37e7..f9ea56488 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -5,132 +5,132 @@
5 5
6menu "Networking Utilities" 6menu "Networking Utilities"
7 7
8config CONFIG_FEATURE_IPV6 8config FEATURE_IPV6
9 bool "Enable IPv6 support" 9 bool "Enable IPv6 support"
10 default n 10 default n
11 help 11 help
12 Enable IPv6 support in busybox. 12 Enable IPv6 support in busybox.
13 This adds IPv6 support in the networking applets. 13 This adds IPv6 support in the networking applets.
14 14
15config CONFIG_ARPING 15config ARPING
16 bool "arping" 16 bool "arping"
17 default n 17 default n
18 help 18 help
19 Ping hosts by ARP packets 19 Ping hosts by ARP packets
20 20
21config CONFIG_DNSD 21config DNSD
22 bool "dnsd" 22 bool "dnsd"
23 default n 23 default n
24 help 24 help
25 Small and static DNS server daemon. 25 Small and static DNS server daemon.
26 26
27config CONFIG_ETHER_WAKE 27config ETHER_WAKE
28 bool "ether-wake" 28 bool "ether-wake"
29 default n 29 default n
30 help 30 help
31 Send a magic packet to wake up sleeping machines. 31 Send a magic packet to wake up sleeping machines.
32 32
33config CONFIG_FAKEIDENTD 33config FAKEIDENTD
34 bool "fakeidentd" 34 bool "fakeidentd"
35 default n 35 default n
36 select CONFIG_FEATURE_SYSLOG 36 select FEATURE_SYSLOG
37 help 37 help
38 fakeidentd listens on the ident port and returns a predefined 38 fakeidentd listens on the ident port and returns a predefined
39 fake value on any query. 39 fake value on any query.
40 40
41config CONFIG_FTPGET 41config FTPGET
42 bool "ftpget" 42 bool "ftpget"
43 default n 43 default n
44 help 44 help
45 Retrieve a remote file via FTP. 45 Retrieve a remote file via FTP.
46 46
47config CONFIG_FTPPUT 47config FTPPUT
48 bool "ftpput" 48 bool "ftpput"
49 default n 49 default n
50 help 50 help
51 Store a remote file via FTP. 51 Store a remote file via FTP.
52 52
53config CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS 53config FEATURE_FTPGETPUT_LONG_OPTIONS
54 bool "Enable long options in ftpget/ftpput" 54 bool "Enable long options in ftpget/ftpput"
55 default n 55 default n
56 depends on CONFIG_GETOPT_LONG && (CONFIG_FTPGET || CONFIG_FTPPUT) 56 depends on GETOPT_LONG && (CONFIG_FTPGET || FTPPUT)
57 help 57 help
58 Support long options for the ftpget/ftpput applet. 58 Support long options for the ftpget/ftpput applet.
59 59
60config CONFIG_HOSTNAME 60config HOSTNAME
61 bool "hostname" 61 bool "hostname"
62 default n 62 default n
63 help 63 help
64 Show or set the system's host name 64 Show or set the system's host name
65 65
66config CONFIG_HTTPD 66config HTTPD
67 bool "httpd" 67 bool "httpd"
68 default n 68 default n
69 help 69 help
70 Serve web pages via an HTTP server. 70 Serve web pages via an HTTP server.
71 71
72config CONFIG_FEATURE_HTTPD_WITHOUT_INETD 72config FEATURE_HTTPD_WITHOUT_INETD
73 bool "Support using httpd as a daemon (not from inetd)" 73 bool "Support using httpd as a daemon (not from inetd)"
74 default n 74 default n
75 depends on CONFIG_HTTPD 75 depends on HTTPD
76 help 76 help
77 This option enables uid and port options for the httpd applet, 77 This option enables uid and port options for the httpd applet,
78 and eliminates the need to be called from the inetd server daemon. 78 and eliminates the need to be called from the inetd server daemon.
79 79
80config CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP 80config FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
81 bool "Support reloading the global config file using hup signal" 81 bool "Support reloading the global config file using hup signal"
82 default n 82 default n
83 depends on CONFIG_HTTPD && CONFIG_FEATURE_HTTPD_WITHOUT_INETD 83 depends on HTTPD && FEATURE_HTTPD_WITHOUT_INETD
84 help 84 help
85 This option enables processing of SIGHUP to reload cached 85 This option enables processing of SIGHUP to reload cached
86 configuration settings. 86 configuration settings.
87 87
88config CONFIG_FEATURE_HTTPD_SETUID 88config FEATURE_HTTPD_SETUID
89 bool "Enable support -u <user> option" 89 bool "Enable support -u <user> option"
90 default n 90 default n
91 depends on CONFIG_HTTPD && CONFIG_FEATURE_HTTPD_WITHOUT_INETD 91 depends on HTTPD && FEATURE_HTTPD_WITHOUT_INETD
92 help 92 help
93 This option allows the server to run as a specific user 93 This option allows the server to run as a specific user
94 rather than defaulting to the user that starts the server. 94 rather than defaulting to the user that starts the server.
95 Use of this option requires special privileges to change to a 95 Use of this option requires special privileges to change to a
96 different user. 96 different user.
97 97
98config CONFIG_FEATURE_HTTPD_BASIC_AUTH 98config FEATURE_HTTPD_BASIC_AUTH
99 bool "Enable Basic http Authentication" 99 bool "Enable Basic http Authentication"
100 default y 100 default y
101 depends on CONFIG_HTTPD 101 depends on HTTPD
102 help 102 help
103 Utilizes password settings from /etc/httpd.conf for basic 103 Utilizes password settings from /etc/httpd.conf for basic
104 authentication on a per url basis. 104 authentication on a per url basis.
105 105
106config CONFIG_FEATURE_HTTPD_AUTH_MD5 106config FEATURE_HTTPD_AUTH_MD5
107 bool "Support MD5 crypted passwords for http Authentication" 107 bool "Support MD5 crypted passwords for http Authentication"
108 default n 108 default n
109 depends on CONFIG_FEATURE_HTTPD_BASIC_AUTH 109 depends on FEATURE_HTTPD_BASIC_AUTH
110 help 110 help
111 Enables basic per URL authentication from /etc/httpd.conf 111 Enables basic per URL authentication from /etc/httpd.conf
112 using md5 passwords. 112 using md5 passwords.
113 113
114config CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES 114config FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
115 bool "Support loading additional MIME types at run-time" 115 bool "Support loading additional MIME types at run-time"
116 default n 116 default n
117 depends on CONFIG_HTTPD 117 depends on HTTPD
118 help 118 help
119 This option enables support for additional MIME types at 119 This option enables support for additional MIME types at
120 run-time to be specified in the configuration file. 120 run-time to be specified in the configuration file.
121 121
122config CONFIG_FEATURE_HTTPD_CGI 122config FEATURE_HTTPD_CGI
123 bool "Support Common Gateway Interface (CGI)" 123 bool "Support Common Gateway Interface (CGI)"
124 default y 124 default y
125 depends on CONFIG_HTTPD 125 depends on HTTPD
126 help 126 help
127 This option allows scripts and executables to be invoked 127 This option allows scripts and executables to be invoked
128 when specific URLs are requested. 128 when specific URLs are requested.
129 129
130config CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 130config FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
131 bool "Enable support for running scripts through an interpreter" 131 bool "Enable support for running scripts through an interpreter"
132 default n 132 default n
133 depends on CONFIG_FEATURE_HTTPD_CGI 133 depends on FEATURE_HTTPD_CGI
134 help 134 help
135 This option enables support for running scripts through an 135 This option enables support for running scripts through an
136 interpreter. Turn this on if you want PHP scripts to work 136 interpreter. Turn this on if you want PHP scripts to work
@@ -138,81 +138,81 @@ config CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
138 config file: 138 config file:
139 *.php:/path/to/your/php 139 *.php:/path/to/your/php
140 140
141config CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV 141config FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
142 bool "Support the REMOTE_PORT environment variable for CGI" 142 bool "Support the REMOTE_PORT environment variable for CGI"
143 default n 143 default n
144 depends on CONFIG_FEATURE_HTTPD_CGI 144 depends on FEATURE_HTTPD_CGI
145 help 145 help
146 Use of this option can assist scripts in generating 146 Use of this option can assist scripts in generating
147 references that contain a unique port number. 147 references that contain a unique port number.
148 148
149config CONFIG_FEATURE_HTTPD_ENCODE_URL_STR 149config FEATURE_HTTPD_ENCODE_URL_STR
150 bool "Enable the -e option for shell script CGI simplification." 150 bool "Enable the -e option for shell script CGI simplification."
151 default y 151 default y
152 depends on CONFIG_HTTPD 152 depends on HTTPD
153 help 153 help
154 This option allows html encoding arbitrary 154 This option allows html encoding arbitrary
155 strings for display of the browser. Output goes to stdout. 155 strings for display of the browser. Output goes to stdout.
156 For example, httpd -e "<Hello World>" as 156 For example, httpd -e "<Hello World>" as
157 "&#60Hello&#32World&#62". 157 "&#60Hello&#32World&#62".
158 158
159config CONFIG_IFCONFIG 159config IFCONFIG
160 bool "ifconfig" 160 bool "ifconfig"
161 default n 161 default n
162 help 162 help
163 Ifconfig is used to configure the kernel-resident network interfaces. 163 Ifconfig is used to configure the kernel-resident network interfaces.
164 164
165config CONFIG_FEATURE_IFCONFIG_STATUS 165config FEATURE_IFCONFIG_STATUS
166 bool "Enable status reporting output (+7k)" 166 bool "Enable status reporting output (+7k)"
167 default y 167 default y
168 depends on CONFIG_IFCONFIG 168 depends on IFCONFIG
169 help 169 help
170 If ifconfig is called with no arguments it will display the status 170 If ifconfig is called with no arguments it will display the status
171 of the currently active interfaces. 171 of the currently active interfaces.
172 172
173config CONFIG_FEATURE_IFCONFIG_SLIP 173config FEATURE_IFCONFIG_SLIP
174 bool "Enable slip-specific options \"keepalive\" and \"outfill\"" 174 bool "Enable slip-specific options \"keepalive\" and \"outfill\""
175 default n 175 default n
176 depends on CONFIG_IFCONFIG 176 depends on IFCONFIG
177 help 177 help
178 Allow "keepalive" and "outfill" support for SLIP. If you're not 178 Allow "keepalive" and "outfill" support for SLIP. If you're not
179 planning on using serial lines, leave this unchecked. 179 planning on using serial lines, leave this unchecked.
180 180
181config CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ 181config FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
182 bool "Enable options \"mem_start\", \"io_addr\", and \"irq\"" 182 bool "Enable options \"mem_start\", \"io_addr\", and \"irq\""
183 default n 183 default n
184 depends on CONFIG_IFCONFIG 184 depends on IFCONFIG
185 help 185 help
186 Allow the start address for shared memory, start address for I/O, 186 Allow the start address for shared memory, start address for I/O,
187 and/or the interrupt line used by the specified device. 187 and/or the interrupt line used by the specified device.
188 188
189config CONFIG_FEATURE_IFCONFIG_HW 189config FEATURE_IFCONFIG_HW
190 bool "Enable option \"hw\" (ether only)" 190 bool "Enable option \"hw\" (ether only)"
191 default y 191 default y
192 depends on CONFIG_IFCONFIG 192 depends on IFCONFIG
193 help 193 help
194 Set the hardware address of this interface, if the device driver 194 Set the hardware address of this interface, if the device driver
195 supports this operation. Currently, we only support the 'ether' 195 supports this operation. Currently, we only support the 'ether'
196 class. 196 class.
197 197
198config CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS 198config FEATURE_IFCONFIG_BROADCAST_PLUS
199 bool "Set the broadcast automatically" 199 bool "Set the broadcast automatically"
200 default n 200 default n
201 depends on CONFIG_IFCONFIG 201 depends on IFCONFIG
202 help 202 help
203 Setting this will make ifconfig attempt to find the broadcast 203 Setting this will make ifconfig attempt to find the broadcast
204 automatically if the value '+' is used. 204 automatically if the value '+' is used.
205 205
206config CONFIG_IFUPDOWN 206config IFUPDOWN
207 bool "ifupdown" 207 bool "ifupdown"
208 default n 208 default n
209 select CONFIG_RUN_PARTS 209 select RUN_PARTS
210 help 210 help
211 Activate or deactivate the specified interfaces. This applet makes 211 Activate or deactivate the specified interfaces. This applet makes
212 use of either "ifconfig" and "route" or the "ip" command to actually 212 use of either "ifconfig" and "route" or the "ip" command to actually
213 configure network interfaces. Therefore, you will probably also want 213 configure network interfaces. Therefore, you will probably also want
214 to enable either CONFIG_IFCONFIG and CONFIG_ROUTE, or enable 214 to enable either IFCONFIG and ROUTE, or enable
215 CONFIG_FEATURE_IFUPDOWN_IP and the various CONFIG_IP options. Of 215 FEATURE_IFUPDOWN_IP and the various IP options. Of
216 course you could use non-busybox versions of these programs, so 216 course you could use non-busybox versions of these programs, so
217 against my better judgement (since this will surely result in plenty 217 against my better judgement (since this will surely result in plenty
218 of support questions on the mailing list), I do not force you to 218 of support questions on the mailing list), I do not force you to
@@ -220,34 +220,34 @@ config CONFIG_IFUPDOWN
220 "ifconfig" and "route" or the "ip" command, either via busybox or via 220 "ifconfig" and "route" or the "ip" command, either via busybox or via
221 standalone utilities. 221 standalone utilities.
222 222
223config CONFIG_FEATURE_IFUPDOWN_IP 223config FEATURE_IFUPDOWN_IP
224 bool "Use ip applet" 224 bool "Use ip applet"
225 default n 225 default n
226 depends on CONFIG_IFUPDOWN 226 depends on IFUPDOWN
227 help 227 help
228 Use the iproute "ip" command to implement "ifup" and "ifdown", rather 228 Use the iproute "ip" command to implement "ifup" and "ifdown", rather
229 than the default of using the older 'ifconfig' and 'route' utilities. 229 than the default of using the older 'ifconfig' and 'route' utilities.
230 230
231config CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN 231config FEATURE_IFUPDOWN_IP_BUILTIN
232 bool "Use busybox ip applet" 232 bool "Use busybox ip applet"
233 default y 233 default y
234 depends on CONFIG_FEATURE_IFUPDOWN_IP 234 depends on FEATURE_IFUPDOWN_IP
235 select CONFIG_IP 235 select IP
236 select CONFIG_FEATURE_IP_ADDRESS 236 select FEATURE_IP_ADDRESS
237 select CONFIG_FEATURE_IP_LINK 237 select FEATURE_IP_LINK
238 select CONFIG_FEATURE_IP_ROUTE 238 select FEATURE_IP_ROUTE
239 help 239 help
240 Use the busybox iproute "ip" applet to implement "ifupdown". 240 Use the busybox iproute "ip" applet to implement "ifupdown".
241 241
242 If leave this disabled, you must install the full-blown iproute2 242 If leave this disabled, you must install the full-blown iproute2
243 utility or the "ifup" and "ifdown" applets will not work. 243 utility or the "ifup" and "ifdown" applets will not work.
244 244
245config CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN 245config FEATURE_IFUPDOWN_IP_BUILTIN
246 bool "Use busybox ifconfig and route applets" 246 bool "Use busybox ifconfig and route applets"
247 default y 247 default y
248 depends on CONFIG_IFUPDOWN && !CONFIG_FEATURE_IFUPDOWN_IP 248 depends on IFUPDOWN && !CONFIG_FEATURE_IFUPDOWN_IP
249 select CONFIG_IFCONFIG 249 select IFCONFIG
250 select CONFIG_ROUTE 250 select ROUTE
251 help 251 help
252 Use the busybox iproute "ifconfig" and "route" applets to 252 Use the busybox iproute "ifconfig" and "route" applets to
253 implement the "ifup" and "ifdown" utilities. 253 implement the "ifup" and "ifdown" utilities.
@@ -256,87 +256,87 @@ config CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN
256 and route utilities, or the "ifup" and "ifdown" applets will not 256 and route utilities, or the "ifup" and "ifdown" applets will not
257 work. 257 work.
258 258
259config CONFIG_FEATURE_IFUPDOWN_IPV4 259config FEATURE_IFUPDOWN_IPV4
260 bool "Enable support for IPv4" 260 bool "Enable support for IPv4"
261 default y 261 default y
262 depends on CONFIG_IFUPDOWN 262 depends on IFUPDOWN
263 help 263 help
264 If you want busybox to talk IPv4, leave this on. 264 If you want busybox to talk IPv4, leave this on.
265 265
266config CONFIG_FEATURE_IFUPDOWN_IPV6 266config FEATURE_IFUPDOWN_IPV6
267 bool "Enable support for IPv6" 267 bool "Enable support for IPv6"
268 default n 268 default n
269 depends on CONFIG_IFUPDOWN && CONFIG_FEATURE_IPV6 269 depends on IFUPDOWN && FEATURE_IPV6
270 help 270 help
271 If you need support for IPv6, turn this option on. 271 If you need support for IPv6, turn this option on.
272 272
273config CONFIG_FEATURE_IFUPDOWN_IPX 273config FEATURE_IFUPDOWN_IPX
274 bool "Enable support for IPX" 274 bool "Enable support for IPX"
275 default n 275 default n
276 depends on CONFIG_IFUPDOWN 276 depends on IFUPDOWN
277 help 277 help
278 If this option is selected you can use busybox to work with IPX 278 If this option is selected you can use busybox to work with IPX
279 networks. 279 networks.
280 280
281config CONFIG_FEATURE_IFUPDOWN_MAPPING 281config FEATURE_IFUPDOWN_MAPPING
282 bool "Enable mapping support" 282 bool "Enable mapping support"
283 default n 283 default n
284 depends on CONFIG_IFUPDOWN 284 depends on IFUPDOWN
285 help 285 help
286 This enables support for the "mapping" stanza, unless you have 286 This enables support for the "mapping" stanza, unless you have
287 a weird network setup you don't need it. 287 a weird network setup you don't need it.
288 288
289config CONFIG_INETD 289config INETD
290 bool "inetd" 290 bool "inetd"
291 default n 291 default n
292 select CONFIG_FEATURE_SYSLOG 292 select FEATURE_SYSLOG
293 help 293 help
294 Internet superserver daemon 294 Internet superserver daemon
295 295
296config CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO 296config FEATURE_INETD_SUPPORT_BUILTIN_ECHO
297 bool "Support echo service" 297 bool "Support echo service"
298 default y 298 default y
299 depends on CONFIG_INETD 299 depends on INETD
300 help 300 help
301 Echo received data internal inetd service 301 Echo received data internal inetd service
302 302
303config CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD 303config FEATURE_INETD_SUPPORT_BUILTIN_DISCARD
304 bool "Support discard service" 304 bool "Support discard service"
305 default y 305 default y
306 depends on CONFIG_INETD 306 depends on INETD
307 help 307 help
308 Internet /dev/null internal inetd service 308 Internet /dev/null internal inetd service
309 309
310config CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME 310config FEATURE_INETD_SUPPORT_BUILTIN_TIME
311 bool "Support time service" 311 bool "Support time service"
312 default y 312 default y
313 depends on CONFIG_INETD 313 depends on INETD
314 help 314 help
315 Return 32 bit time since 1900 internal inetd service 315 Return 32 bit time since 1900 internal inetd service
316 316
317config CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME 317config FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME
318 bool "Support daytime service" 318 bool "Support daytime service"
319 default y 319 default y
320 depends on CONFIG_INETD 320 depends on INETD
321 help 321 help
322 Return human-readable time internal inetd service 322 Return human-readable time internal inetd service
323 323
324config CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN 324config FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
325 bool "Support chargen service" 325 bool "Support chargen service"
326 default y 326 default y
327 depends on CONFIG_INETD 327 depends on INETD
328 help 328 help
329 Familiar character generator internal inetd service 329 Familiar character generator internal inetd service
330 330
331config CONFIG_FEATURE_INETD_RPC 331config FEATURE_INETD_RPC
332 bool "Support RPC services" 332 bool "Support RPC services"
333 default n 333 default n
334 depends on CONFIG_INETD 334 depends on INETD
335 help 335 help
336 Suuport Sun-RPC based services 336 Suuport Sun-RPC based services
337 337
338 338
339config CONFIG_IP 339config IP
340 bool "ip" 340 bool "ip"
341 default n 341 default n
342 help 342 help
@@ -344,38 +344,38 @@ config CONFIG_IP
344 utility. You generally don't need "ip" to use busybox with 344 utility. You generally don't need "ip" to use busybox with
345 TCP/IP. 345 TCP/IP.
346 346
347config CONFIG_FEATURE_IP_ADDRESS 347config FEATURE_IP_ADDRESS
348 bool "ip address" 348 bool "ip address"
349 default y 349 default y
350 depends on CONFIG_IP 350 depends on IP
351 help 351 help
352 Address manipulation support for the "ip" applet. 352 Address manipulation support for the "ip" applet.
353 353
354config CONFIG_FEATURE_IP_LINK 354config FEATURE_IP_LINK
355 bool "ip link" 355 bool "ip link"
356 default y 356 default y
357 depends on CONFIG_IP 357 depends on IP
358 help 358 help
359 Configure network devices with "ip". 359 Configure network devices with "ip".
360 360
361config CONFIG_FEATURE_IP_ROUTE 361config FEATURE_IP_ROUTE
362 bool "ip route" 362 bool "ip route"
363 default y 363 default y
364 depends on CONFIG_IP 364 depends on IP
365 help 365 help
366 Add support for routing table management to "ip". 366 Add support for routing table management to "ip".
367 367
368config CONFIG_FEATURE_IP_TUNNEL 368config FEATURE_IP_TUNNEL
369 bool "ip tunnel" 369 bool "ip tunnel"
370 default n 370 default n
371 depends on CONFIG_IP 371 depends on IP
372 help 372 help
373 Add support for tunneling commands to "ip". 373 Add support for tunneling commands to "ip".
374 374
375config CONFIG_FEATURE_IP_SHORT_FORMS 375config FEATURE_IP_SHORT_FORMS
376 bool "Support short forms of ip commands." 376 bool "Support short forms of ip commands."
377 default n 377 default n
378 depends on CONFIG_IP 378 depends on IP
379 help 379 help
380 Also support short-form of ip <OBJECT> commands: 380 Also support short-form of ip <OBJECT> commands:
381 ip addr -> ipaddr 381 ip addr -> ipaddr
@@ -386,51 +386,51 @@ config CONFIG_FEATURE_IP_SHORT_FORMS
386 Say N unless you desparately need the short form of the ip 386 Say N unless you desparately need the short form of the ip
387 object commands. 387 object commands.
388 388
389config CONFIG_IPADDR 389config IPADDR
390 bool 390 bool
391 default y 391 default y
392 depends on CONFIG_FEATURE_IP_SHORT_FORMS && CONFIG_FEATURE_IP_ADDRESS 392 depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_ADDRESS
393 393
394config CONFIG_IPLINK 394config IPLINK
395 bool 395 bool
396 default y 396 default y
397 depends on CONFIG_FEATURE_IP_SHORT_FORMS && CONFIG_FEATURE_IP_LINK 397 depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_LINK
398 398
399config CONFIG_IPROUTE 399config IPROUTE
400 bool 400 bool
401 default y 401 default y
402 depends on CONFIG_FEATURE_IP_SHORT_FORMS && CONFIG_FEATURE_IP_ROUTE 402 depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_ROUTE
403 403
404config CONFIG_IPTUNNEL 404config IPTUNNEL
405 bool 405 bool
406 default y 406 default y
407 depends on CONFIG_FEATURE_IP_SHORT_FORMS && CONFIG_FEATURE_IP_TUNNEL 407 depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_TUNNEL
408 408
409config CONFIG_IPCALC 409config IPCALC
410 bool "ipcalc" 410 bool "ipcalc"
411 default n 411 default n
412 help 412 help
413 ipcalc takes an IP address and netmask and calculates the 413 ipcalc takes an IP address and netmask and calculates the
414 resulting broadcast, network, and host range. 414 resulting broadcast, network, and host range.
415 415
416config CONFIG_FEATURE_IPCALC_FANCY 416config FEATURE_IPCALC_FANCY
417 bool "Fancy IPCALC, more options, adds 1 kbyte" 417 bool "Fancy IPCALC, more options, adds 1 kbyte"
418 default y 418 default y
419 depends on CONFIG_IPCALC 419 depends on IPCALC
420 help 420 help
421 Adds the options hostname, prefix and silent to the output of "ipcalc". 421 Adds the options hostname, prefix and silent to the output of "ipcalc".
422 422
423config CONFIG_FEATURE_IPCALC_LONG_OPTIONS 423config FEATURE_IPCALC_LONG_OPTIONS
424 bool "Enable long options" 424 bool "Enable long options"
425 default n 425 default n
426 depends on CONFIG_IPCALC && CONFIG_GETOPT_LONG 426 depends on IPCALC && GETOPT_LONG
427 help 427 help
428 Support long options for the ipcalc applet. 428 Support long options for the ipcalc applet.
429 429
430config CONFIG_NAMEIF 430config NAMEIF
431 bool "nameif" 431 bool "nameif"
432 default n 432 default n
433 select CONFIG_FEATURE_SYSLOG 433 select FEATURE_SYSLOG
434 help 434 help
435 nameif is used to rename network interface by its MAC address. 435 nameif is used to rename network interface by its MAC address.
436 Renamed interfaces MUST be in the down state. 436 Renamed interfaces MUST be in the down state.
@@ -442,107 +442,107 @@ config CONFIG_NAMEIF
442 # Comment 442 # Comment
443 new_interface_name XX:XX:XX:XX:XX:XX 443 new_interface_name XX:XX:XX:XX:XX:XX
444 444
445config CONFIG_NC 445config NC
446 bool "nc" 446 bool "nc"
447 default n 447 default n
448 help 448 help
449 A simple Unix utility which reads and writes data across network 449 A simple Unix utility which reads and writes data across network
450 connections. 450 connections.
451 451
452config CONFIG_NC_SERVER 452config NC_SERVER
453 bool "Netcat server options (-lp)" 453 bool "Netcat server options (-lp)"
454 default n 454 default n
455 depends on CONFIG_NC 455 depends on NC
456 help 456 help
457 Allow netcat to act as a server. 457 Allow netcat to act as a server.
458 458
459config CONFIG_NC_EXTRA 459config NC_EXTRA
460 bool "Netcat extensions (-eiw and filename)" 460 bool "Netcat extensions (-eiw and filename)"
461 default n 461 default n
462 depends on CONFIG_NC 462 depends on NC
463 help 463 help
464 Add -e (support for executing the rest of the command line after 464 Add -e (support for executing the rest of the command line after
465 making or receiving a successful connection), -i (delay interval for 465 making or receiving a successful connection), -i (delay interval for
466 lines sent), -w (timeout for initial connection). 466 lines sent), -w (timeout for initial connection).
467 467
468config CONFIG_NETSTAT 468config NETSTAT
469 bool "netstat" 469 bool "netstat"
470 default n 470 default n
471 help 471 help
472 netstat prints information about the Linux networking subsystem. 472 netstat prints information about the Linux networking subsystem.
473 473
474config CONFIG_NSLOOKUP 474config NSLOOKUP
475 bool "nslookup" 475 bool "nslookup"
476 default n 476 default n
477 help 477 help
478 nslookup is a tool to query Internet name servers. 478 nslookup is a tool to query Internet name servers.
479 479
480config CONFIG_PING 480config PING
481 bool "ping" 481 bool "ping"
482 default n 482 default n
483 help 483 help
484 ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to 484 ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to
485 elicit an ICMP ECHO_RESPONSE from a host or gateway. 485 elicit an ICMP ECHO_RESPONSE from a host or gateway.
486 486
487config CONFIG_FEATURE_FANCY_PING 487config FEATURE_FANCY_PING
488 bool "Enable fancy ping output" 488 bool "Enable fancy ping output"
489 default y 489 default y
490 depends on CONFIG_PING 490 depends on PING
491 help 491 help
492 Make the output from the ping applet include statistics, and at the 492 Make the output from the ping applet include statistics, and at the
493 same time provide full support for ICMP packets. 493 same time provide full support for ICMP packets.
494 494
495config CONFIG_PING6 495config PING6
496 bool "ping6" 496 bool "ping6"
497 default n 497 default n
498 depends on CONFIG_FEATURE_IPV6 498 depends on FEATURE_IPV6
499 help 499 help
500 This will give you a ping that can talk IPv6. 500 This will give you a ping that can talk IPv6.
501 501
502config CONFIG_FEATURE_FANCY_PING6 502config FEATURE_FANCY_PING6
503 bool "Enable fancy ping6 output" 503 bool "Enable fancy ping6 output"
504 default y 504 default y
505 depends on CONFIG_PING6 505 depends on PING6
506 help 506 help
507 Make the output from the ping6 applet include statistics, and at the 507 Make the output from the ping6 applet include statistics, and at the
508 same time provide full support for ICMP packets. 508 same time provide full support for ICMP packets.
509 509
510config CONFIG_ROUTE 510config ROUTE
511 bool "route" 511 bool "route"
512 default n 512 default n
513 help 513 help
514 Route displays or manipulates the kernel's IP routing tables. 514 Route displays or manipulates the kernel's IP routing tables.
515 515
516config CONFIG_TELNET 516config TELNET
517 bool "telnet" 517 bool "telnet"
518 default n 518 default n
519 help 519 help
520 Telnet is an interface to the TELNET protocol, but is also commonly 520 Telnet is an interface to the TELNET protocol, but is also commonly
521 used to test other simple protocols. 521 used to test other simple protocols.
522 522
523config CONFIG_FEATURE_TELNET_TTYPE 523config FEATURE_TELNET_TTYPE
524 bool "Pass TERM type to remote host" 524 bool "Pass TERM type to remote host"
525 default y 525 default y
526 depends on CONFIG_TELNET 526 depends on TELNET
527 help 527 help
528 Setting this option will forward the TERM environment variable to the 528 Setting this option will forward the TERM environment variable to the
529 remote host you are connecting to. This is useful to make sure that 529 remote host you are connecting to. This is useful to make sure that
530 things like ANSI colors and other control sequences behave. 530 things like ANSI colors and other control sequences behave.
531 531
532config CONFIG_FEATURE_TELNET_AUTOLOGIN 532config FEATURE_TELNET_AUTOLOGIN
533 bool "Pass USER type to remote host" 533 bool "Pass USER type to remote host"
534 default y 534 default y
535 depends on CONFIG_TELNET 535 depends on TELNET
536 help 536 help
537 Setting this option will forward the USER environment variable to the 537 Setting this option will forward the USER environment variable to the
538 remote host you are connecting to. This is useful when you need to 538 remote host you are connecting to. This is useful when you need to
539 log into a machine without telling the username (autologin). This 539 log into a machine without telling the username (autologin). This
540 option enables `-a' and `-l USER' arguments. 540 option enables `-a' and `-l USER' arguments.
541 541
542config CONFIG_TELNETD 542config TELNETD
543 bool "telnetd" 543 bool "telnetd"
544 default n 544 default n
545 select CONFIG_FEATURE_SYSLOG 545 select FEATURE_SYSLOG
546 help 546 help
547 A daemon for the TELNET protocol, allowing you to log onto the host 547 A daemon for the TELNET protocol, allowing you to log onto the host
548 running the daemon. Please keep in mind that the TELNET protocol 548 running the daemon. Please keep in mind that the TELNET protocol
@@ -554,8 +554,8 @@ config CONFIG_TELNETD
554 554
555 Note that for busybox telnetd to work you need several things: 555 Note that for busybox telnetd to work you need several things:
556 First of all, your kernel needs: 556 First of all, your kernel needs:
557 CONFIG_UNIX98_PTYS=y 557 UNIX98_PTYS=y
558 CONFIG_DEVPTS_FS=y 558 DEVPTS_FS=y
559 559
560 Next, you need a /dev/pts directory on your root filesystem: 560 Next, you need a /dev/pts directory on your root filesystem:
561 561
@@ -572,8 +572,8 @@ config CONFIG_TELNETD
572 572
573 mount -t devpts devpts /dev/pts 573 mount -t devpts devpts /dev/pts
574 574
575 You need to be sure that Busybox has CONFIG_LOGIN and 575 You need to be sure that Busybox has LOGIN and
576 CONFIG_FEATURE_SUID enabled. And finally, you should make 576 FEATURE_SUID enabled. And finally, you should make
577 certain that Busybox has been installed setuid root: 577 certain that Busybox has been installed setuid root:
578 578
579 chown root.root /bin/busybox 579 chown root.root /bin/busybox
@@ -582,15 +582,15 @@ config CONFIG_TELNETD
582 with all that done, telnetd _should_ work.... 582 with all that done, telnetd _should_ work....
583 583
584 584
585config CONFIG_FEATURE_TELNETD_INETD 585config FEATURE_TELNETD_INETD
586 bool "Support call from inetd only" 586 bool "Support call from inetd only"
587 default n 587 default n
588 depends on CONFIG_TELNETD 588 depends on TELNETD
589 help 589 help
590 Selecting this will make telnetd only callable from inetd, 590 Selecting this will make telnetd only callable from inetd,
591 removing the standalone support. 591 removing the standalone support.
592 592
593config CONFIG_TFTP 593config TFTP
594 bool "tftp" 594 bool "tftp"
595 default n 595 default n
596 help 596 help
@@ -598,114 +598,114 @@ config CONFIG_TFTP
598 is usually used for simple, small transfers such as a root image 598 is usually used for simple, small transfers such as a root image
599 for a network-enabled bootloader. 599 for a network-enabled bootloader.
600 600
601config CONFIG_FEATURE_TFTP_GET 601config FEATURE_TFTP_GET
602 bool "Enable \"get\" command" 602 bool "Enable \"get\" command"
603 default y 603 default y
604 depends on CONFIG_TFTP 604 depends on TFTP
605 help 605 help
606 Add support for the GET command within the TFTP client. This allows 606 Add support for the GET command within the TFTP client. This allows
607 a client to retrieve a file from a TFTP server. 607 a client to retrieve a file from a TFTP server.
608 608
609config CONFIG_FEATURE_TFTP_PUT 609config FEATURE_TFTP_PUT
610 bool "Enable \"put\" command" 610 bool "Enable \"put\" command"
611 default y 611 default y
612 depends on CONFIG_TFTP 612 depends on TFTP
613 help 613 help
614 Add support for the PUT command within the TFTP client. This allows 614 Add support for the PUT command within the TFTP client. This allows
615 a client to transfer a file to a TFTP server. 615 a client to transfer a file to a TFTP server.
616 616
617config CONFIG_FEATURE_TFTP_BLOCKSIZE 617config FEATURE_TFTP_BLOCKSIZE
618 bool "Enable \"blocksize\" command" 618 bool "Enable \"blocksize\" command"
619 default n 619 default n
620 depends on CONFIG_TFTP 620 depends on TFTP
621 help 621 help
622 Allow the client to specify the desired block size for transfers. 622 Allow the client to specify the desired block size for transfers.
623 623
624config CONFIG_DEBUG_TFTP 624config DEBUG_TFTP
625 bool "Enable debug" 625 bool "Enable debug"
626 default n 626 default n
627 depends on CONFIG_TFTP 627 depends on TFTP
628 help 628 help
629 Enable debug settings for tftp. This is useful if you're running 629 Enable debug settings for tftp. This is useful if you're running
630 into problems with tftp as the protocol doesn't help you much when 630 into problems with tftp as the protocol doesn't help you much when
631 you run into problems. 631 you run into problems.
632 632
633config CONFIG_TRACEROUTE 633config TRACEROUTE
634 bool "traceroute" 634 bool "traceroute"
635 default n 635 default n
636 help 636 help
637 Utility to trace the route of IP packets 637 Utility to trace the route of IP packets
638 638
639config CONFIG_FEATURE_TRACEROUTE_VERBOSE 639config FEATURE_TRACEROUTE_VERBOSE
640 bool "Enable verbose output" 640 bool "Enable verbose output"
641 default n 641 default n
642 depends on CONFIG_TRACEROUTE 642 depends on TRACEROUTE
643 help 643 help
644 Add some verbosity to traceroute. This includes amongst other things 644 Add some verbosity to traceroute. This includes amongst other things
645 hostnames and ICMP response types. 645 hostnames and ICMP response types.
646 646
647config CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE 647config FEATURE_TRACEROUTE_SOURCE_ROUTE
648 bool "Enable loose source route" 648 bool "Enable loose source route"
649 default n 649 default n
650 depends on CONFIG_TRACEROUTE 650 depends on TRACEROUTE
651 help 651 help
652 Add option to specify a loose source route gateway 652 Add option to specify a loose source route gateway
653 (8 maximum). 653 (8 maximum).
654 654
655config CONFIG_FEATURE_TRACEROUTE_USE_ICMP 655config FEATURE_TRACEROUTE_USE_ICMP
656 bool "Use ICMP instead of UDP" 656 bool "Use ICMP instead of UDP"
657 default n 657 default n
658 depends on CONFIG_TRACEROUTE 658 depends on TRACEROUTE
659 help 659 help
660 Add feature to allow for ICMP ECHO instead of UDP datagrams. 660 Add feature to allow for ICMP ECHO instead of UDP datagrams.
661 661
662source networking/udhcp/Config.in 662source networking/udhcp/Config.in
663 663
664config CONFIG_VCONFIG 664config VCONFIG
665 bool "vconfig" 665 bool "vconfig"
666 default n 666 default n
667 help 667 help
668 Creates, removes, and configures VLAN interfaces 668 Creates, removes, and configures VLAN interfaces
669 669
670config CONFIG_WGET 670config WGET
671 bool "wget" 671 bool "wget"
672 default n 672 default n
673 help 673 help
674 wget is a utility for non-interactive download of files from HTTP, 674 wget is a utility for non-interactive download of files from HTTP,
675 HTTPS, and FTP servers. 675 HTTPS, and FTP servers.
676 676
677config CONFIG_FEATURE_WGET_STATUSBAR 677config FEATURE_WGET_STATUSBAR
678 bool "Enable a nifty process meter (+2k)" 678 bool "Enable a nifty process meter (+2k)"
679 default y 679 default y
680 depends on CONFIG_WGET 680 depends on WGET
681 help 681 help
682 Enable the transfer progress bar for wget transfers. 682 Enable the transfer progress bar for wget transfers.
683 683
684config CONFIG_FEATURE_WGET_AUTHENTICATION 684config FEATURE_WGET_AUTHENTICATION
685 bool "Enable HTTP authentication" 685 bool "Enable HTTP authentication"
686 default y 686 default y
687 depends on CONFIG_WGET 687 depends on WGET
688 help 688 help
689 Support authenticated HTTP transfers. 689 Support authenticated HTTP transfers.
690 690
691config CONFIG_FEATURE_WGET_IP6_LITERAL 691config FEATURE_WGET_IP6_LITERAL
692 bool "Enable IPv6 literal addresses" 692 bool "Enable IPv6 literal addresses"
693 default y 693 default y
694 depends on CONFIG_WGET && CONFIG_FEATURE_IPV6 694 depends on WGET && FEATURE_IPV6
695 help 695 help
696 Support IPv6 address literal notation in URLs. 696 Support IPv6 address literal notation in URLs.
697 697
698config CONFIG_FEATURE_WGET_LONG_OPTIONS 698config FEATURE_WGET_LONG_OPTIONS
699 bool "Enable long options" 699 bool "Enable long options"
700 default n 700 default n
701 depends on CONFIG_WGET && CONFIG_GETOPT_LONG 701 depends on WGET && GETOPT_LONG
702 help 702 help
703 Support long options for the wget applet. 703 Support long options for the wget applet.
704 704
705config CONFIG_ZCIP 705config ZCIP
706 bool "zcip" 706 bool "zcip"
707 default n 707 default n
708 select CONFIG_FEATURE_SYSLOG 708 select FEATURE_SYSLOG
709 help 709 help
710 ZCIP provides ZeroConf IPv4 address selection, according to RFC 3927. 710 ZCIP provides ZeroConf IPv4 address selection, according to RFC 3927.
711 It's a daemon that allocates and defends a dynamically assigned 711 It's a daemon that allocates and defends a dynamically assigned
diff --git a/networking/Kbuild b/networking/Kbuild
new file mode 100644
index 000000000..066475925
--- /dev/null
+++ b/networking/Kbuild
@@ -0,0 +1,38 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_ARPING) += arping.o
9lib-$(CONFIG_DNSD) += dnsd.o
10lib-$(CONFIG_ETHER_WAKE) += ether-wake.o
11lib-$(CONFIG_FAKEIDENTD) += fakeidentd.o
12lib-$(CONFIG_FTPGET) += ftpgetput.o
13lib-$(CONFIG_FTPPUT) += ftpgetput.o
14lib-$(CONFIG_HOSTNAME) += hostname.o
15lib-$(CONFIG_HTTPD) += httpd.o
16lib-$(CONFIG_IFCONFIG) += ifconfig.o interface.o
17lib-$(CONFIG_IFUPDOWN) += ifupdown.o
18lib-$(CONFIG_INETD) += inetd.o
19lib-$(CONFIG_IP) += ip.o
20lib-$(CONFIG_IPCALC) += ipcalc.o
21lib-$(CONFIG_IPADDR) += ipaddr.o
22lib-$(CONFIG_IPLINK) += iplink.o
23lib-$(CONFIG_IPROUTE) += iproute.o
24lib-$(CONFIG_IPTUNNEL) += iptunnel.o
25lib-$(CONFIG_NAMEIF) += nameif.o
26lib-$(CONFIG_NC) += nc.o
27lib-$(CONFIG_NETSTAT) += netstat.o
28lib-$(CONFIG_NSLOOKUP) += nslookup.o
29lib-$(CONFIG_PING) += ping.o
30lib-$(CONFIG_PING6) += ping6.o
31lib-$(CONFIG_ROUTE) += route.o
32lib-$(CONFIG_TELNET) += telnet.o
33lib-$(CONFIG_TELNETD) += telnetd.o
34lib-$(CONFIG_TFTP) += tftp.o
35lib-$(CONFIG_TRACEROUTE) += traceroute.o
36lib-$(CONFIG_VCONFIG) += vconfig.o
37lib-$(CONFIG_WGET) += wget.o
38lib-$(CONFIG_ZCIP) += zcip.o
diff --git a/networking/Makefile b/networking/Makefile
deleted file mode 100644
index c3f2d79c9..000000000
--- a/networking/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/networking
14NETWORKING_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/networking/Makefile.in b/networking/Makefile.in
deleted file mode 100644
index 650fc1a4a..000000000
--- a/networking/Makefile.in
+++ /dev/null
@@ -1,70 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7NETWORKING_AR:=networking.a
8ifndef $(NETWORKING_DIR)
9NETWORKING_DIR:=$(top_builddir)/networking/
10endif
11srcdir=$(top_srcdir)/networking
12
13NETWORKING-y:=
14NETWORKING-$(CONFIG_ARPING) += arping.o
15NETWORKING-$(CONFIG_DNSD) += dnsd.o
16NETWORKING-$(CONFIG_ETHER_WAKE) += ether-wake.o
17NETWORKING-$(CONFIG_FAKEIDENTD) += fakeidentd.o
18NETWORKING-$(CONFIG_FTPGET) += ftpgetput.o
19NETWORKING-$(CONFIG_FTPPUT) += ftpgetput.o
20NETWORKING-$(CONFIG_HOSTNAME) += hostname.o
21NETWORKING-$(CONFIG_HTTPD) += httpd.o
22NETWORKING-$(CONFIG_IFCONFIG) += ifconfig.o interface.o
23NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o
24NETWORKING-$(CONFIG_INETD) += inetd.o
25NETWORKING-$(CONFIG_IP) += ip.o
26NETWORKING-$(CONFIG_IPCALC) += ipcalc.o
27NETWORKING-$(CONFIG_IPADDR) += ipaddr.o
28NETWORKING-$(CONFIG_IPLINK) += iplink.o
29NETWORKING-$(CONFIG_IPROUTE) += iproute.o
30NETWORKING-$(CONFIG_IPTUNNEL) += iptunnel.o
31NETWORKING-$(CONFIG_NAMEIF) += nameif.o
32NETWORKING-$(CONFIG_NC) += nc.o
33NETWORKING-$(CONFIG_NETSTAT) += netstat.o
34NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o
35NETWORKING-$(CONFIG_PING) += ping.o
36NETWORKING-$(CONFIG_PING6) += ping6.o
37NETWORKING-$(CONFIG_ROUTE) += route.o
38NETWORKING-$(CONFIG_TELNET) += telnet.o
39NETWORKING-$(CONFIG_TELNETD) += telnetd.o
40NETWORKING-$(CONFIG_TFTP) += tftp.o
41NETWORKING-$(CONFIG_TRACEROUTE) += traceroute.o
42NETWORKING-$(CONFIG_VCONFIG) += vconfig.o
43NETWORKING-$(CONFIG_WGET) += wget.o
44NETWORKING-$(CONFIG_ZCIP) += zcip.o
45
46NETWORKING-y:=$(sort $(NETWORKING-y))
47ifneq ($(strip $(NETWORKING-y)),)
48libraries-y+=$(NETWORKING_DIR)$(NETWORKING_AR)
49endif
50
51NETWORKING_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(NETWORKING-y))
52NETWORKING_SRC-a:=$(wildcard $(srcdir)/*.c)
53APPLET_SRC-y+=$(NETWORKING_SRC-y)
54APPLET_SRC-a+=$(NETWORKING_SRC-a)
55
56LIBRARY_DEFINE-y+= -I$(top_srcdir)/networking
57LIBRARY_DEFINE-a+= -I$(top_srcdir)/networking
58
59needcrypt-y:=
60needcrypt-$(CONFIG_FEATURE_HTTPD_AUTH_MD5) := y
61
62ifeq ($(needcrypt-y),y)
63 LIBRARIES := -lcrypt $(filter-out -lcrypt,$(LIBRARIES))
64endif
65
66$(NETWORKING_DIR)$(NETWORKING_AR): $(patsubst %,$(NETWORKING_DIR)%, $(NETWORKING-y))
67 $(do_ar)
68
69$(NETWORKING_DIR)%.o: $(srcdir)/%.c
70 $(compile.c)
diff --git a/networking/libiproute/Kbuild b/networking/libiproute/Kbuild
new file mode 100644
index 000000000..476374e19
--- /dev/null
+++ b/networking/libiproute/Kbuild
@@ -0,0 +1,58 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6#
7
8lib-y:=
9lib-$(CONFIG_IP) += \
10 ip_parse_common_args.o \
11 ipaddress.o \
12 iplink.o \
13 iproute.o \
14 iptunnel.o \
15 libnetlink.o \
16 ll_addr.o \
17 ll_map.o \
18 ll_proto.o \
19 ll_types.o \
20 rt_names.o \
21 rtm_map.o \
22 utils.o
23
24lib-$(CONFIG_IPADDR) += \
25 ip_parse_common_args.o \
26 ipaddress.o \
27 libnetlink.o \
28 ll_addr.o \
29 ll_map.o \
30 ll_types.o \
31 rt_names.o \
32 utils.o
33
34lib-$(CONFIG_IPLINK) += \
35 ip_parse_common_args.o \
36 ipaddress.o \
37 iplink.o \
38 libnetlink.o \
39 ll_addr.o \
40 ll_map.o \
41 ll_types.o \
42 rt_names.o \
43 utils.o
44
45lib-$(CONFIG_IPROUTE) += \
46 ip_parse_common_args.o \
47 iproute.o \
48 libnetlink.o \
49 ll_map.o \
50 rt_names.o \
51 rtm_map.o \
52 utils.o
53
54lib-$(CONFIG_IPTUNNEL) += \
55 ip_parse_common_args.o \
56 iptunnel.o \
57 rt_names.o \
58 utils.o
diff --git a/networking/libiproute/Makefile b/networking/libiproute/Makefile
deleted file mode 100644
index 2fafae738..000000000
--- a/networking/libiproute/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19
20ifndef top_srcdir
21top_srcdir=../..
22endif
23ifndef top_builddir
24top_builddir=../..
25endif
26srcdir=$(top_srcdir)/networking/libiproute
27LIBIPROUTE_DIR:=./
28include $(top_srcdir)/Rules.mak
29include $(top_builddir)/.config
30include Makefile.in
31all: $(libraries-y)
32-include $(top_builddir)/.depend
33
34clean:
35 rm -f *.o *.a $(AR_TARGET)
36
diff --git a/networking/libiproute/Makefile.in b/networking/libiproute/Makefile.in
deleted file mode 100644
index f713502b3..000000000
--- a/networking/libiproute/Makefile.in
+++ /dev/null
@@ -1,83 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6#
7
8LIBIPROUTE_AR:=libiproute.a
9ifndef $(LIBIPROUTE_DIR)
10LIBIPROUTE_DIR:=$(top_builddir)/networking/libiproute
11endif
12srcdir=$(top_srcdir)/networking/libiproute
13
14LIBIPROUTE-y:=
15LIBIPROUTE-$(CONFIG_IP) += \
16 ip_parse_common_args.o \
17 ipaddress.o \
18 iplink.o \
19 iproute.o \
20 iptunnel.o \
21 libnetlink.o \
22 ll_addr.o \
23 ll_map.o \
24 ll_proto.o \
25 ll_types.o \
26 rt_names.o \
27 rtm_map.o \
28 utils.o
29
30LIBIPROUTE-$(CONFIG_IPADDR) += \
31 ip_parse_common_args.o \
32 ipaddress.o \
33 libnetlink.o \
34 ll_addr.o \
35 ll_map.o \
36 ll_types.o \
37 rt_names.o \
38 utils.o
39
40LIBIPROUTE-$(CONFIG_IPLINK) += \
41 ip_parse_common_args.o \
42 ipaddress.o \
43 iplink.o \
44 libnetlink.o \
45 ll_addr.o \
46 ll_map.o \
47 ll_types.o \
48 rt_names.o \
49 utils.o
50
51LIBIPROUTE-$(CONFIG_IPROUTE) += \
52 ip_parse_common_args.o \
53 iproute.o \
54 libnetlink.o \
55 ll_map.o \
56 rt_names.o \
57 rtm_map.o \
58 utils.o
59
60LIBIPROUTE-$(CONFIG_IPTUNNEL) += \
61 ip_parse_common_args.o \
62 iptunnel.o \
63 rt_names.o \
64 utils.o
65
66LIBIPROUTE-y:=$(sort $(LIBIPROUTE-y))
67
68LIBIPROUTE_SRC-y:=$(patsubst %,$(srcdir)/%,$(subst .o,.c,$(LIBIPROUTE-y)))
69LIBIPROUTE_SRC-a:=$(wildcard $(srcdir)/*.c)
70LIBRARY_SRC-y+=$(LIBIPROUTE_SRC-y)
71LIBRARY_SRC-a+=$(LIBIPROUTE_SRC-a)
72
73LIBIPROUTE-obj:=$(LIBIPROUTE_DIR)/$(LIBIPROUTE_AR)
74
75ifneq ($(strip $(LIBIPROUTE-y)),)
76libraries-y+=$(LIBIPROUTE_DIR)/$(LIBIPROUTE_AR)
77endif
78
79$(LIBIPROUTE_DIR)/$(LIBIPROUTE_AR): $(patsubst %,$(LIBIPROUTE_DIR)/%,$(LIBIPROUTE-y))
80 $(do_ar)
81
82$(LIBIPROUTE_DIR)/%.o: $(srcdir)/%.c
83 $(compile.c)
diff --git a/networking/udhcp/Config.in b/networking/udhcp/Config.in
index f01340192..13dbcee9c 100644
--- a/networking/udhcp/Config.in
+++ b/networking/udhcp/Config.in
@@ -3,7 +3,7 @@
3# see scripts/kbuild/config-language.txt. 3# see scripts/kbuild/config-language.txt.
4# 4#
5 5
6config CONFIG_APP_UDHCPD 6config APP_UDHCPD
7 bool "udhcp Server (udhcpd)" 7 bool "udhcp Server (udhcpd)"
8 default n 8 default n
9 help 9 help
@@ -12,10 +12,10 @@ config CONFIG_APP_UDHCPD
12 12
13 See http://udhcp.busybox.net for further details. 13 See http://udhcp.busybox.net for further details.
14 14
15config CONFIG_APP_DUMPLEASES 15config APP_DUMPLEASES
16 bool "Lease display utility (dumpleases)" 16 bool "Lease display utility (dumpleases)"
17 default n 17 default n
18 depends on CONFIG_APP_UDHCPD 18 depends on APP_UDHCPD
19 help 19 help
20 dumpleases displays the leases written out by the udhcpd server. 20 dumpleases displays the leases written out by the udhcpd server.
21 Lease times are stored in the file by time remaining in lease, or 21 Lease times are stored in the file by time remaining in lease, or
@@ -23,7 +23,7 @@ config CONFIG_APP_DUMPLEASES
23 23
24 See http://udhcp.busybox.net for further details. 24 See http://udhcp.busybox.net for further details.
25 25
26config CONFIG_APP_UDHCPC 26config APP_UDHCPC
27 bool "udhcp Client (udhcpc)" 27 bool "udhcp Client (udhcpc)"
28 default n 28 default n
29 help 29 help
@@ -35,21 +35,21 @@ config CONFIG_APP_UDHCPC
35 35
36 See http://udhcp.busybox.net for further details. 36 See http://udhcp.busybox.net for further details.
37 37
38config CONFIG_FEATURE_UDHCP_SYSLOG 38config FEATURE_UDHCP_SYSLOG
39 bool "Log udhcp messages to syslog" 39 bool "Log udhcp messages to syslog"
40 default n 40 default n
41 depends on CONFIG_APP_UDHCPD || CONFIG_APP_UDHCPC 41 depends on APP_UDHCPD || APP_UDHCPC
42 select CONFIG_FEATURE_SYSLOG 42 select FEATURE_SYSLOG
43 help 43 help
44 If not daemonized, udhcpd prints its messages to stdout/stderr. 44 If not daemonized, udhcpd prints its messages to stdout/stderr.
45 If this option is selected, it will also log them to syslog. 45 If this option is selected, it will also log them to syslog.
46 46
47 See http://udhcp.busybox.net for further details. 47 See http://udhcp.busybox.net for further details.
48 48
49config CONFIG_FEATURE_UDHCP_DEBUG 49config FEATURE_UDHCP_DEBUG
50 bool "Compile udhcp with noisy debugging messages" 50 bool "Compile udhcp with noisy debugging messages"
51 default n 51 default n
52 depends on CONFIG_APP_UDHCPD || CONFIG_APP_UDHCPC 52 depends on APP_UDHCPD || APP_UDHCPC
53 help 53 help
54 If selected, udhcpd will output extra debugging output. If using 54 If selected, udhcpd will output extra debugging output. If using
55 this option, compile uDHCP with "-g", and do not fork the daemon to 55 this option, compile uDHCP with "-g", and do not fork the daemon to
diff --git a/networking/udhcp/Kbuild b/networking/udhcp/Kbuild
new file mode 100644
index 000000000..90047c174
--- /dev/null
+++ b/networking/udhcp/Kbuild
@@ -0,0 +1,17 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6#
7
8lib-y:=
9lib-$(CONFIG_APP_UDHCPC) += common.o options.o packet.o pidfile.o \
10 signalpipe.o socket.o
11lib-$(CONFIG_APP_UDHCPD) += common.o options.o packet.o pidfile.o \
12 signalpipe.o socket.o
13lib-$(CONFIG_APP_UDHCPC) += dhcpc.o clientpacket.o clientsocket.o \
14 script.o
15lib-$(CONFIG_APP_UDHCPD) += dhcpd.o arpping.o files.o leases.o \
16 serverpacket.o static_leases.o
17lib-$(CONFIG_APP_DUMPLEASES) += dumpleases.o
diff --git a/networking/udhcp/Makefile b/networking/udhcp/Makefile
deleted file mode 100644
index 23131f8f0..000000000
--- a/networking/udhcp/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
6
7#ifndef top_srcdir
8#top_srcdir=../..
9#endif
10#ifndef top_builddir
11#top_builddir=../..
12#endif
13srcdir=$(top_srcdir)/networking/udhcp
14UDHCP_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/networking/udhcp/Makefile.in b/networking/udhcp/Makefile.in
deleted file mode 100644
index cbc6f2b39..000000000
--- a/networking/udhcp/Makefile.in
+++ /dev/null
@@ -1,53 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6#
7
8UDHCP_AR:=udhcp.a
9ifndef $(UDHCP_DIR)
10UDHCP_DIR:=$(top_builddir)/networking/udhcp/
11endif
12srcdir=$(top_srcdir)/networking/udhcp
13
14#ok, so I forgot how to do an or, but this is a quick and dirty hack
15ifeq ($(strip $(CONFIG_APP_UDHCPC)),y)
16CONFIG_UDHCP_SHARED=y
17else
18ifeq ($(strip $(CONFIG_APP_UDHCPD)),y)
19CONFIG_UDHCP_SHARED=y
20else
21CONFIG_UDHCP_SHARED=n
22endif
23endif
24
25UDHCP-y:=
26UDHCP-$(CONFIG_UDHCP_SHARED) += common.c options.c packet.c pidfile.c \
27 signalpipe.c socket.c
28UDHCP-$(CONFIG_APP_UDHCPC) += dhcpc.c clientpacket.c clientsocket.c \
29 script.c
30UDHCP-$(CONFIG_APP_UDHCPD) += dhcpd.c arpping.c files.c leases.c \
31 serverpacket.c static_leases.c
32UDHCP-$(CONFIG_APP_DUMPLEASES) += dumpleases.c
33UDHCP_OBJS:=$(patsubst %.c,$(UDHCP_DIR)%.o, $(UDHCP-y))
34
35ifneq ($(strip $(UDHCP-y)),)
36libraries-y+=$(UDHCP_DIR)$(UDHCP_AR)
37endif
38
39UDHCP-y:=$(patsubst %,$(srcdir)/%,$(UDHCP-y))
40UDHCP-a:=$(wildcard $(srcdir)/*.c)
41APPLET_SRC-y+=$(UDHCP-y)
42APPLET_SRC-a+=$(UDHCP-a)
43
44UDHCP_INCLUDES:=$(srcdir)
45
46APPLETS_DEFINE-y+= -I$(UDHCP_INCLUDES)
47APPLETS_DEFINE-a+= -I$(UDHCP_INCLUDES)
48
49$(UDHCP_DIR)$(UDHCP_AR): $(UDHCP_OBJS)
50 $(do_ar)
51
52$(UDHCP_OBJS): $(UDHCP_DIR)%.o : $(srcdir)/%.c
53 $(compile.c)
diff --git a/procps/Config.in b/procps/Config.in
index 2d4ad3bd4..20d5f9bf2 100644
--- a/procps/Config.in
+++ b/procps/Config.in
@@ -5,7 +5,7 @@
5 5
6menu "Process Utilities" 6menu "Process Utilities"
7 7
8config CONFIG_FREE 8config FREE
9 bool "free" 9 bool "free"
10 default n 10 default n
11 help 11 help
@@ -13,7 +13,7 @@ config CONFIG_FREE
13 memory in the system, as well as the buffers used by the kernel. 13 memory in the system, as well as the buffers used by the kernel.
14 The shared memory column should be ignored; it is obsolete. 14 The shared memory column should be ignored; it is obsolete.
15 15
16config CONFIG_FUSER 16config FUSER
17 bool "fuser" 17 bool "fuser"
18 default n 18 default n
19 help 19 help
@@ -21,7 +21,7 @@ config CONFIG_FUSER
21 file open. fuser can also list all PIDs that have a given network 21 file open. fuser can also list all PIDs that have a given network
22 (TCP or UDP) port open. 22 (TCP or UDP) port open.
23 23
24config CONFIG_KILL 24config KILL
25 bool "kill" 25 bool "kill"
26 default n 26 default n
27 help 27 help
@@ -29,86 +29,86 @@ config CONFIG_KILL
29 process or process group. If no signal is specified, the TERM 29 process or process group. If no signal is specified, the TERM
30 signal is sent. 30 signal is sent.
31 31
32config CONFIG_KILLALL 32config KILLALL
33 bool "killall" 33 bool "killall"
34 default n 34 default n
35 depends on CONFIG_KILL 35 depends on KILL
36 help 36 help
37 killall sends a signal to all processes running any of the 37 killall sends a signal to all processes running any of the
38 specified commands. If no signal name is specified, SIGTERM is 38 specified commands. If no signal name is specified, SIGTERM is
39 sent. 39 sent.
40 40
41config CONFIG_KILLALL5 41config KILLALL5
42 bool "killall5" 42 bool "killall5"
43 default n 43 default n
44 depends on CONFIG_KILL 44 depends on KILL
45 45
46config CONFIG_PIDOF 46config PIDOF
47 bool "pidof" 47 bool "pidof"
48 default n 48 default n
49 help 49 help
50 Pidof finds the process id's (pids) of the named programs. It prints 50 Pidof finds the process id's (pids) of the named programs. It prints
51 those id's on the standard output. 51 those id's on the standard output.
52 52
53config CONFIG_FEATURE_PIDOF_SINGLE 53config FEATURE_PIDOF_SINGLE
54 bool "Enable argument for single shot (-s)" 54 bool "Enable argument for single shot (-s)"
55 default n 55 default n
56 depends on CONFIG_PIDOF 56 depends on PIDOF
57 help 57 help
58 Support argument '-s' for returning only the first pid found. 58 Support argument '-s' for returning only the first pid found.
59 59
60config CONFIG_FEATURE_PIDOF_OMIT 60config FEATURE_PIDOF_OMIT
61 bool "Enable argument for omitting pids (-o)" 61 bool "Enable argument for omitting pids (-o)"
62 default n 62 default n
63 depends on CONFIG_PIDOF 63 depends on PIDOF
64 help 64 help
65 Support argument '-o' for omitting the given pids in output. 65 Support argument '-o' for omitting the given pids in output.
66 The special pid %PPID can be used to name the parent process 66 The special pid %PPID can be used to name the parent process
67 of the pidof, in other words the calling shell or shell script. 67 of the pidof, in other words the calling shell or shell script.
68 68
69config CONFIG_PS 69config PS
70 bool "ps" 70 bool "ps"
71 default n 71 default n
72 help 72 help
73 ps gives a snapshot of the current processes. 73 ps gives a snapshot of the current processes.
74 74
75config CONFIG_FEATURE_PS_WIDE 75config FEATURE_PS_WIDE
76 bool "Enable argument for wide output (-w)" 76 bool "Enable argument for wide output (-w)"
77 default n 77 default n
78 depends on CONFIG_PS 78 depends on PS
79 help 79 help
80 Support argument 'w' for wide output. 80 Support argument 'w' for wide output.
81 If given once, 132 chars are printed and given more than 81 If given once, 132 chars are printed and given more than
82 one, the length is unlimited. 82 one, the length is unlimited.
83 83
84config CONFIG_RENICE 84config RENICE
85 bool "renice" 85 bool "renice"
86 default n 86 default n
87 help 87 help
88 Renice alters the scheduling priority of one or more running 88 Renice alters the scheduling priority of one or more running
89 processes. 89 processes.
90 90
91config CONFIG_BB_SYSCTL 91config BB_SYSCTL
92 bool "sysctl" 92 bool "sysctl"
93 default n 93 default n
94 help 94 help
95 Configure kernel parameters at runtime. 95 Configure kernel parameters at runtime.
96 96
97config CONFIG_TOP 97config TOP
98 bool "top" 98 bool "top"
99 default n 99 default n
100 help 100 help
101 The top program provides a dynamic real-time view of a running 101 The top program provides a dynamic real-time view of a running
102 system. 102 system.
103 103
104config CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE 104config FEATURE_TOP_CPU_USAGE_PERCENTAGE
105 bool "Support showing CPU usage percentage (add 2k bytes)" 105 bool "Support showing CPU usage percentage (add 2k bytes)"
106 default y 106 default y
107 depends on CONFIG_TOP 107 depends on TOP
108 help 108 help
109 Make top display CPU usage. 109 Make top display CPU usage.
110 110
111config CONFIG_UPTIME 111config UPTIME
112 bool "uptime" 112 bool "uptime"
113 default n 113 default n
114 help 114 help
diff --git a/procps/Kbuild b/procps/Kbuild
new file mode 100644
index 000000000..6a9a86637
--- /dev/null
+++ b/procps/Kbuild
@@ -0,0 +1,16 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_FREE) += free.o
9lib-$(CONFIG_KILL) += kill.o
10lib-$(CONFIG_PIDOF) += pidof.o
11lib-$(CONFIG_PS) += ps.o
12lib-$(CONFIG_RENICE) += renice.o
13lib-$(CONFIG_BB_SYSCTL) += sysctl.o
14lib-$(CONFIG_TOP) += top.o
15lib-$(CONFIG_UPTIME) += uptime.o
16lib-$(CONFIG_FUSER) += fuser.o
diff --git a/procps/Makefile b/procps/Makefile
deleted file mode 100644
index 1db6ffa58..000000000
--- a/procps/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/procps
14PROCPS_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/procps/Makefile.in b/procps/Makefile.in
deleted file mode 100644
index 261c49b02..000000000
--- a/procps/Makefile.in
+++ /dev/null
@@ -1,37 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7PROCPS_AR:=procps.a
8ifndef $(PROCPS_DIR)
9PROCPS_DIR:=$(top_builddir)/procps/
10endif
11srcdir=$(top_srcdir)/procps
12
13PROCPS-y:=
14PROCPS-$(CONFIG_FREE) += free.o
15PROCPS-$(CONFIG_KILL) += kill.o
16PROCPS-$(CONFIG_PIDOF) += pidof.o
17PROCPS-$(CONFIG_PS) += ps.o
18PROCPS-$(CONFIG_RENICE) += renice.o
19PROCPS-$(CONFIG_BB_SYSCTL) += sysctl.o
20PROCPS-$(CONFIG_TOP) += top.o
21PROCPS-$(CONFIG_UPTIME) += uptime.o
22PROCPS-$(CONFIG_FUSER) += fuser.o
23
24ifneq ($(strip $(PROCPS-y)),)
25libraries-y+=$(PROCPS_DIR)$(PROCPS_AR)
26endif
27
28PROCPS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(PROCPS-y))
29PROCPS_SRC-a:=$(wildcard $(srcdir)/*.c)
30APPLET_SRC-y+=$(PROCPS_SRC-y)
31APPLET_SRC-a+=$(PROCPS_SRC-a)
32
33$(PROCPS_DIR)$(PROCPS_AR): $(patsubst %,$(PROCPS_DIR)%, $(PROCPS-y))
34 $(do_ar)
35
36$(PROCPS_DIR)%.o: $(srcdir)/%.c
37 $(compile.c)
diff --git a/runit/Config.in b/runit/Config.in
index 073ca1425..b90b0232e 100644
--- a/runit/Config.in
+++ b/runit/Config.in
@@ -5,30 +5,30 @@
5 5
6menu "Runit Utilities" 6menu "Runit Utilities"
7 7
8config CONFIG_CHPST 8config CHPST
9 bool "chpst" 9 bool "chpst"
10 default n 10 default n
11 help 11 help
12 chpst changes the process state according to the given options, and 12 chpst changes the process state according to the given options, and
13 execs specified program. 13 execs specified program.
14 14
15config CONFIG_SETUIDGID 15config SETUIDGID
16 bool "setuidgid" 16 bool "setuidgid"
17 help 17 help
18 Sets soft resource limits as specified by options 18 Sets soft resource limits as specified by options
19 19
20config CONFIG_ENVUIDGID 20config ENVUIDGID
21 bool "envuidgid" 21 bool "envuidgid"
22 help 22 help
23 Sets $UID to account's uid and $GID to account's gid 23 Sets $UID to account's uid and $GID to account's gid
24 24
25config CONFIG_ENVDIR 25config ENVDIR
26 bool "envdir" 26 bool "envdir"
27 help 27 help
28 Sets various environment variables as specified by files 28 Sets various environment variables as specified by files
29 in the given directory 29 in the given directory
30 30
31config CONFIG_SOFTLIMIT 31config SOFTLIMIT
32 bool "softlimit" 32 bool "softlimit"
33 help 33 help
34 Sets soft resource limits as specified by options 34 Sets soft resource limits as specified by options
diff --git a/runit/Kbuild b/runit/Kbuild
new file mode 100644
index 000000000..9fee84224
--- /dev/null
+++ b/runit/Kbuild
@@ -0,0 +1,8 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_CHPST) += chpst.o uidgid.o
diff --git a/runit/Makefile b/runit/Makefile
deleted file mode 100644
index be65856fe..000000000
--- a/runit/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/runit
14RUNIT_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/runit/Makefile.in b/runit/Makefile.in
deleted file mode 100644
index d8cea10c2..000000000
--- a/runit/Makefile.in
+++ /dev/null
@@ -1,42 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7RUNIT_AR:=runit.a
8ifndef RUNIT_DIR
9RUNIT_DIR:=$(top_builddir)/runit/
10endif
11srcdir=$(top_srcdir)/runit
12
13#unix_a:=buffer.o \
14#buffer_get.o buffer_put.o buffer_read.o buffer_write.o coe.o \
15#fd_copy.o fd_move.o fifo.o lock_ex.o lock_exnb.o \
16#ndelay_off.o ndelay_on.o open_append.o open_read.o \
17#open_trunc.o open_write.o openreadclose.o pathexec_env.o \
18#pathexec_run.o prot.o readclose.o seek_set.o sig.o \
19#sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \
20#stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \
21#stralloc_pend.o wait_nohang.o \
22#wait_pid.o
23
24RUNIT-y:=
25RUNIT-$(CONFIG_CHPST) += chpst.o uidgid.o
26
27RUNIT-y:=$(sort $(RUNIT-y))
28
29ifneq ($(strip $(RUNIT-y)),)
30libraries-y+=$(RUNIT_DIR)$(RUNIT_AR)
31endif
32
33RUNIT_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(RUNIT-y))
34RUNIT_SRC-a:=$(wildcard $(srcdir)/*.c)
35APPLET_SRC-y+=$(RUNIT_SRC-y)
36APPLET_SRC-a+=$(RUNIT_SRC-a)
37
38$(RUNIT_DIR)$(RUNIT_AR): $(patsubst %,$(RUNIT_DIR)%, $(RUNIT-y))
39 $(do_ar)
40
41$(RUNIT_DIR)%.o: $(srcdir)/%.c
42 $(compile.c)
diff --git a/scripts/Kbuild b/scripts/Kbuild
new file mode 100644
index 000000000..80c60733e
--- /dev/null
+++ b/scripts/Kbuild
@@ -0,0 +1,11 @@
1###
2# scripts contains sources for various helper programs used throughout
3# the kernel for the build process.
4# ---------------------------------------------------------------------------
5
6hostprogs-y += usage
7
8always := $(hostprogs-y)
9
10# Let clean descend into subdirs
11subdir- += basic kconfig
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
new file mode 100644
index 000000000..b0d067be7
--- /dev/null
+++ b/scripts/Kbuild.include
@@ -0,0 +1,148 @@
1####
2# kbuild: Generic definitions
3
4# Convinient variables
5comma := ,
6squote := '
7empty :=
8space := $(empty) $(empty)
9
10###
11# The temporary file to save gcc -MD generated dependencies must not
12# contain a comma
13depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
14
15###
16# Escape single quote for use in echo statements
17escsq = $(subst $(squote),'\$(squote)',$1)
18
19###
20# filechk is used to check if the content of a generated file is updated.
21# Sample usage:
22# define filechk_sample
23# echo $KERNELRELEASE
24# endef
25# version.h : Makefile
26# $(call filechk,sample)
27# The rule defined shall write to stdout the content of the new file.
28# The existing file will be compared with the new one.
29# - If no file exist it is created
30# - If the content differ the new file is used
31# - If they are equal no change, and no timestamp update
32# - stdin is piped in from the first prerequisite ($<) so one has
33# to specify a valid file as first prerequisite (often the kbuild file)
34define filechk
35 $(Q)set -e; \
36 echo ' CHK $@'; \
37 mkdir -p $(dir $@); \
38 $(filechk_$(1)) < $< > $@.tmp; \
39 if [ -r $@ ] && cmp -s $@ $@.tmp; then \
40 rm -f $@.tmp; \
41 else \
42 echo ' UPD $@'; \
43 mv -f $@.tmp $@; \
44 fi
45endef
46
47######
48# gcc support functions
49# See documentation in Documentation/kbuild/makefiles.txt
50
51# as-option
52# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
53
54as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
55 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
56 else echo "$(2)"; fi ;)
57
58# cc-option
59# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
60
61cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
62 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
63
64# cc-option-yn
65# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
66cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
67 > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
68
69# cc-option-align
70# Prefix align with either -falign or -malign
71cc-option-align = $(subst -functions=0,,\
72 $(call cc-option,-falign-functions=0,-malign-functions=0))
73
74# cc-version
75# Usage gcc-ver := $(call cc-version, $(CC))
76cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
77 $(if $(1), $(1), $(CC)))
78
79# cc-ifversion
80# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
81cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \
82 echo $(3); fi;)
83
84###
85# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
86# Usage:
87# $(Q)$(MAKE) $(build)=dir
88build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
89
90# Prefix -I with $(srctree) if it is not an absolute path
91addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
92# Find all -I options and call addtree
93flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
94
95# If quiet is set, only print short version of command
96cmd = @$(echo-cmd) $(cmd_$(1))
97
98# Add $(obj)/ for paths that is not absolute
99objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
100
101###
102# if_changed - execute command if any prerequisite is newer than
103# target, or command line has changed
104# if_changed_dep - as if_changed, but uses fixdep to reveal dependencies
105# including used config symbols
106# if_changed_rule - as if_changed but execute rule instead
107# See Documentation/kbuild/makefiles.txt for more info
108
109ifneq ($(KBUILD_NOCMDDEP),1)
110# Check if both arguments has same arguments. Result in empty string if equal
111# User may override this check using make KBUILD_NOCMDDEP=1
112arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) )
113endif
114
115# echo command. Short version is $(quiet) equals quiet, otherwise full command
116echo-cmd = $(if $($(quiet)cmd_$(1)), \
117 echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
118
119make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
120
121# function to only execute the passed command if necessary
122# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
123# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
124#
125if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
126 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
127 @set -e; \
128 $(echo-cmd) $(cmd_$(1)); \
129 echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
130
131# execute the command and also postprocess generated .d dependencies
132# file
133if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
134 $(filter-out FORCE $(wildcard $^),$^) \
135 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
136 @set -e; \
137 $(echo-cmd) $(cmd_$(1)); \
138 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
139 rm -f $(depfile); \
140 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
141
142# Usage: $(call if_changed_rule,foo)
143# will check if $(cmd_foo) changed, or any of the prequisites changed,
144# and if so will execute $(rule_foo)
145if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
146 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
147 @set -e; \
148 $(rule_$(1)))
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
new file mode 100644
index 000000000..e48e60da3
--- /dev/null
+++ b/scripts/Makefile.build
@@ -0,0 +1,338 @@
1# ==========================================================================
2# Building
3# ==========================================================================
4
5src := $(obj)
6
7PHONY := __build
8__build:
9
10# Read .config if it exist, otherwise ignore
11-include .config
12
13include scripts/Kbuild.include
14
15# The filename Kbuild has precedence over Makefile
16kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
17include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
18
19include scripts/Makefile.lib
20
21ifdef host-progs
22ifneq ($(hostprogs-y),$(host-progs))
23$(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!)
24hostprogs-y += $(host-progs)
25endif
26endif
27
28# Do not include host rules unles needed
29ifneq ($(hostprogs-y)$(hostprogs-m),)
30include scripts/Makefile.host
31endif
32
33ifneq ($(KBUILD_SRC),)
34# Create output directory if not already present
35_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
36
37# Create directories for object files if directory does not exist
38# Needed when obj-y := dir/file.o syntax is used
39_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
40endif
41
42
43ifdef EXTRA_TARGETS
44$(warning kbuild: $(obj)/Makefile - Usage of EXTRA_TARGETS is obsolete in 2.6. Please fix!)
45endif
46
47ifdef build-targets
48$(warning kbuild: $(obj)/Makefile - Usage of build-targets is obsolete in 2.6. Please fix!)
49endif
50
51ifdef export-objs
52$(warning kbuild: $(obj)/Makefile - Usage of export-objs is obsolete in 2.6. Please fix!)
53endif
54
55ifdef O_TARGET
56$(warning kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete in 2.6. Please fix!)
57endif
58
59ifdef L_TARGET
60$(error kbuild: $(obj)/Makefile - Use of L_TARGET is replaced by lib-y in 2.6. Please fix!)
61endif
62
63ifdef list-multi
64$(warning kbuild: $(obj)/Makefile - list-multi := $(list-multi) is obsolete in 2.6. Please fix!)
65endif
66
67ifndef obj
68$(warning kbuild: Makefile.build is included improperly)
69endif
70
71# ===========================================================================
72
73ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),)
74lib-target := $(obj)/lib.a
75endif
76
77ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),)
78builtin-target := $(obj)/built-in.o
79endif
80
81# We keep a list of all modules in $(MODVERDIR)
82
83__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
84 $(if $(KBUILD_MODULES),$(obj-m)) \
85 $(subdir-ym) $(always)
86 @:
87
88# Linus' kernel sanity checking tool
89ifneq ($(KBUILD_CHECKSRC),0)
90 ifeq ($(KBUILD_CHECKSRC),2)
91 quiet_cmd_force_checksrc = CHECK $<
92 cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
93 else
94 quiet_cmd_checksrc = CHECK $<
95 cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
96 endif
97endif
98
99
100# Compile C sources (.c)
101# ---------------------------------------------------------------------------
102
103# Default is built-in, unless we know otherwise
104modkern_cflags := $(CFLAGS_KERNEL)
105quiet_modtag := $(empty) $(empty)
106
107$(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE)
108$(real-objs-m:.o=.i) : modkern_cflags := $(CFLAGS_MODULE)
109$(real-objs-m:.o=.s) : modkern_cflags := $(CFLAGS_MODULE)
110$(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE)
111
112$(real-objs-m) : quiet_modtag := [M]
113$(real-objs-m:.o=.i) : quiet_modtag := [M]
114$(real-objs-m:.o=.s) : quiet_modtag := [M]
115$(real-objs-m:.o=.lst): quiet_modtag := [M]
116
117$(obj-m) : quiet_modtag := [M]
118
119# Default for not multi-part modules
120modname = $(*F)
121
122$(multi-objs-m) : modname = $(modname-multi)
123$(multi-objs-m:.o=.i) : modname = $(modname-multi)
124$(multi-objs-m:.o=.s) : modname = $(modname-multi)
125$(multi-objs-m:.o=.lst) : modname = $(modname-multi)
126$(multi-objs-y) : modname = $(modname-multi)
127$(multi-objs-y:.o=.i) : modname = $(modname-multi)
128$(multi-objs-y:.o=.s) : modname = $(modname-multi)
129$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
130
131quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
132cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
133
134%.s: %.c FORCE
135 $(call if_changed_dep,cc_s_c)
136
137quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@
138cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $<
139
140%.i: %.c FORCE
141 $(call if_changed_dep,cc_i_c)
142
143# C (.c) files
144# The C file is compiled and updated dependency information is generated.
145# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
146
147quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
148
149ifndef CONFIG_MODVERSIONS
150cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
151
152else
153# When module versioning is enabled the following steps are executed:
154# o compile a .tmp_<file>.o from <file>.c
155# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
156# not export symbols, we just rename .tmp_<file>.o to <file>.o and
157# are done.
158# o otherwise, we calculate symbol versions using the good old
159# genksyms on the preprocessed source and postprocess them in a way
160# that they are usable as a linker script
161# o generate <file>.o from .tmp_<file>.o using the linker to
162# replace the unresolved symbols __crc_exported_symbol with
163# the actual value of the checksum generated by genksyms
164
165cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
166cmd_modversions = \
167 if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
168 $(CPP) -D__GENKSYMS__ $(c_flags) $< \
169 | $(GENKSYMS) -a $(ARCH) \
170 > $(@D)/.tmp_$(@F:.o=.ver); \
171 \
172 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
173 -T $(@D)/.tmp_$(@F:.o=.ver); \
174 rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
175 else \
176 mv -f $(@D)/.tmp_$(@F) $@; \
177 fi;
178endif
179
180define rule_cc_o_c
181 $(call echo-cmd,checksrc) $(cmd_checksrc) \
182 $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
183 $(cmd_modversions) \
184 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \
185 rm -f $(depfile); \
186 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
187endef
188
189# Built-in and composite module parts
190
191%.o: %.c FORCE
192 $(call cmd,force_checksrc)
193 $(call if_changed_rule,cc_o_c)
194
195# Single-part modules are special since we need to mark them in $(MODVERDIR)
196
197$(single-used-m): %.o: %.c FORCE
198 $(call cmd,force_checksrc)
199 $(call if_changed_rule,cc_o_c)
200 @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
201
202quiet_cmd_cc_lst_c = MKLST $@
203 cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
204 $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
205 System.map $(OBJDUMP) > $@
206
207%.lst: %.c FORCE
208 $(call if_changed_dep,cc_lst_c)
209
210# Compile assembler sources (.S)
211# ---------------------------------------------------------------------------
212
213modkern_aflags := $(AFLAGS_KERNEL)
214
215$(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE)
216$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE)
217
218quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
219cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
220
221%.s: %.S FORCE
222 $(call if_changed_dep,as_s_S)
223
224quiet_cmd_as_o_S = AS $(quiet_modtag) $@
225cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
226
227%.o: %.S FORCE
228 $(call if_changed_dep,as_o_S)
229
230targets += $(real-objs-y) $(real-objs-m) $(lib-y)
231targets += $(extra-y) $(MAKECMDGOALS) $(always)
232
233# Linker scripts preprocessor (.lds.S -> .lds)
234# ---------------------------------------------------------------------------
235quiet_cmd_cpp_lds_S = LDS $@
236 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $<
237
238%.lds: %.lds.S FORCE
239 $(call if_changed_dep,cpp_lds_S)
240
241# Build the compiled-in targets
242# ---------------------------------------------------------------------------
243
244# To build objects in subdirs, we need to descend into the directories
245$(sort $(subdir-obj-y)): $(subdir-ym) ;
246
247#
248# Rule to compile a set of .o files into one .o file
249#
250ifdef builtin-target
251quiet_cmd_link_o_target = LD $@
252# If the list of objects to link is empty, just create an empty built-in.o
253cmd_link_o_target = $(if $(strip $(obj-y)),\
254 $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
255 rm -f $@; $(AR) rcs $@)
256
257$(builtin-target): $(obj-y) FORCE
258 $(call if_changed,link_o_target)
259
260targets += $(builtin-target)
261endif # builtin-target
262
263#
264# Rule to compile a set of .o files into one .a file
265#
266ifdef lib-target
267quiet_cmd_link_l_target = AR $@
268cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(lib-y)
269
270$(lib-target): $(lib-y) FORCE
271 $(call if_changed,link_l_target)
272
273targets += $(lib-target)
274endif
275
276#
277# Rule to link composite objects
278#
279# Composite objects are specified in kbuild makefile as follows:
280# <composite-object>-objs := <list of .o files>
281# or
282# <composite-object>-y := <list of .o files>
283link_multi_deps = \
284$(filter $(addprefix $(obj)/, \
285$($(subst $(obj)/,,$(@:.o=-objs))) \
286$($(subst $(obj)/,,$(@:.o=-y)))), $^)
287
288quiet_cmd_link_multi-y = LD $@
289cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
290
291quiet_cmd_link_multi-m = LD [M] $@
292cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps)
293
294# We would rather have a list of rules like
295# foo.o: $(foo-objs)
296# but that's not so easy, so we rather make all composite objects depend
297# on the set of all their parts
298$(multi-used-y) : %.o: $(multi-objs-y) FORCE
299 $(call if_changed,link_multi-y)
300
301$(multi-used-m) : %.o: $(multi-objs-m) FORCE
302 $(call if_changed,link_multi-m)
303 @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
304
305targets += $(multi-used-y) $(multi-used-m)
306
307
308# Descending
309# ---------------------------------------------------------------------------
310
311PHONY += $(subdir-ym)
312$(subdir-ym):
313 $(Q)$(MAKE) $(build)=$@
314
315# Add FORCE to the prequisites of a target to force it to be always rebuilt.
316# ---------------------------------------------------------------------------
317
318PHONY += FORCE
319
320FORCE:
321
322# Read all saved command lines and dependencies for the $(targets) we
323# may be building above, using $(if_changed{,_dep}). As an
324# optimization, we don't need to read them if the target does not
325# exist, we will rebuild anyway in that case.
326
327targets := $(wildcard $(sort $(targets)))
328cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
329
330ifneq ($(cmd_files),)
331 include $(cmd_files)
332endif
333
334
335# Declare the contents of the .PHONY variable as phony. We keep that
336# information in a variable se we can use it in if_changed and friends.
337
338.PHONY: $(PHONY)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
new file mode 100644
index 000000000..2d519704b
--- /dev/null
+++ b/scripts/Makefile.host
@@ -0,0 +1,156 @@
1# ==========================================================================
2# Building binaries on the host system
3# Binaries are used during the compilation of the kernel, for example
4# to preprocess a data file.
5#
6# Both C and C++ is supported, but preferred language is C for such utilities.
7#
8# Samle syntax (see Documentation/kbuild/makefile.txt for reference)
9# hostprogs-y := bin2hex
10# Will compile bin2hex.c and create an executable named bin2hex
11#
12# hostprogs-y := lxdialog
13# lxdialog-objs := checklist.o lxdialog.o
14# Will compile lxdialog.c and checklist.c, and then link the executable
15# lxdialog, based on checklist.o and lxdialog.o
16#
17# hostprogs-y := qconf
18# qconf-cxxobjs := qconf.o
19# qconf-objs := menu.o
20# Will compile qconf as a C++ program, and menu as a C program.
21# They are linked as C++ code to the executable qconf
22
23# hostprogs-y := conf
24# conf-objs := conf.o libkconfig.so
25# libkconfig-objs := expr.o type.o
26# Will create a shared library named libkconfig.so that consist of
27# expr.o and type.o (they are both compiled as C code and the object file
28# are made as position independent code).
29# conf.c is compiled as a c program, and conf.o is linked together with
30# libkconfig.so as the executable conf.
31# Note: Shared libraries consisting of C++ files are not supported
32
33__hostprogs := $(sort $(hostprogs-y)$(hostprogs-m))
34
35# hostprogs-y := tools/build may have been specified. Retreive directory
36obj-dirs += $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f))))
37obj-dirs := $(strip $(sort $(filter-out ./,$(obj-dirs))))
38
39
40# C code
41# Executables compiled from a single .c file
42host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
43
44# C executables linked based on several .o files
45host-cmulti := $(foreach m,$(__hostprogs),\
46 $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
47
48# Object (.o) files compiled from .c files
49host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
50
51# C++ code
52# C++ executables compiled from at least on .cc file
53# and zero or more .c files
54host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m)))
55
56# C++ Object (.o) files compiled from .cc files
57host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
58
59# Shared libaries (only .c supported)
60# Shared libraries (.so) - all .so files referenced in "xxx-objs"
61host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
62# Remove .so files from "xxx-objs"
63host-cobjs := $(filter-out %.so,$(host-cobjs))
64
65#Object (.o) files used by the shared libaries
66host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
67
68__hostprogs := $(addprefix $(obj)/,$(__hostprogs))
69host-csingle := $(addprefix $(obj)/,$(host-csingle))
70host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
71host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
72host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
73host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
74host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
75host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
76obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
77
78#####
79# Handle options to gcc. Support building with separate output directory
80
81_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o)
82_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o)
83
84ifeq ($(KBUILD_SRC),)
85__hostc_flags = $(_hostc_flags)
86__hostcxx_flags = $(_hostcxx_flags)
87else
88__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
89__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
90endif
91
92hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
93hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
94
95#####
96# Compile programs on the host
97
98# Create executable from a single .c file
99# host-csingle -> Executable
100quiet_cmd_host-csingle = HOSTCC $@
101 cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \
102 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
103$(host-csingle): %: %.c FORCE
104 $(call if_changed_dep,host-csingle)
105
106# Link an executable based on list of .o files, all plain c
107# host-cmulti -> executable
108quiet_cmd_host-cmulti = HOSTLD $@
109 cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
110 $(addprefix $(obj)/,$($(@F)-objs)) \
111 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
112$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE
113 $(call if_changed,host-cmulti)
114
115# Create .o file from a single .c file
116# host-cobjs -> .o
117quiet_cmd_host-cobjs = HOSTCC $@
118 cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $<
119$(host-cobjs): %.o: %.c FORCE
120 $(call if_changed_dep,host-cobjs)
121
122# Link an executable based on list of .o files, a mixture of .c and .cc
123# host-cxxmulti -> executable
124quiet_cmd_host-cxxmulti = HOSTLD $@
125 cmd_host-cxxmulti = $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \
126 $(foreach o,objs cxxobjs,\
127 $(addprefix $(obj)/,$($(@F)-$(o)))) \
128 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
129$(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
130 $(call if_changed,host-cxxmulti)
131
132# Create .o file from a single .cc (C++) file
133quiet_cmd_host-cxxobjs = HOSTCXX $@
134 cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $<
135$(host-cxxobjs): %.o: %.cc FORCE
136 $(call if_changed_dep,host-cxxobjs)
137
138# Compile .c file, create position independent .o file
139# host-cshobjs -> .o
140quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
141 cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
142$(host-cshobjs): %.o: %.c FORCE
143 $(call if_changed_dep,host-cshobjs)
144
145# Link a shared library, based on position independent .o files
146# *.o -> .so shared library (host-cshlib)
147quiet_cmd_host-cshlib = HOSTLLD -shared $@
148 cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \
149 $(addprefix $(obj)/,$($(@F:.so=-objs))) \
150 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
151$(host-cshlib): %: $(host-cshobjs) FORCE
152 $(call if_changed,host-cshlib)
153
154targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
155 $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
156
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
new file mode 100644
index 000000000..2cb4935e8
--- /dev/null
+++ b/scripts/Makefile.lib
@@ -0,0 +1,165 @@
1# Backward compatibility - to be removed...
2extra-y += $(EXTRA_TARGETS)
3# Figure out what we need to build from the various variables
4# ===========================================================================
5
6# When an object is listed to be built compiled-in and modular,
7# only build the compiled-in version
8
9obj-m := $(filter-out $(obj-y),$(obj-m))
10
11# Libraries are always collected in one lib file.
12# Filter out objects already built-in
13
14lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
15
16
17# Handle objects in subdirs
18# ---------------------------------------------------------------------------
19# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o
20# and add the directory to the list of dirs to descend into: $(subdir-y)
21# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
22# and add the directory to the list of dirs to descend into: $(subdir-m)
23
24__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
25subdir-y += $(__subdir-y)
26__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
27subdir-m += $(__subdir-m)
28obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
29obj-m := $(filter-out %/, $(obj-m))
30
31# Subdirectories we need to descend into
32
33subdir-ym := $(sort $(subdir-y) $(subdir-m))
34
35# if $(foo-objs) exists, foo.o is a composite object
36multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
37multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
38multi-used := $(multi-used-y) $(multi-used-m)
39single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
40
41# Build list of the parts of our composite objects, our composite
42# objects depend on those (obviously)
43multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
44multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
45multi-objs := $(multi-objs-y) $(multi-objs-m)
46
47# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
48# in the local directory
49subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
50
51# $(obj-dirs) is a list of directories that contain object files
52obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
53
54# Replace multi-part objects by their individual parts, look at local dir only
55real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
56real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
57
58# Add subdir path
59
60extra-y := $(addprefix $(obj)/,$(extra-y))
61always := $(addprefix $(obj)/,$(always))
62targets := $(addprefix $(obj)/,$(targets))
63obj-y := $(addprefix $(obj)/,$(obj-y))
64obj-m := $(addprefix $(obj)/,$(obj-m))
65lib-y := $(addprefix $(obj)/,$(lib-y))
66subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
67real-objs-y := $(addprefix $(obj)/,$(real-objs-y))
68real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
69single-used-m := $(addprefix $(obj)/,$(single-used-m))
70multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
71multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
72multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
73multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
74subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
75obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
76
77# These flags are needed for modversions and compiling, so we define them here
78# already
79# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
80# end up in (or would, if it gets compiled in)
81# Note: It's possible that one object gets potentially linked into more
82# than one module. In that case KBUILD_MODNAME will be set to foo_bar,
83# where foo and bar are the name of the modules.
84name-fix = $(subst $(comma),_,$(subst -,_,$1))
85basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))"
86modname_flags = $(if $(filter 1,$(words $(modname))),\
87 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
88
89_c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o)
90_a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
91_cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
92
93# If building the kernel in a separate objtree expand all occurrences
94# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
95
96ifeq ($(KBUILD_SRC),)
97__c_flags = $(_c_flags)
98__a_flags = $(_a_flags)
99__cpp_flags = $(_cpp_flags)
100else
101
102# -I$(obj) locates generated .h files
103# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
104# and locates generated .h files
105# FIXME: Replace both with specific CFLAGS* statements in the makefiles
106__c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags)
107__a_flags = $(call flags,_a_flags)
108__cpp_flags = $(call flags,_cpp_flags)
109endif
110
111c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
112 $(__c_flags) $(modkern_cflags) \
113 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
114
115a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
116 $(__a_flags) $(modkern_aflags)
117
118cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
119
120ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS)
121
122# Finds the multi-part object the current object will be linked into
123modname-multi = $(sort $(foreach m,$(multi-used),\
124 $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
125
126# Shipped files
127# ===========================================================================
128
129quiet_cmd_shipped = SHIPPED $@
130cmd_shipped = cat $< > $@
131
132$(obj)/%:: $(src)/%_shipped
133 $(call cmd,shipped)
134
135# Commands useful for building a boot image
136# ===========================================================================
137#
138# Use as following:
139#
140# target: source(s) FORCE
141# $(if_changed,ld/objcopy/gzip)
142#
143# and add target to EXTRA_TARGETS so that we know we have to
144# read in the saved command line
145
146# Linking
147# ---------------------------------------------------------------------------
148
149quiet_cmd_ld = LD $@
150cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \
151 $(filter-out FORCE,$^) -o $@
152
153# Objcopy
154# ---------------------------------------------------------------------------
155
156quiet_cmd_objcopy = OBJCOPY $@
157cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
158
159# Gzip
160# ---------------------------------------------------------------------------
161
162quiet_cmd_gzip = GZIP $@
163cmd_gzip = gzip -f -9 < $< > $@
164
165
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
new file mode 100644
index 000000000..f22e94c3a
--- /dev/null
+++ b/scripts/basic/Makefile
@@ -0,0 +1,18 @@
1###
2# Makefile.basic list the most basic programs used during the build process.
3# The programs listed herein is what is needed to do the basic stuff,
4# such as splitting .config and fix dependency file.
5# This initial step is needed to avoid files to be recompiled
6# when kernel configuration changes (which is what happens when
7# .config is included by main Makefile.
8# ---------------------------------------------------------------------------
9# fixdep: Used to generate dependency information during build process
10# split-include: Divide all config symbols up in a number of files in
11# include/config/...
12# docproc: Used in Documentation/docbook
13
14hostprogs-y := fixdep split-include docproc
15always := $(hostprogs-y)
16
17# fixdep is needed to compile other host programs
18$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
new file mode 100644
index 000000000..cb02baa63
--- /dev/null
+++ b/scripts/basic/docproc.c
@@ -0,0 +1,398 @@
1/*
2 * docproc is a simple preprocessor for the template files
3 * used as placeholders for the kernel internal documentation.
4 * docproc is used for documentation-frontend and
5 * dependency-generator.
6 * The two usages have in common that they require
7 * some knowledge of the .tmpl syntax, therefore they
8 * are kept together.
9 *
10 * documentation-frontend
11 * Scans the template file and call kernel-doc for
12 * all occurrences of ![EIF]file
13 * Beforehand each referenced file are scanned for
14 * any exported sympols "EXPORT_SYMBOL()" statements.
15 * This is used to create proper -function and
16 * -nofunction arguments in calls to kernel-doc.
17 * Usage: docproc doc file.tmpl
18 *
19 * dependency-generator:
20 * Scans the template file and list all files
21 * referenced in a format recognized by make.
22 * Usage: docproc depend file.tmpl
23 * Writes dependency information to stdout
24 * in the following format:
25 * file.tmpl src.c src2.c
26 * The filenames are obtained from the following constructs:
27 * !Efilename
28 * !Ifilename
29 * !Dfilename
30 * !Ffilename
31 *
32 */
33
34#include <stdio.h>
35#include <stdlib.h>
36#include <string.h>
37#include <ctype.h>
38#include <unistd.h>
39#include <limits.h>
40#include <sys/types.h>
41#include <sys/wait.h>
42
43/* exitstatus is used to keep track of any failing calls to kernel-doc,
44 * but execution continues. */
45int exitstatus = 0;
46
47typedef void DFL(char *);
48DFL *defaultline;
49
50typedef void FILEONLY(char * file);
51FILEONLY *internalfunctions;
52FILEONLY *externalfunctions;
53FILEONLY *symbolsonly;
54
55typedef void FILELINE(char * file, char * line);
56FILELINE * singlefunctions;
57FILELINE * entity_system;
58
59#define MAXLINESZ 2048
60#define MAXFILES 250
61#define KERNELDOCPATH "scripts/"
62#define KERNELDOC "kernel-doc"
63#define DOCBOOK "-docbook"
64#define FUNCTION "-function"
65#define NOFUNCTION "-nofunction"
66
67void usage (void)
68{
69 fprintf(stderr, "Usage: docproc {doc|depend} file\n");
70 fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
71 fprintf(stderr, "doc: frontend when generating kernel documentation\n");
72 fprintf(stderr, "depend: generate list of files referenced within file\n");
73}
74
75/*
76 * Execute kernel-doc with parameters givin in svec
77 */
78void exec_kernel_doc(char **svec)
79{
80 pid_t pid;
81 int ret;
82 char real_filename[PATH_MAX + 1];
83 /* Make sure output generated so far are flushed */
84 fflush(stdout);
85 switch(pid=fork()) {
86 case -1:
87 perror("fork");
88 exit(1);
89 case 0:
90 memset(real_filename, 0, sizeof(real_filename));
91 strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
92 strncat(real_filename, KERNELDOCPATH KERNELDOC,
93 PATH_MAX - strlen(real_filename));
94 execvp(real_filename, svec);
95 fprintf(stderr, "exec ");
96 perror(real_filename);
97 exit(1);
98 default:
99 waitpid(pid, &ret ,0);
100 }
101 if (WIFEXITED(ret))
102 exitstatus |= WEXITSTATUS(ret);
103 else
104 exitstatus = 0xff;
105}
106
107/* Types used to create list of all exported symbols in a number of files */
108struct symbols
109{
110 char *name;
111};
112
113struct symfile
114{
115 char *filename;
116 struct symbols *symbollist;
117 int symbolcnt;
118};
119
120struct symfile symfilelist[MAXFILES];
121int symfilecnt = 0;
122
123void add_new_symbol(struct symfile *sym, char * symname)
124{
125 sym->symbollist =
126 realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *));
127 sym->symbollist[sym->symbolcnt++].name = strdup(symname);
128}
129
130/* Add a filename to the list */
131struct symfile * add_new_file(char * filename)
132{
133 symfilelist[symfilecnt++].filename = strdup(filename);
134 return &symfilelist[symfilecnt - 1];
135}
136/* Check if file already are present in the list */
137struct symfile * filename_exist(char * filename)
138{
139 int i;
140 for (i=0; i < symfilecnt; i++)
141 if (strcmp(symfilelist[i].filename, filename) == 0)
142 return &symfilelist[i];
143 return NULL;
144}
145
146/*
147 * List all files referenced within the template file.
148 * Files are separated by tabs.
149 */
150void adddep(char * file) { printf("\t%s", file); }
151void adddep2(char * file, char * line) { line = line; adddep(file); }
152void noaction(char * line) { line = line; }
153void noaction2(char * file, char * line) { file = file; line = line; }
154
155/* Echo the line without further action */
156void printline(char * line) { printf("%s", line); }
157
158/*
159 * Find all symbols exported with EXPORT_SYMBOL and EXPORT_SYMBOL_GPL
160 * in filename.
161 * All symbols located are stored in symfilelist.
162 */
163void find_export_symbols(char * filename)
164{
165 FILE * fp;
166 struct symfile *sym;
167 char line[MAXLINESZ];
168 if (filename_exist(filename) == NULL) {
169 char real_filename[PATH_MAX + 1];
170 memset(real_filename, 0, sizeof(real_filename));
171 strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
172 strncat(real_filename, filename,
173 PATH_MAX - strlen(real_filename));
174 sym = add_new_file(filename);
175 fp = fopen(real_filename, "r");
176 if (fp == NULL)
177 {
178 fprintf(stderr, "docproc: ");
179 perror(real_filename);
180 }
181 while(fgets(line, MAXLINESZ, fp)) {
182 char *p;
183 char *e;
184 if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != 0) ||
185 ((p = strstr(line, "EXPORT_SYMBOL")) != 0)) {
186 /* Skip EXPORT_SYMBOL{_GPL} */
187 while (isalnum(*p) || *p == '_')
188 p++;
189 /* Remove paranteses and additional ws */
190 while (isspace(*p))
191 p++;
192 if (*p != '(')
193 continue; /* Syntax error? */
194 else
195 p++;
196 while (isspace(*p))
197 p++;
198 e = p;
199 while (isalnum(*e) || *e == '_')
200 e++;
201 *e = '\0';
202 add_new_symbol(sym, p);
203 }
204 }
205 fclose(fp);
206 }
207}
208
209/*
210 * Document all external or internal functions in a file.
211 * Call kernel-doc with following parameters:
212 * kernel-doc -docbook -nofunction function_name1 filename
213 * function names are obtained from all the the src files
214 * by find_export_symbols.
215 * intfunc uses -nofunction
216 * extfunc uses -function
217 */
218void docfunctions(char * filename, char * type)
219{
220 int i,j;
221 int symcnt = 0;
222 int idx = 0;
223 char **vec;
224
225 for (i=0; i <= symfilecnt; i++)
226 symcnt += symfilelist[i].symbolcnt;
227 vec = malloc((2 + 2 * symcnt + 2) * sizeof(char*));
228 if (vec == NULL) {
229 perror("docproc: ");
230 exit(1);
231 }
232 vec[idx++] = KERNELDOC;
233 vec[idx++] = DOCBOOK;
234 for (i=0; i < symfilecnt; i++) {
235 struct symfile * sym = &symfilelist[i];
236 for (j=0; j < sym->symbolcnt; j++) {
237 vec[idx++] = type;
238 vec[idx++] = sym->symbollist[j].name;
239 }
240 }
241 vec[idx++] = filename;
242 vec[idx] = NULL;
243 printf("<!-- %s -->\n", filename);
244 exec_kernel_doc(vec);
245 fflush(stdout);
246 free(vec);
247}
248void intfunc(char * filename) { docfunctions(filename, NOFUNCTION); }
249void extfunc(char * filename) { docfunctions(filename, FUNCTION); }
250
251/*
252 * Document spåecific function(s) in a file.
253 * Call kernel-doc with the following parameters:
254 * kernel-doc -docbook -function function1 [-function function2]
255 */
256void singfunc(char * filename, char * line)
257{
258 char *vec[200]; /* Enough for specific functions */
259 int i, idx = 0;
260 int startofsym = 1;
261 vec[idx++] = KERNELDOC;
262 vec[idx++] = DOCBOOK;
263
264 /* Split line up in individual parameters preceeded by FUNCTION */
265 for (i=0; line[i]; i++) {
266 if (isspace(line[i])) {
267 line[i] = '\0';
268 startofsym = 1;
269 continue;
270 }
271 if (startofsym) {
272 startofsym = 0;
273 vec[idx++] = FUNCTION;
274 vec[idx++] = &line[i];
275 }
276 }
277 vec[idx++] = filename;
278 vec[idx] = NULL;
279 exec_kernel_doc(vec);
280}
281
282/*
283 * Parse file, calling action specific functions for:
284 * 1) Lines containing !E
285 * 2) Lines containing !I
286 * 3) Lines containing !D
287 * 4) Lines containing !F
288 * 5) Default lines - lines not matching the above
289 */
290void parse_file(FILE *infile)
291{
292 char line[MAXLINESZ];
293 char * s;
294 while(fgets(line, MAXLINESZ, infile)) {
295 if (line[0] == '!') {
296 s = line + 2;
297 switch (line[1]) {
298 case 'E':
299 while (*s && !isspace(*s)) s++;
300 *s = '\0';
301 externalfunctions(line+2);
302 break;
303 case 'I':
304 while (*s && !isspace(*s)) s++;
305 *s = '\0';
306 internalfunctions(line+2);
307 break;
308 case 'D':
309 while (*s && !isspace(*s)) s++;
310 *s = '\0';
311 symbolsonly(line+2);
312 break;
313 case 'F':
314 /* filename */
315 while (*s && !isspace(*s)) s++;
316 *s++ = '\0';
317 /* function names */
318 while (isspace(*s))
319 s++;
320 singlefunctions(line +2, s);
321 break;
322 default:
323 defaultline(line);
324 }
325 }
326 else {
327 defaultline(line);
328 }
329 }
330 fflush(stdout);
331}
332
333
334int main(int argc, char *argv[])
335{
336 FILE * infile;
337 if (argc != 3) {
338 usage();
339 exit(1);
340 }
341 /* Open file, exit on error */
342 infile = fopen(argv[2], "r");
343 if (infile == NULL) {
344 fprintf(stderr, "docproc: ");
345 perror(argv[2]);
346 exit(2);
347 }
348
349 if (strcmp("doc", argv[1]) == 0)
350 {
351 /* Need to do this in two passes.
352 * First pass is used to collect all symbols exported
353 * in the various files.
354 * Second pass generate the documentation.
355 * This is required because function are declared
356 * and exported in different files :-((
357 */
358 /* Collect symbols */
359 defaultline = noaction;
360 internalfunctions = find_export_symbols;
361 externalfunctions = find_export_symbols;
362 symbolsonly = find_export_symbols;
363 singlefunctions = noaction2;
364 parse_file(infile);
365
366 /* Rewind to start from beginning of file again */
367 fseek(infile, 0, SEEK_SET);
368 defaultline = printline;
369 internalfunctions = intfunc;
370 externalfunctions = extfunc;
371 symbolsonly = printline;
372 singlefunctions = singfunc;
373
374 parse_file(infile);
375 }
376 else if (strcmp("depend", argv[1]) == 0)
377 {
378 /* Create first part of dependency chain
379 * file.tmpl */
380 printf("%s\t", argv[2]);
381 defaultline = noaction;
382 internalfunctions = adddep;
383 externalfunctions = adddep;
384 symbolsonly = adddep;
385 singlefunctions = adddep2;
386 parse_file(infile);
387 printf("\n");
388 }
389 else
390 {
391 fprintf(stderr, "Unknown option: %s\n", argv[1]);
392 exit(1);
393 }
394 fclose(infile);
395 fflush(stdout);
396 return exitstatus;
397}
398
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
new file mode 100644
index 000000000..cc2c6541b
--- /dev/null
+++ b/scripts/basic/fixdep.c
@@ -0,0 +1,393 @@
1/*
2 * "Optimize" a list of dependencies as spit out by gcc -MD
3 * for the kernel build
4 * ===========================================================================
5 *
6 * Author Kai Germaschewski
7 * Copyright 2002 by Kai Germaschewski <kai.germaschewski@gmx.de>
8 *
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
11 *
12 *
13 * Introduction:
14 *
15 * gcc produces a very nice and correct list of dependencies which
16 * tells make when to remake a file.
17 *
18 * To use this list as-is however has the drawback that virtually
19 * every file in the kernel includes <linux/config.h> which then again
20 * includes <linux/autoconf.h>
21 *
22 * If the user re-runs make *config, linux/autoconf.h will be
23 * regenerated. make notices that and will rebuild every file which
24 * includes autoconf.h, i.e. basically all files. This is extremely
25 * annoying if the user just changed CONFIG_HIS_DRIVER from n to m.
26 *
27 * So we play the same trick that "mkdep" played before. We replace
28 * the dependency on linux/autoconf.h by a dependency on every config
29 * option which is mentioned in any of the listed prequisites.
30 *
31 * To be exact, split-include populates a tree in include/config/,
32 * e.g. include/config/his/driver.h, which contains the #define/#undef
33 * for the CONFIG_HIS_DRIVER option.
34 *
35 * So if the user changes his CONFIG_HIS_DRIVER option, only the objects
36 * which depend on "include/linux/config/his/driver.h" will be rebuilt,
37 * so most likely only his driver ;-)
38 *
39 * The idea above dates, by the way, back to Michael E Chastain, AFAIK.
40 *
41 * So to get dependencies right, there are two issues:
42 * o if any of the files the compiler read changed, we need to rebuild
43 * o if the command line given to the compile the file changed, we
44 * better rebuild as well.
45 *
46 * The former is handled by using the -MD output, the later by saving
47 * the command line used to compile the old object and comparing it
48 * to the one we would now use.
49 *
50 * Again, also this idea is pretty old and has been discussed on
51 * kbuild-devel a long time ago. I don't have a sensibly working
52 * internet connection right now, so I rather don't mention names
53 * without double checking.
54 *
55 * This code here has been based partially based on mkdep.c, which
56 * says the following about its history:
57 *
58 * Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>.
59 * This is a C version of syncdep.pl by Werner Almesberger.
60 *
61 *
62 * It is invoked as
63 *
64 * fixdep <depfile> <target> <cmdline>
65 *
66 * and will read the dependency file <depfile>
67 *
68 * The transformed dependency snipped is written to stdout.
69 *
70 * It first generates a line
71 *
72 * cmd_<target> = <cmdline>
73 *
74 * and then basically copies the .<target>.d file to stdout, in the
75 * process filtering out the dependency on linux/autoconf.h and adding
76 * dependencies on include/config/my/option.h for every
77 * CONFIG_MY_OPTION encountered in any of the prequisites.
78 *
79 * It will also filter out all the dependencies on *.ver. We need
80 * to make sure that the generated version checksum are globally up
81 * to date before even starting the recursive build, so it's too late
82 * at this point anyway.
83 *
84 * The algorithm to grep for "CONFIG_..." is bit unusual, but should
85 * be fast ;-) We don't even try to really parse the header files, but
86 * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will
87 * be picked up as well. It's not a problem with respect to
88 * correctness, since that can only give too many dependencies, thus
89 * we cannot miss a rebuild. Since people tend to not mention totally
90 * unrelated CONFIG_ options all over the place, it's not an
91 * efficiency problem either.
92 *
93 * (Note: it'd be easy to port over the complete mkdep state machine,
94 * but I don't think the added complexity is worth it)
95 */
96/*
97 * Note 2: if somebody writes HELLO_CONFIG_BOOM in a file, it will depend onto
98 * CONFIG_BOOM. This could seem a bug (not too hard to fix), but please do not
99 * fix it! Some UserModeLinux files (look at arch/um/) call CONFIG_BOOM as
100 * UML_CONFIG_BOOM, to avoid conflicts with /usr/include/linux/autoconf.h,
101 * through arch/um/include/uml-config.h; this fixdep "bug" makes sure that
102 * those files will have correct dependencies.
103 */
104
105#include <sys/types.h>
106#include <sys/stat.h>
107#include <sys/mman.h>
108#include <unistd.h>
109#include <fcntl.h>
110#include <string.h>
111#include <stdlib.h>
112#include <stdio.h>
113#include <limits.h>
114#include <ctype.h>
115#include <arpa/inet.h>
116
117#define INT_CONF ntohl(0x434f4e46)
118#define INT_ONFI ntohl(0x4f4e4649)
119#define INT_NFIG ntohl(0x4e464947)
120#define INT_FIG_ ntohl(0x4649475f)
121
122char *target;
123char *depfile;
124char *cmdline;
125
126void usage(void)
127
128{
129 fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
130 exit(1);
131}
132
133/*
134 * Print out the commandline prefixed with cmd_<target filename> :=
135 */
136void print_cmdline(void)
137{
138 printf("cmd_%s := %s\n\n", target, cmdline);
139}
140
141char * str_config = NULL;
142int size_config = 0;
143int len_config = 0;
144
145/*
146 * Grow the configuration string to a desired length.
147 * Usually the first growth is plenty.
148 */
149void grow_config(int len)
150{
151 while (len_config + len > size_config) {
152 if (size_config == 0)
153 size_config = 2048;
154 str_config = realloc(str_config, size_config *= 2);
155 if (str_config == NULL)
156 { perror("fixdep:malloc"); exit(1); }
157 }
158}
159
160
161
162/*
163 * Lookup a value in the configuration string.
164 */
165int is_defined_config(const char * name, int len)
166{
167 const char * pconfig;
168 const char * plast = str_config + len_config - len;
169 for ( pconfig = str_config + 1; pconfig < plast; pconfig++ ) {
170 if (pconfig[ -1] == '\n'
171 && pconfig[len] == '\n'
172 && !memcmp(pconfig, name, len))
173 return 1;
174 }
175 return 0;
176}
177
178/*
179 * Add a new value to the configuration string.
180 */
181void define_config(const char * name, int len)
182{
183 grow_config(len + 1);
184
185 memcpy(str_config+len_config, name, len);
186 len_config += len;
187 str_config[len_config++] = '\n';
188}
189
190/*
191 * Clear the set of configuration strings.
192 */
193void clear_config(void)
194{
195 len_config = 0;
196 define_config("", 0);
197}
198
199/*
200 * Record the use of a CONFIG_* word.
201 */
202void use_config(char *m, int slen)
203{
204 char s[PATH_MAX];
205 char *p;
206
207 if (is_defined_config(m, slen))
208 return;
209
210 define_config(m, slen);
211
212 memcpy(s, m, slen); s[slen] = 0;
213
214 for (p = s; p < s + slen; p++) {
215 if (*p == '_')
216 *p = '/';
217 else
218 *p = tolower((int)*p);
219 }
220 printf(" $(wildcard include/config/%s.h) \\\n", s);
221}
222
223void parse_config_file(char *map, size_t len)
224{
225 int *end = (int *) (map + len);
226 /* start at +1, so that p can never be < map */
227 int *m = (int *) map + 1;
228 char *p, *q;
229
230 for (; m < end; m++) {
231 if (*m == INT_CONF) { p = (char *) m ; goto conf; }
232 if (*m == INT_ONFI) { p = (char *) m-1; goto conf; }
233 if (*m == INT_NFIG) { p = (char *) m-2; goto conf; }
234 if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }
235 continue;
236 conf:
237 if (p > map + len - 7)
238 continue;
239 if (memcmp(p, "CONFIG_", 7))
240 continue;
241 for (q = p + 7; q < map + len; q++) {
242 if (!(isalnum(*q) || *q == '_'))
243 goto found;
244 }
245 continue;
246
247 found:
248 use_config(p+7, q-p-7);
249 }
250}
251
252/* test is s ends in sub */
253int strrcmp(char *s, char *sub)
254{
255 int slen = strlen(s);
256 int sublen = strlen(sub);
257
258 if (sublen > slen)
259 return 1;
260
261 return memcmp(s + slen - sublen, sub, sublen);
262}
263
264void do_config_file(char *filename)
265{
266 struct stat st;
267 int fd;
268 void *map;
269
270 fd = open(filename, O_RDONLY);
271 if (fd < 0) {
272 fprintf(stderr, "fixdep: ");
273 perror(filename);
274 exit(2);
275 }
276 fstat(fd, &st);
277 if (st.st_size == 0) {
278 close(fd);
279 return;
280 }
281 map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
282 if ((long) map == -1) {
283 perror("fixdep: mmap");
284 close(fd);
285 return;
286 }
287
288 parse_config_file(map, st.st_size);
289
290 munmap(map, st.st_size);
291
292 close(fd);
293}
294
295void parse_dep_file(void *map, size_t len)
296{
297 char *m = map;
298 char *end = m + len;
299 char *p;
300 char s[PATH_MAX];
301
302 p = strchr(m, ':');
303 if (!p) {
304 fprintf(stderr, "fixdep: parse error\n");
305 exit(1);
306 }
307 memcpy(s, m, p-m); s[p-m] = 0;
308 printf("deps_%s := \\\n", target);
309 m = p+1;
310
311 clear_config();
312
313 while (m < end) {
314 while (m < end && (*m == ' ' || *m == '\\' || *m == '\n'))
315 m++;
316 p = m;
317 while (p < end && *p != ' ') p++;
318 if (p == end) {
319 do p--; while (!isalnum(*p));
320 p++;
321 }
322 memcpy(s, m, p-m); s[p-m] = 0;
323 if (strrcmp(s, "include/autoconf.h") &&
324 strrcmp(s, "arch/um/include/uml-config.h") &&
325 strrcmp(s, ".ver")) {
326 printf(" %s \\\n", s);
327 do_config_file(s);
328 }
329 m = p + 1;
330 }
331 printf("\n%s: $(deps_%s)\n\n", target, target);
332 printf("$(deps_%s):\n", target);
333}
334
335void print_deps(void)
336{
337 struct stat st;
338 int fd;
339 void *map;
340
341 fd = open(depfile, O_RDONLY);
342 if (fd < 0) {
343 fprintf(stderr, "fixdep: ");
344 perror(depfile);
345 exit(2);
346 }
347 fstat(fd, &st);
348 if (st.st_size == 0) {
349 fprintf(stderr,"fixdep: %s is empty\n",depfile);
350 close(fd);
351 return;
352 }
353 map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
354 if ((long) map == -1) {
355 perror("fixdep: mmap");
356 close(fd);
357 return;
358 }
359
360 parse_dep_file(map, st.st_size);
361
362 munmap(map, st.st_size);
363
364 close(fd);
365}
366
367void traps(void)
368{
369 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
370
371 if (*(int *)test != INT_CONF) {
372 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
373 *(int *)test);
374 exit(2);
375 }
376}
377
378int main(int argc, char *argv[])
379{
380 traps();
381
382 if (argc != 4)
383 usage();
384
385 depfile = argv[1];
386 target = argv[2];
387 cmdline = argv[3];
388
389 print_cmdline();
390 print_deps();
391
392 return 0;
393}
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c
new file mode 100644
index 000000000..459c45276
--- /dev/null
+++ b/scripts/basic/split-include.c
@@ -0,0 +1,226 @@
1/*
2 * split-include.c
3 *
4 * Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>.
5 * This is a C version of syncdep.pl by Werner Almesberger.
6 *
7 * This program takes autoconf.h as input and outputs a directory full
8 * of one-line include files, merging onto the old values.
9 *
10 * Think of the configuration options as key-value pairs. Then there
11 * are five cases:
12 *
13 * key old value new value action
14 *
15 * KEY-1 VALUE-1 VALUE-1 leave file alone
16 * KEY-2 VALUE-2A VALUE-2B write VALUE-2B into file
17 * KEY-3 - VALUE-3 write VALUE-3 into file
18 * KEY-4 VALUE-4 - write an empty file
19 * KEY-5 (empty) - leave old empty file alone
20 */
21
22#include <sys/stat.h>
23#include <sys/types.h>
24
25#include <ctype.h>
26#include <errno.h>
27#include <fcntl.h>
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <unistd.h>
32
33#define ERROR_EXIT(strExit) \
34 { \
35 const int errnoSave = errno; \
36 fprintf(stderr, "%s: ", str_my_name); \
37 errno = errnoSave; \
38 perror((strExit)); \
39 exit(1); \
40 }
41
42
43
44int main(int argc, const char * argv [])
45{
46 const char * str_my_name;
47 const char * str_file_autoconf;
48 const char * str_dir_config;
49
50 FILE * fp_config;
51 FILE * fp_target;
52 FILE * fp_find;
53
54 int buffer_size;
55
56 char * line;
57 char * old_line;
58 char * list_target;
59 char * ptarget;
60
61 struct stat stat_buf;
62
63 /* Check arg count. */
64 if (argc != 3)
65 {
66 fprintf(stderr, "%s: wrong number of arguments.\n", argv[0]);
67 exit(1);
68 }
69
70 str_my_name = argv[0];
71 str_file_autoconf = argv[1];
72 str_dir_config = argv[2];
73
74 /* Find a buffer size. */
75 if (stat(str_file_autoconf, &stat_buf) != 0)
76 ERROR_EXIT(str_file_autoconf);
77 buffer_size = 2 * stat_buf.st_size + 4096;
78
79 /* Allocate buffers. */
80 if ( (line = malloc(buffer_size)) == NULL
81 || (old_line = malloc(buffer_size)) == NULL
82 || (list_target = malloc(buffer_size)) == NULL )
83 ERROR_EXIT(str_file_autoconf);
84
85 /* Open autoconfig file. */
86 if ((fp_config = fopen(str_file_autoconf, "r")) == NULL)
87 ERROR_EXIT(str_file_autoconf);
88
89 /* Make output directory if needed. */
90 if (stat(str_dir_config, &stat_buf) != 0)
91 {
92 if (mkdir(str_dir_config, 0755) != 0)
93 ERROR_EXIT(str_dir_config);
94 }
95
96 /* Change to output directory. */
97 if (chdir(str_dir_config) != 0)
98 ERROR_EXIT(str_dir_config);
99
100 /* Put initial separator into target list. */
101 ptarget = list_target;
102 *ptarget++ = '\n';
103
104 /* Read config lines. */
105 while (fgets(line, buffer_size, fp_config))
106 {
107 const char * str_config;
108 int is_same;
109 int itarget;
110
111 if (line[0] != '#')
112 continue;
113 if ((str_config = strstr(line, "CONFIG_")) == NULL)
114 continue;
115
116 /* Make the output file name. */
117 str_config += sizeof("CONFIG_") - 1;
118 for (itarget = 0; !isspace(str_config[itarget]); itarget++)
119 {
120 int c = (unsigned char) str_config[itarget];
121 if (isupper(c)) c = tolower(c);
122 if (c == '_') c = '/';
123 ptarget[itarget] = c;
124 }
125 ptarget[itarget++] = '.';
126 ptarget[itarget++] = 'h';
127 ptarget[itarget++] = '\0';
128
129 /* Check for existing file. */
130 is_same = 0;
131 if ((fp_target = fopen(ptarget, "r")) != NULL)
132 {
133 fgets(old_line, buffer_size, fp_target);
134 if (fclose(fp_target) != 0)
135 ERROR_EXIT(ptarget);
136 if (!strcmp(line, old_line))
137 is_same = 1;
138 }
139
140 if (!is_same)
141 {
142 /* Auto-create directories. */
143 int islash;
144 for (islash = 0; islash < itarget; islash++)
145 {
146 if (ptarget[islash] == '/')
147 {
148 ptarget[islash] = '\0';
149 if (stat(ptarget, &stat_buf) != 0
150 && mkdir(ptarget, 0755) != 0)
151 ERROR_EXIT( ptarget );
152 ptarget[islash] = '/';
153 }
154 }
155
156 /* Write the file. */
157 if ((fp_target = fopen(ptarget, "w" )) == NULL)
158 ERROR_EXIT(ptarget);
159 fputs(line, fp_target);
160 if (ferror(fp_target) || fclose(fp_target) != 0)
161 ERROR_EXIT(ptarget);
162 }
163
164 /* Update target list */
165 ptarget += itarget;
166 *(ptarget-1) = '\n';
167 }
168
169 /*
170 * Close autoconfig file.
171 * Terminate the target list.
172 */
173 if (fclose(fp_config) != 0)
174 ERROR_EXIT(str_file_autoconf);
175 *ptarget = '\0';
176
177 /*
178 * Fix up existing files which have no new value.
179 * This is Case 4 and Case 5.
180 *
181 * I re-read the tree and filter it against list_target.
182 * This is crude. But it avoids data copies. Also, list_target
183 * is compact and contiguous, so it easily fits into cache.
184 *
185 * Notice that list_target contains strings separated by \n,
186 * with a \n before the first string and after the last.
187 * fgets gives the incoming names a terminating \n.
188 * So by having an initial \n, strstr will find exact matches.
189 */
190
191 fp_find = popen("find * -type f -name \"*.h\" -print", "r");
192 if (fp_find == 0)
193 ERROR_EXIT( "find" );
194
195 line[0] = '\n';
196 while (fgets(line+1, buffer_size, fp_find))
197 {
198 if (strstr(list_target, line) == NULL)
199 {
200 /*
201 * This is an old file with no CONFIG_* flag in autoconf.h.
202 */
203
204 /* First strip the \n. */
205 line[strlen(line)-1] = '\0';
206
207 /* Grab size. */
208 if (stat(line+1, &stat_buf) != 0)
209 ERROR_EXIT(line);
210
211 /* If file is not empty, make it empty and give it a fresh date. */
212 if (stat_buf.st_size != 0)
213 {
214 if ((fp_target = fopen(line+1, "w")) == NULL)
215 ERROR_EXIT(line);
216 if (fclose(fp_target) != 0)
217 ERROR_EXIT(line);
218 }
219 }
220 }
221
222 if (pclose(fp_find) != 0)
223 ERROR_EXIT("find");
224
225 return 0;
226}
diff --git a/scripts/config/Kconfig-language.txt b/scripts/config/Kconfig-language.txt
deleted file mode 100644
index 9b90bc392..000000000
--- a/scripts/config/Kconfig-language.txt
+++ /dev/null
@@ -1,255 +0,0 @@
1Introduction
2------------
3
4The configuration database is collection of configuration options
5organized in a tree structure:
6
7 +- Code maturity level options
8 | +- Prompt for development and/or incomplete code/drivers
9 +- General setup
10 | +- Networking support
11 | +- System V IPC
12 | +- BSD Process Accounting
13 | +- Sysctl support
14 +- Loadable module support
15 | +- Enable loadable module support
16 | +- Set version information on all module symbols
17 | +- Kernel module loader
18 +- ...
19
20Every entry has its own dependencies. These dependencies are used
21to determine the visible of an entry. Any child entry is only
22visible if its parent entry is also visible.
23
24Menu entries
25------------
26
27Most entries define a config option, all other entries help to organize
28them. A single configuration option is defined like this:
29
30config MODVERSIONS
31 bool "Set version information on all module symbols"
32 depends MODULES
33 help
34 Usually, modules have to be recompiled whenever you switch to a new
35 kernel. ...
36
37Every line starts with a key word and can be followed by multiple
38arguments. "config" starts a new config entry. The following lines
39define attributes for this config option. Attributes can be the type of
40the config option, input prompt, dependencies, help text and default
41values. A config option can be defined multiple times with the same
42name, but every definition can have only a single input prompt and the
43type must not conflict.
44
45Menu attributes
46---------------
47
48A menu entry can have a number of attributes. Not all of them are
49applicable everywhere (see syntax).
50
51- type definition: "bool"/"tristate"/"string"/"hex"/"integer"
52 Every config option must have a type. There are only two basic types:
53 tristate and string, the other types base on these two. The type
54 definition optionally accepts an input prompt, so these two examples
55 are equivalent:
56
57 bool "Networking support"
58 and
59 bool
60 prompt "Networking support"
61
62- input prompt: "prompt" <prompt> ["if" <expr>]
63 Every menu entry can have at most one prompt, which is used to display
64 to the user. Optionally dependencies only for this prompt can be added
65 with "if".
66
67- default value: "default" <symbol> ["if" <expr>]
68 A config option can have any number of default values. If multiple
69 default values are visible, only the first defined one is active.
70 Default values are not limited to the menu entry, where they are
71 defined, this means the default can be defined somewhere else or be
72 overridden by an earlier definition.
73 The default value is only assigned to the config symbol if no other
74 value was set by the user (via the input prompt above). If an input
75 prompt is visible the default value is presented to the user and can
76 be overridden by him.
77 Optionally dependencies only for this default value can be added with
78 "if".
79
80- dependencies: "depends on"/"requires" <expr>
81 This defines a dependency for this menu entry. If multiple
82 dependencies are defined they are connected with '&&'. Dependencies
83 are applied to all other options within this menu entry (which also
84 accept "if" expression), so these two examples are equivalent:
85
86 bool "foo" if BAR
87 default y if BAR
88 and
89 depends on BAR
90 bool "foo"
91 default y
92
93- help text: "help"
94 This defines a help text. The end of the help text is determined by
95 the level indentation, this means it ends at the first line which has
96 a smaller indentation than the first line of the help text.
97
98
99Menu dependencies
100-----------------
101
102Dependencies define the visibility of a menu entry and can also reduce
103the input range of tristate symbols. The tristate logic used in the
104expressions uses one more state than normal boolean logic to express the
105module state. Dependency expressions have the following syntax:
106
107<expr> ::= <symbol> (1)
108 <symbol> '=' <symbol> (2)
109 <symbol> '!=' <symbol> (3)
110 '(' <expr> ')' (4)
111 '!' <expr> (5)
112 <expr> '||' <expr> (6)
113 <expr> '&&' <expr> (7)
114
115Expressions are listed in decreasing order of precedence.
116
117(1) Convert the symbol into an expression. Boolean and tristate symbols
118 are simply converted into the respective expression values. All
119 other symbol types result in 'n'.
120(2) If the values of both symbols are equal, it returns 'y',
121 otherwise 'n'.
122(3) If the values of both symbols are equal, it returns 'n',
123 otherwise 'y'.
124(4) Returns the value of the expression. Used to override precedence.
125(5) Returns the result of (2-/expr/).
126(6) Returns the result of min(/expr/, /expr/).
127(7) Returns the result of max(/expr/, /expr/).
128
129An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
130respectively for calculations). A menu entry becomes visible when it's
131expression evaluates to 'm' or 'y'.
132
133There are two type of symbols: constant and nonconstant symbols.
134Nonconstant symbols are the most common ones and are defined with the
135'config' statement. Nonconstant symbols consist entirely of alphanumeric
136characters or underscores.
137Constant symbols are only part of expressions. Constant symbols are
138always surrounded by single or double quotes. Within the quote any
139other character is allowed and the quotes can be escaped using '\'.
140
141Menu structure
142--------------
143
144The position of a menu entry in the tree is determined in two ways. First
145it can be specified explicitely:
146
147menu "Network device support"
148 depends NET
149
150config NETDEVICES
151 ...
152
153endmenu
154
155All entries within the "menu" ... "endmenu" block become a submenu of
156"Network device support". All subentries inherit the dependencies from
157the menu entry, e.g. this means the dependency "NET" is added to the
158dependency list of the config option NETDEVICES.
159
160The other way to generate the menu structure is done by analyzing the
161dependencies. If a menu entry somehow depends on the previous entry, it
162can be made a submenu of it. First the the previous (parent) symbol must
163be part of the dependency list and then one of these two condititions
164must be true:
165- the child entry must become invisible, if the parent is set to 'n'
166- the child entry must only be visible, if the parent is visible
167
168config MODULES
169 bool "Enable loadable module support"
170
171config MODVERSIONS
172 bool "Set version information on all module symbols"
173 depends MODULES
174
175comment "module support disabled"
176 depends !MODULES
177
178MODVERSIONS directly depends on MODULES, this means it's only visible if
179MODULES is different from 'n'. The comment on the other hand is always
180visible when MODULES it's visible (the (empty) dependency of MODULES is
181also part of the comment dependencies).
182
183
184Kconfig syntax
185--------------
186
187The configuration file describes a series of menu entries, where every
188line starts with a keyword (except help texts). The following keywords
189end a menu entry:
190- config
191- choice/endchoice
192- comment
193- menu/endmenu
194- if/endif
195- source
196The first four also start the definition of a menu entry.
197
198config:
199
200 "config" <symbol>
201 <config options>
202
203This defines a config symbol <symbol> and accepts any of above
204attributes as options.
205
206choices:
207
208 "choice"
209 <choice options>
210 <choice block>
211 "endchoice"
212
213This defines a choice group and accepts any of above attributes as
214options. A choice can only be of type bool or tristate, while a boolean
215choice only allows a single config entry to be selected, a tristate
216choice also allows any number of config entries to be set to 'm'. This
217can be used if multiple drivers for a single hardware exists and only a
218single driver can be compiled/loaded into the kernel, but all drivers
219can be compiled as modules.
220A choice accepts another option "optional", which allows to set the
221choice to 'n' and no entry needs to be selected.
222
223comment:
224
225 "comment" <prompt>
226 <comment options>
227
228This defines a comment which is displayed to the user during the
229configuration process and is also echoed to the output files. The only
230possible options are dependencies.
231
232menu:
233
234 "menu" <prompt>
235 <menu options>
236 <menu block>
237 "endmenu"
238
239This defines a menu block, see "Menu structure" above for more
240information. The only possible options are dependencies.
241
242if:
243
244 "if" <expr>
245 <if block>
246 "endif"
247
248This defines an if block. The dependency expression <expr> is appended
249to all enclosed menu entries.
250
251source:
252
253 "source" <prompt>
254
255This reads the specified configuration file. This file is always parsed.
diff --git a/scripts/config/Makefile b/scripts/config/Makefile
deleted file mode 100644
index 4c966f7a6..000000000
--- a/scripts/config/Makefile
+++ /dev/null
@@ -1,122 +0,0 @@
1# Makefile for BusyBox
2#
3# Copyright (C) 2002 Erik Andersen <andersen@codepoet.org>
4
5top_srcdir=../..
6top_builddir=../..
7srcdir=$(top_srcdir)/scripts/config
8include $(top_srcdir)/Rules.mak
9
10all: ncurses conf mconf
11
12ifeq ($(shell uname),SunOS)
13LIBS = -lcurses
14else
15LIBS = -lncurses
16endif
17ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
18 HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
19else
20ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
21 HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
22else
23ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
24 HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
25else
26ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
27 HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
28else
29ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
30 HOSTNCURSES += -DCURSES_LOC="<ncurses.h>"
31else
32 HOSTNCURSES += -DCURSES_LOC="<curses.h>"
33endif
34endif
35endif
36endif
37endif
38
39CONF_SRC = conf.c
40MCONF_SRC = mconf.c
41LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \
42 lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \
43 lxdialog/msgbox.c
44
45SHARED_SRC = zconf.tab.c
46SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \
47 lkc_defs.h $(srcdir)/expr.h zconf.tab.h
48CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC))
49MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC))
50SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC))
51
52conf: $(CONF_OBJS) $(SHARED_OBJS)
53 $(SECHO) " "HOSTCC $@ ; true
54 $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
55
56mconf: $(MCONF_OBJS) $(SHARED_OBJS)
57 $(SECHO) " "HOSTCC $@ ; true
58 $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
59
60$(CONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
61 $(compile.h) -I.
62
63$(MCONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
64 @[ -d $(@D) ] || mkdir $(@D)
65 $(compile.h) $(HOSTNCURSES) -I.
66
67lkc_defs.h: $(srcdir)/lkc_proto.h
68 @$(SED) < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
69
70###
71# The following requires flex/bison
72# By default we use the _shipped versions, uncomment the
73# following line if you are modifying the flex/bison src.
74#LKC_GENPARSER := 1
75
76ifdef LKC_GENPARSER
77
78%.tab.c %.tab.h: $(srcdir)/%.y
79 bison -t -d -v -b $* -p $(notdir $*) $<
80
81lex.%.c: $(srcdir)/%.l
82 flex -P$(notdir $*) -o$@ $<
83else
84
85lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
86 $(compile.h) -I$(srcdir)
87
88lex.zconf.c: $(srcdir)/lex.zconf.c_shipped
89 $(Q)cp $< $@
90
91zconf.tab.c: $(srcdir)/zconf.tab.c_shipped
92 $(Q)cp $< $@
93
94zconf.tab.h: $(srcdir)/zconf.tab.h_shipped
95 $(Q)cp $< $@
96endif
97
98zconf.tab.o: zconf.tab.c lex.zconf.c $(srcdir)/confdata.c $(srcdir)/expr.c \
99 $(srcdir)/symbol.c $(srcdir)/menu.c $(SHARED_DEPS)
100 $(compile.h) -I$(srcdir) -I.
101
102.PHONY: ncurses
103
104ncurses:
105 @echo "main() {}" > lxtemp.c
106 @if $(HOSTCC) lxtemp.c $(LIBS) ; then \
107 rm -f lxtemp.c a.out; \
108 else \
109 rm -f lxtemp.c; \
110 echo -e "\007" ;\
111 echo ">> Unable to find the Ncurses libraries." ;\
112 echo ">>" ;\
113 echo ">> You must have Ncurses installed in order" ;\
114 echo ">> to use 'make menuconfig'" ;\
115 echo ;\
116 exit 1 ;\
117 fi
118
119clean:
120 rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
121 conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h
122
diff --git a/scripts/config/lex.zconf.c_shipped b/scripts/config/lex.zconf.c_shipped
deleted file mode 100644
index 8e5e85e4c..000000000
--- a/scripts/config/lex.zconf.c_shipped
+++ /dev/null
@@ -1,3688 +0,0 @@
1
2#line 3 "lex.zconf.c"
3
4#define YY_INT_ALIGNED short int
5
6/* A lexical scanner generated by flex */
7
8#define FLEX_SCANNER
9#define YY_FLEX_MAJOR_VERSION 2
10#define YY_FLEX_MINOR_VERSION 5
11#define YY_FLEX_SUBMINOR_VERSION 31
12#if YY_FLEX_SUBMINOR_VERSION > 0
13#define FLEX_BETA
14#endif
15
16/* First, we deal with platform-specific or compiler-specific issues. */
17
18/* begin standard C headers. */
19#include <stdio.h>
20#include <string.h>
21#include <errno.h>
22#include <stdlib.h>
23
24/* end standard C headers. */
25
26/* flex integer type definitions */
27
28#ifndef FLEXINT_H
29#define FLEXINT_H
30
31/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
33#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
34#include <inttypes.h>
35typedef int8_t flex_int8_t;
36typedef uint8_t flex_uint8_t;
37typedef int16_t flex_int16_t;
38typedef uint16_t flex_uint16_t;
39typedef int32_t flex_int32_t;
40typedef uint32_t flex_uint32_t;
41#else
42typedef signed char flex_int8_t;
43typedef short int flex_int16_t;
44typedef int flex_int32_t;
45typedef unsigned char flex_uint8_t;
46typedef unsigned short int flex_uint16_t;
47typedef unsigned int flex_uint32_t;
48#endif /* ! C99 */
49
50/* Limits of integral types. */
51#ifndef INT8_MIN
52#define INT8_MIN (-128)
53#endif
54#ifndef INT16_MIN
55#define INT16_MIN (-32767-1)
56#endif
57#ifndef INT32_MIN
58#define INT32_MIN (-2147483647-1)
59#endif
60#ifndef INT8_MAX
61#define INT8_MAX (127)
62#endif
63#ifndef INT16_MAX
64#define INT16_MAX (32767)
65#endif
66#ifndef INT32_MAX
67#define INT32_MAX (2147483647)
68#endif
69#ifndef UINT8_MAX
70#define UINT8_MAX (255U)
71#endif
72#ifndef UINT16_MAX
73#define UINT16_MAX (65535U)
74#endif
75#ifndef UINT32_MAX
76#define UINT32_MAX (4294967295U)
77#endif
78
79#endif /* ! FLEXINT_H */
80
81#ifdef __cplusplus
82
83/* The "const" storage-class-modifier is valid. */
84#define YY_USE_CONST
85
86#else /* ! __cplusplus */
87
88#if __STDC__
89
90#define YY_USE_CONST
91
92#endif /* __STDC__ */
93#endif /* ! __cplusplus */
94
95#ifdef YY_USE_CONST
96#define yyconst const
97#else
98#define yyconst
99#endif
100
101/* Returned upon end-of-file. */
102#define YY_NULL 0
103
104/* Promotes a possibly negative, possibly signed char to an unsigned
105 * integer for use as an array index. If the signed char is negative,
106 * we want to instead treat it as an 8-bit unsigned char, hence the
107 * double cast.
108 */
109#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
110
111/* Enter a start condition. This macro really ought to take a parameter,
112 * but we do it the disgusting crufty way forced on us by the ()-less
113 * definition of BEGIN.
114 */
115#define BEGIN (yy_start) = 1 + 2 *
116
117/* Translate the current start state into a value that can be later handed
118 * to BEGIN to return to the state. The YYSTATE alias is for lex
119 * compatibility.
120 */
121#define YY_START (((yy_start) - 1) / 2)
122#define YYSTATE YY_START
123
124/* Action number for EOF rule of a given start state. */
125#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
126
127/* Special action meaning "start processing a new file". */
128#define YY_NEW_FILE zconfrestart(zconfin )
129
130#define YY_END_OF_BUFFER_CHAR 0
131
132/* Size of default input buffer. */
133#ifndef YY_BUF_SIZE
134#define YY_BUF_SIZE 16384
135#endif
136
137#ifndef YY_TYPEDEF_YY_BUFFER_STATE
138#define YY_TYPEDEF_YY_BUFFER_STATE
139typedef struct yy_buffer_state *YY_BUFFER_STATE;
140#endif
141
142extern int zconfleng;
143
144extern FILE *zconfin, *zconfout;
145
146#define EOB_ACT_CONTINUE_SCAN 0
147#define EOB_ACT_END_OF_FILE 1
148#define EOB_ACT_LAST_MATCH 2
149
150 #define YY_LESS_LINENO(n)
151
152/* Return all but the first "n" matched characters back to the input stream. */
153#define yyless(n) \
154 do \
155 { \
156 /* Undo effects of setting up zconftext. */ \
157 int yyless_macro_arg = (n); \
158 YY_LESS_LINENO(yyless_macro_arg);\
159 *yy_cp = (yy_hold_char); \
160 YY_RESTORE_YY_MORE_OFFSET \
161 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
162 YY_DO_BEFORE_ACTION; /* set up zconftext again */ \
163 } \
164 while ( 0 )
165
166#define unput(c) yyunput( c, (yytext_ptr) )
167
168/* The following is because we cannot portably get our hands on size_t
169 * (without autoconf's help, which isn't available because we want
170 * flex-generated scanners to compile on their own).
171 */
172
173#ifndef YY_TYPEDEF_YY_SIZE_T
174#define YY_TYPEDEF_YY_SIZE_T
175typedef unsigned int yy_size_t;
176#endif
177
178#ifndef YY_STRUCT_YY_BUFFER_STATE
179#define YY_STRUCT_YY_BUFFER_STATE
180struct yy_buffer_state
181 {
182 FILE *yy_input_file;
183
184 char *yy_ch_buf; /* input buffer */
185 char *yy_buf_pos; /* current position in input buffer */
186
187 /* Size of input buffer in bytes, not including room for EOB
188 * characters.
189 */
190 yy_size_t yy_buf_size;
191
192 /* Number of characters read into yy_ch_buf, not including EOB
193 * characters.
194 */
195 int yy_n_chars;
196
197 /* Whether we "own" the buffer - i.e., we know we created it,
198 * and can realloc() it to grow it, and should free() it to
199 * delete it.
200 */
201 int yy_is_our_buffer;
202
203 /* Whether this is an "interactive" input source; if so, and
204 * if we're using stdio for input, then we want to use getc()
205 * instead of fread(), to make sure we stop fetching input after
206 * each newline.
207 */
208 int yy_is_interactive;
209
210 /* Whether we're considered to be at the beginning of a line.
211 * If so, '^' rules will be active on the next match, otherwise
212 * not.
213 */
214 int yy_at_bol;
215
216 int yy_bs_lineno; /**< The line count. */
217 int yy_bs_column; /**< The column count. */
218
219 /* Whether to try to fill the input buffer when we reach the
220 * end of it.
221 */
222 int yy_fill_buffer;
223
224 int yy_buffer_status;
225
226#define YY_BUFFER_NEW 0
227#define YY_BUFFER_NORMAL 1
228 /* When an EOF's been seen but there's still some text to process
229 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
230 * shouldn't try reading from the input source any more. We might
231 * still have a bunch of tokens to match, though, because of
232 * possible backing-up.
233 *
234 * When we actually see the EOF, we change the status to "new"
235 * (via zconfrestart()), so that the user can continue scanning by
236 * just pointing zconfin at a new input file.
237 */
238#define YY_BUFFER_EOF_PENDING 2
239
240 };
241#endif /* !YY_STRUCT_YY_BUFFER_STATE */
242
243/* Stack of input buffers. */
244static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
245static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
246static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
247
248/* We provide macros for accessing buffer states in case in the
249 * future we want to put the buffer states in a more general
250 * "scanner state".
251 *
252 * Returns the top of the stack, or NULL.
253 */
254#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
255 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
256 : NULL)
257
258/* Same as previous macro, but useful when we know that the buffer stack is not
259 * NULL or when we need an lvalue. For internal use only.
260 */
261#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
262
263/* yy_hold_char holds the character lost when zconftext is formed. */
264static char yy_hold_char;
265static int yy_n_chars; /* number of characters read into yy_ch_buf */
266int zconfleng;
267
268/* Points to current character in buffer. */
269static char *yy_c_buf_p = (char *) 0;
270static int yy_init = 1; /* whether we need to initialize */
271static int yy_start = 0; /* start state number */
272
273/* Flag which is used to allow zconfwrap()'s to do buffer switches
274 * instead of setting up a fresh zconfin. A bit of a hack ...
275 */
276static int yy_did_buffer_switch_on_eof;
277
278void zconfrestart (FILE *input_file );
279void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer );
280YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size );
281void zconf_delete_buffer (YY_BUFFER_STATE b );
282void zconf_flush_buffer (YY_BUFFER_STATE b );
283void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer );
284void zconfpop_buffer_state (void );
285
286static void zconfensure_buffer_stack (void );
287static void zconf_load_buffer_state (void );
288static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file );
289
290#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER )
291
292YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size );
293YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str );
294YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len );
295
296void *zconfalloc (yy_size_t );
297void *zconfrealloc (void *,yy_size_t );
298void zconffree (void * );
299
300#define yy_new_buffer zconf_create_buffer
301
302#define yy_set_interactive(is_interactive) \
303 { \
304 if ( ! YY_CURRENT_BUFFER ){ \
305 zconfensure_buffer_stack (); \
306 YY_CURRENT_BUFFER_LVALUE = \
307 zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
308 } \
309 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
310 }
311
312#define yy_set_bol(at_bol) \
313 { \
314 if ( ! YY_CURRENT_BUFFER ){\
315 zconfensure_buffer_stack (); \
316 YY_CURRENT_BUFFER_LVALUE = \
317 zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
318 } \
319 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
320 }
321
322#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
323
324/* Begin user sect3 */
325
326#define zconfwrap(n) 1
327#define YY_SKIP_YYWRAP
328
329typedef unsigned char YY_CHAR;
330
331FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0;
332
333typedef int yy_state_type;
334
335extern int zconflineno;
336
337int zconflineno = 1;
338
339extern char *zconftext;
340#define yytext_ptr zconftext
341static yyconst flex_int16_t yy_nxt[][38] =
342 {
343 {
344 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
346 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
347 0, 0, 0, 0, 0, 0, 0, 0
348 },
349
350 {
351 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
352 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
353 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
354 12, 12, 12, 12, 12, 12, 12, 12
355 },
356
357 {
358 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
359 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
360
361 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
362 12, 12, 12, 12, 12, 12, 12, 12
363 },
364
365 {
366 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
367 16, 16, 16, 18, 16, 16, 18, 18, 19, 20,
368 21, 22, 18, 18, 23, 24, 18, 25, 18, 26,
369 27, 18, 28, 29, 30, 18, 18, 16
370 },
371
372 {
373 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
374 16, 16, 16, 18, 16, 16, 18, 18, 19, 20,
375 21, 22, 18, 18, 23, 24, 18, 25, 18, 26,
376 27, 18, 28, 29, 30, 18, 18, 16
377
378 },
379
380 {
381 11, 31, 32, 33, 31, 31, 31, 31, 31, 31,
382 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
383 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
384 31, 31, 31, 31, 31, 31, 31, 31
385 },
386
387 {
388 11, 31, 32, 33, 31, 31, 31, 31, 31, 31,
389 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
390 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
391 31, 31, 31, 31, 31, 31, 31, 31
392 },
393
394 {
395 11, 34, 34, 35, 34, 36, 34, 34, 36, 34,
396 34, 34, 34, 34, 34, 37, 34, 34, 34, 34,
397
398 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
399 34, 34, 34, 34, 34, 34, 34, 34
400 },
401
402 {
403 11, 34, 34, 35, 34, 36, 34, 34, 36, 34,
404 34, 34, 34, 34, 34, 37, 34, 34, 34, 34,
405 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
406 34, 34, 34, 34, 34, 34, 34, 34
407 },
408
409 {
410 11, 38, 38, 39, 40, 41, 42, 43, 41, 44,
411 45, 46, 47, 47, 48, 49, 47, 47, 47, 47,
412 47, 47, 47, 47, 47, 50, 47, 47, 47, 51,
413 47, 47, 47, 47, 47, 47, 47, 52
414
415 },
416
417 {
418 11, 38, 38, 39, 40, 41, 42, 43, 41, 44,
419 45, 46, 47, 47, 48, 49, 47, 47, 47, 47,
420 47, 47, 47, 47, 47, 50, 47, 47, 47, 51,
421 47, 47, 47, 47, 47, 47, 47, 52
422 },
423
424 {
425 -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
426 -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
427 -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
428 -11, -11, -11, -11, -11, -11, -11, -11
429 },
430
431 {
432 11, -12, -12, -12, -12, -12, -12, -12, -12, -12,
433 -12, -12, -12, -12, -12, -12, -12, -12, -12, -12,
434
435 -12, -12, -12, -12, -12, -12, -12, -12, -12, -12,
436 -12, -12, -12, -12, -12, -12, -12, -12
437 },
438
439 {
440 11, -13, 53, 54, -13, -13, 55, -13, -13, -13,
441 -13, -13, -13, -13, -13, -13, -13, -13, -13, -13,
442 -13, -13, -13, -13, -13, -13, -13, -13, -13, -13,
443 -13, -13, -13, -13, -13, -13, -13, -13
444 },
445
446 {
447 11, -14, -14, -14, -14, -14, -14, -14, -14, -14,
448 -14, -14, -14, -14, -14, -14, -14, -14, -14, -14,
449 -14, -14, -14, -14, -14, -14, -14, -14, -14, -14,
450 -14, -14, -14, -14, -14, -14, -14, -14
451
452 },
453
454 {
455 11, 56, 56, 57, 56, 56, 56, 56, 56, 56,
456 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
457 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
458 56, 56, 56, 56, 56, 56, 56, 56
459 },
460
461 {
462 11, -16, -16, -16, -16, -16, -16, -16, -16, -16,
463 -16, -16, -16, -16, -16, -16, -16, -16, -16, -16,
464 -16, -16, -16, -16, -16, -16, -16, -16, -16, -16,
465 -16, -16, -16, -16, -16, -16, -16, -16
466 },
467
468 {
469 11, -17, -17, -17, -17, -17, -17, -17, -17, -17,
470 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
471
472 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
473 -17, -17, -17, -17, -17, -17, -17, -17
474 },
475
476 {
477 11, -18, -18, -18, -18, -18, -18, -18, -18, -18,
478 -18, -18, -18, 58, -18, -18, 58, 58, 58, 58,
479 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
480 58, 58, 58, 58, 58, 58, 58, -18
481 },
482
483 {
484 11, -19, -19, -19, -19, -19, -19, -19, -19, -19,
485 -19, -19, -19, 58, -19, -19, 58, 58, 58, 58,
486 58, 58, 58, 58, 58, 58, 58, 58, 58, 59,
487 58, 58, 58, 58, 58, 58, 58, -19
488
489 },
490
491 {
492 11, -20, -20, -20, -20, -20, -20, -20, -20, -20,
493 -20, -20, -20, 58, -20, -20, 58, 58, 58, 58,
494 58, 58, 58, 58, 60, 58, 58, 58, 58, 61,
495 58, 58, 58, 58, 58, 58, 58, -20
496 },
497
498 {
499 11, -21, -21, -21, -21, -21, -21, -21, -21, -21,
500 -21, -21, -21, 58, -21, -21, 58, 58, 58, 58,
501 58, 62, 58, 58, 58, 58, 58, 58, 58, 58,
502 58, 58, 58, 58, 58, 58, 58, -21
503 },
504
505 {
506 11, -22, -22, -22, -22, -22, -22, -22, -22, -22,
507 -22, -22, -22, 58, -22, -22, 58, 58, 58, 58,
508
509 58, 58, 58, 58, 58, 58, 58, 58, 63, 58,
510 58, 58, 58, 58, 58, 58, 58, -22
511 },
512
513 {
514 11, -23, -23, -23, -23, -23, -23, -23, -23, -23,
515 -23, -23, -23, 58, -23, -23, 58, 58, 58, 58,
516 58, 64, 58, 58, 58, 58, 58, 58, 58, 58,
517 58, 58, 58, 58, 58, 58, 58, -23
518 },
519
520 {
521 11, -24, -24, -24, -24, -24, -24, -24, -24, -24,
522 -24, -24, -24, 58, -24, -24, 58, 58, 58, 58,
523 58, 58, 65, 58, 58, 58, 58, 58, 66, 58,
524 58, 58, 58, 58, 58, 58, 58, -24
525
526 },
527
528 {
529 11, -25, -25, -25, -25, -25, -25, -25, -25, -25,
530 -25, -25, -25, 58, -25, -25, 58, 67, 58, 58,
531 58, 68, 58, 58, 58, 58, 58, 58, 58, 58,
532 58, 58, 58, 58, 58, 58, 58, -25
533 },
534
535 {
536 11, -26, -26, -26, -26, -26, -26, -26, -26, -26,
537 -26, -26, -26, 58, -26, -26, 58, 58, 58, 58,
538 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
539 69, 58, 58, 58, 58, 58, 58, -26
540 },
541
542 {
543 11, -27, -27, -27, -27, -27, -27, -27, -27, -27,
544 -27, -27, -27, 58, -27, -27, 58, 58, 58, 58,
545
546 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
547 58, 58, 70, 58, 58, 58, 58, -27
548 },
549
550 {
551 11, -28, -28, -28, -28, -28, -28, -28, -28, -28,
552 -28, -28, -28, 58, -28, -28, 58, 71, 58, 58,
553 58, 72, 58, 58, 58, 58, 58, 58, 58, 58,
554 58, 58, 58, 58, 58, 58, 58, -28
555 },
556
557 {
558 11, -29, -29, -29, -29, -29, -29, -29, -29, -29,
559 -29, -29, -29, 58, -29, -29, 58, 58, 58, 58,
560 58, 73, 58, 58, 58, 58, 58, 58, 58, 74,
561 58, 58, 58, 58, 75, 58, 58, -29
562
563 },
564
565 {
566 11, -30, -30, -30, -30, -30, -30, -30, -30, -30,
567 -30, -30, -30, 58, -30, -30, 58, 58, 58, 58,
568 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
569 58, 58, 76, 58, 58, 58, 58, -30
570 },
571
572 {
573 11, 77, 77, -31, 77, 77, 77, 77, 77, 77,
574 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
575 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
576 77, 77, 77, 77, 77, 77, 77, 77
577 },
578
579 {
580 11, -32, 78, 79, -32, -32, -32, -32, -32, -32,
581 -32, -32, -32, -32, -32, -32, -32, -32, -32, -32,
582
583 -32, -32, -32, -32, -32, -32, -32, -32, -32, -32,
584 -32, -32, -32, -32, -32, -32, -32, -32
585 },
586
587 {
588 11, 80, -33, -33, 80, 80, 80, 80, 80, 80,
589 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
590 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
591 80, 80, 80, 80, 80, 80, 80, 80
592 },
593
594 {
595 11, 81, 81, 82, 81, -34, 81, 81, -34, 81,
596 81, 81, 81, 81, 81, -34, 81, 81, 81, 81,
597 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
598 81, 81, 81, 81, 81, 81, 81, 81
599
600 },
601
602 {
603 11, -35, -35, -35, -35, -35, -35, -35, -35, -35,
604 -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
605 -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
606 -35, -35, -35, -35, -35, -35, -35, -35
607 },
608
609 {
610 11, -36, -36, -36, -36, -36, -36, -36, -36, -36,
611 -36, -36, -36, -36, -36, -36, -36, -36, -36, -36,
612 -36, -36, -36, -36, -36, -36, -36, -36, -36, -36,
613 -36, -36, -36, -36, -36, -36, -36, -36
614 },
615
616 {
617 11, 83, 83, 84, 83, 83, 83, 83, 83, 83,
618 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
619
620 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
621 83, 83, 83, 83, 83, 83, 83, 83
622 },
623
624 {
625 11, -38, -38, -38, -38, -38, -38, -38, -38, -38,
626 -38, -38, -38, -38, -38, -38, -38, -38, -38, -38,
627 -38, -38, -38, -38, -38, -38, -38, -38, -38, -38,
628 -38, -38, -38, -38, -38, -38, -38, -38
629 },
630
631 {
632 11, -39, -39, -39, -39, -39, -39, -39, -39, -39,
633 -39, -39, -39, -39, -39, -39, -39, -39, -39, -39,
634 -39, -39, -39, -39, -39, -39, -39, -39, -39, -39,
635 -39, -39, -39, -39, -39, -39, -39, -39
636
637 },
638
639 {
640 11, -40, -40, -40, -40, -40, -40, -40, -40, -40,
641 -40, -40, -40, -40, 85, -40, -40, -40, -40, -40,
642 -40, -40, -40, -40, -40, -40, -40, -40, -40, -40,
643 -40, -40, -40, -40, -40, -40, -40, -40
644 },
645
646 {
647 11, -41, -41, -41, -41, -41, -41, -41, -41, -41,
648 -41, -41, -41, -41, -41, -41, -41, -41, -41, -41,
649 -41, -41, -41, -41, -41, -41, -41, -41, -41, -41,
650 -41, -41, -41, -41, -41, -41, -41, -41
651 },
652
653 {
654 11, 86, 86, -42, 86, 86, 86, 86, 86, 86,
655 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
656
657 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
658 86, 86, 86, 86, 86, 86, 86, 86
659 },
660
661 {
662 11, -43, -43, -43, -43, -43, -43, 87, -43, -43,
663 -43, -43, -43, -43, -43, -43, -43, -43, -43, -43,
664 -43, -43, -43, -43, -43, -43, -43, -43, -43, -43,
665 -43, -43, -43, -43, -43, -43, -43, -43
666 },
667
668 {
669 11, -44, -44, -44, -44, -44, -44, -44, -44, -44,
670 -44, -44, -44, -44, -44, -44, -44, -44, -44, -44,
671 -44, -44, -44, -44, -44, -44, -44, -44, -44, -44,
672 -44, -44, -44, -44, -44, -44, -44, -44
673
674 },
675
676 {
677 11, -45, -45, -45, -45, -45, -45, -45, -45, -45,
678 -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
679 -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
680 -45, -45, -45, -45, -45, -45, -45, -45
681 },
682
683 {
684 11, -46, -46, -46, -46, -46, -46, -46, -46, -46,
685 -46, 88, 89, 89, -46, -46, 89, 89, 89, 89,
686 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
687 89, 89, 89, 89, 89, 89, 89, -46
688 },
689
690 {
691 11, -47, -47, -47, -47, -47, -47, -47, -47, -47,
692 -47, 89, 89, 89, -47, -47, 89, 89, 89, 89,
693
694 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
695 89, 89, 89, 89, 89, 89, 89, -47
696 },
697
698 {
699 11, -48, -48, -48, -48, -48, -48, -48, -48, -48,
700 -48, -48, -48, -48, -48, -48, -48, -48, -48, -48,
701 -48, -48, -48, -48, -48, -48, -48, -48, -48, -48,
702 -48, -48, -48, -48, -48, -48, -48, -48
703 },
704
705 {
706 11, -49, -49, 90, -49, -49, -49, -49, -49, -49,
707 -49, -49, -49, -49, -49, -49, -49, -49, -49, -49,
708 -49, -49, -49, -49, -49, -49, -49, -49, -49, -49,
709 -49, -49, -49, -49, -49, -49, -49, -49
710
711 },
712
713 {
714 11, -50, -50, -50, -50, -50, -50, -50, -50, -50,
715 -50, 89, 89, 89, -50, -50, 89, 89, 89, 89,
716 89, 89, 91, 89, 89, 89, 89, 89, 89, 89,
717 89, 89, 89, 89, 89, 89, 89, -50
718 },
719
720 {
721 11, -51, -51, -51, -51, -51, -51, -51, -51, -51,
722 -51, 89, 89, 89, -51, -51, 89, 89, 89, 89,
723 89, 89, 89, 89, 89, 89, 89, 89, 92, 89,
724 89, 89, 89, 89, 89, 89, 89, -51
725 },
726
727 {
728 11, -52, -52, -52, -52, -52, -52, -52, -52, -52,
729 -52, -52, -52, -52, -52, -52, -52, -52, -52, -52,
730
731 -52, -52, -52, -52, -52, -52, -52, -52, -52, -52,
732 -52, -52, -52, -52, -52, -52, -52, 93
733 },
734
735 {
736 11, -53, 53, 54, -53, -53, 55, -53, -53, -53,
737 -53, -53, -53, -53, -53, -53, -53, -53, -53, -53,
738 -53, -53, -53, -53, -53, -53, -53, -53, -53, -53,
739 -53, -53, -53, -53, -53, -53, -53, -53
740 },
741
742 {
743 11, -54, -54, -54, -54, -54, -54, -54, -54, -54,
744 -54, -54, -54, -54, -54, -54, -54, -54, -54, -54,
745 -54, -54, -54, -54, -54, -54, -54, -54, -54, -54,
746 -54, -54, -54, -54, -54, -54, -54, -54
747
748 },
749
750 {
751 11, 56, 56, 57, 56, 56, 56, 56, 56, 56,
752 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
753 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
754 56, 56, 56, 56, 56, 56, 56, 56
755 },
756
757 {
758 11, 56, 56, 57, 56, 56, 56, 56, 56, 56,
759 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
760 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
761 56, 56, 56, 56, 56, 56, 56, 56
762 },
763
764 {
765 11, -57, -57, -57, -57, -57, -57, -57, -57, -57,
766 -57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
767
768 -57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
769 -57, -57, -57, -57, -57, -57, -57, -57
770 },
771
772 {
773 11, -58, -58, -58, -58, -58, -58, -58, -58, -58,
774 -58, -58, -58, 58, -58, -58, 58, 58, 58, 58,
775 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
776 58, 58, 58, 58, 58, 58, 58, -58
777 },
778
779 {
780 11, -59, -59, -59, -59, -59, -59, -59, -59, -59,
781 -59, -59, -59, 58, -59, -59, 58, 58, 58, 58,
782 58, 58, 58, 58, 58, 58, 58, 58, 58, 94,
783 58, 58, 58, 58, 58, 58, 58, -59
784
785 },
786
787 {
788 11, -60, -60, -60, -60, -60, -60, -60, -60, -60,
789 -60, -60, -60, 58, -60, -60, 58, 58, 58, 58,
790 58, 58, 58, 58, 58, 58, 58, 58, 58, 95,
791 58, 58, 58, 58, 58, 58, 58, -60
792 },
793
794 {
795 11, -61, -61, -61, -61, -61, -61, -61, -61, -61,
796 -61, -61, -61, 58, -61, -61, 58, 58, 58, 58,
797 58, 58, 58, 58, 58, 58, 58, 96, 97, 58,
798 58, 58, 58, 58, 58, 58, 58, -61
799 },
800
801 {
802 11, -62, -62, -62, -62, -62, -62, -62, -62, -62,
803 -62, -62, -62, 58, -62, -62, 58, 58, 58, 58,
804
805 58, 58, 98, 58, 58, 58, 58, 58, 58, 58,
806 99, 58, 58, 58, 58, 58, 58, -62
807 },
808
809 {
810 11, -63, -63, -63, -63, -63, -63, -63, -63, -63,
811 -63, -63, -63, 58, -63, -63, 58, 100, 58, 58,
812 101, 58, 58, 58, 58, 58, 58, 58, 58, 58,
813 58, 58, 58, 58, 58, 58, 58, -63
814 },
815
816 {
817 11, -64, -64, -64, -64, -64, -64, -64, -64, -64,
818 -64, -64, -64, 58, -64, -64, 58, 58, 58, 58,
819 58, 58, 58, 58, 58, 58, 102, 58, 58, 58,
820 58, 58, 58, 58, 58, 58, 103, -64
821
822 },
823
824 {
825 11, -65, -65, -65, -65, -65, -65, -65, -65, -65,
826 -65, -65, -65, 58, -65, -65, 58, 58, 58, 58,
827 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
828 58, 58, 58, 58, 58, 58, 58, -65
829 },
830
831 {
832 11, -66, -66, -66, -66, -66, -66, -66, -66, -66,
833 -66, -66, -66, 58, -66, -66, 58, 58, 58, 58,
834 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
835 58, 58, 58, 58, 104, 58, 58, -66
836 },
837
838 {
839 11, -67, -67, -67, -67, -67, -67, -67, -67, -67,
840 -67, -67, -67, 58, -67, -67, 58, 58, 58, 58,
841
842 58, 58, 58, 58, 58, 105, 58, 58, 58, 58,
843 58, 58, 58, 58, 58, 58, 58, -67
844 },
845
846 {
847 11, -68, -68, -68, -68, -68, -68, -68, -68, -68,
848 -68, -68, -68, 58, -68, -68, 58, 58, 58, 58,
849 58, 58, 58, 58, 58, 58, 58, 58, 106, 58,
850 58, 58, 58, 58, 58, 58, 58, -68
851 },
852
853 {
854 11, -69, -69, -69, -69, -69, -69, -69, -69, -69,
855 -69, -69, -69, 58, -69, -69, 58, 58, 58, 58,
856 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
857 58, 58, 58, 58, 107, 58, 58, -69
858
859 },
860
861 {
862 11, -70, -70, -70, -70, -70, -70, -70, -70, -70,
863 -70, -70, -70, 58, -70, -70, 58, 58, 58, 58,
864 58, 58, 58, 58, 58, 58, 58, 58, 58, 108,
865 58, 58, 58, 58, 58, 58, 58, -70
866 },
867
868 {
869 11, -71, -71, -71, -71, -71, -71, -71, -71, -71,
870 -71, -71, -71, 58, -71, -71, 58, 58, 58, 58,
871 58, 58, 58, 58, 58, 58, 58, 58, 109, 58,
872 58, 58, 58, 58, 58, 58, 58, -71
873 },
874
875 {
876 11, -72, -72, -72, -72, -72, -72, -72, -72, -72,
877 -72, -72, -72, 58, -72, -72, 58, 58, 58, 58,
878
879 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
880 58, 110, 58, 58, 58, 58, 58, -72
881 },
882
883 {
884 11, -73, -73, -73, -73, -73, -73, -73, -73, -73,
885 -73, -73, -73, 58, -73, -73, 58, 58, 58, 58,
886 58, 58, 58, 58, 58, 58, 111, 58, 58, 58,
887 58, 58, 58, 58, 58, 58, 58, -73
888 },
889
890 {
891 11, -74, -74, -74, -74, -74, -74, -74, -74, -74,
892 -74, -74, -74, 58, -74, -74, 58, 58, 58, 58,
893 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
894 58, 58, 58, 58, 58, 112, 58, -74
895
896 },
897
898 {
899 11, -75, -75, -75, -75, -75, -75, -75, -75, -75,
900 -75, -75, -75, 58, -75, -75, 58, 58, 58, 58,
901 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
902 58, 58, 113, 58, 58, 58, 58, -75
903 },
904
905 {
906 11, -76, -76, -76, -76, -76, -76, -76, -76, -76,
907 -76, -76, -76, 58, -76, -76, 58, 58, 58, 58,
908 58, 58, 58, 58, 58, 114, 58, 58, 58, 58,
909 58, 58, 58, 58, 58, 58, 58, -76
910 },
911
912 {
913 11, 77, 77, -77, 77, 77, 77, 77, 77, 77,
914 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
915
916 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
917 77, 77, 77, 77, 77, 77, 77, 77
918 },
919
920 {
921 11, -78, 78, 79, -78, -78, -78, -78, -78, -78,
922 -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
923 -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
924 -78, -78, -78, -78, -78, -78, -78, -78
925 },
926
927 {
928 11, 80, -79, -79, 80, 80, 80, 80, 80, 80,
929 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
930 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
931 80, 80, 80, 80, 80, 80, 80, 80
932
933 },
934
935 {
936 11, -80, -80, -80, -80, -80, -80, -80, -80, -80,
937 -80, -80, -80, -80, -80, -80, -80, -80, -80, -80,
938 -80, -80, -80, -80, -80, -80, -80, -80, -80, -80,
939 -80, -80, -80, -80, -80, -80, -80, -80
940 },
941
942 {
943 11, 81, 81, 82, 81, -81, 81, 81, -81, 81,
944 81, 81, 81, 81, 81, -81, 81, 81, 81, 81,
945 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
946 81, 81, 81, 81, 81, 81, 81, 81
947 },
948
949 {
950 11, -82, -82, -82, -82, -82, -82, -82, -82, -82,
951 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
952
953 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
954 -82, -82, -82, -82, -82, -82, -82, -82
955 },
956
957 {
958 11, -83, -83, 84, -83, -83, -83, -83, -83, -83,
959 -83, -83, -83, -83, -83, -83, -83, -83, -83, -83,
960 -83, -83, -83, -83, -83, -83, -83, -83, -83, -83,
961 -83, -83, -83, -83, -83, -83, -83, -83
962 },
963
964 {
965 11, -84, -84, -84, -84, -84, -84, -84, -84, -84,
966 -84, -84, -84, -84, -84, -84, -84, -84, -84, -84,
967 -84, -84, -84, -84, -84, -84, -84, -84, -84, -84,
968 -84, -84, -84, -84, -84, -84, -84, -84
969
970 },
971
972 {
973 11, -85, -85, -85, -85, -85, -85, -85, -85, -85,
974 -85, -85, -85, -85, -85, -85, -85, -85, -85, -85,
975 -85, -85, -85, -85, -85, -85, -85, -85, -85, -85,
976 -85, -85, -85, -85, -85, -85, -85, -85
977 },
978
979 {
980 11, 86, 86, -86, 86, 86, 86, 86, 86, 86,
981 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
982 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
983 86, 86, 86, 86, 86, 86, 86, 86
984 },
985
986 {
987 11, -87, -87, -87, -87, -87, -87, -87, -87, -87,
988 -87, -87, -87, -87, -87, -87, -87, -87, -87, -87,
989
990 -87, -87, -87, -87, -87, -87, -87, -87, -87, -87,
991 -87, -87, -87, -87, -87, -87, -87, -87
992 },
993
994 {
995 11, -88, -88, -88, -88, -88, -88, -88, -88, -88,
996 -88, 115, 89, 89, -88, -88, 89, 89, 89, 89,
997 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
998 89, 89, 89, 89, 89, 89, 89, -88
999 },
1000
1001 {
1002 11, -89, -89, -89, -89, -89, -89, -89, -89, -89,
1003 -89, 89, 89, 89, -89, -89, 89, 89, 89, 89,
1004 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
1005 89, 89, 89, 89, 89, 89, 89, -89
1006
1007 },
1008
1009 {
1010 11, -90, -90, -90, -90, -90, -90, -90, -90, -90,
1011 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
1012 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
1013 -90, -90, -90, -90, -90, -90, -90, -90
1014 },
1015
1016 {
1017 11, -91, -91, -91, -91, -91, -91, -91, -91, -91,
1018 -91, 89, 89, 89, -91, -91, 89, 89, 89, 89,
1019 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
1020 89, 89, 89, 89, 89, 89, 89, -91
1021 },
1022
1023 {
1024 11, -92, -92, -92, -92, -92, -92, -92, -92, -92,
1025 -92, 89, 89, 89, -92, -92, 89, 89, 89, 89,
1026
1027 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
1028 89, 89, 89, 89, 89, 89, 89, -92
1029 },
1030
1031 {
1032 11, -93, -93, -93, -93, -93, -93, -93, -93, -93,
1033 -93, -93, -93, -93, -93, -93, -93, -93, -93, -93,
1034 -93, -93, -93, -93, -93, -93, -93, -93, -93, -93,
1035 -93, -93, -93, -93, -93, -93, -93, -93
1036 },
1037
1038 {
1039 11, -94, -94, -94, -94, -94, -94, -94, -94, -94,
1040 -94, -94, -94, 58, -94, -94, 58, 58, 58, 58,
1041 58, 58, 58, 58, 58, 58, 116, 58, 58, 58,
1042 58, 58, 58, 58, 58, 58, 58, -94
1043
1044 },
1045
1046 {
1047 11, -95, -95, -95, -95, -95, -95, -95, -95, -95,
1048 -95, -95, -95, 58, -95, -95, 58, 58, 58, 58,
1049 58, 58, 58, 58, 58, 117, 58, 58, 58, 58,
1050 58, 58, 58, 58, 58, 58, 58, -95
1051 },
1052
1053 {
1054 11, -96, -96, -96, -96, -96, -96, -96, -96, -96,
1055 -96, -96, -96, 58, -96, -96, 58, 58, 58, 58,
1056 58, 58, 58, 58, 58, 58, 58, 118, 58, 58,
1057 58, 58, 58, 58, 58, 58, 58, -96
1058 },
1059
1060 {
1061 11, -97, -97, -97, -97, -97, -97, -97, -97, -97,
1062 -97, -97, -97, 58, -97, -97, 58, 58, 58, 58,
1063
1064 58, 58, 119, 58, 58, 58, 58, 58, 58, 58,
1065 58, 58, 58, 58, 58, 58, 58, -97
1066 },
1067
1068 {
1069 11, -98, -98, -98, -98, -98, -98, -98, -98, -98,
1070 -98, -98, -98, 58, -98, -98, 120, 121, 58, 58,
1071 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1072 58, 58, 58, 58, 58, 58, 58, -98
1073 },
1074
1075 {
1076 11, -99, -99, -99, -99, -99, -99, -99, -99, -99,
1077 -99, -99, -99, 58, -99, -99, 58, 58, 58, 58,
1078 58, 122, 58, 58, 58, 58, 58, 58, 58, 58,
1079 58, 58, 58, 58, 58, 58, 58, -99
1080
1081 },
1082
1083 {
1084 11, -100, -100, -100, -100, -100, -100, -100, -100, -100,
1085 -100, -100, -100, 58, -100, -100, 58, 58, 123, 58,
1086 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1087 58, 58, 58, 58, 58, 58, 58, -100
1088 },
1089
1090 {
1091 11, -101, -101, -101, -101, -101, -101, -101, -101, -101,
1092 -101, -101, -101, 58, -101, -101, 58, 58, 58, 124,
1093 58, 58, 58, 58, 58, 125, 58, 126, 58, 58,
1094 58, 58, 58, 58, 58, 58, 58, -101
1095 },
1096
1097 {
1098 11, -102, -102, -102, -102, -102, -102, -102, -102, -102,
1099 -102, -102, -102, 58, -102, -102, 58, 58, 58, 58,
1100
1101 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1102 127, 58, 58, 58, 58, 58, 58, -102
1103 },
1104
1105 {
1106 11, -103, -103, -103, -103, -103, -103, -103, -103, -103,
1107 -103, -103, -103, 58, -103, -103, 58, 58, 58, 58,
1108 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1109 58, 58, 58, 58, 58, 58, 58, -103
1110 },
1111
1112 {
1113 11, -104, -104, -104, -104, -104, -104, -104, -104, -104,
1114 -104, -104, -104, 58, -104, -104, 58, 58, 58, 58,
1115 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1116 58, 58, 58, 58, 58, 58, 58, -104
1117
1118 },
1119
1120 {
1121 11, -105, -105, -105, -105, -105, -105, -105, -105, -105,
1122 -105, -105, -105, 58, -105, -105, 58, 58, 58, 58,
1123 58, 58, 58, 58, 58, 58, 58, 58, 128, 58,
1124 58, 58, 58, 58, 58, 58, 58, -105
1125 },
1126
1127 {
1128 11, -106, -106, -106, -106, -106, -106, -106, -106, -106,
1129 -106, -106, -106, 58, -106, -106, 58, 58, 58, 58,
1130 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1131 58, 58, 58, 58, 58, 129, 58, -106
1132 },
1133
1134 {
1135 11, -107, -107, -107, -107, -107, -107, -107, -107, -107,
1136 -107, -107, -107, 58, -107, -107, 58, 58, 58, 58,
1137
1138 58, 58, 58, 58, 58, 130, 58, 58, 58, 58,
1139 58, 58, 58, 58, 58, 58, 58, -107
1140 },
1141
1142 {
1143 11, -108, -108, -108, -108, -108, -108, -108, -108, -108,
1144 -108, -108, -108, 58, -108, -108, 58, 58, 58, 58,
1145 58, 58, 58, 58, 58, 58, 58, 131, 58, 58,
1146 58, 58, 58, 58, 58, 58, 58, -108
1147 },
1148
1149 {
1150 11, -109, -109, -109, -109, -109, -109, -109, -109, -109,
1151 -109, -109, -109, 58, -109, -109, 58, 58, 58, 58,
1152 58, 58, 58, 132, 58, 58, 58, 58, 58, 58,
1153 58, 58, 58, 58, 58, 58, 58, -109
1154
1155 },
1156
1157 {
1158 11, -110, -110, -110, -110, -110, -110, -110, -110, -110,
1159 -110, -110, -110, 58, -110, -110, 58, 58, 58, 58,
1160 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1161 58, 58, 58, 58, 58, 133, 58, -110
1162 },
1163
1164 {
1165 11, -111, -111, -111, -111, -111, -111, -111, -111, -111,
1166 -111, -111, -111, 58, -111, -111, 58, 58, 58, 58,
1167 58, 134, 58, 58, 58, 58, 58, 58, 58, 58,
1168 58, 58, 58, 58, 58, 58, 58, -111
1169 },
1170
1171 {
1172 11, -112, -112, -112, -112, -112, -112, -112, -112, -112,
1173 -112, -112, -112, 58, -112, -112, 58, 58, 58, 58,
1174
1175 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1176 58, 58, 135, 58, 58, 58, 58, -112
1177 },
1178
1179 {
1180 11, -113, -113, -113, -113, -113, -113, -113, -113, -113,
1181 -113, -113, -113, 58, -113, -113, 58, 58, 58, 58,
1182 58, 58, 58, 58, 58, 136, 58, 58, 58, 58,
1183 58, 58, 58, 58, 58, 58, 58, -113
1184 },
1185
1186 {
1187 11, -114, -114, -114, -114, -114, -114, -114, -114, -114,
1188 -114, -114, -114, 58, -114, -114, 58, 58, 58, 58,
1189 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1190 58, 58, 58, 137, 58, 58, 58, -114
1191
1192 },
1193
1194 {
1195 11, -115, -115, -115, -115, -115, -115, -115, -115, -115,
1196 -115, 89, 89, 89, -115, -115, 89, 89, 89, 89,
1197 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
1198 89, 89, 89, 89, 89, 89, 89, -115
1199 },
1200
1201 {
1202 11, -116, -116, -116, -116, -116, -116, -116, -116, -116,
1203 -116, -116, -116, 58, -116, -116, 58, 58, 58, 58,
1204 58, 138, 58, 58, 58, 58, 58, 58, 58, 58,
1205 58, 58, 58, 58, 58, 58, 58, -116
1206 },
1207
1208 {
1209 11, -117, -117, -117, -117, -117, -117, -117, -117, -117,
1210 -117, -117, -117, 58, -117, -117, 58, 58, 58, 139,
1211
1212 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1213 58, 58, 58, 58, 58, 58, 58, -117
1214 },
1215
1216 {
1217 11, -118, -118, -118, -118, -118, -118, -118, -118, -118,
1218 -118, -118, -118, 58, -118, -118, 58, 58, 58, 58,
1219 58, 140, 58, 58, 58, 58, 58, 58, 58, 58,
1220 58, 58, 58, 58, 58, 58, 58, -118
1221 },
1222
1223 {
1224 11, -119, -119, -119, -119, -119, -119, -119, -119, -119,
1225 -119, -119, -119, 58, -119, -119, 58, 58, 58, 58,
1226 58, 58, 58, 58, 58, 141, 58, 58, 58, 58,
1227 58, 58, 58, 58, 58, 58, 58, -119
1228
1229 },
1230
1231 {
1232 11, -120, -120, -120, -120, -120, -120, -120, -120, -120,
1233 -120, -120, -120, 58, -120, -120, 58, 58, 142, 58,
1234 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1235 58, 58, 58, 58, 143, 58, 58, -120
1236 },
1237
1238 {
1239 11, -121, -121, -121, -121, -121, -121, -121, -121, -121,
1240 -121, -121, -121, 58, -121, -121, 58, 58, 58, 58,
1241 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1242 58, 58, 58, 58, 58, 144, 58, -121
1243 },
1244
1245 {
1246 11, -122, -122, -122, -122, -122, -122, -122, -122, -122,
1247 -122, -122, -122, 58, -122, -122, 58, 58, 58, 58,
1248
1249 58, 58, 58, 58, 58, 58, 58, 58, 145, 58,
1250 58, 58, 58, 58, 58, 58, 58, -122
1251 },
1252
1253 {
1254 11, -123, -123, -123, -123, -123, -123, -123, -123, -123,
1255 -123, -123, -123, 58, -123, -123, 58, 58, 58, 58,
1256 58, 58, 58, 58, 58, 58, 146, 58, 58, 58,
1257 58, 58, 58, 58, 58, 58, 58, -123
1258 },
1259
1260 {
1261 11, -124, -124, -124, -124, -124, -124, -124, -124, -124,
1262 -124, -124, -124, 58, -124, -124, 58, 58, 58, 58,
1263 58, 58, 58, 58, 147, 58, 58, 58, 58, 58,
1264 58, 58, 58, 58, 58, 58, 58, -124
1265
1266 },
1267
1268 {
1269 11, -125, -125, -125, -125, -125, -125, -125, -125, -125,
1270 -125, -125, -125, 58, -125, -125, 58, 58, 58, 58,
1271 58, 58, 148, 58, 58, 58, 58, 58, 58, 58,
1272 58, 58, 58, 58, 58, 58, 58, -125
1273 },
1274
1275 {
1276 11, -126, -126, -126, -126, -126, -126, -126, -126, -126,
1277 -126, -126, -126, 58, -126, -126, 58, 58, 58, 58,
1278 58, 149, 58, 58, 58, 58, 58, 58, 58, 58,
1279 58, 58, 58, 58, 58, 58, 58, -126
1280 },
1281
1282 {
1283 11, -127, -127, -127, -127, -127, -127, -127, -127, -127,
1284 -127, -127, -127, 58, -127, -127, 58, 58, 58, 58,
1285
1286 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1287 58, 58, 58, 58, 58, 58, 58, -127
1288 },
1289
1290 {
1291 11, -128, -128, -128, -128, -128, -128, -128, -128, -128,
1292 -128, -128, -128, 58, -128, -128, 58, 58, 58, 58,
1293 58, 58, 58, 58, 58, 58, 58, 150, 58, 58,
1294 58, 58, 58, 58, 58, 58, 58, -128
1295 },
1296
1297 {
1298 11, -129, -129, -129, -129, -129, -129, -129, -129, -129,
1299 -129, -129, -129, 58, -129, -129, 58, 58, 58, 151,
1300 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1301 58, 58, 58, 58, 58, 58, 58, -129
1302
1303 },
1304
1305 {
1306 11, -130, -130, -130, -130, -130, -130, -130, -130, -130,
1307 -130, -130, -130, 58, -130, -130, 58, 58, 58, 58,
1308 58, 58, 58, 58, 58, 58, 58, 58, 58, 152,
1309 58, 58, 58, 58, 58, 58, 58, -130
1310 },
1311
1312 {
1313 11, -131, -131, -131, -131, -131, -131, -131, -131, -131,
1314 -131, -131, -131, 58, -131, -131, 58, 58, 58, 58,
1315 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1316 153, 58, 58, 58, 58, 58, 58, -131
1317 },
1318
1319 {
1320 11, -132, -132, -132, -132, -132, -132, -132, -132, -132,
1321 -132, -132, -132, 58, -132, -132, 58, 58, 58, 58,
1322
1323 58, 154, 58, 58, 58, 58, 58, 58, 58, 58,
1324 58, 58, 58, 58, 58, 58, 58, -132
1325 },
1326
1327 {
1328 11, -133, -133, -133, -133, -133, -133, -133, -133, -133,
1329 -133, -133, -133, 58, -133, -133, 58, 58, 58, 58,
1330 58, 58, 58, 58, 58, 155, 58, 58, 58, 58,
1331 58, 58, 58, 58, 58, 58, 58, -133
1332 },
1333
1334 {
1335 11, -134, -134, -134, -134, -134, -134, -134, -134, -134,
1336 -134, -134, -134, 58, -134, -134, 58, 58, 58, 156,
1337 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1338 58, 58, 58, 58, 58, 58, 58, -134
1339
1340 },
1341
1342 {
1343 11, -135, -135, -135, -135, -135, -135, -135, -135, -135,
1344 -135, -135, -135, 58, -135, -135, 58, 58, 58, 157,
1345 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1346 58, 58, 58, 58, 58, 58, 58, -135
1347 },
1348
1349 {
1350 11, -136, -136, -136, -136, -136, -136, -136, -136, -136,
1351 -136, -136, -136, 58, -136, -136, 58, 58, 58, 58,
1352 58, 58, 58, 58, 58, 58, 58, 58, 158, 58,
1353 58, 58, 58, 58, 58, 58, 58, -136
1354 },
1355
1356 {
1357 11, -137, -137, -137, -137, -137, -137, -137, -137, -137,
1358 -137, -137, -137, 58, -137, -137, 58, 58, 58, 58,
1359
1360 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1361 58, 58, 58, 58, 159, 58, 58, -137
1362 },
1363
1364 {
1365 11, -138, -138, -138, -138, -138, -138, -138, -138, -138,
1366 -138, -138, -138, 58, -138, -138, 58, 160, 58, 58,
1367 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1368 58, 58, 58, 58, 58, 58, 58, -138
1369 },
1370
1371 {
1372 11, -139, -139, -139, -139, -139, -139, -139, -139, -139,
1373 -139, -139, -139, 58, -139, -139, 58, 58, 58, 58,
1374 58, 161, 58, 58, 58, 58, 58, 58, 58, 58,
1375 58, 58, 58, 58, 58, 58, 58, -139
1376
1377 },
1378
1379 {
1380 11, -140, -140, -140, -140, -140, -140, -140, -140, -140,
1381 -140, -140, -140, 58, -140, -140, 58, 58, 58, 58,
1382 58, 58, 58, 58, 58, 58, 58, 58, 162, 58,
1383 58, 58, 58, 58, 58, 58, 58, -140
1384 },
1385
1386 {
1387 11, -141, -141, -141, -141, -141, -141, -141, -141, -141,
1388 -141, -141, -141, 58, -141, -141, 58, 58, 58, 58,
1389 58, 58, 58, 163, 58, 58, 58, 58, 58, 58,
1390 58, 58, 58, 58, 58, 58, 58, -141
1391 },
1392
1393 {
1394 11, -142, -142, -142, -142, -142, -142, -142, -142, -142,
1395 -142, -142, -142, 58, -142, -142, 58, 58, 58, 58,
1396
1397 58, 58, 58, 58, 58, 58, 58, 58, 58, 164,
1398 58, 58, 58, 58, 58, 58, 58, -142
1399 },
1400
1401 {
1402 11, -143, -143, -143, -143, -143, -143, -143, -143, -143,
1403 -143, -143, -143, 58, -143, -143, 58, 58, 58, 58,
1404 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1405 58, 58, 165, 58, 58, 58, 58, -143
1406 },
1407
1408 {
1409 11, -144, -144, -144, -144, -144, -144, -144, -144, -144,
1410 -144, -144, -144, 58, -144, -144, 58, 58, 58, 58,
1411 58, 58, 58, 58, 58, 58, 166, 58, 58, 58,
1412 58, 58, 58, 58, 58, 58, 58, -144
1413
1414 },
1415
1416 {
1417 11, -145, -145, -145, -145, -145, -145, -145, -145, -145,
1418 -145, -145, -145, 58, -145, -145, 58, 58, 58, 58,
1419 167, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1420 58, 58, 58, 58, 58, 58, 58, -145
1421 },
1422
1423 {
1424 11, -146, -146, -146, -146, -146, -146, -146, -146, -146,
1425 -146, -146, -146, 58, -146, -146, 58, 58, 58, 58,
1426 58, 168, 58, 58, 58, 58, 58, 58, 58, 58,
1427 58, 58, 58, 58, 58, 58, 58, -146
1428 },
1429
1430 {
1431 11, -147, -147, -147, -147, -147, -147, -147, -147, -147,
1432 -147, -147, -147, 58, -147, -147, 58, 58, 58, 58,
1433
1434 58, 58, 58, 58, 58, 58, 58, 58, 58, 169,
1435 58, 58, 58, 58, 58, 58, 58, -147
1436 },
1437
1438 {
1439 11, -148, -148, -148, -148, -148, -148, -148, -148, -148,
1440 -148, -148, -148, 58, -148, -148, 58, 58, 58, 58,
1441 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1442 58, 58, 58, 58, 58, 58, 58, -148
1443 },
1444
1445 {
1446 11, -149, -149, -149, -149, -149, -149, -149, -149, -149,
1447 -149, -149, -149, 58, -149, -149, 58, 58, 58, 58,
1448 58, 58, 58, 58, 58, 58, 58, 58, 170, 58,
1449 58, 58, 58, 58, 58, 58, 58, -149
1450
1451 },
1452
1453 {
1454 11, -150, -150, -150, -150, -150, -150, -150, -150, -150,
1455 -150, -150, -150, 58, -150, -150, 58, 58, 58, 58,
1456 58, 171, 58, 58, 58, 58, 58, 58, 58, 58,
1457 58, 58, 58, 58, 58, 58, 58, -150
1458 },
1459
1460 {
1461 11, -151, -151, -151, -151, -151, -151, -151, -151, -151,
1462 -151, -151, -151, 58, -151, -151, 58, 58, 58, 58,
1463 58, 58, 58, 58, 58, 58, 58, 58, 58, 172,
1464 58, 58, 58, 58, 58, 58, 58, -151
1465 },
1466
1467 {
1468 11, -152, -152, -152, -152, -152, -152, -152, -152, -152,
1469 -152, -152, -152, 58, -152, -152, 58, 58, 58, 58,
1470
1471 58, 58, 58, 58, 58, 58, 58, 58, 173, 58,
1472 58, 58, 58, 58, 58, 58, 58, -152
1473 },
1474
1475 {
1476 11, -153, -153, -153, -153, -153, -153, -153, -153, -153,
1477 -153, -153, -153, 58, -153, -153, 58, 58, 58, 58,
1478 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1479 58, 58, 58, 58, 174, 58, 58, -153
1480 },
1481
1482 {
1483 11, -154, -154, -154, -154, -154, -154, -154, -154, -154,
1484 -154, -154, -154, 58, -154, -154, 58, 58, 58, 58,
1485 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1486 58, 58, 58, 58, 58, 58, 58, -154
1487
1488 },
1489
1490 {
1491 11, -155, -155, -155, -155, -155, -155, -155, -155, -155,
1492 -155, -155, -155, 58, -155, -155, 58, 58, 58, 58,
1493 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1494 58, 58, 175, 58, 58, 58, 58, -155
1495 },
1496
1497 {
1498 11, -156, -156, -156, -156, -156, -156, -156, -156, -156,
1499 -156, -156, -156, 58, -156, -156, 58, 58, 58, 58,
1500 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1501 58, 58, 58, 58, 176, 58, 58, -156
1502 },
1503
1504 {
1505 11, -157, -157, -157, -157, -157, -157, -157, -157, -157,
1506 -157, -157, -157, 58, -157, -157, 58, 58, 58, 58,
1507
1508 58, 177, 58, 58, 58, 58, 58, 58, 58, 58,
1509 58, 58, 58, 58, 58, 58, 58, -157
1510 },
1511
1512 {
1513 11, -158, -158, -158, -158, -158, -158, -158, -158, -158,
1514 -158, -158, -158, 58, -158, -158, 58, 58, 58, 58,
1515 58, 58, 58, 178, 58, 58, 58, 58, 58, 58,
1516 58, 58, 58, 58, 58, 58, 58, -158
1517 },
1518
1519 {
1520 11, -159, -159, -159, -159, -159, -159, -159, -159, -159,
1521 -159, -159, -159, 58, -159, -159, 58, 179, 58, 58,
1522 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1523 58, 58, 58, 58, 58, 58, 58, -159
1524
1525 },
1526
1527 {
1528 11, -160, -160, -160, -160, -160, -160, -160, -160, -160,
1529 -160, -160, -160, 58, -160, -160, 58, 58, 58, 58,
1530 58, 58, 58, 58, 58, 58, 58, 58, 180, 58,
1531 58, 58, 58, 58, 58, 58, 58, -160
1532 },
1533
1534 {
1535 11, -161, -161, -161, -161, -161, -161, -161, -161, -161,
1536 -161, -161, -161, 58, -161, -161, 58, 58, 58, 58,
1537 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1538 58, 58, 58, 58, 58, 58, 58, -161
1539 },
1540
1541 {
1542 11, -162, -162, -162, -162, -162, -162, -162, -162, -162,
1543 -162, -162, -162, 58, -162, -162, 58, 58, 58, 58,
1544
1545 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1546 58, 58, 58, 58, 181, 58, 58, -162
1547 },
1548
1549 {
1550 11, -163, -163, -163, -163, -163, -163, -163, -163, -163,
1551 -163, -163, -163, 58, -163, -163, 58, 58, 58, 58,
1552 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1553 58, 58, 58, 58, 58, 58, 58, -163
1554 },
1555
1556 {
1557 11, -164, -164, -164, -164, -164, -164, -164, -164, -164,
1558 -164, -164, -164, 58, -164, -164, 58, 58, 58, 58,
1559 58, 58, 58, 58, 58, 58, 58, 58, 58, 182,
1560 58, 58, 58, 58, 58, 58, 58, -164
1561
1562 },
1563
1564 {
1565 11, -165, -165, -165, -165, -165, -165, -165, -165, -165,
1566 -165, -165, -165, 58, -165, -165, 58, 58, 58, 58,
1567 58, 58, 58, 58, 58, 183, 58, 58, 58, 58,
1568 58, 58, 58, 58, 58, 58, 58, -165
1569 },
1570
1571 {
1572 11, -166, -166, -166, -166, -166, -166, -166, -166, -166,
1573 -166, -166, -166, 58, -166, -166, 58, 58, 58, 58,
1574 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1575 58, 58, 58, 58, 184, 58, 58, -166
1576 },
1577
1578 {
1579 11, -167, -167, -167, -167, -167, -167, -167, -167, -167,
1580 -167, -167, -167, 58, -167, -167, 58, 58, 58, 58,
1581
1582 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1583 58, 58, 58, 185, 58, 58, 58, -167
1584 },
1585
1586 {
1587 11, -168, -168, -168, -168, -168, -168, -168, -168, -168,
1588 -168, -168, -168, 58, -168, -168, 58, 58, 58, 58,
1589 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1590 58, 58, 58, 58, 58, 58, 58, -168
1591 },
1592
1593 {
1594 11, -169, -169, -169, -169, -169, -169, -169, -169, -169,
1595 -169, -169, -169, 58, -169, -169, 58, 58, 58, 58,
1596 58, 58, 58, 58, 58, 186, 58, 58, 58, 58,
1597 58, 58, 58, 58, 58, 58, 58, -169
1598
1599 },
1600
1601 {
1602 11, -170, -170, -170, -170, -170, -170, -170, -170, -170,
1603 -170, -170, -170, 58, -170, -170, 58, 58, 58, 58,
1604 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1605 58, 58, 58, 58, 58, 187, 58, -170
1606 },
1607
1608 {
1609 11, -171, -171, -171, -171, -171, -171, -171, -171, -171,
1610 -171, -171, -171, 58, -171, -171, 58, 58, 58, 58,
1611 58, 58, 58, 58, 58, 58, 58, 58, 188, 58,
1612 58, 58, 58, 58, 58, 58, 58, -171
1613 },
1614
1615 {
1616 11, -172, -172, -172, -172, -172, -172, -172, -172, -172,
1617 -172, -172, -172, 58, -172, -172, 58, 58, 58, 58,
1618
1619 58, 58, 58, 58, 58, 58, 58, 58, 189, 58,
1620 58, 58, 58, 58, 58, 58, 58, -172
1621 },
1622
1623 {
1624 11, -173, -173, -173, -173, -173, -173, -173, -173, -173,
1625 -173, -173, -173, 58, -173, -173, 58, 190, 58, 58,
1626 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1627 58, 58, 58, 58, 58, 58, 58, -173
1628 },
1629
1630 {
1631 11, -174, -174, -174, -174, -174, -174, -174, -174, -174,
1632 -174, -174, -174, 58, -174, -174, 58, 58, 58, 58,
1633 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1634 58, 58, 58, 58, 58, 58, 58, -174
1635
1636 },
1637
1638 {
1639 11, -175, -175, -175, -175, -175, -175, -175, -175, -175,
1640 -175, -175, -175, 58, -175, -175, 58, 58, 58, 58,
1641 58, 191, 58, 58, 58, 58, 58, 58, 58, 58,
1642 58, 58, 58, 58, 58, 58, 58, -175
1643 },
1644
1645 {
1646 11, -176, -176, -176, -176, -176, -176, -176, -176, -176,
1647 -176, -176, -176, 58, -176, -176, 58, 58, 58, 58,
1648 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1649 58, 58, 58, 58, 58, 58, 58, -176
1650 },
1651
1652 {
1653 11, -177, -177, -177, -177, -177, -177, -177, -177, -177,
1654 -177, -177, -177, 58, -177, -177, 58, 58, 58, 58,
1655
1656 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1657 58, 58, 58, 58, 58, 58, 58, -177
1658 },
1659
1660 {
1661 11, -178, -178, -178, -178, -178, -178, -178, -178, -178,
1662 -178, -178, -178, 58, -178, -178, 58, 58, 58, 58,
1663 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1664 58, 58, 58, 58, 58, 58, 58, -178
1665 },
1666
1667 {
1668 11, -179, -179, -179, -179, -179, -179, -179, -179, -179,
1669 -179, -179, -179, 58, -179, -179, 58, 58, 58, 58,
1670 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1671 58, 58, 58, 58, 192, 58, 58, -179
1672
1673 },
1674
1675 {
1676 11, -180, -180, -180, -180, -180, -180, -180, -180, -180,
1677 -180, -180, -180, 58, -180, -180, 58, 58, 58, 58,
1678 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1679 58, 58, 58, 58, 58, 58, 58, -180
1680 },
1681
1682 {
1683 11, -181, -181, -181, -181, -181, -181, -181, -181, -181,
1684 -181, -181, -181, 58, -181, -181, 58, 58, 58, 58,
1685 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1686 58, 58, 58, 58, 58, 58, 58, -181
1687 },
1688
1689 {
1690 11, -182, -182, -182, -182, -182, -182, -182, -182, -182,
1691 -182, -182, -182, 58, -182, -182, 58, 58, 58, 58,
1692
1693 58, 58, 58, 58, 58, 58, 193, 58, 58, 58,
1694 58, 58, 58, 58, 58, 58, 58, -182
1695 },
1696
1697 {
1698 11, -183, -183, -183, -183, -183, -183, -183, -183, -183,
1699 -183, -183, -183, 58, -183, -183, 58, 58, 58, 58,
1700 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1701 58, 58, 58, 194, 58, 58, 58, -183
1702 },
1703
1704 {
1705 11, -184, -184, -184, -184, -184, -184, -184, -184, -184,
1706 -184, -184, -184, 58, -184, -184, 58, 58, 58, 58,
1707 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1708 58, 58, 58, 58, 58, 58, 58, -184
1709
1710 },
1711
1712 {
1713 11, -185, -185, -185, -185, -185, -185, -185, -185, -185,
1714 -185, -185, -185, 58, -185, -185, 58, 58, 58, 58,
1715 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1716 58, 58, 58, 58, 58, 58, 58, -185
1717 },
1718
1719 {
1720 11, -186, -186, -186, -186, -186, -186, -186, -186, -186,
1721 -186, -186, -186, 58, -186, -186, 58, 58, 58, 195,
1722 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1723 58, 58, 58, 58, 58, 58, 58, -186
1724 },
1725
1726 {
1727 11, -187, -187, -187, -187, -187, -187, -187, -187, -187,
1728 -187, -187, -187, 58, -187, -187, 58, 58, 58, 58,
1729
1730 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1731 58, 58, 58, 58, 58, 58, 58, -187
1732 },
1733
1734 {
1735 11, -188, -188, -188, -188, -188, -188, -188, -188, -188,
1736 -188, -188, -188, 58, -188, -188, 58, 58, 58, 58,
1737 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1738 58, 58, 58, 58, 58, 196, 58, -188
1739 },
1740
1741 {
1742 11, -189, -189, -189, -189, -189, -189, -189, -189, -189,
1743 -189, -189, -189, 58, -189, -189, 58, 58, 58, 58,
1744 58, 58, 197, 58, 58, 58, 58, 58, 58, 58,
1745 58, 58, 58, 58, 58, 58, 58, -189
1746
1747 },
1748
1749 {
1750 11, -190, -190, -190, -190, -190, -190, -190, -190, -190,
1751 -190, -190, -190, 58, -190, -190, 58, 58, 58, 58,
1752 58, 58, 58, 58, 58, 58, 198, 58, 58, 58,
1753 58, 58, 58, 58, 58, 58, 58, -190
1754 },
1755
1756 {
1757 11, -191, -191, -191, -191, -191, -191, -191, -191, -191,
1758 -191, -191, -191, 58, -191, -191, 58, 58, 58, 58,
1759 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1760 58, 58, 58, 199, 58, 58, 58, -191
1761 },
1762
1763 {
1764 11, -192, -192, -192, -192, -192, -192, -192, -192, -192,
1765 -192, -192, -192, 58, -192, -192, 58, 58, 58, 58,
1766
1767 58, 200, 58, 58, 58, 58, 58, 58, 58, 58,
1768 58, 58, 58, 58, 58, 58, 58, -192
1769 },
1770
1771 {
1772 11, -193, -193, -193, -193, -193, -193, -193, -193, -193,
1773 -193, -193, -193, 58, -193, -193, 58, 58, 58, 58,
1774 58, 201, 58, 58, 58, 58, 58, 58, 58, 58,
1775 58, 58, 58, 58, 58, 58, 58, -193
1776 },
1777
1778 {
1779 11, -194, -194, -194, -194, -194, -194, -194, -194, -194,
1780 -194, -194, -194, 58, -194, -194, 58, 58, 58, 58,
1781 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1782 58, 58, 58, 58, 202, 58, 58, -194
1783
1784 },
1785
1786 {
1787 11, -195, -195, -195, -195, -195, -195, -195, -195, -195,
1788 -195, -195, -195, 58, -195, -195, 58, 58, 58, 58,
1789 58, 203, 58, 58, 58, 58, 58, 58, 58, 58,
1790 58, 58, 58, 58, 58, 58, 58, -195
1791 },
1792
1793 {
1794 11, -196, -196, -196, -196, -196, -196, -196, -196, -196,
1795 -196, -196, -196, 58, -196, -196, 58, 58, 58, 58,
1796 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1797 58, 58, 58, 58, 58, 58, 58, -196
1798 },
1799
1800 {
1801 11, -197, -197, -197, -197, -197, -197, -197, -197, -197,
1802 -197, -197, -197, 58, -197, -197, 58, 58, 58, 58,
1803
1804 58, 58, 58, 58, 58, 204, 58, 58, 58, 58,
1805 58, 58, 58, 58, 58, 58, 58, -197
1806 },
1807
1808 {
1809 11, -198, -198, -198, -198, -198, -198, -198, -198, -198,
1810 -198, -198, -198, 58, -198, -198, 58, 58, 58, 58,
1811 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1812 58, 58, 58, 58, 58, 58, 58, -198
1813 },
1814
1815 {
1816 11, -199, -199, -199, -199, -199, -199, -199, -199, -199,
1817 -199, -199, -199, 58, -199, -199, 58, 58, 58, 58,
1818 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1819 58, 58, 58, 58, 58, 58, 58, -199
1820
1821 },
1822
1823 {
1824 11, -200, -200, -200, -200, -200, -200, -200, -200, -200,
1825 -200, -200, -200, 58, -200, -200, 58, 58, 58, 58,
1826 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1827 58, 58, 58, 58, 58, 58, 58, -200
1828 },
1829
1830 {
1831 11, -201, -201, -201, -201, -201, -201, -201, -201, -201,
1832 -201, -201, -201, 58, -201, -201, 58, 205, 58, 58,
1833 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1834 58, 58, 58, 58, 58, 58, 58, -201
1835 },
1836
1837 {
1838 11, -202, -202, -202, -202, -202, -202, -202, -202, -202,
1839 -202, -202, -202, 58, -202, -202, 58, 206, 58, 58,
1840
1841 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1842 58, 58, 58, 58, 58, 58, 58, -202
1843 },
1844
1845 {
1846 11, -203, -203, -203, -203, -203, -203, -203, -203, -203,
1847 -203, -203, -203, 58, -203, -203, 58, 58, 58, 58,
1848 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1849 58, 58, 58, 58, 58, 58, 58, -203
1850 },
1851
1852 {
1853 11, -204, -204, -204, -204, -204, -204, -204, -204, -204,
1854 -204, -204, -204, 58, -204, -204, 58, 58, 58, 58,
1855 58, 58, 58, 207, 58, 58, 58, 58, 58, 58,
1856 58, 58, 58, 58, 58, 58, 58, -204
1857
1858 },
1859
1860 {
1861 11, -205, -205, -205, -205, -205, -205, -205, -205, -205,
1862 -205, -205, -205, 58, -205, -205, 58, 58, 58, 58,
1863 58, 58, 58, 58, 58, 58, 58, 58, 208, 58,
1864 58, 58, 58, 58, 58, 58, 58, -205
1865 },
1866
1867 {
1868 11, -206, -206, -206, -206, -206, -206, -206, -206, -206,
1869 -206, -206, -206, 58, -206, -206, 58, 58, 58, 58,
1870 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1871 58, 58, 58, 58, 209, 58, 58, -206
1872 },
1873
1874 {
1875 11, -207, -207, -207, -207, -207, -207, -207, -207, -207,
1876 -207, -207, -207, 58, -207, -207, 58, 58, 58, 58,
1877
1878 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1879 58, 58, 58, 58, 58, 58, 58, -207
1880 },
1881
1882 {
1883 11, -208, -208, -208, -208, -208, -208, -208, -208, -208,
1884 -208, -208, -208, 58, -208, -208, 58, 58, 58, 58,
1885 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1886 58, 58, 58, 58, 58, 58, 58, -208
1887 },
1888
1889 {
1890 11, -209, -209, -209, -209, -209, -209, -209, -209, -209,
1891 -209, -209, -209, 58, -209, -209, 58, 58, 58, 58,
1892 58, 210, 58, 58, 58, 58, 58, 58, 58, 58,
1893 58, 58, 58, 58, 58, 58, 58, -209
1894
1895 },
1896
1897 {
1898 11, -210, -210, -210, -210, -210, -210, -210, -210, -210,
1899 -210, -210, -210, 58, -210, -210, 58, 58, 58, 58,
1900 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1901 58, 58, 58, 58, 58, 58, 58, -210
1902 },
1903
1904 } ;
1905
1906static yy_state_type yy_get_previous_state (void );
1907static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
1908static int yy_get_next_buffer (void );
1909static void yy_fatal_error (yyconst char msg[] );
1910
1911/* Done after the current pattern has been matched and before the
1912 * corresponding action - sets up zconftext.
1913 */
1914#define YY_DO_BEFORE_ACTION \
1915 (yytext_ptr) = yy_bp; \
1916 zconfleng = (size_t) (yy_cp - yy_bp); \
1917 (yy_hold_char) = *yy_cp; \
1918 *yy_cp = '\0'; \
1919 (yy_c_buf_p) = yy_cp;
1920
1921#define YY_NUM_RULES 64
1922#define YY_END_OF_BUFFER 65
1923/* This struct is not used in this scanner,
1924 but its presence is necessary. */
1925struct yy_trans_info
1926 {
1927 flex_int32_t yy_verify;
1928 flex_int32_t yy_nxt;
1929 };
1930static yyconst flex_int16_t yy_accept[211] =
1931 { 0,
1932 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1933 65, 5, 4, 3, 2, 36, 37, 35, 35, 35,
1934 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
1935 63, 60, 62, 55, 59, 58, 57, 53, 48, 42,
1936 47, 51, 53, 40, 41, 50, 50, 43, 53, 50,
1937 50, 53, 4, 3, 2, 2, 1, 35, 35, 35,
1938 35, 35, 35, 35, 16, 35, 35, 35, 35, 35,
1939 35, 35, 35, 35, 35, 35, 63, 60, 62, 61,
1940 55, 54, 57, 56, 44, 51, 38, 50, 50, 52,
1941 45, 46, 39, 35, 35, 35, 35, 35, 35, 35,
1942
1943 35, 35, 30, 29, 35, 35, 35, 35, 35, 35,
1944 35, 35, 35, 35, 49, 25, 35, 35, 35, 35,
1945 35, 35, 35, 35, 35, 35, 15, 35, 7, 35,
1946 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
1947 35, 35, 35, 35, 35, 35, 35, 17, 35, 35,
1948 35, 35, 35, 34, 35, 35, 35, 35, 35, 35,
1949 10, 35, 13, 35, 35, 35, 35, 33, 35, 35,
1950 35, 35, 35, 22, 35, 32, 9, 31, 35, 26,
1951 12, 35, 35, 21, 18, 35, 8, 35, 35, 35,
1952 35, 35, 27, 35, 35, 6, 35, 20, 19, 23,
1953
1954 35, 35, 11, 35, 35, 35, 14, 28, 35, 24
1955 } ;
1956
1957static yyconst flex_int32_t yy_ec[256] =
1958 { 0,
1959 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1960 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1961 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1962 1, 2, 4, 5, 6, 1, 1, 7, 8, 9,
1963 10, 1, 1, 1, 11, 12, 12, 13, 13, 13,
1964 13, 13, 13, 13, 13, 13, 13, 1, 1, 1,
1965 14, 1, 1, 1, 13, 13, 13, 13, 13, 13,
1966 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
1967 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
1968 1, 15, 1, 1, 16, 1, 17, 18, 19, 20,
1969
1970 21, 22, 23, 24, 25, 13, 13, 26, 27, 28,
1971 29, 30, 31, 32, 33, 34, 35, 13, 13, 36,
1972 13, 13, 1, 37, 1, 1, 1, 1, 1, 1,
1973 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1974 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1975 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1976 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1977 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1978 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1979 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1980
1981 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1982 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1983 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1984 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1985 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1986 1, 1, 1, 1, 1
1987 } ;
1988
1989extern int zconf_flex_debug;
1990int zconf_flex_debug = 0;
1991
1992/* The intent behind this definition is that it'll catch
1993 * any uses of REJECT which flex missed.
1994 */
1995#define REJECT reject_used_but_not_detected
1996#define yymore() yymore_used_but_not_detected
1997#define YY_MORE_ADJ 0
1998#define YY_RESTORE_YY_MORE_OFFSET
1999char *zconftext;
2000
2001/*
2002 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
2003 * Released under the terms of the GNU GPL v2.0.
2004 */
2005
2006#include <limits.h>
2007#include <stdio.h>
2008#include <stdlib.h>
2009#include <string.h>
2010#include <unistd.h>
2011
2012#define LKC_DIRECT_LINK
2013#include "lkc.h"
2014
2015#define START_STRSIZE 16
2016
2017char *text;
2018static char *text_ptr;
2019static int text_size, text_asize;
2020
2021struct buffer {
2022 struct buffer *parent;
2023 YY_BUFFER_STATE state;
2024};
2025
2026struct buffer *current_buf;
2027
2028static int last_ts, first_ts;
2029
2030static void zconf_endhelp(void);
2031static struct buffer *zconf_endfile(void);
2032
2033void new_string(void)
2034{
2035 text = malloc(START_STRSIZE);
2036 text_asize = START_STRSIZE;
2037 text_ptr = text;
2038 text_size = 0;
2039 *text_ptr = 0;
2040}
2041
2042void append_string(const char *str, int size)
2043{
2044 int new_size = text_size + size + 1;
2045 if (new_size > text_asize) {
2046 text = realloc(text, new_size);
2047 text_asize = new_size;
2048 text_ptr = text + text_size;
2049 }
2050 memcpy(text_ptr, str, size);
2051 text_ptr += size;
2052 text_size += size;
2053 *text_ptr = 0;
2054}
2055
2056void alloc_string(const char *str, int size)
2057{
2058 text = malloc(size + 1);
2059 memcpy(text, str, size);
2060 text[size] = 0;
2061}
2062
2063#define INITIAL 0
2064#define COMMAND 1
2065#define HELP 2
2066#define STRING 3
2067#define PARAM 4
2068
2069/* Special case for "unistd.h", since it is non-ANSI. We include it way
2070 * down here because we want the user's section 1 to have been scanned first.
2071 * The user has a chance to override it with an option.
2072 */
2073#include <unistd.h>
2074
2075#ifndef YY_EXTRA_TYPE
2076#define YY_EXTRA_TYPE void *
2077#endif
2078
2079/* Macros after this point can all be overridden by user definitions in
2080 * section 1.
2081 */
2082
2083#ifndef YY_SKIP_YYWRAP
2084#ifdef __cplusplus
2085extern "C" int zconfwrap (void );
2086#else
2087extern int zconfwrap (void );
2088#endif
2089#endif
2090
2091 static void yyunput (int c,char *buf_ptr );
2092
2093#ifndef yytext_ptr
2094static void yy_flex_strncpy (char *,yyconst char *,int );
2095#endif
2096
2097#ifdef YY_NEED_STRLEN
2098static int yy_flex_strlen (yyconst char * );
2099#endif
2100
2101#ifndef YY_NO_INPUT
2102
2103#ifdef __cplusplus
2104static int yyinput (void );
2105#else
2106static int input (void );
2107#endif
2108
2109#endif
2110
2111/* Amount of stuff to slurp up with each read. */
2112#ifndef YY_READ_BUF_SIZE
2113#define YY_READ_BUF_SIZE 8192
2114#endif
2115
2116/* Copy whatever the last rule matched to the standard output. */
2117#ifndef ECHO
2118/* This used to be an fputs(), but since the string might contain NUL's,
2119 * we now use fwrite().
2120 */
2121#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout )
2122#endif
2123
2124/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
2125 * is returned in "result".
2126 */
2127#ifndef YY_INPUT
2128#define YY_INPUT(buf,result,max_size) \
2129 errno=0; \
2130 while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \
2131 { \
2132 if( errno != EINTR) \
2133 { \
2134 YY_FATAL_ERROR( "input in flex scanner failed" ); \
2135 break; \
2136 } \
2137 errno=0; \
2138 clearerr(zconfin); \
2139 }\
2140\
2141
2142#endif
2143
2144/* No semi-colon after return; correct usage is to write "yyterminate();" -
2145 * we don't want an extra ';' after the "return" because that will cause
2146 * some compilers to complain about unreachable statements.
2147 */
2148#ifndef yyterminate
2149#define yyterminate() return YY_NULL
2150#endif
2151
2152/* Number of entries by which start-condition stack grows. */
2153#ifndef YY_START_STACK_INCR
2154#define YY_START_STACK_INCR 25
2155#endif
2156
2157/* Report a fatal error. */
2158#ifndef YY_FATAL_ERROR
2159#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
2160#endif
2161
2162/* end tables serialization structures and prototypes */
2163
2164/* Default declaration of generated scanner - a define so the user can
2165 * easily add parameters.
2166 */
2167#ifndef YY_DECL
2168#define YY_DECL_IS_OURS 1
2169
2170extern int zconflex (void);
2171
2172#define YY_DECL int zconflex (void)
2173#endif /* !YY_DECL */
2174
2175/* Code executed at the beginning of each rule, after zconftext and zconfleng
2176 * have been set up.
2177 */
2178#ifndef YY_USER_ACTION
2179#define YY_USER_ACTION
2180#endif
2181
2182/* Code executed at the end of each rule. */
2183#ifndef YY_BREAK
2184#define YY_BREAK break;
2185#endif
2186
2187#define YY_RULE_SETUP \
2188 YY_USER_ACTION
2189
2190/** The main scanner function which does all the work.
2191 */
2192YY_DECL
2193{
2194 register yy_state_type yy_current_state;
2195 register char *yy_cp, *yy_bp;
2196 register int yy_act;
2197
2198 int str = 0;
2199 int ts, i;
2200
2201 if ( (yy_init) )
2202 {
2203 (yy_init) = 0;
2204
2205#ifdef YY_USER_INIT
2206 YY_USER_INIT;
2207#endif
2208
2209 if ( ! (yy_start) )
2210 (yy_start) = 1; /* first start state */
2211
2212 if ( ! zconfin )
2213 zconfin = stdin;
2214
2215 if ( ! zconfout )
2216 zconfout = stdout;
2217
2218 if ( ! YY_CURRENT_BUFFER ) {
2219 zconfensure_buffer_stack ();
2220 YY_CURRENT_BUFFER_LVALUE =
2221 zconf_create_buffer(zconfin,YY_BUF_SIZE );
2222 }
2223
2224 zconf_load_buffer_state( );
2225 }
2226
2227 while ( 1 ) /* loops until end-of-file is reached */
2228 {
2229 yy_cp = (yy_c_buf_p);
2230
2231 /* Support of zconftext. */
2232 *yy_cp = (yy_hold_char);
2233
2234 /* yy_bp points to the position in yy_ch_buf of the start of
2235 * the current run.
2236 */
2237 yy_bp = yy_cp;
2238
2239 yy_current_state = (yy_start);
2240yy_match:
2241 while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 )
2242 ++yy_cp;
2243
2244 yy_current_state = -yy_current_state;
2245
2246yy_find_action:
2247 yy_act = yy_accept[yy_current_state];
2248
2249 YY_DO_BEFORE_ACTION;
2250
2251do_action: /* This label is used only to access EOF actions. */
2252
2253 switch ( yy_act )
2254 { /* beginning of action switch */
2255case 1:
2256/* rule 1 can match eol */
2257YY_RULE_SETUP
2258current_file->lineno++;
2259 YY_BREAK
2260case 2:
2261YY_RULE_SETUP
2262
2263 YY_BREAK
2264case 3:
2265/* rule 3 can match eol */
2266YY_RULE_SETUP
2267current_file->lineno++; return T_EOL;
2268 YY_BREAK
2269case 4:
2270YY_RULE_SETUP
2271{
2272 BEGIN(COMMAND);
2273}
2274 YY_BREAK
2275case 5:
2276YY_RULE_SETUP
2277{
2278 unput(zconftext[0]);
2279 BEGIN(COMMAND);
2280}
2281 YY_BREAK
2282
2283case 6:
2284YY_RULE_SETUP
2285BEGIN(PARAM); return T_MAINMENU;
2286 YY_BREAK
2287case 7:
2288YY_RULE_SETUP
2289BEGIN(PARAM); return T_MENU;
2290 YY_BREAK
2291case 8:
2292YY_RULE_SETUP
2293BEGIN(PARAM); return T_ENDMENU;
2294 YY_BREAK
2295case 9:
2296YY_RULE_SETUP
2297BEGIN(PARAM); return T_SOURCE;
2298 YY_BREAK
2299case 10:
2300YY_RULE_SETUP
2301BEGIN(PARAM); return T_CHOICE;
2302 YY_BREAK
2303case 11:
2304YY_RULE_SETUP
2305BEGIN(PARAM); return T_ENDCHOICE;
2306 YY_BREAK
2307case 12:
2308YY_RULE_SETUP
2309BEGIN(PARAM); return T_COMMENT;
2310 YY_BREAK
2311case 13:
2312YY_RULE_SETUP
2313BEGIN(PARAM); return T_CONFIG;
2314 YY_BREAK
2315case 14:
2316YY_RULE_SETUP
2317BEGIN(PARAM); return T_MENUCONFIG;
2318 YY_BREAK
2319case 15:
2320YY_RULE_SETUP
2321BEGIN(PARAM); return T_HELP;
2322 YY_BREAK
2323case 16:
2324YY_RULE_SETUP
2325BEGIN(PARAM); return T_IF;
2326 YY_BREAK
2327case 17:
2328YY_RULE_SETUP
2329BEGIN(PARAM); return T_ENDIF;
2330 YY_BREAK
2331case 18:
2332YY_RULE_SETUP
2333BEGIN(PARAM); return T_DEPENDS;
2334 YY_BREAK
2335case 19:
2336YY_RULE_SETUP
2337BEGIN(PARAM); return T_REQUIRES;
2338 YY_BREAK
2339case 20:
2340YY_RULE_SETUP
2341BEGIN(PARAM); return T_OPTIONAL;
2342 YY_BREAK
2343case 21:
2344YY_RULE_SETUP
2345BEGIN(PARAM); return T_DEFAULT;
2346 YY_BREAK
2347case 22:
2348YY_RULE_SETUP
2349BEGIN(PARAM); return T_PROMPT;
2350 YY_BREAK
2351case 23:
2352YY_RULE_SETUP
2353BEGIN(PARAM); return T_TRISTATE;
2354 YY_BREAK
2355case 24:
2356YY_RULE_SETUP
2357BEGIN(PARAM); return T_DEF_TRISTATE;
2358 YY_BREAK
2359case 25:
2360YY_RULE_SETUP
2361BEGIN(PARAM); return T_BOOLEAN;
2362 YY_BREAK
2363case 26:
2364YY_RULE_SETUP
2365BEGIN(PARAM); return T_BOOLEAN;
2366 YY_BREAK
2367case 27:
2368YY_RULE_SETUP
2369BEGIN(PARAM); return T_DEF_BOOLEAN;
2370 YY_BREAK
2371case 28:
2372YY_RULE_SETUP
2373BEGIN(PARAM); return T_DEF_BOOLEAN;
2374 YY_BREAK
2375case 29:
2376YY_RULE_SETUP
2377BEGIN(PARAM); return T_INT;
2378 YY_BREAK
2379case 30:
2380YY_RULE_SETUP
2381BEGIN(PARAM); return T_HEX;
2382 YY_BREAK
2383case 31:
2384YY_RULE_SETUP
2385BEGIN(PARAM); return T_STRING;
2386 YY_BREAK
2387case 32:
2388YY_RULE_SETUP
2389BEGIN(PARAM); return T_SELECT;
2390 YY_BREAK
2391case 33:
2392YY_RULE_SETUP
2393BEGIN(PARAM); return T_SELECT;
2394 YY_BREAK
2395case 34:
2396YY_RULE_SETUP
2397BEGIN(PARAM); return T_RANGE;
2398 YY_BREAK
2399case 35:
2400YY_RULE_SETUP
2401{
2402 alloc_string(zconftext, zconfleng);
2403 zconflval.string = text;
2404 return T_WORD;
2405 }
2406 YY_BREAK
2407case 36:
2408YY_RULE_SETUP
2409
2410 YY_BREAK
2411case 37:
2412/* rule 37 can match eol */
2413YY_RULE_SETUP
2414current_file->lineno++; BEGIN(INITIAL);
2415 YY_BREAK
2416
2417case 38:
2418YY_RULE_SETUP
2419return T_AND;
2420 YY_BREAK
2421case 39:
2422YY_RULE_SETUP
2423return T_OR;
2424 YY_BREAK
2425case 40:
2426YY_RULE_SETUP
2427return T_OPEN_PAREN;
2428 YY_BREAK
2429case 41:
2430YY_RULE_SETUP
2431return T_CLOSE_PAREN;
2432 YY_BREAK
2433case 42:
2434YY_RULE_SETUP
2435return T_NOT;
2436 YY_BREAK
2437case 43:
2438YY_RULE_SETUP
2439return T_EQUAL;
2440 YY_BREAK
2441case 44:
2442YY_RULE_SETUP
2443return T_UNEQUAL;
2444 YY_BREAK
2445case 45:
2446YY_RULE_SETUP
2447return T_IF;
2448 YY_BREAK
2449case 46:
2450YY_RULE_SETUP
2451return T_ON;
2452 YY_BREAK
2453case 47:
2454YY_RULE_SETUP
2455{
2456 str = zconftext[0];
2457 new_string();
2458 BEGIN(STRING);
2459 }
2460 YY_BREAK
2461case 48:
2462/* rule 48 can match eol */
2463YY_RULE_SETUP
2464BEGIN(INITIAL); current_file->lineno++; return T_EOL;
2465 YY_BREAK
2466case 49:
2467YY_RULE_SETUP
2468/* ignore */
2469 YY_BREAK
2470case 50:
2471YY_RULE_SETUP
2472{
2473 alloc_string(zconftext, zconfleng);
2474 zconflval.string = text;
2475 return T_WORD;
2476 }
2477 YY_BREAK
2478case 51:
2479YY_RULE_SETUP
2480/* comment */
2481 YY_BREAK
2482case 52:
2483/* rule 52 can match eol */
2484YY_RULE_SETUP
2485current_file->lineno++;
2486 YY_BREAK
2487case 53:
2488YY_RULE_SETUP
2489
2490 YY_BREAK
2491case YY_STATE_EOF(PARAM):
2492{
2493 BEGIN(INITIAL);
2494 }
2495 YY_BREAK
2496
2497case 54:
2498/* rule 54 can match eol */
2499*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
2500(yy_c_buf_p) = yy_cp -= 1;
2501YY_DO_BEFORE_ACTION; /* set up zconftext again */
2502YY_RULE_SETUP
2503{
2504 append_string(zconftext, zconfleng);
2505 zconflval.string = text;
2506 return T_WORD_QUOTE;
2507 }
2508 YY_BREAK
2509case 55:
2510YY_RULE_SETUP
2511{
2512 append_string(zconftext, zconfleng);
2513 }
2514 YY_BREAK
2515case 56:
2516/* rule 56 can match eol */
2517*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
2518(yy_c_buf_p) = yy_cp -= 1;
2519YY_DO_BEFORE_ACTION; /* set up zconftext again */
2520YY_RULE_SETUP
2521{
2522 append_string(zconftext + 1, zconfleng - 1);
2523 zconflval.string = text;
2524 return T_WORD_QUOTE;
2525 }
2526 YY_BREAK
2527case 57:
2528YY_RULE_SETUP
2529{
2530 append_string(zconftext + 1, zconfleng - 1);
2531 }
2532 YY_BREAK
2533case 58:
2534YY_RULE_SETUP
2535{
2536 if (str == zconftext[0]) {
2537 BEGIN(PARAM);
2538 zconflval.string = text;
2539 return T_WORD_QUOTE;
2540 } else
2541 append_string(zconftext, 1);
2542 }
2543 YY_BREAK
2544case 59:
2545/* rule 59 can match eol */
2546YY_RULE_SETUP
2547{
2548 printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
2549 current_file->lineno++;
2550 BEGIN(INITIAL);
2551 return T_EOL;
2552 }
2553 YY_BREAK
2554case YY_STATE_EOF(STRING):
2555{
2556 BEGIN(INITIAL);
2557 }
2558 YY_BREAK
2559
2560case 60:
2561YY_RULE_SETUP
2562{
2563 ts = 0;
2564 for (i = 0; i < zconfleng; i++) {
2565 if (zconftext[i] == '\t')
2566 ts = (ts & ~7) + 8;
2567 else
2568 ts++;
2569 }
2570 last_ts = ts;
2571 if (first_ts) {
2572 if (ts < first_ts) {
2573 zconf_endhelp();
2574 return T_HELPTEXT;
2575 }
2576 ts -= first_ts;
2577 while (ts > 8) {
2578 append_string(" ", 8);
2579 ts -= 8;
2580 }
2581 append_string(" ", ts);
2582 }
2583 }
2584 YY_BREAK
2585case 61:
2586/* rule 61 can match eol */
2587*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
2588(yy_c_buf_p) = yy_cp -= 1;
2589YY_DO_BEFORE_ACTION; /* set up zconftext again */
2590YY_RULE_SETUP
2591{
2592 current_file->lineno++;
2593 zconf_endhelp();
2594 return T_HELPTEXT;
2595 }
2596 YY_BREAK
2597case 62:
2598/* rule 62 can match eol */
2599YY_RULE_SETUP
2600{
2601 current_file->lineno++;
2602 append_string("\n", 1);
2603 }
2604 YY_BREAK
2605case 63:
2606YY_RULE_SETUP
2607{
2608 append_string(zconftext, zconfleng);
2609 if (!first_ts)
2610 first_ts = last_ts;
2611 }
2612 YY_BREAK
2613case YY_STATE_EOF(HELP):
2614{
2615 zconf_endhelp();
2616 return T_HELPTEXT;
2617 }
2618 YY_BREAK
2619
2620case YY_STATE_EOF(INITIAL):
2621case YY_STATE_EOF(COMMAND):
2622{
2623 if (current_buf) {
2624 zconf_endfile();
2625 return T_EOF;
2626 }
2627 fclose(zconfin);
2628 yyterminate();
2629}
2630 YY_BREAK
2631case 64:
2632YY_RULE_SETUP
2633YY_FATAL_ERROR( "flex scanner jammed" );
2634 YY_BREAK
2635
2636 case YY_END_OF_BUFFER:
2637 {
2638 /* Amount of text matched not including the EOB char. */
2639 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
2640
2641 /* Undo the effects of YY_DO_BEFORE_ACTION. */
2642 *yy_cp = (yy_hold_char);
2643 YY_RESTORE_YY_MORE_OFFSET
2644
2645 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
2646 {
2647 /* We're scanning a new file or input source. It's
2648 * possible that this happened because the user
2649 * just pointed zconfin at a new source and called
2650 * zconflex(). If so, then we have to assure
2651 * consistency between YY_CURRENT_BUFFER and our
2652 * globals. Here is the right place to do so, because
2653 * this is the first action (other than possibly a
2654 * back-up) that will match for the new input source.
2655 */
2656 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2657 YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin;
2658 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
2659 }
2660
2661 /* Note that here we test for yy_c_buf_p "<=" to the position
2662 * of the first EOB in the buffer, since yy_c_buf_p will
2663 * already have been incremented past the NUL character
2664 * (since all states make transitions on EOB to the
2665 * end-of-buffer state). Contrast this with the test
2666 * in input().
2667 */
2668 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
2669 { /* This was really a NUL. */
2670 yy_state_type yy_next_state;
2671
2672 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
2673
2674 yy_current_state = yy_get_previous_state( );
2675
2676 /* Okay, we're now positioned to make the NUL
2677 * transition. We couldn't have
2678 * yy_get_previous_state() go ahead and do it
2679 * for us because it doesn't know how to deal
2680 * with the possibility of jamming (and we don't
2681 * want to build jamming into it because then it
2682 * will run more slowly).
2683 */
2684
2685 yy_next_state = yy_try_NUL_trans( yy_current_state );
2686
2687 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
2688
2689 if ( yy_next_state )
2690 {
2691 /* Consume the NUL. */
2692 yy_cp = ++(yy_c_buf_p);
2693 yy_current_state = yy_next_state;
2694 goto yy_match;
2695 }
2696
2697 else
2698 {
2699 yy_cp = (yy_c_buf_p);
2700 goto yy_find_action;
2701 }
2702 }
2703
2704 else switch ( yy_get_next_buffer( ) )
2705 {
2706 case EOB_ACT_END_OF_FILE:
2707 {
2708 (yy_did_buffer_switch_on_eof) = 0;
2709
2710 if ( zconfwrap( ) )
2711 {
2712 /* Note: because we've taken care in
2713 * yy_get_next_buffer() to have set up
2714 * zconftext, we can now set up
2715 * yy_c_buf_p so that if some total
2716 * hoser (like flex itself) wants to
2717 * call the scanner after we return the
2718 * YY_NULL, it'll still work - another
2719 * YY_NULL will get returned.
2720 */
2721 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
2722
2723 yy_act = YY_STATE_EOF(YY_START);
2724 goto do_action;
2725 }
2726
2727 else
2728 {
2729 if ( ! (yy_did_buffer_switch_on_eof) )
2730 YY_NEW_FILE;
2731 }
2732 break;
2733 }
2734
2735 case EOB_ACT_CONTINUE_SCAN:
2736 (yy_c_buf_p) =
2737 (yytext_ptr) + yy_amount_of_matched_text;
2738
2739 yy_current_state = yy_get_previous_state( );
2740
2741 yy_cp = (yy_c_buf_p);
2742 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
2743 goto yy_match;
2744
2745 case EOB_ACT_LAST_MATCH:
2746 (yy_c_buf_p) =
2747 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
2748
2749 yy_current_state = yy_get_previous_state( );
2750
2751 yy_cp = (yy_c_buf_p);
2752 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
2753 goto yy_find_action;
2754 }
2755 break;
2756 }
2757
2758 default:
2759 YY_FATAL_ERROR(
2760 "fatal flex scanner internal error--no action found" );
2761 } /* end of action switch */
2762 } /* end of scanning one token */
2763} /* end of zconflex */
2764
2765/* yy_get_next_buffer - try to read in a new buffer
2766 *
2767 * Returns a code representing an action:
2768 * EOB_ACT_LAST_MATCH -
2769 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
2770 * EOB_ACT_END_OF_FILE - end of file
2771 */
2772static int yy_get_next_buffer (void)
2773{
2774 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
2775 register char *source = (yytext_ptr);
2776 register int number_to_move, i;
2777 int ret_val;
2778
2779 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
2780 YY_FATAL_ERROR(
2781 "fatal flex scanner internal error--end of buffer missed" );
2782
2783 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
2784 { /* Don't try to fill the buffer, so this is an EOF. */
2785 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
2786 {
2787 /* We matched a single character, the EOB, so
2788 * treat this as a final EOF.
2789 */
2790 return EOB_ACT_END_OF_FILE;
2791 }
2792
2793 else
2794 {
2795 /* We matched some text prior to the EOB, first
2796 * process it.
2797 */
2798 return EOB_ACT_LAST_MATCH;
2799 }
2800 }
2801
2802 /* Try to read more data. */
2803
2804 /* First move last chars to start of buffer. */
2805 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
2806
2807 for ( i = 0; i < number_to_move; ++i )
2808 *(dest++) = *(source++);
2809
2810 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2811 /* don't do the read, it's not guaranteed to return an EOF,
2812 * just force an EOF
2813 */
2814 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
2815
2816 else
2817 {
2818 size_t num_to_read =
2819 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2820
2821 while ( num_to_read <= 0 )
2822 { /* Not enough room in the buffer - grow it. */
2823
2824 /* just a shorter name for the current buffer */
2825 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
2826
2827 int yy_c_buf_p_offset =
2828 (int) ((yy_c_buf_p) - b->yy_ch_buf);
2829
2830 if ( b->yy_is_our_buffer )
2831 {
2832 int new_size = b->yy_buf_size * 2;
2833
2834 if ( new_size <= 0 )
2835 b->yy_buf_size += b->yy_buf_size / 8;
2836 else
2837 b->yy_buf_size *= 2;
2838
2839 b->yy_ch_buf = (char *)
2840 /* Include room in for 2 EOB chars. */
2841 zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
2842 }
2843 else
2844 /* Can't grow it, we don't own it. */
2845 b->yy_ch_buf = 0;
2846
2847 if ( ! b->yy_ch_buf )
2848 YY_FATAL_ERROR(
2849 "fatal error - scanner input buffer overflow" );
2850
2851 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
2852
2853 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2854 number_to_move - 1;
2855
2856 }
2857
2858 if ( num_to_read > YY_READ_BUF_SIZE )
2859 num_to_read = YY_READ_BUF_SIZE;
2860
2861 /* Read in more data. */
2862 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2863 (yy_n_chars), num_to_read );
2864
2865 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2866 }
2867
2868 if ( (yy_n_chars) == 0 )
2869 {
2870 if ( number_to_move == YY_MORE_ADJ )
2871 {
2872 ret_val = EOB_ACT_END_OF_FILE;
2873 zconfrestart(zconfin );
2874 }
2875
2876 else
2877 {
2878 ret_val = EOB_ACT_LAST_MATCH;
2879 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2880 YY_BUFFER_EOF_PENDING;
2881 }
2882 }
2883
2884 else
2885 ret_val = EOB_ACT_CONTINUE_SCAN;
2886
2887 (yy_n_chars) += number_to_move;
2888 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
2889 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
2890
2891 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2892
2893 return ret_val;
2894}
2895
2896/* yy_get_previous_state - get the state just before the EOB char was reached */
2897
2898 static yy_state_type yy_get_previous_state (void)
2899{
2900 register yy_state_type yy_current_state;
2901 register char *yy_cp;
2902
2903 yy_current_state = (yy_start);
2904
2905 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
2906 {
2907 yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
2908 }
2909
2910 return yy_current_state;
2911}
2912
2913/* yy_try_NUL_trans - try to make a transition on the NUL character
2914 *
2915 * synopsis
2916 * next_state = yy_try_NUL_trans( current_state );
2917 */
2918 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
2919{
2920 register int yy_is_jam;
2921
2922 yy_current_state = yy_nxt[yy_current_state][1];
2923 yy_is_jam = (yy_current_state <= 0);
2924
2925 return yy_is_jam ? 0 : yy_current_state;
2926}
2927
2928 static void yyunput (int c, register char * yy_bp )
2929{
2930 register char *yy_cp;
2931
2932 yy_cp = (yy_c_buf_p);
2933
2934 /* undo effects of setting up zconftext */
2935 *yy_cp = (yy_hold_char);
2936
2937 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
2938 { /* need to shift things up to make room */
2939 /* +2 for EOB chars. */
2940 register int number_to_move = (yy_n_chars) + 2;
2941 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
2942 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
2943 register char *source =
2944 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
2945
2946 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2947 *--dest = *--source;
2948
2949 yy_cp += (int) (dest - source);
2950 yy_bp += (int) (dest - source);
2951 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
2952 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
2953
2954 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
2955 YY_FATAL_ERROR( "flex scanner push-back overflow" );
2956 }
2957
2958 *--yy_cp = (char) c;
2959
2960 (yytext_ptr) = yy_bp;
2961 (yy_hold_char) = *yy_cp;
2962 (yy_c_buf_p) = yy_cp;
2963}
2964
2965#ifndef YY_NO_INPUT
2966#ifdef __cplusplus
2967 static int yyinput (void)
2968#else
2969 static int input (void)
2970#endif
2971
2972{
2973 int c;
2974
2975 *(yy_c_buf_p) = (yy_hold_char);
2976
2977 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
2978 {
2979 /* yy_c_buf_p now points to the character we want to return.
2980 * If this occurs *before* the EOB characters, then it's a
2981 * valid NUL; if not, then we've hit the end of the buffer.
2982 */
2983 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
2984 /* This was really a NUL. */
2985 *(yy_c_buf_p) = '\0';
2986
2987 else
2988 { /* need more input */
2989 int offset = (yy_c_buf_p) - (yytext_ptr);
2990 ++(yy_c_buf_p);
2991
2992 switch ( yy_get_next_buffer( ) )
2993 {
2994 case EOB_ACT_LAST_MATCH:
2995 /* This happens because yy_g_n_b()
2996 * sees that we've accumulated a
2997 * token and flags that we need to
2998 * try matching the token before
2999 * proceeding. But for input(),
3000 * there's no matching to consider.
3001 * So convert the EOB_ACT_LAST_MATCH
3002 * to EOB_ACT_END_OF_FILE.
3003 */
3004
3005 /* Reset buffer status. */
3006 zconfrestart(zconfin );
3007
3008 /*FALLTHROUGH*/
3009
3010 case EOB_ACT_END_OF_FILE:
3011 {
3012 if ( zconfwrap( ) )
3013 return EOF;
3014
3015 if ( ! (yy_did_buffer_switch_on_eof) )
3016 YY_NEW_FILE;
3017#ifdef __cplusplus
3018 return yyinput();
3019#else
3020 return input();
3021#endif
3022 }
3023
3024 case EOB_ACT_CONTINUE_SCAN:
3025 (yy_c_buf_p) = (yytext_ptr) + offset;
3026 break;
3027 }
3028 }
3029 }
3030
3031 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
3032 *(yy_c_buf_p) = '\0'; /* preserve zconftext */
3033 (yy_hold_char) = *++(yy_c_buf_p);
3034
3035 return c;
3036}
3037#endif /* ifndef YY_NO_INPUT */
3038
3039/** Immediately switch to a different input stream.
3040 * @param input_file A readable stream.
3041 *
3042 * @note This function does not reset the start condition to @c INITIAL .
3043 */
3044 void zconfrestart (FILE * input_file )
3045{
3046
3047 if ( ! YY_CURRENT_BUFFER ){
3048 zconfensure_buffer_stack ();
3049 YY_CURRENT_BUFFER_LVALUE =
3050 zconf_create_buffer(zconfin,YY_BUF_SIZE );
3051 }
3052
3053 zconf_init_buffer(YY_CURRENT_BUFFER,input_file );
3054 zconf_load_buffer_state( );
3055}
3056
3057/** Switch to a different input buffer.
3058 * @param new_buffer The new input buffer.
3059 *
3060 */
3061 void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer )
3062{
3063
3064 /* TODO. We should be able to replace this entire function body
3065 * with
3066 * zconfpop_buffer_state();
3067 * zconfpush_buffer_state(new_buffer);
3068 */
3069 zconfensure_buffer_stack ();
3070 if ( YY_CURRENT_BUFFER == new_buffer )
3071 return;
3072
3073 if ( YY_CURRENT_BUFFER )
3074 {
3075 /* Flush out information for old buffer. */
3076 *(yy_c_buf_p) = (yy_hold_char);
3077 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
3078 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
3079 }
3080
3081 YY_CURRENT_BUFFER_LVALUE = new_buffer;
3082 zconf_load_buffer_state( );
3083
3084 /* We don't actually know whether we did this switch during
3085 * EOF (zconfwrap()) processing, but the only time this flag
3086 * is looked at is after zconfwrap() is called, so it's safe
3087 * to go ahead and always set it.
3088 */
3089 (yy_did_buffer_switch_on_eof) = 1;
3090}
3091
3092static void zconf_load_buffer_state (void)
3093{
3094 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
3095 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
3096 zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
3097 (yy_hold_char) = *(yy_c_buf_p);
3098}
3099
3100/** Allocate and initialize an input buffer state.
3101 * @param file A readable stream.
3102 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
3103 *
3104 * @return the allocated buffer state.
3105 */
3106 YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size )
3107{
3108 YY_BUFFER_STATE b;
3109
3110 b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
3111 if ( ! b )
3112 YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
3113
3114 b->yy_buf_size = size;
3115
3116 /* yy_ch_buf has to be 2 characters longer than the size given because
3117 * we need to put in 2 end-of-buffer characters.
3118 */
3119 b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 );
3120 if ( ! b->yy_ch_buf )
3121 YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
3122
3123 b->yy_is_our_buffer = 1;
3124
3125 zconf_init_buffer(b,file );
3126
3127 return b;
3128}
3129
3130/** Destroy the buffer.
3131 * @param b a buffer created with zconf_create_buffer()
3132 *
3133 */
3134 void zconf_delete_buffer (YY_BUFFER_STATE b )
3135{
3136
3137 if ( ! b )
3138 return;
3139
3140 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
3141 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
3142
3143 if ( b->yy_is_our_buffer )
3144 zconffree((void *) b->yy_ch_buf );
3145
3146 zconffree((void *) b );
3147}
3148
3149/* Initializes or reinitializes a buffer.
3150 * This function is sometimes called more than once on the same buffer,
3151 * such as during a zconfrestart() or at EOF.
3152 */
3153 static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file )
3154
3155{
3156 int oerrno = errno;
3157
3158 zconf_flush_buffer(b );
3159
3160 b->yy_input_file = file;
3161 b->yy_fill_buffer = 1;
3162
3163 /* If b is the current buffer, then zconf_init_buffer was _probably_
3164 * called from zconfrestart() or through yy_get_next_buffer.
3165 * In that case, we don't want to reset the lineno or column.
3166 */
3167 if (b != YY_CURRENT_BUFFER){
3168 b->yy_bs_lineno = 1;
3169 b->yy_bs_column = 0;
3170 }
3171
3172 b->yy_is_interactive = 0;
3173
3174 errno = oerrno;
3175}
3176
3177/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
3178 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
3179 *
3180 */
3181 void zconf_flush_buffer (YY_BUFFER_STATE b )
3182{
3183 if ( ! b )
3184 return;
3185
3186 b->yy_n_chars = 0;
3187
3188 /* We always need two end-of-buffer characters. The first causes
3189 * a transition to the end-of-buffer state. The second causes
3190 * a jam in that state.
3191 */
3192 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
3193 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
3194
3195 b->yy_buf_pos = &b->yy_ch_buf[0];
3196
3197 b->yy_at_bol = 1;
3198 b->yy_buffer_status = YY_BUFFER_NEW;
3199
3200 if ( b == YY_CURRENT_BUFFER )
3201 zconf_load_buffer_state( );
3202}
3203
3204/** Pushes the new state onto the stack. The new state becomes
3205 * the current state. This function will allocate the stack
3206 * if necessary.
3207 * @param new_buffer The new state.
3208 *
3209 */
3210void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer )
3211{
3212 if (new_buffer == NULL)
3213 return;
3214
3215 zconfensure_buffer_stack();
3216
3217 /* This block is copied from zconf_switch_to_buffer. */
3218 if ( YY_CURRENT_BUFFER )
3219 {
3220 /* Flush out information for old buffer. */
3221 *(yy_c_buf_p) = (yy_hold_char);
3222 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
3223 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
3224 }
3225
3226 /* Only push if top exists. Otherwise, replace top. */
3227 if (YY_CURRENT_BUFFER)
3228 (yy_buffer_stack_top)++;
3229 YY_CURRENT_BUFFER_LVALUE = new_buffer;
3230
3231 /* copied from zconf_switch_to_buffer. */
3232 zconf_load_buffer_state( );
3233 (yy_did_buffer_switch_on_eof) = 1;
3234}
3235
3236/** Removes and deletes the top of the stack, if present.
3237 * The next element becomes the new top.
3238 *
3239 */
3240void zconfpop_buffer_state (void)
3241{
3242 if (!YY_CURRENT_BUFFER)
3243 return;
3244
3245 zconf_delete_buffer(YY_CURRENT_BUFFER );
3246 YY_CURRENT_BUFFER_LVALUE = NULL;
3247 if ((yy_buffer_stack_top) > 0)
3248 --(yy_buffer_stack_top);
3249
3250 if (YY_CURRENT_BUFFER) {
3251 zconf_load_buffer_state( );
3252 (yy_did_buffer_switch_on_eof) = 1;
3253 }
3254}
3255
3256/* Allocates the stack if it does not exist.
3257 * Guarantees space for at least one push.
3258 */
3259static void zconfensure_buffer_stack (void)
3260{
3261 int num_to_alloc;
3262
3263 if (!(yy_buffer_stack)) {
3264
3265 /* First allocation is just for 2 elements, since we don't know if this
3266 * scanner will even need a stack. We use 2 instead of 1 to avoid an
3267 * immediate realloc on the next call.
3268 */
3269 num_to_alloc = 1;
3270 (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc
3271 (num_to_alloc * sizeof(struct yy_buffer_state*)
3272 );
3273
3274 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
3275
3276 (yy_buffer_stack_max) = num_to_alloc;
3277 (yy_buffer_stack_top) = 0;
3278 return;
3279 }
3280
3281 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
3282
3283 /* Increase the buffer to prepare for a possible push. */
3284 int grow_size = 8 /* arbitrary grow size */;
3285
3286 num_to_alloc = (yy_buffer_stack_max) + grow_size;
3287 (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc
3288 ((yy_buffer_stack),
3289 num_to_alloc * sizeof(struct yy_buffer_state*)
3290 );
3291
3292 /* zero only the new slots.*/
3293 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
3294 (yy_buffer_stack_max) = num_to_alloc;
3295 }
3296}
3297
3298/** Setup the input buffer state to scan directly from a user-specified character buffer.
3299 * @param base the character buffer
3300 * @param size the size in bytes of the character buffer
3301 *
3302 * @return the newly allocated buffer state object.
3303 */
3304YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size )
3305{
3306 YY_BUFFER_STATE b;
3307
3308 if ( size < 2 ||
3309 base[size-2] != YY_END_OF_BUFFER_CHAR ||
3310 base[size-1] != YY_END_OF_BUFFER_CHAR )
3311 /* They forgot to leave room for the EOB's. */
3312 return 0;
3313
3314 b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
3315 if ( ! b )
3316 YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" );
3317
3318 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
3319 b->yy_buf_pos = b->yy_ch_buf = base;
3320 b->yy_is_our_buffer = 0;
3321 b->yy_input_file = 0;
3322 b->yy_n_chars = b->yy_buf_size;
3323 b->yy_is_interactive = 0;
3324 b->yy_at_bol = 1;
3325 b->yy_fill_buffer = 0;
3326 b->yy_buffer_status = YY_BUFFER_NEW;
3327
3328 zconf_switch_to_buffer(b );
3329
3330 return b;
3331}
3332
3333/** Setup the input buffer state to scan a string. The next call to zconflex() will
3334 * scan from a @e copy of @a str.
3335 * @param str a NUL-terminated string to scan
3336 *
3337 * @return the newly allocated buffer state object.
3338 * @note If you want to scan bytes that may contain NUL values, then use
3339 * zconf_scan_bytes() instead.
3340 */
3341YY_BUFFER_STATE zconf_scan_string (yyconst char * str )
3342{
3343
3344 return zconf_scan_bytes(str,strlen(str) );
3345}
3346
3347/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
3348 * scan from a @e copy of @a bytes.
3349 * @param bytes the byte buffer to scan
3350 * @param len the number of bytes in the buffer pointed to by @a bytes.
3351 *
3352 * @return the newly allocated buffer state object.
3353 */
3354YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len )
3355{
3356 YY_BUFFER_STATE b;
3357 char *buf;
3358 yy_size_t n;
3359 int i;
3360
3361 /* Get memory for full buffer, including space for trailing EOB's. */
3362 n = len + 2;
3363 buf = (char *) zconfalloc(n );
3364 if ( ! buf )
3365 YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" );
3366
3367 for ( i = 0; i < len; ++i )
3368 buf[i] = bytes[i];
3369
3370 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
3371
3372 b = zconf_scan_buffer(buf,n );
3373 if ( ! b )
3374 YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" );
3375
3376 /* It's okay to grow etc. this buffer, and we should throw it
3377 * away when we're done.
3378 */
3379 b->yy_is_our_buffer = 1;
3380
3381 return b;
3382}
3383
3384#ifndef YY_EXIT_FAILURE
3385#define YY_EXIT_FAILURE 2
3386#endif
3387
3388static void yy_fatal_error (yyconst char* msg )
3389{
3390 (void) fprintf( stderr, "%s\n", msg );
3391 exit( YY_EXIT_FAILURE );
3392}
3393
3394/* Redefine yyless() so it works in section 3 code. */
3395
3396#undef yyless
3397#define yyless(n) \
3398 do \
3399 { \
3400 /* Undo effects of setting up zconftext. */ \
3401 int yyless_macro_arg = (n); \
3402 YY_LESS_LINENO(yyless_macro_arg);\
3403 zconftext[zconfleng] = (yy_hold_char); \
3404 (yy_c_buf_p) = zconftext + yyless_macro_arg; \
3405 (yy_hold_char) = *(yy_c_buf_p); \
3406 *(yy_c_buf_p) = '\0'; \
3407 zconfleng = yyless_macro_arg; \
3408 } \
3409 while ( 0 )
3410
3411/* Accessor methods (get/set functions) to struct members. */
3412
3413/** Get the current line number.
3414 *
3415 */
3416int zconfget_lineno (void)
3417{
3418
3419 return zconflineno;
3420}
3421
3422/** Get the input stream.
3423 *
3424 */
3425FILE *zconfget_in (void)
3426{
3427 return zconfin;
3428}
3429
3430/** Get the output stream.
3431 *
3432 */
3433FILE *zconfget_out (void)
3434{
3435 return zconfout;
3436}
3437
3438/** Get the length of the current token.
3439 *
3440 */
3441int zconfget_leng (void)
3442{
3443 return zconfleng;
3444}
3445
3446/** Get the current token.
3447 *
3448 */
3449
3450char *zconfget_text (void)
3451{
3452 return zconftext;
3453}
3454
3455/** Set the current line number.
3456 * @param line_number
3457 *
3458 */
3459void zconfset_lineno (int line_number )
3460{
3461
3462 zconflineno = line_number;
3463}
3464
3465/** Set the input stream. This does not discard the current
3466 * input buffer.
3467 * @param in_str A readable stream.
3468 *
3469 * @see zconf_switch_to_buffer
3470 */
3471void zconfset_in (FILE * in_str )
3472{
3473 zconfin = in_str ;
3474}
3475
3476void zconfset_out (FILE * out_str )
3477{
3478 zconfout = out_str ;
3479}
3480
3481int zconfget_debug (void)
3482{
3483 return zconf_flex_debug;
3484}
3485
3486void zconfset_debug (int bdebug )
3487{
3488 zconf_flex_debug = bdebug ;
3489}
3490
3491/* zconflex_destroy is for both reentrant and non-reentrant scanners. */
3492int zconflex_destroy (void)
3493{
3494
3495 /* Pop the buffer stack, destroying each element. */
3496 while(YY_CURRENT_BUFFER){
3497 zconf_delete_buffer(YY_CURRENT_BUFFER );
3498 YY_CURRENT_BUFFER_LVALUE = NULL;
3499 zconfpop_buffer_state();
3500 }
3501
3502 /* Destroy the stack itself. */
3503 zconffree((yy_buffer_stack) );
3504 (yy_buffer_stack) = NULL;
3505
3506 return 0;
3507}
3508
3509/*
3510 * Internal utility routines.
3511 */
3512
3513#ifndef yytext_ptr
3514static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
3515{
3516 register int i;
3517 for ( i = 0; i < n; ++i )
3518 s1[i] = s2[i];
3519}
3520#endif
3521
3522#ifdef YY_NEED_STRLEN
3523static int yy_flex_strlen (yyconst char * s )
3524{
3525 register int n;
3526 for ( n = 0; s[n]; ++n )
3527 ;
3528
3529 return n;
3530}
3531#endif
3532
3533void *zconfalloc (yy_size_t size )
3534{
3535 return (void *) malloc( size );
3536}
3537
3538void *zconfrealloc (void * ptr, yy_size_t size )
3539{
3540 /* The cast to (char *) in the following accommodates both
3541 * implementations that use char* generic pointers, and those
3542 * that use void* generic pointers. It works with the latter
3543 * because both ANSI C and C++ allow castless assignment from
3544 * any pointer type to void*, and deal with argument conversions
3545 * as though doing an assignment.
3546 */
3547 return (void *) realloc( (char *) ptr, size );
3548}
3549
3550void zconffree (void * ptr )
3551{
3552 free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */
3553}
3554
3555#define YYTABLES_NAME "yytables"
3556
3557#undef YY_NEW_FILE
3558#undef YY_FLUSH_BUFFER
3559#undef yy_set_bol
3560#undef yy_new_buffer
3561#undef yy_set_interactive
3562#undef yytext_ptr
3563#undef YY_DO_BEFORE_ACTION
3564
3565#ifdef YY_DECL_IS_OURS
3566#undef YY_DECL_IS_OURS
3567#undef YY_DECL
3568#endif
3569
3570void zconf_starthelp(void)
3571{
3572 new_string();
3573 last_ts = first_ts = 0;
3574 BEGIN(HELP);
3575}
3576
3577static void zconf_endhelp(void)
3578{
3579 zconflval.string = text;
3580 BEGIN(INITIAL);
3581}
3582
3583/*
3584 * Try to open specified file with following names:
3585 * ./name
3586 * $(srctree)/name
3587 * The latter is used when srctree is separate from objtree
3588 * when compiling the kernel.
3589 * Return NULL if file is not found.
3590 */
3591FILE *zconf_fopen(const char *name)
3592{
3593 char *env, fullname[PATH_MAX+1];
3594 FILE *f;
3595
3596 f = fopen(name, "r");
3597 if (!f && name[0] != '/') {
3598 env = getenv(SRCTREE);
3599 if (env) {
3600 sprintf(fullname, "%s/%s", env, name);
3601 f = fopen(fullname, "r");
3602 }
3603 }
3604 return f;
3605}
3606
3607void zconf_initscan(const char *name)
3608{
3609 zconfin = zconf_fopen(name);
3610 if (!zconfin) {
3611 printf("can't find file %s\n", name);
3612 exit(1);
3613 }
3614
3615 current_buf = malloc(sizeof(*current_buf));
3616 memset(current_buf, 0, sizeof(*current_buf));
3617
3618 current_file = file_lookup(name);
3619 current_file->lineno = 1;
3620 current_file->flags = FILE_BUSY;
3621}
3622
3623void zconf_nextfile(const char *name)
3624{
3625 struct file *file = file_lookup(name);
3626 struct buffer *buf = malloc(sizeof(*buf));
3627 memset(buf, 0, sizeof(*buf));
3628
3629 current_buf->state = YY_CURRENT_BUFFER;
3630 zconfin = zconf_fopen(name);
3631 if (!zconfin) {
3632 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
3633 exit(1);
3634 }
3635 zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
3636 buf->parent = current_buf;
3637 current_buf = buf;
3638
3639 if (file->flags & FILE_BUSY) {
3640 printf("recursive scan (%s)?\n", name);
3641 exit(1);
3642 }
3643 if (file->flags & FILE_SCANNED) {
3644 printf("file %s already scanned?\n", name);
3645 exit(1);
3646 }
3647 file->flags |= FILE_BUSY;
3648 file->lineno = 1;
3649 file->parent = current_file;
3650 current_file = file;
3651}
3652
3653static struct buffer *zconf_endfile(void)
3654{
3655 struct buffer *parent;
3656
3657 current_file->flags |= FILE_SCANNED;
3658 current_file->flags &= ~FILE_BUSY;
3659 current_file = current_file->parent;
3660
3661 parent = current_buf->parent;
3662 if (parent) {
3663 fclose(zconfin);
3664 zconf_delete_buffer(YY_CURRENT_BUFFER);
3665 zconf_switch_to_buffer(parent->state);
3666 }
3667 free(current_buf);
3668 current_buf = parent;
3669
3670 return parent;
3671}
3672
3673int zconf_lineno(void)
3674{
3675 if (current_buf)
3676 return current_file->lineno - 1;
3677 else
3678 return 0;
3679}
3680
3681char *zconf_curname(void)
3682{
3683 if (current_buf)
3684 return current_file->name;
3685 else
3686 return "<none>";
3687}
3688
diff --git a/scripts/config/lxdialog/checklist.c b/scripts/config/lxdialog/checklist.c
deleted file mode 100644
index 1513a8966..000000000
--- a/scripts/config/lxdialog/checklist.c
+++ /dev/null
@@ -1,373 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * checklist.c -- implements the checklist box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension
7 * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two
8 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#include "dialog.h"
26
27static int list_width, check_x, item_x, checkflag;
28
29/*
30 * Print list item
31 */
32static void
33print_item (WINDOW * win, const char *item, int status,
34 int choice, int selected)
35{
36 int i;
37
38 /* Clear 'residue' of last item */
39 wattrset (win, menubox_attr);
40 wmove (win, choice, 0);
41 for (i = 0; i < list_width; i++)
42 waddch (win, ' ');
43
44 wmove (win, choice, check_x);
45 wattrset (win, selected ? check_selected_attr : check_attr);
46 if (checkflag == FLAG_CHECK)
47 wprintw (win, "[%c]", status ? 'X' : ' ');
48 else
49 wprintw (win, "(%c)", status ? 'X' : ' ');
50
51 wattrset (win, selected ? tag_selected_attr : tag_attr);
52 mvwaddch(win, choice, item_x, item[0]);
53 wattrset (win, selected ? item_selected_attr : item_attr);
54 waddstr (win, (char *)item+1);
55 if (selected) {
56 wmove (win, choice, check_x+1);
57 wrefresh (win);
58 }
59}
60
61/*
62 * Print the scroll indicators.
63 */
64static void
65print_arrows (WINDOW * win, int choice, int item_no, int scroll,
66 int y, int x, int height)
67{
68 wmove(win, y, x);
69
70 if (scroll > 0) {
71 wattrset (win, uarrow_attr);
72 waddch (win, ACS_UARROW);
73 waddstr (win, "(-)");
74 }
75 else {
76 wattrset (win, menubox_attr);
77 waddch (win, ACS_HLINE);
78 waddch (win, ACS_HLINE);
79 waddch (win, ACS_HLINE);
80 waddch (win, ACS_HLINE);
81 }
82
83 y = y + height + 1;
84 wmove(win, y, x);
85
86 if ((height < item_no) && (scroll + choice < item_no - 1)) {
87 wattrset (win, darrow_attr);
88 waddch (win, ACS_DARROW);
89 waddstr (win, "(+)");
90 }
91 else {
92 wattrset (win, menubox_border_attr);
93 waddch (win, ACS_HLINE);
94 waddch (win, ACS_HLINE);
95 waddch (win, ACS_HLINE);
96 waddch (win, ACS_HLINE);
97 }
98}
99
100/*
101 * Display the termination buttons
102 */
103static void
104print_buttons( WINDOW *dialog, int height, int width, int selected)
105{
106 int x = width / 2 - 11;
107 int y = height - 2;
108
109 print_button (dialog, "Select", y, x, selected == 0);
110 print_button (dialog, " Help ", y, x + 14, selected == 1);
111
112 wmove(dialog, y, x+1 + 14*selected);
113 wrefresh (dialog);
114}
115
116/*
117 * Display a dialog box with a list of options that can be turned on or off
118 * The `flag' parameter is used to select between radiolist and checklist.
119 */
120int
121dialog_checklist (const char *title, const char *prompt, int height, int width,
122 int list_height, int item_no, struct dialog_list_item ** items,
123 int flag)
124
125{
126 int i, x, y, box_x, box_y;
127 int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status;
128 WINDOW *dialog, *list;
129
130 checkflag = flag;
131
132 /* Allocate space for storing item on/off status */
133 if ((status = malloc (sizeof (int) * item_no)) == NULL) {
134 endwin ();
135 fprintf (stderr,
136 "\nCan't allocate memory in dialog_checklist().\n");
137 exit (-1);
138 }
139
140 /* Initializes status */
141 for (i = 0; i < item_no; i++) {
142 status[i] = (items[i]->selected == 1); /* ON */
143 if ((!choice && status[i]) || items[i]->selected == 2) /* SELECTED */
144 choice = i + 1;
145 }
146 if (choice)
147 choice--;
148
149 max_choice = MIN (list_height, item_no);
150
151 /* center dialog box on screen */
152 x = (COLS - width) / 2;
153 y = (LINES - height) / 2;
154
155 draw_shadow (stdscr, y, x, height, width);
156
157 dialog = newwin (height, width, y, x);
158 keypad (dialog, TRUE);
159
160 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
161 wattrset (dialog, border_attr);
162 mvwaddch (dialog, height-3, 0, ACS_LTEE);
163 for (i = 0; i < width - 2; i++)
164 waddch (dialog, ACS_HLINE);
165 wattrset (dialog, dialog_attr);
166 waddch (dialog, ACS_RTEE);
167
168 if (title != NULL && strlen(title) >= width-2 ) {
169 /* truncate long title -- mec */
170 char * title2 = malloc(width-2+1);
171 memcpy( title2, title, width-2 );
172 title2[width-2] = '\0';
173 title = title2;
174 }
175
176 if (title != NULL) {
177 wattrset (dialog, title_attr);
178 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
179 waddstr (dialog, (char *)title);
180 waddch (dialog, ' ');
181 }
182
183 wattrset (dialog, dialog_attr);
184 print_autowrap (dialog, prompt, width - 2, 1, 3);
185
186 list_width = width - 6;
187 box_y = height - list_height - 5;
188 box_x = (width - list_width) / 2 - 1;
189
190 /* create new window for the list */
191 list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1);
192
193 keypad (list, TRUE);
194
195 /* draw a box around the list items */
196 draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2,
197 menubox_border_attr, menubox_attr);
198
199 /* Find length of longest item in order to center checklist */
200 check_x = 0;
201 for (i = 0; i < item_no; i++)
202 check_x = MAX (check_x, + strlen (items[i]->name) + 4);
203
204 check_x = (list_width - check_x) / 2;
205 item_x = check_x + 4;
206
207 if (choice >= list_height) {
208 scroll = choice - list_height + 1;
209 choice -= scroll;
210 }
211
212 /* Print the list */
213 for (i = 0; i < max_choice; i++) {
214 print_item (list, items[scroll + i]->name,
215 status[i+scroll], i, i == choice);
216 }
217
218 print_arrows(dialog, choice, item_no, scroll,
219 box_y, box_x + check_x + 5, list_height);
220
221 print_buttons(dialog, height, width, 0);
222
223 wnoutrefresh (list);
224 wnoutrefresh (dialog);
225 doupdate ();
226
227 while (key != ESC) {
228 key = wgetch (dialog);
229
230 for (i = 0; i < max_choice; i++)
231 if (toupper(key) == toupper(items[scroll + i]->name[0]))
232 break;
233
234
235 if ( i < max_choice || key == KEY_UP || key == KEY_DOWN ||
236 key == '+' || key == '-' ) {
237 if (key == KEY_UP || key == '-') {
238 if (!choice) {
239 if (!scroll)
240 continue;
241 /* Scroll list down */
242 if (list_height > 1) {
243 /* De-highlight current first item */
244 print_item (list, items[scroll]->name,
245 status[scroll], 0, FALSE);
246 scrollok (list, TRUE);
247 wscrl (list, -1);
248 scrollok (list, FALSE);
249 }
250 scroll--;
251 print_item (list, items[scroll]->name,
252 status[scroll], 0, TRUE);
253 wnoutrefresh (list);
254
255 print_arrows(dialog, choice, item_no, scroll,
256 box_y, box_x + check_x + 5, list_height);
257
258 wrefresh (dialog);
259
260 continue; /* wait for another key press */
261 } else
262 i = choice - 1;
263 } else if (key == KEY_DOWN || key == '+') {
264 if (choice == max_choice - 1) {
265 if (scroll + choice >= item_no - 1)
266 continue;
267 /* Scroll list up */
268 if (list_height > 1) {
269 /* De-highlight current last item before scrolling up */
270 print_item (list, items[scroll + max_choice - 1]->name,
271 status[scroll + max_choice - 1],
272 max_choice - 1, FALSE);
273 scrollok (list, TRUE);
274 scroll (list);
275 scrollok (list, FALSE);
276 }
277 scroll++;
278 print_item (list, items[scroll + max_choice - 1]->name,
279 status[scroll + max_choice - 1],
280 max_choice - 1, TRUE);
281 wnoutrefresh (list);
282
283 print_arrows(dialog, choice, item_no, scroll,
284 box_y, box_x + check_x + 5, list_height);
285
286 wrefresh (dialog);
287
288 continue; /* wait for another key press */
289 } else
290 i = choice + 1;
291 }
292 if (i != choice) {
293 /* De-highlight current item */
294 print_item (list, items[scroll + choice]->name,
295 status[scroll + choice], choice, FALSE);
296 /* Highlight new item */
297 choice = i;
298 print_item (list, items[scroll + choice]->name,
299 status[scroll + choice], choice, TRUE);
300 wnoutrefresh (list);
301 wrefresh (dialog);
302 }
303 continue; /* wait for another key press */
304 }
305 switch (key) {
306 case 'H':
307 case 'h':
308 case '?':
309 for (i = 0; i < item_no; i++)
310 items[i]->selected = 0;
311 items[scroll + choice]->selected = 1;
312 delwin (dialog);
313 free (status);
314 return 1;
315 case TAB:
316 case KEY_LEFT:
317 case KEY_RIGHT:
318 button = ((key == KEY_LEFT ? --button : ++button) < 0)
319 ? 1 : (button > 1 ? 0 : button);
320
321 print_buttons(dialog, height, width, button);
322 wrefresh (dialog);
323 break;
324 case 'S':
325 case 's':
326 case ' ':
327 case '\n':
328 if (!button) {
329 if (flag == FLAG_CHECK) {
330 status[scroll + choice] = !status[scroll + choice];
331 wmove (list, choice, check_x);
332 wattrset (list, check_selected_attr);
333 wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' ');
334 } else {
335 if (!status[scroll + choice]) {
336 for (i = 0; i < item_no; i++)
337 status[i] = 0;
338 status[scroll + choice] = 1;
339 for (i = 0; i < max_choice; i++)
340 print_item (list, items[scroll + i]->name,
341 status[scroll + i], i, i == choice);
342 }
343 }
344 wnoutrefresh (list);
345 wrefresh (dialog);
346
347 for (i = 0; i < item_no; i++) {
348 items[i]->selected = status[i];
349 }
350 } else {
351 for (i = 0; i < item_no; i++)
352 items[i]->selected = 0;
353 items[scroll + choice]->selected = 1;
354 }
355 delwin (dialog);
356 free (status);
357 return button;
358 case 'X':
359 case 'x':
360 key = ESC;
361 case ESC:
362 break;
363 }
364
365 /* Now, update everything... */
366 doupdate ();
367 }
368
369
370 delwin (dialog);
371 free (status);
372 return -1; /* ESC pressed */
373}
diff --git a/scripts/config/lxdialog/inputbox.c b/scripts/config/lxdialog/inputbox.c
deleted file mode 100644
index a42f8127d..000000000
--- a/scripts/config/lxdialog/inputbox.c
+++ /dev/null
@@ -1,241 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * inputbox.c -- implements the input box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25char dialog_input_result[MAX_LEN + 1];
26
27/*
28 * Print the termination buttons
29 */
30static void
31print_buttons(WINDOW *dialog, int height, int width, int selected)
32{
33 int x = width / 2 - 11;
34 int y = height - 2;
35
36 print_button (dialog, " Ok ", y, x, selected==0);
37 print_button (dialog, " Help ", y, x + 14, selected==1);
38
39 wmove(dialog, y, x+1+14*selected);
40 wrefresh(dialog);
41}
42
43/*
44 * Display a dialog box for inputing a string
45 */
46int
47dialog_inputbox (const char *title, const char *prompt, int height, int width,
48 const char *init)
49{
50 int i, x, y, box_y, box_x, box_width;
51 int input_x = 0, scroll = 0, key = 0, button = -1;
52 char *instr = dialog_input_result;
53 WINDOW *dialog;
54
55 /* center dialog box on screen */
56 x = (COLS - width) / 2;
57 y = (LINES - height) / 2;
58
59
60 draw_shadow (stdscr, y, x, height, width);
61
62 dialog = newwin (height, width, y, x);
63 keypad (dialog, TRUE);
64
65 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
66 wattrset (dialog, border_attr);
67 mvwaddch (dialog, height-3, 0, ACS_LTEE);
68 for (i = 0; i < width - 2; i++)
69 waddch (dialog, ACS_HLINE);
70 wattrset (dialog, dialog_attr);
71 waddch (dialog, ACS_RTEE);
72
73 if (title != NULL && strlen(title) >= width-2 ) {
74 /* truncate long title -- mec */
75 char * title2 = malloc(width-2+1);
76 memcpy( title2, title, width-2 );
77 title2[width-2] = '\0';
78 title = title2;
79 }
80
81 if (title != NULL) {
82 wattrset (dialog, title_attr);
83 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
84 waddstr (dialog, (char *)title);
85 waddch (dialog, ' ');
86 }
87
88 wattrset (dialog, dialog_attr);
89 print_autowrap (dialog, prompt, width - 2, 1, 3);
90
91 /* Draw the input field box */
92 box_width = width - 6;
93 getyx (dialog, y, x);
94 box_y = y + 2;
95 box_x = (width - box_width) / 2;
96 draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2,
97 border_attr, dialog_attr);
98
99 print_buttons(dialog, height, width, 0);
100
101 /* Set up the initial value */
102 wmove (dialog, box_y, box_x);
103 wattrset (dialog, inputbox_attr);
104
105 if (!init)
106 instr[0] = '\0';
107 else
108 strcpy (instr, init);
109
110 input_x = strlen (instr);
111
112 if (input_x >= box_width) {
113 scroll = input_x - box_width + 1;
114 input_x = box_width - 1;
115 for (i = 0; i < box_width - 1; i++)
116 waddch (dialog, instr[scroll + i]);
117 } else
118 waddstr (dialog, instr);
119
120 wmove (dialog, box_y, box_x + input_x);
121
122 wrefresh (dialog);
123
124 while (key != ESC) {
125 key = wgetch (dialog);
126
127 if (button == -1) { /* Input box selected */
128 switch (key) {
129 case TAB:
130 case KEY_UP:
131 case KEY_DOWN:
132 break;
133 case KEY_LEFT:
134 continue;
135 case KEY_RIGHT:
136 continue;
137 case KEY_BACKSPACE:
138 case 127:
139 if (input_x || scroll) {
140 wattrset (dialog, inputbox_attr);
141 if (!input_x) {
142 scroll = scroll < box_width - 1 ?
143 0 : scroll - (box_width - 1);
144 wmove (dialog, box_y, box_x);
145 for (i = 0; i < box_width; i++)
146 waddch (dialog, instr[scroll + input_x + i] ?
147 instr[scroll + input_x + i] : ' ');
148 input_x = strlen (instr) - scroll;
149 } else
150 input_x--;
151 instr[scroll + input_x] = '\0';
152 mvwaddch (dialog, box_y, input_x + box_x, ' ');
153 wmove (dialog, box_y, input_x + box_x);
154 wrefresh (dialog);
155 }
156 continue;
157 default:
158 if (key < 0x100 && isprint (key)) {
159 if (scroll + input_x < MAX_LEN) {
160 wattrset (dialog, inputbox_attr);
161 instr[scroll + input_x] = key;
162 instr[scroll + input_x + 1] = '\0';
163 if (input_x == box_width - 1) {
164 scroll++;
165 wmove (dialog, box_y, box_x);
166 for (i = 0; i < box_width - 1; i++)
167 waddch (dialog, instr[scroll + i]);
168 } else {
169 wmove (dialog, box_y, input_x++ + box_x);
170 waddch (dialog, key);
171 }
172 wrefresh (dialog);
173 } else
174 flash (); /* Alarm user about overflow */
175 continue;
176 }
177 }
178 }
179 switch (key) {
180 case 'O':
181 case 'o':
182 delwin (dialog);
183 return 0;
184 case 'H':
185 case 'h':
186 delwin (dialog);
187 return 1;
188 case KEY_UP:
189 case KEY_LEFT:
190 switch (button) {
191 case -1:
192 button = 1; /* Indicates "Cancel" button is selected */
193 print_buttons(dialog, height, width, 1);
194 break;
195 case 0:
196 button = -1; /* Indicates input box is selected */
197 print_buttons(dialog, height, width, 0);
198 wmove (dialog, box_y, box_x + input_x);
199 wrefresh (dialog);
200 break;
201 case 1:
202 button = 0; /* Indicates "OK" button is selected */
203 print_buttons(dialog, height, width, 0);
204 break;
205 }
206 break;
207 case TAB:
208 case KEY_DOWN:
209 case KEY_RIGHT:
210 switch (button) {
211 case -1:
212 button = 0; /* Indicates "OK" button is selected */
213 print_buttons(dialog, height, width, 0);
214 break;
215 case 0:
216 button = 1; /* Indicates "Cancel" button is selected */
217 print_buttons(dialog, height, width, 1);
218 break;
219 case 1:
220 button = -1; /* Indicates input box is selected */
221 print_buttons(dialog, height, width, 0);
222 wmove (dialog, box_y, box_x + input_x);
223 wrefresh (dialog);
224 break;
225 }
226 break;
227 case ' ':
228 case '\n':
229 delwin (dialog);
230 return (button == -1 ? 0 : button);
231 case 'X':
232 case 'x':
233 key = ESC;
234 case ESC:
235 break;
236 }
237 }
238
239 delwin (dialog);
240 return -1; /* ESC pressed */
241}
diff --git a/scripts/config/lxdialog/menubox.c b/scripts/config/lxdialog/menubox.c
deleted file mode 100644
index bdaaa1040..000000000
--- a/scripts/config/lxdialog/menubox.c
+++ /dev/null
@@ -1,439 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * menubox.c -- implements the menu box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23/*
24 * Changes by Clifford Wolf (god@clifford.at)
25 *
26 * [ 1998-06-13 ]
27 *
28 * *) A bugfix for the Page-Down problem
29 *
30 * *) Formerly when I used Page Down and Page Up, the cursor would be set
31 * to the first position in the menu box. Now lxdialog is a bit
32 * smarter and works more like other menu systems (just have a look at
33 * it).
34 *
35 * *) Formerly if I selected something my scrolling would be broken because
36 * lxdialog is re-invoked by the Menuconfig shell script, can't
37 * remember the last scrolling position, and just sets it so that the
38 * cursor is at the bottom of the box. Now it writes the temporary file
39 * lxdialog.scrltmp which contains this information. The file is
40 * deleted by lxdialog if the user leaves a submenu or enters a new
41 * one, but it would be nice if Menuconfig could make another "rm -f"
42 * just to be sure. Just try it out - you will recognise a difference!
43 *
44 * [ 1998-06-14 ]
45 *
46 * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files
47 * and menus change their size on the fly.
48 *
49 * *) If for some reason the last scrolling position is not saved by
50 * lxdialog, it sets the scrolling so that the selected item is in the
51 * middle of the menu box, not at the bottom.
52 *
53 * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net)
54 * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus.
55 * This fixes a bug in Menuconfig where using ' ' to descend into menus
56 * would leave mis-synchronized lxdialog.scrltmp files lying around,
57 * fscanf would read in 'scroll', and eventually that value would get used.
58 */
59
60#include "dialog.h"
61
62static int menu_width, item_x;
63
64/*
65 * Print menu item
66 */
67static void
68print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey)
69{
70 int j;
71 char menu_item[menu_width+1];
72
73 strncpy(menu_item, item, menu_width);
74 menu_item[menu_width] = 0;
75 j = first_alpha(menu_item, "YyNnMmHh");
76
77 /* Clear 'residue' of last item */
78 wattrset (win, menubox_attr);
79 wmove (win, choice, 0);
80#if OLD_NCURSES
81 {
82 int i;
83 for (i = 0; i < menu_width; i++)
84 waddch (win, ' ');
85 }
86#else
87 wclrtoeol(win);
88#endif
89 wattrset (win, selected ? item_selected_attr : item_attr);
90 mvwaddstr (win, choice, item_x, menu_item);
91 if (hotkey) {
92 wattrset (win, selected ? tag_key_selected_attr : tag_key_attr);
93 mvwaddch(win, choice, item_x+j, menu_item[j]);
94 }
95 if (selected) {
96 wmove (win, choice, item_x+1);
97 wrefresh (win);
98 }
99}
100
101/*
102 * Print the scroll indicators.
103 */
104static void
105print_arrows (WINDOW * win, int item_no, int scroll,
106 int y, int x, int height)
107{
108 int cur_y, cur_x;
109
110 getyx(win, cur_y, cur_x);
111
112 wmove(win, y, x);
113
114 if (scroll > 0) {
115 wattrset (win, uarrow_attr);
116 waddch (win, ACS_UARROW);
117 waddstr (win, "(-)");
118 }
119 else {
120 wattrset (win, menubox_attr);
121 waddch (win, ACS_HLINE);
122 waddch (win, ACS_HLINE);
123 waddch (win, ACS_HLINE);
124 waddch (win, ACS_HLINE);
125 }
126
127 y = y + height + 1;
128 wmove(win, y, x);
129
130 if ((height < item_no) && (scroll + height < item_no)) {
131 wattrset (win, darrow_attr);
132 waddch (win, ACS_DARROW);
133 waddstr (win, "(+)");
134 }
135 else {
136 wattrset (win, menubox_border_attr);
137 waddch (win, ACS_HLINE);
138 waddch (win, ACS_HLINE);
139 waddch (win, ACS_HLINE);
140 waddch (win, ACS_HLINE);
141 }
142
143 wmove(win, cur_y, cur_x);
144}
145
146/*
147 * Display the termination buttons.
148 */
149static void
150print_buttons (WINDOW *win, int height, int width, int selected)
151{
152 int x = width / 2 - 16;
153 int y = height - 2;
154
155 print_button (win, "Select", y, x, selected == 0);
156 print_button (win, " Exit ", y, x + 12, selected == 1);
157 print_button (win, " Help ", y, x + 24, selected == 2);
158
159 wmove(win, y, x+1+12*selected);
160 wrefresh (win);
161}
162
163/*
164 * Display a menu for choosing among a number of options
165 */
166int
167dialog_menu (const char *title, const char *prompt, int height, int width,
168 int menu_height, const char *current, int item_no,
169 struct dialog_list_item ** items)
170{
171 int i, j, x, y, box_x, box_y;
172 int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice;
173 WINDOW *dialog, *menu;
174 FILE *f;
175
176 max_choice = MIN (menu_height, item_no);
177
178 /* center dialog box on screen */
179 x = (COLS - width) / 2;
180 y = (LINES - height) / 2;
181
182 draw_shadow (stdscr, y, x, height, width);
183
184 dialog = newwin (height, width, y, x);
185 keypad (dialog, TRUE);
186
187 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
188 wattrset (dialog, border_attr);
189 mvwaddch (dialog, height - 3, 0, ACS_LTEE);
190 for (i = 0; i < width - 2; i++)
191 waddch (dialog, ACS_HLINE);
192 wattrset (dialog, dialog_attr);
193 wbkgdset (dialog, dialog_attr & A_COLOR);
194 waddch (dialog, ACS_RTEE);
195
196 if (title != NULL && strlen(title) >= width-2 ) {
197 /* truncate long title -- mec */
198 char * title2 = malloc(width-2+1);
199 memcpy( title2, title, width-2 );
200 title2[width-2] = '\0';
201 title = title2;
202 }
203
204 if (title != NULL) {
205 wattrset (dialog, title_attr);
206 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
207 waddstr (dialog, (char *)title);
208 waddch (dialog, ' ');
209 }
210
211 wattrset (dialog, dialog_attr);
212 print_autowrap (dialog, prompt, width - 2, 1, 3);
213
214 menu_width = width - 6;
215 box_y = height - menu_height - 5;
216 box_x = (width - menu_width) / 2 - 1;
217
218 /* create new window for the menu */
219 menu = subwin (dialog, menu_height, menu_width,
220 y + box_y + 1, x + box_x + 1);
221 keypad (menu, TRUE);
222
223 /* draw a box around the menu items */
224 draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2,
225 menubox_border_attr, menubox_attr);
226
227 /*
228 * Find length of longest item in order to center menu.
229 * Set 'choice' to default item.
230 */
231 item_x = 0;
232 for (i = 0; i < item_no; i++) {
233 item_x = MAX (item_x, MIN(menu_width, strlen (items[i]->name) + 2));
234 if (strcmp(current, items[i]->tag) == 0) choice = i;
235 }
236
237 item_x = (menu_width - item_x) / 2;
238
239 /* get the scroll info from the temp file */
240 if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) {
241 if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) &&
242 (scroll+max_choice > choice) && (scroll >= 0) &&
243 (scroll+max_choice <= item_no) ) {
244 first_item = scroll;
245 choice = choice - scroll;
246 fclose(f);
247 } else {
248 scroll=0;
249 remove("lxdialog.scrltmp");
250 fclose(f);
251 f=NULL;
252 }
253 }
254 if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) {
255 if (choice >= item_no-max_choice/2)
256 scroll = first_item = item_no-max_choice;
257 else
258 scroll = first_item = choice - max_choice/2;
259 choice = choice - scroll;
260 }
261
262 /* Print the menu */
263 for (i=0; i < max_choice; i++) {
264 print_item (menu, items[first_item + i]->name, i, i == choice,
265 (items[first_item + i]->tag[0] != ':'));
266 }
267
268 wnoutrefresh (menu);
269
270 print_arrows(dialog, item_no, scroll,
271 box_y, box_x+item_x+1, menu_height);
272
273 print_buttons (dialog, height, width, 0);
274 wmove (menu, choice, item_x+1);
275 wrefresh (menu);
276
277 while (key != ESC) {
278 key = wgetch(menu);
279
280 if (key < 256 && isalpha(key)) key = tolower(key);
281
282 if (strchr("ynmh", key))
283 i = max_choice;
284 else {
285 for (i = choice+1; i < max_choice; i++) {
286 j = first_alpha(items[scroll + i]->name, "YyNnMmHh");
287 if (key == tolower(items[scroll + i]->name[j]))
288 break;
289 }
290 if (i == max_choice)
291 for (i = 0; i < max_choice; i++) {
292 j = first_alpha(items[scroll + i]->name, "YyNnMmHh");
293 if (key == tolower(items[scroll + i]->name[j]))
294 break;
295 }
296 }
297
298 if (i < max_choice ||
299 key == KEY_UP || key == KEY_DOWN ||
300 key == '-' || key == '+' ||
301 key == KEY_PPAGE || key == KEY_NPAGE) {
302
303 print_item (menu, items[scroll + choice]->name, choice, FALSE,
304 (items[scroll + choice]->tag[0] != ':'));
305
306 if (key == KEY_UP || key == '-') {
307 if (choice < 2 && scroll) {
308 /* Scroll menu down */
309 scrollok (menu, TRUE);
310 wscrl (menu, -1);
311 scrollok (menu, FALSE);
312
313 scroll--;
314
315 print_item (menu, items[scroll]->name, 0, FALSE,
316 (items[scroll]->tag[0] != ':'));
317 } else
318 choice = MAX(choice - 1, 0);
319
320 } else if (key == KEY_DOWN || key == '+') {
321
322 print_item (menu, items[scroll + choice]->name, choice, FALSE,
323 (items[scroll + choice]->tag[0] != ':'));
324
325 if ((choice > max_choice-3) &&
326 (scroll + max_choice < item_no)
327 ) {
328 /* Scroll menu up */
329 scrollok (menu, TRUE);
330 scroll (menu);
331 scrollok (menu, FALSE);
332
333 scroll++;
334
335 print_item (menu, items[scroll + max_choice - 1]->name,
336 max_choice-1, FALSE,
337 (items[scroll + max_choice - 1]->tag[0] != ':'));
338 } else
339 choice = MIN(choice+1, max_choice-1);
340
341 } else if (key == KEY_PPAGE) {
342 scrollok (menu, TRUE);
343 for (i=0; (i < max_choice); i++) {
344 if (scroll > 0) {
345 wscrl (menu, -1);
346 scroll--;
347 print_item (menu, items[scroll]->name, 0, FALSE,
348 (items[scroll]->tag[0] != ':'));
349 } else {
350 if (choice > 0)
351 choice--;
352 }
353 }
354 scrollok (menu, FALSE);
355
356 } else if (key == KEY_NPAGE) {
357 for (i=0; (i < max_choice); i++) {
358 if (scroll+max_choice < item_no) {
359 scrollok (menu, TRUE);
360 scroll(menu);
361 scrollok (menu, FALSE);
362 scroll++;
363 print_item (menu, items[scroll + max_choice - 1]->name,
364 max_choice-1, FALSE,
365 (items[scroll + max_choice - 1]->tag[0] != ':'));
366 } else {
367 if (choice+1 < max_choice)
368 choice++;
369 }
370 }
371
372 } else
373 choice = i;
374
375 print_item (menu, items[scroll + choice]->name, choice, TRUE,
376 (items[scroll + choice]->tag[0] != ':'));
377
378 print_arrows(dialog, item_no, scroll,
379 box_y, box_x+item_x+1, menu_height);
380
381 wnoutrefresh (dialog);
382 wrefresh (menu);
383
384 continue; /* wait for another key press */
385 }
386
387 switch (key) {
388 case KEY_LEFT:
389 case TAB:
390 case KEY_RIGHT:
391 button = ((key == KEY_LEFT ? --button : ++button) < 0)
392 ? 2 : (button > 2 ? 0 : button);
393
394 print_buttons(dialog, height, width, button);
395 wrefresh (menu);
396 break;
397 case ' ':
398 case 's':
399 case 'y':
400 case 'n':
401 case 'm':
402 case '/':
403 /* save scroll info */
404 if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) {
405 fprintf(f,"%d\n",scroll);
406 fclose(f);
407 }
408 delwin (dialog);
409 items[scroll + choice]->selected = 1;
410 switch (key) {
411 case 's': return 3;
412 case 'y': return 3;
413 case 'n': return 4;
414 case 'm': return 5;
415 case ' ': return 6;
416 case '/': return 7;
417 }
418 return 0;
419 case 'h':
420 case '?':
421 button = 2;
422 case '\n':
423 delwin (dialog);
424 items[scroll + choice]->selected = 1;
425
426 remove("lxdialog.scrltmp");
427 return button;
428 case 'e':
429 case 'x':
430 key = ESC;
431 case ESC:
432 break;
433 }
434 }
435
436 delwin (dialog);
437 remove("lxdialog.scrltmp");
438 return -1; /* ESC pressed */
439}
diff --git a/scripts/config/lxdialog/msgbox.c b/scripts/config/lxdialog/msgbox.c
deleted file mode 100644
index a13bcbafb..000000000
--- a/scripts/config/lxdialog/msgbox.c
+++ /dev/null
@@ -1,86 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * msgbox.c -- implements the message box and info box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25/*
26 * Display a message box. Program will pause and display an "OK" button
27 * if the parameter 'pause' is non-zero.
28 */
29int
30dialog_msgbox (const char *title, const char *prompt, int height, int width,
31 int pause)
32{
33 int i, x, y, key = 0;
34 WINDOW *dialog;
35
36 /* center dialog box on screen */
37 x = (COLS - width) / 2;
38 y = (LINES - height) / 2;
39
40 draw_shadow (stdscr, y, x, height, width);
41
42 dialog = newwin (height, width, y, x);
43 keypad (dialog, TRUE);
44
45 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
46
47 if (title != NULL && strlen(title) >= width-2 ) {
48 /* truncate long title -- mec */
49 char * title2 = malloc(width-2+1);
50 memcpy( title2, title, width-2 );
51 title2[width-2] = '\0';
52 title = title2;
53 }
54
55 if (title != NULL) {
56 wattrset (dialog, title_attr);
57 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
58 waddstr (dialog, (char *)title);
59 waddch (dialog, ' ');
60 }
61 wattrset (dialog, dialog_attr);
62 print_autowrap (dialog, prompt, width - 2, 1, 2);
63
64 if (pause) {
65 wattrset (dialog, border_attr);
66 mvwaddch (dialog, height - 3, 0, ACS_LTEE);
67 for (i = 0; i < width - 2; i++)
68 waddch (dialog, ACS_HLINE);
69 wattrset (dialog, dialog_attr);
70 waddch (dialog, ACS_RTEE);
71
72 print_button (dialog, " Ok ",
73 height - 2, width / 2 - 4, TRUE);
74
75 wrefresh (dialog);
76 while (key != ESC && key != '\n' && key != ' ' &&
77 key != 'O' && key != 'o' && key != 'X' && key != 'x')
78 key = wgetch (dialog);
79 } else {
80 key = '\n';
81 wrefresh (dialog);
82 }
83
84 delwin (dialog);
85 return key == ESC ? -1 : 0;
86}
diff --git a/scripts/config/lxdialog/textbox.c b/scripts/config/lxdialog/textbox.c
deleted file mode 100644
index aa7f5afe2..000000000
--- a/scripts/config/lxdialog/textbox.c
+++ /dev/null
@@ -1,557 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * textbox.c -- implements the text box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25static void back_lines (int n);
26static void print_page (WINDOW * win, int height, int width);
27static void print_line (WINDOW * win, int row, int width);
28static char *get_line (void);
29static void print_position (WINDOW * win, int height, int width);
30
31static int hscroll, fd, file_size, bytes_read;
32static int begin_reached = 1, end_reached, page_length;
33static char *buf, *page;
34
35/*
36 * Display text from a file in a dialog box.
37 */
38int
39dialog_textbox (const char *title, const char *file, int height, int width)
40{
41 int i, x, y, cur_x, cur_y, fpos, key = 0;
42 int passed_end;
43 char search_term[MAX_LEN + 1];
44 WINDOW *dialog, *text;
45
46 search_term[0] = '\0'; /* no search term entered yet */
47
48 /* Open input file for reading */
49 if ((fd = open (file, O_RDONLY)) == -1) {
50 endwin ();
51 fprintf (stderr,
52 "\nCan't open input file in dialog_textbox().\n");
53 exit (-1);
54 }
55 /* Get file size. Actually, 'file_size' is the real file size - 1,
56 since it's only the last byte offset from the beginning */
57 if ((file_size = lseek (fd, 0, SEEK_END)) == -1) {
58 endwin ();
59 fprintf (stderr, "\nError getting file size in dialog_textbox().\n");
60 exit (-1);
61 }
62 /* Restore file pointer to beginning of file after getting file size */
63 if (lseek (fd, 0, SEEK_SET) == -1) {
64 endwin ();
65 fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n");
66 exit (-1);
67 }
68 /* Allocate space for read buffer */
69 if ((buf = malloc (BUF_SIZE + 1)) == NULL) {
70 endwin ();
71 fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n");
72 exit (-1);
73 }
74 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
75 endwin ();
76 fprintf (stderr, "\nError reading file in dialog_textbox().\n");
77 exit (-1);
78 }
79 buf[bytes_read] = '\0'; /* mark end of valid data */
80 page = buf; /* page is pointer to start of page to be displayed */
81
82 /* center dialog box on screen */
83 x = (COLS - width) / 2;
84 y = (LINES - height) / 2;
85
86
87 draw_shadow (stdscr, y, x, height, width);
88
89 dialog = newwin (height, width, y, x);
90 keypad (dialog, TRUE);
91
92 /* Create window for text region, used for scrolling text */
93 text = subwin (dialog, height - 4, width - 2, y + 1, x + 1);
94 wattrset (text, dialog_attr);
95 wbkgdset (text, dialog_attr & A_COLOR);
96
97 keypad (text, TRUE);
98
99 /* register the new window, along with its borders */
100 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
101
102 wattrset (dialog, border_attr);
103 mvwaddch (dialog, height-3, 0, ACS_LTEE);
104 for (i = 0; i < width - 2; i++)
105 waddch (dialog, ACS_HLINE);
106 wattrset (dialog, dialog_attr);
107 wbkgdset (dialog, dialog_attr & A_COLOR);
108 waddch (dialog, ACS_RTEE);
109
110 if (title != NULL && strlen(title) >= width-2 ) {
111 /* truncate long title -- mec */
112 char * title2 = malloc(width-2+1);
113 memcpy( title2, title, width-2 );
114 title2[width-2] = '\0';
115 title = title2;
116 }
117
118 if (title != NULL) {
119 wattrset (dialog, title_attr);
120 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
121 waddstr (dialog, (char *)title);
122 waddch (dialog, ' ');
123 }
124 print_button (dialog, " Exit ", height - 2, width / 2 - 4, TRUE);
125 wnoutrefresh (dialog);
126 getyx (dialog, cur_y, cur_x); /* Save cursor position */
127
128 /* Print first page of text */
129 attr_clear (text, height - 4, width - 2, dialog_attr);
130 print_page (text, height - 4, width - 2);
131 print_position (dialog, height, width);
132 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
133 wrefresh (dialog);
134
135 while ((key != ESC) && (key != '\n')) {
136 key = wgetch (dialog);
137 switch (key) {
138 case 'E': /* Exit */
139 case 'e':
140 case 'X':
141 case 'x':
142 delwin (dialog);
143 free (buf);
144 close (fd);
145 return 0;
146 case 'g': /* First page */
147 case KEY_HOME:
148 if (!begin_reached) {
149 begin_reached = 1;
150 /* First page not in buffer? */
151 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
152 endwin ();
153 fprintf (stderr,
154 "\nError moving file pointer in dialog_textbox().\n");
155 exit (-1);
156 }
157 if (fpos > bytes_read) { /* Yes, we have to read it in */
158 if (lseek (fd, 0, SEEK_SET) == -1) {
159 endwin ();
160 fprintf (stderr, "\nError moving file pointer in "
161 "dialog_textbox().\n");
162 exit (-1);
163 }
164 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
165 endwin ();
166 fprintf (stderr,
167 "\nError reading file in dialog_textbox().\n");
168 exit (-1);
169 }
170 buf[bytes_read] = '\0';
171 }
172 page = buf;
173 print_page (text, height - 4, width - 2);
174 print_position (dialog, height, width);
175 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
176 wrefresh (dialog);
177 }
178 break;
179 case 'G': /* Last page */
180 case KEY_END:
181
182 end_reached = 1;
183 /* Last page not in buffer? */
184 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
185 endwin ();
186 fprintf (stderr,
187 "\nError moving file pointer in dialog_textbox().\n");
188 exit (-1);
189 }
190 if (fpos < file_size) { /* Yes, we have to read it in */
191 if (lseek (fd, -BUF_SIZE, SEEK_END) == -1) {
192 endwin ();
193 fprintf (stderr,
194 "\nError moving file pointer in dialog_textbox().\n");
195 exit (-1);
196 }
197 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
198 endwin ();
199 fprintf (stderr,
200 "\nError reading file in dialog_textbox().\n");
201 exit (-1);
202 }
203 buf[bytes_read] = '\0';
204 }
205 page = buf + bytes_read;
206 back_lines (height - 4);
207 print_page (text, height - 4, width - 2);
208 print_position (dialog, height, width);
209 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
210 wrefresh (dialog);
211 break;
212 case 'K': /* Previous line */
213 case 'k':
214 case KEY_UP:
215 if (!begin_reached) {
216 back_lines (page_length + 1);
217
218 /* We don't call print_page() here but use scrolling to ensure
219 faster screen update. However, 'end_reached' and
220 'page_length' should still be updated, and 'page' should
221 point to start of next page. This is done by calling
222 get_line() in the following 'for' loop. */
223 scrollok (text, TRUE);
224 wscrl (text, -1); /* Scroll text region down one line */
225 scrollok (text, FALSE);
226 page_length = 0;
227 passed_end = 0;
228 for (i = 0; i < height - 4; i++) {
229 if (!i) {
230 /* print first line of page */
231 print_line (text, 0, width - 2);
232 wnoutrefresh (text);
233 } else
234 /* Called to update 'end_reached' and 'page' */
235 get_line ();
236 if (!passed_end)
237 page_length++;
238 if (end_reached && !passed_end)
239 passed_end = 1;
240 }
241
242 print_position (dialog, height, width);
243 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
244 wrefresh (dialog);
245 }
246 break;
247 case 'B': /* Previous page */
248 case 'b':
249 case KEY_PPAGE:
250 if (begin_reached)
251 break;
252 back_lines (page_length + height - 4);
253 print_page (text, height - 4, width - 2);
254 print_position (dialog, height, width);
255 wmove (dialog, cur_y, cur_x);
256 wrefresh (dialog);
257 break;
258 case 'J': /* Next line */
259 case 'j':
260 case KEY_DOWN:
261 if (!end_reached) {
262 begin_reached = 0;
263 scrollok (text, TRUE);
264 scroll (text); /* Scroll text region up one line */
265 scrollok (text, FALSE);
266 print_line (text, height - 5, width - 2);
267 wnoutrefresh (text);
268 print_position (dialog, height, width);
269 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
270 wrefresh (dialog);
271 }
272 break;
273 case KEY_NPAGE: /* Next page */
274 case ' ':
275 if (end_reached)
276 break;
277
278 begin_reached = 0;
279 print_page (text, height - 4, width - 2);
280 print_position (dialog, height, width);
281 wmove (dialog, cur_y, cur_x);
282 wrefresh (dialog);
283 break;
284 case '0': /* Beginning of line */
285 case 'H': /* Scroll left */
286 case 'h':
287 case KEY_LEFT:
288 if (hscroll <= 0)
289 break;
290
291 if (key == '0')
292 hscroll = 0;
293 else
294 hscroll--;
295 /* Reprint current page to scroll horizontally */
296 back_lines (page_length);
297 print_page (text, height - 4, width - 2);
298 wmove (dialog, cur_y, cur_x);
299 wrefresh (dialog);
300 break;
301 case 'L': /* Scroll right */
302 case 'l':
303 case KEY_RIGHT:
304 if (hscroll >= MAX_LEN)
305 break;
306 hscroll++;
307 /* Reprint current page to scroll horizontally */
308 back_lines (page_length);
309 print_page (text, height - 4, width - 2);
310 wmove (dialog, cur_y, cur_x);
311 wrefresh (dialog);
312 break;
313 case ESC:
314 break;
315 }
316 }
317
318 delwin (dialog);
319 free (buf);
320 close (fd);
321 return 1; /* ESC pressed */
322}
323
324/*
325 * Go back 'n' lines in text file. Called by dialog_textbox().
326 * 'page' will be updated to point to the desired line in 'buf'.
327 */
328static void
329back_lines (int n)
330{
331 int i, fpos;
332
333 begin_reached = 0;
334 /* We have to distinguish between end_reached and !end_reached
335 since at end of file, the line is not ended by a '\n'.
336 The code inside 'if' basically does a '--page' to move one
337 character backward so as to skip '\n' of the previous line */
338 if (!end_reached) {
339 /* Either beginning of buffer or beginning of file reached? */
340 if (page == buf) {
341 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
342 endwin ();
343 fprintf (stderr, "\nError moving file pointer in "
344 "back_lines().\n");
345 exit (-1);
346 }
347 if (fpos > bytes_read) { /* Not beginning of file yet */
348 /* We've reached beginning of buffer, but not beginning of
349 file yet, so read previous part of file into buffer.
350 Note that we only move backward for BUF_SIZE/2 bytes,
351 but not BUF_SIZE bytes to avoid re-reading again in
352 print_page() later */
353 /* Really possible to move backward BUF_SIZE/2 bytes? */
354 if (fpos < BUF_SIZE / 2 + bytes_read) {
355 /* No, move less then */
356 if (lseek (fd, 0, SEEK_SET) == -1) {
357 endwin ();
358 fprintf (stderr, "\nError moving file pointer in "
359 "back_lines().\n");
360 exit (-1);
361 }
362 page = buf + fpos - bytes_read;
363 } else { /* Move backward BUF_SIZE/2 bytes */
364 if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR)
365 == -1) {
366 endwin ();
367 fprintf (stderr, "\nError moving file pointer "
368 "in back_lines().\n");
369 exit (-1);
370 }
371 page = buf + BUF_SIZE / 2;
372 }
373 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
374 endwin ();
375 fprintf (stderr, "\nError reading file in back_lines().\n");
376 exit (-1);
377 }
378 buf[bytes_read] = '\0';
379 } else { /* Beginning of file reached */
380 begin_reached = 1;
381 return;
382 }
383 }
384 if (*(--page) != '\n') { /* '--page' here */
385 /* Something's wrong... */
386 endwin ();
387 fprintf (stderr, "\nInternal error in back_lines().\n");
388 exit (-1);
389 }
390 }
391 /* Go back 'n' lines */
392 for (i = 0; i < n; i++)
393 do {
394 if (page == buf) {
395 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
396 endwin ();
397 fprintf (stderr,
398 "\nError moving file pointer in back_lines().\n");
399 exit (-1);
400 }
401 if (fpos > bytes_read) {
402 /* Really possible to move backward BUF_SIZE/2 bytes? */
403 if (fpos < BUF_SIZE / 2 + bytes_read) {
404 /* No, move less then */
405 if (lseek (fd, 0, SEEK_SET) == -1) {
406 endwin ();
407 fprintf (stderr, "\nError moving file pointer "
408 "in back_lines().\n");
409 exit (-1);
410 }
411 page = buf + fpos - bytes_read;
412 } else { /* Move backward BUF_SIZE/2 bytes */
413 if (lseek (fd, -(BUF_SIZE / 2 + bytes_read),
414 SEEK_CUR) == -1) {
415 endwin ();
416 fprintf (stderr, "\nError moving file pointer"
417 " in back_lines().\n");
418 exit (-1);
419 }
420 page = buf + BUF_SIZE / 2;
421 }
422 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
423 endwin ();
424 fprintf (stderr, "\nError reading file in "
425 "back_lines().\n");
426 exit (-1);
427 }
428 buf[bytes_read] = '\0';
429 } else { /* Beginning of file reached */
430 begin_reached = 1;
431 return;
432 }
433 }
434 } while (*(--page) != '\n');
435 page++;
436}
437
438/*
439 * Print a new page of text. Called by dialog_textbox().
440 */
441static void
442print_page (WINDOW * win, int height, int width)
443{
444 int i, passed_end = 0;
445
446 page_length = 0;
447 for (i = 0; i < height; i++) {
448 print_line (win, i, width);
449 if (!passed_end)
450 page_length++;
451 if (end_reached && !passed_end)
452 passed_end = 1;
453 }
454 wnoutrefresh (win);
455}
456
457/*
458 * Print a new line of text. Called by dialog_textbox() and print_page().
459 */
460static void
461print_line (WINDOW * win, int row, int width)
462{
463 int y, x;
464 char *line;
465
466 line = get_line ();
467 line += MIN (strlen (line), hscroll); /* Scroll horizontally */
468 wmove (win, row, 0); /* move cursor to correct line */
469 waddch (win, ' ');
470 waddnstr (win, line, MIN (strlen (line), width - 2));
471
472 getyx (win, y, x);
473 /* Clear 'residue' of previous line */
474#if OLD_NCURSES
475 {
476 int i;
477 for (i = 0; i < width - x; i++)
478 waddch (win, ' ');
479 }
480#else
481 wclrtoeol(win);
482#endif
483}
484
485/*
486 * Return current line of text. Called by dialog_textbox() and print_line().
487 * 'page' should point to start of current line before calling, and will be
488 * updated to point to start of next line.
489 */
490static char *
491get_line (void)
492{
493 int i = 0, fpos;
494 static char line[MAX_LEN + 1];
495
496 end_reached = 0;
497 while (*page != '\n') {
498 if (*page == '\0') {
499 /* Either end of file or end of buffer reached */
500 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
501 endwin ();
502 fprintf (stderr, "\nError moving file pointer in "
503 "get_line().\n");
504 exit (-1);
505 }
506 if (fpos < file_size) { /* Not end of file yet */
507 /* We've reached end of buffer, but not end of file yet,
508 so read next part of file into buffer */
509 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
510 endwin ();
511 fprintf (stderr, "\nError reading file in get_line().\n");
512 exit (-1);
513 }
514 buf[bytes_read] = '\0';
515 page = buf;
516 } else {
517 if (!end_reached)
518 end_reached = 1;
519 break;
520 }
521 } else if (i < MAX_LEN)
522 line[i++] = *(page++);
523 else {
524 /* Truncate lines longer than MAX_LEN characters */
525 if (i == MAX_LEN)
526 line[i++] = '\0';
527 page++;
528 }
529 }
530 if (i <= MAX_LEN)
531 line[i] = '\0';
532 if (!end_reached)
533 page++; /* move pass '\n' */
534
535 return line;
536}
537
538/*
539 * Print current position
540 */
541static void
542print_position (WINDOW * win, int height, int width)
543{
544 int fpos, percent;
545
546 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
547 endwin ();
548 fprintf (stderr, "\nError moving file pointer in print_position().\n");
549 exit (-1);
550 }
551 wattrset (win, position_indicator_attr);
552 wbkgdset (win, position_indicator_attr & A_COLOR);
553 percent = !file_size ?
554 100 : ((fpos - bytes_read + page - buf) * 100) / file_size;
555 wmove (win, height - 3, width - 9);
556 wprintw (win, "(%3d%%)", percent);
557}
diff --git a/scripts/config/lxdialog/util.c b/scripts/config/lxdialog/util.c
deleted file mode 100644
index 26dd376b9..000000000
--- a/scripts/config/lxdialog/util.c
+++ /dev/null
@@ -1,376 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * util.c
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25
26/* use colors by default? */
27bool use_colors = 1;
28
29const char *backtitle = NULL;
30
31const char *dialog_result;
32
33/*
34 * Attribute values, default is for mono display
35 */
36chtype attributes[] =
37{
38 A_NORMAL, /* screen_attr */
39 A_NORMAL, /* shadow_attr */
40 A_NORMAL, /* dialog_attr */
41 A_BOLD, /* title_attr */
42 A_NORMAL, /* border_attr */
43 A_REVERSE, /* button_active_attr */
44 A_DIM, /* button_inactive_attr */
45 A_REVERSE, /* button_key_active_attr */
46 A_BOLD, /* button_key_inactive_attr */
47 A_REVERSE, /* button_label_active_attr */
48 A_NORMAL, /* button_label_inactive_attr */
49 A_NORMAL, /* inputbox_attr */
50 A_NORMAL, /* inputbox_border_attr */
51 A_NORMAL, /* searchbox_attr */
52 A_BOLD, /* searchbox_title_attr */
53 A_NORMAL, /* searchbox_border_attr */
54 A_BOLD, /* position_indicator_attr */
55 A_NORMAL, /* menubox_attr */
56 A_NORMAL, /* menubox_border_attr */
57 A_NORMAL, /* item_attr */
58 A_REVERSE, /* item_selected_attr */
59 A_BOLD, /* tag_attr */
60 A_REVERSE, /* tag_selected_attr */
61 A_BOLD, /* tag_key_attr */
62 A_REVERSE, /* tag_key_selected_attr */
63 A_BOLD, /* check_attr */
64 A_REVERSE, /* check_selected_attr */
65 A_BOLD, /* uarrow_attr */
66 A_BOLD /* darrow_attr */
67};
68
69
70#include "colors.h"
71
72/*
73 * Table of color values
74 */
75int color_table[][3] =
76{
77 {SCREEN_FG, SCREEN_BG, SCREEN_HL},
78 {SHADOW_FG, SHADOW_BG, SHADOW_HL},
79 {DIALOG_FG, DIALOG_BG, DIALOG_HL},
80 {TITLE_FG, TITLE_BG, TITLE_HL},
81 {BORDER_FG, BORDER_BG, BORDER_HL},
82 {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL},
83 {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL},
84 {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL},
85 {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL},
86 {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL},
87 {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG,
88 BUTTON_LABEL_INACTIVE_HL},
89 {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL},
90 {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL},
91 {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL},
92 {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL},
93 {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL},
94 {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL},
95 {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL},
96 {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL},
97 {ITEM_FG, ITEM_BG, ITEM_HL},
98 {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL},
99 {TAG_FG, TAG_BG, TAG_HL},
100 {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL},
101 {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL},
102 {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL},
103 {CHECK_FG, CHECK_BG, CHECK_HL},
104 {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL},
105 {UARROW_FG, UARROW_BG, UARROW_HL},
106 {DARROW_FG, DARROW_BG, DARROW_HL},
107}; /* color_table */
108
109/*
110 * Set window to attribute 'attr'
111 */
112void
113attr_clear (WINDOW * win, int height, int width, chtype attr)
114{
115 int i, j;
116
117 wattrset (win, attr);
118 for (i = 0; i < height; i++) {
119 wmove (win, i, 0);
120 for (j = 0; j < width; j++)
121 waddch (win, ' ');
122 }
123 touchwin (win);
124}
125
126void dialog_clear (void)
127{
128 attr_clear (stdscr, LINES, COLS, screen_attr);
129 /* Display background title if it exists ... - SLH */
130 if (backtitle != NULL) {
131 int i;
132
133 wattrset (stdscr, screen_attr);
134 mvwaddstr (stdscr, 0, 1, (char *)backtitle);
135 wmove (stdscr, 1, 1);
136 for (i = 1; i < COLS - 1; i++)
137 waddch (stdscr, ACS_HLINE);
138 }
139 wnoutrefresh (stdscr);
140}
141
142/*
143 * Do some initialization for dialog
144 */
145void
146init_dialog (void)
147{
148 initscr (); /* Init curses */
149 keypad (stdscr, TRUE);
150 cbreak ();
151 noecho ();
152
153
154 if (use_colors) /* Set up colors */
155 color_setup ();
156
157
158 dialog_clear ();
159}
160
161/*
162 * Setup for color display
163 */
164void
165color_setup (void)
166{
167 int i;
168
169 if (has_colors ()) { /* Terminal supports color? */
170 start_color ();
171
172 /* Initialize color pairs */
173 for (i = 0; i < ATTRIBUTE_COUNT; i++)
174 init_pair (i + 1, color_table[i][0], color_table[i][1]);
175
176 /* Setup color attributes */
177 for (i = 0; i < ATTRIBUTE_COUNT; i++)
178 attributes[i] = C_ATTR (color_table[i][2], i + 1);
179 }
180}
181
182/*
183 * End using dialog functions.
184 */
185void
186end_dialog (void)
187{
188 endwin ();
189}
190
191
192/*
193 * Print a string of text in a window, automatically wrap around to the
194 * next line if the string is too long to fit on one line. Newline
195 * characters '\n' are replaced by spaces. We start on a new line
196 * if there is no room for at least 4 nonblanks following a double-space.
197 */
198void
199print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
200{
201 int newl, cur_x, cur_y;
202 int i, prompt_len, room, wlen;
203 char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
204
205 strcpy (tempstr, prompt);
206
207 prompt_len = strlen(tempstr);
208
209 /*
210 * Remove newlines
211 */
212 for(i=0; i<prompt_len; i++) {
213 if(tempstr[i] == '\n') tempstr[i] = ' ';
214 }
215
216 if (prompt_len <= width - x * 2) { /* If prompt is short */
217 wmove (win, y, (width - prompt_len) / 2);
218 waddstr (win, tempstr);
219 } else {
220 cur_x = x;
221 cur_y = y;
222 newl = 1;
223 word = tempstr;
224 while (word && *word) {
225 sp = strchr(word, ' ');
226 if (sp)
227 *sp++ = 0;
228
229 /* Wrap to next line if either the word does not fit,
230 or it is the first word of a new sentence, and it is
231 short, and the next word does not fit. */
232 room = width - cur_x;
233 wlen = strlen(word);
234 if (wlen > room ||
235 (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room
236 && (!(sp2 = strchr(sp, ' ')) || wlen+1+(sp2-sp) > room))) {
237 cur_y++;
238 cur_x = x;
239 }
240 wmove (win, cur_y, cur_x);
241 waddstr (win, word);
242 getyx (win, cur_y, cur_x);
243 cur_x++;
244 if (sp && *sp == ' ') {
245 cur_x++; /* double space */
246 while (*++sp == ' ');
247 newl = 1;
248 } else
249 newl = 0;
250 word = sp;
251 }
252 }
253}
254
255/*
256 * Print a button
257 */
258void
259print_button (WINDOW * win, const char *label, int y, int x, int selected)
260{
261 int i, temp;
262
263 wmove (win, y, x);
264 wattrset (win, selected ? button_active_attr : button_inactive_attr);
265 waddstr (win, "<");
266 temp = strspn (label, " ");
267 label += temp;
268 wattrset (win, selected ? button_label_active_attr
269 : button_label_inactive_attr);
270 for (i = 0; i < temp; i++)
271 waddch (win, ' ');
272 wattrset (win, selected ? button_key_active_attr
273 : button_key_inactive_attr);
274 waddch (win, label[0]);
275 wattrset (win, selected ? button_label_active_attr
276 : button_label_inactive_attr);
277 waddstr (win, (char *)label + 1);
278 wattrset (win, selected ? button_active_attr : button_inactive_attr);
279 waddstr (win, ">");
280 wmove (win, y, x + temp + 1);
281}
282
283/*
284 * Draw a rectangular box with line drawing characters
285 */
286void
287draw_box (WINDOW * win, int y, int x, int height, int width,
288 chtype box, chtype border)
289{
290 int i, j;
291
292 wattrset (win, 0);
293 for (i = 0; i < height; i++) {
294 wmove (win, y + i, x);
295 for (j = 0; j < width; j++)
296 if (!i && !j)
297 waddch (win, border | ACS_ULCORNER);
298 else if (i == height - 1 && !j)
299 waddch (win, border | ACS_LLCORNER);
300 else if (!i && j == width - 1)
301 waddch (win, box | ACS_URCORNER);
302 else if (i == height - 1 && j == width - 1)
303 waddch (win, box | ACS_LRCORNER);
304 else if (!i)
305 waddch (win, border | ACS_HLINE);
306 else if (i == height - 1)
307 waddch (win, box | ACS_HLINE);
308 else if (!j)
309 waddch (win, border | ACS_VLINE);
310 else if (j == width - 1)
311 waddch (win, box | ACS_VLINE);
312 else
313 waddch (win, box | ' ');
314 }
315}
316
317/*
318 * Draw shadows along the right and bottom edge to give a more 3D look
319 * to the boxes
320 */
321void
322draw_shadow (WINDOW * win, int y, int x, int height, int width)
323{
324 int i;
325
326 if (has_colors ()) { /* Whether terminal supports color? */
327 wattrset (win, shadow_attr);
328 wmove (win, y + height, x + 2);
329 for (i = 0; i < width; i++)
330 waddch (win, winch (win) & A_CHARTEXT);
331 for (i = y + 1; i < y + height + 1; i++) {
332 wmove (win, i, x + width);
333 waddch (win, winch (win) & A_CHARTEXT);
334 waddch (win, winch (win) & A_CHARTEXT);
335 }
336 wnoutrefresh (win);
337 }
338}
339
340/*
341 * Return the position of the first alphabetic character in a string.
342 */
343int
344first_alpha(const char *string, const char *exempt)
345{
346 int i, in_paren=0, c;
347
348 for (i = 0; i < strlen(string); i++) {
349 c = tolower(string[i]);
350
351 if (strchr("<[(", c)) ++in_paren;
352 if (strchr(">])", c) && in_paren > 0) --in_paren;
353
354 if ((! in_paren) && isalpha(c) &&
355 strchr(exempt, c) == 0)
356 return i;
357 }
358
359 return 0;
360}
361
362/*
363 * Get the first selected item in the dialog_list_item list.
364 */
365struct dialog_list_item *
366first_sel_item(int item_no, struct dialog_list_item ** items)
367{
368 int i;
369
370 for (i = 0; i < item_no; i++) {
371 if (items[i]->selected)
372 return items[i];
373 }
374
375 return NULL;
376}
diff --git a/scripts/config/lxdialog/yesno.c b/scripts/config/lxdialog/yesno.c
deleted file mode 100644
index 98562d8a9..000000000
--- a/scripts/config/lxdialog/yesno.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * yesno.c -- implements the yes/no box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25/*
26 * Display termination buttons
27 */
28static void
29print_buttons(WINDOW *dialog, int height, int width, int selected)
30{
31 int x = width / 2 - 10;
32 int y = height - 2;
33
34 print_button (dialog, " Yes ", y, x, selected == 0);
35 print_button (dialog, " No ", y, x + 13, selected == 1);
36
37 wmove(dialog, y, x+1 + 13*selected );
38 wrefresh (dialog);
39}
40
41/*
42 * Display a dialog box with two buttons - Yes and No
43 */
44int
45dialog_yesno (const char *title, const char *prompt, int height, int width)
46{
47 int i, x, y, key = 0, button = 0;
48 WINDOW *dialog;
49
50 /* center dialog box on screen */
51 x = (COLS - width) / 2;
52 y = (LINES - height) / 2;
53
54 draw_shadow (stdscr, y, x, height, width);
55
56 dialog = newwin (height, width, y, x);
57 keypad (dialog, TRUE);
58
59 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
60 wattrset (dialog, border_attr);
61 mvwaddch (dialog, height-3, 0, ACS_LTEE);
62 for (i = 0; i < width - 2; i++)
63 waddch (dialog, ACS_HLINE);
64 wattrset (dialog, dialog_attr);
65 waddch (dialog, ACS_RTEE);
66
67 if (title != NULL && strlen(title) >= width-2 ) {
68 /* truncate long title -- mec */
69 char * title2 = malloc(width-2+1);
70 memcpy( title2, title, width-2 );
71 title2[width-2] = '\0';
72 title = title2;
73 }
74
75 if (title != NULL) {
76 wattrset (dialog, title_attr);
77 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
78 waddstr (dialog, (char *)title);
79 waddch (dialog, ' ');
80 }
81
82 wattrset (dialog, dialog_attr);
83 print_autowrap (dialog, prompt, width - 2, 1, 3);
84
85 print_buttons(dialog, height, width, 0);
86
87 while (key != ESC) {
88 key = wgetch (dialog);
89 switch (key) {
90 case 'Y':
91 case 'y':
92 delwin (dialog);
93 return 0;
94 case 'N':
95 case 'n':
96 delwin (dialog);
97 return 1;
98
99 case TAB:
100 case KEY_LEFT:
101 case KEY_RIGHT:
102 button = ((key == KEY_LEFT ? --button : ++button) < 0)
103 ? 1 : (button > 1 ? 0 : button);
104
105 print_buttons(dialog, height, width, button);
106 wrefresh (dialog);
107 break;
108 case ' ':
109 case '\n':
110 delwin (dialog);
111 return button;
112 case ESC:
113 break;
114 }
115 }
116
117 delwin (dialog);
118 return -1; /* ESC pressed */
119}
diff --git a/scripts/config/zconf.tab.h_shipped b/scripts/config/zconf.tab.h_shipped
deleted file mode 100644
index 3b191ef59..000000000
--- a/scripts/config/zconf.tab.h_shipped
+++ /dev/null
@@ -1,125 +0,0 @@
1/* A Bison parser, made from zconf.y, by GNU bison 1.75. */
2
3/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26#ifndef BISON_ZCONF_TAB_H
27# define BISON_ZCONF_TAB_H
28
29/* Tokens. */
30#ifndef YYTOKENTYPE
31# define YYTOKENTYPE
32 /* Put the tokens into the symbol table, so that GDB and other debuggers
33 know about them. */
34 enum yytokentype {
35 T_MAINMENU = 258,
36 T_MENU = 259,
37 T_ENDMENU = 260,
38 T_SOURCE = 261,
39 T_CHOICE = 262,
40 T_ENDCHOICE = 263,
41 T_COMMENT = 264,
42 T_CONFIG = 265,
43 T_HELP = 266,
44 T_HELPTEXT = 267,
45 T_IF = 268,
46 T_ENDIF = 269,
47 T_DEPENDS = 270,
48 T_REQUIRES = 271,
49 T_OPTIONAL = 272,
50 T_PROMPT = 273,
51 T_DEFAULT = 274,
52 T_TRISTATE = 275,
53 T_BOOLEAN = 276,
54 T_INT = 277,
55 T_HEX = 278,
56 T_WORD = 279,
57 T_STRING = 280,
58 T_UNEQUAL = 281,
59 T_EOF = 282,
60 T_EOL = 283,
61 T_CLOSE_PAREN = 284,
62 T_OPEN_PAREN = 285,
63 T_ON = 286,
64 T_OR = 287,
65 T_AND = 288,
66 T_EQUAL = 289,
67 T_NOT = 290
68 };
69#endif
70#define T_MAINMENU 258
71#define T_MENU 259
72#define T_ENDMENU 260
73#define T_SOURCE 261
74#define T_CHOICE 262
75#define T_ENDCHOICE 263
76#define T_COMMENT 264
77#define T_CONFIG 265
78#define T_HELP 266
79#define T_HELPTEXT 267
80#define T_IF 268
81#define T_ENDIF 269
82#define T_DEPENDS 270
83#define T_REQUIRES 271
84#define T_OPTIONAL 272
85#define T_PROMPT 273
86#define T_DEFAULT 274
87#define T_TRISTATE 275
88#define T_BOOLEAN 276
89#define T_INT 277
90#define T_HEX 278
91#define T_WORD 279
92#define T_STRING 280
93#define T_UNEQUAL 281
94#define T_EOF 282
95#define T_EOL 283
96#define T_CLOSE_PAREN 284
97#define T_OPEN_PAREN 285
98#define T_ON 286
99#define T_OR 287
100#define T_AND 288
101#define T_EQUAL 289
102#define T_NOT 290
103
104
105
106
107#ifndef YYSTYPE
108#line 33 "zconf.y"
109typedef union {
110 int token;
111 char *string;
112 struct symbol *symbol;
113 struct expr *expr;
114 struct menu *menu;
115} yystype;
116/* Line 1281 of /usr/share/bison/yacc.c. */
117#line 118 "zconf.tab.h"
118# define YYSTYPE yystype
119#endif
120
121extern YYSTYPE zconflval;
122
123
124#endif /* not BISON_ZCONF_TAB_H */
125
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
new file mode 100644
index 000000000..a28414de8
--- /dev/null
+++ b/scripts/kconfig/Makefile
@@ -0,0 +1,254 @@
1# ===========================================================================
2# Kernel configuration targets
3# These targets are used from top-level makefile
4
5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
6
7xconfig: $(obj)/qconf
8 $< Config.in
9
10gconfig: $(obj)/gconf
11 $< Config.in
12
13menuconfig: $(obj)/mconf
14 $(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog
15 $< Config.in
16
17config: $(obj)/conf
18 $< Config.in
19
20oldconfig: $(obj)/conf
21 $< -o Config.in
22
23silentoldconfig: $(obj)/conf
24 $< -s Config.in
25
26update-po-config: $(obj)/kxgettext
27 xgettext --default-domain=linux \
28 --add-comments --keyword=_ --keyword=N_ \
29 --files-from=scripts/kconfig/POTFILES.in \
30 --output scripts/kconfig/config.pot
31 $(Q)ln -fs Kconfig_i386 arch/um/Kconfig_arch
32 $(Q)for i in `ls arch/`; \
33 do \
34 scripts/kconfig/kxgettext arch/$$i/Kconfig \
35 | msguniq -o scripts/kconfig/linux_$${i}.pot; \
36 done
37 $(Q)msgcat scripts/kconfig/config.pot \
38 `find scripts/kconfig/ -type f -name linux_*.pot` \
39 --output scripts/kconfig/linux_raw.pot
40 $(Q)msguniq --sort-by-file scripts/kconfig/linux_raw.pot \
41 --output scripts/kconfig/linux.pot
42 $(Q)rm -f arch/um/Kconfig_arch
43 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
44
45PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
46
47randconfig: $(obj)/conf
48 $< -r Config.in
49
50allyesconfig: $(obj)/conf
51 $< -y Config.in
52
53allnoconfig: $(obj)/conf
54 $< -n Config.in
55
56allmodconfig: $(obj)/conf
57 $< -m Config.in
58
59defconfig: $(obj)/conf
60ifeq ($(KBUILD_DEFCONFIG),)
61 $< -d Config.in
62else
63 @echo *** Default configuration is based on '$(KBUILD_DEFCONFIG)'
64 $(Q)$< -D $(KBUILD_DEFCONFIG) Config.in
65endif
66
67%_defconfig: $(obj)/conf
68 $(Q)$< -D $@ Config.in
69
70# Help text used by make help
71help:
72 @echo ' config - Update current config utilising a line-oriented program'
73 @echo ' menuconfig - Update current config utilising a menu based program'
74 @echo ' xconfig - Update current config utilising a QT based front-end'
75 @echo ' gconfig - Update current config utilising a GTK based front-end'
76 @echo ' oldconfig - Update current config utilising a provided .config as base'
77 @echo ' randconfig - New config with random answer to all options'
78 @echo ' defconfig - New config with default answer to all options'
79 @echo ' allmodconfig - New config selecting modules when possible'
80 @echo ' allyesconfig - New config where all options are accepted with yes'
81 @echo ' allnoconfig - New config where all options are answered with no'
82
83# ===========================================================================
84# Shared Makefile for the various kconfig executables:
85# conf: Used for defconfig, oldconfig and related targets
86# mconf: Used for the mconfig target.
87# Utilizes the lxdialog package
88# qconf: Used for the xconfig target
89# Based on QT which needs to be installed to compile it
90# gconf: Used for the gconfig target
91# Based on GTK which needs to be installed to compile it
92# object files used by all kconfig flavours
93
94hostprogs-y := conf mconf qconf gconf kxgettext
95conf-objs := conf.o zconf.tab.o
96mconf-objs := mconf.o zconf.tab.o
97kxgettext-objs := kxgettext.o zconf.tab.o
98
99ifeq ($(MAKECMDGOALS),xconfig)
100 qconf-target := 1
101endif
102ifeq ($(MAKECMDGOALS),gconfig)
103 gconf-target := 1
104endif
105
106
107ifeq ($(qconf-target),1)
108qconf-cxxobjs := qconf.o
109qconf-objs := kconfig_load.o zconf.tab.o
110endif
111
112ifeq ($(gconf-target),1)
113gconf-objs := gconf.o kconfig_load.o zconf.tab.o
114endif
115
116clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \
117 .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c
118subdir- += lxdialog
119
120# Needed for systems without gettext
121KBUILD_HAVE_NLS := $(shell \
122 if echo "\#include <libintl.h>" | $(HOSTCC) $(HOSTCFLAGS) -E - > /dev/null 2>&1 ; \
123 then echo yes ; \
124 else echo no ; fi)
125ifeq ($(KBUILD_HAVE_NLS),no)
126HOSTCFLAGS += -DKBUILD_NO_NLS
127endif
128
129# generated files seem to need this to find local include files
130HOSTCFLAGS_lex.zconf.o := -I$(src)
131HOSTCFLAGS_zconf.tab.o := -I$(src)
132
133HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
134HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
135
136HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
137HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
138 -D LKC_DIRECT_LINK
139
140$(obj)/qconf.o: $(obj)/.tmp_qtcheck
141
142ifeq ($(qconf-target),1)
143$(obj)/.tmp_qtcheck: $(src)/Makefile
144-include $(obj)/.tmp_qtcheck
145
146# QT needs some extra effort...
147$(obj)/.tmp_qtcheck:
148 @set -e; echo " CHECK qt"; dir=""; pkg=""; \
149 pkg-config --exists qt 2> /dev/null && pkg=qt; \
150 pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
151 if [ -n "$$pkg" ]; then \
152 cflags="\$$(shell pkg-config $$pkg --cflags)"; \
153 libs="\$$(shell pkg-config $$pkg --libs)"; \
154 moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
155 dir="$$(pkg-config $$pkg --variable=prefix)"; \
156 else \
157 for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
158 if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
159 done; \
160 if [ -z "$$dir" ]; then \
161 echo "*"; \
162 echo "* Unable to find the QT installation. Please make sure that"; \
163 echo "* the QT development package is correctly installed and"; \
164 echo "* either install pkg-config or set the QTDIR environment"; \
165 echo "* variable to the correct location."; \
166 echo "*"; \
167 false; \
168 fi; \
169 libpath=$$dir/lib; lib=qt; osdir=""; \
170 $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
171 osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
172 test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
173 test -f $$libpath/libqt-mt.so && lib=qt-mt; \
174 cflags="-I$$dir/include"; \
175 libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
176 moc="$$dir/bin/moc"; \
177 fi; \
178 if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
179 echo "*"; \
180 echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
181 echo "*"; \
182 moc="/usr/bin/moc"; \
183 fi; \
184 echo "KC_QT_CFLAGS=$$cflags" > $@; \
185 echo "KC_QT_LIBS=$$libs" >> $@; \
186 echo "KC_QT_MOC=$$moc" >> $@
187endif
188
189$(obj)/gconf.o: $(obj)/.tmp_gtkcheck
190
191ifeq ($(gconf-target),1)
192-include $(obj)/.tmp_gtkcheck
193
194# GTK needs some extra effort, too...
195$(obj)/.tmp_gtkcheck:
196 @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
197 if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
198 touch $@; \
199 else \
200 echo "*"; \
201 echo "* GTK+ is present but version >= 2.0.0 is required."; \
202 echo "*"; \
203 false; \
204 fi \
205 else \
206 echo "*"; \
207 echo "* Unable to find the GTK+ installation. Please make sure that"; \
208 echo "* the GTK+ 2.0 development package is correctly installed..."; \
209 echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
210 echo "*"; \
211 false; \
212 fi
213endif
214
215$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
216
217$(obj)/kconfig_load.o: $(obj)/lkc_defs.h
218
219$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
220
221$(obj)/gconf.o: $(obj)/lkc_defs.h
222
223$(obj)/%.moc: $(src)/%.h
224 $(KC_QT_MOC) -i $< -o $@
225
226$(obj)/lkc_defs.h: $(src)/lkc_proto.h
227 sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
228
229
230###
231# The following requires flex/bison/gperf
232# By default we use the _shipped versions, uncomment the following line if
233# you are modifying the flex/bison src.
234# LKC_GENPARSER := 1
235
236ifdef LKC_GENPARSER
237
238$(obj)/zconf.tab.c: $(src)/zconf.y
239$(obj)/lex.zconf.c: $(src)/zconf.l
240$(obj)/zconf.hash.c: $(src)/zconf.gperf
241
242%.tab.c: %.y
243 bison -l -b $* -p $(notdir $*) $<
244 cp $@ $@_shipped
245
246lex.%.c: %.l
247 flex -L -P$(notdir $*) -o$@ $<
248 cp $@ $@_shipped
249
250%.hash.c: %.gperf
251 gperf < $< > $@
252 cp $@ $@_shipped
253
254endif
diff --git a/scripts/kconfig/POTFILES.in b/scripts/kconfig/POTFILES.in
new file mode 100644
index 000000000..cc94e46a7
--- /dev/null
+++ b/scripts/kconfig/POTFILES.in
@@ -0,0 +1,5 @@
1scripts/kconfig/mconf.c
2scripts/kconfig/conf.c
3scripts/kconfig/confdata.c
4scripts/kconfig/gconf.c
5scripts/kconfig/qconf.cc
diff --git a/scripts/config/conf.c b/scripts/kconfig/conf.c
index 2da5ff7a7..8012d1076 100644
--- a/scripts/config/conf.c
+++ b/scripts/kconfig/conf.c
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
@@ -6,6 +5,7 @@
6 5
7#include <ctype.h> 6#include <ctype.h>
8#include <stdlib.h> 7#include <stdlib.h>
8#include <stdio.h>
9#include <string.h> 9#include <string.h>
10#include <unistd.h> 10#include <unistd.h>
11#include <time.h> 11#include <time.h>
@@ -35,7 +35,7 @@ static int conf_cnt;
35static char line[128]; 35static char line[128];
36static struct menu *rootEntry; 36static struct menu *rootEntry;
37 37
38static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; 38static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
39 39
40static void strip(char *str) 40static void strip(char *str)
41{ 41{
@@ -57,9 +57,9 @@ static void strip(char *str)
57static void check_stdin(void) 57static void check_stdin(void)
58{ 58{
59 if (!valid_stdin && input_mode == ask_silent) { 59 if (!valid_stdin && input_mode == ask_silent) {
60 printf("aborted!\n\n"); 60 printf(_("aborted!\n\n"));
61 printf("Console input/output is redirected. "); 61 printf(_("Console input/output is redirected. "));
62 printf("Run 'make oldconfig' to update configuration.\n\n"); 62 printf(_("Run 'make oldconfig' to update configuration.\n\n"));
63 exit(1); 63 exit(1);
64 } 64 }
65} 65}
@@ -83,6 +83,15 @@ static void conf_askvalue(struct symbol *sym, const char *def)
83 } 83 }
84 84
85 switch (input_mode) { 85 switch (input_mode) {
86 case set_no:
87 case set_mod:
88 case set_yes:
89 case set_random:
90 if (sym_has_value(sym)) {
91 printf("%s\n", def);
92 return;
93 }
94 break;
86 case ask_new: 95 case ask_new:
87 case ask_silent: 96 case ask_silent:
88 if (sym_has_value(sym)) { 97 if (sym_has_value(sym)) {
@@ -306,8 +315,7 @@ static int conf_choice(struct menu *menu)
306 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); 315 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
307 def_sym = sym_get_choice_value(sym); 316 def_sym = sym_get_choice_value(sym);
308 cnt = def = 0; 317 cnt = def = 0;
309 line[0] = '0'; 318 line[0] = 0;
310 line[1] = 0;
311 for (child = menu->list; child; child = child->next) { 319 for (child = menu->list; child; child = child->next) {
312 if (!menu_is_visible(child)) 320 if (!menu_is_visible(child))
313 continue; 321 continue;
@@ -468,15 +476,14 @@ static void check_conf(struct menu *menu)
468 return; 476 return;
469 477
470 sym = menu->sym; 478 sym = menu->sym;
471 if (sym) { 479 if (sym && !sym_has_value(sym)) {
472 if (sym_is_changable(sym) && !sym_has_value(sym)) { 480 if (sym_is_changable(sym) ||
481 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
473 if (!conf_cnt++) 482 if (!conf_cnt++)
474 printf("*\n* Restart config...\n*\n"); 483 printf(_("*\n* Restart config...\n*\n"));
475 rootEntry = menu_get_parent_menu(menu); 484 rootEntry = menu_get_parent_menu(menu);
476 conf(rootEntry); 485 conf(rootEntry);
477 } 486 }
478 if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod)
479 return;
480 } 487 }
481 488
482 for (child = menu->list; child; child = child->next) 489 for (child = menu->list; child; child = child->next)
@@ -505,7 +512,7 @@ int main(int ac, char **av)
505 input_mode = set_default; 512 input_mode = set_default;
506 defconfig_file = av[i++]; 513 defconfig_file = av[i++];
507 if (!defconfig_file) { 514 if (!defconfig_file) {
508 printf("%s: No default config file specified\n", 515 printf(_("%s: No default config file specified\n"),
509 av[0]); 516 av[0]);
510 exit(1); 517 exit(1);
511 } 518 }
@@ -525,13 +532,13 @@ int main(int ac, char **av)
525 break; 532 break;
526 case 'h': 533 case 'h':
527 case '?': 534 case '?':
528 printf("%s [-o|-s] config\n", av[0]); 535 fprintf(stderr, "See README for usage info\n");
529 exit(0); 536 exit(0);
530 } 537 }
531 } 538 }
532 name = av[i]; 539 name = av[i];
533 if (!name) { 540 if (!name) {
534 printf("%s: configuration file missing\n", av[0]); 541 printf(_("%s: Kconfig file missing\n"), av[0]);
535 } 542 }
536 conf_parse(name); 543 conf_parse(name);
537 //zconfdump(stdout); 544 //zconfdump(stdout);
@@ -548,18 +555,39 @@ int main(int ac, char **av)
548 break; 555 break;
549 case ask_silent: 556 case ask_silent:
550 if (stat(".config", &tmpstat)) { 557 if (stat(".config", &tmpstat)) {
551 printf("***\n" 558 printf(_("***\n"
552 "*** You have not yet configured BusyBox!\n" 559 "*** You have not yet configured your kernel!\n"
553 "***\n" 560 "***\n"
554 "*** Please run some configurator (e.g. \"make oldconfig\" or\n" 561 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
555 "*** \"make menuconfig\" or \"make config\").\n" 562 "*** \"make menuconfig\" or \"make xconfig\").\n"
556 "***\n"); 563 "***\n"));
557 exit(1); 564 exit(1);
558 } 565 }
559 case ask_all: 566 case ask_all:
560 case ask_new: 567 case ask_new:
561 conf_read(NULL); 568 conf_read(NULL);
562 break; 569 break;
570 case set_no:
571 case set_mod:
572 case set_yes:
573 case set_random:
574 name = getenv("KCONFIG_ALLCONFIG");
575 if (name && !stat(name, &tmpstat)) {
576 conf_read_simple(name);
577 break;
578 }
579 switch (input_mode) {
580 case set_no: name = "allno.config"; break;
581 case set_mod: name = "allmod.config"; break;
582 case set_yes: name = "allyes.config"; break;
583 case set_random: name = "allrandom.config"; break;
584 default: break;
585 }
586 if (!stat(name, &tmpstat))
587 conf_read_simple(name);
588 else if (!stat("all.config", &tmpstat))
589 conf_read_simple("all.config");
590 break;
563 default: 591 default:
564 break; 592 break;
565 } 593 }
@@ -577,7 +605,7 @@ int main(int ac, char **av)
577 check_conf(&rootmenu); 605 check_conf(&rootmenu);
578 } while (conf_cnt); 606 } while (conf_cnt);
579 if (conf_write(NULL)) { 607 if (conf_write(NULL)) {
580 fprintf(stderr, "\n*** Error during writing of the BusyBox configuration.\n\n"); 608 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
581 return 1; 609 return 1;
582 } 610 }
583 return 0; 611 return 0;
diff --git a/scripts/config/confdata.c b/scripts/kconfig/confdata.c
index db3fdcd56..301774f0c 100644
--- a/scripts/config/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
@@ -9,21 +8,42 @@
9#include <stdio.h> 8#include <stdio.h>
10#include <stdlib.h> 9#include <stdlib.h>
11#include <string.h> 10#include <string.h>
11#include <time.h>
12#include <unistd.h> 12#include <unistd.h>
13 13
14#define LKC_DIRECT_LINK 14#define LKC_DIRECT_LINK
15#include "lkc.h" 15#include "lkc.h"
16 16
17static void conf_warning(const char *fmt, ...)
18 __attribute__ ((format (printf, 1, 2)));
19
20static const char *conf_filename;
21static int conf_lineno, conf_warnings, conf_unsaved;
22
17const char conf_def_filename[] = ".config"; 23const char conf_def_filename[] = ".config";
18 24
19const char conf_defname[] = "defconfig"; 25const char conf_defname[] = "arch/$ARCH/defconfig";
20 26
21const char *conf_confnames[] = { 27const char *conf_confnames[] = {
22 ".config", 28 ".config",
29 "/lib/modules/$UNAME_RELEASE/.config",
30 "/etc/kernel-config",
31 "/boot/config-$UNAME_RELEASE",
23 conf_defname, 32 conf_defname,
24 NULL, 33 NULL,
25}; 34};
26 35
36static void conf_warning(const char *fmt, ...)
37{
38 va_list ap;
39 va_start(ap, fmt);
40 fprintf(stderr, "%s:%d:warning: ", conf_filename, conf_lineno);
41 vfprintf(stderr, fmt, ap);
42 fprintf(stderr, "\n");
43 va_end(ap);
44 conf_warnings++;
45}
46
27static char *conf_expand_value(const char *in) 47static char *conf_expand_value(const char *in)
28{ 48{
29 struct symbol *sym; 49 struct symbol *sym;
@@ -66,15 +86,12 @@ char *conf_get_default_confname(void)
66 return name; 86 return name;
67} 87}
68 88
69int conf_read(const char *name) 89int conf_read_simple(const char *name)
70{ 90{
71 FILE *in = NULL; 91 FILE *in = NULL;
72 char line[1024]; 92 char line[1024];
73 char *p, *p2; 93 char *p, *p2;
74 int lineno = 0;
75 struct symbol *sym; 94 struct symbol *sym;
76 struct property *prop;
77 struct expr *e;
78 int i; 95 int i;
79 96
80 if (name) { 97 if (name) {
@@ -85,25 +102,32 @@ int conf_read(const char *name)
85 name = conf_expand_value(name); 102 name = conf_expand_value(name);
86 in = zconf_fopen(name); 103 in = zconf_fopen(name);
87 if (in) { 104 if (in) {
88 printf("#\n" 105 printf(_("#\n"
89 "# using defaults found in %s\n" 106 "# using defaults found in %s\n"
90 "#\n", name); 107 "#\n"), name);
91 break; 108 break;
92 } 109 }
93 } 110 }
94 } 111 }
95
96 if (!in) 112 if (!in)
97 return 1; 113 return 1;
98 114
115 conf_filename = name;
116 conf_lineno = 0;
117 conf_warnings = 0;
118 conf_unsaved = 0;
119
99 for_all_symbols(i, sym) { 120 for_all_symbols(i, sym) {
100 sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; 121 sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
122 if (sym_is_choice(sym))
123 sym->flags &= ~SYMBOL_NEW;
101 sym->flags &= ~SYMBOL_VALID; 124 sym->flags &= ~SYMBOL_VALID;
102 switch (sym->type) { 125 switch (sym->type) {
103 case S_INT: 126 case S_INT:
104 case S_HEX: 127 case S_HEX:
105 case S_STRING: 128 case S_STRING:
106 free(sym->user.val); 129 if (sym->user.val)
130 free(sym->user.val);
107 default: 131 default:
108 sym->user.val = NULL; 132 sym->user.val = NULL;
109 sym->user.tri = no; 133 sym->user.tri = no;
@@ -111,21 +135,24 @@ int conf_read(const char *name)
111 } 135 }
112 136
113 while (fgets(line, sizeof(line), in)) { 137 while (fgets(line, sizeof(line), in)) {
114 lineno++; 138 conf_lineno++;
115 sym = NULL; 139 sym = NULL;
116 switch (line[0]) { 140 switch (line[0]) {
117 case '#': 141 case '#':
118 if (line[1]!=' ') 142 if (memcmp(line + 2, "CONFIG_", 7))
119 continue; 143 continue;
120 p = strchr(line + 2, ' '); 144 p = strchr(line + 9, ' ');
121 if (!p) 145 if (!p)
122 continue; 146 continue;
123 *p++ = 0; 147 *p++ = 0;
124 if (strncmp(p, "is not set", 10)) 148 if (strncmp(p, "is not set", 10))
125 continue; 149 continue;
126 sym = sym_find(line + 2); 150 sym = sym_find(line + 9);
127 if (!sym) { 151 if (!sym) {
128 fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 2); 152 conf_warning("trying to assign nonexistent symbol %s", line + 9);
153 break;
154 } else if (!(sym->flags & SYMBOL_NEW)) {
155 conf_warning("trying to reassign symbol %s", sym->name);
129 break; 156 break;
130 } 157 }
131 switch (sym->type) { 158 switch (sym->type) {
@@ -138,18 +165,24 @@ int conf_read(const char *name)
138 ; 165 ;
139 } 166 }
140 break; 167 break;
141 168 case 'C':
142 case 'A' ... 'Z': 169 if (memcmp(line, "CONFIG_", 7)) {
143 p = strchr(line, '='); 170 conf_warning("unexpected data");
171 continue;
172 }
173 p = strchr(line + 7, '=');
144 if (!p) 174 if (!p)
145 continue; 175 continue;
146 *p++ = 0; 176 *p++ = 0;
147 p2 = strchr(p, '\n'); 177 p2 = strchr(p, '\n');
148 if (p2) 178 if (p2)
149 *p2 = 0; 179 *p2 = 0;
150 sym = sym_find(line); 180 sym = sym_find(line + 7);
151 if (!sym) { 181 if (!sym) {
152 fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line); 182 conf_warning("trying to assign nonexistent symbol %s", line + 7);
183 break;
184 } else if (!(sym->flags & SYMBOL_NEW)) {
185 conf_warning("trying to reassign symbol %s", sym->name);
153 break; 186 break;
154 } 187 }
155 switch (sym->type) { 188 switch (sym->type) {
@@ -170,6 +203,7 @@ int conf_read(const char *name)
170 sym->flags &= ~SYMBOL_NEW; 203 sym->flags &= ~SYMBOL_NEW;
171 break; 204 break;
172 } 205 }
206 conf_warning("symbol value '%s' invalid for %s", p, sym->name);
173 break; 207 break;
174 case S_STRING: 208 case S_STRING:
175 if (*p++ != '"') 209 if (*p++ != '"')
@@ -182,8 +216,8 @@ int conf_read(const char *name)
182 memmove(p2, p2 + 1, strlen(p2)); 216 memmove(p2, p2 + 1, strlen(p2));
183 } 217 }
184 if (!p2) { 218 if (!p2) {
185 fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); 219 conf_warning("invalid string found");
186 exit(1); 220 continue;
187 } 221 }
188 case S_INT: 222 case S_INT:
189 case S_HEX: 223 case S_HEX:
@@ -191,8 +225,8 @@ int conf_read(const char *name)
191 sym->user.val = strdup(p); 225 sym->user.val = strdup(p);
192 sym->flags &= ~SYMBOL_NEW; 226 sym->flags &= ~SYMBOL_NEW;
193 } else { 227 } else {
194 fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); 228 conf_warning("symbol value '%s' invalid for %s", p, sym->name);
195 exit(1); 229 continue;
196 } 230 }
197 break; 231 break;
198 default: 232 default:
@@ -202,6 +236,7 @@ int conf_read(const char *name)
202 case '\n': 236 case '\n':
203 break; 237 break;
204 default: 238 default:
239 conf_warning("unexpected data");
205 continue; 240 continue;
206 } 241 }
207 if (sym && sym_is_choice_value(sym)) { 242 if (sym && sym_is_choice_value(sym)) {
@@ -210,25 +245,63 @@ int conf_read(const char *name)
210 case no: 245 case no:
211 break; 246 break;
212 case mod: 247 case mod:
213 if (cs->user.tri == yes) 248 if (cs->user.tri == yes) {
214 /* warn? */; 249 conf_warning("%s creates inconsistent choice state", sym->name);
250 cs->flags |= SYMBOL_NEW;
251 }
215 break; 252 break;
216 case yes: 253 case yes:
217 if (cs->user.tri != no) 254 if (cs->user.tri != no) {
218 /* warn? */; 255 conf_warning("%s creates inconsistent choice state", sym->name);
219 cs->user.val = sym; 256 cs->flags |= SYMBOL_NEW;
257 } else
258 cs->user.val = sym;
220 break; 259 break;
221 } 260 }
222 cs->user.tri = E_OR(cs->user.tri, sym->user.tri); 261 cs->user.tri = E_OR(cs->user.tri, sym->user.tri);
223 cs->flags &= ~SYMBOL_NEW;
224 } 262 }
225 } 263 }
226 fclose(in); 264 fclose(in);
227 265
228 if (modules_sym) 266 if (modules_sym)
229 sym_calc_value(modules_sym); 267 sym_calc_value(modules_sym);
268 return 0;
269}
270
271int conf_read(const char *name)
272{
273 struct symbol *sym;
274 struct property *prop;
275 struct expr *e;
276 int i;
277
278 if (conf_read_simple(name))
279 return 1;
280
230 for_all_symbols(i, sym) { 281 for_all_symbols(i, sym) {
231 sym_calc_value(sym); 282 sym_calc_value(sym);
283 if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))
284 goto sym_ok;
285 if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
286 /* check that calculated value agrees with saved value */
287 switch (sym->type) {
288 case S_BOOLEAN:
289 case S_TRISTATE:
290 if (sym->user.tri != sym_get_tristate_value(sym))
291 break;
292 if (!sym_is_choice(sym))
293 goto sym_ok;
294 default:
295 if (!strcmp(sym->curr.val, sym->user.val))
296 goto sym_ok;
297 break;
298 }
299 } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
300 /* no previous value and not saved */
301 goto sym_ok;
302 conf_unsaved++;
303 /* maybe print value in verbose mode... */
304 sym_ok:
232 if (sym_has_value(sym) && !sym_is_choice_value(sym)) { 305 if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
233 if (sym->visible == no) 306 if (sym->visible == no)
234 sym->flags |= SYMBOL_NEW; 307 sym->flags |= SYMBOL_NEW;
@@ -236,8 +309,10 @@ int conf_read(const char *name)
236 case S_STRING: 309 case S_STRING:
237 case S_INT: 310 case S_INT:
238 case S_HEX: 311 case S_HEX:
239 if (!sym_string_within_range(sym, sym->user.val)) 312 if (!sym_string_within_range(sym, sym->user.val)) {
240 sym->flags |= SYMBOL_NEW; 313 sym->flags |= SYMBOL_NEW;
314 sym->flags &= ~SYMBOL_VALID;
315 }
241 default: 316 default:
242 break; 317 break;
243 } 318 }
@@ -250,26 +325,11 @@ int conf_read(const char *name)
250 sym->flags |= e->right.sym->flags & SYMBOL_NEW; 325 sym->flags |= e->right.sym->flags & SYMBOL_NEW;
251 } 326 }
252 327
253 sym_change_count = 1; 328 sym_change_count = conf_warnings || conf_unsaved;
254 329
255 return 0; 330 return 0;
256} 331}
257 332
258struct menu *next_menu(struct menu *menu)
259{
260 if (menu->list) return menu->list;
261 do {
262 if (menu->next) {
263 menu = menu->next;
264 break;
265 }
266 } while ((menu = menu->parent));
267
268 return menu;
269}
270
271#define SYMBOL_FORCEWRITE (1<<31)
272
273int conf_write(const char *name) 333int conf_write(const char *name)
274{ 334{
275 FILE *out, *out_h; 335 FILE *out, *out_h;
@@ -279,10 +339,9 @@ int conf_write(const char *name)
279 char dirname[128], tmpname[128], newname[128]; 339 char dirname[128], tmpname[128], newname[128];
280 int type, l; 340 int type, l;
281 const char *str; 341 const char *str;
282 342 time_t now;
283 /* busybox`s code */ 343 int use_timestamp = 1;
284 const char *opt_name; 344 char *env;
285 int use_flg;
286 345
287 dirname[0] = 0; 346 dirname[0] = 0;
288 if (name && name[0]) { 347 if (name && name[0]) {
@@ -315,38 +374,42 @@ int conf_write(const char *name)
315 out_h = fopen(".tmpconfig.h", "w"); 374 out_h = fopen(".tmpconfig.h", "w");
316 if (!out_h) 375 if (!out_h)
317 return 1; 376 return 1;
377 file_write_dep(NULL);
318 } 378 }
319 fprintf(out, "#\n" 379 sym = sym_lookup("KERNELVERSION", 0);
320 "# Automatically generated make config: don't edit\n" 380 sym_calc_value(sym);
321 "#\n"); 381 time(&now);
322 382 env = getenv("KCONFIG_NOTIMESTAMP");
323 /* busybox`s code */ 383 if (env && *env)
384 use_timestamp = 0;
385
386 fprintf(out, _("#\n"
387 "# Automatically generated make config: don't edit\n"
388 "# Linux kernel version: %s\n"
389 "%s%s"
390 "#\n"),
391 sym_get_string_value(sym),
392 use_timestamp ? "# " : "",
393 use_timestamp ? ctime(&now) : "");
324 if (out_h) { 394 if (out_h) {
325 fprintf(out_h, "#ifndef BB_CONFIG_H\n#define BB_CONFIG_H\n"); 395 char buf[sizeof("#define AUTOCONF_TIMESTAMP "
396 "\"YYYY-MM-DD HH:MM:SS some_timezone\"\n")];
397 buf[0] = '\0';
398 if (use_timestamp)
399 strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP "
400 "\"%Y-%m-%d %H:%M:%S %Z\"\n", localtime(&now));
326 fprintf(out_h, "/*\n" 401 fprintf(out_h, "/*\n"
327 " * Automatically generated header file: don't edit\n" 402 " * Automatically generated C config: don't edit\n"
328 " */\n\n" 403 " * Linux kernel version: %s\n"
329 "/* Version Number */\n" 404 " */\n"
330 "#define BB_VER \"%s\"\n" 405 "%s"
331 "#define BB_BT \"%s\"\n", 406 "#define AUTOCONF_INCLUDED\n",
332 getenv("VERSION"), 407 sym_get_string_value(sym),
333 getenv("BUILDTIME")); 408 buf);
334 if (getenv("EXTRA_VERSION"))
335 fprintf(out_h, "#define BB_EXTRA_VERSION \"%s\"\n",
336 getenv("EXTRA_VERSION"));
337 fprintf(out_h, "\n");
338 } 409 }
339 /* end busybox`s code */
340
341 if (!sym_change_count) 410 if (!sym_change_count)
342 sym_clear_all_valid(); 411 sym_clear_all_valid();
343 412
344 /* Force write of all non-duplicate symbols. */
345
346 /* Write out everything by default. */
347 for(menu = rootmenu.list; menu; menu = next_menu(menu))
348 if (menu->sym) menu->sym->flags |= SYMBOL_FORCEWRITE;
349
350 menu = rootmenu.list; 413 menu = rootmenu.list;
351 while (menu) { 414 while (menu) {
352 sym = menu->sym; 415 sym = menu->sym;
@@ -365,56 +428,52 @@ int conf_write(const char *name)
365 " */\n", str); 428 " */\n", str);
366 } else if (!(sym->flags & SYMBOL_CHOICE)) { 429 } else if (!(sym->flags & SYMBOL_CHOICE)) {
367 sym_calc_value(sym); 430 sym_calc_value(sym);
368 if (!(sym->flags & SYMBOL_FORCEWRITE)) 431 if (!(sym->flags & SYMBOL_WRITE))
369 goto next; 432 goto next;
370 433 sym->flags &= ~SYMBOL_WRITE;
371 sym->flags &= ~SYMBOL_FORCEWRITE;
372 type = sym->type; 434 type = sym->type;
373 if (type == S_TRISTATE) { 435 if (type == S_TRISTATE) {
374 sym_calc_value(modules_sym); 436 sym_calc_value(modules_sym);
375 if (modules_sym->curr.tri == no) 437 if (modules_sym->curr.tri == no)
376 type = S_BOOLEAN; 438 type = S_BOOLEAN;
377 } 439 }
378
379 /* busybox`s code */
380 opt_name = strchr(sym->name, '_');
381 if(opt_name == NULL)
382 opt_name = sym->name;
383 else
384 opt_name++;
385 use_flg = 1;
386 /* end busybox`s code */
387
388 switch (type) { 440 switch (type) {
389 case S_BOOLEAN: 441 case S_BOOLEAN:
390 case S_TRISTATE: 442 case S_TRISTATE:
391 switch (sym_get_tristate_value(sym)) { 443 switch (sym_get_tristate_value(sym)) {
392 case no: 444 case no:
393 fprintf(out, "# %s is not set\n", sym->name); 445 fprintf(out, "# CONFIG_%s is not set\n", sym->name);
394 if (out_h) 446 if (out_h) {
395 fprintf(out_h, "#undef %s\n", sym->name); 447 fprintf(out_h, "#undef CONFIG_%s\n", sym->name);
396 use_flg = 0; /* busybox`s code */ 448 /* bbox */
449 fprintf(out_h, "#define ENABLE_%s 0\n", sym->name);
450 fprintf(out_h, "#define USE_%s(...)\n", sym->name);
451 fprintf(out_h, "#define SKIP_%s(...) __VA_ARGS__\n", sym->name);
452 }
397 break; 453 break;
398 case mod: 454 case mod:
399#if 0 /* busybox`s code */ 455 fprintf(out, "CONFIG_%s=m\n", sym->name);
400 fprintf(out, "%s=m\n", sym->name);
401 if (out_h) 456 if (out_h)
402 fprintf(out_h, "#define %s_MODULE 1\n", sym->name); 457 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
403#endif /* busybox`s code */
404 break; 458 break;
405 case yes: 459 case yes:
406 fprintf(out, "%s=y\n", sym->name); 460 fprintf(out, "CONFIG_%s=y\n", sym->name);
407 if (out_h) 461 if (out_h) {
408 fprintf(out_h, "#define %s 1\n", sym->name); 462 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name);
463 /* bbox */
464 fprintf(out_h, "#define ENABLE_%s 1\n", sym->name);
465 fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", sym->name);
466 fprintf(out_h, "#define SKIP_%s(...)\n", sym->name);
467 }
409 break; 468 break;
410 } 469 }
411 break; 470 break;
412 case S_STRING: 471 case S_STRING:
413 // fix me 472 // fix me
414 str = sym_get_string_value(sym); 473 str = sym_get_string_value(sym);
415 fprintf(out, "%s=\"", sym->name); 474 fprintf(out, "CONFIG_%s=\"", sym->name);
416 if (out_h) 475 if (out_h)
417 fprintf(out_h, "#define %s \"", sym->name); 476 fprintf(out_h, "#define CONFIG_%s \"", sym->name);
418 do { 477 do {
419 l = strcspn(str, "\"\\"); 478 l = strcspn(str, "\"\\");
420 if (l) { 479 if (l) {
@@ -431,43 +490,59 @@ int conf_write(const char *name)
431 } 490 }
432 } while (*str); 491 } while (*str);
433 fputs("\"\n", out); 492 fputs("\"\n", out);
434 if (out_h) 493 if (out_h) {
435 fputs("\"\n", out_h); 494 fputs("\"\n", out_h);
495 /* bbox */
496 fprintf(out_h, "#define ENABLE_%s 1\n", sym->name);
497 fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", sym->name);
498 fprintf(out_h, "#define SKIP_%s(...)\n", sym->name);
499 }
436 break; 500 break;
437 case S_HEX: 501 case S_HEX:
438 str = sym_get_string_value(sym); 502 str = sym_get_string_value(sym);
439 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { 503 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
440 fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); 504 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
441 if (out_h) 505 if (out_h) {
442 fprintf(out_h, "#define %s 0x%s\n", sym->name, str); 506 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str);
507 /* bbox */
508 fprintf(out_h, "#define ENABLE_%s 1\n", sym->name);
509 fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", sym->name);
510 fprintf(out_h, "#define SKIP_%s(...)\n", sym->name);
511 }
443 break; 512 break;
444 } 513 }
445 case S_INT: 514 case S_INT:
446 str = sym_get_string_value(sym); 515 str = sym_get_string_value(sym);
447 fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); 516 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
448 if (out_h) 517 if (out_h) {
449 fprintf(out_h, "#define %s %s\n", sym->name, str); 518 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str);
519 /* bbox */
520 fprintf(out_h, "#define ENABLE_%s 1\n", sym->name);
521 fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", sym->name);
522 fprintf(out_h, "#define SKIP_%s(...)\n", sym->name);
523 }
450 break; 524 break;
451 } 525 }
452 /* busybox`s code */ 526 }
453 if (out_h) { 527
454 fprintf(out_h, "#define ENABLE_%s %d\n", opt_name, use_flg); 528 next:
455 fprintf(out_h, "#define USE_%s(...)%s\n", opt_name, 529 if (menu->list) {
456 (use_flg ? " __VA_ARGS__" : "")); 530 menu = menu->list;
457 fprintf(out_h, "#define SKIP_%s(...)%s\n\n", opt_name, 531 continue;
458 (use_flg ? "" : " __VA_ARGS__")); 532 }
533 if (menu->next)
534 menu = menu->next;
535 else while ((menu = menu->parent)) {
536 if (menu->next) {
537 menu = menu->next;
538 break;
459 } 539 }
460 /* end busybox`s code */
461 } 540 }
462next:
463 menu = next_menu(menu);
464 } 541 }
465 fclose(out); 542 fclose(out);
466 if (out_h) { 543 if (out_h) {
467 fprintf(out_h, "#endif /* BB_CONFIG_H */\n"); /* busybox`s code */
468 fclose(out_h); 544 fclose(out_h);
469 rename(".tmpconfig.h", "include/bb_config.h"); /* busybox`s config name */ 545 rename(".tmpconfig.h", "include/autoconf.h");
470 file_write_dep(NULL);
471 } 546 }
472 if (!name || basename != conf_def_filename) { 547 if (!name || basename != conf_def_filename) {
473 if (!name) 548 if (!name)
diff --git a/scripts/config/expr.c b/scripts/kconfig/expr.c
index 125573e77..30e4f9d69 100644
--- a/scripts/config/expr.c
+++ b/scripts/kconfig/expr.c
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
@@ -825,7 +824,7 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
825 default: 824 default:
826 ; 825 ;
827 } 826 }
828 return false; 827 return false;
829} 828}
830 829
831struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) 830struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2)
diff --git a/scripts/config/expr.h b/scripts/kconfig/expr.h
index de7332f64..1b36ef18c 100644
--- a/scripts/config/expr.h
+++ b/scripts/kconfig/expr.h
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
@@ -94,7 +93,6 @@ struct symbol {
94#define SYMBOL_NEW 0x0800 93#define SYMBOL_NEW 0x0800
95#define SYMBOL_AUTO 0x1000 94#define SYMBOL_AUTO 0x1000
96#define SYMBOL_CHECKED 0x2000 95#define SYMBOL_CHECKED 0x2000
97#define SYMBOL_CHECK_DONE 0x4000
98#define SYMBOL_WARNED 0x8000 96#define SYMBOL_WARNED 0x8000
99 97
100#define SYMBOL_MAXLENGTH 256 98#define SYMBOL_MAXLENGTH 256
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
new file mode 100644
index 000000000..665bd5300
--- /dev/null
+++ b/scripts/kconfig/gconf.c
@@ -0,0 +1,1645 @@
1/* Hey EMACS -*- linux-c -*- */
2/*
3 *
4 * Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
5 * Released under the terms of the GNU GPL v2.0.
6 *
7 */
8
9#ifdef HAVE_CONFIG_H
10# include <config.h>
11#endif
12
13#include "lkc.h"
14#include "images.c"
15
16#include <glade/glade.h>
17#include <gtk/gtk.h>
18#include <glib.h>
19#include <gdk/gdkkeysyms.h>
20
21#include <stdio.h>
22#include <string.h>
23#include <unistd.h>
24#include <time.h>
25#include <stdlib.h>
26
27//#define DEBUG
28
29enum {
30 SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
31};
32
33static gint view_mode = FULL_VIEW;
34static gboolean show_name = TRUE;
35static gboolean show_range = TRUE;
36static gboolean show_value = TRUE;
37static gboolean show_all = FALSE;
38static gboolean show_debug = FALSE;
39static gboolean resizeable = FALSE;
40
41static gboolean config_changed = FALSE;
42
43static char nohelp_text[] =
44 N_("Sorry, no help available for this option yet.\n");
45
46GtkWidget *main_wnd = NULL;
47GtkWidget *tree1_w = NULL; // left frame
48GtkWidget *tree2_w = NULL; // right frame
49GtkWidget *text_w = NULL;
50GtkWidget *hpaned = NULL;
51GtkWidget *vpaned = NULL;
52GtkWidget *back_btn = NULL;
53
54GtkTextTag *tag1, *tag2;
55GdkColor color;
56
57GtkTreeStore *tree1, *tree2, *tree;
58GtkTreeModel *model1, *model2;
59static GtkTreeIter *parents[256];
60static gint indent;
61
62static struct menu *current; // current node for SINGLE view
63static struct menu *browsed; // browsed node for SPLIT view
64
65enum {
66 COL_OPTION, COL_NAME, COL_NO, COL_MOD, COL_YES, COL_VALUE,
67 COL_MENU, COL_COLOR, COL_EDIT, COL_PIXBUF,
68 COL_PIXVIS, COL_BTNVIS, COL_BTNACT, COL_BTNINC, COL_BTNRAD,
69 COL_NUMBER
70};
71
72static void display_list(void);
73static void display_tree(struct menu *menu);
74static void display_tree_part(void);
75static void update_tree(struct menu *src, GtkTreeIter * dst);
76static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row);
77static gchar **fill_row(struct menu *menu);
78
79
80/* Helping/Debugging Functions */
81
82
83const char *dbg_print_stype(int val)
84{
85 static char buf[256];
86
87 bzero(buf, 256);
88
89 if (val == S_UNKNOWN)
90 strcpy(buf, "unknown");
91 if (val == S_BOOLEAN)
92 strcpy(buf, "boolean");
93 if (val == S_TRISTATE)
94 strcpy(buf, "tristate");
95 if (val == S_INT)
96 strcpy(buf, "int");
97 if (val == S_HEX)
98 strcpy(buf, "hex");
99 if (val == S_STRING)
100 strcpy(buf, "string");
101 if (val == S_OTHER)
102 strcpy(buf, "other");
103
104#ifdef DEBUG
105 printf("%s", buf);
106#endif
107
108 return buf;
109}
110
111const char *dbg_print_flags(int val)
112{
113 static char buf[256];
114
115 bzero(buf, 256);
116
117 if (val & SYMBOL_YES)
118 strcat(buf, "yes/");
119 if (val & SYMBOL_MOD)
120 strcat(buf, "mod/");
121 if (val & SYMBOL_NO)
122 strcat(buf, "no/");
123 if (val & SYMBOL_CONST)
124 strcat(buf, "const/");
125 if (val & SYMBOL_CHECK)
126 strcat(buf, "check/");
127 if (val & SYMBOL_CHOICE)
128 strcat(buf, "choice/");
129 if (val & SYMBOL_CHOICEVAL)
130 strcat(buf, "choiceval/");
131 if (val & SYMBOL_PRINTED)
132 strcat(buf, "printed/");
133 if (val & SYMBOL_VALID)
134 strcat(buf, "valid/");
135 if (val & SYMBOL_OPTIONAL)
136 strcat(buf, "optional/");
137 if (val & SYMBOL_WRITE)
138 strcat(buf, "write/");
139 if (val & SYMBOL_CHANGED)
140 strcat(buf, "changed/");
141 if (val & SYMBOL_NEW)
142 strcat(buf, "new/");
143 if (val & SYMBOL_AUTO)
144 strcat(buf, "auto/");
145
146 buf[strlen(buf) - 1] = '\0';
147#ifdef DEBUG
148 printf("%s", buf);
149#endif
150
151 return buf;
152}
153
154const char *dbg_print_ptype(int val)
155{
156 static char buf[256];
157
158 bzero(buf, 256);
159
160 if (val == P_UNKNOWN)
161 strcpy(buf, "unknown");
162 if (val == P_PROMPT)
163 strcpy(buf, "prompt");
164 if (val == P_COMMENT)
165 strcpy(buf, "comment");
166 if (val == P_MENU)
167 strcpy(buf, "menu");
168 if (val == P_DEFAULT)
169 strcpy(buf, "default");
170 if (val == P_CHOICE)
171 strcpy(buf, "choice");
172
173#ifdef DEBUG
174 printf("%s", buf);
175#endif
176
177 return buf;
178}
179
180
181void replace_button_icon(GladeXML * xml, GdkDrawable * window,
182 GtkStyle * style, gchar * btn_name, gchar ** xpm)
183{
184 GdkPixmap *pixmap;
185 GdkBitmap *mask;
186 GtkToolButton *button;
187 GtkWidget *image;
188
189 pixmap = gdk_pixmap_create_from_xpm_d(window, &mask,
190 &style->bg[GTK_STATE_NORMAL],
191 xpm);
192
193 button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name));
194 image = gtk_image_new_from_pixmap(pixmap, mask);
195 gtk_widget_show(image);
196 gtk_tool_button_set_icon_widget(button, image);
197}
198
199/* Main Window Initialization */
200void init_main_window(const gchar * glade_file)
201{
202 GladeXML *xml;
203 GtkWidget *widget;
204 GtkTextBuffer *txtbuf;
205 char title[256];
206 GtkStyle *style;
207
208 xml = glade_xml_new(glade_file, "window1", NULL);
209 if (!xml)
210 g_error(_("GUI loading failed !\n"));
211 glade_xml_signal_autoconnect(xml);
212
213 main_wnd = glade_xml_get_widget(xml, "window1");
214 hpaned = glade_xml_get_widget(xml, "hpaned1");
215 vpaned = glade_xml_get_widget(xml, "vpaned1");
216 tree1_w = glade_xml_get_widget(xml, "treeview1");
217 tree2_w = glade_xml_get_widget(xml, "treeview2");
218 text_w = glade_xml_get_widget(xml, "textview3");
219
220 back_btn = glade_xml_get_widget(xml, "button1");
221 gtk_widget_set_sensitive(back_btn, FALSE);
222
223 widget = glade_xml_get_widget(xml, "show_name1");
224 gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
225 show_name);
226
227 widget = glade_xml_get_widget(xml, "show_range1");
228 gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
229 show_range);
230
231 widget = glade_xml_get_widget(xml, "show_data1");
232 gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
233 show_value);
234
235 style = gtk_widget_get_style(main_wnd);
236 widget = glade_xml_get_widget(xml, "toolbar1");
237
238#if 0 /* Use stock Gtk icons instead */
239 replace_button_icon(xml, main_wnd->window, style,
240 "button1", (gchar **) xpm_back);
241 replace_button_icon(xml, main_wnd->window, style,
242 "button2", (gchar **) xpm_load);
243 replace_button_icon(xml, main_wnd->window, style,
244 "button3", (gchar **) xpm_save);
245#endif
246 replace_button_icon(xml, main_wnd->window, style,
247 "button4", (gchar **) xpm_single_view);
248 replace_button_icon(xml, main_wnd->window, style,
249 "button5", (gchar **) xpm_split_view);
250 replace_button_icon(xml, main_wnd->window, style,
251 "button6", (gchar **) xpm_tree_view);
252
253#if 0
254 switch (view_mode) {
255 case SINGLE_VIEW:
256 widget = glade_xml_get_widget(xml, "button4");
257 g_signal_emit_by_name(widget, "clicked");
258 break;
259 case SPLIT_VIEW:
260 widget = glade_xml_get_widget(xml, "button5");
261 g_signal_emit_by_name(widget, "clicked");
262 break;
263 case FULL_VIEW:
264 widget = glade_xml_get_widget(xml, "button6");
265 g_signal_emit_by_name(widget, "clicked");
266 break;
267 }
268#endif
269 txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
270 tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
271 "foreground", "red",
272 "weight", PANGO_WEIGHT_BOLD,
273 NULL);
274 tag2 = gtk_text_buffer_create_tag(txtbuf, "mytag2",
275 /*"style", PANGO_STYLE_OBLIQUE, */
276 NULL);
277
278 sprintf(title, _("Linux Kernel v%s Configuration"),
279 getenv("KERNELVERSION"));
280 gtk_window_set_title(GTK_WINDOW(main_wnd), title);
281
282 gtk_widget_show(main_wnd);
283}
284
285void init_tree_model(void)
286{
287 gint i;
288
289 tree = tree2 = gtk_tree_store_new(COL_NUMBER,
290 G_TYPE_STRING, G_TYPE_STRING,
291 G_TYPE_STRING, G_TYPE_STRING,
292 G_TYPE_STRING, G_TYPE_STRING,
293 G_TYPE_POINTER, GDK_TYPE_COLOR,
294 G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
295 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
296 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
297 G_TYPE_BOOLEAN);
298 model2 = GTK_TREE_MODEL(tree2);
299
300 for (parents[0] = NULL, i = 1; i < 256; i++)
301 parents[i] = (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter));
302
303 tree1 = gtk_tree_store_new(COL_NUMBER,
304 G_TYPE_STRING, G_TYPE_STRING,
305 G_TYPE_STRING, G_TYPE_STRING,
306 G_TYPE_STRING, G_TYPE_STRING,
307 G_TYPE_POINTER, GDK_TYPE_COLOR,
308 G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
309 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
310 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
311 G_TYPE_BOOLEAN);
312 model1 = GTK_TREE_MODEL(tree1);
313}
314
315void init_left_tree(void)
316{
317 GtkTreeView *view = GTK_TREE_VIEW(tree1_w);
318 GtkCellRenderer *renderer;
319 GtkTreeSelection *sel;
320 GtkTreeViewColumn *column;
321
322 gtk_tree_view_set_model(view, model1);
323 gtk_tree_view_set_headers_visible(view, TRUE);
324 gtk_tree_view_set_rules_hint(view, FALSE);
325
326 column = gtk_tree_view_column_new();
327 gtk_tree_view_append_column(view, column);
328 gtk_tree_view_column_set_title(column, _("Options"));
329
330 renderer = gtk_cell_renderer_toggle_new();
331 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
332 renderer, FALSE);
333 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
334 renderer,
335 "active", COL_BTNACT,
336 "inconsistent", COL_BTNINC,
337 "visible", COL_BTNVIS,
338 "radio", COL_BTNRAD, NULL);
339 renderer = gtk_cell_renderer_text_new();
340 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
341 renderer, FALSE);
342 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
343 renderer,
344 "text", COL_OPTION,
345 "foreground-gdk",
346 COL_COLOR, NULL);
347
348 sel = gtk_tree_view_get_selection(view);
349 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
350 gtk_widget_realize(tree1_w);
351}
352
353static void renderer_edited(GtkCellRendererText * cell,
354 const gchar * path_string,
355 const gchar * new_text, gpointer user_data);
356static void renderer_toggled(GtkCellRendererToggle * cellrenderertoggle,
357 gchar * arg1, gpointer user_data);
358
359void init_right_tree(void)
360{
361 GtkTreeView *view = GTK_TREE_VIEW(tree2_w);
362 GtkCellRenderer *renderer;
363 GtkTreeSelection *sel;
364 GtkTreeViewColumn *column;
365 gint i;
366
367 gtk_tree_view_set_model(view, model2);
368 gtk_tree_view_set_headers_visible(view, TRUE);
369 gtk_tree_view_set_rules_hint(view, FALSE);
370
371 column = gtk_tree_view_column_new();
372 gtk_tree_view_append_column(view, column);
373 gtk_tree_view_column_set_title(column, _("Options"));
374
375 renderer = gtk_cell_renderer_pixbuf_new();
376 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
377 renderer, FALSE);
378 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
379 renderer,
380 "pixbuf", COL_PIXBUF,
381 "visible", COL_PIXVIS, NULL);
382 renderer = gtk_cell_renderer_toggle_new();
383 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
384 renderer, FALSE);
385 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
386 renderer,
387 "active", COL_BTNACT,
388 "inconsistent", COL_BTNINC,
389 "visible", COL_BTNVIS,
390 "radio", COL_BTNRAD, NULL);
391 /*g_signal_connect(G_OBJECT(renderer), "toggled",
392 G_CALLBACK(renderer_toggled), NULL); */
393 renderer = gtk_cell_renderer_text_new();
394 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
395 renderer, FALSE);
396 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
397 renderer,
398 "text", COL_OPTION,
399 "foreground-gdk",
400 COL_COLOR, NULL);
401
402 renderer = gtk_cell_renderer_text_new();
403 gtk_tree_view_insert_column_with_attributes(view, -1,
404 _("Name"), renderer,
405 "text", COL_NAME,
406 "foreground-gdk",
407 COL_COLOR, NULL);
408 renderer = gtk_cell_renderer_text_new();
409 gtk_tree_view_insert_column_with_attributes(view, -1,
410 "N", renderer,
411 "text", COL_NO,
412 "foreground-gdk",
413 COL_COLOR, NULL);
414 renderer = gtk_cell_renderer_text_new();
415 gtk_tree_view_insert_column_with_attributes(view, -1,
416 "M", renderer,
417 "text", COL_MOD,
418 "foreground-gdk",
419 COL_COLOR, NULL);
420 renderer = gtk_cell_renderer_text_new();
421 gtk_tree_view_insert_column_with_attributes(view, -1,
422 "Y", renderer,
423 "text", COL_YES,
424 "foreground-gdk",
425 COL_COLOR, NULL);
426 renderer = gtk_cell_renderer_text_new();
427 gtk_tree_view_insert_column_with_attributes(view, -1,
428 _("Value"), renderer,
429 "text", COL_VALUE,
430 "editable",
431 COL_EDIT,
432 "foreground-gdk",
433 COL_COLOR, NULL);
434 g_signal_connect(G_OBJECT(renderer), "edited",
435 G_CALLBACK(renderer_edited), NULL);
436
437 column = gtk_tree_view_get_column(view, COL_NAME);
438 gtk_tree_view_column_set_visible(column, show_name);
439 column = gtk_tree_view_get_column(view, COL_NO);
440 gtk_tree_view_column_set_visible(column, show_range);
441 column = gtk_tree_view_get_column(view, COL_MOD);
442 gtk_tree_view_column_set_visible(column, show_range);
443 column = gtk_tree_view_get_column(view, COL_YES);
444 gtk_tree_view_column_set_visible(column, show_range);
445 column = gtk_tree_view_get_column(view, COL_VALUE);
446 gtk_tree_view_column_set_visible(column, show_value);
447
448 if (resizeable) {
449 for (i = 0; i < COL_VALUE; i++) {
450 column = gtk_tree_view_get_column(view, i);
451 gtk_tree_view_column_set_resizable(column, TRUE);
452 }
453 }
454
455 sel = gtk_tree_view_get_selection(view);
456 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
457}
458
459
460/* Utility Functions */
461
462
463static void text_insert_help(struct menu *menu)
464{
465 GtkTextBuffer *buffer;
466 GtkTextIter start, end;
467 const char *prompt = menu_get_prompt(menu);
468 gchar *name;
469 const char *help = _(nohelp_text);
470
471 if (!menu->sym)
472 help = "";
473 else if (menu->sym->help)
474 help = _(menu->sym->help);
475
476 if (menu->sym && menu->sym->name)
477 name = g_strdup_printf(_(menu->sym->name));
478 else
479 name = g_strdup("");
480
481 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
482 gtk_text_buffer_get_bounds(buffer, &start, &end);
483 gtk_text_buffer_delete(buffer, &start, &end);
484 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
485
486 gtk_text_buffer_get_end_iter(buffer, &end);
487 gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
488 NULL);
489 gtk_text_buffer_insert_at_cursor(buffer, " ", 1);
490 gtk_text_buffer_get_end_iter(buffer, &end);
491 gtk_text_buffer_insert_with_tags(buffer, &end, name, -1, tag1,
492 NULL);
493 gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
494 gtk_text_buffer_get_end_iter(buffer, &end);
495 gtk_text_buffer_insert_with_tags(buffer, &end, help, -1, tag2,
496 NULL);
497}
498
499
500static void text_insert_msg(const char *title, const char *message)
501{
502 GtkTextBuffer *buffer;
503 GtkTextIter start, end;
504 const char *msg = message;
505
506 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
507 gtk_text_buffer_get_bounds(buffer, &start, &end);
508 gtk_text_buffer_delete(buffer, &start, &end);
509 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
510
511 gtk_text_buffer_get_end_iter(buffer, &end);
512 gtk_text_buffer_insert_with_tags(buffer, &end, title, -1, tag1,
513 NULL);
514 gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
515 gtk_text_buffer_get_end_iter(buffer, &end);
516 gtk_text_buffer_insert_with_tags(buffer, &end, msg, -1, tag2,
517 NULL);
518}
519
520
521/* Main Windows Callbacks */
522
523void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data);
524gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
525 gpointer user_data)
526{
527 GtkWidget *dialog, *label;
528 gint result;
529
530 if (config_changed == FALSE)
531 return FALSE;
532
533 dialog = gtk_dialog_new_with_buttons(_("Warning !"),
534 GTK_WINDOW(main_wnd),
535 (GtkDialogFlags)
536 (GTK_DIALOG_MODAL |
537 GTK_DIALOG_DESTROY_WITH_PARENT),
538 GTK_STOCK_OK,
539 GTK_RESPONSE_YES,
540 GTK_STOCK_NO,
541 GTK_RESPONSE_NO,
542 GTK_STOCK_CANCEL,
543 GTK_RESPONSE_CANCEL, NULL);
544 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
545 GTK_RESPONSE_CANCEL);
546
547 label = gtk_label_new(_("\nSave configuration ?\n"));
548 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
549 gtk_widget_show(label);
550
551 result = gtk_dialog_run(GTK_DIALOG(dialog));
552 switch (result) {
553 case GTK_RESPONSE_YES:
554 on_save1_activate(NULL, NULL);
555 return FALSE;
556 case GTK_RESPONSE_NO:
557 return FALSE;
558 case GTK_RESPONSE_CANCEL:
559 case GTK_RESPONSE_DELETE_EVENT:
560 default:
561 gtk_widget_destroy(dialog);
562 return TRUE;
563 }
564
565 return FALSE;
566}
567
568
569void on_window1_destroy(GtkObject * object, gpointer user_data)
570{
571 gtk_main_quit();
572}
573
574
575void
576on_window1_size_request(GtkWidget * widget,
577 GtkRequisition * requisition, gpointer user_data)
578{
579 static gint old_h;
580 gint w, h;
581
582 if (widget->window == NULL)
583 gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
584 else
585 gdk_window_get_size(widget->window, &w, &h);
586
587 if (h == old_h)
588 return;
589 old_h = h;
590
591 gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
592}
593
594
595/* Menu & Toolbar Callbacks */
596
597
598static void
599load_filename(GtkFileSelection * file_selector, gpointer user_data)
600{
601 const gchar *fn;
602
603 fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
604 (user_data));
605
606 if (conf_read(fn))
607 text_insert_msg(_("Error"), _("Unable to load configuration !"));
608 else
609 display_tree(&rootmenu);
610}
611
612void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
613{
614 GtkWidget *fs;
615
616 fs = gtk_file_selection_new(_("Load file..."));
617 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
618 "clicked",
619 G_CALLBACK(load_filename), (gpointer) fs);
620 g_signal_connect_swapped(GTK_OBJECT
621 (GTK_FILE_SELECTION(fs)->ok_button),
622 "clicked", G_CALLBACK(gtk_widget_destroy),
623 (gpointer) fs);
624 g_signal_connect_swapped(GTK_OBJECT
625 (GTK_FILE_SELECTION(fs)->cancel_button),
626 "clicked", G_CALLBACK(gtk_widget_destroy),
627 (gpointer) fs);
628 gtk_widget_show(fs);
629}
630
631
632void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data)
633{
634 if (conf_write(NULL))
635 text_insert_msg(_("Error"), _("Unable to save configuration !"));
636
637 config_changed = FALSE;
638}
639
640
641static void
642store_filename(GtkFileSelection * file_selector, gpointer user_data)
643{
644 const gchar *fn;
645
646 fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
647 (user_data));
648
649 if (conf_write(fn))
650 text_insert_msg(_("Error"), _("Unable to save configuration !"));
651
652 gtk_widget_destroy(GTK_WIDGET(user_data));
653}
654
655void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
656{
657 GtkWidget *fs;
658
659 fs = gtk_file_selection_new(_("Save file as..."));
660 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
661 "clicked",
662 G_CALLBACK(store_filename), (gpointer) fs);
663 g_signal_connect_swapped(GTK_OBJECT
664 (GTK_FILE_SELECTION(fs)->ok_button),
665 "clicked", G_CALLBACK(gtk_widget_destroy),
666 (gpointer) fs);
667 g_signal_connect_swapped(GTK_OBJECT
668 (GTK_FILE_SELECTION(fs)->cancel_button),
669 "clicked", G_CALLBACK(gtk_widget_destroy),
670 (gpointer) fs);
671 gtk_widget_show(fs);
672}
673
674
675void on_quit1_activate(GtkMenuItem * menuitem, gpointer user_data)
676{
677 if (!on_window1_delete_event(NULL, NULL, NULL))
678 gtk_widget_destroy(GTK_WIDGET(main_wnd));
679}
680
681
682void on_show_name1_activate(GtkMenuItem * menuitem, gpointer user_data)
683{
684 GtkTreeViewColumn *col;
685
686 show_name = GTK_CHECK_MENU_ITEM(menuitem)->active;
687 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NAME);
688 if (col)
689 gtk_tree_view_column_set_visible(col, show_name);
690}
691
692
693void on_show_range1_activate(GtkMenuItem * menuitem, gpointer user_data)
694{
695 GtkTreeViewColumn *col;
696
697 show_range = GTK_CHECK_MENU_ITEM(menuitem)->active;
698 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NO);
699 if (col)
700 gtk_tree_view_column_set_visible(col, show_range);
701 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_MOD);
702 if (col)
703 gtk_tree_view_column_set_visible(col, show_range);
704 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_YES);
705 if (col)
706 gtk_tree_view_column_set_visible(col, show_range);
707
708}
709
710
711void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
712{
713 GtkTreeViewColumn *col;
714
715 show_value = GTK_CHECK_MENU_ITEM(menuitem)->active;
716 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_VALUE);
717 if (col)
718 gtk_tree_view_column_set_visible(col, show_value);
719}
720
721
722void
723on_show_all_options1_activate(GtkMenuItem * menuitem, gpointer user_data)
724{
725 show_all = GTK_CHECK_MENU_ITEM(menuitem)->active;
726
727 gtk_tree_store_clear(tree2);
728 display_tree(&rootmenu); // instead of update_tree to speed-up
729}
730
731
732void
733on_show_debug_info1_activate(GtkMenuItem * menuitem, gpointer user_data)
734{
735 show_debug = GTK_CHECK_MENU_ITEM(menuitem)->active;
736 update_tree(&rootmenu, NULL);
737}
738
739
740void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
741{
742 GtkWidget *dialog;
743 const gchar *intro_text = _(
744 "Welcome to gkc, the GTK+ graphical kernel configuration tool\n"
745 "for Linux.\n"
746 "For each option, a blank box indicates the feature is disabled, a\n"
747 "check indicates it is enabled, and a dot indicates that it is to\n"
748 "be compiled as a module. Clicking on the box will cycle through the three states.\n"
749 "\n"
750 "If you do not see an option (e.g., a device driver) that you\n"
751 "believe should be present, try turning on Show All Options\n"
752 "under the Options menu.\n"
753 "Although there is no cross reference yet to help you figure out\n"
754 "what other options must be enabled to support the option you\n"
755 "are interested in, you can still view the help of a grayed-out\n"
756 "option.\n"
757 "\n"
758 "Toggling Show Debug Info under the Options menu will show \n"
759 "the dependencies, which you can then match by examining other options.");
760
761 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
762 GTK_DIALOG_DESTROY_WITH_PARENT,
763 GTK_MESSAGE_INFO,
764 GTK_BUTTONS_CLOSE, intro_text);
765 g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
766 G_CALLBACK(gtk_widget_destroy),
767 GTK_OBJECT(dialog));
768 gtk_widget_show_all(dialog);
769}
770
771
772void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
773{
774 GtkWidget *dialog;
775 const gchar *about_text =
776 _("gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
777 "Based on the source code from Roman Zippel.\n");
778
779 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
780 GTK_DIALOG_DESTROY_WITH_PARENT,
781 GTK_MESSAGE_INFO,
782 GTK_BUTTONS_CLOSE, about_text);
783 g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
784 G_CALLBACK(gtk_widget_destroy),
785 GTK_OBJECT(dialog));
786 gtk_widget_show_all(dialog);
787}
788
789
790void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
791{
792 GtkWidget *dialog;
793 const gchar *license_text =
794 _("gkc is released under the terms of the GNU GPL v2.\n"
795 "For more information, please see the source code or\n"
796 "visit http://www.fsf.org/licenses/licenses.html\n");
797
798 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
799 GTK_DIALOG_DESTROY_WITH_PARENT,
800 GTK_MESSAGE_INFO,
801 GTK_BUTTONS_CLOSE, license_text);
802 g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
803 G_CALLBACK(gtk_widget_destroy),
804 GTK_OBJECT(dialog));
805 gtk_widget_show_all(dialog);
806}
807
808
809void on_back_clicked(GtkButton * button, gpointer user_data)
810{
811 enum prop_type ptype;
812
813 current = current->parent;
814 ptype = current->prompt ? current->prompt->type : P_UNKNOWN;
815 if (ptype != P_MENU)
816 current = current->parent;
817 display_tree_part();
818
819 if (current == &rootmenu)
820 gtk_widget_set_sensitive(back_btn, FALSE);
821}
822
823
824void on_load_clicked(GtkButton * button, gpointer user_data)
825{
826 on_load1_activate(NULL, user_data);
827}
828
829
830void on_save_clicked(GtkButton * button, gpointer user_data)
831{
832 on_save1_activate(NULL, user_data);
833}
834
835
836void on_single_clicked(GtkButton * button, gpointer user_data)
837{
838 view_mode = SINGLE_VIEW;
839 gtk_paned_set_position(GTK_PANED(hpaned), 0);
840 gtk_widget_hide(tree1_w);
841 current = &rootmenu;
842 display_tree_part();
843}
844
845
846void on_split_clicked(GtkButton * button, gpointer user_data)
847{
848 gint w, h;
849 view_mode = SPLIT_VIEW;
850 gtk_widget_show(tree1_w);
851 gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
852 gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
853 if (tree2)
854 gtk_tree_store_clear(tree2);
855 display_list();
856
857 /* Disable back btn, like in full mode. */
858 gtk_widget_set_sensitive(back_btn, FALSE);
859}
860
861
862void on_full_clicked(GtkButton * button, gpointer user_data)
863{
864 view_mode = FULL_VIEW;
865 gtk_paned_set_position(GTK_PANED(hpaned), 0);
866 gtk_widget_hide(tree1_w);
867 if (tree2)
868 gtk_tree_store_clear(tree2);
869 display_tree(&rootmenu);
870 gtk_widget_set_sensitive(back_btn, FALSE);
871}
872
873
874void on_collapse_clicked(GtkButton * button, gpointer user_data)
875{
876 gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w));
877}
878
879
880void on_expand_clicked(GtkButton * button, gpointer user_data)
881{
882 gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
883}
884
885
886/* CTree Callbacks */
887
888/* Change hex/int/string value in the cell */
889static void renderer_edited(GtkCellRendererText * cell,
890 const gchar * path_string,
891 const gchar * new_text, gpointer user_data)
892{
893 GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
894 GtkTreeIter iter;
895 const char *old_def, *new_def;
896 struct menu *menu;
897 struct symbol *sym;
898
899 if (!gtk_tree_model_get_iter(model2, &iter, path))
900 return;
901
902 gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
903 sym = menu->sym;
904
905 gtk_tree_model_get(model2, &iter, COL_VALUE, &old_def, -1);
906 new_def = new_text;
907
908 sym_set_string_value(sym, new_def);
909
910 config_changed = TRUE;
911 update_tree(&rootmenu, NULL);
912
913 gtk_tree_path_free(path);
914}
915
916/* Change the value of a symbol and update the tree */
917static void change_sym_value(struct menu *menu, gint col)
918{
919 struct symbol *sym = menu->sym;
920 tristate oldval, newval;
921
922 if (!sym)
923 return;
924
925 if (col == COL_NO)
926 newval = no;
927 else if (col == COL_MOD)
928 newval = mod;
929 else if (col == COL_YES)
930 newval = yes;
931 else
932 return;
933
934 switch (sym_get_type(sym)) {
935 case S_BOOLEAN:
936 case S_TRISTATE:
937 oldval = sym_get_tristate_value(sym);
938 if (!sym_tristate_within_range(sym, newval))
939 newval = yes;
940 sym_set_tristate_value(sym, newval);
941 config_changed = TRUE;
942 if (view_mode == FULL_VIEW)
943 update_tree(&rootmenu, NULL);
944 else if (view_mode == SPLIT_VIEW) {
945 update_tree(browsed, NULL);
946 display_list();
947 }
948 else if (view_mode == SINGLE_VIEW)
949 display_tree_part(); //fixme: keep exp/coll
950 break;
951 case S_INT:
952 case S_HEX:
953 case S_STRING:
954 default:
955 break;
956 }
957}
958
959static void toggle_sym_value(struct menu *menu)
960{
961 if (!menu->sym)
962 return;
963
964 sym_toggle_tristate_value(menu->sym);
965 if (view_mode == FULL_VIEW)
966 update_tree(&rootmenu, NULL);
967 else if (view_mode == SPLIT_VIEW) {
968 update_tree(browsed, NULL);
969 display_list();
970 }
971 else if (view_mode == SINGLE_VIEW)
972 display_tree_part(); //fixme: keep exp/coll
973}
974
975static void renderer_toggled(GtkCellRendererToggle * cell,
976 gchar * path_string, gpointer user_data)
977{
978 GtkTreePath *path, *sel_path = NULL;
979 GtkTreeIter iter, sel_iter;
980 GtkTreeSelection *sel;
981 struct menu *menu;
982
983 path = gtk_tree_path_new_from_string(path_string);
984 if (!gtk_tree_model_get_iter(model2, &iter, path))
985 return;
986
987 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w));
988 if (gtk_tree_selection_get_selected(sel, NULL, &sel_iter))
989 sel_path = gtk_tree_model_get_path(model2, &sel_iter);
990 if (!sel_path)
991 goto out1;
992 if (gtk_tree_path_compare(path, sel_path))
993 goto out2;
994
995 gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
996 toggle_sym_value(menu);
997
998 out2:
999 gtk_tree_path_free(sel_path);
1000 out1:
1001 gtk_tree_path_free(path);
1002}
1003
1004static gint column2index(GtkTreeViewColumn * column)
1005{
1006 gint i;
1007
1008 for (i = 0; i < COL_NUMBER; i++) {
1009 GtkTreeViewColumn *col;
1010
1011 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), i);
1012 if (col == column)
1013 return i;
1014 }
1015
1016 return -1;
1017}
1018
1019
1020/* User click: update choice (full) or goes down (single) */
1021gboolean
1022on_treeview2_button_press_event(GtkWidget * widget,
1023 GdkEventButton * event, gpointer user_data)
1024{
1025 GtkTreeView *view = GTK_TREE_VIEW(widget);
1026 GtkTreePath *path;
1027 GtkTreeViewColumn *column;
1028 GtkTreeIter iter;
1029 struct menu *menu;
1030 gint col;
1031
1032#if GTK_CHECK_VERSION(2,1,4) // bug in ctree with earlier version of GTK
1033 gint tx = (gint) event->x;
1034 gint ty = (gint) event->y;
1035 gint cx, cy;
1036
1037 gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx,
1038 &cy);
1039#else
1040 gtk_tree_view_get_cursor(view, &path, &column);
1041#endif
1042 if (path == NULL)
1043 return FALSE;
1044
1045 if (!gtk_tree_model_get_iter(model2, &iter, path))
1046 return FALSE;
1047 gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
1048
1049 col = column2index(column);
1050 if (event->type == GDK_2BUTTON_PRESS) {
1051 enum prop_type ptype;
1052 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
1053
1054 if (ptype == P_MENU && view_mode != FULL_VIEW && col == COL_OPTION) {
1055 // goes down into menu
1056 current = menu;
1057 display_tree_part();
1058 gtk_widget_set_sensitive(back_btn, TRUE);
1059 } else if ((col == COL_OPTION)) {
1060 toggle_sym_value(menu);
1061 gtk_tree_view_expand_row(view, path, TRUE);
1062 }
1063 } else {
1064 if (col == COL_VALUE) {
1065 toggle_sym_value(menu);
1066 gtk_tree_view_expand_row(view, path, TRUE);
1067 } else if (col == COL_NO || col == COL_MOD
1068 || col == COL_YES) {
1069 change_sym_value(menu, col);
1070 gtk_tree_view_expand_row(view, path, TRUE);
1071 }
1072 }
1073
1074 return FALSE;
1075}
1076
1077/* Key pressed: update choice */
1078gboolean
1079on_treeview2_key_press_event(GtkWidget * widget,
1080 GdkEventKey * event, gpointer user_data)
1081{
1082 GtkTreeView *view = GTK_TREE_VIEW(widget);
1083 GtkTreePath *path;
1084 GtkTreeViewColumn *column;
1085 GtkTreeIter iter;
1086 struct menu *menu;
1087 gint col;
1088
1089 gtk_tree_view_get_cursor(view, &path, &column);
1090 if (path == NULL)
1091 return FALSE;
1092
1093 if (event->keyval == GDK_space) {
1094 if (gtk_tree_view_row_expanded(view, path))
1095 gtk_tree_view_collapse_row(view, path);
1096 else
1097 gtk_tree_view_expand_row(view, path, FALSE);
1098 return TRUE;
1099 }
1100 if (event->keyval == GDK_KP_Enter) {
1101 }
1102 if (widget == tree1_w)
1103 return FALSE;
1104
1105 gtk_tree_model_get_iter(model2, &iter, path);
1106 gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
1107
1108 if (!strcasecmp(event->string, "n"))
1109 col = COL_NO;
1110 else if (!strcasecmp(event->string, "m"))
1111 col = COL_MOD;
1112 else if (!strcasecmp(event->string, "y"))
1113 col = COL_YES;
1114 else
1115 col = -1;
1116 change_sym_value(menu, col);
1117
1118 return FALSE;
1119}
1120
1121
1122/* Row selection changed: update help */
1123void
1124on_treeview2_cursor_changed(GtkTreeView * treeview, gpointer user_data)
1125{
1126 GtkTreeSelection *selection;
1127 GtkTreeIter iter;
1128 struct menu *menu;
1129
1130 selection = gtk_tree_view_get_selection(treeview);
1131 if (gtk_tree_selection_get_selected(selection, &model2, &iter)) {
1132 gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
1133 text_insert_help(menu);
1134 }
1135}
1136
1137
1138/* User click: display sub-tree in the right frame. */
1139gboolean
1140on_treeview1_button_press_event(GtkWidget * widget,
1141 GdkEventButton * event, gpointer user_data)
1142{
1143 GtkTreeView *view = GTK_TREE_VIEW(widget);
1144 GtkTreePath *path;
1145 GtkTreeViewColumn *column;
1146 GtkTreeIter iter;
1147 struct menu *menu;
1148
1149 gint tx = (gint) event->x;
1150 gint ty = (gint) event->y;
1151 gint cx, cy;
1152
1153 gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx,
1154 &cy);
1155 if (path == NULL)
1156 return FALSE;
1157
1158 gtk_tree_model_get_iter(model1, &iter, path);
1159 gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1);
1160
1161 if (event->type == GDK_2BUTTON_PRESS) {
1162 toggle_sym_value(menu);
1163 current = menu;
1164 display_tree_part();
1165 } else {
1166 browsed = menu;
1167 display_tree_part();
1168 }
1169
1170 gtk_widget_realize(tree2_w);
1171 gtk_tree_view_set_cursor(view, path, NULL, FALSE);
1172 gtk_widget_grab_focus(tree2_w);
1173
1174 return FALSE;
1175}
1176
1177
1178/* Fill a row of strings */
1179static gchar **fill_row(struct menu *menu)
1180{
1181 static gchar *row[COL_NUMBER];
1182 struct symbol *sym = menu->sym;
1183 const char *def;
1184 int stype;
1185 tristate val;
1186 enum prop_type ptype;
1187 int i;
1188
1189 for (i = COL_OPTION; i <= COL_COLOR; i++)
1190 g_free(row[i]);
1191 bzero(row, sizeof(row));
1192
1193 row[COL_OPTION] =
1194 g_strdup_printf("%s %s", menu_get_prompt(menu),
1195 sym ? (sym->
1196 flags & SYMBOL_NEW ? "(NEW)" : "") :
1197 "");
1198
1199 if (show_all && !menu_is_visible(menu))
1200 row[COL_COLOR] = g_strdup("DarkGray");
1201 else
1202 row[COL_COLOR] = g_strdup("Black");
1203
1204 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
1205 switch (ptype) {
1206 case P_MENU:
1207 row[COL_PIXBUF] = (gchar *) xpm_menu;
1208 if (view_mode == SINGLE_VIEW)
1209 row[COL_PIXVIS] = GINT_TO_POINTER(TRUE);
1210 row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
1211 break;
1212 case P_COMMENT:
1213 row[COL_PIXBUF] = (gchar *) xpm_void;
1214 row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
1215 row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
1216 break;
1217 default:
1218 row[COL_PIXBUF] = (gchar *) xpm_void;
1219 row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
1220 row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
1221 break;
1222 }
1223
1224 if (!sym)
1225 return row;
1226 row[COL_NAME] = g_strdup(sym->name);
1227
1228 sym_calc_value(sym);
1229 sym->flags &= ~SYMBOL_CHANGED;
1230
1231 if (sym_is_choice(sym)) { // parse childs for getting final value
1232 struct menu *child;
1233 struct symbol *def_sym = sym_get_choice_value(sym);
1234 struct menu *def_menu = NULL;
1235
1236 row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
1237
1238 for (child = menu->list; child; child = child->next) {
1239 if (menu_is_visible(child)
1240 && child->sym == def_sym)
1241 def_menu = child;
1242 }
1243
1244 if (def_menu)
1245 row[COL_VALUE] =
1246 g_strdup(menu_get_prompt(def_menu));
1247 }
1248 if (sym->flags & SYMBOL_CHOICEVAL)
1249 row[COL_BTNRAD] = GINT_TO_POINTER(TRUE);
1250
1251 stype = sym_get_type(sym);
1252 switch (stype) {
1253 case S_BOOLEAN:
1254 if (GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE)
1255 row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
1256 if (sym_is_choice(sym))
1257 break;
1258 case S_TRISTATE:
1259 val = sym_get_tristate_value(sym);
1260 switch (val) {
1261 case no:
1262 row[COL_NO] = g_strdup("N");
1263 row[COL_VALUE] = g_strdup("N");
1264 row[COL_BTNACT] = GINT_TO_POINTER(FALSE);
1265 row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
1266 break;
1267 case mod:
1268 row[COL_MOD] = g_strdup("M");
1269 row[COL_VALUE] = g_strdup("M");
1270 row[COL_BTNINC] = GINT_TO_POINTER(TRUE);
1271 break;
1272 case yes:
1273 row[COL_YES] = g_strdup("Y");
1274 row[COL_VALUE] = g_strdup("Y");
1275 row[COL_BTNACT] = GINT_TO_POINTER(TRUE);
1276 row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
1277 break;
1278 }
1279
1280 if (val != no && sym_tristate_within_range(sym, no))
1281 row[COL_NO] = g_strdup("_");
1282 if (val != mod && sym_tristate_within_range(sym, mod))
1283 row[COL_MOD] = g_strdup("_");
1284 if (val != yes && sym_tristate_within_range(sym, yes))
1285 row[COL_YES] = g_strdup("_");
1286 break;
1287 case S_INT:
1288 case S_HEX:
1289 case S_STRING:
1290 def = sym_get_string_value(sym);
1291 row[COL_VALUE] = g_strdup(def);
1292 row[COL_EDIT] = GINT_TO_POINTER(TRUE);
1293 row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
1294 break;
1295 }
1296
1297 return row;
1298}
1299
1300
1301/* Set the node content with a row of strings */
1302static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row)
1303{
1304 GdkColor color;
1305 gboolean success;
1306 GdkPixbuf *pix;
1307
1308 pix = gdk_pixbuf_new_from_xpm_data((const char **)
1309 row[COL_PIXBUF]);
1310
1311 gdk_color_parse(row[COL_COLOR], &color);
1312 gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color, 1,
1313 FALSE, FALSE, &success);
1314
1315 gtk_tree_store_set(tree, node,
1316 COL_OPTION, row[COL_OPTION],
1317 COL_NAME, row[COL_NAME],
1318 COL_NO, row[COL_NO],
1319 COL_MOD, row[COL_MOD],
1320 COL_YES, row[COL_YES],
1321 COL_VALUE, row[COL_VALUE],
1322 COL_MENU, (gpointer) menu,
1323 COL_COLOR, &color,
1324 COL_EDIT, GPOINTER_TO_INT(row[COL_EDIT]),
1325 COL_PIXBUF, pix,
1326 COL_PIXVIS, GPOINTER_TO_INT(row[COL_PIXVIS]),
1327 COL_BTNVIS, GPOINTER_TO_INT(row[COL_BTNVIS]),
1328 COL_BTNACT, GPOINTER_TO_INT(row[COL_BTNACT]),
1329 COL_BTNINC, GPOINTER_TO_INT(row[COL_BTNINC]),
1330 COL_BTNRAD, GPOINTER_TO_INT(row[COL_BTNRAD]),
1331 -1);
1332
1333 g_object_unref(pix);
1334}
1335
1336
1337/* Add a node to the tree */
1338static void place_node(struct menu *menu, char **row)
1339{
1340 GtkTreeIter *parent = parents[indent - 1];
1341 GtkTreeIter *node = parents[indent];
1342
1343 gtk_tree_store_append(tree, node, parent);
1344 set_node(node, menu, row);
1345}
1346
1347
1348/* Find a node in the GTK+ tree */
1349static GtkTreeIter found;
1350
1351/*
1352 * Find a menu in the GtkTree starting at parent.
1353 */
1354GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent,
1355 struct menu *tofind)
1356{
1357 GtkTreeIter iter;
1358 GtkTreeIter *child = &iter;
1359 gboolean valid;
1360 GtkTreeIter *ret;
1361
1362 valid = gtk_tree_model_iter_children(model2, child, parent);
1363 while (valid) {
1364 struct menu *menu;
1365
1366 gtk_tree_model_get(model2, child, 6, &menu, -1);
1367
1368 if (menu == tofind) {
1369 memcpy(&found, child, sizeof(GtkTreeIter));
1370 return &found;
1371 }
1372
1373 ret = gtktree_iter_find_node(child, tofind);
1374 if (ret)
1375 return ret;
1376
1377 valid = gtk_tree_model_iter_next(model2, child);
1378 }
1379
1380 return NULL;
1381}
1382
1383
1384/*
1385 * Update the tree by adding/removing entries
1386 * Does not change other nodes
1387 */
1388static void update_tree(struct menu *src, GtkTreeIter * dst)
1389{
1390 struct menu *child1;
1391 GtkTreeIter iter, tmp;
1392 GtkTreeIter *child2 = &iter;
1393 gboolean valid;
1394 GtkTreeIter *sibling;
1395 struct symbol *sym;
1396 struct property *prop;
1397 struct menu *menu1, *menu2;
1398
1399 if (src == &rootmenu)
1400 indent = 1;
1401
1402 valid = gtk_tree_model_iter_children(model2, child2, dst);
1403 for (child1 = src->list; child1; child1 = child1->next) {
1404
1405 prop = child1->prompt;
1406 sym = child1->sym;
1407
1408 reparse:
1409 menu1 = child1;
1410 if (valid)
1411 gtk_tree_model_get(model2, child2, COL_MENU,
1412 &menu2, -1);
1413 else
1414 menu2 = NULL; // force adding of a first child
1415
1416#ifdef DEBUG
1417 printf("%*c%s | %s\n", indent, ' ',
1418 menu1 ? menu_get_prompt(menu1) : "nil",
1419 menu2 ? menu_get_prompt(menu2) : "nil");
1420#endif
1421
1422 if (!menu_is_visible(child1) && !show_all) { // remove node
1423 if (gtktree_iter_find_node(dst, menu1) != NULL) {
1424 memcpy(&tmp, child2, sizeof(GtkTreeIter));
1425 valid = gtk_tree_model_iter_next(model2,
1426 child2);
1427 gtk_tree_store_remove(tree2, &tmp);
1428 if (!valid)
1429 return; // next parent
1430 else
1431 goto reparse; // next child
1432 } else
1433 continue;
1434 }
1435
1436 if (menu1 != menu2) {
1437 if (gtktree_iter_find_node(dst, menu1) == NULL) { // add node
1438 if (!valid && !menu2)
1439 sibling = NULL;
1440 else
1441 sibling = child2;
1442 gtk_tree_store_insert_before(tree2,
1443 child2,
1444 dst, sibling);
1445 set_node(child2, menu1, fill_row(menu1));
1446 if (menu2 == NULL)
1447 valid = TRUE;
1448 } else { // remove node
1449 memcpy(&tmp, child2, sizeof(GtkTreeIter));
1450 valid = gtk_tree_model_iter_next(model2,
1451 child2);
1452 gtk_tree_store_remove(tree2, &tmp);
1453 if (!valid)
1454 return; // next parent
1455 else
1456 goto reparse; // next child
1457 }
1458 } else if (sym && (sym->flags & SYMBOL_CHANGED)) {
1459 set_node(child2, menu1, fill_row(menu1));
1460 }
1461
1462 indent++;
1463 update_tree(child1, child2);
1464 indent--;
1465
1466 valid = gtk_tree_model_iter_next(model2, child2);
1467 }
1468}
1469
1470
1471/* Display the whole tree (single/split/full view) */
1472static void display_tree(struct menu *menu)
1473{
1474 struct symbol *sym;
1475 struct property *prop;
1476 struct menu *child;
1477 enum prop_type ptype;
1478
1479 if (menu == &rootmenu) {
1480 indent = 1;
1481 current = &rootmenu;
1482 }
1483
1484 for (child = menu->list; child; child = child->next) {
1485 prop = child->prompt;
1486 sym = child->sym;
1487 ptype = prop ? prop->type : P_UNKNOWN;
1488
1489 if (sym)
1490 sym->flags &= ~SYMBOL_CHANGED;
1491
1492 if ((view_mode == SPLIT_VIEW)
1493 && !(child->flags & MENU_ROOT) && (tree == tree1))
1494 continue;
1495
1496 if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT)
1497 && (tree == tree2))
1498 continue;
1499
1500 if (menu_is_visible(child) || show_all)
1501 place_node(child, fill_row(child));
1502#ifdef DEBUG
1503 printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
1504 printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
1505 dbg_print_ptype(ptype);
1506 printf(" | ");
1507 if (sym) {
1508 dbg_print_stype(sym->type);
1509 printf(" | ");
1510 dbg_print_flags(sym->flags);
1511 printf("\n");
1512 } else
1513 printf("\n");
1514#endif
1515 if ((view_mode != FULL_VIEW) && (ptype == P_MENU)
1516 && (tree == tree2))
1517 continue;
1518/*
1519 if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
1520 || (view_mode == FULL_VIEW)
1521 || (view_mode == SPLIT_VIEW))*/
1522 if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
1523 || (view_mode == FULL_VIEW)
1524 || (view_mode == SPLIT_VIEW)) {
1525 indent++;
1526 display_tree(child);
1527 indent--;
1528 }
1529 }
1530}
1531
1532/* Display a part of the tree starting at current node (single/split view) */
1533static void display_tree_part(void)
1534{
1535 if (tree2)
1536 gtk_tree_store_clear(tree2);
1537 if (view_mode == SINGLE_VIEW)
1538 display_tree(current);
1539 else if (view_mode == SPLIT_VIEW)
1540 display_tree(browsed);
1541 gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
1542}
1543
1544/* Display the list in the left frame (split view) */
1545static void display_list(void)
1546{
1547 if (tree1)
1548 gtk_tree_store_clear(tree1);
1549
1550 tree = tree1;
1551 display_tree(&rootmenu);
1552 gtk_tree_view_expand_all(GTK_TREE_VIEW(tree1_w));
1553 tree = tree2;
1554}
1555
1556void fixup_rootmenu(struct menu *menu)
1557{
1558 struct menu *child;
1559 static int menu_cnt = 0;
1560
1561 menu->flags |= MENU_ROOT;
1562 for (child = menu->list; child; child = child->next) {
1563 if (child->prompt && child->prompt->type == P_MENU) {
1564 menu_cnt++;
1565 fixup_rootmenu(child);
1566 menu_cnt--;
1567 } else if (!menu_cnt)
1568 fixup_rootmenu(child);
1569 }
1570}
1571
1572
1573/* Main */
1574int main(int ac, char *av[])
1575{
1576 const char *name;
1577 char *env;
1578 gchar *glade_file;
1579
1580#ifndef LKC_DIRECT_LINK
1581 kconfig_load();
1582#endif
1583
1584 bindtextdomain(PACKAGE, LOCALEDIR);
1585 bind_textdomain_codeset(PACKAGE, "UTF-8");
1586 textdomain(PACKAGE);
1587
1588 /* GTK stuffs */
1589 gtk_set_locale();
1590 gtk_init(&ac, &av);
1591 glade_init();
1592
1593 //add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
1594 //add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");
1595
1596 /* Determine GUI path */
1597 env = getenv(SRCTREE);
1598 if (env)
1599 glade_file = g_strconcat(env, "/scripts/kconfig/gconf.glade", NULL);
1600 else if (av[0][0] == '/')
1601 glade_file = g_strconcat(av[0], ".glade", NULL);
1602 else
1603 glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL);
1604
1605 /* Load the interface and connect signals */
1606 init_main_window(glade_file);
1607 init_tree_model();
1608 init_left_tree();
1609 init_right_tree();
1610
1611 /* Conf stuffs */
1612 if (ac > 1 && av[1][0] == '-') {
1613 switch (av[1][1]) {
1614 case 'a':
1615 //showAll = 1;
1616 break;
1617 case 'h':
1618 case '?':
1619 printf("%s <config>\n", av[0]);
1620 exit(0);
1621 }
1622 name = av[2];
1623 } else
1624 name = av[1];
1625
1626 conf_parse(name);
1627 fixup_rootmenu(&rootmenu);
1628 conf_read(NULL);
1629
1630 switch (view_mode) {
1631 case SINGLE_VIEW:
1632 display_tree_part();
1633 break;
1634 case SPLIT_VIEW:
1635 display_list();
1636 break;
1637 case FULL_VIEW:
1638 display_tree(&rootmenu);
1639 break;
1640 }
1641
1642 gtk_main();
1643
1644 return 0;
1645}
diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade
new file mode 100644
index 000000000..f8744ed64
--- /dev/null
+++ b/scripts/kconfig/gconf.glade
@@ -0,0 +1,648 @@
1<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
2<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
3
4<glade-interface>
5
6<widget class="GtkWindow" id="window1">
7 <property name="visible">True</property>
8 <property name="title" translatable="yes">Gtk Kernel Configurator</property>
9 <property name="type">GTK_WINDOW_TOPLEVEL</property>
10 <property name="window_position">GTK_WIN_POS_NONE</property>
11 <property name="modal">False</property>
12 <property name="default_width">640</property>
13 <property name="default_height">480</property>
14 <property name="resizable">True</property>
15 <property name="destroy_with_parent">False</property>
16 <property name="decorated">True</property>
17 <property name="skip_taskbar_hint">False</property>
18 <property name="skip_pager_hint">False</property>
19 <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
20 <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
21 <signal name="destroy" handler="on_window1_destroy" object="window1"/>
22 <signal name="size_request" handler="on_window1_size_request" object="vpaned1" last_modification_time="Fri, 11 Jan 2002 16:17:11 GMT"/>
23 <signal name="delete_event" handler="on_window1_delete_event" object="window1" last_modification_time="Sun, 09 Mar 2003 19:42:46 GMT"/>
24
25 <child>
26 <widget class="GtkVBox" id="vbox1">
27 <property name="visible">True</property>
28 <property name="homogeneous">False</property>
29 <property name="spacing">0</property>
30
31 <child>
32 <widget class="GtkMenuBar" id="menubar1">
33 <property name="visible">True</property>
34
35 <child>
36 <widget class="GtkMenuItem" id="file1">
37 <property name="visible">True</property>
38 <property name="label" translatable="yes">_File</property>
39 <property name="use_underline">True</property>
40
41 <child>
42 <widget class="GtkMenu" id="file1_menu">
43
44 <child>
45 <widget class="GtkImageMenuItem" id="load1">
46 <property name="visible">True</property>
47 <property name="tooltip" translatable="yes">Load a config file</property>
48 <property name="label" translatable="yes">_Load</property>
49 <property name="use_underline">True</property>
50 <signal name="activate" handler="on_load1_activate"/>
51 <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
52
53 <child internal-child="image">
54 <widget class="GtkImage" id="image39">
55 <property name="visible">True</property>
56 <property name="stock">gtk-open</property>
57 <property name="icon_size">1</property>
58 <property name="xalign">0.5</property>
59 <property name="yalign">0.5</property>
60 <property name="xpad">0</property>
61 <property name="ypad">0</property>
62 </widget>
63 </child>
64 </widget>
65 </child>
66
67 <child>
68 <widget class="GtkImageMenuItem" id="save1">
69 <property name="visible">True</property>
70 <property name="tooltip" translatable="yes">Save the config in .config</property>
71 <property name="label" translatable="yes">_Save</property>
72 <property name="use_underline">True</property>
73 <signal name="activate" handler="on_save1_activate"/>
74 <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
75
76 <child internal-child="image">
77 <widget class="GtkImage" id="image40">
78 <property name="visible">True</property>
79 <property name="stock">gtk-save</property>
80 <property name="icon_size">1</property>
81 <property name="xalign">0.5</property>
82 <property name="yalign">0.5</property>
83 <property name="xpad">0</property>
84 <property name="ypad">0</property>
85 </widget>
86 </child>
87 </widget>
88 </child>
89
90 <child>
91 <widget class="GtkImageMenuItem" id="save_as1">
92 <property name="visible">True</property>
93 <property name="tooltip" translatable="yes">Save the config in a file</property>
94 <property name="label" translatable="yes">Save _as</property>
95 <property name="use_underline">True</property>
96 <signal name="activate" handler="on_save_as1_activate"/>
97
98 <child internal-child="image">
99 <widget class="GtkImage" id="image41">
100 <property name="visible">True</property>
101 <property name="stock">gtk-save-as</property>
102 <property name="icon_size">1</property>
103 <property name="xalign">0.5</property>
104 <property name="yalign">0.5</property>
105 <property name="xpad">0</property>
106 <property name="ypad">0</property>
107 </widget>
108 </child>
109 </widget>
110 </child>
111
112 <child>
113 <widget class="GtkSeparatorMenuItem" id="separator1">
114 <property name="visible">True</property>
115 </widget>
116 </child>
117
118 <child>
119 <widget class="GtkImageMenuItem" id="quit1">
120 <property name="visible">True</property>
121 <property name="label" translatable="yes">_Quit</property>
122 <property name="use_underline">True</property>
123 <signal name="activate" handler="on_quit1_activate"/>
124 <accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
125
126 <child internal-child="image">
127 <widget class="GtkImage" id="image42">
128 <property name="visible">True</property>
129 <property name="stock">gtk-quit</property>
130 <property name="icon_size">1</property>
131 <property name="xalign">0.5</property>
132 <property name="yalign">0.5</property>
133 <property name="xpad">0</property>
134 <property name="ypad">0</property>
135 </widget>
136 </child>
137 </widget>
138 </child>
139 </widget>
140 </child>
141 </widget>
142 </child>
143
144 <child>
145 <widget class="GtkMenuItem" id="options1">
146 <property name="visible">True</property>
147 <property name="label" translatable="yes">_Options</property>
148 <property name="use_underline">True</property>
149
150 <child>
151 <widget class="GtkMenu" id="options1_menu">
152
153 <child>
154 <widget class="GtkCheckMenuItem" id="show_name1">
155 <property name="visible">True</property>
156 <property name="tooltip" translatable="yes">Show name</property>
157 <property name="label" translatable="yes">Show _name</property>
158 <property name="use_underline">True</property>
159 <property name="active">False</property>
160 <signal name="activate" handler="on_show_name1_activate"/>
161 </widget>
162 </child>
163
164 <child>
165 <widget class="GtkCheckMenuItem" id="show_range1">
166 <property name="visible">True</property>
167 <property name="tooltip" translatable="yes">Show range (Y/M/N)</property>
168 <property name="label" translatable="yes">Show _range</property>
169 <property name="use_underline">True</property>
170 <property name="active">False</property>
171 <signal name="activate" handler="on_show_range1_activate"/>
172 </widget>
173 </child>
174
175 <child>
176 <widget class="GtkCheckMenuItem" id="show_data1">
177 <property name="visible">True</property>
178 <property name="tooltip" translatable="yes">Show value of the option</property>
179 <property name="label" translatable="yes">Show _data</property>
180 <property name="use_underline">True</property>
181 <property name="active">False</property>
182 <signal name="activate" handler="on_show_data1_activate"/>
183 </widget>
184 </child>
185
186 <child>
187 <widget class="GtkSeparatorMenuItem" id="separator2">
188 <property name="visible">True</property>
189 </widget>
190 </child>
191
192 <child>
193 <widget class="GtkCheckMenuItem" id="show_all_options1">
194 <property name="visible">True</property>
195 <property name="tooltip" translatable="yes">Show all options</property>
196 <property name="label" translatable="yes">Show all _options</property>
197 <property name="use_underline">True</property>
198 <property name="active">False</property>
199 <signal name="activate" handler="on_show_all_options1_activate"/>
200 </widget>
201 </child>
202
203 <child>
204 <widget class="GtkCheckMenuItem" id="show_debug_info1">
205 <property name="visible">True</property>
206 <property name="tooltip" translatable="yes">Show masked options</property>
207 <property name="label" translatable="yes">Show _debug info</property>
208 <property name="use_underline">True</property>
209 <property name="active">False</property>
210 <signal name="activate" handler="on_show_debug_info1_activate"/>
211 </widget>
212 </child>
213 </widget>
214 </child>
215 </widget>
216 </child>
217
218 <child>
219 <widget class="GtkMenuItem" id="help1">
220 <property name="visible">True</property>
221 <property name="label" translatable="yes">_Help</property>
222 <property name="use_underline">True</property>
223
224 <child>
225 <widget class="GtkMenu" id="help1_menu">
226
227 <child>
228 <widget class="GtkImageMenuItem" id="introduction1">
229 <property name="visible">True</property>
230 <property name="label" translatable="yes">_Introduction</property>
231 <property name="use_underline">True</property>
232 <signal name="activate" handler="on_introduction1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
233 <accelerator key="I" modifiers="GDK_CONTROL_MASK" signal="activate"/>
234
235 <child internal-child="image">
236 <widget class="GtkImage" id="image43">
237 <property name="visible">True</property>
238 <property name="stock">gtk-dialog-question</property>
239 <property name="icon_size">1</property>
240 <property name="xalign">0.5</property>
241 <property name="yalign">0.5</property>
242 <property name="xpad">0</property>
243 <property name="ypad">0</property>
244 </widget>
245 </child>
246 </widget>
247 </child>
248
249 <child>
250 <widget class="GtkImageMenuItem" id="about1">
251 <property name="visible">True</property>
252 <property name="label" translatable="yes">_About</property>
253 <property name="use_underline">True</property>
254 <signal name="activate" handler="on_about1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
255 <accelerator key="A" modifiers="GDK_CONTROL_MASK" signal="activate"/>
256
257 <child internal-child="image">
258 <widget class="GtkImage" id="image44">
259 <property name="visible">True</property>
260 <property name="stock">gtk-properties</property>
261 <property name="icon_size">1</property>
262 <property name="xalign">0.5</property>
263 <property name="yalign">0.5</property>
264 <property name="xpad">0</property>
265 <property name="ypad">0</property>
266 </widget>
267 </child>
268 </widget>
269 </child>
270
271 <child>
272 <widget class="GtkImageMenuItem" id="license1">
273 <property name="visible">True</property>
274 <property name="label" translatable="yes">_License</property>
275 <property name="use_underline">True</property>
276 <signal name="activate" handler="on_license1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
277
278 <child internal-child="image">
279 <widget class="GtkImage" id="image45">
280 <property name="visible">True</property>
281 <property name="stock">gtk-justify-fill</property>
282 <property name="icon_size">1</property>
283 <property name="xalign">0.5</property>
284 <property name="yalign">0.5</property>
285 <property name="xpad">0</property>
286 <property name="ypad">0</property>
287 </widget>
288 </child>
289 </widget>
290 </child>
291 </widget>
292 </child>
293 </widget>
294 </child>
295 </widget>
296 <packing>
297 <property name="padding">0</property>
298 <property name="expand">False</property>
299 <property name="fill">False</property>
300 </packing>
301 </child>
302
303 <child>
304 <widget class="GtkHandleBox" id="handlebox1">
305 <property name="visible">True</property>
306 <property name="shadow_type">GTK_SHADOW_OUT</property>
307 <property name="handle_position">GTK_POS_LEFT</property>
308 <property name="snap_edge">GTK_POS_TOP</property>
309
310 <child>
311 <widget class="GtkToolbar" id="toolbar1">
312 <property name="visible">True</property>
313 <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
314 <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
315 <property name="tooltips">True</property>
316 <property name="show_arrow">True</property>
317
318 <child>
319 <widget class="GtkToolButton" id="button1">
320 <property name="visible">True</property>
321 <property name="tooltip" translatable="yes">Goes up of one level (single view)</property>
322 <property name="label" translatable="yes">Back</property>
323 <property name="use_underline">True</property>
324 <property name="stock_id">gtk-undo</property>
325 <property name="visible_horizontal">True</property>
326 <property name="visible_vertical">True</property>
327 <property name="is_important">False</property>
328 <signal name="clicked" handler="on_back_clicked"/>
329 </widget>
330 <packing>
331 <property name="expand">False</property>
332 <property name="homogeneous">True</property>
333 </packing>
334 </child>
335
336 <child>
337 <widget class="GtkToolItem" id="toolitem1">
338 <property name="visible">True</property>
339 <property name="visible_horizontal">True</property>
340 <property name="visible_vertical">True</property>
341 <property name="is_important">False</property>
342
343 <child>
344 <widget class="GtkVSeparator" id="vseparator1">
345 <property name="visible">True</property>
346 </widget>
347 </child>
348 </widget>
349 <packing>
350 <property name="expand">False</property>
351 <property name="homogeneous">False</property>
352 </packing>
353 </child>
354
355 <child>
356 <widget class="GtkToolButton" id="button2">
357 <property name="visible">True</property>
358 <property name="tooltip" translatable="yes">Load a config file</property>
359 <property name="label" translatable="yes">Load</property>
360 <property name="use_underline">True</property>
361 <property name="stock_id">gtk-open</property>
362 <property name="visible_horizontal">True</property>
363 <property name="visible_vertical">True</property>
364 <property name="is_important">False</property>
365 <signal name="clicked" handler="on_load_clicked"/>
366 </widget>
367 <packing>
368 <property name="expand">False</property>
369 <property name="homogeneous">True</property>
370 </packing>
371 </child>
372
373 <child>
374 <widget class="GtkToolButton" id="button3">
375 <property name="visible">True</property>
376 <property name="tooltip" translatable="yes">Save a config file</property>
377 <property name="label" translatable="yes">Save</property>
378 <property name="use_underline">True</property>
379 <property name="stock_id">gtk-save</property>
380 <property name="visible_horizontal">True</property>
381 <property name="visible_vertical">True</property>
382 <property name="is_important">False</property>
383 <signal name="clicked" handler="on_save_clicked"/>
384 </widget>
385 <packing>
386 <property name="expand">False</property>
387 <property name="homogeneous">True</property>
388 </packing>
389 </child>
390
391 <child>
392 <widget class="GtkToolItem" id="toolitem2">
393 <property name="visible">True</property>
394 <property name="visible_horizontal">True</property>
395 <property name="visible_vertical">True</property>
396 <property name="is_important">False</property>
397
398 <child>
399 <widget class="GtkVSeparator" id="vseparator2">
400 <property name="visible">True</property>
401 </widget>
402 </child>
403 </widget>
404 <packing>
405 <property name="expand">False</property>
406 <property name="homogeneous">False</property>
407 </packing>
408 </child>
409
410 <child>
411 <widget class="GtkToolButton" id="button4">
412 <property name="visible">True</property>
413 <property name="tooltip" translatable="yes">Single view</property>
414 <property name="label" translatable="yes">Single</property>
415 <property name="use_underline">True</property>
416 <property name="stock_id">gtk-missing-image</property>
417 <property name="visible_horizontal">True</property>
418 <property name="visible_vertical">True</property>
419 <property name="is_important">False</property>
420 <signal name="clicked" handler="on_single_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:39 GMT"/>
421 </widget>
422 <packing>
423 <property name="expand">False</property>
424 <property name="homogeneous">True</property>
425 </packing>
426 </child>
427
428 <child>
429 <widget class="GtkToolButton" id="button5">
430 <property name="visible">True</property>
431 <property name="tooltip" translatable="yes">Split view</property>
432 <property name="label" translatable="yes">Split</property>
433 <property name="use_underline">True</property>
434 <property name="stock_id">gtk-missing-image</property>
435 <property name="visible_horizontal">True</property>
436 <property name="visible_vertical">True</property>
437 <property name="is_important">False</property>
438 <signal name="clicked" handler="on_split_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:45 GMT"/>
439 </widget>
440 <packing>
441 <property name="expand">False</property>
442 <property name="homogeneous">True</property>
443 </packing>
444 </child>
445
446 <child>
447 <widget class="GtkToolButton" id="button6">
448 <property name="visible">True</property>
449 <property name="tooltip" translatable="yes">Full view</property>
450 <property name="label" translatable="yes">Full</property>
451 <property name="use_underline">True</property>
452 <property name="stock_id">gtk-missing-image</property>
453 <property name="visible_horizontal">True</property>
454 <property name="visible_vertical">True</property>
455 <property name="is_important">False</property>
456 <signal name="clicked" handler="on_full_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:50 GMT"/>
457 </widget>
458 <packing>
459 <property name="expand">False</property>
460 <property name="homogeneous">True</property>
461 </packing>
462 </child>
463
464 <child>
465 <widget class="GtkToolItem" id="toolitem3">
466 <property name="visible">True</property>
467 <property name="visible_horizontal">True</property>
468 <property name="visible_vertical">True</property>
469 <property name="is_important">False</property>
470
471 <child>
472 <widget class="GtkVSeparator" id="vseparator3">
473 <property name="visible">True</property>
474 </widget>
475 </child>
476 </widget>
477 <packing>
478 <property name="expand">False</property>
479 <property name="homogeneous">False</property>
480 </packing>
481 </child>
482
483 <child>
484 <widget class="GtkToolButton" id="button7">
485 <property name="visible">True</property>
486 <property name="tooltip" translatable="yes">Collapse the whole tree in the right frame</property>
487 <property name="label" translatable="yes">Collapse</property>
488 <property name="use_underline">True</property>
489 <property name="stock_id">gtk-remove</property>
490 <property name="visible_horizontal">True</property>
491 <property name="visible_vertical">True</property>
492 <property name="is_important">False</property>
493 <signal name="clicked" handler="on_collapse_clicked"/>
494 </widget>
495 <packing>
496 <property name="expand">False</property>
497 <property name="homogeneous">True</property>
498 </packing>
499 </child>
500
501 <child>
502 <widget class="GtkToolButton" id="button8">
503 <property name="visible">True</property>
504 <property name="tooltip" translatable="yes">Expand the whole tree in the right frame</property>
505 <property name="label" translatable="yes">Expand</property>
506 <property name="use_underline">True</property>
507 <property name="stock_id">gtk-add</property>
508 <property name="visible_horizontal">True</property>
509 <property name="visible_vertical">True</property>
510 <property name="is_important">False</property>
511 <signal name="clicked" handler="on_expand_clicked"/>
512 </widget>
513 <packing>
514 <property name="expand">False</property>
515 <property name="homogeneous">True</property>
516 </packing>
517 </child>
518 </widget>
519 </child>
520 </widget>
521 <packing>
522 <property name="padding">0</property>
523 <property name="expand">False</property>
524 <property name="fill">False</property>
525 </packing>
526 </child>
527
528 <child>
529 <widget class="GtkHPaned" id="hpaned1">
530 <property name="width_request">1</property>
531 <property name="visible">True</property>
532 <property name="can_focus">True</property>
533 <property name="position">0</property>
534
535 <child>
536 <widget class="GtkScrolledWindow" id="scrolledwindow1">
537 <property name="visible">True</property>
538 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
539 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
540 <property name="shadow_type">GTK_SHADOW_IN</property>
541 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
542
543 <child>
544 <widget class="GtkTreeView" id="treeview1">
545 <property name="visible">True</property>
546 <property name="can_focus">True</property>
547 <property name="headers_visible">True</property>
548 <property name="rules_hint">False</property>
549 <property name="reorderable">False</property>
550 <property name="enable_search">True</property>
551 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/>
552 <signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/>
553 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/>
554 </widget>
555 </child>
556 </widget>
557 <packing>
558 <property name="shrink">True</property>
559 <property name="resize">False</property>
560 </packing>
561 </child>
562
563 <child>
564 <widget class="GtkVPaned" id="vpaned1">
565 <property name="visible">True</property>
566 <property name="can_focus">True</property>
567 <property name="position">0</property>
568
569 <child>
570 <widget class="GtkScrolledWindow" id="scrolledwindow2">
571 <property name="visible">True</property>
572 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
573 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
574 <property name="shadow_type">GTK_SHADOW_IN</property>
575 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
576
577 <child>
578 <widget class="GtkTreeView" id="treeview2">
579 <property name="visible">True</property>
580 <property name="can_focus">True</property>
581 <property name="has_focus">True</property>
582 <property name="headers_visible">True</property>
583 <property name="rules_hint">False</property>
584 <property name="reorderable">False</property>
585 <property name="enable_search">True</property>
586 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/>
587 <signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/>
588 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/>
589 </widget>
590 </child>
591 </widget>
592 <packing>
593 <property name="shrink">True</property>
594 <property name="resize">False</property>
595 </packing>
596 </child>
597
598 <child>
599 <widget class="GtkScrolledWindow" id="scrolledwindow3">
600 <property name="visible">True</property>
601 <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
602 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
603 <property name="shadow_type">GTK_SHADOW_IN</property>
604 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
605
606 <child>
607 <widget class="GtkTextView" id="textview3">
608 <property name="visible">True</property>
609 <property name="can_focus">True</property>
610 <property name="editable">False</property>
611 <property name="overwrite">False</property>
612 <property name="accepts_tab">True</property>
613 <property name="justification">GTK_JUSTIFY_LEFT</property>
614 <property name="wrap_mode">GTK_WRAP_WORD</property>
615 <property name="cursor_visible">True</property>
616 <property name="pixels_above_lines">0</property>
617 <property name="pixels_below_lines">0</property>
618 <property name="pixels_inside_wrap">0</property>
619 <property name="left_margin">0</property>
620 <property name="right_margin">0</property>
621 <property name="indent">0</property>
622 <property name="text" translatable="yes">Sorry, no help available for this option yet.</property>
623 </widget>
624 </child>
625 </widget>
626 <packing>
627 <property name="shrink">True</property>
628 <property name="resize">True</property>
629 </packing>
630 </child>
631 </widget>
632 <packing>
633 <property name="shrink">True</property>
634 <property name="resize">True</property>
635 </packing>
636 </child>
637 </widget>
638 <packing>
639 <property name="padding">0</property>
640 <property name="expand">True</property>
641 <property name="fill">True</property>
642 </packing>
643 </child>
644 </widget>
645 </child>
646</widget>
647
648</glade-interface>
diff --git a/scripts/kconfig/images.c b/scripts/kconfig/images.c
new file mode 100644
index 000000000..d4f84bd4a
--- /dev/null
+++ b/scripts/kconfig/images.c
@@ -0,0 +1,326 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6static const char *xpm_load[] = {
7"22 22 5 1",
8". c None",
9"# c #000000",
10"c c #838100",
11"a c #ffff00",
12"b c #ffffff",
13"......................",
14"......................",
15"......................",
16"............####....#.",
17"...........#....##.##.",
18"..................###.",
19".................####.",
20".####...........#####.",
21"#abab##########.......",
22"#babababababab#.......",
23"#ababababababa#.......",
24"#babababababab#.......",
25"#ababab###############",
26"#babab##cccccccccccc##",
27"#abab##cccccccccccc##.",
28"#bab##cccccccccccc##..",
29"#ab##cccccccccccc##...",
30"#b##cccccccccccc##....",
31"###cccccccccccc##.....",
32"##cccccccccccc##......",
33"###############.......",
34"......................"};
35
36static const char *xpm_save[] = {
37"22 22 5 1",
38". c None",
39"# c #000000",
40"a c #838100",
41"b c #c5c2c5",
42"c c #cdb6d5",
43"......................",
44".####################.",
45".#aa#bbbbbbbbbbbb#bb#.",
46".#aa#bbbbbbbbbbbb#bb#.",
47".#aa#bbbbbbbbbcbb####.",
48".#aa#bbbccbbbbbbb#aa#.",
49".#aa#bbbccbbbbbbb#aa#.",
50".#aa#bbbbbbbbbbbb#aa#.",
51".#aa#bbbbbbbbbbbb#aa#.",
52".#aa#bbbbbbbbbbbb#aa#.",
53".#aa#bbbbbbbbbbbb#aa#.",
54".#aaa############aaa#.",
55".#aaaaaaaaaaaaaaaaaa#.",
56".#aaaaaaaaaaaaaaaaaa#.",
57".#aaa#############aa#.",
58".#aaa#########bbb#aa#.",
59".#aaa#########bbb#aa#.",
60".#aaa#########bbb#aa#.",
61".#aaa#########bbb#aa#.",
62".#aaa#########bbb#aa#.",
63"..##################..",
64"......................"};
65
66static const char *xpm_back[] = {
67"22 22 3 1",
68". c None",
69"# c #000083",
70"a c #838183",
71"......................",
72"......................",
73"......................",
74"......................",
75"......................",
76"...........######a....",
77"..#......##########...",
78"..##...####......##a..",
79"..###.###.........##..",
80"..######..........##..",
81"..#####...........##..",
82"..######..........##..",
83"..#######.........##..",
84"..########.......##a..",
85"...............a###...",
86"...............###....",
87"......................",
88"......................",
89"......................",
90"......................",
91"......................",
92"......................"};
93
94static const char *xpm_tree_view[] = {
95"22 22 2 1",
96". c None",
97"# c #000000",
98"......................",
99"......................",
100"......#...............",
101"......#...............",
102"......#...............",
103"......#...............",
104"......#...............",
105"......########........",
106"......#...............",
107"......#...............",
108"......#...............",
109"......#...............",
110"......#...............",
111"......########........",
112"......#...............",
113"......#...............",
114"......#...............",
115"......#...............",
116"......#...............",
117"......########........",
118"......................",
119"......................"};
120
121static const char *xpm_single_view[] = {
122"22 22 2 1",
123". c None",
124"# c #000000",
125"......................",
126"......................",
127"..........#...........",
128"..........#...........",
129"..........#...........",
130"..........#...........",
131"..........#...........",
132"..........#...........",
133"..........#...........",
134"..........#...........",
135"..........#...........",
136"..........#...........",
137"..........#...........",
138"..........#...........",
139"..........#...........",
140"..........#...........",
141"..........#...........",
142"..........#...........",
143"..........#...........",
144"..........#...........",
145"......................",
146"......................"};
147
148static const char *xpm_split_view[] = {
149"22 22 2 1",
150". c None",
151"# c #000000",
152"......................",
153"......................",
154"......#......#........",
155"......#......#........",
156"......#......#........",
157"......#......#........",
158"......#......#........",
159"......#......#........",
160"......#......#........",
161"......#......#........",
162"......#......#........",
163"......#......#........",
164"......#......#........",
165"......#......#........",
166"......#......#........",
167"......#......#........",
168"......#......#........",
169"......#......#........",
170"......#......#........",
171"......#......#........",
172"......................",
173"......................"};
174
175static const char *xpm_symbol_no[] = {
176"12 12 2 1",
177" c white",
178". c black",
179" ",
180" .......... ",
181" . . ",
182" . . ",
183" . . ",
184" . . ",
185" . . ",
186" . . ",
187" . . ",
188" . . ",
189" .......... ",
190" "};
191
192static const char *xpm_symbol_mod[] = {
193"12 12 2 1",
194" c white",
195". c black",
196" ",
197" .......... ",
198" . . ",
199" . . ",
200" . .. . ",
201" . .... . ",
202" . .... . ",
203" . .. . ",
204" . . ",
205" . . ",
206" .......... ",
207" "};
208
209static const char *xpm_symbol_yes[] = {
210"12 12 2 1",
211" c white",
212". c black",
213" ",
214" .......... ",
215" . . ",
216" . . ",
217" . . . ",
218" . .. . ",
219" . . .. . ",
220" . .... . ",
221" . .. . ",
222" . . ",
223" .......... ",
224" "};
225
226static const char *xpm_choice_no[] = {
227"12 12 2 1",
228" c white",
229". c black",
230" ",
231" .... ",
232" .. .. ",
233" . . ",
234" . . ",
235" . . ",
236" . . ",
237" . . ",
238" . . ",
239" .. .. ",
240" .... ",
241" "};
242
243static const char *xpm_choice_yes[] = {
244"12 12 2 1",
245" c white",
246". c black",
247" ",
248" .... ",
249" .. .. ",
250" . . ",
251" . .. . ",
252" . .... . ",
253" . .... . ",
254" . .. . ",
255" . . ",
256" .. .. ",
257" .... ",
258" "};
259
260static const char *xpm_menu[] = {
261"12 12 2 1",
262" c white",
263". c black",
264" ",
265" .......... ",
266" . . ",
267" . .. . ",
268" . .... . ",
269" . ...... . ",
270" . ...... . ",
271" . .... . ",
272" . .. . ",
273" . . ",
274" .......... ",
275" "};
276
277static const char *xpm_menu_inv[] = {
278"12 12 2 1",
279" c white",
280". c black",
281" ",
282" .......... ",
283" .......... ",
284" .. ...... ",
285" .. .... ",
286" .. .. ",
287" .. .. ",
288" .. .... ",
289" .. ...... ",
290" .......... ",
291" .......... ",
292" "};
293
294static const char *xpm_menuback[] = {
295"12 12 2 1",
296" c white",
297". c black",
298" ",
299" .......... ",
300" . . ",
301" . .. . ",
302" . .... . ",
303" . ...... . ",
304" . ...... . ",
305" . .... . ",
306" . .. . ",
307" . . ",
308" .......... ",
309" "};
310
311static const char *xpm_void[] = {
312"12 12 2 1",
313" c white",
314". c black",
315" ",
316" ",
317" ",
318" ",
319" ",
320" ",
321" ",
322" ",
323" ",
324" ",
325" ",
326" "};
diff --git a/scripts/kconfig/kconfig_load.c b/scripts/kconfig/kconfig_load.c
new file mode 100644
index 000000000..dbdcaad82
--- /dev/null
+++ b/scripts/kconfig/kconfig_load.c
@@ -0,0 +1,35 @@
1#include <dlfcn.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5#include "lkc.h"
6
7#define P(name,type,arg) type (*name ## _p) arg
8#include "lkc_proto.h"
9#undef P
10
11void kconfig_load(void)
12{
13 void *handle;
14 char *error;
15
16 handle = dlopen("./libkconfig.so", RTLD_LAZY);
17 if (!handle) {
18 handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY);
19 if (!handle) {
20 fprintf(stderr, "%s\n", dlerror());
21 exit(1);
22 }
23 }
24
25#define P(name,type,arg) \
26{ \
27 name ## _p = dlsym(handle, #name); \
28 if ((error = dlerror())) { \
29 fprintf(stderr, "%s\n", error); \
30 exit(1); \
31 } \
32}
33#include "lkc_proto.h"
34#undef P
35}
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c
new file mode 100644
index 000000000..abee55ca6
--- /dev/null
+++ b/scripts/kconfig/kxgettext.c
@@ -0,0 +1,227 @@
1/*
2 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 2005
3 *
4 * Released under the terms of the GNU GPL v2.0
5 */
6
7#include <stdlib.h>
8#include <string.h>
9
10#define LKC_DIRECT_LINK
11#include "lkc.h"
12
13static char *escape(const char* text, char *bf, int len)
14{
15 char *bfp = bf;
16 int multiline = strchr(text, '\n') != NULL;
17 int eol = 0;
18 int textlen = strlen(text);
19
20 if ((textlen > 0) && (text[textlen-1] == '\n'))
21 eol = 1;
22
23 *bfp++ = '"';
24 --len;
25
26 if (multiline) {
27 *bfp++ = '"';
28 *bfp++ = '\n';
29 *bfp++ = '"';
30 len -= 3;
31 }
32
33 while (*text != '\0' && len > 1) {
34 if (*text == '"')
35 *bfp++ = '\\';
36 else if (*text == '\n') {
37 *bfp++ = '\\';
38 *bfp++ = 'n';
39 *bfp++ = '"';
40 *bfp++ = '\n';
41 *bfp++ = '"';
42 len -= 5;
43 ++text;
44 goto next;
45 }
46 *bfp++ = *text++;
47next:
48 --len;
49 }
50
51 if (multiline && eol)
52 bfp -= 3;
53
54 *bfp++ = '"';
55 *bfp = '\0';
56
57 return bf;
58}
59
60struct file_line {
61 struct file_line *next;
62 char* file;
63 int lineno;
64};
65
66static struct file_line *file_line__new(char *file, int lineno)
67{
68 struct file_line *self = malloc(sizeof(*self));
69
70 if (self == NULL)
71 goto out;
72
73 self->file = file;
74 self->lineno = lineno;
75 self->next = NULL;
76out:
77 return self;
78}
79
80struct message {
81 const char *msg;
82 const char *option;
83 struct message *next;
84 struct file_line *files;
85};
86
87static struct message *message__list;
88
89static struct message *message__new(const char *msg, char *option, char *file, int lineno)
90{
91 struct message *self = malloc(sizeof(*self));
92
93 if (self == NULL)
94 goto out;
95
96 self->files = file_line__new(file, lineno);
97 if (self->files == NULL)
98 goto out_fail;
99
100 self->msg = strdup(msg);
101 if (self->msg == NULL)
102 goto out_fail_msg;
103
104 self->option = option;
105 self->next = NULL;
106out:
107 return self;
108out_fail_msg:
109 free(self->files);
110out_fail:
111 free(self);
112 self = NULL;
113 goto out;
114}
115
116static struct message *mesage__find(const char *msg)
117{
118 struct message *m = message__list;
119
120 while (m != NULL) {
121 if (strcmp(m->msg, msg) == 0)
122 break;
123 m = m->next;
124 }
125
126 return m;
127}
128
129static int message__add_file_line(struct message *self, char *file, int lineno)
130{
131 int rc = -1;
132 struct file_line *fl = file_line__new(file, lineno);
133
134 if (fl == NULL)
135 goto out;
136
137 fl->next = self->files;
138 self->files = fl;
139 rc = 0;
140out:
141 return rc;
142}
143
144static int message__add(const char *msg, char *option, char *file, int lineno)
145{
146 int rc = 0;
147 char bf[16384];
148 char *escaped = escape(msg, bf, sizeof(bf));
149 struct message *m = mesage__find(escaped);
150
151 if (m != NULL)
152 rc = message__add_file_line(m, file, lineno);
153 else {
154 m = message__new(escaped, option, file, lineno);
155
156 if (m != NULL) {
157 m->next = message__list;
158 message__list = m;
159 } else
160 rc = -1;
161 }
162 return rc;
163}
164
165void menu_build_message_list(struct menu *menu)
166{
167 struct menu *child;
168
169 message__add(menu_get_prompt(menu), NULL,
170 menu->file == NULL ? "Root Menu" : menu->file->name,
171 menu->lineno);
172
173 if (menu->sym != NULL && menu->sym->help != NULL)
174 message__add(menu->sym->help, menu->sym->name,
175 menu->file == NULL ? "Root Menu" : menu->file->name,
176 menu->lineno);
177
178 for (child = menu->list; child != NULL; child = child->next)
179 if (child->prompt != NULL)
180 menu_build_message_list(child);
181}
182
183static void message__print_file_lineno(struct message *self)
184{
185 struct file_line *fl = self->files;
186
187 putchar('\n');
188 if (self->option != NULL)
189 printf("# %s:00000\n", self->option);
190
191 printf("#: %s:%d", fl->file, fl->lineno);
192 fl = fl->next;
193
194 while (fl != NULL) {
195 printf(", %s:%d", fl->file, fl->lineno);
196 fl = fl->next;
197 }
198
199 putchar('\n');
200}
201
202static void message__print_gettext_msgid_msgstr(struct message *self)
203{
204 message__print_file_lineno(self);
205
206 printf("msgid %s\n"
207 "msgstr \"\"\n", self->msg);
208}
209
210void menu__xgettext(void)
211{
212 struct message *m = message__list;
213
214 while (m != NULL) {
215 message__print_gettext_msgid_msgstr(m);
216 m = m->next;
217 }
218}
219
220int main(int ac, char **av)
221{
222 conf_parse(av[1]);
223
224 menu_build_message_list(menu_get_root_menu(NULL));
225 menu__xgettext();
226 return 0;
227}
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped
new file mode 100644
index 000000000..24e3c8cbb
--- /dev/null
+++ b/scripts/kconfig/lex.zconf.c_shipped
@@ -0,0 +1,2317 @@
1
2#line 3 "scripts/kconfig/lex.zconf.c"
3
4#define YY_INT_ALIGNED short int
5
6/* A lexical scanner generated by flex */
7
8#define FLEX_SCANNER
9#define YY_FLEX_MAJOR_VERSION 2
10#define YY_FLEX_MINOR_VERSION 5
11#define YY_FLEX_SUBMINOR_VERSION 31
12#if YY_FLEX_SUBMINOR_VERSION > 0
13#define FLEX_BETA
14#endif
15
16/* First, we deal with platform-specific or compiler-specific issues. */
17
18/* begin standard C headers. */
19#include <stdio.h>
20#include <string.h>
21#include <errno.h>
22#include <stdlib.h>
23
24/* end standard C headers. */
25
26/* flex integer type definitions */
27
28#ifndef FLEXINT_H
29#define FLEXINT_H
30
31/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
33#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
34#include <inttypes.h>
35typedef int8_t flex_int8_t;
36typedef uint8_t flex_uint8_t;
37typedef int16_t flex_int16_t;
38typedef uint16_t flex_uint16_t;
39typedef int32_t flex_int32_t;
40typedef uint32_t flex_uint32_t;
41#else
42typedef signed char flex_int8_t;
43typedef short int flex_int16_t;
44typedef int flex_int32_t;
45typedef unsigned char flex_uint8_t;
46typedef unsigned short int flex_uint16_t;
47typedef unsigned int flex_uint32_t;
48#endif /* ! C99 */
49
50/* Limits of integral types. */
51#ifndef INT8_MIN
52#define INT8_MIN (-128)
53#endif
54#ifndef INT16_MIN
55#define INT16_MIN (-32767-1)
56#endif
57#ifndef INT32_MIN
58#define INT32_MIN (-2147483647-1)
59#endif
60#ifndef INT8_MAX
61#define INT8_MAX (127)
62#endif
63#ifndef INT16_MAX
64#define INT16_MAX (32767)
65#endif
66#ifndef INT32_MAX
67#define INT32_MAX (2147483647)
68#endif
69#ifndef UINT8_MAX
70#define UINT8_MAX (255U)
71#endif
72#ifndef UINT16_MAX
73#define UINT16_MAX (65535U)
74#endif
75#ifndef UINT32_MAX
76#define UINT32_MAX (4294967295U)
77#endif
78
79#endif /* ! FLEXINT_H */
80
81#ifdef __cplusplus
82
83/* The "const" storage-class-modifier is valid. */
84#define YY_USE_CONST
85
86#else /* ! __cplusplus */
87
88#if __STDC__
89
90#define YY_USE_CONST
91
92#endif /* __STDC__ */
93#endif /* ! __cplusplus */
94
95#ifdef YY_USE_CONST
96#define yyconst const
97#else
98#define yyconst
99#endif
100
101/* Returned upon end-of-file. */
102#define YY_NULL 0
103
104/* Promotes a possibly negative, possibly signed char to an unsigned
105 * integer for use as an array index. If the signed char is negative,
106 * we want to instead treat it as an 8-bit unsigned char, hence the
107 * double cast.
108 */
109#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
110
111/* Enter a start condition. This macro really ought to take a parameter,
112 * but we do it the disgusting crufty way forced on us by the ()-less
113 * definition of BEGIN.
114 */
115#define BEGIN (yy_start) = 1 + 2 *
116
117/* Translate the current start state into a value that can be later handed
118 * to BEGIN to return to the state. The YYSTATE alias is for lex
119 * compatibility.
120 */
121#define YY_START (((yy_start) - 1) / 2)
122#define YYSTATE YY_START
123
124/* Action number for EOF rule of a given start state. */
125#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
126
127/* Special action meaning "start processing a new file". */
128#define YY_NEW_FILE zconfrestart(zconfin )
129
130#define YY_END_OF_BUFFER_CHAR 0
131
132/* Size of default input buffer. */
133#ifndef YY_BUF_SIZE
134#define YY_BUF_SIZE 16384
135#endif
136
137#ifndef YY_TYPEDEF_YY_BUFFER_STATE
138#define YY_TYPEDEF_YY_BUFFER_STATE
139typedef struct yy_buffer_state *YY_BUFFER_STATE;
140#endif
141
142extern int zconfleng;
143
144extern FILE *zconfin, *zconfout;
145
146#define EOB_ACT_CONTINUE_SCAN 0
147#define EOB_ACT_END_OF_FILE 1
148#define EOB_ACT_LAST_MATCH 2
149
150 #define YY_LESS_LINENO(n)
151
152/* Return all but the first "n" matched characters back to the input stream. */
153#define yyless(n) \
154 do \
155 { \
156 /* Undo effects of setting up zconftext. */ \
157 int yyless_macro_arg = (n); \
158 YY_LESS_LINENO(yyless_macro_arg);\
159 *yy_cp = (yy_hold_char); \
160 YY_RESTORE_YY_MORE_OFFSET \
161 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
162 YY_DO_BEFORE_ACTION; /* set up zconftext again */ \
163 } \
164 while ( 0 )
165
166#define unput(c) yyunput( c, (yytext_ptr) )
167
168/* The following is because we cannot portably get our hands on size_t
169 * (without autoconf's help, which isn't available because we want
170 * flex-generated scanners to compile on their own).
171 */
172
173#ifndef YY_TYPEDEF_YY_SIZE_T
174#define YY_TYPEDEF_YY_SIZE_T
175typedef unsigned int yy_size_t;
176#endif
177
178#ifndef YY_STRUCT_YY_BUFFER_STATE
179#define YY_STRUCT_YY_BUFFER_STATE
180struct yy_buffer_state
181 {
182 FILE *yy_input_file;
183
184 char *yy_ch_buf; /* input buffer */
185 char *yy_buf_pos; /* current position in input buffer */
186
187 /* Size of input buffer in bytes, not including room for EOB
188 * characters.
189 */
190 yy_size_t yy_buf_size;
191
192 /* Number of characters read into yy_ch_buf, not including EOB
193 * characters.
194 */
195 int yy_n_chars;
196
197 /* Whether we "own" the buffer - i.e., we know we created it,
198 * and can realloc() it to grow it, and should free() it to
199 * delete it.
200 */
201 int yy_is_our_buffer;
202
203 /* Whether this is an "interactive" input source; if so, and
204 * if we're using stdio for input, then we want to use getc()
205 * instead of fread(), to make sure we stop fetching input after
206 * each newline.
207 */
208 int yy_is_interactive;
209
210 /* Whether we're considered to be at the beginning of a line.
211 * If so, '^' rules will be active on the next match, otherwise
212 * not.
213 */
214 int yy_at_bol;
215
216 int yy_bs_lineno; /**< The line count. */
217 int yy_bs_column; /**< The column count. */
218
219 /* Whether to try to fill the input buffer when we reach the
220 * end of it.
221 */
222 int yy_fill_buffer;
223
224 int yy_buffer_status;
225
226#define YY_BUFFER_NEW 0
227#define YY_BUFFER_NORMAL 1
228 /* When an EOF's been seen but there's still some text to process
229 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
230 * shouldn't try reading from the input source any more. We might
231 * still have a bunch of tokens to match, though, because of
232 * possible backing-up.
233 *
234 * When we actually see the EOF, we change the status to "new"
235 * (via zconfrestart()), so that the user can continue scanning by
236 * just pointing zconfin at a new input file.
237 */
238#define YY_BUFFER_EOF_PENDING 2
239
240 };
241#endif /* !YY_STRUCT_YY_BUFFER_STATE */
242
243/* Stack of input buffers. */
244static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
245static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
246static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
247
248/* We provide macros for accessing buffer states in case in the
249 * future we want to put the buffer states in a more general
250 * "scanner state".
251 *
252 * Returns the top of the stack, or NULL.
253 */
254#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
255 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
256 : NULL)
257
258/* Same as previous macro, but useful when we know that the buffer stack is not
259 * NULL or when we need an lvalue. For internal use only.
260 */
261#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
262
263/* yy_hold_char holds the character lost when zconftext is formed. */
264static char yy_hold_char;
265static int yy_n_chars; /* number of characters read into yy_ch_buf */
266int zconfleng;
267
268/* Points to current character in buffer. */
269static char *yy_c_buf_p = (char *) 0;
270static int yy_init = 1; /* whether we need to initialize */
271static int yy_start = 0; /* start state number */
272
273/* Flag which is used to allow zconfwrap()'s to do buffer switches
274 * instead of setting up a fresh zconfin. A bit of a hack ...
275 */
276static int yy_did_buffer_switch_on_eof;
277
278void zconfrestart (FILE *input_file );
279void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer );
280YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size );
281void zconf_delete_buffer (YY_BUFFER_STATE b );
282void zconf_flush_buffer (YY_BUFFER_STATE b );
283void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer );
284void zconfpop_buffer_state (void );
285
286static void zconfensure_buffer_stack (void );
287static void zconf_load_buffer_state (void );
288static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file );
289
290#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER )
291
292YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size );
293YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str );
294YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len );
295
296void *zconfalloc (yy_size_t );
297void *zconfrealloc (void *,yy_size_t );
298void zconffree (void * );
299
300#define yy_new_buffer zconf_create_buffer
301
302#define yy_set_interactive(is_interactive) \
303 { \
304 if ( ! YY_CURRENT_BUFFER ){ \
305 zconfensure_buffer_stack (); \
306 YY_CURRENT_BUFFER_LVALUE = \
307 zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
308 } \
309 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
310 }
311
312#define yy_set_bol(at_bol) \
313 { \
314 if ( ! YY_CURRENT_BUFFER ){\
315 zconfensure_buffer_stack (); \
316 YY_CURRENT_BUFFER_LVALUE = \
317 zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
318 } \
319 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
320 }
321
322#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
323
324/* Begin user sect3 */
325
326#define zconfwrap() 1
327#define YY_SKIP_YYWRAP
328
329typedef unsigned char YY_CHAR;
330
331FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0;
332
333typedef int yy_state_type;
334
335extern int zconflineno;
336
337int zconflineno = 1;
338
339extern char *zconftext;
340#define yytext_ptr zconftext
341static yyconst flex_int16_t yy_nxt[][17] =
342 {
343 {
344 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 0, 0
346 },
347
348 {
349 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
350 12, 12, 12, 12, 12, 12, 12
351 },
352
353 {
354 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
355 12, 12, 12, 12, 12, 12, 12
356 },
357
358 {
359 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
360 16, 16, 16, 18, 16, 16, 16
361 },
362
363 {
364 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
365 16, 16, 16, 18, 16, 16, 16
366
367 },
368
369 {
370 11, 19, 20, 21, 19, 19, 19, 19, 19, 19,
371 19, 19, 19, 19, 19, 19, 19
372 },
373
374 {
375 11, 19, 20, 21, 19, 19, 19, 19, 19, 19,
376 19, 19, 19, 19, 19, 19, 19
377 },
378
379 {
380 11, 22, 22, 23, 22, 24, 22, 22, 24, 22,
381 22, 22, 22, 22, 22, 25, 22
382 },
383
384 {
385 11, 22, 22, 23, 22, 24, 22, 22, 24, 22,
386 22, 22, 22, 22, 22, 25, 22
387 },
388
389 {
390 11, 26, 26, 27, 28, 29, 30, 31, 29, 32,
391 33, 34, 35, 35, 36, 37, 38
392
393 },
394
395 {
396 11, 26, 26, 27, 28, 29, 30, 31, 29, 32,
397 33, 34, 35, 35, 36, 37, 38
398 },
399
400 {
401 -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
402 -11, -11, -11, -11, -11, -11, -11
403 },
404
405 {
406 11, -12, -12, -12, -12, -12, -12, -12, -12, -12,
407 -12, -12, -12, -12, -12, -12, -12
408 },
409
410 {
411 11, -13, 39, 40, -13, -13, 41, -13, -13, -13,
412 -13, -13, -13, -13, -13, -13, -13
413 },
414
415 {
416 11, -14, -14, -14, -14, -14, -14, -14, -14, -14,
417 -14, -14, -14, -14, -14, -14, -14
418
419 },
420
421 {
422 11, 42, 42, 43, 42, 42, 42, 42, 42, 42,
423 42, 42, 42, 42, 42, 42, 42
424 },
425
426 {
427 11, -16, -16, -16, -16, -16, -16, -16, -16, -16,
428 -16, -16, -16, -16, -16, -16, -16
429 },
430
431 {
432 11, -17, -17, -17, -17, -17, -17, -17, -17, -17,
433 -17, -17, -17, -17, -17, -17, -17
434 },
435
436 {
437 11, -18, -18, -18, -18, -18, -18, -18, -18, -18,
438 -18, -18, -18, 44, -18, -18, -18
439 },
440
441 {
442 11, 45, 45, -19, 45, 45, 45, 45, 45, 45,
443 45, 45, 45, 45, 45, 45, 45
444
445 },
446
447 {
448 11, -20, 46, 47, -20, -20, -20, -20, -20, -20,
449 -20, -20, -20, -20, -20, -20, -20
450 },
451
452 {
453 11, 48, -21, -21, 48, 48, 48, 48, 48, 48,
454 48, 48, 48, 48, 48, 48, 48
455 },
456
457 {
458 11, 49, 49, 50, 49, -22, 49, 49, -22, 49,
459 49, 49, 49, 49, 49, -22, 49
460 },
461
462 {
463 11, -23, -23, -23, -23, -23, -23, -23, -23, -23,
464 -23, -23, -23, -23, -23, -23, -23
465 },
466
467 {
468 11, -24, -24, -24, -24, -24, -24, -24, -24, -24,
469 -24, -24, -24, -24, -24, -24, -24
470
471 },
472
473 {
474 11, 51, 51, 52, 51, 51, 51, 51, 51, 51,
475 51, 51, 51, 51, 51, 51, 51
476 },
477
478 {
479 11, -26, -26, -26, -26, -26, -26, -26, -26, -26,
480 -26, -26, -26, -26, -26, -26, -26
481 },
482
483 {
484 11, -27, -27, -27, -27, -27, -27, -27, -27, -27,
485 -27, -27, -27, -27, -27, -27, -27
486 },
487
488 {
489 11, -28, -28, -28, -28, -28, -28, -28, -28, -28,
490 -28, -28, -28, -28, 53, -28, -28
491 },
492
493 {
494 11, -29, -29, -29, -29, -29, -29, -29, -29, -29,
495 -29, -29, -29, -29, -29, -29, -29
496
497 },
498
499 {
500 11, 54, 54, -30, 54, 54, 54, 54, 54, 54,
501 54, 54, 54, 54, 54, 54, 54
502 },
503
504 {
505 11, -31, -31, -31, -31, -31, -31, 55, -31, -31,
506 -31, -31, -31, -31, -31, -31, -31
507 },
508
509 {
510 11, -32, -32, -32, -32, -32, -32, -32, -32, -32,
511 -32, -32, -32, -32, -32, -32, -32
512 },
513
514 {
515 11, -33, -33, -33, -33, -33, -33, -33, -33, -33,
516 -33, -33, -33, -33, -33, -33, -33
517 },
518
519 {
520 11, -34, -34, -34, -34, -34, -34, -34, -34, -34,
521 -34, 56, 57, 57, -34, -34, -34
522
523 },
524
525 {
526 11, -35, -35, -35, -35, -35, -35, -35, -35, -35,
527 -35, 57, 57, 57, -35, -35, -35
528 },
529
530 {
531 11, -36, -36, -36, -36, -36, -36, -36, -36, -36,
532 -36, -36, -36, -36, -36, -36, -36
533 },
534
535 {
536 11, -37, -37, 58, -37, -37, -37, -37, -37, -37,
537 -37, -37, -37, -37, -37, -37, -37
538 },
539
540 {
541 11, -38, -38, -38, -38, -38, -38, -38, -38, -38,
542 -38, -38, -38, -38, -38, -38, 59
543 },
544
545 {
546 11, -39, 39, 40, -39, -39, 41, -39, -39, -39,
547 -39, -39, -39, -39, -39, -39, -39
548
549 },
550
551 {
552 11, -40, -40, -40, -40, -40, -40, -40, -40, -40,
553 -40, -40, -40, -40, -40, -40, -40
554 },
555
556 {
557 11, 42, 42, 43, 42, 42, 42, 42, 42, 42,
558 42, 42, 42, 42, 42, 42, 42
559 },
560
561 {
562 11, 42, 42, 43, 42, 42, 42, 42, 42, 42,
563 42, 42, 42, 42, 42, 42, 42
564 },
565
566 {
567 11, -43, -43, -43, -43, -43, -43, -43, -43, -43,
568 -43, -43, -43, -43, -43, -43, -43
569 },
570
571 {
572 11, -44, -44, -44, -44, -44, -44, -44, -44, -44,
573 -44, -44, -44, 44, -44, -44, -44
574
575 },
576
577 {
578 11, 45, 45, -45, 45, 45, 45, 45, 45, 45,
579 45, 45, 45, 45, 45, 45, 45
580 },
581
582 {
583 11, -46, 46, 47, -46, -46, -46, -46, -46, -46,
584 -46, -46, -46, -46, -46, -46, -46
585 },
586
587 {
588 11, 48, -47, -47, 48, 48, 48, 48, 48, 48,
589 48, 48, 48, 48, 48, 48, 48
590 },
591
592 {
593 11, -48, -48, -48, -48, -48, -48, -48, -48, -48,
594 -48, -48, -48, -48, -48, -48, -48
595 },
596
597 {
598 11, 49, 49, 50, 49, -49, 49, 49, -49, 49,
599 49, 49, 49, 49, 49, -49, 49
600
601 },
602
603 {
604 11, -50, -50, -50, -50, -50, -50, -50, -50, -50,
605 -50, -50, -50, -50, -50, -50, -50
606 },
607
608 {
609 11, -51, -51, 52, -51, -51, -51, -51, -51, -51,
610 -51, -51, -51, -51, -51, -51, -51
611 },
612
613 {
614 11, -52, -52, -52, -52, -52, -52, -52, -52, -52,
615 -52, -52, -52, -52, -52, -52, -52
616 },
617
618 {
619 11, -53, -53, -53, -53, -53, -53, -53, -53, -53,
620 -53, -53, -53, -53, -53, -53, -53
621 },
622
623 {
624 11, 54, 54, -54, 54, 54, 54, 54, 54, 54,
625 54, 54, 54, 54, 54, 54, 54
626
627 },
628
629 {
630 11, -55, -55, -55, -55, -55, -55, -55, -55, -55,
631 -55, -55, -55, -55, -55, -55, -55
632 },
633
634 {
635 11, -56, -56, -56, -56, -56, -56, -56, -56, -56,
636 -56, 60, 57, 57, -56, -56, -56
637 },
638
639 {
640 11, -57, -57, -57, -57, -57, -57, -57, -57, -57,
641 -57, 57, 57, 57, -57, -57, -57
642 },
643
644 {
645 11, -58, -58, -58, -58, -58, -58, -58, -58, -58,
646 -58, -58, -58, -58, -58, -58, -58
647 },
648
649 {
650 11, -59, -59, -59, -59, -59, -59, -59, -59, -59,
651 -59, -59, -59, -59, -59, -59, -59
652
653 },
654
655 {
656 11, -60, -60, -60, -60, -60, -60, -60, -60, -60,
657 -60, 57, 57, 57, -60, -60, -60
658 },
659
660 } ;
661
662static yy_state_type yy_get_previous_state (void );
663static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
664static int yy_get_next_buffer (void );
665static void yy_fatal_error (yyconst char msg[] );
666
667/* Done after the current pattern has been matched and before the
668 * corresponding action - sets up zconftext.
669 */
670#define YY_DO_BEFORE_ACTION \
671 (yytext_ptr) = yy_bp; \
672 zconfleng = (size_t) (yy_cp - yy_bp); \
673 (yy_hold_char) = *yy_cp; \
674 *yy_cp = '\0'; \
675 (yy_c_buf_p) = yy_cp;
676
677#define YY_NUM_RULES 33
678#define YY_END_OF_BUFFER 34
679/* This struct is not used in this scanner,
680 but its presence is necessary. */
681struct yy_trans_info
682 {
683 flex_int32_t yy_verify;
684 flex_int32_t yy_nxt;
685 };
686static yyconst flex_int16_t yy_accept[61] =
687 { 0,
688 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
689 34, 5, 4, 2, 3, 7, 8, 6, 32, 29,
690 31, 24, 28, 27, 26, 22, 17, 13, 16, 20,
691 22, 11, 12, 19, 19, 14, 22, 22, 4, 2,
692 3, 3, 1, 6, 32, 29, 31, 30, 24, 23,
693 26, 25, 15, 20, 9, 19, 19, 21, 10, 18
694 } ;
695
696static yyconst flex_int32_t yy_ec[256] =
697 { 0,
698 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
699 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
700 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
701 1, 2, 4, 5, 6, 1, 1, 7, 8, 9,
702 10, 1, 1, 1, 11, 12, 12, 13, 13, 13,
703 13, 13, 13, 13, 13, 13, 13, 1, 1, 1,
704 14, 1, 1, 1, 13, 13, 13, 13, 13, 13,
705 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
706 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
707 1, 15, 1, 1, 13, 1, 13, 13, 13, 13,
708
709 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
710 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
711 13, 13, 1, 16, 1, 1, 1, 1, 1, 1,
712 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
713 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
714 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
715 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
716 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
717 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
718 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
719
720 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
721 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
722 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
723 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
724 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
725 1, 1, 1, 1, 1
726 } ;
727
728extern int zconf_flex_debug;
729int zconf_flex_debug = 0;
730
731/* The intent behind this definition is that it'll catch
732 * any uses of REJECT which flex missed.
733 */
734#define REJECT reject_used_but_not_detected
735#define yymore() yymore_used_but_not_detected
736#define YY_MORE_ADJ 0
737#define YY_RESTORE_YY_MORE_OFFSET
738char *zconftext;
739
740/*
741 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
742 * Released under the terms of the GNU GPL v2.0.
743 */
744
745#include <limits.h>
746#include <stdio.h>
747#include <stdlib.h>
748#include <string.h>
749#include <unistd.h>
750
751#define LKC_DIRECT_LINK
752#include "lkc.h"
753
754#define START_STRSIZE 16
755
756static struct {
757 struct file *file;
758 int lineno;
759} current_pos;
760
761static char *text;
762static int text_size, text_asize;
763
764struct buffer {
765 struct buffer *parent;
766 YY_BUFFER_STATE state;
767};
768
769struct buffer *current_buf;
770
771static int last_ts, first_ts;
772
773static void zconf_endhelp(void);
774static void zconf_endfile(void);
775
776void new_string(void)
777{
778 text = malloc(START_STRSIZE);
779 text_asize = START_STRSIZE;
780 text_size = 0;
781 *text = 0;
782}
783
784void append_string(const char *str, int size)
785{
786 int new_size = text_size + size + 1;
787 if (new_size > text_asize) {
788 new_size += START_STRSIZE - 1;
789 new_size &= -START_STRSIZE;
790 text = realloc(text, new_size);
791 text_asize = new_size;
792 }
793 memcpy(text + text_size, str, size);
794 text_size += size;
795 text[text_size] = 0;
796}
797
798void alloc_string(const char *str, int size)
799{
800 text = malloc(size + 1);
801 memcpy(text, str, size);
802 text[size] = 0;
803}
804
805#define INITIAL 0
806#define COMMAND 1
807#define HELP 2
808#define STRING 3
809#define PARAM 4
810
811#ifndef YY_NO_UNISTD_H
812/* Special case for "unistd.h", since it is non-ANSI. We include it way
813 * down here because we want the user's section 1 to have been scanned first.
814 * The user has a chance to override it with an option.
815 */
816#include <unistd.h>
817#endif
818
819#ifndef YY_EXTRA_TYPE
820#define YY_EXTRA_TYPE void *
821#endif
822
823/* Macros after this point can all be overridden by user definitions in
824 * section 1.
825 */
826
827#ifndef YY_SKIP_YYWRAP
828#ifdef __cplusplus
829extern "C" int zconfwrap (void );
830#else
831extern int zconfwrap (void );
832#endif
833#endif
834
835 static void yyunput (int c,char *buf_ptr );
836
837#ifndef yytext_ptr
838static void yy_flex_strncpy (char *,yyconst char *,int );
839#endif
840
841#ifdef YY_NEED_STRLEN
842static int yy_flex_strlen (yyconst char * );
843#endif
844
845#ifndef YY_NO_INPUT
846
847#ifdef __cplusplus
848static int yyinput (void );
849#else
850static int input (void );
851#endif
852
853#endif
854
855/* Amount of stuff to slurp up with each read. */
856#ifndef YY_READ_BUF_SIZE
857#define YY_READ_BUF_SIZE 8192
858#endif
859
860/* Copy whatever the last rule matched to the standard output. */
861#ifndef ECHO
862/* This used to be an fputs(), but since the string might contain NUL's,
863 * we now use fwrite().
864 */
865#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout )
866#endif
867
868/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
869 * is returned in "result".
870 */
871#ifndef YY_INPUT
872#define YY_INPUT(buf,result,max_size) \
873 errno=0; \
874 while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \
875 { \
876 if( errno != EINTR) \
877 { \
878 YY_FATAL_ERROR( "input in flex scanner failed" ); \
879 break; \
880 } \
881 errno=0; \
882 clearerr(zconfin); \
883 }\
884\
885
886#endif
887
888/* No semi-colon after return; correct usage is to write "yyterminate();" -
889 * we don't want an extra ';' after the "return" because that will cause
890 * some compilers to complain about unreachable statements.
891 */
892#ifndef yyterminate
893#define yyterminate() return YY_NULL
894#endif
895
896/* Number of entries by which start-condition stack grows. */
897#ifndef YY_START_STACK_INCR
898#define YY_START_STACK_INCR 25
899#endif
900
901/* Report a fatal error. */
902#ifndef YY_FATAL_ERROR
903#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
904#endif
905
906/* end tables serialization structures and prototypes */
907
908/* Default declaration of generated scanner - a define so the user can
909 * easily add parameters.
910 */
911#ifndef YY_DECL
912#define YY_DECL_IS_OURS 1
913
914extern int zconflex (void);
915
916#define YY_DECL int zconflex (void)
917#endif /* !YY_DECL */
918
919/* Code executed at the beginning of each rule, after zconftext and zconfleng
920 * have been set up.
921 */
922#ifndef YY_USER_ACTION
923#define YY_USER_ACTION
924#endif
925
926/* Code executed at the end of each rule. */
927#ifndef YY_BREAK
928#define YY_BREAK break;
929#endif
930
931#define YY_RULE_SETUP \
932 YY_USER_ACTION
933
934/** The main scanner function which does all the work.
935 */
936YY_DECL
937{
938 register yy_state_type yy_current_state;
939 register char *yy_cp, *yy_bp;
940 register int yy_act;
941
942 int str = 0;
943 int ts, i;
944
945 if ( (yy_init) )
946 {
947 (yy_init) = 0;
948
949#ifdef YY_USER_INIT
950 YY_USER_INIT;
951#endif
952
953 if ( ! (yy_start) )
954 (yy_start) = 1; /* first start state */
955
956 if ( ! zconfin )
957 zconfin = stdin;
958
959 if ( ! zconfout )
960 zconfout = stdout;
961
962 if ( ! YY_CURRENT_BUFFER ) {
963 zconfensure_buffer_stack ();
964 YY_CURRENT_BUFFER_LVALUE =
965 zconf_create_buffer(zconfin,YY_BUF_SIZE );
966 }
967
968 zconf_load_buffer_state( );
969 }
970
971 while ( 1 ) /* loops until end-of-file is reached */
972 {
973 yy_cp = (yy_c_buf_p);
974
975 /* Support of zconftext. */
976 *yy_cp = (yy_hold_char);
977
978 /* yy_bp points to the position in yy_ch_buf of the start of
979 * the current run.
980 */
981 yy_bp = yy_cp;
982
983 yy_current_state = (yy_start);
984yy_match:
985 while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 )
986 ++yy_cp;
987
988 yy_current_state = -yy_current_state;
989
990yy_find_action:
991 yy_act = yy_accept[yy_current_state];
992
993 YY_DO_BEFORE_ACTION;
994
995do_action: /* This label is used only to access EOF actions. */
996
997 switch ( yy_act )
998 { /* beginning of action switch */
999case 1:
1000/* rule 1 can match eol */
1001case 2:
1002/* rule 2 can match eol */
1003YY_RULE_SETUP
1004{
1005 current_file->lineno++;
1006 return T_EOL;
1007}
1008 YY_BREAK
1009case 3:
1010YY_RULE_SETUP
1011
1012 YY_BREAK
1013case 4:
1014YY_RULE_SETUP
1015{
1016 BEGIN(COMMAND);
1017}
1018 YY_BREAK
1019case 5:
1020YY_RULE_SETUP
1021{
1022 unput(zconftext[0]);
1023 BEGIN(COMMAND);
1024}
1025 YY_BREAK
1026
1027case 6:
1028YY_RULE_SETUP
1029{
1030 struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
1031 BEGIN(PARAM);
1032 current_pos.file = current_file;
1033 current_pos.lineno = current_file->lineno;
1034 if (id && id->flags & TF_COMMAND) {
1035 zconflval.id = id;
1036 return id->token;
1037 }
1038 alloc_string(zconftext, zconfleng);
1039 zconflval.string = text;
1040 return T_WORD;
1041 }
1042 YY_BREAK
1043case 7:
1044YY_RULE_SETUP
1045
1046 YY_BREAK
1047case 8:
1048/* rule 8 can match eol */
1049YY_RULE_SETUP
1050{
1051 BEGIN(INITIAL);
1052 current_file->lineno++;
1053 return T_EOL;
1054 }
1055 YY_BREAK
1056
1057case 9:
1058YY_RULE_SETUP
1059return T_AND;
1060 YY_BREAK
1061case 10:
1062YY_RULE_SETUP
1063return T_OR;
1064 YY_BREAK
1065case 11:
1066YY_RULE_SETUP
1067return T_OPEN_PAREN;
1068 YY_BREAK
1069case 12:
1070YY_RULE_SETUP
1071return T_CLOSE_PAREN;
1072 YY_BREAK
1073case 13:
1074YY_RULE_SETUP
1075return T_NOT;
1076 YY_BREAK
1077case 14:
1078YY_RULE_SETUP
1079return T_EQUAL;
1080 YY_BREAK
1081case 15:
1082YY_RULE_SETUP
1083return T_UNEQUAL;
1084 YY_BREAK
1085case 16:
1086YY_RULE_SETUP
1087{
1088 str = zconftext[0];
1089 new_string();
1090 BEGIN(STRING);
1091 }
1092 YY_BREAK
1093case 17:
1094/* rule 17 can match eol */
1095YY_RULE_SETUP
1096BEGIN(INITIAL); current_file->lineno++; return T_EOL;
1097 YY_BREAK
1098case 18:
1099YY_RULE_SETUP
1100/* ignore */
1101 YY_BREAK
1102case 19:
1103YY_RULE_SETUP
1104{
1105 struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
1106 if (id && id->flags & TF_PARAM) {
1107 zconflval.id = id;
1108 return id->token;
1109 }
1110 alloc_string(zconftext, zconfleng);
1111 zconflval.string = text;
1112 return T_WORD;
1113 }
1114 YY_BREAK
1115case 20:
1116YY_RULE_SETUP
1117/* comment */
1118 YY_BREAK
1119case 21:
1120/* rule 21 can match eol */
1121YY_RULE_SETUP
1122current_file->lineno++;
1123 YY_BREAK
1124case 22:
1125YY_RULE_SETUP
1126
1127 YY_BREAK
1128case YY_STATE_EOF(PARAM):
1129{
1130 BEGIN(INITIAL);
1131 }
1132 YY_BREAK
1133
1134case 23:
1135/* rule 23 can match eol */
1136*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
1137(yy_c_buf_p) = yy_cp -= 1;
1138YY_DO_BEFORE_ACTION; /* set up zconftext again */
1139YY_RULE_SETUP
1140{
1141 append_string(zconftext, zconfleng);
1142 zconflval.string = text;
1143 return T_WORD_QUOTE;
1144 }
1145 YY_BREAK
1146case 24:
1147YY_RULE_SETUP
1148{
1149 append_string(zconftext, zconfleng);
1150 }
1151 YY_BREAK
1152case 25:
1153/* rule 25 can match eol */
1154*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
1155(yy_c_buf_p) = yy_cp -= 1;
1156YY_DO_BEFORE_ACTION; /* set up zconftext again */
1157YY_RULE_SETUP
1158{
1159 append_string(zconftext + 1, zconfleng - 1);
1160 zconflval.string = text;
1161 return T_WORD_QUOTE;
1162 }
1163 YY_BREAK
1164case 26:
1165YY_RULE_SETUP
1166{
1167 append_string(zconftext + 1, zconfleng - 1);
1168 }
1169 YY_BREAK
1170case 27:
1171YY_RULE_SETUP
1172{
1173 if (str == zconftext[0]) {
1174 BEGIN(PARAM);
1175 zconflval.string = text;
1176 return T_WORD_QUOTE;
1177 } else
1178 append_string(zconftext, 1);
1179 }
1180 YY_BREAK
1181case 28:
1182/* rule 28 can match eol */
1183YY_RULE_SETUP
1184{
1185 printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
1186 current_file->lineno++;
1187 BEGIN(INITIAL);
1188 return T_EOL;
1189 }
1190 YY_BREAK
1191case YY_STATE_EOF(STRING):
1192{
1193 BEGIN(INITIAL);
1194 }
1195 YY_BREAK
1196
1197case 29:
1198YY_RULE_SETUP
1199{
1200 ts = 0;
1201 for (i = 0; i < zconfleng; i++) {
1202 if (zconftext[i] == '\t')
1203 ts = (ts & ~7) + 8;
1204 else
1205 ts++;
1206 }
1207 last_ts = ts;
1208 if (first_ts) {
1209 if (ts < first_ts) {
1210 zconf_endhelp();
1211 return T_HELPTEXT;
1212 }
1213 ts -= first_ts;
1214 while (ts > 8) {
1215 append_string(" ", 8);
1216 ts -= 8;
1217 }
1218 append_string(" ", ts);
1219 }
1220 }
1221 YY_BREAK
1222case 30:
1223/* rule 30 can match eol */
1224*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
1225(yy_c_buf_p) = yy_cp -= 1;
1226YY_DO_BEFORE_ACTION; /* set up zconftext again */
1227YY_RULE_SETUP
1228{
1229 current_file->lineno++;
1230 zconf_endhelp();
1231 return T_HELPTEXT;
1232 }
1233 YY_BREAK
1234case 31:
1235/* rule 31 can match eol */
1236YY_RULE_SETUP
1237{
1238 current_file->lineno++;
1239 append_string("\n", 1);
1240 }
1241 YY_BREAK
1242case 32:
1243YY_RULE_SETUP
1244{
1245 append_string(zconftext, zconfleng);
1246 if (!first_ts)
1247 first_ts = last_ts;
1248 }
1249 YY_BREAK
1250case YY_STATE_EOF(HELP):
1251{
1252 zconf_endhelp();
1253 return T_HELPTEXT;
1254 }
1255 YY_BREAK
1256
1257case YY_STATE_EOF(INITIAL):
1258case YY_STATE_EOF(COMMAND):
1259{
1260 if (current_file) {
1261 zconf_endfile();
1262 return T_EOL;
1263 }
1264 fclose(zconfin);
1265 yyterminate();
1266}
1267 YY_BREAK
1268case 33:
1269YY_RULE_SETUP
1270YY_FATAL_ERROR( "flex scanner jammed" );
1271 YY_BREAK
1272
1273 case YY_END_OF_BUFFER:
1274 {
1275 /* Amount of text matched not including the EOB char. */
1276 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1277
1278 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1279 *yy_cp = (yy_hold_char);
1280 YY_RESTORE_YY_MORE_OFFSET
1281
1282 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1283 {
1284 /* We're scanning a new file or input source. It's
1285 * possible that this happened because the user
1286 * just pointed zconfin at a new source and called
1287 * zconflex(). If so, then we have to assure
1288 * consistency between YY_CURRENT_BUFFER and our
1289 * globals. Here is the right place to do so, because
1290 * this is the first action (other than possibly a
1291 * back-up) that will match for the new input source.
1292 */
1293 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1294 YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin;
1295 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1296 }
1297
1298 /* Note that here we test for yy_c_buf_p "<=" to the position
1299 * of the first EOB in the buffer, since yy_c_buf_p will
1300 * already have been incremented past the NUL character
1301 * (since all states make transitions on EOB to the
1302 * end-of-buffer state). Contrast this with the test
1303 * in input().
1304 */
1305 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1306 { /* This was really a NUL. */
1307 yy_state_type yy_next_state;
1308
1309 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1310
1311 yy_current_state = yy_get_previous_state( );
1312
1313 /* Okay, we're now positioned to make the NUL
1314 * transition. We couldn't have
1315 * yy_get_previous_state() go ahead and do it
1316 * for us because it doesn't know how to deal
1317 * with the possibility of jamming (and we don't
1318 * want to build jamming into it because then it
1319 * will run more slowly).
1320 */
1321
1322 yy_next_state = yy_try_NUL_trans( yy_current_state );
1323
1324 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1325
1326 if ( yy_next_state )
1327 {
1328 /* Consume the NUL. */
1329 yy_cp = ++(yy_c_buf_p);
1330 yy_current_state = yy_next_state;
1331 goto yy_match;
1332 }
1333
1334 else
1335 {
1336 yy_cp = (yy_c_buf_p);
1337 goto yy_find_action;
1338 }
1339 }
1340
1341 else switch ( yy_get_next_buffer( ) )
1342 {
1343 case EOB_ACT_END_OF_FILE:
1344 {
1345 (yy_did_buffer_switch_on_eof) = 0;
1346
1347 if ( zconfwrap( ) )
1348 {
1349 /* Note: because we've taken care in
1350 * yy_get_next_buffer() to have set up
1351 * zconftext, we can now set up
1352 * yy_c_buf_p so that if some total
1353 * hoser (like flex itself) wants to
1354 * call the scanner after we return the
1355 * YY_NULL, it'll still work - another
1356 * YY_NULL will get returned.
1357 */
1358 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1359
1360 yy_act = YY_STATE_EOF(YY_START);
1361 goto do_action;
1362 }
1363
1364 else
1365 {
1366 if ( ! (yy_did_buffer_switch_on_eof) )
1367 YY_NEW_FILE;
1368 }
1369 break;
1370 }
1371
1372 case EOB_ACT_CONTINUE_SCAN:
1373 (yy_c_buf_p) =
1374 (yytext_ptr) + yy_amount_of_matched_text;
1375
1376 yy_current_state = yy_get_previous_state( );
1377
1378 yy_cp = (yy_c_buf_p);
1379 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1380 goto yy_match;
1381
1382 case EOB_ACT_LAST_MATCH:
1383 (yy_c_buf_p) =
1384 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1385
1386 yy_current_state = yy_get_previous_state( );
1387
1388 yy_cp = (yy_c_buf_p);
1389 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1390 goto yy_find_action;
1391 }
1392 break;
1393 }
1394
1395 default:
1396 YY_FATAL_ERROR(
1397 "fatal flex scanner internal error--no action found" );
1398 } /* end of action switch */
1399 } /* end of scanning one token */
1400} /* end of zconflex */
1401
1402/* yy_get_next_buffer - try to read in a new buffer
1403 *
1404 * Returns a code representing an action:
1405 * EOB_ACT_LAST_MATCH -
1406 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1407 * EOB_ACT_END_OF_FILE - end of file
1408 */
1409static int yy_get_next_buffer (void)
1410{
1411 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1412 register char *source = (yytext_ptr);
1413 register int number_to_move, i;
1414 int ret_val;
1415
1416 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1417 YY_FATAL_ERROR(
1418 "fatal flex scanner internal error--end of buffer missed" );
1419
1420 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1421 { /* Don't try to fill the buffer, so this is an EOF. */
1422 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1423 {
1424 /* We matched a single character, the EOB, so
1425 * treat this as a final EOF.
1426 */
1427 return EOB_ACT_END_OF_FILE;
1428 }
1429
1430 else
1431 {
1432 /* We matched some text prior to the EOB, first
1433 * process it.
1434 */
1435 return EOB_ACT_LAST_MATCH;
1436 }
1437 }
1438
1439 /* Try to read more data. */
1440
1441 /* First move last chars to start of buffer. */
1442 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1443
1444 for ( i = 0; i < number_to_move; ++i )
1445 *(dest++) = *(source++);
1446
1447 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1448 /* don't do the read, it's not guaranteed to return an EOF,
1449 * just force an EOF
1450 */
1451 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1452
1453 else
1454 {
1455 size_t num_to_read =
1456 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1457
1458 while ( num_to_read <= 0 )
1459 { /* Not enough room in the buffer - grow it. */
1460
1461 /* just a shorter name for the current buffer */
1462 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1463
1464 int yy_c_buf_p_offset =
1465 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1466
1467 if ( b->yy_is_our_buffer )
1468 {
1469 int new_size = b->yy_buf_size * 2;
1470
1471 if ( new_size <= 0 )
1472 b->yy_buf_size += b->yy_buf_size / 8;
1473 else
1474 b->yy_buf_size *= 2;
1475
1476 b->yy_ch_buf = (char *)
1477 /* Include room in for 2 EOB chars. */
1478 zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1479 }
1480 else
1481 /* Can't grow it, we don't own it. */
1482 b->yy_ch_buf = 0;
1483
1484 if ( ! b->yy_ch_buf )
1485 YY_FATAL_ERROR(
1486 "fatal error - scanner input buffer overflow" );
1487
1488 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1489
1490 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1491 number_to_move - 1;
1492
1493 }
1494
1495 if ( num_to_read > YY_READ_BUF_SIZE )
1496 num_to_read = YY_READ_BUF_SIZE;
1497
1498 /* Read in more data. */
1499 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1500 (yy_n_chars), num_to_read );
1501
1502 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1503 }
1504
1505 if ( (yy_n_chars) == 0 )
1506 {
1507 if ( number_to_move == YY_MORE_ADJ )
1508 {
1509 ret_val = EOB_ACT_END_OF_FILE;
1510 zconfrestart(zconfin );
1511 }
1512
1513 else
1514 {
1515 ret_val = EOB_ACT_LAST_MATCH;
1516 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1517 YY_BUFFER_EOF_PENDING;
1518 }
1519 }
1520
1521 else
1522 ret_val = EOB_ACT_CONTINUE_SCAN;
1523
1524 (yy_n_chars) += number_to_move;
1525 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1526 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1527
1528 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1529
1530 return ret_val;
1531}
1532
1533/* yy_get_previous_state - get the state just before the EOB char was reached */
1534
1535 static yy_state_type yy_get_previous_state (void)
1536{
1537 register yy_state_type yy_current_state;
1538 register char *yy_cp;
1539
1540 yy_current_state = (yy_start);
1541
1542 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1543 {
1544 yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
1545 }
1546
1547 return yy_current_state;
1548}
1549
1550/* yy_try_NUL_trans - try to make a transition on the NUL character
1551 *
1552 * synopsis
1553 * next_state = yy_try_NUL_trans( current_state );
1554 */
1555 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1556{
1557 register int yy_is_jam;
1558
1559 yy_current_state = yy_nxt[yy_current_state][1];
1560 yy_is_jam = (yy_current_state <= 0);
1561
1562 return yy_is_jam ? 0 : yy_current_state;
1563}
1564
1565 static void yyunput (int c, register char * yy_bp )
1566{
1567 register char *yy_cp;
1568
1569 yy_cp = (yy_c_buf_p);
1570
1571 /* undo effects of setting up zconftext */
1572 *yy_cp = (yy_hold_char);
1573
1574 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1575 { /* need to shift things up to make room */
1576 /* +2 for EOB chars. */
1577 register int number_to_move = (yy_n_chars) + 2;
1578 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1579 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1580 register char *source =
1581 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1582
1583 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1584 *--dest = *--source;
1585
1586 yy_cp += (int) (dest - source);
1587 yy_bp += (int) (dest - source);
1588 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1589 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1590
1591 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1592 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1593 }
1594
1595 *--yy_cp = (char) c;
1596
1597 (yytext_ptr) = yy_bp;
1598 (yy_hold_char) = *yy_cp;
1599 (yy_c_buf_p) = yy_cp;
1600}
1601
1602#ifndef YY_NO_INPUT
1603#ifdef __cplusplus
1604 static int yyinput (void)
1605#else
1606 static int input (void)
1607#endif
1608
1609{
1610 int c;
1611
1612 *(yy_c_buf_p) = (yy_hold_char);
1613
1614 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1615 {
1616 /* yy_c_buf_p now points to the character we want to return.
1617 * If this occurs *before* the EOB characters, then it's a
1618 * valid NUL; if not, then we've hit the end of the buffer.
1619 */
1620 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1621 /* This was really a NUL. */
1622 *(yy_c_buf_p) = '\0';
1623
1624 else
1625 { /* need more input */
1626 int offset = (yy_c_buf_p) - (yytext_ptr);
1627 ++(yy_c_buf_p);
1628
1629 switch ( yy_get_next_buffer( ) )
1630 {
1631 case EOB_ACT_LAST_MATCH:
1632 /* This happens because yy_g_n_b()
1633 * sees that we've accumulated a
1634 * token and flags that we need to
1635 * try matching the token before
1636 * proceeding. But for input(),
1637 * there's no matching to consider.
1638 * So convert the EOB_ACT_LAST_MATCH
1639 * to EOB_ACT_END_OF_FILE.
1640 */
1641
1642 /* Reset buffer status. */
1643 zconfrestart(zconfin );
1644
1645 /*FALLTHROUGH*/
1646
1647 case EOB_ACT_END_OF_FILE:
1648 {
1649 if ( zconfwrap( ) )
1650 return EOF;
1651
1652 if ( ! (yy_did_buffer_switch_on_eof) )
1653 YY_NEW_FILE;
1654#ifdef __cplusplus
1655 return yyinput();
1656#else
1657 return input();
1658#endif
1659 }
1660
1661 case EOB_ACT_CONTINUE_SCAN:
1662 (yy_c_buf_p) = (yytext_ptr) + offset;
1663 break;
1664 }
1665 }
1666 }
1667
1668 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1669 *(yy_c_buf_p) = '\0'; /* preserve zconftext */
1670 (yy_hold_char) = *++(yy_c_buf_p);
1671
1672 return c;
1673}
1674#endif /* ifndef YY_NO_INPUT */
1675
1676/** Immediately switch to a different input stream.
1677 * @param input_file A readable stream.
1678 *
1679 * @note This function does not reset the start condition to @c INITIAL .
1680 */
1681 void zconfrestart (FILE * input_file )
1682{
1683
1684 if ( ! YY_CURRENT_BUFFER ){
1685 zconfensure_buffer_stack ();
1686 YY_CURRENT_BUFFER_LVALUE =
1687 zconf_create_buffer(zconfin,YY_BUF_SIZE );
1688 }
1689
1690 zconf_init_buffer(YY_CURRENT_BUFFER,input_file );
1691 zconf_load_buffer_state( );
1692}
1693
1694/** Switch to a different input buffer.
1695 * @param new_buffer The new input buffer.
1696 *
1697 */
1698 void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1699{
1700
1701 /* TODO. We should be able to replace this entire function body
1702 * with
1703 * zconfpop_buffer_state();
1704 * zconfpush_buffer_state(new_buffer);
1705 */
1706 zconfensure_buffer_stack ();
1707 if ( YY_CURRENT_BUFFER == new_buffer )
1708 return;
1709
1710 if ( YY_CURRENT_BUFFER )
1711 {
1712 /* Flush out information for old buffer. */
1713 *(yy_c_buf_p) = (yy_hold_char);
1714 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1715 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1716 }
1717
1718 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1719 zconf_load_buffer_state( );
1720
1721 /* We don't actually know whether we did this switch during
1722 * EOF (zconfwrap()) processing, but the only time this flag
1723 * is looked at is after zconfwrap() is called, so it's safe
1724 * to go ahead and always set it.
1725 */
1726 (yy_did_buffer_switch_on_eof) = 1;
1727}
1728
1729static void zconf_load_buffer_state (void)
1730{
1731 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1732 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1733 zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1734 (yy_hold_char) = *(yy_c_buf_p);
1735}
1736
1737/** Allocate and initialize an input buffer state.
1738 * @param file A readable stream.
1739 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1740 *
1741 * @return the allocated buffer state.
1742 */
1743 YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size )
1744{
1745 YY_BUFFER_STATE b;
1746
1747 b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
1748 if ( ! b )
1749 YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
1750
1751 b->yy_buf_size = size;
1752
1753 /* yy_ch_buf has to be 2 characters longer than the size given because
1754 * we need to put in 2 end-of-buffer characters.
1755 */
1756 b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 );
1757 if ( ! b->yy_ch_buf )
1758 YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
1759
1760 b->yy_is_our_buffer = 1;
1761
1762 zconf_init_buffer(b,file );
1763
1764 return b;
1765}
1766
1767/** Destroy the buffer.
1768 * @param b a buffer created with zconf_create_buffer()
1769 *
1770 */
1771 void zconf_delete_buffer (YY_BUFFER_STATE b )
1772{
1773
1774 if ( ! b )
1775 return;
1776
1777 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1778 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1779
1780 if ( b->yy_is_our_buffer )
1781 zconffree((void *) b->yy_ch_buf );
1782
1783 zconffree((void *) b );
1784}
1785
1786/* Initializes or reinitializes a buffer.
1787 * This function is sometimes called more than once on the same buffer,
1788 * such as during a zconfrestart() or at EOF.
1789 */
1790 static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file )
1791
1792{
1793 int oerrno = errno;
1794
1795 zconf_flush_buffer(b );
1796
1797 b->yy_input_file = file;
1798 b->yy_fill_buffer = 1;
1799
1800 /* If b is the current buffer, then zconf_init_buffer was _probably_
1801 * called from zconfrestart() or through yy_get_next_buffer.
1802 * In that case, we don't want to reset the lineno or column.
1803 */
1804 if (b != YY_CURRENT_BUFFER){
1805 b->yy_bs_lineno = 1;
1806 b->yy_bs_column = 0;
1807 }
1808
1809 b->yy_is_interactive = 0;
1810
1811 errno = oerrno;
1812}
1813
1814/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1815 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1816 *
1817 */
1818 void zconf_flush_buffer (YY_BUFFER_STATE b )
1819{
1820 if ( ! b )
1821 return;
1822
1823 b->yy_n_chars = 0;
1824
1825 /* We always need two end-of-buffer characters. The first causes
1826 * a transition to the end-of-buffer state. The second causes
1827 * a jam in that state.
1828 */
1829 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1830 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1831
1832 b->yy_buf_pos = &b->yy_ch_buf[0];
1833
1834 b->yy_at_bol = 1;
1835 b->yy_buffer_status = YY_BUFFER_NEW;
1836
1837 if ( b == YY_CURRENT_BUFFER )
1838 zconf_load_buffer_state( );
1839}
1840
1841/** Pushes the new state onto the stack. The new state becomes
1842 * the current state. This function will allocate the stack
1843 * if necessary.
1844 * @param new_buffer The new state.
1845 *
1846 */
1847void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer )
1848{
1849 if (new_buffer == NULL)
1850 return;
1851
1852 zconfensure_buffer_stack();
1853
1854 /* This block is copied from zconf_switch_to_buffer. */
1855 if ( YY_CURRENT_BUFFER )
1856 {
1857 /* Flush out information for old buffer. */
1858 *(yy_c_buf_p) = (yy_hold_char);
1859 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1860 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1861 }
1862
1863 /* Only push if top exists. Otherwise, replace top. */
1864 if (YY_CURRENT_BUFFER)
1865 (yy_buffer_stack_top)++;
1866 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1867
1868 /* copied from zconf_switch_to_buffer. */
1869 zconf_load_buffer_state( );
1870 (yy_did_buffer_switch_on_eof) = 1;
1871}
1872
1873/** Removes and deletes the top of the stack, if present.
1874 * The next element becomes the new top.
1875 *
1876 */
1877void zconfpop_buffer_state (void)
1878{
1879 if (!YY_CURRENT_BUFFER)
1880 return;
1881
1882 zconf_delete_buffer(YY_CURRENT_BUFFER );
1883 YY_CURRENT_BUFFER_LVALUE = NULL;
1884 if ((yy_buffer_stack_top) > 0)
1885 --(yy_buffer_stack_top);
1886
1887 if (YY_CURRENT_BUFFER) {
1888 zconf_load_buffer_state( );
1889 (yy_did_buffer_switch_on_eof) = 1;
1890 }
1891}
1892
1893/* Allocates the stack if it does not exist.
1894 * Guarantees space for at least one push.
1895 */
1896static void zconfensure_buffer_stack (void)
1897{
1898 int num_to_alloc;
1899
1900 if (!(yy_buffer_stack)) {
1901
1902 /* First allocation is just for 2 elements, since we don't know if this
1903 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1904 * immediate realloc on the next call.
1905 */
1906 num_to_alloc = 1;
1907 (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc
1908 (num_to_alloc * sizeof(struct yy_buffer_state*)
1909 );
1910
1911 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1912
1913 (yy_buffer_stack_max) = num_to_alloc;
1914 (yy_buffer_stack_top) = 0;
1915 return;
1916 }
1917
1918 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1919
1920 /* Increase the buffer to prepare for a possible push. */
1921 int grow_size = 8 /* arbitrary grow size */;
1922
1923 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1924 (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc
1925 ((yy_buffer_stack),
1926 num_to_alloc * sizeof(struct yy_buffer_state*)
1927 );
1928
1929 /* zero only the new slots.*/
1930 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1931 (yy_buffer_stack_max) = num_to_alloc;
1932 }
1933}
1934
1935/** Setup the input buffer state to scan directly from a user-specified character buffer.
1936 * @param base the character buffer
1937 * @param size the size in bytes of the character buffer
1938 *
1939 * @return the newly allocated buffer state object.
1940 */
1941YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size )
1942{
1943 YY_BUFFER_STATE b;
1944
1945 if ( size < 2 ||
1946 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1947 base[size-1] != YY_END_OF_BUFFER_CHAR )
1948 /* They forgot to leave room for the EOB's. */
1949 return 0;
1950
1951 b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
1952 if ( ! b )
1953 YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" );
1954
1955 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1956 b->yy_buf_pos = b->yy_ch_buf = base;
1957 b->yy_is_our_buffer = 0;
1958 b->yy_input_file = 0;
1959 b->yy_n_chars = b->yy_buf_size;
1960 b->yy_is_interactive = 0;
1961 b->yy_at_bol = 1;
1962 b->yy_fill_buffer = 0;
1963 b->yy_buffer_status = YY_BUFFER_NEW;
1964
1965 zconf_switch_to_buffer(b );
1966
1967 return b;
1968}
1969
1970/** Setup the input buffer state to scan a string. The next call to zconflex() will
1971 * scan from a @e copy of @a str.
1972 * @param yy_str a NUL-terminated string to scan
1973 *
1974 * @return the newly allocated buffer state object.
1975 * @note If you want to scan bytes that may contain NUL values, then use
1976 * zconf_scan_bytes() instead.
1977 */
1978YY_BUFFER_STATE zconf_scan_string (yyconst char * yy_str )
1979{
1980
1981 return zconf_scan_bytes(yy_str,strlen(yy_str) );
1982}
1983
1984/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
1985 * scan from a @e copy of @a bytes.
1986 * @param bytes the byte buffer to scan
1987 * @param len the number of bytes in the buffer pointed to by @a bytes.
1988 *
1989 * @return the newly allocated buffer state object.
1990 */
1991YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len )
1992{
1993 YY_BUFFER_STATE b;
1994 char *buf;
1995 yy_size_t n;
1996 int i;
1997
1998 /* Get memory for full buffer, including space for trailing EOB's. */
1999 n = len + 2;
2000 buf = (char *) zconfalloc(n );
2001 if ( ! buf )
2002 YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" );
2003
2004 for ( i = 0; i < len; ++i )
2005 buf[i] = bytes[i];
2006
2007 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
2008
2009 b = zconf_scan_buffer(buf,n );
2010 if ( ! b )
2011 YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" );
2012
2013 /* It's okay to grow etc. this buffer, and we should throw it
2014 * away when we're done.
2015 */
2016 b->yy_is_our_buffer = 1;
2017
2018 return b;
2019}
2020
2021#ifndef YY_EXIT_FAILURE
2022#define YY_EXIT_FAILURE 2
2023#endif
2024
2025static void yy_fatal_error (yyconst char* msg )
2026{
2027 (void) fprintf( stderr, "%s\n", msg );
2028 exit( YY_EXIT_FAILURE );
2029}
2030
2031/* Redefine yyless() so it works in section 3 code. */
2032
2033#undef yyless
2034#define yyless(n) \
2035 do \
2036 { \
2037 /* Undo effects of setting up zconftext. */ \
2038 int yyless_macro_arg = (n); \
2039 YY_LESS_LINENO(yyless_macro_arg);\
2040 zconftext[zconfleng] = (yy_hold_char); \
2041 (yy_c_buf_p) = zconftext + yyless_macro_arg; \
2042 (yy_hold_char) = *(yy_c_buf_p); \
2043 *(yy_c_buf_p) = '\0'; \
2044 zconfleng = yyless_macro_arg; \
2045 } \
2046 while ( 0 )
2047
2048/* Accessor methods (get/set functions) to struct members. */
2049
2050/** Get the current line number.
2051 *
2052 */
2053int zconfget_lineno (void)
2054{
2055
2056 return zconflineno;
2057}
2058
2059/** Get the input stream.
2060 *
2061 */
2062FILE *zconfget_in (void)
2063{
2064 return zconfin;
2065}
2066
2067/** Get the output stream.
2068 *
2069 */
2070FILE *zconfget_out (void)
2071{
2072 return zconfout;
2073}
2074
2075/** Get the length of the current token.
2076 *
2077 */
2078int zconfget_leng (void)
2079{
2080 return zconfleng;
2081}
2082
2083/** Get the current token.
2084 *
2085 */
2086
2087char *zconfget_text (void)
2088{
2089 return zconftext;
2090}
2091
2092/** Set the current line number.
2093 * @param line_number
2094 *
2095 */
2096void zconfset_lineno (int line_number )
2097{
2098
2099 zconflineno = line_number;
2100}
2101
2102/** Set the input stream. This does not discard the current
2103 * input buffer.
2104 * @param in_str A readable stream.
2105 *
2106 * @see zconf_switch_to_buffer
2107 */
2108void zconfset_in (FILE * in_str )
2109{
2110 zconfin = in_str ;
2111}
2112
2113void zconfset_out (FILE * out_str )
2114{
2115 zconfout = out_str ;
2116}
2117
2118int zconfget_debug (void)
2119{
2120 return zconf_flex_debug;
2121}
2122
2123void zconfset_debug (int bdebug )
2124{
2125 zconf_flex_debug = bdebug ;
2126}
2127
2128/* zconflex_destroy is for both reentrant and non-reentrant scanners. */
2129int zconflex_destroy (void)
2130{
2131
2132 /* Pop the buffer stack, destroying each element. */
2133 while(YY_CURRENT_BUFFER){
2134 zconf_delete_buffer(YY_CURRENT_BUFFER );
2135 YY_CURRENT_BUFFER_LVALUE = NULL;
2136 zconfpop_buffer_state();
2137 }
2138
2139 /* Destroy the stack itself. */
2140 zconffree((yy_buffer_stack) );
2141 (yy_buffer_stack) = NULL;
2142
2143 return 0;
2144}
2145
2146/*
2147 * Internal utility routines.
2148 */
2149
2150#ifndef yytext_ptr
2151static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2152{
2153 register int i;
2154 for ( i = 0; i < n; ++i )
2155 s1[i] = s2[i];
2156}
2157#endif
2158
2159#ifdef YY_NEED_STRLEN
2160static int yy_flex_strlen (yyconst char * s )
2161{
2162 register int n;
2163 for ( n = 0; s[n]; ++n )
2164 ;
2165
2166 return n;
2167}
2168#endif
2169
2170void *zconfalloc (yy_size_t size )
2171{
2172 return (void *) malloc( size );
2173}
2174
2175void *zconfrealloc (void * ptr, yy_size_t size )
2176{
2177 /* The cast to (char *) in the following accommodates both
2178 * implementations that use char* generic pointers, and those
2179 * that use void* generic pointers. It works with the latter
2180 * because both ANSI C and C++ allow castless assignment from
2181 * any pointer type to void*, and deal with argument conversions
2182 * as though doing an assignment.
2183 */
2184 return (void *) realloc( (char *) ptr, size );
2185}
2186
2187void zconffree (void * ptr )
2188{
2189 free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */
2190}
2191
2192#define YYTABLES_NAME "yytables"
2193
2194#undef YY_NEW_FILE
2195#undef YY_FLUSH_BUFFER
2196#undef yy_set_bol
2197#undef yy_new_buffer
2198#undef yy_set_interactive
2199#undef yytext_ptr
2200#undef YY_DO_BEFORE_ACTION
2201
2202#ifdef YY_DECL_IS_OURS
2203#undef YY_DECL_IS_OURS
2204#undef YY_DECL
2205#endif
2206
2207void zconf_starthelp(void)
2208{
2209 new_string();
2210 last_ts = first_ts = 0;
2211 BEGIN(HELP);
2212}
2213
2214static void zconf_endhelp(void)
2215{
2216 zconflval.string = text;
2217 BEGIN(INITIAL);
2218}
2219
2220/*
2221 * Try to open specified file with following names:
2222 * ./name
2223 * $(srctree)/name
2224 * The latter is used when srctree is separate from objtree
2225 * when compiling the kernel.
2226 * Return NULL if file is not found.
2227 */
2228FILE *zconf_fopen(const char *name)
2229{
2230 char *env, fullname[PATH_MAX+1];
2231 FILE *f;
2232
2233 f = fopen(name, "r");
2234 if (!f && name[0] != '/') {
2235 env = getenv(SRCTREE);
2236 if (env) {
2237 sprintf(fullname, "%s/%s", env, name);
2238 f = fopen(fullname, "r");
2239 }
2240 }
2241 return f;
2242}
2243
2244void zconf_initscan(const char *name)
2245{
2246 zconfin = zconf_fopen(name);
2247 if (!zconfin) {
2248 printf("can't find file %s\n", name);
2249 exit(1);
2250 }
2251
2252 current_buf = malloc(sizeof(*current_buf));
2253 memset(current_buf, 0, sizeof(*current_buf));
2254
2255 current_file = file_lookup(name);
2256 current_file->lineno = 1;
2257 current_file->flags = FILE_BUSY;
2258}
2259
2260void zconf_nextfile(const char *name)
2261{
2262 struct file *file = file_lookup(name);
2263 struct buffer *buf = malloc(sizeof(*buf));
2264 memset(buf, 0, sizeof(*buf));
2265
2266 current_buf->state = YY_CURRENT_BUFFER;
2267 zconfin = zconf_fopen(name);
2268 if (!zconfin) {
2269 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
2270 exit(1);
2271 }
2272 zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
2273 buf->parent = current_buf;
2274 current_buf = buf;
2275
2276 if (file->flags & FILE_BUSY) {
2277 printf("recursive scan (%s)?\n", name);
2278 exit(1);
2279 }
2280 if (file->flags & FILE_SCANNED) {
2281 printf("file %s already scanned?\n", name);
2282 exit(1);
2283 }
2284 file->flags |= FILE_BUSY;
2285 file->lineno = 1;
2286 file->parent = current_file;
2287 current_file = file;
2288}
2289
2290static void zconf_endfile(void)
2291{
2292 struct buffer *parent;
2293
2294 current_file->flags |= FILE_SCANNED;
2295 current_file->flags &= ~FILE_BUSY;
2296 current_file = current_file->parent;
2297
2298 parent = current_buf->parent;
2299 if (parent) {
2300 fclose(zconfin);
2301 zconf_delete_buffer(YY_CURRENT_BUFFER);
2302 zconf_switch_to_buffer(parent->state);
2303 }
2304 free(current_buf);
2305 current_buf = parent;
2306}
2307
2308int zconf_lineno(void)
2309{
2310 return current_pos.lineno;
2311}
2312
2313char *zconf_curname(void)
2314{
2315 return current_pos.file ? current_pos.file->name : "<none>";
2316}
2317
diff --git a/scripts/config/lkc.h b/scripts/kconfig/lkc.h
index 8c38f1f87..527f60c99 100644
--- a/scripts/config/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
@@ -9,6 +8,14 @@
9 8
10#include "expr.h" 9#include "expr.h"
11 10
11#ifndef KBUILD_NO_NLS
12# include <libintl.h>
13#else
14# define gettext(Msgid) ((const char *) (Msgid))
15# define textdomain(Domainname) ((const char *) (Domainname))
16# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
17#endif
18
12#ifdef __cplusplus 19#ifdef __cplusplus
13extern "C" { 20extern "C" {
14#endif 21#endif
@@ -24,6 +31,23 @@ extern "C" {
24 31
25#define SRCTREE "srctree" 32#define SRCTREE "srctree"
26 33
34#define PACKAGE "linux"
35#define LOCALEDIR "/usr/share/locale"
36
37#define _(text) gettext(text)
38#define N_(text) (text)
39
40
41#define TF_COMMAND 0x0001
42#define TF_PARAM 0x0002
43
44struct kconf_id {
45 int name;
46 int token;
47 unsigned int flags;
48 enum symbol_type stype;
49};
50
27int zconfparse(void); 51int zconfparse(void);
28void zconfdump(FILE *out); 52void zconfdump(FILE *out);
29 53
@@ -37,7 +61,6 @@ char *zconf_curname(void);
37 61
38/* confdata.c */ 62/* confdata.c */
39extern const char conf_def_filename[]; 63extern const char conf_def_filename[];
40extern char conf_filename[];
41 64
42char *conf_get_default_confname(void); 65char *conf_get_default_confname(void);
43 66
@@ -46,13 +69,13 @@ void kconfig_load(void);
46 69
47/* menu.c */ 70/* menu.c */
48void menu_init(void); 71void menu_init(void);
49void menu_add_menu(void); 72struct menu *menu_add_menu(void);
50void menu_end_menu(void); 73void menu_end_menu(void);
51void menu_add_entry(struct symbol *sym); 74void menu_add_entry(struct symbol *sym);
52void menu_end_entry(void); 75void menu_end_entry(void);
53void menu_add_dep(struct expr *dep); 76void menu_add_dep(struct expr *dep);
54struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); 77struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
55void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); 78struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
56void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); 79void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
57void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); 80void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
58void menu_finalize(struct menu *parent); 81void menu_finalize(struct menu *parent);
diff --git a/scripts/config/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index c416357df..b6a389c5f 100644
--- a/scripts/config/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -1,8 +1,8 @@
1/* vi: set sw=4 ts=4: */
2 1
3/* confdata.c */ 2/* confdata.c */
4P(conf_parse,void,(const char *name)); 3P(conf_parse,void,(const char *name));
5P(conf_read,int,(const char *name)); 4P(conf_read,int,(const char *name));
5P(conf_read_simple,int,(const char *name));
6P(conf_write,int,(const char *name)); 6P(conf_write,int,(const char *name));
7 7
8/* menu.c */ 8/* menu.c */
diff --git a/scripts/config/lxdialog/BIG.FAT.WARNING b/scripts/kconfig/lxdialog/BIG.FAT.WARNING
index 7cb5a7ec9..a8999d82b 100644
--- a/scripts/config/lxdialog/BIG.FAT.WARNING
+++ b/scripts/kconfig/lxdialog/BIG.FAT.WARNING
@@ -1,4 +1,4 @@
1This is NOT the official version of dialog. This version has been 1This is NOT the official version of dialog. This version has been
2significantly modified from the original. It is for use by the Linux 2significantly modified from the original. It is for use by the Linux
3kernel configuration script. Please do not bother Savio Lam with 3kernel configuration script. Please do not bother Savio Lam with
4questions about this program. 4questions about this program.
diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile
new file mode 100644
index 000000000..a8b026326
--- /dev/null
+++ b/scripts/kconfig/lxdialog/Makefile
@@ -0,0 +1,21 @@
1# Makefile to build lxdialog package
2#
3
4check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh
5
6# Use reursively expanded variables so we do not call gcc unless
7# we really need to do so. (Do not call gcc as part of make mrproper)
8HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
9HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
10
11HOST_EXTRACFLAGS += -DLOCALE
12
13PHONY += dochecklxdialog
14$(obj)/dochecklxdialog:
15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
16
17hostprogs-y := lxdialog
18always := $(hostprogs-y) dochecklxdialog
19
20lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \
21 util.o lxdialog.o msgbox.o
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
new file mode 100644
index 000000000..120d624e6
--- /dev/null
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -0,0 +1,84 @@
1#!/bin/sh
2# Check ncurses compatibility
3
4# What library to link
5ldflags()
6{
7 $cc -print-file-name=libncursesw.so | grep -q /
8 if [ $? -eq 0 ]; then
9 echo '-lncursesw'
10 exit
11 fi
12 $cc -print-file-name=libncurses.so | grep -q /
13 if [ $? -eq 0 ]; then
14 echo '-lncurses'
15 exit
16 fi
17 $cc -print-file-name=libcurses.so | grep -q /
18 if [ $? -eq 0 ]; then
19 echo '-lcurses'
20 exit
21 fi
22 exit 1
23}
24
25# Where is ncurses.h?
26ccflags()
27{
28 if [ -f /usr/include/ncurses/ncurses.h ]; then
29 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
30 elif [ -f /usr/include/ncurses/curses.h ]; then
31 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
32 elif [ -f /usr/include/ncurses.h ]; then
33 echo '-DCURSES_LOC="<ncurses.h>"'
34 else
35 echo '-DCURSES_LOC="<curses.h>"'
36 fi
37}
38
39# Temp file, try to clean up after us
40tmp=.lxdialog.tmp
41trap "rm -f $tmp" 0 1 2 3 15
42
43# Check if we can link to ncurses
44check() {
45 echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
46 if [ $? != 0 ]; then
47 echo " *** Unable to find the ncurses libraries." 1>&2
48 echo " *** make menuconfig require the ncurses libraries" 1>&2
49 echo " *** " 1>&2
50 echo " *** Install ncurses (ncurses-devel) and try again" 1>&2
51 echo " *** " 1>&2
52 exit 1
53 fi
54}
55
56usage() {
57 printf "Usage: $0 [-check compiler options|-header|-library]\n"
58}
59
60if [ $# == 0 ]; then
61 usage
62 exit 1
63fi
64
65cc=""
66case "$1" in
67 "-check")
68 shift
69 cc="$@"
70 check
71 ;;
72 "-ccflags")
73 ccflags
74 ;;
75 "-ldflags")
76 shift
77 cc="$@"
78 ldflags
79 ;;
80 "*")
81 usage
82 exit 1
83 ;;
84esac
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c
new file mode 100644
index 000000000..be0200e9c
--- /dev/null
+++ b/scripts/kconfig/lxdialog/checklist.c
@@ -0,0 +1,333 @@
1/*
2 * checklist.c -- implements the checklist box
3 *
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension
6 * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two
7 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include "dialog.h"
25
26static int list_width, check_x, item_x;
27
28/*
29 * Print list item
30 */
31static void print_item(WINDOW * win, const char *item, int status, int choice,
32 int selected)
33{
34 int i;
35
36 /* Clear 'residue' of last item */
37 wattrset(win, menubox_attr);
38 wmove(win, choice, 0);
39 for (i = 0; i < list_width; i++)
40 waddch(win, ' ');
41
42 wmove(win, choice, check_x);
43 wattrset(win, selected ? check_selected_attr : check_attr);
44 wprintw(win, "(%c)", status ? 'X' : ' ');
45
46 wattrset(win, selected ? tag_selected_attr : tag_attr);
47 mvwaddch(win, choice, item_x, item[0]);
48 wattrset(win, selected ? item_selected_attr : item_attr);
49 waddstr(win, (char *)item + 1);
50 if (selected) {
51 wmove(win, choice, check_x + 1);
52 wrefresh(win);
53 }
54}
55
56/*
57 * Print the scroll indicators.
58 */
59static void print_arrows(WINDOW * win, int choice, int item_no, int scroll,
60 int y, int x, int height)
61{
62 wmove(win, y, x);
63
64 if (scroll > 0) {
65 wattrset(win, uarrow_attr);
66 waddch(win, ACS_UARROW);
67 waddstr(win, "(-)");
68 } else {
69 wattrset(win, menubox_attr);
70 waddch(win, ACS_HLINE);
71 waddch(win, ACS_HLINE);
72 waddch(win, ACS_HLINE);
73 waddch(win, ACS_HLINE);
74 }
75
76 y = y + height + 1;
77 wmove(win, y, x);
78
79 if ((height < item_no) && (scroll + choice < item_no - 1)) {
80 wattrset(win, darrow_attr);
81 waddch(win, ACS_DARROW);
82 waddstr(win, "(+)");
83 } else {
84 wattrset(win, menubox_border_attr);
85 waddch(win, ACS_HLINE);
86 waddch(win, ACS_HLINE);
87 waddch(win, ACS_HLINE);
88 waddch(win, ACS_HLINE);
89 }
90}
91
92/*
93 * Display the termination buttons
94 */
95static void print_buttons(WINDOW * dialog, int height, int width, int selected)
96{
97 int x = width / 2 - 11;
98 int y = height - 2;
99
100 print_button(dialog, "Select", y, x, selected == 0);
101 print_button(dialog, " Help ", y, x + 14, selected == 1);
102
103 wmove(dialog, y, x + 1 + 14 * selected);
104 wrefresh(dialog);
105}
106
107/*
108 * Display a dialog box with a list of options that can be turned on or off
109 * in the style of radiolist (only one option turned on at a time).
110 */
111int dialog_checklist(const char *title, const char *prompt, int height,
112 int width, int list_height, int item_no,
113 const char *const *items)
114{
115 int i, x, y, box_x, box_y;
116 int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status;
117 WINDOW *dialog, *list;
118
119 /* Allocate space for storing item on/off status */
120 if ((status = malloc(sizeof(int) * item_no)) == NULL) {
121 endwin();
122 fprintf(stderr,
123 "\nCan't allocate memory in dialog_checklist().\n");
124 exit(-1);
125 }
126
127 /* Initializes status */
128 for (i = 0; i < item_no; i++) {
129 status[i] = !strcasecmp(items[i * 3 + 2], "on");
130 if ((!choice && status[i])
131 || !strcasecmp(items[i * 3 + 2], "selected"))
132 choice = i + 1;
133 }
134 if (choice)
135 choice--;
136
137 max_choice = MIN(list_height, item_no);
138
139 /* center dialog box on screen */
140 x = (COLS - width) / 2;
141 y = (LINES - height) / 2;
142
143 draw_shadow(stdscr, y, x, height, width);
144
145 dialog = newwin(height, width, y, x);
146 keypad(dialog, TRUE);
147
148 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
149 wattrset(dialog, border_attr);
150 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
151 for (i = 0; i < width - 2; i++)
152 waddch(dialog, ACS_HLINE);
153 wattrset(dialog, dialog_attr);
154 waddch(dialog, ACS_RTEE);
155
156 print_title(dialog, title, width);
157
158 wattrset(dialog, dialog_attr);
159 print_autowrap(dialog, prompt, width - 2, 1, 3);
160
161 list_width = width - 6;
162 box_y = height - list_height - 5;
163 box_x = (width - list_width) / 2 - 1;
164
165 /* create new window for the list */
166 list = subwin(dialog, list_height, list_width, y + box_y + 1,
167 x + box_x + 1);
168
169 keypad(list, TRUE);
170
171 /* draw a box around the list items */
172 draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2,
173 menubox_border_attr, menubox_attr);
174
175 /* Find length of longest item in order to center checklist */
176 check_x = 0;
177 for (i = 0; i < item_no; i++)
178 check_x = MAX(check_x, +strlen(items[i * 3 + 1]) + 4);
179
180 check_x = (list_width - check_x) / 2;
181 item_x = check_x + 4;
182
183 if (choice >= list_height) {
184 scroll = choice - list_height + 1;
185 choice -= scroll;
186 }
187
188 /* Print the list */
189 for (i = 0; i < max_choice; i++) {
190 print_item(list, items[(scroll + i) * 3 + 1],
191 status[i + scroll], i, i == choice);
192 }
193
194 print_arrows(dialog, choice, item_no, scroll,
195 box_y, box_x + check_x + 5, list_height);
196
197 print_buttons(dialog, height, width, 0);
198
199 wnoutrefresh(dialog);
200 wnoutrefresh(list);
201 doupdate();
202
203 while (key != ESC) {
204 key = wgetch(dialog);
205
206 for (i = 0; i < max_choice; i++)
207 if (toupper(key) ==
208 toupper(items[(scroll + i) * 3 + 1][0]))
209 break;
210
211 if (i < max_choice || key == KEY_UP || key == KEY_DOWN ||
212 key == '+' || key == '-') {
213 if (key == KEY_UP || key == '-') {
214 if (!choice) {
215 if (!scroll)
216 continue;
217 /* Scroll list down */
218 if (list_height > 1) {
219 /* De-highlight current first item */
220 print_item(list, items[scroll * 3 + 1],
221 status[scroll], 0, FALSE);
222 scrollok(list, TRUE);
223 wscrl(list, -1);
224 scrollok(list, FALSE);
225 }
226 scroll--;
227 print_item(list, items[scroll * 3 + 1], status[scroll], 0, TRUE);
228 print_arrows(dialog, choice, item_no,
229 scroll, box_y, box_x + check_x + 5, list_height);
230
231 wnoutrefresh(dialog);
232 wrefresh(list);
233
234 continue; /* wait for another key press */
235 } else
236 i = choice - 1;
237 } else if (key == KEY_DOWN || key == '+') {
238 if (choice == max_choice - 1) {
239 if (scroll + choice >= item_no - 1)
240 continue;
241 /* Scroll list up */
242 if (list_height > 1) {
243 /* De-highlight current last item before scrolling up */
244 print_item(list, items[(scroll + max_choice - 1) * 3 + 1],
245 status[scroll + max_choice - 1],
246 max_choice - 1, FALSE);
247 scrollok(list, TRUE);
248 wscrl(list, 1);
249 scrollok(list, FALSE);
250 }
251 scroll++;
252 print_item(list, items[(scroll + max_choice - 1) * 3 + 1],
253 status[scroll + max_choice - 1], max_choice - 1, TRUE);
254
255 print_arrows(dialog, choice, item_no,
256 scroll, box_y, box_x + check_x + 5, list_height);
257
258 wnoutrefresh(dialog);
259 wrefresh(list);
260
261 continue; /* wait for another key press */
262 } else
263 i = choice + 1;
264 }
265 if (i != choice) {
266 /* De-highlight current item */
267 print_item(list, items[(scroll + choice) * 3 + 1],
268 status[scroll + choice], choice, FALSE);
269 /* Highlight new item */
270 choice = i;
271 print_item(list, items[(scroll + choice) * 3 + 1],
272 status[scroll + choice], choice, TRUE);
273 wnoutrefresh(dialog);
274 wrefresh(list);
275 }
276 continue; /* wait for another key press */
277 }
278 switch (key) {
279 case 'H':
280 case 'h':
281 case '?':
282 fprintf(stderr, "%s", items[(scroll + choice) * 3]);
283 delwin(dialog);
284 free(status);
285 return 1;
286 case TAB:
287 case KEY_LEFT:
288 case KEY_RIGHT:
289 button = ((key == KEY_LEFT ? --button : ++button) < 0)
290 ? 1 : (button > 1 ? 0 : button);
291
292 print_buttons(dialog, height, width, button);
293 wrefresh(dialog);
294 break;
295 case 'S':
296 case 's':
297 case ' ':
298 case '\n':
299 if (!button) {
300 if (!status[scroll + choice]) {
301 for (i = 0; i < item_no; i++)
302 status[i] = 0;
303 status[scroll + choice] = 1;
304 for (i = 0; i < max_choice; i++)
305 print_item(list, items[(scroll + i) * 3 + 1],
306 status[scroll + i], i, i == choice);
307 }
308 wnoutrefresh(dialog);
309 wrefresh(list);
310
311 for (i = 0; i < item_no; i++)
312 if (status[i])
313 fprintf(stderr, "%s", items[i * 3]);
314 } else
315 fprintf(stderr, "%s", items[(scroll + choice) * 3]);
316 delwin(dialog);
317 free(status);
318 return button;
319 case 'X':
320 case 'x':
321 key = ESC;
322 case ESC:
323 break;
324 }
325
326 /* Now, update everything... */
327 doupdate();
328 }
329
330 delwin(dialog);
331 free(status);
332 return -1; /* ESC pressed */
333}
diff --git a/scripts/config/lxdialog/colors.h b/scripts/kconfig/lxdialog/colors.h
index 4a2d06421..db071df12 100644
--- a/scripts/config/lxdialog/colors.h
+++ b/scripts/kconfig/lxdialog/colors.h
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * colors.h -- color attribute definitions 2 * colors.h -- color attribute definitions
4 * 3 *
@@ -19,7 +18,6 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 19 */
21 20
22
23/* 21/*
24 * Default color definitions 22 * Default color definitions
25 * 23 *
@@ -153,10 +151,4 @@
153 * Global variables 151 * Global variables
154 */ 152 */
155 153
156typedef struct {
157 char name[COLOR_NAME_LEN];
158 int value;
159} color_names_st;
160
161extern color_names_st color_names[];
162extern int color_table[][3]; 154extern int color_table[][3];
diff --git a/scripts/config/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index 236a68dce..af3cf716e 100644
--- a/scripts/config/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -1,5 +1,3 @@
1/* vi: set sw=4 ts=4: */
2
3/* 1/*
4 * dialog.h -- common declarations for all dialog modules 2 * dialog.h -- common declarations for all dialog modules
5 * 3 *
@@ -27,7 +25,6 @@
27#include <stdlib.h> 25#include <stdlib.h>
28#include <string.h> 26#include <string.h>
29 27
30#ifdef CURSES_LOC
31#ifdef __sun__ 28#ifdef __sun__
32#define CURS_MACROS 29#define CURS_MACROS
33#endif 30#endif
@@ -44,7 +41,7 @@
44#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) 41#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE)
45#define OLD_NCURSES 1 42#define OLD_NCURSES 1
46#undef wbkgdset 43#undef wbkgdset
47#define wbkgdset(w,p) /*nothing*/ 44#define wbkgdset(w,p) /*nothing */
48#else 45#else
49#define OLD_NCURSES 0 46#define OLD_NCURSES 0
50#endif 47#endif
@@ -58,7 +55,6 @@
58#define MIN(x,y) (x < y ? x : y) 55#define MIN(x,y) (x < y ? x : y)
59#define MAX(x,y) (x > y ? x : y) 56#define MAX(x,y) (x > y ? x : y)
60 57
61
62#ifndef ACS_ULCORNER 58#ifndef ACS_ULCORNER
63#define ACS_ULCORNER '+' 59#define ACS_ULCORNER '+'
64#endif 60#endif
@@ -130,53 +126,44 @@
130 * Global variables 126 * Global variables
131 */ 127 */
132extern bool use_colors; 128extern bool use_colors;
129extern bool use_shadow;
133 130
134extern chtype attributes[]; 131extern chtype attributes[];
135#endif
136 132
137extern const char *backtitle; 133extern const char *backtitle;
138 134
139struct dialog_list_item {
140 char *name;
141 int namelen;
142 char *tag;
143 int selected; /* Set to 1 by dialog_*() function. */
144};
145
146/* 135/*
147 * Function prototypes 136 * Function prototypes
148 */ 137 */
149 138extern void create_rc(const char *filename);
150void init_dialog (void); 139extern int parse_rc(void);
151void end_dialog (void); 140
152void dialog_clear (void); 141void init_dialog(void);
153#ifdef CURSES_LOC 142void end_dialog(void);
154void attr_clear (WINDOW * win, int height, int width, chtype attr); 143void attr_clear(WINDOW * win, int height, int width, chtype attr);
155void color_setup (void); 144void dialog_clear(void);
156void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); 145void color_setup(void);
157void print_button (WINDOW * win, const char *label, int y, int x, int selected); 146void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
158void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, 147void print_button(WINDOW * win, const char *label, int y, int x, int selected);
159 chtype border); 148void print_title(WINDOW *dialog, const char *title, int width);
160void draw_shadow (WINDOW * win, int y, int x, int height, int width); 149void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box,
161#endif 150 chtype border);
162 151void draw_shadow(WINDOW * win, int y, int x, int height, int width);
163int first_alpha (const char *string, const char *exempt); 152
164int dialog_yesno (const char *title, const char *prompt, int height, int width); 153int first_alpha(const char *string, const char *exempt);
165int dialog_msgbox (const char *title, const char *prompt, int height, 154int dialog_yesno(const char *title, const char *prompt, int height, int width);
166 int width, int pause); 155int dialog_msgbox(const char *title, const char *prompt, int height,
167int dialog_textbox (const char *title, const char *file, int height, int width); 156 int width, int pause);
168int dialog_menu (const char *title, const char *prompt, int height, int width, 157int dialog_textbox(const char *title, const char *file, int height, int width);
158int dialog_menu(const char *title, const char *prompt, int height, int width,
169 int menu_height, const char *choice, int item_no, 159 int menu_height, const char *choice, int item_no,
170 struct dialog_list_item ** items); 160 const char *const *items);
171int dialog_checklist (const char *title, const char *prompt, int height, 161int dialog_checklist(const char *title, const char *prompt, int height,
172 int width, int list_height, int item_no, 162 int width, int list_height, int item_no,
173 struct dialog_list_item ** items, int flag); 163 const char *const *items);
174extern char dialog_input_result[]; 164extern char dialog_input_result[];
175int dialog_inputbox (const char *title, const char *prompt, int height, 165int dialog_inputbox(const char *title, const char *prompt, int height,
176 int width, const char *init); 166 int width, const char *init);
177
178struct dialog_list_item *first_sel_item(int item_no,
179 struct dialog_list_item ** items);
180 167
181/* 168/*
182 * This is the base for fictitious keys, which activate 169 * This is the base for fictitious keys, which activate
@@ -187,14 +174,4 @@ struct dialog_list_item *first_sel_item(int item_no,
187 * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') 174 * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o')
188 * -- uppercase chars are used to invoke the button (M_EVENT + 'O') 175 * -- uppercase chars are used to invoke the button (M_EVENT + 'O')
189 */ 176 */
190#ifdef CURSES_LOC
191#define M_EVENT (KEY_MAX+1) 177#define M_EVENT (KEY_MAX+1)
192#endif
193
194
195/*
196 * The `flag' parameter in checklist is used to select between
197 * radiolist and checklist
198 */
199#define FLAG_CHECK 1
200#define FLAG_RADIO 0
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
new file mode 100644
index 000000000..779503726
--- /dev/null
+++ b/scripts/kconfig/lxdialog/inputbox.c
@@ -0,0 +1,224 @@
1/*
2 * inputbox.c -- implements the input box
3 *
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include "dialog.h"
23
24char dialog_input_result[MAX_LEN + 1];
25
26/*
27 * Print the termination buttons
28 */
29static void print_buttons(WINDOW * dialog, int height, int width, int selected)
30{
31 int x = width / 2 - 11;
32 int y = height - 2;
33
34 print_button(dialog, " Ok ", y, x, selected == 0);
35 print_button(dialog, " Help ", y, x + 14, selected == 1);
36
37 wmove(dialog, y, x + 1 + 14 * selected);
38 wrefresh(dialog);
39}
40
41/*
42 * Display a dialog box for inputing a string
43 */
44int dialog_inputbox(const char *title, const char *prompt, int height, int width,
45 const char *init)
46{
47 int i, x, y, box_y, box_x, box_width;
48 int input_x = 0, scroll = 0, key = 0, button = -1;
49 char *instr = dialog_input_result;
50 WINDOW *dialog;
51
52 /* center dialog box on screen */
53 x = (COLS - width) / 2;
54 y = (LINES - height) / 2;
55
56 draw_shadow(stdscr, y, x, height, width);
57
58 dialog = newwin(height, width, y, x);
59 keypad(dialog, TRUE);
60
61 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
62 wattrset(dialog, border_attr);
63 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
64 for (i = 0; i < width - 2; i++)
65 waddch(dialog, ACS_HLINE);
66 wattrset(dialog, dialog_attr);
67 waddch(dialog, ACS_RTEE);
68
69 print_title(dialog, title, width);
70
71 wattrset(dialog, dialog_attr);
72 print_autowrap(dialog, prompt, width - 2, 1, 3);
73
74 /* Draw the input field box */
75 box_width = width - 6;
76 getyx(dialog, y, x);
77 box_y = y + 2;
78 box_x = (width - box_width) / 2;
79 draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr);
80
81 print_buttons(dialog, height, width, 0);
82
83 /* Set up the initial value */
84 wmove(dialog, box_y, box_x);
85 wattrset(dialog, inputbox_attr);
86
87 if (!init)
88 instr[0] = '\0';
89 else
90 strcpy(instr, init);
91
92 input_x = strlen(instr);
93
94 if (input_x >= box_width) {
95 scroll = input_x - box_width + 1;
96 input_x = box_width - 1;
97 for (i = 0; i < box_width - 1; i++)
98 waddch(dialog, instr[scroll + i]);
99 } else {
100 waddstr(dialog, instr);
101 }
102
103 wmove(dialog, box_y, box_x + input_x);
104
105 wrefresh(dialog);
106
107 while (key != ESC) {
108 key = wgetch(dialog);
109
110 if (button == -1) { /* Input box selected */
111 switch (key) {
112 case TAB:
113 case KEY_UP:
114 case KEY_DOWN:
115 break;
116 case KEY_LEFT:
117 continue;
118 case KEY_RIGHT:
119 continue;
120 case KEY_BACKSPACE:
121 case 127:
122 if (input_x || scroll) {
123 wattrset(dialog, inputbox_attr);
124 if (!input_x) {
125 scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
126 wmove(dialog, box_y, box_x);
127 for (i = 0; i < box_width; i++)
128 waddch(dialog,
129 instr[scroll + input_x + i] ?
130 instr[scroll + input_x + i] : ' ');
131 input_x = strlen(instr) - scroll;
132 } else
133 input_x--;
134 instr[scroll + input_x] = '\0';
135 mvwaddch(dialog, box_y, input_x + box_x, ' ');
136 wmove(dialog, box_y, input_x + box_x);
137 wrefresh(dialog);
138 }
139 continue;
140 default:
141 if (key < 0x100 && isprint(key)) {
142 if (scroll + input_x < MAX_LEN) {
143 wattrset(dialog, inputbox_attr);
144 instr[scroll + input_x] = key;
145 instr[scroll + input_x + 1] = '\0';
146 if (input_x == box_width - 1) {
147 scroll++;
148 wmove(dialog, box_y, box_x);
149 for (i = 0; i < box_width - 1; i++)
150 waddch(dialog, instr [scroll + i]);
151 } else {
152 wmove(dialog, box_y, input_x++ + box_x);
153 waddch(dialog, key);
154 }
155 wrefresh(dialog);
156 } else
157 flash(); /* Alarm user about overflow */
158 continue;
159 }
160 }
161 }
162 switch (key) {
163 case 'O':
164 case 'o':
165 delwin(dialog);
166 return 0;
167 case 'H':
168 case 'h':
169 delwin(dialog);
170 return 1;
171 case KEY_UP:
172 case KEY_LEFT:
173 switch (button) {
174 case -1:
175 button = 1; /* Indicates "Cancel" button is selected */
176 print_buttons(dialog, height, width, 1);
177 break;
178 case 0:
179 button = -1; /* Indicates input box is selected */
180 print_buttons(dialog, height, width, 0);
181 wmove(dialog, box_y, box_x + input_x);
182 wrefresh(dialog);
183 break;
184 case 1:
185 button = 0; /* Indicates "OK" button is selected */
186 print_buttons(dialog, height, width, 0);
187 break;
188 }
189 break;
190 case TAB:
191 case KEY_DOWN:
192 case KEY_RIGHT:
193 switch (button) {
194 case -1:
195 button = 0; /* Indicates "OK" button is selected */
196 print_buttons(dialog, height, width, 0);
197 break;
198 case 0:
199 button = 1; /* Indicates "Cancel" button is selected */
200 print_buttons(dialog, height, width, 1);
201 break;
202 case 1:
203 button = -1; /* Indicates input box is selected */
204 print_buttons(dialog, height, width, 0);
205 wmove(dialog, box_y, box_x + input_x);
206 wrefresh(dialog);
207 break;
208 }
209 break;
210 case ' ':
211 case '\n':
212 delwin(dialog);
213 return (button == -1 ? 0 : button);
214 case 'X':
215 case 'x':
216 key = ESC;
217 case ESC:
218 break;
219 }
220 }
221
222 delwin(dialog);
223 return -1; /* ESC pressed */
224}
diff --git a/scripts/kconfig/lxdialog/lxdialog.c b/scripts/kconfig/lxdialog/lxdialog.c
new file mode 100644
index 000000000..79f6c5fb5
--- /dev/null
+++ b/scripts/kconfig/lxdialog/lxdialog.c
@@ -0,0 +1,204 @@
1/*
2 * dialog - Display simple dialog boxes from shell scripts
3 *
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include "dialog.h"
23
24static void Usage(const char *name);
25
26typedef int (jumperFn) (const char *title, int argc, const char *const *argv);
27
28struct Mode {
29 char *name;
30 int argmin, argmax, argmod;
31 jumperFn *jumper;
32};
33
34jumperFn j_menu, j_radiolist, j_yesno, j_textbox, j_inputbox;
35jumperFn j_msgbox, j_infobox;
36
37static struct Mode modes[] = {
38 {"--menu", 9, 0, 3, j_menu},
39 {"--radiolist", 9, 0, 3, j_radiolist},
40 {"--yesno", 5, 5, 1, j_yesno},
41 {"--textbox", 5, 5, 1, j_textbox},
42 {"--inputbox", 5, 6, 1, j_inputbox},
43 {"--msgbox", 5, 5, 1, j_msgbox},
44 {"--infobox", 5, 5, 1, j_infobox},
45 {NULL, 0, 0, 0, NULL}
46};
47
48static struct Mode *modePtr;
49
50#ifdef LOCALE
51#include <locale.h>
52#endif
53
54int main(int argc, const char *const *argv)
55{
56 int offset = 0, opt_clear = 0, end_common_opts = 0, retval;
57 const char *title = NULL;
58
59#ifdef LOCALE
60 (void)setlocale(LC_ALL, "");
61#endif
62
63#ifdef TRACE
64 trace(TRACE_CALLS | TRACE_UPDATE);
65#endif
66 if (argc < 2) {
67 Usage(argv[0]);
68 exit(-1);
69 }
70
71 while (offset < argc - 1 && !end_common_opts) { /* Common options */
72 if (!strcmp(argv[offset + 1], "--title")) {
73 if (argc - offset < 3 || title != NULL) {
74 Usage(argv[0]);
75 exit(-1);
76 } else {
77 title = argv[offset + 2];
78 offset += 2;
79 }
80 } else if (!strcmp(argv[offset + 1], "--backtitle")) {
81 if (backtitle != NULL) {
82 Usage(argv[0]);
83 exit(-1);
84 } else {
85 backtitle = argv[offset + 2];
86 offset += 2;
87 }
88 } else if (!strcmp(argv[offset + 1], "--clear")) {
89 if (opt_clear) { /* Hey, "--clear" can't appear twice! */
90 Usage(argv[0]);
91 exit(-1);
92 } else if (argc == 2) { /* we only want to clear the screen */
93 init_dialog();
94 refresh(); /* init_dialog() will clear the screen for us */
95 end_dialog();
96 return 0;
97 } else {
98 opt_clear = 1;
99 offset++;
100 }
101 } else /* no more common options */
102 end_common_opts = 1;
103 }
104
105 if (argc - 1 == offset) { /* no more options */
106 Usage(argv[0]);
107 exit(-1);
108 }
109 /* use a table to look for the requested mode, to avoid code duplication */
110
111 for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */
112 if (!strcmp(argv[offset + 1], modePtr->name))
113 break;
114
115 if (!modePtr->name)
116 Usage(argv[0]);
117 if (argc - offset < modePtr->argmin)
118 Usage(argv[0]);
119 if (modePtr->argmax && argc - offset > modePtr->argmax)
120 Usage(argv[0]);
121
122 init_dialog();
123 retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset);
124
125 if (opt_clear) { /* clear screen before exit */
126 attr_clear(stdscr, LINES, COLS, screen_attr);
127 refresh();
128 }
129 end_dialog();
130
131 exit(retval);
132}
133
134/*
135 * Print program usage
136 */
137static void Usage(const char *name)
138{
139 fprintf(stderr, "\
140\ndialog, by Savio Lam (lam836@cs.cuhk.hk).\
141\n patched by Stuart Herbert (S.Herbert@shef.ac.uk)\
142\n modified/gutted for use as a Linux kernel config tool by \
143\n William Roadcap (roadcapw@cfw.com)\
144\n\
145\n* Display dialog boxes from shell scripts *\
146\n\
147\nUsage: %s --clear\
148\n %s [--title <title>] [--backtitle <backtitle>] --clear <Box options>\
149\n\
150\nBox options:\
151\n\
152\n --menu <text> <height> <width> <menu height> <tag1> <item1>...\
153\n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\
154\n --textbox <file> <height> <width>\
155\n --inputbox <text> <height> <width> [<init>]\
156\n --yesno <text> <height> <width>\
157\n", name, name);
158 exit(-1);
159}
160
161/*
162 * These are the program jumpers
163 */
164
165int j_menu(const char *t, int ac, const char *const *av)
166{
167 return dialog_menu(t, av[2], atoi(av[3]), atoi(av[4]),
168 atoi(av[5]), av[6], (ac - 6) / 2, av + 7);
169}
170
171int j_radiolist(const char *t, int ac, const char *const *av)
172{
173 return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]),
174 atoi(av[5]), (ac - 6) / 3, av + 6);
175}
176
177int j_textbox(const char *t, int ac, const char *const *av)
178{
179 return dialog_textbox(t, av[2], atoi(av[3]), atoi(av[4]));
180}
181
182int j_yesno(const char *t, int ac, const char *const *av)
183{
184 return dialog_yesno(t, av[2], atoi(av[3]), atoi(av[4]));
185}
186
187int j_inputbox(const char *t, int ac, const char *const *av)
188{
189 int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]),
190 ac == 6 ? av[5] : (char *)NULL);
191 if (ret == 0)
192 fprintf(stderr, dialog_input_result);
193 return ret;
194}
195
196int j_msgbox(const char *t, int ac, const char *const *av)
197{
198 return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 1);
199}
200
201int j_infobox(const char *t, int ac, const char *const *av)
202{
203 return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 0);
204}
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
new file mode 100644
index 000000000..bf8052f4f
--- /dev/null
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -0,0 +1,426 @@
1/*
2 * menubox.c -- implements the menu box
3 *
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22/*
23 * Changes by Clifford Wolf (god@clifford.at)
24 *
25 * [ 1998-06-13 ]
26 *
27 * *) A bugfix for the Page-Down problem
28 *
29 * *) Formerly when I used Page Down and Page Up, the cursor would be set
30 * to the first position in the menu box. Now lxdialog is a bit
31 * smarter and works more like other menu systems (just have a look at
32 * it).
33 *
34 * *) Formerly if I selected something my scrolling would be broken because
35 * lxdialog is re-invoked by the Menuconfig shell script, can't
36 * remember the last scrolling position, and just sets it so that the
37 * cursor is at the bottom of the box. Now it writes the temporary file
38 * lxdialog.scrltmp which contains this information. The file is
39 * deleted by lxdialog if the user leaves a submenu or enters a new
40 * one, but it would be nice if Menuconfig could make another "rm -f"
41 * just to be sure. Just try it out - you will recognise a difference!
42 *
43 * [ 1998-06-14 ]
44 *
45 * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files
46 * and menus change their size on the fly.
47 *
48 * *) If for some reason the last scrolling position is not saved by
49 * lxdialog, it sets the scrolling so that the selected item is in the
50 * middle of the menu box, not at the bottom.
51 *
52 * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net)
53 * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus.
54 * This fixes a bug in Menuconfig where using ' ' to descend into menus
55 * would leave mis-synchronized lxdialog.scrltmp files lying around,
56 * fscanf would read in 'scroll', and eventually that value would get used.
57 */
58
59#include "dialog.h"
60
61static int menu_width, item_x;
62
63/*
64 * Print menu item
65 */
66static void do_print_item(WINDOW * win, const char *item, int choice,
67 int selected, int hotkey)
68{
69 int j;
70 char *menu_item = malloc(menu_width + 1);
71
72 strncpy(menu_item, item, menu_width - item_x);
73 menu_item[menu_width] = 0;
74 j = first_alpha(menu_item, "YyNnMmHh");
75
76 /* Clear 'residue' of last item */
77 wattrset(win, menubox_attr);
78 wmove(win, choice, 0);
79#if OLD_NCURSES
80 {
81 int i;
82 for (i = 0; i < menu_width; i++)
83 waddch(win, ' ');
84 }
85#else
86 wclrtoeol(win);
87#endif
88 wattrset(win, selected ? item_selected_attr : item_attr);
89 mvwaddstr(win, choice, item_x, menu_item);
90 if (hotkey) {
91 wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
92 mvwaddch(win, choice, item_x + j, menu_item[j]);
93 }
94 if (selected) {
95 wmove(win, choice, item_x + 1);
96 }
97 free(menu_item);
98 wrefresh(win);
99}
100
101#define print_item(index, choice, selected) \
102do {\
103 int hotkey = (items[(index) * 2][0] != ':'); \
104 do_print_item(menu, items[(index) * 2 + 1], choice, selected, hotkey); \
105} while (0)
106
107/*
108 * Print the scroll indicators.
109 */
110static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x,
111 int height)
112{
113 int cur_y, cur_x;
114
115 getyx(win, cur_y, cur_x);
116
117 wmove(win, y, x);
118
119 if (scroll > 0) {
120 wattrset(win, uarrow_attr);
121 waddch(win, ACS_UARROW);
122 waddstr(win, "(-)");
123 } else {
124 wattrset(win, menubox_attr);
125 waddch(win, ACS_HLINE);
126 waddch(win, ACS_HLINE);
127 waddch(win, ACS_HLINE);
128 waddch(win, ACS_HLINE);
129 }
130
131 y = y + height + 1;
132 wmove(win, y, x);
133 wrefresh(win);
134
135 if ((height < item_no) && (scroll + height < item_no)) {
136 wattrset(win, darrow_attr);
137 waddch(win, ACS_DARROW);
138 waddstr(win, "(+)");
139 } else {
140 wattrset(win, menubox_border_attr);
141 waddch(win, ACS_HLINE);
142 waddch(win, ACS_HLINE);
143 waddch(win, ACS_HLINE);
144 waddch(win, ACS_HLINE);
145 }
146
147 wmove(win, cur_y, cur_x);
148 wrefresh(win);
149}
150
151/*
152 * Display the termination buttons.
153 */
154static void print_buttons(WINDOW * win, int height, int width, int selected)
155{
156 int x = width / 2 - 16;
157 int y = height - 2;
158
159 print_button(win, "Select", y, x, selected == 0);
160 print_button(win, " Exit ", y, x + 12, selected == 1);
161 print_button(win, " Help ", y, x + 24, selected == 2);
162
163 wmove(win, y, x + 1 + 12 * selected);
164 wrefresh(win);
165}
166
167/* scroll up n lines (n may be negative) */
168static void do_scroll(WINDOW *win, int *scroll, int n)
169{
170 /* Scroll menu up */
171 scrollok(win, TRUE);
172 wscrl(win, n);
173 scrollok(win, FALSE);
174 *scroll = *scroll + n;
175 wrefresh(win);
176}
177
178/*
179 * Display a menu for choosing among a number of options
180 */
181int dialog_menu(const char *title, const char *prompt, int height, int width,
182 int menu_height, const char *current, int item_no,
183 const char *const *items)
184{
185 int i, j, x, y, box_x, box_y;
186 int key = 0, button = 0, scroll = 0, choice = 0;
187 int first_item = 0, max_choice;
188 WINDOW *dialog, *menu;
189 FILE *f;
190
191 max_choice = MIN(menu_height, item_no);
192
193 /* center dialog box on screen */
194 x = (COLS - width) / 2;
195 y = (LINES - height) / 2;
196
197 draw_shadow(stdscr, y, x, height, width);
198
199 dialog = newwin(height, width, y, x);
200 keypad(dialog, TRUE);
201
202 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
203 wattrset(dialog, border_attr);
204 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
205 for (i = 0; i < width - 2; i++)
206 waddch(dialog, ACS_HLINE);
207 wattrset(dialog, dialog_attr);
208 wbkgdset(dialog, dialog_attr & A_COLOR);
209 waddch(dialog, ACS_RTEE);
210
211 print_title(dialog, title, width);
212
213 wattrset(dialog, dialog_attr);
214 print_autowrap(dialog, prompt, width - 2, 1, 3);
215
216 menu_width = width - 6;
217 box_y = height - menu_height - 5;
218 box_x = (width - menu_width) / 2 - 1;
219
220 /* create new window for the menu */
221 menu = subwin(dialog, menu_height, menu_width,
222 y + box_y + 1, x + box_x + 1);
223 keypad(menu, TRUE);
224
225 /* draw a box around the menu items */
226 draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
227 menubox_border_attr, menubox_attr);
228
229 item_x = (menu_width - 70) / 2;
230
231 /* Set choice to default item */
232 for (i = 0; i < item_no; i++)
233 if (strcmp(current, items[i * 2]) == 0)
234 choice = i;
235
236 /* get the scroll info from the temp file */
237 if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) {
238 if ((fscanf(f, "%d\n", &scroll) == 1) && (scroll <= choice) &&
239 (scroll + max_choice > choice) && (scroll >= 0) &&
240 (scroll + max_choice <= item_no)) {
241 first_item = scroll;
242 choice = choice - scroll;
243 fclose(f);
244 } else {
245 scroll = 0;
246 remove("lxdialog.scrltmp");
247 fclose(f);
248 f = NULL;
249 }
250 }
251 if ((choice >= max_choice) || (f == NULL && choice >= max_choice / 2)) {
252 if (choice >= item_no - max_choice / 2)
253 scroll = first_item = item_no - max_choice;
254 else
255 scroll = first_item = choice - max_choice / 2;
256 choice = choice - scroll;
257 }
258
259 /* Print the menu */
260 for (i = 0; i < max_choice; i++) {
261 print_item(first_item + i, i, i == choice);
262 }
263
264 wnoutrefresh(menu);
265
266 print_arrows(dialog, item_no, scroll,
267 box_y, box_x + item_x + 1, menu_height);
268
269 print_buttons(dialog, height, width, 0);
270 wmove(menu, choice, item_x + 1);
271 wrefresh(menu);
272
273 while (key != ESC) {
274 key = wgetch(menu);
275
276 if (key < 256 && isalpha(key))
277 key = tolower(key);
278
279 if (strchr("ynmh", key))
280 i = max_choice;
281 else {
282 for (i = choice + 1; i < max_choice; i++) {
283 j = first_alpha(items[(scroll + i) * 2 + 1], "YyNnMmHh");
284 if (key == tolower(items[(scroll + i) * 2 + 1][j]))
285 break;
286 }
287 if (i == max_choice)
288 for (i = 0; i < max_choice; i++) {
289 j = first_alpha(items [(scroll + i) * 2 + 1], "YyNnMmHh");
290 if (key == tolower(items[(scroll + i) * 2 + 1][j]))
291 break;
292 }
293 }
294
295 if (i < max_choice ||
296 key == KEY_UP || key == KEY_DOWN ||
297 key == '-' || key == '+' ||
298 key == KEY_PPAGE || key == KEY_NPAGE) {
299 /* Remove highligt of current item */
300 print_item(scroll + choice, choice, FALSE);
301
302 if (key == KEY_UP || key == '-') {
303 if (choice < 2 && scroll) {
304 /* Scroll menu down */
305 do_scroll(menu, &scroll, -1);
306
307 print_item(scroll, 0, FALSE);
308 } else
309 choice = MAX(choice - 1, 0);
310
311 } else if (key == KEY_DOWN || key == '+') {
312 print_item(scroll+choice, choice, FALSE);
313
314 if ((choice > max_choice - 3) &&
315 (scroll + max_choice < item_no)) {
316 /* Scroll menu up */
317 do_scroll(menu, &scroll, 1);
318
319 print_item(scroll+max_choice - 1,
320 max_choice - 1, FALSE);
321 } else
322 choice = MIN(choice + 1, max_choice - 1);
323
324 } else if (key == KEY_PPAGE) {
325 scrollok(menu, TRUE);
326 for (i = 0; (i < max_choice); i++) {
327 if (scroll > 0) {
328 do_scroll(menu, &scroll, -1);
329 print_item(scroll, 0, FALSE);
330 } else {
331 if (choice > 0)
332 choice--;
333 }
334 }
335
336 } else if (key == KEY_NPAGE) {
337 for (i = 0; (i < max_choice); i++) {
338 if (scroll + max_choice < item_no) {
339 do_scroll(menu, &scroll, 1);
340 print_item(scroll+max_choice-1,
341 max_choice - 1, FALSE);
342 } else {
343 if (choice + 1 < max_choice)
344 choice++;
345 }
346 }
347 } else
348 choice = i;
349
350 print_item(scroll + choice, choice, TRUE);
351
352 print_arrows(dialog, item_no, scroll,
353 box_y, box_x + item_x + 1, menu_height);
354
355 wnoutrefresh(dialog);
356 wrefresh(menu);
357
358 continue; /* wait for another key press */
359 }
360
361 switch (key) {
362 case KEY_LEFT:
363 case TAB:
364 case KEY_RIGHT:
365 button = ((key == KEY_LEFT ? --button : ++button) < 0)
366 ? 2 : (button > 2 ? 0 : button);
367
368 print_buttons(dialog, height, width, button);
369 wrefresh(menu);
370 break;
371 case ' ':
372 case 's':
373 case 'y':
374 case 'n':
375 case 'm':
376 case '/':
377 /* save scroll info */
378 if ((f = fopen("lxdialog.scrltmp", "w")) != NULL) {
379 fprintf(f, "%d\n", scroll);
380 fclose(f);
381 }
382 delwin(dialog);
383 fprintf(stderr, "%s\n", items[(scroll + choice) * 2]);
384 switch (key) {
385 case 's':
386 return 3;
387 case 'y':
388 return 3;
389 case 'n':
390 return 4;
391 case 'm':
392 return 5;
393 case ' ':
394 return 6;
395 case '/':
396 return 7;
397 }
398 return 0;
399 case 'h':
400 case '?':
401 button = 2;
402 case '\n':
403 delwin(dialog);
404 if (button == 2)
405 fprintf(stderr, "%s \"%s\"\n",
406 items[(scroll + choice) * 2],
407 items[(scroll + choice) * 2 + 1] +
408 first_alpha(items [(scroll + choice) * 2 + 1], ""));
409 else
410 fprintf(stderr, "%s\n",
411 items[(scroll + choice) * 2]);
412
413 remove("lxdialog.scrltmp");
414 return button;
415 case 'e':
416 case 'x':
417 key = ESC;
418 case ESC:
419 break;
420 }
421 }
422
423 delwin(dialog);
424 remove("lxdialog.scrltmp");
425 return -1; /* ESC pressed */
426}
diff --git a/scripts/kconfig/lxdialog/msgbox.c b/scripts/kconfig/lxdialog/msgbox.c
new file mode 100644
index 000000000..7323f5471
--- /dev/null
+++ b/scripts/kconfig/lxdialog/msgbox.c
@@ -0,0 +1,71 @@
1/*
2 * msgbox.c -- implements the message box and info box
3 *
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include "dialog.h"
23
24/*
25 * Display a message box. Program will pause and display an "OK" button
26 * if the parameter 'pause' is non-zero.
27 */
28int dialog_msgbox(const char *title, const char *prompt, int height, int width,
29 int pause)
30{
31 int i, x, y, key = 0;
32 WINDOW *dialog;
33
34 /* center dialog box on screen */
35 x = (COLS - width) / 2;
36 y = (LINES - height) / 2;
37
38 draw_shadow(stdscr, y, x, height, width);
39
40 dialog = newwin(height, width, y, x);
41 keypad(dialog, TRUE);
42
43 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
44
45 print_title(dialog, title, width);
46
47 wattrset(dialog, dialog_attr);
48 print_autowrap(dialog, prompt, width - 2, 1, 2);
49
50 if (pause) {
51 wattrset(dialog, border_attr);
52 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
53 for (i = 0; i < width - 2; i++)
54 waddch(dialog, ACS_HLINE);
55 wattrset(dialog, dialog_attr);
56 waddch(dialog, ACS_RTEE);
57
58 print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE);
59
60 wrefresh(dialog);
61 while (key != ESC && key != '\n' && key != ' ' &&
62 key != 'O' && key != 'o' && key != 'X' && key != 'x')
63 key = wgetch(dialog);
64 } else {
65 key = '\n';
66 wrefresh(dialog);
67 }
68
69 delwin(dialog);
70 return key == ESC ? -1 : 0;
71}
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c
new file mode 100644
index 000000000..77848bb8e
--- /dev/null
+++ b/scripts/kconfig/lxdialog/textbox.c
@@ -0,0 +1,533 @@
1/*
2 * textbox.c -- implements the text box
3 *
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include "dialog.h"
23
24static void back_lines(int n);
25static void print_page(WINDOW * win, int height, int width);
26static void print_line(WINDOW * win, int row, int width);
27static char *get_line(void);
28static void print_position(WINDOW * win, int height, int width);
29
30static int hscroll, fd, file_size, bytes_read;
31static int begin_reached = 1, end_reached, page_length;
32static char *buf, *page;
33
34/*
35 * Display text from a file in a dialog box.
36 */
37int dialog_textbox(const char *title, const char *file, int height, int width)
38{
39 int i, x, y, cur_x, cur_y, fpos, key = 0;
40 int passed_end;
41 char search_term[MAX_LEN + 1];
42 WINDOW *dialog, *text;
43
44 search_term[0] = '\0'; /* no search term entered yet */
45
46 /* Open input file for reading */
47 if ((fd = open(file, O_RDONLY)) == -1) {
48 endwin();
49 fprintf(stderr, "\nCan't open input file in dialog_textbox().\n");
50 exit(-1);
51 }
52 /* Get file size. Actually, 'file_size' is the real file size - 1,
53 since it's only the last byte offset from the beginning */
54 if ((file_size = lseek(fd, 0, SEEK_END)) == -1) {
55 endwin();
56 fprintf(stderr, "\nError getting file size in dialog_textbox().\n");
57 exit(-1);
58 }
59 /* Restore file pointer to beginning of file after getting file size */
60 if (lseek(fd, 0, SEEK_SET) == -1) {
61 endwin();
62 fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
63 exit(-1);
64 }
65 /* Allocate space for read buffer */
66 if ((buf = malloc(BUF_SIZE + 1)) == NULL) {
67 endwin();
68 fprintf(stderr, "\nCan't allocate memory in dialog_textbox().\n");
69 exit(-1);
70 }
71 if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
72 endwin();
73 fprintf(stderr, "\nError reading file in dialog_textbox().\n");
74 exit(-1);
75 }
76 buf[bytes_read] = '\0'; /* mark end of valid data */
77 page = buf; /* page is pointer to start of page to be displayed */
78
79 /* center dialog box on screen */
80 x = (COLS - width) / 2;
81 y = (LINES - height) / 2;
82
83 draw_shadow(stdscr, y, x, height, width);
84
85 dialog = newwin(height, width, y, x);
86 keypad(dialog, TRUE);
87
88 /* Create window for text region, used for scrolling text */
89 text = subwin(dialog, height - 4, width - 2, y + 1, x + 1);
90 wattrset(text, dialog_attr);
91 wbkgdset(text, dialog_attr & A_COLOR);
92
93 keypad(text, TRUE);
94
95 /* register the new window, along with its borders */
96 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
97
98 wattrset(dialog, border_attr);
99 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
100 for (i = 0; i < width - 2; i++)
101 waddch(dialog, ACS_HLINE);
102 wattrset(dialog, dialog_attr);
103 wbkgdset(dialog, dialog_attr & A_COLOR);
104 waddch(dialog, ACS_RTEE);
105
106 print_title(dialog, title, width);
107
108 print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE);
109 wnoutrefresh(dialog);
110 getyx(dialog, cur_y, cur_x); /* Save cursor position */
111
112 /* Print first page of text */
113 attr_clear(text, height - 4, width - 2, dialog_attr);
114 print_page(text, height - 4, width - 2);
115 print_position(dialog, height, width);
116 wmove(dialog, cur_y, cur_x); /* Restore cursor position */
117 wrefresh(dialog);
118
119 while ((key != ESC) && (key != '\n')) {
120 key = wgetch(dialog);
121 switch (key) {
122 case 'E': /* Exit */
123 case 'e':
124 case 'X':
125 case 'x':
126 delwin(dialog);
127 free(buf);
128 close(fd);
129 return 0;
130 case 'g': /* First page */
131 case KEY_HOME:
132 if (!begin_reached) {
133 begin_reached = 1;
134 /* First page not in buffer? */
135 if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
136 endwin();
137 fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
138 exit(-1);
139 }
140 if (fpos > bytes_read) { /* Yes, we have to read it in */
141 if (lseek(fd, 0, SEEK_SET) == -1) {
142 endwin();
143 fprintf(stderr, "\nError moving file pointer in "
144 "dialog_textbox().\n");
145 exit(-1);
146 }
147 if ((bytes_read =
148 read(fd, buf, BUF_SIZE)) == -1) {
149 endwin();
150 fprintf(stderr, "\nError reading file in dialog_textbox().\n");
151 exit(-1);
152 }
153 buf[bytes_read] = '\0';
154 }
155 page = buf;
156 print_page(text, height - 4, width - 2);
157 print_position(dialog, height, width);
158 wmove(dialog, cur_y, cur_x); /* Restore cursor position */
159 wrefresh(dialog);
160 }
161 break;
162 case 'G': /* Last page */
163 case KEY_END:
164
165 end_reached = 1;
166 /* Last page not in buffer? */
167 if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
168 endwin();
169 fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
170 exit(-1);
171 }
172 if (fpos < file_size) { /* Yes, we have to read it in */
173 if (lseek(fd, -BUF_SIZE, SEEK_END) == -1) {
174 endwin();
175 fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n");
176 exit(-1);
177 }
178 if ((bytes_read =
179 read(fd, buf, BUF_SIZE)) == -1) {
180 endwin();
181 fprintf(stderr, "\nError reading file in dialog_textbox().\n");
182 exit(-1);
183 }
184 buf[bytes_read] = '\0';
185 }
186 page = buf + bytes_read;
187 back_lines(height - 4);
188 print_page(text, height - 4, width - 2);
189 print_position(dialog, height, width);
190 wmove(dialog, cur_y, cur_x); /* Restore cursor position */
191 wrefresh(dialog);
192 break;
193 case 'K': /* Previous line */
194 case 'k':
195 case KEY_UP:
196 if (!begin_reached) {
197 back_lines(page_length + 1);
198
199 /* We don't call print_page() here but use scrolling to ensure
200 faster screen update. However, 'end_reached' and
201 'page_length' should still be updated, and 'page' should
202 point to start of next page. This is done by calling
203 get_line() in the following 'for' loop. */
204 scrollok(text, TRUE);
205 wscrl(text, -1); /* Scroll text region down one line */
206 scrollok(text, FALSE);
207 page_length = 0;
208 passed_end = 0;
209 for (i = 0; i < height - 4; i++) {
210 if (!i) {
211 /* print first line of page */
212 print_line(text, 0, width - 2);
213 wnoutrefresh(text);
214 } else
215 /* Called to update 'end_reached' and 'page' */
216 get_line();
217 if (!passed_end)
218 page_length++;
219 if (end_reached && !passed_end)
220 passed_end = 1;
221 }
222
223 print_position(dialog, height, width);
224 wmove(dialog, cur_y, cur_x); /* Restore cursor position */
225 wrefresh(dialog);
226 }
227 break;
228 case 'B': /* Previous page */
229 case 'b':
230 case KEY_PPAGE:
231 if (begin_reached)
232 break;
233 back_lines(page_length + height - 4);
234 print_page(text, height - 4, width - 2);
235 print_position(dialog, height, width);
236 wmove(dialog, cur_y, cur_x);
237 wrefresh(dialog);
238 break;
239 case 'J': /* Next line */
240 case 'j':
241 case KEY_DOWN:
242 if (!end_reached) {
243 begin_reached = 0;
244 scrollok(text, TRUE);
245 scroll(text); /* Scroll text region up one line */
246 scrollok(text, FALSE);
247 print_line(text, height - 5, width - 2);
248 wnoutrefresh(text);
249 print_position(dialog, height, width);
250 wmove(dialog, cur_y, cur_x); /* Restore cursor position */
251 wrefresh(dialog);
252 }
253 break;
254 case KEY_NPAGE: /* Next page */
255 case ' ':
256 if (end_reached)
257 break;
258
259 begin_reached = 0;
260 print_page(text, height - 4, width - 2);
261 print_position(dialog, height, width);
262 wmove(dialog, cur_y, cur_x);
263 wrefresh(dialog);
264 break;
265 case '0': /* Beginning of line */
266 case 'H': /* Scroll left */
267 case 'h':
268 case KEY_LEFT:
269 if (hscroll <= 0)
270 break;
271
272 if (key == '0')
273 hscroll = 0;
274 else
275 hscroll--;
276 /* Reprint current page to scroll horizontally */
277 back_lines(page_length);
278 print_page(text, height - 4, width - 2);
279 wmove(dialog, cur_y, cur_x);
280 wrefresh(dialog);
281 break;
282 case 'L': /* Scroll right */
283 case 'l':
284 case KEY_RIGHT:
285 if (hscroll >= MAX_LEN)
286 break;
287 hscroll++;
288 /* Reprint current page to scroll horizontally */
289 back_lines(page_length);
290 print_page(text, height - 4, width - 2);
291 wmove(dialog, cur_y, cur_x);
292 wrefresh(dialog);
293 break;
294 case ESC:
295 break;
296 }
297 }
298
299 delwin(dialog);
300 free(buf);
301 close(fd);
302 return -1; /* ESC pressed */
303}
304
305/*
306 * Go back 'n' lines in text file. Called by dialog_textbox().
307 * 'page' will be updated to point to the desired line in 'buf'.
308 */
309static void back_lines(int n)
310{
311 int i, fpos;
312
313 begin_reached = 0;
314 /* We have to distinguish between end_reached and !end_reached
315 since at end of file, the line is not ended by a '\n'.
316 The code inside 'if' basically does a '--page' to move one
317 character backward so as to skip '\n' of the previous line */
318 if (!end_reached) {
319 /* Either beginning of buffer or beginning of file reached? */
320 if (page == buf) {
321 if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
322 endwin();
323 fprintf(stderr, "\nError moving file pointer in "
324 "back_lines().\n");
325 exit(-1);
326 }
327 if (fpos > bytes_read) { /* Not beginning of file yet */
328 /* We've reached beginning of buffer, but not beginning of
329 file yet, so read previous part of file into buffer.
330 Note that we only move backward for BUF_SIZE/2 bytes,
331 but not BUF_SIZE bytes to avoid re-reading again in
332 print_page() later */
333 /* Really possible to move backward BUF_SIZE/2 bytes? */
334 if (fpos < BUF_SIZE / 2 + bytes_read) {
335 /* No, move less then */
336 if (lseek(fd, 0, SEEK_SET) == -1) {
337 endwin();
338 fprintf(stderr, "\nError moving file pointer in "
339 "back_lines().\n");
340 exit(-1);
341 }
342 page = buf + fpos - bytes_read;
343 } else { /* Move backward BUF_SIZE/2 bytes */
344 if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) {
345 endwin();
346 fprintf(stderr, "\nError moving file pointer "
347 "in back_lines().\n");
348 exit(-1);
349 }
350 page = buf + BUF_SIZE / 2;
351 }
352 if ((bytes_read =
353 read(fd, buf, BUF_SIZE)) == -1) {
354 endwin();
355 fprintf(stderr, "\nError reading file in back_lines().\n");
356 exit(-1);
357 }
358 buf[bytes_read] = '\0';
359 } else { /* Beginning of file reached */
360 begin_reached = 1;
361 return;
362 }
363 }
364 if (*(--page) != '\n') { /* '--page' here */
365 /* Something's wrong... */
366 endwin();
367 fprintf(stderr, "\nInternal error in back_lines().\n");
368 exit(-1);
369 }
370 }
371 /* Go back 'n' lines */
372 for (i = 0; i < n; i++)
373 do {
374 if (page == buf) {
375 if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
376 endwin();
377 fprintf(stderr, "\nError moving file pointer in back_lines().\n");
378 exit(-1);
379 }
380 if (fpos > bytes_read) {
381 /* Really possible to move backward BUF_SIZE/2 bytes? */
382 if (fpos < BUF_SIZE / 2 + bytes_read) {
383 /* No, move less then */
384 if (lseek(fd, 0, SEEK_SET) == -1) {
385 endwin();
386 fprintf(stderr, "\nError moving file pointer "
387 "in back_lines().\n");
388 exit(-1);
389 }
390 page = buf + fpos - bytes_read;
391 } else { /* Move backward BUF_SIZE/2 bytes */
392 if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) {
393 endwin();
394 fprintf(stderr, "\nError moving file pointer"
395 " in back_lines().\n");
396 exit(-1);
397 }
398 page = buf + BUF_SIZE / 2;
399 }
400 if ((bytes_read =
401 read(fd, buf, BUF_SIZE)) == -1) {
402 endwin();
403 fprintf(stderr, "\nError reading file in "
404 "back_lines().\n");
405 exit(-1);
406 }
407 buf[bytes_read] = '\0';
408 } else { /* Beginning of file reached */
409 begin_reached = 1;
410 return;
411 }
412 }
413 } while (*(--page) != '\n');
414 page++;
415}
416
417/*
418 * Print a new page of text. Called by dialog_textbox().
419 */
420static void print_page(WINDOW * win, int height, int width)
421{
422 int i, passed_end = 0;
423
424 page_length = 0;
425 for (i = 0; i < height; i++) {
426 print_line(win, i, width);
427 if (!passed_end)
428 page_length++;
429 if (end_reached && !passed_end)
430 passed_end = 1;
431 }
432 wnoutrefresh(win);
433}
434
435/*
436 * Print a new line of text. Called by dialog_textbox() and print_page().
437 */
438static void print_line(WINDOW * win, int row, int width)
439{
440 int y, x;
441 char *line;
442
443 line = get_line();
444 line += MIN(strlen(line), hscroll); /* Scroll horizontally */
445 wmove(win, row, 0); /* move cursor to correct line */
446 waddch(win, ' ');
447 waddnstr(win, line, MIN(strlen(line), width - 2));
448
449 getyx(win, y, x);
450 /* Clear 'residue' of previous line */
451#if OLD_NCURSES
452 {
453 int i;
454 for (i = 0; i < width - x; i++)
455 waddch(win, ' ');
456 }
457#else
458 wclrtoeol(win);
459#endif
460}
461
462/*
463 * Return current line of text. Called by dialog_textbox() and print_line().
464 * 'page' should point to start of current line before calling, and will be
465 * updated to point to start of next line.
466 */
467static char *get_line(void)
468{
469 int i = 0, fpos;
470 static char line[MAX_LEN + 1];
471
472 end_reached = 0;
473 while (*page != '\n') {
474 if (*page == '\0') {
475 /* Either end of file or end of buffer reached */
476 if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
477 endwin();
478 fprintf(stderr, "\nError moving file pointer in "
479 "get_line().\n");
480 exit(-1);
481 }
482 if (fpos < file_size) { /* Not end of file yet */
483 /* We've reached end of buffer, but not end of file yet,
484 so read next part of file into buffer */
485 if ((bytes_read =
486 read(fd, buf, BUF_SIZE)) == -1) {
487 endwin();
488 fprintf(stderr, "\nError reading file in get_line().\n");
489 exit(-1);
490 }
491 buf[bytes_read] = '\0';
492 page = buf;
493 } else {
494 if (!end_reached)
495 end_reached = 1;
496 break;
497 }
498 } else if (i < MAX_LEN)
499 line[i++] = *(page++);
500 else {
501 /* Truncate lines longer than MAX_LEN characters */
502 if (i == MAX_LEN)
503 line[i++] = '\0';
504 page++;
505 }
506 }
507 if (i <= MAX_LEN)
508 line[i] = '\0';
509 if (!end_reached)
510 page++; /* move pass '\n' */
511
512 return line;
513}
514
515/*
516 * Print current position
517 */
518static void print_position(WINDOW * win, int height, int width)
519{
520 int fpos, percent;
521
522 if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
523 endwin();
524 fprintf(stderr, "\nError moving file pointer in print_position().\n");
525 exit(-1);
526 }
527 wattrset(win, position_indicator_attr);
528 wbkgdset(win, position_indicator_attr & A_COLOR);
529 percent = !file_size ?
530 100 : ((fpos - bytes_read + page - buf) * 100) / file_size;
531 wmove(win, height - 3, width - 9);
532 wprintw(win, "(%3d%%)", percent);
533}
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
new file mode 100644
index 000000000..f82cebb9f
--- /dev/null
+++ b/scripts/kconfig/lxdialog/util.c
@@ -0,0 +1,362 @@
1/*
2 * util.c
3 *
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include "dialog.h"
23
24/* use colors by default? */
25bool use_colors = 1;
26
27const char *backtitle = NULL;
28
29/*
30 * Attribute values, default is for mono display
31 */
32chtype attributes[] = {
33 A_NORMAL, /* screen_attr */
34 A_NORMAL, /* shadow_attr */
35 A_NORMAL, /* dialog_attr */
36 A_BOLD, /* title_attr */
37 A_NORMAL, /* border_attr */
38 A_REVERSE, /* button_active_attr */
39 A_DIM, /* button_inactive_attr */
40 A_REVERSE, /* button_key_active_attr */
41 A_BOLD, /* button_key_inactive_attr */
42 A_REVERSE, /* button_label_active_attr */
43 A_NORMAL, /* button_label_inactive_attr */
44 A_NORMAL, /* inputbox_attr */
45 A_NORMAL, /* inputbox_border_attr */
46 A_NORMAL, /* searchbox_attr */
47 A_BOLD, /* searchbox_title_attr */
48 A_NORMAL, /* searchbox_border_attr */
49 A_BOLD, /* position_indicator_attr */
50 A_NORMAL, /* menubox_attr */
51 A_NORMAL, /* menubox_border_attr */
52 A_NORMAL, /* item_attr */
53 A_REVERSE, /* item_selected_attr */
54 A_BOLD, /* tag_attr */
55 A_REVERSE, /* tag_selected_attr */
56 A_BOLD, /* tag_key_attr */
57 A_REVERSE, /* tag_key_selected_attr */
58 A_BOLD, /* check_attr */
59 A_REVERSE, /* check_selected_attr */
60 A_BOLD, /* uarrow_attr */
61 A_BOLD /* darrow_attr */
62};
63
64#include "colors.h"
65
66/*
67 * Table of color values
68 */
69int color_table[][3] = {
70 {SCREEN_FG, SCREEN_BG, SCREEN_HL},
71 {SHADOW_FG, SHADOW_BG, SHADOW_HL},
72 {DIALOG_FG, DIALOG_BG, DIALOG_HL},
73 {TITLE_FG, TITLE_BG, TITLE_HL},
74 {BORDER_FG, BORDER_BG, BORDER_HL},
75 {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL},
76 {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL},
77 {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL},
78 {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG,
79 BUTTON_KEY_INACTIVE_HL},
80 {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG,
81 BUTTON_LABEL_ACTIVE_HL},
82 {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG,
83 BUTTON_LABEL_INACTIVE_HL},
84 {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL},
85 {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL},
86 {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL},
87 {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL},
88 {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL},
89 {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL},
90 {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL},
91 {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL},
92 {ITEM_FG, ITEM_BG, ITEM_HL},
93 {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL},
94 {TAG_FG, TAG_BG, TAG_HL},
95 {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL},
96 {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL},
97 {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL},
98 {CHECK_FG, CHECK_BG, CHECK_HL},
99 {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL},
100 {UARROW_FG, UARROW_BG, UARROW_HL},
101 {DARROW_FG, DARROW_BG, DARROW_HL},
102}; /* color_table */
103
104/*
105 * Set window to attribute 'attr'
106 */
107void attr_clear(WINDOW * win, int height, int width, chtype attr)
108{
109 int i, j;
110
111 wattrset(win, attr);
112 for (i = 0; i < height; i++) {
113 wmove(win, i, 0);
114 for (j = 0; j < width; j++)
115 waddch(win, ' ');
116 }
117 touchwin(win);
118}
119
120void dialog_clear(void)
121{
122 attr_clear(stdscr, LINES, COLS, screen_attr);
123 /* Display background title if it exists ... - SLH */
124 if (backtitle != NULL) {
125 int i;
126
127 wattrset(stdscr, screen_attr);
128 mvwaddstr(stdscr, 0, 1, (char *)backtitle);
129 wmove(stdscr, 1, 1);
130 for (i = 1; i < COLS - 1; i++)
131 waddch(stdscr, ACS_HLINE);
132 }
133 wnoutrefresh(stdscr);
134}
135
136/*
137 * Do some initialization for dialog
138 */
139void init_dialog(void)
140{
141 initscr(); /* Init curses */
142 keypad(stdscr, TRUE);
143 cbreak();
144 noecho();
145
146 if (use_colors) /* Set up colors */
147 color_setup();
148
149 dialog_clear();
150}
151
152/*
153 * Setup for color display
154 */
155void color_setup(void)
156{
157 int i;
158
159 if (has_colors()) { /* Terminal supports color? */
160 start_color();
161
162 /* Initialize color pairs */
163 for (i = 0; i < ATTRIBUTE_COUNT; i++)
164 init_pair(i + 1, color_table[i][0], color_table[i][1]);
165
166 /* Setup color attributes */
167 for (i = 0; i < ATTRIBUTE_COUNT; i++)
168 attributes[i] = C_ATTR(color_table[i][2], i + 1);
169 }
170}
171
172/*
173 * End using dialog functions.
174 */
175void end_dialog(void)
176{
177 endwin();
178}
179
180/* Print the title of the dialog. Center the title and truncate
181 * tile if wider than dialog (- 2 chars).
182 **/
183void print_title(WINDOW *dialog, const char *title, int width)
184{
185 if (title) {
186 int tlen = MIN(width - 2, strlen(title));
187 wattrset(dialog, title_attr);
188 mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' ');
189 mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen);
190 waddch(dialog, ' ');
191 }
192}
193
194/*
195 * Print a string of text in a window, automatically wrap around to the
196 * next line if the string is too long to fit on one line. Newline
197 * characters '\n' are replaced by spaces. We start on a new line
198 * if there is no room for at least 4 nonblanks following a double-space.
199 */
200void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
201{
202 int newl, cur_x, cur_y;
203 int i, prompt_len, room, wlen;
204 char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
205
206 strcpy(tempstr, prompt);
207
208 prompt_len = strlen(tempstr);
209
210 /*
211 * Remove newlines
212 */
213 for (i = 0; i < prompt_len; i++) {
214 if (tempstr[i] == '\n')
215 tempstr[i] = ' ';
216 }
217
218 if (prompt_len <= width - x * 2) { /* If prompt is short */
219 wmove(win, y, (width - prompt_len) / 2);
220 waddstr(win, tempstr);
221 } else {
222 cur_x = x;
223 cur_y = y;
224 newl = 1;
225 word = tempstr;
226 while (word && *word) {
227 sp = index(word, ' ');
228 if (sp)
229 *sp++ = 0;
230
231 /* Wrap to next line if either the word does not fit,
232 or it is the first word of a new sentence, and it is
233 short, and the next word does not fit. */
234 room = width - cur_x;
235 wlen = strlen(word);
236 if (wlen > room ||
237 (newl && wlen < 4 && sp
238 && wlen + 1 + strlen(sp) > room
239 && (!(sp2 = index(sp, ' '))
240 || wlen + 1 + (sp2 - sp) > room))) {
241 cur_y++;
242 cur_x = x;
243 }
244 wmove(win, cur_y, cur_x);
245 waddstr(win, word);
246 getyx(win, cur_y, cur_x);
247 cur_x++;
248 if (sp && *sp == ' ') {
249 cur_x++; /* double space */
250 while (*++sp == ' ') ;
251 newl = 1;
252 } else
253 newl = 0;
254 word = sp;
255 }
256 }
257}
258
259/*
260 * Print a button
261 */
262void print_button(WINDOW * win, const char *label, int y, int x, int selected)
263{
264 int i, temp;
265
266 wmove(win, y, x);
267 wattrset(win, selected ? button_active_attr : button_inactive_attr);
268 waddstr(win, "<");
269 temp = strspn(label, " ");
270 label += temp;
271 wattrset(win, selected ? button_label_active_attr
272 : button_label_inactive_attr);
273 for (i = 0; i < temp; i++)
274 waddch(win, ' ');
275 wattrset(win, selected ? button_key_active_attr
276 : button_key_inactive_attr);
277 waddch(win, label[0]);
278 wattrset(win, selected ? button_label_active_attr
279 : button_label_inactive_attr);
280 waddstr(win, (char *)label + 1);
281 wattrset(win, selected ? button_active_attr : button_inactive_attr);
282 waddstr(win, ">");
283 wmove(win, y, x + temp + 1);
284}
285
286/*
287 * Draw a rectangular box with line drawing characters
288 */
289void
290draw_box(WINDOW * win, int y, int x, int height, int width,
291 chtype box, chtype border)
292{
293 int i, j;
294
295 wattrset(win, 0);
296 for (i = 0; i < height; i++) {
297 wmove(win, y + i, x);
298 for (j = 0; j < width; j++)
299 if (!i && !j)
300 waddch(win, border | ACS_ULCORNER);
301 else if (i == height - 1 && !j)
302 waddch(win, border | ACS_LLCORNER);
303 else if (!i && j == width - 1)
304 waddch(win, box | ACS_URCORNER);
305 else if (i == height - 1 && j == width - 1)
306 waddch(win, box | ACS_LRCORNER);
307 else if (!i)
308 waddch(win, border | ACS_HLINE);
309 else if (i == height - 1)
310 waddch(win, box | ACS_HLINE);
311 else if (!j)
312 waddch(win, border | ACS_VLINE);
313 else if (j == width - 1)
314 waddch(win, box | ACS_VLINE);
315 else
316 waddch(win, box | ' ');
317 }
318}
319
320/*
321 * Draw shadows along the right and bottom edge to give a more 3D look
322 * to the boxes
323 */
324void draw_shadow(WINDOW * win, int y, int x, int height, int width)
325{
326 int i;
327
328 if (has_colors()) { /* Whether terminal supports color? */
329 wattrset(win, shadow_attr);
330 wmove(win, y + height, x + 2);
331 for (i = 0; i < width; i++)
332 waddch(win, winch(win) & A_CHARTEXT);
333 for (i = y + 1; i < y + height + 1; i++) {
334 wmove(win, i, x + width);
335 waddch(win, winch(win) & A_CHARTEXT);
336 waddch(win, winch(win) & A_CHARTEXT);
337 }
338 wnoutrefresh(win);
339 }
340}
341
342/*
343 * Return the position of the first alphabetic character in a string.
344 */
345int first_alpha(const char *string, const char *exempt)
346{
347 int i, in_paren = 0, c;
348
349 for (i = 0; i < strlen(string); i++) {
350 c = tolower(string[i]);
351
352 if (strchr("<[(", c))
353 ++in_paren;
354 if (strchr(">])", c) && in_paren > 0)
355 --in_paren;
356
357 if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0)
358 return i;
359 }
360
361 return 0;
362}
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c
new file mode 100644
index 000000000..cb2568aae
--- /dev/null
+++ b/scripts/kconfig/lxdialog/yesno.c
@@ -0,0 +1,102 @@
1/*
2 * yesno.c -- implements the yes/no box
3 *
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include "dialog.h"
23
24/*
25 * Display termination buttons
26 */
27static void print_buttons(WINDOW * dialog, int height, int width, int selected)
28{
29 int x = width / 2 - 10;
30 int y = height - 2;
31
32 print_button(dialog, " Yes ", y, x, selected == 0);
33 print_button(dialog, " No ", y, x + 13, selected == 1);
34
35 wmove(dialog, y, x + 1 + 13 * selected);
36 wrefresh(dialog);
37}
38
39/*
40 * Display a dialog box with two buttons - Yes and No
41 */
42int dialog_yesno(const char *title, const char *prompt, int height, int width)
43{
44 int i, x, y, key = 0, button = 0;
45 WINDOW *dialog;
46
47 /* center dialog box on screen */
48 x = (COLS - width) / 2;
49 y = (LINES - height) / 2;
50
51 draw_shadow(stdscr, y, x, height, width);
52
53 dialog = newwin(height, width, y, x);
54 keypad(dialog, TRUE);
55
56 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
57 wattrset(dialog, border_attr);
58 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
59 for (i = 0; i < width - 2; i++)
60 waddch(dialog, ACS_HLINE);
61 wattrset(dialog, dialog_attr);
62 waddch(dialog, ACS_RTEE);
63
64 print_title(dialog, title, width);
65
66 wattrset(dialog, dialog_attr);
67 print_autowrap(dialog, prompt, width - 2, 1, 3);
68
69 print_buttons(dialog, height, width, 0);
70
71 while (key != ESC) {
72 key = wgetch(dialog);
73 switch (key) {
74 case 'Y':
75 case 'y':
76 delwin(dialog);
77 return 0;
78 case 'N':
79 case 'n':
80 delwin(dialog);
81 return 1;
82
83 case TAB:
84 case KEY_LEFT:
85 case KEY_RIGHT:
86 button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button);
87
88 print_buttons(dialog, height, width, button);
89 wrefresh(dialog);
90 break;
91 case ' ':
92 case '\n':
93 delwin(dialog);
94 return button;
95 case ESC:
96 break;
97 }
98 }
99
100 delwin(dialog);
101 return -1; /* ESC pressed */
102}
diff --git a/scripts/config/mconf.c b/scripts/kconfig/mconf.c
index b8f27e69c..7f973195e 100644
--- a/scripts/config/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
@@ -6,8 +5,7 @@
6 * Introduced single menu mode (show all sub-menus in one large tree). 5 * Introduced single menu mode (show all sub-menus in one large tree).
7 * 2002-11-06 Petr Baudis <pasky@ucw.cz> 6 * 2002-11-06 Petr Baudis <pasky@ucw.cz>
8 * 7 *
9 * Directly use liblxdialog library routines. 8 * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
10 * 2002-11-14 Petr Baudis <pasky@ucw.cz>
11 */ 9 */
12 10
13#include <sys/ioctl.h> 11#include <sys/ioctl.h>
@@ -22,28 +20,29 @@
22#include <string.h> 20#include <string.h>
23#include <termios.h> 21#include <termios.h>
24#include <unistd.h> 22#include <unistd.h>
25 23#include <locale.h>
26#include "lxdialog/dialog.h"
27 24
28#define LKC_DIRECT_LINK 25#define LKC_DIRECT_LINK
29#include "lkc.h" 26#include "lkc.h"
30 27
31static char menu_backtitle[128]; 28static char menu_backtitle[128];
32static const char mconf_readme[] = 29static const char mconf_readme[] = N_(
33"Overview\n" 30"Overview\n"
34"--------\n" 31"--------\n"
35"Some features may be built directly into BusyBox. Some features\n" 32"Some kernel features may be built directly into the kernel.\n"
33"Some may be made into loadable runtime modules. Some features\n"
36"may be completely removed altogether. There are also certain\n" 34"may be completely removed altogether. There are also certain\n"
37"parameters which are not really features, but must be\n" 35"kernel parameters which are not really features, but must be\n"
38"entered in as decimal or hexadecimal numbers or possibly text.\n" 36"entered in as decimal or hexadecimal numbers or possibly text.\n"
39"\n" 37"\n"
40"Menu items beginning with [*] or [ ] represent features\n" 38"Menu items beginning with [*], <M> or [ ] represent features\n"
41"configured to be built in or removed respectively.\n" 39"configured to be built in, modularized or removed respectively.\n"
40"Pointed brackets <> represent module capable features.\n"
42"\n" 41"\n"
43"To change any of these features, highlight it with the cursor\n" 42"To change any of these features, highlight it with the cursor\n"
44"keys and press <Y> to build it in or <N> to removed it.\n" 43"keys and press <Y> to build it in, <M> to make it a module or\n"
45"You may also press the <Space Bar> to cycle\n" 44"<N> to removed it. You may also press the <Space Bar> to cycle\n"
46"through the available options (ie. Y->N->Y).\n" 45"through the available options (ie. Y->N->M->Y).\n"
47"\n" 46"\n"
48"Some additional keyboard hints:\n" 47"Some additional keyboard hints:\n"
49"\n" 48"\n"
@@ -116,7 +115,7 @@ static const char mconf_readme[] =
116"-----------------------------\n" 115"-----------------------------\n"
117"Menuconfig supports the use of alternate configuration files for\n" 116"Menuconfig supports the use of alternate configuration files for\n"
118"those who, for various reasons, find it necessary to switch\n" 117"those who, for various reasons, find it necessary to switch\n"
119"between different configurations.\n" 118"between different kernel configurations.\n"
120"\n" 119"\n"
121"At the end of the main menu you will find two options. One is\n" 120"At the end of the main menu you will find two options. One is\n"
122"for saving the current configuration to a file of your choosing.\n" 121"for saving the current configuration to a file of your choosing.\n"
@@ -149,7 +148,7 @@ static const char mconf_readme[] =
149"\n" 148"\n"
150"Optional personality available\n" 149"Optional personality available\n"
151"------------------------------\n" 150"------------------------------\n"
152"If you prefer to have all of the options listed in a single\n" 151"If you prefer to have all of the kernel options listed in a single\n"
153"menu, rather than the default multimenu hierarchy, run the menuconfig\n" 152"menu, rather than the default multimenu hierarchy, run the menuconfig\n"
154"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" 153"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
155"\n" 154"\n"
@@ -160,55 +159,55 @@ static const char mconf_readme[] =
160"\n" 159"\n"
161"Note that this mode can eventually be a little more CPU expensive\n" 160"Note that this mode can eventually be a little more CPU expensive\n"
162"(especially with a larger number of unrolled categories) than the\n" 161"(especially with a larger number of unrolled categories) than the\n"
163"default mode.\n", 162"default mode.\n"),
164menu_instructions[] = 163menu_instructions[] = N_(
165 "Arrow keys navigate the menu. " 164 "Arrow keys navigate the menu. "
166 "<Enter> selects submenus --->. " 165 "<Enter> selects submenus --->. "
167 "Highlighted letters are hotkeys. " 166 "Highlighted letters are hotkeys. "
168 "Pressing <Y> selectes a feature, while <N> will exclude a feature. " 167 "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
169 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " 168 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
170 "Legend: [*] feature is selected [ ] feature is excluded", 169 "Legend: [*] built-in [ ] excluded <M> module < > module capable"),
171radiolist_instructions[] = 170radiolist_instructions[] = N_(
172 "Use the arrow keys to navigate this window or " 171 "Use the arrow keys to navigate this window or "
173 "press the hotkey of the item you wish to select " 172 "press the hotkey of the item you wish to select "
174 "followed by the <SPACE BAR>. " 173 "followed by the <SPACE BAR>. "
175 "Press <?> for additional information about this option.", 174 "Press <?> for additional information about this option."),
176inputbox_instructions_int[] = 175inputbox_instructions_int[] = N_(
177 "Please enter a decimal value. " 176 "Please enter a decimal value. "
178 "Fractions will not be accepted. " 177 "Fractions will not be accepted. "
179 "Use the <TAB> key to move from the input field to the buttons below it.", 178 "Use the <TAB> key to move from the input field to the buttons below it."),
180inputbox_instructions_hex[] = 179inputbox_instructions_hex[] = N_(
181 "Please enter a hexadecimal value. " 180 "Please enter a hexadecimal value. "
182 "Use the <TAB> key to move from the input field to the buttons below it.", 181 "Use the <TAB> key to move from the input field to the buttons below it."),
183inputbox_instructions_string[] = 182inputbox_instructions_string[] = N_(
184 "Please enter a string value. " 183 "Please enter a string value. "
185 "Use the <TAB> key to move from the input field to the buttons below it.", 184 "Use the <TAB> key to move from the input field to the buttons below it."),
186setmod_text[] = 185setmod_text[] = N_(
187 "This feature depends on another which has been configured as a module.\n" 186 "This feature depends on another which has been configured as a module.\n"
188 "As a result, this feature will be built as a module.", 187 "As a result, this feature will be built as a module."),
189nohelp_text[] = 188nohelp_text[] = N_(
190 "There is no help available for this option.\n", 189 "There is no help available for this kernel option.\n"),
191load_config_text[] = 190load_config_text[] = N_(
192 "Enter the name of the configuration file you wish to load. " 191 "Enter the name of the configuration file you wish to load. "
193 "Accept the name shown to restore the configuration you " 192 "Accept the name shown to restore the configuration you "
194 "last retrieved. Leave blank to abort.", 193 "last retrieved. Leave blank to abort."),
195load_config_help[] = 194load_config_help[] = N_(
196 "\n" 195 "\n"
197 "For various reasons, one may wish to keep several different BusyBox\n" 196 "For various reasons, one may wish to keep several different kernel\n"
198 "configurations available on a single machine.\n" 197 "configurations available on a single machine.\n"
199 "\n" 198 "\n"
200 "If you have saved a previous configuration in a file other than the\n" 199 "If you have saved a previous configuration in a file other than the\n"
201 "BusyBox's default, entering the name of the file here will allow you\n" 200 "kernel's default, entering the name of the file here will allow you\n"
202 "to modify that configuration.\n" 201 "to modify that configuration.\n"
203 "\n" 202 "\n"
204 "If you are uncertain, then you have probably never used alternate\n" 203 "If you are uncertain, then you have probably never used alternate\n"
205 "configuration files. You should therefor leave this blank to abort.\n", 204 "configuration files. You should therefor leave this blank to abort.\n"),
206save_config_text[] = 205save_config_text[] = N_(
207 "Enter a filename to which this configuration should be saved " 206 "Enter a filename to which this configuration should be saved "
208 "as an alternate. Leave blank to abort.", 207 "as an alternate. Leave blank to abort."),
209save_config_help[] = 208save_config_help[] = N_(
210 "\n" 209 "\n"
211 "For various reasons, one may wish to keep different BusyBox\n" 210 "For various reasons, one may wish to keep different kernel\n"
212 "configurations available on a single machine.\n" 211 "configurations available on a single machine.\n"
213 "\n" 212 "\n"
214 "Entering a file name here will allow you to later retrieve, modify\n" 213 "Entering a file name here will allow you to later retrieve, modify\n"
@@ -216,10 +215,11 @@ save_config_help[] =
216 "configuration options you have selected at that time.\n" 215 "configuration options you have selected at that time.\n"
217 "\n" 216 "\n"
218 "If you are uncertain what all this means then you should probably\n" 217 "If you are uncertain what all this means then you should probably\n"
219 "leave this blank.\n", 218 "leave this blank.\n"),
220search_help[] = 219search_help[] = N_(
221 "\n" 220 "\n"
222 "Search for CONFIG_ symbols and display their relations.\n" 221 "Search for CONFIG_ symbols and display their relations.\n"
222 "Regular expressions are allowed.\n"
223 "Example: search for \"^FOO\"\n" 223 "Example: search for \"^FOO\"\n"
224 "Result:\n" 224 "Result:\n"
225 "-----------------------------------------------------------------\n" 225 "-----------------------------------------------------------------\n"
@@ -254,19 +254,20 @@ search_help[] =
254 "Examples: USB => find all CONFIG_ symbols containing USB\n" 254 "Examples: USB => find all CONFIG_ symbols containing USB\n"
255 " ^USB => find all CONFIG_ symbols starting with USB\n" 255 " ^USB => find all CONFIG_ symbols starting with USB\n"
256 " USB$ => find all CONFIG_ symbols ending with USB\n" 256 " USB$ => find all CONFIG_ symbols ending with USB\n"
257 "\n"; 257 "\n");
258 258
259static char buf[4096], *bufptr = buf;
260static char input_buf[4096];
259static char filename[PATH_MAX+1] = ".config"; 261static char filename[PATH_MAX+1] = ".config";
262static char *args[1024], **argptr = args;
260static int indent; 263static int indent;
261static struct termios ios_org; 264static struct termios ios_org;
262static int rows = 0, cols = 0; 265static int rows = 0, cols = 0;
263static struct menu *current_menu; 266static struct menu *current_menu;
264static int child_count; 267static int child_count;
268static int do_resize;
265static int single_menu_mode; 269static int single_menu_mode;
266 270
267static struct dialog_list_item *items[16384]; /* FIXME: This ought to be dynamic. */
268static int item_no;
269
270static void conf(struct menu *menu); 271static void conf(struct menu *menu);
271static void conf_choice(struct menu *menu); 272static void conf_choice(struct menu *menu);
272static void conf_string(struct menu *menu); 273static void conf_string(struct menu *menu);
@@ -277,6 +278,11 @@ static void show_helptext(const char *title, const char *text);
277static void show_help(struct menu *menu); 278static void show_help(struct menu *menu);
278static void show_file(const char *filename, const char *title, int r, int c); 279static void show_file(const char *filename, const char *title, int r, int c);
279 280
281static void cprint_init(void);
282static int cprint1(const char *fmt, ...);
283static void cprint_done(void);
284static int cprint(const char *fmt, ...);
285
280static void init_wsize(void) 286static void init_wsize(void)
281{ 287{
282 struct winsize ws; 288 struct winsize ws;
@@ -303,8 +309,8 @@ static void init_wsize(void)
303 } 309 }
304 310
305 if (rows < 19 || cols < 80) { 311 if (rows < 19 || cols < 80) {
306 fprintf(stderr, "Your display is too small to run Menuconfig!\n"); 312 fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
307 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); 313 fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
308 exit(1); 314 exit(1);
309 } 315 }
310 316
@@ -312,65 +318,54 @@ static void init_wsize(void)
312 cols -= 5; 318 cols -= 5;
313} 319}
314 320
315static void cinit(void) 321static void cprint_init(void)
316{
317 item_no = 0;
318}
319
320static void cmake(void)
321{ 322{
322 items[item_no] = malloc(sizeof(struct dialog_list_item)); 323 bufptr = buf;
323 memset(items[item_no], 0, sizeof(struct dialog_list_item)); 324 argptr = args;
324 items[item_no]->tag = malloc(32); items[item_no]->tag[0] = 0; 325 memset(args, 0, sizeof(args));
325 items[item_no]->name = malloc(512); items[item_no]->name[0] = 0; 326 indent = 0;
326 items[item_no]->namelen = 0; 327 child_count = 0;
327 item_no++; 328 cprint("./scripts/kconfig/lxdialog/lxdialog");
329 cprint("--backtitle");
330 cprint(menu_backtitle);
328} 331}
329 332
330static int cprint_name(const char *fmt, ...) 333static int cprint1(const char *fmt, ...)
331{ 334{
332 va_list ap; 335 va_list ap;
333 int res; 336 int res;
334 337
335 if (!item_no) 338 if (!*argptr)
336 cmake(); 339 *argptr = bufptr;
337 va_start(ap, fmt); 340 va_start(ap, fmt);
338 res = vsnprintf(items[item_no - 1]->name + items[item_no - 1]->namelen, 341 res = vsprintf(bufptr, fmt, ap);
339 512 - items[item_no - 1]->namelen, fmt, ap);
340 if (res > 0)
341 items[item_no - 1]->namelen += res;
342 va_end(ap); 342 va_end(ap);
343 bufptr += res;
343 344
344 return res; 345 return res;
345} 346}
346 347
347static int cprint_tag(const char *fmt, ...) 348static void cprint_done(void)
349{
350 *bufptr++ = 0;
351 argptr++;
352}
353
354static int cprint(const char *fmt, ...)
348{ 355{
349 va_list ap; 356 va_list ap;
350 int res; 357 int res;
351 358
352 if (!item_no) 359 *argptr++ = bufptr;
353 cmake();
354 va_start(ap, fmt); 360 va_start(ap, fmt);
355 res = vsnprintf(items[item_no - 1]->tag, 32, fmt, ap); 361 res = vsprintf(bufptr, fmt, ap);
356 va_end(ap); 362 va_end(ap);
363 bufptr += res;
364 *bufptr++ = 0;
357 365
358 return res; 366 return res;
359} 367}
360 368
361static void cdone(void)
362{
363 int i;
364
365 for (i = 0; i < item_no; i++) {
366 free(items[i]->tag);
367 free(items[i]->name);
368 free(items[i]);
369 }
370
371 item_no = 0;
372}
373
374static void get_prompt_str(struct gstr *r, struct property *prop) 369static void get_prompt_str(struct gstr *r, struct property *prop)
375{ 370{
376 int i, j; 371 int i, j;
@@ -408,7 +403,7 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym)
408 struct property *prop; 403 struct property *prop;
409 404
410 str_printf(r, "Symbol: %s [=%s]\n", sym->name, 405 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
411 sym_get_string_value(sym)); 406 sym_get_string_value(sym));
412 for_all_prompts(sym, prop) 407 for_all_prompts(sym, prop)
413 get_prompt_str(r, prop); 408 get_prompt_str(r, prop);
414 hit = false; 409 hit = false;
@@ -443,28 +438,121 @@ static struct gstr get_relations_str(struct symbol **sym_arr)
443 return res; 438 return res;
444} 439}
445 440
441pid_t pid;
442
443static void winch_handler(int sig)
444{
445 if (!do_resize) {
446 kill(pid, SIGINT);
447 do_resize = 1;
448 }
449}
450
451static int exec_conf(void)
452{
453 int pipefd[2], stat, size;
454 struct sigaction sa;
455 sigset_t sset, osset;
456
457 sigemptyset(&sset);
458 sigaddset(&sset, SIGINT);
459 sigprocmask(SIG_BLOCK, &sset, &osset);
460
461 signal(SIGINT, SIG_DFL);
462
463 sa.sa_handler = winch_handler;
464 sigemptyset(&sa.sa_mask);
465 sa.sa_flags = SA_RESTART;
466 sigaction(SIGWINCH, &sa, NULL);
467
468 *argptr++ = NULL;
469
470 pipe(pipefd);
471 pid = fork();
472 if (pid == 0) {
473 sigprocmask(SIG_SETMASK, &osset, NULL);
474 dup2(pipefd[1], 2);
475 close(pipefd[0]);
476 close(pipefd[1]);
477 execv(args[0], args);
478 _exit(EXIT_FAILURE);
479 }
480
481 close(pipefd[1]);
482 bufptr = input_buf;
483 while (1) {
484 size = input_buf + sizeof(input_buf) - bufptr;
485 size = read(pipefd[0], bufptr, size);
486 if (size <= 0) {
487 if (size < 0) {
488 if (errno == EINTR || errno == EAGAIN)
489 continue;
490 perror("read");
491 }
492 break;
493 }
494 bufptr += size;
495 }
496 *bufptr++ = 0;
497 close(pipefd[0]);
498 waitpid(pid, &stat, 0);
499
500 if (do_resize) {
501 init_wsize();
502 do_resize = 0;
503 sigprocmask(SIG_SETMASK, &osset, NULL);
504 return -1;
505 }
506 if (WIFSIGNALED(stat)) {
507 printf("\finterrupted(%d)\n", WTERMSIG(stat));
508 exit(1);
509 }
510#if 0
511 printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf);
512 sleep(1);
513#endif
514 sigpending(&sset);
515 if (sigismember(&sset, SIGINT)) {
516 printf("\finterrupted\n");
517 exit(1);
518 }
519 sigprocmask(SIG_SETMASK, &osset, NULL);
520
521 return WEXITSTATUS(stat);
522}
523
446static void search_conf(void) 524static void search_conf(void)
447{ 525{
448 struct symbol **sym_arr; 526 struct symbol **sym_arr;
527 int stat;
449 struct gstr res; 528 struct gstr res;
450 529
451again: 530again:
452 switch (dialog_inputbox("Search Configuration Parameter", 531 cprint_init();
453 "Enter Keyword", 10, 75, 532 cprint("--title");
454 NULL)) { 533 cprint(_("Search Configuration Parameter"));
534 cprint("--inputbox");
535 cprint(_("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"));
536 cprint("10");
537 cprint("75");
538 cprint("");
539 stat = exec_conf();
540 if (stat < 0)
541 goto again;
542 switch (stat) {
455 case 0: 543 case 0:
456 break; 544 break;
457 case 1: 545 case 1:
458 show_helptext("Search Configuration", search_help); 546 show_helptext(_("Search Configuration"), search_help);
459 goto again; 547 goto again;
460 default: 548 default:
461 return; 549 return;
462 } 550 }
463 551
464 sym_arr = sym_re_search(dialog_input_result); 552 sym_arr = sym_re_search(input_buf);
465 res = get_relations_str(sym_arr); 553 res = get_relations_str(sym_arr);
466 free(sym_arr); 554 free(sym_arr);
467 show_textbox("Search Results", str_get(&res), 0, 0); 555 show_textbox(_("Search Results"), str_get(&res), 0, 0);
468 str_free(&res); 556 str_free(&res);
469} 557}
470 558
@@ -488,26 +576,24 @@ static void build_conf(struct menu *menu)
488 switch (prop->type) { 576 switch (prop->type) {
489 case P_MENU: 577 case P_MENU:
490 child_count++; 578 child_count++;
491 cmake(); 579 cprint("m%p", menu);
492 cprint_tag("m%p", menu);
493 580
494 if (single_menu_mode) { 581 if (single_menu_mode) {
495 cprint_name("%s%*c%s", 582 cprint1("%s%*c%s",
496 menu->data ? "-->" : "++>", 583 menu->data ? "-->" : "++>",
497 indent + 1, ' ', prompt); 584 indent + 1, ' ', prompt);
498 } else { 585 } else
499 cprint_name(" %*c%s --->", indent + 1, ' ', prompt); 586 cprint1(" %*c%s --->", indent + 1, ' ', prompt);
500 }
501 587
588 cprint_done();
502 if (single_menu_mode && menu->data) 589 if (single_menu_mode && menu->data)
503 goto conf_childs; 590 goto conf_childs;
504 return; 591 return;
505 default: 592 default:
506 if (prompt) { 593 if (prompt) {
507 child_count++; 594 child_count++;
508 cmake(); 595 cprint(":%p", menu);
509 cprint_tag(":%p", menu); 596 cprint("---%*c%s", indent + 1, ' ', prompt);
510 cprint_name("---%*c%s", indent + 1, ' ', prompt);
511 } 597 }
512 } 598 }
513 } else 599 } else
@@ -515,7 +601,6 @@ static void build_conf(struct menu *menu)
515 goto conf_childs; 601 goto conf_childs;
516 } 602 }
517 603
518 cmake();
519 type = sym_get_type(sym); 604 type = sym_get_type(sym);
520 if (sym_is_choice(sym)) { 605 if (sym_is_choice(sym)) {
521 struct symbol *def_sym = sym_get_choice_value(sym); 606 struct symbol *def_sym = sym_get_choice_value(sym);
@@ -529,10 +614,10 @@ static void build_conf(struct menu *menu)
529 614
530 val = sym_get_tristate_value(sym); 615 val = sym_get_tristate_value(sym);
531 if (sym_is_changable(sym)) { 616 if (sym_is_changable(sym)) {
532 cprint_tag("t%p", menu); 617 cprint("t%p", menu);
533 switch (type) { 618 switch (type) {
534 case S_BOOLEAN: 619 case S_BOOLEAN:
535 cprint_name("[%c]", val == no ? ' ' : '*'); 620 cprint1("[%c]", val == no ? ' ' : '*');
536 break; 621 break;
537 case S_TRISTATE: 622 case S_TRISTATE:
538 switch (val) { 623 switch (val) {
@@ -540,78 +625,84 @@ static void build_conf(struct menu *menu)
540 case mod: ch = 'M'; break; 625 case mod: ch = 'M'; break;
541 default: ch = ' '; break; 626 default: ch = ' '; break;
542 } 627 }
543 cprint_name("<%c>", ch); 628 cprint1("<%c>", ch);
544 break; 629 break;
545 } 630 }
546 } else { 631 } else {
547 cprint_tag("%c%p", def_menu ? 't' : ':', menu); 632 cprint("%c%p", def_menu ? 't' : ':', menu);
548 cprint_name(" "); 633 cprint1(" ");
549 } 634 }
550 635
551 cprint_name("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 636 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
552 if (val == yes) { 637 if (val == yes) {
553 if (def_menu) { 638 if (def_menu) {
554 cprint_name(" (%s)", menu_get_prompt(def_menu)); 639 cprint1(" (%s)", menu_get_prompt(def_menu));
555 cprint_name(" --->"); 640 cprint1(" --->");
641 cprint_done();
556 if (def_menu->list) { 642 if (def_menu->list) {
557 indent += 2; 643 indent += 2;
558 build_conf(def_menu); 644 build_conf(def_menu);
559 indent -= 2; 645 indent -= 2;
560 } 646 }
561 } 647 } else
648 cprint_done();
562 return; 649 return;
563 } 650 }
651 cprint_done();
564 } else { 652 } else {
565 if (menu == current_menu) { 653 if (menu == current_menu) {
566 cprint_tag(":%p", menu); 654 cprint(":%p", menu);
567 cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 655 cprint("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
568 goto conf_childs; 656 goto conf_childs;
569 } 657 }
570 child_count++; 658 child_count++;
571 val = sym_get_tristate_value(sym); 659 val = sym_get_tristate_value(sym);
572 if (sym_is_choice_value(sym) && val == yes) { 660 if (sym_is_choice_value(sym) && val == yes) {
573 cprint_tag(":%p", menu); 661 cprint(":%p", menu);
574 cprint_name(" "); 662 cprint1(" ");
575 } else { 663 } else {
576 switch (type) { 664 switch (type) {
577 case S_BOOLEAN: 665 case S_BOOLEAN:
578 cprint_tag("t%p", menu); 666 cprint("t%p", menu);
579 if (sym_is_changable(sym)) 667 if (sym_is_changable(sym))
580 cprint_name("[%c]", val == no ? ' ' : '*'); 668 cprint1("[%c]", val == no ? ' ' : '*');
581 else 669 else
582 cprint_name("---"); 670 cprint1("---");
583 break; 671 break;
584 case S_TRISTATE: 672 case S_TRISTATE:
585 cprint_tag("t%p", menu); 673 cprint("t%p", menu);
586 switch (val) { 674 switch (val) {
587 case yes: ch = '*'; break; 675 case yes: ch = '*'; break;
588 case mod: ch = 'M'; break; 676 case mod: ch = 'M'; break;
589 default: ch = ' '; break; 677 default: ch = ' '; break;
590 } 678 }
591 if (sym_is_changable(sym)) 679 if (sym_is_changable(sym))
592 cprint_name("<%c>", ch); 680 cprint1("<%c>", ch);
593 else 681 else
594 cprint_name("---"); 682 cprint1("---");
595 break; 683 break;
596 default: 684 default:
597 cprint_tag("s%p", menu); 685 cprint("s%p", menu);
598 tmp = cprint_name("(%s)", sym_get_string_value(sym)); 686 tmp = cprint1("(%s)", sym_get_string_value(sym));
599 tmp = indent - tmp + 4; 687 tmp = indent - tmp + 4;
600 if (tmp < 0) 688 if (tmp < 0)
601 tmp = 0; 689 tmp = 0;
602 cprint_name("%*c%s%s", tmp, ' ', menu_get_prompt(menu), 690 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
603 (sym_has_value(sym) || !sym_is_changable(sym)) ? 691 (sym_has_value(sym) || !sym_is_changable(sym)) ?
604 "" : " (NEW)"); 692 "" : " (NEW)");
693 cprint_done();
605 goto conf_childs; 694 goto conf_childs;
606 } 695 }
607 } 696 }
608 cprint_name("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), 697 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
609 (sym_has_value(sym) || !sym_is_changable(sym)) ? 698 (sym_has_value(sym) || !sym_is_changable(sym)) ?
610 "" : " (NEW)"); 699 "" : " (NEW)");
611 if (menu->prompt->type == P_MENU) { 700 if (menu->prompt->type == P_MENU) {
612 cprint_name(" --->"); 701 cprint1(" --->");
702 cprint_done();
613 return; 703 return;
614 } 704 }
705 cprint_done();
615 } 706 }
616 707
617conf_childs: 708conf_childs:
@@ -623,51 +714,57 @@ conf_childs:
623 714
624static void conf(struct menu *menu) 715static void conf(struct menu *menu)
625{ 716{
626 struct dialog_list_item *active_item = NULL;
627 struct menu *submenu; 717 struct menu *submenu;
628 const char *prompt = menu_get_prompt(menu); 718 const char *prompt = menu_get_prompt(menu);
629 struct symbol *sym; 719 struct symbol *sym;
630 char active_entry[40]; 720 char active_entry[40];
631 int stat, type; 721 int stat, type, i;
632 722
633 unlink("lxdialog.scrltmp"); 723 unlink("lxdialog.scrltmp");
634 active_entry[0] = 0; 724 active_entry[0] = 0;
635 while (1) { 725 while (1) {
636 indent = 0; 726 cprint_init();
637 child_count = 0; 727 cprint("--title");
728 cprint("%s", prompt ? prompt : _("Main Menu"));
729 cprint("--menu");
730 cprint(_(menu_instructions));
731 cprint("%d", rows);
732 cprint("%d", cols);
733 cprint("%d", rows - 10);
734 cprint("%s", active_entry);
638 current_menu = menu; 735 current_menu = menu;
639 cdone(); cinit();
640 build_conf(menu); 736 build_conf(menu);
641 if (!child_count) 737 if (!child_count)
642 break; 738 break;
643 if (menu == &rootmenu) { 739 if (menu == &rootmenu) {
644 cmake(); cprint_tag(":"); cprint_name("--- "); 740 cprint(":");
645 cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File"); 741 cprint("--- ");
646 cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File"); 742 cprint("L");
743 cprint(_(" Load an Alternate Configuration File"));
744 cprint("S");
745 cprint(_(" Save Configuration to an Alternate File"));
647 } 746 }
648 dialog_clear(); 747 stat = exec_conf();
649 stat = dialog_menu(prompt ? prompt : "Main Menu",
650 menu_instructions, rows, cols, rows - 10,
651 active_entry, item_no, items);
652 if (stat < 0) 748 if (stat < 0)
653 return; 749 continue;
654 750
655 if (stat == 1 || stat == 255) 751 if (stat == 1 || stat == 255)
656 break; 752 break;
657 753
658 active_item = first_sel_item(item_no, items); 754 type = input_buf[0];
659 if (!active_item)
660 continue;
661 active_item->selected = 0;
662 strncpy(active_entry, active_item->tag, sizeof(active_entry));
663 active_entry[sizeof(active_entry)-1] = 0;
664 type = active_entry[0];
665 if (!type) 755 if (!type)
666 continue; 756 continue;
667 757
758 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++)
759 ;
760 if (i >= sizeof(active_entry))
761 i = sizeof(active_entry) - 1;
762 input_buf[i] = 0;
763 strcpy(active_entry, input_buf);
764
668 sym = NULL; 765 sym = NULL;
669 submenu = NULL; 766 submenu = NULL;
670 if (sscanf(active_entry + 1, "%p", &submenu) == 1) 767 if (sscanf(input_buf + 1, "%p", &submenu) == 1)
671 sym = submenu->sym; 768 sym = submenu->sym;
672 769
673 switch (stat) { 770 switch (stat) {
@@ -700,7 +797,7 @@ static void conf(struct menu *menu)
700 if (sym) 797 if (sym)
701 show_help(submenu); 798 show_help(submenu);
702 else 799 else
703 show_helptext("README", mconf_readme); 800 show_helptext("README", _(mconf_readme));
704 break; 801 break;
705 case 3: 802 case 3:
706 if (type == 't') { 803 if (type == 't') {
@@ -755,8 +852,8 @@ static void show_help(struct menu *menu)
755 if (sym->help) 852 if (sym->help)
756 { 853 {
757 if (sym->name) { 854 if (sym->name) {
758 str_printf(&help, "%s:\n\n", sym->name); 855 str_printf(&help, "CONFIG_%s:\n\n", sym->name);
759 str_append(&help, sym->help); 856 str_append(&help, _(sym->help));
760 str_append(&help, "\n"); 857 str_append(&help, "\n");
761 } 858 }
762 } else { 859 } else {
@@ -769,8 +866,17 @@ static void show_help(struct menu *menu)
769 866
770static void show_file(const char *filename, const char *title, int r, int c) 867static void show_file(const char *filename, const char *title, int r, int c)
771{ 868{
772 while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0) 869 do {
773 ; 870 cprint_init();
871 if (title) {
872 cprint("--title");
873 cprint("%s", title);
874 }
875 cprint("--textbox");
876 cprint("%s", filename);
877 cprint("%d", r ? r : rows);
878 cprint("%d", c ? c : cols);
879 } while (exec_conf() < 0);
774} 880}
775 881
776static void conf_choice(struct menu *menu) 882static void conf_choice(struct menu *menu)
@@ -778,35 +884,42 @@ static void conf_choice(struct menu *menu)
778 const char *prompt = menu_get_prompt(menu); 884 const char *prompt = menu_get_prompt(menu);
779 struct menu *child; 885 struct menu *child;
780 struct symbol *active; 886 struct symbol *active;
887 int stat;
781 888
782 active = sym_get_choice_value(menu->sym); 889 active = sym_get_choice_value(menu->sym);
783 while (1) { 890 while (1) {
891 cprint_init();
892 cprint("--title");
893 cprint("%s", prompt ? prompt : _("Main Menu"));
894 cprint("--radiolist");
895 cprint(_(radiolist_instructions));
896 cprint("15");
897 cprint("70");
898 cprint("6");
899
784 current_menu = menu; 900 current_menu = menu;
785 cdone(); cinit();
786 for (child = menu->list; child; child = child->next) { 901 for (child = menu->list; child; child = child->next) {
787 if (!menu_is_visible(child)) 902 if (!menu_is_visible(child))
788 continue; 903 continue;
789 cmake(); 904 cprint("%p", child);
790 cprint_tag("%p", child); 905 cprint("%s", menu_get_prompt(child));
791 cprint_name("%s", menu_get_prompt(child));
792 if (child->sym == sym_get_choice_value(menu->sym)) 906 if (child->sym == sym_get_choice_value(menu->sym))
793 items[item_no - 1]->selected = 1; /* ON */ 907 cprint("ON");
794 else if (child->sym == active) 908 else if (child->sym == active)
795 items[item_no - 1]->selected = 2; /* SELECTED */ 909 cprint("SELECTED");
796 else 910 else
797 items[item_no - 1]->selected = 0; /* OFF */ 911 cprint("OFF");
798 } 912 }
799 913
800 switch (dialog_checklist(prompt ? prompt : "Main Menu", 914 stat = exec_conf();
801 radiolist_instructions, 15, 70, 6, 915 switch (stat) {
802 item_no, items, FLAG_RADIO)) {
803 case 0: 916 case 0:
804 if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) != 1) 917 if (sscanf(input_buf, "%p", &child) != 1)
805 break; 918 break;
806 sym_set_tristate_value(child->sym, yes); 919 sym_set_tristate_value(child->sym, yes);
807 return; 920 return;
808 case 1: 921 case 1:
809 if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) == 1) { 922 if (sscanf(input_buf, "%p", &child) == 1) {
810 show_help(child); 923 show_help(child);
811 active = child->sym; 924 active = child->sym;
812 } else 925 } else
@@ -821,32 +934,35 @@ static void conf_choice(struct menu *menu)
821static void conf_string(struct menu *menu) 934static void conf_string(struct menu *menu)
822{ 935{
823 const char *prompt = menu_get_prompt(menu); 936 const char *prompt = menu_get_prompt(menu);
937 int stat;
824 938
825 while (1) { 939 while (1) {
826 char *heading; 940 cprint_init();
827 941 cprint("--title");
942 cprint("%s", prompt ? prompt : _("Main Menu"));
943 cprint("--inputbox");
828 switch (sym_get_type(menu->sym)) { 944 switch (sym_get_type(menu->sym)) {
829 case S_INT: 945 case S_INT:
830 heading = (char *) inputbox_instructions_int; 946 cprint(_(inputbox_instructions_int));
831 break; 947 break;
832 case S_HEX: 948 case S_HEX:
833 heading = (char *) inputbox_instructions_hex; 949 cprint(_(inputbox_instructions_hex));
834 break; 950 break;
835 case S_STRING: 951 case S_STRING:
836 heading = (char *) inputbox_instructions_string; 952 cprint(_(inputbox_instructions_string));
837 break; 953 break;
838 default: 954 default:
839 heading = "Internal mconf error!";
840 /* panic? */; 955 /* panic? */;
841 } 956 }
842 957 cprint("10");
843 switch (dialog_inputbox(prompt ? prompt : "Main Menu", 958 cprint("75");
844 heading, 10, 75, 959 cprint("%s", sym_get_string_value(menu->sym));
845 sym_get_string_value(menu->sym))) { 960 stat = exec_conf();
961 switch (stat) {
846 case 0: 962 case 0:
847 if (sym_set_string_value(menu->sym, dialog_input_result)) 963 if (sym_set_string_value(menu->sym, input_buf))
848 return; 964 return;
849 show_textbox(NULL, "You have made an invalid entry.", 5, 43); 965 show_textbox(NULL, _("You have made an invalid entry."), 5, 43);
850 break; 966 break;
851 case 1: 967 case 1:
852 show_help(menu); 968 show_help(menu);
@@ -859,18 +975,26 @@ static void conf_string(struct menu *menu)
859 975
860static void conf_load(void) 976static void conf_load(void)
861{ 977{
978 int stat;
979
862 while (1) { 980 while (1) {
863 switch (dialog_inputbox(NULL, load_config_text, 11, 55, 981 cprint_init();
864 filename)) { 982 cprint("--inputbox");
983 cprint(load_config_text);
984 cprint("11");
985 cprint("55");
986 cprint("%s", filename);
987 stat = exec_conf();
988 switch(stat) {
865 case 0: 989 case 0:
866 if (!dialog_input_result[0]) 990 if (!input_buf[0])
867 return; 991 return;
868 if (!conf_read(dialog_input_result)) 992 if (!conf_read(input_buf))
869 return; 993 return;
870 show_textbox(NULL, "File does not exist!", 5, 38); 994 show_textbox(NULL, _("File does not exist!"), 5, 38);
871 break; 995 break;
872 case 1: 996 case 1:
873 show_helptext("Load Alternate Configuration", load_config_help); 997 show_helptext(_("Load Alternate Configuration"), load_config_help);
874 break; 998 break;
875 case 255: 999 case 255:
876 return; 1000 return;
@@ -880,18 +1004,26 @@ static void conf_load(void)
880 1004
881static void conf_save(void) 1005static void conf_save(void)
882{ 1006{
1007 int stat;
1008
883 while (1) { 1009 while (1) {
884 switch (dialog_inputbox(NULL, save_config_text, 11, 55, 1010 cprint_init();
885 filename)) { 1011 cprint("--inputbox");
1012 cprint(save_config_text);
1013 cprint("11");
1014 cprint("55");
1015 cprint("%s", filename);
1016 stat = exec_conf();
1017 switch(stat) {
886 case 0: 1018 case 0:
887 if (!dialog_input_result[0]) 1019 if (!input_buf[0])
888 return; 1020 return;
889 if (!conf_write(dialog_input_result)) 1021 if (!conf_write(input_buf))
890 return; 1022 return;
891 show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); 1023 show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60);
892 break; 1024 break;
893 case 1: 1025 case 1:
894 show_helptext("Save Alternate Configuration", save_config_help); 1026 show_helptext(_("Save Alternate Configuration"), save_config_help);
895 break; 1027 break;
896 case 255: 1028 case 255:
897 return; 1029 return;
@@ -903,30 +1035,7 @@ static void conf_cleanup(void)
903{ 1035{
904 tcsetattr(1, TCSAFLUSH, &ios_org); 1036 tcsetattr(1, TCSAFLUSH, &ios_org);
905 unlink(".help.tmp"); 1037 unlink(".help.tmp");
906} 1038 unlink("lxdialog.scrltmp");
907
908static void winch_handler(int sig)
909{
910 struct winsize ws;
911
912 if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
913 rows = 24;
914 cols = 80;
915 } else {
916 rows = ws.ws_row;
917 cols = ws.ws_col;
918 }
919
920 if (rows < 19 || cols < 80) {
921 end_dialog();
922 fprintf(stderr, "Your display is too small to run Menuconfig!\n");
923 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n");
924 exit(1);
925 }
926
927 rows -= 4;
928 cols -= 5;
929
930} 1039}
931 1040
932int main(int ac, char **av) 1041int main(int ac, char **av)
@@ -935,12 +1044,16 @@ int main(int ac, char **av)
935 char *mode; 1044 char *mode;
936 int stat; 1045 int stat;
937 1046
1047 setlocale(LC_ALL, "");
1048 bindtextdomain(PACKAGE, LOCALEDIR);
1049 textdomain(PACKAGE);
1050
938 conf_parse(av[1]); 1051 conf_parse(av[1]);
939 conf_read(NULL); 1052 conf_read(NULL);
940 1053
941 sym = sym_lookup("VERSION", 0); 1054 sym = sym_lookup("KERNELVERSION", 0);
942 sym_calc_value(sym); 1055 sym_calc_value(sym);
943 snprintf(menu_backtitle, 128, "BusyBox v%s Configuration", 1056 sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"),
944 sym_get_string_value(sym)); 1057 sym_get_string_value(sym));
945 1058
946 mode = getenv("MENUCONFIG_MODE"); 1059 mode = getenv("MENUCONFIG_MODE");
@@ -952,25 +1065,34 @@ int main(int ac, char **av)
952 tcgetattr(1, &ios_org); 1065 tcgetattr(1, &ios_org);
953 atexit(conf_cleanup); 1066 atexit(conf_cleanup);
954 init_wsize(); 1067 init_wsize();
955 init_dialog();
956 signal(SIGWINCH, winch_handler);
957 conf(&rootmenu); 1068 conf(&rootmenu);
958 end_dialog();
959 1069
960 /* Restart dialog to act more like when lxdialog was still separate */
961 init_dialog();
962 do { 1070 do {
963 stat = dialog_yesno(NULL, 1071 cprint_init();
964 "Do you wish to save your new BusyBox configuration?", 5, 60); 1072 cprint("--yesno");
1073 cprint(_("Do you wish to save your new kernel configuration?"));
1074 cprint("5");
1075 cprint("60");
1076 stat = exec_conf();
965 } while (stat < 0); 1077 } while (stat < 0);
966 end_dialog();
967 1078
968 if (stat == 0) { 1079 if (stat == 0) {
969 conf_write(NULL); 1080 if (conf_write(NULL)) {
970 printf("\n" 1081 fprintf(stderr, _("\n\n"
971 "*** End of BusyBox configuration.\n"); 1082 "Error during writing of the kernel configuration.\n"
972 } else 1083 "Your kernel configuration changes were NOT saved."
973 printf("\n\nYour BusyBox configuration changes were NOT saved.\n\n"); 1084 "\n\n"));
1085 return 1;
1086 }
1087 printf(_("\n\n"
1088 "*** End of Linux kernel configuration.\n"
1089 "*** Execute 'make' to build the kernel or try 'make help'."
1090 "\n\n"));
1091 } else {
1092 fprintf(stderr, _("\n\n"
1093 "Your kernel configuration changes were NOT saved."
1094 "\n\n"));
1095 }
974 1096
975 return 0; 1097 return 0;
976} 1098}
diff --git a/scripts/config/menu.c b/scripts/kconfig/menu.c
index 7e97e8330..0fce20cb7 100644
--- a/scripts/config/menu.c
+++ b/scripts/kconfig/menu.c
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
@@ -62,10 +61,11 @@ void menu_end_entry(void)
62{ 61{
63} 62}
64 63
65void menu_add_menu(void) 64struct menu *menu_add_menu(void)
66{ 65{
67 current_menu = current_entry; 66 menu_end_entry();
68 last_entry_ptr = &current_entry->list; 67 last_entry_ptr = &current_entry->list;
68 return current_menu = current_entry;
69} 69}
70 70
71void menu_end_menu(void) 71void menu_end_menu(void)
@@ -137,9 +137,9 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e
137 return prop; 137 return prop;
138} 138}
139 139
140void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) 140struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
141{ 141{
142 menu_add_prop(type, prompt, NULL, dep); 142 return menu_add_prop(type, prompt, NULL, dep);
143} 143}
144 144
145void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) 145void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
@@ -152,6 +152,12 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
152 menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); 152 menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
153} 153}
154 154
155static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
156{
157 return sym2->type == S_INT || sym2->type == S_HEX ||
158 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
159}
160
155void sym_check_prop(struct symbol *sym) 161void sym_check_prop(struct symbol *sym)
156{ 162{
157 struct property *prop; 163 struct property *prop;
@@ -185,9 +191,9 @@ void sym_check_prop(struct symbol *sym)
185 case P_RANGE: 191 case P_RANGE:
186 if (sym->type != S_INT && sym->type != S_HEX) 192 if (sym->type != S_INT && sym->type != S_HEX)
187 prop_warn(prop, "range is only allowed " 193 prop_warn(prop, "range is only allowed "
188 "for int or hex symbols"); 194 "for int or hex symbols");
189 if (!sym_string_valid(sym, prop->expr->left.sym->name) || 195 if (!menu_range_valid_sym(sym, prop->expr->left.sym) ||
190 !sym_string_valid(sym, prop->expr->right.sym->name)) 196 !menu_range_valid_sym(sym, prop->expr->right.sym))
191 prop_warn(prop, "range is invalid"); 197 prop_warn(prop, "range is invalid");
192 break; 198 break;
193 default: 199 default:
@@ -366,9 +372,9 @@ bool menu_is_visible(struct menu *menu)
366const char *menu_get_prompt(struct menu *menu) 372const char *menu_get_prompt(struct menu *menu)
367{ 373{
368 if (menu->prompt) 374 if (menu->prompt)
369 return menu->prompt->text; 375 return _(menu->prompt->text);
370 else if (menu->sym) 376 else if (menu->sym)
371 return menu->sym->name; 377 return _(menu->sym->name);
372 return NULL; 378 return NULL;
373} 379}
374 380
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
new file mode 100644
index 000000000..4590cd316
--- /dev/null
+++ b/scripts/kconfig/qconf.cc
@@ -0,0 +1,1426 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <qapplication.h>
7#include <qmainwindow.h>
8#include <qtoolbar.h>
9#include <qvbox.h>
10#include <qsplitter.h>
11#include <qlistview.h>
12#include <qtextview.h>
13#include <qlineedit.h>
14#include <qmenubar.h>
15#include <qmessagebox.h>
16#include <qaction.h>
17#include <qheader.h>
18#include <qfiledialog.h>
19#include <qregexp.h>
20
21#include <stdlib.h>
22
23#include "lkc.h"
24#include "qconf.h"
25
26#include "qconf.moc"
27#include "images.c"
28
29#ifdef _
30# undef _
31# define _ qgettext
32#endif
33
34static QApplication *configApp;
35
36static inline QString qgettext(const char* str)
37{
38 return QString::fromLocal8Bit(gettext(str));
39}
40
41static inline QString qgettext(const QString& str)
42{
43 return QString::fromLocal8Bit(gettext(str.latin1()));
44}
45
46ConfigSettings::ConfigSettings()
47 : showAll(false), showName(false), showRange(false), showData(false)
48{
49}
50
51#if QT_VERSION >= 300
52/**
53 * Reads the list column settings from the application settings.
54 */
55void ConfigSettings::readListSettings()
56{
57 showAll = readBoolEntry("/kconfig/qconf/showAll", false);
58 showName = readBoolEntry("/kconfig/qconf/showName", false);
59 showRange = readBoolEntry("/kconfig/qconf/showRange", false);
60 showData = readBoolEntry("/kconfig/qconf/showData", false);
61}
62
63/**
64 * Reads a list of integer values from the application settings.
65 */
66QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
67{
68 QValueList<int> result;
69 QStringList entryList = readListEntry(key, ok);
70 if (ok) {
71 QStringList::Iterator it;
72 for (it = entryList.begin(); it != entryList.end(); ++it)
73 result.push_back((*it).toInt());
74 }
75
76 return result;
77}
78
79/**
80 * Writes a list of integer values to the application settings.
81 */
82bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value)
83{
84 QStringList stringList;
85 QValueList<int>::ConstIterator it;
86
87 for (it = value.begin(); it != value.end(); ++it)
88 stringList.push_back(QString::number(*it));
89 return writeEntry(key, stringList);
90}
91#endif
92
93
94/*
95 * update all the children of a menu entry
96 * removes/adds the entries from the parent widget as necessary
97 *
98 * parent: either the menu list widget or a menu entry widget
99 * menu: entry to be updated
100 */
101template <class P>
102void ConfigList::updateMenuList(P* parent, struct menu* menu)
103{
104 struct menu* child;
105 ConfigItem* item;
106 ConfigItem* last;
107 bool visible;
108 enum prop_type type;
109
110 if (!menu) {
111 while ((item = parent->firstChild()))
112 delete item;
113 return;
114 }
115
116 last = parent->firstChild();
117 if (last && !last->goParent)
118 last = 0;
119 for (child = menu->list; child; child = child->next) {
120 item = last ? last->nextSibling() : parent->firstChild();
121 type = child->prompt ? child->prompt->type : P_UNKNOWN;
122
123 switch (mode) {
124 case menuMode:
125 if (!(child->flags & MENU_ROOT))
126 goto hide;
127 break;
128 case symbolMode:
129 if (child->flags & MENU_ROOT)
130 goto hide;
131 break;
132 default:
133 break;
134 }
135
136 visible = menu_is_visible(child);
137 if (showAll || visible) {
138 if (!item || item->menu != child)
139 item = new ConfigItem(parent, last, child, visible);
140 else
141 item->testUpdateMenu(visible);
142
143 if (mode == fullMode || mode == menuMode || type != P_MENU)
144 updateMenuList(item, child);
145 else
146 updateMenuList(item, 0);
147 last = item;
148 continue;
149 }
150 hide:
151 if (item && item->menu == child) {
152 last = parent->firstChild();
153 if (last == item)
154 last = 0;
155 else while (last->nextSibling() != item)
156 last = last->nextSibling();
157 delete item;
158 }
159 }
160}
161
162#if QT_VERSION >= 300
163/*
164 * set the new data
165 * TODO check the value
166 */
167void ConfigItem::okRename(int col)
168{
169 Parent::okRename(col);
170 sym_set_string_value(menu->sym, text(dataColIdx).latin1());
171}
172#endif
173
174/*
175 * update the displayed of a menu entry
176 */
177void ConfigItem::updateMenu(void)
178{
179 ConfigList* list;
180 struct symbol* sym;
181 struct property *prop;
182 QString prompt;
183 int type;
184 tristate expr;
185
186 list = listView();
187 if (goParent) {
188 setPixmap(promptColIdx, list->menuBackPix);
189 prompt = "..";
190 goto set_prompt;
191 }
192
193 sym = menu->sym;
194 prop = menu->prompt;
195 prompt = QString::fromLocal8Bit(menu_get_prompt(menu));
196
197 if (prop) switch (prop->type) {
198 case P_MENU:
199 if (list->mode == singleMode || list->mode == symbolMode) {
200 /* a menuconfig entry is displayed differently
201 * depending whether it's at the view root or a child.
202 */
203 if (sym && list->rootEntry == menu)
204 break;
205 setPixmap(promptColIdx, list->menuPix);
206 } else {
207 if (sym)
208 break;
209 setPixmap(promptColIdx, 0);
210 }
211 goto set_prompt;
212 case P_COMMENT:
213 setPixmap(promptColIdx, 0);
214 goto set_prompt;
215 default:
216 ;
217 }
218 if (!sym)
219 goto set_prompt;
220
221 setText(nameColIdx, QString::fromLocal8Bit(sym->name));
222
223 type = sym_get_type(sym);
224 switch (type) {
225 case S_BOOLEAN:
226 case S_TRISTATE:
227 char ch;
228
229 if (!sym_is_changable(sym) && !list->showAll) {
230 setPixmap(promptColIdx, 0);
231 setText(noColIdx, QString::null);
232 setText(modColIdx, QString::null);
233 setText(yesColIdx, QString::null);
234 break;
235 }
236 expr = sym_get_tristate_value(sym);
237 switch (expr) {
238 case yes:
239 if (sym_is_choice_value(sym) && type == S_BOOLEAN)
240 setPixmap(promptColIdx, list->choiceYesPix);
241 else
242 setPixmap(promptColIdx, list->symbolYesPix);
243 setText(yesColIdx, "Y");
244 ch = 'Y';
245 break;
246 case mod:
247 setPixmap(promptColIdx, list->symbolModPix);
248 setText(modColIdx, "M");
249 ch = 'M';
250 break;
251 default:
252 if (sym_is_choice_value(sym) && type == S_BOOLEAN)
253 setPixmap(promptColIdx, list->choiceNoPix);
254 else
255 setPixmap(promptColIdx, list->symbolNoPix);
256 setText(noColIdx, "N");
257 ch = 'N';
258 break;
259 }
260 if (expr != no)
261 setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0);
262 if (expr != mod)
263 setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0);
264 if (expr != yes)
265 setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0);
266
267 setText(dataColIdx, QChar(ch));
268 break;
269 case S_INT:
270 case S_HEX:
271 case S_STRING:
272 const char* data;
273
274 data = sym_get_string_value(sym);
275
276#if QT_VERSION >= 300
277 int i = list->mapIdx(dataColIdx);
278 if (i >= 0)
279 setRenameEnabled(i, TRUE);
280#endif
281 setText(dataColIdx, data);
282 if (type == S_STRING)
283 prompt = QString("%1: %2").arg(prompt).arg(data);
284 else
285 prompt = QString("(%2) %1").arg(prompt).arg(data);
286 break;
287 }
288 if (!sym_has_value(sym) && visible)
289 prompt += " (NEW)";
290set_prompt:
291 setText(promptColIdx, prompt);
292}
293
294void ConfigItem::testUpdateMenu(bool v)
295{
296 ConfigItem* i;
297
298 visible = v;
299 if (!menu)
300 return;
301
302 sym_calc_value(menu->sym);
303 if (menu->flags & MENU_CHANGED) {
304 /* the menu entry changed, so update all list items */
305 menu->flags &= ~MENU_CHANGED;
306 for (i = (ConfigItem*)menu->data; i; i = i->nextItem)
307 i->updateMenu();
308 } else if (listView()->updateAll)
309 updateMenu();
310}
311
312void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align)
313{
314 ConfigList* list = listView();
315
316 if (visible) {
317 if (isSelected() && !list->hasFocus() && list->mode == menuMode)
318 Parent::paintCell(p, list->inactivedColorGroup, column, width, align);
319 else
320 Parent::paintCell(p, cg, column, width, align);
321 } else
322 Parent::paintCell(p, list->disabledColorGroup, column, width, align);
323}
324
325/*
326 * construct a menu entry
327 */
328void ConfigItem::init(void)
329{
330 if (menu) {
331 ConfigList* list = listView();
332 nextItem = (ConfigItem*)menu->data;
333 menu->data = this;
334
335 if (list->mode != fullMode)
336 setOpen(TRUE);
337 sym_calc_value(menu->sym);
338 }
339 updateMenu();
340}
341
342/*
343 * destruct a menu entry
344 */
345ConfigItem::~ConfigItem(void)
346{
347 if (menu) {
348 ConfigItem** ip = (ConfigItem**)&menu->data;
349 for (; *ip; ip = &(*ip)->nextItem) {
350 if (*ip == this) {
351 *ip = nextItem;
352 break;
353 }
354 }
355 }
356}
357
358void ConfigLineEdit::show(ConfigItem* i)
359{
360 item = i;
361 if (sym_get_string_value(item->menu->sym))
362 setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym)));
363 else
364 setText(QString::null);
365 Parent::show();
366 setFocus();
367}
368
369void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
370{
371 switch (e->key()) {
372 case Key_Escape:
373 break;
374 case Key_Return:
375 case Key_Enter:
376 sym_set_string_value(item->menu->sym, text().latin1());
377 parent()->updateList(item);
378 break;
379 default:
380 Parent::keyPressEvent(e);
381 return;
382 }
383 e->accept();
384 parent()->list->setFocus();
385 hide();
386}
387
388ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv, ConfigSettings* configSettings)
389 : Parent(p), cview(cv),
390 updateAll(false),
391 symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
392 choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
393 menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
394 showAll(false), showName(false), showRange(false), showData(false),
395 rootEntry(0)
396{
397 int i;
398
399 setSorting(-1);
400 setRootIsDecorated(TRUE);
401 disabledColorGroup = palette().active();
402 disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text());
403 inactivedColorGroup = palette().active();
404 inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight());
405
406 connect(this, SIGNAL(selectionChanged(void)),
407 SLOT(updateSelection(void)));
408
409 if (configSettings) {
410 showAll = configSettings->showAll;
411 showName = configSettings->showName;
412 showRange = configSettings->showRange;
413 showData = configSettings->showData;
414 }
415
416 for (i = 0; i < colNr; i++)
417 colMap[i] = colRevMap[i] = -1;
418 addColumn(promptColIdx, "Option");
419
420 reinit();
421}
422
423void ConfigList::reinit(void)
424{
425 removeColumn(dataColIdx);
426 removeColumn(yesColIdx);
427 removeColumn(modColIdx);
428 removeColumn(noColIdx);
429 removeColumn(nameColIdx);
430
431 if (showName)
432 addColumn(nameColIdx, "Name");
433 if (showRange) {
434 addColumn(noColIdx, "N");
435 addColumn(modColIdx, "M");
436 addColumn(yesColIdx, "Y");
437 }
438 if (showData)
439 addColumn(dataColIdx, "Value");
440
441 updateListAll();
442}
443
444void ConfigList::updateSelection(void)
445{
446 struct menu *menu;
447 enum prop_type type;
448
449 ConfigItem* item = (ConfigItem*)selectedItem();
450 if (!item)
451 return;
452
453 cview->setHelp(item);
454
455 menu = item->menu;
456 if (!menu)
457 return;
458 type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
459 if (mode == menuMode && type == P_MENU)
460 emit menuSelected(menu);
461}
462
463void ConfigList::updateList(ConfigItem* item)
464{
465 ConfigItem* last = 0;
466
467 if (!rootEntry)
468 goto update;
469
470 if (rootEntry != &rootmenu && (mode == singleMode ||
471 (mode == symbolMode && rootEntry->parent != &rootmenu))) {
472 item = firstChild();
473 if (!item)
474 item = new ConfigItem(this, 0, true);
475 last = item;
476 }
477 if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) &&
478 rootEntry->sym && rootEntry->prompt) {
479 item = last ? last->nextSibling() : firstChild();
480 if (!item)
481 item = new ConfigItem(this, last, rootEntry, true);
482 else
483 item->testUpdateMenu(true);
484
485 updateMenuList(item, rootEntry);
486 triggerUpdate();
487 return;
488 }
489update:
490 updateMenuList(this, rootEntry);
491 triggerUpdate();
492}
493
494void ConfigList::setAllOpen(bool open)
495{
496 QListViewItemIterator it(this);
497
498 for (; it.current(); it++)
499 it.current()->setOpen(open);
500}
501
502void ConfigList::setValue(ConfigItem* item, tristate val)
503{
504 struct symbol* sym;
505 int type;
506 tristate oldval;
507
508 sym = item->menu ? item->menu->sym : 0;
509 if (!sym)
510 return;
511
512 type = sym_get_type(sym);
513 switch (type) {
514 case S_BOOLEAN:
515 case S_TRISTATE:
516 oldval = sym_get_tristate_value(sym);
517
518 if (!sym_set_tristate_value(sym, val))
519 return;
520 if (oldval == no && item->menu->list)
521 item->setOpen(TRUE);
522 parent()->updateList(item);
523 break;
524 }
525}
526
527void ConfigList::changeValue(ConfigItem* item)
528{
529 struct symbol* sym;
530 struct menu* menu;
531 int type, oldexpr, newexpr;
532
533 menu = item->menu;
534 if (!menu)
535 return;
536 sym = menu->sym;
537 if (!sym) {
538 if (item->menu->list)
539 item->setOpen(!item->isOpen());
540 return;
541 }
542
543 type = sym_get_type(sym);
544 switch (type) {
545 case S_BOOLEAN:
546 case S_TRISTATE:
547 oldexpr = sym_get_tristate_value(sym);
548 newexpr = sym_toggle_tristate_value(sym);
549 if (item->menu->list) {
550 if (oldexpr == newexpr)
551 item->setOpen(!item->isOpen());
552 else if (oldexpr == no)
553 item->setOpen(TRUE);
554 }
555 if (oldexpr != newexpr)
556 parent()->updateList(item);
557 break;
558 case S_INT:
559 case S_HEX:
560 case S_STRING:
561#if QT_VERSION >= 300
562 if (colMap[dataColIdx] >= 0)
563 item->startRename(colMap[dataColIdx]);
564 else
565#endif
566 parent()->lineEdit->show(item);
567 break;
568 }
569}
570
571void ConfigList::setRootMenu(struct menu *menu)
572{
573 enum prop_type type;
574
575 if (rootEntry == menu)
576 return;
577 type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN;
578 if (type != P_MENU)
579 return;
580 updateMenuList(this, 0);
581 rootEntry = menu;
582 updateListAll();
583 setSelected(currentItem(), hasFocus());
584}
585
586void ConfigList::setParentMenu(void)
587{
588 ConfigItem* item;
589 struct menu *oldroot;
590
591 oldroot = rootEntry;
592 if (rootEntry == &rootmenu)
593 return;
594 setRootMenu(menu_get_parent_menu(rootEntry->parent));
595
596 QListViewItemIterator it(this);
597 for (; (item = (ConfigItem*)it.current()); it++) {
598 if (item->menu == oldroot) {
599 setCurrentItem(item);
600 ensureItemVisible(item);
601 break;
602 }
603 }
604}
605
606void ConfigList::keyPressEvent(QKeyEvent* ev)
607{
608 QListViewItem* i = currentItem();
609 ConfigItem* item;
610 struct menu *menu;
611 enum prop_type type;
612
613 if (ev->key() == Key_Escape && mode != fullMode) {
614 emit parentSelected();
615 ev->accept();
616 return;
617 }
618
619 if (!i) {
620 Parent::keyPressEvent(ev);
621 return;
622 }
623 item = (ConfigItem*)i;
624
625 switch (ev->key()) {
626 case Key_Return:
627 case Key_Enter:
628 if (item->goParent) {
629 emit parentSelected();
630 break;
631 }
632 menu = item->menu;
633 if (!menu)
634 break;
635 type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
636 if (type == P_MENU && rootEntry != menu &&
637 mode != fullMode && mode != menuMode) {
638 emit menuSelected(menu);
639 break;
640 }
641 case Key_Space:
642 changeValue(item);
643 break;
644 case Key_N:
645 setValue(item, no);
646 break;
647 case Key_M:
648 setValue(item, mod);
649 break;
650 case Key_Y:
651 setValue(item, yes);
652 break;
653 default:
654 Parent::keyPressEvent(ev);
655 return;
656 }
657 ev->accept();
658}
659
660void ConfigList::contentsMousePressEvent(QMouseEvent* e)
661{
662 //QPoint p(contentsToViewport(e->pos()));
663 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
664 Parent::contentsMousePressEvent(e);
665}
666
667void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
668{
669 QPoint p(contentsToViewport(e->pos()));
670 ConfigItem* item = (ConfigItem*)itemAt(p);
671 struct menu *menu;
672 enum prop_type ptype;
673 const QPixmap* pm;
674 int idx, x;
675
676 if (!item)
677 goto skip;
678
679 menu = item->menu;
680 x = header()->offset() + p.x();
681 idx = colRevMap[header()->sectionAt(x)];
682 switch (idx) {
683 case promptColIdx:
684 pm = item->pixmap(promptColIdx);
685 if (pm) {
686 int off = header()->sectionPos(0) + itemMargin() +
687 treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0));
688 if (x >= off && x < off + pm->width()) {
689 if (item->goParent) {
690 emit parentSelected();
691 break;
692 } else if (!menu)
693 break;
694 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
695 if (ptype == P_MENU && rootEntry != menu &&
696 mode != fullMode && mode != menuMode)
697 emit menuSelected(menu);
698 else
699 changeValue(item);
700 }
701 }
702 break;
703 case noColIdx:
704 setValue(item, no);
705 break;
706 case modColIdx:
707 setValue(item, mod);
708 break;
709 case yesColIdx:
710 setValue(item, yes);
711 break;
712 case dataColIdx:
713 changeValue(item);
714 break;
715 }
716
717skip:
718 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());
719 Parent::contentsMouseReleaseEvent(e);
720}
721
722void ConfigList::contentsMouseMoveEvent(QMouseEvent* e)
723{
724 //QPoint p(contentsToViewport(e->pos()));
725 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
726 Parent::contentsMouseMoveEvent(e);
727}
728
729void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e)
730{
731 QPoint p(contentsToViewport(e->pos()));
732 ConfigItem* item = (ConfigItem*)itemAt(p);
733 struct menu *menu;
734 enum prop_type ptype;
735
736 if (!item)
737 goto skip;
738 if (item->goParent) {
739 emit parentSelected();
740 goto skip;
741 }
742 menu = item->menu;
743 if (!menu)
744 goto skip;
745 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
746 if (ptype == P_MENU && (mode == singleMode || mode == symbolMode))
747 emit menuSelected(menu);
748 else if (menu->sym)
749 changeValue(item);
750
751skip:
752 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());
753 Parent::contentsMouseDoubleClickEvent(e);
754}
755
756void ConfigList::focusInEvent(QFocusEvent *e)
757{
758 Parent::focusInEvent(e);
759
760 QListViewItem* item = currentItem();
761 if (!item)
762 return;
763
764 setSelected(item, TRUE);
765 emit gotFocus();
766}
767
768ConfigView* ConfigView::viewList;
769
770ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview,
771 ConfigSettings *configSettings)
772 : Parent(parent)
773{
774 list = new ConfigList(this, cview, configSettings);
775 lineEdit = new ConfigLineEdit(this);
776 lineEdit->hide();
777
778 this->nextView = viewList;
779 viewList = this;
780}
781
782ConfigView::~ConfigView(void)
783{
784 ConfigView** vp;
785
786 for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
787 if (*vp == this) {
788 *vp = nextView;
789 break;
790 }
791 }
792}
793
794void ConfigView::updateList(ConfigItem* item)
795{
796 ConfigView* v;
797
798 for (v = viewList; v; v = v->nextView)
799 v->list->updateList(item);
800}
801
802void ConfigView::updateListAll(void)
803{
804 ConfigView* v;
805
806 for (v = viewList; v; v = v->nextView)
807 v->list->updateListAll();
808}
809
810/*
811 * Construct the complete config widget
812 */
813ConfigMainWindow::ConfigMainWindow(void)
814{
815 QMenuBar* menu;
816 bool ok;
817 int x, y, width, height;
818
819 QWidget *d = configApp->desktop();
820
821 ConfigSettings* configSettings = new ConfigSettings();
822#if QT_VERSION >= 300
823 width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64);
824 height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64);
825 resize(width, height);
826 x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok);
827 if (ok)
828 y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok);
829 if (ok)
830 move(x, y);
831 showDebug = configSettings->readBoolEntry("/kconfig/qconf/showDebug", false);
832
833 // read list settings into configSettings, will be used later for ConfigList setup
834 configSettings->readListSettings();
835#else
836 width = d->width() - 64;
837 height = d->height() - 64;
838 resize(width, height);
839 showDebug = false;
840#endif
841
842 split1 = new QSplitter(this);
843 split1->setOrientation(QSplitter::Horizontal);
844 setCentralWidget(split1);
845
846 menuView = new ConfigView(split1, this, configSettings);
847 menuList = menuView->list;
848
849 split2 = new QSplitter(split1);
850 split2->setOrientation(QSplitter::Vertical);
851
852 // create config tree
853 configView = new ConfigView(split2, this, configSettings);
854 configList = configView->list;
855
856 helpText = new QTextView(split2);
857 helpText->setTextFormat(Qt::RichText);
858
859 setTabOrder(configList, helpText);
860 configList->setFocus();
861
862 menu = menuBar();
863 toolBar = new QToolBar("Tools", this);
864
865 backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this);
866 connect(backAction, SIGNAL(activated()), SLOT(goBack()));
867 backAction->setEnabled(FALSE);
868 QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this);
869 connect(quitAction, SIGNAL(activated()), SLOT(close()));
870 QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this);
871 connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
872 QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
873 connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
874 QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);
875 connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
876 QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);
877 connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
878 QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);
879 connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
880 QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
881 connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
882
883 QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
884 showNameAction->setToggleAction(TRUE);
885 showNameAction->setOn(configList->showName);
886 connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool)));
887 QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);
888 showRangeAction->setToggleAction(TRUE);
889 showRangeAction->setOn(configList->showRange);
890 connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool)));
891 QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);
892 showDataAction->setToggleAction(TRUE);
893 showDataAction->setOn(configList->showData);
894 connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool)));
895 QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);
896 showAllAction->setToggleAction(TRUE);
897 showAllAction->setOn(configList->showAll);
898 connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool)));
899 QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
900 showDebugAction->setToggleAction(TRUE);
901 showDebugAction->setOn(showDebug);
902 connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
903
904 QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
905 connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
906 QAction *showAboutAction = new QAction(NULL, "About", 0, this);
907 connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
908
909 // init tool bar
910 backAction->addTo(toolBar);
911 toolBar->addSeparator();
912 loadAction->addTo(toolBar);
913 saveAction->addTo(toolBar);
914 toolBar->addSeparator();
915 singleViewAction->addTo(toolBar);
916 splitViewAction->addTo(toolBar);
917 fullViewAction->addTo(toolBar);
918
919 // create config menu
920 QPopupMenu* config = new QPopupMenu(this);
921 menu->insertItem("&File", config);
922 loadAction->addTo(config);
923 saveAction->addTo(config);
924 saveAsAction->addTo(config);
925 config->insertSeparator();
926 quitAction->addTo(config);
927
928 // create options menu
929 QPopupMenu* optionMenu = new QPopupMenu(this);
930 menu->insertItem("&Option", optionMenu);
931 showNameAction->addTo(optionMenu);
932 showRangeAction->addTo(optionMenu);
933 showDataAction->addTo(optionMenu);
934 optionMenu->insertSeparator();
935 showAllAction->addTo(optionMenu);
936 showDebugAction->addTo(optionMenu);
937
938 // create help menu
939 QPopupMenu* helpMenu = new QPopupMenu(this);
940 menu->insertSeparator();
941 menu->insertItem("&Help", helpMenu);
942 showIntroAction->addTo(helpMenu);
943 showAboutAction->addTo(helpMenu);
944
945 connect(configList, SIGNAL(menuSelected(struct menu *)),
946 SLOT(changeMenu(struct menu *)));
947 connect(configList, SIGNAL(parentSelected()),
948 SLOT(goBack()));
949 connect(menuList, SIGNAL(menuSelected(struct menu *)),
950 SLOT(changeMenu(struct menu *)));
951
952 connect(configList, SIGNAL(gotFocus(void)),
953 SLOT(listFocusChanged(void)));
954 connect(menuList, SIGNAL(gotFocus(void)),
955 SLOT(listFocusChanged(void)));
956
957#if QT_VERSION >= 300
958 QString listMode = configSettings->readEntry("/kconfig/qconf/listMode", "symbol");
959 if (listMode == "single")
960 showSingleView();
961 else if (listMode == "full")
962 showFullView();
963 else /*if (listMode == "split")*/
964 showSplitView();
965
966 // UI setup done, restore splitter positions
967 QValueList<int> sizes = configSettings->readSizes("/kconfig/qconf/split1", &ok);
968 if (ok)
969 split1->setSizes(sizes);
970
971 sizes = configSettings->readSizes("/kconfig/qconf/split2", &ok);
972 if (ok)
973 split2->setSizes(sizes);
974#else
975 showSplitView();
976#endif
977 delete configSettings;
978}
979
980static QString print_filter(const QString &str)
981{
982 QRegExp re("[<>&\"\\n]");
983 QString res = str;
984 for (int i = 0; (i = res.find(re, i)) >= 0;) {
985 switch (res[i].latin1()) {
986 case '<':
987 res.replace(i, 1, "&lt;");
988 i += 4;
989 break;
990 case '>':
991 res.replace(i, 1, "&gt;");
992 i += 4;
993 break;
994 case '&':
995 res.replace(i, 1, "&amp;");
996 i += 5;
997 break;
998 case '"':
999 res.replace(i, 1, "&quot;");
1000 i += 6;
1001 break;
1002 case '\n':
1003 res.replace(i, 1, "<br>");
1004 i += 4;
1005 break;
1006 }
1007 }
1008 return res;
1009}
1010
1011static void expr_print_help(void *data, const char *str)
1012{
1013 reinterpret_cast<QString*>(data)->append(print_filter(str));
1014}
1015
1016/*
1017 * display a new help entry as soon as a new menu entry is selected
1018 */
1019void ConfigMainWindow::setHelp(QListViewItem* item)
1020{
1021 struct symbol* sym;
1022 struct menu* menu = 0;
1023
1024 configList->parent()->lineEdit->hide();
1025 if (item)
1026 menu = ((ConfigItem*)item)->menu;
1027 if (!menu) {
1028 helpText->setText(QString::null);
1029 return;
1030 }
1031
1032 QString head, debug, help;
1033 menu = ((ConfigItem*)item)->menu;
1034 sym = menu->sym;
1035 if (sym) {
1036 if (menu->prompt) {
1037 head += "<big><b>";
1038 head += print_filter(_(menu->prompt->text));
1039 head += "</b></big>";
1040 if (sym->name) {
1041 head += " (";
1042 head += print_filter(_(sym->name));
1043 head += ")";
1044 }
1045 } else if (sym->name) {
1046 head += "<big><b>";
1047 head += print_filter(_(sym->name));
1048 head += "</b></big>";
1049 }
1050 head += "<br><br>";
1051
1052 if (showDebug) {
1053 debug += "type: ";
1054 debug += print_filter(sym_type_name(sym->type));
1055 if (sym_is_choice(sym))
1056 debug += " (choice)";
1057 debug += "<br>";
1058 if (sym->rev_dep.expr) {
1059 debug += "reverse dep: ";
1060 expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
1061 debug += "<br>";
1062 }
1063 for (struct property *prop = sym->prop; prop; prop = prop->next) {
1064 switch (prop->type) {
1065 case P_PROMPT:
1066 case P_MENU:
1067 debug += "prompt: ";
1068 debug += print_filter(_(prop->text));
1069 debug += "<br>";
1070 break;
1071 case P_DEFAULT:
1072 debug += "default: ";
1073 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1074 debug += "<br>";
1075 break;
1076 case P_CHOICE:
1077 if (sym_is_choice(sym)) {
1078 debug += "choice: ";
1079 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1080 debug += "<br>";
1081 }
1082 break;
1083 case P_SELECT:
1084 debug += "select: ";
1085 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1086 debug += "<br>";
1087 break;
1088 case P_RANGE:
1089 debug += "range: ";
1090 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1091 debug += "<br>";
1092 break;
1093 default:
1094 debug += "unknown property: ";
1095 debug += prop_get_type_name(prop->type);
1096 debug += "<br>";
1097 }
1098 if (prop->visible.expr) {
1099 debug += "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
1100 expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
1101 debug += "<br>";
1102 }
1103 }
1104 debug += "<br>";
1105 }
1106
1107 help = print_filter(_(sym->help));
1108 } else if (menu->prompt) {
1109 head += "<big><b>";
1110 head += print_filter(_(menu->prompt->text));
1111 head += "</b></big><br><br>";
1112 if (showDebug) {
1113 if (menu->prompt->visible.expr) {
1114 debug += "&nbsp;&nbsp;dep: ";
1115 expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
1116 debug += "<br><br>";
1117 }
1118 }
1119 }
1120 if (showDebug)
1121 debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
1122 helpText->setText(head + debug + help);
1123}
1124
1125void ConfigMainWindow::loadConfig(void)
1126{
1127 QString s = QFileDialog::getOpenFileName(".config", NULL, this);
1128 if (s.isNull())
1129 return;
1130 if (conf_read(QFile::encodeName(s)))
1131 QMessageBox::information(this, "qconf", "Unable to load configuration!");
1132 ConfigView::updateListAll();
1133}
1134
1135void ConfigMainWindow::saveConfig(void)
1136{
1137 if (conf_write(NULL))
1138 QMessageBox::information(this, "qconf", "Unable to save configuration!");
1139}
1140
1141void ConfigMainWindow::saveConfigAs(void)
1142{
1143 QString s = QFileDialog::getSaveFileName(".config", NULL, this);
1144 if (s.isNull())
1145 return;
1146 if (conf_write(QFile::encodeName(s)))
1147 QMessageBox::information(this, "qconf", "Unable to save configuration!");
1148}
1149
1150void ConfigMainWindow::changeMenu(struct menu *menu)
1151{
1152 configList->setRootMenu(menu);
1153 backAction->setEnabled(TRUE);
1154}
1155
1156void ConfigMainWindow::listFocusChanged(void)
1157{
1158 if (menuList->hasFocus()) {
1159 if (menuList->mode == menuMode)
1160 configList->clearSelection();
1161 setHelp(menuList->selectedItem());
1162 } else if (configList->hasFocus()) {
1163 setHelp(configList->selectedItem());
1164 }
1165}
1166
1167void ConfigMainWindow::goBack(void)
1168{
1169 ConfigItem* item;
1170
1171 configList->setParentMenu();
1172 if (configList->rootEntry == &rootmenu)
1173 backAction->setEnabled(FALSE);
1174 item = (ConfigItem*)menuList->selectedItem();
1175 while (item) {
1176 if (item->menu == configList->rootEntry) {
1177 menuList->setSelected(item, TRUE);
1178 break;
1179 }
1180 item = (ConfigItem*)item->parent();
1181 }
1182}
1183
1184void ConfigMainWindow::showSingleView(void)
1185{
1186 menuView->hide();
1187 menuList->setRootMenu(0);
1188 configList->mode = singleMode;
1189 if (configList->rootEntry == &rootmenu)
1190 configList->updateListAll();
1191 else
1192 configList->setRootMenu(&rootmenu);
1193 configList->setAllOpen(TRUE);
1194 configList->setFocus();
1195}
1196
1197void ConfigMainWindow::showSplitView(void)
1198{
1199 configList->mode = symbolMode;
1200 if (configList->rootEntry == &rootmenu)
1201 configList->updateListAll();
1202 else
1203 configList->setRootMenu(&rootmenu);
1204 configList->setAllOpen(TRUE);
1205 configApp->processEvents();
1206 menuList->mode = menuMode;
1207 menuList->setRootMenu(&rootmenu);
1208 menuList->setAllOpen(TRUE);
1209 menuView->show();
1210 menuList->setFocus();
1211}
1212
1213void ConfigMainWindow::showFullView(void)
1214{
1215 menuView->hide();
1216 menuList->setRootMenu(0);
1217 configList->mode = fullMode;
1218 if (configList->rootEntry == &rootmenu)
1219 configList->updateListAll();
1220 else
1221 configList->setRootMenu(&rootmenu);
1222 configList->setAllOpen(FALSE);
1223 configList->setFocus();
1224}
1225
1226void ConfigMainWindow::setShowAll(bool b)
1227{
1228 if (configList->showAll == b)
1229 return;
1230 configList->showAll = b;
1231 configList->updateListAll();
1232 menuList->showAll = b;
1233 menuList->updateListAll();
1234}
1235
1236void ConfigMainWindow::setShowDebug(bool b)
1237{
1238 if (showDebug == b)
1239 return;
1240 showDebug = b;
1241}
1242
1243void ConfigMainWindow::setShowName(bool b)
1244{
1245 if (configList->showName == b)
1246 return;
1247 configList->showName = b;
1248 configList->reinit();
1249 menuList->showName = b;
1250 menuList->reinit();
1251}
1252
1253void ConfigMainWindow::setShowRange(bool b)
1254{
1255 if (configList->showRange == b)
1256 return;
1257 configList->showRange = b;
1258 configList->reinit();
1259 menuList->showRange = b;
1260 menuList->reinit();
1261}
1262
1263void ConfigMainWindow::setShowData(bool b)
1264{
1265 if (configList->showData == b)
1266 return;
1267 configList->showData = b;
1268 configList->reinit();
1269 menuList->showData = b;
1270 menuList->reinit();
1271}
1272
1273/*
1274 * ask for saving configuration before quitting
1275 * TODO ask only when something changed
1276 */
1277void ConfigMainWindow::closeEvent(QCloseEvent* e)
1278{
1279 if (!sym_change_count) {
1280 e->accept();
1281 return;
1282 }
1283 QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
1284 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
1285 mb.setButtonText(QMessageBox::Yes, "&Save Changes");
1286 mb.setButtonText(QMessageBox::No, "&Discard Changes");
1287 mb.setButtonText(QMessageBox::Cancel, "Cancel Exit");
1288 switch (mb.exec()) {
1289 case QMessageBox::Yes:
1290 conf_write(NULL);
1291 case QMessageBox::No:
1292 e->accept();
1293 break;
1294 case QMessageBox::Cancel:
1295 e->ignore();
1296 break;
1297 }
1298}
1299
1300void ConfigMainWindow::showIntro(void)
1301{
1302 static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
1303 "For each option, a blank box indicates the feature is disabled, a check\n"
1304 "indicates it is enabled, and a dot indicates that it is to be compiled\n"
1305 "as a module. Clicking on the box will cycle through the three states.\n\n"
1306 "If you do not see an option (e.g., a device driver) that you believe\n"
1307 "should be present, try turning on Show All Options under the Options menu.\n"
1308 "Although there is no cross reference yet to help you figure out what other\n"
1309 "options must be enabled to support the option you are interested in, you can\n"
1310 "still view the help of a grayed-out option.\n\n"
1311 "Toggling Show Debug Info under the Options menu will show the dependencies,\n"
1312 "which you can then match by examining other options.\n\n";
1313
1314 QMessageBox::information(this, "qconf", str);
1315}
1316
1317void ConfigMainWindow::showAbout(void)
1318{
1319 static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
1320 "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n";
1321
1322 QMessageBox::information(this, "qconf", str);
1323}
1324
1325void ConfigMainWindow::saveSettings(void)
1326{
1327#if QT_VERSION >= 300
1328 ConfigSettings *configSettings = new ConfigSettings;
1329 configSettings->writeEntry("/kconfig/qconf/window x", pos().x());
1330 configSettings->writeEntry("/kconfig/qconf/window y", pos().y());
1331 configSettings->writeEntry("/kconfig/qconf/window width", size().width());
1332 configSettings->writeEntry("/kconfig/qconf/window height", size().height());
1333 configSettings->writeEntry("/kconfig/qconf/showName", configList->showName);
1334 configSettings->writeEntry("/kconfig/qconf/showRange", configList->showRange);
1335 configSettings->writeEntry("/kconfig/qconf/showData", configList->showData);
1336 configSettings->writeEntry("/kconfig/qconf/showAll", configList->showAll);
1337 configSettings->writeEntry("/kconfig/qconf/showDebug", showDebug);
1338
1339 QString entry;
1340 switch(configList->mode) {
1341 case singleMode :
1342 entry = "single";
1343 break;
1344
1345 case symbolMode :
1346 entry = "split";
1347 break;
1348
1349 case fullMode :
1350 entry = "full";
1351 break;
1352 }
1353 configSettings->writeEntry("/kconfig/qconf/listMode", entry);
1354
1355 configSettings->writeSizes("/kconfig/qconf/split1", split1->sizes());
1356 configSettings->writeSizes("/kconfig/qconf/split2", split2->sizes());
1357
1358 delete configSettings;
1359#endif
1360}
1361
1362void fixup_rootmenu(struct menu *menu)
1363{
1364 struct menu *child;
1365 static int menu_cnt = 0;
1366
1367 menu->flags |= MENU_ROOT;
1368 for (child = menu->list; child; child = child->next) {
1369 if (child->prompt && child->prompt->type == P_MENU) {
1370 menu_cnt++;
1371 fixup_rootmenu(child);
1372 menu_cnt--;
1373 } else if (!menu_cnt)
1374 fixup_rootmenu(child);
1375 }
1376}
1377
1378static const char *progname;
1379
1380static void usage(void)
1381{
1382 printf("%s <config>\n", progname);
1383 exit(0);
1384}
1385
1386int main(int ac, char** av)
1387{
1388 ConfigMainWindow* v;
1389 const char *name;
1390
1391 bindtextdomain(PACKAGE, LOCALEDIR);
1392 textdomain(PACKAGE);
1393
1394#ifndef LKC_DIRECT_LINK
1395 kconfig_load();
1396#endif
1397
1398 progname = av[0];
1399 configApp = new QApplication(ac, av);
1400 if (ac > 1 && av[1][0] == '-') {
1401 switch (av[1][1]) {
1402 case 'h':
1403 case '?':
1404 usage();
1405 }
1406 name = av[2];
1407 } else
1408 name = av[1];
1409 if (!name)
1410 usage();
1411
1412 conf_parse(name);
1413 fixup_rootmenu(&rootmenu);
1414 conf_read(NULL);
1415 //zconfdump(stdout);
1416
1417 v = new ConfigMainWindow();
1418
1419 //zconfdump(stdout);
1420 v->show();
1421 configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
1422 configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
1423 configApp->exec();
1424
1425 return 0;
1426}
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
new file mode 100644
index 000000000..e52f3e90b
--- /dev/null
+++ b/scripts/kconfig/qconf.h
@@ -0,0 +1,263 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <qlistview.h>
7#if QT_VERSION >= 300
8#include <qsettings.h>
9#else
10class QSettings { };
11#endif
12
13class ConfigList;
14class ConfigItem;
15class ConfigLineEdit;
16class ConfigMainWindow;
17
18
19class ConfigSettings : public QSettings {
20public:
21 ConfigSettings();
22
23#if QT_VERSION >= 300
24 void readListSettings();
25 QValueList<int> readSizes(const QString& key, bool *ok);
26 bool writeSizes(const QString& key, const QValueList<int>& value);
27#endif
28
29 bool showAll;
30 bool showName;
31 bool showRange;
32 bool showData;
33};
34
35class ConfigView : public QVBox {
36 Q_OBJECT
37 typedef class QVBox Parent;
38public:
39 ConfigView(QWidget* parent, ConfigMainWindow* cview, ConfigSettings* configSettings);
40 ~ConfigView(void);
41 static void updateList(ConfigItem* item);
42 static void updateListAll(void);
43
44public:
45 ConfigList* list;
46 ConfigLineEdit* lineEdit;
47
48 static ConfigView* viewList;
49 ConfigView* nextView;
50};
51
52enum colIdx {
53 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
54};
55enum listMode {
56 singleMode, menuMode, symbolMode, fullMode
57};
58
59class ConfigList : public QListView {
60 Q_OBJECT
61 typedef class QListView Parent;
62public:
63 ConfigList(ConfigView* p, ConfigMainWindow* cview, ConfigSettings *configSettings);
64 void reinit(void);
65 ConfigView* parent(void) const
66 {
67 return (ConfigView*)Parent::parent();
68 }
69
70protected:
71 ConfigMainWindow* cview;
72
73 void keyPressEvent(QKeyEvent *e);
74 void contentsMousePressEvent(QMouseEvent *e);
75 void contentsMouseReleaseEvent(QMouseEvent *e);
76 void contentsMouseMoveEvent(QMouseEvent *e);
77 void contentsMouseDoubleClickEvent(QMouseEvent *e);
78 void focusInEvent(QFocusEvent *e);
79public slots:
80 void setRootMenu(struct menu *menu);
81
82 void updateList(ConfigItem *item);
83 void setValue(ConfigItem* item, tristate val);
84 void changeValue(ConfigItem* item);
85 void updateSelection(void);
86signals:
87 void menuSelected(struct menu *menu);
88 void parentSelected(void);
89 void gotFocus(void);
90
91public:
92 void updateListAll(void)
93 {
94 updateAll = true;
95 updateList(NULL);
96 updateAll = false;
97 }
98 ConfigList* listView()
99 {
100 return this;
101 }
102 ConfigItem* firstChild() const
103 {
104 return (ConfigItem *)Parent::firstChild();
105 }
106 int mapIdx(colIdx idx)
107 {
108 return colMap[idx];
109 }
110 void addColumn(colIdx idx, const QString& label)
111 {
112 colMap[idx] = Parent::addColumn(label);
113 colRevMap[colMap[idx]] = idx;
114 }
115 void removeColumn(colIdx idx)
116 {
117 int col = colMap[idx];
118 if (col >= 0) {
119 Parent::removeColumn(col);
120 colRevMap[col] = colMap[idx] = -1;
121 }
122 }
123 void setAllOpen(bool open);
124 void setParentMenu(void);
125
126 template <class P>
127 void updateMenuList(P*, struct menu*);
128
129 bool updateAll;
130
131 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
132 QPixmap choiceYesPix, choiceNoPix;
133 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
134
135 bool showAll, showName, showRange, showData;
136 enum listMode mode;
137 struct menu *rootEntry;
138 QColorGroup disabledColorGroup;
139 QColorGroup inactivedColorGroup;
140
141private:
142 int colMap[colNr];
143 int colRevMap[colNr];
144};
145
146class ConfigItem : public QListViewItem {
147 typedef class QListViewItem Parent;
148public:
149 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v)
150 : Parent(parent, after), menu(m), visible(v), goParent(false)
151 {
152 init();
153 }
154 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
155 : Parent(parent, after), menu(m), visible(v), goParent(false)
156 {
157 init();
158 }
159 ConfigItem(QListView *parent, ConfigItem *after, bool v)
160 : Parent(parent, after), menu(0), visible(v), goParent(true)
161 {
162 init();
163 }
164 ~ConfigItem(void);
165 void init(void);
166#if QT_VERSION >= 300
167 void okRename(int col);
168#endif
169 void updateMenu(void);
170 void testUpdateMenu(bool v);
171 ConfigList* listView() const
172 {
173 return (ConfigList*)Parent::listView();
174 }
175 ConfigItem* firstChild() const
176 {
177 return (ConfigItem *)Parent::firstChild();
178 }
179 ConfigItem* nextSibling() const
180 {
181 return (ConfigItem *)Parent::nextSibling();
182 }
183 void setText(colIdx idx, const QString& text)
184 {
185 Parent::setText(listView()->mapIdx(idx), text);
186 }
187 QString text(colIdx idx) const
188 {
189 return Parent::text(listView()->mapIdx(idx));
190 }
191 void setPixmap(colIdx idx, const QPixmap& pm)
192 {
193 Parent::setPixmap(listView()->mapIdx(idx), pm);
194 }
195 const QPixmap* pixmap(colIdx idx) const
196 {
197 return Parent::pixmap(listView()->mapIdx(idx));
198 }
199 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
200
201 ConfigItem* nextItem;
202 struct menu *menu;
203 bool visible;
204 bool goParent;
205};
206
207class ConfigLineEdit : public QLineEdit {
208 Q_OBJECT
209 typedef class QLineEdit Parent;
210public:
211 ConfigLineEdit(ConfigView* parent)
212 : Parent(parent)
213 { }
214 ConfigView* parent(void) const
215 {
216 return (ConfigView*)Parent::parent();
217 }
218 void show(ConfigItem *i);
219 void keyPressEvent(QKeyEvent *e);
220
221public:
222 ConfigItem *item;
223};
224
225class ConfigMainWindow : public QMainWindow {
226 Q_OBJECT
227public:
228 ConfigMainWindow(void);
229public slots:
230 void setHelp(QListViewItem* item);
231 void changeMenu(struct menu *);
232 void listFocusChanged(void);
233 void goBack(void);
234 void loadConfig(void);
235 void saveConfig(void);
236 void saveConfigAs(void);
237 void showSingleView(void);
238 void showSplitView(void);
239 void showFullView(void);
240 void setShowAll(bool);
241 void setShowDebug(bool);
242 void setShowRange(bool);
243 void setShowName(bool);
244 void setShowData(bool);
245 void showIntro(void);
246 void showAbout(void);
247 void saveSettings(void);
248
249protected:
250 void closeEvent(QCloseEvent *e);
251
252 ConfigView *menuView;
253 ConfigList *menuList;
254 ConfigView *configView;
255 ConfigList *configList;
256 QTextView *helpText;
257 QToolBar *toolBar;
258 QAction *backAction;
259 QSplitter* split1;
260 QSplitter* split2;
261
262 bool showDebug;
263};
diff --git a/scripts/config/symbol.c b/scripts/kconfig/symbol.c
index aeea4cc9f..3d7877afc 100644
--- a/scripts/config/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
@@ -45,6 +44,7 @@ void sym_add_default(struct symbol *sym, const char *def)
45void sym_init(void) 44void sym_init(void)
46{ 45{
47 struct symbol *sym; 46 struct symbol *sym;
47 struct utsname uts;
48 char *p; 48 char *p;
49 static bool inited = false; 49 static bool inited = false;
50 50
@@ -52,20 +52,26 @@ void sym_init(void)
52 return; 52 return;
53 inited = true; 53 inited = true;
54 54
55 sym = sym_lookup("VERSION", 0); 55 uname(&uts);
56
57 sym = sym_lookup("ARCH", 0);
56 sym->type = S_STRING; 58 sym->type = S_STRING;
57 sym->flags |= SYMBOL_AUTO; 59 sym->flags |= SYMBOL_AUTO;
58 p = getenv("VERSION"); 60 p = getenv("ARCH");
59 if (p) 61 if (p)
60 sym_add_default(sym, p); 62 sym_add_default(sym, p);
61 63
62 sym = sym_lookup("TARGET_ARCH", 0); 64 sym = sym_lookup("KERNELVERSION", 0);
63 sym->type = S_STRING; 65 sym->type = S_STRING;
64 sym->flags |= SYMBOL_AUTO; 66 sym->flags |= SYMBOL_AUTO;
65 p = getenv("TARGET_ARCH"); 67 p = getenv("KERNELVERSION");
66 if (p) 68 if (p)
67 sym_add_default(sym, p); 69 sym_add_default(sym, p);
68 70
71 sym = sym_lookup("UNAME_RELEASE", 0);
72 sym->type = S_STRING;
73 sym->flags |= SYMBOL_AUTO;
74 sym_add_default(sym, uts.release);
69} 75}
70 76
71enum symbol_type sym_get_type(struct symbol *sym) 77enum symbol_type sym_get_type(struct symbol *sym)
@@ -135,6 +141,55 @@ struct property *sym_get_range_prop(struct symbol *sym)
135 return NULL; 141 return NULL;
136} 142}
137 143
144static int sym_get_range_val(struct symbol *sym, int base)
145{
146 sym_calc_value(sym);
147 switch (sym->type) {
148 case S_INT:
149 base = 10;
150 break;
151 case S_HEX:
152 base = 16;
153 break;
154 default:
155 break;
156 }
157 return strtol(sym->curr.val, NULL, base);
158}
159
160static void sym_validate_range(struct symbol *sym)
161{
162 struct property *prop;
163 int base, val, val2;
164 char str[64];
165
166 switch (sym->type) {
167 case S_INT:
168 base = 10;
169 break;
170 case S_HEX:
171 base = 16;
172 break;
173 default:
174 return;
175 }
176 prop = sym_get_range_prop(sym);
177 if (!prop)
178 return;
179 val = strtol(sym->curr.val, NULL, base);
180 val2 = sym_get_range_val(prop->expr->left.sym, base);
181 if (val >= val2) {
182 val2 = sym_get_range_val(prop->expr->right.sym, base);
183 if (val <= val2)
184 return;
185 }
186 if (sym->type == S_INT)
187 sprintf(str, "%d", val2);
188 else
189 sprintf(str, "0x%x", val2);
190 sym->curr.val = strdup(str);
191}
192
138static void sym_calc_visibility(struct symbol *sym) 193static void sym_calc_visibility(struct symbol *sym)
139{ 194{
140 struct property *prop; 195 struct property *prop;
@@ -295,6 +350,7 @@ void sym_calc_value(struct symbol *sym)
295 sym->curr = newval; 350 sym->curr = newval;
296 if (sym_is_choice(sym) && newval.tri == yes) 351 if (sym_is_choice(sym) && newval.tri == yes)
297 sym->curr.val = sym_calc_choice(sym); 352 sym->curr.val = sym_calc_choice(sym);
353 sym_validate_range(sym);
298 354
299 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) 355 if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
300 sym_set_changed(sym); 356 sym_set_changed(sym);
@@ -374,11 +430,22 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val)
374 sym->flags &= ~SYMBOL_NEW; 430 sym->flags &= ~SYMBOL_NEW;
375 sym_set_changed(sym); 431 sym_set_changed(sym);
376 } 432 }
433 /*
434 * setting a choice value also resets the new flag of the choice
435 * symbol and all other choice values.
436 */
377 if (sym_is_choice_value(sym) && val == yes) { 437 if (sym_is_choice_value(sym) && val == yes) {
378 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); 438 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
439 struct property *prop;
440 struct expr *e;
379 441
380 cs->user.val = sym; 442 cs->user.val = sym;
381 cs->flags &= ~SYMBOL_NEW; 443 cs->flags &= ~SYMBOL_NEW;
444 prop = sym_get_choice_prop(cs);
445 for (e = prop->expr; e; e = e->left.expr) {
446 if (e->right.sym->visible != no)
447 e->right.sym->flags &= ~SYMBOL_NEW;
448 }
382 } 449 }
383 450
384 sym->user.tri = val; 451 sym->user.tri = val;
@@ -472,8 +539,8 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
472 if (!prop) 539 if (!prop)
473 return true; 540 return true;
474 val = strtol(str, NULL, 10); 541 val = strtol(str, NULL, 10);
475 return val >= strtol(prop->expr->left.sym->name, NULL, 10) && 542 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
476 val <= strtol(prop->expr->right.sym->name, NULL, 10); 543 val <= sym_get_range_val(prop->expr->right.sym, 10);
477 case S_HEX: 544 case S_HEX:
478 if (!sym_string_valid(sym, str)) 545 if (!sym_string_valid(sym, str))
479 return false; 546 return false;
@@ -481,8 +548,8 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
481 if (!prop) 548 if (!prop)
482 return true; 549 return true;
483 val = strtol(str, NULL, 16); 550 val = strtol(str, NULL, 16);
484 return val >= strtol(prop->expr->left.sym->name, NULL, 16) && 551 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
485 val <= strtol(prop->expr->right.sym->name, NULL, 16); 552 val <= sym_get_range_val(prop->expr->right.sym, 16);
486 case S_BOOLEAN: 553 case S_BOOLEAN:
487 case S_TRISTATE: 554 case S_TRISTATE:
488 switch (str[0]) { 555 switch (str[0]) {
@@ -725,12 +792,12 @@ struct symbol *sym_check_deps(struct symbol *sym)
725 struct symbol *sym2; 792 struct symbol *sym2;
726 struct property *prop; 793 struct property *prop;
727 794
728 if (sym->flags & SYMBOL_CHECK_DONE)
729 return NULL;
730 if (sym->flags & SYMBOL_CHECK) { 795 if (sym->flags & SYMBOL_CHECK) {
731 printf("Warning! Found recursive dependency: %s", sym->name); 796 printf("Warning! Found recursive dependency: %s", sym->name);
732 return sym; 797 return sym;
733 } 798 }
799 if (sym->flags & SYMBOL_CHECKED)
800 return NULL;
734 801
735 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); 802 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
736 sym2 = sym_check_expr_deps(sym->rev_dep.expr); 803 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
@@ -750,8 +817,13 @@ struct symbol *sym_check_deps(struct symbol *sym)
750 goto out; 817 goto out;
751 } 818 }
752out: 819out:
753 if (sym2) 820 if (sym2) {
754 printf(" %s", sym->name); 821 printf(" %s", sym->name);
822 if (sym2 == sym) {
823 printf("\n");
824 sym2 = NULL;
825 }
826 }
755 sym->flags &= ~SYMBOL_CHECK; 827 sym->flags &= ~SYMBOL_CHECK;
756 return sym2; 828 return sym2;
757} 829}
diff --git a/scripts/config/util.c b/scripts/kconfig/util.c
index dbf23edef..aea8d56ce 100644
--- a/scripts/config/util.c
+++ b/scripts/kconfig/util.c
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org>
4 * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org> 3 * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org>
@@ -34,8 +33,8 @@ int file_write_dep(const char *name)
34 FILE *out; 33 FILE *out;
35 34
36 if (!name) 35 if (!name)
37 name = ".config.cmd"; 36 name = ".kconfig.d";
38 out = fopen(".config.tmp", "w"); 37 out = fopen("..config.tmp", "w");
39 if (!out) 38 if (!out)
40 return 1; 39 return 1;
41 fprintf(out, "deps_config := \\\n"); 40 fprintf(out, "deps_config := \\\n");
@@ -45,9 +44,9 @@ int file_write_dep(const char *name)
45 else 44 else
46 fprintf(out, "\t%s\n", file->name); 45 fprintf(out, "\t%s\n", file->name);
47 } 46 }
48 fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); 47 fprintf(out, "\n.config include/autoconf.h: $(deps_config)\n\n$(deps_config):\n");
49 fclose(out); 48 fclose(out);
50 rename(".config.tmp", name); 49 rename("..config.tmp", name);
51 return 0; 50 return 0;
52} 51}
53 52
@@ -102,7 +101,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...)
102 va_end(ap); 101 va_end(ap);
103} 102}
104 103
105/* Retreive value of growable string */ 104/* Retrieve value of growable string */
106const char *str_get(struct gstr *gs) 105const char *str_get(struct gstr *gs)
107{ 106{
108 return gs->s; 107 return gs->s;
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
new file mode 100644
index 000000000..b03220600
--- /dev/null
+++ b/scripts/kconfig/zconf.gperf
@@ -0,0 +1,43 @@
1%language=ANSI-C
2%define hash-function-name kconf_id_hash
3%define lookup-function-name kconf_id_lookup
4%define string-pool-name kconf_id_strings
5%compare-strncmp
6%enum
7%pic
8%struct-type
9
10struct kconf_id;
11
12%%
13mainmenu, T_MAINMENU, TF_COMMAND
14menu, T_MENU, TF_COMMAND
15endmenu, T_ENDMENU, TF_COMMAND
16source, T_SOURCE, TF_COMMAND
17choice, T_CHOICE, TF_COMMAND
18endchoice, T_ENDCHOICE, TF_COMMAND
19comment, T_COMMENT, TF_COMMAND
20config, T_CONFIG, TF_COMMAND
21menuconfig, T_MENUCONFIG, TF_COMMAND
22help, T_HELP, TF_COMMAND
23if, T_IF, TF_COMMAND|TF_PARAM
24endif, T_ENDIF, TF_COMMAND
25depends, T_DEPENDS, TF_COMMAND
26requires, T_REQUIRES, TF_COMMAND
27optional, T_OPTIONAL, TF_COMMAND
28default, T_DEFAULT, TF_COMMAND, S_UNKNOWN
29prompt, T_PROMPT, TF_COMMAND
30tristate, T_TYPE, TF_COMMAND, S_TRISTATE
31def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE
32bool, T_TYPE, TF_COMMAND, S_BOOLEAN
33boolean, T_TYPE, TF_COMMAND, S_BOOLEAN
34def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN
35def_boolean, T_DEFAULT, TF_COMMAND, S_BOOLEAN
36int, T_TYPE, TF_COMMAND, S_INT
37hex, T_TYPE, TF_COMMAND, S_HEX
38string, T_TYPE, TF_COMMAND, S_STRING
39select, T_SELECT, TF_COMMAND
40enable, T_SELECT, TF_COMMAND
41range, T_RANGE, TF_COMMAND
42on, T_ON, TF_PARAM
43%%
diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped
new file mode 100644
index 000000000..345f0fc07
--- /dev/null
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -0,0 +1,231 @@
1/* ANSI-C code produced by gperf version 3.0.1 */
2/* Command-line: gperf */
3/* Computed positions: -k'1,3' */
4
5#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
6 && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
7 && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
8 && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
9 && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
10 && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
11 && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
12 && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
13 && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
14 && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
15 && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
16 && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
17 && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
18 && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
19 && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
20 && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
21 && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
22 && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
23 && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
24 && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
25 && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
26 && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
27 && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
28/* The character set is not based on ISO-646. */
29#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
30#endif
31
32struct kconf_id;
33/* maximum key range = 45, duplicates = 0 */
34
35#ifdef __GNUC__
36__inline
37#else
38#ifdef __cplusplus
39inline
40#endif
41#endif
42static unsigned int
43kconf_id_hash (register const char *str, register unsigned int len)
44{
45 static unsigned char asso_values[] =
46 {
47 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
48 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
49 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
50 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
51 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
52 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
53 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
54 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
55 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
56 47, 47, 47, 47, 47, 47, 47, 25, 10, 15,
57 0, 0, 5, 47, 0, 0, 47, 47, 0, 10,
58 0, 20, 20, 20, 5, 0, 0, 20, 47, 47,
59 20, 47, 47, 47, 47, 47, 47, 47, 47, 47,
60 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
61 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
62 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
63 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
64 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
65 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
66 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
67 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
68 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
69 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
70 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
71 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
72 47, 47, 47, 47, 47, 47
73 };
74 register int hval = len;
75
76 switch (hval)
77 {
78 default:
79 hval += asso_values[(unsigned char)str[2]];
80 /*FALLTHROUGH*/
81 case 2:
82 case 1:
83 hval += asso_values[(unsigned char)str[0]];
84 break;
85 }
86 return hval;
87}
88
89struct kconf_id_strings_t
90 {
91 char kconf_id_strings_str2[sizeof("if")];
92 char kconf_id_strings_str3[sizeof("int")];
93 char kconf_id_strings_str4[sizeof("help")];
94 char kconf_id_strings_str5[sizeof("endif")];
95 char kconf_id_strings_str6[sizeof("select")];
96 char kconf_id_strings_str7[sizeof("endmenu")];
97 char kconf_id_strings_str8[sizeof("tristate")];
98 char kconf_id_strings_str9[sizeof("endchoice")];
99 char kconf_id_strings_str10[sizeof("range")];
100 char kconf_id_strings_str11[sizeof("string")];
101 char kconf_id_strings_str12[sizeof("default")];
102 char kconf_id_strings_str13[sizeof("def_bool")];
103 char kconf_id_strings_str14[sizeof("menu")];
104 char kconf_id_strings_str16[sizeof("def_boolean")];
105 char kconf_id_strings_str17[sizeof("def_tristate")];
106 char kconf_id_strings_str18[sizeof("mainmenu")];
107 char kconf_id_strings_str20[sizeof("menuconfig")];
108 char kconf_id_strings_str21[sizeof("config")];
109 char kconf_id_strings_str22[sizeof("on")];
110 char kconf_id_strings_str23[sizeof("hex")];
111 char kconf_id_strings_str26[sizeof("source")];
112 char kconf_id_strings_str27[sizeof("depends")];
113 char kconf_id_strings_str28[sizeof("optional")];
114 char kconf_id_strings_str31[sizeof("enable")];
115 char kconf_id_strings_str32[sizeof("comment")];
116 char kconf_id_strings_str33[sizeof("requires")];
117 char kconf_id_strings_str34[sizeof("bool")];
118 char kconf_id_strings_str37[sizeof("boolean")];
119 char kconf_id_strings_str41[sizeof("choice")];
120 char kconf_id_strings_str46[sizeof("prompt")];
121 };
122static struct kconf_id_strings_t kconf_id_strings_contents =
123 {
124 "if",
125 "int",
126 "help",
127 "endif",
128 "select",
129 "endmenu",
130 "tristate",
131 "endchoice",
132 "range",
133 "string",
134 "default",
135 "def_bool",
136 "menu",
137 "def_boolean",
138 "def_tristate",
139 "mainmenu",
140 "menuconfig",
141 "config",
142 "on",
143 "hex",
144 "source",
145 "depends",
146 "optional",
147 "enable",
148 "comment",
149 "requires",
150 "bool",
151 "boolean",
152 "choice",
153 "prompt"
154 };
155#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
156#ifdef __GNUC__
157__inline
158#endif
159struct kconf_id *
160kconf_id_lookup (register const char *str, register unsigned int len)
161{
162 enum
163 {
164 TOTAL_KEYWORDS = 30,
165 MIN_WORD_LENGTH = 2,
166 MAX_WORD_LENGTH = 12,
167 MIN_HASH_VALUE = 2,
168 MAX_HASH_VALUE = 46
169 };
170
171 static struct kconf_id wordlist[] =
172 {
173 {-1}, {-1},
174 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM},
175 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT},
176 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str4, T_HELP, TF_COMMAND},
177 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND},
178 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_SELECT, TF_COMMAND},
179 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND},
180 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE},
181 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND},
182 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND},
183 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_TYPE, TF_COMMAND, S_STRING},
184 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
185 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
186 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_MENU, TF_COMMAND},
187 {-1},
188 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
189 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE},
190 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_MAINMENU, TF_COMMAND},
191 {-1},
192 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str20, T_MENUCONFIG, TF_COMMAND},
193 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_CONFIG, TF_COMMAND},
194 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ON, TF_PARAM},
195 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_HEX},
196 {-1}, {-1},
197 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SOURCE, TF_COMMAND},
198 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_DEPENDS, TF_COMMAND},
199 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_OPTIONAL, TF_COMMAND},
200 {-1}, {-1},
201 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND},
202 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
203 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_REQUIRES, TF_COMMAND},
204 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str34, T_TYPE, TF_COMMAND, S_BOOLEAN},
205 {-1}, {-1},
206 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_TYPE, TF_COMMAND, S_BOOLEAN},
207 {-1}, {-1}, {-1},
208 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_CHOICE, TF_COMMAND},
209 {-1}, {-1}, {-1}, {-1},
210 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_PROMPT, TF_COMMAND}
211 };
212
213 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
214 {
215 register int key = kconf_id_hash (str, len);
216
217 if (key <= MAX_HASH_VALUE && key >= 0)
218 {
219 register int o = wordlist[key].name;
220 if (o >= 0)
221 {
222 register const char *s = o + kconf_id_strings;
223
224 if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
225 return &wordlist[key];
226 }
227 }
228 }
229 return 0;
230}
231
diff --git a/scripts/config/zconf.l b/scripts/kconfig/zconf.l
index 55517b287..cfa46077c 100644
--- a/scripts/config/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -18,8 +18,12 @@
18 18
19#define START_STRSIZE 16 19#define START_STRSIZE 16
20 20
21char *text; 21static struct {
22static char *text_ptr; 22 struct file *file;
23 int lineno;
24} current_pos;
25
26static char *text;
23static int text_size, text_asize; 27static int text_size, text_asize;
24 28
25struct buffer { 29struct buffer {
@@ -32,29 +36,28 @@ struct buffer *current_buf;
32static int last_ts, first_ts; 36static int last_ts, first_ts;
33 37
34static void zconf_endhelp(void); 38static void zconf_endhelp(void);
35static struct buffer *zconf_endfile(void); 39static void zconf_endfile(void);
36 40
37void new_string(void) 41void new_string(void)
38{ 42{
39 text = malloc(START_STRSIZE); 43 text = malloc(START_STRSIZE);
40 text_asize = START_STRSIZE; 44 text_asize = START_STRSIZE;
41 text_ptr = text;
42 text_size = 0; 45 text_size = 0;
43 *text_ptr = 0; 46 *text = 0;
44} 47}
45 48
46void append_string(const char *str, int size) 49void append_string(const char *str, int size)
47{ 50{
48 int new_size = text_size + size + 1; 51 int new_size = text_size + size + 1;
49 if (new_size > text_asize) { 52 if (new_size > text_asize) {
53 new_size += START_STRSIZE - 1;
54 new_size &= -START_STRSIZE;
50 text = realloc(text, new_size); 55 text = realloc(text, new_size);
51 text_asize = new_size; 56 text_asize = new_size;
52 text_ptr = text + text_size;
53 } 57 }
54 memcpy(text_ptr, str, size); 58 memcpy(text + text_size, str, size);
55 text_ptr += size;
56 text_size += size; 59 text_size += size;
57 *text_ptr = 0; 60 text[text_size] = 0;
58} 61}
59 62
60void alloc_string(const char *str, int size) 63void alloc_string(const char *str, int size)
@@ -72,10 +75,13 @@ n [A-Za-z0-9_]
72 int str = 0; 75 int str = 0;
73 int ts, i; 76 int ts, i;
74 77
75[ \t]*#.*\n current_file->lineno++; 78[ \t]*#.*\n |
79[ \t]*\n {
80 current_file->lineno++;
81 return T_EOL;
82}
76[ \t]*#.* 83[ \t]*#.*
77 84
78[ \t]*\n current_file->lineno++; return T_EOL;
79 85
80[ \t]+ { 86[ \t]+ {
81 BEGIN(COMMAND); 87 BEGIN(COMMAND);
@@ -88,42 +94,25 @@ n [A-Za-z0-9_]
88 94
89 95
90<COMMAND>{ 96<COMMAND>{
91 "mainmenu" BEGIN(PARAM); return T_MAINMENU;
92 "menu" BEGIN(PARAM); return T_MENU;
93 "endmenu" BEGIN(PARAM); return T_ENDMENU;
94 "source" BEGIN(PARAM); return T_SOURCE;
95 "choice" BEGIN(PARAM); return T_CHOICE;
96 "endchoice" BEGIN(PARAM); return T_ENDCHOICE;
97 "comment" BEGIN(PARAM); return T_COMMENT;
98 "config" BEGIN(PARAM); return T_CONFIG;
99 "menuconfig" BEGIN(PARAM); return T_MENUCONFIG;
100 "help" BEGIN(PARAM); return T_HELP;
101 "if" BEGIN(PARAM); return T_IF;
102 "endif" BEGIN(PARAM); return T_ENDIF;
103 "depends" BEGIN(PARAM); return T_DEPENDS;
104 "requires" BEGIN(PARAM); return T_REQUIRES;
105 "optional" BEGIN(PARAM); return T_OPTIONAL;
106 "default" BEGIN(PARAM); return T_DEFAULT;
107 "prompt" BEGIN(PARAM); return T_PROMPT;
108 "tristate" BEGIN(PARAM); return T_TRISTATE;
109 "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE;
110 "bool" BEGIN(PARAM); return T_BOOLEAN;
111 "boolean" BEGIN(PARAM); return T_BOOLEAN;
112 "def_bool" BEGIN(PARAM); return T_DEF_BOOLEAN;
113 "def_boolean" BEGIN(PARAM); return T_DEF_BOOLEAN;
114 "int" BEGIN(PARAM); return T_INT;
115 "hex" BEGIN(PARAM); return T_HEX;
116 "string" BEGIN(PARAM); return T_STRING;
117 "select" BEGIN(PARAM); return T_SELECT;
118 "enable" BEGIN(PARAM); return T_SELECT;
119 "range" BEGIN(PARAM); return T_RANGE;
120 {n}+ { 97 {n}+ {
98 struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
99 BEGIN(PARAM);
100 current_pos.file = current_file;
101 current_pos.lineno = current_file->lineno;
102 if (id && id->flags & TF_COMMAND) {
103 zconflval.id = id;
104 return id->token;
105 }
121 alloc_string(yytext, yyleng); 106 alloc_string(yytext, yyleng);
122 zconflval.string = text; 107 zconflval.string = text;
123 return T_WORD; 108 return T_WORD;
124 } 109 }
125 . 110 .
126 \n current_file->lineno++; BEGIN(INITIAL); 111 \n {
112 BEGIN(INITIAL);
113 current_file->lineno++;
114 return T_EOL;
115 }
127} 116}
128 117
129<PARAM>{ 118<PARAM>{
@@ -134,8 +123,6 @@ n [A-Za-z0-9_]
134 "!" return T_NOT; 123 "!" return T_NOT;
135 "=" return T_EQUAL; 124 "=" return T_EQUAL;
136 "!=" return T_UNEQUAL; 125 "!=" return T_UNEQUAL;
137 "if" return T_IF;
138 "on" return T_ON;
139 \"|\' { 126 \"|\' {
140 str = yytext[0]; 127 str = yytext[0];
141 new_string(); 128 new_string();
@@ -144,6 +131,11 @@ n [A-Za-z0-9_]
144 \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; 131 \n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
145 --- /* ignore */ 132 --- /* ignore */
146 ({n}|[-/.])+ { 133 ({n}|[-/.])+ {
134 struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
135 if (id && id->flags & TF_PARAM) {
136 zconflval.id = id;
137 return id->token;
138 }
147 alloc_string(yytext, yyleng); 139 alloc_string(yytext, yyleng);
148 zconflval.string = text; 140 zconflval.string = text;
149 return T_WORD; 141 return T_WORD;
@@ -236,9 +228,9 @@ n [A-Za-z0-9_]
236} 228}
237 229
238<<EOF>> { 230<<EOF>> {
239 if (current_buf) { 231 if (current_file) {
240 zconf_endfile(); 232 zconf_endfile();
241 return T_EOF; 233 return T_EOL;
242 } 234 }
243 fclose(yyin); 235 fclose(yyin);
244 yyterminate(); 236 yyterminate();
@@ -329,7 +321,7 @@ void zconf_nextfile(const char *name)
329 current_file = file; 321 current_file = file;
330} 322}
331 323
332static struct buffer *zconf_endfile(void) 324static void zconf_endfile(void)
333{ 325{
334 struct buffer *parent; 326 struct buffer *parent;
335 327
@@ -345,22 +337,14 @@ static struct buffer *zconf_endfile(void)
345 } 337 }
346 free(current_buf); 338 free(current_buf);
347 current_buf = parent; 339 current_buf = parent;
348
349 return parent;
350} 340}
351 341
352int zconf_lineno(void) 342int zconf_lineno(void)
353{ 343{
354 if (current_buf) 344 return current_pos.lineno;
355 return current_file->lineno - 1;
356 else
357 return 0;
358} 345}
359 346
360char *zconf_curname(void) 347char *zconf_curname(void)
361{ 348{
362 if (current_buf) 349 return current_pos.file ? current_pos.file->name : "<none>";
363 return current_file->name;
364 else
365 return "<none>";
366} 350}
diff --git a/scripts/config/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 0bf511e30..ea7755da8 100644
--- a/scripts/config/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -1,7 +1,7 @@
1/* A Bison parser, made by GNU Bison 1.875a. */ 1/* A Bison parser, made by GNU Bison 2.0. */
2 2
3/* Skeleton parser for Yacc-like parsing with Bison, 3/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
@@ -45,8 +45,7 @@
45/* Using locations. */ 45/* Using locations. */
46#define YYLSP_NEEDED 0 46#define YYLSP_NEEDED 0
47 47
48/* If NAME_PREFIX is specified substitute the variables and functions 48/* Substitute the variable and function names. */
49 names. */
50#define yyparse zconfparse 49#define yyparse zconfparse
51#define yylex zconflex 50#define yylex zconflex
52#define yyerror zconferror 51#define yyerror zconferror
@@ -79,28 +78,21 @@
79 T_REQUIRES = 272, 78 T_REQUIRES = 272,
80 T_OPTIONAL = 273, 79 T_OPTIONAL = 273,
81 T_PROMPT = 274, 80 T_PROMPT = 274,
82 T_DEFAULT = 275, 81 T_TYPE = 275,
83 T_TRISTATE = 276, 82 T_DEFAULT = 276,
84 T_DEF_TRISTATE = 277, 83 T_SELECT = 277,
85 T_BOOLEAN = 278, 84 T_RANGE = 278,
86 T_DEF_BOOLEAN = 279, 85 T_ON = 279,
87 T_STRING = 280, 86 T_WORD = 280,
88 T_INT = 281, 87 T_WORD_QUOTE = 281,
89 T_HEX = 282, 88 T_UNEQUAL = 282,
90 T_WORD = 283, 89 T_CLOSE_PAREN = 283,
91 T_WORD_QUOTE = 284, 90 T_OPEN_PAREN = 284,
92 T_UNEQUAL = 285, 91 T_EOL = 285,
93 T_EOF = 286, 92 T_OR = 286,
94 T_EOL = 287, 93 T_AND = 287,
95 T_CLOSE_PAREN = 288, 94 T_EQUAL = 288,
96 T_OPEN_PAREN = 289, 95 T_NOT = 289
97 T_ON = 290,
98 T_SELECT = 291,
99 T_RANGE = 292,
100 T_OR = 293,
101 T_AND = 294,
102 T_EQUAL = 295,
103 T_NOT = 296
104 }; 96 };
105#endif 97#endif
106#define T_MAINMENU 258 98#define T_MAINMENU 258
@@ -120,28 +112,21 @@
120#define T_REQUIRES 272 112#define T_REQUIRES 272
121#define T_OPTIONAL 273 113#define T_OPTIONAL 273
122#define T_PROMPT 274 114#define T_PROMPT 274
123#define T_DEFAULT 275 115#define T_TYPE 275
124#define T_TRISTATE 276 116#define T_DEFAULT 276
125#define T_DEF_TRISTATE 277 117#define T_SELECT 277
126#define T_BOOLEAN 278 118#define T_RANGE 278
127#define T_DEF_BOOLEAN 279 119#define T_ON 279
128#define T_STRING 280 120#define T_WORD 280
129#define T_INT 281 121#define T_WORD_QUOTE 281
130#define T_HEX 282 122#define T_UNEQUAL 282
131#define T_WORD 283 123#define T_CLOSE_PAREN 283
132#define T_WORD_QUOTE 284 124#define T_OPEN_PAREN 284
133#define T_UNEQUAL 285 125#define T_EOL 285
134#define T_EOF 286 126#define T_OR 286
135#define T_EOL 287 127#define T_AND 287
136#define T_CLOSE_PAREN 288 128#define T_EQUAL 288
137#define T_OPEN_PAREN 289 129#define T_NOT 289
138#define T_ON 290
139#define T_SELECT 291
140#define T_RANGE 292
141#define T_OR 293
142#define T_AND 294
143#define T_EQUAL 295
144#define T_NOT 296
145 130
146 131
147 132
@@ -161,6 +146,11 @@
161#include <string.h> 146#include <string.h>
162#include <stdbool.h> 147#include <stdbool.h>
163 148
149#define LKC_DIRECT_LINK
150#include "lkc.h"
151
152#include "zconf.hash.c"
153
164#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) 154#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
165 155
166#define PRINTD 0x0001 156#define PRINTD 0x0001
@@ -170,14 +160,18 @@ int cdebug = PRINTD;
170 160
171extern int zconflex(void); 161extern int zconflex(void);
172static void zconfprint(const char *err, ...); 162static void zconfprint(const char *err, ...);
163static void zconf_error(const char *err, ...);
173static void zconferror(const char *err); 164static void zconferror(const char *err);
174static bool zconf_endtoken(int token, int starttoken, int endtoken); 165static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
175 166
176struct symbol *symbol_hash[257]; 167struct symbol *symbol_hash[257];
177 168
178static struct menu *current_menu, *current_entry; 169static struct menu *current_menu, *current_entry;
179 170
171#define YYDEBUG 0
172#if YYDEBUG
180#define YYERROR_VERBOSE 173#define YYERROR_VERBOSE
174#endif
181 175
182 176
183/* Enabling traces. */ 177/* Enabling traces. */
@@ -196,13 +190,14 @@ static struct menu *current_menu, *current_entry;
196#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) 190#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
197 191
198typedef union YYSTYPE { 192typedef union YYSTYPE {
199 int token;
200 char *string; 193 char *string;
194 struct file *file;
201 struct symbol *symbol; 195 struct symbol *symbol;
202 struct expr *expr; 196 struct expr *expr;
203 struct menu *menu; 197 struct menu *menu;
198 struct kconf_id *id;
204} YYSTYPE; 199} YYSTYPE;
205/* Line 191 of yacc.c. */ 200/* Line 190 of yacc.c. */
206 201
207# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 202# define yystype YYSTYPE /* obsolescent; will be withdrawn */
208# define YYSTYPE_IS_DECLARED 1 203# define YYSTYPE_IS_DECLARED 1
@@ -214,27 +209,26 @@ typedef union YYSTYPE {
214/* Copy the second part of user declarations. */ 209/* Copy the second part of user declarations. */
215 210
216 211
217#define LKC_DIRECT_LINK 212/* Line 213 of yacc.c. */
218#include "lkc.h"
219
220
221/* Line 214 of yacc.c. */
222 213
223 214
224#if ! defined (yyoverflow) || YYERROR_VERBOSE 215#if ! defined (yyoverflow) || YYERROR_VERBOSE
225 216
217# ifndef YYFREE
218# define YYFREE free
219# endif
220# ifndef YYMALLOC
221# define YYMALLOC malloc
222# endif
223
226/* The parser invokes alloca or malloc; define the necessary symbols. */ 224/* The parser invokes alloca or malloc; define the necessary symbols. */
227 225
228# if YYSTACK_USE_ALLOCA 226# ifdef YYSTACK_USE_ALLOCA
229# define YYSTACK_ALLOC alloca 227# if YYSTACK_USE_ALLOCA
230# else 228# ifdef __GNUC__
231# ifndef YYSTACK_USE_ALLOCA 229# define YYSTACK_ALLOC __builtin_alloca
232# if defined (alloca) || (defined (_ALLOCA_H) && defined (__GNUC__))
233# define YYSTACK_ALLOC alloca
234# else 230# else
235# ifdef __GNUC__ 231# define YYSTACK_ALLOC alloca
236# define YYSTACK_ALLOC __builtin_alloca
237# endif
238# endif 232# endif
239# endif 233# endif
240# endif 234# endif
@@ -247,20 +241,20 @@ typedef union YYSTYPE {
247# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 241# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
248# define YYSIZE_T size_t 242# define YYSIZE_T size_t
249# endif 243# endif
250# define YYSTACK_ALLOC malloc 244# define YYSTACK_ALLOC YYMALLOC
251# define YYSTACK_FREE free 245# define YYSTACK_FREE YYFREE
252# endif 246# endif
253#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ 247#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
254 248
255 249
256#if (! defined (yyoverflow) \ 250#if (! defined (yyoverflow) \
257 && (! defined (__cplusplus) \ 251 && (! defined (__cplusplus) \
258 || (YYSTYPE_IS_TRIVIAL))) 252 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
259 253
260/* A type that is properly aligned for any stack member. */ 254/* A type that is properly aligned for any stack member. */
261union yyalloc 255union yyalloc
262{ 256{
263 short yyss; 257 short int yyss;
264 YYSTYPE yyvs; 258 YYSTYPE yyvs;
265 }; 259 };
266 260
@@ -270,13 +264,13 @@ union yyalloc
270/* The size of an array large to enough to hold all stacks, each with 264/* The size of an array large to enough to hold all stacks, each with
271 N elements. */ 265 N elements. */
272# define YYSTACK_BYTES(N) \ 266# define YYSTACK_BYTES(N) \
273 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ 267 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
274 + YYSTACK_GAP_MAXIMUM) 268 + YYSTACK_GAP_MAXIMUM)
275 269
276/* Copy COUNT objects from FROM to TO. The source and destination do 270/* Copy COUNT objects from FROM to TO. The source and destination do
277 not overlap. */ 271 not overlap. */
278# ifndef YYCOPY 272# ifndef YYCOPY
279# if 1 < __GNUC__ 273# if defined (__GNUC__) && 1 < __GNUC__
280# define YYCOPY(To, From, Count) \ 274# define YYCOPY(To, From, Count) \
281 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 275 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
282# else 276# else
@@ -312,28 +306,28 @@ union yyalloc
312#if defined (__STDC__) || defined (__cplusplus) 306#if defined (__STDC__) || defined (__cplusplus)
313 typedef signed char yysigned_char; 307 typedef signed char yysigned_char;
314#else 308#else
315 typedef short yysigned_char; 309 typedef short int yysigned_char;
316#endif 310#endif
317 311
318/* YYFINAL -- State number of the termination state. */ 312/* YYFINAL -- State number of the termination state. */
319#define YYFINAL 2 313#define YYFINAL 3
320/* YYLAST -- Last index in YYTABLE. */ 314/* YYLAST -- Last index in YYTABLE. */
321#define YYLAST 201 315#define YYLAST 264
322 316
323/* YYNTOKENS -- Number of terminals. */ 317/* YYNTOKENS -- Number of terminals. */
324#define YYNTOKENS 42 318#define YYNTOKENS 35
325/* YYNNTS -- Number of nonterminals. */ 319/* YYNNTS -- Number of nonterminals. */
326#define YYNNTS 41 320#define YYNNTS 42
327/* YYNRULES -- Number of rules. */ 321/* YYNRULES -- Number of rules. */
328#define YYNRULES 104 322#define YYNRULES 104
329/* YYNRULES -- Number of states. */ 323/* YYNRULES -- Number of states. */
330#define YYNSTATES 182 324#define YYNSTATES 175
331 325
332/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 326/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
333#define YYUNDEFTOK 2 327#define YYUNDEFTOK 2
334#define YYMAXUTOK 296 328#define YYMAXUTOK 289
335 329
336#define YYTRANSLATE(YYX) \ 330#define YYTRANSLATE(YYX) \
337 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 331 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
338 332
339/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ 333/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
@@ -367,79 +361,78 @@ static const unsigned char yytranslate[] =
367 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 361 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
368 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 362 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
369 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 363 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
370 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 364 25, 26, 27, 28, 29, 30, 31, 32, 33, 34
371 35, 36, 37, 38, 39, 40, 41
372}; 365};
373 366
374#if YYDEBUG 367#if YYDEBUG
375/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 368/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
376 YYRHS. */ 369 YYRHS. */
377static const unsigned short yyprhs[] = 370static const unsigned short int yyprhs[] =
378{ 371{
379 0, 0, 3, 4, 7, 9, 11, 13, 17, 19, 372 0, 0, 3, 5, 6, 9, 12, 15, 20, 23,
380 21, 23, 26, 28, 30, 32, 34, 36, 38, 42, 373 28, 33, 37, 39, 41, 43, 45, 47, 49, 51,
381 45, 49, 52, 53, 56, 59, 62, 65, 69, 74, 374 53, 55, 57, 59, 61, 63, 67, 70, 74, 77,
382 78, 83, 87, 91, 95, 100, 105, 110, 116, 119, 375 81, 84, 85, 88, 91, 94, 97, 100, 104, 109,
383 122, 124, 128, 131, 132, 135, 138, 141, 144, 149, 376 114, 119, 125, 128, 131, 133, 137, 138, 141, 144,
384 153, 157, 160, 165, 166, 169, 173, 175, 179, 182, 377 147, 150, 153, 158, 162, 165, 170, 171, 174, 178,
385 183, 186, 189, 192, 196, 199, 201, 205, 208, 209, 378 180, 184, 185, 188, 191, 194, 198, 201, 203, 207,
386 212, 215, 218, 222, 226, 228, 232, 235, 238, 241, 379 208, 211, 214, 217, 221, 225, 228, 231, 234, 235,
387 242, 245, 248, 253, 257, 261, 262, 265, 267, 269, 380 238, 241, 244, 249, 253, 257, 258, 261, 263, 265,
388 272, 275, 278, 280, 282, 283, 286, 288, 292, 296, 381 268, 271, 274, 276, 279, 280, 283, 285, 289, 293,
389 300, 303, 307, 311, 313 382 297, 300, 304, 308, 310
390}; 383};
391 384
392/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 385/* YYRHS -- A `-1'-separated list of the rules' RHS. */
393static const yysigned_char yyrhs[] = 386static const yysigned_char yyrhs[] =
394{ 387{
395 43, 0, -1, -1, 43, 44, -1, 45, -1, 55, 388 36, 0, -1, 37, -1, -1, 37, 39, -1, 37,
396 -1, 66, -1, 3, 77, 79, -1, 5, -1, 15, 389 50, -1, 37, 61, -1, 37, 3, 71, 73, -1,
397 -1, 8, -1, 1, 79, -1, 61, -1, 71, -1, 390 37, 72, -1, 37, 25, 1, 30, -1, 37, 38,
398 47, -1, 49, -1, 69, -1, 79, -1, 10, 28, 391 1, 30, -1, 37, 1, 30, -1, 16, -1, 19,
399 32, -1, 46, 50, -1, 11, 28, 32, -1, 48, 392 -1, 20, -1, 22, -1, 18, -1, 23, -1, 21,
400 50, -1, -1, 50, 51, -1, 50, 75, -1, 50, 393 -1, 30, -1, 56, -1, 65, -1, 42, -1, 44,
401 73, -1, 50, 32, -1, 21, 76, 32, -1, 22, 394 -1, 63, -1, 25, 1, 30, -1, 1, 30, -1,
402 81, 80, 32, -1, 23, 76, 32, -1, 24, 81, 395 10, 25, 30, -1, 41, 45, -1, 11, 25, 30,
403 80, 32, -1, 26, 76, 32, -1, 27, 76, 32, 396 -1, 43, 45, -1, -1, 45, 46, -1, 45, 69,
404 -1, 25, 76, 32, -1, 19, 77, 80, 32, -1, 397 -1, 45, 67, -1, 45, 40, -1, 45, 30, -1,
405 20, 81, 80, 32, -1, 36, 28, 80, 32, -1, 398 20, 70, 30, -1, 19, 71, 74, 30, -1, 21,
406 37, 82, 82, 80, 32, -1, 7, 32, -1, 52, 399 75, 74, 30, -1, 22, 25, 74, 30, -1, 23,
407 56, -1, 78, -1, 53, 58, 54, -1, 53, 58, 400 76, 76, 74, 30, -1, 7, 30, -1, 47, 51,
408 -1, -1, 56, 57, -1, 56, 75, -1, 56, 73, 401 -1, 72, -1, 48, 53, 49, -1, -1, 51, 52,
409 -1, 56, 32, -1, 19, 77, 80, 32, -1, 21, 402 -1, 51, 69, -1, 51, 67, -1, 51, 30, -1,
410 76, 32, -1, 23, 76, 32, -1, 18, 32, -1, 403 51, 40, -1, 19, 71, 74, 30, -1, 20, 70,
411 20, 28, 80, 32, -1, -1, 58, 45, -1, 14, 404 30, -1, 18, 30, -1, 21, 25, 74, 30, -1,
412 81, 32, -1, 78, -1, 59, 62, 60, -1, 59, 405 -1, 53, 39, -1, 14, 75, 73, -1, 72, -1,
413 62, -1, -1, 62, 45, -1, 62, 66, -1, 62, 406 54, 57, 55, -1, -1, 57, 39, -1, 57, 61,
414 55, -1, 4, 77, 32, -1, 63, 74, -1, 78, 407 -1, 57, 50, -1, 4, 71, 30, -1, 58, 68,
415 -1, 64, 67, 65, -1, 64, 67, -1, -1, 67, 408 -1, 72, -1, 59, 62, 60, -1, -1, 62, 39,
416 45, -1, 67, 66, -1, 67, 55, -1, 67, 1, 409 -1, 62, 61, -1, 62, 50, -1, 6, 71, 30,
417 32, -1, 6, 77, 32, -1, 68, -1, 9, 77, 410 -1, 9, 71, 30, -1, 64, 68, -1, 12, 30,
418 32, -1, 70, 74, -1, 12, 32, -1, 72, 13, 411 -1, 66, 13, -1, -1, 68, 69, -1, 68, 30,
419 -1, -1, 74, 75, -1, 74, 32, -1, 16, 35, 412 -1, 68, 40, -1, 16, 24, 75, 30, -1, 16,
420 81, 32, -1, 16, 81, 32, -1, 17, 81, 32, 413 75, 30, -1, 17, 75, 30, -1, -1, 71, 74,
421 -1, -1, 77, 80, -1, 28, -1, 29, -1, 5, 414 -1, 25, -1, 26, -1, 5, 30, -1, 8, 30,
422 79, -1, 8, 79, -1, 15, 79, -1, 32, -1, 415 -1, 15, 30, -1, 30, -1, 73, 30, -1, -1,
423 31, -1, -1, 14, 81, -1, 82, -1, 82, 40, 416 14, 75, -1, 76, -1, 76, 33, 76, -1, 76,
424 82, -1, 82, 30, 82, -1, 34, 81, 33, -1, 417 27, 76, -1, 29, 75, 28, -1, 34, 75, -1,
425 41, 81, -1, 81, 38, 81, -1, 81, 39, 81, 418 75, 31, 75, -1, 75, 32, 75, -1, 25, -1,
426 -1, 28, -1, 29, -1 419 26, -1
427}; 420};
428 421
429/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 422/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
430static const unsigned short yyrline[] = 423static const unsigned short int yyrline[] =
431{ 424{
432 0, 94, 94, 95, 98, 99, 100, 101, 102, 103, 425 0, 103, 103, 105, 107, 108, 109, 110, 111, 112,
433 104, 105, 109, 110, 111, 112, 113, 114, 120, 128, 426 113, 117, 121, 121, 121, 121, 121, 121, 121, 125,
434 134, 142, 152, 154, 155, 156, 157, 160, 166, 173, 427 126, 127, 128, 129, 130, 134, 135, 141, 149, 155,
435 179, 186, 192, 198, 204, 210, 216, 222, 230, 239, 428 163, 173, 175, 176, 177, 178, 179, 182, 190, 196,
436 245, 254, 255, 261, 263, 264, 265, 266, 269, 275, 429 206, 212, 220, 229, 234, 242, 245, 247, 248, 249,
437 281, 287, 293, 299, 301, 306, 315, 324, 325, 331, 430 250, 251, 254, 260, 271, 277, 287, 289, 294, 302,
438 333, 334, 335, 340, 347, 353, 362, 363, 369, 371, 431 310, 313, 315, 316, 317, 322, 329, 334, 342, 345,
439 372, 373, 374, 377, 383, 390, 397, 404, 410, 417, 432 347, 348, 349, 352, 360, 367, 374, 380, 387, 389,
440 418, 419, 422, 427, 432, 440, 442, 447, 448, 451, 433 390, 391, 394, 399, 404, 412, 414, 419, 420, 423,
441 452, 453, 457, 457, 459, 460, 463, 464, 465, 466, 434 424, 425, 429, 430, 433, 434, 437, 438, 439, 440,
442 467, 468, 469, 472, 473 435 441, 442, 443, 446, 447
443}; 436};
444#endif 437#endif
445 438
@@ -451,64 +444,62 @@ static const char *const yytname[] =
451 "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", 444 "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU",
452 "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", 445 "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
453 "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", 446 "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
454 "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE", 447 "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT",
455 "T_DEF_TRISTATE", "T_BOOLEAN", "T_DEF_BOOLEAN", "T_STRING", "T_INT", 448 "T_SELECT", "T_RANGE", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL",
456 "T_HEX", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_EOF", "T_EOL", 449 "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL",
457 "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_SELECT", "T_RANGE", "T_OR", 450 "T_NOT", "$accept", "input", "stmt_list", "option_name", "common_stmt",
458 "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "block", 451 "option_error", "config_entry_start", "config_stmt",
459 "common_block", "config_entry_start", "config_stmt",
460 "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", 452 "menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
461 "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", 453 "config_option", "choice", "choice_entry", "choice_end", "choice_stmt",
462 "choice_option_list", "choice_option", "choice_block", "if", "if_end", 454 "choice_option_list", "choice_option", "choice_block", "if_entry",
463 "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", 455 "if_end", "if_stmt", "if_block", "menu", "menu_entry", "menu_end",
464 "menu_block", "source", "source_stmt", "comment", "comment_stmt", 456 "menu_stmt", "menu_block", "source_stmt", "comment", "comment_stmt",
465 "help_start", "help", "depends_list", "depends", "prompt_stmt_opt", 457 "help_start", "help", "depends_list", "depends", "prompt_stmt_opt",
466 "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0 458 "prompt", "end", "nl", "if_expr", "expr", "symbol", 0
467}; 459};
468#endif 460#endif
469 461
470# ifdef YYPRINT 462# ifdef YYPRINT
471/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to 463/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
472 token YYLEX-NUM. */ 464 token YYLEX-NUM. */
473static const unsigned short yytoknum[] = 465static const unsigned short int yytoknum[] =
474{ 466{
475 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 467 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
476 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 468 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
477 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 469 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
478 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 470 285, 286, 287, 288, 289
479 295, 296
480}; 471};
481# endif 472# endif
482 473
483/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 474/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
484static const unsigned char yyr1[] = 475static const unsigned char yyr1[] =
485{ 476{
486 0, 42, 43, 43, 44, 44, 44, 44, 44, 44, 477 0, 35, 36, 37, 37, 37, 37, 37, 37, 37,
487 44, 44, 45, 45, 45, 45, 45, 45, 46, 47, 478 37, 37, 38, 38, 38, 38, 38, 38, 38, 39,
488 48, 49, 50, 50, 50, 50, 50, 51, 51, 51, 479 39, 39, 39, 39, 39, 40, 40, 41, 42, 43,
489 51, 51, 51, 51, 51, 51, 51, 51, 52, 53, 480 44, 45, 45, 45, 45, 45, 45, 46, 46, 46,
490 54, 55, 55, 56, 56, 56, 56, 56, 57, 57, 481 46, 46, 47, 48, 49, 50, 51, 51, 51, 51,
491 57, 57, 57, 58, 58, 59, 60, 61, 61, 62, 482 51, 51, 52, 52, 52, 52, 53, 53, 54, 55,
492 62, 62, 62, 63, 64, 65, 66, 66, 67, 67, 483 56, 57, 57, 57, 57, 58, 59, 60, 61, 62,
493 67, 67, 67, 68, 69, 70, 71, 72, 73, 74, 484 62, 62, 62, 63, 64, 65, 66, 67, 68, 68,
494 74, 74, 75, 75, 75, 76, 76, 77, 77, 78, 485 68, 68, 69, 69, 69, 70, 70, 71, 71, 72,
495 78, 78, 79, 79, 80, 80, 81, 81, 81, 81, 486 72, 72, 73, 73, 74, 74, 75, 75, 75, 75,
496 81, 81, 81, 82, 82 487 75, 75, 75, 76, 76
497}; 488};
498 489
499/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 490/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
500static const unsigned char yyr2[] = 491static const unsigned char yyr2[] =
501{ 492{
502 0, 2, 0, 2, 1, 1, 1, 3, 1, 1, 493 0, 2, 1, 0, 2, 2, 2, 4, 2, 4,
503 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, 494 4, 3, 1, 1, 1, 1, 1, 1, 1, 1,
504 3, 2, 0, 2, 2, 2, 2, 3, 4, 3, 495 1, 1, 1, 1, 1, 3, 2, 3, 2, 3,
505 4, 3, 3, 3, 4, 4, 4, 5, 2, 2, 496 2, 0, 2, 2, 2, 2, 2, 3, 4, 4,
506 1, 3, 2, 0, 2, 2, 2, 2, 4, 3, 497 4, 5, 2, 2, 1, 3, 0, 2, 2, 2,
507 3, 2, 4, 0, 2, 3, 1, 3, 2, 0, 498 2, 2, 4, 3, 2, 4, 0, 2, 3, 1,
508 2, 2, 2, 3, 2, 1, 3, 2, 0, 2, 499 3, 0, 2, 2, 2, 3, 2, 1, 3, 0,
509 2, 2, 3, 3, 1, 3, 2, 2, 2, 0, 500 2, 2, 2, 3, 3, 2, 2, 2, 0, 2,
510 2, 2, 4, 3, 3, 0, 2, 1, 1, 2, 501 2, 2, 4, 3, 3, 0, 2, 1, 1, 2,
511 2, 2, 1, 1, 0, 2, 1, 3, 3, 3, 502 2, 2, 1, 2, 0, 2, 1, 3, 3, 3,
512 2, 3, 3, 1, 1 503 2, 3, 3, 1, 1
513}; 504};
514 505
@@ -517,151 +508,160 @@ static const unsigned char yyr2[] =
517 means the default is an error. */ 508 means the default is an error. */
518static const unsigned char yydefact[] = 509static const unsigned char yydefact[] =
519{ 510{
520 2, 0, 1, 0, 0, 0, 8, 0, 0, 10, 511 3, 0, 0, 1, 0, 0, 0, 0, 0, 0,
521 0, 0, 0, 0, 9, 93, 92, 3, 4, 22, 512 0, 0, 0, 0, 0, 0, 12, 16, 13, 14,
522 14, 22, 15, 43, 53, 5, 59, 12, 79, 68, 513 18, 15, 17, 0, 19, 0, 4, 31, 22, 31,
523 6, 74, 16, 79, 13, 17, 11, 87, 88, 0, 514 23, 46, 56, 5, 61, 20, 78, 69, 6, 24,
524 0, 0, 38, 0, 0, 0, 103, 104, 0, 0, 515 78, 21, 8, 11, 87, 88, 0, 0, 89, 0,
525 0, 96, 19, 21, 39, 42, 58, 64, 0, 76, 516 42, 90, 0, 0, 0, 103, 104, 0, 0, 0,
526 7, 63, 73, 75, 18, 20, 0, 100, 55, 0, 517 96, 91, 0, 0, 0, 0, 0, 0, 0, 0,
527 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, 518 0, 0, 92, 7, 65, 73, 74, 27, 29, 0,
528 85, 0, 85, 85, 85, 26, 0, 0, 23, 0, 519 100, 0, 0, 58, 0, 0, 9, 10, 0, 0,
529 25, 24, 0, 0, 0, 85, 85, 47, 44, 46, 520 0, 0, 0, 85, 0, 0, 0, 0, 36, 35,
530 45, 0, 0, 0, 54, 41, 40, 60, 62, 57, 521 32, 0, 34, 33, 0, 0, 85, 0, 50, 51,
531 61, 56, 81, 80, 0, 69, 71, 66, 70, 65, 522 47, 49, 48, 57, 45, 44, 62, 64, 60, 63,
532 99, 101, 102, 98, 97, 77, 0, 0, 0, 94, 523 59, 80, 81, 79, 70, 72, 68, 71, 67, 93,
533 94, 0, 94, 94, 0, 94, 0, 0, 0, 94, 524 99, 101, 102, 98, 97, 26, 76, 0, 0, 0,
534 0, 78, 51, 94, 94, 0, 0, 89, 90, 91, 525 94, 0, 94, 94, 94, 0, 0, 77, 54, 94,
535 72, 0, 83, 84, 0, 0, 0, 27, 86, 0, 526 0, 94, 0, 83, 84, 0, 0, 37, 86, 0,
536 29, 0, 33, 31, 32, 0, 94, 0, 0, 49, 527 0, 94, 25, 0, 53, 0, 82, 95, 38, 39,
537 50, 82, 95, 34, 35, 28, 30, 36, 0, 48, 528 40, 0, 52, 55, 41
538 52, 37
539}; 529};
540 530
541/* YYDEFGOTO[NTERM-NUM]. */ 531/* YYDEFGOTO[NTERM-NUM]. */
542static const short yydefgoto[] = 532static const short int yydefgoto[] =
543{ 533{
544 -1, 1, 17, 18, 19, 20, 21, 22, 52, 88, 534 -1, 1, 2, 25, 26, 99, 27, 28, 29, 30,
545 23, 24, 105, 25, 54, 98, 55, 26, 109, 27, 535 64, 100, 31, 32, 114, 33, 66, 110, 67, 34,
546 56, 28, 29, 117, 30, 58, 31, 32, 33, 34, 536 118, 35, 68, 36, 37, 126, 38, 70, 39, 40,
547 89, 90, 57, 91, 131, 132, 106, 35, 155, 50, 537 41, 101, 102, 69, 103, 141, 142, 42, 73, 156,
548 51 538 59, 60
549}; 539};
550 540
551/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 541/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
552 STATE-NUM. */ 542 STATE-NUM. */
553#define YYPACT_NINF -99 543#define YYPACT_NINF -78
554static const short yypact[] = 544static const short int yypact[] =
555{ 545{
556 -99, 48, -99, 38, 46, 46, -99, 46, -29, -99, 546 -78, 2, 159, -78, -21, 0, 0, -12, 0, 1,
557 46, -17, -3, -11, -99, -99, -99, -99, -99, -99, 547 4, 0, 27, 38, 60, 58, -78, -78, -78, -78,
558 -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, 548 -78, -78, -78, 100, -78, 104, -78, -78, -78, -78,
559 -99, -99, -99, -99, -99, -99, -99, -99, -99, 38, 549 -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
560 12, 15, -99, 18, 51, 62, -99, -99, -11, -11, 550 -78, -78, -78, -78, -78, -78, 86, 113, -78, 114,
561 4, -24, 138, 138, 160, 121, 110, -4, 81, -4, 551 -78, -78, 125, 127, 128, -78, -78, 60, 60, 210,
562 -99, -99, -99, -99, -99, -99, -19, -99, -99, -11, 552 65, -78, 141, 142, 39, 103, 182, 200, 6, 66,
563 -11, 70, 70, 73, 32, -11, 46, -11, 46, -11, 553 6, 131, -78, 146, -78, -78, -78, -78, -78, 196,
564 46, -11, 46, 46, 46, -99, 36, 70, -99, 95, 554 -78, 60, 60, 146, 40, 40, -78, -78, 155, 156,
565 -99, -99, 96, 46, 106, 46, 46, -99, -99, -99, 555 -2, 60, 0, 0, 60, 105, 40, 194, -78, -78,
566 -99, 38, 38, 38, -99, -99, -99, -99, -99, -99, 556 -78, 206, -78, -78, 183, 0, 0, 195, -78, -78,
567 -99, -99, -99, -99, 112, -99, -99, -99, -99, -99, 557 -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
568 -99, 117, -99, -99, -99, -99, -11, 33, 65, 131, 558 -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
569 1, 119, 131, 1, 136, 1, 153, 154, 155, 131, 559 -78, 197, -78, -78, -78, -78, -78, 60, 213, 216,
570 70, -99, -99, 131, 131, 156, 157, -99, -99, -99, 560 212, 203, 212, 190, 212, 40, 208, -78, -78, 212,
571 -99, 101, -99, -99, -11, 158, 159, -99, -99, 161, 561 222, 212, 219, -78, -78, 60, 223, -78, -78, 224,
572 -99, 162, -99, -99, -99, 163, 131, 164, 165, -99, 562 225, 212, -78, 226, -78, 227, -78, 47, -78, -78,
573 -99, -99, 99, -99, -99, -99, -99, -99, 166, -99, 563 -78, 228, -78, -78, -78
574 -99, -99
575}; 564};
576 565
577/* YYPGOTO[NTERM-NUM]. */ 566/* YYPGOTO[NTERM-NUM]. */
578static const short yypgoto[] = 567static const short int yypgoto[] =
579{ 568{
580 -99, -99, -99, 111, -99, -99, -99, -99, 178, -99, 569 -78, -78, -78, -78, 164, -36, -78, -78, -78, -78,
581 -99, -99, -99, 91, -99, -99, -99, -99, -99, -99, 570 230, -78, -78, -78, -78, 29, -78, -78, -78, -78,
582 -99, -99, -99, -99, 115, -99, -99, -99, -99, -99, 571 -78, -78, -78, -78, -78, -78, 59, -78, -78, -78,
583 -99, 146, 168, 89, 27, 0, 126, -1, -98, -48, 572 -78, -78, 198, 220, 24, 157, -5, 169, 202, 74,
584 -63 573 -53, -77
585}; 574};
586 575
587/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 576/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
588 positive, shift that token. If negative, reduce the rule which 577 positive, shift that token. If negative, reduce the rule which
589 number is the opposite. If zero, do what YYDEFACT says. 578 number is the opposite. If zero, do what YYDEFACT says.
590 If YYTABLE_NINF, syntax error. */ 579 If YYTABLE_NINF, syntax error. */
591#define YYTABLE_NINF -68 580#define YYTABLE_NINF -76
592static const short yytable[] = 581static const short int yytable[] =
593{ 582{
594 66, 67, 36, 42, 39, 40, 71, 41, 123, 124, 583 46, 47, 3, 49, 79, 80, 52, 133, 134, 43,
595 43, 44, 74, 75, 120, 154, 72, 46, 47, 69, 584 6, 7, 8, 9, 10, 11, 12, 13, 48, 145,
596 70, 121, 122, 48, 140, 45, 127, 128, 112, 130, 585 14, 15, 137, 55, 56, 44, 45, 57, 131, 132,
597 49, 133, 156, 135, 158, 159, 68, 161, 60, 69, 586 109, 50, 58, 122, 51, 122, 24, 138, 139, -28,
598 70, 165, 69, 70, 61, 167, 168, 62, 2, 3, 587 88, 143, -28, -28, -28, -28, -28, -28, -28, -28,
599 63, 4, 5, 6, 7, 8, 9, 10, 11, 12, 588 -28, 89, 53, -28, -28, 90, 91, -28, 92, 93,
600 46, 47, 13, 14, 139, 152, 48, 126, 178, 15, 589 94, 95, 96, 54, 97, 55, 56, 88, 161, 98,
601 16, 69, 70, 49, 37, 38, 129, 166, 151, 15, 590 -66, -66, -66, -66, -66, -66, -66, -66, 81, 82,
602 16, -67, 114, 64, -67, 5, 101, 7, 8, 102, 591 -66, -66, 90, 91, 152, 55, 56, 140, 61, 57,
603 10, 11, 12, 143, 65, 13, 103, 153, 46, 47, 592 112, 97, 84, 123, 58, 123, 121, 117, 85, 125,
604 147, 148, 149, 69, 70, 125, 172, 134, 141, 136, 593 149, 62, 167, -30, 88, 63, -30, -30, -30, -30,
605 137, 138, 15, 16, 5, 101, 7, 8, 102, 10, 594 -30, -30, -30, -30, -30, 89, 72, -30, -30, 90,
606 11, 12, 145, 146, 13, 103, 101, 7, 142, 102, 595 91, -30, 92, 93, 94, 95, 96, 119, 97, 127,
607 10, 11, 12, 171, 144, 13, 103, 69, 70, 69, 596 144, -75, 88, 98, -75, -75, -75, -75, -75, -75,
608 70, 15, 16, 100, 150, 154, 113, 108, 113, 116, 597 -75, -75, -75, 74, 75, -75, -75, 90, 91, -75,
609 73, 157, 15, 16, 74, 75, 70, 76, 77, 78, 598 -75, -75, -75, -75, -75, 76, 97, 77, 78, -2,
610 79, 80, 81, 82, 83, 84, 104, 107, 160, 115, 599 4, 121, 5, 6, 7, 8, 9, 10, 11, 12,
611 85, 110, 73, 118, 86, 87, 74, 75, 92, 93, 600 13, 86, 87, 14, 15, 16, 129, 17, 18, 19,
612 94, 95, 111, 96, 119, 162, 163, 164, 169, 170, 601 20, 21, 22, 88, 23, 135, 136, -43, -43, 24,
613 173, 174, 97, 175, 176, 177, 179, 180, 181, 53, 602 -43, -43, -43, -43, 89, 146, -43, -43, 90, 91,
614 99, 59 603 104, 105, 106, 107, 155, 7, 8, 97, 10, 11,
604 12, 13, 108, 148, 14, 15, 158, 159, 160, 147,
605 151, 81, 82, 163, 130, 165, 155, 81, 82, 82,
606 24, 113, 116, 157, 124, 171, 115, 120, 162, 128,
607 72, 81, 82, 153, 81, 82, 154, 81, 82, 166,
608 81, 82, 164, 168, 169, 170, 172, 173, 174, 65,
609 71, 83, 0, 150, 111
615}; 610};
616 611
617static const unsigned char yycheck[] = 612static const short int yycheck[] =
618{ 613{
619 48, 49, 3, 32, 4, 5, 30, 7, 71, 72, 614 5, 6, 0, 8, 57, 58, 11, 84, 85, 30,
620 10, 28, 16, 17, 33, 14, 40, 28, 29, 38, 615 4, 5, 6, 7, 8, 9, 10, 11, 30, 96,
621 39, 69, 70, 34, 87, 28, 74, 75, 32, 77, 616 14, 15, 24, 25, 26, 25, 26, 29, 81, 82,
622 41, 79, 130, 81, 132, 133, 32, 135, 39, 38, 617 66, 30, 34, 69, 30, 71, 30, 90, 91, 0,
623 39, 139, 38, 39, 32, 143, 144, 32, 0, 1, 618 1, 94, 3, 4, 5, 6, 7, 8, 9, 10,
624 32, 3, 4, 5, 6, 7, 8, 9, 10, 11, 619 11, 12, 25, 14, 15, 16, 17, 18, 19, 20,
625 28, 29, 14, 15, 28, 32, 34, 35, 166, 31, 620 21, 22, 23, 25, 25, 25, 26, 1, 145, 30,
626 32, 38, 39, 41, 28, 29, 76, 140, 126, 31, 621 4, 5, 6, 7, 8, 9, 10, 11, 31, 32,
627 32, 0, 1, 32, 3, 4, 5, 6, 7, 8, 622 14, 15, 16, 17, 137, 25, 26, 92, 30, 29,
628 9, 10, 11, 93, 32, 14, 15, 32, 28, 29, 623 66, 25, 27, 69, 34, 71, 30, 68, 33, 70,
629 101, 102, 103, 38, 39, 32, 154, 80, 13, 82, 624 105, 1, 155, 0, 1, 1, 3, 4, 5, 6,
630 83, 84, 31, 32, 4, 5, 6, 7, 8, 9, 625 7, 8, 9, 10, 11, 12, 30, 14, 15, 16,
631 10, 11, 95, 96, 14, 15, 5, 6, 32, 8, 626 17, 18, 19, 20, 21, 22, 23, 68, 25, 70,
632 9, 10, 11, 32, 28, 14, 15, 38, 39, 38, 627 25, 0, 1, 30, 3, 4, 5, 6, 7, 8,
633 39, 31, 32, 54, 32, 14, 57, 56, 59, 58, 628 9, 10, 11, 30, 30, 14, 15, 16, 17, 18,
634 12, 32, 31, 32, 16, 17, 39, 19, 20, 21, 629 19, 20, 21, 22, 23, 30, 25, 30, 30, 0,
635 22, 23, 24, 25, 26, 27, 55, 56, 32, 58, 630 1, 30, 3, 4, 5, 6, 7, 8, 9, 10,
636 32, 56, 12, 58, 36, 37, 16, 17, 18, 19, 631 11, 30, 30, 14, 15, 16, 30, 18, 19, 20,
637 20, 21, 56, 23, 58, 32, 32, 32, 32, 32, 632 21, 22, 23, 1, 25, 30, 30, 5, 6, 30,
638 32, 32, 32, 32, 32, 32, 32, 32, 32, 21, 633 8, 9, 10, 11, 12, 1, 14, 15, 16, 17,
639 54, 33 634 18, 19, 20, 21, 14, 5, 6, 25, 8, 9,
635 10, 11, 30, 30, 14, 15, 142, 143, 144, 13,
636 25, 31, 32, 149, 28, 151, 14, 31, 32, 32,
637 30, 67, 68, 30, 70, 161, 67, 68, 30, 70,
638 30, 31, 32, 30, 31, 32, 30, 31, 32, 30,
639 31, 32, 30, 30, 30, 30, 30, 30, 30, 29,
640 40, 59, -1, 106, 66
640}; 641};
641 642
642/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 643/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
643 symbol of state STATE-NUM. */ 644 symbol of state STATE-NUM. */
644static const unsigned char yystos[] = 645static const unsigned char yystos[] =
645{ 646{
646 0, 43, 0, 1, 3, 4, 5, 6, 7, 8, 647 0, 36, 37, 0, 1, 3, 4, 5, 6, 7,
647 9, 10, 11, 14, 15, 31, 32, 44, 45, 46, 648 8, 9, 10, 11, 14, 15, 16, 18, 19, 20,
648 47, 48, 49, 52, 53, 55, 59, 61, 63, 64, 649 21, 22, 23, 25, 30, 38, 39, 41, 42, 43,
649 66, 68, 69, 70, 71, 79, 79, 28, 29, 77, 650 44, 47, 48, 50, 54, 56, 58, 59, 61, 63,
650 77, 77, 32, 77, 28, 28, 28, 29, 34, 41, 651 64, 65, 72, 30, 25, 26, 71, 71, 30, 71,
651 81, 82, 50, 50, 56, 58, 62, 74, 67, 74, 652 30, 30, 71, 25, 25, 25, 26, 29, 34, 75,
652 79, 32, 32, 32, 32, 32, 81, 81, 32, 38, 653 76, 30, 1, 1, 45, 45, 51, 53, 57, 68,
653 39, 30, 40, 12, 16, 17, 19, 20, 21, 22, 654 62, 68, 30, 73, 30, 30, 30, 30, 30, 75,
654 23, 24, 25, 26, 27, 32, 36, 37, 51, 72, 655 75, 31, 32, 73, 27, 33, 30, 30, 1, 12,
655 73, 75, 18, 19, 20, 21, 23, 32, 57, 73, 656 16, 17, 19, 20, 21, 22, 23, 25, 30, 40,
656 75, 5, 8, 15, 45, 54, 78, 45, 55, 60, 657 46, 66, 67, 69, 18, 19, 20, 21, 30, 40,
657 66, 78, 32, 75, 1, 45, 55, 65, 66, 78, 658 52, 67, 69, 39, 49, 72, 39, 50, 55, 61,
658 33, 81, 81, 82, 82, 32, 35, 81, 81, 77, 659 72, 30, 40, 69, 39, 50, 60, 61, 72, 30,
659 81, 76, 77, 81, 76, 81, 76, 76, 76, 28, 660 28, 75, 75, 76, 76, 30, 30, 24, 75, 75,
660 82, 13, 32, 77, 28, 76, 76, 79, 79, 79, 661 71, 70, 71, 75, 25, 76, 1, 13, 30, 71,
661 32, 81, 32, 32, 14, 80, 80, 32, 80, 80, 662 70, 25, 75, 30, 30, 14, 74, 30, 74, 74,
662 32, 80, 32, 32, 32, 80, 82, 80, 80, 32, 663 74, 76, 30, 74, 30, 74, 30, 75, 30, 30,
663 32, 32, 81, 32, 32, 32, 32, 32, 80, 32, 664 30, 74, 30, 30, 30
664 32, 32
665}; 665};
666 666
667#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 667#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
@@ -687,7 +687,7 @@ static const unsigned char yystos[] =
687 687
688#define YYACCEPT goto yyacceptlab 688#define YYACCEPT goto yyacceptlab
689#define YYABORT goto yyabortlab 689#define YYABORT goto yyabortlab
690#define YYERROR goto yyerrlab1 690#define YYERROR goto yyerrorlab
691 691
692 692
693/* Like YYERROR except do call yyerror. This remains here temporarily 693/* Like YYERROR except do call yyerror. This remains here temporarily
@@ -709,26 +709,59 @@ do \
709 goto yybackup; \ 709 goto yybackup; \
710 } \ 710 } \
711 else \ 711 else \
712 { \ 712 { \
713 yyerror ("syntax error: cannot back up");\ 713 yyerror ("syntax error: cannot back up");\
714 YYERROR; \ 714 YYERROR; \
715 } \ 715 } \
716while (0) 716while (0)
717 717
718
718#define YYTERROR 1 719#define YYTERROR 1
719#define YYERRCODE 256 720#define YYERRCODE 256
720 721
721/* YYLLOC_DEFAULT -- Compute the default location (before the actions
722 are run). */
723 722
723/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
724 If N is 0, then set CURRENT to the empty location which ends
725 the previous symbol: RHS[0] (always defined). */
726
727#define YYRHSLOC(Rhs, K) ((Rhs)[K])
724#ifndef YYLLOC_DEFAULT 728#ifndef YYLLOC_DEFAULT
725# define YYLLOC_DEFAULT(Current, Rhs, N) \ 729# define YYLLOC_DEFAULT(Current, Rhs, N) \
726 Current.first_line = Rhs[1].first_line; \ 730 do \
727 Current.first_column = Rhs[1].first_column; \ 731 if (N) \
728 Current.last_line = Rhs[N].last_line; \ 732 { \
729 Current.last_column = Rhs[N].last_column; 733 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
734 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
735 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
736 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
737 } \
738 else \
739 { \
740 (Current).first_line = (Current).last_line = \
741 YYRHSLOC (Rhs, 0).last_line; \
742 (Current).first_column = (Current).last_column = \
743 YYRHSLOC (Rhs, 0).last_column; \
744 } \
745 while (0)
730#endif 746#endif
731 747
748
749/* YY_LOCATION_PRINT -- Print the location on the stream.
750 This macro was not mandated originally: define only if we know
751 we won't break user code: when these are the locations we know. */
752
753#ifndef YY_LOCATION_PRINT
754# if YYLTYPE_IS_TRIVIAL
755# define YY_LOCATION_PRINT(File, Loc) \
756 fprintf (File, "%d.%d-%d.%d", \
757 (Loc).first_line, (Loc).first_column, \
758 (Loc).last_line, (Loc).last_column)
759# else
760# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
761# endif
762#endif
763
764
732/* YYLEX -- calling `yylex' with the right arguments. */ 765/* YYLEX -- calling `yylex' with the right arguments. */
733 766
734#ifdef YYLEX_PARAM 767#ifdef YYLEX_PARAM
@@ -751,36 +784,30 @@ do { \
751 YYFPRINTF Args; \ 784 YYFPRINTF Args; \
752} while (0) 785} while (0)
753 786
754# define YYDSYMPRINT(Args) \ 787# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
755do { \
756 if (yydebug) \
757 yysymprint Args; \
758} while (0)
759
760# define YYDSYMPRINTF(Title, Token, Value, Location) \
761do { \ 788do { \
762 if (yydebug) \ 789 if (yydebug) \
763 { \ 790 { \
764 YYFPRINTF (stderr, "%s ", Title); \ 791 YYFPRINTF (stderr, "%s ", Title); \
765 yysymprint (stderr, \ 792 yysymprint (stderr, \
766 Token, Value); \ 793 Type, Value); \
767 YYFPRINTF (stderr, "\n"); \ 794 YYFPRINTF (stderr, "\n"); \
768 } \ 795 } \
769} while (0) 796} while (0)
770 797
771/*------------------------------------------------------------------. 798/*------------------------------------------------------------------.
772| yy_stack_print -- Print the state stack from its BOTTOM up to its | 799| yy_stack_print -- Print the state stack from its BOTTOM up to its |
773| TOP (cinluded). | 800| TOP (included). |
774`------------------------------------------------------------------*/ 801`------------------------------------------------------------------*/
775 802
776#if defined (__STDC__) || defined (__cplusplus) 803#if defined (__STDC__) || defined (__cplusplus)
777static void 804static void
778yy_stack_print (short *bottom, short *top) 805yy_stack_print (short int *bottom, short int *top)
779#else 806#else
780static void 807static void
781yy_stack_print (bottom, top) 808yy_stack_print (bottom, top)
782 short *bottom; 809 short int *bottom;
783 short *top; 810 short int *top;
784#endif 811#endif
785{ 812{
786 YYFPRINTF (stderr, "Stack now"); 813 YYFPRINTF (stderr, "Stack now");
@@ -810,9 +837,9 @@ yy_reduce_print (yyrule)
810#endif 837#endif
811{ 838{
812 int yyi; 839 int yyi;
813 unsigned int yylineno = yyrline[yyrule]; 840 unsigned int yylno = yyrline[yyrule];
814 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", 841 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
815 yyrule - 1, yylineno); 842 yyrule - 1, yylno);
816 /* Print the symbols being reduced, and their result. */ 843 /* Print the symbols being reduced, and their result. */
817 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) 844 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
818 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); 845 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
@@ -830,8 +857,7 @@ do { \
830int yydebug; 857int yydebug;
831#else /* !YYDEBUG */ 858#else /* !YYDEBUG */
832# define YYDPRINTF(Args) 859# define YYDPRINTF(Args)
833# define YYDSYMPRINT(Args) 860# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
834# define YYDSYMPRINTF(Title, Token, Value, Location)
835# define YY_STACK_PRINT(Bottom, Top) 861# define YY_STACK_PRINT(Bottom, Top)
836# define YY_REDUCE_PRINT(Rule) 862# define YY_REDUCE_PRINT(Rule)
837#endif /* !YYDEBUG */ 863#endif /* !YYDEBUG */
@@ -849,10 +875,6 @@ int yydebug;
849 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) 875 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
850 evaluated with infinite-precision integer arithmetic. */ 876 evaluated with infinite-precision integer arithmetic. */
851 877
852#if YYMAXDEPTH == 0
853# undef YYMAXDEPTH
854#endif
855
856#ifndef YYMAXDEPTH 878#ifndef YYMAXDEPTH
857# define YYMAXDEPTH 10000 879# define YYMAXDEPTH 10000
858#endif 880#endif
@@ -934,15 +956,15 @@ yysymprint (yyoutput, yytype, yyvaluep)
934 (void) yyvaluep; 956 (void) yyvaluep;
935 957
936 if (yytype < YYNTOKENS) 958 if (yytype < YYNTOKENS)
937 { 959 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
938 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
939# ifdef YYPRINT
940 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
941# endif
942 }
943 else 960 else
944 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 961 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
945 962
963
964# ifdef YYPRINT
965 if (yytype < YYNTOKENS)
966 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
967# endif
946 switch (yytype) 968 switch (yytype)
947 { 969 {
948 default: 970 default:
@@ -958,10 +980,11 @@ yysymprint (yyoutput, yytype, yyvaluep)
958 980
959#if defined (__STDC__) || defined (__cplusplus) 981#if defined (__STDC__) || defined (__cplusplus)
960static void 982static void
961yydestruct (int yytype, YYSTYPE *yyvaluep) 983yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
962#else 984#else
963static void 985static void
964yydestruct (yytype, yyvaluep) 986yydestruct (yymsg, yytype, yyvaluep)
987 const char *yymsg;
965 int yytype; 988 int yytype;
966 YYSTYPE *yyvaluep; 989 YYSTYPE *yyvaluep;
967#endif 990#endif
@@ -969,8 +992,42 @@ yydestruct (yytype, yyvaluep)
969 /* Pacify ``unused variable'' warnings. */ 992 /* Pacify ``unused variable'' warnings. */
970 (void) yyvaluep; 993 (void) yyvaluep;
971 994
995 if (!yymsg)
996 yymsg = "Deleting";
997 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
998
972 switch (yytype) 999 switch (yytype)
973 { 1000 {
1001 case 48: /* choice_entry */
1002
1003 {
1004 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
1005 (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno);
1006 if (current_menu == (yyvaluep->menu))
1007 menu_end_menu();
1008};
1009
1010 break;
1011 case 54: /* if_entry */
1012
1013 {
1014 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
1015 (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno);
1016 if (current_menu == (yyvaluep->menu))
1017 menu_end_menu();
1018};
1019
1020 break;
1021 case 59: /* menu_entry */
1022
1023 {
1024 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
1025 (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno);
1026 if (current_menu == (yyvaluep->menu))
1027 menu_end_menu();
1028};
1029
1030 break;
974 1031
975 default: 1032 default:
976 break; 1033 break;
@@ -996,10 +1053,10 @@ int yyparse ();
996 1053
997 1054
998 1055
999/* The lookahead symbol. */ 1056/* The look-ahead symbol. */
1000int yychar; 1057int yychar;
1001 1058
1002/* The semantic value of the lookahead symbol. */ 1059/* The semantic value of the look-ahead symbol. */
1003YYSTYPE yylval; 1060YYSTYPE yylval;
1004 1061
1005/* Number of syntax errors so far. */ 1062/* Number of syntax errors so far. */
@@ -1029,13 +1086,13 @@ yyparse ()
1029#endif 1086#endif
1030#endif 1087#endif
1031{ 1088{
1032 1089
1033 register int yystate; 1090 register int yystate;
1034 register int yyn; 1091 register int yyn;
1035 int yyresult; 1092 int yyresult;
1036 /* Number of tokens to shift before error messages enabled. */ 1093 /* Number of tokens to shift before error messages enabled. */
1037 int yyerrstatus; 1094 int yyerrstatus;
1038 /* Lookahead token as an internal (translated) token number. */ 1095 /* Look-ahead token as an internal (translated) token number. */
1039 int yytoken = 0; 1096 int yytoken = 0;
1040 1097
1041 /* Three stacks and their tools: 1098 /* Three stacks and their tools:
@@ -1047,9 +1104,9 @@ yyparse ()
1047 to reallocate them elsewhere. */ 1104 to reallocate them elsewhere. */
1048 1105
1049 /* The state stack. */ 1106 /* The state stack. */
1050 short yyssa[YYINITDEPTH]; 1107 short int yyssa[YYINITDEPTH];
1051 short *yyss = yyssa; 1108 short int *yyss = yyssa;
1052 register short *yyssp; 1109 register short int *yyssp;
1053 1110
1054 /* The semantic value stack. */ 1111 /* The semantic value stack. */
1055 YYSTYPE yyvsa[YYINITDEPTH]; 1112 YYSTYPE yyvsa[YYINITDEPTH];
@@ -1086,6 +1143,9 @@ yyparse ()
1086 yyssp = yyss; 1143 yyssp = yyss;
1087 yyvsp = yyvs; 1144 yyvsp = yyvs;
1088 1145
1146
1147 yyvsp[0] = yylval;
1148
1089 goto yysetstate; 1149 goto yysetstate;
1090 1150
1091/*------------------------------------------------------------. 1151/*------------------------------------------------------------.
@@ -1111,7 +1171,7 @@ yyparse ()
1111 these so that the &'s don't force the real ones into 1171 these so that the &'s don't force the real ones into
1112 memory. */ 1172 memory. */
1113 YYSTYPE *yyvs1 = yyvs; 1173 YYSTYPE *yyvs1 = yyvs;
1114 short *yyss1 = yyss; 1174 short int *yyss1 = yyss;
1115 1175
1116 1176
1117 /* Each stack pointer address is followed by the size of the 1177 /* Each stack pointer address is followed by the size of the
@@ -1139,7 +1199,7 @@ yyparse ()
1139 yystacksize = YYMAXDEPTH; 1199 yystacksize = YYMAXDEPTH;
1140 1200
1141 { 1201 {
1142 short *yyss1 = yyss; 1202 short int *yyss1 = yyss;
1143 union yyalloc *yyptr = 1203 union yyalloc *yyptr =
1144 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1204 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1145 if (! yyptr) 1205 if (! yyptr)
@@ -1175,18 +1235,18 @@ yyparse ()
1175yybackup: 1235yybackup:
1176 1236
1177/* Do appropriate processing given the current state. */ 1237/* Do appropriate processing given the current state. */
1178/* Read a lookahead token if we need one and don't already have one. */ 1238/* Read a look-ahead token if we need one and don't already have one. */
1179/* yyresume: */ 1239/* yyresume: */
1180 1240
1181 /* First try to decide what to do without reference to lookahead token. */ 1241 /* First try to decide what to do without reference to look-ahead token. */
1182 1242
1183 yyn = yypact[yystate]; 1243 yyn = yypact[yystate];
1184 if (yyn == YYPACT_NINF) 1244 if (yyn == YYPACT_NINF)
1185 goto yydefault; 1245 goto yydefault;
1186 1246
1187 /* Not known => get a lookahead token if don't already have one. */ 1247 /* Not known => get a look-ahead token if don't already have one. */
1188 1248
1189 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 1249 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1190 if (yychar == YYEMPTY) 1250 if (yychar == YYEMPTY)
1191 { 1251 {
1192 YYDPRINTF ((stderr, "Reading a token: ")); 1252 YYDPRINTF ((stderr, "Reading a token: "));
@@ -1201,7 +1261,7 @@ yybackup:
1201 else 1261 else
1202 { 1262 {
1203 yytoken = YYTRANSLATE (yychar); 1263 yytoken = YYTRANSLATE (yychar);
1204 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); 1264 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1205 } 1265 }
1206 1266
1207 /* If the proper action on seeing token YYTOKEN is to reduce or to 1267 /* If the proper action on seeing token YYTOKEN is to reduce or to
@@ -1221,8 +1281,8 @@ yybackup:
1221 if (yyn == YYFINAL) 1281 if (yyn == YYFINAL)
1222 YYACCEPT; 1282 YYACCEPT;
1223 1283
1224 /* Shift the lookahead token. */ 1284 /* Shift the look-ahead token. */
1225 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); 1285 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1226 1286
1227 /* Discard the token being shifted unless it is eof. */ 1287 /* Discard the token being shifted unless it is eof. */
1228 if (yychar != YYEOF) 1288 if (yychar != YYEOF)
@@ -1273,155 +1333,123 @@ yyreduce:
1273 { 1333 {
1274 case 8: 1334 case 8:
1275 1335
1276 { zconfprint("unexpected 'endmenu' statement"); ;} 1336 { zconf_error("unexpected end statement"); ;}
1277 break; 1337 break;
1278 1338
1279 case 9: 1339 case 9:
1280 1340
1281 { zconfprint("unexpected 'endif' statement"); ;} 1341 { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); ;}
1282 break; 1342 break;
1283 1343
1284 case 10: 1344 case 10:
1285 1345
1286 { zconfprint("unexpected 'endchoice' statement"); ;} 1346 {
1347 zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[-2].id)->name);
1348;}
1287 break; 1349 break;
1288 1350
1289 case 11: 1351 case 11:
1290 1352
1291 { zconfprint("syntax error"); yyerrok; ;} 1353 { zconf_error("invalid statement"); ;}
1292 break; 1354 break;
1293 1355
1294 case 18: 1356 case 25:
1295 1357
1296 { 1358 { zconf_error("unknown option \"%s\"", (yyvsp[-2].string)); ;}
1297 struct symbol *sym = sym_lookup(yyvsp[-1].string, 0);
1298 sym->flags |= SYMBOL_OPTIONAL;
1299 menu_add_entry(sym);
1300 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string);
1301;}
1302 break; 1359 break;
1303 1360
1304 case 19: 1361 case 26:
1305 1362
1306 { 1363 { zconf_error("invalid option"); ;}
1307 menu_end_entry();
1308 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1309;}
1310 break; 1364 break;
1311 1365
1312 case 20: 1366 case 27:
1313 1367
1314 { 1368 {
1315 struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); 1369 struct symbol *sym = sym_lookup((yyvsp[-1].string), 0);
1316 sym->flags |= SYMBOL_OPTIONAL; 1370 sym->flags |= SYMBOL_OPTIONAL;
1317 menu_add_entry(sym); 1371 menu_add_entry(sym);
1318 printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); 1372 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
1319;} 1373;}
1320 break; 1374 break;
1321 1375
1322 case 21: 1376 case 28:
1323 1377
1324 { 1378 {
1325 if (current_entry->prompt)
1326 current_entry->prompt->type = P_MENU;
1327 else
1328 zconfprint("warning: menuconfig statement without prompt");
1329 menu_end_entry(); 1379 menu_end_entry();
1330 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); 1380 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1331;} 1381;}
1332 break; 1382 break;
1333 1383
1334 case 27:
1335
1336 {
1337 menu_set_type(S_TRISTATE);
1338 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
1339;}
1340 break;
1341
1342 case 28:
1343
1344 {
1345 menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr);
1346 menu_set_type(S_TRISTATE);
1347 printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno());
1348;}
1349 break;
1350
1351 case 29: 1384 case 29:
1352 1385
1353 { 1386 {
1354 menu_set_type(S_BOOLEAN); 1387 struct symbol *sym = sym_lookup((yyvsp[-1].string), 0);
1355 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); 1388 sym->flags |= SYMBOL_OPTIONAL;
1389 menu_add_entry(sym);
1390 printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
1356;} 1391;}
1357 break; 1392 break;
1358 1393
1359 case 30: 1394 case 30:
1360 1395
1361 { 1396 {
1362 menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); 1397 if (current_entry->prompt)
1363 menu_set_type(S_BOOLEAN); 1398 current_entry->prompt->type = P_MENU;
1364 printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); 1399 else
1365;} 1400 zconfprint("warning: menuconfig statement without prompt");
1366 break; 1401 menu_end_entry();
1367 1402 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1368 case 31:
1369
1370 {
1371 menu_set_type(S_INT);
1372 printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno());
1373;}
1374 break;
1375
1376 case 32:
1377
1378 {
1379 menu_set_type(S_HEX);
1380 printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno());
1381;} 1403;}
1382 break; 1404 break;
1383 1405
1384 case 33: 1406 case 37:
1385 1407
1386 { 1408 {
1387 menu_set_type(S_STRING); 1409 menu_set_type((yyvsp[-2].id)->stype);
1388 printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); 1410 printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
1411 zconf_curname(), zconf_lineno(),
1412 (yyvsp[-2].id)->stype);
1389;} 1413;}
1390 break; 1414 break;
1391 1415
1392 case 34: 1416 case 38:
1393 1417
1394 { 1418 {
1395 menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); 1419 menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
1396 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); 1420 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1397;} 1421;}
1398 break; 1422 break;
1399 1423
1400 case 35: 1424 case 39:
1401 1425
1402 { 1426 {
1403 menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); 1427 menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr));
1404 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); 1428 if ((yyvsp[-3].id)->stype != S_UNKNOWN)
1429 menu_set_type((yyvsp[-3].id)->stype);
1430 printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
1431 zconf_curname(), zconf_lineno(),
1432 (yyvsp[-3].id)->stype);
1405;} 1433;}
1406 break; 1434 break;
1407 1435
1408 case 36: 1436 case 40:
1409 1437
1410 { 1438 {
1411 menu_add_symbol(P_SELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); 1439 menu_add_symbol(P_SELECT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
1412 printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); 1440 printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
1413;} 1441;}
1414 break; 1442 break;
1415 1443
1416 case 37: 1444 case 41:
1417 1445
1418 { 1446 {
1419 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,yyvsp[-3].symbol, yyvsp[-2].symbol), yyvsp[-1].expr); 1447 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[-3].symbol), (yyvsp[-2].symbol)), (yyvsp[-1].expr));
1420 printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); 1448 printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
1421;} 1449;}
1422 break; 1450 break;
1423 1451
1424 case 38: 1452 case 42:
1425 1453
1426 { 1454 {
1427 struct symbol *sym = sym_lookup(NULL, 0); 1455 struct symbol *sym = sym_lookup(NULL, 0);
@@ -1432,57 +1460,45 @@ yyreduce:
1432;} 1460;}
1433 break; 1461 break;
1434 1462
1435 case 39: 1463 case 43:
1436 1464
1437 { 1465 {
1438 menu_end_entry(); 1466 (yyval.menu) = menu_add_menu();
1439 menu_add_menu();
1440;} 1467;}
1441 break; 1468 break;
1442 1469
1443 case 40: 1470 case 44:
1444 1471
1445 { 1472 {
1446 if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) { 1473 if (zconf_endtoken((yyvsp[0].id), T_CHOICE, T_ENDCHOICE)) {
1447 menu_end_menu(); 1474 menu_end_menu();
1448 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); 1475 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
1449 } 1476 }
1450;} 1477;}
1451 break; 1478 break;
1452 1479
1453 case 42: 1480 case 52:
1454
1455 {
1456 printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno);
1457 zconfnerrs++;
1458;}
1459 break;
1460
1461 case 48:
1462 1481
1463 { 1482 {
1464 menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); 1483 menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
1465 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); 1484 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1466;} 1485;}
1467 break; 1486 break;
1468 1487
1469 case 49: 1488 case 53:
1470 1489
1471 { 1490 {
1472 menu_set_type(S_TRISTATE); 1491 if ((yyvsp[-2].id)->stype == S_BOOLEAN || (yyvsp[-2].id)->stype == S_TRISTATE) {
1473 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); 1492 menu_set_type((yyvsp[-2].id)->stype);
1493 printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
1494 zconf_curname(), zconf_lineno(),
1495 (yyvsp[-2].id)->stype);
1496 } else
1497 YYERROR;
1474;} 1498;}
1475 break; 1499 break;
1476 1500
1477 case 50: 1501 case 54:
1478
1479 {
1480 menu_set_type(S_BOOLEAN);
1481 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
1482;}
1483 break;
1484
1485 case 51:
1486 1502
1487 { 1503 {
1488 current_entry->sym->flags |= SYMBOL_OPTIONAL; 1504 current_entry->sym->flags |= SYMBOL_OPTIONAL;
@@ -1490,115 +1506,89 @@ yyreduce:
1490;} 1506;}
1491 break; 1507 break;
1492 1508
1493 case 52: 1509 case 55:
1494 1510
1495 { 1511 {
1496 menu_add_symbol(P_DEFAULT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); 1512 if ((yyvsp[-3].id)->stype == S_UNKNOWN) {
1497 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); 1513 menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
1514 printd(DEBUG_PARSE, "%s:%d:default\n",
1515 zconf_curname(), zconf_lineno());
1516 } else
1517 YYERROR;
1498;} 1518;}
1499 break; 1519 break;
1500 1520
1501 case 55: 1521 case 58:
1502 1522
1503 { 1523 {
1504 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); 1524 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
1505 menu_add_entry(NULL); 1525 menu_add_entry(NULL);
1506 menu_add_dep(yyvsp[-1].expr); 1526 menu_add_dep((yyvsp[-1].expr));
1507 menu_end_entry(); 1527 (yyval.menu) = menu_add_menu();
1508 menu_add_menu();
1509;} 1528;}
1510 break; 1529 break;
1511 1530
1512 case 56: 1531 case 59:
1513 1532
1514 { 1533 {
1515 if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) { 1534 if (zconf_endtoken((yyvsp[0].id), T_IF, T_ENDIF)) {
1516 menu_end_menu(); 1535 menu_end_menu();
1517 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); 1536 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
1518 } 1537 }
1519;} 1538;}
1520 break; 1539 break;
1521 1540
1522 case 58: 1541 case 65:
1523
1524 {
1525 printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno);
1526 zconfnerrs++;
1527;}
1528 break;
1529
1530 case 63:
1531 1542
1532 { 1543 {
1533 menu_add_entry(NULL); 1544 menu_add_entry(NULL);
1534 menu_add_prop(P_MENU, yyvsp[-1].string, NULL, NULL); 1545 menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL);
1535 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); 1546 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
1536;} 1547;}
1537 break; 1548 break;
1538 1549
1539 case 64: 1550 case 66:
1540 1551
1541 { 1552 {
1542 menu_end_entry(); 1553 (yyval.menu) = menu_add_menu();
1543 menu_add_menu();
1544;} 1554;}
1545 break; 1555 break;
1546 1556
1547 case 65: 1557 case 67:
1548 1558
1549 { 1559 {
1550 if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) { 1560 if (zconf_endtoken((yyvsp[0].id), T_MENU, T_ENDMENU)) {
1551 menu_end_menu(); 1561 menu_end_menu();
1552 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); 1562 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
1553 } 1563 }
1554;} 1564;}
1555 break; 1565 break;
1556 1566
1557 case 67:
1558
1559 {
1560 printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno);
1561 zconfnerrs++;
1562;}
1563 break;
1564
1565 case 72:
1566
1567 { zconfprint("invalid menu option"); yyerrok; ;}
1568 break;
1569
1570 case 73: 1567 case 73:
1571 1568
1572 { 1569 {
1573 yyval.string = yyvsp[-1].string; 1570 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
1574 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); 1571 zconf_nextfile((yyvsp[-1].string));
1575;} 1572;}
1576 break; 1573 break;
1577 1574
1578 case 74: 1575 case 74:
1579 1576
1580 { 1577 {
1581 zconf_nextfile(yyvsp[0].string);
1582;}
1583 break;
1584
1585 case 75:
1586
1587 {
1588 menu_add_entry(NULL); 1578 menu_add_entry(NULL);
1589 menu_add_prop(P_COMMENT, yyvsp[-1].string, NULL, NULL); 1579 menu_add_prompt(P_COMMENT, (yyvsp[-1].string), NULL);
1590 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); 1580 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
1591;} 1581;}
1592 break; 1582 break;
1593 1583
1594 case 76: 1584 case 75:
1595 1585
1596 { 1586 {
1597 menu_end_entry(); 1587 menu_end_entry();
1598;} 1588;}
1599 break; 1589 break;
1600 1590
1601 case 77: 1591 case 76:
1602 1592
1603 { 1593 {
1604 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); 1594 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
@@ -1606,17 +1596,17 @@ yyreduce:
1606;} 1596;}
1607 break; 1597 break;
1608 1598
1609 case 78: 1599 case 77:
1610 1600
1611 { 1601 {
1612 current_entry->sym->help = yyvsp[0].string; 1602 current_entry->sym->help = (yyvsp[0].string);
1613;} 1603;}
1614 break; 1604 break;
1615 1605
1616 case 82: 1606 case 82:
1617 1607
1618 { 1608 {
1619 menu_add_dep(yyvsp[-1].expr); 1609 menu_add_dep((yyvsp[-1].expr));
1620 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); 1610 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
1621;} 1611;}
1622 break; 1612 break;
@@ -1624,7 +1614,7 @@ yyreduce:
1624 case 83: 1614 case 83:
1625 1615
1626 { 1616 {
1627 menu_add_dep(yyvsp[-1].expr); 1617 menu_add_dep((yyvsp[-1].expr));
1628 printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); 1618 printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
1629;} 1619;}
1630 break; 1620 break;
@@ -1632,7 +1622,7 @@ yyreduce:
1632 case 84: 1622 case 84:
1633 1623
1634 { 1624 {
1635 menu_add_dep(yyvsp[-1].expr); 1625 menu_add_dep((yyvsp[-1].expr));
1636 printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); 1626 printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
1637;} 1627;}
1638 break; 1628 break;
@@ -1640,84 +1630,84 @@ yyreduce:
1640 case 86: 1630 case 86:
1641 1631
1642 { 1632 {
1643 menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr); 1633 menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr));
1644;} 1634;}
1645 break; 1635 break;
1646 1636
1647 case 89: 1637 case 89:
1648 1638
1649 { yyval.token = T_ENDMENU; ;} 1639 { (yyval.id) = (yyvsp[-1].id); ;}
1650 break; 1640 break;
1651 1641
1652 case 90: 1642 case 90:
1653 1643
1654 { yyval.token = T_ENDCHOICE; ;} 1644 { (yyval.id) = (yyvsp[-1].id); ;}
1655 break; 1645 break;
1656 1646
1657 case 91: 1647 case 91:
1658 1648
1659 { yyval.token = T_ENDIF; ;} 1649 { (yyval.id) = (yyvsp[-1].id); ;}
1660 break; 1650 break;
1661 1651
1662 case 94: 1652 case 94:
1663 1653
1664 { yyval.expr = NULL; ;} 1654 { (yyval.expr) = NULL; ;}
1665 break; 1655 break;
1666 1656
1667 case 95: 1657 case 95:
1668 1658
1669 { yyval.expr = yyvsp[0].expr; ;} 1659 { (yyval.expr) = (yyvsp[0].expr); ;}
1670 break; 1660 break;
1671 1661
1672 case 96: 1662 case 96:
1673 1663
1674 { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); ;} 1664 { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); ;}
1675 break; 1665 break;
1676 1666
1677 case 97: 1667 case 97:
1678 1668
1679 { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} 1669 { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); ;}
1680 break; 1670 break;
1681 1671
1682 case 98: 1672 case 98:
1683 1673
1684 { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} 1674 { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); ;}
1685 break; 1675 break;
1686 1676
1687 case 99: 1677 case 99:
1688 1678
1689 { yyval.expr = yyvsp[-1].expr; ;} 1679 { (yyval.expr) = (yyvsp[-1].expr); ;}
1690 break; 1680 break;
1691 1681
1692 case 100: 1682 case 100:
1693 1683
1694 { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); ;} 1684 { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); ;}
1695 break; 1685 break;
1696 1686
1697 case 101: 1687 case 101:
1698 1688
1699 { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); ;} 1689 { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;}
1700 break; 1690 break;
1701 1691
1702 case 102: 1692 case 102:
1703 1693
1704 { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); ;} 1694 { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); ;}
1705 break; 1695 break;
1706 1696
1707 case 103: 1697 case 103:
1708 1698
1709 { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); ;} 1699 { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); ;}
1710 break; 1700 break;
1711 1701
1712 case 104: 1702 case 104:
1713 1703
1714 { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); ;} 1704 { (yyval.symbol) = sym_lookup((yyvsp[0].string), 1); free((yyvsp[0].string)); ;}
1715 break; 1705 break;
1716 1706
1717 1707
1718 } 1708 }
1719 1709
1720/* Line 999 of yacc.c. */ 1710/* Line 1037 of yacc.c. */
1721 1711
1722 1712
1723 yyvsp -= yylen; 1713 yyvsp -= yylen;
@@ -1759,18 +1749,33 @@ yyerrlab:
1759 { 1749 {
1760 YYSIZE_T yysize = 0; 1750 YYSIZE_T yysize = 0;
1761 int yytype = YYTRANSLATE (yychar); 1751 int yytype = YYTRANSLATE (yychar);
1752 const char* yyprefix;
1762 char *yymsg; 1753 char *yymsg;
1763 int yyx, yycount; 1754 int yyx;
1764 1755
1765 yycount = 0;
1766 /* Start YYX at -YYN if negative to avoid negative indexes in 1756 /* Start YYX at -YYN if negative to avoid negative indexes in
1767 YYCHECK. */ 1757 YYCHECK. */
1768 for (yyx = yyn < 0 ? -yyn : 0; 1758 int yyxbegin = yyn < 0 ? -yyn : 0;
1769 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) 1759
1760 /* Stay within bounds of both yycheck and yytname. */
1761 int yychecklim = YYLAST - yyn;
1762 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1763 int yycount = 0;
1764
1765 yyprefix = ", expecting ";
1766 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1770 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1767 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1771 yysize += yystrlen (yytname[yyx]) + 15, yycount++; 1768 {
1772 yysize += yystrlen ("syntax error, unexpected ") + 1; 1769 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1773 yysize += yystrlen (yytname[yytype]); 1770 yycount += 1;
1771 if (yycount == 5)
1772 {
1773 yysize = 0;
1774 break;
1775 }
1776 }
1777 yysize += (sizeof ("syntax error, unexpected ")
1778 + yystrlen (yytname[yytype]));
1774 yymsg = (char *) YYSTACK_ALLOC (yysize); 1779 yymsg = (char *) YYSTACK_ALLOC (yysize);
1775 if (yymsg != 0) 1780 if (yymsg != 0)
1776 { 1781 {
@@ -1779,16 +1784,13 @@ yyerrlab:
1779 1784
1780 if (yycount < 5) 1785 if (yycount < 5)
1781 { 1786 {
1782 yycount = 0; 1787 yyprefix = ", expecting ";
1783 for (yyx = yyn < 0 ? -yyn : 0; 1788 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1784 yyx < (int) (sizeof (yytname) / sizeof (char *));
1785 yyx++)
1786 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1789 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1787 { 1790 {
1788 const char *yyq = ! yycount ? ", expecting " : " or "; 1791 yyp = yystpcpy (yyp, yyprefix);
1789 yyp = yystpcpy (yyp, yyq);
1790 yyp = yystpcpy (yyp, yytname[yyx]); 1792 yyp = yystpcpy (yyp, yytname[yyx]);
1791 yycount++; 1793 yyprefix = " or ";
1792 } 1794 }
1793 } 1795 }
1794 yyerror (yymsg); 1796 yyerror (yymsg);
@@ -1806,38 +1808,57 @@ yyerrlab:
1806 1808
1807 if (yyerrstatus == 3) 1809 if (yyerrstatus == 3)
1808 { 1810 {
1809 /* If just tried and failed to reuse lookahead token after an 1811 /* If just tried and failed to reuse look-ahead token after an
1810 error, discard it. */ 1812 error, discard it. */
1811 1813
1812 /* Return failure if at end of input. */ 1814 if (yychar <= YYEOF)
1813 if (yychar == YYEOF)
1814 { 1815 {
1815 /* Pop the error token. */ 1816 /* If at end of input, pop the error token,
1816 YYPOPSTACK; 1817 then the rest of the stack, then return failure. */
1817 /* Pop the rest of the stack. */ 1818 if (yychar == YYEOF)
1818 while (yyss < yyssp) 1819 for (;;)
1819 { 1820 {
1820 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); 1821
1821 yydestruct (yystos[*yyssp], yyvsp); 1822 YYPOPSTACK;
1822 YYPOPSTACK; 1823 if (yyssp == yyss)
1823 } 1824 YYABORT;
1824 YYABORT; 1825 yydestruct ("Error: popping",
1826 yystos[*yyssp], yyvsp);
1827 }
1825 } 1828 }
1826 1829 else
1827 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); 1830 {
1828 yydestruct (yytoken, &yylval); 1831 yydestruct ("Error: discarding", yytoken, &yylval);
1829 yychar = YYEMPTY; 1832 yychar = YYEMPTY;
1830 1833 }
1831 } 1834 }
1832 1835
1833 /* Else will try to reuse lookahead token after shifting the error 1836 /* Else will try to reuse look-ahead token after shifting the error
1834 token. */ 1837 token. */
1835 goto yyerrlab1; 1838 goto yyerrlab1;
1836 1839
1837 1840
1838/*----------------------------------------------------. 1841/*---------------------------------------------------.
1839| yyerrlab1 -- error raised explicitly by an action. | 1842| yyerrorlab -- error raised explicitly by YYERROR. |
1840`----------------------------------------------------*/ 1843`---------------------------------------------------*/
1844yyerrorlab:
1845
1846#ifdef __GNUC__
1847 /* Pacify GCC when the user code never invokes YYERROR and the label
1848 yyerrorlab therefore never appears in user code. */
1849 if (0)
1850 goto yyerrorlab;
1851#endif
1852
1853yyvsp -= yylen;
1854 yyssp -= yylen;
1855 yystate = *yyssp;
1856 goto yyerrlab1;
1857
1858
1859/*-------------------------------------------------------------.
1860| yyerrlab1 -- common code for both syntax error and YYERROR. |
1861`-------------------------------------------------------------*/
1841yyerrlab1: 1862yyerrlab1:
1842 yyerrstatus = 3; /* Each real token shifted decrements this. */ 1863 yyerrstatus = 3; /* Each real token shifted decrements this. */
1843 1864
@@ -1859,22 +1880,22 @@ yyerrlab1:
1859 if (yyssp == yyss) 1880 if (yyssp == yyss)
1860 YYABORT; 1881 YYABORT;
1861 1882
1862 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1863 yydestruct (yystos[yystate], yyvsp);
1864 yyvsp--;
1865 yystate = *--yyssp;
1866 1883
1884 yydestruct ("Error: popping", yystos[yystate], yyvsp);
1885 YYPOPSTACK;
1886 yystate = *yyssp;
1867 YY_STACK_PRINT (yyss, yyssp); 1887 YY_STACK_PRINT (yyss, yyssp);
1868 } 1888 }
1869 1889
1870 if (yyn == YYFINAL) 1890 if (yyn == YYFINAL)
1871 YYACCEPT; 1891 YYACCEPT;
1872 1892
1873 YYDPRINTF ((stderr, "Shifting error token, "));
1874
1875 *++yyvsp = yylval; 1893 *++yyvsp = yylval;
1876 1894
1877 1895
1896 /* Shift the error token. */
1897 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1898
1878 yystate = yyn; 1899 yystate = yyn;
1879 goto yynewstate; 1900 goto yynewstate;
1880 1901
@@ -1890,6 +1911,9 @@ yyacceptlab:
1890| yyabortlab -- YYABORT comes here. | 1911| yyabortlab -- YYABORT comes here. |
1891`-----------------------------------*/ 1912`-----------------------------------*/
1892yyabortlab: 1913yyabortlab:
1914 yydestruct ("Error: discarding lookahead",
1915 yytoken, &yylval);
1916 yychar = YYEMPTY;
1893 yyresult = 1; 1917 yyresult = 1;
1894 goto yyreturn; 1918 goto yyreturn;
1895 1919
@@ -1925,18 +1949,18 @@ void conf_parse(const char *name)
1925 sym_init(); 1949 sym_init();
1926 menu_init(); 1950 menu_init();
1927 modules_sym = sym_lookup("MODULES", 0); 1951 modules_sym = sym_lookup("MODULES", 0);
1928 rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL); 1952 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
1929 1953
1930 //zconfdebug = 1; 1954#if YYDEBUG
1955 if (getenv("ZCONF_DEBUG"))
1956 zconfdebug = 1;
1957#endif
1931 zconfparse(); 1958 zconfparse();
1932 if (zconfnerrs) 1959 if (zconfnerrs)
1933 exit(1); 1960 exit(1);
1934 menu_finalize(&rootmenu); 1961 menu_finalize(&rootmenu);
1935 for_all_symbols(i, sym) { 1962 for_all_symbols(i, sym) {
1936 if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) 1963 sym_check_deps(sym);
1937 printf("\n");
1938 else
1939 sym->flags |= SYMBOL_CHECK_DONE;
1940 } 1964 }
1941 1965
1942 sym_change_count = 1; 1966 sym_change_count = 1;
@@ -1951,20 +1975,25 @@ const char *zconf_tokenname(int token)
1951 case T_ENDCHOICE: return "endchoice"; 1975 case T_ENDCHOICE: return "endchoice";
1952 case T_IF: return "if"; 1976 case T_IF: return "if";
1953 case T_ENDIF: return "endif"; 1977 case T_ENDIF: return "endif";
1978 case T_DEPENDS: return "depends";
1954 } 1979 }
1955 return "<token>"; 1980 return "<token>";
1956} 1981}
1957 1982
1958static bool zconf_endtoken(int token, int starttoken, int endtoken) 1983static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
1959{ 1984{
1960 if (token != endtoken) { 1985 if (id->token != endtoken) {
1961 zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); 1986 zconf_error("unexpected '%s' within %s block",
1987 kconf_id_strings + id->name, zconf_tokenname(starttoken));
1962 zconfnerrs++; 1988 zconfnerrs++;
1963 return false; 1989 return false;
1964 } 1990 }
1965 if (current_menu->file != current_file) { 1991 if (current_menu->file != current_file) {
1966 zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); 1992 zconf_error("'%s' in different file than '%s'",
1967 zconfprint("location of the '%s'", zconf_tokenname(starttoken)); 1993 kconf_id_strings + id->name, zconf_tokenname(starttoken));
1994 fprintf(stderr, "%s:%d: location of the '%s'\n",
1995 current_menu->file->name, current_menu->lineno,
1996 zconf_tokenname(starttoken));
1968 zconfnerrs++; 1997 zconfnerrs++;
1969 return false; 1998 return false;
1970 } 1999 }
@@ -1975,7 +2004,19 @@ static void zconfprint(const char *err, ...)
1975{ 2004{
1976 va_list ap; 2005 va_list ap;
1977 2006
1978 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); 2007 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
2008 va_start(ap, err);
2009 vfprintf(stderr, err, ap);
2010 va_end(ap);
2011 fprintf(stderr, "\n");
2012}
2013
2014static void zconf_error(const char *err, ...)
2015{
2016 va_list ap;
2017
2018 zconfnerrs++;
2019 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
1979 va_start(ap, err); 2020 va_start(ap, err);
1980 vfprintf(stderr, err, ap); 2021 vfprintf(stderr, err, ap);
1981 va_end(ap); 2022 va_end(ap);
@@ -1984,7 +2025,9 @@ static void zconfprint(const char *err, ...)
1984 2025
1985static void zconferror(const char *err) 2026static void zconferror(const char *err)
1986{ 2027{
2028#if YYDEBUG
1987 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); 2029 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
2030#endif
1988} 2031}
1989 2032
1990void print_quoted_string(FILE *out, const char *str) 2033void print_quoted_string(FILE *out, const char *str)
diff --git a/scripts/config/zconf.y b/scripts/kconfig/zconf.y
index 5ebaf0a78..1f61fba6a 100644
--- a/scripts/config/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -11,6 +11,11 @@
11#include <string.h> 11#include <string.h>
12#include <stdbool.h> 12#include <stdbool.h>
13 13
14#define LKC_DIRECT_LINK
15#include "lkc.h"
16
17#include "zconf.hash.c"
18
14#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) 19#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
15 20
16#define PRINTD 0x0001 21#define PRINTD 0x0001
@@ -20,61 +25,59 @@ int cdebug = PRINTD;
20 25
21extern int zconflex(void); 26extern int zconflex(void);
22static void zconfprint(const char *err, ...); 27static void zconfprint(const char *err, ...);
28static void zconf_error(const char *err, ...);
23static void zconferror(const char *err); 29static void zconferror(const char *err);
24static bool zconf_endtoken(int token, int starttoken, int endtoken); 30static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
25 31
26struct symbol *symbol_hash[257]; 32struct symbol *symbol_hash[257];
27 33
28static struct menu *current_menu, *current_entry; 34static struct menu *current_menu, *current_entry;
29 35
36#define YYDEBUG 0
37#if YYDEBUG
30#define YYERROR_VERBOSE 38#define YYERROR_VERBOSE
39#endif
31%} 40%}
32%expect 40 41%expect 26
33 42
34%union 43%union
35{ 44{
36 int token;
37 char *string; 45 char *string;
46 struct file *file;
38 struct symbol *symbol; 47 struct symbol *symbol;
39 struct expr *expr; 48 struct expr *expr;
40 struct menu *menu; 49 struct menu *menu;
50 struct kconf_id *id;
41} 51}
42 52
43%token T_MAINMENU 53%token <id>T_MAINMENU
44%token T_MENU 54%token <id>T_MENU
45%token T_ENDMENU 55%token <id>T_ENDMENU
46%token T_SOURCE 56%token <id>T_SOURCE
47%token T_CHOICE 57%token <id>T_CHOICE
48%token T_ENDCHOICE 58%token <id>T_ENDCHOICE
49%token T_COMMENT 59%token <id>T_COMMENT
50%token T_CONFIG 60%token <id>T_CONFIG
51%token T_MENUCONFIG 61%token <id>T_MENUCONFIG
52%token T_HELP 62%token <id>T_HELP
53%token <string> T_HELPTEXT 63%token <string> T_HELPTEXT
54%token T_IF 64%token <id>T_IF
55%token T_ENDIF 65%token <id>T_ENDIF
56%token T_DEPENDS 66%token <id>T_DEPENDS
57%token T_REQUIRES 67%token <id>T_REQUIRES
58%token T_OPTIONAL 68%token <id>T_OPTIONAL
59%token T_PROMPT 69%token <id>T_PROMPT
60%token T_DEFAULT 70%token <id>T_TYPE
61%token T_TRISTATE 71%token <id>T_DEFAULT
62%token T_DEF_TRISTATE 72%token <id>T_SELECT
63%token T_BOOLEAN 73%token <id>T_RANGE
64%token T_DEF_BOOLEAN 74%token <id>T_ON
65%token T_STRING
66%token T_INT
67%token T_HEX
68%token <string> T_WORD 75%token <string> T_WORD
69%token <string> T_WORD_QUOTE 76%token <string> T_WORD_QUOTE
70%token T_UNEQUAL 77%token T_UNEQUAL
71%token T_EOF
72%token T_EOL
73%token T_CLOSE_PAREN 78%token T_CLOSE_PAREN
74%token T_OPEN_PAREN 79%token T_OPEN_PAREN
75%token T_ON 80%token T_EOL
76%token T_SELECT
77%token T_RANGE
78 81
79%left T_OR 82%left T_OR
80%left T_AND 83%left T_AND
@@ -82,38 +85,54 @@ static struct menu *current_menu, *current_entry;
82%nonassoc T_NOT 85%nonassoc T_NOT
83 86
84%type <string> prompt 87%type <string> prompt
85%type <string> source
86%type <symbol> symbol 88%type <symbol> symbol
87%type <expr> expr 89%type <expr> expr
88%type <expr> if_expr 90%type <expr> if_expr
89%type <token> end 91%type <id> end
92%type <id> option_name
93%type <menu> if_entry menu_entry choice_entry
94
95%destructor {
96 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
97 $$->file->name, $$->lineno);
98 if (current_menu == $$)
99 menu_end_menu();
100} if_entry menu_entry choice_entry
90 101
91%{
92#define LKC_DIRECT_LINK
93#include "lkc.h"
94%}
95%% 102%%
96input: /* empty */ 103input: stmt_list;
97 | input block 104
105stmt_list:
106 /* empty */
107 | stmt_list common_stmt
108 | stmt_list choice_stmt
109 | stmt_list menu_stmt
110 | stmt_list T_MAINMENU prompt nl
111 | stmt_list end { zconf_error("unexpected end statement"); }
112 | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
113 | stmt_list option_name error T_EOL
114{
115 zconf_error("unexpected option \"%s\"", kconf_id_strings + $2->name);
116}
117 | stmt_list error T_EOL { zconf_error("invalid statement"); }
98; 118;
99 119
100block: common_block 120option_name:
101 | choice_stmt 121 T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT
102 | menu_stmt
103 | T_MAINMENU prompt nl_or_eof
104 | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); }
105 | T_ENDIF { zconfprint("unexpected 'endif' statement"); }
106 | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); }
107 | error nl_or_eof { zconfprint("syntax error"); yyerrok; }
108; 122;
109 123
110common_block: 124common_stmt:
111 if_stmt 125 T_EOL
126 | if_stmt
112 | comment_stmt 127 | comment_stmt
113 | config_stmt 128 | config_stmt
114 | menuconfig_stmt 129 | menuconfig_stmt
115 | source_stmt 130 | source_stmt
116 | nl_or_eof 131;
132
133option_error:
134 T_WORD error T_EOL { zconf_error("unknown option \"%s\"", $1); }
135 | error T_EOL { zconf_error("invalid option"); }
117; 136;
118 137
119 138
@@ -156,51 +175,16 @@ config_option_list:
156 | config_option_list config_option 175 | config_option_list config_option
157 | config_option_list depends 176 | config_option_list depends
158 | config_option_list help 177 | config_option_list help
178 | config_option_list option_error
159 | config_option_list T_EOL 179 | config_option_list T_EOL
160; 180;
161 181
162config_option: T_TRISTATE prompt_stmt_opt T_EOL 182config_option: T_TYPE prompt_stmt_opt T_EOL
163{ 183{
164 menu_set_type(S_TRISTATE); 184 menu_set_type($1->stype);
165 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); 185 printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
166}; 186 zconf_curname(), zconf_lineno(),
167 187 $1->stype);
168config_option: T_DEF_TRISTATE expr if_expr T_EOL
169{
170 menu_add_expr(P_DEFAULT, $2, $3);
171 menu_set_type(S_TRISTATE);
172 printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno());
173};
174
175config_option: T_BOOLEAN prompt_stmt_opt T_EOL
176{
177 menu_set_type(S_BOOLEAN);
178 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
179};
180
181config_option: T_DEF_BOOLEAN expr if_expr T_EOL
182{
183 menu_add_expr(P_DEFAULT, $2, $3);
184 menu_set_type(S_BOOLEAN);
185 printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno());
186};
187
188config_option: T_INT prompt_stmt_opt T_EOL
189{
190 menu_set_type(S_INT);
191 printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno());
192};
193
194config_option: T_HEX prompt_stmt_opt T_EOL
195{
196 menu_set_type(S_HEX);
197 printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno());
198};
199
200config_option: T_STRING prompt_stmt_opt T_EOL
201{
202 menu_set_type(S_STRING);
203 printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno());
204}; 188};
205 189
206config_option: T_PROMPT prompt if_expr T_EOL 190config_option: T_PROMPT prompt if_expr T_EOL
@@ -212,7 +196,11 @@ config_option: T_PROMPT prompt if_expr T_EOL
212config_option: T_DEFAULT expr if_expr T_EOL 196config_option: T_DEFAULT expr if_expr T_EOL
213{ 197{
214 menu_add_expr(P_DEFAULT, $2, $3); 198 menu_add_expr(P_DEFAULT, $2, $3);
215 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); 199 if ($1->stype != S_UNKNOWN)
200 menu_set_type($1->stype);
201 printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
202 zconf_curname(), zconf_lineno(),
203 $1->stype);
216}; 204};
217 205
218config_option: T_SELECT T_WORD if_expr T_EOL 206config_option: T_SELECT T_WORD if_expr T_EOL
@@ -240,8 +228,7 @@ choice: T_CHOICE T_EOL
240 228
241choice_entry: choice choice_option_list 229choice_entry: choice choice_option_list
242{ 230{
243 menu_end_entry(); 231 $$ = menu_add_menu();
244 menu_add_menu();
245}; 232};
246 233
247choice_end: end 234choice_end: end
@@ -252,13 +239,8 @@ choice_end: end
252 } 239 }
253}; 240};
254 241
255choice_stmt: 242choice_stmt: choice_entry choice_block choice_end
256 choice_entry choice_block choice_end 243;
257 | choice_entry choice_block
258{
259 printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno);
260 zconfnerrs++;
261};
262 244
263choice_option_list: 245choice_option_list:
264 /* empty */ 246 /* empty */
@@ -266,6 +248,7 @@ choice_option_list:
266 | choice_option_list depends 248 | choice_option_list depends
267 | choice_option_list help 249 | choice_option_list help
268 | choice_option_list T_EOL 250 | choice_option_list T_EOL
251 | choice_option_list option_error
269; 252;
270 253
271choice_option: T_PROMPT prompt if_expr T_EOL 254choice_option: T_PROMPT prompt if_expr T_EOL
@@ -274,16 +257,15 @@ choice_option: T_PROMPT prompt if_expr T_EOL
274 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); 257 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
275}; 258};
276 259
277choice_option: T_TRISTATE prompt_stmt_opt T_EOL 260choice_option: T_TYPE prompt_stmt_opt T_EOL
278{
279 menu_set_type(S_TRISTATE);
280 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
281};
282
283choice_option: T_BOOLEAN prompt_stmt_opt T_EOL
284{ 261{
285 menu_set_type(S_BOOLEAN); 262 if ($1->stype == S_BOOLEAN || $1->stype == S_TRISTATE) {
286 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); 263 menu_set_type($1->stype);
264 printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
265 zconf_curname(), zconf_lineno(),
266 $1->stype);
267 } else
268 YYERROR;
287}; 269};
288 270
289choice_option: T_OPTIONAL T_EOL 271choice_option: T_OPTIONAL T_EOL
@@ -294,24 +276,27 @@ choice_option: T_OPTIONAL T_EOL
294 276
295choice_option: T_DEFAULT T_WORD if_expr T_EOL 277choice_option: T_DEFAULT T_WORD if_expr T_EOL
296{ 278{
297 menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); 279 if ($1->stype == S_UNKNOWN) {
298 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); 280 menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3);
281 printd(DEBUG_PARSE, "%s:%d:default\n",
282 zconf_curname(), zconf_lineno());
283 } else
284 YYERROR;
299}; 285};
300 286
301choice_block: 287choice_block:
302 /* empty */ 288 /* empty */
303 | choice_block common_block 289 | choice_block common_stmt
304; 290;
305 291
306/* if entry */ 292/* if entry */
307 293
308if: T_IF expr T_EOL 294if_entry: T_IF expr nl
309{ 295{
310 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); 296 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
311 menu_add_entry(NULL); 297 menu_add_entry(NULL);
312 menu_add_dep($2); 298 menu_add_dep($2);
313 menu_end_entry(); 299 $$ = menu_add_menu();
314 menu_add_menu();
315}; 300};
316 301
317if_end: end 302if_end: end
@@ -322,17 +307,12 @@ if_end: end
322 } 307 }
323}; 308};
324 309
325if_stmt: 310if_stmt: if_entry if_block if_end
326 if if_block if_end 311;
327 | if if_block
328{
329 printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno);
330 zconfnerrs++;
331};
332 312
333if_block: 313if_block:
334 /* empty */ 314 /* empty */
335 | if_block common_block 315 | if_block common_stmt
336 | if_block menu_stmt 316 | if_block menu_stmt
337 | if_block choice_stmt 317 | if_block choice_stmt
338; 318;
@@ -342,14 +322,13 @@ if_block:
342menu: T_MENU prompt T_EOL 322menu: T_MENU prompt T_EOL
343{ 323{
344 menu_add_entry(NULL); 324 menu_add_entry(NULL);
345 menu_add_prop(P_MENU, $2, NULL, NULL); 325 menu_add_prompt(P_MENU, $2, NULL);
346 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); 326 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
347}; 327};
348 328
349menu_entry: menu depends_list 329menu_entry: menu depends_list
350{ 330{
351 menu_end_entry(); 331 $$ = menu_add_menu();
352 menu_add_menu();
353}; 332};
354 333
355menu_end: end 334menu_end: end
@@ -360,31 +339,20 @@ menu_end: end
360 } 339 }
361}; 340};
362 341
363menu_stmt: 342menu_stmt: menu_entry menu_block menu_end
364 menu_entry menu_block menu_end 343;
365 | menu_entry menu_block
366{
367 printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno);
368 zconfnerrs++;
369};
370 344
371menu_block: 345menu_block:
372 /* empty */ 346 /* empty */
373 | menu_block common_block 347 | menu_block common_stmt
374 | menu_block menu_stmt 348 | menu_block menu_stmt
375 | menu_block choice_stmt 349 | menu_block choice_stmt
376 | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; }
377; 350;
378 351
379source: T_SOURCE prompt T_EOL 352source_stmt: T_SOURCE prompt T_EOL
380{ 353{
381 $$ = $2;
382 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); 354 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
383}; 355 zconf_nextfile($2);
384
385source_stmt: source
386{
387 zconf_nextfile($1);
388}; 356};
389 357
390/* comment entry */ 358/* comment entry */
@@ -392,7 +360,7 @@ source_stmt: source
392comment: T_COMMENT prompt T_EOL 360comment: T_COMMENT prompt T_EOL
393{ 361{
394 menu_add_entry(NULL); 362 menu_add_entry(NULL);
395 menu_add_prop(P_COMMENT, $2, NULL, NULL); 363 menu_add_prompt(P_COMMENT, $2, NULL);
396 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); 364 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
397}; 365};
398 366
@@ -416,9 +384,11 @@ help: help_start T_HELPTEXT
416 384
417/* depends option */ 385/* depends option */
418 386
419depends_list: /* empty */ 387depends_list:
420 | depends_list depends 388 /* empty */
421 | depends_list T_EOL 389 | depends_list depends
390 | depends_list T_EOL
391 | depends_list option_error
422; 392;
423 393
424depends: T_DEPENDS T_ON expr T_EOL 394depends: T_DEPENDS T_ON expr T_EOL
@@ -443,20 +413,22 @@ prompt_stmt_opt:
443 /* empty */ 413 /* empty */
444 | prompt if_expr 414 | prompt if_expr
445{ 415{
446 menu_add_prop(P_PROMPT, $1, NULL, $2); 416 menu_add_prompt(P_PROMPT, $1, $2);
447}; 417};
448 418
449prompt: T_WORD 419prompt: T_WORD
450 | T_WORD_QUOTE 420 | T_WORD_QUOTE
451; 421;
452 422
453end: T_ENDMENU nl_or_eof { $$ = T_ENDMENU; } 423end: T_ENDMENU T_EOL { $$ = $1; }
454 | T_ENDCHOICE nl_or_eof { $$ = T_ENDCHOICE; } 424 | T_ENDCHOICE T_EOL { $$ = $1; }
455 | T_ENDIF nl_or_eof { $$ = T_ENDIF; } 425 | T_ENDIF T_EOL { $$ = $1; }
456; 426;
457 427
458nl_or_eof: 428nl:
459 T_EOL | T_EOF; 429 T_EOL
430 | nl T_EOL
431;
460 432
461if_expr: /* empty */ { $$ = NULL; } 433if_expr: /* empty */ { $$ = NULL; }
462 | T_IF expr { $$ = $2; } 434 | T_IF expr { $$ = $2; }
@@ -487,18 +459,18 @@ void conf_parse(const char *name)
487 sym_init(); 459 sym_init();
488 menu_init(); 460 menu_init();
489 modules_sym = sym_lookup("MODULES", 0); 461 modules_sym = sym_lookup("MODULES", 0);
490 rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL); 462 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
491 463
492 //zconfdebug = 1; 464#if YYDEBUG
465 if (getenv("ZCONF_DEBUG"))
466 zconfdebug = 1;
467#endif
493 zconfparse(); 468 zconfparse();
494 if (zconfnerrs) 469 if (zconfnerrs)
495 exit(1); 470 exit(1);
496 menu_finalize(&rootmenu); 471 menu_finalize(&rootmenu);
497 for_all_symbols(i, sym) { 472 for_all_symbols(i, sym) {
498 if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) 473 sym_check_deps(sym);
499 printf("\n");
500 else
501 sym->flags |= SYMBOL_CHECK_DONE;
502 } 474 }
503 475
504 sym_change_count = 1; 476 sym_change_count = 1;
@@ -513,20 +485,25 @@ const char *zconf_tokenname(int token)
513 case T_ENDCHOICE: return "endchoice"; 485 case T_ENDCHOICE: return "endchoice";
514 case T_IF: return "if"; 486 case T_IF: return "if";
515 case T_ENDIF: return "endif"; 487 case T_ENDIF: return "endif";
488 case T_DEPENDS: return "depends";
516 } 489 }
517 return "<token>"; 490 return "<token>";
518} 491}
519 492
520static bool zconf_endtoken(int token, int starttoken, int endtoken) 493static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
521{ 494{
522 if (token != endtoken) { 495 if (id->token != endtoken) {
523 zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); 496 zconf_error("unexpected '%s' within %s block",
497 kconf_id_strings + id->name, zconf_tokenname(starttoken));
524 zconfnerrs++; 498 zconfnerrs++;
525 return false; 499 return false;
526 } 500 }
527 if (current_menu->file != current_file) { 501 if (current_menu->file != current_file) {
528 zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); 502 zconf_error("'%s' in different file than '%s'",
529 zconfprint("location of the '%s'", zconf_tokenname(starttoken)); 503 kconf_id_strings + id->name, zconf_tokenname(starttoken));
504 fprintf(stderr, "%s:%d: location of the '%s'\n",
505 current_menu->file->name, current_menu->lineno,
506 zconf_tokenname(starttoken));
530 zconfnerrs++; 507 zconfnerrs++;
531 return false; 508 return false;
532 } 509 }
@@ -537,7 +514,19 @@ static void zconfprint(const char *err, ...)
537{ 514{
538 va_list ap; 515 va_list ap;
539 516
540 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); 517 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
518 va_start(ap, err);
519 vfprintf(stderr, err, ap);
520 va_end(ap);
521 fprintf(stderr, "\n");
522}
523
524static void zconf_error(const char *err, ...)
525{
526 va_list ap;
527
528 zconfnerrs++;
529 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
541 va_start(ap, err); 530 va_start(ap, err);
542 vfprintf(stderr, err, ap); 531 vfprintf(stderr, err, ap);
543 va_end(ap); 532 va_end(ap);
@@ -546,7 +535,9 @@ static void zconfprint(const char *err, ...)
546 535
547static void zconferror(const char *err) 536static void zconferror(const char *err)
548{ 537{
538#if YYDEBUG
549 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); 539 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
540#endif
550} 541}
551 542
552void print_quoted_string(FILE *out, const char *str) 543void print_quoted_string(FILE *out, const char *str)
diff --git a/scripts/config/mkconfigs b/scripts/mkconfigs
index fda9de72f..fda9de72f 100755
--- a/scripts/config/mkconfigs
+++ b/scripts/mkconfigs
diff --git a/scripts/trylink b/scripts/trylink
new file mode 100755
index 000000000..dfe282db5
--- /dev/null
+++ b/scripts/trylink
@@ -0,0 +1,18 @@
1#!/bin/sh
2
3debug=false
4
5function try {
6 added="$1"
7 shift
8 $debug && echo "Trying: $* $added"
9 "$@" $added >/dev/null 2>&1 \
10 && exit 0
11}
12
13try "" "$@"
14try "-lm" "$@"
15try "-lcrypt" "$@"
16try "-Wl,--start-group -lcrypt -lm -Wl,--end-group" "$@"
17# It failed. Rerun & let people see the error messages
18"$@" $added
diff --git a/scripts/usage.c b/scripts/usage.c
index 373642cd6..adb290e4d 100644
--- a/scripts/usage.c
+++ b/scripts/usage.c
@@ -1,11 +1,13 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2#include <unistd.h> 2#include <unistd.h>
3#include "busybox.h" 3
4#include "../include/autoconf.h"
5#include "../include/busybox.h"
4 6
5static const char usage_messages[] = 7static const char usage_messages[] =
6#define MAKE_USAGE 8#define MAKE_USAGE
7#include "usage.h" 9#include "../include/usage.h"
8#include "applets.h" 10#include "../include/applets.h"
9; 11;
10 12
11int main(void) 13int main(void)
diff --git a/scripts/usage_compressed b/scripts/usage_compressed
index 8e2228af2..ab164aa12 100644..100755
--- a/scripts/usage_compressed
+++ b/scripts/usage_compressed
@@ -1,13 +1,19 @@
1#!/bin/sh 1#!/bin/sh
2 2
3loc="$1" 3target="$1"
4loc="$2"
4 5
6test "$target" || exit 1
5test "$loc" || loc=. 7test "$loc" || loc=.
6test -x "$loc/usage" || exit 1 8test -x "$loc/usage" || exit 1
9test "$SED" || SED=sed
10
11sz=`"$loc/usage" | wc -c` || exit 1
12
13exec >"$target"
7 14
8echo 'static const char packed_usage[] = ' 15echo 'static const char packed_usage[] = '
9"$loc"/usage | bzip2 -1 | od -v -t x1 \ 16"$loc/usage" | bzip2 -1 | od -v -t x1 \
10| $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' || exit 1 17| $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
11echo ';' 18echo ';'
12sz=`"$loc"/usage | wc -c` || exit 1
13echo '#define SIZEOF_usage_messages' `expr 0 + $sz` 19echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
diff --git a/shell/Config.in b/shell/Config.in
index cfe081f2c..0e25bedcb 100644
--- a/shell/Config.in
+++ b/shell/Config.in
@@ -7,36 +7,36 @@ menu "Shells"
7 7
8choice 8choice
9 prompt "Choose your default shell" 9 prompt "Choose your default shell"
10 default CONFIG_FEATURE_SH_IS_NONE 10 default FEATURE_SH_IS_NONE
11 help 11 help
12 Choose a shell. The ash shell is the most bash compatible 12 Choose a shell. The ash shell is the most bash compatible
13 and full featured one. 13 and full featured one.
14 14
15config CONFIG_FEATURE_SH_IS_ASH 15config FEATURE_SH_IS_ASH
16 select CONFIG_ASH 16 select ASH
17 bool "ash" 17 bool "ash"
18 18
19config CONFIG_FEATURE_SH_IS_HUSH 19config FEATURE_SH_IS_HUSH
20 select CONFIG_HUSH 20 select HUSH
21 bool "hush" 21 bool "hush"
22 22
23config CONFIG_FEATURE_SH_IS_LASH 23config FEATURE_SH_IS_LASH
24 select CONFIG_LASH 24 select LASH
25 bool "lash" 25 bool "lash"
26 26
27config CONFIG_FEATURE_SH_IS_MSH 27config FEATURE_SH_IS_MSH
28 select CONFIG_MSH 28 select MSH
29 bool "msh" 29 bool "msh"
30 30
31config CONFIG_FEATURE_SH_IS_NONE 31config FEATURE_SH_IS_NONE
32 bool "none" 32 bool "none"
33 33
34endchoice 34endchoice
35 35
36config CONFIG_ASH 36config ASH
37 bool "ash" 37 bool "ash"
38 default n 38 default n
39 select CONFIG_TEST 39 select TEST
40 help 40 help
41 Tha 'ash' shell adds about 60k in the default configuration and is 41 Tha 'ash' shell adds about 60k in the default configuration and is
42 the most complete and most pedantically correct shell included with 42 the most complete and most pedantically correct shell included with
@@ -45,105 +45,105 @@ config CONFIG_ASH
45 (written by Kenneth Almquist) from NetBSD. 45 (written by Kenneth Almquist) from NetBSD.
46 46
47comment "Ash Shell Options" 47comment "Ash Shell Options"
48 depends on CONFIG_ASH 48 depends on ASH
49 49
50config CONFIG_ASH_JOB_CONTROL 50config ASH_JOB_CONTROL
51 bool "Job control" 51 bool "Job control"
52 default y 52 default y
53 depends on CONFIG_ASH 53 depends on ASH
54 help 54 help
55 Enable job control in the ash shell. 55 Enable job control in the ash shell.
56 56
57config CONFIG_ASH_READ_NCHARS 57config ASH_READ_NCHARS
58 bool "'read -n N' and 'read -s' support" 58 bool "'read -n N' and 'read -s' support"
59 default n 59 default n
60 depends on CONFIG_ASH 60 depends on ASH
61 help 61 help
62 'read -n N' will return a value after N characters have been read. 62 'read -n N' will return a value after N characters have been read.
63 'read -s' will read without echoing the user's input. 63 'read -s' will read without echoing the user's input.
64 64
65config CONFIG_ASH_READ_TIMEOUT 65config ASH_READ_TIMEOUT
66 bool "'read -t S' support." 66 bool "'read -t S' support."
67 default n 67 default n
68 depends on CONFIG_ASH 68 depends on ASH
69 help 69 help
70 'read -t S' will return a value after S seconds have passed. 70 'read -t S' will return a value after S seconds have passed.
71 This implementation will allow fractional seconds, expressed 71 This implementation will allow fractional seconds, expressed
72 as a decimal fraction, e.g. 'read -t 2.5 foo'. 72 as a decimal fraction, e.g. 'read -t 2.5 foo'.
73 73
74config CONFIG_ASH_ALIAS 74config ASH_ALIAS
75 bool "alias support" 75 bool "alias support"
76 default y 76 default y
77 depends on CONFIG_ASH 77 depends on ASH
78 help 78 help
79 Enable alias support in the ash shell. 79 Enable alias support in the ash shell.
80 80
81config CONFIG_ASH_MATH_SUPPORT 81config ASH_MATH_SUPPORT
82 bool "Posix math support" 82 bool "Posix math support"
83 default y 83 default y
84 depends on CONFIG_ASH 84 depends on ASH
85 help 85 help
86 Enable math support in the ash shell. 86 Enable math support in the ash shell.
87 87
88config CONFIG_ASH_MATH_SUPPORT_64 88config ASH_MATH_SUPPORT_64
89 bool "Extend Posix math support to 64 bit" 89 bool "Extend Posix math support to 64 bit"
90 default n 90 default n
91 depends on CONFIG_ASH_MATH_SUPPORT 91 depends on ASH_MATH_SUPPORT
92 help 92 help
93 Enable 64-bit math support in the ash shell. This will make 93 Enable 64-bit math support in the ash shell. This will make
94 the shell slightly larger, but will allow computation with very 94 the shell slightly larger, but will allow computation with very
95 large numbers. 95 large numbers.
96 96
97config CONFIG_ASH_GETOPTS 97config ASH_GETOPTS
98 bool "Builtin getopt to parse positional parameters" 98 bool "Builtin getopt to parse positional parameters"
99 default n 99 default n
100 depends on CONFIG_ASH 100 depends on ASH
101 help 101 help
102 Enable getopts builtin in the ash shell. 102 Enable getopts builtin in the ash shell.
103 103
104config CONFIG_ASH_BUILTIN_ECHO 104config ASH_BUILTIN_ECHO
105 bool "Builtin version of 'echo'" 105 bool "Builtin version of 'echo'"
106 default y 106 default y
107 select CONFIG_ECHO 107 select ECHO
108 depends on CONFIG_ASH 108 depends on ASH
109 help 109 help
110 Enable support for echo, built in to ash. 110 Enable support for echo, built in to ash.
111 111
112config CONFIG_ASH_BUILTIN_TEST 112config ASH_BUILTIN_TEST
113 bool "Builtin version of 'test'" 113 bool "Builtin version of 'test'"
114 default y 114 default y
115 select CONFIG_TEST 115 select TEST
116 depends on CONFIG_ASH 116 depends on ASH
117 help 117 help
118 Enable support for test, built in to ash. 118 Enable support for test, built in to ash.
119 119
120config CONFIG_ASH_CMDCMD 120config ASH_CMDCMD
121 bool "'command' command to override shell builtins" 121 bool "'command' command to override shell builtins"
122 default n 122 default n
123 depends on CONFIG_ASH 123 depends on ASH
124 help 124 help
125 Enable support for the ash 'command' builtin, which allows 125 Enable support for the ash 'command' builtin, which allows
126 you to run the specified command with the specified arguments, 126 you to run the specified command with the specified arguments,
127 even when there is an ash builtin command with the same name. 127 even when there is an ash builtin command with the same name.
128 128
129config CONFIG_ASH_MAIL 129config ASH_MAIL
130 bool "Check for new mail on interactive shells" 130 bool "Check for new mail on interactive shells"
131 default y 131 default y
132 depends on CONFIG_ASH 132 depends on ASH
133 help 133 help
134 Enable "check for new mail" in the ash shell. 134 Enable "check for new mail" in the ash shell.
135 135
136config CONFIG_ASH_OPTIMIZE_FOR_SIZE 136config ASH_OPTIMIZE_FOR_SIZE
137 bool "Optimize for size instead of speed" 137 bool "Optimize for size instead of speed"
138 default y 138 default y
139 depends on CONFIG_ASH 139 depends on ASH
140 help 140 help
141 Compile ash for reduced size at the price of speed. 141 Compile ash for reduced size at the price of speed.
142 142
143config CONFIG_ASH_RANDOM_SUPPORT 143config ASH_RANDOM_SUPPORT
144 bool "Pseudorandom generator and variable $RANDOM" 144 bool "Pseudorandom generator and variable $RANDOM"
145 default n 145 default n
146 depends on CONFIG_ASH 146 depends on ASH
147 help 147 help
148 Enable pseudorandom generator and dynamic variable "$RANDOM". 148 Enable pseudorandom generator and dynamic variable "$RANDOM".
149 Each read of "$RANDOM" will generate a new pseudorandom value. 149 Each read of "$RANDOM" will generate a new pseudorandom value.
@@ -151,21 +151,21 @@ config CONFIG_ASH_RANDOM_SUPPORT
151 After "unset RANDOM" then generator will switch off and this 151 After "unset RANDOM" then generator will switch off and this
152 variable will no longer have special treatment. 152 variable will no longer have special treatment.
153 153
154config CONFIG_ASH_EXPAND_PRMT 154config ASH_EXPAND_PRMT
155 bool "Expand prompt string" 155 bool "Expand prompt string"
156 default n 156 default n
157 depends on CONFIG_ASH 157 depends on ASH
158 help 158 help
159 "PS#" may be contain volatile content, such as backquote commands. 159 "PS#" may be contain volatile content, such as backquote commands.
160 This option recreates the prompt string from the environment 160 This option recreates the prompt string from the environment
161 variable each time it is displayed. 161 variable each time it is displayed.
162 162
163config CONFIG_HUSH 163config HUSH
164 bool "hush" 164 bool "hush"
165 default n 165 default n
166 select CONFIG_TRUE 166 select TRUE
167 select CONFIG_FALSE 167 select FALSE
168 select CONFIG_TEST 168 select TEST
169 help 169 help
170 hush is a very small shell (just 18k) and it has fairly complete 170 hush is a very small shell (just 18k) and it has fairly complete
171 Bourne shell grammar. It even handles all the normal flow control 171 Bourne shell grammar. It even handles all the normal flow control
@@ -177,12 +177,12 @@ config CONFIG_HUSH
177 expansion, &> and >& redirection of stdout+stderr, etc. 177 expansion, &> and >& redirection of stdout+stderr, etc.
178 178
179 179
180config CONFIG_LASH 180config LASH
181 bool "lash" 181 bool "lash"
182 default n 182 default n
183 select CONFIG_TRUE 183 select TRUE
184 select CONFIG_FALSE 184 select FALSE
185 select CONFIG_TEST 185 select TEST
186 help 186 help
187 lash is the very smallest shell (adds just 10k) and it is quite 187 lash is the very smallest shell (adds just 10k) and it is quite
188 usable as a command prompt, but it is not suitable for any but the 188 usable as a command prompt, but it is not suitable for any but the
@@ -192,12 +192,12 @@ config CONFIG_LASH
192 command editing makes it a very nice lightweight command prompt. 192 command editing makes it a very nice lightweight command prompt.
193 193
194 194
195config CONFIG_MSH 195config MSH
196 bool "msh" 196 bool "msh"
197 default n 197 default n
198 select CONFIG_TRUE 198 select TRUE
199 select CONFIG_FALSE 199 select FALSE
200 select CONFIG_TEST 200 select TEST
201 help 201 help
202 The minix shell (adds just 30k) is quite complete and handles things 202 The minix shell (adds just 30k) is quite complete and handles things
203 like for/do/done, case/esac and all the things you expect a Bourne 203 like for/do/done, case/esac and all the things you expect a Bourne
@@ -207,19 +207,19 @@ config CONFIG_MSH
207 It also uses only vfork, so it can be used on uClinux systems. 207 It also uses only vfork, so it can be used on uClinux systems.
208 208
209comment "Bourne Shell Options" 209comment "Bourne Shell Options"
210 depends on CONFIG_MSH || CONFIG_LASH || CONFIG_HUSH || CONFIG_ASH 210 depends on MSH || LASH || HUSH || ASH
211 211
212config CONFIG_FEATURE_SH_EXTRA_QUIET 212config FEATURE_SH_EXTRA_QUIET
213 bool "Hide message on interactive shell startup" 213 bool "Hide message on interactive shell startup"
214 default n 214 default n
215 depends on CONFIG_MSH || CONFIG_LASH || CONFIG_HUSH || CONFIG_ASH 215 depends on MSH || LASH || HUSH || ASH
216 help 216 help
217 Remove the busybox introduction when starting a shell. 217 Remove the busybox introduction when starting a shell.
218 218
219config CONFIG_FEATURE_SH_STANDALONE_SHELL 219config FEATURE_SH_STANDALONE_SHELL
220 bool "Standalone shell" 220 bool "Standalone shell"
221 default n 221 default n
222 depends on CONFIG_MSH || CONFIG_LASH || CONFIG_HUSH || CONFIG_ASH 222 depends on MSH || LASH || HUSH || ASH
223 help 223 help
224 This option causes the selected busybox shell to use busybox applets 224 This option causes the selected busybox shell to use busybox applets
225 in preference to executables in the PATH whenever possible. For 225 in preference to executables in the PATH whenever possible. For
@@ -240,53 +240,53 @@ config CONFIG_FEATURE_SH_STANDALONE_SHELL
240 that exact location with that exact name, this option will not work at 240 that exact location with that exact name, this option will not work at
241 all. 241 all.
242 242
243config CONFIG_FEATURE_COMMAND_EDITING 243config FEATURE_COMMAND_EDITING
244 bool "Command line editing" 244 bool "Command line editing"
245 default n 245 default n
246 depends on CONFIG_MSH || CONFIG_LASH || CONFIG_HUSH || CONFIG_ASH 246 depends on MSH || LASH || HUSH || ASH
247 help 247 help
248 Enable command editing in shell. 248 Enable command editing in shell.
249 249
250config CONFIG_FEATURE_COMMAND_EDITING_VI 250config FEATURE_COMMAND_EDITING_VI
251 bool "vi-style line editing commands" 251 bool "vi-style line editing commands"
252 default n 252 default n
253 depends on CONFIG_FEATURE_COMMAND_EDITING 253 depends on FEATURE_COMMAND_EDITING
254 help 254 help
255 Enable vi-style line editing in the shell. This mode can be 255 Enable vi-style line editing in the shell. This mode can be
256 turned on and off with "set -o vi" and "set +o vi". 256 turned on and off with "set -o vi" and "set +o vi".
257 257
258config CONFIG_FEATURE_COMMAND_HISTORY 258config FEATURE_COMMAND_HISTORY
259 int "History size" 259 int "History size"
260 default 15 260 default 15
261 depends on CONFIG_FEATURE_COMMAND_EDITING 261 depends on FEATURE_COMMAND_EDITING
262 help 262 help
263 Specify command history size in shell. 263 Specify command history size in shell.
264 264
265config CONFIG_FEATURE_COMMAND_SAVEHISTORY 265config FEATURE_COMMAND_SAVEHISTORY
266 bool "History saving" 266 bool "History saving"
267 default n 267 default n
268 depends on CONFIG_ASH && CONFIG_FEATURE_COMMAND_EDITING 268 depends on ASH && FEATURE_COMMAND_EDITING
269 help 269 help
270 Enable history saving in ash shell. 270 Enable history saving in ash shell.
271 271
272config CONFIG_FEATURE_COMMAND_TAB_COMPLETION 272config FEATURE_COMMAND_TAB_COMPLETION
273 bool "Tab completion" 273 bool "Tab completion"
274 default n 274 default n
275 depends on CONFIG_FEATURE_COMMAND_EDITING 275 depends on FEATURE_COMMAND_EDITING
276 help 276 help
277 Enable tab completion in shell. 277 Enable tab completion in shell.
278 278
279config CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION 279config FEATURE_COMMAND_USERNAME_COMPLETION
280 bool "Username completion" 280 bool "Username completion"
281 default n 281 default n
282 depends on CONFIG_FEATURE_COMMAND_TAB_COMPLETION 282 depends on FEATURE_COMMAND_TAB_COMPLETION
283 help 283 help
284 Enable username completion in shell. 284 Enable username completion in shell.
285 285
286config CONFIG_FEATURE_SH_FANCY_PROMPT 286config FEATURE_SH_FANCY_PROMPT
287 bool "Fancy shell prompts" 287 bool "Fancy shell prompts"
288 default n 288 default n
289 depends on CONFIG_FEATURE_COMMAND_EDITING 289 depends on FEATURE_COMMAND_EDITING
290 help 290 help
291 Setting this option allows for prompts to use things like \w and 291 Setting this option allows for prompts to use things like \w and
292 \$ and also using escape codes. 292 \$ and also using escape codes.
diff --git a/shell/Kbuild b/shell/Kbuild
new file mode 100644
index 000000000..eb0199ee2
--- /dev/null
+++ b/shell/Kbuild
@@ -0,0 +1,12 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_ASH) += ash.o
9lib-$(CONFIG_HUSH) += hush.o
10lib-$(CONFIG_LASH) += lash.o
11lib-$(CONFIG_MSH) += msh.o
12lib-$(CONFIG_FEATURE_COMMAND_EDITING) += cmdedit.o
diff --git a/shell/Makefile b/shell/Makefile
deleted file mode 100644
index 9590f524e..000000000
--- a/shell/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/shell
14SHELL_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
23
diff --git a/shell/Makefile.in b/shell/Makefile.in
deleted file mode 100644
index fcd93f345..000000000
--- a/shell/Makefile.in
+++ /dev/null
@@ -1,33 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7SHELL_AR:=shell.a
8ifndef $(SHELL_DIR)
9SHELL_DIR:=$(top_builddir)/shell/
10endif
11srcdir=$(top_srcdir)/shell
12
13SHELLT-y:=
14SHELLT-$(CONFIG_ASH) += ash.o
15SHELLT-$(CONFIG_HUSH) += hush.o
16SHELLT-$(CONFIG_LASH) += lash.o
17SHELLT-$(CONFIG_MSH) += msh.o
18SHELLT-$(CONFIG_FEATURE_COMMAND_EDITING) += cmdedit.o
19
20ifneq ($(strip $(SHELLT-y)),)
21libraries-y+=$(SHELL_DIR)$(SHELL_AR)
22endif
23
24SHELLT_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(SHELLT-y))
25SHELLT_SRC-a:=$(wildcard $(srcdir)/*.c)
26APPLET_SRC-y+=$(SHELLT_SRC-y)
27APPLET_SRC-a+=$(SHELLT_SRC-a)
28
29$(SHELL_DIR)$(SHELL_AR): $(patsubst %,$(SHELL_DIR)%, $(SHELLT-y))
30 $(do_ar)
31
32$(SHELL_DIR)%.o: $(srcdir)/%.c
33 $(compile.c)
diff --git a/shell/ash.c b/shell/ash.c
index 0d9fa7fe2..3564044b2 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -81,8 +81,6 @@
81#include <time.h> 81#include <time.h>
82#include <fnmatch.h> 82#include <fnmatch.h>
83 83
84#include "pwd_.h"
85
86#ifdef CONFIG_ASH_JOB_CONTROL 84#ifdef CONFIG_ASH_JOB_CONTROL
87#define JOBS 1 85#define JOBS 1
88#else 86#else
diff --git a/shell/cmdedit.c b/shell/cmdedit.c
index a9fc84798..7b4d46511 100644
--- a/shell/cmdedit.c
+++ b/shell/cmdedit.c
@@ -79,11 +79,6 @@
79#define CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR 79#define CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
80#endif 80#endif
81 81
82#ifdef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
83#include "pwd_.h"
84#endif /* advanced FEATURES */
85
86
87/* Maximum length of the linked list for the command line history */ 82/* Maximum length of the linked list for the command line history */
88#ifndef CONFIG_FEATURE_COMMAND_HISTORY 83#ifndef CONFIG_FEATURE_COMMAND_HISTORY
89#define MAX_HISTORY 15 84#define MAX_HISTORY 15
diff --git a/sysklogd/Config.in b/sysklogd/Config.in
index 399315208..9875b3c12 100644
--- a/sysklogd/Config.in
+++ b/sysklogd/Config.in
@@ -5,7 +5,7 @@
5 5
6menu "System Logging Utilities" 6menu "System Logging Utilities"
7 7
8config CONFIG_SYSLOGD 8config SYSLOGD
9 bool "syslogd" 9 bool "syslogd"
10 default n 10 default n
11 help 11 help
@@ -20,18 +20,18 @@ config CONFIG_SYSLOGD
20 wrong. And something almost always will go wrong if 20 wrong. And something almost always will go wrong if
21 you wait long enough.... 21 you wait long enough....
22 22
23config CONFIG_FEATURE_ROTATE_LOGFILE 23config FEATURE_ROTATE_LOGFILE
24 bool "Rotate message files" 24 bool "Rotate message files"
25 default n 25 default n
26 depends on CONFIG_SYSLOGD 26 depends on SYSLOGD
27 help 27 help
28 This enables syslogd to rotate the message files 28 This enables syslogd to rotate the message files
29 on his own. No need to use an external rotatescript. 29 on his own. No need to use an external rotatescript.
30 30
31config CONFIG_FEATURE_REMOTE_LOG 31config FEATURE_REMOTE_LOG
32 bool "Remote Log support" 32 bool "Remote Log support"
33 default n 33 default n
34 depends on CONFIG_SYSLOGD 34 depends on SYSLOGD
35 help 35 help
36 When you enable this feature, the syslogd utility can 36 When you enable this feature, the syslogd utility can
37 be used to send system log messages to another system 37 be used to send system log messages to another system
@@ -42,10 +42,10 @@ config CONFIG_FEATURE_REMOTE_LOG
42 measure to prevent system logs from being tampered with 42 measure to prevent system logs from being tampered with
43 by an intruder. 43 by an intruder.
44 44
45config CONFIG_FEATURE_IPC_SYSLOG 45config FEATURE_IPC_SYSLOG
46 bool "Circular Buffer support" 46 bool "Circular Buffer support"
47 default n 47 default n
48 depends on CONFIG_SYSLOGD 48 depends on SYSLOGD
49 help 49 help
50 When you enable this feature, the syslogd utility will 50 When you enable this feature, the syslogd utility will
51 use a circular buffer to record system log messages. 51 use a circular buffer to record system log messages.
@@ -56,28 +56,28 @@ config CONFIG_FEATURE_IPC_SYSLOG
56 entire filesystem, which may cause your system to 56 entire filesystem, which may cause your system to
57 break badly. 57 break badly.
58 58
59config CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE 59config FEATURE_IPC_SYSLOG_BUFFER_SIZE
60 int " Circular buffer size in Kbytes (minimum 4KB)" 60 int " Circular buffer size in Kbytes (minimum 4KB)"
61 default 16 61 default 16
62 depends on CONFIG_FEATURE_IPC_SYSLOG 62 depends on FEATURE_IPC_SYSLOG
63 help 63 help
64 This option sets the size of the circular buffer 64 This option sets the size of the circular buffer
65 used to record system log messages. 65 used to record system log messages.
66 66
67config CONFIG_LOGREAD 67config LOGREAD
68 bool "logread" 68 bool "logread"
69 default y 69 default y
70 depends on CONFIG_FEATURE_IPC_SYSLOG 70 depends on FEATURE_IPC_SYSLOG
71 help 71 help
72 If you enabled Circular Buffer support, you almost 72 If you enabled Circular Buffer support, you almost
73 certainly want to enable this feature as well. This 73 certainly want to enable this feature as well. This
74 utility will allow you to read the messages that are 74 utility will allow you to read the messages that are
75 stored in the syslogd circular buffer. 75 stored in the syslogd circular buffer.
76 76
77config CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING 77config FEATURE_LOGREAD_REDUCED_LOCKING
78 bool "logread double buffering" 78 bool "logread double buffering"
79 default n 79 default n
80 depends on CONFIG_LOGREAD 80 depends on LOGREAD
81 help 81 help
82 'logread' ouput to slow serial terminals can have 82 'logread' ouput to slow serial terminals can have
83 side effects on syslog because of the semaphore. 83 side effects on syslog because of the semaphore.
@@ -85,11 +85,11 @@ config CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING
85 from circular buffer, minimizing semaphore 85 from circular buffer, minimizing semaphore
86 contention at some minor memory expense. 86 contention at some minor memory expense.
87 87
88config CONFIG_KLOGD 88config KLOGD
89 bool "klogd" 89 bool "klogd"
90 default n 90 default n
91 depends on CONFIG_SYSLOGD 91 depends on SYSLOGD
92 select CONFIG_FEATURE_SYSLOG 92 select FEATURE_SYSLOG
93 help 93 help
94 klogd is a utility which intercepts and logs all 94 klogd is a utility which intercepts and logs all
95 messages from the Linux kernel and sends the messages 95 messages from the Linux kernel and sends the messages
@@ -97,10 +97,10 @@ config CONFIG_KLOGD
97 you wish to record the messages produced by the kernel, 97 you wish to record the messages produced by the kernel,
98 you should enable this option. 98 you should enable this option.
99 99
100config CONFIG_LOGGER 100config LOGGER
101 bool "logger" 101 bool "logger"
102 default n 102 default n
103 select CONFIG_FEATURE_SYSLOG 103 select FEATURE_SYSLOG
104 help 104 help
105 The logger utility allows you to send arbitrary text 105 The logger utility allows you to send arbitrary text
106 messages to the system log (i.e. the 'syslogd' utility) so 106 messages to the system log (i.e. the 'syslogd' utility) so
diff --git a/sysklogd/Kbuild b/sysklogd/Kbuild
new file mode 100644
index 000000000..0d5b2b929
--- /dev/null
+++ b/sysklogd/Kbuild
@@ -0,0 +1,11 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_KLOGD) += klogd.o
9lib-$(CONFIG_LOGGER) += logger.o
10lib-$(CONFIG_LOGREAD) += logread.o
11lib-$(CONFIG_SYSLOGD) += syslogd.o
diff --git a/sysklogd/Makefile b/sysklogd/Makefile
deleted file mode 100644
index 0ae4f1d35..000000000
--- a/sysklogd/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/sysklogd
14SYSKLOGD_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
diff --git a/sysklogd/Makefile.in b/sysklogd/Makefile.in
deleted file mode 100644
index 83f77be90..000000000
--- a/sysklogd/Makefile.in
+++ /dev/null
@@ -1,32 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7SYSKLOGD_AR:=sysklogd.a
8ifndef $(SYSKLOGD_DIR)
9SYSKLOGD_DIR:=$(top_builddir)/sysklogd/
10endif
11srcdir=$(top_srcdir)/sysklogd
12
13SYSKLOGD-y:=
14SYSKLOGD-$(CONFIG_KLOGD) += klogd.o
15SYSKLOGD-$(CONFIG_LOGGER) += logger.o
16SYSKLOGD-$(CONFIG_LOGREAD) += logread.o
17SYSKLOGD-$(CONFIG_SYSLOGD) += syslogd.o
18
19ifneq ($(strip $(SYSKLOGD-y)),)
20libraries-y+=$(SYSKLOGD_DIR)$(SYSKLOGD_AR)
21endif
22
23SYSKLOGD_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(SYSKLOGD-y))
24SYSKLOGD_SRC-a:=$(wildcard $(srcdir)/*.c)
25APPLET_SRC-y+=$(SYSKLOGD_SRC-y)
26APPLET_SRC-a+=$(SYSKLOGD_SRC-a)
27
28$(SYSKLOGD_DIR)$(SYSKLOGD_AR): $(patsubst %,$(SYSKLOGD_DIR)%, $(SYSKLOGD-y))
29 $(do_ar)
30
31$(SYSKLOGD_DIR)%.o: $(srcdir)/%.c
32 $(compile.c)
diff --git a/util-linux/Config.in b/util-linux/Config.in
index a215e250f..a6640e19d 100644
--- a/util-linux/Config.in
+++ b/util-linux/Config.in
@@ -5,7 +5,7 @@
5 5
6menu "Linux System Utilities" 6menu "Linux System Utilities"
7 7
8config CONFIG_DMESG 8config DMESG
9 bool "dmesg" 9 bool "dmesg"
10 default n 10 default n
11 help 11 help
@@ -17,10 +17,10 @@ config CONFIG_DMESG
17 are also logged to the system console. Enable this option if you 17 are also logged to the system console. Enable this option if you
18 wish to enable the 'dmesg' utility. 18 wish to enable the 'dmesg' utility.
19 19
20config CONFIG_FEATURE_DMESG_PRETTY 20config FEATURE_DMESG_PRETTY
21 bool "pretty dmesg output" 21 bool "pretty dmesg output"
22 default y 22 default y
23 depends on CONFIG_DMESG 23 depends on DMESG
24 help 24 help
25 If you wish to scrub the syslog level from the output, say 'Y' here. 25 If you wish to scrub the syslog level from the output, say 'Y' here.
26 The syslog level is a string prefixed to every line with the form "<#>". 26 The syslog level is a string prefixed to every line with the form "<#>".
@@ -37,7 +37,7 @@ config CONFIG_FEATURE_DMESG_PRETTY
37 <6>BIOS-provided physical RAM map: 37 <6>BIOS-provided physical RAM map:
38 <6> BIOS-e820: 0000000000000000 - 000000000009f000 (usable) 38 <6> BIOS-e820: 0000000000000000 - 000000000009f000 (usable)
39 39
40config CONFIG_FBSET 40config FBSET
41 bool "fbset" 41 bool "fbset"
42 default n 42 default n
43 help 43 help
@@ -46,26 +46,26 @@ config CONFIG_FBSET
46 interface to access a graphics display. Enable this option 46 interface to access a graphics display. Enable this option
47 if you wish to enable the 'fbset' utility. 47 if you wish to enable the 'fbset' utility.
48 48
49config CONFIG_FEATURE_FBSET_FANCY 49config FEATURE_FBSET_FANCY
50 bool "Turn on extra fbset options" 50 bool "Turn on extra fbset options"
51 default n 51 default n
52 depends on CONFIG_FBSET 52 depends on FBSET
53 help 53 help
54 This option enables extended fbset options, allowing one to set the 54 This option enables extended fbset options, allowing one to set the
55 framebuffer size, color depth, etc. interface to access a graphics 55 framebuffer size, color depth, etc. interface to access a graphics
56 display. Enable this option if you wish to enable extended fbset 56 display. Enable this option if you wish to enable extended fbset
57 options. 57 options.
58 58
59config CONFIG_FEATURE_FBSET_READMODE 59config FEATURE_FBSET_READMODE
60 bool "Turn on fbset readmode support" 60 bool "Turn on fbset readmode support"
61 default n 61 default n
62 depends on CONFIG_FBSET 62 depends on FBSET
63 help 63 help
64 This option allows fbset to read the video mode database stored by 64 This option allows fbset to read the video mode database stored by
65 default as /etc/fb.modes, which can be used to set frame buffer 65 default as /etc/fb.modes, which can be used to set frame buffer
66 device to pre-defined video modes. 66 device to pre-defined video modes.
67 67
68config CONFIG_FDFLUSH 68config FDFLUSH
69 bool "fdflush" 69 bool "fdflush"
70 default n 70 default n
71 help 71 help
@@ -77,13 +77,13 @@ config CONFIG_FDFLUSH
77 you change a disk. Most people have working hardware and can safely 77 you change a disk. Most people have working hardware and can safely
78 leave this disabled. 78 leave this disabled.
79 79
80config CONFIG_FDFORMAT 80config FDFORMAT
81 bool "fdformat" 81 bool "fdformat"
82 default n 82 default n
83 help 83 help
84 fdformat is used to low-level format a floppy disk. 84 fdformat is used to low-level format a floppy disk.
85 85
86config CONFIG_FDISK 86config FDISK
87 bool "fdisk" 87 bool "fdisk"
88 default n 88 default n
89 help 89 help
@@ -95,62 +95,62 @@ config CONFIG_FDISK
95config FDISK_SUPPORT_LARGE_DISKS 95config FDISK_SUPPORT_LARGE_DISKS
96 bool "support over 4GB disks" 96 bool "support over 4GB disks"
97 default y 97 default y
98 depends on CONFIG_FDISK 98 depends on FDISK
99 help 99 help
100 Enable this option to support large disks > 4GB. 100 Enable this option to support large disks > 4GB.
101 101
102config CONFIG_FEATURE_FDISK_WRITABLE 102config FEATURE_FDISK_WRITABLE
103 bool "Write support" 103 bool "Write support"
104 default y 104 default y
105 depends on CONFIG_FDISK 105 depends on FDISK
106 help 106 help
107 Enabling this option allows you to create or change a partition table 107 Enabling this option allows you to create or change a partition table
108 and write those changes out to disk. If you leave this option 108 and write those changes out to disk. If you leave this option
109 disabled, you will only be able to view the partition table. 109 disabled, you will only be able to view the partition table.
110 110
111config CONFIG_FEATURE_AIX_LABEL 111config FEATURE_AIX_LABEL
112 bool "Support AIX disklabels" 112 bool "Support AIX disklabels"
113 default n 113 default n
114 depends on CONFIG_FDISK && CONFIG_FEATURE_FDISK_WRITABLE 114 depends on FDISK && FEATURE_FDISK_WRITABLE
115 help 115 help
116 Enabling this option allows you to create or change AIX disklabels. 116 Enabling this option allows you to create or change AIX disklabels.
117 Most people can safely leave this option disabled. 117 Most people can safely leave this option disabled.
118 118
119config CONFIG_FEATURE_SGI_LABEL 119config FEATURE_SGI_LABEL
120 bool "Support SGI disklabels" 120 bool "Support SGI disklabels"
121 default n 121 default n
122 depends on CONFIG_FDISK && CONFIG_FEATURE_FDISK_WRITABLE 122 depends on FDISK && FEATURE_FDISK_WRITABLE
123 help 123 help
124 Enabling this option allows you to create or change SGI disklabels. 124 Enabling this option allows you to create or change SGI disklabels.
125 Most people can safely leave this option disabled. 125 Most people can safely leave this option disabled.
126 126
127config CONFIG_FEATURE_SUN_LABEL 127config FEATURE_SUN_LABEL
128 bool "Support SUN disklabels" 128 bool "Support SUN disklabels"
129 default n 129 default n
130 depends on CONFIG_FDISK && CONFIG_FEATURE_FDISK_WRITABLE 130 depends on FDISK && FEATURE_FDISK_WRITABLE
131 help 131 help
132 Enabling this option allows you to create or change SUN disklabels. 132 Enabling this option allows you to create or change SUN disklabels.
133 Most people can safely leave this option disabled. 133 Most people can safely leave this option disabled.
134 134
135config CONFIG_FEATURE_OSF_LABEL 135config FEATURE_OSF_LABEL
136 bool "Support BSD disklabels" 136 bool "Support BSD disklabels"
137 default n 137 default n
138 depends on CONFIG_FDISK && CONFIG_FEATURE_FDISK_WRITABLE 138 depends on FDISK && FEATURE_FDISK_WRITABLE
139 help 139 help
140 Enabling this option allows you to create or change BSD disklabels 140 Enabling this option allows you to create or change BSD disklabels
141 and define and edit BSD disk slices. 141 and define and edit BSD disk slices.
142 142
143config CONFIG_FEATURE_FDISK_ADVANCED 143config FEATURE_FDISK_ADVANCED
144 bool "Support expert mode" 144 bool "Support expert mode"
145 default n 145 default n
146 depends on CONFIG_FDISK && CONFIG_FEATURE_FDISK_WRITABLE 146 depends on FDISK && FEATURE_FDISK_WRITABLE
147 help 147 help
148 Enabling this option allows you to do terribly unsafe things like 148 Enabling this option allows you to do terribly unsafe things like
149 define arbitrary drive geometry, move the beginning of data in a 149 define arbitrary drive geometry, move the beginning of data in a
150 partition, and similarly evil things. Unless you have a very good 150 partition, and similarly evil things. Unless you have a very good
151 reason you would be wise to leave this disabled. 151 reason you would be wise to leave this disabled.
152 152
153config CONFIG_FREERAMDISK 153config FREERAMDISK
154 bool "freeramdisk" 154 bool "freeramdisk"
155 default n 155 default n
156 help 156 help
@@ -161,7 +161,7 @@ config CONFIG_FREERAMDISK
161 ramdisk. If you have no use for freeing memory from a ramdisk, leave 161 ramdisk. If you have no use for freeing memory from a ramdisk, leave
162 this disabled. 162 this disabled.
163 163
164config CONFIG_FSCK_MINIX 164config FSCK_MINIX
165 bool "fsck_minix" 165 bool "fsck_minix"
166 default n 166 default n
167 help 167 help
@@ -172,7 +172,7 @@ config CONFIG_FSCK_MINIX
172 check for and attempt to repair any corruption that occurs to a minix 172 check for and attempt to repair any corruption that occurs to a minix
173 filesystem. 173 filesystem.
174 174
175config CONFIG_MKFS_MINIX 175config MKFS_MINIX
176 bool "mkfs_minix" 176 bool "mkfs_minix"
177 default n 177 default n
178 help 178 help
@@ -181,18 +181,18 @@ config CONFIG_MKFS_MINIX
181 this utility will do the job for you. 181 this utility will do the job for you.
182 182
183comment "Minix filesystem support" 183comment "Minix filesystem support"
184 depends on CONFIG_FSCK_MINIX || CONFIG_MKFS_MINIX 184 depends on FSCK_MINIX || MKFS_MINIX
185 185
186config CONFIG_FEATURE_MINIX2 186config FEATURE_MINIX2
187 bool "Support Minix fs v2 (fsck_minix/mkfs_minix)" 187 bool "Support Minix fs v2 (fsck_minix/mkfs_minix)"
188 default y 188 default y
189 depends on CONFIG_FSCK_MINIX || CONFIG_MKFS_MINIX 189 depends on FSCK_MINIX || MKFS_MINIX
190 help 190 help
191 If you wish to be able to create version 2 minix filesystems, enable this. 191 If you wish to be able to create version 2 minix filesystems, enable this.
192 If you enabled 'mkfs_minix' then you almost certainly want to be using the 192 If you enabled 'mkfs_minix' then you almost certainly want to be using the
193 version 2 filesystem support. 193 version 2 filesystem support.
194 194
195config CONFIG_GETOPT 195config GETOPT
196 bool "getopt" 196 bool "getopt"
197 default n 197 default n
198 help 198 help
@@ -203,14 +203,14 @@ config CONFIG_GETOPT
203 written by others, this utility may be for you. Most people will 203 written by others, this utility may be for you. Most people will
204 wisely leave this disabled. 204 wisely leave this disabled.
205 205
206config CONFIG_HEXDUMP 206config HEXDUMP
207 bool "hexdump" 207 bool "hexdump"
208 default n 208 default n
209 help 209 help
210 The hexdump utility is used to display binary data in a readable 210 The hexdump utility is used to display binary data in a readable
211 way that is comparable to the output from most hex editors. 211 way that is comparable to the output from most hex editors.
212 212
213config CONFIG_HWCLOCK 213config HWCLOCK
214 bool "hwclock" 214 bool "hwclock"
215 default n 215 default n
216 help 216 help
@@ -219,19 +219,19 @@ config CONFIG_HWCLOCK
219 shutdown in the hardware clock, so the hardware will keep the 219 shutdown in the hardware clock, so the hardware will keep the
220 correct time when Linux is _not_ running. 220 correct time when Linux is _not_ running.
221 221
222config CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS 222config FEATURE_HWCLOCK_LONG_OPTIONS
223 bool "Support long options (--hctosys,...)" 223 bool "Support long options (--hctosys,...)"
224 default n 224 default n
225 depends on CONFIG_HWCLOCK && CONFIG_GETOPT_LONG 225 depends on HWCLOCK && GETOPT_LONG
226 help 226 help
227 By default, the hwclock utility only uses short options. If you 227 By default, the hwclock utility only uses short options. If you
228 are overly fond of its long options, such as --hctosys, --utc, etc) 228 are overly fond of its long options, such as --hctosys, --utc, etc)
229 then enable this option. 229 then enable this option.
230 230
231config CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS 231config FEATURE_HWCLOCK_ADJTIME_FHS
232 bool "Use FHS /var/lib/hwclock/adjtime" 232 bool "Use FHS /var/lib/hwclock/adjtime"
233 default y 233 default y
234 depends on CONFIG_HWCLOCK 234 depends on HWCLOCK
235 help 235 help
236 Starting with FHS 2.3, the adjtime state file is supposed to exist 236 Starting with FHS 2.3, the adjtime state file is supposed to exist
237 at /var/lib/hwclock/adjtime instead of /etc/adjtime. If you wish 237 at /var/lib/hwclock/adjtime instead of /etc/adjtime. If you wish
@@ -240,24 +240,24 @@ config CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS
240 240
241 http://www.pathname.com/fhs/pub/fhs-2.3.html#VARLIBHWCLOCKSTATEDIRECTORYFORHWCLO 241 http://www.pathname.com/fhs/pub/fhs-2.3.html#VARLIBHWCLOCKSTATEDIRECTORYFORHWCLO
242 242
243config CONFIG_IPCRM 243config IPCRM
244 bool "ipcrm" 244 bool "ipcrm"
245 default n 245 default n
246 select CONFIG_FEATURE_SUID 246 select FEATURE_SUID
247 help 247 help
248 The ipcrm utility allows the removal of System V interprocess 248 The ipcrm utility allows the removal of System V interprocess
249 communication (IPC) objects and the associated data structures 249 communication (IPC) objects and the associated data structures
250 from the system. 250 from the system.
251 251
252config CONFIG_IPCS 252config IPCS
253 bool "ipcs" 253 bool "ipcs"
254 default n 254 default n
255 select CONFIG_FEATURE_SUID 255 select FEATURE_SUID
256 help 256 help
257 The ipcs utility is used to provide information on the currently 257 The ipcs utility is used to provide information on the currently
258 allocated System V interprocess (IPC) objects in the system. 258 allocated System V interprocess (IPC) objects in the system.
259 259
260config CONFIG_LOSETUP 260config LOSETUP
261 bool "losetup" 261 bool "losetup"
262 default n 262 default n
263 help 263 help
@@ -265,7 +265,7 @@ config CONFIG_LOSETUP
265 file or block device, and to query the status of a loop device. This 265 file or block device, and to query the status of a loop device. This
266 version does not currently support enabling data encryption. 266 version does not currently support enabling data encryption.
267 267
268config CONFIG_MDEV 268config MDEV
269 bool "mdev" 269 bool "mdev"
270 default n 270 default n
271 help 271 help
@@ -274,10 +274,10 @@ config CONFIG_MDEV
274 have it handle hotplug events afterwards. Device names are taken 274 have it handle hotplug events afterwards. Device names are taken
275 from sysfs. 275 from sysfs.
276 276
277config CONFIG_FEATURE_MDEV_CONF 277config FEATURE_MDEV_CONF
278 bool "Support /etc/mdev.conf" 278 bool "Support /etc/mdev.conf"
279 default n 279 default n
280 depends on CONFIG_MDEV 280 depends on MDEV
281 help 281 help
282 The mdev config file contains lines that look like: 282 The mdev config file contains lines that look like:
283 283
@@ -289,10 +289,10 @@ config CONFIG_FEATURE_MDEV_CONF
289 entry is matched, devices are created with default 0:0 660. (Make 289 entry is matched, devices are created with default 0:0 660. (Make
290 the last line match .* to override this.) 290 the last line match .* to override this.)
291 291
292config CONFIG_FEATURE_MDEV_EXEC 292config FEATURE_MDEV_EXEC
293 bool "Support command execution at device addition/removal" 293 bool "Support command execution at device addition/removal"
294 default n 294 default n
295 depends on CONFIG_FEATURE_MDEV_CONF 295 depends on FEATURE_MDEV_CONF
296 help 296 help
297 This adds support for an optional field to /etc/mdev.conf, consisting 297 This adds support for an optional field to /etc/mdev.conf, consisting
298 of a special character and a command line to run after creating the 298 of a special character and a command line to run after creating the
@@ -310,7 +310,7 @@ config CONFIG_FEATURE_MDEV_EXEC
310 Commands are executed via system() so you need /bin/sh, meaning you 310 Commands are executed via system() so you need /bin/sh, meaning you
311 probably want to select a default shell in the Shells menu. 311 probably want to select a default shell in the Shells menu.
312 312
313config CONFIG_MKSWAP 313config MKSWAP
314 bool "mkswap" 314 bool "mkswap"
315 default n 315 default n
316 help 316 help
@@ -323,17 +323,17 @@ config CONFIG_MKSWAP
323 Once you have created swap space using 'mkswap' you need to enable 323 Once you have created swap space using 'mkswap' you need to enable
324 the swap space using the 'swapon' utility. 324 the swap space using the 'swapon' utility.
325 325
326config CONFIG_FEATURE_MKSWAP_V0 326config FEATURE_MKSWAP_V0
327 bool "version 0 support" 327 bool "version 0 support"
328 default n 328 default n
329 depends on CONFIG_MKSWAP 329 depends on MKSWAP
330# depends on CONFIG_MKSWAP && CONFIG_DEPRECATED 330# depends on MKSWAP && DEPRECATED
331 help 331 help
332 Enable support for the old v0 style. 332 Enable support for the old v0 style.
333 If your kernel is older than 2.1.117, then v0 support is the 333 If your kernel is older than 2.1.117, then v0 support is the
334 only option. 334 only option.
335 335
336config CONFIG_MORE 336config MORE
337 bool "more" 337 bool "more"
338 default n 338 default n
339 help 339 help
@@ -343,10 +343,10 @@ config CONFIG_MORE
343 you will probably find this utility very helpful. If you don't have 343 you will probably find this utility very helpful. If you don't have
344 any need to reading text files, you can leave this disabled. 344 any need to reading text files, you can leave this disabled.
345 345
346config CONFIG_FEATURE_USE_TERMIOS 346config FEATURE_USE_TERMIOS
347 bool "Use termios to manipulate the screen" 347 bool "Use termios to manipulate the screen"
348 default y 348 default y
349 depends on CONFIG_MORE 349 depends on MORE
350 help 350 help
351 This option allows utilities such as 'more' and 'top' to determine 351 This option allows utilities such as 'more' and 'top' to determine
352 the size of the screen. If you leave this disabled, your utilities 352 the size of the screen. If you leave this disabled, your utilities
@@ -354,7 +354,7 @@ config CONFIG_FEATURE_USE_TERMIOS
354 will be unable to determine the current screen size, and will be 354 will be unable to determine the current screen size, and will be
355 unable to move the cursor. 355 unable to move the cursor.
356 356
357config CONFIG_MOUNT 357config MOUNT
358 bool "mount" 358 bool "mount"
359 default n 359 default n
360 help 360 help
@@ -365,23 +365,23 @@ config CONFIG_MOUNT
365 NFS filesystems. Most people using BusyBox will also want to enable 365 NFS filesystems. Most people using BusyBox will also want to enable
366 the 'mount' utility. 366 the 'mount' utility.
367 367
368config CONFIG_FEATURE_MOUNT_NFS 368config FEATURE_MOUNT_NFS
369 bool "Support mounting NFS file systems" 369 bool "Support mounting NFS file systems"
370 default n 370 default n
371 depends on CONFIG_MOUNT 371 depends on MOUNT
372 select CONFIG_FEATURE_SYSLOG 372 select FEATURE_SYSLOG
373 help 373 help
374 Enable mounting of NFS file systems. 374 Enable mounting of NFS file systems.
375 375
376config CONFIG_FEATURE_MOUNT_CIFS 376config FEATURE_MOUNT_CIFS
377 bool "Support mounting CIFS/SMB file systems" 377 bool "Support mounting CIFS/SMB file systems"
378 default n 378 default n
379 depends on CONFIG_MOUNT 379 depends on MOUNT
380 help 380 help
381 Enable support for samba mounts. 381 Enable support for samba mounts.
382 382
383config CONFIG_FEATURE_MOUNT_FLAGS 383config FEATURE_MOUNT_FLAGS
384 depends on CONFIG_MOUNT 384 depends on MOUNT
385 bool "Support lots of -o flags in mount" 385 bool "Support lots of -o flags in mount"
386 default y 386 default y
387 help 387 help
@@ -390,14 +390,14 @@ config CONFIG_FEATURE_MOUNT_FLAGS
390 noatime, diratime, nodiratime, loud, bind, move, shared, slave, 390 noatime, diratime, nodiratime, loud, bind, move, shared, slave,
391 private, unbindable, rshared, rslave, rprivate, and runbindable. 391 private, unbindable, rshared, rslave, rprivate, and runbindable.
392 392
393config CONFIG_FEATURE_MOUNT_FSTAB 393config FEATURE_MOUNT_FSTAB
394 depends on CONFIG_MOUNT 394 depends on MOUNT
395 bool "Support /etc/fstab and -a" 395 bool "Support /etc/fstab and -a"
396 default y 396 default y
397 help 397 help
398 Support mount all and looking for files in /etc/fstab. 398 Support mount all and looking for files in /etc/fstab.
399 399
400config CONFIG_PIVOT_ROOT 400config PIVOT_ROOT
401 bool "pivot_root" 401 bool "pivot_root"
402 default n 402 default n
403 help 403 help
@@ -409,7 +409,7 @@ config CONFIG_PIVOT_ROOT
409 Note: This is for initrd in linux 2.4. Under initramfs (introduced 409 Note: This is for initrd in linux 2.4. Under initramfs (introduced
410 in linux 2.6) use switch_root instead. 410 in linux 2.6) use switch_root instead.
411 411
412config CONFIG_RDATE 412config RDATE
413 bool "rdate" 413 bool "rdate"
414 default n 414 default n
415 help 415 help
@@ -418,13 +418,13 @@ config CONFIG_RDATE
418 the RFC868 protocol, which is built into the inetd daemon on most 418 the RFC868 protocol, which is built into the inetd daemon on most
419 systems. 419 systems.
420 420
421config CONFIG_READPROFILE 421config READPROFILE
422 bool "readprofile" 422 bool "readprofile"
423 default n 423 default n
424 help 424 help
425 This allows you to parse /proc/profile for basic profiling. 425 This allows you to parse /proc/profile for basic profiling.
426 426
427config CONFIG_SETARCH 427config SETARCH
428 bool "setarch" 428 bool "setarch"
429 default n 429 default n
430 help 430 help
@@ -433,7 +433,7 @@ config CONFIG_SETARCH
433 this util on a system that supports both 64bit and 32bit userland 433 this util on a system that supports both 64bit and 32bit userland
434 (like amd64/x86, ppc64/ppc, sparc64/sparc, etc...). 434 (like amd64/x86, ppc64/ppc, sparc64/sparc, etc...).
435 435
436config CONFIG_SWAPONOFF 436config SWAPONOFF
437 bool "swaponoff" 437 bool "swaponoff"
438 default n 438 default n
439 help 439 help
@@ -444,7 +444,7 @@ config CONFIG_SWAPONOFF
444 space. If you are not using any swap space, you can leave this 444 space. If you are not using any swap space, you can leave this
445 option disabled. 445 option disabled.
446 446
447config CONFIG_SWITCH_ROOT 447config SWITCH_ROOT
448 bool "switch_root" 448 bool "switch_root"
449 default n 449 default n
450 help 450 help
@@ -463,7 +463,7 @@ config CONFIG_SWITCH_ROOT
463 and ending point for searching through the kernel's doubly linked 463 and ending point for searching through the kernel's doubly linked
464 list of active mount points. That's why. 464 list of active mount points. That's why.
465 465
466config CONFIG_UMOUNT 466config UMOUNT
467 bool "umount" 467 bool "umount"
468 default n 468 default n
469 help 469 help
@@ -472,20 +472,20 @@ config CONFIG_UMOUNT
472 the tool to use. If you enabled the 'mount' utility, you almost certainly 472 the tool to use. If you enabled the 'mount' utility, you almost certainly
473 also want to enable 'umount'. 473 also want to enable 'umount'.
474 474
475config CONFIG_FEATURE_UMOUNT_ALL 475config FEATURE_UMOUNT_ALL
476 bool "umount -a option" 476 bool "umount -a option"
477 default n 477 default n
478 depends on CONFIG_UMOUNT 478 depends on UMOUNT
479 help 479 help
480 Support -a option to unmount all currently mounted filesystems. 480 Support -a option to unmount all currently mounted filesystems.
481 481
482comment "Common options for mount/umount" 482comment "Common options for mount/umount"
483 depends on CONFIG_MOUNT || CONFIG_UMOUNT 483 depends on MOUNT || UMOUNT
484 484
485config CONFIG_FEATURE_MOUNT_LOOP 485config FEATURE_MOUNT_LOOP
486 bool "Support loopback mounts" 486 bool "Support loopback mounts"
487 default n 487 default n
488 depends on CONFIG_MOUNT || CONFIG_UMOUNT 488 depends on MOUNT || UMOUNT
489 help 489 help
490 Enabling this feature allows automatic mounting of files (containing 490 Enabling this feature allows automatic mounting of files (containing
491 filesystem images) via the linux kernel's loopback devices. The mount 491 filesystem images) via the linux kernel's loopback devices. The mount
@@ -498,10 +498,10 @@ config CONFIG_FEATURE_MOUNT_LOOP
498 specify an offset or cryptographic options to the loopback device. 498 specify an offset or cryptographic options to the loopback device.
499 (If you don't want umount to free the loop device, use "umount -D".) 499 (If you don't want umount to free the loop device, use "umount -D".)
500 500
501config CONFIG_FEATURE_MTAB_SUPPORT 501config FEATURE_MTAB_SUPPORT
502 bool "Support for the old /etc/mtab file" 502 bool "Support for the old /etc/mtab file"
503 default n 503 default n
504 depends on CONFIG_MOUNT || CONFIG_UMOUNT 504 depends on MOUNT || UMOUNT
505 help 505 help
506 Historically, Unix systems kept track of the currently mounted 506 Historically, Unix systems kept track of the currently mounted
507 partitions in the file "/etc/mtab". These days, the kernel exports 507 partitions in the file "/etc/mtab". These days, the kernel exports
diff --git a/util-linux/Kbuild b/util-linux/Kbuild
new file mode 100644
index 000000000..cc1d0e05d
--- /dev/null
+++ b/util-linux/Kbuild
@@ -0,0 +1,32 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:=
8lib-$(CONFIG_DMESG) +=dmesg.o
9lib-$(CONFIG_FBSET) +=fbset.o
10lib-$(CONFIG_FDFLUSH) +=freeramdisk.o
11lib-$(CONFIG_FDFORMAT) +=fdformat.o
12lib-$(CONFIG_FDISK) +=fdisk.o
13lib-$(CONFIG_FREERAMDISK) +=freeramdisk.o
14lib-$(CONFIG_FSCK_MINIX) +=fsck_minix.o
15lib-$(CONFIG_GETOPT) +=getopt.o
16lib-$(CONFIG_HEXDUMP) +=hexdump.o
17lib-$(CONFIG_HWCLOCK) +=hwclock.o
18lib-$(CONFIG_IPCRM) +=ipcrm.o
19lib-$(CONFIG_IPCS) +=ipcs.o
20lib-$(CONFIG_LOSETUP) +=losetup.o
21lib-$(CONFIG_MDEV) +=mdev.o
22lib-$(CONFIG_MKFS_MINIX) +=mkfs_minix.o
23lib-$(CONFIG_MKSWAP) +=mkswap.o
24lib-$(CONFIG_MORE) +=more.o
25lib-$(CONFIG_MOUNT) +=mount.o
26lib-$(CONFIG_PIVOT_ROOT) +=pivot_root.o
27lib-$(CONFIG_RDATE) +=rdate.o
28lib-$(CONFIG_READPROFILE) +=readprofile.o
29lib-$(CONFIG_SETARCH) +=setarch.o
30lib-$(CONFIG_SWAPONOFF) +=swaponoff.o
31lib-$(CONFIG_SWITCH_ROOT) +=switch_root.o
32lib-$(CONFIG_UMOUNT) +=umount.o
diff --git a/util-linux/Makefile b/util-linux/Makefile
deleted file mode 100644
index 9a53470a4..000000000
--- a/util-linux/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/util-linux
14UTILLINUX_DIR:=./
15include $(top_srcdir)/Rules.mak
16include $(top_builddir)/.config
17include Makefile.in
18all: $(libraries-y)
19-include $(top_builddir)/.depend
20
21clean:
22 rm -f *.o *.a $(AR_TARGET)
diff --git a/util-linux/Makefile.in b/util-linux/Makefile.in
deleted file mode 100644
index 3d6c96a35..000000000
--- a/util-linux/Makefile.in
+++ /dev/null
@@ -1,62 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7UTILLINUX_AR:=util-linux.a
8ifndef $(UTILLINUX_DIR)
9UTILLINUX_DIR:=$(top_builddir)/util-linux/
10endif
11srcdir=$(top_srcdir)/util-linux
12
13UTILLINUX-y:=
14UTILLINUX-$(CONFIG_DMESG) +=dmesg.o
15UTILLINUX-$(CONFIG_FBSET) +=fbset.o
16UTILLINUX-$(CONFIG_FDFLUSH) +=freeramdisk.o
17UTILLINUX-$(CONFIG_FDFORMAT) +=fdformat.o
18UTILLINUX-$(CONFIG_FDISK) +=fdisk.o
19UTILLINUX-$(CONFIG_FREERAMDISK) +=freeramdisk.o
20UTILLINUX-$(CONFIG_FSCK_MINIX) +=fsck_minix.o
21UTILLINUX-$(CONFIG_GETOPT) +=getopt.o
22UTILLINUX-$(CONFIG_HEXDUMP) +=hexdump.o
23UTILLINUX-$(CONFIG_HWCLOCK) +=hwclock.o
24UTILLINUX-$(CONFIG_IPCRM) +=ipcrm.o
25UTILLINUX-$(CONFIG_IPCS) +=ipcs.o
26UTILLINUX-$(CONFIG_LOSETUP) +=losetup.o
27UTILLINUX-$(CONFIG_MDEV) +=mdev.o
28UTILLINUX-$(CONFIG_MKFS_MINIX) +=mkfs_minix.o
29UTILLINUX-$(CONFIG_MKSWAP) +=mkswap.o
30UTILLINUX-$(CONFIG_MORE) +=more.o
31UTILLINUX-$(CONFIG_MOUNT) +=mount.o
32UTILLINUX-$(CONFIG_PIVOT_ROOT) +=pivot_root.o
33UTILLINUX-$(CONFIG_RDATE) +=rdate.o
34UTILLINUX-$(CONFIG_READPROFILE) +=readprofile.o
35UTILLINUX-$(CONFIG_SETARCH) +=setarch.o
36UTILLINUX-$(CONFIG_SWAPONOFF) +=swaponoff.o
37UTILLINUX-$(CONFIG_SWITCH_ROOT) +=switch_root.o
38UTILLINUX-$(CONFIG_UMOUNT) +=umount.o
39
40UTILLINUX-y:=$(sort $(UTILLINUX-y))
41
42ifneq ($(strip $(UTILLINUX-y)),)
43libraries-y+=$(UTILLINUX_DIR)$(UTILLINUX_AR)
44endif
45
46UTILLINUX_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(UTILLINUX-y))
47UTILLINUX_SRC-a:=$(wildcard $(srcdir)/*.c)
48APPLET_SRC-y+=$(UTILLINUX_SRC-y)
49APPLET_SRC-a+=$(UTILLINUX_SRC-a)
50
51$(UTILLINUX_DIR)$(UTILLINUX_AR): $(patsubst %,$(UTILLINUX_DIR)%, $(UTILLINUX-y))
52 $(do_ar)
53
54$(UTILLINUX_DIR)%.o: $(srcdir)/%.c
55 $(compile.c)
56
57ifneq ($(strip $(CONFIG_LFS)),y)
58ifeq ($(strip $(FDISK_SUPPORT_LARGE_DISKS)),y)
59$(UTILLINUX_DIR)fdisk.o: $(srcdir)/fdisk.c
60 $(compile.c) -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
61endif
62endif