diff -Naupr wahcade-0.99pre8.orig/install wahcade-0.99pre8/install
--- wahcade-0.99pre8.orig/install	2008-12-18 17:29:22.000000000 +0100
+++ wahcade-0.99pre8/install	2009-11-02 14:59:05.520320648 +0100
@@ -3,106 +3,108 @@
 NAME=wahcade
 LAYOUT_NAME=wahcade-layout-editor
 SETUP_NAME=wahcade-setup
-PREFIX=/usr/local
-BINDIR=$PREFIX/bin
-DESTDIR=$PREFIX/share/$NAME
+PREFIX=${PREFIX:-/usr/local}
+BINDIR=${BINDIR:-${PREFIX}/bin}
+DATADIR=${DATADIR:-${PREFIX}/share}
+
+mkdir -p $DESTDIR/{$PREFIX,$BINDIR,$DATADIR}
 
 #wahcade start script
-echo "#!/bin/bash" > $BINDIR/$NAME
-echo "cd ${DESTDIR}" >> $BINDIR/$NAME
-echo "python ${NAME}.py \$*" >> $BINDIR/$NAME
-chmod 755 $BINDIR/$NAME
+echo "#!/bin/bash" > $DESTDIR$BINDIR/$NAME
+echo "cd ${DATADIR}/$NAME" >> $DESTDIR$BINDIR/$NAME
+echo "exec python ${NAME}.py \$*" >> $DESTDIR$BINDIR/$NAME
+chmod 755 $DESTDIR$BINDIR/$NAME
 
 #wahcade layout editor start script
-echo "#!/bin/bash" > $BINDIR/$LAYOUT_NAME
-echo "cd ${DESTDIR}" >> $BINDIR/$LAYOUT_NAME
-echo "python ${LAYOUT_NAME}.py \$*" >> $BINDIR/$LAYOUT_NAME
-chmod 755 $BINDIR/$LAYOUT_NAME
+echo "#!/bin/bash" > $DESTDIR$BINDIR/$LAYOUT_NAME
+echo "cd ${DATADIR}/$NAME" >> $DESTDIR$BINDIR/$LAYOUT_NAME
+echo "exec python ${LAYOUT_NAME}.py \$*" >> $DESTDIR$BINDIR/$LAYOUT_NAME
+chmod 755 $DESTDIR$BINDIR/$LAYOUT_NAME
 
 #wahcade setup start script
-echo "#!/bin/bash" > $BINDIR/$SETUP_NAME
-echo "cd ${DESTDIR}" >> $BINDIR/$SETUP_NAME
-echo "python ${SETUP_NAME}.py \$*" >> $BINDIR/$SETUP_NAME
-chmod 755 $BINDIR/$SETUP_NAME
+echo "#!/bin/bash" > $DESTDIR$BINDIR/$SETUP_NAME
+echo "cd ${DATADIR}/$NAME" >> $DESTDIR$BINDIR/$SETUP_NAME
+echo "python ${SETUP_NAME}.py \$*" >> $DESTDIR$BINDIR/$SETUP_NAME
+chmod 755 $DESTDIR$BINDIR/$SETUP_NAME
 
 #install files
