[sane-devel] Odd compile problem

Michael Carmack karmak@karmak.org
Thu, 21 Mar 2002 03:42:05 +0000

On Thu, Mar 21, 2002 at 01:57:58AM +0000, Michael Carmack wrote:
> The problem occurs when I try to specify a target directory 
> (via --prefix=...) that is of the following form:
>     /some/path/.i686-pc-linux-gnu/prefix/dir
> It's the .i686-pc-linux-gnu directory that's causing problems. Apparently
> the binaries get paths compiled into them that have .i686-pc-linux-gnu
> replaced with .1-pc-1-gnu, i.e. the "i686" and "linux" strings are
> being replaced with 1's.

Ok, I traced this back to STRINGIFY in include/sane/sanei.h. 

STRINGIFY is referenced from sanei/sanei_config.c to generate the path 
to the config directory. For some reason STRINGIFY converts the sysconfdir
path (passed via the 'configure' option --sysconfdir) from 
/x/y/z/.i686-pc-linux-gnu to /x/y/z/.1-pc-1-gnu. I do not know why this
happens, but the following change to include/sane/sanei.h fixes the

/** @def STRINGIFY(x)
 * Turn parameter into string.
/* #define STRINGIFY1(x) #x  [Original code, breaks custom --sysconfdir] */
#define STRINGIFY1(x)   "x"
#define STRINGIFY(x)    STRINGIFY1(x)

That is, replacing  #x  with  "x"  correctly stringifies the path.

Does anyone know why STRINGIFY with the #x would change the path? I
chanced upon the "fix" on google, but I'm not sure why it works, or why
the i686 and linux bits got replaced with 1's in the first place.

Is this a fault with the sane code or gcc?