$NetBSD: patch-Makefile,v 1.4 2023/01/04 09:34:45 wiz Exp $

- Add DESTDIR support.
- Support install(1) that does not create directories automatically.
- Fix linking against freetype.
- Honor LDFLAGS.

--- Makefile.orig	2021-06-27 13:07:44.000000000 +0000
+++ Makefile
@@ -6,6 +6,7 @@
 # Modified 2009-02-09 by Tupone Alfredo <tupone@gentoo.org>
 # Modified 2018-02-19 by Jordan Evens <jordan.evens@gmail.com>
 
+DESTDIR?=
 # Einstein Puzzle is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
@@ -35,15 +36,9 @@ else
 	PREFIX=/usr/local
 	PROFILER=#-pg
 	LIBS=
-	ifeq ($(UNAME_S),Linux)
-		CXXFLAGS=-pipe -Wall $(OPTIMIZE) $(DEBUG) `sdl-config --cflags` -DPREFIX=L\"$(PREFIX)\" $(PROFILER)
-		LNFLAGS=-pipe `sdl-config --libs` -lz -lSDL_mixer -lSDL_ttf -lfreetype $(PROFILER)
-		INSTALL=install
-	endif
-	ifeq ($(UNAME_S),Darwin)
-		CXXFLAGS=-pipe -Wall $(OPTIMIZE) $(DEBUG) -I/Library/Frameworks/SDL.framework/Headers/ -I/Library/Frameworks/SDL_ttf.framework/Headers/ -I/Library/Frameworks/SDL_mixer.framework/Headers/ -DPREFIX=L\"$(PREFIX)\" $(PROFILER)
-		LNFLAGS=-pipe -framework Cocoa -framework SDL_ttf -framework SDL -framework SDL_mixer -lSDLmain -lz  $(PROFILER)
-	endif
+	CXXFLAGS+=-pipe -Wall $(OPTIMIZE) $(DEBUG) `sdl-config --cflags` -DPREFIX=L\"$(PREFIX)\" $(PROFILER)
+	LNFLAGS=$(LDFLAGS) -pipe `sdl-config --libs` -lz -lSDL_mixer -lSDL_ttf -lfreetype $(PROFILER)
+	INSTALL=install
 endif
 
 MKRES=mkres$(EXE)
@@ -104,8 +99,10 @@ run: einstein
 	./einstein
 
 install: $(TARGET)
-	$(INSTALL) -s -D $(TARGET) $(PREFIX)/bin/$(TARGET)
-	$(INSTALL) -D einstein.res $(PREFIX)/share/einstein/res/einstein.res
+	$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
+	$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/einstein/res
+	$(INSTALL) -s $(TARGET) $(DESTDIR)$(PREFIX)/bin/$(TARGET)
+	$(INSTALL) einstein.res $(DESTDIR)$(PREFIX)/share/einstein/res/einstein.res
 
 $(DEPDIR)/%.d: ;
 .PRECIOUS: $(DEPDIR)/%.d
