[Mesa-dev] [PATCHv2 6/6] Add possibility to use linux filesystem hierarchy on CMake build.

Johannes Obermayr johannesobermayr at gmx.de
Sat Nov 19 09:37:48 PST 2011


It introduces following variables (as prefixes):
  (-D)BINDIR  - default: none, ${BINDIR}/${subdir}
  (-D)DATADIR - default: none, ${DATADIR}/${subdir}
  (-D)DOCDIR  - default: doc

---
 CMakeLists.txt                |   23 +++++++++++++++++++----
 configure.ac                  |   17 +++++++++++++++--
 src/data/CMakeLists.txt       |    2 +-
 src/data/Makefile.am          |    3 +--
 src/demos/CMakeLists.txt      |    4 ++--
 src/demos/copypix.c           |    2 +-
 src/demos/dissolve.c          |    4 ++--
 src/demos/drawpix.c           |    2 +-
 src/demos/engine.c            |    2 +-
 src/demos/fbo_firecube.c      |    6 +++---
 src/demos/fire.c              |    6 +++---
 src/demos/geartrain.c         |    2 +-
 src/demos/gloss.c             |    4 ++--
 src/demos/ipers.c             |    2 +-
 src/demos/isosurf.c           |    4 ++--
 src/demos/lodbias.c           |    2 +-
 src/demos/multiarb.c          |    4 ++--
 src/demos/projtex.c           |    8 ++++----
 src/demos/rain.cxx            |    2 +-
 src/demos/readpix.c           |    2 +-
 src/demos/reflect.c           |    2 +-
 src/demos/teapot.c            |    4 ++--
 src/demos/terrain.c           |    2 +-
 src/demos/texcyl.c            |    2 +-
 src/demos/textures.c          |    8 ++++----
 src/demos/tunnel.c            |    4 ++--
 src/demos/tunnel2.c           |    4 ++--
 src/demos/winpos.c            |    2 +-
 src/egl/opengl/CMakeLists.txt |    6 +++---
 src/fp/CMakeLists.txt         |   10 +++++++---
 src/fp/fp-tri.c               |    2 +-
 src/fp/tri-tex.c              |    2 +-
 src/fpglsl/CMakeLists.txt     |    4 ++--
 src/fpglsl/fp-tri.c           |    2 +-
 src/glsl/CMakeLists.txt       |    4 ++--
 src/glsl/brick.c              |    4 ++--
 src/glsl/bump.c               |    8 ++++----
 src/glsl/convolutions.c       |    2 +-
 src/glsl/mandelbrot.c         |    4 ++--
 src/glsl/multitex.c           |    8 ++++----
 src/glsl/simplex-noise.c      |    2 +-
 src/glsl/skinning.c           |    4 ++--
 src/glsl/texdemo1.c           |   12 ++++++------
 src/glsl/toyball.c            |    4 ++--
 src/gs/CMakeLists.txt         |    4 ++--
 src/objviewer/CMakeLists.txt  |    4 ++--
 src/objviewer/objview.c       |   14 +++++++-------
 src/perf/CMakeLists.txt       |    2 +-
 src/perf/glslstateschange.c   |    8 ++++----
 src/redbook/CMakeLists.txt    |    2 +-
 src/samples/CMakeLists.txt    |    4 ++--
 src/samples/sphere.c          |    2 +-
 src/slang/CMakeLists.txt      |    4 ++--
 src/slang/cltest.c            |    2 +-
 src/slang/vstest.c            |    2 +-
 src/tests/CMakeLists.txt      |    4 ++--
 src/tests/afsmultiarb.c       |    4 ++--
 src/tests/arbfptexture.c      |    2 +-
 src/tests/arbfptrig.c         |    2 +-
 src/tests/arbnpot.c           |    2 +-
 src/tests/arbvparray.c        |    2 +-
 src/tests/arraytexture.c      |   16 ++++++++--------
 src/tests/blendxor.c          |    2 +-
 src/tests/bug_3195.c          |    2 +-
 src/tests/bumpmap.c           |    2 +-
 src/tests/ext422square.c      |    2 +-
 src/tests/fillrate.c          |    4 ++--
 src/tests/floattex.c          |    2 +-
 src/tests/fptexture.c         |    2 +-
 src/tests/invert.c            |    2 +-
 src/tests/mipmap_limits.c     |    2 +-
 src/tests/mipmap_view.c       |    2 +-
 src/tests/multipal.c          |    4 ++--
 src/tests/pbo.c               |    2 +-
 src/tests/rubberband.c        |    2 +-
 src/tests/texcmp.c            |    2 +-
 src/tests/texcompress2.c      |    2 +-
 src/tests/texline.c           |    2 +-
 src/tests/texrect.c           |    4 ++--
 src/tests/vparray.c           |    2 +-
 src/tests/yuvrect.c           |    2 +-
 src/tests/yuvsquare.c         |    2 +-
 src/trivial/CMakeLists.txt    |    2 +-
 src/vp/CMakeLists.txt         |   10 +++++++---
 src/vpglsl/CMakeLists.txt     |    4 ++--
 src/wgl/CMakeLists.txt        |    2 +-
 src/xdemos/CMakeLists.txt     |    4 ++--
 src/xdemos/yuvrect_client.c   |    2 +-
 88 files changed, 196 insertions(+), 161 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d07215f..4e74a39 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,16 +101,31 @@ if (MSVC)
 	add_definitions (-wd4244) # conversion' conversion from 'type1' to 'type2', possible loss of data
 endif (MSVC)
 
