^mutt_dotlock(\.c)?$
^mutt_md5$
^patchlist\.c$
+^conststrings\.c$
^pgpewrap|pgpring$
^reldate\.h$
^smime_keys$
+^txt2c$
^stamp-doc-rc$
^doc/instdoc$
^doc/manual\.(txt|xml|aux|log|out|tex|pdf)$
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 = \
mutt_dotlock.c: dotlock.c
cp $(srcdir)/dotlock.c mutt_dotlock.c
+# If this fails, we will fall back to the implementation in txt2c.sh
+txt2c: txt2c.c
+ -$${NATIVECC-$(CC)} -o $@ $<
+
+conststrings.c: txt2c config.status
+ ( \
+ $(CC) -v || \
+ $(CC) --version || \
+ $(CC) -V || \
+ echo "unknown compiler"; \
+ ) 2>&1 | ./txt2c.sh cc_version >conststrings_c
+ echo "$(CFLAGS)" | ./txt2c.sh cc_cflags >>conststrings_c
+ grep ac_cs_config= config.status | \
+ cut -d= -f2- | \
+ sed -e 's/^"//' -e 's/"$$//' | ./txt2c.sh 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
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;
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
# 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
--- /dev/null
+#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;
+}
--- /dev/null
+#!/bin/sh
+
+txt2c_fallback () {
+ # consumes stdin
+
+ # declaration
+ echo "unsigned char $1[] = "
+
+ # initializer - filter out unwanted characters, then convert problematic
+ # or odd-looking sequences. The result is a sequence of quote-bounded
+ # C strings, which the compiler concatenates into a single C string.
+ tr -c '\011\012\015\040[!-~]' '?' |
+ sed \
+ -e 's/\\/\\\\/g' \
+ -e 's/"/\\"/g' \
+ -e 's/??/\?\?/g' \
+ -e 's/\t/\\t/'g \
+ -e 's/\r/\\r/g' \
+ -e 's/^/ "/g' \
+ -e 's/$/\\n"/g'
+ echo ";"
+}
+
+./txt2c test </dev/null >/dev/null 2>&1 &&
+./txt2c "$1" ||
+txt2c_fallback "$1"