kusano 7d535a
# $Id: SConstruct,v 1.4 2007/02/24 15:03:47 dron Exp $
kusano 7d535a
kusano 7d535a
# Tag Image File Format (TIFF) Software
kusano 7d535a
#
kusano 7d535a
# Copyright (C) 2005, Andrey Kiselev <dron@ak4719.spb.edu></dron@ak4719.spb.edu>
kusano 7d535a
#
kusano 7d535a
# Permission to use, copy, modify, distribute, and sell this software and 
kusano 7d535a
# its documentation for any purpose is hereby granted without fee, provided
kusano 7d535a
# that (i) the above copyright notices and this permission notice appear in
kusano 7d535a
# all copies of the software and related documentation, and (ii) the names of
kusano 7d535a
# Sam Leffler and Silicon Graphics may not be used in any advertising or
kusano 7d535a
# publicity relating to the software without the specific, prior written
kusano 7d535a
# permission of Sam Leffler and Silicon Graphics.
kusano 7d535a
# 
kusano 7d535a
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
kusano 7d535a
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
kusano 7d535a
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
kusano 7d535a
# 
kusano 7d535a
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
kusano 7d535a
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
kusano 7d535a
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
kusano 7d535a
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
kusano 7d535a
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
kusano 7d535a
# OF THIS SOFTWARE.
kusano 7d535a
kusano 7d535a
# This file contains rules to build software with the SCons tool
kusano 7d535a
# (see the http://www.scons.org/ for details on SCons).
kusano 7d535a
kusano 7d535a
import os
kusano 7d535a
kusano 7d535a
env = Environment()
kusano 7d535a
kusano 7d535a
# Read the user supplied options
kusano 7d535a
opts = Options('libtiff.conf')
kusano 7d535a
opts.Add(PathOption('PREFIX', \
kusano 7d535a
    'install architecture-independent files in this directory', \
kusano 7d535a
    '/usr/local', PathOption.PathIsDirCreate))
