$NetBSD: patch-aa,v 1.6 2019/01/02 19:16:21 tnn Exp $

NetBSD config & path fixes
python 3.x support

--- SConstruct.orig	2010-03-18 13:34:15.000000000 +0000
+++ SConstruct
@@ -19,7 +19,7 @@
 ##  along with this program; if not, write to the Free Software
 ##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-import sys, os
+import sys, os, re
 import SCons.Util
 
 pingus_sources = [
@@ -348,7 +348,10 @@ def DefineOptions(filename, args):
 
    opts.Add(BoolVariable('with_xinput',        'Build with Xinput support', False))
    opts.Add(BoolVariable('with_linuxusbmouse', 'Build with Linux USB mouse support', True))
-   opts.Add(BoolVariable('with_linuxevdev',    'Build with Linux evdev support', True))
+   if sys.platform == 'linux':
+      opts.Add(BoolVariable('with_linuxevdev',    'Build with Linux evdev support', True))
+   else:
+      opts.Add(BoolVariable('with_linuxevdev',    'Build with Linux evdev support', False))
    opts.Add(BoolVariable('with_wiimote',       'Build with Wiimote support', False))
    opts.Add(BoolVariable('ignore_errors',      'Ignore any fatal configuration errors', False))
    opts.Add('optional_sources', 'Additional source files', [])
@@ -383,7 +386,10 @@ int main() {
    return 0;
 }
 """
-   config.CheckLibWithHeader('iconv', 'iconv.h', 'c++') # Ok to fail
+   if re.match("netbsd*", sys.platform):
+     config.CheckLibWithHeader('iconv_std', 'iconv.h', 'c++')
+   else:
+     config.CheckLibWithHeader('iconv', 'iconv.h', 'c++') # Ok to fail
    context.Message('Check how to call iconv...')
 
    for i in ['', 'const']:
@@ -408,20 +414,20 @@ if ('configure' in COMMAND_LINE_TARGETS)
    not (os.path.exists('config.py') and os.path.exists('config.h')) and \
    not GetOption('clean'):
     opts = DefineOptions(None, ARGUMENTS)
-    env = Environment(options = opts)
+    env = Environment(options = opts, ENV=os.environ)
     Help(opts.GenerateHelpText(env))
 
     opts.Update(env)
 
-    if os.environ.has_key('PATH'):
+    if 'PATH' in os.environ:
         env['ENV']['PATH'] = os.environ['PATH']
-    if os.environ.has_key('HOME'):
+    if 'HOME' in os.environ:
        env['ENV']['HOME'] = os.environ['HOME']
 
-    if os.environ.has_key('PKG_CONFIG_PATH'):
+    if 'PKG_CONFIG_PATH' in os.environ:
         env['ENV']['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
     
-    env['CPPPATH'] += ['.', 'src/']
+    env['CPPPATH'] += '.:src/'
 
     config_h_defines = []      
 
@@ -496,16 +502,16 @@ if ('configure' in COMMAND_LINE_TARGETS)
     env = config.Finish()
     opts.Save("config.py", env)
 
-    print "Reports:"
-    print reports
+    print("Reports:")
+    print(reports)
 
     if not fatal_error == "":
-        print "Fatal Errors:"
-        print fatal_error
+        print("Fatal Errors:")
+        print(fatal_error)
         if not env['ignore_errors']:
            Exit(1)
         else:
-           print "\nError are being ignored, the build continues"
+           print("\nError are being ignored, the build continues")
 
     config_h = open('config.h', 'w')
     config_h.write('#define VERSION "0.7.2"\n')
@@ -515,27 +521,27 @@ if ('configure' in COMMAND_LINE_TARGETS)
         config_h.write('#define %s %s\n' % (v, k))
     config_h.close()
     if ('configure' in COMMAND_LINE_TARGETS):
-        print "Configuration written to config.h and config.py, run:"
-        print ""
-        print "  scons"
-        print ""
-        print "To start the compile"
+        print("Configuration written to config.h and config.py, run:")
+        print("")
+        print("  scons")
+        print("")
+        print("To start the compile")
     else:
-        print "Configuration written to config.h and config.py"
+        print("Configuration written to config.h and config.py")
     ARGUMENTS = {}
 
 if not ('configure' in COMMAND_LINE_TARGETS):
     if ARGUMENTS != {}:
-        print "Error: You must not supply arguments to the compile step."
-        print "Use:"
-        print ""
-        print "  scons configure [ARGUMENTS]..."
-        print ""
-        print "If you want to change the build configuration."
+        print("Error: You must not supply arguments to the compile step.")
+        print("Use:")
+        print("")
+        print("  scons configure [ARGUMENTS]...")
+        print("")
+        print("If you want to change the build configuration.")
         os.sys.exit(1)
         
     opts = DefineOptions("config.py", {})
-    env = Environment(options = opts)
+    env = Environment(options = opts, ENV=os.environ)
     Help(opts.GenerateHelpText(env))
 
     opts.Update(env)
