Comments?

# HG changeset patch
# User David Champion <[email protected]>
# Date 1350429193 18000
# Branch HEAD
# Node ID 778e6c6562508f686eb10b143e7911ea6d90dd87
# Parent  70810a88ce9feb66d5c74e7ec3f2a633bd8b5312
Add compiler and configure info to mutt -v output.

This adds txt2c.py 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 778e6c656250 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,6 +94,17 @@
 mutt_dotlock.c: dotlock.c
        cp $(srcdir)/dotlock.c mutt_dotlock.c
 
+conststrings.c: txt2c.py
+       ( \
+               $${CC-cc} --version || \
+               $${CC-cc} -v || \
+               $${CC-cc} -V || \
+               echo "unknown compiler"; \
+       ) 2>/dev/null | python txt2c.py cc_version >conststrings.c
+       grep ac_cs_config= config.status | \
+       cut -d= -f2- | \
+       sed -e 's/^"//' -e 's/"$$//' | python txt2c.py configure_options 
>>conststrings.c
+
 CLEANFILES = mutt_dotlock.c keymap_alldefs.h $(BUILT_SOURCES)
 
 DISTCLEANFILES= flea smime_keys
diff -r 70810a88ce9f -r 778e6c656250 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,9 @@
   exit (0);
 }
 
+extern const char cc_version[];
+extern const char configure_options[];
+
 static void show_version (void)
 {
   struct utsname uts;
@@ -193,6 +196,11 @@
   printf ("\nhcache backend: %s", mutt_hcache_backend ());
 #endif
 
+  puts ("\n\nCompiler:");
+  puts (cc_version);
+
+  printf ("\nConfigure options: %s\n", configure_options);
+
   puts (_("\nCompile options:"));
 
 #ifdef DOMAIN
diff -r 70810a88ce9f -r 778e6c656250 txt2c.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/txt2c.py  Tue Oct 16 18:13:13 2012 -0500
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+def txt2c(sym, txt, per_line = 12):
+       print 'const char %s[] = {' % sym
+       off = 0
+       max = len(txt)
+       while off + per_line < max:
+               print '\t' + ', '.join(['0x%02x' % ord(x) for x in txt[off:off 
+ per_line]]) + ','
+               off += per_line
+       print '\t' + ', '.join(['0x%02x' % ord(x) for x in txt[off:]]) + ','
+       print '\t0x00'
+       print '};'
+
+import sys
+txt2c(sys.argv[1], sys.stdin.read().strip())


Reply via email to