• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 Rene Rivera
2# Distributed under the Boost Software License, Version 1.0.
3# (See accompanying file LICENSE_1_0.txt or copy at
4# http://www.boost.org/LICENSE_1_0.txt)
5
6import feature ;
7import modules ;
8import os ;
9
10.os-names =
11    aix android appletv bsd cygwin darwin freebsd haiku hpux iphone linux
12    netbsd openbsd osf qnx qnxnto sgi solaris unix unixware windows vms vxworks
13    freertos
14
15    # Not actually an OS -- used for targeting bare metal where object
16    # format is ELF.  This catches both -elf and -eabi gcc targets as well
17    # as other compilers targeting ELF. It is not clear how often we need
18    # the 'elf' key as opposed to other bare metal targets, but let us
19    # stick with gcc naming.
20    elf
21    ;
22
23# Feature used to determine which OS we're on. New <target-os> and <host-os>
24# features should be used instead.
25local os = [ modules.peek : OS ] ;
26feature.feature os : $(os) : propagated link-incompatible ;
27
28# Translates from bjam current OS to the os tags used in host-os and
29# target-os, i.e. returns the running host-os.
30#
31local rule default-host-os ( )
32{
33    local host-os ;
34    if [ os.name ] in $(.os-names:U)
35    {
36        host-os = [ os.name ] ;
37    }
38    else
39    {
40        switch [ os.name ]
41        {
42            case NT           : host-os = windows ;
43            case AS400        : host-os = unix    ;
44            case MINGW        : host-os = windows ;
45            case BSDI         : host-os = bsd     ;
46            case COHERENT     : host-os = unix    ;
47            case DRAGONFLYBSD : host-os = bsd     ;
48            case IRIX         : host-os = sgi     ;
49            case HAIKU        : host-os = haiku   ;
50            case MACOSX       : host-os = darwin  ;
51            case KFREEBSD     : host-os = freebsd ;
52            case LINUX        : host-os = linux   ;
53            case VMS          : host-os = vms     ;
54            case SUNOS        :
55                ECHO
56                    "SunOS is not a supported operating system."
57                    "We believe last version of SunOS was released in 1992, "
58                    "so if you get this message, something is very wrong with "
59                    "configuration logic. Please report this as a bug. " ;
60                EXIT ;
61            case *            : host-os = unix    ;
62        }
63    }
64    return $(host-os:L) ;
65}
66
67
68# The two OS features define a known set of abstract OS names. The host-os is
69# the OS under which bjam is running. Even though this should really be a fixed
70# property we need to list all the values to prevent unknown value errors. Both
71# set the default value to the current OS to account for the default use case of
72# building on the target OS.
73feature.feature host-os : $(.os-names) ;
74feature.set-default host-os : [ default-host-os ] ;
75
76#| tag::doc[]
77
78[[bbv2.builtin.features.target-os]]`target-os`::
79*Allowed values:* `aix`, `android`, `appletv`, `bsd`, `cygwin`, `darwin`,
80`freebsd`, `haiku`, `hpux`, `iphone`, `linux`, `netbsd`, `openbsd`, `osf`,
81`qnx`, `qnxnto`, `sgi`, `solaris`, `unix`, `unixware`, `windows`, `vms`,
82`vxworks`, `freertos`.
83+
84Specifies the operating system for which the code is to be generated. The
85compiler you used should be the compiler for that operating system. This option
86causes B2 to use naming conventions suitable for that operating
87system, and adjust build process accordingly. For example, with gcc, it
88controls if import libraries are produced for shared libraries or not.
89+
90See the section <<Cross-compilation>> for details of cross-compilation.
91
92|# # end::doc[]
93
94feature.feature target-os : $(.os-names) : propagated link-incompatible ;
95feature.set-default target-os : [ default-host-os ] ;
96