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
18 import "class" : new ;
28 # jpeglib.h requires stdio.h to be included first.
29 header-test = "#include <stdio.h>\n#include <jpeglib.h>\n" ;
33 sources = jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c
34 jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c
35 jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c
36 jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c
37 jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c
38 jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c
39 jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c ;
43 if --debug-configuration in [ modules.peek : ARGV ]
48 # Initializes the libjpeg library.
50 # libjpeg can be configured either to use pre-existing binaries
51 # or to build the library from source.
53 # Options for configuring a prebuilt libjpeg::
56 # The directory containing the libjpeg binaries.
58 # Overrides the default library name.
60 # The directory containing the libjpeg headers.
62 # If none of these options is specified, then the environmental
63 # variables LIBJPEG_LIBRARY_PATH, LIBJPEG_NAME, and LIBJPEG_INCLUDE will
66 # Options for building libjpeg from source::
69 # The libjpeg source directory. Defaults to the environmental variable
72 # A rule which computes the actual name of the compiled
73 # libraries based on the build properties. Ignored
74 # when using precompiled binaries.
76 # The base name to use for the compiled library. Ignored
77 # when using precompiled binaries.
81 # # Find libjpeg in the default system location
83 # # Build libjpeg from source
84 # using libjpeg : 8c : <source>/home/steven/libjpeg-8c ;
85 # # Find libjpeg in /usr/local
87 # : <include>/usr/local/include <search>/usr/local/lib ;
88 # # Build libjpeg from source for msvc and find
89 # # prebuilt binaries for gcc.
90 # using libjpeg : 8c : <source>C:/Devel/src/libjpeg-8c : <toolset>msvc ;
91 # using libjpeg : 8c : : <toolset>gcc ;
95 # The libjpeg version (currently ignored)
98 # A list of the options to use
101 # The requirements for the libjpeg target
104 # Default configurations are only used when libjpeg
105 # has not yet been configured. This option is
106 # deprecated. A configuration will be treated
107 # as a default when none of <include>, <search>,
108 # <name>, and <source> are present.
111 local caller = [ project.current ] ;
115 .initialized = true ;
117 project.initialize $(__name__) ;
118 .project = [ project.current ] ;
122 local library-path = [ feature.get-values <search> : $(options) ] ;
123 local include-path = [ feature.get-values <include> : $(options) ] ;
124 local source-path = [ feature.get-values <source> : $(options) ] ;
125 local library-name = [ feature.get-values <name> : $(options) ] ;
126 local tag = [ feature.get-values <tag> : $(options) ] ;
127 local build-name = [ feature.get-values <build-name> : $(options) ] ;
129 condition = [ property-set.create $(requirements) ] ;
130 condition = [ property-set.create [ $(condition).base ] ] ;
132 if ! $(library-path) && ! $(include-path) && ! $(source-path) && ! $(library-name)
137 # Ignore environmental LIBJPEG_SOURCE if this initialization
138 # requested to search for a specific pre-built library.
139 if $(library-path) || $(include-path) || $(library-name)
141 if $(source-path) || $(tag) || $(build-name)
143 errors.user-error "incompatible options for libjpeg:"
144 [ property.select <search> <include> <name> : $(options) ] "and"
145 [ property.select <source> <tag> <build-name> : $(options) ] ;
150 source-path ?= [ modules.peek : LIBJPEG_SOURCE ] ;
153 if $(.configured.$(condition))
159 ECHO "notice: [libjpeg] libjpeg is already configured" ;
164 errors.user-error "libjpeg is already configured" ;
168 else if $(source-path)
171 library-id = [ CALC $(library-id) + 1 ] ;
172 tag = [ MATCH ^@?(.*)$ : $(tag) ] ;
175 tag = [ indirect.make $(tag) : [ $(caller).project-module ] ] ;
177 sources = [ path.glob $(source-path) : $(sources) ] ;
180 ECHO "notice: [libjpeg] Building libjpeg from source as $(build-name)" ;
183 ECHO "notice: [libjpeg] Condition" [ $(condition).raw ] ;
187 ECHO "notice: [libjpeg] found libjpeg source in $(source-path)" ;
191 ECHO "warning: [libjpeg] could not find libjpeg source in $(source-path)" ;
196 target = [ targets.create-typed-target LIB : $(.project)
197 : $(build-name).$(library-id)
201 <include>$(source-path)
202 <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
203 <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
205 : <include>$(source-path) ] ;
208 local mt = [ new ac-library libjpeg : $(.project) : $(condition) ] ;
209 $(mt).set-header $(header) ;
210 $(mt).set-default-names $(names) ;
213 $(mt).set-target $(target) ;
215 targets.main-target-alternative $(mt) ;
219 ECHO "notice: [libjpeg] Using pre-installed library" ;
222 ECHO "notice: [libjpeg] Condition" [ $(condition).raw ] ;
226 local mt = [ new ac-library libjpeg : $(.project) : $(condition) :
227 $(include-path) : $(library-path) : $(library-name) : $(root) ] ;
228 $(mt).set-header $(header) ;
229 $(mt).set-header-test $(header-test) ;
230 $(mt).set-default-names $(names) ;
231 targets.main-target-alternative $(mt) ;
233 .configured.$(condition) = true ;