summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-03-06 09:53:49 +0100
committerWerner Koch <wk@gnupg.org>2015-03-06 10:36:24 +0100
commit4441e96801fdc4c900abae8c0aa0b53e2e26e079 (patch)
treeb77610e0d70076527b767f8b6c777ac584209898
parent0f814d4c4a285573eef2391c70e21cf8126cafcb (diff)
downloadlibgpg-error-4441e96801fdc4c900abae8c0aa0b53e2e26e079.tar.gz
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 <wk@gnupg.org>
-rw-r--r--README4
-rw-r--r--src/Makefile.am3
-rw-r--r--src/mkheader.c50
-rw-r--r--src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h (renamed from src/syscfg/lock-obj-pub.i586-pc-linux-gnu.h)2
4 files changed, 51 insertions, 8 deletions
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.i686-pc-linux-gnu.h
index fc2d132..b97273b 100644
--- a/src/syscfg/lock-obj-pub.i586-pc-linux-gnu.h
+++ b/src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h
@@ -1,4 +1,4 @@
-## lock-obj-pub.i586-pc-linux-gnu.h
+## 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