Unverified Commit 65e3c278 authored by Karl Linden's avatar Karl Linden
Browse files

Make platform detection less hardcoded. Rename --dist-target=mingw option to --platform=win32.

parent 7bdad496
......@@ -400,7 +400,7 @@ def options(opt):
opt.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
# options affecting binaries
opt.add_option('--dist-target', type='string', default='auto', help='Specify the target for cross-compiling [auto,mingw]')
opt.add_option('--platform', type='string', default=sys.platform, help='Target platform for cross-compiling, e.g. cygwin or win32')
opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
......@@ -449,31 +449,33 @@ def options(opt):
# this must be called before the configure phase
def configure(conf):
if Options.options.dist_target == 'auto':
platform = sys.platform
conf.env['IS_MACOSX'] = platform == 'darwin'
conf.env['IS_LINUX'] = platform == 'linux' or platform == 'linux2' or platform == 'linux3' or platform == 'posix'
conf.env['IS_SUN'] = platform == 'sunos'
def detect_platform(conf):
# GNU/kFreeBSD and GNU/Hurd are treated as Linux
if platform.startswith('gnu0') or platform.startswith('gnukfreebsd'):
conf.env['IS_LINUX'] = True
elif Options.options.dist_target == 'mingw':
conf.env['IS_WINDOWS'] = True
platforms = [
# ('KEY, 'Human readable name', ['strings', 'to', 'check', 'for'])
('IS_LINUX', 'Linux', ['gnu0', 'gnukfreebsd', 'linux', 'posix']),
('IS_MACOSX', 'MacOS X', ['darwin']),
('IS_SUN', 'SunOS', ['sunos']),
('IS_WINDOWS', 'Windows', ['cygwin', 'win32'])
if conf.env['IS_LINUX']:
Logs.pprint('CYAN', "Linux detected")
for key,name,strings in platforms:
conf.env[key] = False
if conf.env['IS_MACOSX']:
Logs.pprint('CYAN', "MacOS X detected")
conf.start_msg('Checking platform')
platform = Options.options.platform
for key,name,strings in platforms:
for s in strings:
if platform.startswith(s):
conf.env[key] = True
conf.end_msg(name, color='CYAN')
if conf.env['IS_SUN']:
Logs.pprint('CYAN', "SunOS detected")
def configure(conf):
if conf.env['IS_WINDOWS']:
Logs.pprint('CYAN', "Windows detected")
if conf.env['IS_WINDOWS']:
conf.env.append_unique('CCDEFINES', '_POSIX')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment