void build_configure(struct supported_gdb_version *sp) { FILE *fp1, *fp2; char buf[512]; char *target; char *target_CFLAGS; char *gdb_conf_flags; char *ldflags; char *cflags; get_current_configuration(sp); target = target_CFLAGS = NULL; gdb_conf_flags = GDB_TARGET_DEFAULT; switch (target_data.target) { case X86: target = TARGET_X86; if (target_data.host == X86_64) { target_CFLAGS = TARGET_CFLAGS_X86_ON_X86_64; gdb_conf_flags = GDB_TARGET_X86_ON_X86_64; } else target_CFLAGS = TARGET_CFLAGS_X86; break; case ALPHA: target = TARGET_ALPHA; target_CFLAGS = TARGET_CFLAGS_ALPHA; break; case PPC: target = TARGET_PPC; if (target_data.host == PPC64) { target_CFLAGS = TARGET_CFLAGS_PPC_ON_PPC64; gdb_conf_flags = GDB_TARGET_PPC_ON_PPC64; } else target_CFLAGS = TARGET_CFLAGS_PPC; break; case IA64: target = TARGET_IA64; target_CFLAGS = TARGET_CFLAGS_IA64; break; case S390: target = TARGET_S390; target_CFLAGS = TARGET_CFLAGS_S390; break; case S390X: target = TARGET_S390X; target_CFLAGS = TARGET_CFLAGS_S390X; break; case PPC64: target = TARGET_PPC64; if (target_data.host == X86_64) { target_CFLAGS = TARGET_CFLAGS_PPC64_ON_X86_64; gdb_conf_flags = GDB_TARGET_PPC64_ON_X86_64; } else target_CFLAGS = TARGET_CFLAGS_PPC64; break; case X86_64: target = TARGET_X86_64; target_CFLAGS = TARGET_CFLAGS_X86_64; break; case ARM: target = TARGET_ARM; if (target_data.host == X86) { target_CFLAGS = TARGET_CFLAGS_ARM_ON_X86; gdb_conf_flags = GDB_TARGET_ARM_ON_X86; } else if (target_data.host == X86_64) { target_CFLAGS = TARGET_CFLAGS_ARM_ON_X86_64; gdb_conf_flags = GDB_TARGET_ARM_ON_X86_64; } else target_CFLAGS = TARGET_CFLAGS_ARM; break; case ARM64: target = TARGET_ARM64; if (target_data.host == X86_64) { target_CFLAGS = TARGET_CFLAGS_ARM64_ON_X86_64; gdb_conf_flags = GDB_TARGET_ARM64_ON_X86_64; } else target_CFLAGS = TARGET_CFLAGS_ARM64; break; case MIPS: target = TARGET_MIPS; if (target_data.host == X86) { target_CFLAGS = TARGET_CFLAGS_MIPS_ON_X86; gdb_conf_flags = GDB_TARGET_MIPS_ON_X86; } else if (target_data.host == X86_64) { target_CFLAGS = TARGET_CFLAGS_MIPS_ON_X86_64; gdb_conf_flags = GDB_TARGET_MIPS_ON_X86_64; } else target_CFLAGS = TARGET_CFLAGS_MIPS; break; } ldflags = get_extra_flags("LDFLAGS.extra", NULL); cflags = get_extra_flags("CFLAGS.extra", NULL); gdb_conf_flags = get_extra_flags("GDBFLAGS.extra", gdb_conf_flags); makefile_setup(&fp1, &fp2); while (fgets(buf, 512, fp1)) { if (strncmp(buf, "TARGET=", strlen("TARGET=")) == 0) fprintf(fp2, "%s\n", target); else if (strncmp(buf, "TARGET_CFLAGS=", strlen("TARGET_CFLAGS=")) == 0) fprintf(fp2, "%s%s%s\n", target_CFLAGS, cflags ? " " : "", cflags ? cflags : ""); else if (strncmp(buf, "GDB_CONF_FLAGS=", strlen("GDB_CONF_FLAGS=")) == 0) fprintf(fp2, "%s\n", gdb_conf_flags); else if (strncmp(buf, "GDB_FILES=",strlen("GDB_FILES=")) == 0) fprintf(fp2, "%s\n", sp->GDB_FILES); else if (strncmp(buf, "GDB_OFILES=",strlen("GDB_OFILES=")) == 0) fprintf(fp2, "%s\n", sp->GDB_OFILES); else if (strncmp(buf, "GDB_PATCH_FILES=",strlen("GDB_PATCH_FILES=")) == 0) fprintf(fp2, "%s\n", sp->GDB_PATCH_FILES); else if (strncmp(buf, "GDB_FLAGS=",strlen("GDB_FLAGS=")) == 0) fprintf(fp2, "%s\n", sp->GDB_FLAGS); else if (strncmp(buf, "GPL_FILES=", strlen("GPL_FILES=")) == 0) fprintf(fp2, "GPL_FILES=%s\n", strcmp(sp->GPL, "GPLv2") == 0 ? "COPYING" : "COPYING3"); else if (strncmp(buf, "GDB=", strlen("GDB=")) == 0) { fprintf(fp2, "%s\n", sp->GDB); sprintf(target_data.gdb_version, "%s", &sp->GDB[4]); } else if (strncmp(buf, "LDFLAGS=", strlen("LDFLAGS=")) == 0) { fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : ""); } else fprintf(fp2, "%s", buf); } makefile_create(&fp1, &fp2); show_configuration(); make_build_data(&target[strlen("TARGET=")]); }
// ------------------------------------------------------------------ int main(int argc,char *argv[]) { bool info = false; bool usage = false; setup_configuration(); for (int i = 1; i < argc; i++) if (!strcmp(argv[i], "-info")) info = true; else if (!strncmp(argv[i], "--enable-", 9)) set(&argv[i][9], true); else if (!strncmp(argv[i], "--disable-", 10)) set(&argv[i][10], false); else if (!strncmp(argv[i], "--platform=", 11)) set_platform(&argv[i][11]); else if (!strncmp(argv[i], "--name=", 7)) replace_makefile("NAME", &argv[i][7]); else if (!strncmp(argv[i], "--prefix=", 9)) replace_makefile("PREFIX", &argv[i][9]); else if (!strncmp(argv[i], "--namespace=", 12)) set_namespace(&argv[i][12]); else if (!strcmp(argv[i], "-v")) any_set = true; else if (!strcmp(argv[i], "-q")) quiet = true; else if (*argv[i] == '-') { fprintf(stderr, "Unknown command line option: %s\n", argv[i]); usage = true; } else usage = true; if (usage) { fprintf(stderr, "Usage: %s [-info] [-v] [-h] [--platform=PLATFORM] [--prefix=<path>] [--name=<Name>] [--namespace=<ns>] [--enable-OPTION] [--disable-OPTION]\n", *argv); fprintf(stderr, "\n"); fprintf(stderr, "Options (default value)\n"); fprintf(stderr, "\n"); fprintf(stderr, " -info Show compiled options\n"); fprintf(stderr, " -v Show configuration options\n"); fprintf(stderr, " -q Don't show extra info\n"); fprintf(stderr, " -h Show this help\n"); fprintf(stderr, "\n"); fprintf(stderr, " --platform= Select target platform\n"); fprintf(stderr, " --prefix= Set installation path (/usr/local/$NAME)\n"); fprintf(stderr, " --name= Set library name (Sockets)\n"); fprintf(stderr, " --namespace= Set C++ namespace for entire library\n"); fprintf(stderr, "\n"); fprintf(stderr, "Defined platforms\n"); fprintf(stderr, "\n"); fprintf(stderr, " linux-x86-32\n"); fprintf(stderr, " linux-x86-64\n"); fprintf(stderr, " win32-cygwin\n"); fprintf(stderr, " solaris9-sparc-64\n"); fprintf(stderr, " macosx\n"); fprintf(stderr, " solaris8\n"); fprintf(stderr, "\n"); fprintf(stderr, "Possible OPTION values:\n"); fprintf(stderr, "\n"); fprintf(stderr, " openssl Enable openssl library\n"); fprintf(stderr, " ipv6 Add ipv6 support\n"); fprintf(stderr, " sctp Add SCTP support\n"); fprintf(stderr, " no_addrinfo Do not use addrinfo API for dns requests\n"); fprintf(stderr, " pool Enable client connection pool\n"); fprintf(stderr, " socks4 Enable socks4 client support\n"); fprintf(stderr, " resolver Enable asynchronous dns\n"); fprintf(stderr, " reconnect Enable tcp reconnect\n"); fprintf(stderr, " detach Enable detach functionality\n"); fprintf(stderr, " exceptions Enable C++ exceptions on some error conditions\n"); fprintf(stderr, " xml2 Enable libxml2 support\n"); fprintf(stderr, "\n"); fprintf(stderr, "Use with no options to show platform configuration options in CFLAGS format.\n"); return 0; } if (argc > 1 && info) { show_info(); return 0; } if (any_set) { if (!quiet) show_configuration(); return 0; } printf(" -D_VERSION='\"%s\"'", _VERSION); #ifdef LINUX printf(" -DLINUX"); #endif #ifdef MACOSX printf(" -DMACOSX"); #endif #ifdef SOLARIS printf(" -DSOLARIS"); #endif #ifdef SOLARIS8 printf(" -DSOLARIS8"); #endif #ifdef _WIN32 printf(" -D_WIN32"); #endif #ifdef __CYGWIN__ printf(" -D__CYGWIN__"); #endif #ifdef SOCKETS_NAMESPACE printf(" -DSOCKETS_NAMESPACE=%s", SOCKETS_NAMESPACE_STR); #endif #ifdef _DEBUG printf(" -D_DEBUG"); #endif }