-add_definitions(-DDEMOS_DATA_DIR=\"../data/\")
-
 if (BUILD_SHARED_LIBS AND NOT DEFINED LIBDIR)
 	set(LIBDIR lib)
 endif (BUILD_SHARED_LIBS AND NOT DEFINED LIBDIR)
 
-add_subdirectory (src)
+if (DEFINED BINDIR)
+	set(BINDIR ${BINDIR}/)
+endif (DEFINED BINDIR)
+
+if (DEFINED DATADIR)
+	set(DATADIR ${DATADIR}/)
+endif (DEFINED DATADIR)
 
+if (DEFINED BINDIR OR DEFINED DATADIR)
+	add_definitions(-DDEMOS_DATA_DIR=\"${DATADIR}\")
+else (DEFINED BINDIR OR DEFINED DATADIR)
+	add_definitions(-DDEMOS_DATA_DIR=\"..\")
+endif (DEFINED BINDIR OR DEFINED DATADIR)
+
+add_subdirectory (src)
 
-install (FILES index.html DESTINATION doc)
+if (DEFINED DOCDIR)
+	install (FILES index.html DESTINATION ${DOCDIR})
+else (DEFINED DOCDIR)
+	install (FILES index.html DESTINATION doc)
+endif (DEFINED DOCDIR)
 
 set (CPACK_PACKAGE_NAME "mesa-demos")
 set (CPACK_PACKAGE_VERSION_MAJOR "8")
diff --git a/configure.ac b/configure.ac
index 4f6f16f..bc6533f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -235,15 +235,28 @@ AC_ARG_WITH([mesa-source],
 	[mesa_source_enabled="no"])
 MESA_GLAPI="$mesa_source_dir/src/mesa/glapi"
 
+use_bindir=no
+AC_ARG_WITH([bindir],
+	    [AS_HELP_STRING([--bindir=DIR],
+			    [Use bindir for install binaries (default: no)])],
+	    [use_bindir=yes], [])
+
+use_datadir=no
+AC_ARG_WITH([datadir],
+	    [AS_HELP_STRING([--datadir=DIR],
+			    [Use datadir for install data files (default: no)])],
+	    [use_datadir=yes], [])
+
 use_system_data=no
 AC_ARG_WITH([system-data-files],
 	    [AS_HELP_STRING([--with-system-data-files],
 			    [Use system data files for demos (default: no)])],
 	    [use_system_data=yes], [])
-if test "x$use_system_data" = xyes; then
+
+if test "x$use_system_data" = xyes -o "x$use_bindir" = xyes -o "x$use_datadir" = xyes; then
     demos_data_dir="${datadir}/${PACKAGE}/"
 else
-    demos_data_dir="../data/"
+    demos_data_dir="../"
 fi
 AC_DEFINE_DIR(DEMOS_DATA_DIR, demos_data_dir, [Data dir for demos])
 AC_DEFINE_UNQUOTED([DEMOS_DATA_DIR], "$DEMOS_DATA_DIR",
diff --git a/src/data/CMakeLists.txt b/src/data/CMakeLists.txt
index 971fa19..ddc43b5 100644
--- a/src/data/CMakeLists.txt
+++ b/src/data/CMakeLists.txt
@@ -1,3 +1,3 @@
 file (GLOB data *.rgb *.rgba *.dat)
 
-install (FILES ${data} DESTINATION data)
+install (FILES ${data} DESTINATION ${DATADIR}data)
diff --git a/src/data/Makefile.am b/src/data/Makefile.am
index 28022c9..f82e85a 100644
--- a/src/data/Makefile.am
+++ b/src/data/Makefile.am
@@ -22,7 +22,7 @@
 # Authors:
 #    Eric Anholt <eric at anholt.net>
 
-demosdatadir=$(datadir)/$(PACKAGE)/
+demosdatadir=$(datadir)/$(PACKAGE)/data/
 dist_demosdata_DATA= \
 	arch.rgb \
 	bw.rgb \
@@ -34,7 +34,6 @@ dist_demosdata_DATA= \
 	tree2.rgba \
 	tree3.rgb \
 	wrs_logo.rgb \
-	\
 	geartrain.dat \
 	isosurf.dat \
 	terrain.dat
diff --git a/src/demos/CMakeLists.txt b/src/demos/CMakeLists.txt
index b35fae6..96af1af 100644
--- a/src/demos/CMakeLists.txt
+++ b/src/demos/CMakeLists.txt
@@ -81,9 +81,9 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 add_executable (rain rain.cxx particles.cxx)
 
-install (TARGETS rain DESTINATION demos)
+install (TARGETS rain DESTINATION ${BINDIR}${subdir})
diff --git a/src/demos/copypix.c b/src/demos/copypix.c
index 286c5a9..24eadab 100644
--- a/src/demos/copypix.c
+++ b/src/demos/copypix.c
@@ -14,7 +14,7 @@
 
 #include "readtex.h"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "arch.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/arch.rgb"
 
 static int ImgWidth, ImgHeight;
 static GLenum ImgFormat;
diff --git a/src/demos/dissolve.c b/src/demos/dissolve.c
index 696ae68..4d061c4 100644
--- a/src/demos/dissolve.c
+++ b/src/demos/dissolve.c
@@ -14,8 +14,8 @@
 #include "glut_wrap.h"
 #include "readtex.h"
 
-#define FILE1 DEMOS_DATA_DIR "bw.rgb"
-#define FILE2 DEMOS_DATA_DIR "arch.rgb"
+#define FILE1 DEMOS_DATA_DIR "data/bw.rgb"
+#define FILE2 DEMOS_DATA_DIR "data/arch.rgb"
 
 
 static int Win;
diff --git a/src/demos/drawpix.c b/src/demos/drawpix.c
index 1ac7bbf..b6fc58e 100644
--- a/src/demos/drawpix.c
+++ b/src/demos/drawpix.c
@@ -13,7 +13,7 @@
 
 #include "readtex.h"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static int ImgWidth, ImgHeight;
 static GLenum ImgFormat;
diff --git a/src/demos/engine.c b/src/demos/engine.c
index 928fcbb..69855bf 100644
--- a/src/demos/engine.c
+++ b/src/demos/engine.c
@@ -21,7 +21,7 @@
 
 #define DEG_TO_RAD(DEG)  ((DEG) * M_PI / 180.0)
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "reflect.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/reflect.rgb"
 
 /* Target engine speed: */
 const int RPM = 100.0;
diff --git a/src/demos/fbo_firecube.c b/src/demos/fbo_firecube.c
index 333c04c..73c2db7 100644
--- a/src/demos/fbo_firecube.c
+++ b/src/demos/fbo_firecube.c
@@ -675,7 +675,7 @@ inittextures(void)
    glBindTexture(GL_TEXTURE_2D, groundid);
 
    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
-   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "s128.rgb", GL_RGB)) {
+   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/s128.rgb", GL_RGB)) {
       fprintf(stderr, "Error reading a texture.\n");
       exit(-1);
    }
@@ -697,7 +697,7 @@ inittextures(void)
 	 int w, h;
 	 GLenum format;
 	 int x, y;
-	 GLubyte *image = LoadRGBImage(DEMOS_DATA_DIR "tree3.rgb",
+	 GLubyte *image = LoadRGBImage(DEMOS_DATA_DIR "data/tree3.rgb",
 				       &w, &h, &format);
 
 	 if (!image) {
@@ -724,7 +724,7 @@ inittextures(void)
 	 }
       }
    else {
-      if (!LoadRGBMipmaps(DEMOS_DATA_DIR "tree2.rgba", GL_RGBA)) {
+      if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/tree2.rgba", GL_RGBA)) {
 	 fprintf(stderr, "Error reading a texture.\n");
 	 exit(-1);
       }
diff --git a/src/demos/fire.c b/src/demos/fire.c
index c40278b..48106bf 100644
--- a/src/demos/fire.c
+++ b/src/demos/fire.c
@@ -627,7 +627,7 @@ inittextures(void)
    glBindTexture(GL_TEXTURE_2D, groundid);
 
    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
-   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "s128.rgb", GL_RGB)) {
+   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/s128.rgb", GL_RGB)) {
       fprintf(stderr, "Error reading a texture.\n");
       exit(-1);
    }
@@ -649,7 +649,7 @@ inittextures(void)
       int w, h;
       GLenum format;
       int x, y;
-      GLubyte *image = LoadRGBImage(DEMOS_DATA_DIR "tree3.rgb",
+      GLubyte *image = LoadRGBImage(DEMOS_DATA_DIR "data/tree3.rgb",
 				    &w, &h, &format);
 
       if (!image) {
@@ -676,7 +676,7 @@ inittextures(void)
       }
    }
    else {
-      if (!LoadRGBMipmaps(DEMOS_DATA_DIR "tree2.rgba", GL_RGBA)) {
+      if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/tree2.rgba", GL_RGBA)) {
 	 fprintf(stderr, "Error reading a texture.\n");
 	 exit(-1);
       }
diff --git a/src/demos/geartrain.c b/src/demos/geartrain.c
index 09e5da2..6bfc1aa 100644
--- a/src/demos/geartrain.c
+++ b/src/demos/geartrain.c
@@ -1003,7 +1003,7 @@ main (int argc, char *argv[])
       exit (1);
 
     if (argc < 2)
-       file = DEMOS_DATA_DIR "geartrain.dat";
+       file = DEMOS_DATA_DIR "data/geartrain.dat";
     else
        file = argv[1];
 
diff --git a/src/demos/gloss.c b/src/demos/gloss.c
index a198a63..a2a7590 100644
--- a/src/demos/gloss.c
+++ b/src/demos/gloss.c
@@ -29,8 +29,8 @@
 #include "trackball.h"
 
 
-#define SPECULAR_TEXTURE_FILE DEMOS_DATA_DIR "reflect.rgb"
-#define BASE_TEXTURE_FILE DEMOS_DATA_DIR "tile.rgb"
+#define SPECULAR_TEXTURE_FILE DEMOS_DATA_DIR "data/reflect.rgb"
+#define BASE_TEXTURE_FILE DEMOS_DATA_DIR "data/tile.rgb"
 
 /* Menu items */
 #define DO_SPEC_TEXTURE 1
diff --git a/src/demos/ipers.c b/src/demos/ipers.c
index 4ecf7cc..4947465 100644
--- a/src/demos/ipers.c
+++ b/src/demos/ipers.c
@@ -151,7 +151,7 @@ inittextures(void)
    glGenTextures(1, &t1id);
    glBindTexture(GL_TEXTURE_2D, t1id);
 
-   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "bw.rgb", 3)) {
+   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/bw.rgb", 3)) {
       fprintf(stderr, "Error reading a texture.\n");
       exit(-1);
    }
