]> jfr.im git - irc/znc/znc.git/blame - configure.sh
Update translations from Crowdin for de_DE es_ES pt_BR
[irc/znc/znc.git] / configure.sh
CommitLineData
e95f0ea6 1#!/bin/sh
561a1805
AS
2#
3# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
e95f0ea6
AS
18# http://stackoverflow.com/questions/18993438/shebang-env-preferred-python-version
19# http://stackoverflow.com/questions/12070516/conditional-shebang-line-for-different-versions-of-python
20""":"
21which python3 >/dev/null 2>&1 && exec python3 "$0" "$@"
22which python >/dev/null 2>&1 && exec python "$0" "$@"
23which python2 >/dev/null 2>&1 && exec python2 "$0" "$@"
24echo "Error: configure wrapper requires python"
25exec echo "Either install python, or use cmake directly"
26":"""
561a1805
AS
27
28import argparse
29import os
30import subprocess
31import sys
32import re
33
34extra_args = [os.path.dirname(sys.argv[0])]
35parser = argparse.ArgumentParser()
36
37def gnu_install_dir(name, cmake=None):
38 if cmake is None:
39 cmake = name.upper()
40 parser.add_argument('--' + name, action='append', metavar=cmake,
41 dest='cm_args',
42 type=lambda s: '-DCMAKE_INSTALL_{}={}'.format(cmake, s))
43
44gnu_install_dir('prefix')
45gnu_install_dir('bindir')
46gnu_install_dir('sbindir')
47gnu_install_dir('libexecdir')
48gnu_install_dir('sysconfdir')
49gnu_install_dir('sharedstatedir')
50gnu_install_dir('localstatedir')
51gnu_install_dir('libdir')
52gnu_install_dir('includedir')
53gnu_install_dir('oldincludedir')
54gnu_install_dir('datarootdir')
55gnu_install_dir('datadir')
56gnu_install_dir('infodir')
57gnu_install_dir('localedir')
58gnu_install_dir('mandir')
59gnu_install_dir('docdir')
60
61
62group = parser.add_mutually_exclusive_group()
63group.add_argument('--enable-debug', action='store_const', dest='build_type',
64 const='Debug', default='Release')
65group.add_argument('--disable-debug', action='store_const', dest='build_type',
66 const='Release', default='Release')
67
68def tristate(name, cmake=None):
69 if cmake is None:
70 cmake = name.upper()
71 group = parser.add_mutually_exclusive_group()
72 group.add_argument('--enable-' + name, action='append_const',
73 dest='cm_args', const='-DWANT_{}=YES'.format(cmake))
74 group.add_argument('--disable-' + name, action='append_const',
75 dest='cm_args', const='-DWANT_{}=NO'.format(cmake))
76
77tristate('ipv6')
78tristate('openssl')
79tristate('zlib')
80tristate('perl')
81tristate('swig')
82tristate('cyrus')
83tristate('charset', 'ICU')
84tristate('tcl')
8eeeaf71 85tristate('i18n')
561a1805
AS
86
87class HandlePython(argparse.Action):
88 def __call__(self, parser, namespace, values, option_string=None):
89 extra_args.append('-DWANT_PYTHON=YES')
90 if values is not None:
fa79f69b 91 extra_args.append('-DWANT_PYTHON_VERSION=' + values)
561a1805
AS
92
93group = parser.add_mutually_exclusive_group()
94group.add_argument('--enable-python', action=HandlePython, nargs='?',
95 metavar='PYTHON_VERSION')
96group.add_argument('--disable-python', action='append_const', dest='cm_args',
97 const='-DWANT_PYTHON=NO')
98
99parser.add_argument('--with-gtest', action='store', dest='gtest')
100parser.add_argument('--with-gmock', action='store', dest='gmock')
101
102class HandleSystemd(argparse.Action):
103 def __call__(self, parser, namespace, values, option_string=None):
104 extra_args.append('-DWANT_SYSTEMD=YES')
105 if values is not None:
106 extra_args.append('-DWANT_SYSTEMD_DIR=' + values)
107
108parser.add_argument('--with-systemdsystemunitdir', action=HandleSystemd,
109 nargs='?', metavar='UNITDIR')
110
111def env_type(s):
112 name, value = s.split('=', 1)
113 return (name, value)
114
115parser.add_argument('env', nargs='*', type=env_type, metavar='ENV_VAR=VALUE')
116
117args = parser.parse_args()
118
119cm_args = args.cm_args or []
120
121for env_key, env_value in args.env:
122 os.environ[env_key] = env_value
123if args.gtest:
124 os.environ['GTEST_ROOT'] = args.gtest
125if args.gmock:
126 os.environ['GMOCK_ROOT'] = args.gmock
127
128if os.environ.get('CXX') is not None:
129 extra_args.append('-DCMAKE_CXX_COMPILER=' + os.environ['CXX'])
130
131try:
132 os.remove('CMakeCache.txt')
133except OSError:
134 pass
135subprocess.check_call(['cmake', '-DCMAKE_BUILD_TYPE=' + args.build_type]
136 + cm_args + extra_args)