From af100a3c3e02d8aa45ffc8efde39abf7238e333e Mon Sep 17 00:00:00 2001 From: Steven Schubiger Date: Wed, 1 Jul 2009 23:59:57 +0200 Subject: [PATCH] Generate build_info.c automatically. --- ChangeLog | 6 +++ Makefile.am | 5 +- build_info.pl | 107 ++++++++++++++++++++++++++++++++++++++++ src/ChangeLog | 10 ++++ src/Makefile.am | 14 ++++-- src/build_info.c | 117 -------------------------------------------- src/build_info.c.in | 25 ++++++++++ 7 files changed, 160 insertions(+), 124 deletions(-) create mode 100755 build_info.pl delete mode 100644 src/build_info.c create mode 100644 src/build_info.c.in diff --git a/ChangeLog b/ChangeLog index 659415aa..187914cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-07-01 Steven Schubiger + + * Makefile.am: Add build_info.pl to EXTRA_DIST. + + * build_info.pl: Generate build_info.c from data. + 2009-06-14 Micah Cowan * po/Makefile.in.in (distclean): remove en_US.po, too. diff --git a/Makefile.am b/Makefile.am index d5b415c7..25e30cf0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ # 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 @@ -38,6 +38,7 @@ SUBDIRS = lib md5 src doc po tests util windows 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 diff --git a/build_info.pl b/build_info.pl new file mode 100755 index 00000000..5766a254 --- /dev/null +++ b/build_info.pl @@ -0,0 +1,107 @@ +#!/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 . + +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 $/; }, "\n"; + print <{$define}) { + push @output, <{$define}", +#else + "-$feature->{$define}", +#endif +EOC + } + else { + push @output, <{$define} +EOC + } + } + print join "\n", @output; + print < diff --git a/src/ChangeLog b/src/ChangeLog index ac22d75e..2d54cb34 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2009-07-01 Steven Schubiger + + * 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 * html-url.c (append_url): Quote some more arguments that might diff --git a/src/Makefile.am b/src/Makefile.am index 58e9b545..a225e8f6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ # 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 @@ -39,7 +39,7 @@ DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(local 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 \ @@ -50,7 +50,7 @@ wget_SOURCES = build_info.c cmpt.c connect.c convert.c cookies.c ftp.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@ @@ -61,6 +61,9 @@ 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 */' > $@ @@ -77,8 +80,9 @@ version.c: $(wget_SOURCES) $(LDADD) $(srcdir)/Makefile.am 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 diff --git a/src/build_info.c b/src/build_info.c deleted file mode 100644 index 89ae74f8..00000000 --- a/src/build_info.c +++ /dev/null @@ -1,117 +0,0 @@ -/* 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 . - -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 - -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 -}; - - diff --git a/src/build_info.c.in b/src/build_info.c.in new file mode 100644 index 00000000..90784a5d --- /dev/null +++ b/src/build_info.c.in @@ -0,0 +1,25 @@ +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 -- 2.39.2