~glproxy-dev/glproxy/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import Options

out = 'build'
top = '.'

APPNAME = 'glproxy'
VERSION = '2012.03'
VERSION_NUMBER = '0.5.1'

def options(opt):
    opt.tool_options('compiler_cc')
    opt.tool_options('gnu_dirs')

    opt.add_option('--no-debug', action='store_false', dest = 'debug', default = True, help='disable compiler debug information')
    opt.add_option('--no-opt', action='store_false', dest = 'opt', default = True, help='disable compiler optimizations')
    opt.add_option('--build-tests', action='store_true', dest = 'build_tests', default = False, help='build test programs')

def configure(ctx):
    ctx.check_tool('compiler_cc')
    ctx.check_tool('gnu_dirs')

    # Check required headers
    req_headers = ['stdio.h', 'stdint.h', 'stdlib.h', 'dlfcn.h']
    for header in req_headers:
        ctx.check_cc(header_name = header, mandatory = True)

    # Check required packages
    ctx.check_cfg(package = 'x11', uselib_store = 'x11', args = '--cflags --libs', mandatory = True)

    # Check conditional packages (for tests)
    if Options.options.build_tests:
        ctx.check_cc(lib = 'm', uselib_store = 'm')

    ctx.env.append_unique('CFLAGS', '-D_GNU_SOURCE -Wall -Wextra'.split(' '))

    # Prepend -O# and -g flags so that they can be overriden by the CFLAGS environment variable
    if Options.options.opt:
        ctx.env.prepend_value('CFLAGS', '-O2')
    if Options.options.debug:
        ctx.env.prepend_value('CFLAGS', '-g')

    ctx.env.BUILD_TESTS = Options.options.build_tests
    ctx.msg("Building tests", ctx.env.BUILD_TESTS, color='PINK')
    
    ctx.env.append_unique('DEFINES', 'GLPROXY_VERSION="%s"' % VERSION)
    ctx.env.GLPROXY_VERSION = VERSION

    ctx.msg("Prefix", ctx.env.PREFIX, color='PINK')

def build(ctx):
    ctx.shlib(
            source = ctx.path.ant_glob('src/*.c'),
            target = 'glproxy',
            includes = 'include',
            export_includes = 'include',
            vnum = VERSION_NUMBER)
    ctx(
        source='glproxy.pc.in',
        VERSION_NUMBER = VERSION_NUMBER)
    
    if ctx.env.BUILD_TESTS:
        ctx.recurse('tests/tfp')
        ctx.recurse('tests/triangle')
        ctx.recurse('tests/list')
    
    ctx.install_files('${INCLUDEDIR}/GL', ctx.path.ant_glob('include/GL/*.h'))
    ctx.install_files('${INCLUDEDIR}/KHR', ctx.path.ant_glob('include/KHR/*.h'))
    ctx.install_files('${INCLUDEDIR}/EGL', ctx.path.ant_glob('include/EGL/*.h'))

def dist(ctx):
    import Node
    ctx.algo = 'tar.gz'
    ctx.base_name = APPNAME + '-' + VERSION_NUMBER + '-' + VERSION
    ctx.excl = Node.exclude_regs + ' **/*~ **/*.rej **/*.orig **/*.bak **/*.swp **/.lock-w* .waf* .gdb_history debian'