From: Philippe E. <ph...@wa...> - 2003-04-16 16:55:26
|
Nicholas Nethercote wrote: > On Thu, 20 Mar 2003, Ruben Garcia wrote: > > >>In valgrind 1.0.4 (dont know if this is fixed in development) >>the location of gdb is hardcoded in vg_main.c as /usr/bin/gdb. >> >>Gdb sources, on the other hand, install by default in /usr/local/bin/gdb. >>Surely a patch to the ./configure to check where gdb is installed cannot >>be difficult. > > > I have this working, but I'm not certain if I've done it the best way. > > Here's what I did: > > - added this to configure.in: > > AC_PATH_PROG(GDB, gdb) > > - added this to coregrind/Makefile.am: > > vg_main.o: CFLAGS += -DWHERE_IS_GDB=@GDB@ > > - changed coregrind/vg_main.c to use WHERE_IS_GDB for the path. > > This works, but it would be better if the GDB variable was put into a .h > file, so it's available everywhere -- that's better than having to feed it > in to every file that needs it with -D. This could be done by introducing > eg. vg_skin.h.in, but that would be a pain, especially just for one > variable. > > I tried various ways to get the WHERE_IS_GDB variable put into config.h, > but didn't manage... this would be a better solution. Does anyone know > how to do this? Yes, it's a better way but the trivial: AC_PATH_PROG(GDB, gdb) AC_DEFINE(GDB_PATH, @GDB@, "gdb path") AC_SUBST(GDB) doesn't work cause configure don't do subsititution in config.h.in when creating config.h, I don't think there is any way to put it in config.h.in. I work around by doing: ** configure.in: AC_PATH(GDB_PATH, gdb) AC_SUBST(GDB_PATH) AC_OUTPUT( .... \ path-1.h) AX_COPY_IF_CHANGE(path-1.h, path.h) $ cat path-1.h.in #define GDB_PATH @GDB_PATH@ $ cat copyifchange.m4 dnl AX_COPY_IF_CHANGE(source, dest) dnl copy source to dest if they don't compare equally or if dest doesn't exist AC_DEFUN(AX_COPY_IF_CHANGE, [ if test -r $2; then if cmp $1 $2 > /dev/null; then echo $2 is unchanged else cp -f $1 $2 fi else cp -f $1 $2 fi ]) I use path-1.h and copyifchange to avoid spurious recompilation when you configure and nothing change in path-1.h. (configure take care to not change time stamp of config.h if unnecessary but doesn't do the same thing for other .in translation) Not very elegant but the only way I found The only required file in cvs/tarball is path-1.h.in regards, Phil |