4fe887e
diff -up gutenprint-5.2.6/src/main/gutenprint-internal.h.postscriptdriver gutenprint-5.2.6/src/main/gutenprint-internal.h
4fe887e
--- gutenprint-5.2.6/src/main/gutenprint-internal.h.postscriptdriver	2010-08-04 02:33:56.000000000 +0200
4fe887e
+++ gutenprint-5.2.6/src/main/gutenprint-internal.h	2010-08-11 16:11:19.000000000 +0200
4fe887e
@@ -56,6 +56,8 @@ extern void stpi_init_printer(void);
4fe887e
 #define BUFFER_FLAG_FLIP_X	0x1
4fe887e
 #define BUFFER_FLAG_FLIP_Y	0x2
4fe887e
 extern stp_image_t* stpi_buffer_image(stp_image_t* image, unsigned int flags);
4fe887e
+extern stp_list_t *stp_paths_copy_with_prefix(stp_list_t* list,
4fe887e
+					      const char *prefix);
4fe887e
 
4fe887e
 #define STPI_ASSERT(x,v)						\
4fe887e
 do									\
4fe887e
diff -up gutenprint-5.2.6/src/main/module.c.postscriptdriver gutenprint-5.2.6/src/main/module.c
4fe887e
--- gutenprint-5.2.6/src/main/module.c.postscriptdriver	2006-09-30 17:02:59.000000000 +0200
4fe887e
+++ gutenprint-5.2.6/src/main/module.c	2010-08-11 16:13:43.000000000 +0200
1bd8b5c
@@ -151,12 +151,20 @@ int stp_module_load(void)
1bd8b5c
     }
1bd8b5c
   else
1bd8b5c
     {
1bd8b5c
+      const char *prefix = getenv("DESTDIR");
1bd8b5c
 #ifdef USE_LTDL
1bd8b5c
       stp_path_split(dir_list, getenv("LTDL_LIBRARY_PATH"));
1bd8b5c
       stp_path_split(dir_list, lt_dlgetsearchpath());
1bd8b5c
 #else
1bd8b5c
       stp_path_split(dir_list, PKGMODULEDIR);
1bd8b5c
 #endif
1bd8b5c
+      if (prefix)
1bd8b5c
+	{
1bd8b5c
+	  stp_list_t *prefix_list;
1bd8b5c
+	  prefix_list = stp_paths_copy_with_prefix(dir_list, prefix);
1bd8b5c
+	  stp_list_destroy(dir_list);
1bd8b5c
+	  dir_list = prefix_list;
1bd8b5c
+	}
1bd8b5c
     }
1bd8b5c
 #ifdef USE_LTDL
1bd8b5c
   file_list = stp_path_search(dir_list, ".la");
4fe887e
diff -up gutenprint-5.2.6/src/main/path.c.postscriptdriver gutenprint-5.2.6/src/main/path.c
4fe887e
--- gutenprint-5.2.6/src/main/path.c.postscriptdriver	2008-06-01 16:41:18.000000000 +0200
4fe887e
+++ gutenprint-5.2.6/src/main/path.c	2010-08-11 16:13:43.000000000 +0200
1bd8b5c
@@ -158,7 +158,17 @@ stpi_data_path(void)
1bd8b5c
   if (getenv("STP_DATA_PATH"))
1bd8b5c
     stp_path_split(dir_list, getenv("STP_DATA_PATH"));
1bd8b5c
   else
1bd8b5c
-    stp_path_split(dir_list, PKGXMLDATADIR);
1bd8b5c
+    {
1bd8b5c
+      const char *prefix = getenv("DESTDIR");
1bd8b5c
+      stp_path_split(dir_list, PKGXMLDATADIR);
1bd8b5c
+      if (prefix)
1bd8b5c
+	{
1bd8b5c
+	  stp_list_t *prefix_list;
1bd8b5c
+	  prefix_list = stp_paths_copy_with_prefix(dir_list, prefix);
1bd8b5c
+	  stp_list_destroy(dir_list);
1bd8b5c
+	  dir_list = prefix_list;
1bd8b5c
+	}
1bd8b5c
+    }
1bd8b5c
   return dir_list;
1bd8b5c
 }
1bd8b5c
 
1bd8b5c
@@ -226,6 +236,40 @@ stp_path_split(stp_list_t *list, /* List
1bd8b5c
     }
1bd8b5c
 }
1bd8b5c
 
1bd8b5c
+/*
1bd8b5c
+ * Split a PATH-type string (colon-delimited) into separate
1bd8b5c
+ * directories.
1bd8b5c
+ */
1bd8b5c
+stp_list_t *
1bd8b5c
+stp_paths_copy_with_prefix(stp_list_t *list,   /* List to add prefix to */
1bd8b5c
+			   const char *prefix) /* Prefix to add */
1bd8b5c
+{
1bd8b5c
+  stp_list_t *new_list;
1bd8b5c
+  stp_list_item_t *item;
1bd8b5c
+  int prefixlen = strlen (prefix);
1bd8b5c
+  if (!(new_list = stp_list_create()))
1bd8b5c
+    return;
1bd8b5c
+
1bd8b5c
+  item = stp_list_get_start (list);
1bd8b5c
+  while (item)
1bd8b5c
+    {
1bd8b5c
+      const char *data;
1bd8b5c
+      char *new_data;
1bd8b5c
+      int len;
1bd8b5c
+      data = stp_list_item_get_data (item);
1bd8b5c
+      len = strlen (data);
1bd8b5c
+      new_data = (char *) stp_malloc(prefixlen + 1 + len + 1);
1bd8b5c
+      strncpy(new_data, prefix, prefixlen);
1bd8b5c
+      new_data[prefixlen] = '/';
1bd8b5c
+      strcpy(new_data + prefixlen + 1, data);
1bd8b5c
+      stp_list_item_create(new_list, NULL, new_data);
1bd8b5c
+
1bd8b5c
+      item = stp_list_item_next (item);
1bd8b5c
+    }
1bd8b5c
+
1bd8b5c
+  return new_list;
1bd8b5c
+}
1bd8b5c
+
1bd8b5c
 /* Adapted from GNU libc <dirent.h>
1bd8b5c
    These macros extract size information from a `struct dirent *'.
1bd8b5c
    They may evaluate their argument multiple times, so it must not