Description: Install to FHS-compliant locations and handle DESTDIR
Author: Stephen Kitt <skitt@debian.org>

--- nestopia.orig/Makefile
+++ nestopia/Makefile
@@ -4,8 +4,8 @@
 # By R. Danbrook 2012
 #
 
-CC   = @gcc
-CXX  = @g++
+CC   = gcc
+CXX  = g++
 CFLAGS ?= -O3 -g3
 CXXFLAGS ?= -O3 -g3
 CPPFLAGS += -DNST_PRAGMA_ONCE_SUPPORT -D_SZ_ONE_DIRECTORY
@@ -36,8 +36,8 @@
 	CPPFLAGS += -DBSD
 endif
 
-PREFIX = /usr/local
-BINDIR = $(PREFIX)/bin
+PREFIX = /usr
+BINDIR = $(PREFIX)/games
 DATADIR = $(PREFIX)/share/nestopia
 
 # OpenGL Support
@@ -190,15 +190,16 @@
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LIBS)
 
 install:
-	mkdir -p $(DATADIR)/icons
-	mkdir -p $(PREFIX)/share/pixmaps
-	install -m 0755 $(BIN) $(BINDIR)
-	install -m 0644 source/unix/icons/nestopia.desktop $(DATADIR)
-	install -m 0644 NstDatabase.xml $(DATADIR)
-	install -m 0644 source/unix/icons/*.png $(DATADIR)/icons
-	install -m 0644 source/unix/icons/*.svg $(DATADIR)/icons
-	install -m 0644 source/unix/icons/nestopia.svg $(PREFIX)/share/pixmaps
-	xdg-desktop-menu install --novendor $(DATADIR)/nestopia.desktop
+	mkdir -p $(DESTDIR)/$(BINDIR)
+	mkdir -p $(DESTDIR)/$(PREFIX)/share/applications
+	mkdir -p $(DESTDIR)/$(DATADIR)/icons
+	mkdir -p $(DESTDIR)/$(PREFIX)/share/pixmaps
+	install -m 0755 $(BIN) $(DESTDIR)/$(BINDIR)
+	install -m 0644 source/unix/icons/nestopia.desktop $(DESTDIR)/$(PREFIX)/share/applications
+	install -m 0644 NstDatabase.xml $(DESTDIR)/$(DATADIR)
+	install -m 0644 source/unix/icons/*.png $(DESTDIR)/$(DATADIR)/icons
+	install -m 0644 source/unix/icons/*.svg $(DESTDIR)/$(DATADIR)/icons
+	install -m 0644 source/unix/icons/nestopia.svg $(DESTDIR)/$(PREFIX)/share/pixmaps
 
 uninstall:
 	xdg-desktop-menu uninstall $(DATADIR)/nestopia.desktop