diff --git a/src/demos/isosurf.c b/src/demos/isosurf.c
index 747da2f..6f53d0c 100644
--- a/src/demos/isosurf.c
+++ b/src/demos/isosurf.c
@@ -36,7 +36,7 @@
 #include "glut_wrap.h"
 
 #include "readtex.h"
-#define TEXTURE_FILE DEMOS_DATA_DIR "reflect.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/reflect.rgb"
 
 #define LIT		0x00000001
 #define UNLIT		0x00000002
@@ -1052,7 +1052,7 @@ int main(int argc, char **argv)
    if (arg_mode & QUIT)
       exit(0);
 
-   read_surface(DEMOS_DATA_DIR "isosurf.dat");
+   read_surface(DEMOS_DATA_DIR "data/isosurf.dat");
 
    glutInitWindowSize(400, 400);
    glutInit( &argc, argv);
diff --git a/src/demos/lodbias.c b/src/demos/lodbias.c
index 8fb015e..cee1f02 100644
--- a/src/demos/lodbias.c
+++ b/src/demos/lodbias.c
@@ -36,7 +36,7 @@
 
 #include "readtex.h"
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLfloat Xrot = 0, Yrot = -30, Zrot = 0;
 static GLboolean Anim = GL_TRUE;
diff --git a/src/demos/multiarb.c b/src/demos/multiarb.c
index a5eff64..6583a9b 100644
--- a/src/demos/multiarb.c
+++ b/src/demos/multiarb.c
@@ -19,8 +19,8 @@
 
 #include "readtex.h"
 
-#define TEXTURE_1_FILE DEMOS_DATA_DIR "girl.rgb"
-#define TEXTURE_2_FILE DEMOS_DATA_DIR "reflect.rgb"
+#define TEXTURE_1_FILE DEMOS_DATA_DIR "data/girl.rgb"
+#define TEXTURE_2_FILE DEMOS_DATA_DIR "data/reflect.rgb"
 
 #define TEX0 1
 #define TEX7 8
diff --git a/src/demos/projtex.c b/src/demos/projtex.c
index ea55142..61ff297 100644
--- a/src/demos/projtex.c
+++ b/src/demos/projtex.c
@@ -51,10 +51,10 @@ GLboolean showProjection = GL_TRUE;
 GLboolean linearFilter = GL_TRUE;
 
 char *texFilename[MAX_TEX] = {
-   DEMOS_DATA_DIR "girl.rgb",
-   DEMOS_DATA_DIR "tile.rgb",
-   DEMOS_DATA_DIR "bw.rgb",
-   DEMOS_DATA_DIR "reflect.rgb"
+   DEMOS_DATA_DIR "data/girl.rgb",
+   DEMOS_DATA_DIR "data/tile.rgb",
+   DEMOS_DATA_DIR "data/bw.rgb",
+   DEMOS_DATA_DIR "data/reflect.rgb"
 };
 
 
diff --git a/src/demos/rain.cxx b/src/demos/rain.cxx
index 138da3c..d325761 100644
--- a/src/demos/rain.cxx
+++ b/src/demos/rain.cxx
@@ -309,7 +309,7 @@ static void inittextures(void)
   glGenTextures(1,&groundid);
   glBindTexture(GL_TEXTURE_2D,groundid);
 
-  if(!(img=LoadRGBImage(DEMOS_DATA_DIR "s128.rgb",
+  if(!(img=LoadRGBImage(DEMOS_DATA_DIR "data/s128.rgb",
 			&width,&height,&format))){
   	fprintf(stderr,"Error reading a texture.\n");
   	exit(-1);
diff --git a/src/demos/readpix.c b/src/demos/readpix.c
index dc57cf8..66dcfd4 100644
--- a/src/demos/readpix.c
+++ b/src/demos/readpix.c
@@ -14,7 +14,7 @@
 
 #include "readtex.h"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static int ImgWidth, ImgHeight;
 static int WinWidth, WinHeight;
diff --git a/src/demos/reflect.c b/src/demos/reflect.c
index 13b5a68..88f1ed5 100644
--- a/src/demos/reflect.c
+++ b/src/demos/reflect.c
@@ -37,7 +37,7 @@
 
 
 #define DEG2RAD (3.14159/180.0)
-#define TABLE_TEXTURE DEMOS_DATA_DIR "tile.rgb"
+#define TABLE_TEXTURE DEMOS_DATA_DIR "data/tile.rgb"
 #define MAX_OBJECTS 2
 #define INIT_WIDTH 400
 #define INIT_HEIGHT 300
diff --git a/src/demos/teapot.c b/src/demos/teapot.c
index f75ad94..25ac47e 100644
--- a/src/demos/teapot.c
+++ b/src/demos/teapot.c
@@ -503,7 +503,7 @@ static void inittextures(void)
   glBindTexture(GL_TEXTURE_2D,t1id);
 
   glPixelStorei(GL_UNPACK_ALIGNMENT,4);
-  if (!LoadRGBMipmaps(DEMOS_DATA_DIR "tile.rgb", GL_RGB)) {
+  if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/tile.rgb", GL_RGB)) {
     fprintf(stderr,"Error reading a texture.\n");
     exit(-1);
   }
@@ -526,7 +526,7 @@ static void inittextures(void)
   glPixelTransferf(GL_BLUE_SCALE, 0.75);
   glPixelTransferf(GL_BLUE_BIAS, 0.25);
 
-  if (!LoadRGBMipmaps(DEMOS_DATA_DIR "bw.rgb", GL_RGB)) {
+  if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/bw.rgb", GL_RGB)) {
     fprintf(stderr,"Error reading a texture.\n");
     exit(-1);
   }
diff --git a/src/demos/terrain.c b/src/demos/terrain.c
index 435912a..a8d2d7c 100644
--- a/src/demos/terrain.c
+++ b/src/demos/terrain.c
@@ -563,7 +563,7 @@ loadpic(void)
    GLenum gluerr;
    size_t result;
 
-   if ((FilePic = fopen(DEMOS_DATA_DIR "terrain.dat", "r")) == NULL) {
+   if ((FilePic = fopen(DEMOS_DATA_DIR "data/terrain.dat", "r")) == NULL) {
       fprintf(stderr, "Error loading terrain.dat\n");
       exit(-1);
    }
diff --git a/src/demos/texcyl.c b/src/demos/texcyl.c
index f91b03c..87847f3 100644
--- a/src/demos/texcyl.c
+++ b/src/demos/texcyl.c
@@ -17,7 +17,7 @@
 
 #include "readtex.h"
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "reflect.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/reflect.rgb"
 
 #define LIT 1
 #define TEXTURED 2
diff --git a/src/demos/textures.c b/src/demos/textures.c
index 70229bf..fb6e60d 100644
--- a/src/demos/textures.c
+++ b/src/demos/textures.c
@@ -32,10 +32,10 @@ static float TexPos[MAX_TEXTURES][3];
 static float TexAspect[MAX_TEXTURES];
 
 static const char *DefaultFiles[] = {
-   DEMOS_DATA_DIR "arch.rgb",
-   DEMOS_DATA_DIR "reflect.rgb",
-   DEMOS_DATA_DIR "tree2.rgba",
-   DEMOS_DATA_DIR "tile.rgb"
+   DEMOS_DATA_DIR "data/arch.rgb",
+   DEMOS_DATA_DIR "data/reflect.rgb",
+   DEMOS_DATA_DIR "data/tree2.rgba",
+   DEMOS_DATA_DIR "data/tile.rgb"
 };
 
 
diff --git a/src/demos/tunnel.c b/src/demos/tunnel.c
index 6e48ad4..84d1ca9 100644
--- a/src/demos/tunnel.c
+++ b/src/demos/tunnel.c
@@ -75,7 +75,7 @@ inittextures(void)
    glGenTextures(1, &t1id);
    glBindTexture(GL_TEXTURE_2D, t1id);
 
-   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "tile.rgb", GL_RGB)) {
+   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/tile.rgb", GL_RGB)) {
       fprintf(stderr, "Error reading a texture.\n");
       exit(-1);
    }
@@ -90,7 +90,7 @@ inittextures(void)
    glGenTextures(1, &t2id);
    glBindTexture(GL_TEXTURE_2D, t2id);
 
-   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "bw.rgb", GL_RGB)) {
+   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/bw.rgb", GL_RGB)) {
       fprintf(stderr, "Error reading a texture.\n");
       exit(-1);
    }
diff --git a/src/demos/tunnel2.c b/src/demos/tunnel2.c
index 800ea7b..943cbf4 100644
--- a/src/demos/tunnel2.c
+++ b/src/demos/tunnel2.c
@@ -73,7 +73,7 @@ inittextures(void)
    glGenTextures(1, &t1id);
    glBindTexture(GL_TEXTURE_2D, t1id);
 
-   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "tile.rgb", GL_RGB)) {
+   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/tile.rgb", GL_RGB)) {
       fprintf(stderr, "Error reading a texture.\n");
       exit(-1);
    }
