summaryrefslogtreecommitdiff
path: root/jam-files/boost-build/tools/zlib.jam
blob: f9138fd573a4a0a72c8fd24a91342ebf53925b4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright (c) 2010 Vladimir Prus.
#
# Use, modification and distribution is subject to the Boost Software
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)

# Supports the zlib library
#
# After 'using zlib', the following targets are available:
#
# /zlib//zlib -- The zlib library


# In addition to direct purpose of supporting zlib, this module also
# serves as canonical example of how third-party condiguration works
# in Boost.Build. The operation is as follows
#
# - For each 'using zlib : condition ... : ...' we create a target alternative
#   for zlib, with the specified condition.
# - There's one target alternative for 'zlib' with no specific condition
#   properties. 
#
# Two invocations of 'using zlib' with the same condition but different
# properties are not permitted, e.g.:
#
#   using zlib : condition <target-os>windows : include foo ;
#   using zlib : condition <target-os>windows : include bar ;
#
# is in error. One exception is for empty condition, 'using' without any
# parameters is overridable. That is:
#
#   using zlib ;
#   using zlib : include foo ;
# 
# Is OK then the first 'using' is ignored. Likewise if the order of the statements
# is reversed.
#
# When 'zlib' target is built, a target alternative is selected as usual for
# Boost.Build. The selected alternative is a custom target class, which:
#
# - calls ac.find-include-path to find header path. If explicit path is provided
#   in 'using', only that path is checked, and if no header is found there, error
#   is emitted. Otherwise, we check a directory specified using ZLIB_INCLUDE
#   environment variable, and failing that, in standard directories.
#   [TODO: document sysroot handling]
# - calls ac.find-library to find the library, in an identical fashion.
#

import project ;
import ac ;
import errors ;
import "class" : new ;
import targets ; 

project.initialize $(__name__) ;
project = [ project.current ] ;
project zlib ;

header = zlib.h ;
names = z zlib zll zdll ;

.default-alternative = [ new ac-library zlib : $(project) ] ;
$(.default-alternative).set-header $(header) ;
$(.default-alternative).set-default-names $(names) ;
targets.main-target-alternative $(.default-alternative) ;

rule init ( * : * )
{
    if ! $(condition)
    {
        # Special case the no-condition case so that 'using' without parameters
        # can mix with more specific 'using'.
        $(.default-alternative).reconfigure $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
    }
    else                    
    {
        # FIXME: consider if we should allow overriding definitions for a given
        # condition -- e.g. project-config.jam might want to override whatever is
        # in user-config.jam. 
        local mt = [ new ac-library zlib : $(project)
          : $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ] ;
        $(mt).set-header $(header) ;
        $(mt).set-default-names $(names) ;
        targets.main-target-alternative $(mt) ;
    }    
}