Too many things happening at once here.  There are other changes:
* removes the gcc output stanza from muttbug/flea.
* adds cflags (because muttbug showed it)

* On 18 Oct 2012, David Champion wrote: 
> Thanks for the reviews! Changes:
> * Uses a C txt2c instead of Python - no new build prereqs
> * conststrings.c depends on config.status
> * conststrings.c created atomically to avoid race condition under parallel 
> make
> 
> Any other observations?  I'll plan to push this otherwise.
> 
> # HG changeset patch
> # User David Champion <d...@uchicago.edu>
> # Date 1350429193 18000
> # Branch HEAD
> # Node ID 0dc5d40c97c1810159a2c3e7dbb719d1bc92d81e
> # Parent  70810a88ce9feb66d5c74e7ec3f2a633bd8b5312
> Add compiler and configure info to mutt -v output (closes #3537)
> 
> This adds txt2c.c for coding text (on stdin) to a C byte array, and
> adds methods in Makefile(.am) to produce constrings.c, containing these
> two information strings.  main.c is updated to print them.
> 
> diff -r 70810a88ce9f -r 0dc5d40c97c1 Makefile.am
> --- a/Makefile.am     Sun Jul 22 11:15:30 2012 -0700
> +++ b/Makefile.am     Tue Oct 16 18:13:13 2012 -0500
> @@ -17,7 +17,7 @@
>  HCVERSION = hcversion.h
>  endif
>  
> -BUILT_SOURCES = keymap_defs.h patchlist.c reldate.h $(HCVERSION)
> +BUILT_SOURCES = keymap_defs.h patchlist.c reldate.h conststrings.c 
> $(HCVERSION)
>  
>  bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
>  mutt_SOURCES = \
> @@ -94,9 +94,25 @@
>  mutt_dotlock.c: dotlock.c
>       cp $(srcdir)/dotlock.c mutt_dotlock.c
>  
> +txt2c: txt2c.c
> +     $(CC) -o $@ $<
> +
> +conststrings.c: txt2c config.status
> +     ( \
> +             $${CC-cc} --version || \
> +             $${CC-cc} -v || \
> +             $${CC-cc} -V || \
> +             echo "unknown compiler"; \
> +     ) 2>/dev/null | ./txt2c cc_version >conststrings_c
> +     echo "$(CFLAGS)" | ./txt2c cc_cflags >>conststrings_c
> +     grep ac_cs_config= config.status | \
> +     cut -d= -f2- | \
> +     sed -e 's/^"//' -e 's/"$$//' | ./txt2c configure_options 
> >>conststrings_c
> +     mv -f conststrings_c conststrings.c
> +
>  CLEANFILES = mutt_dotlock.c keymap_alldefs.h $(BUILT_SOURCES)
>  
> -DISTCLEANFILES= flea smime_keys
> +DISTCLEANFILES= flea smime_keys txt2c
>  
>  ACLOCAL_AMFLAGS = -I m4
>  
> diff -r 70810a88ce9f -r 0dc5d40c97c1 main.c
> --- a/main.c  Sun Jul 22 11:15:30 2012 -0700
> +++ b/main.c  Tue Oct 16 18:13:13 2012 -0500
> @@ -154,6 +154,24 @@
>    exit (0);
>  }
>  
> +extern const char cc_version[];
> +extern const char cc_cflags[];
> +extern const char configure_options[];
> +
> +static char *
> +rstrip_in_place(char *s)
> +{
> +  char *p;
> +
> +  p = &s[strlen(s)];
> +  if (p == s)
> +    return s;
> +  p--;
> +  while (p >= s && (*p == '\n' || *p == '\r'))
> +    *p-- = '\0';
> +  return s;
> +}
> +
>  static void show_version (void)
>  {
>    struct utsname uts;
> @@ -193,6 +211,16 @@
>    printf ("\nhcache backend: %s", mutt_hcache_backend ());
>  #endif
>  
> +  puts ("\n\nCompiler:");
> +  rstrip_in_place((char *)cc_version);
> +  puts (cc_version);
> +
> +  rstrip_in_place((char *)configure_options);
> +  printf ("\nConfigure options: %s\n", configure_options);
> +
> +  rstrip_in_place((char *)cc_cflags);
> +  printf ("\nCompilation CFLAGS: %s\n", cc_cflags);
> +
>    puts (_("\nCompile options:"));
>  
>  #ifdef DOMAIN
> diff -r 70810a88ce9f -r 0dc5d40c97c1 muttbug.sh.in
> --- a/muttbug.sh.in   Sun Jul 22 11:15:30 2012 -0700
> +++ b/muttbug.sh.in   Tue Oct 16 18:13:13 2012 -0500
> @@ -248,21 +248,6 @@
>       # Please provide more of these if you have any.
>  fi
>  
> -echo 
> -echo "-- Build environment information"
> -echo
> -echo "(Note: This is the build environment installed on the system"
> -echo "muttbug is run on.  Information may or may not match the environment"
> -echo "used to build mutt.)"
> -echo
> -echo "- gcc version information"
> -echo "@CC@"
> -@CC@ -v 2>&1
> -echo
> -echo "- CFLAGS"
> -echo @CFLAGS@
> -
> -
>  echo
>  echo "-- Mutt Version Information"
>  echo
> diff -r 70810a88ce9f -r 0dc5d40c97c1 txt2c.c
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/txt2c.c Tue Oct 16 18:13:13 2012 -0500
> @@ -0,0 +1,37 @@
> +#include <stdio.h>
> +
> +#define per_line 12
> +
> +void
> +txt2c(char *sym, FILE *fp)
> +{
> +     unsigned char buf[per_line];
> +     int i;
> +     int sz = 0;
> +
> +     printf("unsigned char %s[] = {\n", sym);
> +     while (1) {
> +             sz = fread(buf, sizeof(unsigned char), per_line, fp);
> +             if (sz == 0)
> +                     break;
> +             printf("\t");
> +             for (i = 0; i < sz; i++)
> +                     printf("0x%02x, ", buf[i]);
> +             printf("\n");
> +     }
> +
> +     printf("\t0x00\n};\n");
> +}
> +
> +
> +int
> +main(int argc, char *argv[])
> +{
> +     if (argc != 2) {
> +             fprintf(stderr, "usage: %s symbol <textfile >textfile.c\n", 
> argv[0]);
> +             return 2;
> +     }
> +
> +     txt2c(argv[1], stdin);
> +     return 0;
> +}
> 

-- 
David Champion • d...@bikeshed.us

Reply via email to