@@ -88,7 +88,7 @@ inittextures(void)
    glGenTextures(1, &t2id);
    glBindTexture(GL_TEXTURE_2D, t2id);
 
-   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "bw.rgb", GL_RGB)) {
+   if (!LoadRGBMipmaps(DEMOS_DATA_DIR "data/bw.rgb", GL_RGB)) {
       fprintf(stderr, "Error reading a texture.\n");
       exit(-1);
    }
diff --git a/src/demos/winpos.c b/src/demos/winpos.c
index 162974e..18460a0 100644
--- a/src/demos/winpos.c
+++ b/src/demos/winpos.c
@@ -16,7 +16,7 @@
 
 #include "readtex.h"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 
 #ifndef M_PI
diff --git a/src/egl/opengl/CMakeLists.txt b/src/egl/opengl/CMakeLists.txt
index 854f64a..d7f3d94 100644
--- a/src/egl/opengl/CMakeLists.txt
+++ b/src/egl/opengl/CMakeLists.txt
@@ -21,7 +21,7 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 
@@ -35,12 +35,12 @@ set (targets
 foreach (target ${targets})
 	add_executable (${target}_screen ${target}.c)
 	target_link_libraries (${target}_screen eglut_screen)
-	install (TARGETS ${target}_screen DESTINATION ${subdir})
+	install (TARGETS ${target}_screen DESTINATION ${BINDIR}${subdir})
 
 	if (X11_FOUND)
 		add_executable (${target}_x11 ${target}.c)
 		target_link_libraries (${target}_x11 eglut_x11)
-		install (TARGETS ${target}_x11 DESTINATION ${subdir})
+		install (TARGETS ${target}_x11 DESTINATION ${BINDIR}${subdir})
 	endif ()
 endforeach (target)
 
diff --git a/src/fp/CMakeLists.txt b/src/fp/CMakeLists.txt
index a8aaad2..c28fd3e 100644
--- a/src/fp/CMakeLists.txt
+++ b/src/fp/CMakeLists.txt
@@ -33,9 +33,13 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
-file (GLOB data *.txt)
+file (GLOB data *.txt *.sh)
 
-install (FILES ${data} DESTINATION ${subdir})
+if (DEFINED BINDIR OR DEFINED DATADIR)
+	execute_process(COMMAND sed -i -e "s:.*fp-tri:${BINDIR}${subdir}/fp-tri:g" ${CMAKE_CURRENT_SOURCE_DIR}/run.sh)
+endif (DEFINED BINDIR OR DEFINED DATADIR)
+
+install (FILES ${data} DESTINATION ${DATADIR}${subdir})
diff --git a/src/fp/fp-tri.c b/src/fp/fp-tri.c
index f946dfa..15f5b1f 100644
--- a/src/fp/fp-tri.c
+++ b/src/fp/fp-tri.c
@@ -14,7 +14,7 @@
 #include "readtex.c"
 
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "bw.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/bw.rgb"
 
 unsigned show_fps = 0;
 unsigned int frame_cnt = 0;
diff --git a/src/fp/tri-tex.c b/src/fp/tri-tex.c
index fd04a53..141f73a 100644
--- a/src/fp/tri-tex.c
+++ b/src/fp/tri-tex.c
@@ -9,7 +9,7 @@
 #include "readtex.c"
 
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 
 
diff --git a/src/fpglsl/CMakeLists.txt b/src/fpglsl/CMakeLists.txt
index deb335b..aaf5c48 100644
--- a/src/fpglsl/CMakeLists.txt
+++ b/src/fpglsl/CMakeLists.txt
@@ -26,9 +26,9 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 file (GLOB data *.glsl)
 
-install (FILES ${data} DESTINATION ${subdir})
+install (FILES ${data} DESTINATION ${DATADIR}${subdir})
diff --git a/src/fpglsl/fp-tri.c b/src/fpglsl/fp-tri.c
index ebaadbe..f803ee8 100644
--- a/src/fpglsl/fp-tri.c
+++ b/src/fpglsl/fp-tri.c
@@ -14,7 +14,7 @@
 #include "readtex.c"
 
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "bw.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/bw.rgb"
 
 unsigned show_fps = 0;
 unsigned int frame_cnt = 0;
diff --git a/src/glsl/CMakeLists.txt b/src/glsl/CMakeLists.txt
index 11f8e37..040c892 100644
--- a/src/glsl/CMakeLists.txt
+++ b/src/glsl/CMakeLists.txt
@@ -58,9 +58,9 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 file (GLOB data *.frag *.vert *.shtest)
 
-install (FILES ${data} DESTINATION ${subdir})
+install (FILES ${data} DESTINATION ${DATADIR}${subdir})
diff --git a/src/glsl/brick.c b/src/glsl/brick.c
index 3021856..8148365 100644
--- a/src/glsl/brick.c
+++ b/src/glsl/brick.c
@@ -14,8 +14,8 @@
 #include "shaderutil.h"
 
 
-static char *FragProgFile = "CH06-brick.frag";
-static char *VertProgFile = "CH06-brick.vert";
+static char *FragProgFile = DEMOS_DATA_DIR "glsl/CH06-brick.frag";
+static char *VertProgFile = DEMOS_DATA_DIR "glsl/CH06-brick.vert";
 
 /* program/shader objects */
 static GLuint fragShader;
diff --git a/src/glsl/bump.c b/src/glsl/bump.c
index 59f62cd..a99d97e 100644
--- a/src/glsl/bump.c
+++ b/src/glsl/bump.c
@@ -15,10 +15,10 @@
 #include "readtex.h"
 
 
-static char *FragProgFile = "CH11-bumpmap.frag";
-static char *FragTexProgFile = "CH11-bumpmaptex.frag";
-static char *VertProgFile = "CH11-bumpmap.vert";
-static char *TextureFile = DEMOS_DATA_DIR "tile.rgb";
+static char *FragProgFile = DEMOS_DATA_DIR "glsl/CH11-bumpmap.frag";
+static char *FragTexProgFile = DEMOS_DATA_DIR "glsl/CH11-bumpmaptex.frag";
+static char *VertProgFile = DEMOS_DATA_DIR "glsl/CH11-bumpmap.vert";
+static char *TextureFile = DEMOS_DATA_DIR "data/tile.rgb";
 
 /* program/shader objects */
 static GLuint fragShader;
diff --git a/src/glsl/convolutions.c b/src/glsl/convolutions.c
index a120cfe..362bce5 100644
--- a/src/glsl/convolutions.c
+++ b/src/glsl/convolutions.c
@@ -40,7 +40,7 @@ struct Texture {
    GLenum format;
 };
 
-static const char *textureLocation = DEMOS_DATA_DIR "girl2.rgb";
+static const char *textureLocation = DEMOS_DATA_DIR "data/girl2.rgb";
 
 static GLfloat viewRotx = 0.0, viewRoty = 0.0, viewRotz = 0.0;
 static struct BoundingBox box;
diff --git a/src/glsl/mandelbrot.c b/src/glsl/mandelbrot.c
index 31ede1d..67e538e 100644
--- a/src/glsl/mandelbrot.c
+++ b/src/glsl/mandelbrot.c
@@ -14,8 +14,8 @@
 #include "shaderutil.h"
 
 
-static char *FragProgFile = "CH18-mandel.frag";
-static char *VertProgFile = "CH18-mandel.vert";
+static char *FragProgFile = DEMOS_DATA_DIR "glsl/CH18-mandel.frag";
+static char *VertProgFile = DEMOS_DATA_DIR "glsl/CH18-mandel.vert";
 
 /* program/shader objects */
 static GLuint fragShader;
diff --git a/src/glsl/multitex.c b/src/glsl/multitex.c
index 262ea50..c419d60 100644
--- a/src/glsl/multitex.c
+++ b/src/glsl/multitex.c
@@ -35,13 +35,13 @@
 
 static const char *Demo = "multitex";
 
-static const char *VertFile = "multitex.vert";
-static const char *FragFile = "multitex.frag";
+static const char *VertFile = DEMOS_DATA_DIR "glsl/multitex.vert";
+static const char *FragFile = DEMOS_DATA_DIR "glsl/multitex.frag";
 
 static const char *TexFiles[2] = 
    {
-      DEMOS_DATA_DIR "tile.rgb",
-      DEMOS_DATA_DIR "tree2.rgba"
+      DEMOS_DATA_DIR "data/tile.rgb",
+      DEMOS_DATA_DIR "data/tree2.rgba"
    };
 
 
diff --git a/src/glsl/simplex-noise.c b/src/glsl/simplex-noise.c
index 13fdd5d..261ed09 100644
--- a/src/glsl/simplex-noise.c
+++ b/src/glsl/simplex-noise.c
@@ -169,7 +169,7 @@ SpecialKey(int key, int x, int y)
 static void
 Init(void)
 {
-   const char *filename = "simplex-noise.glsl";
+   const char *filename = DEMOS_DATA_DIR "glsl/simplex-noise.glsl";
    char noiseText[10000];
    FILE *f;
    int len;
diff --git a/src/glsl/skinning.c b/src/glsl/skinning.c
index bf38d77..579f027 100644
--- a/src/glsl/skinning.c
+++ b/src/glsl/skinning.c
@@ -20,8 +20,8 @@
 #define M_PI 3.1415926535
 #endif
 
-static char *FragProgFile = "skinning.frag";
-static char *VertProgFile = "skinning.vert";
+static char *FragProgFile = DEMOS_DATA_DIR "glsl/skinning.frag";
+static char *VertProgFile = DEMOS_DATA_DIR "glsl/skinning.vert";
 
 /* program/shader objects */
 static GLuint fragShader;
diff --git a/src/glsl/texdemo1.c b/src/glsl/texdemo1.c
index 6cde239..8e73a3b 100644
--- a/src/glsl/texdemo1.c
+++ b/src/glsl/texdemo1.c
@@ -33,15 +33,15 @@
 #include "readtex.h"
 #include "shaderutil.h"
 
-static const char *Demo = "texdemo1";
+static const char *Demo = DEMOS_DATA_DIR "glsl/texdemo1";
 
-static const char *ReflectVertFile = "reflect.vert";
-static const char *CubeFragFile = "cubemap.frag";
+static const char *ReflectVertFile = DEMOS_DATA_DIR "glsl/reflect.vert";
+static const char *CubeFragFile = DEMOS_DATA_DIR "glsl/cubemap.frag";
 
-static const char *SimpleVertFile = "simple.vert";
-static const char *SimpleTexFragFile = "shadowtex.frag";
+static const char *SimpleVertFile = DEMOS_DATA_DIR "glsl/simple.vert";
+static const char *SimpleTexFragFile = DEMOS_DATA_DIR "glsl/shadowtex.frag";
 
-static const char *GroundImage = DEMOS_DATA_DIR "tile.rgb";
+static const char *GroundImage = DEMOS_DATA_DIR "data/tile.rgb";
 
 static GLuint Program1, Program2;
 
diff --git a/src/glsl/toyball.c b/src/glsl/toyball.c
index 5f27951..9bf440a 100644
--- a/src/glsl/toyball.c
+++ b/src/glsl/toyball.c
@@ -14,8 +14,8 @@
 #include "shaderutil.h"
 
 
-static char *FragProgFile = "CH11-toyball.frag";
-static char *VertProgFile = "CH11-toyball.vert";
+static char *FragProgFile = DEMOS_DATA_DIR "glsl/CH11-toyball.frag";
+static char *VertProgFile = DEMOS_DATA_DIR "glsl/CH11-toyball.vert";
 
 /* program/shader objects */
 static GLuint fragShader;
diff --git a/src/gs/CMakeLists.txt b/src/gs/CMakeLists.txt
index eef685d..8516013 100644
--- a/src/gs/CMakeLists.txt
+++ b/src/gs/CMakeLists.txt
@@ -26,9 +26,9 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 file (GLOB data *.glsl)
 
-install (FILES ${data} DESTINATION ${subdir})
+install (FILES ${data} DESTINATION ${DATADIR}${subdir})
diff --git a/src/objviewer/CMakeLists.txt b/src/objviewer/CMakeLists.txt
index fc61720..7bdd657 100644
--- a/src/objviewer/CMakeLists.txt
+++ b/src/objviewer/CMakeLists.txt
@@ -24,8 +24,8 @@ add_executable (objview
 	objview.c
 	skybox.c
 )
-install (TARGETS objview DESTINATION objviewer)
+install (TARGETS objview DESTINATION ${BINDIR}objviewer)
 
 file (GLOB data *.mtl *.obj *.rgb)
 
-install (FILES ${data} DESTINATION objviewer)
+install (FILES ${data} DESTINATION ${DATADIR}objviewer)
diff --git a/src/objviewer/objview.c b/src/objviewer/objview.c
index 6def726..7c94cc6 100644
--- a/src/objviewer/objview.c
+++ b/src/objviewer/objview.c
@@ -162,12 +162,12 @@ init_model(void)
 static void
 init_skybox(void)
 {
-   SkyboxTex = LoadSkyBoxCubeTexture("alpine_east.rgb",
-                                     "alpine_west.rgb",
-                                     "alpine_up.rgb",
-                                     "alpine_down.rgb",
-                                     "alpine_south.rgb",
-                                     "alpine_north.rgb");
+   SkyboxTex = LoadSkyBoxCubeTexture(DEMOS_DATA_DIR "objviewer/alpine_east.rgb",
+                                     DEMOS_DATA_DIR "objviewer/alpine_west.rgb",
+                                     DEMOS_DATA_DIR "objviewer/alpine_up.rgb",
+                                     DEMOS_DATA_DIR "objviewer/alpine_down.rgb",
+                                     DEMOS_DATA_DIR "objviewer/alpine_south.rgb",
+                                     DEMOS_DATA_DIR "objviewer/alpine_north.rgb");
    glmSpecularTexture(Model, SkyboxTex);
 }
 
@@ -475,7 +475,7 @@ main(int argc, char** argv)
    if (!Model_file) {
       fprintf(stderr, "usage: objview file.obj\n");
       fprintf(stderr, "(using default bunny.obj)\n");
-      Model_file = "bunny.obj";
+      Model_file = DEMOS_DATA_DIR "objviewer/bunny.obj";
    }
 
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
diff --git a/src/perf/CMakeLists.txt b/src/perf/CMakeLists.txt
index 68b6875..3f042c2 100644
--- a/src/perf/CMakeLists.txt
+++ b/src/perf/CMakeLists.txt
@@ -35,5 +35,5 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c common.c glmain.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
diff --git a/src/perf/glslstateschange.c b/src/perf/glslstateschange.c
index 7422b78..ecdd66b 100644
--- a/src/perf/glslstateschange.c
+++ b/src/perf/glslstateschange.c
@@ -60,10 +60,10 @@ static GLint P2TexCoord0_attr = -1, P2TexCoord1_attr = -1;
 
 static const char *TexFiles[4] =
    {
-      DEMOS_DATA_DIR "tile.rgb",
-      DEMOS_DATA_DIR "tree2.rgba",
-      DEMOS_DATA_DIR "tile.rgb",
-      DEMOS_DATA_DIR "tree2.rgba"
+      DEMOS_DATA_DIR "data/tile.rgb",
+      DEMOS_DATA_DIR "data/tree2.rgba",
+      DEMOS_DATA_DIR "data/tile.rgb",
+      DEMOS_DATA_DIR "data/tree2.rgba"
    };
 GLuint texObj[4];
 
diff --git a/src/redbook/CMakeLists.txt b/src/redbook/CMakeLists.txt
index 37201af..7c2f1bb 100644
--- a/src/redbook/CMakeLists.txt
+++ b/src/redbook/CMakeLists.txt
@@ -101,5 +101,5 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
diff --git a/src/samples/CMakeLists.txt b/src/samples/CMakeLists.txt
index b83ee91..699e7d5 100644
--- a/src/samples/CMakeLists.txt
+++ b/src/samples/CMakeLists.txt
@@ -56,7 +56,7 @@ foreach (target ${targets})
 		${GLUT_glut_LIBRARY}
 		${GLEW_glew_LIBRARY}
 	)
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 if (X11_FOUND)
@@ -77,6 +77,6 @@ if (X11_FOUND)
 			${X11_Xext_LIB}
 			${X11_X11_LIB}
 		)
-		install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+		install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 	endforeach (target)
 endif (X11_FOUND)
diff --git a/src/samples/sphere.c b/src/samples/sphere.c
index 6fb4001..7231e50 100644
--- a/src/samples/sphere.c
+++ b/src/samples/sphere.c
@@ -40,7 +40,7 @@
 GLenum doubleBuffer;
 int W = 400, H = 400;
 
-char *imageFileName = DEMOS_DATA_DIR "reflect.rgb";
+char *imageFileName = DEMOS_DATA_DIR "data/reflect.rgb";
 
 float *minFilter, *magFilter, *sWrapMode, *tWrapMode;
 float decal[] = {GL_DECAL};
diff --git a/src/slang/CMakeLists.txt b/src/slang/CMakeLists.txt
index 8e5c7e1..c214339 100644
--- a/src/slang/CMakeLists.txt
+++ b/src/slang/CMakeLists.txt
@@ -28,7 +28,7 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c framework.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
-install (FILES cltest.txt vstest.txt DESTINATION ${subdir})
+install (FILES cltest.txt vstest.txt DESTINATION ${DATADIR}${subdir})
diff --git a/src/slang/cltest.c b/src/slang/cltest.c
index dfff6cb..c25bfc5 100644
--- a/src/slang/cltest.c
+++ b/src/slang/cltest.c
@@ -159,7 +159,7 @@ void InitScene (void)
    vert = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB);
    glAttachObjectARB (prog, vert);
    glDeleteObjectARB (vert);