-install -D --mode=755 $NAME.desktop $PREFIX/share/applications/$NAME.desktop
-install --directory $DESTDIR
-install --mode=644 *.py $DESTDIR
-install --directory $DESTDIR/config.dist
-install --directory $DESTDIR/config.dist/ctrlr
-install --directory $DESTDIR/config.dist/files
-install --directory $DESTDIR/config.dist/ini
-install --directory $DESTDIR/config.dist/layouts
-install --directory $DESTDIR/config.dist/layouts/classic_480x640
-install --directory $DESTDIR/config.dist/layouts/classic_640x480
-install --directory $DESTDIR/config.dist/layouts/classic_800x600
-install --directory $DESTDIR/config.dist/layouts/classic_1024x768
-install --directory $DESTDIR/config.dist/layouts/classic_cpviewer
-install --directory $DESTDIR/config.dist/layouts/classic_histview
-install --directory $DESTDIR/config.dist/layouts/retro_black_640x480
-install --directory $DESTDIR/config.dist/layouts/retro_black_800x600
-install --directory $DESTDIR/config.dist/layouts/retro_black_1024x768
-install --directory $DESTDIR/config.dist/layouts/retro_white_640x480
-install --directory $DESTDIR/config.dist/layouts/retro_white_800x600
-install --directory $DESTDIR/config.dist/layouts/retro_white_1024x768
-install --directory $DESTDIR/config.dist/layouts/retro_cpviewer
-install --directory $DESTDIR/config.dist/layouts/retro_histview
-install --directory $DESTDIR/doc
-install --directory $DESTDIR/doc/file_formats
-install --directory $DESTDIR/doc/xmame
-install --directory $DESTDIR/glade
-install --directory $DESTDIR/locale
-install --directory $DESTDIR/locale/de/
-install --directory $DESTDIR/locale/de/LC_MESSAGES
-install --directory $DESTDIR/locale/en_GB/
-install --directory $DESTDIR/locale/en_GB/LC_MESSAGES
-install --directory $DESTDIR/locale/en/
-install --directory $DESTDIR/locale/en/LC_MESSAGES
-install --directory $DESTDIR/locale/es/
-install --directory $DESTDIR/locale/es/LC_MESSAGES
-install --directory $DESTDIR/locale/fr/
-install --directory $DESTDIR/locale/fr/LC_MESSAGES
-install --directory $DESTDIR/locale/sv/
-install --directory $DESTDIR/locale/sv/LC_MESSAGES
-install --directory $DESTDIR/pixmaps
-install --directory $DESTDIR/templates
-#install --mode=644 ../common/glade2.py $DESTDIR
-install --mode=644 config.dist/* $DESTDIR/config.dist
-install --mode=644 config.dist/ctrlr/* $DESTDIR/config.dist/ctrlr
-install --mode=644 config.dist/files/.* $DESTDIR/config.dist/files
-install --mode=644 config.dist/ini/* $DESTDIR/config.dist/ini
-install --mode=644 config.dist/layouts/classic_480x640/* $DESTDIR/config.dist/layouts/classic_480x640
-install --mode=644 config.dist/layouts/classic_640x480/* $DESTDIR/config.dist/layouts/classic_640x480
-install --mode=644 config.dist/layouts/classic_800x600/* $DESTDIR/config.dist/layouts/classic_800x600
-install --mode=644 config.dist/layouts/classic_1024x768/* $DESTDIR/config.dist/layouts/classic_1024x768
-install --mode=644 config.dist/layouts/classic_cpviewer/* $DESTDIR/config.dist/layouts/classic_cpviewer
-install --mode=644 config.dist/layouts/classic_histview/* $DESTDIR/config.dist/layouts/classic_histview
-install --mode=644 config.dist/layouts/retro_black_640x480/* $DESTDIR/config.dist/layouts/retro_black_640x480
-install --mode=644 config.dist/layouts/retro_black_800x600/* $DESTDIR/config.dist/layouts/retro_black_800x600
-install --mode=644 config.dist/layouts/retro_black_1024x768/* $DESTDIR/config.dist/layouts/retro_black_1024x768
-install --mode=644 config.dist/layouts/retro_white_640x480/* $DESTDIR/config.dist/layouts/retro_white_640x480
-install --mode=644 config.dist/layouts/retro_white_800x600/* $DESTDIR/config.dist/layouts/retro_white_800x600
-install --mode=644 config.dist/layouts/retro_white_1024x768/* $DESTDIR/config.dist/layouts/retro_white_1024x768
-install --mode=644 config.dist/layouts/retro_cpviewer/* $DESTDIR/config.dist/layouts/retro_cpviewer
-install --mode=644 config.dist/layouts/retro_histview/* $DESTDIR/config.dist/layouts/retro_histview
-install --mode=644 doc/* $DESTDIR/doc
-install --mode=644 doc/file_formats/* $DESTDIR/doc/file_formats
-install --mode=644 doc/xmame/* $DESTDIR/doc/xmame
-install --mode=644 glade/*.glade $DESTDIR/glade
-install --mode=644 glade/*.png $DESTDIR/glade
-install --mode=644 locale/de/LC_MESSAGES/*.mo $DESTDIR/locale/de/LC_MESSAGES
-install --mode=644 locale/en_GB/LC_MESSAGES/*.mo $DESTDIR/locale/en_GB/LC_MESSAGES
-install --mode=644 locale/en/LC_MESSAGES/*.mo $DESTDIR/locale/en/LC_MESSAGES
-install --mode=644 locale/es/LC_MESSAGES/*.mo $DESTDIR/locale/es/LC_MESSAGES
-install --mode=644 locale/fr/LC_MESSAGES/*.mo $DESTDIR/locale/fr/LC_MESSAGES
-install --mode=644 locale/sv/LC_MESSAGES/*.mo $DESTDIR/locale/sv/LC_MESSAGES
-install --mode=644 pixmaps/*.png $DESTDIR/pixmaps
-install --mode=644 pixmaps/*.ico $DESTDIR/pixmaps
-install --mode=644 templates/*.ini $DESTDIR/templates
-install --mode=644 $NAME.desktop /usr/share/applications
-install --mode=644 pixmaps/$NAME.png /usr/share/pixmaps
+#install -D --mode=755 $NAME.desktop $PREFIX/share/applications/$NAME.desktop
+install --directory $DESTDIR$DATADIR/$NAME
+install --mode=644 *.py $DESTDIR$DATADIR/$NAME
+install --directory $DESTDIR$DATADIR/$NAME/config.dist
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/ctrlr
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/files
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/ini
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_480x640
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_640x480
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_800x600
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_1024x768
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_cpviewer
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_histview
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_black_640x480
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_black_800x600
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_black_1024x768
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_white_640x480
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_white_800x600
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_white_1024x768
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_cpviewer
+install --directory $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_histview
+install --directory $DESTDIR$DATADIR/$NAME/doc
+install --directory $DESTDIR$DATADIR/$NAME/doc/file_formats
+install --directory $DESTDIR$DATADIR/$NAME/doc/xmame
+install --directory $DESTDIR$DATADIR/$NAME/glade
+install --directory $DESTDIR$DATADIR/locale
+install --directory $DESTDIR$DATADIR/locale/de/
+install --directory $DESTDIR$DATADIR/locale/de/LC_MESSAGES
+install --directory $DESTDIR$DATADIR/locale/en_GB/
+install --directory $DESTDIR$DATADIR/locale/en_GB/LC_MESSAGES
+install --directory $DESTDIR$DATADIR/locale/en/
+install --directory $DESTDIR$DATADIR/locale/en/LC_MESSAGES
+install --directory $DESTDIR$DATADIR/locale/es/
+install --directory $DESTDIR$DATADIR/locale/es/LC_MESSAGES
+install --directory $DESTDIR$DATADIR/locale/fr/
+install --directory $DESTDIR$DATADIR/locale/fr/LC_MESSAGES
+install --directory $DESTDIR$DATADIR/locale/sv/
+install --directory $DESTDIR$DATADIR/locale/sv/LC_MESSAGES
+install --directory $DESTDIR$DATADIR/pixmaps
+install --directory $DESTDIR$DATADIR/$NAME/templates
+#install --mode=644 ../common/glade2.py $DESTDIR$DATADIR
+install --mode=644 config.dist/* $DESTDIR$DATADIR/$NAME/config.dist
+install --mode=644 config.dist/ctrlr/* $DESTDIR$DATADIR/$NAME/config.dist/ctrlr
+install --mode=644 config.dist/files/.* $DESTDIR$DATADIR/$NAME/config.dist/files
+install --mode=644 config.dist/ini/* $DESTDIR$DATADIR/$NAME/config.dist/ini
+install --mode=644 config.dist/layouts/classic_480x640/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_480x640
+install --mode=644 config.dist/layouts/classic_640x480/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_640x480
+install --mode=644 config.dist/layouts/classic_800x600/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_800x600
+install --mode=644 config.dist/layouts/classic_1024x768/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_1024x768
+install --mode=644 config.dist/layouts/classic_cpviewer/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_cpviewer
+install --mode=644 config.dist/layouts/classic_histview/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/classic_histview
+install --mode=644 config.dist/layouts/retro_black_640x480/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_black_640x480
+install --mode=644 config.dist/layouts/retro_black_800x600/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_black_800x600
+install --mode=644 config.dist/layouts/retro_black_1024x768/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_black_1024x768
+install --mode=644 config.dist/layouts/retro_white_640x480/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_white_640x480
+install --mode=644 config.dist/layouts/retro_white_800x600/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_white_800x600
+install --mode=644 config.dist/layouts/retro_white_1024x768/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_white_1024x768
+install --mode=644 config.dist/layouts/retro_cpviewer/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_cpviewer
+install --mode=644 config.dist/layouts/retro_histview/* $DESTDIR$DATADIR/$NAME/config.dist/layouts/retro_histview
+install --mode=644 glade/*.glade $DESTDIR$DATADIR/$NAME/glade
+install --mode=644 glade/*.png $DESTDIR$DATADIR/$NAME/glade
+install --mode=644 locale/de/LC_MESSAGES/*.mo $DESTDIR$DATADIR/locale/de/LC_MESSAGES
+install --mode=644 locale/en_GB/LC_MESSAGES/*.mo $DESTDIR$DATADIR/locale/en_GB/LC_MESSAGES
+install --mode=644 locale/en/LC_MESSAGES/*.mo $DESTDIR$DATADIR/locale/en/LC_MESSAGES
+install --mode=644 locale/es/LC_MESSAGES/*.mo $DESTDIR$DATADIR/locale/es/LC_MESSAGES
+install --mode=644 locale/fr/LC_MESSAGES/*.mo $DESTDIR$DATADIR/locale/fr/LC_MESSAGES
+install --mode=644 locale/sv/LC_MESSAGES/*.mo $DESTDIR$DATADIR/locale/sv/LC_MESSAGES
+install --directory $DESTDIR$DATADIR/$NAME/pixmaps
+install --mode=644 pixmaps/*.png $DESTDIR$DATADIR/$NAME/pixmaps
+install --mode=644 pixmaps/*.ico $DESTDIR$DATADIR/$NAME/pixmaps
+install --mode=644 templates/*.ini $DESTDIR$DATADIR/$NAME/templates
+install --directory $DESTDIR$DATADIR/pixmaps
+install --mode=644 pixmaps/$NAME.png $DESTDIR$DATADIR/pixmaps
+install --directory $DESTDIR$DATADIR/applications
+install --mode=644 $NAME.desktop $DESTDIR$DATADIR/applications
 
 #compile everything python
-python -c "import compileall; compileall.compile_dir('${DESTDIR}')"
+python -c "import compileall; compileall.compile_dir('${DESTDIR}${DATADIR}')"
 
