]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/zlib.jam
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / tools / zlib.jam
1 # Copyright (c) 2010 Vladimir Prus.
2 # Copyright (c) 2013 Steven Watanabe
3 #
4 # Use, modification and distribution is subject to the Boost Software
5 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
6 # http://www.boost.org/LICENSE_1_0.txt)
7
8 # Supports the zlib library
9 #
10 # After 'using zlib', the following targets are available:
11 #
12 # /zlib//zlib -- The zlib library
13
14 import project ;
15 import ac ;
16 import errors ;
17 import "class" : new ;
18 import targets ;
19 import path ;
20 import modules ;
21 import errors ;
22 import indirect ;
23 import property ;
24 import property-set ;
25
26 header = zlib.h ;
27 names = z zlib zll zdll ;
28
29 sources = adler32.c compress.c
30 crc32.c deflate.c gzclose.c gzio.c gzlib.c gzread.c gzwrite.c
31 infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c ;
32
33 library-id = 0 ;
34
35 if --debug-configuration in [ modules.peek : ARGV ]
36 {
37 .debug = true ;
38 }
39
40 # Initializes the zlib library.
41 #
42 # zlib can be configured either to use pre-existing binaries
43 # or to build the library from source.
44 #
45 # Options for configuring a prebuilt zlib::
46 #
47 # <search>
48 # The directory containing the zlib binaries.
49 # <name>
50 # Overrides the default library name.
51 # <include>
52 # The directory containing the zlib headers.
53 #
54 # If none of these options is specified, then the environmental
55 # variables ZLIB_LIBRARY_PATH, ZLIB_NAME, and ZLIB_INCLUDE will
56 # be used instead.
57 #
58 # Options for building zlib from source::
59 #
60 # <source>
61 # The zlib source directory. Defaults to the environmental variable
62 # ZLIB_SOURCE.
63 # <tag>
64 # A rule which computes the actual name of the compiled
65 # libraries based on the build properties. Ignored
66 # when using precompiled binaries.
67 # <build-name>
68 # The base name to use for the compiled library. Ignored
69 # when using precompiled binaries.
70 #
71 # Examples::
72 #
73 # # Find zlib in the default system location
74 # using zlib ;
75 # # Build zlib from source
76 # using zlib : 1.2.7 : <source>/home/steven/zlib-1.2.7 ;
77 # # Find zlib in /usr/local
78 # using zlib : 1.2.7
79 # : <include>/usr/local/include <search>/usr/local/lib ;
80 # # Build zlib from source for msvc and find
81 # # prebuilt binaries for gcc.
82 # using zlib : 1.2.7 : <source>C:/Devel/src/zlib-1.2.7 : <toolset>msvc ;
83 # using zlib : 1.2.7 : : <toolset>gcc ;
84 #
85 rule init (
86 version ?
87 # The zlib version (currently ignored)
88
89 : options *
90 # A list of the options to use
91
92 : requirements *
93 # The requirements for the zlib target
94
95 : is-default ?
96 # Default configurations are only used when zlib
97 # has not yet been configured.
98 )
99 {
100 local caller = [ project.current ] ;
101
102 if ! $(.initialized)
103 {
104 .initialized = true ;
105
106 project.initialize $(__name__) ;
107 .project = [ project.current ] ;
108 project zlib ;
109 }
110
111 local library-path = [ property.select <search> : $(options) ] ;
112 library-path = $(library-path:G=) ;
113 local include-path = [ property.select <include> : $(options) ] ;
114 include-path = $(include-path:G=) ;
115 local source-path = [ property.select <source> : $(options) ] ;
116 source-path = $(source-path:G=) ;
117 local library-name = [ property.select <name> : $(options) ] ;
118 library-name = $(library-name:G=) ;
119 local tag = [ property.select <tag> : $(options) ] ;
120 tag = $(tag:G=) ;
121 local build-name = [ property.select <build-name> : $(options) ] ;
122 build-name = $(build-name:G=) ;
123
124 condition = [ property-set.create $(requirements) ] ;
125 condition = [ property-set.create [ $(condition).base ] ] ;
126
127 local no-build-from-source ;
128 # Ignore environmental ZLIB_SOURCE if this initialization
129 # requested to search for a specific pre-built library.
130 if $(library-path) || $(include-path) || $(library-name)
131 {
132 if $(source-path) || $(tag) || $(build-name)
133 {
134 errors.user-error "incompatible options for zlib:"
135 [ property.select <search> <include> <name> : $(options) ] "and"
136 [ property.select <source> <tag> <build-name> : $(options) ] ;
137 }
138 }
139 else
140 {
141 source-path ?= [ modules.peek : ZLIB_SOURCE ] ;
142 }
143
144 if $(.configured.$(condition))
145 {
146 if $(is-default)
147 {
148 if $(.debug)
149 {
150 ECHO "notice: [zlib] zlib is already configured" ;
151 }
152 }
153 else
154 {
155 errors.user-error "zlib is already configured" ;
156 }
157 return ;
158 }
159 else if $(source-path)
160 {
161 build-name ?= z ;
162 library-id = [ CALC $(library-id) + 1 ] ;
163 tag = [ MATCH ^@?(.*)$ : $(tag) ] ;
164 if $(tag) && ! [ MATCH ^([^%]*)%([^%]+)$ : $(tag) ]
165 {
166 tag = [ indirect.make $(tag) : [ $(caller).project-module ] ] ;
167 }
168 sources = [ path.glob $(source-path) : $(sources) ] ;
169 if $(.debug)
170 {
171 ECHO "notice: [zlib] Building zlib from source as $(build-name)" ;
172 if $(condition)
173 {
174 ECHO "notice: [zlib] Condition" [ $(condition).raw ] ;
175 }
176 if $(sources)
177 {
178 ECHO "notice: [zlib] found zlib source in $(source-path)" ;
179 }
180 else
181 {
182 ECHO "warning: [zlib] could not find zlib source in $(source-path)" ;
183 }
184 }
185 local target ;
186 if $(sources)
187 {
188 target = [ targets.create-typed-target LIB : $(.project)
189 : $(build-name).$(library-id)
190 : $(sources)
191 : $(requirements)
192 <tag>@$(tag)
193 <include>$(source-path)
194 <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
195 <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
196 <link>shared:<define>ZLIB_DLL
197 :
198 : <include>$(source-path) ] ;
199 }
200
201 local mt = [ new ac-library zlib : $(.project) : $(condition) ] ;
202 $(mt).set-header $(header) ;
203 $(mt).set-default-names $(names) ;
204 if $(target)
205 {
206 $(mt).set-target $(target) ;
207 }
208 targets.main-target-alternative $(mt) ;
209 }
210 else
211 {
212 if $(.debug)
213 {
214 ECHO "notice: [zlib] Using pre-installed library" ;
215 if $(condition)
216 {
217 ECHO "notice: [zlib] Condition" [ $(condition).raw ] ;
218 }
219 }
220
221 local mt = [ new ac-library zlib : $(.project) : $(condition) :
222 $(include-path) : $(library-path) : $(library-name) ] ;
223 $(mt).set-header $(header) ;
224 $(mt).set-default-names $(names) ;
225 targets.main-target-alternative $(mt) ;
226 }
227 .configured.$(condition) = true ;
228 }