-   load_test_file ("cltest.txt", &program);
+   load_test_file (DEMOS_DATA_DIR "slang/cltest.txt", &program);
 }
 
 void RenderScene (void)
diff --git a/src/slang/vstest.c b/src/slang/vstest.c
index fa3c082..1458fe4 100644
--- a/src/slang/vstest.c
+++ b/src/slang/vstest.c
@@ -252,7 +252,7 @@ void InitScene (void)
    vert = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB);
    glAttachObjectARB (prog, vert);
    glDeleteObjectARB (vert);
-   load_test_file ("vstest.txt");
+   load_test_file (DEMOS_DATA_DIR "slang/vstest.txt");
    glLinkProgramARB (prog);
    if (!CheckObjectStatus (prog))
       exit (0);
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index c65505b..3d75476 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -148,7 +148,7 @@ foreach (target ${targets})
 		${GLUT_glut_LIBRARY}
 		${GLEW_glew_LIBRARY}
 	)
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 if (X11_FOUND)
@@ -173,6 +173,6 @@ if (X11_FOUND)
 			${X11_Xext_LIB}
 			${X11_X11_LIB}
 		)
-		install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+		install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 	endforeach (target)
 endif (X11_FOUND)
diff --git a/src/tests/afsmultiarb.c b/src/tests/afsmultiarb.c
index 51e7618..249a25e 100644
--- a/src/tests/afsmultiarb.c
+++ b/src/tests/afsmultiarb.c
@@ -16,8 +16,8 @@
 
 #include "readtex.h"
 
