| 1 |
"""Support for NetBSD.""" |
| 2 |
|
| 3 |
import os |
| 4 |
|
| 5 |
from rpython.translator.platform import posix |
| 6 |
|
| 7 |
def get_env(key, default): |
| 8 |
if key in os.environ: |
| 9 |
return os.environ[key] |
| 10 |
else: |
| 11 |
return default |
| 12 |
|
| 13 |
def get_env_vector(key, default): |
| 14 |
string = get_env(key, default) |
| 15 |
|
| 16 |
return string.split() |
| 17 |
|
| 18 |
class Netbsd(posix.BasePosix): |
| 19 |
name = "netbsd" |
| 20 |
|
| 21 |
link_flags = ['-pthread', |
| 22 |
'-Wl,-R' + get_env("LOCALBASE", "/usr/pkg") + '/lib' |
| 23 |
] + get_env_vector('LDFLAGS', '') |
| 24 |
cflags = ['-O3', '-pthread', '-fomit-frame-pointer' |
| 25 |
] + get_env_vector('CFLAGS', '') |
| 26 |
standalone_only = [] |
| 27 |
shared_only = [] |
| 28 |
so_ext = 'so' |
| 29 |
make_cmd = 'gmake' |
| 30 |
extra_libs = ('-lrt',) |
| 31 |
|
| 32 |
def __init__(self, cc=None): |
| 33 |
if cc is None: |
| 34 |
cc = get_env("CC", "gcc") |
| 35 |
super(Netbsd, self).__init__(cc) |
| 36 |
|
| 37 |
def _args_for_shared(self, args, **kwds): |
| 38 |
return ['-shared'] + args |
| 39 |
|
| 40 |
def _preprocess_include_dirs(self, include_dirs): |
| 41 |
res_incl_dirs = list(include_dirs) |
| 42 |
res_incl_dirs.append(os.path.join(get_env("LOCALBASE", "/usr/pkg"), "include")) |
| 43 |
return res_incl_dirs |
| 44 |
|
| 45 |
def _preprocess_library_dirs(self, library_dirs): |
| 46 |
res_lib_dirs = list(library_dirs) |
| 47 |
res_lib_dirs.append(os.path.join(get_env("LOCALBASE", "/usr/pkg"), "lib")) |
| 48 |
return res_lib_dirs |
| 49 |
|
| 50 |
def _include_dirs_for_libffi(self): |
| 51 |
return [os.path.join(get_env("LOCALBASE", "/usr/pkg"), "include")] |
| 52 |
|
| 53 |
def _library_dirs_for_libffi(self): |
| 54 |
return [os.path.join(get_env("LOCALBASE", "/usr/pkg"), "lib")] |
| 55 |
|
| 56 |
class Netbsd_64(Netbsd): |
| 57 |
shared_only = ('-fPIC',) |