--- Makefile.orig	2003-02-25 19:31:32.000000000 +0300
+++ Makefile	2014-11-29 04:34:05.000000000 +0300
@@ -1,9 +1,9 @@
-CC=gcc
+CC?=gcc
 
-SDLCONFIG=sdl-config
+SDLCONFIG=${SDL_CONFIG}
 
 ifndef prefix
-  prefix=/usr/local
+  prefix=${PREFIX}
   #prefix=/usr
 endif
 
@@ -12,7 +12,7 @@
 endif
 
 ifndef mandir
-  mandir=$(prefix)/share/man
+  mandir=$(prefix)/man
 endif
 
 ifndef bindir
@@ -21,12 +21,12 @@
 
 
 ifndef highscoredir
-  highscoredir=/var/local/lib/games
+  highscoredir=/var/games
   #highscoredir=/var/lib/games
 endif
 
 
-CFLAGS=-Wall $(OPTIMIZE) $(SDL_CFLAGS) -DDATAPREFIX=\"$(datadir)/icebreaker\" -DHISCOREPREFIX=\"$(highscoredir)\"
+CFLAGS+=-Wall $(SDL_CFLAGS) -DDATAPREFIX=\"$(datadir)/icebreaker\" -DHISCOREPREFIX=\"$(highscoredir)\"
 
 SRC=icebreaker.c cursor.c grid.c laundry.c line.c penguin.c sound.c \
     level.c intro.c text.c status.c transition.c hiscore.c dialog.c \
@@ -40,7 +40,7 @@
 SDL_CFLAGS := $(shell $(SDLCONFIG) --cflags)
 SDL_LDFLAGS := $(shell $(SDLCONFIG) --libs)
 VERSION := $(shell awk '/^\#define VERSION/ { print $$3 }' icebreaker.h)
-VERDATE := $(shell date -r icebreaker.h +"%d %B %Y")
+VERDATE := $(shell date -r $(shell stat -f %m icebreaker.h) +"%d %B %Y")
 
 CROSSTOOLSPATH=/usr/local/cross-tools
 # note that you almost certainly want to set wine to use the tty driver instead
@@ -177,7 +177,7 @@
 	[ -d win32.build ] && rm -rf win32.build || true
 
 icebreaker:	$(SRC:.c=.o)
-	$(CC) $(CFLAGS) $^ -o icebreaker $(SDL_LIB)
+	$(CC) $(LDFLAGS) $^ -o icebreaker $(SDL_LIB)
 
 man: icebreaker.6
 
@@ -190,31 +190,25 @@
 	   sed 's?\$$HIGHSCOREDIR?$(highscoredir)/?' > $@
 
 install-mkdirs:
-	mkdir -p $(datadir)/icebreaker
-	mkdir -p $(bindir)
-	mkdir -p $(highscoredir)
-	mkdir -p $(mandir)/man6
+	mkdir -p ${DESTDIR}$(datadir)/icebreaker
+	mkdir -p ${DESTDIR}$(bindir)
+	mkdir -p ${DESTDIR}$(highscoredir)
+	mkdir -p ${DESTDIR}$(mandir)/man6
 
 themes-install: install-themes
 
 install-themes:
-	install -m 644 *.ibt $(datadir)/icebreaker
-	install -m 644 *.wav *.bmp $(datadir)/icebreaker
+	${BSD_INSTALL_DATA} *.ibt ${DESTDIR}$(datadir)/icebreaker
+	${BSD_INSTALL_DATA} *.wav *.bmp ${DESTDIR}$(datadir)/icebreaker
 
 install-bin: icebreaker
-	install -s -g games -m 2755 icebreaker $(bindir) || \
-	  install -s -m 755 icebreaker $(bindir)
-	@test -g $(bindir)/icebreaker || \
-	  echo -e '*** Note: icebreaker binary not installed set-group-ID "games" -- shared\n*** highscores may be impossible. (Try installing as root.)'
+	${BSD_INSTALL_PROGRAM} icebreaker ${DESTDIR}$(bindir)
 
 install-man: icebreaker.6
-	install -m 644 icebreaker.6 $(mandir)/man6
+	${BSD_INSTALL_MAN} icebreaker.6 ${DESTDIR}$(mandir)/man6
 
 install-scorefile:
-	touch $(highscoredir)/icebreaker.scores
-	chown -f games:games $(highscoredir)/icebreaker.scores && \
-	chmod 664 $(highscoredir)/icebreaker.scores || \
-	chmod 644 $(highscoredir)/icebreaker.scores
+	touch ${DESTDIR}$(highscoredir)/icebreaker.scores.sample
 
 
 install: all install-mkdirs install-themes install-bin install-man install-scorefile