[sane-devel] [PATCH] Do not use STRINGIFY for LIBDIR but pass "LIBDIR" from build system

Niels Ole Salscheider niels_ole at salscheider-online.de
Wed Jun 10 17:51:25 UTC 2015


Otherwise, "linux" will be expanded to "1" when it is stringified.

This is a problem for e. g. LIBDIR, which might contain a target triplet.
On my system, /usr/x86_64-pc-linux-gnu-gcc would expand to x86_64-pc-1-gnu-gcc.
---
 backend/Makefile.am | 2 +-
 backend/dll.c       | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/backend/Makefile.am b/backend/Makefile.am
index 40ec6c6..c5791e6 100644
--- a/backend/Makefile.am
+++ b/backend/Makefile.am
@@ -24,7 +24,7 @@ USB_LIBS = @USB_LIBS@
 SCSI_LIBS = @SCSI_LIBS@
 PTHREAD_LIBS = @PTHREAD_LIBS@
 
-AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -DLIBDIR="$(libdir)/sane"
+AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -DLIBDIR="\"$(libdir)/sane\""
 
 V_MAJOR = @V_MAJOR@
 V_MINOR = @V_MINOR@
diff --git a/backend/dll.c b/backend/dll.c
index 619ee55..5264f11 100644
--- a/backend/dll.c
+++ b/backend/dll.c
@@ -430,7 +430,7 @@ load (struct backend *be)
 
   if (path)
     {
-      src_len = strlen (path) + strlen (STRINGIFY (LIBDIR)) + 1 + 1;
+      src_len = strlen (path) + strlen (LIBDIR) + 1 + 1;
       src = malloc (src_len);
       if (!src)
 	{
@@ -438,11 +438,11 @@ load (struct backend *be)
 	  return SANE_STATUS_NO_MEM;
 	}
       orig_src = src;
-      snprintf (src, src_len, "%s:%s", path, STRINGIFY (LIBDIR));
+      snprintf (src, src_len, "%s:%s", path, LIBDIR);
     }
   else
     {
-      src = STRINGIFY (LIBDIR);
+      src = LIBDIR;
       src = strdup (src);
       if (!src)
 	{
-- 
2.4.3




More information about the sane-devel mailing list