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