]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/libjpeg.jam
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / tools / libjpeg.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 libjpeg library
9 #
10 # After 'using libjpeg', the following targets are available:
11 #
12 # /libjpeg//libjpeg -- The libjpeg 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 = jpeglib.h ;
27
28 names = jpeg ;
29
30 sources = jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c
31 jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c
32 jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c
33 jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c
34 jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c
35 jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c
36 jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c ;
37
38 library-id = 0 ;
39
40 if --debug-configuration in [ modules.peek : ARGV ]
41 {
42 .debug = true ;
43 }
44
45 # Initializes the libjpeg library.
46 #
47 # libjpeg can be configured either to use pre-existing binaries
48 # or to build the library from source.
49 #
50 # Options for configuring a prebuilt libjpeg::
51 #
52 # <search>
53 # The directory containing the libjpeg binaries.
54 # <name>
55 # Overrides the default library name.
56 # <include>
57 # The directory containing the libjpeg headers.
58 #
59 # If none of these options is specified, then the environmental
60 # variables LIBJPEG_LIBRARY_PATH, LIBJPEG_NAME, and LIBJPEG_INCLUDE will
61 # be used instead.
62 #
63 # Options for building libjpeg from source::
64 #
65 # <source>
66 # The libjpeg source directory. Defaults to the environmental variable
67 # LIBJPEG_SOURCE.
68 # <tag>
69 # A rule which computes the actual name of the compiled
70 # libraries based on the build properties. Ignored
71 # when using precompiled binaries.
72 # <build-name>
73 # The base name to use for the compiled library. Ignored
74 # when using precompiled binaries.
75 #
76 # Examples::
77 #
78 # # Find libjpeg in the default system location
79 # using libjpeg ;
80 # # Build libjpeg from source
81 # using libjpeg : 8c : <source>/home/steven/libjpeg-8c ;
82 # # Find libjpeg in /usr/local
83 # using libjpeg : 8c
84 # : <include>/usr/local/include <search>/usr/local/lib ;
85 # # Build libjpeg from source for msvc and find
86 # # prebuilt binaries for gcc.
87 # using libjpeg : 8c : <source>C:/Devel/src/libjpeg-8c : <toolset>msvc ;
88 # using libjpeg : 8c : : <toolset>gcc ;
89 #
90 rule init (
91 version ?
92 # The libjpeg version (currently ignored)
93
94 : options *
95 # A list of the options to use
96
97 : requirements *
98 # The requirements for the libjpeg target
99
100 : is-default ?
101 # Default configurations are only used when libjpeg
102 # has not yet been configured.
103 )
104 {
105 local caller = [ project.current ] ;
106
107 if ! $(.initialized)
108 {
109 .initialized = true ;
110
111 project.initialize $(__name__) ;
112 .project = [ project.current ] ;
113 project libjpeg ;
114 }
115
116 local library-path = [ property.select <search> : $(options) ] ;
117 library-path = $(library-path:G=) ;
118 local include-path = [ property.select <include> : $(options) ] ;
119 include-path = $(include-path:G=) ;
120 local source-path = [ property.select <source> : $(options) ] ;
121 source-path = $(source-path:G=) ;
122 local library-name = [ property.select <name> : $(options) ] ;
123 library-name = $(library-name:G=) ;
124 local tag = [ property.select <tag> : $(options) ] ;
125 tag = $(tag:G=) ;
126 local build-name = [ property.select <build-name> : $(options) ] ;
127 build-name = $(build-name:G=) ;
128
129 condition = [ property-set.create $(requirements) ] ;
130 condition = [ property-set.create [ $(condition).base ] ] ;
131
132 local no-build-from-source ;
133 # Ignore environmental ZLIB_SOURCE if this initialization
134 # requested to search for a specific pre-built library.
135 if $(library-path) || $(include-path) || $(library-name)
136 {
137 if $(source-path) || $(tag) || $(build-name)
138 {
139 errors.user-error "incompatible options for libjpeg:"
140 [ property.select <search> <include> <name> : $(options) ] "and"
141 [ property.select <source> <tag> <build-name> : $(options) ] ;
142 }
143 else
144 {
145 no-build-from-source = true ;
146 }
147 }
148
149 source-path ?= [ modules.peek : ZLIB_SOURCE ] ;
150
151 if $(.configured.$(condition))
152 {
153 if $(is-default)
154 {
155 if $(.debug)
156 {
157 ECHO "notice: [libjpeg] libjpeg is already configured" ;
158 }
159 }
160 else
161 {
162 errors.user-error "libjpeg is already configured" ;
163 }
164 return ;
165 }
166 else if $(source-path) && ! $(no-build-from-source)
167 {
168 build-name ?= jpeg ;
169 library-id = [ CALC $(library-id) + 1 ] ;
170 tag = [ MATCH ^@?(.*)$ : $(tag) ] ;
171 if $(tag) && ! [ MATCH ^([^%]*)%([^%]+)$ : $(tag) ]
172 {
173 tag = [ indirect.make $(tag) : [ $(caller).project-module ] ] ;
174 }
175 sources = [ path.glob $(source-path) : $(sources) ] ;
176 if $(.debug)
177 {
178 ECHO "notice: [libjpeg] Building libjpeg from source as $(build-name)" ;
179 if $(condition)
180 {
181 ECHO "notice: [libjpeg] Condition" [ $(condition).raw ] ;
182 }
183 if $(sources)
184 {
185 ECHO "notice: [libjpeg] found libjpeg source in $(source-path)" ;
186 }
187 else
188 {
189 ECHO "warning: [libjpeg] could not find libjpeg source in $(source-path)" ;
190 }
191 }
192 local target ;
193 if $(sources) {
194 target = [ targets.create-typed-target LIB : $(.project)
195 : $(build-name).$(library-id)
196 : $(sources)
197 : $(requirements)
198 <tag>@$(tag)
199 <include>$(source-path)
200 <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
201 <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
202 <link>shared:<define>ZLIB_DLL
203 :
204 : <include>$(source-path) ] ;
205 }
206
207 local mt = [ new ac-library libjpeg : $(.project) : $(condition) ] ;
208 $(mt).set-header $(header) ;
209 $(mt).set-default-names $(names) ;
210 if $(target)
211 {
212 $(mt).set-target $(target) ;
213 }
214 targets.main-target-alternative $(mt) ;
215 } else {
216 if $(.debug)
217 {
218 ECHO "notice: [libjpeg] Using pre-installed library" ;
219 if $(condition)
220 {
221 ECHO "notice: [libjpeg] Condition" [ $(condition).raw ] ;
222 }
223 }
224
225 local mt = [ new ac-library libjpeg : $(.project) : $(condition) :
226 $(include-path) : $(library-path) : $(library-name) : $(root) ] ;
227 $(mt).set-header $(header) ;
228 $(mt).set-default-names $(names) ;
229 targets.main-target-alternative $(mt) ;
230 }
231 .configured.$(condition) = true ;
232 }