$OpenBSD: patch-SConstruct,v 1.1.1.1 2007/07/14 20:33:55 ajacoutot Exp $
--- SConstruct.orig	Sun Mar  4 14:14:23 2007
+++ SConstruct	Sat Jul 14 12:50:04 2007
@@ -33,12 +33,12 @@ SConsignFile()
 
 def DefineOptions(filename, args):
    opts = Options(filename, args)
-   opts.Add('CPPPATH', 'Additional preprocessor paths')
+   opts.Add('CPPPATH', 'Additional preprocessor paths', Split(''))
    opts.Add('CPPFLAGS', 'Additional preprocessor flags')
    opts.Add('CPPDEFINES', 'defined constants', Split(''))
    opts.Add('LIBPATH', 'Additional library paths')
    opts.Add('LIBS', 'Additional libraries')
-   opts.Add('CCFLAGS', 'C Compiler flags', Split(ccflags))
+   opts.Add('CCFLAGS', 'C Compiler flags', Split(''))
    opts.Add('LINKFLAGS', 'Linker Compiler flags')
    opts.Add('CC', 'C Compiler')
    opts.Add('CXX', 'C++ Compiler')
@@ -52,6 +52,8 @@ def DefineOptions(filename, args):
 opts = DefineOptions("build_options.py", ARGUMENTS)
 env = Environment(ENV = {'PATH':os.environ['PATH']}) # for an unknown reason Environment(options=opts) doesnt work well
 opts.Update(env) # Needed as Environment(options=opts) doesnt seem to work
+env['CCFLAGS'] = Split(ccflags) + Split(env['CCFLAGS'])
+env['CPPPATH'] = Split(env['CPPPATH'])
 Help(opts.GenerateHelpText(env))
 optionsChanged = True
 if os.path.exists('build_options.py'):
@@ -101,8 +103,8 @@ def CheckOpenGL(env, conf):
   sourcesEngine.append(globSources("guichan/opengl"))
 
 def CheckLuaLib(env, conf):
-  if env.WhereIs('lua-config'):
-    env.ParseConfig('lua-config --include --libs')
+  if env.WhereIs('pkg-config'):
+    env.ParseConfig('pkg-config --cflags --libs lua')
   found = 0
   if conf.CheckLibWithHeader('lua', 'lua.h', 'c'):
     found = 1
@@ -117,7 +119,7 @@ def CheckLuaLib(env, conf):
   if not found:
     return 0
 
-  if conf.CheckLibWithHeader('lualib', 'lualib.h', 'c'):
+  if conf.CheckLibWithHeader('lua', 'lualib.h', 'c'):
      return 1
   if conf.CheckLibWithHeader('lualib50', 'lualib.h', 'c'):
      return 1
@@ -139,26 +141,23 @@ def AutoConfigure(env):
   if not conf.CheckLibWithHeader('SDL', 'SDL.h', 'c'):
      print 'Did not find SDL library or headers, exiting!'
      Exit(1)
-  if not conf.CheckLibWithHeader('png', 'png.h', 'c'):
-     print 'Did not find png library or headers, exiting!'
-     Exit(1)
   if not conf.CheckLibWithHeader('z', 'zlib.h', 'c'):
      print 'Did not find the zlib library or headers, exiting!'
      Exit(1)
-  if not conf.CheckLib('dl'):
-     print 'Did not find dl library or header which is needed on some systems for lua. Exiting!'
+  if not conf.CheckLibWithHeader('png', 'png.h', 'c'):
+     print 'Did not find png library or headers, exiting!'
      Exit(1)
   if not CheckLuaLib(env, conf):
      print 'Did not find required lua library. Exiting!'
      Exit(1)
 
   # Check for optional libraries #
+  if conf.CheckLib('ogg'):
+     env.Append(CPPDEFINES = 'USE_OGG')
   if conf.CheckLib('vorbis'):
      env.Append(CPPDEFINES = 'USE_VORBIS')
   if conf.CheckLib('theora'):
      env.Append(CPPDEFINES = 'USE_THEORA')
-  if conf.CheckLib('ogg'):
-     env.Append(CPPDEFINES = 'USE_OGG')
   if env['opengl'] == 1:
      CheckOpenGL(env, conf)
   
@@ -202,7 +201,7 @@ if env['debug'] or ARGUMENTS.has_key('DEBUG') or env['
     env.Append(CPPDEFINES = 'DEBUG')
     env.Append(CCFLAGS = Split('-g -Wsign-compare -Wall -Werror'))
 else:
-    env.Append(CCFLAGS = Split('-O2 -pipe -fomit-frame-pointer -fexpensive-optimizations -ffast-math'))
+    env.Append(CCFLAGS = Split('-fomit-frame-pointer -fexpensive-optimizations -ffast-math'))
 
 if env['profile']:
     env.Append(CCFLAGS = Split('-pg'))
