From 4441e96801fdc4c900abae8c0aa0b53e2e26e079 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 6 Mar 2015 09:53:49 +0100 Subject: Add host-triplet aliasing feature to mkheader. * src/Makefile.am (lock_obj_pub): Rename i586-pc-linux-gnu to i686-pc-linux-gnu. Remove i486-pc-linux-gnu. * src/mkheader.c (canon_host_triplet): New. (main): Use it. -- config.sub does not map i{4,5,6}86-pc-linux-gnu to one common triplet. However, they all use the same ABI and thus we do not need several versions of the syscfg files. Signed-off-by: Werner Koch --- README | 4 ++- src/Makefile.am | 3 +- src/mkheader.c | 50 ++++++++++++++++++++++++++--- src/syscfg/lock-obj-pub.i586-pc-linux-gnu.h | 23 ------------- src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h | 23 +++++++++++++ 5 files changed, 73 insertions(+), 30 deletions(-) delete mode 100644 src/syscfg/lock-obj-pub.i586-pc-linux-gnu.h create mode 100644 src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h diff --git a/README b/README index d0a1d47..be7b7dc 100644 --- a/README +++ b/README @@ -116,7 +116,9 @@ need to figure out these values. You may use these commands: If you are using a VPATH build adjust accordingly. If this all works for you (make sure to run the test programs on the target platform), please send the generated file to the gnupg-devel mailing list so that -we can include it in the next release. +we can include it in the next release. Note that in addition to the +aliasing done by config.sub the src/mkheader build tool does some +extra aliasing to avoid having too much identical syscfg files. diff --git a/src/Makefile.am b/src/Makefile.am index 18a4cb7..99c2c53 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,8 +51,7 @@ lock_obj_pub = \ syscfg/lock-obj-pub.hppa-unknown-linux-gnu.h \ syscfg/lock-obj-pub.i486-pc-gnu.h \ syscfg/lock-obj-pub.i486-pc-kfreebsd-gnu.h \ - syscfg/lock-obj-pub.i486-pc-linux-gnu.h \ - syscfg/lock-obj-pub.i586-pc-linux-gnu.h \ + syscfg/lock-obj-pub.i686-pc-linux-gnu.h \ syscfg/lock-obj-pub.m68k-unknown-linux-gnu.h \ syscfg/lock-obj-pub.mips-unknown-linux-gnu.h \ syscfg/lock-obj-pub.mips64el-unknown-linux-gnuabi64.h \ diff --git a/src/mkheader.c b/src/mkheader.c index 9fe0695..3481771 100644 --- a/src/mkheader.c +++ b/src/mkheader.c @@ -23,7 +23,7 @@ #define LINESIZE 1024 static const char *host_os; -static const char *host_triplet; +static char *host_triplet; static char *srcdir; static const char *hdr_version; static const char *hdr_version_number; @@ -63,6 +63,40 @@ xstrdup (const char *string) } +/* Return a malloced string with TRIPLET. If TRIPLET has an alias + return that instead. In general build-aux/config.sub should do the + aliasing but some returned triplets are anyway identical and thus we + use this function to map it to the canonical form. */ +static char * +canon_host_triplet (const char *triplet) +{ + struct { + const char *name; + const char *alias; + } tbl[] = { + {"i486-pc-linux-gnu", "i686-pc-linux-gnu" }, + {"i586-pc-linux-gnu" }, + + { NULL } + }; + int i; + const char *lastalias = NULL; + + for (i=0; tbl[i].name; i++) + { + if (tbl[i].alias) + lastalias = tbl[i].alias; + if (!strcmp (tbl[i].name, triplet)) + { + if (!lastalias) + break; /* Ooops: first entry has no alias. */ + return xstrdup (lastalias); + } + } + return xstrdup (triplet); +} + + /* Parse the supplied config.h file and extract required info. Returns 0 on success. */ static int @@ -481,6 +515,7 @@ main (int argc, char **argv) const char *fname, *s; char *p1, *p2; const char *config_h; + const char *host_triplet_raw; if (argc) { @@ -496,12 +531,14 @@ main (int argc, char **argv) return 1; } host_os = argv[0]; - host_triplet = argv[1]; + host_triplet_raw = argv[1]; fname = argv[2]; config_h = argv[3]; hdr_version = argv[4]; hdr_version_number = argv[5]; + host_triplet = canon_host_triplet (host_triplet_raw); + srcdir = malloc (strlen (fname) + 2 + 1); if (!srcdir) { @@ -554,8 +591,12 @@ main (int argc, char **argv) if (!strcmp (p1, "configure_input")) { s = strrchr (fname, '/'); - printf ("Do not edit. Generated from %s for %s.", - s? s+1 : fname, host_triplet); + printf ("Do not edit. Generated from %s for:\n%*s", + s? s+1 : fname, (int)(p1 - line) + 13, ""); + if (!strcmp (host_triplet, host_triplet_raw)) + printf ("%s", host_triplet); + else + printf ("%s (%s)", host_triplet, host_triplet_raw); fputs (p2, stdout); } else if (!write_special (fname, lnr, p1)) @@ -593,5 +634,6 @@ main (int argc, char **argv) fclose (fp); + xfree (host_triplet); return 0; } diff --git a/src/syscfg/lock-obj-pub.i586-pc-linux-gnu.h b/src/syscfg/lock-obj-pub.i586-pc-linux-gnu.h deleted file mode 100644 index fc2d132..0000000 --- a/src/syscfg/lock-obj-pub.i586-pc-linux-gnu.h +++ /dev/null @@ -1,23 +0,0 @@ -## lock-obj-pub.i586-pc-linux-gnu.h -## File created by gen-posix-lock-obj - DO NOT EDIT -## To be included by mkheader into gpg-error.h - -typedef struct -{ - long _vers; - union { - volatile char _priv[24]; - long _x_align; - long *_xp_align; - } u; -} gpgrt_lock_t; - -#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \ - 0,0,0,0,0,0,0,0, \ - 0,0,0,0,0,0,0,0}}} -## -## Local Variables: -## mode: c -## buffer-read-only: t -## End: -## diff --git a/src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h b/src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h new file mode 100644 index 0000000..b97273b --- /dev/null +++ b/src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h @@ -0,0 +1,23 @@ +## lock-obj-pub.i686-pc-linux-gnu.h +## File created by gen-posix-lock-obj - DO NOT EDIT +## To be included by mkheader into gpg-error.h + +typedef struct +{ + long _vers; + union { + volatile char _priv[24]; + long _x_align; + long *_xp_align; + } u; +} gpgrt_lock_t; + +#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \ + 0,0,0,0,0,0,0,0, \ + 0,0,0,0,0,0,0,0}}} +## +## Local Variables: +## mode: c +## buffer-read-only: t +## End: +## -- cgit v1.2.3