File teeworlds-0.6.4-extlibs-optflags.patch of Package teeworlds

diff -aur teeworlds-0.6.4-src/bam.lua teeworlds-0.6.4-src_patched/bam.lua
--- teeworlds-0.6.4-src/bam.lua	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/bam.lua	2016-11-10 18:25:46.260577586 +0100
@@ -11,6 +11,8 @@
 config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"))
 config:Add(OptTestCompileC("macosxppc", "int main(){return 0;}", "-arch ppc"))
 config:Add(OptLibrary("zlib", "zlib.h", false))
+config:Add(OptLibrary("wavpack", "wavpack/wavpack.h", false))
+config:Add(OptLibrary("pnglite", "sys/types.h", false))
 config:Add(SDL.OptFind("sdl", true))
 config:Add(FreeType.OptFind("freetype", true))
 config:Finalize("config.lua")
@@ -142,6 +144,12 @@
 	
 	--settings.objdir = Path("objs")
 	settings.cc.Output = Intermediate_Output
+	settings.cc.flags:Add(os.getenv ('CFLAGS'))
+	settings.cc.flags:Add(os.getenv ('CPPFLAGS'))
+	settings.cc.flags:Add(os.getenv ('LDFLAGS'))
+	settings.link.libs:Add("wavpack")
+	settings.link.libs:Add("z")
+	settings.link.libs:Add("pnglite")
 
 	if config.compiler.driver == "cl" then
 		settings.cc.flags:Add("/wd4244", "/wd4577")
@@ -186,22 +194,6 @@
 		settings.link.libs:Add("shell32")
 	end
 
-	-- compile zlib if needed
-	if config.zlib.value == 1 then
-		settings.link.libs:Add("z")
-		if config.zlib.include_path then
-			settings.cc.includes:Add(config.zlib.include_path)
-		end
-		zlib = {}
-	else
-		zlib = Compile(settings, Collect("src/engine/external/zlib/*.c"))
-		settings.cc.includes:Add("src/engine/external/zlib")
-	end
-
-	-- build the small libraries
-	wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
-	pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c"))
-
 	-- build game components
 	engine_settings = settings:Copy()
 	server_settings = engine_settings:Copy()
diff -aur teeworlds-0.6.4-src/src/engine/client/graphics.cpp teeworlds-0.6.4-src_patched/src/engine/client/graphics.cpp
--- teeworlds-0.6.4-src/src/engine/client/graphics.cpp	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/src/engine/client/graphics.cpp	2016-11-10 18:26:32.883445477 +0100
@@ -9,7 +9,7 @@
 #include "SDL_opengl.h"
 
 #include <base/system.h>
-#include <engine/external/pnglite/pnglite.h>
+#include <pnglite.h>
 
 #include <engine/shared/config.h>
 #include <engine/graphics.h>
diff -aur teeworlds-0.6.4-src/src/engine/client/graphics_threaded.cpp teeworlds-0.6.4-src_patched/src/engine/client/graphics_threaded.cpp
--- teeworlds-0.6.4-src/src/engine/client/graphics_threaded.cpp	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/src/engine/client/graphics_threaded.cpp	2016-11-10 18:26:32.880445614 +0100
@@ -6,7 +6,7 @@
 #include <base/tl/threading.h>
 
 #include <base/system.h>
-#include <engine/external/pnglite/pnglite.h>
+#include <pnglite.h>
 
 #include <engine/shared/config.h>
 #include <engine/graphics.h>
diff -aur teeworlds-0.6.4-src/src/engine/client/sound.cpp teeworlds-0.6.4-src_patched/src/engine/client/sound.cpp
--- teeworlds-0.6.4-src/src/engine/client/sound.cpp	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/src/engine/client/sound.cpp	2016-11-10 18:29:06.548420110 +0100
@@ -13,7 +13,7 @@
 #include "sound.h"
 
 extern "C" { // wavpack
-	#include <engine/external/wavpack/wavpack.h>
+	#include <wavpack/wavpack.h>
 }
 #include <math.h>
 
@@ -338,6 +338,8 @@
 	CSample *pSample;
 	int SampleID = -1;
 	char aError[100];
