1 # Copyright (c) 2010 Vladimir Prus.
2 # Copyright (c) 2013 Steven Watanabe
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)
8 # Supports the libjpeg library
10 # After 'using libjpeg', the following targets are available:
12 # /libjpeg//libjpeg -- The libjpeg library
17 import "class" : new ;
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 ;
40 if --debug-configuration in [ modules.peek : ARGV ]
45 # Initializes the libjpeg library.
47 # libjpeg can be configured either to use pre-existing binaries
48 # or to build the library from source.
50 # Options for configuring a prebuilt libjpeg::
53 # The directory containing the libjpeg binaries.
55 # Overrides the default library name.
57 # The directory containing the libjpeg headers.
59 # If none of these options is specified, then the environmental
60 # variables LIBJPEG_LIBRARY_PATH, LIBJPEG_NAME, and LIBJPEG_INCLUDE will
63 # Options for building libjpeg from source::
66 # The libjpeg source directory. Defaults to the environmental variable
69 # A rule which computes the actual name of the compiled
70 # libraries based on the build properties. Ignored
71 # when using precompiled binaries.
73 # The base name to use for the compiled library. Ignored
74 # when using precompiled binaries.
78 # # Find libjpeg in the default system location
80 # # Build libjpeg from source
81 # using libjpeg : 8c : <source>/home/steven/libjpeg-8c ;
82 # # Find libjpeg in /usr/local
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 ;
92 # The libjpeg version (currently ignored)
95 # A list of the options to use
98 # The requirements for the libjpeg target
101 # Default configurations are only used when libjpeg
102 # has not yet been configured.
105 local caller = [ project.current ] ;
109 .initialized = true ;
111 project.initialize $(__name__) ;
112 .project = [ project.current ] ;
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) ] ;
126 local build-name = [ property.select <build-name> : $(options) ] ;
127 build-name = $(build-name:G=) ;
129 condition = [ property-set.create $(requirements) ] ;
130 condition = [ property-set.create [ $(condition).base ] ] ;
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)
137 if $(source-path) || $(tag) || $(build-name)
139 errors.user-error "incompatible options for libjpeg:"
140 [ property.select <search> <include> <name> : $(options) ] "and"
141 [ property.select <source> <tag> <build-name> : $(options) ] ;
145 no-build-from-source = true ;
149 source-path ?= [ modules.peek : ZLIB_SOURCE ] ;
151 if $(.configured.$(condition))
157 ECHO "notice: [libjpeg] libjpeg is already configured" ;
162 errors.user-error "libjpeg is already configured" ;
166 else if $(source-path) && ! $(no-build-from-source)
169 library-id = [ CALC $(library-id) + 1 ] ;
170 tag = [ MATCH ^@?(.*)$ : $(tag) ] ;
171 if $(tag) && ! [ MATCH ^([^%]*)%([^%]+)$ : $(tag) ]
173 tag = [ indirect.make $(tag) : [ $(caller).project-module ] ] ;
175 sources = [ path.glob $(source-path) : $(sources) ] ;
178 ECHO "notice: [libjpeg] Building libjpeg from source as $(build-name)" ;
181 ECHO "notice: [libjpeg] Condition" [ $(condition).raw ] ;
185 ECHO "notice: [libjpeg] found libjpeg source in $(source-path)" ;
189 ECHO "warning: [libjpeg] could not find libjpeg source in $(source-path)" ;
194 target = [ targets.create-typed-target LIB : $(.project)
195 : $(build-name).$(library-id)
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
204 : <include>$(source-path) ] ;
207 local mt = [ new ac-library libjpeg : $(.project) : $(condition) ] ;
208 $(mt).set-header $(header) ;
209 $(mt).set-default-names $(names) ;
212 $(mt).set-target $(target) ;
214 targets.main-target-alternative $(mt) ;
218 ECHO "notice: [libjpeg] Using pre-installed library" ;
221 ECHO "notice: [libjpeg] Condition" [ $(condition).raw ] ;
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) ;
231 .configured.$(condition) = true ;