$OpenBSD: patch-bam-0_4_0_src_driver_gcc_lua,v 1.1 2015/12/27 17:56:22 jasper Exp $

Don't hardcode compiler path and flags.

--- bam-0.4.0/src/driver_gcc.lua.orig	Mon Aug  9 20:08:24 2010
+++ bam-0.4.0/src/driver_gcc.lua	Sat Mar 17 15:14:24 2012
@@ -13,7 +13,6 @@ function DriverGCC_Get(exe, cache_name, flags_name)
 			local f = cc.flags:ToString()
 			f = f .. cc[flags_name]:ToString()
 			if settings.debug > 0 then f = f .. "-g " end
-			if settings.optimize > 0 then f = f .. "-O2 " end
 			
 			cache.str = cc[exe] .. " " .. f .. "-c " .. d .. i .. " -o "
 		end
@@ -27,7 +26,7 @@ function DriverGCC_CTest(code, options)
 	f:write(code)
 	f:write("\n")
 	f:close()
-	local ret = ExecuteSilent("gcc _test.c -o _test " .. options)
+	local ret = ExecuteSilent("${CC} _test.c -o _test " .. options)
 	os.remove("_test.c")
 	os.remove("_test")
 	return ret==0
@@ -80,8 +79,8 @@ end
 function SetDriversGCC(settings)
 	if settings.cc then
 		settings.cc.extension = ".o"
-		settings.cc.exe_c = "gcc"
-		settings.cc.exe_cxx = "g++"
+		settings.cc.exe_c = "${CC} ${CFLAGS}"
+		settings.cc.exe_cxx = "${CXX} ${CXXFLAGS}"
 		settings.cc.DriverCTest = DriverGCC_CTest
 		settings.cc.DriverC = DriverGCC_Get("exe_c", "_c_cache", "flags_c")
 		settings.cc.DriverCXX = DriverGCC_Get("exe_cxx", "_cxx_cache", "flags_cxx")
@@ -89,7 +88,7 @@ function SetDriversGCC(settings)
 	
 	if settings.link then
 		settings.link.extension = ""
-		settings.link.exe = "g++"
+		settings.link.exe = "${CXX}"
 		settings.link.Driver = DriverGCC_Link
 	end
 	
@@ -108,7 +107,7 @@ function SetDriversGCC(settings)
 			settings.dll.prefix = ""
 			settings.dll.extension = ".so"
 		end
-		settings.dll.exe = "g++"
+		settings.dll.exe = "${CXX}"
 		settings.dll.Driver = DriverGCC_DLL
 	end
 end
