+ set_be_option("pic=true");
+ set_create_ld_ident(create_name_macho);
+ } else if (strstr(os, "mingw") != NULL || streq(os, "win32")) {
+ wchar_atomic_kind = ATOMIC_TYPE_USHORT;
+ enable_main_collect2_hack = true;
+ set_be_option("ia32-gasmode=mingw");
+ set_create_ld_ident(create_name_win32);
+ } else {
+ return false;
+ }
+
+ return true;
+}
+
+static bool parse_target_triple(const char *arg)
+{
+ const char *manufacturer = strchr(arg, '-');
+ if (manufacturer == NULL) {
+ fprintf(stderr, "Target-triple is not in the form 'cpu_type-manufacturer-operating_system'\n");
+ return false;
+ }
+ manufacturer += 1;
+
+ const char *os = strchr(manufacturer, '-');
+ if (os == NULL) {
+ fprintf(stderr, "Target-triple is not in the form 'cpu_type-manufacturer-operating_system'\n");
+ return false;
+ }
+ os += 1;
+
+ /* Note: Triples are more or less defined by what the config.guess and
+ * config.sub scripts from GNU autoconf emit. We have to lookup there what
+ * triples are possible */
+
+ /* process cpu type */
+ if (strstart(arg, "i386-")) {
+ be_parse_arg("isa=ia32");
+ be_parse_arg("ia32-arch=i386");
+ } else if (strstart(arg, "i486-")) {
+ be_parse_arg("isa=ia32");
+ be_parse_arg("ia32-arch=i486");
+ } else if (strstart(arg, "i586-")) {
+ be_parse_arg("isa=ia32");
+ be_parse_arg("ia32-arch=i586");
+ } else if (strstart(arg, "i686-")) {
+ be_parse_arg("isa=ia32");
+ be_parse_arg("ia32-arch=i686");
+ } else if (strstart(arg, "i786-")) {
+ be_parse_arg("isa=ia32");
+ be_parse_arg("ia32-arch=pentium4");
+ } else if (strstart(arg, "x86_64")) {
+ be_parse_arg("isa=amd64");
+ } else if (strstart(arg, "sparc-")) {
+ be_parse_arg("isa=sparc");
+ } else if (strstart(arg, "arm-")) {
+ be_parse_arg("isa=arm");
+ } else {
+ fprintf(stderr, "Unknown cpu in triple '%s'\n", arg);
+ return false;
+ }
+
+ /* process manufacturer, alot of people incorrectly leave out the
+ * manufacturer instead of using unknown- */
+ if (strstart(manufacturer, "linux")) {
+ os = manufacturer;
+ manufacturer = "unknown-";
+ }
+
+ /* process operating system */
+ if (!set_os_support(os)) {
+ fprintf(stderr, "Unknown operating system '%s' in triple '%s'\n", os, arg);
+ return false;