]> sjero.net Git - wget/commitdiff
build_info.pl improvements, advertise large-file support.
authorMicah Cowan <micah@cowan.name>
Fri, 9 Oct 2009 09:02:39 +0000 (02:02 -0700)
committerMicah Cowan <micah@cowan.name>
Fri, 9 Oct 2009 09:02:39 +0000 (02:02 -0700)
ChangeLog
build-aux/build_info.pl
src/ChangeLog
src/Makefile.am
src/build_info.c.in

index 111460c95f897fcc9451e9dbbc111ba588d61320..f24317b63e16f3e08749e3123602dc7d3f5dc8ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-10-09  Micah Cowan  <micah@cowan.name>
+
+       * build_aux/build_info.pl: Reworked the input format. Eliminated
+       support, and need, for arbitrary #if blocks. Introduced
+       "choices", and explicitly open the .c file rather than print to
+       STDOUT, so we avoid creating the file if we find problems with
+       the input. Options are advertised in alphabetical order.
+
 2009-09-24  Micah Cowan  <micah@cowan.name>
 
        * vms/vms.c: Moved to src/src.c.
index a006b6da0173132028d3f024fe41d9441d6c81a7..372fe42ed2498339eb08c18b2f8477d58d8a961a 100755 (executable)
@@ -20,8 +20,7 @@
 use strict;
 use warnings;
 
-use FindBin qw($Bin);
-use File::Spec ();
+use Carp qw(croak);
 
 my $file = shift @ARGV;
 
