+2009-07-01 Steven Schubiger <stsc@member.fsf.org>
+
+ * Makefile.am: Add build_info.pl to EXTRA_DIST.
+
+ * build_info.pl: Generate build_info.c from data.
+
2009-06-14 Micah Cowan <micah@cowan.name>
* po/Makefile.in.in (distclean): remove en_US.po, too.
# Makefile for `Wget' utility
# Copyright (C) 1995, 1996, 1997, 2006, 2007,
-# 2008 Free Software Foundation, Inc.
+# 2008, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
EXTRA_DIST = ChangeLog.README configure.bat MAILING-LIST \
msdos/ChangeLog msdos/config.h msdos/Makefile.DJ \
- msdos/Makefile.WC ABOUT-NLS autogen.sh
+ msdos/Makefile.WC ABOUT-NLS autogen.sh \
+ build_info.pl
CLEANFILES = *~ *.bak $(DISTNAME).tar.gz
--- /dev/null
+#!/usr/bin/perl
+
+# Generate build_info.c.
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+use warnings;
+
+use FindBin qw($Bin);
+use File::Spec ();
+
+my $file = File::Spec->catfile($Bin, 'src', 'build_info.c.in');
+
+{
+ my $data = parse_config();
+ output_code($data);
+}
+
+sub parse_config
+{
+ my (%block, @defines, %feature);
+
+ open(my $fh, '<', $file) or die "Cannot open $file: $!";
+ my $cfg = do { local $/; <$fh> };
+ close($fh);
+
+ while ($cfg =~ /^\ *? (\w+) (?:\s+?)? (\w+?)? \s*$/gmx) {
+ $feature{$1} = $2 || '_MISSING';
+ push @defines, $1;
+ }
+ while ($cfg =~ /^(\ *? \#\w+? \s+? (\w+) .+ \#\w+)/gmsx) {
+ $block{$2} = $1;
+ }
+
+ my %data = (
+ block => \%block,
+ defines => \@defines,
+ feature => \%feature,
+ );
+
+ return \%data;
+}
+
+sub output_code
+{
+ my ($block, $defines, $feature) =
+ map $_[0]->{$_}, qw(block defines feature);
+
+ print do { local $/; <DATA> }, "\n";
+ print <<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}",
+#endif
+EOC
+ }
+ else {
+ push @output, <<EOC;
+$block->{$define}
+EOC
+ }
+ }
+ print join "\n", @output;
+ print <<EOC;
+
+ /* sentinel value */
+ NULL
+};
+
+
+EOC
+}
+
+__DATA__
+/* Autogenerated by build_info.pl - DO NOT EDIT */
+
+/* This stores global variables that are initialized with
+ preprocessor declarations for output with the --version flag.
+
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+ 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. */
+
+#include "wget.h"
+#include <stdio.h>
+2009-07-01 Steven Schubiger <stsc@member.fsf.org>
+
+ * Makefile.am: Add a rule to generate build_info.c and list
+ the build_info.c.in file in EXTRA_DIST. Adjust elsewhere
+ where needed.
+
+ * build_info.c: Remove this static source file.
+
+ * build_info.c.in: Data for generation of build_info.c.
+
2009-06-29 Micah Cowan <micah@cowan.name>
* html-url.c (append_url): Quote some more arguments that might
# Makefile for `wget' utility
# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-# 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBINTL@ @LIBS@
bin_PROGRAMS = wget
-wget_SOURCES = build_info.c cmpt.c connect.c convert.c cookies.c ftp.c \
+wget_SOURCES = cmpt.c connect.c convert.c cookies.c ftp.c \
css.l css-url.c css-tokens.h \
ftp-basic.c ftp-ls.c hash.c host.c html-parse.c html-url.c \
http.c init.c log.c main.c netrc.c progress.c ptimer.c \
http.h http-ntlm.h init.h log.h mswindows.h netrc.h \
options.h progress.h ptimer.h recur.h res.h retr.h \
spider.h ssl.h sysdep.h url.h utils.h wget.h
-nodist_wget_SOURCES = version.c
+nodist_wget_SOURCES = build_info.c version.c
EXTRA_wget_SOURCES = mswindows.c
LDADD = $(LIBOBJS) ../lib/libgnu.a @MD5_LDADD@
AM_CPPFLAGS = -I$(top_srcdir)/lib @MD5_CPPFLAGS@
../md5/libmd5.a:
cd ../lib && $(MAKE) $(AM_MAKEFLAGS)
+build_info.c: $(wget_SOURCES) $(LDADD) $(srcdir)/Makefile.am
+ perl $(top_srcdir)/build_info.pl > $@
+
ESCAPEQUOTE = sed -e 's/[\\"]/\\&/g' -e 's/\\"/"/' -e 's/\\";$$/";/'
version.c: $(wget_SOURCES) $(LDADD) $(srcdir)/Makefile.am
echo '/* version.c */' > $@
check_LIBRARIES = libunittest.a
libunittest_a_SOURCES = $(wget_SOURCES) test.c test.h
-nodist_libunittest_a_SOURCES = version.c
+nodist_libunittest_a_SOURCES = build_info.c version.c
libunittest_a_CPPFLAGS = -DTESTING -I$(top_srcdir)/lib
libunittest_a_LIBADD = $(LIBOBJS)
+EXTRA_DIST = build_info.c.in
-CLEANFILES = *~ *.bak core core.[0-9]* version.c
+CLEANFILES = *~ *.bak core core.[0-9]* build_info.c version.c
+++ /dev/null
-/* This stores global variables that are initialized with
- preprocessor declarations for output with the --version flag.
-
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-
-This file is part of GNU Wget.
-
-GNU Wget is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-GNU Wget is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Wget. If not, see <http://www.gnu.org/licenses/>.
-
-Additional permission under GNU GPL version 3 section 7
-
-If you modify this program, or any covered work, by linking or
-combining it with the OpenSSL project's OpenSSL library (or a
-modified version of that library), containing parts covered by the
-terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
-grants you additional permission to convey the resulting work.
-Corresponding Source for a non-source form of such a combination
-shall include the source code for the parts of OpenSSL used as well
-as that of the covered work. */
-
-#include "wget.h"
-#include <stdio.h>
-
-const char* (compiled_features[]) =
-{
-
-#ifdef ENABLE_DIGEST
- "+digest",
-#else
- "-digest",
-#endif
-
-#ifdef ENABLE_IPV6
- "+ipv6",
-#else
- "-ipv6",
-#endif
-
-#ifdef ENABLE_NLS
- "+nls",
-#else
- "-nls",
-#endif
-
-#ifdef ENABLE_NTLM
- "+ntlm",
-#else
- "-ntlm",
-#endif
-
-#ifdef ENABLE_OPIE
- "+opie",
-#else
- "-opie",
-#endif
-
-#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
-
-#ifdef HAVE_SSL
- "+https",
-#else
- "-https",
-#endif
-
-#ifdef HAVE_LIBGNUTLS
- "+gnutls",
-#else
- "-gnutls",
-#endif
-
-#ifdef HAVE_LIBSSL
- "+openssl",
-#else
- "-openssl",
-#endif
-
-#ifdef HAVE_GETTEXT
- "+gettext",
-#else
- "-gettext",
-#endif
-
-#ifdef ENABLE_IRI
- "+iri",
-#else
- "-iri",
-#endif
-
- /* sentinel value */
- NULL
-};
-
-
--- /dev/null
+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
+HAVE_GETTEXT gettext
+ENABLE_IRI iri
+
+#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