diff options
author | Carmelo Amoroso <carmelo.amoroso@st.com> | 2008-11-17 15:10:13 +0000 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2008-11-17 15:10:13 +0000 |
commit | 02169fea4dd790c46c100e210fe21faf112e27d7 (patch) | |
tree | 7f6a257548c81cead6f61b56eba74b18a1dcaf18 | |
parent | 9584b4e582b293ead79d8bb0ff85c1ef12a888d9 (diff) | |
download | uClibc-alpine-02169fea4dd790c46c100e210fe21faf112e27d7.tar.bz2 uClibc-alpine-02169fea4dd790c46c100e210fe21faf112e27d7.tar.xz |
Synch with trunk @ 24071.
Step 2
locale stuff - configuration and top Makefiles
42 files changed, 1448 insertions, 923 deletions
@@ -11,3 +11,4 @@ top_builddir=./ #all: libs include Makefile.in include $(top_srcdir)Makerules +include $(top_srcdir)Makefile.help diff --git a/Makefile.help b/Makefile.help new file mode 100644 index 000000000..b8d2edc3c --- /dev/null +++ b/Makefile.help @@ -0,0 +1,45 @@ +# Makefile.help for uClibc +# +# Copyright (C) 2008 Erik Andersen <andersen@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +help: + @echo 'Cleaning:' + @echo ' clean - delete temporary object files' + @echo ' realclean - delete temporary object file, including dependencies' + @echo ' distclean - delete all non-source files (including .config)' + @echo + @echo 'Build:' + @echo ' all - libraries and generated headers' + @echo ' pregen - generate headers' + @echo + @echo 'Configuration:' + @echo ' allnoconfig - disable all symbols in .config' + @echo ' allyesconfig - enable all symbols in .config (see defconfig)' + @echo ' config - text based configurator (of last resort)' + @echo ' defconfig - set .config to arch-specific defaults' + @echo ' menuconfig - interactive curses-based configurator' + @echo ' oldconfig - resolve any unresolved symbols in .config' + @echo ' silentoldconfig - resolve any unresolved symbols in .config, silently' + @echo ' randconfig - generate a random .config' + @echo + @echo 'Installation:' + @echo ' install - install both the runtime and the headers' + @echo ' install_runtime - install the libraries' + @echo ' install_dev - install all headers and static libs' + @echo ' install_headers - install headers excluding generated ones' + @echo + @echo 'Development:' + @echo ' check - run testsuite' + @echo ' test_compile - compile testsuite binaries' + @echo ' release - create a distribution tarball' + @echo + @echo 'Environment variables:' + @echo ' - Quiet build' + @echo ' V=1 - Verbose build' + @echo ' V=2 - Very verbose build' + @echo ' CROSS= - Override CROSS_COMPILER_PREFIX from .config' + @echo ' SHELL= - Shell to use for make' + @echo ' CONFIG_SHELL= - Shell to use for menuconfig' diff --git a/Makefile.in b/Makefile.in index 58811c5e0..70d55eff2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ # Makefile for uClibc # -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org> # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # @@ -8,22 +8,33 @@ #-------------------------------------------------------------- # You shouldn't need to mess with anything beyond this point... #-------------------------------------------------------------- +clean_targets := clean realclean distclean \ + objclean-y headers_clean-y utils_clean noconfig_targets := menuconfig config oldconfig silentoldconfig randconfig \ - defconfig allyesconfig allnoconfig clean distclean \ - release dist tags + defconfig allyesconfig allnoconfig \ + release dist tags help include $(top_builddir)Rules.mak sub_headers := headers -#suspicious_dependency:=include/bits - ifeq ($(HAVE_DOT_CONFIG),y) all: pregen libs +libs: pregen # In this section, we need .config -include .config.cmd +else # ifeq ($(HAVE_DOT_CONFIG),y) + +all: menuconfig + +headers: + @echo "Need to make a config file first, run: make menuconfig" + @false + +endif # ifeq ($(HAVE_DOT_CONFIG),y) + include $(top_srcdir)ldso/Makefile.in include $(top_srcdir)libcrypt/Makefile.in include $(top_srcdir)libintl/Makefile.in @@ -38,6 +49,7 @@ include $(top_srcdir)extra/locale/Makefile.in # last included to catch all the objects added by others (locales/threads) include $(top_srcdir)libc/Makefile.in +ifeq ($(HAVE_DOT_CONFIG),y) # If the .config changes then we have to make sure that our includes are # updated properly. This would normally work by saying that the headers # have uClibc_config.h as prerequisite but since we _symlink_ the headers @@ -45,7 +57,6 @@ include $(top_srcdir)libc/Makefile.in # on spot to save us from alot of hazzle. include/bits/uClibc_config.h: extra/config/conf .config $(top_srcdir)extra/scripts/conf-header.sh | include/bits @$(disp_gen) - @#superfluous: $(Q)$(INSTALL) -d $(dir $@) $(Q)@$< -s $(top_srcdir)extra/Configs/Config.in $(Q)$(top_srcdir)extra/scripts/conf-header.sh .config > $@ $(Q)$(MAKE) headers-y @@ -152,7 +163,7 @@ include/bits/sysnum.h: $(top_srcdir)extra/scripts/gen_bits_syscall_h.sh @$(disp_gen) $(Q)set -e; \ cd $(top_builddir); \ - tmp=`mktemp include/bits/sysnum.h.XXXXXX 2>/dev/null`; \ + tmp=`mktemp include/bits/sysnum.h.XXXXXX 2>/dev/null || true`; \ [ -z "$$tmp" ] && tmp='include/bits/sysnum.h.new'; \ KERNEL_HEADERS="${KERNEL_HEADERS}" top_builddir=. CC="$(CC) $(CPU_CFLAGS)" $(SHELL) extra/scripts/gen_bits_syscall_h.sh > $$tmp; \ if cmp include/bits/sysnum.h $$tmp >/dev/null 2>&1; then \ @@ -308,6 +319,13 @@ ifneq ($(UCLIBC_LINUX_SPECIFIC),y) $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/inotify.h $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/perm.h $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/personality.h + $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/prctl.h + $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/reboot.h + $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/sendfile.h + $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/fsuid.h + $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/signalfd.h + $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/swap.h + $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/sysctl.h endif ifneq ($(UCLIBC_SV4_DEPRECATED),y) # Remove ustat.h since deprecated SV4 support was disabled upon request @@ -340,20 +358,24 @@ ifneq ($(UCLIBC_HAS_CRYPT),y) # Remove crypt.h since libcrypt was disabled upon request $(RM) $(PREFIX)$(DEVEL_PREFIX)include/crypt.h endif +ifneq ($(UCLIBC_SUPPORT_AI_ADDRCONFIG),y) + # Remove ifaddrs.h since the corresponding functionality is disabled + $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ifaddrs.h +endif # Installs development library links. -install_dev: install_headers +install_dev: install_headers all $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/ ifeq ($(HAVE_SHARED),y) for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \ - sed -e 's/lib\///'` ; do \ + $(SED) -e 's/lib\///'` ; do \ $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \ $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \ done if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \ $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \ - sed -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \ + $(SED) -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \ -e 's:$(SHARED_MAJORNAME):$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME):' \ -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO):' \ $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \ @@ -376,9 +398,9 @@ ifeq ($(DOPIC),y) # # If we build shared libraries then the static libs are PIC... # # Make _pic.a symlinks to make mklibs.py and similar tools happy. if [ -d lib ] ; then \ - for i in `find lib/ -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \ + for i in `find lib/ -type f -name 'lib*.a' | $(SED) -e 's/lib\///'` ; do \ $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \ - | sed -e 's/\.a$$/_pic.a/'`; \ + | $(SED) -e 's/\.a$$/_pic.a/'`; \ done ; \ fi endif @@ -387,14 +409,14 @@ ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y) for file in lib/lib*.gdb; do \ if test -f $$file; then \ $(INSTALL) -m 755 $$file $(PREFIX)$(DEVEL_PREFIX)lib; \ - $(INSTALL) -m 755 `echo $$file | sed 's/\.gdb$$//'` \ + $(INSTALL) -m 755 `echo $$file | $(SED) 's/\.gdb$$//'` \ $(PREFIX)$(DEVEL_PREFIX)lib; \ fi; \ done endif # Installs run-time libraries -install_runtime: +install_runtime: all ifeq ($(HAVE_SHARED),y) $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib $(INSTALL) -m 644 lib/lib*-$(VERSION).so \ @@ -408,6 +430,8 @@ ifeq ($(HAVE_SHARED),y) fi endif +hostutils: + $(Q)$(MAKE) CROSS="$(CROSS)" CC="$(CC)" HOSTCC="$(HOSTCC)" -C utils hostutils # Installs only library tests install_test: @@ -430,65 +454,50 @@ utils: install_utils: utils $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils utils_install -else # ifeq ($(HAVE_DOT_CONFIG),y) - -all: menuconfig - -headers: - @echo "Need to make a config file first, run: make menuconfig" - @false - endif # ifeq ($(HAVE_DOT_CONFIG),y) -include/bits: +include/bits include/config: @$(disp_mkdir) $(Q)$(INSTALL) -d $@ # configuration # --------------------------------------------------------------------------- -extra/config/conf extra/config/mconf: $(suspicious_dependency) +extra/config/conf extra/config/mconf: | include/config $(Q)$(MAKE) -C extra/config $(notdir $@) -menuconfig: extra/config/mconf $(suspicious_dependency) +menuconfig: extra/config/mconf $(Q)./extra/config/mconf extra/Configs/Config.in -config: extra/config/conf $(suspicious_dependency) +config: extra/config/conf $(Q)./extra/config/conf extra/Configs/Config.in -oldconfig: extra/config/conf $(suspicious_dependency) +oldconfig: extra/config/conf $(Q)./extra/config/conf -o extra/Configs/Config.in -silentoldconfig: extra/config/conf $(suspicious_dependency) +silentoldconfig: extra/config/conf $(Q)./extra/config/conf -s extra/Configs/Config.in -randconfig: extra/config/conf $(suspicious_dependency) +randconfig: extra/config/conf $(Q)./extra/config/conf -r extra/Configs/Config.in -allyesconfig: extra/config/conf $(suspicious_dependency) +allyesconfig: extra/config/conf $(Q)./extra/config/conf -y extra/Configs/Config.in - sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config - sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config - sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config - sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config - sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config + $(SED) -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config + $(SED) -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config + $(SED) -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config + $(SED) -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config + $(SED) -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config $(Q)./extra/config/conf -o extra/Configs/Config.in -allnoconfig: extra/config/conf $(suspicious_dependency) +allnoconfig: extra/config/conf $(Q)./extra/config/conf -n extra/Configs/Config.in -defconfig: extra/config/conf $(suspicious_dependency) +defconfig: extra/config/conf $(Q)./extra/config/conf -d extra/Configs/Config.in \ -D extra/Configs/defconfigs/$(ARCH) -clean: - $(Q)$(RM) -r lib include/bits - $(RM) ldso/*/*.a libpthread/*/*.a libc/*.a libcrypt/*.a libintl/*.a \ - libm/*.a libnsl/*.a libpthread/*.a libresolv/*.a librt/*.a \ - libutil/*.a lib/*.a \ - include/fpu_control.h include/dl-osinfo.h include/hp-timing.h - $(MAKE) objclean-y headers_clean-y - $(MAKE) -s -C test clean - $(MAKE) -C utils utils_clean +include_clean: + $(Q)$(RM) include/fpu_control.h include/dl-osinfo.h include/hp-timing.h @set -e; \ for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \ $(RM) include/sys/$$i; \ @@ -498,9 +507,14 @@ clean: $(RM) include/sys/$$i; \ done; \ fi + +clean: include_clean + $(Q)$(RM) -r lib include/bits + @$(MAKE) -C utils utils_clean + +$(MAKE) -s -C test clean @$(RM) include/linux include/asm* - $(RM) $(top_builddir)extra/scripts/unifdef - $(RM) -r $(LOCAL_INSTALL_PATH) + $(Q)$(RM) $(top_builddir)extra/scripts/unifdef + $(Q)$(RM) -r $(LOCAL_INSTALL_PATH) distclean: clean -find . \( -name core -o -name \*.orig -o -name \*~ -o -name .\*.dep \) -exec $(RM) {} \; @@ -7,9 +7,9 @@ PHONY := FORCE .PHONY: dummy $(PHONY) \ - all check clean realclean distclean test \ + all check test $(clean_targets) \ config dist menuconfig oldconfig release \ - subdirs utils + subdirs utils help # order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a ifeq ($(HAVE_SHARED),y) @@ -81,6 +81,8 @@ pur_disp_compile.u = echo " "CC $(show_objs) pur_disp_compile.S = echo " "AS $(show_objs) pur_disp_compile.m = $(pur_disp_compile.c) pur_disp_compile-m = echo " "CC-m $(show_objs) +pur_disp_hcompile.u= echo " "HOSTCC $(show_objs) +pur_disp_hcompile.o= echo " "HOSTCC-o $(show_objs) pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@ pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS) $@ pur_disp_ar = echo " "AR $(ARFLAGS) $@ @@ -89,6 +91,7 @@ pur_disp_ln = echo " "LN $@ pur_disp_mkdir = echo " "MKDIR $@ pur_disp_gen = echo " "GEN $@ pur_disp_unifdef = echo " "UNIFDEF $@ +pur_disp_rm = echo " "CLEAN $(@:_clean=) sil_disp_compile.c = true sil_disp_compile.i = true @@ -97,6 +100,8 @@ sil_disp_compile.u = true sil_disp_compile.S = true sil_disp_compile.m = true sil_disp_compile-m = true +sil_disp_hcompile.u= true +sil_disp_hcompile.o= true sil_disp_strip = true sil_disp_t_strip = true sil_disp_ar = true @@ -105,6 +110,7 @@ sil_disp_ln = true sil_disp_mkdir = true sil_disp_gen = true sil_disp_unifdef = true +sil_disp_rm = true ver_disp_compile.c = echo $(cmd_compile.c) ver_disp_compile.i = echo $(cmd_compile.i) @@ -113,6 +119,8 @@ ver_disp_compile.u = echo $(cmd_compile.u) ver_disp_compile.S = echo $(cmd_compile.S) ver_disp_compile.m = echo $(cmd_compile.m) ver_disp_compile-m = echo $(cmd_compile-m) +ver_disp_hcompile.u= echo $(cmd_hcompile.u) +ver_disp_hcompile.o= echo $(cmd_hcompile.o) ver_disp_strip = echo $(cmd_strip) ver_disp_t_strip = echo $(cmd_t_strip) ver_disp_ar = echo $(cmd_ar) @@ -121,6 +129,7 @@ ver_disp_ln = ver_disp_mkdir = ver_disp_gen = ver_disp_unifdef = echo $(cmd_unifdef) +ver_disp_rm = disp_compile.c = $($(DISP)_disp_compile.c) disp_compile.i = $($(DISP)_disp_compile.i) @@ -129,6 +138,8 @@ disp_compile.u = $($(DISP)_disp_compile.u) disp_compile.S = $($(DISP)_disp_compile.S) disp_compile.m = $($(DISP)_disp_compile.m) disp_compile-m = $($(DISP)_disp_compile-m) +disp_hcompile.u= $($(DISP)_disp_hcompile.u) +disp_hcompile.o= $($(DISP)_disp_hcompile.o) disp_strip = $($(DISP)_disp_strip) disp_t_strip = $($(DISP)_disp_t_strip) disp_ar = $($(DISP)_disp_ar) @@ -137,6 +148,7 @@ disp_ln = $($(DISP)_disp_ln) disp_mkdir = $($(DISP)_disp_mkdir) disp_gen = $($(DISP)_disp_gen) disp_unifdef = $($(DISP)_disp_unifdef) +disp_rm = $($(DISP)_disp_rm) any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) @@ -172,7 +184,7 @@ cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) \ $(CFLAGS-$(notdir $<)) \ $(CFLAGS-$(notdir $@)) \ $(CFLAGS_gen.dep) -cmd_compile.i = $(cmd_compile.c:-c=-E -dD) +cmd_compile.i = $(cmd_compile.c:-c=-E -dD $(EXTRA_CPPFLAGS)) cmd_compile.s = $(cmd_compile.c:-c=-S) cmd_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $(CFLAGS_gen.dep) cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@)) @@ -188,6 +200,12 @@ define do_ln $(Q)$(LN) -fs endef + +define do_rm + @$(disp_rm) + $(Q)$(RM) +endef + define do_awk @$(disp_gen) $(Q)$(AWK) -f @@ -198,21 +216,23 @@ compile.i = $(call maybe_exec,compile.i) compile.s = $(call maybe_exec,compile.s) compile.S = @$(call maybe_exec,compile.S) compile.m = @$(call maybe_exec,compile.m) -compile-m = @$(disp_compile-m) ; $(cmd_compile-m) ; $(do_t_strip) +compile-m = @$(disp_compile-m) ; $(cmd_compile-m) ; $(cmd_t_strip) do_strip = @$(disp_strip) ; $(cmd_strip) do_t_strip= @$(disp_t_strip) ; $(cmd_t_strip) do_unifdef= @$(disp_unifdef) ; $(cmd_unifdef) +hcompile.u= @$(disp_hcompile.u); $(cmd_hcompile.u) +hcompile.o= @$(disp_hcompile.o); $(cmd_hcompile.o) define do_ar - $(do_strip) @$(disp_ar) ; $(cmd_ar) + @$(do_t_strip) endef define compile.u @$(disp_compile.u) ; $(cmd_compile.u) @$(disp_t_strip) endef -hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) -hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) +cmd_hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) +cmd_hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) define link.so $(Q)$(INSTALL) -d $(dir $@) @@ -281,6 +301,7 @@ CFLAGS-.oS+=$(PICFLAG) -DSHARED %.i: %.S FORCE ; $(compile.i) %.s: %.c FORCE ; $(compile.s) %.s: %.S FORCE ; $(compile.s) +%.dep: $(top_builddir)lib/interp.c: | $(sub_headers) $(Q)$(INSTALL) -d $(dir $@) @@ -365,7 +386,7 @@ CRTS_COMPAT := #endif $(crt-y): $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC) -$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC): | $(headers-y) +$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC): | headers $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y) $(Q)$(INSTALL) -d $(dir $@) @@ -1,12 +1,12 @@ # Rules.make for uClibc # -# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org> # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # # check for proper make version -ifneq ($(findstring 3.7,$(MAKE_VERSION)),) +ifneq ($(findstring x3.7,x$(MAKE_VERSION)),) $(error Your make is too old $(MAKE_VERSION). Go get at least 3.80) endif @@ -41,6 +41,7 @@ INSTALL = install LN = ln RM = rm -f TAR = tar +SED = sed AWK = awk STRIP_FLAGS ?= -x -R .note -R .comment @@ -50,8 +51,10 @@ UNIFDEF := $(top_builddir)extra/scripts/unifdef -UUCLIBC_INTERNAL # Select the compiler needed to build binaries for your development system HOSTCC = gcc BUILD_CFLAGS = -O2 -Wall -export ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun.*/sparc/ -e s/sparc.*/sparc/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/ \ +export ARCH := $(shell uname -m | $(SED) -e s/i.86/i386/ \ + -e s/sun.*/sparc/ -e s/sparc.*/sparc/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/sh.*/sh/ \ -e s/s390x/s390/ -e s/parisc.*/hppa/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ -e s/xtensa.*/xtensa/ ) @@ -68,9 +71,9 @@ ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) endif # Make certain these contain a final "/", but no "//"s. -TARGET_ARCH:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | sed -e 's/^TARGET_ARCH=//' -e 's/"//g') +TARGET_ARCH:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | $(SED) -e 's/^TARGET_ARCH=//' -e 's/"//g') TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH)))) -TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | sed -e 's/^TARGET_SUBARCH=//' -e 's/"//g') +TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | $(SED) -e 's/^TARGET_SUBARCH=//' -e 's/"//g') TARGET_SUBARCH:=$(strip $(subst ",, $(strip $(TARGET_SUBARCH)))) RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX)))))) DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX)))))) @@ -81,8 +84,8 @@ export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS # Now config hard core MAJOR_VERSION := 0 MINOR_VERSION := 9 -SUBLEVEL := 29 -EXTRAVERSION := +SUBLEVEL := 30 +EXTRAVERSION :=-svn VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL) ifneq ($(EXTRAVERSION),) VERSION := $(VERSION)$(EXTRAVERSION) @@ -95,8 +98,10 @@ LIBC := libc SHARED_MAJORNAME := $(LIBC).so.$(MAJOR_VERSION) ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sparc64 x86_64 ),) UCLIBC_LDSO_NAME := ld64-uClibc +ARCH_NATIVE_BIT := 64 else UCLIBC_LDSO_NAME := ld-uClibc +ARCH_NATIVE_BIT := 32 endif UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(MAJOR_VERSION) NONSHARED_LIBNAME := uclibc_nonshared.a @@ -126,7 +131,7 @@ comma:=, space:= # ifndef CROSS -CROSS=$(subst ",, $(strip $(CROSS_COMPILER_PREFIX))) +CROSS=$(strip $(subst ",, $(CROSS_COMPILER_PREFIX))) endif # A nifty macro to make testing gcc features easier @@ -286,6 +291,7 @@ ifeq ($(TARGET_ARCH),mips) CPU_CFLAGS-$(CONFIG_MIPS_ISA_3)+=-mips3 -mtune=mips3 CPU_CFLAGS-$(CONFIG_MIPS_ISA_4)+=-mips4 -mtune=mips4 CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32)+=-mips32 -mtune=mips32 + CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32R2)+=-march=mips32r2 -mtune=mips32r2 CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32 ifeq ($(strip $(ARCH_BIG_ENDIAN)),y) CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-Wl,-melf64btsmip @@ -363,7 +369,7 @@ ifeq ($(TARGET_ARCH),powerpc) PIEFLAG_NAME:=-fpie PPC_HAS_REL16:=$(shell echo -e "\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n) CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16 - CPU_CFLAGS-$(CONFIG_E500) += "-D__NO_MATH_INLINES -D__NO_LONG_DOUBLE_MATH" + CPU_CFLAGS-$(CONFIG_E500) += "-D__NO_MATH_INLINES" endif @@ -475,9 +481,11 @@ ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y) # soft float encodings. ifneq ($(TARGET_ARCH),nios) ifneq ($(TARGET_ARCH),nios2) +ifneq ($(TARGET_ARCH),sh) CFLAGS += -msoft-float endif endif +endif ifeq ($(TARGET_ARCH),arm) # No longer needed with current toolchains, but leave it here for now. # If anyone is actually still using gcc 2.95 (say), they can uncomment it. diff --git a/extra/Configs/Config.arm b/extra/Configs/Config.arm index 26e1f3da4..2b91a34d3 100644 --- a/extra/Configs/Config.arm +++ b/extra/Configs/Config.arm @@ -48,8 +48,8 @@ choice optimizing purposes. To build a library that will run on all ARMCPU types (albeit not optimally fast), you can specify "Generic Arm" here. If you pick anything other than "Generic Arm", there is no guarantee - that uClibc will even run on anything other than the selected processor - type. + that uClibc will even run on anything other than the selected + processor type. Here are the settings recommended for greatest speed: - "Generic Arm" select this if your compiler is already setup to diff --git a/extra/Configs/Config.cris b/extra/Configs/Config.cris index 18c75fb58..b3811d1e9 100644 --- a/extra/Configs/Config.cris +++ b/extra/Configs/Config.cris @@ -19,10 +19,10 @@ choice prompt "Target Architecture Type" default CONFIG_CRIS help - This is the architecture type of your CPU. This information is used for - optimizing purposes. + This is the architecture type of your CPU. This information + is used for optimizing purposes. - These are the possible settings: + Possible settings: - CRIS Generic support for Axis' CRIS architecture. - CRISv32 Support for Axis' CRISv32 architecture. diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index fa6c74bf4..8d895935e 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -8,7 +8,7 @@ mainmenu "uClibc C Library Configuration" choice prompt "Target Architecture" help - Stuff + The architecture of your target. config TARGET_alpha bool "alpha" @@ -239,14 +239,14 @@ config FORCE_SHAREABLE_TEXT_SEGMENTS default n help If you answer Y here, the uClibc native shared library loader will - only load shared libraries, which do not need to modify any non-writable - segments. These libraries haven't set the DT_TEXTREL tag in the dynamic - section (==> objdump). All your libraries must be compiled with - -fPIC or -fpic, and all assembler function must be written as position - independent code (PIC). + only load shared libraries, which do not need to modify any + non-writable segments. These libraries haven't set the DT_TEXTREL + tag in the dynamic section (==> objdump). + All your libraries must be compiled with -fPIC or -fpic, and all + assembler function must be written as position independent code (PIC). Enabling this option will make uClibc's shared library loader a - little bit smaller and guarantee that no memory will be wasted by badly - coded shared libraries. + little bit smaller and guarantee that no memory will be wasted by + badly coded shared libraries. config LDSO_LDD_SUPPORT bool "Native 'ldd' support" @@ -257,7 +257,8 @@ config LDSO_LDD_SUPPORT which executes the shared library loader to resolve all dependencies and then provide a list of shared libraries that are required for an application to function. Disabling this option will makes uClibc's - shared library loader a little bit smaller. Most people will answer Y. + shared library loader a little bit smaller. + Most people will answer Y. config LDSO_CACHE_SUPPORT bool "Enable library loader cache (ld.so.conf)" @@ -345,7 +346,8 @@ config LDSO_GNU_HASH_SUPPORT Newest binutils support a new hash style named GNU-hash. The dynamic linker will use the new GNU-hash section (.gnu.hash) for symbol lookup if present into the ELF binaries, otherwise it will use the old SysV - hash style (.hash). This ensures that it is completely backward compatible. + hash style (.hash). This ensures that it is completely backward + compatible. Further, being the hash table implementation self-contained into each executable and shared libraries, objects with mixed hash style can peacefully coexist in the same process. @@ -422,6 +424,10 @@ config LINUXTHREADS_OLD the latest code from glibc, so it may be the only choice for the newer ports (like alpha/amd64/64bit arches and hppa). +config LINUXTHREADS_NEW + def_bool y + depends on UCLIBC_HAS_THREADS && !LINUXTHREADS_OLD && !UCLIBC_HAS_THREADS_NATIVE + config UCLIBC_HAS_SYSLOG bool "Syslog support" default y @@ -444,20 +450,34 @@ choice prompt "Malloc Implementation" default MALLOC if ! ARCH_USE_MMU default MALLOC_STANDARD if ARCH_USE_MMU + +config MALLOC + bool "malloc" help - "malloc" use mmap for all allocations and so works very well on MMU-less - systems that do not support the brk() system call. It is pretty smart - about reusing already allocated memory, and minimizing memory wastage. + "malloc" use mmap for all allocations and so works very well on + MMU-less systems that do not support the brk() system call. It is + pretty smart about reusing already allocated memory, and minimizing + memory wastage. This is the default for uClinux MMU-less systems. - "malloc-simple" was written from scratch for uClibc, and is the - simplest possible (and therefore smallest) malloc implementation. - This uses only the mmap() system call to allocation memory, and does - not use the brk() system call at all, making it a fine choice for - MMU-less systems with very limited memory. It is rather dumb, and - certainly isn't the fastest. But it is 100% standards compliant, - thread safe, and very small. +config MALLOC_SIMPLE + bool "malloc-simple" + help + "malloc-simple" is trivially simple and slow as molasses. It + was written from scratch for uClibc, and is the simplest possible + (and therefore smallest) malloc implementation. + + This uses only the mmap() system call to allocate and free memory, + and does not use the brk() system call at all, making it a fine + choice for MMU-less systems with very limited memory. It's 100% + standards compliant, thread safe, very small, and releases freed + memory back to the OS immediately rather than keeping it in the + process's heap for reallocation. It is also VERY SLOW. +config MALLOC_STANDARD + bool "malloc-standard" + depends on ARCH_USE_MMU + help "malloc-standard" is derived from the public domain dlmalloc implementation by Doug Lea. It is quite fast, and is pretty smart about reusing already allocated memory, and minimizing memory @@ -467,16 +487,6 @@ choice If unsure, answer "malloc-standard". -config MALLOC - bool "malloc" - -config MALLOC_SIMPLE - bool "malloc-simple" - -config MALLOC_STANDARD - bool "malloc-standard" - depends on ARCH_USE_MMU - endchoice config MALLOC_GLIBC_COMPAT @@ -516,8 +526,8 @@ config COMPAT_ATEXIT bool "Old (visible) atexit Support" default n help - Enable this option if you want to update from 0.9.28 to svn/0.9.29, else - you will be missing atexit() until you rebuild all apps. + Enable this option if you want to update from 0.9.28 to svn/0.9.29, + else you will be missing atexit() until you rebuild all apps. config UCLIBC_SUSV3_LEGACY bool "Enable SuSv3 LEGACY functions" @@ -679,7 +689,7 @@ config UCLIBC_HAS_TZ_FILE file consists of a single line (newline required) of text describing the timezone in the format specified for the TZ environment variable. - Simply doing 'echo CST6CDT > /etc/TZ' is enough to create a valid file. + Doing 'echo CST6CDT > /etc/TZ' is enough to create a valid file. See http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html for details on valid settings of 'TZ'. @@ -692,10 +702,10 @@ config UCLIBC_HAS_TZ_FILE_READ_MANY default y help Answer Y to enable repeated reading of the '/etc/TZ' file even after - a valid value has been read. This incurs the overhead of an open/read/close - for each tzset() call (explicit or implied). However, setting this - will allows applications to update their timezone information if the contents - of the file change. + a valid value has been read. This incurs the overhead of an + open/read/close for each tzset() call (explicit or implied). However, + setting this will allow applications to update their timezone + information if the contents of the file change. Most people will answer Y. @@ -725,7 +735,7 @@ config UCLIBC_PWD_BUFFER_SIZE config UCLIBC_GRP_BUFFER_SIZE int "Buffer size for getgrnam() and friends" default 256 - range 256 1024 + range 12 1024 help This sets the value of the buffer size for getgrnam() and friends. By default, this is 256. (For reference, glibc uses 1024). @@ -738,9 +748,8 @@ config UCLIBC_LINUX_MODULE_24 bool "Linux kernel module functions" default y help - init_module, create_module, query_module, delete_module - are used in linux (allegedly prior to 2.6) for loadable - kernel modules. + create_module, query_module + are used in linux (prior to 2.6) for loadable kernel modules. Say N if you do not use kernel modules. @@ -749,7 +758,7 @@ config UCLIBC_LINUX_SPECIFIC default y help fstatfs(), inotify_*(), ioperm(), iopl(), madvise(), modify_ldt(), - personality(), ppoll(), setresuid() + personality(), ppoll(), setresuid(), signalfd() config UCLIBC_HAS_GNU_ERROR bool "Support GNU extensions for error-reporting" @@ -784,7 +793,7 @@ config UCLIBC_HAS_OBSOLETE_BSD_SIGNAL bool "BSD obsolete signal functions" default n help - These functions are provided as a compatibility interface for + These functions are provided as a compatibility interface for programs that make use of the historical System V signal API. This API is obsolete: new applications should use the POSIX signal API (sigaction(2), @@ -824,8 +833,6 @@ config UCLIBC_SV4_DEPRECATED config UCLIBC_HAS_REALTIME bool "Realtime-related family of SUSv functions" default y - # glitch in mq_{send,receive} currently forces this on - select UCLIBC_HAS_ADVANCED_REALTIME help These functions are part of the Timers option and need not be available on all implementations. @@ -1017,11 +1024,14 @@ config UCLIBC_HAS_IPV6 config UCLIBC_HAS_RPC bool "Remote Procedure Call (RPC) support" default n + # RPC+socket-ipvX doesn't currently work. + depends on UCLIBC_HAS_IPV4 || UCLIBC_HAS_IPV6 help If you want to include RPC support, enable this. RPC is rarely used - for anything except for the NFS filesystem. Unless you plan to use NFS, - you can probably leave this set to N and save some space. If you need - to use NFS then you should answer Y. + for anything except for the NFS filesystem. Unless you plan to use + NFS, you can probably leave this set to N and save some space. + + If you need to use NFS then you should answer Y. config UCLIBC_HAS_FULL_RPC bool "Full RPC support" @@ -1077,30 +1087,52 @@ config UCLIBC_HAS_BSD_RES_CLOSE Most people will say N. +config UCLIBC_HAS_COMPAT_RES_STATE + bool "Use compatible but bloated _res" + default y + help + Answer Y if you build network utilities and they muck with resolver + internals a lot (_res global structure). uclibc does not use most + of _res.XXX fields, and with this option OFF they won't even exist. + Which will make e.g. dig build fail. + Answering N saves around 400 bytes in bss. + +config UCLIBC_HAS_EXTRA_COMPAT_RES_STATE + bool "Use extra compatible but extra bloated _res" + default n + help + Answer Y if selecting UCLIBC_HAS_COMPAT_RES_STATE is not enough. + As far as I can say, this should never be needed. + endif menu "String and Stdio Support" config UCLIBC_HAS_STRING_GENERIC_OPT - bool "Use glibc generic string functions" + bool "Use faster (but larger) generic string functions" default y help Answer Y to use the (tweaked) glibc generic string functions. + In general, they are faster (but 3-5K larger) than the base uClibc string functions which are optimized solely for size. Many people will answer Y. config UCLIBC_HAS_STRING_ARCH_OPT - bool "Use arch-specific string functions" + bool "Use arch-specific assembly string functions (where available)" default y help - Answer Y to use the arch-specific string functions instead of the - base uClibc versions, which are optimized exclusively for size. + Answer Y to use any archtecture-specific assembly language string + functions available for this target plaform. - Most people will answer Y, as this has been default behavior - for some time. + Note that assembly implementations are not available for all string + functions, so some generic (written in C) string functions may + still be used. + + These are small and fast, the only reason _not_ to say Y here is + for debugging purposes. config UCLIBC_HAS_CTYPE_TABLES bool "Use Table Versions Of 'ctype.h' Functions." @@ -1130,7 +1162,8 @@ choice depends on UCLIBC_HAS_CTYPE_TABLES default UCLIBC_HAS_CTYPE_UNSAFE help - Please select the invalid arg behavior you want for the 'ctype' functions. + Please select the invalid arg behavior you want for the 'ctype' + functions. The 'ctype' functions are now implemented using table lookups, with the arg being the index. This can result in incorrect memory accesses @@ -1187,15 +1220,17 @@ config UCLIBC_PREGENERATED_LOCALE_DATA default n help If you are selective and only want locale data for a few particular - locales, or you enjoy pain, or you are a rabid do-it-yourself sort of - person, you can turn this option off and manually walk through the - mostly undocumented procedure needed to generate your own locale - data. + locales, you can turn this option off. Mere mortals will answer Y and use the default set of pregenerated locale data, which supports 169 UTF-8 locales, and 144 locales for other codesets (for the complete list see extra/locale/LOCALES). + Note that these pregenerated locales are sensitive to your + target architecture (endianess, bitcount). + + Saying N here is recommended. + config UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA bool "Automagically Download the Pre-generated Locale Data (if necessary)" depends on UCLIBC_PREGENERATED_LOCALE_DATA @@ -1204,8 +1239,8 @@ config UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA If you would like the build process to use 'wget' to automatically download the pregenerated locale data, enable this option. Otherwise you will need to obtain the locale data yourself from: - http://www.uclibc.org/downloads/uClibc-locale-030818.tgz - and place the uClibc-locale-030818.tgz tarball in the extra/locale/ + http://www.uclibc.org/downloads/uClibc-locale-*.tgz + and place the uClibc-locale-*.tgz tarball in the extra/locale/ directory. Go ahead and make life easy for yourself... Answer Y. @@ -1216,8 +1251,10 @@ config UCLIBC_HAS_XLOCALE default n help Answer Y to enable extended locale support similar to that provided - by glibc. This is primarily intended to support libstd++ functionality. - However, it also allows thread-specific locale selection via uselocale(). + by glibc. This is primarily intended to support libstd++ + functionality. + However, it also allows thread-specific locale selection via + uselocale(). Most people will answer N. @@ -1240,9 +1277,10 @@ config UCLIBC_HAS_GLIBC_DIGIT_GROUPING depends on UCLIBC_HAS_FLOATS default n help - Answer Y to enable support for glibc's \"'\" flag for allowing locale-specific - digit grouping in base 10 integer conversions and appropriate floating point - conversions in the *printf() and *scanf() functions. + Answer Y to enable support for glibc's \"'\" flag for allowing + locale-specific digit grouping in base 10 integer conversions and + appropriate floating point conversions in the *printf() and *scanf() + functions. Most people will answer N. @@ -1251,10 +1289,11 @@ config UCLIBC_HAS_SCANF_LENIENT_DIGIT_GROUPING depends on UCLIBC_HAS_GLIBC_DIGIT_GROUPING default y help - Answer Y to make digit grouping optional when the \"'\" flag is specified. + Answer Y to make digit grouping optional when the \"'\" flag is + specified. This is the standard glibc behavior. If the initial string of digits - exceeds the maximum group number, the input will be treated as a normal - non-grouped number. + exceeds the maximum group number, the input will be treated as a + normal non-grouped number. Most people will answer N. @@ -1266,8 +1305,8 @@ config UCLIBC_HAS_GLIBC_CUSTOM_PRINTF Answer Y to support glibc's register_printf_function() to allow an application to add its own printf conversion specifiers. - NOTE: This implementation limits the number or registered specifiers to 10. - NOTE: This implementation requires new conversion specifiers to be ASCII + NOTE: Limits the number or registered specifiers to 10. + NOTE: Requires new conversion specifiers to be ASCII characters (0-0x7f). This is to avoid problems with processing format strings in locales with different multibyte conversions. @@ -1278,9 +1317,10 @@ config USE_OLD_VFPRINTF depends on !UCLIBC_HAS_WCHAR default n help - Set to true to use the old vfprintf instead of the new. This is roughly - C89 compliant with some extensions, and is much smaller. However, it does - not support wide chars, positional args, or glibc custom printf specifiers. + Set to true to use the old vfprintf instead of the new. This is + roughly C89 compliant with some extensions, and is much smaller. + However, it does not support wide chars, positional args, or glibc + custom printf specifiers. Most people will answer N. @@ -1289,12 +1329,15 @@ config UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS depends on !USE_OLD_VFPRINTF default 9 help - Set the maximum number of positional args supported by the printf/scanf - functions. The Single Unix Specification Version 3 requires a minimum - value of 9. Setting this to a value lower than 9 will disable positional - arg support and cause the NL_ARGMAX macro in limits.h to be #undef'd. - WARNING! The workspace to support positional args is currently allocated - on the stack. You probably don't want to set this to too high a value. + Set the maximum number of positional args supported by the + printf/scanf functions. The Single Unix Specification Version 3 + requires a minimum value of 9. Setting this to a value lower than + 9 will disable positional arg support and cause the NL_ARGMAX macro + in limits.h to be #undef'd. + + WARNING! The workspace to support positional args is currently + allocated on the stack. You probably don't want to set + this to too high a value. Most people will answer 9. @@ -1381,9 +1424,10 @@ config UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT bool "Attempt to shutdown stdio subsystem when abort() is called." default n help - ANSI/ISO C99 requires abort() to be asyn-signal-safe. So there was a behavioral - change made in SUSv3. Previously, abort() was required to have the affect of - fclose() on all open streams. The wording has been changed to "may" from "shall". + ANSI/ISO C99 requires abort() to be asyn-signal-safe. So there was + a behavioral change made in SUSv3. Previously, abort() was required + to have the affect of fclose() on all open streams. The wording has + been changed to "may" from "shall". Most people will answer N. @@ -1410,15 +1454,17 @@ config UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION default y help Answer Y to enable the stdio subsystem to automaticly transition - between reading and writing. This relaxes the ANSI/ISO C99 requirement: - - When a file is opened with update mode ('+' as the second or third character - in the list of mode argument values), both input and output may be performed - on the associated stream. However, output shall not be directly followed by - input without an intervening call to the fflush function or to a file - positioning function (fseek, fsetpos, or rewind), and input shall not be - directly followed by output without an intervening call to a file positioning - function, unless the input operation encounters endoffile. + between reading and writing. This relaxes the ANSI/ISO C99 + requirement: + + When a file is opened with update mode ('+' as the second or third + character in the list of mode argument values), both input and output + may be performed on the associated stream. However, output shall not + be directly followed by input without an intervening call to the + fflush function or to a file positioning function (fseek, fsetpos, + or rewind), and input shall not be directly followed by output without + an intervening call to a file positioning function, unless the input + operation encounters endoffile. Most people will answer Y. @@ -1460,7 +1506,8 @@ config UCLIBC_HAS_PRINTF_M_SPEC help Answer Y to support a glibc extension to interpret '%m' in printf format strings as an instruction to output the error message string - (as generated by strerror) corresponding to the current value of 'errno'. + (as generated by strerror) corresponding to the current value of + 'errno'. Most people will answer N. @@ -1484,7 +1531,8 @@ config UCLIBC_HAS_SYS_ERRLIST arch where it adds over 4K. WARNING! In the future, support for sys_errlist[] may be unavailable - in at least some configurations. In fact, it may be removed altogether. + in at least some configurations. In fact, it may be removed + altogether. Most people will answer N. @@ -1508,7 +1556,8 @@ config UCLIBC_HAS_SYS_SIGLIST Answer Y if you want to support sys_siglist[]. WARNING! In the future, support for sys_siglist[] may be unavailable - in at least some configurations. In fact, it may be removed altogether. + in at least some configurations. In fact, it may be removed + altogether. Most people will answer N. @@ -1652,12 +1701,12 @@ config UCLIBC_HAS_GNU_GLOB depends on UCLIBC_HAS_GLOB default n help - The gnu glob interface is somewhat larger (weighing in at about 4,2k) than - it's SuSv3 counterpart (and is out of date). It is an old copy from glibc and - does not support all the GNU specific options. + The gnu glob interface is somewhat larger (weighing in at about 4,2k) + than it's SuSv3 counterpart (and is out of date). It is an old copy + from glibc and does not support all the GNU specific options. - Answer Y if you want to include full gnu glob() instead of the smaller SUSv3 - compatible glob(). + Answer Y if you want to include full gnu glob() instead of the smaller + SUSv3 compatible glob(). Most people will answer N. @@ -1731,12 +1780,16 @@ config UCLIBC_BUILD_PIE select FORCE_SHAREABLE_TEXT_SEGMENTS default n help - If you answer Y here, ldd and iconv are built as ET_DYN/PIE executables. + If you answer Y here, ldd and iconv are built as ET_DYN/PIE + executables. + It requires gcc-3.4 and binutils-2.15 (for arm 2.16) or later. More about ET_DYN/PIE binaries on <http://pax.grsecurity.net/> . - WARNING: This option also enables FORCE_SHAREABLE_TEXT_SEGMENTS, so all - libraries have to be built with -fPIC or -fpic, and all assembler - functions must be written as position independent code (PIC). + + WARNING: This option also enables FORCE_SHAREABLE_TEXT_SEGMENTS, so + all libraries have to be built with -fPIC or -fpic, and all + assembler functions must be written as position independent + code (PIC). config UCLIBC_HAS_ARC4RANDOM bool "Include the arc4random() function" @@ -1756,14 +1809,24 @@ config HAVE_NO_SSP default n config UCLIBC_HAS_SSP - bool "Support for propolice smashing stack protector" + bool "Support for GCC stack smashing protector" depends on !HAVE_NO_SSP default n help - Add propolice smashing stack protector to the library. - This requires GCC 4.1, supporting the -fstack-protector[-all] - options. GCC does not have to provide libssp, the needed - functions are added to ldso/libc instead. + Add code to support GCC's -fstack-protector[-all] option to uClibc. + This requires GCC 4.1 or newer. GCC does not have to provide libssp, + the needed functions are added to ldso/libc instead. + + GCC's stack protector is a reimplementation of IBM's propolice. + See http://www.trl.ibm.com/projects/security/ssp/ and + http://www.linuxfromscratch.org/hints/downloads/files/ssp.txt + for details. + + Note that NOEXECSTACK on a kernel with address space randomization + is generally sufficient to prevent most buffer overflow exploits + without increasing code size. This option essentially adds debugging + code to catch them. + Most people will answer N. config UCLIBC_HAS_SSP_COMPAT @@ -1772,12 +1835,15 @@ config UCLIBC_HAS_SSP_COMPAT default n help Add gcc-3.x propolice smashing stack protector to the library. + This requires a patched version of GCC, supporting the -fstack-protector[-all] options, with the __guard and __stack_smash_handler functions removed from libgcc. These functions are added to ldso/libc instead. + More information at: <http://www.research.ibm.com/trl/projects/security/ssp/> + Most people will answer N. config SSP_QUICK_CANARY @@ -1814,33 +1880,74 @@ config PROPOLICE_BLOCK_SEGV endchoice config UCLIBC_BUILD_SSP - bool "Build uClibc with propolice protection" + bool "Build uClibc with -fstack-protector" depends on UCLIBC_HAS_SSP default n help - Build all libraries and executables with propolice protection enabled. + Build all uClibc libraries and executables with -fstack-protector, + adding extra stack overflow checking to most uClibc functions. config UCLIBC_BUILD_RELRO - bool "Build uClibc with RELRO" + bool "Build uClibc with linker option -z RELRO" depends on HAVE_SHARED default y help - Build all libraries and executables with -z relro. + Build all libraries and executables with "ld -z relro". + + This tells the linker to mark chunks of an executable or shared + library read-only after applying dynamic relocations. (This comes + up when a global const variable is initialized to the address of a + function or the value of another global variable.) + + This is a fairly obscure option the ld man page doesn't even bother + to document properly. It's a security paranoia issue that's more + likely to consume memory (by allocating an extra page) rather than + save it. + + This is explained in more depth at + http://www.airs.com/blog/archives/189 + + Nobody is likely to care whether you say Y or N here. config UCLIBC_BUILD_NOW - bool "Build uClibc with NOW" + bool "Build uClibc with linker option -z NOW" depends on HAVE_SHARED default n help - Build all libraries and executables with -z now. + Build all libraries and executables with "ld -z now". + + This tells the linker to resolve all symbols when the library is + first loaded, rather than when each function is first called. This + increases start-up latency by a few microseconds and may do + unnecessary work (resolving symbols that are never used), but the + realtime people like it for making microbenchmark timings slightly + more predictable and in some cases it can be slightly faster due to + CPU cache behavior (not having to fault the linker back in to do + lazy symbol resolution). + + Most people can't tell the difference between selecting Y or N here. config UCLIBC_BUILD_NOEXECSTACK bool "Build uClibc with noexecstack marking" default y help - Mark all assembler files as noexecstack. This will result in marking - all libraries and executables built against uClibc not requiring - executable stack. + Mark all assembler files as noexecstack, which will mark uClibc + as not requiring an executable stack. (This doesn't prevent other + files you link against from claiming to need an executable stack, it + just won't cause uClibc to request it unnecessarily.) + + This is a security thing to make buffer overflows harder to exploit. + By itself, it's kind of useless, as Linus Torvalds explained in 1998: + http://old.lwn.net/1998/0806/a/linus-noexec.html + + It only actually provides any security when combined with address + space randomization, explained here: http://lwn.net/Articles/121845/ + + Address space randomization is on by default in current linux + kernels (although it can be disabled using the option + CONFIG_COMPAT_BRK). + + You should probably say Y. endmenu @@ -1918,9 +2025,11 @@ config SUPPORT_LD_DEBUG detail provide more information for some options move display copy processing symbols display symbol table processing - reloc display relocation processing; detail shows the relocation patch + reloc display relocation processing; detail shows the + relocation patch nofixups never fixes up jump relocations - bindings displays the resolve processing (function calls); detail shows the relocation patch + bindings displays the resolve processing (function calls); + detail shows the relocation patch all Enable everything! The additional environment variable: @@ -1959,12 +2068,14 @@ config UCLIBC_MALLOC_DEBUGGING Malloc debugging output may then be enabled at runtime using the MALLOC_DEBUG environment variable. - The value of MALLOC_DEBUG should be an integer, which is interpreted as - a bitmask with the following bits: + The value of MALLOC_DEBUG should be an integer, which is interpreted + as a bitmask with the following bits: 1 - do extra consistency checking - 2 - output messages for malloc/free calls and OS allocation calls + 2 - output messages for malloc/free calls and OS + allocation calls 4 - output messages for the `MMB' layer - 8 - output messages for internal malloc heap manipulation calls + 8 - output messages for internal malloc heap manipulation + calls Because this increases the size of malloc appreciably (due to strings etc), you should say N unless you need to debug a malloc problem. @@ -1986,6 +2097,13 @@ config DOMULTI default n help Set this to compile all sources at once into an object (IMA). + This mode of compilation uses alot of memory but may produce + smaller binaries. + + Note that you need a very recent GCC for this to work, like + gcc >= 4.3 plus eventually some patches. + + If unsure, keep the default of N. config UCLIBC_MJN3_ONLY bool "Manuel's hidden warnings" diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch index 2a912a109..f4a44ef1c 100644 --- a/extra/Configs/Config.in.arch +++ b/extra/Configs/Config.in.arch @@ -168,6 +168,19 @@ config UCLIBC_HAS_FENV point environment, rounding and exception handling functions then say Y here. + NOTE: Supported architectures currently include: + i386 + +config UCLIBC_HAS_LONG_DOUBLE_MATH + bool "Enable long double support" + depends on DO_C99_MATH + depends on TARGET_i386 || TARGET_m68k || TARGET_sparc || TARGET_x86_64 || TARGET_powerpc + default y + help + If you want the uClibc math library to contain the full set of C99 + long double math library features, then answer Y. Don't enable it + for sparc w/ 32bit ABI. + config KERNEL_HEADERS string "Linux kernel header location" default "/usr/include" diff --git a/extra/Configs/Config.m68k b/extra/Configs/Config.m68k index f86ca35b4..95807c485 100644 --- a/extra/Configs/Config.m68k +++ b/extra/Configs/Config.m68k @@ -11,7 +11,3 @@ config FORCE_OPTIONS_FOR_ARCH bool default y select ARCH_BIG_ENDIAN - -config ARCH_CFLAGS - string - default "-Wa,--bitwise-or" diff --git a/extra/Configs/Config.mips b/extra/Configs/Config.mips index 442209884..8350ea427 100644 --- a/extra/Configs/Config.mips +++ b/extra/Configs/Config.mips @@ -68,6 +68,9 @@ config CONFIG_MIPS_ISA_4 config CONFIG_MIPS_ISA_MIPS32 bool "MIPS32" +config CONFIG_MIPS_ISA_MIPS32R2 + bool "MIPS32r2" + config CONFIG_MIPS_ISA_MIPS64 bool "MIPS64" diff --git a/extra/config/Makefile b/extra/config/Makefile index 45ec1f47e..836f1f9f1 100644 --- a/extra/config/Makefile +++ b/extra/config/Makefile @@ -13,7 +13,7 @@ endif -include .depend .depend: $(wildcard *.h *.c) - $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > .depend 2>/dev/null || : + $(Q)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > .depend 2>/dev/null || : __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) @@ -37,7 +37,9 @@ clean: $(Q)rm -f $(clean-files) conf distclean: clean $(Q)rm -f $(lxdialog) $(conf-objs) $(mconf-objs) $(kxgettext-objs) \ - $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) .depend + $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \ + .depend + $(Q)rm -r -f $(top_builddir)include/config FORCE: .PHONY: FORCE clean distclean diff --git a/extra/config/Makefile.kconfig b/extra/config/Makefile.kconfig index 32e8c5a22..fa1a7d565 100644 --- a/extra/config/Makefile.kconfig +++ b/extra/config/Makefile.kconfig @@ -36,10 +36,10 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h --output $(obj)/config.pot $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch - $(Q)(for i in `ls arch/`; \ + $(Q)(for i in `ls arch/*/Kconfig`; \ do \ echo " GEN $$i"; \ - $(obj)/kxgettext arch/$$i/Kconfig \ + $(obj)/kxgettext $$i \ >> $(obj)/config.pot; \ done ) $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ diff --git a/extra/config/README.uClibc b/extra/config/README.uClibc index fa1a0018f..b05cabc2a 100644 --- a/extra/config/README.uClibc +++ b/extra/config/README.uClibc @@ -5,8 +5,9 @@ To update: cd extra/config.new cp /usr/src/linux/Documentation/kbuild/kconfig-language.txt . mv Makefile Makefile.kconfig - patch -p1 < ../config/kconfig-to-uclibc.patch + zcat ../config/kconfig-to-uclibc.patch.gz | patch -p1 cp ../config/README.uClibc . + cp ../config/Makefile . cd .. rm -rf config mv config.new config diff --git a/extra/config/conf.c b/extra/config/conf.c index 6735bfe76..02b2600c2 100644 --- a/extra/config/conf.c +++ b/extra/config/conf.c @@ -32,6 +32,7 @@ char *defconfig_file; static int indent = 1; static int valid_stdin = 1; +static int sync_kconfig; static int conf_cnt; static char line[128]; static struct menu *rootEntry; @@ -65,7 +66,7 @@ static void strip(char *str) static void check_stdin(void) { - if (!valid_stdin && input_mode == ask_silent) { + if (!valid_stdin) { printf(_("aborted!\n\n")); printf(_("Console input/output is redirected. ")); printf(_("Run 'make oldconfig' to update configuration.\n\n")); @@ -76,7 +77,6 @@ static void check_stdin(void) static int conf_askvalue(struct symbol *sym, const char *def) { enum symbol_type type = sym_get_type(sym); - tristate val; if (!sym_has_value(sym)) printf(_("(NEW) ")); @@ -92,15 +92,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) } switch (input_mode) { - case set_no: - case set_mod: - case set_yes: - case set_random: - if (sym_has_value(sym)) { - printf("%s\n", def); - return 0; - } - break; case ask_new: case ask_silent: if (sym_has_value(sym)) { @@ -112,9 +103,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) fflush(stdout); fgets(line, 128, stdin); return 1; - case set_default: - printf("%s\n", def); - return 1; default: break; } @@ -128,52 +116,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) default: ; } - switch (input_mode) { - case set_yes: - if (sym_tristate_within_range(sym, yes)) { - line[0] = 'y'; - line[1] = '\n'; - line[2] = 0; - break; - } - case set_mod: - if (type == S_TRISTATE) { - if (sym_tristate_within_range(sym, mod)) { - line[0] = 'm'; - line[1] = '\n'; - line[2] = 0; - break; - } - } else { - if (sym_tristate_within_range(sym, yes)) { - line[0] = 'y'; - line[1] = '\n'; - line[2] = 0; - break; - } - } - case set_no: - if (sym_tristate_within_range(sym, no)) { - line[0] = 'n'; - line[1] = '\n'; - line[2] = 0; - break; - } - case set_random: - do { - val = (tristate)(rand() % 3); - } while (!sym_tristate_within_range(sym, val)); - switch (val) { - case no: line[0] = 'n'; break; - case mod: line[0] = 'm'; break; - case yes: line[0] = 'y'; break; - } - line[1] = '\n'; - line[2] = 0; - break; - default: - break; - } printf("%s", line); return 1; } @@ -374,15 +316,7 @@ static int conf_choice(struct menu *menu) else continue; break; - case set_random: - if (is_new) - def = (rand() % cnt) + 1; - case set_default: - case set_yes: - case set_mod: - case set_no: - cnt = def; - printf("%d\n", cnt); + default: break; } @@ -507,11 +441,11 @@ int main(int ac, char **av) while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { switch (opt) { case 'o': - input_mode = ask_new; + input_mode = ask_silent; break; case 's': input_mode = ask_silent; - valid_stdin = isatty(0) && isatty(1) && isatty(2); + sync_kconfig = 1; break; case 'd': input_mode = set_default; @@ -549,6 +483,19 @@ int main(int ac, char **av) name = av[optind]; conf_parse(name); //zconfdump(stdout); + if (sync_kconfig) { + if (stat(".config", &tmpstat)) { + fprintf(stderr, _("***\n" + "*** You have not yet configured!\n" + "*** (missing .config file)\n" + "***\n" + "*** Please run some configurator (e.g. \"make oldconfig\" or\n" + "*** \"make menuconfig\" or \"make xconfig\").\n" + "***\n")); + exit(1); + } + } + switch (input_mode) { case set_default: if (!defconfig_file) @@ -561,16 +508,6 @@ int main(int ac, char **av) } break; case ask_silent: - if (stat(".config", &tmpstat)) { - printf(_("***\n" - "*** You have not yet configured!\n" - "*** (missing .config file)\n" - "***\n" - "*** Please run some configurator (e.g. \"make oldconfig\" or\n" - "*** \"make menuconfig\" or \"make xconfig\").\n" - "***\n")); - exit(1); - } case ask_all: case ask_new: conf_read(NULL); @@ -600,35 +537,66 @@ int main(int ac, char **av) break; } - if (input_mode != ask_silent) { + if (sync_kconfig) { + if (conf_get_changed()) { + name = getenv("KCONFIG_NOSILENTUPDATE"); + if (name && *name) { + fprintf(stderr, + _("\n*** configuration requires explicit update.\n\n")); + return 1; + } + } + valid_stdin = isatty(0) && isatty(1) && isatty(2); + } + + switch (input_mode) { + case set_no: + conf_set_all_new_symbols(def_no); + break; + case set_yes: + conf_set_all_new_symbols(def_yes); + break; + case set_mod: + conf_set_all_new_symbols(def_mod); + break; + case set_random: + conf_set_all_new_symbols(def_random); + break; + case set_default: + conf_set_all_new_symbols(def_default); + break; + case ask_new: + case ask_all: rootEntry = &rootmenu; conf(&rootmenu); - if (input_mode == ask_all) { - input_mode = ask_silent; - valid_stdin = 1; + input_mode = ask_silent; + /* fall through */ + case ask_silent: + /* Update until a loop caused no more changes */ + do { + conf_cnt = 0; + check_conf(&rootmenu); + } while (conf_cnt); + break; + } + + if (sync_kconfig) { + /* silentoldconfig is used during the build so we shall update autoconf. + * All other commands are only used to generate a config. + */ + if (conf_get_changed() && conf_write(NULL)) { + fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); + exit(1); } - } else if (conf_get_changed()) { - name = getenv("KCONFIG_NOSILENTUPDATE"); - if (name && *name) { - fprintf(stderr, _("\n*** configuration requires explicit update.\n\n")); + if (conf_write_autoconf()) { + fprintf(stderr, _("\n*** Error during update of the configuration.\n\n")); return 1; } - } else - goto skip_check; - - do { - conf_cnt = 0; - check_conf(&rootmenu); - } while (conf_cnt); - if (conf_write(NULL)) { - fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); - return 1; - } -skip_check: - if (/*input_mode == ask_silent &&*/ conf_write_autoconf()) { - fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); - return 1; + } else { + if (conf_write(NULL)) { + fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); + exit(1); + } } - return 0; } diff --git a/extra/config/confdata.c b/extra/config/confdata.c index 59a2fec78..9da48ebdc 100644 --- a/extra/config/confdata.c +++ b/extra/config/confdata.c @@ -212,7 +212,7 @@ load: sym = NULL; switch (line[0]) { case '#': - if (line[1]!=' ') + if (line[1] != ' ') continue; p = strchr(line + 2, ' '); if (!p) @@ -223,7 +223,7 @@ load: if (def == S_DEF_USER) { sym = sym_find(line + 2); if (!sym) { - conf_warning("trying to assign nonexistent symbol %s", line + 2); + sym_add_change_count(1); break; } } else { @@ -244,10 +244,12 @@ load: ; } break; - case 'A' ... 'Z': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': p = strchr(line, '='); - if (!p) + if (!p) { + conf_warning("unexpected data '%s'", line); continue; + } *p++ = 0; p2 = strchr(p, '\n'); if (p2) { @@ -258,7 +260,7 @@ load: if (def == S_DEF_USER) { sym = sym_find(line); if (!sym) { - conf_warning("trying to assign nonexistent symbol %s", line); + sym_add_change_count(1); break; } } else { @@ -441,8 +443,10 @@ int conf_write(const char *name) fprintf(out, _("#\n" "# Automatically generated make config: don't edit\n" + "# Version: %s\n" "%s%s" "#\n"), + sym_get_string_value(sym), use_timestamp ? "# " : "", use_timestamp ? ctime(&now) : ""); @@ -669,8 +673,6 @@ int conf_write_autoconf(void) time_t now; int i, l; - return 0; - sym_clear_all_valid(); file_write_dep("include/config/auto.conf.cmd"); @@ -693,14 +695,17 @@ int conf_write_autoconf(void) time(&now); fprintf(out, "#\n" "# Automatically generated make config: don't edit\n" + "# Version: %s\n" "# %s" "#\n", - ctime(&now)); + sym_get_string_value(sym), ctime(&now)); fprintf(out_h, "/*\n" " * Automatically generated C config: don't edit\n" + " * Version: %s\n" " * %s" - " */\n", - ctime(&now)); + " */\n" + "#define AUTOCONF_INCLUDED\n", + sym_get_string_value(sym), ctime(&now)); for_all_symbols(i, sym) { sym_calc_value(sym); @@ -713,8 +718,8 @@ int conf_write_autoconf(void) case no: break; case mod: - fprintf(out, "%s=m\n", sym->name); - fprintf(out_h, "#define %s_MODULE 1\n", sym->name); + fprintf(out, "CONFIG_%s=m\n", sym->name); + fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); break; case yes: fprintf(out, "%s=y\n", sym->name); @@ -763,7 +768,7 @@ int conf_write_autoconf(void) name = getenv("KCONFIG_AUTOHEADER"); if (!name) - name = "include/linux/autoconf.h"; + name = "include/config/autoconf.h"; if (rename(".tmpconfig.h", name)) return 1; name = getenv("KCONFIG_AUTOCONFIG"); @@ -805,3 +810,73 @@ void conf_set_changed_callback(void (*fn)(void)) { conf_changed_callback = fn; } + + +void conf_set_all_new_symbols(enum conf_def_mode mode) +{ + struct symbol *sym, *csym; + struct property *prop; + struct expr *e; + int i, cnt, def; + + for_all_symbols(i, sym) { + if (sym_has_value(sym)) + continue; + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + switch (mode) { + case def_yes: + sym->def[S_DEF_USER].tri = yes; + break; + case def_mod: + sym->def[S_DEF_USER].tri = mod; + break; + case def_no: + sym->def[S_DEF_USER].tri = no; + break; + case def_random: + sym->def[S_DEF_USER].tri = (tristate)(rand() % 3); + break; + default: + continue; + } + if (!sym_is_choice(sym) || mode != def_random) + sym->flags |= SYMBOL_DEF_USER; + break; + default: + break; + } + + } + + if (modules_sym) + sym_calc_value(modules_sym); + + if (mode != def_random) + return; + + for_all_symbols(i, csym) { + if (sym_has_value(csym) || !sym_is_choice(csym)) + continue; + + sym_calc_value(csym); + prop = sym_get_choice_prop(csym); + def = -1; + while (1) { + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) { + if (sym->visible == no) + continue; + if (def == cnt++) { + csym->def[S_DEF_USER].val = sym; + break; + } + } + if (def >= 0 || cnt < 2) + break; + def = (rand() % cnt) + 1; + } + csym->flags |= SYMBOL_DEF_USER; + } +} diff --git a/extra/config/expr.h b/extra/config/expr.h index 9d60dd330..9d4cba1c0 100644 --- a/extra/config/expr.h +++ b/extra/config/expr.h @@ -184,12 +184,12 @@ void expr_fprint(struct expr *e, FILE *out); struct gstr; /* forward */ void expr_gstr_print(struct expr *e, struct gstr *gs); -static __inline__ int expr_is_yes(struct expr *e) +static inline int expr_is_yes(struct expr *e) { return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); } -static __inline__ int expr_is_no(struct expr *e) +static inline int expr_is_no(struct expr *e) { return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); } diff --git a/extra/config/kconfig-language.txt b/extra/config/kconfig-language.txt index 649cb8799..c412c2458 100644 --- a/extra/config/kconfig-language.txt +++ b/extra/config/kconfig-language.txt @@ -104,14 +104,15 @@ applicable everywhere (see syntax). Reverse dependencies can only be used with boolean or tristate symbols. Note: - select is evil.... select will by brute force set a symbol - equal to 'y' without visiting the dependencies. So abusing - select you are able to select a symbol FOO even if FOO depends - on BAR that is not set. In general use select only for - non-visible symbols (no prompts anywhere) and for symbols with - no dependencies. That will limit the usefulness but on the - other hand avoid the illegal configurations all over. kconfig - should one day warn about such things. + select should be used with care. select will force + a symbol to a value without visiting the dependencies. + By abusing select you are able to select a symbol FOO even + if FOO depends on BAR that is not set. + In general use select only for non-visible symbols + (no prompts anywhere) and for symbols with no dependencies. + That will limit the usefulness but on the other hand avoid + the illegal configurations all over. + kconfig should one day warn about such things. - numerical ranges: "range" <symbol> <symbol> ["if" <expr>] This allows to limit the range of possible input values for int @@ -376,27 +377,3 @@ config FOO limits FOO to module (=m) or disabled (=n). - -Build limited by a third config symbol which may be =y or =m -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -A common idiom that we see (and sometimes have problems with) is this: - -When option C in B (module or subsystem) uses interfaces from A (module -or subsystem), and both A and B are tristate (could be =y or =m if they -were independent of each other, but they aren't), then we need to limit -C such that it cannot be built statically if A is built as a loadable -module. (C already depends on B, so there is no dependency issue to -take care of here.) - -If A is linked statically into the kernel image, C can be built -statically or as loadable module(s). However, if A is built as loadable -module(s), then C must be restricted to loadable module(s) also. This -can be expressed in kconfig language as: - -config C - depends on A = y || A = B - -or for real examples, use this command in a kernel tree: - -$ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig - diff --git a/extra/config/kconfig-to-uclibc.patch.gz b/extra/config/kconfig-to-uclibc.patch.gz Binary files differindex df28093ba..58c41730e 100644 --- a/extra/config/kconfig-to-uclibc.patch.gz +++ b/extra/config/kconfig-to-uclibc.patch.gz diff --git a/extra/config/lex.zconf.c_shipped b/extra/config/lex.zconf.c_shipped index 6a1ea6f9e..09a1ec8e3 100644 --- a/extra/config/lex.zconf.c_shipped +++ b/extra/config/lex.zconf.c_shipped @@ -27,7 +27,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 33 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -49,7 +49,7 @@ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ -#if __STDC_VERSION__ >= 199901L +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. @@ -72,7 +72,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -103,6 +102,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -112,11 +113,12 @@ typedef unsigned int flex_uint32_t; #else /* ! __cplusplus */ -#if __STDC__ +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) #define YY_USE_CONST -#endif /* __STDC__ */ +#endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST @@ -196,14 +198,9 @@ extern FILE *zconfin, *zconfout; #define unput(c) yyunput( c, (yytext_ptr) ) -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T -typedef unsigned int yy_size_t; +typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -767,6 +764,7 @@ int zconf_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *zconftext; +#define YY_NO_INPUT 1 /* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> @@ -853,6 +851,35 @@ void alloc_string(const char *str, int size) static int yy_init_globals (void ); +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int zconflex_destroy (void ); + +int zconfget_debug (void ); + +void zconfset_debug (int debug_flag ); + +YY_EXTRA_TYPE zconfget_extra (void ); + +void zconfset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *zconfget_in (void ); + +void zconfset_in (FILE * in_str ); + +FILE *zconfget_out (void ); + +void zconfset_out (FILE * out_str ); + +int zconfget_leng (void ); + +char *zconfget_text (void ); + +int zconfget_lineno (void ); + +void zconfset_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -895,7 +922,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout ) +#define ECHO fwrite( zconftext, zconfleng, 1, zconfout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1535,7 +1562,7 @@ static int yy_get_next_buffer (void) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); + (yy_n_chars), (size_t) num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } @@ -1559,6 +1586,14 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) zconfrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; @@ -1945,7 +1980,9 @@ static void zconfensure_buffer_stack (void) (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); - + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" ); + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; @@ -1963,6 +2000,8 @@ static void zconfensure_buffer_stack (void) ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -2007,7 +2046,7 @@ YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) /** Setup the input buffer state to scan a string. The next call to zconflex() will * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan + * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use diff --git a/extra/config/lkc.h b/extra/config/lkc.h index c55c2fbd7..4a9af6f78 100644 --- a/extra/config/lkc.h +++ b/extra/config/lkc.h @@ -11,9 +11,9 @@ #ifndef KBUILD_NO_NLS # include <libintl.h> #else -# define gettext(Msgid) ((const char *) (Msgid)) -# define textdomain(Domainname) ((const char *) (Domainname)) -# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) +static inline const char *gettext(const char *txt) { return txt; } +static inline void textdomain(const char *domainname) {} +static inline void bindtextdomain(const char *name, const char *dir) {} #endif #ifdef __cplusplus @@ -42,6 +42,14 @@ extern "C" { #define TF_PARAM 0x0002 #define TF_OPTION 0x0004 +enum conf_def_mode { + def_default, + def_yes, + def_mod, + def_no, + def_random +}; + #define T_OPT_MODULES 1 #define T_OPT_DEFCONFIG_LIST 2 #define T_OPT_ENV 3 @@ -69,6 +77,7 @@ const char *conf_get_configname(void); char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); +void conf_set_all_new_symbols(enum conf_def_mode mode); /* kconfig_load.c */ void kconfig_load(void); @@ -116,38 +125,38 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym); struct symbol *prop_get_symbol(struct property *prop); struct property *sym_get_env_prop(struct symbol *sym); -static __inline__ tristate sym_get_tristate_value(struct symbol *sym) +static inline tristate sym_get_tristate_value(struct symbol *sym) { return sym->curr.tri; } -static __inline__ struct symbol *sym_get_choice_value(struct symbol *sym) +static inline struct symbol *sym_get_choice_value(struct symbol *sym) { return (struct symbol *)sym->curr.val; } -static __inline__ bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) +static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) { return sym_set_tristate_value(chval, yes); } -static __inline__ bool sym_is_choice(struct symbol *sym) +static inline bool sym_is_choice(struct symbol *sym) { return sym->flags & SYMBOL_CHOICE ? true : false; } -static __inline__ bool sym_is_choice_value(struct symbol *sym) +static inline bool sym_is_choice_value(struct symbol *sym) { return sym->flags & SYMBOL_CHOICEVAL ? true : false; } -static __inline__ bool sym_is_optional(struct symbol *sym) +static inline bool sym_is_optional(struct symbol *sym) { return sym->flags & SYMBOL_OPTIONAL ? true : false; } -static __inline__ bool sym_has_value(struct symbol *sym) +static inline bool sym_has_value(struct symbol *sym) { return sym->flags & SYMBOL_DEF_USER ? true : false; } diff --git a/extra/config/lkc_proto.h b/extra/config/lkc_proto.h index 4d09f6dde..8e6946131 100644 --- a/extra/config/lkc_proto.h +++ b/extra/config/lkc_proto.h @@ -21,7 +21,7 @@ P(menu_get_help,const char *,(struct menu *menu)); /* symbol.c */ P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); -P(sym_lookup,struct symbol *,(const char *name, int isconst)); +P(sym_lookup,struct symbol *,(const char *name, int flags)); P(sym_find,struct symbol *,(const char *name)); P(sym_re_search,struct symbol **,(const char *pattern)); P(sym_type_name,const char *,(enum symbol_type type)); diff --git a/extra/config/lxdialog/check-lxdialog.sh b/extra/config/lxdialog/check-lxdialog.sh index 62e1e0212..5552154cb 100755 --- a/extra/config/lxdialog/check-lxdialog.sh +++ b/extra/config/lxdialog/check-lxdialog.sh @@ -36,8 +36,10 @@ trap "rm -f $tmp" 0 1 2 3 15 # Check if we can link to ncurses check() { - echo -e " #include CURSES_LOC \n main() {}" | - $cc -xc - -o $tmp 2> /dev/null + $cc -xc - -o $tmp 2>/dev/null <<'EOF' +#include CURSES_LOC +main() {} +EOF if [ $? != 0 ]; then echo " *** Unable to find the ncurses libraries or the" 1>&2 echo " *** required header files." 1>&2 diff --git a/extra/config/lxdialog/inputbox.c b/extra/config/lxdialog/inputbox.c index 4946bd02b..616c60138 100644 --- a/extra/config/lxdialog/inputbox.c +++ b/extra/config/lxdialog/inputbox.c @@ -89,7 +89,7 @@ do_resize: box_y = y + 2; box_x = (width - box_width) / 2; draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, - dlg.border.atr, dlg.dialog.atr); + dlg.dialog.atr, dlg.border.atr); print_buttons(dialog, height, width, 0); diff --git a/extra/config/mconf.c b/extra/config/mconf.c index 3effa5b5b..18583bd43 100644 --- a/extra/config/mconf.c +++ b/extra/config/mconf.c @@ -704,9 +704,12 @@ static void show_help(struct menu *menu) { if (sym->name) { str_printf(&help, "%s:\n\n", sym->name); - str_append(&help, _(menu_get_help(menu))); - str_append(&help, "\n"); } + str_append(&help, _(menu_get_help(menu))); + str_append(&help, "\n"); + } else if (menu_has_help(sym->prop->menu->parent)) { + str_append(&help, _(menu_get_help(sym->prop->menu->parent))); + str_append(&help, "\n"); } else { str_append(&help, nohelp_text); } @@ -772,7 +775,7 @@ static void conf_string(struct menu *menu) while (1) { int res; - char *heading; + const char *heading; switch (sym_get_type(menu->sym)) { case S_INT: @@ -924,3 +927,4 @@ int main(int ac, char **av) return conf_write_autoconf(); } + diff --git a/extra/config/menu.c b/extra/config/menu.c index 606ceb9e7..07ff8d105 100644 --- a/extra/config/menu.c +++ b/extra/config/menu.c @@ -235,18 +235,22 @@ void menu_finalize(struct menu *parent) sym = parent->sym; if (parent->list) { if (sym && sym_is_choice(sym)) { - /* find the first choice value and find out choice type */ - for (menu = parent->list; menu; menu = menu->next) { - if (menu->sym) { - current_entry = parent; - if (sym->type == S_UNKNOWN) + if (sym->type == S_UNKNOWN) { + /* find the first choice value to find out choice type */ + current_entry = parent; + for (menu = parent->list; menu; menu = menu->next) { + if (menu->sym && menu->sym->type != S_UNKNOWN) { menu_set_type(menu->sym->type); - current_entry = menu; - if (menu->sym->type == S_UNKNOWN) - menu_set_type(sym->type); - break; + break; + } } } + /* set the type of the remaining choice values */ + for (menu = parent->list; menu; menu = menu->next) { + current_entry = menu; + if (menu->sym && menu->sym->type == S_UNKNOWN) + menu_set_type(sym->type); + } parentdep = expr_alloc_symbol(sym); } else if (parent->prompt) parentdep = parent->prompt->visible.expr; @@ -313,50 +317,36 @@ void menu_finalize(struct menu *parent) } } for (menu = parent->list; menu; menu = menu->next) { - if (sym && sym_is_choice(sym) && menu->sym) { + if (sym && sym_is_choice(sym) && + menu->sym && !sym_is_choice_value(menu->sym)) { + current_entry = menu; menu->sym->flags |= SYMBOL_CHOICEVAL; if (!menu->prompt) menu_warn(menu, "choice value must have a prompt"); for (prop = menu->sym->prop; prop; prop = prop->next) { - if (prop->type == P_PROMPT && prop->menu != menu) { - prop_warn(prop, "choice values " - "currently only support a " - "single prompt"); - } if (prop->type == P_DEFAULT) prop_warn(prop, "defaults for choice " - "values not supported"); + "values not supported"); + if (prop->menu == menu) + continue; + if (prop->type == P_PROMPT && + prop->menu->parent->sym != sym) + prop_warn(prop, "choice value used outside its choice group"); } - current_entry = menu; - if (menu->sym->type == S_UNKNOWN) - menu_set_type(sym->type); /* Non-tristate choice values of tristate choices must * depend on the choice being set to Y. The choice * values' dependencies were propagated to their * properties above, so the change here must be re- - * propagated. */ + * propagated. + */ if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) { basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes); - basedep = expr_alloc_and(basedep, menu->dep); - basedep = expr_eliminate_dups(basedep); - menu->dep = basedep; + menu->dep = expr_alloc_and(basedep, menu->dep); for (prop = menu->sym->prop; prop; prop = prop->next) { if (prop->menu != menu) continue; - dep = expr_alloc_and(expr_copy(basedep), - prop->visible.expr); - dep = expr_eliminate_dups(dep); - dep = expr_trans_bool(dep); - prop->visible.expr = dep; - if (prop->type == P_SELECT) { - struct symbol *es = prop_get_symbol(prop); - dep2 = expr_alloc_symbol(menu->sym); - dep = expr_alloc_and(dep2, - expr_copy(dep)); - dep = expr_alloc_or(es->rev_dep.expr, dep); - dep = expr_eliminate_dups(dep); - es->rev_dep.expr = dep; - } + prop->visible.expr = expr_alloc_and(expr_copy(basedep), + prop->visible.expr); } } menu_add_symbol(P_CHOICE, sym, NULL); diff --git a/extra/config/symbol.c b/extra/config/symbol.c index f8cd319f8..b27047c32 100644 --- a/extra/config/symbol.c +++ b/extra/config/symbol.c @@ -39,7 +39,7 @@ void sym_add_default(struct symbol *sym, const char *def) { struct property *prop = prop_alloc(P_DEFAULT, sym); - prop->expr = expr_alloc_symbol(sym_lookup(def, 1)); + prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST)); } void sym_init(void) @@ -350,9 +350,6 @@ void sym_calc_value(struct symbol *sym) ; } - if (sym->flags & SYMBOL_AUTO) - sym->flags &= ~SYMBOL_WRITE; - sym->curr = newval; if (sym_is_choice(sym) && newval.tri == yes) sym->curr.val = sym_calc_choice(sym); @@ -377,6 +374,9 @@ void sym_calc_value(struct symbol *sym) sym_set_changed(choice_sym); } } + + if (sym->flags & SYMBOL_AUTO) + sym->flags &= ~SYMBOL_WRITE; } void sym_clear_all_valid(void) @@ -651,7 +651,7 @@ bool sym_is_changable(struct symbol *sym) return sym->visible > sym->rev_dep.tri; } -struct symbol *sym_lookup(const char *name, int isconst) +struct symbol *sym_lookup(const char *name, int flags) { struct symbol *symbol; const char *ptr; @@ -671,11 +671,10 @@ struct symbol *sym_lookup(const char *name, int isconst) hash &= 0xff; for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { - if (!strcmp(symbol->name, name)) { - if ((isconst && symbol->flags & SYMBOL_CONST) || - (!isconst && !(symbol->flags & SYMBOL_CONST))) - return symbol; - } + if (!strcmp(symbol->name, name) && + (flags ? symbol->flags & flags + : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE)))) + return symbol; } new_name = strdup(name); } else { @@ -687,8 +686,7 @@ struct symbol *sym_lookup(const char *name, int isconst) memset(symbol, 0, sizeof(*symbol)); symbol->name = new_name; symbol->type = S_UNKNOWN; - if (isconst) - symbol->flags |= SYMBOL_CONST; + symbol->flags |= flags; symbol->next = symbol_hash[hash]; symbol_hash[hash] = symbol; @@ -762,8 +760,6 @@ struct symbol **sym_re_search(const char *pattern) } -struct symbol *sym_check_deps(struct symbol *sym); - static struct symbol *sym_check_expr_deps(struct expr *e) { struct symbol *sym; @@ -795,40 +791,100 @@ static struct symbol *sym_check_expr_deps(struct expr *e) } /* return NULL when dependencies are OK */ -struct symbol *sym_check_deps(struct symbol *sym) +static struct symbol *sym_check_sym_deps(struct symbol *sym) { struct symbol *sym2; struct property *prop; - if (sym->flags & SYMBOL_CHECK) { - fprintf(stderr, "%s:%d:error: found recursive dependency: %s", - sym->prop->file->name, sym->prop->lineno, sym->name); - return sym; - } - if (sym->flags & SYMBOL_CHECKED) - return NULL; - - sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); sym2 = sym_check_expr_deps(sym->rev_dep.expr); if (sym2) - goto out; + return sym2; for (prop = sym->prop; prop; prop = prop->next) { if (prop->type == P_CHOICE || prop->type == P_SELECT) continue; sym2 = sym_check_expr_deps(prop->visible.expr); if (sym2) - goto out; + break; if (prop->type != P_DEFAULT || sym_is_choice(sym)) continue; sym2 = sym_check_expr_deps(prop->expr); if (sym2) - goto out; + break; } -out: + + return sym2; +} + +static struct symbol *sym_check_choice_deps(struct symbol *choice) +{ + struct symbol *sym, *sym2; + struct property *prop; + struct expr *e; + + prop = sym_get_choice_prop(choice); + expr_list_for_each_sym(prop->expr, e, sym) + sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + + choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + sym2 = sym_check_sym_deps(choice); + choice->flags &= ~SYMBOL_CHECK; if (sym2) - fprintf(stderr, " -> %s%s", sym->name, sym2 == sym? "\n": ""); - sym->flags &= ~SYMBOL_CHECK; + goto out; + + expr_list_for_each_sym(prop->expr, e, sym) { + sym2 = sym_check_sym_deps(sym); + if (sym2) { + fprintf(stderr, " -> %s", sym->name); + break; + } + } +out: + expr_list_for_each_sym(prop->expr, e, sym) + sym->flags &= ~SYMBOL_CHECK; + + if (sym2 && sym_is_choice_value(sym2) && + prop_get_symbol(sym_get_choice_prop(sym2)) == choice) + sym2 = choice; + + return sym2; +} + +struct symbol *sym_check_deps(struct symbol *sym) +{ + struct symbol *sym2; + struct property *prop; + + if (sym->flags & SYMBOL_CHECK) { + fprintf(stderr, "%s:%d:error: found recursive dependency: %s", + sym->prop->file->name, sym->prop->lineno, + sym->name ? sym->name : "<choice>"); + return sym; + } + if (sym->flags & SYMBOL_CHECKED) + return NULL; + + if (sym_is_choice_value(sym)) { + /* for choice groups start the check with main choice symbol */ + prop = sym_get_choice_prop(sym); + sym2 = sym_check_deps(prop_get_symbol(prop)); + } else if (sym_is_choice(sym)) { + sym2 = sym_check_choice_deps(sym); + } else { + sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + sym2 = sym_check_sym_deps(sym); + sym->flags &= ~SYMBOL_CHECK; + } + + if (sym2) { + fprintf(stderr, " -> %s", sym->name ? sym->name : "<choice>"); + if (sym2 == sym) { + fprintf(stderr, "\n"); + zconfnerrs++; + sym2 = NULL; + } + } + return sym2; } @@ -904,7 +960,7 @@ void prop_add_env(const char *env) } prop = prop_alloc(P_ENV, sym); - prop->expr = expr_alloc_symbol(sym_lookup(env, 1)); + prop->expr = expr_alloc_symbol(sym_lookup(env, SYMBOL_CONST)); sym_env_list = expr_alloc_one(E_LIST, sym_env_list); sym_env_list->right.sym = sym; diff --git a/extra/config/util.c b/extra/config/util.c index f8e73c039..3cc9f9369 100644 --- a/extra/config/util.c +++ b/extra/config/util.c @@ -77,7 +77,7 @@ struct gstr str_new(void) { struct gstr gs; gs.s = malloc(sizeof(char) * 64); - gs.len = 16; + gs.len = 64; strcpy(gs.s, "\0"); return gs; } diff --git a/extra/config/zconf.l b/extra/config/zconf.l index 4cea5c85c..5164ef7ce 100644 --- a/extra/config/zconf.l +++ b/extra/config/zconf.l @@ -1,5 +1,6 @@ %option backup nostdinit noyywrap never-interactive full ecs %option 8bit backup nodefault perf-report perf-report +%option noinput %x COMMAND HELP STRING PARAM %{ /* diff --git a/extra/config/zconf.tab.c_shipped b/extra/config/zconf.tab.c_shipped index eb4982948..08223ec4c 100644 --- a/extra/config/zconf.tab.c_shipped +++ b/extra/config/zconf.tab.c_shipped @@ -446,16 +446,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 258 +#define YYLAST 259 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 35 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 45 +#define YYNNTS 46 /* YYNRULES -- Number of rules. */ -#define YYNRULES 108 +#define YYNRULES 110 /* YYNRULES -- Number of states. */ -#define YYNSTATES 178 +#define YYNSTATES 180 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -507,13 +507,14 @@ static const yytype_uint16 yyprhs[] = 28, 33, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 67, 70, 74, 77, 81, 84, 85, 88, 91, 94, 97, 100, 103, 107, - 112, 117, 122, 128, 132, 133, 137, 138, 141, 144, - 147, 149, 153, 154, 157, 160, 163, 166, 169, 174, - 178, 181, 186, 187, 190, 194, 196, 200, 201, 204, - 207, 210, 214, 217, 219, 223, 224, 227, 230, 233, - 237, 241, 244, 247, 250, 251, 254, 257, 260, 265, - 266, 269, 271, 273, 276, 279, 282, 284, 287, 288, - 291, 293, 297, 301, 305, 308, 312, 316, 318 + 112, 117, 122, 128, 132, 133, 137, 138, 141, 145, + 148, 150, 154, 155, 158, 161, 164, 167, 170, 175, + 179, 182, 187, 188, 191, 195, 197, 201, 202, 205, + 208, 211, 215, 218, 220, 224, 225, 228, 231, 234, + 238, 242, 245, 248, 251, 252, 255, 258, 261, 266, + 267, 270, 272, 274, 277, 280, 283, 285, 288, 289, + 292, 294, 298, 302, 306, 309, 313, 317, 319, 321, + 322 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -533,24 +534,25 @@ static const yytype_int8 yyrhs[] = 30, -1, 20, 78, 77, 30, -1, 21, 25, 77, 30, -1, 22, 79, 79, 77, 30, -1, 23, 48, 30, -1, -1, 48, 25, 49, -1, -1, 33, 74, - -1, 7, 30, -1, 50, 54, -1, 75, -1, 51, - 56, 52, -1, -1, 54, 55, -1, 54, 72, -1, - 54, 70, -1, 54, 30, -1, 54, 40, -1, 18, - 74, 77, 30, -1, 19, 73, 30, -1, 17, 30, - -1, 20, 25, 77, 30, -1, -1, 56, 39, -1, - 14, 78, 76, -1, 75, -1, 57, 60, 58, -1, - -1, 60, 39, -1, 60, 64, -1, 60, 53, -1, - 4, 74, 30, -1, 61, 71, -1, 75, -1, 62, - 65, 63, -1, -1, 65, 39, -1, 65, 64, -1, - 65, 53, -1, 6, 74, 30, -1, 9, 74, 30, - -1, 67, 71, -1, 12, 30, -1, 69, 13, -1, - -1, 71, 72, -1, 71, 30, -1, 71, 40, -1, - 16, 24, 78, 30, -1, -1, 74, 77, -1, 25, - -1, 26, -1, 5, 30, -1, 8, 30, -1, 15, - 30, -1, 30, -1, 76, 30, -1, -1, 14, 78, - -1, 79, -1, 79, 33, 79, -1, 79, 27, 79, - -1, 29, 78, 28, -1, 34, 78, -1, 78, 31, - 78, -1, 78, 32, 78, -1, 25, -1, 26, -1 + -1, 7, 80, 30, -1, 50, 54, -1, 75, -1, + 51, 56, 52, -1, -1, 54, 55, -1, 54, 72, + -1, 54, 70, -1, 54, 30, -1, 54, 40, -1, + 18, 74, 77, 30, -1, 19, 73, 30, -1, 17, + 30, -1, 20, 25, 77, 30, -1, -1, 56, 39, + -1, 14, 78, 76, -1, 75, -1, 57, 60, 58, + -1, -1, 60, 39, -1, 60, 64, -1, 60, 53, + -1, 4, 74, 30, -1, 61, 71, -1, 75, -1, + 62, 65, 63, -1, -1, 65, 39, -1, 65, 64, + -1, 65, 53, -1, 6, 74, 30, -1, 9, 74, + 30, -1, 67, 71, -1, 12, 30, -1, 69, 13, + -1, -1, 71, 72, -1, 71, 30, -1, 71, 40, + -1, 16, 24, 78, 30, -1, -1, 74, 77, -1, + 25, -1, 26, -1, 5, 30, -1, 8, 30, -1, + 15, 30, -1, 30, -1, 76, 30, -1, -1, 14, + 78, -1, 79, -1, 79, 33, 79, -1, 79, 27, + 79, -1, 29, 78, 28, -1, 34, 78, -1, 78, + 31, 78, -1, 78, 32, 78, -1, 25, -1, 26, + -1, -1, 25, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -566,7 +568,8 @@ static const yytype_uint16 yyrline[] = 339, 344, 351, 356, 364, 367, 369, 370, 371, 374, 382, 389, 396, 402, 409, 411, 412, 413, 416, 424, 426, 431, 432, 435, 436, 437, 441, 442, 445, 446, - 449, 450, 451, 452, 453, 454, 455, 458, 459 + 449, 450, 451, 452, 453, 454, 455, 458, 459, 462, + 463 }; #endif @@ -590,7 +593,8 @@ static const char *const yytname[] = "if_entry", "if_end", "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt", "comment", "comment_stmt", "help_start", "help", "depends_list", "depends", - "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr", "symbol", 0 + "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr", "symbol", + "word_opt", 0 }; #endif @@ -619,7 +623,8 @@ static const yytype_uint8 yyr1[] = 60, 61, 62, 63, 64, 65, 65, 65, 65, 66, 67, 68, 69, 70, 71, 71, 71, 71, 72, 73, 73, 74, 74, 75, 75, 75, 76, 76, 77, 77, - 78, 78, 78, 78, 78, 78, 78, 79, 79 + 78, 78, 78, 78, 78, 78, 78, 79, 79, 80, + 80 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -629,13 +634,14 @@ static const yytype_uint8 yyr2[] = 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 3, 2, 3, 2, 0, 2, 2, 2, 2, 2, 2, 3, 4, - 4, 4, 5, 3, 0, 3, 0, 2, 2, 2, + 4, 4, 5, 3, 0, 3, 0, 2, 3, 2, 1, 3, 0, 2, 2, 2, 2, 2, 4, 3, 2, 4, 0, 2, 3, 1, 3, 0, 2, 2, 2, 3, 2, 1, 3, 0, 2, 2, 2, 3, 3, 2, 2, 2, 0, 2, 2, 2, 4, 0, 2, 1, 1, 2, 2, 2, 1, 2, 0, 2, - 1, 3, 3, 3, 2, 3, 3, 1, 1 + 1, 3, 3, 3, 2, 3, 3, 1, 1, 0, + 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -643,69 +649,69 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 3, 0, 0, 1, 0, 0, 0, 0, 0, 109, 0, 0, 0, 0, 0, 0, 12, 16, 13, 14, 18, 15, 17, 0, 19, 0, 4, 31, 22, 31, 23, 52, 62, 5, 67, 20, 84, 75, 6, 24, 84, 21, 8, 11, 91, 92, 0, 0, 93, 0, - 48, 94, 0, 0, 0, 107, 108, 0, 0, 0, - 100, 95, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 96, 7, 71, 79, 80, 27, 29, 0, - 104, 0, 0, 64, 0, 0, 9, 10, 0, 0, - 0, 0, 89, 0, 0, 0, 44, 0, 37, 36, - 32, 33, 0, 35, 34, 0, 0, 89, 0, 56, - 57, 53, 55, 54, 63, 51, 50, 68, 70, 66, - 69, 65, 86, 87, 85, 76, 78, 74, 77, 73, - 97, 103, 105, 106, 102, 101, 26, 82, 0, 98, - 0, 98, 98, 98, 0, 0, 0, 83, 60, 98, - 0, 98, 0, 0, 0, 38, 90, 0, 0, 98, - 46, 43, 25, 0, 59, 0, 88, 99, 39, 40, - 41, 0, 0, 45, 58, 61, 42, 47 + 110, 0, 94, 0, 0, 0, 107, 108, 0, 0, + 0, 100, 95, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 96, 7, 71, 79, 48, 80, 27, + 29, 0, 104, 0, 0, 64, 0, 0, 9, 10, + 0, 0, 0, 0, 89, 0, 0, 0, 44, 0, + 37, 36, 32, 33, 0, 35, 34, 0, 0, 89, + 0, 56, 57, 53, 55, 54, 63, 51, 50, 68, + 70, 66, 69, 65, 86, 87, 85, 76, 78, 74, + 77, 73, 97, 103, 105, 106, 102, 101, 26, 82, + 0, 98, 0, 98, 98, 98, 0, 0, 0, 83, + 60, 98, 0, 98, 0, 0, 0, 38, 90, 0, + 0, 98, 46, 43, 25, 0, 59, 0, 88, 99, + 39, 40, 41, 0, 0, 45, 58, 61, 42, 47 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 2, 25, 26, 99, 27, 28, 29, 30, - 64, 100, 101, 145, 173, 31, 32, 115, 33, 66, - 111, 67, 34, 119, 35, 68, 36, 37, 127, 38, - 70, 39, 40, 41, 102, 103, 69, 104, 140, 141, - 42, 73, 154, 59, 60 + -1, 1, 2, 25, 26, 101, 27, 28, 29, 30, + 65, 102, 103, 147, 175, 31, 32, 117, 33, 67, + 113, 68, 34, 121, 35, 69, 36, 37, 129, 38, + 71, 39, 40, 41, 104, 105, 70, 106, 142, 143, + 42, 74, 156, 60, 61, 51 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -78 +#define YYPACT_NINF -80 static const yytype_int16 yypact[] = { - -78, 33, 130, -78, -28, 73, 73, 7, 73, 36, - 41, 73, 26, 52, -4, 58, -78, -78, -78, -78, - -78, -78, -78, 90, -78, 94, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, 74, 85, -78, 96, - -78, -78, 131, 134, 147, -78, -78, -4, -4, 193, - -10, -78, 162, 164, 38, 102, 64, 148, 5, 192, - 5, 165, -78, 174, -78, -78, -78, -78, -78, 65, - -78, -4, -4, 174, 103, 103, -78, -78, 175, 185, - 197, 73, 73, -4, 194, 103, -78, 231, -78, -78, - -78, -78, 220, -78, -78, 204, 73, 73, 210, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, 205, -78, -78, -78, -78, -78, -4, 222, - 208, 222, 195, 222, 103, 2, 209, -78, -78, 222, - 211, 222, 199, -4, 212, -78, -78, 213, 214, 222, - 207, -78, -78, 215, -78, 216, -78, 111, -78, -78, - -78, 217, 73, -78, -78, -78, -78, -78 + -80, 2, 132, -80, -13, -1, -1, -2, -1, 9, + 33, -1, 27, 40, -3, 38, -80, -80, -80, -80, + -80, -80, -80, 71, -80, 77, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, 57, 61, -80, 63, + -80, 76, -80, 87, 101, 133, -80, -80, -3, -3, + 195, -6, -80, 136, 149, 39, 104, 65, 150, 5, + 194, 5, 167, -80, 176, -80, -80, -80, -80, -80, + -80, 68, -80, -3, -3, 176, 72, 72, -80, -80, + 177, 187, 78, -1, -1, -3, 196, 72, -80, 222, + -80, -80, -80, -80, 221, -80, -80, 205, -1, -1, + 211, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, 206, -80, -80, -80, -80, -80, + -3, 223, 209, 223, 197, 223, 72, 7, 210, -80, + -80, 223, 212, 223, 201, -3, 213, -80, -80, 214, + 215, 223, 208, -80, -80, 216, -80, 217, -80, 113, + -80, -80, -80, 218, -1, -80, -80, -80, -80, -80 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -78, -78, -78, -78, 121, -35, -78, -78, -78, -78, - 219, -78, -78, -78, -78, -78, -78, -78, -44, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -6, - -78, -78, -78, -78, -78, 183, 218, 21, 143, -5, - 146, 196, 69, -53, -77 + -80, -80, -80, -80, 122, -34, -80, -80, -80, -80, + 220, -80, -80, -80, -80, -80, -80, -80, 59, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, 125, + -80, -80, -80, -80, -80, 183, 219, 22, 142, -5, + 147, 192, 69, -54, -79, -80 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -715,62 +721,62 @@ static const yytype_int16 yypgoto[] = #define YYTABLE_NINF -82 static const yytype_int16 yytable[] = { - 46, 47, 43, 49, 79, 80, 52, 134, 135, 6, - 7, 8, 9, 10, 11, 12, 13, 84, 144, 14, - 15, 55, 56, 85, 118, 57, 126, 160, 132, 133, - 58, 110, 161, 3, 123, 24, 123, 48, -28, 88, - 142, -28, -28, -28, -28, -28, -28, -28, -28, -28, - 89, 53, -28, -28, 90, -28, 91, 92, 93, 94, - 95, 96, 120, 97, 128, 88, 50, 159, 98, -49, - -49, 51, -49, -49, -49, -49, 89, 54, -49, -49, - 90, 105, 106, 107, 108, 152, 139, 113, 61, 97, - 124, 62, 124, 131, 109, 63, 81, 82, 44, 45, - 167, 149, -30, 88, 72, -30, -30, -30, -30, -30, - -30, -30, -30, -30, 89, 74, -30, -30, 90, -30, - 91, 92, 93, 94, 95, 96, 75, 97, 55, 56, - -2, 4, 98, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 81, 82, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 7, 8, 23, 10, 11, 12, 13, - 24, 76, 14, 15, 77, -81, 88, 177, -81, -81, - -81, -81, -81, -81, -81, -81, -81, 78, 24, -81, - -81, 90, -81, -81, -81, -81, -81, -81, 114, 117, - 97, 125, 86, 88, 87, 122, -72, -72, -72, -72, - -72, -72, -72, -72, 130, 136, -72, -72, 90, 153, - 156, 157, 158, 116, 121, 137, 129, 97, 163, 143, - 165, 138, 122, 72, 81, 82, 81, 82, 171, 166, - 81, 82, 146, 147, 148, 151, 153, 82, 155, 162, - 172, 164, 168, 169, 170, 174, 175, 176, 65, 112, - 150, 0, 0, 0, 0, 83, 0, 0, 71 + 46, 47, 3, 49, 81, 82, 53, 136, 137, 6, + 7, 8, 9, 10, 11, 12, 13, 43, 146, 14, + 15, 86, 56, 57, 44, 45, 58, 87, 48, 134, + 135, 59, 162, 112, 50, 24, 125, 163, 125, -28, + 90, 144, -28, -28, -28, -28, -28, -28, -28, -28, + -28, 91, 54, -28, -28, 92, -28, 93, 94, 95, + 96, 97, 98, 52, 99, 55, 90, 161, 62, 100, + -49, -49, 63, -49, -49, -49, -49, 91, 64, -49, + -49, 92, 107, 108, 109, 110, 154, 73, 141, 115, + 99, 75, 126, 76, 126, 111, 133, 56, 57, 83, + 84, 169, 140, 151, -30, 90, 77, -30, -30, -30, + -30, -30, -30, -30, -30, -30, 91, 78, -30, -30, + 92, -30, 93, 94, 95, 96, 97, 98, 120, 99, + 128, 79, -2, 4, 100, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 83, 84, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 7, 8, 23, 10, 11, + 12, 13, 24, 80, 14, 15, 88, -81, 90, 179, + -81, -81, -81, -81, -81, -81, -81, -81, -81, 89, + 24, -81, -81, 92, -81, -81, -81, -81, -81, -81, + 116, 119, 99, 127, 122, 90, 130, 124, -72, -72, + -72, -72, -72, -72, -72, -72, 132, 138, -72, -72, + 92, 155, 158, 159, 160, 118, 123, 139, 131, 99, + 165, 145, 167, 148, 124, 73, 83, 84, 83, 84, + 173, 168, 83, 84, 149, 150, 153, 155, 84, 157, + 164, 174, 166, 170, 171, 172, 176, 177, 178, 66, + 114, 152, 85, 0, 0, 0, 0, 0, 0, 72 }; static const yytype_int16 yycheck[] = { - 5, 6, 30, 8, 57, 58, 11, 84, 85, 4, - 5, 6, 7, 8, 9, 10, 11, 27, 95, 14, - 15, 25, 26, 33, 68, 29, 70, 25, 81, 82, - 34, 66, 30, 0, 69, 30, 71, 30, 0, 1, - 93, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 25, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 68, 25, 70, 1, 30, 144, 30, 5, - 6, 30, 8, 9, 10, 11, 12, 25, 14, 15, - 16, 17, 18, 19, 20, 138, 91, 66, 30, 25, - 69, 1, 71, 28, 30, 1, 31, 32, 25, 26, - 153, 106, 0, 1, 30, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 30, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 30, 25, 25, 26, - 0, 1, 30, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 31, 32, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 5, 6, 25, 8, 9, 10, 11, - 30, 30, 14, 15, 30, 0, 1, 172, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 30, 30, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 67, 68, - 25, 70, 30, 1, 30, 30, 4, 5, 6, 7, - 8, 9, 10, 11, 30, 30, 14, 15, 16, 14, - 141, 142, 143, 67, 68, 30, 70, 25, 149, 25, - 151, 24, 30, 30, 31, 32, 31, 32, 159, 30, - 31, 32, 1, 13, 30, 25, 14, 32, 30, 30, - 33, 30, 30, 30, 30, 30, 30, 30, 29, 66, - 107, -1, -1, -1, -1, 59, -1, -1, 40 + 5, 6, 0, 8, 58, 59, 11, 86, 87, 4, + 5, 6, 7, 8, 9, 10, 11, 30, 97, 14, + 15, 27, 25, 26, 25, 26, 29, 33, 30, 83, + 84, 34, 25, 67, 25, 30, 70, 30, 72, 0, + 1, 95, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 25, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 30, 25, 25, 1, 146, 30, 30, + 5, 6, 1, 8, 9, 10, 11, 12, 1, 14, + 15, 16, 17, 18, 19, 20, 140, 30, 93, 67, + 25, 30, 70, 30, 72, 30, 28, 25, 26, 31, + 32, 155, 24, 108, 0, 1, 30, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 30, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 69, 25, + 71, 30, 0, 1, 30, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 31, 32, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 5, 6, 25, 8, 9, + 10, 11, 30, 30, 14, 15, 30, 0, 1, 174, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 30, + 30, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 68, 69, 25, 71, 69, 1, 71, 30, 4, 5, + 6, 7, 8, 9, 10, 11, 30, 30, 14, 15, + 16, 14, 143, 144, 145, 68, 69, 30, 71, 25, + 151, 25, 153, 1, 30, 30, 31, 32, 31, 32, + 161, 30, 31, 32, 13, 30, 25, 14, 32, 30, + 30, 33, 30, 30, 30, 30, 30, 30, 30, 29, + 67, 109, 60, -1, -1, -1, -1, -1, -1, 40 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -782,19 +788,19 @@ static const yytype_uint8 yystos[] = 20, 21, 22, 25, 30, 38, 39, 41, 42, 43, 44, 50, 51, 53, 57, 59, 61, 62, 64, 66, 67, 68, 75, 30, 25, 26, 74, 74, 30, 74, - 30, 30, 74, 25, 25, 25, 26, 29, 34, 78, - 79, 30, 1, 1, 45, 45, 54, 56, 60, 71, - 65, 71, 30, 76, 30, 30, 30, 30, 30, 78, - 78, 31, 32, 76, 27, 33, 30, 30, 1, 12, - 16, 18, 19, 20, 21, 22, 23, 25, 30, 40, - 46, 47, 69, 70, 72, 17, 18, 19, 20, 30, - 40, 55, 70, 72, 39, 52, 75, 39, 53, 58, - 64, 75, 30, 40, 72, 39, 53, 63, 64, 75, - 30, 28, 78, 78, 79, 79, 30, 30, 24, 74, - 73, 74, 78, 25, 79, 48, 1, 13, 30, 74, - 73, 25, 78, 14, 77, 30, 77, 77, 77, 79, - 25, 30, 30, 77, 30, 77, 30, 78, 30, 30, - 30, 77, 33, 49, 30, 30, 30, 74 + 25, 80, 30, 74, 25, 25, 25, 26, 29, 34, + 78, 79, 30, 1, 1, 45, 45, 54, 56, 60, + 71, 65, 71, 30, 76, 30, 30, 30, 30, 30, + 30, 78, 78, 31, 32, 76, 27, 33, 30, 30, + 1, 12, 16, 18, 19, 20, 21, 22, 23, 25, + 30, 40, 46, 47, 69, 70, 72, 17, 18, 19, + 20, 30, 40, 55, 70, 72, 39, 52, 75, 39, + 53, 58, 64, 75, 30, 40, 72, 39, 53, 63, + 64, 75, 30, 28, 78, 78, 79, 79, 30, 30, + 24, 74, 73, 74, 78, 25, 79, 48, 1, 13, + 30, 74, 73, 25, 78, 14, 77, 30, 77, 77, + 77, 79, 25, 30, 30, 77, 30, 77, 30, 78, + 30, 30, 30, 77, 33, 49, 30, 30, 30, 74 }; #define yyerrok (yyerrstatus = 0) @@ -1276,6 +1282,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar) } #endif /* YYERROR_VERBOSE */ + /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ @@ -1780,8 +1787,8 @@ yyreduce: case 48: { - struct symbol *sym = sym_lookup(NULL, 0); - sym->flags |= SYMBOL_CHOICE; + struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE); + sym->flags |= SYMBOL_AUTO; menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); @@ -2013,7 +2020,12 @@ yyreduce: case 108: - { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 1); free((yyvsp[(1) - (1)].string)); ;} + { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;} + break; + + case 109: + + { (yyval.string) = NULL; ;} break; diff --git a/extra/config/zconf.y b/extra/config/zconf.y index 4c6a8e3a3..029c9b6c3 100644 --- a/extra/config/zconf.y +++ b/extra/config/zconf.y @@ -91,7 +91,7 @@ static struct menu *current_menu, *current_entry; %type <id> end %type <id> option_name %type <menu> if_entry menu_entry choice_entry -%type <string> symbol_option_arg +%type <string> symbol_option_arg word_opt %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -239,10 +239,10 @@ symbol_option_arg: /* choice entry */ -choice: T_CHOICE T_EOL +choice: T_CHOICE word_opt T_EOL { - struct symbol *sym = sym_lookup(NULL, 0); - sym->flags |= SYMBOL_CHOICE; + struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE); + sym->flags |= SYMBOL_AUTO; menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); @@ -456,9 +456,12 @@ expr: symbol { $$ = expr_alloc_symbol($1); } ; symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } - | T_WORD_QUOTE { $$ = sym_lookup($1, 1); free($1); } + | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); } ; +word_opt: /* empty */ { $$ = NULL; } + | T_WORD + %% void conf_parse(const char *name) diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in index 52de0f26e..b4801b04b 100644 --- a/extra/locale/Makefile.in +++ b/extra/locale/Makefile.in @@ -1,55 +1,59 @@ # Makefile for uClibc # -# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org> # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # +locale_DIR := $(top_srcdir)extra/locale +locale_OUT := $(top_builddir)extra/locale + # command used to download source code WGET := wget --passive-ftp -LOCALE_DATA_FILENAME := uClibc-locale-030818.tgz +LOCALE_DATA_FILENAME := uClibc-locale-20081111-$(ARCH_NATIVE_BIT)-$(if $(ARCH_LITTLE_ENDIAN),el,eb).tgz BUILD_CFLAGS-locale-common := \ -D__UCLIBC_GEN_LOCALE \ - -DUCLIBC_CTYPE_HEADER='"$(top_builddir)include/bits/uClibc_ctype.h"' + -I$(top_builddir) \ + -DUCLIBC_CTYPE_HEADER='"include/bits/uClibc_ctype.h"' BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1 - BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common) - BUILD_CFLAGS-gen_ldc := ifeq ($(UCLIBC_HAS_WCHAR),y) BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1 BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1 endif +BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE -I$(locale_OUT) +BUILD_CFLAGS-gen_collate := -D_GNU_SOURCE -BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE - -DEPH-locale := $(top_builddir)include/bits/sysnum.h -DEPH-gen_locale := c8tables.h -DEPH-gen_ldc := c8tables.h wctables.h locale_tables.h locale_collate.h +locale_headers-$(UCLIBC_HAS_LOCALE) := $(top_builddir)include/bits/uClibc_locale_data.h -locale_DIR := $(top_srcdir)extra/locale -locale_OUT := $(top_builddir)extra/locale +#DEPH-locale := $(top_builddir)include/bits/sysnum.h +DEPH-locale := $(top_builddir)include/bits/uClibc_config.h +DEPH-gen_collate := $(DEPH-locale) +DEPH-gen_ldc := $(addprefix $(locale_OUT)/,c8tables.h wctables.h locale_tables.h locale_collate.h) $(DEPH-locale) +DEPH-gen_locale := $(addprefix $(locale_OUT)/,c8tables.h) $(DEPH-locale) +DEPH-gen_wc8bit := $(top_builddir)/include/bits/uClibc_ctype.h $(DEPH-locale) +DEPH-gen_wctype := $(top_builddir)/include/bits/uClibc_ctype.h $(DEPH-locale) -#locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype -locale_HOBJ := gen_collate gen_wc8bit gen_wctype -locale_HOBJ := $(patsubst %,$(locale_OUT)/%,$(locale_HOBJ)) +locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype +locale_HOBJ := $(addprefix $(locale_OUT)/,$(locale_HOBJ)) locale_SRC := $(locale_OUT)/locale_data.c locale_OBJ := $(locale_OUT)/locale_data.o CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR) -# produces a loop -#headers-$(UCLIBC_HAS_LOCALE) += locale_headers +#headers-$(UCLIBC_HAS_LOCALE) += $(locale_headers-y) +headers: $(locale_headers-y) libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ) libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ) -locale_headers: $(top_builddir)include/bits/uClibc_locale_data.h +locale_headers: headers $(top_builddir)include/bits/uClibc_locale_data.h # make sure that the host system has locales (this check is ok for uClibc/glibc) # we do not know though which locales were really enabled for libc at build time @@ -61,8 +65,8 @@ $(locale_OUT)/codesets.txt: echo " "; \ echo "You do not have a codesets.txt file. Please create this "; \ echo "file in the $(locale_OUT) directory by running something like: "; \ - echo -e " find $(locale_DIR)/charmaps -name \"*.pairs\" > \\"; \ - echo -e " $@"; \ + echo " cd $(locale_DIR)/ && find charmaps -name \"*.pairs\" > \\"; \ + echo " $@"; \ echo "and then edit that file to disable/enable the codesets you wish to support. "; \ echo " "; \ false; \ @@ -86,58 +90,88 @@ $(locale_OUT)/locales.txt: else $(locale_OUT)/codesets.txt: + @$(disp_gen) ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y) - echo "$(locale_DIR)/charmaps/ASCII.pairs" > $@ ; \ - echo "$(locale_DIR)/charmaps/ISO-8859-1.pairs" >> $@ + $(Q)echo "charmaps/ASCII.pairs" > $@ ; \ + $(Q)echo "charmaps/ISO-8859-1.pairs" >> $@ else - find $(locale_DIR)/charmaps -name '*.pairs' | sort > $@ + $(Q)(cd $(locale_DIR)/ && find charmaps/ -name '*.pairs' | sort ) > $@ endif # the lines beginning w/ '#-' are mandatory # at least one conversion is needed (euro/cyrillic) $(locale_OUT)/locales.txt: $(locale_DIR)/LOCALES + @$(disp_gen) ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y) - echo "@euro e" > $@ ; \ - echo "#-" >> $@ ; \ - echo "UTF-8 yes" >> $@ ; \ - echo "8-BIT yes" >> $@ ; \ - echo "#-" >> $@ ; \ - echo "en_US.UTF-8 UTF-8" >> $@ ; \ - echo "en_US ISO-8859-1" >> $@ + $(Q)echo "@euro e" > $@ ; \ + $(Q)echo "#-" >> $@ ; \ + $(Q)echo "UTF-8 yes" >> $@ ; \ + $(Q)echo "8-BIT yes" >> $@ ; \ + $(Q)echo "#-" >> $@ ; \ + $(Q)echo "en_US.UTF-8 UTF-8" >> $@ ; \ + $(Q)echo "en_US ISO-8859-1" >> $@ else - cp $< $@ + $(Q)cat $< > $@ endif endif -$(locale_HOBJ): $(locale_OUT)/% : $(locale_DIR)/%.c | $(DEPH-locale) +$(locale_DIR)/gen_collate.c: $(DEPH-gen_collate) +$(locale_OUT)/gen_collate : $(locale_DIR)/gen_collate.c $(hcompile.u) - -$(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_locale)) +$(locale_DIR)/gen_ldc.c: $(DEPH-gen_ldc) +$(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c $(hcompile.u) - -$(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_ldc)) +$(locale_DIR)/gen_locale.c: $(DEPH-gen_locale) +$(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c + $(hcompile.u) +$(locale_DIR)/gen_wc8bit.c: $(DEPH-gen_wc8bit) +$(locale_OUT)/gen_wc8bit : $(locale_DIR)/gen_wc8bit.c + $(hcompile.u) +$(locale_DIR)/gen_wctype.c: $(DEPH-gen_wctype) +$(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c $(hcompile.u) +ifneq ($(V),) +ifeq ($(V),1) +FLAG-locale-verbose := -v +endif +ifeq ($(V),2) +FLAG-locale-verbose := -v -v +endif +endif + # code needs to be modified to support top_builddir in almost all apps that write directly to a file # grep fopen *.c $(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt - $< `cat $(word 2,$^)` + @$(disp_gen) + $(Q)(cd $(<D) && ./$(<F) `cat $(word 2,$(^F))`) # Warning! Beware tr_TR toupper/tolower exceptions! $(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype - $< en_US + @$(disp_gen) + $(Q)(cd $(<D) || exit 1 ; \ + ./$(<F) $(FLAG-locale-verbose) en_US || \ + ./$(<F) $(FLAG-locale-verbose) en_US.UTF-8 || \ + ./$(<F) $(FLAG-locale-verbose) en_US.iso8859-1 || \ + ./$(<F) $(FLAG-locale-verbose) en_GB || \ + ./$(<F) $(FLAG-locale-verbose) en_GB.UTF-8 \ + ) $(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt - $< $(word 2,$^) + @$(disp_gen) + $(Q)$< $(FLAG-locale-verbose) -o $@ $(word 2,$^) $(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h - grep "^#define" $< > $@ - grep "^#define __lc" $(word 2,$^) >> $@ + @$(disp_gen) + $(Q)grep "^#define" $< > $@ + $(Q)grep "^#define __lc" $(word 2,$^) >> $@ $(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h - grep COL_IDX_ $(word 2,$^) | sed -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | \ - sort | uniq | xargs $< + @$(disp_gen) + $(Q)grep COL_IDX_ $(word 2,$^) | \ + $(SED) -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | \ + xargs $< $(locale_DIR)/collation $(FLAG-locale-verbose) -o $@ $(locale_OUT)/$(LOCALE_DATA_FILENAME): ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y) @@ -147,33 +181,37 @@ endif ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y) $(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME) - zcat $< | tar -xv -C $(dir $@) -f - + zcat $< | $(TAR) -xv -C $(dir $@) -f - touch $@ # we use the one in locale_DIR #$(RM) $(locale_OUT)/locale_mmap.h -# for arch specific versions we have to at least overwrite lt_defines.h/locale_data.c/uClibc_locale_data.h +# for arch specific versions we have to at least overwrite +# lt_defines.h/locale_data.c/uClibc_locale_data.h $(locale_OUT)/uClibc_locale_data.h: $(locale_SRC) else -$(locale_SRC): $(locale_OUT)/gen_ldc - $< +$(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/lt_defines.h + @$(disp_gen) + $(Q)$< $@ $(locale_OUT)/uClibc_locale_data.h: $(locale_OUT)/lt_defines.h $(locale_OUT)/c8tables.h $(locale_OUT)/wctables.h $(locale_DIR)/locale_mmap.h | $(locale_SRC) - grep -v "define __LC" $< > $@ - cat $(wordlist 2,4,$^) >> $@ + @$(disp_gen) + $(Q)grep -v "define __LC" $< > $@ + $(Q)cat $(wordlist 2,4,$^) >> $@ endif $(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h - cat $< | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > $@ + @$(disp_gen) + $(Q)$(AWK) 'BEGIN{i=1}{if (/WANT_/) i=/endif/;else if (i) print $0}' \ + $< > $@ objclean-y += locale_clean # lmmtolso.c/gen_mmap.c/tst-*.c not used locale_clean: - $(RM) $(locale_HOBJ) $(locale_SRC) $(locale_OUT)/{*.{o,os,txt},gen_locale,gen_ldc} - $(RM) $(locale_OUT)/{uClibc_locale_data,lt_defines,c8tables,wctables,locale_tables,locale_collate}.h - $(RM) $(locale_OUT)/{lmmtolso,gen_mmap,locale.mmap} + $(do_rm) $(locale_HOBJ) $(locale_SRC) $(addprefix $(locale_OUT)/*., o os txt) \ + $(addprefix $(locale_OUT)/,$(addsuffix .h,uClibc_locale_data lt_defines c8tables wctables locale_tables locale_collate) lmmtolso gen_mmap locale.mmap) diff --git a/extra/locale/gen_collate.c b/extra/locale/gen_collate.c index 77dc5ff9e..44f6215b6 100644 --- a/extra/locale/gen_collate.c +++ b/extra/locale/gen_collate.c @@ -1,3 +1,12 @@ +/* + * Usage: + * gen_collate <INPUTDIR> [-o OUTPUTFILE] LOCALE ... + * + * Generate collation data from locales LOCALE. + * Reads all LOCALE from INPUTDIR and writes collation data to OUTPUTFILE. + * + * The output file defaults to "locales_collate.h". + */ /* TODO: * * add UNDEFINED at end if not specified @@ -24,6 +33,7 @@ #include <limits.h> #include <ctype.h> #include <assert.h> +#include <errno.h> #include <search.h> typedef struct { @@ -253,6 +263,14 @@ static void *root_sym = NULL; static size_t num_sym = 0; static size_t mem_sym = 0; +static const char *inputdir; +static size_t inputdir_len; +static unsigned verbose = 0; +enum { + VINFO = (1<<0), + VDETAIL = (1<<1), +}; + static void error_msg(const char *fmt, ...) __attribute__ ((noreturn, format (printf, 1, 2))); static void *xmalloc(size_t n); static char *xsymdup(const char *s); /* only allocate once... store in a tree */ @@ -294,6 +312,18 @@ enum { DT_RANGE = 0x10, }; +static int verbose_msg(const unsigned lvl, const char *fmt, ...) +{ + va_list arg; + int ret = 0; + + if (verbose & lvl) { + va_start(arg, fmt); + ret = vfprintf(stderr, fmt, arg); + va_end(arg); + } + return ret; +} static section_t *new_section(const char *name) { section_t *p; @@ -310,7 +340,7 @@ static section_t *new_section(const char *name) ++anonsection; } #warning devel code -/* fprintf(stderr, "section %s\n", name); */ +/* verbose_msg(VDETAIL, "section %s\n", name); */ p->name = xsymdup(name); p->itm_list = NULL; p->num_items = 0; @@ -328,7 +358,7 @@ static section_t *new_section(const char *name) p->rules[3] |= R_POSITION; cur_rule[3] |= R_POSITION; } -/* fprintf(stderr, "new section %s -- cur_num_weights = %d\n", p->name, cur_num_weights); */ +/* verbose_msg(VDETAIL, "new section %s -- cur_num_weights = %d\n", p->name, cur_num_weights); */ return p; } @@ -379,7 +409,7 @@ static void do_unrecognized(void) #if 1 error_msg("warning: unrecognized: %s", pos); #else -/* fprintf(stderr, "warning: unrecognized initial keyword \"%s\"\n", pos); */ +/* verbose_msg(VDETAIL, "warning: unrecognized initial keyword \"%s\"\n", pos); */ fprintf(stderr, "warning: unrecognized: %s", pos); if (end_of_token) { fprintf(stderr, "%c%s", end_of_token, pos_e+1); @@ -587,10 +617,10 @@ static void add_superset_weight(char *t) lli = new_ll_item(DT_REORDER, cur_section); lli->prev = lli->next = lli; insque(lli, comm_prev_ptr); -/* fprintf(stderr, " subsection -----------------------\n"); */ +/* verbose_msg(VDETAIL, " subsection -----------------------\n"); */ } -/* fprintf(stderr, " %s %s\n", t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol); */ +/* verbose_msg(VDETAIL, " %s %s\n", t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol); */ wi = add_weight(t); lli = new_ll_item(DT_WEIGHTED, wi); mark_reordered(wi->symbol); @@ -745,7 +775,7 @@ static void processfile(void) } if (cur_base == cur_col) { - fprintf(stderr, "Base: %15s", cur_col->name); + verbose_msg(VDETAIL, "Base: %15s", cur_col->name); } else { #if 1 if (!cur_col->undefined_idx) { @@ -794,20 +824,21 @@ static void processfile(void) } #endif - fprintf(stderr, " Der: %15s", cur_col->name); + verbose_msg(VDETAIL, " Der: %15s", cur_col->name); } { +#if 0 ll_item_t *p = cur_col->section_list; - - fprintf(stderr, "%6u weights", tnumnodes(cur_col->root_wi_index)); +#endif + verbose_msg(VDETAIL, "%6u weights", tnumnodes(cur_col->root_wi_index)); if (cur_base) { - fprintf(stderr, " %6u der %6u reor %6u starter - %u new stubs", + verbose_msg(VDETAIL, " %6u der %6u reor %6u starter - %u new stubs", tnumnodes(cur_base->root_derived_wi), tnumnodes(cur_base->root_wi_index_reordered), tnumnodes(cur_base->root_starter_char), ll_count(cur_col->section_list, DT_REORDER)); } - fprintf(stderr, "\n"); + verbose_msg(VDETAIL, "\n"); #if 0 while (p) { @@ -826,7 +857,7 @@ static void processfile(void) if ((*((section_t *)(p->data))->name != 'a') || (((section_t *)(p->data))->num_items > 0) ) { - fprintf(stderr, + verbose_msg(VDETAIL, /* "\t%-15s %zu\n", */ "\t%-15s %6u\n", ((section_t *)(p->data))->name, @@ -1089,18 +1120,35 @@ int main(int argc, char **argv) ll_item_t *lli; int i; int total; + char *output_file = "locale_collate.h"; + unsigned verbosity = 0; - if (argc < 2) { + if (argc < 3) { return EXIT_FAILURE; } - + --argc; + inputdir = strdup(*++argv); + inputdir_len = strlen(inputdir); init_locale_list(); while (--argc) { - p = (const deps_t *) bsearch(*++argv, deps, sizeof(deps)/sizeof(deps[0]), sizeof(deps[0]), dep_cmp); + ++argv; + if (!strcmp(*argv, "-o")) { + --argc; + if (*++argv == NULL) { + printf("-o <outfile> requires an argument\n"); + return EXIT_FAILURE; + } + output_file = strdup(*argv); + continue; + } else if (!strcmp(*argv, "-v")) { + verbosity++; + continue; + } + p = (const deps_t *) bsearch(*argv, deps, sizeof(deps)/sizeof(deps[0]), sizeof(deps[0]), dep_cmp); if (!p) { if (!strcmp("C", *argv)) { - printf("ignoring C locale\n"); + printf("ignoring %s locale\n", *argv); continue; } else { printf("%s not found\n", *argv); @@ -1125,10 +1173,10 @@ int main(int argc, char **argv) total = 0; for (i=0 ; i < BASE_MAX ; i++) { -/* printf("der_count[%2d] = %3d\n", i, der_count[i]); */ +/* printf("der_count[%2d] = %3d\n", i, der_count[i]); */ total += der_count[i]; } -/* printf("total = %d\n", total); */ +/* printf("total = %d\n", total); */ new_args[new_arg_count++] = "dummyprogramname"; for (i=0 ; i < BASE_MAX ; i++) { @@ -1143,11 +1191,16 @@ int main(int argc, char **argv) } while (lli != locale_list[i]); new_args[new_arg_count++] = "-f"; } + for (i=0; i < verbosity; i++) + new_args[new_arg_count++] = "-v"; -/* for (i=0 ; i < new_arg_count ; i++) { */ -/* printf("%3d: %s\n", i, new_args[i]); */ -/* } */ - + new_args[new_arg_count++] = "-o"; + new_args[new_arg_count++] = output_file; +/* + for (i=0 ; i < new_arg_count ; i++) { + printf("%3d: %s\n", i, new_args[i]); + } +*/ return old_main(new_arg_count, (char **) new_args); } @@ -1158,6 +1211,7 @@ static int old_main(int argc, char **argv) { int next_is_base = 0; int next_is_subset = 0; + char *output_file = NULL; superset = 0; @@ -1185,6 +1239,11 @@ static int old_main(int argc, char **argv) next_is_subset = 0; next_is_base = 2; superset = 0; + } else if (((*argv)[1] == 'o') && !(*argv)[2]) { /* output file */ + --argc; + output_file = *++argv; + } else if (((*argv)[1] == 'v') && !(*argv)[2]) { /* verbose */ + ++verbose; } else { error_msg("unrecognized option %s", *argv); } @@ -1198,7 +1257,7 @@ static int old_main(int argc, char **argv) cur_derived = cur_col; } pushfile(*argv); -/* fprintf(stderr, "processing file %s\n", *argv); */ +/* verbose_msg(VDETAIL, "processing file %s\n", *argv); */ processfile(); /* this does a popfile */ /* twalk(cur_col->root_colitem, print_colnode); */ @@ -1212,17 +1271,17 @@ static int old_main(int argc, char **argv) } } - fprintf(stderr, "success!\n"); - fprintf(stderr, + verbose_msg(VINFO, "success!\n"); + verbose_msg(VINFO, /* "num_sym=%zu mem_sym=%zu unique_weights=%zu\n", */ "num_sym=%u mem_sym=%u unique_weights=%u\n", num_sym, mem_sym, unique_weights); /* twalk(root_weight, print_weight_node); */ - fprintf(stderr, "num base locales = %d num derived locales = %d\n", + verbose_msg(VINFO, "num base locales = %d num derived locales = %d\n", base_locale_len, der_locale_len); - fprintf(stderr, + verbose_msg(VINFO, "override_len = %d multistart_len = %d weightstr_len = %d\n" "wcs2colidt_len = %d index2weight_len = %d index2ruleidx_len = %d\n" "ruletable_len = %d\n" @@ -1250,10 +1309,10 @@ static int old_main(int argc, char **argv) #endif { - FILE *fp = fopen("locale_collate.h", "w"); + FILE *fp = fopen(output_file, "w"); if (!fp) { - error_msg("couldn't open output file!"); + error_msg("cannot open output file '%s'!", output_file); } dump_collate(fp); if (ferror(fp) || fclose(fp)) { @@ -1282,20 +1341,23 @@ static void error_msg(const char *fmt, ...) static void pushfile(char *filename) { - static char fbuf[PATH_MAX]; - - snprintf(fbuf, PATH_MAX, "collation/%s", filename); + char *inputfile; + size_t inputfile_len; if (fno >= MAX_FNO) { error_msg("file stack size exceeded"); } - if (!(fstack[++fno] = fopen(fbuf, "r"))) { + inputfile_len = inputdir_len + strlen(filename) + 2; + inputfile = xmalloc(inputfile_len); + memset(inputfile, 0, inputfile_len); + sprintf(inputfile, "%s/%s", inputdir, filename); + if (!(fstack[++fno] = fopen(inputfile, "r"))) { --fno; /* oops */ - error_msg("cannot open file %s", fbuf); + error_msg("cannot open file %s: %s", inputfile, strerror(errno)); } - fname[fno] = xsymdup(filename); + fname[fno] = xsymdup(inputfile); lineno[fno] = 0; } @@ -1452,11 +1514,11 @@ static void do_copy(void) *e = 0; ++s; if (cur_base && !strcmp(cur_base->name,s)) { -/* fprintf(stderr, "skipping copy of base file %s\n", s); */ +/* verbose_msg(VDETAIL, "skipping copy of base file %s\n", s); */ #warning need to update last in order and position or check return; } -/* fprintf(stderr, "full copy of %s\n", s); */ +/* verbose_msg(VDETAIL, "full copy of %s\n", s); */ pushfile(s); return; } @@ -1541,7 +1603,7 @@ static ll_item_t *find_section_list_item(const char *name, col_locale_t *loc) while (p) { #warning devel code /* if (!((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER))) { */ -/* fprintf(stderr, "fsli = %d\n", p->data_type); */ +/* verbose_msg(VDETAIL, "fsli = %d\n", p->data_type); */ /* } */ assert((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER)); if (!strcmp(name, ((section_t *)(p->data))->name)) { @@ -1685,11 +1747,11 @@ static void add_colitem(char *item, char *def) #warning devel code if (superset) { if (tfind(p, &cur_base->root_colitem, colitem_cmp)) { -/* fprintf(stderr, "skipping superset duplicate collating item \"%s\"\n", p->string); */ +/* verbose_msg(VDETAIL, "skipping superset duplicate collating item \"%s\"\n", p->string); */ del_colitem(p); return; /* } else { */ -/* fprintf(stderr, "superset: new collating item \"%s\" = %s\n", p->string, p->element); */ +/* verbose_msg(VDETAIL, "superset: new collating item \"%s\" = %s\n", p->string, p->element); */ } } @@ -1850,7 +1912,7 @@ static void do_order_start(void) cur_section = sect; -/* fprintf(stderr, "setting cur_num_weights to %d for %s\n", sect->num_rules, sect->name); */ +/* verbose_msg(VDETAIL, "setting cur_num_weights to %d for %s\n", sect->num_rules, sect->name); */ cur_num_weights = sect->num_rules; memcpy(cur_rule, sect->rules, MAX_COLLATION_WEIGHTS); } @@ -1923,7 +1985,7 @@ static void do_reorder_after(void) insque(l1, l2); l3 = find_ll_last(cur_col->section_list); - fprintf(stderr, "reorder_after %p %p %p %s\n", l1, l2, l3, cur_section->name); + verbose_msg(VDETAIL, "reorder_after %p %p %p %s\n", l1, l2, l3, cur_section->name); } #else insque(new_ll_item(DT_REORDER, cur_section), find_ll_last(cur_col->section_list)); @@ -1935,7 +1997,7 @@ static void do_reorder_after(void) #warning devel code -/* fprintf(stderr, "reorder -- %s %d\n", ((weighted_item_t *)(lli->data))->symbol, w->num_weights); */ +/* verbose_msg(VDETAIL, "reorder -- %s %d\n", ((weighted_item_t *)(lli->data))->symbol, w->num_weights); */ #warning hack to get around hu_HU reorder-after problem /* if (!w->num_weights) { */ @@ -1945,7 +2007,7 @@ static void do_reorder_after(void) /* memcpy(cur_rule, w->rule, MAX_COLLATION_WEIGHTS); */ /* } */ -/* fprintf(stderr, "reorder_after succeeded for %s\n", t); */ +/* verbose_msg(VDETAIL, "reorder_after succeeded for %s\n", t); */ } static void do_reorder_end(void) @@ -1986,9 +2048,9 @@ static void do_reorder_sections_after(void) lli = cur_base->section_list; do { -/* fprintf(stderr, "hmm -- |%s|%d|\n", ((section_t *)(lli->data))->name, lli->data_type); */ +/* verbose_msg(VDETAIL, "hmm -- |%s|%d|\n", ((section_t *)(lli->data))->name, lli->data_type); */ if (lli->data_type & DT_SECTION) { -/* fprintf(stderr, "checking |%s|%s|\n", ((section_t *)(lli->data))->name, t); */ +/* verbose_msg(VDETAIL, "checking |%s|%s|\n", ((section_t *)(lli->data))->name, t); */ if (!strcmp(((section_t *)(lli->data))->name, t)) { reorder_section_ptr = lli; return; @@ -2025,7 +2087,7 @@ static ll_item_t *new_ll_item(int data_type, void *data) static int sym_cmp(const void *n1, const void *n2) { -/* fprintf(stderr, "sym_cmp: |%s| |%s|\n", (const char *)n1, (const char *)n2); */ +/* verbose_msg(VDETAIL, "sym_cmp: |%s| |%s|\n", (const char *)n1, (const char *)n2); */ return strcmp((const char *) n1, (const char *) n2); } @@ -2039,9 +2101,9 @@ static char *xsymdup(const char *s) } ++num_sym; mem_sym += strlen(s) + 1; -/* fprintf(stderr, "xsymdup: alloc |%s| %p |%s| %p\n", *(char **)p, p, s, s); */ +/* verbose_msg(VDETAIL, "xsymdup: alloc |%s| %p |%s| %p\n", *(char **)p, p, s, s); */ /* } else { */ -/* fprintf(stderr, "xsymdup: found |%s| %p\n", *(char **)p, p); */ +/* verbose_msg(VDETAIL, "xsymdup: found |%s| %p\n", *(char **)p, p); */ } return *(char **) p; } @@ -2079,7 +2141,7 @@ static weight_t *register_weight(weight_t *w) } ++unique_weights; /* } else { */ -/* fprintf(stderr, "rw: found\n"); */ +/* verbose_msg(VDETAIL, "rw: found\n"); */ } return *(weight_t **)p; } @@ -2200,7 +2262,7 @@ static void add_final_col_index(const char *s) ci.element = NULL; /* don't care */ v = tfind(&ci, &cur_base->root_colitem, colitem_cmp); if (!v) { - fprintf(stderr, "%s NOT DEFINED!!!\n", s); + verbose_msg(VDETAIL, "%s NOT DEFINED!!!\n", s); } else { p = *((colitem_t **) v); if (p->element != NULL) { @@ -2347,11 +2409,11 @@ static ll_item_t *init_comm_ptr(void) #warning devel code /* { */ /* ll_item_t *p = comm_cur_ptr; */ -/* fprintf(stderr, "init_comm_ptr\n"); */ +/* verbose_msg(VDETAIL, "init_comm_ptr\n"); */ /* while (p != comm_cur_ptr) { */ /* if (p->data_type & DT_WEIGHTED) { */ -/* fprintf(stderr, "%s", ((weighted_item_t *)p)->symbol); */ +/* verbose_msg(VDETAIL, "%s", ((weighted_item_t *)p)->symbol); */ /* } */ /* p = p->next; */ /* } */ @@ -2359,7 +2421,7 @@ static ll_item_t *init_comm_ptr(void) assert(comm_cur_ptr); -/* fprintf(stderr, "init_comm_ptr -- %s %p %p %p %d\n", */ +/* verbose_msg(VDETAIL, "init_comm_ptr -- %s %p %p %p %d\n", */ /* ((weighted_item_t *)(comm_cur_ptr->data))->symbol, */ /* comm_cur_ptr, comm_cur_ptr->prev, comm_cur_ptr->next, */ /* ll_len(comm_cur_ptr)); */ @@ -2625,7 +2687,7 @@ static void finalize_base(void) for (s = cur_base->section_list ; s ; s = s->next) { #if 1 if (s->data_type & DT_REORDER) { /* a reordered section */ - fprintf(stderr, "pass1: reordered section %s - xxx\n", ((section_t *)(s->data))->name); + verbose_msg(VDETAIL, "pass1: reordered section %s - xxx\n", ((section_t *)(s->data))->name); lli = ((section_t *)(s->data))->itm_list; r = 0; if (lli) { @@ -2635,7 +2697,7 @@ static void finalize_base(void) if (r > mr) { mr = r; } - fprintf(stderr, "pass1: reordered section %s - %d\n", ((section_t *)(s->data))->name, r); + verbose_msg(VDETAIL, "pass1: reordered section %s - %d\n", ((section_t *)(s->data))->name, r); continue; } #endif @@ -2652,11 +2714,11 @@ static void finalize_base(void) lli->idx = i; assert(!rli); rli = lli; - fprintf(stderr, "range pre = %d after = ", i); + verbose_msg(VDETAIL, "range pre = %d after = ", i); i += ((range_item_t *)(lli->data))->length + 1; #warning check ko_kR and 9 /* ++i; */ - fprintf(stderr, "%d\n", i); + verbose_msg(VDETAIL, "%d\n", i); if (!index2weight_len_inc) { /* ko_KR hack */ final_index += ((range_item_t *)(lli->data))->length + 1; } @@ -2726,7 +2788,7 @@ static void finalize_base(void) /* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ } else { -/* fprintf(stderr, "section: %s %d %d\n", ((section_t *)(s->data))->name, */ +/* verbose_msg(VDETAIL, "section: %s %d %d\n", ((section_t *)(s->data))->name, */ /* s->data_type, lli->data_type); */ /* assert(!(s->data_type & DT_REORDER)); */ /* assert(lli->data_type & DT_REORDER); */ @@ -2772,7 +2834,7 @@ static void finalize_base(void) mr = mi; for (cli = cur_base->derived_list ; cli ; cli = cli->next) { cl = (col_locale_t *)(cli->data); -/* fprintf(stderr, "pass3: %d %s\n", cli->data_type, cl->name); */ +/* verbose_msg(VDETAIL, "pass3: %d %s\n", cli->data_type, cl->name); */ /* fprintf(stdout, "pass3: %d %s\n", cli->data_type, cl->name); */ @@ -2790,7 +2852,7 @@ static void finalize_base(void) do { assert(!(lli->data_type & DT_RANGE)); if (lli->data_type & DT_WEIGHTED) { -/* fprintf(stderr, " %d %d %s\n", lli->data_type, lli->idx, ((weighted_item_t *)(lli->data))->symbol); */ +/* verbose_msg(VDETAIL, " %d %d %s\n", lli->data_type, lli->idx, ((weighted_item_t *)(lli->data))->symbol); */ add_final_col_index(((weighted_item_t *)(lli->data))->symbol); if (s->data_type & DT_REORDER) { continue; @@ -2850,10 +2912,10 @@ static void finalize_base(void) ++wcs2index_count; if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) { wcs2index[i] = ++starter_index; -/* fprintf(stderr, "wcs2index[ %#06x ] = %d (starter)\n", i, wcs2index[i]); */ +/* verbose_msg(VDETAIL, "wcs2index[ %#06x ] = %d (starter)\n", i, wcs2index[i]); */ } else { wcs2index[i] = (int)(p->data); -/* fprintf(stderr, "wcs2index[ %#06x ] = %d\n", i, wcs2index[i]); */ +/* verbose_msg(VDETAIL, "wcs2index[ %#06x ] = %d\n", i, wcs2index[i]); */ } } else { if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) { @@ -2898,7 +2960,7 @@ static void finalize_base(void) smallest = newopt(wcs2index, RANGE, n, &table); assert(t == smallest); wcs2colidt_len += smallest; -/* fprintf(stderr, "smallest = %d wcs2colidt_len = %d\n", smallest, wcs2colidt_len); */ +/* verbose_msg(VDETAIL, "smallest = %d wcs2colidt_len = %d\n", smallest, wcs2colidt_len); */ #if 0 { @@ -2919,15 +2981,15 @@ static void finalize_base(void) u >>= __LOCALE_DATA_WCctype_II_SHIFT; i0 = tbl->ii[u]; - fprintf(stderr, "i0 = %d\n", i0); + verbose_msg(VDETAIL, "i0 = %d\n", i0); i0 <<= __LOCALE_DATA_WCctype_II_SHIFT; i1 = tbl->ii[__LOCALE_DATA_WCctype_II_LEN + i0 + n]; /* i1 = tbl->ti[i0 + n]; */ - fprintf(stderr, "i1 = %d\n", i1); + verbose_msg(VDETAIL, "i1 = %d\n", i1); i1 <<= __LOCALE_DATA_WCctype_TI_SHIFT; /* return *(uint16_t *)(&(tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc])); */ - fprintf(stderr, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc); - fprintf(stderr, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]); + verbose_msg(VDETAIL, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc); + verbose_msg(VDETAIL, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]); /* return tbl->ut[i1 + sc]; */ @@ -2944,7 +3006,7 @@ static void finalize_base(void) base_locale_array[base_locale_len].max_col_index = final_index; base_locale_array[base_locale_len].max_weight = max_weight; - fprintf(stderr, "%s: %6u invariant %6u varying %6u derived %6u total %6u max weight %6u wcs2\n", + verbose_msg(VDETAIL, "%s: %6u invariant %6u varying %6u derived %6u total %6u max weight %6u wcs2\n", cur_base->name, num_invariant, num_varying, tnumnodes(cur_base->root_derived_wi), final_index, max_weight, wcs2index_count); @@ -2960,7 +3022,7 @@ static void finalize_base(void) for (s = cur_base->section_list ; s ; s = s->next) { #if 1 if (s->data_type & DT_REORDER) { - fprintf(stderr, "1: skipping reordered section %s\n", ((section_t *)(s->data))->name); + verbose_msg(VDETAIL, "1: skipping reordered section %s\n", ((section_t *)(s->data))->name); continue; } #endif @@ -2988,7 +3050,7 @@ static void finalize_base(void) for (s = cur_base->section_list ; s ; s = s->next) { #if 1 if (s->data_type & DT_REORDER) { - fprintf(stderr, "2: skipping reordered section %s\n", ((section_t *)(s->data))->name); + verbose_msg(VDETAIL, "2: skipping reordered section %s\n", ((section_t *)(s->data))->name); continue; } #endif @@ -3015,7 +3077,7 @@ static void finalize_base(void) do_starter_lists(cur_base); -/* fprintf(stderr,"updated final_index = %d\n", final_index); */ +/* verbose_msg(VDETAIL,"updated final_index = %d\n", final_index); */ if (rli) { base_locale_array[base_locale_len].range_low @@ -3042,8 +3104,8 @@ static void finalize_base(void) && isupper(cur_base->name[4]) ) { - fprintf(stderr, "adding special derived for %s\n", cur_base->name); -/* fprintf(stderr,"updated final_index = %d\n", final_index); */ + verbose_msg(VDETAIL, "adding special derived for %s\n", cur_base->name); +/* verbose_msg(VDETAIL,"updated final_index = %d\n", final_index); */ assert(der_locale_len+1 < DER_LOCALE_LEN); @@ -3080,7 +3142,7 @@ static void finalize_base(void) ++der_locale_len; } else { - fprintf(stderr, "NOT adding special derived for %s\n", cur_base->name); + verbose_msg(VDETAIL, "NOT adding special derived for %s\n", cur_base->name); } /* now all the derived... */ @@ -3102,7 +3164,7 @@ static void finalize_base(void) } /* we do this in two passes... first all sequences, then all single reorders */ for (s = cl->section_list ; s ; s = s->next) { -/* fprintf(stderr, "doing section %s\n", ((section_t *)(s->data))->name); */ +/* verbose_msg(VDETAIL, "doing section %s\n", ((section_t *)(s->data))->name); */ h = lli = ((section_t *)(s->data))->itm_list; if (!lli) { /* fprintf(stdout, "EMPTY ITEM LIST IN SECTION %s\n", ((section_t *)(s->data))->name ); */ @@ -3195,7 +3257,7 @@ static void finalize_base(void) ++base_locale_len; /* if (tnumnodes(cur_base->root_starter_char)) { */ -/* fprintf(stderr, "starter nodes\n"); */ +/* verbose_msg(VDETAIL, "starter nodes\n"); */ /* twalk(cur_base->root_starter_char, print_starter_node); */ /* } */ } @@ -3287,7 +3349,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level) if (++u16_starter < base_locale_array[base_locale_len].num_starters) { u16_buf[u16_starter] = u16_buf_len; } -/* fprintf(stderr, "ucode - %d %d\n", u16_buf[u16_starter-1], u16_buf_len); */ +/* verbose_msg(VDETAIL, "ucode - %d %d\n", u16_buf[u16_starter-1], u16_buf_len); */ } else { x.string = w->symbol; x.element = NULL; @@ -3299,7 +3361,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level) assert(u16_buf[u16_buf_len-1]); assert(*s == '"'); n = is_ucode(++s); -/* fprintf(stderr, "s is |%s| with len %d (%d)\n", s, strlen(s), n); */ +/* verbose_msg(VDETAIL, "s is |%s| with len %d (%d)\n", s, strlen(s), n); */ assert(n); s += n; while (*s != '"') { @@ -3307,7 +3369,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level) assert(n); strncpy(buf, s, n+1); buf[n] = 0; -/* fprintf(stderr, "buf is |%s| with len %d (%d)\n", buf, strlen(buf), n); */ +/* verbose_msg(VDETAIL, "buf is |%s| with len %d (%d)\n", buf, strlen(buf), n); */ u16_buf[u16_buf_len++] = final_index_val(buf); assert(u16_buf[u16_buf_len-1]); s += n; @@ -3331,7 +3393,7 @@ static void complete_starter_node(const void *ptr, VISIT order, int level) p = xmalloc(sizeof(weighted_item_t)); p->symbol = w.symbol; p->weight = NULL; -/* fprintf(stderr, "complete_starter_node: %s\n", *(const char **) ptr); */ +/* verbose_msg(VDETAIL, "complete_starter_node: %s\n", *(const char **) ptr); */ if (!tsearch(p, p_cl_root_starter_all, starter_all_cmp)) { error_msg("OUT OF MEMORY"); } @@ -3377,7 +3439,7 @@ static void do_starter_lists(col_locale_t *cl) x.element = NULL; p = tfind(&x, &cur_base->root_colitem, colitem_cmp); if (!p) { -/* fprintf(stderr, "Whoa... processing starters for %s and couldn't find %s\n", */ +/* verbose_msg(VDETAIL, "Whoa... processing starters for %s and couldn't find %s\n", */ /* cl->name, w->symbol); */ continue; } @@ -3426,13 +3488,13 @@ static void do_starter_lists(col_locale_t *cl) u16_starter = 0; u16_buf[0] = u16_buf_len = base_locale_array[base_locale_len].num_starters; twalk(cl->root_starter_all, process_starter_node); -/* fprintf(stderr, "s=%d n=%d\n", u16_starter, base_locale_array[base_locale_len].num_starters); */ +/* verbose_msg(VDETAIL, "s=%d n=%d\n", u16_starter, base_locale_array[base_locale_len].num_starters); */ assert(u16_starter == base_locale_array[base_locale_len].num_starters); #if 0 { int i; for (i=0 ; i < u16_buf_len ; i++) { - fprintf(stderr, "starter %2d: %d - %#06x\n", i, u16_buf[i], u16_buf[i]); + verbose_msg(VDETAIL, "starter %2d: %d - %#06x\n", i, u16_buf[i], u16_buf[i]); }} #endif @@ -3451,7 +3513,7 @@ static void do_starter_lists(col_locale_t *cl) der_locale_array[der_locale_len].multistart_offset = multistart_len; } multistart_len += u16_buf_len; -/* fprintf(stderr, "%s: multistart_len = %d u16_buf_len = %d\n", cl->name, multistart_len, u16_buf_len); */ +/* verbose_msg(VDETAIL, "%s: multistart_len = %d u16_buf_len = %d\n", cl->name, multistart_len, u16_buf_len); */ } else if (!(u16_buf_len > multistart_len)) { assert(mm); if (cl == cur_base) { @@ -3459,7 +3521,7 @@ static void do_starter_lists(col_locale_t *cl) } else { der_locale_array[der_locale_len].multistart_offset = ((uint16_t *)(mm)) - multistart_buffer; } -/* fprintf(stderr, "%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */ +/* verbose_msg(VDETAIL, "%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */ } } else { assert(!base_locale_array[base_locale_len].num_starters); diff --git a/extra/locale/gen_ldc.c b/extra/locale/gen_ldc.c index 2a121610e..2cedbddaf 100644 --- a/extra/locale/gen_ldc.c +++ b/extra/locale/gen_ldc.c @@ -148,8 +148,9 @@ void out_size_t(FILE *f, const size_t *p, size_t n, char *comment) } -int main(void) +int main(int argc, char **argv) { + char *output_file = "locale_data.c"; FILE *lso; /* static object */ int i; #ifdef __LOCALE_DATA_MAGIC_SIZE @@ -158,8 +159,10 @@ int main(void) memset(magic, 0, __LOCALE_DATA_MAGIC_SIZE); #endif /* __LOCALE_DATA_MAGIC_SIZE */ - if (!(lso = fopen("locale_data.c", "w"))) { - printf("can't open locale_data.c!\n"); + if (argc == 2) + output_file = argv[1]; + if (!(lso = fopen(output_file, "w"))) { + printf("cannot open output file '%s'!\n", output_file); return EXIT_FAILURE; } diff --git a/extra/locale/gen_locale.c b/extra/locale/gen_locale.c index 31df4156e..5e8936082 100644 --- a/extra/locale/gen_locale.c +++ b/extra/locale/gen_locale.c @@ -4,6 +4,7 @@ #include <ctype.h> #include <limits.h> #include <assert.h> +#include <stdarg.h> #include <locale.h> #include <langinfo.h> #include <nl_types.h> @@ -15,7 +16,7 @@ #define __LOCALE_DATA_CATEGORIES 6 /* must agree with ordering of gen_mmap! */ -static const unsigned char *lc_names[] = { +static const char *lc_names[] = { "LC_CTYPE", "LC_NUMERIC", "LC_MONETARY", @@ -89,6 +90,41 @@ static int default_8bit; static int total_size; static int null_count; +static unsigned verbose = 0; +enum { + VINFO = (1<<0), + VDETAIL = (1<<1), +}; +static int verbose_msg(const unsigned lvl, const char *fmt, ...) +{ + va_list arg; + int ret = 0; + + if (verbose & lvl) { + va_start(arg, fmt); + ret = vfprintf(stderr, fmt, arg); + va_end(arg); + } + return ret; +} + +static void error_msg(const char *fmt, ...) __attribute__ ((noreturn, format (printf, 1, 2))); +static void error_msg(const char *fmt, ...) +{ + va_list arg; + + fprintf(stderr, "Error: "); +/* if (fno >= 0) { + fprintf(stderr, "file %s (%d): ", fname[fno], lineno[fno]); + } */ + va_start(arg, fmt); + vfprintf(stderr, fmt, arg); + va_end(arg); + fprintf(stderr, "\n"); + + exit(EXIT_FAILURE); +} + static void do_locale_names(void) { /* "C" locale name is handled specially by the setlocale code. */ @@ -96,8 +132,7 @@ static void do_locale_names(void) int i; if (num_locales <= 1) { -/* printf("error - only C locale?\n"); */ -/* exit(EXIT_FAILURE); */ +/* error_msg("only C locale?"); */ fprintf(ofp, "static const unsigned char __locales[%d];\n", (3 + __LOCALE_DATA_CATEGORIES)); fprintf(ofp, "static const unsigned char __locale_names5[5];\n"); } else { @@ -131,8 +166,7 @@ static void do_locale_names(void) } else if (!strcmp(locales[i].glibc_name, "C")) { fprintf(ofp, "COL_IDX_C , "); } else { - printf("don't know how to handle COL_IDX_ for %s\n", locales[i].glibc_name); - exit(EXIT_FAILURE); + error_msg("don't know how to handle COL_IDX_ for %s", locales[i].glibc_name); } #else fprintf(ofp, "%#4x, ", 0); /* place holder for lc_collate */ @@ -196,8 +230,7 @@ static void do_locale_names(void) } } if (pos[__LOCALE_DATA_CATEGORIES-1] > 255) { - printf("error - lc_names is too big (%d)\n", pos[__LOCALE_DATA_CATEGORIES-1]); - exit(EXIT_FAILURE); + error_msg("lc_names is too big (%d)", pos[__LOCALE_DATA_CATEGORIES-1]); } fprintf(ofp, "#define __LC_ALL\t\t%d\n\n", i); @@ -218,7 +251,7 @@ static void do_locale_names(void) fprintf(ofp, ";\n\n"); } - printf("locale data = %d name data = %d for %d uniq\n", + verbose_msg(VDETAIL,"locale data = %d name data = %d for %d uniq\n", num_locales * (3 + __LOCALE_DATA_CATEGORIES), uniq * 5, uniq); total_size += num_locales * (3 + __LOCALE_DATA_CATEGORIES) + uniq * 5; @@ -236,8 +269,7 @@ static void read_at_mappings(void) if (!(p = strtok(line_buf, " \t\n")) || (*p == '#')) { if (!fgets(line_buf, sizeof(line_buf), fp)) { if (ferror(fp)) { - printf("error reading file\n"); - exit(EXIT_FAILURE); + error_msg("reading file"); } return; /* EOF */ } @@ -248,17 +280,14 @@ static void read_at_mappings(void) } if (*p == '@') { if (p[1] == 0) { - printf("error: missing @modifier name\n"); - exit(EXIT_FAILURE); + error_msg("missing @modifier name"); } m = p; /* save the modifier name */ if (!(p = strtok(NULL, " \t\n")) || p[1] || (((unsigned char) *p) > 0x7f)) { - printf("error: missing or illegal @modifier mapping char\n"); - exit(EXIT_FAILURE); + error_msg("missing or illegal @modifier mapping char"); } if (at_mappings[(int)((unsigned char) *p)]) { - printf("error: reused @modifier mapping char\n"); - exit(EXIT_FAILURE); + error_msg("reused @modifier mapping char"); } at_mappings[(int)((unsigned char) *p)] = 1; at_mapto[mc] = *p; @@ -267,10 +296,10 @@ static void read_at_mappings(void) strcpy(++at_strings_end, m+1); at_strings_end += (unsigned char) at_strings_end[-1]; - printf("@mapping: \"%s\" to '%c'\n", m, *p); + verbose_msg(VDETAIL,"@mapping: \"%s\" to '%c'\n", m, *p); if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) { - printf("ignoring trailing text: %s...\n", p); + fprintf(stderr,"ignoring trailing text: %s...\n", p); } *line_buf = 0; continue; @@ -283,12 +312,12 @@ static void read_at_mappings(void) p = at_strings; if (!*p) { - printf("no @ strings\n"); + verbose_msg(VDETAIL,"no @ strings\n"); return; } do { - printf("%s\n", p+1); + verbose_msg(VDETAIL,"%s\n", p+1); p += 1 + (unsigned char) *p; } while (*p); } @@ -303,8 +332,7 @@ static void read_enable_disable(void) if (!(p = strtok(line_buf, " =\t\n")) || (*p == '#')) { if (!fgets(line_buf, sizeof(line_buf), fp)) { if (ferror(fp)) { - printf("error reading file\n"); - exit(EXIT_FAILURE); + error_msg("reading file"); } return; /* EOF */ } @@ -316,25 +344,23 @@ static void read_enable_disable(void) if (!strcmp(p, "UTF-8")) { if (!(p = strtok(NULL, " =\t\n")) || ((toupper(*p) != 'Y') && (toupper(*p) != 'N'))) { - printf("error: missing or illegal UTF-8 setting\n"); - exit(EXIT_FAILURE); + error_msg("missing or illegal UTF-8 setting"); } default_utf8 = (toupper(*p) == 'Y'); - printf("UTF-8 locales are %sabled\n", "dis\0en"+ (default_utf8 << 2)); + verbose_msg(VINFO,"UTF-8 locales are %sabled\n", "dis\0en"+ (default_utf8 << 2)); } else if (!strcmp(p, "8-BIT")) { if (!(p = strtok(NULL, " =\t\n")) || ((toupper(*p) != 'Y') && (toupper(*p) != 'N'))) { - printf("error: missing or illegal 8-BIT setting\n"); - exit(EXIT_FAILURE); + error_msg("missing or illegal 8-BIT setting"); } default_8bit = (toupper(*p) == 'Y'); - printf("8-BIT locales are %sabled\n", "dis\0en" + (default_8bit << 2)); + verbose_msg(VINFO,"8-BIT locales are %sabled\n", "dis\0en" + (default_8bit << 2)); } else { break; } if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) { - printf("ignoring trailing text: %s...\n", p); + fprintf(stderr,"ignoring trailing text: %s...\n", p); } *line_buf = 0; continue; @@ -354,13 +380,12 @@ static int find_codeset_num(const char *cs) if (strcmp(cs, "UTF-8") != 0) { ++r; while (*s && strcmp(__LOCALE_DATA_CODESET_LIST+ ((unsigned char) *s), cs)) { -/* printf("tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */ +/* verbose_msg(VDETAIL,"tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */ ++r; ++s; } if (!*s) { - printf("error: unsupported codeset %s\n", cs); - exit(EXIT_FAILURE); + error_msg("unsupported codeset %s", cs); } } return r; @@ -375,8 +400,7 @@ static int find_codeset_num(const char *cs) /* 7-bit is 1, UTF-8 is 2, 8-bits are > 2 */ if (strcmp(cs, "UTF-8") != 0) { - printf("error: unsupported codeset %s\n", cs); - exit(EXIT_FAILURE); + error_msg("unsupported codeset %s", cs); } return r; } @@ -396,8 +420,7 @@ static int find_at_string_num(const char *as) p += 1 + (unsigned char) *p; } - printf("error: unmapped @string %s\n", as); - exit(EXIT_FAILURE); + error_msg("error: unmapped @string %s", as); } static void read_locale_list(void) @@ -429,8 +452,7 @@ static void read_locale_list(void) if (!(p = strtok(line_buf, " \t\n")) || (*p == '#')) { if (!fgets(line_buf, sizeof(line_buf), fp)) { if (ferror(fp)) { - printf("error reading file\n"); - exit(EXIT_FAILURE); + error_msg("reading file"); } return; /* EOF */ } @@ -448,7 +470,7 @@ static void read_locale_list(void) s += 1 + ((unsigned char) *s); } if (i < num_locales) { - printf("ignoring dulplicate locale name: %s", p); + fprintf(stderr,"ignoring duplicate locale name: %s", p); *line_buf = 0; continue; } @@ -460,24 +482,23 @@ static void read_locale_list(void) ln = p; /* save locale name */ if (!(p = strtok(NULL, " \t\n"))) { - printf("error: missing codeset for locale %s\n", ln); - exit(EXIT_FAILURE); + error_msg("missing codeset for locale %s", ln); } cs = p; i = find_codeset_num(p); if ((i == 2) && !default_utf8) { - printf("ignoring UTF-8 locale %s\n", ln); + fprintf(stderr,"ignoring UTF-8 locale %s\n", ln); *line_buf = 0; continue; } else if ((i > 2) && !default_8bit) { - printf("ignoring 8-bit codeset locale %s\n", ln); + fprintf(stderr,"ignoring 8-bit codeset locale %s\n", ln); *line_buf = 0; continue; } locales[num_locales].cs = (char)((unsigned char) i); if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) { - printf("ignoring trailing text: %s...\n", p); + verbose_msg(VINFO,"ignoring trailing text: %s...\n", p); } /* Now go back to locale string for .codeset and @modifier */ @@ -492,19 +513,18 @@ static void read_locale_list(void) ls = ln; if ((strlen(ls) != 5) || (ls[2] != '_')) { - printf("error: illegal locale name %s\n", ls); - exit(EXIT_FAILURE); + error_msg("illegal locale name %s", ls); } i = 0; /* value for unspecified codeset */ if (ds) { i = find_codeset_num(ds); if ((i == 2) && !default_utf8) { - printf("ignoring UTF-8 locale %s\n", ln); + fprintf(stderr,"ignoring UTF-8 locale %s\n", ln); *line_buf = 0; continue; } else if ((i > 2) && !default_8bit) { - printf("ignoring 8-bit codeset locale %s\n", ln); + fprintf(stderr,"ignoring 8-bit codeset locale %s\n", ln); *line_buf = 0; continue; } @@ -516,7 +536,7 @@ static void read_locale_list(void) ls[2] = at_mapto[i]; } memcpy(locales[num_locales].name, ls, 5); -/* printf("locale: %5.5s %2d %2d %s\n", */ +/* verbose_msg(VDETAIL,"locale: %5.5s %2d %2d %s\n", */ /* locales[num_locales].name, */ /* locales[num_locales].cs, */ /* locales[num_locales].dot_cs, */ @@ -554,10 +574,24 @@ static int le_cmp(const void *a, const void *b) int main(int argc, char **argv) { - if ((argc != 2) || (!(fp = fopen(*++argv, "r")))) { - printf("error: missing filename or file!\n"); - return EXIT_FAILURE; + char *output_file = NULL; + + while (--argc) { + ++argv; + if (!strcmp(*argv, "-o")) { + --argc; + output_file = strdup(*++argv); + } else if (!strcmp(*argv, "-v")) { + verbose++; + } else if (!(fp = fopen(*argv, "r"))) { +no_inputfile: + error_msg("missing filename or file!"); + } } + if (fp == NULL) + goto no_inputfile; + if (output_file == NULL) + output_file = strdup("locale_tables.h"); at_strings_end = at_strings; @@ -572,7 +606,7 @@ int main(int argc, char **argv) #if 0 for (i=0 ; i < num_locales ; i++) { - printf("locale: %5.5s %2d %2d %s\n", + verbose_msg(VDETAIL,"locale: %5.5s %2d %2d %s\n", locales[i].name, locales[i].cs, locales[i].dot_cs, @@ -580,10 +614,10 @@ int main(int argc, char **argv) ); } #endif - - if (!(ofp = fopen("locale_tables.h", "w"))) { - printf("error: can not open locale_tables.h for writing!\n"); - return EXIT_FAILURE; + if (argc == 3) + output_file = *++argv; + if (output_file == NULL || !(ofp = fopen(output_file, "w"))) { + error_msg("cannot open output file '%s'!", output_file); } do_lc_time(); @@ -596,8 +630,8 @@ int main(int argc, char **argv) fclose(ofp); - printf("total data size = %d\n", total_size); - printf("null count = %d\n", null_count); + verbose_msg(VINFO, "total data size = %d\n", total_size); + verbose_msg(VDETAIL, "null count = %d\n", null_count); return EXIT_SUCCESS; } @@ -622,12 +656,10 @@ static int addblock(const char *s, size_t n) /* l includes nul terminator */ } } if (uniq >= sizeof(idx)) { - printf("too many uniq strings!\n"); - exit(EXIT_FAILURE); + error_msg("too many uniq strings!"); } if (last + n >= buf + sizeof(buf)) { - printf("need to increase size of buf!\n"); - exit(EXIT_FAILURE); + error_msg("need to increase size of buf!"); } idx[uniq] = last; @@ -653,13 +685,11 @@ static int addstring(const char *s) } } if (uniq >= sizeof(idx)) { - printf("too many uniq strings!\n"); - exit(EXIT_FAILURE); + error_msg("too many uniq strings!"); } l = strlen(s) + 1; if (last + l >= buf + sizeof(buf)) { - printf("need to increase size of buf!\n"); - exit(EXIT_FAILURE); + error_msg("need to increase size of buf!"); } idx[uniq] = last; @@ -670,9 +700,9 @@ static int addstring(const char *s) } #define DO_LC_COMMON(CATEGORY) \ - printf("buf-size=%d uniq=%d rows=%d\n", \ + verbose_msg(VDETAIL, "buf-size=%d uniq=%d rows=%d\n", \ (int)(last - buf), uniq, lc_##CATEGORY##_uniq); \ - printf("total = %d + %d * %d + %d = %d\n", \ + verbose_msg(VDETAIL, "total = %d + %d * %d + %d = %d\n", \ num_locales, lc_##CATEGORY##_uniq, NUM_NL_##CATEGORY, (int)(last - buf), \ i = num_locales + lc_##CATEGORY##_uniq*NUM_NL_##CATEGORY + (int)(last - buf)); \ total_size += i; \ @@ -701,8 +731,7 @@ static int addstring(const char *s) #define DL_LC_LOOPTAIL(CATEGORY) \ if (k > NUM_NL_##CATEGORY) { \ - printf("error -- lc_" #CATEGORY " nl_item count > %d!\n", NUM_NL_##CATEGORY); \ - exit(EXIT_FAILURE); \ + error_msg("lc_" #CATEGORY " nl_item count > %d!", NUM_NL_##CATEGORY); \ } \ { \ int r; \ @@ -715,8 +744,7 @@ static int addstring(const char *s) if (r == lc_##CATEGORY##_uniq) { /* new locale row */ \ ++lc_##CATEGORY##_uniq; \ if (lc_##CATEGORY##_uniq > 255) { \ - printf("too many unique lc_" #CATEGORY " rows!\n"); \ - exit(EXIT_FAILURE); \ + error_msg("too many unique lc_" #CATEGORY " rows!"); \ } \ } \ locales[i].lc_##CATEGORY##_row = r; \ @@ -781,8 +809,7 @@ static void dump_table16(const char *name, const int *tbl, int len) fprintf(ofp, "\n\t"); } if (tbl[i] != (uint16_t) tbl[i]) { - printf("error - falls outside uint16 range!\n"); - exit(EXIT_FAILURE); + error_msg("falls outside uint16 range!"); } fprintf(ofp, "%#6x, ", tbl[i]); } @@ -823,7 +850,7 @@ static void lc_time_S(int X, int k) len = p - s; } j = addblock(s, len); -/* if (len > 1) fprintf(stderr, "alt_digit: called addblock with len %zd\n", len); */ +/* if (len > 1) verbose_msg(VDETAIL, "alt_digit: called addblock with len %zd\n", len); */ } else if (X == ERA) { if (!s) { s = nulbuf; @@ -837,7 +864,7 @@ static void lc_time_S(int X, int k) } ++p; j = addblock(s, p - s); -/* if (p-s > 1) fprintf(stderr, "era: called addblock with len %d\n", p-s); */ +/* if (p-s > 1) verbose_msg(VDETAIL, "era: called addblock with len %d\n", p-s); */ } else { j = addstring(s); } @@ -848,8 +875,7 @@ static void lc_time_S(int X, int k) } if (m == lc_time_count[k]) { /* new for this nl_item */ if (m > 255) { - printf("too many nl_item %d entries in lc_time\n", k); - exit(EXIT_FAILURE); + error_msg("too many nl_item %d entries in lc_time", k); } lc_time_item[k][m] = j; ++lc_time_count[k]; @@ -870,7 +896,7 @@ static void do_lc_time(void) k = 0; if (!setlocale(LC_ALL, locales[i].glibc_name)) { - printf("setlocale(LC_ALL,%s) failed!\n", + verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n", locales[i].glibc_name); } @@ -973,8 +999,7 @@ static void lc_numeric_S(int X, int k) ++e; } if ((e - s) > sizeof(buf)) { - printf("grouping specifier too long\n"); - exit(EXIT_FAILURE); + error_msg("grouping specifier too long"); } strncpy(buf, s, (e-s)); e = buf + (e-s); @@ -1000,13 +1025,12 @@ static void lc_numeric_S(int X, int k) } if (m == lc_numeric_count[k]) { /* new for this nl_item */ if (m > 255) { - printf("too many nl_item %d entries in lc_numeric\n", k); - exit(EXIT_FAILURE); + error_msg("too many nl_item %d entries in lc_numeric", k); } lc_numeric_item[k][m] = j; ++lc_numeric_count[k]; } -/* printf("\\x%02x", m); */ +/* verbose_msg(VDETAIL, "\\x%02x", m); */ lc_numeric_uniq_X[lc_numeric_uniq][k] = m; } @@ -1023,7 +1047,7 @@ static void do_lc_numeric(void) k = 0; if (!setlocale(LC_ALL, locales[i].glibc_name)) { - printf("setlocale(LC_ALL,%s) failed!\n", + verbose_msg(VDETAIL,"setlocale(LC_ALL,%s) failed!\n", locales[i].glibc_name); } @@ -1048,7 +1072,7 @@ static int lc_monetary_uniq; #define DO_NL_S(X) lc_monetary_S(X, k++) -/* #define DO_NL_C(X) printf("%#02x", (int)(unsigned char)(*nl_langinfo(X))); */ +/* #define DO_NL_C(X) verbose_msg(VDETAIL,"%#02x", (int)(unsigned char)(*nl_langinfo(X))); */ #define DO_NL_C(X) lc_monetary_C(X, k++) static void lc_monetary_C(int X, int k) @@ -1068,13 +1092,12 @@ static void lc_monetary_C(int X, int k) } if (m == lc_monetary_count[k]) { /* new for this nl_item */ if (m > 255) { - printf("too many nl_item %d entries in lc_monetary\n", k); - exit(EXIT_FAILURE); + error_msg("too many nl_item %d entries in lc_monetary", k); } lc_monetary_item[k][m] = j; ++lc_monetary_count[k]; } -/* printf("\\x%02x", m); */ +/* verbose_msg(VDETAIL,"\\x%02x", m); */ lc_monetary_uniq_X[lc_monetary_uniq][k] = m; } @@ -1104,8 +1127,7 @@ static void lc_monetary_S(int X, int k) ++e; } if ((e - s) > sizeof(buf)) { - printf("mon_grouping specifier too long\n"); - exit(EXIT_FAILURE); + error_msg("mon_grouping specifier too long"); } strncpy(buf, s, (e-s)); e = buf + (e-s); @@ -1131,13 +1153,12 @@ static void lc_monetary_S(int X, int k) } if (m == lc_monetary_count[k]) { /* new for this nl_item */ if (m > 255) { - printf("too many nl_item %d entries in lc_monetary\n", k); - exit(EXIT_FAILURE); + error_msg("too many nl_item %d entries in lc_monetary", k); } lc_monetary_item[k][m] = j; ++lc_monetary_count[k]; } -/* printf("\\x%02x", m); */ +/* verbose_msg(VDETAIL,"\\x%02x", m); */ lc_monetary_uniq_X[lc_monetary_uniq][k] = m; } @@ -1154,7 +1175,7 @@ static void do_lc_monetary(void) k = 0; if (!setlocale(LC_ALL, locales[i].glibc_name)) { - printf("setlocale(LC_ALL,%s) failed!\n", + verbose_msg(VDETAIL,"setlocale(LC_ALL,%s) failed!\n", locales[i].glibc_name); } @@ -1213,13 +1234,12 @@ static void lc_messages_S(int X, int k) } if (m == lc_messages_count[k]) { /* new for this nl_item */ if (m > 255) { - printf("too many nl_item %d entries in lc_messages\n", k); - exit(EXIT_FAILURE); + error_msg("too many nl_item %d entries in lc_messages", k); } lc_messages_item[k][m] = j; ++lc_messages_count[k]; } -/* printf("\\x%02x", m); */ +/* verbose_msg(VDETAIL, "\\x%02x", m); */ lc_messages_uniq_X[lc_messages_uniq][k] = m; } @@ -1236,7 +1256,7 @@ static void do_lc_messages(void) k = 0; if (!setlocale(LC_ALL, locales[i].glibc_name)) { - printf("setlocale(LC_ALL,%s) failed!\n", + verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n", locales[i].glibc_name); } @@ -1273,13 +1293,12 @@ static void lc_ctype_S(int X, int k) } if (m == lc_ctype_count[k]) { /* new for this nl_item */ if (m > 255) { - printf("too many nl_item %d entries in lc_ctype\n", k); - exit(EXIT_FAILURE); + error_msg("too many nl_item %d entries in lc_ctype", k); } lc_ctype_item[k][m] = j; ++lc_ctype_count[k]; } -/* printf("\\x%02x", m); */ +/* verbose_msg(VDETAIL, "\\x%02x", m); */ lc_ctype_uniq_X[lc_ctype_uniq][k] = m; } @@ -1296,7 +1315,7 @@ static void do_lc_ctype(void) k = 0; if (!setlocale(LC_ALL, locales[i].glibc_name)) { - printf("setlocale(LC_ALL,%s) failed!\n", + verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n", locales[i].glibc_name); } diff --git a/extra/locale/gen_mmap.c b/extra/locale/gen_mmap.c index f9bce022c..1cf0bb9e6 100644 --- a/extra/locale/gen_mmap.c +++ b/extra/locale/gen_mmap.c @@ -127,7 +127,7 @@ int main(void) unsigned char *p; if (!(fp = fopen("locale.mmap", "w"))) { - printf("error - can't open locale.mmap for writing!"); + printf("cannot open locale.mmap for writing!"); return EXIT_FAILURE; } diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c index c6db41231..20f8f648b 100644 --- a/extra/locale/gen_wc8bit.c +++ b/extra/locale/gen_wc8bit.c @@ -103,7 +103,7 @@ int main(int argc, char **argv) } if (!(out = fopen("c8tables.h","w"))) { - printf("error: couldn't open file \"c8tables.h\"\n"); + printf("cannot open output file 'c8tables.h'!\n"); return EXIT_FAILURE; } @@ -173,7 +173,7 @@ int main(int argc, char **argv) codeset_index[0] = 0; while (--argc) { if (!(fp = fopen(*++argv,"r"))) { - printf("error: couldn't open file \"%s\"\n", *argv); + printf("cannot open file \"%s\"\n", *argv); return EXIT_FAILURE; } printf("processing %s... ", *argv); diff --git a/extra/locale/gen_wctype.c b/extra/locale/gen_wctype.c index 085ec51b1..a0542e609 100644 --- a/extra/locale/gen_wctype.c +++ b/extra/locale/gen_wctype.c @@ -130,7 +130,7 @@ enum { #define mywalnum(x) __CTYPE_isalnum(d) #define mywalpha(x) __CTYPE_isalpha(d) -#define mywblank(x) __CTYPE_isblank(d) +#define mywblank(x) __CTYPE_isblank(d) #define mywcntrl(x) __CTYPE_iscntrl(d) #define mywdigit(x) __CTYPE_isdigit(d) #define mywgraph(x) __CTYPE_isgraph(d) @@ -159,6 +159,8 @@ typedef struct { unsigned char *ut; } table_data; +static unsigned verbose; +#define verbose_msg(msg...) if (verbose) fprintf(stderr, msg) void output_table(FILE *fp, const char *name, table_data *tbl) { @@ -200,7 +202,7 @@ void output_table(FILE *fp, const char *name, table_data *tbl) static void dump_table_data(table_data *tbl) { - printf("ii_shift = %d ti_shift = %d\n" + verbose_msg("ii_shift = %d ti_shift = %d\n" "ii_len = %d ti_len = %d ut_len = %d\n" "total = %d\n", tbl->ii_shift, tbl->ti_shift, @@ -231,10 +233,11 @@ int main(int argc, char **argv) uldiff_entry uldiff[MAXTO]; table_data cttable; table_data ultable; +#if 0 table_data combtable; table_data widthtable; long int last_comb = 0; - +#endif unsigned char wct[(RANGE/2)+1]; /* wctype table (nibble per wchar) */ unsigned char ult[RANGE+1]; /* upper/lower table */ unsigned char combt[(RANGE/4)+1]; /* combining */ @@ -269,22 +272,32 @@ int main(int argc, char **argv) INIT_TYPENAME(cntrl_space_blank); INIT_TYPENAME(cntrl_nonspace); + memset(&cttable, 0, sizeof(table_data)); + memset(&ultable, 0, sizeof(table_data)); +#if 0 + memset(combtable, 0, sizeof table_data); + memset(widthtable, 0, sizeof table_data); +#endif setvbuf(stdout, NULL, _IONBF, 0); while (--argc) { - if (!setlocale(LC_CTYPE, *++argv)) { - printf("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv); + ++argv; + if (!strcmp(*argv, "-v")) { + ++verbose; + continue; + } else if (!setlocale(LC_CTYPE, *argv)) { + verbose_msg("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv); continue; } if (!(totitle = wctrans("totitle"))) { - printf("no totitle transformation.\n"); + verbose_msg("no totitle transformation.\n"); } if (!(is_comb = wctype("combining"))) { - printf("no combining wctype.\n"); + verbose_msg("no combining wctype.\n"); } if (!(is_comb3 = wctype("combining_level3"))) { - printf("no combining_level3 wctype.\n"); + verbose_msg("no combining_level3 wctype.\n"); } if (!built) { @@ -344,9 +357,9 @@ int main(int argc, char **argv) #if 0 if (iswspace(c)) { if (iswblank(c)) { - printf("%#8x : space blank\n", c); + verbose_msg("%#8x : space blank\n", c); } else { - printf("%#8x : space\n", c); + verbose_msg("%#8x : space\n", c); } } #endif @@ -368,7 +381,7 @@ int main(int argc, char **argv) if (isspace(c)) ++glibc; glibc <<= 1; if (isupper(c)) ++glibc; glibc <<= 1; if (isxdigit(c)) ++glibc; - printf("%#8x : ctype %#4x\n", c, glibc); + verbose_msg("%#8x : ctype %#4x\n", c, glibc); } #endif @@ -407,14 +420,14 @@ int main(int argc, char **argv) if (mywxdigit(c)) ++mine; if (glibc != mine) { - printf("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d); + verbose_msg("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d); return EXIT_FAILURE; } #if 0 if (iswctype(c,is_comb) || iswctype(c,is_comb3)) { /* if (!iswpunct(c)) { */ - printf("%#8x : %d %d %#4x\n", + verbose_msg("%#8x : %d %d %#4x\n", c, iswctype(c,is_comb),iswctype(c,is_comb3), glibc); /* } */ } @@ -422,10 +435,10 @@ int main(int argc, char **argv) #if 0 if (iswctype(c,is_comb) || iswctype(c,is_comb3)) { if (!last_comb) { - printf("%#8x - ", c); + verbose_msg("%#8x - ", c); last_comb = c; } else if (last_comb + 1 < c) { - printf("%#8x\n%#8x - ", last_comb, c); + verbose_msg("%#8x\n%#8x - ", last_comb, c); last_comb = c; } else { last_comb = c; @@ -451,7 +464,7 @@ int main(int argc, char **argv) ult[c] = 0; if (l || u) { if ((l != (short)l) || (u != (short)u)) { - printf("range assumption error! %x %ld %ld\n", c, l, u); + verbose_msg("range assumption error! %x %ld %ld\n", c, l, u); return EXIT_FAILURE; } for (i=0 ; i < ul_count ; i++) { @@ -463,7 +476,7 @@ int main(int argc, char **argv) uldiff[ul_count].u = u; ++ul_count; if (ul_count > MAXTO) { - printf("too many touppers/tolowers!\n"); + verbose_msg("too many touppers/tolowers!\n"); return EXIT_FAILURE; } found: @@ -472,10 +485,10 @@ int main(int argc, char **argv) } for (i = 0 ; i < 16 ; i++) { - printf("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]); + verbose_msg("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]); } - printf("optimizing is* table..\n"); + verbose_msg("optimizing is* table..\n"); n = -1; smallest = SIZE_MAX; cttable.ii = NULL; @@ -488,9 +501,9 @@ int main(int argc, char **argv) /* break; */ } } - printf("smallest = %zu\n", smallest); + verbose_msg("smallest = %zu\n", smallest); if (!(cttable.ii = malloc(smallest))) { - printf("couldn't allocate space!\n"); + verbose_msg("couldn't allocate space!\n"); return EXIT_FAILURE; } smallest = SIZE_MAX; @@ -499,7 +512,7 @@ int main(int argc, char **argv) - printf("optimizing u/l-to table..\n"); + verbose_msg("optimizing u/l-to table..\n"); smallest = SIZE_MAX; ultable.ii = NULL; for (i=0 ; i < 14 ; i++) { @@ -511,11 +524,11 @@ int main(int argc, char **argv) /* break; */ } } - printf("%zu (smallest) + %zu (u/l diffs) = %zu\n", + verbose_msg("%zu (smallest) + %zu (u/l diffs) = %zu\n", smallest, 4 * ul_count, smallest + 4 * ul_count); - printf("smallest = %zu\n", smallest); + verbose_msg("smallest = %zu\n", smallest); if (!(ultable.ii = malloc(smallest))) { - printf("couldn't allocate space!\n"); + verbose_msg("couldn't allocate space!\n"); return EXIT_FAILURE; } smallest = SIZE_MAX; @@ -523,7 +536,7 @@ int main(int argc, char **argv) #if 0 - printf("optimizing comb table..\n"); + verbose_msg("optimizing comb table..\n"); smallest = SIZE_MAX; combtable.ii = NULL; for (i=0 ; i < 14 ; i++) { @@ -535,9 +548,9 @@ int main(int argc, char **argv) /* break; */ } } - printf("smallest = %zu\n", smallest); + verbose_msg("smallest = %zu\n", smallest); if (!(combtable.ii = malloc(smallest))) { - printf("couldn't allocate space!\n"); + verbose_msg("couldn't allocate space!\n"); return EXIT_FAILURE; } smallest = SIZE_MAX; @@ -547,7 +560,7 @@ int main(int argc, char **argv) #if 0 - printf("optimizing width table..\n"); + verbose_msg("optimizing width table..\n"); smallest = SIZE_MAX; widthtable.ii = NULL; for (i=0 ; i < 14 ; i++) { @@ -559,9 +572,9 @@ int main(int argc, char **argv) /* break; */ } } - printf("smallest = %zu\n", smallest); + verbose_msg("smallest = %zu\n", smallest); if (!(widthtable.ii = malloc(smallest))) { - printf("couldn't allocate space!\n"); + verbose_msg("couldn't allocate space!\n"); return EXIT_FAILURE; } smallest = SIZE_MAX; @@ -570,7 +583,7 @@ int main(int argc, char **argv) #endif #if 0 - printf("optimizing comb3 table..\n"); + verbose_msg("optimizing comb3 table..\n"); smallest = SIZE_MAX; comb3table.ii = NULL; for (i=0 ; i < 14 ; i++) { @@ -582,9 +595,9 @@ int main(int argc, char **argv) /* break; */ } } - printf("smallest = %zu\n", smallest); + verbose_msg("smallest = %zu\n", smallest); if (!(comb3table.ii = malloc(smallest))) { - printf("couldn't allocate space!\n"); + verbose_msg("couldn't allocate space!\n"); return EXIT_FAILURE; } smallest = SIZE_MAX; @@ -594,10 +607,12 @@ int main(int argc, char **argv) dump_table_data(&cttable); dump_table_data(&ultable); +#if 0 dump_table_data(&combtable); +#endif } - printf("verifying for %s...\n", *argv); + verbose_msg("verifying for %s...\n", *argv); #if RANGE == 0xffffU for (c=0 ; c <= 0xffffUL ; c++) #else @@ -683,9 +698,9 @@ int main(int argc, char **argv) if (mywxdigit(c)) ++mine; if (glibc != mine) { - printf("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d); + verbose_msg("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d); if (c < 0x30000UL) { - printf("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1); + verbose_msg("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1); } } upper = lower = u = c; @@ -706,32 +721,32 @@ int main(int argc, char **argv) } if (towupper(c) != upper) { - printf("%#8x : towupper glibc %#4x != %#4x mine\n", + verbose_msg("%#8x : towupper glibc %#4x != %#4x mine\n", c, towupper(c), upper); } if (towlower(c) != lower) { - printf("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n", + verbose_msg("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n", c, towlower(c), lower, i0); } if (totitle && ((tt = towctrans(c, totitle)) != upper)) { - printf("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n", + verbose_msg("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n", c, tt, upper, i0); } } - if ((c & 0xfff) == 0xfff) printf("."); + if ((c & 0xfff) == 0xfff) verbose_msg("."); } - printf("done\n"); + verbose_msg("done\n"); } - if (1) { + if (built) { FILE *fp; if (!(fp = fopen("wctables.h", "w"))) { - printf("couldn't open wctables.h!\n"); + verbose_msg("cannot open output file 'wctables.h'!\n"); return EXIT_FAILURE; } @@ -756,13 +771,13 @@ int main(int argc, char **argv) fprintf(fp, "#endif /* WANT_WCuplow_diff_data */\n\n"); -/* output_table(fp, "comb", &combtable); */ -/* output_table(fp, "width", &widthtable); */ +/* output_table(fp, "comb", &combtable); */ +/* output_table(fp, "width", &widthtable); */ fclose(fp); } - return EXIT_SUCCESS; + return !built; } size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl) @@ -806,7 +821,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl) } #if 1 else if (memcmp(ti[i-1], ti[i], blocksize) > 0) { - printf("bad sort %i!\n", i); + verbose_msg("bad sort %i!\n", i); abort(); } #endif @@ -835,7 +850,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl) shift2 = j; smallest = t; if (!tbl->ii) { - printf("ishift %zu tshift %zu size %zu\n", + verbose_msg("ishift %zu tshift %zu size %zu\n", shift2, shift, t); } /* } else { */ @@ -860,7 +875,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl) } } else { ++recurse; - printf("setting ishift %zu tshift %zu\n", + verbose_msg("setting ishift %zu tshift %zu\n", shift2, shift); newopt(uit, numblocks, shift2, tbl); --recurse; @@ -874,3 +889,4 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl) } return smallest; } +/* vi: set sw=4 ts=4: */ diff --git a/extra/locale/lmmtolso.c b/extra/locale/lmmtolso.c index a1876a7dc..2437a8f69 100644 --- a/extra/locale/lmmtolso.c +++ b/extra/locale/lmmtolso.c @@ -14,18 +14,18 @@ int main(void) size_t i; if (!(lmm = fopen("locale.mmap", "r"))) { - printf("can't open locale.mmap!\n"); + printf("cannot open locale.mmap!\n"); return EXIT_FAILURE; } if (fstat(fileno(lmm), &fd_stat)) { - printf("can't stat locale.mmap!\n"); + printf("cannot stat locale.mmap!\n"); fclose(lmm); return EXIT_FAILURE; } if (!(lso = fopen("locale_data.c", "w"))) { - printf("can't open locale_data.c!\n"); + printf("cannot open locale_data.c!\n"); fclose(lmm); return EXIT_FAILURE; } diff --git a/extra/scripts/gen_bits_syscall_h.sh b/extra/scripts/gen_bits_syscall_h.sh index d4adb0fad..f6353baa2 100755 --- a/extra/scripts/gen_bits_syscall_h.sh +++ b/extra/scripts/gen_bits_syscall_h.sh @@ -22,16 +22,11 @@ case $CC in *) CC_SYSNUM_ARGS="-dN" ;; esac -# Most syscall numbers have names like '__NR_open', which become names -# like 'SYS_open'. Some of the ARM syscalls have names like -# '__ARM_NR_set_tls', which we transform into names like -# 'SYS_ARM_set_tls'. - ( echo "#include <asm/unistd.h>"; echo "#include <asm/unistd.h>" | $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - | - sed -ne 's/^[ ]*#define[ ]*__\([A-Za-z0-9_]*\)NR_\([A-Za-z0-9_]*\).*/UCLIBC_\1NR_\2 __\1NR_\2/gp' \ - -e 's/^[ ]*#undef[ ]*__\([A-Za-z0-9_]*\)NR_\([A-Za-z0-9_]*\).*/UNDEFUCLIBC_\1NR_\2 __\1NR_\2/gp' # needed to strip out any kernel-internal defines + sed -ne 's/^[ ]*#define[ ]*\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/UCLIBC\1\2 \1\2/gp' \ + -e 's/^[ ]*#undef[ ]*\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/UNDEFUCLIBC\1\2 \1\2/gp' # needed to strip out any kernel-internal defines ) | $CC -E $INCLUDE_OPTS - | ( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ; @@ -42,10 +37,10 @@ $CC -E $INCLUDE_OPTS - | echo "#ifndef _SYSCALL_H" ; echo "# error \"Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead.\"" ; echo "#endif" ; echo ; - sed -ne 's/^UCLIBC_\([A-Za-z0-9_]*\)NR_\([A-Za-z0-9_]*\) *\(.*\)/#undef __\1NR_\2\ -#define __\1NR_\2 \3\ -#define SYS_\1\2 __\1NR_\2/gp' \ - -e 's/^UNDEFUCLIBC_\([A-Za-z0-9_]*\)NR_\([A-Za-z0-9_]*\).*/#undef __\1NR_\2/gp' + sed -ne 's/^UCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\) *\(.*\)/#undef \1\2\ +#define \1\2 \3\ +#define SYS_\2 \1\2/gp' \ + -e 's/^UNDEFUCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/#undef \1\2/gp' echo ; echo "#endif" ; ) diff --git a/extra/scripts/install_headers.sh b/extra/scripts/install_headers.sh index 6d73ad2c6..d38d85327 100755 --- a/extra/scripts/install_headers.sh +++ b/extra/scripts/install_headers.sh @@ -33,12 +33,12 @@ fi ( # We must cd, or else we'll prepend "$1" to filenames! cd "$1" || exit 1 -find ! -name '.' -a ! -path '*/.*' +find ! -name '.' -a ! -path '*/.*' | sed -e 's/^\.\///' -e '/^config\//d' \ + -e '/^config$/d' ) | \ ( IFS='' while read -r filename; do - filename="${filename#./}" if test -d "$1/$filename"; then mkdir -p "$2/$filename" 2>/dev/null else @@ -46,7 +46,7 @@ while read -r filename; do # exactly the same as input. That's ok. # Do not abort the script if unifdef "fails"! "$top_builddir/extra/scripts/unifdef" -UUCLIBC_INTERNAL "$1/$filename" \ - | grep -v '^libc_hidden_proto[ ]*([a-zA-Z0-9_]*)$' >"$2/$filename" + | sed -e '/^\(rtld\|lib\(c\|m\|resolv\|dl\|intl\|rt\|nsl\|util\|crypt\|pthread\)\)_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' >"$2/$filename" fi done ) diff --git a/extra/scripts/randconfig.sh b/extra/scripts/randconfig.sh new file mode 100755 index 000000000..5986a9b12 --- /dev/null +++ b/extra/scripts/randconfig.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# build random configurations +# Usage: +# ARCH=i386 nohup ./extra/scripts/randconfig.sh & sleep 1800 && touch STOP +# +# The above builds random i386 configs and automatically stops after 30 minutes + +test "x$ARCH" = "x" && ARCH=`uname -m` +KCONFIG_ALLCONFIG=.config.allconfig +(echo TARGET_$ARCH=y + echo '# UCLIBC_PREGENERATED_LOCALE_DATA is not set' + echo '# DOMULTI is not set' + echo '# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set' +) > $KCONFIG_ALLCONFIG +export KCONFIG_ALLCONFIG + +i=0 +while test ! -f STOP +do + make $* randconfig > /dev/null + make $* silentoldconfig > /dev/null + if (make $*) 2>&1 >& mk.log + then + : + else + i=`expr $i + 1` + num=`printf "%.5d" $i` + mv .config FAILED.$num.config + mv mk.log FAILED.$num.log + fi + make distclean > /dev/null || true +done +rm -f STOP |