diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2014-04-06 14:46:57 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2014-04-06 14:46:57 +0200 |
commit | e8440b5c2722b2740b7fd444edcd7cbd531ccddb (patch) | |
tree | 64f07e9f722439e9d77bf66b4b6c8339149537a9 /toolchain/uclibc | |
parent | b5a90a6f0655899fed42ba37d7825f7709ad4dea (diff) |
use lowercase directory name
Diffstat (limited to 'toolchain/uclibc')
-rw-r--r-- | toolchain/uclibc/Makefile | 129 | ||||
-rw-r--r-- | toolchain/uclibc/Makefile.inc | 10 | ||||
-rw-r--r-- | toolchain/uclibc/patches/uclibc-git-20140313.patch | 116105 | ||||
-rw-r--r-- | toolchain/uclibc/patches/xxx-origin.patch | 177 | ||||
-rw-r--r-- | toolchain/uclibc/patches/xxx-sparc-wait4.patch | 12 |
5 files changed, 116433 insertions, 0 deletions
diff --git a/toolchain/uclibc/Makefile b/toolchain/uclibc/Makefile new file mode 100644 index 000000000..94a81391d --- /dev/null +++ b/toolchain/uclibc/Makefile @@ -0,0 +1,129 @@ +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +_IN_CVTC= 1 + +include $(TOPDIR)/rules.mk +include ../rules.mk +include Makefile.inc +include ${TOPDIR}/mk/buildhlp.mk + +TARGET_CFLAGS:=$(filter-out -flto,$(TARGET_CFLAGS)) + +ifeq (${ADK_MAKE_PARALLEL},y) +UCLIBC_MAKEOPTS+= -j${ADK_MAKE_JOBS} +endif + +$(WRKBUILD)/.headers: + $(SED) 's,^CROSS_COMPILE=.*,CROSS_COMPILE=$(TARGET_CROSS),g' $(WRKBUILD)/Rules.mak + sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \ + $(TOPDIR)/target/$(ADK_TARGET_ARCH)/uclibc.config >${WRKBUILD}/.config +ifeq ($(ADK_TARGET_ENDIAN),little) + $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config + $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config +else + $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config + $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config +endif +ifeq ($(ADK_LINUX_64),y) + $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/# \1 is not set/' ${WRKBUILD}/.config +else + $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/# \1 is not set/' ${WRKBUILD}/.config +endif +ifeq ($(ADK_n64),y) + $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config + $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config +endif +ifeq ($(ADK_n32),y) + $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config + $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config +endif +ifeq ($(ADK_o32),y) + $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' ${WRKBUILD}/.config + $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config + $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config +endif +ifneq ($(ADK_PACKAGE_GDB),) + $(SED) "s/.*\(PTHREADS_DEBUG_SUPPORT\).*/\1=y/" ${WRKBUILD}/.config +endif +ifeq ($(ADK_LINUX_ARM_WITH_THUMB),y) + $(SED) 's/.*\(COMPILE_IN_THUMB_MODE\).*/\1=y/' ${WRKBUILD}/.config +endif +ifeq ($(ADK_TOOLCHAIN_GCC_USE_SSP),y) + $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config + echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config + echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config + echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config +endif + echo N|$(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \ + PREFIX=$(STAGING_TARGET_DIR) \ + DEVEL_PREFIX=/usr/ \ + RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \ + HOSTCC="$(CC_FOR_BUILD)" \ + CPU_CFLAGS="$(TARGET_CFLAGS)" \ + oldconfig + $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \ + PREFIX=$(STAGING_TARGET_DIR) \ + DEVEL_PREFIX=/usr/ \ + RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \ + HOSTCC="$(CC_FOR_BUILD)" \ + CPU_CFLAGS="$(TARGET_CFLAGS)" \ + install_headers + touch $(WRKBUILD)/.configured + touch $@ + +$(WRKBUILD)/.compiled: + $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \ + PREFIX= \ + DEVEL_PREFIX=/ \ + RUNTIME_PREFIX=/ \ + HOSTCC="$(CC_FOR_BUILD)" \ + CPU_CFLAGS="$(TARGET_CFLAGS)" \ + all + touch $@ + +$(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled + $(MAKE) -C $(WRKBUILD) \ + PREFIX=$(STAGING_TARGET_DIR) \ + DEVEL_PREFIX=/usr/ \ + DEVEL_PREFIX_LIB=/ \ + RUNTIME_PREFIX=/ \ + CPU_CFLAGS="$(TARGET_CFLAGS)" \ + install_dev + touch $@ + +$(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers + touch $@ + +$(WRKBUILD)/.fixup: + # DOSTRIP kills x86 target (ld.so can not map libc.so.0), always use DODEBUG + # DODEBUG compile failure linking with libgcc_eh.a on arm hf +ifneq ($(ADK_LINUX_ARM),y) + $(SED) 's,DOSTRIP,DODEBUG,' ${WRKBUILD}/.config +endif + $(MAKE) -C $(WRKBUILD) \ + PREFIX=$(STAGING_TARGET_DIR) \ + DEVEL_PREFIX=/usr/ \ + DEVEL_PREFIX_LIB=/ \ + RUNTIME_PREFIX=/ \ + CPU_CFLAGS="$(TARGET_CFLAGS)" \ + all install_runtime + # cleanup toolchain + -find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -delete +ifeq ($(ADK_TOOLCHAIN),y) + # strip target libs and host tools for toolchain builds + PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \ + $(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME) + debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin +endif + touch $@ + +include ${TOPDIR}/mk/toolchain.mk diff --git a/toolchain/uclibc/Makefile.inc b/toolchain/uclibc/Makefile.inc new file mode 100644 index 000000000..eff931e2b --- /dev/null +++ b/toolchain/uclibc/Makefile.inc @@ -0,0 +1,10 @@ +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +PKG_NAME:= uClibc +PKG_VERSION:= 0.9.33.2 +GIT_VERSION:= 0.9.34-git +PKG_RELEASE:= 1 +PKG_MD5SUM:= 73e6fe215648d02246f4d195b25fb17e +PKG_SITES:= http://uclibc.org/downloads/ +DISTFILES:= $(PKG_NAME)-$(PKG_VERSION).tar.xz diff --git a/toolchain/uclibc/patches/uclibc-git-20140313.patch b/toolchain/uclibc/patches/uclibc-git-20140313.patch new file mode 100644 index 000000000..561c08007 --- /dev/null +++ b/toolchain/uclibc/patches/uclibc-git-20140313.patch @@ -0,0 +1,116105 @@ +diff -Nur uClibc-0.9.33.2/docs/man/arc4random.3 uClibc-git/docs/man/arc4random.3 +--- uClibc-0.9.33.2/docs/man/arc4random.3 1970-01-01 01:00:00.000000000 +0100 ++++ uClibc-git/docs/man/arc4random.3 2014-02-03 12:32:56.000000000 +0100 +@@ -0,0 +1,110 @@ ++.\" $OpenBSD: arc4random.3,v 1.19 2005/07/17 08:50:55 jaredy Exp $ ++.\" ++.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> ++.\" All rights reserved. ++.\" ++.\" Redistribution and use in source and binary forms, with or without ++.\" modification, are permitted provided that the following conditions ++.\" are met: ++.\" 1. Redistributions of source code must retain the above copyright ++.\" notice, this list of conditions and the following disclaimer. ++.\" 2. Redistributions in binary form must reproduce the above copyright ++.\" notice, this list of conditions and the following disclaimer in the ++.\" documentation and/or other materials provided with the distribution. ++.\" 3. All advertising materials mentioning features or use of this software ++.\" must display the following acknowledgement: ++.\" This product includes software developed by Niels Provos. ++.\" 4. The name of the author may not be used to endorse or promote products ++.\" derived from this software without specific prior written permission. ++.\" ++.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++.\" ++.\" Manual page, using -mandoc macros ++.\" ++.Dd April 15, 1997 ++.Dt ARC4RANDOM 3 ++.Os ++.Sh NAME ++.Nm arc4random , ++.Nm arc4random_stir , ++.Nm arc4random_addrandom ++.Nd arc4 random number generator ++.Sh SYNOPSIS ++.Fd #include <stdlib.h> ++.Ft uint32_t ++.Fn arc4random "void" ++.Ft void ++.Fn arc4random_stir "void" ++.Ft void ++.Fn arc4random_addrandom "u_char *dat" "int datlen" ++.Sh DESCRIPTION ++The ++.Fn arc4random ++function provides a high quality 32-bit pseudo-random ++number very quickly. ++.Fn arc4random ++seeds itself on a regular basis from the kernel strong random number ++subsystem described in ++.Xr random 4 . ++On each call, an ARC4 generator is used to generate a new result. ++The ++.Fn arc4random ++function uses the ARC4 cipher key stream generator, ++which uses 8*8 8-bit S-Boxes. ++The S-Boxes can be in about (2**1700) states. ++.Pp ++.Fn arc4random ++fits into a middle ground not covered by other subsystems such as ++the strong, slow, and resource expensive random ++devices described in ++.Xr random 4 ++versus the fast but poor quality interfaces described in ++.Xr rand 3 , ++.Xr random 3 , ++and ++.Xr drand48 3 . ++.Pp ++The ++.Fn arc4random_stir ++function reads data from a pseudo-random device, usually ++.Pa /dev/urandom, ++and uses it to permute the S-Boxes via ++.Fn arc4random_addrandom . ++.Pp ++There is no need to call ++.Fn arc4random_stir ++before using ++.Fn arc4random , ++since ++.Fn arc4random ++automatically initializes itself. ++.Sh SEE ALSO ++.Xr rand 3 , ++.Xr rand48 3 , ++.Xr random 3 ++.Sh HISTORY ++An algorithm called ++.Pa RC4 ++was designed by RSA Data Security, Inc. ++It was considered a trade secret. ++Because it was a trade secret, it obviously could not be patented. ++A clone of this was posted anonymously to USENET and confirmed to ++be equivalent by several sources who had access to the original cipher. ++Because of the trade secret situation, RSA Data Security, Inc. can do ++nothing about the release of the ARC4 algorithm. ++Since ++.Pa RC4 ++used to be a trade secret, the cipher is now referred to as ++.Pa ARC4 . ++.Pp ++These functions first appeared in ++.Ox 2.1 . +diff -Nur uClibc-0.9.33.2/docs/PORTING uClibc-git/docs/PORTING +--- uClibc-0.9.33.2/docs/PORTING 2012-05-15 09:20:09.000000000 +0200 ++++ uClibc-git/docs/PORTING 2014-02-03 12:32:56.000000000 +0100 +@@ -130,9 +130,6 @@ + ==================== + === Misc Cruft === + ==================== +-- utils/readelf.c - not really needed generally speaking, but might as well +- add your arch to the giant EM_* list (describe_elf_hdr) +- + - MAINTAINERS - presumably you're going to submit this code back to mainline + and since you're the only one who cares about this arch (right now), you + should add yourself to the toplevel MAINTAINERS file. do it. +diff -Nur uClibc-0.9.33.2/extra/config/check.sh uClibc-git/extra/config/check.sh +--- uClibc-0.9.33.2/extra/config/check.sh 2012-05-15 09:20:09.000000000 +0200 ++++ uClibc-git/extra/config/check.sh 2014-02-03 12:32:56.000000000 +0100 +@@ -1,6 +1,6 @@ + #!/bin/sh + # Needed for systems without gettext +-$* -xc -o /dev/null - > /dev/null 2>&1 << EOF ++$* -x c -o /dev/null - > /dev/null 2>&1 << EOF + #include <libintl.h> + int main() + { +diff -Nur uClibc-0.9.33.2/extra/config/conf.c uClibc-git/extra/config/conf.c +--- uClibc-0.9.33.2/extra/config/conf.c 2012-05-15 09:20:09.000000000 +0200 ++++ uClibc-git/extra/config/conf.c 2014-02-03 12:32:56.000000000 +0100 +@@ -10,42 +10,48 @@ + #include <string.h> + #include <time.h> + #include <unistd.h> ++#include <getopt.h> + #include <sys/stat.h> + #include <sys/time.h> ++#include <errno.h> + +-#define LKC_DIRECT_LINK + #include "lkc.h" + + static void conf(struct menu *menu); + static void check_conf(struct menu *menu); ++static void xfgets(char *str, int size, FILE *in); + +-enum { +- ask_all, +- ask_new, +- ask_silent, +- set_default, +- set_yes, +- set_mod, +- set_no, +- set_random +-} input_mode = ask_all; +-char *defconfig_file; ++enum input_mode { ++ oldaskconfig, ++ silentoldconfig, ++ oldconfig, ++ allnoconfig, ++ allyesconfig, ++ allmodconfig, ++ alldefconfig, ++ randconfig, ++ defconfig, ++ savedefconfig, ++ listnewconfig, ++ olddefconfig, ++} input_mode = oldaskconfig; + + static int indent = 1; ++static int tty_stdio; + static int valid_stdin = 1; + static int sync_kconfig; + static int conf_cnt; + static char line[128]; + static struct menu *rootEntry; + +-static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"); +- +-static const char *get_help(struct menu *menu) ++static void print_help(struct menu *menu) + { +- if (menu_has_help(menu)) +- return _(menu_get_help(menu)); +- else +- return nohelp_text; ++ struct gstr help = str_new(); ++ ++ menu_get_ext_help(menu, &help); ++ ++ printf("\n%s\n", str_get(&help)); ++ str_free(&help); + } + + static void strip(char *str) +@@ -93,16 +99,19 @@ + } + + switch (input_mode) { +- case ask_new: +- case ask_silent: ++ case oldconfig: ++ case silentoldconfig: + if (sym_has_value(sym)) { + printf("%s\n", def); + return 0; + } + check_stdin(); +- case ask_all: ++ /* fall through */ ++ case oldaskconfig: + fflush(stdout); +- fgets(line, 128, stdin); ++ xfgets(line, 128, stdin); ++ if (!tty_stdio) ++ printf("\n"); + return 1; + default: + break; +@@ -121,7 +130,7 @@ + return 1; + } + +-int conf_string(struct menu *menu) ++static int conf_string(struct menu *menu) + { + struct symbol *sym = menu->sym; + const char *def; +@@ -140,10 +149,11 @@ + case '?': + /* print help */ + if (line[1] == '\n') { +- printf("\n%s\n", get_help(menu)); ++ print_help(menu); + def = NULL; + break; + } ++ /* fall through */ + default: + line[strlen(line)-1] = 0; + def = line; +@@ -156,14 +166,12 @@ + static int conf_sym(struct menu *menu) + { + struct symbol *sym = menu->sym; +- int type; + tristate oldval, newval; + + while (1) { + printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); + if (sym->name) + printf("(%s) ", sym->name); +- type = sym_get_type(sym); + putchar('['); + oldval = sym_get_tristate_value(sym); + switch (oldval) { +@@ -220,7 +228,7 @@ + if (sym_set_tristate_value(sym, newval)) + return 0; + help: +- printf("\n%s\n", get_help(menu)); ++ print_help(menu); + } + } + +@@ -228,11 +236,9 @@ + { + struct symbol *sym, *def_sym; + struct menu *child; +- int type; + bool is_new; + + sym = menu->sym; +- type = sym_get_type(sym); + is_new = !sym_has_value(sym); + if (sym_is_changable(sym)) { + conf_sym(menu); +@@ -294,20 +300,21 @@ + printf("?"); + printf("]: "); + switch (input_mode) { +- case ask_new: +- case ask_silent: ++ case oldconfig: ++ case silentoldconfig: + if (!is_new) { + cnt = def; + printf("%d\n", cnt); + break; + } + check_stdin(); +- case ask_all: ++ /* fall through */ ++ case oldaskconfig: + fflush(stdout); +- fgets(line, 128, stdin); ++ xfgets(line, 128, stdin); + strip(line); + if (line[0] == '?') { +- printf("\n%s\n", get_help(menu)); ++ print_help(menu); + continue; + } + if (!line[0]) +@@ -330,8 +337,8 @@ + } + if (!child) + continue; +- if (line[strlen(line) - 1] == '?') { +- printf("\n%s\n", get_help(child)); ++ if (line[0] && line[strlen(line) - 1] == '?') { ++ print_help(child); + continue; + } + sym_set_choice_value(sym, child->sym); +@@ -360,10 +367,14 @@ + + switch (prop->type) { + case P_MENU: +- if (input_mode == ask_silent && rootEntry != menu) { ++ if ((input_mode == silentoldconfig || ++ input_mode == listnewconfig || ++ input_mode == olddefconfig) && ++ rootEntry != menu) { + check_conf(menu); + return; + } ++ /* fall through */ + case P_COMMENT: + prompt = menu_get_prompt(menu); + if (prompt) +@@ -418,10 +429,16 @@ + if (sym && !sym_has_value(sym)) { + if (sym_is_changable(sym) || + (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { +- if (!conf_cnt++) +- printf(_("*\n* Restart config...\n*\n")); +- rootEntry = menu_get_parent_menu(menu); +- conf(rootEntry); ++ if (input_mode == listnewconfig) { ++ if (sym->name && !sym_is_choice_value(sym)) { ++ printf("%s%s\n", CONFIG_, sym->name); ++ } ++ } else if (input_mode != olddefconfig) { ++ if (!conf_cnt++) ++ printf(_("*\n* Restart config...\n*\n")); ++ rootEntry = menu_get_parent_menu(menu); ++ conf(rootEntry); ++ } + } + } + +@@ -429,90 +446,170 @@ + check_conf(child); + } + ++#if 00 // || !defined __UCLIBC__ || \ ++ (defined UCLIBC_HAS_GETOPT_LONG || defined UCLIBC_HAS_GNU_GETOPT) ++static struct option long_opts[] = { ++ {"oldaskconfig", no_argument, NULL, oldaskconfig}, ++ {"oldconfig", no_argument, NULL, oldconfig}, ++ {"silentoldconfig", no_argument, NULL, silentoldconfig}, ++ {"defconfig", optional_argument, NULL, defconfig}, ++ {"savedefconfig", required_argument, NULL, savedefconfig}, ++ {"allnoconfig", no_argument, NULL, allnoconfig}, ++ {"allyesconfig", no_argument, NULL, allyesconfig}, ++ {"allmodconfig", no_argument, NULL, allmodconfig}, ++ {"alldefconfig", no_argument, NULL, alldefconfig}, ++ {"randconfig", no_argument, NULL, randconfig}, ++ {"listnewconfig", no_argument, NULL, listnewconfig}, ++ {"olddefconfig", no_argument, NULL, olddefconfig}, ++ /* ++ * oldnoconfig is an alias of olddefconfig, because people already ++ * are dependent on its behavior(sets new symbols to their default ++ * value but not 'n') with the counter-intuitive name. ++ */ ++ {"oldnoconfig", no_argument, NULL, olddefconfig}, ++ {NULL, 0, NULL, 0} ++}; ++ ++static void conf_usage(const char *progname) ++{ ++ ++ printf("Usage: %s [option] <kconfig-file>\n", progname); ++ printf("[option] is _one_ of the following:\n"); ++ printf(" --listnewconfig List new options\n"); ++ printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); ++ printf(" --oldconfig Update a configuration using a provided .config as base\n"); ++ printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); ++ printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n"); ++ printf(" --oldnoconfig An alias of olddefconfig\n"); ++ printf(" --defconfig <file> New config with default defined in <file>\n"); ++ printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n"); ++ printf(" --allnoconfig New config where all options are answered with no\n"); ++ printf(" --allyesconfig New config where all options are answered with yes\n"); ++ printf(" --allmodconfig New config where all options are answered with mod\n"); ++ printf(" --alldefconfig New config with all symbols set to default\n"); ++ printf(" --randconfig New config with random answer to all options\n"); ++} ++#else ++static void conf_usage(const char *progname) ++{ ++ ++ printf("Usage: %s [option] <kconfig-file>\n", progname); ++ printf("[option] is _one_ of the following:\n"); ++ printf(" -a, --oldaskconfig Start a new configuration using a line-oriented program\n"); ++ printf(" -s, --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); ++ printf(" -o, --oldconfig Update a configuration using a provided .config as base\n"); ++ printf(" -n, --allnoconfig New config where all options are answered with no\n"); ++ printf(" -y, --allyesconfig New config where all options are answered with yes\n"); ++ printf(" -m, --allmodconfig New config where all options are answered with mod\n"); ++ printf(" -A, --alldefconfig New config with all symbols set to default\n"); ++ printf(" -r, --randconfig New config with random answer to all options\n"); ++ printf(" -D, --defconfig <file> New config with default defined in <file>\n"); ++ printf(" -S, --savedefconfig <file> Save the minimal current configuration to <file>\n"); ++ printf(" -l, --listnewconfig List new options\n"); ++ printf(" -d, --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n"); ++ printf(" --oldnoconfig An alias of olddefconfig\n"); ++ ++} ++#endif ++ + int main(int ac, char **av) + { ++ const char *progname = av[0]; + int opt; +- const char *name; +- const char *configname = conf_get_configname(); ++ const char *name, *defconfig_file = NULL /* gcc uninit */; + struct stat tmpstat; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + +- while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { ++ tty_stdio = isatty(0) && isatty(1) && isatty(2); ++ ++#if 00// !defined __UCLIBC__ || \ ++ (defined UCLIBC_HAS_GETOPT_LONG || defined UCLIBC_HAS_GNU_GETOPT) ++ while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) ++#else ++ char *gch = "asonymArDSld"; ++ while ((opt = getopt(ac, av, "asonymArD:S:ldh")) != -1) ++#endif ++ { ++ char *x = memchr(gch, opt, strlen(gch)); ++ if (x == NULL) ++ opt = '?'; ++ else ++ opt = x - gch; ++ input_mode = (enum input_mode)opt; + switch (opt) { +- case 'o': +- input_mode = ask_silent; +- break; +- case 's': +- input_mode = ask_silent; ++ case silentoldconfig: + sync_kconfig = 1; + break; +- case 'd': +- input_mode = set_default; +- break; +- case 'D': +- input_mode = set_default; ++ case defconfig: ++ case savedefconfig: + defconfig_file = optarg; + break; +- case 'n': +- input_mode = set_no; +- break; +- case 'm': +- input_mode = set_mod; +- break; +- case 'y': +- input_mode = set_yes; +- break; +- case 'r': ++ case randconfig: + { + struct timeval now; + unsigned int seed; ++ char *seed_env; + + /* + * Use microseconds derived seed, + * compensate for systems where it may be zero + */ + gettimeofday(&now, NULL); +- + seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); +- srand(seed); + +- input_mode = set_random; ++ seed_env = getenv("KCONFIG_SEED"); ++ if( seed_env && *seed_env ) { ++ char *endp; ++ int tmp = (int)strtol(seed_env, &endp, 0); ++ if (*endp == '\0') { ++ seed = tmp; ++ } ++ } ++ fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed ); ++ srand(seed); + break; + } +- case 'h': +- printf(_("See README for usage info\n")); +- exit(0); ++ case oldaskconfig: ++ case oldconfig: ++ case allnoconfig: ++ case allyesconfig: ++ case allmodconfig: ++ case alldefconfig: ++ case listnewconfig: ++ case olddefconfig: + break; +- default: +- fprintf(stderr, _("See README for usage info\n")); ++ case '?': ++ conf_usage(progname); + exit(1); ++ break; + } + } + if (ac == optind) { + printf(_("%s: Kconfig file missing\n"), av[0]); ++ conf_usage(progname); + exit(1); + } + name = av[optind]; + conf_parse(name); + //zconfdump(stdout); + if (sync_kconfig) { +- if (stat(configname, &tmpstat)) { ++ name = conf_get_configname(); ++ if (stat(name, &tmpstat)) { + fprintf(stderr, _("***\n" +- "*** You have not yet configured!\n" +- "*** (missing .config file)\n" ++ "*** Configuration file \"%s\" not found!\n" + "***\n" + "*** Please run some configurator (e.g. \"make oldconfig\" or\n" + "*** \"make menuconfig\" or \"make xconfig\").\n" +- "***\n")); ++ "***\n"), name); + exit(1); + } + } + + switch (input_mode) { +- case set_default: ++ case defconfig: + if (!defconfig_file) + defconfig_file = conf_get_default_confname(); + if (conf_read(defconfig_file)) { +@@ -522,31 +619,46 @@ + exit(1); + } + break; +- case ask_silent: +- case ask_all: +- case ask_new: ++ case savedefconfig: ++ case silentoldconfig: ++ case oldaskconfig: ++ case oldconfig: ++ case listnewconfig: ++ case olddefconfig: + conf_read(NULL); + break; +- case set_no: +- case set_mod: +- case set_yes: +- case set_random: ++ case allnoconfig: ++ case allyesconfig: ++ case allmodconfig: ++ case alldefconfig: ++ case randconfig: + name = getenv("KCONFIG_ALLCONFIG"); +- if (name && !stat(name, &tmpstat)) { +- conf_read_simple(name, S_DEF_USER); ++ if (!name) ++ break; ++ if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { ++ if (conf_read_simple(name, S_DEF_USER)) { ++ fprintf(stderr, ++ _("*** Can't read seed configuration \"%s\"!\n"), ++ name); ++ exit(1); ++ } + break; + } + switch (input_mode) { +- case set_no: name = "allno.config"; break; +- case set_mod: name = "allmod.config"; break; +- case set_yes: name = "allyes.config"; break; +- case set_random: name = "allrandom.config"; break; ++ case allnoconfig: name = "allno.config"; break; ++ case allyesconfig: name = "allyes.config"; break; ++ case allmodconfig: name = "allmod.config"; break; ++ case alldefconfig: name = "alldef.config"; break; ++ case randconfig: name = "allrandom.config"; break; + default: break; + } +- if (!stat(name, &tmpstat)) +- conf_read_simple(name, S_DEF_USER); +- else if (!stat("all.config", &tmpstat)) +- conf_read_simple("all.config", S_DEF_USER); ++ if (conf_read_simple(name, S_DEF_USER) && ++ conf_read_simple("all.config", S_DEF_USER)) { ++ fprintf(stderr, ++ _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"), ++ name); ++ exit(1); ++ } + break; + default: + break; +@@ -557,41 +669,51 @@ + name = getenv("KCONFIG_NOSILENTUPDATE"); + if (name && *name) { + fprintf(stderr, +- _("\n*** configuration requires explicit update.\n\n")); ++ _("\n*** The configuration requires explicit update.\n\n")); + return 1; + } + } +- valid_stdin = isatty(0) && isatty(1) && isatty(2); ++ valid_stdin = tty_stdio; + } + + switch (input_mode) { +- case set_no: ++ case allnoconfig: + conf_set_all_new_symbols(def_no); + break; +- case set_yes: ++ case allyesconfig: + conf_set_all_new_symbols(def_yes); + break; +- case set_mod: ++ case allmodconfig: + conf_set_all_new_symbols(def_mod); + break; +- case set_random: +- conf_set_all_new_symbols(def_random); ++ case alldefconfig: ++ conf_set_all_new_symbols(def_default); ++ break; ++ case randconfig: ++ /* Really nothing to do in this loop */ ++ while (conf_set_all_new_symbols(def_random)) ; + break; +- case set_default: ++ case defconfig: + conf_set_all_new_symbols(def_default); + break; +- case ask_new: +- case ask_all: ++ case savedefconfig: ++ break; ++ case oldaskconfig: + rootEntry = &rootmenu; + conf(&rootmenu); +- input_mode = ask_silent; ++ input_mode = silentoldconfig; + /* fall through */ +- case ask_silent: ++ case oldconfig: ++ case listnewconfig: ++ case olddefconfig: ++ case silentoldconfig: + /* Update until a loop caused no more changes */ + do { + conf_cnt = 0; + check_conf(&rootmenu); +- } while (conf_cnt); ++ } while (conf_cnt && ++ (input_mode != listnewconfig && ++ input_mode != olddefconfig)); + break; + } + +@@ -607,7 +729,13 @@ + fprintf(stderr, _("\n*** Error during update of the configuration.\n\n")); + return 1; + } +- } else { ++ } else if (input_mode == savedefconfig) { ++ if (conf_write_defconfig(defconfig_file)) { ++ fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"), ++ defconfig_file); ++ return 1; ++ } ++ } else if (input_mode != listnewconfig) { + if (conf_write(NULL)) { + fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); + exit(1); +@@ -615,3 +743,12 @@ + } + return 0; + } ++ ++/* ++ * Helper function to facilitate fgets() by Jean Sacren. ++ */ ++void xfgets(char *str, int size, FILE *in) ++{ ++ if (fgets(str, size, in) == NULL) ++ fprintf(stderr, "\nError in reading or end of file.\n"); ++} +diff -Nur uClibc-0.9.33.2/extra/config/confdata.c uClibc-git/extra/config/confdata.c +--- uClibc-0.9.33.2/extra/config/confdata.c 2012-05-15 09:20:09.000000000 +0200 ++++ uClibc-git/extra/config/confdata.c 2014-02-03 12:32:56.000000000 +0100 +@@ -5,24 +5,27 @@ + + #include <sys/stat.h> + #include <ctype.h> ++#include <errno.h> + #include <fcntl.h> ++#include <stdarg.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + #include <time.h> + #include <unistd.h> +-#include <libgen.h> + +-#define LKC_DIRECT_LINK + #include "lkc.h" + + static void conf_warning(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + ++static void conf_message(const char *fmt, ...) ++ __attribute__ ((format (printf, 1, 2))); ++ + static const char *conf_filename; + static int conf_lineno, conf_warnings, conf_unsaved; + +-const char conf_defname[] = "extra/Configs/defconfigs/$ARCH"; ++const char conf_defname[] = "arch/$ARCH/defconfig"; + + static void conf_warning(const char *fmt, ...) + { +@@ -35,6 +38,29 @@ + conf_warnings++; + } + ++static void conf_default_message_callback(const char *fmt, va_list ap) ++{ ++ printf("#\n# "); ++ vprintf(fmt, ap); ++ printf("\n#\n"); ++} ++ ++static void (*conf_message_callback) (const char *fmt, va_list ap) = ++ conf_default_message_callback; ++void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) ++{ ++ conf_message_callback = fn; ++} ++ ++static void conf_message(const char *fmt, ...) ++{ ++ va_list ap; ++ ++ va_start(ap, fmt); ++ if (conf_message_callback) ++ conf_message_callback(fmt, ap); ++} ++ + const char *conf_get_configname(void) + { + char *name = getenv("KCONFIG_CONFIG"); +@@ -42,6 +68,13 @@ + return name ? name : ".config"; + } + ++const char *conf_get_autoconfig_name(void) ++{ ++ char *name = getenv("KCONFIG_AUTOCONFIG"); ++ ++ return name ? name : "include/config/auto.conf"; ++} ++ + static char *conf_expand_value(const char *in) + { + struct symbol *sym; +@@ -95,6 +128,7 @@ + sym->flags |= def_flags; + break; + } ++ /* fall through */ + case S_BOOLEAN: + if (p[0] == 'y') { + sym->def[def].tri = yes; +@@ -107,7 +141,7 @@ + break; + } + conf_warning("symbol value '%s' invalid for %s", p, sym->name); +- break; ++ return 1; + case S_OTHER: + if (*p != '"') { + for (p2 = p; *p2 && !isspace(*p2); p2++) +@@ -115,6 +149,7 @@ + sym->type = S_STRING; + goto done; + } ++ /* fall through */ + case S_STRING: + if (*p++ != '"') + break; +@@ -129,6 +164,7 @@ + conf_warning("invalid string found"); + return 1; + } ++ /* fall through */ + case S_INT: + case S_HEX: + done: +@@ -146,10 +182,66 @@ + return 0; + } + ++#define LINE_GROWTH 16 ++static int add_byte(int c, char **lineptr, size_t slen, size_t *n) ++{ ++ char *nline; ++ size_t new_size = slen + 1; ++ if (new_size > *n) { ++ new_size += LINE_GROWTH - 1; ++ new_size *= 2; ++ nline = realloc(*lineptr, new_size); ++ if (!nline) ++ return -1; ++ ++ *lineptr = nline; ++ *n = new_size; ++ } ++ ++ (*lineptr)[slen] = c; ++ ++ return 0; ++} ++ ++static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream) ++{ ++ char *line = *lineptr; ++ size_t slen = 0; ++ ++ for (;;) { ++ int c = getc(stream); ++ ++ switch (c) { ++ case '\n': ++ if (add_byte(c, &line, slen, n) < 0) ++ goto e_out; ++ slen++; ++ /* fall through */ ++ case EOF: ++ if (add_byte('\0', &line, slen, n) < 0) ++ goto e_out; ++ *lineptr = line; ++ if (slen == 0) ++ return -1; ++ return slen; ++ default: ++ if (add_byte(c, &line, slen, n) < 0) ++ goto e_out; ++ slen++; ++ } ++ } ++ ++e_out: ++ line[slen-1] = '\0'; ++ *lineptr = line; ++ return -1; ++} ++ + int conf_read_simple(const char *name, int def) + { + FILE *in = NULL; +- char line[1024]; ++ char *line = NULL; ++ size_t line_asize = 0; + char *p, *p2; + struct symbol *sym; + int i, def_flags; +@@ -164,8 +256,11 @@ + if (in) + goto load; + sym_add_change_count(1); +- if (!sym_defconfig_list) ++ if (!sym_defconfig_list) { ++ if (modules_sym) ++ sym_calc_value(modules_sym); + return 1; ++ } + + for_all_defaults(sym_defconfig_list, prop) { + if (expr_calc_value(prop->visible.expr) == no || +@@ -174,9 +269,8 @@ + name = conf_expand_value(prop->expr->left.sym->name); + in = zconf_fopen(name); + if (in) { +- printf(_("#\n" +- "# using defaults found in %s\n" +- "#\n"), name); ++ conf_message(_("using defaults found in %s"), ++ name); + goto load; + } + } +@@ -202,33 +296,33 @@ + case S_STRING: + if (sym->def[def].val) + free(sym->def[def].val); |