~ubuntu-branches/ubuntu/trusty/ldb/trusty-proposed

« back to all changes in this revision

Viewing changes to buildtools/wafadmin/Tools/gnu_dirs.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-02-07 16:04:26 UTC
  • mfrom: (1.3.11)
  • Revision ID: package-import@ubuntu.com-20120207160426-hz17vq8gs1epwkf2
Tags: 1:1.1.4+git20120206-1
* New upstream snapshot.
 + Extracts waf source code. Closes: #654482
 + Disable tdb2 support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# encoding: utf-8
 
3
# Ali Sabil, 2007
 
4
 
 
5
"""
 
6
To use this module do not forget to call
 
7
opt.tool_options('gnu_dirs')
 
8
AND
 
9
conf.check_tool('gnu_dirs')
 
10
 
 
11
Add options for the standard GNU directories, this tool will add the options
 
12
found in autotools, and will update the environment with the following
 
13
installation variables:
 
14
 
 
15
 * PREFIX : architecture-independent files [/usr/local]
 
16
 * EXEC_PREFIX : architecture-dependent files [PREFIX]
 
17
 * BINDIR : user executables [EXEC_PREFIX/bin]
 
18
 * SBINDIR : user executables [EXEC_PREFIX/sbin]
 
19
 * LIBEXECDIR : program executables [EXEC_PREFIX/libexec]
 
20
 * SYSCONFDIR : read-only single-machine data [PREFIX/etc]
 
21
 * SHAREDSTATEDIR : modifiable architecture-independent data [PREFIX/com]
 
22
 * LOCALSTATEDIR : modifiable single-machine data [PREFIX/var]
 
23
 * LIBDIR : object code libraries [EXEC_PREFIX/lib]
 
24
 * INCLUDEDIR : C header files [PREFIX/include]
 
25
 * OLDINCLUDEDIR : C header files for non-gcc [/usr/include]
 
26
 * DATAROOTDIR : read-only arch.-independent data root [PREFIX/share]
 
27
 * DATADIR : read-only architecture-independent data [DATAROOTDIR]
 
28
 * INFODIR : info documentation [DATAROOTDIR/info]
 
29
 * LOCALEDIR : locale-dependent data [DATAROOTDIR/locale]
 
30
 * MANDIR : man documentation [DATAROOTDIR/man]
 
31
 * DOCDIR : documentation root [DATAROOTDIR/doc/telepathy-glib]
 
32
 * HTMLDIR : html documentation [DOCDIR]
 
33
 * DVIDIR : dvi documentation [DOCDIR]
 
34
 * PDFDIR : pdf documentation [DOCDIR]
 
35
 * PSDIR : ps documentation [DOCDIR]
 
36
"""
 
37
 
 
38
import Utils, Options
 
39
 
 
40
_options = [x.split(', ') for x in '''
 
41
bindir, user executables, ${EXEC_PREFIX}/bin
 
42
sbindir, system admin executables, ${EXEC_PREFIX}/sbin
 
43
libexecdir, program executables, ${EXEC_PREFIX}/libexec
 
44
sysconfdir, read-only single-machine data, ${PREFIX}/etc
 
45
sharedstatedir, modifiable architecture-independent data, ${PREFIX}/com
 
46
localstatedir, modifiable single-machine data, ${PREFIX}/var
 
47
libdir, object code libraries, ${EXEC_PREFIX}/lib
 
48
includedir, C header files, ${PREFIX}/include
 
49
oldincludedir, C header files for non-gcc, /usr/include
 
50
datarootdir, read-only arch.-independent data root, ${PREFIX}/share
 
51
datadir, read-only architecture-independent data, ${DATAROOTDIR}
 
52
infodir, info documentation, ${DATAROOTDIR}/info
 
53
localedir, locale-dependent data, ${DATAROOTDIR}/locale
 
54
mandir, man documentation, ${DATAROOTDIR}/man
 
55
docdir, documentation root, ${DATAROOTDIR}/doc/${PACKAGE}
 
56
htmldir, html documentation, ${DOCDIR}
 
57
dvidir, dvi documentation, ${DOCDIR}
 
58
pdfdir, pdf documentation, ${DOCDIR}
 
59
psdir, ps documentation, ${DOCDIR}
 
60
'''.split('\n') if x]
 
61
 
 
62
def detect(conf):
 
63
        def get_param(varname, default):
 
64
                return getattr(Options.options, varname, '') or default
 
65
 
 
66
        env = conf.env
 
67
        env['EXEC_PREFIX'] = get_param('EXEC_PREFIX', env['PREFIX'])
 
68
        env['PACKAGE'] = Utils.g_module.APPNAME
 
69
 
 
70
        complete = False
 
71
        iter = 0
 
72
        while not complete and iter < len(_options) + 1:
 
73
                iter += 1
 
74
                complete = True
 
75
                for name, help, default in _options:
 
76
                        name = name.upper()
 
77
                        if not env[name]:
 
78
                                try:
 
79
                                        env[name] = Utils.subst_vars(get_param(name, default), env)
 
80
                                except TypeError:
 
81
                                        complete = False
 
82
        if not complete:
 
83
                lst = [name for name, _, _ in _options if not env[name.upper()]]
 
84
                raise Utils.WafError('Variable substitution failure %r' % lst)
 
85
 
 
86
def set_options(opt):
 
87
 
 
88
        inst_dir = opt.add_option_group('Installation directories',
 
89
'By default, "waf install" will put the files in\
 
90
 "/usr/local/bin", "/usr/local/lib" etc. An installation prefix other\
 
91
 than "/usr/local" can be given using "--prefix", for example "--prefix=$HOME"')
 
92
 
 
93
        for k in ('--prefix', '--destdir'):
 
94
                option = opt.parser.get_option(k)
 
95
                if option:
 
96
                        opt.parser.remove_option(k)
 
97
                        inst_dir.add_option(option)
 
98
 
 
99
        inst_dir.add_option('--exec-prefix',
 
100
                help = 'installation prefix [Default: ${PREFIX}]',
 
101
                default = '',
 
102
                dest = 'EXEC_PREFIX')
 
103
 
 
104
        dirs_options = opt.add_option_group('Pre-defined installation directories', '')
 
105
 
 
106
        for name, help, default in _options:
 
107
                option_name = '--' + name
 
108
                str_default = default
 
109
                str_help = '%s [Default: %s]' % (help, str_default)
 
110
                dirs_options.add_option(option_name, help=str_help, default='', dest=name.upper())
 
111