OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.swp.api/] [openmcapi/] [1.0/] [libmcapi/] [shm/] [wscript] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
#!/usr/bin/env python
2
 
3
import os.path
4
 
5
from waflib.Build import BuildContext, InstallContext, UninstallContext, CleanContext
6
 
7
def makeopts(ctx, path):
8
        '''Assemble the options to pass to Kbuild.'''
9
 
10
        makeopts = [
11
                '-C %s/linux/kmod' % path,
12
                'ARCH=%s' % ctx.env.ARCH,
13
                'INSTALL_MOD_PATH=%s/linux/kmod/deploy' %
14
                        os.path.join(ctx.out_dir, path),
15
        ]
16
        if ctx.env.LINUXDIR:
17
                makeopts.append('KERNELDIR=%s' % ctx.env.LINUXDIR)
18
        if ctx.env.CROSS:
19
                makeopts.append('CROSS_COMPILE=%s' % ctx.env.CROSS)
20
        if ctx.env.LINUXARGS:
21
                makeopts.append(ctx.env.LINUXARGS)
22
 
23
        return ' '.join(makeopts)
24
 
25
def options(opt):
26
        opt.add_option('--linuxdir', help='Directory to Linux kernel which has had \'make modules_prepare\' run.')
27
        opt.add_option('--linuxargs', help='Extra options to pass to the Linux kernel module build system.')
28
        opt.add_option('--shm-sysv', action='store_true', help='For debugging purposes: use SysV shared memory instead of physical RAM. Implies --no-kmods.')
29
        opt.add_option('--shm-nodes', default='2', type='int', help='Number of nodes communicating via shared memory segment.')
30
 
31
        # These classes are magic to make the Linux kmod build automatically:
32
        path = opt.path.abspath()
33
        class _build(BuildContext):
34
                def compile(self):
35
                        if not self.env.NO_KMODS:
36
                                ret = self.exec_command(
37
                                        'make %s modules modules_install' % makeopts(self, path),
38
                                        cwd=path)
39
                                if ret:
40
                                        self.fatal('make returned %r' % ret)
41
                        super(_build, self).compile()
42
 
43
        class _clean(CleanContext):
44
                def clean(self):
45
                        if not self.env.NO_KMODS:
46
                                self.exec_command('make %s clean' % makeopts(self, path),
47
                                                  cwd=path)
48
                        super(_clean, self).clean()
49
 
50
def configure(conf):
51
        conf.env.LINUXDIR = conf.options.linuxdir
52
        conf.env.LINUXARGS = conf.options.linuxargs
53
        conf.env.SHM_SYSV = conf.options.shm_sysv
54
        if conf.env.SHM_SYSV:
55
                conf.env.NO_KMODS = True
56
 
57
        conf.define('CONFIG_SHM_NR_NODES', conf.options.shm_nodes)
58
 
59
def build(bld):
60
        includes = [
61
                '.',
62
                '../include',
63
                '../../include',
64
                '../../include/%s' % bld.env.OS,
65
                '../include/arch/%s' % bld.env.ARCH,
66
        ]
67
 
68
        sources = [
69
                'shm.c'
70
        ]
71
 
72
        shm_sources = [
73
                'sysv.c'
74
        ]
75
 
76
        extra_sources = {
77
                'linux': ['linux/shm_os.c'],
78
        }
79
 
80
        if bld.env.SHM_SYSV:
81
                # sysv is OS-agnostic and trumps OS drivers
82
                sources += shm_sources
83
        else:
84
                sources += extra_sources.get(bld.env.OS, [])
85
 
86
        bld.objects(
87
                target='shm_objs',
88
                source=' '.join(sources),
89
                includes=' '.join(includes),
90
        )
91
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.