+	char completefilename[1024] = "/usr/share/teeworlds/";
+	const int fnlength = strlen(completefilename);
 	WavpackContext *pContext;
 
 	// don't waste memory on sound when we are stress testing
@@ -351,7 +353,9 @@
 	if(!m_pStorage)
 		return -1;
 
-	ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
+	strncpy(completefilename+fnlength, pFilename, sizeof(completefilename) - fnlength);
+	ms_File = m_pStorage->OpenFile(completefilename, IOFLAG_READ, IStorage::TYPE_ALL);
+
 	if(!ms_File)
 	{
 		dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
@@ -363,7 +367,7 @@
 		return -1;
 	pSample = &m_aSamples[SampleID];
 
-	pContext = WavpackOpenFileInput(ReadData, aError);
+	pContext = WavpackOpenFileInput(completefilename, aError, 0, 0);
 	if (pContext)
 	{
 		int m_aSamples = WavpackGetNumSamples(pContext);
diff -aur teeworlds-0.6.4-src/src/tools/dilate.cpp teeworlds-0.6.4-src_patched/src/tools/dilate.cpp
--- teeworlds-0.6.4-src/src/tools/dilate.cpp	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/src/tools/dilate.cpp	2016-11-10 18:26:32.884445431 +0100
@@ -2,7 +2,7 @@
 /* If you are missing that file, acquire a complete release at teeworlds.com.                */
 #include <base/system.h>
 #include <base/math.h>
-#include <engine/external/pnglite/pnglite.h>
+#include <pnglite.h>
 
 typedef struct
 {
diff -aur teeworlds-0.6.4-src/src/tools/tileset_borderadd.cpp teeworlds-0.6.4-src_patched/src/tools/tileset_borderadd.cpp
--- teeworlds-0.6.4-src/src/tools/tileset_borderadd.cpp	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/src/tools/tileset_borderadd.cpp	2016-11-10 18:26:32.884445431 +0100
@@ -2,7 +2,7 @@
 /* If you are missing that file, acquire a complete release at teeworlds.com.                */
 #include <base/math.h>
 #include <base/system.h>
-#include <engine/external/pnglite/pnglite.h>
+#include <pnglite.h>
 
 typedef struct
 {
diff -aur teeworlds-0.6.4-src/src/tools/tileset_borderfix.cpp teeworlds-0.6.4-src_patched/src/tools/tileset_borderfix.cpp
--- teeworlds-0.6.4-src/src/tools/tileset_borderfix.cpp	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/src/tools/tileset_borderfix.cpp	2016-11-10 18:26:32.885445385 +0100
@@ -1,7 +1,7 @@
 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
 /* If you are missing that file, acquire a complete release at teeworlds.com.                */
 #include <base/system.h>
-#include <engine/external/pnglite/pnglite.h>
+#include <pnglite.h>
 
 typedef struct
 {
diff -aur teeworlds-0.6.4-src/src/tools/tileset_borderrem.cpp teeworlds-0.6.4-src_patched/src/tools/tileset_borderrem.cpp
--- teeworlds-0.6.4-src/src/tools/tileset_borderrem.cpp	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/src/tools/tileset_borderrem.cpp	2016-11-10 18:26:32.883445477 +0100
@@ -2,7 +2,7 @@
 /* If you are missing that file, acquire a complete release at teeworlds.com.                */
 #include <base/math.h>
 #include <base/system.h>
-#include <engine/external/pnglite/pnglite.h>
+#include <pnglite.h>
 
 typedef struct
 {
diff -aur teeworlds-0.6.4-src/src/tools/tileset_borderset.cpp teeworlds-0.6.4-src_patched/src/tools/tileset_borderset.cpp
--- teeworlds-0.6.4-src/src/tools/tileset_borderset.cpp	2016-11-07 23:30:50.000000000 +0100
+++ teeworlds-0.6.4-src_patched/src/tools/tileset_borderset.cpp	2016-11-10 18:26:32.884445431 +0100
@@ -2,7 +2,7 @@
 /* If you are missing that file, acquire a complete release at teeworlds.com.                */
 #include <base/math.h>
 #include <base/system.h>
-#include <engine/external/pnglite/pnglite.h>
+#include <pnglite.h>
 
 typedef struct
 {