Index: libgpg-error-1.22/src/mkheader.c =================================================================== --- libgpg-error-1.22/src/mkheader.c +++ libgpg-error-1.22/src/mkheader.c @@ -17,6 +17,7 @@ #include #include #include +#include #define PGM "mkheader" @@ -64,46 +65,59 @@ } -/* 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. */ +/* Return a malloced string with TRIPLET. The TRIPLET should conform + * to the hostnames in the header file names in src/syscfg. Assume that + * build-aux/config.sub correctly validates the names and try to map it + * to a header hostname. Order is important as "i?86*linux-gnu" + * should be evaluated before "i?86*-gnu" */ static char * canon_host_triplet (const char *triplet) { struct { - const char *name; - const char *alias; + const char *pattern; + const char *host; } tbl[] = { - {"i486-pc-linux-gnu", "i686-pc-linux-gnu" }, - {"i586-pc-linux-gnu" }, - {"i486-pc-gnu", "i686-pc-gnu"}, - {"i586-pc-gnu"}, - {"i486-pc-kfreebsd-gnu", "i686-pc-kfreebsd-gnu"}, - {"i586-pc-kfreebsd-gnu"}, - {"x86_64-pc-linux-gnuhardened1", "x86_64-pc-linux-gnu" }, - {"powerpc-unknown-linux-gnuspe", "powerpc-unknown-linux-gnu" }, + {"aarch64*apple-darwin", "aarch64-apple-darwin"}, + {"aarch64*linux-gnu", "aarch64-unknown-linux-gnu"}, + {"alpha*linux-gnu", "alpha-unknown-linux-gnu"}, + {"arm*apple-darwin", "arm-apple-darwin"}, + {"arm*linux-androideabi", "arm-unknown-linux-androideabi"}, + {"arm*linux-gnueabihf", "arm-unknown-linux-gnueabihf"}, + {"armv6*linux-musleabihf", "armv6-unknown-linux-musleabihf"}, + {"armv5*linux-musleabi", "armv5-unknown-linux-musleabi"}, + {"arm*linux-gnueabi", "arm-unknown-linux-gnueabi"}, + {"hppa*linux-gnu", "hppa-unknown-linux-gnu"}, + {"i?86*freebsd-gnu", "i686-pc-kfreebsd-gnu"}, + {"i?86*linux-gnu", "i686-pc-linux-gnu"}, + {"i?86*-gnu", "i686-pc-gnu"}, + {"m68*linux-gnu", "m68k-unknown-linux-gnu"}, + {"mingw*", "mingw32"}, + {"mips64el*linux-gnuabi64", "mips64el-unknown-linux-gnuabi64"}, + {"mipsel*linux-gnu", "mipsel-unknown-linux-gnu"}, + {"mips*linux-gnu", "mips-unknown-linux-gnu"}, + {"nios2*linux-gnu", "nios2-unknown-linux-gnu"}, + {"or1k*linux-gnu", "or1k-unknown-linux-gnu"}, + {"powerpc64le*linux-gnu", "powerpc64le-unknown-linux-gnu"}, + {"powerpc64*linux-gnu", "powerpc64-unknown-linux-gnu"}, + {"powerpc*linux-gnu", "powerpc-unknown-linux-gnu"}, + {"s390x*linux-gnu", "s390x-ibm-linux-gnu"}, + {"sh*linux-gnu", "sh4-unknown-linux-gnu"}, + {"sparc64*linux-gnu", "sparc64-unknown-linux-gnu"}, + {"sparc*linux-gnu", "sparc-unknown-linux-gnu"}, + {"x86_64*freebsd-gnu", "x86_64-pc-kfreebsd-gnu"}, + {"x86_64*linux-musl", "x86_64-pc-linux-musl"}, + {"x86_64*linux-gnux32", "x86_64-pc-linux-gnux32"}, + {"x86_64*linux-gnu", "x86_64-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); - } - } + for (int i=0; tbl[i].pattern; i++) + if (fnmatch(tbl[i].pattern, triplet, 0) == 0) + return xstrdup (tbl[i].host); return xstrdup (triplet); } - /* Parse the supplied config.h file and extract required info. Returns 0 on success. */ static int