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