Commits

Brian Kearns  committed 06373bf

apply patch for netbsd support from yamamoto@valinux.co.jp

  • Participants
  • Parent commits 4d7cd4d

Comments (0)

Files changed (5)

File rpython/rlib/rdynload.py

 _WIN32 = _MSVC or _MINGW
 _MAC_OS = platform.name == "darwin"
 _FREEBSD = sys.platform.startswith("freebsd")
+_NETBSD = sys.platform.startswith("netbsd")
 
 if _WIN32:
     from rpython.rlib import rwin32
 else: 
     pre_include_bits = []
 
-if _FREEBSD or _WIN32:
+if _FREEBSD or _NETBSD or _WIN32:
     libraries = []
 else:
     libraries = ['dl']

File rpython/rtyper/module/ll_os.py

             decls = []
             defs = []
             for name in self.w_star:
-                data = {'ret_type': 'int', 'name': name}
-                decls.append((decl_snippet % data).strip())
-                defs.append((def_snippet % data).strip())
+                if hasattr(os, name):
+                    data = {'ret_type': 'int', 'name': name}
+                    decls.append((decl_snippet % data).strip())
+                    defs.append((def_snippet % data).strip())
 
             self.compilation_info = self.compilation_info.merge(
                 ExternalCompilationInfo(

File rpython/rtyper/module/ll_time.py

         RUSAGE = platform.Struct('struct rusage', [('ru_utime', TIMEVAL),
                                                    ('ru_stime', TIMEVAL)])
 
-if sys.platform.startswith('freebsd'):
+if sys.platform.startswith('freebsd') or sys.platform.startswith('netbsd'):
     libraries = ['compat']
 else:
     libraries = []

File rpython/translator/platform/__init__.py

         host_factory = Freebsd
     else:
         host_factory = Freebsd_64
+elif sys.platform.startswith('netbsd'):
+    from rpython.translator.platform.netbsd import Netbsd, Netbsd_64
+    import platform
+    if platform.architecture()[0] == '32bit':
+        host_factory = Netbsd
+    else:
+        host_factory = Netbsd_64
 elif "openbsd" in sys.platform:
     from rpython.translator.platform.openbsd import OpenBSD, OpenBSD_64
     import platform

File rpython/translator/platform/netbsd.py

+"""Support for NetBSD."""
+
+import os
+
+from rpython.translator.platform import posix
+
+def get_env(key, default):
+    if key in os.environ:
+        return os.environ[key]
+    else:
+        return default
+
+def get_env_vector(key, default):
+    string = get_env(key, default)
+    # XXX: handle quotes
+    return string.split()
+
+class Netbsd(posix.BasePosix):
+    name = "netbsd"
+
+    link_flags = ['-pthread'] + get_env_vector('LDFLAGS', '')
+    cflags = ['-O3', '-pthread', '-fomit-frame-pointer'
+             ] + get_env_vector('CFLAGS', '')
+    standalone_only = []
+    shared_only = []
+    so_ext = 'so'
+    make_cmd = 'gmake'
+    extra_libs = ('-lrt',)
+
+    def __init__(self, cc=None):
+        if cc is None:
+            cc = get_env("CC", "gcc")
+        super(Netbsd, self).__init__(cc)
+
+    def _args_for_shared(self, args):
+        return ['-shared'] + args
+
+    def _preprocess_include_dirs(self, include_dirs):
+        res_incl_dirs = list(include_dirs)
+        res_incl_dirs.append(os.path.join(get_env("LOCALBASE", "/usr/pkg"), "include"))
+        return res_incl_dirs
+
+    def _preprocess_library_dirs(self, library_dirs):
+        res_lib_dirs = list(library_dirs)
+        res_lib_dirs.append(os.path.join(get_env("LOCALBASE", "/usr/pkg"), "lib"))
+        return res_lib_dirs
+
+    def _include_dirs_for_libffi(self):
+        return [os.path.join(get_env("LOCALBASE", "/usr/pkg"), "include")]
+
+    def _library_dirs_for_libffi(self):
+        return [os.path.join(get_env("LOCALBASE", "/usr/pkg"), "lib")]
+
+class Netbsd_64(Netbsd):
+    shared_only = ('-fPIC',)