-#define TEXTURE_1_FILE DEMOS_DATA_DIR "girl.rgb"
-#define TEXTURE_2_FILE DEMOS_DATA_DIR "reflect.rgb"
+#define TEXTURE_1_FILE DEMOS_DATA_DIR "data/girl.rgb"
+#define TEXTURE_2_FILE DEMOS_DATA_DIR "data/reflect.rgb"
 
 #define TEX0 1
 #define TEX7 8
diff --git a/src/tests/arbfptexture.c b/src/tests/arbfptexture.c
index 8f68551..c3546fc 100644
--- a/src/tests/arbfptexture.c
+++ b/src/tests/arbfptexture.c
@@ -11,7 +11,7 @@
 #include "readtex.c"
 
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
 
diff --git a/src/tests/arbfptrig.c b/src/tests/arbfptrig.c
index f590751..cc1b75d 100644
--- a/src/tests/arbfptrig.c
+++ b/src/tests/arbfptrig.c
@@ -11,7 +11,7 @@
 #include "readtex.c"
 
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
 
diff --git a/src/tests/arbnpot.c b/src/tests/arbnpot.c
index 21875af..b5b3c31 100644
--- a/src/tests/arbnpot.c
+++ b/src/tests/arbnpot.c
@@ -12,7 +12,7 @@
 #include "glut_wrap.h"
 #include "../util/readtex.c"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLfloat Zrot = 0;
 
