Set up GDB_CONF_FLAGS from the configure utility. This avoids duplication of
logic between configure.c and Makefile. Additionally, the new method ensures
that the gdb target always matches the configured crash target. This may
become useful when we allow cross-compiling crash for a different target
(think of arm on x86, for example).
Signed-off-by: Petr Tesarik <ptesarik(a)suse.cz>
---
Makefile | 18 ++----------------
configure.c | 32 +++++++++++++++++++++++++++++---
2 files changed, 31 insertions(+), 19 deletions(-)
--- a/configure.c
+++ b/configure.c
@@ -18,14 +18,14 @@
/*
* define, clear and undef dynamically update the top-level Makefile:
*
- * -b define: TARGET, GDB, GDB_FILES, GDB_OFILES, GDB_PATCH_FILES,
TARGET_CFLAGS and GPL_FILES
+ * -b define: TARGET, GDB, GDB_FILES, GDB_OFILES, GDB_PATCH_FILES,
TARGET_CFLAGS, GDB_CONF_FLAGS and GPL_FILES
* create: build_data.c
*
- * -d define: TARGET, GDB, GDB_FILES, GDB_OFILES, GDB_PATCH_FILES,
TARGET_CFLAGS, and
+ * -d define: TARGET, GDB, GDB_FILES, GDB_OFILES, GDB_PATCH_FILES,
TARGET_CFLAGS, GDB_CONF_FLAGS and
* PROGRAM (for daemon)
* create: build_data.c
*
- * -u clear: TARGET, GDB, GDB_FILES, GDB_OFILES, VERSION,
GDB_PATCH_FILES, TARGET_CFLAGS and GPL_FILES
+ * -u clear: TARGET, GDB, GDB_FILES, GDB_OFILES, VERSION,
GDB_PATCH_FILES, TARGET_CFLAGS, GDB_CONF_FLAGS and GPL_FILES
* undef: WARNING_ERROR, WARNING_OPTIONS
*
* -r define: GDB_FILES, VERSION, GDB_PATCH_FILES GPL_FILES
@@ -131,6 +131,16 @@ int name_to_target(char *);
#define TARGET_CFLAGS_ARM_ON_X86_64 "TARGET_CFLAGS=-m32 -
D_FILE_OFFSET_BITS=64"
#define TARGET_CFLAGS_X86_ON_X86_64 "TARGET_CFLAGS=-m32 -
D_FILE_OFFSET_BITS=64"
+#define GDB_TARGET_X86 "GDB_CONF_FLAGS=--target=i686-pc-linux-gnu"
+#define GDB_TARGET_ALPHA "GDB_CONF_FLAGS=--target=alpha-linux-gnu"
+#define GDB_TARGET_PPC "GDB_CONF_FLAGS=--target=powerpc-linux-gnu"
+#define GDB_TARGET_IA64 "GDB_CONF_FLAGS=--target=ia64-linux-gnu"
+#define GDB_TARGET_S390 "GDB_CONF_FLAGS=--target=s390-ibm-linux-gnu"
+#define GDB_TARGET_S390X "GDB_CONF_FLAGS=--target=s390x-ibm-linux-gnu"
+#define GDB_TARGET_PPC64 "GDB_CONF_FLAGS=--target=powerpc64-linux-gnu"
+#define GDB_TARGET_X86_64 "GDB_CONF_FLAGS=--target=x86_64-pc-linux-gnu"
+#define GDB_TARGET_ARM "GDB_CONF_FLAGS=--target=arm-elf-linux-gnu"
+
/*
* The original plan was to allow the use of a particular version
* of gdb for a given architecture. But for practical purposes,
@@ -512,6 +522,7 @@ build_configure(struct supported_gdb_ver
char buf[512];
char *target;
char *target_CFLAGS;
+ char *gdb_conf_flags;
get_current_configuration(sp);
@@ -525,34 +536,42 @@ build_configure(struct supported_gdb_ver
target_CFLAGS = TARGET_CFLAGS_X86_ON_X86_64;
else
target_CFLAGS = TARGET_CFLAGS_X86;
+ gdb_conf_flags = GDB_TARGET_X86;
break;
case ALPHA:
target = TARGET_ALPHA;
target_CFLAGS = TARGET_CFLAGS_ALPHA;
+ gdb_conf_flags = GDB_TARGET_ALPHA;
break;
case PPC:
target = TARGET_PPC;
target_CFLAGS = TARGET_CFLAGS_PPC;
+ gdb_conf_flags = GDB_TARGET_PPC;
break;
case IA64:
target = TARGET_IA64;
target_CFLAGS = TARGET_CFLAGS_IA64;
+ gdb_conf_flags = GDB_TARGET_IA64;
break;
case S390:
target = TARGET_S390;
target_CFLAGS = TARGET_CFLAGS_S390;
+ gdb_conf_flags = GDB_TARGET_S390;
break;
case S390X:
target = TARGET_S390X;
target_CFLAGS = TARGET_CFLAGS_S390X;
+ gdb_conf_flags = GDB_TARGET_S390X;
break;
case PPC64:
target = TARGET_PPC64;
target_CFLAGS = TARGET_CFLAGS_PPC64;
+ gdb_conf_flags = GDB_TARGET_PPC64;
break;
case X86_64:
target = TARGET_X86_64;
target_CFLAGS = TARGET_CFLAGS_X86_64;
+ gdb_conf_flags = GDB_TARGET_X86_64;
break;
case ARM:
target = TARGET_ARM;
@@ -562,6 +581,7 @@ build_configure(struct supported_gdb_ver
target_CFLAGS = TARGET_CFLAGS_ARM_ON_X86_64;
else
target_CFLAGS = TARGET_CFLAGS_ARM;
+ gdb_conf_flags = GDB_TARGET_ARM;
break;
}
@@ -573,6 +593,9 @@ build_configure(struct supported_gdb_ver
else if (strncmp(buf, "TARGET_CFLAGS=",
strlen("TARGET_CFLAGS=")) == 0)
fprintf(fp2, "%s\n", target_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)
@@ -745,6 +768,9 @@ unconfigure(void)
else if (strncmp(buf, "TARGET_CFLAGS=",
strlen("TARGET_CFLAGS=")) == 0)
fprintf(fp2, "TARGET_CFLAGS=\n");
+ else if (strncmp(buf, "GDB_CONF_FLAGS=",
+ strlen("GDB_CONF_FLAGS=")) == 0)
+ fprintf(fp2, "GDB_CONF_FLAGS=\n");
else if (strncmp(buf,
"GDB_FILES=",strlen("GDB_FILES=")) ==
0)
fprintf(fp2, "GDB_FILES=\n");
else if (strncmp(buf,
"GDB_OFILES=",strlen("GDB_OFILES=")) ==
0)
--- a/Makefile
+++ b/Makefile
@@ -23,30 +23,16 @@ PROGRAM=crash
#
# Supported targets: X86 ALPHA PPC IA64 PPC64
-# TARGET will be configured automatically by configure
+# TARGET and GDB_CONF_FLAGS will be configured automatically by configure
#
TARGET=
+GDB_CONF_FLAGS=
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e
s/arm.*/arm/ -e s/sa110/arm/)
ifeq ($(ARCH), ppc64)
CONF_FLAGS = -m64
endif
-ifeq ($(TARGET), ARM)
-ifeq ($(ARCH), i386)
-GDB_CONF_FLAGS = --target=arm-elf-linux
-endif
-ifeq ($(ARCH), x86_64)
-GDB_CONF_FLAGS = --target=arm-elf-linux CFLAGS=-m32
-endif
-endif
-
-ifeq ($(TARGET), X86)
-ifeq ($(ARCH), x86_64)
-GDB_CONF_FLAGS = --target=i686-pc-linux-gnu CFLAGS=-m32
-endif
-endif
-
#
# GDB, GDB_FILES, GDB_OFILES and GDB_PATCH_FILES will be configured
automatically by configure
#