/usr/share/boost-build/src/tools
Edit: /usr/share/boost-build/src/tools/libpng.jam (7104B)
# Copyright (c) 2010 Vladimir Prus.
# Copyright (c) 2013 Steven Watanabe
#
# Use, modification and distribution is subject to the Boost Software
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
# Supports the libpng library
#
# After 'using libpng', the following targets are available:
#
# /libpng//libpng -- The libpng library
import project ;
import ac ;
import errors ;
import feature ;
import "class" : new ;
import targets ;
import path ;
import modules ;
import indirect ;
import property ;
import property-set ;
header = png.h ;
# On Windows, binary distributions of libpng and package managers
# name the library differently (e.g. vcpkg installs libpng16.lib).
# Listing popular names increases chances of successful look-up.
names = libpng libpng16 png png16 ;
sources = png.c pngerror.c pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c ;
library-id = 0 ;
if --debug-configuration in [ modules.peek : ARGV ]
{
.debug = true ;
}
# Initializes the libpng library.
#
# libpng can be configured either to use pre-existing binaries
# or to build the library from source.
#
# Options for configuring a prebuilt libpng::
#
#
# The directory containing the libpng binaries.
#
# Overrides the default library name.
#
# The directory containing the libpng headers.
#
# If none of these options is specified, then the environmental
# variables LIBPNG_LIBRARY_PATH, LIBPNG_NAME, and LIBPNG_INCLUDE will
# be used instead.
#
# Options for building libpng from source::
#
#
# The libpng source directory. Defaults to the environmental variable
# LIBPNG_SOURCE.
#
# A rule which computes the actual name of the compiled
# libraries based on the build properties. Ignored
# when using precompiled binaries.
#
# The base name to use for the compiled library. Ignored
# when using precompiled binaries.
#
# Examples::
#
# # Find libpng in the default system location
# using libpng ;
# # Build libpng from source
# using libpng : 1.5.4 : /home/steven/libpng-1.5.4 ;
# # Find libpng in /usr/local
# using libpng : 1.5.4
# : /usr/local/include /usr/local/lib ;
# # Build libpng from source for msvc and find
# # prebuilt binaries for gcc.
# using libpng : 1.5.4 : C:/Devel/src/libpng-1.5.4 : msvc ;
# using libpng : 1.5.4 : : gcc ;
#
rule init (
version ?
# The libpng version (currently ignored)
: options *
# A list of the options to use
: requirements *
# The requirements for the libpng target
: is-default ?
# Default configurations are only used when libpng
# has not yet been configured. This option is
# deprecated. A configuration will be treated
# as a default when none of , ,
# , and are present.
)
{
local caller = [ project.current ] ;
if ! $(.initialized)
{
.initialized = true ;
project.initialize $(__name__) ;
.project = [ project.current ] ;
project libpng ;
}
local library-path = [ feature.get-values : $(options) ] ;
local include-path = [ feature.get-values : $(options) ] ;
local source-path = [ feature.get-values : $(options) ] ;
local library-name = [ feature.get-values : $(options) ] ;
local tag = [ feature.get-values : $(options) ] ;
local build-name = [ feature.get-values : $(options) ] ;
if ! $(library-path) && ! $(include-path) && ! $(source-path) && ! $(library-name)
{
is-default = true ;
}
condition = [ property-set.create $(requirements) ] ;
condition = [ property-set.create [ $(condition).base ] ] ;
# Ignore environmental LIBPNG_SOURCE if this initialization
# requested to search for a specific pre-built library.
if $(library-path) || $(include-path) || $(library-name)
{
if $(source-path) || $(tag) || $(build-name)
{
errors.user-error "incompatible options for libpng:"
[ property.select : $(options) ] "and"
[ property.select : $(options) ] ;
}
}
else
{
source-path ?= [ modules.peek : LIBPNG_SOURCE ] ;
}
if $(.configured.$(condition))
{
if $(is-default)
{
if $(.debug)
{
ECHO "notice: [libpng] libpng is already configured" ;
}
}
else
{
errors.user-error "libpng is already configured" ;
}
return ;
}
else if $(source-path)
{
build-name ?= png ;
library-id = [ CALC $(library-id) + 1 ] ;
tag = [ MATCH ^@?(.*)$ : $(tag) ] ;
if $(tag)
{
tag = [ indirect.make $(tag) : [ $(caller).project-module ] ] ;
}
sources = [ path.glob $(source-path) : $(sources) ] ;
if $(.debug)
{
ECHO "notice: [libpng] Building libpng from source as $(build-name)" ;
if $(condition)
{
ECHO "notice: [libpng] Condition" [ $(condition).raw ] ;
}
if $(sources)
{
ECHO "notice: [libpng] found libpng source in $(source-path)" ;
}
else
{
ECHO "warning: [libpng] could not find libpng source in $(source-path)" ;
}
}
local target ;
if $(sources) {
target = [ targets.create-typed-target LIB : $(.project)
: $(build-name).$(library-id)
: $(sources)
: $(requirements)
@$(tag)
$(source-path)
msvc:_CRT_SECURE_NO_DEPRECATE
msvc:_SCL_SECURE_NO_DEPRECATE
shared:LIBPNG_DLL
:
: $(source-path) ] ;
}
local mt = [ new ac-library libpng : $(.project) : $(condition) ] ;
$(mt).set-header $(header) ;
$(mt).set-default-names $(names) ;
if $(target)
{
$(mt).set-target $(target) ;
}
targets.main-target-alternative $(mt) ;
} else {
if $(.debug)
{
ECHO "notice: [libpng] Using pre-installed library" ;
if $(condition)
{
ECHO "notice: [libpng] Condition" [ $(condition).raw ] ;
}
}
local mt = [ new ac-library libpng : $(.project) : $(condition) :
$(include-path) : $(library-path) : $(library-name) : $(root) ] ;
$(mt).set-header $(header) ;
$(mt).set-default-names $(names) ;
targets.main-target-alternative $(mt) ;
}
.configured.$(condition) = true ;
}