pulled from

http://www.eglibc.org/archives/patches/msg01043.html


Upstream-Status: Pending
Signed-off-by: Khem


This patch builds on the menuconfig patch for EGLIBC.


There are a few options that have non-boolean types, that would benefit from the new 'make *config' support:

EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE (int)
EGLIBC_NSSWITCH_FIXED_CONFIG (string)
EGLIBC_NSSWITCH_FIXED_FUNCTIONS (string)


The patch converts these to real options in libc/option-groups.def. Also, libc/scripts/option-groups.awk is modified to output a '#define' line for int, hex, or string options encountered in the config file.

In the post-processing script config-postproc.pl, a small change is needed: for any boolean option FOO that is implicitly disabled in the kconfig output, make sure that option is indeed a boolean before printing the explicit OPTION_FOO=n.

Finally, libc/malloc/Makefile passes __OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE as a CPPFLAGS, which is not necessary anymore because this macro will now be present in the generated header.

attached is the updated patch to address above issues.

Steve

--
Steve Longerbeam | Senior Embedded Engineer, ESD Services
Mentor Embedded(tm) | 46871 Bayside Parkway, Fremont, CA 94538
P 510.354.5838 | M 408.410.2735
Nucleus(r) | Linux(r) | Android(tm) | Services | UI | Multi-OS


Index: libc/malloc/Makefile
===================================================================
--- libc.orig/malloc/Makefile	2012-01-04 22:06:18.000000000 -0800
+++ libc/malloc/Makefile	2012-05-09 19:35:28.598682105 -0700
@@ -48,10 +48,6 @@
 ifeq ($(OPTION_EGLIBC_MEMUSAGE),y)
 extra-libs = libmemusage
 extra-libs-others = $(extra-libs)
-
-ifdef OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
-CPPFLAGS-memusage += -D__OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE=$(OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE)
-endif
 endif
 
 libmemusage-routines = memusage
Index: libc/option-groups.def
===================================================================
--- libc.orig/option-groups.def	2012-05-09 19:33:48.398677256 -0700
+++ libc/option-groups.def	2012-05-09 19:35:28.610682107 -0700
@@ -513,8 +513,11 @@
        the `memusage' and `memusagestat' utilities.
        These components provide memory profiling functions.
 
-       EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
-
+config EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+   int "Memory profiling library buffer size"
+   depends on EGLIBC_MEMUSAGE
+   default "32768"
+   help
        Libmemusage library buffers the profiling data in memory
        before writing it out to disk.  By default, the library
        allocates 1.5M buffer, which can be substantial for some
@@ -553,8 +556,11 @@
        'option-groups.config' file must set the following two
        variables:
 
-       EGLIBC_NSSWITCH_FIXED_CONFIG
-
+config EGLIBC_NSSWITCH_FIXED_CONFIG
+   string "Nsswitch fixed config filename"
+   depends on !EGLIBC_NSSWITCH
+   default ""
+   help
           Set this to the name of a file whose contents observe the
           same syntax as an ordinary '/etc/nsswitch.conf' file.  The
           EGLIBC build process parses this file just as EGLIBC would
@@ -576,8 +582,11 @@
           you will probably want to delete references to databases not
           needed on your system.
 
-       EGLIBC_NSSWITCH_FIXED_FUNCTIONS
-
+config EGLIBC_NSSWITCH_FIXED_FUNCTIONS
+   string "Nsswitch fixed functions filename"
+   depends on !EGLIBC_NSSWITCH
+   default ""
+   help
           The EGLIBC build process uses this file to decide which
           functions to make available from which service libraries.
           The file 'nss/fixed-nsswitch.functions' serves as a sample
Index: libc/options-config/config-postproc.pl
===================================================================
--- libc.orig/options-config/config-postproc.pl	2012-05-09 19:33:36.530676681 -0700
+++ libc/options-config/config-postproc.pl	2012-05-09 19:35:28.610682107 -0700
@@ -8,7 +8,7 @@
 die "Could not open $ARGV[0]" unless -T $ARGV[0];
 
 sub yank {
-    @option = grep($_ ne $_[0], @option);
+    @option = grep(!($_ =~ /$_[0]\s*=/), @option);
 }
 
 open(DEFAULTS, $defaults) || die "Could not open $defaults\n";
@@ -16,7 +16,7 @@
 # get the full list of available options using the default config file
 $i = 0;
 while (<DEFAULTS>) {
-    if (/^\s*OPTION_(\w+)\s*=/) {
+    if (/^\s*OPTION_(\w+\s*=.*$)/) {
 	$option[$i++] = $1;
     }
 }
@@ -35,8 +35,9 @@
 	s/CONFIG_/OPTION_/g;
 	print;
     } elsif (/^\s*#\s+CONFIG_(\w+) is not set/) {
-	# this is a comment line, change CONFIG_ to OPTION_, remove this
-	# option from option list, and convert to explicit OPTION_FOO=n
+	# this is a comment line for an unset boolean option, change CONFIG_
+	# to OPTION_, remove this option from option list, and convert to
+	# explicit OPTION_FOO=n
 	$opt = $1;
 	yank($opt);
 	s/CONFIG_/OPTION_/g;
@@ -46,9 +47,12 @@
     }
 }
 
-# any options left in @options, are options that were not mentioned in
+# any boolean options left in @options, are options that were not mentioned in
 # the config file, and implicitly that means the option must be set =n,
 # so do that here.
 foreach $opt (@option) {
-    print "OPTION_$opt=n\n";
+    if ($opt =~ /=\s*[yn]/) {
+	$opt =~ s/=\s*[yn]/=n/;
+	print "OPTION_$opt\n";
+    }
 }
Index: libc/scripts/option-groups.awk
===================================================================
--- libc.orig/scripts/option-groups.awk	2012-01-04 22:06:00.000000000 -0800
+++ libc/scripts/option-groups.awk	2012-05-09 19:35:28.610682107 -0700
@@ -46,9 +46,15 @@
                 print "#define __" var " 1"
             else if (vars[var] == "n")
                 print "/* #undef __" var " */"
-            # Ignore variables that don't have boolean values.
-            # Ideally, this would be driven by the types given in
-            # option-groups.def.
+	    else if (vars[var] ~ /^[0-9]+/ ||
+		     vars[var] ~ /^0x[0-9aAbBcCdDeEfF]+/ ||
+		     vars[var] ~ /^\"/)
+		 print "#define __" var " " vars[var]
+	    else
+		print "/* #undef __" var " */"
+            # Ignore variables that don't have boolean, int, hex, or
+	    # string values. Ideally, this would be driven by the types
+	    # given in option-groups.def.
         }
     }
 