@@ -32,59 +31,92 @@ my $file = shift @ARGV;
 
 sub parse_config
 {
-    my (%block, @defines, %feature);
-
-    open(my $fh, '<', $file) or die "Cannot open $file: $!";
-    my $cfg = do { local $/; <$fh> };
-    close($fh);
+    my $features = [];
+    my $choice_key;
+    my $choice = [];
+    my $list = $features;
+
+    open(my $fh, '<', "$file.in") or die "Cannot open $file.in: $!";
+
+    while (<$fh>) {
+        next if /^\s*$/;
+
+        if ($list eq $choice) {
+            unless (s/^\s+//) {
+                $list = $features;
+                push @$features, [$choice_key, $choice];
+                $choice = [];
+                undef $choice_key;
+            }
+        } elsif (/^([A-Za-z0-9_-]+) \s+ choice:\s*$/x) {
+            $choice_key = $1;
+            $list = $choice;
+            next;
+        }
 
-    while ($cfg =~ /^\ *? (\w+) (?:\s+?)? (\w+?)? \s*$/gmx) {
-        $feature{$1} = $2 || '_MISSING';
-        push @defines, $1;
+        if (/^([A-Za-z0-9_-]+) \s+ (.*)$/x) {
+            push @$list, [$1, $2];
+        } else {
+            croak "Can't parse line: $_";
+        }
     }
-    while ($cfg =~ /^(\ *? \#\w+? \s+? (\w+) .+ \#\w+)/gmsx) {
-        $block{$2} = $1;
+
+    if ($list eq $choice) {
+        push @$features, [$choice_key, $choice];
     }
 
-    my %data = (
-        block   => \%block,
-        defines => \@defines,
-        feature => \%feature,
-    );
+    close($fh);
 
-    return \%data;
+    return $features;
 }
 
 sub output_code
 {
-    my ($block, $defines, $feature) =
-      map $_[0]->{$_}, qw(block defines feature);
+    my $features = shift;
 
-    print do { local $/; <DATA> }, "\n";
-    print <<EOC;
+    open(my $fh, '>', "$file") or die "Cannot open $file: $!";
+
+    print $fh do { local $/; <DATA> }, "\n";
+    print $fh <<EOC;
 const char* (compiled_features[]) =
 {
 
 EOC
-    my @output;
-    foreach my $define (@$defines) {
-        if (!exists $block->{$define}) {
-            push @output, <<EOC;
-#ifdef $define
-  "+$feature->{$define}",
-#else
-  "-$feature->{$define}",
+    foreach my $feature (sort { $a->[0] cmp $b->[0] } @$features) {
+        my ($name, $check) = @$feature;
+
+        if (ref $check eq 'ARRAY') {
+            my ($ch_name, $ch_check) = @{ shift @$check };
+            print $fh <<EOC;
+#if $ch_check
+  "+$name/$ch_name",
+EOC
+            foreach my $choice (@$check) {
+                ($ch_name, $ch_check) = @$choice;
+
+                print $fh <<EOC;
+#elif $ch_check
+  "+$name/$ch_name",
+EOC
+            }
+                print $fh <<EOC;
+#else 
+  "-$name",
 #endif
+
 EOC
-        }
-        else {
-            push @output, <<EOC;
-$block->{$define}
+        } else {
+            print $fh <<EOC;
+#if $check
+  "+$name",
+#else
+  "-$name",
+#endif
+
 EOC
         }
     }
-    print join "\n", @output;
-    print <<EOC;
+    print $fh <<EOC;
 
   /* sentinel value */
   NULL
index 37436435381a0e6138834e3b20cd1413e0cf77da..4b22f6a95b126b3f3b8a6d3d855770dadebba194 100644 (file)
@@ -1,3 +1,9 @@
+2009-10-09  Micah Cowan  <micah@cowan.name>
+
+       * build_info.c.in: Adapt to new input format. Added a check for
+       large-file support. Replaced the "openssl" and "gnutls"
+       advertisements with a single "ssl/foo" advertisement.
+
 2009-09-30  Micah Cowan  <micah@cowan.name>
 
        * sysdep.h: Unconditionally include stdbool.h (gnulib has it for
index 44b62fb3270b789bb97361756fff0136432f5b64..e1b997ee4a7dfacc6f990b739646d367f93c717a 100644 (file)
@@ -65,7 +65,7 @@ MD5_LDADD = @MD5_LDADD@
 
 build_info.c: $(srcdir)/Makefile.am $(srcdir)/build_info.c.in
        $(PERL) $(top_srcdir)/build-aux/build_info.pl \
-           $(srcdir)/build_info.c.in > $@
+           $(srcdir)/build_info.c
 
 ESCAPEQUOTE = sed -e 's/[\\"]/\\&/g' -e 's/\\"/"/' -e 's/\\";$$/";/'
 version.c:  $(wget_SOURCES) ../lib/libgnu.a $(MD5_LDADD) \
index 7530dae0dd6a7649d0d986cb6ecf471bccde9017..39311811ace91ff9330ade45755816e070292c7a 100644 (file)
@@ -1,24 +1,18 @@
-ENABLE_DIGEST  digest
-ENABLE_IPV6    ipv6
-ENABLE_NLS     nls
-ENABLE_NTLM    ntlm
-ENABLE_OPIE    opie
-HAVE_MD5
-HAVE_SSL       https
-HAVE_LIBGNUTLS gnutls
-HAVE_LIBSSL    openssl
-ENABLE_IRI     iri
+digest          defined ENABLE_DIGEST
+https           defined HAVE_SSL
+ipv6            defined ENABLE_IPV6
+iri             defined ENABLE_IRI
+large-file      SIZEOF_OFF_T >= 8
 
-#ifdef HAVE_MD5
-#ifdef HAVE_BUILTIN_MD5
-  "+md5/builtin",
-#elif HAVE_OPENSSL_MD5
-  "+md5/openssl",
-#elif HAVE_SOLARIS_MD5
-  "+md5/solaris",
-#else
-#error "md5 set, but no library found!",
-#endif
-#else
-  "-md5",
-#endif
+md5 choice:
+    builtin     defined HAVE_BUILTIN_MD5
+    openssl     defined HAVE_OPENSSL_MD5
+    solaris     defined HAVE_SOLARIS_MD5
+
+nls             defined ENABLE_NLS
+ntlm            defined ENABLE_NTLM
+opie            defined ENABLE_OPIE
+
+ssl choice:
+    openssl     defined HAVE_LIBSSL
+    gnutls      defined HAVE_LIBGNUTLS