]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/src/tools/libpng.jam
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / boost / tools / build / src / tools / libpng.jam
CommitLineData
7c673cae
FG
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 libpng library
9#
10# After 'using libpng', the following targets are available:
11#
12# /libpng//libpng -- The libpng library
13
14import project ;
15import ac ;
16import errors ;
17import "class" : new ;
18import targets ;
19import path ;
20import modules ;
21import errors ;
22import indirect ;
23import property ;
24import property-set ;
25
26header = png.h ;
27names = png ;
28
29sources = png.c pngerror.c pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c
30 pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c ;
31
32library-id = 0 ;
33
34if --debug-configuration in [ modules.peek : ARGV ]
35{
36 .debug = true ;
37}
38
39# Initializes the libpng library.
40#
41# libpng can be configured either to use pre-existing binaries
42# or to build the library from source.
43#
44# Options for configuring a prebuilt libpng::
45#
46# <search>
47# The directory containing the libpng binaries.
48# <name>
49# Overrides the default library name.
50# <include>
51# The directory containing the libpng headers.
52#
53# If none of these options is specified, then the environmental
54# variables LIBPNG_LIBRARY_PATH, LIBPNG_NAME, and LIBPNG_INCLUDE will
55# be used instead.
56#
57# Options for building libpng from source::
58#
59# <source>
60# The libpng source directory. Defaults to the environmental variable
61# LIBPNG_SOURCE.
62# <tag>
63# A rule which computes the actual name of the compiled
64# libraries based on the build properties. Ignored
65# when using precompiled binaries.
66# <build-name>
67# The base name to use for the compiled library. Ignored
68# when using precompiled binaries.
69#
70# Examples::
71#
72# # Find libpng in the default system location
73# using libpng ;
74# # Build libpng from source
75# using libpng : 1.5.4 : <source>/home/steven/libpng-1.5.4 ;
76# # Find libpng in /usr/local
77# using libpng : 1.5.4
78# : <include>/usr/local/include <search>/usr/local/lib ;
79# # Build libpng from source for msvc and find
80# # prebuilt binaries for gcc.
81# using libpng : 1.5.4 : <source>C:/Devel/src/libpng-1.5.4 : <toolset>msvc ;
82# using libpng : 1.5.4 : : <toolset>gcc ;
83#
84rule init (
85 version ?
86 # The libpng version (currently ignored)
87
88 : options *
89 # A list of the options to use
90
91 : requirements *
92 # The requirements for the libpng target
93
94 : is-default ?
95 # Default configurations are only used when libpng
96 # has not yet been configured.
97 )
98{
99 local caller = [ project.current ] ;
100
101 if ! $(.initialized)
102 {
103 .initialized = true ;
104
105 project.initialize $(__name__) ;
106 .project = [ project.current ] ;
107 project libpng ;
108 }
109
110 local library-path = [ property.select <search> : $(options) ] ;
111 library-path = $(library-path:G=) ;
112 local include-path = [ property.select <include> : $(options) ] ;
113 include-path = $(include-path:G=) ;
114 local source-path = [ property.select <source> : $(options) ] ;
115 source-path = $(source-path:G=) ;
116 local library-name = [ property.select <name> : $(options) ] ;
117 library-name = $(library-name:G=) ;
118 local tag = [ property.select <tag> : $(options) ] ;
119 tag = $(tag:G=) ;
120 local build-name = [ property.select <build-name> : $(options) ] ;
121 build-name = $(build-name:G=) ;
122
123 condition = [ property-set.create $(requirements) ] ;
124 condition = [ property-set.create [ $(condition).base ] ] ;
125
126 local no-build-from-source ;
127 # Ignore environmental LIBPNG_SOURCE if this initialization
128 # requested to search for a specific pre-built library.
129 if $(library-path) || $(include-path) || $(library-name)
130 {
131 if $(source-path) || $(tag) || $(build-name)
132 {
133 errors.user-error "incompatible options for libpng:"
134 [ property.select <search> <include> <name> : $(options) ] "and"
135 [ property.select <source> <tag> <build-name> : $(options) ] ;
136 }
137 else
138 {
139 no-build-from-source = true ;
140 }
141 }
142
143 source-path ?= [ modules.peek : LIBPNG_SOURCE ] ;
144
145 if $(.configured.$(condition))
146 {
147 if $(is-default)
148 {
149 if $(.debug)
150 {
151 ECHO "notice: [libpng] libpng is already configured" ;
152 }
153 }
154 else
155 {
156 errors.user-error "libpng is already configured" ;
157 }
158 return ;
159 }
160 else if $(source-path) && ! $(no-build-from-source)
161 {
162 build-name ?= png ;
163 library-id = [ CALC $(library-id) + 1 ] ;
164 tag = [ MATCH ^@?(.*)$ : $(tag) ] ;
165 if $(tag) && ! [ MATCH ^([^%]*)%([^%]+)$ : $(tag) ]
166 {
167 tag = [ indirect.make $(tag) : [ $(caller).project-module ] ] ;
168 }
169 sources = [ path.glob $(source-path) : $(sources) ] ;
170 if $(.debug)
171 {
172 ECHO "notice: [libpng] Building libpng from source as $(build-name)" ;
173 if $(condition)
174 {
175 ECHO "notice: [libpng] Condition" [ $(condition).raw ] ;
176 }
177 if $(sources)
178 {
179 ECHO "notice: [libpng] found libpng source in $(source-path)" ;
180 }
181 else
182 {
183 ECHO "warning: [libpng] could not find libpng source in $(source-path)" ;
184 }
185 }
186 local target ;
187 if $(sources) {
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>LIBPNG_DLL
197 :
198 : <include>$(source-path) ] ;
199 }
200
201 local mt = [ new ac-library libpng : $(.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 } else {
210 if $(.debug)
211 {
212 ECHO "notice: [libpng] Using pre-installed library" ;
213 if $(condition)
214 {
215 ECHO "notice: [libpng] Condition" [ $(condition).raw ] ;
216 }
217 }
218
219 local mt = [ new ac-library libpng : $(.project) : $(condition) :
220 $(include-path) : $(library-path) : $(library-name) : $(root) ] ;
221 $(mt).set-header $(header) ;
222 $(mt).set-default-names $(names) ;
223 targets.main-target-alternative $(mt) ;
224 }
225 .configured.$(condition) = true ;
226}