├── .pc ├── .quilt_patches ├── .quilt_series ├── .version ├── 01-kconfig-kernel-to-buildroot.patch │ ├── .timestamp │ ├── confdata.c │ ├── gconf.glade │ ├── mconf.c │ ├── qconf.cc │ ├── zconf.tab.c_shipped │ └── zconf.y ├── 10-br-build-system.patch │ ├── .timestamp │ ├── Makefile.br │ └── foo.h ├── 100-kconfig-generic-env.patch │ ├── .timestamp │ ├── Makefile │ ├── conf.c │ ├── confdata.c │ ├── expr.h │ ├── gconf.glade │ ├── lkc.h │ ├── mconf.c │ ├── merge_config.sh │ ├── qconf.cc │ ├── zconf.tab.c_shipped │ └── zconf.y ├── 101-kconfig-build.patch │ ├── .timestamp │ ├── GNUmakefile │ ├── README │ └── config.sh ├── 11-use-mktemp-for-lxdialog.patch │ ├── .timestamp │ └── lxdialog │ │ └── check-lxdialog.sh ├── 12-fix-glade-file-path.patch │ ├── .timestamp │ └── gconf.c ├── 14-support-out-of-tree-config.patch │ ├── .timestamp │ ├── conf.c │ ├── confdata.c │ └── util.c ├── 15-fix-qconf-moc-rule.patch │ ├── .timestamp │ └── Makefile ├── 16-fix-space-to-de-select-options.patch │ ├── .timestamp │ └── lxdialog │ │ └── menubox.c └── applied-patches ├── GNUmakefile ├── Makefile ├── Makefile.br ├── POTFILES.in ├── README ├── README.buildroot ├── check.sh ├── conf.c ├── confdata.c ├── config.sh ├── expr.c ├── expr.h ├── foo.h ├── gconf.c ├── gconf.glade ├── images.c ├── kxgettext.c ├── list.h ├── lkc.h ├── lkc_proto.h ├── lxdialog ├── .gitignore ├── BIG.FAT.WARNING ├── check-lxdialog.sh ├── checklist.c ├── dialog.h ├── inputbox.c ├── menubox.c ├── textbox.c ├── util.c └── yesno.c ├── mconf.c ├── menu.c ├── merge_config.sh ├── nconf.c ├── nconf.gui.c ├── nconf.h ├── patches ├── 01-kconfig-kernel-to-buildroot.patch ├── 06-br-build-system-integration.patch ├── 10-br-build-system.patch ├── 100-kconfig-generic-env.patch ├── 101-kconfig-build.patch ├── 11-use-mktemp-for-lxdialog.patch ├── 12-fix-glade-file-path.patch ├── 14-support-out-of-tree-config.patch ├── 15-fix-qconf-moc-rule.patch ├── 16-fix-space-to-de-select-options.patch └── series ├── qconf.cc ├── qconf.h ├── streamline_config.pl ├── symbol.c ├── util.c ├── zconf.gperf ├── zconf.hash.c_shipped ├── zconf.l ├── zconf.lex.c_shipped ├── zconf.tab.c_shipped └── zconf.y /.pc/.quilt_patches: -------------------------------------------------------------------------------- 1 | patches 2 | -------------------------------------------------------------------------------- /.pc/.quilt_series: -------------------------------------------------------------------------------- 1 | series 2 | -------------------------------------------------------------------------------- /.pc/.version: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /.pc/01-kconfig-kernel-to-buildroot.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/01-kconfig-kernel-to-buildroot.patch/.timestamp -------------------------------------------------------------------------------- /.pc/10-br-build-system.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/10-br-build-system.patch/.timestamp -------------------------------------------------------------------------------- /.pc/10-br-build-system.patch/Makefile.br: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/10-br-build-system.patch/Makefile.br -------------------------------------------------------------------------------- /.pc/10-br-build-system.patch/foo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/10-br-build-system.patch/foo.h -------------------------------------------------------------------------------- /.pc/100-kconfig-generic-env.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/100-kconfig-generic-env.patch/.timestamp -------------------------------------------------------------------------------- /.pc/100-kconfig-generic-env.patch/Makefile: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # Kernel configuration targets 3 | # These targets are used from top-level makefile 4 | 5 | PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \ 6 | localmodconfig localyesconfig 7 | 8 | ifdef KBUILD_KCONFIG 9 | Kconfig := $(KBUILD_KCONFIG) 10 | else 11 | Kconfig := Kconfig 12 | endif 13 | 14 | # We need this, in case the user has it in its environment 15 | unexport CONFIG_ 16 | 17 | xconfig: $(obj)/qconf 18 | $< $(Kconfig) 19 | 20 | gconfig: $(obj)/gconf 21 | $< $(Kconfig) 22 | 23 | menuconfig: $(obj)/mconf 24 | $< $(Kconfig) 25 | 26 | config: $(obj)/conf 27 | $< --oldaskconfig $(Kconfig) 28 | 29 | nconfig: $(obj)/nconf 30 | $< $(Kconfig) 31 | 32 | oldconfig: $(obj)/conf 33 | $< --$@ $(Kconfig) 34 | 35 | silentoldconfig: $(obj)/conf 36 | $(Q)mkdir -p include/generated 37 | $< --$@ $(Kconfig) 38 | 39 | localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 40 | $(Q)mkdir -p include/generated 41 | $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config 42 | $(Q)if [ -f .config ]; then \ 43 | cmp -s .tmp.config .config || \ 44 | (mv -f .config .config.old.1; \ 45 | mv -f .tmp.config .config; \ 46 | $(obj)/conf --silentoldconfig $(Kconfig); \ 47 | mv -f .config.old.1 .config.old) \ 48 | else \ 49 | mv -f .tmp.config .config; \ 50 | $(obj)/conf --silentoldconfig $(Kconfig); \ 51 | fi 52 | $(Q)rm -f .tmp.config 53 | 54 | # Create new linux.pot file 55 | # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 56 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h 57 | $(Q)echo " GEN config.pot" 58 | $(Q)xgettext --default-domain=linux \ 59 | --add-comments --keyword=_ --keyword=N_ \ 60 | --from-code=UTF-8 \ 61 | --files-from=$(srctree)/scripts/kconfig/POTFILES.in \ 62 | --directory=$(srctree) --directory=$(objtree) \ 63 | --output $(obj)/config.pot 64 | $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot 65 | $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \ 66 | $(srctree)/arch/*/um/Kconfig`; \ 67 | do \ 68 | echo " GEN $$i"; \ 69 | $(obj)/kxgettext $$i \ 70 | >> $(obj)/config.pot; \ 71 | done ) 72 | $(Q)echo " GEN linux.pot" 73 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ 74 | --output $(obj)/linux.pot 75 | $(Q)rm -f $(obj)/config.pot 76 | 77 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig 78 | 79 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf 80 | $< --$@ $(Kconfig) 81 | 82 | PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig 83 | 84 | listnewconfig olddefconfig: $(obj)/conf 85 | $< --$@ $(Kconfig) 86 | 87 | # oldnoconfig is an alias of olddefconfig, because people already are dependent 88 | # on its behavior(sets new symbols to their default value but not 'n') with the 89 | # counter-intuitive name. 90 | oldnoconfig: $(obj)/conf 91 | $< --olddefconfig $(Kconfig) 92 | 93 | savedefconfig: $(obj)/conf 94 | $< --$@=defconfig $(Kconfig) 95 | 96 | defconfig: $(obj)/conf 97 | ifeq ($(KBUILD_DEFCONFIG),) 98 | $< --defconfig $(Kconfig) 99 | else 100 | @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 101 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 102 | endif 103 | 104 | %_defconfig: $(obj)/conf 105 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 106 | 107 | # Help text used by make help 108 | help: 109 | @echo ' config - Update current config utilising a line-oriented program' 110 | @echo ' nconfig - Update current config utilising a ncurses menu based program' 111 | @echo ' menuconfig - Update current config utilising a menu based program' 112 | @echo ' xconfig - Update current config utilising a QT based front-end' 113 | @echo ' gconfig - Update current config utilising a GTK based front-end' 114 | @echo ' oldconfig - Update current config utilising a provided .config as base' 115 | @echo ' localmodconfig - Update current config disabling modules not loaded' 116 | @echo ' localyesconfig - Update current config converting local mods to core' 117 | @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' 118 | @echo ' defconfig - New config with default from ARCH supplied defconfig' 119 | @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 120 | @echo ' allnoconfig - New config where all options are answered with no' 121 | @echo ' allyesconfig - New config where all options are accepted with yes' 122 | @echo ' allmodconfig - New config selecting modules when possible' 123 | @echo ' alldefconfig - New config with all symbols set to default' 124 | @echo ' randconfig - New config with random answer to all options' 125 | @echo ' listnewconfig - List new options' 126 | @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value' 127 | 128 | # lxdialog stuff 129 | check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh 130 | 131 | # Use recursively expanded variables so we do not call gcc unless 132 | # we really need to do so. (Do not call gcc as part of make mrproper) 133 | HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \ 134 | -DLOCALE 135 | 136 | # =========================================================================== 137 | # Shared Makefile for the various kconfig executables: 138 | # conf: Used for defconfig, oldconfig and related targets 139 | # nconf: Used for the nconfig target. 140 | # Utilizes ncurses 141 | # mconf: Used for the menuconfig target 142 | # Utilizes the lxdialog package 143 | # qconf: Used for the xconfig target 144 | # Based on QT which needs to be installed to compile it 145 | # gconf: Used for the gconfig target 146 | # Based on GTK which needs to be installed to compile it 147 | # object files used by all kconfig flavours 148 | 149 | lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o 150 | lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o 151 | 152 | conf-objs := conf.o zconf.tab.o 153 | mconf-objs := mconf.o zconf.tab.o $(lxdialog) 154 | nconf-objs := nconf.o zconf.tab.o nconf.gui.o 155 | kxgettext-objs := kxgettext.o zconf.tab.o 156 | qconf-cxxobjs := qconf.o 157 | qconf-objs := zconf.tab.o 158 | gconf-objs := gconf.o zconf.tab.o 159 | 160 | hostprogs-y := conf 161 | 162 | ifeq ($(MAKECMDGOALS),nconfig) 163 | hostprogs-y += nconf 164 | endif 165 | 166 | ifeq ($(MAKECMDGOALS),menuconfig) 167 | hostprogs-y += mconf 168 | endif 169 | 170 | ifeq ($(MAKECMDGOALS),update-po-config) 171 | hostprogs-y += kxgettext 172 | endif 173 | 174 | ifeq ($(MAKECMDGOALS),xconfig) 175 | qconf-target := 1 176 | endif 177 | ifeq ($(MAKECMDGOALS),gconfig) 178 | gconf-target := 1 179 | endif 180 | 181 | 182 | ifeq ($(qconf-target),1) 183 | hostprogs-y += qconf 184 | endif 185 | 186 | ifeq ($(gconf-target),1) 187 | hostprogs-y += gconf 188 | endif 189 | 190 | clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck 191 | clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h 192 | clean-files += mconf qconf gconf nconf 193 | clean-files += config.pot linux.pot 194 | 195 | # Check that we have the required ncurses stuff installed for lxdialog (menuconfig) 196 | PHONY += $(obj)/dochecklxdialog 197 | $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog 198 | $(obj)/dochecklxdialog: 199 | $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf) 200 | 201 | always := dochecklxdialog 202 | 203 | # Add environment specific flags 204 | HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) 205 | 206 | # generated files seem to need this to find local include files 207 | HOSTCFLAGS_zconf.lex.o := -I$(src) 208 | HOSTCFLAGS_zconf.tab.o := -I$(src) 209 | 210 | LEX_PREFIX_zconf := zconf 211 | YACC_PREFIX_zconf := zconf 212 | 213 | HOSTLOADLIBES_qconf = $(KC_QT_LIBS) 214 | HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) 215 | 216 | HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` 217 | HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ 218 | -Wno-missing-prototypes 219 | 220 | HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 221 | 222 | HOSTLOADLIBES_nconf = $(shell \ 223 | pkg-config --libs menu panel ncurses 2>/dev/null \ 224 | || echo "-lmenu -lpanel -lncurses" ) 225 | $(obj)/qconf.o: $(obj)/.tmp_qtcheck 226 | 227 | ifeq ($(qconf-target),1) 228 | $(obj)/.tmp_qtcheck: $(src)/Makefile 229 | -include $(obj)/.tmp_qtcheck 230 | 231 | # QT needs some extra effort... 232 | $(obj)/.tmp_qtcheck: 233 | @set -e; echo " CHECK qt"; dir=""; pkg=""; \ 234 | if ! pkg-config --exists QtCore 2> /dev/null; then \ 235 | echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \ 236 | pkg-config --exists qt 2> /dev/null && pkg=qt; \ 237 | pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ 238 | if [ -n "$$pkg" ]; then \ 239 | cflags="\$$(shell pkg-config $$pkg --cflags)"; \ 240 | libs="\$$(shell pkg-config $$pkg --libs)"; \ 241 | moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ 242 | dir="$$(pkg-config $$pkg --variable=prefix)"; \ 243 | else \ 244 | for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ 245 | if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ 246 | done; \ 247 | if [ -z "$$dir" ]; then \ 248 | echo >&2 "*"; \ 249 | echo >&2 "* Unable to find any QT installation. Please make sure that"; \ 250 | echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \ 251 | echo >&2 "* either qmake can be found or install pkg-config or set"; \ 252 | echo >&2 "* the QTDIR environment variable to the correct location."; \ 253 | echo >&2 "*"; \ 254 | false; \ 255 | fi; \ 256 | libpath=$$dir/lib; lib=qt; osdir=""; \ 257 | $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \ 258 | osdir=x$$($(HOSTCXX) -print-multi-os-directory); \ 259 | test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \ 260 | test -f $$libpath/libqt-mt.so && lib=qt-mt; \ 261 | cflags="-I$$dir/include"; \ 262 | libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \ 263 | moc="$$dir/bin/moc"; \ 264 | fi; \ 265 | if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \ 266 | echo "*"; \ 267 | echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \ 268 | echo "*"; \ 269 | moc="/usr/bin/moc"; \ 270 | fi; \ 271 | else \ 272 | cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ 273 | libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ 274 | moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \ 275 | [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \ 276 | fi; \ 277 | echo "KC_QT_CFLAGS=$$cflags" > $@; \ 278 | echo "KC_QT_LIBS=$$libs" >> $@; \ 279 | echo "KC_QT_MOC=$$moc" >> $@ 280 | endif 281 | 282 | $(obj)/gconf.o: $(obj)/.tmp_gtkcheck 283 | 284 | ifeq ($(gconf-target),1) 285 | -include $(obj)/.tmp_gtkcheck 286 | 287 | # GTK needs some extra effort, too... 288 | $(obj)/.tmp_gtkcheck: 289 | @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \ 290 | if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ 291 | touch $@; \ 292 | else \ 293 | echo >&2 "*"; \ 294 | echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \ 295 | echo >&2 "*"; \ 296 | false; \ 297 | fi \ 298 | else \ 299 | echo >&2 "*"; \ 300 | echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \ 301 | echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \ 302 | echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \ 303 | echo >&2 "*"; \ 304 | false; \ 305 | fi 306 | endif 307 | 308 | $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c 309 | 310 | $(obj)/qconf.o: $(obj)/qconf.moc 311 | 312 | $(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck 313 | $(KC_QT_MOC) -i $< -o $@ 314 | 315 | # Extract gconf menu items for I18N support 316 | $(obj)/gconf.glade.h: $(obj)/gconf.glade 317 | $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ 318 | $(obj)/gconf.glade 319 | 320 | -------------------------------------------------------------------------------- /.pc/100-kconfig-generic-env.patch/expr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Roman Zippel 3 | * Released under the terms of the GNU GPL v2.0. 4 | */ 5 | 6 | #ifndef EXPR_H 7 | #define EXPR_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #include 14 | #include 15 | #include "list.h" 16 | #ifndef __cplusplus 17 | #include 18 | #endif 19 | 20 | struct file { 21 | struct file *next; 22 | struct file *parent; 23 | const char *name; 24 | int lineno; 25 | }; 26 | 27 | typedef enum tristate { 28 | no, mod, yes 29 | } tristate; 30 | 31 | enum expr_type { 32 | E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE 33 | }; 34 | 35 | union expr_data { 36 | struct expr *expr; 37 | struct symbol *sym; 38 | }; 39 | 40 | struct expr { 41 | enum expr_type type; 42 | union expr_data left, right; 43 | }; 44 | 45 | #define EXPR_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) 46 | #define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) 47 | #define EXPR_NOT(dep) (2-(dep)) 48 | 49 | #define expr_list_for_each_sym(l, e, s) \ 50 | for (e = (l); e && (s = e->right.sym); e = e->left.expr) 51 | 52 | struct expr_value { 53 | struct expr *expr; 54 | tristate tri; 55 | }; 56 | 57 | struct symbol_value { 58 | void *val; 59 | tristate tri; 60 | }; 61 | 62 | enum symbol_type { 63 | S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER 64 | }; 65 | 66 | /* enum values are used as index to symbol.def[] */ 67 | enum { 68 | S_DEF_USER, /* main user value */ 69 | S_DEF_AUTO, /* values read from auto.conf */ 70 | S_DEF_DEF3, /* Reserved for UI usage */ 71 | S_DEF_DEF4, /* Reserved for UI usage */ 72 | S_DEF_COUNT 73 | }; 74 | 75 | struct symbol { 76 | struct symbol *next; 77 | char *name; 78 | enum symbol_type type; 79 | struct symbol_value curr; 80 | struct symbol_value def[S_DEF_COUNT]; 81 | tristate visible; 82 | int flags; 83 | struct property *prop; 84 | struct expr_value dir_dep; 85 | struct expr_value rev_dep; 86 | }; 87 | 88 | #define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) 89 | 90 | #define SYMBOL_CONST 0x0001 /* symbol is const */ 91 | #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ 92 | #define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */ 93 | #define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ 94 | #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ 95 | #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ 96 | #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ 97 | #define SYMBOL_CHANGED 0x0400 /* ? */ 98 | #define SYMBOL_AUTO 0x1000 /* value from environment variable */ 99 | #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ 100 | #define SYMBOL_WARNED 0x8000 /* warning has been issued */ 101 | 102 | /* Set when symbol.def[] is used */ 103 | #define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */ 104 | #define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */ 105 | #define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */ 106 | #define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ 107 | #define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ 108 | 109 | /* choice values need to be set before calculating this symbol value */ 110 | #define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 111 | 112 | #define SYMBOL_MAXLENGTH 256 113 | #define SYMBOL_HASHSIZE 9973 114 | 115 | /* A property represent the config options that can be associated 116 | * with a config "symbol". 117 | * Sample: 118 | * config FOO 119 | * default y 120 | * prompt "foo prompt" 121 | * select BAR 122 | * config BAZ 123 | * int "BAZ Value" 124 | * range 1..255 125 | */ 126 | enum prop_type { 127 | P_UNKNOWN, 128 | P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ 129 | P_COMMENT, /* text associated with a comment */ 130 | P_MENU, /* prompt associated with a menuconfig option */ 131 | P_DEFAULT, /* default y */ 132 | P_CHOICE, /* choice value */ 133 | P_SELECT, /* select BAR */ 134 | P_RANGE, /* range 7..100 (for a symbol) */ 135 | P_ENV, /* value from environment variable */ 136 | P_SYMBOL, /* where a symbol is defined */ 137 | }; 138 | 139 | struct property { 140 | struct property *next; /* next property - null if last */ 141 | struct symbol *sym; /* the symbol for which the property is associated */ 142 | enum prop_type type; /* type of property */ 143 | const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */ 144 | struct expr_value visible; 145 | struct expr *expr; /* the optional conditional part of the property */ 146 | struct menu *menu; /* the menu the property are associated with 147 | * valid for: P_SELECT, P_RANGE, P_CHOICE, 148 | * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ 149 | struct file *file; /* what file was this property defined */ 150 | int lineno; /* what lineno was this property defined */ 151 | }; 152 | 153 | #define for_all_properties(sym, st, tok) \ 154 | for (st = sym->prop; st; st = st->next) \ 155 | if (st->type == (tok)) 156 | #define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) 157 | #define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) 158 | #define for_all_prompts(sym, st) \ 159 | for (st = sym->prop; st; st = st->next) \ 160 | if (st->text) 161 | 162 | struct menu { 163 | struct menu *next; 164 | struct menu *parent; 165 | struct menu *list; 166 | struct symbol *sym; 167 | struct property *prompt; 168 | struct expr *visibility; 169 | struct expr *dep; 170 | unsigned int flags; 171 | char *help; 172 | struct file *file; 173 | int lineno; 174 | void *data; 175 | }; 176 | 177 | #define MENU_CHANGED 0x0001 178 | #define MENU_ROOT 0x0002 179 | 180 | struct jump_key { 181 | struct list_head entries; 182 | size_t offset; 183 | struct menu *target; 184 | int index; 185 | }; 186 | 187 | #define JUMP_NB 9 188 | 189 | extern struct file *file_list; 190 | extern struct file *current_file; 191 | struct file *lookup_file(const char *name); 192 | 193 | extern struct symbol symbol_yes, symbol_no, symbol_mod; 194 | extern struct symbol *modules_sym; 195 | extern struct symbol *sym_defconfig_list; 196 | extern int cdebug; 197 | struct expr *expr_alloc_symbol(struct symbol *sym); 198 | struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); 199 | struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); 200 | struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); 201 | struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); 202 | struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); 203 | struct expr *expr_copy(const struct expr *org); 204 | void expr_free(struct expr *e); 205 | int expr_eq(struct expr *e1, struct expr *e2); 206 | void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); 207 | tristate expr_calc_value(struct expr *e); 208 | struct expr *expr_eliminate_yn(struct expr *e); 209 | struct expr *expr_trans_bool(struct expr *e); 210 | struct expr *expr_eliminate_dups(struct expr *e); 211 | struct expr *expr_transform(struct expr *e); 212 | int expr_contains_symbol(struct expr *dep, struct symbol *sym); 213 | bool expr_depends_symbol(struct expr *dep, struct symbol *sym); 214 | struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); 215 | struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); 216 | void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); 217 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); 218 | struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); 219 | 220 | void expr_fprint(struct expr *e, FILE *out); 221 | struct gstr; /* forward */ 222 | void expr_gstr_print(struct expr *e, struct gstr *gs); 223 | 224 | static inline int expr_is_yes(struct expr *e) 225 | { 226 | return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); 227 | } 228 | 229 | static inline int expr_is_no(struct expr *e) 230 | { 231 | return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); 232 | } 233 | 234 | #ifdef __cplusplus 235 | } 236 | #endif 237 | 238 | #endif /* EXPR_H */ 239 | -------------------------------------------------------------------------------- /.pc/100-kconfig-generic-env.patch/lkc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Roman Zippel 3 | * Released under the terms of the GNU GPL v2.0. 4 | */ 5 | 6 | #ifndef LKC_H 7 | #define LKC_H 8 | 9 | #include "expr.h" 10 | 11 | #ifndef KBUILD_NO_NLS 12 | # include 13 | #else 14 | static inline const char *gettext(const char *txt) { return txt; } 15 | static inline void textdomain(const char *domainname) {} 16 | static inline void bindtextdomain(const char *name, const char *dir) {} 17 | static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; } 18 | #endif 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define P(name,type,arg) extern type name arg 25 | #include "lkc_proto.h" 26 | #undef P 27 | 28 | #define SRCTREE "srctree" 29 | 30 | #ifndef PACKAGE 31 | #define PACKAGE "linux" 32 | #endif 33 | 34 | #define LOCALEDIR "/usr/share/locale" 35 | 36 | #define _(text) gettext(text) 37 | #define N_(text) (text) 38 | 39 | #ifndef CONFIG_ 40 | #define CONFIG_ "CONFIG_" 41 | #endif 42 | static inline const char *CONFIG_prefix(void) 43 | { 44 | return getenv( "CONFIG_" ) ?: CONFIG_; 45 | } 46 | #undef CONFIG_ 47 | #define CONFIG_ CONFIG_prefix() 48 | 49 | #define TF_COMMAND 0x0001 50 | #define TF_PARAM 0x0002 51 | #define TF_OPTION 0x0004 52 | 53 | enum conf_def_mode { 54 | def_default, 55 | def_yes, 56 | def_mod, 57 | def_no, 58 | def_random 59 | }; 60 | 61 | #define T_OPT_MODULES 1 62 | #define T_OPT_DEFCONFIG_LIST 2 63 | #define T_OPT_ENV 3 64 | 65 | struct kconf_id { 66 | int name; 67 | int token; 68 | unsigned int flags; 69 | enum symbol_type stype; 70 | }; 71 | 72 | extern int zconfdebug; 73 | 74 | int zconfparse(void); 75 | void zconfdump(FILE *out); 76 | void zconf_starthelp(void); 77 | FILE *zconf_fopen(const char *name); 78 | void zconf_initscan(const char *name); 79 | void zconf_nextfile(const char *name); 80 | int zconf_lineno(void); 81 | const char *zconf_curname(void); 82 | 83 | /* confdata.c */ 84 | const char *conf_get_configname(void); 85 | const char *conf_get_autoconfig_name(void); 86 | char *conf_get_default_confname(void); 87 | void sym_set_change_count(int count); 88 | void sym_add_change_count(int count); 89 | bool conf_set_all_new_symbols(enum conf_def_mode mode); 90 | void set_all_choice_values(struct symbol *csym); 91 | 92 | struct conf_printer { 93 | void (*print_symbol)(FILE *, struct symbol *, const char *, void *); 94 | void (*print_comment)(FILE *, const char *, void *); 95 | }; 96 | 97 | /* confdata.c and expr.c */ 98 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) 99 | { 100 | assert(len != 0); 101 | 102 | if (fwrite(str, len, count, out) != count) 103 | fprintf(stderr, "Error in writing or end of file.\n"); 104 | } 105 | 106 | /* menu.c */ 107 | void _menu_init(void); 108 | void menu_warn(struct menu *menu, const char *fmt, ...); 109 | struct menu *menu_add_menu(void); 110 | void menu_end_menu(void); 111 | void menu_add_entry(struct symbol *sym); 112 | void menu_end_entry(void); 113 | void menu_add_dep(struct expr *dep); 114 | void menu_add_visibility(struct expr *dep); 115 | struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); 116 | struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); 117 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); 118 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); 119 | void menu_add_option(int token, char *arg); 120 | void menu_finalize(struct menu *parent); 121 | void menu_set_type(int type); 122 | 123 | /* util.c */ 124 | struct file *file_lookup(const char *name); 125 | int file_write_dep(const char *name); 126 | void *xmalloc(size_t size); 127 | void *xcalloc(size_t nmemb, size_t size); 128 | 129 | struct gstr { 130 | size_t len; 131 | char *s; 132 | /* 133 | * when max_width is not zero long lines in string s (if any) get 134 | * wrapped not to exceed the max_width value 135 | */ 136 | int max_width; 137 | }; 138 | struct gstr str_new(void); 139 | struct gstr str_assign(const char *s); 140 | void str_free(struct gstr *gs); 141 | void str_append(struct gstr *gs, const char *s); 142 | void str_printf(struct gstr *gs, const char *fmt, ...); 143 | const char *str_get(struct gstr *gs); 144 | 145 | /* symbol.c */ 146 | extern struct expr *sym_env_list; 147 | 148 | void sym_init(void); 149 | void sym_clear_all_valid(void); 150 | void sym_set_all_changed(void); 151 | void sym_set_changed(struct symbol *sym); 152 | struct symbol *sym_choice_default(struct symbol *sym); 153 | const char *sym_get_string_default(struct symbol *sym); 154 | struct symbol *sym_check_deps(struct symbol *sym); 155 | struct property *prop_alloc(enum prop_type type, struct symbol *sym); 156 | struct symbol *prop_get_symbol(struct property *prop); 157 | struct property *sym_get_env_prop(struct symbol *sym); 158 | 159 | static inline tristate sym_get_tristate_value(struct symbol *sym) 160 | { 161 | return sym->curr.tri; 162 | } 163 | 164 | 165 | static inline struct symbol *sym_get_choice_value(struct symbol *sym) 166 | { 167 | return (struct symbol *)sym->curr.val; 168 | } 169 | 170 | static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) 171 | { 172 | return sym_set_tristate_value(chval, yes); 173 | } 174 | 175 | static inline bool sym_is_choice(struct symbol *sym) 176 | { 177 | return sym->flags & SYMBOL_CHOICE ? true : false; 178 | } 179 | 180 | static inline bool sym_is_choice_value(struct symbol *sym) 181 | { 182 | return sym->flags & SYMBOL_CHOICEVAL ? true : false; 183 | } 184 | 185 | static inline bool sym_is_optional(struct symbol *sym) 186 | { 187 | return sym->flags & SYMBOL_OPTIONAL ? true : false; 188 | } 189 | 190 | static inline bool sym_has_value(struct symbol *sym) 191 | { 192 | return sym->flags & SYMBOL_DEF_USER ? true : false; 193 | } 194 | 195 | #ifdef __cplusplus 196 | } 197 | #endif 198 | 199 | #endif /* LKC_H */ 200 | -------------------------------------------------------------------------------- /.pc/100-kconfig-generic-env.patch/merge_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # merge_config.sh - Takes a list of config fragment values, and merges 3 | # them one by one. Provides warnings on overridden values, and specified 4 | # values that did not make it to the resulting .config file (due to missed 5 | # dependencies or config symbol removal). 6 | # 7 | # Portions reused from kconf_check and generate_cfg: 8 | # http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/kconf_check 9 | # http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/generate_cfg 10 | # 11 | # Copyright (c) 2009-2010 Wind River Systems, Inc. 12 | # Copyright 2011 Linaro 13 | # 14 | # This program is free software; you can redistribute it and/or modify 15 | # it under the terms of the GNU General Public License version 2 as 16 | # published by the Free Software Foundation. 17 | # 18 | # This program is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | 23 | clean_up() { 24 | rm -f $TMP_FILE 25 | exit 26 | } 27 | trap clean_up HUP INT TERM 28 | 29 | usage() { 30 | echo "Usage: $0 [OPTIONS] [CONFIG [...]]" 31 | echo " -h display this help text" 32 | echo " -m only merge the fragments, do not execute the make command" 33 | echo " -n use allnoconfig instead of alldefconfig" 34 | echo " -r list redundant entries when merging fragments" 35 | echo " -O dir to put generated output files" 36 | } 37 | 38 | MAKE=true 39 | ALLTARGET=alldefconfig 40 | WARNREDUN=false 41 | OUTPUT=. 42 | 43 | while true; do 44 | case $1 in 45 | "-n") 46 | ALLTARGET=allnoconfig 47 | shift 48 | continue 49 | ;; 50 | "-m") 51 | MAKE=false 52 | shift 53 | continue 54 | ;; 55 | "-h") 56 | usage 57 | exit 58 | ;; 59 | "-r") 60 | WARNREDUN=true 61 | shift 62 | continue 63 | ;; 64 | "-O") 65 | if [ -d $2 ];then 66 | OUTPUT=$(echo $2 | sed 's/\/*$//') 67 | else 68 | echo "output directory $2 does not exist" 1>&2 69 | exit 1 70 | fi 71 | shift 2 72 | continue 73 | ;; 74 | *) 75 | break 76 | ;; 77 | esac 78 | done 79 | 80 | INITFILE=$1 81 | shift; 82 | 83 | MERGE_LIST=$* 84 | SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" 85 | TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) 86 | 87 | echo "Using $INITFILE as base" 88 | cat $INITFILE > $TMP_FILE 89 | 90 | # Merge files, printing warnings on overrided values 91 | for MERGE_FILE in $MERGE_LIST ; do 92 | echo "Merging $MERGE_FILE" 93 | CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) 94 | 95 | for CFG in $CFG_LIST ; do 96 | grep -q -w $CFG $TMP_FILE 97 | if [ $? -eq 0 ] ; then 98 | PREV_VAL=$(grep -w $CFG $TMP_FILE) 99 | NEW_VAL=$(grep -w $CFG $MERGE_FILE) 100 | if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then 101 | echo Value of $CFG is redefined by fragment $MERGE_FILE: 102 | echo Previous value: $PREV_VAL 103 | echo New value: $NEW_VAL 104 | echo 105 | elif [ "$WARNREDUN" = "true" ]; then 106 | echo Value of $CFG is redundant by fragment $MERGE_FILE: 107 | fi 108 | sed -i "/$CFG[ =]/d" $TMP_FILE 109 | fi 110 | done 111 | cat $MERGE_FILE >> $TMP_FILE 112 | done 113 | 114 | if [ "$MAKE" = "false" ]; then 115 | cp $TMP_FILE $OUTPUT/.config 116 | echo "#" 117 | echo "# merged configuration written to $OUTPUT/.config (needs make)" 118 | echo "#" 119 | clean_up 120 | exit 121 | fi 122 | 123 | # If we have an output dir, setup the O= argument, otherwise leave 124 | # it blank, since O=. will create an unnecessary ./source softlink 125 | OUTPUT_ARG="" 126 | if [ "$OUTPUT" != "." ] ; then 127 | OUTPUT_ARG="O=$OUTPUT" 128 | fi 129 | 130 | 131 | # Use the merged file as the starting point for: 132 | # alldefconfig: Fills in any missing symbols with Kconfig default 133 | # allnoconfig: Fills in any missing symbols with # CONFIG_* is not set 134 | make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET 135 | 136 | 137 | # Check all specified config values took (might have missed-dependency issues) 138 | for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do 139 | 140 | REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) 141 | ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config) 142 | if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then 143 | echo "Value requested for $CFG not in final .config" 144 | echo "Requested value: $REQUESTED_VAL" 145 | echo "Actual value: $ACTUAL_VAL" 146 | echo "" 147 | fi 148 | done 149 | 150 | clean_up 151 | -------------------------------------------------------------------------------- /.pc/101-kconfig-build.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/101-kconfig-build.patch/.timestamp -------------------------------------------------------------------------------- /.pc/101-kconfig-build.patch/GNUmakefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/101-kconfig-build.patch/GNUmakefile -------------------------------------------------------------------------------- /.pc/101-kconfig-build.patch/README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/101-kconfig-build.patch/README -------------------------------------------------------------------------------- /.pc/101-kconfig-build.patch/config.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/101-kconfig-build.patch/config.sh -------------------------------------------------------------------------------- /.pc/11-use-mktemp-for-lxdialog.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/11-use-mktemp-for-lxdialog.patch/.timestamp -------------------------------------------------------------------------------- /.pc/11-use-mktemp-for-lxdialog.patch/lxdialog/check-lxdialog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Check ncurses compatibility 3 | 4 | # What library to link 5 | ldflags() 6 | { 7 | pkg-config --libs ncursesw 2>/dev/null && exit 8 | pkg-config --libs ncurses 2>/dev/null && exit 9 | for ext in so a dll.a dylib ; do 10 | for lib in ncursesw ncurses curses ; do 11 | $cc -print-file-name=lib${lib}.${ext} | grep -q / 12 | if [ $? -eq 0 ]; then 13 | echo "-l${lib}" 14 | exit 15 | fi 16 | done 17 | done 18 | exit 1 19 | } 20 | 21 | # Where is ncurses.h? 22 | ccflags() 23 | { 24 | if [ -f /usr/include/ncursesw/curses.h ]; then 25 | echo '-I/usr/include/ncursesw -DCURSES_LOC=""' 26 | echo ' -DNCURSES_WIDECHAR=1' 27 | elif [ -f /usr/include/ncurses/ncurses.h ]; then 28 | echo '-I/usr/include/ncurses -DCURSES_LOC=""' 29 | elif [ -f /usr/include/ncurses/curses.h ]; then 30 | echo '-I/usr/include/ncurses -DCURSES_LOC=""' 31 | elif [ -f /usr/include/ncurses.h ]; then 32 | echo '-DCURSES_LOC=""' 33 | else 34 | echo '-DCURSES_LOC=""' 35 | fi 36 | } 37 | 38 | # Temp file, try to clean up after us 39 | tmp=.lxdialog.tmp 40 | trap "rm -f $tmp" 0 1 2 3 15 41 | 42 | # Check if we can link to ncurses 43 | check() { 44 | $cc -x c - -o $tmp 2>/dev/null <<'EOF' 45 | #include CURSES_LOC 46 | main() {} 47 | EOF 48 | if [ $? != 0 ]; then 49 | echo " *** Unable to find the ncurses libraries or the" 1>&2 50 | echo " *** required header files." 1>&2 51 | echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2 52 | echo " *** " 1>&2 53 | echo " *** Install ncurses (ncurses-devel) and try again." 1>&2 54 | echo " *** " 1>&2 55 | exit 1 56 | fi 57 | } 58 | 59 | usage() { 60 | printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n" 61 | } 62 | 63 | if [ $# -eq 0 ]; then 64 | usage 65 | exit 1 66 | fi 67 | 68 | cc="" 69 | case "$1" in 70 | "-check") 71 | shift 72 | cc="$@" 73 | check 74 | ;; 75 | "-ccflags") 76 | ccflags 77 | ;; 78 | "-ldflags") 79 | shift 80 | cc="$@" 81 | ldflags 82 | ;; 83 | "*") 84 | usage 85 | exit 1 86 | ;; 87 | esac 88 | -------------------------------------------------------------------------------- /.pc/12-fix-glade-file-path.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/12-fix-glade-file-path.patch/.timestamp -------------------------------------------------------------------------------- /.pc/14-support-out-of-tree-config.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/14-support-out-of-tree-config.patch/.timestamp -------------------------------------------------------------------------------- /.pc/14-support-out-of-tree-config.patch/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2005 Roman Zippel 3 | * Copyright (C) 2002-2005 Sam Ravnborg 4 | * 5 | * Released under the terms of the GNU GPL v2.0. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "lkc.h" 12 | 13 | /* file already present in list? If not add it */ 14 | struct file *file_lookup(const char *name) 15 | { 16 | struct file *file; 17 | const char *file_name = sym_expand_string_value(name); 18 | 19 | for (file = file_list; file; file = file->next) { 20 | if (!strcmp(name, file->name)) { 21 | free((void *)file_name); 22 | return file; 23 | } 24 | } 25 | 26 | file = xmalloc(sizeof(*file)); 27 | memset(file, 0, sizeof(*file)); 28 | file->name = file_name; 29 | file->next = file_list; 30 | file_list = file; 31 | return file; 32 | } 33 | 34 | /* write a dependency file as used by kbuild to track dependencies */ 35 | int file_write_dep(const char *name) 36 | { 37 | struct symbol *sym, *env_sym; 38 | struct expr *e; 39 | struct file *file; 40 | FILE *out; 41 | 42 | if (!name) 43 | name = ".kconfig.d"; 44 | out = fopen("..config.tmp", "w"); 45 | if (!out) 46 | return 1; 47 | fprintf(out, "deps_config := \\\n"); 48 | for (file = file_list; file; file = file->next) { 49 | if (file->next) 50 | fprintf(out, "\t%s \\\n", file->name); 51 | else 52 | fprintf(out, "\t%s\n", file->name); 53 | } 54 | fprintf(out, "\n%s: \\\n" 55 | "\t$(deps_config)\n\n", conf_get_autoconfig_name()); 56 | 57 | expr_list_for_each_sym(sym_env_list, e, sym) { 58 | struct property *prop; 59 | const char *value; 60 | 61 | prop = sym_get_env_prop(sym); 62 | env_sym = prop_get_symbol(prop); 63 | if (!env_sym) 64 | continue; 65 | value = getenv(env_sym->name); 66 | if (!value) 67 | value = ""; 68 | fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value); 69 | fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name()); 70 | fprintf(out, "endif\n"); 71 | } 72 | 73 | fprintf(out, "\n$(deps_config): ;\n"); 74 | fclose(out); 75 | rename("..config.tmp", name); 76 | return 0; 77 | } 78 | 79 | 80 | /* Allocate initial growable string */ 81 | struct gstr str_new(void) 82 | { 83 | struct gstr gs; 84 | gs.s = xmalloc(sizeof(char) * 64); 85 | gs.len = 64; 86 | gs.max_width = 0; 87 | strcpy(gs.s, "\0"); 88 | return gs; 89 | } 90 | 91 | /* Allocate and assign growable string */ 92 | struct gstr str_assign(const char *s) 93 | { 94 | struct gstr gs; 95 | gs.s = strdup(s); 96 | gs.len = strlen(s) + 1; 97 | gs.max_width = 0; 98 | return gs; 99 | } 100 | 101 | /* Free storage for growable string */ 102 | void str_free(struct gstr *gs) 103 | { 104 | if (gs->s) 105 | free(gs->s); 106 | gs->s = NULL; 107 | gs->len = 0; 108 | } 109 | 110 | /* Append to growable string */ 111 | void str_append(struct gstr *gs, const char *s) 112 | { 113 | size_t l; 114 | if (s) { 115 | l = strlen(gs->s) + strlen(s) + 1; 116 | if (l > gs->len) { 117 | gs->s = realloc(gs->s, l); 118 | gs->len = l; 119 | } 120 | strcat(gs->s, s); 121 | } 122 | } 123 | 124 | /* Append printf formatted string to growable string */ 125 | void str_printf(struct gstr *gs, const char *fmt, ...) 126 | { 127 | va_list ap; 128 | char s[10000]; /* big enough... */ 129 | va_start(ap, fmt); 130 | vsnprintf(s, sizeof(s), fmt, ap); 131 | str_append(gs, s); 132 | va_end(ap); 133 | } 134 | 135 | /* Retrieve value of growable string */ 136 | const char *str_get(struct gstr *gs) 137 | { 138 | return gs->s; 139 | } 140 | 141 | void *xmalloc(size_t size) 142 | { 143 | void *p = malloc(size); 144 | if (p) 145 | return p; 146 | fprintf(stderr, "Out of memory.\n"); 147 | exit(1); 148 | } 149 | 150 | void *xcalloc(size_t nmemb, size_t size) 151 | { 152 | void *p = calloc(nmemb, size); 153 | if (p) 154 | return p; 155 | fprintf(stderr, "Out of memory.\n"); 156 | exit(1); 157 | } 158 | 159 | 160 | -------------------------------------------------------------------------------- /.pc/15-fix-qconf-moc-rule.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/15-fix-qconf-moc-rule.patch/.timestamp -------------------------------------------------------------------------------- /.pc/15-fix-qconf-moc-rule.patch/Makefile: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # Kernel configuration targets 3 | # These targets are used from top-level makefile 4 | 5 | PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \ 6 | localmodconfig localyesconfig 7 | 8 | ifdef KBUILD_KCONFIG 9 | Kconfig := $(KBUILD_KCONFIG) 10 | else 11 | Kconfig := Kconfig 12 | endif 13 | 14 | # We need this, in case the user has it in its environment 15 | unexport CONFIG_ 16 | 17 | xconfig: $(obj)/qconf 18 | $< $(Kconfig) 19 | 20 | gconfig: $(obj)/gconf 21 | $< $(Kconfig) 22 | 23 | menuconfig: $(obj)/mconf 24 | $< $(Kconfig) 25 | 26 | config: $(obj)/conf 27 | $< --oldaskconfig $(Kconfig) 28 | 29 | nconfig: $(obj)/nconf 30 | $< $(Kconfig) 31 | 32 | oldconfig: $(obj)/conf 33 | $< --$@ $(Kconfig) 34 | 35 | silentoldconfig: $(obj)/conf 36 | $(Q)mkdir -p include/generated 37 | $< --$@ $(Kconfig) 38 | 39 | localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 40 | $(Q)mkdir -p include/generated 41 | $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config 42 | $(Q)if [ -f .config ]; then \ 43 | cmp -s .tmp.config .config || \ 44 | (mv -f .config .config.old.1; \ 45 | mv -f .tmp.config .config; \ 46 | $(obj)/conf --silentoldconfig $(Kconfig); \ 47 | mv -f .config.old.1 .config.old) \ 48 | else \ 49 | mv -f .tmp.config .config; \ 50 | $(obj)/conf --silentoldconfig $(Kconfig); \ 51 | fi 52 | $(Q)rm -f .tmp.config 53 | 54 | # Create new linux.pot file 55 | # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 56 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h 57 | $(Q)echo " GEN config.pot" 58 | $(Q)xgettext --default-domain=linux \ 59 | --add-comments --keyword=_ --keyword=N_ \ 60 | --from-code=UTF-8 \ 61 | --files-from=$(srctree)/scripts/kconfig/POTFILES.in \ 62 | --directory=$(srctree) --directory=$(objtree) \ 63 | --output $(obj)/config.pot 64 | $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot 65 | $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \ 66 | $(srctree)/arch/*/um/Kconfig`; \ 67 | do \ 68 | echo " GEN $$i"; \ 69 | $(obj)/kxgettext $$i \ 70 | >> $(obj)/config.pot; \ 71 | done ) 72 | $(Q)echo " GEN linux.pot" 73 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ 74 | --output $(obj)/linux.pot 75 | $(Q)rm -f $(obj)/config.pot 76 | 77 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig 78 | 79 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf 80 | $< --$@ $(Kconfig) 81 | 82 | PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig 83 | 84 | listnewconfig olddefconfig: $(obj)/conf 85 | $< --$@ $(Kconfig) 86 | 87 | # oldnoconfig is an alias of olddefconfig, because people already are dependent 88 | # on its behavior(sets new symbols to their default value but not 'n') with the 89 | # counter-intuitive name. 90 | oldnoconfig: $(obj)/conf 91 | $< --olddefconfig $(Kconfig) 92 | 93 | savedefconfig: $(obj)/conf 94 | $< --$@=defconfig $(Kconfig) 95 | 96 | defconfig: $(obj)/conf 97 | ifeq ($(KBUILD_DEFCONFIG),) 98 | $< --defconfig $(Kconfig) 99 | else 100 | @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 101 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 102 | endif 103 | 104 | %_defconfig: $(obj)/conf 105 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 106 | 107 | # Help text used by make help 108 | help: 109 | @echo ' config - Update current config utilising a line-oriented program' 110 | @echo ' nconfig - Update current config utilising a ncurses menu based program' 111 | @echo ' menuconfig - Update current config utilising a menu based program' 112 | @echo ' xconfig - Update current config utilising a QT based front-end' 113 | @echo ' gconfig - Update current config utilising a GTK based front-end' 114 | @echo ' oldconfig - Update current config utilising a provided .config as base' 115 | @echo ' localmodconfig - Update current config disabling modules not loaded' 116 | @echo ' localyesconfig - Update current config converting local mods to core' 117 | @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' 118 | @echo ' defconfig - New config with default from ARCH supplied defconfig' 119 | @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 120 | @echo ' allnoconfig - New config where all options are answered with no' 121 | @echo ' allyesconfig - New config where all options are accepted with yes' 122 | @echo ' allmodconfig - New config selecting modules when possible' 123 | @echo ' alldefconfig - New config with all symbols set to default' 124 | @echo ' randconfig - New config with random answer to all options' 125 | @echo ' listnewconfig - List new options' 126 | @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value' 127 | 128 | # lxdialog stuff 129 | check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh 130 | 131 | # Use recursively expanded variables so we do not call gcc unless 132 | # we really need to do so. (Do not call gcc as part of make mrproper) 133 | HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \ 134 | -DLOCALE 135 | 136 | # =========================================================================== 137 | # Shared Makefile for the various kconfig executables: 138 | # conf: Used for defconfig, oldconfig and related targets 139 | # nconf: Used for the nconfig target. 140 | # Utilizes ncurses 141 | # mconf: Used for the menuconfig target 142 | # Utilizes the lxdialog package 143 | # qconf: Used for the xconfig target 144 | # Based on QT which needs to be installed to compile it 145 | # gconf: Used for the gconfig target 146 | # Based on GTK which needs to be installed to compile it 147 | # object files used by all kconfig flavours 148 | 149 | lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o 150 | lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o 151 | 152 | conf-objs := conf.o zconf.tab.o 153 | mconf-objs := mconf.o zconf.tab.o $(lxdialog) 154 | nconf-objs := nconf.o zconf.tab.o nconf.gui.o 155 | kxgettext-objs := kxgettext.o zconf.tab.o 156 | qconf-cxxobjs := qconf.o 157 | qconf-objs := zconf.tab.o 158 | gconf-objs := gconf.o zconf.tab.o 159 | 160 | hostprogs-y := conf 161 | 162 | ifeq ($(MAKECMDGOALS),nconfig) 163 | hostprogs-y += nconf 164 | endif 165 | 166 | ifeq ($(MAKECMDGOALS),menuconfig) 167 | hostprogs-y += mconf 168 | endif 169 | 170 | ifeq ($(MAKECMDGOALS),update-po-config) 171 | hostprogs-y += kxgettext 172 | endif 173 | 174 | ifeq ($(MAKECMDGOALS),xconfig) 175 | qconf-target := 1 176 | endif 177 | ifeq ($(MAKECMDGOALS),gconfig) 178 | gconf-target := 1 179 | endif 180 | 181 | 182 | ifeq ($(qconf-target),1) 183 | hostprogs-y += qconf 184 | endif 185 | 186 | ifeq ($(gconf-target),1) 187 | hostprogs-y += gconf 188 | endif 189 | 190 | clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck 191 | clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h 192 | clean-files += mconf qconf gconf nconf 193 | clean-files += config.pot linux.pot 194 | 195 | # Check that we have the required ncurses stuff installed for lxdialog (menuconfig) 196 | PHONY += $(obj)/dochecklxdialog 197 | $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog 198 | $(obj)/dochecklxdialog: 199 | $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf) 200 | 201 | always := dochecklxdialog 202 | 203 | # Add environment specific flags 204 | HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) 205 | 206 | # generated files seem to need this to find local include files 207 | HOSTCFLAGS_zconf.lex.o := -I$(src) 208 | HOSTCFLAGS_zconf.tab.o := -I$(src) 209 | 210 | LEX_PREFIX_zconf := zconf 211 | YACC_PREFIX_zconf := zconf 212 | 213 | HOSTLOADLIBES_qconf = $(KC_QT_LIBS) 214 | HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) 215 | 216 | HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` 217 | HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ 218 | -Wno-missing-prototypes 219 | 220 | HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 221 | 222 | HOSTLOADLIBES_nconf = $(shell \ 223 | pkg-config --libs menu panel ncurses 2>/dev/null \ 224 | || echo "-lmenu -lpanel -lncurses" ) 225 | $(obj)/qconf.o: $(obj)/.tmp_qtcheck 226 | 227 | ifeq ($(qconf-target),1) 228 | $(obj)/.tmp_qtcheck: $(src)/Makefile 229 | -include $(obj)/.tmp_qtcheck 230 | 231 | # QT needs some extra effort... 232 | $(obj)/.tmp_qtcheck: 233 | @set -e; echo " CHECK qt"; dir=""; pkg=""; \ 234 | if ! pkg-config --exists QtCore 2> /dev/null; then \ 235 | echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \ 236 | pkg-config --exists qt 2> /dev/null && pkg=qt; \ 237 | pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ 238 | if [ -n "$$pkg" ]; then \ 239 | cflags="\$$(shell pkg-config $$pkg --cflags)"; \ 240 | libs="\$$(shell pkg-config $$pkg --libs)"; \ 241 | moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ 242 | dir="$$(pkg-config $$pkg --variable=prefix)"; \ 243 | else \ 244 | for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ 245 | if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ 246 | done; \ 247 | if [ -z "$$dir" ]; then \ 248 | echo >&2 "*"; \ 249 | echo >&2 "* Unable to find any QT installation. Please make sure that"; \ 250 | echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \ 251 | echo >&2 "* either qmake can be found or install pkg-config or set"; \ 252 | echo >&2 "* the QTDIR environment variable to the correct location."; \ 253 | echo >&2 "*"; \ 254 | false; \ 255 | fi; \ 256 | libpath=$$dir/lib; lib=qt; osdir=""; \ 257 | $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \ 258 | osdir=x$$($(HOSTCXX) -print-multi-os-directory); \ 259 | test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \ 260 | test -f $$libpath/libqt-mt.so && lib=qt-mt; \ 261 | cflags="-I$$dir/include"; \ 262 | libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \ 263 | moc="$$dir/bin/moc"; \ 264 | fi; \ 265 | if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \ 266 | echo "*"; \ 267 | echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \ 268 | echo "*"; \ 269 | moc="/usr/bin/moc"; \ 270 | fi; \ 271 | else \ 272 | cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ 273 | libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ 274 | moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \ 275 | [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \ 276 | fi; \ 277 | echo "KC_QT_CFLAGS=$$cflags" > $@; \ 278 | echo "KC_QT_LIBS=$$libs" >> $@; \ 279 | echo "KC_QT_MOC=$$moc" >> $@ 280 | endif 281 | 282 | $(obj)/gconf.o: $(obj)/.tmp_gtkcheck 283 | 284 | ifeq ($(gconf-target),1) 285 | -include $(obj)/.tmp_gtkcheck 286 | 287 | # GTK needs some extra effort, too... 288 | $(obj)/.tmp_gtkcheck: 289 | @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \ 290 | if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ 291 | touch $@; \ 292 | else \ 293 | echo >&2 "*"; \ 294 | echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \ 295 | echo >&2 "*"; \ 296 | false; \ 297 | fi \ 298 | else \ 299 | echo >&2 "*"; \ 300 | echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \ 301 | echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \ 302 | echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \ 303 | echo >&2 "*"; \ 304 | false; \ 305 | fi 306 | endif 307 | 308 | $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c 309 | 310 | $(obj)/qconf.o: $(obj)/qconf.moc 311 | 312 | quiet_cmd_moc = MOC $@ 313 | cmd_moc = $(KC_QT_MOC) -i $< -o $@ 314 | 315 | $(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck 316 | $(call cmd,moc) 317 | 318 | # Extract gconf menu items for I18N support 319 | $(obj)/gconf.glade.h: $(obj)/gconf.glade 320 | $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ 321 | $(obj)/gconf.glade 322 | 323 | -------------------------------------------------------------------------------- /.pc/16-fix-space-to-de-select-options.patch/.timestamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillon/kconfig/6814159a0a618a145aa5786a0ec3d311ce81ee91/.pc/16-fix-space-to-de-select-options.patch/.timestamp -------------------------------------------------------------------------------- /.pc/applied-patches: -------------------------------------------------------------------------------- 1 | 01-kconfig-kernel-to-buildroot.patch 2 | 10-br-build-system.patch 3 | 11-use-mktemp-for-lxdialog.patch 4 | 12-fix-glade-file-path.patch 5 | 14-support-out-of-tree-config.patch 6 | 15-fix-qconf-moc-rule.patch 7 | 16-fix-space-to-de-select-options.patch 8 | 100-kconfig-generic-env.patch 9 | 101-kconfig-build.patch 10 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | # 2 | # Default stand alone makefile for kconfig. 3 | # 4 | # The Makefile and Makefile.br in this directory should 5 | # not be called directly for standalone build. 6 | # Actually they are included by this makefile. 7 | # 8 | 9 | ## 10 | # Makefile parameters. 11 | # 12 | # The parameters are configured as for kernel build 13 | # by default. Override them for your application 14 | # setting. 15 | # 16 | 17 | # TOP srcdir and this srcdir (relative to TOPDIR) 18 | TOPDIR=. 19 | SRCDIR=. 20 | 21 | # O: output directory (objs/exes), default to src dir 22 | O=$(TOPDIR)/$(SRCDIR) 23 | 24 | # Build configuration 25 | KBUILD_KCONFIG=Kconfig 26 | KBUILD_CONFIG_DIR=configs 27 | KBUILD_DEFCONFIG=defconfig 28 | 29 | # Product information (exported) 30 | export PRODUCT_ENV=KCONFIG 31 | export PRODUCT=Kernel 32 | export PRODUCT_VERSION= 33 | export PRODUCT_DOMAIN=kernel.org 34 | 35 | # Kconfig configuration (exported) 36 | export $(PRODUCT_ENV)_CONFIG=config 37 | 38 | 39 | # End of Makefile parameters. 40 | ## 41 | 42 | ## 43 | # Makefile adaptation/inclusion. 44 | 45 | # Buid vars 46 | HOSTCC=$(CC) 47 | HOSTCXX=$(CXX) 48 | HOSTCFLAGS=-O2 -g 49 | HOSTCXXFLAGS=-O2 -g 50 | srctree=$(TOPDIR) 51 | src=$(TOPDIR)/$(SRCDIR) 52 | obj=$(O) 53 | 54 | # Enable execution from Makefile *conf programs 55 | export PATH:=$(PATH):$(obj) 56 | 57 | include $(TOPDIR)/$(SRCDIR)/Makefile.br 58 | 59 | # End of Makefile adaptation/inclusion. 60 | ## 61 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # Kernel configuration targets 3 | # These targets are used from top-level makefile 4 | 5 | PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \ 6 | localmodconfig localyesconfig 7 | 8 | ifdef KBUILD_KCONFIG 9 | Kconfig := $(KBUILD_KCONFIG) 10 | else 11 | Kconfig := Kconfig 12 | endif 13 | 14 | ifndef KBUILD_CONFIG_DIR 15 | KBUILD_CONFIG_DIR=arch/$(SRCARCH)/configs 16 | endif 17 | 18 | # We need this, in case the user has it in its environment 19 | unexport CONFIG_ 20 | 21 | xconfig: $(obj)/qconf 22 | $< $(Kconfig) 23 | 24 | gconfig: $(obj)/gconf 25 | $< $(Kconfig) 26 | 27 | menuconfig: $(obj)/mconf 28 | $< $(Kconfig) 29 | 30 | config: $(obj)/conf 31 | $< --oldaskconfig $(Kconfig) 32 | 33 | nconfig: $(obj)/nconf 34 | $< $(Kconfig) 35 | 36 | oldconfig: $(obj)/conf 37 | $< --$@ $(Kconfig) 38 | 39 | silentoldconfig: $(obj)/conf 40 | $(Q)mkdir -p include/generated 41 | $< --$@ $(Kconfig) 42 | 43 | localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 44 | $(Q)mkdir -p include/generated 45 | $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config 46 | $(Q)if [ -f .config ]; then \ 47 | cmp -s .tmp.config .config || \ 48 | (mv -f .config .config.old.1; \ 49 | mv -f .tmp.config .config; \ 50 | $(obj)/conf --silentoldconfig $(Kconfig); \ 51 | mv -f .config.old.1 .config.old) \ 52 | else \ 53 | mv -f .tmp.config .config; \ 54 | $(obj)/conf --silentoldconfig $(Kconfig); \ 55 | fi 56 | $(Q)rm -f .tmp.config 57 | 58 | # Create new linux.pot file 59 | # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 60 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h 61 | $(Q)echo " GEN config.pot" 62 | $(Q)xgettext --default-domain=linux \ 63 | --add-comments --keyword=_ --keyword=N_ \ 64 | --from-code=UTF-8 \ 65 | --files-from=$(srctree)/scripts/kconfig/POTFILES.in \ 66 | --directory=$(srctree) --directory=$(objtree) \ 67 | --output $(obj)/config.pot 68 | $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot 69 | $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \ 70 | $(srctree)/arch/*/um/Kconfig`; \ 71 | do \ 72 | echo " GEN $$i"; \ 73 | $(obj)/kxgettext $$i \ 74 | >> $(obj)/config.pot; \ 75 | done ) 76 | $(Q)echo " GEN linux.pot" 77 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ 78 | --output $(obj)/linux.pot 79 | $(Q)rm -f $(obj)/config.pot 80 | 81 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig 82 | 83 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf 84 | $< --$@ $(Kconfig) 85 | 86 | PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig 87 | 88 | listnewconfig olddefconfig: $(obj)/conf 89 | $< --$@ $(Kconfig) 90 | 91 | # oldnoconfig is an alias of olddefconfig, because people already are dependent 92 | # on its behavior(sets new symbols to their default value but not 'n') with the 93 | # counter-intuitive name. 94 | oldnoconfig: $(obj)/conf 95 | $< --olddefconfig $(Kconfig) 96 | 97 | savedefconfig: $(obj)/conf 98 | $< --$@=defconfig $(Kconfig) 99 | 100 | defconfig: $(obj)/conf 101 | ifeq ($(KBUILD_DEFCONFIG),) 102 | $< --defconfig $(Kconfig) 103 | else 104 | @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 105 | $(Q)$< --defconfig=$(KBUILD_CONFIG_DIR)/$(KBUILD_DEFCONFIG) $(Kconfig) 106 | endif 107 | 108 | %_defconfig: $(obj)/conf 109 | $(Q)$< --defconfig=$(KBUILD_CONFIG_DIR)/$@ $(Kconfig) 110 | 111 | # Help text used by make help 112 | help: 113 | @echo ' config - Update current config utilising a line-oriented program' 114 | @echo ' nconfig - Update current config utilising a ncurses menu based program' 115 | @echo ' menuconfig - Update current config utilising a menu based program' 116 | @echo ' xconfig - Update current config utilising a QT based front-end' 117 | @echo ' gconfig - Update current config utilising a GTK based front-end' 118 | @echo ' oldconfig - Update current config utilising a provided .config as base' 119 | @echo ' localmodconfig - Update current config disabling modules not loaded' 120 | @echo ' localyesconfig - Update current config converting local mods to core' 121 | @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' 122 | @echo ' defconfig - New config with default from ARCH supplied defconfig' 123 | @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 124 | @echo ' allnoconfig - New config where all options are answered with no' 125 | @echo ' allyesconfig - New config where all options are accepted with yes' 126 | @echo ' allmodconfig - New config selecting modules when possible' 127 | @echo ' alldefconfig - New config with all symbols set to default' 128 | @echo ' randconfig - New config with random answer to all options' 129 | @echo ' listnewconfig - List new options' 130 | @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value' 131 | 132 | # lxdialog stuff 133 | check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh 134 | 135 | # Use recursively expanded variables so we do not call gcc unless 136 | # we really need to do so. (Do not call gcc as part of make mrproper) 137 | HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \ 138 | -DLOCALE 139 | 140 | # =========================================================================== 141 | # Shared Makefile for the various kconfig executables: 142 | # conf: Used for defconfig, oldconfig and related targets 143 | # nconf: Used for the nconfig target. 144 | # Utilizes ncurses 145 | # mconf: Used for the menuconfig target 146 | # Utilizes the lxdialog package 147 | # qconf: Used for the xconfig target 148 | # Based on QT which needs to be installed to compile it 149 | # gconf: Used for the gconfig target 150 | # Based on GTK which needs to be installed to compile it 151 | # object files used by all kconfig flavours 152 | 153 | lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o 154 | lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o 155 | 156 | conf-objs := conf.o zconf.tab.o 157 | mconf-objs := mconf.o zconf.tab.o $(lxdialog) 158 | nconf-objs := nconf.o zconf.tab.o nconf.gui.o 159 | kxgettext-objs := kxgettext.o zconf.tab.o 160 | qconf-cxxobjs := qconf.o 161 | qconf-objs := zconf.tab.o 162 | gconf-objs := gconf.o zconf.tab.o 163 | 164 | hostprogs-y := conf 165 | 166 | ifeq ($(MAKECMDGOALS),nconfig) 167 | hostprogs-y += nconf 168 | endif 169 | 170 | ifeq ($(MAKECMDGOALS),menuconfig) 171 | hostprogs-y += mconf 172 | endif 173 | 174 | ifeq ($(MAKECMDGOALS),update-po-config) 175 | hostprogs-y += kxgettext 176 | endif 177 | 178 | ifeq ($(MAKECMDGOALS),xconfig) 179 | qconf-target := 1 180 | endif 181 | ifeq ($(MAKECMDGOALS),gconfig) 182 | gconf-target := 1 183 | endif 184 | 185 | 186 | ifeq ($(qconf-target),1) 187 | hostprogs-y += qconf 188 | endif 189 | 190 | ifeq ($(gconf-target),1) 191 | hostprogs-y += gconf 192 | endif 193 | 194 | clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck 195 | clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h 196 | clean-files += mconf qconf gconf nconf 197 | clean-files += config.pot linux.pot 198 | 199 | # Check that we have the required ncurses stuff installed for lxdialog (menuconfig) 200 | PHONY += $(obj)/dochecklxdialog 201 | $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog 202 | $(obj)/dochecklxdialog: 203 | $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf) 204 | 205 | always := dochecklxdialog 206 | 207 | # Add environment specific flags 208 | HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) 209 | 210 | # generated files seem to need this to find local include files 211 | HOSTCFLAGS_zconf.lex.o := -I$(src) 212 | HOSTCFLAGS_zconf.tab.o := -I$(src) 213 | 214 | LEX_PREFIX_zconf := zconf 215 | YACC_PREFIX_zconf := zconf 216 | 217 | HOSTLOADLIBES_qconf = $(KC_QT_LIBS) 218 | HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) 219 | 220 | HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` 221 | HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ 222 | -Wno-missing-prototypes 223 | 224 | HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 225 | 226 | HOSTLOADLIBES_nconf = $(shell \ 227 | pkg-config --libs menu panel ncurses 2>/dev/null \ 228 | || echo "-lmenu -lpanel -lncurses" ) 229 | $(obj)/qconf.o: $(obj)/.tmp_qtcheck 230 | 231 | ifeq ($(qconf-target),1) 232 | $(obj)/.tmp_qtcheck: $(src)/Makefile 233 | -include $(obj)/.tmp_qtcheck 234 | 235 | # QT needs some extra effort... 236 | $(obj)/.tmp_qtcheck: 237 | @set -e; echo " CHECK qt"; dir=""; pkg=""; \ 238 | if ! pkg-config --exists QtCore 2> /dev/null; then \ 239 | echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \ 240 | pkg-config --exists qt 2> /dev/null && pkg=qt; \ 241 | pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ 242 | if [ -n "$$pkg" ]; then \ 243 | cflags="\$$(shell pkg-config $$pkg --cflags)"; \ 244 | libs="\$$(shell pkg-config $$pkg --libs)"; \ 245 | moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ 246 | dir="$$(pkg-config $$pkg --variable=prefix)"; \ 247 | else \ 248 | for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ 249 | if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ 250 | done; \ 251 | if [ -z "$$dir" ]; then \ 252 | echo >&2 "*"; \ 253 | echo >&2 "* Unable to find any QT installation. Please make sure that"; \ 254 | echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \ 255 | echo >&2 "* either qmake can be found or install pkg-config or set"; \ 256 | echo >&2 "* the QTDIR environment variable to the correct location."; \ 257 | echo >&2 "*"; \ 258 | false; \ 259 | fi; \ 260 | libpath=$$dir/lib; lib=qt; osdir=""; \ 261 | $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \ 262 | osdir=x$$($(HOSTCXX) -print-multi-os-directory); \ 263 | test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \ 264 | test -f $$libpath/libqt-mt.so && lib=qt-mt; \ 265 | cflags="-I$$dir/include"; \ 266 | libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \ 267 | moc="$$dir/bin/moc"; \ 268 | fi; \ 269 | if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \ 270 | echo "*"; \ 271 | echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \ 272 | echo "*"; \ 273 | moc="/usr/bin/moc"; \ 274 | fi; \ 275 | else \ 276 | cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ 277 | libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ 278 | moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \ 279 | [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \ 280 | fi; \ 281 | echo "KC_QT_CFLAGS=$$cflags" > $@; \ 282 | echo "KC_QT_LIBS=$$libs" >> $@; \ 283 | echo "KC_QT_MOC=$$moc" >> $@ 284 | endif 285 | 286 | $(obj)/gconf.o: $(obj)/.tmp_gtkcheck 287 | 288 | ifeq ($(gconf-target),1) 289 | -include $(obj)/.tmp_gtkcheck 290 | 291 | # GTK needs some extra effort, too... 292 | $(obj)/.tmp_gtkcheck: 293 | @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \ 294 | if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ 295 | touch $@; \ 296 | else \ 297 | echo >&2 "*"; \ 298 | echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \ 299 | echo >&2 "*"; \ 300 | false; \ 301 | fi \ 302 | else \ 303 | echo >&2 "*"; \ 304 | echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \ 305 | echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \ 306 | echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \ 307 | echo >&2 "*"; \ 308 | false; \ 309 | fi 310 | endif 311 | 312 | $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c 313 | 314 | $(obj)/qconf.o: $(obj)/qconf.moc 315 | 316 | $(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck 317 | $(KC_QT_MOC) -i $< -o $@ 318 | 319 | # Extract gconf menu items for I18N support 320 | $(obj)/gconf.glade.h: $(obj)/gconf.glade 321 | $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ 322 | $(obj)/gconf.glade 323 | 324 | -------------------------------------------------------------------------------- /Makefile.br: -------------------------------------------------------------------------------- 1 | src ?= . 2 | top_srcdir ?= ../../ 3 | top_builddir ?= ../../ 4 | srctree ?= . 5 | obj ?= . 6 | 7 | include $(src)/Makefile 8 | #HOSTCFLAGS+=-Dinline="" -include foo.h 9 | -include $(obj)/.depend 10 | $(obj)/.depend: $(wildcard *.h *.c) 11 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > $@ 2>/dev/null || : 12 | 13 | __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) 14 | host-csingle := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))) 15 | host-cmulti := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),\ 16 | $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))) 17 | host-cxxmulti := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),\ 18 | $(if $($(m)-cxxobjs),$(m),$(if $($(m)-objs),)))) 19 | host-cobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-objs)))) 20 | host-cxxobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-cxxobjs)))) 21 | 22 | HOST_EXTRACFLAGS += -I$(obj) -DCONFIG_=\"\" 23 | 24 | $(host-csingle): %: %.c 25 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $< -o $@ 26 | 27 | $(host-cmulti): %: $(host-cobjs) $(host-cshlib) 28 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F)) -o $@ 29 | 30 | $(host-cxxmulti): %: $(host-cxxobjs) $(host-cobjs) $(host-cshlib) 31 | $(HOSTCXX) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$(@F)) $(addprefix $(obj)/,$($(@F)-objs) $($(@F)-cxxobjs)) $(HOSTLOADLIBES_$(@F)) -o $@ 32 | 33 | $(obj)/%.o: %.c 34 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) -c $< -o $@ 35 | 36 | $(obj)/%.o: $(obj)/%.c 37 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) -c $< -o $@ 38 | 39 | $(obj)/%.o: %.cc 40 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$(@F)) -c $< -o $@ 41 | 42 | $(obj)/%:: $(src)/%_shipped 43 | $(Q)cat $< > $@ 44 | 45 | clean: 46 | $(Q)rm -f $(addprefix $(obj)/,$(clean-files)) 47 | distclean: clean 48 | $(Q)rm -f $(addprefix $(obj)/,$(lxdialog) $(conf-objs) $(mconf-objs) $(kxgettext-objs) \ 49 | $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \ 50 | mconf .depend) 51 | 52 | FORCE: 53 | .PHONY: FORCE clean distclean 54 | -------------------------------------------------------------------------------- /POTFILES.in: -------------------------------------------------------------------------------- 1 | scripts/kconfig/lxdialog/checklist.c 2 | scripts/kconfig/lxdialog/inputbox.c 3 | scripts/kconfig/lxdialog/menubox.c 4 | scripts/kconfig/lxdialog/textbox.c 5 | scripts/kconfig/lxdialog/util.c 6 | scripts/kconfig/lxdialog/yesno.c 7 | scripts/kconfig/mconf.c 8 | scripts/kconfig/conf.c 9 | scripts/kconfig/confdata.c 10 | scripts/kconfig/gconf.c 11 | scripts/kconfig/gconf.glade.h 12 | scripts/kconfig/qconf.cc 13 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | # Synopsys 3 | 4 | kconfig is an isolated packaging of the kernel configuration tools 5 | as found in the scripts/kconfig/ directory of the kernel sources. 6 | 7 | The purpose is to provide the great functionalities of the kernel 8 | configuration mechanism to any project that need application 9 | level configuration. 10 | 11 | # Usage 12 | 13 | On can extract kconfig sources and run without installation 14 | from his own project directory: 15 | 16 | $ cd myproject/ 17 | $ kconfig/config.sh manuconfig 18 | 19 | As a default the mypoject/Kconfig file must be present for 20 | declaring the project configuration. 21 | The result is a myproject/config file which can be sources in 22 | a shell of makefile script. 23 | 24 | Alternatively the call to: 25 | 26 | $ kconfig/config.sh menuconfig 27 | 28 | can be replaced by a direct call to the kconfig/GNUmakefile: 29 | 30 | $ make -f kconfig/GNUmakefile TOPDIR=. SRCDIR=kconfig 31 | 32 | Note that all common kernel configuration targets are available, 33 | in particular config, menuconfig, nconfig, gconfig, xconfig, 34 | defconfig, oldconfig, etc... 35 | 36 | Get the list of targets with: 37 | 38 | $ kconfig/config.sh help 39 | 40 | or 41 | 42 | $ make -f kconfig/GNUmakefile help TOPDIR=. SRCDIR=kconfig 43 | 44 | 45 | # References 46 | 47 | Ref to buildroot README.buildroot file for the original idea 48 | of packaging kconfig. 49 | 50 | Ref to kernel.org for actual contributors of kconfig. 51 | -------------------------------------------------------------------------------- /README.buildroot: -------------------------------------------------------------------------------- 1 | This is a copy of the kconfig code in the kernel (currently 3.13-rc5) tweaked 2 | to suit Buildroot. 3 | 4 | To update: 5 | cp -r /usr/src/linux/scripts/kconfig support/kconfig.new 6 | cd support/kconfig.new 7 | cp -a ../kconfig/patches ../kconfig/README.buildroot ../kconfig/.gitignore . 8 | quilt push -a 9 | # Fix any conflict 10 | cd .. 11 | rm -rf kconfig 12 | mv kconfig.new kconfig 13 | 14 | Then verify the toplevel targets work: 15 | config 16 | defconfig 17 | menuconfig 18 | xconfig 19 | gconfig 20 | oldconfig 21 | -------------------------------------------------------------------------------- /check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Needed for systems without gettext 3 | $* -x c -o /dev/null - > /dev/null 2>&1 << EOF 4 | #include 5 | int main() 6 | { 7 | gettext(""); 8 | return 0; 9 | } 10 | EOF 11 | if [ ! "$?" -eq "0" ]; then 12 | echo -DKBUILD_NO_NLS; 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # usage: kconfig/config.sh 4 | # 5 | # Runs the requested configuration from 6 | # the directory to be configured. 7 | # 8 | # For instance: 9 | # cd myproject/ 10 | # kconfig/config.sh menuconfig 11 | # 12 | # Will generated a 'config' file in 13 | # myproject/ from the 'Kconfig' file 14 | # in myproject/ 15 | # 16 | 17 | set -e 18 | dir=`dirname $0` 19 | topdir=`dirname $dir` 20 | srcdir=`basename $dir` 21 | kconfig_targets="${1-config}" 22 | set -x 23 | exec make -f $dir/GNUmakefile \ 24 | TOPDIR=$topdir \ 25 | SRCDIR=$srcdir \ 26 | $kconfig_targets 27 | -------------------------------------------------------------------------------- /expr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Roman Zippel 3 | * Released under the terms of the GNU GPL v2.0. 4 | */ 5 | 6 | #ifndef EXPR_H 7 | #define EXPR_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #include 14 | #include 15 | #include "list.h" 16 | #ifndef __cplusplus 17 | #include 18 | #endif 19 | 20 | struct file { 21 | struct file *next; 22 | struct file *parent; 23 | const char *name; 24 | int lineno; 25 | }; 26 | 27 | typedef enum tristate { 28 | no, mod, yes 29 | } tristate; 30 | 31 | enum expr_type { 32 | E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE 33 | }; 34 | 35 | union expr_data { 36 | struct expr *expr; 37 | struct symbol *sym; 38 | }; 39 | 40 | struct expr { 41 | enum expr_type type; 42 | union expr_data left, right; 43 | }; 44 | 45 | #define EXPR_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) 46 | #define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) 47 | #define EXPR_NOT(dep) (2-(dep)) 48 | 49 | #define expr_list_for_each_sym(l, e, s) \ 50 | for (e = (l); e && (s = e->right.sym); e = e->left.expr) 51 | 52 | struct expr_value { 53 | struct expr *expr; 54 | tristate tri; 55 | }; 56 | 57 | struct symbol_value { 58 | void *val; 59 | tristate tri; 60 | }; 61 | 62 | enum symbol_type { 63 | S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER 64 | }; 65 | 66 | /* enum values are used as index to symbol.def[] */ 67 | enum { 68 | S_DEF_USER, /* main user value */ 69 | S_DEF_AUTO, /* values read from auto.conf */ 70 | S_DEF_DEF3, /* Reserved for UI usage */ 71 | S_DEF_DEF4, /* Reserved for UI usage */ 72 | S_DEF_COUNT 73 | }; 74 | 75 | struct symbol { 76 | struct symbol *next; 77 | char *name; 78 | enum symbol_type type; 79 | struct symbol_value curr; 80 | struct symbol_value def[S_DEF_COUNT]; 81 | tristate visible; 82 | int flags; 83 | struct property *prop; 84 | struct expr_value dir_dep; 85 | struct expr_value rev_dep; 86 | }; 87 | 88 | #define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) 89 | 90 | #define SYMBOL_CONST 0x0001 /* symbol is const */ 91 | #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ 92 | #define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */ 93 | #define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ 94 | #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ 95 | #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ 96 | #define SYMBOL_WRITE 0x0200 /* write symbol to file (PRODUCT_ENV"_CONFIG") */ 97 | #define SYMBOL_CHANGED 0x0400 /* ? */ 98 | #define SYMBOL_AUTO 0x1000 /* value from environment variable */ 99 | #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ 100 | #define SYMBOL_WARNED 0x8000 /* warning has been issued */ 101 | 102 | /* Set when symbol.def[] is used */ 103 | #define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */ 104 | #define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */ 105 | #define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */ 106 | #define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ 107 | #define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ 108 | 109 | /* choice values need to be set before calculating this symbol value */ 110 | #define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 111 | 112 | #define SYMBOL_MAXLENGTH 256 113 | #define SYMBOL_HASHSIZE 9973 114 | 115 | /* A property represent the config options that can be associated 116 | * with a config "symbol". 117 | * Sample: 118 | * config FOO 119 | * default y 120 | * prompt "foo prompt" 121 | * select BAR 122 | * config BAZ 123 | * int "BAZ Value" 124 | * range 1..255 125 | */ 126 | enum prop_type { 127 | P_UNKNOWN, 128 | P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ 129 | P_COMMENT, /* text associated with a comment */ 130 | P_MENU, /* prompt associated with a menuconfig option */ 131 | P_DEFAULT, /* default y */ 132 | P_CHOICE, /* choice value */ 133 | P_SELECT, /* select BAR */ 134 | P_RANGE, /* range 7..100 (for a symbol) */ 135 | P_ENV, /* value from environment variable */ 136 | P_SYMBOL, /* where a symbol is defined */ 137 | }; 138 | 139 | struct property { 140 | struct property *next; /* next property - null if last */ 141 | struct symbol *sym; /* the symbol for which the property is associated */ 142 | enum prop_type type; /* type of property */ 143 | const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */ 144 | struct expr_value visible; 145 | struct expr *expr; /* the optional conditional part of the property */ 146 | struct menu *menu; /* the menu the property are associated with 147 | * valid for: P_SELECT, P_RANGE, P_CHOICE, 148 | * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ 149 | struct file *file; /* what file was this property defined */ 150 | int lineno; /* what lineno was this property defined */ 151 | }; 152 | 153 | #define for_all_properties(sym, st, tok) \ 154 | for (st = sym->prop; st; st = st->next) \ 155 | if (st->type == (tok)) 156 | #define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) 157 | #define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) 158 | #define for_all_prompts(sym, st) \ 159 | for (st = sym->prop; st; st = st->next) \ 160 | if (st->text) 161 | 162 | struct menu { 163 | struct menu *next; 164 | struct menu *parent; 165 | struct menu *list; 166 | struct symbol *sym; 167 | struct property *prompt; 168 | struct expr *visibility; 169 | struct expr *dep; 170 | unsigned int flags; 171 | char *help; 172 | struct file *file; 173 | int lineno; 174 | void *data; 175 | }; 176 | 177 | #define MENU_CHANGED 0x0001 178 | #define MENU_ROOT 0x0002 179 | 180 | struct jump_key { 181 | struct list_head entries; 182 | size_t offset; 183 | struct menu *target; 184 | int index; 185 | }; 186 | 187 | #define JUMP_NB 9 188 | 189 | extern struct file *file_list; 190 | extern struct file *current_file; 191 | struct file *lookup_file(const char *name); 192 | 193 | extern struct symbol symbol_yes, symbol_no, symbol_mod; 194 | extern struct symbol *modules_sym; 195 | extern struct symbol *sym_defconfig_list; 196 | extern int cdebug; 197 | struct expr *expr_alloc_symbol(struct symbol *sym); 198 | struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); 199 | struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); 200 | struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); 201 | struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); 202 | struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); 203 | struct expr *expr_copy(const struct expr *org); 204 | void expr_free(struct expr *e); 205 | int expr_eq(struct expr *e1, struct expr *e2); 206 | void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); 207 | tristate expr_calc_value(struct expr *e); 208 | struct expr *expr_eliminate_yn(struct expr *e); 209 | struct expr *expr_trans_bool(struct expr *e); 210 | struct expr *expr_eliminate_dups(struct expr *e); 211 | struct expr *expr_transform(struct expr *e); 212 | int expr_contains_symbol(struct expr *dep, struct symbol *sym); 213 | bool expr_depends_symbol(struct expr *dep, struct symbol *sym); 214 | struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); 215 | struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); 216 | void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); 217 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); 218 | struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); 219 | 220 | void expr_fprint(struct expr *e, FILE *out); 221 | struct gstr; /* forward */ 222 | void expr_gstr_print(struct expr *e, struct gstr *gs); 223 | 224 | static inline int expr_is_yes(struct expr *e) 225 | { 226 | return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); 227 | } 228 | 229 | static inline int expr_is_no(struct expr *e) 230 | { 231 | return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); 232 | } 233 | 234 | #ifdef __cplusplus 235 | } 236 | #endif 237 | 238 | #endif /* EXPR_H */ 239 | -------------------------------------------------------------------------------- /foo.h: -------------------------------------------------------------------------------- 1 | #ifndef __KCONFIG_FOO_H 2 | #define __KCONFIG_FOO_H 3 | 4 | #ifndef __APPLE__ 5 | #include 6 | #endif 7 | #include 8 | 9 | #ifndef PATH_MAX 10 | #define PATH_MAX 1024 11 | #endif 12 | #endif /* __KCONFIG_FOO_H */ 13 | -------------------------------------------------------------------------------- /images.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Roman Zippel 3 | * Released under the terms of the GNU GPL v2.0. 4 | */ 5 | 6 | static 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 | 36 | static 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 | 66 | static 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 | 94 | static 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 | 121 | static 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 | 148 | static 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 | 175 | static 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 | 192 | static 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 | 209 | static 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 | 226 | static 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 | 243 | static 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 | 260 | static 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 | 277 | static 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 | 294 | static 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 | 311 | static 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 | " "}; 327 | -------------------------------------------------------------------------------- /kxgettext.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Arnaldo Carvalho de Melo , 2005 3 | * 4 | * Released under the terms of the GNU GPL v2.0 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #include "lkc.h" 11 | 12 | static char *escape(const char* text, char *bf, int len) 13 | { 14 | char *bfp = bf; 15 | int multiline = strchr(text, '\n') != NULL; 16 | int eol = 0; 17 | int textlen = strlen(text); 18 | 19 | if ((textlen > 0) && (text[textlen-1] == '\n')) 20 | eol = 1; 21 | 22 | *bfp++ = '"'; 23 | --len; 24 | 25 | if (multiline) { 26 | *bfp++ = '"'; 27 | *bfp++ = '\n'; 28 | *bfp++ = '"'; 29 | len -= 3; 30 | } 31 | 32 | while (*text != '\0' && len > 1) { 33 | if (*text == '"') 34 | *bfp++ = '\\'; 35 | else if (*text == '\n') { 36 | *bfp++ = '\\'; 37 | *bfp++ = 'n'; 38 | *bfp++ = '"'; 39 | *bfp++ = '\n'; 40 | *bfp++ = '"'; 41 | len -= 5; 42 | ++text; 43 | goto next; 44 | } 45 | else if (*text == '\\') { 46 | *bfp++ = '\\'; 47 | len--; 48 | } 49 | *bfp++ = *text++; 50 | next: 51 | --len; 52 | } 53 | 54 | if (multiline && eol) 55 | bfp -= 3; 56 | 57 | *bfp++ = '"'; 58 | *bfp = '\0'; 59 | 60 | return bf; 61 | } 62 | 63 | struct file_line { 64 | struct file_line *next; 65 | const char *file; 66 | int lineno; 67 | }; 68 | 69 | static struct file_line *file_line__new(const char *file, int lineno) 70 | { 71 | struct file_line *self = malloc(sizeof(*self)); 72 | 73 | if (self == NULL) 74 | goto out; 75 | 76 | self->file = file; 77 | self->lineno = lineno; 78 | self->next = NULL; 79 | out: 80 | return self; 81 | } 82 | 83 | struct message { 84 | const char *msg; 85 | const char *option; 86 | struct message *next; 87 | struct file_line *files; 88 | }; 89 | 90 | static struct message *message__list; 91 | 92 | static struct message *message__new(const char *msg, char *option, 93 | const char *file, int lineno) 94 | { 95 | struct message *self = malloc(sizeof(*self)); 96 | 97 | if (self == NULL) 98 | goto out; 99 | 100 | self->files = file_line__new(file, lineno); 101 | if (self->files == NULL) 102 | goto out_fail; 103 | 104 | self->msg = strdup(msg); 105 | if (self->msg == NULL) 106 | goto out_fail_msg; 107 | 108 | self->option = option; 109 | self->next = NULL; 110 | out: 111 | return self; 112 | out_fail_msg: 113 | free(self->files); 114 | out_fail: 115 | free(self); 116 | self = NULL; 117 | goto out; 118 | } 119 | 120 | static struct message *mesage__find(const char *msg) 121 | { 122 | struct message *m = message__list; 123 | 124 | while (m != NULL) { 125 | if (strcmp(m->msg, msg) == 0) 126 | break; 127 | m = m->next; 128 | } 129 | 130 | return m; 131 | } 132 | 133 | static int message__add_file_line(struct message *self, const char *file, 134 | int lineno) 135 | { 136 | int rc = -1; 137 | struct file_line *fl = file_line__new(file, lineno); 138 | 139 | if (fl == NULL) 140 | goto out; 141 | 142 | fl->next = self->files; 143 | self->files = fl; 144 | rc = 0; 145 | out: 146 | return rc; 147 | } 148 | 149 | static int message__add(const char *msg, char *option, const char *file, 150 | int lineno) 151 | { 152 | int rc = 0; 153 | char bf[16384]; 154 | char *escaped = escape(msg, bf, sizeof(bf)); 155 | struct message *m = mesage__find(escaped); 156 | 157 | if (m != NULL) 158 | rc = message__add_file_line(m, file, lineno); 159 | else { 160 | m = message__new(escaped, option, file, lineno); 161 | 162 | if (m != NULL) { 163 | m->next = message__list; 164 | message__list = m; 165 | } else 166 | rc = -1; 167 | } 168 | return rc; 169 | } 170 | 171 | static void menu_build_message_list(struct menu *menu) 172 | { 173 | struct menu *child; 174 | 175 | message__add(menu_get_prompt(menu), NULL, 176 | menu->file == NULL ? "Root Menu" : menu->file->name, 177 | menu->lineno); 178 | 179 | if (menu->sym != NULL && menu_has_help(menu)) 180 | message__add(menu_get_help(menu), menu->sym->name, 181 | menu->file == NULL ? "Root Menu" : menu->file->name, 182 | menu->lineno); 183 | 184 | for (child = menu->list; child != NULL; child = child->next) 185 | if (child->prompt != NULL) 186 | menu_build_message_list(child); 187 | } 188 | 189 | static void message__print_file_lineno(struct message *self) 190 | { 191 | struct file_line *fl = self->files; 192 | 193 | putchar('\n'); 194 | if (self->option != NULL) 195 | printf("# %s:00000\n", self->option); 196 | 197 | printf("#: %s:%d", fl->file, fl->lineno); 198 | fl = fl->next; 199 | 200 | while (fl != NULL) { 201 | printf(", %s:%d", fl->file, fl->lineno); 202 | fl = fl->next; 203 | } 204 | 205 | putchar('\n'); 206 | } 207 | 208 | static void message__print_gettext_msgid_msgstr(struct message *self) 209 | { 210 | message__print_file_lineno(self); 211 | 212 | printf("msgid %s\n" 213 | "msgstr \"\"\n", self->msg); 214 | } 215 | 216 | static void menu__xgettext(void) 217 | { 218 | struct message *m = message__list; 219 | 220 | while (m != NULL) { 221 | /* skip empty lines ("") */ 222 | if (strlen(m->msg) > sizeof("\"\"")) 223 | message__print_gettext_msgid_msgstr(m); 224 | m = m->next; 225 | } 226 | } 227 | 228 | int main(int ac, char **av) 229 | { 230 | conf_parse(av[1]); 231 | 232 | menu_build_message_list(menu_get_root_menu(NULL)); 233 | menu__xgettext(); 234 | return 0; 235 | } 236 | -------------------------------------------------------------------------------- /list.h: -------------------------------------------------------------------------------- 1 | #ifndef LIST_H 2 | #define LIST_H 3 | 4 | /* 5 | * Copied from include/linux/... 6 | */ 7 | 8 | #undef offsetof 9 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 10 | 11 | /** 12 | * container_of - cast a member of a structure out to the containing structure 13 | * @ptr: the pointer to the member. 14 | * @type: the type of the container struct this is embedded in. 15 | * @member: the name of the member within the struct. 16 | * 17 | */ 18 | #define container_of(ptr, type, member) ({ \ 19 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 20 | (type *)( (char *)__mptr - offsetof(type,member) );}) 21 | 22 | 23 | struct list_head { 24 | struct list_head *next, *prev; 25 | }; 26 | 27 | 28 | #define LIST_HEAD_INIT(name) { &(name), &(name) } 29 | 30 | #define LIST_HEAD(name) \ 31 | struct list_head name = LIST_HEAD_INIT(name) 32 | 33 | /** 34 | * list_entry - get the struct for this entry 35 | * @ptr: the &struct list_head pointer. 36 | * @type: the type of the struct this is embedded in. 37 | * @member: the name of the list_struct within the struct. 38 | */ 39 | #define list_entry(ptr, type, member) \ 40 | container_of(ptr, type, member) 41 | 42 | /** 43 | * list_for_each_entry - iterate over list of given type 44 | * @pos: the type * to use as a loop cursor. 45 | * @head: the head for your list. 46 | * @member: the name of the list_struct within the struct. 47 | */ 48 | #define list_for_each_entry(pos, head, member) \ 49 | for (pos = list_entry((head)->next, typeof(*pos), member); \ 50 | &pos->member != (head); \ 51 | pos = list_entry(pos->member.next, typeof(*pos), member)) 52 | 53 | /** 54 | * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry 55 | * @pos: the type * to use as a loop cursor. 56 | * @n: another type * to use as temporary storage 57 | * @head: the head for your list. 58 | * @member: the name of the list_struct within the struct. 59 | */ 60 | #define list_for_each_entry_safe(pos, n, head, member) \ 61 | for (pos = list_entry((head)->next, typeof(*pos), member), \ 62 | n = list_entry(pos->member.next, typeof(*pos), member); \ 63 | &pos->member != (head); \ 64 | pos = n, n = list_entry(n->member.next, typeof(*n), member)) 65 | 66 | /** 67 | * list_empty - tests whether a list is empty 68 | * @head: the list to test. 69 | */ 70 | static inline int list_empty(const struct list_head *head) 71 | { 72 | return head->next == head; 73 | } 74 | 75 | /* 76 | * Insert a new entry between two known consecutive entries. 77 | * 78 | * This is only for internal list manipulation where we know 79 | * the prev/next entries already! 80 | */ 81 | static inline void __list_add(struct list_head *_new, 82 | struct list_head *prev, 83 | struct list_head *next) 84 | { 85 | next->prev = _new; 86 | _new->next = next; 87 | _new->prev = prev; 88 | prev->next = _new; 89 | } 90 | 91 | /** 92 | * list_add_tail - add a new entry 93 | * @new: new entry to be added 94 | * @head: list head to add it before 95 | * 96 | * Insert a new entry before the specified head. 97 | * This is useful for implementing queues. 98 | */ 99 | static inline void list_add_tail(struct list_head *_new, struct list_head *head) 100 | { 101 | __list_add(_new, head->prev, head); 102 | } 103 | 104 | /* 105 | * Delete a list entry by making the prev/next entries 106 | * point to each other. 107 | * 108 | * This is only for internal list manipulation where we know 109 | * the prev/next entries already! 110 | */ 111 | static inline void __list_del(struct list_head *prev, struct list_head *next) 112 | { 113 | next->prev = prev; 114 | prev->next = next; 115 | } 116 | 117 | #define LIST_POISON1 ((void *) 0x00100100) 118 | #define LIST_POISON2 ((void *) 0x00200200) 119 | /** 120 | * list_del - deletes entry from list. 121 | * @entry: the element to delete from the list. 122 | * Note: list_empty() on entry does not return true after this, the entry is 123 | * in an undefined state. 124 | */ 125 | static inline void list_del(struct list_head *entry) 126 | { 127 | __list_del(entry->prev, entry->next); 128 | entry->next = (struct list_head*)LIST_POISON1; 129 | entry->prev = (struct list_head*)LIST_POISON2; 130 | } 131 | #endif 132 | -------------------------------------------------------------------------------- /lkc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Roman Zippel 3 | * Released under the terms of the GNU GPL v2.0. 4 | */ 5 | 6 | #ifndef LKC_H 7 | #define LKC_H 8 | 9 | #include "expr.h" 10 | 11 | #ifndef KBUILD_NO_NLS 12 | # include 13 | #else 14 | static inline const char *gettext(const char *txt) { return txt; } 15 | static inline void textdomain(const char *domainname) {} 16 | static inline void bindtextdomain(const char *name, const char *dir) {} 17 | static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; } 18 | #endif 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #ifndef PRODUCT_ENV 25 | /* BR2 for buildroot, KCONFIG for kernel. */ 26 | #define PRODUCT_ENV "KCONFIG" 27 | #endif 28 | 29 | #ifndef PRODUCT 30 | /* Buildroot buildroot, Kernel for kernel. */ 31 | #define PRODUCT "Kernel" 32 | #endif 33 | 34 | #ifndef PRODUCT_DOMAIN 35 | /* buildroot.org for buildroot, kernel.org for kernel. */ 36 | #define PRODUCT_DOMAIN "kernel.org" 37 | #endif 38 | 39 | #define P(name,type,arg) extern type name arg 40 | #include "lkc_proto.h" 41 | #undef P 42 | 43 | #define SRCTREE "srctree" 44 | 45 | #ifndef PACKAGE 46 | #define PACKAGE "linux" 47 | #endif 48 | 49 | #define LOCALEDIR "/usr/share/locale" 50 | 51 | #define _(text) gettext(text) 52 | #define N_(text) (text) 53 | 54 | #ifndef CONFIG_ 55 | #define CONFIG_ "CONFIG_" 56 | #endif 57 | static inline const char *CONFIG_prefix(void) 58 | { 59 | return getenv( "CONFIG_" ) ?: CONFIG_; 60 | } 61 | #undef CONFIG_ 62 | #define CONFIG_ CONFIG_prefix() 63 | 64 | #define TF_COMMAND 0x0001 65 | #define TF_PARAM 0x0002 66 | #define TF_OPTION 0x0004 67 | 68 | enum conf_def_mode { 69 | def_default, 70 | def_yes, 71 | def_mod, 72 | def_no, 73 | def_random 74 | }; 75 | 76 | #define T_OPT_MODULES 1 77 | #define T_OPT_DEFCONFIG_LIST 2 78 | #define T_OPT_ENV 3 79 | 80 | struct kconf_id { 81 | int name; 82 | int token; 83 | unsigned int flags; 84 | enum symbol_type stype; 85 | }; 86 | 87 | extern int zconfdebug; 88 | 89 | int zconfparse(void); 90 | void zconfdump(FILE *out); 91 | void zconf_starthelp(void); 92 | FILE *zconf_fopen(const char *name); 93 | void zconf_initscan(const char *name); 94 | void zconf_nextfile(const char *name); 95 | int zconf_lineno(void); 96 | const char *zconf_curname(void); 97 | 98 | /* confdata.c */ 99 | const char *conf_get_configname(void); 100 | const char *conf_get_autoconfig_name(void); 101 | char *conf_get_default_confname(void); 102 | void sym_set_change_count(int count); 103 | void sym_add_change_count(int count); 104 | bool conf_set_all_new_symbols(enum conf_def_mode mode); 105 | void set_all_choice_values(struct symbol *csym); 106 | 107 | struct conf_printer { 108 | void (*print_symbol)(FILE *, struct symbol *, const char *, void *); 109 | void (*print_comment)(FILE *, const char *, void *); 110 | }; 111 | 112 | /* confdata.c and expr.c */ 113 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) 114 | { 115 | assert(len != 0); 116 | 117 | if (fwrite(str, len, count, out) != count) 118 | fprintf(stderr, "Error in writing or end of file.\n"); 119 | } 120 | 121 | /* menu.c */ 122 | void _menu_init(void); 123 | void menu_warn(struct menu *menu, const char *fmt, ...); 124 | struct menu *menu_add_menu(void); 125 | void menu_end_menu(void); 126 | void menu_add_entry(struct symbol *sym); 127 | void menu_end_entry(void); 128 | void menu_add_dep(struct expr *dep); 129 | void menu_add_visibility(struct expr *dep); 130 | struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); 131 | struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); 132 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); 133 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); 134 | void menu_add_option(int token, char *arg); 135 | void menu_finalize(struct menu *parent); 136 | void menu_set_type(int type); 137 | 138 | /* util.c */ 139 | struct file *file_lookup(const char *name); 140 | int file_write_dep(const char *name); 141 | void *xmalloc(size_t size); 142 | void *xcalloc(size_t nmemb, size_t size); 143 | 144 | struct gstr { 145 | size_t len; 146 | char *s; 147 | /* 148 | * when max_width is not zero long lines in string s (if any) get 149 | * wrapped not to exceed the max_width value 150 | */ 151 | int max_width; 152 | }; 153 | struct gstr str_new(void); 154 | struct gstr str_assign(const char *s); 155 | void str_free(struct gstr *gs); 156 | void str_append(struct gstr *gs, const char *s); 157 | void str_printf(struct gstr *gs, const char *fmt, ...); 158 | const char *str_get(struct gstr *gs); 159 | 160 | /* symbol.c */ 161 | extern struct expr *sym_env_list; 162 | 163 | void sym_init(void); 164 | void sym_clear_all_valid(void); 165 | void sym_set_all_changed(void); 166 | void sym_set_changed(struct symbol *sym); 167 | struct symbol *sym_choice_default(struct symbol *sym); 168 | const char *sym_get_string_default(struct symbol *sym); 169 | struct symbol *sym_check_deps(struct symbol *sym); 170 | struct property *prop_alloc(enum prop_type type, struct symbol *sym); 171 | struct symbol *prop_get_symbol(struct property *prop); 172 | struct property *sym_get_env_prop(struct symbol *sym); 173 | 174 | static inline tristate sym_get_tristate_value(struct symbol *sym) 175 | { 176 | return sym->curr.tri; 177 | } 178 | 179 | 180 | static inline struct symbol *sym_get_choice_value(struct symbol *sym) 181 | { 182 | return (struct symbol *)sym->curr.val; 183 | } 184 | 185 | static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) 186 | { 187 | return sym_set_tristate_value(chval, yes); 188 | } 189 | 190 | static inline bool sym_is_choice(struct symbol *sym) 191 | { 192 | return sym->flags & SYMBOL_CHOICE ? true : false; 193 | } 194 | 195 | static inline bool sym_is_choice_value(struct symbol *sym) 196 | { 197 | return sym->flags & SYMBOL_CHOICEVAL ? true : false; 198 | } 199 | 200 | static inline bool sym_is_optional(struct symbol *sym) 201 | { 202 | return sym->flags & SYMBOL_OPTIONAL ? true : false; 203 | } 204 | 205 | static inline bool sym_has_value(struct symbol *sym) 206 | { 207 | return sym->flags & SYMBOL_DEF_USER ? true : false; 208 | } 209 | 210 | #ifdef __cplusplus 211 | } 212 | #endif 213 | 214 | #endif /* LKC_H */ 215 | -------------------------------------------------------------------------------- /lkc_proto.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* confdata.c */ 4 | P(conf_parse,void,(const char *name)); 5 | P(conf_read,int,(const char *name)); 6 | P(conf_read_simple,int,(const char *name, int)); 7 | P(conf_write_defconfig,int,(const char *name)); 8 | P(conf_write,int,(const char *name)); 9 | P(conf_write_autoconf,int,(void)); 10 | P(conf_get_changed,bool,(void)); 11 | P(conf_set_changed_callback, void,(void (*fn)(void))); 12 | P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap))); 13 | 14 | /* menu.c */ 15 | P(rootmenu,struct menu,); 16 | 17 | P(menu_is_empty, bool, (struct menu *menu)); 18 | P(menu_is_visible, bool, (struct menu *menu)); 19 | P(menu_has_prompt, bool, (struct menu *menu)); 20 | P(menu_get_prompt,const char *,(struct menu *menu)); 21 | P(menu_get_root_menu,struct menu *,(struct menu *menu)); 22 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 23 | P(menu_has_help,bool,(struct menu *menu)); 24 | P(menu_get_help,const char *,(struct menu *menu)); 25 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head 26 | *head)); 27 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head 28 | *head)); 29 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); 30 | 31 | /* symbol.c */ 32 | P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); 33 | 34 | P(sym_lookup,struct symbol *,(const char *name, int flags)); 35 | P(sym_find,struct symbol *,(const char *name)); 36 | P(sym_expand_string_value,const char *,(const char *in)); 37 | P(sym_escape_string_value, const char *,(const char *in)); 38 | P(sym_re_search,struct symbol **,(const char *pattern)); 39 | P(sym_type_name,const char *,(enum symbol_type type)); 40 | P(sym_calc_value,void,(struct symbol *sym)); 41 | P(sym_get_type,enum symbol_type,(struct symbol *sym)); 42 | P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); 43 | P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); 44 | P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); 45 | P(sym_string_valid,bool,(struct symbol *sym, const char *newval)); 46 | P(sym_string_within_range,bool,(struct symbol *sym, const char *str)); 47 | P(sym_set_string_value,bool,(struct symbol *sym, const char *newval)); 48 | P(sym_is_changable,bool,(struct symbol *sym)); 49 | P(sym_get_choice_prop,struct property *,(struct symbol *sym)); 50 | P(sym_get_default_prop,struct property *,(struct symbol *sym)); 51 | P(sym_get_string_value,const char *,(struct symbol *sym)); 52 | 53 | P(prop_get_type_name,const char *,(enum prop_type type)); 54 | 55 | /* expr.c */ 56 | P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); 57 | P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)); 58 | -------------------------------------------------------------------------------- /lxdialog/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Generated files 3 | # 4 | lxdialog 5 | -------------------------------------------------------------------------------- /lxdialog/BIG.FAT.WARNING: -------------------------------------------------------------------------------- 1 | This is NOT the official version of dialog. This version has been 2 | significantly modified from the original. It is for use by the Linux 3 | kernel configuration script. Please do not bother Savio Lam with 4 | questions about this program. 5 | -------------------------------------------------------------------------------- /lxdialog/check-lxdialog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Check ncurses compatibility 3 | 4 | # What library to link 5 | ldflags() 6 | { 7 | pkg-config --libs ncursesw 2>/dev/null && exit 8 | pkg-config --libs ncurses 2>/dev/null && exit 9 | for ext in so a dll.a dylib ; do 10 | for lib in ncursesw ncurses curses ; do 11 | $cc -print-file-name=lib${lib}.${ext} | grep -q / 12 | if [ $? -eq 0 ]; then 13 | echo "-l${lib}" 14 | exit 15 | fi 16 | done 17 | done 18 | exit 1 19 | } 20 | 21 | # Where is ncurses.h? 22 | ccflags() 23 | { 24 | if [ -f /usr/include/ncursesw/curses.h ]; then 25 | echo '-I/usr/include/ncursesw -DCURSES_LOC=""' 26 | echo ' -DNCURSES_WIDECHAR=1' 27 | elif [ -f /usr/include/ncurses/ncurses.h ]; then 28 | echo '-I/usr/include/ncurses -DCURSES_LOC=""' 29 | elif [ -f /usr/include/ncurses/curses.h ]; then 30 | echo '-I/usr/include/ncurses -DCURSES_LOC=""' 31 | elif [ -f /usr/include/ncurses.h ]; then 32 | echo '-DCURSES_LOC=""' 33 | else 34 | echo '-DCURSES_LOC=""' 35 | fi 36 | } 37 | 38 | # Temp file, try to clean up after us 39 | tmp=$(mktemp) 40 | trap "rm -f $tmp" 0 1 2 3 15 41 | 42 | # Check if we can link to ncurses 43 | check() { 44 | $cc -x c - -o $tmp 2>/dev/null <<'EOF' 45 | #include CURSES_LOC 46 | main() {} 47 | EOF 48 | if [ $? != 0 ]; then 49 | echo " *** Unable to find the ncurses libraries or the" 1>&2 50 | echo " *** required header files." 1>&2 51 | echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2 52 | echo " *** " 1>&2 53 | echo " *** Install ncurses (ncurses-devel) and try again." 1>&2 54 | echo " *** " 1>&2 55 | exit 1 56 | fi 57 | } 58 | 59 | usage() { 60 | printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n" 61 | } 62 | 63 | if [ $# -eq 0 ]; then 64 | usage 65 | exit 1 66 | fi 67 | 68 | cc="" 69 | case "$1" in 70 | "-check") 71 | shift 72 | cc="$@" 73 | check 74 | ;; 75 | "-ccflags") 76 | ccflags 77 | ;; 78 | "-ldflags") 79 | shift 80 | cc="$@" 81 | ldflags 82 | ;; 83 | "*") 84 | usage 85 | exit 1 86 | ;; 87 | esac 88 | -------------------------------------------------------------------------------- /lxdialog/checklist.c: -------------------------------------------------------------------------------- 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 | 26 | static int list_width, check_x, item_x; 27 | 28 | /* 29 | * Print list item 30 | */ 31 | static void print_item(WINDOW * win, int choice, int selected) 32 | { 33 | int i; 34 | char *list_item = malloc(list_width + 1); 35 | 36 | strncpy(list_item, item_str(), list_width - item_x); 37 | list_item[list_width - item_x] = '\0'; 38 | 39 | /* Clear 'residue' of last item */ 40 | wattrset(win, dlg.menubox.atr); 41 | wmove(win, choice, 0); 42 | for (i = 0; i < list_width; i++) 43 | waddch(win, ' '); 44 | 45 | wmove(win, choice, check_x); 46 | wattrset(win, selected ? dlg.check_selected.atr 47 | : dlg.check.atr); 48 | if (!item_is_tag(':')) 49 | wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); 50 | 51 | wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); 52 | mvwaddch(win, choice, item_x, list_item[0]); 53 | wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); 54 | waddstr(win, list_item + 1); 55 | if (selected) { 56 | wmove(win, choice, check_x + 1); 57 | wrefresh(win); 58 | } 59 | free(list_item); 60 | } 61 | 62 | /* 63 | * Print the scroll indicators. 64 | */ 65 | static void print_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, dlg.uarrow.atr); 72 | waddch(win, ACS_UARROW); 73 | waddstr(win, "(-)"); 74 | } else { 75 | wattrset(win, dlg.menubox.atr); 76 | waddch(win, ACS_HLINE); 77 | waddch(win, ACS_HLINE); 78 | waddch(win, ACS_HLINE); 79 | waddch(win, ACS_HLINE); 80 | } 81 | 82 | y = y + height + 1; 83 | wmove(win, y, x); 84 | 85 | if ((height < item_no) && (scroll + choice < item_no - 1)) { 86 | wattrset(win, dlg.darrow.atr); 87 | waddch(win, ACS_DARROW); 88 | waddstr(win, "(+)"); 89 | } else { 90 | wattrset(win, dlg.menubox_border.atr); 91 | waddch(win, ACS_HLINE); 92 | waddch(win, ACS_HLINE); 93 | waddch(win, ACS_HLINE); 94 | waddch(win, ACS_HLINE); 95 | } 96 | } 97 | 98 | /* 99 | * Display the termination buttons 100 | */ 101 | static void print_buttons(WINDOW * dialog, int height, int width, int selected) 102 | { 103 | int x = width / 2 - 11; 104 | int y = height - 2; 105 | 106 | print_button(dialog, gettext("Select"), y, x, selected == 0); 107 | print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); 108 | 109 | wmove(dialog, y, x + 1 + 14 * selected); 110 | wrefresh(dialog); 111 | } 112 | 113 | /* 114 | * Display a dialog box with a list of options that can be turned on or off 115 | * in the style of radiolist (only one option turned on at a time). 116 | */ 117 | int dialog_checklist(const char *title, const char *prompt, int height, 118 | int width, int list_height) 119 | { 120 | int i, x, y, box_x, box_y; 121 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice; 122 | WINDOW *dialog, *list; 123 | 124 | /* which item to highlight */ 125 | item_foreach() { 126 | if (item_is_tag('X')) 127 | choice = item_n(); 128 | if (item_is_selected()) { 129 | choice = item_n(); 130 | break; 131 | } 132 | } 133 | 134 | do_resize: 135 | if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN)) 136 | return -ERRDISPLAYTOOSMALL; 137 | if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN)) 138 | return -ERRDISPLAYTOOSMALL; 139 | 140 | max_choice = MIN(list_height, item_count()); 141 | 142 | /* center dialog box on screen */ 143 | x = (getmaxx(stdscr) - width) / 2; 144 | y = (getmaxy(stdscr) - height) / 2; 145 | 146 | draw_shadow(stdscr, y, x, height, width); 147 | 148 | dialog = newwin(height, width, y, x); 149 | keypad(dialog, TRUE); 150 | 151 | draw_box(dialog, 0, 0, height, width, 152 | dlg.dialog.atr, dlg.border.atr); 153 | wattrset(dialog, dlg.border.atr); 154 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); 155 | for (i = 0; i < width - 2; i++) 156 | waddch(dialog, ACS_HLINE); 157 | wattrset(dialog, dlg.dialog.atr); 158 | waddch(dialog, ACS_RTEE); 159 | 160 | print_title(dialog, title, width); 161 | 162 | wattrset(dialog, dlg.dialog.atr); 163 | print_autowrap(dialog, prompt, width - 2, 1, 3); 164 | 165 | list_width = width - 6; 166 | box_y = height - list_height - 5; 167 | box_x = (width - list_width) / 2 - 1; 168 | 169 | /* create new window for the list */ 170 | list = subwin(dialog, list_height, list_width, y + box_y + 1, 171 | x + box_x + 1); 172 | 173 | keypad(list, TRUE); 174 | 175 | /* draw a box around the list items */ 176 | draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, 177 | dlg.menubox_border.atr, dlg.menubox.atr); 178 | 179 | /* Find length of longest item in order to center checklist */ 180 | check_x = 0; 181 | item_foreach() 182 | check_x = MAX(check_x, strlen(item_str()) + 4); 183 | check_x = MIN(check_x, list_width); 184 | 185 | check_x = (list_width - check_x) / 2; 186 | item_x = check_x + 4; 187 | 188 | if (choice >= list_height) { 189 | scroll = choice - list_height + 1; 190 | choice -= scroll; 191 | } 192 | 193 | /* Print the list */ 194 | for (i = 0; i < max_choice; i++) { 195 | item_set(scroll + i); 196 | print_item(list, i, i == choice); 197 | } 198 | 199 | print_arrows(dialog, choice, item_count(), scroll, 200 | box_y, box_x + check_x + 5, list_height); 201 | 202 | print_buttons(dialog, height, width, 0); 203 | 204 | wnoutrefresh(dialog); 205 | wnoutrefresh(list); 206 | doupdate(); 207 | 208 | while (key != KEY_ESC) { 209 | key = wgetch(dialog); 210 | 211 | for (i = 0; i < max_choice; i++) { 212 | item_set(i + scroll); 213 | if (toupper(key) == toupper(item_str()[0])) 214 | break; 215 | } 216 | 217 | if (i < max_choice || key == KEY_UP || key == KEY_DOWN || 218 | key == '+' || key == '-') { 219 | if (key == KEY_UP || key == '-') { 220 | if (!choice) { 221 | if (!scroll) 222 | continue; 223 | /* Scroll list down */ 224 | if (list_height > 1) { 225 | /* De-highlight current first item */ 226 | item_set(scroll); 227 | print_item(list, 0, FALSE); 228 | scrollok(list, TRUE); 229 | wscrl(list, -1); 230 | scrollok(list, FALSE); 231 | } 232 | scroll--; 233 | item_set(scroll); 234 | print_item(list, 0, TRUE); 235 | print_arrows(dialog, choice, item_count(), 236 | scroll, box_y, box_x + check_x + 5, list_height); 237 | 238 | wnoutrefresh(dialog); 239 | wrefresh(list); 240 | 241 | continue; /* wait for another key press */ 242 | } else 243 | i = choice - 1; 244 | } else if (key == KEY_DOWN || key == '+') { 245 | if (choice == max_choice - 1) { 246 | if (scroll + choice >= item_count() - 1) 247 | continue; 248 | /* Scroll list up */ 249 | if (list_height > 1) { 250 | /* De-highlight current last item before scrolling up */ 251 | item_set(scroll + max_choice - 1); 252 | print_item(list, 253 | max_choice - 1, 254 | FALSE); 255 | scrollok(list, TRUE); 256 | wscrl(list, 1); 257 | scrollok(list, FALSE); 258 | } 259 | scroll++; 260 | item_set(scroll + max_choice - 1); 261 | print_item(list, max_choice - 1, TRUE); 262 | 263 | print_arrows(dialog, choice, item_count(), 264 | scroll, box_y, box_x + check_x + 5, list_height); 265 | 266 | wnoutrefresh(dialog); 267 | wrefresh(list); 268 | 269 | continue; /* wait for another key press */ 270 | } else 271 | i = choice + 1; 272 | } 273 | if (i != choice) { 274 | /* De-highlight current item */ 275 | item_set(scroll + choice); 276 | print_item(list, choice, FALSE); 277 | /* Highlight new item */ 278 | choice = i; 279 | item_set(scroll + choice); 280 | print_item(list, choice, TRUE); 281 | wnoutrefresh(dialog); 282 | wrefresh(list); 283 | } 284 | continue; /* wait for another key press */ 285 | } 286 | switch (key) { 287 | case 'H': 288 | case 'h': 289 | case '?': 290 | button = 1; 291 | /* fall-through */ 292 | case 'S': 293 | case 's': 294 | case ' ': 295 | case '\n': 296 | item_foreach() 297 | item_set_selected(0); 298 | item_set(scroll + choice); 299 | item_set_selected(1); 300 | delwin(list); 301 | delwin(dialog); 302 | return button; 303 | case TAB: 304 | case KEY_LEFT: 305 | case KEY_RIGHT: 306 | button = ((key == KEY_LEFT ? --button : ++button) < 0) 307 | ? 1 : (button > 1 ? 0 : button); 308 | 309 | print_buttons(dialog, height, width, button); 310 | wrefresh(dialog); 311 | break; 312 | case 'X': 313 | case 'x': 314 | key = KEY_ESC; 315 | break; 316 | case KEY_ESC: 317 | key = on_key_esc(dialog); 318 | break; 319 | case KEY_RESIZE: 320 | delwin(list); 321 | delwin(dialog); 322 | on_key_resize(); 323 | goto do_resize; 324 | } 325 | 326 | /* Now, update everything... */ 327 | doupdate(); 328 | } 329 | delwin(list); 330 | delwin(dialog); 331 | return key; /* ESC pressed */ 332 | } 333 | -------------------------------------------------------------------------------- /lxdialog/dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dialog.h -- common declarations for all dialog modules 3 | * 4 | * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) 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., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #ifndef KBUILD_NO_NLS 30 | # include 31 | #else 32 | # define gettext(Msgid) ((const char *) (Msgid)) 33 | #endif 34 | 35 | #ifdef __sun__ 36 | #define CURS_MACROS 37 | #endif 38 | #include CURSES_LOC 39 | 40 | /* 41 | * Colors in ncurses 1.9.9e do not work properly since foreground and 42 | * background colors are OR'd rather than separately masked. This version 43 | * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible 44 | * with standard curses. The simplest fix (to make this work with standard 45 | * curses) uses the wbkgdset() function, not used in the original hack. 46 | * Turn it off if we're building with 1.9.9e, since it just confuses things. 47 | */ 48 | #if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) 49 | #define OLD_NCURSES 1 50 | #undef wbkgdset 51 | #define wbkgdset(w,p) /*nothing */ 52 | #else 53 | #define OLD_NCURSES 0 54 | #endif 55 | 56 | #define TR(params) _tracef params 57 | 58 | #define KEY_ESC 27 59 | #define TAB 9 60 | #define MAX_LEN 2048 61 | #define BUF_SIZE (10*1024) 62 | #define MIN(x,y) (x < y ? x : y) 63 | #define MAX(x,y) (x > y ? x : y) 64 | 65 | #ifndef ACS_ULCORNER 66 | #define ACS_ULCORNER '+' 67 | #endif 68 | #ifndef ACS_LLCORNER 69 | #define ACS_LLCORNER '+' 70 | #endif 71 | #ifndef ACS_URCORNER 72 | #define ACS_URCORNER '+' 73 | #endif 74 | #ifndef ACS_LRCORNER 75 | #define ACS_LRCORNER '+' 76 | #endif 77 | #ifndef ACS_HLINE 78 | #define ACS_HLINE '-' 79 | #endif 80 | #ifndef ACS_VLINE 81 | #define ACS_VLINE '|' 82 | #endif 83 | #ifndef ACS_LTEE 84 | #define ACS_LTEE '+' 85 | #endif 86 | #ifndef ACS_RTEE 87 | #define ACS_RTEE '+' 88 | #endif 89 | #ifndef ACS_UARROW 90 | #define ACS_UARROW '^' 91 | #endif 92 | #ifndef ACS_DARROW 93 | #define ACS_DARROW 'v' 94 | #endif 95 | 96 | /* error return codes */ 97 | #define ERRDISPLAYTOOSMALL (KEY_MAX + 1) 98 | 99 | /* 100 | * Color definitions 101 | */ 102 | struct dialog_color { 103 | chtype atr; /* Color attribute */ 104 | int fg; /* foreground */ 105 | int bg; /* background */ 106 | int hl; /* highlight this item */ 107 | }; 108 | 109 | struct subtitle_list { 110 | struct subtitle_list *next; 111 | const char *text; 112 | }; 113 | 114 | struct dialog_info { 115 | const char *backtitle; 116 | struct subtitle_list *subtitles; 117 | struct dialog_color screen; 118 | struct dialog_color shadow; 119 | struct dialog_color dialog; 120 | struct dialog_color title; 121 | struct dialog_color border; 122 | struct dialog_color button_active; 123 | struct dialog_color button_inactive; 124 | struct dialog_color button_key_active; 125 | struct dialog_color button_key_inactive; 126 | struct dialog_color button_label_active; 127 | struct dialog_color button_label_inactive; 128 | struct dialog_color inputbox; 129 | struct dialog_color inputbox_border; 130 | struct dialog_color searchbox; 131 | struct dialog_color searchbox_title; 132 | struct dialog_color searchbox_border; 133 | struct dialog_color position_indicator; 134 | struct dialog_color menubox; 135 | struct dialog_color menubox_border; 136 | struct dialog_color item; 137 | struct dialog_color item_selected; 138 | struct dialog_color tag; 139 | struct dialog_color tag_selected; 140 | struct dialog_color tag_key; 141 | struct dialog_color tag_key_selected; 142 | struct dialog_color check; 143 | struct dialog_color check_selected; 144 | struct dialog_color uarrow; 145 | struct dialog_color darrow; 146 | }; 147 | 148 | /* 149 | * Global variables 150 | */ 151 | extern struct dialog_info dlg; 152 | extern char dialog_input_result[]; 153 | extern int saved_x, saved_y; /* Needed in signal handler in mconf.c */ 154 | 155 | /* 156 | * Function prototypes 157 | */ 158 | 159 | /* item list as used by checklist and menubox */ 160 | void item_reset(void); 161 | void item_make(const char *fmt, ...); 162 | void item_add_str(const char *fmt, ...); 163 | void item_set_tag(char tag); 164 | void item_set_data(void *p); 165 | void item_set_selected(int val); 166 | int item_activate_selected(void); 167 | void *item_data(void); 168 | char item_tag(void); 169 | 170 | /* item list manipulation for lxdialog use */ 171 | #define MAXITEMSTR 200 172 | struct dialog_item { 173 | char str[MAXITEMSTR]; /* promtp displayed */ 174 | char tag; 175 | void *data; /* pointer to menu item - used by menubox+checklist */ 176 | int selected; /* Set to 1 by dialog_*() function if selected. */ 177 | }; 178 | 179 | /* list of lialog_items */ 180 | struct dialog_list { 181 | struct dialog_item node; 182 | struct dialog_list *next; 183 | }; 184 | 185 | extern struct dialog_list *item_cur; 186 | extern struct dialog_list item_nil; 187 | extern struct dialog_list *item_head; 188 | 189 | int item_count(void); 190 | void item_set(int n); 191 | int item_n(void); 192 | const char *item_str(void); 193 | int item_is_selected(void); 194 | int item_is_tag(char tag); 195 | #define item_foreach() \ 196 | for (item_cur = item_head ? item_head: item_cur; \ 197 | item_cur && (item_cur != &item_nil); item_cur = item_cur->next) 198 | 199 | /* generic key handlers */ 200 | int on_key_esc(WINDOW *win); 201 | int on_key_resize(void); 202 | 203 | /* minimum (re)size values */ 204 | #define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */ 205 | #define CHECKLIST_WIDTH_MIN 6 206 | #define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */ 207 | #define INPUTBOX_WIDTH_MIN 2 208 | #define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */ 209 | #define MENUBOX_WIDTH_MIN 65 210 | #define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */ 211 | #define TEXTBOX_WIDTH_MIN 8 212 | #define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */ 213 | #define YESNO_WIDTH_MIN 4 214 | #define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */ 215 | #define WINDOW_WIDTH_MIN 80 216 | 217 | int init_dialog(const char *backtitle); 218 | void set_dialog_backtitle(const char *backtitle); 219 | void set_dialog_subtitles(struct subtitle_list *subtitles); 220 | void end_dialog(int x, int y); 221 | void attr_clear(WINDOW * win, int height, int width, chtype attr); 222 | void dialog_clear(void); 223 | void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); 224 | void print_button(WINDOW * win, const char *label, int y, int x, int selected); 225 | void print_title(WINDOW *dialog, const char *title, int width); 226 | void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, 227 | chtype border); 228 | void draw_shadow(WINDOW * win, int y, int x, int height, int width); 229 | 230 | int first_alpha(const char *string, const char *exempt); 231 | int dialog_yesno(const char *title, const char *prompt, int height, int width); 232 | int dialog_msgbox(const char *title, const char *prompt, int height, 233 | int width, int pause); 234 | 235 | 236 | typedef void (*update_text_fn)(char *buf, size_t start, size_t end, void 237 | *_data); 238 | int dialog_textbox(const char *title, char *tbuf, int initial_height, 239 | int initial_width, int *keys, int *_vscroll, int *_hscroll, 240 | update_text_fn update_text, void *data); 241 | int dialog_menu(const char *title, const char *prompt, 242 | const void *selected, int *s_scroll); 243 | int dialog_checklist(const char *title, const char *prompt, int height, 244 | int width, int list_height); 245 | int dialog_inputbox(const char *title, const char *prompt, int height, 246 | int width, const char *init); 247 | 248 | /* 249 | * This is the base for fictitious keys, which activate 250 | * the buttons. 251 | * 252 | * Mouse-generated keys are the following: 253 | * -- the first 32 are used as numbers, in addition to '0'-'9' 254 | * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') 255 | * -- uppercase chars are used to invoke the button (M_EVENT + 'O') 256 | */ 257 | #define M_EVENT (KEY_MAX+1) 258 | -------------------------------------------------------------------------------- /lxdialog/inputbox.c: -------------------------------------------------------------------------------- 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 | 24 | char dialog_input_result[MAX_LEN + 1]; 25 | 26 | /* 27 | * Print the termination buttons 28 | */ 29 | static 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, gettext(" Ok "), y, x, selected == 0); 35 | print_button(dialog, gettext(" 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 | */ 44 | int 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, key = 0, button = -1; 49 | int show_x, len, pos; 50 | char *instr = dialog_input_result; 51 | WINDOW *dialog; 52 | 53 | if (!init) 54 | instr[0] = '\0'; 55 | else 56 | strcpy(instr, init); 57 | 58 | do_resize: 59 | if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN)) 60 | return -ERRDISPLAYTOOSMALL; 61 | if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN)) 62 | return -ERRDISPLAYTOOSMALL; 63 | 64 | /* center dialog box on screen */ 65 | x = (getmaxx(stdscr) - width) / 2; 66 | y = (getmaxy(stdscr) - height) / 2; 67 | 68 | draw_shadow(stdscr, y, x, height, width); 69 | 70 | dialog = newwin(height, width, y, x); 71 | keypad(dialog, TRUE); 72 | 73 | draw_box(dialog, 0, 0, height, width, 74 | dlg.dialog.atr, dlg.border.atr); 75 | wattrset(dialog, dlg.border.atr); 76 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); 77 | for (i = 0; i < width - 2; i++) 78 | waddch(dialog, ACS_HLINE); 79 | wattrset(dialog, dlg.dialog.atr); 80 | waddch(dialog, ACS_RTEE); 81 | 82 | print_title(dialog, title, width); 83 | 84 | wattrset(dialog, dlg.dialog.atr); 85 | print_autowrap(dialog, prompt, width - 2, 1, 3); 86 | 87 | /* Draw the input field box */ 88 | box_width = width - 6; 89 | getyx(dialog, y, x); 90 | box_y = y + 2; 91 | box_x = (width - box_width) / 2; 92 | draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, 93 | dlg.dialog.atr, dlg.border.atr); 94 | 95 | print_buttons(dialog, height, width, 0); 96 | 97 | /* Set up the initial value */ 98 | wmove(dialog, box_y, box_x); 99 | wattrset(dialog, dlg.inputbox.atr); 100 | 101 | len = strlen(instr); 102 | pos = len; 103 | 104 | if (len >= box_width) { 105 | show_x = len - box_width + 1; 106 | input_x = box_width - 1; 107 | for (i = 0; i < box_width - 1; i++) 108 | waddch(dialog, instr[show_x + i]); 109 | } else { 110 | show_x = 0; 111 | input_x = len; 112 | waddstr(dialog, instr); 113 | } 114 | 115 | wmove(dialog, box_y, box_x + input_x); 116 | 117 | wrefresh(dialog); 118 | 119 | while (key != KEY_ESC) { 120 | key = wgetch(dialog); 121 | 122 | if (button == -1) { /* Input box selected */ 123 | switch (key) { 124 | case TAB: 125 | case KEY_UP: 126 | case KEY_DOWN: 127 | break; 128 | case KEY_BACKSPACE: 129 | case 127: 130 | if (pos) { 131 | wattrset(dialog, dlg.inputbox.atr); 132 | if (input_x == 0) { 133 | show_x--; 134 | } else 135 | input_x--; 136 | 137 | if (pos < len) { 138 | for (i = pos - 1; i < len; i++) { 139 | instr[i] = instr[i+1]; 140 | } 141 | } 142 | 143 | pos--; 144 | len--; 145 | instr[len] = '\0'; 146 | wmove(dialog, box_y, box_x); 147 | for (i = 0; i < box_width; i++) { 148 | if (!instr[show_x + i]) { 149 | waddch(dialog, ' '); 150 | break; 151 | } 152 | waddch(dialog, instr[show_x + i]); 153 | } 154 | wmove(dialog, box_y, input_x + box_x); 155 | wrefresh(dialog); 156 | } 157 | continue; 158 | case KEY_LEFT: 159 | if (pos > 0) { 160 | if (input_x > 0) { 161 | wmove(dialog, box_y, --input_x + box_x); 162 | } else if (input_x == 0) { 163 | show_x--; 164 | wmove(dialog, box_y, box_x); 165 | for (i = 0; i < box_width; i++) { 166 | if (!instr[show_x + i]) { 167 | waddch(dialog, ' '); 168 | break; 169 | } 170 | waddch(dialog, instr[show_x + i]); 171 | } 172 | wmove(dialog, box_y, box_x); 173 | } 174 | pos--; 175 | } 176 | continue; 177 | case KEY_RIGHT: 178 | if (pos < len) { 179 | if (input_x < box_width - 1) { 180 | wmove(dialog, box_y, ++input_x + box_x); 181 | } else if (input_x == box_width - 1) { 182 | show_x++; 183 | wmove(dialog, box_y, box_x); 184 | for (i = 0; i < box_width; i++) { 185 | if (!instr[show_x + i]) { 186 | waddch(dialog, ' '); 187 | break; 188 | } 189 | waddch(dialog, instr[show_x + i]); 190 | } 191 | wmove(dialog, box_y, input_x + box_x); 192 | } 193 | pos++; 194 | } 195 | continue; 196 | default: 197 | if (key < 0x100 && isprint(key)) { 198 | if (len < MAX_LEN) { 199 | wattrset(dialog, dlg.inputbox.atr); 200 | if (pos < len) { 201 | for (i = len; i > pos; i--) 202 | instr[i] = instr[i-1]; 203 | instr[pos] = key; 204 | } else { 205 | instr[len] = key; 206 | } 207 | pos++; 208 | len++; 209 | instr[len] = '\0'; 210 | 211 | if (input_x == box_width - 1) { 212 | show_x++; 213 | } else { 214 | input_x++; 215 | } 216 | 217 | wmove(dialog, box_y, box_x); 218 | for (i = 0; i < box_width; i++) { 219 | if (!instr[show_x + i]) { 220 | waddch(dialog, ' '); 221 | break; 222 | } 223 | waddch(dialog, instr[show_x + i]); 224 | } 225 | wmove(dialog, box_y, input_x + box_x); 226 | wrefresh(dialog); 227 | } else 228 | flash(); /* Alarm user about overflow */ 229 | continue; 230 | } 231 | } 232 | } 233 | switch (key) { 234 | case 'O': 235 | case 'o': 236 | delwin(dialog); 237 | return 0; 238 | case 'H': 239 | case 'h': 240 | delwin(dialog); 241 | return 1; 242 | case KEY_UP: 243 | case KEY_LEFT: 244 | switch (button) { 245 | case -1: 246 | button = 1; /* Indicates "Help" button is selected */ 247 | print_buttons(dialog, height, width, 1); 248 | break; 249 | case 0: 250 | button = -1; /* Indicates input box is selected */ 251 | print_buttons(dialog, height, width, 0); 252 | wmove(dialog, box_y, box_x + input_x); 253 | wrefresh(dialog); 254 | break; 255 | case 1: 256 | button = 0; /* Indicates "OK" button is selected */ 257 | print_buttons(dialog, height, width, 0); 258 | break; 259 | } 260 | break; 261 | case TAB: 262 | case KEY_DOWN: 263 | case KEY_RIGHT: 264 | switch (button) { 265 | case -1: 266 | button = 0; /* Indicates "OK" button is selected */ 267 | print_buttons(dialog, height, width, 0); 268 | break; 269 | case 0: 270 | button = 1; /* Indicates "Help" button is selected */ 271 | print_buttons(dialog, height, width, 1); 272 | break; 273 | case 1: 274 | button = -1; /* Indicates input box is selected */ 275 | print_buttons(dialog, height, width, 0); 276 | wmove(dialog, box_y, box_x + input_x); 277 | wrefresh(dialog); 278 | break; 279 | } 280 | break; 281 | case ' ': 282 | case '\n': 283 | delwin(dialog); 284 | return (button == -1 ? 0 : button); 285 | case 'X': 286 | case 'x': 287 | key = KEY_ESC; 288 | break; 289 | case KEY_ESC: 290 | key = on_key_esc(dialog); 291 | break; 292 | case KEY_RESIZE: 293 | delwin(dialog); 294 | on_key_resize(); 295 | goto do_resize; 296 | } 297 | } 298 | 299 | delwin(dialog); 300 | return KEY_ESC; /* ESC pressed */ 301 | } 302 | -------------------------------------------------------------------------------- /lxdialog/textbox.c: -------------------------------------------------------------------------------- 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 | 24 | static void back_lines(int n); 25 | static void print_page(WINDOW *win, int height, int width, update_text_fn 26 | update_text, void *data); 27 | static void print_line(WINDOW *win, int row, int width); 28 | static char *get_line(void); 29 | static void print_position(WINDOW * win); 30 | 31 | static int hscroll; 32 | static int begin_reached, end_reached, page_length; 33 | static char *buf; 34 | static char *page; 35 | 36 | /* 37 | * refresh window content 38 | */ 39 | static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, 40 | int cur_y, int cur_x, update_text_fn update_text, 41 | void *data) 42 | { 43 | print_page(box, boxh, boxw, update_text, data); 44 | print_position(dialog); 45 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ 46 | wrefresh(dialog); 47 | } 48 | 49 | 50 | /* 51 | * Display text from a file in a dialog box. 52 | * 53 | * keys is a null-terminated array 54 | * update_text() may not add or remove any '\n' or '\0' in tbuf 55 | */ 56 | int dialog_textbox(const char *title, char *tbuf, int initial_height, 57 | int initial_width, int *keys, int *_vscroll, int *_hscroll, 58 | update_text_fn update_text, void *data) 59 | { 60 | int i, x, y, cur_x, cur_y, key = 0; 61 | int height, width, boxh, boxw; 62 | WINDOW *dialog, *box; 63 | bool done = false; 64 | 65 | begin_reached = 1; 66 | end_reached = 0; 67 | page_length = 0; 68 | hscroll = 0; 69 | buf = tbuf; 70 | page = buf; /* page is pointer to start of page to be displayed */ 71 | 72 | if (_vscroll && *_vscroll) { 73 | begin_reached = 0; 74 | 75 | for (i = 0; i < *_vscroll; i++) 76 | get_line(); 77 | } 78 | if (_hscroll) 79 | hscroll = *_hscroll; 80 | 81 | do_resize: 82 | getmaxyx(stdscr, height, width); 83 | if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN) 84 | return -ERRDISPLAYTOOSMALL; 85 | if (initial_height != 0) 86 | height = initial_height; 87 | else 88 | if (height > 4) 89 | height -= 4; 90 | else 91 | height = 0; 92 | if (initial_width != 0) 93 | width = initial_width; 94 | else 95 | if (width > 5) 96 | width -= 5; 97 | else 98 | width = 0; 99 | 100 | /* center dialog box on screen */ 101 | x = (getmaxx(stdscr) - width) / 2; 102 | y = (getmaxy(stdscr) - height) / 2; 103 | 104 | draw_shadow(stdscr, y, x, height, width); 105 | 106 | dialog = newwin(height, width, y, x); 107 | keypad(dialog, TRUE); 108 | 109 | /* Create window for box region, used for scrolling text */ 110 | boxh = height - 4; 111 | boxw = width - 2; 112 | box = subwin(dialog, boxh, boxw, y + 1, x + 1); 113 | wattrset(box, dlg.dialog.atr); 114 | wbkgdset(box, dlg.dialog.atr & A_COLOR); 115 | 116 | keypad(box, TRUE); 117 | 118 | /* register the new window, along with its borders */ 119 | draw_box(dialog, 0, 0, height, width, 120 | dlg.dialog.atr, dlg.border.atr); 121 | 122 | wattrset(dialog, dlg.border.atr); 123 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); 124 | for (i = 0; i < width - 2; i++) 125 | waddch(dialog, ACS_HLINE); 126 | wattrset(dialog, dlg.dialog.atr); 127 | wbkgdset(dialog, dlg.dialog.atr & A_COLOR); 128 | waddch(dialog, ACS_RTEE); 129 | 130 | print_title(dialog, title, width); 131 | 132 | print_button(dialog, gettext(" Exit "), height - 2, width / 2 - 4, TRUE); 133 | wnoutrefresh(dialog); 134 | getyx(dialog, cur_y, cur_x); /* Save cursor position */ 135 | 136 | /* Print first page of text */ 137 | attr_clear(box, boxh, boxw, dlg.dialog.atr); 138 | refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x, update_text, 139 | data); 140 | 141 | while (!done) { 142 | key = wgetch(dialog); 143 | switch (key) { 144 | case 'E': /* Exit */ 145 | case 'e': 146 | case 'X': 147 | case 'x': 148 | case 'q': 149 | case '\n': 150 | done = true; 151 | break; 152 | case 'g': /* First page */ 153 | case KEY_HOME: 154 | if (!begin_reached) { 155 | begin_reached = 1; 156 | page = buf; 157 | refresh_text_box(dialog, box, boxh, boxw, 158 | cur_y, cur_x, update_text, 159 | data); 160 | } 161 | break; 162 | case 'G': /* Last page */ 163 | case KEY_END: 164 | 165 | end_reached = 1; 166 | /* point to last char in buf */ 167 | page = buf + strlen(buf); 168 | back_lines(boxh); 169 | refresh_text_box(dialog, box, boxh, boxw, cur_y, 170 | cur_x, update_text, data); 171 | break; 172 | case 'K': /* Previous line */ 173 | case 'k': 174 | case KEY_UP: 175 | if (begin_reached) 176 | break; 177 | 178 | back_lines(page_length + 1); 179 | refresh_text_box(dialog, box, boxh, boxw, cur_y, 180 | cur_x, update_text, data); 181 | break; 182 | case 'B': /* Previous page */ 183 | case 'b': 184 | case 'u': 185 | case KEY_PPAGE: 186 | if (begin_reached) 187 | break; 188 | back_lines(page_length + boxh); 189 | refresh_text_box(dialog, box, boxh, boxw, cur_y, 190 | cur_x, update_text, data); 191 | break; 192 | case 'J': /* Next line */ 193 | case 'j': 194 | case KEY_DOWN: 195 | if (end_reached) 196 | break; 197 | 198 | back_lines(page_length - 1); 199 | refresh_text_box(dialog, box, boxh, boxw, cur_y, 200 | cur_x, update_text, data); 201 | break; 202 | case KEY_NPAGE: /* Next page */ 203 | case ' ': 204 | case 'd': 205 | if (end_reached) 206 | break; 207 | 208 | begin_reached = 0; 209 | refresh_text_box(dialog, box, boxh, boxw, cur_y, 210 | cur_x, update_text, data); 211 | break; 212 | case '0': /* Beginning of line */ 213 | case 'H': /* Scroll left */ 214 | case 'h': 215 | case KEY_LEFT: 216 | if (hscroll <= 0) 217 | break; 218 | 219 | if (key == '0') 220 | hscroll = 0; 221 | else 222 | hscroll--; 223 | /* Reprint current page to scroll horizontally */ 224 | back_lines(page_length); 225 | refresh_text_box(dialog, box, boxh, boxw, cur_y, 226 | cur_x, update_text, data); 227 | break; 228 | case 'L': /* Scroll right */ 229 | case 'l': 230 | case KEY_RIGHT: 231 | if (hscroll >= MAX_LEN) 232 | break; 233 | hscroll++; 234 | /* Reprint current page to scroll horizontally */ 235 | back_lines(page_length); 236 | refresh_text_box(dialog, box, boxh, boxw, cur_y, 237 | cur_x, update_text, data); 238 | break; 239 | case KEY_ESC: 240 | if (on_key_esc(dialog) == KEY_ESC) 241 | done = true; 242 | break; 243 | case KEY_RESIZE: 244 | back_lines(height); 245 | delwin(box); 246 | delwin(dialog); 247 | on_key_resize(); 248 | goto do_resize; 249 | default: 250 | for (i = 0; keys[i]; i++) { 251 | if (key == keys[i]) { 252 | done = true; 253 | break; 254 | } 255 | } 256 | } 257 | } 258 | delwin(box); 259 | delwin(dialog); 260 | if (_vscroll) { 261 | const char *s; 262 | 263 | s = buf; 264 | *_vscroll = 0; 265 | back_lines(page_length); 266 | while (s < page && (s = strchr(s, '\n'))) { 267 | (*_vscroll)++; 268 | s++; 269 | } 270 | } 271 | if (_hscroll) 272 | *_hscroll = hscroll; 273 | return key; 274 | } 275 | 276 | /* 277 | * Go back 'n' lines in text. Called by dialog_textbox(). 278 | * 'page' will be updated to point to the desired line in 'buf'. 279 | */ 280 | static void back_lines(int n) 281 | { 282 | int i; 283 | 284 | begin_reached = 0; 285 | /* Go back 'n' lines */ 286 | for (i = 0; i < n; i++) { 287 | if (*page == '\0') { 288 | if (end_reached) { 289 | end_reached = 0; 290 | continue; 291 | } 292 | } 293 | if (page == buf) { 294 | begin_reached = 1; 295 | return; 296 | } 297 | page--; 298 | do { 299 | if (page == buf) { 300 | begin_reached = 1; 301 | return; 302 | } 303 | page--; 304 | } while (*page != '\n'); 305 | page++; 306 | } 307 | } 308 | 309 | /* 310 | * Print a new page of text. 311 | */ 312 | static void print_page(WINDOW *win, int height, int width, update_text_fn 313 | update_text, void *data) 314 | { 315 | int i, passed_end = 0; 316 | 317 | if (update_text) { 318 | char *end; 319 | 320 | for (i = 0; i < height; i++) 321 | get_line(); 322 | end = page; 323 | back_lines(height); 324 | update_text(buf, page - buf, end - buf, data); 325 | } 326 | 327 | page_length = 0; 328 | for (i = 0; i < height; i++) { 329 | print_line(win, i, width); 330 | if (!passed_end) 331 | page_length++; 332 | if (end_reached && !passed_end) 333 | passed_end = 1; 334 | } 335 | wnoutrefresh(win); 336 | } 337 | 338 | /* 339 | * Print a new line of text. 340 | */ 341 | static void print_line(WINDOW * win, int row, int width) 342 | { 343 | char *line; 344 | 345 | line = get_line(); 346 | line += MIN(strlen(line), hscroll); /* Scroll horizontally */ 347 | wmove(win, row, 0); /* move cursor to correct line */ 348 | waddch(win, ' '); 349 | waddnstr(win, line, MIN(strlen(line), width - 2)); 350 | 351 | /* Clear 'residue' of previous line */ 352 | #if OLD_NCURSES 353 | { 354 | int x = getcurx(win); 355 | int i; 356 | for (i = 0; i < width - x; i++) 357 | waddch(win, ' '); 358 | } 359 | #else 360 | wclrtoeol(win); 361 | #endif 362 | } 363 | 364 | /* 365 | * Return current line of text. Called by dialog_textbox() and print_line(). 366 | * 'page' should point to start of current line before calling, and will be 367 | * updated to point to start of next line. 368 | */ 369 | static char *get_line(void) 370 | { 371 | int i = 0; 372 | static char line[MAX_LEN + 1]; 373 | 374 | end_reached = 0; 375 | while (*page != '\n') { 376 | if (*page == '\0') { 377 | end_reached = 1; 378 | break; 379 | } else if (i < MAX_LEN) 380 | line[i++] = *(page++); 381 | else { 382 | /* Truncate lines longer than MAX_LEN characters */ 383 | if (i == MAX_LEN) 384 | line[i++] = '\0'; 385 | page++; 386 | } 387 | } 388 | if (i <= MAX_LEN) 389 | line[i] = '\0'; 390 | if (!end_reached) 391 | page++; /* move past '\n' */ 392 | 393 | return line; 394 | } 395 | 396 | /* 397 | * Print current position 398 | */ 399 | static void print_position(WINDOW * win) 400 | { 401 | int percent; 402 | 403 | wattrset(win, dlg.position_indicator.atr); 404 | wbkgdset(win, dlg.position_indicator.atr & A_COLOR); 405 | percent = (page - buf) * 100 / strlen(buf); 406 | wmove(win, getmaxy(win) - 3, getmaxx(win) - 9); 407 | wprintw(win, "(%3d%%)", percent); 408 | } 409 | -------------------------------------------------------------------------------- /lxdialog/yesno.c: -------------------------------------------------------------------------------- 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 | */ 27 | static 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, gettext(" Yes "), y, x, selected == 0); 33 | print_button(dialog, gettext(" 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 | */ 42 | int 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 | do_resize: 48 | if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN)) 49 | return -ERRDISPLAYTOOSMALL; 50 | if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN)) 51 | return -ERRDISPLAYTOOSMALL; 52 | 53 | /* center dialog box on screen */ 54 | x = (getmaxx(stdscr) - width) / 2; 55 | y = (getmaxy(stdscr) - height) / 2; 56 | 57 | draw_shadow(stdscr, y, x, height, width); 58 | 59 | dialog = newwin(height, width, y, x); 60 | keypad(dialog, TRUE); 61 | 62 | draw_box(dialog, 0, 0, height, width, 63 | dlg.dialog.atr, dlg.border.atr); 64 | wattrset(dialog, dlg.border.atr); 65 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); 66 | for (i = 0; i < width - 2; i++) 67 | waddch(dialog, ACS_HLINE); 68 | wattrset(dialog, dlg.dialog.atr); 69 | waddch(dialog, ACS_RTEE); 70 | 71 | print_title(dialog, title, width); 72 | 73 | wattrset(dialog, dlg.dialog.atr); 74 | print_autowrap(dialog, prompt, width - 2, 1, 3); 75 | 76 | print_buttons(dialog, height, width, 0); 77 | 78 | while (key != KEY_ESC) { 79 | key = wgetch(dialog); 80 | switch (key) { 81 | case 'Y': 82 | case 'y': 83 | delwin(dialog); 84 | return 0; 85 | case 'N': 86 | case 'n': 87 | delwin(dialog); 88 | return 1; 89 | 90 | case TAB: 91 | case KEY_LEFT: 92 | case KEY_RIGHT: 93 | button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); 94 | 95 | print_buttons(dialog, height, width, button); 96 | wrefresh(dialog); 97 | break; 98 | case ' ': 99 | case '\n': 100 | delwin(dialog); 101 | return button; 102 | case KEY_ESC: 103 | key = on_key_esc(dialog); 104 | break; 105 | case KEY_RESIZE: 106 | delwin(dialog); 107 | on_key_resize(); 108 | goto do_resize; 109 | } 110 | } 111 | 112 | delwin(dialog); 113 | return key; /* ESC pressed */ 114 | } 115 | -------------------------------------------------------------------------------- /merge_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # merge_config.sh - Takes a list of config fragment values, and merges 3 | # them one by one. Provides warnings on overridden values, and specified 4 | # values that did not make it to the resulting .config file (due to missed 5 | # dependencies or config symbol removal). 6 | # 7 | # Portions reused from kconf_check and generate_cfg: 8 | # http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/kconf_check 9 | # http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/generate_cfg 10 | # 11 | # Copyright (c) 2009-2010 Wind River Systems, Inc. 12 | # Copyright 2011 Linaro 13 | # 14 | # This program is free software; you can redistribute it and/or modify 15 | # it under the terms of the GNU General Public License version 2 as 16 | # published by the Free Software Foundation. 17 | # 18 | # This program is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | 23 | clean_up() { 24 | rm -f $TMP_FILE 25 | exit 26 | } 27 | trap clean_up HUP INT TERM 28 | 29 | usage() { 30 | echo "Usage: $0 [OPTIONS] [CONFIG [...]]" 31 | echo " -h display this help text" 32 | echo " -m only merge the fragments, do not execute the make command" 33 | echo " -n use allnoconfig instead of alldefconfig" 34 | echo " -r list redundant entries when merging fragments" 35 | echo " -O dir to put generated output files" 36 | } 37 | 38 | MAKE=true 39 | ALLTARGET=alldefconfig 40 | WARNREDUN=false 41 | OUTPUT=. 42 | 43 | while true; do 44 | case $1 in 45 | "-n") 46 | ALLTARGET=allnoconfig 47 | shift 48 | continue 49 | ;; 50 | "-m") 51 | MAKE=false 52 | shift 53 | continue 54 | ;; 55 | "-h") 56 | usage 57 | exit 58 | ;; 59 | "-r") 60 | WARNREDUN=true 61 | shift 62 | continue 63 | ;; 64 | "-O") 65 | if [ -d $2 ];then 66 | OUTPUT=$(echo $2 | sed 's/\/*$//') 67 | else 68 | echo "output directory $2 does not exist" 1>&2 69 | exit 1 70 | fi 71 | shift 2 72 | continue 73 | ;; 74 | *) 75 | break 76 | ;; 77 | esac 78 | done 79 | 80 | INITFILE=$1 81 | shift; 82 | 83 | MERGE_LIST=$* 84 | SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" 85 | TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) 86 | 87 | echo "Using $INITFILE as base" 88 | cat $INITFILE > $TMP_FILE 89 | 90 | # Merge files, printing warnings on overrided values 91 | for MERGE_FILE in $MERGE_LIST ; do 92 | echo "Merging $MERGE_FILE" 93 | CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) 94 | 95 | for CFG in $CFG_LIST ; do 96 | grep -q -w $CFG $TMP_FILE 97 | if [ $? -eq 0 ] ; then 98 | PREV_VAL=$(grep -w $CFG $TMP_FILE) 99 | NEW_VAL=$(grep -w $CFG $MERGE_FILE) 100 | if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then 101 | echo Value of $CFG is redefined by fragment $MERGE_FILE: 102 | echo Previous value: $PREV_VAL 103 | echo New value: $NEW_VAL 104 | echo 105 | elif [ "$WARNREDUN" = "true" ]; then 106 | echo Value of $CFG is redundant by fragment $MERGE_FILE: 107 | fi 108 | sed -i "/$CFG[ =]/d" $TMP_FILE 109 | fi 110 | done 111 | cat $MERGE_FILE >> $TMP_FILE 112 | done 113 | 114 | if [ "$MAKE" = "false" ]; then 115 | cp $TMP_FILE $OUTPUT/.config 116 | echo "#" 117 | echo "# merged configuration written to $OUTPUT/.config (needs make)" 118 | echo "#" 119 | clean_up 120 | exit 121 | fi 122 | 123 | # If we have an output dir, setup the O= argument, otherwise leave 124 | # it blank, since O=. will create an unnecessary ./source softlink 125 | OUTPUT_ARG="" 126 | if [ "$OUTPUT" != "." ] ; then 127 | OUTPUT_ARG="O=$OUTPUT" 128 | fi 129 | 130 | 131 | # Use the merged file as the starting point for: 132 | # alldefconfig: Fills in any missing symbols with Kconfig default 133 | # allnoconfig: Fills in any missing symbols with # CONFIG_* is not set 134 | PRODUCT_ENV=${PRODUCT_ENV:-KCONFIG} 135 | make ${PRODUCT_ENV}_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET 136 | 137 | 138 | # Check all specified config values took (might have missed-dependency issues) 139 | for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do 140 | 141 | REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) 142 | ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config) 143 | if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then 144 | echo "Value requested for $CFG not in final .config" 145 | echo "Requested value: $REQUESTED_VAL" 146 | echo "Actual value: $ACTUAL_VAL" 147 | echo "" 148 | fi 149 | done 150 | 151 | clean_up 152 | -------------------------------------------------------------------------------- /nconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Nir Tzachar 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "ncurses.h" 28 | 29 | #define max(a, b) ({\ 30 | typeof(a) _a = a;\ 31 | typeof(b) _b = b;\ 32 | _a > _b ? _a : _b; }) 33 | 34 | #define min(a, b) ({\ 35 | typeof(a) _a = a;\ 36 | typeof(b) _b = b;\ 37 | _a < _b ? _a : _b; }) 38 | 39 | typedef enum { 40 | NORMAL = 1, 41 | MAIN_HEADING, 42 | MAIN_MENU_BOX, 43 | MAIN_MENU_FORE, 44 | MAIN_MENU_BACK, 45 | MAIN_MENU_GREY, 46 | MAIN_MENU_HEADING, 47 | SCROLLWIN_TEXT, 48 | SCROLLWIN_HEADING, 49 | SCROLLWIN_BOX, 50 | DIALOG_TEXT, 51 | DIALOG_MENU_FORE, 52 | DIALOG_MENU_BACK, 53 | DIALOG_BOX, 54 | INPUT_BOX, 55 | INPUT_HEADING, 56 | INPUT_TEXT, 57 | INPUT_FIELD, 58 | FUNCTION_TEXT, 59 | FUNCTION_HIGHLIGHT, 60 | ATTR_MAX 61 | } attributes_t; 62 | extern attributes_t attributes[]; 63 | 64 | typedef enum { 65 | F_HELP = 1, 66 | F_SYMBOL = 2, 67 | F_INSTS = 3, 68 | F_CONF = 4, 69 | F_BACK = 5, 70 | F_SAVE = 6, 71 | F_LOAD = 7, 72 | F_SEARCH = 8, 73 | F_EXIT = 9, 74 | } function_key; 75 | 76 | void set_colors(void); 77 | 78 | /* this changes the windows attributes !!! */ 79 | void print_in_middle(WINDOW *win, 80 | int starty, 81 | int startx, 82 | int width, 83 | const char *string, 84 | chtype color); 85 | int get_line_length(const char *line); 86 | int get_line_no(const char *text); 87 | const char *get_line(const char *text, int line_no); 88 | void fill_window(WINDOW *win, const char *text); 89 | int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...); 90 | int dialog_inputbox(WINDOW *main_window, 91 | const char *title, const char *prompt, 92 | const char *init, char **resultp, int *result_len); 93 | void refresh_all_windows(WINDOW *main_window); 94 | void show_scroll_win(WINDOW *main_window, 95 | const char *title, 96 | const char *text); 97 | -------------------------------------------------------------------------------- /patches/01-kconfig-kernel-to-buildroot.patch: -------------------------------------------------------------------------------- 1 | --- 2 | confdata.c | 4 ++-- 3 | gconf.glade | 2 +- 4 | mconf.c | 4 ++-- 5 | zconf.tab.c_shipped | 2 +- 6 | zconf.y | 2 +- 7 | 5 files changed, 7 insertions(+), 7 deletions(-) 8 | 9 | Index: kconfig/gconf.glade 10 | =================================================================== 11 | --- kconfig.orig/gconf.glade 2013-12-27 22:14:32.395629843 +0100 12 | +++ kconfig/gconf.glade 2013-12-27 22:14:32.387630158 +0100 13 | @@ -4,7 +4,7 @@ 14 | 15 | 16 | True 17 | - Gtk Kernel Configurator 18 | + Gtk Buildroot Configurator 19 | GTK_WINDOW_TOPLEVEL 20 | GTK_WIN_POS_NONE 21 | False 22 | Index: kconfig/mconf.c 23 | =================================================================== 24 | --- kconfig.orig/mconf.c 2013-12-27 22:14:32.395629843 +0100 25 | +++ kconfig/mconf.c 2013-12-27 22:14:42.179244153 +0100 26 | @@ -176,9 +176,9 @@ 27 | "Arrow keys navigate the menu. " 28 | " selects submenus ---> (or empty submenus ----). " 29 | "Highlighted letters are hotkeys. " 30 | - "Pressing includes, excludes, modularizes features. " 31 | + "Pressing selectes a feature, while will exclude a feature. " 32 | "Press to exit, for Help, for Search. " 33 | - "Legend: [*] built-in [ ] excluded module < > module capable"), 34 | + "Legend: [*] feature is selected [ ] feature is excluded"), 35 | radiolist_instructions[] = N_( 36 | "Use the arrow keys to navigate this window or " 37 | "press the hotkey of the item you wish to select " 38 | @@ -959,7 +959,7 @@ 39 | if (conf_get_changed()) 40 | res = dialog_yesno(NULL, 41 | _("Do you wish to save your new configuration?\n" 42 | - "(Press to continue kernel configuration.)"), 43 | + "(Press to continue Buildroot configuration.)"), 44 | 6, 60); 45 | else 46 | res = -1; 47 | Index: kconfig/zconf.tab.c_shipped 48 | =================================================================== 49 | --- kconfig.orig/zconf.tab.c_shipped 2013-12-27 22:14:32.395629843 +0100 50 | +++ kconfig/zconf.tab.c_shipped 2013-12-27 22:14:32.391630000 +0100 51 | @@ -2297,7 +2297,7 @@ 52 | 53 | sym_init(); 54 | _menu_init(); 55 | - rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); 56 | + rootmenu.prompt = menu_add_prompt(P_MENU, "Buildroot Configuration", NULL); 57 | 58 | if (getenv("ZCONF_DEBUG")) 59 | zconfdebug = 1; 60 | Index: kconfig/zconf.y 61 | =================================================================== 62 | --- kconfig.orig/zconf.y 2013-12-27 22:14:32.395629843 +0100 63 | +++ kconfig/zconf.y 2013-12-27 22:14:32.391630000 +0100 64 | @@ -493,7 +493,7 @@ 65 | 66 | sym_init(); 67 | _menu_init(); 68 | - rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); 69 | + rootmenu.prompt = menu_add_prompt(P_MENU, "Buildroot Configuration", NULL); 70 | 71 | if (getenv("ZCONF_DEBUG")) 72 | zconfdebug = 1; 73 | Index: kconfig/confdata.c 74 | =================================================================== 75 | --- kconfig.orig/confdata.c 2013-12-27 22:14:32.395629843 +0100 76 | +++ kconfig/confdata.c 2013-12-27 22:14:32.391630000 +0100 77 | @@ -25,7 +25,7 @@ 78 | static const char *conf_filename; 79 | static int conf_lineno, conf_warnings, conf_unsaved; 80 | 81 | -const char conf_defname[] = "arch/$ARCH/defconfig"; 82 | +const char conf_defname[] = ".defconfig"; 83 | 84 | static void conf_warning(const char *fmt, ...) 85 | { 86 | @@ -63,7 +63,7 @@ 87 | 88 | const char *conf_get_configname(void) 89 | { 90 | - char *name = getenv("KCONFIG_CONFIG"); 91 | + char *name = getenv("BR2_CONFIG"); 92 | 93 | return name ? name : ".config"; 94 | } 95 | Index: kconfig/qconf.cc 96 | =================================================================== 97 | --- kconfig.orig/qconf.cc 2013-12-27 22:12:15.825013567 +0100 98 | +++ kconfig/qconf.cc 2013-12-27 22:14:57.826627300 +0100 99 | @@ -70,7 +70,7 @@ 100 | } 101 | 102 | ConfigSettings::ConfigSettings() 103 | - : QSettings("kernel.org", "qconf") 104 | + : QSettings("buildroot.org", "qconf") 105 | { 106 | } 107 | 108 | -------------------------------------------------------------------------------- /patches/06-br-build-system-integration.patch: -------------------------------------------------------------------------------- 1 | --- 2 | Makefile | 8 ++++---- 3 | 1 file changed, 4 insertions(+), 4 deletions(-) 4 | 5 | Index: b/Makefile 6 | =================================================================== 7 | --- a/Makefile 8 | +++ b/Makefile 9 | @@ -159,11 +159,11 @@ 10 | 11 | hostprogs-y := conf 12 | 13 | -ifeq ($(MAKECMDGOALS),nconfig) 14 | +ifeq ($(MAKECMDGOALS),nconf) 15 | hostprogs-y += nconf 16 | endif 17 | 18 | -ifeq ($(MAKECMDGOALS),menuconfig) 19 | +ifeq ($(MAKECMDGOALS),mconf) 20 | hostprogs-y += mconf 21 | endif 22 | 23 | @@ -171,10 +171,10 @@ 24 | hostprogs-y += kxgettext 25 | endif 26 | 27 | -ifeq ($(MAKECMDGOALS),xconfig) 28 | +ifeq ($(MAKECMDGOALS),qconf) 29 | qconf-target := 1 30 | endif 31 | -ifeq ($(MAKECMDGOALS),gconfig) 32 | +ifeq ($(MAKECMDGOALS),gconf) 33 | gconf-target := 1 34 | endif 35 | 36 | -------------------------------------------------------------------------------- /patches/10-br-build-system.patch: -------------------------------------------------------------------------------- 1 | --- 2 | Makefile.br | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | foo.h | 12 ++++++++++++ 4 | 2 files changed, 65 insertions(+) 5 | 6 | Index: b/Makefile.br 7 | =================================================================== 8 | --- /dev/null 9 | +++ b/Makefile.br 10 | @@ -0,0 +1,53 @@ 11 | +src := . 12 | +top_srcdir=../../ 13 | +top_builddir=../../ 14 | +srctree := . 15 | +obj ?= . 16 | + 17 | +include Makefile 18 | +#HOSTCFLAGS+=-Dinline="" -include foo.h 19 | +-include $(obj)/.depend 20 | +$(obj)/.depend: $(wildcard *.h *.c) 21 | + $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > $@ 2>/dev/null || : 22 | + 23 | +__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) 24 | +host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) 25 | +host-cmulti := $(foreach m,$(__hostprogs),\ 26 | + $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) 27 | +host-cxxmulti := $(foreach m,$(__hostprogs),\ 28 | + $(if $($(m)-cxxobjs),$(m),$(if $($(m)-objs),))) 29 | +host-cobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-objs)))) 30 | +host-cxxobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-cxxobjs)))) 31 | + 32 | +HOST_EXTRACFLAGS += -I$(obj) -DCONFIG_=\"\" 33 | + 34 | +$(host-csingle): %: %.c 35 | + $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $< -o $(obj)/$@ 36 | + 37 | +$(host-cmulti): %: $(host-cobjs) $(host-cshlib) 38 | + $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F)) -o $(obj)/$@ 39 | + 40 | +$(host-cxxmulti): %: $(host-cxxobjs) $(host-cobjs) $(host-cshlib) 41 | + $(HOSTCXX) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$@) $(addprefix $(obj)/,$($(@F)-objs) $($(@F)-cxxobjs)) $(HOSTLOADLIBES_$(@F)) -o $(obj)/$@ 42 | + 43 | +$(obj)/%.o: %.c 44 | + $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) -c $< -o $@ 45 | + 46 | +$(obj)/%.o: $(obj)/%.c 47 | + $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) -c $< -o $@ 48 | + 49 | +$(obj)/%.o: %.cc 50 | + $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$(@F)) -c $< -o $@ 51 | + 52 | +$(obj)/%:: $(src)/%_shipped 53 | + $(Q)cat $< > $@ 54 | + 55 | +clean: 56 | + $(Q)rm -f $(addprefix $(obj)/,$(clean-files)) 57 | +distclean: clean 58 | + $(Q)rm -f $(addprefix $(obj)/,$(lxdialog) $(conf-objs) $(mconf-objs) $(kxgettext-objs) \ 59 | + $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \ 60 | + mconf .depend) 61 | + 62 | +FORCE: 63 | +.PHONY: FORCE clean distclean 64 | Index: b/foo.h 65 | =================================================================== 66 | --- /dev/null 67 | +++ b/foo.h 68 | @@ -0,0 +1,12 @@ 69 | +#ifndef __KCONFIG_FOO_H 70 | +#define __KCONFIG_FOO_H 71 | + 72 | +#ifndef __APPLE__ 73 | +#include 74 | +#endif 75 | +#include 76 | + 77 | +#ifndef PATH_MAX 78 | +#define PATH_MAX 1024 79 | +#endif 80 | +#endif /* __KCONFIG_FOO_H */ 81 | -------------------------------------------------------------------------------- /patches/100-kconfig-generic-env.patch: -------------------------------------------------------------------------------- 1 | Makefile | 8 ++++++-- 2 | conf.c | 10 +++++----- 3 | confdata.c | 16 ++++++++-------- 4 | expr.h | 2 +- 5 | gconf.glade | 2 +- 6 | lkc.h | 15 +++++++++++++++ 7 | mconf.c | 2 +- 8 | merge_config.sh | 3 ++- 9 | qconf.cc | 2 +- 10 | zconf.tab.c_shipped | 2 +- 11 | zconf.y | 2 +- 12 | 11 files changed, 42 insertions(+), 22 deletions(-) 13 | 14 | Index: kconfig/Makefile 15 | =================================================================== 16 | --- kconfig.orig/Makefile 2014-05-20 13:13:21.000000000 +0200 17 | +++ kconfig/Makefile 2014-05-20 13:13:21.000000000 +0200 18 | @@ -11,6 +11,10 @@ 19 | Kconfig := Kconfig 20 | endif 21 | 22 | +ifndef KBUILD_CONFIG_DIR 23 | +KBUILD_CONFIG_DIR=arch/$(SRCARCH)/configs 24 | +endif 25 | + 26 | # We need this, in case the user has it in its environment 27 | unexport CONFIG_ 28 | 29 | @@ -98,11 +102,11 @@ 30 | $< --defconfig $(Kconfig) 31 | else 32 | @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 33 | - $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 34 | + $(Q)$< --defconfig=$(KBUILD_CONFIG_DIR)/$(KBUILD_DEFCONFIG) $(Kconfig) 35 | endif 36 | 37 | %_defconfig: $(obj)/conf 38 | - $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 39 | + $(Q)$< --defconfig=$(KBUILD_CONFIG_DIR)/$@ $(Kconfig) 40 | 41 | # Help text used by make help 42 | help: 43 | Index: kconfig/conf.c 44 | =================================================================== 45 | --- kconfig.orig/conf.c 2014-05-20 13:13:21.000000000 +0200 46 | +++ kconfig/conf.c 2014-05-20 13:13:21.000000000 +0200 47 | @@ -524,7 +524,7 @@ 48 | gettimeofday(&now, NULL); 49 | seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); 50 | 51 | - seed_env = getenv("KCONFIG_SEED"); 52 | + seed_env = getenv(PRODUCT_ENV"_SEED"); 53 | if( seed_env && *seed_env ) { 54 | char *endp; 55 | int tmp = (int)strtol(seed_env, &endp, 0); 56 | @@ -532,7 +532,7 @@ 57 | seed = tmp; 58 | } 59 | } 60 | - fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed ); 61 | + fprintf( stderr, PRODUCT_ENV"_SEED=0x%X\n", seed ); 62 | srand(seed); 63 | break; 64 | } 65 | @@ -595,7 +595,7 @@ 66 | case allmodconfig: 67 | case alldefconfig: 68 | case randconfig: 69 | - name = getenv("KCONFIG_ALLCONFIG"); 70 | + name = getenv(PRODUCT_ENV"_ALLCONFIG"); 71 | if (!name) 72 | break; 73 | if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { 74 | @@ -618,7 +618,7 @@ 75 | if (conf_read_simple(name, S_DEF_USER) && 76 | conf_read_simple("all.config", S_DEF_USER)) { 77 | fprintf(stderr, 78 | - _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"), 79 | + _("*** "PRODUCT_ENV"_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"), 80 | name); 81 | exit(1); 82 | } 83 | @@ -629,7 +629,7 @@ 84 | 85 | if (sync_kconfig) { 86 | if (conf_get_changed()) { 87 | - name = getenv("KCONFIG_NOSILENTUPDATE"); 88 | + name = getenv(PRODUCT_ENV"_NOSILENTUPDATE"); 89 | if (name && *name) { 90 | fprintf(stderr, 91 | _("\n*** The configuration requires explicit update.\n\n")); 92 | Index: kconfig/confdata.c 93 | =================================================================== 94 | --- kconfig.orig/confdata.c 2014-05-20 13:13:21.000000000 +0200 95 | +++ kconfig/confdata.c 2014-05-20 13:13:21.000000000 +0200 96 | @@ -64,14 +64,14 @@ 97 | 98 | const char *conf_get_configname(void) 99 | { 100 | - char *name = getenv("BR2_CONFIG"); 101 | + char *name = getenv(PRODUCT_ENV"_CONFIG"); 102 | 103 | return name ? name : ".config"; 104 | } 105 | 106 | const char *conf_get_autoconfig_name(void) 107 | { 108 | - return getenv("KCONFIG_AUTOCONFIG"); 109 | + return getenv(PRODUCT_ENV"_AUTOCONFIG"); 110 | } 111 | 112 | static char *conf_expand_value(const char *in) 113 | @@ -767,7 +767,7 @@ 114 | basename = conf_get_configname(); 115 | 116 | sprintf(newname, "%s%s", dirname, basename); 117 | - env = getenv("KCONFIG_OVERWRITECONFIG"); 118 | + env = getenv(PRODUCT_ENV"_OVERWRITECONFIG"); 119 | if (!env || !*env) { 120 | sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid()); 121 | out = fopen(tmpname, "w"); 122 | @@ -1027,13 +1027,13 @@ 123 | fclose(tristate); 124 | fclose(out_h); 125 | 126 | - name = getenv("KCONFIG_AUTOHEADER"); 127 | + name = getenv(PRODUCT_ENV"_AUTOHEADER"); 128 | if (!name) 129 | name = "include/generated/autoconf.h"; 130 | sprintf(buf, "%s.tmpconfig.h", dir); 131 | if (rename(buf, name)) 132 | return 1; 133 | - name = getenv("KCONFIG_TRISTATE"); 134 | + name = getenv(PRODUCT_ENV"_TRISTATE"); 135 | if (!name) 136 | name = "include/config/tristate.conf"; 137 | sprintf(buf, "%s.tmpconfig_tristate", dir); 138 | @@ -1159,7 +1159,7 @@ 139 | * -Wmaybe-uninitialized */ 140 | if (mode == def_random) { 141 | int n, p[3]; 142 | - char *env = getenv("KCONFIG_PROBABILITY"); 143 | + char *env = getenv(PRODUCT_ENV"_PROBABILITY"); 144 | n = 0; 145 | while( env && *env ) { 146 | char *endp; 147 | @@ -1168,7 +1168,7 @@ 148 | p[n++] = tmp; 149 | } else { 150 | errno = ERANGE; 151 | - perror( "KCONFIG_PROBABILITY" ); 152 | + perror( PRODUCT_ENV"_PROBABILITY" ); 153 | exit( 1 ); 154 | } 155 | env = (*endp == ':') ? endp+1 : endp; 156 | @@ -1190,7 +1190,7 @@ 157 | 158 | if( pty+ptm > 100 ) { 159 | errno = ERANGE; 160 | - perror( "KCONFIG_PROBABILITY" ); 161 | + perror( PRODUCT_ENV"_PROBABILITY" ); 162 | exit( 1 ); 163 | } 164 | } 165 | Index: kconfig/expr.h 166 | =================================================================== 167 | --- kconfig.orig/expr.h 2014-05-20 13:12:12.000000000 +0200 168 | +++ kconfig/expr.h 2014-05-20 13:13:21.000000000 +0200 169 | @@ -93,7 +93,7 @@ 170 | #define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ 171 | #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ 172 | #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ 173 | -#define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ 174 | +#define SYMBOL_WRITE 0x0200 /* write symbol to file (PRODUCT_ENV"_CONFIG") */ 175 | #define SYMBOL_CHANGED 0x0400 /* ? */ 176 | #define SYMBOL_AUTO 0x1000 /* value from environment variable */ 177 | #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ 178 | Index: kconfig/gconf.glade 179 | =================================================================== 180 | --- kconfig.orig/gconf.glade 2014-05-20 13:13:21.000000000 +0200 181 | +++ kconfig/gconf.glade 2014-05-20 13:13:21.000000000 +0200 182 | @@ -4,7 +4,7 @@ 183 | 184 | 185 | True 186 | - Gtk Buildroot Configurator 187 | + Gtk PRODUCT Configurator 188 | GTK_WINDOW_TOPLEVEL 189 | GTK_WIN_POS_NONE 190 | False 191 | Index: kconfig/lkc.h 192 | =================================================================== 193 | --- kconfig.orig/lkc.h 2014-05-20 13:12:12.000000000 +0200 194 | +++ kconfig/lkc.h 2014-05-20 13:13:21.000000000 +0200 195 | @@ -21,6 +21,21 @@ 196 | extern "C" { 197 | #endif 198 | 199 | +#ifndef PRODUCT_ENV 200 | +/* BR2 for buildroot, KCONFIG for kernel. */ 201 | +#define PRODUCT_ENV "KCONFIG" 202 | +#endif 203 | + 204 | +#ifndef PRODUCT 205 | +/* Buildroot buildroot, Kernel for kernel. */ 206 | +#define PRODUCT "Kernel" 207 | +#endif 208 | + 209 | +#ifndef PRODUCT_DOMAIN 210 | +/* buildroot.org for buildroot, kernel.org for kernel. */ 211 | +#define PRODUCT_DOMAIN "kernel.org" 212 | +#endif 213 | + 214 | #define P(name,type,arg) extern type name arg 215 | #include "lkc_proto.h" 216 | #undef P 217 | Index: kconfig/mconf.c 218 | =================================================================== 219 | --- kconfig.orig/mconf.c 2014-05-20 13:13:21.000000000 +0200 220 | +++ kconfig/mconf.c 2014-05-20 13:13:21.000000000 +0200 221 | @@ -959,7 +959,7 @@ 222 | if (conf_get_changed()) 223 | res = dialog_yesno(NULL, 224 | _("Do you wish to save your new configuration?\n" 225 | - "(Press to continue Buildroot configuration.)"), 226 | + "(Press to continue "PRODUCT" configuration.)"), 227 | 6, 60); 228 | else 229 | res = -1; 230 | Index: kconfig/merge_config.sh 231 | =================================================================== 232 | --- kconfig.orig/merge_config.sh 2014-05-20 13:12:12.000000000 +0200 233 | +++ kconfig/merge_config.sh 2014-05-20 13:13:21.000000000 +0200 234 | @@ -131,7 +131,8 @@ 235 | # Use the merged file as the starting point for: 236 | # alldefconfig: Fills in any missing symbols with Kconfig default 237 | # allnoconfig: Fills in any missing symbols with # CONFIG_* is not set 238 | -make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET 239 | +PRODUCT_ENV=${PRODUCT_ENV:-KCONFIG} 240 | +make ${PRODUCT_ENV}_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET 241 | 242 | 243 | # Check all specified config values took (might have missed-dependency issues) 244 | Index: kconfig/qconf.cc 245 | =================================================================== 246 | --- kconfig.orig/qconf.cc 2014-05-20 13:13:21.000000000 +0200 247 | +++ kconfig/qconf.cc 2014-05-20 13:13:21.000000000 +0200 248 | @@ -70,7 +70,7 @@ 249 | } 250 | 251 | ConfigSettings::ConfigSettings() 252 | - : QSettings("buildroot.org", "qconf") 253 | + : QSettings(PRODUCT_DOMAIN, "qconf") 254 | { 255 | } 256 | 257 | Index: kconfig/zconf.tab.c_shipped 258 | =================================================================== 259 | --- kconfig.orig/zconf.tab.c_shipped 2014-05-20 13:13:21.000000000 +0200 260 | +++ kconfig/zconf.tab.c_shipped 2014-05-20 13:13:21.000000000 +0200 261 | @@ -2297,7 +2297,7 @@ 262 | 263 | sym_init(); 264 | _menu_init(); 265 | - rootmenu.prompt = menu_add_prompt(P_MENU, "Buildroot Configuration", NULL); 266 | + rootmenu.prompt = menu_add_prompt(P_MENU, PRODUCT" Configuration", NULL); 267 | 268 | if (getenv("ZCONF_DEBUG")) 269 | zconfdebug = 1; 270 | Index: kconfig/zconf.y 271 | =================================================================== 272 | --- kconfig.orig/zconf.y 2014-05-20 13:13:21.000000000 +0200 273 | +++ kconfig/zconf.y 2014-05-20 13:13:21.000000000 +0200 274 | @@ -493,7 +493,7 @@ 275 | 276 | sym_init(); 277 | _menu_init(); 278 | - rootmenu.prompt = menu_add_prompt(P_MENU, "Buildroot Configuration", NULL); 279 | + rootmenu.prompt = menu_add_prompt(P_MENU, PRODUCT" Configuration", NULL); 280 | 281 | if (getenv("ZCONF_DEBUG")) 282 | zconfdebug = 1; 283 | -------------------------------------------------------------------------------- /patches/101-kconfig-build.patch: -------------------------------------------------------------------------------- 1 | GNUmakefile | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | Makefile.br | 26 ++++++++++++------------ 3 | README | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 | config.sh | 26 +++++++++++++++++++++++++ 5 | 4 files changed, 149 insertions(+), 13 deletions(-) 6 | 7 | Index: kconfig/GNUmakefile 8 | =================================================================== 9 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 10 | +++ kconfig/GNUmakefile 2014-05-20 14:12:37.000000000 +0200 11 | @@ -0,0 +1,60 @@ 12 | +# 13 | +# Default stand alone makefile for kconfig. 14 | +# 15 | +# The Makefile and Makefile.br in this directory should 16 | +# not be called directly for standalone build. 17 | +# Actually they are included by this makefile. 18 | +# 19 | + 20 | +## 21 | +# Makefile parameters. 22 | +# 23 | +# The parameters are configured as for kernel build 24 | +# by default. Override them for your application 25 | +# setting. 26 | +# 27 | + 28 | +# TOP srcdir and this srcdir (relative to TOPDIR) 29 | +TOPDIR=. 30 | +SRCDIR=. 31 | + 32 | +# O: output directory (objs/exes), default to src dir 33 | +O=$(TOPDIR)/$(SRCDIR) 34 | + 35 | +# Build configuration 36 | +KBUILD_KCONFIG=Kconfig 37 | +KBUILD_CONFIG_DIR=configs 38 | +KBUILD_DEFCONFIG=defconfig 39 | + 40 | +# Product information (exported) 41 | +export PRODUCT_ENV=KCONFIG 42 | +export PRODUCT=Kernel 43 | +export PRODUCT_VERSION= 44 | +export PRODUCT_DOMAIN=kernel.org 45 | + 46 | +# Kconfig configuration (exported) 47 | +export $(PRODUCT_ENV)_CONFIG=config 48 | + 49 | + 50 | +# End of Makefile parameters. 51 | +## 52 | + 53 | +## 54 | +# Makefile adaptation/inclusion. 55 | + 56 | +# Buid vars 57 | +HOSTCC=$(CC) 58 | +HOSTCXX=$(CXX) 59 | +HOSTCFLAGS=-O2 -g 60 | +HOSTCXXFLAGS=-O2 -g 61 | +srctree=$(TOPDIR) 62 | +src=$(TOPDIR)/$(SRCDIR) 63 | +obj=$(O) 64 | + 65 | +# Enable execution from Makefile *conf programs 66 | +export PATH:=$(PATH):$(obj) 67 | + 68 | +include $(TOPDIR)/$(SRCDIR)/Makefile.br 69 | + 70 | +# End of Makefile adaptation/inclusion. 71 | +## 72 | Index: kconfig/README 73 | =================================================================== 74 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 75 | +++ kconfig/README 2014-05-20 14:12:37.000000000 +0200 76 | @@ -0,0 +1,50 @@ 77 | + 78 | +# Synopsys 79 | + 80 | +kconfig is an isolated packaging of the kernel configuration tools 81 | +as found in the scripts/kconfig/ directory of the kernel sources. 82 | + 83 | +The purpose is to provide the great functionalities of the kernel 84 | +configuration mechanism to any project that need application 85 | +level configuration. 86 | + 87 | +# Usage 88 | + 89 | +On can extract kconfig sources and run without installation 90 | +from his own project directory: 91 | + 92 | +$ cd myproject/ 93 | +$ kconfig/config.sh manuconfig 94 | + 95 | +As a default the mypoject/Kconfig file must be present for 96 | +declaring the project configuration. 97 | +The result is a myproject/config file which can be sources in 98 | +a shell of makefile script. 99 | + 100 | +Alternatively the call to: 101 | + 102 | +$ kconfig/config.sh menuconfig 103 | + 104 | +can be replaced by a direct call to the kconfig/GNUmakefile: 105 | + 106 | +$ make -f kconfig/GNUmakefile TOPDIR=. SRCDIR=kconfig 107 | + 108 | +Note that all common kernel configuration targets are available, 109 | +in particular config, menuconfig, nconfig, gconfig, xconfig, 110 | +defconfig, oldconfig, etc... 111 | + 112 | +Get the list of targets with: 113 | + 114 | +$ kconfig/config.sh help 115 | + 116 | +or 117 | + 118 | +$ make -f kconfig/GNUmakefile help TOPDIR=. SRCDIR=kconfig 119 | + 120 | + 121 | +# References 122 | + 123 | +Ref to buildroot README.buildroot file for the original idea 124 | +of packaging kconfig. 125 | + 126 | +Ref to kernel.org for actual contributors of kconfig. 127 | Index: kconfig/config.sh 128 | =================================================================== 129 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 130 | +++ kconfig/config.sh 2014-05-20 14:12:37.000000000 +0200 131 | @@ -0,0 +1,26 @@ 132 | +#!/bin/sh 133 | +# 134 | +# usage: kconfig/config.sh 135 | +# 136 | +# Runs the requested configuration from 137 | +# the directory to be configured. 138 | +# 139 | +# For instance: 140 | +# cd myproject/ 141 | +# kconfig/config.sh menuconfig 142 | +# 143 | +# Will generated a 'config' file in 144 | +# myproject/ from the 'Kconfig' file 145 | +# in myproject/ 146 | +# 147 | + 148 | +set -e 149 | +dir=`dirname $0` 150 | +topdir=`dirname $dir` 151 | +srcdir=`basename $dir` 152 | +kconfig_targets="${1-config}" 153 | +set -x 154 | +exec make -f $dir/GNUmakefile \ 155 | + TOPDIR=$topdir \ 156 | + SRCDIR=$srcdir \ 157 | + $kconfig_targets 158 | -------------------------------------------------------------------------------- /patches/11-use-mktemp-for-lxdialog.patch: -------------------------------------------------------------------------------- 1 | --- 2 | lxdialog/check-lxdialog.sh | 2 +- 3 | 1 file changed, 1 insertion(+), 1 deletion(-) 4 | 5 | Index: b/lxdialog/check-lxdialog.sh 6 | =================================================================== 7 | --- a/lxdialog/check-lxdialog.sh 8 | +++ b/lxdialog/check-lxdialog.sh 9 | @@ -36,7 +36,7 @@ 10 | } 11 | 12 | # Temp file, try to clean up after us 13 | -tmp=.lxdialog.tmp 14 | +tmp=$(mktemp) 15 | trap "rm -f $tmp" 0 1 2 3 15 16 | 17 | # Check if we can link to ncurses 18 | -------------------------------------------------------------------------------- /patches/12-fix-glade-file-path.patch: -------------------------------------------------------------------------------- 1 | --- 2 | gconf.c | 2 +- 3 | 1 file changed, 1 insertion(+), 1 deletion(-) 4 | 5 | Index: b/gconf.c 6 | =================================================================== 7 | --- a/gconf.c 8 | +++ b/gconf.c 9 | @@ -1486,7 +1486,7 @@ 10 | /* Determine GUI path */ 11 | env = getenv(SRCTREE); 12 | if (env) 13 | - glade_file = g_strconcat(env, "/scripts/kconfig/gconf.glade", NULL); 14 | + glade_file = g_strconcat(env, "/support/kconfig/gconf.glade", NULL); 15 | else if (av[0][0] == '/') 16 | glade_file = g_strconcat(av[0], ".glade", NULL); 17 | else 18 | -------------------------------------------------------------------------------- /patches/14-support-out-of-tree-config.patch: -------------------------------------------------------------------------------- 1 | --- 2 | conf.c | 1 3 | confdata.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++--------------- 4 | util.c | 16 +++++++++++++-- 5 | 3 files changed, 61 insertions(+), 18 deletions(-) 6 | 7 | Index: b/conf.c 8 | =================================================================== 9 | --- a/conf.c 10 | +++ b/conf.c 11 | @@ -558,7 +558,6 @@ 12 | } 13 | name = av[optind]; 14 | conf_parse(name); 15 | - //zconfdump(stdout); 16 | if (sync_kconfig) { 17 | name = conf_get_configname(); 18 | if (stat(name, &tmpstat)) { 19 | Index: b/confdata.c 20 | =================================================================== 21 | --- a/confdata.c 22 | +++ b/confdata.c 23 | @@ -13,6 +13,7 @@ 24 | #include 25 | #include 26 | #include 27 | +#include 28 | 29 | #include "lkc.h" 30 | 31 | @@ -70,9 +71,7 @@ 32 | 33 | const char *conf_get_autoconfig_name(void) 34 | { 35 | - char *name = getenv("KCONFIG_AUTOCONFIG"); 36 | - 37 | - return name ? name : "include/config/auto.conf"; 38 | + return getenv("KCONFIG_AUTOCONFIG"); 39 | } 40 | 41 | static char *conf_expand_value(const char *in) 42 | @@ -742,6 +741,9 @@ 43 | char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; 44 | char *env; 45 | 46 | + if (!name) 47 | + name = conf_get_configname(); 48 | + 49 | dirname[0] = 0; 50 | if (name && name[0]) { 51 | struct stat st; 52 | @@ -836,6 +838,7 @@ 53 | { 54 | const char *name; 55 | char path[PATH_MAX+1]; 56 | + char *opwd, *dir, *_name; 57 | char *s, *d, c; 58 | struct symbol *sym; 59 | struct stat sb; 60 | @@ -844,8 +847,20 @@ 61 | name = conf_get_autoconfig_name(); 62 | conf_read_simple(name, S_DEF_AUTO); 63 | 64 | - if (chdir("include/config")) 65 | - return 1; 66 | + opwd = malloc(256); 67 | + _name = strdup(name); 68 | + if (opwd == NULL || _name == NULL) 69 | + return 1; 70 | + opwd = getcwd(opwd, 256); 71 | + dir = dirname(_name); 72 | + if (dir == NULL) { 73 | + res = 1; 74 | + goto err; 75 | + } 76 | + if (chdir(dir)) { 77 | + res = 1; 78 | + goto err; 79 | + } 80 | 81 | res = 0; 82 | for_all_symbols(i, sym) { 83 | @@ -938,9 +953,11 @@ 84 | close(fd); 85 | } 86 | out: 87 | - if (chdir("../..")) 88 | - return 1; 89 | - 90 | + if (chdir(opwd)) 91 | + res = 1; 92 | +err: 93 | + free(opwd); 94 | + free(_name); 95 | return res; 96 | } 97 | 98 | @@ -950,25 +967,38 @@ 99 | const char *name; 100 | FILE *out, *tristate, *out_h; 101 | int i; 102 | + char dir[PATH_MAX+1], buf[PATH_MAX+1]; 103 | + char *s; 104 | + 105 | + strcpy(dir, conf_get_configname()); 106 | + s = strrchr(dir, '/'); 107 | + if (s) 108 | + s[1] = 0; 109 | + else 110 | + dir[0] = 0; 111 | 112 | sym_clear_all_valid(); 113 | 114 | - file_write_dep("include/config/auto.conf.cmd"); 115 | + sprintf(buf, "%s.config.cmd", dir); 116 | + file_write_dep(buf); 117 | 118 | if (conf_split_config()) 119 | return 1; 120 | 121 | - out = fopen(".tmpconfig", "w"); 122 | + sprintf(buf, "%s.tmpconfig", dir); 123 | + out = fopen(buf, "w"); 124 | if (!out) 125 | return 1; 126 | 127 | - tristate = fopen(".tmpconfig_tristate", "w"); 128 | + sprintf(buf, "%s.tmpconfig_tristate", dir); 129 | + tristate = fopen(buf, "w"); 130 | if (!tristate) { 131 | fclose(out); 132 | return 1; 133 | } 134 | 135 | - out_h = fopen(".tmpconfig.h", "w"); 136 | + sprintf(buf, "%s.tmpconfig.h", dir); 137 | + out_h = fopen(buf, "w"); 138 | if (!out_h) { 139 | fclose(out); 140 | fclose(tristate); 141 | @@ -1000,19 +1030,22 @@ 142 | name = getenv("KCONFIG_AUTOHEADER"); 143 | if (!name) 144 | name = "include/generated/autoconf.h"; 145 | - if (rename(".tmpconfig.h", name)) 146 | + sprintf(buf, "%s.tmpconfig.h", dir); 147 | + if (rename(buf, name)) 148 | return 1; 149 | name = getenv("KCONFIG_TRISTATE"); 150 | if (!name) 151 | name = "include/config/tristate.conf"; 152 | - if (rename(".tmpconfig_tristate", name)) 153 | + sprintf(buf, "%s.tmpconfig_tristate", dir); 154 | + if (rename(buf, name)) 155 | return 1; 156 | name = conf_get_autoconfig_name(); 157 | /* 158 | * This must be the last step, kbuild has a dependency on auto.conf 159 | * and this marks the successful completion of the previous steps. 160 | */ 161 | - if (rename(".tmpconfig", name)) 162 | + sprintf(buf, "%s.tmpconfig", dir); 163 | + if (rename(buf, name)) 164 | return 1; 165 | 166 | return 0; 167 | Index: b/util.c 168 | =================================================================== 169 | --- a/util.c 170 | +++ b/util.c 171 | @@ -34,6 +34,8 @@ 172 | /* write a dependency file as used by kbuild to track dependencies */ 173 | int file_write_dep(const char *name) 174 | { 175 | + char *str; 176 | + char buf[PATH_MAX+1], buf2[PATH_MAX+1], dir[PATH_MAX+1]; 177 | struct symbol *sym, *env_sym; 178 | struct expr *e; 179 | struct file *file; 180 | @@ -41,7 +43,16 @@ 181 | 182 | if (!name) 183 | name = ".kconfig.d"; 184 | - out = fopen("..config.tmp", "w"); 185 | + 186 | + strcpy(dir, conf_get_configname()); 187 | + str = strrchr(dir, '/'); 188 | + if (str) 189 | + str[1] = 0; 190 | + else 191 | + dir[0] = 0; 192 | + 193 | + sprintf(buf, "%s..config.tmp", dir); 194 | + out = fopen(buf, "w"); 195 | if (!out) 196 | return 1; 197 | fprintf(out, "deps_config := \\\n"); 198 | @@ -72,7 +83,8 @@ 199 | 200 | fprintf(out, "\n$(deps_config): ;\n"); 201 | fclose(out); 202 | - rename("..config.tmp", name); 203 | + sprintf(buf2, "%s%s", dir, name); 204 | + rename(buf, buf2); 205 | return 0; 206 | } 207 | 208 | -------------------------------------------------------------------------------- /patches/15-fix-qconf-moc-rule.patch: -------------------------------------------------------------------------------- 1 | Fix the rule that generates the .moc file 2 | 3 | The Linux kernel has a "cmd" make function, but we don't have it in 4 | Buildroot, so we need to adjust this rule. 5 | 6 | Signed-off-by: Thomas Petazzoni 7 | 8 | Index: b/Makefile 9 | =================================================================== 10 | --- a/Makefile 11 | +++ b/Makefile 12 | @@ -309,11 +309,8 @@ 13 | 14 | $(obj)/qconf.o: $(obj)/qconf.moc 15 | 16 | -quiet_cmd_moc = MOC $@ 17 | - cmd_moc = $(KC_QT_MOC) -i $< -o $@ 18 | - 19 | $(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck 20 | - $(call cmd,moc) 21 | + $(KC_QT_MOC) -i $< -o $@ 22 | 23 | # Extract gconf menu items for I18N support 24 | $(obj)/gconf.glade.h: $(obj)/gconf.glade 25 | -------------------------------------------------------------------------------- /patches/16-fix-space-to-de-select-options.patch: -------------------------------------------------------------------------------- 1 | commit 6faa447282fe90d42e0513af46c13f20b4b327d4 2 | Author: Yann E. MORIN 3 | Date: Wed Nov 13 22:45:02 2013 +0100 4 | 5 | support/kconfig: fix 'space' to (de)select options 6 | 7 | In case a menu has comment without letters/numbers (eg. characters 8 | matching the regexp '^[^[:alpha:][:digit:]]+$', for example - or *), 9 | hitting space will cycle through those comments, rather than 10 | selecting/deselecting the currently-highlighted option. 11 | 12 | This is the behaviour of hitting any letter/digit: jump to the next 13 | option which prompt starts with that letter. The only letters that 14 | do not behave as such are 'y' 'm' and 'n'. Prompts that start with 15 | one of those three letters are instead matched on the first letter 16 | that is not 'y', 'm' or 'n'. 17 | 18 | Fix that by treating 'space' as we treat y/m/n, ie. as an action key, 19 | not as shortcut to jump to prompt. 20 | 21 | Signed-off-by: "Yann E. MORIN" 22 | Cc: Thomas Petazzoni 23 | Cc: Peter Korsgaard 24 | Cc: Samuel Martin 25 | Cc: Thomas De Schampheleire 26 | --- 27 | Note: I'll be running this upstream soonish. 28 | 29 | diff --git a/support/kconfig/lxdialog/menubox.c b/support/kconfig/lxdialog/menubox.c 30 | index 48d382e..6fc7e78 100644 31 | --- a/lxdialog/menubox.c 32 | +++ b/lxdialog/menubox.c 33 | @@ -285,7 +285,7 @@ do_resize: 34 | if (key < 256 && isalpha(key)) 35 | key = tolower(key); 36 | 37 | - if (strchr("ynmh", key)) 38 | + if (strchr("ynmh ", key)) 39 | i = max_choice; 40 | else { 41 | for (i = choice + 1; i < max_choice; i++) { 42 | -------------------------------------------------------------------------------- /patches/series: -------------------------------------------------------------------------------- 1 | 01-kconfig-kernel-to-buildroot.patch 2 | 10-br-build-system.patch 3 | 11-use-mktemp-for-lxdialog.patch 4 | 12-fix-glade-file-path.patch 5 | 14-support-out-of-tree-config.patch 6 | 15-fix-qconf-moc-rule.patch 7 | 16-fix-space-to-de-select-options.patch 8 | 100-kconfig-generic-env.patch 9 | 101-kconfig-build.patch 10 | -------------------------------------------------------------------------------- /qconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Roman Zippel 3 | * Released under the terms of the GNU GPL v2.0. 4 | */ 5 | 6 | #if QT_VERSION < 0x040000 7 | #include 8 | #else 9 | #include 10 | #endif 11 | #include 12 | 13 | #if QT_VERSION < 0x040000 14 | #define Q3ValueList QValueList 15 | #define Q3PopupMenu QPopupMenu 16 | #define Q3ListView QListView 17 | #define Q3ListViewItem QListViewItem 18 | #define Q3VBox QVBox 19 | #define Q3TextBrowser QTextBrowser 20 | #define Q3MainWindow QMainWindow 21 | #define Q3Action QAction 22 | #define Q3ToolBar QToolBar 23 | #define Q3ListViewItemIterator QListViewItemIterator 24 | #define Q3FileDialog QFileDialog 25 | #endif 26 | 27 | class ConfigView; 28 | class ConfigList; 29 | class ConfigItem; 30 | class ConfigLineEdit; 31 | class ConfigMainWindow; 32 | 33 | class ConfigSettings : public QSettings { 34 | public: 35 | ConfigSettings(); 36 | Q3ValueList readSizes(const QString& key, bool *ok); 37 | bool writeSizes(const QString& key, const Q3ValueList& value); 38 | }; 39 | 40 | enum colIdx { 41 | promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr 42 | }; 43 | enum listMode { 44 | singleMode, menuMode, symbolMode, fullMode, listMode 45 | }; 46 | enum optionMode { 47 | normalOpt = 0, allOpt, promptOpt 48 | }; 49 | 50 | class ConfigList : public Q3ListView { 51 | Q_OBJECT 52 | typedef class Q3ListView Parent; 53 | public: 54 | ConfigList(ConfigView* p, const char *name = 0); 55 | void reinit(void); 56 | ConfigView* parent(void) const 57 | { 58 | return (ConfigView*)Parent::parent(); 59 | } 60 | ConfigItem* findConfigItem(struct menu *); 61 | 62 | protected: 63 | void keyPressEvent(QKeyEvent *e); 64 | void contentsMousePressEvent(QMouseEvent *e); 65 | void contentsMouseReleaseEvent(QMouseEvent *e); 66 | void contentsMouseMoveEvent(QMouseEvent *e); 67 | void contentsMouseDoubleClickEvent(QMouseEvent *e); 68 | void focusInEvent(QFocusEvent *e); 69 | void contextMenuEvent(QContextMenuEvent *e); 70 | 71 | public slots: 72 | void setRootMenu(struct menu *menu); 73 | 74 | void updateList(ConfigItem *item); 75 | void setValue(ConfigItem* item, tristate val); 76 | void changeValue(ConfigItem* item); 77 | void updateSelection(void); 78 | void saveSettings(void); 79 | signals: 80 | void menuChanged(struct menu *menu); 81 | void menuSelected(struct menu *menu); 82 | void parentSelected(void); 83 | void gotFocus(struct menu *); 84 | 85 | public: 86 | void updateListAll(void) 87 | { 88 | updateAll = true; 89 | updateList(NULL); 90 | updateAll = false; 91 | } 92 | ConfigList* listView() 93 | { 94 | return this; 95 | } 96 | ConfigItem* firstChild() const 97 | { 98 | return (ConfigItem *)Parent::firstChild(); 99 | } 100 | int mapIdx(colIdx idx) 101 | { 102 | return colMap[idx]; 103 | } 104 | void addColumn(colIdx idx, const QString& label) 105 | { 106 | colMap[idx] = Parent::addColumn(label); 107 | colRevMap[colMap[idx]] = idx; 108 | } 109 | void removeColumn(colIdx idx) 110 | { 111 | int col = colMap[idx]; 112 | if (col >= 0) { 113 | Parent::removeColumn(col); 114 | colRevMap[col] = colMap[idx] = -1; 115 | } 116 | } 117 | void setAllOpen(bool open); 118 | void setParentMenu(void); 119 | 120 | bool menuSkip(struct menu *); 121 | 122 | template 123 | void updateMenuList(P*, struct menu*); 124 | 125 | bool updateAll; 126 | 127 | QPixmap symbolYesPix, symbolModPix, symbolNoPix; 128 | QPixmap choiceYesPix, choiceNoPix; 129 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; 130 | 131 | bool showName, showRange, showData; 132 | enum listMode mode; 133 | enum optionMode optMode; 134 | struct menu *rootEntry; 135 | QColorGroup disabledColorGroup; 136 | QColorGroup inactivedColorGroup; 137 | Q3PopupMenu* headerPopup; 138 | 139 | private: 140 | int colMap[colNr]; 141 | int colRevMap[colNr]; 142 | }; 143 | 144 | class ConfigItem : public Q3ListViewItem { 145 | typedef class Q3ListViewItem Parent; 146 | public: 147 | ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v) 148 | : Parent(parent, after), menu(m), visible(v), goParent(false) 149 | { 150 | init(); 151 | } 152 | ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) 153 | : Parent(parent, after), menu(m), visible(v), goParent(false) 154 | { 155 | init(); 156 | } 157 | ConfigItem(Q3ListView *parent, ConfigItem *after, bool v) 158 | : Parent(parent, after), menu(0), visible(v), goParent(true) 159 | { 160 | init(); 161 | } 162 | ~ConfigItem(void); 163 | void init(void); 164 | void okRename(int col); 165 | void updateMenu(void); 166 | void testUpdateMenu(bool v); 167 | ConfigList* listView() const 168 | { 169 | return (ConfigList*)Parent::listView(); 170 | } 171 | ConfigItem* firstChild() const 172 | { 173 | return (ConfigItem *)Parent::firstChild(); 174 | } 175 | ConfigItem* nextSibling() const 176 | { 177 | return (ConfigItem *)Parent::nextSibling(); 178 | } 179 | void setText(colIdx idx, const QString& text) 180 | { 181 | Parent::setText(listView()->mapIdx(idx), text); 182 | } 183 | QString text(colIdx idx) const 184 | { 185 | return Parent::text(listView()->mapIdx(idx)); 186 | } 187 | void setPixmap(colIdx idx, const QPixmap& pm) 188 | { 189 | Parent::setPixmap(listView()->mapIdx(idx), pm); 190 | } 191 | const QPixmap* pixmap(colIdx idx) const 192 | { 193 | return Parent::pixmap(listView()->mapIdx(idx)); 194 | } 195 | void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); 196 | 197 | ConfigItem* nextItem; 198 | struct menu *menu; 199 | bool visible; 200 | bool goParent; 201 | }; 202 | 203 | class ConfigLineEdit : public QLineEdit { 204 | Q_OBJECT 205 | typedef class QLineEdit Parent; 206 | public: 207 | ConfigLineEdit(ConfigView* parent); 208 | ConfigView* parent(void) const 209 | { 210 | return (ConfigView*)Parent::parent(); 211 | } 212 | void show(ConfigItem *i); 213 | void keyPressEvent(QKeyEvent *e); 214 | 215 | public: 216 | ConfigItem *item; 217 | }; 218 | 219 | class ConfigView : public Q3VBox { 220 | Q_OBJECT 221 | typedef class Q3VBox Parent; 222 | public: 223 | ConfigView(QWidget* parent, const char *name = 0); 224 | ~ConfigView(void); 225 | static void updateList(ConfigItem* item); 226 | static void updateListAll(void); 227 | 228 | bool showName(void) const { return list->showName; } 229 | bool showRange(void) const { return list->showRange; } 230 | bool showData(void) const { return list->showData; } 231 | public slots: 232 | void setShowName(bool); 233 | void setShowRange(bool); 234 | void setShowData(bool); 235 | void setOptionMode(QAction *); 236 | signals: 237 | void showNameChanged(bool); 238 | void showRangeChanged(bool); 239 | void showDataChanged(bool); 240 | public: 241 | ConfigList* list; 242 | ConfigLineEdit* lineEdit; 243 | 244 | static ConfigView* viewList; 245 | ConfigView* nextView; 246 | 247 | static QAction *showNormalAction; 248 | static QAction *showAllAction; 249 | static QAction *showPromptAction; 250 | }; 251 | 252 | class ConfigInfoView : public Q3TextBrowser { 253 | Q_OBJECT 254 | typedef class Q3TextBrowser Parent; 255 | public: 256 | ConfigInfoView(QWidget* parent, const char *name = 0); 257 | bool showDebug(void) const { return _showDebug; } 258 | 259 | public slots: 260 | void setInfo(struct menu *menu); 261 | void saveSettings(void); 262 | void setShowDebug(bool); 263 | 264 | signals: 265 | void showDebugChanged(bool); 266 | void menuSelected(struct menu *); 267 | 268 | protected: 269 | void symbolInfo(void); 270 | void menuInfo(void); 271 | QString debug_info(struct symbol *sym); 272 | static QString print_filter(const QString &str); 273 | static void expr_print_help(void *data, struct symbol *sym, const char *str); 274 | Q3PopupMenu* createPopupMenu(const QPoint& pos); 275 | void contentsContextMenuEvent(QContextMenuEvent *e); 276 | 277 | struct symbol *sym; 278 | struct menu *_menu; 279 | bool _showDebug; 280 | }; 281 | 282 | class ConfigSearchWindow : public QDialog { 283 | Q_OBJECT 284 | typedef class QDialog Parent; 285 | public: 286 | ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); 287 | 288 | public slots: 289 | void saveSettings(void); 290 | void search(void); 291 | 292 | protected: 293 | QLineEdit* editField; 294 | QPushButton* searchButton; 295 | QSplitter* split; 296 | ConfigView* list; 297 | ConfigInfoView* info; 298 | 299 | struct symbol **result; 300 | }; 301 | 302 | class ConfigMainWindow : public Q3MainWindow { 303 | Q_OBJECT 304 | 305 | static Q3Action *saveAction; 306 | static void conf_changed(void); 307 | public: 308 | ConfigMainWindow(void); 309 | public slots: 310 | void changeMenu(struct menu *); 311 | void setMenuLink(struct menu *); 312 | void listFocusChanged(void); 313 | void goBack(void); 314 | void loadConfig(void); 315 | bool saveConfig(void); 316 | void saveConfigAs(void); 317 | void searchConfig(void); 318 | void showSingleView(void); 319 | void showSplitView(void); 320 | void showFullView(void); 321 | void showIntro(void); 322 | void showAbout(void); 323 | void saveSettings(void); 324 | 325 | protected: 326 | void closeEvent(QCloseEvent *e); 327 | 328 | ConfigSearchWindow *searchWindow; 329 | ConfigView *menuView; 330 | ConfigList *menuList; 331 | ConfigView *configView; 332 | ConfigList *configList; 333 | ConfigInfoView *helpText; 334 | Q3ToolBar *toolBar; 335 | Q3Action *backAction; 336 | QSplitter* split1; 337 | QSplitter* split2; 338 | }; 339 | -------------------------------------------------------------------------------- /util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2005 Roman Zippel 3 | * Copyright (C) 2002-2005 Sam Ravnborg 4 | * 5 | * Released under the terms of the GNU GPL v2.0. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "lkc.h" 12 | 13 | /* file already present in list? If not add it */ 14 | struct file *file_lookup(const char *name) 15 | { 16 | struct file *file; 17 | const char *file_name = sym_expand_string_value(name); 18 | 19 | for (file = file_list; file; file = file->next) { 20 | if (!strcmp(name, file->name)) { 21 | free((void *)file_name); 22 | return file; 23 | } 24 | } 25 | 26 | file = xmalloc(sizeof(*file)); 27 | memset(file, 0, sizeof(*file)); 28 | file->name = file_name; 29 | file->next = file_list; 30 | file_list = file; 31 | return file; 32 | } 33 | 34 | /* write a dependency file as used by kbuild to track dependencies */ 35 | int file_write_dep(const char *name) 36 | { 37 | char *str; 38 | char buf[PATH_MAX+1], buf2[PATH_MAX+1], dir[PATH_MAX+1]; 39 | struct symbol *sym, *env_sym; 40 | struct expr *e; 41 | struct file *file; 42 | FILE *out; 43 | 44 | if (!name) 45 | name = ".kconfig.d"; 46 | 47 | strcpy(dir, conf_get_configname()); 48 | str = strrchr(dir, '/'); 49 | if (str) 50 | str[1] = 0; 51 | else 52 | dir[0] = 0; 53 | 54 | sprintf(buf, "%s..config.tmp", dir); 55 | out = fopen(buf, "w"); 56 | if (!out) 57 | return 1; 58 | fprintf(out, "deps_config := \\\n"); 59 | for (file = file_list; file; file = file->next) { 60 | if (file->next) 61 | fprintf(out, "\t%s \\\n", file->name); 62 | else 63 | fprintf(out, "\t%s\n", file->name); 64 | } 65 | fprintf(out, "\n%s: \\\n" 66 | "\t$(deps_config)\n\n", conf_get_autoconfig_name()); 67 | 68 | expr_list_for_each_sym(sym_env_list, e, sym) { 69 | struct property *prop; 70 | const char *value; 71 | 72 | prop = sym_get_env_prop(sym); 73 | env_sym = prop_get_symbol(prop); 74 | if (!env_sym) 75 | continue; 76 | value = getenv(env_sym->name); 77 | if (!value) 78 | value = ""; 79 | fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value); 80 | fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name()); 81 | fprintf(out, "endif\n"); 82 | } 83 | 84 | fprintf(out, "\n$(deps_config): ;\n"); 85 | fclose(out); 86 | sprintf(buf2, "%s%s", dir, name); 87 | rename(buf, buf2); 88 | return 0; 89 | } 90 | 91 | 92 | /* Allocate initial growable string */ 93 | struct gstr str_new(void) 94 | { 95 | struct gstr gs; 96 | gs.s = xmalloc(sizeof(char) * 64); 97 | gs.len = 64; 98 | gs.max_width = 0; 99 | strcpy(gs.s, "\0"); 100 | return gs; 101 | } 102 | 103 | /* Allocate and assign growable string */ 104 | struct gstr str_assign(const char *s) 105 | { 106 | struct gstr gs; 107 | gs.s = strdup(s); 108 | gs.len = strlen(s) + 1; 109 | gs.max_width = 0; 110 | return gs; 111 | } 112 | 113 | /* Free storage for growable string */ 114 | void str_free(struct gstr *gs) 115 | { 116 | if (gs->s) 117 | free(gs->s); 118 | gs->s = NULL; 119 | gs->len = 0; 120 | } 121 | 122 | /* Append to growable string */ 123 | void str_append(struct gstr *gs, const char *s) 124 | { 125 | size_t l; 126 | if (s) { 127 | l = strlen(gs->s) + strlen(s) + 1; 128 | if (l > gs->len) { 129 | gs->s = realloc(gs->s, l); 130 | gs->len = l; 131 | } 132 | strcat(gs->s, s); 133 | } 134 | } 135 | 136 | /* Append printf formatted string to growable string */ 137 | void str_printf(struct gstr *gs, const char *fmt, ...) 138 | { 139 | va_list ap; 140 | char s[10000]; /* big enough... */ 141 | va_start(ap, fmt); 142 | vsnprintf(s, sizeof(s), fmt, ap); 143 | str_append(gs, s); 144 | va_end(ap); 145 | } 146 | 147 | /* Retrieve value of growable string */ 148 | const char *str_get(struct gstr *gs) 149 | { 150 | return gs->s; 151 | } 152 | 153 | void *xmalloc(size_t size) 154 | { 155 | void *p = malloc(size); 156 | if (p) 157 | return p; 158 | fprintf(stderr, "Out of memory.\n"); 159 | exit(1); 160 | } 161 | 162 | void *xcalloc(size_t nmemb, size_t size) 163 | { 164 | void *p = calloc(nmemb, size); 165 | if (p) 166 | return p; 167 | fprintf(stderr, "Out of memory.\n"); 168 | exit(1); 169 | } 170 | 171 | 172 | -------------------------------------------------------------------------------- /zconf.gperf: -------------------------------------------------------------------------------- 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 | 10 | struct kconf_id; 11 | 12 | static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); 13 | 14 | %% 15 | mainmenu, T_MAINMENU, TF_COMMAND 16 | menu, T_MENU, TF_COMMAND 17 | endmenu, T_ENDMENU, TF_COMMAND 18 | source, T_SOURCE, TF_COMMAND 19 | choice, T_CHOICE, TF_COMMAND 20 | endchoice, T_ENDCHOICE, TF_COMMAND 21 | comment, T_COMMENT, TF_COMMAND 22 | config, T_CONFIG, TF_COMMAND 23 | menuconfig, T_MENUCONFIG, TF_COMMAND 24 | help, T_HELP, TF_COMMAND 25 | if, T_IF, TF_COMMAND|TF_PARAM 26 | endif, T_ENDIF, TF_COMMAND 27 | depends, T_DEPENDS, TF_COMMAND 28 | optional, T_OPTIONAL, TF_COMMAND 29 | default, T_DEFAULT, TF_COMMAND, S_UNKNOWN 30 | prompt, T_PROMPT, TF_COMMAND 31 | tristate, T_TYPE, TF_COMMAND, S_TRISTATE 32 | def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE 33 | bool, T_TYPE, TF_COMMAND, S_BOOLEAN 34 | boolean, T_TYPE, TF_COMMAND, S_BOOLEAN 35 | def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN 36 | int, T_TYPE, TF_COMMAND, S_INT 37 | hex, T_TYPE, TF_COMMAND, S_HEX 38 | string, T_TYPE, TF_COMMAND, S_STRING 39 | select, T_SELECT, TF_COMMAND 40 | range, T_RANGE, TF_COMMAND 41 | visible, T_VISIBLE, TF_COMMAND 42 | option, T_OPTION, TF_COMMAND 43 | on, T_ON, TF_PARAM 44 | modules, T_OPT_MODULES, TF_OPTION 45 | defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION 46 | env, T_OPT_ENV, TF_OPTION 47 | %% 48 | -------------------------------------------------------------------------------- /zconf.l: -------------------------------------------------------------------------------- 1 | %option nostdinit noyywrap never-interactive full ecs 2 | %option 8bit nodefault perf-report perf-report 3 | %option noinput 4 | %x COMMAND HELP STRING PARAM 5 | %{ 6 | /* 7 | * Copyright (C) 2002 Roman Zippel 8 | * Released under the terms of the GNU GPL v2.0. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "lkc.h" 18 | 19 | #define START_STRSIZE 16 20 | 21 | static struct { 22 | struct file *file; 23 | int lineno; 24 | } current_pos; 25 | 26 | static char *text; 27 | static int text_size, text_asize; 28 | 29 | struct buffer { 30 | struct buffer *parent; 31 | YY_BUFFER_STATE state; 32 | }; 33 | 34 | struct buffer *current_buf; 35 | 36 | static int last_ts, first_ts; 37 | 38 | static void zconf_endhelp(void); 39 | static void zconf_endfile(void); 40 | 41 | static void new_string(void) 42 | { 43 | text = xmalloc(START_STRSIZE); 44 | text_asize = START_STRSIZE; 45 | text_size = 0; 46 | *text = 0; 47 | } 48 | 49 | static void append_string(const char *str, int size) 50 | { 51 | int new_size = text_size + size + 1; 52 | if (new_size > text_asize) { 53 | new_size += START_STRSIZE - 1; 54 | new_size &= -START_STRSIZE; 55 | text = realloc(text, new_size); 56 | text_asize = new_size; 57 | } 58 | memcpy(text + text_size, str, size); 59 | text_size += size; 60 | text[text_size] = 0; 61 | } 62 | 63 | static void alloc_string(const char *str, int size) 64 | { 65 | text = xmalloc(size + 1); 66 | memcpy(text, str, size); 67 | text[size] = 0; 68 | } 69 | %} 70 | 71 | n [A-Za-z0-9_] 72 | 73 | %% 74 | int str = 0; 75 | int ts, i; 76 | 77 | [ \t]*#.*\n | 78 | [ \t]*\n { 79 | current_file->lineno++; 80 | return T_EOL; 81 | } 82 | [ \t]*#.* 83 | 84 | 85 | [ \t]+ { 86 | BEGIN(COMMAND); 87 | } 88 | 89 | . { 90 | unput(yytext[0]); 91 | BEGIN(COMMAND); 92 | } 93 | 94 | 95 | { 96 | {n}+ { 97 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); 98 | BEGIN(PARAM); 99 | current_pos.file = current_file; 100 | current_pos.lineno = current_file->lineno; 101 | if (id && id->flags & TF_COMMAND) { 102 | zconflval.id = id; 103 | return id->token; 104 | } 105 | alloc_string(yytext, yyleng); 106 | zconflval.string = text; 107 | return T_WORD; 108 | } 109 | . 110 | \n { 111 | BEGIN(INITIAL); 112 | current_file->lineno++; 113 | return T_EOL; 114 | } 115 | } 116 | 117 | { 118 | "&&" return T_AND; 119 | "||" return T_OR; 120 | "(" return T_OPEN_PAREN; 121 | ")" return T_CLOSE_PAREN; 122 | "!" return T_NOT; 123 | "=" return T_EQUAL; 124 | "!=" return T_UNEQUAL; 125 | \"|\' { 126 | str = yytext[0]; 127 | new_string(); 128 | BEGIN(STRING); 129 | } 130 | \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; 131 | --- /* ignore */ 132 | ({n}|[-/.])+ { 133 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); 134 | if (id && id->flags & TF_PARAM) { 135 | zconflval.id = id; 136 | return id->token; 137 | } 138 | alloc_string(yytext, yyleng); 139 | zconflval.string = text; 140 | return T_WORD; 141 | } 142 | #.* /* comment */ 143 | \\\n current_file->lineno++; 144 | . 145 | <> { 146 | BEGIN(INITIAL); 147 | } 148 | } 149 | 150 | { 151 | [^'"\\\n]+/\n { 152 | append_string(yytext, yyleng); 153 | zconflval.string = text; 154 | return T_WORD_QUOTE; 155 | } 156 | [^'"\\\n]+ { 157 | append_string(yytext, yyleng); 158 | } 159 | \\.?/\n { 160 | append_string(yytext + 1, yyleng - 1); 161 | zconflval.string = text; 162 | return T_WORD_QUOTE; 163 | } 164 | \\.? { 165 | append_string(yytext + 1, yyleng - 1); 166 | } 167 | \'|\" { 168 | if (str == yytext[0]) { 169 | BEGIN(PARAM); 170 | zconflval.string = text; 171 | return T_WORD_QUOTE; 172 | } else 173 | append_string(yytext, 1); 174 | } 175 | \n { 176 | printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); 177 | current_file->lineno++; 178 | BEGIN(INITIAL); 179 | return T_EOL; 180 | } 181 | <> { 182 | BEGIN(INITIAL); 183 | } 184 | } 185 | 186 | { 187 | [ \t]+ { 188 | ts = 0; 189 | for (i = 0; i < yyleng; i++) { 190 | if (yytext[i] == '\t') 191 | ts = (ts & ~7) + 8; 192 | else 193 | ts++; 194 | } 195 | last_ts = ts; 196 | if (first_ts) { 197 | if (ts < first_ts) { 198 | zconf_endhelp(); 199 | return T_HELPTEXT; 200 | } 201 | ts -= first_ts; 202 | while (ts > 8) { 203 | append_string(" ", 8); 204 | ts -= 8; 205 | } 206 | append_string(" ", ts); 207 | } 208 | } 209 | [ \t]*\n/[^ \t\n] { 210 | current_file->lineno++; 211 | zconf_endhelp(); 212 | return T_HELPTEXT; 213 | } 214 | [ \t]*\n { 215 | current_file->lineno++; 216 | append_string("\n", 1); 217 | } 218 | [^ \t\n].* { 219 | while (yyleng) { 220 | if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t')) 221 | break; 222 | yyleng--; 223 | } 224 | append_string(yytext, yyleng); 225 | if (!first_ts) 226 | first_ts = last_ts; 227 | } 228 | <> { 229 | zconf_endhelp(); 230 | return T_HELPTEXT; 231 | } 232 | } 233 | 234 | <> { 235 | if (current_file) { 236 | zconf_endfile(); 237 | return T_EOL; 238 | } 239 | fclose(yyin); 240 | yyterminate(); 241 | } 242 | 243 | %% 244 | void zconf_starthelp(void) 245 | { 246 | new_string(); 247 | last_ts = first_ts = 0; 248 | BEGIN(HELP); 249 | } 250 | 251 | static void zconf_endhelp(void) 252 | { 253 | zconflval.string = text; 254 | BEGIN(INITIAL); 255 | } 256 | 257 | 258 | /* 259 | * Try to open specified file with following names: 260 | * ./name 261 | * $(srctree)/name 262 | * The latter is used when srctree is separate from objtree 263 | * when compiling the kernel. 264 | * Return NULL if file is not found. 265 | */ 266 | FILE *zconf_fopen(const char *name) 267 | { 268 | char *env, fullname[PATH_MAX+1]; 269 | FILE *f; 270 | 271 | f = fopen(name, "r"); 272 | if (!f && name != NULL && name[0] != '/') { 273 | env = getenv(SRCTREE); 274 | if (env) { 275 | sprintf(fullname, "%s/%s", env, name); 276 | f = fopen(fullname, "r"); 277 | } 278 | } 279 | return f; 280 | } 281 | 282 | void zconf_initscan(const char *name) 283 | { 284 | yyin = zconf_fopen(name); 285 | if (!yyin) { 286 | printf("can't find file %s\n", name); 287 | exit(1); 288 | } 289 | 290 | current_buf = xmalloc(sizeof(*current_buf)); 291 | memset(current_buf, 0, sizeof(*current_buf)); 292 | 293 | current_file = file_lookup(name); 294 | current_file->lineno = 1; 295 | } 296 | 297 | void zconf_nextfile(const char *name) 298 | { 299 | struct file *iter; 300 | struct file *file = file_lookup(name); 301 | struct buffer *buf = xmalloc(sizeof(*buf)); 302 | memset(buf, 0, sizeof(*buf)); 303 | 304 | current_buf->state = YY_CURRENT_BUFFER; 305 | yyin = zconf_fopen(file->name); 306 | if (!yyin) { 307 | printf("%s:%d: can't open file \"%s\"\n", 308 | zconf_curname(), zconf_lineno(), file->name); 309 | exit(1); 310 | } 311 | yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); 312 | buf->parent = current_buf; 313 | current_buf = buf; 314 | 315 | for (iter = current_file->parent; iter; iter = iter->parent ) { 316 | if (!strcmp(current_file->name,iter->name) ) { 317 | printf("%s:%d: recursive inclusion detected. " 318 | "Inclusion path:\n current file : '%s'\n", 319 | zconf_curname(), zconf_lineno(), 320 | zconf_curname()); 321 | iter = current_file->parent; 322 | while (iter && \ 323 | strcmp(iter->name,current_file->name)) { 324 | printf(" included from: '%s:%d'\n", 325 | iter->name, iter->lineno-1); 326 | iter = iter->parent; 327 | } 328 | if (iter) 329 | printf(" included from: '%s:%d'\n", 330 | iter->name, iter->lineno+1); 331 | exit(1); 332 | } 333 | } 334 | file->lineno = 1; 335 | file->parent = current_file; 336 | current_file = file; 337 | } 338 | 339 | static void zconf_endfile(void) 340 | { 341 | struct buffer *parent; 342 | 343 | current_file = current_file->parent; 344 | 345 | parent = current_buf->parent; 346 | if (parent) { 347 | fclose(yyin); 348 | yy_delete_buffer(YY_CURRENT_BUFFER); 349 | yy_switch_to_buffer(parent->state); 350 | } 351 | free(current_buf); 352 | current_buf = parent; 353 | } 354 | 355 | int zconf_lineno(void) 356 | { 357 | return current_pos.lineno; 358 | } 359 | 360 | const char *zconf_curname(void) 361 | { 362 | return current_pos.file ? current_pos.file->name : ""; 363 | } 364 | --------------------------------------------------------------------------------