diff --git a/src/tests/arbvparray.c b/src/tests/arbvparray.c
index 1111afd..8c30f44 100644
--- a/src/tests/arbvparray.c
+++ b/src/tests/arbvparray.c
@@ -213,7 +213,7 @@ static void init(void)
    glEnable( GL_DEPTH_TEST );
    glEnable(GL_NORMALIZE);
    InitMaterials();
-   read_surface(DEMOS_DATA_DIR "isosurf.dat");
+   read_surface(DEMOS_DATA_DIR "data/isosurf.dat");
    init_program();
 }
 
diff --git a/src/tests/arraytexture.c b/src/tests/arraytexture.c
index 4d6b5c0..7816f68 100644
--- a/src/tests/arraytexture.c
+++ b/src/tests/arraytexture.c
@@ -53,15 +53,15 @@
     } while (0)
 
 static const char *const textures[] = {
-   DEMOS_DATA_DIR "girl.rgb",
-   DEMOS_DATA_DIR "girl2.rgb",
-   DEMOS_DATA_DIR "arch.rgb",
-   DEMOS_DATA_DIR "s128.rgb",
+   DEMOS_DATA_DIR "data/girl.rgb",
+   DEMOS_DATA_DIR "data/girl2.rgb",
+   DEMOS_DATA_DIR "data/arch.rgb",
+   DEMOS_DATA_DIR "data/s128.rgb",
 
-   DEMOS_DATA_DIR "tree3.rgb",
-   DEMOS_DATA_DIR "bw.rgb",
-   DEMOS_DATA_DIR "reflect.rgb",
-   DEMOS_DATA_DIR "wrs_logo.rgb",
+   DEMOS_DATA_DIR "data/tree3.rgb",
+   DEMOS_DATA_DIR "data/bw.rgb",
+   DEMOS_DATA_DIR "data/reflect.rgb",
+   DEMOS_DATA_DIR "data/wrs_logo.rgb",
    NULL
 };
 
diff --git a/src/tests/blendxor.c b/src/tests/blendxor.c
index af81a17..aaea3bf 100644
--- a/src/tests/blendxor.c
+++ b/src/tests/blendxor.c
@@ -10,7 +10,7 @@
 #include "glut_wrap.h"
 #include "readtex.c"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "arch.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/arch.rgb"
 
 static int ImgWidth, ImgHeight;
 static GLenum ImgFormat;
diff --git a/src/tests/bug_3195.c b/src/tests/bug_3195.c
index fd76307..c3cadb4 100644
--- a/src/tests/bug_3195.c
+++ b/src/tests/bug_3195.c
@@ -41,7 +41,7 @@
 
 #include "readtex.h"
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLfloat Xrot = 0, Yrot = -30, Zrot = 0;
 static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */
diff --git a/src/tests/bumpmap.c b/src/tests/bumpmap.c
index c77394a..d94950c 100644
--- a/src/tests/bumpmap.c
+++ b/src/tests/bumpmap.c
@@ -35,7 +35,7 @@
 
 #include "readtex.h"
 
-static const char *TexFile = DEMOS_DATA_DIR "arch.rgb";
+static const char *TexFile = DEMOS_DATA_DIR "data/arch.rgb";
 
 static const GLfloat Near = 5.0, Far = 25.0;
 
diff --git a/src/tests/ext422square.c b/src/tests/ext422square.c
index cf4bbdc..6514e41 100644
--- a/src/tests/ext422square.c
+++ b/src/tests/ext422square.c
@@ -18,7 +18,7 @@
 
 #include "../util/readtex.c"   /* I know, this is a hack. */
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "tile.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/tile.rgb"
 
 static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
 static GLint ImgWidth, ImgHeight;
diff --git a/src/tests/fillrate.c b/src/tests/fillrate.c
index f1365b8..1b5e62b 100644
--- a/src/tests/fillrate.c
+++ b/src/tests/fillrate.c
@@ -13,8 +13,8 @@
 #include "glut_wrap.h"
 #include "readtex.h"
 
-#define TEXTURE_1_FILE DEMOS_DATA_DIR "tile.rgb"
-#define TEXTURE_2_FILE DEMOS_DATA_DIR "reflect.rgb"
+#define TEXTURE_1_FILE DEMOS_DATA_DIR "data/tile.rgb"
+#define TEXTURE_2_FILE DEMOS_DATA_DIR "data/reflect.rgb"
 
 static int Win;
 static int Width = 1010, Height = 1010;
diff --git a/src/tests/floattex.c b/src/tests/floattex.c
index 1da850b..e8d13b1 100644
--- a/src/tests/floattex.c
+++ b/src/tests/floattex.c
@@ -13,7 +13,7 @@
 #include "shaderutil.h"
 
 
-static const char *TexFile = DEMOS_DATA_DIR "arch.rgb";
+static const char *TexFile = DEMOS_DATA_DIR "data/arch.rgb";
 
 static const char *FragShaderText = 
    "uniform sampler2D tex1; \n"
diff --git a/src/tests/fptexture.c b/src/tests/fptexture.c
index ab7cfc4..5e79ec6 100644
--- a/src/tests/fptexture.c
+++ b/src/tests/fptexture.c
@@ -11,7 +11,7 @@
 #include "../util/readtex.c"
 
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
 
diff --git a/src/tests/invert.c b/src/tests/invert.c
index a44b769..d562864 100644
--- a/src/tests/invert.c
+++ b/src/tests/invert.c
@@ -40,7 +40,7 @@
 
 #include "readtex.h"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "tree3.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/tree3.rgb"
 
 static int Width = 420;
 static int Height = 150;
diff --git a/src/tests/mipmap_limits.c b/src/tests/mipmap_limits.c
index dd17407..c79762f 100644
--- a/src/tests/mipmap_limits.c
+++ b/src/tests/mipmap_limits.c
@@ -56,7 +56,7 @@
 
 #include "readtex.h"
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLint BaseLevel = 0, MaxLevel = 9;
 static GLfloat MinLod = -1, MaxLod = 9;
diff --git a/src/tests/mipmap_view.c b/src/tests/mipmap_view.c
index 32df8da..9cba48a 100644
--- a/src/tests/mipmap_view.c
+++ b/src/tests/mipmap_view.c
@@ -15,7 +15,7 @@
 
 #include "readtex.h"
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "arch.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/arch.rgb"
 
 #define LEVELS 8
 #define SIZE (1<<LEVELS)
diff --git a/src/tests/multipal.c b/src/tests/multipal.c
index 5ba4f86..647f7ee 100644
--- a/src/tests/multipal.c
+++ b/src/tests/multipal.c
@@ -18,8 +18,8 @@
 
 #include "../util/readtex.c"   /* I know, this is a hack. */
 
-#define TEXTURE_1_FILE DEMOS_DATA_DIR "tile.rgb"
-#define TEXTURE_2_FILE DEMOS_DATA_DIR "reflect.rgb"
+#define TEXTURE_1_FILE DEMOS_DATA_DIR "data/tile.rgb"
+#define TEXTURE_2_FILE DEMOS_DATA_DIR "data/reflect.rgb"
 
 #define TEX0 1
 #define TEX1 2
diff --git a/src/tests/pbo.c b/src/tests/pbo.c
index dd0106f..bb2729f 100644
--- a/src/tests/pbo.c
+++ b/src/tests/pbo.c
@@ -15,7 +15,7 @@
 
 #include "../util/readtex.c"  /* a hack, I know */
 
-#define IMAGE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static int ImgWidth, ImgHeight;
 static GLenum ImgFormat;
diff --git a/src/tests/rubberband.c b/src/tests/rubberband.c
index 43772e7..b3b700b 100644
--- a/src/tests/rubberband.c
+++ b/src/tests/rubberband.c
@@ -9,7 +9,7 @@
 #include "glut_wrap.h"
 #include "readtex.c"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "arch.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/arch.rgb"
 
 static int ImgWidth, ImgHeight;
 static GLenum ImgFormat;