kusano 7d535a
opts.Add(BoolOption('ccitt', \
kusano 7d535a
    'enable support for CCITT Group 3 & 4 algorithms', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Add(BoolOption('packbits', \
kusano 7d535a
    'enable support for Macintosh PackBits algorithm', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Add(BoolOption('lzw', \
kusano 7d535a
    'enable support for LZW algorithm', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Add(BoolOption('thunder', \
kusano 7d535a
    'enable support for ThunderScan 4-bit RLE algorithm', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Add(BoolOption('next', \
kusano 7d535a
    'enable support for NeXT 2-bit RLE algorithm', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Add(BoolOption('logluv', \
kusano 7d535a
    'enable support for LogLuv high dynamic range encoding', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Add(BoolOption('strip_chopping', \
kusano 7d535a
    'support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage)', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Add(BoolOption('extrasample_as_alpha', \
kusano 7d535a
    'the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don\'t mark the alpha properly', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Add(BoolOption('check_ycbcr_subsampling', \
kusano 7d535a
    'disable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag', \
kusano 7d535a
    'yes'))
kusano 7d535a
opts.Update(env)
kusano 7d535a
opts.Save('libtiff.conf', env)
kusano 7d535a
Help(opts.GenerateHelpText(env))
kusano 7d535a
kusano 7d535a
# Here are our installation paths:
kusano 7d535a
idir_prefix = '$PREFIX'
kusano 7d535a
idir_lib = '$PREFIX/lib'
kusano 7d535a
idir_bin = '$PREFIX/bin'
kusano 7d535a
idir_inc = '$PREFIX/include'
kusano 7d535a
idir_doc = '$PREFIX/doc'
kusano 7d535a
Export([ 'env', 'idir_prefix', 'idir_lib', 'idir_bin', 'idir_inc', 'idir_doc' ])
kusano 7d535a
kusano 7d535a
# Now proceed to system feature checks
kusano 7d535a
target_cpu, target_vendor, target_kernel, target_os = \
kusano 7d535a
    os.popen("./config/config.guess").readlines()[0].split("-")
kusano 7d535a
kusano 7d535a
def Define(context, key, have):
kusano 7d535a
    import SCons.Conftest
kusano 7d535a
    SCons.Conftest._Have(context, key, have)
kusano 7d535a
kusano 7d535a
def CheckCustomOption(context, name):
kusano 7d535a
    context.Message('Checking is the ' + name + ' option set... ')
kusano 7d535a
    ret = env[name]
kusano 7d535a
    Define(context, name + '_SUPPORT', ret)
kusano 7d535a
    context.Result(ret)
kusano 7d535a
    return ret
kusano 7d535a
kusano 7d535a
def CheckFillorderOption(context):
kusano 7d535a
    context.Message('Checking for the native cpu bit order... ')
kusano 7d535a
    if target_cpu[0] == 'i' and target_cpu[2:] == '86':
kusano 7d535a
	Define(context, 'HOST_FILLORDER', 'FILLORDER_LSB2MSB')
kusano 7d535a
	context.Result('lsb2msb')
kusano 7d535a
    else:
kusano 7d535a
	Define(context, 'HOST_FILLORDER', 'FILLORDER_MSB2LSB')
kusano 7d535a
	context.Result('msb2lsb')
kusano 7d535a
    return 1
kusano 7d535a
kusano 7d535a
def CheckIEEEFPOption(context):
kusano 7d535a
    context.Message('Checking for the IEEE floating point format... ')
kusano 7d535a
    Define(context, 'HAVE_IEEEFP', 1)
kusano 7d535a
    context.Result(1)
kusano 7d535a
    return 1
kusano 7d535a
kusano 7d535a
def CheckOtherOption(context, name):
kusano 7d535a
    context.Message('Checking is the ' + name + ' option set... ')
kusano 7d535a
    ret = env[name]
kusano 7d535a
    Define(context, 'HAVE_' + name, ret)
kusano 7d535a
    context.Result(ret)
kusano 7d535a
    return ret
kusano 7d535a
kusano 7d535a
custom_tests = { \
kusano 7d535a
    'CheckCustomOption' : CheckCustomOption, \
kusano 7d535a
    'CheckFillorderOption' : CheckFillorderOption, \
kusano 7d535a
    'CheckIEEEFPOption' : CheckIEEEFPOption, \
kusano 7d535a
    'CheckOtherOption' : CheckOtherOption \
kusano 7d535a
    }
kusano 7d535a
conf = Configure(env, custom_tests = custom_tests, \
kusano 7d535a
    config_h = 'libtiff/tif_config.h')
kusano 7d535a
kusano 7d535a
# Check for standard library
kusano 7d535a
conf.CheckLib('c')
kusano 7d535a
if target_os != 'cygwin' \
kusano 7d535a
    and target_os != 'mingw32' \
kusano 7d535a
    and target_os != 'beos' \
kusano 7d535a
    and target_os != 'darwin':
kusano 7d535a
    conf.CheckLib('m')
kusano 7d535a
kusano 7d535a
# Check for system headers
kusano 7d535a
conf.CheckCHeader('assert.h')
kusano 7d535a
conf.CheckCHeader('fcntl.h')
kusano 7d535a
conf.CheckCHeader('io.h')
kusano 7d535a
conf.CheckCHeader('limits.h')
kusano 7d535a
conf.CheckCHeader('malloc.h')
kusano 7d535a
conf.CheckCHeader('search.h')
kusano 7d535a
conf.CheckCHeader('sys/time.h')
kusano 7d535a
conf.CheckCHeader('unistd.h')
kusano 7d535a
kusano 7d535a
# Check for standard library functions
kusano 7d535a
conf.CheckFunc('floor')
kusano 7d535a
conf.CheckFunc('isascii')
kusano 7d535a
conf.CheckFunc('memmove')
kusano 7d535a
conf.CheckFunc('memset')
kusano 7d535a
conf.CheckFunc('mmap')
kusano 7d535a
conf.CheckFunc('pow')
kusano 7d535a
conf.CheckFunc('setmode')
kusano 7d535a
conf.CheckFunc('sqrt')
kusano 7d535a
conf.CheckFunc('strchr')
kusano 7d535a
conf.CheckFunc('strrchr')
kusano 7d535a
conf.CheckFunc('strstr')
kusano 7d535a
conf.CheckFunc('strtol')
kusano 7d535a
kusano 7d535a
conf.CheckFillorderOption()
kusano 7d535a
conf.CheckIEEEFPOption()
kusano 7d535a
conf.CheckCustomOption('ccitt')
kusano 7d535a
conf.CheckCustomOption('packbits')
kusano 7d535a
conf.CheckCustomOption('lzw')
kusano 7d535a
conf.CheckCustomOption('thunder')
kusano 7d535a
conf.CheckCustomOption('next')
kusano 7d535a
conf.CheckCustomOption('logluv')
kusano 7d535a
conf.CheckOtherOption('strip_chopping')
kusano 7d535a
conf.CheckOtherOption('extrasample_as_alpha')
kusano 7d535a
conf.CheckOtherOption('check_ycbcr_subsampling')
kusano 7d535a
kusano 7d535a
env = conf.Finish()
kusano 7d535a
kusano 7d535a
# Ok, now go to build files in the subdirectories
kusano 7d535a
SConscript(dirs = [ 'libtiff' ], name = 'SConstruct')