diff --git a/src/tests/texcmp.c b/src/tests/texcmp.c
index 9782b79..c76137e 100644
--- a/src/tests/texcmp.c
+++ b/src/tests/texcmp.c
@@ -11,7 +11,7 @@
 #include "glut_wrap.h"
 
 #include "readtex.c" /* I know, this is a hack. */
-#define TEXTURE_FILE DEMOS_DATA_DIR "tree2.rgba"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/tree2.rgba"
 
 
 static float Rot = 0.0;
diff --git a/src/tests/texcompress2.c b/src/tests/texcompress2.c
index 142bba1..80bce92 100644
--- a/src/tests/texcompress2.c
+++ b/src/tests/texcompress2.c
@@ -9,7 +9,7 @@
 #include "glut_wrap.h"
 #include "readtex.c"
 
-#define IMAGE_FILE DEMOS_DATA_DIR "arch.rgb"
+#define IMAGE_FILE DEMOS_DATA_DIR "data/arch.rgb"
 
 static int ImgWidth, ImgHeight;
 static GLenum ImgFormat;
diff --git a/src/tests/texline.c b/src/tests/texline.c
index 815de12..0b94851 100644
--- a/src/tests/texline.c
+++ b/src/tests/texline.c
@@ -13,7 +13,7 @@
 #include "glut_wrap.h"
 #include "../util/readtex.c"   /* I know, this is a hack. */
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLboolean Antialias = GL_FALSE;
 static GLboolean Animate = GL_FALSE;
diff --git a/src/tests/texrect.c b/src/tests/texrect.c
index fa84449..9709615 100644
--- a/src/tests/texrect.c
+++ b/src/tests/texrect.c
@@ -14,8 +14,8 @@
 #include "glut_wrap.h"
 #include "readtex.h"
 
-#define TEXTURE_0_FILE DEMOS_DATA_DIR "girl.rgb"
-#define TEXTURE_1_FILE DEMOS_DATA_DIR "reflect.rgb"
+#define TEXTURE_0_FILE DEMOS_DATA_DIR "data/girl.rgb"
+#define TEXTURE_1_FILE DEMOS_DATA_DIR "data/reflect.rgb"
 
 #define TEX0 1
 #define TEX7 8
diff --git a/src/tests/vparray.c b/src/tests/vparray.c
index 3de6180..18c27f8 100644
--- a/src/tests/vparray.c
+++ b/src/tests/vparray.c
@@ -208,7 +208,7 @@ static void init(void)
    glEnable( GL_DEPTH_TEST );
    glEnable(GL_NORMALIZE);
    InitMaterials();
-   read_surface(DEMOS_DATA_DIR "isosurf.dat");
+   read_surface(DEMOS_DATA_DIR "data/isosurf.dat");
    init_program();
 }
 
diff --git a/src/tests/yuvrect.c b/src/tests/yuvrect.c
index c39ac1b..3860aba 100644
--- a/src/tests/yuvrect.c
+++ b/src/tests/yuvrect.c
@@ -14,7 +14,7 @@
 
 #include "../util/readtex.c"   /* I know, this is a hack. */
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl.rgb"
 
 static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
 static GLint ImgWidth, ImgHeight;
diff --git a/src/tests/yuvsquare.c b/src/tests/yuvsquare.c
index 35b53bf..7e7dc59 100644
--- a/src/tests/yuvsquare.c
+++ b/src/tests/yuvsquare.c
@@ -14,7 +14,7 @@
 
 #include "../util/readtex.c"   /* I know, this is a hack. */
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "tile.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/tile.rgb"
 
 static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
 static GLint ImgWidth, ImgHeight;
diff --git a/src/trivial/CMakeLists.txt b/src/trivial/CMakeLists.txt
index 267fa23..a6d4387 100644
--- a/src/trivial/CMakeLists.txt
+++ b/src/trivial/CMakeLists.txt
@@ -198,5 +198,5 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
diff --git a/src/vp/CMakeLists.txt b/src/vp/CMakeLists.txt
index 5bc4911..7d2e4d3 100644
--- a/src/vp/CMakeLists.txt
+++ b/src/vp/CMakeLists.txt
@@ -26,9 +26,13 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
-file (GLOB data *.txt)
+file (GLOB data *.txt *.sh)
 
-install (FILES ${data} DESTINATION ${subdir})
+if (DEFINED BINDIR OR DEFINED DATADIR)
+	execute_process(COMMAND sed -i -e "s:.*vp-tris:${BINDIR}${subdir}/vp-tris:g" ${CMAKE_CURRENT_SOURCE_DIR}/run.sh)
+endif (DEFINED BINDIR OR DEFINED DATADIR)
+
+install (FILES ${data} DESTINATION ${DATADIR}${subdir})
diff --git a/src/vpglsl/CMakeLists.txt b/src/vpglsl/CMakeLists.txt
index 36ee986..190d4ee 100644
--- a/src/vpglsl/CMakeLists.txt
+++ b/src/vpglsl/CMakeLists.txt
@@ -26,9 +26,9 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 file (GLOB data *.glsl)
 
-install (FILES ${data} DESTINATION ${subdir})
+install (FILES ${data} DESTINATION ${DATADIR}${subdir})
diff --git a/src/wgl/CMakeLists.txt b/src/wgl/CMakeLists.txt
index 88e6a20..2462008 100644
--- a/src/wgl/CMakeLists.txt
+++ b/src/wgl/CMakeLists.txt
@@ -15,4 +15,4 @@ set_target_properties (wgl_sharedtex_mt PROPERTIES OUTPUT_NAME sharedtex_mt)
 add_executable (wglinfo wglinfo.c)
 add_executable (wglcontext wglcontext.c)
 
-install (TARGETS wglthreads wgl_sharedtex_mt wglinfo DESTINATION wgl)
+install (TARGETS wglthreads wgl_sharedtex_mt wglinfo DESTINATION ${DATADIR}wgl)
diff --git a/src/xdemos/CMakeLists.txt b/src/xdemos/CMakeLists.txt
index ee8b12d..c85b52c 100644
--- a/src/xdemos/CMakeLists.txt
+++ b/src/xdemos/CMakeLists.txt
@@ -62,7 +62,7 @@ set (targets
 foreach (target ${targets})
 	add_executable (${subdir}_${target} ${target}.c)
 	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
-	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+	install (TARGETS ${subdir}_${target} DESTINATION ${BINDIR}${subdir})
 endforeach (target)
 
 target_link_libraries (${subdir}_glthreads pthread)
@@ -74,4 +74,4 @@ target_link_libraries (${subdir}_sharedtex_mt pthread)
 add_executable (corender corender.c ipc.c) 
 add_executable (xrotfontdemo xrotfontdemo.c xuserotfont.c)
 
-install (TARGETS corender xrotfontdemo DESTINATION demos)
+install (TARGETS corender xrotfontdemo DESTINATION ${BINDIR}demos)
diff --git a/src/xdemos/yuvrect_client.c b/src/xdemos/yuvrect_client.c
index ccbd479..933eaba 100644
--- a/src/xdemos/yuvrect_client.c
+++ b/src/xdemos/yuvrect_client.c
@@ -16,7 +16,7 @@
 
 #include "../util/readtex.c"   /* I know, this is a hack. */
 
-#define TEXTURE_FILE DEMOS_DATA_DIR "girl2.rgb"
+#define TEXTURE_FILE DEMOS_DATA_DIR "data/girl2.rgb"
 
 static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
 static GLint ImgWidth, ImgHeight;
-- 
1.7.7



More information about the mesa-dev mailing list