Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From 2f49a3a4f4792db1 To d5cddb67f4e39e6b
2013-08-24
| ||
08:10 | upgrading to automake 1.13.4 Leaf check-in: 2f49a3a4f4 user: sandro tags: trunk | |
2013-02-18
| ||
09:37 | supporting SVG dasharray check-in: eeac5b1cd9 user: sandro tags: trunk | |
2011-11-12
| ||
09:48 | initial repository setp up check-in: e7d0f5bcc0 user: sandro tags: trunk | |
09:44 | initial empty check-in check-in: d5cddb67f4 user: sandro tags: trunk | |
Deleted AUTHORS.
1 -Original Author: 2 -Alessandro Furieri <a.furieri@lqt.it>
Deleted COPYING.
1 - GNU LESSER GENERAL PUBLIC LICENSE 2 - Version 3, 29 June 2007 3 - 4 - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> 5 - Everyone is permitted to copy and distribute verbatim copies 6 - of this license document, but changing it is not allowed. 7 - 8 - 9 - This version of the GNU Lesser General Public License incorporates 10 -the terms and conditions of version 3 of the GNU General Public 11 -License, supplemented by the additional permissions listed below. 12 - 13 - 0. Additional Definitions. 14 - 15 - As used herein, "this License" refers to version 3 of the GNU Lesser 16 -General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 -General Public License. 18 - 19 - "The Library" refers to a covered work governed by this License, 20 -other than an Application or a Combined Work as defined below. 21 - 22 - An "Application" is any work that makes use of an interface provided 23 -by the Library, but which is not otherwise based on the Library. 24 -Defining a subclass of a class defined by the Library is deemed a mode 25 -of using an interface provided by the Library. 26 - 27 - A "Combined Work" is a work produced by combining or linking an 28 -Application with the Library. The particular version of the Library 29 -with which the Combined Work was made is also called the "Linked 30 -Version". 31 - 32 - The "Minimal Corresponding Source" for a Combined Work means the 33 -Corresponding Source for the Combined Work, excluding any source code 34 -for portions of the Combined Work that, considered in isolation, are 35 -based on the Application, and not on the Linked Version. 36 - 37 - The "Corresponding Application Code" for a Combined Work means the 38 -object code and/or source code for the Application, including any data 39 -and utility programs needed for reproducing the Combined Work from the 40 -Application, but excluding the System Libraries of the Combined Work. 41 - 42 - 1. Exception to Section 3 of the GNU GPL. 43 - 44 - You may convey a covered work under sections 3 and 4 of this License 45 -without being bound by section 3 of the GNU GPL. 46 - 47 - 2. Conveying Modified Versions. 48 - 49 - If you modify a copy of the Library, and, in your modifications, a 50 -facility refers to a function or data to be supplied by an Application 51 -that uses the facility (other than as an argument passed when the 52 -facility is invoked), then you may convey a copy of the modified 53 -version: 54 - 55 - a) under this License, provided that you make a good faith effort to 56 - ensure that, in the event an Application does not supply the 57 - function or data, the facility still operates, and performs 58 - whatever part of its purpose remains meaningful, or 59 - 60 - b) under the GNU GPL, with none of the additional permissions of 61 - this License applicable to that copy. 62 - 63 - 3. Object Code Incorporating Material from Library Header Files. 64 - 65 - The object code form of an Application may incorporate material from 66 -a header file that is part of the Library. You may convey such object 67 -code under terms of your choice, provided that, if the incorporated 68 -material is not limited to numerical parameters, data structure 69 -layouts and accessors, or small macros, inline functions and templates 70 -(ten or fewer lines in length), you do both of the following: 71 - 72 - a) Give prominent notice with each copy of the object code that the 73 - Library is used in it and that the Library and its use are 74 - covered by this License. 75 - 76 - b) Accompany the object code with a copy of the GNU GPL and this license 77 - document. 78 - 79 - 4. Combined Works. 80 - 81 - You may convey a Combined Work under terms of your choice that, 82 -taken together, effectively do not restrict modification of the 83 -portions of the Library contained in the Combined Work and reverse 84 -engineering for debugging such modifications, if you also do each of 85 -the following: 86 - 87 - a) Give prominent notice with each copy of the Combined Work that 88 - the Library is used in it and that the Library and its use are 89 - covered by this License. 90 - 91 - b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 - document. 93 - 94 - c) For a Combined Work that displays copyright notices during 95 - execution, include the copyright notice for the Library among 96 - these notices, as well as a reference directing the user to the 97 - copies of the GNU GPL and this license document. 98 - 99 - d) Do one of the following: 100 - 101 - 0) Convey the Minimal Corresponding Source under the terms of this 102 - License, and the Corresponding Application Code in a form 103 - suitable for, and under terms that permit, the user to 104 - recombine or relink the Application with a modified version of 105 - the Linked Version to produce a modified Combined Work, in the 106 - manner specified by section 6 of the GNU GPL for conveying 107 - Corresponding Source. 108 - 109 - 1) Use a suitable shared library mechanism for linking with the 110 - Library. A suitable mechanism is one that (a) uses at run time 111 - a copy of the Library already present on the user's computer 112 - system, and (b) will operate properly with a modified version 113 - of the Library that is interface-compatible with the Linked 114 - Version. 115 - 116 - e) Provide Installation Information, but only if you would otherwise 117 - be required to provide such information under section 6 of the 118 - GNU GPL, and only to the extent that such information is 119 - necessary to install and execute a modified version of the 120 - Combined Work produced by recombining or relinking the 121 - Application with a modified version of the Linked Version. (If 122 - you use option 4d0, the Installation Information must accompany 123 - the Minimal Corresponding Source and Corresponding Application 124 - Code. If you use option 4d1, you must provide the Installation 125 - Information in the manner specified by section 6 of the GNU GPL 126 - for conveying Corresponding Source.) 127 - 128 - 5. Combined Libraries. 129 - 130 - You may place library facilities that are a work based on the 131 -Library side by side in a single library together with other library 132 -facilities that are not Applications and are not covered by this 133 -License, and convey such a combined library under terms of your 134 -choice, if you do both of the following: 135 - 136 - a) Accompany the combined library with a copy of the same work based 137 - on the Library, uncombined with any other library facilities, 138 - conveyed under the terms of this License. 139 - 140 - b) Give prominent notice with the combined library that part of it 141 - is a work based on the Library, and explaining where to find the 142 - accompanying uncombined form of the same work. 143 - 144 - 6. Revised Versions of the GNU Lesser General Public License. 145 - 146 - The Free Software Foundation may publish revised and/or new versions 147 -of the GNU Lesser General Public License from time to time. Such new 148 -versions will be similar in spirit to the present version, but may 149 -differ in detail to address new problems or concerns. 150 - 151 - Each version is given a distinguishing version number. If the 152 -Library as you received it specifies that a certain numbered version 153 -of the GNU Lesser General Public License "or any later version" 154 -applies to it, you have the option of following the terms and 155 -conditions either of that published version or of any later version 156 -published by the Free Software Foundation. If the Library as you 157 -received it does not specify a version number of the GNU Lesser 158 -General Public License, you may choose any version of the GNU Lesser 159 -General Public License ever published by the Free Software Foundation. 160 - 161 - If the Library as you received it specifies that a proxy can decide 162 -whether future versions of the GNU Lesser General Public License shall 163 -apply, that proxy's public statement of acceptance of any version is 164 -permanent authorization for you to choose that version for the 165 -Library. 166 -
Deleted ChangeLog.
Deleted INSTALL.
1 -Basic Installation 2 -================== 3 - 4 - These are generic installation instructions. 5 - 6 - The `configure' shell script attempts to guess correct values for 7 -various system-dependent variables used during compilation. It uses 8 -those values to create a `Makefile' in each directory of the package. 9 -It may also create one or more `.h' files containing system-dependent 10 -definitions. Finally, it creates a shell script `config.status' that 11 -you can run in the future to recreate the current configuration, a file 12 -`config.cache' that saves the results of its tests to speed up 13 -reconfiguring, and a file `config.log' containing compiler output 14 -(useful mainly for debugging `configure'). 15 - 16 - If you need to do unusual things to compile the package, please try 17 -to figure out how `configure' could check whether to do them, and mail 18 -diffs or instructions to the address given in the `README' so they can 19 -be considered for the next release. If at some point `config.cache' 20 -contains results you don't want to keep, you may remove or edit it. 21 - 22 - The file `configure.in' is used to create `configure' by a program 23 -called `autoconf'. You only need `configure.in' if you want to change 24 -it or regenerate `configure' using a newer version of `autoconf'. 25 - 26 -The simplest way to compile this package is: 27 - 28 - 1. `cd' to the directory containing the package's source code and type 29 - `./configure' to configure the package for your system. If you're 30 - using `csh' on an old version of System V, you might need to type 31 - `sh ./configure' instead to prevent `csh' from trying to execute 32 - `configure' itself. 33 - 34 - Running `configure' takes awhile. While running, it prints some 35 - messages telling which features it is checking for. 36 - 37 - 2. Type `make' to compile the package. 38 - 39 - 3. Optionally, type `make check' to run any self-tests that come with 40 - the package. 41 - 42 - 4. Type `make install' to install the programs and any data files and 43 - documentation. 44 - 45 - 5. You can remove the program binaries and object files from the 46 - source code directory by typing `make clean'. To also remove the 47 - files that `configure' created (so you can compile the package for 48 - a different kind of computer), type `make distclean'. There is 49 - also a `make maintainer-clean' target, but that is intended mainly 50 - for the package's developers. If you use it, you may have to get 51 - all sorts of other programs in order to regenerate files that came 52 - with the distribution. 53 - 54 -Compilers and Options 55 -===================== 56 - 57 - Some systems require unusual options for compilation or linking that 58 -the `configure' script does not know about. You can give `configure' 59 -initial values for variables by setting them in the environment. Using 60 -a Bourne-compatible shell, you can do that on the command line like 61 -this: 62 - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure 63 - 64 -Or on systems that have the `env' program, you can do it like this: 65 - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure 66 - 67 -Compiling For Multiple Architectures 68 -==================================== 69 - 70 - You can compile the package for more than one kind of computer at the 71 -same time, by placing the object files for each architecture in their 72 -own directory. To do this, you must use a version of `make' that 73 -supports the `VPATH' variable, such as GNU `make'. `cd' to the 74 -directory where you want the object files and executables to go and run 75 -the `configure' script. `configure' automatically checks for the 76 -source code in the directory that `configure' is in and in `..'. 77 - 78 - If you have to use a `make' that does not supports the `VPATH' 79 -variable, you have to compile the package for one architecture at a time 80 -in the source code directory. After you have installed the package for 81 -one architecture, use `make distclean' before reconfiguring for another 82 -architecture. 83 - 84 -Installation Names 85 -================== 86 - 87 - By default, `make install' will install the package's files in 88 -`/usr/local/bin', `/usr/local/man', etc. You can specify an 89 -installation prefix other than `/usr/local' by giving `configure' the 90 -option `--prefix=PATH'. 91 - 92 - You can specify separate installation prefixes for 93 -architecture-specific files and architecture-independent files. If you 94 -give `configure' the option `--exec-prefix=PATH', the package will use 95 -PATH as the prefix for installing programs and libraries. 96 -Documentation and other data files will still use the regular prefix. 97 - 98 - In addition, if you use an unusual directory layout you can give 99 -options like `--bindir=PATH' to specify different values for particular 100 -kinds of files. Run `configure --help' for a list of the directories 101 -you can set and what kinds of files go in them. 102 - 103 - If the package supports it, you can cause programs to be installed 104 -with an extra prefix or suffix on their names by giving `configure' the 105 -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 106 - 107 -Optional Features 108 -================= 109 - 110 - Some packages pay attention to `--enable-FEATURE' options to 111 -`configure', where FEATURE indicates an optional part of the package. 112 -They may also pay attention to `--with-PACKAGE' options, where PACKAGE 113 -is something like `gnu-as' or `x' (for the X Window System). The 114 -`README' should mention any `--enable-' and `--with-' options that the 115 -package recognizes. 116 - 117 - For packages that use the X Window System, `configure' can usually 118 -find the X include and library files automatically, but if it doesn't, 119 -you can use the `configure' options `--x-includes=DIR' and 120 -`--x-libraries=DIR' to specify their locations. 121 - 122 -Specifying the System Type 123 -========================== 124 - 125 - There may be some features `configure' can not figure out 126 -automatically, but needs to determine by the type of host the package 127 -will run on. Usually `configure' can figure that out, but if it prints 128 -a message saying it can not guess the host type, give it the 129 -`--host=TYPE' option. TYPE can either be a short name for the system 130 -type, such as `sun4', or a canonical name with three fields: 131 - CPU-COMPANY-SYSTEM 132 - 133 -See the file `config.sub' for the possible values of each field. If 134 -`config.sub' isn't included in this package, then this package doesn't 135 -need to know the host type. 136 - 137 - If you are building compiler tools for cross-compiling, you can also 138 -use the `--target=TYPE' option to select the type of system they will 139 -produce code for and the `--build=TYPE' option to select the type of 140 -system on which you are compiling the package. 141 - 142 -Sharing Defaults 143 -================ 144 - 145 - If you want to set default values for `configure' scripts to share, 146 -you can create a site shell script called `config.site' that gives 147 -default values for variables like `CC', `cache_file', and `prefix'. 148 -`configure' looks for `PREFIX/share/config.site' if it exists, then 149 -`PREFIX/etc/config.site' if it exists. Or, you can set the 150 -`CONFIG_SITE' environment variable to the location of the site script. 151 -A warning: not all `configure' scripts look for a site script. 152 - 153 -Operation Controls 154 -================== 155 - 156 - `configure' recognizes the following options to control how it 157 -operates. 158 - 159 -`--cache-file=FILE' 160 - Use and save the results of the tests in FILE instead of 161 - `./config.cache'. Set FILE to `/dev/null' to disable caching, for 162 - debugging `configure'. 163 - 164 -`--help' 165 - Print a summary of the options to `configure', and exit. 166 - 167 -`--quiet' 168 -`--silent' 169 -`-q' 170 - Do not print messages saying which checks are being made. To 171 - suppress all normal output, redirect it to `/dev/null' (any error 172 - messages will still be shown). 173 - 174 -`--srcdir=DIR' 175 - Look for the package's source code in directory DIR. Usually 176 - `configure' can determine that directory automatically. 177 - 178 -`--version' 179 - Print the version of Autoconf used to generate the `configure' 180 - script, and exit. 181 - 182 -`configure' also accepts some other, not widely useful, options. 183 -
Deleted Makefile.am.
1 -ACLOCAL_AMFLAGS = -I m4 2 - 3 -SUBDIRS = headers src 4 - 5 -AUTOMAKE_OPTIONS = dist-zip 6 - 7 -pkgconfigdir = $(libdir)/pkgconfig 8 -pkgconfig_DATA = gaiagraphics.pc 9 -
Deleted Makefile.in.
1 -# Makefile.in generated by automake 1.13.4 from Makefile.am. 2 -# @configure_input@ 3 - 4 -# Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 - 6 -# This Makefile.in is free software; the Free Software Foundation 7 -# gives unlimited permission to copy and/or distribute it, 8 -# with or without modifications, as long as this notice is preserved. 9 - 10 -# This program is distributed in the hope that it will be useful, 11 -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 -# PARTICULAR PURPOSE. 14 - 15 -@SET_MAKE@ 16 - 17 -VPATH = @srcdir@ 18 -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 19 -am__make_running_with_option = \ 20 - case $${target_option-} in \ 21 - ?) ;; \ 22 - *) echo "am__make_running_with_option: internal error: invalid" \ 23 - "target option '$${target_option-}' specified" >&2; \ 24 - exit 1;; \ 25 - esac; \ 26 - has_opt=no; \ 27 - sane_makeflags=$$MAKEFLAGS; \ 28 - if $(am__is_gnu_make); then \ 29 - sane_makeflags=$$MFLAGS; \ 30 - else \ 31 - case $$MAKEFLAGS in \ 32 - *\\[\ \ ]*) \ 33 - bs=\\; \ 34 - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 35 - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 36 - esac; \ 37 - fi; \ 38 - skip_next=no; \ 39 - strip_trailopt () \ 40 - { \ 41 - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 42 - }; \ 43 - for flg in $$sane_makeflags; do \ 44 - test $$skip_next = yes && { skip_next=no; continue; }; \ 45 - case $$flg in \ 46 - *=*|--*) continue;; \ 47 - -*I) strip_trailopt 'I'; skip_next=yes;; \ 48 - -*I?*) strip_trailopt 'I';; \ 49 - -*O) strip_trailopt 'O'; skip_next=yes;; \ 50 - -*O?*) strip_trailopt 'O';; \ 51 - -*l) strip_trailopt 'l'; skip_next=yes;; \ 52 - -*l?*) strip_trailopt 'l';; \ 53 - -[dEDm]) skip_next=yes;; \ 54 - -[JT]) skip_next=yes;; \ 55 - esac; \ 56 - case $$flg in \ 57 - *$$target_option*) has_opt=yes; break;; \ 58 - esac; \ 59 - done; \ 60 - test $$has_opt = yes 61 -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 62 -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 63 -pkgdatadir = $(datadir)/@PACKAGE@ 64 -pkgincludedir = $(includedir)/@PACKAGE@ 65 -pkglibdir = $(libdir)/@PACKAGE@ 66 -pkglibexecdir = $(libexecdir)/@PACKAGE@ 67 -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 68 -install_sh_DATA = $(install_sh) -c -m 644 69 -install_sh_PROGRAM = $(install_sh) -c 70 -install_sh_SCRIPT = $(install_sh) -c 71 -INSTALL_HEADER = $(INSTALL_DATA) 72 -transform = $(program_transform_name) 73 -NORMAL_INSTALL = : 74 -PRE_INSTALL = : 75 -POST_INSTALL = : 76 -NORMAL_UNINSTALL = : 77 -PRE_UNINSTALL = : 78 -POST_UNINSTALL = : 79 -build_triplet = @build@ 80 -host_triplet = @host@ 81 -subdir = . 82 -DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ 83 - $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ 84 - $(top_srcdir)/configure $(am__configure_deps) \ 85 - $(srcdir)/gaiagraphics.pc.in COPYING config.guess config.sub \ 86 - depcomp install-sh missing ltmain.sh 87 -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 88 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ 89 - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ 90 - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ 91 - $(top_srcdir)/configure.ac 92 -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 93 - $(ACLOCAL_M4) 94 -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ 95 - configure.lineno config.status.lineno 96 -mkinstalldirs = $(install_sh) -d 97 -CONFIG_CLEAN_FILES = gaiagraphics.pc 98 -CONFIG_CLEAN_VPATH_FILES = 99 -AM_V_P = $(am__v_P_@AM_V@) 100 -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 101 -am__v_P_0 = false 102 -am__v_P_1 = : 103 -AM_V_GEN = $(am__v_GEN_@AM_V@) 104 -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 105 -am__v_GEN_0 = @echo " GEN " $@; 106 -am__v_GEN_1 = 107 -AM_V_at = $(am__v_at_@AM_V@) 108 -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 109 -am__v_at_0 = @ 110 -am__v_at_1 = 111 -SOURCES = 112 -DIST_SOURCES = 113 -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ 114 - ctags-recursive dvi-recursive html-recursive info-recursive \ 115 - install-data-recursive install-dvi-recursive \ 116 - install-exec-recursive install-html-recursive \ 117 - install-info-recursive install-pdf-recursive \ 118 - install-ps-recursive install-recursive installcheck-recursive \ 119 - installdirs-recursive pdf-recursive ps-recursive \ 120 - tags-recursive uninstall-recursive 121 -am__can_run_installinfo = \ 122 - case $$AM_UPDATE_INFO_DIR in \ 123 - n|no|NO) false;; \ 124 - *) (install-info --version) >/dev/null 2>&1;; \ 125 - esac 126 -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 127 -am__vpath_adj = case $$p in \ 128 - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 129 - *) f=$$p;; \ 130 - esac; 131 -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; 132 -am__install_max = 40 133 -am__nobase_strip_setup = \ 134 - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` 135 -am__nobase_strip = \ 136 - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" 137 -am__nobase_list = $(am__nobase_strip_setup); \ 138 - for p in $$list; do echo "$$p $$p"; done | \ 139 - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ 140 - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ 141 - if (++n[$$2] == $(am__install_max)) \ 142 - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ 143 - END { for (dir in files) print dir, files[dir] }' 144 -am__base_list = \ 145 - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ 146 - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' 147 -am__uninstall_files_from_dir = { \ 148 - test -z "$$files" \ 149 - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ 150 - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ 151 - $(am__cd) "$$dir" && rm -f $$files; }; \ 152 - } 153 -am__installdirs = "$(DESTDIR)$(pkgconfigdir)" 154 -DATA = $(pkgconfig_DATA) 155 -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ 156 - distclean-recursive maintainer-clean-recursive 157 -am__recursive_targets = \ 158 - $(RECURSIVE_TARGETS) \ 159 - $(RECURSIVE_CLEAN_TARGETS) \ 160 - $(am__extra_recursive_targets) 161 -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ 162 - cscope distdir dist dist-all distcheck 163 -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 164 -# Read a list of newline-separated strings from the standard input, 165 -# and print each of them once, without duplicates. Input order is 166 -# *not* preserved. 167 -am__uniquify_input = $(AWK) '\ 168 - BEGIN { nonempty = 0; } \ 169 - { items[$$0] = 1; nonempty = 1; } \ 170 - END { if (nonempty) { for (i in items) print i; }; } \ 171 -' 172 -# Make sure the list of sources is unique. This is necessary because, 173 -# e.g., the same source file might be shared among _SOURCES variables 174 -# for different programs/libraries. 175 -am__define_uniq_tagged_files = \ 176 - list='$(am__tagged_files)'; \ 177 - unique=`for i in $$list; do \ 178 - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 179 - done | $(am__uniquify_input)` 180 -ETAGS = etags 181 -CTAGS = ctags 182 -CSCOPE = cscope 183 -DIST_SUBDIRS = $(SUBDIRS) 184 -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 185 -distdir = $(PACKAGE)-$(VERSION) 186 -top_distdir = $(distdir) 187 -am__remove_distdir = \ 188 - if test -d "$(distdir)"; then \ 189 - find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ 190 - && rm -rf "$(distdir)" \ 191 - || { sleep 5 && rm -rf "$(distdir)"; }; \ 192 - else :; fi 193 -am__post_remove_distdir = $(am__remove_distdir) 194 -am__relativize = \ 195 - dir0=`pwd`; \ 196 - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ 197 - sed_rest='s,^[^/]*/*,,'; \ 198 - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ 199 - sed_butlast='s,/*[^/]*$$,,'; \ 200 - while test -n "$$dir1"; do \ 201 - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ 202 - if test "$$first" != "."; then \ 203 - if test "$$first" = ".."; then \ 204 - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ 205 - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ 206 - else \ 207 - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ 208 - if test "$$first2" = "$$first"; then \ 209 - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ 210 - else \ 211 - dir2="../$$dir2"; \ 212 - fi; \ 213 - dir0="$$dir0"/"$$first"; \ 214 - fi; \ 215 - fi; \ 216 - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ 217 - done; \ 218 - reldir="$$dir2" 219 -DIST_ARCHIVES = $(distdir).tar.gz $(distdir).zip 220 -GZIP_ENV = --best 221 -DIST_TARGETS = dist-gzip dist-zip 222 -distuninstallcheck_listfiles = find . -type f -print 223 -am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ 224 - | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' 225 -distcleancheck_listfiles = find . -type f -print 226 -ACLOCAL = @ACLOCAL@ 227 -AMTAR = @AMTAR@ 228 -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 229 -AR = @AR@ 230 -AS = @AS@ 231 -AUTOCONF = @AUTOCONF@ 232 -AUTOHEADER = @AUTOHEADER@ 233 -AUTOMAKE = @AUTOMAKE@ 234 -AWK = @AWK@ 235 -CC = @CC@ 236 -CCDEPMODE = @CCDEPMODE@ 237 -CFLAGS = @CFLAGS@ 238 -CPP = @CPP@ 239 -CPPFLAGS = @CPPFLAGS@ 240 -CXX = @CXX@ 241 -CXXCPP = @CXXCPP@ 242 -CXXDEPMODE = @CXXDEPMODE@ 243 -CXXFLAGS = @CXXFLAGS@ 244 -CYGPATH_W = @CYGPATH_W@ 245 -DEFS = @DEFS@ 246 -DEPDIR = @DEPDIR@ 247 -DLLTOOL = @DLLTOOL@ 248 -DSYMUTIL = @DSYMUTIL@ 249 -DUMPBIN = @DUMPBIN@ 250 -ECHO_C = @ECHO_C@ 251 -ECHO_N = @ECHO_N@ 252 -ECHO_T = @ECHO_T@ 253 -EGREP = @EGREP@ 254 -EXEEXT = @EXEEXT@ 255 -FGREP = @FGREP@ 256 -GREP = @GREP@ 257 -INSTALL = @INSTALL@ 258 -INSTALL_DATA = @INSTALL_DATA@ 259 -INSTALL_PROGRAM = @INSTALL_PROGRAM@ 260 -INSTALL_SCRIPT = @INSTALL_SCRIPT@ 261 -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 262 -LD = @LD@ 263 -LDFLAGS = @LDFLAGS@ 264 -LIBCAIRO_CFLAGS = @LIBCAIRO_CFLAGS@ 265 -LIBCAIRO_LIBS = @LIBCAIRO_LIBS@ 266 -LIBOBJS = @LIBOBJS@ 267 -LIBPNG_CFLAGS = @LIBPNG_CFLAGS@ 268 -LIBPNG_LIBS = @LIBPNG_LIBS@ 269 -LIBS = @LIBS@ 270 -LIBTOOL = @LIBTOOL@ 271 -LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ 272 -LIBXML2_LIBS = @LIBXML2_LIBS@ 273 -LIPO = @LIPO@ 274 -LN_S = @LN_S@ 275 -LTLIBOBJS = @LTLIBOBJS@ 276 -MAINT = @MAINT@ 277 -MAKEINFO = @MAKEINFO@ 278 -MANIFEST_TOOL = @MANIFEST_TOOL@ 279 -MKDIR_P = @MKDIR_P@ 280 -NM = @NM@ 281 -NMEDIT = @NMEDIT@ 282 -OBJDUMP = @OBJDUMP@ 283 -OBJEXT = @OBJEXT@ 284 -OTOOL = @OTOOL@ 285 -OTOOL64 = @OTOOL64@ 286 -PACKAGE = @PACKAGE@ 287 -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 288 -PACKAGE_NAME = @PACKAGE_NAME@ 289 -PACKAGE_STRING = @PACKAGE_STRING@ 290 -PACKAGE_TARNAME = @PACKAGE_TARNAME@ 291 -PACKAGE_URL = @PACKAGE_URL@ 292 -PACKAGE_VERSION = @PACKAGE_VERSION@ 293 -PATH_SEPARATOR = @PATH_SEPARATOR@ 294 -PKG_CONFIG = @PKG_CONFIG@ 295 -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ 296 -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ 297 -RANLIB = @RANLIB@ 298 -SED = @SED@ 299 -SET_MAKE = @SET_MAKE@ 300 -SHELL = @SHELL@ 301 -STRIP = @STRIP@ 302 -VERSION = @VERSION@ 303 -abs_builddir = @abs_builddir@ 304 -abs_srcdir = @abs_srcdir@ 305 -abs_top_builddir = @abs_top_builddir@ 306 -abs_top_srcdir = @abs_top_srcdir@ 307 -ac_ct_AR = @ac_ct_AR@ 308 -ac_ct_CC = @ac_ct_CC@ 309 -ac_ct_CXX = @ac_ct_CXX@ 310 -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 311 -am__include = @am__include@ 312 -am__leading_dot = @am__leading_dot@ 313 -am__quote = @am__quote@ 314 -am__tar = @am__tar@ 315 -am__untar = @am__untar@ 316 -bindir = @bindir@ 317 -build = @build@ 318 -build_alias = @build_alias@ 319 -build_cpu = @build_cpu@ 320 -build_os = @build_os@ 321 -build_vendor = @build_vendor@ 322 -builddir = @builddir@ 323 -datadir = @datadir@ 324 -datarootdir = @datarootdir@ 325 -docdir = @docdir@ 326 -dvidir = @dvidir@ 327 -exec_prefix = @exec_prefix@ 328 -host = @host@ 329 -host_alias = @host_alias@ 330 -host_cpu = @host_cpu@ 331 -host_os = @host_os@ 332 -host_vendor = @host_vendor@ 333 -htmldir = @htmldir@ 334 -includedir = @includedir@ 335 -infodir = @infodir@ 336 -install_sh = @install_sh@ 337 -libdir = @libdir@ 338 -libexecdir = @libexecdir@ 339 -localedir = @localedir@ 340 -localstatedir = @localstatedir@ 341 -mandir = @mandir@ 342 -mkdir_p = @mkdir_p@ 343 -oldincludedir = @oldincludedir@ 344 -pdfdir = @pdfdir@ 345 -prefix = @prefix@ 346 -program_transform_name = @program_transform_name@ 347 -psdir = @psdir@ 348 -sbindir = @sbindir@ 349 -sharedstatedir = @sharedstatedir@ 350 -srcdir = @srcdir@ 351 -sysconfdir = @sysconfdir@ 352 -target_alias = @target_alias@ 353 -top_build_prefix = @top_build_prefix@ 354 -top_builddir = @top_builddir@ 355 -top_srcdir = @top_srcdir@ 356 -ACLOCAL_AMFLAGS = -I m4 357 -SUBDIRS = headers src 358 -AUTOMAKE_OPTIONS = dist-zip 359 -pkgconfigdir = $(libdir)/pkgconfig 360 -pkgconfig_DATA = gaiagraphics.pc 361 -all: all-recursive 362 - 363 -.SUFFIXES: 364 -am--refresh: Makefile 365 - @: 366 -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) 367 - @for dep in $?; do \ 368 - case '$(am__configure_deps)' in \ 369 - *$$dep*) \ 370 - echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ 371 - $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ 372 - && exit 0; \ 373 - exit 1;; \ 374 - esac; \ 375 - done; \ 376 - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ 377 - $(am__cd) $(top_srcdir) && \ 378 - $(AUTOMAKE) --gnu Makefile 379 -.PRECIOUS: Makefile 380 -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 381 - @case '$?' in \ 382 - *config.status*) \ 383 - echo ' $(SHELL) ./config.status'; \ 384 - $(SHELL) ./config.status;; \ 385 - *) \ 386 - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ 387 - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ 388 - esac; 389 - 390 -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 391 - $(SHELL) ./config.status --recheck 392 - 393 -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 394 - $(am__cd) $(srcdir) && $(AUTOCONF) 395 -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) 396 - $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) 397 -$(am__aclocal_m4_deps): 398 -gaiagraphics.pc: $(top_builddir)/config.status $(srcdir)/gaiagraphics.pc.in 399 - cd $(top_builddir) && $(SHELL) ./config.status $@ 400 - 401 -mostlyclean-libtool: 402 - -rm -f *.lo 403 - 404 -clean-libtool: 405 - -rm -rf .libs _libs 406 - 407 -distclean-libtool: 408 - -rm -f libtool config.lt 409 -install-pkgconfigDATA: $(pkgconfig_DATA) 410 - @$(NORMAL_INSTALL) 411 - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ 412 - if test -n "$$list"; then \ 413 - echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ 414 - $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ 415 - fi; \ 416 - for p in $$list; do \ 417 - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 418 - echo "$$d$$p"; \ 419 - done | $(am__base_list) | \ 420 - while read files; do \ 421 - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ 422 - $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ 423 - done 424 - 425 -uninstall-pkgconfigDATA: 426 - @$(NORMAL_UNINSTALL) 427 - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ 428 - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ 429 - dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) 430 - 431 -# This directory's subdirectories are mostly independent; you can cd 432 -# into them and run 'make' without going through this Makefile. 433 -# To change the values of 'make' variables: instead of editing Makefiles, 434 -# (1) if the variable is set in 'config.status', edit 'config.status' 435 -# (which will cause the Makefiles to be regenerated when you run 'make'); 436 -# (2) otherwise, pass the desired values on the 'make' command line. 437 -$(am__recursive_targets): 438 - @fail=; \ 439 - if $(am__make_keepgoing); then \ 440 - failcom='fail=yes'; \ 441 - else \ 442 - failcom='exit 1'; \ 443 - fi; \ 444 - dot_seen=no; \ 445 - target=`echo $@ | sed s/-recursive//`; \ 446 - case "$@" in \ 447 - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ 448 - *) list='$(SUBDIRS)' ;; \ 449 - esac; \ 450 - for subdir in $$list; do \ 451 - echo "Making $$target in $$subdir"; \ 452 - if test "$$subdir" = "."; then \ 453 - dot_seen=yes; \ 454 - local_target="$$target-am"; \ 455 - else \ 456 - local_target="$$target"; \ 457 - fi; \ 458 - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ 459 - || eval $$failcom; \ 460 - done; \ 461 - if test "$$dot_seen" = "no"; then \ 462 - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ 463 - fi; test -z "$$fail" 464 - 465 -ID: $(am__tagged_files) 466 - $(am__define_uniq_tagged_files); mkid -fID $$unique 467 -tags: tags-recursive 468 -TAGS: tags 469 - 470 -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 471 - set x; \ 472 - here=`pwd`; \ 473 - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ 474 - include_option=--etags-include; \ 475 - empty_fix=.; \ 476 - else \ 477 - include_option=--include; \ 478 - empty_fix=; \ 479 - fi; \ 480 - list='$(SUBDIRS)'; for subdir in $$list; do \ 481 - if test "$$subdir" = .; then :; else \ 482 - test ! -f $$subdir/TAGS || \ 483 - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ 484 - fi; \ 485 - done; \ 486 - $(am__define_uniq_tagged_files); \ 487 - shift; \ 488 - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 489 - test -n "$$unique" || unique=$$empty_fix; \ 490 - if test $$# -gt 0; then \ 491 - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 492 - "$$@" $$unique; \ 493 - else \ 494 - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 495 - $$unique; \ 496 - fi; \ 497 - fi 498 -ctags: ctags-recursive 499 - 500 -CTAGS: ctags 501 -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 502 - $(am__define_uniq_tagged_files); \ 503 - test -z "$(CTAGS_ARGS)$$unique" \ 504 - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 505 - $$unique 506 - 507 -GTAGS: 508 - here=`$(am__cd) $(top_builddir) && pwd` \ 509 - && $(am__cd) $(top_srcdir) \ 510 - && gtags -i $(GTAGS_ARGS) "$$here" 511 -cscope: cscope.files 512 - test ! -s cscope.files \ 513 - || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) 514 -clean-cscope: 515 - -rm -f cscope.files 516 -cscope.files: clean-cscope cscopelist 517 -cscopelist: cscopelist-recursive 518 - 519 -cscopelist-am: $(am__tagged_files) 520 - list='$(am__tagged_files)'; \ 521 - case "$(srcdir)" in \ 522 - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 523 - *) sdir=$(subdir)/$(srcdir) ;; \ 524 - esac; \ 525 - for i in $$list; do \ 526 - if test -f "$$i"; then \ 527 - echo "$(subdir)/$$i"; \ 528 - else \ 529 - echo "$$sdir/$$i"; \ 530 - fi; \ 531 - done >> $(top_builddir)/cscope.files 532 - 533 -distclean-tags: 534 - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 535 - -rm -f cscope.out cscope.in.out cscope.po.out cscope.files 536 - 537 -distdir: $(DISTFILES) 538 - $(am__remove_distdir) 539 - test -d "$(distdir)" || mkdir "$(distdir)" 540 - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 541 - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 542 - list='$(DISTFILES)'; \ 543 - dist_files=`for file in $$list; do echo $$file; done | \ 544 - sed -e "s|^$$srcdirstrip/||;t" \ 545 - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 546 - case $$dist_files in \ 547 - */*) $(MKDIR_P) `echo "$$dist_files" | \ 548 - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 549 - sort -u` ;; \ 550 - esac; \ 551 - for file in $$dist_files; do \ 552 - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 553 - if test -d $$d/$$file; then \ 554 - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 555 - if test -d "$(distdir)/$$file"; then \ 556 - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 557 - fi; \ 558 - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 559 - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 560 - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 561 - fi; \ 562 - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 563 - else \ 564 - test -f "$(distdir)/$$file" \ 565 - || cp -p $$d/$$file "$(distdir)/$$file" \ 566 - || exit 1; \ 567 - fi; \ 568 - done 569 - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ 570 - if test "$$subdir" = .; then :; else \ 571 - $(am__make_dryrun) \ 572 - || test -d "$(distdir)/$$subdir" \ 573 - || $(MKDIR_P) "$(distdir)/$$subdir" \ 574 - || exit 1; \ 575 - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ 576 - $(am__relativize); \ 577 - new_distdir=$$reldir; \ 578 - dir1=$$subdir; dir2="$(top_distdir)"; \ 579 - $(am__relativize); \ 580 - new_top_distdir=$$reldir; \ 581 - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ 582 - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ 583 - ($(am__cd) $$subdir && \ 584 - $(MAKE) $(AM_MAKEFLAGS) \ 585 - top_distdir="$$new_top_distdir" \ 586 - distdir="$$new_distdir" \ 587 - am__remove_distdir=: \ 588 - am__skip_length_check=: \ 589 - am__skip_mode_fix=: \ 590 - distdir) \ 591 - || exit 1; \ 592 - fi; \ 593 - done 594 - -test -n "$(am__skip_mode_fix)" \ 595 - || find "$(distdir)" -type d ! -perm -755 \ 596 - -exec chmod u+rwx,go+rx {} \; -o \ 597 - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ 598 - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ 599 - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ 600 - || chmod -R a+r "$(distdir)" 601 -dist-gzip: distdir 602 - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 603 - $(am__post_remove_distdir) 604 - 605 -dist-bzip2: distdir 606 - tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 607 - $(am__post_remove_distdir) 608 - 609 -dist-lzip: distdir 610 - tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz 611 - $(am__post_remove_distdir) 612 - 613 -dist-xz: distdir 614 - tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz 615 - $(am__post_remove_distdir) 616 - 617 -dist-tarZ: distdir 618 - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z 619 - $(am__post_remove_distdir) 620 - 621 -dist-shar: distdir 622 - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz 623 - $(am__post_remove_distdir) 624 -dist-zip: distdir 625 - -rm -f $(distdir).zip 626 - zip -rq $(distdir).zip $(distdir) 627 - $(am__post_remove_distdir) 628 - 629 -dist dist-all: 630 - $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' 631 - $(am__post_remove_distdir) 632 - 633 -# This target untars the dist file and tries a VPATH configuration. Then 634 -# it guarantees that the distribution is self-contained by making another 635 -# tarfile. 636 -distcheck: dist 637 - case '$(DIST_ARCHIVES)' in \ 638 - *.tar.gz*) \ 639 - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ 640 - *.tar.bz2*) \ 641 - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ 642 - *.tar.lz*) \ 643 - lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ 644 - *.tar.xz*) \ 645 - xz -dc $(distdir).tar.xz | $(am__untar) ;;\ 646 - *.tar.Z*) \ 647 - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ 648 - *.shar.gz*) \ 649 - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ 650 - *.zip*) \ 651 - unzip $(distdir).zip ;;\ 652 - esac 653 - chmod -R a-w $(distdir) 654 - chmod u+w $(distdir) 655 - mkdir $(distdir)/_build $(distdir)/_inst 656 - chmod a-w $(distdir) 657 - test -d $(distdir)/_build || exit 0; \ 658 - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ 659 - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ 660 - && am__cwd=`pwd` \ 661 - && $(am__cd) $(distdir)/_build \ 662 - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ 663 - $(AM_DISTCHECK_CONFIGURE_FLAGS) \ 664 - $(DISTCHECK_CONFIGURE_FLAGS) \ 665 - && $(MAKE) $(AM_MAKEFLAGS) \ 666 - && $(MAKE) $(AM_MAKEFLAGS) dvi \ 667 - && $(MAKE) $(AM_MAKEFLAGS) check \ 668 - && $(MAKE) $(AM_MAKEFLAGS) install \ 669 - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ 670 - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ 671 - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ 672 - distuninstallcheck \ 673 - && chmod -R a-w "$$dc_install_base" \ 674 - && ({ \ 675 - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ 676 - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ 677 - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ 678 - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ 679 - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ 680 - } || { rm -rf "$$dc_destdir"; exit 1; }) \ 681 - && rm -rf "$$dc_destdir" \ 682 - && $(MAKE) $(AM_MAKEFLAGS) dist \ 683 - && rm -rf $(DIST_ARCHIVES) \ 684 - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ 685 - && cd "$$am__cwd" \ 686 - || exit 1 687 - $(am__post_remove_distdir) 688 - @(echo "$(distdir) archives ready for distribution: "; \ 689 - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ 690 - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' 691 -distuninstallcheck: 692 - @test -n '$(distuninstallcheck_dir)' || { \ 693 - echo 'ERROR: trying to run $@ with an empty' \ 694 - '$$(distuninstallcheck_dir)' >&2; \ 695 - exit 1; \ 696 - }; \ 697 - $(am__cd) '$(distuninstallcheck_dir)' || { \ 698 - echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ 699 - exit 1; \ 700 - }; \ 701 - test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ 702 - || { echo "ERROR: files left after uninstall:" ; \ 703 - if test -n "$(DESTDIR)"; then \ 704 - echo " (check DESTDIR support)"; \ 705 - fi ; \ 706 - $(distuninstallcheck_listfiles) ; \ 707 - exit 1; } >&2 708 -distcleancheck: distclean 709 - @if test '$(srcdir)' = . ; then \ 710 - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ 711 - exit 1 ; \ 712 - fi 713 - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ 714 - || { echo "ERROR: files left in build directory after distclean:" ; \ 715 - $(distcleancheck_listfiles) ; \ 716 - exit 1; } >&2 717 -check-am: all-am 718 -check: check-recursive 719 -all-am: Makefile $(DATA) 720 -installdirs: installdirs-recursive 721 -installdirs-am: 722 - for dir in "$(DESTDIR)$(pkgconfigdir)"; do \ 723 - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 724 - done 725 -install: install-recursive 726 -install-exec: install-exec-recursive 727 -install-data: install-data-recursive 728 -uninstall: uninstall-recursive 729 - 730 -install-am: all-am 731 - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 732 - 733 -installcheck: installcheck-recursive 734 -install-strip: 735 - if test -z '$(STRIP)'; then \ 736 - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 737 - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 738 - install; \ 739 - else \ 740 - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 741 - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 742 - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 743 - fi 744 -mostlyclean-generic: 745 - 746 -clean-generic: 747 - 748 -distclean-generic: 749 - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 750 - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 751 - 752 -maintainer-clean-generic: 753 - @echo "This command is intended for maintainers to use" 754 - @echo "it deletes files that may require special tools to rebuild." 755 -clean: clean-recursive 756 - 757 -clean-am: clean-generic clean-libtool mostlyclean-am 758 - 759 -distclean: distclean-recursive 760 - -rm -f $(am__CONFIG_DISTCLEAN_FILES) 761 - -rm -f Makefile 762 -distclean-am: clean-am distclean-generic distclean-libtool \ 763 - distclean-tags 764 - 765 -dvi: dvi-recursive 766 - 767 -dvi-am: 768 - 769 -html: html-recursive 770 - 771 -html-am: 772 - 773 -info: info-recursive 774 - 775 -info-am: 776 - 777 -install-data-am: install-pkgconfigDATA 778 - 779 -install-dvi: install-dvi-recursive 780 - 781 -install-dvi-am: 782 - 783 -install-exec-am: 784 - 785 -install-html: install-html-recursive 786 - 787 -install-html-am: 788 - 789 -install-info: install-info-recursive 790 - 791 -install-info-am: 792 - 793 -install-man: 794 - 795 -install-pdf: install-pdf-recursive 796 - 797 -install-pdf-am: 798 - 799 -install-ps: install-ps-recursive 800 - 801 -install-ps-am: 802 - 803 -installcheck-am: 804 - 805 -maintainer-clean: maintainer-clean-recursive 806 - -rm -f $(am__CONFIG_DISTCLEAN_FILES) 807 - -rm -rf $(top_srcdir)/autom4te.cache 808 - -rm -f Makefile 809 -maintainer-clean-am: distclean-am maintainer-clean-generic 810 - 811 -mostlyclean: mostlyclean-recursive 812 - 813 -mostlyclean-am: mostlyclean-generic mostlyclean-libtool 814 - 815 -pdf: pdf-recursive 816 - 817 -pdf-am: 818 - 819 -ps: ps-recursive 820 - 821 -ps-am: 822 - 823 -uninstall-am: uninstall-pkgconfigDATA 824 - 825 -.MAKE: $(am__recursive_targets) install-am install-strip 826 - 827 -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ 828 - am--refresh check check-am clean clean-cscope clean-generic \ 829 - clean-libtool cscope cscopelist-am ctags ctags-am dist \ 830 - dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ 831 - dist-xz dist-zip distcheck distclean distclean-generic \ 832 - distclean-libtool distclean-tags distcleancheck distdir \ 833 - distuninstallcheck dvi dvi-am html html-am info info-am \ 834 - install install-am install-data install-data-am install-dvi \ 835 - install-dvi-am install-exec install-exec-am install-html \ 836 - install-html-am install-info install-info-am install-man \ 837 - install-pdf install-pdf-am install-pkgconfigDATA install-ps \ 838 - install-ps-am install-strip installcheck installcheck-am \ 839 - installdirs installdirs-am maintainer-clean \ 840 - maintainer-clean-generic mostlyclean mostlyclean-generic \ 841 - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ 842 - uninstall-am uninstall-pkgconfigDATA 843 - 844 - 845 -# Tell versions [3.59,3.63) of GNU make to not export all variables. 846 -# Otherwise a system limit (for SysV at least) may be exceeded. 847 -.NOEXPORT:
Deleted NEWS.
Deleted README.
1 -If you get build (compilation) errors about missing symbols or types starting with wx, then try installing the GTK version of the WxWidgets packages (if any).
Deleted aclocal.m4.
1 -# generated automatically by aclocal 1.13.4 -*- Autoconf -*- 2 - 3 -# Copyright (C) 1996-2013 Free Software Foundation, Inc. 4 - 5 -# This file is free software; the Free Software Foundation 6 -# gives unlimited permission to copy and/or distribute it, 7 -# with or without modifications, as long as this notice is preserved. 8 - 9 -# This program is distributed in the hope that it will be useful, 10 -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11 -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 -# PARTICULAR PURPOSE. 13 - 14 -m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) 15 -m4_ifndef([AC_AUTOCONF_VERSION], 16 - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl 17 -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, 18 -[m4_warning([this file was generated for autoconf 2.69. 19 -You have another version of autoconf. It may work, but is not guaranteed to. 20 -If you have problems, you may need to regenerate the build system entirely. 21 -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) 22 - 23 -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- 24 -# serial 1 (pkg-config-0.24) 25 -# 26 -# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. 27 -# 28 -# This program is free software; you can redistribute it and/or modify 29 -# it under the terms of the GNU General Public License as published by 30 -# the Free Software Foundation; either version 2 of the License, or 31 -# (at your option) any later version. 32 -# 33 -# This program is distributed in the hope that it will be useful, but 34 -# WITHOUT ANY WARRANTY; without even the implied warranty of 35 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 -# General Public License for more details. 37 -# 38 -# You should have received a copy of the GNU General Public License 39 -# along with this program; if not, write to the Free Software 40 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 41 -# 42 -# As a special exception to the GNU General Public License, if you 43 -# distribute this file as part of a program that contains a 44 -# configuration script generated by Autoconf, you may include it under 45 -# the same distribution terms that you use for the rest of that program. 46 - 47 -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) 48 -# ---------------------------------- 49 -AC_DEFUN([PKG_PROG_PKG_CONFIG], 50 -[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) 51 -m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) 52 -m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) 53 -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) 54 -AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) 55 -AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) 56 - 57 -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then 58 - AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) 59 -fi 60 -if test -n "$PKG_CONFIG"; then 61 - _pkg_min_version=m4_default([$1], [0.9.0]) 62 - AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) 63 - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then 64 - AC_MSG_RESULT([yes]) 65 - else 66 - AC_MSG_RESULT([no]) 67 - PKG_CONFIG="" 68 - fi 69 -fi[]dnl 70 -])# PKG_PROG_PKG_CONFIG 71 - 72 -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 73 -# 74 -# Check to see whether a particular set of modules exists. Similar 75 -# to PKG_CHECK_MODULES(), but does not set variables or print errors. 76 -# 77 -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 78 -# only at the first occurence in configure.ac, so if the first place 79 -# it's called might be skipped (such as if it is within an "if", you 80 -# have to call PKG_CHECK_EXISTS manually 81 -# -------------------------------------------------------------- 82 -AC_DEFUN([PKG_CHECK_EXISTS], 83 -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 84 -if test -n "$PKG_CONFIG" && \ 85 - AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then 86 - m4_default([$2], [:]) 87 -m4_ifvaln([$3], [else 88 - $3])dnl 89 -fi]) 90 - 91 -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) 92 -# --------------------------------------------- 93 -m4_define([_PKG_CONFIG], 94 -[if test -n "$$1"; then 95 - pkg_cv_[]$1="$$1" 96 - elif test -n "$PKG_CONFIG"; then 97 - PKG_CHECK_EXISTS([$3], 98 - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` 99 - test "x$?" != "x0" && pkg_failed=yes ], 100 - [pkg_failed=yes]) 101 - else 102 - pkg_failed=untried 103 -fi[]dnl 104 -])# _PKG_CONFIG 105 - 106 -# _PKG_SHORT_ERRORS_SUPPORTED 107 -# ----------------------------- 108 -AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], 109 -[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 110 -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then 111 - _pkg_short_errors_supported=yes 112 -else 113 - _pkg_short_errors_supported=no 114 -fi[]dnl 115 -])# _PKG_SHORT_ERRORS_SUPPORTED 116 - 117 - 118 -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 119 -# [ACTION-IF-NOT-FOUND]) 120 -# 121 -# 122 -# Note that if there is a possibility the first call to 123 -# PKG_CHECK_MODULES might not happen, you should be sure to include an 124 -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac 125 -# 126 -# 127 -# -------------------------------------------------------------- 128 -AC_DEFUN([PKG_CHECK_MODULES], 129 -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 130 -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl 131 -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl 132 - 133 -pkg_failed=no 134 -AC_MSG_CHECKING([for $1]) 135 - 136 -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) 137 -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) 138 - 139 -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS 140 -and $1[]_LIBS to avoid the need to call pkg-config. 141 -See the pkg-config man page for more details.]) 142 - 143 -if test $pkg_failed = yes; then 144 - AC_MSG_RESULT([no]) 145 - _PKG_SHORT_ERRORS_SUPPORTED 146 - if test $_pkg_short_errors_supported = yes; then 147 - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` 148 - else 149 - $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` 150 - fi 151 - # Put the nasty error message in config.log where it belongs 152 - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD 153 - 154 - m4_default([$4], [AC_MSG_ERROR( 155 -[Package requirements ($2) were not met: 156 - 157 -$$1_PKG_ERRORS 158 - 159 -Consider adjusting the PKG_CONFIG_PATH environment variable if you 160 -installed software in a non-standard prefix. 161 - 162 -_PKG_TEXT])[]dnl 163 - ]) 164 -elif test $pkg_failed = untried; then 165 - AC_MSG_RESULT([no]) 166 - m4_default([$4], [AC_MSG_FAILURE( 167 -[The pkg-config script could not be found or is too old. Make sure it 168 -is in your PATH or set the PKG_CONFIG environment variable to the full 169 -path to pkg-config. 170 - 171 -_PKG_TEXT 172 - 173 -To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl 174 - ]) 175 -else 176 - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS 177 - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS 178 - AC_MSG_RESULT([yes]) 179 - $3 180 -fi[]dnl 181 -])# PKG_CHECK_MODULES 182 - 183 - 184 -# PKG_INSTALLDIR(DIRECTORY) 185 -# ------------------------- 186 -# Substitutes the variable pkgconfigdir as the location where a module 187 -# should install pkg-config .pc files. By default the directory is 188 -# $libdir/pkgconfig, but the default can be changed by passing 189 -# DIRECTORY. The user can override through the --with-pkgconfigdir 190 -# parameter. 191 -AC_DEFUN([PKG_INSTALLDIR], 192 -[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) 193 -m4_pushdef([pkg_description], 194 - [pkg-config installation directory @<:@]pkg_default[@:>@]) 195 -AC_ARG_WITH([pkgconfigdir], 196 - [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, 197 - [with_pkgconfigdir=]pkg_default) 198 -AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) 199 -m4_popdef([pkg_default]) 200 -m4_popdef([pkg_description]) 201 -]) dnl PKG_INSTALLDIR 202 - 203 - 204 -# PKG_NOARCH_INSTALLDIR(DIRECTORY) 205 -# ------------------------- 206 -# Substitutes the variable noarch_pkgconfigdir as the location where a 207 -# module should install arch-independent pkg-config .pc files. By 208 -# default the directory is $datadir/pkgconfig, but the default can be 209 -# changed by passing DIRECTORY. The user can override through the 210 -# --with-noarch-pkgconfigdir parameter. 211 -AC_DEFUN([PKG_NOARCH_INSTALLDIR], 212 -[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) 213 -m4_pushdef([pkg_description], 214 - [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) 215 -AC_ARG_WITH([noarch-pkgconfigdir], 216 - [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, 217 - [with_noarch_pkgconfigdir=]pkg_default) 218 -AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) 219 -m4_popdef([pkg_default]) 220 -m4_popdef([pkg_description]) 221 -]) dnl PKG_NOARCH_INSTALLDIR 222 - 223 -# Copyright (C) 2002-2013 Free Software Foundation, Inc. 224 -# 225 -# This file is free software; the Free Software Foundation 226 -# gives unlimited permission to copy and/or distribute it, 227 -# with or without modifications, as long as this notice is preserved. 228 - 229 -# AM_AUTOMAKE_VERSION(VERSION) 230 -# ---------------------------- 231 -# Automake X.Y traces this macro to ensure aclocal.m4 has been 232 -# generated from the m4 files accompanying Automake X.Y. 233 -# (This private macro should not be called outside this file.) 234 -AC_DEFUN([AM_AUTOMAKE_VERSION], 235 -[am__api_version='1.13' 236 -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to 237 -dnl require some minimum version. Point them to the right macro. 238 -m4_if([$1], [1.13.4], [], 239 - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl 240 -]) 241 - 242 -# _AM_AUTOCONF_VERSION(VERSION) 243 -# ----------------------------- 244 -# aclocal traces this macro to find the Autoconf version. 245 -# This is a private macro too. Using m4_define simplifies 246 -# the logic in aclocal, which can simply ignore this definition. 247 -m4_define([_AM_AUTOCONF_VERSION], []) 248 - 249 -# AM_SET_CURRENT_AUTOMAKE_VERSION 250 -# ------------------------------- 251 -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. 252 -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. 253 -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], 254 -[AM_AUTOMAKE_VERSION([1.13.4])dnl 255 -m4_ifndef([AC_AUTOCONF_VERSION], 256 - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl 257 -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) 258 - 259 -# AM_AUX_DIR_EXPAND -*- Autoconf -*- 260 - 261 -# Copyright (C) 2001-2013 Free Software Foundation, Inc. 262 -# 263 -# This file is free software; the Free Software Foundation 264 -# gives unlimited permission to copy and/or distribute it, 265 -# with or without modifications, as long as this notice is preserved. 266 - 267 -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets 268 -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to 269 -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. 270 -# 271 -# Of course, Automake must honor this variable whenever it calls a 272 -# tool from the auxiliary directory. The problem is that $srcdir (and 273 -# therefore $ac_aux_dir as well) can be either absolute or relative, 274 -# depending on how configure is run. This is pretty annoying, since 275 -# it makes $ac_aux_dir quite unusable in subdirectories: in the top 276 -# source directory, any form will work fine, but in subdirectories a 277 -# relative path needs to be adjusted first. 278 -# 279 -# $ac_aux_dir/missing 280 -# fails when called from a subdirectory if $ac_aux_dir is relative 281 -# $top_srcdir/$ac_aux_dir/missing 282 -# fails if $ac_aux_dir is absolute, 283 -# fails when called from a subdirectory in a VPATH build with 284 -# a relative $ac_aux_dir 285 -# 286 -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir 287 -# are both prefixed by $srcdir. In an in-source build this is usually 288 -# harmless because $srcdir is '.', but things will broke when you 289 -# start a VPATH build or use an absolute $srcdir. 290 -# 291 -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, 292 -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: 293 -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` 294 -# and then we would define $MISSING as 295 -# MISSING="\${SHELL} $am_aux_dir/missing" 296 -# This will work as long as MISSING is not called from configure, because 297 -# unfortunately $(top_srcdir) has no meaning in configure. 298 -# However there are other variables, like CC, which are often used in 299 -# configure, and could therefore not use this "fixed" $ac_aux_dir. 300 -# 301 -# Another solution, used here, is to always expand $ac_aux_dir to an 302 -# absolute PATH. The drawback is that using absolute paths prevent a 303 -# configured tree to be moved without reconfiguration. 304 - 305 -AC_DEFUN([AM_AUX_DIR_EXPAND], 306 -[dnl Rely on autoconf to set up CDPATH properly. 307 -AC_PREREQ([2.50])dnl 308 -# expand $ac_aux_dir to an absolute path 309 -am_aux_dir=`cd $ac_aux_dir && pwd` 310 -]) 311 - 312 -# AM_CONDITIONAL -*- Autoconf -*- 313 - 314 -# Copyright (C) 1997-2013 Free Software Foundation, Inc. 315 -# 316 -# This file is free software; the Free Software Foundation 317 -# gives unlimited permission to copy and/or distribute it, 318 -# with or without modifications, as long as this notice is preserved. 319 - 320 -# AM_CONDITIONAL(NAME, SHELL-CONDITION) 321 -# ------------------------------------- 322 -# Define a conditional. 323 -AC_DEFUN([AM_CONDITIONAL], 324 -[AC_PREREQ([2.52])dnl 325 - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], 326 - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl 327 -AC_SUBST([$1_TRUE])dnl 328 -AC_SUBST([$1_FALSE])dnl 329 -_AM_SUBST_NOTMAKE([$1_TRUE])dnl 330 -_AM_SUBST_NOTMAKE([$1_FALSE])dnl 331 -m4_define([_AM_COND_VALUE_$1], [$2])dnl 332 -if $2; then 333 - $1_TRUE= 334 - $1_FALSE='#' 335 -else 336 - $1_TRUE='#' 337 - $1_FALSE= 338 -fi 339 -AC_CONFIG_COMMANDS_PRE( 340 -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then 341 - AC_MSG_ERROR([[conditional "$1" was never defined. 342 -Usually this means the macro was only invoked conditionally.]]) 343 -fi])]) 344 - 345 -# Copyright (C) 1999-2013 Free Software Foundation, Inc. 346 -# 347 -# This file is free software; the Free Software Foundation 348 -# gives unlimited permission to copy and/or distribute it, 349 -# with or without modifications, as long as this notice is preserved. 350 - 351 - 352 -# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be 353 -# written in clear, in which case automake, when reading aclocal.m4, 354 -# will think it sees a *use*, and therefore will trigger all it's 355 -# C support machinery. Also note that it means that autoscan, seeing 356 -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... 357 - 358 - 359 -# _AM_DEPENDENCIES(NAME) 360 -# ---------------------- 361 -# See how the compiler implements dependency checking. 362 -# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". 363 -# We try a few techniques and use that to set a single cache variable. 364 -# 365 -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was 366 -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular 367 -# dependency, and given that the user is not expected to run this macro, 368 -# just rely on AC_PROG_CC. 369 -AC_DEFUN([_AM_DEPENDENCIES], 370 -[AC_REQUIRE([AM_SET_DEPDIR])dnl 371 -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl 372 -AC_REQUIRE([AM_MAKE_INCLUDE])dnl 373 -AC_REQUIRE([AM_DEP_TRACK])dnl 374 - 375 -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], 376 - [$1], [CXX], [depcc="$CXX" am_compiler_list=], 377 - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], 378 - [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], 379 - [$1], [UPC], [depcc="$UPC" am_compiler_list=], 380 - [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], 381 - [depcc="$$1" am_compiler_list=]) 382 - 383 -AC_CACHE_CHECK([dependency style of $depcc], 384 - [am_cv_$1_dependencies_compiler_type], 385 -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then 386 - # We make a subdir and do the tests there. Otherwise we can end up 387 - # making bogus files that we don't know about and never remove. For 388 - # instance it was reported that on HP-UX the gcc test will end up 389 - # making a dummy file named 'D' -- because '-MD' means "put the output 390 - # in D". 391 - rm -rf conftest.dir 392 - mkdir conftest.dir 393 - # Copy depcomp to subdir because otherwise we won't find it if we're 394 - # using a relative directory. 395 - cp "$am_depcomp" conftest.dir 396 - cd conftest.dir 397 - # We will build objects and dependencies in a subdirectory because 398 - # it helps to detect inapplicable dependency modes. For instance 399 - # both Tru64's cc and ICC support -MD to output dependencies as a 400 - # side effect of compilation, but ICC will put the dependencies in 401 - # the current directory while Tru64 will put them in the object 402 - # directory. 403 - mkdir sub 404 - 405 - am_cv_$1_dependencies_compiler_type=none 406 - if test "$am_compiler_list" = ""; then 407 - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` 408 - fi 409 - am__universal=false 410 - m4_case([$1], [CC], 411 - [case " $depcc " in #( 412 - *\ -arch\ *\ -arch\ *) am__universal=true ;; 413 - esac], 414 - [CXX], 415 - [case " $depcc " in #( 416 - *\ -arch\ *\ -arch\ *) am__universal=true ;; 417 - esac]) 418 - 419 - for depmode in $am_compiler_list; do 420 - # Setup a source with many dependencies, because some compilers 421 - # like to wrap large dependency lists on column 80 (with \), and 422 - # we should not choose a depcomp mode which is confused by this. 423 - # 424 - # We need to recreate these files for each test, as the compiler may 425 - # overwrite some of them when testing with obscure command lines. 426 - # This happens at least with the AIX C compiler. 427 - : > sub/conftest.c 428 - for i in 1 2 3 4 5 6; do 429 - echo '#include "conftst'$i'.h"' >> sub/conftest.c 430 - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with 431 - # Solaris 10 /bin/sh. 432 - echo '/* dummy */' > sub/conftst$i.h 433 - done 434 - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf 435 - 436 - # We check with '-c' and '-o' for the sake of the "dashmstdout" 437 - # mode. It turns out that the SunPro C++ compiler does not properly 438 - # handle '-M -o', and we need to detect this. Also, some Intel 439 - # versions had trouble with output in subdirs. 440 - am__obj=sub/conftest.${OBJEXT-o} 441 - am__minus_obj="-o $am__obj" 442 - case $depmode in 443 - gcc) 444 - # This depmode causes a compiler race in universal mode. 445 - test "$am__universal" = false || continue 446 - ;; 447 - nosideeffect) 448 - # After this tag, mechanisms are not by side-effect, so they'll 449 - # only be used when explicitly requested. 450 - if test "x$enable_dependency_tracking" = xyes; then 451 - continue 452 - else 453 - break 454 - fi 455 - ;; 456 - msvc7 | msvc7msys | msvisualcpp | msvcmsys) 457 - # This compiler won't grok '-c -o', but also, the minuso test has 458 - # not run yet. These depmodes are late enough in the game, and 459 - # so weak that their functioning should not be impacted. 460 - am__obj=conftest.${OBJEXT-o} 461 - am__minus_obj= 462 - ;; 463 - none) break ;; 464 - esac 465 - if depmode=$depmode \ 466 - source=sub/conftest.c object=$am__obj \ 467 - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ 468 - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ 469 - >/dev/null 2>conftest.err && 470 - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && 471 - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && 472 - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && 473 - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then 474 - # icc doesn't choke on unknown options, it will just issue warnings 475 - # or remarks (even with -Werror). So we grep stderr for any message 476 - # that says an option was ignored or not supported. 477 - # When given -MP, icc 7.0 and 7.1 complain thusly: 478 - # icc: Command line warning: ignoring option '-M'; no argument required 479 - # The diagnosis changed in icc 8.0: 480 - # icc: Command line remark: option '-MP' not supported 481 - if (grep 'ignoring option' conftest.err || 482 - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else 483 - am_cv_$1_dependencies_compiler_type=$depmode 484 - break 485 - fi 486 - fi 487 - done 488 - 489 - cd .. 490 - rm -rf conftest.dir 491 -else 492 - am_cv_$1_dependencies_compiler_type=none 493 -fi 494 -]) 495 -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) 496 -AM_CONDITIONAL([am__fastdep$1], [ 497 - test "x$enable_dependency_tracking" != xno \ 498 - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) 499 -]) 500 - 501 - 502 -# AM_SET_DEPDIR 503 -# ------------- 504 -# Choose a directory name for dependency files. 505 -# This macro is AC_REQUIREd in _AM_DEPENDENCIES. 506 -AC_DEFUN([AM_SET_DEPDIR], 507 -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl 508 -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl 509 -]) 510 - 511 - 512 -# AM_DEP_TRACK 513 -# ------------ 514 -AC_DEFUN([AM_DEP_TRACK], 515 -[AC_ARG_ENABLE([dependency-tracking], [dnl 516 -AS_HELP_STRING( 517 - [--enable-dependency-tracking], 518 - [do not reject slow dependency extractors]) 519 -AS_HELP_STRING( 520 - [--disable-dependency-tracking], 521 - [speeds up one-time build])]) 522 -if test "x$enable_dependency_tracking" != xno; then 523 - am_depcomp="$ac_aux_dir/depcomp" 524 - AMDEPBACKSLASH='\' 525 - am__nodep='_no' 526 -fi 527 -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) 528 -AC_SUBST([AMDEPBACKSLASH])dnl 529 -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl 530 -AC_SUBST([am__nodep])dnl 531 -_AM_SUBST_NOTMAKE([am__nodep])dnl 532 -]) 533 - 534 -# Generate code to set up dependency tracking. -*- Autoconf -*- 535 - 536 -# Copyright (C) 1999-2013 Free Software Foundation, Inc. 537 -# 538 -# This file is free software; the Free Software Foundation 539 -# gives unlimited permission to copy and/or distribute it, 540 -# with or without modifications, as long as this notice is preserved. 541 - 542 - 543 -# _AM_OUTPUT_DEPENDENCY_COMMANDS 544 -# ------------------------------ 545 -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], 546 -[{ 547 - # Older Autoconf quotes --file arguments for eval, but not when files 548 - # are listed without --file. Let's play safe and only enable the eval 549 - # if we detect the quoting. 550 - case $CONFIG_FILES in 551 - *\'*) eval set x "$CONFIG_FILES" ;; 552 - *) set x $CONFIG_FILES ;; 553 - esac 554 - shift 555 - for mf 556 - do 557 - # Strip MF so we end up with the name of the file. 558 - mf=`echo "$mf" | sed -e 's/:.*$//'` 559 - # Check whether this is an Automake generated Makefile or not. 560 - # We used to match only the files named 'Makefile.in', but 561 - # some people rename them; so instead we look at the file content. 562 - # Grep'ing the first line is not enough: some people post-process 563 - # each Makefile.in and add a new line on top of each file to say so. 564 - # Grep'ing the whole file is not good either: AIX grep has a line 565 - # limit of 2048, but all sed's we know have understand at least 4000. 566 - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then 567 - dirpart=`AS_DIRNAME("$mf")` 568 - else 569 - continue 570 - fi 571 - # Extract the definition of DEPDIR, am__include, and am__quote 572 - # from the Makefile without running 'make'. 573 - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` 574 - test -z "$DEPDIR" && continue 575 - am__include=`sed -n 's/^am__include = //p' < "$mf"` 576 - test -z "$am__include" && continue 577 - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` 578 - # Find all dependency output files, they are included files with 579 - # $(DEPDIR) in their names. We invoke sed twice because it is the 580 - # simplest approach to changing $(DEPDIR) to its actual value in the 581 - # expansion. 582 - for file in `sed -n " 583 - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ 584 - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do 585 - # Make sure the directory exists. 586 - test -f "$dirpart/$file" && continue 587 - fdir=`AS_DIRNAME(["$file"])` 588 - AS_MKDIR_P([$dirpart/$fdir]) 589 - # echo "creating $dirpart/$file" 590 - echo '# dummy' > "$dirpart/$file" 591 - done 592 - done 593 -} 594 -])# _AM_OUTPUT_DEPENDENCY_COMMANDS 595 - 596 - 597 -# AM_OUTPUT_DEPENDENCY_COMMANDS 598 -# ----------------------------- 599 -# This macro should only be invoked once -- use via AC_REQUIRE. 600 -# 601 -# This code is only required when automatic dependency tracking 602 -# is enabled. FIXME. This creates each '.P' file that we will 603 -# need in order to bootstrap the dependency handling code. 604 -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], 605 -[AC_CONFIG_COMMANDS([depfiles], 606 - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], 607 - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) 608 -]) 609 - 610 -# Do all the work for Automake. -*- Autoconf -*- 611 - 612 -# Copyright (C) 1996-2013 Free Software Foundation, Inc. 613 -# 614 -# This file is free software; the Free Software Foundation 615 -# gives unlimited permission to copy and/or distribute it, 616 -# with or without modifications, as long as this notice is preserved. 617 - 618 -# This macro actually does too much. Some checks are only needed if 619 -# your package does certain things. But this isn't really a big deal. 620 - 621 -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) 622 -# AM_INIT_AUTOMAKE([OPTIONS]) 623 -# ----------------------------------------------- 624 -# The call with PACKAGE and VERSION arguments is the old style 625 -# call (pre autoconf-2.50), which is being phased out. PACKAGE 626 -# and VERSION should now be passed to AC_INIT and removed from 627 -# the call to AM_INIT_AUTOMAKE. 628 -# We support both call styles for the transition. After 629 -# the next Automake release, Autoconf can make the AC_INIT 630 -# arguments mandatory, and then we can depend on a new Autoconf 631 -# release and drop the old call support. 632 -AC_DEFUN([AM_INIT_AUTOMAKE], 633 -[AC_PREREQ([2.65])dnl 634 -dnl Autoconf wants to disallow AM_ names. We explicitly allow 635 -dnl the ones we care about. 636 -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl 637 -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl 638 -AC_REQUIRE([AC_PROG_INSTALL])dnl 639 -if test "`cd $srcdir && pwd`" != "`pwd`"; then 640 - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output 641 - # is not polluted with repeated "-I." 642 - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl 643 - # test to see if srcdir already configured 644 - if test -f $srcdir/config.status; then 645 - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) 646 - fi 647 -fi 648 - 649 -# test whether we have cygpath 650 -if test -z "$CYGPATH_W"; then 651 - if (cygpath --version) >/dev/null 2>/dev/null; then 652 - CYGPATH_W='cygpath -w' 653 - else 654 - CYGPATH_W=echo 655 - fi 656 -fi 657 -AC_SUBST([CYGPATH_W]) 658 - 659 -# Define the identity of the package. 660 -dnl Distinguish between old-style and new-style calls. 661 -m4_ifval([$2], 662 -[AC_DIAGNOSE([obsolete], 663 - [$0: two- and three-arguments forms are deprecated.]) 664 -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl 665 - AC_SUBST([PACKAGE], [$1])dnl 666 - AC_SUBST([VERSION], [$2])], 667 -[_AM_SET_OPTIONS([$1])dnl 668 -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. 669 -m4_if( 670 - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), 671 - [ok:ok],, 672 - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl 673 - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl 674 - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl 675 - 676 -_AM_IF_OPTION([no-define],, 677 -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) 678 - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl 679 - 680 -# Some tools Automake needs. 681 -AC_REQUIRE([AM_SANITY_CHECK])dnl 682 -AC_REQUIRE([AC_ARG_PROGRAM])dnl 683 -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) 684 -AM_MISSING_PROG([AUTOCONF], [autoconf]) 685 -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) 686 -AM_MISSING_PROG([AUTOHEADER], [autoheader]) 687 -AM_MISSING_PROG([MAKEINFO], [makeinfo]) 688 -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl 689 -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl 690 -AC_REQUIRE([AC_PROG_MKDIR_P])dnl 691 -# For better backward compatibility. To be removed once Automake 1.9.x 692 -# dies out for good. For more background, see: 693 -# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> 694 -# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> 695 -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) 696 -# We need awk for the "check" target. The system "awk" is bad on 697 -# some platforms. 698 -AC_REQUIRE([AC_PROG_AWK])dnl 699 -AC_REQUIRE([AC_PROG_MAKE_SET])dnl 700 -AC_REQUIRE([AM_SET_LEADING_DOT])dnl 701 -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], 702 - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], 703 - [_AM_PROG_TAR([v7])])]) 704 -_AM_IF_OPTION([no-dependencies],, 705 -[AC_PROVIDE_IFELSE([AC_PROG_CC], 706 - [_AM_DEPENDENCIES([CC])], 707 - [m4_define([AC_PROG_CC], 708 - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl 709 -AC_PROVIDE_IFELSE([AC_PROG_CXX], 710 - [_AM_DEPENDENCIES([CXX])], 711 - [m4_define([AC_PROG_CXX], 712 - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl 713 -AC_PROVIDE_IFELSE([AC_PROG_OBJC], 714 - [_AM_DEPENDENCIES([OBJC])], 715 - [m4_define([AC_PROG_OBJC], 716 - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl 717 -AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], 718 - [_AM_DEPENDENCIES([OBJCXX])], 719 - [m4_define([AC_PROG_OBJCXX], 720 - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl 721 -]) 722 -AC_REQUIRE([AM_SILENT_RULES])dnl 723 -dnl The testsuite driver may need to know about EXEEXT, so add the 724 -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This 725 -dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. 726 -AC_CONFIG_COMMANDS_PRE(dnl 727 -[m4_provide_if([_AM_COMPILER_EXEEXT], 728 - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl 729 -]) 730 - 731 -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not 732 -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further 733 -dnl mangled by Autoconf and run in a shell conditional statement. 734 -m4_define([_AC_COMPILER_EXEEXT], 735 -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) 736 - 737 - 738 -# When config.status generates a header, we must update the stamp-h file. 739 -# This file resides in the same directory as the config header 740 -# that is generated. The stamp files are numbered to have different names. 741 - 742 -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the 743 -# loop where config.status creates the headers, so we can generate 744 -# our stamp files there. 745 -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], 746 -[# Compute $1's index in $config_headers. 747 -_am_arg=$1 748 -_am_stamp_count=1 749 -for _am_header in $config_headers :; do 750 - case $_am_header in 751 - $_am_arg | $_am_arg:* ) 752 - break ;; 753 - * ) 754 - _am_stamp_count=`expr $_am_stamp_count + 1` ;; 755 - esac 756 -done 757 -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) 758 - 759 -# Copyright (C) 2001-2013 Free Software Foundation, Inc. 760 -# 761 -# This file is free software; the Free Software Foundation 762 -# gives unlimited permission to copy and/or distribute it, 763 -# with or without modifications, as long as this notice is preserved. 764 - 765 -# AM_PROG_INSTALL_SH 766 -# ------------------ 767 -# Define $install_sh. 768 -AC_DEFUN([AM_PROG_INSTALL_SH], 769 -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl 770 -if test x"${install_sh}" != xset; then 771 - case $am_aux_dir in 772 - *\ * | *\ *) 773 - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; 774 - *) 775 - install_sh="\${SHELL} $am_aux_dir/install-sh" 776 - esac 777 -fi 778 -AC_SUBST([install_sh])]) 779 - 780 -# Copyright (C) 2003-2013 Free Software Foundation, Inc. 781 -# 782 -# This file is free software; the Free Software Foundation 783 -# gives unlimited permission to copy and/or distribute it, 784 -# with or without modifications, as long as this notice is preserved. 785 - 786 -# Check whether the underlying file-system supports filenames 787 -# with a leading dot. For instance MS-DOS doesn't. 788 -AC_DEFUN([AM_SET_LEADING_DOT], 789 -[rm -rf .tst 2>/dev/null 790 -mkdir .tst 2>/dev/null 791 -if test -d .tst; then 792 - am__leading_dot=. 793 -else 794 - am__leading_dot=_ 795 -fi 796 -rmdir .tst 2>/dev/null 797 -AC_SUBST([am__leading_dot])]) 798 - 799 -# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- 800 -# From Jim Meyering 801 - 802 -# Copyright (C) 1996-2013 Free Software Foundation, Inc. 803 -# 804 -# This file is free software; the Free Software Foundation 805 -# gives unlimited permission to copy and/or distribute it, 806 -# with or without modifications, as long as this notice is preserved. 807 - 808 -# AM_MAINTAINER_MODE([DEFAULT-MODE]) 809 -# ---------------------------------- 810 -# Control maintainer-specific portions of Makefiles. 811 -# Default is to disable them, unless 'enable' is passed literally. 812 -# For symmetry, 'disable' may be passed as well. Anyway, the user 813 -# can override the default with the --enable/--disable switch. 814 -AC_DEFUN([AM_MAINTAINER_MODE], 815 -[m4_case(m4_default([$1], [disable]), 816 - [enable], [m4_define([am_maintainer_other], [disable])], 817 - [disable], [m4_define([am_maintainer_other], [enable])], 818 - [m4_define([am_maintainer_other], [enable]) 819 - m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) 820 -AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) 821 - dnl maintainer-mode's default is 'disable' unless 'enable' is passed 822 - AC_ARG_ENABLE([maintainer-mode], 823 - [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], 824 - am_maintainer_other[ make rules and dependencies not useful 825 - (and sometimes confusing) to the casual installer])], 826 - [USE_MAINTAINER_MODE=$enableval], 827 - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) 828 - AC_MSG_RESULT([$USE_MAINTAINER_MODE]) 829 - AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) 830 - MAINT=$MAINTAINER_MODE_TRUE 831 - AC_SUBST([MAINT])dnl 832 -] 833 -) 834 - 835 -# Check to see how 'make' treats includes. -*- Autoconf -*- 836 - 837 -# Copyright (C) 2001-2013 Free Software Foundation, Inc. 838 -# 839 -# This file is free software; the Free Software Foundation 840 -# gives unlimited permission to copy and/or distribute it, 841 -# with or without modifications, as long as this notice is preserved. 842 - 843 -# AM_MAKE_INCLUDE() 844 -# ----------------- 845 -# Check to see how make treats includes. 846 -AC_DEFUN([AM_MAKE_INCLUDE], 847 -[am_make=${MAKE-make} 848 -cat > confinc << 'END' 849 -am__doit: 850 - @echo this is the am__doit target 851 -.PHONY: am__doit 852 -END 853 -# If we don't find an include directive, just comment out the code. 854 -AC_MSG_CHECKING([for style of include used by $am_make]) 855 -am__include="#" 856 -am__quote= 857 -_am_result=none 858 -# First try GNU make style include. 859 -echo "include confinc" > confmf 860 -# Ignore all kinds of additional output from 'make'. 861 -case `$am_make -s -f confmf 2> /dev/null` in #( 862 -*the\ am__doit\ target*) 863 - am__include=include 864 - am__quote= 865 - _am_result=GNU 866 - ;; 867 -esac 868 -# Now try BSD make style include. 869 -if test "$am__include" = "#"; then 870 - echo '.include "confinc"' > confmf 871 - case `$am_make -s -f confmf 2> /dev/null` in #( 872 - *the\ am__doit\ target*) 873 - am__include=.include 874 - am__quote="\"" 875 - _am_result=BSD 876 - ;; 877 - esac 878 -fi 879 -AC_SUBST([am__include]) 880 -AC_SUBST([am__quote]) 881 -AC_MSG_RESULT([$_am_result]) 882 -rm -f confinc confmf 883 -]) 884 - 885 -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- 886 - 887 -# Copyright (C) 1997-2013 Free Software Foundation, Inc. 888 -# 889 -# This file is free software; the Free Software Foundation 890 -# gives unlimited permission to copy and/or distribute it, 891 -# with or without modifications, as long as this notice is preserved. 892 - 893 -# AM_MISSING_PROG(NAME, PROGRAM) 894 -# ------------------------------ 895 -AC_DEFUN([AM_MISSING_PROG], 896 -[AC_REQUIRE([AM_MISSING_HAS_RUN]) 897 -$1=${$1-"${am_missing_run}$2"} 898 -AC_SUBST($1)]) 899 - 900 -# AM_MISSING_HAS_RUN 901 -# ------------------ 902 -# Define MISSING if not defined so far and test if it is modern enough. 903 -# If it is, set am_missing_run to use it, otherwise, to nothing. 904 -AC_DEFUN([AM_MISSING_HAS_RUN], 905 -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl 906 -AC_REQUIRE_AUX_FILE([missing])dnl 907 -if test x"${MISSING+set}" != xset; then 908 - case $am_aux_dir in 909 - *\ * | *\ *) 910 - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; 911 - *) 912 - MISSING="\${SHELL} $am_aux_dir/missing" ;; 913 - esac 914 -fi 915 -# Use eval to expand $SHELL 916 -if eval "$MISSING --is-lightweight"; then 917 - am_missing_run="$MISSING " 918 -else 919 - am_missing_run= 920 - AC_MSG_WARN(['missing' script is too old or missing]) 921 -fi 922 -]) 923 - 924 -# Helper functions for option handling. -*- Autoconf -*- 925 - 926 -# Copyright (C) 2001-2013 Free Software Foundation, Inc. 927 -# 928 -# This file is free software; the Free Software Foundation 929 -# gives unlimited permission to copy and/or distribute it, 930 -# with or without modifications, as long as this notice is preserved. 931 - 932 -# _AM_MANGLE_OPTION(NAME) 933 -# ----------------------- 934 -AC_DEFUN([_AM_MANGLE_OPTION], 935 -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) 936 - 937 -# _AM_SET_OPTION(NAME) 938 -# -------------------- 939 -# Set option NAME. Presently that only means defining a flag for this option. 940 -AC_DEFUN([_AM_SET_OPTION], 941 -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) 942 - 943 -# _AM_SET_OPTIONS(OPTIONS) 944 -# ------------------------ 945 -# OPTIONS is a space-separated list of Automake options. 946 -AC_DEFUN([_AM_SET_OPTIONS], 947 -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) 948 - 949 -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) 950 -# ------------------------------------------- 951 -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. 952 -AC_DEFUN([_AM_IF_OPTION], 953 -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) 954 - 955 -# Check to make sure that the build environment is sane. -*- Autoconf -*- 956 - 957 -# Copyright (C) 1996-2013 Free Software Foundation, Inc. 958 -# 959 -# This file is free software; the Free Software Foundation 960 -# gives unlimited permission to copy and/or distribute it, 961 -# with or without modifications, as long as this notice is preserved. 962 - 963 -# AM_SANITY_CHECK 964 -# --------------- 965 -AC_DEFUN([AM_SANITY_CHECK], 966 -[AC_MSG_CHECKING([whether build environment is sane]) 967 -# Reject unsafe characters in $srcdir or the absolute working directory 968 -# name. Accept space and tab only in the latter. 969 -am_lf=' 970 -' 971 -case `pwd` in 972 - *[[\\\"\#\$\&\'\`$am_lf]]*) 973 - AC_MSG_ERROR([unsafe absolute working directory name]);; 974 -esac 975 -case $srcdir in 976 - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) 977 - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; 978 -esac 979 - 980 -# Do 'set' in a subshell so we don't clobber the current shell's 981 -# arguments. Must try -L first in case configure is actually a 982 -# symlink; some systems play weird games with the mod time of symlinks 983 -# (eg FreeBSD returns the mod time of the symlink's containing 984 -# directory). 985 -if ( 986 - am_has_slept=no 987 - for am_try in 1 2; do 988 - echo "timestamp, slept: $am_has_slept" > conftest.file 989 - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` 990 - if test "$[*]" = "X"; then 991 - # -L didn't work. 992 - set X `ls -t "$srcdir/configure" conftest.file` 993 - fi 994 - if test "$[*]" != "X $srcdir/configure conftest.file" \ 995 - && test "$[*]" != "X conftest.file $srcdir/configure"; then 996 - 997 - # If neither matched, then we have a broken ls. This can happen 998 - # if, for instance, CONFIG_SHELL is bash and it inherits a 999 - # broken ls alias from the environment. This has actually 1000 - # happened. Such a system could not be considered "sane". 1001 - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken 1002 - alias in your environment]) 1003 - fi 1004 - if test "$[2]" = conftest.file || test $am_try -eq 2; then 1005 - break 1006 - fi 1007 - # Just in case. 1008 - sleep 1 1009 - am_has_slept=yes 1010 - done 1011 - test "$[2]" = conftest.file 1012 - ) 1013 -then 1014 - # Ok. 1015 - : 1016 -else 1017 - AC_MSG_ERROR([newly created file is older than distributed files! 1018 -Check your system clock]) 1019 -fi 1020 -AC_MSG_RESULT([yes]) 1021 -# If we didn't sleep, we still need to ensure time stamps of config.status and 1022 -# generated files are strictly newer. 1023 -am_sleep_pid= 1024 -if grep 'slept: no' conftest.file >/dev/null 2>&1; then 1025 - ( sleep 1 ) & 1026 - am_sleep_pid=$! 1027 -fi 1028 -AC_CONFIG_COMMANDS_PRE( 1029 - [AC_MSG_CHECKING([that generated files are newer than configure]) 1030 - if test -n "$am_sleep_pid"; then 1031 - # Hide warnings about reused PIDs. 1032 - wait $am_sleep_pid 2>/dev/null 1033 - fi 1034 - AC_MSG_RESULT([done])]) 1035 -rm -f conftest.file 1036 -]) 1037 - 1038 -# Copyright (C) 2009-2013 Free Software Foundation, Inc. 1039 -# 1040 -# This file is free software; the Free Software Foundation 1041 -# gives unlimited permission to copy and/or distribute it, 1042 -# with or without modifications, as long as this notice is preserved. 1043 - 1044 -# AM_SILENT_RULES([DEFAULT]) 1045 -# -------------------------- 1046 -# Enable less verbose build rules; with the default set to DEFAULT 1047 -# ("yes" being less verbose, "no" or empty being verbose). 1048 -AC_DEFUN([AM_SILENT_RULES], 1049 -[AC_ARG_ENABLE([silent-rules], [dnl 1050 -AS_HELP_STRING( 1051 - [--enable-silent-rules], 1052 - [less verbose build output (undo: "make V=1")]) 1053 -AS_HELP_STRING( 1054 - [--disable-silent-rules], 1055 - [verbose build output (undo: "make V=0")])dnl 1056 -]) 1057 -case $enable_silent_rules in @%:@ ((( 1058 - yes) AM_DEFAULT_VERBOSITY=0;; 1059 - no) AM_DEFAULT_VERBOSITY=1;; 1060 - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; 1061 -esac 1062 -dnl 1063 -dnl A few 'make' implementations (e.g., NonStop OS and NextStep) 1064 -dnl do not support nested variable expansions. 1065 -dnl See automake bug#9928 and bug#10237. 1066 -am_make=${MAKE-make} 1067 -AC_CACHE_CHECK([whether $am_make supports nested variables], 1068 - [am_cv_make_support_nested_variables], 1069 - [if AS_ECHO([['TRUE=$(BAR$(V)) 1070 -BAR0=false 1071 -BAR1=true 1072 -V=1 1073 -am__doit: 1074 - @$(TRUE) 1075 -.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then 1076 - am_cv_make_support_nested_variables=yes 1077 -else 1078 - am_cv_make_support_nested_variables=no 1079 -fi]) 1080 -if test $am_cv_make_support_nested_variables = yes; then 1081 - dnl Using '$V' instead of '$(V)' breaks IRIX make. 1082 - AM_V='$(V)' 1083 - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' 1084 -else 1085 - AM_V=$AM_DEFAULT_VERBOSITY 1086 - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY 1087 -fi 1088 -AC_SUBST([AM_V])dnl 1089 -AM_SUBST_NOTMAKE([AM_V])dnl 1090 -AC_SUBST([AM_DEFAULT_V])dnl 1091 -AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl 1092 -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl 1093 -AM_BACKSLASH='\' 1094 -AC_SUBST([AM_BACKSLASH])dnl 1095 -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl 1096 -]) 1097 - 1098 -# Copyright (C) 2001-2013 Free Software Foundation, Inc. 1099 -# 1100 -# This file is free software; the Free Software Foundation 1101 -# gives unlimited permission to copy and/or distribute it, 1102 -# with or without modifications, as long as this notice is preserved. 1103 - 1104 -# AM_PROG_INSTALL_STRIP 1105 -# --------------------- 1106 -# One issue with vendor 'install' (even GNU) is that you can't 1107 -# specify the program used to strip binaries. This is especially 1108 -# annoying in cross-compiling environments, where the build's strip 1109 -# is unlikely to handle the host's binaries. 1110 -# Fortunately install-sh will honor a STRIPPROG variable, so we 1111 -# always use install-sh in "make install-strip", and initialize 1112 -# STRIPPROG with the value of the STRIP variable (set by the user). 1113 -AC_DEFUN([AM_PROG_INSTALL_STRIP], 1114 -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl 1115 -# Installed binaries are usually stripped using 'strip' when the user 1116 -# run "make install-strip". However 'strip' might not be the right 1117 -# tool to use in cross-compilation environments, therefore Automake 1118 -# will honor the 'STRIP' environment variable to overrule this program. 1119 -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. 1120 -if test "$cross_compiling" != no; then 1121 - AC_CHECK_TOOL([STRIP], [strip], :) 1122 -fi 1123 -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" 1124 -AC_SUBST([INSTALL_STRIP_PROGRAM])]) 1125 - 1126 -# Copyright (C) 2006-2013 Free Software Foundation, Inc. 1127 -# 1128 -# This file is free software; the Free Software Foundation 1129 -# gives unlimited permission to copy and/or distribute it, 1130 -# with or without modifications, as long as this notice is preserved. 1131 - 1132 -# _AM_SUBST_NOTMAKE(VARIABLE) 1133 -# --------------------------- 1134 -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. 1135 -# This macro is traced by Automake. 1136 -AC_DEFUN([_AM_SUBST_NOTMAKE]) 1137 - 1138 -# AM_SUBST_NOTMAKE(VARIABLE) 1139 -# -------------------------- 1140 -# Public sister of _AM_SUBST_NOTMAKE. 1141 -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) 1142 - 1143 -# Check how to create a tarball. -*- Autoconf -*- 1144 - 1145 -# Copyright (C) 2004-2013 Free Software Foundation, Inc. 1146 -# 1147 -# This file is free software; the Free Software Foundation 1148 -# gives unlimited permission to copy and/or distribute it, 1149 -# with or without modifications, as long as this notice is preserved. 1150 - 1151 -# _AM_PROG_TAR(FORMAT) 1152 -# -------------------- 1153 -# Check how to create a tarball in format FORMAT. 1154 -# FORMAT should be one of 'v7', 'ustar', or 'pax'. 1155 -# 1156 -# Substitute a variable $(am__tar) that is a command 1157 -# writing to stdout a FORMAT-tarball containing the directory 1158 -# $tardir. 1159 -# tardir=directory && $(am__tar) > result.tar 1160 -# 1161 -# Substitute a variable $(am__untar) that extract such 1162 -# a tarball read from stdin. 1163 -# $(am__untar) < result.tar 1164 -# 1165 -AC_DEFUN([_AM_PROG_TAR], 1166 -[# Always define AMTAR for backward compatibility. Yes, it's still used 1167 -# in the wild :-( We should find a proper way to deprecate it ... 1168 -AC_SUBST([AMTAR], ['$${TAR-tar}']) 1169 - 1170 -# We'll loop over all known methods to create a tar archive until one works. 1171 -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' 1172 - 1173 -m4_if([$1], [v7], 1174 - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], 1175 - 1176 - [m4_case([$1], 1177 - [ustar], 1178 - [# The POSIX 1988 'ustar' format is defined with fixed-size fields. 1179 - # There is notably a 21 bits limit for the UID and the GID. In fact, 1180 - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 1181 - # and bug#13588). 1182 - am_max_uid=2097151 # 2^21 - 1 1183 - am_max_gid=$am_max_uid 1184 - # The $UID and $GID variables are not portable, so we need to resort 1185 - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls 1186 - # below are definitely unexpected, so allow the users to see them 1187 - # (that is, avoid stderr redirection). 1188 - am_uid=`id -u || echo unknown` 1189 - am_gid=`id -g || echo unknown` 1190 - AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) 1191 - if test $am_uid -le $am_max_uid; then 1192 - AC_MSG_RESULT([yes]) 1193 - else 1194 - AC_MSG_RESULT([no]) 1195 - _am_tools=none 1196 - fi 1197 - AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) 1198 - if test $am_gid -le $am_max_gid; then 1199 - AC_MSG_RESULT([yes]) 1200 - else 1201 - AC_MSG_RESULT([no]) 1202 - _am_tools=none 1203 - fi], 1204 - 1205 - [pax], 1206 - [], 1207 - 1208 - [m4_fatal([Unknown tar format])]) 1209 - 1210 - AC_MSG_CHECKING([how to create a $1 tar archive]) 1211 - 1212 - # Go ahead even if we have the value already cached. We do so because we 1213 - # need to set the values for the 'am__tar' and 'am__untar' variables. 1214 - _am_tools=${am_cv_prog_tar_$1-$_am_tools} 1215 - 1216 - for _am_tool in $_am_tools; do 1217 - case $_am_tool in 1218 - gnutar) 1219 - for _am_tar in tar gnutar gtar; do 1220 - AM_RUN_LOG([$_am_tar --version]) && break 1221 - done 1222 - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' 1223 - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' 1224 - am__untar="$_am_tar -xf -" 1225 - ;; 1226 - plaintar) 1227 - # Must skip GNU tar: if it does not support --format= it doesn't create 1228 - # ustar tarball either. 1229 - (tar --version) >/dev/null 2>&1 && continue 1230 - am__tar='tar chf - "$$tardir"' 1231 - am__tar_='tar chf - "$tardir"' 1232 - am__untar='tar xf -' 1233 - ;; 1234 - pax) 1235 - am__tar='pax -L -x $1 -w "$$tardir"' 1236 - am__tar_='pax -L -x $1 -w "$tardir"' 1237 - am__untar='pax -r' 1238 - ;; 1239 - cpio) 1240 - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' 1241 - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' 1242 - am__untar='cpio -i -H $1 -d' 1243 - ;; 1244 - none) 1245 - am__tar=false 1246 - am__tar_=false 1247 - am__untar=false 1248 - ;; 1249 - esac 1250 - 1251 - # If the value was cached, stop now. We just wanted to have am__tar 1252 - # and am__untar set. 1253 - test -n "${am_cv_prog_tar_$1}" && break 1254 - 1255 - # tar/untar a dummy directory, and stop if the command works. 1256 - rm -rf conftest.dir 1257 - mkdir conftest.dir 1258 - echo GrepMe > conftest.dir/file 1259 - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) 1260 - rm -rf conftest.dir 1261 - if test -s conftest.tar; then 1262 - AM_RUN_LOG([$am__untar <conftest.tar]) 1263 - AM_RUN_LOG([cat conftest.dir/file]) 1264 - grep GrepMe conftest.dir/file >/dev/null 2>&1 && break 1265 - fi 1266 - done 1267 - rm -rf conftest.dir 1268 - 1269 - AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) 1270 - AC_MSG_RESULT([$am_cv_prog_tar_$1])]) 1271 - 1272 -AC_SUBST([am__tar]) 1273 -AC_SUBST([am__untar]) 1274 -]) # _AM_PROG_TAR 1275 - 1276 -m4_include([m4/libtool.m4]) 1277 -m4_include([m4/ltoptions.m4]) 1278 -m4_include([m4/ltsugar.m4]) 1279 -m4_include([m4/ltversion.m4]) 1280 -m4_include([m4/lt~obsolete.m4])
Deleted config.guess.
1 -#! /bin/sh 2 -# Attempt to guess a canonical system name. 3 -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4 -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 5 -# 2011, 2012 Free Software Foundation, Inc. 6 - 7 -timestamp='2012-02-10' 8 - 9 -# This file is free software; you can redistribute it and/or modify it 10 -# under the terms of the GNU General Public License as published by 11 -# the Free Software Foundation; either version 2 of the License, or 12 -# (at your option) any later version. 13 -# 14 -# This program is distributed in the hope that it will be useful, but 15 -# WITHOUT ANY WARRANTY; without even the implied warranty of 16 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 -# General Public License for more details. 18 -# 19 -# You should have received a copy of the GNU General Public License 20 -# along with this program; if not, see <http://www.gnu.org/licenses/>. 21 -# 22 -# As a special exception to the GNU General Public License, if you 23 -# distribute this file as part of a program that contains a 24 -# configuration script generated by Autoconf, you may include it under 25 -# the same distribution terms that you use for the rest of that program. 26 - 27 - 28 -# Originally written by Per Bothner. Please send patches (context 29 -# diff format) to <config-patches@gnu.org> and include a ChangeLog 30 -# entry. 31 -# 32 -# This script attempts to guess a canonical system name similar to 33 -# config.sub. If it succeeds, it prints the system name on stdout, and 34 -# exits with 0. Otherwise, it exits with 1. 35 -# 36 -# You can get the latest version of this script from: 37 -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD 38 - 39 -me=`echo "$0" | sed -e 's,.*/,,'` 40 - 41 -usage="\ 42 -Usage: $0 [OPTION] 43 - 44 -Output the configuration name of the system \`$me' is run on. 45 - 46 -Operation modes: 47 - -h, --help print this help, then exit 48 - -t, --time-stamp print date of last modification, then exit 49 - -v, --version print version number, then exit 50 - 51 -Report bugs and patches to <config-patches@gnu.org>." 52 - 53 -version="\ 54 -GNU config.guess ($timestamp) 55 - 56 -Originally written by Per Bothner. 57 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 58 -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 59 -Free Software Foundation, Inc. 60 - 61 -This is free software; see the source for copying conditions. There is NO 62 -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 63 - 64 -help=" 65 -Try \`$me --help' for more information." 66 - 67 -# Parse command line 68 -while test $# -gt 0 ; do 69 - case $1 in 70 - --time-stamp | --time* | -t ) 71 - echo "$timestamp" ; exit ;; 72 - --version | -v ) 73 - echo "$version" ; exit ;; 74 - --help | --h* | -h ) 75 - echo "$usage"; exit ;; 76 - -- ) # Stop option processing 77 - shift; break ;; 78 - - ) # Use stdin as input. 79 - break ;; 80 - -* ) 81 - echo "$me: invalid option $1$help" >&2 82 - exit 1 ;; 83 - * ) 84 - break ;; 85 - esac 86 -done 87 - 88 -if test $# != 0; then 89 - echo "$me: too many arguments$help" >&2 90 - exit 1 91 -fi 92 - 93 -trap 'exit 1' 1 2 15 94 - 95 -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a 96 -# compiler to aid in system detection is discouraged as it requires 97 -# temporary files to be created and, as you can see below, it is a 98 -# headache to deal with in a portable fashion. 99 - 100 -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still 101 -# use `HOST_CC' if defined, but it is deprecated. 102 - 103 -# Portable tmp directory creation inspired by the Autoconf team. 104 - 105 -set_cc_for_build=' 106 -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; 107 -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; 108 -: ${TMPDIR=/tmp} ; 109 - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || 110 - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || 111 - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || 112 - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; 113 -dummy=$tmp/dummy ; 114 -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; 115 -case $CC_FOR_BUILD,$HOST_CC,$CC in 116 - ,,) echo "int x;" > $dummy.c ; 117 - for c in cc gcc c89 c99 ; do 118 - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then 119 - CC_FOR_BUILD="$c"; break ; 120 - fi ; 121 - done ; 122 - if test x"$CC_FOR_BUILD" = x ; then 123 - CC_FOR_BUILD=no_compiler_found ; 124 - fi 125 - ;; 126 - ,,*) CC_FOR_BUILD=$CC ;; 127 - ,*,*) CC_FOR_BUILD=$HOST_CC ;; 128 -esac ; set_cc_for_build= ;' 129 - 130 -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. 131 -# (ghazi@noc.rutgers.edu 1994-08-24) 132 -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then 133 - PATH=$PATH:/.attbin ; export PATH 134 -fi 135 - 136 -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown 137 -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown 138 -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown 139 -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown 140 - 141 -# Note: order is significant - the case branches are not exclusive. 142 - 143 -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in 144 - *:NetBSD:*:*) 145 - # NetBSD (nbsd) targets should (where applicable) match one or 146 - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, 147 - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently 148 - # switched to ELF, *-*-netbsd* would select the old 149 - # object file format. This provides both forward 150 - # compatibility and a consistent mechanism for selecting the 151 - # object file format. 152 - # 153 - # Note: NetBSD doesn't particularly care about the vendor 154 - # portion of the name. We always set it to "unknown". 155 - sysctl="sysctl -n hw.machine_arch" 156 - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ 157 - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` 158 - case "${UNAME_MACHINE_ARCH}" in 159 - armeb) machine=armeb-unknown ;; 160 - arm*) machine=arm-unknown ;; 161 - sh3el) machine=shl-unknown ;; 162 - sh3eb) machine=sh-unknown ;; 163 - sh5el) machine=sh5le-unknown ;; 164 - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; 165 - esac 166 - # The Operating System including object format, if it has switched 167 - # to ELF recently, or will in the future. 168 - case "${UNAME_MACHINE_ARCH}" in 169 - arm*|i386|m68k|ns32k|sh3*|sparc|vax) 170 - eval $set_cc_for_build 171 - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ 172 - | grep -q __ELF__ 173 - then 174 - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). 175 - # Return netbsd for either. FIX? 176 - os=netbsd 177 - else 178 - os=netbsdelf 179 - fi 180 - ;; 181 - *) 182 - os=netbsd 183 - ;; 184 - esac 185 - # The OS release 186 - # Debian GNU/NetBSD machines have a different userland, and 187 - # thus, need a distinct triplet. However, they do not need 188 - # kernel version information, so it can be replaced with a 189 - # suitable tag, in the style of linux-gnu. 190 - case "${UNAME_VERSION}" in 191 - Debian*) 192 - release='-gnu' 193 - ;; 194 - *) 195 - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` 196 - ;; 197 - esac 198 - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: 199 - # contains redundant information, the shorter form: 200 - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. 201 - echo "${machine}-${os}${release}" 202 - exit ;; 203 - *:OpenBSD:*:*) 204 - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` 205 - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} 206 - exit ;; 207 - *:ekkoBSD:*:*) 208 - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} 209 - exit ;; 210 - *:SolidBSD:*:*) 211 - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} 212 - exit ;; 213 - macppc:MirBSD:*:*) 214 - echo powerpc-unknown-mirbsd${UNAME_RELEASE} 215 - exit ;; 216 - *:MirBSD:*:*) 217 - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} 218 - exit ;; 219 - alpha:OSF1:*:*) 220 - case $UNAME_RELEASE in 221 - *4.0) 222 - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` 223 - ;; 224 - *5.*) 225 - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` 226 - ;; 227 - esac 228 - # According to Compaq, /usr/sbin/psrinfo has been available on 229 - # OSF/1 and Tru64 systems produced since 1995. I hope that 230 - # covers most systems running today. This code pipes the CPU 231 - # types through head -n 1, so we only detect the type of CPU 0. 232 - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` 233 - case "$ALPHA_CPU_TYPE" in 234 - "EV4 (21064)") 235 - UNAME_MACHINE="alpha" ;; 236 - "EV4.5 (21064)") 237 - UNAME_MACHINE="alpha" ;; 238 - "LCA4 (21066/21068)") 239 - UNAME_MACHINE="alpha" ;; 240 - "EV5 (21164)") 241 - UNAME_MACHINE="alphaev5" ;; 242 - "EV5.6 (21164A)") 243 - UNAME_MACHINE="alphaev56" ;; 244 - "EV5.6 (21164PC)") 245 - UNAME_MACHINE="alphapca56" ;; 246 - "EV5.7 (21164PC)") 247 - UNAME_MACHINE="alphapca57" ;; 248 - "EV6 (21264)") 249 - UNAME_MACHINE="alphaev6" ;; 250 - "EV6.7 (21264A)") 251 - UNAME_MACHINE="alphaev67" ;; 252 - "EV6.8CB (21264C)") 253 - UNAME_MACHINE="alphaev68" ;; 254 - "EV6.8AL (21264B)") 255 - UNAME_MACHINE="alphaev68" ;; 256 - "EV6.8CX (21264D)") 257 - UNAME_MACHINE="alphaev68" ;; 258 - "EV6.9A (21264/EV69A)") 259 - UNAME_MACHINE="alphaev69" ;; 260 - "EV7 (21364)") 261 - UNAME_MACHINE="alphaev7" ;; 262 - "EV7.9 (21364A)") 263 - UNAME_MACHINE="alphaev79" ;; 264 - esac 265 - # A Pn.n version is a patched version. 266 - # A Vn.n version is a released version. 267 - # A Tn.n version is a released field test version. 268 - # A Xn.n version is an unreleased experimental baselevel. 269 - # 1.2 uses "1.2" for uname -r. 270 - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 271 - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. 272 - exitcode=$? 273 - trap '' 0 274 - exit $exitcode ;; 275 - Alpha\ *:Windows_NT*:*) 276 - # How do we know it's Interix rather than the generic POSIX subsystem? 277 - # Should we change UNAME_MACHINE based on the output of uname instead 278 - # of the specific Alpha model? 279 - echo alpha-pc-interix 280 - exit ;; 281 - 21064:Windows_NT:50:3) 282 - echo alpha-dec-winnt3.5 283 - exit ;; 284 - Amiga*:UNIX_System_V:4.0:*) 285 - echo m68k-unknown-sysv4 286 - exit ;; 287 - *:[Aa]miga[Oo][Ss]:*:*) 288 - echo ${UNAME_MACHINE}-unknown-amigaos 289 - exit ;; 290 - *:[Mm]orph[Oo][Ss]:*:*) 291 - echo ${UNAME_MACHINE}-unknown-morphos 292 - exit ;; 293 - *:OS/390:*:*) 294 - echo i370-ibm-openedition 295 - exit ;; 296 - *:z/VM:*:*) 297 - echo s390-ibm-zvmoe 298 - exit ;; 299 - *:OS400:*:*) 300 - echo powerpc-ibm-os400 301 - exit ;; 302 - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) 303 - echo arm-acorn-riscix${UNAME_RELEASE} 304 - exit ;; 305 - arm:riscos:*:*|arm:RISCOS:*:*) 306 - echo arm-unknown-riscos 307 - exit ;; 308 - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) 309 - echo hppa1.1-hitachi-hiuxmpp 310 - exit ;; 311 - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) 312 - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. 313 - if test "`(/bin/universe) 2>/dev/null`" = att ; then 314 - echo pyramid-pyramid-sysv3 315 - else 316 - echo pyramid-pyramid-bsd 317 - fi 318 - exit ;; 319 - NILE*:*:*:dcosx) 320 - echo pyramid-pyramid-svr4 321 - exit ;; 322 - DRS?6000:unix:4.0:6*) 323 - echo sparc-icl-nx6 324 - exit ;; 325 - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) 326 - case `/usr/bin/uname -p` in 327 - sparc) echo sparc-icl-nx7; exit ;; 328 - esac ;; 329 - s390x:SunOS:*:*) 330 - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 331 - exit ;; 332 - sun4H:SunOS:5.*:*) 333 - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 334 - exit ;; 335 - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) 336 - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 337 - exit ;; 338 - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) 339 - echo i386-pc-auroraux${UNAME_RELEASE} 340 - exit ;; 341 - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) 342 - eval $set_cc_for_build 343 - SUN_ARCH="i386" 344 - # If there is a compiler, see if it is configured for 64-bit objects. 345 - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. 346 - # This test works for both compilers. 347 - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 348 - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ 349 - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 350 - grep IS_64BIT_ARCH >/dev/null 351 - then 352 - SUN_ARCH="x86_64" 353 - fi 354 - fi 355 - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 356 - exit ;; 357 - sun4*:SunOS:6*:*) 358 - # According to config.sub, this is the proper way to canonicalize 359 - # SunOS6. Hard to guess exactly what SunOS6 will be like, but 360 - # it's likely to be more like Solaris than SunOS4. 361 - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 362 - exit ;; 363 - sun4*:SunOS:*:*) 364 - case "`/usr/bin/arch -k`" in 365 - Series*|S4*) 366 - UNAME_RELEASE=`uname -v` 367 - ;; 368 - esac 369 - # Japanese Language versions have a version number like `4.1.3-JL'. 370 - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` 371 - exit ;; 372 - sun3*:SunOS:*:*) 373 - echo m68k-sun-sunos${UNAME_RELEASE} 374 - exit ;; 375 - sun*:*:4.2BSD:*) 376 - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` 377 - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 378 - case "`/bin/arch`" in 379 - sun3) 380 - echo m68k-sun-sunos${UNAME_RELEASE} 381 - ;; 382 - sun4) 383 - echo sparc-sun-sunos${UNAME_RELEASE} 384 - ;; 385 - esac 386 - exit ;; 387 - aushp:SunOS:*:*) 388 - echo sparc-auspex-sunos${UNAME_RELEASE} 389 - exit ;; 390 - # The situation for MiNT is a little confusing. The machine name 391 - # can be virtually everything (everything which is not 392 - # "atarist" or "atariste" at least should have a processor 393 - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" 394 - # to the lowercase version "mint" (or "freemint"). Finally 395 - # the system name "TOS" denotes a system which is actually not 396 - # MiNT. But MiNT is downward compatible to TOS, so this should 397 - # be no problem. 398 - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) 399 - echo m68k-atari-mint${UNAME_RELEASE} 400 - exit ;; 401 - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) 402 - echo m68k-atari-mint${UNAME_RELEASE} 403 - exit ;; 404 - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) 405 - echo m68k-atari-mint${UNAME_RELEASE} 406 - exit ;; 407 - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) 408 - echo m68k-milan-mint${UNAME_RELEASE} 409 - exit ;; 410 - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) 411 - echo m68k-hades-mint${UNAME_RELEASE} 412 - exit ;; 413 - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) 414 - echo m68k-unknown-mint${UNAME_RELEASE} 415 - exit ;; 416 - m68k:machten:*:*) 417 - echo m68k-apple-machten${UNAME_RELEASE} 418 - exit ;; 419 - powerpc:machten:*:*) 420 - echo powerpc-apple-machten${UNAME_RELEASE} 421 - exit ;; 422 - RISC*:Mach:*:*) 423 - echo mips-dec-mach_bsd4.3 424 - exit ;; 425 - RISC*:ULTRIX:*:*) 426 - echo mips-dec-ultrix${UNAME_RELEASE} 427 - exit ;; 428 - VAX*:ULTRIX*:*:*) 429 - echo vax-dec-ultrix${UNAME_RELEASE} 430 - exit ;; 431 - 2020:CLIX:*:* | 2430:CLIX:*:*) 432 - echo clipper-intergraph-clix${UNAME_RELEASE} 433 - exit ;; 434 - mips:*:*:UMIPS | mips:*:*:RISCos) 435 - eval $set_cc_for_build 436 - sed 's/^ //' << EOF >$dummy.c 437 -#ifdef __cplusplus 438 -#include <stdio.h> /* for printf() prototype */ 439 - int main (int argc, char *argv[]) { 440 -#else 441 - int main (argc, argv) int argc; char *argv[]; { 442 -#endif 443 - #if defined (host_mips) && defined (MIPSEB) 444 - #if defined (SYSTYPE_SYSV) 445 - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); 446 - #endif 447 - #if defined (SYSTYPE_SVR4) 448 - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); 449 - #endif 450 - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) 451 - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); 452 - #endif 453 - #endif 454 - exit (-1); 455 - } 456 -EOF 457 - $CC_FOR_BUILD -o $dummy $dummy.c && 458 - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && 459 - SYSTEM_NAME=`$dummy $dummyarg` && 460 - { echo "$SYSTEM_NAME"; exit; } 461 - echo mips-mips-riscos${UNAME_RELEASE} 462 - exit ;; 463 - Motorola:PowerMAX_OS:*:*) 464 - echo powerpc-motorola-powermax 465 - exit ;; 466 - Motorola:*:4.3:PL8-*) 467 - echo powerpc-harris-powermax 468 - exit ;; 469 - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) 470 - echo powerpc-harris-powermax 471 - exit ;; 472 - Night_Hawk:Power_UNIX:*:*) 473 - echo powerpc-harris-powerunix 474 - exit ;; 475 - m88k:CX/UX:7*:*) 476 - echo m88k-harris-cxux7 477 - exit ;; 478 - m88k:*:4*:R4*) 479 - echo m88k-motorola-sysv4 480 - exit ;; 481 - m88k:*:3*:R3*) 482 - echo m88k-motorola-sysv3 483 - exit ;; 484 - AViiON:dgux:*:*) 485 - # DG/UX returns AViiON for all architectures 486 - UNAME_PROCESSOR=`/usr/bin/uname -p` 487 - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] 488 - then 489 - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ 490 - [ ${TARGET_BINARY_INTERFACE}x = x ] 491 - then 492 - echo m88k-dg-dgux${UNAME_RELEASE} 493 - else 494 - echo m88k-dg-dguxbcs${UNAME_RELEASE} 495 - fi 496 - else 497 - echo i586-dg-dgux${UNAME_RELEASE} 498 - fi 499 - exit ;; 500 - M88*:DolphinOS:*:*) # DolphinOS (SVR3) 501 - echo m88k-dolphin-sysv3 502 - exit ;; 503 - M88*:*:R3*:*) 504 - # Delta 88k system running SVR3 505 - echo m88k-motorola-sysv3 506 - exit ;; 507 - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) 508 - echo m88k-tektronix-sysv3 509 - exit ;; 510 - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) 511 - echo m68k-tektronix-bsd 512 - exit ;; 513 - *:IRIX*:*:*) 514 - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` 515 - exit ;; 516 - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. 517 - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id 518 - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' 519 - i*86:AIX:*:*) 520 - echo i386-ibm-aix 521 - exit ;; 522 - ia64:AIX:*:*) 523 - if [ -x /usr/bin/oslevel ] ; then 524 - IBM_REV=`/usr/bin/oslevel` 525 - else 526 - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 527 - fi 528 - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} 529 - exit ;; 530 - *:AIX:2:3) 531 - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then 532 - eval $set_cc_for_build 533 - sed 's/^ //' << EOF >$dummy.c 534 - #include <sys/systemcfg.h> 535 - 536 - main() 537 - { 538 - if (!__power_pc()) 539 - exit(1); 540 - puts("powerpc-ibm-aix3.2.5"); 541 - exit(0); 542 - } 543 -EOF 544 - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` 545 - then 546 - echo "$SYSTEM_NAME" 547 - else 548 - echo rs6000-ibm-aix3.2.5 549 - fi 550 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then 551 - echo rs6000-ibm-aix3.2.4 552 - else 553 - echo rs6000-ibm-aix3.2 554 - fi 555 - exit ;; 556 - *:AIX:*:[4567]) 557 - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 558 - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then 559 - IBM_ARCH=rs6000 560 - else 561 - IBM_ARCH=powerpc 562 - fi 563 - if [ -x /usr/bin/oslevel ] ; then 564 - IBM_REV=`/usr/bin/oslevel` 565 - else 566 - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 567 - fi 568 - echo ${IBM_ARCH}-ibm-aix${IBM_REV} 569 - exit ;; 570 - *:AIX:*:*) 571 - echo rs6000-ibm-aix 572 - exit ;; 573 - ibmrt:4.4BSD:*|romp-ibm:BSD:*) 574 - echo romp-ibm-bsd4.4 575 - exit ;; 576 - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and 577 - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to 578 - exit ;; # report: romp-ibm BSD 4.3 579 - *:BOSX:*:*) 580 - echo rs6000-bull-bosx 581 - exit ;; 582 - DPX/2?00:B.O.S.:*:*) 583 - echo m68k-bull-sysv3 584 - exit ;; 585 - 9000/[34]??:4.3bsd:1.*:*) 586 - echo m68k-hp-bsd 587 - exit ;; 588 - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) 589 - echo m68k-hp-bsd4.4 590 - exit ;; 591 - 9000/[34678]??:HP-UX:*:*) 592 - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 593 - case "${UNAME_MACHINE}" in 594 - 9000/31? ) HP_ARCH=m68000 ;; 595 - 9000/[34]?? ) HP_ARCH=m68k ;; 596 - 9000/[678][0-9][0-9]) 597 - if [ -x /usr/bin/getconf ]; then 598 - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` 599 - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` 600 - case "${sc_cpu_version}" in 601 - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 602 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 603 - 532) # CPU_PA_RISC2_0 604 - case "${sc_kernel_bits}" in 605 - 32) HP_ARCH="hppa2.0n" ;; 606 - 64) HP_ARCH="hppa2.0w" ;; 607 - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 608 - esac ;; 609 - esac 610 - fi 611 - if [ "${HP_ARCH}" = "" ]; then 612 - eval $set_cc_for_build 613 - sed 's/^ //' << EOF >$dummy.c 614 - 615 - #define _HPUX_SOURCE 616 - #include <stdlib.h> 617 - #include <unistd.h> 618 - 619 - int main () 620 - { 621 - #if defined(_SC_KERNEL_BITS) 622 - long bits = sysconf(_SC_KERNEL_BITS); 623 - #endif 624 - long cpu = sysconf (_SC_CPU_VERSION); 625 - 626 - switch (cpu) 627 - { 628 - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; 629 - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; 630 - case CPU_PA_RISC2_0: 631 - #if defined(_SC_KERNEL_BITS) 632 - switch (bits) 633 - { 634 - case 64: puts ("hppa2.0w"); break; 635 - case 32: puts ("hppa2.0n"); break; 636 - default: puts ("hppa2.0"); break; 637 - } break; 638 - #else /* !defined(_SC_KERNEL_BITS) */ 639 - puts ("hppa2.0"); break; 640 - #endif 641 - default: puts ("hppa1.0"); break; 642 - } 643 - exit (0); 644 - } 645 -EOF 646 - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` 647 - test -z "$HP_ARCH" && HP_ARCH=hppa 648 - fi ;; 649 - esac 650 - if [ ${HP_ARCH} = "hppa2.0w" ] 651 - then 652 - eval $set_cc_for_build 653 - 654 - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating 655 - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler 656 - # generating 64-bit code. GNU and HP use different nomenclature: 657 - # 658 - # $ CC_FOR_BUILD=cc ./config.guess 659 - # => hppa2.0w-hp-hpux11.23 660 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess 661 - # => hppa64-hp-hpux11.23 662 - 663 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | 664 - grep -q __LP64__ 665 - then 666 - HP_ARCH="hppa2.0w" 667 - else 668 - HP_ARCH="hppa64" 669 - fi 670 - fi 671 - echo ${HP_ARCH}-hp-hpux${HPUX_REV} 672 - exit ;; 673 - ia64:HP-UX:*:*) 674 - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 675 - echo ia64-hp-hpux${HPUX_REV} 676 - exit ;; 677 - 3050*:HI-UX:*:*) 678 - eval $set_cc_for_build 679 - sed 's/^ //' << EOF >$dummy.c 680 - #include <unistd.h> 681 - int 682 - main () 683 - { 684 - long cpu = sysconf (_SC_CPU_VERSION); 685 - /* The order matters, because CPU_IS_HP_MC68K erroneously returns 686 - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct 687 - results, however. */ 688 - if (CPU_IS_PA_RISC (cpu)) 689 - { 690 - switch (cpu) 691 - { 692 - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; 693 - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; 694 - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; 695 - default: puts ("hppa-hitachi-hiuxwe2"); break; 696 - } 697 - } 698 - else if (CPU_IS_HP_MC68K (cpu)) 699 - puts ("m68k-hitachi-hiuxwe2"); 700 - else puts ("unknown-hitachi-hiuxwe2"); 701 - exit (0); 702 - } 703 -EOF 704 - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && 705 - { echo "$SYSTEM_NAME"; exit; } 706 - echo unknown-hitachi-hiuxwe2 707 - exit ;; 708 - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) 709 - echo hppa1.1-hp-bsd 710 - exit ;; 711 - 9000/8??:4.3bsd:*:*) 712 - echo hppa1.0-hp-bsd 713 - exit ;; 714 - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) 715 - echo hppa1.0-hp-mpeix 716 - exit ;; 717 - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) 718 - echo hppa1.1-hp-osf 719 - exit ;; 720 - hp8??:OSF1:*:*) 721 - echo hppa1.0-hp-osf 722 - exit ;; 723 - i*86:OSF1:*:*) 724 - if [ -x /usr/sbin/sysversion ] ; then 725 - echo ${UNAME_MACHINE}-unknown-osf1mk 726 - else 727 - echo ${UNAME_MACHINE}-unknown-osf1 728 - fi 729 - exit ;; 730 - parisc*:Lites*:*:*) 731 - echo hppa1.1-hp-lites 732 - exit ;; 733 - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) 734 - echo c1-convex-bsd 735 - exit ;; 736 - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) 737 - if getsysinfo -f scalar_acc 738 - then echo c32-convex-bsd 739 - else echo c2-convex-bsd 740 - fi 741 - exit ;; 742 - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) 743 - echo c34-convex-bsd 744 - exit ;; 745 - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) 746 - echo c38-convex-bsd 747 - exit ;; 748 - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) 749 - echo c4-convex-bsd 750 - exit ;; 751 - CRAY*Y-MP:*:*:*) 752 - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 753 - exit ;; 754 - CRAY*[A-Z]90:*:*:*) 755 - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ 756 - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ 757 - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ 758 - -e 's/\.[^.]*$/.X/' 759 - exit ;; 760 - CRAY*TS:*:*:*) 761 - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 762 - exit ;; 763 - CRAY*T3E:*:*:*) 764 - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 765 - exit ;; 766 - CRAY*SV1:*:*:*) 767 - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 768 - exit ;; 769 - *:UNICOS/mp:*:*) 770 - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 771 - exit ;; 772 - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) 773 - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 774 - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 775 - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` 776 - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 777 - exit ;; 778 - 5000:UNIX_System_V:4.*:*) 779 - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 780 - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` 781 - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 782 - exit ;; 783 - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) 784 - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} 785 - exit ;; 786 - sparc*:BSD/OS:*:*) 787 - echo sparc-unknown-bsdi${UNAME_RELEASE} 788 - exit ;; 789 - *:BSD/OS:*:*) 790 - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} 791 - exit ;; 792 - *:FreeBSD:*:*) 793 - UNAME_PROCESSOR=`/usr/bin/uname -p` 794 - case ${UNAME_PROCESSOR} in 795 - amd64) 796 - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 797 - *) 798 - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 799 - esac 800 - exit ;; 801 - i*:CYGWIN*:*) 802 - echo ${UNAME_MACHINE}-pc-cygwin 803 - exit ;; 804 - *:MINGW*:*) 805 - echo ${UNAME_MACHINE}-pc-mingw32 806 - exit ;; 807 - i*:MSYS*:*) 808 - echo ${UNAME_MACHINE}-pc-msys 809 - exit ;; 810 - i*:windows32*:*) 811 - # uname -m includes "-pc" on this system. 812 - echo ${UNAME_MACHINE}-mingw32 813 - exit ;; 814 - i*:PW*:*) 815 - echo ${UNAME_MACHINE}-pc-pw32 816 - exit ;; 817 - *:Interix*:*) 818 - case ${UNAME_MACHINE} in 819 - x86) 820 - echo i586-pc-interix${UNAME_RELEASE} 821 - exit ;; 822 - authenticamd | genuineintel | EM64T) 823 - echo x86_64-unknown-interix${UNAME_RELEASE} 824 - exit ;; 825 - IA64) 826 - echo ia64-unknown-interix${UNAME_RELEASE} 827 - exit ;; 828 - esac ;; 829 - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) 830 - echo i${UNAME_MACHINE}-pc-mks 831 - exit ;; 832 - 8664:Windows_NT:*) 833 - echo x86_64-pc-mks 834 - exit ;; 835 - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) 836 - # How do we know it's Interix rather than the generic POSIX subsystem? 837 - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we 838 - # UNAME_MACHINE based on the output of uname instead of i386? 839 - echo i586-pc-interix 840 - exit ;; 841 - i*:UWIN*:*) 842 - echo ${UNAME_MACHINE}-pc-uwin 843 - exit ;; 844 - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) 845 - echo x86_64-unknown-cygwin 846 - exit ;; 847 - p*:CYGWIN*:*) 848 - echo powerpcle-unknown-cygwin 849 - exit ;; 850 - prep*:SunOS:5.*:*) 851 - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 852 - exit ;; 853 - *:GNU:*:*) 854 - # the GNU system 855 - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` 856 - exit ;; 857 - *:GNU/*:*:*) 858 - # other systems with GNU libc and userland 859 - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu 860 - exit ;; 861 - i*86:Minix:*:*) 862 - echo ${UNAME_MACHINE}-pc-minix 863 - exit ;; 864 - aarch64:Linux:*:*) 865 - echo ${UNAME_MACHINE}-unknown-linux-gnu 866 - exit ;; 867 - aarch64_be:Linux:*:*) 868 - UNAME_MACHINE=aarch64_be 869 - echo ${UNAME_MACHINE}-unknown-linux-gnu 870 - exit ;; 871 - alpha:Linux:*:*) 872 - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in 873 - EV5) UNAME_MACHINE=alphaev5 ;; 874 - EV56) UNAME_MACHINE=alphaev56 ;; 875 - PCA56) UNAME_MACHINE=alphapca56 ;; 876 - PCA57) UNAME_MACHINE=alphapca56 ;; 877 - EV6) UNAME_MACHINE=alphaev6 ;; 878 - EV67) UNAME_MACHINE=alphaev67 ;; 879 - EV68*) UNAME_MACHINE=alphaev68 ;; 880 - esac 881 - objdump --private-headers /bin/sh | grep -q ld.so.1 882 - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi 883 - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} 884 - exit ;; 885 - arm*:Linux:*:*) 886 - eval $set_cc_for_build 887 - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ 888 - | grep -q __ARM_EABI__ 889 - then 890 - echo ${UNAME_MACHINE}-unknown-linux-gnu 891 - else 892 - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ 893 - | grep -q __ARM_PCS_VFP 894 - then 895 - echo ${UNAME_MACHINE}-unknown-linux-gnueabi 896 - else 897 - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf 898 - fi 899 - fi 900 - exit ;; 901 - avr32*:Linux:*:*) 902 - echo ${UNAME_MACHINE}-unknown-linux-gnu 903 - exit ;; 904 - cris:Linux:*:*) 905 - echo ${UNAME_MACHINE}-axis-linux-gnu 906 - exit ;; 907 - crisv32:Linux:*:*) 908 - echo ${UNAME_MACHINE}-axis-linux-gnu 909 - exit ;; 910 - frv:Linux:*:*) 911 - echo ${UNAME_MACHINE}-unknown-linux-gnu 912 - exit ;; 913 - hexagon:Linux:*:*) 914 - echo ${UNAME_MACHINE}-unknown-linux-gnu 915 - exit ;; 916 - i*86:Linux:*:*) 917 - LIBC=gnu 918 - eval $set_cc_for_build 919 - sed 's/^ //' << EOF >$dummy.c 920 - #ifdef __dietlibc__ 921 - LIBC=dietlibc 922 - #endif 923 -EOF 924 - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` 925 - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" 926 - exit ;; 927 - ia64:Linux:*:*) 928 - echo ${UNAME_MACHINE}-unknown-linux-gnu 929 - exit ;; 930 - m32r*:Linux:*:*) 931 - echo ${UNAME_MACHINE}-unknown-linux-gnu 932 - exit ;; 933 - m68*:Linux:*:*) 934 - echo ${UNAME_MACHINE}-unknown-linux-gnu 935 - exit ;; 936 - mips:Linux:*:* | mips64:Linux:*:*) 937 - eval $set_cc_for_build 938 - sed 's/^ //' << EOF >$dummy.c 939 - #undef CPU 940 - #undef ${UNAME_MACHINE} 941 - #undef ${UNAME_MACHINE}el 942 - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) 943 - CPU=${UNAME_MACHINE}el 944 - #else 945 - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) 946 - CPU=${UNAME_MACHINE} 947 - #else 948 - CPU= 949 - #endif 950 - #endif 951 -EOF 952 - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` 953 - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } 954 - ;; 955 - or32:Linux:*:*) 956 - echo ${UNAME_MACHINE}-unknown-linux-gnu 957 - exit ;; 958 - padre:Linux:*:*) 959 - echo sparc-unknown-linux-gnu 960 - exit ;; 961 - parisc64:Linux:*:* | hppa64:Linux:*:*) 962 - echo hppa64-unknown-linux-gnu 963 - exit ;; 964 - parisc:Linux:*:* | hppa:Linux:*:*) 965 - # Look for CPU level 966 - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in 967 - PA7*) echo hppa1.1-unknown-linux-gnu ;; 968 - PA8*) echo hppa2.0-unknown-linux-gnu ;; 969 - *) echo hppa-unknown-linux-gnu ;; 970 - esac 971 - exit ;; 972 - ppc64:Linux:*:*) 973 - echo powerpc64-unknown-linux-gnu 974 - exit ;; 975 - ppc:Linux:*:*) 976 - echo powerpc-unknown-linux-gnu 977 - exit ;; 978 - s390:Linux:*:* | s390x:Linux:*:*) 979 - echo ${UNAME_MACHINE}-ibm-linux 980 - exit ;; 981 - sh64*:Linux:*:*) 982 - echo ${UNAME_MACHINE}-unknown-linux-gnu 983 - exit ;; 984 - sh*:Linux:*:*) 985 - echo ${UNAME_MACHINE}-unknown-linux-gnu 986 - exit ;; 987 - sparc:Linux:*:* | sparc64:Linux:*:*) 988 - echo ${UNAME_MACHINE}-unknown-linux-gnu 989 - exit ;; 990 - tile*:Linux:*:*) 991 - echo ${UNAME_MACHINE}-unknown-linux-gnu 992 - exit ;; 993 - vax:Linux:*:*) 994 - echo ${UNAME_MACHINE}-dec-linux-gnu 995 - exit ;; 996 - x86_64:Linux:*:*) 997 - echo ${UNAME_MACHINE}-unknown-linux-gnu 998 - exit ;; 999 - xtensa*:Linux:*:*) 1000 - echo ${UNAME_MACHINE}-unknown-linux-gnu 1001 - exit ;; 1002 - i*86:DYNIX/ptx:4*:*) 1003 - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. 1004 - # earlier versions are messed up and put the nodename in both 1005 - # sysname and nodename. 1006 - echo i386-sequent-sysv4 1007 - exit ;; 1008 - i*86:UNIX_SV:4.2MP:2.*) 1009 - # Unixware is an offshoot of SVR4, but it has its own version 1010 - # number series starting with 2... 1011 - # I am not positive that other SVR4 systems won't match this, 1012 - # I just have to hope. -- rms. 1013 - # Use sysv4.2uw... so that sysv4* matches it. 1014 - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} 1015 - exit ;; 1016 - i*86:OS/2:*:*) 1017 - # If we were able to find `uname', then EMX Unix compatibility 1018 - # is probably installed. 1019 - echo ${UNAME_MACHINE}-pc-os2-emx 1020 - exit ;; 1021 - i*86:XTS-300:*:STOP) 1022 - echo ${UNAME_MACHINE}-unknown-stop 1023 - exit ;; 1024 - i*86:atheos:*:*) 1025 - echo ${UNAME_MACHINE}-unknown-atheos 1026 - exit ;; 1027 - i*86:syllable:*:*) 1028 - echo ${UNAME_MACHINE}-pc-syllable 1029 - exit ;; 1030 - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) 1031 - echo i386-unknown-lynxos${UNAME_RELEASE} 1032 - exit ;; 1033 - i*86:*DOS:*:*) 1034 - echo ${UNAME_MACHINE}-pc-msdosdjgpp 1035 - exit ;; 1036 - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) 1037 - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` 1038 - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then 1039 - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} 1040 - else 1041 - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} 1042 - fi 1043 - exit ;; 1044 - i*86:*:5:[678]*) 1045 - # UnixWare 7.x, OpenUNIX and OpenServer 6. 1046 - case `/bin/uname -X | grep "^Machine"` in 1047 - *486*) UNAME_MACHINE=i486 ;; 1048 - *Pentium) UNAME_MACHINE=i586 ;; 1049 - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; 1050 - esac 1051 - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} 1052 - exit ;; 1053 - i*86:*:3.2:*) 1054 - if test -f /usr/options/cb.name; then 1055 - UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` 1056 - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL 1057 - elif /bin/uname -X 2>/dev/null >/dev/null ; then 1058 - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` 1059 - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 1060 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ 1061 - && UNAME_MACHINE=i586 1062 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ 1063 - && UNAME_MACHINE=i686 1064 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ 1065 - && UNAME_MACHINE=i686 1066 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL 1067 - else 1068 - echo ${UNAME_MACHINE}-pc-sysv32 1069 - fi 1070 - exit ;; 1071 - pc:*:*:*) 1072 - # Left here for compatibility: 1073 - # uname -m prints for DJGPP always 'pc', but it prints nothing about 1074 - # the processor, so we play safe by assuming i586. 1075 - # Note: whatever this is, it MUST be the same as what config.sub 1076 - # prints for the "djgpp" host, or else GDB configury will decide that 1077 - # this is a cross-build. 1078 - echo i586-pc-msdosdjgpp 1079 - exit ;; 1080 - Intel:Mach:3*:*) 1081 - echo i386-pc-mach3 1082 - exit ;; 1083 - paragon:*:*:*) 1084 - echo i860-intel-osf1 1085 - exit ;; 1086 - i860:*:4.*:*) # i860-SVR4 1087 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then 1088 - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 1089 - else # Add other i860-SVR4 vendors below as they are discovered. 1090 - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 1091 - fi 1092 - exit ;; 1093 - mini*:CTIX:SYS*5:*) 1094 - # "miniframe" 1095 - echo m68010-convergent-sysv 1096 - exit ;; 1097 - mc68k:UNIX:SYSTEM5:3.51m) 1098 - echo m68k-convergent-sysv 1099 - exit ;; 1100 - M680?0:D-NIX:5.3:*) 1101 - echo m68k-diab-dnix 1102 - exit ;; 1103 - M68*:*:R3V[5678]*:*) 1104 - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 1105 - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) 1106 - OS_REL='' 1107 - test -r /etc/.relid \ 1108 - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 1109 - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1110 - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } 1111 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 1112 - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1113 - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 1114 - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1115 - && { echo i486-ncr-sysv4; exit; } ;; 1116 - NCR*:*:4.2:* | MPRAS*:*:4.2:*) 1117 - OS_REL='.3' 1118 - test -r /etc/.relid \ 1119 - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 1120 - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1121 - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } 1122 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 1123 - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } 1124 - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ 1125 - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1126 - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) 1127 - echo m68k-unknown-lynxos${UNAME_RELEASE} 1128 - exit ;; 1129 - mc68030:UNIX_System_V:4.*:*) 1130 - echo m68k-atari-sysv4 1131 - exit ;; 1132 - TSUNAMI:LynxOS:2.*:*) 1133 - echo sparc-unknown-lynxos${UNAME_RELEASE} 1134 - exit ;; 1135 - rs6000:LynxOS:2.*:*) 1136 - echo rs6000-unknown-lynxos${UNAME_RELEASE} 1137 - exit ;; 1138 - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) 1139 - echo powerpc-unknown-lynxos${UNAME_RELEASE} 1140 - exit ;; 1141 - SM[BE]S:UNIX_SV:*:*) 1142 - echo mips-dde-sysv${UNAME_RELEASE} 1143 - exit ;; 1144 - RM*:ReliantUNIX-*:*:*) 1145 - echo mips-sni-sysv4 1146 - exit ;; 1147 - RM*:SINIX-*:*:*) 1148 - echo mips-sni-sysv4 1149 - exit ;; 1150 - *:SINIX-*:*:*) 1151 - if uname -p 2>/dev/null >/dev/null ; then 1152 - UNAME_MACHINE=`(uname -p) 2>/dev/null` 1153 - echo ${UNAME_MACHINE}-sni-sysv4 1154 - else 1155 - echo ns32k-sni-sysv 1156 - fi 1157 - exit ;; 1158 - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort 1159 - # says <Richard.M.Bartel@ccMail.Census.GOV> 1160 - echo i586-unisys-sysv4 1161 - exit ;; 1162 - *:UNIX_System_V:4*:FTX*) 1163 - # From Gerald Hewes <hewes@openmarket.com>. 1164 - # How about differentiating between stratus architectures? -djm 1165 - echo hppa1.1-stratus-sysv4 1166 - exit ;; 1167 - *:*:*:FTX*) 1168 - # From seanf@swdc.stratus.com. 1169 - echo i860-stratus-sysv4 1170 - exit ;; 1171 - i*86:VOS:*:*) 1172 - # From Paul.Green@stratus.com. 1173 - echo ${UNAME_MACHINE}-stratus-vos 1174 - exit ;; 1175 - *:VOS:*:*) 1176 - # From Paul.Green@stratus.com. 1177 - echo hppa1.1-stratus-vos 1178 - exit ;; 1179 - mc68*:A/UX:*:*) 1180 - echo m68k-apple-aux${UNAME_RELEASE} 1181 - exit ;; 1182 - news*:NEWS-OS:6*:*) 1183 - echo mips-sony-newsos6 1184 - exit ;; 1185 - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) 1186 - if [ -d /usr/nec ]; then 1187 - echo mips-nec-sysv${UNAME_RELEASE} 1188 - else 1189 - echo mips-unknown-sysv${UNAME_RELEASE} 1190 - fi 1191 - exit ;; 1192 - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. 1193 - echo powerpc-be-beos 1194 - exit ;; 1195 - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. 1196 - echo powerpc-apple-beos 1197 - exit ;; 1198 - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. 1199 - echo i586-pc-beos 1200 - exit ;; 1201 - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. 1202 - echo i586-pc-haiku 1203 - exit ;; 1204 - SX-4:SUPER-UX:*:*) 1205 - echo sx4-nec-superux${UNAME_RELEASE} 1206 - exit ;; 1207 - SX-5:SUPER-UX:*:*) 1208 - echo sx5-nec-superux${UNAME_RELEASE} 1209 - exit ;; 1210 - SX-6:SUPER-UX:*:*) 1211 - echo sx6-nec-superux${UNAME_RELEASE} 1212 - exit ;; 1213 - SX-7:SUPER-UX:*:*) 1214 - echo sx7-nec-superux${UNAME_RELEASE} 1215 - exit ;; 1216 - SX-8:SUPER-UX:*:*) 1217 - echo sx8-nec-superux${UNAME_RELEASE} 1218 - exit ;; 1219 - SX-8R:SUPER-UX:*:*) 1220 - echo sx8r-nec-superux${UNAME_RELEASE} 1221 - exit ;; 1222 - Power*:Rhapsody:*:*) 1223 - echo powerpc-apple-rhapsody${UNAME_RELEASE} 1224 - exit ;; 1225 - *:Rhapsody:*:*) 1226 - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} 1227 - exit ;; 1228 - *:Darwin:*:*) 1229 - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown 1230 - case $UNAME_PROCESSOR in 1231 - i386) 1232 - eval $set_cc_for_build 1233 - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 1234 - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ 1235 - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 1236 - grep IS_64BIT_ARCH >/dev/null 1237 - then 1238 - UNAME_PROCESSOR="x86_64" 1239 - fi 1240 - fi ;; 1241 - unknown) UNAME_PROCESSOR=powerpc ;; 1242 - esac 1243 - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} 1244 - exit ;; 1245 - *:procnto*:*:* | *:QNX:[0123456789]*:*) 1246 - UNAME_PROCESSOR=`uname -p` 1247 - if test "$UNAME_PROCESSOR" = "x86"; then 1248 - UNAME_PROCESSOR=i386 1249 - UNAME_MACHINE=pc 1250 - fi 1251 - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} 1252 - exit ;; 1253 - *:QNX:*:4*) 1254 - echo i386-pc-qnx 1255 - exit ;; 1256 - NEO-?:NONSTOP_KERNEL:*:*) 1257 - echo neo-tandem-nsk${UNAME_RELEASE} 1258 - exit ;; 1259 - NSE-?:NONSTOP_KERNEL:*:*) 1260 - echo nse-tandem-nsk${UNAME_RELEASE} 1261 - exit ;; 1262 - NSR-?:NONSTOP_KERNEL:*:*) 1263 - echo nsr-tandem-nsk${UNAME_RELEASE} 1264 - exit ;; 1265 - *:NonStop-UX:*:*) 1266 - echo mips-compaq-nonstopux 1267 - exit ;; 1268 - BS2000:POSIX*:*:*) 1269 - echo bs2000-siemens-sysv 1270 - exit ;; 1271 - DS/*:UNIX_System_V:*:*) 1272 - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} 1273 - exit ;; 1274 - *:Plan9:*:*) 1275 - # "uname -m" is not consistent, so use $cputype instead. 386 1276 - # is converted to i386 for consistency with other x86 1277 - # operating systems. 1278 - if test "$cputype" = "386"; then 1279 - UNAME_MACHINE=i386 1280 - else 1281 - UNAME_MACHINE="$cputype" 1282 - fi 1283 - echo ${UNAME_MACHINE}-unknown-plan9 1284 - exit ;; 1285 - *:TOPS-10:*:*) 1286 - echo pdp10-unknown-tops10 1287 - exit ;; 1288 - *:TENEX:*:*) 1289 - echo pdp10-unknown-tenex 1290 - exit ;; 1291 - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) 1292 - echo pdp10-dec-tops20 1293 - exit ;; 1294 - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) 1295 - echo pdp10-xkl-tops20 1296 - exit ;; 1297 - *:TOPS-20:*:*) 1298 - echo pdp10-unknown-tops20 1299 - exit ;; 1300 - *:ITS:*:*) 1301 - echo pdp10-unknown-its 1302 - exit ;; 1303 - SEI:*:*:SEIUX) 1304 - echo mips-sei-seiux${UNAME_RELEASE} 1305 - exit ;; 1306 - *:DragonFly:*:*) 1307 - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` 1308 - exit ;; 1309 - *:*VMS:*:*) 1310 - UNAME_MACHINE=`(uname -p) 2>/dev/null` 1311 - case "${UNAME_MACHINE}" in 1312 - A*) echo alpha-dec-vms ; exit ;; 1313 - I*) echo ia64-dec-vms ; exit ;; 1314 - V*) echo vax-dec-vms ; exit ;; 1315 - esac ;; 1316 - *:XENIX:*:SysV) 1317 - echo i386-pc-xenix 1318 - exit ;; 1319 - i*86:skyos:*:*) 1320 - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' 1321 - exit ;; 1322 - i*86:rdos:*:*) 1323 - echo ${UNAME_MACHINE}-pc-rdos 1324 - exit ;; 1325 - i*86:AROS:*:*) 1326 - echo ${UNAME_MACHINE}-pc-aros 1327 - exit ;; 1328 - x86_64:VMkernel:*:*) 1329 - echo ${UNAME_MACHINE}-unknown-esx 1330 - exit ;; 1331 -esac 1332 - 1333 -#echo '(No uname command or uname output not recognized.)' 1>&2 1334 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 1335 - 1336 -eval $set_cc_for_build 1337 -cat >$dummy.c <<EOF 1338 -#ifdef _SEQUENT_ 1339 -# include <sys/types.h> 1340 -# include <sys/utsname.h> 1341 -#endif 1342 -main () 1343 -{ 1344 -#if defined (sony) 1345 -#if defined (MIPSEB) 1346 - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, 1347 - I don't know.... */ 1348 - printf ("mips-sony-bsd\n"); exit (0); 1349 -#else 1350 -#include <sys/param.h> 1351 - printf ("m68k-sony-newsos%s\n", 1352 -#ifdef NEWSOS4 1353 - "4" 1354 -#else 1355 - "" 1356 -#endif 1357 - ); exit (0); 1358 -#endif 1359 -#endif 1360 - 1361 -#if defined (__arm) && defined (__acorn) && defined (__unix) 1362 - printf ("arm-acorn-riscix\n"); exit (0); 1363 -#endif 1364 - 1365 -#if defined (hp300) && !defined (hpux) 1366 - printf ("m68k-hp-bsd\n"); exit (0); 1367 -#endif 1368 - 1369 -#if defined (NeXT) 1370 -#if !defined (__ARCHITECTURE__) 1371 -#define __ARCHITECTURE__ "m68k" 1372 -#endif 1373 - int version; 1374 - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; 1375 - if (version < 4) 1376 - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); 1377 - else 1378 - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); 1379 - exit (0); 1380 -#endif 1381 - 1382 -#if defined (MULTIMAX) || defined (n16) 1383 -#if defined (UMAXV) 1384 - printf ("ns32k-encore-sysv\n"); exit (0); 1385 -#else 1386 -#if defined (CMU) 1387 - printf ("ns32k-encore-mach\n"); exit (0); 1388 -#else 1389 - printf ("ns32k-encore-bsd\n"); exit (0); 1390 -#endif 1391 -#endif 1392 -#endif 1393 - 1394 -#if defined (__386BSD__) 1395 - printf ("i386-pc-bsd\n"); exit (0); 1396 -#endif 1397 - 1398 -#if defined (sequent) 1399 -#if defined (i386) 1400 - printf ("i386-sequent-dynix\n"); exit (0); 1401 -#endif 1402 -#if defined (ns32000) 1403 - printf ("ns32k-sequent-dynix\n"); exit (0); 1404 -#endif 1405 -#endif 1406 - 1407 -#if defined (_SEQUENT_) 1408 - struct utsname un; 1409 - 1410 - uname(&un); 1411 - 1412 - if (strncmp(un.version, "V2", 2) == 0) { 1413 - printf ("i386-sequent-ptx2\n"); exit (0); 1414 - } 1415 - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ 1416 - printf ("i386-sequent-ptx1\n"); exit (0); 1417 - } 1418 - printf ("i386-sequent-ptx\n"); exit (0); 1419 - 1420 -#endif 1421 - 1422 -#if defined (vax) 1423 -# if !defined (ultrix) 1424 -# include <sys/param.h> 1425 -# if defined (BSD) 1426 -# if BSD == 43 1427 - printf ("vax-dec-bsd4.3\n"); exit (0); 1428 -# else 1429 -# if BSD == 199006 1430 - printf ("vax-dec-bsd4.3reno\n"); exit (0); 1431 -# else 1432 - printf ("vax-dec-bsd\n"); exit (0); 1433 -# endif 1434 -# endif 1435 -# else 1436 - printf ("vax-dec-bsd\n"); exit (0); 1437 -# endif 1438 -# else 1439 - printf ("vax-dec-ultrix\n"); exit (0); 1440 -# endif 1441 -#endif 1442 - 1443 -#if defined (alliant) && defined (i860) 1444 - printf ("i860-alliant-bsd\n"); exit (0); 1445 -#endif 1446 - 1447 - exit (1); 1448 -} 1449 -EOF 1450 - 1451 -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && 1452 - { echo "$SYSTEM_NAME"; exit; } 1453 - 1454 -# Apollos put the system type in the environment. 1455 - 1456 -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } 1457 - 1458 -# Convex versions that predate uname can use getsysinfo(1) 1459 - 1460 -if [ -x /usr/convex/getsysinfo ] 1461 -then 1462 - case `getsysinfo -f cpu_type` in 1463 - c1*) 1464 - echo c1-convex-bsd 1465 - exit ;; 1466 - c2*) 1467 - if getsysinfo -f scalar_acc 1468 - then echo c32-convex-bsd 1469 - else echo c2-convex-bsd 1470 - fi 1471 - exit ;; 1472 - c34*) 1473 - echo c34-convex-bsd 1474 - exit ;; 1475 - c38*) 1476 - echo c38-convex-bsd 1477 - exit ;; 1478 - c4*) 1479 - echo c4-convex-bsd 1480 - exit ;; 1481 - esac 1482 -fi 1483 - 1484 -cat >&2 <<EOF 1485 -$0: unable to guess system type 1486 - 1487 -This script, last modified $timestamp, has failed to recognize 1488 -the operating system you are using. It is advised that you 1489 -download the most up to date version of the config scripts from 1490 - 1491 - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD 1492 -and 1493 - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD 1494 - 1495 -If the version you run ($0) is already up to date, please 1496 -send the following data and any information you think might be 1497 -pertinent to <config-patches@gnu.org> in order to provide the needed 1498 -information to handle your system. 1499 - 1500 -config.guess timestamp = $timestamp 1501 - 1502 -uname -m = `(uname -m) 2>/dev/null || echo unknown` 1503 -uname -r = `(uname -r) 2>/dev/null || echo unknown` 1504 -uname -s = `(uname -s) 2>/dev/null || echo unknown` 1505 -uname -v = `(uname -v) 2>/dev/null || echo unknown` 1506 - 1507 -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` 1508 -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` 1509 - 1510 -hostinfo = `(hostinfo) 2>/dev/null` 1511 -/bin/universe = `(/bin/universe) 2>/dev/null` 1512 -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` 1513 -/bin/arch = `(/bin/arch) 2>/dev/null` 1514 -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` 1515 -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` 1516 - 1517 -UNAME_MACHINE = ${UNAME_MACHINE} 1518 -UNAME_RELEASE = ${UNAME_RELEASE} 1519 -UNAME_SYSTEM = ${UNAME_SYSTEM} 1520 -UNAME_VERSION = ${UNAME_VERSION} 1521 -EOF 1522 - 1523 -exit 1 1524 - 1525 -# Local variables: 1526 -# eval: (add-hook 'write-file-hooks 'time-stamp) 1527 -# time-stamp-start: "timestamp='" 1528 -# time-stamp-format: "%:y-%02m-%02d" 1529 -# time-stamp-end: "'" 1530 -# End:
Deleted config.sub.
1 -#! /bin/sh 2 -# Configuration validation subroutine script. 3 -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4 -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 5 -# 2011, 2012 Free Software Foundation, Inc. 6 - 7 -timestamp='2012-02-10' 8 - 9 -# This file is (in principle) common to ALL GNU software. 10 -# The presence of a machine in this file suggests that SOME GNU software 11 -# can handle that machine. It does not imply ALL GNU software can. 12 -# 13 -# This file is free software; you can redistribute it and/or modify 14 -# it under the terms of the GNU General Public License as published by 15 -# the Free Software Foundation; either version 2 of the License, or 16 -# (at your option) any later version. 17 -# 18 -# This program is distributed in the hope that it will be useful, 19 -# but WITHOUT ANY WARRANTY; without even the implied warranty of 20 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 -# GNU General Public License for more details. 22 -# 23 -# You should have received a copy of the GNU General Public License 24 -# along with this program; if not, see <http://www.gnu.org/licenses/>. 25 -# 26 -# As a special exception to the GNU General Public License, if you 27 -# distribute this file as part of a program that contains a 28 -# configuration script generated by Autoconf, you may include it under 29 -# the same distribution terms that you use for the rest of that program. 30 - 31 - 32 -# Please send patches to <config-patches@gnu.org>. Submit a context 33 -# diff and a properly formatted GNU ChangeLog entry. 34 -# 35 -# Configuration subroutine to validate and canonicalize a configuration type. 36 -# Supply the specified configuration type as an argument. 37 -# If it is invalid, we print an error message on stderr and exit with code 1. 38 -# Otherwise, we print the canonical config type on stdout and succeed. 39 - 40 -# You can get the latest version of this script from: 41 -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD 42 - 43 -# This file is supposed to be the same for all GNU packages 44 -# and recognize all the CPU types, system types and aliases 45 -# that are meaningful with *any* GNU software. 46 -# Each package is responsible for reporting which valid configurations 47 -# it does not support. The user should be able to distinguish 48 -# a failure to support a valid configuration from a meaningless 49 -# configuration. 50 - 51 -# The goal of this file is to map all the various variations of a given 52 -# machine specification into a single specification in the form: 53 -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 54 -# or in some cases, the newer four-part form: 55 -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM 56 -# It is wrong to echo any other type of specification. 57 - 58 -me=`echo "$0" | sed -e 's,.*/,,'` 59 - 60 -usage="\ 61 -Usage: $0 [OPTION] CPU-MFR-OPSYS 62 - $0 [OPTION] ALIAS 63 - 64 -Canonicalize a configuration name. 65 - 66 -Operation modes: 67 - -h, --help print this help, then exit 68 - -t, --time-stamp print date of last modification, then exit 69 - -v, --version print version number, then exit 70 - 71 -Report bugs and patches to <config-patches@gnu.org>." 72 - 73 -version="\ 74 -GNU config.sub ($timestamp) 75 - 76 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 77 -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 78 -Free Software Foundation, Inc. 79 - 80 -This is free software; see the source for copying conditions. There is NO 81 -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 82 - 83 -help=" 84 -Try \`$me --help' for more information." 85 - 86 -# Parse command line 87 -while test $# -gt 0 ; do 88 - case $1 in 89 - --time-stamp | --time* | -t ) 90 - echo "$timestamp" ; exit ;; 91 - --version | -v ) 92 - echo "$version" ; exit ;; 93 - --help | --h* | -h ) 94 - echo "$usage"; exit ;; 95 - -- ) # Stop option processing 96 - shift; break ;; 97 - - ) # Use stdin as input. 98 - break ;; 99 - -* ) 100 - echo "$me: invalid option $1$help" 101 - exit 1 ;; 102 - 103 - *local*) 104 - # First pass through any local machine types. 105 - echo $1 106 - exit ;; 107 - 108 - * ) 109 - break ;; 110 - esac 111 -done 112 - 113 -case $# in 114 - 0) echo "$me: missing argument$help" >&2 115 - exit 1;; 116 - 1) ;; 117 - *) echo "$me: too many arguments$help" >&2 118 - exit 1;; 119 -esac 120 - 121 -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). 122 -# Here we must recognize all the valid KERNEL-OS combinations. 123 -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` 124 -case $maybe_os in 125 - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ 126 - linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ 127 - knetbsd*-gnu* | netbsd*-gnu* | \ 128 - kopensolaris*-gnu* | \ 129 - storm-chaos* | os2-emx* | rtmk-nova*) 130 - os=-$maybe_os 131 - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` 132 - ;; 133 - android-linux) 134 - os=-linux-android 135 - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown 136 - ;; 137 - *) 138 - basic_machine=`echo $1 | sed 's/-[^-]*$//'` 139 - if [ $basic_machine != $1 ] 140 - then os=`echo $1 | sed 's/.*-/-/'` 141 - else os=; fi 142 - ;; 143 -esac 144 - 145 -### Let's recognize common machines as not being operating systems so 146 -### that things like config.sub decstation-3100 work. We also 147 -### recognize some manufacturers as not being operating systems, so we 148 -### can provide default operating systems below. 149 -case $os in 150 - -sun*os*) 151 - # Prevent following clause from handling this invalid input. 152 - ;; 153 - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ 154 - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ 155 - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ 156 - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ 157 - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ 158 - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ 159 - -apple | -axis | -knuth | -cray | -microblaze) 160 - os= 161 - basic_machine=$1 162 - ;; 163 - -bluegene*) 164 - os=-cnk 165 - ;; 166 - -sim | -cisco | -oki | -wec | -winbond) 167 - os= 168 - basic_machine=$1 169 - ;; 170 - -scout) 171 - ;; 172 - -wrs) 173 - os=-vxworks 174 - basic_machine=$1 175 - ;; 176 - -chorusos*) 177 - os=-chorusos 178 - basic_machine=$1 179 - ;; 180 - -chorusrdb) 181 - os=-chorusrdb 182 - basic_machine=$1 183 - ;; 184 - -hiux*) 185 - os=-hiuxwe2 186 - ;; 187 - -sco6) 188 - os=-sco5v6 189 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 190 - ;; 191 - -sco5) 192 - os=-sco3.2v5 193 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 194 - ;; 195 - -sco4) 196 - os=-sco3.2v4 197 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 198 - ;; 199 - -sco3.2.[4-9]*) 200 - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` 201 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 202 - ;; 203 - -sco3.2v[4-9]*) 204 - # Don't forget version if it is 3.2v4 or newer. 205 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 206 - ;; 207 - -sco5v6*) 208 - # Don't forget version if it is 3.2v4 or newer. 209 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 210 - ;; 211 - -sco*) 212 - os=-sco3.2v2 213 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 214 - ;; 215 - -udk*) 216 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 217 - ;; 218 - -isc) 219 - os=-isc2.2 220 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 221 - ;; 222 - -clix*) 223 - basic_machine=clipper-intergraph 224 - ;; 225 - -isc*) 226 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 227 - ;; 228 - -lynx*) 229 - os=-lynxos 230 - ;; 231 - -ptx*) 232 - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` 233 - ;; 234 - -windowsnt*) 235 - os=`echo $os | sed -e 's/windowsnt/winnt/'` 236 - ;; 237 - -psos*) 238 - os=-psos 239 - ;; 240 - -mint | -mint[0-9]*) 241 - basic_machine=m68k-atari 242 - os=-mint 243 - ;; 244 -esac 245 - 246 -# Decode aliases for certain CPU-COMPANY combinations. 247 -case $basic_machine in 248 - # Recognize the basic CPU types without company name. 249 - # Some are omitted here because they have special meanings below. 250 - 1750a | 580 \ 251 - | a29k \ 252 - | aarch64 | aarch64_be \ 253 - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ 254 - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ 255 - | am33_2.0 \ 256 - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ 257 - | be32 | be64 \ 258 - | bfin \ 259 - | c4x | clipper \ 260 - | d10v | d30v | dlx | dsp16xx \ 261 - | epiphany \ 262 - | fido | fr30 | frv \ 263 - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ 264 - | hexagon \ 265 - | i370 | i860 | i960 | ia64 \ 266 - | ip2k | iq2000 \ 267 - | le32 | le64 \ 268 - | lm32 \ 269 - | m32c | m32r | m32rle | m68000 | m68k | m88k \ 270 - | maxq | mb | microblaze | mcore | mep | metag \ 271 - | mips | mipsbe | mipseb | mipsel | mipsle \ 272 - | mips16 \ 273 - | mips64 | mips64el \ 274 - | mips64octeon | mips64octeonel \ 275 - | mips64orion | mips64orionel \ 276 - | mips64r5900 | mips64r5900el \ 277 - | mips64vr | mips64vrel \ 278 - | mips64vr4100 | mips64vr4100el \ 279 - | mips64vr4300 | mips64vr4300el \ 280 - | mips64vr5000 | mips64vr5000el \ 281 - | mips64vr5900 | mips64vr5900el \ 282 - | mipsisa32 | mipsisa32el \ 283 - | mipsisa32r2 | mipsisa32r2el \ 284 - | mipsisa64 | mipsisa64el \ 285 - | mipsisa64r2 | mipsisa64r2el \ 286 - | mipsisa64sb1 | mipsisa64sb1el \ 287 - | mipsisa64sr71k | mipsisa64sr71kel \ 288 - | mipstx39 | mipstx39el \ 289 - | mn10200 | mn10300 \ 290 - | moxie \ 291 - | mt \ 292 - | msp430 \ 293 - | nds32 | nds32le | nds32be \ 294 - | nios | nios2 \ 295 - | ns16k | ns32k \ 296 - | open8 \ 297 - | or32 \ 298 - | pdp10 | pdp11 | pj | pjl \ 299 - | powerpc | powerpc64 | powerpc64le | powerpcle \ 300 - | pyramid \ 301 - | rl78 | rx \ 302 - | score \ 303 - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ 304 - | sh64 | sh64le \ 305 - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ 306 - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ 307 - | spu \ 308 - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ 309 - | ubicom32 \ 310 - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ 311 - | we32k \ 312 - | x86 | xc16x | xstormy16 | xtensa \ 313 - | z8k | z80) 314 - basic_machine=$basic_machine-unknown 315 - ;; 316 - c54x) 317 - basic_machine=tic54x-unknown 318 - ;; 319 - c55x) 320 - basic_machine=tic55x-unknown 321 - ;; 322 - c6x) 323 - basic_machine=tic6x-unknown 324 - ;; 325 - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) 326 - basic_machine=$basic_machine-unknown 327 - os=-none 328 - ;; 329 - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) 330 - ;; 331 - ms1) 332 - basic_machine=mt-unknown 333 - ;; 334 - 335 - strongarm | thumb | xscale) 336 - basic_machine=arm-unknown 337 - ;; 338 - xgate) 339 - basic_machine=$basic_machine-unknown 340 - os=-none 341 - ;; 342 - xscaleeb) 343 - basic_machine=armeb-unknown 344 - ;; 345 - 346 - xscaleel) 347 - basic_machine=armel-unknown 348 - ;; 349 - 350 - # We use `pc' rather than `unknown' 351 - # because (1) that's what they normally are, and 352 - # (2) the word "unknown" tends to confuse beginning users. 353 - i*86 | x86_64) 354 - basic_machine=$basic_machine-pc 355 - ;; 356 - # Object if more than one company name word. 357 - *-*-*) 358 - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 359 - exit 1 360 - ;; 361 - # Recognize the basic CPU types with company name. 362 - 580-* \ 363 - | a29k-* \ 364 - | aarch64-* | aarch64_be-* \ 365 - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ 366 - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ 367 - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ 368 - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ 369 - | avr-* | avr32-* \ 370 - | be32-* | be64-* \ 371 - | bfin-* | bs2000-* \ 372 - | c[123]* | c30-* | [cjt]90-* | c4x-* \ 373 - | clipper-* | craynv-* | cydra-* \ 374 - | d10v-* | d30v-* | dlx-* \ 375 - | elxsi-* \ 376 - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ 377 - | h8300-* | h8500-* \ 378 - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ 379 - | hexagon-* \ 380 - | i*86-* | i860-* | i960-* | ia64-* \ 381 - | ip2k-* | iq2000-* \ 382 - | le32-* | le64-* \ 383 - | lm32-* \ 384 - | m32c-* | m32r-* | m32rle-* \ 385 - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ 386 - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ 387 - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ 388 - | mips16-* \ 389 - | mips64-* | mips64el-* \ 390 - | mips64octeon-* | mips64octeonel-* \ 391 - | mips64orion-* | mips64orionel-* \ 392 - | mips64r5900-* | mips64r5900el-* \ 393 - | mips64vr-* | mips64vrel-* \ 394 - | mips64vr4100-* | mips64vr4100el-* \ 395 - | mips64vr4300-* | mips64vr4300el-* \ 396 - | mips64vr5000-* | mips64vr5000el-* \ 397 - | mips64vr5900-* | mips64vr5900el-* \ 398 - | mipsisa32-* | mipsisa32el-* \ 399 - | mipsisa32r2-* | mipsisa32r2el-* \ 400 - | mipsisa64-* | mipsisa64el-* \ 401 - | mipsisa64r2-* | mipsisa64r2el-* \ 402 - | mipsisa64sb1-* | mipsisa64sb1el-* \ 403 - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ 404 - | mipstx39-* | mipstx39el-* \ 405 - | mmix-* \ 406 - | mt-* \ 407 - | msp430-* \ 408 - | nds32-* | nds32le-* | nds32be-* \ 409 - | nios-* | nios2-* \ 410 - | none-* | np1-* | ns16k-* | ns32k-* \ 411 - | open8-* \ 412 - | orion-* \ 413 - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ 414 - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ 415 - | pyramid-* \ 416 - | rl78-* | romp-* | rs6000-* | rx-* \ 417 - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ 418 - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ 419 - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ 420 - | sparclite-* \ 421 - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ 422 - | tahoe-* \ 423 - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ 424 - | tile*-* \ 425 - | tron-* \ 426 - | ubicom32-* \ 427 - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ 428 - | vax-* \ 429 - | we32k-* \ 430 - | x86-* | x86_64-* | xc16x-* | xps100-* \ 431 - | xstormy16-* | xtensa*-* \ 432 - | ymp-* \ 433 - | z8k-* | z80-*) 434 - ;; 435 - # Recognize the basic CPU types without company name, with glob match. 436 - xtensa*) 437 - basic_machine=$basic_machine-unknown 438 - ;; 439 - # Recognize the various machine names and aliases which stand 440 - # for a CPU type and a company and sometimes even an OS. 441 - 386bsd) 442 - basic_machine=i386-unknown 443 - os=-bsd 444 - ;; 445 - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) 446 - basic_machine=m68000-att 447 - ;; 448 - 3b*) 449 - basic_machine=we32k-att 450 - ;; 451 - a29khif) 452 - basic_machine=a29k-amd 453 - os=-udi 454 - ;; 455 - abacus) 456 - basic_machine=abacus-unknown 457 - ;; 458 - adobe68k) 459 - basic_machine=m68010-adobe 460 - os=-scout 461 - ;; 462 - alliant | fx80) 463 - basic_machine=fx80-alliant 464 - ;; 465 - altos | altos3068) 466 - basic_machine=m68k-altos 467 - ;; 468 - am29k) 469 - basic_machine=a29k-none 470 - os=-bsd 471 - ;; 472 - amd64) 473 - basic_machine=x86_64-pc 474 - ;; 475 - amd64-*) 476 - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` 477 - ;; 478 - amdahl) 479 - basic_machine=580-amdahl 480 - os=-sysv 481 - ;; 482 - amiga | amiga-*) 483 - basic_machine=m68k-unknown 484 - ;; 485 - amigaos | amigados) 486 - basic_machine=m68k-unknown 487 - os=-amigaos 488 - ;; 489 - amigaunix | amix) 490 - basic_machine=m68k-unknown 491 - os=-sysv4 492 - ;; 493 - apollo68) 494 - basic_machine=m68k-apollo 495 - os=-sysv 496 - ;; 497 - apollo68bsd) 498 - basic_machine=m68k-apollo 499 - os=-bsd 500 - ;; 501 - aros) 502 - basic_machine=i386-pc 503 - os=-aros 504 - ;; 505 - aux) 506 - basic_machine=m68k-apple 507 - os=-aux 508 - ;; 509 - balance) 510 - basic_machine=ns32k-sequent 511 - os=-dynix 512 - ;; 513 - blackfin) 514 - basic_machine=bfin-unknown 515 - os=-linux 516 - ;; 517 - blackfin-*) 518 - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` 519 - os=-linux 520 - ;; 521 - bluegene*) 522 - basic_machine=powerpc-ibm 523 - os=-cnk 524 - ;; 525 - c54x-*) 526 - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` 527 - ;; 528 - c55x-*) 529 - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` 530 - ;; 531 - c6x-*) 532 - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` 533 - ;; 534 - c90) 535 - basic_machine=c90-cray 536 - os=-unicos 537 - ;; 538 - cegcc) 539 - basic_machine=arm-unknown 540 - os=-cegcc 541 - ;; 542 - convex-c1) 543 - basic_machine=c1-convex 544 - os=-bsd 545 - ;; 546 - convex-c2) 547 - basic_machine=c2-convex 548 - os=-bsd 549 - ;; 550 - convex-c32) 551 - basic_machine=c32-convex 552 - os=-bsd 553 - ;; 554 - convex-c34) 555 - basic_machine=c34-convex 556 - os=-bsd 557 - ;; 558 - convex-c38) 559 - basic_machine=c38-convex 560 - os=-bsd 561 - ;; 562 - cray | j90) 563 - basic_machine=j90-cray 564 - os=-unicos 565 - ;; 566 - craynv) 567 - basic_machine=craynv-cray 568 - os=-unicosmp 569 - ;; 570 - cr16 | cr16-*) 571 - basic_machine=cr16-unknown 572 - os=-elf 573 - ;; 574 - crds | unos) 575 - basic_machine=m68k-crds 576 - ;; 577 - crisv32 | crisv32-* | etraxfs*) 578 - basic_machine=crisv32-axis 579 - ;; 580 - cris | cris-* | etrax*) 581 - basic_machine=cris-axis 582 - ;; 583 - crx) 584 - basic_machine=crx-unknown 585 - os=-elf 586 - ;; 587 - da30 | da30-*) 588 - basic_machine=m68k-da30 589 - ;; 590 - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) 591 - basic_machine=mips-dec 592 - ;; 593 - decsystem10* | dec10*) 594 - basic_machine=pdp10-dec 595 - os=-tops10 596 - ;; 597 - decsystem20* | dec20*) 598 - basic_machine=pdp10-dec 599 - os=-tops20 600 - ;; 601 - delta | 3300 | motorola-3300 | motorola-delta \ 602 - | 3300-motorola | delta-motorola) 603 - basic_machine=m68k-motorola 604 - ;; 605 - delta88) 606 - basic_machine=m88k-motorola 607 - os=-sysv3 608 - ;; 609 - dicos) 610 - basic_machine=i686-pc 611 - os=-dicos 612 - ;; 613 - djgpp) 614 - basic_machine=i586-pc 615 - os=-msdosdjgpp 616 - ;; 617 - dpx20 | dpx20-*) 618 - basic_machine=rs6000-bull 619 - os=-bosx 620 - ;; 621 - dpx2* | dpx2*-bull) 622 - basic_machine=m68k-bull 623 - os=-sysv3 624 - ;; 625 - ebmon29k) 626 - basic_machine=a29k-amd 627 - os=-ebmon 628 - ;; 629 - elxsi) 630 - basic_machine=elxsi-elxsi 631 - os=-bsd 632 - ;; 633 - encore | umax | mmax) 634 - basic_machine=ns32k-encore 635 - ;; 636 - es1800 | OSE68k | ose68k | ose | OSE) 637 - basic_machine=m68k-ericsson 638 - os=-ose 639 - ;; 640 - fx2800) 641 - basic_machine=i860-alliant 642 - ;; 643 - genix) 644 - basic_machine=ns32k-ns 645 - ;; 646 - gmicro) 647 - basic_machine=tron-gmicro 648 - os=-sysv 649 - ;; 650 - go32) 651 - basic_machine=i386-pc 652 - os=-go32 653 - ;; 654 - h3050r* | hiux*) 655 - basic_machine=hppa1.1-hitachi 656 - os=-hiuxwe2 657 - ;; 658 - h8300hms) 659 - basic_machine=h8300-hitachi 660 - os=-hms 661 - ;; 662 - h8300xray) 663 - basic_machine=h8300-hitachi 664 - os=-xray 665 - ;; 666 - h8500hms) 667 - basic_machine=h8500-hitachi 668 - os=-hms 669 - ;; 670 - harris) 671 - basic_machine=m88k-harris 672 - os=-sysv3 673 - ;; 674 - hp300-*) 675 - basic_machine=m68k-hp 676 - ;; 677 - hp300bsd) 678 - basic_machine=m68k-hp 679 - os=-bsd 680 - ;; 681 - hp300hpux) 682 - basic_machine=m68k-hp 683 - os=-hpux 684 - ;; 685 - hp3k9[0-9][0-9] | hp9[0-9][0-9]) 686 - basic_machine=hppa1.0-hp 687 - ;; 688 - hp9k2[0-9][0-9] | hp9k31[0-9]) 689 - basic_machine=m68000-hp 690 - ;; 691 - hp9k3[2-9][0-9]) 692 - basic_machine=m68k-hp 693 - ;; 694 - hp9k6[0-9][0-9] | hp6[0-9][0-9]) 695 - basic_machine=hppa1.0-hp 696 - ;; 697 - hp9k7[0-79][0-9] | hp7[0-79][0-9]) 698 - basic_machine=hppa1.1-hp 699 - ;; 700 - hp9k78[0-9] | hp78[0-9]) 701 - # FIXME: really hppa2.0-hp 702 - basic_machine=hppa1.1-hp 703 - ;; 704 - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) 705 - # FIXME: really hppa2.0-hp 706 - basic_machine=hppa1.1-hp 707 - ;; 708 - hp9k8[0-9][13679] | hp8[0-9][13679]) 709 - basic_machine=hppa1.1-hp 710 - ;; 711 - hp9k8[0-9][0-9] | hp8[0-9][0-9]) 712 - basic_machine=hppa1.0-hp 713 - ;; 714 - hppa-next) 715 - os=-nextstep3 716 - ;; 717 - hppaosf) 718 - basic_machine=hppa1.1-hp 719 - os=-osf 720 - ;; 721 - hppro) 722 - basic_machine=hppa1.1-hp 723 - os=-proelf 724 - ;; 725 - i370-ibm* | ibm*) 726 - basic_machine=i370-ibm 727 - ;; 728 - i*86v32) 729 - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 730 - os=-sysv32 731 - ;; 732 - i*86v4*) 733 - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 734 - os=-sysv4 735 - ;; 736 - i*86v) 737 - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 738 - os=-sysv 739 - ;; 740 - i*86sol2) 741 - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 742 - os=-solaris2 743 - ;; 744 - i386mach) 745 - basic_machine=i386-mach 746 - os=-mach 747 - ;; 748 - i386-vsta | vsta) 749 - basic_machine=i386-unknown 750 - os=-vsta 751 - ;; 752 - iris | iris4d) 753 - basic_machine=mips-sgi 754 - case $os in 755 - -irix*) 756 - ;; 757 - *) 758 - os=-irix4 759 - ;; 760 - esac 761 - ;; 762 - isi68 | isi) 763 - basic_machine=m68k-isi 764 - os=-sysv 765 - ;; 766 - m68knommu) 767 - basic_machine=m68k-unknown 768 - os=-linux 769 - ;; 770 - m68knommu-*) 771 - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` 772 - os=-linux 773 - ;; 774 - m88k-omron*) 775 - basic_machine=m88k-omron 776 - ;; 777 - magnum | m3230) 778 - basic_machine=mips-mips 779 - os=-sysv 780 - ;; 781 - merlin) 782 - basic_machine=ns32k-utek 783 - os=-sysv 784 - ;; 785 - microblaze) 786 - basic_machine=microblaze-xilinx 787 - ;; 788 - mingw32) 789 - basic_machine=i386-pc 790 - os=-mingw32 791 - ;; 792 - mingw32ce) 793 - basic_machine=arm-unknown 794 - os=-mingw32ce 795 - ;; 796 - miniframe) 797 - basic_machine=m68000-convergent 798 - ;; 799 - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) 800 - basic_machine=m68k-atari 801 - os=-mint 802 - ;; 803 - mips3*-*) 804 - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` 805 - ;; 806 - mips3*) 807 - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown 808 - ;; 809 - monitor) 810 - basic_machine=m68k-rom68k 811 - os=-coff 812 - ;; 813 - morphos) 814 - basic_machine=powerpc-unknown 815 - os=-morphos 816 - ;; 817 - msdos) 818 - basic_machine=i386-pc 819 - os=-msdos 820 - ;; 821 - ms1-*) 822 - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` 823 - ;; 824 - msys) 825 - basic_machine=i386-pc 826 - os=-msys 827 - ;; 828 - mvs) 829 - basic_machine=i370-ibm 830 - os=-mvs 831 - ;; 832 - nacl) 833 - basic_machine=le32-unknown 834 - os=-nacl 835 - ;; 836 - ncr3000) 837 - basic_machine=i486-ncr 838 - os=-sysv4 839 - ;; 840 - netbsd386) 841 - basic_machine=i386-unknown 842 - os=-netbsd 843 - ;; 844 - netwinder) 845 - basic_machine=armv4l-rebel 846 - os=-linux 847 - ;; 848 - news | news700 | news800 | news900) 849 - basic_machine=m68k-sony 850 - os=-newsos 851 - ;; 852 - news1000) 853 - basic_machine=m68030-sony 854 - os=-newsos 855 - ;; 856 - news-3600 | risc-news) 857 - basic_machine=mips-sony 858 - os=-newsos 859 - ;; 860 - necv70) 861 - basic_machine=v70-nec 862 - os=-sysv 863 - ;; 864 - next | m*-next ) 865 - basic_machine=m68k-next 866 - case $os in 867 - -nextstep* ) 868 - ;; 869 - -ns2*) 870 - os=-nextstep2 871 - ;; 872 - *) 873 - os=-nextstep3 874 - ;; 875 - esac 876 - ;; 877 - nh3000) 878 - basic_machine=m68k-harris 879 - os=-cxux 880 - ;; 881 - nh[45]000) 882 - basic_machine=m88k-harris 883 - os=-cxux 884 - ;; 885 - nindy960) 886 - basic_machine=i960-intel 887 - os=-nindy 888 - ;; 889 - mon960) 890 - basic_machine=i960-intel 891 - os=-mon960 892 - ;; 893 - nonstopux) 894 - basic_machine=mips-compaq 895 - os=-nonstopux 896 - ;; 897 - np1) 898 - basic_machine=np1-gould 899 - ;; 900 - neo-tandem) 901 - basic_machine=neo-tandem 902 - ;; 903 - nse-tandem) 904 - basic_machine=nse-tandem 905 - ;; 906 - nsr-tandem) 907 - basic_machine=nsr-tandem 908 - ;; 909 - op50n-* | op60c-*) 910 - basic_machine=hppa1.1-oki 911 - os=-proelf 912 - ;; 913 - openrisc | openrisc-*) 914 - basic_machine=or32-unknown 915 - ;; 916 - os400) 917 - basic_machine=powerpc-ibm 918 - os=-os400 919 - ;; 920 - OSE68000 | ose68000) 921 - basic_machine=m68000-ericsson 922 - os=-ose 923 - ;; 924 - os68k) 925 - basic_machine=m68k-none 926 - os=-os68k 927 - ;; 928 - pa-hitachi) 929 - basic_machine=hppa1.1-hitachi 930 - os=-hiuxwe2 931 - ;; 932 - paragon) 933 - basic_machine=i860-intel 934 - os=-osf 935 - ;; 936 - parisc) 937 - basic_machine=hppa-unknown 938 - os=-linux 939 - ;; 940 - parisc-*) 941 - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` 942 - os=-linux 943 - ;; 944 - pbd) 945 - basic_machine=sparc-tti 946 - ;; 947 - pbb) 948 - basic_machine=m68k-tti 949 - ;; 950 - pc532 | pc532-*) 951 - basic_machine=ns32k-pc532 952 - ;; 953 - pc98) 954 - basic_machine=i386-pc 955 - ;; 956 - pc98-*) 957 - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` 958 - ;; 959 - pentium | p5 | k5 | k6 | nexgen | viac3) 960 - basic_machine=i586-pc 961 - ;; 962 - pentiumpro | p6 | 6x86 | athlon | athlon_*) 963 - basic_machine=i686-pc 964 - ;; 965 - pentiumii | pentium2 | pentiumiii | pentium3) 966 - basic_machine=i686-pc 967 - ;; 968 - pentium4) 969 - basic_machine=i786-pc 970 - ;; 971 - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) 972 - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` 973 - ;; 974 - pentiumpro-* | p6-* | 6x86-* | athlon-*) 975 - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 976 - ;; 977 - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) 978 - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 979 - ;; 980 - pentium4-*) 981 - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` 982 - ;; 983 - pn) 984 - basic_machine=pn-gould 985 - ;; 986 - power) basic_machine=power-ibm 987 - ;; 988 - ppc | ppcbe) basic_machine=powerpc-unknown 989 - ;; 990 - ppc-* | ppcbe-*) 991 - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` 992 - ;; 993 - ppcle | powerpclittle | ppc-le | powerpc-little) 994 - basic_machine=powerpcle-unknown 995 - ;; 996 - ppcle-* | powerpclittle-*) 997 - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` 998 - ;; 999 - ppc64) basic_machine=powerpc64-unknown 1000 - ;; 1001 - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` 1002 - ;; 1003 - ppc64le | powerpc64little | ppc64-le | powerpc64-little) 1004 - basic_machine=powerpc64le-unknown 1005 - ;; 1006 - ppc64le-* | powerpc64little-*) 1007 - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` 1008 - ;; 1009 - ps2) 1010 - basic_machine=i386-ibm 1011 - ;; 1012 - pw32) 1013 - basic_machine=i586-unknown 1014 - os=-pw32 1015 - ;; 1016 - rdos) 1017 - basic_machine=i386-pc 1018 - os=-rdos 1019 - ;; 1020 - rom68k) 1021 - basic_machine=m68k-rom68k 1022 - os=-coff 1023 - ;; 1024 - rm[46]00) 1025 - basic_machine=mips-siemens 1026 - ;; 1027 - rtpc | rtpc-*) 1028 - basic_machine=romp-ibm 1029 - ;; 1030 - s390 | s390-*) 1031 - basic_machine=s390-ibm 1032 - ;; 1033 - s390x | s390x-*) 1034 - basic_machine=s390x-ibm 1035 - ;; 1036 - sa29200) 1037 - basic_machine=a29k-amd 1038 - os=-udi 1039 - ;; 1040 - sb1) 1041 - basic_machine=mipsisa64sb1-unknown 1042 - ;; 1043 - sb1el) 1044 - basic_machine=mipsisa64sb1el-unknown 1045 - ;; 1046 - sde) 1047 - basic_machine=mipsisa32-sde 1048 - os=-elf 1049 - ;; 1050 - sei) 1051 - basic_machine=mips-sei 1052 - os=-seiux 1053 - ;; 1054 - sequent) 1055 - basic_machine=i386-sequent 1056 - ;; 1057 - sh) 1058 - basic_machine=sh-hitachi 1059 - os=-hms 1060 - ;; 1061 - sh5el) 1062 - basic_machine=sh5le-unknown 1063 - ;; 1064 - sh64) 1065 - basic_machine=sh64-unknown 1066 - ;; 1067 - sparclite-wrs | simso-wrs) 1068 - basic_machine=sparclite-wrs 1069 - os=-vxworks 1070 - ;; 1071 - sps7) 1072 - basic_machine=m68k-bull 1073 - os=-sysv2 1074 - ;; 1075 - spur) 1076 - basic_machine=spur-unknown 1077 - ;; 1078 - st2000) 1079 - basic_machine=m68k-tandem 1080 - ;; 1081 - stratus) 1082 - basic_machine=i860-stratus 1083 - os=-sysv4 1084 - ;; 1085 - strongarm-* | thumb-*) 1086 - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` 1087 - ;; 1088 - sun2) 1089 - basic_machine=m68000-sun 1090 - ;; 1091 - sun2os3) 1092 - basic_machine=m68000-sun 1093 - os=-sunos3 1094 - ;; 1095 - sun2os4) 1096 - basic_machine=m68000-sun 1097 - os=-sunos4 1098 - ;; 1099 - sun3os3) 1100 - basic_machine=m68k-sun 1101 - os=-sunos3 1102 - ;; 1103 - sun3os4) 1104 - basic_machine=m68k-sun 1105 - os=-sunos4 1106 - ;; 1107 - sun4os3) 1108 - basic_machine=sparc-sun 1109 - os=-sunos3 1110 - ;; 1111 - sun4os4) 1112 - basic_machine=sparc-sun 1113 - os=-sunos4 1114 - ;; 1115 - sun4sol2) 1116 - basic_machine=sparc-sun 1117 - os=-solaris2 1118 - ;; 1119 - sun3 | sun3-*) 1120 - basic_machine=m68k-sun 1121 - ;; 1122 - sun4) 1123 - basic_machine=sparc-sun 1124 - ;; 1125 - sun386 | sun386i | roadrunner) 1126 - basic_machine=i386-sun 1127 - ;; 1128 - sv1) 1129 - basic_machine=sv1-cray 1130 - os=-unicos 1131 - ;; 1132 - symmetry) 1133 - basic_machine=i386-sequent 1134 - os=-dynix 1135 - ;; 1136 - t3e) 1137 - basic_machine=alphaev5-cray 1138 - os=-unicos 1139 - ;; 1140 - t90) 1141 - basic_machine=t90-cray 1142 - os=-unicos 1143 - ;; 1144 - tile*) 1145 - basic_machine=$basic_machine-unknown 1146 - os=-linux-gnu 1147 - ;; 1148 - tx39) 1149 - basic_machine=mipstx39-unknown 1150 - ;; 1151 - tx39el) 1152 - basic_machine=mipstx39el-unknown 1153 - ;; 1154 - toad1) 1155 - basic_machine=pdp10-xkl 1156 - os=-tops20 1157 - ;; 1158 - tower | tower-32) 1159 - basic_machine=m68k-ncr 1160 - ;; 1161 - tpf) 1162 - basic_machine=s390x-ibm 1163 - os=-tpf 1164 - ;; 1165 - udi29k) 1166 - basic_machine=a29k-amd 1167 - os=-udi 1168 - ;; 1169 - ultra3) 1170 - basic_machine=a29k-nyu 1171 - os=-sym1 1172 - ;; 1173 - v810 | necv810) 1174 - basic_machine=v810-nec 1175 - os=-none 1176 - ;; 1177 - vaxv) 1178 - basic_machine=vax-dec 1179 - os=-sysv 1180 - ;; 1181 - vms) 1182 - basic_machine=vax-dec 1183 - os=-vms 1184 - ;; 1185 - vpp*|vx|vx-*) 1186 - basic_machine=f301-fujitsu 1187 - ;; 1188 - vxworks960) 1189 - basic_machine=i960-wrs 1190 - os=-vxworks 1191 - ;; 1192 - vxworks68) 1193 - basic_machine=m68k-wrs 1194 - os=-vxworks 1195 - ;; 1196 - vxworks29k) 1197 - basic_machine=a29k-wrs 1198 - os=-vxworks 1199 - ;; 1200 - w65*) 1201 - basic_machine=w65-wdc 1202 - os=-none 1203 - ;; 1204 - w89k-*) 1205 - basic_machine=hppa1.1-winbond 1206 - os=-proelf 1207 - ;; 1208 - xbox) 1209 - basic_machine=i686-pc 1210 - os=-mingw32 1211 - ;; 1212 - xps | xps100) 1213 - basic_machine=xps100-honeywell 1214 - ;; 1215 - xscale-* | xscalee[bl]-*) 1216 - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` 1217 - ;; 1218 - ymp) 1219 - basic_machine=ymp-cray 1220 - os=-unicos 1221 - ;; 1222 - z8k-*-coff) 1223 - basic_machine=z8k-unknown 1224 - os=-sim 1225 - ;; 1226 - z80-*-coff) 1227 - basic_machine=z80-unknown 1228 - os=-sim 1229 - ;; 1230 - none) 1231 - basic_machine=none-none 1232 - os=-none 1233 - ;; 1234 - 1235 -# Here we handle the default manufacturer of certain CPU types. It is in 1236 -# some cases the only manufacturer, in others, it is the most popular. 1237 - w89k) 1238 - basic_machine=hppa1.1-winbond 1239 - ;; 1240 - op50n) 1241 - basic_machine=hppa1.1-oki 1242 - ;; 1243 - op60c) 1244 - basic_machine=hppa1.1-oki 1245 - ;; 1246 - romp) 1247 - basic_machine=romp-ibm 1248 - ;; 1249 - mmix) 1250 - basic_machine=mmix-knuth 1251 - ;; 1252 - rs6000) 1253 - basic_machine=rs6000-ibm 1254 - ;; 1255 - vax) 1256 - basic_machine=vax-dec 1257 - ;; 1258 - pdp10) 1259 - # there are many clones, so DEC is not a safe bet 1260 - basic_machine=pdp10-unknown 1261 - ;; 1262 - pdp11) 1263 - basic_machine=pdp11-dec 1264 - ;; 1265 - we32k) 1266 - basic_machine=we32k-att 1267 - ;; 1268 - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) 1269 - basic_machine=sh-unknown 1270 - ;; 1271 - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) 1272 - basic_machine=sparc-sun 1273 - ;; 1274 - cydra) 1275 - basic_machine=cydra-cydrome 1276 - ;; 1277 - orion) 1278 - basic_machine=orion-highlevel 1279 - ;; 1280 - orion105) 1281 - basic_machine=clipper-highlevel 1282 - ;; 1283 - mac | mpw | mac-mpw) 1284 - basic_machine=m68k-apple 1285 - ;; 1286 - pmac | pmac-mpw) 1287 - basic_machine=powerpc-apple 1288 - ;; 1289 - *-unknown) 1290 - # Make sure to match an already-canonicalized machine name. 1291 - ;; 1292 - *) 1293 - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 1294 - exit 1 1295 - ;; 1296 -esac 1297 - 1298 -# Here we canonicalize certain aliases for manufacturers. 1299 -case $basic_machine in 1300 - *-digital*) 1301 - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` 1302 - ;; 1303 - *-commodore*) 1304 - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` 1305 - ;; 1306 - *) 1307 - ;; 1308 -esac 1309 - 1310 -# Decode manufacturer-specific aliases for certain operating systems. 1311 - 1312 -if [ x"$os" != x"" ] 1313 -then 1314 -case $os in 1315 - # First match some system type aliases 1316 - # that might get confused with valid system types. 1317 - # -solaris* is a basic system type, with this one exception. 1318 - -auroraux) 1319 - os=-auroraux 1320 - ;; 1321 - -solaris1 | -solaris1.*) 1322 - os=`echo $os | sed -e 's|solaris1|sunos4|'` 1323 - ;; 1324 - -solaris) 1325 - os=-solaris2 1326 - ;; 1327 - -svr4*) 1328 - os=-sysv4 1329 - ;; 1330 - -unixware*) 1331 - os=-sysv4.2uw 1332 - ;; 1333 - -gnu/linux*) 1334 - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` 1335 - ;; 1336 - # First accept the basic system types. 1337 - # The portable systems comes first. 1338 - # Each alternative MUST END IN A *, to match a version number. 1339 - # -sysv* is not here because it comes later, after sysvr4. 1340 - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ 1341 - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ 1342 - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ 1343 - | -sym* | -kopensolaris* \ 1344 - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ 1345 - | -aos* | -aros* \ 1346 - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ 1347 - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ 1348 - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ 1349 - | -openbsd* | -solidbsd* \ 1350 - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ 1351 - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ 1352 - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ 1353 - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ 1354 - | -chorusos* | -chorusrdb* | -cegcc* \ 1355 - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ 1356 - | -mingw32* | -linux-gnu* | -linux-android* \ 1357 - | -linux-newlib* | -linux-uclibc* \ 1358 - | -uxpv* | -beos* | -mpeix* | -udk* \ 1359 - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ 1360 - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ 1361 - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ 1362 - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ 1363 - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ 1364 - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ 1365 - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) 1366 - # Remember, each alternative MUST END IN *, to match a version number. 1367 - ;; 1368 - -qnx*) 1369 - case $basic_machine in 1370 - x86-* | i*86-*) 1371 - ;; 1372 - *) 1373 - os=-nto$os 1374 - ;; 1375 - esac 1376 - ;; 1377 - -nto-qnx*) 1378 - ;; 1379 - -nto*) 1380 - os=`echo $os | sed -e 's|nto|nto-qnx|'` 1381 - ;; 1382 - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ 1383 - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ 1384 - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) 1385 - ;; 1386 - -mac*) 1387 - os=`echo $os | sed -e 's|mac|macos|'` 1388 - ;; 1389 - -linux-dietlibc) 1390 - os=-linux-dietlibc 1391 - ;; 1392 - -linux*) 1393 - os=`echo $os | sed -e 's|linux|linux-gnu|'` 1394 - ;; 1395 - -sunos5*) 1396 - os=`echo $os | sed -e 's|sunos5|solaris2|'` 1397 - ;; 1398 - -sunos6*) 1399 - os=`echo $os | sed -e 's|sunos6|solaris3|'` 1400 - ;; 1401 - -opened*) 1402 - os=-openedition 1403 - ;; 1404 - -os400*) 1405 - os=-os400 1406 - ;; 1407 - -wince*) 1408 - os=-wince 1409 - ;; 1410 - -osfrose*) 1411 - os=-osfrose 1412 - ;; 1413 - -osf*) 1414 - os=-osf 1415 - ;; 1416 - -utek*) 1417 - os=-bsd 1418 - ;; 1419 - -dynix*) 1420 - os=-bsd 1421 - ;; 1422 - -acis*) 1423 - os=-aos 1424 - ;; 1425 - -atheos*) 1426 - os=-atheos 1427 - ;; 1428 - -syllable*) 1429 - os=-syllable 1430 - ;; 1431 - -386bsd) 1432 - os=-bsd 1433 - ;; 1434 - -ctix* | -uts*) 1435 - os=-sysv 1436 - ;; 1437 - -nova*) 1438 - os=-rtmk-nova 1439 - ;; 1440 - -ns2 ) 1441 - os=-nextstep2 1442 - ;; 1443 - -nsk*) 1444 - os=-nsk 1445 - ;; 1446 - # Preserve the version number of sinix5. 1447 - -sinix5.*) 1448 - os=`echo $os | sed -e 's|sinix|sysv|'` 1449 - ;; 1450 - -sinix*) 1451 - os=-sysv4 1452 - ;; 1453 - -tpf*) 1454 - os=-tpf 1455 - ;; 1456 - -triton*) 1457 - os=-sysv3 1458 - ;; 1459 - -oss*) 1460 - os=-sysv3 1461 - ;; 1462 - -svr4) 1463 - os=-sysv4 1464 - ;; 1465 - -svr3) 1466 - os=-sysv3 1467 - ;; 1468 - -sysvr4) 1469 - os=-sysv4 1470 - ;; 1471 - # This must come after -sysvr4. 1472 - -sysv*) 1473 - ;; 1474 - -ose*) 1475 - os=-ose 1476 - ;; 1477 - -es1800*) 1478 - os=-ose 1479 - ;; 1480 - -xenix) 1481 - os=-xenix 1482 - ;; 1483 - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1484 - os=-mint 1485 - ;; 1486 - -aros*) 1487 - os=-aros 1488 - ;; 1489 - -kaos*) 1490 - os=-kaos 1491 - ;; 1492 - -zvmoe) 1493 - os=-zvmoe 1494 - ;; 1495 - -dicos*) 1496 - os=-dicos 1497 - ;; 1498 - -nacl*) 1499 - ;; 1500 - -none) 1501 - ;; 1502 - *) 1503 - # Get rid of the `-' at the beginning of $os. 1504 - os=`echo $os | sed 's/[^-]*-//'` 1505 - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 1506 - exit 1 1507 - ;; 1508 -esac 1509 -else 1510 - 1511 -# Here we handle the default operating systems that come with various machines. 1512 -# The value should be what the vendor currently ships out the door with their 1513 -# machine or put another way, the most popular os provided with the machine. 1514 - 1515 -# Note that if you're going to try to match "-MANUFACTURER" here (say, 1516 -# "-sun"), then you have to tell the case statement up towards the top 1517 -# that MANUFACTURER isn't an operating system. Otherwise, code above 1518 -# will signal an error saying that MANUFACTURER isn't an operating 1519 -# system, and we'll never get to this point. 1520 - 1521 -case $basic_machine in 1522 - score-*) 1523 - os=-elf 1524 - ;; 1525 - spu-*) 1526 - os=-elf 1527 - ;; 1528 - *-acorn) 1529 - os=-riscix1.2 1530 - ;; 1531 - arm*-rebel) 1532 - os=-linux 1533 - ;; 1534 - arm*-semi) 1535 - os=-aout 1536 - ;; 1537 - c4x-* | tic4x-*) 1538 - os=-coff 1539 - ;; 1540 - tic54x-*) 1541 - os=-coff 1542 - ;; 1543 - tic55x-*) 1544 - os=-coff 1545 - ;; 1546 - tic6x-*) 1547 - os=-coff 1548 - ;; 1549 - # This must come before the *-dec entry. 1550 - pdp10-*) 1551 - os=-tops20 1552 - ;; 1553 - pdp11-*) 1554 - os=-none 1555 - ;; 1556 - *-dec | vax-*) 1557 - os=-ultrix4.2 1558 - ;; 1559 - m68*-apollo) 1560 - os=-domain 1561 - ;; 1562 - i386-sun) 1563 - os=-sunos4.0.2 1564 - ;; 1565 - m68000-sun) 1566 - os=-sunos3 1567 - ;; 1568 - m68*-cisco) 1569 - os=-aout 1570 - ;; 1571 - mep-*) 1572 - os=-elf 1573 - ;; 1574 - mips*-cisco) 1575 - os=-elf 1576 - ;; 1577 - mips*-*) 1578 - os=-elf 1579 - ;; 1580 - or32-*) 1581 - os=-coff 1582 - ;; 1583 - *-tti) # must be before sparc entry or we get the wrong os. 1584 - os=-sysv3 1585 - ;; 1586 - sparc-* | *-sun) 1587 - os=-sunos4.1.1 1588 - ;; 1589 - *-be) 1590 - os=-beos 1591 - ;; 1592 - *-haiku) 1593 - os=-haiku 1594 - ;; 1595 - *-ibm) 1596 - os=-aix 1597 - ;; 1598 - *-knuth) 1599 - os=-mmixware 1600 - ;; 1601 - *-wec) 1602 - os=-proelf 1603 - ;; 1604 - *-winbond) 1605 - os=-proelf 1606 - ;; 1607 - *-oki) 1608 - os=-proelf 1609 - ;; 1610 - *-hp) 1611 - os=-hpux 1612 - ;; 1613 - *-hitachi) 1614 - os=-hiux 1615 - ;; 1616 - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) 1617 - os=-sysv 1618 - ;; 1619 - *-cbm) 1620 - os=-amigaos 1621 - ;; 1622 - *-dg) 1623 - os=-dgux 1624 - ;; 1625 - *-dolphin) 1626 - os=-sysv3 1627 - ;; 1628 - m68k-ccur) 1629 - os=-rtu 1630 - ;; 1631 - m88k-omron*) 1632 - os=-luna 1633 - ;; 1634 - *-next ) 1635 - os=-nextstep 1636 - ;; 1637 - *-sequent) 1638 - os=-ptx 1639 - ;; 1640 - *-crds) 1641 - os=-unos 1642 - ;; 1643 - *-ns) 1644 - os=-genix 1645 - ;; 1646 - i370-*) 1647 - os=-mvs 1648 - ;; 1649 - *-next) 1650 - os=-nextstep3 1651 - ;; 1652 - *-gould) 1653 - os=-sysv 1654 - ;; 1655 - *-highlevel) 1656 - os=-bsd 1657 - ;; 1658 - *-encore) 1659 - os=-bsd 1660 - ;; 1661 - *-sgi) 1662 - os=-irix 1663 - ;; 1664 - *-siemens) 1665 - os=-sysv4 1666 - ;; 1667 - *-masscomp) 1668 - os=-rtu 1669 - ;; 1670 - f30[01]-fujitsu | f700-fujitsu) 1671 - os=-uxpv 1672 - ;; 1673 - *-rom68k) 1674 - os=-coff 1675 - ;; 1676 - *-*bug) 1677 - os=-coff 1678 - ;; 1679 - *-apple) 1680 - os=-macos 1681 - ;; 1682 - *-atari*) 1683 - os=-mint 1684 - ;; 1685 - *) 1686 - os=-none 1687 - ;; 1688 -esac 1689 -fi 1690 - 1691 -# Here we handle the case where we know the os, and the CPU type, but not the 1692 -# manufacturer. We pick the logical manufacturer. 1693 -vendor=unknown 1694 -case $basic_machine in 1695 - *-unknown) 1696 - case $os in 1697 - -riscix*) 1698 - vendor=acorn 1699 - ;; 1700 - -sunos*) 1701 - vendor=sun 1702 - ;; 1703 - -cnk*|-aix*) 1704 - vendor=ibm 1705 - ;; 1706 - -beos*) 1707 - vendor=be 1708 - ;; 1709 - -hpux*) 1710 - vendor=hp 1711 - ;; 1712 - -mpeix*) 1713 - vendor=hp 1714 - ;; 1715 - -hiux*) 1716 - vendor=hitachi 1717 - ;; 1718 - -unos*) 1719 - vendor=crds 1720 - ;; 1721 - -dgux*) 1722 - vendor=dg 1723 - ;; 1724 - -luna*) 1725 - vendor=omron 1726 - ;; 1727 - -genix*) 1728 - vendor=ns 1729 - ;; 1730 - -mvs* | -opened*) 1731 - vendor=ibm 1732 - ;; 1733 - -os400*) 1734 - vendor=ibm 1735 - ;; 1736 - -ptx*) 1737 - vendor=sequent 1738 - ;; 1739 - -tpf*) 1740 - vendor=ibm 1741 - ;; 1742 - -vxsim* | -vxworks* | -windiss*) 1743 - vendor=wrs 1744 - ;; 1745 - -aux*) 1746 - vendor=apple 1747 - ;; 1748 - -hms*) 1749 - vendor=hitachi 1750 - ;; 1751 - -mpw* | -macos*) 1752 - vendor=apple 1753 - ;; 1754 - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1755 - vendor=atari 1756 - ;; 1757 - -vos*) 1758 - vendor=stratus 1759 - ;; 1760 - esac 1761 - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` 1762 - ;; 1763 -esac 1764 - 1765 -echo $basic_machine$os 1766 -exit 1767 - 1768 -# Local variables: 1769 -# eval: (add-hook 'write-file-hooks 'time-stamp) 1770 -# time-stamp-start: "timestamp='" 1771 -# time-stamp-format: "%:y-%02m-%02d" 1772 -# time-stamp-end: "'" 1773 -# End:
Deleted configure.
more than 10,000 changes
Deleted configure.ac.
1 -# -*- Autoconf -*- 2 -# Process this file with autoconf to produce a configure script. 3 - 4 -AC_PREREQ(2.61) 5 -AC_INIT(libgaiagraphics, 0.5, a.furieri @ lqt.it) 6 -AC_LANG(C) 7 -AC_CONFIG_AUX_DIR([.]) 8 -AC_CONFIG_MACRO_DIR([m4]) 9 - 10 -AM_INIT_AUTOMAKE 11 -AM_MAINTAINER_MODE 12 - 13 -# Checks for header files. 14 -AC_CHECK_HEADERS(stdlib.h,, [AC_MSG_ERROR([cannot find stdlib.h, bailing out])]) 15 -AC_CHECK_HEADERS(stdio.h,,[AC_MSG_ERROR([cannot find stdio.h, bailing out])]) 16 -AC_CHECK_HEADERS(string.h,, [AC_MSG_ERROR([cannot find string.h, bailing out])]) 17 -AC_CHECK_HEADERS(memory.h,, [AC_MSG_ERROR([cannot find memory.h, bailing out])]) 18 -AC_CHECK_HEADERS(math.h,,[AC_MSG_ERROR([cannot find math.h, bailing out])]) 19 -AC_CHECK_HEADERS(float.h,,[AC_MSG_ERROR([cannot find float.h, bailing out])]) 20 -AC_CHECK_HEADERS(fcntl.h,,[AC_MSG_ERROR([cannot find fcntl.h, bailing out])]) 21 -AC_CHECK_HEADERS(inttypes.h,, [AC_MSG_ERROR([cannot find inttypes.h, bailing out])]) 22 -AC_CHECK_HEADERS(stddef.h,, [AC_MSG_ERROR([cannot find stddef.h, bailing out])]) 23 -AC_CHECK_HEADERS(stdint.h,, [AC_MSG_ERROR([cannot find stdint.h, bailing out])]) 24 -AC_CHECK_HEADERS(sys/time.h,, [AC_MSG_ERROR([cannot find sys/time.h, bailing out])]) 25 -AC_CHECK_HEADERS(unistd.h,, [AC_MSG_ERROR([cannot find unistd.h, bailing out])]) 26 -AC_CHECK_HEADERS(jpeglib.h,, [AC_MSG_ERROR([cannot find jpeglib.h, bailing out])]) 27 -AC_CHECK_HEADERS(jerror.h,, [AC_MSG_ERROR([cannot find jerror.h, bailing out])]) 28 - 29 -# 30 -# testing GeoTiff headers 31 -# on some systems they are located on -/include 32 -# on other systems they are on -/include/geotiff 33 -# or even on -/include/libgeotiff 34 -# 35 -# this patch was kindly contributed by Brad Hards 36 -# 2011-09-02 37 -# 38 -AC_CHECK_HEADERS(geotiff/geotiff.h) 39 -AC_CHECK_HEADERS(libgeotiff/geotiff.h) 40 -AC_CHECK_HEADERS(geotiff.h) 41 -if test x"$ac_cv_header_geotiff_geotiff_h" != x"yes" && 42 - test x"$ac_cv_header_libgeotiff_geotiff_h" != x"yes" && 43 - test x"$ac_cv_header_geotiff_h" != x"yes"; 44 -then 45 - AC_MSG_ERROR(['libgeotiff' is required but the header (geotiff.h) doesn't seem to be installed on this system]) 46 -fi 47 - 48 -# Checks for programs. 49 -AC_PROG_CXX 50 -AC_PROG_CC 51 -AC_PROG_CPP 52 -AC_PROG_INSTALL 53 -AC_PROG_LN_S 54 -AC_PROG_MAKE_SET 55 -AC_LIBTOOL_WIN32_DLL 56 -AC_PROG_LIBTOOL 57 - 58 -# Checks for typedefs, structures, and compiler characteristics. 59 -AC_C_CONST 60 -AC_TYPE_OFF_T 61 -AC_TYPE_SIZE_T 62 -AC_HEADER_TIME 63 -AC_STRUCT_TM 64 -AC_C_VOLATILE 65 - 66 -# Checks for library functions. 67 -AC_FUNC_LSTAT 68 -AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK 69 -AC_FUNC_MEMCMP 70 -AC_FUNC_STAT 71 -AC_FUNC_STRFTIME 72 -AC_CHECK_FUNCS([memset sqrt strcasecmp strerror strncasecmp strstr fdatasync ftruncate getcwd gettimeofday localtime_r memmove strerror]) 73 - 74 -# Checks for installed libraries 75 -AC_CHECK_LIB(z,inflateInit_,,AC_MSG_ERROR(['libz' is required but it doesn't seems to be installed on this system.]),-lm) 76 -AC_CHECK_LIB(jpeg,jpeg_start_compress,,AC_MSG_ERROR(['libjpeg' is required but it doesn't seems to be installed on this system.]),-lm) 77 -AC_CHECK_LIB(tiff,TIFFClientOpen,,AC_MSG_ERROR(['libtiff' is required but it doesn't seems to be installed on this system.]),-lm) 78 -AC_CHECK_LIB(proj,pj_init_plus,,AC_MSG_ERROR(['libproj' is required but it doesn't seems to be installed on this system.]),-lm) 79 -AC_CHECK_LIB(geotiff,GTIFSetFromProj4,,AC_MSG_ERROR(['libgeotiff' [>= v.1.2.5] is required but it doesn't seems to be installed on this system.]),-lm) 80 - 81 -PKG_CHECK_MODULES([LIBPNG], [libpng], , AC_MSG_ERROR(['libpng' is required but it doesn't seems to be installed on this system.])) 82 -AC_SUBST(LIBPNG_CFLAGS) 83 -AC_SUBST(LIBPNG_LIBS) 84 - 85 -PKG_CHECK_MODULES([LIBCAIRO], [cairo], , AC_MSG_ERROR(['libcairo' is required but it doesn't seems to be installed on this system.])) 86 -AC_SUBST(LIBCAIRO_CFLAGS) 87 -AC_SUBST(LIBCAIRO_LIBS) 88 - 89 -PKG_CHECK_MODULES([LIBXML2], [libxml-2.0], , AC_MSG_ERROR(['libxml2' is required but it doesn't seem to be installed on this system.])) 90 - AC_SUBST(LIBXML2_CFLAGS) 91 - AC_SUBST(LIBXML2_LIBS) 92 - 93 -AC_CONFIG_FILES([Makefile \ 94 - headers/Makefile \ 95 - src/Makefile \ 96 - gaiagraphics.pc]) 97 - 98 -# Checking for MinGW 99 -AM_CONDITIONAL([MINGW], [test "$target_alias" = "mingw32"]) 100 - 101 -AC_OUTPUT
Deleted depcomp.
1 -#! /bin/sh 2 -# depcomp - compile a program generating dependencies as side-effects 3 - 4 -scriptversion=2012-03-27.16; # UTC 5 - 6 -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 7 -# 2011, 2012 Free Software Foundation, Inc. 8 - 9 -# This program is free software; you can redistribute it and/or modify 10 -# it under the terms of the GNU General Public License as published by 11 -# the Free Software Foundation; either version 2, or (at your option) 12 -# any later version. 13 - 14 -# This program is distributed in the hope that it will be useful, 15 -# but WITHOUT ANY WARRANTY; without even the implied warranty of 16 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 -# GNU General Public License for more details. 18 - 19 -# You should have received a copy of the GNU General Public License 20 -# along with this program. If not, see <http://www.gnu.org/licenses/>. 21 - 22 -# As a special exception to the GNU General Public License, if you 23 -# distribute this file as part of a program that contains a 24 -# configuration script generated by Autoconf, you may include it under 25 -# the same distribution terms that you use for the rest of that program. 26 - 27 -# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28 - 29 -case $1 in 30 - '') 31 - echo "$0: No command. Try '$0 --help' for more information." 1>&2 32 - exit 1; 33 - ;; 34 - -h | --h*) 35 - cat <<\EOF 36 -Usage: depcomp [--help] [--version] PROGRAM [ARGS] 37 - 38 -Run PROGRAMS ARGS to compile a file, generating dependencies 39 -as side-effects. 40 - 41 -Environment variables: 42 - depmode Dependency tracking mode. 43 - source Source file read by 'PROGRAMS ARGS'. 44 - object Object file output by 'PROGRAMS ARGS'. 45 - DEPDIR directory where to store dependencies. 46 - depfile Dependency file to output. 47 - tmpdepfile Temporary file to use when outputting dependencies. 48 - libtool Whether libtool is used (yes/no). 49 - 50 -Report bugs to <bug-automake@gnu.org>. 51 -EOF 52 - exit $? 53 - ;; 54 - -v | --v*) 55 - echo "depcomp $scriptversion" 56 - exit $? 57 - ;; 58 -esac 59 - 60 -# A tabulation character. 61 -tab=' ' 62 -# A newline character. 63 -nl=' 64 -' 65 - 66 -if test -z "$depmode" || test -z "$source" || test -z "$object"; then 67 - echo "depcomp: Variables source, object and depmode must be set" 1>&2 68 - exit 1 69 -fi 70 - 71 -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 72 -depfile=${depfile-`echo "$object" | 73 - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 74 -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 75 - 76 -rm -f "$tmpdepfile" 77 - 78 -# Some modes work just like other modes, but use different flags. We 79 -# parameterize here, but still list the modes in the big case below, 80 -# to make depend.m4 easier to write. Note that we *cannot* use a case 81 -# here, because this file can only contain one case statement. 82 -if test "$depmode" = hp; then 83 - # HP compiler uses -M and no extra arg. 84 - gccflag=-M 85 - depmode=gcc 86 -fi 87 - 88 -if test "$depmode" = dashXmstdout; then 89 - # This is just like dashmstdout with a different argument. 90 - dashmflag=-xM 91 - depmode=dashmstdout 92 -fi 93 - 94 -cygpath_u="cygpath -u -f -" 95 -if test "$depmode" = msvcmsys; then 96 - # This is just like msvisualcpp but w/o cygpath translation. 97 - # Just convert the backslash-escaped backslashes to single forward 98 - # slashes to satisfy depend.m4 99 - cygpath_u='sed s,\\\\,/,g' 100 - depmode=msvisualcpp 101 -fi 102 - 103 -if test "$depmode" = msvc7msys; then 104 - # This is just like msvc7 but w/o cygpath translation. 105 - # Just convert the backslash-escaped backslashes to single forward 106 - # slashes to satisfy depend.m4 107 - cygpath_u='sed s,\\\\,/,g' 108 - depmode=msvc7 109 -fi 110 - 111 -if test "$depmode" = xlc; then 112 - # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. 113 - gccflag=-qmakedep=gcc,-MF 114 - depmode=gcc 115 -fi 116 - 117 -case "$depmode" in 118 -gcc3) 119 -## gcc 3 implements dependency tracking that does exactly what 120 -## we want. Yay! Note: for some reason libtool 1.4 doesn't like 121 -## it if -MD -MP comes after the -MF stuff. Hmm. 122 -## Unfortunately, FreeBSD c89 acceptance of flags depends upon 123 -## the command line argument order; so add the flags where they 124 -## appear in depend2.am. Note that the slowdown incurred here 125 -## affects only configure: in makefiles, %FASTDEP% shortcuts this. 126 - for arg 127 - do 128 - case $arg in 129 - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 130 - *) set fnord "$@" "$arg" ;; 131 - esac 132 - shift # fnord 133 - shift # $arg 134 - done 135 - "$@" 136 - stat=$? 137 - if test $stat -eq 0; then : 138 - else 139 - rm -f "$tmpdepfile" 140 - exit $stat 141 - fi 142 - mv "$tmpdepfile" "$depfile" 143 - ;; 144 - 145 -gcc) 146 -## There are various ways to get dependency output from gcc. Here's 147 -## why we pick this rather obscure method: 148 -## - Don't want to use -MD because we'd like the dependencies to end 149 -## up in a subdir. Having to rename by hand is ugly. 150 -## (We might end up doing this anyway to support other compilers.) 151 -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 152 -## -MM, not -M (despite what the docs say). 153 -## - Using -M directly means running the compiler twice (even worse 154 -## than renaming). 155 - if test -z "$gccflag"; then 156 - gccflag=-MD, 157 - fi 158 - "$@" -Wp,"$gccflag$tmpdepfile" 159 - stat=$? 160 - if test $stat -eq 0; then : 161 - else 162 - rm -f "$tmpdepfile" 163 - exit $stat 164 - fi 165 - rm -f "$depfile" 166 - echo "$object : \\" > "$depfile" 167 - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 168 -## The second -e expression handles DOS-style file names with drive letters. 169 - sed -e 's/^[^:]*: / /' \ 170 - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 171 -## This next piece of magic avoids the "deleted header file" problem. 172 -## The problem is that when a header file which appears in a .P file 173 -## is deleted, the dependency causes make to die (because there is 174 -## typically no way to rebuild the header). We avoid this by adding 175 -## dummy dependencies for each header file. Too bad gcc doesn't do 176 -## this for us directly. 177 - tr ' ' "$nl" < "$tmpdepfile" | 178 -## Some versions of gcc put a space before the ':'. On the theory 179 -## that the space means something, we add a space to the output as 180 -## well. hp depmode also adds that space, but also prefixes the VPATH 181 -## to the object. Take care to not repeat it in the output. 182 -## Some versions of the HPUX 10.20 sed can't process this invocation 183 -## correctly. Breaking it into two sed invocations is a workaround. 184 - sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 185 - | sed -e 's/$/ :/' >> "$depfile" 186 - rm -f "$tmpdepfile" 187 - ;; 188 - 189 -hp) 190 - # This case exists only to let depend.m4 do its work. It works by 191 - # looking at the text of this script. This case will never be run, 192 - # since it is checked for above. 193 - exit 1 194 - ;; 195 - 196 -sgi) 197 - if test "$libtool" = yes; then 198 - "$@" "-Wp,-MDupdate,$tmpdepfile" 199 - else 200 - "$@" -MDupdate "$tmpdepfile" 201 - fi 202 - stat=$? 203 - if test $stat -eq 0; then : 204 - else 205 - rm -f "$tmpdepfile" 206 - exit $stat 207 - fi 208 - rm -f "$depfile" 209 - 210 - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 211 - echo "$object : \\" > "$depfile" 212 - 213 - # Clip off the initial element (the dependent). Don't try to be 214 - # clever and replace this with sed code, as IRIX sed won't handle 215 - # lines with more than a fixed number of characters (4096 in 216 - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 217 - # the IRIX cc adds comments like '#:fec' to the end of the 218 - # dependency line. 219 - tr ' ' "$nl" < "$tmpdepfile" \ 220 - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 221 - tr "$nl" ' ' >> "$depfile" 222 - echo >> "$depfile" 223 - 224 - # The second pass generates a dummy entry for each header file. 225 - tr ' ' "$nl" < "$tmpdepfile" \ 226 - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 227 - >> "$depfile" 228 - else 229 - # The sourcefile does not contain any dependencies, so just 230 - # store a dummy comment line, to avoid errors with the Makefile 231 - # "include basename.Plo" scheme. 232 - echo "#dummy" > "$depfile" 233 - fi 234 - rm -f "$tmpdepfile" 235 - ;; 236 - 237 -xlc) 238 - # This case exists only to let depend.m4 do its work. It works by 239 - # looking at the text of this script. This case will never be run, 240 - # since it is checked for above. 241 - exit 1 242 - ;; 243 - 244 -aix) 245 - # The C for AIX Compiler uses -M and outputs the dependencies 246 - # in a .u file. In older versions, this file always lives in the 247 - # current directory. Also, the AIX compiler puts '$object:' at the 248 - # start of each line; $object doesn't have directory information. 249 - # Version 6 uses the directory in both cases. 250 - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 251 - test "x$dir" = "x$object" && dir= 252 - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 253 - if test "$libtool" = yes; then 254 - tmpdepfile1=$dir$base.u 255 - tmpdepfile2=$base.u 256 - tmpdepfile3=$dir.libs/$base.u 257 - "$@" -Wc,-M 258 - else 259 - tmpdepfile1=$dir$base.u 260 - tmpdepfile2=$dir$base.u 261 - tmpdepfile3=$dir$base.u 262 - "$@" -M 263 - fi 264 - stat=$? 265 - 266 - if test $stat -eq 0; then : 267 - else 268 - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 269 - exit $stat 270 - fi 271 - 272 - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 273 - do 274 - test -f "$tmpdepfile" && break 275 - done 276 - if test -f "$tmpdepfile"; then 277 - # Each line is of the form 'foo.o: dependent.h'. 278 - # Do two passes, one to just change these to 279 - # '$object: dependent.h' and one to simply 'dependent.h:'. 280 - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 281 - sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 282 - else 283 - # The sourcefile does not contain any dependencies, so just 284 - # store a dummy comment line, to avoid errors with the Makefile 285 - # "include basename.Plo" scheme. 286 - echo "#dummy" > "$depfile" 287 - fi 288 - rm -f "$tmpdepfile" 289 - ;; 290 - 291 -icc) 292 - # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. 293 - # However on 294 - # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c 295 - # ICC 7.0 will fill foo.d with something like 296 - # foo.o: sub/foo.c 297 - # foo.o: sub/foo.h 298 - # which is wrong. We want 299 - # sub/foo.o: sub/foo.c 300 - # sub/foo.o: sub/foo.h 301 - # sub/foo.c: 302 - # sub/foo.h: 303 - # ICC 7.1 will output 304 - # foo.o: sub/foo.c sub/foo.h 305 - # and will wrap long lines using '\': 306 - # foo.o: sub/foo.c ... \ 307 - # sub/foo.h ... \ 308 - # ... 309 - # tcc 0.9.26 (FIXME still under development at the moment of writing) 310 - # will emit a similar output, but also prepend the continuation lines 311 - # with horizontal tabulation characters. 312 - "$@" -MD -MF "$tmpdepfile" 313 - stat=$? 314 - if test $stat -eq 0; then : 315 - else 316 - rm -f "$tmpdepfile" 317 - exit $stat 318 - fi 319 - rm -f "$depfile" 320 - # Each line is of the form 'foo.o: dependent.h', 321 - # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. 322 - # Do two passes, one to just change these to 323 - # '$object: dependent.h' and one to simply 'dependent.h:'. 324 - sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ 325 - < "$tmpdepfile" > "$depfile" 326 - sed ' 327 - s/[ '"$tab"'][ '"$tab"']*/ /g 328 - s/^ *// 329 - s/ *\\*$// 330 - s/^[^:]*: *// 331 - /^$/d 332 - /:$/d 333 - s/$/ :/ 334 - ' < "$tmpdepfile" >> "$depfile" 335 - rm -f "$tmpdepfile" 336 - ;; 337 - 338 -hp2) 339 - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 340 - # compilers, which have integrated preprocessors. The correct option 341 - # to use with these is +Maked; it writes dependencies to a file named 342 - # 'foo.d', which lands next to the object file, wherever that 343 - # happens to be. 344 - # Much of this is similar to the tru64 case; see comments there. 345 - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 346 - test "x$dir" = "x$object" && dir= 347 - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 348 - if test "$libtool" = yes; then 349 - tmpdepfile1=$dir$base.d 350 - tmpdepfile2=$dir.libs/$base.d 351 - "$@" -Wc,+Maked 352 - else 353 - tmpdepfile1=$dir$base.d 354 - tmpdepfile2=$dir$base.d 355 - "$@" +Maked 356 - fi 357 - stat=$? 358 - if test $stat -eq 0; then : 359 - else 360 - rm -f "$tmpdepfile1" "$tmpdepfile2" 361 - exit $stat 362 - fi 363 - 364 - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 365 - do 366 - test -f "$tmpdepfile" && break 367 - done 368 - if test -f "$tmpdepfile"; then 369 - sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 370 - # Add 'dependent.h:' lines. 371 - sed -ne '2,${ 372 - s/^ *// 373 - s/ \\*$// 374 - s/$/:/ 375 - p 376 - }' "$tmpdepfile" >> "$depfile" 377 - else 378 - echo "#dummy" > "$depfile" 379 - fi 380 - rm -f "$tmpdepfile" "$tmpdepfile2" 381 - ;; 382 - 383 -tru64) 384 - # The Tru64 compiler uses -MD to generate dependencies as a side 385 - # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 386 - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 387 - # dependencies in 'foo.d' instead, so we check for that too. 388 - # Subdirectories are respected. 389 - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 390 - test "x$dir" = "x$object" && dir= 391 - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 392 - 393 - if test "$libtool" = yes; then 394 - # With Tru64 cc, shared objects can also be used to make a 395 - # static library. This mechanism is used in libtool 1.4 series to 396 - # handle both shared and static libraries in a single compilation. 397 - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 398 - # 399 - # With libtool 1.5 this exception was removed, and libtool now 400 - # generates 2 separate objects for the 2 libraries. These two 401 - # compilations output dependencies in $dir.libs/$base.o.d and 402 - # in $dir$base.o.d. We have to check for both files, because 403 - # one of the two compilations can be disabled. We should prefer 404 - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 405 - # automatically cleaned when .libs/ is deleted, while ignoring 406 - # the former would cause a distcleancheck panic. 407 - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 408 - tmpdepfile2=$dir$base.o.d # libtool 1.5 409 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 410 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 411 - "$@" -Wc,-MD 412 - else 413 - tmpdepfile1=$dir$base.o.d 414 - tmpdepfile2=$dir$base.d 415 - tmpdepfile3=$dir$base.d 416 - tmpdepfile4=$dir$base.d 417 - "$@" -MD 418 - fi 419 - 420 - stat=$? 421 - if test $stat -eq 0; then : 422 - else 423 - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 424 - exit $stat 425 - fi 426 - 427 - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 428 - do 429 - test -f "$tmpdepfile" && break 430 - done 431 - if test -f "$tmpdepfile"; then 432 - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 433 - sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 434 - else 435 - echo "#dummy" > "$depfile" 436 - fi 437 - rm -f "$tmpdepfile" 438 - ;; 439 - 440 -msvc7) 441 - if test "$libtool" = yes; then 442 - showIncludes=-Wc,-showIncludes 443 - else 444 - showIncludes=-showIncludes 445 - fi 446 - "$@" $showIncludes > "$tmpdepfile" 447 - stat=$? 448 - grep -v '^Note: including file: ' "$tmpdepfile" 449 - if test "$stat" = 0; then : 450 - else 451 - rm -f "$tmpdepfile" 452 - exit $stat 453 - fi 454 - rm -f "$depfile" 455 - echo "$object : \\" > "$depfile" 456 - # The first sed program below extracts the file names and escapes 457 - # backslashes for cygpath. The second sed program outputs the file 458 - # name when reading, but also accumulates all include files in the 459 - # hold buffer in order to output them again at the end. This only 460 - # works with sed implementations that can handle large buffers. 461 - sed < "$tmpdepfile" -n ' 462 -/^Note: including file: *\(.*\)/ { 463 - s//\1/ 464 - s/\\/\\\\/g 465 - p 466 -}' | $cygpath_u | sort -u | sed -n ' 467 -s/ /\\ /g 468 -s/\(.*\)/'"$tab"'\1 \\/p 469 -s/.\(.*\) \\/\1:/ 470 -H 471 -$ { 472 - s/.*/'"$tab"'/ 473 - G 474 - p 475 -}' >> "$depfile" 476 - rm -f "$tmpdepfile" 477 - ;; 478 - 479 -msvc7msys) 480 - # This case exists only to let depend.m4 do its work. It works by 481 - # looking at the text of this script. This case will never be run, 482 - # since it is checked for above. 483 - exit 1 484 - ;; 485 - 486 -#nosideeffect) 487 - # This comment above is used by automake to tell side-effect 488 - # dependency tracking mechanisms from slower ones. 489 - 490 -dashmstdout) 491 - # Important note: in order to support this mode, a compiler *must* 492 - # always write the preprocessed file to stdout, regardless of -o. 493 - "$@" || exit $? 494 - 495 - # Remove the call to Libtool. 496 - if test "$libtool" = yes; then 497 - while test "X$1" != 'X--mode=compile'; do 498 - shift 499 - done 500 - shift 501 - fi 502 - 503 - # Remove '-o $object'. 504 - IFS=" " 505 - for arg 506 - do 507 - case $arg in 508 - -o) 509 - shift 510 - ;; 511 - $object) 512 - shift 513 - ;; 514 - *) 515 - set fnord "$@" "$arg" 516 - shift # fnord 517 - shift # $arg 518 - ;; 519 - esac 520 - done 521 - 522 - test -z "$dashmflag" && dashmflag=-M 523 - # Require at least two characters before searching for ':' 524 - # in the target name. This is to cope with DOS-style filenames: 525 - # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 526 - "$@" $dashmflag | 527 - sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" 528 - rm -f "$depfile" 529 - cat < "$tmpdepfile" > "$depfile" 530 - tr ' ' "$nl" < "$tmpdepfile" | \ 531 -## Some versions of the HPUX 10.20 sed can't process this invocation 532 -## correctly. Breaking it into two sed invocations is a workaround. 533 - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 534 - rm -f "$tmpdepfile" 535 - ;; 536 - 537 -dashXmstdout) 538 - # This case only exists to satisfy depend.m4. It is never actually 539 - # run, as this mode is specially recognized in the preamble. 540 - exit 1 541 - ;; 542 - 543 -makedepend) 544 - "$@" || exit $? 545 - # Remove any Libtool call 546 - if test "$libtool" = yes; then 547 - while test "X$1" != 'X--mode=compile'; do 548 - shift 549 - done 550 - shift 551 - fi 552 - # X makedepend 553 - shift 554 - cleared=no eat=no 555 - for arg 556 - do 557 - case $cleared in 558 - no) 559 - set ""; shift 560 - cleared=yes ;; 561 - esac 562 - if test $eat = yes; then 563 - eat=no 564 - continue 565 - fi 566 - case "$arg" in 567 - -D*|-I*) 568 - set fnord "$@" "$arg"; shift ;; 569 - # Strip any option that makedepend may not understand. Remove 570 - # the object too, otherwise makedepend will parse it as a source file. 571 - -arch) 572 - eat=yes ;; 573 - -*|$object) 574 - ;; 575 - *) 576 - set fnord "$@" "$arg"; shift ;; 577 - esac 578 - done 579 - obj_suffix=`echo "$object" | sed 's/^.*\././'` 580 - touch "$tmpdepfile" 581 - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 582 - rm -f "$depfile" 583 - # makedepend may prepend the VPATH from the source file name to the object. 584 - # No need to regex-escape $object, excess matching of '.' is harmless. 585 - sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 586 - sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ 587 -## Some versions of the HPUX 10.20 sed can't process this invocation 588 -## correctly. Breaking it into two sed invocations is a workaround. 589 - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 590 - rm -f "$tmpdepfile" "$tmpdepfile".bak 591 - ;; 592 - 593 -cpp) 594 - # Important note: in order to support this mode, a compiler *must* 595 - # always write the preprocessed file to stdout. 596 - "$@" || exit $? 597 - 598 - # Remove the call to Libtool. 599 - if test "$libtool" = yes; then 600 - while test "X$1" != 'X--mode=compile'; do 601 - shift 602 - done 603 - shift 604 - fi 605 - 606 - # Remove '-o $object'. 607 - IFS=" " 608 - for arg 609 - do 610 - case $arg in 611 - -o) 612 - shift 613 - ;; 614 - $object) 615 - shift 616 - ;; 617 - *) 618 - set fnord "$@" "$arg" 619 - shift # fnord 620 - shift # $arg 621 - ;; 622 - esac 623 - done 624 - 625 - "$@" -E | 626 - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 627 - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 628 - sed '$ s: \\$::' > "$tmpdepfile" 629 - rm -f "$depfile" 630 - echo "$object : \\" > "$depfile" 631 - cat < "$tmpdepfile" >> "$depfile" 632 - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 633 - rm -f "$tmpdepfile" 634 - ;; 635 - 636 -msvisualcpp) 637 - # Important note: in order to support this mode, a compiler *must* 638 - # always write the preprocessed file to stdout. 639 - "$@" || exit $? 640 - 641 - # Remove the call to Libtool. 642 - if test "$libtool" = yes; then 643 - while test "X$1" != 'X--mode=compile'; do 644 - shift 645 - done 646 - shift 647 - fi 648 - 649 - IFS=" " 650 - for arg 651 - do 652 - case "$arg" in 653 - -o) 654 - shift 655 - ;; 656 - $object) 657 - shift 658 - ;; 659 - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 660 - set fnord "$@" 661 - shift 662 - shift 663 - ;; 664 - *) 665 - set fnord "$@" "$arg" 666 - shift 667 - shift 668 - ;; 669 - esac 670 - done 671 - "$@" -E 2>/dev/null | 672 - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 673 - rm -f "$depfile" 674 - echo "$object : \\" > "$depfile" 675 - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 676 - echo "$tab" >> "$depfile" 677 - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 678 - rm -f "$tmpdepfile" 679 - ;; 680 - 681 -msvcmsys) 682 - # This case exists only to let depend.m4 do its work. It works by 683 - # looking at the text of this script. This case will never be run, 684 - # since it is checked for above. 685 - exit 1 686 - ;; 687 - 688 -none) 689 - exec "$@" 690 - ;; 691 - 692 -*) 693 - echo "Unknown depmode $depmode" 1>&2 694 - exit 1 695 - ;; 696 -esac 697 - 698 -exit 0 699 - 700 -# Local Variables: 701 -# mode: shell-script 702 -# sh-indentation: 2 703 -# eval: (add-hook 'write-file-hooks 'time-stamp) 704 -# time-stamp-start: "scriptversion=" 705 -# time-stamp-format: "%:y-%02m-%02d.%02H" 706 -# time-stamp-time-zone: "UTC" 707 -# time-stamp-end: "; # UTC" 708 -# End:
Deleted gaiagraphics.pc.in.
1 -# Package Information for pkg-config 2 - 3 -prefix=@prefix@ 4 -exec_prefix=@exec_prefix@ 5 -libdir=@libdir@ 6 -includedir=@includedir@ 7 - 8 -Name: gaiagraphics 9 -Description: Gaia Common Graphics Support 10 -Version: 1.0 11 -Libs: -L${libdir} -lgaiagraphics 12 -Cflags: -I${includedir}
Deleted headers/Makefile.am.
1 - 2 -noinst_HEADERS = gaiagraphics_internals.h 3 -include_HEADERS = gaiagraphics.h 4 -
Deleted headers/Makefile.in.
1 -# Makefile.in generated by automake 1.13.4 from Makefile.am. 2 -# @configure_input@ 3 - 4 -# Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 - 6 -# This Makefile.in is free software; the Free Software Foundation 7 -# gives unlimited permission to copy and/or distribute it, 8 -# with or without modifications, as long as this notice is preserved. 9 - 10 -# This program is distributed in the hope that it will be useful, 11 -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 -# PARTICULAR PURPOSE. 14 - 15 -@SET_MAKE@ 16 - 17 -VPATH = @srcdir@ 18 -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 19 -am__make_running_with_option = \ 20 - case $${target_option-} in \ 21 - ?) ;; \ 22 - *) echo "am__make_running_with_option: internal error: invalid" \ 23 - "target option '$${target_option-}' specified" >&2; \ 24 - exit 1;; \ 25 - esac; \ 26 - has_opt=no; \ 27 - sane_makeflags=$$MAKEFLAGS; \ 28 - if $(am__is_gnu_make); then \ 29 - sane_makeflags=$$MFLAGS; \ 30 - else \ 31 - case $$MAKEFLAGS in \ 32 - *\\[\ \ ]*) \ 33 - bs=\\; \ 34 - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 35 - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 36 - esac; \ 37 - fi; \ 38 - skip_next=no; \ 39 - strip_trailopt () \ 40 - { \ 41 - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 42 - }; \ 43 - for flg in $$sane_makeflags; do \ 44 - test $$skip_next = yes && { skip_next=no; continue; }; \ 45 - case $$flg in \ 46 - *=*|--*) continue;; \ 47 - -*I) strip_trailopt 'I'; skip_next=yes;; \ 48 - -*I?*) strip_trailopt 'I';; \ 49 - -*O) strip_trailopt 'O'; skip_next=yes;; \ 50 - -*O?*) strip_trailopt 'O';; \ 51 - -*l) strip_trailopt 'l'; skip_next=yes;; \ 52 - -*l?*) strip_trailopt 'l';; \ 53 - -[dEDm]) skip_next=yes;; \ 54 - -[JT]) skip_next=yes;; \ 55 - esac; \ 56 - case $$flg in \ 57 - *$$target_option*) has_opt=yes; break;; \ 58 - esac; \ 59 - done; \ 60 - test $$has_opt = yes 61 -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 62 -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 63 -pkgdatadir = $(datadir)/@PACKAGE@ 64 -pkgincludedir = $(includedir)/@PACKAGE@ 65 -pkglibdir = $(libdir)/@PACKAGE@ 66 -pkglibexecdir = $(libexecdir)/@PACKAGE@ 67 -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 68 -install_sh_DATA = $(install_sh) -c -m 644 69 -install_sh_PROGRAM = $(install_sh) -c 70 -install_sh_SCRIPT = $(install_sh) -c 71 -INSTALL_HEADER = $(INSTALL_DATA) 72 -transform = $(program_transform_name) 73 -NORMAL_INSTALL = : 74 -PRE_INSTALL = : 75 -POST_INSTALL = : 76 -NORMAL_UNINSTALL = : 77 -PRE_UNINSTALL = : 78 -POST_UNINSTALL = : 79 -build_triplet = @build@ 80 -host_triplet = @host@ 81 -subdir = headers 82 -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ 83 - $(include_HEADERS) $(noinst_HEADERS) 84 -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 85 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ 86 - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ 87 - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ 88 - $(top_srcdir)/configure.ac 89 -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 90 - $(ACLOCAL_M4) 91 -mkinstalldirs = $(install_sh) -d 92 -CONFIG_CLEAN_FILES = 93 -CONFIG_CLEAN_VPATH_FILES = 94 -AM_V_P = $(am__v_P_@AM_V@) 95 -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 96 -am__v_P_0 = false 97 -am__v_P_1 = : 98 -AM_V_GEN = $(am__v_GEN_@AM_V@) 99 -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 100 -am__v_GEN_0 = @echo " GEN " $@; 101 -am__v_GEN_1 = 102 -AM_V_at = $(am__v_at_@AM_V@) 103 -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 104 -am__v_at_0 = @ 105 -am__v_at_1 = 106 -SOURCES = 107 -DIST_SOURCES = 108 -am__can_run_installinfo = \ 109 - case $$AM_UPDATE_INFO_DIR in \ 110 - n|no|NO) false;; \ 111 - *) (install-info --version) >/dev/null 2>&1;; \ 112 - esac 113 -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 114 -am__vpath_adj = case $$p in \ 115 - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 116 - *) f=$$p;; \ 117 - esac; 118 -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; 119 -am__install_max = 40 120 -am__nobase_strip_setup = \ 121 - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` 122 -am__nobase_strip = \ 123 - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" 124 -am__nobase_list = $(am__nobase_strip_setup); \ 125 - for p in $$list; do echo "$$p $$p"; done | \ 126 - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ 127 - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ 128 - if (++n[$$2] == $(am__install_max)) \ 129 - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ 130 - END { for (dir in files) print dir, files[dir] }' 131 -am__base_list = \ 132 - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ 133 - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' 134 -am__uninstall_files_from_dir = { \ 135 - test -z "$$files" \ 136 - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ 137 - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ 138 - $(am__cd) "$$dir" && rm -f $$files; }; \ 139 - } 140 -am__installdirs = "$(DESTDIR)$(includedir)" 141 -HEADERS = $(include_HEADERS) $(noinst_HEADERS) 142 -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 143 -# Read a list of newline-separated strings from the standard input, 144 -# and print each of them once, without duplicates. Input order is 145 -# *not* preserved. 146 -am__uniquify_input = $(AWK) '\ 147 - BEGIN { nonempty = 0; } \ 148 - { items[$$0] = 1; nonempty = 1; } \ 149 - END { if (nonempty) { for (i in items) print i; }; } \ 150 -' 151 -# Make sure the list of sources is unique. This is necessary because, 152 -# e.g., the same source file might be shared among _SOURCES variables 153 -# for different programs/libraries. 154 -am__define_uniq_tagged_files = \ 155 - list='$(am__tagged_files)'; \ 156 - unique=`for i in $$list; do \ 157 - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 158 - done | $(am__uniquify_input)` 159 -ETAGS = etags 160 -CTAGS = ctags 161 -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 162 -ACLOCAL = @ACLOCAL@ 163 -AMTAR = @AMTAR@ 164 -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 165 -AR = @AR@ 166 -AS = @AS@ 167 -AUTOCONF = @AUTOCONF@ 168 -AUTOHEADER = @AUTOHEADER@ 169 -AUTOMAKE = @AUTOMAKE@ 170 -AWK = @AWK@ 171 -CC = @CC@ 172 -CCDEPMODE = @CCDEPMODE@ 173 -CFLAGS = @CFLAGS@ 174 -CPP = @CPP@ 175 -CPPFLAGS = @CPPFLAGS@ 176 -CXX = @CXX@ 177 -CXXCPP = @CXXCPP@ 178 -CXXDEPMODE = @CXXDEPMODE@ 179 -CXXFLAGS = @CXXFLAGS@ 180 -CYGPATH_W = @CYGPATH_W@ 181 -DEFS = @DEFS@ 182 -DEPDIR = @DEPDIR@ 183 -DLLTOOL = @DLLTOOL@ 184 -DSYMUTIL = @DSYMUTIL@ 185 -DUMPBIN = @DUMPBIN@ 186 -ECHO_C = @ECHO_C@ 187 -ECHO_N = @ECHO_N@ 188 -ECHO_T = @ECHO_T@ 189 -EGREP = @EGREP@ 190 -EXEEXT = @EXEEXT@ 191 -FGREP = @FGREP@ 192 -GREP = @GREP@ 193 -INSTALL = @INSTALL@ 194 -INSTALL_DATA = @INSTALL_DATA@ 195 -INSTALL_PROGRAM = @INSTALL_PROGRAM@ 196 -INSTALL_SCRIPT = @INSTALL_SCRIPT@ 197 -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 198 -LD = @LD@ 199 -LDFLAGS = @LDFLAGS@ 200 -LIBCAIRO_CFLAGS = @LIBCAIRO_CFLAGS@ 201 -LIBCAIRO_LIBS = @LIBCAIRO_LIBS@ 202 -LIBOBJS = @LIBOBJS@ 203 -LIBPNG_CFLAGS = @LIBPNG_CFLAGS@ 204 -LIBPNG_LIBS = @LIBPNG_LIBS@ 205 -LIBS = @LIBS@ 206 -LIBTOOL = @LIBTOOL@ 207 -LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ 208 -LIBXML2_LIBS = @LIBXML2_LIBS@ 209 -LIPO = @LIPO@ 210 -LN_S = @LN_S@ 211 -LTLIBOBJS = @LTLIBOBJS@ 212 -MAINT = @MAINT@ 213 -MAKEINFO = @MAKEINFO@ 214 -MANIFEST_TOOL = @MANIFEST_TOOL@ 215 -MKDIR_P = @MKDIR_P@ 216 -NM = @NM@ 217 -NMEDIT = @NMEDIT@ 218 -OBJDUMP = @OBJDUMP@ 219 -OBJEXT = @OBJEXT@ 220 -OTOOL = @OTOOL@ 221 -OTOOL64 = @OTOOL64@ 222 -PACKAGE = @PACKAGE@ 223 -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 224 -PACKAGE_NAME = @PACKAGE_NAME@ 225 -PACKAGE_STRING = @PACKAGE_STRING@ 226 -PACKAGE_TARNAME = @PACKAGE_TARNAME@ 227 -PACKAGE_URL = @PACKAGE_URL@ 228 -PACKAGE_VERSION = @PACKAGE_VERSION@ 229 -PATH_SEPARATOR = @PATH_SEPARATOR@ 230 -PKG_CONFIG = @PKG_CONFIG@ 231 -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ 232 -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ 233 -RANLIB = @RANLIB@ 234 -SED = @SED@ 235 -SET_MAKE = @SET_MAKE@ 236 -SHELL = @SHELL@ 237 -STRIP = @STRIP@ 238 -VERSION = @VERSION@ 239 -abs_builddir = @abs_builddir@ 240 -abs_srcdir = @abs_srcdir@ 241 -abs_top_builddir = @abs_top_builddir@ 242 -abs_top_srcdir = @abs_top_srcdir@ 243 -ac_ct_AR = @ac_ct_AR@ 244 -ac_ct_CC = @ac_ct_CC@ 245 -ac_ct_CXX = @ac_ct_CXX@ 246 -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 247 -am__include = @am__include@ 248 -am__leading_dot = @am__leading_dot@ 249 -am__quote = @am__quote@ 250 -am__tar = @am__tar@ 251 -am__untar = @am__untar@ 252 -bindir = @bindir@ 253 -build = @build@ 254 -build_alias = @build_alias@ 255 -build_cpu = @build_cpu@ 256 -build_os = @build_os@ 257 -build_vendor = @build_vendor@ 258 -builddir = @builddir@ 259 -datadir = @datadir@ 260 -datarootdir = @datarootdir@ 261 -docdir = @docdir@ 262 -dvidir = @dvidir@ 263 -exec_prefix = @exec_prefix@ 264 -host = @host@ 265 -host_alias = @host_alias@ 266 -host_cpu = @host_cpu@ 267 -host_os = @host_os@ 268 -host_vendor = @host_vendor@ 269 -htmldir = @htmldir@ 270 -includedir = @includedir@ 271 -infodir = @infodir@ 272 -install_sh = @install_sh@ 273 -libdir = @libdir@ 274 -libexecdir = @libexecdir@ 275 -localedir = @localedir@ 276 -localstatedir = @localstatedir@ 277 -mandir = @mandir@ 278 -mkdir_p = @mkdir_p@ 279 -oldincludedir = @oldincludedir@ 280 -pdfdir = @pdfdir@ 281 -prefix = @prefix@ 282 -program_transform_name = @program_transform_name@ 283 -psdir = @psdir@ 284 -sbindir = @sbindir@ 285 -sharedstatedir = @sharedstatedir@ 286 -srcdir = @srcdir@ 287 -sysconfdir = @sysconfdir@ 288 -target_alias = @target_alias@ 289 -top_build_prefix = @top_build_prefix@ 290 -top_builddir = @top_builddir@ 291 -top_srcdir = @top_srcdir@ 292 -noinst_HEADERS = gaiagraphics_internals.h 293 -include_HEADERS = gaiagraphics.h 294 -all: all-am 295 - 296 -.SUFFIXES: 297 -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) 298 - @for dep in $?; do \ 299 - case '$(am__configure_deps)' in \ 300 - *$$dep*) \ 301 - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 302 - && { if test -f $@; then exit 0; else break; fi; }; \ 303 - exit 1;; \ 304 - esac; \ 305 - done; \ 306 - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu headers/Makefile'; \ 307 - $(am__cd) $(top_srcdir) && \ 308 - $(AUTOMAKE) --gnu headers/Makefile 309 -.PRECIOUS: Makefile 310 -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 311 - @case '$?' in \ 312 - *config.status*) \ 313 - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 314 - *) \ 315 - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 316 - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 317 - esac; 318 - 319 -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 320 - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 321 - 322 -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 323 - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 324 -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) 325 - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 326 -$(am__aclocal_m4_deps): 327 - 328 -mostlyclean-libtool: 329 - -rm -f *.lo 330 - 331 -clean-libtool: 332 - -rm -rf .libs _libs 333 -install-includeHEADERS: $(include_HEADERS) 334 - @$(NORMAL_INSTALL) 335 - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ 336 - if test -n "$$list"; then \ 337 - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ 338 - $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ 339 - fi; \ 340 - for p in $$list; do \ 341 - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 342 - echo "$$d$$p"; \ 343 - done | $(am__base_list) | \ 344 - while read files; do \ 345 - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ 346 - $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ 347 - done 348 - 349 -uninstall-includeHEADERS: 350 - @$(NORMAL_UNINSTALL) 351 - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ 352 - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ 353 - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) 354 - 355 -ID: $(am__tagged_files) 356 - $(am__define_uniq_tagged_files); mkid -fID $$unique 357 -tags: tags-am 358 -TAGS: tags 359 - 360 -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 361 - set x; \ 362 - here=`pwd`; \ 363 - $(am__define_uniq_tagged_files); \ 364 - shift; \ 365 - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 366 - test -n "$$unique" || unique=$$empty_fix; \ 367 - if test $$# -gt 0; then \ 368 - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 369 - "$$@" $$unique; \ 370 - else \ 371 - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 372 - $$unique; \ 373 - fi; \ 374 - fi 375 -ctags: ctags-am 376 - 377 -CTAGS: ctags 378 -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 379 - $(am__define_uniq_tagged_files); \ 380 - test -z "$(CTAGS_ARGS)$$unique" \ 381 - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 382 - $$unique 383 - 384 -GTAGS: 385 - here=`$(am__cd) $(top_builddir) && pwd` \ 386 - && $(am__cd) $(top_srcdir) \ 387 - && gtags -i $(GTAGS_ARGS) "$$here" 388 -cscopelist: cscopelist-am 389 - 390 -cscopelist-am: $(am__tagged_files) 391 - list='$(am__tagged_files)'; \ 392 - case "$(srcdir)" in \ 393 - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 394 - *) sdir=$(subdir)/$(srcdir) ;; \ 395 - esac; \ 396 - for i in $$list; do \ 397 - if test -f "$$i"; then \ 398 - echo "$(subdir)/$$i"; \ 399 - else \ 400 - echo "$$sdir/$$i"; \ 401 - fi; \ 402 - done >> $(top_builddir)/cscope.files 403 - 404 -distclean-tags: 405 - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 406 - 407 -distdir: $(DISTFILES) 408 - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 409 - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 410 - list='$(DISTFILES)'; \ 411 - dist_files=`for file in $$list; do echo $$file; done | \ 412 - sed -e "s|^$$srcdirstrip/||;t" \ 413 - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 414 - case $$dist_files in \ 415 - */*) $(MKDIR_P) `echo "$$dist_files" | \ 416 - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 417 - sort -u` ;; \ 418 - esac; \ 419 - for file in $$dist_files; do \ 420 - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 421 - if test -d $$d/$$file; then \ 422 - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 423 - if test -d "$(distdir)/$$file"; then \ 424 - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 425 - fi; \ 426 - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 427 - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 428 - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 429 - fi; \ 430 - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 431 - else \ 432 - test -f "$(distdir)/$$file" \ 433 - || cp -p $$d/$$file "$(distdir)/$$file" \ 434 - || exit 1; \ 435 - fi; \ 436 - done 437 -check-am: all-am 438 -check: check-am 439 -all-am: Makefile $(HEADERS) 440 -installdirs: 441 - for dir in "$(DESTDIR)$(includedir)"; do \ 442 - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 443 - done 444 -install: install-am 445 -install-exec: install-exec-am 446 -install-data: install-data-am 447 -uninstall: uninstall-am 448 - 449 -install-am: all-am 450 - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 451 - 452 -installcheck: installcheck-am 453 -install-strip: 454 - if test -z '$(STRIP)'; then \ 455 - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 456 - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 457 - install; \ 458 - else \ 459 - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 460 - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 461 - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 462 - fi 463 -mostlyclean-generic: 464 - 465 -clean-generic: 466 - 467 -distclean-generic: 468 - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 469 - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 470 - 471 -maintainer-clean-generic: 472 - @echo "This command is intended for maintainers to use" 473 - @echo "it deletes files that may require special tools to rebuild." 474 -clean: clean-am 475 - 476 -clean-am: clean-generic clean-libtool mostlyclean-am 477 - 478 -distclean: distclean-am 479 - -rm -f Makefile 480 -distclean-am: clean-am distclean-generic distclean-tags 481 - 482 -dvi: dvi-am 483 - 484 -dvi-am: 485 - 486 -html: html-am 487 - 488 -html-am: 489 - 490 -info: info-am 491 - 492 -info-am: 493 - 494 -install-data-am: install-includeHEADERS 495 - 496 -install-dvi: install-dvi-am 497 - 498 -install-dvi-am: 499 - 500 -install-exec-am: 501 - 502 -install-html: install-html-am 503 - 504 -install-html-am: 505 - 506 -install-info: install-info-am 507 - 508 -install-info-am: 509 - 510 -install-man: 511 - 512 -install-pdf: install-pdf-am 513 - 514 -install-pdf-am: 515 - 516 -install-ps: install-ps-am 517 - 518 -install-ps-am: 519 - 520 -installcheck-am: 521 - 522 -maintainer-clean: maintainer-clean-am 523 - -rm -f Makefile 524 -maintainer-clean-am: distclean-am maintainer-clean-generic 525 - 526 -mostlyclean: mostlyclean-am 527 - 528 -mostlyclean-am: mostlyclean-generic mostlyclean-libtool 529 - 530 -pdf: pdf-am 531 - 532 -pdf-am: 533 - 534 -ps: ps-am 535 - 536 -ps-am: 537 - 538 -uninstall-am: uninstall-includeHEADERS 539 - 540 -.MAKE: install-am install-strip 541 - 542 -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ 543 - clean-libtool cscopelist-am ctags ctags-am distclean \ 544 - distclean-generic distclean-libtool distclean-tags distdir dvi \ 545 - dvi-am html html-am info info-am install install-am \ 546 - install-data install-data-am install-dvi install-dvi-am \ 547 - install-exec install-exec-am install-html install-html-am \ 548 - install-includeHEADERS install-info install-info-am \ 549 - install-man install-pdf install-pdf-am install-ps \ 550 - install-ps-am install-strip installcheck installcheck-am \ 551 - installdirs maintainer-clean maintainer-clean-generic \ 552 - mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ 553 - ps ps-am tags tags-am uninstall uninstall-am \ 554 - uninstall-includeHEADERS 555 - 556 - 557 -# Tell versions [3.59,3.63) of GNU make to not export all variables. 558 -# Otherwise a system limit (for SysV at least) may be exceeded. 559 -.NOEXPORT:
Deleted headers/gaiagraphics.h.
1 -/* 2 -/ gGraph.h 3 -/ 4 -/ public gGraph declarations 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#ifdef _WIN32 28 -#ifdef DLL_EXPORT 29 -#define GGRAPH_DECLARE __declspec(dllexport) 30 -#else 31 -#define GGRAPH_DECLARE extern 32 -#endif 33 -#else 34 -#define GGRAPH_DECLARE __attribute__ ((visibility("default"))) 35 -#endif 36 - 37 -#ifndef _GGRAPH_H 38 -#define _GGRAPH_H 39 - 40 -#ifdef __cplusplus 41 -extern "C" 42 -{ 43 -#endif 44 - 45 -#define GGRAPH_COLORSPACE_UNKNOWN -1000 46 -#define GGRAPH_COLORSPACE_MONOCHROME 1001 47 -#define GGRAPH_COLORSPACE_PALETTE 1002 48 -#define GGRAPH_COLORSPACE_GRAYSCALE 1003 49 -#define GGRAPH_COLORSPACE_TRUECOLOR 1004 50 -#define GGRAPH_COLORSPACE_TRUECOLOR_ALPHA 1005 51 -#define GGRAPH_COLORSPACE_GRID 1006 52 - 53 -#define GGRAPH_SAMPLE_UNKNOWN -1500 54 -#define GGRAPH_SAMPLE_UINT 1501 55 -#define GGRAPH_SAMPLE_INT 1502 56 -#define GGRAPH_SAMPLE_FLOAT 1503 57 - 58 -#define GGRAPH_TIFF_DEFAULT -1001 59 - 60 -#define GGRAPH_TIFF_LAYOUT_STRIPS 2001 61 -#define GGRAPH_TIFF_LAYOUT_TILES 2002 62 - 63 -#define GGRAPH_TIFF_COMPRESSION_UNKNOWN -3000 64 -#define GGRAPH_TIFF_COMPRESSION_NONE 3001 65 -#define GGRAPH_TIFF_COMPRESSION_CCITTFAX3 3002 66 -#define GGRAPH_TIFF_COMPRESSION_CCITTFAX4 3003 67 -#define GGRAPH_TIFF_COMPRESSION_LZW 3004 68 -#define GGRAPH_TIFF_COMPRESSION_DEFLATE 3005 69 -#define GGRAPH_TIFF_COMPRESSION_JPEG 3006 70 - 71 -#define GGRAPH_IMAGE_UNKNOWN -4000 72 -#define GGRAPH_IMAGE_GIF 4001 73 -#define GGRAPH_IMAGE_PNG 4002 74 -#define GGRAPH_IMAGE_JPEG 4003 75 -#define GGRAPH_IMAGE_TIFF 4004 76 -#define GGRAPH_IMAGE_GEOTIFF 4005 77 -#define GGRAPH_IMAGE_HGT 4006 78 -#define GGRAPH_IMAGE_BIN_HDR 4007 79 -#define GGRAPH_IMAGE_FLT_HDR 4008 80 -#define GGRAPH_IMAGE_DEM_HDR 4009 81 -#define GGRAPH_IMAGE_ASCII_GRID 4010 82 - 83 -#define GGRAPH_PENSTYLE_SOLID 5001 84 -#define GGRAPH_PENSTYLE_DOT 5002 85 -#define GGRAPH_PENSTYLE_LONG_DASH 5003 86 -#define GGRAPH_PENSTYLE_SHORT_DASH 5004 87 -#define GGRAPH_PENSTYLE_DOT_DASH 5005 88 - 89 -#define GGRAPH_FONTSTYLE_NORMAL 5101 90 -#define GGRAPH_FONTSTYLE_ITALIC 5102 91 - 92 -#define GGRAPH_FONTWEIGHT_NORMAL 5201 93 -#define GGRAPH_FONTWEIGHT_BOLD 5202 94 - 95 -#define GGRAPH_CLEAR_PATH 5100 96 -#define GGRAPH_PRESERVE_PATH 5101 97 - 98 - 99 -#define GGRAPH_OK 0 100 -#define GGRAPH_ERROR -1 101 -#define GGRAPH_INVALID_IMAGE -2 102 -#define GGRAPH_INSUFFICIENT_MEMORY -3 103 -#define GGRAPH_FILE_OPEN_ERROR -4 104 -#define GGRAPH_FILE_READ_ERROR -5 105 -#define GGRAPH_FILE_WRITE_ERROR -6 106 -#define GGRAPH_GIF_CODEC_ERROR -7 107 -#define GGRAPH_PNG_CODEC_ERROR -8 108 -#define GGRAPH_JPEG_CODEC_ERROR -9 109 -#define GGRAPH_TIFF_CODEC_ERROR -10 110 -#define GGRAPH_GEOTIFF_CODEC_ERROR -11 111 -#define GGRAPH_HGT_CODEC_ERROR -12 112 -#define GGRAPH_BIN_CODEC_ERROR -13 113 -#define GGRAPH_FLT_CODEC_ERROR -14 114 -#define GGRAPH_DEM_CODEC_ERROR -15 115 -#define GGRAPH_ASCII_CODEC_ERROR -16 116 -#define GGRAPH_UNSUPPORTED_TIFF_LAYOUT -17 117 -#define GGRAPH_MISSING_GEO_DEFS -18 118 -#define GGRAPH_INVALID_COLOR_RULE -19 119 -#define GGRAPH_INVALID_COLOR_MAP -20 120 -#define GGRAPH_INVALID_SHADED_RELIEF_3ROWS -21 121 -#define GGRAPH_INVALID_PAINT_CONTEXT -22 122 -#define GGRAPH_INVALID_PAINT_BITMAP -23 123 -#define GGRAPH_INVALID_PAINT_BRUSH -24 124 -#define GGRAPH_INVALID_PAINT_FONT -25 125 -#define GGRAPH_INVALID_SVG -26 126 - 127 -#define GGRAPH_TRUE -1 128 -#define GGRAPH_FALSE -2 129 - 130 - typedef struct gaia_graphics_landsat_recalibration 131 - { 132 -/* a struct used for Landsat Radiometric Recalibration */ 133 - double sun_distance; /* Earth-Sun distance (in AU) */ 134 - double sun_elevation; /* Sun elevation (in degrees) */ 135 -/* RED band params (#3) */ 136 - double lmin_red; /* LMIN (from metafile) */ 137 - double lmax_red; /* LMAX (from metafile) */ 138 - double qcalmin_red; /* QCALMIN (from metafile) */ 139 - double qcalmax_red; /* QCALMAX (from metafile) */ 140 - int is_gain_low_red; /* GAIN LOW (1=yes 0=no) (from metafile) */ 141 - double spectral_irradiance_red; /* SPECTRAL IRRADIANCE constant */ 142 - double low_gain_factor_red; /* LOW GAIN multiplicator */ 143 - double high_gain_factor_red; /* HIGH GAIN multiplicator */ 144 - unsigned char recalibration_min_red; /* color recalibration MIN DN [0-255] */ 145 - unsigned char recalibration_max_red; /* color recalibration MAX DN [0-255] */ 146 -/* GREEN band params (#2) */ 147 - double lmin_green; /* same as RED band */ 148 - double lmax_green; 149 - double qcalmin_green; 150 - double qcalmax_green; 151 - int is_gain_low_green; 152 - double spectral_irradiance_green; 153 - double low_gain_factor_green; 154 - double high_gain_factor_green; 155 - unsigned char recalibration_min_green; 156 - unsigned char recalibration_max_green; 157 -/* BLUE band params (#1) */ 158 - double lmin_blue; /* same as RED band */ 159 - double lmax_blue; 160 - double qcalmin_blue; 161 - double qcalmax_blue; 162 - int is_gain_low_blue; 163 - double spectral_irradiance_blue; 164 - double low_gain_factor_blue; 165 - double high_gain_factor_blue; 166 - unsigned char recalibration_min_blue; 167 - unsigned char recalibration_max_blue; 168 -/* PANCHRO band params (#8) */ 169 - double lmin_panchro; /* same as RED band */ 170 - double lmax_panchro; 171 - double qcalmin_panchro; 172 - double qcalmax_panchro; 173 - int is_gain_low_panchro; 174 - double spectral_irradiance_panchro; 175 - double low_gain_factor_panchro; 176 - double high_gain_factor_panchro; 177 - unsigned char recalibration_min_panchro; 178 - unsigned char recalibration_max_panchro; 179 - } gGraphLandsatRecalibration; 180 - typedef gGraphLandsatRecalibration *gGraphLandsatRecalibrationPtr; 181 - 182 - GGRAPH_DECLARE int gGraphCreateContext (int width, int height, 183 - const void **context); 184 - GGRAPH_DECLARE int gGraphDestroyContext (const void *context); 185 - GGRAPH_DECLARE int gGraphCreateSvgContext (const char *path, int width, 186 - int height, 187 - const void **context); 188 - GGRAPH_DECLARE int gGraphDestroySvgContext (const void *context); 189 - GGRAPH_DECLARE int gGraphCreatePdfContext (const char *path, int page_width, 190 - int page_height, int width, 191 - int height, 192 - const void **context); 193 - GGRAPH_DECLARE int gGraphDestroyPdfContext (const void *context); 194 - GGRAPH_DECLARE int gGraphSetPen (const void *context, unsigned char red, 195 - unsigned char green, unsigned char blue, 196 - unsigned char alpha, double width, 197 - int style); 198 - GGRAPH_DECLARE int gGraphSetBrush (const void *context, unsigned char red, 199 - unsigned char green, unsigned char blue, 200 - unsigned char alpha); 201 - GGRAPH_DECLARE int gGraphSetLinearGradientBrush (const void *context, 202 - double x, double y, 203 - double width, 204 - double height, 205 - unsigned char red1, 206 - unsigned char green1, 207 - unsigned char blue1, 208 - unsigned char alpha1, 209 - unsigned char red2, 210 - unsigned char green2, 211 - unsigned char blue2, 212 - unsigned char alpha2); 213 - GGRAPH_DECLARE int gGraphSetPatternBrush (const void *context, 214 - const void *brush); 215 - GGRAPH_DECLARE int gGraphSetFont (const void *context, const void *font); 216 - GGRAPH_DECLARE int gGraphFillPath (const void *context, int preserve); 217 - GGRAPH_DECLARE int gGraphStrokePath (const void *context, int preserve); 218 - GGRAPH_DECLARE int gGraphMoveToPoint (const void *context, double x, 219 - double y); 220 - GGRAPH_DECLARE int gGraphAddLineToPath (const void *context, double x, 221 - double y); 222 - GGRAPH_DECLARE int gGraphCloseSubpath (const void *context); 223 - GGRAPH_DECLARE int gGraphStrokeLine (const void *context, double x0, 224 - double y0, double x1, double y1); 225 - GGRAPH_DECLARE int gGraphDrawEllipse (const void *context, double x, 226 - double y, double width, 227 - double height); 228 - GGRAPH_DECLARE int gGraphDrawRectangle (const void *context, double x, 229 - double y, double width, 230 - double height); 231 - GGRAPH_DECLARE int gGraphDrawRoundedRectangle (const void *context, 232 - double x, double y, 233 - double width, double height, 234 - double radius); 235 - GGRAPH_DECLARE int gGraphDrawCircleSector (const void *context, 236 - double center_x, double center_y, 237 - double radius, double from_angle, 238 - double to_angle); 239 - GGRAPH_DECLARE int gGraphGetTextExtent (const void *context, 240 - const char *text, double *pre_x, 241 - double *pre_y, double *width, 242 - double *height, double *post_x, 243 - double *post_y); 244 - GGRAPH_DECLARE int gGraphDrawText (const void *context, const char *text, 245 - double x, double y, double angle); 246 - GGRAPH_DECLARE int gGraphGetContextRgbArray (const void *context, 247 - unsigned char **rgbArray); 248 - GGRAPH_DECLARE int gGraphGetContextAlphaArray (const void *context, 249 - unsigned char **alphaArray); 250 - GGRAPH_DECLARE int gGraphDrawBitmap (const void *context, 251 - const void *bitmap, int x, int y); 252 - GGRAPH_DECLARE int gGraphCreateBitmap (unsigned char *rgbaArray, int width, 253 - int height, const void **bitmap); 254 - GGRAPH_DECLARE int gGraphDestroyBitmap (const void *bitmap); 255 - GGRAPH_DECLARE int gGraphCreateBrush (unsigned char *rgbaArray, int width, 256 - int height, const void **brush); 257 - GGRAPH_DECLARE int gGraphDestroyBrush (const void *brush); 258 - GGRAPH_DECLARE int gGraphCreateFont (double size, int style, int weight, 259 - const void **font); 260 - GGRAPH_DECLARE int gGraphDestroyFont (const void *font); 261 - GGRAPH_DECLARE int gGraphFontSetColor (const void *font, unsigned char red, 262 - unsigned char green, 263 - unsigned char blue, 264 - unsigned char alpha); 265 - GGRAPH_DECLARE int gGraphFontSetOutline (const void *font, double width); 266 - 267 -/* 268 -/ image access methods 269 -*/ 270 - GGRAPH_DECLARE const void *gGraphCreateRgbImage (int width, int height); 271 - GGRAPH_DECLARE const void *gGraphCreateRgbImageFromBitmap (unsigned char 272 - *bitmap, 273 - int width, 274 - int height); 275 - GGRAPH_DECLARE const void *gGraphCreateRgbaImage (int width, int height); 276 - GGRAPH_DECLARE const void *gGraphCreateGrayscaleImage (int width, 277 - int height); 278 - GGRAPH_DECLARE const void *gGraphCreatePaletteImage (int width, int height); 279 - GGRAPH_DECLARE const void *gGraphCreateMonochromeImage (int width, 280 - int height); 281 - GGRAPH_DECLARE const void *gGraphCreateGridInt16Image (int width, 282 - int height); 283 - GGRAPH_DECLARE const void *gGraphCreateGridUInt16Image (int width, 284 - int height); 285 - GGRAPH_DECLARE const void *gGraphCreateGridInt32Image (int width, 286 - int height); 287 - GGRAPH_DECLARE const void *gGraphCreateGridUInt32Image (int width, 288 - int height); 289 - GGRAPH_DECLARE const void *gGraphCreateGridFloatImage (int width, 290 - int height); 291 - GGRAPH_DECLARE const void *gGraphCreateGridDoubleImage (int width, 292 - int height); 293 - GGRAPH_DECLARE int gGraphImageBackgroundFill (const void *img, 294 - unsigned char red, 295 - unsigned char green, 296 - unsigned char blue, 297 - unsigned char alpha); 298 - GGRAPH_DECLARE int gGraphImageSetTransparentColor (const void *img, 299 - unsigned char red, 300 - unsigned char green, 301 - unsigned char blue); 302 - GGRAPH_DECLARE int gGraphImageGetTransparentColor (const void *img, 303 - unsigned char *red, 304 - unsigned char *green, 305 - unsigned char *blue); 306 - GGRAPH_DECLARE int gGraphGridBackgroundFill (const void *img, 307 - double no_data_value); 308 - GGRAPH_DECLARE int gGraphImageSetNoDataValue (const void *img, 309 - double no_data_vale); 310 - GGRAPH_DECLARE int gGraphImageGetNoDataValue (const void *img, 311 - double *no_data_value); 312 - GGRAPH_DECLARE void gGraphDestroyImage (const void *img); 313 - GGRAPH_DECLARE void gGraphDestroyImageInfos (const void *img); 314 - GGRAPH_DECLARE int gGraphGetImageDims (const void *img, int *width, 315 - int *height); 316 - GGRAPH_DECLARE int gGraphGetImageInfos (const void *img, int *width, 317 - int *height, int *colorspace, 318 - int *max_palette, 319 - int *bits_per_sample, 320 - int *samples_per_pixel, 321 - int *sample_format, int *tile_width, 322 - int *tile_height, 323 - int *rows_per_strip, 324 - int *compression, 325 - double *no_data_value, 326 - double *min_value, 327 - double *max_value, int *scale_1_2, 328 - int *scale_1_4, int *scale_1_8); 329 - GGRAPH_DECLARE int gGraphGetImageSize (const void *img, int *size); 330 - GGRAPH_DECLARE int gGraphImageColorSpaceOptimize (const void *img); 331 - GGRAPH_DECLARE int gGraphImageResampleAsRgb (const void *img); 332 - GGRAPH_DECLARE int gGraphImageResampleAsMonochrome (const void *img); 333 - GGRAPH_DECLARE int gGraphImageResampleAsPalette (const void *img, 334 - int num_colors); 335 - GGRAPH_DECLARE int gGraphImageResampleAsGrayscale (const void *img); 336 - GGRAPH_DECLARE int gGraphImageResampleAsPhotographic (const void *img); 337 - GGRAPH_DECLARE int gGraphImageResampleAsGridInt16 (const void *img); 338 - GGRAPH_DECLARE int gGraphImageResampleAsGridUInt16 (const void *img); 339 - GGRAPH_DECLARE int gGraphImageResampleAsGridInt32 (const void *img); 340 - GGRAPH_DECLARE int gGraphImageResampleAsGridUInt32 (const void *img); 341 - GGRAPH_DECLARE int gGraphImageResampleAsGridFloat (const void *img); 342 - GGRAPH_DECLARE int gGraphImageResampleAsGridDouble (const void *img); 343 - GGRAPH_DECLARE int gGraphImageTransparentResample (const void *img); 344 - GGRAPH_DECLARE int gGraphImageGuessFormat (const void *mem_buf, 345 - int mem_buf_size); 346 - GGRAPH_DECLARE int gGraphFileImageGuessFormat (const char *path, int *type); 347 - 348 -/* 349 -/ the following methods return a copy of the internal image buffer 350 -/ PLEASE NOTE: you are responsible to free() the returned memory block 351 -*/ 352 - GGRAPH_DECLARE int gGraphImageBufferReferenceRGB (const void *img, 353 - unsigned char **buffer); 354 - GGRAPH_DECLARE int gGraphImageBufferReferenceRGBA (const void *img, 355 - unsigned char **buffer); 356 - GGRAPH_DECLARE int gGraphImageBufferReferenceARGB (const void *img, 357 - unsigned char **buffer); 358 - GGRAPH_DECLARE int gGraphImageBufferReferenceBGR (const void *img, 359 - unsigned char **buffer); 360 - GGRAPH_DECLARE int gGraphImageBufferReferenceBGRA (const void *img, 361 - unsigned char **buffer); 362 - 363 -/* 364 -/ image resizing / image subsetting 365 -*/ 366 - GGRAPH_DECLARE int gGraphImageResizeNormal (const void *orig, 367 - const void **dest, int width, 368 - int height); 369 - GGRAPH_DECLARE int gGraphImageResizeHighQuality (const void *orig, 370 - const void **dest, 371 - int width, int height); 372 - GGRAPH_DECLARE int gGraphImageResizeToResolution (const void *orig, 373 - const void **dest, 374 - double pixel_x_size, 375 - double pixel_y_size, 376 - int *width, int *height); 377 - GGRAPH_DECLARE int gGraphImageSubSet (const void *orig, const void **dest, 378 - int upper_left_x, int upper_left_y, 379 - int width, int height); 380 - 381 -/* 382 -/ utility functions handling image georeferencing 383 -*/ 384 - GGRAPH_DECLARE int gGraphGetWorldFilePath (const char *main_path, 385 - char *world_file_path); 386 - 387 - GGRAPH_DECLARE int gGraphCheckHgtPath (const char *path, int *lat, 388 - int *lon); 389 - GGRAPH_DECLARE int gGraphCheckBinPath (const char *path, char *hdr_path, 390 - int dont_test); 391 - GGRAPH_DECLARE int gGraphCheckFltPath (const char *path, char *hdr_path, 392 - int dont_test); 393 - GGRAPH_DECLARE int gGraphCheckDemPath (const char *path, char *hdr_path, 394 - int dont_test); 395 - GGRAPH_DECLARE int gGraphCheckAscPath (const char *path); 396 - 397 - GGRAPH_DECLARE int gGraphImageIsGeoRef (const void *img); 398 - GGRAPH_DECLARE int gGraphImageSetGeoRef (const void *img, int srid, 399 - const char *srs_name, 400 - const char *proj4text, 401 - double upper_left_x, 402 - double upper_left_y, 403 - double pixel_x_size, 404 - double pixel_y_size); 405 - GGRAPH_DECLARE int gGraphImageGetGeoRef (const void *img, int *srid, 406 - char *srs_name, 407 - char *proj4text, 408 - double *upper_left_x, 409 - double *upper_left_y, 410 - double *pixel_x_size, 411 - double *pixel_y_size); 412 - GGRAPH_DECLARE int gGraphImageInfosGetGeoRef (const void *img, 413 - int *srid, 414 - char *srs_name, 415 - char *proj4text, 416 - double *upper_left_x, 417 - double *upper_left_y, 418 - double *pixel_x_size, 419 - double *pixel_y_size); 420 - GGRAPH_DECLARE int gGraphReadWorldFile (const char *path, 421 - double *upper_left_x, 422 - double *upper_left_y, 423 - double *pixel_x_size, 424 - double *pixel_y_size); 425 - 426 -/* 427 -/ utility functions returning an image 428 -*/ 429 - GGRAPH_DECLARE int gGraphImageFromFile (const char *path, int image_type, 430 - const void **image_handle, 431 - int scale); 432 - GGRAPH_DECLARE int gGraphImageFromMemBuf (const void *mem_buf, 433 - int mem_buf_size, int image_type, 434 - const void **image_handle, 435 - int scale); 436 - 437 -/* 438 -/ utility functions returning image infos 439 -*/ 440 - GGRAPH_DECLARE int gGraphImageInfosFromHgtFile (const char *path, 441 - int lat, int lon, 442 - const void **infos_handle); 443 - GGRAPH_DECLARE int gGraphImageInfosFromBinFile (const char *path, 444 - const char *hdr_path, 445 - const void **infos_handle); 446 - GGRAPH_DECLARE int gGraphImageInfosFromFltFile (const char *path, 447 - const char *hdr_path, 448 - const void **infos_handle); 449 - GGRAPH_DECLARE int gGraphImageInfosFromDemFile (const char *path, 450 - const char *hdr_path, 451 - const void **infos_handle); 452 - GGRAPH_DECLARE int gGraphImageInfosFromAscFile (const char *path, 453 - const void **infos_handle); 454 - GGRAPH_DECLARE int gGraphImageInfosFromFile (const char *path, 455 - int image_type, 456 - const void **infos_handle); 457 - GGRAPH_DECLARE int gGraphImageInfosFromMemBuf (const void *mem_buf, 458 - int mem_buf_size, 459 - int image_type, 460 - const void **infos_handle); 461 - 462 -/* 463 -/ utility functions generating a file from an image 464 -*/ 465 - GGRAPH_DECLARE int gGraphImageToJpegFile (const void *img, const char *path, 466 - int quality); 467 - GGRAPH_DECLARE int gGraphImageToPngFile (const void *img, const char *path, 468 - int compression_level, 469 - int quantization_factor, 470 - int interlaced); 471 - GGRAPH_DECLARE int gGraphImageToGifFile (const void *img, const char *path); 472 - 473 -/* 474 -/ utility functions generating a memory buffer from an image 475 -*/ 476 - GGRAPH_DECLARE int gGraphImageToJpegMemBuf (const void *img, void **mem_buf, 477 - int *mem_buf_size, 478 - int jpeg_quality); 479 - GGRAPH_DECLARE int gGraphImageToPngMemBuf (const void *img, void **mem_buf, 480 - int *mem_buf_size, 481 - int compression_level, 482 - int quantization_factor, 483 - int interlaced, 484 - int is_transparent); 485 - GGRAPH_DECLARE int gGraphImageToGifMemBuf (const void *img, void **mem_buf, 486 - int *mem_buf_size, 487 - int is_transparent); 488 - 489 -/* 490 -/ utility functions handling Adam7 and Monochrome encoding 491 -*/ 492 - GGRAPH_DECLARE int gGraphImageToAdam7 (const void *img, void *mem_bufs[7], 493 - int mem_buf_sizes[7], void **palette, 494 - int *palette_size); 495 - GGRAPH_DECLARE int gGraphImageFromAdam7 (void *mem_bufs[7], 496 - int mem_buf_sizes[7], 497 - void *palette, int palette_size, 498 - const void **image_handle, 499 - int scale); 500 - GGRAPH_DECLARE int gGraphImageToMonochrome (const void *img, void **mem_buf, 501 - int *mem_buf_size); 502 - GGRAPH_DECLARE int gGraphImageFromMonochrome (const void *mem_buf, 503 - int mem_buf_size, 504 - const void **image_handle); 505 - 506 -/* 507 -/ functions for RAW image handling 508 -*/ 509 - GGRAPH_DECLARE int gGraphImageFromRawMemBuf (const void *mem_buf, 510 - int mem_buf_size, 511 - const void **image_handle); 512 - GGRAPH_DECLARE int gGraphIsRawImage (const void *mem_buf, int mem_buf_size); 513 - 514 -/* 515 -/ methods accessing a file-based Image by Strips 516 -*/ 517 - GGRAPH_DECLARE int gGraphImageFromHgtFileByStrips (const char *path, 518 - int lat, int lon, 519 - const void 520 - **strip_handle); 521 - GGRAPH_DECLARE int gGraphImageFromBinFileByStrips (const char *path, 522 - const char *hdr_path, 523 - const void 524 - **strip_handle); 525 - GGRAPH_DECLARE int gGraphImageFromFltFileByStrips (const char *path, 526 - const char *hdr_path, 527 - const void 528 - **strip_handle); 529 - GGRAPH_DECLARE int gGraphImageFromDemFileByStrips (const char *path, 530 - const char *hdr_path, 531 - const void 532 - **strip_handle); 533 - GGRAPH_DECLARE int gGraphImageFromAscFileByStrips (const char *path, 534 - const void 535 - **strip_handle); 536 - GGRAPH_DECLARE int gGraphImageFromFileByStrips (const char *path, 537 - int image_type, 538 - const void **strip_handle); 539 - GGRAPH_DECLARE int gGraphReadNextStrip (const void *strip_handle, 540 - int *progress); 541 - 542 - GGRAPH_DECLARE int gGraphImageToJpegFileByStrips (const void **strip_handle, 543 - const char *path, 544 - int width, int height, 545 - int color_model, 546 - int quality); 547 - GGRAPH_DECLARE int gGraphImageToPngFileByStrips (const void **strip_handle, 548 - const char *path, 549 - int width, int height, 550 - int color_model, 551 - int bits_per_sample, 552 - int num_palette, 553 - unsigned char *red, 554 - unsigned char *green, 555 - unsigned char *blue, 556 - int compression_level, 557 - int quantization_factor); 558 - GGRAPH_DECLARE int gGraphImageToTiffFileByStrips (const void **strip_handle, 559 - const char *path, 560 - int width, int height, 561 - int color_model, 562 - int is_tiled, 563 - int tile_width, 564 - int tile_height, 565 - int rows_per_strip, 566 - int bits_per_sample, 567 - int sample_format, 568 - int num_palette, 569 - unsigned char *red, 570 - unsigned char *green, 571 - unsigned char *blue, 572 - int compression); 573 - GGRAPH_DECLARE int gGraphImageToGeoTiffFileByStrips (const void 574 - **strip_handle, 575 - const char *path, 576 - int width, int height, 577 - int color_model, 578 - int is_tiled, 579 - int tile_width, 580 - int tile_height, 581 - int rows_per_strip, 582 - int bits_per_sample, 583 - int sample_format, 584 - int num_palette, 585 - unsigned char *red, 586 - unsigned char *green, 587 - unsigned char *blue, 588 - int compression, 589 - int srid, 590 - const char *srs_name, 591 - const char *proj4text, 592 - double upper_left_x, 593 - double upper_left_y, 594 - double pixel_x_size, 595 - double pixel_y_size); 596 - GGRAPH_DECLARE int gGraphImageToBinHdrFileByStrips (const void 597 - **strip_handle, 598 - const char *path, 599 - int width, int height, 600 - int bits_per_sample, 601 - double upper_left_x, 602 - double upper_left_y, 603 - double pixel_x_size, 604 - double pixel_y_size, 605 - double no_data_value); 606 - GGRAPH_DECLARE int gGraphImageToFltHdrFileByStrips (const void 607 - **strip_handle, 608 - const char *path, 609 - int width, int height, 610 - int bits_per_sample, 611 - double upper_left_x, 612 - double upper_left_y, 613 - double pixel_x_size, 614 - double pixel_y_size, 615 - double no_data_value); 616 - GGRAPH_DECLARE int gGraphImageToAscFileByStrips (const void **strip_handle, 617 - const char *path, 618 - int width, int height, 619 - int sample, 620 - int bits_per_sample, 621 - double upper_left_x, 622 - double upper_left_y, 623 - double pixel_x_size, 624 - double pixel_y_size, 625 - double no_data_value); 626 - GGRAPH_DECLARE int gGraphWriteNextStrip (const void *strip_handle, 627 - int *progress); 628 - GGRAPH_DECLARE int gGraphWriteBinHeader (const char *hdr_path, 629 - const void *strip_handle); 630 - GGRAPH_DECLARE int gGraphWriteFltHeader (const char *hdr_path, 631 - const void *strip_handle); 632 - 633 - GGRAPH_DECLARE int gGraphStripImageClonePalette (const void *strip_handle, 634 - int *color_model, 635 - int *num_palette, 636 - unsigned char *red, 637 - unsigned char *green, 638 - unsigned char *blue); 639 - GGRAPH_DECLARE int gGraphStripImageAllocPixels (const void *strip_handle, 640 - int rows_per_block); 641 - GGRAPH_DECLARE int gGraphStripImageEOF (const void *strip_handle); 642 - GGRAPH_DECLARE int gGraphStripImageCopyPixels (const void *in_strip_handle, 643 - const void 644 - *out_strip_handle); 645 - GGRAPH_DECLARE int gGraphStripImageRenderGridPixels (const void 646 - *in_strip_handle, 647 - const void 648 - *out_strip_handle, 649 - const void 650 - *color_map_handle, 651 - int num_threads); 652 - GGRAPH_DECLARE int gGraphStripImageSubSetPixels (const void 653 - *in_strip_handle, 654 - const void 655 - *out_strip_handle, 656 - int start_from, int row); 657 - GGRAPH_DECLARE int gGraphStripImageGetNextRow (const void *in_strip_handle, 658 - int *next_row); 659 - GGRAPH_DECLARE int gGraphStripIsFull (const void *in_strip_handle); 660 - GGRAPH_DECLARE int gGraphGetStripImageMinMaxValue (const void 661 - *in_strip_handle, 662 - double *min_value, 663 - double *max_value, 664 - double no_data_value); 665 - 666 - GGRAPH_DECLARE int gGraphStripImageRewind (const void *in_strip_handle); 667 - GGRAPH_DECLARE int gGraphStripImageGetCurrentRows (const void 668 - *in_strip_handle, 669 - int *rows); 670 - GGRAPH_DECLARE int gGraphStripImageSetCurrentRows (const void 671 - *in_strip_handle, 672 - int rows); 673 - GGRAPH_DECLARE int gGraphStripImageGetPixelRGB (const void *in_strip_handle, 674 - int col, int row, 675 - unsigned char *red, 676 - unsigned char *green, 677 - unsigned char *blue); 678 - GGRAPH_DECLARE int gGraphStripImageSetPixelRGB (const void *in_strip_handle, 679 - int col, int row, 680 - unsigned char red, 681 - unsigned char green, 682 - unsigned char blue); 683 - 684 - GGRAPH_DECLARE int gGraphCountColors (const char *path, int image_type, 685 - int rows_per_block); 686 - GGRAPH_DECLARE void gGraphSmartPrintf (double value, char *buf); 687 - 688 - GGRAPH_DECLARE int gGraphColorRuleFromFile (const char *path, 689 - const void **color_rule); 690 - GGRAPH_DECLARE int gGraphColorRuleFromMemBuf (char *buf, 691 - const void **color_rule); 692 - GGRAPH_DECLARE void gGraphDestroyColorRule (const void *color_rule); 693 - GGRAPH_DECLARE int gGraphIsColorRuleRelative (const void *color_rule, 694 - int *relative); 695 - GGRAPH_DECLARE int gGraphCreateColorMapAbsolute (const void *color_rule, 696 - unsigned char 697 - background_red, 698 - unsigned char 699 - background_green, 700 - unsigned char 701 - background_blue, 702 - const void **color_map); 703 - GGRAPH_DECLARE int gGraphCreateColorMapRelative (const void *color_rule, 704 - double min, double max, 705 - unsigned char 706 - background_red, 707 - unsigned char 708 - background_green, 709 - unsigned char 710 - background_blue, 711 - const void **color_map); 712 - GGRAPH_DECLARE void gGraphDestroyColorMap (const void *color_map); 713 - 714 - GGRAPH_DECLARE int gGraphCreateShadedReliefTripleRow (int width, 715 - unsigned char 716 - background_red, 717 - unsigned char 718 - background_green, 719 - unsigned char 720 - background_blue, 721 - double no_data, 722 - const void 723 - *color_map_handle, 724 - unsigned char 725 - mono_red, 726 - unsigned char 727 - mono_green, 728 - unsigned char 729 - mono_blue, 730 - double z_factor, 731 - double scale_factor, 732 - double azimuth, 733 - double altitude, 734 - const void 735 - **triple_row_handle); 736 - GGRAPH_DECLARE void gGraphDestroyShadedReliefTripleRow (const void 737 - *triple_row_handle); 738 - 739 - GGRAPH_DECLARE int gGraphShadedReliefRenderPixels (const void 740 - *triple_row_handle, 741 - int num_threads, 742 - int *out_row_ready); 743 - GGRAPH_DECLARE int gGraphStripImageGetShadedReliefScanline (const void 744 - *in_img_handle, 745 - int row_index, 746 - const void 747 - *triple_row_handle); 748 - GGRAPH_DECLARE int gGraphStripImageSetShadedReliefScanline (const void 749 - *triple_row_handle, 750 - const void 751 - *out_img_handle, 752 - int row_index); 753 - GGRAPH_DECLARE int gGraphLandsatRGB (const void *img_red, 754 - const void *img_green, 755 - const void *img_blue, 756 - const void *img_rgb, int width, 757 - int num_rows, 758 - gGraphLandsatRecalibrationPtr params, 759 - int num_threads); 760 - GGRAPH_DECLARE int gGraphLandsatBW (const void *img_in, const void *img_out, 761 - int width, int num_rows, 762 - gGraphLandsatRecalibrationPtr params, 763 - int num_threads); 764 - GGRAPH_DECLARE int gGraphGetLandsatSceneExtent (const void *img_in, 765 - int base_row, double *top_x, 766 - double *top_y, 767 - double *bottom_x, 768 - double *bottom_y, 769 - double *left_x, 770 - double *left_y, 771 - double *right_x, 772 - double *right_y); 773 - GGRAPH_DECLARE int gGraphLandsatMergePixels (const void *img_in, 774 - int base_row, 775 - const void *img_out); 776 - GGRAPH_DECLARE int gGraphOutputPixelsToStripImage (const void *img_in, 777 - const void *img_out, 778 - int in_row, int out_row); 779 - GGRAPH_DECLARE int gGraphInputPixelsFromStripImage (const void *img_in, 780 - const void *img_out, 781 - int in_col); 782 - GGRAPH_DECLARE int gGraphGeoMergePixels (const void *img_in, 783 - const void *img_out); 784 - GGRAPH_DECLARE int gGraphImageFromStripImage (const void *img_in, 785 - int color_space, 786 - int sample_format, 787 - int bits_per_sample, 788 - int samples_per_pixel, 789 - int start_line, 790 - const void **img_out); 791 - 792 -/* SVG images */ 793 - GGRAPH_DECLARE int gGraphCreateSVG (const unsigned char *svg_document, 794 - int svg_bytes, void **svg_handle); 795 - GGRAPH_DECLARE int gGraphGetSVGDims (void *svg_handle, double *width, 796 - double *height); 797 - GGRAPH_DECLARE int gGraphImageFromSVG (void *handle, double size, 798 - const void **img_out); 799 - GGRAPH_DECLARE int gGraphFreeSVG (void *sgv_handle); 800 - 801 -#ifdef __cplusplus 802 -} 803 -#endif 804 - 805 -#endif /* _GGRAPH_H */
Deleted headers/gaiagraphics_internals.h.
1 -/* 2 -/ GGRAPH_internals.h 3 -/ 4 -/ internal declarations 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <cairo/cairo.h> 28 -#include <cairo/cairo-svg.h> 29 -#include <cairo/cairo-pdf.h> 30 - 31 -#ifdef _WIN32 32 -#ifdef DLL_EXPORT 33 -#define GGRAPH_PRIVATE 34 -#else 35 -#define GGRAPH_PRIVATE 36 -#endif 37 -#else 38 -#define GGRAPH_PRIVATE __attribute__ ((visibility("hidden"))) 39 -#endif 40 - 41 -#define GG_IMAGE_JPEG_RGB 100 42 -#define GG_IMAGE_JPEG_BW 101 43 -#define GG_IMAGE_TIFF_FAX4 102 44 -#define GG_IMAGE_TIFF_PALETTE 103 45 -#define GG_IMAGE_TIFF_GRAYSCALE 104 46 -#define GG_IMAGE_TIFF_RGB 105 47 -#define GG_IMAGE_PNG_PALETTE 106 48 -#define GG_IMAGE_PNG_GRAYSCALE 107 49 -#define GG_IMAGE_PNG_RGB 108 50 -#define GG_IMAGE_GIF_PALETTE 109 51 - 52 -#define GG_PIXEL_UNKNOWN -200 53 -#define GG_PIXEL_RGB 201 54 -#define GG_PIXEL_RGBA 202 55 -#define GG_PIXEL_ARGB 203 56 -#define GG_PIXEL_BGR 204 57 -#define GG_PIXEL_BGRA 205 58 -#define GG_PIXEL_GRAYSCALE 206 59 -#define GG_PIXEL_PALETTE 207 60 -#define GG_PIXEL_GRID 208 61 - 62 -#define GG_TARGET_IS_MEMORY 2001 63 -#define GG_TARGET_IS_FILE 2002 64 - 65 -#define GG_IMAGE_MAGIC_SIGNATURE 65391 66 -#define GG_IMAGE_INFOS_MAGIC_SIGNATURE 37183 67 -#define GG_STRIP_IMAGE_MAGIC_SIGNATURE 17359 68 -#define GG_COLOR_RULE_MAGIC_SIGNATURE 23713 69 -#define GG_COLOR_MAP_MAGIC_SIGNATURE 27317 70 -#define GG_SHADED_RELIEF_3ROWS_MAGIC_SIGNATURE 18573 71 - 72 -#define GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE 1314 73 -#define GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE 1334 74 -#define GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE 1374 75 -#define GG_GRAPHICS_BITMAP_MAGIC_SIGNATURE 5317 76 -#define GG_GRAPHICS_BRUSH_MAGIC_SIGNATURE 2671 77 -#define GG_GRAPHICS_FONT_MAGIC_SIGNATURE 7459 78 -#define GG_GRAPHICS_SVG_MAGIC_SIGNATURE 3265 79 - 80 -/* ADAM7/RAW markers */ 81 -#define GG_MONOCHROME_START 3301 82 -#define GG_MONOCHROME_END 3311 83 -#define GG_ADAM7_PALETTE_START 3901 84 -#define GG_ADAM7_PALETTE_END 3911 85 -#define GG_ADAM7_0_RGB_START 3001 86 -#define GG_ADAM7_0_RGB_END 3011 87 -#define GG_ADAM7_1_RGB_START 3002 88 -#define GG_ADAM7_1_RGB_END 3012 89 -#define GG_ADAM7_2_RGB_START 3003 90 -#define GG_ADAM7_2_RGB_END 3013 91 -#define GG_ADAM7_3_RGB_START 3004 92 -#define GG_ADAM7_3_RGB_END 3014 93 -#define GG_ADAM7_4_RGB_START 3005 94 -#define GG_ADAM7_4_RGB_END 3015 95 -#define GG_ADAM7_5_RGB_START 3006 96 -#define GG_ADAM7_5_RGB_END 3016 97 -#define GG_ADAM7_6_RGB_START 3007 98 -#define GG_ADAM7_6_RGB_END 3017 99 -#define GG_ADAM7_0_GRAYSCALE_START 3101 100 -#define GG_ADAM7_0_GRAYSCALE_END 3111 101 -#define GG_ADAM7_1_GRAYSCALE_START 3102 102 -#define GG_ADAM7_1_GRAYSCALE_END 3112 103 -#define GG_ADAM7_2_GRAYSCALE_START 3103 104 -#define GG_ADAM7_2_GRAYSCALE_END 3113 105 -#define GG_ADAM7_3_GRAYSCALE_START 3104 106 -#define GG_ADAM7_3_GRAYSCALE_END 3114 107 -#define GG_ADAM7_4_GRAYSCALE_START 3105 108 -#define GG_ADAM7_4_GRAYSCALE_END 3115 109 -#define GG_ADAM7_5_GRAYSCALE_START 3106 110 -#define GG_ADAM7_5_GRAYSCALE_END 3116 111 -#define GG_ADAM7_6_GRAYSCALE_START 3107 112 -#define GG_ADAM7_6_GRAYSCALE_END 3117 113 -#define GG_ADAM7_0_PALETTE_START 3201 114 -#define GG_ADAM7_0_PALETTE_END 3211 115 -#define GG_ADAM7_1_PALETTE_START 3202 116 -#define GG_ADAM7_1_PALETTE_END 3212 117 -#define GG_ADAM7_2_PALETTE_START 3203 118 -#define GG_ADAM7_2_PALETTE_END 3213 119 -#define GG_ADAM7_3_PALETTE_START 3204 120 -#define GG_ADAM7_3_PALETTE_END 3214 121 -#define GG_ADAM7_4_PALETTE_START 3205 122 -#define GG_ADAM7_4_PALETTE_END 3215 123 -#define GG_ADAM7_5_PALETTE_START 3206 124 -#define GG_ADAM7_5_PALETTE_END 3216 125 -#define GG_ADAM7_6_PALETTE_START 3207 126 -#define GG_ADAM7_6_PALETTE_END 3217 127 -#define GG_ADAM7_0_INT16_START 3401 128 -#define GG_ADAM7_0_INT16_END 3411 129 -#define GG_ADAM7_1_INT16_START 3402 130 -#define GG_ADAM7_1_INT16_END 3412 131 -#define GG_ADAM7_2_INT16_START 3403 132 -#define GG_ADAM7_2_INT16_END 3413 133 -#define GG_ADAM7_3_INT16_START 3404 134 -#define GG_ADAM7_3_INT16_END 3414 135 -#define GG_ADAM7_4_INT16_START 3405 136 -#define GG_ADAM7_4_INT16_END 3415 137 -#define GG_ADAM7_5_INT16_START 3406 138 -#define GG_ADAM7_5_INT16_END 3416 139 -#define GG_ADAM7_6_INT16_START 3407 140 -#define GG_ADAM7_6_INT16_END 3417 141 -#define GG_ADAM7_0_UINT16_START 3501 142 -#define GG_ADAM7_0_UINT16_END 3511 143 -#define GG_ADAM7_1_UINT16_START 3502 144 -#define GG_ADAM7_1_UINT16_END 3512 145 -#define GG_ADAM7_2_UINT16_START 3503 146 -#define GG_ADAM7_2_UINT16_END 3513 147 -#define GG_ADAM7_3_UINT16_START 3504 148 -#define GG_ADAM7_3_UINT16_END 3514 149 -#define GG_ADAM7_4_UINT16_START 3505 150 -#define GG_ADAM7_4_UINT16_END 3515 151 -#define GG_ADAM7_5_UINT16_START 3506 152 -#define GG_ADAM7_5_UINT16_END 3516 153 -#define GG_ADAM7_6_UINT16_START 3507 154 -#define GG_ADAM7_6_UINT16_END 3517 155 -#define GG_ADAM7_0_INT32_START 3501 156 -#define GG_ADAM7_0_INT32_END 3511 157 -#define GG_ADAM7_1_INT32_START 3502 158 -#define GG_ADAM7_1_INT32_END 3512 159 -#define GG_ADAM7_2_INT32_START 3503 160 -#define GG_ADAM7_2_INT32_END 3513 161 -#define GG_ADAM7_3_INT32_START 3504 162 -#define GG_ADAM7_3_INT32_END 3514 163 -#define GG_ADAM7_4_INT32_START 3505 164 -#define GG_ADAM7_4_INT32_END 3515 165 -#define GG_ADAM7_5_INT32_START 3506 166 -#define GG_ADAM7_5_INT32_END 3516 167 -#define GG_ADAM7_6_INT32_START 3507 168 -#define GG_ADAM7_6_INT32_END 3517 169 -#define GG_ADAM7_0_UINT32_START 3601 170 -#define GG_ADAM7_0_UINT32_END 3611 171 -#define GG_ADAM7_1_UINT32_START 3602 172 -#define GG_ADAM7_1_UINT32_END 3612 173 -#define GG_ADAM7_2_UINT32_START 3603 174 -#define GG_ADAM7_2_UINT32_END 3613 175 -#define GG_ADAM7_3_UINT32_START 3604 176 -#define GG_ADAM7_3_UINT32_END 3614 177 -#define GG_ADAM7_4_UINT32_START 3605 178 -#define GG_ADAM7_4_UINT32_END 3615 179 -#define GG_ADAM7_5_UINT32_START 3606 180 -#define GG_ADAM7_5_UINT32_END 3616 181 -#define GG_ADAM7_6_UINT32_START 3607 182 -#define GG_ADAM7_6_UINT32_END 3617 183 -#define GG_ADAM7_0_FLOAT_START 3701 184 -#define GG_ADAM7_0_FLOAT_END 3711 185 -#define GG_ADAM7_1_FLOAT_START 3702 186 -#define GG_ADAM7_1_FLOAT_END 3712 187 -#define GG_ADAM7_2_FLOAT_START 3703 188 -#define GG_ADAM7_2_FLOAT_END 3713 189 -#define GG_ADAM7_3_FLOAT_START 3704 190 -#define GG_ADAM7_3_FLOAT_END 3714 191 -#define GG_ADAM7_4_FLOAT_START 3705 192 -#define GG_ADAM7_4_FLOAT_END 3715 193 -#define GG_ADAM7_5_FLOAT_START 3706 194 -#define GG_ADAM7_5_FLOAT_END 3716 195 -#define GG_ADAM7_6_FLOAT_START 3707 196 -#define GG_ADAM7_6_FLOAT_END 3717 197 -#define GG_ADAM7_0_DOUBLE_START 3801 198 -#define GG_ADAM7_0_DOUBLE_END 3811 199 -#define GG_ADAM7_1_DOUBLE_START 3802 200 -#define GG_ADAM7_1_DOUBLE_END 3812 201 -#define GG_ADAM7_2_DOUBLE_START 3803 202 -#define GG_ADAM7_2_DOUBLE_END 3813 203 -#define GG_ADAM7_3_DOUBLE_START 3804 204 -#define GG_ADAM7_3_DOUBLE_END 3814 205 -#define GG_ADAM7_4_DOUBLE_START 3805 206 -#define GG_ADAM7_4_DOUBLE_END 3815 207 -#define GG_ADAM7_5_DOUBLE_START 3806 208 -#define GG_ADAM7_5_DOUBLE_END 3816 209 -#define GG_ADAM7_6_DOUBLE_START 3807 210 -#define GG_ADAM7_6_DOUBLE_END 3817 211 - 212 -/* SVG constants */ 213 -#define GG_SVG_UNKNOWN 0 214 - 215 -/* SVG basic shapes */ 216 -#define GG_SVG_RECT 1 217 -#define GG_SVG_CIRCLE 2 218 -#define GG_SVG_ELLIPSE 3 219 -#define GG_SVG_LINE 4 220 -#define GG_SVG_POLYLINE 5 221 -#define GG_SVG_POLYGON 6 222 -#define GG_SVG_PATH 7 223 - 224 -/* SVG transformations */ 225 -#define GG_SVG_MATRIX 8 226 -#define GG_SVG_TRANSLATE 9 227 -#define GG_SVG_SCALE 10 228 -#define GG_SVG_ROTATE 11 229 -#define GG_SVG_SKEW_X 12 230 -#define GG_SVG_SKEW_Y 13 231 - 232 -/* SVG Path actions */ 233 -#define GG_SVG_MOVE_TO 14 234 -#define GG_SVG_LINE_TO 15 235 -#define GG_SVG_CURVE_3 16 236 -#define GG_SVG_CURVE_4 17 237 -#define GG_SVG_ELLIPT_ARC 18 238 -#define GG_SVG_CLOSE_PATH 19 239 - 240 -/* SGV Items */ 241 -#define GG_SVG_ITEM_GROUP 20 242 -#define GG_SVG_ITEM_SHAPE 21 243 -#define GG_SVG_ITEM_USE 22 244 -#define GG_SVG_ITEM_CLIP 23 245 - 246 -/* SVG Gradients */ 247 -#define GG_SVG_LINEAR_GRADIENT 24 248 -#define GG_SVG_RADIAL_GRADIENT 25 249 -#define GG_SVG_USER_SPACE 26 250 -#define GG_SVG_BOUNDING_BOX 27 251 - 252 -typedef struct gaia_graphics_image_infos 253 -{ 254 -/* a generic image INFOS */ 255 - int signature; 256 - int width; 257 - int height; 258 - int pixel_format; 259 - int bits_per_sample; 260 - int samples_per_pixel; 261 - int sample_format; 262 - int max_palette; 263 - unsigned char palette_red[256]; 264 - unsigned char palette_green[256]; 265 - unsigned char palette_blue[256]; 266 - int is_transparent; 267 - int tile_width; 268 - int tile_height; 269 - int rows_per_strip; 270 - int compression; 271 - int scale_1_2; 272 - int scale_1_4; 273 - int scale_1_8; 274 - int is_georeferenced; 275 - int srid; 276 - char *srs_name; 277 - char *proj4text; 278 - double upper_left_x; 279 - double upper_left_y; 280 - double pixel_x_size; 281 - double pixel_y_size; 282 - double no_data_value; 283 - double min_value; 284 - double max_value; 285 -} gGraphImageInfos; 286 -typedef gGraphImageInfos *gGraphImageInfosPtr; 287 - 288 -typedef struct gaia_graphics_image 289 -{ 290 -/* a generic image */ 291 - int signature; 292 - unsigned char *pixels; 293 - int width; 294 - int height; 295 - int bits_per_sample; 296 - int samples_per_pixel; 297 - int sample_format; 298 - int scanline_width; 299 - int pixel_size; 300 - int pixel_format; 301 - int max_palette; 302 - unsigned char palette_red[256]; 303 - unsigned char palette_green[256]; 304 - unsigned char palette_blue[256]; 305 - int is_transparent; 306 - unsigned char transparent_red; 307 - unsigned char transparent_green; 308 - unsigned char transparent_blue; 309 - int tile_width; 310 - int tile_height; 311 - int rows_per_strip; 312 - int compression; 313 - int is_georeferenced; 314 - int srid; 315 - char *srs_name; 316 - char *proj4text; 317 - double upper_left_x; 318 - double upper_left_y; 319 - double pixel_x_size; 320 - double pixel_y_size; 321 - double no_data_value; 322 - double min_value; 323 - double max_value; 324 -} gGraphImage; 325 -typedef gGraphImage *gGraphImagePtr; 326 - 327 -typedef struct gaia_graphics_strip_image 328 -{ 329 -/* a file-based image accessed by strips */ 330 - int signature; 331 - FILE *file_handle; 332 - int codec_id; 333 - int rows_per_block; 334 - int current_available_rows; 335 - int next_row; 336 - unsigned char *pixels; 337 - int width; 338 - int height; 339 - int bits_per_sample; 340 - int samples_per_pixel; 341 - int sample_format; 342 - int scanline_width; 343 - int pixel_size; 344 - int pixel_format; 345 - int max_palette; 346 - unsigned char palette_red[256]; 347 - unsigned char palette_green[256]; 348 - unsigned char palette_blue[256]; 349 - int is_transparent; 350 - unsigned char transparent_red; 351 - unsigned char transparent_green; 352 - unsigned char transparent_blue; 353 - int tile_width; 354 - int tile_height; 355 - int rows_per_strip; 356 - int compression; 357 - int is_georeferenced; 358 - int srid; 359 - char *srs_name; 360 - char *proj4text; 361 - double upper_left_x; 362 - double upper_left_y; 363 - double pixel_x_size; 364 - double pixel_y_size; 365 - double no_data_value; 366 - double min_value; 367 - double max_value; 368 - void *codec_data; 369 -} gGraphStripImage; 370 -typedef gGraphStripImage *gGraphStripImagePtr; 371 - 372 -typedef struct gaia_graphics_color_rule_item 373 -{ 374 -/* a Color Rule Item */ 375 - double value; 376 - double percent_value; 377 - unsigned char is_percent; 378 - unsigned char red; 379 - unsigned char green; 380 - unsigned char blue; 381 - struct gaia_graphics_color_rule_item *next; 382 -} gGraphColorRuleItem; 383 -typedef gGraphColorRuleItem *gGraphColorRuleItemPtr; 384 - 385 -typedef struct gaia_graphics_color_rule 386 -{ 387 -/* a Color Rule definition [GRASS-like] */ 388 - int signature; 389 - struct gaia_graphics_color_rule_item *first; 390 - struct gaia_graphics_color_rule_item *last; 391 - unsigned char no_data_red; 392 - unsigned char no_data_green; 393 - unsigned char no_data_blue; 394 - unsigned char needs_range; 395 -} gGraphColorRule; 396 -typedef gGraphColorRule *gGraphColorRulePtr; 397 - 398 -typedef struct gaia_graphics_color_map_entry 399 -{ 400 -/* a Color Map Entry */ 401 - double min; 402 - double max; 403 - unsigned char red; 404 - unsigned char green; 405 - unsigned char blue; 406 - struct gaia_graphics_color_map_entry *next; 407 -} gGraphColorMapEntry; 408 -typedef gGraphColorMapEntry *gGraphColorMapEntryPtr; 409 - 410 -typedef struct gaia_graphics_color_map 411 -{ 412 -/* a Color Map */ 413 - int signature; 414 - unsigned char no_data_red; 415 - unsigned char no_data_green; 416 - unsigned char no_data_blue; 417 - unsigned char not_found_red; 418 - unsigned char not_found_green; 419 - unsigned char not_found_blue; 420 - struct gaia_graphics_color_map_entry *first; 421 - struct gaia_graphics_color_map_entry *last; 422 - int num_entries; 423 - struct gaia_graphics_color_map_entry **array; 424 -} gGraphColorMap; 425 -typedef gGraphColorMap *gGraphColorMapPtr; 426 - 427 -typedef struct shaded_relief_triple_row 428 -{ 429 -/* the 3-scanlines object for Shaded Relief */ 430 - int signature; 431 - int width; 432 - float *in_row1; 433 - float *in_row2; 434 - float *in_row3; 435 - float *current_row; 436 - unsigned char *out_rgb; 437 - struct gaia_graphics_color_map *color_map; 438 - unsigned char mono_red; 439 - unsigned char mono_green; 440 - unsigned char mono_blue; 441 - double z_factor; 442 - double scale_factor; 443 - double azimuth; 444 - double altitude; 445 - float no_data_value; 446 - unsigned char no_red; 447 - unsigned char no_green; 448 - unsigned char no_blue; 449 -} gGraphShadedReliefTripleRow; 450 -typedef gGraphShadedReliefTripleRow *gGraphShadedReliefTripleRowPtr; 451 - 452 -struct gaia_graphics_pen 453 -{ 454 -/* a struct wrapping a Cairo Pen */ 455 - double red; 456 - double green; 457 - double blue; 458 - double alpha; 459 - double width; 460 - double lengths[4]; 461 - int lengths_count; 462 -}; 463 - 464 -struct gaia_graphics_brush 465 -{ 466 -/* a struct wrapping a Cairo Brush */ 467 - int is_solid_color; 468 - int is_linear_gradient; 469 - int is_pattern; 470 - double red; 471 - double green; 472 - double blue; 473 - double alpha; 474 - double x0; 475 - double y0; 476 - double x1; 477 - double y1; 478 - double red2; 479 - double green2; 480 - double blue2; 481 - double alpha2; 482 - cairo_pattern_t *pattern; 483 -}; 484 - 485 -typedef struct gaia_graphics_context 486 -{ 487 -/* a Cairo based painting context */ 488 - int signature; 489 - cairo_surface_t *surface; 490 - cairo_t *cairo; 491 - struct gaia_graphics_pen current_pen; 492 - struct gaia_graphics_brush current_brush; 493 - double font_red; 494 - double font_green; 495 - double font_blue; 496 - double font_alpha; 497 - int is_font_outlined; 498 - double font_outline_width; 499 -} gGraphContext; 500 -typedef gGraphContext *gGraphContextPtr; 501 - 502 -typedef struct gaia_graphics_bitmap 503 -{ 504 -/* a Cairo based symbol bitmap */ 505 - int signature; 506 - int width; 507 - int height; 508 - cairo_surface_t *bitmap; 509 - cairo_pattern_t *pattern; 510 -} gGraphBitmap; 511 -typedef gGraphBitmap *gGraphBitmapPtr; 512 - 513 -typedef struct gaia_graphics_pattern_brush 514 -{ 515 -/* a Cairo based pattern brush */ 516 - int signature; 517 - int width; 518 - int height; 519 - cairo_surface_t *bitmap; 520 - cairo_pattern_t *pattern; 521 -} gGraphPatternBrush; 522 -typedef gGraphPatternBrush *gGraphPatternBrushPtr; 523 - 524 -typedef struct gaia_graphics_font 525 -{ 526 -/* a struct wrapping a Cairo Font */ 527 - int signature; 528 - double size; 529 - int is_outlined; 530 - double outline_width; 531 - int style; 532 - int weight; 533 - double red; 534 - double green; 535 - double blue; 536 - double alpha; 537 -} gGraphFont; 538 -typedef gGraphFont *gGraphFontPtr; 539 - 540 -struct gg_svg_matrix 541 -{ 542 -/* SVG Matrix data */ 543 - double a; 544 - double b; 545 - double c; 546 - double d; 547 - double e; 548 - double f; 549 -}; 550 - 551 -struct gg_svg_translate 552 -{ 553 -/* SVG Translate data */ 554 - double tx; 555 - double ty; 556 -}; 557 - 558 -struct gg_svg_scale 559 -{ 560 -/* SVG Scale data */ 561 - double sx; 562 - double sy; 563 -}; 564 - 565 -struct gg_svg_rotate 566 -{ 567 -/* SVG Rotate data */ 568 - double angle; 569 - double cx; 570 - double cy; 571 -}; 572 - 573 -struct gg_svg_skew 574 -{ 575 -/* SVG Skew data */ 576 - double angle; 577 -}; 578 - 579 -struct gg_svg_transform 580 -{ 581 -/* SVG Transform (linked list) */ 582 - int type; 583 - void *data; 584 - struct gg_svg_transform *next; 585 -}; 586 - 587 -struct gg_svg_gradient_stop 588 -{ 589 -/* SVG Gradient Stop */ 590 - char *id; 591 - double offset; 592 - double red; 593 - double green; 594 - double blue; 595 - double opacity; 596 - struct gg_svg_gradient_stop *next; 597 -}; 598 - 599 -struct gg_svg_gradient 600 -{ 601 -/* SVG Gradient */ 602 - int type; 603 - char *id; 604 - char *xlink_href; 605 - int gradient_units; 606 - double x1; 607 - double y1; 608 - double x2; 609 - double y2; 610 - double cx; 611 - double cy; 612 - double fx; 613 - double fy; 614 - double r; 615 - struct gg_svg_gradient_stop *first_stop; 616 - struct gg_svg_gradient_stop *last_stop; 617 - struct gg_svg_transform *first_trans; 618 - struct gg_svg_transform *last_trans; 619 - struct gg_svg_gradient *prev; 620 - struct gg_svg_gradient *next; 621 -}; 622 - 623 -struct gg_svg_rect 624 -{ 625 -/* SVG Rect data */ 626 - double x; 627 - double y; 628 - double width; 629 - double height; 630 - double rx; 631 - double ry; 632 -}; 633 - 634 -struct gg_svg_circle 635 -{ 636 -/* SVG Circle data */ 637 - double cx; 638 - double cy; 639 - double r; 640 -}; 641 - 642 -struct gg_svg_ellipse 643 -{ 644 -/* SVG Ellipse data */ 645 - double cx; 646 - double cy; 647 - double rx; 648 - double ry; 649 -}; 650 - 651 -struct gg_svg_line 652 -{ 653 -/* SVG Line data */ 654 - double x1; 655 - double y1; 656 - double x2; 657 - double y2; 658 -}; 659 - 660 -struct gg_svg_polyline 661 -{ 662 -/* SVG Polyline data */ 663 - int points; 664 - double *x; 665 - double *y; 666 -}; 667 - 668 -struct gg_svg_polygon 669 -{ 670 -/* SVG Polygon data */ 671 - int points; 672 - double *x; 673 - double *y; 674 -}; 675 - 676 -struct gg_svg_path_move 677 -{ 678 -/* SVG Path: MoveTo and LineTo data */ 679 - double x; 680 - double y; 681 -}; 682 - 683 -struct gg_svg_path_bezier 684 -{ 685 -/* SVG Path: any Bezier Curve */ 686 - double x1; 687 - double y1; 688 - double x2; 689 - double y2; 690 - double x; 691 - double y; 692 -}; 693 - 694 -struct gg_svg_path_ellipt_arc 695 -{ 696 -/* SVG Path: Elliptical Arc */ 697 - double rx; 698 - double ry; 699 - double rotation; 700 - int large_arc; 701 - int sweep; 702 - double x; 703 - double y; 704 -}; 705 - 706 -struct gg_svg_path_item 707 -{ 708 -/* SVG Path item (linked list) */ 709 - int type; 710 - void *data; 711 - struct gg_svg_path_item *next; 712 -}; 713 - 714 -struct gg_svg_path 715 -{ 716 -/* SVG Path */ 717 - struct gg_svg_path_item *first; 718 - struct gg_svg_path_item *last; 719 - int error; 720 -}; 721 - 722 -struct gg_svg_style 723 -{ 724 -/* SVG Style-related definitions */ 725 - char visibility; 726 - double opacity; 727 - char fill; 728 - char no_fill; 729 - int fill_rule; 730 - char *fill_url; 731 - struct gg_svg_gradient *fill_pointer; 732 - double fill_red; 733 - double fill_green; 734 - double fill_blue; 735 - double fill_opacity; 736 - char stroke; 737 - char no_stroke; 738 - double stroke_width; 739 - int stroke_linecap; 740 - int stroke_linejoin; 741 - double stroke_miterlimit; 742 - int stroke_dashitems; 743 - double *stroke_dasharray; 744 - double stroke_dashoffset; 745 - char *stroke_url; 746 - struct gg_svg_gradient *stroke_pointer; 747 - double stroke_red; 748 - double stroke_green; 749 - double stroke_blue; 750 - double stroke_opacity; 751 - char *clip_url; 752 - struct gg_svg_item *clip_pointer; 753 -}; 754 - 755 -struct gg_svg_shape 756 -{ 757 -/* generic SVG shape container */ 758 - char *id; 759 - int type; 760 - void *data; 761 - struct gg_svg_group *parent; 762 - struct gg_svg_style style; 763 - struct gg_svg_transform *first_trans; 764 - struct gg_svg_transform *last_trans; 765 - int is_defs; 766 - int is_flow_root; 767 - struct gg_svg_shape *next; 768 -}; 769 - 770 -struct gg_svg_use 771 -{ 772 -/* SVG Use (xlink:href) */ 773 - char *xlink_href; 774 - double x; 775 - double y; 776 - double width; 777 - double height; 778 - struct gg_svg_style style; 779 - struct gg_svg_group *parent; 780 - struct gg_svg_transform *first_trans; 781 - struct gg_svg_transform *last_trans; 782 - struct gg_svg_use *next; 783 -}; 784 - 785 -struct gg_svg_item 786 -{ 787 -/* SVG generic item */ 788 - int type; 789 - void *pointer; 790 - struct gg_svg_item *next; 791 -}; 792 - 793 -struct gg_svg_group 794 -{ 795 -/* SVG group container: <g> */ 796 - char *id; 797 - struct gg_svg_style style; 798 - struct gg_svg_group *parent; 799 - struct gg_svg_item *first; 800 - struct gg_svg_item *last; 801 - struct gg_svg_transform *first_trans; 802 - struct gg_svg_transform *last_trans; 803 - int is_defs; 804 - int is_flow_root; 805 - struct gg_svg_group *next; 806 -}; 807 - 808 -struct gg_svg_clip 809 -{ 810 -/* SVG group container: <clipPath> */ 811 - char *id; 812 - struct gg_svg_item *first; 813 - struct gg_svg_item *last; 814 - struct gg_svg_clip *next; 815 -}; 816 - 817 - 818 -struct gg_svg_document 819 -{ 820 -/* SVG document main container */ 821 - int signature; 822 - cairo_matrix_t matrix; 823 - double width; 824 - double height; 825 - double viewbox_x; 826 - double viewbox_y; 827 - double viewbox_width; 828 - double viewbox_height; 829 - struct gg_svg_item *first; 830 - struct gg_svg_item *last; 831 - struct gg_svg_gradient *first_grad; 832 - struct gg_svg_gradient *last_grad; 833 - struct gg_svg_group *current_group; 834 - struct gg_svg_shape *current_shape; 835 - struct gg_svg_clip *current_clip; 836 - int defs_count; 837 - int flow_root_count; 838 -}; 839 - 840 -GGRAPH_PRIVATE gGraphColorRulePtr gg_color_rule_create (void); 841 -GGRAPH_PRIVATE void gg_color_rule_destroy (gGraphColorRulePtr color_rule); 842 -GGRAPH_PRIVATE gGraphColorMapPtr gg_color_map_create (void); 843 -GGRAPH_PRIVATE void gg_color_map_destroy (gGraphColorMapPtr color_map); 844 - 845 -GGRAPH_PRIVATE gGraphShadedReliefTripleRowPtr 846 -gg_shaded_relief_triple_row_create (void); 847 -GGRAPH_PRIVATE void 848 -gg_shaded_relief_triple_row_destroy (gGraphShadedReliefTripleRowPtr triple_row); 849 - 850 -GGRAPH_PRIVATE gGraphImageInfosPtr gg_image_infos_create (int pixel_format, 851 - int width, int height, 852 - int bits_per_sample, 853 - int samples_per_pixel, 854 - int sample_format, 855 - const char *srs_name, 856 - const char 857 - *proj4text); 858 -GGRAPH_PRIVATE void gg_image_infos_destroy (gGraphImageInfosPtr img); 859 -GGRAPH_PRIVATE gGraphImagePtr gg_image_create (int pixel_format, int width, 860 - int height, int bits_per_sample, 861 - int samples_per_pixel, 862 - int sample_format, 863 - const char *srs_name, 864 - const char *proj4text); 865 -GGRAPH_PRIVATE gGraphImagePtr gg_image_create_from_bitmap (unsigned char 866 - *bitmap, 867 - int pixel_format, 868 - int width, 869 - int height, 870 - int bits_per_sample, 871 - int 872 - samples_per_pixel, 873 - int sample_format, 874 - const char *srs_name, 875 - const char 876 - *proj4text); 877 -GGRAPH_PRIVATE void gg_image_destroy (gGraphImagePtr img); 878 -GGRAPH_PRIVATE gGraphStripImagePtr gg_strip_image_create (FILE * file_handle, 879 - int codec_id, 880 - int pixel_format, 881 - int width, int height, 882 - int bits_per_sample, 883 - int samples_per_pixel, 884 - int sample_format, 885 - const char *srs_name, 886 - const char 887 - *proj4text); 888 -GGRAPH_PRIVATE void gg_strip_image_destroy (gGraphStripImagePtr img); 889 -GGRAPH_PRIVATE void gg_png_codec_destroy (void *p); 890 -GGRAPH_PRIVATE void gg_jpeg_codec_destroy (void *p); 891 -GGRAPH_PRIVATE void gg_tiff_codec_destroy (void *p); 892 -GGRAPH_PRIVATE void gg_grid_codec_destroy (void *p); 893 -GGRAPH_PRIVATE void gg_image_fill (const gGraphImagePtr img, unsigned char r, 894 - unsigned char g, unsigned char b, 895 - unsigned char alpha); 896 -GGRAPH_PRIVATE unsigned char gg_match_palette (const gGraphImagePtr img, 897 - unsigned char r, unsigned char g, 898 - unsigned char b); 899 -GGRAPH_PRIVATE int gg_set_image_transparent_color (unsigned char r, 900 - unsigned char g, 901 - unsigned char b); 902 -GGRAPH_PRIVATE int gg_is_image_monochrome (const gGraphImagePtr img); 903 -GGRAPH_PRIVATE int gg_is_image_monochrome_ready (const gGraphImagePtr img); 904 -GGRAPH_PRIVATE int gg_is_image_grayscale (const gGraphImagePtr img); 905 -GGRAPH_PRIVATE int gg_is_image_palette256 (const gGraphImagePtr img); 906 - 907 -GGRAPH_PRIVATE void gg_make_thumbnail (const gGraphImagePtr thumbnail, 908 - const gGraphImagePtr image); 909 -GGRAPH_PRIVATE void gg_image_resize (const gGraphImagePtr dst, 910 - const gGraphImagePtr src); 911 -GGRAPH_PRIVATE void gg_make_grid_thumbnail (const gGraphImagePtr thumbnail, 912 - const gGraphImagePtr image); 913 -GGRAPH_PRIVATE void gg_grid_resize (const gGraphImagePtr dst, 914 - const gGraphImagePtr src); 915 -GGRAPH_PRIVATE void gg_image_clone_georeferencing (const gGraphImagePtr dst, 916 - const gGraphImagePtr src); 917 -GGRAPH_PRIVATE void gg_image_sub_set (const gGraphImagePtr dst, 918 - const gGraphImagePtr src, 919 - int upper_left_x, int upper_left_y); 920 - 921 -GGRAPH_PRIVATE int gg_image_to_jpeg (const gGraphImagePtr img, void **mem_buf, 922 - int *mem_buf_size, FILE * out, 923 - int dest_type, int quality); 924 -GGRAPH_PRIVATE int gg_image_prepare_to_jpeg_by_strip (const gGraphStripImagePtr 925 - img, FILE * out, 926 - int quality); 927 -GGRAPH_PRIVATE int gg_image_write_to_jpeg_by_strip (const gGraphStripImagePtr 928 - img, int *progress); 929 -GGRAPH_PRIVATE int gg_image_to_png (const gGraphImagePtr img, void **mem_buf, 930 - int *mem_buf_size, FILE * out, 931 - int dest_type, int compression_level, 932 - int quantization_factor, int interlaced, 933 - int is_transparent); 934 -GGRAPH_PRIVATE int gg_image_prepare_to_png_by_strip (const gGraphStripImagePtr 935 - img, FILE * out, 936 - int compression_level, 937 - int quantization_factor); 938 -GGRAPH_PRIVATE int gg_image_write_to_png_by_strip (const gGraphStripImagePtr 939 - img, int *progress); 940 -GGRAPH_PRIVATE int gg_image_to_gif (const gGraphImagePtr img, void **mem_buf, 941 - int *mem_buf_size, FILE * out, 942 - int dest_type, int is_transparent); 943 -GGRAPH_PRIVATE int gg_image_write_to_bin_hdr_by_strip (const gGraphStripImagePtr 944 - img, int *progress); 945 -GGRAPH_PRIVATE int gg_image_write_to_flt_hdr_by_strip (const gGraphStripImagePtr 946 - img, int *progress); 947 -GGRAPH_PRIVATE int gg_image_write_to_ascii_grid_by_strip (const 948 - gGraphStripImagePtr 949 - img, int *progress); 950 -GGRAPH_PRIVATE int gg_image_prepare_to_tiff_by_strip (const gGraphStripImagePtr 951 - img, const char *path, 952 - int layout, 953 - int tile_width, 954 - int tile_height, 955 - int rows_per_strip, 956 - int color_model, 957 - int bits_per_sample, 958 - int sample_format, 959 - int num_palette, 960 - unsigned char *red, 961 - unsigned char *green, 962 - unsigned char *blue, 963 - int compression); 964 -GGRAPH_PRIVATE int gg_image_prepare_to_geotiff_by_strip (const 965 - gGraphStripImagePtr 966 - img, const char *path, 967 - int layout, 968 - int tile_width, 969 - int tile_height, 970 - int rows_per_strip, 971 - int color_model, 972 - int bits_per_sample, 973 - int sample_format, 974 - int num_palette, 975 - unsigned char *red, 976 - unsigned char *green, 977 - unsigned char *blue, 978 - int compression); 979 -GGRAPH_PRIVATE int gg_image_prepare_to_bin_hdr_by_strip (const 980 - gGraphStripImagePtr 981 - img); 982 -GGRAPH_PRIVATE int gg_image_prepare_to_flt_hdr_by_strip (const 983 - gGraphStripImagePtr 984 - img); 985 -GGRAPH_PRIVATE int gg_image_prepare_to_ascii_grid_by_strip (const 986 - gGraphStripImagePtr 987 - img, FILE * out); 988 -GGRAPH_PRIVATE int gg_image_write_to_tiff_by_strip (const gGraphStripImagePtr 989 - img, int *progress); 990 - 991 -GGRAPH_PRIVATE int gg_convert_image_to_rgb (const gGraphImagePtr img); 992 -GGRAPH_PRIVATE int gg_convert_image_to_rgba (const gGraphImagePtr img); 993 -GGRAPH_PRIVATE int gg_convert_image_to_argb (const gGraphImagePtr img); 994 -GGRAPH_PRIVATE int gg_convert_image_to_bgr (const gGraphImagePtr img); 995 -GGRAPH_PRIVATE int gg_convert_image_to_bgra (const gGraphImagePtr img); 996 -GGRAPH_PRIVATE int gg_convert_image_to_grayscale (const gGraphImagePtr img); 997 -GGRAPH_PRIVATE int gg_convert_image_to_palette (const gGraphImagePtr img); 998 -GGRAPH_PRIVATE int gg_image_resample_as_palette (const gGraphImagePtr img, 999 - int num_colors); 1000 -GGRAPH_PRIVATE int gg_convert_image_to_monochrome (const gGraphImagePtr img); 1001 -GGRAPH_PRIVATE int gg_convert_image_to_grid_int16 (const gGraphImagePtr img); 1002 -GGRAPH_PRIVATE int gg_convert_image_to_grid_uint16 (const gGraphImagePtr img); 1003 -GGRAPH_PRIVATE int gg_convert_image_to_grid_int32 (const gGraphImagePtr img); 1004 -GGRAPH_PRIVATE int gg_convert_image_to_grid_uint32 (const gGraphImagePtr img); 1005 -GGRAPH_PRIVATE int gg_convert_image_to_grid_float (const gGraphImagePtr img); 1006 -GGRAPH_PRIVATE int gg_convert_image_to_grid_double (const gGraphImagePtr img); 1007 - 1008 -GGRAPH_PRIVATE int gg_resample_transparent_rgb (const gGraphImagePtr img); 1009 -GGRAPH_PRIVATE int gg_resample_transparent_rgba (const gGraphImagePtr img); 1010 -GGRAPH_PRIVATE int gg_resample_transparent_grayscale (const gGraphImagePtr img); 1011 -GGRAPH_PRIVATE int gg_resample_transparent_palette (const gGraphImagePtr img); 1012 - 1013 -GGRAPH_PRIVATE int gg_image_from_raw (int size, const void *data, 1014 - gGraphImagePtr * image_handle); 1015 -GGRAPH_PRIVATE int gg_image_from_jpeg (int size, const void *data, 1016 - int source_type, 1017 - gGraphImagePtr * image_handle, 1018 - int scale); 1019 -GGRAPH_PRIVATE int gg_image_from_png (int size, const void *data, 1020 - int source_type, 1021 - gGraphImagePtr * image_handle, int scale); 1022 -GGRAPH_PRIVATE int gg_image_from_gif (int size, const void *data, 1023 - int source_type, 1024 - gGraphImagePtr * image_handle); 1025 -GGRAPH_PRIVATE int gg_image_from_mem_tiff (int size, const void *data, 1026 - gGraphImagePtr * image_handle); 1027 - 1028 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_png (FILE * in, 1029 - gGraphStripImagePtr * 1030 - image_handle); 1031 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_jpeg (FILE * in, 1032 - gGraphStripImagePtr * 1033 - image_handle); 1034 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_jpeg (FILE * in, 1035 - gGraphStripImagePtr * 1036 - image_handle); 1037 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_tiff (const char *path, 1038 - gGraphStripImagePtr * 1039 - image_handle); 1040 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_geotiff (const char *path, 1041 - gGraphStripImagePtr * 1042 - image_handle); 1043 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_hgt (FILE * in, int lon, int lat, 1044 - gGraphStripImagePtr * 1045 - image_handle); 1046 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_bin_hdr (FILE * in, 1047 - const char *hdr_path, 1048 - gGraphStripImagePtr * 1049 - image_handle); 1050 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_flt_hdr (FILE * in, 1051 - const char *hdr_path, 1052 - gGraphStripImagePtr * 1053 - image_handle); 1054 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_dem_hdr (FILE * in, 1055 - const char *hdr_path, 1056 - gGraphStripImagePtr * 1057 - image_handle); 1058 -GGRAPH_PRIVATE int gg_image_strip_prepare_from_ascii_grid (FILE * in, 1059 - gGraphStripImagePtr * 1060 - image_handle); 1061 - 1062 -GGRAPH_PRIVATE int gg_image_strip_read_from_png (gGraphStripImagePtr 1063 - image_handle, int *progress); 1064 -GGRAPH_PRIVATE int gg_image_strip_read_from_jpeg (gGraphStripImagePtr 1065 - image_handle, int *progress); 1066 -GGRAPH_PRIVATE int gg_image_strip_read_from_tiff (gGraphStripImagePtr 1067 - image_handle, int *progress); 1068 -GGRAPH_PRIVATE int gg_image_strip_read_from_hgt (gGraphStripImagePtr 1069 - image_handle, int *progress); 1070 -GGRAPH_PRIVATE int gg_image_strip_read_from_bin_grid (gGraphStripImagePtr 1071 - image_handle, 1072 - int *progress); 1073 -GGRAPH_PRIVATE int gg_image_strip_read_from_dem_grid (gGraphStripImagePtr 1074 - image_handle, 1075 - int *progress); 1076 -GGRAPH_PRIVATE int gg_image_strip_read_from_ascii_grid (gGraphStripImagePtr 1077 - image_handle, 1078 - int *progress); 1079 - 1080 -GGRAPH_PRIVATE int gg_image_infos_from_jpeg (int size, const void *data, 1081 - int source_type, 1082 - gGraphImageInfosPtr * 1083 - infos_handle); 1084 -GGRAPH_PRIVATE int gg_image_infos_from_png (int size, const void *data, 1085 - int source_type, 1086 - gGraphImageInfosPtr * infos_handle); 1087 -GGRAPH_PRIVATE int gg_image_infos_from_gif (int size, const void *data, 1088 - int source_type, 1089 - gGraphImageInfosPtr * infos_handle); 1090 -GGRAPH_PRIVATE int gg_image_infos_from_mem_tiff (int size, const void *data, 1091 - gGraphImageInfosPtr * 1092 - infos_handle); 1093 -GGRAPH_PRIVATE int gg_image_infos_from_tiff (const char *path, 1094 - gGraphImageInfosPtr * 1095 - infos_handle); 1096 -GGRAPH_PRIVATE int gg_image_infos_from_geo_tiff (const char *path, 1097 - gGraphImageInfosPtr * 1098 - infos_handle); 1099 - 1100 -GGRAPH_PRIVATE int gg_endian_arch (void); 1101 -GGRAPH_PRIVATE short gg_import_int16 (const unsigned char *p, 1102 - int little_endian, 1103 - int little_endian_arch); 1104 -GGRAPH_PRIVATE int gg_import_int32 (const unsigned char *p, int little_endian, 1105 - int little_endian_arch); 1106 -GGRAPH_PRIVATE unsigned short gg_import_uint16 (const unsigned char *p, 1107 - int little_endian, 1108 - int little_endian_arch); 1109 -GGRAPH_PRIVATE unsigned int gg_import_uint32 (const unsigned char *p, 1110 - int little_endian, 1111 - int little_endian_arch); 1112 -GGRAPH_PRIVATE float gg_import_float (const unsigned char *p, int little_endian, 1113 - int little_endian_arch); 1114 -GGRAPH_PRIVATE double gg_import_double (const unsigned char *p, 1115 - int little_endian, 1116 - int little_endian_arch); 1117 - 1118 -GGRAPH_PRIVATE void gg_export_int16 (short value, unsigned char *p, 1119 - int little_endian, int little_endian_arch); 1120 -GGRAPH_PRIVATE void gg_export_int32 (int value, unsigned char *p, 1121 - int little_endian, int little_endian_arch); 1122 -GGRAPH_PRIVATE void gg_export_uint16 (unsigned short value, unsigned char *p, 1123 - int little_endian, 1124 - int little_endian_arch); 1125 -GGRAPH_PRIVATE void gg_export_uint32 (unsigned int value, unsigned char *p, 1126 - int little_endian, 1127 - int little_endian_arch); 1128 -GGRAPH_PRIVATE void gg_export_float (float value, unsigned char *p, 1129 - int little_endian, int little_endian_arch); 1130 -GGRAPH_PRIVATE void gg_export_double (double value, unsigned char *p, 1131 - int little_endian, 1132 - int little_endian_arch); 1133 - 1134 - 1135 -GGRAPH_PRIVATE struct gg_svg_transform *gg_svg_alloc_transform (int type, 1136 - void *data); 1137 -GGRAPH_PRIVATE void gg_svg_free_transform (struct gg_svg_transform *p); 1138 -GGRAPH_PRIVATE struct gg_svg_polyline *gg_svg_alloc_polyline (int points, 1139 - double *x, 1140 - double *y); 1141 -GGRAPH_PRIVATE void gg_svg_free_polyline (struct gg_svg_polyline *p); 1142 -GGRAPH_PRIVATE struct gg_svg_polygon *gg_svg_alloc_polygon (int points, 1143 - double *x, 1144 - double *y); 1145 -GGRAPH_PRIVATE void gg_svg_free_polygon (struct gg_svg_polygon *p); 1146 -GGRAPH_PRIVATE struct gg_svg_path_item *gg_svg_alloc_path_item (int type, 1147 - void *data); 1148 -GGRAPH_PRIVATE void gg_svg_free_path_item (struct gg_svg_path_item *p); 1149 -GGRAPH_PRIVATE struct gg_svg_path *gg_svg_alloc_path (void); 1150 -GGRAPH_PRIVATE void gg_svg_free_path (struct gg_svg_path *p); 1151 -GGRAPH_PRIVATE struct gg_svg_shape *gg_svg_alloc_shape (int type, void *data, 1152 - struct gg_svg_group 1153 - *parent); 1154 -GGRAPH_PRIVATE void gg_svg_free_shape (struct gg_svg_shape *p); 1155 -GGRAPH_PRIVATE void gg_svg_add_shape_id (struct gg_svg_shape *p, 1156 - const char *id); 1157 -GGRAPH_PRIVATE struct gg_svg_use *gg_svg_alloc_use (void *parent, 1158 - const char *xlink_href, 1159 - double x, double y, 1160 - double width, 1161 - double height); 1162 -GGRAPH_PRIVATE void gg_svg_free_use (struct gg_svg_use *p); 1163 -GGRAPH_PRIVATE struct gg_svg_group *gg_svg_alloc_group (void); 1164 -GGRAPH_PRIVATE void gg_svg_free_group (struct gg_svg_group *p); 1165 -GGRAPH_PRIVATE void gg_svg_add_group_id (struct gg_svg_group *p, 1166 - const char *id); 1167 -GGRAPH_PRIVATE struct gg_svg_clip *svg_alloc_clip (void); 1168 -GGRAPH_PRIVATE void gg_svg_free_clip (struct gg_svg_clip *p); 1169 -GGRAPH_PRIVATE void gg_svg_add_clip_id (struct gg_svg_clip *p, const char *id); 1170 -GGRAPH_PRIVATE struct gg_svg_gradient_stop *gg_svg_alloc_gradient_stop (double 1171 - offset, 1172 - double 1173 - red, 1174 - double 1175 - green, 1176 - double 1177 - blue, 1178 - double 1179 - opacity); 1180 -GGRAPH_PRIVATE struct gg_svg_gradient_stop *gg_svg_clone_gradient_stop (struct 1181 - gg_svg_gradient_stop 1182 - *in); 1183 -GGRAPH_PRIVATE void gg_svg_free_gradient_stop (struct gg_svg_gradient_stop *p); 1184 -GGRAPH_PRIVATE struct gg_svg_gradient *gg_svg_clone_gradient (struct 1185 - gg_svg_gradient 1186 - *in, 1187 - struct 1188 - gg_svg_gradient 1189 - *old); 1190 -GGRAPH_PRIVATE void gg_svg_free_gradient (struct gg_svg_gradient *p); 1191 -GGRAPH_PRIVATE struct gg_svg_document *gg_svg_alloc_document (void); 1192 -GGRAPH_PRIVATE void gg_svg_free_document (struct gg_svg_document *p); 1193 -GGRAPH_PRIVATE struct gg_svg_item *gg_svg_alloc_item (int type, void *pointer); 1194 -GGRAPH_PRIVATE struct gg_svg_matrix *gg_svg_alloc_matrix (double a, double b, 1195 - double c, double d, 1196 - double e, double f); 1197 -GGRAPH_PRIVATE struct gg_svg_translate *gg_svg_alloc_translate (double tx, 1198 - double ty); 1199 -GGRAPH_PRIVATE struct gg_svg_scale *gg_svg_alloc_scale (double sx, double sy); 1200 -GGRAPH_PRIVATE struct gg_svg_rotate *gg_svg_alloc_rotate (double angle, 1201 - double cx, double cy); 1202 -GGRAPH_PRIVATE struct gg_svg_skew *gg_svg_alloc_skew (double angle); 1203 -GGRAPH_PRIVATE struct gg_svg_rect *gg_svg_alloc_rect (double x, double y, 1204 - double width, 1205 - double height, double rx, 1206 - double ry); 1207 -GGRAPH_PRIVATE struct gg_svg_circle *gg_svg_alloc_circle (double cx, double cy, 1208 - double r); 1209 -GGRAPH_PRIVATE struct gg_svg_ellipse *gg_svg_alloc_ellipse (double cx, 1210 - double cy, 1211 - double rx, 1212 - double ry); 1213 -GGRAPH_PRIVATE struct gg_svg_line *gg_svg_alloc_line (double x1, double y1, 1214 - double x2, double y2); 1215 -GGRAPH_PRIVATE struct gg_svg_path_move *gg_svg_alloc_path_move (double x, 1216 - double y); 1217 -GGRAPH_PRIVATE struct gg_svg_path_bezier *gg_svg_alloc_path_bezier (double x1, 1218 - double y1, 1219 - double x2, 1220 - double y2, 1221 - double x, 1222 - double y); 1223 -GGRAPH_PRIVATE struct gg_svg_path_ellipt_arc 1224 - *gg_svg_alloc_path_ellipt_arc (double rx, double ry, double rotation, 1225 - int large_arc, int sweep, double x, 1226 - double y); 1227 - 1228 -GGRAPH_PRIVATE void gg_svg_add_path_item (struct gg_svg_path *path, int type, 1229 - void *data); 1230 -GGRAPH_PRIVATE void gg_svg_insert_shape (struct gg_svg_document *svg_doc, 1231 - int type, void *data); 1232 -GGRAPH_PRIVATE struct gg_svg_use *gg_svg_insert_use (struct gg_svg_document 1233 - *svg_doc, 1234 - const char *xlink_href, 1235 - double x, double y, 1236 - double width, 1237 - double height); 1238 -GGRAPH_PRIVATE void gg_svg_insert_group (struct gg_svg_document *svg_doc); 1239 -GGRAPH_PRIVATE void gg_svg_close_group (struct gg_svg_document *svg_doc); 1240 -GGRAPH_PRIVATE void gg_svg_insert_clip (struct gg_svg_document *svg_doc); 1241 -GGRAPH_PRIVATE void gg_svg_close_clip (struct gg_svg_document *svg_doc); 1242 -GGRAPH_PRIVATE struct gg_svg_gradient *gg_svg_insert_linear_gradient (struct 1243 - gg_svg_document 1244 - *svg_doc, 1245 - const char 1246 - *id, 1247 - const char 1248 - *xlink_href, 1249 - double x1, 1250 - double y1, 1251 - double x2, 1252 - double y2, 1253 - int 1254 - units); 1255 -GGRAPH_PRIVATE void gg_svg_insert_gradient_stop (struct gg_svg_gradient 1256 - *gradient, double offset, 1257 - double red, double green, 1258 - double blue, double opacity); 1259 -GGRAPH_PRIVATE struct gg_svg_gradient *gg_svg_insert_radial_gradient (struct 1260 - gg_svg_document 1261 - *svg_doc, 1262 - const char 1263 - *id, 1264 - const char 1265 - *xlink_href, 1266 - double cx, 1267 - double cy, 1268 - double fx, 1269 - double fy, 1270 - double r, 1271 - int 1272 - units); 1273 - 1274 -GGRAPH_PRIVATE struct gg_svg_document *gg_svg_parse_doc (const unsigned char 1275 - *svg, int svg_len); 1276 - 1277 -GGRAPH_PRIVATE struct gg_svg_shape *gg_svg_clone_shape (struct gg_svg_shape *in, 1278 - struct gg_svg_use *use); 1279 -GGRAPH_PRIVATE struct gg_svg_group *gg_svg_clone_group (struct gg_svg_group *in, 1280 - struct gg_svg_use *use); 1281 -GGRAPH_PRIVATE struct gg_svg_clip *gg_svg_clone_clip (struct gg_svg_clip *in); 1282 -GGRAPH_PRIVATE void gg_svg_set_group_parent (struct gg_svg_item *item, 1283 - struct gg_svg_group *group); 1284 -GGRAPH_PRIVATE struct gg_svg_item *gg_svg_clone_item (struct gg_svg_item *in); 1285 -GGRAPH_PRIVATE void gg_svg_add_fill_gradient_url (struct gg_svg_style *style, 1286 - const char *url); 1287 -GGRAPH_PRIVATE void gg_svg_add_stroke_gradient_url (struct gg_svg_style *style, 1288 - const char *url); 1289 -GGRAPH_PRIVATE void gg_svg_add_clip_url (struct gg_svg_style *style, 1290 - const char *url); 1291 - 1292 -/* 1293 -/ 1294 -/ DISCLAIMER: 1295 -/ all the following code merely represents an 'ad hoc' adaption 1296 -/ deriving from the original GD lib code [BSD-like licensed] 1297 -/ 1298 -*/ 1299 - 1300 -#define XGD_CTX_FREE 300 1301 -#define XGD_CTX_DONT_FREE 400 1302 - 1303 -typedef struct xgdIOCtx 1304 -{ 1305 - int (*getC) (struct xgdIOCtx *); 1306 - int (*getBuf) (struct xgdIOCtx *, void *, int); 1307 - void (*putC) (struct xgdIOCtx *, int); 1308 - int (*putBuf) (struct xgdIOCtx *, const void *, int); 1309 - int (*seek) (struct xgdIOCtx *, const int); 1310 - long (*tell) (struct xgdIOCtx *); 1311 - void (*xgd_free) (struct xgdIOCtx *); 1312 -} 1313 -xgdIOCtx; 1314 - 1315 -typedef struct xgdIOCtx *xgdIOCtxPtr; 1316 - 1317 -typedef struct dpStruct 1318 -{ 1319 - FILE *file; 1320 - void *data; 1321 - int logicalSize; 1322 - int realSize; 1323 - int dataGood; 1324 - int pos; 1325 - int freeOK; 1326 -} 1327 -dynamicPtr; 1328 - 1329 -typedef struct dpIOCtx 1330 -{ 1331 - xgdIOCtx ctx; 1332 - dynamicPtr *dp; 1333 -} 1334 -dpIOCtx; 1335 - 1336 -typedef struct dpIOCtx *dpIOCtxPtr; 1337 - 1338 -GGRAPH_PRIVATE int overflow2 (int a, int b); 1339 -GGRAPH_PRIVATE void *xgdDPExtractData (struct xgdIOCtx *ctx, int *size); 1340 -GGRAPH_PRIVATE xgdIOCtx *xgdNewDynamicCtx (int initialSize, const void *data, 1341 - int mem_or_file); 1342 -GGRAPH_PRIVATE xgdIOCtx *xgdNewDynamicCtxEx (int initialSize, const void *data, 1343 - int freeOKFlag, int mem_or_file); 1344 -GGRAPH_PRIVATE int xgdPutBuf (const void *buf, int size, xgdIOCtx * ctx); 1345 -GGRAPH_PRIVATE int xgdGetBuf (void *, int, xgdIOCtx *);
Deleted install-sh.
1 -#!/bin/sh 2 -# install - install a program, script, or datafile 3 - 4 -scriptversion=2011-01-19.21; # UTC 5 - 6 -# This originates from X11R5 (mit/util/scripts/install.sh), which was 7 -# later released in X11R6 (xc/config/util/install.sh) with the 8 -# following copyright and license. 9 -# 10 -# Copyright (C) 1994 X Consortium 11 -# 12 -# Permission is hereby granted, free of charge, to any person obtaining a copy 13 -# of this software and associated documentation files (the "Software"), to 14 -# deal in the Software without restriction, including without limitation the 15 -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 -# sell copies of the Software, and to permit persons to whom the Software is 17 -# furnished to do so, subject to the following conditions: 18 -# 19 -# The above copyright notice and this permission notice shall be included in 20 -# all copies or substantial portions of the Software. 21 -# 22 -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 -# 29 -# Except as contained in this notice, the name of the X Consortium shall not 30 -# be used in advertising or otherwise to promote the sale, use or other deal- 31 -# ings in this Software without prior written authorization from the X Consor- 32 -# tium. 33 -# 34 -# 35 -# FSF changes to this file are in the public domain. 36 -# 37 -# Calling this script install-sh is preferred over install.sh, to prevent 38 -# `make' implicit rules from creating a file called install from it 39 -# when there is no Makefile. 40 -# 41 -# This script is compatible with the BSD install script, but was written 42 -# from scratch. 43 - 44 -nl=' 45 -' 46 -IFS=" "" $nl" 47 - 48 -# set DOITPROG to echo to test this script 49 - 50 -# Don't use :- since 4.3BSD and earlier shells don't like it. 51 -doit=${DOITPROG-} 52 -if test -z "$doit"; then 53 - doit_exec=exec 54 -else 55 - doit_exec=$doit 56 -fi 57 - 58 -# Put in absolute file names if you don't have them in your path; 59 -# or use environment vars. 60 - 61 -chgrpprog=${CHGRPPROG-chgrp} 62 -chmodprog=${CHMODPROG-chmod} 63 -chownprog=${CHOWNPROG-chown} 64 -cmpprog=${CMPPROG-cmp} 65 -cpprog=${CPPROG-cp} 66 -mkdirprog=${MKDIRPROG-mkdir} 67 -mvprog=${MVPROG-mv} 68 -rmprog=${RMPROG-rm} 69 -stripprog=${STRIPPROG-strip} 70 - 71 -posix_glob='?' 72 -initialize_posix_glob=' 73 - test "$posix_glob" != "?" || { 74 - if (set -f) 2>/dev/null; then 75 - posix_glob= 76 - else 77 - posix_glob=: 78 - fi 79 - } 80 -' 81 - 82 -posix_mkdir= 83 - 84 -# Desired mode of installed file. 85 -mode=0755 86 - 87 -chgrpcmd= 88 -chmodcmd=$chmodprog 89 -chowncmd= 90 -mvcmd=$mvprog 91 -rmcmd="$rmprog -f" 92 -stripcmd= 93 - 94 -src= 95 -dst= 96 -dir_arg= 97 -dst_arg= 98 - 99 -copy_on_change=false 100 -no_target_directory= 101 - 102 -usage="\ 103 -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 - or: $0 [OPTION]... SRCFILES... DIRECTORY 105 - or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 - or: $0 [OPTION]... -d DIRECTORIES... 107 - 108 -In the 1st form, copy SRCFILE to DSTFILE. 109 -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 -In the 4th, create DIRECTORIES. 111 - 112 -Options: 113 - --help display this help and exit. 114 - --version display version info and exit. 115 - 116 - -c (ignored) 117 - -C install only if different (preserve the last data modification time) 118 - -d create directories instead of installing files. 119 - -g GROUP $chgrpprog installed files to GROUP. 120 - -m MODE $chmodprog installed files to MODE. 121 - -o USER $chownprog installed files to USER. 122 - -s $stripprog installed files. 123 - -t DIRECTORY install into DIRECTORY. 124 - -T report an error if DSTFILE is a directory. 125 - 126 -Environment variables override the default commands: 127 - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 - RMPROG STRIPPROG 129 -" 130 - 131 -while test $# -ne 0; do 132 - case $1 in 133 - -c) ;; 134 - 135 - -C) copy_on_change=true;; 136 - 137 - -d) dir_arg=true;; 138 - 139 - -g) chgrpcmd="$chgrpprog $2" 140 - shift;; 141 - 142 - --help) echo "$usage"; exit $?;; 143 - 144 - -m) mode=$2 145 - case $mode in 146 - *' '* | *' '* | *' 147 -'* | *'*'* | *'?'* | *'['*) 148 - echo "$0: invalid mode: $mode" >&2 149 - exit 1;; 150 - esac 151 - shift;; 152 - 153 - -o) chowncmd="$chownprog $2" 154 - shift;; 155 - 156 - -s) stripcmd=$stripprog;; 157 - 158 - -t) dst_arg=$2 159 - # Protect names problematic for `test' and other utilities. 160 - case $dst_arg in 161 - -* | [=\(\)!]) dst_arg=./$dst_arg;; 162 - esac 163 - shift;; 164 - 165 - -T) no_target_directory=true;; 166 - 167 - --version) echo "$0 $scriptversion"; exit $?;; 168 - 169 - --) shift 170 - break;; 171 - 172 - -*) echo "$0: invalid option: $1" >&2 173 - exit 1;; 174 - 175 - *) break;; 176 - esac 177 - shift 178 -done 179 - 180 -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 181 - # When -d is used, all remaining arguments are directories to create. 182 - # When -t is used, the destination is already specified. 183 - # Otherwise, the last argument is the destination. Remove it from $@. 184 - for arg 185 - do 186 - if test -n "$dst_arg"; then 187 - # $@ is not empty: it contains at least $arg. 188 - set fnord "$@" "$dst_arg" 189 - shift # fnord 190 - fi 191 - shift # arg 192 - dst_arg=$arg 193 - # Protect names problematic for `test' and other utilities. 194 - case $dst_arg in 195 - -* | [=\(\)!]) dst_arg=./$dst_arg;; 196 - esac 197 - done 198 -fi 199 - 200 -if test $# -eq 0; then 201 - if test -z "$dir_arg"; then 202 - echo "$0: no input file specified." >&2 203 - exit 1 204 - fi 205 - # It's OK to call `install-sh -d' without argument. 206 - # This can happen when creating conditional directories. 207 - exit 0 208 -fi 209 - 210 -if test -z "$dir_arg"; then 211 - do_exit='(exit $ret); exit $ret' 212 - trap "ret=129; $do_exit" 1 213 - trap "ret=130; $do_exit" 2 214 - trap "ret=141; $do_exit" 13 215 - trap "ret=143; $do_exit" 15 216 - 217 - # Set umask so as not to create temps with too-generous modes. 218 - # However, 'strip' requires both read and write access to temps. 219 - case $mode in 220 - # Optimize common cases. 221 - *644) cp_umask=133;; 222 - *755) cp_umask=22;; 223 - 224 - *[0-7]) 225 - if test -z "$stripcmd"; then 226 - u_plus_rw= 227 - else 228 - u_plus_rw='% 200' 229 - fi 230 - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 231 - *) 232 - if test -z "$stripcmd"; then 233 - u_plus_rw= 234 - else 235 - u_plus_rw=,u+rw 236 - fi 237 - cp_umask=$mode$u_plus_rw;; 238 - esac 239 -fi 240 - 241 -for src 242 -do 243 - # Protect names problematic for `test' and other utilities. 244 - case $src in 245 - -* | [=\(\)!]) src=./$src;; 246 - esac 247 - 248 - if test -n "$dir_arg"; then 249 - dst=$src 250 - dstdir=$dst 251 - test -d "$dstdir" 252 - dstdir_status=$? 253 - else 254 - 255 - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 256 - # might cause directories to be created, which would be especially bad 257 - # if $src (and thus $dsttmp) contains '*'. 258 - if test ! -f "$src" && test ! -d "$src"; then 259 - echo "$0: $src does not exist." >&2 260 - exit 1 261 - fi 262 - 263 - if test -z "$dst_arg"; then 264 - echo "$0: no destination specified." >&2 265 - exit 1 266 - fi 267 - dst=$dst_arg 268 - 269 - # If destination is a directory, append the input filename; won't work 270 - # if double slashes aren't ignored. 271 - if test -d "$dst"; then 272 - if test -n "$no_target_directory"; then 273 - echo "$0: $dst_arg: Is a directory" >&2 274 - exit 1 275 - fi 276 - dstdir=$dst 277 - dst=$dstdir/`basename "$src"` 278 - dstdir_status=0 279 - else 280 - # Prefer dirname, but fall back on a substitute if dirname fails. 281 - dstdir=` 282 - (dirname "$dst") 2>/dev/null || 283 - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 284 - X"$dst" : 'X\(//\)[^/]' \| \ 285 - X"$dst" : 'X\(//\)$' \| \ 286 - X"$dst" : 'X\(/\)' \| . 2>/dev/null || 287 - echo X"$dst" | 288 - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 289 - s//\1/ 290 - q 291 - } 292 - /^X\(\/\/\)[^/].*/{ 293 - s//\1/ 294 - q 295 - } 296 - /^X\(\/\/\)$/{ 297 - s//\1/ 298 - q 299 - } 300 - /^X\(\/\).*/{ 301 - s//\1/ 302 - q 303 - } 304 - s/.*/./; q' 305 - ` 306 - 307 - test -d "$dstdir" 308 - dstdir_status=$? 309 - fi 310 - fi 311 - 312 - obsolete_mkdir_used=false 313 - 314 - if test $dstdir_status != 0; then 315 - case $posix_mkdir in 316 - '') 317 - # Create intermediate dirs using mode 755 as modified by the umask. 318 - # This is like FreeBSD 'install' as of 1997-10-28. 319 - umask=`umask` 320 - case $stripcmd.$umask in 321 - # Optimize common cases. 322 - *[2367][2367]) mkdir_umask=$umask;; 323 - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 324 - 325 - *[0-7]) 326 - mkdir_umask=`expr $umask + 22 \ 327 - - $umask % 100 % 40 + $umask % 20 \ 328 - - $umask % 10 % 4 + $umask % 2 329 - `;; 330 - *) mkdir_umask=$umask,go-w;; 331 - esac 332 - 333 - # With -d, create the new directory with the user-specified mode. 334 - # Otherwise, rely on $mkdir_umask. 335 - if test -n "$dir_arg"; then 336 - mkdir_mode=-m$mode 337 - else 338 - mkdir_mode= 339 - fi 340 - 341 - posix_mkdir=false 342 - case $umask in 343 - *[123567][0-7][0-7]) 344 - # POSIX mkdir -p sets u+wx bits regardless of umask, which 345 - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 346 - ;; 347 - *) 348 - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 349 - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 350 - 351 - if (umask $mkdir_umask && 352 - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 353 - then 354 - if test -z "$dir_arg" || { 355 - # Check for POSIX incompatibilities with -m. 356 - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 357 - # other-writeable bit of parent directory when it shouldn't. 358 - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 359 - ls_ld_tmpdir=`ls -ld "$tmpdir"` 360 - case $ls_ld_tmpdir in 361 - d????-?r-*) different_mode=700;; 362 - d????-?--*) different_mode=755;; 363 - *) false;; 364 - esac && 365 - $mkdirprog -m$different_mode -p -- "$tmpdir" && { 366 - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 367 - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 368 - } 369 - } 370 - then posix_mkdir=: 371 - fi 372 - rmdir "$tmpdir/d" "$tmpdir" 373 - else 374 - # Remove any dirs left behind by ancient mkdir implementations. 375 - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 376 - fi 377 - trap '' 0;; 378 - esac;; 379 - esac 380 - 381 - if 382 - $posix_mkdir && ( 383 - umask $mkdir_umask && 384 - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 385 - ) 386 - then : 387 - else 388 - 389 - # The umask is ridiculous, or mkdir does not conform to POSIX, 390 - # or it failed possibly due to a race condition. Create the 391 - # directory the slow way, step by step, checking for races as we go. 392 - 393 - case $dstdir in 394 - /*) prefix='/';; 395 - [-=\(\)!]*) prefix='./';; 396 - *) prefix='';; 397 - esac 398 - 399 - eval "$initialize_posix_glob" 400 - 401 - oIFS=$IFS 402 - IFS=/ 403 - $posix_glob set -f 404 - set fnord $dstdir 405 - shift 406 - $posix_glob set +f 407 - IFS=$oIFS 408 - 409 - prefixes= 410 - 411 - for d 412 - do 413 - test X"$d" = X && continue 414 - 415 - prefix=$prefix$d 416 - if test -d "$prefix"; then 417 - prefixes= 418 - else 419 - if $posix_mkdir; then 420 - (umask=$mkdir_umask && 421 - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 422 - # Don't fail if two instances are running concurrently. 423 - test -d "$prefix" || exit 1 424 - else 425 - case $prefix in 426 - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 427 - *) qprefix=$prefix;; 428 - esac 429 - prefixes="$prefixes '$qprefix'" 430 - fi 431 - fi 432 - prefix=$prefix/ 433 - done 434 - 435 - if test -n "$prefixes"; then 436 - # Don't fail if two instances are running concurrently. 437 - (umask $mkdir_umask && 438 - eval "\$doit_exec \$mkdirprog $prefixes") || 439 - test -d "$dstdir" || exit 1 440 - obsolete_mkdir_used=true 441 - fi 442 - fi 443 - fi 444 - 445 - if test -n "$dir_arg"; then 446 - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 447 - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 448 - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 449 - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 450 - else 451 - 452 - # Make a couple of temp file names in the proper directory. 453 - dsttmp=$dstdir/_inst.$$_ 454 - rmtmp=$dstdir/_rm.$$_ 455 - 456 - # Trap to clean up those temp files at exit. 457 - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 458 - 459 - # Copy the file name to the temp name. 460 - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 461 - 462 - # and set any options; do chmod last to preserve setuid bits. 463 - # 464 - # If any of these fail, we abort the whole thing. If we want to 465 - # ignore errors from any of these, just make sure not to ignore 466 - # errors from the above "$doit $cpprog $src $dsttmp" command. 467 - # 468 - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 469 - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 470 - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 471 - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 472 - 473 - # If -C, don't bother to copy if it wouldn't change the file. 474 - if $copy_on_change && 475 - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 476 - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 477 - 478 - eval "$initialize_posix_glob" && 479 - $posix_glob set -f && 480 - set X $old && old=:$2:$4:$5:$6 && 481 - set X $new && new=:$2:$4:$5:$6 && 482 - $posix_glob set +f && 483 - 484 - test "$old" = "$new" && 485 - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 486 - then 487 - rm -f "$dsttmp" 488 - else 489 - # Rename the file to the real destination. 490 - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 491 - 492 - # The rename failed, perhaps because mv can't rename something else 493 - # to itself, or perhaps because mv is so ancient that it does not 494 - # support -f. 495 - { 496 - # Now remove or move aside any old file at destination location. 497 - # We try this two ways since rm can't unlink itself on some 498 - # systems and the destination file might be busy for other 499 - # reasons. In this case, the final cleanup might fail but the new 500 - # file should still install successfully. 501 - { 502 - test ! -f "$dst" || 503 - $doit $rmcmd -f "$dst" 2>/dev/null || 504 - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 505 - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 506 - } || 507 - { echo "$0: cannot unlink or rename $dst" >&2 508 - (exit 1); exit 1 509 - } 510 - } && 511 - 512 - # Now rename the file to the real destination. 513 - $doit $mvcmd "$dsttmp" "$dst" 514 - } 515 - fi || exit 1 516 - 517 - trap '' 0 518 - fi 519 -done 520 - 521 -# Local variables: 522 -# eval: (add-hook 'write-file-hooks 'time-stamp) 523 -# time-stamp-start: "scriptversion=" 524 -# time-stamp-format: "%:y-%02m-%02d.%02H" 525 -# time-stamp-time-zone: "UTC" 526 -# time-stamp-end: "; # UTC" 527 -# End:
Deleted ltmain.sh.
1 - 2 -# libtool (GNU libtool) 2.4.2 3 -# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4 - 5 -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6 -# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 7 -# This is free software; see the source for copying conditions. There is NO 8 -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 - 10 -# GNU Libtool is free software; you can redistribute it and/or modify 11 -# it under the terms of the GNU General Public License as published by 12 -# the Free Software Foundation; either version 2 of the License, or 13 -# (at your option) any later version. 14 -# 15 -# As a special exception to the GNU General Public License, 16 -# if you distribute this file as part of a program or library that 17 -# is built using GNU Libtool, you may include this file under the 18 -# same distribution terms that you use for the rest of that program. 19 -# 20 -# GNU Libtool is distributed in the hope that it will be useful, but 21 -# WITHOUT ANY WARRANTY; without even the implied warranty of 22 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 -# General Public License for more details. 24 -# 25 -# You should have received a copy of the GNU General Public License 26 -# along with GNU Libtool; see the file COPYING. If not, a copy 27 -# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28 -# or obtained by writing to the Free Software Foundation, Inc., 29 -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30 - 31 -# Usage: $progname [OPTION]... [MODE-ARG]... 32 -# 33 -# Provide generalized library-building support services. 34 -# 35 -# --config show all configuration variables 36 -# --debug enable verbose shell tracing 37 -# -n, --dry-run display commands without modifying any files 38 -# --features display basic configuration information and exit 39 -# --mode=MODE use operation mode MODE 40 -# --preserve-dup-deps don't remove duplicate dependency libraries 41 -# --quiet, --silent don't print informational messages 42 -# --no-quiet, --no-silent 43 -# print informational messages (default) 44 -# --no-warn don't display warning messages 45 -# --tag=TAG use configuration variables from tag TAG 46 -# -v, --verbose print more informational messages than default 47 -# --no-verbose don't print the extra informational messages 48 -# --version print version information 49 -# -h, --help, --help-all print short, long, or detailed help message 50 -# 51 -# MODE must be one of the following: 52 -# 53 -# clean remove files from the build directory 54 -# compile compile a source file into a libtool object 55 -# execute automatically set library path, then run a program 56 -# finish complete the installation of libtool libraries 57 -# install install libraries or executables 58 -# link create a library or an executable 59 -# uninstall remove libraries from an installed directory 60 -# 61 -# MODE-ARGS vary depending on the MODE. When passed as first option, 62 -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63 -# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64 -# 65 -# When reporting a bug, please describe a test case to reproduce it and 66 -# include the following information: 67 -# 68 -# host-triplet: $host 69 -# shell: $SHELL 70 -# compiler: $LTCC 71 -# compiler flags: $LTCFLAGS 72 -# linker: $LD (gnu? $with_gnu_ld) 73 -# $progname: (GNU libtool) 2.4.2 74 -# automake: $automake_version 75 -# autoconf: $autoconf_version 76 -# 77 -# Report bugs to <bug-libtool@gnu.org>. 78 -# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 79 -# General help using GNU software: <http://www.gnu.org/gethelp/>. 80 - 81 -PROGRAM=libtool 82 -PACKAGE=libtool 83 -VERSION=2.4.2 84 -TIMESTAMP="" 85 -package_revision=1.3337 86 - 87 -# Be Bourne compatible 88 -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89 - emulate sh 90 - NULLCMD=: 91 - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92 - # is contrary to our usage. Disable this feature. 93 - alias -g '${1+"$@"}'='"$@"' 94 - setopt NO_GLOB_SUBST 95 -else 96 - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97 -fi 98 -BIN_SH=xpg4; export BIN_SH # for Tru64 99 -DUALCASE=1; export DUALCASE # for MKS sh 100 - 101 -# A function that is used when there is no print builtin or printf. 102 -func_fallback_echo () 103 -{ 104 - eval 'cat <<_LTECHO_EOF 105 -$1 106 -_LTECHO_EOF' 107 -} 108 - 109 -# NLS nuisances: We save the old values to restore during execute mode. 110 -lt_user_locale= 111 -lt_safe_locale= 112 -for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113 -do 114 - eval "if test \"\${$lt_var+set}\" = set; then 115 - save_$lt_var=\$$lt_var 116 - $lt_var=C 117 - export $lt_var 118 - lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 119 - lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120 - fi" 121 -done 122 -LC_ALL=C 123 -LANGUAGE=C 124 -export LANGUAGE LC_ALL 125 - 126 -$lt_unset CDPATH 127 - 128 - 129 -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130 -# is ksh but when the shell is invoked as "sh" and the current value of 131 -# the _XPG environment variable is not equal to 1 (one), the special 132 -# positional parameter $0, within a function call, is the name of the 133 -# function. 134 -progpath="$0" 135 - 136 - 137 - 138 -: ${CP="cp -f"} 139 -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 140 -: ${MAKE="make"} 141 -: ${MKDIR="mkdir"} 142 -: ${MV="mv -f"} 143 -: ${RM="rm -f"} 144 -: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 145 -: ${Xsed="$SED -e 1s/^X//"} 146 - 147 -# Global variables: 148 -EXIT_SUCCESS=0 149 -EXIT_FAILURE=1 150 -EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 151 -EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 152 - 153 -exit_status=$EXIT_SUCCESS 154 - 155 -# Make sure IFS has a sensible default 156 -lt_nl=' 157 -' 158 -IFS=" $lt_nl" 159 - 160 -dirname="s,/[^/]*$,," 161 -basename="s,^.*/,," 162 - 163 -# func_dirname file append nondir_replacement 164 -# Compute the dirname of FILE. If nonempty, add APPEND to the result, 165 -# otherwise set result to NONDIR_REPLACEMENT. 166 -func_dirname () 167 -{ 168 - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 169 - if test "X$func_dirname_result" = "X${1}"; then 170 - func_dirname_result="${3}" 171 - else 172 - func_dirname_result="$func_dirname_result${2}" 173 - fi 174 -} # func_dirname may be replaced by extended shell implementation 175 - 176 - 177 -# func_basename file 178 -func_basename () 179 -{ 180 - func_basename_result=`$ECHO "${1}" | $SED "$basename"` 181 -} # func_basename may be replaced by extended shell implementation 182 - 183 - 184 -# func_dirname_and_basename file append nondir_replacement 185 -# perform func_basename and func_dirname in a single function 186 -# call: 187 -# dirname: Compute the dirname of FILE. If nonempty, 188 -# add APPEND to the result, otherwise set result 189 -# to NONDIR_REPLACEMENT. 190 -# value returned in "$func_dirname_result" 191 -# basename: Compute filename of FILE. 192 -# value retuned in "$func_basename_result" 193 -# Implementation must be kept synchronized with func_dirname 194 -# and func_basename. For efficiency, we do not delegate to 195 -# those functions but instead duplicate the functionality here. 196 -func_dirname_and_basename () 197 -{ 198 - # Extract subdirectory from the argument. 199 - func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 200 - if test "X$func_dirname_result" = "X${1}"; then 201 - func_dirname_result="${3}" 202 - else 203 - func_dirname_result="$func_dirname_result${2}" 204 - fi 205 - func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 206 -} # func_dirname_and_basename may be replaced by extended shell implementation 207 - 208 - 209 -# func_stripname prefix suffix name 210 -# strip PREFIX and SUFFIX off of NAME. 211 -# PREFIX and SUFFIX must not contain globbing or regex special 212 -# characters, hashes, percent signs, but SUFFIX may contain a leading 213 -# dot (in which case that matches only a dot). 214 -# func_strip_suffix prefix name 215 -func_stripname () 216 -{ 217 - case ${2} in 218 - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 219 - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 220 - esac 221 -} # func_stripname may be replaced by extended shell implementation 222 - 223 - 224 -# These SED scripts presuppose an absolute path with a trailing slash. 225 -pathcar='s,^/\([^/]*\).*$,\1,' 226 -pathcdr='s,^/[^/]*,,' 227 -removedotparts=':dotsl 228 - s@/\./@/@g 229 - t dotsl 230 - s,/\.$,/,' 231 -collapseslashes='s@/\{1,\}@/@g' 232 -finalslash='s,/*$,/,' 233 - 234 -# func_normal_abspath PATH 235 -# Remove doubled-up and trailing slashes, "." path components, 236 -# and cancel out any ".." path components in PATH after making 237 -# it an absolute path. 238 -# value returned in "$func_normal_abspath_result" 239 -func_normal_abspath () 240 -{ 241 - # Start from root dir and reassemble the path. 242 - func_normal_abspath_result= 243 - func_normal_abspath_tpath=$1 244 - func_normal_abspath_altnamespace= 245 - case $func_normal_abspath_tpath in 246 - "") 247 - # Empty path, that just means $cwd. 248 - func_stripname '' '/' "`pwd`" 249 - func_normal_abspath_result=$func_stripname_result 250 - return 251 - ;; 252 - # The next three entries are used to spot a run of precisely 253 - # two leading slashes without using negated character classes; 254 - # we take advantage of case's first-match behaviour. 255 - ///*) 256 - # Unusual form of absolute path, do nothing. 257 - ;; 258 - //*) 259 - # Not necessarily an ordinary path; POSIX reserves leading '//' 260 - # and for example Cygwin uses it to access remote file shares 261 - # over CIFS/SMB, so we conserve a leading double slash if found. 262 - func_normal_abspath_altnamespace=/ 263 - ;; 264 - /*) 265 - # Absolute path, do nothing. 266 - ;; 267 - *) 268 - # Relative path, prepend $cwd. 269 - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270 - ;; 271 - esac 272 - # Cancel out all the simple stuff to save iterations. We also want 273 - # the path to end with a slash for ease of parsing, so make sure 274 - # there is one (and only one) here. 275 - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276 - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277 - while :; do 278 - # Processed it all yet? 279 - if test "$func_normal_abspath_tpath" = / ; then 280 - # If we ascended to the root using ".." the result may be empty now. 281 - if test -z "$func_normal_abspath_result" ; then 282 - func_normal_abspath_result=/ 283 - fi 284 - break 285 - fi 286 - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287 - -e "$pathcar"` 288 - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289 - -e "$pathcdr"` 290 - # Figure out what to do with it 291 - case $func_normal_abspath_tcomponent in 292 - "") 293 - # Trailing empty path component, ignore it. 294 - ;; 295 - ..) 296 - # Parent dir; strip last assembled component from result. 297 - func_dirname "$func_normal_abspath_result" 298 - func_normal_abspath_result=$func_dirname_result 299 - ;; 300 - *) 301 - # Actual path component, append it. 302 - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303 - ;; 304 - esac 305 - done 306 - # Restore leading double-slash if one was found on entry. 307 - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 308 -} 309 - 310 -# func_relative_path SRCDIR DSTDIR 311 -# generates a relative path from SRCDIR to DSTDIR, with a trailing 312 -# slash if non-empty, suitable for immediately appending a filename 313 -# without needing to append a separator. 314 -# value returned in "$func_relative_path_result" 315 -func_relative_path () 316 -{ 317 - func_relative_path_result= 318 - func_normal_abspath "$1" 319 - func_relative_path_tlibdir=$func_normal_abspath_result 320 - func_normal_abspath "$2" 321 - func_relative_path_tbindir=$func_normal_abspath_result 322 - 323 - # Ascend the tree starting from libdir 324 - while :; do 325 - # check if we have found a prefix of bindir 326 - case $func_relative_path_tbindir in 327 - $func_relative_path_tlibdir) 328 - # found an exact match 329 - func_relative_path_tcancelled= 330 - break 331 - ;; 332 - $func_relative_path_tlibdir*) 333 - # found a matching prefix 334 - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335 - func_relative_path_tcancelled=$func_stripname_result 336 - if test -z "$func_relative_path_result"; then 337 - func_relative_path_result=. 338 - fi 339 - break 340 - ;; 341 - *) 342 - func_dirname $func_relative_path_tlibdir 343 - func_relative_path_tlibdir=${func_dirname_result} 344 - if test "x$func_relative_path_tlibdir" = x ; then 345 - # Have to descend all the way to the root! 346 - func_relative_path_result=../$func_relative_path_result 347 - func_relative_path_tcancelled=$func_relative_path_tbindir 348 - break 349 - fi 350 - func_relative_path_result=../$func_relative_path_result 351 - ;; 352 - esac 353 - done 354 - 355 - # Now calculate path; take care to avoid doubling-up slashes. 356 - func_stripname '' '/' "$func_relative_path_result" 357 - func_relative_path_result=$func_stripname_result 358 - func_stripname '/' '/' "$func_relative_path_tcancelled" 359 - if test "x$func_stripname_result" != x ; then 360 - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361 - fi 362 - 363 - # Normalisation. If bindir is libdir, return empty string, 364 - # else relative path ending with a slash; either way, target 365 - # file name can be directly appended. 366 - if test ! -z "$func_relative_path_result"; then 367 - func_stripname './' '' "$func_relative_path_result/" 368 - func_relative_path_result=$func_stripname_result 369 - fi 370 -} 371 - 372 -# The name of this program: 373 -func_dirname_and_basename "$progpath" 374 -progname=$func_basename_result 375 - 376 -# Make sure we have an absolute path for reexecution: 377 -case $progpath in 378 - [\\/]*|[A-Za-z]:\\*) ;; 379 - *[\\/]*) 380 - progdir=$func_dirname_result 381 - progdir=`cd "$progdir" && pwd` 382 - progpath="$progdir/$progname" 383 - ;; 384 - *) 385 - save_IFS="$IFS" 386 - IFS=${PATH_SEPARATOR-:} 387 - for progdir in $PATH; do 388 - IFS="$save_IFS" 389 - test -x "$progdir/$progname" && break 390 - done 391 - IFS="$save_IFS" 392 - test -n "$progdir" || progdir=`pwd` 393 - progpath="$progdir/$progname" 394 - ;; 395 -esac 396 - 397 -# Sed substitution that helps us do robust quoting. It backslashifies 398 -# metacharacters that are still active within double-quoted strings. 399 -Xsed="${SED}"' -e 1s/^X//' 400 -sed_quote_subst='s/\([`"$\\]\)/\\\1/g' 401 - 402 -# Same as above, but do not quote variable references. 403 -double_quote_subst='s/\(["`\\]\)/\\\1/g' 404 - 405 -# Sed substitution that turns a string into a regex matching for the 406 -# string literally. 407 -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 408 - 409 -# Sed substitution that converts a w32 file name or path 410 -# which contains forward slashes, into one that contains 411 -# (escaped) backslashes. A very naive implementation. 412 -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 413 - 414 -# Re-`\' parameter expansions in output of double_quote_subst that were 415 -# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 416 -# in input to double_quote_subst, that '$' was protected from expansion. 417 -# Since each input `\' is now two `\'s, look for any number of runs of 418 -# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 419 -bs='\\' 420 -bs2='\\\\' 421 -bs4='\\\\\\\\' 422 -dollar='\$' 423 -sed_double_backslash="\ 424 - s/$bs4/&\\ 425 -/g 426 - s/^$bs2$dollar/$bs&/ 427 - s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 428 - s/\n//g" 429 - 430 -# Standard options: 431 -opt_dry_run=false 432 -opt_help=false 433 -opt_quiet=false 434 -opt_verbose=false 435 -opt_warning=: 436 - 437 -# func_echo arg... 438 -# Echo program name prefixed message, along with the current mode 439 -# name if it has been set yet. 440 -func_echo () 441 -{ 442 - $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 443 -} 444 - 445 -# func_verbose arg... 446 -# Echo program name prefixed message in verbose mode only. 447 -func_verbose () 448 -{ 449 - $opt_verbose && func_echo ${1+"$@"} 450 - 451 - # A bug in bash halts the script if the last line of a function 452 - # fails when set -e is in force, so we need another command to 453 - # work around that: 454 - : 455 -} 456 - 457 -# func_echo_all arg... 458 -# Invoke $ECHO with all args, space-separated. 459 -func_echo_all () 460 -{ 461 - $ECHO "$*" 462 -} 463 - 464 -# func_error arg... 465 -# Echo program name prefixed message to standard error. 466 -func_error () 467 -{ 468 - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 469 -} 470 - 471 -# func_warning arg... 472 -# Echo program name prefixed warning message to standard error. 473 -func_warning () 474 -{ 475 - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 476 - 477 - # bash bug again: 478 - : 479 -} 480 - 481 -# func_fatal_error arg... 482 -# Echo program name prefixed message to standard error, and exit. 483 -func_fatal_error () 484 -{ 485 - func_error ${1+"$@"} 486 - exit $EXIT_FAILURE 487 -} 488 - 489 -# func_fatal_help arg... 490 -# Echo program name prefixed message to standard error, followed by 491 -# a help hint, and exit. 492 -func_fatal_help () 493 -{ 494 - func_error ${1+"$@"} 495 - func_fatal_error "$help" 496 -} 497 -help="Try \`$progname --help' for more information." ## default 498 - 499 - 500 -# func_grep expression filename 501 -# Check whether EXPRESSION matches any line of FILENAME, without output. 502 -func_grep () 503 -{ 504 - $GREP "$1" "$2" >/dev/null 2>&1 505 -} 506 - 507 - 508 -# func_mkdir_p directory-path 509 -# Make sure the entire path to DIRECTORY-PATH is available. 510 -func_mkdir_p () 511 -{ 512 - my_directory_path="$1" 513 - my_dir_list= 514 - 515 - if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 516 - 517 - # Protect directory names starting with `-' 518 - case $my_directory_path in 519 - -*) my_directory_path="./$my_directory_path" ;; 520 - esac 521 - 522 - # While some portion of DIR does not yet exist... 523 - while test ! -d "$my_directory_path"; do 524 - # ...make a list in topmost first order. Use a colon delimited 525 - # list incase some portion of path contains whitespace. 526 - my_dir_list="$my_directory_path:$my_dir_list" 527 - 528 - # If the last portion added has no slash in it, the list is done 529 - case $my_directory_path in */*) ;; *) break ;; esac 530 - 531 - # ...otherwise throw away the child directory and loop 532 - my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 533 - done 534 - my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 535 - 536 - save_mkdir_p_IFS="$IFS"; IFS=':' 537 - for my_dir in $my_dir_list; do 538 - IFS="$save_mkdir_p_IFS" 539 - # mkdir can fail with a `File exist' error if two processes 540 - # try to create one of the directories concurrently. Don't 541 - # stop in that case! 542 - $MKDIR "$my_dir" 2>/dev/null || : 543 - done 544 - IFS="$save_mkdir_p_IFS" 545 - 546 - # Bail out if we (or some other process) failed to create a directory. 547 - test -d "$my_directory_path" || \ 548 - func_fatal_error "Failed to create \`$1'" 549 - fi 550 -} 551 - 552 - 553 -# func_mktempdir [string] 554 -# Make a temporary directory that won't clash with other running 555 -# libtool processes, and avoids race conditions if possible. If 556 -# given, STRING is the basename for that directory. 557 -func_mktempdir () 558 -{ 559 - my_template="${TMPDIR-/tmp}/${1-$progname}" 560 - 561 - if test "$opt_dry_run" = ":"; then 562 - # Return a directory name, but don't create it in dry-run mode 563 - my_tmpdir="${my_template}-$$" 564 - else 565 - 566 - # If mktemp works, use that first and foremost 567 - my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568 - 569 - if test ! -d "$my_tmpdir"; then 570 - # Failing that, at least try and use $RANDOM to avoid a race 571 - my_tmpdir="${my_template}-${RANDOM-0}$$" 572 - 573 - save_mktempdir_umask=`umask` 574 - umask 0077 575 - $MKDIR "$my_tmpdir" 576 - umask $save_mktempdir_umask 577 - fi 578 - 579 - # If we're not in dry-run mode, bomb out on failure 580 - test -d "$my_tmpdir" || \ 581 - func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582 - fi 583 - 584 - $ECHO "$my_tmpdir" 585 -} 586 - 587 - 588 -# func_quote_for_eval arg 589 -# Aesthetically quote ARG to be evaled later. 590 -# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 591 -# is double-quoted, suitable for a subsequent eval, whereas 592 -# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 593 -# which are still active within double quotes backslashified. 594 -func_quote_for_eval () 595 -{ 596 - case $1 in 597 - *[\\\`\"\$]*) 598 - func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 599 - *) 600 - func_quote_for_eval_unquoted_result="$1" ;; 601 - esac 602 - 603 - case $func_quote_for_eval_unquoted_result in 604 - # Double-quote args containing shell metacharacters to delay 605 - # word splitting, command substitution and and variable 606 - # expansion for a subsequent eval. 607 - # Many Bourne shells cannot handle close brackets correctly 608 - # in scan sets, so we specify it separately. 609 - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 610 - func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 611 - ;; 612 - *) 613 - func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614 - esac 615 -} 616 - 617 - 618 -# func_quote_for_expand arg 619 -# Aesthetically quote ARG to be evaled later; same as above, 620 -# but do not quote variable references. 621 -func_quote_for_expand () 622 -{ 623 - case $1 in 624 - *[\\\`\"]*) 625 - my_arg=`$ECHO "$1" | $SED \ 626 - -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627 - *) 628 - my_arg="$1" ;; 629 - esac 630 - 631 - case $my_arg in 632 - # Double-quote args containing shell metacharacters to delay 633 - # word splitting and command substitution for a subsequent eval. 634 - # Many Bourne shells cannot handle close brackets correctly 635 - # in scan sets, so we specify it separately. 636 - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 637 - my_arg="\"$my_arg\"" 638 - ;; 639 - esac 640 - 641 - func_quote_for_expand_result="$my_arg" 642 -} 643 - 644 - 645 -# func_show_eval cmd [fail_exp] 646 -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 647 -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 648 -# is given, then evaluate it. 649 -func_show_eval () 650 -{ 651 - my_cmd="$1" 652 - my_fail_exp="${2-:}" 653 - 654 - ${opt_silent-false} || { 655 - func_quote_for_expand "$my_cmd" 656 - eval "func_echo $func_quote_for_expand_result" 657 - } 658 - 659 - if ${opt_dry_run-false}; then :; else 660 - eval "$my_cmd" 661 - my_status=$? 662 - if test "$my_status" -eq 0; then :; else 663 - eval "(exit $my_status); $my_fail_exp" 664 - fi 665 - fi 666 -} 667 - 668 - 669 -# func_show_eval_locale cmd [fail_exp] 670 -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 671 -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 672 -# is given, then evaluate it. Use the saved locale for evaluation. 673 -func_show_eval_locale () 674 -{ 675 - my_cmd="$1" 676 - my_fail_exp="${2-:}" 677 - 678 - ${opt_silent-false} || { 679 - func_quote_for_expand "$my_cmd" 680 - eval "func_echo $func_quote_for_expand_result" 681 - } 682 - 683 - if ${opt_dry_run-false}; then :; else 684 - eval "$lt_user_locale 685 - $my_cmd" 686 - my_status=$? 687 - eval "$lt_safe_locale" 688 - if test "$my_status" -eq 0; then :; else 689 - eval "(exit $my_status); $my_fail_exp" 690 - fi 691 - fi 692 -} 693 - 694 -# func_tr_sh 695 -# Turn $1 into a string suitable for a shell variable name. 696 -# Result is stored in $func_tr_sh_result. All characters 697 -# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 698 -# if $1 begins with a digit, a '_' is prepended as well. 699 -func_tr_sh () 700 -{ 701 - case $1 in 702 - [0-9]* | *[!a-zA-Z0-9_]*) 703 - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704 - ;; 705 - * ) 706 - func_tr_sh_result=$1 707 - ;; 708 - esac 709 -} 710 - 711 - 712 -# func_version 713 -# Echo version message to standard output and exit. 714 -func_version () 715 -{ 716 - $opt_debug 717 - 718 - $SED -n '/(C)/!b go 719 - :more 720 - /\./!{ 721 - N 722 - s/\n# / / 723 - b more 724 - } 725 - :go 726 - /^# '$PROGRAM' (GNU /,/# warranty; / { 727 - s/^# // 728 - s/^# *$// 729 - s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 730 - p 731 - }' < "$progpath" 732 - exit $? 733 -} 734 - 735 -# func_usage 736 -# Echo short help message to standard output and exit. 737 -func_usage () 738 -{ 739 - $opt_debug 740 - 741 - $SED -n '/^# Usage:/,/^# *.*--help/ { 742 - s/^# // 743 - s/^# *$// 744 - s/\$progname/'$progname'/ 745 - p 746 - }' < "$progpath" 747 - echo 748 - $ECHO "run \`$progname --help | more' for full usage" 749 - exit $? 750 -} 751 - 752 -# func_help [NOEXIT] 753 -# Echo long help message to standard output and exit, 754 -# unless 'noexit' is passed as argument. 755 -func_help () 756 -{ 757 - $opt_debug 758 - 759 - $SED -n '/^# Usage:/,/# Report bugs to/ { 760 - :print 761 - s/^# // 762 - s/^# *$// 763 - s*\$progname*'$progname'* 764 - s*\$host*'"$host"'* 765 - s*\$SHELL*'"$SHELL"'* 766 - s*\$LTCC*'"$LTCC"'* 767 - s*\$LTCFLAGS*'"$LTCFLAGS"'* 768 - s*\$LD*'"$LD"'* 769 - s/\$with_gnu_ld/'"$with_gnu_ld"'/ 770 - s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 771 - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 772 - p 773 - d 774 - } 775 - /^# .* home page:/b print 776 - /^# General help using/b print 777 - ' < "$progpath" 778 - ret=$? 779 - if test -z "$1"; then 780 - exit $ret 781 - fi 782 -} 783 - 784 -# func_missing_arg argname 785 -# Echo program name prefixed message to standard error and set global 786 -# exit_cmd. 787 -func_missing_arg () 788 -{ 789 - $opt_debug 790 - 791 - func_error "missing argument for $1." 792 - exit_cmd=exit 793 -} 794 - 795 - 796 -# func_split_short_opt shortopt 797 -# Set func_split_short_opt_name and func_split_short_opt_arg shell 798 -# variables after splitting SHORTOPT after the 2nd character. 799 -func_split_short_opt () 800 -{ 801 - my_sed_short_opt='1s/^\(..\).*$/\1/;q' 802 - my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 803 - 804 - func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 805 - func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 806 -} # func_split_short_opt may be replaced by extended shell implementation 807 - 808 - 809 -# func_split_long_opt longopt 810 -# Set func_split_long_opt_name and func_split_long_opt_arg shell 811 -# variables after splitting LONGOPT at the `=' sign. 812 -func_split_long_opt () 813 -{ 814 - my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 815 - my_sed_long_arg='1s/^--[^=]*=//' 816 - 817 - func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 818 - func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 819 -} # func_split_long_opt may be replaced by extended shell implementation 820 - 821 -exit_cmd=: 822 - 823 - 824 - 825 - 826 - 827 -magic="%%%MAGIC variable%%%" 828 -magic_exe="%%%MAGIC EXE variable%%%" 829 - 830 -# Global variables. 831 -nonopt= 832 -preserve_args= 833 -lo2o="s/\\.lo\$/.${objext}/" 834 -o2lo="s/\\.${objext}\$/.lo/" 835 -extracted_archives= 836 -extracted_serial=0 837 - 838 -# If this variable is set in any of the actions, the command in it 839 -# will be execed at the end. This prevents here-documents from being 840 -# left over by shells. 841 -exec_cmd= 842 - 843 -# func_append var value 844 -# Append VALUE to the end of shell variable VAR. 845 -func_append () 846 -{ 847 - eval "${1}=\$${1}\${2}" 848 -} # func_append may be replaced by extended shell implementation 849 - 850 -# func_append_quoted var value 851 -# Quote VALUE and append to the end of shell variable VAR, separated 852 -# by a space. 853 -func_append_quoted () 854 -{ 855 - func_quote_for_eval "${2}" 856 - eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 857 -} # func_append_quoted may be replaced by extended shell implementation 858 - 859 - 860 -# func_arith arithmetic-term... 861 -func_arith () 862 -{ 863 - func_arith_result=`expr "${@}"` 864 -} # func_arith may be replaced by extended shell implementation 865 - 866 - 867 -# func_len string 868 -# STRING may not start with a hyphen. 869 -func_len () 870 -{ 871 - func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 872 -} # func_len may be replaced by extended shell implementation 873 - 874 - 875 -# func_lo2o object 876 -func_lo2o () 877 -{ 878 - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 879 -} # func_lo2o may be replaced by extended shell implementation 880 - 881 - 882 -# func_xform libobj-or-source 883 -func_xform () 884 -{ 885 - func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 886 -} # func_xform may be replaced by extended shell implementation 887 - 888 - 889 -# func_fatal_configuration arg... 890 -# Echo program name prefixed message to standard error, followed by 891 -# a configuration failure hint, and exit. 892 -func_fatal_configuration () 893 -{ 894 - func_error ${1+"$@"} 895 - func_error "See the $PACKAGE documentation for more information." 896 - func_fatal_error "Fatal configuration error." 897 -} 898 - 899 - 900 -# func_config 901 -# Display the configuration for all the tags in this script. 902 -func_config () 903 -{ 904 - re_begincf='^# ### BEGIN LIBTOOL' 905 - re_endcf='^# ### END LIBTOOL' 906 - 907 - # Default configuration. 908 - $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 909 - 910 - # Now print the configurations for the tags. 911 - for tagname in $taglist; do 912 - $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913 - done 914 - 915 - exit $? 916 -} 917 - 918 -# func_features 919 -# Display the features supported by this script. 920 -func_features () 921 -{ 922 - echo "host: $host" 923 - if test "$build_libtool_libs" = yes; then 924 - echo "enable shared libraries" 925 - else 926 - echo "disable shared libraries" 927 - fi 928 - if test "$build_old_libs" = yes; then 929 - echo "enable static libraries" 930 - else 931 - echo "disable static libraries" 932 - fi 933 - 934 - exit $? 935 -} 936 - 937 -# func_enable_tag tagname 938 -# Verify that TAGNAME is valid, and either flag an error and exit, or 939 -# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 940 -# variable here. 941 -func_enable_tag () 942 -{ 943 - # Global variable: 944 - tagname="$1" 945 - 946 - re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 947 - re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 948 - sed_extractcf="/$re_begincf/,/$re_endcf/p" 949 - 950 - # Validate tagname. 951 - case $tagname in 952 - *[!-_A-Za-z0-9,/]*) 953 - func_fatal_error "invalid tag name: $tagname" 954 - ;; 955 - esac 956 - 957 - # Don't test for the "default" C tag, as we know it's 958 - # there but not specially marked. 959 - case $tagname in 960 - CC) ;; 961 - *) 962 - if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 963 - taglist="$taglist $tagname" 964 - 965 - # Evaluate the configuration. Be careful to quote the path 966 - # and the sed script, to avoid splitting on whitespace, but 967 - # also don't use non-portable quotes within backquotes within 968 - # quotes we have to do it in 2 steps: 969 - extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 970 - eval "$extractedcf" 971 - else 972 - func_error "ignoring unknown tag $tagname" 973 - fi 974 - ;; 975 - esac 976 -} 977 - 978 -# func_check_version_match 979 -# Ensure that we are using m4 macros, and libtool script from the same 980 -# release of libtool. 981 -func_check_version_match () 982 -{ 983 - if test "$package_revision" != "$macro_revision"; then 984 - if test "$VERSION" != "$macro_version"; then 985 - if test -z "$macro_version"; then 986 - cat >&2 <<_LT_EOF 987 -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 988 -$progname: definition of this LT_INIT comes from an older release. 989 -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 990 -$progname: and run autoconf again. 991 -_LT_EOF 992 - else 993 - cat >&2 <<_LT_EOF 994 -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 995 -$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 996 -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 997 -$progname: and run autoconf again. 998 -_LT_EOF 999 - fi 1000 - else 1001 - cat >&2 <<_LT_EOF 1002 -$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1003 -$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1004 -$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1005 -$progname: of $PACKAGE $VERSION and run autoconf again. 1006 -_LT_EOF 1007 - fi 1008 - 1009 - exit $EXIT_MISMATCH 1010 - fi 1011 -} 1012 - 1013 - 1014 -# Shorthand for --mode=foo, only valid as the first argument 1015 -case $1 in 1016 -clean|clea|cle|cl) 1017 - shift; set dummy --mode clean ${1+"$@"}; shift 1018 - ;; 1019 -compile|compil|compi|comp|com|co|c) 1020 - shift; set dummy --mode compile ${1+"$@"}; shift 1021 - ;; 1022 -execute|execut|execu|exec|exe|ex|e) 1023 - shift; set dummy --mode execute ${1+"$@"}; shift 1024 - ;; 1025 -finish|finis|fini|fin|fi|f) 1026 - shift; set dummy --mode finish ${1+"$@"}; shift 1027 - ;; 1028 -install|instal|insta|inst|ins|in|i) 1029 - shift; set dummy --mode install ${1+"$@"}; shift 1030 - ;; 1031 -link|lin|li|l) 1032 - shift; set dummy --mode link ${1+"$@"}; shift 1033 - ;; 1034 -uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1035 - shift; set dummy --mode uninstall ${1+"$@"}; shift 1036 - ;; 1037 -esac 1038 - 1039 - 1040 - 1041 -# Option defaults: 1042 -opt_debug=: 1043 -opt_dry_run=false 1044 -opt_config=false 1045 -opt_preserve_dup_deps=false 1046 -opt_features=false 1047 -opt_finish=false 1048 -opt_help=false 1049 -opt_help_all=false 1050 -opt_silent=: 1051 -opt_warning=: 1052 -opt_verbose=: 1053 -opt_silent=false 1054 -opt_verbose=false 1055 - 1056 - 1057 -# Parse options once, thoroughly. This comes as soon as possible in the 1058 -# script to make things like `--version' happen as quickly as we can. 1059 -{ 1060 - # this just eases exit handling 1061 - while test $# -gt 0; do 1062 - opt="$1" 1063 - shift 1064 - case $opt in 1065 - --debug|-x) opt_debug='set -x' 1066 - func_echo "enabling shell trace mode" 1067 - $opt_debug 1068 - ;; 1069 - --dry-run|--dryrun|-n) 1070 - opt_dry_run=: 1071 - ;; 1072 - --config) 1073 - opt_config=: 1074 -func_config 1075 - ;; 1076 - --dlopen|-dlopen) 1077 - optarg="$1" 1078 - opt_dlopen="${opt_dlopen+$opt_dlopen 1079 -}$optarg" 1080 - shift 1081 - ;; 1082 - --preserve-dup-deps) 1083 - opt_preserve_dup_deps=: 1084 - ;; 1085 - --features) 1086 - opt_features=: 1087 -func_features 1088 - ;; 1089 - --finish) 1090 - opt_finish=: 1091 -set dummy --mode finish ${1+"$@"}; shift 1092 - ;; 1093 - --help) 1094 - opt_help=: 1095 - ;; 1096 - --help-all) 1097 - opt_help_all=: 1098 -opt_help=': help-all' 1099 - ;; 1100 - --mode) 1101 - test $# = 0 && func_missing_arg $opt && break 1102 - optarg="$1" 1103 - opt_mode="$optarg" 1104 -case $optarg in 1105 - # Valid mode arguments: 1106 - clean|compile|execute|finish|install|link|relink|uninstall) ;; 1107 - 1108 - # Catch anything else as an error 1109 - *) func_error "invalid argument for $opt" 1110 - exit_cmd=exit 1111 - break 1112 - ;; 1113 -esac 1114 - shift 1115 - ;; 1116 - --no-silent|--no-quiet) 1117 - opt_silent=false 1118 -func_append preserve_args " $opt" 1119 - ;; 1120 - --no-warning|--no-warn) 1121 - opt_warning=false 1122 -func_append preserve_args " $opt" 1123 - ;; 1124 - --no-verbose) 1125 - opt_verbose=false 1126 -func_append preserve_args " $opt" 1127 - ;; 1128 - --silent|--quiet) 1129 - opt_silent=: 1130 -func_append preserve_args " $opt" 1131 - opt_verbose=false 1132 - ;; 1133 - --verbose|-v) 1134 - opt_verbose=: 1135 -func_append preserve_args " $opt" 1136 -opt_silent=false 1137 - ;; 1138 - --tag) 1139 - test $# = 0 && func_missing_arg $opt && break 1140 - optarg="$1" 1141 - opt_tag="$optarg" 1142 -func_append preserve_args " $opt $optarg" 1143 -func_enable_tag "$optarg" 1144 - shift 1145 - ;; 1146 - 1147 - -\?|-h) func_usage ;; 1148 - --help) func_help ;; 1149 - --version) func_version ;; 1150 - 1151 - # Separate optargs to long options: 1152 - --*=*) 1153 - func_split_long_opt "$opt" 1154 - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1155 - shift 1156 - ;; 1157 - 1158 - # Separate non-argument short options: 1159 - -\?*|-h*|-n*|-v*) 1160 - func_split_short_opt "$opt" 1161 - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1162 - shift 1163 - ;; 1164 - 1165 - --) break ;; 1166 - -*) func_fatal_help "unrecognized option \`$opt'" ;; 1167 - *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168 - esac 1169 - done 1170 - 1171 - # Validate options: 1172 - 1173 - # save first non-option argument 1174 - if test "$#" -gt 0; then 1175 - nonopt="$opt" 1176 - shift 1177 - fi 1178 - 1179 - # preserve --debug 1180 - test "$opt_debug" = : || func_append preserve_args " --debug" 1181 - 1182 - case $host in 1183 - *cygwin* | *mingw* | *pw32* | *cegcc*) 1184 - # don't eliminate duplications in $postdeps and $predeps 1185 - opt_duplicate_compiler_generated_deps=: 1186 - ;; 1187 - *) 1188 - opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1189 - ;; 1190 - esac 1191 - 1192 - $opt_help || { 1193 - # Sanity checks first: 1194 - func_check_version_match 1195 - 1196 - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1197 - func_fatal_configuration "not configured to build any kind of library" 1198 - fi 1199 - 1200 - # Darwin sucks 1201 - eval std_shrext=\"$shrext_cmds\" 1202 - 1203 - # Only execute mode is allowed to have -dlopen flags. 1204 - if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1205 - func_error "unrecognized option \`-dlopen'" 1206 - $ECHO "$help" 1>&2 1207 - exit $EXIT_FAILURE 1208 - fi 1209 - 1210 - # Change the help message to a mode-specific one. 1211 - generic_help="$help" 1212 - help="Try \`$progname --help --mode=$opt_mode' for more information." 1213 - } 1214 - 1215 - 1216 - # Bail if the options were screwed 1217 - $exit_cmd $EXIT_FAILURE 1218 -} 1219 - 1220 - 1221 - 1222 - 1223 -## ----------- ## 1224 -## Main. ## 1225 -## ----------- ## 1226 - 1227 -# func_lalib_p file 1228 -# True iff FILE is a libtool `.la' library or `.lo' object file. 1229 -# This function is only a basic sanity check; it will hardly flush out 1230 -# determined imposters. 1231 -func_lalib_p () 1232 -{ 1233 - test -f "$1" && 1234 - $SED -e 4q "$1" 2>/dev/null \ 1235 - | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1236 -} 1237 - 1238 -# func_lalib_unsafe_p file 1239 -# True iff FILE is a libtool `.la' library or `.lo' object file. 1240 -# This function implements the same check as func_lalib_p without 1241 -# resorting to external programs. To this end, it redirects stdin and 1242 -# closes it afterwards, without saving the original file descriptor. 1243 -# As a safety measure, use it only where a negative result would be 1244 -# fatal anyway. Works if `file' does not exist. 1245 -func_lalib_unsafe_p () 1246 -{ 1247 - lalib_p=no 1248 - if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1249 - for lalib_p_l in 1 2 3 4 1250 - do 1251 - read lalib_p_line 1252 - case "$lalib_p_line" in 1253 - \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1254 - esac 1255 - done 1256 - exec 0<&5 5<&- 1257 - fi 1258 - test "$lalib_p" = yes 1259 -} 1260 - 1261 -# func_ltwrapper_script_p file 1262 -# True iff FILE is a libtool wrapper script 1263 -# This function is only a basic sanity check; it will hardly flush out 1264 -# determined imposters. 1265 -func_ltwrapper_script_p () 1266 -{ 1267 - func_lalib_p "$1" 1268 -} 1269 - 1270 -# func_ltwrapper_executable_p file 1271 -# True iff FILE is a libtool wrapper executable 1272 -# This function is only a basic sanity check; it will hardly flush out 1273 -# determined imposters. 1274 -func_ltwrapper_executable_p () 1275 -{ 1276 - func_ltwrapper_exec_suffix= 1277 - case $1 in 1278 - *.exe) ;; 1279 - *) func_ltwrapper_exec_suffix=.exe ;; 1280 - esac 1281 - $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1282 -} 1283 - 1284 -# func_ltwrapper_scriptname file 1285 -# Assumes file is an ltwrapper_executable 1286 -# uses $file to determine the appropriate filename for a 1287 -# temporary ltwrapper_script. 1288 -func_ltwrapper_scriptname () 1289 -{ 1290 - func_dirname_and_basename "$1" "" "." 1291 - func_stripname '' '.exe' "$func_basename_result" 1292 - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1293 -} 1294 - 1295 -# func_ltwrapper_p file 1296 -# True iff FILE is a libtool wrapper script or wrapper executable 1297 -# This function is only a basic sanity check; it will hardly flush out 1298 -# determined imposters. 1299 -func_ltwrapper_p () 1300 -{ 1301 - func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1302 -} 1303 - 1304 - 1305 -# func_execute_cmds commands fail_cmd 1306 -# Execute tilde-delimited COMMANDS. 1307 -# If FAIL_CMD is given, eval that upon failure. 1308 -# FAIL_CMD may read-access the current command in variable CMD! 1309 -func_execute_cmds () 1310 -{ 1311 - $opt_debug 1312 - save_ifs=$IFS; IFS='~' 1313 - for cmd in $1; do 1314 - IFS=$save_ifs 1315 - eval cmd=\"$cmd\" 1316 - func_show_eval "$cmd" "${2-:}" 1317 - done 1318 - IFS=$save_ifs 1319 -} 1320 - 1321 - 1322 -# func_source file 1323 -# Source FILE, adding directory component if necessary. 1324 -# Note that it is not necessary on cygwin/mingw to append a dot to 1325 -# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1326 -# behavior happens only for exec(3), not for open(2)! Also, sourcing 1327 -# `FILE.' does not work on cygwin managed mounts. 1328 -func_source () 1329 -{ 1330 - $opt_debug 1331 - case $1 in 1332 - */* | *\\*) . "$1" ;; 1333 - *) . "./$1" ;; 1334 - esac 1335 -} 1336 - 1337 - 1338 -# func_resolve_sysroot PATH 1339 -# Replace a leading = in PATH with a sysroot. Store the result into 1340 -# func_resolve_sysroot_result 1341 -func_resolve_sysroot () 1342 -{ 1343 - func_resolve_sysroot_result=$1 1344 - case $func_resolve_sysroot_result in 1345 - =*) 1346 - func_stripname '=' '' "$func_resolve_sysroot_result" 1347 - func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1348 - ;; 1349 - esac 1350 -} 1351 - 1352 -# func_replace_sysroot PATH 1353 -# If PATH begins with the sysroot, replace it with = and 1354 -# store the result into func_replace_sysroot_result. 1355 -func_replace_sysroot () 1356 -{ 1357 - case "$lt_sysroot:$1" in 1358 - ?*:"$lt_sysroot"*) 1359 - func_stripname "$lt_sysroot" '' "$1" 1360 - func_replace_sysroot_result="=$func_stripname_result" 1361 - ;; 1362 - *) 1363 - # Including no sysroot. 1364 - func_replace_sysroot_result=$1 1365 - ;; 1366 - esac 1367 -} 1368 - 1369 -# func_infer_tag arg 1370 -# Infer tagged configuration to use if any are available and 1371 -# if one wasn't chosen via the "--tag" command line option. 1372 -# Only attempt this if the compiler in the base compile 1373 -# command doesn't match the default compiler. 1374 -# arg is usually of the form 'gcc ...' 1375 -func_infer_tag () 1376 -{ 1377 - $opt_debug 1378 - if test -n "$available_tags" && test -z "$tagname"; then 1379 - CC_quoted= 1380 - for arg in $CC; do 1381 - func_append_quoted CC_quoted "$arg" 1382 - done 1383 - CC_expanded=`func_echo_all $CC` 1384 - CC_quoted_expanded=`func_echo_all $CC_quoted` 1385 - case $@ in 1386 - # Blanks in the command may have been stripped by the calling shell, 1387 - # but not from the CC environment variable when configure was run. 1388 - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1389 - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1390 - # Blanks at the start of $base_compile will cause this to fail 1391 - # if we don't check for them as well. 1392 - *) 1393 - for z in $available_tags; do 1394 - if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1395 - # Evaluate the configuration. 1396 - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1397 - CC_quoted= 1398 - for arg in $CC; do 1399 - # Double-quote args containing other shell metacharacters. 1400 - func_append_quoted CC_quoted "$arg" 1401 - done 1402 - CC_expanded=`func_echo_all $CC` 1403 - CC_quoted_expanded=`func_echo_all $CC_quoted` 1404 - case "$@ " in 1405 - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1406 - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1407 - # The compiler in the base compile command matches 1408 - # the one in the tagged configuration. 1409 - # Assume this is the tagged configuration we want. 1410 - tagname=$z 1411 - break 1412 - ;; 1413 - esac 1414 - fi 1415 - done 1416 - # If $tagname still isn't set, then no tagged configuration 1417 - # was found and let the user know that the "--tag" command 1418 - # line option must be used. 1419 - if test -z "$tagname"; then 1420 - func_echo "unable to infer tagged configuration" 1421 - func_fatal_error "specify a tag with \`--tag'" 1422 -# else 1423 -# func_verbose "using $tagname tagged configuration" 1424 - fi 1425 - ;; 1426 - esac 1427 - fi 1428 -} 1429 - 1430 - 1431 - 1432 -# func_write_libtool_object output_name pic_name nonpic_name 1433 -# Create a libtool object file (analogous to a ".la" file), 1434 -# but don't create it if we're doing a dry run. 1435 -func_write_libtool_object () 1436 -{ 1437 - write_libobj=${1} 1438 - if test "$build_libtool_libs" = yes; then 1439 - write_lobj=\'${2}\' 1440 - else 1441 - write_lobj=none 1442 - fi 1443 - 1444 - if test "$build_old_libs" = yes; then 1445 - write_oldobj=\'${3}\' 1446 - else 1447 - write_oldobj=none 1448 - fi 1449 - 1450 - $opt_dry_run || { 1451 - cat >${write_libobj}T <<EOF 1452 -# $write_libobj - a libtool object file 1453 -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1454 -# 1455 -# Please DO NOT delete this file! 1456 -# It is necessary for linking the library. 1457 - 1458 -# Name of the PIC object. 1459 -pic_object=$write_lobj 1460 - 1461 -# Name of the non-PIC object 1462 -non_pic_object=$write_oldobj 1463 - 1464 -EOF 1465 - $MV "${write_libobj}T" "${write_libobj}" 1466 - } 1467 -} 1468 - 1469 - 1470 -################################################## 1471 -# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1472 -################################################## 1473 - 1474 -# func_convert_core_file_wine_to_w32 ARG 1475 -# Helper function used by file name conversion functions when $build is *nix, 1476 -# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1477 -# correctly configured wine environment available, with the winepath program 1478 -# in $build's $PATH. 1479 -# 1480 -# ARG is the $build file name to be converted to w32 format. 1481 -# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1482 -# be empty on error (or when ARG is empty) 1483 -func_convert_core_file_wine_to_w32 () 1484 -{ 1485 - $opt_debug 1486 - func_convert_core_file_wine_to_w32_result="$1" 1487 - if test -n "$1"; then 1488 - # Unfortunately, winepath does not exit with a non-zero error code, so we 1489 - # are forced to check the contents of stdout. On the other hand, if the 1490 - # command is not found, the shell will set an exit code of 127 and print 1491 - # *an error message* to stdout. So we must check for both error code of 1492 - # zero AND non-empty stdout, which explains the odd construction: 1493 - func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1494 - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1495 - func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1496 - $SED -e "$lt_sed_naive_backslashify"` 1497 - else 1498 - func_convert_core_file_wine_to_w32_result= 1499 - fi 1500 - fi 1501 -} 1502 -# end: func_convert_core_file_wine_to_w32 1503 - 1504 - 1505 -# func_convert_core_path_wine_to_w32 ARG 1506 -# Helper function used by path conversion functions when $build is *nix, and 1507 -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1508 -# configured wine environment available, with the winepath program in $build's 1509 -# $PATH. Assumes ARG has no leading or trailing path separator characters. 1510 -# 1511 -# ARG is path to be converted from $build format to win32. 1512 -# Result is available in $func_convert_core_path_wine_to_w32_result. 1513 -# Unconvertible file (directory) names in ARG are skipped; if no directory names 1514 -# are convertible, then the result may be empty. 1515 -func_convert_core_path_wine_to_w32 () 1516 -{ 1517 - $opt_debug 1518 - # unfortunately, winepath doesn't convert paths, only file names 1519 - func_convert_core_path_wine_to_w32_result="" 1520 - if test -n "$1"; then 1521 - oldIFS=$IFS 1522 - IFS=: 1523 - for func_convert_core_path_wine_to_w32_f in $1; do 1524 - IFS=$oldIFS 1525 - func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1526 - if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1527 - if test -z "$func_convert_core_path_wine_to_w32_result"; then 1528 - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1529 - else 1530 - func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1531 - fi 1532 - fi 1533 - done 1534 - IFS=$oldIFS 1535 - fi 1536 -} 1537 -# end: func_convert_core_path_wine_to_w32 1538 - 1539 - 1540 -# func_cygpath ARGS... 1541 -# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1542 -# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1543 -# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1544 -# (2), returns the Cygwin file name or path in func_cygpath_result (input 1545 -# file name or path is assumed to be in w32 format, as previously converted 1546 -# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1547 -# or path in func_cygpath_result (input file name or path is assumed to be in 1548 -# Cygwin format). Returns an empty string on error. 1549 -# 1550 -# ARGS are passed to cygpath, with the last one being the file name or path to 1551 -# be converted. 1552 -# 1553 -# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1554 -# environment variable; do not put it in $PATH. 1555 -func_cygpath () 1556 -{ 1557 - $opt_debug 1558 - if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1559 - func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1560 - if test "$?" -ne 0; then 1561 - # on failure, ensure result is empty 1562 - func_cygpath_result= 1563 - fi 1564 - else 1565 - func_cygpath_result= 1566 - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1567 - fi 1568 -} 1569 -#end: func_cygpath 1570 - 1571 - 1572 -# func_convert_core_msys_to_w32 ARG 1573 -# Convert file name or path ARG from MSYS format to w32 format. Return 1574 -# result in func_convert_core_msys_to_w32_result. 1575 -func_convert_core_msys_to_w32 () 1576 -{ 1577 - $opt_debug 1578 - # awkward: cmd appends spaces to result 1579 - func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1580 - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1581 -} 1582 -#end: func_convert_core_msys_to_w32 1583 - 1584 - 1585 -# func_convert_file_check ARG1 ARG2 1586 -# Verify that ARG1 (a file name in $build format) was converted to $host 1587 -# format in ARG2. Otherwise, emit an error message, but continue (resetting 1588 -# func_to_host_file_result to ARG1). 1589 -func_convert_file_check () 1590 -{ 1591 - $opt_debug 1592 - if test -z "$2" && test -n "$1" ; then 1593 - func_error "Could not determine host file name corresponding to" 1594 - func_error " \`$1'" 1595 - func_error "Continuing, but uninstalled executables may not work." 1596 - # Fallback: 1597 - func_to_host_file_result="$1" 1598 - fi 1599 -} 1600 -# end func_convert_file_check 1601 - 1602 - 1603 -# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1604 -# Verify that FROM_PATH (a path in $build format) was converted to $host 1605 -# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1606 -# func_to_host_file_result to a simplistic fallback value (see below). 1607 -func_convert_path_check () 1608 -{ 1609 - $opt_debug 1610 - if test -z "$4" && test -n "$3"; then 1611 - func_error "Could not determine the host path corresponding to" 1612 - func_error " \`$3'" 1613 - func_error "Continuing, but uninstalled executables may not work." 1614 - # Fallback. This is a deliberately simplistic "conversion" and 1615 - # should not be "improved". See libtool.info. 1616 - if test "x$1" != "x$2"; then 1617 - lt_replace_pathsep_chars="s|$1|$2|g" 1618 - func_to_host_path_result=`echo "$3" | 1619 - $SED -e "$lt_replace_pathsep_chars"` 1620 - else 1621 - func_to_host_path_result="$3" 1622 - fi 1623 - fi 1624 -} 1625 -# end func_convert_path_check 1626 - 1627 - 1628 -# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1629 -# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1630 -# and appending REPL if ORIG matches BACKPAT. 1631 -func_convert_path_front_back_pathsep () 1632 -{ 1633 - $opt_debug 1634 - case $4 in 1635 - $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1636 - ;; 1637 - esac 1638 - case $4 in 1639 - $2 ) func_append func_to_host_path_result "$3" 1640 - ;; 1641 - esac 1642 -} 1643 -# end func_convert_path_front_back_pathsep 1644 - 1645 - 1646 -################################################## 1647 -# $build to $host FILE NAME CONVERSION FUNCTIONS # 1648 -################################################## 1649 -# invoked via `$to_host_file_cmd ARG' 1650 -# 1651 -# In each case, ARG is the path to be converted from $build to $host format. 1652 -# Result will be available in $func_to_host_file_result. 1653 - 1654 - 1655 -# func_to_host_file ARG 1656 -# Converts the file name ARG from $build format to $host format. Return result 1657 -# in func_to_host_file_result. 1658 -func_to_host_file () 1659 -{ 1660 - $opt_debug 1661 - $to_host_file_cmd "$1" 1662 -} 1663 -# end func_to_host_file 1664 - 1665 - 1666 -# func_to_tool_file ARG LAZY 1667 -# converts the file name ARG from $build format to toolchain format. Return 1668 -# result in func_to_tool_file_result. If the conversion in use is listed 1669 -# in (the comma separated) LAZY, no conversion takes place. 1670 -func_to_tool_file () 1671 -{ 1672 - $opt_debug 1673 - case ,$2, in 1674 - *,"$to_tool_file_cmd",*) 1675 - func_to_tool_file_result=$1 1676 - ;; 1677 - *) 1678 - $to_tool_file_cmd "$1" 1679 - func_to_tool_file_result=$func_to_host_file_result 1680 - ;; 1681 - esac 1682 -} 1683 -# end func_to_tool_file 1684 - 1685 - 1686 -# func_convert_file_noop ARG 1687 -# Copy ARG to func_to_host_file_result. 1688 -func_convert_file_noop () 1689 -{ 1690 - func_to_host_file_result="$1" 1691 -} 1692 -# end func_convert_file_noop 1693 - 1694 - 1695 -# func_convert_file_msys_to_w32 ARG 1696 -# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1697 -# conversion to w32 is not available inside the cwrapper. Returns result in 1698 -# func_to_host_file_result. 1699 -func_convert_file_msys_to_w32 () 1700 -{ 1701 - $opt_debug 1702 - func_to_host_file_result="$1" 1703 - if test -n "$1"; then 1704 - func_convert_core_msys_to_w32 "$1" 1705 - func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1706 - fi 1707 - func_convert_file_check "$1" "$func_to_host_file_result" 1708 -} 1709 -# end func_convert_file_msys_to_w32 1710 - 1711 - 1712 -# func_convert_file_cygwin_to_w32 ARG 1713 -# Convert file name ARG from Cygwin to w32 format. Returns result in 1714 -# func_to_host_file_result. 1715 -func_convert_file_cygwin_to_w32 () 1716 -{ 1717 - $opt_debug 1718 - func_to_host_file_result="$1" 1719 - if test -n "$1"; then 1720 - # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1721 - # LT_CYGPATH in this case. 1722 - func_to_host_file_result=`cygpath -m "$1"` 1723 - fi 1724 - func_convert_file_check "$1" "$func_to_host_file_result" 1725 -} 1726 -# end func_convert_file_cygwin_to_w32 1727 - 1728 - 1729 -# func_convert_file_nix_to_w32 ARG 1730 -# Convert file name ARG from *nix to w32 format. Requires a wine environment 1731 -# and a working winepath. Returns result in func_to_host_file_result. 1732 -func_convert_file_nix_to_w32 () 1733 -{ 1734 - $opt_debug 1735 - func_to_host_file_result="$1" 1736 - if test -n "$1"; then 1737 - func_convert_core_file_wine_to_w32 "$1" 1738 - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1739 - fi 1740 - func_convert_file_check "$1" "$func_to_host_file_result" 1741 -} 1742 -# end func_convert_file_nix_to_w32 1743 - 1744 - 1745 -# func_convert_file_msys_to_cygwin ARG 1746 -# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1747 -# Returns result in func_to_host_file_result. 1748 -func_convert_file_msys_to_cygwin () 1749 -{ 1750 - $opt_debug 1751 - func_to_host_file_result="$1" 1752 - if test -n "$1"; then 1753 - func_convert_core_msys_to_w32 "$1" 1754 - func_cygpath -u "$func_convert_core_msys_to_w32_result" 1755 - func_to_host_file_result="$func_cygpath_result" 1756 - fi 1757 - func_convert_file_check "$1" "$func_to_host_file_result" 1758 -} 1759 -# end func_convert_file_msys_to_cygwin 1760 - 1761 - 1762 -# func_convert_file_nix_to_cygwin ARG 1763 -# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1764 -# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1765 -# in func_to_host_file_result. 1766 -func_convert_file_nix_to_cygwin () 1767 -{ 1768 - $opt_debug 1769 - func_to_host_file_result="$1" 1770 - if test -n "$1"; then 1771 - # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1772 - func_convert_core_file_wine_to_w32 "$1" 1773 - func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1774 - func_to_host_file_result="$func_cygpath_result" 1775 - fi 1776 - func_convert_file_check "$1" "$func_to_host_file_result" 1777 -} 1778 -# end func_convert_file_nix_to_cygwin 1779 - 1780 - 1781 -############################################# 1782 -# $build to $host PATH CONVERSION FUNCTIONS # 1783 -############################################# 1784 -# invoked via `$to_host_path_cmd ARG' 1785 -# 1786 -# In each case, ARG is the path to be converted from $build to $host format. 1787 -# The result will be available in $func_to_host_path_result. 1788 -# 1789 -# Path separators are also converted from $build format to $host format. If 1790 -# ARG begins or ends with a path separator character, it is preserved (but 1791 -# converted to $host format) on output. 1792 -# 1793 -# All path conversion functions are named using the following convention: 1794 -# file name conversion function : func_convert_file_X_to_Y () 1795 -# path conversion function : func_convert_path_X_to_Y () 1796 -# where, for any given $build/$host combination the 'X_to_Y' value is the 1797 -# same. If conversion functions are added for new $build/$host combinations, 1798 -# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1799 -# will break. 1800 - 1801 - 1802 -# func_init_to_host_path_cmd 1803 -# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1804 -# appropriate value, based on the value of $to_host_file_cmd. 1805 -to_host_path_cmd= 1806 -func_init_to_host_path_cmd () 1807 -{ 1808 - $opt_debug 1809 - if test -z "$to_host_path_cmd"; then 1810 - func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1811 - to_host_path_cmd="func_convert_path_${func_stripname_result}" 1812 - fi 1813 -} 1814 - 1815 - 1816 -# func_to_host_path ARG 1817 -# Converts the path ARG from $build format to $host format. Return result 1818 -# in func_to_host_path_result. 1819 -func_to_host_path () 1820 -{ 1821 - $opt_debug 1822 - func_init_to_host_path_cmd 1823 - $to_host_path_cmd "$1" 1824 -} 1825 -# end func_to_host_path 1826 - 1827 - 1828 -# func_convert_path_noop ARG 1829 -# Copy ARG to func_to_host_path_result. 1830 -func_convert_path_noop () 1831 -{ 1832 - func_to_host_path_result="$1" 1833 -} 1834 -# end func_convert_path_noop 1835 - 1836 - 1837 -# func_convert_path_msys_to_w32 ARG 1838 -# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1839 -# conversion to w32 is not available inside the cwrapper. Returns result in 1840 -# func_to_host_path_result. 1841 -func_convert_path_msys_to_w32 () 1842 -{ 1843 - $opt_debug 1844 - func_to_host_path_result="$1" 1845 - if test -n "$1"; then 1846 - # Remove leading and trailing path separator characters from ARG. MSYS 1847 - # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1848 - # and winepath ignores them completely. 1849 - func_stripname : : "$1" 1850 - func_to_host_path_tmp1=$func_stripname_result 1851 - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1852 - func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1853 - func_convert_path_check : ";" \ 1854 - "$func_to_host_path_tmp1" "$func_to_host_path_result" 1855 - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1856 - fi 1857 -} 1858 -# end func_convert_path_msys_to_w32 1859 - 1860 - 1861 -# func_convert_path_cygwin_to_w32 ARG 1862 -# Convert path ARG from Cygwin to w32 format. Returns result in 1863 -# func_to_host_file_result. 1864 -func_convert_path_cygwin_to_w32 () 1865 -{ 1866 - $opt_debug 1867 - func_to_host_path_result="$1" 1868 - if test -n "$1"; then 1869 - # See func_convert_path_msys_to_w32: 1870 - func_stripname : : "$1" 1871 - func_to_host_path_tmp1=$func_stripname_result 1872 - func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1873 - func_convert_path_check : ";" \ 1874 - "$func_to_host_path_tmp1" "$func_to_host_path_result" 1875 - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1876 - fi 1877 -} 1878 -# end func_convert_path_cygwin_to_w32 1879 - 1880 - 1881 -# func_convert_path_nix_to_w32 ARG 1882 -# Convert path ARG from *nix to w32 format. Requires a wine environment and 1883 -# a working winepath. Returns result in func_to_host_file_result. 1884 -func_convert_path_nix_to_w32 () 1885 -{ 1886 - $opt_debug 1887 - func_to_host_path_result="$1" 1888 - if test -n "$1"; then 1889 - # See func_convert_path_msys_to_w32: 1890 - func_stripname : : "$1" 1891 - func_to_host_path_tmp1=$func_stripname_result 1892 - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1893 - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1894 - func_convert_path_check : ";" \ 1895 - "$func_to_host_path_tmp1" "$func_to_host_path_result" 1896 - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1897 - fi 1898 -} 1899 -# end func_convert_path_nix_to_w32 1900 - 1901 - 1902 -# func_convert_path_msys_to_cygwin ARG 1903 -# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1904 -# Returns result in func_to_host_file_result. 1905 -func_convert_path_msys_to_cygwin () 1906 -{ 1907 - $opt_debug 1908 - func_to_host_path_result="$1" 1909 - if test -n "$1"; then 1910 - # See func_convert_path_msys_to_w32: 1911 - func_stripname : : "$1" 1912 - func_to_host_path_tmp1=$func_stripname_result 1913 - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1914 - func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1915 - func_to_host_path_result="$func_cygpath_result" 1916 - func_convert_path_check : : \ 1917 - "$func_to_host_path_tmp1" "$func_to_host_path_result" 1918 - func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1919 - fi 1920 -} 1921 -# end func_convert_path_msys_to_cygwin 1922 - 1923 - 1924 -# func_convert_path_nix_to_cygwin ARG 1925 -# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1926 -# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1927 -# func_to_host_file_result. 1928 -func_convert_path_nix_to_cygwin () 1929 -{ 1930 - $opt_debug 1931 - func_to_host_path_result="$1" 1932 - if test -n "$1"; then 1933 - # Remove leading and trailing path separator characters from 1934 - # ARG. msys behavior is inconsistent here, cygpath turns them 1935 - # into '.;' and ';.', and winepath ignores them completely. 1936 - func_stripname : : "$1" 1937 - func_to_host_path_tmp1=$func_stripname_result 1938 - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1939 - func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1940 - func_to_host_path_result="$func_cygpath_result" 1941 - func_convert_path_check : : \ 1942 - "$func_to_host_path_tmp1" "$func_to_host_path_result" 1943 - func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1944 - fi 1945 -} 1946 -# end func_convert_path_nix_to_cygwin 1947 - 1948 - 1949 -# func_mode_compile arg... 1950 -func_mode_compile () 1951 -{ 1952 - $opt_debug 1953 - # Get the compilation command and the source file. 1954 - base_compile= 1955 - srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1956 - suppress_opt=yes 1957 - suppress_output= 1958 - arg_mode=normal 1959 - libobj= 1960 - later= 1961 - pie_flag= 1962 - 1963 - for arg 1964 - do 1965 - case $arg_mode in 1966 - arg ) 1967 - # do not "continue". Instead, add this to base_compile 1968 - lastarg="$arg" 1969 - arg_mode=normal 1970 - ;; 1971 - 1972 - target ) 1973 - libobj="$arg" 1974 - arg_mode=normal 1975 - continue 1976 - ;; 1977 - 1978 - normal ) 1979 - # Accept any command-line options. 1980 - case $arg in 1981 - -o) 1982 - test -n "$libobj" && \ 1983 - func_fatal_error "you cannot specify \`-o' more than once" 1984 - arg_mode=target 1985 - continue 1986 - ;; 1987 - 1988 - -pie | -fpie | -fPIE) 1989 - func_append pie_flag " $arg" 1990 - continue 1991 - ;; 1992 - 1993 - -shared | -static | -prefer-pic | -prefer-non-pic) 1994 - func_append later " $arg" 1995 - continue 1996 - ;; 1997 - 1998 - -no-suppress) 1999 - suppress_opt=no 2000 - continue 2001 - ;; 2002 - 2003 - -Xcompiler) 2004 - arg_mode=arg # the next one goes into the "base_compile" arg list 2005 - continue # The current "srcfile" will either be retained or 2006 - ;; # replaced later. I would guess that would be a bug. 2007 - 2008 - -Wc,*) 2009 - func_stripname '-Wc,' '' "$arg" 2010 - args=$func_stripname_result 2011 - lastarg= 2012 - save_ifs="$IFS"; IFS=',' 2013 - for arg in $args; do 2014 - IFS="$save_ifs" 2015 - func_append_quoted lastarg "$arg" 2016 - done 2017 - IFS="$save_ifs" 2018 - func_stripname ' ' '' "$lastarg" 2019 - lastarg=$func_stripname_result 2020 - 2021 - # Add the arguments to base_compile. 2022 - func_append base_compile " $lastarg" 2023 - continue 2024 - ;; 2025 - 2026 - *) 2027 - # Accept the current argument as the source file. 2028 - # The previous "srcfile" becomes the current argument. 2029 - # 2030 - lastarg="$srcfile" 2031 - srcfile="$arg" 2032 - ;; 2033 - esac # case $arg 2034 - ;; 2035 - esac # case $arg_mode 2036 - 2037 - # Aesthetically quote the previous argument. 2038 - func_append_quoted base_compile "$lastarg" 2039 - done # for arg 2040 - 2041 - case $arg_mode in 2042 - arg) 2043 - func_fatal_error "you must specify an argument for -Xcompile" 2044 - ;; 2045 - target) 2046 - func_fatal_error "you must specify a target with \`-o'" 2047 - ;; 2048 - *) 2049 - # Get the name of the library object. 2050 - test -z "$libobj" && { 2051 - func_basename "$srcfile" 2052 - libobj="$func_basename_result" 2053 - } 2054 - ;; 2055 - esac 2056 - 2057 - # Recognize several different file suffixes. 2058 - # If the user specifies -o file.o, it is replaced with file.lo 2059 - case $libobj in 2060 - *.[cCFSifmso] | \ 2061 - *.ada | *.adb | *.ads | *.asm | \ 2062 - *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2063 - *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 2064 - func_xform "$libobj" 2065 - libobj=$func_xform_result 2066 - ;; 2067 - esac 2068 - 2069 - case $libobj in 2070 - *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2071 - *) 2072 - func_fatal_error "cannot determine name of library object from \`$libobj'" 2073 - ;; 2074 - esac 2075 - 2076 - func_infer_tag $base_compile 2077 - 2078 - for arg in $later; do 2079 - case $arg in 2080 - -shared) 2081 - test "$build_libtool_libs" != yes && \ 2082 - func_fatal_configuration "can not build a shared library" 2083 - build_old_libs=no 2084 - continue 2085 - ;; 2086 - 2087 - -static) 2088 - build_libtool_libs=no 2089 - build_old_libs=yes 2090 - continue 2091 - ;; 2092 - 2093 - -prefer-pic) 2094 - pic_mode=yes 2095 - continue 2096 - ;; 2097 - 2098 - -prefer-non-pic) 2099 - pic_mode=no 2100 - continue 2101 - ;; 2102 - esac 2103 - done 2104 - 2105 - func_quote_for_eval "$libobj" 2106 - test "X$libobj" != "X$func_quote_for_eval_result" \ 2107 - && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2108 - && func_warning "libobj name \`$libobj' may not contain shell special characters." 2109 - func_dirname_and_basename "$obj" "/" "" 2110 - objname="$func_basename_result" 2111 - xdir="$func_dirname_result" 2112 - lobj=${xdir}$objdir/$objname 2113 - 2114 - test -z "$base_compile" && \ 2115 - func_fatal_help "you must specify a compilation command" 2116 - 2117 - # Delete any leftover library objects. 2118 - if test "$build_old_libs" = yes; then 2119 - removelist="$obj $lobj $libobj ${libobj}T" 2120 - else 2121 - removelist="$lobj $libobj ${libobj}T" 2122 - fi 2123 - 2124 - # On Cygwin there's no "real" PIC flag so we must build both object types 2125 - case $host_os in 2126 - cygwin* | mingw* | pw32* | os2* | cegcc*) 2127 - pic_mode=default 2128 - ;; 2129 - esac 2130 - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2131 - # non-PIC code in shared libraries is not supported 2132 - pic_mode=default 2133 - fi 2134 - 2135 - # Calculate the filename of the output object if compiler does 2136 - # not support -o with -c 2137 - if test "$compiler_c_o" = no; then 2138 - output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139 - lockfile="$output_obj.lock" 2140 - else 2141 - output_obj= 2142 - need_locks=no 2143 - lockfile= 2144 - fi 2145 - 2146 - # Lock this critical section if it is needed 2147 - # We use this script file to make the link, it avoids creating a new file 2148 - if test "$need_locks" = yes; then 2149 - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2150 - func_echo "Waiting for $lockfile to be removed" 2151 - sleep 2 2152 - done 2153 - elif test "$need_locks" = warn; then 2154 - if test -f "$lockfile"; then 2155 - $ECHO "\ 2156 -*** ERROR, $lockfile exists and contains: 2157 -`cat $lockfile 2>/dev/null` 2158 - 2159 -This indicates that another process is trying to use the same 2160 -temporary object file, and libtool could not work around it because 2161 -your compiler does not support \`-c' and \`-o' together. If you 2162 -repeat this compilation, it may succeed, by chance, but you had better 2163 -avoid parallel builds (make -j) in this platform, or get a better 2164 -compiler." 2165 - 2166 - $opt_dry_run || $RM $removelist 2167 - exit $EXIT_FAILURE 2168 - fi 2169 - func_append removelist " $output_obj" 2170 - $ECHO "$srcfile" > "$lockfile" 2171 - fi 2172 - 2173 - $opt_dry_run || $RM $removelist 2174 - func_append removelist " $lockfile" 2175 - trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2176 - 2177 - func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2178 - srcfile=$func_to_tool_file_result 2179 - func_quote_for_eval "$srcfile" 2180 - qsrcfile=$func_quote_for_eval_result 2181 - 2182 - # Only build a PIC object if we are building libtool libraries. 2183 - if test "$build_libtool_libs" = yes; then 2184 - # Without this assignment, base_compile gets emptied. 2185 - fbsd_hideous_sh_bug=$base_compile 2186 - 2187 - if test "$pic_mode" != no; then 2188 - command="$base_compile $qsrcfile $pic_flag" 2189 - else 2190 - # Don't build PIC code 2191 - command="$base_compile $qsrcfile" 2192 - fi 2193 - 2194 - func_mkdir_p "$xdir$objdir" 2195 - 2196 - if test -z "$output_obj"; then 2197 - # Place PIC objects in $objdir 2198 - func_append command " -o $lobj" 2199 - fi 2200 - 2201 - func_show_eval_locale "$command" \ 2202 - 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203 - 2204 - if test "$need_locks" = warn && 2205 - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2206 - $ECHO "\ 2207 -*** ERROR, $lockfile contains: 2208 -`cat $lockfile 2>/dev/null` 2209 - 2210 -but it should contain: 2211 -$srcfile 2212 - 2213 -This indicates that another process is trying to use the same 2214 -temporary object file, and libtool could not work around it because 2215 -your compiler does not support \`-c' and \`-o' together. If you 2216 -repeat this compilation, it may succeed, by chance, but you had better 2217 -avoid parallel builds (make -j) in this platform, or get a better 2218 -compiler." 2219 - 2220 - $opt_dry_run || $RM $removelist 2221 - exit $EXIT_FAILURE 2222 - fi 2223 - 2224 - # Just move the object if needed, then go on to compile the next one 2225 - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2226 - func_show_eval '$MV "$output_obj" "$lobj"' \ 2227 - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2228 - fi 2229 - 2230 - # Allow error messages only from the first compilation. 2231 - if test "$suppress_opt" = yes; then 2232 - suppress_output=' >/dev/null 2>&1' 2233 - fi 2234 - fi 2235 - 2236 - # Only build a position-dependent object if we build old libraries. 2237 - if test "$build_old_libs" = yes; then 2238 - if test "$pic_mode" != yes; then 2239 - # Don't build PIC code 2240 - command="$base_compile $qsrcfile$pie_flag" 2241 - else 2242 - command="$base_compile $qsrcfile $pic_flag" 2243 - fi 2244 - if test "$compiler_c_o" = yes; then 2245 - func_append command " -o $obj" 2246 - fi 2247 - 2248 - # Suppress compiler output if we already did a PIC compilation. 2249 - func_append command "$suppress_output" 2250 - func_show_eval_locale "$command" \ 2251 - '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252 - 2253 - if test "$need_locks" = warn && 2254 - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2255 - $ECHO "\ 2256 -*** ERROR, $lockfile contains: 2257 -`cat $lockfile 2>/dev/null` 2258 - 2259 -but it should contain: 2260 -$srcfile 2261 - 2262 -This indicates that another process is trying to use the same 2263 -temporary object file, and libtool could not work around it because 2264 -your compiler does not support \`-c' and \`-o' together. If you 2265 -repeat this compilation, it may succeed, by chance, but you had better 2266 -avoid parallel builds (make -j) in this platform, or get a better 2267 -compiler." 2268 - 2269 - $opt_dry_run || $RM $removelist 2270 - exit $EXIT_FAILURE 2271 - fi 2272 - 2273 - # Just move the object if needed 2274 - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2275 - func_show_eval '$MV "$output_obj" "$obj"' \ 2276 - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2277 - fi 2278 - fi 2279 - 2280 - $opt_dry_run || { 2281 - func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282 - 2283 - # Unlock the critical section if it was locked 2284 - if test "$need_locks" != no; then 2285 - removelist=$lockfile 2286 - $RM "$lockfile" 2287 - fi 2288 - } 2289 - 2290 - exit $EXIT_SUCCESS 2291 -} 2292 - 2293 -$opt_help || { 2294 - test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2295 -} 2296 - 2297 -func_mode_help () 2298 -{ 2299 - # We need to display help for each of the modes. 2300 - case $opt_mode in 2301 - "") 2302 - # Generic help is extracted from the usage comments 2303 - # at the start of this file. 2304 - func_help 2305 - ;; 2306 - 2307 - clean) 2308 - $ECHO \ 2309 -"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310 - 2311 -Remove files from the build directory. 2312 - 2313 -RM is the name of the program to use to delete files associated with each FILE 2314 -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2315 -to RM. 2316 - 2317 -If FILE is a libtool library, object or program, all the files associated 2318 -with it are deleted. Otherwise, only FILE itself is deleted using RM." 2319 - ;; 2320 - 2321 - compile) 2322 - $ECHO \ 2323 -"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324 - 2325 -Compile a source file into a libtool library object. 2326 - 2327 -This mode accepts the following additional options: 2328 - 2329 - -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2330 - -no-suppress do not suppress compiler output for multiple passes 2331 - -prefer-pic try to build PIC objects only 2332 - -prefer-non-pic try to build non-PIC objects only 2333 - -shared do not build a \`.o' file suitable for static linking 2334 - -static only build a \`.o' file suitable for static linking 2335 - -Wc,FLAG pass FLAG directly to the compiler 2336 - 2337 -COMPILE-COMMAND is a command to be used in creating a \`standard' object file 2338 -from the given SOURCEFILE. 2339 - 2340 -The output file name is determined by removing the directory component from 2341 -SOURCEFILE, then substituting the C source code suffix \`.c' with the 2342 -library object suffix, \`.lo'." 2343 - ;; 2344 - 2345 - execute) 2346 - $ECHO \ 2347 -"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348 - 2349 -Automatically set library path, then run a program. 2350 - 2351 -This mode accepts the following additional options: 2352 - 2353 - -dlopen FILE add the directory containing FILE to the library path 2354 - 2355 -This mode sets the library path environment variable according to \`-dlopen' 2356 -flags. 2357 - 2358 -If any of the ARGS are libtool executable wrappers, then they are translated 2359 -into their corresponding uninstalled binary, and any of their required library 2360 -directories are added to the library path. 2361 - 2362 -Then, COMMAND is executed, with ARGS as arguments." 2363 - ;; 2364 - 2365 - finish) 2366 - $ECHO \ 2367 -"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2368 - 2369 -Complete the installation of libtool libraries. 2370 - 2371 -Each LIBDIR is a directory that contains libtool libraries. 2372 - 2373 -The commands that this mode executes may require superuser privileges. Use 2374 -the \`--dry-run' option if you just want to see what would be executed." 2375 - ;; 2376 - 2377 - install) 2378 - $ECHO \ 2379 -"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2380 - 2381 -Install executables or libraries. 2382 - 2383 -INSTALL-COMMAND is the installation command. The first component should be 2384 -either the \`install' or \`cp' program. 2385 - 2386 -The following components of INSTALL-COMMAND are treated specially: 2387 - 2388 - -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2389 - 2390 -The rest of the components are interpreted as arguments to that command (only 2391 -BSD-compatible install options are recognized)." 2392 - ;; 2393 - 2394 - link) 2395 - $ECHO \ 2396 -"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2397 - 2398 -Link object files or libraries together to form another library, or to 2399 -create an executable program. 2400 - 2401 -LINK-COMMAND is a command using the C compiler that you would use to create 2402 -a program from several object files. 2403 - 2404 -The following components of LINK-COMMAND are treated specially: 2405 - 2406 - -all-static do not do any dynamic linking at all 2407 - -avoid-version do not add a version suffix if possible 2408 - -bindir BINDIR specify path to binaries directory (for systems where 2409 - libraries must be found in the PATH setting at runtime) 2410 - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2411 - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2412 - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2413 - -export-symbols SYMFILE 2414 - try to export only the symbols listed in SYMFILE 2415 - -export-symbols-regex REGEX 2416 - try to export only the symbols matching REGEX 2417 - -LLIBDIR search LIBDIR for required installed libraries 2418 - -lNAME OUTPUT-FILE requires the installed library libNAME 2419 - -module build a library that can dlopened 2420 - -no-fast-install disable the fast-install mode 2421 - -no-install link a not-installable executable 2422 - -no-undefined declare that a library does not refer to external symbols 2423 - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2424 - -objectlist FILE Use a list of object files found in FILE to specify objects 2425 - -precious-files-regex REGEX 2426 - don't remove output files matching REGEX 2427 - -release RELEASE specify package release information 2428 - -rpath LIBDIR the created library will eventually be installed in LIBDIR 2429 - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2430 - -shared only do dynamic linking of libtool libraries 2431 - -shrext SUFFIX override the standard shared library file extension 2432 - -static do not do any dynamic linking of uninstalled libtool libraries 2433 - -static-libtool-libs 2434 - do not do any dynamic linking of libtool libraries 2435 - -version-info CURRENT[:REVISION[:AGE]] 2436 - specify library version info [each variable defaults to 0] 2437 - -weak LIBNAME declare that the target provides the LIBNAME interface 2438 - -Wc,FLAG 2439 - -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2440 - -Wl,FLAG 2441 - -Xlinker FLAG pass linker-specific FLAG directly to the linker 2442 - -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2443 - 2444 -All other options (arguments beginning with \`-') are ignored. 2445 - 2446 -Every other argument is treated as a filename. Files ending in \`.la' are 2447 -treated as uninstalled libtool libraries, other files are standard or library 2448 -object files. 2449 - 2450 -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2451 -only library objects (\`.lo' files) may be specified, and \`-rpath' is 2452 -required, except when creating a convenience library. 2453 - 2454 -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2455 -using \`ar' and \`ranlib', or on Windows using \`lib'. 2456 - 2457 -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2458 -is created, otherwise an executable program is created." 2459 - ;; 2460 - 2461 - uninstall) 2462 - $ECHO \ 2463 -"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2464 - 2465 -Remove libraries from an installation directory. 2466 - 2467 -RM is the name of the program to use to delete files associated with each FILE 2468 -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2469 -to RM. 2470 - 2471 -If FILE is a libtool library, all the files associated with it are deleted. 2472 -Otherwise, only FILE itself is deleted using RM." 2473 - ;; 2474 - 2475 - *) 2476 - func_fatal_help "invalid operation mode \`$opt_mode'" 2477 - ;; 2478 - esac 2479 - 2480 - echo 2481 - $ECHO "Try \`$progname --help' for more information about other modes." 2482 -} 2483 - 2484 -# Now that we've collected a possible --mode arg, show help if necessary 2485 -if $opt_help; then 2486 - if test "$opt_help" = :; then 2487 - func_mode_help 2488 - else 2489 - { 2490 - func_help noexit 2491 - for opt_mode in compile link execute install finish uninstall clean; do 2492 - func_mode_help 2493 - done 2494 - } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2495 - { 2496 - func_help noexit 2497 - for opt_mode in compile link execute install finish uninstall clean; do 2498 - echo 2499 - func_mode_help 2500 - done 2501 - } | 2502 - sed '1d 2503 - /^When reporting/,/^Report/{ 2504 - H 2505 - d 2506 - } 2507 - $x 2508 - /information about other modes/d 2509 - /more detailed .*MODE/d 2510 - s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2511 - fi 2512 - exit $? 2513 -fi 2514 - 2515 - 2516 -# func_mode_execute arg... 2517 -func_mode_execute () 2518 -{ 2519 - $opt_debug 2520 - # The first argument is the command name. 2521 - cmd="$nonopt" 2522 - test -z "$cmd" && \ 2523 - func_fatal_help "you must specify a COMMAND" 2524 - 2525 - # Handle -dlopen flags immediately. 2526 - for file in $opt_dlopen; do 2527 - test -f "$file" \ 2528 - || func_fatal_help "\`$file' is not a file" 2529 - 2530 - dir= 2531 - case $file in 2532 - *.la) 2533 - func_resolve_sysroot "$file" 2534 - file=$func_resolve_sysroot_result 2535 - 2536 - # Check to see that this really is a libtool archive. 2537 - func_lalib_unsafe_p "$file" \ 2538 - || func_fatal_help "\`$lib' is not a valid libtool archive" 2539 - 2540 - # Read the libtool library. 2541 - dlname= 2542 - library_names= 2543 - func_source "$file" 2544 - 2545 - # Skip this library if it cannot be dlopened. 2546 - if test -z "$dlname"; then 2547 - # Warn if it was a shared library. 2548 - test -n "$library_names" && \ 2549 - func_warning "\`$file' was not linked with \`-export-dynamic'" 2550 - continue 2551 - fi 2552 - 2553 - func_dirname "$file" "" "." 2554 - dir="$func_dirname_result" 2555 - 2556 - if test -f "$dir/$objdir/$dlname"; then 2557 - func_append dir "/$objdir" 2558 - else 2559 - if test ! -f "$dir/$dlname"; then 2560 - func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2561 - fi 2562 - fi 2563 - ;; 2564 - 2565 - *.lo) 2566 - # Just add the directory containing the .lo file. 2567 - func_dirname "$file" "" "." 2568 - dir="$func_dirname_result" 2569 - ;; 2570 - 2571 - *) 2572 - func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2573 - continue 2574 - ;; 2575 - esac 2576 - 2577 - # Get the absolute pathname. 2578 - absdir=`cd "$dir" && pwd` 2579 - test -n "$absdir" && dir="$absdir" 2580 - 2581 - # Now add the directory to shlibpath_var. 2582 - if eval "test -z \"\$$shlibpath_var\""; then 2583 - eval "$shlibpath_var=\"\$dir\"" 2584 - else 2585 - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2586 - fi 2587 - done 2588 - 2589 - # This variable tells wrapper scripts just to set shlibpath_var 2590 - # rather than running their programs. 2591 - libtool_execute_magic="$magic" 2592 - 2593 - # Check if any of the arguments is a wrapper script. 2594 - args= 2595 - for file 2596 - do 2597 - case $file in 2598 - -* | *.la | *.lo ) ;; 2599 - *) 2600 - # Do a test to see if this is really a libtool program. 2601 - if func_ltwrapper_script_p "$file"; then 2602 - func_source "$file" 2603 - # Transform arg to wrapped name. 2604 - file="$progdir/$program" 2605 - elif func_ltwrapper_executable_p "$file"; then 2606 - func_ltwrapper_scriptname "$file" 2607 - func_source "$func_ltwrapper_scriptname_result" 2608 - # Transform arg to wrapped name. 2609 - file="$progdir/$program" 2610 - fi 2611 - ;; 2612 - esac 2613 - # Quote arguments (to preserve shell metacharacters). 2614 - func_append_quoted args "$file" 2615 - done 2616 - 2617 - if test "X$opt_dry_run" = Xfalse; then 2618 - if test -n "$shlibpath_var"; then 2619 - # Export the shlibpath_var. 2620 - eval "export $shlibpath_var" 2621 - fi 2622 - 2623 - # Restore saved environment variables 2624 - for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2625 - do 2626 - eval "if test \"\${save_$lt_var+set}\" = set; then 2627 - $lt_var=\$save_$lt_var; export $lt_var 2628 - else 2629 - $lt_unset $lt_var 2630 - fi" 2631 - done 2632 - 2633 - # Now prepare to actually exec the command. 2634 - exec_cmd="\$cmd$args" 2635 - else 2636 - # Display what would be done. 2637 - if test -n "$shlibpath_var"; then 2638 - eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2639 - echo "export $shlibpath_var" 2640 - fi 2641 - $ECHO "$cmd$args" 2642 - exit $EXIT_SUCCESS 2643 - fi 2644 -} 2645 - 2646 -test "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2647 - 2648 - 2649 -# func_mode_finish arg... 2650 -func_mode_finish () 2651 -{ 2652 - $opt_debug 2653 - libs= 2654 - libdirs= 2655 - admincmds= 2656 - 2657 - for opt in "$nonopt" ${1+"$@"} 2658 - do 2659 - if test -d "$opt"; then 2660 - func_append libdirs " $opt" 2661 - 2662 - elif test -f "$opt"; then 2663 - if func_lalib_unsafe_p "$opt"; then 2664 - func_append libs " $opt" 2665 - else 2666 - func_warning "\`$opt' is not a valid libtool archive" 2667 - fi 2668 - 2669 - else 2670 - func_fatal_error "invalid argument \`$opt'" 2671 - fi 2672 - done 2673 - 2674 - if test -n "$libs"; then 2675 - if test -n "$lt_sysroot"; then 2676 - sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2677 - sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2678 - else 2679 - sysroot_cmd= 2680 - fi 2681 - 2682 - # Remove sysroot references 2683 - if $opt_dry_run; then 2684 - for lib in $libs; do 2685 - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2686 - done 2687 - else 2688 - tmpdir=`func_mktempdir` 2689 - for lib in $libs; do 2690 - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2691 - > $tmpdir/tmp-la 2692 - mv -f $tmpdir/tmp-la $lib 2693 - done 2694 - ${RM}r "$tmpdir" 2695 - fi 2696 - fi 2697 - 2698 - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2699 - for libdir in $libdirs; do 2700 - if test -n "$finish_cmds"; then 2701 - # Do each command in the finish commands. 2702 - func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2703 -'"$cmd"'"' 2704 - fi 2705 - if test -n "$finish_eval"; then 2706 - # Do the single finish_eval. 2707 - eval cmds=\"$finish_eval\" 2708 - $opt_dry_run || eval "$cmds" || func_append admincmds " 2709 - $cmds" 2710 - fi 2711 - done 2712 - fi 2713 - 2714 - # Exit here if they wanted silent mode. 2715 - $opt_silent && exit $EXIT_SUCCESS 2716 - 2717 - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2718 - echo "----------------------------------------------------------------------" 2719 - echo "Libraries have been installed in:" 2720 - for libdir in $libdirs; do 2721 - $ECHO " $libdir" 2722 - done 2723 - echo 2724 - echo "If you ever happen to want to link against installed libraries" 2725 - echo "in a given directory, LIBDIR, you must either use libtool, and" 2726 - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2727 - echo "flag during linking and do at least one of the following:" 2728 - if test -n "$shlibpath_var"; then 2729 - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2730 - echo " during execution" 2731 - fi 2732 - if test -n "$runpath_var"; then 2733 - echo " - add LIBDIR to the \`$runpath_var' environment variable" 2734 - echo " during linking" 2735 - fi 2736 - if test -n "$hardcode_libdir_flag_spec"; then 2737 - libdir=LIBDIR 2738 - eval flag=\"$hardcode_libdir_flag_spec\" 2739 - 2740 - $ECHO " - use the \`$flag' linker flag" 2741 - fi 2742 - if test -n "$admincmds"; then 2743 - $ECHO " - have your system administrator run these commands:$admincmds" 2744 - fi 2745 - if test -f /etc/ld.so.conf; then 2746 - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2747 - fi 2748 - echo 2749 - 2750 - echo "See any operating system documentation about shared libraries for" 2751 - case $host in 2752 - solaris2.[6789]|solaris2.1[0-9]) 2753 - echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2754 - echo "pages." 2755 - ;; 2756 - *) 2757 - echo "more information, such as the ld(1) and ld.so(8) manual pages." 2758 - ;; 2759 - esac 2760 - echo "----------------------------------------------------------------------" 2761 - fi 2762 - exit $EXIT_SUCCESS 2763 -} 2764 - 2765 -test "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2766 - 2767 - 2768 -# func_mode_install arg... 2769 -func_mode_install () 2770 -{ 2771 - $opt_debug 2772 - # There may be an optional sh(1) argument at the beginning of 2773 - # install_prog (especially on Windows NT). 2774 - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2775 - # Allow the use of GNU shtool's install command. 2776 - case $nonopt in *shtool*) :;; *) false;; esac; then 2777 - # Aesthetically quote it. 2778 - func_quote_for_eval "$nonopt" 2779 - install_prog="$func_quote_for_eval_result " 2780 - arg=$1 2781 - shift 2782 - else 2783 - install_prog= 2784 - arg=$nonopt 2785 - fi 2786 - 2787 - # The real first argument should be the name of the installation program. 2788 - # Aesthetically quote it. 2789 - func_quote_for_eval "$arg" 2790 - func_append install_prog "$func_quote_for_eval_result" 2791 - install_shared_prog=$install_prog 2792 - case " $install_prog " in 2793 - *[\\\ /]cp\ *) install_cp=: ;; 2794 - *) install_cp=false ;; 2795 - esac 2796 - 2797 - # We need to accept at least all the BSD install flags. 2798 - dest= 2799 - files= 2800 - opts= 2801 - prev= 2802 - install_type= 2803 - isdir=no 2804 - stripme= 2805 - no_mode=: 2806 - for arg 2807 - do 2808 - arg2= 2809 - if test -n "$dest"; then 2810 - func_append files " $dest" 2811 - dest=$arg 2812 - continue 2813 - fi 2814 - 2815 - case $arg in 2816 - -d) isdir=yes ;; 2817 - -f) 2818 - if $install_cp; then :; else 2819 - prev=$arg 2820 - fi 2821 - ;; 2822 - -g | -m | -o) 2823 - prev=$arg 2824 - ;; 2825 - -s) 2826 - stripme=" -s" 2827 - continue 2828 - ;; 2829 - -*) 2830 - ;; 2831 - *) 2832 - # If the previous option needed an argument, then skip it. 2833 - if test -n "$prev"; then 2834 - if test "x$prev" = x-m && test -n "$install_override_mode"; then 2835 - arg2=$install_override_mode 2836 - no_mode=false 2837 - fi 2838 - prev= 2839 - else 2840 - dest=$arg 2841 - continue 2842 - fi 2843 - ;; 2844 - esac 2845 - 2846 - # Aesthetically quote the argument. 2847 - func_quote_for_eval "$arg" 2848 - func_append install_prog " $func_quote_for_eval_result" 2849 - if test -n "$arg2"; then 2850 - func_quote_for_eval "$arg2" 2851 - fi 2852 - func_append install_shared_prog " $func_quote_for_eval_result" 2853 - done 2854 - 2855 - test -z "$install_prog" && \ 2856 - func_fatal_help "you must specify an install program" 2857 - 2858 - test -n "$prev" && \ 2859 - func_fatal_help "the \`$prev' option requires an argument" 2860 - 2861 - if test -n "$install_override_mode" && $no_mode; then 2862 - if $install_cp; then :; else 2863 - func_quote_for_eval "$install_override_mode" 2864 - func_append install_shared_prog " -m $func_quote_for_eval_result" 2865 - fi 2866 - fi 2867 - 2868 - if test -z "$files"; then 2869 - if test -z "$dest"; then 2870 - func_fatal_help "no file or destination specified" 2871 - else 2872 - func_fatal_help "you must specify a destination" 2873 - fi 2874 - fi 2875 - 2876 - # Strip any trailing slash from the destination. 2877 - func_stripname '' '/' "$dest" 2878 - dest=$func_stripname_result 2879 - 2880 - # Check to see that the destination is a directory. 2881 - test -d "$dest" && isdir=yes 2882 - if test "$isdir" = yes; then 2883 - destdir="$dest" 2884 - destname= 2885 - else 2886 - func_dirname_and_basename "$dest" "" "." 2887 - destdir="$func_dirname_result" 2888 - destname="$func_basename_result" 2889 - 2890 - # Not a directory, so check to see that there is only one file specified. 2891 - set dummy $files; shift 2892 - test "$#" -gt 1 && \ 2893 - func_fatal_help "\`$dest' is not a directory" 2894 - fi 2895 - case $destdir in 2896 - [\\/]* | [A-Za-z]:[\\/]*) ;; 2897 - *) 2898 - for file in $files; do 2899 - case $file in 2900 - *.lo) ;; 2901 - *) 2902 - func_fatal_help "\`$destdir' must be an absolute directory name" 2903 - ;; 2904 - esac 2905 - done 2906 - ;; 2907 - esac 2908 - 2909 - # This variable tells wrapper scripts just to set variables rather 2910 - # than running their programs. 2911 - libtool_install_magic="$magic" 2912 - 2913 - staticlibs= 2914 - future_libdirs= 2915 - current_libdirs= 2916 - for file in $files; do 2917 - 2918 - # Do each installation. 2919 - case $file in 2920 - *.$libext) 2921 - # Do the static libraries later. 2922 - func_append staticlibs " $file" 2923 - ;; 2924 - 2925 - *.la) 2926 - func_resolve_sysroot "$file" 2927 - file=$func_resolve_sysroot_result 2928 - 2929 - # Check to see that this really is a libtool archive. 2930 - func_lalib_unsafe_p "$file" \ 2931 - || func_fatal_help "\`$file' is not a valid libtool archive" 2932 - 2933 - library_names= 2934 - old_library= 2935 - relink_command= 2936 - func_source "$file" 2937 - 2938 - # Add the libdir to current_libdirs if it is the destination. 2939 - if test "X$destdir" = "X$libdir"; then 2940 - case "$current_libdirs " in 2941 - *" $libdir "*) ;; 2942 - *) func_append current_libdirs " $libdir" ;; 2943 - esac 2944 - else 2945 - # Note the libdir as a future libdir. 2946 - case "$future_libdirs " in 2947 - *" $libdir "*) ;; 2948 - *) func_append future_libdirs " $libdir" ;; 2949 - esac 2950 - fi 2951 - 2952 - func_dirname "$file" "/" "" 2953 - dir="$func_dirname_result" 2954 - func_append dir "$objdir" 2955 - 2956 - if test -n "$relink_command"; then 2957 - # Determine the prefix the user has applied to our future dir. 2958 - inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2959 - 2960 - # Don't allow the user to place us outside of our expected 2961 - # location b/c this prevents finding dependent libraries that 2962 - # are installed to the same prefix. 2963 - # At present, this check doesn't affect windows .dll's that 2964 - # are installed into $libdir/../bin (currently, that works fine) 2965 - # but it's something to keep an eye on. 2966 - test "$inst_prefix_dir" = "$destdir" && \ 2967 - func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2968 - 2969 - if test -n "$inst_prefix_dir"; then 2970 - # Stick the inst_prefix_dir data into the link command. 2971 - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2972 - else 2973 - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2974 - fi 2975 - 2976 - func_warning "relinking \`$file'" 2977 - func_show_eval "$relink_command" \ 2978 - 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2979 - fi 2980 - 2981 - # See the names of the shared library. 2982 - set dummy $library_names; shift 2983 - if test -n "$1"; then 2984 - realname="$1" 2985 - shift 2986 - 2987 - srcname="$realname" 2988 - test -n "$relink_command" && srcname="$realname"T 2989 - 2990 - # Install the shared library and build the symlinks. 2991 - func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2992 - 'exit $?' 2993 - tstripme="$stripme" 2994 - case $host_os in 2995 - cygwin* | mingw* | pw32* | cegcc*) 2996 - case $realname in 2997 - *.dll.a) 2998 - tstripme="" 2999 - ;; 3000 - esac 3001 - ;; 3002 - esac 3003 - if test -n "$tstripme" && test -n "$striplib"; then 3004 - func_show_eval "$striplib $destdir/$realname" 'exit $?' 3005 - fi 3006 - 3007 - if test "$#" -gt 0; then 3008 - # Delete the old symlinks, and create new ones. 3009 - # Try `ln -sf' first, because the `ln' binary might depend on 3010 - # the symlink we replace! Solaris /bin/ln does not understand -f, 3011 - # so we also need to try rm && ln -s. 3012 - for linkname 3013 - do 3014 - test "$linkname" != "$realname" \ 3015 - && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3016 - done 3017 - fi 3018 - 3019 - # Do each command in the postinstall commands. 3020 - lib="$destdir/$realname" 3021 - func_execute_cmds "$postinstall_cmds" 'exit $?' 3022 - fi 3023 - 3024 - # Install the pseudo-library for information purposes. 3025 - func_basename "$file" 3026 - name="$func_basename_result" 3027 - instname="$dir/$name"i 3028 - func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029 - 3030 - # Maybe install the static library, too. 3031 - test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3032 - ;; 3033 - 3034 - *.lo) 3035 - # Install (i.e. copy) a libtool object. 3036 - 3037 - # Figure out destination file name, if it wasn't already specified. 3038 - if test -n "$destname"; then 3039 - destfile="$destdir/$destname" 3040 - else 3041 - func_basename "$file" 3042 - destfile="$func_basename_result" 3043 - destfile="$destdir/$destfile" 3044 - fi 3045 - 3046 - # Deduce the name of the destination old-style object file. 3047 - case $destfile in 3048 - *.lo) 3049 - func_lo2o "$destfile" 3050 - staticdest=$func_lo2o_result 3051 - ;; 3052 - *.$objext) 3053 - staticdest="$destfile" 3054 - destfile= 3055 - ;; 3056 - *) 3057 - func_fatal_help "cannot copy a libtool object to \`$destfile'" 3058 - ;; 3059 - esac 3060 - 3061 - # Install the libtool object if requested. 3062 - test -n "$destfile" && \ 3063 - func_show_eval "$install_prog $file $destfile" 'exit $?' 3064 - 3065 - # Install the old object if enabled. 3066 - if test "$build_old_libs" = yes; then 3067 - # Deduce the name of the old-style object file. 3068 - func_lo2o "$file" 3069 - staticobj=$func_lo2o_result 3070 - func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3071 - fi 3072 - exit $EXIT_SUCCESS 3073 - ;; 3074 - 3075 - *) 3076 - # Figure out destination file name, if it wasn't already specified. 3077 - if test -n "$destname"; then 3078 - destfile="$destdir/$destname" 3079 - else 3080 - func_basename "$file" 3081 - destfile="$func_basename_result" 3082 - destfile="$destdir/$destfile" 3083 - fi 3084 - 3085 - # If the file is missing, and there is a .exe on the end, strip it 3086 - # because it is most likely a libtool script we actually want to 3087 - # install 3088 - stripped_ext="" 3089 - case $file in 3090 - *.exe) 3091 - if test ! -f "$file"; then 3092 - func_stripname '' '.exe' "$file" 3093 - file=$func_stripname_result 3094 - stripped_ext=".exe" 3095 - fi 3096 - ;; 3097 - esac 3098 - 3099 - # Do a test to see if this is really a libtool program. 3100 - case $host in 3101 - *cygwin* | *mingw*) 3102 - if func_ltwrapper_executable_p "$file"; then 3103 - func_ltwrapper_scriptname "$file" 3104 - wrapper=$func_ltwrapper_scriptname_result 3105 - else 3106 - func_stripname '' '.exe' "$file" 3107 - wrapper=$func_stripname_result 3108 - fi 3109 - ;; 3110 - *) 3111 - wrapper=$file 3112 - ;; 3113 - esac 3114 - if func_ltwrapper_script_p "$wrapper"; then 3115 - notinst_deplibs= 3116 - relink_command= 3117 - 3118 - func_source "$wrapper" 3119 - 3120 - # Check the variables that should have been set. 3121 - test -z "$generated_by_libtool_version" && \ 3122 - func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3123 - 3124 - finalize=yes 3125 - for lib in $notinst_deplibs; do 3126 - # Check to see that each library is installed. 3127 - libdir= 3128 - if test -f "$lib"; then 3129 - func_source "$lib" 3130 - fi 3131 - libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3132 - if test -n "$libdir" && test ! -f "$libfile"; then 3133 - func_warning "\`$lib' has not been installed in \`$libdir'" 3134 - finalize=no 3135 - fi 3136 - done 3137 - 3138 - relink_command= 3139 - func_source "$wrapper" 3140 - 3141 - outputname= 3142 - if test "$fast_install" = no && test -n "$relink_command"; then 3143 - $opt_dry_run || { 3144 - if test "$finalize" = yes; then 3145 - tmpdir=`func_mktempdir` 3146 - func_basename "$file$stripped_ext" 3147 - file="$func_basename_result" 3148 - outputname="$tmpdir/$file" 3149 - # Replace the output file specification. 3150 - relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3151 - 3152 - $opt_silent || { 3153 - func_quote_for_expand "$relink_command" 3154 - eval "func_echo $func_quote_for_expand_result" 3155 - } 3156 - if eval "$relink_command"; then : 3157 - else 3158 - func_error "error: relink \`$file' with the above command before installing it" 3159 - $opt_dry_run || ${RM}r "$tmpdir" 3160 - continue 3161 - fi 3162 - file="$outputname" 3163 - else 3164 - func_warning "cannot relink \`$file'" 3165 - fi 3166 - } 3167 - else 3168 - # Install the binary that we compiled earlier. 3169 - file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3170 - fi 3171 - fi 3172 - 3173 - # remove .exe since cygwin /usr/bin/install will append another 3174 - # one anyway 3175 - case $install_prog,$host in 3176 - */usr/bin/install*,*cygwin*) 3177 - case $file:$destfile in 3178 - *.exe:*.exe) 3179 - # this is ok 3180 - ;; 3181 - *.exe:*) 3182 - destfile=$destfile.exe 3183 - ;; 3184 - *:*.exe) 3185 - func_stripname '' '.exe' "$destfile" 3186 - destfile=$func_stripname_result 3187 - ;; 3188 - esac 3189 - ;; 3190 - esac 3191 - func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3192 - $opt_dry_run || if test -n "$outputname"; then 3193 - ${RM}r "$tmpdir" 3194 - fi 3195 - ;; 3196 - esac 3197 - done 3198 - 3199 - for file in $staticlibs; do 3200 - func_basename "$file" 3201 - name="$func_basename_result" 3202 - 3203 - # Set up the ranlib parameters. 3204 - oldlib="$destdir/$name" 3205 - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 3206 - tool_oldlib=$func_to_tool_file_result 3207 - 3208 - func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3209 - 3210 - if test -n "$stripme" && test -n "$old_striplib"; then 3211 - func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3212 - fi 3213 - 3214 - # Do each command in the postinstall commands. 3215 - func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3216 - done 3217 - 3218 - test -n "$future_libdirs" && \ 3219 - func_warning "remember to run \`$progname --finish$future_libdirs'" 3220 - 3221 - if test -n "$current_libdirs"; then 3222 - # Maybe just do a dry run. 3223 - $opt_dry_run && current_libdirs=" -n$current_libdirs" 3224 - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3225 - else 3226 - exit $EXIT_SUCCESS 3227 - fi 3228 -} 3229 - 3230 -test "$opt_mode" = install && func_mode_install ${1+"$@"} 3231 - 3232 - 3233 -# func_generate_dlsyms outputname originator pic_p 3234 -# Extract symbols from dlprefiles and create ${outputname}S.o with 3235 -# a dlpreopen symbol table. 3236 -func_generate_dlsyms () 3237 -{ 3238 - $opt_debug 3239 - my_outputname="$1" 3240 - my_originator="$2" 3241 - my_pic_p="${3-no}" 3242 - my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3243 - my_dlsyms= 3244 - 3245 - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3246 - if test -n "$NM" && test -n "$global_symbol_pipe"; then 3247 - my_dlsyms="${my_outputname}S.c" 3248 - else 3249 - func_error "not configured to extract global symbols from dlpreopened files" 3250 - fi 3251 - fi 3252 - 3253 - if test -n "$my_dlsyms"; then 3254 - case $my_dlsyms in 3255 - "") ;; 3256 - *.c) 3257 - # Discover the nlist of each of the dlfiles. 3258 - nlist="$output_objdir/${my_outputname}.nm" 3259 - 3260 - func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3261 - 3262 - # Parse the name list into a source file. 3263 - func_verbose "creating $output_objdir/$my_dlsyms" 3264 - 3265 - $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3266 -/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3267 -/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3268 - 3269 -#ifdef __cplusplus 3270 -extern \"C\" { 3271 -#endif 3272 - 3273 -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3274 -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3275 -#endif 3276 - 3277 -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3278 -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3279 -/* DATA imports from DLLs on WIN32 con't be const, because runtime 3280 - relocations are performed -- see ld's documentation on pseudo-relocs. */ 3281 -# define LT_DLSYM_CONST 3282 -#elif defined(__osf__) 3283 -/* This system does not cope well with relocations in const data. */ 3284 -# define LT_DLSYM_CONST 3285 -#else 3286 -# define LT_DLSYM_CONST const 3287 -#endif 3288 - 3289 -/* External symbol declarations for the compiler. */\ 3290 -" 3291 - 3292 - if test "$dlself" = yes; then 3293 - func_verbose "generating symbol list for \`$output'" 3294 - 3295 - $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3296 - 3297 - # Add our own program objects to the symbol list. 3298 - progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3299 - for progfile in $progfiles; do 3300 - func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3301 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3302 - $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3303 - done 3304 - 3305 - if test -n "$exclude_expsyms"; then 3306 - $opt_dry_run || { 3307 - eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3308 - eval '$MV "$nlist"T "$nlist"' 3309 - } 3310 - fi 3311 - 3312 - if test -n "$export_symbols_regex"; then 3313 - $opt_dry_run || { 3314 - eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3315 - eval '$MV "$nlist"T "$nlist"' 3316 - } 3317 - fi 3318 - 3319 - # Prepare the list of exported symbols 3320 - if test -z "$export_symbols"; then 3321 - export_symbols="$output_objdir/$outputname.exp" 3322 - $opt_dry_run || { 3323 - $RM $export_symbols 3324 - eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3325 - case $host in 3326 - *cygwin* | *mingw* | *cegcc* ) 3327 - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3328 - eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3329 - ;; 3330 - esac 3331 - } 3332 - else 3333 - $opt_dry_run || { 3334 - eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3335 - eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3336 - eval '$MV "$nlist"T "$nlist"' 3337 - case $host in 3338 - *cygwin* | *mingw* | *cegcc* ) 3339 - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3340 - eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3341 - ;; 3342 - esac 3343 - } 3344 - fi 3345 - fi 3346 - 3347 - for dlprefile in $dlprefiles; do 3348 - func_verbose "extracting global C symbols from \`$dlprefile'" 3349 - func_basename "$dlprefile" 3350 - name="$func_basename_result" 3351 - case $host in 3352 - *cygwin* | *mingw* | *cegcc* ) 3353 - # if an import library, we need to obtain dlname 3354 - if func_win32_import_lib_p "$dlprefile"; then 3355 - func_tr_sh "$dlprefile" 3356 - eval "curr_lafile=\$libfile_$func_tr_sh_result" 3357 - dlprefile_dlbasename="" 3358 - if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3359 - # Use subshell, to avoid clobbering current variable values 3360 - dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3361 - if test -n "$dlprefile_dlname" ; then 3362 - func_basename "$dlprefile_dlname" 3363 - dlprefile_dlbasename="$func_basename_result" 3364 - else 3365 - # no lafile. user explicitly requested -dlpreopen <import library>. 3366 - $sharedlib_from_linklib_cmd "$dlprefile" 3367 - dlprefile_dlbasename=$sharedlib_from_linklib_result 3368 - fi 3369 - fi 3370 - $opt_dry_run || { 3371 - if test -n "$dlprefile_dlbasename" ; then 3372 - eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3373 - else 3374 - func_warning "Could not compute DLL name from $name" 3375 - eval '$ECHO ": $name " >> "$nlist"' 3376 - fi 3377 - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3378 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3379 - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3380 - } 3381 - else # not an import lib 3382 - $opt_dry_run || { 3383 - eval '$ECHO ": $name " >> "$nlist"' 3384 - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3385 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3386 - } 3387 - fi 3388 - ;; 3389 - *) 3390 - $opt_dry_run || { 3391 - eval '$ECHO ": $name " >> "$nlist"' 3392 - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3393 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3394 - } 3395 - ;; 3396 - esac 3397 - done 3398 - 3399 - $opt_dry_run || { 3400 - # Make sure we have at least an empty file. 3401 - test -f "$nlist" || : > "$nlist" 3402 - 3403 - if test -n "$exclude_expsyms"; then 3404 - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3405 - $MV "$nlist"T "$nlist" 3406 - fi 3407 - 3408 - # Try sorting and uniquifying the output. 3409 - if $GREP -v "^: " < "$nlist" | 3410 - if sort -k 3 </dev/null >/dev/null 2>&1; then 3411 - sort -k 3 3412 - else 3413 - sort +2 3414 - fi | 3415 - uniq > "$nlist"S; then 3416 - : 3417 - else 3418 - $GREP -v "^: " < "$nlist" > "$nlist"S 3419 - fi 3420 - 3421 - if test -f "$nlist"S; then 3422 - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3423 - else 3424 - echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3425 - fi 3426 - 3427 - echo >> "$output_objdir/$my_dlsyms" "\ 3428 - 3429 -/* The mapping between symbol names and symbols. */ 3430 -typedef struct { 3431 - const char *name; 3432 - void *address; 3433 -} lt_dlsymlist; 3434 -extern LT_DLSYM_CONST lt_dlsymlist 3435 -lt_${my_prefix}_LTX_preloaded_symbols[]; 3436 -LT_DLSYM_CONST lt_dlsymlist 3437 -lt_${my_prefix}_LTX_preloaded_symbols[] = 3438 -{\ 3439 - { \"$my_originator\", (void *) 0 }," 3440 - 3441 - case $need_lib_prefix in 3442 - no) 3443 - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444 - ;; 3445 - *) 3446 - eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3447 - ;; 3448 - esac 3449 - echo >> "$output_objdir/$my_dlsyms" "\ 3450 - {0, (void *) 0} 3451 -}; 3452 - 3453 -/* This works around a problem in FreeBSD linker */ 3454 -#ifdef FREEBSD_WORKAROUND 3455 -static const void *lt_preloaded_setup() { 3456 - return lt_${my_prefix}_LTX_preloaded_symbols; 3457 -} 3458 -#endif 3459 - 3460 -#ifdef __cplusplus 3461 -} 3462 -#endif\ 3463 -" 3464 - } # !$opt_dry_run 3465 - 3466 - pic_flag_for_symtable= 3467 - case "$compile_command " in 3468 - *" -static "*) ;; 3469 - *) 3470 - case $host in 3471 - # compiling the symbol table file with pic_flag works around 3472 - # a FreeBSD bug that causes programs to crash when -lm is 3473 - # linked before any other PIC object. But we must not use 3474 - # pic_flag when linking with -static. The problem exists in 3475 - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3476 - *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3477 - pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3478 - *-*-hpux*) 3479 - pic_flag_for_symtable=" $pic_flag" ;; 3480 - *) 3481 - if test "X$my_pic_p" != Xno; then 3482 - pic_flag_for_symtable=" $pic_flag" 3483 - fi 3484 - ;; 3485 - esac 3486 - ;; 3487 - esac 3488 - symtab_cflags= 3489 - for arg in $LTCFLAGS; do 3490 - case $arg in 3491 - -pie | -fpie | -fPIE) ;; 3492 - *) func_append symtab_cflags " $arg" ;; 3493 - esac 3494 - done 3495 - 3496 - # Now compile the dynamic symbol file. 3497 - func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498 - 3499 - # Clean up the generated files. 3500 - func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3501 - 3502 - # Transform the symbol file into the correct name. 3503 - symfileobj="$output_objdir/${my_outputname}S.$objext" 3504 - case $host in 3505 - *cygwin* | *mingw* | *cegcc* ) 3506 - if test -f "$output_objdir/$my_outputname.def"; then 3507 - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3508 - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3509 - else 3510 - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3511 - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3512 - fi 3513 - ;; 3514 - *) 3515 - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3516 - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3517 - ;; 3518 - esac 3519 - ;; 3520 - *) 3521 - func_fatal_error "unknown suffix for \`$my_dlsyms'" 3522 - ;; 3523 - esac 3524 - else 3525 - # We keep going just in case the user didn't refer to 3526 - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3527 - # really was required. 3528 - 3529 - # Nullify the symbol file. 3530 - compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3531 - finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3532 - fi 3533 -} 3534 - 3535 -# func_win32_libid arg 3536 -# return the library type of file 'arg' 3537 -# 3538 -# Need a lot of goo to handle *both* DLLs and import libs 3539 -# Has to be a shell function in order to 'eat' the argument 3540 -# that is supplied when $file_magic_command is called. 3541 -# Despite the name, also deal with 64 bit binaries. 3542 -func_win32_libid () 3543 -{ 3544 - $opt_debug 3545 - win32_libid_type="unknown" 3546 - win32_fileres=`file -L $1 2>/dev/null` 3547 - case $win32_fileres in 3548 - *ar\ archive\ import\ library*) # definitely import 3549 - win32_libid_type="x86 archive import" 3550 - ;; 3551 - *ar\ archive*) # could be an import, or static 3552 - # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3553 - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3554 - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3555 - func_to_tool_file "$1" func_convert_file_msys_to_w32 3556 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3557 - $SED -n -e ' 3558 - 1,100{ 3559 - / I /{ 3560 - s,.*,import, 3561 - p 3562 - q 3563 - } 3564 - }'` 3565 - case $win32_nmres in 3566 - import*) win32_libid_type="x86 archive import";; 3567 - *) win32_libid_type="x86 archive static";; 3568 - esac 3569 - fi 3570 - ;; 3571 - *DLL*) 3572 - win32_libid_type="x86 DLL" 3573 - ;; 3574 - *executable*) # but shell scripts are "executable" too... 3575 - case $win32_fileres in 3576 - *MS\ Windows\ PE\ Intel*) 3577 - win32_libid_type="x86 DLL" 3578 - ;; 3579 - esac 3580 - ;; 3581 - esac 3582 - $ECHO "$win32_libid_type" 3583 -} 3584 - 3585 -# func_cygming_dll_for_implib ARG 3586 -# 3587 -# Platform-specific function to extract the 3588 -# name of the DLL associated with the specified 3589 -# import library ARG. 3590 -# Invoked by eval'ing the libtool variable 3591 -# $sharedlib_from_linklib_cmd 3592 -# Result is available in the variable 3593 -# $sharedlib_from_linklib_result 3594 -func_cygming_dll_for_implib () 3595 -{ 3596 - $opt_debug 3597 - sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3598 -} 3599 - 3600 -# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3601 -# 3602 -# The is the core of a fallback implementation of a 3603 -# platform-specific function to extract the name of the 3604 -# DLL associated with the specified import library LIBNAME. 3605 -# 3606 -# SECTION_NAME is either .idata$6 or .idata$7, depending 3607 -# on the platform and compiler that created the implib. 3608 -# 3609 -# Echos the name of the DLL associated with the 3610 -# specified import library. 3611 -func_cygming_dll_for_implib_fallback_core () 3612 -{ 3613 - $opt_debug 3614 - match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3615 - $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3616 - $SED '/^Contents of section '"$match_literal"':/{ 3617 - # Place marker at beginning of archive member dllname section 3618 - s/.*/====MARK====/ 3619 - p 3620 - d 3621 - } 3622 - # These lines can sometimes be longer than 43 characters, but 3623 - # are always uninteresting 3624 - /:[ ]*file format pe[i]\{,1\}-/d 3625 - /^In archive [^:]*:/d 3626 - # Ensure marker is printed 3627 - /^====MARK====/p 3628 - # Remove all lines with less than 43 characters 3629 - /^.\{43\}/!d 3630 - # From remaining lines, remove first 43 characters 3631 - s/^.\{43\}//' | 3632 - $SED -n ' 3633 - # Join marker and all lines until next marker into a single line 3634 - /^====MARK====/ b para 3635 - H 3636 - $ b para 3637 - b 3638 - :para 3639 - x 3640 - s/\n//g 3641 - # Remove the marker 3642 - s/^====MARK====// 3643 - # Remove trailing dots and whitespace 3644 - s/[\. \t]*$// 3645 - # Print 3646 - /./p' | 3647 - # we now have a list, one entry per line, of the stringified 3648 - # contents of the appropriate section of all members of the 3649 - # archive which possess that section. Heuristic: eliminate 3650 - # all those which have a first or second character that is 3651 - # a '.' (that is, objdump's representation of an unprintable 3652 - # character.) This should work for all archives with less than 3653 - # 0x302f exports -- but will fail for DLLs whose name actually 3654 - # begins with a literal '.' or a single character followed by 3655 - # a '.'. 3656 - # 3657 - # Of those that remain, print the first one. 3658 - $SED -e '/^\./d;/^.\./d;q' 3659 -} 3660 - 3661 -# func_cygming_gnu_implib_p ARG 3662 -# This predicate returns with zero status (TRUE) if 3663 -# ARG is a GNU/binutils-style import library. Returns 3664 -# with nonzero status (FALSE) otherwise. 3665 -func_cygming_gnu_implib_p () 3666 -{ 3667 - $opt_debug 3668 - func_to_tool_file "$1" func_convert_file_msys_to_w32 3669 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` 3670 - test -n "$func_cygming_gnu_implib_tmp" 3671 -} 3672 - 3673 -# func_cygming_ms_implib_p ARG 3674 -# This predicate returns with zero status (TRUE) if 3675 -# ARG is an MS-style import library. Returns 3676 -# with nonzero status (FALSE) otherwise. 3677 -func_cygming_ms_implib_p () 3678 -{ 3679 - $opt_debug 3680 - func_to_tool_file "$1" func_convert_file_msys_to_w32 3681 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3682 - test -n "$func_cygming_ms_implib_tmp" 3683 -} 3684 - 3685 -# func_cygming_dll_for_implib_fallback ARG 3686 -# Platform-specific function to extract the 3687 -# name of the DLL associated with the specified 3688 -# import library ARG. 3689 -# 3690 -# This fallback implementation is for use when $DLLTOOL 3691 -# does not support the --identify-strict option. 3692 -# Invoked by eval'ing the libtool variable 3693 -# $sharedlib_from_linklib_cmd 3694 -# Result is available in the variable 3695 -# $sharedlib_from_linklib_result 3696 -func_cygming_dll_for_implib_fallback () 3697 -{ 3698 - $opt_debug 3699 - if func_cygming_gnu_implib_p "$1" ; then 3700 - # binutils import library 3701 - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3702 - elif func_cygming_ms_implib_p "$1" ; then 3703 - # ms-generated import library 3704 - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3705 - else 3706 - # unknown 3707 - sharedlib_from_linklib_result="" 3708 - fi 3709 -} 3710 - 3711 - 3712 -# func_extract_an_archive dir oldlib 3713 -func_extract_an_archive () 3714 -{ 3715 - $opt_debug 3716 - f_ex_an_ar_dir="$1"; shift 3717 - f_ex_an_ar_oldlib="$1" 3718 - if test "$lock_old_archive_extraction" = yes; then 3719 - lockfile=$f_ex_an_ar_oldlib.lock 3720 - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3721 - func_echo "Waiting for $lockfile to be removed" 3722 - sleep 2 3723 - done 3724 - fi 3725 - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3726 - 'stat=$?; rm -f "$lockfile"; exit $stat' 3727 - if test "$lock_old_archive_extraction" = yes; then 3728 - $opt_dry_run || rm -f "$lockfile" 3729 - fi 3730 - if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3731 - : 3732 - else 3733 - func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3734 - fi 3735 -} 3736 - 3737 - 3738 -# func_extract_archives gentop oldlib ... 3739 -func_extract_archives () 3740 -{ 3741 - $opt_debug 3742 - my_gentop="$1"; shift 3743 - my_oldlibs=${1+"$@"} 3744 - my_oldobjs="" 3745 - my_xlib="" 3746 - my_xabs="" 3747 - my_xdir="" 3748 - 3749 - for my_xlib in $my_oldlibs; do 3750 - # Extract the objects. 3751 - case $my_xlib in 3752 - [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3753 - *) my_xabs=`pwd`"/$my_xlib" ;; 3754 - esac 3755 - func_basename "$my_xlib" 3756 - my_xlib="$func_basename_result" 3757 - my_xlib_u=$my_xlib 3758 - while :; do 3759 - case " $extracted_archives " in 3760 - *" $my_xlib_u "*) 3761 - func_arith $extracted_serial + 1 3762 - extracted_serial=$func_arith_result 3763 - my_xlib_u=lt$extracted_serial-$my_xlib ;; 3764 - *) break ;; 3765 - esac 3766 - done 3767 - extracted_archives="$extracted_archives $my_xlib_u" 3768 - my_xdir="$my_gentop/$my_xlib_u" 3769 - 3770 - func_mkdir_p "$my_xdir" 3771 - 3772 - case $host in 3773 - *-darwin*) 3774 - func_verbose "Extracting $my_xabs" 3775 - # Do not bother doing anything if just a dry run 3776 - $opt_dry_run || { 3777 - darwin_orig_dir=`pwd` 3778 - cd $my_xdir || exit $? 3779 - darwin_archive=$my_xabs 3780 - darwin_curdir=`pwd` 3781 - darwin_base_archive=`basename "$darwin_archive"` 3782 - darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3783 - if test -n "$darwin_arches"; then 3784 - darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3785 - darwin_arch= 3786 - func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3787 - for darwin_arch in $darwin_arches ; do 3788 - func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3789 - $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3790 - cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3791 - func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3792 - cd "$darwin_curdir" 3793 - $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3794 - done # $darwin_arches 3795 - ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3796 - darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3797 - darwin_file= 3798 - darwin_files= 3799 - for darwin_file in $darwin_filelist; do 3800 - darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3801 - $LIPO -create -output "$darwin_file" $darwin_files 3802 - done # $darwin_filelist 3803 - $RM -rf unfat-$$ 3804 - cd "$darwin_orig_dir" 3805 - else 3806 - cd $darwin_orig_dir 3807 - func_extract_an_archive "$my_xdir" "$my_xabs" 3808 - fi # $darwin_arches 3809 - } # !$opt_dry_run 3810 - ;; 3811 - *) 3812 - func_extract_an_archive "$my_xdir" "$my_xabs" 3813 - ;; 3814 - esac 3815 - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3816 - done 3817 - 3818 - func_extract_archives_result="$my_oldobjs" 3819 -} 3820 - 3821 - 3822 -# func_emit_wrapper [arg=no] 3823 -# 3824 -# Emit a libtool wrapper script on stdout. 3825 -# Don't directly open a file because we may want to 3826 -# incorporate the script contents within a cygwin/mingw 3827 -# wrapper executable. Must ONLY be called from within 3828 -# func_mode_link because it depends on a number of variables 3829 -# set therein. 3830 -# 3831 -# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3832 -# variable will take. If 'yes', then the emitted script 3833 -# will assume that the directory in which it is stored is 3834 -# the $objdir directory. This is a cygwin/mingw-specific 3835 -# behavior. 3836 -func_emit_wrapper () 3837 -{ 3838 - func_emit_wrapper_arg1=${1-no} 3839 - 3840 - $ECHO "\ 3841 -#! $SHELL 3842 - 3843 -# $output - temporary wrapper script for $objdir/$outputname 3844 -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3845 -# 3846 -# The $output program cannot be directly executed until all the libtool 3847 -# libraries that it depends on are installed. 3848 -# 3849 -# This wrapper script should never be moved out of the build directory. 3850 -# If it is, it will not operate correctly. 3851 - 3852 -# Sed substitution that helps us do robust quoting. It backslashifies 3853 -# metacharacters that are still active within double-quoted strings. 3854 -sed_quote_subst='$sed_quote_subst' 3855 - 3856 -# Be Bourne compatible 3857 -if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3858 - emulate sh 3859 - NULLCMD=: 3860 - # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3861 - # is contrary to our usage. Disable this feature. 3862 - alias -g '\${1+\"\$@\"}'='\"\$@\"' 3863 - setopt NO_GLOB_SUBST 3864 -else 3865 - case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3866 -fi 3867 -BIN_SH=xpg4; export BIN_SH # for Tru64 3868 -DUALCASE=1; export DUALCASE # for MKS sh 3869 - 3870 -# The HP-UX ksh and POSIX shell print the target directory to stdout 3871 -# if CDPATH is set. 3872 -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873 - 3874 -relink_command=\"$relink_command\" 3875 - 3876 -# This environment variable determines our operation mode. 3877 -if test \"\$libtool_install_magic\" = \"$magic\"; then 3878 - # install mode needs the following variables: 3879 - generated_by_libtool_version='$macro_version' 3880 - notinst_deplibs='$notinst_deplibs' 3881 -else 3882 - # When we are sourced in execute mode, \$file and \$ECHO are already set. 3883 - if test \"\$libtool_execute_magic\" != \"$magic\"; then 3884 - file=\"\$0\"" 3885 - 3886 - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3887 - $ECHO "\ 3888 - 3889 -# A function that is used when there is no print builtin or printf. 3890 -func_fallback_echo () 3891 -{ 3892 - eval 'cat <<_LTECHO_EOF 3893 -\$1 3894 -_LTECHO_EOF' 3895 -} 3896 - ECHO=\"$qECHO\" 3897 - fi 3898 - 3899 -# Very basic option parsing. These options are (a) specific to 3900 -# the libtool wrapper, (b) are identical between the wrapper 3901 -# /script/ and the wrapper /executable/ which is used only on 3902 -# windows platforms, and (c) all begin with the string "--lt-" 3903 -# (application programs are unlikely to have options which match 3904 -# this pattern). 3905 -# 3906 -# There are only two supported options: --lt-debug and 3907 -# --lt-dump-script. There is, deliberately, no --lt-help. 3908 -# 3909 -# The first argument to this parsing function should be the 3910 -# script's $0 value, followed by "$@". 3911 -lt_option_debug= 3912 -func_parse_lt_options () 3913 -{ 3914 - lt_script_arg0=\$0 3915 - shift 3916 - for lt_opt 3917 - do 3918 - case \"\$lt_opt\" in 3919 - --lt-debug) lt_option_debug=1 ;; 3920 - --lt-dump-script) 3921 - lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3922 - test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3923 - lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3924 - cat \"\$lt_dump_D/\$lt_dump_F\" 3925 - exit 0 3926 - ;; 3927 - --lt-*) 3928 - \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3929 - exit 1 3930 - ;; 3931 - esac 3932 - done 3933 - 3934 - # Print the debug banner immediately: 3935 - if test -n \"\$lt_option_debug\"; then 3936 - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3937 - fi 3938 -} 3939 - 3940 -# Used when --lt-debug. Prints its arguments to stdout 3941 -# (redirection is the responsibility of the caller) 3942 -func_lt_dump_args () 3943 -{ 3944 - lt_dump_args_N=1; 3945 - for lt_arg 3946 - do 3947 - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3948 - lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3949 - done 3950 -} 3951 - 3952 -# Core function for launching the target application 3953 -func_exec_program_core () 3954 -{ 3955 -" 3956 - case $host in 3957 - # Backslashes separate directories on plain windows 3958 - *-*-mingw | *-*-os2* | *-cegcc*) 3959 - $ECHO "\ 3960 - if test -n \"\$lt_option_debug\"; then 3961 - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3962 - func_lt_dump_args \${1+\"\$@\"} 1>&2 3963 - fi 3964 - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3965 -" 3966 - ;; 3967 - 3968 - *) 3969 - $ECHO "\ 3970 - if test -n \"\$lt_option_debug\"; then 3971 - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3972 - func_lt_dump_args \${1+\"\$@\"} 1>&2 3973 - fi 3974 - exec \"\$progdir/\$program\" \${1+\"\$@\"} 3975 -" 3976 - ;; 3977 - esac 3978 - $ECHO "\ 3979 - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3980 - exit 1 3981 -} 3982 - 3983 -# A function to encapsulate launching the target application 3984 -# Strips options in the --lt-* namespace from \$@ and 3985 -# launches target application with the remaining arguments. 3986 -func_exec_program () 3987 -{ 3988 - case \" \$* \" in 3989 - *\\ --lt-*) 3990 - for lt_wr_arg 3991 - do 3992 - case \$lt_wr_arg in 3993 - --lt-*) ;; 3994 - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3995 - esac 3996 - shift 3997 - done ;; 3998 - esac 3999 - func_exec_program_core \${1+\"\$@\"} 4000 -} 4001 - 4002 - # Parse options 4003 - func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004 - 4005 - # Find the directory that this script lives in. 4006 - thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4007 - test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008 - 4009 - # Follow symbolic links until we get to the real thisdir. 4010 - file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4011 - while test -n \"\$file\"; do 4012 - destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4013 - 4014 - # If there was a directory component, then change thisdir. 4015 - if test \"x\$destdir\" != \"x\$file\"; then 4016 - case \"\$destdir\" in 4017 - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4018 - *) thisdir=\"\$thisdir/\$destdir\" ;; 4019 - esac 4020 - fi 4021 - 4022 - file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4023 - file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4024 - done 4025 - 4026 - # Usually 'no', except on cygwin/mingw when embedded into 4027 - # the cwrapper. 4028 - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4029 - if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4030 - # special case for '.' 4031 - if test \"\$thisdir\" = \".\"; then 4032 - thisdir=\`pwd\` 4033 - fi 4034 - # remove .libs from thisdir 4035 - case \"\$thisdir\" in 4036 - *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4037 - $objdir ) thisdir=. ;; 4038 - esac 4039 - fi 4040 - 4041 - # Try to get the absolute directory name. 4042 - absdir=\`cd \"\$thisdir\" && pwd\` 4043 - test -n \"\$absdir\" && thisdir=\"\$absdir\" 4044 -" 4045 - 4046 - if test "$fast_install" = yes; then 4047 - $ECHO "\ 4048 - program=lt-'$outputname'$exeext 4049 - progdir=\"\$thisdir/$objdir\" 4050 - 4051 - if test ! -f \"\$progdir/\$program\" || 4052 - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4053 - test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4054 - 4055 - file=\"\$\$-\$program\" 4056 - 4057 - if test ! -d \"\$progdir\"; then 4058 - $MKDIR \"\$progdir\" 4059 - else 4060 - $RM \"\$progdir/\$file\" 4061 - fi" 4062 - 4063 - $ECHO "\ 4064 - 4065 - # relink executable if necessary 4066 - if test -n \"\$relink_command\"; then 4067 - if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4068 - else 4069 - $ECHO \"\$relink_command_output\" >&2 4070 - $RM \"\$progdir/\$file\" 4071 - exit 1 4072 - fi 4073 - fi 4074 - 4075 - $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4076 - { $RM \"\$progdir/\$program\"; 4077 - $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4078 - $RM \"\$progdir/\$file\" 4079 - fi" 4080 - else 4081 - $ECHO "\ 4082 - program='$outputname' 4083 - progdir=\"\$thisdir/$objdir\" 4084 -" 4085 - fi 4086 - 4087 - $ECHO "\ 4088 - 4089 - if test -f \"\$progdir/\$program\"; then" 4090 - 4091 - # fixup the dll searchpath if we need to. 4092 - # 4093 - # Fix the DLL searchpath if we need to. Do this before prepending 4094 - # to shlibpath, because on Windows, both are PATH and uninstalled 4095 - # libraries must come first. 4096 - if test -n "$dllsearchpath"; then 4097 - $ECHO "\ 4098 - # Add the dll search path components to the executable PATH 4099 - PATH=$dllsearchpath:\$PATH 4100 -" 4101 - fi 4102 - 4103 - # Export our shlibpath_var if we have one. 4104 - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4105 - $ECHO "\ 4106 - # Add our own library path to $shlibpath_var 4107 - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108 - 4109 - # Some systems cannot cope with colon-terminated $shlibpath_var 4110 - # The second colon is a workaround for a bug in BeOS R4 sed 4111 - $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4112 - 4113 - export $shlibpath_var 4114 -" 4115 - fi 4116 - 4117 - $ECHO "\ 4118 - if test \"\$libtool_execute_magic\" != \"$magic\"; then 4119 - # Run the actual program with our arguments. 4120 - func_exec_program \${1+\"\$@\"} 4121 - fi 4122 - else 4123 - # The program doesn't exist. 4124 - \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4125 - \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4126 - \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4127 - exit 1 4128 - fi 4129 -fi\ 4130 -" 4131 -} 4132 - 4133 - 4134 -# func_emit_cwrapperexe_src 4135 -# emit the source code for a wrapper executable on stdout 4136 -# Must ONLY be called from within func_mode_link because 4137 -# it depends on a number of variable set therein. 4138 -func_emit_cwrapperexe_src () 4139 -{ 4140 - cat <<EOF 4141 - 4142 -/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4143 - Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144 - 4145 - The $output program cannot be directly executed until all the libtool 4146 - libraries that it depends on are installed. 4147 - 4148 - This wrapper executable should never be moved out of the build directory. 4149 - If it is, it will not operate correctly. 4150 -*/ 4151 -EOF 4152 - cat <<"EOF" 4153 -#ifdef _MSC_VER 4154 -# define _CRT_SECURE_NO_DEPRECATE 1 4155 -#endif 4156 -#include <stdio.h> 4157 -#include <stdlib.h> 4158 -#ifdef _MSC_VER 4159 -# include <direct.h> 4160 -# include <process.h> 4161 -# include <io.h> 4162 -#else 4163 -# include <unistd.h> 4164 -# include <stdint.h> 4165 -# ifdef __CYGWIN__ 4166 -# include <io.h> 4167 -# endif 4168 -#endif 4169 -#include <malloc.h> 4170 -#include <stdarg.h> 4171 -#include <assert.h> 4172 -#include <string.h> 4173 -#include <ctype.h> 4174 -#include <errno.h> 4175 -#include <fcntl.h> 4176 -#include <sys/stat.h> 4177 - 4178 -/* declarations of non-ANSI functions */ 4179 -#if defined(__MINGW32__) 4180 -# ifdef __STRICT_ANSI__ 4181 -int _putenv (const char *); 4182 -# endif 4183 -#elif defined(__CYGWIN__) 4184 -# ifdef __STRICT_ANSI__ 4185 -char *realpath (const char *, char *); 4186 -int putenv (char *); 4187 -int setenv (const char *, const char *, int); 4188 -# endif 4189 -/* #elif defined (other platforms) ... */ 4190 -#endif 4191 - 4192 -/* portability defines, excluding path handling macros */ 4193 -#if defined(_MSC_VER) 4194 -# define setmode _setmode 4195 -# define stat _stat 4196 -# define chmod _chmod 4197 -# define getcwd _getcwd 4198 -# define putenv _putenv 4199 -# define S_IXUSR _S_IEXEC 4200 -# ifndef _INTPTR_T_DEFINED 4201 -# define _INTPTR_T_DEFINED 4202 -# define intptr_t int 4203 -# endif 4204 -#elif defined(__MINGW32__) 4205 -# define setmode _setmode 4206 -# define stat _stat 4207 -# define chmod _chmod 4208 -# define getcwd _getcwd 4209 -# define putenv _putenv 4210 -#elif defined(__CYGWIN__) 4211 -# define HAVE_SETENV 4212 -# define FOPEN_WB "wb" 4213 -/* #elif defined (other platforms) ... */ 4214 -#endif 4215 - 4216 -#if defined(PATH_MAX) 4217 -# define LT_PATHMAX PATH_MAX 4218 -#elif defined(MAXPATHLEN) 4219 -# define LT_PATHMAX MAXPATHLEN 4220 -#else 4221 -# define LT_PATHMAX 1024 4222 -#endif 4223 - 4224 -#ifndef S_IXOTH 4225 -# define S_IXOTH 0 4226 -#endif 4227 -#ifndef S_IXGRP 4228 -# define S_IXGRP 0 4229 -#endif 4230 - 4231 -/* path handling portability macros */ 4232 -#ifndef DIR_SEPARATOR 4233 -# define DIR_SEPARATOR '/' 4234 -# define PATH_SEPARATOR ':' 4235 -#endif 4236 - 4237 -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4238 - defined (__OS2__) 4239 -# define HAVE_DOS_BASED_FILE_SYSTEM 4240 -# define FOPEN_WB "wb" 4241 -# ifndef DIR_SEPARATOR_2 4242 -# define DIR_SEPARATOR_2 '\\' 4243 -# endif 4244 -# ifndef PATH_SEPARATOR_2 4245 -# define PATH_SEPARATOR_2 ';' 4246 -# endif 4247 -#endif 4248 - 4249 -#ifndef DIR_SEPARATOR_2 4250 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4251 -#else /* DIR_SEPARATOR_2 */ 4252 -# define IS_DIR_SEPARATOR(ch) \ 4253 - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4254 -#endif /* DIR_SEPARATOR_2 */ 4255 - 4256 -#ifndef PATH_SEPARATOR_2 4257 -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4258 -#else /* PATH_SEPARATOR_2 */ 4259 -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4260 -#endif /* PATH_SEPARATOR_2 */ 4261 - 4262 -#ifndef FOPEN_WB 4263 -# define FOPEN_WB "w" 4264 -#endif 4265 -#ifndef _O_BINARY 4266 -# define _O_BINARY 0 4267 -#endif 4268 - 4269 -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4270 -#define XFREE(stale) do { \ 4271 - if (stale) { free ((void *) stale); stale = 0; } \ 4272 -} while (0) 4273 - 4274 -#if defined(LT_DEBUGWRAPPER) 4275 -static int lt_debug = 1; 4276 -#else 4277 -static int lt_debug = 0; 4278 -#endif 4279 - 4280 -const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4281 - 4282 -void *xmalloc (size_t num); 4283 -char *xstrdup (const char *string); 4284 -const char *base_name (const char *name); 4285 -char *find_executable (const char *wrapper); 4286 -char *chase_symlinks (const char *pathspec); 4287 -int make_executable (const char *path); 4288 -int check_executable (const char *path); 4289 -char *strendzap (char *str, const char *pat); 4290 -void lt_debugprintf (const char *file, int line, const char *fmt, ...); 4291 -void lt_fatal (const char *file, int line, const char *message, ...); 4292 -static const char *nonnull (const char *s); 4293 -static const char *nonempty (const char *s); 4294 -void lt_setenv (const char *name, const char *value); 4295 -char *lt_extend_str (const char *orig_value, const char *add, int to_end); 4296 -void lt_update_exe_path (const char *name, const char *value); 4297 -void lt_update_lib_path (const char *name, const char *value); 4298 -char **prepare_spawn (char **argv); 4299 -void lt_dump_script (FILE *f); 4300 -EOF 4301 - 4302 - cat <<EOF 4303 -volatile const char * MAGIC_EXE = "$magic_exe"; 4304 -const char * LIB_PATH_VARNAME = "$shlibpath_var"; 4305 -EOF 4306 - 4307 - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4308 - func_to_host_path "$temp_rpath" 4309 - cat <<EOF 4310 -const char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4311 -EOF 4312 - else 4313 - cat <<"EOF" 4314 -const char * LIB_PATH_VALUE = ""; 4315 -EOF 4316 - fi 4317 - 4318 - if test -n "$dllsearchpath"; then 4319 - func_to_host_path "$dllsearchpath:" 4320 - cat <<EOF 4321 -const char * EXE_PATH_VARNAME = "PATH"; 4322 -const char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4323 -EOF 4324 - else 4325 - cat <<"EOF" 4326 -const char * EXE_PATH_VARNAME = ""; 4327 -const char * EXE_PATH_VALUE = ""; 4328 -EOF 4329 - fi 4330 - 4331 - if test "$fast_install" = yes; then 4332 - cat <<EOF 4333 -const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4334 -EOF 4335 - else 4336 - cat <<EOF 4337 -const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4338 -EOF 4339 - fi 4340 - 4341 - 4342 - cat <<"EOF" 4343 - 4344 -#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345 - 4346 -static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4347 -static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4348 -static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349 - 4350 -int 4351 -main (int argc, char *argv[]) 4352 -{ 4353 - char **newargz; 4354 - int newargc; 4355 - char *tmp_pathspec; 4356 - char *actual_cwrapper_path; 4357 - char *actual_cwrapper_name; 4358 - char *target_name; 4359 - char *lt_argv_zero; 4360 - intptr_t rval = 127; 4361 - 4362 - int i; 4363 - 4364 - program_name = (char *) xstrdup (base_name (argv[0])); 4365 - newargz = XMALLOC (char *, argc + 1); 4366 - 4367 - /* very simple arg parsing; don't want to rely on getopt 4368 - * also, copy all non cwrapper options to newargz, except 4369 - * argz[0], which is handled differently 4370 - */ 4371 - newargc=0; 4372 - for (i = 1; i < argc; i++) 4373 - { 4374 - if (strcmp (argv[i], dumpscript_opt) == 0) 4375 - { 4376 -EOF 4377 - case "$host" in 4378 - *mingw* | *cygwin* ) 4379 - # make stdout use "unix" line endings 4380 - echo " setmode(1,_O_BINARY);" 4381 - ;; 4382 - esac 4383 - 4384 - cat <<"EOF" 4385 - lt_dump_script (stdout); 4386 - return 0; 4387 - } 4388 - if (strcmp (argv[i], debug_opt) == 0) 4389 - { 4390 - lt_debug = 1; 4391 - continue; 4392 - } 4393 - if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4394 - { 4395 - /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4396 - namespace, but it is not one of the ones we know about and 4397 - have already dealt with, above (inluding dump-script), then 4398 - report an error. Otherwise, targets might begin to believe 4399 - they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4400 - namespace. The first time any user complains about this, we'll 4401 - need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4402 - or a configure.ac-settable value. 4403 - */ 4404 - lt_fatal (__FILE__, __LINE__, 4405 - "unrecognized %s option: '%s'", 4406 - ltwrapper_option_prefix, argv[i]); 4407 - } 4408 - /* otherwise ... */ 4409 - newargz[++newargc] = xstrdup (argv[i]); 4410 - } 4411 - newargz[++newargc] = NULL; 4412 - 4413 -EOF 4414 - cat <<EOF 4415 - /* The GNU banner must be the first non-error debug message */ 4416 - lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4417 -EOF 4418 - cat <<"EOF" 4419 - lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4420 - lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4421 - 4422 - tmp_pathspec = find_executable (argv[0]); 4423 - if (tmp_pathspec == NULL) 4424 - lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4425 - lt_debugprintf (__FILE__, __LINE__, 4426 - "(main) found exe (before symlink chase) at: %s\n", 4427 - tmp_pathspec); 4428 - 4429 - actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4430 - lt_debugprintf (__FILE__, __LINE__, 4431 - "(main) found exe (after symlink chase) at: %s\n", 4432 - actual_cwrapper_path); 4433 - XFREE (tmp_pathspec); 4434 - 4435 - actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4436 - strendzap (actual_cwrapper_path, actual_cwrapper_name); 4437 - 4438 - /* wrapper name transforms */ 4439 - strendzap (actual_cwrapper_name, ".exe"); 4440 - tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4441 - XFREE (actual_cwrapper_name); 4442 - actual_cwrapper_name = tmp_pathspec; 4443 - tmp_pathspec = 0; 4444 - 4445 - /* target_name transforms -- use actual target program name; might have lt- prefix */ 4446 - target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4447 - strendzap (target_name, ".exe"); 4448 - tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4449 - XFREE (target_name); 4450 - target_name = tmp_pathspec; 4451 - tmp_pathspec = 0; 4452 - 4453 - lt_debugprintf (__FILE__, __LINE__, 4454 - "(main) libtool target name: %s\n", 4455 - target_name); 4456 -EOF 4457 - 4458 - cat <<EOF 4459 - newargz[0] = 4460 - XMALLOC (char, (strlen (actual_cwrapper_path) + 4461 - strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4462 - strcpy (newargz[0], actual_cwrapper_path); 4463 - strcat (newargz[0], "$objdir"); 4464 - strcat (newargz[0], "/"); 4465 -EOF 4466 - 4467 - cat <<"EOF" 4468 - /* stop here, and copy so we don't have to do this twice */ 4469 - tmp_pathspec = xstrdup (newargz[0]); 4470 - 4471 - /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4472 - strcat (newargz[0], actual_cwrapper_name); 4473 - 4474 - /* DO want the lt- prefix here if it exists, so use target_name */ 4475 - lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4476 - XFREE (tmp_pathspec); 4477 - tmp_pathspec = NULL; 4478 -EOF 4479 - 4480 - case $host_os in 4481 - mingw*) 4482 - cat <<"EOF" 4483 - { 4484 - char* p; 4485 - while ((p = strchr (newargz[0], '\\')) != NULL) 4486 - { 4487 - *p = '/'; 4488 - } 4489 - while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4490 - { 4491 - *p = '/'; 4492 - } 4493 - } 4494 -EOF 4495 - ;; 4496 - esac 4497 - 4498 - cat <<"EOF" 4499 - XFREE (target_name); 4500 - XFREE (actual_cwrapper_path); 4501 - XFREE (actual_cwrapper_name); 4502 - 4503 - lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4504 - lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4505 - /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4506 - be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4507 - because on Windows, both *_VARNAMEs are PATH but uninstalled 4508 - libraries must come first. */ 4509 - lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4510 - lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4511 - 4512 - lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4513 - nonnull (lt_argv_zero)); 4514 - for (i = 0; i < newargc; i++) 4515 - { 4516 - lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4517 - i, nonnull (newargz[i])); 4518 - } 4519 - 4520 -EOF 4521 - 4522 - case $host_os in 4523 - mingw*) 4524 - cat <<"EOF" 4525 - /* execv doesn't actually work on mingw as expected on unix */ 4526 - newargz = prepare_spawn (newargz); 4527 - rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4528 - if (rval == -1) 4529 - { 4530 - /* failed to start process */ 4531 - lt_debugprintf (__FILE__, __LINE__, 4532 - "(main) failed to launch target \"%s\": %s\n", 4533 - lt_argv_zero, nonnull (strerror (errno))); 4534 - return 127; 4535 - } 4536 - return rval; 4537 -EOF 4538 - ;; 4539 - *) 4540 - cat <<"EOF" 4541 - execv (lt_argv_zero, newargz); 4542 - return rval; /* =127, but avoids unused variable warning */ 4543 -EOF 4544 - ;; 4545 - esac 4546 - 4547 - cat <<"EOF" 4548 -} 4549 - 4550 -void * 4551 -xmalloc (size_t num) 4552 -{ 4553 - void *p = (void *) malloc (num); 4554 - if (!p) 4555 - lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556 - 4557 - return p; 4558 -} 4559 - 4560 -char * 4561 -xstrdup (const char *string) 4562 -{ 4563 - return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4564 - string) : NULL; 4565 -} 4566 - 4567 -const char * 4568 -base_name (const char *name) 4569 -{ 4570 - const char *base; 4571 - 4572 -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4573 - /* Skip over the disk name in MSDOS pathnames. */ 4574 - if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4575 - name += 2; 4576 -#endif 4577 - 4578 - for (base = name; *name; name++) 4579 - if (IS_DIR_SEPARATOR (*name)) 4580 - base = name + 1; 4581 - return base; 4582 -} 4583 - 4584 -int 4585 -check_executable (const char *path) 4586 -{ 4587 - struct stat st; 4588 - 4589 - lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4590 - nonempty (path)); 4591 - if ((!path) || (!*path)) 4592 - return 0; 4593 - 4594 - if ((stat (path, &st) >= 0) 4595 - && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4596 - return 1; 4597 - else 4598 - return 0; 4599 -} 4600 - 4601 -int 4602 -make_executable (const char *path) 4603 -{ 4604 - int rval = 0; 4605 - struct stat st; 4606 - 4607 - lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4608 - nonempty (path)); 4609 - if ((!path) || (!*path)) 4610 - return 0; 4611 - 4612 - if (stat (path, &st) >= 0) 4613 - { 4614 - rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4615 - } 4616 - return rval; 4617 -} 4618 - 4619 -/* Searches for the full path of the wrapper. Returns 4620 - newly allocated full path name if found, NULL otherwise 4621 - Does not chase symlinks, even on platforms that support them. 4622 -*/ 4623 -char * 4624 -find_executable (const char *wrapper) 4625 -{ 4626 - int has_slash = 0; 4627 - const char *p; 4628 - const char *p_next; 4629 - /* static buffer for getcwd */ 4630 - char tmp[LT_PATHMAX + 1]; 4631 - int tmp_len; 4632 - char *concat_name; 4633 - 4634 - lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4635 - nonempty (wrapper)); 4636 - 4637 - if ((wrapper == NULL) || (*wrapper == '\0')) 4638 - return NULL; 4639 - 4640 - /* Absolute path? */ 4641 -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4642 - if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4643 - { 4644 - concat_name = xstrdup (wrapper); 4645 - if (check_executable (concat_name)) 4646 - return concat_name; 4647 - XFREE (concat_name); 4648 - } 4649 - else 4650 - { 4651 -#endif 4652 - if (IS_DIR_SEPARATOR (wrapper[0])) 4653 - { 4654 - concat_name = xstrdup (wrapper); 4655 - if (check_executable (concat_name)) 4656 - return concat_name; 4657 - XFREE (concat_name); 4658 - } 4659 -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4660 - } 4661 -#endif 4662 - 4663 - for (p = wrapper; *p; p++) 4664 - if (*p == '/') 4665 - { 4666 - has_slash = 1; 4667 - break; 4668 - } 4669 - if (!has_slash) 4670 - { 4671 - /* no slashes; search PATH */ 4672 - const char *path = getenv ("PATH"); 4673 - if (path != NULL) 4674 - { 4675 - for (p = path; *p; p = p_next) 4676 - { 4677 - const char *q; 4678 - size_t p_len; 4679 - for (q = p; *q; q++) 4680 - if (IS_PATH_SEPARATOR (*q)) 4681 - break; 4682 - p_len = q - p; 4683 - p_next = (*q == '\0' ? q : q + 1); 4684 - if (p_len == 0) 4685 - { 4686 - /* empty path: current directory */ 4687 - if (getcwd (tmp, LT_PATHMAX) == NULL) 4688 - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4689 - nonnull (strerror (errno))); 4690 - tmp_len = strlen (tmp); 4691 - concat_name = 4692 - XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4693 - memcpy (concat_name, tmp, tmp_len); 4694 - concat_name[tmp_len] = '/'; 4695 - strcpy (concat_name + tmp_len + 1, wrapper); 4696 - } 4697 - else 4698 - { 4699 - concat_name = 4700 - XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4701 - memcpy (concat_name, p, p_len); 4702 - concat_name[p_len] = '/'; 4703 - strcpy (concat_name + p_len + 1, wrapper); 4704 - } 4705 - if (check_executable (concat_name)) 4706 - return concat_name; 4707 - XFREE (concat_name); 4708 - } 4709 - } 4710 - /* not found in PATH; assume curdir */ 4711 - } 4712 - /* Relative path | not found in path: prepend cwd */ 4713 - if (getcwd (tmp, LT_PATHMAX) == NULL) 4714 - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4715 - nonnull (strerror (errno))); 4716 - tmp_len = strlen (tmp); 4717 - concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4718 - memcpy (concat_name, tmp, tmp_len); 4719 - concat_name[tmp_len] = '/'; 4720 - strcpy (concat_name + tmp_len + 1, wrapper); 4721 - 4722 - if (check_executable (concat_name)) 4723 - return concat_name; 4724 - XFREE (concat_name); 4725 - return NULL; 4726 -} 4727 - 4728 -char * 4729 -chase_symlinks (const char *pathspec) 4730 -{ 4731 -#ifndef S_ISLNK 4732 - return xstrdup (pathspec); 4733 -#else 4734 - char buf[LT_PATHMAX]; 4735 - struct stat s; 4736 - char *tmp_pathspec = xstrdup (pathspec); 4737 - char *p; 4738 - int has_symlinks = 0; 4739 - while (strlen (tmp_pathspec) && !has_symlinks) 4740 - { 4741 - lt_debugprintf (__FILE__, __LINE__, 4742 - "checking path component for symlinks: %s\n", 4743 - tmp_pathspec); 4744 - if (lstat (tmp_pathspec, &s) == 0) 4745 - { 4746 - if (S_ISLNK (s.st_mode) != 0) 4747 - { 4748 - has_symlinks = 1; 4749 - break; 4750 - } 4751 - 4752 - /* search backwards for last DIR_SEPARATOR */ 4753 - p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4754 - while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4755 - p--; 4756 - if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4757 - { 4758 - /* no more DIR_SEPARATORS left */ 4759 - break; 4760 - } 4761 - *p = '\0'; 4762 - } 4763 - else 4764 - { 4765 - lt_fatal (__FILE__, __LINE__, 4766 - "error accessing file \"%s\": %s", 4767 - tmp_pathspec, nonnull (strerror (errno))); 4768 - } 4769 - } 4770 - XFREE (tmp_pathspec); 4771 - 4772 - if (!has_symlinks) 4773 - { 4774 - return xstrdup (pathspec); 4775 - } 4776 - 4777 - tmp_pathspec = realpath (pathspec, buf); 4778 - if (tmp_pathspec == 0) 4779 - { 4780 - lt_fatal (__FILE__, __LINE__, 4781 - "could not follow symlinks for %s", pathspec); 4782 - } 4783 - return xstrdup (tmp_pathspec); 4784 -#endif 4785 -} 4786 - 4787 -char * 4788 -strendzap (char *str, const char *pat) 4789 -{ 4790 - size_t len, patlen; 4791 - 4792 - assert (str != NULL); 4793 - assert (pat != NULL); 4794 - 4795 - len = strlen (str); 4796 - patlen = strlen (pat); 4797 - 4798 - if (patlen <= len) 4799 - { 4800 - str += len - patlen; 4801 - if (strcmp (str, pat) == 0) 4802 - *str = '\0'; 4803 - } 4804 - return str; 4805 -} 4806 - 4807 -void 4808 -lt_debugprintf (const char *file, int line, const char *fmt, ...) 4809 -{ 4810 - va_list args; 4811 - if (lt_debug) 4812 - { 4813 - (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4814 - va_start (args, fmt); 4815 - (void) vfprintf (stderr, fmt, args); 4816 - va_end (args); 4817 - } 4818 -} 4819 - 4820 -static void 4821 -lt_error_core (int exit_status, const char *file, 4822 - int line, const char *mode, 4823 - const char *message, va_list ap) 4824 -{ 4825 - fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4826 - vfprintf (stderr, message, ap); 4827 - fprintf (stderr, ".\n"); 4828 - 4829 - if (exit_status >= 0) 4830 - exit (exit_status); 4831 -} 4832 - 4833 -void 4834 -lt_fatal (const char *file, int line, const char *message, ...) 4835 -{ 4836 - va_list ap; 4837 - va_start (ap, message); 4838 - lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4839 - va_end (ap); 4840 -} 4841 - 4842 -static const char * 4843 -nonnull (const char *s) 4844 -{ 4845 - return s ? s : "(null)"; 4846 -} 4847 - 4848 -static const char * 4849 -nonempty (const char *s) 4850 -{ 4851 - return (s && !*s) ? "(empty)" : nonnull (s); 4852 -} 4853 - 4854 -void 4855 -lt_setenv (const char *name, const char *value) 4856 -{ 4857 - lt_debugprintf (__FILE__, __LINE__, 4858 - "(lt_setenv) setting '%s' to '%s'\n", 4859 - nonnull (name), nonnull (value)); 4860 - { 4861 -#ifdef HAVE_SETENV 4862 - /* always make a copy, for consistency with !HAVE_SETENV */ 4863 - char *str = xstrdup (value); 4864 - setenv (name, str, 1); 4865 -#else 4866 - int len = strlen (name) + 1 + strlen (value) + 1; 4867 - char *str = XMALLOC (char, len); 4868 - sprintf (str, "%s=%s", name, value); 4869 - if (putenv (str) != EXIT_SUCCESS) 4870 - { 4871 - XFREE (str); 4872 - } 4873 -#endif 4874 - } 4875 -} 4876 - 4877 -char * 4878 -lt_extend_str (const char *orig_value, const char *add, int to_end) 4879 -{ 4880 - char *new_value; 4881 - if (orig_value && *orig_value) 4882 - { 4883 - int orig_value_len = strlen (orig_value); 4884 - int add_len = strlen (add); 4885 - new_value = XMALLOC (char, add_len + orig_value_len + 1); 4886 - if (to_end) 4887 - { 4888 - strcpy (new_value, orig_value); 4889 - strcpy (new_value + orig_value_len, add); 4890 - } 4891 - else 4892 - { 4893 - strcpy (new_value, add); 4894 - strcpy (new_value + add_len, orig_value); 4895 - } 4896 - } 4897 - else 4898 - { 4899 - new_value = xstrdup (add); 4900 - } 4901 - return new_value; 4902 -} 4903 - 4904 -void 4905 -lt_update_exe_path (const char *name, const char *value) 4906 -{ 4907 - lt_debugprintf (__FILE__, __LINE__, 4908 - "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4909 - nonnull (name), nonnull (value)); 4910 - 4911 - if (name && *name && value && *value) 4912 - { 4913 - char *new_value = lt_extend_str (getenv (name), value, 0); 4914 - /* some systems can't cope with a ':'-terminated path #' */ 4915 - int len = strlen (new_value); 4916 - while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4917 - { 4918 - new_value[len-1] = '\0'; 4919 - } 4920 - lt_setenv (name, new_value); 4921 - XFREE (new_value); 4922 - } 4923 -} 4924 - 4925 -void 4926 -lt_update_lib_path (const char *name, const char *value) 4927 -{ 4928 - lt_debugprintf (__FILE__, __LINE__, 4929 - "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4930 - nonnull (name), nonnull (value)); 4931 - 4932 - if (name && *name && value && *value) 4933 - { 4934 - char *new_value = lt_extend_str (getenv (name), value, 0); 4935 - lt_setenv (name, new_value); 4936 - XFREE (new_value); 4937 - } 4938 -} 4939 - 4940 -EOF 4941 - case $host_os in 4942 - mingw*) 4943 - cat <<"EOF" 4944 - 4945 -/* Prepares an argument vector before calling spawn(). 4946 - Note that spawn() does not by itself call the command interpreter 4947 - (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4948 - ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4949 - GetVersionEx(&v); 4950 - v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4951 - }) ? "cmd.exe" : "command.com"). 4952 - Instead it simply concatenates the arguments, separated by ' ', and calls 4953 - CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4954 - interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4955 - special way: 4956 - - Space and tab are interpreted as delimiters. They are not treated as 4957 - delimiters if they are surrounded by double quotes: "...". 4958 - - Unescaped double quotes are removed from the input. Their only effect is 4959 - that within double quotes, space and tab are treated like normal 4960 - characters. 4961 - - Backslashes not followed by double quotes are not special. 4962 - - But 2*n+1 backslashes followed by a double quote become 4963 - n backslashes followed by a double quote (n >= 0): 4964 - \" -> " 4965 - \\\" -> \" 4966 - \\\\\" -> \\" 4967 - */ 4968 -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" 4969 -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" 4970 -char ** 4971 -prepare_spawn (char **argv) 4972 -{ 4973 - size_t argc; 4974 - char **new_argv; 4975 - size_t i; 4976 - 4977 - /* Count number of arguments. */ 4978 - for (argc = 0; argv[argc] != NULL; argc++) 4979 - ; 4980 - 4981 - /* Allocate new argument vector. */ 4982 - new_argv = XMALLOC (char *, argc + 1); 4983 - 4984 - /* Put quoted arguments into the new argument vector. */ 4985 - for (i = 0; i < argc; i++) 4986 - { 4987 - const char *string = argv[i]; 4988 - 4989 - if (string[0] == '\0') 4990 - new_argv[i] = xstrdup ("\"\""); 4991 - else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4992 - { 4993 - int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4994 - size_t length; 4995 - unsigned int backslashes; 4996 - const char *s; 4997 - char *quoted_string; 4998 - char *p; 4999 - 5000 - length = 0; 5001 - backslashes = 0; 5002 - if (quote_around) 5003 - length++; 5004 - for (s = string; *s != '\0'; s++) 5005 - { 5006 - char c = *s; 5007 - if (c == '"') 5008 - length += backslashes + 1; 5009 - length++; 5010 - if (c == '\\') 5011 - backslashes++; 5012 - else 5013 - backslashes = 0; 5014 - } 5015 - if (quote_around) 5016 - length += backslashes + 1; 5017 - 5018 - quoted_string = XMALLOC (char, length + 1); 5019 - 5020 - p = quoted_string; 5021 - backslashes = 0; 5022 - if (quote_around) 5023 - *p++ = '"'; 5024 - for (s = string; *s != '\0'; s++) 5025 - { 5026 - char c = *s; 5027 - if (c == '"') 5028 - { 5029 - unsigned int j; 5030 - for (j = backslashes + 1; j > 0; j--) 5031 - *p++ = '\\'; 5032 - } 5033 - *p++ = c; 5034 - if (c == '\\') 5035 - backslashes++; 5036 - else 5037 - backslashes = 0; 5038 - } 5039 - if (quote_around) 5040 - { 5041 - unsigned int j; 5042 - for (j = backslashes; j > 0; j--) 5043 - *p++ = '\\'; 5044 - *p++ = '"'; 5045 - } 5046 - *p = '\0'; 5047 - 5048 - new_argv[i] = quoted_string; 5049 - } 5050 - else 5051 - new_argv[i] = (char *) string; 5052 - } 5053 - new_argv[argc] = NULL; 5054 - 5055 - return new_argv; 5056 -} 5057 -EOF 5058 - ;; 5059 - esac 5060 - 5061 - cat <<"EOF" 5062 -void lt_dump_script (FILE* f) 5063 -{ 5064 -EOF 5065 - func_emit_wrapper yes | 5066 - $SED -n -e ' 5067 -s/^\(.\{79\}\)\(..*\)/\1\ 5068 -\2/ 5069 -h 5070 -s/\([\\"]\)/\\\1/g 5071 -s/$/\\n/ 5072 -s/\([^\n]*\).*/ fputs ("\1", f);/p 5073 -g 5074 -D' 5075 - cat <<"EOF" 5076 -} 5077 -EOF 5078 -} 5079 -# end: func_emit_cwrapperexe_src 5080 - 5081 -# func_win32_import_lib_p ARG 5082 -# True if ARG is an import lib, as indicated by $file_magic_cmd 5083 -func_win32_import_lib_p () 5084 -{ 5085 - $opt_debug 5086 - case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5087 - *import*) : ;; 5088 - *) false ;; 5089 - esac 5090 -} 5091 - 5092 -# func_mode_link arg... 5093 -func_mode_link () 5094 -{ 5095 - $opt_debug 5096 - case $host in 5097 - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5098 - # It is impossible to link a dll without this setting, and 5099 - # we shouldn't force the makefile maintainer to figure out 5100 - # which system we are compiling for in order to pass an extra 5101 - # flag for every libtool invocation. 5102 - # allow_undefined=no 5103 - 5104 - # FIXME: Unfortunately, there are problems with the above when trying 5105 - # to make a dll which has undefined symbols, in which case not 5106 - # even a static library is built. For now, we need to specify 5107 - # -no-undefined on the libtool link line when we can be certain 5108 - # that all symbols are satisfied, otherwise we get a static library. 5109 - allow_undefined=yes 5110 - ;; 5111 - *) 5112 - allow_undefined=yes 5113 - ;; 5114 - esac 5115 - libtool_args=$nonopt 5116 - base_compile="$nonopt $@" 5117 - compile_command=$nonopt 5118 - finalize_command=$nonopt 5119 - 5120 - compile_rpath= 5121 - finalize_rpath= 5122 - compile_shlibpath= 5123 - finalize_shlibpath= 5124 - convenience= 5125 - old_convenience= 5126 - deplibs= 5127 - old_deplibs= 5128 - compiler_flags= 5129 - linker_flags= 5130 - dllsearchpath= 5131 - lib_search_path=`pwd` 5132 - inst_prefix_dir= 5133 - new_inherited_linker_flags= 5134 - 5135 - avoid_version=no 5136 - bindir= 5137 - dlfiles= 5138 - dlprefiles= 5139 - dlself=no 5140 - export_dynamic=no 5141 - export_symbols= 5142 - export_symbols_regex= 5143 - generated= 5144 - libobjs= 5145 - ltlibs= 5146 - module=no 5147 - no_install=no 5148 - objs= 5149 - non_pic_objects= 5150 - precious_files_regex= 5151 - prefer_static_libs=no 5152 - preload=no 5153 - prev= 5154 - prevarg= 5155 - release= 5156 - rpath= 5157 - xrpath= 5158 - perm_rpath= 5159 - temp_rpath= 5160 - thread_safe=no 5161 - vinfo= 5162 - vinfo_number=no 5163 - weak_libs= 5164 - single_module="${wl}-single_module" 5165 - func_infer_tag $base_compile 5166 - 5167 - # We need to know -static, to get the right output filenames. 5168 - for arg 5169 - do 5170 - case $arg in 5171 - -shared) 5172 - test "$build_libtool_libs" != yes && \ 5173 - func_fatal_configuration "can not build a shared library" 5174 - build_old_libs=no 5175 - break 5176 - ;; 5177 - -all-static | -static | -static-libtool-libs) 5178 - case $arg in 5179 - -all-static) 5180 - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5181 - func_warning "complete static linking is impossible in this configuration" 5182 - fi 5183 - if test -n "$link_static_flag"; then 5184 - dlopen_self=$dlopen_self_static 5185 - fi 5186 - prefer_static_libs=yes 5187 - ;; 5188 - -static) 5189 - if test -z "$pic_flag" && test -n "$link_static_flag"; then 5190 - dlopen_self=$dlopen_self_static 5191 - fi 5192 - prefer_static_libs=built 5193 - ;; 5194 - -static-libtool-libs) 5195 - if test -z "$pic_flag" && test -n "$link_static_flag"; then 5196 - dlopen_self=$dlopen_self_static 5197 - fi 5198 - prefer_static_libs=yes 5199 - ;; 5200 - esac 5201 - build_libtool_libs=no 5202 - build_old_libs=yes 5203 - break 5204 - ;; 5205 - esac 5206 - done 5207 - 5208 - # See if our shared archives depend on static archives. 5209 - test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210 - 5211 - # Go through the arguments, transforming them on the way. 5212 - while test "$#" -gt 0; do 5213 - arg="$1" 5214 - shift 5215 - func_quote_for_eval "$arg" 5216 - qarg=$func_quote_for_eval_unquoted_result 5217 - func_append libtool_args " $func_quote_for_eval_result" 5218 - 5219 - # If the previous option needs an argument, assign it. 5220 - if test -n "$prev"; then 5221 - case $prev in 5222 - output) 5223 - func_append compile_command " @OUTPUT@" 5224 - func_append finalize_command " @OUTPUT@" 5225 - ;; 5226 - esac 5227 - 5228 - case $prev in 5229 - bindir) 5230 - bindir="$arg" 5231 - prev= 5232 - continue 5233 - ;; 5234 - dlfiles|dlprefiles) 5235 - if test "$preload" = no; then 5236 - # Add the symbol object into the linking commands. 5237 - func_append compile_command " @SYMFILE@" 5238 - func_append finalize_command " @SYMFILE@" 5239 - preload=yes 5240 - fi 5241 - case $arg in 5242 - *.la | *.lo) ;; # We handle these cases below. 5243 - force) 5244 - if test "$dlself" = no; then 5245 - dlself=needless 5246 - export_dynamic=yes 5247 - fi 5248 - prev= 5249 - continue 5250 - ;; 5251 - self) 5252 - if test "$prev" = dlprefiles; then 5253 - dlself=yes 5254 - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5255 - dlself=yes 5256 - else 5257 - dlself=needless 5258 - export_dynamic=yes 5259 - fi 5260 - prev= 5261 - continue 5262 - ;; 5263 - *) 5264 - if test "$prev" = dlfiles; then 5265 - func_append dlfiles " $arg" 5266 - else 5267 - func_append dlprefiles " $arg" 5268 - fi 5269 - prev= 5270 - continue 5271 - ;; 5272 - esac 5273 - ;; 5274 - expsyms) 5275 - export_symbols="$arg" 5276 - test -f "$arg" \ 5277 - || func_fatal_error "symbol file \`$arg' does not exist" 5278 - prev= 5279 - continue 5280 - ;; 5281 - expsyms_regex) 5282 - export_symbols_regex="$arg" 5283 - prev= 5284 - continue 5285 - ;; 5286 - framework) 5287 - case $host in 5288 - *-*-darwin*) 5289 - case "$deplibs " in 5290 - *" $qarg.ltframework "*) ;; 5291 - *) func_append deplibs " $qarg.ltframework" # this is fixed later 5292 - ;; 5293 - esac 5294 - ;; 5295 - esac 5296 - prev= 5297 - continue 5298 - ;; 5299 - inst_prefix) 5300 - inst_prefix_dir="$arg" 5301 - prev= 5302 - continue 5303 - ;; 5304 - objectlist) 5305 - if test -f "$arg"; then 5306 - save_arg=$arg 5307 - moreargs= 5308 - for fil in `cat "$save_arg"` 5309 - do 5310 -# func_append moreargs " $fil" 5311 - arg=$fil 5312 - # A libtool-controlled object. 5313 - 5314 - # Check to see that this really is a libtool object. 5315 - if func_lalib_unsafe_p "$arg"; then 5316 - pic_object= 5317 - non_pic_object= 5318 - 5319 - # Read the .lo file 5320 - func_source "$arg" 5321 - 5322 - if test -z "$pic_object" || 5323 - test -z "$non_pic_object" || 5324 - test "$pic_object" = none && 5325 - test "$non_pic_object" = none; then 5326 - func_fatal_error "cannot find name of object for \`$arg'" 5327 - fi 5328 - 5329 - # Extract subdirectory from the argument. 5330 - func_dirname "$arg" "/" "" 5331 - xdir="$func_dirname_result" 5332 - 5333 - if test "$pic_object" != none; then 5334 - # Prepend the subdirectory the object is found in. 5335 - pic_object="$xdir$pic_object" 5336 - 5337 - if test "$prev" = dlfiles; then 5338 - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5339 - func_append dlfiles " $pic_object" 5340 - prev= 5341 - continue 5342 - else 5343 - # If libtool objects are unsupported, then we need to preload. 5344 - prev=dlprefiles 5345 - fi 5346 - fi 5347 - 5348 - # CHECK ME: I think I busted this. -Ossama 5349 - if test "$prev" = dlprefiles; then 5350 - # Preload the old-style object. 5351 - func_append dlprefiles " $pic_object" 5352 - prev= 5353 - fi 5354 - 5355 - # A PIC object. 5356 - func_append libobjs " $pic_object" 5357 - arg="$pic_object" 5358 - fi 5359 - 5360 - # Non-PIC object. 5361 - if test "$non_pic_object" != none; then 5362 - # Prepend the subdirectory the object is found in. 5363 - non_pic_object="$xdir$non_pic_object" 5364 - 5365 - # A standard non-PIC object 5366 - func_append non_pic_objects " $non_pic_object" 5367 - if test -z "$pic_object" || test "$pic_object" = none ; then 5368 - arg="$non_pic_object" 5369 - fi 5370 - else 5371 - # If the PIC object exists, use it instead. 5372 - # $xdir was prepended to $pic_object above. 5373 - non_pic_object="$pic_object" 5374 - func_append non_pic_objects " $non_pic_object" 5375 - fi 5376 - else 5377 - # Only an error if not doing a dry-run. 5378 - if $opt_dry_run; then 5379 - # Extract subdirectory from the argument. 5380 - func_dirname "$arg" "/" "" 5381 - xdir="$func_dirname_result" 5382 - 5383 - func_lo2o "$arg" 5384 - pic_object=$xdir$objdir/$func_lo2o_result 5385 - non_pic_object=$xdir$func_lo2o_result 5386 - func_append libobjs " $pic_object" 5387 - func_append non_pic_objects " $non_pic_object" 5388 - else 5389 - func_fatal_error "\`$arg' is not a valid libtool object" 5390 - fi 5391 - fi 5392 - done 5393 - else 5394 - func_fatal_error "link input file \`$arg' does not exist" 5395 - fi 5396 - arg=$save_arg 5397 - prev= 5398 - continue 5399 - ;; 5400 - precious_regex) 5401 - precious_files_regex="$arg" 5402 - prev= 5403 - continue 5404 - ;; 5405 - release) 5406 - release="-$arg" 5407 - prev= 5408 - continue 5409 - ;; 5410 - rpath | xrpath) 5411 - # We need an absolute path. 5412 - case $arg in 5413 - [\\/]* | [A-Za-z]:[\\/]*) ;; 5414 - *) 5415 - func_fatal_error "only absolute run-paths are allowed" 5416 - ;; 5417 - esac 5418 - if test "$prev" = rpath; then 5419 - case "$rpath " in 5420 - *" $arg "*) ;; 5421 - *) func_append rpath " $arg" ;; 5422 - esac 5423 - else 5424 - case "$xrpath " in 5425 - *" $arg "*) ;; 5426 - *) func_append xrpath " $arg" ;; 5427 - esac 5428 - fi 5429 - prev= 5430 - continue 5431 - ;; 5432 - shrext) 5433 - shrext_cmds="$arg" 5434 - prev= 5435 - continue 5436 - ;; 5437 - weak) 5438 - func_append weak_libs " $arg" 5439 - prev= 5440 - continue 5441 - ;; 5442 - xcclinker) 5443 - func_append linker_flags " $qarg" 5444 - func_append compiler_flags " $qarg" 5445 - prev= 5446 - func_append compile_command " $qarg" 5447 - func_append finalize_command " $qarg" 5448 - continue 5449 - ;; 5450 - xcompiler) 5451 - func_append compiler_flags " $qarg" 5452 - prev= 5453 - func_append compile_command " $qarg" 5454 - func_append finalize_command " $qarg" 5455 - continue 5456 - ;; 5457 - xlinker) 5458 - func_append linker_flags " $qarg" 5459 - func_append compiler_flags " $wl$qarg" 5460 - prev= 5461 - func_append compile_command " $wl$qarg" 5462 - func_append finalize_command " $wl$qarg" 5463 - continue 5464 - ;; 5465 - *) 5466 - eval "$prev=\"\$arg\"" 5467 - prev= 5468 - continue 5469 - ;; 5470 - esac 5471 - fi # test -n "$prev" 5472 - 5473 - prevarg="$arg" 5474 - 5475 - case $arg in 5476 - -all-static) 5477 - if test -n "$link_static_flag"; then 5478 - # See comment for -static flag below, for more details. 5479 - func_append compile_command " $link_static_flag" 5480 - func_append finalize_command " $link_static_flag" 5481 - fi 5482 - continue 5483 - ;; 5484 - 5485 - -allow-undefined) 5486 - # FIXME: remove this flag sometime in the future. 5487 - func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5488 - ;; 5489 - 5490 - -avoid-version) 5491 - avoid_version=yes 5492 - continue 5493 - ;; 5494 - 5495 - -bindir) 5496 - prev=bindir 5497 - continue 5498 - ;; 5499 - 5500 - -dlopen) 5501 - prev=dlfiles 5502 - continue 5503 - ;; 5504 - 5505 - -dlpreopen) 5506 - prev=dlprefiles 5507 - continue 5508 - ;; 5509 - 5510 - -export-dynamic) 5511 - export_dynamic=yes 5512 - continue 5513 - ;; 5514 - 5515 - -export-symbols | -export-symbols-regex) 5516 - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5517 - func_fatal_error "more than one -exported-symbols argument is not allowed" 5518 - fi 5519 - if test "X$arg" = "X-export-symbols"; then 5520 - prev=expsyms 5521 - else 5522 - prev=expsyms_regex 5523 - fi 5524 - continue 5525 - ;; 5526 - 5527 - -framework) 5528 - prev=framework 5529 - continue 5530 - ;; 5531 - 5532 - -inst-prefix-dir) 5533 - prev=inst_prefix 5534 - continue 5535 - ;; 5536 - 5537 - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5538 - # so, if we see these flags be careful not to treat them like -L 5539 - -L[A-Z][A-Z]*:*) 5540 - case $with_gcc/$host in 5541 - no/*-*-irix* | /*-*-irix*) 5542 - func_append compile_command " $arg" 5543 - func_append finalize_command " $arg" 5544 - ;; 5545 - esac 5546 - continue 5547 - ;; 5548 - 5549 - -L*) 5550 - func_stripname "-L" '' "$arg" 5551 - if test -z "$func_stripname_result"; then 5552 - if test "$#" -gt 0; then 5553 - func_fatal_error "require no space between \`-L' and \`$1'" 5554 - else 5555 - func_fatal_error "need path for \`-L' option" 5556 - fi 5557 - fi 5558 - func_resolve_sysroot "$func_stripname_result" 5559 - dir=$func_resolve_sysroot_result 5560 - # We need an absolute path. 5561 - case $dir in 5562 - [\\/]* | [A-Za-z]:[\\/]*) ;; 5563 - *) 5564 - absdir=`cd "$dir" && pwd` 5565 - test -z "$absdir" && \ 5566 - func_fatal_error "cannot determine absolute directory name of \`$dir'" 5567 - dir="$absdir" 5568 - ;; 5569 - esac 5570 - case "$deplibs " in 5571 - *" -L$dir "* | *" $arg "*) 5572 - # Will only happen for absolute or sysroot arguments 5573 - ;; 5574 - *) 5575 - # Preserve sysroot, but never include relative directories 5576 - case $dir in 5577 - [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5578 - *) func_append deplibs " -L$dir" ;; 5579 - esac 5580 - func_append lib_search_path " $dir" 5581 - ;; 5582 - esac 5583 - case $host in 5584 - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5585 - testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5586 - case :$dllsearchpath: in 5587 - *":$dir:"*) ;; 5588 - ::) dllsearchpath=$dir;; 5589 - *) func_append dllsearchpath ":$dir";; 5590 - esac 5591 - case :$dllsearchpath: in 5592 - *":$testbindir:"*) ;; 5593 - ::) dllsearchpath=$testbindir;; 5594 - *) func_append dllsearchpath ":$testbindir";; 5595 - esac 5596 - ;; 5597 - esac 5598 - continue 5599 - ;; 5600 - 5601 - -l*) 5602 - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5603 - case $host in 5604 - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5605 - # These systems don't actually have a C or math library (as such) 5606 - continue 5607 - ;; 5608 - *-*-os2*) 5609 - # These systems don't actually have a C library (as such) 5610 - test "X$arg" = "X-lc" && continue 5611 - ;; 5612 - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5613 - # Do not include libc due to us having libc/libc_r. 5614 - test "X$arg" = "X-lc" && continue 5615 - ;; 5616 - *-*-rhapsody* | *-*-darwin1.[012]) 5617 - # Rhapsody C and math libraries are in the System framework 5618 - func_append deplibs " System.ltframework" 5619 - continue 5620 - ;; 5621 - *-*-sco3.2v5* | *-*-sco5v6*) 5622 - # Causes problems with __ctype 5623 - test "X$arg" = "X-lc" && continue 5624 - ;; 5625 - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5626 - # Compiler inserts libc in the correct place for threads to work 5627 - test "X$arg" = "X-lc" && continue 5628 - ;; 5629 - esac 5630 - elif test "X$arg" = "X-lc_r"; then 5631 - case $host in 5632 - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5633 - # Do not include libc_r directly, use -pthread flag. 5634 - continue 5635 - ;; 5636 - esac 5637 - fi 5638 - func_append deplibs " $arg" 5639 - continue 5640 - ;; 5641 - 5642 - -module) 5643 - module=yes 5644 - continue 5645 - ;; 5646 - 5647 - # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5648 - # classes, name mangling, and exception handling. 5649 - # Darwin uses the -arch flag to determine output architecture. 5650 - -model|-arch|-isysroot|--sysroot) 5651 - func_append compiler_flags " $arg" 5652 - func_append compile_command " $arg" 5653 - func_append finalize_command " $arg" 5654 - prev=xcompiler 5655 - continue 5656 - ;; 5657 - 5658 - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 5659 - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 5660 - func_append compiler_flags " $arg" 5661 - func_append compile_command " $arg" 5662 - func_append finalize_command " $arg" 5663 - case "$new_inherited_linker_flags " in 5664 - *" $arg "*) ;; 5665 - * ) func_append new_inherited_linker_flags " $arg" ;; 5666 - esac 5667 - continue 5668 - ;; 5669 - 5670 - -multi_module) 5671 - single_module="${wl}-multi_module" 5672 - continue 5673 - ;; 5674 - 5675 - -no-fast-install) 5676 - fast_install=no 5677 - continue 5678 - ;; 5679 - 5680 - -no-install) 5681 - case $host in 5682 - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5683 - # The PATH hackery in wrapper scripts is required on Windows 5684 - # and Darwin in order for the loader to find any dlls it needs. 5685 - func_warning "\`-no-install' is ignored for $host" 5686 - func_warning "assuming \`-no-fast-install' instead" 5687 - fast_install=no 5688 - ;; 5689 - *) no_install=yes ;; 5690 - esac 5691 - continue 5692 - ;; 5693 - 5694 - -no-undefined) 5695 - allow_undefined=no 5696 - continue 5697 - ;; 5698 - 5699 - -objectlist) 5700 - prev=objectlist 5701 - continue 5702 - ;; 5703 - 5704 - -o) prev=output ;; 5705 - 5706 - -precious-files-regex) 5707 - prev=precious_regex 5708 - continue 5709 - ;; 5710 - 5711 - -release) 5712 - prev=release 5713 - continue 5714 - ;; 5715 - 5716 - -rpath) 5717 - prev=rpath 5718 - continue 5719 - ;; 5720 - 5721 - -R) 5722 - prev=xrpath 5723 - continue 5724 - ;; 5725 - 5726 - -R*) 5727 - func_stripname '-R' '' "$arg" 5728 - dir=$func_stripname_result 5729 - # We need an absolute path. 5730 - case $dir in 5731 - [\\/]* | [A-Za-z]:[\\/]*) ;; 5732 - =*) 5733 - func_stripname '=' '' "$dir" 5734 - dir=$lt_sysroot$func_stripname_result 5735 - ;; 5736 - *) 5737 - func_fatal_error "only absolute run-paths are allowed" 5738 - ;; 5739 - esac 5740 - case "$xrpath " in 5741 - *" $dir "*) ;; 5742 - *) func_append xrpath " $dir" ;; 5743 - esac 5744 - continue 5745 - ;; 5746 - 5747 - -shared) 5748 - # The effects of -shared are defined in a previous loop. 5749 - continue 5750 - ;; 5751 - 5752 - -shrext) 5753 - prev=shrext 5754 - continue 5755 - ;; 5756 - 5757 - -static | -static-libtool-libs) 5758 - # The effects of -static are defined in a previous loop. 5759 - # We used to do the same as -all-static on platforms that 5760 - # didn't have a PIC flag, but the assumption that the effects 5761 - # would be equivalent was wrong. It would break on at least 5762 - # Digital Unix and AIX. 5763 - continue 5764 - ;; 5765 - 5766 - -thread-safe) 5767 - thread_safe=yes 5768 - continue 5769 - ;; 5770 - 5771 - -version-info) 5772 - prev=vinfo 5773 - continue 5774 - ;; 5775 - 5776 - -version-number) 5777 - prev=vinfo 5778 - vinfo_number=yes 5779 - continue 5780 - ;; 5781 - 5782 - -weak) 5783 - prev=weak 5784 - continue 5785 - ;; 5786 - 5787 - -Wc,*) 5788 - func_stripname '-Wc,' '' "$arg" 5789 - args=$func_stripname_result 5790 - arg= 5791 - save_ifs="$IFS"; IFS=',' 5792 - for flag in $args; do 5793 - IFS="$save_ifs" 5794 - func_quote_for_eval "$flag" 5795 - func_append arg " $func_quote_for_eval_result" 5796 - func_append compiler_flags " $func_quote_for_eval_result" 5797 - done 5798 - IFS="$save_ifs" 5799 - func_stripname ' ' '' "$arg" 5800 - arg=$func_stripname_result 5801 - ;; 5802 - 5803 - -Wl,*) 5804 - func_stripname '-Wl,' '' "$arg" 5805 - args=$func_stripname_result 5806 - arg= 5807 - save_ifs="$IFS"; IFS=',' 5808 - for flag in $args; do 5809 - IFS="$save_ifs" 5810 - func_quote_for_eval "$flag" 5811 - func_append arg " $wl$func_quote_for_eval_result" 5812 - func_append compiler_flags " $wl$func_quote_for_eval_result" 5813 - func_append linker_flags " $func_quote_for_eval_result" 5814 - done 5815 - IFS="$save_ifs" 5816 - func_stripname ' ' '' "$arg" 5817 - arg=$func_stripname_result 5818 - ;; 5819 - 5820 - -Xcompiler) 5821 - prev=xcompiler 5822 - continue 5823 - ;; 5824 - 5825 - -Xlinker) 5826 - prev=xlinker 5827 - continue 5828 - ;; 5829 - 5830 - -XCClinker) 5831 - prev=xcclinker 5832 - continue 5833 - ;; 5834 - 5835 - # -msg_* for osf cc 5836 - -msg_*) 5837 - func_quote_for_eval "$arg" 5838 - arg="$func_quote_for_eval_result" 5839 - ;; 5840 - 5841 - # Flags to be passed through unchanged, with rationale: 5842 - # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5843 - # -r[0-9][0-9]* specify processor for the SGI compiler 5844 - # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5845 - # +DA*, +DD* enable 64-bit mode for the HP compiler 5846 - # -q* compiler args for the IBM compiler 5847 - # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5848 - # -F/path path to uninstalled frameworks, gcc on darwin 5849 - # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5850 - # @file GCC response files 5851 - # -tp=* Portland pgcc target processor selection 5852 - # --sysroot=* for sysroot support 5853 - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5854 - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5855 - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5856 - -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5857 - func_quote_for_eval "$arg" 5858 - arg="$func_quote_for_eval_result" 5859 - func_append compile_command " $arg" 5860 - func_append finalize_command " $arg" 5861 - func_append compiler_flags " $arg" 5862 - continue 5863 - ;; 5864 - 5865 - # Some other compiler flag. 5866 - -* | +*) 5867 - func_quote_for_eval "$arg" 5868 - arg="$func_quote_for_eval_result" 5869 - ;; 5870 - 5871 - *.$objext) 5872 - # A standard object. 5873 - func_append objs " $arg" 5874 - ;; 5875 - 5876 - *.lo) 5877 - # A libtool-controlled object. 5878 - 5879 - # Check to see that this really is a libtool object. 5880 - if func_lalib_unsafe_p "$arg"; then 5881 - pic_object= 5882 - non_pic_object= 5883 - 5884 - # Read the .lo file 5885 - func_source "$arg" 5886 - 5887 - if test -z "$pic_object" || 5888 - test -z "$non_pic_object" || 5889 - test "$pic_object" = none && 5890 - test "$non_pic_object" = none; then 5891 - func_fatal_error "cannot find name of object for \`$arg'" 5892 - fi 5893 - 5894 - # Extract subdirectory from the argument. 5895 - func_dirname "$arg" "/" "" 5896 - xdir="$func_dirname_result" 5897 - 5898 - if test "$pic_object" != none; then 5899 - # Prepend the subdirectory the object is found in. 5900 - pic_object="$xdir$pic_object" 5901 - 5902 - if test "$prev" = dlfiles; then 5903 - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5904 - func_append dlfiles " $pic_object" 5905 - prev= 5906 - continue 5907 - else 5908 - # If libtool objects are unsupported, then we need to preload. 5909 - prev=dlprefiles 5910 - fi 5911 - fi 5912 - 5913 - # CHECK ME: I think I busted this. -Ossama 5914 - if test "$prev" = dlprefiles; then 5915 - # Preload the old-style object. 5916 - func_append dlprefiles " $pic_object" 5917 - prev= 5918 - fi 5919 - 5920 - # A PIC object. 5921 - func_append libobjs " $pic_object" 5922 - arg="$pic_object" 5923 - fi 5924 - 5925 - # Non-PIC object. 5926 - if test "$non_pic_object" != none; then 5927 - # Prepend the subdirectory the object is found in. 5928 - non_pic_object="$xdir$non_pic_object" 5929 - 5930 - # A standard non-PIC object 5931 - func_append non_pic_objects " $non_pic_object" 5932 - if test -z "$pic_object" || test "$pic_object" = none ; then 5933 - arg="$non_pic_object" 5934 - fi 5935 - else 5936 - # If the PIC object exists, use it instead. 5937 - # $xdir was prepended to $pic_object above. 5938 - non_pic_object="$pic_object" 5939 - func_append non_pic_objects " $non_pic_object" 5940 - fi 5941 - else 5942 - # Only an error if not doing a dry-run. 5943 - if $opt_dry_run; then 5944 - # Extract subdirectory from the argument. 5945 - func_dirname "$arg" "/" "" 5946 - xdir="$func_dirname_result" 5947 - 5948 - func_lo2o "$arg" 5949 - pic_object=$xdir$objdir/$func_lo2o_result 5950 - non_pic_object=$xdir$func_lo2o_result 5951 - func_append libobjs " $pic_object" 5952 - func_append non_pic_objects " $non_pic_object" 5953 - else 5954 - func_fatal_error "\`$arg' is not a valid libtool object" 5955 - fi 5956 - fi 5957 - ;; 5958 - 5959 - *.$libext) 5960 - # An archive. 5961 - func_append deplibs " $arg" 5962 - func_append old_deplibs " $arg" 5963 - continue 5964 - ;; 5965 - 5966 - *.la) 5967 - # A libtool-controlled library. 5968 - 5969 - func_resolve_sysroot "$arg" 5970 - if test "$prev" = dlfiles; then 5971 - # This library was specified with -dlopen. 5972 - func_append dlfiles " $func_resolve_sysroot_result" 5973 - prev= 5974 - elif test "$prev" = dlprefiles; then 5975 - # The library was specified with -dlpreopen. 5976 - func_append dlprefiles " $func_resolve_sysroot_result" 5977 - prev= 5978 - else 5979 - func_append deplibs " $func_resolve_sysroot_result" 5980 - fi 5981 - continue 5982 - ;; 5983 - 5984 - # Some other compiler argument. 5985 - *) 5986 - # Unknown arguments in both finalize_command and compile_command need 5987 - # to be aesthetically quoted because they are evaled later. 5988 - func_quote_for_eval "$arg" 5989 - arg="$func_quote_for_eval_result" 5990 - ;; 5991 - esac # arg 5992 - 5993 - # Now actually substitute the argument into the commands. 5994 - if test -n "$arg"; then 5995 - func_append compile_command " $arg" 5996 - func_append finalize_command " $arg" 5997 - fi 5998 - done # argument parsing loop 5999 - 6000 - test -n "$prev" && \ 6001 - func_fatal_help "the \`$prevarg' option requires an argument" 6002 - 6003 - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 6004 - eval arg=\"$export_dynamic_flag_spec\" 6005 - func_append compile_command " $arg" 6006 - func_append finalize_command " $arg" 6007 - fi 6008 - 6009 - oldlibs= 6010 - # calculate the name of the file, without its directory 6011 - func_basename "$output" 6012 - outputname="$func_basename_result" 6013 - libobjs_save="$libobjs" 6014 - 6015 - if test -n "$shlibpath_var"; then 6016 - # get the directories listed in $shlibpath_var 6017 - eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6018 - else 6019 - shlib_search_path= 6020 - fi 6021 - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6022 - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6023 - 6024 - func_dirname "$output" "/" "" 6025 - output_objdir="$func_dirname_result$objdir" 6026 - func_to_tool_file "$output_objdir/" 6027 - tool_output_objdir=$func_to_tool_file_result 6028 - # Create the object directory. 6029 - func_mkdir_p "$output_objdir" 6030 - 6031 - # Determine the type of output 6032 - case $output in 6033 - "") 6034 - func_fatal_help "you must specify an output file" 6035 - ;; 6036 - *.$libext) linkmode=oldlib ;; 6037 - *.lo | *.$objext) linkmode=obj ;; 6038 - *.la) linkmode=lib ;; 6039 - *) linkmode=prog ;; # Anything else should be a program. 6040 - esac 6041 - 6042 - specialdeplibs= 6043 - 6044 - libs= 6045 - # Find all interdependent deplibs by searching for libraries 6046 - # that are linked more than once (e.g. -la -lb -la) 6047 - for deplib in $deplibs; do 6048 - if $opt_preserve_dup_deps ; then 6049 - case "$libs " in 6050 - *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6051 - esac 6052 - fi 6053 - func_append libs " $deplib" 6054 - done 6055 - 6056 - if test "$linkmode" = lib; then 6057 - libs="$predeps $libs $compiler_lib_search_path $postdeps" 6058 - 6059 - # Compute libraries that are listed more than once in $predeps 6060 - # $postdeps and mark them as special (i.e., whose duplicates are 6061 - # not to be eliminated). 6062 - pre_post_deps= 6063 - if $opt_duplicate_compiler_generated_deps; then 6064 - for pre_post_dep in $predeps $postdeps; do 6065 - case "$pre_post_deps " in 6066 - *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6067 - esac 6068 - func_append pre_post_deps " $pre_post_dep" 6069 - done 6070 - fi 6071 - pre_post_deps= 6072 - fi 6073 - 6074 - deplibs= 6075 - newdependency_libs= 6076 - newlib_search_path= 6077 - need_relink=no # whether we're linking any uninstalled libtool libraries 6078 - notinst_deplibs= # not-installed libtool libraries 6079 - notinst_path= # paths that contain not-installed libtool libraries 6080 - 6081 - case $linkmode in 6082 - lib) 6083 - passes="conv dlpreopen link" 6084 - for file in $dlfiles $dlprefiles; do 6085 - case $file in 6086 - *.la) ;; 6087 - *) 6088 - func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6089 - ;; 6090 - esac 6091 - done 6092 - ;; 6093 - prog) 6094 - compile_deplibs= 6095 - finalize_deplibs= 6096 - alldeplibs=no 6097 - newdlfiles= 6098 - newdlprefiles= 6099 - passes="conv scan dlopen dlpreopen link" 6100 - ;; 6101 - *) passes="conv" 6102 - ;; 6103 - esac 6104 - 6105 - for pass in $passes; do 6106 - # The preopen pass in lib mode reverses $deplibs; put it back here 6107 - # so that -L comes before libs that need it for instance... 6108 - if test "$linkmode,$pass" = "lib,link"; then 6109 - ## FIXME: Find the place where the list is rebuilt in the wrong 6110 - ## order, and fix it there properly 6111 - tmp_deplibs= 6112 - for deplib in $deplibs; do 6113 - tmp_deplibs="$deplib $tmp_deplibs" 6114 - done 6115 - deplibs="$tmp_deplibs" 6116 - fi 6117 - 6118 - if test "$linkmode,$pass" = "lib,link" || 6119 - test "$linkmode,$pass" = "prog,scan"; then 6120 - libs="$deplibs" 6121 - deplibs= 6122 - fi 6123 - if test "$linkmode" = prog; then 6124 - case $pass in 6125 - dlopen) libs="$dlfiles" ;; 6126 - dlpreopen) libs="$dlprefiles" ;; 6127 - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6128 - esac 6129 - fi 6130 - if test "$linkmode,$pass" = "lib,dlpreopen"; then 6131 - # Collect and forward deplibs of preopened libtool libs 6132 - for lib in $dlprefiles; do 6133 - # Ignore non-libtool-libs 6134 - dependency_libs= 6135 - func_resolve_sysroot "$lib" 6136 - case $lib in 6137 - *.la) func_source "$func_resolve_sysroot_result" ;; 6138 - esac 6139 - 6140 - # Collect preopened libtool deplibs, except any this library 6141 - # has declared as weak libs 6142 - for deplib in $dependency_libs; do 6143 - func_basename "$deplib" 6144 - deplib_base=$func_basename_result 6145 - case " $weak_libs " in 6146 - *" $deplib_base "*) ;; 6147 - *) func_append deplibs " $deplib" ;; 6148 - esac 6149 - done 6150 - done 6151 - libs="$dlprefiles" 6152 - fi 6153 - if test "$pass" = dlopen; then 6154 - # Collect dlpreopened libraries 6155 - save_deplibs="$deplibs" 6156 - deplibs= 6157 - fi 6158 - 6159 - for deplib in $libs; do 6160 - lib= 6161 - found=no 6162 - case $deplib in 6163 - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 6164 - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 6165 - if test "$linkmode,$pass" = "prog,link"; then 6166 - compile_deplibs="$deplib $compile_deplibs" 6167 - finalize_deplibs="$deplib $finalize_deplibs" 6168 - else 6169 - func_append compiler_flags " $deplib" 6170 - if test "$linkmode" = lib ; then 6171 - case "$new_inherited_linker_flags " in 6172 - *" $deplib "*) ;; 6173 - * ) func_append new_inherited_linker_flags " $deplib" ;; 6174 - esac 6175 - fi 6176 - fi 6177 - continue 6178 - ;; 6179 - -l*) 6180 - if test "$linkmode" != lib && test "$linkmode" != prog; then 6181 - func_warning "\`-l' is ignored for archives/objects" 6182 - continue 6183 - fi 6184 - func_stripname '-l' '' "$deplib" 6185 - name=$func_stripname_result 6186 - if test "$linkmode" = lib; then 6187 - searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6188 - else 6189 - searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6190 - fi 6191 - for searchdir in $searchdirs; do 6192 - for search_ext in .la $std_shrext .so .a; do 6193 - # Search the libtool library 6194 - lib="$searchdir/lib${name}${search_ext}" 6195 - if test -f "$lib"; then 6196 - if test "$search_ext" = ".la"; then 6197 - found=yes 6198 - else 6199 - found=no 6200 - fi 6201 - break 2 6202 - fi 6203 - done 6204 - done 6205 - if test "$found" != yes; then 6206 - # deplib doesn't seem to be a libtool library 6207 - if test "$linkmode,$pass" = "prog,link"; then 6208 - compile_deplibs="$deplib $compile_deplibs" 6209 - finalize_deplibs="$deplib $finalize_deplibs" 6210 - else 6211 - deplibs="$deplib $deplibs" 6212 - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6213 - fi 6214 - continue 6215 - else # deplib is a libtool library 6216 - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6217 - # We need to do some special things here, and not later. 6218 - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6219 - case " $predeps $postdeps " in 6220 - *" $deplib "*) 6221 - if func_lalib_p "$lib"; then 6222 - library_names= 6223 - old_library= 6224 - func_source "$lib" 6225 - for l in $old_library $library_names; do 6226 - ll="$l" 6227 - done 6228 - if test "X$ll" = "X$old_library" ; then # only static version available 6229 - found=no 6230 - func_dirname "$lib" "" "." 6231 - ladir="$func_dirname_result" 6232 - lib=$ladir/$old_library 6233 - if test "$linkmode,$pass" = "prog,link"; then 6234 - compile_deplibs="$deplib $compile_deplibs" 6235 - finalize_deplibs="$deplib $finalize_deplibs" 6236 - else 6237 - deplibs="$deplib $deplibs" 6238 - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6239 - fi 6240 - continue 6241 - fi 6242 - fi 6243 - ;; 6244 - *) ;; 6245 - esac 6246 - fi 6247 - fi 6248 - ;; # -l 6249 - *.ltframework) 6250 - if test "$linkmode,$pass" = "prog,link"; then 6251 - compile_deplibs="$deplib $compile_deplibs" 6252 - finalize_deplibs="$deplib $finalize_deplibs" 6253 - else 6254 - deplibs="$deplib $deplibs" 6255 - if test "$linkmode" = lib ; then 6256 - case "$new_inherited_linker_flags " in 6257 - *" $deplib "*) ;; 6258 - * ) func_append new_inherited_linker_flags " $deplib" ;; 6259 - esac 6260 - fi 6261 - fi 6262 - continue 6263 - ;; 6264 - -L*) 6265 - case $linkmode in 6266 - lib) 6267 - deplibs="$deplib $deplibs" 6268 - test "$pass" = conv && continue 6269 - newdependency_libs="$deplib $newdependency_libs" 6270 - func_stripname '-L' '' "$deplib" 6271 - func_resolve_sysroot "$func_stripname_result" 6272 - func_append newlib_search_path " $func_resolve_sysroot_result" 6273 - ;; 6274 - prog) 6275 - if test "$pass" = conv; then 6276 - deplibs="$deplib $deplibs" 6277 - continue 6278 - fi 6279 - if test "$pass" = scan; then 6280 - deplibs="$deplib $deplibs" 6281 - else 6282 - compile_deplibs="$deplib $compile_deplibs" 6283 - finalize_deplibs="$deplib $finalize_deplibs" 6284 - fi 6285 - func_stripname '-L' '' "$deplib" 6286 - func_resolve_sysroot "$func_stripname_result" 6287 - func_append newlib_search_path " $func_resolve_sysroot_result" 6288 - ;; 6289 - *) 6290 - func_warning "\`-L' is ignored for archives/objects" 6291 - ;; 6292 - esac # linkmode 6293 - continue 6294 - ;; # -L 6295 - -R*) 6296 - if test "$pass" = link; then 6297 - func_stripname '-R' '' "$deplib" 6298 - func_resolve_sysroot "$func_stripname_result" 6299 - dir=$func_resolve_sysroot_result 6300 - # Make sure the xrpath contains only unique directories. 6301 - case "$xrpath " in 6302 - *" $dir "*) ;; 6303 - *) func_append xrpath " $dir" ;; 6304 - esac 6305 - fi 6306 - deplibs="$deplib $deplibs" 6307 - continue 6308 - ;; 6309 - *.la) 6310 - func_resolve_sysroot "$deplib" 6311 - lib=$func_resolve_sysroot_result 6312 - ;; 6313 - *.$libext) 6314 - if test "$pass" = conv; then 6315 - deplibs="$deplib $deplibs" 6316 - continue 6317 - fi 6318 - case $linkmode in 6319 - lib) 6320 - # Linking convenience modules into shared libraries is allowed, 6321 - # but linking other static libraries is non-portable. 6322 - case " $dlpreconveniencelibs " in 6323 - *" $deplib "*) ;; 6324 - *) 6325 - valid_a_lib=no 6326 - case $deplibs_check_method in 6327 - match_pattern*) 6328 - set dummy $deplibs_check_method; shift 6329 - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6330 - if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6331 - | $EGREP "$match_pattern_regex" > /dev/null; then 6332 - valid_a_lib=yes 6333 - fi 6334 - ;; 6335 - pass_all) 6336 - valid_a_lib=yes 6337 - ;; 6338 - esac 6339 - if test "$valid_a_lib" != yes; then 6340 - echo 6341 - $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6342 - echo "*** I have the capability to make that library automatically link in when" 6343 - echo "*** you link to this library. But I can only do this if you have a" 6344 - echo "*** shared version of the library, which you do not appear to have" 6345 - echo "*** because the file extensions .$libext of this argument makes me believe" 6346 - echo "*** that it is just a static archive that I should not use here." 6347 - else 6348 - echo 6349 - $ECHO "*** Warning: Linking the shared library $output against the" 6350 - $ECHO "*** static library $deplib is not portable!" 6351 - deplibs="$deplib $deplibs" 6352 - fi 6353 - ;; 6354 - esac 6355 - continue 6356 - ;; 6357 - prog) 6358 - if test "$pass" != link; then 6359 - deplibs="$deplib $deplibs" 6360 - else 6361 - compile_deplibs="$deplib $compile_deplibs" 6362 - finalize_deplibs="$deplib $finalize_deplibs" 6363 - fi 6364 - continue 6365 - ;; 6366 - esac # linkmode 6367 - ;; # *.$libext 6368 - *.lo | *.$objext) 6369 - if test "$pass" = conv; then 6370 - deplibs="$deplib $deplibs" 6371 - elif test "$linkmode" = prog; then 6372 - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6373 - # If there is no dlopen support or we're linking statically, 6374 - # we need to preload. 6375 - func_append newdlprefiles " $deplib" 6376 - compile_deplibs="$deplib $compile_deplibs" 6377 - finalize_deplibs="$deplib $finalize_deplibs" 6378 - else 6379 - func_append newdlfiles " $deplib" 6380 - fi 6381 - fi 6382 - continue 6383 - ;; 6384 - %DEPLIBS%) 6385 - alldeplibs=yes 6386 - continue 6387 - ;; 6388 - esac # case $deplib 6389 - 6390 - if test "$found" = yes || test -f "$lib"; then : 6391 - else 6392 - func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6393 - fi 6394 - 6395 - # Check to see that this really is a libtool archive. 6396 - func_lalib_unsafe_p "$lib" \ 6397 - || func_fatal_error "\`$lib' is not a valid libtool archive" 6398 - 6399 - func_dirname "$lib" "" "." 6400 - ladir="$func_dirname_result" 6401 - 6402 - dlname= 6403 - dlopen= 6404 - dlpreopen= 6405 - libdir= 6406 - library_names= 6407 - old_library= 6408 - inherited_linker_flags= 6409 - # If the library was installed with an old release of libtool, 6410 - # it will not redefine variables installed, or shouldnotlink 6411 - installed=yes 6412 - shouldnotlink=no 6413 - avoidtemprpath= 6414 - 6415 - 6416 - # Read the .la file 6417 - func_source "$lib" 6418 - 6419 - # Convert "-framework foo" to "foo.ltframework" 6420 - if test -n "$inherited_linker_flags"; then 6421 - tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6422 - for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6423 - case " $new_inherited_linker_flags " in 6424 - *" $tmp_inherited_linker_flag "*) ;; 6425 - *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6426 - esac 6427 - done 6428 - fi 6429 - dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6430 - if test "$linkmode,$pass" = "lib,link" || 6431 - test "$linkmode,$pass" = "prog,scan" || 6432 - { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6433 - test -n "$dlopen" && func_append dlfiles " $dlopen" 6434 - test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6435 - fi 6436 - 6437 - if test "$pass" = conv; then 6438 - # Only check for convenience libraries 6439 - deplibs="$lib $deplibs" 6440 - if test -z "$libdir"; then 6441 - if test -z "$old_library"; then 6442 - func_fatal_error "cannot find name of link library for \`$lib'" 6443 - fi 6444 - # It is a libtool convenience library, so add in its objects. 6445 - func_append convenience " $ladir/$objdir/$old_library" 6446 - func_append old_convenience " $ladir/$objdir/$old_library" 6447 - elif test "$linkmode" != prog && test "$linkmode" != lib; then 6448 - func_fatal_error "\`$lib' is not a convenience library" 6449 - fi 6450 - tmp_libs= 6451 - for deplib in $dependency_libs; do 6452 - deplibs="$deplib $deplibs" 6453 - if $opt_preserve_dup_deps ; then 6454 - case "$tmp_libs " in 6455 - *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6456 - esac 6457 - fi 6458 - func_append tmp_libs " $deplib" 6459 - done 6460 - continue 6461 - fi # $pass = conv 6462 - 6463 - 6464 - # Get the name of the library we link against. 6465 - linklib= 6466 - if test -n "$old_library" && 6467 - { test "$prefer_static_libs" = yes || 6468 - test "$prefer_static_libs,$installed" = "built,no"; }; then 6469 - linklib=$old_library 6470 - else 6471 - for l in $old_library $library_names; do 6472 - linklib="$l" 6473 - done 6474 - fi 6475 - if test -z "$linklib"; then 6476 - func_fatal_error "cannot find name of link library for \`$lib'" 6477 - fi 6478 - 6479 - # This library was specified with -dlopen. 6480 - if test "$pass" = dlopen; then 6481 - if test -z "$libdir"; then 6482 - func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6483 - fi 6484 - if test -z "$dlname" || 6485 - test "$dlopen_support" != yes || 6486 - test "$build_libtool_libs" = no; then 6487 - # If there is no dlname, no dlopen support or we're linking 6488 - # statically, we need to preload. We also need to preload any 6489 - # dependent libraries so libltdl's deplib preloader doesn't 6490 - # bomb out in the load deplibs phase. 6491 - func_append dlprefiles " $lib $dependency_libs" 6492 - else 6493 - func_append newdlfiles " $lib" 6494 - fi 6495 - continue 6496 - fi # $pass = dlopen 6497 - 6498 - # We need an absolute path. 6499 - case $ladir in 6500 - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6501 - *) 6502 - abs_ladir=`cd "$ladir" && pwd` 6503 - if test -z "$abs_ladir"; then 6504 - func_warning "cannot determine absolute directory name of \`$ladir'" 6505 - func_warning "passing it literally to the linker, although it might fail" 6506 - abs_ladir="$ladir" 6507 - fi 6508 - ;; 6509 - esac 6510 - func_basename "$lib" 6511 - laname="$func_basename_result" 6512 - 6513 - # Find the relevant object directory and library name. 6514 - if test "X$installed" = Xyes; then 6515 - if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6516 - func_warning "library \`$lib' was moved." 6517 - dir="$ladir" 6518 - absdir="$abs_ladir" 6519 - libdir="$abs_ladir" 6520 - else 6521 - dir="$lt_sysroot$libdir" 6522 - absdir="$lt_sysroot$libdir" 6523 - fi 6524 - test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6525 - else 6526 - if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6527 - dir="$ladir" 6528 - absdir="$abs_ladir" 6529 - # Remove this search path later 6530 - func_append notinst_path " $abs_ladir" 6531 - else 6532 - dir="$ladir/$objdir" 6533 - absdir="$abs_ladir/$objdir" 6534 - # Remove this search path later 6535 - func_append notinst_path " $abs_ladir" 6536 - fi 6537 - fi # $installed = yes 6538 - func_stripname 'lib' '.la' "$laname" 6539 - name=$func_stripname_result 6540 - 6541 - # This library was specified with -dlpreopen. 6542 - if test "$pass" = dlpreopen; then 6543 - if test -z "$libdir" && test "$linkmode" = prog; then 6544 - func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6545 - fi 6546 - case "$host" in 6547 - # special handling for platforms with PE-DLLs. 6548 - *cygwin* | *mingw* | *cegcc* ) 6549 - # Linker will automatically link against shared library if both 6550 - # static and shared are present. Therefore, ensure we extract 6551 - # symbols from the import library if a shared library is present 6552 - # (otherwise, the dlopen module name will be incorrect). We do 6553 - # this by putting the import library name into $newdlprefiles. 6554 - # We recover the dlopen module name by 'saving' the la file 6555 - # name in a special purpose variable, and (later) extracting the 6556 - # dlname from the la file. 6557 - if test -n "$dlname"; then 6558 - func_tr_sh "$dir/$linklib" 6559 - eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6560 - func_append newdlprefiles " $dir/$linklib" 6561 - else 6562 - func_append newdlprefiles " $dir/$old_library" 6563 - # Keep a list of preopened convenience libraries to check 6564 - # that they are being used correctly in the link pass. 6565 - test -z "$libdir" && \ 6566 - func_append dlpreconveniencelibs " $dir/$old_library" 6567 - fi 6568 - ;; 6569 - * ) 6570 - # Prefer using a static library (so that no silly _DYNAMIC symbols 6571 - # are required to link). 6572 - if test -n "$old_library"; then 6573 - func_append newdlprefiles " $dir/$old_library" 6574 - # Keep a list of preopened convenience libraries to check 6575 - # that they are being used correctly in the link pass. 6576 - test -z "$libdir" && \ 6577 - func_append dlpreconveniencelibs " $dir/$old_library" 6578 - # Otherwise, use the dlname, so that lt_dlopen finds it. 6579 - elif test -n "$dlname"; then 6580 - func_append newdlprefiles " $dir/$dlname" 6581 - else 6582 - func_append newdlprefiles " $dir/$linklib" 6583 - fi 6584 - ;; 6585 - esac 6586 - fi # $pass = dlpreopen 6587 - 6588 - if test -z "$libdir"; then 6589 - # Link the convenience library 6590 - if test "$linkmode" = lib; then 6591 - deplibs="$dir/$old_library $deplibs" 6592 - elif test "$linkmode,$pass" = "prog,link"; then 6593 - compile_deplibs="$dir/$old_library $compile_deplibs" 6594 - finalize_deplibs="$dir/$old_library $finalize_deplibs" 6595 - else 6596 - deplibs="$lib $deplibs" # used for prog,scan pass 6597 - fi 6598 - continue 6599 - fi 6600 - 6601 - 6602 - if test "$linkmode" = prog && test "$pass" != link; then 6603 - func_append newlib_search_path " $ladir" 6604 - deplibs="$lib $deplibs" 6605 - 6606 - linkalldeplibs=no 6607 - if test "$link_all_deplibs" != no || test -z "$library_names" || 6608 - test "$build_libtool_libs" = no; then 6609 - linkalldeplibs=yes 6610 - fi 6611 - 6612 - tmp_libs= 6613 - for deplib in $dependency_libs; do 6614 - case $deplib in 6615 - -L*) func_stripname '-L' '' "$deplib" 6616 - func_resolve_sysroot "$func_stripname_result" 6617 - func_append newlib_search_path " $func_resolve_sysroot_result" 6618 - ;; 6619 - esac 6620 - # Need to link against all dependency_libs? 6621 - if test "$linkalldeplibs" = yes; then 6622 - deplibs="$deplib $deplibs" 6623 - else 6624 - # Need to hardcode shared library paths 6625 - # or/and link against static libraries 6626 - newdependency_libs="$deplib $newdependency_libs" 6627 - fi 6628 - if $opt_preserve_dup_deps ; then 6629 - case "$tmp_libs " in 6630 - *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6631 - esac 6632 - fi 6633 - func_append tmp_libs " $deplib" 6634 - done # for deplib 6635 - continue 6636 - fi # $linkmode = prog... 6637 - 6638 - if test "$linkmode,$pass" = "prog,link"; then 6639 - if test -n "$library_names" && 6640 - { { test "$prefer_static_libs" = no || 6641 - test "$prefer_static_libs,$installed" = "built,yes"; } || 6642 - test -z "$old_library"; }; then 6643 - # We need to hardcode the library path 6644 - if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6645 - # Make sure the rpath contains only unique directories. 6646 - case "$temp_rpath:" in 6647 - *"$absdir:"*) ;; 6648 - *) func_append temp_rpath "$absdir:" ;; 6649 - esac 6650 - fi 6651 - 6652 - # Hardcode the library path. 6653 - # Skip directories that are in the system default run-time 6654 - # search path. 6655 - case " $sys_lib_dlsearch_path " in 6656 - *" $absdir "*) ;; 6657 - *) 6658 - case "$compile_rpath " in 6659 - *" $absdir "*) ;; 6660 - *) func_append compile_rpath " $absdir" ;; 6661 - esac 6662 - ;; 6663 - esac 6664 - case " $sys_lib_dlsearch_path " in 6665 - *" $libdir "*) ;; 6666 - *) 6667 - case "$finalize_rpath " in 6668 - *" $libdir "*) ;; 6669 - *) func_append finalize_rpath " $libdir" ;; 6670 - esac 6671 - ;; 6672 - esac 6673 - fi # $linkmode,$pass = prog,link... 6674 - 6675 - if test "$alldeplibs" = yes && 6676 - { test "$deplibs_check_method" = pass_all || 6677 - { test "$build_libtool_libs" = yes && 6678 - test -n "$library_names"; }; }; then 6679 - # We only need to search for static libraries 6680 - continue 6681 - fi 6682 - fi 6683 - 6684 - link_static=no # Whether the deplib will be linked statically 6685 - use_static_libs=$prefer_static_libs 6686 - if test "$use_static_libs" = built && test "$installed" = yes; then 6687 - use_static_libs=no 6688 - fi 6689 - if test -n "$library_names" && 6690 - { test "$use_static_libs" = no || test -z "$old_library"; }; then 6691 - case $host in 6692 - *cygwin* | *mingw* | *cegcc*) 6693 - # No point in relinking DLLs because paths are not encoded 6694 - func_append notinst_deplibs " $lib" 6695 - need_relink=no 6696 - ;; 6697 - *) 6698 - if test "$installed" = no; then 6699 - func_append notinst_deplibs " $lib" 6700 - need_relink=yes 6701 - fi 6702 - ;; 6703 - esac 6704 - # This is a shared library 6705 - 6706 - # Warn about portability, can't link against -module's on some 6707 - # systems (darwin). Don't bleat about dlopened modules though! 6708 - dlopenmodule="" 6709 - for dlpremoduletest in $dlprefiles; do 6710 - if test "X$dlpremoduletest" = "X$lib"; then 6711 - dlopenmodule="$dlpremoduletest" 6712 - break 6713 - fi 6714 - done 6715 - if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6716 - echo 6717 - if test "$linkmode" = prog; then 6718 - $ECHO "*** Warning: Linking the executable $output against the loadable module" 6719 - else 6720 - $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6721 - fi 6722 - $ECHO "*** $linklib is not portable!" 6723 - fi 6724 - if test "$linkmode" = lib && 6725 - test "$hardcode_into_libs" = yes; then 6726 - # Hardcode the library path. 6727 - # Skip directories that are in the system default run-time 6728 - # search path. 6729 - case " $sys_lib_dlsearch_path " in 6730 - *" $absdir "*) ;; 6731 - *) 6732 - case "$compile_rpath " in 6733 - *" $absdir "*) ;; 6734 - *) func_append compile_rpath " $absdir" ;; 6735 - esac 6736 - ;; 6737 - esac 6738 - case " $sys_lib_dlsearch_path " in 6739 - *" $libdir "*) ;; 6740 - *) 6741 - case "$finalize_rpath " in 6742 - *" $libdir "*) ;; 6743 - *) func_append finalize_rpath " $libdir" ;; 6744 - esac 6745 - ;; 6746 - esac 6747 - fi 6748 - 6749 - if test -n "$old_archive_from_expsyms_cmds"; then 6750 - # figure out the soname 6751 - set dummy $library_names 6752 - shift 6753 - realname="$1" 6754 - shift 6755 - libname=`eval "\\$ECHO \"$libname_spec\""` 6756 - # use dlname if we got it. it's perfectly good, no? 6757 - if test -n "$dlname"; then 6758 - soname="$dlname" 6759 - elif test -n "$soname_spec"; then 6760 - # bleh windows 6761 - case $host in 6762 - *cygwin* | mingw* | *cegcc*) 6763 - func_arith $current - $age 6764 - major=$func_arith_result 6765 - versuffix="-$major" 6766 - ;; 6767 - esac 6768 - eval soname=\"$soname_spec\" 6769 - else 6770 - soname="$realname" 6771 - fi 6772 - 6773 - # Make a new name for the extract_expsyms_cmds to use 6774 - soroot="$soname" 6775 - func_basename "$soroot" 6776 - soname="$func_basename_result" 6777 - func_stripname 'lib' '.dll' "$soname" 6778 - newlib=libimp-$func_stripname_result.a 6779 - 6780 - # If the library has no export list, then create one now 6781 - if test -f "$output_objdir/$soname-def"; then : 6782 - else 6783 - func_verbose "extracting exported symbol list from \`$soname'" 6784 - func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6785 - fi 6786 - 6787 - # Create $newlib 6788 - if test -f "$output_objdir/$newlib"; then :; else 6789 - func_verbose "generating import library for \`$soname'" 6790 - func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6791 - fi 6792 - # make sure the library variables are pointing to the new library 6793 - dir=$output_objdir 6794 - linklib=$newlib 6795 - fi # test -n "$old_archive_from_expsyms_cmds" 6796 - 6797 - if test "$linkmode" = prog || test "$opt_mode" != relink; then 6798 - add_shlibpath= 6799 - add_dir= 6800 - add= 6801 - lib_linked=yes 6802 - case $hardcode_action in 6803 - immediate | unsupported) 6804 - if test "$hardcode_direct" = no; then 6805 - add="$dir/$linklib" 6806 - case $host in 6807 - *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6808 - *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6809 - *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6810 - *-*-unixware7*) add_dir="-L$dir" ;; 6811 - *-*-darwin* ) 6812 - # if the lib is a (non-dlopened) module then we can not 6813 - # link against it, someone is ignoring the earlier warnings 6814 - if /usr/bin/file -L $add 2> /dev/null | 6815 - $GREP ": [^:]* bundle" >/dev/null ; then 6816 - if test "X$dlopenmodule" != "X$lib"; then 6817 - $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6818 - if test -z "$old_library" ; then 6819 - echo 6820 - echo "*** And there doesn't seem to be a static archive available" 6821 - echo "*** The link will probably fail, sorry" 6822 - else 6823 - add="$dir/$old_library" 6824 - fi 6825 - elif test -n "$old_library"; then 6826 - add="$dir/$old_library" 6827 - fi 6828 - fi 6829 - esac 6830 - elif test "$hardcode_minus_L" = no; then 6831 - case $host in 6832 - *-*-sunos*) add_shlibpath="$dir" ;; 6833 - esac 6834 - add_dir="-L$dir" 6835 - add="-l$name" 6836 - elif test "$hardcode_shlibpath_var" = no; then 6837 - add_shlibpath="$dir" 6838 - add="-l$name" 6839 - else 6840 - lib_linked=no 6841 - fi 6842 - ;; 6843 - relink) 6844 - if test "$hardcode_direct" = yes && 6845 - test "$hardcode_direct_absolute" = no; then 6846 - add="$dir/$linklib" 6847 - elif test "$hardcode_minus_L" = yes; then 6848 - add_dir="-L$absdir" 6849 - # Try looking first in the location we're being installed to. 6850 - if test -n "$inst_prefix_dir"; then 6851 - case $libdir in 6852 - [\\/]*) 6853 - func_append add_dir " -L$inst_prefix_dir$libdir" 6854 - ;; 6855 - esac 6856 - fi 6857 - add="-l$name" 6858 - elif test "$hardcode_shlibpath_var" = yes; then 6859 - add_shlibpath="$dir" 6860 - add="-l$name" 6861 - else 6862 - lib_linked=no 6863 - fi 6864 - ;; 6865 - *) lib_linked=no ;; 6866 - esac 6867 - 6868 - if test "$lib_linked" != yes; then 6869 - func_fatal_configuration "unsupported hardcode properties" 6870 - fi 6871 - 6872 - if test -n "$add_shlibpath"; then 6873 - case :$compile_shlibpath: in 6874 - *":$add_shlibpath:"*) ;; 6875 - *) func_append compile_shlibpath "$add_shlibpath:" ;; 6876 - esac 6877 - fi 6878 - if test "$linkmode" = prog; then 6879 - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6880 - test -n "$add" && compile_deplibs="$add $compile_deplibs" 6881 - else 6882 - test -n "$add_dir" && deplibs="$add_dir $deplibs" 6883 - test -n "$add" && deplibs="$add $deplibs" 6884 - if test "$hardcode_direct" != yes && 6885 - test "$hardcode_minus_L" != yes && 6886 - test "$hardcode_shlibpath_var" = yes; then 6887 - case :$finalize_shlibpath: in 6888 - *":$libdir:"*) ;; 6889 - *) func_append finalize_shlibpath "$libdir:" ;; 6890 - esac 6891 - fi 6892 - fi 6893 - fi 6894 - 6895 - if test "$linkmode" = prog || test "$opt_mode" = relink; then 6896 - add_shlibpath= 6897 - add_dir= 6898 - add= 6899 - # Finalize command for both is simple: just hardcode it. 6900 - if test "$hardcode_direct" = yes && 6901 - test "$hardcode_direct_absolute" = no; then 6902 - add="$libdir/$linklib" 6903 - elif test "$hardcode_minus_L" = yes; then 6904 - add_dir="-L$libdir" 6905 - add="-l$name" 6906 - elif test "$hardcode_shlibpath_var" = yes; then 6907 - case :$finalize_shlibpath: in 6908 - *":$libdir:"*) ;; 6909 - *) func_append finalize_shlibpath "$libdir:" ;; 6910 - esac 6911 - add="-l$name" 6912 - elif test "$hardcode_automatic" = yes; then 6913 - if test -n "$inst_prefix_dir" && 6914 - test -f "$inst_prefix_dir$libdir/$linklib" ; then 6915 - add="$inst_prefix_dir$libdir/$linklib" 6916 - else 6917 - add="$libdir/$linklib" 6918 - fi 6919 - else 6920 - # We cannot seem to hardcode it, guess we'll fake it. 6921 - add_dir="-L$libdir" 6922 - # Try looking first in the location we're being installed to. 6923 - if test -n "$inst_prefix_dir"; then 6924 - case $libdir in 6925 - [\\/]*) 6926 - func_append add_dir " -L$inst_prefix_dir$libdir" 6927 - ;; 6928 - esac 6929 - fi 6930 - add="-l$name" 6931 - fi 6932 - 6933 - if test "$linkmode" = prog; then 6934 - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6935 - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6936 - else 6937 - test -n "$add_dir" && deplibs="$add_dir $deplibs" 6938 - test -n "$add" && deplibs="$add $deplibs" 6939 - fi 6940 - fi 6941 - elif test "$linkmode" = prog; then 6942 - # Here we assume that one of hardcode_direct or hardcode_minus_L 6943 - # is not unsupported. This is valid on all known static and 6944 - # shared platforms. 6945 - if test "$hardcode_direct" != unsupported; then 6946 - test -n "$old_library" && linklib="$old_library" 6947 - compile_deplibs="$dir/$linklib $compile_deplibs" 6948 - finalize_deplibs="$dir/$linklib $finalize_deplibs" 6949 - else 6950 - compile_deplibs="-l$name -L$dir $compile_deplibs" 6951 - finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6952 - fi 6953 - elif test "$build_libtool_libs" = yes; then 6954 - # Not a shared library 6955 - if test "$deplibs_check_method" != pass_all; then 6956 - # We're trying link a shared library against a static one 6957 - # but the system doesn't support it. 6958 - 6959 - # Just print a warning and add the library to dependency_libs so 6960 - # that the program can be linked against the static library. 6961 - echo 6962 - $ECHO "*** Warning: This system can not link to static lib archive $lib." 6963 - echo "*** I have the capability to make that library automatically link in when" 6964 - echo "*** you link to this library. But I can only do this if you have a" 6965 - echo "*** shared version of the library, which you do not appear to have." 6966 - if test "$module" = yes; then 6967 - echo "*** But as you try to build a module library, libtool will still create " 6968 - echo "*** a static module, that should work as long as the dlopening application" 6969 - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6970 - if test -z "$global_symbol_pipe"; then 6971 - echo 6972 - echo "*** However, this would only work if libtool was able to extract symbol" 6973 - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6974 - echo "*** not find such a program. So, this module is probably useless." 6975 - echo "*** \`nm' from GNU binutils and a full rebuild may help." 6976 - fi 6977 - if test "$build_old_libs" = no; then 6978 - build_libtool_libs=module 6979 - build_old_libs=yes 6980 - else 6981 - build_libtool_libs=no 6982 - fi 6983 - fi 6984 - else 6985 - deplibs="$dir/$old_library $deplibs" 6986 - link_static=yes 6987 - fi 6988 - fi # link shared/static library? 6989 - 6990 - if test "$linkmode" = lib; then 6991 - if test -n "$dependency_libs" && 6992 - { test "$hardcode_into_libs" != yes || 6993 - test "$build_old_libs" = yes || 6994 - test "$link_static" = yes; }; then 6995 - # Extract -R from dependency_libs 6996 - temp_deplibs= 6997 - for libdir in $dependency_libs; do 6998 - case $libdir in 6999 - -R*) func_stripname '-R' '' "$libdir" 7000 - temp_xrpath=$func_stripname_result 7001 - case " $xrpath " in 7002 - *" $temp_xrpath "*) ;; 7003 - *) func_append xrpath " $temp_xrpath";; 7004 - esac;; 7005 - *) func_append temp_deplibs " $libdir";; 7006 - esac 7007 - done 7008 - dependency_libs="$temp_deplibs" 7009 - fi 7010 - 7011 - func_append newlib_search_path " $absdir" 7012 - # Link against this library 7013 - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7014 - # ... and its dependency_libs 7015 - tmp_libs= 7016 - for deplib in $dependency_libs; do 7017 - newdependency_libs="$deplib $newdependency_libs" 7018 - case $deplib in 7019 - -L*) func_stripname '-L' '' "$deplib" 7020 - func_resolve_sysroot "$func_stripname_result";; 7021 - *) func_resolve_sysroot "$deplib" ;; 7022 - esac 7023 - if $opt_preserve_dup_deps ; then 7024 - case "$tmp_libs " in 7025 - *" $func_resolve_sysroot_result "*) 7026 - func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7027 - esac 7028 - fi 7029 - func_append tmp_libs " $func_resolve_sysroot_result" 7030 - done 7031 - 7032 - if test "$link_all_deplibs" != no; then 7033 - # Add the search paths of all dependency libraries 7034 - for deplib in $dependency_libs; do 7035 - path= 7036 - case $deplib in 7037 - -L*) path="$deplib" ;; 7038 - *.la) 7039 - func_resolve_sysroot "$deplib" 7040 - deplib=$func_resolve_sysroot_result 7041 - func_dirname "$deplib" "" "." 7042 - dir=$func_dirname_result 7043 - # We need an absolute path. 7044 - case $dir in 7045 - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7046 - *) 7047 - absdir=`cd "$dir" && pwd` 7048 - if test -z "$absdir"; then 7049 - func_warning "cannot determine absolute directory name of \`$dir'" 7050 - absdir="$dir" 7051 - fi 7052 - ;; 7053 - esac 7054 - if $GREP "^installed=no" $deplib > /dev/null; then 7055 - case $host in 7056 - *-*-darwin*) 7057 - depdepl= 7058 - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7059 - if test -n "$deplibrary_names" ; then 7060 - for tmp in $deplibrary_names ; do 7061 - depdepl=$tmp 7062 - done 7063 - if test -f "$absdir/$objdir/$depdepl" ; then 7064 - depdepl="$absdir/$objdir/$depdepl" 7065 - darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7066 - if test -z "$darwin_install_name"; then 7067 - darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7068 - fi 7069 - func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7070 - func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7071 - path= 7072 - fi 7073 - fi 7074 - ;; 7075 - *) 7076 - path="-L$absdir/$objdir" 7077 - ;; 7078 - esac 7079 - else 7080 - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7081 - test -z "$libdir" && \ 7082 - func_fatal_error "\`$deplib' is not a valid libtool archive" 7083 - test "$absdir" != "$libdir" && \ 7084 - func_warning "\`$deplib' seems to be moved" 7085 - 7086 - path="-L$absdir" 7087 - fi 7088 - ;; 7089 - esac 7090 - case " $deplibs " in 7091 - *" $path "*) ;; 7092 - *) deplibs="$path $deplibs" ;; 7093 - esac 7094 - done 7095 - fi # link_all_deplibs != no 7096 - fi # linkmode = lib 7097 - done # for deplib in $libs 7098 - if test "$pass" = link; then 7099 - if test "$linkmode" = "prog"; then 7100 - compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7101 - finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7102 - else 7103 - compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7104 - fi 7105 - fi 7106 - dependency_libs="$newdependency_libs" 7107 - if test "$pass" = dlpreopen; then 7108 - # Link the dlpreopened libraries before other libraries 7109 - for deplib in $save_deplibs; do 7110 - deplibs="$deplib $deplibs" 7111 - done 7112 - fi 7113 - if test "$pass" != dlopen; then 7114 - if test "$pass" != conv; then 7115 - # Make sure lib_search_path contains only unique directories. 7116 - lib_search_path= 7117 - for dir in $newlib_search_path; do 7118 - case "$lib_search_path " in 7119 - *" $dir "*) ;; 7120 - *) func_append lib_search_path " $dir" ;; 7121 - esac 7122 - done 7123 - newlib_search_path= 7124 - fi 7125 - 7126 - if test "$linkmode,$pass" != "prog,link"; then 7127 - vars="deplibs" 7128 - else 7129 - vars="compile_deplibs finalize_deplibs" 7130 - fi 7131 - for var in $vars dependency_libs; do 7132 - # Add libraries to $var in reverse order 7133 - eval tmp_libs=\"\$$var\" 7134 - new_libs= 7135 - for deplib in $tmp_libs; do 7136 - # FIXME: Pedantically, this is the right thing to do, so 7137 - # that some nasty dependency loop isn't accidentally 7138 - # broken: 7139 - #new_libs="$deplib $new_libs" 7140 - # Pragmatically, this seems to cause very few problems in 7141 - # practice: 7142 - case $deplib in 7143 - -L*) new_libs="$deplib $new_libs" ;; 7144 - -R*) ;; 7145 - *) 7146 - # And here is the reason: when a library appears more 7147 - # than once as an explicit dependence of a library, or 7148 - # is implicitly linked in more than once by the 7149 - # compiler, it is considered special, and multiple 7150 - # occurrences thereof are not removed. Compare this 7151 - # with having the same library being listed as a 7152 - # dependency of multiple other libraries: in this case, 7153 - # we know (pedantically, we assume) the library does not 7154 - # need to be listed more than once, so we keep only the 7155 - # last copy. This is not always right, but it is rare 7156 - # enough that we require users that really mean to play 7157 - # such unportable linking tricks to link the library 7158 - # using -Wl,-lname, so that libtool does not consider it 7159 - # for duplicate removal. 7160 - case " $specialdeplibs " in 7161 - *" $deplib "*) new_libs="$deplib $new_libs" ;; 7162 - *) 7163 - case " $new_libs " in 7164 - *" $deplib "*) ;; 7165 - *) new_libs="$deplib $new_libs" ;; 7166 - esac 7167 - ;; 7168 - esac 7169 - ;; 7170 - esac 7171 - done 7172 - tmp_libs= 7173 - for deplib in $new_libs; do 7174 - case $deplib in 7175 - -L*) 7176 - case " $tmp_libs " in 7177 - *" $deplib "*) ;; 7178 - *) func_append tmp_libs " $deplib" ;; 7179 - esac 7180 - ;; 7181 - *) func_append tmp_libs " $deplib" ;; 7182 - esac 7183 - done 7184 - eval $var=\"$tmp_libs\" 7185 - done # for var 7186 - fi 7187 - # Last step: remove runtime libs from dependency_libs 7188 - # (they stay in deplibs) 7189 - tmp_libs= 7190 - for i in $dependency_libs ; do 7191 - case " $predeps $postdeps $compiler_lib_search_path " in 7192 - *" $i "*) 7193 - i="" 7194 - ;; 7195 - esac 7196 - if test -n "$i" ; then 7197 - func_append tmp_libs " $i" 7198 - fi 7199 - done 7200 - dependency_libs=$tmp_libs 7201 - done # for pass 7202 - if test "$linkmode" = prog; then 7203 - dlfiles="$newdlfiles" 7204 - fi 7205 - if test "$linkmode" = prog || test "$linkmode" = lib; then 7206 - dlprefiles="$newdlprefiles" 7207 - fi 7208 - 7209 - case $linkmode in 7210 - oldlib) 7211 - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7212 - func_warning "\`-dlopen' is ignored for archives" 7213 - fi 7214 - 7215 - case " $deplibs" in 7216 - *\ -l* | *\ -L*) 7217 - func_warning "\`-l' and \`-L' are ignored for archives" ;; 7218 - esac 7219 - 7220 - test -n "$rpath" && \ 7221 - func_warning "\`-rpath' is ignored for archives" 7222 - 7223 - test -n "$xrpath" && \ 7224 - func_warning "\`-R' is ignored for archives" 7225 - 7226 - test -n "$vinfo" && \ 7227 - func_warning "\`-version-info/-version-number' is ignored for archives" 7228 - 7229 - test -n "$release" && \ 7230 - func_warning "\`-release' is ignored for archives" 7231 - 7232 - test -n "$export_symbols$export_symbols_regex" && \ 7233 - func_warning "\`-export-symbols' is ignored for archives" 7234 - 7235 - # Now set the variables for building old libraries. 7236 - build_libtool_libs=no 7237 - oldlibs="$output" 7238 - func_append objs "$old_deplibs" 7239 - ;; 7240 - 7241 - lib) 7242 - # Make sure we only generate libraries of the form `libNAME.la'. 7243 - case $outputname in 7244 - lib*) 7245 - func_stripname 'lib' '.la' "$outputname" 7246 - name=$func_stripname_result 7247 - eval shared_ext=\"$shrext_cmds\" 7248 - eval libname=\"$libname_spec\" 7249 - ;; 7250 - *) 7251 - test "$module" = no && \ 7252 - func_fatal_help "libtool library \`$output' must begin with \`lib'" 7253 - 7254 - if test "$need_lib_prefix" != no; then 7255 - # Add the "lib" prefix for modules if required 7256 - func_stripname '' '.la' "$outputname" 7257 - name=$func_stripname_result 7258 - eval shared_ext=\"$shrext_cmds\" 7259 - eval libname=\"$libname_spec\" 7260 - else 7261 - func_stripname '' '.la' "$outputname" 7262 - libname=$func_stripname_result 7263 - fi 7264 - ;; 7265 - esac 7266 - 7267 - if test -n "$objs"; then 7268 - if test "$deplibs_check_method" != pass_all; then 7269 - func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7270 - else 7271 - echo 7272 - $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7273 - $ECHO "*** objects $objs is not portable!" 7274 - func_append libobjs " $objs" 7275 - fi 7276 - fi 7277 - 7278 - test "$dlself" != no && \ 7279 - func_warning "\`-dlopen self' is ignored for libtool libraries" 7280 - 7281 - set dummy $rpath 7282 - shift 7283 - test "$#" -gt 1 && \ 7284 - func_warning "ignoring multiple \`-rpath's for a libtool library" 7285 - 7286 - install_libdir="$1" 7287 - 7288 - oldlibs= 7289 - if test -z "$rpath"; then 7290 - if test "$build_libtool_libs" = yes; then 7291 - # Building a libtool convenience library. 7292 - # Some compilers have problems with a `.al' extension so 7293 - # convenience libraries should have the same extension an 7294 - # archive normally would. 7295 - oldlibs="$output_objdir/$libname.$libext $oldlibs" 7296 - build_libtool_libs=convenience 7297 - build_old_libs=yes 7298 - fi 7299 - 7300 - test -n "$vinfo" && \ 7301 - func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7302 - 7303 - test -n "$release" && \ 7304 - func_warning "\`-release' is ignored for convenience libraries" 7305 - else 7306 - 7307 - # Parse the version information argument. 7308 - save_ifs="$IFS"; IFS=':' 7309 - set dummy $vinfo 0 0 0 7310 - shift 7311 - IFS="$save_ifs" 7312 - 7313 - test -n "$7" && \ 7314 - func_fatal_help "too many parameters to \`-version-info'" 7315 - 7316 - # convert absolute version numbers to libtool ages 7317 - # this retains compatibility with .la files and attempts 7318 - # to make the code below a bit more comprehensible 7319 - 7320 - case $vinfo_number in 7321 - yes) 7322 - number_major="$1" 7323 - number_minor="$2" 7324 - number_revision="$3" 7325 - # 7326 - # There are really only two kinds -- those that 7327 - # use the current revision as the major version 7328 - # and those that subtract age and use age as 7329 - # a minor version. But, then there is irix 7330 - # which has an extra 1 added just for fun 7331 - # 7332 - case $version_type in 7333 - # correct linux to gnu/linux during the next big refactor 7334 - darwin|linux|osf|windows|none) 7335 - func_arith $number_major + $number_minor 7336 - current=$func_arith_result 7337 - age="$number_minor" 7338 - revision="$number_revision" 7339 - ;; 7340 - freebsd-aout|freebsd-elf|qnx|sunos) 7341 - current="$number_major" 7342 - revision="$number_minor" 7343 - age="0" 7344 - ;; 7345 - irix|nonstopux) 7346 - func_arith $number_major + $number_minor 7347 - current=$func_arith_result 7348 - age="$number_minor" 7349 - revision="$number_minor" 7350 - lt_irix_increment=no 7351 - ;; 7352 - esac 7353 - ;; 7354 - no) 7355 - current="$1" 7356 - revision="$2" 7357 - age="$3" 7358 - ;; 7359 - esac 7360 - 7361 - # Check that each of the things are valid numbers. 7362 - case $current in 7363 - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; 7364 - *) 7365 - func_error "CURRENT \`$current' must be a nonnegative integer" 7366 - func_fatal_error "\`$vinfo' is not valid version information" 7367 - ;; 7368 - esac 7369 - 7370 - case $revision in 7371 - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; 7372 - *) 7373 - func_error "REVISION \`$revision' must be a nonnegative integer" 7374 - func_fatal_error "\`$vinfo' is not valid version information" 7375 - ;; 7376 - esac 7377 - 7378 - case $age in 7379 - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; 7380 - *) 7381 - func_error "AGE \`$age' must be a nonnegative integer" 7382 - func_fatal_error "\`$vinfo' is not valid version information" 7383 - ;; 7384 - esac 7385 - 7386 - if test "$age" -gt "$current"; then 7387 - func_error "AGE \`$age' is greater than the current interface number \`$current'" 7388 - func_fatal_error "\`$vinfo' is not valid version information" 7389 - fi 7390 - 7391 - # Calculate the version variables. 7392 - major= 7393 - versuffix= 7394 - verstring= 7395 - case $version_type in 7396 - none) ;; 7397 - 7398 - darwin) 7399 - # Like Linux, but with the current version available in 7400 - # verstring for coding it into the library header 7401 - func_arith $current - $age 7402 - major=.$func_arith_result 7403 - versuffix="$major.$age.$revision" 7404 - # Darwin ld doesn't like 0 for these options... 7405 - func_arith $current + 1 7406 - minor_current=$func_arith_result 7407 - xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7408 - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7409 - ;; 7410 - 7411 - freebsd-aout) 7412 - major=".$current" 7413 - versuffix=".$current.$revision"; 7414 - ;; 7415 - 7416 - freebsd-elf) 7417 - major=".$current" 7418 - versuffix=".$current" 7419 - ;; 7420 - 7421 - irix | nonstopux) 7422 - if test "X$lt_irix_increment" = "Xno"; then 7423 - func_arith $current - $age 7424 - else 7425 - func_arith $current - $age + 1 7426 - fi 7427 - major=$func_arith_result 7428 - 7429 - case $version_type in 7430 - nonstopux) verstring_prefix=nonstopux ;; 7431 - *) verstring_prefix=sgi ;; 7432 - esac 7433 - verstring="$verstring_prefix$major.$revision" 7434 - 7435 - # Add in all the interfaces that we are compatible with. 7436 - loop=$revision 7437 - while test "$loop" -ne 0; do 7438 - func_arith $revision - $loop 7439 - iface=$func_arith_result 7440 - func_arith $loop - 1 7441 - loop=$func_arith_result 7442 - verstring="$verstring_prefix$major.$iface:$verstring" 7443 - done 7444 - 7445 - # Before this point, $major must not contain `.'. 7446 - major=.$major 7447 - versuffix="$major.$revision" 7448 - ;; 7449 - 7450 - linux) # correct to gnu/linux during the next big refactor 7451 - func_arith $current - $age 7452 - major=.$func_arith_result 7453 - versuffix="$major.$age.$revision" 7454 - ;; 7455 - 7456 - osf) 7457 - func_arith $current - $age 7458 - major=.$func_arith_result 7459 - versuffix=".$current.$age.$revision" 7460 - verstring="$current.$age.$revision" 7461 - 7462 - # Add in all the interfaces that we are compatible with. 7463 - loop=$age 7464 - while test "$loop" -ne 0; do 7465 - func_arith $current - $loop 7466 - iface=$func_arith_result 7467 - func_arith $loop - 1 7468 - loop=$func_arith_result 7469 - verstring="$verstring:${iface}.0" 7470 - done 7471 - 7472 - # Make executables depend on our current version. 7473 - func_append verstring ":${current}.0" 7474 - ;; 7475 - 7476 - qnx) 7477 - major=".$current" 7478 - versuffix=".$current" 7479 - ;; 7480 - 7481 - sunos) 7482 - major=".$current" 7483 - versuffix=".$current.$revision" 7484 - ;; 7485 - 7486 - windows) 7487 - # Use '-' rather than '.', since we only want one 7488 - # extension on DOS 8.3 filesystems. 7489 - func_arith $current - $age 7490 - major=$func_arith_result 7491 - versuffix="-$major" 7492 - ;; 7493 - 7494 - *) 7495 - func_fatal_configuration "unknown library version type \`$version_type'" 7496 - ;; 7497 - esac 7498 - 7499 - # Clear the version info if we defaulted, and they specified a release. 7500 - if test -z "$vinfo" && test -n "$release"; then 7501 - major= 7502 - case $version_type in 7503 - darwin) 7504 - # we can't check for "0.0" in archive_cmds due to quoting 7505 - # problems, so we reset it completely 7506 - verstring= 7507 - ;; 7508 - *) 7509 - verstring="0.0" 7510 - ;; 7511 - esac 7512 - if test "$need_version" = no; then 7513 - versuffix= 7514 - else 7515 - versuffix=".0.0" 7516 - fi 7517 - fi 7518 - 7519 - # Remove version info from name if versioning should be avoided 7520 - if test "$avoid_version" = yes && test "$need_version" = no; then 7521 - major= 7522 - versuffix= 7523 - verstring="" 7524 - fi 7525 - 7526 - # Check to see if the archive will have undefined symbols. 7527 - if test "$allow_undefined" = yes; then 7528 - if test "$allow_undefined_flag" = unsupported; then 7529 - func_warning "undefined symbols not allowed in $host shared libraries" 7530 - build_libtool_libs=no 7531 - build_old_libs=yes 7532 - fi 7533 - else 7534 - # Don't allow undefined symbols. 7535 - allow_undefined_flag="$no_undefined_flag" 7536 - fi 7537 - 7538 - fi 7539 - 7540 - func_generate_dlsyms "$libname" "$libname" "yes" 7541 - func_append libobjs " $symfileobj" 7542 - test "X$libobjs" = "X " && libobjs= 7543 - 7544 - if test "$opt_mode" != relink; then 7545 - # Remove our outputs, but don't remove object files since they 7546 - # may have been created when compiling PIC objects. 7547 - removelist= 7548 - tempremovelist=`$ECHO "$output_objdir/*"` 7549 - for p in $tempremovelist; do 7550 - case $p in 7551 - *.$objext | *.gcno) 7552 - ;; 7553 - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7554 - if test "X$precious_files_regex" != "X"; then 7555 - if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7556 - then 7557 - continue 7558 - fi 7559 - fi 7560 - func_append removelist " $p" 7561 - ;; 7562 - *) ;; 7563 - esac 7564 - done 7565 - test -n "$removelist" && \ 7566 - func_show_eval "${RM}r \$removelist" 7567 - fi 7568 - 7569 - # Now set the variables for building old libraries. 7570 - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7571 - func_append oldlibs " $output_objdir/$libname.$libext" 7572 - 7573 - # Transform .lo files to .o files. 7574 - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7575 - fi 7576 - 7577 - # Eliminate all temporary directories. 7578 - #for path in $notinst_path; do 7579 - # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7580 - # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7581 - # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7582 - #done 7583 - 7584 - if test -n "$xrpath"; then 7585 - # If the user specified any rpath flags, then add them. 7586 - temp_xrpath= 7587 - for libdir in $xrpath; do 7588 - func_replace_sysroot "$libdir" 7589 - func_append temp_xrpath " -R$func_replace_sysroot_result" 7590 - case "$finalize_rpath " in 7591 - *" $libdir "*) ;; 7592 - *) func_append finalize_rpath " $libdir" ;; 7593 - esac 7594 - done 7595 - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7596 - dependency_libs="$temp_xrpath $dependency_libs" 7597 - fi 7598 - fi 7599 - 7600 - # Make sure dlfiles contains only unique files that won't be dlpreopened 7601 - old_dlfiles="$dlfiles" 7602 - dlfiles= 7603 - for lib in $old_dlfiles; do 7604 - case " $dlprefiles $dlfiles " in 7605 - *" $lib "*) ;; 7606 - *) func_append dlfiles " $lib" ;; 7607 - esac 7608 - done 7609 - 7610 - # Make sure dlprefiles contains only unique files 7611 - old_dlprefiles="$dlprefiles" 7612 - dlprefiles= 7613 - for lib in $old_dlprefiles; do 7614 - case "$dlprefiles " in 7615 - *" $lib "*) ;; 7616 - *) func_append dlprefiles " $lib" ;; 7617 - esac 7618 - done 7619 - 7620 - if test "$build_libtool_libs" = yes; then 7621 - if test -n "$rpath"; then 7622 - case $host in 7623 - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7624 - # these systems don't actually have a c library (as such)! 7625 - ;; 7626 - *-*-rhapsody* | *-*-darwin1.[012]) 7627 - # Rhapsody C library is in the System framework 7628 - func_append deplibs " System.ltframework" 7629 - ;; 7630 - *-*-netbsd*) 7631 - # Don't link with libc until the a.out ld.so is fixed. 7632 - ;; 7633 - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7634 - # Do not include libc due to us having libc/libc_r. 7635 - ;; 7636 - *-*-sco3.2v5* | *-*-sco5v6*) 7637 - # Causes problems with __ctype 7638 - ;; 7639 - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7640 - # Compiler inserts libc in the correct place for threads to work 7641 - ;; 7642 - *) 7643 - # Add libc to deplibs on all other systems if necessary. 7644 - if test "$build_libtool_need_lc" = "yes"; then 7645 - func_append deplibs " -lc" 7646 - fi 7647 - ;; 7648 - esac 7649 - fi 7650 - 7651 - # Transform deplibs into only deplibs that can be linked in shared. 7652 - name_save=$name 7653 - libname_save=$libname 7654 - release_save=$release 7655 - versuffix_save=$versuffix 7656 - major_save=$major 7657 - # I'm not sure if I'm treating the release correctly. I think 7658 - # release should show up in the -l (ie -lgmp5) so we don't want to 7659 - # add it in twice. Is that correct? 7660 - release="" 7661 - versuffix="" 7662 - major="" 7663 - newdeplibs= 7664 - droppeddeps=no 7665 - case $deplibs_check_method in 7666 - pass_all) 7667 - # Don't check for shared/static. Everything works. 7668 - # This might be a little naive. We might want to check 7669 - # whether the library exists or not. But this is on 7670 - # osf3 & osf4 and I'm not really sure... Just 7671 - # implementing what was already the behavior. 7672 - newdeplibs=$deplibs 7673 - ;; 7674 - test_compile) 7675 - # This code stresses the "libraries are programs" paradigm to its 7676 - # limits. Maybe even breaks it. We compile a program, linking it 7677 - # against the deplibs as a proxy for the library. Then we can check 7678 - # whether they linked in statically or dynamically with ldd. 7679 - $opt_dry_run || $RM conftest.c 7680 - cat > conftest.c <<EOF 7681 - int main() { return 0; } 7682 -EOF 7683 - $opt_dry_run || $RM conftest 7684 - if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7685 - ldd_output=`ldd conftest` 7686 - for i in $deplibs; do 7687 - case $i in 7688 - -l*) 7689 - func_stripname -l '' "$i" 7690 - name=$func_stripname_result 7691 - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7692 - case " $predeps $postdeps " in 7693 - *" $i "*) 7694 - func_append newdeplibs " $i" 7695 - i="" 7696 - ;; 7697 - esac 7698 - fi 7699 - if test -n "$i" ; then 7700 - libname=`eval "\\$ECHO \"$libname_spec\""` 7701 - deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7702 - set dummy $deplib_matches; shift 7703 - deplib_match=$1 7704 - if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7705 - func_append newdeplibs " $i" 7706 - else 7707 - droppeddeps=yes 7708 - echo 7709 - $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7710 - echo "*** I have the capability to make that library automatically link in when" 7711 - echo "*** you link to this library. But I can only do this if you have a" 7712 - echo "*** shared version of the library, which I believe you do not have" 7713 - echo "*** because a test_compile did reveal that the linker did not use it for" 7714 - echo "*** its dynamic dependency list that programs get resolved with at runtime." 7715 - fi 7716 - fi 7717 - ;; 7718 - *) 7719 - func_append newdeplibs " $i" 7720 - ;; 7721 - esac 7722 - done 7723 - else 7724 - # Error occurred in the first compile. Let's try to salvage 7725 - # the situation: Compile a separate program for each library. 7726 - for i in $deplibs; do 7727 - case $i in 7728 - -l*) 7729 - func_stripname -l '' "$i" 7730 - name=$func_stripname_result 7731 - $opt_dry_run || $RM conftest 7732 - if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7733 - ldd_output=`ldd conftest` 7734 - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7735 - case " $predeps $postdeps " in 7736 - *" $i "*) 7737 - func_append newdeplibs " $i" 7738 - i="" 7739 - ;; 7740 - esac 7741 - fi 7742 - if test -n "$i" ; then 7743 - libname=`eval "\\$ECHO \"$libname_spec\""` 7744 - deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7745 - set dummy $deplib_matches; shift 7746 - deplib_match=$1 7747 - if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7748 - func_append newdeplibs " $i" 7749 - else 7750 - droppeddeps=yes 7751 - echo 7752 - $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7753 - echo "*** I have the capability to make that library automatically link in when" 7754 - echo "*** you link to this library. But I can only do this if you have a" 7755 - echo "*** shared version of the library, which you do not appear to have" 7756 - echo "*** because a test_compile did reveal that the linker did not use this one" 7757 - echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7758 - fi 7759 - fi 7760 - else 7761 - droppeddeps=yes 7762 - echo 7763 - $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7764 - echo "*** make it link in! You will probably need to install it or some" 7765 - echo "*** library that it depends on before this library will be fully" 7766 - echo "*** functional. Installing it before continuing would be even better." 7767 - fi 7768 - ;; 7769 - *) 7770 - func_append newdeplibs " $i" 7771 - ;; 7772 - esac 7773 - done 7774 - fi 7775 - ;; 7776 - file_magic*) 7777 - set dummy $deplibs_check_method; shift 7778 - file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7779 - for a_deplib in $deplibs; do 7780 - case $a_deplib in 7781 - -l*) 7782 - func_stripname -l '' "$a_deplib" 7783 - name=$func_stripname_result 7784 - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7785 - case " $predeps $postdeps " in 7786 - *" $a_deplib "*) 7787 - func_append newdeplibs " $a_deplib" 7788 - a_deplib="" 7789 - ;; 7790 - esac 7791 - fi 7792 - if test -n "$a_deplib" ; then 7793 - libname=`eval "\\$ECHO \"$libname_spec\""` 7794 - if test -n "$file_magic_glob"; then 7795 - libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7796 - else 7797 - libnameglob=$libname 7798 - fi 7799 - test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7800 - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7801 - if test "$want_nocaseglob" = yes; then 7802 - shopt -s nocaseglob 7803 - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7804 - $nocaseglob 7805 - else 7806 - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7807 - fi 7808 - for potent_lib in $potential_libs; do 7809 - # Follow soft links. 7810 - if ls -lLd "$potent_lib" 2>/dev/null | 7811 - $GREP " -> " >/dev/null; then 7812 - continue 7813 - fi 7814 - # The statement above tries to avoid entering an 7815 - # endless loop below, in case of cyclic links. 7816 - # We might still enter an endless loop, since a link 7817 - # loop can be closed while we follow links, 7818 - # but so what? 7819 - potlib="$potent_lib" 7820 - while test -h "$potlib" 2>/dev/null; do 7821 - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7822 - case $potliblink in 7823 - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7824 - *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7825 - esac 7826 - done 7827 - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7828 - $SED -e 10q | 7829 - $EGREP "$file_magic_regex" > /dev/null; then 7830 - func_append newdeplibs " $a_deplib" 7831 - a_deplib="" 7832 - break 2 7833 - fi 7834 - done 7835 - done 7836 - fi 7837 - if test -n "$a_deplib" ; then 7838 - droppeddeps=yes 7839 - echo 7840 - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7841 - echo "*** I have the capability to make that library automatically link in when" 7842 - echo "*** you link to this library. But I can only do this if you have a" 7843 - echo "*** shared version of the library, which you do not appear to have" 7844 - echo "*** because I did check the linker path looking for a file starting" 7845 - if test -z "$potlib" ; then 7846 - $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7847 - else 7848 - $ECHO "*** with $libname and none of the candidates passed a file format test" 7849 - $ECHO "*** using a file magic. Last file checked: $potlib" 7850 - fi 7851 - fi 7852 - ;; 7853 - *) 7854 - # Add a -L argument. 7855 - func_append newdeplibs " $a_deplib" 7856 - ;; 7857 - esac 7858 - done # Gone through all deplibs. 7859 - ;; 7860 - match_pattern*) 7861 - set dummy $deplibs_check_method; shift 7862 - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7863 - for a_deplib in $deplibs; do 7864 - case $a_deplib in 7865 - -l*) 7866 - func_stripname -l '' "$a_deplib" 7867 - name=$func_stripname_result 7868 - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7869 - case " $predeps $postdeps " in 7870 - *" $a_deplib "*) 7871 - func_append newdeplibs " $a_deplib" 7872 - a_deplib="" 7873 - ;; 7874 - esac 7875 - fi 7876 - if test -n "$a_deplib" ; then 7877 - libname=`eval "\\$ECHO \"$libname_spec\""` 7878 - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7879 - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7880 - for potent_lib in $potential_libs; do 7881 - potlib="$potent_lib" # see symlink-check above in file_magic test 7882 - if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7883 - $EGREP "$match_pattern_regex" > /dev/null; then 7884 - func_append newdeplibs " $a_deplib" 7885 - a_deplib="" 7886 - break 2 7887 - fi 7888 - done 7889 - done 7890 - fi 7891 - if test -n "$a_deplib" ; then 7892 - droppeddeps=yes 7893 - echo 7894 - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7895 - echo "*** I have the capability to make that library automatically link in when" 7896 - echo "*** you link to this library. But I can only do this if you have a" 7897 - echo "*** shared version of the library, which you do not appear to have" 7898 - echo "*** because I did check the linker path looking for a file starting" 7899 - if test -z "$potlib" ; then 7900 - $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7901 - else 7902 - $ECHO "*** with $libname and none of the candidates passed a file format test" 7903 - $ECHO "*** using a regex pattern. Last file checked: $potlib" 7904 - fi 7905 - fi 7906 - ;; 7907 - *) 7908 - # Add a -L argument. 7909 - func_append newdeplibs " $a_deplib" 7910 - ;; 7911 - esac 7912 - done # Gone through all deplibs. 7913 - ;; 7914 - none | unknown | *) 7915 - newdeplibs="" 7916 - tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7917 - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7918 - for i in $predeps $postdeps ; do 7919 - # can't use Xsed below, because $i might contain '/' 7920 - tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7921 - done 7922 - fi 7923 - case $tmp_deplibs in 7924 - *[!\ \ ]*) 7925 - echo 7926 - if test "X$deplibs_check_method" = "Xnone"; then 7927 - echo "*** Warning: inter-library dependencies are not supported in this platform." 7928 - else 7929 - echo "*** Warning: inter-library dependencies are not known to be supported." 7930 - fi 7931 - echo "*** All declared inter-library dependencies are being dropped." 7932 - droppeddeps=yes 7933 - ;; 7934 - esac 7935 - ;; 7936 - esac 7937 - versuffix=$versuffix_save 7938 - major=$major_save 7939 - release=$release_save 7940 - libname=$libname_save 7941 - name=$name_save 7942 - 7943 - case $host in 7944 - *-*-rhapsody* | *-*-darwin1.[012]) 7945 - # On Rhapsody replace the C library with the System framework 7946 - newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7947 - ;; 7948 - esac 7949 - 7950 - if test "$droppeddeps" = yes; then 7951 - if test "$module" = yes; then 7952 - echo 7953 - echo "*** Warning: libtool could not satisfy all declared inter-library" 7954 - $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7955 - echo "*** a static module, that should work as long as the dlopening" 7956 - echo "*** application is linked with the -dlopen flag." 7957 - if test -z "$global_symbol_pipe"; then 7958 - echo 7959 - echo "*** However, this would only work if libtool was able to extract symbol" 7960 - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7961 - echo "*** not find such a program. So, this module is probably useless." 7962 - echo "*** \`nm' from GNU binutils and a full rebuild may help." 7963 - fi 7964 - if test "$build_old_libs" = no; then 7965 - oldlibs="$output_objdir/$libname.$libext" 7966 - build_libtool_libs=module 7967 - build_old_libs=yes 7968 - else 7969 - build_libtool_libs=no 7970 - fi 7971 - else 7972 - echo "*** The inter-library dependencies that have been dropped here will be" 7973 - echo "*** automatically added whenever a program is linked with this library" 7974 - echo "*** or is declared to -dlopen it." 7975 - 7976 - if test "$allow_undefined" = no; then 7977 - echo 7978 - echo "*** Since this library must not contain undefined symbols," 7979 - echo "*** because either the platform does not support them or" 7980 - echo "*** it was explicitly requested with -no-undefined," 7981 - echo "*** libtool will only create a static version of it." 7982 - if test "$build_old_libs" = no; then 7983 - oldlibs="$output_objdir/$libname.$libext" 7984 - build_libtool_libs=module 7985 - build_old_libs=yes 7986 - else 7987 - build_libtool_libs=no 7988 - fi 7989 - fi 7990 - fi 7991 - fi 7992 - # Done checking deplibs! 7993 - deplibs=$newdeplibs 7994 - fi 7995 - # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7996 - case $host in 7997 - *-*-darwin*) 7998 - newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7999 - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8000 - deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8001 - ;; 8002 - esac 8003 - 8004 - # move library search paths that coincide with paths to not yet 8005 - # installed libraries to the beginning of the library search list 8006 - new_libs= 8007 - for path in $notinst_path; do 8008 - case " $new_libs " in 8009 - *" -L$path/$objdir "*) ;; 8010 - *) 8011 - case " $deplibs " in 8012 - *" -L$path/$objdir "*) 8013 - func_append new_libs " -L$path/$objdir" ;; 8014 - esac 8015 - ;; 8016 - esac 8017 - done 8018 - for deplib in $deplibs; do 8019 - case $deplib in 8020 - -L*) 8021 - case " $new_libs " in 8022 - *" $deplib "*) ;; 8023 - *) func_append new_libs " $deplib" ;; 8024 - esac 8025 - ;; 8026 - *) func_append new_libs " $deplib" ;; 8027 - esac 8028 - done 8029 - deplibs="$new_libs" 8030 - 8031 - # All the library-specific variables (install_libdir is set above). 8032 - library_names= 8033 - old_library= 8034 - dlname= 8035 - 8036 - # Test again, we may have decided not to build it any more 8037 - if test "$build_libtool_libs" = yes; then 8038 - # Remove ${wl} instances when linking with ld. 8039 - # FIXME: should test the right _cmds variable. 8040 - case $archive_cmds in 8041 - *\$LD\ *) wl= ;; 8042 - esac 8043 - if test "$hardcode_into_libs" = yes; then 8044 - # Hardcode the library paths 8045 - hardcode_libdirs= 8046 - dep_rpath= 8047 - rpath="$finalize_rpath" 8048 - test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8049 - for libdir in $rpath; do 8050 - if test -n "$hardcode_libdir_flag_spec"; then 8051 - if test -n "$hardcode_libdir_separator"; then 8052 - func_replace_sysroot "$libdir" 8053 - libdir=$func_replace_sysroot_result 8054 - if test -z "$hardcode_libdirs"; then 8055 - hardcode_libdirs="$libdir" 8056 - else 8057 - # Just accumulate the unique libdirs. 8058 - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8059 - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8060 - ;; 8061 - *) 8062 - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8063 - ;; 8064 - esac 8065 - fi 8066 - else 8067 - eval flag=\"$hardcode_libdir_flag_spec\" 8068 - func_append dep_rpath " $flag" 8069 - fi 8070 - elif test -n "$runpath_var"; then 8071 - case "$perm_rpath " in 8072 - *" $libdir "*) ;; 8073 - *) func_append perm_rpath " $libdir" ;; 8074 - esac 8075 - fi 8076 - done 8077 - # Substitute the hardcoded libdirs into the rpath. 8078 - if test -n "$hardcode_libdir_separator" && 8079 - test -n "$hardcode_libdirs"; then 8080 - libdir="$hardcode_libdirs" 8081 - eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 8082 - fi 8083 - if test -n "$runpath_var" && test -n "$perm_rpath"; then 8084 - # We should set the runpath_var. 8085 - rpath= 8086 - for dir in $perm_rpath; do 8087 - func_append rpath "$dir:" 8088 - done 8089 - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8090 - fi 8091 - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8092 - fi 8093 - 8094 - shlibpath="$finalize_shlibpath" 8095 - test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8096 - if test -n "$shlibpath"; then 8097 - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8098 - fi 8099 - 8100 - # Get the real and link names of the library. 8101 - eval shared_ext=\"$shrext_cmds\" 8102 - eval library_names=\"$library_names_spec\" 8103 - set dummy $library_names 8104 - shift 8105 - realname="$1" 8106 - shift 8107 - 8108 - if test -n "$soname_spec"; then 8109 - eval soname=\"$soname_spec\" 8110 - else 8111 - soname="$realname" 8112 - fi 8113 - if test -z "$dlname"; then 8114 - dlname=$soname 8115 - fi 8116 - 8117 - lib="$output_objdir/$realname" 8118 - linknames= 8119 - for link 8120 - do 8121 - func_append linknames " $link" 8122 - done 8123 - 8124 - # Use standard objects if they are pic 8125 - test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8126 - test "X$libobjs" = "X " && libobjs= 8127 - 8128 - delfiles= 8129 - if test -n "$export_symbols" && test -n "$include_expsyms"; then 8130 - $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8131 - export_symbols="$output_objdir/$libname.uexp" 8132 - func_append delfiles " $export_symbols" 8133 - fi 8134 - 8135 - orig_export_symbols= 8136 - case $host_os in 8137 - cygwin* | mingw* | cegcc*) 8138 - if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8139 - # exporting using user supplied symfile 8140 - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8141 - # and it's NOT already a .def file. Must figure out 8142 - # which of the given symbols are data symbols and tag 8143 - # them as such. So, trigger use of export_symbols_cmds. 8144 - # export_symbols gets reassigned inside the "prepare 8145 - # the list of exported symbols" if statement, so the 8146 - # include_expsyms logic still works. 8147 - orig_export_symbols="$export_symbols" 8148 - export_symbols= 8149 - always_export_symbols=yes 8150 - fi 8151 - fi 8152 - ;; 8153 - esac 8154 - 8155 - # Prepare the list of exported symbols 8156 - if test -z "$export_symbols"; then 8157 - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8158 - func_verbose "generating symbol list for \`$libname.la'" 8159 - export_symbols="$output_objdir/$libname.exp" 8160 - $opt_dry_run || $RM $export_symbols 8161 - cmds=$export_symbols_cmds 8162 - save_ifs="$IFS"; IFS='~' 8163 - for cmd1 in $cmds; do 8164 - IFS="$save_ifs" 8165 - # Take the normal branch if the nm_file_list_spec branch 8166 - # doesn't work or if tool conversion is not needed. 8167 - case $nm_file_list_spec~$to_tool_file_cmd in 8168 - *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8169 - try_normal_branch=yes 8170 - eval cmd=\"$cmd1\" 8171 - func_len " $cmd" 8172 - len=$func_len_result 8173 - ;; 8174 - *) 8175 - try_normal_branch=no 8176 - ;; 8177 - esac 8178 - if test "$try_normal_branch" = yes \ 8179 - && { test "$len" -lt "$max_cmd_len" \ 8180 - || test "$max_cmd_len" -le -1; } 8181 - then 8182 - func_show_eval "$cmd" 'exit $?' 8183 - skipped_export=false 8184 - elif test -n "$nm_file_list_spec"; then 8185 - func_basename "$output" 8186 - output_la=$func_basename_result 8187 - save_libobjs=$libobjs 8188 - save_output=$output 8189 - output=${output_objdir}/${output_la}.nm 8190 - func_to_tool_file "$output" 8191 - libobjs=$nm_file_list_spec$func_to_tool_file_result 8192 - func_append delfiles " $output" 8193 - func_verbose "creating $NM input file list: $output" 8194 - for obj in $save_libobjs; do 8195 - func_to_tool_file "$obj" 8196 - $ECHO "$func_to_tool_file_result" 8197 - done > "$output" 8198 - eval cmd=\"$cmd1\" 8199 - func_show_eval "$cmd" 'exit $?' 8200 - output=$save_output 8201 - libobjs=$save_libobjs 8202 - skipped_export=false 8203 - else 8204 - # The command line is too long to execute in one step. 8205 - func_verbose "using reloadable object file for export list..." 8206 - skipped_export=: 8207 - # Break out early, otherwise skipped_export may be 8208 - # set to false by a later but shorter cmd. 8209 - break 8210 - fi 8211 - done 8212 - IFS="$save_ifs" 8213 - if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8214 - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8215 - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8216 - fi 8217 - fi 8218 - fi 8219 - 8220 - if test -n "$export_symbols" && test -n "$include_expsyms"; then 8221 - tmp_export_symbols="$export_symbols" 8222 - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8223 - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8224 - fi 8225 - 8226 - if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8227 - # The given exports_symbols file has to be filtered, so filter it. 8228 - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8229 - # FIXME: $output_objdir/$libname.filter potentially contains lots of 8230 - # 's' commands which not all seds can handle. GNU sed should be fine 8231 - # though. Also, the filter scales superlinearly with the number of 8232 - # global variables. join(1) would be nice here, but unfortunately 8233 - # isn't a blessed tool. 8234 - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8235 - func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8236 - export_symbols=$output_objdir/$libname.def 8237 - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8238 - fi 8239 - 8240 - tmp_deplibs= 8241 - for test_deplib in $deplibs; do 8242 - case " $convenience " in 8243 - *" $test_deplib "*) ;; 8244 - *) 8245 - func_append tmp_deplibs " $test_deplib" 8246 - ;; 8247 - esac 8248 - done 8249 - deplibs="$tmp_deplibs" 8250 - 8251 - if test -n "$convenience"; then 8252 - if test -n "$whole_archive_flag_spec" && 8253 - test "$compiler_needs_object" = yes && 8254 - test -z "$libobjs"; then 8255 - # extract the archives, so we have objects to list. 8256 - # TODO: could optimize this to just extract one archive. 8257 - whole_archive_flag_spec= 8258 - fi 8259 - if test -n "$whole_archive_flag_spec"; then 8260 - save_libobjs=$libobjs 8261 - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8262 - test "X$libobjs" = "X " && libobjs= 8263 - else 8264 - gentop="$output_objdir/${outputname}x" 8265 - func_append generated " $gentop" 8266 - 8267 - func_extract_archives $gentop $convenience 8268 - func_append libobjs " $func_extract_archives_result" 8269 - test "X$libobjs" = "X " && libobjs= 8270 - fi 8271 - fi 8272 - 8273 - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8274 - eval flag=\"$thread_safe_flag_spec\" 8275 - func_append linker_flags " $flag" 8276 - fi 8277 - 8278 - # Make a backup of the uninstalled library when relinking 8279 - if test "$opt_mode" = relink; then 8280 - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8281 - fi 8282 - 8283 - # Do each of the archive commands. 8284 - if test "$module" = yes && test -n "$module_cmds" ; then 8285 - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8286 - eval test_cmds=\"$module_expsym_cmds\" 8287 - cmds=$module_expsym_cmds 8288 - else 8289 - eval test_cmds=\"$module_cmds\" 8290 - cmds=$module_cmds 8291 - fi 8292 - else 8293 - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8294 - eval test_cmds=\"$archive_expsym_cmds\" 8295 - cmds=$archive_expsym_cmds 8296 - else 8297 - eval test_cmds=\"$archive_cmds\" 8298 - cmds=$archive_cmds 8299 - fi 8300 - fi 8301 - 8302 - if test "X$skipped_export" != "X:" && 8303 - func_len " $test_cmds" && 8304 - len=$func_len_result && 8305 - test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8306 - : 8307 - else 8308 - # The command line is too long to link in one step, link piecewise 8309 - # or, if using GNU ld and skipped_export is not :, use a linker 8310 - # script. 8311 - 8312 - # Save the value of $output and $libobjs because we want to 8313 - # use them later. If we have whole_archive_flag_spec, we 8314 - # want to use save_libobjs as it was before 8315 - # whole_archive_flag_spec was expanded, because we can't 8316 - # assume the linker understands whole_archive_flag_spec. 8317 - # This may have to be revisited, in case too many 8318 - # convenience libraries get linked in and end up exceeding 8319 - # the spec. 8320 - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8321 - save_libobjs=$libobjs 8322 - fi 8323 - save_output=$output 8324 - func_basename "$output" 8325 - output_la=$func_basename_result 8326 - 8327 - # Clear the reloadable object creation command queue and 8328 - # initialize k to one. 8329 - test_cmds= 8330 - concat_cmds= 8331 - objlist= 8332 - last_robj= 8333 - k=1 8334 - 8335 - if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8336 - output=${output_objdir}/${output_la}.lnkscript 8337 - func_verbose "creating GNU ld script: $output" 8338 - echo 'INPUT (' > $output 8339 - for obj in $save_libobjs 8340 - do 8341 - func_to_tool_file "$obj" 8342 - $ECHO "$func_to_tool_file_result" >> $output 8343 - done 8344 - echo ')' >> $output 8345 - func_append delfiles " $output" 8346 - func_to_tool_file "$output" 8347 - output=$func_to_tool_file_result 8348 - elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8349 - output=${output_objdir}/${output_la}.lnk 8350 - func_verbose "creating linker input file list: $output" 8351 - : > $output 8352 - set x $save_libobjs 8353 - shift 8354 - firstobj= 8355 - if test "$compiler_needs_object" = yes; then 8356 - firstobj="$1 " 8357 - shift 8358 - fi 8359 - for obj 8360 - do 8361 - func_to_tool_file "$obj" 8362 - $ECHO "$func_to_tool_file_result" >> $output 8363 - done 8364 - func_append delfiles " $output" 8365 - func_to_tool_file "$output" 8366 - output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8367 - else 8368 - if test -n "$save_libobjs"; then 8369 - func_verbose "creating reloadable object files..." 8370 - output=$output_objdir/$output_la-${k}.$objext 8371 - eval test_cmds=\"$reload_cmds\" 8372 - func_len " $test_cmds" 8373 - len0=$func_len_result 8374 - len=$len0 8375 - 8376 - # Loop over the list of objects to be linked. 8377 - for obj in $save_libobjs 8378 - do 8379 - func_len " $obj" 8380 - func_arith $len + $func_len_result 8381 - len=$func_arith_result 8382 - if test "X$objlist" = X || 8383 - test "$len" -lt "$max_cmd_len"; then 8384 - func_append objlist " $obj" 8385 - else 8386 - # The command $test_cmds is almost too long, add a 8387 - # command to the queue. 8388 - if test "$k" -eq 1 ; then 8389 - # The first file doesn't have a previous command to add. 8390 - reload_objs=$objlist 8391 - eval concat_cmds=\"$reload_cmds\" 8392 - else 8393 - # All subsequent reloadable object files will link in 8394 - # the last one created. 8395 - reload_objs="$objlist $last_robj" 8396 - eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8397 - fi 8398 - last_robj=$output_objdir/$output_la-${k}.$objext 8399 - func_arith $k + 1 8400 - k=$func_arith_result 8401 - output=$output_objdir/$output_la-${k}.$objext 8402 - objlist=" $obj" 8403 - func_len " $last_robj" 8404 - func_arith $len0 + $func_len_result 8405 - len=$func_arith_result 8406 - fi 8407 - done 8408 - # Handle the remaining objects by creating one last 8409 - # reloadable object file. All subsequent reloadable object 8410 - # files will link in the last one created. 8411 - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8412 - reload_objs="$objlist $last_robj" 8413 - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8414 - if test -n "$last_robj"; then 8415 - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8416 - fi 8417 - func_append delfiles " $output" 8418 - 8419 - else 8420 - output= 8421 - fi 8422 - 8423 - if ${skipped_export-false}; then 8424 - func_verbose "generating symbol list for \`$libname.la'" 8425 - export_symbols="$output_objdir/$libname.exp" 8426 - $opt_dry_run || $RM $export_symbols 8427 - libobjs=$output 8428 - # Append the command to create the export file. 8429 - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8430 - eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8431 - if test -n "$last_robj"; then 8432 - eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8433 - fi 8434 - fi 8435 - 8436 - test -n "$save_libobjs" && 8437 - func_verbose "creating a temporary reloadable object file: $output" 8438 - 8439 - # Loop through the commands generated above and execute them. 8440 - save_ifs="$IFS"; IFS='~' 8441 - for cmd in $concat_cmds; do 8442 - IFS="$save_ifs" 8443 - $opt_silent || { 8444 - func_quote_for_expand "$cmd" 8445 - eval "func_echo $func_quote_for_expand_result" 8446 - } 8447 - $opt_dry_run || eval "$cmd" || { 8448 - lt_exit=$? 8449 - 8450 - # Restore the uninstalled library and exit 8451 - if test "$opt_mode" = relink; then 8452 - ( cd "$output_objdir" && \ 8453 - $RM "${realname}T" && \ 8454 - $MV "${realname}U" "$realname" ) 8455 - fi 8456 - 8457 - exit $lt_exit 8458 - } 8459 - done 8460 - IFS="$save_ifs" 8461 - 8462 - if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8463 - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8464 - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8465 - fi 8466 - fi 8467 - 8468 - if ${skipped_export-false}; then 8469 - if test -n "$export_symbols" && test -n "$include_expsyms"; then 8470 - tmp_export_symbols="$export_symbols" 8471 - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8472 - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8473 - fi 8474 - 8475 - if test -n "$orig_export_symbols"; then 8476 - # The given exports_symbols file has to be filtered, so filter it. 8477 - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8478 - # FIXME: $output_objdir/$libname.filter potentially contains lots of 8479 - # 's' commands which not all seds can handle. GNU sed should be fine 8480 - # though. Also, the filter scales superlinearly with the number of 8481 - # global variables. join(1) would be nice here, but unfortunately 8482 - # isn't a blessed tool. 8483 - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8484 - func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8485 - export_symbols=$output_objdir/$libname.def 8486 - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8487 - fi 8488 - fi 8489 - 8490 - libobjs=$output 8491 - # Restore the value of output. 8492 - output=$save_output 8493 - 8494 - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8495 - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8496 - test "X$libobjs" = "X " && libobjs= 8497 - fi 8498 - # Expand the library linking commands again to reset the 8499 - # value of $libobjs for piecewise linking. 8500 - 8501 - # Do each of the archive commands. 8502 - if test "$module" = yes && test -n "$module_cmds" ; then 8503 - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8504 - cmds=$module_expsym_cmds 8505 - else 8506 - cmds=$module_cmds 8507 - fi 8508 - else 8509 - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8510 - cmds=$archive_expsym_cmds 8511 - else 8512 - cmds=$archive_cmds 8513 - fi 8514 - fi 8515 - fi 8516 - 8517 - if test -n "$delfiles"; then 8518 - # Append the command to remove temporary files to $cmds. 8519 - eval cmds=\"\$cmds~\$RM $delfiles\" 8520 - fi 8521 - 8522 - # Add any objects from preloaded convenience libraries 8523 - if test -n "$dlprefiles"; then 8524 - gentop="$output_objdir/${outputname}x" 8525 - func_append generated " $gentop" 8526 - 8527 - func_extract_archives $gentop $dlprefiles 8528 - func_append libobjs " $func_extract_archives_result" 8529 - test "X$libobjs" = "X " && libobjs= 8530 - fi 8531 - 8532 - save_ifs="$IFS"; IFS='~' 8533 - for cmd in $cmds; do 8534 - IFS="$save_ifs" 8535 - eval cmd=\"$cmd\" 8536 - $opt_silent || { 8537 - func_quote_for_expand "$cmd" 8538 - eval "func_echo $func_quote_for_expand_result" 8539 - } 8540 - $opt_dry_run || eval "$cmd" || { 8541 - lt_exit=$? 8542 - 8543 - # Restore the uninstalled library and exit 8544 - if test "$opt_mode" = relink; then 8545 - ( cd "$output_objdir" && \ 8546 - $RM "${realname}T" && \ 8547 - $MV "${realname}U" "$realname" ) 8548 - fi 8549 - 8550 - exit $lt_exit 8551 - } 8552 - done 8553 - IFS="$save_ifs" 8554 - 8555 - # Restore the uninstalled library and exit 8556 - if test "$opt_mode" = relink; then 8557 - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8558 - 8559 - if test -n "$convenience"; then 8560 - if test -z "$whole_archive_flag_spec"; then 8561 - func_show_eval '${RM}r "$gentop"' 8562 - fi 8563 - fi 8564 - 8565 - exit $EXIT_SUCCESS 8566 - fi 8567 - 8568 - # Create links to the real library. 8569 - for linkname in $linknames; do 8570 - if test "$realname" != "$linkname"; then 8571 - func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8572 - fi 8573 - done 8574 - 8575 - # If -module or -export-dynamic was specified, set the dlname. 8576 - if test "$module" = yes || test "$export_dynamic" = yes; then 8577 - # On all known operating systems, these are identical. 8578 - dlname="$soname" 8579 - fi 8580 - fi 8581 - ;; 8582 - 8583 - obj) 8584 - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8585 - func_warning "\`-dlopen' is ignored for objects" 8586 - fi 8587 - 8588 - case " $deplibs" in 8589 - *\ -l* | *\ -L*) 8590 - func_warning "\`-l' and \`-L' are ignored for objects" ;; 8591 - esac 8592 - 8593 - test -n "$rpath" && \ 8594 - func_warning "\`-rpath' is ignored for objects" 8595 - 8596 - test -n "$xrpath" && \ 8597 - func_warning "\`-R' is ignored for objects" 8598 - 8599 - test -n "$vinfo" && \ 8600 - func_warning "\`-version-info' is ignored for objects" 8601 - 8602 - test -n "$release" && \ 8603 - func_warning "\`-release' is ignored for objects" 8604 - 8605 - case $output in 8606 - *.lo) 8607 - test -n "$objs$old_deplibs" && \ 8608 - func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8609 - 8610 - libobj=$output 8611 - func_lo2o "$libobj" 8612 - obj=$func_lo2o_result 8613 - ;; 8614 - *) 8615 - libobj= 8616 - obj="$output" 8617 - ;; 8618 - esac 8619 - 8620 - # Delete the old objects. 8621 - $opt_dry_run || $RM $obj $libobj 8622 - 8623 - # Objects from convenience libraries. This assumes 8624 - # single-version convenience libraries. Whenever we create 8625 - # different ones for PIC/non-PIC, this we'll have to duplicate 8626 - # the extraction. 8627 - reload_conv_objs= 8628 - gentop= 8629 - # reload_cmds runs $LD directly, so let us get rid of 8630 - # -Wl from whole_archive_flag_spec and hope we can get by with 8631 - # turning comma into space.. 8632 - wl= 8633 - 8634 - if test -n "$convenience"; then 8635 - if test -n "$whole_archive_flag_spec"; then 8636 - eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8637 - reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8638 - else 8639 - gentop="$output_objdir/${obj}x" 8640 - func_append generated " $gentop" 8641 - 8642 - func_extract_archives $gentop $convenience 8643 - reload_conv_objs="$reload_objs $func_extract_archives_result" 8644 - fi 8645 - fi 8646 - 8647 - # If we're not building shared, we need to use non_pic_objs 8648 - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8649 - 8650 - # Create the old-style object. 8651 - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8652 - 8653 - output="$obj" 8654 - func_execute_cmds "$reload_cmds" 'exit $?' 8655 - 8656 - # Exit if we aren't doing a library object file. 8657 - if test -z "$libobj"; then 8658 - if test -n "$gentop"; then 8659 - func_show_eval '${RM}r "$gentop"' 8660 - fi 8661 - 8662 - exit $EXIT_SUCCESS 8663 - fi 8664 - 8665 - if test "$build_libtool_libs" != yes; then 8666 - if test -n "$gentop"; then 8667 - func_show_eval '${RM}r "$gentop"' 8668 - fi 8669 - 8670 - # Create an invalid libtool object if no PIC, so that we don't 8671 - # accidentally link it into a program. 8672 - # $show "echo timestamp > $libobj" 8673 - # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8674 - exit $EXIT_SUCCESS 8675 - fi 8676 - 8677 - if test -n "$pic_flag" || test "$pic_mode" != default; then 8678 - # Only do commands if we really have different PIC objects. 8679 - reload_objs="$libobjs $reload_conv_objs" 8680 - output="$libobj" 8681 - func_execute_cmds "$reload_cmds" 'exit $?' 8682 - fi 8683 - 8684 - if test -n "$gentop"; then 8685 - func_show_eval '${RM}r "$gentop"' 8686 - fi 8687 - 8688 - exit $EXIT_SUCCESS 8689 - ;; 8690 - 8691 - prog) 8692 - case $host in 8693 - *cygwin*) func_stripname '' '.exe' "$output" 8694 - output=$func_stripname_result.exe;; 8695 - esac 8696 - test -n "$vinfo" && \ 8697 - func_warning "\`-version-info' is ignored for programs" 8698 - 8699 - test -n "$release" && \ 8700 - func_warning "\`-release' is ignored for programs" 8701 - 8702 - test "$preload" = yes \ 8703 - && test "$dlopen_support" = unknown \ 8704 - && test "$dlopen_self" = unknown \ 8705 - && test "$dlopen_self_static" = unknown && \ 8706 - func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8707 - 8708 - case $host in 8709 - *-*-rhapsody* | *-*-darwin1.[012]) 8710 - # On Rhapsody replace the C library is the System framework 8711 - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8712 - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8713 - ;; 8714 - esac 8715 - 8716 - case $host in 8717 - *-*-darwin*) 8718 - # Don't allow lazy linking, it breaks C++ global constructors 8719 - # But is supposedly fixed on 10.4 or later (yay!). 8720 - if test "$tagname" = CXX ; then 8721 - case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8722 - 10.[0123]) 8723 - func_append compile_command " ${wl}-bind_at_load" 8724 - func_append finalize_command " ${wl}-bind_at_load" 8725 - ;; 8726 - esac 8727 - fi 8728 - # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8729 - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8730 - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8731 - ;; 8732 - esac 8733 - 8734 - 8735 - # move library search paths that coincide with paths to not yet 8736 - # installed libraries to the beginning of the library search list 8737 - new_libs= 8738 - for path in $notinst_path; do 8739 - case " $new_libs " in 8740 - *" -L$path/$objdir "*) ;; 8741 - *) 8742 - case " $compile_deplibs " in 8743 - *" -L$path/$objdir "*) 8744 - func_append new_libs " -L$path/$objdir" ;; 8745 - esac 8746 - ;; 8747 - esac 8748 - done 8749 - for deplib in $compile_deplibs; do 8750 - case $deplib in 8751 - -L*) 8752 - case " $new_libs " in 8753 - *" $deplib "*) ;; 8754 - *) func_append new_libs " $deplib" ;; 8755 - esac 8756 - ;; 8757 - *) func_append new_libs " $deplib" ;; 8758 - esac 8759 - done 8760 - compile_deplibs="$new_libs" 8761 - 8762 - 8763 - func_append compile_command " $compile_deplibs" 8764 - func_append finalize_command " $finalize_deplibs" 8765 - 8766 - if test -n "$rpath$xrpath"; then 8767 - # If the user specified any rpath flags, then add them. 8768 - for libdir in $rpath $xrpath; do 8769 - # This is the magic to use -rpath. 8770 - case "$finalize_rpath " in 8771 - *" $libdir "*) ;; 8772 - *) func_append finalize_rpath " $libdir" ;; 8773 - esac 8774 - done 8775 - fi 8776 - 8777 - # Now hardcode the library paths 8778 - rpath= 8779 - hardcode_libdirs= 8780 - for libdir in $compile_rpath $finalize_rpath; do 8781 - if test -n "$hardcode_libdir_flag_spec"; then 8782 - if test -n "$hardcode_libdir_separator"; then 8783 - if test -z "$hardcode_libdirs"; then 8784 - hardcode_libdirs="$libdir" 8785 - else 8786 - # Just accumulate the unique libdirs. 8787 - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8788 - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8789 - ;; 8790 - *) 8791 - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8792 - ;; 8793 - esac 8794 - fi 8795 - else 8796 - eval flag=\"$hardcode_libdir_flag_spec\" 8797 - func_append rpath " $flag" 8798 - fi 8799 - elif test -n "$runpath_var"; then 8800 - case "$perm_rpath " in 8801 - *" $libdir "*) ;; 8802 - *) func_append perm_rpath " $libdir" ;; 8803 - esac 8804 - fi 8805 - case $host in 8806 - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8807 - testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8808 - case :$dllsearchpath: in 8809 - *":$libdir:"*) ;; 8810 - ::) dllsearchpath=$libdir;; 8811 - *) func_append dllsearchpath ":$libdir";; 8812 - esac 8813 - case :$dllsearchpath: in 8814 - *":$testbindir:"*) ;; 8815 - ::) dllsearchpath=$testbindir;; 8816 - *) func_append dllsearchpath ":$testbindir";; 8817 - esac 8818 - ;; 8819 - esac 8820 - done 8821 - # Substitute the hardcoded libdirs into the rpath. 8822 - if test -n "$hardcode_libdir_separator" && 8823 - test -n "$hardcode_libdirs"; then 8824 - libdir="$hardcode_libdirs" 8825 - eval rpath=\" $hardcode_libdir_flag_spec\" 8826 - fi 8827 - compile_rpath="$rpath" 8828 - 8829 - rpath= 8830 - hardcode_libdirs= 8831 - for libdir in $finalize_rpath; do 8832 - if test -n "$hardcode_libdir_flag_spec"; then 8833 - if test -n "$hardcode_libdir_separator"; then 8834 - if test -z "$hardcode_libdirs"; then 8835 - hardcode_libdirs="$libdir" 8836 - else 8837 - # Just accumulate the unique libdirs. 8838 - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8839 - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8840 - ;; 8841 - *) 8842 - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8843 - ;; 8844 - esac 8845 - fi 8846 - else 8847 - eval flag=\"$hardcode_libdir_flag_spec\" 8848 - func_append rpath " $flag" 8849 - fi 8850 - elif test -n "$runpath_var"; then 8851 - case "$finalize_perm_rpath " in 8852 - *" $libdir "*) ;; 8853 - *) func_append finalize_perm_rpath " $libdir" ;; 8854 - esac 8855 - fi 8856 - done 8857 - # Substitute the hardcoded libdirs into the rpath. 8858 - if test -n "$hardcode_libdir_separator" && 8859 - test -n "$hardcode_libdirs"; then 8860 - libdir="$hardcode_libdirs" 8861 - eval rpath=\" $hardcode_libdir_flag_spec\" 8862 - fi 8863 - finalize_rpath="$rpath" 8864 - 8865 - if test -n "$libobjs" && test "$build_old_libs" = yes; then 8866 - # Transform all the library objects into standard objects. 8867 - compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8868 - finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8869 - fi 8870 - 8871 - func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8872 - 8873 - # template prelinking step 8874 - if test -n "$prelink_cmds"; then 8875 - func_execute_cmds "$prelink_cmds" 'exit $?' 8876 - fi 8877 - 8878 - wrappers_required=yes 8879 - case $host in 8880 - *cegcc* | *mingw32ce*) 8881 - # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8882 - wrappers_required=no 8883 - ;; 8884 - *cygwin* | *mingw* ) 8885 - if test "$build_libtool_libs" != yes; then 8886 - wrappers_required=no 8887 - fi 8888 - ;; 8889 - *) 8890 - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8891 - wrappers_required=no 8892 - fi 8893 - ;; 8894 - esac 8895 - if test "$wrappers_required" = no; then 8896 - # Replace the output file specification. 8897 - compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8898 - link_command="$compile_command$compile_rpath" 8899 - 8900 - # We have no uninstalled library dependencies, so finalize right now. 8901 - exit_status=0 8902 - func_show_eval "$link_command" 'exit_status=$?' 8903 - 8904 - if test -n "$postlink_cmds"; then 8905 - func_to_tool_file "$output" 8906 - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8907 - func_execute_cmds "$postlink_cmds" 'exit $?' 8908 - fi 8909 - 8910 - # Delete the generated files. 8911 - if test -f "$output_objdir/${outputname}S.${objext}"; then 8912 - func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8913 - fi 8914 - 8915 - exit $exit_status 8916 - fi 8917 - 8918 - if test -n "$compile_shlibpath$finalize_shlibpath"; then 8919 - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8920 - fi 8921 - if test -n "$finalize_shlibpath"; then 8922 - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8923 - fi 8924 - 8925 - compile_var= 8926 - finalize_var= 8927 - if test -n "$runpath_var"; then 8928 - if test -n "$perm_rpath"; then 8929 - # We should set the runpath_var. 8930 - rpath= 8931 - for dir in $perm_rpath; do 8932 - func_append rpath "$dir:" 8933 - done 8934 - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8935 - fi 8936 - if test -n "$finalize_perm_rpath"; then 8937 - # We should set the runpath_var. 8938 - rpath= 8939 - for dir in $finalize_perm_rpath; do 8940 - func_append rpath "$dir:" 8941 - done 8942 - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8943 - fi 8944 - fi 8945 - 8946 - if test "$no_install" = yes; then 8947 - # We don't need to create a wrapper script. 8948 - link_command="$compile_var$compile_command$compile_rpath" 8949 - # Replace the output file specification. 8950 - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8951 - # Delete the old output file. 8952 - $opt_dry_run || $RM $output 8953 - # Link the executable and exit 8954 - func_show_eval "$link_command" 'exit $?' 8955 - 8956 - if test -n "$postlink_cmds"; then 8957 - func_to_tool_file "$output" 8958 - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8959 - func_execute_cmds "$postlink_cmds" 'exit $?' 8960 - fi 8961 - 8962 - exit $EXIT_SUCCESS 8963 - fi 8964 - 8965 - if test "$hardcode_action" = relink; then 8966 - # Fast installation is not supported 8967 - link_command="$compile_var$compile_command$compile_rpath" 8968 - relink_command="$finalize_var$finalize_command$finalize_rpath" 8969 - 8970 - func_warning "this platform does not like uninstalled shared libraries" 8971 - func_warning "\`$output' will be relinked during installation" 8972 - else 8973 - if test "$fast_install" != no; then 8974 - link_command="$finalize_var$compile_command$finalize_rpath" 8975 - if test "$fast_install" = yes; then 8976 - relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8977 - else 8978 - # fast_install is set to needless 8979 - relink_command= 8980 - fi 8981 - else 8982 - link_command="$compile_var$compile_command$compile_rpath" 8983 - relink_command="$finalize_var$finalize_command$finalize_rpath" 8984 - fi 8985 - fi 8986 - 8987 - # Replace the output file specification. 8988 - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8989 - 8990 - # Delete the old output files. 8991 - $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8992 - 8993 - func_show_eval "$link_command" 'exit $?' 8994 - 8995 - if test -n "$postlink_cmds"; then 8996 - func_to_tool_file "$output_objdir/$outputname" 8997 - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8998 - func_execute_cmds "$postlink_cmds" 'exit $?' 8999 - fi 9000 - 9001 - # Now create the wrapper script. 9002 - func_verbose "creating $output" 9003 - 9004 - # Quote the relink command for shipping. 9005 - if test -n "$relink_command"; then 9006 - # Preserve any variables that may affect compiler behavior 9007 - for var in $variables_saved_for_relink; do 9008 - if eval test -z \"\${$var+set}\"; then 9009 - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9010 - elif eval var_value=\$$var; test -z "$var_value"; then 9011 - relink_command="$var=; export $var; $relink_command" 9012 - else 9013 - func_quote_for_eval "$var_value" 9014 - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9015 - fi 9016 - done 9017 - relink_command="(cd `pwd`; $relink_command)" 9018 - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9019 - fi 9020 - 9021 - # Only actually do things if not in dry run mode. 9022 - $opt_dry_run || { 9023 - # win32 will think the script is a binary if it has 9024 - # a .exe suffix, so we strip it off here. 9025 - case $output in 9026 - *.exe) func_stripname '' '.exe' "$output" 9027 - output=$func_stripname_result ;; 9028 - esac 9029 - # test for cygwin because mv fails w/o .exe extensions 9030 - case $host in 9031 - *cygwin*) 9032 - exeext=.exe 9033 - func_stripname '' '.exe' "$outputname" 9034 - outputname=$func_stripname_result ;; 9035 - *) exeext= ;; 9036 - esac 9037 - case $host in 9038 - *cygwin* | *mingw* ) 9039 - func_dirname_and_basename "$output" "" "." 9040 - output_name=$func_basename_result 9041 - output_path=$func_dirname_result 9042 - cwrappersource="$output_path/$objdir/lt-$output_name.c" 9043 - cwrapper="$output_path/$output_name.exe" 9044 - $RM $cwrappersource $cwrapper 9045 - trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9046 - 9047 - func_emit_cwrapperexe_src > $cwrappersource 9048 - 9049 - # The wrapper executable is built using the $host compiler, 9050 - # because it contains $host paths and files. If cross- 9051 - # compiling, it, like the target executable, must be 9052 - # executed on the $host or under an emulation environment. 9053 - $opt_dry_run || { 9054 - $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9055 - $STRIP $cwrapper 9056 - } 9057 - 9058 - # Now, create the wrapper script for func_source use: 9059 - func_ltwrapper_scriptname $cwrapper 9060 - $RM $func_ltwrapper_scriptname_result 9061 - trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9062 - $opt_dry_run || { 9063 - # note: this script will not be executed, so do not chmod. 9064 - if test "x$build" = "x$host" ; then 9065 - $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9066 - else 9067 - func_emit_wrapper no > $func_ltwrapper_scriptname_result 9068 - fi 9069 - } 9070 - ;; 9071 - * ) 9072 - $RM $output 9073 - trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9074 - 9075 - func_emit_wrapper no > $output 9076 - chmod +x $output 9077 - ;; 9078 - esac 9079 - } 9080 - exit $EXIT_SUCCESS 9081 - ;; 9082 - esac 9083 - 9084 - # See if we need to build an old-fashioned archive. 9085 - for oldlib in $oldlibs; do 9086 - 9087 - if test "$build_libtool_libs" = convenience; then 9088 - oldobjs="$libobjs_save $symfileobj" 9089 - addlibs="$convenience" 9090 - build_libtool_libs=no 9091 - else 9092 - if test "$build_libtool_libs" = module; then 9093 - oldobjs="$libobjs_save" 9094 - build_libtool_libs=no 9095 - else 9096 - oldobjs="$old_deplibs $non_pic_objects" 9097 - if test "$preload" = yes && test -f "$symfileobj"; then 9098 - func_append oldobjs " $symfileobj" 9099 - fi 9100 - fi 9101 - addlibs="$old_convenience" 9102 - fi 9103 - 9104 - if test -n "$addlibs"; then 9105 - gentop="$output_objdir/${outputname}x" 9106 - func_append generated " $gentop" 9107 - 9108 - func_extract_archives $gentop $addlibs 9109 - func_append oldobjs " $func_extract_archives_result" 9110 - fi 9111 - 9112 - # Do each command in the archive commands. 9113 - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9114 - cmds=$old_archive_from_new_cmds 9115 - else 9116 - 9117 - # Add any objects from preloaded convenience libraries 9118 - if test -n "$dlprefiles"; then 9119 - gentop="$output_objdir/${outputname}x" 9120 - func_append generated " $gentop" 9121 - 9122 - func_extract_archives $gentop $dlprefiles 9123 - func_append oldobjs " $func_extract_archives_result" 9124 - fi 9125 - 9126 - # POSIX demands no paths to be encoded in archives. We have 9127 - # to avoid creating archives with duplicate basenames if we 9128 - # might have to extract them afterwards, e.g., when creating a 9129 - # static archive out of a convenience library, or when linking 9130 - # the entirety of a libtool archive into another (currently 9131 - # not supported by libtool). 9132 - if (for obj in $oldobjs 9133 - do 9134 - func_basename "$obj" 9135 - $ECHO "$func_basename_result" 9136 - done | sort | sort -uc >/dev/null 2>&1); then 9137 - : 9138 - else 9139 - echo "copying selected object files to avoid basename conflicts..." 9140 - gentop="$output_objdir/${outputname}x" 9141 - func_append generated " $gentop" 9142 - func_mkdir_p "$gentop" 9143 - save_oldobjs=$oldobjs 9144 - oldobjs= 9145 - counter=1 9146 - for obj in $save_oldobjs 9147 - do 9148 - func_basename "$obj" 9149 - objbase="$func_basename_result" 9150 - case " $oldobjs " in 9151 - " ") oldobjs=$obj ;; 9152 - *[\ /]"$objbase "*) 9153 - while :; do 9154 - # Make sure we don't pick an alternate name that also 9155 - # overlaps. 9156 - newobj=lt$counter-$objbase 9157 - func_arith $counter + 1 9158 - counter=$func_arith_result 9159 - case " $oldobjs " in 9160 - *[\ /]"$newobj "*) ;; 9161 - *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9162 - esac 9163 - done 9164 - func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9165 - func_append oldobjs " $gentop/$newobj" 9166 - ;; 9167 - *) func_append oldobjs " $obj" ;; 9168 - esac 9169 - done 9170 - fi 9171 - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 9172 - tool_oldlib=$func_to_tool_file_result 9173 - eval cmds=\"$old_archive_cmds\" 9174 - 9175 - func_len " $cmds" 9176 - len=$func_len_result 9177 - if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9178 - cmds=$old_archive_cmds 9179 - elif test -n "$archiver_list_spec"; then 9180 - func_verbose "using command file archive linking..." 9181 - for obj in $oldobjs 9182 - do 9183 - func_to_tool_file "$obj" 9184 - $ECHO "$func_to_tool_file_result" 9185 - done > $output_objdir/$libname.libcmd 9186 - func_to_tool_file "$output_objdir/$libname.libcmd" 9187 - oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9188 - cmds=$old_archive_cmds 9189 - else 9190 - # the command line is too long to link in one step, link in parts 9191 - func_verbose "using piecewise archive linking..." 9192 - save_RANLIB=$RANLIB 9193 - RANLIB=: 9194 - objlist= 9195 - concat_cmds= 9196 - save_oldobjs=$oldobjs 9197 - oldobjs= 9198 - # Is there a better way of finding the last object in the list? 9199 - for obj in $save_oldobjs 9200 - do 9201 - last_oldobj=$obj 9202 - done 9203 - eval test_cmds=\"$old_archive_cmds\" 9204 - func_len " $test_cmds" 9205 - len0=$func_len_result 9206 - len=$len0 9207 - for obj in $save_oldobjs 9208 - do 9209 - func_len " $obj" 9210 - func_arith $len + $func_len_result 9211 - len=$func_arith_result 9212 - func_append objlist " $obj" 9213 - if test "$len" -lt "$max_cmd_len"; then 9214 - : 9215 - else 9216 - # the above command should be used before it gets too long 9217 - oldobjs=$objlist 9218 - if test "$obj" = "$last_oldobj" ; then 9219 - RANLIB=$save_RANLIB 9220 - fi 9221 - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9222 - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9223 - objlist= 9224 - len=$len0 9225 - fi 9226 - done 9227 - RANLIB=$save_RANLIB 9228 - oldobjs=$objlist 9229 - if test "X$oldobjs" = "X" ; then 9230 - eval cmds=\"\$concat_cmds\" 9231 - else 9232 - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9233 - fi 9234 - fi 9235 - fi 9236 - func_execute_cmds "$cmds" 'exit $?' 9237 - done 9238 - 9239 - test -n "$generated" && \ 9240 - func_show_eval "${RM}r$generated" 9241 - 9242 - # Now create the libtool archive. 9243 - case $output in 9244 - *.la) 9245 - old_library= 9246 - test "$build_old_libs" = yes && old_library="$libname.$libext" 9247 - func_verbose "creating $output" 9248 - 9249 - # Preserve any variables that may affect compiler behavior 9250 - for var in $variables_saved_for_relink; do 9251 - if eval test -z \"\${$var+set}\"; then 9252 - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9253 - elif eval var_value=\$$var; test -z "$var_value"; then 9254 - relink_command="$var=; export $var; $relink_command" 9255 - else 9256 - func_quote_for_eval "$var_value" 9257 - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9258 - fi 9259 - done 9260 - # Quote the link command for shipping. 9261 - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9262 - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9263 - if test "$hardcode_automatic" = yes ; then 9264 - relink_command= 9265 - fi 9266 - 9267 - # Only create the output if not a dry run. 9268 - $opt_dry_run || { 9269 - for installed in no yes; do 9270 - if test "$installed" = yes; then 9271 - if test -z "$install_libdir"; then 9272 - break 9273 - fi 9274 - output="$output_objdir/$outputname"i 9275 - # Replace all uninstalled libtool libraries with the installed ones 9276 - newdependency_libs= 9277 - for deplib in $dependency_libs; do 9278 - case $deplib in 9279 - *.la) 9280 - func_basename "$deplib" 9281 - name="$func_basename_result" 9282 - func_resolve_sysroot "$deplib" 9283 - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 9284 - test -z "$libdir" && \ 9285 - func_fatal_error "\`$deplib' is not a valid libtool archive" 9286 - func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9287 - ;; 9288 - -L*) 9289 - func_stripname -L '' "$deplib" 9290 - func_replace_sysroot "$func_stripname_result" 9291 - func_append newdependency_libs " -L$func_replace_sysroot_result" 9292 - ;; 9293 - -R*) 9294 - func_stripname -R '' "$deplib" 9295 - func_replace_sysroot "$func_stripname_result" 9296 - func_append newdependency_libs " -R$func_replace_sysroot_result" 9297 - ;; 9298 - *) func_append newdependency_libs " $deplib" ;; 9299 - esac 9300 - done 9301 - dependency_libs="$newdependency_libs" 9302 - newdlfiles= 9303 - 9304 - for lib in $dlfiles; do 9305 - case $lib in 9306 - *.la) 9307 - func_basename "$lib" 9308 - name="$func_basename_result" 9309 - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9310 - test -z "$libdir" && \ 9311 - func_fatal_error "\`$lib' is not a valid libtool archive" 9312 - func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9313 - ;; 9314 - *) func_append newdlfiles " $lib" ;; 9315 - esac 9316 - done 9317 - dlfiles="$newdlfiles" 9318 - newdlprefiles= 9319 - for lib in $dlprefiles; do 9320 - case $lib in 9321 - *.la) 9322 - # Only pass preopened files to the pseudo-archive (for 9323 - # eventual linking with the app. that links it) if we 9324 - # didn't already link the preopened objects directly into 9325 - # the library: 9326 - func_basename "$lib" 9327 - name="$func_basename_result" 9328 - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9329 - test -z "$libdir" && \ 9330 - func_fatal_error "\`$lib' is not a valid libtool archive" 9331 - func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9332 - ;; 9333 - esac 9334 - done 9335 - dlprefiles="$newdlprefiles" 9336 - else 9337 - newdlfiles= 9338 - for lib in $dlfiles; do 9339 - case $lib in 9340 - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9341 - *) abs=`pwd`"/$lib" ;; 9342 - esac 9343 - func_append newdlfiles " $abs" 9344 - done 9345 - dlfiles="$newdlfiles" 9346 - newdlprefiles= 9347 - for lib in $dlprefiles; do 9348 - case $lib in 9349 - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9350 - *) abs=`pwd`"/$lib" ;; 9351 - esac 9352 - func_append newdlprefiles " $abs" 9353 - done 9354 - dlprefiles="$newdlprefiles" 9355 - fi 9356 - $RM $output 9357 - # place dlname in correct position for cygwin 9358 - # In fact, it would be nice if we could use this code for all target 9359 - # systems that can't hard-code library paths into their executables 9360 - # and that have no shared library path variable independent of PATH, 9361 - # but it turns out we can't easily determine that from inspecting 9362 - # libtool variables, so we have to hard-code the OSs to which it 9363 - # applies here; at the moment, that means platforms that use the PE 9364 - # object format with DLL files. See the long comment at the top of 9365 - # tests/bindir.at for full details. 9366 - tdlname=$dlname 9367 - case $host,$output,$installed,$module,$dlname in 9368 - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9369 - # If a -bindir argument was supplied, place the dll there. 9370 - if test "x$bindir" != x ; 9371 - then 9372 - func_relative_path "$install_libdir" "$bindir" 9373 - tdlname=$func_relative_path_result$dlname 9374 - else 9375 - # Otherwise fall back on heuristic. 9376 - tdlname=../bin/$dlname 9377 - fi 9378 - ;; 9379 - esac 9380 - $ECHO > $output "\ 9381 -# $outputname - a libtool library file 9382 -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9383 -# 9384 -# Please DO NOT delete this file! 9385 -# It is necessary for linking the library. 9386 - 9387 -# The name that we can dlopen(3). 9388 -dlname='$tdlname' 9389 - 9390 -# Names of this library. 9391 -library_names='$library_names' 9392 - 9393 -# The name of the static archive. 9394 -old_library='$old_library' 9395 - 9396 -# Linker flags that can not go in dependency_libs. 9397 -inherited_linker_flags='$new_inherited_linker_flags' 9398 - 9399 -# Libraries that this one depends upon. 9400 -dependency_libs='$dependency_libs' 9401 - 9402 -# Names of additional weak libraries provided by this library 9403 -weak_library_names='$weak_libs' 9404 - 9405 -# Version information for $libname. 9406 -current=$current 9407 -age=$age 9408 -revision=$revision 9409 - 9410 -# Is this an already installed library? 9411 -installed=$installed 9412 - 9413 -# Should we warn about portability when linking against -modules? 9414 -shouldnotlink=$module 9415 - 9416 -# Files to dlopen/dlpreopen 9417 -dlopen='$dlfiles' 9418 -dlpreopen='$dlprefiles' 9419 - 9420 -# Directory that this library needs to be installed in: 9421 -libdir='$install_libdir'" 9422 - if test "$installed" = no && test "$need_relink" = yes; then 9423 - $ECHO >> $output "\ 9424 -relink_command=\"$relink_command\"" 9425 - fi 9426 - done 9427 - } 9428 - 9429 - # Do a symbolic link so that the libtool archive can be found in 9430 - # LD_LIBRARY_PATH before the program is installed. 9431 - func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9432 - ;; 9433 - esac 9434 - exit $EXIT_SUCCESS 9435 -} 9436 - 9437 -{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9438 - func_mode_link ${1+"$@"} 9439 - 9440 - 9441 -# func_mode_uninstall arg... 9442 -func_mode_uninstall () 9443 -{ 9444 - $opt_debug 9445 - RM="$nonopt" 9446 - files= 9447 - rmforce= 9448 - exit_status=0 9449 - 9450 - # This variable tells wrapper scripts just to set variables rather 9451 - # than running their programs. 9452 - libtool_install_magic="$magic" 9453 - 9454 - for arg 9455 - do 9456 - case $arg in 9457 - -f) func_append RM " $arg"; rmforce=yes ;; 9458 - -*) func_append RM " $arg" ;; 9459 - *) func_append files " $arg" ;; 9460 - esac 9461 - done 9462 - 9463 - test -z "$RM" && \ 9464 - func_fatal_help "you must specify an RM program" 9465 - 9466 - rmdirs= 9467 - 9468 - for file in $files; do 9469 - func_dirname "$file" "" "." 9470 - dir="$func_dirname_result" 9471 - if test "X$dir" = X.; then 9472 - odir="$objdir" 9473 - else 9474 - odir="$dir/$objdir" 9475 - fi 9476 - func_basename "$file" 9477 - name="$func_basename_result" 9478 - test "$opt_mode" = uninstall && odir="$dir" 9479 - 9480 - # Remember odir for removal later, being careful to avoid duplicates 9481 - if test "$opt_mode" = clean; then 9482 - case " $rmdirs " in 9483 - *" $odir "*) ;; 9484 - *) func_append rmdirs " $odir" ;; 9485 - esac 9486 - fi 9487 - 9488 - # Don't error if the file doesn't exist and rm -f was used. 9489 - if { test -L "$file"; } >/dev/null 2>&1 || 9490 - { test -h "$file"; } >/dev/null 2>&1 || 9491 - test -f "$file"; then 9492 - : 9493 - elif test -d "$file"; then 9494 - exit_status=1 9495 - continue 9496 - elif test "$rmforce" = yes; then 9497 - continue 9498 - fi 9499 - 9500 - rmfiles="$file" 9501 - 9502 - case $name in 9503 - *.la) 9504 - # Possibly a libtool archive, so verify it. 9505 - if func_lalib_p "$file"; then 9506 - func_source $dir/$name 9507 - 9508 - # Delete the libtool libraries and symlinks. 9509 - for n in $library_names; do 9510 - func_append rmfiles " $odir/$n" 9511 - done 9512 - test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9513 - 9514 - case "$opt_mode" in 9515 - clean) 9516 - case " $library_names " in 9517 - *" $dlname "*) ;; 9518 - *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9519 - esac 9520 - test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9521 - ;; 9522 - uninstall) 9523 - if test -n "$library_names"; then 9524 - # Do each command in the postuninstall commands. 9525 - func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9526 - fi 9527 - 9528 - if test -n "$old_library"; then 9529 - # Do each command in the old_postuninstall commands. 9530 - func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9531 - fi 9532 - # FIXME: should reinstall the best remaining shared library. 9533 - ;; 9534 - esac 9535 - fi 9536 - ;; 9537 - 9538 - *.lo) 9539 - # Possibly a libtool object, so verify it. 9540 - if func_lalib_p "$file"; then 9541 - 9542 - # Read the .lo file 9543 - func_source $dir/$name 9544 - 9545 - # Add PIC object to the list of files to remove. 9546 - if test -n "$pic_object" && 9547 - test "$pic_object" != none; then 9548 - func_append rmfiles " $dir/$pic_object" 9549 - fi 9550 - 9551 - # Add non-PIC object to the list of files to remove. 9552 - if test -n "$non_pic_object" && 9553 - test "$non_pic_object" != none; then 9554 - func_append rmfiles " $dir/$non_pic_object" 9555 - fi 9556 - fi 9557 - ;; 9558 - 9559 - *) 9560 - if test "$opt_mode" = clean ; then 9561 - noexename=$name 9562 - case $file in 9563 - *.exe) 9564 - func_stripname '' '.exe' "$file" 9565 - file=$func_stripname_result 9566 - func_stripname '' '.exe' "$name" 9567 - noexename=$func_stripname_result 9568 - # $file with .exe has already been added to rmfiles, 9569 - # add $file without .exe 9570 - func_append rmfiles " $file" 9571 - ;; 9572 - esac 9573 - # Do a test to see if this is a libtool program. 9574 - if func_ltwrapper_p "$file"; then 9575 - if func_ltwrapper_executable_p "$file"; then 9576 - func_ltwrapper_scriptname "$file" 9577 - relink_command= 9578 - func_source $func_ltwrapper_scriptname_result 9579 - func_append rmfiles " $func_ltwrapper_scriptname_result" 9580 - else 9581 - relink_command= 9582 - func_source $dir/$noexename 9583 - fi 9584 - 9585 - # note $name still contains .exe if it was in $file originally 9586 - # as does the version of $file that was added into $rmfiles 9587 - func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9588 - if test "$fast_install" = yes && test -n "$relink_command"; then 9589 - func_append rmfiles " $odir/lt-$name" 9590 - fi 9591 - if test "X$noexename" != "X$name" ; then 9592 - func_append rmfiles " $odir/lt-${noexename}.c" 9593 - fi 9594 - fi 9595 - fi 9596 - ;; 9597 - esac 9598 - func_show_eval "$RM $rmfiles" 'exit_status=1' 9599 - done 9600 - 9601 - # Try to remove the ${objdir}s in the directories where we deleted files 9602 - for dir in $rmdirs; do 9603 - if test -d "$dir"; then 9604 - func_show_eval "rmdir $dir >/dev/null 2>&1" 9605 - fi 9606 - done 9607 - 9608 - exit $exit_status 9609 -} 9610 - 9611 -{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9612 - func_mode_uninstall ${1+"$@"} 9613 - 9614 -test -z "$opt_mode" && { 9615 - help="$generic_help" 9616 - func_fatal_help "you must specify a MODE" 9617 -} 9618 - 9619 -test -z "$exec_cmd" && \ 9620 - func_fatal_help "invalid operation mode \`$opt_mode'" 9621 - 9622 -if test -n "$exec_cmd"; then 9623 - eval exec "$exec_cmd" 9624 - exit $EXIT_FAILURE 9625 -fi 9626 - 9627 -exit $exit_status 9628 - 9629 - 9630 -# The TAGs below are defined such that we never get into a situation 9631 -# in which we disable both kinds of libraries. Given conflicting 9632 -# choices, we go for a static library, that is the most portable, 9633 -# since we can't tell whether shared libraries were disabled because 9634 -# the user asked for that or because the platform doesn't support 9635 -# them. This is particularly important on AIX, because we don't 9636 -# support having both static and shared libraries enabled at the same 9637 -# time on that platform, so we default to a shared-only configuration. 9638 -# If a disable-shared tag is given, we'll fallback to a static-only 9639 -# configuration. But we'll never go from static-only to shared-only. 9640 - 9641 -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9642 -build_libtool_libs=no 9643 -build_old_libs=yes 9644 -# ### END LIBTOOL TAG CONFIG: disable-shared 9645 - 9646 -# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9647 -build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9648 -# ### END LIBTOOL TAG CONFIG: disable-static 9649 - 9650 -# Local Variables: 9651 -# mode:shell-script 9652 -# sh-indentation:2 9653 -# End: 9654 -# vi:sw=2 9655 -
Deleted m4/libtool.m4.
1 -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- 2 -# 3 -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 4 -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software 5 -# Foundation, Inc. 6 -# Written by Gordon Matzigkeit, 1996 7 -# 8 -# This file is free software; the Free Software Foundation gives 9 -# unlimited permission to copy and/or distribute it, with or without 10 -# modifications, as long as this notice is preserved. 11 - 12 -m4_define([_LT_COPYING], [dnl 13 -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 14 -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software 15 -# Foundation, Inc. 16 -# Written by Gordon Matzigkeit, 1996 17 -# 18 -# This file is part of GNU Libtool. 19 -# 20 -# GNU Libtool is free software; you can redistribute it and/or 21 -# modify it under the terms of the GNU General Public License as 22 -# published by the Free Software Foundation; either version 2 of 23 -# the License, or (at your option) any later version. 24 -# 25 -# As a special exception to the GNU General Public License, 26 -# if you distribute this file as part of a program or library that 27 -# is built using GNU Libtool, you may include this file under the 28 -# same distribution terms that you use for the rest of that program. 29 -# 30 -# GNU Libtool is distributed in the hope that it will be useful, 31 -# but WITHOUT ANY WARRANTY; without even the implied warranty of 32 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 -# GNU General Public License for more details. 34 -# 35 -# You should have received a copy of the GNU General Public License 36 -# along with GNU Libtool; see the file COPYING. If not, a copy 37 -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or 38 -# obtained by writing to the Free Software Foundation, Inc., 39 -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 40 -]) 41 - 42 -# serial 57 LT_INIT 43 - 44 - 45 -# LT_PREREQ(VERSION) 46 -# ------------------ 47 -# Complain and exit if this libtool version is less that VERSION. 48 -m4_defun([LT_PREREQ], 49 -[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, 50 - [m4_default([$3], 51 - [m4_fatal([Libtool version $1 or higher is required], 52 - 63)])], 53 - [$2])]) 54 - 55 - 56 -# _LT_CHECK_BUILDDIR 57 -# ------------------ 58 -# Complain if the absolute build directory name contains unusual characters 59 -m4_defun([_LT_CHECK_BUILDDIR], 60 -[case `pwd` in 61 - *\ * | *\ *) 62 - AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; 63 -esac 64 -]) 65 - 66 - 67 -# LT_INIT([OPTIONS]) 68 -# ------------------ 69 -AC_DEFUN([LT_INIT], 70 -[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT 71 -AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl 72 -AC_BEFORE([$0], [LT_LANG])dnl 73 -AC_BEFORE([$0], [LT_OUTPUT])dnl 74 -AC_BEFORE([$0], [LTDL_INIT])dnl 75 -m4_require([_LT_CHECK_BUILDDIR])dnl 76 - 77 -dnl Autoconf doesn't catch unexpanded LT_ macros by default: 78 -m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl 79 -m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl 80 -dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 81 -dnl unless we require an AC_DEFUNed macro: 82 -AC_REQUIRE([LTOPTIONS_VERSION])dnl 83 -AC_REQUIRE([LTSUGAR_VERSION])dnl 84 -AC_REQUIRE([LTVERSION_VERSION])dnl 85 -AC_REQUIRE([LTOBSOLETE_VERSION])dnl 86 -m4_require([_LT_PROG_LTMAIN])dnl 87 - 88 -_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) 89 - 90 -dnl Parse OPTIONS 91 -_LT_SET_OPTIONS([$0], [$1]) 92 - 93 -# This can be used to rebuild libtool when needed 94 -LIBTOOL_DEPS="$ltmain" 95 - 96 -# Always use our own libtool. 97 -LIBTOOL='$(SHELL) $(top_builddir)/libtool' 98 -AC_SUBST(LIBTOOL)dnl 99 - 100 -_LT_SETUP 101 - 102 -# Only expand once: 103 -m4_define([LT_INIT]) 104 -])# LT_INIT 105 - 106 -# Old names: 107 -AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) 108 -AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) 109 -dnl aclocal-1.4 backwards compatibility: 110 -dnl AC_DEFUN([AC_PROG_LIBTOOL], []) 111 -dnl AC_DEFUN([AM_PROG_LIBTOOL], []) 112 - 113 - 114 -# _LT_CC_BASENAME(CC) 115 -# ------------------- 116 -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. 117 -m4_defun([_LT_CC_BASENAME], 118 -[for cc_temp in $1""; do 119 - case $cc_temp in 120 - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; 121 - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; 122 - \-*) ;; 123 - *) break;; 124 - esac 125 -done 126 -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` 127 -]) 128 - 129 - 130 -# _LT_FILEUTILS_DEFAULTS 131 -# ---------------------- 132 -# It is okay to use these file commands and assume they have been set 133 -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. 134 -m4_defun([_LT_FILEUTILS_DEFAULTS], 135 -[: ${CP="cp -f"} 136 -: ${MV="mv -f"} 137 -: ${RM="rm -f"} 138 -])# _LT_FILEUTILS_DEFAULTS 139 - 140 - 141 -# _LT_SETUP 142 -# --------- 143 -m4_defun([_LT_SETUP], 144 -[AC_REQUIRE([AC_CANONICAL_HOST])dnl 145 -AC_REQUIRE([AC_CANONICAL_BUILD])dnl 146 -AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl 147 -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl 148 - 149 -_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl 150 -dnl 151 -_LT_DECL([], [host_alias], [0], [The host system])dnl 152 -_LT_DECL([], [host], [0])dnl 153 -_LT_DECL([], [host_os], [0])dnl 154 -dnl 155 -_LT_DECL([], [build_alias], [0], [The build system])dnl 156 -_LT_DECL([], [build], [0])dnl 157 -_LT_DECL([], [build_os], [0])dnl 158 -dnl 159 -AC_REQUIRE([AC_PROG_CC])dnl 160 -AC_REQUIRE([LT_PATH_LD])dnl 161 -AC_REQUIRE([LT_PATH_NM])dnl 162 -dnl 163 -AC_REQUIRE([AC_PROG_LN_S])dnl 164 -test -z "$LN_S" && LN_S="ln -s" 165 -_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl 166 -dnl 167 -AC_REQUIRE([LT_CMD_MAX_LEN])dnl 168 -_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl 169 -_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl 170 -dnl 171 -m4_require([_LT_FILEUTILS_DEFAULTS])dnl 172 -m4_require([_LT_CHECK_SHELL_FEATURES])dnl 173 -m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl 174 -m4_require([_LT_CMD_RELOAD])dnl 175 -m4_require([_LT_CHECK_MAGIC_METHOD])dnl 176 -m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl 177 -m4_require([_LT_CMD_OLD_ARCHIVE])dnl 178 -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl 179 -m4_require([_LT_WITH_SYSROOT])dnl 180 - 181 -_LT_CONFIG_LIBTOOL_INIT([ 182 -# See if we are running on zsh, and set the options which allow our 183 -# commands through without removal of \ escapes INIT. 184 -if test -n "\${ZSH_VERSION+set}" ; then 185 - setopt NO_GLOB_SUBST 186 -fi 187 -]) 188 -if test -n "${ZSH_VERSION+set}" ; then 189 - setopt NO_GLOB_SUBST 190 -fi 191 - 192 -_LT_CHECK_OBJDIR 193 - 194 -m4_require([_LT_TAG_COMPILER])dnl 195 - 196 -case $host_os in 197 -aix3*) 198 - # AIX sometimes has problems with the GCC collect2 program. For some 199 - # reason, if we set the COLLECT_NAMES environment variable, the problems 200 - # vanish in a puff of smoke. 201 - if test "X${COLLECT_NAMES+set}" != Xset; then 202 - COLLECT_NAMES= 203 - export COLLECT_NAMES 204 - fi 205 - ;; 206 -esac 207 - 208 -# Global variables: 209 -ofile=libtool 210 -can_build_shared=yes 211 - 212 -# All known linkers require a `.a' archive for static linking (except MSVC, 213 -# which needs '.lib'). 214 -libext=a 215 - 216 -with_gnu_ld="$lt_cv_prog_gnu_ld" 217 - 218 -old_CC="$CC" 219 -old_CFLAGS="$CFLAGS" 220 - 221 -# Set sane defaults for various variables 222 -test -z "$CC" && CC=cc 223 -test -z "$LTCC" && LTCC=$CC 224 -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS 225 -test -z "$LD" && LD=ld 226 -test -z "$ac_objext" && ac_objext=o 227 - 228 -_LT_CC_BASENAME([$compiler]) 229 - 230 -# Only perform the check for file, if the check method requires it 231 -test -z "$MAGIC_CMD" && MAGIC_CMD=file 232 -case $deplibs_check_method in 233 -file_magic*) 234 - if test "$file_magic_cmd" = '$MAGIC_CMD'; then 235 - _LT_PATH_MAGIC 236 - fi 237 - ;; 238 -esac 239 - 240 -# Use C for the default configuration in the libtool script 241 -LT_SUPPORTED_TAG([CC]) 242 -_LT_LANG_C_CONFIG 243 -_LT_LANG_DEFAULT_CONFIG 244 -_LT_CONFIG_COMMANDS 245 -])# _LT_SETUP 246 - 247 - 248 -# _LT_PREPARE_SED_QUOTE_VARS 249 -# -------------------------- 250 -# Define a few sed substitution that help us do robust quoting. 251 -m4_defun([_LT_PREPARE_SED_QUOTE_VARS], 252 -[# Backslashify metacharacters that are still active within 253 -# double-quoted strings. 254 -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' 255 - 256 -# Same as above, but do not quote variable references. 257 -double_quote_subst='s/\([["`\\]]\)/\\\1/g' 258 - 259 -# Sed substitution to delay expansion of an escaped shell variable in a 260 -# double_quote_subst'ed string. 261 -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' 262 - 263 -# Sed substitution to delay expansion of an escaped single quote. 264 -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' 265 - 266 -# Sed substitution to avoid accidental globbing in evaled expressions 267 -no_glob_subst='s/\*/\\\*/g' 268 -]) 269 - 270 -# _LT_PROG_LTMAIN 271 -# --------------- 272 -# Note that this code is called both from `configure', and `config.status' 273 -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, 274 -# `config.status' has no value for ac_aux_dir unless we are using Automake, 275 -# so we pass a copy along to make sure it has a sensible value anyway. 276 -m4_defun([_LT_PROG_LTMAIN], 277 -[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl 278 -_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) 279 -ltmain="$ac_aux_dir/ltmain.sh" 280 -])# _LT_PROG_LTMAIN 281 - 282 - 283 -## ------------------------------------- ## 284 -## Accumulate code for creating libtool. ## 285 -## ------------------------------------- ## 286 - 287 -# So that we can recreate a full libtool script including additional 288 -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS 289 -# in macros and then make a single call at the end using the `libtool' 290 -# label. 291 - 292 - 293 -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) 294 -# ---------------------------------------- 295 -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. 296 -m4_define([_LT_CONFIG_LIBTOOL_INIT], 297 -[m4_ifval([$1], 298 - [m4_append([_LT_OUTPUT_LIBTOOL_INIT], 299 - [$1 300 -])])]) 301 - 302 -# Initialize. 303 -m4_define([_LT_OUTPUT_LIBTOOL_INIT]) 304 - 305 - 306 -# _LT_CONFIG_LIBTOOL([COMMANDS]) 307 -# ------------------------------ 308 -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. 309 -m4_define([_LT_CONFIG_LIBTOOL], 310 -[m4_ifval([$1], 311 - [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], 312 - [$1 313 -])])]) 314 - 315 -# Initialize. 316 -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) 317 - 318 - 319 -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) 320 -# ----------------------------------------------------- 321 -m4_defun([_LT_CONFIG_SAVE_COMMANDS], 322 -[_LT_CONFIG_LIBTOOL([$1]) 323 -_LT_CONFIG_LIBTOOL_INIT([$2]) 324 -]) 325 - 326 - 327 -# _LT_FORMAT_COMMENT([COMMENT]) 328 -# ----------------------------- 329 -# Add leading comment marks to the start of each line, and a trailing 330 -# full-stop to the whole comment if one is not present already. 331 -m4_define([_LT_FORMAT_COMMENT], 332 -[m4_ifval([$1], [ 333 -m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], 334 - [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) 335 -)]) 336 - 337 - 338 - 339 -## ------------------------ ## 340 -## FIXME: Eliminate VARNAME ## 341 -## ------------------------ ## 342 - 343 - 344 -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) 345 -# ------------------------------------------------------------------- 346 -# CONFIGNAME is the name given to the value in the libtool script. 347 -# VARNAME is the (base) name used in the configure script. 348 -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on 349 -# VARNAME. Any other value will be used directly. 350 -m4_define([_LT_DECL], 351 -[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], 352 - [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], 353 - [m4_ifval([$1], [$1], [$2])]) 354 - lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) 355 - m4_ifval([$4], 356 - [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) 357 - lt_dict_add_subkey([lt_decl_dict], [$2], 358 - [tagged?], [m4_ifval([$5], [yes], [no])])]) 359 -]) 360 - 361 - 362 -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) 363 -# -------------------------------------------------------- 364 -m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) 365 - 366 - 367 -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) 368 -# ------------------------------------------------ 369 -m4_define([lt_decl_tag_varnames], 370 -[_lt_decl_filter([tagged?], [yes], $@)]) 371 - 372 - 373 -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) 374 -# --------------------------------------------------------- 375 -m4_define([_lt_decl_filter], 376 -[m4_case([$#], 377 - [0], [m4_fatal([$0: too few arguments: $#])], 378 - [1], [m4_fatal([$0: too few arguments: $#: $1])], 379 - [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], 380 - [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], 381 - [lt_dict_filter([lt_decl_dict], $@)])[]dnl 382 -]) 383 - 384 - 385 -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) 386 -# -------------------------------------------------- 387 -m4_define([lt_decl_quote_varnames], 388 -[_lt_decl_filter([value], [1], $@)]) 389 - 390 - 391 -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) 392 -# --------------------------------------------------- 393 -m4_define([lt_decl_dquote_varnames], 394 -[_lt_decl_filter([value], [2], $@)]) 395 - 396 - 397 -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) 398 -# --------------------------------------------------- 399 -m4_define([lt_decl_varnames_tagged], 400 -[m4_assert([$# <= 2])dnl 401 -_$0(m4_quote(m4_default([$1], [[, ]])), 402 - m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), 403 - m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) 404 -m4_define([_lt_decl_varnames_tagged], 405 -[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) 406 - 407 - 408 -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) 409 -# ------------------------------------------------ 410 -m4_define([lt_decl_all_varnames], 411 -[_$0(m4_quote(m4_default([$1], [[, ]])), 412 - m4_if([$2], [], 413 - m4_quote(lt_decl_varnames), 414 - m4_quote(m4_shift($@))))[]dnl 415 -]) 416 -m4_define([_lt_decl_all_varnames], 417 -[lt_join($@, lt_decl_varnames_tagged([$1], 418 - lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl 419 -]) 420 - 421 - 422 -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) 423 -# ------------------------------------ 424 -# Quote a variable value, and forward it to `config.status' so that its 425 -# declaration there will have the same value as in `configure'. VARNAME 426 -# must have a single quote delimited value for this to work. 427 -m4_define([_LT_CONFIG_STATUS_DECLARE], 428 -[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) 429 - 430 - 431 -# _LT_CONFIG_STATUS_DECLARATIONS 432 -# ------------------------------ 433 -# We delimit libtool config variables with single quotes, so when 434 -# we write them to config.status, we have to be sure to quote all 435 -# embedded single quotes properly. In configure, this macro expands 436 -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: 437 -# 438 -# <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`' 439 -m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], 440 -[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), 441 - [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) 442 - 443 - 444 -# _LT_LIBTOOL_TAGS 445 -# ---------------- 446 -# Output comment and list of tags supported by the script 447 -m4_defun([_LT_LIBTOOL_TAGS], 448 -[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl 449 -available_tags="_LT_TAGS"dnl 450 -]) 451 - 452 - 453 -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) 454 -# ----------------------------------- 455 -# Extract the dictionary values for VARNAME (optionally with TAG) and 456 -# expand to a commented shell variable setting: 457 -# 458 -# # Some comment about what VAR is for. 459 -# visible_name=$lt_internal_name 460 -m4_define([_LT_LIBTOOL_DECLARE], 461 -[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], 462 - [description])))[]dnl 463 -m4_pushdef([_libtool_name], 464 - m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl 465 -m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), 466 - [0], [_libtool_name=[$]$1], 467 - [1], [_libtool_name=$lt_[]$1], 468 - [2], [_libtool_name=$lt_[]$1], 469 - [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl 470 -m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl 471 -]) 472 - 473 - 474 -# _LT_LIBTOOL_CONFIG_VARS 475 -# ----------------------- 476 -# Produce commented declarations of non-tagged libtool config variables 477 -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' 478 -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG 479 -# section) are produced by _LT_LIBTOOL_TAG_VARS. 480 -m4_defun([_LT_LIBTOOL_CONFIG_VARS], 481 -[m4_foreach([_lt_var], 482 - m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), 483 - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) 484 - 485 - 486 -# _LT_LIBTOOL_TAG_VARS(TAG) 487 -# ------------------------- 488 -m4_define([_LT_LIBTOOL_TAG_VARS], 489 -[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), 490 - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) 491 - 492 - 493 -# _LT_TAGVAR(VARNAME, [TAGNAME]) 494 -# ------------------------------ 495 -m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) 496 - 497 - 498 -# _LT_CONFIG_COMMANDS 499 -# ------------------- 500 -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of 501 -# variables for single and double quote escaping we saved from calls 502 -# to _LT_DECL, we can put quote escaped variables declarations 503 -# into `config.status', and then the shell code to quote escape them in 504 -# for loops in `config.status'. Finally, any additional code accumulated 505 -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. 506 -m4_defun([_LT_CONFIG_COMMANDS], 507 -[AC_PROVIDE_IFELSE([LT_OUTPUT], 508 - dnl If the libtool generation code has been placed in $CONFIG_LT, 509 - dnl instead of duplicating it all over again into config.status, 510 - dnl then we will have config.status run $CONFIG_LT later, so it 511 - dnl needs to know what name is stored there: 512 - [AC_CONFIG_COMMANDS([libtool], 513 - [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], 514 - dnl If the libtool generation code is destined for config.status, 515 - dnl expand the accumulated commands and init code now: 516 - [AC_CONFIG_COMMANDS([libtool], 517 - [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) 518 -])#_LT_CONFIG_COMMANDS 519 - 520 - 521 -# Initialize. 522 -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], 523 -[ 524 - 525 -# The HP-UX ksh and POSIX shell print the target directory to stdout 526 -# if CDPATH is set. 527 -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 528 - 529 -sed_quote_subst='$sed_quote_subst' 530 -double_quote_subst='$double_quote_subst' 531 -delay_variable_subst='$delay_variable_subst' 532 -_LT_CONFIG_STATUS_DECLARATIONS 533 -LTCC='$LTCC' 534 -LTCFLAGS='$LTCFLAGS' 535 -compiler='$compiler_DEFAULT' 536 - 537 -# A function that is used when there is no print builtin or printf. 538 -func_fallback_echo () 539 -{ 540 - eval 'cat <<_LTECHO_EOF 541 -\$[]1 542 -_LTECHO_EOF' 543 -} 544 - 545 -# Quote evaled strings. 546 -for var in lt_decl_all_varnames([[ \ 547 -]], lt_decl_quote_varnames); do 548 - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in 549 - *[[\\\\\\\`\\"\\\$]]*) 550 - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" 551 - ;; 552 - *) 553 - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" 554 - ;; 555 - esac 556 -done 557 - 558 -# Double-quote double-evaled strings. 559 -for var in lt_decl_all_varnames([[ \ 560 -]], lt_decl_dquote_varnames); do 561 - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in 562 - *[[\\\\\\\`\\"\\\$]]*) 563 - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" 564 - ;; 565 - *) 566 - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" 567 - ;; 568 - esac 569 -done 570 - 571 -_LT_OUTPUT_LIBTOOL_INIT 572 -]) 573 - 574 -# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) 575 -# ------------------------------------ 576 -# Generate a child script FILE with all initialization necessary to 577 -# reuse the environment learned by the parent script, and make the 578 -# file executable. If COMMENT is supplied, it is inserted after the 579 -# `#!' sequence but before initialization text begins. After this 580 -# macro, additional text can be appended to FILE to form the body of 581 -# the child script. The macro ends with non-zero status if the 582 -# file could not be fully written (such as if the disk is full). 583 -m4_ifdef([AS_INIT_GENERATED], 584 -[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], 585 -[m4_defun([_LT_GENERATED_FILE_INIT], 586 -[m4_require([AS_PREPARE])]dnl 587 -[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl 588 -[lt_write_fail=0 589 -cat >$1 <<_ASEOF || lt_write_fail=1 590 -#! $SHELL 591 -# Generated by $as_me. 592 -$2 593 -SHELL=\${CONFIG_SHELL-$SHELL} 594 -export SHELL 595 -_ASEOF 596 -cat >>$1 <<\_ASEOF || lt_write_fail=1 597 -AS_SHELL_SANITIZE 598 -_AS_PREPARE 599 -exec AS_MESSAGE_FD>&1 600 -_ASEOF 601 -test $lt_write_fail = 0 && chmod +x $1[]dnl 602 -m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT 603 - 604 -# LT_OUTPUT 605 -# --------- 606 -# This macro allows early generation of the libtool script (before 607 -# AC_OUTPUT is called), incase it is used in configure for compilation 608 -# tests. 609 -AC_DEFUN([LT_OUTPUT], 610 -[: ${CONFIG_LT=./config.lt} 611 -AC_MSG_NOTICE([creating $CONFIG_LT]) 612 -_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], 613 -[# Run this file to recreate a libtool stub with the current configuration.]) 614 - 615 -cat >>"$CONFIG_LT" <<\_LTEOF 616 -lt_cl_silent=false 617 -exec AS_MESSAGE_LOG_FD>>config.log 618 -{ 619 - echo 620 - AS_BOX([Running $as_me.]) 621 -} >&AS_MESSAGE_LOG_FD 622 - 623 -lt_cl_help="\ 624 -\`$as_me' creates a local libtool stub from the current configuration, 625 -for use in further configure time tests before the real libtool is 626 -generated. 627 - 628 -Usage: $[0] [[OPTIONS]] 629 - 630 - -h, --help print this help, then exit 631 - -V, --version print version number, then exit 632 - -q, --quiet do not print progress messages 633 - -d, --debug don't remove temporary files 634 - 635 -Report bugs to <bug-libtool@gnu.org>." 636 - 637 -lt_cl_version="\ 638 -m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl 639 -m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) 640 -configured by $[0], generated by m4_PACKAGE_STRING. 641 - 642 -Copyright (C) 2011 Free Software Foundation, Inc. 643 -This config.lt script is free software; the Free Software Foundation 644 -gives unlimited permision to copy, distribute and modify it." 645 - 646 -while test $[#] != 0 647 -do 648 - case $[1] in 649 - --version | --v* | -V ) 650 - echo "$lt_cl_version"; exit 0 ;; 651 - --help | --h* | -h ) 652 - echo "$lt_cl_help"; exit 0 ;; 653 - --debug | --d* | -d ) 654 - debug=: ;; 655 - --quiet | --q* | --silent | --s* | -q ) 656 - lt_cl_silent=: ;; 657 - 658 - -*) AC_MSG_ERROR([unrecognized option: $[1] 659 -Try \`$[0] --help' for more information.]) ;; 660 - 661 - *) AC_MSG_ERROR([unrecognized argument: $[1] 662 -Try \`$[0] --help' for more information.]) ;; 663 - esac 664 - shift 665 -done 666 - 667 -if $lt_cl_silent; then 668 - exec AS_MESSAGE_FD>/dev/null 669 -fi 670 -_LTEOF 671 - 672 -cat >>"$CONFIG_LT" <<_LTEOF 673 -_LT_OUTPUT_LIBTOOL_COMMANDS_INIT 674 -_LTEOF 675 - 676 -cat >>"$CONFIG_LT" <<\_LTEOF 677 -AC_MSG_NOTICE([creating $ofile]) 678 -_LT_OUTPUT_LIBTOOL_COMMANDS 679 -AS_EXIT(0) 680 -_LTEOF 681 -chmod +x "$CONFIG_LT" 682 - 683 -# configure is writing to config.log, but config.lt does its own redirection, 684 -# appending to config.log, which fails on DOS, as config.log is still kept 685 -# open by configure. Here we exec the FD to /dev/null, effectively closing 686 -# config.log, so it can be properly (re)opened and appended to by config.lt. 687 -lt_cl_success=: 688 -test "$silent" = yes && 689 - lt_config_lt_args="$lt_config_lt_args --quiet" 690 -exec AS_MESSAGE_LOG_FD>/dev/null 691 -$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false 692 -exec AS_MESSAGE_LOG_FD>>config.log 693 -$lt_cl_success || AS_EXIT(1) 694 -])# LT_OUTPUT 695 - 696 - 697 -# _LT_CONFIG(TAG) 698 -# --------------- 699 -# If TAG is the built-in tag, create an initial libtool script with a 700 -# default configuration from the untagged config vars. Otherwise add code 701 -# to config.status for appending the configuration named by TAG from the 702 -# matching tagged config vars. 703 -m4_defun([_LT_CONFIG], 704 -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl 705 -_LT_CONFIG_SAVE_COMMANDS([ 706 - m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl 707 - m4_if(_LT_TAG, [C], [ 708 - # See if we are running on zsh, and set the options which allow our 709 - # commands through without removal of \ escapes. 710 - if test -n "${ZSH_VERSION+set}" ; then 711 - setopt NO_GLOB_SUBST 712 - fi 713 - 714 - cfgfile="${ofile}T" 715 - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 716 - $RM "$cfgfile" 717 - 718 - cat <<_LT_EOF >> "$cfgfile" 719 -#! $SHELL 720 - 721 -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. 722 -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION 723 -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: 724 -# NOTE: Changes made to this file will be lost: look at ltmain.sh. 725 -# 726 -_LT_COPYING 727 -_LT_LIBTOOL_TAGS 728 - 729 -# ### BEGIN LIBTOOL CONFIG 730 -_LT_LIBTOOL_CONFIG_VARS 731 -_LT_LIBTOOL_TAG_VARS 732 -# ### END LIBTOOL CONFIG 733 - 734 -_LT_EOF 735 - 736 - case $host_os in 737 - aix3*) 738 - cat <<\_LT_EOF >> "$cfgfile" 739 -# AIX sometimes has problems with the GCC collect2 program. For some 740 -# reason, if we set the COLLECT_NAMES environment variable, the problems 741 -# vanish in a puff of smoke. 742 -if test "X${COLLECT_NAMES+set}" != Xset; then 743 - COLLECT_NAMES= 744 - export COLLECT_NAMES 745 -fi 746 -_LT_EOF 747 - ;; 748 - esac 749 - 750 - _LT_PROG_LTMAIN 751 - 752 - # We use sed instead of cat because bash on DJGPP gets confused if 753 - # if finds mixed CR/LF and LF-only lines. Since sed operates in 754 - # text mode, it properly converts lines to CR/LF. This bash problem 755 - # is reportedly fixed, but why not run on old versions too? 756 - sed '$q' "$ltmain" >> "$cfgfile" \ 757 - || (rm -f "$cfgfile"; exit 1) 758 - 759 - _LT_PROG_REPLACE_SHELLFNS 760 - 761 - mv -f "$cfgfile" "$ofile" || 762 - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") 763 - chmod +x "$ofile" 764 -], 765 -[cat <<_LT_EOF >> "$ofile" 766 - 767 -dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded 768 -dnl in a comment (ie after a #). 769 -# ### BEGIN LIBTOOL TAG CONFIG: $1 770 -_LT_LIBTOOL_TAG_VARS(_LT_TAG) 771 -# ### END LIBTOOL TAG CONFIG: $1 772 -_LT_EOF 773 -])dnl /m4_if 774 -], 775 -[m4_if([$1], [], [ 776 - PACKAGE='$PACKAGE' 777 - VERSION='$VERSION' 778 - TIMESTAMP='$TIMESTAMP' 779 - RM='$RM' 780 - ofile='$ofile'], []) 781 -])dnl /_LT_CONFIG_SAVE_COMMANDS 782 -])# _LT_CONFIG 783 - 784 - 785 -# LT_SUPPORTED_TAG(TAG) 786 -# --------------------- 787 -# Trace this macro to discover what tags are supported by the libtool 788 -# --tag option, using: 789 -# autoconf --trace 'LT_SUPPORTED_TAG:$1' 790 -AC_DEFUN([LT_SUPPORTED_TAG], []) 791 - 792 - 793 -# C support is built-in for now 794 -m4_define([_LT_LANG_C_enabled], []) 795 -m4_define([_LT_TAGS], []) 796 - 797 - 798 -# LT_LANG(LANG) 799 -# ------------- 800 -# Enable libtool support for the given language if not already enabled. 801 -AC_DEFUN([LT_LANG], 802 -[AC_BEFORE([$0], [LT_OUTPUT])dnl 803 -m4_case([$1], 804 - [C], [_LT_LANG(C)], 805 - [C++], [_LT_LANG(CXX)], 806 - [Go], [_LT_LANG(GO)], 807 - [Java], [_LT_LANG(GCJ)], 808 - [Fortran 77], [_LT_LANG(F77)], 809 - [Fortran], [_LT_LANG(FC)], 810 - [Windows Resource], [_LT_LANG(RC)], 811 - [m4_ifdef([_LT_LANG_]$1[_CONFIG], 812 - [_LT_LANG($1)], 813 - [m4_fatal([$0: unsupported language: "$1"])])])dnl 814 -])# LT_LANG 815 - 816 - 817 -# _LT_LANG(LANGNAME) 818 -# ------------------ 819 -m4_defun([_LT_LANG], 820 -[m4_ifdef([_LT_LANG_]$1[_enabled], [], 821 - [LT_SUPPORTED_TAG([$1])dnl 822 - m4_append([_LT_TAGS], [$1 ])dnl 823 - m4_define([_LT_LANG_]$1[_enabled], [])dnl 824 - _LT_LANG_$1_CONFIG($1)])dnl 825 -])# _LT_LANG 826 - 827 - 828 -m4_ifndef([AC_PROG_GO], [ 829 -############################################################ 830 -# NOTE: This macro has been submitted for inclusion into # 831 -# GNU Autoconf as AC_PROG_GO. When it is available in # 832 -# a released version of Autoconf we should remove this # 833 -# macro and use it instead. # 834 -############################################################ 835 -m4_defun([AC_PROG_GO], 836 -[AC_LANG_PUSH(Go)dnl 837 -AC_ARG_VAR([GOC], [Go compiler command])dnl 838 -AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl 839 -_AC_ARG_VAR_LDFLAGS()dnl 840 -AC_CHECK_TOOL(GOC, gccgo) 841 -if test -z "$GOC"; then 842 - if test -n "$ac_tool_prefix"; then 843 - AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) 844 - fi 845 -fi 846 -if test -z "$GOC"; then 847 - AC_CHECK_PROG(GOC, gccgo, gccgo, false) 848 -fi 849 -])#m4_defun 850 -])#m4_ifndef 851 - 852 - 853 -# _LT_LANG_DEFAULT_CONFIG 854 -# ----------------------- 855 -m4_defun([_LT_LANG_DEFAULT_CONFIG], 856 -[AC_PROVIDE_IFELSE([AC_PROG_CXX], 857 - [LT_LANG(CXX)], 858 - [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) 859 - 860 -AC_PROVIDE_IFELSE([AC_PROG_F77], 861 - [LT_LANG(F77)], 862 - [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) 863 - 864 -AC_PROVIDE_IFELSE([AC_PROG_FC], 865 - [LT_LANG(FC)], 866 - [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) 867 - 868 -dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal 869 -dnl pulling things in needlessly. 870 -AC_PROVIDE_IFELSE([AC_PROG_GCJ], 871 - [LT_LANG(GCJ)], 872 - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], 873 - [LT_LANG(GCJ)], 874 - [AC_PROVIDE_IFELSE([LT_PROG_GCJ], 875 - [LT_LANG(GCJ)], 876 - [m4_ifdef([AC_PROG_GCJ], 877 - [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) 878 - m4_ifdef([A][M_PROG_GCJ], 879 - [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) 880 - m4_ifdef([LT_PROG_GCJ], 881 - [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) 882 - 883 -AC_PROVIDE_IFELSE([AC_PROG_GO], 884 - [LT_LANG(GO)], 885 - [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) 886 - 887 -AC_PROVIDE_IFELSE([LT_PROG_RC], 888 - [LT_LANG(RC)], 889 - [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) 890 -])# _LT_LANG_DEFAULT_CONFIG 891 - 892 -# Obsolete macros: 893 -AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) 894 -AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) 895 -AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) 896 -AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) 897 -AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) 898 -dnl aclocal-1.4 backwards compatibility: 899 -dnl AC_DEFUN([AC_LIBTOOL_CXX], []) 900 -dnl AC_DEFUN([AC_LIBTOOL_F77], []) 901 -dnl AC_DEFUN([AC_LIBTOOL_FC], []) 902 -dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) 903 -dnl AC_DEFUN([AC_LIBTOOL_RC], []) 904 - 905 - 906 -# _LT_TAG_COMPILER 907 -# ---------------- 908 -m4_defun([_LT_TAG_COMPILER], 909 -[AC_REQUIRE([AC_PROG_CC])dnl 910 - 911 -_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl 912 -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl 913 -_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl 914 -_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl 915 - 916 -# If no C compiler was specified, use CC. 917 -LTCC=${LTCC-"$CC"} 918 - 919 -# If no C compiler flags were specified, use CFLAGS. 920 -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} 921 - 922 -# Allow CC to be a program name with arguments. 923 -compiler=$CC 924 -])# _LT_TAG_COMPILER 925 - 926 - 927 -# _LT_COMPILER_BOILERPLATE 928 -# ------------------------ 929 -# Check for compiler boilerplate output or warnings with 930 -# the simple compiler test code. 931 -m4_defun([_LT_COMPILER_BOILERPLATE], 932 -[m4_require([_LT_DECL_SED])dnl 933 -ac_outfile=conftest.$ac_objext 934 -echo "$lt_simple_compile_test_code" >conftest.$ac_ext 935 -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err 936 -_lt_compiler_boilerplate=`cat conftest.err` 937 -$RM conftest* 938 -])# _LT_COMPILER_BOILERPLATE 939 - 940 - 941 -# _LT_LINKER_BOILERPLATE 942 -# ---------------------- 943 -# Check for linker boilerplate output or warnings with 944 -# the simple link test code. 945 -m4_defun([_LT_LINKER_BOILERPLATE], 946 -[m4_require([_LT_DECL_SED])dnl 947 -ac_outfile=conftest.$ac_objext 948 -echo "$lt_simple_link_test_code" >conftest.$ac_ext 949 -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err 950 -_lt_linker_boilerplate=`cat conftest.err` 951 -$RM -r conftest* 952 -])# _LT_LINKER_BOILERPLATE 953 - 954 -# _LT_REQUIRED_DARWIN_CHECKS 955 -# ------------------------- 956 -m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ 957 - case $host_os in 958 - rhapsody* | darwin*) 959 - AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) 960 - AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) 961 - AC_CHECK_TOOL([LIPO], [lipo], [:]) 962 - AC_CHECK_TOOL([OTOOL], [otool], [:]) 963 - AC_CHECK_TOOL([OTOOL64], [otool64], [:]) 964 - _LT_DECL([], [DSYMUTIL], [1], 965 - [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) 966 - _LT_DECL([], [NMEDIT], [1], 967 - [Tool to change global to local symbols on Mac OS X]) 968 - _LT_DECL([], [LIPO], [1], 969 - [Tool to manipulate fat objects and archives on Mac OS X]) 970 - _LT_DECL([], [OTOOL], [1], 971 - [ldd/readelf like tool for Mach-O binaries on Mac OS X]) 972 - _LT_DECL([], [OTOOL64], [1], 973 - [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) 974 - 975 - AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], 976 - [lt_cv_apple_cc_single_mod=no 977 - if test -z "${LT_MULTI_MODULE}"; then 978 - # By default we will add the -single_module flag. You can override 979 - # by either setting the environment variable LT_MULTI_MODULE 980 - # non-empty at configure time, or by adding -multi_module to the 981 - # link flags. 982 - rm -rf libconftest.dylib* 983 - echo "int foo(void){return 1;}" > conftest.c 984 - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ 985 --dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD 986 - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ 987 - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err 988 - _lt_result=$? 989 - # If there is a non-empty error log, and "single_module" 990 - # appears in it, assume the flag caused a linker warning 991 - if test -s conftest.err && $GREP single_module conftest.err; then 992 - cat conftest.err >&AS_MESSAGE_LOG_FD 993 - # Otherwise, if the output was created with a 0 exit code from 994 - # the compiler, it worked. 995 - elif test -f libconftest.dylib && test $_lt_result -eq 0; then 996 - lt_cv_apple_cc_single_mod=yes 997 - else 998 - cat conftest.err >&AS_MESSAGE_LOG_FD 999 - fi 1000 - rm -rf libconftest.dylib* 1001 - rm -f conftest.* 1002 - fi]) 1003 - 1004 - AC_CACHE_CHECK([for -exported_symbols_list linker flag], 1005 - [lt_cv_ld_exported_symbols_list], 1006 - [lt_cv_ld_exported_symbols_list=no 1007 - save_LDFLAGS=$LDFLAGS 1008 - echo "_main" > conftest.sym 1009 - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" 1010 - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], 1011 - [lt_cv_ld_exported_symbols_list=yes], 1012 - [lt_cv_ld_exported_symbols_list=no]) 1013 - LDFLAGS="$save_LDFLAGS" 1014 - ]) 1015 - 1016 - AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], 1017 - [lt_cv_ld_force_load=no 1018 - cat > conftest.c << _LT_EOF 1019 -int forced_loaded() { return 2;} 1020 -_LT_EOF 1021 - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD 1022 - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD 1023 - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD 1024 - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD 1025 - echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD 1026 - $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD 1027 - cat > conftest.c << _LT_EOF 1028 -int main() { return 0;} 1029 -_LT_EOF 1030 - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD 1031 - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err 1032 - _lt_result=$? 1033 - if test -s conftest.err && $GREP force_load conftest.err; then 1034 - cat conftest.err >&AS_MESSAGE_LOG_FD 1035 - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then 1036 - lt_cv_ld_force_load=yes 1037 - else 1038 - cat conftest.err >&AS_MESSAGE_LOG_FD 1039 - fi 1040 - rm -f conftest.err libconftest.a conftest conftest.c 1041 - rm -rf conftest.dSYM 1042 - ]) 1043 - case $host_os in 1044 - rhapsody* | darwin1.[[012]]) 1045 - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; 1046 - darwin1.*) 1047 - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 1048 - darwin*) # darwin 5.x on 1049 - # if running on 10.5 or later, the deployment target defaults 1050 - # to the OS version, if on x86, and 10.4, the deployment 1051 - # target defaults to 10.4. Don't you love it? 1052 - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 1053 - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) 1054 - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 1055 - 10.[[012]]*) 1056 - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 1057 - 10.*) 1058 - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 1059 - esac 1060 - ;; 1061 - esac 1062 - if test "$lt_cv_apple_cc_single_mod" = "yes"; then 1063 - _lt_dar_single_mod='$single_module' 1064 - fi 1065 - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then 1066 - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' 1067 - else 1068 - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' 1069 - fi 1070 - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then 1071 - _lt_dsymutil='~$DSYMUTIL $lib || :' 1072 - else 1073 - _lt_dsymutil= 1074 - fi 1075 - ;; 1076 - esac 1077 -]) 1078 - 1079 - 1080 -# _LT_DARWIN_LINKER_FEATURES([TAG]) 1081 -# --------------------------------- 1082 -# Checks for linker and compiler features on darwin 1083 -m4_defun([_LT_DARWIN_LINKER_FEATURES], 1084 -[ 1085 - m4_require([_LT_REQUIRED_DARWIN_CHECKS]) 1086 - _LT_TAGVAR(archive_cmds_need_lc, $1)=no 1087 - _LT_TAGVAR(hardcode_direct, $1)=no 1088 - _LT_TAGVAR(hardcode_automatic, $1)=yes 1089 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported 1090 - if test "$lt_cv_ld_force_load" = "yes"; then 1091 - _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' 1092 - m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], 1093 - [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) 1094 - else 1095 - _LT_TAGVAR(whole_archive_flag_spec, $1)='' 1096 - fi 1097 - _LT_TAGVAR(link_all_deplibs, $1)=yes 1098 - _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" 1099 - case $cc_basename in 1100 - ifort*) _lt_dar_can_shared=yes ;; 1101 - *) _lt_dar_can_shared=$GCC ;; 1102 - esac 1103 - if test "$_lt_dar_can_shared" = "yes"; then 1104 - output_verbose_link_cmd=func_echo_all 1105 - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" 1106 - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" 1107 - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" 1108 - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" 1109 - m4_if([$1], [CXX], 1110 -[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then 1111 - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" 1112 - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" 1113 - fi 1114 -],[]) 1115 - else 1116 - _LT_TAGVAR(ld_shlibs, $1)=no 1117 - fi 1118 -]) 1119 - 1120 -# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) 1121 -# ---------------------------------- 1122 -# Links a minimal program and checks the executable 1123 -# for the system default hardcoded library path. In most cases, 1124 -# this is /usr/lib:/lib, but when the MPI compilers are used 1125 -# the location of the communication and MPI libs are included too. 1126 -# If we don't find anything, use the default library path according 1127 -# to the aix ld manual. 1128 -# Store the results from the different compilers for each TAGNAME. 1129 -# Allow to override them for all tags through lt_cv_aix_libpath. 1130 -m4_defun([_LT_SYS_MODULE_PATH_AIX], 1131 -[m4_require([_LT_DECL_SED])dnl 1132 -if test "${lt_cv_aix_libpath+set}" = set; then 1133 - aix_libpath=$lt_cv_aix_libpath 1134 -else 1135 - AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], 1136 - [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ 1137 - lt_aix_libpath_sed='[ 1138 - /Import File Strings/,/^$/ { 1139 - /^0/ { 1140 - s/^0 *\([^ ]*\) *$/\1/ 1141 - p 1142 - } 1143 - }]' 1144 - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` 1145 - # Check for a 64-bit object if we didn't find anything. 1146 - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then 1147 - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` 1148 - fi],[]) 1149 - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then 1150 - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" 1151 - fi 1152 - ]) 1153 - aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) 1154 -fi 1155 -])# _LT_SYS_MODULE_PATH_AIX 1156 - 1157 - 1158 -# _LT_SHELL_INIT(ARG) 1159 -# ------------------- 1160 -m4_define([_LT_SHELL_INIT], 1161 -[m4_divert_text([M4SH-INIT], [$1 1162 -])])# _LT_SHELL_INIT 1163 - 1164 - 1165 - 1166 -# _LT_PROG_ECHO_BACKSLASH 1167 -# ----------------------- 1168 -# Find how we can fake an echo command that does not interpret backslash. 1169 -# In particular, with Autoconf 2.60 or later we add some code to the start 1170 -# of the generated configure script which will find a shell with a builtin 1171 -# printf (which we can use as an echo command). 1172 -m4_defun([_LT_PROG_ECHO_BACKSLASH], 1173 -[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' 1174 -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO 1175 -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO 1176 - 1177 -AC_MSG_CHECKING([how to print strings]) 1178 -# Test print first, because it will be a builtin if present. 1179 -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ 1180 - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then 1181 - ECHO='print -r --' 1182 -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then 1183 - ECHO='printf %s\n' 1184 -else 1185 - # Use this function as a fallback that always works. 1186 - func_fallback_echo () 1187 - { 1188 - eval 'cat <<_LTECHO_EOF 1189 -$[]1 1190 -_LTECHO_EOF' 1191 - } 1192 - ECHO='func_fallback_echo' 1193 -fi 1194 - 1195 -# func_echo_all arg... 1196 -# Invoke $ECHO with all args, space-separated. 1197 -func_echo_all () 1198 -{ 1199 - $ECHO "$*" 1200 -} 1201 - 1202 -case "$ECHO" in 1203 - printf*) AC_MSG_RESULT([printf]) ;; 1204 - print*) AC_MSG_RESULT([print -r]) ;; 1205 - *) AC_MSG_RESULT([cat]) ;; 1206 -esac 1207 - 1208 -m4_ifdef([_AS_DETECT_SUGGESTED], 1209 -[_AS_DETECT_SUGGESTED([ 1210 - test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( 1211 - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' 1212 - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO 1213 - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO 1214 - PATH=/empty FPATH=/empty; export PATH FPATH 1215 - test "X`printf %s $ECHO`" = "X$ECHO" \ 1216 - || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) 1217 - 1218 -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) 1219 -_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) 1220 -])# _LT_PROG_ECHO_BACKSLASH 1221 - 1222 - 1223 -# _LT_WITH_SYSROOT 1224 -# ---------------- 1225 -AC_DEFUN([_LT_WITH_SYSROOT], 1226 -[AC_MSG_CHECKING([for sysroot]) 1227 -AC_ARG_WITH([sysroot], 1228 -[ --with-sysroot[=DIR] Search for dependent libraries within DIR 1229 - (or the compiler's sysroot if not specified).], 1230 -[], [with_sysroot=no]) 1231 - 1232 -dnl lt_sysroot will always be passed unquoted. We quote it here 1233 -dnl in case the user passed a directory name. 1234 -lt_sysroot= 1235 -case ${with_sysroot} in #( 1236 - yes) 1237 - if test "$GCC" = yes; then 1238 - lt_sysroot=`$CC --print-sysroot 2>/dev/null` 1239 - fi 1240 - ;; #( 1241 - /*) 1242 - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` 1243 - ;; #( 1244 - no|'') 1245 - ;; #( 1246 - *) 1247 - AC_MSG_RESULT([${with_sysroot}]) 1248 - AC_MSG_ERROR([The sysroot must be an absolute path.]) 1249 - ;; 1250 -esac 1251 - 1252 - AC_MSG_RESULT([${lt_sysroot:-no}]) 1253 -_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl 1254 -[dependent libraries, and in which our libraries should be installed.])]) 1255 - 1256 -# _LT_ENABLE_LOCK 1257 -# --------------- 1258 -m4_defun([_LT_ENABLE_LOCK], 1259 -[AC_ARG_ENABLE([libtool-lock], 1260 - [AS_HELP_STRING([--disable-libtool-lock], 1261 - [avoid locking (might break parallel builds)])]) 1262 -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes 1263 - 1264 -# Some flags need to be propagated to the compiler or linker for good 1265 -# libtool support. 1266 -case $host in 1267 -ia64-*-hpux*) 1268 - # Find out which ABI we are using. 1269 - echo 'int i;' > conftest.$ac_ext 1270 - if AC_TRY_EVAL(ac_compile); then 1271 - case `/usr/bin/file conftest.$ac_objext` in 1272 - *ELF-32*) 1273 - HPUX_IA64_MODE="32" 1274 - ;; 1275 - *ELF-64*) 1276 - HPUX_IA64_MODE="64" 1277 - ;; 1278 - esac 1279 - fi 1280 - rm -rf conftest* 1281 - ;; 1282 -*-*-irix6*) 1283 - # Find out which ABI we are using. 1284 - echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext 1285 - if AC_TRY_EVAL(ac_compile); then 1286 - if test "$lt_cv_prog_gnu_ld" = yes; then 1287 - case `/usr/bin/file conftest.$ac_objext` in 1288 - *32-bit*) 1289 - LD="${LD-ld} -melf32bsmip" 1290 - ;; 1291 - *N32*) 1292 - LD="${LD-ld} -melf32bmipn32" 1293 - ;; 1294 - *64-bit*) 1295 - LD="${LD-ld} -melf64bmip" 1296 - ;; 1297 - esac 1298 - else 1299 - case `/usr/bin/file conftest.$ac_objext` in 1300 - *32-bit*) 1301 - LD="${LD-ld} -32" 1302 - ;; 1303 - *N32*) 1304 - LD="${LD-ld} -n32" 1305 - ;; 1306 - *64-bit*) 1307 - LD="${LD-ld} -64" 1308 - ;; 1309 - esac 1310 - fi 1311 - fi 1312 - rm -rf conftest* 1313 - ;; 1314 - 1315 -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ 1316 -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) 1317 - # Find out which ABI we are using. 1318 - echo 'int i;' > conftest.$ac_ext 1319 - if AC_TRY_EVAL(ac_compile); then 1320 - case `/usr/bin/file conftest.o` in 1321 - *32-bit*) 1322 - case $host in 1323 - x86_64-*kfreebsd*-gnu) 1324 - LD="${LD-ld} -m elf_i386_fbsd" 1325 - ;; 1326 - x86_64-*linux*) 1327 - LD="${LD-ld} -m elf_i386" 1328 - ;; 1329 - ppc64-*linux*|powerpc64-*linux*) 1330 - LD="${LD-ld} -m elf32ppclinux" 1331 - ;; 1332 - s390x-*linux*) 1333 - LD="${LD-ld} -m elf_s390" 1334 - ;; 1335 - sparc64-*linux*) 1336 - LD="${LD-ld} -m elf32_sparc" 1337 - ;; 1338 - esac 1339 - ;; 1340 - *64-bit*) 1341 - case $host in 1342 - x86_64-*kfreebsd*-gnu) 1343 - LD="${LD-ld} -m elf_x86_64_fbsd" 1344 - ;; 1345 - x86_64-*linux*) 1346 - LD="${LD-ld} -m elf_x86_64" 1347 - ;; 1348 - ppc*-*linux*|powerpc*-*linux*) 1349 - LD="${LD-ld} -m elf64ppc" 1350 - ;; 1351 - s390*-*linux*|s390*-*tpf*) 1352 - LD="${LD-ld} -m elf64_s390" 1353 - ;; 1354 - sparc*-*linux*) 1355 - LD="${LD-ld} -m elf64_sparc" 1356 - ;; 1357 - esac 1358 - ;; 1359 - esac 1360 - fi 1361 - rm -rf conftest* 1362 - ;; 1363 - 1364 -*-*-sco3.2v5*) 1365 - # On SCO OpenServer 5, we need -belf to get full-featured binaries. 1366 - SAVE_CFLAGS="$CFLAGS" 1367 - CFLAGS="$CFLAGS -belf" 1368 - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, 1369 - [AC_LANG_PUSH(C) 1370 - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) 1371 - AC_LANG_POP]) 1372 - if test x"$lt_cv_cc_needs_belf" != x"yes"; then 1373 - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf 1374 - CFLAGS="$SAVE_CFLAGS" 1375 - fi 1376 - ;; 1377 -*-*solaris*) 1378 - # Find out which ABI we are using. 1379 - echo 'int i;' > conftest.$ac_ext 1380 - if AC_TRY_EVAL(ac_compile); then 1381 - case `/usr/bin/file conftest.o` in 1382 - *64-bit*) 1383 - case $lt_cv_prog_gnu_ld in 1384 - yes*) 1385 - case $host in 1386 - i?86-*-solaris*) 1387 - LD="${LD-ld} -m elf_x86_64" 1388 - ;; 1389 - sparc*-*-solaris*) 1390 - LD="${LD-ld} -m elf64_sparc" 1391 - ;; 1392 - esac 1393 - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. 1394 - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then 1395 - LD="${LD-ld}_sol2" 1396 - fi 1397 - ;; 1398 - *) 1399 - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then 1400 - LD="${LD-ld} -64" 1401 - fi 1402 - ;; 1403 - esac 1404 - ;; 1405 - esac 1406 - fi 1407 - rm -rf conftest* 1408 - ;; 1409 -esac 1410 - 1411 -need_locks="$enable_libtool_lock" 1412 -])# _LT_ENABLE_LOCK 1413 - 1414 - 1415 -# _LT_PROG_AR 1416 -# ----------- 1417 -m4_defun([_LT_PROG_AR], 1418 -[AC_CHECK_TOOLS(AR, [ar], false) 1419 -: ${AR=ar} 1420 -: ${AR_FLAGS=cru} 1421 -_LT_DECL([], [AR], [1], [The archiver]) 1422 -_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) 1423 - 1424 -AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], 1425 - [lt_cv_ar_at_file=no 1426 - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], 1427 - [echo conftest.$ac_objext > conftest.lst 1428 - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' 1429 - AC_TRY_EVAL([lt_ar_try]) 1430 - if test "$ac_status" -eq 0; then 1431 - # Ensure the archiver fails upon bogus file names. 1432 - rm -f conftest.$ac_objext libconftest.a 1433 - AC_TRY_EVAL([lt_ar_try]) 1434 - if test "$ac_status" -ne 0; then 1435 - lt_cv_ar_at_file=@ 1436 - fi 1437 - fi 1438 - rm -f conftest.* libconftest.a 1439 - ]) 1440 - ]) 1441 - 1442 -if test "x$lt_cv_ar_at_file" = xno; then 1443 - archiver_list_spec= 1444 -else 1445 - archiver_list_spec=$lt_cv_ar_at_file 1446 -fi 1447 -_LT_DECL([], [archiver_list_spec], [1], 1448 - [How to feed a file listing to the archiver]) 1449 -])# _LT_PROG_AR 1450 - 1451 - 1452 -# _LT_CMD_OLD_ARCHIVE 1453 -# ------------------- 1454 -m4_defun([_LT_CMD_OLD_ARCHIVE], 1455 -[_LT_PROG_AR 1456 - 1457 -AC_CHECK_TOOL(STRIP, strip, :) 1458 -test -z "$STRIP" && STRIP=: 1459 -_LT_DECL([], [STRIP], [1], [A symbol stripping program]) 1460 - 1461 -AC_CHECK_TOOL(RANLIB, ranlib, :) 1462 -test -z "$RANLIB" && RANLIB=: 1463 -_LT_DECL([], [RANLIB], [1], 1464 - [Commands used to install an old-style archive]) 1465 - 1466 -# Determine commands to create old-style static archives. 1467 -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' 1468 -old_postinstall_cmds='chmod 644 $oldlib' 1469 -old_postuninstall_cmds= 1470 - 1471 -if test -n "$RANLIB"; then 1472 - case $host_os in 1473 - openbsd*) 1474 - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" 1475 - ;; 1476 - *) 1477 - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" 1478 - ;; 1479 - esac 1480 - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" 1481 -fi 1482 - 1483 -case $host_os in 1484 - darwin*) 1485 - lock_old_archive_extraction=yes ;; 1486 - *) 1487 - lock_old_archive_extraction=no ;; 1488 -esac 1489 -_LT_DECL([], [old_postinstall_cmds], [2]) 1490 -_LT_DECL([], [old_postuninstall_cmds], [2]) 1491 -_LT_TAGDECL([], [old_archive_cmds], [2], 1492 - [Commands used to build an old-style archive]) 1493 -_LT_DECL([], [lock_old_archive_extraction], [0], 1494 - [Whether to use a lock for old archive extraction]) 1495 -])# _LT_CMD_OLD_ARCHIVE 1496 - 1497 - 1498 -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, 1499 -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) 1500 -# ---------------------------------------------------------------- 1501 -# Check whether the given compiler option works 1502 -AC_DEFUN([_LT_COMPILER_OPTION], 1503 -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl 1504 -m4_require([_LT_DECL_SED])dnl 1505 -AC_CACHE_CHECK([$1], [$2], 1506 - [$2=no 1507 - m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) 1508 - echo "$lt_simple_compile_test_code" > conftest.$ac_ext 1509 - lt_compiler_flag="$3" 1510 - # Insert the option either (1) after the last *FLAGS variable, or 1511 - # (2) before a word containing "conftest.", or (3) at the end. 1512 - # Note that $ac_compile itself does not contain backslashes and begins 1513 - # with a dollar sign (not a hyphen), so the echo should work correctly. 1514 - # The option is referenced via a variable to avoid confusing sed. 1515 - lt_compile=`echo "$ac_compile" | $SED \ 1516 - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ 1517 - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ 1518 - -e 's:$: $lt_compiler_flag:'` 1519 - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) 1520 - (eval "$lt_compile" 2>conftest.err) 1521 - ac_status=$? 1522 - cat conftest.err >&AS_MESSAGE_LOG_FD 1523 - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD 1524 - if (exit $ac_status) && test -s "$ac_outfile"; then 1525 - # The compiler can only warn and ignore the option if not recognized 1526 - # So say no if there are warnings other than the usual output. 1527 - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp 1528 - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 1529 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then 1530 - $2=yes 1531 - fi 1532 - fi 1533 - $RM conftest* 1534 -]) 1535 - 1536 -if test x"[$]$2" = xyes; then 1537 - m4_if([$5], , :, [$5]) 1538 -else 1539 - m4_if([$6], , :, [$6]) 1540 -fi 1541 -])# _LT_COMPILER_OPTION 1542 - 1543 -# Old name: 1544 -AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) 1545 -dnl aclocal-1.4 backwards compatibility: 1546 -dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) 1547 - 1548 - 1549 -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, 1550 -# [ACTION-SUCCESS], [ACTION-FAILURE]) 1551 -# ---------------------------------------------------- 1552 -# Check whether the given linker option works 1553 -AC_DEFUN([_LT_LINKER_OPTION], 1554 -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl 1555 -m4_require([_LT_DECL_SED])dnl 1556 -AC_CACHE_CHECK([$1], [$2], 1557 - [$2=no 1558 - save_LDFLAGS="$LDFLAGS" 1559 - LDFLAGS="$LDFLAGS $3" 1560 - echo "$lt_simple_link_test_code" > conftest.$ac_ext 1561 - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then 1562 - # The linker can only warn and ignore the option if not recognized 1563 - # So say no if there are warnings 1564 - if test -s conftest.err; then 1565 - # Append any errors to the config.log. 1566 - cat conftest.err 1>&AS_MESSAGE_LOG_FD 1567 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp 1568 - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 1569 - if diff conftest.exp conftest.er2 >/dev/null; then 1570 - $2=yes 1571 - fi 1572 - else 1573 - $2=yes 1574 - fi 1575 - fi 1576 - $RM -r conftest* 1577 - LDFLAGS="$save_LDFLAGS" 1578 -]) 1579 - 1580 -if test x"[$]$2" = xyes; then 1581 - m4_if([$4], , :, [$4]) 1582 -else 1583 - m4_if([$5], , :, [$5]) 1584 -fi 1585 -])# _LT_LINKER_OPTION 1586 - 1587 -# Old name: 1588 -AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) 1589 -dnl aclocal-1.4 backwards compatibility: 1590 -dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) 1591 - 1592 - 1593 -# LT_CMD_MAX_LEN 1594 -#--------------- 1595 -AC_DEFUN([LT_CMD_MAX_LEN], 1596 -[AC_REQUIRE([AC_CANONICAL_HOST])dnl 1597 -# find the maximum length of command line arguments 1598 -AC_MSG_CHECKING([the maximum length of command line arguments]) 1599 -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl 1600 - i=0 1601 - teststring="ABCD" 1602 - 1603 - case $build_os in 1604 - msdosdjgpp*) 1605 - # On DJGPP, this test can blow up pretty badly due to problems in libc 1606 - # (any single argument exceeding 2000 bytes causes a buffer overrun 1607 - # during glob expansion). Even if it were fixed, the result of this 1608 - # check would be larger than it should be. 1609 - lt_cv_sys_max_cmd_len=12288; # 12K is about right 1610 - ;; 1611 - 1612 - gnu*) 1613 - # Under GNU Hurd, this test is not required because there is 1614 - # no limit to the length of command line arguments. 1615 - # Libtool will interpret -1 as no limit whatsoever 1616 - lt_cv_sys_max_cmd_len=-1; 1617 - ;; 1618 - 1619 - cygwin* | mingw* | cegcc*) 1620 - # On Win9x/ME, this test blows up -- it succeeds, but takes 1621 - # about 5 minutes as the teststring grows exponentially. 1622 - # Worse, since 9x/ME are not pre-emptively multitasking, 1623 - # you end up with a "frozen" computer, even though with patience 1624 - # the test eventually succeeds (with a max line length of 256k). 1625 - # Instead, let's just punt: use the minimum linelength reported by 1626 - # all of the supported platforms: 8192 (on NT/2K/XP). 1627 - lt_cv_sys_max_cmd_len=8192; 1628 - ;; 1629 - 1630 - mint*) 1631 - # On MiNT this can take a long time and run out of memory. 1632 - lt_cv_sys_max_cmd_len=8192; 1633 - ;; 1634 - 1635 - amigaos*) 1636 - # On AmigaOS with pdksh, this test takes hours, literally. 1637 - # So we just punt and use a minimum line length of 8192. 1638 - lt_cv_sys_max_cmd_len=8192; 1639 - ;; 1640 - 1641 - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) 1642 - # This has been around since 386BSD, at least. Likely further. 1643 - if test -x /sbin/sysctl; then 1644 - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` 1645 - elif test -x /usr/sbin/sysctl; then 1646 - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` 1647 - else 1648 - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs 1649 - fi 1650 - # And add a safety zone 1651 - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` 1652 - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` 1653 - ;; 1654 - 1655 - interix*) 1656 - # We know the value 262144 and hardcode it with a safety zone (like BSD) 1657 - lt_cv_sys_max_cmd_len=196608 1658 - ;; 1659 - 1660 - os2*) 1661 - # The test takes a long time on OS/2. 1662 - lt_cv_sys_max_cmd_len=8192 1663 - ;; 1664 - 1665 - osf*) 1666 - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure 1667 - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not 1668 - # nice to cause kernel panics so lets avoid the loop below. 1669 - # First set a reasonable default. 1670 - lt_cv_sys_max_cmd_len=16384 1671 - # 1672 - if test -x /sbin/sysconfig; then 1673 - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in 1674 - *1*) lt_cv_sys_max_cmd_len=-1 ;; 1675 - esac 1676 - fi 1677 - ;; 1678 - sco3.2v5*) 1679 - lt_cv_sys_max_cmd_len=102400 1680 - ;; 1681 - sysv5* | sco5v6* | sysv4.2uw2*) 1682 - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` 1683 - if test -n "$kargmax"; then 1684 - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` 1685 - else 1686 - lt_cv_sys_max_cmd_len=32768 1687 - fi 1688 - ;; 1689 - *) 1690 - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` 1691 - if test -n "$lt_cv_sys_max_cmd_len"; then 1692 - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` 1693 - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` 1694 - else 1695 - # Make teststring a little bigger before we do anything with it. 1696 - # a 1K string should be a reasonable start. 1697 - for i in 1 2 3 4 5 6 7 8 ; do 1698 - teststring=$teststring$teststring 1699 - done 1700 - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} 1701 - # If test is not a shell built-in, we'll probably end up computing a 1702 - # maximum length that is only half of the actual maximum length, but 1703 - # we can't tell. 1704 - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ 1705 - = "X$teststring$teststring"; } >/dev/null 2>&1 && 1706 - test $i != 17 # 1/2 MB should be enough 1707 - do 1708 - i=`expr $i + 1` 1709 - teststring=$teststring$teststring 1710 - done 1711 - # Only check the string length outside the loop. 1712 - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` 1713 - teststring= 1714 - # Add a significant safety factor because C++ compilers can tack on 1715 - # massive amounts of additional arguments before passing them to the 1716 - # linker. It appears as though 1/2 is a usable value. 1717 - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` 1718 - fi 1719 - ;; 1720 - esac 1721 -]) 1722 -if test -n $lt_cv_sys_max_cmd_len ; then 1723 - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) 1724 -else 1725 - AC_MSG_RESULT(none) 1726 -fi 1727 -max_cmd_len=$lt_cv_sys_max_cmd_len 1728 -_LT_DECL([], [max_cmd_len], [0], 1729 - [What is the maximum length of a command?]) 1730 -])# LT_CMD_MAX_LEN 1731 - 1732 -# Old name: 1733 -AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) 1734 -dnl aclocal-1.4 backwards compatibility: 1735 -dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) 1736 - 1737 - 1738 -# _LT_HEADER_DLFCN 1739 -# ---------------- 1740 -m4_defun([_LT_HEADER_DLFCN], 1741 -[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl 1742 -])# _LT_HEADER_DLFCN 1743 - 1744 - 1745 -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, 1746 -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) 1747 -# ---------------------------------------------------------------- 1748 -m4_defun([_LT_TRY_DLOPEN_SELF], 1749 -[m4_require([_LT_HEADER_DLFCN])dnl 1750 -if test "$cross_compiling" = yes; then : 1751 - [$4] 1752 -else 1753 - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 1754 - lt_status=$lt_dlunknown 1755 - cat > conftest.$ac_ext <<_LT_EOF 1756 -[#line $LINENO "configure" 1757 -#include "confdefs.h" 1758 - 1759 -#if HAVE_DLFCN_H 1760 -#include <dlfcn.h> 1761 -#endif 1762 - 1763 -#include <stdio.h> 1764 - 1765 -#ifdef RTLD_GLOBAL 1766 -# define LT_DLGLOBAL RTLD_GLOBAL 1767 -#else 1768 -# ifdef DL_GLOBAL 1769 -# define LT_DLGLOBAL DL_GLOBAL 1770 -# else 1771 -# define LT_DLGLOBAL 0 1772 -# endif 1773 -#endif 1774 - 1775 -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we 1776 - find out it does not work in some platform. */ 1777 -#ifndef LT_DLLAZY_OR_NOW 1778 -# ifdef RTLD_LAZY 1779 -# define LT_DLLAZY_OR_NOW RTLD_LAZY 1780 -# else 1781 -# ifdef DL_LAZY 1782 -# define LT_DLLAZY_OR_NOW DL_LAZY 1783 -# else 1784 -# ifdef RTLD_NOW 1785 -# define LT_DLLAZY_OR_NOW RTLD_NOW 1786 -# else 1787 -# ifdef DL_NOW 1788 -# define LT_DLLAZY_OR_NOW DL_NOW 1789 -# else 1790 -# define LT_DLLAZY_OR_NOW 0 1791 -# endif 1792 -# endif 1793 -# endif 1794 -# endif 1795 -#endif 1796 - 1797 -/* When -fvisbility=hidden is used, assume the code has been annotated 1798 - correspondingly for the symbols needed. */ 1799 -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) 1800 -int fnord () __attribute__((visibility("default"))); 1801 -#endif 1802 - 1803 -int fnord () { return 42; } 1804 -int main () 1805 -{ 1806 - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); 1807 - int status = $lt_dlunknown; 1808 - 1809 - if (self) 1810 - { 1811 - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; 1812 - else 1813 - { 1814 - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; 1815 - else puts (dlerror ()); 1816 - } 1817 - /* dlclose (self); */ 1818 - } 1819 - else 1820 - puts (dlerror ()); 1821 - 1822 - return status; 1823 -}] 1824 -_LT_EOF 1825 - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then 1826 - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null 1827 - lt_status=$? 1828 - case x$lt_status in 1829 - x$lt_dlno_uscore) $1 ;; 1830 - x$lt_dlneed_uscore) $2 ;; 1831 - x$lt_dlunknown|x*) $3 ;; 1832 - esac 1833 - else : 1834 - # compilation failed 1835 - $3 1836 - fi 1837 -fi 1838 -rm -fr conftest* 1839 -])# _LT_TRY_DLOPEN_SELF 1840 - 1841 - 1842 -# LT_SYS_DLOPEN_SELF 1843 -# ------------------ 1844 -AC_DEFUN([LT_SYS_DLOPEN_SELF], 1845 -[m4_require([_LT_HEADER_DLFCN])dnl 1846 -if test "x$enable_dlopen" != xyes; then 1847 - enable_dlopen=unknown 1848 - enable_dlopen_self=unknown 1849 - enable_dlopen_self_static=unknown 1850 -else 1851 - lt_cv_dlopen=no 1852 - lt_cv_dlopen_libs= 1853 - 1854 - case $host_os in 1855 - beos*) 1856 - lt_cv_dlopen="load_add_on" 1857 - lt_cv_dlopen_libs= 1858 - lt_cv_dlopen_self=yes 1859 - ;; 1860 - 1861 - mingw* | pw32* | cegcc*) 1862 - lt_cv_dlopen="LoadLibrary" 1863 - lt_cv_dlopen_libs= 1864 - ;; 1865 - 1866 - cygwin*) 1867 - lt_cv_dlopen="dlopen" 1868 - lt_cv_dlopen_libs= 1869 - ;; 1870 - 1871 - darwin*) 1872 - # if libdl is installed we need to link against it 1873 - AC_CHECK_LIB([dl], [dlopen], 1874 - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ 1875 - lt_cv_dlopen="dyld" 1876 - lt_cv_dlopen_libs= 1877 - lt_cv_dlopen_self=yes 1878 - ]) 1879 - ;; 1880 - 1881 - *) 1882 - AC_CHECK_FUNC([shl_load], 1883 - [lt_cv_dlopen="shl_load"], 1884 - [AC_CHECK_LIB([dld], [shl_load], 1885 - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], 1886 - [AC_CHECK_FUNC([dlopen], 1887 - [lt_cv_dlopen="dlopen"], 1888 - [AC_CHECK_LIB([dl], [dlopen], 1889 - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], 1890 - [AC_CHECK_LIB([svld], [dlopen], 1891 - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], 1892 - [AC_CHECK_LIB([dld], [dld_link], 1893 - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) 1894 - ]) 1895 - ]) 1896 - ]) 1897 - ]) 1898 - ]) 1899 - ;; 1900 - esac 1901 - 1902 - if test "x$lt_cv_dlopen" != xno; then 1903 - enable_dlopen=yes 1904 - else 1905 - enable_dlopen=no 1906 - fi 1907 - 1908 - case $lt_cv_dlopen in 1909 - dlopen) 1910 - save_CPPFLAGS="$CPPFLAGS" 1911 - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" 1912 - 1913 - save_LDFLAGS="$LDFLAGS" 1914 - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" 1915 - 1916 - save_LIBS="$LIBS" 1917 - LIBS="$lt_cv_dlopen_libs $LIBS" 1918 - 1919 - AC_CACHE_CHECK([whether a program can dlopen itself], 1920 - lt_cv_dlopen_self, [dnl 1921 - _LT_TRY_DLOPEN_SELF( 1922 - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, 1923 - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) 1924 - ]) 1925 - 1926 - if test "x$lt_cv_dlopen_self" = xyes; then 1927 - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" 1928 - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], 1929 - lt_cv_dlopen_self_static, [dnl 1930 - _LT_TRY_DLOPEN_SELF( 1931 - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, 1932 - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) 1933 - ]) 1934 - fi 1935 - 1936 - CPPFLAGS="$save_CPPFLAGS" 1937 - LDFLAGS="$save_LDFLAGS" 1938 - LIBS="$save_LIBS" 1939 - ;; 1940 - esac 1941 - 1942 - case $lt_cv_dlopen_self in 1943 - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; 1944 - *) enable_dlopen_self=unknown ;; 1945 - esac 1946 - 1947 - case $lt_cv_dlopen_self_static in 1948 - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; 1949 - *) enable_dlopen_self_static=unknown ;; 1950 - esac 1951 -fi 1952 -_LT_DECL([dlopen_support], [enable_dlopen], [0], 1953 - [Whether dlopen is supported]) 1954 -_LT_DECL([dlopen_self], [enable_dlopen_self], [0], 1955 - [Whether dlopen of programs is supported]) 1956 -_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], 1957 - [Whether dlopen of statically linked programs is supported]) 1958 -])# LT_SYS_DLOPEN_SELF 1959 - 1960 -# Old name: 1961 -AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) 1962 -dnl aclocal-1.4 backwards compatibility: 1963 -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) 1964 - 1965 - 1966 -# _LT_COMPILER_C_O([TAGNAME]) 1967 -# --------------------------- 1968 -# Check to see if options -c and -o are simultaneously supported by compiler. 1969 -# This macro does not hard code the compiler like AC_PROG_CC_C_O. 1970 -m4_defun([_LT_COMPILER_C_O], 1971 -[m4_require([_LT_DECL_SED])dnl 1972 -m4_require([_LT_FILEUTILS_DEFAULTS])dnl 1973 -m4_require([_LT_TAG_COMPILER])dnl 1974 -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], 1975 - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], 1976 - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no 1977 - $RM -r conftest 2>/dev/null 1978 - mkdir conftest 1979 - cd conftest 1980 - mkdir out 1981 - echo "$lt_simple_compile_test_code" > conftest.$ac_ext 1982 - 1983 - lt_compiler_flag="-o out/conftest2.$ac_objext" 1984 - # Insert the option either (1) after the last *FLAGS variable, or 1985 - # (2) before a word containing "conftest.", or (3) at the end. 1986 - # Note that $ac_compile itself does not contain backslashes and begins 1987 - # with a dollar sign (not a hyphen), so the echo should work correctly. 1988 - lt_compile=`echo "$ac_compile" | $SED \ 1989 - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ 1990 - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ 1991 - -e 's:$: $lt_compiler_flag:'` 1992 - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) 1993 - (eval "$lt_compile" 2>out/conftest.err) 1994 - ac_status=$? 1995 - cat out/conftest.err >&AS_MESSAGE_LOG_FD 1996 - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD 1997 - if (exit $ac_status) && test -s out/conftest2.$ac_objext 1998 - then 1999 - # The compiler can only warn and ignore the option if not recognized 2000 - # So say no if there are warnings 2001 - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp 2002 - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 2003 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then 2004 - _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes 2005 - fi 2006 - fi 2007 - chmod u+w . 2>&AS_MESSAGE_LOG_FD 2008 - $RM conftest* 2009 - # SGI C++ compiler will create directory out/ii_files/ for 2010 - # template instantiation 2011 - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files 2012 - $RM out/* && rmdir out 2013 - cd .. 2014 - $RM -r conftest 2015 - $RM conftest* 2016 -]) 2017 -_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], 2018 - [Does compiler simultaneously support -c and -o options?]) 2019 -])# _LT_COMPILER_C_O 2020 - 2021 - 2022 -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) 2023 -# ---------------------------------- 2024 -# Check to see if we can do hard links to lock some files if needed 2025 -m4_defun([_LT_COMPILER_FILE_LOCKS], 2026 -[m4_require([_LT_ENABLE_LOCK])dnl 2027 -m4_require([_LT_FILEUTILS_DEFAULTS])dnl 2028 -_LT_COMPILER_C_O([$1]) 2029 - 2030 -hard_links="nottested" 2031 -if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then 2032 - # do not overwrite the value of need_locks provided by the user 2033 - AC_MSG_CHECKING([if we can lock with hard links]) 2034 - hard_links=yes 2035 - $RM conftest* 2036 - ln conftest.a conftest.b 2>/dev/null && hard_links=no 2037 - touch conftest.a 2038 - ln conftest.a conftest.b 2>&5 || hard_links=no 2039 - ln conftest.a conftest.b 2>/dev/null && hard_links=no 2040 - AC_MSG_RESULT([$hard_links]) 2041 - if test "$hard_links" = no; then 2042 - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) 2043 - need_locks=warn 2044 - fi 2045 -else 2046 - need_locks=no 2047 -fi 2048 -_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) 2049 -])# _LT_COMPILER_FILE_LOCKS 2050 - 2051 - 2052 -# _LT_CHECK_OBJDIR 2053 -# ---------------- 2054 -m4_defun([_LT_CHECK_OBJDIR], 2055 -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], 2056 -[rm -f .libs 2>/dev/null 2057 -mkdir .libs 2>/dev/null 2058 -if test -d .libs; then 2059 - lt_cv_objdir=.libs 2060 -else 2061 - # MS-DOS does not allow filenames that begin with a dot. 2062 - lt_cv_objdir=_libs 2063 -fi 2064 -rmdir .libs 2>/dev/null]) 2065 -objdir=$lt_cv_objdir 2066 -_LT_DECL([], [objdir], [0], 2067 - [The name of the directory that contains temporary libtool files])dnl 2068 -m4_pattern_allow([LT_OBJDIR])dnl 2069 -AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", 2070 - [Define to the sub-directory in which libtool stores uninstalled libraries.]) 2071 -])# _LT_CHECK_OBJDIR 2072 - 2073 - 2074 -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) 2075 -# -------------------------------------- 2076 -# Check hardcoding attributes. 2077 -m4_defun([_LT_LINKER_HARDCODE_LIBPATH], 2078 -[AC_MSG_CHECKING([how to hardcode library paths into programs]) 2079 -_LT_TAGVAR(hardcode_action, $1)= 2080 -if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || 2081 - test -n "$_LT_TAGVAR(runpath_var, $1)" || 2082 - test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then 2083 - 2084 - # We can hardcode non-existent directories. 2085 - if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && 2086 - # If the only mechanism to avoid hardcoding is shlibpath_var, we 2087 - # have to relink, otherwise we might link with an installed library 2088 - # when we should be linking with a yet-to-be-installed one 2089 - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && 2090 - test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then 2091 - # Linking always hardcodes the temporary library directory. 2092 - _LT_TAGVAR(hardcode_action, $1)=relink 2093 - else 2094 - # We can link without hardcoding, and we can hardcode nonexisting dirs. 2095 - _LT_TAGVAR(hardcode_action, $1)=immediate 2096 - fi 2097 -else 2098 - # We cannot hardcode anything, or else we can only hardcode existing 2099 - # directories. 2100 - _LT_TAGVAR(hardcode_action, $1)=unsupported 2101 -fi 2102 -AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) 2103 - 2104 -if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || 2105 - test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then 2106 - # Fast installation is not supported 2107 - enable_fast_install=no 2108 -elif test "$shlibpath_overrides_runpath" = yes || 2109 - test "$enable_shared" = no; then 2110 - # Fast installation is not necessary 2111 - enable_fast_install=needless 2112 -fi 2113 -_LT_TAGDECL([], [hardcode_action], [0], 2114 - [How to hardcode a shared library path into an executable]) 2115 -])# _LT_LINKER_HARDCODE_LIBPATH 2116 - 2117 - 2118 -# _LT_CMD_STRIPLIB 2119 -# ---------------- 2120 -m4_defun([_LT_CMD_STRIPLIB], 2121 -[m4_require([_LT_DECL_EGREP]) 2122 -striplib= 2123 -old_striplib= 2124 -AC_MSG_CHECKING([whether stripping libraries is possible]) 2125 -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then 2126 - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" 2127 - test -z "$striplib" && striplib="$STRIP --strip-unneeded" 2128 - AC_MSG_RESULT([yes]) 2129 -else 2130 -# FIXME - insert some real tests, host_os isn't really good enough 2131 - case $host_os in 2132 - darwin*) 2133 - if test -n "$STRIP" ; then 2134 - striplib="$STRIP -x" 2135 - old_striplib="$STRIP -S" 2136 - AC_MSG_RESULT([yes]) 2137 - else 2138 - AC_MSG_RESULT([no]) 2139 - fi 2140 - ;; 2141 - *) 2142 - AC_MSG_RESULT([no]) 2143 - ;; 2144 - esac 2145 -fi 2146 -_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) 2147 -_LT_DECL([], [striplib], [1]) 2148 -])# _LT_CMD_STRIPLIB 2149 - 2150 - 2151 -# _LT_SYS_DYNAMIC_LINKER([TAG]) 2152 -# ----------------------------- 2153 -# PORTME Fill in your ld.so characteristics 2154 -m4_defun([_LT_SYS_DYNAMIC_LINKER], 2155 -[AC_REQUIRE([AC_CANONICAL_HOST])dnl 2156 -m4_require([_LT_DECL_EGREP])dnl 2157 -m4_require([_LT_FILEUTILS_DEFAULTS])dnl 2158 -m4_require([_LT_DECL_OBJDUMP])dnl 2159 -m4_require([_LT_DECL_SED])dnl 2160 -m4_require([_LT_CHECK_SHELL_FEATURES])dnl 2161 -AC_MSG_CHECKING([dynamic linker characteristics]) 2162 -m4_if([$1], 2163 - [], [ 2164 -if test "$GCC" = yes; then 2165 - case $host_os in 2166 - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; 2167 - *) lt_awk_arg="/^libraries:/" ;; 2168 - esac 2169 - case $host_os in 2170 - mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; 2171 - *) lt_sed_strip_eq="s,=/,/,g" ;; 2172 - esac 2173 - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` 2174 - case $lt_search_path_spec in 2175 - *\;*) 2176 - # if the path contains ";" then we assume it to be the separator 2177 - # otherwise default to the standard path separator (i.e. ":") - it is 2178 - # assumed that no part of a normal pathname contains ";" but that should 2179 - # okay in the real world where ";" in dirpaths is itself problematic. 2180 - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` 2181 - ;; 2182 - *) 2183 - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` 2184 - ;; 2185 - esac 2186 - # Ok, now we have the path, separated by spaces, we can step through it 2187 - # and add multilib dir if necessary. 2188 - lt_tmp_lt_search_path_spec= 2189 - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` 2190 - for lt_sys_path in $lt_search_path_spec; do 2191 - if test -d "$lt_sys_path/$lt_multi_os_dir"; then 2192 - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" 2193 - else 2194 - test -d "$lt_sys_path" && \ 2195 - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" 2196 - fi 2197 - done 2198 - lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' 2199 -BEGIN {RS=" "; FS="/|\n";} { 2200 - lt_foo=""; 2201 - lt_count=0; 2202 - for (lt_i = NF; lt_i > 0; lt_i--) { 2203 - if ($lt_i != "" && $lt_i != ".") { 2204 - if ($lt_i == "..") { 2205 - lt_count++; 2206 - } else { 2207 - if (lt_count == 0) { 2208 - lt_foo="/" $lt_i lt_foo; 2209 - } else { 2210 - lt_count--; 2211 - } 2212 - } 2213 - } 2214 - } 2215 - if (lt_foo != "") { lt_freq[[lt_foo]]++; } 2216 - if (lt_freq[[lt_foo]] == 1) { print lt_foo; } 2217 -}'` 2218 - # AWK program above erroneously prepends '/' to C:/dos/paths 2219 - # for these hosts. 2220 - case $host_os in 2221 - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ 2222 - $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; 2223 - esac 2224 - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` 2225 -else 2226 - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" 2227 -fi]) 2228 -library_names_spec= 2229 -libname_spec='lib$name' 2230 -soname_spec= 2231 -shrext_cmds=".so" 2232 -postinstall_cmds= 2233 -postuninstall_cmds= 2234 -finish_cmds= 2235 -finish_eval= 2236 -shlibpath_var= 2237 -shlibpath_overrides_runpath=unknown 2238 -version_type=none 2239 -dynamic_linker="$host_os ld.so" 2240 -sys_lib_dlsearch_path_spec="/lib /usr/lib" 2241 -need_lib_prefix=unknown 2242 -hardcode_into_libs=no 2243 - 2244 -# when you set need_version to no, make sure it does not cause -set_version 2245 -# flags to be left without arguments 2246 -need_version=unknown 2247 - 2248 -case $host_os in 2249 -aix3*) 2250 - version_type=linux # correct to gnu/linux during the next big refactor 2251 - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' 2252 - shlibpath_var=LIBPATH 2253 - 2254 - # AIX 3 has no versioning support, so we append a major version to the name. 2255 - soname_spec='${libname}${release}${shared_ext}$major' 2256 - ;; 2257 - 2258 -aix[[4-9]]*) 2259 - version_type=linux # correct to gnu/linux during the next big refactor 2260 - need_lib_prefix=no 2261 - need_version=no 2262 - hardcode_into_libs=yes 2263 - if test "$host_cpu" = ia64; then 2264 - # AIX 5 supports IA64 2265 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' 2266 - shlibpath_var=LD_LIBRARY_PATH 2267 - else 2268 - # With GCC up to 2.95.x, collect2 would create an import file 2269 - # for dependence libraries. The import file would start with 2270 - # the line `#! .'. This would cause the generated library to 2271 - # depend on `.', always an invalid library. This was fixed in 2272 - # development snapshots of GCC prior to 3.0. 2273 - case $host_os in 2274 - aix4 | aix4.[[01]] | aix4.[[01]].*) 2275 - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' 2276 - echo ' yes ' 2277 - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then 2278 - : 2279 - else 2280 - can_build_shared=no 2281 - fi 2282 - ;; 2283 - esac 2284 - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct 2285 - # soname into executable. Probably we can add versioning support to 2286 - # collect2, so additional links can be useful in future. 2287 - if test "$aix_use_runtimelinking" = yes; then 2288 - # If using run time linking (on AIX 4.2 or later) use lib<name>.so 2289 - # instead of lib<name>.a to let people know that these are not 2290 - # typical AIX shared libraries. 2291 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2292 - else 2293 - # We preserve .a as extension for shared libraries through AIX4.2 2294 - # and later when we are not doing run time linking. 2295 - library_names_spec='${libname}${release}.a $libname.a' 2296 - soname_spec='${libname}${release}${shared_ext}$major' 2297 - fi 2298 - shlibpath_var=LIBPATH 2299 - fi 2300 - ;; 2301 - 2302 -amigaos*) 2303 - case $host_cpu in 2304 - powerpc) 2305 - # Since July 2007 AmigaOS4 officially supports .so libraries. 2306 - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. 2307 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2308 - ;; 2309 - m68k) 2310 - library_names_spec='$libname.ixlibrary $libname.a' 2311 - # Create ${libname}_ixlibrary.a entries in /sys/libs. 2312 - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' 2313 - ;; 2314 - esac 2315 - ;; 2316 - 2317 -beos*) 2318 - library_names_spec='${libname}${shared_ext}' 2319 - dynamic_linker="$host_os ld.so" 2320 - shlibpath_var=LIBRARY_PATH 2321 - ;; 2322 - 2323 -bsdi[[45]]*) 2324 - version_type=linux # correct to gnu/linux during the next big refactor 2325 - need_version=no 2326 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2327 - soname_spec='${libname}${release}${shared_ext}$major' 2328 - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' 2329 - shlibpath_var=LD_LIBRARY_PATH 2330 - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" 2331 - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" 2332 - # the default ld.so.conf also contains /usr/contrib/lib and 2333 - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow 2334 - # libtool to hard-code these into programs 2335 - ;; 2336 - 2337 -cygwin* | mingw* | pw32* | cegcc*) 2338 - version_type=windows 2339 - shrext_cmds=".dll" 2340 - need_version=no 2341 - need_lib_prefix=no 2342 - 2343 - case $GCC,$cc_basename in 2344 - yes,*) 2345 - # gcc 2346 - library_names_spec='$libname.dll.a' 2347 - # DLL is installed to $(libdir)/../bin by postinstall_cmds 2348 - postinstall_cmds='base_file=`basename \${file}`~ 2349 - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ 2350 - dldir=$destdir/`dirname \$dlpath`~ 2351 - test -d \$dldir || mkdir -p \$dldir~ 2352 - $install_prog $dir/$dlname \$dldir/$dlname~ 2353 - chmod a+x \$dldir/$dlname~ 2354 - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then 2355 - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; 2356 - fi' 2357 - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ 2358 - dlpath=$dir/\$dldll~ 2359 - $RM \$dlpath' 2360 - shlibpath_overrides_runpath=yes 2361 - 2362 - case $host_os in 2363 - cygwin*) 2364 - # Cygwin DLLs use 'cyg' prefix rather than 'lib' 2365 - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' 2366 -m4_if([$1], [],[ 2367 - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) 2368 - ;; 2369 - mingw* | cegcc*) 2370 - # MinGW DLLs use traditional 'lib' prefix 2371 - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' 2372 - ;; 2373 - pw32*) 2374 - # pw32 DLLs use 'pw' prefix rather than 'lib' 2375 - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' 2376 - ;; 2377 - esac 2378 - dynamic_linker='Win32 ld.exe' 2379 - ;; 2380 - 2381 - *,cl*) 2382 - # Native MSVC 2383 - libname_spec='$name' 2384 - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' 2385 - library_names_spec='${libname}.dll.lib' 2386 - 2387 - case $build_os in 2388 - mingw*) 2389 - sys_lib_search_path_spec= 2390 - lt_save_ifs=$IFS 2391 - IFS=';' 2392 - for lt_path in $LIB 2393 - do 2394 - IFS=$lt_save_ifs 2395 - # Let DOS variable expansion print the short 8.3 style file name. 2396 - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` 2397 - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" 2398 - done 2399 - IFS=$lt_save_ifs 2400 - # Convert to MSYS style. 2401 - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` 2402 - ;; 2403 - cygwin*) 2404 - # Convert to unix form, then to dos form, then back to unix form 2405 - # but this time dos style (no spaces!) so that the unix form looks 2406 - # like /cygdrive/c/PROGRA~1:/cygdr... 2407 - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` 2408 - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` 2409 - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` 2410 - ;; 2411 - *) 2412 - sys_lib_search_path_spec="$LIB" 2413 - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then 2414 - # It is most probably a Windows format PATH. 2415 - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` 2416 - else 2417 - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` 2418 - fi 2419 - # FIXME: find the short name or the path components, as spaces are 2420 - # common. (e.g. "Program Files" -> "PROGRA~1") 2421 - ;; 2422 - esac 2423 - 2424 - # DLL is installed to $(libdir)/../bin by postinstall_cmds 2425 - postinstall_cmds='base_file=`basename \${file}`~ 2426 - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ 2427 - dldir=$destdir/`dirname \$dlpath`~ 2428 - test -d \$dldir || mkdir -p \$dldir~ 2429 - $install_prog $dir/$dlname \$dldir/$dlname' 2430 - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ 2431 - dlpath=$dir/\$dldll~ 2432 - $RM \$dlpath' 2433 - shlibpath_overrides_runpath=yes 2434 - dynamic_linker='Win32 link.exe' 2435 - ;; 2436 - 2437 - *) 2438 - # Assume MSVC wrapper 2439 - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' 2440 - dynamic_linker='Win32 ld.exe' 2441 - ;; 2442 - esac 2443 - # FIXME: first we should search . and the directory the executable is in 2444 - shlibpath_var=PATH 2445 - ;; 2446 - 2447 -darwin* | rhapsody*) 2448 - dynamic_linker="$host_os dyld" 2449 - version_type=darwin 2450 - need_lib_prefix=no 2451 - need_version=no 2452 - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' 2453 - soname_spec='${libname}${release}${major}$shared_ext' 2454 - shlibpath_overrides_runpath=yes 2455 - shlibpath_var=DYLD_LIBRARY_PATH 2456 - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' 2457 -m4_if([$1], [],[ 2458 - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) 2459 - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' 2460 - ;; 2461 - 2462 -dgux*) 2463 - version_type=linux # correct to gnu/linux during the next big refactor 2464 - need_lib_prefix=no 2465 - need_version=no 2466 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' 2467 - soname_spec='${libname}${release}${shared_ext}$major' 2468 - shlibpath_var=LD_LIBRARY_PATH 2469 - ;; 2470 - 2471 -freebsd* | dragonfly*) 2472 - # DragonFly does not have aout. When/if they implement a new 2473 - # versioning mechanism, adjust this. 2474 - if test -x /usr/bin/objformat; then 2475 - objformat=`/usr/bin/objformat` 2476 - else 2477 - case $host_os in 2478 - freebsd[[23]].*) objformat=aout ;; 2479 - *) objformat=elf ;; 2480 - esac 2481 - fi 2482 - version_type=freebsd-$objformat 2483 - case $version_type in 2484 - freebsd-elf*) 2485 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' 2486 - need_version=no 2487 - need_lib_prefix=no 2488 - ;; 2489 - freebsd-*) 2490 - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' 2491 - need_version=yes 2492 - ;; 2493 - esac 2494 - shlibpath_var=LD_LIBRARY_PATH 2495 - case $host_os in 2496 - freebsd2.*) 2497 - shlibpath_overrides_runpath=yes 2498 - ;; 2499 - freebsd3.[[01]]* | freebsdelf3.[[01]]*) 2500 - shlibpath_overrides_runpath=yes 2501 - hardcode_into_libs=yes 2502 - ;; 2503 - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ 2504 - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) 2505 - shlibpath_overrides_runpath=no 2506 - hardcode_into_libs=yes 2507 - ;; 2508 - *) # from 4.6 on, and DragonFly 2509 - shlibpath_overrides_runpath=yes 2510 - hardcode_into_libs=yes 2511 - ;; 2512 - esac 2513 - ;; 2514 - 2515 -gnu*) 2516 - version_type=linux # correct to gnu/linux during the next big refactor 2517 - need_lib_prefix=no 2518 - need_version=no 2519 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' 2520 - soname_spec='${libname}${release}${shared_ext}$major' 2521 - shlibpath_var=LD_LIBRARY_PATH 2522 - shlibpath_overrides_runpath=no 2523 - hardcode_into_libs=yes 2524 - ;; 2525 - 2526 -haiku*) 2527 - version_type=linux # correct to gnu/linux during the next big refactor 2528 - need_lib_prefix=no 2529 - need_version=no 2530 - dynamic_linker="$host_os runtime_loader" 2531 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' 2532 - soname_spec='${libname}${release}${shared_ext}$major' 2533 - shlibpath_var=LIBRARY_PATH 2534 - shlibpath_overrides_runpath=yes 2535 - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' 2536 - hardcode_into_libs=yes 2537 - ;; 2538 - 2539 -hpux9* | hpux10* | hpux11*) 2540 - # Give a soname corresponding to the major version so that dld.sl refuses to 2541 - # link against other versions. 2542 - version_type=sunos 2543 - need_lib_prefix=no 2544 - need_version=no 2545 - case $host_cpu in 2546 - ia64*) 2547 - shrext_cmds='.so' 2548 - hardcode_into_libs=yes 2549 - dynamic_linker="$host_os dld.so" 2550 - shlibpath_var=LD_LIBRARY_PATH 2551 - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. 2552 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2553 - soname_spec='${libname}${release}${shared_ext}$major' 2554 - if test "X$HPUX_IA64_MODE" = X32; then 2555 - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" 2556 - else 2557 - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" 2558 - fi 2559 - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec 2560 - ;; 2561 - hppa*64*) 2562 - shrext_cmds='.sl' 2563 - hardcode_into_libs=yes 2564 - dynamic_linker="$host_os dld.sl" 2565 - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH 2566 - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. 2567 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2568 - soname_spec='${libname}${release}${shared_ext}$major' 2569 - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" 2570 - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec 2571 - ;; 2572 - *) 2573 - shrext_cmds='.sl' 2574 - dynamic_linker="$host_os dld.sl" 2575 - shlibpath_var=SHLIB_PATH 2576 - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH 2577 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2578 - soname_spec='${libname}${release}${shared_ext}$major' 2579 - ;; 2580 - esac 2581 - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... 2582 - postinstall_cmds='chmod 555 $lib' 2583 - # or fails outright, so override atomically: 2584 - install_override_mode=555 2585 - ;; 2586 - 2587 -interix[[3-9]]*) 2588 - version_type=linux # correct to gnu/linux during the next big refactor 2589 - need_lib_prefix=no 2590 - need_version=no 2591 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' 2592 - soname_spec='${libname}${release}${shared_ext}$major' 2593 - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' 2594 - shlibpath_var=LD_LIBRARY_PATH 2595 - shlibpath_overrides_runpath=no 2596 - hardcode_into_libs=yes 2597 - ;; 2598 - 2599 -irix5* | irix6* | nonstopux*) 2600 - case $host_os in 2601 - nonstopux*) version_type=nonstopux ;; 2602 - *) 2603 - if test "$lt_cv_prog_gnu_ld" = yes; then 2604 - version_type=linux # correct to gnu/linux during the next big refactor 2605 - else 2606 - version_type=irix 2607 - fi ;; 2608 - esac 2609 - need_lib_prefix=no 2610 - need_version=no 2611 - soname_spec='${libname}${release}${shared_ext}$major' 2612 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' 2613 - case $host_os in 2614 - irix5* | nonstopux*) 2615 - libsuff= shlibsuff= 2616 - ;; 2617 - *) 2618 - case $LD in # libtool.m4 will add one of these switches to LD 2619 - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") 2620 - libsuff= shlibsuff= libmagic=32-bit;; 2621 - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") 2622 - libsuff=32 shlibsuff=N32 libmagic=N32;; 2623 - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") 2624 - libsuff=64 shlibsuff=64 libmagic=64-bit;; 2625 - *) libsuff= shlibsuff= libmagic=never-match;; 2626 - esac 2627 - ;; 2628 - esac 2629 - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH 2630 - shlibpath_overrides_runpath=no 2631 - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" 2632 - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" 2633 - hardcode_into_libs=yes 2634 - ;; 2635 - 2636 -# No shared lib support for Linux oldld, aout, or coff. 2637 -linux*oldld* | linux*aout* | linux*coff*) 2638 - dynamic_linker=no 2639 - ;; 2640 - 2641 -# This must be glibc/ELF. 2642 -linux* | k*bsd*-gnu | kopensolaris*-gnu) 2643 - version_type=linux # correct to gnu/linux during the next big refactor 2644 - need_lib_prefix=no 2645 - need_version=no 2646 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2647 - soname_spec='${libname}${release}${shared_ext}$major' 2648 - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' 2649 - shlibpath_var=LD_LIBRARY_PATH 2650 - shlibpath_overrides_runpath=no 2651 - 2652 - # Some binutils ld are patched to set DT_RUNPATH 2653 - AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], 2654 - [lt_cv_shlibpath_overrides_runpath=no 2655 - save_LDFLAGS=$LDFLAGS 2656 - save_libdir=$libdir 2657 - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ 2658 - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" 2659 - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], 2660 - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], 2661 - [lt_cv_shlibpath_overrides_runpath=yes])]) 2662 - LDFLAGS=$save_LDFLAGS 2663 - libdir=$save_libdir 2664 - ]) 2665 - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath 2666 - 2667 - # This implies no fast_install, which is unacceptable. 2668 - # Some rework will be needed to allow for fast_install 2669 - # before this can be enabled. 2670 - hardcode_into_libs=yes 2671 - 2672 - # Add ABI-specific directories to the system library path. 2673 - sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib" 2674 - 2675 - # Append ld.so.conf contents to the search path 2676 - if test -f /etc/ld.so.conf; then 2677 - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` 2678 - sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra" 2679 - 2680 - fi 2681 - 2682 - # We used to test for /lib/ld.so.1 and disable shared libraries on 2683 - # powerpc, because MkLinux only supported shared libraries with the 2684 - # GNU dynamic linker. Since this was broken with cross compilers, 2685 - # most powerpc-linux boxes support dynamic linking these days and 2686 - # people can always --disable-shared, the test was removed, and we 2687 - # assume the GNU/Linux dynamic linker is in use. 2688 - dynamic_linker='GNU/Linux ld.so' 2689 - ;; 2690 - 2691 -netbsd*) 2692 - version_type=sunos 2693 - need_lib_prefix=no 2694 - need_version=no 2695 - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then 2696 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' 2697 - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' 2698 - dynamic_linker='NetBSD (a.out) ld.so' 2699 - else 2700 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' 2701 - soname_spec='${libname}${release}${shared_ext}$major' 2702 - dynamic_linker='NetBSD ld.elf_so' 2703 - fi 2704 - shlibpath_var=LD_LIBRARY_PATH 2705 - shlibpath_overrides_runpath=yes 2706 - hardcode_into_libs=yes 2707 - ;; 2708 - 2709 -newsos6) 2710 - version_type=linux # correct to gnu/linux during the next big refactor 2711 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2712 - shlibpath_var=LD_LIBRARY_PATH 2713 - shlibpath_overrides_runpath=yes 2714 - ;; 2715 - 2716 -*nto* | *qnx*) 2717 - version_type=qnx 2718 - need_lib_prefix=no 2719 - need_version=no 2720 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2721 - soname_spec='${libname}${release}${shared_ext}$major' 2722 - shlibpath_var=LD_LIBRARY_PATH 2723 - shlibpath_overrides_runpath=no 2724 - hardcode_into_libs=yes 2725 - dynamic_linker='ldqnx.so' 2726 - ;; 2727 - 2728 -openbsd*) 2729 - version_type=sunos 2730 - sys_lib_dlsearch_path_spec="/usr/lib" 2731 - need_lib_prefix=no 2732 - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. 2733 - case $host_os in 2734 - openbsd3.3 | openbsd3.3.*) need_version=yes ;; 2735 - *) need_version=no ;; 2736 - esac 2737 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' 2738 - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' 2739 - shlibpath_var=LD_LIBRARY_PATH 2740 - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then 2741 - case $host_os in 2742 - openbsd2.[[89]] | openbsd2.[[89]].*) 2743 - shlibpath_overrides_runpath=no 2744 - ;; 2745 - *) 2746 - shlibpath_overrides_runpath=yes 2747 - ;; 2748 - esac 2749 - else 2750 - shlibpath_overrides_runpath=yes 2751 - fi 2752 - ;; 2753 - 2754 -os2*) 2755 - libname_spec='$name' 2756 - shrext_cmds=".dll" 2757 - need_lib_prefix=no 2758 - library_names_spec='$libname${shared_ext} $libname.a' 2759 - dynamic_linker='OS/2 ld.exe' 2760 - shlibpath_var=LIBPATH 2761 - ;; 2762 - 2763 -osf3* | osf4* | osf5*) 2764 - version_type=osf 2765 - need_lib_prefix=no 2766 - need_version=no 2767 - soname_spec='${libname}${release}${shared_ext}$major' 2768 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2769 - shlibpath_var=LD_LIBRARY_PATH 2770 - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" 2771 - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" 2772 - ;; 2773 - 2774 -rdos*) 2775 - dynamic_linker=no 2776 - ;; 2777 - 2778 -solaris*) 2779 - version_type=linux # correct to gnu/linux during the next big refactor 2780 - need_lib_prefix=no 2781 - need_version=no 2782 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2783 - soname_spec='${libname}${release}${shared_ext}$major' 2784 - shlibpath_var=LD_LIBRARY_PATH 2785 - shlibpath_overrides_runpath=yes 2786 - hardcode_into_libs=yes 2787 - # ldd complains unless libraries are executable 2788 - postinstall_cmds='chmod +x $lib' 2789 - ;; 2790 - 2791 -sunos4*) 2792 - version_type=sunos 2793 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' 2794 - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' 2795 - shlibpath_var=LD_LIBRARY_PATH 2796 - shlibpath_overrides_runpath=yes 2797 - if test "$with_gnu_ld" = yes; then 2798 - need_lib_prefix=no 2799 - fi 2800 - need_version=yes 2801 - ;; 2802 - 2803 -sysv4 | sysv4.3*) 2804 - version_type=linux # correct to gnu/linux during the next big refactor 2805 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2806 - soname_spec='${libname}${release}${shared_ext}$major' 2807 - shlibpath_var=LD_LIBRARY_PATH 2808 - case $host_vendor in 2809 - sni) 2810 - shlibpath_overrides_runpath=no 2811 - need_lib_prefix=no 2812 - runpath_var=LD_RUN_PATH 2813 - ;; 2814 - siemens) 2815 - need_lib_prefix=no 2816 - ;; 2817 - motorola) 2818 - need_lib_prefix=no 2819 - need_version=no 2820 - shlibpath_overrides_runpath=no 2821 - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' 2822 - ;; 2823 - esac 2824 - ;; 2825 - 2826 -sysv4*MP*) 2827 - if test -d /usr/nec ;then 2828 - version_type=linux # correct to gnu/linux during the next big refactor 2829 - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' 2830 - soname_spec='$libname${shared_ext}.$major' 2831 - shlibpath_var=LD_LIBRARY_PATH 2832 - fi 2833 - ;; 2834 - 2835 -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) 2836 - version_type=freebsd-elf 2837 - need_lib_prefix=no 2838 - need_version=no 2839 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' 2840 - soname_spec='${libname}${release}${shared_ext}$major' 2841 - shlibpath_var=LD_LIBRARY_PATH 2842 - shlibpath_overrides_runpath=yes 2843 - hardcode_into_libs=yes 2844 - if test "$with_gnu_ld" = yes; then 2845 - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' 2846 - else 2847 - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' 2848 - case $host_os in 2849 - sco3.2v5*) 2850 - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" 2851 - ;; 2852 - esac 2853 - fi 2854 - sys_lib_dlsearch_path_spec='/usr/lib' 2855 - ;; 2856 - 2857 -tpf*) 2858 - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. 2859 - version_type=linux # correct to gnu/linux during the next big refactor 2860 - need_lib_prefix=no 2861 - need_version=no 2862 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2863 - shlibpath_var=LD_LIBRARY_PATH 2864 - shlibpath_overrides_runpath=no 2865 - hardcode_into_libs=yes 2866 - ;; 2867 - 2868 -uts4*) 2869 - version_type=linux # correct to gnu/linux during the next big refactor 2870 - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2871 - soname_spec='${libname}${release}${shared_ext}$major' 2872 - shlibpath_var=LD_LIBRARY_PATH 2873 - ;; 2874 - 2875 -*) 2876 - dynamic_linker=no 2877 - ;; 2878 -esac 2879 -AC_MSG_RESULT([$dynamic_linker]) 2880 -test "$dynamic_linker" = no && can_build_shared=no 2881 - 2882 -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" 2883 -if test "$GCC" = yes; then 2884 - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" 2885 -fi 2886 - 2887 -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then 2888 - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" 2889 -fi 2890 -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then 2891 - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" 2892 -fi 2893 - 2894 -_LT_DECL([], [variables_saved_for_relink], [1], 2895 - [Variables whose values should be saved in libtool wrapper scripts and 2896 - restored at link time]) 2897 -_LT_DECL([], [need_lib_prefix], [0], 2898 - [Do we need the "lib" prefix for modules?]) 2899 -_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) 2900 -_LT_DECL([], [version_type], [0], [Library versioning type]) 2901 -_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) 2902 -_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) 2903 -_LT_DECL([], [shlibpath_overrides_runpath], [0], 2904 - [Is shlibpath searched before the hard-coded library search path?]) 2905 -_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) 2906 -_LT_DECL([], [library_names_spec], [1], 2907 - [[List of archive names. First name is the real one, the rest are links. 2908 - The last name is the one that the linker finds with -lNAME]]) 2909 -_LT_DECL([], [soname_spec], [1], 2910 - [[The coded name of the library, if different from the real name]]) 2911 -_LT_DECL([], [install_override_mode], [1], 2912 - [Permission mode override for installation of shared libraries]) 2913 -_LT_DECL([], [postinstall_cmds], [2], 2914 - [Command to use after installation of a shared archive]) 2915 -_LT_DECL([], [postuninstall_cmds], [2], 2916 - [Command to use after uninstallation of a shared archive]) 2917 -_LT_DECL([], [finish_cmds], [2], 2918 - [Commands used to finish a libtool library installation in a directory]) 2919 -_LT_DECL([], [finish_eval], [1], 2920 - [[As "finish_cmds", except a single script fragment to be evaled but 2921 - not shown]]) 2922 -_LT_DECL([], [hardcode_into_libs], [0], 2923 - [Whether we should hardcode library paths into libraries]) 2924 -_LT_DECL([], [sys_lib_search_path_spec], [2], 2925 - [Compile-time system search path for libraries]) 2926 -_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], 2927 - [Run-time system search path for libraries]) 2928 -])# _LT_SYS_DYNAMIC_LINKER 2929 - 2930 - 2931 -# _LT_PATH_TOOL_PREFIX(TOOL) 2932 -# -------------------------- 2933 -# find a file program which can recognize shared library 2934 -AC_DEFUN([_LT_PATH_TOOL_PREFIX], 2935 -[m4_require([_LT_DECL_EGREP])dnl 2936 -AC_MSG_CHECKING([for $1]) 2937 -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, 2938 -[case $MAGIC_CMD in 2939 -[[\\/*] | ?:[\\/]*]) 2940 - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. 2941 - ;; 2942 -*) 2943 - lt_save_MAGIC_CMD="$MAGIC_CMD" 2944 - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR 2945 -dnl $ac_dummy forces splitting on constant user-supplied paths. 2946 -dnl POSIX.2 word splitting is done only on the output of word expansions, 2947 -dnl not every word. This closes a longstanding sh security hole. 2948 - ac_dummy="m4_if([$2], , $PATH, [$2])" 2949 - for ac_dir in $ac_dummy; do 2950 - IFS="$lt_save_ifs" 2951 - test -z "$ac_dir" && ac_dir=. 2952 - if test -f $ac_dir/$1; then 2953 - lt_cv_path_MAGIC_CMD="$ac_dir/$1" 2954 - if test -n "$file_magic_test_file"; then 2955 - case $deplibs_check_method in 2956 - "file_magic "*) 2957 - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` 2958 - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" 2959 - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | 2960 - $EGREP "$file_magic_regex" > /dev/null; then 2961 - : 2962 - else 2963 - cat <<_LT_EOF 1>&2 2964 - 2965 -*** Warning: the command libtool uses to detect shared libraries, 2966 -*** $file_magic_cmd, produces output that libtool cannot recognize. 2967 -*** The result is that libtool may fail to recognize shared libraries 2968 -*** as such. This will affect the creation of libtool libraries that 2969 -*** depend on shared libraries, but programs linked with such libtool 2970 -*** libraries will work regardless of this problem. Nevertheless, you 2971 -*** may want to report the problem to your system manager and/or to 2972 -*** bug-libtool@gnu.org 2973 - 2974 -_LT_EOF 2975 - fi ;; 2976 - esac 2977 - fi 2978 - break 2979 - fi 2980 - done 2981 - IFS="$lt_save_ifs" 2982 - MAGIC_CMD="$lt_save_MAGIC_CMD" 2983 - ;; 2984 -esac]) 2985 -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" 2986 -if test -n "$MAGIC_CMD"; then 2987 - AC_MSG_RESULT($MAGIC_CMD) 2988 -else 2989 - AC_MSG_RESULT(no) 2990 -fi 2991 -_LT_DECL([], [MAGIC_CMD], [0], 2992 - [Used to examine libraries when file_magic_cmd begins with "file"])dnl 2993 -])# _LT_PATH_TOOL_PREFIX 2994 - 2995 -# Old name: 2996 -AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) 2997 -dnl aclocal-1.4 backwards compatibility: 2998 -dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) 2999 - 3000 - 3001 -# _LT_PATH_MAGIC 3002 -# -------------- 3003 -# find a file program which can recognize a shared library 3004 -m4_defun([_LT_PATH_MAGIC], 3005 -[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) 3006 -if test -z "$lt_cv_path_MAGIC_CMD"; then 3007 - if test -n "$ac_tool_prefix"; then 3008 - _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) 3009 - else 3010 - MAGIC_CMD=: 3011 - fi 3012 -fi 3013 -])# _LT_PATH_MAGIC 3014 - 3015 - 3016 -# LT_PATH_LD 3017 -# ---------- 3018 -# find the pathname to the GNU or non-GNU linker 3019 -AC_DEFUN([LT_PATH_LD], 3020 -[AC_REQUIRE([AC_PROG_CC])dnl 3021 -AC_REQUIRE([AC_CANONICAL_HOST])dnl 3022 -AC_REQUIRE([AC_CANONICAL_BUILD])dnl 3023 -m4_require([_LT_DECL_SED])dnl 3024 -m4_require([_LT_DECL_EGREP])dnl 3025 -m4_require([_LT_PROG_ECHO_BACKSLASH])dnl 3026 - 3027 -AC_ARG_WITH([gnu-ld], 3028 - [AS_HELP_STRING([--with-gnu-ld], 3029 - [assume the C compiler uses GNU ld @<:@default=no@:>@])], 3030 - [test "$withval" = no || with_gnu_ld=yes], 3031 - [with_gnu_ld=no])dnl 3032 - 3033 -ac_prog=ld 3034 -if test "$GCC" = yes; then 3035 - # Check if gcc -print-prog-name=ld gives a path. 3036 - AC_MSG_CHECKING([for ld used by $CC]) 3037 - case $host in 3038 - *-*-mingw*) 3039 - # gcc leaves a trailing carriage return which upsets mingw 3040 - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; 3041 - *) 3042 - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; 3043 - esac 3044 - case $ac_prog in 3045 - # Accept absolute paths. 3046 - [[\\/]]* | ?:[[\\/]]*) 3047 - re_direlt='/[[^/]][[^/]]*/\.\./' 3048 - # Canonicalize the pathname of ld 3049 - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` 3050 - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do 3051 - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` 3052 - done 3053 - test -z "$LD" && LD="$ac_prog" 3054 - ;; 3055 - "") 3056 - # If it fails, then pretend we aren't using GCC. 3057 - ac_prog=ld 3058 - ;; 3059 - *) 3060 - # If it is relative, then search for the first ld in PATH. 3061 - with_gnu_ld=unknown 3062 - ;; 3063 - esac 3064 -elif test "$with_gnu_ld" = yes; then 3065 - AC_MSG_CHECKING([for GNU ld]) 3066 -else 3067 - AC_MSG_CHECKING([for non-GNU ld]) 3068 -fi 3069 -AC_CACHE_VAL(lt_cv_path_LD, 3070 -[if test -z "$LD"; then 3071 - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR 3072 - for ac_dir in $PATH; do 3073 - IFS="$lt_save_ifs" 3074 - test -z "$ac_dir" && ac_dir=. 3075 - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then 3076 - lt_cv_path_LD="$ac_dir/$ac_prog" 3077 - # Check to see if the program is GNU ld. I'd rather use --version, 3078 - # but apparently some variants of GNU ld only accept -v. 3079 - # Break only if it was the GNU/non-GNU ld that we prefer. 3080 - case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in 3081 - *GNU* | *'with BFD'*) 3082 - test "$with_gnu_ld" != no && break 3083 - ;; 3084 - *) 3085 - test "$with_gnu_ld" != yes && break 3086 - ;; 3087 - esac 3088 - fi 3089 - done 3090 - IFS="$lt_save_ifs" 3091 -else 3092 - lt_cv_path_LD="$LD" # Let the user override the test with a path. 3093 -fi]) 3094 -LD="$lt_cv_path_LD" 3095 -if test -n "$LD"; then 3096 - AC_MSG_RESULT($LD) 3097 -else 3098 - AC_MSG_RESULT(no) 3099 -fi 3100 -test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) 3101 -_LT_PATH_LD_GNU 3102 -AC_SUBST([LD]) 3103 - 3104 -_LT_TAGDECL([], [LD], [1], [The linker used to build libraries]) 3105 -])# LT_PATH_LD 3106 - 3107 -# Old names: 3108 -AU_ALIAS([AM_PROG_LD], [LT_PATH_LD]) 3109 -AU_ALIAS([AC_PROG_LD], [LT_PATH_LD]) 3110 -dnl aclocal-1.4 backwards compatibility: 3111 -dnl AC_DEFUN([AM_PROG_LD], []) 3112 -dnl AC_DEFUN([AC_PROG_LD], []) 3113 - 3114 - 3115 -# _LT_PATH_LD_GNU 3116 -#- -------------- 3117 -m4_defun([_LT_PATH_LD_GNU], 3118 -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld, 3119 -[# I'd rather use --version here, but apparently some GNU lds only accept -v. 3120 -case `$LD -v 2>&1 </dev/null` in 3121 -*GNU* | *'with BFD'*) 3122 - lt_cv_prog_gnu_ld=yes 3123 - ;; 3124 -*) 3125 - lt_cv_prog_gnu_ld=no 3126 - ;; 3127 -esac]) 3128 -with_gnu_ld=$lt_cv_prog_gnu_ld 3129 -])# _LT_PATH_LD_GNU 3130 - 3131 - 3132 -# _LT_CMD_RELOAD 3133 -# -------------- 3134 -# find reload flag for linker 3135 -# -- PORTME Some linkers may need a different reload flag. 3136 -m4_defun([_LT_CMD_RELOAD], 3137 -[AC_CACHE_CHECK([for $LD option to reload object files], 3138 - lt_cv_ld_reload_flag, 3139 - [lt_cv_ld_reload_flag='-r']) 3140 -reload_flag=$lt_cv_ld_reload_flag 3141 -case $reload_flag in 3142 -"" | " "*) ;; 3143 -*) reload_flag=" $reload_flag" ;; 3144 -esac 3145 -reload_cmds='$LD$reload_flag -o $output$reload_objs' 3146 -case $host_os in 3147 - cygwin* | mingw* | pw32* | cegcc*) 3148 - if test "$GCC" != yes; then 3149 - reload_cmds=false 3150 - fi 3151 - ;; 3152 - darwin*) 3153 - if test "$GCC" = yes; then 3154 - reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' 3155 - else 3156 - reload_cmds='$LD$reload_flag -o $output$reload_objs' 3157 - fi 3158 - ;; 3159 -esac 3160 -_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl 3161 -_LT_TAGDECL([], [reload_cmds], [2])dnl 3162 -])# _LT_CMD_RELOAD 3163 - 3164 - 3165 -# _LT_CHECK_MAGIC_METHOD 3166 -# ---------------------- 3167 -# how to check for library dependencies 3168 -# -- PORTME fill in with the dynamic library characteristics 3169 -m4_defun([_LT_CHECK_MAGIC_METHOD], 3170 -[m4_require([_LT_DECL_EGREP]) 3171 -m4_require([_LT_DECL_OBJDUMP]) 3172 -AC_CACHE_CHECK([how to recognize dependent libraries], 3173 -lt_cv_deplibs_check_method, 3174 -[lt_cv_file_magic_cmd='$MAGIC_CMD' 3175 -lt_cv_file_magic_test_file= 3176 -lt_cv_deplibs_check_method='unknown' 3177 -# Need to set the preceding variable on all platforms that support 3178 -# interlibrary dependencies. 3179 -# 'none' -- dependencies not supported. 3180 -# `unknown' -- same as none, but documents that we really don't know. 3181 -# 'pass_all' -- all dependencies passed with no checks. 3182 -# 'test_compile' -- check by making test program. 3183 -# 'file_magic [[regex]]' -- check by looking for files in library path 3184 -# which responds to the $file_magic_cmd with a given extended regex. 3185 -# If you have `file' or equivalent on your system and you're not sure 3186 -# whether `pass_all' will *always* work, you probably want this one. 3187 - 3188 -case $host_os in 3189 -aix[[4-9]]*) 3190 - lt_cv_deplibs_check_method=pass_all 3191 - ;; 3192 - 3193 -beos*) 3194 - lt_cv_deplibs_check_method=pass_all 3195 - ;; 3196 - 3197 -bsdi[[45]]*) 3198 - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' 3199 - lt_cv_file_magic_cmd='/usr/bin/file -L' 3200 - lt_cv_file_magic_test_file=/shlib/libc.so 3201 - ;; 3202 - 3203 -cygwin*) 3204 - # func_win32_libid is a shell function defined in ltmain.sh 3205 - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' 3206 - lt_cv_file_magic_cmd='func_win32_libid' 3207 - ;; 3208 - 3209 -mingw* | pw32*) 3210 - # Base MSYS/MinGW do not provide the 'file' command needed by 3211 - # func_win32_libid shell function, so use a weaker test based on 'objdump', 3212 - # unless we find 'file', for example because we are cross-compiling. 3213 - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. 3214 - if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then 3215 - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' 3216 - lt_cv_file_magic_cmd='func_win32_libid' 3217 - else 3218 - # Keep this pattern in sync with the one in func_win32_libid. 3219 - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' 3220 - lt_cv_file_magic_cmd='$OBJDUMP -f' 3221 - fi 3222 - ;; 3223 - 3224 -cegcc*) 3225 - # use the weaker test based on 'objdump'. See mingw*. 3226 - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' 3227 - lt_cv_file_magic_cmd='$OBJDUMP -f' 3228 - ;; 3229 - 3230 -darwin* | rhapsody*) 3231 - lt_cv_deplibs_check_method=pass_all 3232 - ;; 3233 - 3234 -freebsd* | dragonfly*) 3235 - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then 3236 - case $host_cpu in 3237 - i*86 ) 3238 - # Not sure whether the presence of OpenBSD here was a mistake. 3239 - # Let's accept both of them until this is cleared up. 3240 - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' 3241 - lt_cv_file_magic_cmd=/usr/bin/file 3242 - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` 3243 - ;; 3244 - esac 3245 - else 3246 - lt_cv_deplibs_check_method=pass_all 3247 - fi 3248 - ;; 3249 - 3250 -gnu*) 3251 - lt_cv_deplibs_check_method=pass_all 3252 - ;; 3253 - 3254 -haiku*) 3255 - lt_cv_deplibs_check_method=pass_all 3256 - ;; 3257 - 3258 -hpux10.20* | hpux11*) 3259 - lt_cv_file_magic_cmd=/usr/bin/file 3260 - case $host_cpu in 3261 - ia64*) 3262 - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' 3263 - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so 3264 - ;; 3265 - hppa*64*) 3266 - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] 3267 - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl 3268 - ;; 3269 - *) 3270 - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' 3271 - lt_cv_file_magic_test_file=/usr/lib/libc.sl 3272 - ;; 3273 - esac 3274 - ;; 3275 - 3276 -interix[[3-9]]*) 3277 - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here 3278 - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' 3279 - ;; 3280 - 3281 -irix5* | irix6* | nonstopux*) 3282 - case $LD in 3283 - *-32|*"-32 ") libmagic=32-bit;; 3284 - *-n32|*"-n32 ") libmagic=N32;; 3285 - *-64|*"-64 ") libmagic=64-bit;; 3286 - *) libmagic=never-match;; 3287 - esac 3288 - lt_cv_deplibs_check_method=pass_all 3289 - ;; 3290 - 3291 -# This must be glibc/ELF. 3292 -linux* | k*bsd*-gnu | kopensolaris*-gnu) 3293 - lt_cv_deplibs_check_method=pass_all 3294 - ;; 3295 - 3296 -netbsd*) 3297 - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then 3298 - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' 3299 - else 3300 - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' 3301 - fi 3302 - ;; 3303 - 3304 -newos6*) 3305 - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' 3306 - lt_cv_file_magic_cmd=/usr/bin/file 3307 - lt_cv_file_magic_test_file=/usr/lib/libnls.so 3308 - ;; 3309 - 3310 -*nto* | *qnx*) 3311 - lt_cv_deplibs_check_method=pass_all 3312 - ;; 3313 - 3314 -openbsd*) 3315 - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then 3316 - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' 3317 - else 3318 - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' 3319 - fi 3320 - ;; 3321 - 3322 -osf3* | osf4* | osf5*) 3323 - lt_cv_deplibs_check_method=pass_all 3324 - ;; 3325 - 3326 -rdos*) 3327 - lt_cv_deplibs_check_method=pass_all 3328 - ;; 3329 - 3330 -solaris*) 3331 - lt_cv_deplibs_check_method=pass_all 3332 - ;; 3333 - 3334 -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) 3335 - lt_cv_deplibs_check_method=pass_all 3336 - ;; 3337 - 3338 -sysv4 | sysv4.3*) 3339 - case $host_vendor in 3340 - motorola) 3341 - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' 3342 - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` 3343 - ;; 3344 - ncr) 3345 - lt_cv_deplibs_check_method=pass_all 3346 - ;; 3347 - sequent) 3348 - lt_cv_file_magic_cmd='/bin/file' 3349 - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' 3350 - ;; 3351 - sni) 3352 - lt_cv_file_magic_cmd='/bin/file' 3353 - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" 3354 - lt_cv_file_magic_test_file=/lib/libc.so 3355 - ;; 3356 - siemens) 3357 - lt_cv_deplibs_check_method=pass_all 3358 - ;; 3359 - pc) 3360 - lt_cv_deplibs_check_method=pass_all 3361 - ;; 3362 - esac 3363 - ;; 3364 - 3365 -tpf*) 3366 - lt_cv_deplibs_check_method=pass_all 3367 - ;; 3368 -esac 3369 -]) 3370 - 3371 -file_magic_glob= 3372 -want_nocaseglob=no 3373 -if test "$build" = "$host"; then 3374 - case $host_os in 3375 - mingw* | pw32*) 3376 - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then 3377 - want_nocaseglob=yes 3378 - else 3379 - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` 3380 - fi 3381 - ;; 3382 - esac 3383 -fi 3384 - 3385 -file_magic_cmd=$lt_cv_file_magic_cmd 3386 -deplibs_check_method=$lt_cv_deplibs_check_method 3387 -test -z "$deplibs_check_method" && deplibs_check_method=unknown 3388 - 3389 -_LT_DECL([], [deplibs_check_method], [1], 3390 - [Method to check whether dependent libraries are shared objects]) 3391 -_LT_DECL([], [file_magic_cmd], [1], 3392 - [Command to use when deplibs_check_method = "file_magic"]) 3393 -_LT_DECL([], [file_magic_glob], [1], 3394 - [How to find potential files when deplibs_check_method = "file_magic"]) 3395 -_LT_DECL([], [want_nocaseglob], [1], 3396 - [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) 3397 -])# _LT_CHECK_MAGIC_METHOD 3398 - 3399 - 3400 -# LT_PATH_NM 3401 -# ---------- 3402 -# find the pathname to a BSD- or MS-compatible name lister 3403 -AC_DEFUN([LT_PATH_NM], 3404 -[AC_REQUIRE([AC_PROG_CC])dnl 3405 -AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, 3406 -[if test -n "$NM"; then 3407 - # Let the user override the test. 3408 - lt_cv_path_NM="$NM" 3409 -else 3410 - lt_nm_to_check="${ac_tool_prefix}nm" 3411 - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then 3412 - lt_nm_to_check="$lt_nm_to_check nm" 3413 - fi 3414 - for lt_tmp_nm in $lt_nm_to_check; do 3415 - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR 3416 - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do 3417 - IFS="$lt_save_ifs" 3418 - test -z "$ac_dir" && ac_dir=. 3419 - tmp_nm="$ac_dir/$lt_tmp_nm" 3420 - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then 3421 - # Check to see if the nm accepts a BSD-compat flag. 3422 - # Adding the `sed 1q' prevents false positives on HP-UX, which says: 3423 - # nm: unknown option "B" ignored 3424 - # Tru64's nm complains that /dev/null is an invalid object file 3425 - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in 3426 - */dev/null* | *'Invalid file or object type'*) 3427 - lt_cv_path_NM="$tmp_nm -B" 3428 - break 3429 - ;; 3430 - *) 3431 - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in 3432 - */dev/null*) 3433 - lt_cv_path_NM="$tmp_nm -p" 3434 - break 3435 - ;; 3436 - *) 3437 - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but 3438 - continue # so that we can try to find one that supports BSD flags 3439 - ;; 3440 - esac 3441 - ;; 3442 - esac 3443 - fi 3444 - done 3445 - IFS="$lt_save_ifs" 3446 - done 3447 - : ${lt_cv_path_NM=no} 3448 -fi]) 3449 -if test "$lt_cv_path_NM" != "no"; then 3450 - NM="$lt_cv_path_NM" 3451 -else 3452 - # Didn't find any BSD compatible name lister, look for dumpbin. 3453 - if test -n "$DUMPBIN"; then : 3454 - # Let the user override the test. 3455 - else 3456 - AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) 3457 - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in 3458 - *COFF*) 3459 - DUMPBIN="$DUMPBIN -symbols" 3460 - ;; 3461 - *) 3462 - DUMPBIN=: 3463 - ;; 3464 - esac 3465 - fi 3466 - AC_SUBST([DUMPBIN]) 3467 - if test "$DUMPBIN" != ":"; then 3468 - NM="$DUMPBIN" 3469 - fi 3470 -fi 3471 -test -z "$NM" && NM=nm 3472 -AC_SUBST([NM]) 3473 -_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl 3474 - 3475 -AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], 3476 - [lt_cv_nm_interface="BSD nm" 3477 - echo "int some_variable = 0;" > conftest.$ac_ext 3478 - (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) 3479 - (eval "$ac_compile" 2>conftest.err) 3480 - cat conftest.err >&AS_MESSAGE_LOG_FD 3481 - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) 3482 - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) 3483 - cat conftest.err >&AS_MESSAGE_LOG_FD 3484 - (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) 3485 - cat conftest.out >&AS_MESSAGE_LOG_FD 3486 - if $GREP 'External.*some_variable' conftest.out > /dev/null; then 3487 - lt_cv_nm_interface="MS dumpbin" 3488 - fi 3489 - rm -f conftest*]) 3490 -])# LT_PATH_NM 3491 - 3492 -# Old names: 3493 -AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) 3494 -AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) 3495 -dnl aclocal-1.4 backwards compatibility: 3496 -dnl AC_DEFUN([AM_PROG_NM], []) 3497 -dnl AC_DEFUN([AC_PROG_NM], []) 3498 - 3499 -# _LT_CHECK_SHAREDLIB_FROM_LINKLIB 3500 -# -------------------------------- 3501 -# how to determine the name of the shared library 3502 -# associated with a specific link library. 3503 -# -- PORTME fill in with the dynamic library characteristics 3504 -m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], 3505 -[m4_require([_LT_DECL_EGREP]) 3506 -m4_require([_LT_DECL_OBJDUMP]) 3507 -m4_require([_LT_DECL_DLLTOOL]) 3508 -AC_CACHE_CHECK([how to associate runtime and link libraries], 3509 -lt_cv_sharedlib_from_linklib_cmd, 3510 -[lt_cv_sharedlib_from_linklib_cmd='unknown' 3511 - 3512 -case $host_os in 3513 -cygwin* | mingw* | pw32* | cegcc*) 3514 - # two different shell functions defined in ltmain.sh 3515 - # decide which to use based on capabilities of $DLLTOOL 3516 - case `$DLLTOOL --help 2>&1` in 3517 - *--identify-strict*) 3518 - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib 3519 - ;; 3520 - *) 3521 - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback 3522 - ;; 3523 - esac 3524 - ;; 3525 -*) 3526 - # fallback: assume linklib IS sharedlib 3527 - lt_cv_sharedlib_from_linklib_cmd="$ECHO" 3528 - ;; 3529 -esac 3530 -]) 3531 -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd 3532 -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO 3533 - 3534 -_LT_DECL([], [sharedlib_from_linklib_cmd], [1], 3535 - [Command to associate shared and link libraries]) 3536 -])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB 3537 - 3538 - 3539 -# _LT_PATH_MANIFEST_TOOL 3540 -# ---------------------- 3541 -# locate the manifest tool 3542 -m4_defun([_LT_PATH_MANIFEST_TOOL], 3543 -[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) 3544 -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt 3545 -AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], 3546 - [lt_cv_path_mainfest_tool=no 3547 - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD 3548 - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out 3549 - cat conftest.err >&AS_MESSAGE_LOG_FD 3550 - if $GREP 'Manifest Tool' conftest.out > /dev/null; then 3551 - lt_cv_path_mainfest_tool=yes 3552 - fi 3553 - rm -f conftest*]) 3554 -if test "x$lt_cv_path_mainfest_tool" != xyes; then 3555 - MANIFEST_TOOL=: 3556 -fi 3557 -_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl 3558 -])# _LT_PATH_MANIFEST_TOOL 3559 - 3560 - 3561 -# LT_LIB_M 3562 -# -------- 3563 -# check for math library 3564 -AC_DEFUN([LT_LIB_M], 3565 -[AC_REQUIRE([AC_CANONICAL_HOST])dnl 3566 -LIBM= 3567 -case $host in 3568 -*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) 3569 - # These system don't have libm, or don't need it 3570 - ;; 3571 -*-ncr-sysv4.3*) 3572 - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") 3573 - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") 3574 - ;; 3575 -*) 3576 - AC_CHECK_LIB(m, cos, LIBM="-lm") 3577 - ;; 3578 -esac 3579 -AC_SUBST([LIBM]) 3580 -])# LT_LIB_M 3581 - 3582 -# Old name: 3583 -AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) 3584 -dnl aclocal-1.4 backwards compatibility: 3585 -dnl AC_DEFUN([AC_CHECK_LIBM], []) 3586 - 3587 - 3588 -# _LT_COMPILER_NO_RTTI([TAGNAME]) 3589 -# ------------------------------- 3590 -m4_defun([_LT_COMPILER_NO_RTTI], 3591 -[m4_require([_LT_TAG_COMPILER])dnl 3592 - 3593 -_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= 3594 - 3595 -if test "$GCC" = yes; then 3596 - case $cc_basename in 3597 - nvcc*) 3598 - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; 3599 - *) 3600 - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; 3601 - esac 3602 - 3603 - _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], 3604 - lt_cv_prog_compiler_rtti_exceptions, 3605 - [-fno-rtti -fno-exceptions], [], 3606 - [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) 3607 -fi 3608 -_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], 3609 - [Compiler flag to turn off builtin functions]) 3610 -])# _LT_COMPILER_NO_RTTI 3611 - 3612 - 3613 -# _LT_CMD_GLOBAL_SYMBOLS 3614 -# ---------------------- 3615 -m4_defun([_LT_CMD_GLOBAL_SYMBOLS], 3616 -[AC_REQUIRE([AC_CANONICAL_HOST])dnl 3617 -AC_REQUIRE([AC_PROG_CC])dnl 3618 -AC_REQUIRE([AC_PROG_AWK])dnl 3619 -AC_REQUIRE([LT_PATH_NM])dnl 3620 -AC_REQUIRE([LT_PATH_LD])dnl 3621 -m4_require([_LT_DECL_SED])dnl 3622 -m4_require([_LT_DECL_EGREP])dnl 3623 -m4_require([_LT_TAG_COMPILER])dnl 3624 - 3625 -# Check for command to grab the raw symbol name followed by C symbol from nm. 3626 -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) 3627 -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], 3628 -[ 3629 -# These are sane defaults that work on at least a few old systems. 3630 -# [They come from Ultrix. What could be older than Ultrix?!! ;)] 3631 - 3632 -# Character class describing NM global symbol codes. 3633 -symcode='[[BCDEGRST]]' 3634 - 3635 -# Regexp to match symbols that can be accessed directly from C. 3636 -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' 3637 - 3638 -# Define system-specific variables. 3639 -case $host_os in 3640 -aix*) 3641 - symcode='[[BCDT]]' 3642 - ;; 3643 -cygwin* | mingw* | pw32* | cegcc*) 3644 - symcode='[[ABCDGISTW]]' 3645 - ;; 3646 -hpux*) 3647 - if test "$host_cpu" = ia64; then 3648 - symcode='[[ABCDEGRST]]' 3649 - fi 3650 - ;; 3651 -irix* | nonstopux*) 3652 - symcode='[[BCDEGRST]]' 3653 - ;; 3654 -osf*) 3655 - symcode='[[BCDEGQRST]]' 3656 - ;; 3657 -solaris*) 3658 - symcode='[[BDRT]]' 3659 - ;; 3660 -sco3.2v5*) 3661 - symcode='[[DT]]' 3662 - ;; 3663 -sysv4.2uw2*) 3664 - symcode='[[DT]]' 3665 - ;; 3666 -sysv5* | sco5v6* | unixware* | OpenUNIX*) 3667 - symcode='[[ABDT]]' 3668 - ;; 3669 -sysv4) 3670 - symcode='[[DFNSTU]]' 3671 - ;; 3672 -esac 3673 - 3674 -# If we're using GNU nm, then use its standard symbol codes. 3675 -case `$NM -V 2>&1` in 3676 -*GNU* | *'with BFD'*) 3677 - symcode='[[ABCDGIRSTW]]' ;; 3678 -esac 3679 - 3680 -# Transform an extracted symbol line into a proper C declaration. 3681 -# Some systems (esp. on ia64) link data and code symbols differently, 3682 -# so use this general approach. 3683 -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" 3684 - 3685 -# Transform an extracted symbol line into symbol name and symbol address 3686 -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" 3687 -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" 3688 - 3689 -# Handle CRLF in mingw tool chain 3690 -opt_cr= 3691 -case $build_os in 3692 -mingw*) 3693 - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp 3694 - ;; 3695 -esac 3696 - 3697 -# Try without a prefix underscore, then with it. 3698 -for ac_symprfx in "" "_"; do 3699 - 3700 - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. 3701 - symxfrm="\\1 $ac_symprfx\\2 \\2" 3702 - 3703 - # Write the raw and C identifiers. 3704 - if test "$lt_cv_nm_interface" = "MS dumpbin"; then 3705 - # Fake it for dumpbin and say T for any non-static function 3706 - # and D for any global variable. 3707 - # Also find C++ and __fastcall symbols from MSVC++, 3708 - # which start with @ or ?. 3709 - lt_cv_sys_global_symbol_pipe="$AWK ['"\ 3710 -" {last_section=section; section=\$ 3};"\ 3711 -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ 3712 -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ 3713 -" \$ 0!~/External *\|/{next};"\ 3714 -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ 3715 -" {if(hide[section]) next};"\ 3716 -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ 3717 -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ 3718 -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ 3719 -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ 3720 -" ' prfx=^$ac_symprfx]" 3721 - else 3722 - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" 3723 - fi 3724 - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" 3725 - 3726 - # Check to see that the pipe works correctly. 3727 - pipe_works=no 3728 - 3729 - rm -f conftest* 3730 - cat > conftest.$ac_ext <<_LT_EOF 3731 -#ifdef __cplusplus 3732 -extern "C" { 3733 -#endif 3734 -char nm_test_var; 3735 -void nm_test_func(void); 3736 -void nm_test_func(void){} 3737 -#ifdef __cplusplus 3738 -} 3739 -#endif 3740 -int main(){nm_test_var='a';nm_test_func();return(0);} 3741 -_LT_EOF 3742 - 3743 - if AC_TRY_EVAL(ac_compile); then 3744 - # Now try to grab the symbols. 3745 - nlist=conftest.nm 3746 - if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then 3747 - # Try sorting and uniquifying the output. 3748 - if sort "$nlist" | uniq > "$nlist"T; then 3749 - mv -f "$nlist"T "$nlist" 3750 - else 3751 - rm -f "$nlist"T 3752 - fi 3753 - 3754 - # Make sure that we snagged all the symbols we need. 3755 - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then 3756 - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then 3757 - cat <<_LT_EOF > conftest.$ac_ext 3758 -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3759 -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3760 -/* DATA imports from DLLs on WIN32 con't be const, because runtime 3761 - relocations are performed -- see ld's documentation on pseudo-relocs. */ 3762 -# define LT@&t@_DLSYM_CONST 3763 -#elif defined(__osf__) 3764 -/* This system does not cope well with relocations in const data. */ 3765 -# define LT@&t@_DLSYM_CONST 3766 -#else 3767 -# define LT@&t@_DLSYM_CONST const 3768 -#endif 3769 - 3770 -#ifdef __cplusplus 3771 -extern "C" { 3772 -#endif 3773 - 3774 -_LT_EOF 3775 - # Now generate the symbol file. 3776 - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' 3777 - 3778 - cat <<_LT_EOF >> conftest.$ac_ext 3779 - 3780 -/* The mapping between symbol names and symbols. */ 3781 -LT@&t@_DLSYM_CONST struct { 3782 - const char *name; 3783 - void *address; 3784 -} 3785 -lt__PROGRAM__LTX_preloaded_symbols[[]] = 3786 -{ 3787 - { "@PROGRAM@", (void *) 0 }, 3788 -_LT_EOF 3789 - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext 3790 - cat <<\_LT_EOF >> conftest.$ac_ext 3791 - {0, (void *) 0} 3792 -}; 3793 - 3794 -/* This works around a problem in FreeBSD linker */ 3795 -#ifdef FREEBSD_WORKAROUND 3796 -static const void *lt_preloaded_setup() { 3797 - return lt__PROGRAM__LTX_preloaded_symbols; 3798 -} 3799 -#endif 3800 - 3801 -#ifdef __cplusplus 3802 -} 3803 -#endif 3804 -_LT_EOF 3805 - # Now try linking the two files. 3806 - mv conftest.$ac_objext conftstm.$ac_objext 3807 - lt_globsym_save_LIBS=$LIBS 3808 - lt_globsym_save_CFLAGS=$CFLAGS 3809 - LIBS="conftstm.$ac_objext" 3810 - CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" 3811 - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then 3812 - pipe_works=yes 3813 - fi 3814 - LIBS=$lt_globsym_save_LIBS 3815 - CFLAGS=$lt_globsym_save_CFLAGS 3816 - else 3817 - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD 3818 - fi 3819 - else 3820 - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD 3821 - fi 3822 - else 3823 - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD 3824 - fi 3825 - else 3826 - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD 3827 - cat conftest.$ac_ext >&5 3828 - fi 3829 - rm -rf conftest* conftst* 3830 - 3831 - # Do not use the global_symbol_pipe unless it works. 3832 - if test "$pipe_works" = yes; then 3833 - break 3834 - else 3835 - lt_cv_sys_global_symbol_pipe= 3836 - fi 3837 -done 3838 -]) 3839 -if test -z "$lt_cv_sys_global_symbol_pipe"; then 3840 - lt_cv_sys_global_symbol_to_cdecl= 3841 -fi 3842 -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then 3843 - AC_MSG_RESULT(failed) 3844 -else 3845 - AC_MSG_RESULT(ok) 3846 -fi 3847 - 3848 -# Response file support. 3849 -if test "$lt_cv_nm_interface" = "MS dumpbin"; then 3850 - nm_file_list_spec='@' 3851 -elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then 3852 - nm_file_list_spec='@' 3853 -fi 3854 - 3855 -_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], 3856 - [Take the output of nm and produce a listing of raw symbols and C names]) 3857 -_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], 3858 - [Transform the output of nm in a proper C declaration]) 3859 -_LT_DECL([global_symbol_to_c_name_address], 3860 - [lt_cv_sys_global_symbol_to_c_name_address], [1], 3861 - [Transform the output of nm in a C name address pair]) 3862 -_LT_DECL([global_symbol_to_c_name_address_lib_prefix], 3863 - [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], 3864 - [Transform the output of nm in a C name address pair when lib prefix is needed]) 3865 -_LT_DECL([], [nm_file_list_spec], [1], 3866 - [Specify filename containing input files for $NM]) 3867 -]) # _LT_CMD_GLOBAL_SYMBOLS 3868 - 3869 - 3870 -# _LT_COMPILER_PIC([TAGNAME]) 3871 -# --------------------------- 3872 -m4_defun([_LT_COMPILER_PIC], 3873 -[m4_require([_LT_TAG_COMPILER])dnl 3874 -_LT_TAGVAR(lt_prog_compiler_wl, $1)= 3875 -_LT_TAGVAR(lt_prog_compiler_pic, $1)= 3876 -_LT_TAGVAR(lt_prog_compiler_static, $1)= 3877 - 3878 -m4_if([$1], [CXX], [ 3879 - # C++ specific cases for pic, static, wl, etc. 3880 - if test "$GXX" = yes; then 3881 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 3882 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' 3883 - 3884 - case $host_os in 3885 - aix*) 3886 - # All AIX code is PIC. 3887 - if test "$host_cpu" = ia64; then 3888 - # AIX 5 now supports IA64 processor 3889 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 3890 - fi 3891 - ;; 3892 - 3893 - amigaos*) 3894 - case $host_cpu in 3895 - powerpc) 3896 - # see comment about AmigaOS4 .so support 3897 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 3898 - ;; 3899 - m68k) 3900 - # FIXME: we need at least 68020 code to build shared libraries, but 3901 - # adding the `-m68020' flag to GCC prevents building anything better, 3902 - # like `-m68040'. 3903 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' 3904 - ;; 3905 - esac 3906 - ;; 3907 - 3908 - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) 3909 - # PIC is the default for these OSes. 3910 - ;; 3911 - mingw* | cygwin* | os2* | pw32* | cegcc*) 3912 - # This hack is so that the source file can tell whether it is being 3913 - # built for inclusion in a dll (and should export symbols for example). 3914 - # Although the cygwin gcc ignores -fPIC, still need this for old-style 3915 - # (--disable-auto-import) libraries 3916 - m4_if([$1], [GCJ], [], 3917 - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) 3918 - ;; 3919 - darwin* | rhapsody*) 3920 - # PIC is the default on this platform 3921 - # Common symbols not allowed in MH_DYLIB files 3922 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' 3923 - ;; 3924 - *djgpp*) 3925 - # DJGPP does not support shared libraries at all 3926 - _LT_TAGVAR(lt_prog_compiler_pic, $1)= 3927 - ;; 3928 - haiku*) 3929 - # PIC is the default for Haiku. 3930 - # The "-static" flag exists, but is broken. 3931 - _LT_TAGVAR(lt_prog_compiler_static, $1)= 3932 - ;; 3933 - interix[[3-9]]*) 3934 - # Interix 3.x gcc -fpic/-fPIC options generate broken code. 3935 - # Instead, we relocate shared libraries at runtime. 3936 - ;; 3937 - sysv4*MP*) 3938 - if test -d /usr/nec; then 3939 - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic 3940 - fi 3941 - ;; 3942 - hpux*) 3943 - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit 3944 - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag 3945 - # sets the default TLS model and affects inlining. 3946 - case $host_cpu in 3947 - hppa*64*) 3948 - ;; 3949 - *) 3950 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 3951 - ;; 3952 - esac 3953 - ;; 3954 - *qnx* | *nto*) 3955 - # QNX uses GNU C++, but need to define -shared option too, otherwise 3956 - # it will coredump. 3957 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' 3958 - ;; 3959 - *) 3960 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 3961 - ;; 3962 - esac 3963 - else 3964 - case $host_os in 3965 - aix[[4-9]]*) 3966 - # All AIX code is PIC. 3967 - if test "$host_cpu" = ia64; then 3968 - # AIX 5 now supports IA64 processor 3969 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 3970 - else 3971 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' 3972 - fi 3973 - ;; 3974 - chorus*) 3975 - case $cc_basename in 3976 - cxch68*) 3977 - # Green Hills C++ Compiler 3978 - # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" 3979 - ;; 3980 - esac 3981 - ;; 3982 - mingw* | cygwin* | os2* | pw32* | cegcc*) 3983 - # This hack is so that the source file can tell whether it is being 3984 - # built for inclusion in a dll (and should export symbols for example). 3985 - m4_if([$1], [GCJ], [], 3986 - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) 3987 - ;; 3988 - dgux*) 3989 - case $cc_basename in 3990 - ec++*) 3991 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 3992 - ;; 3993 - ghcx*) 3994 - # Green Hills C++ Compiler 3995 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' 3996 - ;; 3997 - *) 3998 - ;; 3999 - esac 4000 - ;; 4001 - freebsd* | dragonfly*) 4002 - # FreeBSD uses GNU C++ 4003 - ;; 4004 - hpux9* | hpux10* | hpux11*) 4005 - case $cc_basename in 4006 - CC*) 4007 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4008 - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' 4009 - if test "$host_cpu" != ia64; then 4010 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' 4011 - fi 4012 - ;; 4013 - aCC*) 4014 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4015 - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' 4016 - case $host_cpu in 4017 - hppa*64*|ia64*) 4018 - # +Z the default 4019 - ;; 4020 - *) 4021 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' 4022 - ;; 4023 - esac 4024 - ;; 4025 - *) 4026 - ;; 4027 - esac 4028 - ;; 4029 - interix*) 4030 - # This is c89, which is MS Visual C++ (no shared libs) 4031 - # Anyone wants to do a port? 4032 - ;; 4033 - irix5* | irix6* | nonstopux*) 4034 - case $cc_basename in 4035 - CC*) 4036 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4037 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' 4038 - # CC pic flag -KPIC is the default. 4039 - ;; 4040 - *) 4041 - ;; 4042 - esac 4043 - ;; 4044 - linux* | k*bsd*-gnu | kopensolaris*-gnu) 4045 - case $cc_basename in 4046 - KCC*) 4047 - # KAI C++ Compiler 4048 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' 4049 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 4050 - ;; 4051 - ecpc* ) 4052 - # old Intel C++ for x86_64 which still supported -KPIC. 4053 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4054 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4055 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' 4056 - ;; 4057 - icpc* ) 4058 - # Intel C++, used to be incompatible with GCC. 4059 - # ICC 10 doesn't accept -KPIC any more. 4060 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4061 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 4062 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' 4063 - ;; 4064 - pgCC* | pgcpp*) 4065 - # Portland Group C++ compiler 4066 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4067 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' 4068 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4069 - ;; 4070 - cxx*) 4071 - # Compaq C++ 4072 - # Make sure the PIC flag is empty. It appears that all Alpha 4073 - # Linux and Compaq Tru64 Unix objects are PIC. 4074 - _LT_TAGVAR(lt_prog_compiler_pic, $1)= 4075 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' 4076 - ;; 4077 - xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) 4078 - # IBM XL 8.0, 9.0 on PPC and BlueGene 4079 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4080 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' 4081 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' 4082 - ;; 4083 - *) 4084 - case `$CC -V 2>&1 | sed 5q` in 4085 - *Sun\ C*) 4086 - # Sun C++ 5.9 4087 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4088 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4089 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' 4090 - ;; 4091 - esac 4092 - ;; 4093 - esac 4094 - ;; 4095 - lynxos*) 4096 - ;; 4097 - m88k*) 4098 - ;; 4099 - mvs*) 4100 - case $cc_basename in 4101 - cxx*) 4102 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' 4103 - ;; 4104 - *) 4105 - ;; 4106 - esac 4107 - ;; 4108 - netbsd*) 4109 - ;; 4110 - *qnx* | *nto*) 4111 - # QNX uses GNU C++, but need to define -shared option too, otherwise 4112 - # it will coredump. 4113 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' 4114 - ;; 4115 - osf3* | osf4* | osf5*) 4116 - case $cc_basename in 4117 - KCC*) 4118 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' 4119 - ;; 4120 - RCC*) 4121 - # Rational C++ 2.4.1 4122 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' 4123 - ;; 4124 - cxx*) 4125 - # Digital/Compaq C++ 4126 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4127 - # Make sure the PIC flag is empty. It appears that all Alpha 4128 - # Linux and Compaq Tru64 Unix objects are PIC. 4129 - _LT_TAGVAR(lt_prog_compiler_pic, $1)= 4130 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' 4131 - ;; 4132 - *) 4133 - ;; 4134 - esac 4135 - ;; 4136 - psos*) 4137 - ;; 4138 - solaris*) 4139 - case $cc_basename in 4140 - CC* | sunCC*) 4141 - # Sun C++ 4.2, 5.x and Centerline C++ 4142 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4143 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4144 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' 4145 - ;; 4146 - gcx*) 4147 - # Green Hills C++ Compiler 4148 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' 4149 - ;; 4150 - *) 4151 - ;; 4152 - esac 4153 - ;; 4154 - sunos4*) 4155 - case $cc_basename in 4156 - CC*) 4157 - # Sun C++ 4.x 4158 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' 4159 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4160 - ;; 4161 - lcc*) 4162 - # Lucid 4163 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' 4164 - ;; 4165 - *) 4166 - ;; 4167 - esac 4168 - ;; 4169 - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) 4170 - case $cc_basename in 4171 - CC*) 4172 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4173 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4174 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4175 - ;; 4176 - esac 4177 - ;; 4178 - tandem*) 4179 - case $cc_basename in 4180 - NCC*) 4181 - # NonStop-UX NCC 3.20 4182 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4183 - ;; 4184 - *) 4185 - ;; 4186 - esac 4187 - ;; 4188 - vxworks*) 4189 - ;; 4190 - *) 4191 - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no 4192 - ;; 4193 - esac 4194 - fi 4195 -], 4196 -[ 4197 - if test "$GCC" = yes; then 4198 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4199 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' 4200 - 4201 - case $host_os in 4202 - aix*) 4203 - # All AIX code is PIC. 4204 - if test "$host_cpu" = ia64; then 4205 - # AIX 5 now supports IA64 processor 4206 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4207 - fi 4208 - ;; 4209 - 4210 - amigaos*) 4211 - case $host_cpu in 4212 - powerpc) 4213 - # see comment about AmigaOS4 .so support 4214 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 4215 - ;; 4216 - m68k) 4217 - # FIXME: we need at least 68020 code to build shared libraries, but 4218 - # adding the `-m68020' flag to GCC prevents building anything better, 4219 - # like `-m68040'. 4220 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' 4221 - ;; 4222 - esac 4223 - ;; 4224 - 4225 - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) 4226 - # PIC is the default for these OSes. 4227 - ;; 4228 - 4229 - mingw* | cygwin* | pw32* | os2* | cegcc*) 4230 - # This hack is so that the source file can tell whether it is being 4231 - # built for inclusion in a dll (and should export symbols for example). 4232 - # Although the cygwin gcc ignores -fPIC, still need this for old-style 4233 - # (--disable-auto-import) libraries 4234 - m4_if([$1], [GCJ], [], 4235 - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) 4236 - ;; 4237 - 4238 - darwin* | rhapsody*) 4239 - # PIC is the default on this platform 4240 - # Common symbols not allowed in MH_DYLIB files 4241 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' 4242 - ;; 4243 - 4244 - haiku*) 4245 - # PIC is the default for Haiku. 4246 - # The "-static" flag exists, but is broken. 4247 - _LT_TAGVAR(lt_prog_compiler_static, $1)= 4248 - ;; 4249 - 4250 - hpux*) 4251 - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit 4252 - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag 4253 - # sets the default TLS model and affects inlining. 4254 - case $host_cpu in 4255 - hppa*64*) 4256 - # +Z the default 4257 - ;; 4258 - *) 4259 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 4260 - ;; 4261 - esac 4262 - ;; 4263 - 4264 - interix[[3-9]]*) 4265 - # Interix 3.x gcc -fpic/-fPIC options generate broken code. 4266 - # Instead, we relocate shared libraries at runtime. 4267 - ;; 4268 - 4269 - msdosdjgpp*) 4270 - # Just because we use GCC doesn't mean we suddenly get shared libraries 4271 - # on systems that don't support them. 4272 - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no 4273 - enable_shared=no 4274 - ;; 4275 - 4276 - *nto* | *qnx*) 4277 - # QNX uses GNU C++, but need to define -shared option too, otherwise 4278 - # it will coredump. 4279 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' 4280 - ;; 4281 - 4282 - sysv4*MP*) 4283 - if test -d /usr/nec; then 4284 - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic 4285 - fi 4286 - ;; 4287 - 4288 - *) 4289 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 4290 - ;; 4291 - esac 4292 - 4293 - case $cc_basename in 4294 - nvcc*) # Cuda Compiler Driver 2.2 4295 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' 4296 - if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then 4297 - _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" 4298 - fi 4299 - ;; 4300 - esac 4301 - else 4302 - # PORTME Check for flag to pass linker flags through the system compiler. 4303 - case $host_os in 4304 - aix*) 4305 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4306 - if test "$host_cpu" = ia64; then 4307 - # AIX 5 now supports IA64 processor 4308 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4309 - else 4310 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' 4311 - fi 4312 - ;; 4313 - 4314 - mingw* | cygwin* | pw32* | os2* | cegcc*) 4315 - # This hack is so that the source file can tell whether it is being 4316 - # built for inclusion in a dll (and should export symbols for example). 4317 - m4_if([$1], [GCJ], [], 4318 - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) 4319 - ;; 4320 - 4321 - hpux9* | hpux10* | hpux11*) 4322 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4323 - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but 4324 - # not for PA HP-UX. 4325 - case $host_cpu in 4326 - hppa*64*|ia64*) 4327 - # +Z the default 4328 - ;; 4329 - *) 4330 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' 4331 - ;; 4332 - esac 4333 - # Is there a better lt_prog_compiler_static that works with the bundled CC? 4334 - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' 4335 - ;; 4336 - 4337 - irix5* | irix6* | nonstopux*) 4338 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4339 - # PIC (with -KPIC) is the default. 4340 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' 4341 - ;; 4342 - 4343 - linux* | k*bsd*-gnu | kopensolaris*-gnu) 4344 - case $cc_basename in 4345 - # old Intel for x86_64 which still supported -KPIC. 4346 - ecc*) 4347 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4348 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4349 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' 4350 - ;; 4351 - # icc used to be incompatible with GCC. 4352 - # ICC 10 doesn't accept -KPIC any more. 4353 - icc* | ifort*) 4354 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4355 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 4356 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' 4357 - ;; 4358 - # Lahey Fortran 8.1. 4359 - lf95*) 4360 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4361 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' 4362 - _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' 4363 - ;; 4364 - nagfor*) 4365 - # NAG Fortran compiler 4366 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' 4367 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' 4368 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4369 - ;; 4370 - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) 4371 - # Portland Group compilers (*not* the Pentium gcc compiler, 4372 - # which looks to be a dead project) 4373 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4374 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' 4375 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4376 - ;; 4377 - ccc*) 4378 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4379 - # All Alpha code is PIC. 4380 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' 4381 - ;; 4382 - xl* | bgxl* | bgf* | mpixl*) 4383 - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene 4384 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4385 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' 4386 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' 4387 - ;; 4388 - *) 4389 - case `$CC -V 2>&1 | sed 5q` in 4390 - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) 4391 - # Sun Fortran 8.3 passes all unrecognized flags to the linker 4392 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4393 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4394 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' 4395 - ;; 4396 - *Sun\ F* | *Sun*Fortran*) 4397 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4398 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4399 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' 4400 - ;; 4401 - *Sun\ C*) 4402 - # Sun C 5.9 4403 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4404 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4405 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4406 - ;; 4407 - *Intel*\ [[CF]]*Compiler*) 4408 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4409 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' 4410 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' 4411 - ;; 4412 - *Portland\ Group*) 4413 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4414 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' 4415 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4416 - ;; 4417 - esac 4418 - ;; 4419 - esac 4420 - ;; 4421 - 4422 - newsos6) 4423 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4424 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4425 - ;; 4426 - 4427 - *nto* | *qnx*) 4428 - # QNX uses GNU C++, but need to define -shared option too, otherwise 4429 - # it will coredump. 4430 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' 4431 - ;; 4432 - 4433 - osf3* | osf4* | osf5*) 4434 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4435 - # All OSF/1 code is PIC. 4436 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' 4437 - ;; 4438 - 4439 - rdos*) 4440 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' 4441 - ;; 4442 - 4443 - solaris*) 4444 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4445 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4446 - case $cc_basename in 4447 - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) 4448 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; 4449 - *) 4450 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; 4451 - esac 4452 - ;; 4453 - 4454 - sunos4*) 4455 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' 4456 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' 4457 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4458 - ;; 4459 - 4460 - sysv4 | sysv4.2uw2* | sysv4.3*) 4461 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4462 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4463 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4464 - ;; 4465 - 4466 - sysv4*MP*) 4467 - if test -d /usr/nec ;then 4468 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' 4469 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4470 - fi 4471 - ;; 4472 - 4473 - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) 4474 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4475 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' 4476 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4477 - ;; 4478 - 4479 - unicos*) 4480 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' 4481 - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no 4482 - ;; 4483 - 4484 - uts4*) 4485 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' 4486 - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' 4487 - ;; 4488 - 4489 - *) 4490 - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no 4491 - ;; 4492 - esac 4493 - fi 4494 -]) 4495 -case $host_os in 4496 - # For platforms which do not support PIC, -DPIC is meaningless: 4497 - *djgpp*) 4498 - _LT_TAGVAR(lt_prog_compiler_pic, $1)= 4499 - ;; 4500 - *) 4501 - _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" 4502 - ;; 4503 -esac 4504 - 4505 -AC_CACHE_CHECK([for $compiler option to produce PIC], 4506 - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], 4507 - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) 4508 -_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) 4509 - 4510 -# 4511 -# Check to make sure the PIC flag actually works. 4512 -# 4513 -if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then 4514 - _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], 4515 - [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], 4516 - [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], 4517 - [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in 4518 - "" | " "*) ;; 4519 - *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; 4520 - esac], 4521 - [_LT_TAGVAR(lt_prog_compiler_pic, $1)= 4522 - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) 4523 -fi 4524 -_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], 4525 - [Additional compiler flags for building library objects]) 4526 - 4527 -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], 4528 - [How to pass a linker flag through the compiler]) 4529 -# 4530 -# Check to make sure the static flag actually works. 4531 -# 4532 -wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" 4533 -_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], 4534 - _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), 4535 - $lt_tmp_static_flag, 4536 - [], 4537 - [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) 4538 -_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], 4539 - [Compiler flag to prevent dynamic linking]) 4540 -])# _LT_COMPILER_PIC 4541 - 4542 - 4543 -# _LT_LINKER_SHLIBS([TAGNAME]) 4544 -# ---------------------------- 4545 -# See if the linker supports building shared libraries. 4546 -m4_defun([_LT_LINKER_SHLIBS], 4547 -[AC_REQUIRE([LT_PATH_LD])dnl 4548 -AC_REQUIRE([LT_PATH_NM])dnl 4549 -m4_require([_LT_PATH_MANIFEST_TOOL])dnl 4550 -m4_require([_LT_FILEUTILS_DEFAULTS])dnl 4551 -m4_require([_LT_DECL_EGREP])dnl 4552 -m4_require([_LT_DECL_SED])dnl 4553 -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl 4554 -m4_require([_LT_TAG_COMPILER])dnl 4555 -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) 4556 -m4_if([$1], [CXX], [ 4557 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' 4558 - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] 4559 - case $host_os in 4560 - aix[[4-9]]*) 4561 - # If we're using GNU nm, then we don't want the "-C" option. 4562 - # -C means demangle to AIX nm, but means don't demangle with GNU nm 4563 - # Also, AIX nm treats weak defined symbols like other global defined 4564 - # symbols, whereas GNU nm marks them as "W". 4565 - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then 4566 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' 4567 - else 4568 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' 4569 - fi 4570 - ;; 4571 - pw32*) 4572 - _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" 4573 - ;; 4574 - cygwin* | mingw* | cegcc*) 4575 - case $cc_basename in 4576 - cl*) 4577 - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' 4578 - ;; 4579 - *) 4580 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' 4581 - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] 4582 - ;; 4583 - esac 4584 - ;; 4585 - *) 4586 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' 4587 - ;; 4588 - esac 4589 -], [ 4590 - runpath_var= 4591 - _LT_TAGVAR(allow_undefined_flag, $1)= 4592 - _LT_TAGVAR(always_export_symbols, $1)=no 4593 - _LT_TAGVAR(archive_cmds, $1)= 4594 - _LT_TAGVAR(archive_expsym_cmds, $1)= 4595 - _LT_TAGVAR(compiler_needs_object, $1)=no 4596 - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no 4597 - _LT_TAGVAR(export_dynamic_flag_spec, $1)= 4598 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' 4599 - _LT_TAGVAR(hardcode_automatic, $1)=no 4600 - _LT_TAGVAR(hardcode_direct, $1)=no 4601 - _LT_TAGVAR(hardcode_direct_absolute, $1)=no 4602 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= 4603 - _LT_TAGVAR(hardcode_libdir_separator, $1)= 4604 - _LT_TAGVAR(hardcode_minus_L, $1)=no 4605 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported 4606 - _LT_TAGVAR(inherit_rpath, $1)=no 4607 - _LT_TAGVAR(link_all_deplibs, $1)=unknown 4608 - _LT_TAGVAR(module_cmds, $1)= 4609 - _LT_TAGVAR(module_expsym_cmds, $1)= 4610 - _LT_TAGVAR(old_archive_from_new_cmds, $1)= 4611 - _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= 4612 - _LT_TAGVAR(thread_safe_flag_spec, $1)= 4613 - _LT_TAGVAR(whole_archive_flag_spec, $1)= 4614 - # include_expsyms should be a list of space-separated symbols to be *always* 4615 - # included in the symbol list 4616 - _LT_TAGVAR(include_expsyms, $1)= 4617 - # exclude_expsyms can be an extended regexp of symbols to exclude 4618 - # it will be wrapped by ` (' and `)$', so one must not match beginning or 4619 - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', 4620 - # as well as any symbol that contains `d'. 4621 - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] 4622 - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out 4623 - # platforms (ab)use it in PIC code, but their linkers get confused if 4624 - # the symbol is explicitly referenced. Since portable code cannot 4625 - # rely on this symbol name, it's probably fine to never include it in 4626 - # preloaded symbol tables. 4627 - # Exclude shared library initialization/finalization symbols. 4628 -dnl Note also adjust exclude_expsyms for C++ above. 4629 - extract_expsyms_cmds= 4630 - 4631 - case $host_os in 4632 - cygwin* | mingw* | pw32* | cegcc*) 4633 - # FIXME: the MSVC++ port hasn't been tested in a loooong time 4634 - # When not using gcc, we currently assume that we are using 4635 - # Microsoft Visual C++. 4636 - if test "$GCC" != yes; then 4637 - with_gnu_ld=no 4638 - fi 4639 - ;; 4640 - interix*) 4641 - # we just hope/assume this is gcc and not c89 (= MSVC++) 4642 - with_gnu_ld=yes 4643 - ;; 4644 - openbsd*) 4645 - with_gnu_ld=no 4646 - ;; 4647 - esac 4648 - 4649 - _LT_TAGVAR(ld_shlibs, $1)=yes 4650 - 4651 - # On some targets, GNU ld is compatible enough with the native linker 4652 - # that we're better off using the native interface for both. 4653 - lt_use_gnu_ld_interface=no 4654 - if test "$with_gnu_ld" = yes; then 4655 - case $host_os in 4656 - aix*) 4657 - # The AIX port of GNU ld has always aspired to compatibility 4658 - # with the native linker. However, as the warning in the GNU ld 4659 - # block says, versions before 2.19.5* couldn't really create working 4660 - # shared libraries, regardless of the interface used. 4661 - case `$LD -v 2>&1` in 4662 - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; 4663 - *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; 4664 - *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; 4665 - *) 4666 - lt_use_gnu_ld_interface=yes 4667 - ;; 4668 - esac 4669 - ;; 4670 - *) 4671 - lt_use_gnu_ld_interface=yes 4672 - ;; 4673 - esac 4674 - fi 4675 - 4676 - if test "$lt_use_gnu_ld_interface" = yes; then 4677 - # If archive_cmds runs LD, not CC, wlarc should be empty 4678 - wlarc='${wl}' 4679 - 4680 - # Set some defaults for GNU ld with shared library support. These 4681 - # are reset later if shared libraries are not supported. Putting them 4682 - # here allows them to be overridden if necessary. 4683 - runpath_var=LD_RUN_PATH 4684 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 4685 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' 4686 - # ancient GNU ld didn't support --whole-archive et. al. 4687 - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then 4688 - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' 4689 - else 4690 - _LT_TAGVAR(whole_archive_flag_spec, $1)= 4691 - fi 4692 - supports_anon_versioning=no 4693 - case `$LD -v 2>&1` in 4694 - *GNU\ gold*) supports_anon_versioning=yes ;; 4695 - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 4696 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... 4697 - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... 4698 - *\ 2.11.*) ;; # other 2.11 versions 4699 - *) supports_anon_versioning=yes ;; 4700 - esac 4701 - 4702 - # See if GNU ld supports shared libraries. 4703 - case $host_os in 4704 - aix[[3-9]]*) 4705 - # On AIX/PPC, the GNU linker is very broken 4706 - if test "$host_cpu" != ia64; then 4707 - _LT_TAGVAR(ld_shlibs, $1)=no 4708 - cat <<_LT_EOF 1>&2 4709 - 4710 -*** Warning: the GNU linker, at least up to release 2.19, is reported 4711 -*** to be unable to reliably create shared libraries on AIX. 4712 -*** Therefore, libtool is disabling shared libraries support. If you 4713 -*** really care for shared libraries, you may want to install binutils 4714 -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. 4715 -*** You will then need to restart the configuration process. 4716 - 4717 -_LT_EOF 4718 - fi 4719 - ;; 4720 - 4721 - amigaos*) 4722 - case $host_cpu in 4723 - powerpc) 4724 - # see comment about AmigaOS4 .so support 4725 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 4726 - _LT_TAGVAR(archive_expsym_cmds, $1)='' 4727 - ;; 4728 - m68k) 4729 - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' 4730 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 4731 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 4732 - ;; 4733 - esac 4734 - ;; 4735 - 4736 - beos*) 4737 - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then 4738 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 4739 - # Joseph Beckenbach <jrb3@best.com> says some releases of gcc 4740 - # support --undefined. This deserves some investigation. FIXME 4741 - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 4742 - else 4743 - _LT_TAGVAR(ld_shlibs, $1)=no 4744 - fi 4745 - ;; 4746 - 4747 - cygwin* | mingw* | pw32* | cegcc*) 4748 - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, 4749 - # as there is no search path for DLLs. 4750 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 4751 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' 4752 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 4753 - _LT_TAGVAR(always_export_symbols, $1)=no 4754 - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes 4755 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' 4756 - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] 4757 - 4758 - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then 4759 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' 4760 - # If the export-symbols file already is a .def file (1st line 4761 - # is EXPORTS), use it as is; otherwise, prepend... 4762 - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then 4763 - cp $export_symbols $output_objdir/$soname.def; 4764 - else 4765 - echo EXPORTS > $output_objdir/$soname.def; 4766 - cat $export_symbols >> $output_objdir/$soname.def; 4767 - fi~ 4768 - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' 4769 - else 4770 - _LT_TAGVAR(ld_shlibs, $1)=no 4771 - fi 4772 - ;; 4773 - 4774 - haiku*) 4775 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 4776 - _LT_TAGVAR(link_all_deplibs, $1)=yes 4777 - ;; 4778 - 4779 - interix[[3-9]]*) 4780 - _LT_TAGVAR(hardcode_direct, $1)=no 4781 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 4782 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' 4783 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 4784 - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. 4785 - # Instead, shared libraries are loaded at an image base (0x10000000 by 4786 - # default) and relocated if they conflict, which is a slow very memory 4787 - # consuming and fragmenting process. To avoid this, we pick a random, 4788 - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link 4789 - # time. Moving up from 0x10000000 also allows more sbrk(2) space. 4790 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' 4791 - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' 4792 - ;; 4793 - 4794 - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) 4795 - tmp_diet=no 4796 - if test "$host_os" = linux-dietlibc; then 4797 - case $cc_basename in 4798 - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) 4799 - esac 4800 - fi 4801 - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ 4802 - && test "$tmp_diet" = no 4803 - then 4804 - tmp_addflag=' $pic_flag' 4805 - tmp_sharedflag='-shared' 4806 - case $cc_basename,$host_cpu in 4807 - pgcc*) # Portland Group C compiler 4808 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' 4809 - tmp_addflag=' $pic_flag' 4810 - ;; 4811 - pgf77* | pgf90* | pgf95* | pgfortran*) 4812 - # Portland Group f77 and f90 compilers 4813 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' 4814 - tmp_addflag=' $pic_flag -Mnomain' ;; 4815 - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 4816 - tmp_addflag=' -i_dynamic' ;; 4817 - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 4818 - tmp_addflag=' -i_dynamic -nofor_main' ;; 4819 - ifc* | ifort*) # Intel Fortran compiler 4820 - tmp_addflag=' -nofor_main' ;; 4821 - lf95*) # Lahey Fortran 8.1 4822 - _LT_TAGVAR(whole_archive_flag_spec, $1)= 4823 - tmp_sharedflag='--shared' ;; 4824 - xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) 4825 - tmp_sharedflag='-qmkshrobj' 4826 - tmp_addflag= ;; 4827 - nvcc*) # Cuda Compiler Driver 2.2 4828 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' 4829 - _LT_TAGVAR(compiler_needs_object, $1)=yes 4830 - ;; 4831 - esac 4832 - case `$CC -V 2>&1 | sed 5q` in 4833 - *Sun\ C*) # Sun C 5.9 4834 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' 4835 - _LT_TAGVAR(compiler_needs_object, $1)=yes 4836 - tmp_sharedflag='-G' ;; 4837 - *Sun\ F*) # Sun Fortran 8.3 4838 - tmp_sharedflag='-G' ;; 4839 - esac 4840 - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 4841 - 4842 - if test "x$supports_anon_versioning" = xyes; then 4843 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ 4844 - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ 4845 - echo "local: *; };" >> $output_objdir/$libname.ver~ 4846 - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' 4847 - fi 4848 - 4849 - case $cc_basename in 4850 - xlf* | bgf* | bgxlf* | mpixlf*) 4851 - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself 4852 - _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' 4853 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 4854 - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' 4855 - if test "x$supports_anon_versioning" = xyes; then 4856 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ 4857 - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ 4858 - echo "local: *; };" >> $output_objdir/$libname.ver~ 4859 - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' 4860 - fi 4861 - ;; 4862 - esac 4863 - else 4864 - _LT_TAGVAR(ld_shlibs, $1)=no 4865 - fi 4866 - ;; 4867 - 4868 - netbsd*) 4869 - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then 4870 - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' 4871 - wlarc= 4872 - else 4873 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 4874 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' 4875 - fi 4876 - ;; 4877 - 4878 - solaris*) 4879 - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then 4880 - _LT_TAGVAR(ld_shlibs, $1)=no 4881 - cat <<_LT_EOF 1>&2 4882 - 4883 -*** Warning: The releases 2.8.* of the GNU linker cannot reliably 4884 -*** create shared libraries on Solaris systems. Therefore, libtool 4885 -*** is disabling shared libraries support. We urge you to upgrade GNU 4886 -*** binutils to release 2.9.1 or newer. Another option is to modify 4887 -*** your PATH or compiler configuration so that the native linker is 4888 -*** used, and then restart. 4889 - 4890 -_LT_EOF 4891 - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then 4892 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 4893 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' 4894 - else 4895 - _LT_TAGVAR(ld_shlibs, $1)=no 4896 - fi 4897 - ;; 4898 - 4899 - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) 4900 - case `$LD -v 2>&1` in 4901 - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) 4902 - _LT_TAGVAR(ld_shlibs, $1)=no 4903 - cat <<_LT_EOF 1>&2 4904 - 4905 -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not 4906 -*** reliably create shared libraries on SCO systems. Therefore, libtool 4907 -*** is disabling shared libraries support. We urge you to upgrade GNU 4908 -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify 4909 -*** your PATH or compiler configuration so that the native linker is 4910 -*** used, and then restart. 4911 - 4912 -_LT_EOF 4913 - ;; 4914 - *) 4915 - # For security reasons, it is highly recommended that you always 4916 - # use absolute paths for naming shared libraries, and exclude the 4917 - # DT_RUNPATH tag from executables and libraries. But doing so 4918 - # requires that you compile everything twice, which is a pain. 4919 - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then 4920 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 4921 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 4922 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' 4923 - else 4924 - _LT_TAGVAR(ld_shlibs, $1)=no 4925 - fi 4926 - ;; 4927 - esac 4928 - ;; 4929 - 4930 - sunos4*) 4931 - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' 4932 - wlarc= 4933 - _LT_TAGVAR(hardcode_direct, $1)=yes 4934 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 4935 - ;; 4936 - 4937 - *) 4938 - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then 4939 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 4940 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' 4941 - else 4942 - _LT_TAGVAR(ld_shlibs, $1)=no 4943 - fi 4944 - ;; 4945 - esac 4946 - 4947 - if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then 4948 - runpath_var= 4949 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= 4950 - _LT_TAGVAR(export_dynamic_flag_spec, $1)= 4951 - _LT_TAGVAR(whole_archive_flag_spec, $1)= 4952 - fi 4953 - else 4954 - # PORTME fill in a description of your system's linker (not GNU ld) 4955 - case $host_os in 4956 - aix3*) 4957 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 4958 - _LT_TAGVAR(always_export_symbols, $1)=yes 4959 - _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' 4960 - # Note: this linker hardcodes the directories in LIBPATH if there 4961 - # are no directories specified by -L. 4962 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 4963 - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then 4964 - # Neither direct hardcoding nor static linking is supported with a 4965 - # broken collect2. 4966 - _LT_TAGVAR(hardcode_direct, $1)=unsupported 4967 - fi 4968 - ;; 4969 - 4970 - aix[[4-9]]*) 4971 - if test "$host_cpu" = ia64; then 4972 - # On IA64, the linker does run time linking by default, so we don't 4973 - # have to do anything special. 4974 - aix_use_runtimelinking=no 4975 - exp_sym_flag='-Bexport' 4976 - no_entry_flag="" 4977 - else 4978 - # If we're using GNU nm, then we don't want the "-C" option. 4979 - # -C means demangle to AIX nm, but means don't demangle with GNU nm 4980 - # Also, AIX nm treats weak defined symbols like other global 4981 - # defined symbols, whereas GNU nm marks them as "W". 4982 - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then 4983 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' 4984 - else 4985 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' 4986 - fi 4987 - aix_use_runtimelinking=no 4988 - 4989 - # Test if we are trying to use run time linking or normal 4990 - # AIX style linking. If -brtl is somewhere in LDFLAGS, we 4991 - # need to do runtime linking. 4992 - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) 4993 - for ld_flag in $LDFLAGS; do 4994 - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then 4995 - aix_use_runtimelinking=yes 4996 - break 4997 - fi 4998 - done 4999 - ;; 5000 - esac 5001 - 5002 - exp_sym_flag='-bexport' 5003 - no_entry_flag='-bnoentry' 5004 - fi 5005 - 5006 - # When large executables or shared objects are built, AIX ld can 5007 - # have problems creating the table of contents. If linking a library 5008 - # or program results in "error TOC overflow" add -mminimal-toc to 5009 - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not 5010 - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. 5011 - 5012 - _LT_TAGVAR(archive_cmds, $1)='' 5013 - _LT_TAGVAR(hardcode_direct, $1)=yes 5014 - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes 5015 - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' 5016 - _LT_TAGVAR(link_all_deplibs, $1)=yes 5017 - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' 5018 - 5019 - if test "$GCC" = yes; then 5020 - case $host_os in aix4.[[012]]|aix4.[[012]].*) 5021 - # We only want to do this on AIX 4.2 and lower, the check 5022 - # below for broken collect2 doesn't work under 4.3+ 5023 - collect2name=`${CC} -print-prog-name=collect2` 5024 - if test -f "$collect2name" && 5025 - strings "$collect2name" | $GREP resolve_lib_name >/dev/null 5026 - then 5027 - # We have reworked collect2 5028 - : 5029 - else 5030 - # We have old collect2 5031 - _LT_TAGVAR(hardcode_direct, $1)=unsupported 5032 - # It fails to find uninstalled libraries when the uninstalled 5033 - # path is not listed in the libpath. Setting hardcode_minus_L 5034 - # to unsupported forces relinking 5035 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 5036 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 5037 - _LT_TAGVAR(hardcode_libdir_separator, $1)= 5038 - fi 5039 - ;; 5040 - esac 5041 - shared_flag='-shared' 5042 - if test "$aix_use_runtimelinking" = yes; then 5043 - shared_flag="$shared_flag "'${wl}-G' 5044 - fi 5045 - else 5046 - # not using gcc 5047 - if test "$host_cpu" = ia64; then 5048 - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release 5049 - # chokes on -Wl,-G. The following line is correct: 5050 - shared_flag='-G' 5051 - else 5052 - if test "$aix_use_runtimelinking" = yes; then 5053 - shared_flag='${wl}-G' 5054 - else 5055 - shared_flag='${wl}-bM:SRE' 5056 - fi 5057 - fi 5058 - fi 5059 - 5060 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' 5061 - # It seems that -bexpall does not export symbols beginning with 5062 - # underscore (_), so it is better to generate a list of symbols to export. 5063 - _LT_TAGVAR(always_export_symbols, $1)=yes 5064 - if test "$aix_use_runtimelinking" = yes; then 5065 - # Warning - without using the other runtime loading flags (-brtl), 5066 - # -berok will link without error, but may produce a broken library. 5067 - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' 5068 - # Determine the default libpath from the value encoded in an 5069 - # empty executable. 5070 - _LT_SYS_MODULE_PATH_AIX([$1]) 5071 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" 5072 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" 5073 - else 5074 - if test "$host_cpu" = ia64; then 5075 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' 5076 - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" 5077 - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" 5078 - else 5079 - # Determine the default libpath from the value encoded in an 5080 - # empty executable. 5081 - _LT_SYS_MODULE_PATH_AIX([$1]) 5082 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" 5083 - # Warning - without using the other run time loading flags, 5084 - # -berok will link without error, but may produce a broken library. 5085 - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' 5086 - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' 5087 - if test "$with_gnu_ld" = yes; then 5088 - # We only use this code for GNU lds that support --whole-archive. 5089 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' 5090 - else 5091 - # Exported symbols can be pulled into shared objects from archives 5092 - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' 5093 - fi 5094 - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes 5095 - # This is similar to how AIX traditionally builds its shared libraries. 5096 - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' 5097 - fi 5098 - fi 5099 - ;; 5100 - 5101 - amigaos*) 5102 - case $host_cpu in 5103 - powerpc) 5104 - # see comment about AmigaOS4 .so support 5105 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 5106 - _LT_TAGVAR(archive_expsym_cmds, $1)='' 5107 - ;; 5108 - m68k) 5109 - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' 5110 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 5111 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 5112 - ;; 5113 - esac 5114 - ;; 5115 - 5116 - bsdi[[45]]*) 5117 - _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic 5118 - ;; 5119 - 5120 - cygwin* | mingw* | pw32* | cegcc*) 5121 - # When not using gcc, we currently assume that we are using 5122 - # Microsoft Visual C++. 5123 - # hardcode_libdir_flag_spec is actually meaningless, as there is 5124 - # no search path for DLLs. 5125 - case $cc_basename in 5126 - cl*) 5127 - # Native MSVC 5128 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' 5129 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 5130 - _LT_TAGVAR(always_export_symbols, $1)=yes 5131 - _LT_TAGVAR(file_list_spec, $1)='@' 5132 - # Tell ltmain to make .lib files, not .a files. 5133 - libext=lib 5134 - # Tell ltmain to make .dll files, not .so files. 5135 - shrext_cmds=".dll" 5136 - # FIXME: Setting linknames here is a bad hack. 5137 - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' 5138 - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then 5139 - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; 5140 - else 5141 - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; 5142 - fi~ 5143 - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ 5144 - linknames=' 5145 - # The linker will not automatically build a static lib if we build a DLL. 5146 - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' 5147 - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes 5148 - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' 5149 - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' 5150 - # Don't use ranlib 5151 - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' 5152 - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ 5153 - lt_tool_outputfile="@TOOL_OUTPUT@"~ 5154 - case $lt_outputfile in 5155 - *.exe|*.EXE) ;; 5156 - *) 5157 - lt_outputfile="$lt_outputfile.exe" 5158 - lt_tool_outputfile="$lt_tool_outputfile.exe" 5159 - ;; 5160 - esac~ 5161 - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then 5162 - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; 5163 - $RM "$lt_outputfile.manifest"; 5164 - fi' 5165 - ;; 5166 - *) 5167 - # Assume MSVC wrapper 5168 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' 5169 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 5170 - # Tell ltmain to make .lib files, not .a files. 5171 - libext=lib 5172 - # Tell ltmain to make .dll files, not .so files. 5173 - shrext_cmds=".dll" 5174 - # FIXME: Setting linknames here is a bad hack. 5175 - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' 5176 - # The linker will automatically build a .lib file if we build a DLL. 5177 - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' 5178 - # FIXME: Should let the user specify the lib program. 5179 - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' 5180 - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes 5181 - ;; 5182 - esac 5183 - ;; 5184 - 5185 - darwin* | rhapsody*) 5186 - _LT_DARWIN_LINKER_FEATURES($1) 5187 - ;; 5188 - 5189 - dgux*) 5190 - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' 5191 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 5192 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5193 - ;; 5194 - 5195 - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor 5196 - # support. Future versions do this automatically, but an explicit c++rt0.o 5197 - # does not break anything, and helps significantly (at the cost of a little 5198 - # extra space). 5199 - freebsd2.2*) 5200 - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' 5201 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' 5202 - _LT_TAGVAR(hardcode_direct, $1)=yes 5203 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5204 - ;; 5205 - 5206 - # Unfortunately, older versions of FreeBSD 2 do not have this feature. 5207 - freebsd2.*) 5208 - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' 5209 - _LT_TAGVAR(hardcode_direct, $1)=yes 5210 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 5211 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5212 - ;; 5213 - 5214 - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. 5215 - freebsd* | dragonfly*) 5216 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' 5217 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' 5218 - _LT_TAGVAR(hardcode_direct, $1)=yes 5219 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5220 - ;; 5221 - 5222 - hpux9*) 5223 - if test "$GCC" = yes; then 5224 - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' 5225 - else 5226 - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' 5227 - fi 5228 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' 5229 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 5230 - _LT_TAGVAR(hardcode_direct, $1)=yes 5231 - 5232 - # hardcode_minus_L: Not really in the search PATH, 5233 - # but as the default location of the library. 5234 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 5235 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 5236 - ;; 5237 - 5238 - hpux10*) 5239 - if test "$GCC" = yes && test "$with_gnu_ld" = no; then 5240 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' 5241 - else 5242 - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' 5243 - fi 5244 - if test "$with_gnu_ld" = no; then 5245 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' 5246 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 5247 - _LT_TAGVAR(hardcode_direct, $1)=yes 5248 - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes 5249 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 5250 - # hardcode_minus_L: Not really in the search PATH, 5251 - # but as the default location of the library. 5252 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 5253 - fi 5254 - ;; 5255 - 5256 - hpux11*) 5257 - if test "$GCC" = yes && test "$with_gnu_ld" = no; then 5258 - case $host_cpu in 5259 - hppa*64*) 5260 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' 5261 - ;; 5262 - ia64*) 5263 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' 5264 - ;; 5265 - *) 5266 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' 5267 - ;; 5268 - esac 5269 - else 5270 - case $host_cpu in 5271 - hppa*64*) 5272 - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' 5273 - ;; 5274 - ia64*) 5275 - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' 5276 - ;; 5277 - *) 5278 - m4_if($1, [], [ 5279 - # Older versions of the 11.00 compiler do not understand -b yet 5280 - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) 5281 - _LT_LINKER_OPTION([if $CC understands -b], 5282 - _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], 5283 - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], 5284 - [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], 5285 - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) 5286 - ;; 5287 - esac 5288 - fi 5289 - if test "$with_gnu_ld" = no; then 5290 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' 5291 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 5292 - 5293 - case $host_cpu in 5294 - hppa*64*|ia64*) 5295 - _LT_TAGVAR(hardcode_direct, $1)=no 5296 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5297 - ;; 5298 - *) 5299 - _LT_TAGVAR(hardcode_direct, $1)=yes 5300 - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes 5301 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 5302 - 5303 - # hardcode_minus_L: Not really in the search PATH, 5304 - # but as the default location of the library. 5305 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 5306 - ;; 5307 - esac 5308 - fi 5309 - ;; 5310 - 5311 - irix5* | irix6* | nonstopux*) 5312 - if test "$GCC" = yes; then 5313 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' 5314 - # Try to use the -exported_symbol ld option, if it does not 5315 - # work, assume that -exports_file does not work either and 5316 - # implicitly export all symbols. 5317 - # This should be the same for all languages, so no per-tag cache variable. 5318 - AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], 5319 - [lt_cv_irix_exported_symbol], 5320 - [save_LDFLAGS="$LDFLAGS" 5321 - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" 5322 - AC_LINK_IFELSE( 5323 - [AC_LANG_SOURCE( 5324 - [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], 5325 - [C++], [[int foo (void) { return 0; }]], 5326 - [Fortran 77], [[ 5327 - subroutine foo 5328 - end]], 5329 - [Fortran], [[ 5330 - subroutine foo 5331 - end]])])], 5332 - [lt_cv_irix_exported_symbol=yes], 5333 - [lt_cv_irix_exported_symbol=no]) 5334 - LDFLAGS="$save_LDFLAGS"]) 5335 - if test "$lt_cv_irix_exported_symbol" = yes; then 5336 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' 5337 - fi 5338 - else 5339 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' 5340 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' 5341 - fi 5342 - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' 5343 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 5344 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 5345 - _LT_TAGVAR(inherit_rpath, $1)=yes 5346 - _LT_TAGVAR(link_all_deplibs, $1)=yes 5347 - ;; 5348 - 5349 - netbsd*) 5350 - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then 5351 - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out 5352 - else 5353 - _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF 5354 - fi 5355 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' 5356 - _LT_TAGVAR(hardcode_direct, $1)=yes 5357 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5358 - ;; 5359 - 5360 - newsos6) 5361 - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' 5362 - _LT_TAGVAR(hardcode_direct, $1)=yes 5363 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 5364 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 5365 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5366 - ;; 5367 - 5368 - *nto* | *qnx*) 5369 - ;; 5370 - 5371 - openbsd*) 5372 - if test -f /usr/libexec/ld.so; then 5373 - _LT_TAGVAR(hardcode_direct, $1)=yes 5374 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5375 - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes 5376 - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then 5377 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' 5378 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' 5379 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' 5380 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 5381 - else 5382 - case $host_os in 5383 - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) 5384 - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' 5385 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' 5386 - ;; 5387 - *) 5388 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' 5389 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' 5390 - ;; 5391 - esac 5392 - fi 5393 - else 5394 - _LT_TAGVAR(ld_shlibs, $1)=no 5395 - fi 5396 - ;; 5397 - 5398 - os2*) 5399 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 5400 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 5401 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 5402 - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' 5403 - _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' 5404 - ;; 5405 - 5406 - osf3*) 5407 - if test "$GCC" = yes; then 5408 - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' 5409 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' 5410 - else 5411 - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' 5412 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' 5413 - fi 5414 - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' 5415 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 5416 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 5417 - ;; 5418 - 5419 - osf4* | osf5*) # as osf3* with the addition of -msym flag 5420 - if test "$GCC" = yes; then 5421 - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' 5422 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' 5423 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 5424 - else 5425 - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' 5426 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' 5427 - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ 5428 - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' 5429 - 5430 - # Both c and cxx compiler support -rpath directly 5431 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' 5432 - fi 5433 - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' 5434 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 5435 - ;; 5436 - 5437 - solaris*) 5438 - _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' 5439 - if test "$GCC" = yes; then 5440 - wlarc='${wl}' 5441 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' 5442 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ 5443 - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' 5444 - else 5445 - case `$CC -V 2>&1` in 5446 - *"Compilers 5.0"*) 5447 - wlarc='' 5448 - _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' 5449 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ 5450 - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' 5451 - ;; 5452 - *) 5453 - wlarc='${wl}' 5454 - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' 5455 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ 5456 - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' 5457 - ;; 5458 - esac 5459 - fi 5460 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' 5461 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5462 - case $host_os in 5463 - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; 5464 - *) 5465 - # The compiler driver will combine and reorder linker options, 5466 - # but understands `-z linker_flag'. GCC discards it without `$wl', 5467 - # but is careful enough not to reorder. 5468 - # Supported since Solaris 2.6 (maybe 2.5.1?) 5469 - if test "$GCC" = yes; then 5470 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' 5471 - else 5472 - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' 5473 - fi 5474 - ;; 5475 - esac 5476 - _LT_TAGVAR(link_all_deplibs, $1)=yes 5477 - ;; 5478 - 5479 - sunos4*) 5480 - if test "x$host_vendor" = xsequent; then 5481 - # Use $CC to link under sequent, because it throws in some extra .o 5482 - # files that make .init and .fini sections work. 5483 - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' 5484 - else 5485 - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' 5486 - fi 5487 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 5488 - _LT_TAGVAR(hardcode_direct, $1)=yes 5489 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 5490 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5491 - ;; 5492 - 5493 - sysv4) 5494 - case $host_vendor in 5495 - sni) 5496 - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' 5497 - _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? 5498 - ;; 5499 - siemens) 5500 - ## LD is ld it makes a PLAMLIB 5501 - ## CC just makes a GrossModule. 5502 - _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' 5503 - _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' 5504 - _LT_TAGVAR(hardcode_direct, $1)=no 5505 - ;; 5506 - motorola) 5507 - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' 5508 - _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie 5509 - ;; 5510 - esac 5511 - runpath_var='LD_RUN_PATH' 5512 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5513 - ;; 5514 - 5515 - sysv4.3*) 5516 - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' 5517 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5518 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' 5519 - ;; 5520 - 5521 - sysv4*MP*) 5522 - if test -d /usr/nec; then 5523 - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' 5524 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5525 - runpath_var=LD_RUN_PATH 5526 - hardcode_runpath_var=yes 5527 - _LT_TAGVAR(ld_shlibs, $1)=yes 5528 - fi 5529 - ;; 5530 - 5531 - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) 5532 - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' 5533 - _LT_TAGVAR(archive_cmds_need_lc, $1)=no 5534 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5535 - runpath_var='LD_RUN_PATH' 5536 - 5537 - if test "$GCC" = yes; then 5538 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 5539 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 5540 - else 5541 - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 5542 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 5543 - fi 5544 - ;; 5545 - 5546 - sysv5* | sco3.2v5* | sco5v6*) 5547 - # Note: We can NOT use -z defs as we might desire, because we do not 5548 - # link with -lc, and that would cause any symbols used from libc to 5549 - # always be unresolved, which means just about no library would 5550 - # ever link correctly. If we're not using GNU ld we use -z text 5551 - # though, which does catch some bad symbols but isn't as heavy-handed 5552 - # as -z defs. 5553 - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' 5554 - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' 5555 - _LT_TAGVAR(archive_cmds_need_lc, $1)=no 5556 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5557 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' 5558 - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' 5559 - _LT_TAGVAR(link_all_deplibs, $1)=yes 5560 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' 5561 - runpath_var='LD_RUN_PATH' 5562 - 5563 - if test "$GCC" = yes; then 5564 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 5565 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 5566 - else 5567 - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 5568 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 5569 - fi 5570 - ;; 5571 - 5572 - uts4*) 5573 - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' 5574 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 5575 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 5576 - ;; 5577 - 5578 - *) 5579 - _LT_TAGVAR(ld_shlibs, $1)=no 5580 - ;; 5581 - esac 5582 - 5583 - if test x$host_vendor = xsni; then 5584 - case $host in 5585 - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) 5586 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' 5587 - ;; 5588 - esac 5589 - fi 5590 - fi 5591 -]) 5592 -AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) 5593 -test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no 5594 - 5595 -_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld 5596 - 5597 -_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl 5598 -_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl 5599 -_LT_DECL([], [extract_expsyms_cmds], [2], 5600 - [The commands to extract the exported symbol list from a shared archive]) 5601 - 5602 -# 5603 -# Do we need to explicitly link libc? 5604 -# 5605 -case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in 5606 -x|xyes) 5607 - # Assume -lc should be added 5608 - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes 5609 - 5610 - if test "$enable_shared" = yes && test "$GCC" = yes; then 5611 - case $_LT_TAGVAR(archive_cmds, $1) in 5612 - *'~'*) 5613 - # FIXME: we may have to deal with multi-command sequences. 5614 - ;; 5615 - '$CC '*) 5616 - # Test whether the compiler implicitly links with -lc since on some 5617 - # systems, -lgcc has to come before -lc. If gcc already passes -lc 5618 - # to ld, don't add -lc before -lgcc. 5619 - AC_CACHE_CHECK([whether -lc should be explicitly linked in], 5620 - [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), 5621 - [$RM conftest* 5622 - echo "$lt_simple_compile_test_code" > conftest.$ac_ext 5623 - 5624 - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then 5625 - soname=conftest 5626 - lib=conftest 5627 - libobjs=conftest.$ac_objext 5628 - deplibs= 5629 - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) 5630 - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) 5631 - compiler_flags=-v 5632 - linker_flags=-v 5633 - verstring= 5634 - output_objdir=. 5635 - libname=conftest 5636 - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) 5637 - _LT_TAGVAR(allow_undefined_flag, $1)= 5638 - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 5639 - then 5640 - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no 5641 - else 5642 - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes 5643 - fi 5644 - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag 5645 - else 5646 - cat conftest.err 1>&5 5647 - fi 5648 - $RM conftest* 5649 - ]) 5650 - _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) 5651 - ;; 5652 - esac 5653 - fi 5654 - ;; 5655 -esac 5656 - 5657 -_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], 5658 - [Whether or not to add -lc for building shared libraries]) 5659 -_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], 5660 - [enable_shared_with_static_runtimes], [0], 5661 - [Whether or not to disallow shared libs when runtime libs are static]) 5662 -_LT_TAGDECL([], [export_dynamic_flag_spec], [1], 5663 - [Compiler flag to allow reflexive dlopens]) 5664 -_LT_TAGDECL([], [whole_archive_flag_spec], [1], 5665 - [Compiler flag to generate shared objects directly from archives]) 5666 -_LT_TAGDECL([], [compiler_needs_object], [1], 5667 - [Whether the compiler copes with passing no objects directly]) 5668 -_LT_TAGDECL([], [old_archive_from_new_cmds], [2], 5669 - [Create an old-style archive from a shared archive]) 5670 -_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], 5671 - [Create a temporary old-style archive to link instead of a shared archive]) 5672 -_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) 5673 -_LT_TAGDECL([], [archive_expsym_cmds], [2]) 5674 -_LT_TAGDECL([], [module_cmds], [2], 5675 - [Commands used to build a loadable module if different from building 5676 - a shared archive.]) 5677 -_LT_TAGDECL([], [module_expsym_cmds], [2]) 5678 -_LT_TAGDECL([], [with_gnu_ld], [1], 5679 - [Whether we are building with GNU ld or not]) 5680 -_LT_TAGDECL([], [allow_undefined_flag], [1], 5681 - [Flag that allows shared libraries with undefined symbols to be built]) 5682 -_LT_TAGDECL([], [no_undefined_flag], [1], 5683 - [Flag that enforces no undefined symbols]) 5684 -_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], 5685 - [Flag to hardcode $libdir into a binary during linking. 5686 - This must work even if $libdir does not exist]) 5687 -_LT_TAGDECL([], [hardcode_libdir_separator], [1], 5688 - [Whether we need a single "-rpath" flag with a separated argument]) 5689 -_LT_TAGDECL([], [hardcode_direct], [0], 5690 - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes 5691 - DIR into the resulting binary]) 5692 -_LT_TAGDECL([], [hardcode_direct_absolute], [0], 5693 - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes 5694 - DIR into the resulting binary and the resulting library dependency is 5695 - "absolute", i.e impossible to change by setting ${shlibpath_var} if the 5696 - library is relocated]) 5697 -_LT_TAGDECL([], [hardcode_minus_L], [0], 5698 - [Set to "yes" if using the -LDIR flag during linking hardcodes DIR 5699 - into the resulting binary]) 5700 -_LT_TAGDECL([], [hardcode_shlibpath_var], [0], 5701 - [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR 5702 - into the resulting binary]) 5703 -_LT_TAGDECL([], [hardcode_automatic], [0], 5704 - [Set to "yes" if building a shared library automatically hardcodes DIR 5705 - into the library and all subsequent libraries and executables linked 5706 - against it]) 5707 -_LT_TAGDECL([], [inherit_rpath], [0], 5708 - [Set to yes if linker adds runtime paths of dependent libraries 5709 - to runtime path list]) 5710 -_LT_TAGDECL([], [link_all_deplibs], [0], 5711 - [Whether libtool must link a program against all its dependency libraries]) 5712 -_LT_TAGDECL([], [always_export_symbols], [0], 5713 - [Set to "yes" if exported symbols are required]) 5714 -_LT_TAGDECL([], [export_symbols_cmds], [2], 5715 - [The commands to list exported symbols]) 5716 -_LT_TAGDECL([], [exclude_expsyms], [1], 5717 - [Symbols that should not be listed in the preloaded symbols]) 5718 -_LT_TAGDECL([], [include_expsyms], [1], 5719 - [Symbols that must always be exported]) 5720 -_LT_TAGDECL([], [prelink_cmds], [2], 5721 - [Commands necessary for linking programs (against libraries) with templates]) 5722 -_LT_TAGDECL([], [postlink_cmds], [2], 5723 - [Commands necessary for finishing linking programs]) 5724 -_LT_TAGDECL([], [file_list_spec], [1], 5725 - [Specify filename containing input files]) 5726 -dnl FIXME: Not yet implemented 5727 -dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], 5728 -dnl [Compiler flag to generate thread safe objects]) 5729 -])# _LT_LINKER_SHLIBS 5730 - 5731 - 5732 -# _LT_LANG_C_CONFIG([TAG]) 5733 -# ------------------------ 5734 -# Ensure that the configuration variables for a C compiler are suitably 5735 -# defined. These variables are subsequently used by _LT_CONFIG to write 5736 -# the compiler configuration to `libtool'. 5737 -m4_defun([_LT_LANG_C_CONFIG], 5738 -[m4_require([_LT_DECL_EGREP])dnl 5739 -lt_save_CC="$CC" 5740 -AC_LANG_PUSH(C) 5741 - 5742 -# Source file extension for C test sources. 5743 -ac_ext=c 5744 - 5745 -# Object file extension for compiled C test sources. 5746 -objext=o 5747 -_LT_TAGVAR(objext, $1)=$objext 5748 - 5749 -# Code to be used in simple compile tests 5750 -lt_simple_compile_test_code="int some_variable = 0;" 5751 - 5752 -# Code to be used in simple link tests 5753 -lt_simple_link_test_code='int main(){return(0);}' 5754 - 5755 -_LT_TAG_COMPILER 5756 -# Save the default compiler, since it gets overwritten when the other 5757 -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. 5758 -compiler_DEFAULT=$CC 5759 - 5760 -# save warnings/boilerplate of simple test code 5761 -_LT_COMPILER_BOILERPLATE 5762 -_LT_LINKER_BOILERPLATE 5763 - 5764 -## CAVEAT EMPTOR: 5765 -## There is no encapsulation within the following macros, do not change 5766 -## the running order or otherwise move them around unless you know exactly 5767 -## what you are doing... 5768 -if test -n "$compiler"; then 5769 - _LT_COMPILER_NO_RTTI($1) 5770 - _LT_COMPILER_PIC($1) 5771 - _LT_COMPILER_C_O($1) 5772 - _LT_COMPILER_FILE_LOCKS($1) 5773 - _LT_LINKER_SHLIBS($1) 5774 - _LT_SYS_DYNAMIC_LINKER($1) 5775 - _LT_LINKER_HARDCODE_LIBPATH($1) 5776 - LT_SYS_DLOPEN_SELF 5777 - _LT_CMD_STRIPLIB 5778 - 5779 - # Report which library types will actually be built 5780 - AC_MSG_CHECKING([if libtool supports shared libraries]) 5781 - AC_MSG_RESULT([$can_build_shared]) 5782 - 5783 - AC_MSG_CHECKING([whether to build shared libraries]) 5784 - test "$can_build_shared" = "no" && enable_shared=no 5785 - 5786 - # On AIX, shared libraries and static libraries use the same namespace, and 5787 - # are all built from PIC. 5788 - case $host_os in 5789 - aix3*) 5790 - test "$enable_shared" = yes && enable_static=no 5791 - if test -n "$RANLIB"; then 5792 - archive_cmds="$archive_cmds~\$RANLIB \$lib" 5793 - postinstall_cmds='$RANLIB $lib' 5794 - fi 5795 - ;; 5796 - 5797 - aix[[4-9]]*) 5798 - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then 5799 - test "$enable_shared" = yes && enable_static=no 5800 - fi 5801 - ;; 5802 - esac 5803 - AC_MSG_RESULT([$enable_shared]) 5804 - 5805 - AC_MSG_CHECKING([whether to build static libraries]) 5806 - # Make sure either enable_shared or enable_static is yes. 5807 - test "$enable_shared" = yes || enable_static=yes 5808 - AC_MSG_RESULT([$enable_static]) 5809 - 5810 - _LT_CONFIG($1) 5811 -fi 5812 -AC_LANG_POP 5813 -CC="$lt_save_CC" 5814 -])# _LT_LANG_C_CONFIG 5815 - 5816 - 5817 -# _LT_LANG_CXX_CONFIG([TAG]) 5818 -# -------------------------- 5819 -# Ensure that the configuration variables for a C++ compiler are suitably 5820 -# defined. These variables are subsequently used by _LT_CONFIG to write 5821 -# the compiler configuration to `libtool'. 5822 -m4_defun([_LT_LANG_CXX_CONFIG], 5823 -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl 5824 -m4_require([_LT_DECL_EGREP])dnl 5825 -m4_require([_LT_PATH_MANIFEST_TOOL])dnl 5826 -if test -n "$CXX" && ( test "X$CXX" != "Xno" && 5827 - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || 5828 - (test "X$CXX" != "Xg++"))) ; then 5829 - AC_PROG_CXXCPP 5830 -else 5831 - _lt_caught_CXX_error=yes 5832 -fi 5833 - 5834 -AC_LANG_PUSH(C++) 5835 -_LT_TAGVAR(archive_cmds_need_lc, $1)=no 5836 -_LT_TAGVAR(allow_undefined_flag, $1)= 5837 -_LT_TAGVAR(always_export_symbols, $1)=no 5838 -_LT_TAGVAR(archive_expsym_cmds, $1)= 5839 -_LT_TAGVAR(compiler_needs_object, $1)=no 5840 -_LT_TAGVAR(export_dynamic_flag_spec, $1)= 5841 -_LT_TAGVAR(hardcode_direct, $1)=no 5842 -_LT_TAGVAR(hardcode_direct_absolute, $1)=no 5843 -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= 5844 -_LT_TAGVAR(hardcode_libdir_separator, $1)= 5845 -_LT_TAGVAR(hardcode_minus_L, $1)=no 5846 -_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported 5847 -_LT_TAGVAR(hardcode_automatic, $1)=no 5848 -_LT_TAGVAR(inherit_rpath, $1)=no 5849 -_LT_TAGVAR(module_cmds, $1)= 5850 -_LT_TAGVAR(module_expsym_cmds, $1)= 5851 -_LT_TAGVAR(link_all_deplibs, $1)=unknown 5852 -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds 5853 -_LT_TAGVAR(reload_flag, $1)=$reload_flag 5854 -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds 5855 -_LT_TAGVAR(no_undefined_flag, $1)= 5856 -_LT_TAGVAR(whole_archive_flag_spec, $1)= 5857 -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no 5858 - 5859 -# Source file extension for C++ test sources. 5860 -ac_ext=cpp 5861 - 5862 -# Object file extension for compiled C++ test sources. 5863 -objext=o 5864 -_LT_TAGVAR(objext, $1)=$objext 5865 - 5866 -# No sense in running all these tests if we already determined that 5867 -# the CXX compiler isn't working. Some variables (like enable_shared) 5868 -# are currently assumed to apply to all compilers on this platform, 5869 -# and will be corrupted by setting them based on a non-working compiler. 5870 -if test "$_lt_caught_CXX_error" != yes; then 5871 - # Code to be used in simple compile tests 5872 - lt_simple_compile_test_code="int some_variable = 0;" 5873 - 5874 - # Code to be used in simple link tests 5875 - lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' 5876 - 5877 - # ltmain only uses $CC for tagged configurations so make sure $CC is set. 5878 - _LT_TAG_COMPILER 5879 - 5880 - # save warnings/boilerplate of simple test code 5881 - _LT_COMPILER_BOILERPLATE 5882 - _LT_LINKER_BOILERPLATE 5883 - 5884 - # Allow CC to be a program name with arguments. 5885 - lt_save_CC=$CC 5886 - lt_save_CFLAGS=$CFLAGS 5887 - lt_save_LD=$LD 5888 - lt_save_GCC=$GCC 5889 - GCC=$GXX 5890 - lt_save_with_gnu_ld=$with_gnu_ld 5891 - lt_save_path_LD=$lt_cv_path_LD 5892 - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then 5893 - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx 5894 - else 5895 - $as_unset lt_cv_prog_gnu_ld 5896 - fi 5897 - if test -n "${lt_cv_path_LDCXX+set}"; then 5898 - lt_cv_path_LD=$lt_cv_path_LDCXX 5899 - else 5900 - $as_unset lt_cv_path_LD 5901 - fi 5902 - test -z "${LDCXX+set}" || LD=$LDCXX 5903 - CC=${CXX-"c++"} 5904 - CFLAGS=$CXXFLAGS 5905 - compiler=$CC 5906 - _LT_TAGVAR(compiler, $1)=$CC 5907 - _LT_CC_BASENAME([$compiler]) 5908 - 5909 - if test -n "$compiler"; then 5910 - # We don't want -fno-exception when compiling C++ code, so set the 5911 - # no_builtin_flag separately 5912 - if test "$GXX" = yes; then 5913 - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' 5914 - else 5915 - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= 5916 - fi 5917 - 5918 - if test "$GXX" = yes; then 5919 - # Set up default GNU C++ configuration 5920 - 5921 - LT_PATH_LD 5922 - 5923 - # Check if GNU C++ uses GNU ld as the underlying linker, since the 5924 - # archiving commands below assume that GNU ld is being used. 5925 - if test "$with_gnu_ld" = yes; then 5926 - _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' 5927 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' 5928 - 5929 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 5930 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' 5931 - 5932 - # If archive_cmds runs LD, not CC, wlarc should be empty 5933 - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to 5934 - # investigate it a little bit more. (MM) 5935 - wlarc='${wl}' 5936 - 5937 - # ancient GNU ld didn't support --whole-archive et. al. 5938 - if eval "`$CC -print-prog-name=ld` --help 2>&1" | 5939 - $GREP 'no-whole-archive' > /dev/null; then 5940 - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' 5941 - else 5942 - _LT_TAGVAR(whole_archive_flag_spec, $1)= 5943 - fi 5944 - else 5945 - with_gnu_ld=no 5946 - wlarc= 5947 - 5948 - # A generic and very simple default shared library creation 5949 - # command for GNU C++ for the case where it uses the native 5950 - # linker, instead of GNU ld. If possible, this setting should 5951 - # overridden to take advantage of the native linker features on 5952 - # the platform it is being used on. 5953 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' 5954 - fi 5955 - 5956 - # Commands to make compiler produce verbose output that lists 5957 - # what "hidden" libraries, object files and flags are used when 5958 - # linking a shared library. 5959 - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' 5960 - 5961 - else 5962 - GXX=no 5963 - with_gnu_ld=no 5964 - wlarc= 5965 - fi 5966 - 5967 - # PORTME: fill in a description of your system's C++ link characteristics 5968 - AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) 5969 - _LT_TAGVAR(ld_shlibs, $1)=yes 5970 - case $host_os in 5971 - aix3*) 5972 - # FIXME: insert proper C++ library support 5973 - _LT_TAGVAR(ld_shlibs, $1)=no 5974 - ;; 5975 - aix[[4-9]]*) 5976 - if test "$host_cpu" = ia64; then 5977 - # On IA64, the linker does run time linking by default, so we don't 5978 - # have to do anything special. 5979 - aix_use_runtimelinking=no 5980 - exp_sym_flag='-Bexport' 5981 - no_entry_flag="" 5982 - else 5983 - aix_use_runtimelinking=no 5984 - 5985 - # Test if we are trying to use run time linking or normal 5986 - # AIX style linking. If -brtl is somewhere in LDFLAGS, we 5987 - # need to do runtime linking. 5988 - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) 5989 - for ld_flag in $LDFLAGS; do 5990 - case $ld_flag in 5991 - *-brtl*) 5992 - aix_use_runtimelinking=yes 5993 - break 5994 - ;; 5995 - esac 5996 - done 5997 - ;; 5998 - esac 5999 - 6000 - exp_sym_flag='-bexport' 6001 - no_entry_flag='-bnoentry' 6002 - fi 6003 - 6004 - # When large executables or shared objects are built, AIX ld can 6005 - # have problems creating the table of contents. If linking a library 6006 - # or program results in "error TOC overflow" add -mminimal-toc to 6007 - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not 6008 - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. 6009 - 6010 - _LT_TAGVAR(archive_cmds, $1)='' 6011 - _LT_TAGVAR(hardcode_direct, $1)=yes 6012 - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes 6013 - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' 6014 - _LT_TAGVAR(link_all_deplibs, $1)=yes 6015 - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' 6016 - 6017 - if test "$GXX" = yes; then 6018 - case $host_os in aix4.[[012]]|aix4.[[012]].*) 6019 - # We only want to do this on AIX 4.2 and lower, the check 6020 - # below for broken collect2 doesn't work under 4.3+ 6021 - collect2name=`${CC} -print-prog-name=collect2` 6022 - if test -f "$collect2name" && 6023 - strings "$collect2name" | $GREP resolve_lib_name >/dev/null 6024 - then 6025 - # We have reworked collect2 6026 - : 6027 - else 6028 - # We have old collect2 6029 - _LT_TAGVAR(hardcode_direct, $1)=unsupported 6030 - # It fails to find uninstalled libraries when the uninstalled 6031 - # path is not listed in the libpath. Setting hardcode_minus_L 6032 - # to unsupported forces relinking 6033 - _LT_TAGVAR(hardcode_minus_L, $1)=yes 6034 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 6035 - _LT_TAGVAR(hardcode_libdir_separator, $1)= 6036 - fi 6037 - esac 6038 - shared_flag='-shared' 6039 - if test "$aix_use_runtimelinking" = yes; then 6040 - shared_flag="$shared_flag "'${wl}-G' 6041 - fi 6042 - else 6043 - # not using gcc 6044 - if test "$host_cpu" = ia64; then 6045 - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release 6046 - # chokes on -Wl,-G. The following line is correct: 6047 - shared_flag='-G' 6048 - else 6049 - if test "$aix_use_runtimelinking" = yes; then 6050 - shared_flag='${wl}-G' 6051 - else 6052 - shared_flag='${wl}-bM:SRE' 6053 - fi 6054 - fi 6055 - fi 6056 - 6057 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' 6058 - # It seems that -bexpall does not export symbols beginning with 6059 - # underscore (_), so it is better to generate a list of symbols to 6060 - # export. 6061 - _LT_TAGVAR(always_export_symbols, $1)=yes 6062 - if test "$aix_use_runtimelinking" = yes; then 6063 - # Warning - without using the other runtime loading flags (-brtl), 6064 - # -berok will link without error, but may produce a broken library. 6065 - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' 6066 - # Determine the default libpath from the value encoded in an empty 6067 - # executable. 6068 - _LT_SYS_MODULE_PATH_AIX([$1]) 6069 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" 6070 - 6071 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" 6072 - else 6073 - if test "$host_cpu" = ia64; then 6074 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' 6075 - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" 6076 - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" 6077 - else 6078 - # Determine the default libpath from the value encoded in an 6079 - # empty executable. 6080 - _LT_SYS_MODULE_PATH_AIX([$1]) 6081 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" 6082 - # Warning - without using the other run time loading flags, 6083 - # -berok will link without error, but may produce a broken library. 6084 - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' 6085 - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' 6086 - if test "$with_gnu_ld" = yes; then 6087 - # We only use this code for GNU lds that support --whole-archive. 6088 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' 6089 - else 6090 - # Exported symbols can be pulled into shared objects from archives 6091 - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' 6092 - fi 6093 - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes 6094 - # This is similar to how AIX traditionally builds its shared 6095 - # libraries. 6096 - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' 6097 - fi 6098 - fi 6099 - ;; 6100 - 6101 - beos*) 6102 - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then 6103 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 6104 - # Joseph Beckenbach <jrb3@best.com> says some releases of gcc 6105 - # support --undefined. This deserves some investigation. FIXME 6106 - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 6107 - else 6108 - _LT_TAGVAR(ld_shlibs, $1)=no 6109 - fi 6110 - ;; 6111 - 6112 - chorus*) 6113 - case $cc_basename in 6114 - *) 6115 - # FIXME: insert proper C++ library support 6116 - _LT_TAGVAR(ld_shlibs, $1)=no 6117 - ;; 6118 - esac 6119 - ;; 6120 - 6121 - cygwin* | mingw* | pw32* | cegcc*) 6122 - case $GXX,$cc_basename in 6123 - ,cl* | no,cl*) 6124 - # Native MSVC 6125 - # hardcode_libdir_flag_spec is actually meaningless, as there is 6126 - # no search path for DLLs. 6127 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' 6128 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 6129 - _LT_TAGVAR(always_export_symbols, $1)=yes 6130 - _LT_TAGVAR(file_list_spec, $1)='@' 6131 - # Tell ltmain to make .lib files, not .a files. 6132 - libext=lib 6133 - # Tell ltmain to make .dll files, not .so files. 6134 - shrext_cmds=".dll" 6135 - # FIXME: Setting linknames here is a bad hack. 6136 - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' 6137 - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then 6138 - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; 6139 - else 6140 - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; 6141 - fi~ 6142 - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ 6143 - linknames=' 6144 - # The linker will not automatically build a static lib if we build a DLL. 6145 - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' 6146 - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes 6147 - # Don't use ranlib 6148 - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' 6149 - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ 6150 - lt_tool_outputfile="@TOOL_OUTPUT@"~ 6151 - case $lt_outputfile in 6152 - *.exe|*.EXE) ;; 6153 - *) 6154 - lt_outputfile="$lt_outputfile.exe" 6155 - lt_tool_outputfile="$lt_tool_outputfile.exe" 6156 - ;; 6157 - esac~ 6158 - func_to_tool_file "$lt_outputfile"~ 6159 - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then 6160 - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; 6161 - $RM "$lt_outputfile.manifest"; 6162 - fi' 6163 - ;; 6164 - *) 6165 - # g++ 6166 - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, 6167 - # as there is no search path for DLLs. 6168 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' 6169 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' 6170 - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported 6171 - _LT_TAGVAR(always_export_symbols, $1)=no 6172 - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes 6173 - 6174 - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then 6175 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' 6176 - # If the export-symbols file already is a .def file (1st line 6177 - # is EXPORTS), use it as is; otherwise, prepend... 6178 - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then 6179 - cp $export_symbols $output_objdir/$soname.def; 6180 - else 6181 - echo EXPORTS > $output_objdir/$soname.def; 6182 - cat $export_symbols >> $output_objdir/$soname.def; 6183 - fi~ 6184 - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' 6185 - else 6186 - _LT_TAGVAR(ld_shlibs, $1)=no 6187 - fi 6188 - ;; 6189 - esac 6190 - ;; 6191 - darwin* | rhapsody*) 6192 - _LT_DARWIN_LINKER_FEATURES($1) 6193 - ;; 6194 - 6195 - dgux*) 6196 - case $cc_basename in 6197 - ec++*) 6198 - # FIXME: insert proper C++ library support 6199 - _LT_TAGVAR(ld_shlibs, $1)=no 6200 - ;; 6201 - ghcx*) 6202 - # Green Hills C++ Compiler 6203 - # FIXME: insert proper C++ library support 6204 - _LT_TAGVAR(ld_shlibs, $1)=no 6205 - ;; 6206 - *) 6207 - # FIXME: insert proper C++ library support 6208 - _LT_TAGVAR(ld_shlibs, $1)=no 6209 - ;; 6210 - esac 6211 - ;; 6212 - 6213 - freebsd2.*) 6214 - # C++ shared libraries reported to be fairly broken before 6215 - # switch to ELF 6216 - _LT_TAGVAR(ld_shlibs, $1)=no 6217 - ;; 6218 - 6219 - freebsd-elf*) 6220 - _LT_TAGVAR(archive_cmds_need_lc, $1)=no 6221 - ;; 6222 - 6223 - freebsd* | dragonfly*) 6224 - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF 6225 - # conventions 6226 - _LT_TAGVAR(ld_shlibs, $1)=yes 6227 - ;; 6228 - 6229 - gnu*) 6230 - ;; 6231 - 6232 - haiku*) 6233 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 6234 - _LT_TAGVAR(link_all_deplibs, $1)=yes 6235 - ;; 6236 - 6237 - hpux9*) 6238 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' 6239 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 6240 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 6241 - _LT_TAGVAR(hardcode_direct, $1)=yes 6242 - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, 6243 - # but as the default 6244 - # location of the library. 6245 - 6246 - case $cc_basename in 6247 - CC*) 6248 - # FIXME: insert proper C++ library support 6249 - _LT_TAGVAR(ld_shlibs, $1)=no 6250 - ;; 6251 - aCC*) 6252 - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' 6253 - # Commands to make compiler produce verbose output that lists 6254 - # what "hidden" libraries, object files and flags are used when 6255 - # linking a shared library. 6256 - # 6257 - # There doesn't appear to be a way to prevent this compiler from 6258 - # explicitly linking system object files so we need to strip them 6259 - # from the output so that they don't get included in the library 6260 - # dependencies. 6261 - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' 6262 - ;; 6263 - *) 6264 - if test "$GXX" = yes; then 6265 - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' 6266 - else 6267 - # FIXME: insert proper C++ library support 6268 - _LT_TAGVAR(ld_shlibs, $1)=no 6269 - fi 6270 - ;; 6271 - esac 6272 - ;; 6273 - 6274 - hpux10*|hpux11*) 6275 - if test $with_gnu_ld = no; then 6276 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' 6277 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 6278 - 6279 - case $host_cpu in 6280 - hppa*64*|ia64*) 6281 - ;; 6282 - *) 6283 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 6284 - ;; 6285 - esac 6286 - fi 6287 - case $host_cpu in 6288 - hppa*64*|ia64*) 6289 - _LT_TAGVAR(hardcode_direct, $1)=no 6290 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 6291 - ;; 6292 - *) 6293 - _LT_TAGVAR(hardcode_direct, $1)=yes 6294 - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes 6295 - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, 6296 - # but as the default 6297 - # location of the library. 6298 - ;; 6299 - esac 6300 - 6301 - case $cc_basename in 6302 - CC*) 6303 - # FIXME: insert proper C++ library support 6304 - _LT_TAGVAR(ld_shlibs, $1)=no 6305 - ;; 6306 - aCC*) 6307 - case $host_cpu in 6308 - hppa*64*) 6309 - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' 6310 - ;; 6311 - ia64*) 6312 - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' 6313 - ;; 6314 - *) 6315 - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' 6316 - ;; 6317 - esac 6318 - # Commands to make compiler produce verbose output that lists 6319 - # what "hidden" libraries, object files and flags are used when 6320 - # linking a shared library. 6321 - # 6322 - # There doesn't appear to be a way to prevent this compiler from 6323 - # explicitly linking system object files so we need to strip them 6324 - # from the output so that they don't get included in the library 6325 - # dependencies. 6326 - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' 6327 - ;; 6328 - *) 6329 - if test "$GXX" = yes; then 6330 - if test $with_gnu_ld = no; then 6331 - case $host_cpu in 6332 - hppa*64*) 6333 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' 6334 - ;; 6335 - ia64*) 6336 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' 6337 - ;; 6338 - *) 6339 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' 6340 - ;; 6341 - esac 6342 - fi 6343 - else 6344 - # FIXME: insert proper C++ library support 6345 - _LT_TAGVAR(ld_shlibs, $1)=no 6346 - fi 6347 - ;; 6348 - esac 6349 - ;; 6350 - 6351 - interix[[3-9]]*) 6352 - _LT_TAGVAR(hardcode_direct, $1)=no 6353 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 6354 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' 6355 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 6356 - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. 6357 - # Instead, shared libraries are loaded at an image base (0x10000000 by 6358 - # default) and relocated if they conflict, which is a slow very memory 6359 - # consuming and fragmenting process. To avoid this, we pick a random, 6360 - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link 6361 - # time. Moving up from 0x10000000 also allows more sbrk(2) space. 6362 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' 6363 - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' 6364 - ;; 6365 - irix5* | irix6*) 6366 - case $cc_basename in 6367 - CC*) 6368 - # SGI C++ 6369 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' 6370 - 6371 - # Archives containing C++ object files must be created using 6372 - # "CC -ar", where "CC" is the IRIX C++ compiler. This is 6373 - # necessary to make sure instantiated templates are included 6374 - # in the archive. 6375 - _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' 6376 - ;; 6377 - *) 6378 - if test "$GXX" = yes; then 6379 - if test "$with_gnu_ld" = no; then 6380 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' 6381 - else 6382 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' 6383 - fi 6384 - fi 6385 - _LT_TAGVAR(link_all_deplibs, $1)=yes 6386 - ;; 6387 - esac 6388 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 6389 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 6390 - _LT_TAGVAR(inherit_rpath, $1)=yes 6391 - ;; 6392 - 6393 - linux* | k*bsd*-gnu | kopensolaris*-gnu) 6394 - case $cc_basename in 6395 - KCC*) 6396 - # Kuck and Associates, Inc. (KAI) C++ Compiler 6397 - 6398 - # KCC will only create a shared library if the output file 6399 - # ends with ".so" (or ".sl" for HP-UX), so rename the library 6400 - # to its proper name (with version) after linking. 6401 - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' 6402 - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' 6403 - # Commands to make compiler produce verbose output that lists 6404 - # what "hidden" libraries, object files and flags are used when 6405 - # linking a shared library. 6406 - # 6407 - # There doesn't appear to be a way to prevent this compiler from 6408 - # explicitly linking system object files so we need to strip them 6409 - # from the output so that they don't get included in the library 6410 - # dependencies. 6411 - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' 6412 - 6413 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' 6414 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' 6415 - 6416 - # Archives containing C++ object files must be created using 6417 - # "CC -Bstatic", where "CC" is the KAI C++ compiler. 6418 - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' 6419 - ;; 6420 - icpc* | ecpc* ) 6421 - # Intel C++ 6422 - with_gnu_ld=yes 6423 - # version 8.0 and above of icpc choke on multiply defined symbols 6424 - # if we add $predep_objects and $postdep_objects, however 7.1 and 6425 - # earlier do not add the objects themselves. 6426 - case `$CC -V 2>&1` in 6427 - *"Version 7."*) 6428 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' 6429 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' 6430 - ;; 6431 - *) # Version 8.0 or newer 6432 - tmp_idyn= 6433 - case $host_cpu in 6434 - ia64*) tmp_idyn=' -i_dynamic';; 6435 - esac 6436 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 6437 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' 6438 - ;; 6439 - esac 6440 - _LT_TAGVAR(archive_cmds_need_lc, $1)=no 6441 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' 6442 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' 6443 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' 6444 - ;; 6445 - pgCC* | pgcpp*) 6446 - # Portland Group C++ compiler 6447 - case `$CC -V` in 6448 - *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) 6449 - _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ 6450 - rm -rf $tpldir~ 6451 - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ 6452 - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' 6453 - _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ 6454 - rm -rf $tpldir~ 6455 - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ 6456 - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ 6457 - $RANLIB $oldlib' 6458 - _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ 6459 - rm -rf $tpldir~ 6460 - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ 6461 - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' 6462 - _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ 6463 - rm -rf $tpldir~ 6464 - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ 6465 - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' 6466 - ;; 6467 - *) # Version 6 and above use weak symbols 6468 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' 6469 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' 6470 - ;; 6471 - esac 6472 - 6473 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' 6474 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' 6475 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' 6476 - ;; 6477 - cxx*) 6478 - # Compaq C++ 6479 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' 6480 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' 6481 - 6482 - runpath_var=LD_RUN_PATH 6483 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' 6484 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 6485 - 6486 - # Commands to make compiler produce verbose output that lists 6487 - # what "hidden" libraries, object files and flags are used when 6488 - # linking a shared library. 6489 - # 6490 - # There doesn't appear to be a way to prevent this compiler from 6491 - # explicitly linking system object files so we need to strip them 6492 - # from the output so that they don't get included in the library 6493 - # dependencies. 6494 - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' 6495 - ;; 6496 - xl* | mpixl* | bgxl*) 6497 - # IBM XL 8.0 on PPC, with GNU ld 6498 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 6499 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' 6500 - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' 6501 - if test "x$supports_anon_versioning" = xyes; then 6502 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ 6503 - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ 6504 - echo "local: *; };" >> $output_objdir/$libname.ver~ 6505 - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' 6506 - fi 6507 - ;; 6508 - *) 6509 - case `$CC -V 2>&1 | sed 5q` in 6510 - *Sun\ C*) 6511 - # Sun C++ 5.9 6512 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' 6513 - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' 6514 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' 6515 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' 6516 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' 6517 - _LT_TAGVAR(compiler_needs_object, $1)=yes 6518 - 6519 - # Not sure whether something based on 6520 - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 6521 - # would be better. 6522 - output_verbose_link_cmd='func_echo_all' 6523 - 6524 - # Archives containing C++ object files must be created using 6525 - # "CC -xar", where "CC" is the Sun C++ compiler. This is 6526 - # necessary to make sure instantiated templates are included 6527 - # in the archive. 6528 - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' 6529 - ;; 6530 - esac 6531 - ;; 6532 - esac 6533 - ;; 6534 - 6535 - lynxos*) 6536 - # FIXME: insert proper C++ library support 6537 - _LT_TAGVAR(ld_shlibs, $1)=no 6538 - ;; 6539 - 6540 - m88k*) 6541 - # FIXME: insert proper C++ library support 6542 - _LT_TAGVAR(ld_shlibs, $1)=no 6543 - ;; 6544 - 6545 - mvs*) 6546 - case $cc_basename in 6547 - cxx*) 6548 - # FIXME: insert proper C++ library support 6549 - _LT_TAGVAR(ld_shlibs, $1)=no 6550 - ;; 6551 - *) 6552 - # FIXME: insert proper C++ library support 6553 - _LT_TAGVAR(ld_shlibs, $1)=no 6554 - ;; 6555 - esac 6556 - ;; 6557 - 6558 - netbsd*) 6559 - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then 6560 - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' 6561 - wlarc= 6562 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' 6563 - _LT_TAGVAR(hardcode_direct, $1)=yes 6564 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 6565 - fi 6566 - # Workaround some broken pre-1.5 toolchains 6567 - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' 6568 - ;; 6569 - 6570 - *nto* | *qnx*) 6571 - _LT_TAGVAR(ld_shlibs, $1)=yes 6572 - ;; 6573 - 6574 - openbsd2*) 6575 - # C++ shared libraries are fairly broken 6576 - _LT_TAGVAR(ld_shlibs, $1)=no 6577 - ;; 6578 - 6579 - openbsd*) 6580 - if test -f /usr/libexec/ld.so; then 6581 - _LT_TAGVAR(hardcode_direct, $1)=yes 6582 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 6583 - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes 6584 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' 6585 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' 6586 - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then 6587 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' 6588 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' 6589 - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' 6590 - fi 6591 - output_verbose_link_cmd=func_echo_all 6592 - else 6593 - _LT_TAGVAR(ld_shlibs, $1)=no 6594 - fi 6595 - ;; 6596 - 6597 - osf3* | osf4* | osf5*) 6598 - case $cc_basename in 6599 - KCC*) 6600 - # Kuck and Associates, Inc. (KAI) C++ Compiler 6601 - 6602 - # KCC will only create a shared library if the output file 6603 - # ends with ".so" (or ".sl" for HP-UX), so rename the library 6604 - # to its proper name (with version) after linking. 6605 - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' 6606 - 6607 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' 6608 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 6609 - 6610 - # Archives containing C++ object files must be created using 6611 - # the KAI C++ compiler. 6612 - case $host in 6613 - osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; 6614 - *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; 6615 - esac 6616 - ;; 6617 - RCC*) 6618 - # Rational C++ 2.4.1 6619 - # FIXME: insert proper C++ library support 6620 - _LT_TAGVAR(ld_shlibs, $1)=no 6621 - ;; 6622 - cxx*) 6623 - case $host in 6624 - osf3*) 6625 - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' 6626 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' 6627 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 6628 - ;; 6629 - *) 6630 - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' 6631 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' 6632 - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ 6633 - echo "-hidden">> $lib.exp~ 6634 - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ 6635 - $RM $lib.exp' 6636 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' 6637 - ;; 6638 - esac 6639 - 6640 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 6641 - 6642 - # Commands to make compiler produce verbose output that lists 6643 - # what "hidden" libraries, object files and flags are used when 6644 - # linking a shared library. 6645 - # 6646 - # There doesn't appear to be a way to prevent this compiler from 6647 - # explicitly linking system object files so we need to strip them 6648 - # from the output so that they don't get included in the library 6649 - # dependencies. 6650 - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' 6651 - ;; 6652 - *) 6653 - if test "$GXX" = yes && test "$with_gnu_ld" = no; then 6654 - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' 6655 - case $host in 6656 - osf3*) 6657 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' 6658 - ;; 6659 - *) 6660 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' 6661 - ;; 6662 - esac 6663 - 6664 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' 6665 - _LT_TAGVAR(hardcode_libdir_separator, $1)=: 6666 - 6667 - # Commands to make compiler produce verbose output that lists 6668 - # what "hidden" libraries, object files and flags are used when 6669 - # linking a shared library. 6670 - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' 6671 - 6672 - else 6673 - # FIXME: insert proper C++ library support 6674 - _LT_TAGVAR(ld_shlibs, $1)=no 6675 - fi 6676 - ;; 6677 - esac 6678 - ;; 6679 - 6680 - psos*) 6681 - # FIXME: insert proper C++ library support 6682 - _LT_TAGVAR(ld_shlibs, $1)=no 6683 - ;; 6684 - 6685 - sunos4*) 6686 - case $cc_basename in 6687 - CC*) 6688 - # Sun C++ 4.x 6689 - # FIXME: insert proper C++ library support 6690 - _LT_TAGVAR(ld_shlibs, $1)=no 6691 - ;; 6692 - lcc*) 6693 - # Lucid 6694 - # FIXME: insert proper C++ library support 6695 - _LT_TAGVAR(ld_shlibs, $1)=no 6696 - ;; 6697 - *) 6698 - # FIXME: insert proper C++ library support 6699 - _LT_TAGVAR(ld_shlibs, $1)=no 6700 - ;; 6701 - esac 6702 - ;; 6703 - 6704 - solaris*) 6705 - case $cc_basename in 6706 - CC* | sunCC*) 6707 - # Sun C++ 4.2, 5.x and Centerline C++ 6708 - _LT_TAGVAR(archive_cmds_need_lc,$1)=yes 6709 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' 6710 - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' 6711 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ 6712 - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' 6713 - 6714 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' 6715 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 6716 - case $host_os in 6717 - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; 6718 - *) 6719 - # The compiler driver will combine and reorder linker options, 6720 - # but understands `-z linker_flag'. 6721 - # Supported since Solaris 2.6 (maybe 2.5.1?) 6722 - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' 6723 - ;; 6724 - esac 6725 - _LT_TAGVAR(link_all_deplibs, $1)=yes 6726 - 6727 - output_verbose_link_cmd='func_echo_all' 6728 - 6729 - # Archives containing C++ object files must be created using 6730 - # "CC -xar", where "CC" is the Sun C++ compiler. This is 6731 - # necessary to make sure instantiated templates are included 6732 - # in the archive. 6733 - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' 6734 - ;; 6735 - gcx*) 6736 - # Green Hills C++ Compiler 6737 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' 6738 - 6739 - # The C++ compiler must be used to create the archive. 6740 - _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' 6741 - ;; 6742 - *) 6743 - # GNU C++ compiler with Solaris linker 6744 - if test "$GXX" = yes && test "$with_gnu_ld" = no; then 6745 - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' 6746 - if $CC --version | $GREP -v '^2\.7' > /dev/null; then 6747 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' 6748 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ 6749 - $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' 6750 - 6751 - # Commands to make compiler produce verbose output that lists 6752 - # what "hidden" libraries, object files and flags are used when 6753 - # linking a shared library. 6754 - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' 6755 - else 6756 - # g++ 2.7 appears to require `-G' NOT `-shared' on this 6757 - # platform. 6758 - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' 6759 - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ 6760 - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' 6761 - 6762 - # Commands to make compiler produce verbose output that lists 6763 - # what "hidden" libraries, object files and flags are used when 6764 - # linking a shared library. 6765 - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' 6766 - fi 6767 - 6768 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' 6769 - case $host_os in 6770 - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; 6771 - *) 6772 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' 6773 - ;; 6774 - esac 6775 - fi 6776 - ;; 6777 - esac 6778 - ;; 6779 - 6780 - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) 6781 - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' 6782 - _LT_TAGVAR(archive_cmds_need_lc, $1)=no 6783 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 6784 - runpath_var='LD_RUN_PATH' 6785 - 6786 - case $cc_basename in 6787 - CC*) 6788 - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 6789 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 6790 - ;; 6791 - *) 6792 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 6793 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 6794 - ;; 6795 - esac 6796 - ;; 6797 - 6798 - sysv5* | sco3.2v5* | sco5v6*) 6799 - # Note: We can NOT use -z defs as we might desire, because we do not 6800 - # link with -lc, and that would cause any symbols used from libc to 6801 - # always be unresolved, which means just about no library would 6802 - # ever link correctly. If we're not using GNU ld we use -z text 6803 - # though, which does catch some bad symbols but isn't as heavy-handed 6804 - # as -z defs. 6805 - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' 6806 - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' 6807 - _LT_TAGVAR(archive_cmds_need_lc, $1)=no 6808 - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no 6809 - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' 6810 - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' 6811 - _LT_TAGVAR(link_all_deplibs, $1)=yes 6812 - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' 6813 - runpath_var='LD_RUN_PATH' 6814 - 6815 - case $cc_basename in 6816 - CC*) 6817 - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 6818 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 6819 - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ 6820 - '"$_LT_TAGVAR(old_archive_cmds, $1)" 6821 - _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ 6822 - '"$_LT_TAGVAR(reload_cmds, $1)" 6823 - ;; 6824 - *) 6825 - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 6826 - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' 6827 - ;; 6828 - esac 6829 - ;; 6830 - 6831 - tandem*) 6832 - case $cc_basename in 6833 - NCC*) 6834 - # NonStop-UX NCC 3.20 6835 - # FIXME: insert proper C++ library support 6836 - _LT_TAGVAR(ld_shlibs, $1)=no 6837 - ;; 6838 - *) 6839 - # FIXME: insert proper C++ library support 6840 - _LT_TAGVAR(ld_shlibs, $1)=no 6841 - ;; 6842 - esac 6843 - ;; 6844 - 6845 - vxworks*) 6846 - # FIXME: insert proper C++ library support 6847 - _LT_TAGVAR(ld_shlibs, $1)=no 6848 - ;; 6849 - 6850 - *) 6851 - # FIXME: insert proper C++ library support 6852 - _LT_TAGVAR(ld_shlibs, $1)=no 6853 - ;; 6854 - esac 6855 - 6856 - AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) 6857 - test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no 6858 - 6859 - _LT_TAGVAR(GCC, $1)="$GXX" 6860 - _LT_TAGVAR(LD, $1)="$LD" 6861 - 6862 - ## CAVEAT EMPTOR: 6863 - ## There is no encapsulation within the following macros, do not change 6864 - ## the running order or otherwise move them around unless you know exactly 6865 - ## what you are doing... 6866 - _LT_SYS_HIDDEN_LIBDEPS($1) 6867 - _LT_COMPILER_PIC($1) 6868 - _LT_COMPILER_C_O($1) 6869 - _LT_COMPILER_FILE_LOCKS($1) 6870 - _LT_LINKER_SHLIBS($1) 6871 - _LT_SYS_DYNAMIC_LINKER($1) 6872 - _LT_LINKER_HARDCODE_LIBPATH($1) 6873 - 6874 - _LT_CONFIG($1) 6875 - fi # test -n "$compiler" 6876 - 6877 - CC=$lt_save_CC 6878 - CFLAGS=$lt_save_CFLAGS 6879 - LDCXX=$LD 6880 - LD=$lt_save_LD 6881 - GCC=$lt_save_GCC 6882 - with_gnu_ld=$lt_save_with_gnu_ld 6883 - lt_cv_path_LDCXX=$lt_cv_path_LD 6884 - lt_cv_path_LD=$lt_save_path_LD 6885 - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld 6886 - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld 6887 -fi # test "$_lt_caught_CXX_error" != yes 6888 - 6889 -AC_LANG_POP 6890 -])# _LT_LANG_CXX_CONFIG 6891 - 6892 - 6893 -# _LT_FUNC_STRIPNAME_CNF 6894 -# ---------------------- 6895 -# func_stripname_cnf prefix suffix name 6896 -# strip PREFIX and SUFFIX off of NAME. 6897 -# PREFIX and SUFFIX must not contain globbing or regex special 6898 -# characters, hashes, percent signs, but SUFFIX may contain a leading 6899 -# dot (in which case that matches only a dot). 6900 -# 6901 -# This function is identical to the (non-XSI) version of func_stripname, 6902 -# except this one can be used by m4 code that may be executed by configure, 6903 -# rather than the libtool script. 6904 -m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl 6905 -AC_REQUIRE([_LT_DECL_SED]) 6906 -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) 6907 -func_stripname_cnf () 6908 -{ 6909 - case ${2} in 6910 - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 6911 - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 6912 - esac 6913 -} # func_stripname_cnf 6914 -])# _LT_FUNC_STRIPNAME_CNF 6915 - 6916 -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) 6917 -# --------------------------------- 6918 -# Figure out "hidden" library dependencies from verbose 6919 -# compiler output when linking a shared library. 6920 -# Parse the compiler output and extract the necessary 6921 -# objects, libraries and library flags. 6922 -m4_defun([_LT_SYS_HIDDEN_LIBDEPS], 6923 -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl 6924 -AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl 6925 -# Dependencies to place before and after the object being linked: 6926 -_LT_TAGVAR(predep_objects, $1)= 6927 -_LT_TAGVAR(postdep_objects, $1)= 6928 -_LT_TAGVAR(predeps, $1)= 6929 -_LT_TAGVAR(postdeps, $1)= 6930 -_LT_TAGVAR(compiler_lib_search_path, $1)= 6931 - 6932 -dnl we can't use the lt_simple_compile_test_code here, 6933 -dnl because it contains code intended for an executable, 6934 -dnl not a library. It's possible we should let each 6935 -dnl tag define a new lt_????_link_test_code variable, 6936 -dnl but it's only used here... 6937 -m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF 6938 -int a; 6939 -void foo (void) { a = 0; } 6940 -_LT_EOF 6941 -], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF 6942 -class Foo 6943 -{ 6944 -public: 6945 - Foo (void) { a = 0; } 6946 -private: 6947 - int a; 6948 -}; 6949 -_LT_EOF 6950 -], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF 6951 - subroutine foo 6952 - implicit none 6953 - integer*4 a 6954 - a=0 6955 - return 6956 - end 6957 -_LT_EOF 6958 -], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF 6959 - subroutine foo 6960 - implicit none 6961 - integer a 6962 - a=0 6963 - return 6964 - end 6965 -_LT_EOF 6966 -], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF 6967 -public class foo { 6968 - private int a; 6969 - public void bar (void) { 6970 - a = 0; 6971 - } 6972 -}; 6973 -_LT_EOF 6974 -], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF 6975 -package foo 6976 -func foo() { 6977 -} 6978 -_LT_EOF 6979 -]) 6980 - 6981 -_lt_libdeps_save_CFLAGS=$CFLAGS 6982 -case "$CC $CFLAGS " in #( 6983 -*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; 6984 -*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; 6985 -*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; 6986 -esac 6987 - 6988 -dnl Parse the compiler output and extract the necessary 6989 -dnl objects, libraries and library flags. 6990 -if AC_TRY_EVAL(ac_compile); then 6991 - # Parse the compiler output and extract the necessary 6992 - # objects, libraries and library flags. 6993 - 6994 - # Sentinel used to keep track of whether or not we are before 6995 - # the conftest object file. 6996 - pre_test_object_deps_done=no 6997 - 6998 - for p in `eval "$output_verbose_link_cmd"`; do 6999 - case ${prev}${p} in 7000 - 7001 - -L* | -R* | -l*) 7002 - # Some compilers place space between "-{L,R}" and the path. 7003 - # Remove the space. 7004 - if test $p = "-L" || 7005 - test $p = "-R"; then 7006 - prev=$p 7007 - continue 7008 - fi 7009 - 7010 - # Expand the sysroot to ease extracting the directories later. 7011 - if test -z "$prev"; then 7012 - case $p in 7013 - -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; 7014 - -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; 7015 - -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; 7016 - esac 7017 - fi 7018 - case $p in 7019 - =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; 7020 - esac 7021 - if test "$pre_test_object_deps_done" = no; then 7022 - case ${prev} in 7023 - -L | -R) 7024 - # Internal compiler library paths should come after those 7025 - # provided the user. The postdeps already come after the 7026 - # user supplied libs so there is no need to process them. 7027 - if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then 7028 - _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" 7029 - else 7030 - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" 7031 - fi 7032 - ;; 7033 - # The "-l" case would never come before the object being 7034 - # linked, so don't bother handling this case. 7035 - esac 7036 - else 7037 - if test -z "$_LT_TAGVAR(postdeps, $1)"; then 7038 - _LT_TAGVAR(postdeps, $1)="${prev}${p}" 7039 - else 7040 - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" 7041 - fi 7042 - fi 7043 - prev= 7044 - ;; 7045 - 7046 - *.lto.$objext) ;; # Ignore GCC LTO objects 7047 - *.$objext) 7048 - # This assumes that the test object file only shows up 7049 - # once in the compiler output. 7050 - if test "$p" = "conftest.$objext"; then 7051 - pre_test_object_deps_done=yes 7052 - continue 7053 - fi 7054 - 7055 - if test "$pre_test_object_deps_done" = no; then 7056 - if test -z "$_LT_TAGVAR(predep_objects, $1)"; then 7057 - _LT_TAGVAR(predep_objects, $1)="$p" 7058 - else 7059 - _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" 7060 - fi 7061 - else 7062 - if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then 7063 - _LT_TAGVAR(postdep_objects, $1)="$p" 7064 - else 7065 - _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" 7066 - fi 7067 - fi 7068 - ;; 7069 - 7070 - *) ;; # Ignore the rest. 7071 - 7072 - esac 7073 - done 7074 - 7075 - # Clean up. 7076 - rm -f a.out a.exe 7077 -else 7078 - echo "libtool.m4: error: problem compiling $1 test program" 7079 -fi 7080 - 7081 -$RM -f confest.$objext 7082 -CFLAGS=$_lt_libdeps_save_CFLAGS 7083 - 7084 -# PORTME: override above test on systems where it is broken 7085 -m4_if([$1], [CXX], 7086 -[case $host_os in 7087 -interix[[3-9]]*) 7088 - # Interix 3.5 installs completely hosed .la files for C++, so rather than 7089 - # hack all around it, let's just trust "g++" to DTRT. 7090 - _LT_TAGVAR(predep_objects,$1)= 7091 - _LT_TAGVAR(postdep_objects,$1)= 7092 - _LT_TAGVAR(postdeps,$1)= 7093 - ;; 7094 - 7095 -linux*) 7096 - case `$CC -V 2>&1 | sed 5q` in 7097 - *Sun\ C*) 7098 - # Sun C++ 5.9 7099 - 7100 - # The more standards-conforming stlport4 library is 7101 - # incompatible with the Cstd library. Avoid specifying 7102 - # it if it's in CXXFLAGS. Ignore libCrun as 7103 - # -library=stlport4 depends on it. 7104 - case " $CXX $CXXFLAGS " in 7105 - *" -library=stlport4 "*) 7106 - solaris_use_stlport4=yes 7107 - ;; 7108 - esac 7109 - 7110 - if test "$solaris_use_stlport4" != yes; then 7111 - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' 7112 - fi 7113 - ;; 7114 - esac 7115 - ;; 7116 - 7117 -solaris*) 7118 - case $cc_basename in 7119 - CC* | sunCC*) 7120 - # The more standards-conforming stlport4 library is 7121 - # incompatible with the Cstd library. Avoid specifying 7122 - # it if it's in CXXFLAGS. Ignore libCrun as 7123 - # -library=stlport4 depends on it. 7124 - case " $CXX $CXXFLAGS " in 7125 - *" -library=stlport4 "*) 7126 - solaris_use_stlport4=yes 7127 - ;; 7128 - esac 7129 - 7130 - # Adding this requires a known-good setup of shared libraries for 7131 - # Sun compiler versions before 5.6, else PIC objects from an old 7132 - # archive will be linked into the output, leading to subtle bugs. 7133 - if test "$solaris_use_stlport4" != yes; then 7134 - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' 7135 - fi 7136 - ;; 7137 - esac 7138 - ;; 7139 -esac 7140 -]) 7141 - 7142 -case " $_LT_TAGVAR(postdeps, $1) " in 7143 -*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; 7144 -esac 7145 - _LT_TAGVAR(compiler_lib_search_dirs, $1)= 7146 -if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then 7147 - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` 7148 -fi 7149 -_LT_TAGDECL([], [compiler_lib_search_dirs], [1], 7150 - [The directories searched by this compiler when creating a shared library]) 7151 -_LT_TAGDECL([], [predep_objects], [1], 7152 - [Dependencies to place before and after the objects being linked to 7153 - create a shared library]) 7154 -_LT_TAGDECL([], [postdep_objects], [1]) 7155 -_LT_TAGDECL([], [predeps], [1]) 7156 -_LT_TAGDECL([], [postdeps], [1]) 7157 -_LT_TAGDECL([], [compiler_lib_search_path], [1], 7158 - [The library search path used internally by the compiler when linking 7159 - a shared library]) 7160 -])# _LT_SYS_HIDDEN_LIBDEPS 7161 - 7162 - 7163 -# _LT_LANG_F77_CONFIG([TAG]) 7164 -# -------------------------- 7165 -# Ensure that the configuration variables for a Fortran 77 compiler are 7166 -# suitably defined. These variables are subsequently used by _LT_CONFIG 7167 -# to write the compiler configuration to `libtool'. 7168 -m4_defun([_LT_LANG_F77_CONFIG], 7169 -[AC_LANG_PUSH(Fortran 77) 7170 -if test -z "$F77" || test "X$F77" = "Xno"; then 7171 - _lt_disable_F77=yes 7172 -fi 7173 - 7174 -_LT_TAGVAR(archive_cmds_need_lc, $1)=no 7175 -_LT_TAGVAR(allow_undefined_flag, $1)= 7176 -_LT_TAGVAR(always_export_symbols, $1)=no 7177 -_LT_TAGVAR(archive_expsym_cmds, $1)= 7178 -_LT_TAGVAR(export_dynamic_flag_spec, $1)= 7179 -_LT_TAGVAR(hardcode_direct, $1)=no 7180 -_LT_TAGVAR(hardcode_direct_absolute, $1)=no 7181 -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= 7182 -_LT_TAGVAR(hardcode_libdir_separator, $1)= 7183 -_LT_TAGVAR(hardcode_minus_L, $1)=no 7184 -_LT_TAGVAR(hardcode_automatic, $1)=no 7185 -_LT_TAGVAR(inherit_rpath, $1)=no 7186 -_LT_TAGVAR(module_cmds, $1)= 7187 -_LT_TAGVAR(module_expsym_cmds, $1)= 7188 -_LT_TAGVAR(link_all_deplibs, $1)=unknown 7189 -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds 7190 -_LT_TAGVAR(reload_flag, $1)=$reload_flag 7191 -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds 7192 -_LT_TAGVAR(no_undefined_flag, $1)= 7193 -_LT_TAGVAR(whole_archive_flag_spec, $1)= 7194 -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no 7195 - 7196 -# Source file extension for f77 test sources. 7197 -ac_ext=f 7198 - 7199 -# Object file extension for compiled f77 test sources. 7200 -objext=o 7201 -_LT_TAGVAR(objext, $1)=$objext 7202 - 7203 -# No sense in running all these tests if we already determined that 7204 -# the F77 compiler isn't working. Some variables (like enable_shared) 7205 -# are currently assumed to apply to all compilers on this platform, 7206 -# and will be corrupted by setting them based on a non-working compiler. 7207 -if test "$_lt_disable_F77" != yes; then 7208 - # Code to be used in simple compile tests 7209 - lt_simple_compile_test_code="\ 7210 - subroutine t 7211 - return 7212 - end 7213 -" 7214 - 7215 - # Code to be used in simple link tests 7216 - lt_simple_link_test_code="\ 7217 - program t 7218 - end 7219 -" 7220 - 7221 - # ltmain only uses $CC for tagged configurations so make sure $CC is set. 7222 - _LT_TAG_COMPILER 7223 - 7224 - # save warnings/boilerplate of simple test code 7225 - _LT_COMPILER_BOILERPLATE 7226 - _LT_LINKER_BOILERPLATE 7227 - 7228 - # Allow CC to be a program name with arguments. 7229 - lt_save_CC="$CC" 7230 - lt_save_GCC=$GCC 7231 - lt_save_CFLAGS=$CFLAGS 7232 - CC=${F77-"f77"} 7233 - CFLAGS=$FFLAGS 7234 - compiler=$CC 7235 - _LT_TAGVAR(compiler, $1)=$CC 7236 - _LT_CC_BASENAME([$compiler]) 7237 - GCC=$G77 7238 - if test -n "$compiler"; then 7239 - AC_MSG_CHECKING([if libtool supports shared libraries]) 7240 - AC_MSG_RESULT([$can_build_shared]) 7241 - 7242 - AC_MSG_CHECKING([whether to build shared libraries]) 7243 - test "$can_build_shared" = "no" && enable_shared=no 7244 - 7245 - # On AIX, shared libraries and static libraries use the same namespace, and 7246 - # are all built from PIC. 7247 - case $host_os in 7248 - aix3*) 7249 - test "$enable_shared" = yes && enable_static=no 7250 - if test -n "$RANLIB"; then 7251 - archive_cmds="$archive_cmds~\$RANLIB \$lib" 7252 - postinstall_cmds='$RANLIB $lib' 7253 - fi 7254 - ;; 7255 - aix[[4-9]]*) 7256 - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then 7257 - test "$enable_shared" = yes && enable_static=no 7258 - fi 7259 - ;; 7260 - esac 7261 - AC_MSG_RESULT([$enable_shared]) 7262 - 7263 - AC_MSG_CHECKING([whether to build static libraries]) 7264 - # Make sure either enable_shared or enable_static is yes. 7265 - test "$enable_shared" = yes || enable_static=yes 7266 - AC_MSG_RESULT([$enable_static]) 7267 - 7268 - _LT_TAGVAR(GCC, $1)="$G77" 7269 - _LT_TAGVAR(LD, $1)="$LD" 7270 - 7271 - ## CAVEAT EMPTOR: 7272 - ## There is no encapsulation within the following macros, do not change 7273 - ## the running order or otherwise move them around unless you know exactly 7274 - ## what you are doing... 7275 - _LT_COMPILER_PIC($1) 7276 - _LT_COMPILER_C_O($1) 7277 - _LT_COMPILER_FILE_LOCKS($1) 7278 - _LT_LINKER_SHLIBS($1) 7279 - _LT_SYS_DYNAMIC_LINKER($1) 7280 - _LT_LINKER_HARDCODE_LIBPATH($1) 7281 - 7282 - _LT_CONFIG($1) 7283 - fi # test -n "$compiler" 7284 - 7285 - GCC=$lt_save_GCC 7286 - CC="$lt_save_CC" 7287 - CFLAGS="$lt_save_CFLAGS" 7288 -fi # test "$_lt_disable_F77" != yes 7289 - 7290 -AC_LANG_POP 7291 -])# _LT_LANG_F77_CONFIG 7292 - 7293 - 7294 -# _LT_LANG_FC_CONFIG([TAG]) 7295 -# ------------------------- 7296 -# Ensure that the configuration variables for a Fortran compiler are 7297 -# suitably defined. These variables are subsequently used by _LT_CONFIG 7298 -# to write the compiler configuration to `libtool'. 7299 -m4_defun([_LT_LANG_FC_CONFIG], 7300 -[AC_LANG_PUSH(Fortran) 7301 - 7302 -if test -z "$FC" || test "X$FC" = "Xno"; then 7303 - _lt_disable_FC=yes 7304 -fi 7305 - 7306 -_LT_TAGVAR(archive_cmds_need_lc, $1)=no 7307 -_LT_TAGVAR(allow_undefined_flag, $1)= 7308 -_LT_TAGVAR(always_export_symbols, $1)=no 7309 -_LT_TAGVAR(archive_expsym_cmds, $1)= 7310 -_LT_TAGVAR(export_dynamic_flag_spec, $1)= 7311 -_LT_TAGVAR(hardcode_direct, $1)=no 7312 -_LT_TAGVAR(hardcode_direct_absolute, $1)=no 7313 -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= 7314 -_LT_TAGVAR(hardcode_libdir_separator, $1)= 7315 -_LT_TAGVAR(hardcode_minus_L, $1)=no 7316 -_LT_TAGVAR(hardcode_automatic, $1)=no 7317 -_LT_TAGVAR(inherit_rpath, $1)=no 7318 -_LT_TAGVAR(module_cmds, $1)= 7319 -_LT_TAGVAR(module_expsym_cmds, $1)= 7320 -_LT_TAGVAR(link_all_deplibs, $1)=unknown 7321 -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds 7322 -_LT_TAGVAR(reload_flag, $1)=$reload_flag 7323 -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds 7324 -_LT_TAGVAR(no_undefined_flag, $1)= 7325 -_LT_TAGVAR(whole_archive_flag_spec, $1)= 7326 -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no 7327 - 7328 -# Source file extension for fc test sources. 7329 -ac_ext=${ac_fc_srcext-f} 7330 - 7331 -# Object file extension for compiled fc test sources. 7332 -objext=o 7333 -_LT_TAGVAR(objext, $1)=$objext 7334 - 7335 -# No sense in running all these tests if we already determined that 7336 -# the FC compiler isn't working. Some variables (like enable_shared) 7337 -# are currently assumed to apply to all compilers on this platform, 7338 -# and will be corrupted by setting them based on a non-working compiler. 7339 -if test "$_lt_disable_FC" != yes; then 7340 - # Code to be used in simple compile tests 7341 - lt_simple_compile_test_code="\ 7342 - subroutine t 7343 - return 7344 - end 7345 -" 7346 - 7347 - # Code to be used in simple link tests 7348 - lt_simple_link_test_code="\ 7349 - program t 7350 - end 7351 -" 7352 - 7353 - # ltmain only uses $CC for tagged configurations so make sure $CC is set. 7354 - _LT_TAG_COMPILER 7355 - 7356 - # save warnings/boilerplate of simple test code 7357 - _LT_COMPILER_BOILERPLATE 7358 - _LT_LINKER_BOILERPLATE 7359 - 7360 - # Allow CC to be a program name with arguments. 7361 - lt_save_CC="$CC" 7362 - lt_save_GCC=$GCC 7363 - lt_save_CFLAGS=$CFLAGS 7364 - CC=${FC-"f95"} 7365 - CFLAGS=$FCFLAGS 7366 - compiler=$CC 7367 - GCC=$ac_cv_fc_compiler_gnu 7368 - 7369 - _LT_TAGVAR(compiler, $1)=$CC 7370 - _LT_CC_BASENAME([$compiler]) 7371 - 7372 - if test -n "$compiler"; then 7373 - AC_MSG_CHECKING([if libtool supports shared libraries]) 7374 - AC_MSG_RESULT([$can_build_shared]) 7375 - 7376 - AC_MSG_CHECKING([whether to build shared libraries]) 7377 - test "$can_build_shared" = "no" && enable_shared=no 7378 - 7379 - # On AIX, shared libraries and static libraries use the same namespace, and 7380 - # are all built from PIC. 7381 - case $host_os in 7382 - aix3*) 7383 - test "$enable_shared" = yes && enable_static=no 7384 - if test -n "$RANLIB"; then 7385 - archive_cmds="$archive_cmds~\$RANLIB \$lib" 7386 - postinstall_cmds='$RANLIB $lib' 7387 - fi 7388 - ;; 7389 - aix[[4-9]]*) 7390 - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then 7391 - test "$enable_shared" = yes && enable_static=no 7392 - fi 7393 - ;; 7394 - esac 7395 - AC_MSG_RESULT([$enable_shared]) 7396 - 7397 - AC_MSG_CHECKING([whether to build static libraries]) 7398 - # Make sure either enable_shared or enable_static is yes. 7399 - test "$enable_shared" = yes || enable_static=yes 7400 - AC_MSG_RESULT([$enable_static]) 7401 - 7402 - _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" 7403 - _LT_TAGVAR(LD, $1)="$LD" 7404 - 7405 - ## CAVEAT EMPTOR: 7406 - ## There is no encapsulation within the following macros, do not change 7407 - ## the running order or otherwise move them around unless you know exactly 7408 - ## what you are doing... 7409 - _LT_SYS_HIDDEN_LIBDEPS($1) 7410 - _LT_COMPILER_PIC($1) 7411 - _LT_COMPILER_C_O($1) 7412 - _LT_COMPILER_FILE_LOCKS($1) 7413 - _LT_LINKER_SHLIBS($1) 7414 - _LT_SYS_DYNAMIC_LINKER($1) 7415 - _LT_LINKER_HARDCODE_LIBPATH($1) 7416 - 7417 - _LT_CONFIG($1) 7418 - fi # test -n "$compiler" 7419 - 7420 - GCC=$lt_save_GCC 7421 - CC=$lt_save_CC 7422 - CFLAGS=$lt_save_CFLAGS 7423 -fi # test "$_lt_disable_FC" != yes 7424 - 7425 -AC_LANG_POP 7426 -])# _LT_LANG_FC_CONFIG 7427 - 7428 - 7429 -# _LT_LANG_GCJ_CONFIG([TAG]) 7430 -# -------------------------- 7431 -# Ensure that the configuration variables for the GNU Java Compiler compiler 7432 -# are suitably defined. These variables are subsequently used by _LT_CONFIG 7433 -# to write the compiler configuration to `libtool'. 7434 -m4_defun([_LT_LANG_GCJ_CONFIG], 7435 -[AC_REQUIRE([LT_PROG_GCJ])dnl 7436 -AC_LANG_SAVE 7437 - 7438 -# Source file extension for Java test sources. 7439 -ac_ext=java 7440 - 7441 -# Object file extension for compiled Java test sources. 7442 -objext=o 7443 -_LT_TAGVAR(objext, $1)=$objext 7444 - 7445 -# Code to be used in simple compile tests 7446 -lt_simple_compile_test_code="class foo {}" 7447 - 7448 -# Code to be used in simple link tests 7449 -lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' 7450 - 7451 -# ltmain only uses $CC for tagged configurations so make sure $CC is set. 7452 -_LT_TAG_COMPILER 7453 - 7454 -# save warnings/boilerplate of simple test code 7455 -_LT_COMPILER_BOILERPLATE 7456 -_LT_LINKER_BOILERPLATE 7457 - 7458 -# Allow CC to be a program name with arguments. 7459 -lt_save_CC=$CC 7460 -lt_save_CFLAGS=$CFLAGS 7461 -lt_save_GCC=$GCC 7462 -GCC=yes 7463 -CC=${GCJ-"gcj"} 7464 -CFLAGS=$GCJFLAGS 7465 -compiler=$CC 7466 -_LT_TAGVAR(compiler, $1)=$CC 7467 -_LT_TAGVAR(LD, $1)="$LD" 7468 -_LT_CC_BASENAME([$compiler]) 7469 - 7470 -# GCJ did not exist at the time GCC didn't implicitly link libc in. 7471 -_LT_TAGVAR(archive_cmds_need_lc, $1)=no 7472 - 7473 -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds 7474 -_LT_TAGVAR(reload_flag, $1)=$reload_flag 7475 -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds 7476 - 7477 -## CAVEAT EMPTOR: 7478 -## There is no encapsulation within the following macros, do not change 7479 -## the running order or otherwise move them around unless you know exactly 7480 -## what you are doing... 7481 -if test -n "$compiler"; then 7482 - _LT_COMPILER_NO_RTTI($1) 7483 - _LT_COMPILER_PIC($1) 7484 - _LT_COMPILER_C_O($1) 7485 - _LT_COMPILER_FILE_LOCKS($1) 7486 - _LT_LINKER_SHLIBS($1) 7487 - _LT_LINKER_HARDCODE_LIBPATH($1) 7488 - 7489 - _LT_CONFIG($1) 7490 -fi 7491 - 7492 -AC_LANG_RESTORE 7493 - 7494 -GCC=$lt_save_GCC 7495 -CC=$lt_save_CC 7496 -CFLAGS=$lt_save_CFLAGS 7497 -])# _LT_LANG_GCJ_CONFIG 7498 - 7499 - 7500 -# _LT_LANG_GO_CONFIG([TAG]) 7501 -# -------------------------- 7502 -# Ensure that the configuration variables for the GNU Go compiler 7503 -# are suitably defined. These variables are subsequently used by _LT_CONFIG 7504 -# to write the compiler configuration to `libtool'. 7505 -m4_defun([_LT_LANG_GO_CONFIG], 7506 -[AC_REQUIRE([LT_PROG_GO])dnl 7507 -AC_LANG_SAVE 7508 - 7509 -# Source file extension for Go test sources. 7510 -ac_ext=go 7511 - 7512 -# Object file extension for compiled Go test sources. 7513 -objext=o 7514 -_LT_TAGVAR(objext, $1)=$objext 7515 - 7516 -# Code to be used in simple compile tests 7517 -lt_simple_compile_test_code="package main; func main() { }" 7518 - 7519 -# Code to be used in simple link tests 7520 -lt_simple_link_test_code='package main; func main() { }' 7521 - 7522 -# ltmain only uses $CC for tagged configurations so make sure $CC is set. 7523 -_LT_TAG_COMPILER 7524 - 7525 -# save warnings/boilerplate of simple test code 7526 -_LT_COMPILER_BOILERPLATE 7527 -_LT_LINKER_BOILERPLATE 7528 - 7529 -# Allow CC to be a program name with arguments. 7530 -lt_save_CC=$CC 7531 -lt_save_CFLAGS=$CFLAGS 7532 -lt_save_GCC=$GCC 7533 -GCC=yes 7534 -CC=${GOC-"gccgo"} 7535 -CFLAGS=$GOFLAGS 7536 -compiler=$CC 7537 -_LT_TAGVAR(compiler, $1)=$CC 7538 -_LT_TAGVAR(LD, $1)="$LD" 7539 -_LT_CC_BASENAME([$compiler]) 7540 - 7541 -# Go did not exist at the time GCC didn't implicitly link libc in. 7542 -_LT_TAGVAR(archive_cmds_need_lc, $1)=no 7543 - 7544 -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds 7545 -_LT_TAGVAR(reload_flag, $1)=$reload_flag 7546 -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds 7547 - 7548 -## CAVEAT EMPTOR: 7549 -## There is no encapsulation within the following macros, do not change 7550 -## the running order or otherwise move them around unless you know exactly 7551 -## what you are doing... 7552 -if test -n "$compiler"; then 7553 - _LT_COMPILER_NO_RTTI($1) 7554 - _LT_COMPILER_PIC($1) 7555 - _LT_COMPILER_C_O($1) 7556 - _LT_COMPILER_FILE_LOCKS($1) 7557 - _LT_LINKER_SHLIBS($1) 7558 - _LT_LINKER_HARDCODE_LIBPATH($1) 7559 - 7560 - _LT_CONFIG($1) 7561 -fi 7562 - 7563 -AC_LANG_RESTORE 7564 - 7565 -GCC=$lt_save_GCC 7566 -CC=$lt_save_CC 7567 -CFLAGS=$lt_save_CFLAGS 7568 -])# _LT_LANG_GO_CONFIG 7569 - 7570 - 7571 -# _LT_LANG_RC_CONFIG([TAG]) 7572 -# ------------------------- 7573 -# Ensure that the configuration variables for the Windows resource compiler 7574 -# are suitably defined. These variables are subsequently used by _LT_CONFIG 7575 -# to write the compiler configuration to `libtool'. 7576 -m4_defun([_LT_LANG_RC_CONFIG], 7577 -[AC_REQUIRE([LT_PROG_RC])dnl 7578 -AC_LANG_SAVE 7579 - 7580 -# Source file extension for RC test sources. 7581 -ac_ext=rc 7582 - 7583 -# Object file extension for compiled RC test sources. 7584 -objext=o 7585 -_LT_TAGVAR(objext, $1)=$objext 7586 - 7587 -# Code to be used in simple compile tests 7588 -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' 7589 - 7590 -# Code to be used in simple link tests 7591 -lt_simple_link_test_code="$lt_simple_compile_test_code" 7592 - 7593 -# ltmain only uses $CC for tagged configurations so make sure $CC is set. 7594 -_LT_TAG_COMPILER 7595 - 7596 -# save warnings/boilerplate of simple test code 7597 -_LT_COMPILER_BOILERPLATE 7598 -_LT_LINKER_BOILERPLATE 7599 - 7600 -# Allow CC to be a program name with arguments. 7601 -lt_save_CC="$CC" 7602 -lt_save_CFLAGS=$CFLAGS 7603 -lt_save_GCC=$GCC 7604 -GCC= 7605 -CC=${RC-"windres"} 7606 -CFLAGS= 7607 -compiler=$CC 7608 -_LT_TAGVAR(compiler, $1)=$CC 7609 -_LT_CC_BASENAME([$compiler]) 7610 -_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes 7611 - 7612 -if test -n "$compiler"; then 7613 - : 7614 - _LT_CONFIG($1) 7615 -fi 7616 - 7617 -GCC=$lt_save_GCC 7618 -AC_LANG_RESTORE 7619 -CC=$lt_save_CC 7620 -CFLAGS=$lt_save_CFLAGS 7621 -])# _LT_LANG_RC_CONFIG 7622 - 7623 - 7624 -# LT_PROG_GCJ 7625 -# ----------- 7626 -AC_DEFUN([LT_PROG_GCJ], 7627 -[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], 7628 - [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], 7629 - [AC_CHECK_TOOL(GCJ, gcj,) 7630 - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" 7631 - AC_SUBST(GCJFLAGS)])])[]dnl 7632 -]) 7633 - 7634 -# Old name: 7635 -AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) 7636 -dnl aclocal-1.4 backwards compatibility: 7637 -dnl AC_DEFUN([LT_AC_PROG_GCJ], []) 7638 - 7639 - 7640 -# LT_PROG_GO 7641 -# ---------- 7642 -AC_DEFUN([LT_PROG_GO], 7643 -[AC_CHECK_TOOL(GOC, gccgo,) 7644 -]) 7645 - 7646 - 7647 -# LT_PROG_RC 7648 -# ---------- 7649 -AC_DEFUN([LT_PROG_RC], 7650 -[AC_CHECK_TOOL(RC, windres,) 7651 -]) 7652 - 7653 -# Old name: 7654 -AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) 7655 -dnl aclocal-1.4 backwards compatibility: 7656 -dnl AC_DEFUN([LT_AC_PROG_RC], []) 7657 - 7658 - 7659 -# _LT_DECL_EGREP 7660 -# -------------- 7661 -# If we don't have a new enough Autoconf to choose the best grep 7662 -# available, choose the one first in the user's PATH. 7663 -m4_defun([_LT_DECL_EGREP], 7664 -[AC_REQUIRE([AC_PROG_EGREP])dnl 7665 -AC_REQUIRE([AC_PROG_FGREP])dnl 7666 -test -z "$GREP" && GREP=grep 7667 -_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) 7668 -_LT_DECL([], [EGREP], [1], [An ERE matcher]) 7669 -_LT_DECL([], [FGREP], [1], [A literal string matcher]) 7670 -dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too 7671 -AC_SUBST([GREP]) 7672 -]) 7673 - 7674 - 7675 -# _LT_DECL_OBJDUMP 7676 -# -------------- 7677 -# If we don't have a new enough Autoconf to choose the best objdump 7678 -# available, choose the one first in the user's PATH. 7679 -m4_defun([_LT_DECL_OBJDUMP], 7680 -[AC_CHECK_TOOL(OBJDUMP, objdump, false) 7681 -test -z "$OBJDUMP" && OBJDUMP=objdump 7682 -_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) 7683 -AC_SUBST([OBJDUMP]) 7684 -]) 7685 - 7686 -# _LT_DECL_DLLTOOL 7687 -# ---------------- 7688 -# Ensure DLLTOOL variable is set. 7689 -m4_defun([_LT_DECL_DLLTOOL], 7690 -[AC_CHECK_TOOL(DLLTOOL, dlltool, false) 7691 -test -z "$DLLTOOL" && DLLTOOL=dlltool 7692 -_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) 7693 -AC_SUBST([DLLTOOL]) 7694 -]) 7695 - 7696 -# _LT_DECL_SED 7697 -# ------------ 7698 -# Check for a fully-functional sed program, that truncates 7699 -# as few characters as possible. Prefer GNU sed if found. 7700 -m4_defun([_LT_DECL_SED], 7701 -[AC_PROG_SED 7702 -test -z "$SED" && SED=sed 7703 -Xsed="$SED -e 1s/^X//" 7704 -_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) 7705 -_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], 7706 - [Sed that helps us avoid accidentally triggering echo(1) options like -n]) 7707 -])# _LT_DECL_SED 7708 - 7709 -m4_ifndef([AC_PROG_SED], [ 7710 -############################################################ 7711 -# NOTE: This macro has been submitted for inclusion into # 7712 -# GNU Autoconf as AC_PROG_SED. When it is available in # 7713 -# a released version of Autoconf we should remove this # 7714 -# macro and use it instead. # 7715 -############################################################ 7716 - 7717 -m4_defun([AC_PROG_SED], 7718 -[AC_MSG_CHECKING([for a sed that does not truncate output]) 7719 -AC_CACHE_VAL(lt_cv_path_SED, 7720 -[# Loop through the user's path and test for sed and gsed. 7721 -# Then use that list of sed's as ones to test for truncation. 7722 -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 7723 -for as_dir in $PATH 7724 -do 7725 - IFS=$as_save_IFS 7726 - test -z "$as_dir" && as_dir=. 7727 - for lt_ac_prog in sed gsed; do 7728 - for ac_exec_ext in '' $ac_executable_extensions; do 7729 - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then 7730 - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" 7731 - fi 7732 - done 7733 - done 7734 -done 7735 -IFS=$as_save_IFS 7736 -lt_ac_max=0 7737 -lt_ac_count=0 7738 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris 7739 -# along with /bin/sed that truncates output. 7740 -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do 7741 - test ! -f $lt_ac_sed && continue 7742 - cat /dev/null > conftest.in 7743 - lt_ac_count=0 7744 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in 7745 - # Check for GNU sed and select it if it is found. 7746 - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then 7747 - lt_cv_path_SED=$lt_ac_sed 7748 - break 7749 - fi 7750 - while true; do 7751 - cat conftest.in conftest.in >conftest.tmp 7752 - mv conftest.tmp conftest.in 7753 - cp conftest.in conftest.nl 7754 - echo >>conftest.nl 7755 - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break 7756 - cmp -s conftest.out conftest.nl || break 7757 - # 10000 chars as input seems more than enough 7758 - test $lt_ac_count -gt 10 && break 7759 - lt_ac_count=`expr $lt_ac_count + 1` 7760 - if test $lt_ac_count -gt $lt_ac_max; then 7761 - lt_ac_max=$lt_ac_count 7762 - lt_cv_path_SED=$lt_ac_sed 7763 - fi 7764 - done 7765 -done 7766 -]) 7767 -SED=$lt_cv_path_SED 7768 -AC_SUBST([SED]) 7769 -AC_MSG_RESULT([$SED]) 7770 -])#AC_PROG_SED 7771 -])#m4_ifndef 7772 - 7773 -# Old name: 7774 -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) 7775 -dnl aclocal-1.4 backwards compatibility: 7776 -dnl AC_DEFUN([LT_AC_PROG_SED], []) 7777 - 7778 - 7779 -# _LT_CHECK_SHELL_FEATURES 7780 -# ------------------------ 7781 -# Find out whether the shell is Bourne or XSI compatible, 7782 -# or has some other useful features. 7783 -m4_defun([_LT_CHECK_SHELL_FEATURES], 7784 -[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) 7785 -# Try some XSI features 7786 -xsi_shell=no 7787 -( _lt_dummy="a/b/c" 7788 - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ 7789 - = c,a/b,b/c, \ 7790 - && eval 'test $(( 1 + 1 )) -eq 2 \ 7791 - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ 7792 - && xsi_shell=yes 7793 -AC_MSG_RESULT([$xsi_shell]) 7794 -_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) 7795 - 7796 -AC_MSG_CHECKING([whether the shell understands "+="]) 7797 -lt_shell_append=no 7798 -( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ 7799 - >/dev/null 2>&1 \ 7800 - && lt_shell_append=yes 7801 -AC_MSG_RESULT([$lt_shell_append]) 7802 -_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) 7803 - 7804 -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then 7805 - lt_unset=unset 7806 -else 7807 - lt_unset=false 7808 -fi 7809 -_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl 7810 - 7811 -# test EBCDIC or ASCII 7812 -case `echo X|tr X '\101'` in 7813 - A) # ASCII based system 7814 - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr 7815 - lt_SP2NL='tr \040 \012' 7816 - lt_NL2SP='tr \015\012 \040\040' 7817 - ;; 7818 - *) # EBCDIC based system 7819 - lt_SP2NL='tr \100 \n' 7820 - lt_NL2SP='tr \r\n \100\100' 7821 - ;; 7822 -esac 7823 -_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl 7824 -_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl 7825 -])# _LT_CHECK_SHELL_FEATURES 7826 - 7827 - 7828 -# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) 7829 -# ------------------------------------------------------ 7830 -# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and 7831 -# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. 7832 -m4_defun([_LT_PROG_FUNCTION_REPLACE], 7833 -[dnl { 7834 -sed -e '/^$1 ()$/,/^} # $1 /c\ 7835 -$1 ()\ 7836 -{\ 7837 -m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) 7838 -} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ 7839 - && mv -f "$cfgfile.tmp" "$cfgfile" \ 7840 - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") 7841 -test 0 -eq $? || _lt_function_replace_fail=: 7842 -]) 7843 - 7844 - 7845 -# _LT_PROG_REPLACE_SHELLFNS 7846 -# ------------------------- 7847 -# Replace existing portable implementations of several shell functions with 7848 -# equivalent extended shell implementations where those features are available.. 7849 -m4_defun([_LT_PROG_REPLACE_SHELLFNS], 7850 -[if test x"$xsi_shell" = xyes; then 7851 - _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl 7852 - case ${1} in 7853 - */*) func_dirname_result="${1%/*}${2}" ;; 7854 - * ) func_dirname_result="${3}" ;; 7855 - esac]) 7856 - 7857 - _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl 7858 - func_basename_result="${1##*/}"]) 7859 - 7860 - _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl 7861 - case ${1} in 7862 - */*) func_dirname_result="${1%/*}${2}" ;; 7863 - * ) func_dirname_result="${3}" ;; 7864 - esac 7865 - func_basename_result="${1##*/}"]) 7866 - 7867 - _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl 7868 - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 7869 - # positional parameters, so assign one to ordinary parameter first. 7870 - func_stripname_result=${3} 7871 - func_stripname_result=${func_stripname_result#"${1}"} 7872 - func_stripname_result=${func_stripname_result%"${2}"}]) 7873 - 7874 - _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl 7875 - func_split_long_opt_name=${1%%=*} 7876 - func_split_long_opt_arg=${1#*=}]) 7877 - 7878 - _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl 7879 - func_split_short_opt_arg=${1#??} 7880 - func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) 7881 - 7882 - _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl 7883 - case ${1} in 7884 - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; 7885 - *) func_lo2o_result=${1} ;; 7886 - esac]) 7887 - 7888 - _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) 7889 - 7890 - _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) 7891 - 7892 - _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) 7893 -fi 7894 - 7895 -if test x"$lt_shell_append" = xyes; then 7896 - _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) 7897 - 7898 - _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl 7899 - func_quote_for_eval "${2}" 7900 -dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ 7901 - eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) 7902 - 7903 - # Save a `func_append' function call where possible by direct use of '+=' 7904 - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ 7905 - && mv -f "$cfgfile.tmp" "$cfgfile" \ 7906 - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") 7907 - test 0 -eq $? || _lt_function_replace_fail=: 7908 -else 7909 - # Save a `func_append' function call even when '+=' is not available 7910 - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ 7911 - && mv -f "$cfgfile.tmp" "$cfgfile" \ 7912 - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") 7913 - test 0 -eq $? || _lt_function_replace_fail=: 7914 -fi 7915 - 7916 -if test x"$_lt_function_replace_fail" = x":"; then 7917 - AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) 7918 -fi 7919 -]) 7920 - 7921 -# _LT_PATH_CONVERSION_FUNCTIONS 7922 -# ----------------------------- 7923 -# Determine which file name conversion functions should be used by 7924 -# func_to_host_file (and, implicitly, by func_to_host_path). These are needed 7925 -# for certain cross-compile configurations and native mingw. 7926 -m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], 7927 -[AC_REQUIRE([AC_CANONICAL_HOST])dnl 7928 -AC_REQUIRE([AC_CANONICAL_BUILD])dnl 7929 -AC_MSG_CHECKING([how to convert $build file names to $host format]) 7930 -AC_CACHE_VAL(lt_cv_to_host_file_cmd, 7931 -[case $host in 7932 - *-*-mingw* ) 7933 - case $build in 7934 - *-*-mingw* ) # actually msys 7935 - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 7936 - ;; 7937 - *-*-cygwin* ) 7938 - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 7939 - ;; 7940 - * ) # otherwise, assume *nix 7941 - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 7942 - ;; 7943 - esac 7944 - ;; 7945 - *-*-cygwin* ) 7946 - case $build in 7947 - *-*-mingw* ) # actually msys 7948 - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin 7949 - ;; 7950 - *-*-cygwin* ) 7951 - lt_cv_to_host_file_cmd=func_convert_file_noop 7952 - ;; 7953 - * ) # otherwise, assume *nix 7954 - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin 7955 - ;; 7956 - esac 7957 - ;; 7958 - * ) # unhandled hosts (and "normal" native builds) 7959 - lt_cv_to_host_file_cmd=func_convert_file_noop 7960 - ;; 7961 -esac 7962 -]) 7963 -to_host_file_cmd=$lt_cv_to_host_file_cmd 7964 -AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) 7965 -_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], 7966 - [0], [convert $build file names to $host format])dnl 7967 - 7968 -AC_MSG_CHECKING([how to convert $build file names to toolchain format]) 7969 -AC_CACHE_VAL(lt_cv_to_tool_file_cmd, 7970 -[#assume ordinary cross tools, or native build. 7971 -lt_cv_to_tool_file_cmd=func_convert_file_noop 7972 -case $host in 7973 - *-*-mingw* ) 7974 - case $build in 7975 - *-*-mingw* ) # actually msys 7976 - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 7977 - ;; 7978 - esac 7979 - ;; 7980 -esac 7981 -]) 7982 -to_tool_file_cmd=$lt_cv_to_tool_file_cmd 7983 -AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) 7984 -_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], 7985 - [0], [convert $build files to toolchain format])dnl 7986 -])# _LT_PATH_CONVERSION_FUNCTIONS
Deleted m4/ltoptions.m4.
1 -# Helper functions for option handling. -*- Autoconf -*- 2 -# 3 -# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, 4 -# Inc. 5 -# Written by Gary V. Vaughan, 2004 6 -# 7 -# This file is free software; the Free Software Foundation gives 8 -# unlimited permission to copy and/or distribute it, with or without 9 -# modifications, as long as this notice is preserved. 10 - 11 -# serial 7 ltoptions.m4 12 - 13 -# This is to help aclocal find these macros, as it can't see m4_define. 14 -AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) 15 - 16 - 17 -# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) 18 -# ------------------------------------------ 19 -m4_define([_LT_MANGLE_OPTION], 20 -[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) 21 - 22 - 23 -# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) 24 -# --------------------------------------- 25 -# Set option OPTION-NAME for macro MACRO-NAME, and if there is a 26 -# matching handler defined, dispatch to it. Other OPTION-NAMEs are 27 -# saved as a flag. 28 -m4_define([_LT_SET_OPTION], 29 -[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl 30 -m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), 31 - _LT_MANGLE_DEFUN([$1], [$2]), 32 - [m4_warning([Unknown $1 option `$2'])])[]dnl 33 -]) 34 - 35 - 36 -# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) 37 -# ------------------------------------------------------------ 38 -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. 39 -m4_define([_LT_IF_OPTION], 40 -[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) 41 - 42 - 43 -# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) 44 -# ------------------------------------------------------- 45 -# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME 46 -# are set. 47 -m4_define([_LT_UNLESS_OPTIONS], 48 -[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), 49 - [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), 50 - [m4_define([$0_found])])])[]dnl 51 -m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 52 -])[]dnl 53 -]) 54 - 55 - 56 -# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) 57 -# ---------------------------------------- 58 -# OPTION-LIST is a space-separated list of Libtool options associated 59 -# with MACRO-NAME. If any OPTION has a matching handler declared with 60 -# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about 61 -# the unknown option and exit. 62 -m4_defun([_LT_SET_OPTIONS], 63 -[# Set options 64 -m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), 65 - [_LT_SET_OPTION([$1], _LT_Option)]) 66 - 67 -m4_if([$1],[LT_INIT],[ 68 - dnl 69 - dnl Simply set some default values (i.e off) if boolean options were not 70 - dnl specified: 71 - _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no 72 - ]) 73 - _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no 74 - ]) 75 - dnl 76 - dnl If no reference was made to various pairs of opposing options, then 77 - dnl we run the default mode handler for the pair. For example, if neither 78 - dnl `shared' nor `disable-shared' was passed, we enable building of shared 79 - dnl archives by default: 80 - _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) 81 - _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) 82 - _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) 83 - _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], 84 - [_LT_ENABLE_FAST_INSTALL]) 85 - ]) 86 -])# _LT_SET_OPTIONS 87 - 88 - 89 -## --------------------------------- ## 90 -## Macros to handle LT_INIT options. ## 91 -## --------------------------------- ## 92 - 93 -# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) 94 -# ----------------------------------------- 95 -m4_define([_LT_MANGLE_DEFUN], 96 -[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) 97 - 98 - 99 -# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) 100 -# ----------------------------------------------- 101 -m4_define([LT_OPTION_DEFINE], 102 -[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl 103 -])# LT_OPTION_DEFINE 104 - 105 - 106 -# dlopen 107 -# ------ 108 -LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes 109 -]) 110 - 111 -AU_DEFUN([AC_LIBTOOL_DLOPEN], 112 -[_LT_SET_OPTION([LT_INIT], [dlopen]) 113 -AC_DIAGNOSE([obsolete], 114 -[$0: Remove this warning and the call to _LT_SET_OPTION when you 115 -put the `dlopen' option into LT_INIT's first parameter.]) 116 -]) 117 - 118 -dnl aclocal-1.4 backwards compatibility: 119 -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) 120 - 121 - 122 -# win32-dll 123 -# --------- 124 -# Declare package support for building win32 dll's. 125 -LT_OPTION_DEFINE([LT_INIT], [win32-dll], 126 -[enable_win32_dll=yes 127 - 128 -case $host in 129 -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) 130 - AC_CHECK_TOOL(AS, as, false) 131 - AC_CHECK_TOOL(DLLTOOL, dlltool, false) 132 - AC_CHECK_TOOL(OBJDUMP, objdump, false) 133 - ;; 134 -esac 135 - 136 -test -z "$AS" && AS=as 137 -_LT_DECL([], [AS], [1], [Assembler program])dnl 138 - 139 -test -z "$DLLTOOL" && DLLTOOL=dlltool 140 -_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl 141 - 142 -test -z "$OBJDUMP" && OBJDUMP=objdump 143 -_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl 144 -])# win32-dll 145 - 146 -AU_DEFUN([AC_LIBTOOL_WIN32_DLL], 147 -[AC_REQUIRE([AC_CANONICAL_HOST])dnl 148 -_LT_SET_OPTION([LT_INIT], [win32-dll]) 149 -AC_DIAGNOSE([obsolete], 150 -[$0: Remove this warning and the call to _LT_SET_OPTION when you 151 -put the `win32-dll' option into LT_INIT's first parameter.]) 152 -]) 153 - 154 -dnl aclocal-1.4 backwards compatibility: 155 -dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) 156 - 157 - 158 -# _LT_ENABLE_SHARED([DEFAULT]) 159 -# ---------------------------- 160 -# implement the --enable-shared flag, and supports the `shared' and 161 -# `disable-shared' LT_INIT options. 162 -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 163 -m4_define([_LT_ENABLE_SHARED], 164 -[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl 165 -AC_ARG_ENABLE([shared], 166 - [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], 167 - [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], 168 - [p=${PACKAGE-default} 169 - case $enableval in 170 - yes) enable_shared=yes ;; 171 - no) enable_shared=no ;; 172 - *) 173 - enable_shared=no 174 - # Look at the argument we got. We use all the common list separators. 175 - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 176 - for pkg in $enableval; do 177 - IFS="$lt_save_ifs" 178 - if test "X$pkg" = "X$p"; then 179 - enable_shared=yes 180 - fi 181 - done 182 - IFS="$lt_save_ifs" 183 - ;; 184 - esac], 185 - [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) 186 - 187 - _LT_DECL([build_libtool_libs], [enable_shared], [0], 188 - [Whether or not to build shared libraries]) 189 -])# _LT_ENABLE_SHARED 190 - 191 -LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) 192 -LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) 193 - 194 -# Old names: 195 -AC_DEFUN([AC_ENABLE_SHARED], 196 -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) 197 -]) 198 - 199 -AC_DEFUN([AC_DISABLE_SHARED], 200 -[_LT_SET_OPTION([LT_INIT], [disable-shared]) 201 -]) 202 - 203 -AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) 204 -AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) 205 - 206 -dnl aclocal-1.4 backwards compatibility: 207 -dnl AC_DEFUN([AM_ENABLE_SHARED], []) 208 -dnl AC_DEFUN([AM_DISABLE_SHARED], []) 209 - 210 - 211 - 212 -# _LT_ENABLE_STATIC([DEFAULT]) 213 -# ---------------------------- 214 -# implement the --enable-static flag, and support the `static' and 215 -# `disable-static' LT_INIT options. 216 -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 217 -m4_define([_LT_ENABLE_STATIC], 218 -[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl 219 -AC_ARG_ENABLE([static], 220 - [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], 221 - [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], 222 - [p=${PACKAGE-default} 223 - case $enableval in 224 - yes) enable_static=yes ;; 225 - no) enable_static=no ;; 226 - *) 227 - enable_static=no 228 - # Look at the argument we got. We use all the common list separators. 229 - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 230 - for pkg in $enableval; do 231 - IFS="$lt_save_ifs" 232 - if test "X$pkg" = "X$p"; then 233 - enable_static=yes 234 - fi 235 - done 236 - IFS="$lt_save_ifs" 237 - ;; 238 - esac], 239 - [enable_static=]_LT_ENABLE_STATIC_DEFAULT) 240 - 241 - _LT_DECL([build_old_libs], [enable_static], [0], 242 - [Whether or not to build static libraries]) 243 -])# _LT_ENABLE_STATIC 244 - 245 -LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) 246 -LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) 247 - 248 -# Old names: 249 -AC_DEFUN([AC_ENABLE_STATIC], 250 -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) 251 -]) 252 - 253 -AC_DEFUN([AC_DISABLE_STATIC], 254 -[_LT_SET_OPTION([LT_INIT], [disable-static]) 255 -]) 256 - 257 -AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) 258 -AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) 259 - 260 -dnl aclocal-1.4 backwards compatibility: 261 -dnl AC_DEFUN([AM_ENABLE_STATIC], []) 262 -dnl AC_DEFUN([AM_DISABLE_STATIC], []) 263 - 264 - 265 - 266 -# _LT_ENABLE_FAST_INSTALL([DEFAULT]) 267 -# ---------------------------------- 268 -# implement the --enable-fast-install flag, and support the `fast-install' 269 -# and `disable-fast-install' LT_INIT options. 270 -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 271 -m4_define([_LT_ENABLE_FAST_INSTALL], 272 -[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl 273 -AC_ARG_ENABLE([fast-install], 274 - [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], 275 - [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], 276 - [p=${PACKAGE-default} 277 - case $enableval in 278 - yes) enable_fast_install=yes ;; 279 - no) enable_fast_install=no ;; 280 - *) 281 - enable_fast_install=no 282 - # Look at the argument we got. We use all the common list separators. 283 - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 284 - for pkg in $enableval; do 285 - IFS="$lt_save_ifs" 286 - if test "X$pkg" = "X$p"; then 287 - enable_fast_install=yes 288 - fi 289 - done 290 - IFS="$lt_save_ifs" 291 - ;; 292 - esac], 293 - [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) 294 - 295 -_LT_DECL([fast_install], [enable_fast_install], [0], 296 - [Whether or not to optimize for fast installation])dnl 297 -])# _LT_ENABLE_FAST_INSTALL 298 - 299 -LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) 300 -LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) 301 - 302 -# Old names: 303 -AU_DEFUN([AC_ENABLE_FAST_INSTALL], 304 -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) 305 -AC_DIAGNOSE([obsolete], 306 -[$0: Remove this warning and the call to _LT_SET_OPTION when you put 307 -the `fast-install' option into LT_INIT's first parameter.]) 308 -]) 309 - 310 -AU_DEFUN([AC_DISABLE_FAST_INSTALL], 311 -[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) 312 -AC_DIAGNOSE([obsolete], 313 -[$0: Remove this warning and the call to _LT_SET_OPTION when you put 314 -the `disable-fast-install' option into LT_INIT's first parameter.]) 315 -]) 316 - 317 -dnl aclocal-1.4 backwards compatibility: 318 -dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) 319 -dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) 320 - 321 - 322 -# _LT_WITH_PIC([MODE]) 323 -# -------------------- 324 -# implement the --with-pic flag, and support the `pic-only' and `no-pic' 325 -# LT_INIT options. 326 -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. 327 -m4_define([_LT_WITH_PIC], 328 -[AC_ARG_WITH([pic], 329 - [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], 330 - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], 331 - [lt_p=${PACKAGE-default} 332 - case $withval in 333 - yes|no) pic_mode=$withval ;; 334 - *) 335 - pic_mode=default 336 - # Look at the argument we got. We use all the common list separators. 337 - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 338 - for lt_pkg in $withval; do 339 - IFS="$lt_save_ifs" 340 - if test "X$lt_pkg" = "X$lt_p"; then 341 - pic_mode=yes 342 - fi 343 - done 344 - IFS="$lt_save_ifs" 345 - ;; 346 - esac], 347 - [pic_mode=default]) 348 - 349 -test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) 350 - 351 -_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl 352 -])# _LT_WITH_PIC 353 - 354 -LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) 355 -LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) 356 - 357 -# Old name: 358 -AU_DEFUN([AC_LIBTOOL_PICMODE], 359 -[_LT_SET_OPTION([LT_INIT], [pic-only]) 360 -AC_DIAGNOSE([obsolete], 361 -[$0: Remove this warning and the call to _LT_SET_OPTION when you 362 -put the `pic-only' option into LT_INIT's first parameter.]) 363 -]) 364 - 365 -dnl aclocal-1.4 backwards compatibility: 366 -dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) 367 - 368 -## ----------------- ## 369 -## LTDL_INIT Options ## 370 -## ----------------- ## 371 - 372 -m4_define([_LTDL_MODE], []) 373 -LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], 374 - [m4_define([_LTDL_MODE], [nonrecursive])]) 375 -LT_OPTION_DEFINE([LTDL_INIT], [recursive], 376 - [m4_define([_LTDL_MODE], [recursive])]) 377 -LT_OPTION_DEFINE([LTDL_INIT], [subproject], 378 - [m4_define([_LTDL_MODE], [subproject])]) 379 - 380 -m4_define([_LTDL_TYPE], []) 381 -LT_OPTION_DEFINE([LTDL_INIT], [installable], 382 - [m4_define([_LTDL_TYPE], [installable])]) 383 -LT_OPTION_DEFINE([LTDL_INIT], [convenience], 384 - [m4_define([_LTDL_TYPE], [convenience])])
Deleted m4/ltsugar.m4.
1 -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 -# 3 -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 -# Written by Gary V. Vaughan, 2004 5 -# 6 -# This file is free software; the Free Software Foundation gives 7 -# unlimited permission to copy and/or distribute it, with or without 8 -# modifications, as long as this notice is preserved. 9 - 10 -# serial 6 ltsugar.m4 11 - 12 -# This is to help aclocal find these macros, as it can't see m4_define. 13 -AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 - 15 - 16 -# lt_join(SEP, ARG1, [ARG2...]) 17 -# ----------------------------- 18 -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 -# associated separator. 20 -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 -# versions in m4sugar had bugs. 22 -m4_define([lt_join], 23 -[m4_if([$#], [1], [], 24 - [$#], [2], [[$2]], 25 - [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 -m4_define([_lt_join], 27 -[m4_if([$#$2], [2], [], 28 - [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 - 30 - 31 -# lt_car(LIST) 32 -# lt_cdr(LIST) 33 -# ------------ 34 -# Manipulate m4 lists. 35 -# These macros are necessary as long as will still need to support 36 -# Autoconf-2.59 which quotes differently. 37 -m4_define([lt_car], [[$1]]) 38 -m4_define([lt_cdr], 39 -[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 - [$#], 1, [], 41 - [m4_dquote(m4_shift($@))])]) 42 -m4_define([lt_unquote], $1) 43 - 44 - 45 -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 -# ------------------------------------------ 47 -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 -# Note that neither SEPARATOR nor STRING are expanded; they are appended 49 -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 -# No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 -# than defined and empty). 52 -# 53 -# This macro is needed until we can rely on Autoconf 2.62, since earlier 54 -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 -m4_define([lt_append], 56 -[m4_define([$1], 57 - m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 - 59 - 60 - 61 -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 -# ---------------------------------------------------------- 63 -# Produce a SEP delimited list of all paired combinations of elements of 64 -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 -# has the form PREFIXmINFIXSUFFIXn. 66 -# Needed until we can rely on m4_combine added in Autoconf 2.62. 67 -m4_define([lt_combine], 68 -[m4_if(m4_eval([$# > 3]), [1], 69 - [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 -[[m4_foreach([_Lt_prefix], [$2], 71 - [m4_foreach([_Lt_suffix], 72 - ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 - [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 - 75 - 76 -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 -# ----------------------------------------------------------------------- 78 -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 -m4_define([lt_if_append_uniq], 81 -[m4_ifdef([$1], 82 - [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 - [lt_append([$1], [$2], [$3])$4], 84 - [$5])], 85 - [lt_append([$1], [$2], [$3])$4])]) 86 - 87 - 88 -# lt_dict_add(DICT, KEY, VALUE) 89 -# ----------------------------- 90 -m4_define([lt_dict_add], 91 -[m4_define([$1($2)], [$3])]) 92 - 93 - 94 -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 -# -------------------------------------------- 96 -m4_define([lt_dict_add_subkey], 97 -[m4_define([$1($2:$3)], [$4])]) 98 - 99 - 100 -# lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 -# ---------------------------------- 102 -m4_define([lt_dict_fetch], 103 -[m4_ifval([$3], 104 - m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 - m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 - 107 - 108 -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 -# ----------------------------------------------------------------- 110 -m4_define([lt_if_dict_fetch], 111 -[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 - [$5], 113 - [$6])]) 114 - 115 - 116 -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 -# -------------------------------------------------------------- 118 -m4_define([lt_dict_filter], 119 -[m4_if([$5], [], [], 120 - [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 - lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 - [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 -])
Deleted m4/ltversion.m4.
1 -# ltversion.m4 -- version numbers -*- Autoconf -*- 2 -# 3 -# Copyright (C) 2004 Free Software Foundation, Inc. 4 -# Written by Scott James Remnant, 2004 5 -# 6 -# This file is free software; the Free Software Foundation gives 7 -# unlimited permission to copy and/or distribute it, with or without 8 -# modifications, as long as this notice is preserved. 9 - 10 -# @configure_input@ 11 - 12 -# serial 3337 ltversion.m4 13 -# This file is part of GNU Libtool 14 - 15 -m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 -m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 - 18 -AC_DEFUN([LTVERSION_VERSION], 19 -[macro_version='2.4.2' 20 -macro_revision='1.3337' 21 -_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 -_LT_DECL(, macro_revision, 0) 23 -])
Deleted m4/lt~obsolete.m4.
1 -# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- 2 -# 3 -# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. 4 -# Written by Scott James Remnant, 2004. 5 -# 6 -# This file is free software; the Free Software Foundation gives 7 -# unlimited permission to copy and/or distribute it, with or without 8 -# modifications, as long as this notice is preserved. 9 - 10 -# serial 5 lt~obsolete.m4 11 - 12 -# These exist entirely to fool aclocal when bootstrapping libtool. 13 -# 14 -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) 15 -# which have later been changed to m4_define as they aren't part of the 16 -# exported API, or moved to Autoconf or Automake where they belong. 17 -# 18 -# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN 19 -# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us 20 -# using a macro with the same name in our local m4/libtool.m4 it'll 21 -# pull the old libtool.m4 in (it doesn't see our shiny new m4_define 22 -# and doesn't know about Autoconf macros at all.) 23 -# 24 -# So we provide this file, which has a silly filename so it's always 25 -# included after everything else. This provides aclocal with the 26 -# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything 27 -# because those macros already exist, or will be overwritten later. 28 -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 29 -# 30 -# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. 31 -# Yes, that means every name once taken will need to remain here until 32 -# we give up compatibility with versions before 1.7, at which point 33 -# we need to keep only those names which we still refer to. 34 - 35 -# This is to help aclocal find these macros, as it can't see m4_define. 36 -AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) 37 - 38 -m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) 39 -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) 40 -m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) 41 -m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) 42 -m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) 43 -m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) 44 -m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) 45 -m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) 46 -m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) 47 -m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) 48 -m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) 49 -m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) 50 -m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) 51 -m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) 52 -m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) 53 -m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) 54 -m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) 55 -m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) 56 -m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) 57 -m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) 58 -m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) 59 -m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) 60 -m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) 61 -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) 62 -m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) 63 -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) 64 -m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) 65 -m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) 66 -m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) 67 -m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) 68 -m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) 69 -m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) 70 -m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) 71 -m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) 72 -m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) 73 -m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) 74 -m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) 75 -m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) 76 -m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) 77 -m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) 78 -m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) 79 -m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) 80 -m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) 81 -m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) 82 -m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) 83 -m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) 84 -m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) 85 -m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) 86 -m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) 87 -m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) 88 -m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) 89 -m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) 90 -m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) 91 -m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) 92 -m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) 93 -m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) 94 -m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) 95 -m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) 96 -m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) 97 -m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) 98 -m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
Deleted missing.
1 -#! /bin/sh 2 -# Common stub for a few missing GNU programs while installing. 3 - 4 -scriptversion=2012-01-06.13; # UTC 5 - 6 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 7 -# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. 8 -# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 9 - 10 -# This program is free software; you can redistribute it and/or modify 11 -# it under the terms of the GNU General Public License as published by 12 -# the Free Software Foundation; either version 2, or (at your option) 13 -# any later version. 14 - 15 -# This program is distributed in the hope that it will be useful, 16 -# but WITHOUT ANY WARRANTY; without even the implied warranty of 17 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 -# GNU General Public License for more details. 19 - 20 -# You should have received a copy of the GNU General Public License 21 -# along with this program. If not, see <http://www.gnu.org/licenses/>. 22 - 23 -# As a special exception to the GNU General Public License, if you 24 -# distribute this file as part of a program that contains a 25 -# configuration script generated by Autoconf, you may include it under 26 -# the same distribution terms that you use for the rest of that program. 27 - 28 -if test $# -eq 0; then 29 - echo 1>&2 "Try \`$0 --help' for more information" 30 - exit 1 31 -fi 32 - 33 -run=: 34 -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' 35 -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' 36 - 37 -# In the cases where this matters, `missing' is being run in the 38 -# srcdir already. 39 -if test -f configure.ac; then 40 - configure_ac=configure.ac 41 -else 42 - configure_ac=configure.in 43 -fi 44 - 45 -msg="missing on your system" 46 - 47 -case $1 in 48 ---run) 49 - # Try to run requested program, and just exit if it succeeds. 50 - run= 51 - shift 52 - "$@" && exit 0 53 - # Exit code 63 means version mismatch. This often happens 54 - # when the user try to use an ancient version of a tool on 55 - # a file that requires a minimum version. In this case we 56 - # we should proceed has if the program had been absent, or 57 - # if --run hadn't been passed. 58 - if test $? = 63; then 59 - run=: 60 - msg="probably too old" 61 - fi 62 - ;; 63 - 64 - -h|--h|--he|--hel|--help) 65 - echo "\ 66 -$0 [OPTION]... PROGRAM [ARGUMENT]... 67 - 68 -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 69 -error status if there is no known handling for PROGRAM. 70 - 71 -Options: 72 - -h, --help display this help and exit 73 - -v, --version output version information and exit 74 - --run try to run the given command, and emulate it if it fails 75 - 76 -Supported PROGRAM values: 77 - aclocal touch file \`aclocal.m4' 78 - autoconf touch file \`configure' 79 - autoheader touch file \`config.h.in' 80 - autom4te touch the output file, or create a stub one 81 - automake touch all \`Makefile.in' files 82 - bison create \`y.tab.[ch]', if possible, from existing .[ch] 83 - flex create \`lex.yy.c', if possible, from existing .c 84 - help2man touch the output file 85 - lex create \`lex.yy.c', if possible, from existing .c 86 - makeinfo touch the output file 87 - yacc create \`y.tab.[ch]', if possible, from existing .[ch] 88 - 89 -Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and 90 -\`g' are ignored when checking the name. 91 - 92 -Send bug reports to <bug-automake@gnu.org>." 93 - exit $? 94 - ;; 95 - 96 - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 97 - echo "missing $scriptversion (GNU Automake)" 98 - exit $? 99 - ;; 100 - 101 - -*) 102 - echo 1>&2 "$0: Unknown \`$1' option" 103 - echo 1>&2 "Try \`$0 --help' for more information" 104 - exit 1 105 - ;; 106 - 107 -esac 108 - 109 -# normalize program name to check for. 110 -program=`echo "$1" | sed ' 111 - s/^gnu-//; t 112 - s/^gnu//; t 113 - s/^g//; t'` 114 - 115 -# Now exit if we have it, but it failed. Also exit now if we 116 -# don't have it and --version was passed (most likely to detect 117 -# the program). This is about non-GNU programs, so use $1 not 118 -# $program. 119 -case $1 in 120 - lex*|yacc*) 121 - # Not GNU programs, they don't have --version. 122 - ;; 123 - 124 - *) 125 - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 126 - # We have it, but it failed. 127 - exit 1 128 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 129 - # Could not run --version or --help. This is probably someone 130 - # running `$TOOL --version' or `$TOOL --help' to check whether 131 - # $TOOL exists and not knowing $TOOL uses missing. 132 - exit 1 133 - fi 134 - ;; 135 -esac 136 - 137 -# If it does not exist, or fails to run (possibly an outdated version), 138 -# try to emulate it. 139 -case $program in 140 - aclocal*) 141 - echo 1>&2 "\ 142 -WARNING: \`$1' is $msg. You should only need it if 143 - you modified \`acinclude.m4' or \`${configure_ac}'. You might want 144 - to install the \`Automake' and \`Perl' packages. Grab them from 145 - any GNU archive site." 146 - touch aclocal.m4 147 - ;; 148 - 149 - autoconf*) 150 - echo 1>&2 "\ 151 -WARNING: \`$1' is $msg. You should only need it if 152 - you modified \`${configure_ac}'. You might want to install the 153 - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 154 - archive site." 155 - touch configure 156 - ;; 157 - 158 - autoheader*) 159 - echo 1>&2 "\ 160 -WARNING: \`$1' is $msg. You should only need it if 161 - you modified \`acconfig.h' or \`${configure_ac}'. You might want 162 - to install the \`Autoconf' and \`GNU m4' packages. Grab them 163 - from any GNU archive site." 164 - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 165 - test -z "$files" && files="config.h" 166 - touch_files= 167 - for f in $files; do 168 - case $f in 169 - *:*) touch_files="$touch_files "`echo "$f" | 170 - sed -e 's/^[^:]*://' -e 's/:.*//'`;; 171 - *) touch_files="$touch_files $f.in";; 172 - esac 173 - done 174 - touch $touch_files 175 - ;; 176 - 177 - automake*) 178 - echo 1>&2 "\ 179 -WARNING: \`$1' is $msg. You should only need it if 180 - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 181 - You might want to install the \`Automake' and \`Perl' packages. 182 - Grab them from any GNU archive site." 183 - find . -type f -name Makefile.am -print | 184 - sed 's/\.am$/.in/' | 185 - while read f; do touch "$f"; done 186 - ;; 187 - 188 - autom4te*) 189 - echo 1>&2 "\ 190 -WARNING: \`$1' is needed, but is $msg. 191 - You might have modified some files without having the 192 - proper tools for further handling them. 193 - You can get \`$1' as part of \`Autoconf' from any GNU 194 - archive site." 195 - 196 - file=`echo "$*" | sed -n "$sed_output"` 197 - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 198 - if test -f "$file"; then 199 - touch $file 200 - else 201 - test -z "$file" || exec >$file 202 - echo "#! /bin/sh" 203 - echo "# Created by GNU Automake missing as a replacement of" 204 - echo "# $ $@" 205 - echo "exit 0" 206 - chmod +x $file 207 - exit 1 208 - fi 209 - ;; 210 - 211 - bison*|yacc*) 212 - echo 1>&2 "\ 213 -WARNING: \`$1' $msg. You should only need it if 214 - you modified a \`.y' file. You may need the \`Bison' package 215 - in order for those modifications to take effect. You can get 216 - \`Bison' from any GNU archive site." 217 - rm -f y.tab.c y.tab.h 218 - if test $# -ne 1; then 219 - eval LASTARG=\${$#} 220 - case $LASTARG in 221 - *.y) 222 - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 223 - if test -f "$SRCFILE"; then 224 - cp "$SRCFILE" y.tab.c 225 - fi 226 - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 227 - if test -f "$SRCFILE"; then 228 - cp "$SRCFILE" y.tab.h 229 - fi 230 - ;; 231 - esac 232 - fi 233 - if test ! -f y.tab.h; then 234 - echo >y.tab.h 235 - fi 236 - if test ! -f y.tab.c; then 237 - echo 'main() { return 0; }' >y.tab.c 238 - fi 239 - ;; 240 - 241 - lex*|flex*) 242 - echo 1>&2 "\ 243 -WARNING: \`$1' is $msg. You should only need it if 244 - you modified a \`.l' file. You may need the \`Flex' package 245 - in order for those modifications to take effect. You can get 246 - \`Flex' from any GNU archive site." 247 - rm -f lex.yy.c 248 - if test $# -ne 1; then 249 - eval LASTARG=\${$#} 250 - case $LASTARG in 251 - *.l) 252 - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 253 - if test -f "$SRCFILE"; then 254 - cp "$SRCFILE" lex.yy.c 255 - fi 256 - ;; 257 - esac 258 - fi 259 - if test ! -f lex.yy.c; then 260 - echo 'main() { return 0; }' >lex.yy.c 261 - fi 262 - ;; 263 - 264 - help2man*) 265 - echo 1>&2 "\ 266 -WARNING: \`$1' is $msg. You should only need it if 267 - you modified a dependency of a manual page. You may need the 268 - \`Help2man' package in order for those modifications to take 269 - effect. You can get \`Help2man' from any GNU archive site." 270 - 271 - file=`echo "$*" | sed -n "$sed_output"` 272 - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 273 - if test -f "$file"; then 274 - touch $file 275 - else 276 - test -z "$file" || exec >$file 277 - echo ".ab help2man is required to generate this page" 278 - exit $? 279 - fi 280 - ;; 281 - 282 - makeinfo*) 283 - echo 1>&2 "\ 284 -WARNING: \`$1' is $msg. You should only need it if 285 - you modified a \`.texi' or \`.texinfo' file, or any other file 286 - indirectly affecting the aspect of the manual. The spurious 287 - call might also be the consequence of using a buggy \`make' (AIX, 288 - DU, IRIX). You might want to install the \`Texinfo' package or 289 - the \`GNU make' package. Grab either from any GNU archive site." 290 - # The file to touch is that specified with -o ... 291 - file=`echo "$*" | sed -n "$sed_output"` 292 - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 293 - if test -z "$file"; then 294 - # ... or it is the one specified with @setfilename ... 295 - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 296 - file=`sed -n ' 297 - /^@setfilename/{ 298 - s/.* \([^ ]*\) *$/\1/ 299 - p 300 - q 301 - }' $infile` 302 - # ... or it is derived from the source name (dir/f.texi becomes f.info) 303 - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 304 - fi 305 - # If the file does not exist, the user really needs makeinfo; 306 - # let's fail without touching anything. 307 - test -f $file || exit 1 308 - touch $file 309 - ;; 310 - 311 - *) 312 - echo 1>&2 "\ 313 -WARNING: \`$1' is needed, and is $msg. 314 - You might have modified some files without having the 315 - proper tools for further handling them. Check the \`README' file, 316 - it often tells you about the needed prerequisites for installing 317 - this package. You may also peek at any GNU archive site, in case 318 - some other package would contain this missing \`$1' program." 319 - exit 1 320 - ;; 321 -esac 322 - 323 -exit 0 324 - 325 -# Local variables: 326 -# eval: (add-hook 'write-file-hooks 'time-stamp) 327 -# time-stamp-start: "scriptversion=" 328 -# time-stamp-format: "%:y-%02m-%02d.%02H" 329 -# time-stamp-time-zone: "UTC" 330 -# time-stamp-end: "; # UTC" 331 -# End:
Deleted src/Makefile.am.
1 - 2 -AM_CFLAGS = -D_LARGE_FILE=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 \ 3 - @LIBPNG_CFLAGS@ @LIBCAIRO_CFLAGS@ @LIBXML2_CFLAGS@ 4 - 5 -AM_CPPFLAGS = @CFLAGS@ 6 -AM_CPPFLAGS += -I$(top_srcdir)/headers 7 - 8 -lib_LTLIBRARIES = libgaiagraphics.la 9 - 10 -libgaiagraphics_la_SOURCES = \ 11 - gaiagraphics_paint.c \ 12 - gaiagraphics_io.c \ 13 - gaiagraphics_image.c \ 14 - gaiagraphics_aux.c \ 15 - gaiagraphics_quantize.c \ 16 - gaiagraphics_gif.c \ 17 - gaiagraphics_png.c \ 18 - gaiagraphics_jpeg.c \ 19 - gaiagraphics_tiff.c \ 20 - gaiagraphics_grids.c \ 21 - gaiagraphics_adam7.c \ 22 - gaiagraphics_color_rules.c \ 23 - gaiagraphics_svg.c \ 24 - gaiagraphics_svg_aux.c \ 25 - gaiagraphics_svg_xml.c 26 - 27 -libgaiagraphics_la_LDFLAGS = -version-info 1:0:0 -no-undefined 28 - 29 -if MINGW 30 -libgaiagraphics_la_LIBADD = \ 31 - @LIBXML2_LIBS@ @LIBCAIRO_LIBS@ -lgeotiff -ltiff -ljpeg -lproj @LIBPNG_LIBS@ 32 -else 33 -libgaiagraphics_la_LIBADD = \ 34 - @LIBXML2_LIBS@ @LIBCAIRO_LIBS@ -lgeotiff -ltiff -ljpeg -lproj @LIBPNG_LIBS@ -lpthread 35 -endif 36 -
Deleted src/Makefile.in.
1 -# Makefile.in generated by automake 1.13.4 from Makefile.am. 2 -# @configure_input@ 3 - 4 -# Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 - 6 -# This Makefile.in is free software; the Free Software Foundation 7 -# gives unlimited permission to copy and/or distribute it, 8 -# with or without modifications, as long as this notice is preserved. 9 - 10 -# This program is distributed in the hope that it will be useful, 11 -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 -# PARTICULAR PURPOSE. 14 - 15 -@SET_MAKE@ 16 - 17 -VPATH = @srcdir@ 18 -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 19 -am__make_running_with_option = \ 20 - case $${target_option-} in \ 21 - ?) ;; \ 22 - *) echo "am__make_running_with_option: internal error: invalid" \ 23 - "target option '$${target_option-}' specified" >&2; \ 24 - exit 1;; \ 25 - esac; \ 26 - has_opt=no; \ 27 - sane_makeflags=$$MAKEFLAGS; \ 28 - if $(am__is_gnu_make); then \ 29 - sane_makeflags=$$MFLAGS; \ 30 - else \ 31 - case $$MAKEFLAGS in \ 32 - *\\[\ \ ]*) \ 33 - bs=\\; \ 34 - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 35 - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 36 - esac; \ 37 - fi; \ 38 - skip_next=no; \ 39 - strip_trailopt () \ 40 - { \ 41 - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 42 - }; \ 43 - for flg in $$sane_makeflags; do \ 44 - test $$skip_next = yes && { skip_next=no; continue; }; \ 45 - case $$flg in \ 46 - *=*|--*) continue;; \ 47 - -*I) strip_trailopt 'I'; skip_next=yes;; \ 48 - -*I?*) strip_trailopt 'I';; \ 49 - -*O) strip_trailopt 'O'; skip_next=yes;; \ 50 - -*O?*) strip_trailopt 'O';; \ 51 - -*l) strip_trailopt 'l'; skip_next=yes;; \ 52 - -*l?*) strip_trailopt 'l';; \ 53 - -[dEDm]) skip_next=yes;; \ 54 - -[JT]) skip_next=yes;; \ 55 - esac; \ 56 - case $$flg in \ 57 - *$$target_option*) has_opt=yes; break;; \ 58 - esac; \ 59 - done; \ 60 - test $$has_opt = yes 61 -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 62 -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 63 -pkgdatadir = $(datadir)/@PACKAGE@ 64 -pkgincludedir = $(includedir)/@PACKAGE@ 65 -pkglibdir = $(libdir)/@PACKAGE@ 66 -pkglibexecdir = $(libexecdir)/@PACKAGE@ 67 -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 68 -install_sh_DATA = $(install_sh) -c -m 644 69 -install_sh_PROGRAM = $(install_sh) -c 70 -install_sh_SCRIPT = $(install_sh) -c 71 -INSTALL_HEADER = $(INSTALL_DATA) 72 -transform = $(program_transform_name) 73 -NORMAL_INSTALL = : 74 -PRE_INSTALL = : 75 -POST_INSTALL = : 76 -NORMAL_UNINSTALL = : 77 -PRE_UNINSTALL = : 78 -POST_UNINSTALL = : 79 -build_triplet = @build@ 80 -host_triplet = @host@ 81 -subdir = src 82 -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ 83 - $(top_srcdir)/depcomp 84 -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 85 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ 86 - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ 87 - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ 88 - $(top_srcdir)/configure.ac 89 -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 90 - $(ACLOCAL_M4) 91 -mkinstalldirs = $(install_sh) -d 92 -CONFIG_CLEAN_FILES = 93 -CONFIG_CLEAN_VPATH_FILES = 94 -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 95 -am__vpath_adj = case $$p in \ 96 - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 97 - *) f=$$p;; \ 98 - esac; 99 -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; 100 -am__install_max = 40 101 -am__nobase_strip_setup = \ 102 - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` 103 -am__nobase_strip = \ 104 - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" 105 -am__nobase_list = $(am__nobase_strip_setup); \ 106 - for p in $$list; do echo "$$p $$p"; done | \ 107 - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ 108 - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ 109 - if (++n[$$2] == $(am__install_max)) \ 110 - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ 111 - END { for (dir in files) print dir, files[dir] }' 112 -am__base_list = \ 113 - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ 114 - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' 115 -am__uninstall_files_from_dir = { \ 116 - test -z "$$files" \ 117 - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ 118 - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ 119 - $(am__cd) "$$dir" && rm -f $$files; }; \ 120 - } 121 -am__installdirs = "$(DESTDIR)$(libdir)" 122 -LTLIBRARIES = $(lib_LTLIBRARIES) 123 -libgaiagraphics_la_DEPENDENCIES = 124 -am_libgaiagraphics_la_OBJECTS = gaiagraphics_paint.lo \ 125 - gaiagraphics_io.lo gaiagraphics_image.lo gaiagraphics_aux.lo \ 126 - gaiagraphics_quantize.lo gaiagraphics_gif.lo \ 127 - gaiagraphics_png.lo gaiagraphics_jpeg.lo gaiagraphics_tiff.lo \ 128 - gaiagraphics_grids.lo gaiagraphics_adam7.lo \ 129 - gaiagraphics_color_rules.lo gaiagraphics_svg.lo \ 130 - gaiagraphics_svg_aux.lo gaiagraphics_svg_xml.lo 131 -libgaiagraphics_la_OBJECTS = $(am_libgaiagraphics_la_OBJECTS) 132 -AM_V_lt = $(am__v_lt_@AM_V@) 133 -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) 134 -am__v_lt_0 = --silent 135 -am__v_lt_1 = 136 -libgaiagraphics_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ 137 - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ 138 - $(AM_CFLAGS) $(CFLAGS) $(libgaiagraphics_la_LDFLAGS) \ 139 - $(LDFLAGS) -o $@ 140 -AM_V_P = $(am__v_P_@AM_V@) 141 -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 142 -am__v_P_0 = false 143 -am__v_P_1 = : 144 -AM_V_GEN = $(am__v_GEN_@AM_V@) 145 -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 146 -am__v_GEN_0 = @echo " GEN " $@; 147 -am__v_GEN_1 = 148 -AM_V_at = $(am__v_at_@AM_V@) 149 -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 150 -am__v_at_0 = @ 151 -am__v_at_1 = 152 -DEFAULT_INCLUDES = -I.@am__isrc@ 153 -depcomp = $(SHELL) $(top_srcdir)/depcomp 154 -am__depfiles_maybe = depfiles 155 -am__mv = mv -f 156 -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 157 - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 158 -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 159 - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ 160 - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ 161 - $(AM_CFLAGS) $(CFLAGS) 162 -AM_V_CC = $(am__v_CC_@AM_V@) 163 -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) 164 -am__v_CC_0 = @echo " CC " $@; 165 -am__v_CC_1 = 166 -CCLD = $(CC) 167 -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 168 - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ 169 - $(AM_LDFLAGS) $(LDFLAGS) -o $@ 170 -AM_V_CCLD = $(am__v_CCLD_@AM_V@) 171 -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) 172 -am__v_CCLD_0 = @echo " CCLD " $@; 173 -am__v_CCLD_1 = 174 -SOURCES = $(libgaiagraphics_la_SOURCES) 175 -DIST_SOURCES = $(libgaiagraphics_la_SOURCES) 176 -am__can_run_installinfo = \ 177 - case $$AM_UPDATE_INFO_DIR in \ 178 - n|no|NO) false;; \ 179 - *) (install-info --version) >/dev/null 2>&1;; \ 180 - esac 181 -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 182 -# Read a list of newline-separated strings from the standard input, 183 -# and print each of them once, without duplicates. Input order is 184 -# *not* preserved. 185 -am__uniquify_input = $(AWK) '\ 186 - BEGIN { nonempty = 0; } \ 187 - { items[$$0] = 1; nonempty = 1; } \ 188 - END { if (nonempty) { for (i in items) print i; }; } \ 189 -' 190 -# Make sure the list of sources is unique. This is necessary because, 191 -# e.g., the same source file might be shared among _SOURCES variables 192 -# for different programs/libraries. 193 -am__define_uniq_tagged_files = \ 194 - list='$(am__tagged_files)'; \ 195 - unique=`for i in $$list; do \ 196 - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 197 - done | $(am__uniquify_input)` 198 -ETAGS = etags 199 -CTAGS = ctags 200 -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 201 -ACLOCAL = @ACLOCAL@ 202 -AMTAR = @AMTAR@ 203 -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 204 -AR = @AR@ 205 -AS = @AS@ 206 -AUTOCONF = @AUTOCONF@ 207 -AUTOHEADER = @AUTOHEADER@ 208 -AUTOMAKE = @AUTOMAKE@ 209 -AWK = @AWK@ 210 -CC = @CC@ 211 -CCDEPMODE = @CCDEPMODE@ 212 -CFLAGS = @CFLAGS@ 213 -CPP = @CPP@ 214 -CPPFLAGS = @CPPFLAGS@ 215 -CXX = @CXX@ 216 -CXXCPP = @CXXCPP@ 217 -CXXDEPMODE = @CXXDEPMODE@ 218 -CXXFLAGS = @CXXFLAGS@ 219 -CYGPATH_W = @CYGPATH_W@ 220 -DEFS = @DEFS@ 221 -DEPDIR = @DEPDIR@ 222 -DLLTOOL = @DLLTOOL@ 223 -DSYMUTIL = @DSYMUTIL@ 224 -DUMPBIN = @DUMPBIN@ 225 -ECHO_C = @ECHO_C@ 226 -ECHO_N = @ECHO_N@ 227 -ECHO_T = @ECHO_T@ 228 -EGREP = @EGREP@ 229 -EXEEXT = @EXEEXT@ 230 -FGREP = @FGREP@ 231 -GREP = @GREP@ 232 -INSTALL = @INSTALL@ 233 -INSTALL_DATA = @INSTALL_DATA@ 234 -INSTALL_PROGRAM = @INSTALL_PROGRAM@ 235 -INSTALL_SCRIPT = @INSTALL_SCRIPT@ 236 -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 237 -LD = @LD@ 238 -LDFLAGS = @LDFLAGS@ 239 -LIBCAIRO_CFLAGS = @LIBCAIRO_CFLAGS@ 240 -LIBCAIRO_LIBS = @LIBCAIRO_LIBS@ 241 -LIBOBJS = @LIBOBJS@ 242 -LIBPNG_CFLAGS = @LIBPNG_CFLAGS@ 243 -LIBPNG_LIBS = @LIBPNG_LIBS@ 244 -LIBS = @LIBS@ 245 -LIBTOOL = @LIBTOOL@ 246 -LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ 247 -LIBXML2_LIBS = @LIBXML2_LIBS@ 248 -LIPO = @LIPO@ 249 -LN_S = @LN_S@ 250 -LTLIBOBJS = @LTLIBOBJS@ 251 -MAINT = @MAINT@ 252 -MAKEINFO = @MAKEINFO@ 253 -MANIFEST_TOOL = @MANIFEST_TOOL@ 254 -MKDIR_P = @MKDIR_P@ 255 -NM = @NM@ 256 -NMEDIT = @NMEDIT@ 257 -OBJDUMP = @OBJDUMP@ 258 -OBJEXT = @OBJEXT@ 259 -OTOOL = @OTOOL@ 260 -OTOOL64 = @OTOOL64@ 261 -PACKAGE = @PACKAGE@ 262 -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 263 -PACKAGE_NAME = @PACKAGE_NAME@ 264 -PACKAGE_STRING = @PACKAGE_STRING@ 265 -PACKAGE_TARNAME = @PACKAGE_TARNAME@ 266 -PACKAGE_URL = @PACKAGE_URL@ 267 -PACKAGE_VERSION = @PACKAGE_VERSION@ 268 -PATH_SEPARATOR = @PATH_SEPARATOR@ 269 -PKG_CONFIG = @PKG_CONFIG@ 270 -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ 271 -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ 272 -RANLIB = @RANLIB@ 273 -SED = @SED@ 274 -SET_MAKE = @SET_MAKE@ 275 -SHELL = @SHELL@ 276 -STRIP = @STRIP@ 277 -VERSION = @VERSION@ 278 -abs_builddir = @abs_builddir@ 279 -abs_srcdir = @abs_srcdir@ 280 -abs_top_builddir = @abs_top_builddir@ 281 -abs_top_srcdir = @abs_top_srcdir@ 282 -ac_ct_AR = @ac_ct_AR@ 283 -ac_ct_CC = @ac_ct_CC@ 284 -ac_ct_CXX = @ac_ct_CXX@ 285 -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 286 -am__include = @am__include@ 287 -am__leading_dot = @am__leading_dot@ 288 -am__quote = @am__quote@ 289 -am__tar = @am__tar@ 290 -am__untar = @am__untar@ 291 -bindir = @bindir@ 292 -build = @build@ 293 -build_alias = @build_alias@ 294 -build_cpu = @build_cpu@ 295 -build_os = @build_os@ 296 -build_vendor = @build_vendor@ 297 -builddir = @builddir@ 298 -datadir = @datadir@ 299 -datarootdir = @datarootdir@ 300 -docdir = @docdir@ 301 -dvidir = @dvidir@ 302 -exec_prefix = @exec_prefix@ 303 -host = @host@ 304 -host_alias = @host_alias@ 305 -host_cpu = @host_cpu@ 306 -host_os = @host_os@ 307 -host_vendor = @host_vendor@ 308 -htmldir = @htmldir@ 309 -includedir = @includedir@ 310 -infodir = @infodir@ 311 -install_sh = @install_sh@ 312 -libdir = @libdir@ 313 -libexecdir = @libexecdir@ 314 -localedir = @localedir@ 315 -localstatedir = @localstatedir@ 316 -mandir = @mandir@ 317 -mkdir_p = @mkdir_p@ 318 -oldincludedir = @oldincludedir@ 319 -pdfdir = @pdfdir@ 320 -prefix = @prefix@ 321 -program_transform_name = @program_transform_name@ 322 -psdir = @psdir@ 323 -sbindir = @sbindir@ 324 -sharedstatedir = @sharedstatedir@ 325 -srcdir = @srcdir@ 326 -sysconfdir = @sysconfdir@ 327 -target_alias = @target_alias@ 328 -top_build_prefix = @top_build_prefix@ 329 -top_builddir = @top_builddir@ 330 -top_srcdir = @top_srcdir@ 331 -AM_CFLAGS = -D_LARGE_FILE=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 \ 332 - @LIBPNG_CFLAGS@ @LIBCAIRO_CFLAGS@ @LIBXML2_CFLAGS@ 333 - 334 -AM_CPPFLAGS = @CFLAGS@ -I$(top_srcdir)/headers 335 -lib_LTLIBRARIES = libgaiagraphics.la 336 -libgaiagraphics_la_SOURCES = \ 337 - gaiagraphics_paint.c \ 338 - gaiagraphics_io.c \ 339 - gaiagraphics_image.c \ 340 - gaiagraphics_aux.c \ 341 - gaiagraphics_quantize.c \ 342 - gaiagraphics_gif.c \ 343 - gaiagraphics_png.c \ 344 - gaiagraphics_jpeg.c \ 345 - gaiagraphics_tiff.c \ 346 - gaiagraphics_grids.c \ 347 - gaiagraphics_adam7.c \ 348 - gaiagraphics_color_rules.c \ 349 - gaiagraphics_svg.c \ 350 - gaiagraphics_svg_aux.c \ 351 - gaiagraphics_svg_xml.c 352 - 353 -libgaiagraphics_la_LDFLAGS = -version-info 1:0:0 -no-undefined 354 -@MINGW_FALSE@libgaiagraphics_la_LIBADD = \ 355 -@MINGW_FALSE@ @LIBXML2_LIBS@ @LIBCAIRO_LIBS@ -lgeotiff -ltiff -ljpeg -lproj @LIBPNG_LIBS@ -lpthread 356 - 357 -@MINGW_TRUE@libgaiagraphics_la_LIBADD = \ 358 -@MINGW_TRUE@ @LIBXML2_LIBS@ @LIBCAIRO_LIBS@ -lgeotiff -ltiff -ljpeg -lproj @LIBPNG_LIBS@ 359 - 360 -all: all-am 361 - 362 -.SUFFIXES: 363 -.SUFFIXES: .c .lo .o .obj 364 -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) 365 - @for dep in $?; do \ 366 - case '$(am__configure_deps)' in \ 367 - *$$dep*) \ 368 - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 369 - && { if test -f $@; then exit 0; else break; fi; }; \ 370 - exit 1;; \ 371 - esac; \ 372 - done; \ 373 - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ 374 - $(am__cd) $(top_srcdir) && \ 375 - $(AUTOMAKE) --gnu src/Makefile 376 -.PRECIOUS: Makefile 377 -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 378 - @case '$?' in \ 379 - *config.status*) \ 380 - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 381 - *) \ 382 - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 383 - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 384 - esac; 385 - 386 -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 387 - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 388 - 389 -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 390 - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 391 -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) 392 - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 393 -$(am__aclocal_m4_deps): 394 - 395 -install-libLTLIBRARIES: $(lib_LTLIBRARIES) 396 - @$(NORMAL_INSTALL) 397 - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ 398 - list2=; for p in $$list; do \ 399 - if test -f $$p; then \ 400 - list2="$$list2 $$p"; \ 401 - else :; fi; \ 402 - done; \ 403 - test -z "$$list2" || { \ 404 - echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ 405 - $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ 406 - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ 407 - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ 408 - } 409 - 410 -uninstall-libLTLIBRARIES: 411 - @$(NORMAL_UNINSTALL) 412 - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ 413 - for p in $$list; do \ 414 - $(am__strip_dir) \ 415 - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ 416 - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ 417 - done 418 - 419 -clean-libLTLIBRARIES: 420 - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) 421 - @list='$(lib_LTLIBRARIES)'; \ 422 - locs=`for p in $$list; do echo $$p; done | \ 423 - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ 424 - sort -u`; \ 425 - test -z "$$locs" || { \ 426 - echo rm -f $${locs}; \ 427 - rm -f $${locs}; \ 428 - } 429 - 430 -libgaiagraphics.la: $(libgaiagraphics_la_OBJECTS) $(libgaiagraphics_la_DEPENDENCIES) $(EXTRA_libgaiagraphics_la_DEPENDENCIES) 431 - $(AM_V_CCLD)$(libgaiagraphics_la_LINK) -rpath $(libdir) $(libgaiagraphics_la_OBJECTS) $(libgaiagraphics_la_LIBADD) $(LIBS) 432 - 433 -mostlyclean-compile: 434 - -rm -f *.$(OBJEXT) 435 - 436 -distclean-compile: 437 - -rm -f *.tab.c 438 - 439 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_adam7.Plo@am__quote@ 440 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_aux.Plo@am__quote@ 441 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_color_rules.Plo@am__quote@ 442 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_gif.Plo@am__quote@ 443 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_grids.Plo@am__quote@ 444 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_image.Plo@am__quote@ 445 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_io.Plo@am__quote@ 446 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_jpeg.Plo@am__quote@ 447 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_paint.Plo@am__quote@ 448 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_png.Plo@am__quote@ 449 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_quantize.Plo@am__quote@ 450 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_svg.Plo@am__quote@ 451 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_svg_aux.Plo@am__quote@ 452 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_svg_xml.Plo@am__quote@ 453 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gaiagraphics_tiff.Plo@am__quote@ 454 - 455 -.c.o: 456 -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 457 -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 458 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 459 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 460 -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< 461 - 462 -.c.obj: 463 -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 464 -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 465 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 466 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 467 -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` 468 - 469 -.c.lo: 470 -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 471 -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo 472 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ 473 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 474 -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< 475 - 476 -mostlyclean-libtool: 477 - -rm -f *.lo 478 - 479 -clean-libtool: 480 - -rm -rf .libs _libs 481 - 482 -ID: $(am__tagged_files) 483 - $(am__define_uniq_tagged_files); mkid -fID $$unique 484 -tags: tags-am 485 -TAGS: tags 486 - 487 -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 488 - set x; \ 489 - here=`pwd`; \ 490 - $(am__define_uniq_tagged_files); \ 491 - shift; \ 492 - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 493 - test -n "$$unique" || unique=$$empty_fix; \ 494 - if test $$# -gt 0; then \ 495 - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 496 - "$$@" $$unique; \ 497 - else \ 498 - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 499 - $$unique; \ 500 - fi; \ 501 - fi 502 -ctags: ctags-am 503 - 504 -CTAGS: ctags 505 -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 506 - $(am__define_uniq_tagged_files); \ 507 - test -z "$(CTAGS_ARGS)$$unique" \ 508 - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 509 - $$unique 510 - 511 -GTAGS: 512 - here=`$(am__cd) $(top_builddir) && pwd` \ 513 - && $(am__cd) $(top_srcdir) \ 514 - && gtags -i $(GTAGS_ARGS) "$$here" 515 -cscopelist: cscopelist-am 516 - 517 -cscopelist-am: $(am__tagged_files) 518 - list='$(am__tagged_files)'; \ 519 - case "$(srcdir)" in \ 520 - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 521 - *) sdir=$(subdir)/$(srcdir) ;; \ 522 - esac; \ 523 - for i in $$list; do \ 524 - if test -f "$$i"; then \ 525 - echo "$(subdir)/$$i"; \ 526 - else \ 527 - echo "$$sdir/$$i"; \ 528 - fi; \ 529 - done >> $(top_builddir)/cscope.files 530 - 531 -distclean-tags: 532 - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 533 - 534 -distdir: $(DISTFILES) 535 - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 536 - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 537 - list='$(DISTFILES)'; \ 538 - dist_files=`for file in $$list; do echo $$file; done | \ 539 - sed -e "s|^$$srcdirstrip/||;t" \ 540 - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 541 - case $$dist_files in \ 542 - */*) $(MKDIR_P) `echo "$$dist_files" | \ 543 - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 544 - sort -u` ;; \ 545 - esac; \ 546 - for file in $$dist_files; do \ 547 - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 548 - if test -d $$d/$$file; then \ 549 - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 550 - if test -d "$(distdir)/$$file"; then \ 551 - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 552 - fi; \ 553 - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 554 - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 555 - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 556 - fi; \ 557 - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 558 - else \ 559 - test -f "$(distdir)/$$file" \ 560 - || cp -p $$d/$$file "$(distdir)/$$file" \ 561 - || exit 1; \ 562 - fi; \ 563 - done 564 -check-am: all-am 565 -check: check-am 566 -all-am: Makefile $(LTLIBRARIES) 567 -installdirs: 568 - for dir in "$(DESTDIR)$(libdir)"; do \ 569 - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 570 - done 571 -install: install-am 572 -install-exec: install-exec-am 573 -install-data: install-data-am 574 -uninstall: uninstall-am 575 - 576 -install-am: all-am 577 - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 578 - 579 -installcheck: installcheck-am 580 -install-strip: 581 - if test -z '$(STRIP)'; then \ 582 - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 583 - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 584 - install; \ 585 - else \ 586 - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 587 - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 588 - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 589 - fi 590 -mostlyclean-generic: 591 - 592 -clean-generic: 593 - 594 -distclean-generic: 595 - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 596 - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 597 - 598 -maintainer-clean-generic: 599 - @echo "This command is intended for maintainers to use" 600 - @echo "it deletes files that may require special tools to rebuild." 601 -clean: clean-am 602 - 603 -clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ 604 - mostlyclean-am 605 - 606 -distclean: distclean-am 607 - -rm -rf ./$(DEPDIR) 608 - -rm -f Makefile 609 -distclean-am: clean-am distclean-compile distclean-generic \ 610 - distclean-tags 611 - 612 -dvi: dvi-am 613 - 614 -dvi-am: 615 - 616 -html: html-am 617 - 618 -html-am: 619 - 620 -info: info-am 621 - 622 -info-am: 623 - 624 -install-data-am: 625 - 626 -install-dvi: install-dvi-am 627 - 628 -install-dvi-am: 629 - 630 -install-exec-am: install-libLTLIBRARIES 631 - 632 -install-html: install-html-am 633 - 634 -install-html-am: 635 - 636 -install-info: install-info-am 637 - 638 -install-info-am: 639 - 640 -install-man: 641 - 642 -install-pdf: install-pdf-am 643 - 644 -install-pdf-am: 645 - 646 -install-ps: install-ps-am 647 - 648 -install-ps-am: 649 - 650 -installcheck-am: 651 - 652 -maintainer-clean: maintainer-clean-am 653 - -rm -rf ./$(DEPDIR) 654 - -rm -f Makefile 655 -maintainer-clean-am: distclean-am maintainer-clean-generic 656 - 657 -mostlyclean: mostlyclean-am 658 - 659 -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ 660 - mostlyclean-libtool 661 - 662 -pdf: pdf-am 663 - 664 -pdf-am: 665 - 666 -ps: ps-am 667 - 668 -ps-am: 669 - 670 -uninstall-am: uninstall-libLTLIBRARIES 671 - 672 -.MAKE: install-am install-strip 673 - 674 -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ 675 - clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ 676 - ctags-am distclean distclean-compile distclean-generic \ 677 - distclean-libtool distclean-tags distdir dvi dvi-am html \ 678 - html-am info info-am install install-am install-data \ 679 - install-data-am install-dvi install-dvi-am install-exec \ 680 - install-exec-am install-html install-html-am install-info \ 681 - install-info-am install-libLTLIBRARIES install-man install-pdf \ 682 - install-pdf-am install-ps install-ps-am install-strip \ 683 - installcheck installcheck-am installdirs maintainer-clean \ 684 - maintainer-clean-generic mostlyclean mostlyclean-compile \ 685 - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ 686 - tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES 687 - 688 - 689 -# Tell versions [3.59,3.63) of GNU make to not export all variables. 690 -# Otherwise a system limit (for SysV at least) may be exceeded. 691 -.NOEXPORT:
Deleted src/gaiagraphics_adam7.c.
1 -/* 2 -/ gaiagraphics_adam7.c 3 -/ 4 -/ Adam7 encoding and deconding 5 -/ 6 -/ version 1.0, 2010 September 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2009 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdlib.h> 28 -#include <stdio.h> 29 -#include <string.h> 30 -#include <float.h> 31 - 32 -#include "gaiagraphics.h" 33 -#include "gaiagraphics_internals.h" 34 - 35 -GGRAPH_DECLARE int 36 -gGraphImageToAdam7 (const void *ptr_img, void *mem_bufs[7], 37 - int mem_buf_sizes[7], void **palette, int *palette_size) 38 -{ 39 -/* encoding an image as Adam7 */ 40 - unsigned char *p_in; 41 - unsigned char *p_out; 42 - void *out; 43 - int size; 44 - int scanline_width; 45 - int pixel_size; 46 - int i; 47 - int x; 48 - int y; 49 - short out_width; 50 - short out_height; 51 - int x_base; 52 - int y_base; 53 - int x_step; 54 - int y_step; 55 - int endian_arch = gg_endian_arch (); 56 - int endian; 57 - int is_palette = 0; 58 - short start_marker[7]; 59 - short end_marker[7]; 60 - gGraphImagePtr img = (gGraphImagePtr) ptr_img; 61 - 62 - for (i = 0; i < 7; i++) 63 - { 64 - mem_bufs[i] = NULL; 65 - mem_buf_sizes[i] = 0; 66 - } 67 - *palette = NULL; 68 - *palette_size = 0; 69 - 70 - if (img == NULL) 71 - return GGRAPH_INVALID_IMAGE; 72 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 73 - return GGRAPH_INVALID_IMAGE; 74 - 75 - pixel_size = img->pixel_size; 76 - switch (img->pixel_format) 77 - { 78 - case GG_PIXEL_RGB: 79 - start_marker[0] = GG_ADAM7_0_RGB_START; 80 - end_marker[0] = GG_ADAM7_0_RGB_END; 81 - start_marker[1] = GG_ADAM7_1_RGB_START; 82 - end_marker[1] = GG_ADAM7_1_RGB_END; 83 - start_marker[2] = GG_ADAM7_2_RGB_START; 84 - end_marker[2] = GG_ADAM7_2_RGB_END; 85 - start_marker[3] = GG_ADAM7_3_RGB_START; 86 - end_marker[3] = GG_ADAM7_3_RGB_END; 87 - start_marker[4] = GG_ADAM7_4_RGB_START; 88 - end_marker[4] = GG_ADAM7_4_RGB_END; 89 - start_marker[5] = GG_ADAM7_5_RGB_START; 90 - end_marker[5] = GG_ADAM7_5_RGB_END; 91 - start_marker[6] = GG_ADAM7_6_RGB_START; 92 - end_marker[6] = GG_ADAM7_6_RGB_END; 93 - break; 94 - case GG_PIXEL_GRAYSCALE: 95 - start_marker[0] = GG_ADAM7_0_GRAYSCALE_START; 96 - end_marker[0] = GG_ADAM7_0_GRAYSCALE_END; 97 - start_marker[1] = GG_ADAM7_1_GRAYSCALE_START; 98 - end_marker[1] = GG_ADAM7_1_GRAYSCALE_END; 99 - start_marker[2] = GG_ADAM7_2_GRAYSCALE_START; 100 - end_marker[2] = GG_ADAM7_2_GRAYSCALE_END; 101 - start_marker[3] = GG_ADAM7_3_GRAYSCALE_START; 102 - end_marker[3] = GG_ADAM7_3_GRAYSCALE_END; 103 - start_marker[4] = GG_ADAM7_4_GRAYSCALE_START; 104 - end_marker[4] = GG_ADAM7_4_GRAYSCALE_END; 105 - start_marker[5] = GG_ADAM7_5_GRAYSCALE_START; 106 - end_marker[5] = GG_ADAM7_5_GRAYSCALE_END; 107 - start_marker[6] = GG_ADAM7_6_GRAYSCALE_START; 108 - end_marker[6] = GG_ADAM7_6_GRAYSCALE_END; 109 - break; 110 - case GG_PIXEL_PALETTE: 111 - start_marker[0] = GG_ADAM7_0_PALETTE_START; 112 - end_marker[0] = GG_ADAM7_0_PALETTE_END; 113 - start_marker[1] = GG_ADAM7_1_PALETTE_START; 114 - end_marker[1] = GG_ADAM7_1_PALETTE_END; 115 - start_marker[2] = GG_ADAM7_2_PALETTE_START; 116 - end_marker[2] = GG_ADAM7_2_PALETTE_END; 117 - start_marker[3] = GG_ADAM7_3_PALETTE_START; 118 - end_marker[3] = GG_ADAM7_3_PALETTE_END; 119 - start_marker[4] = GG_ADAM7_4_PALETTE_START; 120 - end_marker[4] = GG_ADAM7_4_PALETTE_END; 121 - start_marker[5] = GG_ADAM7_5_PALETTE_START; 122 - end_marker[5] = GG_ADAM7_5_PALETTE_END; 123 - start_marker[6] = GG_ADAM7_6_PALETTE_START; 124 - end_marker[6] = GG_ADAM7_6_PALETTE_END; 125 - is_palette = 1; 126 - break; 127 - case GG_PIXEL_GRID: 128 - switch (img->sample_format) 129 - { 130 - case GGRAPH_SAMPLE_INT: 131 - if (img->bits_per_sample == 16) 132 - { 133 - start_marker[0] = GG_ADAM7_0_INT16_START; 134 - end_marker[0] = GG_ADAM7_0_INT16_END; 135 - start_marker[1] = GG_ADAM7_1_INT16_START; 136 - end_marker[1] = GG_ADAM7_1_INT16_END; 137 - start_marker[2] = GG_ADAM7_2_INT16_START; 138 - end_marker[2] = GG_ADAM7_2_INT16_END; 139 - start_marker[3] = GG_ADAM7_3_INT16_START; 140 - end_marker[3] = GG_ADAM7_3_INT16_END; 141 - start_marker[4] = GG_ADAM7_4_INT16_START; 142 - end_marker[4] = GG_ADAM7_4_INT16_END; 143 - start_marker[5] = GG_ADAM7_5_INT16_START; 144 - end_marker[5] = GG_ADAM7_5_INT16_END; 145 - start_marker[6] = GG_ADAM7_6_INT16_START; 146 - end_marker[6] = GG_ADAM7_6_INT16_END; 147 - } 148 - else 149 - { 150 - start_marker[0] = GG_ADAM7_0_INT32_START; 151 - end_marker[0] = GG_ADAM7_0_INT32_END; 152 - start_marker[1] = GG_ADAM7_1_INT32_START; 153 - end_marker[1] = GG_ADAM7_1_INT32_END; 154 - start_marker[2] = GG_ADAM7_2_INT32_START; 155 - end_marker[2] = GG_ADAM7_2_INT32_END; 156 - start_marker[3] = GG_ADAM7_3_INT32_START; 157 - end_marker[3] = GG_ADAM7_3_INT32_END; 158 - start_marker[4] = GG_ADAM7_4_INT32_START; 159 - end_marker[4] = GG_ADAM7_4_INT32_END; 160 - start_marker[5] = GG_ADAM7_5_INT32_START; 161 - end_marker[5] = GG_ADAM7_5_INT32_END; 162 - start_marker[6] = GG_ADAM7_6_INT32_START; 163 - end_marker[6] = GG_ADAM7_6_INT32_END; 164 - } 165 - break; 166 - case GGRAPH_SAMPLE_UINT: 167 - if (img->bits_per_sample == 16) 168 - { 169 - start_marker[0] = GG_ADAM7_0_UINT16_START; 170 - end_marker[0] = GG_ADAM7_0_UINT16_END; 171 - start_marker[1] = GG_ADAM7_1_UINT16_START; 172 - end_marker[1] = GG_ADAM7_1_UINT16_END; 173 - start_marker[2] = GG_ADAM7_2_UINT16_START; 174 - end_marker[2] = GG_ADAM7_2_UINT16_END; 175 - start_marker[3] = GG_ADAM7_3_UINT16_START; 176 - end_marker[3] = GG_ADAM7_3_UINT16_END; 177 - start_marker[4] = GG_ADAM7_4_UINT16_START; 178 - end_marker[4] = GG_ADAM7_4_UINT16_END; 179 - start_marker[5] = GG_ADAM7_5_UINT16_START; 180 - end_marker[5] = GG_ADAM7_5_UINT16_END; 181 - start_marker[6] = GG_ADAM7_6_UINT16_START; 182 - end_marker[6] = GG_ADAM7_6_UINT16_END; 183 - } 184 - else 185 - { 186 - start_marker[0] = GG_ADAM7_0_UINT32_START; 187 - end_marker[0] = GG_ADAM7_0_UINT32_END; 188 - start_marker[1] = GG_ADAM7_1_UINT32_START; 189 - end_marker[1] = GG_ADAM7_1_UINT32_END; 190 - start_marker[2] = GG_ADAM7_2_UINT32_START; 191 - end_marker[2] = GG_ADAM7_2_UINT32_END; 192 - start_marker[3] = GG_ADAM7_3_UINT32_START; 193 - end_marker[3] = GG_ADAM7_3_UINT32_END; 194 - start_marker[4] = GG_ADAM7_4_UINT32_START; 195 - end_marker[4] = GG_ADAM7_4_UINT32_END; 196 - start_marker[5] = GG_ADAM7_5_UINT32_START; 197 - end_marker[5] = GG_ADAM7_5_UINT32_END; 198 - start_marker[6] = GG_ADAM7_6_UINT32_START; 199 - end_marker[6] = GG_ADAM7_6_UINT32_END; 200 - } 201 - break; 202 - case GGRAPH_SAMPLE_FLOAT: 203 - if (img->bits_per_sample == 32) 204 - { 205 - start_marker[0] = GG_ADAM7_0_FLOAT_START; 206 - end_marker[0] = GG_ADAM7_0_FLOAT_END; 207 - start_marker[1] = GG_ADAM7_1_FLOAT_START; 208 - end_marker[1] = GG_ADAM7_1_FLOAT_END; 209 - start_marker[2] = GG_ADAM7_2_FLOAT_START; 210 - end_marker[2] = GG_ADAM7_2_FLOAT_END; 211 - start_marker[3] = GG_ADAM7_3_FLOAT_START; 212 - end_marker[3] = GG_ADAM7_3_FLOAT_END; 213 - start_marker[4] = GG_ADAM7_4_FLOAT_START; 214 - end_marker[4] = GG_ADAM7_4_FLOAT_END; 215 - start_marker[5] = GG_ADAM7_5_FLOAT_START; 216 - end_marker[5] = GG_ADAM7_5_FLOAT_END; 217 - start_marker[6] = GG_ADAM7_6_FLOAT_START; 218 - end_marker[6] = GG_ADAM7_6_FLOAT_END; 219 - } 220 - else 221 - { 222 - start_marker[0] = GG_ADAM7_0_DOUBLE_START; 223 - end_marker[0] = GG_ADAM7_0_DOUBLE_END; 224 - start_marker[1] = GG_ADAM7_1_DOUBLE_START; 225 - end_marker[1] = GG_ADAM7_1_DOUBLE_END; 226 - start_marker[2] = GG_ADAM7_2_DOUBLE_START; 227 - end_marker[2] = GG_ADAM7_2_DOUBLE_END; 228 - start_marker[3] = GG_ADAM7_3_DOUBLE_START; 229 - end_marker[3] = GG_ADAM7_3_DOUBLE_END; 230 - start_marker[4] = GG_ADAM7_4_DOUBLE_START; 231 - end_marker[4] = GG_ADAM7_4_DOUBLE_END; 232 - start_marker[5] = GG_ADAM7_5_DOUBLE_START; 233 - end_marker[5] = GG_ADAM7_5_DOUBLE_END; 234 - start_marker[6] = GG_ADAM7_6_DOUBLE_START; 235 - end_marker[6] = GG_ADAM7_6_DOUBLE_END; 236 - } 237 - break; 238 - }; 239 - break; 240 - }; 241 - 242 - for (i = 0; i < 7; i++) 243 - { 244 - /* Adam7 steps */ 245 - switch (i) 246 - { 247 - case 0: 248 - x_base = 0; 249 - y_base = 0; 250 - x_step = 8; 251 - y_step = 8; 252 - break; 253 - case 1: 254 - x_base = 4; 255 - y_base = 0; 256 - x_step = 8; 257 - y_step = 8; 258 - break; 259 - case 2: 260 - x_base = 0; 261 - y_base = 4; 262 - x_step = 4; 263 - y_step = 8; 264 - break; 265 - case 3: 266 - x_base = 2; 267 - y_base = 0; 268 - x_step = 4; 269 - y_step = 4; 270 - break; 271 - case 4: 272 - x_base = 0; 273 - y_base = 2; 274 - x_step = 2; 275 - y_step = 4; 276 - break; 277 - case 5: 278 - x_base = 1; 279 - y_base = 0; 280 - x_step = 2; 281 - y_step = 2; 282 - break; 283 - case 6: 284 - x_base = 0; 285 - y_base = 1; 286 - x_step = 1; 287 - y_step = 2; 288 - break; 289 - }; 290 - out_width = (img->width - x_base) / x_step; 291 - if ((out_width * x_step) < (img->width - x_base)) 292 - out_width++; 293 - out_height = (img->height - y_base) / y_step; 294 - if ((out_height * y_step) < (img->height - y_base)) 295 - out_height++; 296 - scanline_width = out_width * pixel_size; 297 - size = out_height * scanline_width; 298 - size += 4 * sizeof (short); 299 - out = malloc (size); 300 - if (!out) 301 - goto stop; 302 - mem_bufs[i] = out; 303 - mem_buf_sizes[i] = size; 304 - p_out = out; 305 - /* 306 - * tiles are alternatively encoded as LITTLE or BIG-ENDIAN 307 - * in order to ensure an arch-neutral approach 308 - */ 309 - if (i == 0 || i == 2 || i == 4 || i == 6) 310 - endian = 0; 311 - else 312 - endian = 1; 313 - gg_export_int16 (start_marker[i], p_out, endian, endian_arch); 314 - p_out += sizeof (short); 315 - gg_export_int16 (out_width, p_out, endian, endian_arch); 316 - p_out += sizeof (short); 317 - gg_export_int16 (out_height, p_out, endian, endian_arch); 318 - p_out += sizeof (short); 319 - for (y = y_base; y < img->height; y += y_step) 320 - { 321 - p_in = 322 - (unsigned char *) (img->pixels) + 323 - (y * img->scanline_width) + (x_base * pixel_size); 324 - for (x = x_base; x < img->width; x += x_step) 325 - { 326 - if (img->pixel_format == GG_PIXEL_GRID) 327 - { 328 - switch (img->sample_format) 329 - { 330 - case GGRAPH_SAMPLE_INT: 331 - if (img->bits_per_sample == 16) 332 - { 333 - short value = *((short *) p_in); 334 - gg_export_int16 (value, p_out, endian, 335 - endian_arch); 336 - p_in += x_step * sizeof (short); 337 - p_out += sizeof (short); 338 - } 339 - else 340 - { 341 - int value = *((int *) p_in); 342 - gg_export_int32 (value, p_out, endian, 343 - endian_arch); 344 - p_in += x_step * sizeof (int); 345 - p_out += sizeof (int); 346 - } 347 - break; 348 - case GGRAPH_SAMPLE_UINT: 349 - if (img->bits_per_sample == 16) 350 - { 351 - unsigned short value = 352 - *((unsigned short *) p_in); 353 - gg_export_uint16 (value, p_out, endian, 354 - endian_arch); 355 - p_in += 356 - x_step * sizeof (unsigned short); 357 - p_out += sizeof (unsigned short); 358 - } 359 - else 360 - { 361 - unsigned int value = 362 - *((unsigned int *) p_in); 363 - gg_export_uint32 (value, p_out, endian, 364 - endian_arch); 365 - p_in += x_step * sizeof (unsigned int); 366 - p_out += sizeof (unsigned int); 367 - } 368 - break; 369 - case GGRAPH_SAMPLE_FLOAT: 370 - if (img->bits_per_sample == 32) 371 - { 372 - float value = *((float *) p_in); 373 - gg_export_float (value, p_out, endian, 374 - endian_arch); 375 - p_in += x_step * sizeof (float); 376 - p_out += sizeof (float); 377 - } 378 - else 379 - { 380 - double value = *((double *) p_in); 381 - gg_export_double (value, p_out, endian, 382 - endian_arch); 383 - p_in += x_step * sizeof (double); 384 - p_out += sizeof (double); 385 - } 386 - break; 387 - }; 388 - } 389 - else 390 - { 391 - memcpy (p_out, p_in, pixel_size); 392 - p_in += x_step * pixel_size; 393 - p_out += pixel_size; 394 - } 395 - } 396 - } 397 - p_out = (unsigned char *) out + size - sizeof (short); 398 - gg_export_int16 (end_marker[i], p_out, endian, endian_arch); 399 - } 400 - 401 - if (is_palette) 402 - { 403 - /* a palette is required */ 404 - size = (3 * img->max_palette) + (2 * sizeof (short)) + 1; 405 - out = malloc (size); 406 - if (out == NULL) 407 - goto stop; 408 - p_out = out; 409 - /* palette markers always are LITTLE-ENDIAN */ 410 - gg_export_int16 (GG_ADAM7_PALETTE_START, p_out, 1, endian_arch); 411 - p_out += sizeof (short); 412 - *p_out++ = (unsigned char) (img->max_palette); 413 - for (i = 0; i < img->max_palette; i++) 414 - { 415 - *p_out++ = img->palette_red[i]; 416 - *p_out++ = img->palette_green[i]; 417 - *p_out++ = img->palette_blue[i]; 418 - } 419 - gg_export_int16 (GG_ADAM7_PALETTE_END, p_out, 1, endian_arch); 420 - *palette = out; 421 - *palette_size = size; 422 - } 423 - 424 - return GGRAPH_OK; 425 - 426 - stop: 427 - for (i = 0; i < 7; i++) 428 - { 429 - if (mem_bufs[i]) 430 - free (mem_bufs[i]); 431 - mem_bufs[i] = NULL; 432 - mem_buf_sizes[i] = 0; 433 - } 434 - return GGRAPH_INSUFFICIENT_MEMORY; 435 -} 436 - 437 -static gGraphImagePtr 438 -adam7_decode (int img_no, void *mem_buf, int mem_buf_size) 439 -{ 440 -/* decoding an Adam7 sub-image */ 441 - unsigned char *p_in; 442 - int endian_arch = gg_endian_arch (); 443 - int endian; 444 - short start_signature; 445 - short end_signature; 446 - short width; 447 - short height; 448 - int x; 449 - int y; 450 - int pixel_format = GG_PIXEL_UNKNOWN; 451 - int sample_format; 452 - int bits_per_sample; 453 - int samples_per_pixel = 1; 454 - int size; 455 - gGraphImagePtr img = NULL; 456 - 457 - if (mem_buf_size < (int) (sizeof (short) * 4)) 458 - return NULL; 459 -/* 460 -* tiles are alternatively encoded as LITTLE or BIG-ENDIAN 461 -* in order to ensure an arch-neutral approach 462 -*/ 463 - if (img_no == 0 || img_no == 2 || img_no == 4 || img_no == 6) 464 - endian = 0; 465 - else 466 - endian = 1; 467 - 468 -/* checking signatures */ 469 - p_in = mem_buf; 470 - start_signature = gg_import_int16 (p_in, endian, endian_arch); 471 - p_in = (unsigned char *) mem_buf + mem_buf_size - sizeof (short); 472 - end_signature = gg_import_int16 (p_in, endian, endian_arch); 473 - 474 - switch (img_no) 475 - { 476 - case 0: 477 - if (start_signature == GG_ADAM7_0_RGB_START 478 - && end_signature == GG_ADAM7_0_RGB_END) 479 - { 480 - pixel_format = GG_PIXEL_RGB; 481 - sample_format = GGRAPH_SAMPLE_UINT; 482 - bits_per_sample = 8; 483 - samples_per_pixel = 3; 484 - } 485 - if (start_signature == GG_ADAM7_0_GRAYSCALE_START 486 - && end_signature == GG_ADAM7_0_GRAYSCALE_END) 487 - { 488 - pixel_format = GG_PIXEL_GRAYSCALE; 489 - sample_format = GGRAPH_SAMPLE_UINT; 490 - bits_per_sample = 8; 491 - } 492 - if (start_signature == GG_ADAM7_0_PALETTE_START 493 - && end_signature == GG_ADAM7_0_PALETTE_END) 494 - { 495 - pixel_format = GG_PIXEL_PALETTE; 496 - sample_format = GGRAPH_SAMPLE_UINT; 497 - bits_per_sample = 8; 498 - } 499 - if (start_signature == GG_ADAM7_0_INT16_START 500 - && end_signature == GG_ADAM7_0_INT16_END) 501 - { 502 - pixel_format = GG_PIXEL_GRID; 503 - sample_format = GGRAPH_SAMPLE_INT; 504 - bits_per_sample = 16; 505 - } 506 - if (start_signature == GG_ADAM7_0_INT32_START 507 - && end_signature == GG_ADAM7_0_INT32_END) 508 - { 509 - pixel_format = GG_PIXEL_GRID; 510 - sample_format = GGRAPH_SAMPLE_INT; 511 - bits_per_sample = 32; 512 - } 513 - if (start_signature == GG_ADAM7_0_UINT16_START 514 - && end_signature == GG_ADAM7_0_UINT16_END) 515 - { 516 - pixel_format = GG_PIXEL_GRID; 517 - sample_format = GGRAPH_SAMPLE_UINT; 518 - bits_per_sample = 16; 519 - } 520 - if (start_signature == GG_ADAM7_0_UINT32_START 521 - && end_signature == GG_ADAM7_0_UINT32_END) 522 - { 523 - pixel_format = GG_PIXEL_GRID; 524 - sample_format = GGRAPH_SAMPLE_UINT; 525 - bits_per_sample = 32; 526 - } 527 - if (start_signature == GG_ADAM7_0_FLOAT_START 528 - && end_signature == GG_ADAM7_0_FLOAT_END) 529 - { 530 - pixel_format = GG_PIXEL_GRID; 531 - sample_format = GGRAPH_SAMPLE_FLOAT; 532 - bits_per_sample = 32; 533 - } 534 - if (start_signature == GG_ADAM7_0_DOUBLE_START 535 - && end_signature == GG_ADAM7_0_DOUBLE_END) 536 - { 537 - pixel_format = GG_PIXEL_GRID; 538 - sample_format = GGRAPH_SAMPLE_FLOAT; 539 - bits_per_sample = 64; 540 - } 541 - break; 542 - case 1: 543 - if (start_signature == GG_ADAM7_1_RGB_START 544 - && end_signature == GG_ADAM7_1_RGB_END) 545 - { 546 - pixel_format = GG_PIXEL_RGB; 547 - sample_format = GGRAPH_SAMPLE_UINT; 548 - bits_per_sample = 8; 549 - samples_per_pixel = 3; 550 - } 551 - if (start_signature == GG_ADAM7_1_GRAYSCALE_START 552 - && end_signature == GG_ADAM7_1_GRAYSCALE_END) 553 - { 554 - pixel_format = GG_PIXEL_GRAYSCALE; 555 - sample_format = GGRAPH_SAMPLE_UINT; 556 - bits_per_sample = 8; 557 - } 558 - if (start_signature == GG_ADAM7_1_PALETTE_START 559 - && end_signature == GG_ADAM7_1_PALETTE_END) 560 - { 561 - pixel_format = GG_PIXEL_PALETTE; 562 - sample_format = GGRAPH_SAMPLE_UINT; 563 - bits_per_sample = 8; 564 - } 565 - if (start_signature == GG_ADAM7_1_INT16_START 566 - && end_signature == GG_ADAM7_1_INT16_END) 567 - { 568 - pixel_format = GG_PIXEL_GRID; 569 - sample_format = GGRAPH_SAMPLE_INT; 570 - bits_per_sample = 16; 571 - } 572 - if (start_signature == GG_ADAM7_1_INT32_START 573 - && end_signature == GG_ADAM7_1_INT32_END) 574 - { 575 - pixel_format = GG_PIXEL_GRID; 576 - sample_format = GGRAPH_SAMPLE_INT; 577 - bits_per_sample = 32; 578 - } 579 - if (start_signature == GG_ADAM7_1_UINT16_START 580 - && end_signature == GG_ADAM7_1_UINT16_END) 581 - { 582 - pixel_format = GG_PIXEL_GRID; 583 - sample_format = GGRAPH_SAMPLE_UINT; 584 - bits_per_sample = 16; 585 - } 586 - if (start_signature == GG_ADAM7_1_UINT32_START 587 - && end_signature == GG_ADAM7_1_UINT32_END) 588 - { 589 - pixel_format = GG_PIXEL_GRID; 590 - sample_format = GGRAPH_SAMPLE_UINT; 591 - bits_per_sample = 32; 592 - } 593 - if (start_signature == GG_ADAM7_1_FLOAT_START 594 - && end_signature == GG_ADAM7_1_FLOAT_END) 595 - { 596 - pixel_format = GG_PIXEL_GRID; 597 - sample_format = GGRAPH_SAMPLE_FLOAT; 598 - bits_per_sample = 32; 599 - } 600 - if (start_signature == GG_ADAM7_1_DOUBLE_START 601 - && end_signature == GG_ADAM7_1_DOUBLE_END) 602 - { 603 - pixel_format = GG_PIXEL_GRID; 604 - sample_format = GGRAPH_SAMPLE_FLOAT; 605 - bits_per_sample = 64; 606 - } 607 - break; 608 - case 2: 609 - if (start_signature == GG_ADAM7_2_RGB_START 610 - && end_signature == GG_ADAM7_2_RGB_END) 611 - { 612 - pixel_format = GG_PIXEL_RGB; 613 - sample_format = GGRAPH_SAMPLE_UINT; 614 - bits_per_sample = 8; 615 - samples_per_pixel = 3; 616 - } 617 - if (start_signature == GG_ADAM7_2_GRAYSCALE_START 618 - && end_signature == GG_ADAM7_2_GRAYSCALE_END) 619 - { 620 - pixel_format = GG_PIXEL_GRAYSCALE; 621 - sample_format = GGRAPH_SAMPLE_UINT; 622 - bits_per_sample = 8; 623 - } 624 - if (start_signature == GG_ADAM7_2_PALETTE_START 625 - && end_signature == GG_ADAM7_2_PALETTE_END) 626 - { 627 - pixel_format = GG_PIXEL_PALETTE; 628 - sample_format = GGRAPH_SAMPLE_UINT; 629 - bits_per_sample = 8; 630 - } 631 - if (start_signature == GG_ADAM7_2_INT16_START 632 - && end_signature == GG_ADAM7_2_INT16_END) 633 - { 634 - pixel_format = GG_PIXEL_GRID; 635 - sample_format = GGRAPH_SAMPLE_INT; 636 - bits_per_sample = 16; 637 - } 638 - if (start_signature == GG_ADAM7_2_INT32_START 639 - && end_signature == GG_ADAM7_2_INT32_END) 640 - { 641 - pixel_format = GG_PIXEL_GRID; 642 - sample_format = GGRAPH_SAMPLE_INT; 643 - bits_per_sample = 32; 644 - } 645 - if (start_signature == GG_ADAM7_2_UINT16_START 646 - && end_signature == GG_ADAM7_2_UINT16_END) 647 - { 648 - pixel_format = GG_PIXEL_GRID; 649 - sample_format = GGRAPH_SAMPLE_UINT; 650 - bits_per_sample = 16; 651 - } 652 - if (start_signature == GG_ADAM7_2_UINT32_START 653 - && end_signature == GG_ADAM7_2_UINT32_END) 654 - { 655 - pixel_format = GG_PIXEL_GRID; 656 - sample_format = GGRAPH_SAMPLE_UINT; 657 - bits_per_sample = 32; 658 - } 659 - if (start_signature == GG_ADAM7_2_FLOAT_START 660 - && end_signature == GG_ADAM7_2_FLOAT_END) 661 - { 662 - pixel_format = GG_PIXEL_GRID; 663 - sample_format = GGRAPH_SAMPLE_FLOAT; 664 - bits_per_sample = 32; 665 - } 666 - if (start_signature == GG_ADAM7_2_DOUBLE_START 667 - && end_signature == GG_ADAM7_2_DOUBLE_END) 668 - { 669 - pixel_format = GG_PIXEL_GRID; 670 - sample_format = GGRAPH_SAMPLE_FLOAT; 671 - bits_per_sample = 64; 672 - } 673 - break; 674 - case 3: 675 - if (start_signature == GG_ADAM7_3_RGB_START 676 - && end_signature == GG_ADAM7_3_RGB_END) 677 - { 678 - pixel_format = GG_PIXEL_RGB; 679 - sample_format = GGRAPH_SAMPLE_UINT; 680 - bits_per_sample = 8; 681 - samples_per_pixel = 3; 682 - } 683 - if (start_signature == GG_ADAM7_3_GRAYSCALE_START 684 - && end_signature == GG_ADAM7_3_GRAYSCALE_END) 685 - { 686 - pixel_format = GG_PIXEL_GRAYSCALE; 687 - sample_format = GGRAPH_SAMPLE_UINT; 688 - bits_per_sample = 8; 689 - } 690 - if (start_signature == GG_ADAM7_3_PALETTE_START 691 - && end_signature == GG_ADAM7_3_PALETTE_END) 692 - { 693 - pixel_format = GG_PIXEL_PALETTE; 694 - sample_format = GGRAPH_SAMPLE_UINT; 695 - bits_per_sample = 8; 696 - } 697 - if (start_signature == GG_ADAM7_3_INT16_START 698 - && end_signature == GG_ADAM7_3_INT16_END) 699 - { 700 - pixel_format = GG_PIXEL_GRID; 701 - sample_format = GGRAPH_SAMPLE_INT; 702 - bits_per_sample = 16; 703 - } 704 - if (start_signature == GG_ADAM7_3_INT32_START 705 - && end_signature == GG_ADAM7_3_INT32_END) 706 - { 707 - pixel_format = GG_PIXEL_GRID; 708 - sample_format = GGRAPH_SAMPLE_INT; 709 - bits_per_sample = 32; 710 - } 711 - if (start_signature == GG_ADAM7_3_UINT16_START 712 - && end_signature == GG_ADAM7_3_UINT16_END) 713 - { 714 - pixel_format = GG_PIXEL_GRID; 715 - sample_format = GGRAPH_SAMPLE_UINT; 716 - bits_per_sample = 16; 717 - } 718 - if (start_signature == GG_ADAM7_3_UINT32_START 719 - && end_signature == GG_ADAM7_3_UINT32_END) 720 - { 721 - pixel_format = GG_PIXEL_GRID; 722 - sample_format = GGRAPH_SAMPLE_UINT; 723 - bits_per_sample = 32; 724 - } 725 - if (start_signature == GG_ADAM7_3_FLOAT_START 726 - && end_signature == GG_ADAM7_3_FLOAT_END) 727 - { 728 - pixel_format = GG_PIXEL_GRID; 729 - sample_format = GGRAPH_SAMPLE_FLOAT; 730 - bits_per_sample = 32; 731 - } 732 - if (start_signature == GG_ADAM7_3_DOUBLE_START 733 - && end_signature == GG_ADAM7_3_DOUBLE_END) 734 - { 735 - pixel_format = GG_PIXEL_GRID; 736 - sample_format = GGRAPH_SAMPLE_FLOAT; 737 - bits_per_sample = 64; 738 - } 739 - break; 740 - case 4: 741 - if (start_signature == GG_ADAM7_4_RGB_START 742 - && end_signature == GG_ADAM7_4_RGB_END) 743 - { 744 - pixel_format = GG_PIXEL_RGB; 745 - sample_format = GGRAPH_SAMPLE_UINT; 746 - bits_per_sample = 8; 747 - samples_per_pixel = 3; 748 - } 749 - if (start_signature == GG_ADAM7_4_GRAYSCALE_START 750 - && end_signature == GG_ADAM7_4_GRAYSCALE_END) 751 - { 752 - pixel_format = GG_PIXEL_GRAYSCALE; 753 - sample_format = GGRAPH_SAMPLE_UINT; 754 - bits_per_sample = 8; 755 - } 756 - if (start_signature == GG_ADAM7_4_PALETTE_START 757 - && end_signature == GG_ADAM7_4_PALETTE_END) 758 - { 759 - pixel_format = GG_PIXEL_PALETTE; 760 - sample_format = GGRAPH_SAMPLE_UINT; 761 - bits_per_sample = 8; 762 - } 763 - if (start_signature == GG_ADAM7_4_INT16_START 764 - && end_signature == GG_ADAM7_4_INT16_END) 765 - { 766 - pixel_format = GG_PIXEL_GRID; 767 - sample_format = GGRAPH_SAMPLE_INT; 768 - bits_per_sample = 16; 769 - } 770 - if (start_signature == GG_ADAM7_4_INT32_START 771 - && end_signature == GG_ADAM7_4_INT32_END) 772 - { 773 - pixel_format = GG_PIXEL_GRID; 774 - sample_format = GGRAPH_SAMPLE_INT; 775 - bits_per_sample = 32; 776 - } 777 - if (start_signature == GG_ADAM7_4_UINT16_START 778 - && end_signature == GG_ADAM7_4_UINT16_END) 779 - { 780 - pixel_format = GG_PIXEL_GRID; 781 - sample_format = GGRAPH_SAMPLE_UINT; 782 - bits_per_sample = 16; 783 - } 784 - if (start_signature == GG_ADAM7_4_UINT32_START 785 - && end_signature == GG_ADAM7_4_UINT32_END) 786 - { 787 - pixel_format = GG_PIXEL_GRID; 788 - sample_format = GGRAPH_SAMPLE_UINT; 789 - bits_per_sample = 32; 790 - } 791 - if (start_signature == GG_ADAM7_4_FLOAT_START 792 - && end_signature == GG_ADAM7_4_FLOAT_END) 793 - { 794 - pixel_format = GG_PIXEL_GRID; 795 - sample_format = GGRAPH_SAMPLE_FLOAT; 796 - bits_per_sample = 32; 797 - } 798 - if (start_signature == GG_ADAM7_4_DOUBLE_START 799 - && end_signature == GG_ADAM7_4_DOUBLE_END) 800 - { 801 - pixel_format = GG_PIXEL_GRID; 802 - sample_format = GGRAPH_SAMPLE_FLOAT; 803 - bits_per_sample = 64; 804 - } 805 - break; 806 - case 5: 807 - if (start_signature == GG_ADAM7_5_RGB_START 808 - && end_signature == GG_ADAM7_5_RGB_END) 809 - { 810 - pixel_format = GG_PIXEL_RGB; 811 - sample_format = GGRAPH_SAMPLE_UINT; 812 - bits_per_sample = 8; 813 - samples_per_pixel = 3; 814 - } 815 - if (start_signature == GG_ADAM7_5_GRAYSCALE_START 816 - && end_signature == GG_ADAM7_5_GRAYSCALE_END) 817 - { 818 - pixel_format = GG_PIXEL_GRAYSCALE; 819 - sample_format = GGRAPH_SAMPLE_UINT; 820 - bits_per_sample = 8; 821 - } 822 - if (start_signature == GG_ADAM7_5_PALETTE_START 823 - && end_signature == GG_ADAM7_5_PALETTE_END) 824 - { 825 - pixel_format = GG_PIXEL_PALETTE; 826 - sample_format = GGRAPH_SAMPLE_UINT; 827 - bits_per_sample = 8; 828 - } 829 - if (start_signature == GG_ADAM7_5_INT16_START 830 - && end_signature == GG_ADAM7_5_INT16_END) 831 - { 832 - pixel_format = GG_PIXEL_GRID; 833 - sample_format = GGRAPH_SAMPLE_INT; 834 - bits_per_sample = 16; 835 - } 836 - if (start_signature == GG_ADAM7_5_INT32_START 837 - && end_signature == GG_ADAM7_5_INT32_END) 838 - { 839 - pixel_format = GG_PIXEL_GRID; 840 - sample_format = GGRAPH_SAMPLE_INT; 841 - bits_per_sample = 32; 842 - } 843 - if (start_signature == GG_ADAM7_5_UINT16_START 844 - && end_signature == GG_ADAM7_5_UINT16_END) 845 - { 846 - pixel_format = GG_PIXEL_GRID; 847 - sample_format = GGRAPH_SAMPLE_UINT; 848 - bits_per_sample = 16; 849 - } 850 - if (start_signature == GG_ADAM7_5_UINT32_START 851 - && end_signature == GG_ADAM7_5_UINT32_END) 852 - { 853 - pixel_format = GG_PIXEL_GRID; 854 - sample_format = GGRAPH_SAMPLE_UINT; 855 - bits_per_sample = 32; 856 - } 857 - if (start_signature == GG_ADAM7_5_FLOAT_START 858 - && end_signature == GG_ADAM7_5_FLOAT_END) 859 - { 860 - pixel_format = GG_PIXEL_GRID; 861 - sample_format = GGRAPH_SAMPLE_FLOAT; 862 - bits_per_sample = 32; 863 - } 864 - if (start_signature == GG_ADAM7_5_DOUBLE_START 865 - && end_signature == GG_ADAM7_5_DOUBLE_END) 866 - { 867 - pixel_format = GG_PIXEL_GRID; 868 - sample_format = GGRAPH_SAMPLE_FLOAT; 869 - bits_per_sample = 64; 870 - } 871 - break; 872 - case 6: 873 - if (start_signature == GG_ADAM7_6_RGB_START 874 - && end_signature == GG_ADAM7_6_RGB_END) 875 - { 876 - pixel_format = GG_PIXEL_RGB; 877 - sample_format = GGRAPH_SAMPLE_UINT; 878 - bits_per_sample = 8; 879 - samples_per_pixel = 3; 880 - } 881 - if (start_signature == GG_ADAM7_6_GRAYSCALE_START 882 - && end_signature == GG_ADAM7_6_GRAYSCALE_END) 883 - { 884 - pixel_format = GG_PIXEL_GRAYSCALE; 885 - sample_format = GGRAPH_SAMPLE_UINT; 886 - bits_per_sample = 8; 887 - } 888 - if (start_signature == GG_ADAM7_6_PALETTE_START 889 - && end_signature == GG_ADAM7_6_PALETTE_END) 890 - { 891 - pixel_format = GG_PIXEL_PALETTE; 892 - sample_format = GGRAPH_SAMPLE_UINT; 893 - bits_per_sample = 8; 894 - } 895 - if (start_signature == GG_ADAM7_6_INT16_START 896 - && end_signature == GG_ADAM7_6_INT16_END) 897 - { 898 - pixel_format = GG_PIXEL_GRID; 899 - sample_format = GGRAPH_SAMPLE_INT; 900 - bits_per_sample = 16; 901 - } 902 - if (start_signature == GG_ADAM7_6_INT32_START 903 - && end_signature == GG_ADAM7_6_INT32_END) 904 - { 905 - pixel_format = GG_PIXEL_GRID; 906 - sample_format = GGRAPH_SAMPLE_INT; 907 - bits_per_sample = 32; 908 - } 909 - if (start_signature == GG_ADAM7_6_UINT16_START 910 - && end_signature == GG_ADAM7_6_UINT16_END) 911 - { 912 - pixel_format = GG_PIXEL_GRID; 913 - sample_format = GGRAPH_SAMPLE_UINT; 914 - bits_per_sample = 16; 915 - } 916 - if (start_signature == GG_ADAM7_6_UINT32_START 917 - && end_signature == GG_ADAM7_6_UINT32_END) 918 - { 919 - pixel_format = GG_PIXEL_GRID; 920 - sample_format = GGRAPH_SAMPLE_UINT; 921 - bits_per_sample = 32; 922 - } 923 - if (start_signature == GG_ADAM7_6_FLOAT_START 924 - && end_signature == GG_ADAM7_6_FLOAT_END) 925 - { 926 - pixel_format = GG_PIXEL_GRID; 927 - sample_format = GGRAPH_SAMPLE_FLOAT; 928 - bits_per_sample = 32; 929 - } 930 - if (start_signature == GG_ADAM7_6_DOUBLE_START 931 - && end_signature == GG_ADAM7_6_DOUBLE_END) 932 - { 933 - pixel_format = GG_PIXEL_GRID; 934 - sample_format = GGRAPH_SAMPLE_FLOAT; 935 - bits_per_sample = 64; 936 - } 937 - break; 938 - }; 939 - if (pixel_format == GG_PIXEL_UNKNOWN) 940 - return NULL; 941 - 942 -/* retrieving image dimensions */ 943 - p_in = mem_buf; 944 - p_in += sizeof (short); 945 - width = gg_import_int16 (p_in, endian, endian_arch); 946 - p_in += sizeof (short); 947 - height = gg_import_int16 (p_in, endian, endian_arch); 948 - p_in += sizeof (short); 949 - if (width == 0 || height == 0) 950 - return NULL; 951 - 952 -/* checking the pix-buffer size */ 953 - switch (pixel_format) 954 - { 955 - case GG_PIXEL_RGB: 956 - case GG_PIXEL_GRAYSCALE: 957 - size = width * height * samples_per_pixel; 958 - break; 959 - case GG_PIXEL_PALETTE: 960 - size = width * height; 961 - break; 962 - case GG_PIXEL_GRID: 963 - switch (sample_format) 964 - { 965 - case GGRAPH_SAMPLE_INT: 966 - if (bits_per_sample == 16) 967 - size = width * height * sizeof (short); 968 - else 969 - size = width * height * sizeof (int); 970 - break; 971 - case GGRAPH_SAMPLE_UINT: 972 - if (bits_per_sample == 16) 973 - size = width * height * sizeof (unsigned short); 974 - else 975 - size = width * height * sizeof (unsigned int); 976 - break; 977 - case GGRAPH_SAMPLE_FLOAT: 978 - if (bits_per_sample == 32) 979 - size = width * height * sizeof (float); 980 - else 981 - size = width * height * sizeof (double); 982 - break; 983 - }; 984 - break; 985 - }; 986 - if (size != mem_buf_size - (4 * (int) sizeof (short))) 987 - return NULL; 988 - 989 -/* allocating a new image */ 990 - img = 991 - gg_image_create (pixel_format, width, height, bits_per_sample, 992 - samples_per_pixel, sample_format, NULL, NULL); 993 - if (!img) 994 - return NULL; 995 - 996 - if (pixel_format == GG_PIXEL_GRID) 997 - { 998 - /* extracting GRID-values accordingly to endianness */ 999 - short *p_short = (short *) (img->pixels); 1000 - int *p_int = (int *) (img->pixels); 1001 - unsigned short *p_ushort = (unsigned short *) (img->pixels); 1002 - unsigned int *p_uint = (unsigned int *) (img->pixels); 1003 - float *p_float = (float *) (img->pixels); 1004 - double *p_double = (double *) (img->pixels); 1005 - for (y = 0; y < height; y++) 1006 - { 1007 - for (x = 0; x < width; x++) 1008 - { 1009 - switch (sample_format) 1010 - { 1011 - case GGRAPH_SAMPLE_INT: 1012 - if (bits_per_sample == 16) 1013 - { 1014 - short value = gg_import_int16 (p_in, endian, 1015 - endian_arch); 1016 - p_in += sizeof (short); 1017 - *p_short++ = value; 1018 - } 1019 - else 1020 - { 1021 - int value = gg_import_int32 (p_in, endian, 1022 - endian_arch); 1023 - p_in += sizeof (int); 1024 - *p_int++ = value; 1025 - } 1026 - break; 1027 - case GGRAPH_SAMPLE_UINT: 1028 - if (bits_per_sample == 16) 1029 - { 1030 - unsigned short value = 1031 - gg_import_uint16 (p_in, endian, 1032 - endian_arch); 1033 - p_in += sizeof (unsigned short); 1034 - *p_ushort++ = value; 1035 - } 1036 - else 1037 - { 1038 - unsigned int value = 1039 - gg_import_uint32 (p_in, endian, 1040 - endian_arch); 1041 - p_in += sizeof (unsigned int); 1042 - *p_uint++ = value; 1043 - } 1044 - break; 1045 - case GGRAPH_SAMPLE_FLOAT: 1046 - if (bits_per_sample == 32) 1047 - { 1048 - float value = gg_import_float (p_in, endian, 1049 - endian_arch); 1050 - p_in += sizeof (float); 1051 - *p_float++ = value; 1052 - } 1053 - else 1054 - { 1055 - double value = gg_import_double (p_in, endian, 1056 - endian_arch); 1057 - p_in += sizeof (double); 1058 - *p_double++ = value; 1059 - } 1060 - break; 1061 - }; 1062 - } 1063 - } 1064 - } 1065 - else 1066 - memcpy (img->pixels, p_in, size); 1067 - return img; 1068 -} 1069 - 1070 -static int 1071 -check_adam7_subs (gGraphImagePtr im1, gGraphImagePtr im2) 1072 -{ 1073 -/* checks if two Adam7 images are of the same type */ 1074 - if (im1->pixel_format != im2->pixel_format) 1075 - return 0; 1076 - if (im1->sample_format != im2->sample_format) 1077 - return 0; 1078 - if (im1->samples_per_pixel != im2->samples_per_pixel) 1079 - return 0; 1080 - if (im1->bits_per_sample != im2->bits_per_sample) 1081 - return 0; 1082 - return 1; 1083 -} 1084 - 1085 -static int 1086 -get_adam7_dims_4 (gGraphImagePtr img_0, gGraphImagePtr img_1, 1087 - gGraphImagePtr img_2, int *width, int *height) 1088 -{ 1089 -/* checking/computing Adam7 dimensions [1:4 scale] */ 1090 - int w; 1091 - int h; 1092 - int out_width; 1093 - int out_height; 1094 - 1095 - out_width = (img_0->width * 2) - 1; 1096 - out_height = (img_0->height * 2) - 1; 1097 - 1098 - w = img_1->width * 2; 1099 - h = (img_0->height * 2) - 1; 1100 - if (w > out_width) 1101 - out_width = w; 1102 - if (h > out_height) 1103 - out_height = h; 1104 - 1105 - w = img_2->width; 1106 - h = img_2->height * 2; 1107 - if (w > out_width) 1108 - out_width = w; 1109 - if (h > out_height) 1110 - out_height = h; 1111 - 1112 - *width = out_width; 1113 - *height = out_height; 1114 - return 1; 1115 -} 1116 - 1117 -static int 1118 -get_adam7_dims_2 (gGraphImagePtr img_0, gGraphImagePtr img_1, 1119 - gGraphImagePtr img_2, gGraphImagePtr img_3, 1120 - gGraphImagePtr img_4, int *width, int *height) 1121 -{ 1122 -/* checking/computing Adam7 dimensions [1:2 scale] */ 1123 - int w; 1124 - int h; 1125 - int out_width; 1126 - int out_height; 1127 - 1128 - out_width = (img_0->width * 4) - 3; 1129 - out_height = (img_0->height * 4) - 3; 1130 - 1131 - w = (img_1->width * 4) - 1; 1132 - h = (img_0->height * 4) - 3; 1133 - if (w > out_width) 1134 - out_width = w; 1135 - if (h > out_height) 1136 - out_height = h; 1137 - 1138 - w = (img_2->width * 2) - 1; 1139 - h = (img_2->height * 4) - 1; 1140 - if (w > out_width) 1141 - out_width = w; 1142 - if (h > out_height) 1143 - out_height = h; 1144 - 1145 - w = img_3->width * 2; 1146 - h = (img_3->height * 2) - 1; 1147 - if (w > out_width) 1148 - out_width = w; 1149 - if (h > out_height) 1150 - out_height = h; 1151 - 1152 - w = img_4->width; 1153 - h = img_4->height * 2; 1154 - if (w > out_width) 1155 - out_width = w; 1156 - if (h > out_height) 1157 - out_height = h; 1158 - 1159 - *width = out_width; 1160 - *height = out_height; 1161 - return 1; 1162 -} 1163 - 1164 -static int 1165 -get_adam7_dims_1 (gGraphImagePtr img_0, gGraphImagePtr img_1, 1166 - gGraphImagePtr img_2, gGraphImagePtr img_3, 1167 - gGraphImagePtr img_4, gGraphImagePtr img_5, 1168 - gGraphImagePtr img_6, int *width, int *height) 1169 -{ 1170 -/* computing Adam7 dimensions [1:1 scale] */ 1171 - int w; 1172 - int h; 1173 - int out_width; 1174 - int out_height; 1175 - 1176 - out_width = (img_0->width * 8) - 7; 1177 - out_height = (img_0->height * 8) - 7; 1178 - 1179 - w = (img_1->width * 8) - 3; 1180 - h = (img_0->height * 8) - 7; 1181 - if (w > out_width) 1182 - out_width = w; 1183 - if (h > out_height) 1184 - out_height = h; 1185 - 1186 - w = (img_2->width * 4) - 3; 1187 - h = (img_2->height * 8) - 3; 1188 - if (w > out_width) 1189 - out_width = w; 1190 - if (h > out_height) 1191 - out_height = h; 1192 - 1193 - w = (img_3->width * 4) - 1; 1194 - h = (img_3->height * 4) - 3; 1195 - if (w > out_width) 1196 - out_width = w; 1197 - if (h > out_height) 1198 - out_height = h; 1199 - 1200 - w = (img_4->width * 2) - 1; 1201 - h = (img_4->height * 4) - 1; 1202 - if (w > out_width) 1203 - out_width = w; 1204 - if (h > out_height) 1205 - out_height = h; 1206 - 1207 - w = img_5->width * 2; 1208 - h = (img_5->height * 2) - 1; 1209 - if (w > out_width) 1210 - out_width = w; 1211 - if (h > out_height) 1212 - out_height = h; 1213 - 1214 - w = img_6->width; 1215 - h = img_6->height * 2; 1216 - if (w > out_width) 1217 - out_width = w; 1218 - if (h > out_height) 1219 - out_height = h; 1220 - 1221 - *width = out_width; 1222 - *height = out_height; 1223 - return 1; 1224 -} 1225 - 1226 -static gGraphImagePtr 1227 -merge_adam7_scale_1 (gGraphImagePtr img_0, gGraphImagePtr img_1, 1228 - gGraphImagePtr img_2, gGraphImagePtr img_3, 1229 - gGraphImagePtr img_4, gGraphImagePtr img_5, 1230 - gGraphImagePtr img_6, int width, int height) 1231 -{ 1232 -/* decoding an Adam7 image (1:1) */ 1233 - int x; 1234 - int y; 1235 - unsigned char *p_in; 1236 - unsigned char *p_out; 1237 - gGraphImagePtr img = gg_image_create (img_0->pixel_format, width, height, 1238 - img_0->bits_per_sample, 1239 - img_0->samples_per_pixel, 1240 - img_0->sample_format, NULL, 1241 - NULL); 1242 - if (!img) 1243 - return NULL; 1244 - 1245 -/* expanding SubImage-0 */ 1246 - for (y = 0; y < img_0->height; y++) 1247 - { 1248 - p_in = img_0->pixels + (y * img_0->scanline_width); 1249 - p_out = img->pixels + ((y * 8) * img->scanline_width); 1250 - for (x = 0; x < img_0->width; x++) 1251 - { 1252 - switch (img->pixel_format) 1253 - { 1254 - case GG_PIXEL_RGB: 1255 - *p_out++ = *p_in++; 1256 - *p_out++ = *p_in++; 1257 - *p_out++ = *p_in++; 1258 - p_out += (7 * 3); 1259 - break; 1260 - case GG_PIXEL_GRAYSCALE: 1261 - case GG_PIXEL_PALETTE: 1262 - *p_out = *p_in++; 1263 - p_out += 8; 1264 - break; 1265 - case GG_PIXEL_GRID: 1266 - switch (img_0->pixel_format) 1267 - { 1268 - case GGRAPH_SAMPLE_INT: 1269 - if (img_0->bits_per_sample == 16) 1270 - { 1271 - short *p = (short *) p_in; 1272 - short value = *p; 1273 - p_in += sizeof (short); 1274 - p = (short *) p_out; 1275 - *p = value; 1276 - p_out += sizeof (short) * 8; 1277 - } 1278 - else 1279 - { 1280 - int *p = (int *) p_in; 1281 - int value = *p; 1282 - p_in += sizeof (int); 1283 - p = (int *) p_out; 1284 - *p = value; 1285 - p_out += sizeof (int) * 8; 1286 - } 1287 - break; 1288 - case GGRAPH_SAMPLE_UINT: 1289 - if (img_0->bits_per_sample == 16) 1290 - { 1291 - unsigned short *p = (unsigned short *) p_in; 1292 - unsigned short value = *p; 1293 - p_in += sizeof (unsigned short); 1294 - p = (unsigned short *) p_out; 1295 - *p = value; 1296 - p_out += sizeof (unsigned short) * 8; 1297 - } 1298 - else 1299 - { 1300 - unsigned int *p = (unsigned int *) p_in; 1301 - int value = *p; 1302 - p_in += sizeof (unsigned int); 1303 - p = (unsigned int *) p_out; 1304 - *p = value; 1305 - p_out += sizeof (unsigned int) * 8; 1306 - } 1307 - break; 1308 - case GGRAPH_SAMPLE_FLOAT: 1309 - if (img_0->bits_per_sample == 32) 1310 - { 1311 - float *p = (float *) p_in; 1312 - float value = *p; 1313 - p_in += sizeof (float); 1314 - p = (float *) p_out; 1315 - *p = value; 1316 - p_out += sizeof (float) * 8; 1317 - } 1318 - else 1319 - { 1320 - double *p = (double *) p_in; 1321 - double value = *p; 1322 - p_in += sizeof (double); 1323 - p = (double *) p_out; 1324 - *p = value; 1325 - p_out += sizeof (double) * 8; 1326 - } 1327 - break; 1328 - }; 1329 - break; 1330 - }; 1331 - } 1332 - } 1333 - 1334 -/* expanding SubImage-1 */ 1335 - for (y = 0; y < img_1->height; y++) 1336 - { 1337 - p_in = img_1->pixels + (y * img_1->scanline_width); 1338 - p_out = 1339 - img->pixels + ((y * 8) * img->scanline_width) + 1340 - (4 * img->pixel_size); 1341 - for (x = 0; x < img_1->width; x++) 1342 - { 1343 - switch (img->pixel_format) 1344 - { 1345 - case GG_PIXEL_RGB: 1346 - *p_out++ = *p_in++; 1347 - *p_out++ = *p_in++; 1348 - *p_out++ = *p_in++; 1349 - p_out += (7 * 3); 1350 - break; 1351 - case GG_PIXEL_GRAYSCALE: 1352 - case GG_PIXEL_PALETTE: 1353 - *p_out = *p_in++; 1354 - p_out += 8; 1355 - break; 1356 - case GG_PIXEL_GRID: 1357 - switch (img_0->pixel_format) 1358 - { 1359 - case GGRAPH_SAMPLE_INT: 1360 - if (img_0->bits_per_sample == 16) 1361 - { 1362 - short *p = (short *) p_in; 1363 - short value = *p; 1364 - p_in += sizeof (short); 1365 - p = (short *) p_out; 1366 - *p = value; 1367 - p_out += sizeof (short) * 8; 1368 - } 1369 - else 1370 - { 1371 - int *p = (int *) p_in; 1372 - int value = *p; 1373 - p_in += sizeof (int); 1374 - p = (int *) p_out; 1375 - *p = value; 1376 - p_out += sizeof (int) * 8; 1377 - } 1378 - break; 1379 - case GGRAPH_SAMPLE_UINT: 1380 - if (img_0->bits_per_sample == 16) 1381 - { 1382 - unsigned short *p = (unsigned short *) p_in; 1383 - unsigned short value = *p; 1384 - p_in += sizeof (unsigned short); 1385 - p = (unsigned short *) p_out; 1386 - *p = value; 1387 - p_out += sizeof (unsigned short) * 8; 1388 - } 1389 - else 1390 - { 1391 - unsigned int *p = (unsigned int *) p_in; 1392 - int value = *p; 1393 - p_in += sizeof (unsigned int); 1394 - p = (unsigned int *) p_out; 1395 - *p = value; 1396 - p_out += sizeof (unsigned int) * 8; 1397 - } 1398 - break; 1399 - case GGRAPH_SAMPLE_FLOAT: 1400 - if (img_0->bits_per_sample == 32) 1401 - { 1402 - float *p = (float *) p_in; 1403 - float value = *p; 1404 - p_in += sizeof (float); 1405 - p = (float *) p_out; 1406 - *p = value; 1407 - p_out += sizeof (float) * 8; 1408 - } 1409 - else 1410 - { 1411 - double *p = (double *) p_in; 1412 - double value = *p; 1413 - p_in += sizeof (double); 1414 - p = (double *) p_out; 1415 - *p = value; 1416 - p_out += sizeof (double) * 8; 1417 - } 1418 - break; 1419 - }; 1420 - break; 1421 - }; 1422 - } 1423 - } 1424 - 1425 -/* expanding SubImage-2 */ 1426 - for (y = 0; y < img_2->height; y++) 1427 - { 1428 - p_in = img_2->pixels + (y * img_2->scanline_width); 1429 - p_out = img->pixels + (((y * 8) + 4) * img->scanline_width); 1430 - for (x = 0; x < img_2->width; x++) 1431 - { 1432 - switch (img->pixel_format) 1433 - { 1434 - case GG_PIXEL_RGB: 1435 - *p_out++ = *p_in++; 1436 - *p_out++ = *p_in++; 1437 - *p_out++ = *p_in++; 1438 - p_out += (3 * 3); 1439 - break; 1440 - case GG_PIXEL_GRAYSCALE: 1441 - case GG_PIXEL_PALETTE: 1442 - *p_out = *p_in++; 1443 - p_out += 4; 1444 - break; 1445 - case GG_PIXEL_GRID: 1446 - switch (img_0->pixel_format) 1447 - { 1448 - case GGRAPH_SAMPLE_INT: 1449 - if (img_0->bits_per_sample == 16) 1450 - { 1451 - short *p = (short *) p_in; 1452 - short value = *p; 1453 - p_in += sizeof (short); 1454 - p = (short *) p_out; 1455 - *p = value; 1456 - p_out += sizeof (short) * 4; 1457 - } 1458 - else 1459 - { 1460 - int *p = (int *) p_in; 1461 - int value = *p; 1462 - p_in += sizeof (int); 1463 - p = (int *) p_out; 1464 - *p = value; 1465 - p_out += sizeof (int) * 4; 1466 - } 1467 - break; 1468 - case GGRAPH_SAMPLE_UINT: 1469 - if (img_0->bits_per_sample == 16) 1470 - { 1471 - unsigned short *p = (unsigned short *) p_in; 1472 - unsigned short value = *p; 1473 - p_in += sizeof (unsigned short); 1474 - p = (unsigned short *) p_out; 1475 - *p = value; 1476 - p_out += sizeof (unsigned short) * 4; 1477 - } 1478 - else 1479 - { 1480 - unsigned int *p = (unsigned int *) p_in; 1481 - int value = *p; 1482 - p_in += sizeof (unsigned int); 1483 - p = (unsigned int *) p_out; 1484 - *p = value; 1485 - p_out += sizeof (unsigned int) * 4; 1486 - } 1487 - break; 1488 - case GGRAPH_SAMPLE_FLOAT: 1489 - if (img_0->bits_per_sample == 32) 1490 - { 1491 - float *p = (float *) p_in; 1492 - float value = *p; 1493 - p_in += sizeof (float); 1494 - p = (float *) p_out; 1495 - *p = value; 1496 - p_out += sizeof (float) * 4; 1497 - } 1498 - else 1499 - { 1500 - double *p = (double *) p_in; 1501 - double value = *p; 1502 - p_in += sizeof (double); 1503 - p = (double *) p_out; 1504 - *p = value; 1505 - p_out += sizeof (double) * 4; 1506 - } 1507 - break; 1508 - }; 1509 - break; 1510 - }; 1511 - } 1512 - } 1513 - 1514 -/* expanding SubImage-3 */ 1515 - for (y = 0; y < img_3->height; y++) 1516 - { 1517 - p_in = img_3->pixels + (y * img_3->scanline_width); 1518 - p_out = 1519 - img->pixels + ((y * 4) * img->scanline_width) + 1520 - (2 * img->pixel_size); 1521 - for (x = 0; x < img_3->width; x++) 1522 - { 1523 - switch (img->pixel_format) 1524 - { 1525 - case GG_PIXEL_RGB: 1526 - *p_out++ = *p_in++; 1527 - *p_out++ = *p_in++; 1528 - *p_out++ = *p_in++; 1529 - p_out += (3 * 3); 1530 - break; 1531 - case GG_PIXEL_GRAYSCALE: 1532 - case GG_PIXEL_PALETTE: 1533 - *p_out = *p_in++; 1534 - p_out += 4; 1535 - break; 1536 - case GG_PIXEL_GRID: 1537 - switch (img_0->pixel_format) 1538 - { 1539 - case GGRAPH_SAMPLE_INT: 1540 - if (img_0->bits_per_sample == 16) 1541 - { 1542 - short *p = (short *) p_in; 1543 - short value = *p; 1544 - p_in += sizeof (short); 1545 - p = (short *) p_out; 1546 - *p = value; 1547 - p_out += sizeof (short) * 4; 1548 - } 1549 - else 1550 - { 1551 - int *p = (int *) p_in; 1552 - int value = *p; 1553 - p_in += sizeof (int); 1554 - p = (int *) p_out; 1555 - *p = value; 1556 - p_out += sizeof (int) * 4; 1557 - } 1558 - break; 1559 - case GGRAPH_SAMPLE_UINT: 1560 - if (img_0->bits_per_sample == 16) 1561 - { 1562 - unsigned short *p = (unsigned short *) p_in; 1563 - unsigned short value = *p; 1564 - p_in += sizeof (unsigned short); 1565 - p = (unsigned short *) p_out; 1566 - *p = value; 1567 - p_out += sizeof (unsigned short) * 4; 1568 - } 1569 - else 1570 - { 1571 - unsigned int *p = (unsigned int *) p_in; 1572 - int value = *p; 1573 - p_in += sizeof (unsigned int); 1574 - p = (unsigned int *) p_out; 1575 - *p = value; 1576 - p_out += sizeof (unsigned int) * 4; 1577 - } 1578 - break; 1579 - case GGRAPH_SAMPLE_FLOAT: 1580 - if (img_0->bits_per_sample == 32) 1581 - { 1582 - float *p = (float *) p_in; 1583 - float value = *p; 1584 - p_in += sizeof (float); 1585 - p = (float *) p_out; 1586 - *p = value; 1587 - p_out += sizeof (float) * 4; 1588 - } 1589 - else 1590 - { 1591 - double *p = (double *) p_in; 1592 - double value = *p; 1593 - p_in += sizeof (double); 1594 - p = (double *) p_out; 1595 - *p = value; 1596 - p_out += sizeof (double) * 4; 1597 - } 1598 - break; 1599 - }; 1600 - break; 1601 - }; 1602 - } 1603 - } 1604 - 1605 -/* expanding SubImage-4 */ 1606 - for (y = 0; y < img_4->height; y++) 1607 - { 1608 - p_in = img_4->pixels + (y * img_4->scanline_width); 1609 - p_out = img->pixels + (((y * 4) + 2) * img->scanline_width); 1610 - for (x = 0; x < img_4->width; x++) 1611 - { 1612 - switch (img->pixel_format) 1613 - { 1614 - case GG_PIXEL_RGB: 1615 - *p_out++ = *p_in++; 1616 - *p_out++ = *p_in++; 1617 - *p_out++ = *p_in++; 1618 - p_out += 3; 1619 - break; 1620 - case GG_PIXEL_GRAYSCALE: 1621 - case GG_PIXEL_PALETTE: 1622 - *p_out = *p_in++; 1623 - p_out += 2; 1624 - break; 1625 - case GG_PIXEL_GRID: 1626 - switch (img_0->pixel_format) 1627 - { 1628 - case GGRAPH_SAMPLE_INT: 1629 - if (img_0->bits_per_sample == 16) 1630 - { 1631 - short *p = (short *) p_in; 1632 - short value = *p; 1633 - p_in += sizeof (short); 1634 - p = (short *) p_out; 1635 - *p = value; 1636 - p_out += sizeof (short) * 2; 1637 - } 1638 - else 1639 - { 1640 - int *p = (int *) p_in; 1641 - int value = *p; 1642 - p_in += sizeof (int); 1643 - p = (int *) p_out; 1644 - *p = value; 1645 - p_out += sizeof (int) * 2; 1646 - } 1647 - break; 1648 - case GGRAPH_SAMPLE_UINT: 1649 - if (img_0->bits_per_sample == 16) 1650 - { 1651 - unsigned short *p = (unsigned short *) p_in; 1652 - unsigned short value = *p; 1653 - p_in += sizeof (unsigned short); 1654 - p = (unsigned short *) p_out; 1655 - *p = value; 1656 - p_out += sizeof (unsigned short) * 2; 1657 - } 1658 - else 1659 - { 1660 - unsigned int *p = (unsigned int *) p_in; 1661 - int value = *p; 1662 - p_in += sizeof (unsigned int); 1663 - p = (unsigned int *) p_out; 1664 - *p = value; 1665 - p_out += sizeof (unsigned int) * 2; 1666 - } 1667 - break; 1668 - case GGRAPH_SAMPLE_FLOAT: 1669 - if (img_0->bits_per_sample == 32) 1670 - { 1671 - float *p = (float *) p_in; 1672 - float value = *p; 1673 - p_in += sizeof (float); 1674 - p = (float *) p_out; 1675 - *p = value; 1676 - p_out += sizeof (float) * 2; 1677 - } 1678 - else 1679 - { 1680 - double *p = (double *) p_in; 1681 - double value = *p; 1682 - p_in += sizeof (double); 1683 - p = (double *) p_out; 1684 - *p = value; 1685 - p_out += sizeof (double) * 2; 1686 - } 1687 - break; 1688 - }; 1689 - break; 1690 - }; 1691 - } 1692 - } 1693 - 1694 -/* expanding SubImage-5 */ 1695 - for (y = 0; y < img_5->height; y++) 1696 - { 1697 - p_in = img_5->pixels + (y * img_5->scanline_width); 1698 - p_out = 1699 - img->pixels + ((y * 2) * img->scanline_width) + img->pixel_size; 1700 - for (x = 0; x < img_5->width; x++) 1701 - { 1702 - switch (img->pixel_format) 1703 - { 1704 - case GG_PIXEL_RGB: 1705 - *p_out++ = *p_in++; 1706 - *p_out++ = *p_in++; 1707 - *p_out++ = *p_in++; 1708 - p_out += 3; 1709 - break; 1710 - case GG_PIXEL_GRAYSCALE: 1711 - case GG_PIXEL_PALETTE: 1712 - *p_out = *p_in++; 1713 - p_out += 2; 1714 - break; 1715 - case GG_PIXEL_GRID: 1716 - switch (img_0->pixel_format) 1717 - { 1718 - case GGRAPH_SAMPLE_INT: 1719 - if (img_0->bits_per_sample == 16) 1720 - { 1721 - short *p = (short *) p_in; 1722 - short value = *p; 1723 - p_in += sizeof (short); 1724 - p = (short *) p_out; 1725 - *p = value; 1726 - p_out += sizeof (short) * 2; 1727 - } 1728 - else 1729 - { 1730 - int *p = (int *) p_in; 1731 - int value = *p; 1732 - p_in += sizeof (int); 1733 - p = (int *) p_out; 1734 - *p = value; 1735 - p_out += sizeof (int) * 2; 1736 - } 1737 - break; 1738 - case GGRAPH_SAMPLE_UINT: 1739 - if (img_0->bits_per_sample == 16) 1740 - { 1741 - unsigned short *p = (unsigned short *) p_in; 1742 - unsigned short value = *p; 1743 - p_in += sizeof (unsigned short); 1744 - p = (unsigned short *) p_out; 1745 - *p = value; 1746 - p_out += sizeof (unsigned short) * 2; 1747 - } 1748 - else 1749 - { 1750 - unsigned int *p = (unsigned int *) p_in; 1751 - int value = *p; 1752 - p_in += sizeof (unsigned int); 1753 - p = (unsigned int *) p_out; 1754 - *p = value; 1755 - p_out += sizeof (unsigned int) * 2; 1756 - } 1757 - break; 1758 - case GGRAPH_SAMPLE_FLOAT: 1759 - if (img_0->bits_per_sample == 32) 1760 - { 1761 - float *p = (float *) p_in; 1762 - float value = *p; 1763 - p_in += sizeof (float); 1764 - p = (float *) p_out; 1765 - *p = value; 1766 - p_out += sizeof (float) * 2; 1767 - } 1768 - else 1769 - { 1770 - double *p = (double *) p_in; 1771 - double value = *p; 1772 - p_in += sizeof (double); 1773 - p = (double *) p_out; 1774 - *p = value; 1775 - p_out += sizeof (double) * 2; 1776 - } 1777 - break; 1778 - }; 1779 - break; 1780 - }; 1781 - } 1782 - } 1783 - 1784 -/* expanding SubImage-6 */ 1785 - for (y = 0; y < img_6->height; y++) 1786 - { 1787 - p_in = img_6->pixels + (y * img_6->scanline_width); 1788 - p_out = img->pixels + (((y * 2) + 1) * img->scanline_width); 1789 - for (x = 0; x < img_6->width; x++) 1790 - { 1791 - switch (img->pixel_format) 1792 - { 1793 - case GG_PIXEL_RGB: 1794 - *p_out++ = *p_in++; 1795 - *p_out++ = *p_in++; 1796 - *p_out++ = *p_in++; 1797 - break; 1798 - case GG_PIXEL_GRAYSCALE: 1799 - case GG_PIXEL_PALETTE: 1800 - *p_out++ = *p_in++; 1801 - break; 1802 - case GG_PIXEL_GRID: 1803 - switch (img_0->pixel_format) 1804 - { 1805 - case GGRAPH_SAMPLE_INT: 1806 - if (img_0->bits_per_sample == 16) 1807 - { 1808 - short *p = (short *) p_in; 1809 - short value = *p; 1810 - p_in += sizeof (short); 1811 - p = (short *) p_out; 1812 - *p = value; 1813 - p_out += sizeof (short); 1814 - } 1815 - else 1816 - { 1817 - int *p = (int *) p_in; 1818 - int value = *p; 1819 - p_in += sizeof (int); 1820 - p = (int *) p_out; 1821 - *p = value; 1822 - p_out += sizeof (int); 1823 - } 1824 - break; 1825 - case GGRAPH_SAMPLE_UINT: 1826 - if (img_0->bits_per_sample == 16) 1827 - { 1828 - unsigned short *p = (unsigned short *) p_in; 1829 - unsigned short value = *p; 1830 - p_in += sizeof (unsigned short); 1831 - p = (unsigned short *) p_out; 1832 - *p = value; 1833 - p_out += sizeof (unsigned short); 1834 - } 1835 - else 1836 - { 1837 - unsigned int *p = (unsigned int *) p_in; 1838 - int value = *p; 1839 - p_in += sizeof (unsigned int); 1840 - p = (unsigned int *) p_out; 1841 - *p = value; 1842 - p_out += sizeof (unsigned int); 1843 - } 1844 - break; 1845 - case GGRAPH_SAMPLE_FLOAT: 1846 - if (img_0->bits_per_sample == 32) 1847 - { 1848 - float *p = (float *) p_in; 1849 - float value = *p; 1850 - p_in += sizeof (float); 1851 - p = (float *) p_out; 1852 - *p = value; 1853 - p_out += sizeof (float); 1854 - } 1855 - else 1856 - { 1857 - double *p = (double *) p_in; 1858 - double value = *p; 1859 - p_in += sizeof (double); 1860 - p = (double *) p_out; 1861 - *p = value; 1862 - p_out += sizeof (double); 1863 - } 1864 - break; 1865 - }; 1866 - break; 1867 - }; 1868 - } 1869 - } 1870 - 1871 - return img; 1872 -} 1873 - 1874 -static gGraphImagePtr 1875 -merge_adam7_scale_2 (gGraphImagePtr img_0, gGraphImagePtr img_1, 1876 - gGraphImagePtr img_2, gGraphImagePtr img_3, 1877 - gGraphImagePtr img_4, int width, int height) 1878 -{ 1879 -/* decoding an Adam7 image (1:2) */ 1880 - int x; 1881 - int y; 1882 - unsigned char *p_in; 1883 - unsigned char *p_out; 1884 - gGraphImagePtr img = gg_image_create (img_0->pixel_format, width, height, 1885 - img_0->bits_per_sample, 1886 - img_0->samples_per_pixel, 1887 - img_0->sample_format, NULL, 1888 - NULL); 1889 - if (!img) 1890 - return NULL; 1891 - 1892 -/* expanding SubImage-0 */ 1893 - for (y = 0; y < img_0->height; y++) 1894 - { 1895 - p_in = img_0->pixels + (y * img_0->scanline_width); 1896 - p_out = img->pixels + ((y * 4) * img->scanline_width); 1897 - for (x = 0; x < img_0->width; x++) 1898 - { 1899 - switch (img->pixel_format) 1900 - { 1901 - case GG_PIXEL_RGB: 1902 - *p_out++ = *p_in++; 1903 - *p_out++ = *p_in++; 1904 - *p_out++ = *p_in++; 1905 - p_out += (3 * 3); 1906 - break; 1907 - case GG_PIXEL_GRAYSCALE: 1908 - case GG_PIXEL_PALETTE: 1909 - *p_out = *p_in++; 1910 - p_out += 4; 1911 - break; 1912 - case GG_PIXEL_GRID: 1913 - switch (img_0->pixel_format) 1914 - { 1915 - case GGRAPH_SAMPLE_INT: 1916 - if (img_0->bits_per_sample == 16) 1917 - { 1918 - short *p = (short *) p_in; 1919 - short value = *p; 1920 - p_in += sizeof (short); 1921 - p = (short *) p_out; 1922 - *p = value; 1923 - p_out += sizeof (short) * 4; 1924 - } 1925 - else 1926 - { 1927 - int *p = (int *) p_in; 1928 - int value = *p; 1929 - p_in += sizeof (int); 1930 - p = (int *) p_out; 1931 - *p = value; 1932 - p_out += sizeof (int) * 4; 1933 - } 1934 - break; 1935 - case GGRAPH_SAMPLE_UINT: 1936 - if (img_0->bits_per_sample == 16) 1937 - { 1938 - unsigned short *p = (unsigned short *) p_in; 1939 - unsigned short value = *p; 1940 - p_in += sizeof (unsigned short); 1941 - p = (unsigned short *) p_out; 1942 - *p = value; 1943 - p_out += sizeof (unsigned short) * 4; 1944 - } 1945 - else 1946 - { 1947 - unsigned int *p = (unsigned int *) p_in; 1948 - int value = *p; 1949 - p_in += sizeof (unsigned int); 1950 - p = (unsigned int *) p_out; 1951 - *p = value; 1952 - p_out += sizeof (unsigned int) * 4; 1953 - } 1954 - break; 1955 - case GGRAPH_SAMPLE_FLOAT: 1956 - if (img_0->bits_per_sample == 32) 1957 - { 1958 - float *p = (float *) p_in; 1959 - float value = *p; 1960 - p_in += sizeof (float); 1961 - p = (float *) p_out; 1962 - *p = value; 1963 - p_out += sizeof (float) * 4; 1964 - } 1965 - else 1966 - { 1967 - double *p = (double *) p_in; 1968 - double value = *p; 1969 - p_in += sizeof (double); 1970 - p = (double *) p_out; 1971 - *p = value; 1972 - p_out += sizeof (double) * 4; 1973 - } 1974 - break; 1975 - }; 1976 - break; 1977 - }; 1978 - } 1979 - } 1980 - 1981 -/* expanding SubImage-1 */ 1982 - for (y = 0; y < img_1->height; y++) 1983 - { 1984 - p_in = img_1->pixels + (y * img_1->scanline_width); 1985 - p_out = 1986 - img->pixels + ((y * 4) * img->scanline_width) + 1987 - (2 * img->pixel_size); 1988 - for (x = 0; x < img_1->width; x++) 1989 - { 1990 - switch (img->pixel_format) 1991 - { 1992 - case GG_PIXEL_RGB: 1993 - *p_out++ = *p_in++; 1994 - *p_out++ = *p_in++; 1995 - *p_out++ = *p_in++; 1996 - p_out += (3 * 3); 1997 - break; 1998 - case GG_PIXEL_GRAYSCALE: 1999 - case GG_PIXEL_PALETTE: 2000 - *p_out = *p_in++; 2001 - p_out += 4; 2002 - break; 2003 - case GG_PIXEL_GRID: 2004 - switch (img_0->pixel_format) 2005 - { 2006 - case GGRAPH_SAMPLE_INT: 2007 - if (img_0->bits_per_sample == 16) 2008 - { 2009 - short *p = (short *) p_in; 2010 - short value = *p; 2011 - p_in += sizeof (short); 2012 - p = (short *) p_out; 2013 - *p = value; 2014 - p_out += sizeof (short) * 4; 2015 - } 2016 - else 2017 - { 2018 - int *p = (int *) p_in; 2019 - int value = *p; 2020 - p_in += sizeof (int); 2021 - p = (int *) p_out; 2022 - *p = value; 2023 - p_out += sizeof (int) * 4; 2024 - } 2025 - break; 2026 - case GGRAPH_SAMPLE_UINT: 2027 - if (img_0->bits_per_sample == 16) 2028 - { 2029 - unsigned short *p = (unsigned short *) p_in; 2030 - unsigned short value = *p; 2031 - p_in += sizeof (unsigned short); 2032 - p = (unsigned short *) p_out; 2033 - *p = value; 2034 - p_out += sizeof (unsigned short) * 4; 2035 - } 2036 - else 2037 - { 2038 - unsigned int *p = (unsigned int *) p_in; 2039 - int value = *p; 2040 - p_in += sizeof (unsigned int); 2041 - p = (unsigned int *) p_out; 2042 - *p = value; 2043 - p_out += sizeof (unsigned int) * 4; 2044 - } 2045 - break; 2046 - case GGRAPH_SAMPLE_FLOAT: 2047 - if (img_0->bits_per_sample == 32) 2048 - { 2049 - float *p = (float *) p_in; 2050 - float value = *p; 2051 - p_in += sizeof (float); 2052 - p = (float *) p_out; 2053 - *p = value; 2054 - p_out += sizeof (float) * 4; 2055 - } 2056 - else 2057 - { 2058 - double *p = (double *) p_in; 2059 - double value = *p; 2060 - p_in += sizeof (double); 2061 - p = (double *) p_out; 2062 - *p = value; 2063 - p_out += sizeof (double) * 4; 2064 - } 2065 - break; 2066 - }; 2067 - break; 2068 - }; 2069 - } 2070 - } 2071 - 2072 -/* expanding SubImage-2 */ 2073 - for (y = 0; y < img_2->height; y++) 2074 - { 2075 - p_in = img_2->pixels + (y * img_2->scanline_width); 2076 - p_out = img->pixels + (((y * 4) + 2) * img->scanline_width); 2077 - for (x = 0; x < img_2->width; x++) 2078 - { 2079 - switch (img->pixel_format) 2080 - { 2081 - case GG_PIXEL_RGB: 2082 - *p_out++ = *p_in++; 2083 - *p_out++ = *p_in++; 2084 - *p_out++ = *p_in++; 2085 - p_out += 3; 2086 - break; 2087 - case GG_PIXEL_GRAYSCALE: 2088 - case GG_PIXEL_PALETTE: 2089 - *p_out = *p_in++; 2090 - p_out += 2; 2091 - break; 2092 - case GG_PIXEL_GRID: 2093 - switch (img_0->pixel_format) 2094 - { 2095 - case GGRAPH_SAMPLE_INT: 2096 - if (img_0->bits_per_sample == 16) 2097 - { 2098 - short *p = (short *) p_in; 2099 - short value = *p; 2100 - p_in += sizeof (short); 2101 - p = (short *) p_out; 2102 - *p = value; 2103 - p_out += sizeof (short) * 2; 2104 - } 2105 - else 2106 - { 2107 - int *p = (int *) p_in; 2108 - int value = *p; 2109 - p_in += sizeof (int); 2110 - p = (int *) p_out; 2111 - *p = value; 2112 - p_out += sizeof (int) * 2; 2113 - } 2114 - break; 2115 - case GGRAPH_SAMPLE_UINT: 2116 - if (img_0->bits_per_sample == 16) 2117 - { 2118 - unsigned short *p = (unsigned short *) p_in; 2119 - unsigned short value = *p; 2120 - p_in += sizeof (unsigned short); 2121 - p = (unsigned short *) p_out; 2122 - *p = value; 2123 - p_out += sizeof (unsigned short) * 2; 2124 - } 2125 - else 2126 - { 2127 - unsigned int *p = (unsigned int *) p_in; 2128 - int value = *p; 2129 - p_in += sizeof (unsigned int); 2130 - p = (unsigned int *) p_out; 2131 - *p = value; 2132 - p_out += sizeof (unsigned int) * 2; 2133 - } 2134 - break; 2135 - case GGRAPH_SAMPLE_FLOAT: 2136 - if (img_0->bits_per_sample == 32) 2137 - { 2138 - float *p = (float *) p_in; 2139 - float value = *p; 2140 - p_in += sizeof (float); 2141 - p = (float *) p_out; 2142 - *p = value; 2143 - p_out += sizeof (float) * 2; 2144 - } 2145 - else 2146 - { 2147 - double *p = (double *) p_in; 2148 - double value = *p; 2149 - p_in += sizeof (double); 2150 - p = (double *) p_out; 2151 - *p = value; 2152 - p_out += sizeof (double) * 2; 2153 - } 2154 - break; 2155 - }; 2156 - break; 2157 - }; 2158 - } 2159 - } 2160 - 2161 -/* expanding SubImage-3 */ 2162 - for (y = 0; y < img_3->height; y++) 2163 - { 2164 - p_in = img_3->pixels + (y * img_3->scanline_width); 2165 - p_out = 2166 - img->pixels + ((y * 2) * img->scanline_width) + img->pixel_size; 2167 - for (x = 0; x < img_3->width; x++) 2168 - { 2169 - switch (img->pixel_format) 2170 - { 2171 - case GG_PIXEL_RGB: 2172 - *p_out++ = *p_in++; 2173 - *p_out++ = *p_in++; 2174 - *p_out++ = *p_in++; 2175 - p_out += 3; 2176 - break; 2177 - case GG_PIXEL_GRAYSCALE: 2178 - case GG_PIXEL_PALETTE: 2179 - *p_out = *p_in++; 2180 - p_out += 2; 2181 - break; 2182 - case GG_PIXEL_GRID: 2183 - switch (img_0->pixel_format) 2184 - { 2185 - case GGRAPH_SAMPLE_INT: 2186 - if (img_0->bits_per_sample == 16) 2187 - { 2188 - short *p = (short *) p_in; 2189 - short value = *p; 2190 - p_in += sizeof (short); 2191 - p = (short *) p_out; 2192 - *p = value; 2193 - p_out += sizeof (short) * 2; 2194 - } 2195 - else 2196 - { 2197 - int *p = (int *) p_in; 2198 - int value = *p; 2199 - p_in += sizeof (int); 2200 - p = (int *) p_out; 2201 - *p = value; 2202 - p_out += sizeof (int) * 2; 2203 - } 2204 - break; 2205 - case GGRAPH_SAMPLE_UINT: 2206 - if (img_0->bits_per_sample == 16) 2207 - { 2208 - unsigned short *p = (unsigned short *) p_in; 2209 - unsigned short value = *p; 2210 - p_in += sizeof (unsigned short); 2211 - p = (unsigned short *) p_out; 2212 - *p = value; 2213 - p_out += sizeof (unsigned short) * 2; 2214 - } 2215 - else 2216 - { 2217 - unsigned int *p = (unsigned int *) p_in; 2218 - int value = *p; 2219 - p_in += sizeof (unsigned int); 2220 - p = (unsigned int *) p_out; 2221 - *p = value; 2222 - p_out += sizeof (unsigned int) * 2; 2223 - } 2224 - break; 2225 - case GGRAPH_SAMPLE_FLOAT: 2226 - if (img_0->bits_per_sample == 32) 2227 - { 2228 - float *p = (float *) p_in; 2229 - float value = *p; 2230 - p_in += sizeof (float); 2231 - p = (float *) p_out; 2232 - *p = value; 2233 - p_out += sizeof (float) * 2; 2234 - } 2235 - else 2236 - { 2237 - double *p = (double *) p_in; 2238 - double value = *p; 2239 - p_in += sizeof (double); 2240 - p = (double *) p_out; 2241 - *p = value; 2242 - p_out += sizeof (double) * 2; 2243 - } 2244 - break; 2245 - }; 2246 - break; 2247 - }; 2248 - } 2249 - } 2250 - 2251 -/* expanding SubImage-4 */ 2252 - for (y = 0; y < img_4->height; y++) 2253 - { 2254 - p_in = img_4->pixels + (y * img_4->scanline_width); 2255 - p_out = img->pixels + (((y * 2) + 1) * img->scanline_width); 2256 - for (x = 0; x < img_4->width; x++) 2257 - { 2258 - switch (img->pixel_format) 2259 - { 2260 - case GG_PIXEL_RGB: 2261 - *p_out++ = *p_in++; 2262 - *p_out++ = *p_in++; 2263 - *p_out++ = *p_in++; 2264 - break; 2265 - case GG_PIXEL_GRAYSCALE: 2266 - case GG_PIXEL_PALETTE: 2267 - *p_out++ = *p_in++; 2268 - break; 2269 - case GG_PIXEL_GRID: 2270 - switch (img_0->pixel_format) 2271 - { 2272 - case GGRAPH_SAMPLE_INT: 2273 - if (img_0->bits_per_sample == 16) 2274 - { 2275 - short *p = (short *) p_in; 2276 - short value = *p; 2277 - p_in += sizeof (short); 2278 - p = (short *) p_out; 2279 - *p = value; 2280 - p_out += sizeof (short); 2281 - } 2282 - else 2283 - { 2284 - int *p = (int *) p_in; 2285 - int value = *p; 2286 - p_in += sizeof (int); 2287 - p = (int *) p_out; 2288 - *p = value; 2289 - p_out += sizeof (int); 2290 - } 2291 - break; 2292 - case GGRAPH_SAMPLE_UINT: 2293 - if (img_0->bits_per_sample == 16) 2294 - { 2295 - unsigned short *p = (unsigned short *) p_in; 2296 - unsigned short value = *p; 2297 - p_in += sizeof (unsigned short); 2298 - p = (unsigned short *) p_out; 2299 - *p = value; 2300 - p_out += sizeof (unsigned short); 2301 - } 2302 - else 2303 - { 2304 - unsigned int *p = (unsigned int *) p_in; 2305 - int value = *p; 2306 - p_in += sizeof (unsigned int); 2307 - p = (unsigned int *) p_out; 2308 - *p = value; 2309 - p_out += sizeof (unsigned int); 2310 - } 2311 - break; 2312 - case GGRAPH_SAMPLE_FLOAT: 2313 - if (img_0->bits_per_sample == 32) 2314 - { 2315 - float *p = (float *) p_in; 2316 - float value = *p; 2317 - p_in += sizeof (float); 2318 - p = (float *) p_out; 2319 - *p = value; 2320 - p_out += sizeof (float); 2321 - } 2322 - else 2323 - { 2324 - double *p = (double *) p_in; 2325 - double value = *p; 2326 - p_in += sizeof (double); 2327 - p = (double *) p_out; 2328 - *p = value; 2329 - p_out += sizeof (double); 2330 - } 2331 - break; 2332 - }; 2333 - break; 2334 - }; 2335 - } 2336 - } 2337 - 2338 - return img; 2339 -} 2340 - 2341 -static gGraphImagePtr 2342 -merge_adam7_scale_4 (gGraphImagePtr img_0, gGraphImagePtr img_1, 2343 - gGraphImagePtr img_2, int width, int height) 2344 -{ 2345 -/* decoding an Adam7 image (1:4) */ 2346 - int x; 2347 - int y; 2348 - unsigned char *p_in; 2349 - unsigned char *p_out; 2350 - gGraphImagePtr img = gg_image_create (img_0->pixel_format, width, height, 2351 - img_0->bits_per_sample, 2352 - img_0->samples_per_pixel, 2353 - img_0->sample_format, NULL, 2354 - NULL); 2355 - if (!img) 2356 - return NULL; 2357 - 2358 -/* expanding SubImage-0 */ 2359 - for (y = 0; y < img_0->height; y++) 2360 - { 2361 - p_in = img_0->pixels + (y * img_0->scanline_width); 2362 - p_out = img->pixels + ((y * 2) * img->scanline_width); 2363 - for (x = 0; x < img_0->width; x++) 2364 - { 2365 - switch (img->pixel_format) 2366 - { 2367 - case GG_PIXEL_RGB: 2368 - *p_out++ = *p_in++; 2369 - *p_out++ = *p_in++; 2370 - *p_out++ = *p_in++; 2371 - p_out += 3; 2372 - break; 2373 - case GG_PIXEL_GRAYSCALE: 2374 - case GG_PIXEL_PALETTE: 2375 - *p_out = *p_in++; 2376 - p_out += 2; 2377 - break; 2378 - case GG_PIXEL_GRID: 2379 - switch (img_0->pixel_format) 2380 - { 2381 - case GGRAPH_SAMPLE_INT: 2382 - if (img_0->bits_per_sample == 16) 2383 - { 2384 - short *p = (short *) p_in; 2385 - short value = *p; 2386 - p_in += sizeof (short); 2387 - p = (short *) p_out; 2388 - *p = value; 2389 - p_out += sizeof (short) * 2; 2390 - } 2391 - else 2392 - { 2393 - int *p = (int *) p_in; 2394 - int value = *p; 2395 - p_in += sizeof (int); 2396 - p = (int *) p_out; 2397 - *p = value; 2398 - p_out += sizeof (int) * 2; 2399 - } 2400 - break; 2401 - case GGRAPH_SAMPLE_UINT: 2402 - if (img_0->bits_per_sample == 16) 2403 - { 2404 - unsigned short *p = (unsigned short *) p_in; 2405 - unsigned short value = *p; 2406 - p_in += sizeof (unsigned short); 2407 - p = (unsigned short *) p_out; 2408 - *p = value; 2409 - p_out += sizeof (unsigned short) * 2; 2410 - } 2411 - else 2412 - { 2413 - unsigned int *p = (unsigned int *) p_in; 2414 - int value = *p; 2415 - p_in += sizeof (unsigned int); 2416 - p = (unsigned int *) p_out; 2417 - *p = value; 2418 - p_out += sizeof (unsigned int) * 2; 2419 - } 2420 - break; 2421 - case GGRAPH_SAMPLE_FLOAT: 2422 - if (img_0->bits_per_sample == 32) 2423 - { 2424 - float *p = (float *) p_in; 2425 - float value = *p; 2426 - p_in += sizeof (float); 2427 - p = (float *) p_out; 2428 - *p = value; 2429 - p_out += sizeof (float) * 2; 2430 - } 2431 - else 2432 - { 2433 - double *p = (double *) p_in; 2434 - double value = *p; 2435 - p_in += sizeof (double); 2436 - p = (double *) p_out; 2437 - *p = value; 2438 - p_out += sizeof (double) * 2; 2439 - } 2440 - break; 2441 - }; 2442 - break; 2443 - }; 2444 - } 2445 - } 2446 - 2447 -/* expanding SubImage-1 */ 2448 - for (y = 0; y < img_1->height; y++) 2449 - { 2450 - p_in = img_1->pixels + (y * img_1->scanline_width); 2451 - p_out = 2452 - img->pixels + ((y * 2) * img->scanline_width) + img->pixel_size; 2453 - for (x = 0; x < img_1->width; x++) 2454 - { 2455 - switch (img->pixel_format) 2456 - { 2457 - case GG_PIXEL_RGB: 2458 - *p_out++ = *p_in++; 2459 - *p_out++ = *p_in++; 2460 - *p_out++ = *p_in++; 2461 - p_out += 3; 2462 - break; 2463 - case GG_PIXEL_GRAYSCALE: 2464 - case GG_PIXEL_PALETTE: 2465 - *p_out = *p_in++; 2466 - p_out += 2; 2467 - break; 2468 - case GG_PIXEL_GRID: 2469 - switch (img_0->pixel_format) 2470 - { 2471 - case GGRAPH_SAMPLE_INT: 2472 - if (img_0->bits_per_sample == 16) 2473 - { 2474 - short *p = (short *) p_in; 2475 - short value = *p; 2476 - p_in += sizeof (short); 2477 - p = (short *) p_out; 2478 - *p = value; 2479 - p_out += sizeof (short) * 2; 2480 - } 2481 - else 2482 - { 2483 - int *p = (int *) p_in; 2484 - int value = *p; 2485 - p_in += sizeof (int); 2486 - p = (int *) p_out; 2487 - *p = value; 2488 - p_out += sizeof (int) * 2; 2489 - } 2490 - break; 2491 - case GGRAPH_SAMPLE_UINT: 2492 - if (img_0->bits_per_sample == 16) 2493 - { 2494 - unsigned short *p = (unsigned short *) p_in; 2495 - unsigned short value = *p; 2496 - p_in += sizeof (unsigned short); 2497 - p = (unsigned short *) p_out; 2498 - *p = value; 2499 - p_out += sizeof (unsigned short) * 2; 2500 - } 2501 - else 2502 - { 2503 - unsigned int *p = (unsigned int *) p_in; 2504 - int value = *p; 2505 - p_in += sizeof (unsigned int); 2506 - p = (unsigned int *) p_out; 2507 - *p = value; 2508 - p_out += sizeof (unsigned int) * 2; 2509 - } 2510 - break; 2511 - case GGRAPH_SAMPLE_FLOAT: 2512 - if (img_0->bits_per_sample == 32) 2513 - { 2514 - float *p = (float *) p_in; 2515 - float value = *p; 2516 - p_in += sizeof (float); 2517 - p = (float *) p_out; 2518 - *p = value; 2519 - p_out += sizeof (float) * 2; 2520 - } 2521 - else 2522 - { 2523 - double *p = (double *) p_in; 2524 - double value = *p; 2525 - p_in += sizeof (double); 2526 - p = (double *) p_out; 2527 - *p = value; 2528 - p_out += sizeof (double) * 2; 2529 - } 2530 - break; 2531 - }; 2532 - break; 2533 - }; 2534 - } 2535 - } 2536 - 2537 -/* expanding SubImage-2 */ 2538 - for (y = 0; y < img_2->height; y++) 2539 - { 2540 - p_in = img_2->pixels + (y * img_2->scanline_width); 2541 - p_out = img->pixels + (((y * 2) + 1) * img->scanline_width); 2542 - for (x = 0; x < img_2->width; x++) 2543 - { 2544 - switch (img->pixel_format) 2545 - { 2546 - case GG_PIXEL_RGB: 2547 - *p_out++ = *p_in++; 2548 - *p_out++ = *p_in++; 2549 - *p_out++ = *p_in++; 2550 - break; 2551 - case GG_PIXEL_GRAYSCALE: 2552 - case GG_PIXEL_PALETTE: 2553 - *p_out++ = *p_in++; 2554 - break; 2555 - case GG_PIXEL_GRID: 2556 - switch (img_0->pixel_format) 2557 - { 2558 - case GGRAPH_SAMPLE_INT: 2559 - if (img_0->bits_per_sample == 16) 2560 - { 2561 - short *p = (short *) p_in; 2562 - short value = *p; 2563 - p_in += sizeof (short); 2564 - p = (short *) p_out; 2565 - *p = value; 2566 - p_out += sizeof (short); 2567 - } 2568 - else 2569 - { 2570 - int *p = (int *) p_in; 2571 - int value = *p; 2572 - p_in += sizeof (int); 2573 - p = (int *) p_out; 2574 - *p = value; 2575 - p_out += sizeof (int); 2576 - } 2577 - break; 2578 - case GGRAPH_SAMPLE_UINT: 2579 - if (img_0->bits_per_sample == 16) 2580 - { 2581 - unsigned short *p = (unsigned short *) p_in; 2582 - unsigned short value = *p; 2583 - p_in += sizeof (unsigned short); 2584 - p = (unsigned short *) p_out; 2585 - *p = value; 2586 - p_out += sizeof (unsigned short); 2587 - } 2588 - else 2589 - { 2590 - unsigned int *p = (unsigned int *) p_in; 2591 - int value = *p; 2592 - p_in += sizeof (unsigned int); 2593 - p = (unsigned int *) p_out; 2594 - *p = value; 2595 - p_out += sizeof (unsigned int); 2596 - } 2597 - break; 2598 - case GGRAPH_SAMPLE_FLOAT: 2599 - if (img_0->bits_per_sample == 32) 2600 - { 2601 - float *p = (float *) p_in; 2602 - float value = *p; 2603 - p_in += sizeof (float); 2604 - p = (float *) p_out; 2605 - *p = value; 2606 - p_out += sizeof (float); 2607 - } 2608 - else 2609 - { 2610 - double *p = (double *) p_in; 2611 - double value = *p; 2612 - p_in += sizeof (double); 2613 - p = (double *) p_out; 2614 - *p = value; 2615 - p_out += sizeof (double); 2616 - } 2617 - break; 2618 - }; 2619 - break; 2620 - }; 2621 - } 2622 - } 2623 - 2624 - return img; 2625 -} 2626 - 2627 -static int 2628 -adam7_set_palette (gGraphImagePtr img, void *palette, int palette_size) 2629 -{ 2630 -/* setting up a palette */ 2631 - unsigned char *p_in; 2632 - int endian_arch = gg_endian_arch (); 2633 - short palette_start; 2634 - short palette_end; 2635 - int i; 2636 - 2637 - if (img->pixel_format != GG_PIXEL_PALETTE) 2638 - return 0; 2639 - 2640 -/* checking signatures */ 2641 - if (palette_size < (int) ((sizeof (short) * 2) + 1)) 2642 - return 0; 2643 - p_in = palette; 2644 - palette_start = gg_import_int16 (p_in, 1, endian_arch); 2645 - p_in = (unsigned char *) palette + palette_size - sizeof (short); 2646 - palette_end = gg_import_int16 (p_in, 1, endian_arch); 2647 - if (palette_start == GG_ADAM7_PALETTE_START 2648 - && palette_end == GG_ADAM7_PALETTE_END) 2649 - ; 2650 - else 2651 - return 0; 2652 - 2653 - p_in = (unsigned char *) palette + sizeof (short); 2654 - img->max_palette = *p_in++; 2655 - for (i = 0; i < img->max_palette; i++) 2656 - { 2657 - img->palette_red[i] = *p_in++; 2658 - img->palette_green[i] = *p_in++; 2659 - img->palette_blue[i] = *p_in++; 2660 - } 2661 - return 1; 2662 -} 2663 - 2664 -GGRAPH_DECLARE int 2665 -gGraphImageFromAdam7 (void *mem_bufs[7], int mem_buf_sizes[7], void *palette, 2666 - int palette_size, const void **image_handle, int scale) 2667 -{ 2668 -/* decoding an image from Adam7 */ 2669 - gGraphImagePtr img_0 = NULL; 2670 - gGraphImagePtr img_1 = NULL; 2671 - gGraphImagePtr img_2 = NULL; 2672 - gGraphImagePtr img_3 = NULL; 2673 - gGraphImagePtr img_4 = NULL; 2674 - gGraphImagePtr img_5 = NULL; 2675 - gGraphImagePtr img_6 = NULL; 2676 - gGraphImagePtr img; 2677 - int width; 2678 - int height; 2679 - 2680 - *image_handle = NULL; 2681 - 2682 -/* checking sub-images */ 2683 - if (scale == 8) 2684 - { 2685 - if (mem_bufs[0] == NULL || mem_buf_sizes[0] <= 0) 2686 - goto stop; 2687 - img_0 = adam7_decode (0, mem_bufs[0], mem_buf_sizes[0]); 2688 - if (!img_0) 2689 - goto stop; 2690 - if (img_0->pixel_format == GG_PIXEL_PALETTE) 2691 - { 2692 - if (!adam7_set_palette (img_0, palette, palette_size)) 2693 - goto stop; 2694 - } 2695 - *image_handle = img_0; 2696 - return GGRAPH_OK; 2697 - } 2698 - else if (scale == 4) 2699 - { 2700 - if (mem_bufs[0] == NULL || mem_buf_sizes[0] <= 0) 2701 - goto stop; 2702 - if (mem_bufs[1] == NULL || mem_buf_sizes[1] <= 0) 2703 - goto stop; 2704 - if (mem_bufs[2] == NULL || mem_buf_sizes[2] <= 0) 2705 - goto stop; 2706 - img_0 = adam7_decode (0, mem_bufs[0], mem_buf_sizes[0]); 2707 - if (!img_0) 2708 - goto stop; 2709 - img_1 = adam7_decode (1, mem_bufs[1], mem_buf_sizes[1]); 2710 - if (!img_1) 2711 - goto stop; 2712 - img_2 = adam7_decode (2, mem_bufs[2], mem_buf_sizes[2]); 2713 - if (!img_2) 2714 - goto stop; 2715 - if (!check_adam7_subs (img_0, img_1)) 2716 - goto stop; 2717 - if (!check_adam7_subs (img_0, img_2)) 2718 - goto stop; 2719 - if (!get_adam7_dims_4 (img_0, img_1, img_2, &width, &height)) 2720 - goto stop; 2721 - img = merge_adam7_scale_4 (img_0, img_1, img_2, width, height); 2722 - if (!img) 2723 - goto stop; 2724 - gGraphDestroyImage (img_0); 2725 - gGraphDestroyImage (img_1); 2726 - gGraphDestroyImage (img_2); 2727 - if (img->pixel_format == GG_PIXEL_PALETTE) 2728 - { 2729 - if (!adam7_set_palette (img, palette, palette_size)) 2730 - goto stop; 2731 - } 2732 - *image_handle = img; 2733 - return GGRAPH_OK; 2734 - } 2735 - else if (scale == 2) 2736 - { 2737 - if (mem_bufs[0] == NULL || mem_buf_sizes[0] <= 0) 2738 - goto stop; 2739 - if (mem_bufs[1] == NULL || mem_buf_sizes[1] <= 0) 2740 - goto stop; 2741 - if (mem_bufs[2] == NULL || mem_buf_sizes[2] <= 0) 2742 - goto stop; 2743 - if (mem_bufs[3] == NULL || mem_buf_sizes[3] <= 0) 2744 - goto stop; 2745 - if (mem_bufs[4] == NULL || mem_buf_sizes[4] <= 0) 2746 - goto stop; 2747 - img_0 = adam7_decode (0, mem_bufs[0], mem_buf_sizes[0]); 2748 - if (!img_0) 2749 - goto stop; 2750 - img_1 = adam7_decode (1, mem_bufs[1], mem_buf_sizes[1]); 2751 - if (!img_1) 2752 - goto stop; 2753 - img_2 = adam7_decode (2, mem_bufs[2], mem_buf_sizes[2]); 2754 - if (!img_2) 2755 - goto stop; 2756 - img_3 = adam7_decode (3, mem_bufs[3], mem_buf_sizes[3]); 2757 - if (!img_3) 2758 - goto stop; 2759 - img_4 = adam7_decode (4, mem_bufs[4], mem_buf_sizes[4]); 2760 - if (!img_4) 2761 - goto stop; 2762 - if (!check_adam7_subs (img_0, img_1)) 2763 - goto stop; 2764 - if (!check_adam7_subs (img_0, img_2)) 2765 - goto stop; 2766 - if (!check_adam7_subs (img_0, img_3)) 2767 - goto stop; 2768 - if (!check_adam7_subs (img_0, img_4)) 2769 - goto stop; 2770 - if (!get_adam7_dims_2 2771 - (img_0, img_1, img_2, img_3, img_4, &width, &height)) 2772 - goto stop; 2773 - img = 2774 - merge_adam7_scale_2 (img_0, img_1, img_2, img_3, img_4, width, 2775 - height); 2776 - if (!img) 2777 - goto stop; 2778 - gGraphDestroyImage (img_0); 2779 - gGraphDestroyImage (img_1); 2780 - gGraphDestroyImage (img_2); 2781 - gGraphDestroyImage (img_3); 2782 - gGraphDestroyImage (img_4); 2783 - if (img->pixel_format == GG_PIXEL_PALETTE) 2784 - { 2785 - if (!adam7_set_palette (img, palette, palette_size)) 2786 - goto stop; 2787 - } 2788 - *image_handle = img; 2789 - return GGRAPH_OK; 2790 - } 2791 - else 2792 - { 2793 - if (mem_bufs[0] == NULL || mem_buf_sizes[0] <= 0) 2794 - goto stop; 2795 - if (mem_bufs[1] == NULL || mem_buf_sizes[1] <= 0) 2796 - goto stop; 2797 - if (mem_bufs[2] == NULL || mem_buf_sizes[2] <= 0) 2798 - goto stop; 2799 - if (mem_bufs[3] == NULL || mem_buf_sizes[3] <= 0) 2800 - goto stop; 2801 - if (mem_bufs[4] == NULL || mem_buf_sizes[4] <= 0) 2802 - goto stop; 2803 - if (mem_bufs[5] == NULL || mem_buf_sizes[5] <= 0) 2804 - goto stop; 2805 - if (mem_bufs[6] == NULL || mem_buf_sizes[6] <= 0) 2806 - goto stop; 2807 - img_0 = adam7_decode (0, mem_bufs[0], mem_buf_sizes[0]); 2808 - if (!img_0) 2809 - goto stop; 2810 - img_1 = adam7_decode (1, mem_bufs[1], mem_buf_sizes[1]); 2811 - if (!img_1) 2812 - goto stop; 2813 - img_2 = adam7_decode (2, mem_bufs[2], mem_buf_sizes[2]); 2814 - if (!img_2) 2815 - goto stop; 2816 - img_3 = adam7_decode (3, mem_bufs[3], mem_buf_sizes[3]); 2817 - if (!img_3) 2818 - goto stop; 2819 - img_4 = adam7_decode (4, mem_bufs[4], mem_buf_sizes[4]); 2820 - if (!img_4) 2821 - goto stop; 2822 - img_5 = adam7_decode (5, mem_bufs[5], mem_buf_sizes[5]); 2823 - if (!img_5) 2824 - goto stop; 2825 - img_6 = adam7_decode (6, mem_bufs[6], mem_buf_sizes[6]); 2826 - if (!img_6) 2827 - goto stop; 2828 - if (!check_adam7_subs (img_0, img_1)) 2829 - goto stop; 2830 - if (!check_adam7_subs (img_0, img_2)) 2831 - goto stop; 2832 - if (!check_adam7_subs (img_0, img_3)) 2833 - goto stop; 2834 - if (!check_adam7_subs (img_0, img_4)) 2835 - goto stop; 2836 - if (!check_adam7_subs (img_0, img_5)) 2837 - goto stop; 2838 - if (!check_adam7_subs (img_0, img_6)) 2839 - goto stop; 2840 - if (!get_adam7_dims_1 2841 - (img_0, img_1, img_2, img_3, img_4, img_5, img_6, &width, 2842 - &height)) 2843 - goto stop; 2844 - img = 2845 - merge_adam7_scale_1 (img_0, img_1, img_2, img_3, img_4, img_5, 2846 - img_6, width, height); 2847 - if (!img) 2848 - goto stop; 2849 - gGraphDestroyImage (img_0); 2850 - gGraphDestroyImage (img_1); 2851 - gGraphDestroyImage (img_2); 2852 - gGraphDestroyImage (img_3); 2853 - gGraphDestroyImage (img_4); 2854 - gGraphDestroyImage (img_5); 2855 - gGraphDestroyImage (img_6); 2856 - if (img->pixel_format == GG_PIXEL_PALETTE) 2857 - { 2858 - if (!adam7_set_palette (img, palette, palette_size)) 2859 - goto stop; 2860 - } 2861 - *image_handle = img; 2862 - return GGRAPH_OK; 2863 - } 2864 - 2865 - stop: 2866 - if (img_0) 2867 - gGraphDestroyImage (img_0); 2868 - if (img_1) 2869 - gGraphDestroyImage (img_1); 2870 - if (img_2) 2871 - gGraphDestroyImage (img_2); 2872 - if (img_3) 2873 - gGraphDestroyImage (img_3); 2874 - if (img_4) 2875 - gGraphDestroyImage (img_4); 2876 - if (img_5) 2877 - gGraphDestroyImage (img_5); 2878 - if (img_6) 2879 - gGraphDestroyImage (img_6); 2880 - return GGRAPH_INVALID_IMAGE; 2881 -} 2882 - 2883 -GGRAPH_DECLARE int 2884 -gGraphImageToMonochrome (const void *ptr_img, void **mem_buf, int *mem_buf_size) 2885 -{ 2886 -/* encoding an image as Monochrome */ 2887 - int line_width; 2888 - int size; 2889 - void *out; 2890 - int endian_arch = gg_endian_arch (); 2891 - unsigned char *p_in; 2892 - unsigned char *p_out; 2893 - int x; 2894 - int y; 2895 - gGraphImagePtr img = (gGraphImagePtr) ptr_img; 2896 - 2897 - *mem_buf = NULL; 2898 - *mem_buf_size = 0; 2899 - 2900 - if (img == NULL) 2901 - return GGRAPH_INVALID_IMAGE; 2902 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 2903 - return GGRAPH_INVALID_IMAGE; 2904 - if (img->pixel_format != GG_PIXEL_PALETTE) 2905 - return GGRAPH_INVALID_IMAGE; 2906 - 2907 - if (img->max_palette != 2) 2908 - return GGRAPH_INVALID_IMAGE; 2909 - if (img->palette_red[0] == 0 && img->palette_green[0] == 0 2910 - && img->palette_blue[0] == 0 && img->palette_red[1] == 255 2911 - && img->palette_green[1] == 255 && img->palette_blue[1] == 255) 2912 - ; 2913 - else if (img->palette_red[0] == 255 && img->palette_green[0] == 255 2914 - && img->palette_blue[0] == 255 && img->palette_red[1] == 0 2915 - && img->palette_green[1] == 0 && img->palette_blue[1] == 0) 2916 - ; 2917 - else 2918 - return GGRAPH_INVALID_IMAGE; 2919 - 2920 - line_width = img->width / 8; 2921 - if ((line_width * 8) < img->width) 2922 - line_width++; 2923 - size = line_width * img->height; 2924 - size += 4 * sizeof (short); 2925 - out = malloc (size); 2926 - if (!out) 2927 - goto stop; 2928 - p_out = out; 2929 - 2930 -/* 2931 -* monochrome tile signatures are encoded as LITTLE-ENDIAN 2932 -* but Width/Height are BID-ENDIAN encoded 2933 -*/ 2934 - gg_export_int16 (GG_MONOCHROME_START, p_out, 1, endian_arch); 2935 - p_out += sizeof (short); 2936 - gg_export_int16 (img->width, p_out, 0, endian_arch); 2937 - p_out += sizeof (short); 2938 - gg_export_int16 (img->height, p_out, 0, endian_arch); 2939 - p_out += sizeof (short); 2940 - 2941 - for (y = 0; y < img->height; y++) 2942 - { 2943 - unsigned char byte = 0x00; 2944 - int pos = 0; 2945 - p_in = img->pixels + (y * img->scanline_width); 2946 - for (x = 0; x < img->width; x++) 2947 - { 2948 - int idx = *p_in++; 2949 - if (img->palette_red[idx] == 0) 2950 - { 2951 - /* handling a black pixel */ 2952 - switch (pos) 2953 - { 2954 - case 0: 2955 - byte |= 0x80; 2956 - break; 2957 - case 1: 2958 - byte |= 0x40; 2959 - break; 2960 - case 2: 2961 - byte |= 0x20; 2962 - break; 2963 - case 3: 2964 - byte |= 0x10; 2965 - break; 2966 - case 4: 2967 - byte |= 0x08; 2968 - break; 2969 - case 5: 2970 - byte |= 0x04; 2971 - break; 2972 - case 6: 2973 - byte |= 0x02; 2974 - break; 2975 - case 7: 2976 - byte |= 0x01; 2977 - break; 2978 - }; 2979 - } 2980 - pos++; 2981 - if (pos > 7) 2982 - { 2983 - /* exporting an octet */ 2984 - *p_out++ = byte; 2985 - byte = 0x00; 2986 - pos = 0; 2987 - } 2988 - } 2989 - if (pos > 0) /* exporting the last octet */ 2990 - *p_out++ = byte; 2991 - } 2992 - gg_export_int16 (GG_MONOCHROME_END, p_out, 1, endian_arch); 2993 - 2994 - *mem_buf = out; 2995 - *mem_buf_size = size; 2996 - return GGRAPH_OK; 2997 - 2998 - stop: 2999 - return GGRAPH_INSUFFICIENT_MEMORY; 3000 -} 3001 - 3002 -GGRAPH_DECLARE int 3003 -gGraphImageFromMonochrome (const void *mem_buf, int mem_buf_size, 3004 - const void **image_handle) 3005 -{ 3006 -/* decoding an image from Monochrome */ 3007 - const unsigned char *p_in; 3008 - int endian_arch = gg_endian_arch (); 3009 - short start_signature; 3010 - short end_signature; 3011 - short width; 3012 - short height; 3013 - int x; 3014 - int y; 3015 - int line_width; 3016 - gGraphImagePtr img; 3017 - 3018 - *image_handle = NULL; 3019 - 3020 - if (mem_buf_size < (int) (sizeof (short) * 4)) 3021 - return GGRAPH_INVALID_IMAGE; 3022 -/* 3023 -* monochrome tile signatures are encoded as LITTLE-ENDIAN 3024 -* but Width/Height are BID-ENDIAN encoded 3025 -*/ 3026 - 3027 -/* checking signatures */ 3028 - p_in = mem_buf; 3029 - start_signature = gg_import_int16 (p_in, 1, endian_arch); 3030 - p_in = (unsigned char *) mem_buf + mem_buf_size - sizeof (short); 3031 - end_signature = gg_import_int16 (p_in, 1, endian_arch); 3032 - if (start_signature == GG_MONOCHROME_START 3033 - && end_signature == GG_MONOCHROME_END) 3034 - ; 3035 - else 3036 - return GGRAPH_INVALID_IMAGE; 3037 - 3038 - p_in = mem_buf; 3039 - p_in += sizeof (short); 3040 - width = gg_import_int16 (p_in, 0, endian_arch); 3041 - p_in += sizeof (short); 3042 - height = gg_import_int16 (p_in, 0, endian_arch); 3043 - p_in += sizeof (short); 3044 - 3045 - line_width = width / 8; 3046 - if ((line_width * 8) < width) 3047 - line_width++; 3048 - if ((line_width * height) != (int) (mem_buf_size - (4 * sizeof (short)))) 3049 - return GGRAPH_INVALID_IMAGE; 3050 - 3051 - img = 3052 - gg_image_create (GG_PIXEL_PALETTE, width, height, 8, 1, 3053 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3054 - if (!img) 3055 - return GGRAPH_INSUFFICIENT_MEMORY; 3056 - 3057 - img->max_palette = 2; 3058 - img->palette_red[0] = 255; 3059 - img->palette_green[0] = 255; 3060 - img->palette_blue[0] = 255; 3061 - img->palette_red[1] = 0; 3062 - img->palette_green[1] = 0; 3063 - img->palette_blue[1] = 0; 3064 - 3065 - for (y = 0; y < height; y++) 3066 - { 3067 - unsigned char byte = 0x00; 3068 - unsigned char px; 3069 - int pixel; 3070 - int pos = 0; 3071 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3072 - for (x = 0; x < width; x++) 3073 - { 3074 - if (pos == 0) 3075 - byte = *p_in++; 3076 - pixel = 0; 3077 - switch (pos) 3078 - { 3079 - case 0: 3080 - px = byte & 0x80; 3081 - if (px == 0x80) 3082 - pixel = 1; 3083 - break; 3084 - case 1: 3085 - px = byte & 0x40; 3086 - if (px == 0x40) 3087 - pixel = 1; 3088 - break; 3089 - case 2: 3090 - px = byte & 0x20; 3091 - if (px == 0x20) 3092 - pixel = 1; 3093 - break; 3094 - case 3: 3095 - px = byte & 0x10; 3096 - if (px == 0x10) 3097 - pixel = 1; 3098 - break; 3099 - case 4: 3100 - px = byte & 0x08; 3101 - if (px == 0x08) 3102 - pixel = 1; 3103 - break; 3104 - case 5: 3105 - px = byte & 0x04; 3106 - if (px == 0x04) 3107 - pixel = 1; 3108 - break; 3109 - case 6: 3110 - px = byte & 0x02; 3111 - if (px == 0x02) 3112 - pixel = 1; 3113 - break; 3114 - case 7: 3115 - px = byte & 0x01; 3116 - if (px == 0x01) 3117 - pixel = 1; 3118 - break; 3119 - }; 3120 - *p_out++ = pixel; 3121 - pos++; 3122 - if (pos > 7) 3123 - { 3124 - byte = 0x00; 3125 - pos = 0; 3126 - } 3127 - } 3128 - } 3129 - 3130 - *image_handle = img; 3131 - return GGRAPH_OK; 3132 - 3133 -}
Deleted src/gaiagraphics_aux.c.
1 -/* 2 -/ gaiagraphics_aux.c 3 -/ 4 -/ RAW image helpers 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2009 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdlib.h> 28 -#include <stdio.h> 29 -#include <string.h> 30 -#include <float.h> 31 -#include <math.h> 32 - 33 -#include <tiffio.h> 34 - 35 -/* 36 -/ the following patch supporting GeoTiff headers 37 -/ was kindly contributed by Brad Hards: 2011-09-02 38 -*/ 39 -#ifdef HAVE_GEOTIFF_GEOTIFF_H 40 -#include <geotiff/geotiff.h> 41 -#include <geotiff/xtiffio.h> 42 -#include <geotiff/geo_normalize.h> 43 -#include <geotiff/geovalues.h> 44 -#elif HAVE_LIBGEOTIFF_GEOTIFF_H 45 -#include <libgeotiff/geotiff.h> 46 -#include <libgeotiff/xtiffio.h> 47 -#include <libgeotiff/geo_normalize.h> 48 -#include <libgeotiff/geovalues.h> 49 -#else 50 -#include <geotiff.h> 51 -#include <xtiffio.h> 52 -#include <geo_normalize.h> 53 -#include <geovalues.h> 54 -#endif 55 - 56 -#ifdef _WIN32 57 -#include <io.h> 58 -#else 59 -#include <unistd.h> 60 -#endif 61 - 62 -#include "gaiagraphics.h" 63 -#include "gaiagraphics_internals.h" 64 - 65 -GGRAPH_DECLARE const void * 66 -gGraphCreateRgbImage (int width, int height) 67 -{ 68 -/* creating a new RGB image */ 69 - return gg_image_create (GG_PIXEL_RGB, width, height, 8, 3, 70 - GGRAPH_SAMPLE_UINT, NULL, NULL); 71 -} 72 - 73 -GGRAPH_DECLARE const void * 74 -gGraphCreateRgbImageFromBitmap (unsigned char *bitmap, int width, int height) 75 -{ 76 -/* creating a new RGB image */ 77 - return gg_image_create_from_bitmap (bitmap, GG_PIXEL_RGB, width, height, 8, 78 - 3, GGRAPH_SAMPLE_UINT, NULL, NULL); 79 -} 80 - 81 -GGRAPH_DECLARE const void * 82 -gGraphCreateRgbaImage (int width, int height) 83 -{ 84 -/* creating a new RGBA image */ 85 - return gg_image_create (GG_PIXEL_RGBA, width, height, 8, 3, 86 - GGRAPH_SAMPLE_UINT, NULL, NULL); 87 -} 88 - 89 -GGRAPH_DECLARE const void * 90 -gGraphCreateGrayscaleImage (int width, int height) 91 -{ 92 -/* creating a new Grayscale image */ 93 - return gg_image_create (GG_PIXEL_GRAYSCALE, width, height, 8, 1, 94 - GGRAPH_SAMPLE_UINT, NULL, NULL); 95 -} 96 - 97 -GGRAPH_DECLARE const void * 98 -gGraphCreatePaletteImage (int width, int height) 99 -{ 100 -/* creating a new Palette image */ 101 - return gg_image_create (GG_PIXEL_PALETTE, width, height, 8, 1, 102 - GGRAPH_SAMPLE_UINT, NULL, NULL); 103 -} 104 - 105 -GGRAPH_DECLARE const void * 106 -gGraphCreateMonochromeImage (int width, int height) 107 -{ 108 -/* creating a new Monochrome image */ 109 - gGraphImagePtr img = gg_image_create (GG_PIXEL_PALETTE, width, height, 8, 1, 110 - GGRAPH_SAMPLE_UINT, NULL, NULL); 111 - if (!img) 112 - return NULL; 113 - img->palette_red[0] = 255; 114 - img->palette_green[0] = 255; 115 - img->palette_blue[0] = 255; 116 - img->palette_red[1] = 0; 117 - img->palette_green[1] = 0; 118 - img->palette_blue[1] = 0; 119 - img->max_palette = 2; 120 - return img; 121 -} 122 - 123 -GGRAPH_DECLARE const void * 124 -gGraphCreateGridInt16Image (int width, int height) 125 -{ 126 -/* creating a new GRID-INT16 image */ 127 - return gg_image_create (GG_PIXEL_GRID, width, height, 16, 1, 128 - GGRAPH_SAMPLE_INT, NULL, NULL); 129 -} 130 - 131 -GGRAPH_DECLARE const void * 132 -gGraphCreateGridUInt16Image (int width, int height) 133 -{ 134 -/* creating a new GRID-UINT16 image */ 135 - return gg_image_create (GG_PIXEL_GRID, width, height, 16, 1, 136 - GGRAPH_SAMPLE_UINT, NULL, NULL); 137 -} 138 - 139 -GGRAPH_DECLARE const void * 140 -gGraphCreateGridInt32Image (int width, int height) 141 -{ 142 -/* creating a new GRID-INT32 image */ 143 - return gg_image_create (GG_PIXEL_GRID, width, height, 32, 1, 144 - GGRAPH_SAMPLE_INT, NULL, NULL); 145 -} 146 - 147 -GGRAPH_DECLARE const void * 148 -gGraphCreateGridUInt32Image (int width, int height) 149 -{ 150 -/* creating a new GRID-UINT32 image */ 151 - return gg_image_create (GG_PIXEL_GRID, width, height, 32, 1, 152 - GGRAPH_SAMPLE_UINT, NULL, NULL); 153 -} 154 - 155 -GGRAPH_DECLARE const void * 156 -gGraphCreateGridFloatImage (int width, int height) 157 -{ 158 -/* creating a new GRID-FLOAT image */ 159 - return gg_image_create (GG_PIXEL_GRID, width, height, 32, 1, 160 - GGRAPH_SAMPLE_FLOAT, NULL, NULL); 161 -} 162 - 163 -GGRAPH_DECLARE const void * 164 -gGraphCreateGridDoubleImage (int width, int height) 165 -{ 166 -/* creating a new GRID-DOUBLE image */ 167 - return gg_image_create (GG_PIXEL_GRID, width, height, 64, 1, 168 - GGRAPH_SAMPLE_FLOAT, NULL, NULL); 169 -} 170 - 171 -static unsigned char 172 -to_grayscale2 (unsigned char r, unsigned char g, unsigned char b) 173 -{ 174 -/* computing a grayscale value */ 175 - double dval = 176 - (0.3 * (double) r) + (0.59 * (double) g) + (0.11 * (double) b); 177 - int ival = (int) dval; 178 - if (ival < 0) 179 - ival = 0; 180 - if (ival > 255) 181 - ival = 255; 182 - return (unsigned char) ival; 183 -} 184 - 185 -GGRAPH_DECLARE int 186 -gGraphImageBackgroundFill (const void *ptr, unsigned char red, 187 - unsigned char green, unsigned char blue, 188 - unsigned char alpha) 189 -{ 190 -/* filling the image background */ 191 - int x; 192 - int y; 193 - unsigned char *p_out; 194 - gGraphImagePtr img = (gGraphImagePtr) ptr; 195 - 196 - if (img == NULL) 197 - return GGRAPH_INVALID_IMAGE; 198 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 199 - return GGRAPH_INVALID_IMAGE; 200 - 201 - for (y = 0; y < img->height; y++) 202 - { 203 - p_out = img->pixels + (y * img->scanline_width); 204 - for (x = 0; x < img->width; x++) 205 - { 206 - if (img->pixel_format == GG_PIXEL_RGB) 207 - { 208 - *p_out++ = red; 209 - *p_out++ = green; 210 - *p_out++ = blue; 211 - } 212 - if (img->pixel_format == GG_PIXEL_RGBA) 213 - { 214 - *p_out++ = red; 215 - *p_out++ = green; 216 - *p_out++ = blue; 217 - *p_out++ = alpha; 218 - } 219 - if (img->pixel_format == GG_PIXEL_ARGB) 220 - { 221 - *p_out++ = alpha; 222 - *p_out++ = red; 223 - *p_out++ = green; 224 - *p_out++ = blue; 225 - } 226 - if (img->pixel_format == GG_PIXEL_BGR) 227 - { 228 - *p_out++ = blue; 229 - *p_out++ = green; 230 - *p_out++ = red; 231 - } 232 - if (img->pixel_format == GG_PIXEL_BGRA) 233 - { 234 - *p_out++ = blue; 235 - *p_out++ = green; 236 - *p_out++ = red; 237 - *p_out++ = alpha; 238 - } 239 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 240 - { 241 - int gray; 242 - if (red == green && green == blue) 243 - gray = red; 244 - else 245 - gray = to_grayscale2 (red, green, blue); 246 - *p_out++ = gray; 247 - } 248 - if (img->pixel_format == GG_PIXEL_PALETTE) 249 - *p_out++ = 0; 250 - } 251 - } 252 - if (img->pixel_format == GG_PIXEL_PALETTE) 253 - { 254 - /* resetting an empty palette */ 255 - img->max_palette = 1; 256 - img->palette_red[0] = red; 257 - img->palette_green[0] = green; 258 - img->palette_blue[0] = blue; 259 - } 260 - return GGRAPH_OK; 261 -} 262 - 263 -GGRAPH_DECLARE int 264 -gGraphImageSetTransparentColor (const void *ptr, unsigned char red, 265 - unsigned char green, unsigned char blue) 266 -{ 267 -/* setting the image's transparent color */ 268 - gGraphImagePtr img = (gGraphImagePtr) ptr; 269 - 270 - if (img == NULL) 271 - return GGRAPH_INVALID_IMAGE; 272 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 273 - return GGRAPH_INVALID_IMAGE; 274 - 275 - img->transparent_red = red; 276 - img->transparent_green = green; 277 - img->transparent_blue = blue; 278 - return GGRAPH_OK; 279 -} 280 - 281 -GGRAPH_DECLARE int 282 -gGraphImageGetTransparentColor (const void *ptr, unsigned char *red, 283 - unsigned char *green, unsigned char *blue) 284 -{ 285 -/* querying the image's transparent color */ 286 - gGraphImagePtr img = (gGraphImagePtr) ptr; 287 - 288 - if (img == NULL) 289 - return GGRAPH_INVALID_IMAGE; 290 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 291 - return GGRAPH_INVALID_IMAGE; 292 - 293 - *red = img->transparent_red; 294 - *green = img->transparent_green; 295 - *blue = img->transparent_blue; 296 - return GGRAPH_OK; 297 -} 298 - 299 -GGRAPH_DECLARE int 300 -gGraphGridBackgroundFill (const void *ptr, double no_data_value) 301 -{ 302 -/* filling the image (GRID) background */ 303 - int x; 304 - int y; 305 - unsigned char *p_out; 306 - gGraphImagePtr img = (gGraphImagePtr) ptr; 307 - 308 - if (img == NULL) 309 - return GGRAPH_INVALID_IMAGE; 310 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 311 - return GGRAPH_INVALID_IMAGE; 312 - 313 - for (y = 0; y < img->height; y++) 314 - { 315 - p_out = img->pixels + (y * img->scanline_width); 316 - for (x = 0; x < img->width; x++) 317 - { 318 - if (img->pixel_format == GG_PIXEL_GRID) 319 - { 320 - switch (img->sample_format) 321 - { 322 - case GGRAPH_SAMPLE_INT: 323 - if (img->bits_per_sample == 16) 324 - { 325 - short *p = (short *) p_out; 326 - *p = (short) no_data_value; 327 - p_out += sizeof (short); 328 - } 329 - else 330 - { 331 - int *p = (int *) p_out; 332 - *p = (int) no_data_value; 333 - p_out += sizeof (int); 334 - } 335 - break; 336 - case GGRAPH_SAMPLE_UINT: 337 - if (img->bits_per_sample == 16) 338 - { 339 - unsigned short *p = (unsigned short *) p_out; 340 - *p = (unsigned short) no_data_value; 341 - p_out += sizeof (unsigned short); 342 - } 343 - else 344 - { 345 - unsigned int *p = (unsigned int *) p_out; 346 - *p = (unsigned int) no_data_value; 347 - p_out += sizeof (unsigned int); 348 - } 349 - break; 350 - case GGRAPH_SAMPLE_FLOAT: 351 - if (img->bits_per_sample == 32) 352 - { 353 - float *p = (float *) p_out; 354 - *p = (float) no_data_value; 355 - p_out += sizeof (float); 356 - } 357 - else 358 - { 359 - double *p = (double *) p_out; 360 - *p = no_data_value; 361 - p_out += sizeof (double); 362 - } 363 - break; 364 - }; 365 - } 366 - } 367 - } 368 - return GGRAPH_OK; 369 -} 370 - 371 -GGRAPH_DECLARE int 372 -gGraphImageSetNoDataValue (const void *ptr, double no_data_value) 373 -{ 374 -/* setting the image's NoDataValue */ 375 - gGraphImagePtr img = (gGraphImagePtr) ptr; 376 - 377 - if (img == NULL) 378 - return GGRAPH_INVALID_IMAGE; 379 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 380 - return GGRAPH_INVALID_IMAGE; 381 - 382 - img->no_data_value = no_data_value; 383 - return GGRAPH_OK; 384 -} 385 - 386 -GGRAPH_DECLARE int 387 -gGraphImageGetNoDataValue (const void *ptr, double *no_data_value) 388 -{ 389 -/* querying the image's NoDataValue */ 390 - gGraphImagePtr img = (gGraphImagePtr) ptr; 391 - 392 - if (img == NULL) 393 - return GGRAPH_INVALID_IMAGE; 394 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 395 - return GGRAPH_INVALID_IMAGE; 396 - 397 - *no_data_value = img->no_data_value; 398 - return GGRAPH_OK; 399 -} 400 - 401 -GGRAPH_DECLARE int 402 -gGraphImageInfosFromMemBuf (const void *mem_buf, int mem_buf_size, 403 - int image_type, const void **infos_handle) 404 -{ 405 -/* retrieving Image infos from a memory block containing an encoded image */ 406 - gGraphImageInfosPtr infos = NULL; 407 - int ret; 408 - 409 - *infos_handle = NULL; 410 - switch (image_type) 411 - { 412 - case GGRAPH_IMAGE_GIF: 413 - ret = 414 - gg_image_infos_from_gif (mem_buf_size, mem_buf, 415 - GG_TARGET_IS_MEMORY, &infos); 416 - break; 417 - case GGRAPH_IMAGE_PNG: 418 - ret = 419 - gg_image_infos_from_png (mem_buf_size, mem_buf, 420 - GG_TARGET_IS_MEMORY, &infos); 421 - break; 422 - case GGRAPH_IMAGE_JPEG: 423 - ret = 424 - gg_image_infos_from_jpeg (mem_buf_size, mem_buf, 425 - GG_TARGET_IS_MEMORY, &infos); 426 - break; 427 - case GGRAPH_IMAGE_TIFF: 428 - case GGRAPH_IMAGE_GEOTIFF: 429 - ret = gg_image_infos_from_mem_tiff (mem_buf_size, mem_buf, &infos); 430 - break; 431 - } 432 - if (ret != GGRAPH_OK) 433 - return ret; 434 - 435 - *infos_handle = infos; 436 - return GGRAPH_OK; 437 -} 438 - 439 -GGRAPH_DECLARE int 440 -gGraphImageInfosFromFile (const char *path, int image_type, 441 - const void **infos_handle) 442 -{ 443 -/* retrieving Image infos from file */ 444 - FILE *in = NULL; 445 - gGraphImageInfosPtr infos = NULL; 446 - int ret; 447 - 448 - *infos_handle = NULL; 449 - 450 -/* attempting to open the image file */ 451 - if (image_type == GGRAPH_IMAGE_TIFF || image_type == GGRAPH_IMAGE_GEOTIFF) 452 - ; 453 - else 454 - { 455 - in = fopen (path, "rb"); 456 - if (in == NULL) 457 - return GGRAPH_FILE_OPEN_ERROR; 458 - } 459 - switch (image_type) 460 - { 461 - case GGRAPH_IMAGE_GIF: 462 - ret = gg_image_infos_from_gif (0, in, GG_TARGET_IS_FILE, &infos); 463 - break; 464 - case GGRAPH_IMAGE_PNG: 465 - ret = gg_image_infos_from_png (0, in, GG_TARGET_IS_FILE, &infos); 466 - break; 467 - case GGRAPH_IMAGE_JPEG: 468 - ret = gg_image_infos_from_jpeg (0, in, GG_TARGET_IS_FILE, &infos); 469 - break; 470 - case GGRAPH_IMAGE_TIFF: 471 - ret = gg_image_infos_from_tiff (path, &infos); 472 - break; 473 - case GGRAPH_IMAGE_GEOTIFF: 474 - ret = gg_image_infos_from_geo_tiff (path, &infos); 475 - break; 476 - }; 477 - if (in) 478 - fclose (in); 479 - if (ret != GGRAPH_OK) 480 - return ret; 481 - 482 - *infos_handle = infos; 483 - return GGRAPH_OK; 484 -} 485 - 486 -GGRAPH_DECLARE int 487 -gGraphImageFromMemBuf (const void *mem_buf, int mem_buf_size, int image_type, 488 - const void **image_handle, int scale) 489 -{ 490 -/* decompressing a memory block containing an encoded image */ 491 - gGraphImagePtr img = NULL; 492 - int ret; 493 - 494 - *image_handle = NULL; 495 - switch (image_type) 496 - { 497 - case GGRAPH_IMAGE_GIF: 498 - ret = 499 - gg_image_from_gif (mem_buf_size, mem_buf, GG_TARGET_IS_MEMORY, 500 - &img); 501 - break; 502 - case GGRAPH_IMAGE_PNG: 503 - ret = 504 - gg_image_from_png (mem_buf_size, mem_buf, GG_TARGET_IS_MEMORY, 505 - &img, scale); 506 - break; 507 - case GGRAPH_IMAGE_JPEG: 508 - ret = 509 - gg_image_from_jpeg (mem_buf_size, mem_buf, GG_TARGET_IS_MEMORY, 510 - &img, scale); 511 - break; 512 - case GGRAPH_IMAGE_TIFF: 513 - case GGRAPH_IMAGE_GEOTIFF: 514 - ret = gg_image_from_mem_tiff (mem_buf_size, mem_buf, &img); 515 - break; 516 - } 517 - if (ret != GGRAPH_OK) 518 - return ret; 519 - 520 - *image_handle = img; 521 - return GGRAPH_OK; 522 -} 523 - 524 -GGRAPH_DECLARE int 525 -gGraphImageFromFile (const char *path, int image_type, 526 - const void **image_handle, int scale) 527 -{ 528 -/* reading an image from file */ 529 - FILE *in = NULL; 530 - gGraphImagePtr img = NULL; 531 - int ret; 532 - 533 - *image_handle = NULL; 534 - 535 -/* attempting to open the image file */ 536 - in = fopen (path, "rb"); 537 - if (in == NULL) 538 - return GGRAPH_FILE_OPEN_ERROR; 539 - switch (image_type) 540 - { 541 - case GGRAPH_IMAGE_GIF: 542 - ret = gg_image_from_gif (0, in, GG_TARGET_IS_FILE, &img); 543 - break; 544 - case GGRAPH_IMAGE_PNG: 545 - ret = gg_image_from_png (0, in, GG_TARGET_IS_FILE, &img, scale); 546 - break; 547 - case GGRAPH_IMAGE_JPEG: 548 - ret = gg_image_from_jpeg (0, in, GG_TARGET_IS_FILE, &img, scale); 549 - break; 550 - }; 551 - fclose (in); 552 - if (ret != GGRAPH_OK) 553 - return ret; 554 - 555 - *image_handle = img; 556 - return GGRAPH_OK; 557 -} 558 - 559 -GGRAPH_DECLARE int 560 -gGraphImageFromFileByStrips (const char *path, int image_type, 561 - const void **image_handle) 562 -{ 563 -/* reading an image from file [by strips] */ 564 - FILE *in = NULL; 565 - gGraphStripImagePtr img = NULL; 566 - int ret; 567 - 568 - *image_handle = NULL; 569 - 570 -/* attempting to open the image file */ 571 - if (image_type == GGRAPH_IMAGE_TIFF || image_type == GGRAPH_IMAGE_GEOTIFF) 572 - ; 573 - else 574 - { 575 - in = fopen (path, "rb"); 576 - if (in == NULL) 577 - return GGRAPH_FILE_OPEN_ERROR; 578 - } 579 - switch (image_type) 580 - { 581 - case GGRAPH_IMAGE_PNG: 582 - ret = gg_image_strip_prepare_from_png (in, &img); 583 - break; 584 - case GGRAPH_IMAGE_JPEG: 585 - ret = gg_image_strip_prepare_from_jpeg (in, &img); 586 - break; 587 - case GGRAPH_IMAGE_TIFF: 588 - ret = gg_image_strip_prepare_from_tiff (path, &img); 589 - break; 590 - case GGRAPH_IMAGE_GEOTIFF: 591 - ret = gg_image_strip_prepare_from_geotiff (path, &img); 592 - break; 593 - }; 594 - if (ret != GGRAPH_OK) 595 - { 596 - if (in) 597 - fclose (in); 598 - return ret; 599 - } 600 - 601 - *image_handle = img; 602 - return GGRAPH_OK; 603 -} 604 - 605 -GGRAPH_DECLARE int 606 -gGraphImageFromHgtFileByStrips (const char *path, int lat, int lon, 607 - const void **image_handle) 608 -{ 609 -/* reading an HGT GRID from file [by strips] */ 610 - FILE *in = NULL; 611 - gGraphStripImagePtr img = NULL; 612 - int ret; 613 - 614 - *image_handle = NULL; 615 - 616 -/* attempting to open the image file */ 617 - in = fopen (path, "rb"); 618 - if (in == NULL) 619 - return GGRAPH_FILE_OPEN_ERROR; 620 - ret = gg_image_strip_prepare_from_hgt (in, lat, lon, &img); 621 - if (ret != GGRAPH_OK) 622 - { 623 - if (in) 624 - fclose (in); 625 - return ret; 626 - } 627 - 628 - *image_handle = img; 629 - return GGRAPH_OK; 630 -} 631 - 632 -GGRAPH_DECLARE int 633 -gGraphImageFromBinFileByStrips (const char *path, const char *hdr_path, 634 - const void **image_handle) 635 -{ 636 -/* reading a BIN GRID from file [by strips] */ 637 - FILE *in = NULL; 638 - gGraphStripImagePtr img = NULL; 639 - int ret; 640 - 641 - *image_handle = NULL; 642 - 643 -/* attempting to open the image file */ 644 - in = fopen (path, "rb"); 645 - if (in == NULL) 646 - return GGRAPH_FILE_OPEN_ERROR; 647 - ret = gg_image_strip_prepare_from_bin_hdr (in, hdr_path, &img); 648 - if (ret != GGRAPH_OK) 649 - { 650 - if (in) 651 - fclose (in); 652 - return ret; 653 - } 654 - 655 - *image_handle = img; 656 - return GGRAPH_OK; 657 -} 658 - 659 -GGRAPH_DECLARE int 660 -gGraphImageFromFltFileByStrips (const char *path, const char *hdr_path, 661 - const void **image_handle) 662 -{ 663 -/* reading a FLT GRID from file [by strips] */ 664 - FILE *in = NULL; 665 - gGraphStripImagePtr img = NULL; 666 - int ret; 667 - 668 - *image_handle = NULL; 669 - 670 -/* attempting to open the image file */ 671 - in = fopen (path, "rb"); 672 - if (in == NULL) 673 - return GGRAPH_FILE_OPEN_ERROR; 674 - ret = gg_image_strip_prepare_from_flt_hdr (in, hdr_path, &img); 675 - if (ret != GGRAPH_OK) 676 - { 677 - if (in) 678 - fclose (in); 679 - return ret; 680 - } 681 - 682 - *image_handle = img; 683 - return GGRAPH_OK; 684 -} 685 - 686 -GGRAPH_DECLARE int 687 -gGraphImageFromDemFileByStrips (const char *path, const char *hdr_path, 688 - const void **image_handle) 689 -{ 690 -/* reading a DEM GRID from file [by strips] */ 691 - FILE *in = NULL; 692 - gGraphStripImagePtr img = NULL; 693 - int ret; 694 - 695 - *image_handle = NULL; 696 - 697 -/* attempting to open the image file */ 698 - in = fopen (path, "rb"); 699 - if (in == NULL) 700 - return GGRAPH_FILE_OPEN_ERROR; 701 - ret = gg_image_strip_prepare_from_dem_hdr (in, hdr_path, &img); 702 - if (ret != GGRAPH_OK) 703 - { 704 - if (in) 705 - fclose (in); 706 - return ret; 707 - } 708 - 709 - *image_handle = img; 710 - return GGRAPH_OK; 711 -} 712 - 713 -GGRAPH_DECLARE int 714 -gGraphImageFromAscFileByStrips (const char *path, const void **image_handle) 715 -{ 716 -/* reading a ASCII GRID from file [by strips] */ 717 - FILE *in = NULL; 718 - gGraphStripImagePtr img = NULL; 719 - int ret; 720 - 721 - *image_handle = NULL; 722 - 723 -/* attempting to open the image file */ 724 - in = fopen (path, "rb"); 725 - if (in == NULL) 726 - return GGRAPH_FILE_OPEN_ERROR; 727 - ret = gg_image_strip_prepare_from_ascii_grid (in, &img); 728 - if (ret != GGRAPH_OK) 729 - { 730 - if (in) 731 - fclose (in); 732 - return ret; 733 - } 734 - 735 - *image_handle = img; 736 - return GGRAPH_OK; 737 -} 738 - 739 -GGRAPH_DECLARE int 740 -gGraphCountColors (const char *path, int image_type, int rows_per_block) 741 -{ 742 -/* attempting to count how many different colors are into the given image file */ 743 - FILE *in = NULL; 744 - gGraphStripImagePtr img = NULL; 745 - int num_colors = 0; 746 - int ret; 747 - int x; 748 - int y; 749 - unsigned char *count_array = NULL; 750 - int index; 751 - 752 -/* attempting to open the image file */ 753 - if (image_type == GGRAPH_IMAGE_TIFF || image_type == GGRAPH_IMAGE_GEOTIFF) 754 - ; 755 - else 756 - { 757 - in = fopen (path, "rb"); 758 - if (in == NULL) 759 - return GGRAPH_FILE_OPEN_ERROR; 760 - } 761 - switch (image_type) 762 - { 763 - case GGRAPH_IMAGE_PNG: 764 - ret = gg_image_strip_prepare_from_png (in, &img); 765 - break; 766 - case GGRAPH_IMAGE_JPEG: 767 - ret = gg_image_strip_prepare_from_jpeg (in, &img); 768 - break; 769 - case GGRAPH_IMAGE_TIFF: 770 - ret = gg_image_strip_prepare_from_tiff (path, &img); 771 - break; 772 - case GGRAPH_IMAGE_GEOTIFF: 773 - ret = gg_image_strip_prepare_from_geotiff (path, &img); 774 - break; 775 - }; 776 - if (ret != GGRAPH_OK) 777 - { 778 - if (in) 779 - fclose (in); 780 - return 0; 781 - } 782 - 783 -/* creating the input buffer */ 784 - if (gGraphStripImageAllocPixels (img, rows_per_block) != GGRAPH_OK) 785 - { 786 - gGraphDestroyImage (img); 787 - return 0; 788 - } 789 - 790 -/* creating the count array */ 791 - count_array = malloc (256 * 256 * 256); 792 - if (!count_array) 793 - { 794 - gGraphDestroyImage (img); 795 - return 0; 796 - } 797 - for (index = 0; index < (256 * 256 * 256); index++) 798 - count_array[index] = 0; 799 - 800 - while (1) 801 - { 802 - /* inspecting the image pixels */ 803 - if (gGraphStripImageEOF (img) == GGRAPH_OK) 804 - goto done; 805 - if (gGraphReadNextStrip (img, NULL) != GGRAPH_OK) 806 - goto error; 807 - for (y = 0; y < img->current_available_rows; y++) 808 - { 809 - unsigned char *p_in = img->pixels + (y * img->scanline_width); 810 - for (x = 0; x < img->width; x++) 811 - { 812 - unsigned char red; 813 - unsigned char green; 814 - unsigned char blue; 815 - if (img->pixel_format == GG_PIXEL_RGB) 816 - { 817 - red = *p_in++; 818 - green = *p_in++; 819 - blue = *p_in++; 820 - } 821 - else if (img->pixel_format == GG_PIXEL_RGBA) 822 - { 823 - red = *p_in++; 824 - green = *p_in++; 825 - blue = *p_in++; 826 - p_in++; /* skipping Alpha */ 827 - } 828 - else if (img->pixel_format == GG_PIXEL_RGB) 829 - { 830 - p_in++; /* skipping Alpha */ 831 - red = *p_in++; 832 - green = *p_in++; 833 - blue = *p_in++; 834 - } 835 - else if (img->pixel_format == GG_PIXEL_BGR) 836 - { 837 - blue = *p_in++; 838 - green = *p_in++; 839 - red = *p_in++; 840 - } 841 - else if (img->pixel_format == GG_PIXEL_BGRA) 842 - { 843 - blue = *p_in++; 844 - green = *p_in++; 845 - red = *p_in++; 846 - p_in++; /* skipping Alpha */ 847 - } 848 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 849 - { 850 - red = *p_in++; 851 - green = red; 852 - blue = red; 853 - } 854 - else if (img->pixel_format == GG_PIXEL_PALETTE) 855 - { 856 - index = *p_in++; 857 - red = img->palette_red[index]; 858 - green = img->palette_green[index]; 859 - blue = img->palette_blue[index]; 860 - } 861 - index = (red * 256 * 256) + (green * 256) + blue; 862 - count_array[index] = 1; 863 - } 864 - } 865 - } 866 - 867 - error: 868 - gGraphDestroyImage (img); 869 - if (!count_array) 870 - free (count_array); 871 - return 0; 872 - 873 - done: 874 - for (index = 0; index < (256 * 256 * 256); index++) 875 - { 876 - if (count_array[index]) 877 - num_colors++; 878 - } 879 - gGraphDestroyImage (img); 880 - if (!count_array) 881 - free (count_array); 882 - return num_colors; 883 -} 884 - 885 -GGRAPH_DECLARE int 886 -gGraphImageToJpegFile (const void *ptr, const char *path, int quality) 887 -{ 888 -/* exporting an image into a JPEG compressed file */ 889 - gGraphImagePtr img = (gGraphImagePtr) ptr; 890 - int ret; 891 - FILE *out = NULL; 892 - 893 - if (!img) 894 - return GGRAPH_INVALID_IMAGE; 895 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 896 - return GGRAPH_INVALID_IMAGE; 897 - 898 -/* opening the output image file */ 899 - out = fopen (path, "wb"); 900 - if (out == NULL) 901 - return GGRAPH_FILE_OPEN_ERROR; 902 -/* compressing as JPEG */ 903 - ret = gg_image_to_jpeg (img, NULL, NULL, out, GG_TARGET_IS_FILE, quality); 904 - fclose (out); 905 - if (ret != GGRAPH_OK) 906 - { 907 - /* some unexpected error occurred */ 908 - unlink (path); 909 - return ret; 910 - } 911 - 912 - return GGRAPH_OK; 913 -} 914 - 915 -GGRAPH_DECLARE int 916 -gGraphImageToJpegFileByStrips (const void **ptr, const char *path, int width, 917 - int height, int color_model, int quality) 918 -{ 919 -/* exporting an image into a JPEG compressed file [by strips] */ 920 - gGraphStripImagePtr img; 921 - int ret; 922 - FILE *out = NULL; 923 - 924 - *ptr = NULL; 925 - if (color_model == GGRAPH_COLORSPACE_GRAYSCALE 926 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR) 927 - ; 928 - else 929 - return GGRAPH_INVALID_IMAGE; 930 - 931 -/* opening the output image file */ 932 - out = fopen (path, "wb"); 933 - if (out == NULL) 934 - return GGRAPH_FILE_OPEN_ERROR; 935 - 936 -/* creating a Strip Image */ 937 - if (color_model == GGRAPH_COLORSPACE_GRAYSCALE) 938 - { 939 - img = 940 - gg_strip_image_create (out, GGRAPH_IMAGE_JPEG, GG_PIXEL_GRAYSCALE, 941 - width, height, 8, 1, GGRAPH_SAMPLE_UINT, 942 - NULL, NULL); 943 - if (!img) 944 - { 945 - fclose (out); 946 - unlink (path); 947 - return GGRAPH_INSUFFICIENT_MEMORY; 948 - } 949 - } 950 - if (color_model == GGRAPH_COLORSPACE_TRUECOLOR) 951 - { 952 - img = 953 - gg_strip_image_create (out, GGRAPH_IMAGE_JPEG, GG_PIXEL_RGB, 954 - width, height, 8, 3, GGRAPH_SAMPLE_UINT, 955 - NULL, NULL); 956 - if (!img) 957 - { 958 - fclose (out); 959 - unlink (path); 960 - return GGRAPH_INSUFFICIENT_MEMORY; 961 - } 962 - } 963 - 964 - ret = gg_image_prepare_to_jpeg_by_strip (img, out, quality); 965 - if (ret != GGRAPH_OK) 966 - { 967 - gg_strip_image_destroy (img); 968 - return ret; 969 - } 970 - 971 - *ptr = img; 972 - return GGRAPH_OK; 973 -} 974 - 975 -GGRAPH_DECLARE int 976 -gGraphImageToJpegMemBuf (const void *ptr, void **mem_buf, int *mem_buf_size, 977 - int quality) 978 -{ 979 -/* exporting an image into a JPEG compressed memory buffer */ 980 - gGraphImagePtr img = (gGraphImagePtr) ptr; 981 - void *buf = NULL; 982 - int size; 983 - int ret; 984 - 985 - *mem_buf = NULL; 986 - *mem_buf_size = 0; 987 - if (img == NULL) 988 - return GGRAPH_INVALID_IMAGE; 989 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 990 - return GGRAPH_INVALID_IMAGE; 991 - 992 -/* compressing as JPEG */ 993 - ret = 994 - gg_image_to_jpeg (img, &buf, &size, NULL, GG_TARGET_IS_MEMORY, quality); 995 - if (ret != GGRAPH_OK) 996 - return ret; 997 - 998 -/* exporting the memory buffer */ 999 - *mem_buf = buf; 1000 - *mem_buf_size = size; 1001 - return GGRAPH_OK; 1002 -} 1003 - 1004 -GGRAPH_DECLARE int 1005 -gGraphImageToPngFile (const void *ptr, const char *path, int compression_level, 1006 - int quantization_factor, int interlaced) 1007 -{ 1008 -/* exporting an image into a PNG compressed file */ 1009 - gGraphImagePtr img = (gGraphImagePtr) ptr; 1010 - int ret; 1011 - FILE *out = NULL; 1012 - 1013 - if (!img) 1014 - return GGRAPH_INVALID_IMAGE; 1015 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 1016 - return GGRAPH_INVALID_IMAGE; 1017 - 1018 -/* opening the output image file */ 1019 - out = fopen (path, "wb"); 1020 - if (out == NULL) 1021 - return GGRAPH_FILE_OPEN_ERROR; 1022 -/* compressing as PNG */ 1023 - ret = 1024 - gg_image_to_png (img, NULL, NULL, out, GG_TARGET_IS_FILE, 1025 - compression_level, quantization_factor, interlaced, 0); 1026 - fclose (out); 1027 - if (ret != GGRAPH_OK) 1028 - { 1029 - /* some unexpected error occurred */ 1030 - unlink (path); 1031 - return ret; 1032 - } 1033 - 1034 - return GGRAPH_OK; 1035 -} 1036 - 1037 -GGRAPH_DECLARE int 1038 -gGraphImageToPngFileByStrips (const void **ptr, const char *path, int width, 1039 - int height, int color_model, int bits_per_sample, 1040 - int num_palette, unsigned char *red, 1041 - unsigned char *green, unsigned char *blue, 1042 - int compression_level, int quantization_factor) 1043 -{ 1044 -/* exporting an image into a PNG compressed file [by strips] */ 1045 - gGraphStripImagePtr img; 1046 - int ret; 1047 - int i; 1048 - FILE *out = NULL; 1049 - 1050 - *ptr = NULL; 1051 - if (color_model == GGRAPH_COLORSPACE_PALETTE 1052 - || color_model == GGRAPH_COLORSPACE_GRAYSCALE 1053 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR 1054 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR_ALPHA) 1055 - ; 1056 - else 1057 - return GGRAPH_INVALID_IMAGE; 1058 - 1059 - if (color_model == GGRAPH_COLORSPACE_PALETTE) 1060 - { 1061 - if (num_palette < 1) 1062 - return GGRAPH_INVALID_IMAGE; 1063 - if (bits_per_sample == 1 || bits_per_sample == 2 1064 - || bits_per_sample == 4 || bits_per_sample == 8) 1065 - ; 1066 - else 1067 - return GGRAPH_INVALID_IMAGE; 1068 - if (bits_per_sample == 1 && num_palette > 2) 1069 - return GGRAPH_INVALID_IMAGE; 1070 - if (bits_per_sample == 2 && num_palette > 4) 1071 - return GGRAPH_INVALID_IMAGE; 1072 - if (bits_per_sample == 4 && num_palette > 16) 1073 - return GGRAPH_INVALID_IMAGE; 1074 - if (bits_per_sample == 8 && num_palette > 256) 1075 - return GGRAPH_INVALID_IMAGE; 1076 - } 1077 - if (color_model == GGRAPH_COLORSPACE_GRAYSCALE) 1078 - { 1079 - if (bits_per_sample == 1 || bits_per_sample == 2 1080 - || bits_per_sample == 4 || bits_per_sample == 8) 1081 - ; 1082 - else 1083 - return GGRAPH_INVALID_IMAGE; 1084 - } 1085 - 1086 -/* opening the output image file */ 1087 - out = fopen (path, "wb"); 1088 - if (out == NULL) 1089 - return GGRAPH_FILE_OPEN_ERROR; 1090 - 1091 -/* creating a Strip Image */ 1092 - if (color_model == GGRAPH_COLORSPACE_PALETTE) 1093 - { 1094 - img = 1095 - gg_strip_image_create (out, GGRAPH_IMAGE_PNG, GG_PIXEL_PALETTE, 1096 - width, height, bits_per_sample, 1, 1097 - GGRAPH_SAMPLE_UINT, NULL, NULL); 1098 - if (!img) 1099 - { 1100 - fclose (out); 1101 - unlink (path); 1102 - return GGRAPH_INSUFFICIENT_MEMORY; 1103 - } 1104 - for (i = 0; i < num_palette; i++) 1105 - { 1106 - img->palette_red[i] = red[i]; 1107 - img->palette_green[i] = green[i]; 1108 - img->palette_blue[i] = blue[i]; 1109 - img->max_palette = i + 1; 1110 - } 1111 - } 1112 - if (color_model == GGRAPH_COLORSPACE_GRAYSCALE) 1113 - { 1114 - img = 1115 - gg_strip_image_create (out, GGRAPH_IMAGE_PNG, GG_PIXEL_GRAYSCALE, 1116 - width, height, bits_per_sample, 1, 1117 - GGRAPH_SAMPLE_UINT, NULL, NULL); 1118 - if (!img) 1119 - { 1120 - fclose (out); 1121 - unlink (path); 1122 - return GGRAPH_INSUFFICIENT_MEMORY; 1123 - } 1124 - } 1125 - if (color_model == GGRAPH_COLORSPACE_TRUECOLOR) 1126 - { 1127 - img = 1128 - gg_strip_image_create (out, GGRAPH_IMAGE_PNG, GG_PIXEL_RGB, width, 1129 - height, 8, 3, GGRAPH_SAMPLE_UINT, NULL, 1130 - NULL); 1131 - if (!img) 1132 - { 1133 - fclose (out); 1134 - unlink (path); 1135 - return GGRAPH_INSUFFICIENT_MEMORY; 1136 - } 1137 - } 1138 - if (color_model == GGRAPH_COLORSPACE_TRUECOLOR_ALPHA) 1139 - { 1140 - img = 1141 - gg_strip_image_create (out, GGRAPH_IMAGE_PNG, GG_PIXEL_RGBA, 1142 - width, height, 8, 4, GGRAPH_SAMPLE_UINT, 1143 - NULL, NULL); 1144 - if (!img) 1145 - { 1146 - fclose (out); 1147 - unlink (path); 1148 - return GGRAPH_INSUFFICIENT_MEMORY; 1149 - } 1150 - } 1151 - 1152 - ret = 1153 - gg_image_prepare_to_png_by_strip (img, out, compression_level, 1154 - quantization_factor); 1155 - if (ret != GGRAPH_OK) 1156 - { 1157 - gg_strip_image_destroy (img); 1158 - return ret; 1159 - } 1160 - 1161 - *ptr = img; 1162 - return GGRAPH_OK; 1163 -} 1164 - 1165 -GGRAPH_DECLARE int 1166 -gGraphImageToTiffFileByStrips (const void **ptr, const char *path, 1167 - int width, int height, int color_model, 1168 - int tiff_layout, 1169 - int tile_width, 1170 - int tile_height, 1171 - int rows_per_strip, 1172 - int bits_per_sample, int sample_format, 1173 - int num_palette, 1174 - unsigned char *red, unsigned char *green, 1175 - unsigned char *blue, int compression) 1176 -{ 1177 -/* exporting an image into a TIFF compressed file [by strips] */ 1178 - gGraphStripImagePtr img; 1179 - int ret; 1180 - int i; 1181 - 1182 - *ptr = NULL; 1183 - if (color_model == GGRAPH_COLORSPACE_PALETTE 1184 - || color_model == GGRAPH_COLORSPACE_GRAYSCALE 1185 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR 1186 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR_ALPHA 1187 - || color_model == GGRAPH_COLORSPACE_GRID) 1188 - ; 1189 - else 1190 - return GGRAPH_INVALID_IMAGE; 1191 - 1192 - if (color_model == GGRAPH_COLORSPACE_PALETTE) 1193 - { 1194 - if (num_palette < 1) 1195 - return GGRAPH_INVALID_IMAGE; 1196 - if (bits_per_sample == 1 || bits_per_sample == 2 1197 - || bits_per_sample == 4 || bits_per_sample == 8) 1198 - ; 1199 - else 1200 - return GGRAPH_INVALID_IMAGE; 1201 - if (bits_per_sample == 1 && num_palette > 2) 1202 - return GGRAPH_INVALID_IMAGE; 1203 - if (bits_per_sample == 2 && num_palette > 4) 1204 - return GGRAPH_INVALID_IMAGE; 1205 - if (bits_per_sample == 4 && num_palette > 16) 1206 - return GGRAPH_INVALID_IMAGE; 1207 - if (bits_per_sample == 8 && num_palette > 256) 1208 - return GGRAPH_INVALID_IMAGE; 1209 - } 1210 - if (color_model == GGRAPH_COLORSPACE_GRID) 1211 - { 1212 - if (sample_format == GGRAPH_SAMPLE_UINT 1213 - || sample_format == GGRAPH_SAMPLE_INT) 1214 - { 1215 - if (bits_per_sample == 8 || bits_per_sample == 16 1216 - || bits_per_sample == 32) 1217 - ; 1218 - else 1219 - return GGRAPH_INVALID_IMAGE; 1220 - } 1221 - else if (GGRAPH_SAMPLE_FLOAT) 1222 - { 1223 - if (bits_per_sample == 32 || bits_per_sample == 64) 1224 - ; 1225 - else 1226 - return GGRAPH_INVALID_IMAGE; 1227 - } 1228 - else 1229 - return GGRAPH_INVALID_IMAGE; 1230 - } 1231 - 1232 -/* creating a Strip Image */ 1233 - if (color_model == GGRAPH_COLORSPACE_PALETTE) 1234 - { 1235 - img = 1236 - gg_strip_image_create (NULL, GGRAPH_IMAGE_TIFF, GG_PIXEL_PALETTE, 1237 - width, height, bits_per_sample, 1, 1238 - GGRAPH_SAMPLE_UINT, NULL, NULL); 1239 - if (!img) 1240 - return GGRAPH_INSUFFICIENT_MEMORY; 1241 - for (i = 0; i < num_palette; i++) 1242 - { 1243 - img->palette_red[i] = red[i]; 1244 - img->palette_green[i] = green[i]; 1245 - img->palette_blue[i] = blue[i]; 1246 - img->max_palette = i + 1; 1247 - } 1248 - } 1249 - if (color_model == GGRAPH_COLORSPACE_GRAYSCALE) 1250 - { 1251 - img = 1252 - gg_strip_image_create (NULL, GGRAPH_IMAGE_TIFF, 1253 - GG_PIXEL_GRAYSCALE, width, height, 1254 - bits_per_sample, 1, GGRAPH_SAMPLE_UINT, 1255 - NULL, NULL); 1256 - if (!img) 1257 - return GGRAPH_INSUFFICIENT_MEMORY; 1258 - } 1259 - if (color_model == GGRAPH_COLORSPACE_TRUECOLOR 1260 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR_ALPHA) 1261 - { 1262 - img = 1263 - gg_strip_image_create (NULL, GGRAPH_IMAGE_TIFF, GG_PIXEL_RGB, 1264 - width, height, 8, 3, GGRAPH_SAMPLE_UINT, 1265 - NULL, NULL); 1266 - if (!img) 1267 - return GGRAPH_INSUFFICIENT_MEMORY; 1268 - } 1269 - if (color_model == GGRAPH_COLORSPACE_GRID) 1270 - { 1271 - img = 1272 - gg_strip_image_create (NULL, GGRAPH_IMAGE_TIFF, GG_PIXEL_GRID, 1273 - width, height, bits_per_sample, 1, 1274 - sample_format, NULL, NULL); 1275 - if (!img) 1276 - return GGRAPH_INSUFFICIENT_MEMORY; 1277 - } 1278 - 1279 - img->tile_width = tile_width; 1280 - img->tile_height = tile_height; 1281 - img->rows_per_strip = rows_per_strip; 1282 - 1283 - ret = 1284 - gg_image_prepare_to_tiff_by_strip (img, path, tiff_layout, tile_width, 1285 - tile_height, rows_per_strip, 1286 - color_model, bits_per_sample, 1287 - sample_format, num_palette, red, 1288 - green, blue, compression); 1289 - if (ret != GGRAPH_OK) 1290 - { 1291 - gg_strip_image_destroy (img); 1292 - return ret; 1293 - } 1294 - 1295 - *ptr = img; 1296 - return GGRAPH_OK; 1297 -} 1298 - 1299 -GGRAPH_DECLARE int 1300 -gGraphImageToGeoTiffFileByStrips (const void **ptr, const char *path, 1301 - int width, int height, int color_model, 1302 - int tiff_layout, 1303 - int tile_width, 1304 - int tile_height, 1305 - int rows_per_strip, 1306 - int bits_per_sample, int sample_format, 1307 - int num_palette, 1308 - unsigned char *red, unsigned char *green, 1309 - unsigned char *blue, int compression, 1310 - int srid, const char *srs_name, 1311 - const char *proj4text, double upper_left_x, 1312 - double upper_left_y, double pixel_x_size, 1313 - double pixel_y_size) 1314 -{ 1315 -/* exporting an image into a GeoTIFF compressed file [by strips] */ 1316 - gGraphStripImagePtr img; 1317 - int ret; 1318 - int i; 1319 - 1320 - *ptr = NULL; 1321 - if (color_model == GGRAPH_COLORSPACE_PALETTE 1322 - || color_model == GGRAPH_COLORSPACE_GRAYSCALE 1323 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR 1324 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR_ALPHA 1325 - || color_model == GGRAPH_COLORSPACE_GRID) 1326 - ; 1327 - else 1328 - return GGRAPH_INVALID_IMAGE; 1329 - 1330 - if (color_model == GGRAPH_COLORSPACE_PALETTE) 1331 - { 1332 - if (num_palette < 1) 1333 - return GGRAPH_INVALID_IMAGE; 1334 - if (bits_per_sample == 1 || bits_per_sample == 2 1335 - || bits_per_sample == 4 || bits_per_sample == 8) 1336 - ; 1337 - else 1338 - return GGRAPH_INVALID_IMAGE; 1339 - if (bits_per_sample == 1 && num_palette > 2) 1340 - return GGRAPH_INVALID_IMAGE; 1341 - if (bits_per_sample == 2 && num_palette > 4) 1342 - return GGRAPH_INVALID_IMAGE; 1343 - if (bits_per_sample == 4 && num_palette > 16) 1344 - return GGRAPH_INVALID_IMAGE; 1345 - if (bits_per_sample == 8 && num_palette > 256) 1346 - return GGRAPH_INVALID_IMAGE; 1347 - } 1348 - if (color_model == GGRAPH_COLORSPACE_GRID) 1349 - { 1350 - if (sample_format == GGRAPH_SAMPLE_UINT 1351 - || sample_format == GGRAPH_SAMPLE_INT) 1352 - { 1353 - if (bits_per_sample == 8 || bits_per_sample == 16 1354 - || bits_per_sample == 32) 1355 - ; 1356 - else 1357 - return GGRAPH_INVALID_IMAGE; 1358 - } 1359 - else if (GGRAPH_SAMPLE_FLOAT) 1360 - { 1361 - if (bits_per_sample == 32 || bits_per_sample == 64) 1362 - ; 1363 - else 1364 - return GGRAPH_INVALID_IMAGE; 1365 - } 1366 - else 1367 - return GGRAPH_INVALID_IMAGE; 1368 - } 1369 - 1370 -/* creating a Strip Image */ 1371 - if (color_model == GGRAPH_COLORSPACE_PALETTE) 1372 - { 1373 - img = 1374 - gg_strip_image_create (NULL, GGRAPH_IMAGE_GEOTIFF, 1375 - GG_PIXEL_PALETTE, width, height, 1376 - bits_per_sample, 1, GGRAPH_SAMPLE_UINT, 1377 - NULL, NULL); 1378 - if (!img) 1379 - return GGRAPH_INSUFFICIENT_MEMORY; 1380 - for (i = 0; i < num_palette; i++) 1381 - { 1382 - img->palette_red[i] = red[i]; 1383 - img->palette_green[i] = green[i]; 1384 - img->palette_blue[i] = blue[i]; 1385 - img->max_palette = i + 1; 1386 - } 1387 - } 1388 - if (color_model == GGRAPH_COLORSPACE_GRAYSCALE) 1389 - { 1390 - img = 1391 - gg_strip_image_create (NULL, GGRAPH_IMAGE_GEOTIFF, 1392 - GG_PIXEL_GRAYSCALE, width, height, 1393 - bits_per_sample, 1, GGRAPH_SAMPLE_UINT, 1394 - NULL, NULL); 1395 - if (!img) 1396 - return GGRAPH_INSUFFICIENT_MEMORY; 1397 - } 1398 - if (color_model == GGRAPH_COLORSPACE_TRUECOLOR 1399 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR_ALPHA) 1400 - { 1401 - img = 1402 - gg_strip_image_create (NULL, GGRAPH_IMAGE_GEOTIFF, GG_PIXEL_RGB, 1403 - width, height, 8, 3, GGRAPH_SAMPLE_UINT, 1404 - NULL, NULL); 1405 - if (!img) 1406 - return GGRAPH_INSUFFICIENT_MEMORY; 1407 - } 1408 - if (color_model == GGRAPH_COLORSPACE_GRID) 1409 - { 1410 - img = 1411 - gg_strip_image_create (NULL, GGRAPH_IMAGE_GEOTIFF, GG_PIXEL_GRID, 1412 - width, height, bits_per_sample, 1, 1413 - sample_format, NULL, NULL); 1414 - if (!img) 1415 - return GGRAPH_INSUFFICIENT_MEMORY; 1416 - } 1417 - gGraphImageSetGeoRef (img, srid, srs_name, proj4text, upper_left_x, 1418 - upper_left_y, pixel_x_size, pixel_y_size); 1419 - 1420 - img->tile_width = tile_width; 1421 - img->tile_height = tile_height; 1422 - img->rows_per_strip = rows_per_strip; 1423 - 1424 - ret = 1425 - gg_image_prepare_to_geotiff_by_strip (img, path, tiff_layout, 1426 - tile_width, tile_height, 1427 - rows_per_strip, color_model, 1428 - bits_per_sample, sample_format, 1429 - num_palette, red, green, blue, 1430 - compression); 1431 - if (ret != GGRAPH_OK) 1432 - { 1433 - gg_strip_image_destroy (img); 1434 - return ret; 1435 - } 1436 - 1437 - *ptr = img; 1438 - return GGRAPH_OK; 1439 -} 1440 - 1441 -GGRAPH_DECLARE int 1442 -gGraphImageToBinHdrFileByStrips (const void **ptr, const char *path, int width, 1443 - int height, int bits_per_sample, 1444 - double upper_left_x, double upper_left_y, 1445 - double pixel_x_size, double pixel_y_size, 1446 - double no_data_value) 1447 -{ 1448 -/* exporting an image into a BIN+HDR GRID file [by strips] */ 1449 - gGraphStripImagePtr img = NULL; 1450 - int ret; 1451 - FILE *out = NULL; 1452 - 1453 - *ptr = NULL; 1454 - 1455 -/* opening the output image file */ 1456 - out = fopen (path, "wb"); 1457 - if (out == NULL) 1458 - return GGRAPH_FILE_OPEN_ERROR; 1459 - 1460 -/* creating a Strip Image */ 1461 - if (bits_per_sample == 16) 1462 - { 1463 - img = gg_strip_image_create (out, GGRAPH_IMAGE_BIN_HDR, GG_PIXEL_GRID, 1464 - width, height, 16, 1, GGRAPH_SAMPLE_INT, 1465 - NULL, NULL); 1466 - } 1467 - if (bits_per_sample == 32) 1468 - { 1469 - img = gg_strip_image_create (out, GGRAPH_IMAGE_BIN_HDR, GG_PIXEL_GRID, 1470 - width, height, 32, 1, GGRAPH_SAMPLE_INT, 1471 - NULL, NULL); 1472 - } 1473 - if (!img) 1474 - { 1475 - fclose (out); 1476 - unlink (path); 1477 - return GGRAPH_INSUFFICIENT_MEMORY; 1478 - } 1479 - 1480 - img->upper_left_x = upper_left_x; 1481 - img->upper_left_y = upper_left_y; 1482 - img->pixel_x_size = pixel_x_size; 1483 - img->pixel_y_size = pixel_y_size; 1484 - img->no_data_value = no_data_value; 1485 - ret = gg_image_prepare_to_bin_hdr_by_strip (img); 1486 - if (ret != GGRAPH_OK) 1487 - if (ret != GGRAPH_OK) 1488 - { 1489 - gg_strip_image_destroy (img); 1490 - return ret; 1491 - } 1492 - 1493 - *ptr = img; 1494 - return GGRAPH_OK; 1495 -} 1496 - 1497 -GGRAPH_DECLARE int 1498 -gGraphImageToFltHdrFileByStrips (const void **ptr, const char *path, int width, 1499 - int height, int bits_per_sample, 1500 - double upper_left_x, double upper_left_y, 1501 - double pixel_x_size, double pixel_y_size, 1502 - double no_data_value) 1503 -{ 1504 -/* exporting an image into a FLT+HDR GRID file [by strips] */ 1505 - gGraphStripImagePtr img = NULL; 1506 - int ret; 1507 - FILE *out = NULL; 1508 - 1509 - *ptr = NULL; 1510 - 1511 -/* opening the output image file */ 1512 - out = fopen (path, "wb"); 1513 - if (out == NULL) 1514 - return GGRAPH_FILE_OPEN_ERROR; 1515 - 1516 -/* creating a Strip Image */ 1517 - if (bits_per_sample == 32) 1518 - { 1519 - img = gg_strip_image_create (out, GGRAPH_IMAGE_FLT_HDR, GG_PIXEL_GRID, 1520 - width, height, 32, 1, 1521 - GGRAPH_SAMPLE_FLOAT, NULL, NULL); 1522 - } 1523 - if (bits_per_sample == 64) 1524 - { 1525 - img = gg_strip_image_create (out, GGRAPH_IMAGE_FLT_HDR, GG_PIXEL_GRID, 1526 - width, height, 64, 1, 1527 - GGRAPH_SAMPLE_FLOAT, NULL, NULL); 1528 - } 1529 - if (!img) 1530 - { 1531 - fclose (out); 1532 - unlink (path); 1533 - return GGRAPH_INSUFFICIENT_MEMORY; 1534 - } 1535 - 1536 - img->upper_left_x = upper_left_x; 1537 - img->upper_left_y = upper_left_y; 1538 - img->pixel_x_size = pixel_x_size; 1539 - img->pixel_y_size = pixel_y_size; 1540 - img->no_data_value = no_data_value; 1541 - ret = gg_image_prepare_to_flt_hdr_by_strip (img); 1542 - if (ret != GGRAPH_OK) 1543 - { 1544 - gg_strip_image_destroy (img); 1545 - return ret; 1546 - } 1547 - 1548 - *ptr = img; 1549 - return GGRAPH_OK; 1550 -} 1551 - 1552 -GGRAPH_DECLARE int 1553 -gGraphImageToAscFileByStrips (const void **ptr, const char *path, int width, 1554 - int height, int sample, int bits_per_sample, 1555 - double upper_left_x, double upper_left_y, 1556 - double pixel_x_size, double pixel_y_size, 1557 - double no_data_value) 1558 -{ 1559 -/* exporting an image into an ASCII GRID file [by strips] */ 1560 - gGraphStripImagePtr img = NULL; 1561 - int ret; 1562 - FILE *out = NULL; 1563 - 1564 - *ptr = NULL; 1565 - 1566 -/* opening the output image file */ 1567 - out = fopen (path, "wb"); 1568 - if (out == NULL) 1569 - return GGRAPH_FILE_OPEN_ERROR; 1570 - 1571 -/* creating a Strip Image */ 1572 - if (sample == GGRAPH_SAMPLE_UINT) 1573 - { 1574 - if (bits_per_sample == 8) 1575 - { 1576 - img = 1577 - gg_strip_image_create (out, GGRAPH_IMAGE_ASCII_GRID, 1578 - GG_PIXEL_GRID, width, height, 8, 1, 1579 - GGRAPH_SAMPLE_UINT, NULL, NULL); 1580 - } 1581 - if (bits_per_sample == 16) 1582 - { 1583 - img = 1584 - gg_strip_image_create (out, GGRAPH_IMAGE_ASCII_GRID, 1585 - GG_PIXEL_GRID, width, height, 16, 1, 1586 - GGRAPH_SAMPLE_UINT, NULL, NULL); 1587 - } 1588 - if (bits_per_sample == 32) 1589 - { 1590 - img = 1591 - gg_strip_image_create (out, GGRAPH_IMAGE_ASCII_GRID, 1592 - GG_PIXEL_GRID, width, height, 32, 1, 1593 - GGRAPH_SAMPLE_UINT, NULL, NULL); 1594 - } 1595 - } 1596 - if (sample == GGRAPH_SAMPLE_INT) 1597 - { 1598 - if (bits_per_sample == 8) 1599 - { 1600 - img = 1601 - gg_strip_image_create (out, GGRAPH_IMAGE_ASCII_GRID, 1602 - GG_PIXEL_GRID, width, height, 8, 1, 1603 - GGRAPH_SAMPLE_INT, NULL, NULL); 1604 - } 1605 - if (bits_per_sample == 16) 1606 - { 1607 - img = 1608 - gg_strip_image_create (out, GGRAPH_IMAGE_ASCII_GRID, 1609 - GG_PIXEL_GRID, width, height, 16, 1, 1610 - GGRAPH_SAMPLE_INT, NULL, NULL); 1611 - } 1612 - if (bits_per_sample == 32) 1613 - { 1614 - img = 1615 - gg_strip_image_create (out, GGRAPH_IMAGE_ASCII_GRID, 1616 - GG_PIXEL_GRID, width, height, 32, 1, 1617 - GGRAPH_SAMPLE_INT, NULL, NULL); 1618 - } 1619 - } 1620 - if (sample == GGRAPH_SAMPLE_FLOAT) 1621 - { 1622 - if (bits_per_sample == 32) 1623 - { 1624 - img = 1625 - gg_strip_image_create (out, GGRAPH_IMAGE_ASCII_GRID, 1626 - GG_PIXEL_GRID, width, height, 32, 1, 1627 - GGRAPH_SAMPLE_FLOAT, NULL, NULL); 1628 - } 1629 - if (bits_per_sample == 64) 1630 - { 1631 - img = 1632 - gg_strip_image_create (out, GGRAPH_IMAGE_ASCII_GRID, 1633 - GG_PIXEL_GRID, width, height, 64, 1, 1634 - GGRAPH_SAMPLE_FLOAT, NULL, NULL); 1635 - } 1636 - } 1637 - if (!img) 1638 - { 1639 - fclose (out); 1640 - unlink (path); 1641 - return GGRAPH_INSUFFICIENT_MEMORY; 1642 - } 1643 - 1644 - img->upper_left_x = upper_left_x; 1645 - img->upper_left_y = upper_left_y; 1646 - img->pixel_x_size = pixel_x_size; 1647 - img->pixel_y_size = pixel_y_size; 1648 - img->no_data_value = no_data_value; 1649 - ret = gg_image_prepare_to_ascii_grid_by_strip (img, out); 1650 - if (ret != GGRAPH_OK) 1651 - { 1652 - gg_strip_image_destroy (img); 1653 - return ret; 1654 - } 1655 - 1656 - *ptr = img; 1657 - return GGRAPH_OK; 1658 -} 1659 - 1660 -GGRAPH_DECLARE int 1661 -gGraphImageToPngMemBuf (const void *ptr, void **mem_buf, int *mem_buf_size, 1662 - int compression_level, int quantization_factor, 1663 - int interlaced, int is_transparent) 1664 -{ 1665 -/* exporting an image into a PNG compressed memory buffer */ 1666 - gGraphImagePtr img = (gGraphImagePtr) ptr; 1667 - void *buf = NULL; 1668 - int size; 1669 - int ret; 1670 - 1671 - *mem_buf = NULL; 1672 - *mem_buf_size = 0; 1673 - if (img == NULL) 1674 - return GGRAPH_INVALID_IMAGE; 1675 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 1676 - return GGRAPH_INVALID_IMAGE; 1677 - 1678 -/* compressing as PNG */ 1679 - ret = 1680 - gg_image_to_png (img, &buf, &size, NULL, GG_TARGET_IS_MEMORY, 1681 - compression_level, quantization_factor, interlaced, 1682 - is_transparent); 1683 - if (ret != GGRAPH_OK) 1684 - return ret; 1685 - 1686 -/* exporting the memory buffer */ 1687 - *mem_buf = buf; 1688 - *mem_buf_size = size; 1689 - return GGRAPH_OK; 1690 -} 1691 - 1692 -GGRAPH_DECLARE int 1693 -gGraphImageToGifFile (const void *ptr, const char *path) 1694 -{ 1695 -/* exporting an image into a GIF compressed file */ 1696 - gGraphImagePtr img = (gGraphImagePtr) ptr; 1697 - int ret; 1698 - FILE *out = NULL; 1699 - 1700 - if (!img) 1701 - return GGRAPH_INVALID_IMAGE; 1702 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 1703 - return GGRAPH_INVALID_IMAGE; 1704 - 1705 -/* opening the output image file */ 1706 - out = fopen (path, "wb"); 1707 - if (out == NULL) 1708 - return GGRAPH_FILE_OPEN_ERROR; 1709 -/* compressing as GIF */ 1710 - ret = gg_image_to_gif (img, NULL, NULL, out, GG_TARGET_IS_FILE, 0); 1711 - fclose (out); 1712 - if (ret != GGRAPH_OK) 1713 - { 1714 - /* some unexpected error occurred */ 1715 - unlink (path); 1716 - return ret; 1717 - } 1718 - 1719 - return GGRAPH_OK; 1720 -} 1721 - 1722 -GGRAPH_DECLARE int 1723 -gGraphImageToGifMemBuf (const void *ptr, void **mem_buf, int *mem_buf_size, 1724 - int is_transparent) 1725 -{ 1726 -/* exporting an image into a GIF compressed memory buffer */ 1727 - gGraphImagePtr img = (gGraphImagePtr) ptr; 1728 - void *buf = NULL; 1729 - int size; 1730 - int ret; 1731 - 1732 - *mem_buf = NULL; 1733 - *mem_buf_size = 0; 1734 - if (img == NULL) 1735 - return GGRAPH_INVALID_IMAGE; 1736 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 1737 - return GGRAPH_INVALID_IMAGE; 1738 - 1739 -/* compressing as GIF */ 1740 - ret = 1741 - gg_image_to_gif (img, &buf, &size, NULL, GG_TARGET_IS_MEMORY, 1742 - is_transparent); 1743 - if (ret != GGRAPH_OK) 1744 - return ret; 1745 - 1746 -/* exporting the memory buffer */ 1747 - *mem_buf = buf; 1748 - *mem_buf_size = size; 1749 - return GGRAPH_OK; 1750 -} 1751 - 1752 -GGRAPH_DECLARE void 1753 -gGraphDestroyImage (const void *ptr) 1754 -{ 1755 -/* destroyng an image object */ 1756 - gGraphImagePtr img = (gGraphImagePtr) ptr; 1757 - gGraphStripImagePtr strip_img = (gGraphStripImagePtr) ptr; 1758 - 1759 - if (img == NULL) 1760 - return; 1761 - if (img->signature == GG_IMAGE_MAGIC_SIGNATURE) 1762 - { 1763 - gg_image_destroy (img); 1764 - return; 1765 - } 1766 - if (strip_img->signature == GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1767 - { 1768 - gg_strip_image_destroy (strip_img); 1769 - return; 1770 - } 1771 -} 1772 - 1773 -GGRAPH_DECLARE int 1774 -gGraphStripImageClonePalette (const void *ptr, int *color_model, 1775 - int *num_palette, unsigned char *red, 1776 - unsigned char *green, unsigned char *blue) 1777 -{ 1778 -/* exporting the palette and color-space infos from a Strip Image */ 1779 - int i; 1780 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 1781 - 1782 - if (img == NULL) 1783 - return GGRAPH_INVALID_IMAGE; 1784 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1785 - return GGRAPH_INVALID_IMAGE; 1786 - 1787 - switch (img->pixel_format) 1788 - { 1789 - case GG_PIXEL_GRID: 1790 - *color_model = GGRAPH_COLORSPACE_GRID; 1791 - *num_palette = 0; 1792 - break; 1793 - case GG_PIXEL_PALETTE: 1794 - *color_model = GGRAPH_COLORSPACE_PALETTE; 1795 - for (i = 0; i < img->max_palette; i++) 1796 - { 1797 - red[i] = img->palette_red[i]; 1798 - green[i] = img->palette_green[i]; 1799 - blue[i] = img->palette_blue[i]; 1800 - } 1801 - *num_palette = img->max_palette; 1802 - break; 1803 - case GG_PIXEL_GRAYSCALE: 1804 - *color_model = GGRAPH_COLORSPACE_GRAYSCALE; 1805 - *num_palette = 0; 1806 - break; 1807 - case GG_PIXEL_RGBA: 1808 - case GG_PIXEL_ARGB: 1809 - case GG_PIXEL_BGRA: 1810 - *color_model = GGRAPH_COLORSPACE_TRUECOLOR_ALPHA; 1811 - *num_palette = 0; 1812 - break; 1813 - default: 1814 - *color_model = GGRAPH_COLORSPACE_TRUECOLOR; 1815 - *num_palette = 0; 1816 - break; 1817 - }; 1818 - return GGRAPH_OK; 1819 -} 1820 - 1821 -GGRAPH_DECLARE int 1822 -gGraphStripImageAllocPixels (const void *ptr, int rows_per_block) 1823 -{ 1824 -/* allocating the pixels buffer */ 1825 - unsigned char *pixels; 1826 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 1827 - 1828 - if (img == NULL) 1829 - return GGRAPH_INVALID_IMAGE; 1830 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1831 - return GGRAPH_INVALID_IMAGE; 1832 - 1833 -/* allocating the pixel buffer */ 1834 - pixels = malloc (img->scanline_width * rows_per_block); 1835 - if (!pixels) 1836 - return GGRAPH_INSUFFICIENT_MEMORY; 1837 -/* freeing an already allocated buffer (if any) */ 1838 - if (img->pixels) 1839 - free (img->pixels); 1840 - img->pixels = pixels; 1841 - img->rows_per_block = rows_per_block; 1842 - 1843 - return GGRAPH_OK; 1844 -} 1845 - 1846 -GGRAPH_DECLARE int 1847 -gGraphStripImageEOF (const void *ptr) 1848 -{ 1849 -/* checking if there is a StripImage EOF condition */ 1850 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 1851 - 1852 - if (img == NULL) 1853 - return GGRAPH_INVALID_IMAGE; 1854 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1855 - return GGRAPH_INVALID_IMAGE; 1856 - 1857 - if (img->next_row >= img->height) 1858 - return GGRAPH_OK; 1859 - return GGRAPH_ERROR; 1860 -} 1861 - 1862 -static int 1863 -copy_pixels_float (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out) 1864 -{ 1865 -/* copying the pixels buffer between two images [FLOAT] */ 1866 - int x; 1867 - int y; 1868 - for (y = 0; y < img_in->current_available_rows; y++) 1869 - { 1870 - float *p_in = (float *) (img_in->pixels); 1871 - float *p_out = (float *) (img_out->pixels); 1872 - p_in += y * img_in->width; 1873 - p_out += y * img_out->width; 1874 - for (x = 0; x < img_in->width; x++) 1875 - *p_out++ = *p_in++; 1876 - } 1877 - img_out->current_available_rows = img_in->current_available_rows; 1878 - return GGRAPH_OK; 1879 -} 1880 - 1881 -static int 1882 -copy_pixels_double (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out) 1883 -{ 1884 -/* copying the pixels buffer between two images [DOUBLE] */ 1885 - int x; 1886 - int y; 1887 - for (y = 0; y < img_in->current_available_rows; y++) 1888 - { 1889 - double *p_in = (double *) (img_in->pixels); 1890 - double *p_out = (double *) (img_out->pixels); 1891 - p_in += y * img_in->width; 1892 - p_out += y * img_out->width; 1893 - for (x = 0; x < img_in->width; x++) 1894 - *p_out++ = *p_in++; 1895 - } 1896 - img_out->current_available_rows = img_in->current_available_rows; 1897 - return GGRAPH_OK; 1898 -} 1899 - 1900 -static int 1901 -copy_pixels_uint8 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out) 1902 -{ 1903 -/* copying the pixels buffer between two images [UINT-8] */ 1904 - int x; 1905 - int y; 1906 - for (y = 0; y < img_in->current_available_rows; y++) 1907 - { 1908 - unsigned char *p_in = (unsigned char *) (img_in->pixels); 1909 - unsigned char *p_out = (unsigned char *) (img_out->pixels); 1910 - p_in += y * img_in->width; 1911 - p_out += y * img_out->width; 1912 - for (x = 0; x < img_in->width; x++) 1913 - *p_out++ = *p_in++; 1914 - } 1915 - img_out->current_available_rows = img_in->current_available_rows; 1916 - return GGRAPH_OK; 1917 -} 1918 - 1919 -static int 1920 -copy_pixels_int8 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out) 1921 -{ 1922 -/* copying the pixels buffer between two images [INT-8] */ 1923 - int x; 1924 - int y; 1925 - for (y = 0; y < img_in->current_available_rows; y++) 1926 - { 1927 - char *p_in = (char *) (img_in->pixels); 1928 - char *p_out = (char *) (img_out->pixels); 1929 - p_in += y * img_in->width; 1930 - p_out += y * img_out->width; 1931 - for (x = 0; x < img_in->width; x++) 1932 - *p_out++ = *p_in++; 1933 - } 1934 - img_out->current_available_rows = img_in->current_available_rows; 1935 - return GGRAPH_OK; 1936 -} 1937 - 1938 -static int 1939 -copy_pixels_uint16 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out) 1940 -{ 1941 -/* copying the pixels buffer between two images [UINT-16] */ 1942 - int x; 1943 - int y; 1944 - for (y = 0; y < img_in->current_available_rows; y++) 1945 - { 1946 - unsigned short *p_in = (unsigned short *) (img_in->pixels); 1947 - unsigned short *p_out = (unsigned short *) (img_out->pixels); 1948 - p_in += y * img_in->width; 1949 - p_out += y * img_out->width; 1950 - for (x = 0; x < img_in->width; x++) 1951 - *p_out++ = *p_in++; 1952 - } 1953 - img_out->current_available_rows = img_in->current_available_rows; 1954 - return GGRAPH_OK; 1955 -} 1956 - 1957 -static int 1958 -copy_pixels_int16 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out) 1959 -{ 1960 -/* copying the pixels buffer between two images [INT-16] */ 1961 - int x; 1962 - int y; 1963 - for (y = 0; y < img_in->current_available_rows; y++) 1964 - { 1965 - short *p_in = (short *) (img_in->pixels); 1966 - short *p_out = (short *) (img_out->pixels); 1967 - p_in += y * img_in->width; 1968 - p_out += y * img_out->width; 1969 - for (x = 0; x < img_in->width; x++) 1970 - *p_out++ = *p_in++; 1971 - } 1972 - img_out->current_available_rows = img_in->current_available_rows; 1973 - return GGRAPH_OK; 1974 -} 1975 - 1976 -static int 1977 -copy_pixels_uint32 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out) 1978 -{ 1979 -/* copying the pixels buffer between two images [UINT-32] */ 1980 - int x; 1981 - int y; 1982 - for (y = 0; y < img_in->current_available_rows; y++) 1983 - { 1984 - unsigned int *p_in = (unsigned int *) (img_in->pixels); 1985 - unsigned int *p_out = (unsigned int *) (img_out->pixels); 1986 - p_in += y * img_in->width; 1987 - p_out += y * img_out->width; 1988 - for (x = 0; x < img_in->width; x++) 1989 - *p_out++ = *p_in++; 1990 - } 1991 - img_out->current_available_rows = img_in->current_available_rows; 1992 - return GGRAPH_OK; 1993 -} 1994 - 1995 -static int 1996 -copy_pixels_int32 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out) 1997 -{ 1998 -/* copying the pixels buffer between two images [INT-32] */ 1999 - int x; 2000 - int y; 2001 - for (y = 0; y < img_in->current_available_rows; y++) 2002 - { 2003 - int *p_in = (int *) (img_in->pixels); 2004 - int *p_out = (int *) (img_out->pixels); 2005 - p_in += y * img_in->width; 2006 - p_out += y * img_out->width; 2007 - for (x = 0; x < img_in->width; x++) 2008 - *p_out++ = *p_in++; 2009 - } 2010 - img_out->current_available_rows = img_in->current_available_rows; 2011 - return GGRAPH_OK; 2012 -} 2013 - 2014 -GGRAPH_DECLARE int 2015 -gGraphStripImageCopyPixels (const void *in_ptr, const void *out_ptr) 2016 -{ 2017 -/* copying the pixels buffer between two images */ 2018 - int x; 2019 - int y; 2020 - gGraphStripImagePtr img_in = (gGraphStripImagePtr) in_ptr; 2021 - gGraphStripImagePtr img_out = (gGraphStripImagePtr) out_ptr; 2022 - 2023 - if (img_in == NULL || img_out == NULL) 2024 - return GGRAPH_INVALID_IMAGE; 2025 - if (img_in->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2026 - return GGRAPH_INVALID_IMAGE; 2027 - if (img_out->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2028 - return GGRAPH_INVALID_IMAGE; 2029 - 2030 -/* checking if the strip buffers does actually have the same size */ 2031 - if (img_in->width == img_out->width 2032 - && img_in->rows_per_block == img_out->rows_per_block) 2033 - ; 2034 - else 2035 - return GGRAPH_ERROR; 2036 - if (img_in->pixel_format == GG_PIXEL_GRID) 2037 - { 2038 - /* handling GRID data */ 2039 - if (img_in->sample_format == GGRAPH_SAMPLE_FLOAT) 2040 - { 2041 - if (img_in->bits_per_sample == 32) 2042 - return copy_pixels_float (img_in, img_out); 2043 - else 2044 - 2045 - return copy_pixels_double (img_in, img_out); 2046 - } 2047 - else 2048 - { 2049 - /* UINT or INT */ 2050 - if (img_in->bits_per_sample == 8) 2051 - { 2052 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 2053 - return copy_pixels_uint8 (img_in, img_out); 2054 - else 2055 - return copy_pixels_int8 (img_in, img_out); 2056 - } 2057 - else if (img_in->bits_per_sample == 16) 2058 - { 2059 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 2060 - return copy_pixels_uint16 (img_in, img_out); 2061 - else 2062 - return copy_pixels_int16 (img_in, img_out); 2063 - } 2064 - else 2065 - { 2066 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 2067 - return copy_pixels_uint32 (img_in, img_out); 2068 - else 2069 - return copy_pixels_int32 (img_in, img_out); 2070 - } 2071 - } 2072 - } 2073 - for (y = 0; y < img_in->current_available_rows; y++) 2074 - { 2075 - unsigned char *p_in = img_in->pixels + (y * img_in->scanline_width); 2076 - unsigned char *p_out = 2077 - img_out->pixels + (y * img_out->scanline_width); 2078 - for (x = 0; x < img_in->width; x++) 2079 - { 2080 - if (img_in->pixel_format == GG_PIXEL_GRAYSCALE 2081 - && img_out->pixel_format == GG_PIXEL_GRAYSCALE) 2082 - { 2083 - *p_out++ = *p_in++; 2084 - } 2085 - else if (img_in->pixel_format == GG_PIXEL_PALETTE 2086 - && img_out->pixel_format == GG_PIXEL_PALETTE) 2087 - { 2088 - *p_out++ = *p_in++; 2089 - } 2090 - else 2091 - { 2092 - unsigned char red; 2093 - unsigned char green; 2094 - unsigned char blue; 2095 - unsigned char alpha; 2096 - if (img_in->pixel_format == GG_PIXEL_RGB) 2097 - { 2098 - red = *p_in++; 2099 - green = *p_in++; 2100 - blue = *p_in++; 2101 - alpha = 255; 2102 - } 2103 - else if (img_in->pixel_format == GG_PIXEL_RGBA) 2104 - { 2105 - red = *p_in++; 2106 - green = *p_in++; 2107 - blue = *p_in++; 2108 - alpha = *p_in++; 2109 - } 2110 - else if (img_in->pixel_format == GG_PIXEL_ARGB) 2111 - { 2112 - alpha = *p_in++; 2113 - red = *p_in++; 2114 - green = *p_in++; 2115 - blue = *p_in++; 2116 - } 2117 - else if (img_in->pixel_format == GG_PIXEL_BGR) 2118 - { 2119 - blue = *p_in++; 2120 - green = *p_in++; 2121 - red = *p_in++; 2122 - alpha = 255; 2123 - } 2124 - else if (img_in->pixel_format == GG_PIXEL_BGRA) 2125 - { 2126 - blue = *p_in++; 2127 - green = *p_in++; 2128 - red = *p_in++; 2129 - alpha = *p_in++; 2130 - } 2131 - else if (img_in->pixel_format == GG_PIXEL_GRAYSCALE) 2132 - { 2133 - red = *p_in++; 2134 - green = red; 2135 - blue = red; 2136 - alpha = 255; 2137 - } 2138 - else if (img_in->pixel_format == GG_PIXEL_PALETTE) 2139 - { 2140 - int index = *p_in++; 2141 - red = img_in->palette_red[index]; 2142 - green = img_in->palette_green[index]; 2143 - blue = img_in->palette_blue[index]; 2144 - alpha = 255; 2145 - } 2146 - if (img_out->pixel_format == GG_PIXEL_RGB) 2147 - { 2148 - *p_out++ = red; 2149 - *p_out++ = green; 2150 - *p_out++ = blue; 2151 - } 2152 - else if (img_out->pixel_format == GG_PIXEL_RGBA) 2153 - { 2154 - *p_out++ = red; 2155 - *p_out++ = green; 2156 - *p_out++ = blue; 2157 - *p_out++ = alpha; 2158 - } 2159 - else if (img_out->pixel_format == GG_PIXEL_ARGB) 2160 - { 2161 - *p_out++ = alpha; 2162 - *p_out++ = red; 2163 - *p_out++ = green; 2164 - *p_out++ = blue; 2165 - } 2166 - else if (img_out->pixel_format == GG_PIXEL_BGR) 2167 - { 2168 - *p_out++ = blue; 2169 - *p_out++ = green; 2170 - *p_out++ = red; 2171 - } 2172 - else if (img_out->pixel_format == GG_PIXEL_BGRA) 2173 - { 2174 - *p_out++ = blue; 2175 - *p_out++ = green; 2176 - *p_out++ = red; 2177 - *p_out++ = alpha; 2178 - } 2179 - } 2180 - } 2181 - img_out->current_available_rows = img_in->current_available_rows; 2182 - } 2183 - return GGRAPH_OK; 2184 -} 2185 - 2186 -static int 2187 -subset_pixels_float (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out, 2188 - int start_from, int row) 2189 -{ 2190 -/* copying the pixels buffer between two images [SubSet, FLOAT] */ 2191 - int x; 2192 - float *p_in = (float *) (img_in->pixels); 2193 - float *p_out = (float *) (img_out->pixels); 2194 - p_in += start_from; 2195 - p_out += row * img_out->width; 2196 - for (x = 0; x < img_out->width; x++) 2197 - *p_out++ = *p_in++; 2198 - img_out->current_available_rows = row + 1; 2199 - return GGRAPH_OK; 2200 -} 2201 - 2202 -static int 2203 -subset_pixels_double (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out, 2204 - int start_from, int row) 2205 -{ 2206 -/* copying the pixels buffer between two images [SubSet, DOUBLE] */ 2207 - int x; 2208 - double *p_in = (double *) (img_in->pixels); 2209 - double *p_out = (double *) (img_out->pixels); 2210 - p_in += start_from; 2211 - p_out += row * img_out->width; 2212 - for (x = 0; x < img_out->width; x++) 2213 - *p_out++ = *p_in++; 2214 - img_out->current_available_rows = row + 1; 2215 - return GGRAPH_OK; 2216 -} 2217 - 2218 -static int 2219 -subset_pixels_uint8 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out, 2220 - int start_from, int row) 2221 -{ 2222 -/* copying the pixels buffer between two images [SubSet, UINT-8] */ 2223 - int x; 2224 - unsigned char *p_in = (unsigned char *) (img_in->pixels); 2225 - unsigned char *p_out = (unsigned char *) (img_out->pixels); 2226 - p_in += start_from; 2227 - p_out += row * img_out->width; 2228 - for (x = 0; x < img_out->width; x++) 2229 - *p_out++ = *p_in++; 2230 - img_out->current_available_rows = row + 1; 2231 - return GGRAPH_OK; 2232 -} 2233 - 2234 -static int 2235 -subset_pixels_int8 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out, 2236 - int start_from, int row) 2237 -{ 2238 -/* copying the pixels buffer between two images [SubSet, INT-8] */ 2239 - int x; 2240 - char *p_in = (char *) (img_in->pixels); 2241 - char *p_out = (char *) (img_out->pixels); 2242 - p_in += start_from; 2243 - p_out += row * img_out->width; 2244 - for (x = 0; x < img_out->width; x++) 2245 - *p_out++ = *p_in++; 2246 - img_out->current_available_rows = row + 1; 2247 - return GGRAPH_OK; 2248 -} 2249 - 2250 -static int 2251 -subset_pixels_uint16 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out, 2252 - int start_from, int row) 2253 -{ 2254 -/* copying the pixels buffer between two images [SubSet, UINT-16] */ 2255 - int x; 2256 - unsigned short *p_in = (unsigned short *) (img_in->pixels); 2257 - unsigned short *p_out = (unsigned short *) (img_out->pixels); 2258 - p_in += start_from; 2259 - p_out += row * img_out->width; 2260 - for (x = 0; x < img_out->width; x++) 2261 - *p_out++ = *p_in++; 2262 - img_out->current_available_rows = row + 1; 2263 - return GGRAPH_OK; 2264 -} 2265 - 2266 -static int 2267 -subset_pixels_int16 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out, 2268 - int start_from, int row) 2269 -{ 2270 -/* copying the pixels buffer between two images [SubSet, INT-16] */ 2271 - int x; 2272 - short *p_in = (short *) (img_in->pixels); 2273 - short *p_out = (short *) (img_out->pixels); 2274 - p_in += start_from; 2275 - p_out += row * img_out->width; 2276 - for (x = 0; x < img_out->width; x++) 2277 - *p_out++ = *p_in++; 2278 - img_out->current_available_rows = row + 1; 2279 - return GGRAPH_OK; 2280 -} 2281 - 2282 -static int 2283 -subset_pixels_uint32 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out, 2284 - int start_from, int row) 2285 -{ 2286 -/* copying the pixels buffer between two images [SubSet, UINT-32] */ 2287 - int x; 2288 - unsigned int *p_in = (unsigned int *) (img_in->pixels); 2289 - unsigned int *p_out = (unsigned int *) (img_out->pixels); 2290 - p_in += start_from; 2291 - p_out += row * img_out->width; 2292 - for (x = 0; x < img_out->width; x++) 2293 - *p_out++ = *p_in++; 2294 - img_out->current_available_rows = row + 1; 2295 - return GGRAPH_OK; 2296 -} 2297 - 2298 -static int 2299 -subset_pixels_int32 (gGraphStripImagePtr img_in, gGraphStripImagePtr img_out, 2300 - int start_from, int row) 2301 -{ 2302 -/* copying the pixels buffer between two images [SubSet, INT-32] */ 2303 - int x; 2304 - int *p_in = (int *) (img_in->pixels); 2305 - int *p_out = (int *) (img_out->pixels); 2306 - p_in += start_from; 2307 - p_out += row * img_out->width; 2308 - for (x = 0; x < img_out->width; x++) 2309 - *p_out++ = *p_in++; 2310 - img_out->current_available_rows = row + 1; 2311 - return GGRAPH_OK; 2312 -} 2313 - 2314 -GGRAPH_DECLARE int 2315 -gGraphStripImageSubSetPixels (const void *in_ptr, const void *out_ptr, 2316 - int start_from, int row) 2317 -{ 2318 -/* copying the pixels buffer between two images [SubSet] */ 2319 - int x; 2320 - unsigned char *p_in; 2321 - unsigned char *p_out; 2322 - gGraphStripImagePtr img_in = (gGraphStripImagePtr) in_ptr; 2323 - gGraphStripImagePtr img_out = (gGraphStripImagePtr) out_ptr; 2324 - 2325 - if (img_in == NULL || img_out == NULL) 2326 - return GGRAPH_INVALID_IMAGE; 2327 - if (img_out->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2328 - return GGRAPH_INVALID_IMAGE; 2329 - if (img_out->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2330 - return GGRAPH_INVALID_IMAGE; 2331 - 2332 - if (img_in->pixel_format == GG_PIXEL_GRID) 2333 - { 2334 - /* handling GRID data */ 2335 - if (img_in->sample_format == GGRAPH_SAMPLE_FLOAT) 2336 - { 2337 - if (img_in->bits_per_sample == 32) 2338 - return subset_pixels_float (img_in, img_out, start_from, 2339 - row); 2340 - else 2341 - 2342 - return subset_pixels_double (img_in, img_out, start_from, 2343 - row); 2344 - } 2345 - else 2346 - { 2347 - /* UINT or INT */ 2348 - if (img_in->bits_per_sample == 8) 2349 - { 2350 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 2351 - return subset_pixels_uint8 (img_in, img_out, 2352 - start_from, row); 2353 - else 2354 - return subset_pixels_int8 (img_in, img_out, 2355 - start_from, row); 2356 - } 2357 - else if (img_in->bits_per_sample == 16) 2358 - { 2359 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 2360 - return subset_pixels_uint16 (img_in, img_out, 2361 - start_from, row); 2362 - else 2363 - return subset_pixels_int16 (img_in, img_out, 2364 - start_from, row); 2365 - } 2366 - else 2367 - { 2368 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 2369 - return subset_pixels_uint32 (img_in, img_out, 2370 - start_from, row); 2371 - else 2372 - return subset_pixels_int32 (img_in, img_out, 2373 - start_from, row); 2374 - } 2375 - } 2376 - } 2377 - 2378 - p_in = img_in->pixels + (start_from * img_in->pixel_size); 2379 - p_out = img_out->pixels + (row * img_out->scanline_width); 2380 - for (x = 0; x < img_out->width; x++) 2381 - { 2382 - if (img_in->pixel_format == GG_PIXEL_GRAYSCALE 2383 - && img_out->pixel_format == GG_PIXEL_GRAYSCALE) 2384 - { 2385 - *p_out++ = *p_in++; 2386 - } 2387 - else if (img_in->pixel_format == GG_PIXEL_PALETTE 2388 - && img_out->pixel_format == GG_PIXEL_PALETTE) 2389 - { 2390 - *p_out++ = *p_in++; 2391 - } 2392 - else 2393 - { 2394 - unsigned char red; 2395 - unsigned char green; 2396 - unsigned char blue; 2397 - unsigned char alpha; 2398 - if (img_in->pixel_format == GG_PIXEL_RGB) 2399 - { 2400 - red = *p_in++; 2401 - green = *p_in++; 2402 - blue = *p_in++; 2403 - alpha = 255; 2404 - } 2405 - else if (img_in->pixel_format == GG_PIXEL_RGBA) 2406 - { 2407 - red = *p_in++; 2408 - green = *p_in++; 2409 - blue = *p_in++; 2410 - alpha = *p_in++; 2411 - } 2412 - else if (img_in->pixel_format == GG_PIXEL_ARGB) 2413 - { 2414 - alpha = *p_in++; 2415 - red = *p_in++; 2416 - green = *p_in++; 2417 - blue = *p_in++; 2418 - } 2419 - else if (img_in->pixel_format == GG_PIXEL_BGR) 2420 - { 2421 - blue = *p_in++; 2422 - green = *p_in++; 2423 - red = *p_in++; 2424 - alpha = 255; 2425 - } 2426 - else if (img_in->pixel_format == GG_PIXEL_BGRA) 2427 - { 2428 - blue = *p_in++; 2429 - green = *p_in++; 2430 - red = *p_in++; 2431 - alpha = *p_in++; 2432 - } 2433 - else if (img_in->pixel_format == GG_PIXEL_GRAYSCALE) 2434 - { 2435 - red = *p_in++; 2436 - green = red; 2437 - blue = red; 2438 - alpha = 255; 2439 - } 2440 - else if (img_in->pixel_format == GG_PIXEL_PALETTE) 2441 - { 2442 - int index = *p_in++; 2443 - red = img_in->palette_red[index]; 2444 - green = img_in->palette_green[index]; 2445 - blue = img_in->palette_blue[index]; 2446 - alpha = 255; 2447 - } 2448 - if (img_out->pixel_format == GG_PIXEL_RGB) 2449 - { 2450 - *p_out++ = red; 2451 - *p_out++ = green; 2452 - *p_out++ = blue; 2453 - } 2454 - else if (img_out->pixel_format == GG_PIXEL_RGBA) 2455 - { 2456 - *p_out++ = red; 2457 - *p_out++ = green; 2458 - *p_out++ = blue; 2459 - *p_out++ = alpha; 2460 - } 2461 - else if (img_out->pixel_format == GG_PIXEL_ARGB) 2462 - { 2463 - *p_out++ = alpha; 2464 - *p_out++ = red; 2465 - *p_out++ = green; 2466 - *p_out++ = blue; 2467 - } 2468 - else if (img_out->pixel_format == GG_PIXEL_BGR) 2469 - { 2470 - *p_out++ = blue; 2471 - *p_out++ = green; 2472 - *p_out++ = red; 2473 - } 2474 - else if (img_out->pixel_format == GG_PIXEL_BGRA) 2475 - { 2476 - *p_out++ = blue; 2477 - *p_out++ = green; 2478 - *p_out++ = red; 2479 - *p_out++ = alpha; 2480 - } 2481 - } 2482 - } 2483 - img_out->current_available_rows = row + 1; 2484 - return GGRAPH_OK; 2485 -} 2486 - 2487 -GGRAPH_DECLARE int 2488 -gGraphReadNextStrip (const void *ptr, int *progress) 2489 -{ 2490 -/* reading the next strip from a strip image */ 2491 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2492 - 2493 - if (img == NULL) 2494 - return GGRAPH_INVALID_IMAGE; 2495 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2496 - return GGRAPH_INVALID_IMAGE; 2497 - 2498 - if (img->next_row < img->height) 2499 - { 2500 - if (img->codec_id == GGRAPH_IMAGE_PNG) 2501 - return gg_image_strip_read_from_png (img, progress); 2502 - if (img->codec_id == GGRAPH_IMAGE_JPEG) 2503 - return gg_image_strip_read_from_jpeg (img, progress); 2504 - if (img->codec_id == GGRAPH_IMAGE_TIFF 2505 - || img->codec_id == GGRAPH_IMAGE_GEOTIFF) 2506 - return gg_image_strip_read_from_tiff (img, progress); 2507 - if (img->codec_id == GGRAPH_IMAGE_HGT) 2508 - return gg_image_strip_read_from_hgt (img, progress); 2509 - if (img->codec_id == GGRAPH_IMAGE_BIN_HDR) 2510 - return gg_image_strip_read_from_bin_grid (img, progress); 2511 - if (img->codec_id == GGRAPH_IMAGE_FLT_HDR) 2512 - return gg_image_strip_read_from_bin_grid (img, progress); 2513 - if (img->codec_id == GGRAPH_IMAGE_DEM_HDR) 2514 - return gg_image_strip_read_from_dem_grid (img, progress); 2515 - if (img->codec_id == GGRAPH_IMAGE_ASCII_GRID) 2516 - return gg_image_strip_read_from_ascii_grid (img, progress); 2517 - } 2518 - 2519 - return GGRAPH_INVALID_IMAGE; 2520 -} 2521 - 2522 -GGRAPH_DECLARE int 2523 -gGraphWriteNextStrip (const void *ptr, int *progress) 2524 -{ 2525 -/* writing the next strip into a strip image */ 2526 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2527 - 2528 - if (img == NULL) 2529 - return GGRAPH_INVALID_IMAGE; 2530 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2531 - return GGRAPH_INVALID_IMAGE; 2532 - 2533 - if (img->next_row < img->height) 2534 - { 2535 - if (img->codec_id == GGRAPH_IMAGE_PNG) 2536 - return gg_image_write_to_png_by_strip (img, progress); 2537 - if (img->codec_id == GGRAPH_IMAGE_JPEG) 2538 - return gg_image_write_to_jpeg_by_strip (img, progress); 2539 - if (img->codec_id == GGRAPH_IMAGE_TIFF 2540 - || img->codec_id == GGRAPH_IMAGE_GEOTIFF) 2541 - return gg_image_write_to_tiff_by_strip (img, progress); 2542 - if (img->codec_id == GGRAPH_IMAGE_BIN_HDR) 2543 - return gg_image_write_to_bin_hdr_by_strip (img, progress); 2544 - if (img->codec_id == GGRAPH_IMAGE_FLT_HDR) 2545 - return gg_image_write_to_flt_hdr_by_strip (img, progress); 2546 - if (img->codec_id == GGRAPH_IMAGE_ASCII_GRID) 2547 - return gg_image_write_to_ascii_grid_by_strip (img, progress); 2548 - } 2549 - 2550 - return GGRAPH_INVALID_IMAGE; 2551 -} 2552 - 2553 -GGRAPH_DECLARE int 2554 -gGraphStripImageGetNextRow (const void *ptr, int *next_row) 2555 -{ 2556 -/* retrieving the current Next Row */ 2557 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2558 - 2559 - *next_row = -1; 2560 - if (img == NULL) 2561 - return GGRAPH_INVALID_IMAGE; 2562 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2563 - return GGRAPH_INVALID_IMAGE; 2564 - 2565 - *next_row = img->next_row; 2566 - return GGRAPH_OK; 2567 -} 2568 - 2569 -GGRAPH_DECLARE int 2570 -gGraphStripIsFull (const void *ptr) 2571 -{ 2572 -/* checks it the strip is full (ready to be written) */ 2573 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2574 - 2575 - if (img == NULL) 2576 - return GGRAPH_INVALID_IMAGE; 2577 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2578 - return GGRAPH_INVALID_IMAGE; 2579 - 2580 - if (img->current_available_rows == img->rows_per_block) 2581 - return GGRAPH_OK; 2582 - if (img->next_row + img->current_available_rows == img->height) 2583 - return GGRAPH_OK; 2584 - return GGRAPH_ERROR; 2585 -} 2586 - 2587 -GGRAPH_DECLARE int 2588 -gGraphStripImageRewind (const void *ptr) 2589 -{ 2590 -/* rewinds the image (to first scanline) */ 2591 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2592 - 2593 - if (img == NULL) 2594 - return GGRAPH_INVALID_IMAGE; 2595 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2596 - return GGRAPH_INVALID_IMAGE; 2597 - 2598 - img->next_row = 0; 2599 - return GGRAPH_OK; 2600 -} 2601 - 2602 -GGRAPH_DECLARE int 2603 -gGraphStripImageGetCurrentRows (const void *ptr, int *rows) 2604 -{ 2605 -/* return how many rows are currently into the buffer */ 2606 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2607 - 2608 - *rows = 0; 2609 - if (img == NULL) 2610 - return GGRAPH_INVALID_IMAGE; 2611 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2612 - return GGRAPH_INVALID_IMAGE; 2613 - 2614 - *rows = img->current_available_rows; 2615 - return GGRAPH_OK; 2616 -} 2617 - 2618 -GGRAPH_DECLARE int 2619 -gGraphStripImageGetPixelRGB (const void *ptr, int col, int row, 2620 - unsigned char *red, unsigned char *green, 2621 - unsigned char *blue) 2622 -{ 2623 -/* retrieving an RGB pixel by col and row */ 2624 - unsigned char *p_in; 2625 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2626 - 2627 - *red = 0; 2628 - *green = 0; 2629 - *blue = 0; 2630 - if (img == NULL) 2631 - return GGRAPH_INVALID_IMAGE; 2632 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2633 - return GGRAPH_INVALID_IMAGE; 2634 - 2635 - if (col < 0 || col >= img->width) 2636 - return GGRAPH_ERROR; 2637 - if (row < 0 || row >= img->current_available_rows) 2638 - return GGRAPH_ERROR; 2639 - 2640 - p_in = img->pixels + (row * img->scanline_width) + (col * img->pixel_size); 2641 - if (img->pixel_format == GG_PIXEL_RGB) 2642 - { 2643 - *red = *p_in++; 2644 - *green = *p_in++; 2645 - *blue = *p_in++; 2646 - } 2647 - else if (img->pixel_format == GG_PIXEL_RGBA) 2648 - { 2649 - *red = *p_in++; 2650 - *green = *p_in++; 2651 - *blue = *p_in++; 2652 - p_in++; /* discarding Alpha */ 2653 - } 2654 - else if (img->pixel_format == GG_PIXEL_ARGB) 2655 - { 2656 - p_in++; /* discarding Alpha */ 2657 - *red = *p_in++; 2658 - *green = *p_in++; 2659 - *blue = *p_in++; 2660 - } 2661 - else if (img->pixel_format == GG_PIXEL_BGR) 2662 - { 2663 - *blue = *p_in++; 2664 - *green = *p_in++; 2665 - *red = *p_in++; 2666 - } 2667 - else if (img->pixel_format == GG_PIXEL_BGRA) 2668 - { 2669 - *blue = *p_in++; 2670 - *green = *p_in++; 2671 - *red = *p_in++; 2672 - p_in++; /* discarding Alpha */ 2673 - } 2674 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2675 - { 2676 - *red = *p_in++; 2677 - *green = *red; 2678 - *blue = *red; 2679 - } 2680 - else if (img->pixel_format == GG_PIXEL_PALETTE) 2681 - { 2682 - int index = *p_in++; 2683 - *red = img->palette_red[index]; 2684 - *green = img->palette_green[index]; 2685 - *blue = img->palette_blue[index]; 2686 - } 2687 - 2688 - return GGRAPH_OK; 2689 -} 2690 - 2691 -static unsigned char 2692 -match_palette2 (const gGraphStripImagePtr img, unsigned char r, unsigned char g, 2693 - unsigned char b) 2694 -{ 2695 -/* handling palette colors */ 2696 - int index; 2697 - double min_dist = DBL_MAX; 2698 - double dist; 2699 - int min_index; 2700 - for (index = 0; index < img->max_palette; index++) 2701 - { 2702 - /* searching if already defined */ 2703 - if (img->palette_red[index] == r && img->palette_green[index] == g 2704 - && img->palette_blue[index] == b) 2705 - return (unsigned char) index; 2706 - } 2707 - if (img->max_palette < 255) 2708 - { 2709 - /* inserting a new palette entry */ 2710 - unsigned char i = img->max_palette; 2711 - img->max_palette += 1; 2712 - img->palette_red[i] = r; 2713 - img->palette_green[i] = g; 2714 - img->palette_blue[i] = b; 2715 - return i; 2716 - } 2717 -/* all right, the palette is already fully populated */ 2718 - for (index = 0; index < img->max_palette; index++) 2719 - { 2720 - /* computing the minimal euclidean distance */ 2721 - dist = 2722 - sqrt (((img->palette_red[index] - r) * (img->palette_red[index] - 2723 - r)) + 2724 - ((img->palette_green[index] - 2725 - g) * (img->palette_green[index] - g)) + 2726 - ((img->palette_blue[index] - 2727 - b) * (img->palette_blue[index] - b))); 2728 - if (dist < min_dist) 2729 - { 2730 - min_dist = dist; 2731 - min_index = index; 2732 - } 2733 - } 2734 - return (unsigned char) min_index; 2735 -} 2736 - 2737 -GGRAPH_DECLARE int 2738 -gGraphStripImageSetPixelRGB (const void *ptr, int col, int row, 2739 - unsigned char red, unsigned char green, 2740 - unsigned char blue) 2741 -{ 2742 -/* setting an RGB pixel by col and row */ 2743 - unsigned char *p_out; 2744 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2745 - 2746 - if (img == NULL) 2747 - return GGRAPH_INVALID_IMAGE; 2748 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2749 - return GGRAPH_INVALID_IMAGE; 2750 - 2751 - if (col < 0 || col >= img->width) 2752 - return GGRAPH_ERROR; 2753 - if (row < 0 || row >= img->current_available_rows) 2754 - return GGRAPH_ERROR; 2755 - 2756 - p_out = img->pixels + (row * img->scanline_width) + (col * img->pixel_size); 2757 - if (img->pixel_format == GG_PIXEL_RGB) 2758 - { 2759 - *p_out++ = red; 2760 - *p_out++ = green; 2761 - *p_out++ = blue; 2762 - } 2763 - else if (img->pixel_format == GG_PIXEL_RGBA) 2764 - { 2765 - *p_out++ = red; 2766 - *p_out++ = green; 2767 - *p_out++ = blue; 2768 - *p_out++ = 255; /* defaulting Alpha [opaque] */ 2769 - } 2770 - else if (img->pixel_format == GG_PIXEL_ARGB) 2771 - { 2772 - 2773 - *p_out++ = 255; /* defaulting Alpha [opaque] */ 2774 - *p_out++ = red; 2775 - *p_out++ = green; 2776 - *p_out++ = blue; 2777 - } 2778 - else if (img->pixel_format == GG_PIXEL_BGR) 2779 - { 2780 - *p_out++ = blue; 2781 - *p_out++ = green; 2782 - *p_out++ = red; 2783 - } 2784 - else if (img->pixel_format == GG_PIXEL_BGRA) 2785 - { 2786 - *p_out++ = blue; 2787 - *p_out++ = green; 2788 - *p_out++ = red; 2789 - 2790 - *p_out++ = 255; /* defaulting Alpha [opaque] */ 2791 - } 2792 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2793 - { 2794 - int gray; 2795 - if (red == green && green == blue) 2796 - gray = red; 2797 - else 2798 - gray = to_grayscale2 (red, green, blue); 2799 - *p_out++ = gray; 2800 - } 2801 - else if (img->pixel_format == GG_PIXEL_PALETTE) 2802 - { 2803 - int index = match_palette2 (img, red, green, blue); 2804 - *p_out++ = index; 2805 - } 2806 - 2807 - return GGRAPH_OK; 2808 -} 2809 - 2810 -GGRAPH_DECLARE int 2811 -gGraphStripImageSetCurrentRows (const void *ptr, int rows) 2812 -{ 2813 -/* sets the number of rows currently into the buffer */ 2814 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2815 - 2816 - if (img == NULL) 2817 - return GGRAPH_INVALID_IMAGE; 2818 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2819 - return GGRAPH_INVALID_IMAGE; 2820 - 2821 - img->current_available_rows = rows; 2822 - return GGRAPH_OK; 2823 -} 2824 - 2825 -GGRAPH_DECLARE void 2826 -gGraphDestroyImageInfos (const void *ptr) 2827 -{ 2828 -/* destroyng an image INFOS object */ 2829 - gGraphImageInfosPtr img = (gGraphImageInfosPtr) ptr; 2830 - 2831 - if (img == NULL) 2832 - return; 2833 - if (img->signature != GG_IMAGE_INFOS_MAGIC_SIGNATURE) 2834 - return; 2835 - gg_image_infos_destroy (img); 2836 -} 2837 - 2838 -GGRAPH_DECLARE int 2839 -gGraphGetImageInfos (const void *ptr, int *width, int *height, int *colorspace, 2840 - int *max_palette, int *bits_per_sample, 2841 - int *samples_per_pixel, int *sample_format, 2842 - int *tile_width, int *tile_height, int *rows_per_strip, 2843 - int *compression, double *no_data_value, double *min_value, 2844 - double *max_value, int *scale_1_2, int *scale_1_4, 2845 - int *scale_1_8) 2846 -{ 2847 -/* querying image INFOSt */ 2848 - gGraphImageInfosPtr infos = (gGraphImageInfosPtr) ptr; 2849 - gGraphImagePtr img = (gGraphImagePtr) ptr; 2850 - gGraphStripImagePtr strip_img = (gGraphStripImagePtr) ptr; 2851 - 2852 - if (ptr == NULL) 2853 - return GGRAPH_ERROR; 2854 - if (infos->signature == GG_IMAGE_INFOS_MAGIC_SIGNATURE) 2855 - { 2856 - /* form the INFO struct */ 2857 - *width = infos->width; 2858 - *height = infos->height; 2859 - switch (infos->pixel_format) 2860 - { 2861 - case GG_PIXEL_RGB: 2862 - case GG_PIXEL_BGR: 2863 - *colorspace = GGRAPH_COLORSPACE_TRUECOLOR; 2864 - break; 2865 - case GG_PIXEL_RGBA: 2866 - case GG_PIXEL_ARGB: 2867 - case GG_PIXEL_BGRA: 2868 - *colorspace = GGRAPH_COLORSPACE_TRUECOLOR; 2869 - break; 2870 - case GG_PIXEL_GRAYSCALE: 2871 - *colorspace = GGRAPH_COLORSPACE_GRAYSCALE; 2872 - break; 2873 - case GG_PIXEL_PALETTE: 2874 - if (infos->max_palette == 2) 2875 - { 2876 - if ((infos->palette_red[0] == 255 2877 - && infos->palette_green[0] == 255 2878 - && infos->palette_blue[0] == 255 2879 - && infos->palette_red[1] == 0 2880 - && infos->palette_green[1] == 0 2881 - && infos->palette_blue[1] == 0) 2882 - || (infos->palette_red[0] == 0 2883 - && infos->palette_green[0] == 0 2884 - && infos->palette_blue[0] == 0 2885 - && infos->palette_red[1] == 255 2886 - && infos->palette_green[1] == 255 2887 - && infos->palette_blue[1] == 255)) 2888 - *colorspace = GGRAPH_COLORSPACE_MONOCHROME; 2889 - else 2890 - *colorspace = GGRAPH_COLORSPACE_PALETTE; 2891 - } 2892 - else 2893 - *colorspace = GGRAPH_COLORSPACE_PALETTE; 2894 - break; 2895 - case GG_PIXEL_GRID: 2896 - *colorspace = GGRAPH_COLORSPACE_GRID; 2897 - break; 2898 - default: 2899 - *colorspace = GGRAPH_COLORSPACE_UNKNOWN; 2900 - break; 2901 - }; 2902 - *bits_per_sample = infos->bits_per_sample; 2903 - *samples_per_pixel = infos->samples_per_pixel; 2904 - *sample_format = infos->sample_format; 2905 - *tile_width = infos->tile_width; 2906 - *tile_height = infos->tile_height; 2907 - *rows_per_strip = infos->rows_per_strip; 2908 - *compression = infos->compression; 2909 - *no_data_value = infos->no_data_value; 2910 - *min_value = infos->min_value; 2911 - *max_value = infos->max_value; 2912 - *scale_1_2 = infos->scale_1_2; 2913 - *scale_1_4 = infos->scale_1_4; 2914 - *scale_1_8 = infos->scale_1_8; 2915 - return GGRAPH_OK; 2916 - } 2917 - else if (img->signature == GG_IMAGE_MAGIC_SIGNATURE) 2918 - { 2919 - /* from the IMAGE struct */ 2920 - *width = img->width; 2921 - *height = img->height; 2922 - switch (img->pixel_format) 2923 - { 2924 - case GG_PIXEL_RGB: 2925 - case GG_PIXEL_BGR: 2926 - *colorspace = GGRAPH_COLORSPACE_TRUECOLOR; 2927 - break; 2928 - case GG_PIXEL_RGBA: 2929 - case GG_PIXEL_ARGB: 2930 - case GG_PIXEL_BGRA: 2931 - *colorspace = GGRAPH_COLORSPACE_TRUECOLOR; 2932 - break; 2933 - case GG_PIXEL_GRAYSCALE: 2934 - *colorspace = GGRAPH_COLORSPACE_GRAYSCALE; 2935 - break; 2936 - case GG_PIXEL_PALETTE: 2937 - if (img->max_palette == 2) 2938 - { 2939 - if ((img->palette_red[0] == 255 2940 - && img->palette_green[0] == 255 2941 - && img->palette_blue[0] == 255 2942 - && img->palette_red[1] == 0 2943 - && img->palette_green[1] == 0 2944 - && img->palette_blue[1] == 0) 2945 - || (img->palette_red[0] == 0 2946 - && img->palette_green[0] == 0 2947 - && img->palette_blue[0] == 0 2948 - && img->palette_red[1] == 255 2949 - && img->palette_green[1] == 255 2950 - && img->palette_blue[1] == 255)) 2951 - *colorspace = GGRAPH_COLORSPACE_MONOCHROME; 2952 - else 2953 - *colorspace = GGRAPH_COLORSPACE_PALETTE; 2954 - } 2955 - else 2956 - *colorspace = GGRAPH_COLORSPACE_PALETTE; 2957 - break; 2958 - case GG_PIXEL_GRID: 2959 - *colorspace = GGRAPH_COLORSPACE_GRID; 2960 - break; 2961 - default: 2962 - *colorspace = GGRAPH_COLORSPACE_UNKNOWN; 2963 - break; 2964 - }; 2965 - *max_palette = img->max_palette; 2966 - *bits_per_sample = img->bits_per_sample; 2967 - *samples_per_pixel = img->samples_per_pixel; 2968 - *sample_format = img->sample_format; 2969 - *tile_width = img->tile_width; 2970 - *tile_height = img->tile_height; 2971 - *rows_per_strip = img->rows_per_strip; 2972 - *compression = img->compression; 2973 - *no_data_value = img->no_data_value; 2974 - *min_value = img->min_value; 2975 - *max_value = img->max_value; 2976 - return GGRAPH_OK; 2977 - } 2978 - else if (strip_img->signature == GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2979 - { 2980 - /* from the IMAGE struct */ 2981 - *width = strip_img->width; 2982 - *height = strip_img->height; 2983 - switch (strip_img->pixel_format) 2984 - { 2985 - case GG_PIXEL_RGB: 2986 - case GG_PIXEL_BGR: 2987 - *colorspace = GGRAPH_COLORSPACE_TRUECOLOR; 2988 - break; 2989 - case GG_PIXEL_RGBA: 2990 - case GG_PIXEL_ARGB: 2991 - case GG_PIXEL_BGRA: 2992 - *colorspace = GGRAPH_COLORSPACE_TRUECOLOR; 2993 - break; 2994 - case GG_PIXEL_GRAYSCALE: 2995 - *colorspace = GGRAPH_COLORSPACE_GRAYSCALE; 2996 - break; 2997 - case GG_PIXEL_PALETTE: 2998 - if (strip_img->max_palette == 2) 2999 - { 3000 - if ((strip_img->palette_red[0] == 255 3001 - && strip_img->palette_green[0] == 255 3002 - && strip_img->palette_blue[0] == 255 3003 - && strip_img->palette_red[1] == 0 3004 - && strip_img->palette_green[1] == 0 3005 - && strip_img->palette_blue[1] == 0) 3006 - || (strip_img->palette_red[0] == 0 3007 - && strip_img->palette_green[0] == 0 3008 - && strip_img->palette_blue[0] == 0 3009 - && strip_img->palette_red[1] == 255 3010 - && strip_img->palette_green[1] == 255 3011 - && strip_img->palette_blue[1] == 255)) 3012 - *colorspace = GGRAPH_COLORSPACE_MONOCHROME; 3013 - else 3014 - *colorspace = GGRAPH_COLORSPACE_PALETTE; 3015 - } 3016 - else 3017 - *colorspace = GGRAPH_COLORSPACE_PALETTE; 3018 - break; 3019 - case GG_PIXEL_GRID: 3020 - *colorspace = GGRAPH_COLORSPACE_GRID; 3021 - break; 3022 - default: 3023 - *colorspace = GGRAPH_COLORSPACE_UNKNOWN; 3024 - break; 3025 - }; 3026 - *max_palette = strip_img->max_palette; 3027 - *bits_per_sample = strip_img->bits_per_sample; 3028 - *samples_per_pixel = strip_img->samples_per_pixel; 3029 - *sample_format = strip_img->sample_format; 3030 - *tile_width = strip_img->tile_width; 3031 - *tile_height = strip_img->tile_height; 3032 - *rows_per_strip = strip_img->rows_per_strip; 3033 - *compression = strip_img->compression; 3034 - *no_data_value = strip_img->no_data_value; 3035 - *min_value = strip_img->min_value; 3036 - *max_value = strip_img->max_value; 3037 - return GGRAPH_OK; 3038 - } 3039 - return GGRAPH_ERROR; 3040 -} 3041 - 3042 -GGRAPH_DECLARE int 3043 -gGraphGetImageDims (const void *ptr, int *width, int *height) 3044 -{ 3045 -/* querying image Width / Height */ 3046 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3047 - 3048 - if (img == NULL) 3049 - return GGRAPH_INVALID_IMAGE; 3050 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3051 - return GGRAPH_INVALID_IMAGE; 3052 - *width = img->width; 3053 - *height = img->height; 3054 - return GGRAPH_OK; 3055 -} 3056 - 3057 -GGRAPH_DECLARE int 3058 -gGraphGetImageSize (const void *ptr, int *size) 3059 -{ 3060 -/* querying image size */ 3061 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3062 - 3063 - if (img == NULL) 3064 - return GGRAPH_INVALID_IMAGE; 3065 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3066 - return GGRAPH_INVALID_IMAGE; 3067 - 3068 - *size = img->height * img->scanline_width; 3069 - if (gg_is_image_monochrome_ready (img) == GGRAPH_TRUE) 3070 - *size /= 8; 3071 - 3072 - return GGRAPH_OK; 3073 -} 3074 - 3075 -GGRAPH_DECLARE int 3076 -gGraphImageColorSpaceOptimize (const void *ptr) 3077 -{ 3078 -/* attempting to optimize the actual color space */ 3079 - int current_color_space; 3080 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3081 - 3082 - if (img == NULL) 3083 - return GGRAPH_INVALID_IMAGE; 3084 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3085 - return GGRAPH_INVALID_IMAGE; 3086 - 3087 - if (img->pixel_format == GG_PIXEL_PALETTE) 3088 - { 3089 - if (gg_is_image_monochrome_ready (img) == GGRAPH_TRUE) 3090 - current_color_space = GGRAPH_COLORSPACE_MONOCHROME; 3091 - else 3092 - current_color_space = GGRAPH_COLORSPACE_PALETTE; 3093 - } 3094 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 3095 - current_color_space = GGRAPH_COLORSPACE_GRAYSCALE; 3096 - else 3097 - current_color_space = GGRAPH_COLORSPACE_TRUECOLOR; 3098 - 3099 - if (current_color_space == GGRAPH_COLORSPACE_MONOCHROME) 3100 - { 3101 - /* already optimized */ 3102 - return GGRAPH_OK; 3103 - } 3104 - if (gg_is_image_monochrome (img) == GGRAPH_TRUE) 3105 - { 3106 - /* attempting to optimize into MONOCHROME */ 3107 - return gg_convert_image_to_monochrome (img); 3108 - } 3109 - if (gg_is_image_grayscale (img) == GGRAPH_TRUE) 3110 - { 3111 - /* attempting to optimize into GRAYSCALE */ 3112 - return gg_convert_image_to_grayscale (img); 3113 - } 3114 - if (current_color_space == GGRAPH_COLORSPACE_PALETTE) 3115 - { 3116 - /* already optimized */ 3117 - return GGRAPH_OK; 3118 - } 3119 - if (gg_is_image_palette256 (img) == GGRAPH_TRUE) 3120 - { 3121 - /* attempting to optimize into PALETTE */ 3122 - return gg_convert_image_to_palette (img); 3123 - } 3124 - return GGRAPH_OK; 3125 -} 3126 - 3127 -GGRAPH_DECLARE int 3128 -gGraphImageResampleAsGridInt16 (const void *ptr) 3129 -{ 3130 -/* promoting to GRID-Int16 */ 3131 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3132 - 3133 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3134 - return GGRAPH_INVALID_IMAGE; 3135 - 3136 - return gg_convert_image_to_grid_int16 (img); 3137 -} 3138 - 3139 -GGRAPH_DECLARE int 3140 -gGraphImageResampleAsGridUInt16 (const void *ptr) 3141 -{ 3142 -/* promoting to GRID-UInt16 */ 3143 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3144 - 3145 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3146 - return GGRAPH_INVALID_IMAGE; 3147 - 3148 - return gg_convert_image_to_grid_uint16 (img); 3149 -} 3150 - 3151 -GGRAPH_DECLARE int 3152 -gGraphImageResampleAsGridInt32 (const void *ptr) 3153 -{ 3154 -/* promoting to GRID-Int32 */ 3155 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3156 - 3157 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3158 - return GGRAPH_INVALID_IMAGE; 3159 - 3160 - return gg_convert_image_to_grid_int32 (img); 3161 -} 3162 - 3163 -GGRAPH_DECLARE int 3164 -gGraphImageResampleAsGridUInt32 (const void *ptr) 3165 -{ 3166 -/* promoting to GRID-UInt32 */ 3167 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3168 - 3169 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3170 - return GGRAPH_INVALID_IMAGE; 3171 - 3172 - return gg_convert_image_to_grid_uint32 (img); 3173 -} 3174 - 3175 -GGRAPH_DECLARE int 3176 -gGraphImageResampleAsGridFloat (const void *ptr) 3177 -{ 3178 -/* promoting to GRID-Float */ 3179 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3180 - 3181 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3182 - return GGRAPH_INVALID_IMAGE; 3183 - 3184 - return gg_convert_image_to_grid_float (img); 3185 -} 3186 - 3187 -GGRAPH_DECLARE int 3188 -gGraphImageResampleAsGridDouble (const void *ptr) 3189 -{ 3190 -/* promoting to GRID-Double */ 3191 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3192 - 3193 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3194 - return GGRAPH_INVALID_IMAGE; 3195 - 3196 - return gg_convert_image_to_grid_double (img); 3197 -} 3198 - 3199 -GGRAPH_DECLARE int 3200 -gGraphImageResampleAsRgb (const void *ptr) 3201 -{ 3202 -/* promoting to RGB */ 3203 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3204 - 3205 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3206 - return GGRAPH_INVALID_IMAGE; 3207 - 3208 - return gg_convert_image_to_rgb (img); 3209 -} 3210 - 3211 -GGRAPH_DECLARE int 3212 -gGraphImageTransparentResample (const void *ptr) 3213 -{ 3214 -/* resampling the Transparent Color near-values as Transparent */ 3215 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3216 - 3217 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3218 - return GGRAPH_INVALID_IMAGE; 3219 - 3220 - switch (img->pixel_format) 3221 - { 3222 - case GG_PIXEL_RGB: 3223 - return gg_resample_transparent_rgb (img); 3224 - case GG_PIXEL_RGBA: 3225 - return gg_resample_transparent_rgba (img); 3226 - case GG_PIXEL_GRAYSCALE: 3227 - return gg_resample_transparent_grayscale (img); 3228 - case GG_PIXEL_PALETTE: 3229 - return gg_resample_transparent_palette (img); 3230 - default: 3231 - return GGRAPH_OK; 3232 - }; 3233 -} 3234 - 3235 -GGRAPH_DECLARE int 3236 -gGraphImageResampleAsMonochrome (const void *ptr) 3237 -{ 3238 -/* applying BILEVEL quantization */ 3239 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3240 - 3241 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3242 - return GGRAPH_INVALID_IMAGE; 3243 - 3244 - return gg_convert_image_to_monochrome (img); 3245 -} 3246 - 3247 -GGRAPH_DECLARE int 3248 -gGraphImageResampleAsPalette (const void *ptr, int num_colors) 3249 -{ 3250 -/* applying quantization in order to fit into PALETTE colorspace */ 3251 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3252 - 3253 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3254 - return GGRAPH_INVALID_IMAGE; 3255 - 3256 - return gg_image_resample_as_palette (img, num_colors); 3257 -} 3258 - 3259 -GGRAPH_DECLARE int 3260 -gGraphImageResampleAsGrayscale (const void *ptr) 3261 -{ 3262 -/* converting into GRAYSCALE */ 3263 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3264 - 3265 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3266 - return GGRAPH_INVALID_IMAGE; 3267 - 3268 - return gg_convert_image_to_grayscale (img); 3269 -} 3270 - 3271 -GGRAPH_DECLARE int 3272 -gGraphImageResampleAsPhotographic (const void *ptr) 3273 -{ 3274 -/* converting into GRAYSCALE or RGB colorspace */ 3275 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3276 - 3277 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3278 - return GGRAPH_INVALID_IMAGE; 3279 - 3280 - if (img->pixel_format == GG_PIXEL_GRAYSCALE 3281 - || img->pixel_format == GG_PIXEL_RGB) 3282 - return GGRAPH_OK; 3283 - 3284 - if (gg_is_image_grayscale (img) == GGRAPH_TRUE) 3285 - { 3286 - /* attempting to convert into GRAYSCALE */ 3287 - return gg_convert_image_to_grayscale (img); 3288 - } 3289 - 3290 - return gg_convert_image_to_rgb (img); 3291 -} 3292 - 3293 -GGRAPH_DECLARE int 3294 -gGraphImageGuessFormat (const void *mem_buf, int mem_buf_size) 3295 -{ 3296 -/* attempting to guess the Image type from its Magic Number */ 3297 - const unsigned char *p = mem_buf; 3298 - if (mem_buf_size > 6) 3299 - { 3300 - if (p[0] == 'G' && p[1] == 'I' && p[2] == 'F' && p[3] == '8' 3301 - && (p[4] == '7' || p[4] == '9') && p[5] == 'a') 3302 - return GGRAPH_IMAGE_GIF; 3303 - if (p[0] == 0x89 && p[1] == 'P' && p[2] == 'N' && p[3] == 'G' 3304 - && p[4] == 0x0d && p[5] == 0x0a) 3305 - return GGRAPH_IMAGE_PNG; 3306 - } 3307 - if (mem_buf_size > 4) 3308 - { 3309 - if (p[0] == 'M' && p[1] == 'M' && p[2] == 0x00 && p[3] == '*') 3310 - return GGRAPH_IMAGE_TIFF; 3311 - if (p[0] == 'I' && p[1] == 'I' && p[2] == '*' && p[3] == 0x00) 3312 - return GGRAPH_IMAGE_TIFF; 3313 - } 3314 - if (mem_buf_size > 2) 3315 - { 3316 - if (p[0] == 0xff && p[1] == 0xd8) 3317 - return GGRAPH_IMAGE_JPEG; 3318 - } 3319 - return GGRAPH_IMAGE_UNKNOWN; 3320 -} 3321 - 3322 -GGRAPH_DECLARE int 3323 -gGraphFileImageGuessFormat (const char *path, int *type) 3324 -{ 3325 -/* attempting to guess the FileImage type from its Magic Number */ 3326 - FILE *in = NULL; 3327 - unsigned char mem_buf[10]; 3328 - int mem_buf_size; 3329 - 3330 - *type = GGRAPH_IMAGE_UNKNOWN; 3331 -/* attempting to open the image file */ 3332 - in = fopen (path, "rb"); 3333 - if (in == NULL) 3334 - return GGRAPH_FILE_OPEN_ERROR; 3335 - mem_buf_size = fread (mem_buf, 1, 10, in); 3336 - if (mem_buf_size < 10) 3337 - { 3338 - fclose (in); 3339 - return GGRAPH_FILE_READ_ERROR; 3340 - } 3341 - fclose (in); 3342 - *type = gGraphImageGuessFormat (mem_buf, 10); 3343 - return GGRAPH_OK; 3344 -} 3345 - 3346 -GGRAPH_DECLARE int 3347 -gGraphImageIsGeoRef (const void *ptr) 3348 -{ 3349 -/* checking if an Image is georeferenced or not */ 3350 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3351 - 3352 - if (img == NULL) 3353 - return GGRAPH_ERROR; 3354 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3355 - return GGRAPH_ERROR; 3356 - 3357 - if (img->is_georeferenced) 3358 - return GGRAPH_OK; 3359 - return GGRAPH_ERROR; 3360 -} 3361 - 3362 -GGRAPH_DECLARE int 3363 -gGraphImageSetGeoRef (const void *ptr, int srid, const char *srs_name, 3364 - const char *proj4text, double upper_left_x, 3365 - double upper_left_y, double pixel_x_size, 3366 - double pixel_y_size) 3367 -{ 3368 -/* setting the georeferencing infos for some Image */ 3369 - int len; 3370 - char *SrsName = NULL; 3371 - char *Proj4Text = NULL; 3372 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3373 - gGraphStripImagePtr strip_img = (gGraphStripImagePtr) ptr; 3374 - 3375 - if (img == NULL) 3376 - return GGRAPH_IMAGE_UNKNOWN; 3377 - if (img->signature == GG_IMAGE_MAGIC_SIGNATURE) 3378 - { 3379 - /* setting up an Image struct */ 3380 - if (srs_name) 3381 - { 3382 - len = strlen (srs_name); 3383 - if (len > 0) 3384 - { 3385 - SrsName = malloc (len + 1); 3386 - if (!SrsName) 3387 - return GGRAPH_ERROR; 3388 - strcpy (SrsName, srs_name); 3389 - } 3390 - } 3391 - if (proj4text) 3392 - { 3393 - len = strlen (proj4text); 3394 - if (len > 0) 3395 - { 3396 - Proj4Text = malloc (len + 1); 3397 - if (!Proj4Text) 3398 - { 3399 - free (SrsName); 3400 - return GGRAPH_ERROR; 3401 - } 3402 - strcpy (Proj4Text, proj4text); 3403 - } 3404 - } 3405 - 3406 - if (img->srs_name) 3407 - free (img->srs_name); 3408 - if (img->proj4text) 3409 - free (img->proj4text); 3410 - 3411 - img->is_georeferenced = 1; 3412 - img->srid = srid; 3413 - img->srs_name = SrsName; 3414 - img->proj4text = Proj4Text; 3415 - img->upper_left_x = upper_left_x; 3416 - img->upper_left_y = upper_left_y; 3417 - img->pixel_x_size = pixel_x_size; 3418 - img->pixel_y_size = pixel_y_size; 3419 - return GGRAPH_OK; 3420 - } 3421 - else if (strip_img->signature == GG_STRIP_IMAGE_MAGIC_SIGNATURE) 3422 - { /* setting up a Strip Image struct */ 3423 - if (srs_name) 3424 - { 3425 - len = strlen (srs_name); 3426 - if (len > 0) 3427 - { 3428 - SrsName = malloc (len + 1); 3429 - if (!SrsName) 3430 - return GGRAPH_ERROR; 3431 - strcpy (SrsName, srs_name); 3432 - } 3433 - } 3434 - if (proj4text) 3435 - { 3436 - len = strlen (proj4text); 3437 - if (len > 0) 3438 - { 3439 - Proj4Text = malloc (len + 1); 3440 - if (!Proj4Text) 3441 - { 3442 - free (SrsName); 3443 - return GGRAPH_ERROR; 3444 - } 3445 - strcpy (Proj4Text, proj4text); 3446 - } 3447 - } 3448 - 3449 - if (strip_img->srs_name) 3450 - free (strip_img->srs_name); 3451 - if (strip_img->proj4text) 3452 - free (strip_img->proj4text); 3453 - 3454 - strip_img->is_georeferenced = 1; 3455 - strip_img->srid = srid; 3456 - strip_img->srs_name = SrsName; 3457 - strip_img->proj4text = Proj4Text; 3458 - strip_img->upper_left_x = upper_left_x; 3459 - strip_img->upper_left_y = upper_left_y; 3460 - strip_img->pixel_x_size = pixel_x_size; 3461 - strip_img->pixel_y_size = pixel_y_size; 3462 - return GGRAPH_OK; 3463 - } 3464 - return GGRAPH_IMAGE_UNKNOWN; 3465 -} 3466 - 3467 -GGRAPH_DECLARE int 3468 -gGraphImageGetGeoRef (const void *ptr, int *srid, char *srs_name, 3469 - char *proj4text, double *upper_left_x, 3470 - double *upper_left_y, double *pixel_x_size, 3471 - double *pixel_y_size) 3472 -{ 3473 -/* retrieving the georeferencing infos from some Image */ 3474 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3475 - gGraphStripImagePtr strip_img = (gGraphStripImagePtr) ptr; 3476 - 3477 - if (img == NULL) 3478 - return GGRAPH_IMAGE_UNKNOWN; 3479 - if (img->signature == GG_IMAGE_MAGIC_SIGNATURE) 3480 - { 3481 - /* from normal Image */ 3482 - if (img->is_georeferenced == 0) 3483 - return GGRAPH_ERROR; 3484 - 3485 - *srid = img->srid; 3486 - if (img->srs_name) 3487 - strcpy (srs_name, img->srs_name); 3488 - else 3489 - *srs_name = '\0'; 3490 - if (img->proj4text) 3491 - strcpy (proj4text, img->proj4text); 3492 - else 3493 - *proj4text = '\0'; 3494 - *upper_left_x = img->upper_left_x; 3495 - *upper_left_y = img->upper_left_y; 3496 - *pixel_x_size = img->pixel_x_size; 3497 - *pixel_y_size = img->pixel_y_size; 3498 - return GGRAPH_OK; 3499 - } 3500 - else if (strip_img->signature == GG_STRIP_IMAGE_MAGIC_SIGNATURE) 3501 - { 3502 - /* from strip Image */ 3503 - if (strip_img->is_georeferenced == 0) 3504 - return GGRAPH_ERROR; 3505 - 3506 - *srid = strip_img->srid; 3507 - if (strip_img->srs_name) 3508 - strcpy (srs_name, strip_img->srs_name); 3509 - else 3510 - *srs_name = '\0'; 3511 - if (strip_img->proj4text) 3512 - strcpy (proj4text, strip_img->proj4text); 3513 - else 3514 - *proj4text = '\0'; 3515 - *upper_left_x = strip_img->upper_left_x; 3516 - *upper_left_y = strip_img->upper_left_y; 3517 - *pixel_x_size = strip_img->pixel_x_size; 3518 - *pixel_y_size = strip_img->pixel_y_size; 3519 - return GGRAPH_OK; 3520 - } 3521 - return GGRAPH_IMAGE_UNKNOWN; 3522 -} 3523 - 3524 -GGRAPH_DECLARE int 3525 -gGraphImageInfosGetGeoRef (const void *ptr, int *srid, char *srs_name, 3526 - char *proj4text, double *upper_left_x, 3527 - double *upper_left_y, double *pixel_x_size, 3528 - double *pixel_y_size) 3529 -{ 3530 -/* retrieving the georeferencing infos from some Image */ 3531 - gGraphImageInfosPtr img = (gGraphImageInfosPtr) ptr; 3532 - 3533 - if (img == NULL) 3534 - return GGRAPH_IMAGE_UNKNOWN; 3535 - if (img->signature != GG_IMAGE_INFOS_MAGIC_SIGNATURE) 3536 - return GGRAPH_IMAGE_UNKNOWN; 3537 - if (img->is_georeferenced == 0) 3538 - return GGRAPH_ERROR; 3539 - 3540 - *srid = img->srid; 3541 - if (img->srs_name) 3542 - strcpy (srs_name, img->srs_name); 3543 - else 3544 - *srs_name = '\0'; 3545 - if (img->proj4text) 3546 - strcpy (proj4text, img->proj4text); 3547 - else 3548 - *proj4text = '\0'; 3549 - *upper_left_x = img->upper_left_x; 3550 - *upper_left_y = img->upper_left_y; 3551 - *pixel_x_size = img->pixel_x_size; 3552 - *pixel_y_size = img->pixel_y_size; 3553 - return GGRAPH_OK; 3554 -} 3555 - 3556 -static int 3557 -token_to_double (const char *str, double *value) 3558 -{ 3559 -/* attempting to convert from string to double */ 3560 - const char *p = str; 3561 - int error = 0; 3562 - int digits = 0; 3563 - int comma = 0; 3564 - int sign = 0; 3565 - while (*p != '\0') 3566 - { 3567 - if (*p >= '0' && *p <= '9') 3568 - digits++; 3569 - else if (*p == '.') 3570 - comma++; 3571 - else if (*p == '-' || *p == '+') 3572 - { 3573 - if (digits == 0) 3574 - sign++; 3575 - else 3576 - error = 1; 3577 - } 3578 - else 3579 - error = 1; 3580 - p++; 3581 - } 3582 - if (digits > 0 && sign < 2 && comma < 2 && error == 0) 3583 - { 3584 - *value = atof (str); 3585 - return 1; 3586 - } 3587 - return 0; 3588 -} 3589 - 3590 -GGRAPH_DECLARE int 3591 -gGraphGetWorldFilePath (const char *main_path, char *world_file_path) 3592 -{ 3593 -/* generating a World File path corresponding to the Image path */ 3594 - char suffix[1024]; 3595 - char string[1024]; 3596 - int i; 3597 - int len; 3598 - 3599 - strcpy (string, main_path); 3600 - len = strlen (string) - 1; 3601 - for (i = len - 1; i >= 0; i--) 3602 - { 3603 - if (string[i] == '.') 3604 - { 3605 - strcpy (suffix, string + i); 3606 - string[i] = '\0'; 3607 - if (strcasecmp (suffix, ".jpg") == 0) 3608 - { 3609 - strcpy (world_file_path, string); 3610 - strcat (world_file_path, ".jgw"); 3611 - return GGRAPH_OK; 3612 - } 3613 - if (strcasecmp (suffix, ".png") == 0) 3614 - { 3615 - strcpy (world_file_path, string); 3616 - strcat (world_file_path, ".pgw"); 3617 - return GGRAPH_OK; 3618 - } 3619 - if (strcasecmp (suffix, ".gif") == 0) 3620 - { 3621 - strcpy (world_file_path, string); 3622 - strcat (world_file_path, ".gfw"); 3623 - return GGRAPH_OK; 3624 - } 3625 - if (strcasecmp (suffix, ".tif") == 0) 3626 - { 3627 - strcpy (world_file_path, string); 3628 - strcat (world_file_path, ".tfw"); 3629 - return GGRAPH_OK; 3630 - } 3631 - } 3632 - } 3633 - *world_file_path = '\0'; 3634 - return GGRAPH_ERROR; 3635 -} 3636 - 3637 -GGRAPH_DECLARE int 3638 -gGraphReadWorldFile (const char *path, double *ul_x, double *ul_y, 3639 - double *x_size, double *y_size) 3640 -{ 3641 -/* attempting to read georeferencing infos from some World File */ 3642 - FILE *in = NULL; 3643 - double upper_left_x = DBL_MAX; 3644 - double upper_left_y = DBL_MAX; 3645 - double pixel_x = DBL_MAX; 3646 - double pixel_y = DBL_MAX; 3647 - double value; 3648 - int c; 3649 - int i; 3650 - char wf_buf[1024]; 3651 - char *p_wf; 3652 - int wf_row; 3653 - 3654 - in = fopen (path, "rb"); 3655 - if (in == NULL) 3656 - return GGRAPH_FILE_OPEN_ERROR; 3657 - 3658 - wf_row = 0; 3659 - p_wf = wf_buf; 3660 - while ((c = getc (in)) != EOF) 3661 - { 3662 - /* parsing the Worldfile */ 3663 - if (c == '\r') 3664 - continue; 3665 - if (c == '\n') 3666 - { 3667 - *p_wf = '\0'; 3668 - for (i = 0; i < (int) strlen (wf_buf); i++) 3669 - { 3670 - /* replacing any COMMA (badly formatted decimal separator) */ 3671 - if (wf_buf[i] == ',') 3672 - wf_buf[i] = '.'; 3673 - } 3674 - switch (wf_row) 3675 - { 3676 - case 0: 3677 - if (!token_to_double (wf_buf, &value)) 3678 - goto stop; 3679 - else 3680 - pixel_x = value; 3681 - break; 3682 - case 3: 3683 - if (!token_to_double (wf_buf, &value)) 3684 - goto stop; 3685 - else 3686 - pixel_y = value * -1.0; 3687 - break; 3688 - case 4: 3689 - if (!token_to_double (wf_buf, &value)) 3690 - goto stop; 3691 - else 3692 - upper_left_x = value; 3693 - break; 3694 - case 5: 3695 - if (!token_to_double (wf_buf, &value)) 3696 - goto stop; 3697 - else 3698 - upper_left_y = value; 3699 - break; 3700 - }; 3701 - p_wf = wf_buf; 3702 - wf_row++; 3703 - continue; 3704 - } 3705 - *p_wf++ = c; 3706 - if (p_wf - wf_buf > 1024) 3707 - goto stop; 3708 - } 3709 - fclose (in); 3710 - 3711 - if (pixel_x == DBL_MAX || pixel_y == DBL_MAX || upper_left_x == DBL_MAX 3712 - || upper_left_y == DBL_MAX) 3713 - return GGRAPH_ERROR; 3714 - 3715 - *ul_x = upper_left_x; 3716 - *ul_y = upper_left_y; 3717 - *x_size = pixel_x; 3718 - *y_size = pixel_y; 3719 - return GGRAPH_OK; 3720 - 3721 - stop: 3722 - fclose (in); 3723 - return GGRAPH_ERROR; 3724 -} 3725 - 3726 -GGRAPH_DECLARE int 3727 -gGraphImageResizeNormal (const void *orig, const void **dest, int width, 3728 - int height) 3729 -{ 3730 -/* generating a resized image [Normal Quality] */ 3731 - gGraphImagePtr img2 = NULL; 3732 - gGraphImagePtr img = (gGraphImagePtr) orig; 3733 - 3734 - *dest = NULL; 3735 - if (img == NULL) 3736 - return GGRAPH_ERROR; 3737 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3738 - return GGRAPH_ERROR; 3739 - 3740 - img2 = 3741 - gg_image_create (img->pixel_format, width, height, img->bits_per_sample, 3742 - img->samples_per_pixel, img->sample_format, 3743 - img->srs_name, img->proj4text); 3744 - if (!img2) 3745 - return GGRAPH_INSUFFICIENT_MEMORY; 3746 - if (img->pixel_format == GG_PIXEL_GRID) 3747 - gg_grid_resize (img2, img); 3748 - else 3749 - gg_image_resize (img2, img); 3750 - gg_image_clone_georeferencing (img2, img); 3751 - *dest = img2; 3752 - 3753 - return GGRAPH_OK; 3754 -} 3755 - 3756 -GGRAPH_DECLARE int 3757 -gGraphImageResizeHighQuality (const void *orig, const void **dest, int width, 3758 - int height) 3759 -{ 3760 -/* generating a resized image [High Quality] */ 3761 - gGraphImagePtr img2 = NULL; 3762 - gGraphImagePtr img = (gGraphImagePtr) orig; 3763 - 3764 - *dest = NULL; 3765 - if (img == NULL) 3766 - return GGRAPH_ERROR; 3767 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3768 - return GGRAPH_ERROR; 3769 - 3770 - img2 = 3771 - gg_image_create (img->pixel_format, width, height, img->bits_per_sample, 3772 - img->samples_per_pixel, img->sample_format, 3773 - img->srs_name, img->proj4text); 3774 - if (!img2) 3775 - return GGRAPH_INSUFFICIENT_MEMORY; 3776 - if (img->pixel_format == GG_PIXEL_GRID) 3777 - gg_make_grid_thumbnail (img2, img); 3778 - else 3779 - gg_make_thumbnail (img2, img); 3780 - gg_image_clone_georeferencing (img2, img); 3781 - *dest = img2; 3782 - 3783 - return GGRAPH_OK; 3784 -} 3785 - 3786 -GGRAPH_DECLARE int 3787 -gGraphImageResizeToResolution (const void *orig, const void **dest, 3788 - double pixel_x_size, double pixel_y_size, 3789 - int *x_width, int *x_height) 3790 -{ 3791 -/* generating a resized image [High Quality] */ 3792 - int width; 3793 - int height; 3794 - double ww; 3795 - double wh; 3796 - gGraphImagePtr img2 = NULL; 3797 - gGraphImagePtr img = (gGraphImagePtr) orig; 3798 - 3799 - *dest = NULL; 3800 - *x_width = 0; 3801 - *x_height = 0; 3802 - if (img == NULL) 3803 - return GGRAPH_ERROR; 3804 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3805 - return GGRAPH_ERROR; 3806 - 3807 - ww = (double) (img->width) * img->pixel_x_size; 3808 - wh = (double) (img->height) * img->pixel_y_size; 3809 - width = (int) (ww / pixel_x_size); 3810 - height = (int) (wh / pixel_y_size); 3811 - 3812 - img2 = 3813 - gg_image_create (img->pixel_format, width, height, img->bits_per_sample, 3814 - img->samples_per_pixel, img->sample_format, 3815 - img->srs_name, img->proj4text); 3816 - if (!img2) 3817 - return GGRAPH_INSUFFICIENT_MEMORY; 3818 - if (img->pixel_format == GG_PIXEL_GRID) 3819 - gg_make_grid_thumbnail (img2, img); 3820 - else 3821 - gg_make_thumbnail (img2, img); 3822 - gg_image_clone_georeferencing (img2, img); 3823 - *dest = img2; 3824 - *x_width = width; 3825 - *x_height = height; 3826 - 3827 - return GGRAPH_OK; 3828 -} 3829 - 3830 -GGRAPH_DECLARE int 3831 -gGraphImageSubSet (const void *orig, const void **dest, int upper_left_x, 3832 - int upper_left_y, int width, int height) 3833 -{ 3834 -/* generating an Image SubSet */ 3835 - gGraphImagePtr img2 = NULL; 3836 - gGraphImagePtr img = (gGraphImagePtr) orig; 3837 - 3838 - *dest = NULL; 3839 - if (img == NULL) 3840 - return GGRAPH_ERROR; 3841 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3842 - return GGRAPH_ERROR; 3843 - 3844 - img2 = 3845 - gg_image_create (img->pixel_format, width, height, img->bits_per_sample, 3846 - img->samples_per_pixel, img->sample_format, 3847 - img->srs_name, img->proj4text); 3848 - if (!img2) 3849 - return GGRAPH_INSUFFICIENT_MEMORY; 3850 - gg_image_sub_set (img2, img, upper_left_x, upper_left_y); 3851 - *dest = img2; 3852 - 3853 - return GGRAPH_OK; 3854 -} 3855 - 3856 -GGRAPH_DECLARE int 3857 -gGraphImageBufferReferenceRGB (const void *ptr, unsigned char **buffer) 3858 -{ 3859 -/* 3860 -/ this function create a separate copy of the internal image buffer 3861 -/ if required color-space conversion will be applied 3862 -/ and the original image will be unaffected 3863 -*/ 3864 - unsigned char *buf; 3865 - unsigned char *p_in; 3866 - unsigned char *p_out; 3867 - int scanline_width; 3868 - int x; 3869 - int y; 3870 - unsigned char red; 3871 - unsigned char green; 3872 - unsigned char blue; 3873 - unsigned char gray; 3874 - unsigned char index; 3875 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3876 - *buffer = NULL; 3877 - if (img == NULL) 3878 - return GGRAPH_ERROR; 3879 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3880 - return GGRAPH_ERROR; 3881 - 3882 - scanline_width = img->width * 3; 3883 - buf = malloc (scanline_width * img->height); 3884 - if (!buf) 3885 - return GGRAPH_INSUFFICIENT_MEMORY; 3886 - for (y = 0; y < img->height; y++) 3887 - { 3888 - p_in = img->pixels + (y * img->scanline_width); 3889 - p_out = buf + (y * scanline_width); 3890 - for (x = 0; x < img->width; x++) 3891 - { 3892 - if (img->pixel_format == GG_PIXEL_RGB) 3893 - { 3894 - *p_out++ = *p_in++; /* red */ 3895 - *p_out++ = *p_in++; /* green */ 3896 - *p_out++ = *p_in++; /* blue */ 3897 - } 3898 - else if (img->pixel_format == GG_PIXEL_RGBA) 3899 - { 3900 - *p_out++ = *p_in++; /* red */ 3901 - *p_out++ = *p_in++; /* green */ 3902 - *p_out++ = *p_in++; /* blue */ 3903 - p_in++; /* discarding Alpha */ 3904 - } 3905 - else if (img->pixel_format == GG_PIXEL_ARGB) 3906 - { 3907 - p_in++; 3908 - *p_out++ = *p_in++; /* red */ 3909 - *p_out++ = *p_in++; /* green */ 3910 - *p_out++ = *p_in++; /* blue */ 3911 - } 3912 - else if (img->pixel_format == GG_PIXEL_BGR) 3913 - { 3914 - blue = *p_in++; 3915 - green = *p_in++; 3916 - red = *p_in++; 3917 - *p_out++ = red; 3918 - *p_out++ = green; 3919 - *p_out++ = blue; 3920 - } 3921 - else if (img->pixel_format == GG_PIXEL_BGRA) 3922 - { 3923 - blue = *p_in++; 3924 - green = *p_in++; 3925 - red = *p_in++; 3926 - p_in++; /* discarding Alpha */ 3927 - *p_out++ = red; 3928 - *p_out++ = green; 3929 - *p_out++ = blue; 3930 - } 3931 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 3932 - { 3933 - gray = *p_in++; 3934 - *p_out++ = gray; 3935 - *p_out++ = gray; 3936 - *p_out++ = gray; 3937 - } 3938 - else if (img->pixel_format == GG_PIXEL_PALETTE) 3939 - { 3940 - index = *p_in++; 3941 - *p_out++ = img->palette_red[index]; 3942 - *p_out++ = img->palette_green[index]; 3943 - *p_out++ = img->palette_blue[index]; 3944 - } 3945 - } 3946 - } 3947 - *buffer = buf; 3948 - return GGRAPH_OK; 3949 -} 3950 - 3951 -GGRAPH_DECLARE int 3952 -gGraphImageBufferReferenceRGBA (const void *ptr, unsigned char **buffer) 3953 -{ 3954 -/* 3955 -/ this function create a separate copy of the internal image buffer 3956 -/ if required color-space conversion will be applied 3957 -/ and the original image will be unaffected 3958 -*/ 3959 - unsigned char *buf; 3960 - unsigned char *p_in; 3961 - unsigned char *p_out; 3962 - int scanline_width; 3963 - int x; 3964 - int y; 3965 - unsigned char red; 3966 - unsigned char green; 3967 - unsigned char blue; 3968 - unsigned char alpha; 3969 - unsigned char gray; 3970 - unsigned char index; 3971 - gGraphImagePtr img = (gGraphImagePtr) ptr; 3972 - *buffer = NULL; 3973 - if (img == NULL) 3974 - return GGRAPH_ERROR; 3975 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 3976 - return GGRAPH_ERROR; 3977 - 3978 - scanline_width = img->width * 4; 3979 - buf = malloc (scanline_width * img->height); 3980 - if (!buf) 3981 - return GGRAPH_INSUFFICIENT_MEMORY; 3982 - for (y = 0; y < img->height; y++) 3983 - { 3984 - p_in = img->pixels + (y * img->scanline_width); 3985 - p_out = buf + (y * scanline_width); 3986 - for (x = 0; x < img->width; x++) 3987 - { 3988 - if (img->pixel_format == GG_PIXEL_RGB) 3989 - { 3990 - *p_out++ = *p_in++; /* red */ 3991 - *p_out++ = *p_in++; /* green */ 3992 - *p_out++ = *p_in++; /* blue */ 3993 - *p_out++ = 255; /* opaque Alpha */ 3994 - } 3995 - else if (img->pixel_format == GG_PIXEL_RGBA) 3996 - { 3997 - *p_out++ = *p_in++; /* red */ 3998 - *p_out++ = *p_in++; /* green */ 3999 - *p_out++ = *p_in++; /* blue */ 4000 - *p_out++ = *p_in++; /* Alpha */ 4001 - } 4002 - else if (img->pixel_format == GG_PIXEL_ARGB) 4003 - { 4004 - alpha = *p_in++; 4005 - *p_out++ = *p_in++; /* red */ 4006 - *p_out++ = *p_in++; /* green */ 4007 - *p_out++ = *p_in++; /* blue */ 4008 - *p_out++ = alpha; 4009 - } 4010 - else if (img->pixel_format == GG_PIXEL_BGR) 4011 - { 4012 - blue = *p_in++; 4013 - green = *p_in++; 4014 - red = *p_in++; 4015 - *p_out++ = red; 4016 - *p_out++ = green; 4017 - *p_out++ = blue; 4018 - *p_out++ = 255; /* opaque Alpha */ 4019 - } 4020 - else if (img->pixel_format == GG_PIXEL_BGRA) 4021 - { 4022 - blue = *p_in++; 4023 - green = *p_in++; 4024 - red = *p_in++; 4025 - alpha = *p_in++; 4026 - *p_out++ = red; 4027 - *p_out++ = green; 4028 - *p_out++ = blue; 4029 - *p_out++ = alpha; 4030 - } 4031 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 4032 - { 4033 - gray = *p_in++; 4034 - *p_out++ = gray; 4035 - *p_out++ = gray; 4036 - *p_out++ = gray; 4037 - *p_out++ = 255; /* opaque Alpha */ 4038 - } 4039 - else if (img->pixel_format == GG_PIXEL_PALETTE) 4040 - { 4041 - index = *p_in++; 4042 - *p_out++ = img->palette_red[index]; 4043 - *p_out++ = img->palette_green[index]; 4044 - *p_out++ = img->palette_blue[index]; 4045 - *p_out++ = 255; /* opaque Alpha */ 4046 - } 4047 - } 4048 - } 4049 - *buffer = buf; 4050 - return GGRAPH_OK; 4051 -} 4052 - 4053 -GGRAPH_DECLARE int 4054 -gGraphImageBufferReferenceARGB (const void *ptr, unsigned char **buffer) 4055 -{ 4056 -/* 4057 -/ this function create a separate copy of the internal image buffer 4058 -/ if required color-space conversion will be applied 4059 -/ and the original image will be unaffected 4060 -*/ 4061 - unsigned char *buf; 4062 - unsigned char *p_in; 4063 - unsigned char *p_out; 4064 - int scanline_width; 4065 - int x; 4066 - int y; 4067 - unsigned char red; 4068 - unsigned char green; 4069 - unsigned char blue; 4070 - unsigned char alpha; 4071 - unsigned char gray; 4072 - unsigned char index; 4073 - gGraphImagePtr img = (gGraphImagePtr) ptr; 4074 - *buffer = NULL; 4075 - if (img == NULL) 4076 - return GGRAPH_ERROR; 4077 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 4078 - return GGRAPH_ERROR; 4079 - 4080 - scanline_width = img->width * 4; 4081 - buf = malloc (scanline_width * img->height); 4082 - if (!buf) 4083 - return GGRAPH_INSUFFICIENT_MEMORY; 4084 - for (y = 0; y < img->height; y++) 4085 - { 4086 - p_in = img->pixels + (y * img->scanline_width); 4087 - p_out = buf + (y * scanline_width); 4088 - for (x = 0; x < img->width; x++) 4089 - { 4090 - if (img->pixel_format == GG_PIXEL_RGB) 4091 - { 4092 - *p_out++ = 255; /* opaque Alpha */ 4093 - *p_out++ = *p_in++; /* red */ 4094 - *p_out++ = *p_in++; /* green */ 4095 - *p_out++ = *p_in++; /* blue */ 4096 - } 4097 - else if (img->pixel_format == GG_PIXEL_RGBA) 4098 - { 4099 - alpha = *p_in++; 4100 - *p_out++ = *p_in++; /* red */ 4101 - *p_out++ = *p_in++; /* green */ 4102 - *p_out++ = *p_in++; /* blue */ 4103 - *p_in++ = alpha; 4104 - } 4105 - else if (img->pixel_format == GG_PIXEL_ARGB) 4106 - { 4107 - *p_out++ = *p_in++; /* Alpha */ 4108 - *p_out++ = *p_in++; /* red */ 4109 - *p_out++ = *p_in++; /* green */ 4110 - *p_out++ = *p_in++; /* blue */ 4111 - } 4112 - else if (img->pixel_format == GG_PIXEL_BGR) 4113 - { 4114 - blue = *p_in++; 4115 - green = *p_in++; 4116 - red = *p_in++; 4117 - *p_out++ = 255; /* opaque Alpha */ 4118 - *p_out++ = red; 4119 - *p_out++ = green; 4120 - *p_out++ = blue; 4121 - } 4122 - else if (img->pixel_format == GG_PIXEL_BGRA) 4123 - { 4124 - blue = *p_in++; 4125 - green = *p_in++; 4126 - red = *p_in++; 4127 - *p_out++ = *p_in++; /* Alpha */ 4128 - *p_out++ = red; 4129 - *p_out++ = green; 4130 - *p_out++ = blue; 4131 - } 4132 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 4133 - { 4134 - gray = *p_in++; 4135 - *p_out++ = 255; /* opaque Alpha */ 4136 - *p_out++ = gray; 4137 - *p_out++ = gray; 4138 - *p_out++ = gray; 4139 - } 4140 - else if (img->pixel_format == GG_PIXEL_PALETTE) 4141 - { 4142 - index = *p_in++; 4143 - *p_out++ = 255; /* opaque Alpha */ 4144 - *p_out++ = img->palette_red[index]; 4145 - *p_out++ = img->palette_green[index]; 4146 - *p_out++ = img->palette_blue[index]; 4147 - } 4148 - } 4149 - } 4150 - *buffer = buf; 4151 - return GGRAPH_OK; 4152 -} 4153 - 4154 -GGRAPH_DECLARE int 4155 -gGraphImageBufferReferenceBGR (const void *ptr, unsigned char **buffer) 4156 -{ 4157 -/* 4158 -/ this function create a separate copy of the internal image buffer 4159 -/ if required color-space conversion will be applied 4160 -/ and the original image will be unaffected 4161 -*/ 4162 - unsigned char *buf; 4163 - unsigned char *p_in; 4164 - unsigned char *p_out; 4165 - int scanline_width; 4166 - int x; 4167 - int y; 4168 - unsigned char red; 4169 - unsigned char green; 4170 - unsigned char blue; 4171 - unsigned char gray; 4172 - unsigned char index; 4173 - gGraphImagePtr img = (gGraphImagePtr) ptr; 4174 - *buffer = NULL; 4175 - if (img == NULL) 4176 - return GGRAPH_ERROR; 4177 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 4178 - return GGRAPH_ERROR; 4179 - 4180 - scanline_width = img->width * 3; 4181 - buf = malloc (scanline_width * img->height); 4182 - if (!buf) 4183 - return GGRAPH_INSUFFICIENT_MEMORY; 4184 - for (y = 0; y < img->height; y++) 4185 - { 4186 - p_in = img->pixels + (y * img->scanline_width); 4187 - p_out = buf + (y * scanline_width); 4188 - for (x = 0; x < img->width; x++) 4189 - { 4190 - if (img->pixel_format == GG_PIXEL_RGB) 4191 - { 4192 - red = *p_in++; 4193 - green = *p_in++; 4194 - blue = *p_in++; 4195 - *p_out++ = blue; 4196 - *p_out++ = green; 4197 - *p_out++ = red; 4198 - } 4199 - else if (img->pixel_format == GG_PIXEL_RGBA) 4200 - { 4201 - red = *p_in++; 4202 - green = *p_in++; 4203 - blue = *p_in++; 4204 - p_in++; /* discarding Alpha */ 4205 - *p_out++ = blue; 4206 - *p_out++ = green; 4207 - *p_out++ = red; 4208 - } 4209 - else if (img->pixel_format == GG_PIXEL_ARGB) 4210 - { 4211 - p_in++; 4212 - red = *p_in++; 4213 - green = *p_in++; 4214 - blue = *p_in++; 4215 - *p_out++ = blue; 4216 - *p_out++ = green; 4217 - *p_out++ = red; 4218 - } 4219 - else if (img->pixel_format == GG_PIXEL_BGR) 4220 - { 4221 - *p_out++ = *p_in++; /* blue */ 4222 - *p_out++ = *p_in++; /* green */ 4223 - *p_out++ = *p_in++; /* red */ 4224 - } 4225 - else if (img->pixel_format == GG_PIXEL_BGRA) 4226 - { 4227 - *p_out++ = *p_in++; /* blue */ 4228 - *p_out++ = *p_in++; /* green */ 4229 - *p_out++ = *p_in++; /* red */ 4230 - p_in++; /* discarding Alpha */ 4231 - } 4232 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 4233 - { 4234 - gray = *p_in++; 4235 - *p_out++ = gray; 4236 - *p_out++ = gray; 4237 - *p_out++ = gray; 4238 - } 4239 - else if (img->pixel_format == GG_PIXEL_PALETTE) 4240 - { 4241 - index = *p_in++; 4242 - *p_out++ = img->palette_blue[index]; 4243 - *p_out++ = img->palette_green[index]; 4244 - *p_out++ = img->palette_red[index]; 4245 - } 4246 - } 4247 - } 4248 - *buffer = buf; 4249 - return GGRAPH_OK; 4250 -} 4251 - 4252 -GGRAPH_DECLARE int 4253 -gGraphImageBufferReferenceBGRA (const void *ptr, unsigned char **buffer) 4254 -{ 4255 -/* 4256 -/ this function create a separate copy of the internal image buffer 4257 -/ if required color-space conversion will be applied 4258 -/ and the original image will be unaffected 4259 -*/ 4260 - unsigned char *buf; 4261 - unsigned char *p_in; 4262 - unsigned char *p_out; 4263 - int scanline_width; 4264 - int x; 4265 - int y; 4266 - unsigned char red; 4267 - unsigned char green; 4268 - unsigned char blue; 4269 - unsigned char alpha; 4270 - unsigned char gray; 4271 - unsigned char index; 4272 - gGraphImagePtr img = (gGraphImagePtr) ptr; 4273 - *buffer = NULL; 4274 - if (img == NULL) 4275 - return GGRAPH_ERROR; 4276 - if (img->signature != GG_IMAGE_MAGIC_SIGNATURE) 4277 - return GGRAPH_ERROR; 4278 - 4279 - scanline_width = img->width * 4; 4280 - buf = malloc (scanline_width * img->height); 4281 - if (!buf) 4282 - return GGRAPH_INSUFFICIENT_MEMORY; 4283 - for (y = 0; y < img->height; y++) 4284 - { 4285 - p_in = img->pixels + (y * img->scanline_width); 4286 - p_out = buf + (y * scanline_width); 4287 - for (x = 0; x < img->width; x++) 4288 - { 4289 - if (img->pixel_format == GG_PIXEL_RGB) 4290 - { 4291 - red = *p_in++; 4292 - green = *p_in++; 4293 - blue = *p_in++; 4294 - *p_out++ = blue; 4295 - *p_out++ = green; 4296 - *p_out++ = red; 4297 - *p_out++ = 255; /* opaque Alpha */ 4298 - } 4299 - else if (img->pixel_format == GG_PIXEL_RGBA) 4300 - { 4301 - red = *p_in++; 4302 - green = *p_in++; 4303 - blue = *p_in++; 4304 - *p_out++ = blue; 4305 - *p_out++ = green; 4306 - *p_out++ = red; 4307 - *p_out++ = *p_in++; /* Alpha */ 4308 - } 4309 - else if (img->pixel_format == GG_PIXEL_ARGB) 4310 - { 4311 - alpha = *p_in++; 4312 - red = *p_in++; 4313 - green = *p_in++; 4314 - blue = *p_in++; 4315 - *p_out++ = blue; 4316 - *p_out++ = green; 4317 - *p_out++ = red; 4318 - *p_out++ = alpha; 4319 - } 4320 - else if (img->pixel_format == GG_PIXEL_BGR) 4321 - { 4322 - *p_out++ = *p_in++; /* blue */ 4323 - *p_out++ = *p_in++; /* green */ 4324 - *p_out++ = *p_in++; /* red */ 4325 - *p_out++ = 255; /* opaque Alpha */ 4326 - } 4327 - else if (img->pixel_format == GG_PIXEL_BGRA) 4328 - { 4329 - *p_out++ = *p_in++; /* blue */ 4330 - *p_out++ = *p_in++; /* green */ 4331 - *p_out++ = *p_in++; /* red */ 4332 - *p_out++ = *p_in++; /* Alpha */ 4333 - } 4334 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 4335 - { 4336 - gray = *p_in++; 4337 - *p_out++ = gray; 4338 - *p_out++ = gray; 4339 - *p_out++ = gray; 4340 - *p_out++ = 255; /* opaque Alpha */ 4341 - } 4342 - else if (img->pixel_format == GG_PIXEL_PALETTE) 4343 - { 4344 - index = *p_in++; 4345 - *p_out++ = img->palette_blue[index]; 4346 - *p_out++ = img->palette_green[index]; 4347 - *p_out++ = img->palette_red[index]; 4348 - *p_out++ = 255; /* opaque Alpha */ 4349 - } 4350 - } 4351 - } 4352 - *buffer = buf; 4353 - return GGRAPH_OK; 4354 -} 4355 - 4356 -GGRAPH_DECLARE int 4357 -gGraphImageFromRawMemBuf (const void *mem_buf, int mem_buf_size, 4358 - const void **image_handle) 4359 -{ 4360 -/* importing an image from a RAW un-compressed memory buffer */ 4361 - gGraphImagePtr img = NULL; 4362 - int ret; 4363 - 4364 - *image_handle = NULL; 4365 - ret = gg_image_from_raw (mem_buf_size, mem_buf, &img); 4366 - if (ret != GGRAPH_OK) 4367 - return ret; 4368 - 4369 - *image_handle = img; 4370 - return GGRAPH_OK; 4371 -} 4372 - 4373 -GGRAPH_DECLARE int 4374 -gGraphIsRawImage (const void *mem_buf, int mem_buf_size) 4375 -{ 4376 -/* checks if this one is a RAW un-compressed memory buffer */ 4377 - unsigned char *p = (unsigned char *) mem_buf; 4378 - short start_signature; 4379 - short end_signature; 4380 - int endian_arch = gg_endian_arch (); 4381 - 4382 - if (mem_buf_size < (int) (sizeof (short) * 4)) 4383 - return GGRAPH_ERROR; 4384 - 4385 -/* checking the magic signature */ 4386 - start_signature = gg_import_int16 (p, 1, endian_arch); 4387 - p = (unsigned char *) mem_buf + mem_buf_size - sizeof (short); 4388 - end_signature = gg_import_int16 (p, 1, endian_arch); 4389 - if (start_signature == GG_MONOCHROME_START 4390 - && end_signature == GG_MONOCHROME_END) 4391 - return GGRAPH_OK; 4392 - if (start_signature == GG_ADAM7_1_RGB_START 4393 - && end_signature == GG_ADAM7_1_RGB_END) 4394 - return GGRAPH_OK; 4395 - if (start_signature == GG_ADAM7_3_RGB_START 4396 - && end_signature == GG_ADAM7_3_RGB_END) 4397 - return GGRAPH_OK; 4398 - if (start_signature == GG_ADAM7_5_RGB_START 4399 - && end_signature == GG_ADAM7_5_RGB_END) 4400 - return GGRAPH_OK; 4401 - if (start_signature == GG_ADAM7_1_GRAYSCALE_START 4402 - && end_signature == GG_ADAM7_1_GRAYSCALE_END) 4403 - return GGRAPH_OK; 4404 - if (start_signature == GG_ADAM7_3_GRAYSCALE_START 4405 - && end_signature == GG_ADAM7_3_GRAYSCALE_END) 4406 - return GGRAPH_OK; 4407 - if (start_signature == GG_ADAM7_5_GRAYSCALE_START 4408 - && end_signature == GG_ADAM7_5_GRAYSCALE_END) 4409 - return GGRAPH_OK; 4410 - if (start_signature == GG_ADAM7_1_PALETTE_START 4411 - && end_signature == GG_ADAM7_1_PALETTE_END) 4412 - return GGRAPH_OK; 4413 - if (start_signature == GG_ADAM7_3_PALETTE_START 4414 - && end_signature == GG_ADAM7_3_PALETTE_END) 4415 - return GGRAPH_OK; 4416 - if (start_signature == GG_ADAM7_5_PALETTE_START 4417 - && end_signature == GG_ADAM7_5_PALETTE_END) 4418 - return GGRAPH_OK; 4419 - if (start_signature == GG_ADAM7_1_INT16_START 4420 - && end_signature == GG_ADAM7_1_INT16_END) 4421 - return GGRAPH_OK; 4422 - if (start_signature == GG_ADAM7_3_INT16_START 4423 - && end_signature == GG_ADAM7_3_INT16_END) 4424 - return GGRAPH_OK; 4425 - if (start_signature == GG_ADAM7_5_INT16_START 4426 - && end_signature == GG_ADAM7_5_INT16_END) 4427 - return GGRAPH_OK; 4428 - if (start_signature == GG_ADAM7_1_UINT16_START 4429 - && end_signature == GG_ADAM7_1_UINT16_END) 4430 - return GGRAPH_OK; 4431 - if (start_signature == GG_ADAM7_3_UINT16_START 4432 - && end_signature == GG_ADAM7_3_UINT16_END) 4433 - return GGRAPH_OK; 4434 - if (start_signature == GG_ADAM7_5_UINT16_START 4435 - && end_signature == GG_ADAM7_5_UINT16_END) 4436 - return GGRAPH_OK; 4437 - if (start_signature == GG_ADAM7_1_INT32_START 4438 - && end_signature == GG_ADAM7_1_INT32_END) 4439 - return GGRAPH_OK; 4440 - if (start_signature == GG_ADAM7_3_INT32_START 4441 - && end_signature == GG_ADAM7_3_INT32_END) 4442 - return GGRAPH_OK; 4443 - if (start_signature == GG_ADAM7_5_INT32_START 4444 - && end_signature == GG_ADAM7_5_INT32_END) 4445 - return GGRAPH_OK; 4446 - if (start_signature == GG_ADAM7_1_UINT32_START 4447 - && end_signature == GG_ADAM7_1_UINT32_END) 4448 - return GGRAPH_OK; 4449 - if (start_signature == GG_ADAM7_3_UINT32_START 4450 - && end_signature == GG_ADAM7_3_UINT32_END) 4451 - return GGRAPH_OK; 4452 - if (start_signature == GG_ADAM7_5_UINT32_START 4453 - && end_signature == GG_ADAM7_5_UINT32_END) 4454 - return GGRAPH_OK; 4455 - if (start_signature == GG_ADAM7_1_FLOAT_START 4456 - && end_signature == GG_ADAM7_1_FLOAT_END) 4457 - return GGRAPH_OK; 4458 - if (start_signature == GG_ADAM7_3_FLOAT_START 4459 - && end_signature == GG_ADAM7_3_FLOAT_END) 4460 - return GGRAPH_OK; 4461 - if (start_signature == GG_ADAM7_5_FLOAT_START 4462 - && end_signature == GG_ADAM7_5_FLOAT_END) 4463 - return GGRAPH_OK; 4464 - if (start_signature == GG_ADAM7_1_DOUBLE_START 4465 - && end_signature == GG_ADAM7_1_DOUBLE_END) 4466 - return GGRAPH_OK; 4467 - if (start_signature == GG_ADAM7_3_DOUBLE_START 4468 - && end_signature == GG_ADAM7_3_DOUBLE_END) 4469 - return GGRAPH_OK; 4470 - if (start_signature == GG_ADAM7_5_DOUBLE_START 4471 - && end_signature == GG_ADAM7_5_DOUBLE_END) 4472 - return GGRAPH_OK; 4473 - 4474 - p = (unsigned char *) mem_buf; 4475 - start_signature = gg_import_int16 (p, 0, endian_arch); 4476 - p = (unsigned char *) mem_buf + mem_buf_size - sizeof (short); 4477 - end_signature = gg_import_int16 (p, 0, endian_arch); 4478 - if (start_signature == GG_ADAM7_0_RGB_START 4479 - && end_signature == GG_ADAM7_0_RGB_END) 4480 - return GGRAPH_OK; 4481 - if (start_signature == GG_ADAM7_2_RGB_START 4482 - && end_signature == GG_ADAM7_2_RGB_END) 4483 - return GGRAPH_OK; 4484 - if (start_signature == GG_ADAM7_4_RGB_START 4485 - && end_signature == GG_ADAM7_4_RGB_END) 4486 - return GGRAPH_OK; 4487 - if (start_signature == GG_ADAM7_6_RGB_START 4488 - && end_signature == GG_ADAM7_6_RGB_END) 4489 - return GGRAPH_OK; 4490 - if (start_signature == GG_ADAM7_0_GRAYSCALE_START 4491 - && end_signature == GG_ADAM7_0_GRAYSCALE_END) 4492 - return GGRAPH_OK; 4493 - if (start_signature == GG_ADAM7_2_GRAYSCALE_START 4494 - && end_signature == GG_ADAM7_2_GRAYSCALE_END) 4495 - return GGRAPH_OK; 4496 - if (start_signature == GG_ADAM7_4_GRAYSCALE_START 4497 - && end_signature == GG_ADAM7_4_GRAYSCALE_END) 4498 - return GGRAPH_OK; 4499 - if (start_signature == GG_ADAM7_6_GRAYSCALE_START 4500 - && end_signature == GG_ADAM7_6_GRAYSCALE_END) 4501 - return GGRAPH_OK; 4502 - if (start_signature == GG_ADAM7_0_PALETTE_START 4503 - && end_signature == GG_ADAM7_0_PALETTE_END) 4504 - return GGRAPH_OK; 4505 - if (start_signature == GG_ADAM7_2_PALETTE_START 4506 - && end_signature == GG_ADAM7_2_PALETTE_END) 4507 - return GGRAPH_OK; 4508 - if (start_signature == GG_ADAM7_4_PALETTE_START 4509 - && end_signature == GG_ADAM7_4_PALETTE_END) 4510 - return GGRAPH_OK; 4511 - if (start_signature == GG_ADAM7_6_PALETTE_START 4512 - && end_signature == GG_ADAM7_6_PALETTE_END) 4513 - return GGRAPH_OK; 4514 - if (start_signature == GG_ADAM7_0_INT16_START 4515 - && end_signature == GG_ADAM7_0_INT16_END) 4516 - return GGRAPH_OK; 4517 - if (start_signature == GG_ADAM7_2_INT16_START 4518 - && end_signature == GG_ADAM7_2_INT16_END) 4519 - return GGRAPH_OK; 4520 - if (start_signature == GG_ADAM7_4_INT16_START 4521 - && end_signature == GG_ADAM7_4_INT16_END) 4522 - return GGRAPH_OK; 4523 - if (start_signature == GG_ADAM7_6_INT16_START 4524 - && end_signature == GG_ADAM7_6_INT16_END) 4525 - return GGRAPH_OK; 4526 - if (start_signature == GG_ADAM7_0_UINT16_START 4527 - && end_signature == GG_ADAM7_0_UINT16_END) 4528 - return GGRAPH_OK; 4529 - if (start_signature == GG_ADAM7_2_UINT16_START 4530 - && end_signature == GG_ADAM7_2_UINT16_END) 4531 - return GGRAPH_OK; 4532 - if (start_signature == GG_ADAM7_4_UINT16_START 4533 - && end_signature == GG_ADAM7_4_UINT16_END) 4534 - return GGRAPH_OK; 4535 - if (start_signature == GG_ADAM7_6_UINT16_START 4536 - && end_signature == GG_ADAM7_6_UINT16_END) 4537 - return GGRAPH_OK; 4538 - if (start_signature == GG_ADAM7_0_INT32_START 4539 - && end_signature == GG_ADAM7_0_INT32_END) 4540 - return GGRAPH_OK; 4541 - if (start_signature == GG_ADAM7_2_INT32_START 4542 - && end_signature == GG_ADAM7_2_INT32_END) 4543 - return GGRAPH_OK; 4544 - if (start_signature == GG_ADAM7_4_INT32_START 4545 - && end_signature == GG_ADAM7_4_INT32_END) 4546 - return GGRAPH_OK; 4547 - if (start_signature == GG_ADAM7_6_INT32_START 4548 - && end_signature == GG_ADAM7_6_INT32_END) 4549 - return GGRAPH_OK; 4550 - if (start_signature == GG_ADAM7_0_UINT32_START 4551 - && end_signature == GG_ADAM7_0_UINT32_END) 4552 - return GGRAPH_OK; 4553 - if (start_signature == GG_ADAM7_2_UINT32_START 4554 - && end_signature == GG_ADAM7_2_UINT32_END) 4555 - return GGRAPH_OK; 4556 - if (start_signature == GG_ADAM7_4_UINT32_START 4557 - && end_signature == GG_ADAM7_4_UINT32_END) 4558 - return GGRAPH_OK; 4559 - if (start_signature == GG_ADAM7_6_UINT32_START 4560 - && end_signature == GG_ADAM7_6_UINT32_END) 4561 - return GGRAPH_OK; 4562 - if (start_signature == GG_ADAM7_0_FLOAT_START 4563 - && end_signature == GG_ADAM7_0_FLOAT_END) 4564 - return GGRAPH_OK; 4565 - if (start_signature == GG_ADAM7_2_FLOAT_START 4566 - && end_signature == GG_ADAM7_2_FLOAT_END) 4567 - return GGRAPH_OK; 4568 - if (start_signature == GG_ADAM7_4_FLOAT_START 4569 - && end_signature == GG_ADAM7_4_FLOAT_END) 4570 - return GGRAPH_OK; 4571 - if (start_signature == GG_ADAM7_6_FLOAT_START 4572 - && end_signature == GG_ADAM7_6_FLOAT_END) 4573 - return GGRAPH_OK; 4574 - if (start_signature == GG_ADAM7_0_DOUBLE_START 4575 - && end_signature == GG_ADAM7_0_DOUBLE_END) 4576 - return GGRAPH_OK; 4577 - if (start_signature == GG_ADAM7_2_DOUBLE_START 4578 - && end_signature == GG_ADAM7_2_DOUBLE_END) 4579 - return GGRAPH_OK; 4580 - if (start_signature == GG_ADAM7_4_DOUBLE_START 4581 - && end_signature == GG_ADAM7_4_DOUBLE_END) 4582 - return GGRAPH_OK; 4583 - if (start_signature == GG_ADAM7_6_DOUBLE_START 4584 - && end_signature == GG_ADAM7_6_DOUBLE_END) 4585 - return GGRAPH_OK; 4586 - 4587 - return GGRAPH_ERROR; 4588 -} 4589 - 4590 -GGRAPH_DECLARE int 4591 -gGraphOutputPixelsToStripImage (const void *ptr_in, const void *ptr_out, 4592 - int in_row, int out_row) 4593 -{ 4594 -/* copying pixels from a memory image into a Strip Image */ 4595 - unsigned char *p_in; 4596 - unsigned char *p_out; 4597 - gGraphImagePtr img_in = (gGraphImagePtr) ptr_in; 4598 - gGraphStripImagePtr img_out = (gGraphStripImagePtr) ptr_out; 4599 - 4600 - if (img_in == NULL) 4601 - return GGRAPH_INVALID_IMAGE; 4602 - if (img_out == NULL) 4603 - return GGRAPH_INVALID_IMAGE; 4604 - if (img_in->signature != GG_IMAGE_MAGIC_SIGNATURE) 4605 - return GGRAPH_INVALID_IMAGE; 4606 - if (img_out->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 4607 - return GGRAPH_INVALID_IMAGE; 4608 - if (img_in->pixel_format != img_out->pixel_format) 4609 - return GGRAPH_INVALID_IMAGE; 4610 - if (img_in->width != img_out->width) 4611 - return GGRAPH_INVALID_IMAGE; 4612 - 4613 - if (in_row < 0 || in_row >= img_in->height) 4614 - return GGRAPH_ERROR; 4615 - if (out_row < 0 || out_row >= img_out->rows_per_block) 4616 - return GGRAPH_ERROR; 4617 - 4618 - p_in = img_in->pixels + (in_row * img_in->scanline_width); 4619 - p_out = img_out->pixels + (out_row * img_out->scanline_width); 4620 - memcpy (p_out, p_in, img_in->scanline_width); 4621 - img_out->current_available_rows = out_row + 1; 4622 - 4623 - return GGRAPH_OK; 4624 -} 4625 - 4626 -static unsigned char 4627 -feed_palette (gGraphImagePtr img, unsigned char red, unsigned char green, 4628 - unsigned char blue) 4629 -{ 4630 -/* updating a palette */ 4631 - unsigned char i; 4632 - for (i = 0; i < img->max_palette; i++) 4633 - { 4634 - /* testing if this color is already present */ 4635 - if (img->palette_red[i] == red && img->palette_green[i] == green 4636 - && img->palette_blue[i] == blue) 4637 - return i; 4638 - } 4639 -/* inserting a new color */ 4640 - i = img->max_palette; 4641 - img->palette_red[i] = red; 4642 - img->palette_green[i] = green; 4643 - img->palette_blue[i] = blue; 4644 - img->max_palette += 1; 4645 - return i; 4646 -} 4647 - 4648 -GGRAPH_DECLARE int 4649 -gGraphInputPixelsFromStripImage (const void *ptr_in, const void *ptr_out, 4650 - int in_col) 4651 -{ 4652 -/* copying pixels from a Strip Image into a memory image */ 4653 - unsigned char *p_in; 4654 - unsigned char *p_out; 4655 - int y; 4656 - int x; 4657 - int is_monochrome = 0; 4658 - int is_monochrome_minisblack = 0; 4659 - gGraphStripImagePtr img_in = (gGraphStripImagePtr) ptr_in; 4660 - gGraphImagePtr img_out = (gGraphImagePtr) ptr_out; 4661 - 4662 - if (img_in == NULL) 4663 - return GGRAPH_INVALID_IMAGE; 4664 - if (img_out == NULL) 4665 - return GGRAPH_INVALID_IMAGE; 4666 - if (img_in->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 4667 - return GGRAPH_INVALID_IMAGE; 4668 - if (img_out->signature != GG_IMAGE_MAGIC_SIGNATURE) 4669 - return GGRAPH_INVALID_IMAGE; 4670 - if (img_in->rows_per_block < img_out->height) 4671 - return GGRAPH_INVALID_IMAGE; 4672 - if (img_in->pixel_format != img_out->pixel_format) 4673 - return GGRAPH_INVALID_IMAGE; 4674 - 4675 - if (in_col < 0 || in_col >= img_in->width) 4676 - return GGRAPH_ERROR; 4677 - 4678 - if (img_in->pixel_format == GG_PIXEL_PALETTE) 4679 - { 4680 - is_monochrome = 1; 4681 - if (img_in->max_palette == 2 && img_in->palette_red[0] == 0 4682 - && img_in->palette_green[0] == 0 4683 - && img_in->palette_blue[0] == 0 4684 - && img_in->palette_red[1] == 255 4685 - && img_in->palette_green[1] == 255 4686 - && img_in->palette_blue[1] == 255) 4687 - is_monochrome_minisblack = 1; 4688 - if (img_in->max_palette == 2 && img_in->palette_red[0] == 255 4689 - && img_in->palette_green[0] == 255 4690 - && img_in->palette_blue[0] == 255 4691 - && img_in->palette_red[1] == 0 4692 - && img_in->palette_green[1] == 0 && img_in->palette_blue[1] == 0) 4693 - is_monochrome_minisblack = 0; 4694 - } 4695 - 4696 - if (is_monochrome) 4697 - { 4698 - /* feeding a monochrome image */ 4699 - for (y = 0; y < img_out->height; y++) 4700 - { 4701 - p_in = img_in->pixels + (y * img_in->scanline_width) + in_col; 4702 - p_out = img_out->pixels + (y * img_out->scanline_width); 4703 - for (x = 0; x < img_out->width; x++) 4704 - *p_out++ = *p_in++; 4705 - } 4706 - img_out->max_palette = 2; 4707 - if (is_monochrome_minisblack) 4708 - { 4709 - img_out->palette_red[0] = 0; 4710 - img_out->palette_green[0] = 0; 4711 - img_out->palette_blue[0] = 0; 4712 - img_out->palette_red[1] = 255; 4713 - img_out->palette_green[1] = 255; 4714 - img_out->palette_blue[1] = 255; 4715 - } 4716 - else 4717 - { 4718 - img_out->palette_red[0] = 255; 4719 - img_out->palette_green[0] = 255; 4720 - img_out->palette_blue[0] = 255; 4721 - img_out->palette_red[1] = 0; 4722 - img_out->palette_green[1] = 0; 4723 - img_out->palette_blue[1] = 0; 4724 - } 4725 - } 4726 - else if (img_in->pixel_format == GG_PIXEL_PALETTE) 4727 - { 4728 - /* feeding a palette image */ 4729 - for (y = 0; y < img_out->height; y++) 4730 - { 4731 - p_in = img_in->pixels + (y * img_in->scanline_width) + in_col; 4732 - p_out = img_out->pixels + (y * img_out->scanline_width); 4733 - for (x = 0; x < img_out->width; x++) 4734 - { 4735 - int i_idx = *p_in++; 4736 - *p_out++ = 4737 - feed_palette (img_out, img_in->palette_red[i_idx], 4738 - img_in->palette_green[i_idx], 4739 - img_in->palette_blue[i_idx]); 4740 - } 4741 - } 4742 - } 4743 - else 4744 - { 4745 - for (y = 0; y < img_out->height; y++) 4746 - { 4747 - p_in = 4748 - img_in->pixels + (y * img_in->scanline_width) + 4749 - (in_col * img_in->pixel_size); 4750 - p_out = img_out->pixels + (y * img_out->scanline_width); 4751 - memcpy (p_out, p_in, img_out->scanline_width); 4752 - } 4753 - } 4754 - 4755 - return GGRAPH_OK; 4756 -} 4757 - 4758 -GGRAPH_DECLARE int 4759 -gGraphImageFromStripImage (const void *ptr_in, int color_space, 4760 - int sample_format, int bits_per_sample, 4761 - int samples_per_pixel, int start_line, 4762 - const void **ptr_out) 4763 -{ 4764 -/* creating an Image from a StripImage (may be, converting pixel format) */ 4765 - int width; 4766 - int height; 4767 - int pixel_format; 4768 - int x; 4769 - int y; 4770 - gGraphImagePtr img_out = NULL; 4771 - gGraphStripImagePtr img_in = (gGraphStripImagePtr) ptr_in; 4772 - 4773 - *ptr_out = NULL; 4774 - if (img_in == NULL) 4775 - return GGRAPH_INVALID_IMAGE; 4776 - if (img_in->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 4777 - return GGRAPH_INVALID_IMAGE; 4778 - 4779 - width = img_in->width; 4780 - height = img_in->current_available_rows; 4781 - switch (color_space) 4782 - { 4783 - case GGRAPH_COLORSPACE_MONOCHROME: 4784 - case GGRAPH_COLORSPACE_PALETTE: 4785 - pixel_format = GG_PIXEL_PALETTE; 4786 - break; 4787 - case GGRAPH_COLORSPACE_GRAYSCALE: 4788 - pixel_format = GG_PIXEL_GRAYSCALE; 4789 - break; 4790 - case GGRAPH_COLORSPACE_TRUECOLOR: 4791 - case GGRAPH_COLORSPACE_TRUECOLOR_ALPHA: 4792 - pixel_format = GG_PIXEL_RGB; 4793 - break; 4794 - case GGRAPH_COLORSPACE_GRID: 4795 - pixel_format = GG_PIXEL_GRID; 4796 - break; 4797 - default: 4798 - pixel_format = GG_PIXEL_UNKNOWN; 4799 - break; 4800 - }; 4801 - if (pixel_format == GG_PIXEL_UNKNOWN) 4802 - return GGRAPH_ERROR; 4803 - if (img_in->pixel_format == GG_PIXEL_GRID || pixel_format == GG_PIXEL_GRID) 4804 - { 4805 - if (img_in->pixel_format == GG_PIXEL_GRID 4806 - && pixel_format == GG_PIXEL_GRID) 4807 - ; 4808 - else 4809 - return GGRAPH_ERROR; 4810 - } 4811 - if (pixel_format == GG_PIXEL_RGB) 4812 - { 4813 - if (sample_format == GGRAPH_SAMPLE_UINT && bits_per_sample == 8 4814 - && samples_per_pixel == 3) 4815 - ; 4816 - else 4817 - return GGRAPH_ERROR; 4818 - } 4819 - if (pixel_format == GG_PIXEL_GRAYSCALE) 4820 - { 4821 - if (sample_format == GGRAPH_SAMPLE_UINT && bits_per_sample == 8 4822 - && samples_per_pixel == 1) 4823 - ; 4824 - else 4825 - return GGRAPH_ERROR; 4826 - } 4827 - if (pixel_format == GG_PIXEL_PALETTE) 4828 - { 4829 - if (sample_format == GGRAPH_SAMPLE_UINT && samples_per_pixel == 1) 4830 - { 4831 - if (bits_per_sample == 1 || bits_per_sample == 2 4832 - || bits_per_sample == 4 || bits_per_sample == 8) 4833 - ; 4834 - else 4835 - return GGRAPH_ERROR; 4836 - } 4837 - else 4838 - return GGRAPH_ERROR; 4839 - } 4840 - if (pixel_format == GG_PIXEL_GRID) 4841 - { 4842 - if (sample_format == GGRAPH_SAMPLE_UINT && bits_per_sample == 16 4843 - && samples_per_pixel == 1) 4844 - ; 4845 - else if (sample_format == GGRAPH_SAMPLE_UINT && bits_per_sample == 32 4846 - && samples_per_pixel == 1) 4847 - ; 4848 - else if (sample_format == GGRAPH_SAMPLE_INT && bits_per_sample == 16 4849 - && samples_per_pixel == 1) 4850 - ; 4851 - else if (sample_format == GGRAPH_SAMPLE_INT && bits_per_sample == 32 4852 - && samples_per_pixel == 1) 4853 - ; 4854 - else if (sample_format == GGRAPH_SAMPLE_FLOAT && bits_per_sample == 32 4855 - && samples_per_pixel == 1) 4856 - ; 4857 - else if (sample_format == GGRAPH_SAMPLE_FLOAT && bits_per_sample == 64 4858 - && samples_per_pixel == 1) 4859 - ; 4860 - else 4861 - return GGRAPH_ERROR; 4862 - } 4863 - 4864 - img_out = 4865 - gg_image_create (pixel_format, width, height, bits_per_sample, 4866 - samples_per_pixel, sample_format, NULL, NULL); 4867 - if (!img_out) 4868 - return GGRAPH_INSUFFICIENT_MEMORY; 4869 - if (img_in->is_georeferenced) 4870 - { 4871 - /* setting up georeferencing infos */ 4872 - img_out->srid = img_in->srid; 4873 - img_out->pixel_x_size = img_in->pixel_x_size; 4874 - img_out->pixel_y_size = img_in->pixel_y_size; 4875 - img_out->upper_left_x = img_in->upper_left_x; 4876 - img_out->upper_left_y = 4877 - img_in->upper_left_y - 4878 - ((double) start_line * img_in->pixel_y_size); 4879 - img_out->is_georeferenced = 1; 4880 - } 4881 - 4882 - if (img_out->pixel_format == GG_PIXEL_GRID) 4883 - ; 4884 - else if (img_out->pixel_format == GG_PIXEL_PALETTE) 4885 - { 4886 - if (img_in->bits_per_sample <= img_out->bits_per_sample) 4887 - ; 4888 - else 4889 - return GGRAPH_ERROR; 4890 - } 4891 - 4892 - for (y = 0; y < height; y++) 4893 - { 4894 - unsigned char *p_in = img_in->pixels + (y * img_in->scanline_width); 4895 - unsigned char *p_out = 4896 - img_out->pixels + (y * img_out->scanline_width); 4897 - unsigned char red; 4898 - unsigned char green; 4899 - unsigned char blue; 4900 - unsigned char idx; 4901 - for (x = 0; x < width; x++) 4902 - { 4903 - /* fetching the input pixel */ 4904 - switch (img_in->pixel_format) 4905 - { 4906 - case GG_PIXEL_RGB: 4907 - red = *p_in++; 4908 - green = *p_in++; 4909 - blue = *p_in++; 4910 - break; 4911 - case GG_PIXEL_RGBA: 4912 - red = *p_in++; 4913 - green = *p_in++; 4914 - blue = *p_in++; 4915 - p_in++; /* skipping alpha */ 4916 - break; 4917 - case GG_PIXEL_ARGB: 4918 - p_in++; /* skipping alpha */ 4919 - red = *p_in++; 4920 - green = *p_in++; 4921 - blue = *p_in++; 4922 - break; 4923 - case GG_PIXEL_BGR: 4924 - blue = *p_in++; 4925 - green = *p_in++; 4926 - red = *p_in++; 4927 - break; 4928 - case GG_PIXEL_BGRA: 4929 - blue = *p_in++; 4930 - green = *p_in++; 4931 - red = *p_in++; 4932 - p_in++; /* skipping alpha */ 4933 - break; 4934 - case GG_PIXEL_GRAYSCALE: 4935 - red = *p_in++; 4936 - green = red; 4937 - blue = red; 4938 - break; 4939 - case GG_PIXEL_PALETTE: 4940 - idx = *p_in++; 4941 - red = img_in->palette_red[idx]; 4942 - green = img_in->palette_green[idx]; 4943 - blue = img_in->palette_blue[idx]; 4944 - break; 4945 - }; 4946 - /* storing the output pixel */ 4947 - switch (img_out->pixel_format) 4948 - { 4949 - case GG_PIXEL_RGB: 4950 - *p_out++ = red; 4951 - *p_out++ = green; 4952 - *p_out++ = blue; 4953 - break; 4954 - case GG_PIXEL_GRAYSCALE: 4955 - *p_out++ = to_grayscale2 (red, green, blue); 4956 - break; 4957 - case GG_PIXEL_PALETTE: 4958 - *p_out++ = feed_palette (img_out, red, green, blue); 4959 - break; 4960 - }; 4961 - } 4962 - } 4963 - 4964 - *ptr_out = img_out; 4965 - return GGRAPH_OK; 4966 -}
Deleted src/gaiagraphics_color_rules.c.
1 -/* 2 -/ gaiagraphics_color_rules.c 3 -/ 4 -/ GRIDS color rules helpers 5 -/ 6 -/ version 1.0, 2010 August 31 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdio.h> 28 -#include <string.h> 29 -#include <float.h> 30 -#include <math.h> 31 -#include <stdlib.h> 32 - 33 -#ifdef _WIN32 34 -#include <windows.h> 35 -#include <process.h> 36 -#include <io.h> 37 -#else 38 -#include <pthread.h> 39 -#include <unistd.h> 40 -#endif 41 - 42 -#include "gaiagraphics.h" 43 -#include "gaiagraphics_internals.h" 44 - 45 -#define GG_MAX_THREADS 64 46 - 47 -#define LANDSAT_RED 1 48 -#define LANDSAT_GREEN 2 49 -#define LANDSAT_BLUE 3 50 -#define LANDSAT_PANCHRO 4 51 - 52 -struct thread_grid_render 53 -{ 54 -/* a struct used by grid rendering threads */ 55 - gGraphColorMapPtr color_map; 56 - double no_data_value; 57 - int sample_format; 58 - int bits_per_sample; 59 - void *pixels; 60 - int base; 61 - int num_pixels; 62 - unsigned char *p_rgb; 63 -}; 64 - 65 -struct thread_shaded_relief_render 66 -{ 67 -/* a struct used by shader relief rendering threads */ 68 - gGraphShadedReliefTripleRowPtr triple_row; 69 - double altRadians; 70 - double azRadians; 71 - int base; 72 - int num_pixels; 73 - unsigned char *p_rgb; 74 -}; 75 - 76 -struct thread_landsat_recalibrate 77 -{ 78 -/* a struct used by Landsat recalibrate */ 79 - gGraphStripImagePtr img_red; 80 - gGraphStripImagePtr img_green; 81 - gGraphStripImagePtr img_blue; 82 - gGraphStripImagePtr img_out; 83 - int min_row; 84 - int max_row; 85 - int width; 86 - unsigned char value; 87 - double lmin_red; 88 - double lmax_red; 89 - double qcalmin_red; 90 - double qcalmax_red; 91 - int gain_low_red; 92 - double spectral_irradiance_red; 93 - double low_gain_factor_red; 94 - double high_gain_factor_red; 95 - unsigned char recalibration_min_red; 96 - unsigned char recalibration_max_red; 97 - double lmin_green; 98 - double lmax_green; 99 - double qcalmin_green; 100 - double qcalmax_green; 101 - int gain_low_green; 102 - double spectral_irradiance_green; 103 - double low_gain_factor_green; 104 - double high_gain_factor_green; 105 - unsigned char recalibration_min_green; 106 - unsigned char recalibration_max_green; 107 - double lmin_blue; 108 - double lmax_blue; 109 - double qcalmin_blue; 110 - double qcalmax_blue; 111 - int gain_low_blue; 112 - double spectral_irradiance_blue; 113 - double low_gain_factor_blue; 114 - double high_gain_factor_blue; 115 - unsigned char recalibration_min_blue; 116 - unsigned char recalibration_max_blue; 117 - double lmin_panchro; 118 - double lmax_panchro; 119 - double qcalmin_panchro; 120 - double qcalmax_panchro; 121 - int gain_low_panchro; 122 - double spectral_irradiance_panchro; 123 - double low_gain_factor_panchro; 124 - double high_gain_factor_panchro; 125 - unsigned char recalibration_min_panchro; 126 - unsigned char recalibration_max_panchro; 127 - double sun_distance; 128 - double sun_elevation; 129 - int band; 130 -}; 131 - 132 -static int 133 -color_rule_compare1 (double min1, double max1, double min2, double max2) 134 -{ 135 -/* evaluting the range */ 136 - if (min1 == min2 && max1 == max2) 137 - return 0; 138 - if (min1 > min2) 139 - return 1; 140 - if (min1 == min2 && max1 > max2) 141 - return 1; 142 - return -1; 143 -} 144 - 145 -static int 146 -cmp_color_rules1 (const void *p1, const void *p2) 147 -{ 148 -/* compares two Color Entries [for QSORT] */ 149 - gGraphColorMapEntryPtr pR1 = *((gGraphColorMapEntryPtr *) p1); 150 - gGraphColorMapEntryPtr pR2 = *((gGraphColorMapEntryPtr *) p2); 151 - return color_rule_compare1 (pR1->min, pR2->max, pR2->min, pR2->max); 152 -} 153 - 154 -static int 155 -color_rule_compare2 (double value, double min, double max) 156 -{ 157 -/* evaluting the value */ 158 - if (value < min) 159 - return -1; 160 - if (value > max) 161 - return 1; 162 - return 0; 163 -} 164 - 165 -static int 166 -cmp_color_rules2 (const void *p1, const void *p2) 167 -{ 168 -/* compares two Color Entries [for BSEARCH] */ 169 - gGraphColorMapEntryPtr pR1 = (gGraphColorMapEntryPtr) p1; 170 - gGraphColorMapEntryPtr pR2 = *((gGraphColorMapEntryPtr *) p2); 171 - return color_rule_compare2 (pR1->min, pR2->min, pR2->max); 172 -} 173 - 174 -GGRAPH_PRIVATE gGraphColorRulePtr 175 -gg_color_rule_create (void) 176 -{ 177 -/* allocating an empty Color Rule */ 178 - gGraphColorRulePtr ptr = malloc (sizeof (gGraphColorRule)); 179 - if (!ptr) 180 - return NULL; 181 - ptr->signature = GG_COLOR_RULE_MAGIC_SIGNATURE; 182 - ptr->first = NULL; 183 - ptr->last = NULL; 184 - ptr->needs_range = 0; 185 - ptr->no_data_red = 255; 186 - ptr->no_data_green = 255; 187 - ptr->no_data_blue = 255; 188 - return ptr; 189 -} 190 - 191 -GGRAPH_PRIVATE void 192 -gg_color_rule_destroy (gGraphColorRulePtr ptr) 193 -{ 194 -/* destroying a Color Rule */ 195 - gGraphColorRuleItemPtr p; 196 - gGraphColorRuleItemPtr pn; 197 - if (!ptr) 198 - return; 199 - p = ptr->first; 200 - while (p) 201 - { 202 - pn = p->next; 203 - free (p); 204 - p = pn; 205 - } 206 - free (ptr); 207 -} 208 - 209 -GGRAPH_PRIVATE gGraphColorMapPtr 210 -gg_color_map_create (void) 211 -{ 212 -/* allocating an empty Color Map */ 213 - gGraphColorMapPtr ptr = malloc (sizeof (gGraphColorMap)); 214 - if (!ptr) 215 - return NULL; 216 - ptr->signature = GG_COLOR_MAP_MAGIC_SIGNATURE; 217 - ptr->first = NULL; 218 - ptr->last = NULL; 219 - ptr->no_data_red = 255; 220 - ptr->no_data_green = 255; 221 - ptr->no_data_blue = 255; 222 - ptr->not_found_red = 255; 223 - ptr->not_found_green = 255; 224 - ptr->not_found_blue = 255; 225 - ptr->num_entries = 0; 226 - ptr->array = NULL; 227 - return ptr; 228 -} 229 - 230 -GGRAPH_PRIVATE void 231 -gg_color_map_destroy (gGraphColorMapPtr ptr) 232 -{ 233 -/* destroying a Color Map */ 234 - gGraphColorMapEntryPtr p; 235 - gGraphColorMapEntryPtr pn; 236 - if (!ptr) 237 - return; 238 - p = ptr->first; 239 - while (p) 240 - { 241 - pn = p->next; 242 - free (p); 243 - p = pn; 244 - } 245 - if (ptr->array) 246 - free (ptr->array); 247 - free (ptr); 248 -} 249 - 250 -static char * 251 -string_tokenizer (char *string, char *delimiters, char **ptr) 252 -{ 253 -/* breaking a string into distinct tokens */ 254 - char *start = NULL; 255 - char *p; 256 - if (*ptr != NULL) 257 - p = *ptr; 258 - else 259 - p = string; 260 - 261 - if (p == NULL) 262 - return NULL; 263 - 264 - while (1) 265 - { 266 - int sep = 0; 267 - char *pd = delimiters; 268 - 269 - if (*p == '\0') 270 - { 271 - /* last token end */ 272 - *ptr = p; 273 - break; 274 - } 275 - 276 - while (*pd != '\0') 277 - { 278 - if (*p == *pd) 279 - { 280 - /* found a separator char */ 281 - sep = 1; 282 - break; 283 - } 284 - pd++; 285 - } 286 - if (sep) 287 - { 288 - if (start) 289 - { 290 - /* token end */ 291 - *p = '\0'; 292 - *ptr = p + 1; 293 - break; 294 - } 295 - } 296 - else 297 - { 298 - if (!start) 299 - { 300 - /* token start */ 301 - start = p; 302 - } 303 - } 304 - p++; 305 - } 306 - 307 - return start; 308 -} 309 - 310 -static int 311 -is_no_data_token (const char *token) 312 -{ 313 -/* checking if this one is a NoData declaration */ 314 - char buf[8]; 315 - int i; 316 - if (strlen (token) != 2) 317 - return 0; 318 - strcpy (buf, token); 319 - for (i = 0; i < (int) strlen (buf); i++) 320 - { 321 - if (buf[i] >= 'A' && buf[i] <= 'Z') 322 - buf[i] = 'a' + (buf[i] - 'A'); 323 - } 324 - if (strcmp (buf, "nv") == 0) 325 - return 1; 326 - return 0; 327 -} 328 - 329 -static int 330 -token_to_double (const char *str, double *value) 331 -{ 332 -/* attempting to convert from string to double */ 333 - const char *p = str; 334 - int error = 0; 335 - int digits = 0; 336 - int comma = 0; 337 - int sign = 0; 338 - while (*p != '\0') 339 - { 340 - if (*p >= '0' && *p <= '9') 341 - digits++; 342 - else if (*p == '.') 343 - comma++; 344 - else if (*p == '-' || *p == '+') 345 - { 346 - if (digits == 0) 347 - sign++; 348 - else 349 - error = 1; 350 - } 351 - else 352 - error = 1; 353 - p++; 354 - } 355 - if (digits > 0 && sign < 2 && comma < 2 && error == 0) 356 - { 357 - *value = atof (str); 358 - return 1; 359 - } 360 - return 0; 361 -} 362 - 363 -static int 364 -is_percent_token (const char *token, double *perc_value) 365 -{ 366 -/* checking if this one is a percentual value */ 367 - if (token[strlen (token) - 1] == '%') 368 - { 369 - double value; 370 - char buf[128]; 371 - strcpy (buf, token); 372 - buf[strlen (token) - 1] = '\0'; 373 - if (!token_to_double (buf, &value)) 374 - return 0; 375 - *perc_value = value; 376 - return 1; 377 - } 378 - return 0; 379 -} 380 - 381 -static int 382 -is_color_name_token (const char *token, unsigned char *red, 383 - unsigned char *green, unsigned char *blue) 384 -{ 385 -/* checking if this one is a color name */ 386 - char buf[32]; 387 - int i; 388 - if (strlen (token) > 30) 389 - return 0; 390 - strcpy (buf, token); 391 - for (i = 0; i < (int) strlen (buf); i++) 392 - { 393 - if (buf[i] >= 'A' && buf[i] <= 'Z') 394 - buf[i] = 'a' + (buf[i] - 'A'); 395 - } 396 - if (strcmp (buf, "black") == 0) 397 - { 398 - *red = 0; 399 - *green = 0; 400 - *blue = 0; 401 - return 1; 402 - } 403 - if (strcmp (buf, "white") == 0) 404 - { 405 - *red = 255; 406 - *green = 255; 407 - *blue = 255; 408 - return 1; 409 - } 410 - if (strcmp (buf, "red") == 0) 411 - { 412 - *red = 255; 413 - *green = 0; 414 - *blue = 0; 415 - return 1; 416 - } 417 - if (strcmp (buf, "lime") == 0) 418 - { 419 - *red = 0; 420 - *green = 255; 421 - *blue = 0; 422 - return 1; 423 - } 424 - if (strcmp (buf, "blue") == 0) 425 - { 426 - *red = 0; 427 - *green = 0; 428 - *blue = 255; 429 - return 1; 430 - } 431 - if (strcmp (buf, "yellow") == 0) 432 - { 433 - *red = 255; 434 - *green = 255; 435 - *blue = 0; 436 - return 1; 437 - } 438 - if (strcmp (buf, "magenta") == 0 || strcmp (buf, "fuchsia") == 0) 439 - { 440 - *red = 255; 441 - *green = 0; 442 - *blue = 255; 443 - return 1; 444 - } 445 - if (strcmp (buf, "cyan") == 0 || strcmp (buf, "aqua") == 0) 446 - { 447 - *red = 0; 448 - *green = 255; 449 - *blue = 255; 450 - return 1; 451 - } 452 - if (strcmp (buf, "orange") == 0) 453 - { 454 - *red = 255; 455 - *green = 128; 456 - *blue = 0; 457 - return 1; 458 - } 459 - if (strcmp (buf, "violet") == 0) 460 - { 461 - *red = 128; 462 - *green = 0; 463 - *blue = 255; 464 - return 1; 465 - } 466 - if (strcmp (buf, "purple") == 0) 467 - { 468 - *red = 128; 469 - *green = 0; 470 - *blue = 128; 471 - return 1; 472 - } 473 - if (strcmp (buf, "brown") == 0 || strcmp (buf, "maroon") == 0) 474 - { 475 - *red = 128; 476 - *green = 0; 477 - *blue = 0; 478 - return 1; 479 - } 480 - if (strcmp (buf, "indigo") == 0) 481 - { 482 - *red = 0; 483 - *green = 0; 484 - *blue = 128; 485 - return 1; 486 - } 487 - if (strcmp (buf, "green") == 0) 488 - { 489 - *red = 0; 490 - *green = 128; 491 - *blue = 0; 492 - return 1; 493 - } 494 - if (strcmp (buf, "navy") == 0) 495 - { 496 - *red = 0; 497 - *green = 0; 498 - *blue = 128; 499 - return 1; 500 - } 501 - if (strcmp (buf, "olive") == 0) 502 - { 503 - *red = 128; 504 - *green = 128; 505 - *blue = 0; 506 - return 1; 507 - } 508 - if (strcmp (buf, "teal") == 0) 509 - { 510 - *red = 0; 511 - *green = 128; 512 - *blue = 128; 513 - return 1; 514 - } 515 - if (strcmp (buf, "silver") == 0) 516 - { 517 - *red = 192; 518 - *green = 192; 519 - *blue = 192; 520 - return 1; 521 - } 522 - if (strcmp (buf, "gray") == 0) 523 - { 524 - *red = 128; 525 - *green = 128; 526 - *blue = 128; 527 - return 1; 528 - } 529 - return 0; 530 -} 531 - 532 -static gGraphColorRuleItemPtr 533 -alloc_color_rule_item (double value, unsigned char percent, unsigned char red, 534 - unsigned char green, unsigned char blue) 535 -{ 536 -/* allocates and initializes a Color Rule Item */ 537 - gGraphColorRuleItemPtr p = malloc (sizeof (gGraphColorRuleItem)); 538 - if (!p) 539 - return NULL; 540 - if (percent) 541 - { 542 - p->value = DBL_MAX; 543 - p->percent_value = value; 544 - } 545 - else 546 - { 547 - p->value = value; 548 - p->percent_value = DBL_MAX; 549 - } 550 - p->is_percent = percent; 551 - p->red = red; 552 - p->green = green; 553 - p->blue = blue; 554 - p->next = NULL; 555 - return p; 556 -} 557 - 558 -static int 559 -add_interval_to_color_rule (gGraphColorRulePtr ptr, double value, 560 - unsigned char red, unsigned char green, 561 - unsigned char blue) 562 -{ 563 -/* adding an Interval [absolute value] to a Color Rule */ 564 - gGraphColorRuleItemPtr p; 565 - if (!ptr) 566 - return 0; 567 - p = alloc_color_rule_item (value, 0, red, green, blue); 568 - if (!p) 569 - return 0; 570 - if (ptr->first == NULL) 571 - ptr->first = p; 572 - if (ptr->last != NULL) 573 - ptr->last->next = p; 574 - ptr->last = p; 575 - return 1; 576 -} 577 - 578 -static int 579 -add_percent_to_color_rule (gGraphColorRulePtr ptr, double value, 580 - unsigned char red, unsigned char green, 581 - unsigned char blue) 582 -{ 583 -/* adding an Interval [percent] to a Color Rule */ 584 - gGraphColorRuleItemPtr p; 585 - if (!ptr) 586 - return 0; 587 - p = alloc_color_rule_item (value, 1, red, green, blue); 588 - if (!p) 589 - return 0; 590 - ptr->needs_range = 1; 591 - if (ptr->first == NULL) 592 - ptr->first = p; 593 - if (ptr->last != NULL) 594 - ptr->last->next = p; 595 - ptr->last = p; 596 - return 1; 597 -} 598 - 599 -GGRAPH_DECLARE int 600 -gGraphColorRuleFromMemBuf (char *buf, const void **color_rule) 601 -{ 602 -/* trying to load a Color Rule from a GRASS-like memory block [null terminated] */ 603 - const char *p = buf; 604 - char in_buf[1024]; 605 - char *token; 606 - char *p_in; 607 - int error; 608 - double threshold; 609 - unsigned char red; 610 - unsigned char green; 611 - unsigned char blue; 612 - int no_data; 613 - int percent; 614 - double perc_value; 615 - int color_name; 616 - char *saveptr; 617 - int i_tk; 618 - double value; 619 - int ret; 620 - gGraphColorRulePtr rule = NULL; 621 - 622 - *color_rule = NULL; 623 - rule = gg_color_rule_create (); 624 - if (!rule) 625 - return GGRAPH_INSUFFICIENT_MEMORY; 626 - 627 - p_in = in_buf; 628 - while (*p != '\0') 629 - { 630 - /* parsing the Color Map block */ 631 - if (*p == '\r') 632 - { 633 - p++; 634 - continue; 635 - } 636 - if (*p == '\n') 637 - { 638 - *p_in = '\0'; 639 - 640 - red = 0; 641 - green = 0; 642 - blue = 0; 643 - no_data = 0; 644 - percent = 0; 645 - color_name = 0; 646 - error = 0; 647 - 648 - if (*in_buf == '#') 649 - { 650 - /* skipping a comment line */ 651 - p_in = in_buf; 652 - continue; 653 - } 654 - 655 - i_tk = 0; 656 - saveptr = NULL; 657 - while (1) 658 - { 659 - /* breaking the string into separate tokens */ 660 - token = string_tokenizer (in_buf, ": \t", &saveptr); 661 - if (token == NULL) 662 - break; 663 - 664 - if (i_tk == 0) 665 - { 666 - if (is_no_data_token (token)) 667 - { 668 - no_data = 1; 669 - i_tk++; 670 - continue; 671 - } 672 - if (is_percent_token (token, &perc_value)) 673 - { 674 - percent = 1; 675 - i_tk++; 676 - continue; 677 - } 678 - } 679 - else 680 - { 681 - color_name = 682 - is_color_name_token (token, &red, &green, 683 - &blue); 684 - if (color_name) 685 - { 686 - i_tk++; 687 - continue; 688 - } 689 - } 690 - 691 - if (!token_to_double (token, &value)) 692 - error = 1; 693 - else 694 - { 695 - switch (i_tk) 696 - { 697 - case 0: 698 - threshold = value; 699 - break; 700 - case 1: 701 - if (value >= 0.0 && value <= 255.0) 702 - red = (unsigned char) value; 703 - else 704 - error = 1; 705 - break; 706 - case 2: 707 - if (value >= 0.0 && value <= 255.0) 708 - green = (unsigned char) value; 709 - else 710 - error = 1; 711 - break; 712 - case 3: 713 - if (value >= 0.0 && value <= 255.0) 714 - blue = (unsigned char) value; 715 - else 716 - error = 1; 717 - break; 718 - default: 719 - error = 1; 720 - break; 721 - }; 722 - } 723 - 724 - i_tk++; 725 - } 726 - 727 - if (error) 728 - { 729 - ret = GGRAPH_ERROR; 730 - goto stop; 731 - } 732 - else if (no_data) 733 - { 734 - rule->no_data_red = red; 735 - rule->no_data_green = green; 736 - rule->no_data_blue = blue; 737 - } 738 - else if (percent) 739 - { 740 - if (!add_percent_to_color_rule 741 - (rule, perc_value, red, green, blue)) 742 - { 743 - ret = GGRAPH_INSUFFICIENT_MEMORY; 744 - goto stop; 745 - } 746 - } 747 - else 748 - { 749 - if (!add_interval_to_color_rule 750 - (rule, threshold, red, green, blue)) 751 - { 752 - ret = GGRAPH_INSUFFICIENT_MEMORY; 753 - goto stop; 754 - } 755 - } 756 - 757 - p_in = in_buf; 758 - p++; 759 - continue; 760 - } 761 - *p_in++ = *p++; 762 - } 763 - *color_rule = rule; 764 - return GGRAPH_OK; 765 - 766 - stop: 767 - gg_color_rule_destroy (rule); 768 - return ret; 769 -} 770 - 771 -GGRAPH_DECLARE int 772 -gGraphColorRuleFromFile (const char *path, const void **color_rule) 773 -{ 774 -/* trying to load a Color Rule from a GRASS-like file */ 775 - FILE *in = NULL; 776 - int c; 777 - char *buf; 778 - char *p; 779 - int ret; 780 - const void *handle; 781 - 782 - *color_rule = NULL; 783 - buf = malloc (1024 * 1024); 784 - if (!buf) 785 - return GGRAPH_INSUFFICIENT_MEMORY; 786 - 787 - in = fopen (path, "rb"); 788 - if (in == NULL) 789 - return GGRAPH_FILE_OPEN_ERROR; 790 - 791 - p = buf; 792 - while ((c = getc (in)) != EOF) 793 - { 794 - /* loading the Color Rule file */ 795 - *p++ = c; 796 - } 797 - *p = '\0'; 798 - fclose (in); 799 - 800 - ret = gGraphColorRuleFromMemBuf (buf, &handle); 801 - free (buf); 802 - if (ret == GGRAPH_OK) 803 - *color_rule = handle; 804 - return ret; 805 -} 806 - 807 -GGRAPH_DECLARE void 808 -gGraphDestroyColorRule (const void *ptr) 809 -{ 810 -/* destroyng a Color Rule object */ 811 - gGraphColorRulePtr rule = (gGraphColorRulePtr) ptr; 812 - 813 - if (rule == NULL) 814 - return; 815 - if (rule->signature == GG_COLOR_RULE_MAGIC_SIGNATURE) 816 - { 817 - gg_color_rule_destroy (rule); 818 - return; 819 - } 820 -} 821 - 822 -GGRAPH_DECLARE int 823 -gGraphIsColorRuleRelative (const void *ptr, int *relative) 824 -{ 825 -/* checking if this Color Rule is a Relative one */ 826 - gGraphColorRulePtr rule = (gGraphColorRulePtr) ptr; 827 - 828 - if (rule == NULL) 829 - return GGRAPH_INVALID_COLOR_RULE; 830 - if (rule->signature != GG_COLOR_RULE_MAGIC_SIGNATURE) 831 - return GGRAPH_INVALID_COLOR_RULE; 832 - 833 - if (rule->needs_range) 834 - *relative = GGRAPH_TRUE; 835 - else 836 - *relative = GGRAPH_FALSE; 837 - return GGRAPH_OK; 838 -} 839 - 840 -static gGraphColorMapEntryPtr 841 -alloc_color_map_entry (double min, double max, unsigned char red, 842 - unsigned char green, unsigned char blue) 843 -{ 844 -/* allocates and initializes a Color Map Entry object */ 845 - gGraphColorMapEntryPtr p = malloc (sizeof (gGraphColorMapEntry)); 846 - if (!p) 847 - return NULL; 848 - p->min = min; 849 - p->max = max; 850 - p->red = red; 851 - p->green = green; 852 - p->blue = blue; 853 - p->next = NULL; 854 - return p; 855 -} 856 - 857 -static gGraphColorMapEntryPtr 858 -add_entry_to_color_map (gGraphColorMapPtr ptr, double min, 859 - double max, unsigned char red, unsigned char green, 860 - unsigned char blue) 861 -{ 862 -/* adding an Entry to a Color Map object */ 863 - gGraphColorMapEntryPtr entry; 864 - if (!ptr) 865 - return NULL; 866 - 867 - if (ptr->last) 868 - { 869 - entry = ptr->last; 870 - if (entry->red == red && entry->green == green && entry->blue == blue) 871 - { 872 - /* extending the current range */ 873 - if (entry->min > min) 874 - entry->min = min; 875 - if (entry->max < max) 876 - entry->max = max; 877 - return entry; 878 - } 879 - } 880 - 881 - entry = alloc_color_map_entry (min, max, red, green, blue); 882 - if (!entry) 883 - return NULL; 884 - if (ptr->first == NULL) 885 - ptr->first = entry; 886 - if (ptr->last != NULL) 887 - ptr->last->next = entry; 888 - ptr->last = entry; 889 - return entry; 890 -} 891 - 892 -static int 893 -resolve_interval (gGraphColorMapPtr ptr, double min, double max, 894 - unsigned char min_red, unsigned char min_green, 895 - unsigned char min_blue, unsigned char max_red, 896 - unsigned char max_green, unsigned char max_blue) 897 -{ 898 -/* resolving a color gradient */ 899 - double range = max - min; 900 - double red_range; 901 - double green_range; 902 - double blue_range; 903 - double tik = range / 256.0; 904 - double red_tik; 905 - double green_tik; 906 - double blue_tik; 907 - int reverse_red; 908 - int reverse_green; 909 - int reverse_blue; 910 - int i; 911 - 912 - if (max_red >= min_red) 913 - { 914 - red_range = max_red - min_red; 915 - reverse_red = 0; 916 - } 917 - else 918 - { 919 - red_range = min_red - max_red; 920 - reverse_red = 1; 921 - } 922 - if (max_green >= min_green) 923 - { 924 - green_range = max_green - min_green; 925 - reverse_green = 0; 926 - } 927 - else 928 - { 929 - green_range = min_green - max_green; 930 - reverse_green = 1; 931 - } 932 - if (max_blue >= min_blue) 933 - { 934 - blue_range = max_blue - min_blue; 935 - reverse_blue = 0; 936 - } 937 - else 938 - { 939 - blue_range = min_blue - max_blue; 940 - reverse_blue = 1; 941 - } 942 - red_tik = red_range / 256.0; 943 - green_tik = green_range / 256.0; 944 - blue_tik = blue_range / 256.0; 945 - 946 - for (i = 0; i < 256; i++) 947 - { 948 - /* generating range intervals */ 949 - double imin = min + (tik * (double) i); 950 - double imax = imin + tik; 951 - double red; 952 - double green; 953 - double blue; 954 - if (reverse_red) 955 - red = (double) min_red - (red_tik * (double) i); 956 - else 957 - red = (double) min_red + (red_tik * (double) i); 958 - if (reverse_green) 959 - green = (double) min_green - (green_tik * (double) i); 960 - else 961 - green = (double) min_green + (green_tik * (double) i); 962 - if (reverse_blue) 963 - blue = (double) min_blue - (blue_tik * (double) i); 964 - else 965 - blue = (double) min_blue + (blue_tik * (double) i); 966 - if (i == 255) 967 - { 968 - imax = max; 969 - red = max_red; 970 - green = max_green; 971 - blue = max_blue; 972 - } 973 - if (red < 0.0) 974 - red = 0.0; 975 - if (red > 255.0) 976 - red = 255.0; 977 - if (green < 0.0) 978 - green = 0.0; 979 - if (green > 255.0) 980 - green = 255.0; 981 - if (blue < 0.0) 982 - blue = 0.0; 983 - if (blue > 255.0) 984 - blue = 255.0; 985 - if (add_entry_to_color_map (ptr, imin, imax, (unsigned char) red, 986 - (unsigned char) green, 987 - (unsigned char) blue) == NULL) 988 - return GGRAPH_ERROR; 989 - } 990 - return GGRAPH_OK; 991 -} 992 - 993 -static void 994 -color_map_prepare (gGraphColorMapPtr map) 995 -{ 996 -/* preparing the sorted array for Color Entries */ 997 - int ind; 998 - gGraphColorMapEntryPtr entry; 999 - if (map->array) 1000 - free (map->array); 1001 - map->array = NULL; 1002 - 1003 - map->num_entries = 0; 1004 - entry = map->first; 1005 - while (entry) 1006 - { 1007 - /* counting how many Entries are there */ 1008 - map->num_entries += 1; 1009 - entry = entry->next; 1010 - } 1011 - if (map->num_entries <= 0) 1012 - return; 1013 - 1014 - map->array = malloc (sizeof (gGraphColorMapEntryPtr) * map->num_entries); 1015 - ind = 0; 1016 - entry = map->first; 1017 - while (entry) 1018 - { 1019 - /* feeding the pointers array */ 1020 - *(map->array + ind) = entry; 1021 - ind++; 1022 - entry = entry->next; 1023 - } 1024 -/* sorting the array */ 1025 - qsort (map->array, map->num_entries, sizeof (gGraphColorMapEntryPtr), 1026 - cmp_color_rules1); 1027 -} 1028 - 1029 -GGRAPH_DECLARE int 1030 -gGraphCreateColorMapAbsolute (const void *color_rule, 1031 - unsigned char background_red, 1032 - unsigned char background_green, 1033 - unsigned char background_blue, 1034 - const void **color_map) 1035 -{ 1036 -/* attempting to create an ABSOLUTE Color Map */ 1037 - double last_value = DBL_MAX; 1038 - unsigned char last_red; 1039 - unsigned char last_green; 1040 - unsigned char last_blue; 1041 - gGraphColorMapPtr map; 1042 - gGraphColorRuleItemPtr item; 1043 - gGraphColorRulePtr rule = (gGraphColorRulePtr) color_rule; 1044 - 1045 - if (rule == NULL) 1046 - return GGRAPH_INVALID_COLOR_RULE; 1047 - if (rule->signature != GG_COLOR_RULE_MAGIC_SIGNATURE) 1048 - return GGRAPH_INVALID_COLOR_RULE; 1049 - if (rule->needs_range) 1050 - return GGRAPH_INVALID_COLOR_RULE; 1051 - 1052 - *color_map = NULL; 1053 - map = gg_color_map_create (); 1054 - if (!map) 1055 - return GGRAPH_INSUFFICIENT_MEMORY; 1056 - map->no_data_red = background_red; 1057 - map->no_data_green = background_green; 1058 - map->no_data_blue = background_blue; 1059 - map->not_found_red = background_red; 1060 - map->not_found_green = background_green; 1061 - map->not_found_blue = background_blue; 1062 - 1063 - item = rule->first; 1064 - while (item) 1065 - { 1066 - /* expanding intervals by color */ 1067 - if (last_value != DBL_MAX && last_value != item->value) 1068 - { 1069 - if (resolve_interval 1070 - (map, last_value, item->value, last_red, last_green, 1071 - last_blue, item->red, item->green, 1072 - item->blue) != GGRAPH_OK) 1073 - goto error; 1074 - } 1075 - last_value = item->value; 1076 - last_red = item->red; 1077 - last_green = item->green; 1078 - last_blue = item->blue; 1079 - item = item->next; 1080 - } 1081 - color_map_prepare (map); 1082 - if (map->array == NULL) 1083 - goto error; 1084 - *color_map = map; 1085 - return GGRAPH_OK; 1086 - 1087 - error: 1088 - gg_color_map_destroy (map); 1089 - return GGRAPH_ERROR; 1090 -} 1091 - 1092 -GGRAPH_DECLARE int 1093 -gGraphCreateColorMapRelative (const void *color_rule, double min, double max, 1094 - unsigned char background_red, 1095 - unsigned char background_green, 1096 - unsigned char background_blue, 1097 - const void **color_map) 1098 -{ 1099 -/* attempting to create a RELATIVE Color Map */ 1100 - double last_value = DBL_MAX; 1101 - unsigned char last_red; 1102 - unsigned char last_green; 1103 - unsigned char last_blue; 1104 - double percent; 1105 - gGraphColorMapPtr map; 1106 - gGraphColorRuleItemPtr item; 1107 - gGraphColorRulePtr rule = (gGraphColorRulePtr) color_rule; 1108 - 1109 - if (rule == NULL) 1110 - return GGRAPH_INVALID_COLOR_RULE; 1111 - if (rule->signature != GG_COLOR_RULE_MAGIC_SIGNATURE) 1112 - return GGRAPH_INVALID_COLOR_RULE; 1113 - if (rule->needs_range == 0) 1114 - return GGRAPH_INVALID_COLOR_RULE; 1115 - 1116 - *color_map = NULL; 1117 - map = gg_color_map_create (); 1118 - if (!map) 1119 - return GGRAPH_INSUFFICIENT_MEMORY; 1120 - map->no_data_red = background_red; 1121 - map->no_data_green = background_green; 1122 - map->no_data_blue = background_blue; 1123 - map->not_found_red = background_red; 1124 - map->not_found_green = background_green; 1125 - map->not_found_blue = background_blue; 1126 - 1127 - percent = (max - min) / 100.0; 1128 - item = rule->first; 1129 - while (item) 1130 - { 1131 - /* tranforming percent values into absolute ones */ 1132 - if (item->is_percent) 1133 - item->value = min + (percent * item->percent_value); 1134 - item = item->next; 1135 - } 1136 - 1137 - item = rule->first; 1138 - while (item) 1139 - { 1140 - /* expanding intervals by color */ 1141 - if (last_value != DBL_MAX && last_value != item->value) 1142 - { 1143 - if (resolve_interval 1144 - (map, last_value, item->value, last_red, last_green, 1145 - last_blue, item->red, item->green, 1146 - item->blue) != GGRAPH_OK) 1147 - goto error; 1148 - } 1149 - last_value = item->value; 1150 - last_red = item->red; 1151 - last_green = item->green; 1152 - last_blue = item->blue; 1153 - item = item->next; 1154 - } 1155 - color_map_prepare (map); 1156 - if (map->array == NULL) 1157 - goto error; 1158 - *color_map = map; 1159 - return GGRAPH_OK; 1160 - 1161 - error: 1162 - gg_color_map_destroy (map); 1163 - return GGRAPH_ERROR; 1164 -} 1165 - 1166 -GGRAPH_DECLARE void 1167 -gGraphDestroyColorMap (const void *ptr) 1168 -{ 1169 -/* destroyng a Color Map object */ 1170 - gGraphColorMapPtr map = (gGraphColorMapPtr) ptr; 1171 - 1172 - if (map == NULL) 1173 - return; 1174 - if (map->signature == GG_COLOR_MAP_MAGIC_SIGNATURE) 1175 - gg_color_map_destroy (map); 1176 -} 1177 - 1178 -GGRAPH_PRIVATE void 1179 -match_color (gGraphColorMapPtr map, double value, double no_data, 1180 - unsigned char *red, unsigned char *green, unsigned char *blue) 1181 -{ 1182 -/* identifying a color corresponding to a value */ 1183 - gGraphColorMapEntryPtr *ret; 1184 - gGraphColorMapEntryPtr p; 1185 - gGraphColorMapEntry val; 1186 - val.min = value; 1187 - val.max = value; 1188 - if (value == no_data) 1189 - { 1190 - /* NoData */ 1191 - *red = map->no_data_red; 1192 - *green = map->no_data_green; 1193 - *blue = map->no_data_blue; 1194 - return; 1195 - } 1196 -/* dicotomic search */ 1197 - ret = 1198 - (gGraphColorMapEntryPtr *) bsearch (&val, map->array, 1199 - map->num_entries, 1200 - sizeof (gGraphColorMapEntryPtr), 1201 - cmp_color_rules2); 1202 - if (!ret) 1203 - { 1204 - /* not found */ 1205 - *red = map->not_found_red; 1206 - *green = map->not_found_green; 1207 - *blue = map->not_found_blue; 1208 - return; 1209 - } 1210 -/* ok, match found */ 1211 - p = *ret; 1212 - *red = p->red; 1213 - *green = p->green; 1214 - *blue = p->blue; 1215 -} 1216 - 1217 -static void 1218 -do_grid_render (struct thread_grid_render *params) 1219 -{ 1220 -/* actual function: rendering a GRID pixels block */ 1221 - unsigned char red; 1222 - unsigned char green; 1223 - unsigned char blue; 1224 - unsigned char *p_out; 1225 - short *p_int16; 1226 - unsigned short *p_uint16; 1227 - int *p_int32; 1228 - unsigned int *p_uint32; 1229 - float *p_float; 1230 - double *p_double; 1231 - double value; 1232 - int x; 1233 - 1234 - if (params->sample_format == GGRAPH_SAMPLE_FLOAT) 1235 - { 1236 - if (params->bits_per_sample == 32) 1237 - { 1238 - p_float = (float *) (params->pixels); 1239 - p_float += params->base; 1240 - } 1241 - else 1242 - { 1243 - p_double = (double *) (params->pixels); 1244 - p_double += params->base; 1245 - } 1246 - } 1247 - if (params->sample_format == GGRAPH_SAMPLE_INT) 1248 - { 1249 - if (params->bits_per_sample == 32) 1250 - { 1251 - p_int32 = (int *) (params->pixels); 1252 - p_int32 += params->base; 1253 - } 1254 - else 1255 - { 1256 - p_int16 = (short *) (params->pixels); 1257 - p_int16 += params->base; 1258 - } 1259 - } 1260 - if (params->sample_format == GGRAPH_SAMPLE_UINT) 1261 - { 1262 - if (params->bits_per_sample == 32) 1263 - { 1264 - p_uint32 = (unsigned int *) (params->pixels); 1265 - p_uint32 += params->base; 1266 - } 1267 - else 1268 - { 1269 - p_uint16 = (unsigned short *) (params->pixels); 1270 - p_uint16 += params->base; 1271 - } 1272 - } 1273 - p_out = params->p_rgb + (params->base * 3); 1274 - for (x = 0; x < params->num_pixels; x++) 1275 - { 1276 - if (params->sample_format == GGRAPH_SAMPLE_FLOAT) 1277 - { 1278 - if (params->bits_per_sample == 32) 1279 - value = *p_float++; 1280 - else 1281 - value = *p_double++; 1282 - } 1283 - if (params->sample_format == GGRAPH_SAMPLE_INT) 1284 - { 1285 - if (params->bits_per_sample == 32) 1286 - value = *p_int32++; 1287 - else 1288 - value = *p_int16++; 1289 - } 1290 - if (params->sample_format == GGRAPH_SAMPLE_UINT) 1291 - { 1292 - if (params->bits_per_sample == 32) 1293 - value = *p_uint32++; 1294 - else 1295 - value = *p_uint16++; 1296 - } 1297 - match_color (params->color_map, value, params->no_data_value, &red, 1298 - &green, &blue); 1299 - *p_out++ = red; 1300 - *p_out++ = green; 1301 - *p_out++ = blue; 1302 - } 1303 -} 1304 - 1305 -#ifdef _WIN32 1306 -static DWORD WINAPI 1307 -#else 1308 -static void * 1309 -#endif 1310 -grid_render (void *arg) 1311 -{ 1312 -/* threaded function: rendering a GRID pixels block */ 1313 - struct thread_grid_render *params = (struct thread_grid_render *) arg; 1314 - do_grid_render (params); 1315 -#ifdef _WIN32 1316 - return 0; 1317 -#else 1318 - pthread_exit (NULL); 1319 -#endif 1320 -} 1321 - 1322 -GGRAPH_DECLARE int 1323 -gGraphStripImageRenderGridPixels (const void *in_ptr, const void *out_ptr, 1324 - const void *map, int num_threads) 1325 -{ 1326 -/* rendering GRID pixels between two images */ 1327 - int y; 1328 - short *p_int16; 1329 - unsigned short *p_uint16; 1330 - int *p_int32; 1331 - unsigned int *p_uint32; 1332 - float *p_float; 1333 - double *p_double; 1334 - void *p_void; 1335 - unsigned char *p_out; 1336 - int nt; 1337 - struct thread_grid_render threads[GG_MAX_THREADS]; 1338 -#ifdef _WIN32 1339 - HANDLE thread_handles[GG_MAX_THREADS]; 1340 - DWORD dwThreadIdArray[GG_MAX_THREADS]; 1341 -#else 1342 - pthread_t thread_ids[GG_MAX_THREADS]; 1343 -#endif 1344 - gGraphStripImagePtr img_in = (gGraphStripImagePtr) in_ptr; 1345 - gGraphStripImagePtr img_out = (gGraphStripImagePtr) out_ptr; 1346 - gGraphColorMapPtr color_map = (gGraphColorMapPtr) map; 1347 - 1348 - if (img_in == NULL || img_out == NULL) 1349 - return GGRAPH_INVALID_IMAGE; 1350 - if (img_in->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1351 - return GGRAPH_INVALID_IMAGE; 1352 - if (img_out->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1353 - return GGRAPH_INVALID_IMAGE; 1354 - if (map == NULL) 1355 - return GGRAPH_INVALID_COLOR_MAP; 1356 - if (color_map->signature != GG_COLOR_MAP_MAGIC_SIGNATURE) 1357 - return GGRAPH_INVALID_COLOR_MAP; 1358 - 1359 - if (num_threads > GG_MAX_THREADS) 1360 - num_threads = GG_MAX_THREADS; 1361 - if (num_threads < 1) 1362 - num_threads = 1; 1363 - 1364 -/* checking if the strip buffers does actually have the same size */ 1365 - if (img_in->width == img_out->width 1366 - && img_in->rows_per_block == img_out->rows_per_block) 1367 - ; 1368 - else 1369 - return GGRAPH_ERROR; 1370 - if (img_in->pixel_format != GG_PIXEL_GRID) 1371 - return GGRAPH_INVALID_IMAGE; 1372 - if (img_out->pixel_format != GG_PIXEL_RGB) 1373 - return GGRAPH_INVALID_IMAGE; 1374 - 1375 - for (y = 0; y < img_in->current_available_rows; y++) 1376 - { 1377 - if (img_in->sample_format == GGRAPH_SAMPLE_FLOAT) 1378 - { 1379 - if (img_in->bits_per_sample == 32) 1380 - { 1381 - p_float = (float *) (img_in->pixels); 1382 - p_float += y * img_in->width; 1383 - p_void = p_float; 1384 - } 1385 - else 1386 - { 1387 - p_double = (double *) (img_in->pixels); 1388 - p_double += y * img_in->width; 1389 - p_void = p_double; 1390 - } 1391 - } 1392 - if (img_in->sample_format == GGRAPH_SAMPLE_INT) 1393 - { 1394 - if (img_in->bits_per_sample == 32) 1395 - { 1396 - p_int32 = (int *) (img_in->pixels); 1397 - p_int32 += y * img_in->width; 1398 - p_void = p_int32; 1399 - } 1400 - else 1401 - { 1402 - p_int16 = (short *) (img_in->pixels); 1403 - p_int16 += y * img_in->width; 1404 - p_void = p_int16; 1405 - } 1406 - } 1407 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 1408 - { 1409 - if (img_in->bits_per_sample == 32) 1410 - { 1411 - p_uint32 = (unsigned int *) (img_in->pixels); 1412 - p_uint32 += y * img_in->width; 1413 - p_void = p_uint32; 1414 - } 1415 - else 1416 - { 1417 - p_uint16 = (unsigned short *) (img_in->pixels); 1418 - p_uint16 += y * img_in->width; 1419 - p_void = p_uint16; 1420 - } 1421 - } 1422 - p_out = img_out->pixels + (y * img_out->scanline_width); 1423 - 1424 - if (num_threads < 2) 1425 - { 1426 - /* not using multithreading */ 1427 - threads[0].color_map = color_map; 1428 - threads[0].no_data_value = img_in->no_data_value; 1429 - threads[0].sample_format = img_in->sample_format; 1430 - threads[0].bits_per_sample = img_in->bits_per_sample; 1431 - threads[0].pixels = p_void; 1432 - threads[0].base = 0; 1433 - threads[0].num_pixels = img_in->width; 1434 - threads[0].p_rgb = p_out; 1435 - do_grid_render (&(threads[0])); 1436 - } 1437 - else 1438 - { 1439 - /* using concurrent threads */ 1440 - int base = 0; 1441 - int pixels_per_thread = img_in->width / num_threads; 1442 - if ((pixels_per_thread * num_threads) < img_in->width) 1443 - pixels_per_thread++; 1444 - for (nt = 0; nt < num_threads; nt++) 1445 - { 1446 - int num_pixels; 1447 - threads[nt].color_map = color_map; 1448 - threads[nt].no_data_value = img_in->no_data_value; 1449 - threads[nt].sample_format = img_in->sample_format; 1450 - threads[nt].bits_per_sample = img_in->bits_per_sample; 1451 - threads[nt].pixels = p_void; 1452 - threads[nt].base = base; 1453 - num_pixels = pixels_per_thread; 1454 - if (base + pixels_per_thread > img_in->width) 1455 - num_pixels = img_in->width - base; 1456 - threads[nt].num_pixels = num_pixels; 1457 - threads[nt].p_rgb = p_out; 1458 - base += pixels_per_thread; 1459 - if (num_pixels > 0) 1460 - { 1461 -#ifdef _WIN32 1462 - thread_handles[nt] = 1463 - CreateThread (NULL, 0, grid_render, 1464 - &(threads[nt]), 0, 1465 - &dwThreadIdArray[nt]); 1466 -#else 1467 - pthread_create (&(thread_ids[nt]), NULL, 1468 - grid_render, &(threads[nt])); 1469 -#endif 1470 - } 1471 - } 1472 - /* waiting until any concurrent thread terminates */ 1473 -#ifdef _WIN32 1474 - WaitForMultipleObjects (num_threads, thread_handles, TRUE, 1475 - INFINITE); 1476 -#else 1477 - for (nt = 0; nt < num_threads; nt++) 1478 - pthread_join (thread_ids[nt], NULL); 1479 -#endif 1480 - } 1481 - } 1482 - img_out->current_available_rows = img_in->current_available_rows; 1483 - return GGRAPH_OK; 1484 -} 1485 - 1486 -GGRAPH_DECLARE int 1487 -gGraphGetStripImageMinMaxValue (const void *in_ptr, double *min_value, 1488 - double *max_value, double no_data_value) 1489 -{ 1490 -/* determining MinMax values */ 1491 - int x; 1492 - int y; 1493 - short *p_int16; 1494 - unsigned short *p_uint16; 1495 - int *p_int32; 1496 - unsigned int *p_uint32; 1497 - float *p_float; 1498 - double *p_double; 1499 - double value; 1500 - double min = DBL_MAX; 1501 - double max = 0.0 - DBL_MAX; 1502 - int save_row; 1503 - gGraphStripImagePtr img_in = (gGraphStripImagePtr) in_ptr; 1504 - 1505 - *min_value = DBL_MAX; 1506 - *max_value = 0.0 - DBL_MAX; 1507 - if (img_in == NULL) 1508 - return GGRAPH_INVALID_IMAGE; 1509 - if (img_in->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1510 - return GGRAPH_INVALID_IMAGE; 1511 - if (img_in->pixel_format != GG_PIXEL_GRID) 1512 - return GGRAPH_INVALID_IMAGE; 1513 - 1514 - save_row = img_in->next_row; 1515 - img_in->next_row = 0; 1516 - while (1) 1517 - { 1518 - /* reading strips from input */ 1519 - if (gGraphStripImageEOF (img_in) == GGRAPH_OK) 1520 - break; 1521 - if (gGraphReadNextStrip (img_in, NULL) != GGRAPH_OK) 1522 - goto error; 1523 - for (y = 0; y < img_in->current_available_rows; y++) 1524 - { 1525 - if (img_in->sample_format == GGRAPH_SAMPLE_FLOAT) 1526 - { 1527 - if (img_in->bits_per_sample == 32) 1528 - { 1529 - p_float = (float *) (img_in->pixels); 1530 - p_float += y * img_in->width; 1531 - } 1532 - else 1533 - { 1534 - p_double = (double *) (img_in->pixels); 1535 - p_double += y * img_in->width; 1536 - } 1537 - } 1538 - if (img_in->sample_format == GGRAPH_SAMPLE_INT) 1539 - { 1540 - if (img_in->bits_per_sample == 32) 1541 - { 1542 - p_int32 = (int *) (img_in->pixels); 1543 - p_int32 += y * img_in->width; 1544 - } 1545 - else 1546 - { 1547 - p_int16 = (short *) (img_in->pixels); 1548 - p_int16 += y * img_in->width; 1549 - } 1550 - } 1551 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 1552 - { 1553 - if (img_in->bits_per_sample == 32) 1554 - { 1555 - p_uint32 = (unsigned int *) (img_in->pixels); 1556 - p_uint32 += y * img_in->width; 1557 - } 1558 - else 1559 - { 1560 - p_uint16 = (unsigned short *) (img_in->pixels); 1561 - p_uint16 += y * img_in->width; 1562 - } 1563 - } 1564 - for (x = 0; x < img_in->width; x++) 1565 - { 1566 - if (img_in->sample_format == GGRAPH_SAMPLE_FLOAT) 1567 - { 1568 - if (img_in->bits_per_sample == 32) 1569 - value = *p_float++; 1570 - else 1571 - value = *p_double++; 1572 - } 1573 - if (img_in->sample_format == GGRAPH_SAMPLE_INT) 1574 - { 1575 - if (img_in->bits_per_sample == 32) 1576 - value = *p_int32++; 1577 - else 1578 - value = *p_int16++; 1579 - } 1580 - if (img_in->sample_format == GGRAPH_SAMPLE_UINT) 1581 - { 1582 - if (img_in->bits_per_sample == 32) 1583 - value = *p_uint32++; 1584 - else 1585 - value = *p_uint16++; 1586 - } 1587 - if (value != no_data_value) 1588 - { 1589 - if (value < min) 1590 - min = value; 1591 - if (value > max) 1592 - max = value; 1593 - } 1594 - } 1595 - } 1596 - } 1597 - img_in->next_row = save_row; 1598 - *min_value = min; 1599 - *max_value = max; 1600 - return GGRAPH_OK; 1601 - 1602 - error: 1603 - img_in->next_row = save_row; 1604 - return GGRAPH_ERROR; 1605 -} 1606 - 1607 -GGRAPH_PRIVATE gGraphShadedReliefTripleRowPtr 1608 -gg_shaded_relief_triple_row_create (void) 1609 -{ 1610 -/* allocating an empty Shaded Relief Triple Row object */ 1611 - gGraphShadedReliefTripleRowPtr ptr = 1612 - malloc (sizeof (gGraphShadedReliefTripleRow)); 1613 - if (!ptr) 1614 - return NULL; 1615 - ptr->signature = GG_SHADED_RELIEF_3ROWS_MAGIC_SIGNATURE; 1616 - ptr->width = -1; 1617 - ptr->in_row1 = NULL; 1618 - ptr->in_row2 = NULL; 1619 - ptr->in_row3 = NULL; 1620 - ptr->current_row = NULL; 1621 - ptr->out_rgb = NULL; 1622 - ptr->color_map = NULL; 1623 - ptr->mono_red = 0; 1624 - ptr->mono_green = 0; 1625 - ptr->mono_blue = 0; 1626 - ptr->z_factor = DBL_MAX; 1627 - ptr->scale_factor = DBL_MAX; 1628 - ptr->azimuth = DBL_MAX; 1629 - ptr->altitude = DBL_MAX; 1630 - ptr->no_data_value = DBL_MAX; 1631 - ptr->no_red = 0; 1632 - ptr->no_green = 0; 1633 - ptr->no_blue = 0; 1634 - return ptr; 1635 -} 1636 - 1637 -GGRAPH_PRIVATE void 1638 -gg_shaded_relief_triple_row_destroy (gGraphShadedReliefTripleRowPtr ptr) 1639 -{ 1640 -/* destroying a Shaded Relief Triple Row object */ 1641 - if (!ptr) 1642 - return; 1643 - if (ptr->in_row1) 1644 - free (ptr->in_row1); 1645 - if (ptr->in_row2) 1646 - free (ptr->in_row2); 1647 - if (ptr->in_row3) 1648 - free (ptr->in_row3); 1649 - if (ptr->out_rgb) 1650 - free (ptr->out_rgb); 1651 - free (ptr); 1652 -} 1653 - 1654 -GGRAPH_DECLARE int 1655 -gGraphCreateShadedReliefTripleRow (int width, unsigned char background_red, 1656 - unsigned char background_green, 1657 - unsigned char background_blue, 1658 - double no_data, const void *color_map_handle, 1659 - unsigned char mono_red, 1660 - unsigned char mono_green, 1661 - unsigned char mono_blue, double z_factor, 1662 - double scale_factor, double azimuth, 1663 - double altitude, 1664 - const void **triple_row_handle) 1665 -{ 1666 -/* creating a Shaded Relief Triple Row object */ 1667 - gGraphColorMapPtr map = (gGraphColorMapPtr) color_map_handle; 1668 - gGraphShadedReliefTripleRowPtr triple_row = 1669 - gg_shaded_relief_triple_row_create (); 1670 - *triple_row_handle = NULL; 1671 - if (!triple_row) 1672 - return GGRAPH_INSUFFICIENT_MEMORY; 1673 - 1674 - if (map != NULL) 1675 - { 1676 - if (map->signature != GG_COLOR_MAP_MAGIC_SIGNATURE) 1677 - { 1678 - gg_shaded_relief_triple_row_destroy (triple_row); 1679 - return GGRAPH_INVALID_COLOR_MAP; 1680 - } 1681 - } 1682 - 1683 -/* allocating the INPUT triple row buffer */ 1684 - triple_row->in_row1 = malloc (sizeof (float) * width); 1685 - if (triple_row->in_row1 == NULL) 1686 - goto error; 1687 - triple_row->in_row2 = malloc (sizeof (float) * width); 1688 - if (triple_row->in_row2 == NULL) 1689 - goto error; 1690 - triple_row->in_row3 = malloc (sizeof (float) * width); 1691 - if (triple_row->in_row3 == NULL) 1692 - goto error; 1693 -/* allocating the OUTPUT RGB buffer */ 1694 - triple_row->out_rgb = malloc (3 * (width - 2)); 1695 - if (triple_row->out_rgb == NULL) 1696 - goto error; 1697 - 1698 - triple_row->width = width; 1699 - triple_row->color_map = map; 1700 - triple_row->no_red = background_red; 1701 - triple_row->no_green = background_green; 1702 - triple_row->no_blue = background_blue; 1703 - triple_row->mono_red = mono_red; 1704 - triple_row->mono_green = mono_green; 1705 - triple_row->mono_blue = mono_blue; 1706 - triple_row->z_factor = z_factor; 1707 - triple_row->scale_factor = scale_factor; 1708 - triple_row->azimuth = azimuth; 1709 - triple_row->altitude = altitude; 1710 - triple_row->no_data_value = no_data; 1711 - *triple_row_handle = triple_row; 1712 - return GGRAPH_OK; 1713 - 1714 - error: 1715 - gg_shaded_relief_triple_row_destroy (triple_row); 1716 - return GGRAPH_INSUFFICIENT_MEMORY; 1717 -} 1718 - 1719 -GGRAPH_DECLARE void 1720 -gGraphDestroyShadedReliefTripleRow (const void *ptr) 1721 -{ 1722 -/* destroyng a Shaded Relief Triple Row object */ 1723 - gGraphShadedReliefTripleRowPtr triple_row = 1724 - (gGraphShadedReliefTripleRowPtr) ptr; 1725 - 1726 - if (triple_row == NULL) 1727 - return; 1728 - if (triple_row->signature == GG_SHADED_RELIEF_3ROWS_MAGIC_SIGNATURE) 1729 - gg_shaded_relief_triple_row_destroy (triple_row); 1730 -} 1731 - 1732 -static void 1733 -shaded_relief_triple_rotate (gGraphShadedReliefTripleRowPtr p) 1734 -{ 1735 -/* rotating the Shaded Relief Triple Row scanlines */ 1736 - int x; 1737 - float *p_out; 1738 - if (p->current_row == NULL) 1739 - { 1740 - p->current_row = p->in_row1; 1741 - goto no_data_fill; 1742 - } 1743 - if (p->current_row == p->in_row1) 1744 - { 1745 - p->current_row = p->in_row2; 1746 - goto no_data_fill; 1747 - } 1748 - if (p->current_row == p->in_row2) 1749 - { 1750 - p->current_row = p->in_row3; 1751 - goto no_data_fill; 1752 - } 1753 - p->current_row = p->in_row1; 1754 - p->in_row1 = p->in_row2; 1755 - p->in_row2 = p->in_row3; 1756 - p->in_row3 = p->current_row; 1757 - no_data_fill: 1758 - p_out = p->current_row; 1759 - for (x = 0; x < p->width; x++) 1760 - *p_out++ = p->no_data_value; 1761 -} 1762 - 1763 -GGRAPH_DECLARE int 1764 -gGraphStripImageGetShadedReliefScanline (const void *in_img_handle, 1765 - int row_index, 1766 - const void *triple_row_handle) 1767 -{ 1768 -/* inserting a new scanline into the Shaded Relief Triple Row object */ 1769 - int x; 1770 - short *p_int16; 1771 - unsigned short *p_uint16; 1772 - int *p_int32; 1773 - unsigned int *p_uint32; 1774 - float *p_float; 1775 - double *p_double; 1776 - float pixel; 1777 - float *p_out; 1778 - gGraphShadedReliefTripleRowPtr triple_row = 1779 - (gGraphShadedReliefTripleRowPtr) triple_row_handle; 1780 - gGraphStripImagePtr img = (gGraphStripImagePtr) in_img_handle; 1781 - 1782 - if (triple_row == NULL) 1783 - return GGRAPH_INVALID_SHADED_RELIEF_3ROWS; 1784 - if (triple_row->signature != GG_SHADED_RELIEF_3ROWS_MAGIC_SIGNATURE) 1785 - return GGRAPH_INVALID_SHADED_RELIEF_3ROWS; 1786 - if (img == NULL) 1787 - return GGRAPH_INVALID_IMAGE; 1788 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1789 - return GGRAPH_INVALID_IMAGE; 1790 - if (img->pixel_format != GG_PIXEL_GRID) 1791 - return GGRAPH_INVALID_IMAGE; 1792 - if (img->width != triple_row->width) 1793 - return GGRAPH_INVALID_IMAGE; 1794 - if (row_index >= 0 && row_index < img->rows_per_block) 1795 - ; 1796 - else 1797 - return GGRAPH_ERROR; 1798 - 1799 - shaded_relief_triple_rotate (triple_row); 1800 - 1801 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT) 1802 - { 1803 - if (img->bits_per_sample == 32) 1804 - { 1805 - p_float = (float *) (img->pixels); 1806 - p_float += row_index * img->width; 1807 - } 1808 - else 1809 - { 1810 - p_double = (double *) (img->pixels); 1811 - p_double += row_index * img->width; 1812 - } 1813 - } 1814 - if (img->sample_format == GGRAPH_SAMPLE_INT) 1815 - { 1816 - if (img->bits_per_sample == 32) 1817 - { 1818 - p_int32 = (int *) (img->pixels); 1819 - p_int32 += row_index * img->width; 1820 - } 1821 - else 1822 - { 1823 - p_int16 = (short *) (img->pixels); 1824 - p_int16 += row_index * img->width; 1825 - } 1826 - } 1827 - if (img->sample_format == GGRAPH_SAMPLE_UINT) 1828 - { 1829 - if (img->bits_per_sample == 32) 1830 - { 1831 - p_uint32 = (unsigned int *) (img->pixels); 1832 - p_uint32 += row_index * img->width; 1833 - } 1834 - else 1835 - { 1836 - p_uint16 = (unsigned short *) (img->pixels); 1837 - p_uint16 += row_index * img->width; 1838 - } 1839 - } 1840 - p_out = triple_row->current_row; 1841 - for (x = 0; x < img->width; x++) 1842 - { 1843 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT) 1844 - { 1845 - if (img->bits_per_sample == 32) 1846 - pixel = *p_float++; 1847 - else 1848 - pixel = *p_double++; 1849 - } 1850 - if (img->sample_format == GGRAPH_SAMPLE_INT) 1851 - { 1852 - if (img->bits_per_sample == 32) 1853 - pixel = *p_int32++; 1854 - else 1855 - pixel = *p_int16++; 1856 - } 1857 - if (img->sample_format == GGRAPH_SAMPLE_UINT) 1858 - { 1859 - if (img->bits_per_sample == 32) 1860 - pixel = *p_uint32++; 1861 - else 1862 - pixel = *p_uint16++; 1863 - } 1864 - *p_out++ = pixel; 1865 - } 1866 - return GGRAPH_OK; 1867 -} 1868 - 1869 -GGRAPH_DECLARE int 1870 -gGraphStripImageSetShadedReliefScanline (const void *triple_row_handle, 1871 - const void *out_img_handle, 1872 - int row_index) 1873 -{ 1874 -/* copying out a Shaded Relief processed scanline */ 1875 - int x; 1876 - unsigned char *p_in; 1877 - unsigned char *p_out; 1878 - gGraphShadedReliefTripleRowPtr triple_row = 1879 - (gGraphShadedReliefTripleRowPtr) triple_row_handle; 1880 - gGraphStripImagePtr img = (gGraphStripImagePtr) out_img_handle; 1881 - 1882 - if (triple_row == NULL) 1883 - return GGRAPH_INVALID_SHADED_RELIEF_3ROWS; 1884 - if (triple_row->signature != GG_SHADED_RELIEF_3ROWS_MAGIC_SIGNATURE) 1885 - return GGRAPH_INVALID_SHADED_RELIEF_3ROWS; 1886 - if (img == NULL) 1887 - return GGRAPH_INVALID_IMAGE; 1888 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 1889 - return GGRAPH_INVALID_IMAGE; 1890 - if (img->pixel_format != GG_PIXEL_RGB) 1891 - return GGRAPH_INVALID_IMAGE; 1892 - if (img->width != triple_row->width - 2) 1893 - return GGRAPH_INVALID_IMAGE; 1894 - if (row_index >= 0 && row_index < img->rows_per_block) 1895 - ; 1896 - else 1897 - return GGRAPH_ERROR; 1898 - 1899 - p_in = triple_row->out_rgb; 1900 - p_out = img->pixels + (row_index * img->scanline_width); 1901 - for (x = 0; x < img->width; x++) 1902 - { 1903 - *p_out++ = *p_in++; /* RED */ 1904 - *p_out++ = *p_in++; /* GREEN */ 1905 - *p_out++ = *p_in++; /* BLUE */ 1906 - } 1907 - img->current_available_rows = row_index + 1; 1908 - return GGRAPH_OK; 1909 -} 1910 - 1911 -static void 1912 -do_shaded_relief_render (struct thread_shaded_relief_render *params) 1913 -{ 1914 -/* performing actual rendering (1 single pixel) */ 1915 - int j; 1916 - int n; 1917 - double x; 1918 - double y; 1919 - double aspect; 1920 - double slope; 1921 - double cang; 1922 - int gray; 1923 - float afWin[9]; 1924 - double red; 1925 - double green; 1926 - double blue; 1927 - double alpha; 1928 - int bContainsNull; 1929 - unsigned char *p_out; 1930 - unsigned char r; 1931 - unsigned char g; 1932 - unsigned char b; 1933 - gGraphShadedReliefTripleRowPtr triple_row; 1934 - 1935 - p_out = params->p_rgb + (params->base * 3); 1936 - triple_row = params->triple_row; 1937 - 1938 -/* 1939 -* Shaded Relief rendering 1940 -* 1941 -***************************************************************** 1942 -* 1943 -* DISCLAIMER: the following code is largely based upon Even Rouault's 1944 -* gdaldem.c 1945 -* wich was originally released on public domain for GRASS, and is 1946 -* now included into GDAL (X/MIT license) 1947 -* 1948 -*/ 1949 - 1950 - 1951 -/* 1952 -/ Move a 3x3 pafWindow over each cell 1953 -/ (where the cell in question is #4) 1954 -/ 1955 -/ 0 1 2 1956 -/ 3 4 5 1957 -/ 6 7 8 1958 -*/ 1959 - for (j = 0; j < params->num_pixels; j++) 1960 - { 1961 - /* Exclude the edges */ 1962 - int k = j + params->base; 1963 - if (j == 0 || j == params->num_pixels - 1) 1964 - continue; 1965 - 1966 - afWin[0] = triple_row->in_row1[k - 1]; 1967 - afWin[1] = triple_row->in_row1[k]; 1968 - afWin[2] = triple_row->in_row1[k + 1]; 1969 - afWin[3] = triple_row->in_row2[k - 1]; 1970 - afWin[4] = triple_row->in_row2[k]; 1971 - afWin[5] = triple_row->in_row2[k + 1]; 1972 - afWin[6] = triple_row->in_row3[k - 1]; 1973 - afWin[7] = triple_row->in_row3[k]; 1974 - afWin[8] = triple_row->in_row3[k + 1]; 1975 - 1976 - bContainsNull = 0; 1977 - for (n = 0; n <= 8; n++) 1978 - { 1979 - if (afWin[n] == triple_row->no_data_value) 1980 - { 1981 - bContainsNull = 1; 1982 - break; 1983 - } 1984 - } 1985 - 1986 - if (bContainsNull) 1987 - { 1988 - /* We have nulls so write nullValue and move on */ 1989 - r = triple_row->no_red; 1990 - g = triple_row->no_green; 1991 - b = triple_row->no_blue; 1992 - } 1993 - else 1994 - { 1995 - /* We have a valid 3x3 window. */ 1996 - 1997 - /* --------------------------------------- 1998 - * Compute Hillshade 1999 - */ 2000 - 2001 - /* First Slope ... */ 2002 - x = triple_row->z_factor * 2003 - ((afWin[0] + afWin[3] + afWin[3] + afWin[6]) - 2004 - (afWin[2] + afWin[5] + afWin[5] + 2005 - afWin[8])) / (8.0 * triple_row->scale_factor); 2006 - 2007 - y = triple_row->z_factor * 2008 - ((afWin[6] + afWin[7] + afWin[7] + afWin[8]) - 2009 - (afWin[0] + afWin[1] + afWin[1] + 2010 - afWin[2])) / (8.0 * triple_row->scale_factor); 2011 - 2012 - slope = M_PI / 2 - atan (sqrt (x * x + y * y)); 2013 - 2014 - /* ... then aspect... */ 2015 - aspect = atan2 (x, y); 2016 - 2017 - /* ... then the shade value */ 2018 - cang = sin (params->altRadians) * sin (slope) + 2019 - cos (params->altRadians) * cos (slope) * 2020 - cos (params->azRadians - M_PI / 2 - aspect); 2021 - 2022 - if (cang <= 0.0) 2023 - cang = 1.0; 2024 - else 2025 - cang = 1.0 + (254.0 * cang); 2026 - 2027 - if (triple_row->color_map != NULL) 2028 - { 2029 - /* Color + Shaded Relief rendering */ 2030 - match_color (triple_row->color_map, afWin[4], 2031 - triple_row->no_data_value, &r, &g, &b); 2032 - alpha = cang / 255.0; 2033 - red = (double) r *alpha; 2034 - green = (double) g *alpha; 2035 - blue = (double) b *alpha; 2036 - if (red < 0.0) 2037 - red = 0.0; 2038 - if (green < 0.0) 2039 - green = 0.0; 2040 - if (blue < 0.0) 2041 - blue = 0.0; 2042 - if (red > 255.0) 2043 - red = 255.0; 2044 - if (green > 255.0) 2045 - green = 255.0; 2046 - if (blue > 255.0) 2047 - blue = 255.0; 2048 - r = (unsigned char) red; 2049 - g = (unsigned char) green; 2050 - b = (unsigned) blue; 2051 - } 2052 - else 2053 - { 2054 - if ((triple_row->mono_red == 0 2055 - && triple_row->mono_green == 0 2056 - && triple_row->mono_blue == 0) 2057 - || (triple_row->mono_red == 255 2058 - && triple_row->mono_green == 255 2059 - && triple_row->mono_blue == 255)) 2060 - { 2061 - /* plain gray-scale */ 2062 - gray = (int) cang; 2063 - r = (unsigned char) gray; 2064 - g = (unsigned char) gray; 2065 - b = (unsigned) gray; 2066 - } 2067 - else 2068 - { 2069 - /* using the monochrome base color + ALPHA */ 2070 - alpha = cang / 255.0; 2071 - red = (double) (triple_row->mono_red) * alpha; 2072 - green = (double) (triple_row->mono_green) * alpha; 2073 - blue = (double) (triple_row->mono_blue) * alpha; 2074 - if (red < 0.0) 2075 - red = 0.0; 2076 - if (green < 0.0) 2077 - green = 0.0; 2078 - if (blue < 0.0) 2079 - blue = 0.0; 2080 - if (red > 255.0) 2081 - red = 255.0; 2082 - if (green > 255.0) 2083 - green = 255.0; 2084 - if (blue > 255.0) 2085 - blue = 255.0; 2086 - r = (unsigned char) red; 2087 - g = (unsigned char) green; 2088 - b = (unsigned) blue; 2089 - } 2090 - } 2091 - } 2092 - *p_out++ = r; 2093 - *p_out++ = g; 2094 - *p_out++ = b; 2095 - } 2096 -} 2097 - 2098 -#ifdef _WIN32 2099 -static DWORD WINAPI 2100 -#else 2101 -static void * 2102 -#endif 2103 -shaded_relief_render (void *arg) 2104 -{ 2105 -/* threaded function: rendering a Shaded Relief pixel */ 2106 - struct thread_shaded_relief_render *params = 2107 - (struct thread_shaded_relief_render *) arg; 2108 - do_shaded_relief_render (params); 2109 -#ifdef _WIN32 2110 - return 0; 2111 -#else 2112 - pthread_exit (NULL); 2113 -#endif 2114 -} 2115 - 2116 -GGRAPH_DECLARE int 2117 -gGraphShadedReliefRenderPixels (const void *triple_row_handle, int num_threads, 2118 - int *out_row_ready) 2119 -{ 2120 -/* rendering a Shaded Relief scanline */ 2121 - double degreesToRadians; 2122 - unsigned char *p_out; 2123 - int nt; 2124 - struct thread_shaded_relief_render threads[GG_MAX_THREADS]; 2125 -#ifdef _WIN32 2126 - HANDLE thread_handles[GG_MAX_THREADS]; 2127 - DWORD dwThreadIdArray[GG_MAX_THREADS]; 2128 -#else 2129 - pthread_t thread_ids[GG_MAX_THREADS]; 2130 -#endif 2131 - gGraphShadedReliefTripleRowPtr triple_row = 2132 - (gGraphShadedReliefTripleRowPtr) triple_row_handle; 2133 - 2134 - if (triple_row == NULL) 2135 - return GGRAPH_INVALID_SHADED_RELIEF_3ROWS; 2136 - if (triple_row->signature != GG_SHADED_RELIEF_3ROWS_MAGIC_SIGNATURE) 2137 - return GGRAPH_INVALID_SHADED_RELIEF_3ROWS; 2138 - 2139 - if (triple_row->current_row != triple_row->in_row3) 2140 - { 2141 - /* not yet ready ( < 3 rows into the buffer) */ 2142 - *out_row_ready = GGRAPH_FALSE; 2143 - return GGRAPH_OK; 2144 - } 2145 - 2146 - if (num_threads > GG_MAX_THREADS) 2147 - num_threads = GG_MAX_THREADS; 2148 - if (num_threads < 1) 2149 - num_threads = 1; 2150 - degreesToRadians = M_PI / 180.0; 2151 - 2152 - p_out = triple_row->out_rgb; 2153 - if (num_threads < 2) 2154 - { 2155 - /* not using multithreading */ 2156 - threads[0].triple_row = triple_row; 2157 - threads[0].altRadians = triple_row->altitude * degreesToRadians; 2158 - threads[0].azRadians = triple_row->azimuth * degreesToRadians; 2159 - threads[0].base = 0; 2160 - threads[0].num_pixels = triple_row->width; 2161 - threads[0].p_rgb = p_out; 2162 - do_shaded_relief_render (&(threads[0])); 2163 - } 2164 - else 2165 - { 2166 - /* using concurrent threads */ 2167 - int base = 0; 2168 - int pixels_per_thread = triple_row->width / num_threads; 2169 - if ((pixels_per_thread * num_threads) < triple_row->width) 2170 - pixels_per_thread++; 2171 - for (nt = 0; nt < num_threads; nt++) 2172 - { 2173 - int num_pixels; 2174 - threads[nt].triple_row = triple_row; 2175 - threads[nt].altRadians = 2176 - triple_row->altitude * degreesToRadians; 2177 - threads[nt].azRadians = triple_row->azimuth * degreesToRadians; 2178 - if (nt == 0) 2179 - threads[nt].base = base; 2180 - else 2181 - threads[nt].base = base - 1; 2182 - num_pixels = pixels_per_thread + 1; 2183 - if (base + pixels_per_thread > triple_row->width) 2184 - num_pixels = triple_row->width - base; 2185 - threads[nt].num_pixels = num_pixels; 2186 - threads[nt].p_rgb = p_out; 2187 - base += pixels_per_thread; 2188 - if (num_pixels > 0) 2189 - { 2190 -#ifdef _WIN32 2191 - thread_handles[nt] = 2192 - CreateThread (NULL, 0, shaded_relief_render, 2193 - &(threads[nt]), 0, 2194 - &dwThreadIdArray[nt]); 2195 -#else 2196 - pthread_create (&(thread_ids[nt]), NULL, 2197 - shaded_relief_render, &(threads[nt])); 2198 -#endif 2199 - } 2200 - } 2201 - /* waiting until any concurrent thread terminates */ 2202 -#ifdef _WIN32 2203 - WaitForMultipleObjects (num_threads, thread_handles, TRUE, INFINITE); 2204 -#else 2205 - for (nt = 0; nt < num_threads; nt++) 2206 - pthread_join (thread_ids[nt], NULL); 2207 -#endif 2208 - } 2209 - 2210 - *out_row_ready = GGRAPH_TRUE; 2211 - return GGRAPH_OK; 2212 -} 2213 - 2214 -static void 2215 -landsat_recalibrate (struct thread_landsat_recalibrate *p) 2216 -{ 2217 -/* recalibrating color */ 2218 - double lmin; 2219 - double lmax; 2220 - double qcalmin; 2221 - double qcalmax; 2222 - double radiance; 2223 - double albedo; 2224 - double spectral_irradiance; 2225 - double rads; 2226 - double recalibrate; 2227 - double recalibrate_min; 2228 - double recalibrate_max; 2229 - double gain; 2230 - double sample = p->value; 2231 - 2232 - switch (p->band) 2233 - { 2234 - case LANDSAT_RED: 2235 - lmin = p->lmin_red; 2236 - lmax = p->lmax_red; 2237 - qcalmin = p->qcalmin_red; 2238 - qcalmax = p->qcalmax_red; 2239 - spectral_irradiance = p->spectral_irradiance_red; 2240 - if (p->gain_low_red) 2241 - gain = p->low_gain_factor_red; 2242 - else 2243 - gain = p->high_gain_factor_red; 2244 - recalibrate_min = p->recalibration_min_red; 2245 - recalibrate_max = p->recalibration_max_red; 2246 - break; 2247 - case LANDSAT_GREEN: 2248 - lmin = p->lmin_green; 2249 - lmax = p->lmax_green; 2250 - qcalmin = p->qcalmin_green; 2251 - qcalmax = p->qcalmax_green; 2252 - spectral_irradiance = p->spectral_irradiance_green; 2253 - if (p->gain_low_green) 2254 - gain = p->low_gain_factor_green; 2255 - else 2256 - gain = p->high_gain_factor_green; 2257 - recalibrate_min = p->recalibration_min_green; 2258 - recalibrate_max = p->recalibration_max_green; 2259 - break; 2260 - case LANDSAT_BLUE: 2261 - lmin = p->lmin_blue; 2262 - lmax = p->lmax_blue; 2263 - qcalmin = p->qcalmin_blue; 2264 - qcalmax = p->qcalmax_blue; 2265 - spectral_irradiance = p->spectral_irradiance_blue; 2266 - if (p->gain_low_blue) 2267 - gain = p->low_gain_factor_blue; 2268 - else 2269 - gain = p->high_gain_factor_blue; 2270 - recalibrate_min = p->recalibration_min_blue; 2271 - recalibrate_max = p->recalibration_max_blue; 2272 - break; 2273 - case LANDSAT_PANCHRO: 2274 - lmin = p->lmin_panchro; 2275 - lmax = p->lmax_panchro; 2276 - qcalmin = p->qcalmin_panchro; 2277 - qcalmax = p->qcalmax_panchro; 2278 - spectral_irradiance = p->spectral_irradiance_panchro; 2279 - if (p->gain_low_panchro) 2280 - gain = p->low_gain_factor_panchro; 2281 - else 2282 - gain = p->high_gain_factor_panchro; 2283 - recalibrate_min = p->recalibration_min_panchro; 2284 - recalibrate_max = p->recalibration_max_panchro; 2285 - }; 2286 - 2287 -/* converting Solar Zenith angle into Radians */ 2288 - rads = (90.0 - p->sun_elevation) * (M_PI / 180.0); 2289 -/* computing RADIANCE value */ 2290 - radiance = 2291 - ((lmax - lmin) / (qcalmax - qcalmin)) * (sample - qcalmin) + lmin; 2292 -/* computing REFLECTANCE aka ALBEDO value */ 2293 - albedo = M_PI * radiance * (p->sun_distance * p->sun_distance); 2294 - albedo /= spectral_irradiance * cos (rads); 2295 -/* normalizing range [1-255] */ 2296 - sample = (qcalmax - qcalmin) * albedo * gain; 2297 -/* recalibrating (discarding both range extremities) */ 2298 - recalibrate = 2299 - ((sample - recalibrate_min) * (qcalmax - qcalmin)) / (recalibrate_max - 2300 - recalibrate_min); 2301 - sample = recalibrate; 2302 - if (sample > qcalmax) 2303 - sample = qcalmax; 2304 - if (sample < qcalmin) 2305 - sample = qcalmin; 2306 - p->value = (unsigned char) sample; 2307 -} 2308 - 2309 -static void 2310 -landsat_rgb (struct thread_landsat_recalibrate *ptr) 2311 -{ 2312 -/* precessing an RGB Landsat sub-strip */ 2313 - int x; 2314 - int y; 2315 - unsigned char red; 2316 - unsigned char green; 2317 - unsigned char blue; 2318 - unsigned char *p_red; 2319 - unsigned char *p_green; 2320 - unsigned char *p_blue; 2321 - unsigned char *p_rgb; 2322 - struct thread_landsat_recalibrate p; 2323 - 2324 -/* setting up the recalibrate struct */ 2325 - p.lmin_red = ptr->lmin_red; 2326 - p.lmax_red = ptr->lmax_red; 2327 - p.qcalmin_red = ptr->qcalmin_red; 2328 - p.qcalmax_red = ptr->qcalmax_red; 2329 - p.gain_low_red = ptr->gain_low_red; 2330 - p.spectral_irradiance_red = ptr->spectral_irradiance_red; 2331 - p.low_gain_factor_red = ptr->low_gain_factor_red; 2332 - p.high_gain_factor_red = ptr->high_gain_factor_red; 2333 - p.recalibration_min_red = ptr->recalibration_min_red; 2334 - p.recalibration_max_red = ptr->recalibration_max_red; 2335 - p.lmin_green = ptr->lmin_green; 2336 - p.lmax_green = ptr->lmax_green; 2337 - p.qcalmin_green = ptr->qcalmin_green; 2338 - p.qcalmax_green = ptr->qcalmax_green; 2339 - p.gain_low_green = ptr->gain_low_green; 2340 - p.spectral_irradiance_green = ptr->spectral_irradiance_green; 2341 - p.low_gain_factor_green = ptr->low_gain_factor_green; 2342 - p.high_gain_factor_green = ptr->high_gain_factor_green; 2343 - p.recalibration_min_green = ptr->recalibration_min_green; 2344 - p.recalibration_max_green = ptr->recalibration_max_green; 2345 - p.lmin_blue = ptr->lmin_blue; 2346 - p.lmax_blue = ptr->lmax_blue; 2347 - p.qcalmin_blue = ptr->qcalmin_blue; 2348 - p.qcalmax_blue = ptr->qcalmax_blue; 2349 - p.gain_low_blue = ptr->gain_low_blue; 2350 - p.spectral_irradiance_blue = ptr->spectral_irradiance_blue; 2351 - p.low_gain_factor_blue = ptr->low_gain_factor_blue; 2352 - p.high_gain_factor_blue = ptr->high_gain_factor_blue; 2353 - p.recalibration_min_blue = ptr->recalibration_min_blue; 2354 - p.recalibration_max_blue = ptr->recalibration_max_blue; 2355 - p.sun_distance = ptr->sun_distance; 2356 - p.sun_elevation = ptr->sun_elevation; 2357 - 2358 - for (y = ptr->min_row; y < ptr->max_row; y++) 2359 - { 2360 - p_red = ptr->img_red->pixels + (y * ptr->img_red->scanline_width); 2361 - p_green = 2362 - ptr->img_green->pixels + (y * ptr->img_green->scanline_width); 2363 - p_blue = ptr->img_blue->pixels + (y * ptr->img_blue->scanline_width); 2364 - p_rgb = ptr->img_out->pixels + (y * ptr->img_out->scanline_width); 2365 - for (x = 0; x < ptr->width; x++) 2366 - { 2367 - red = *p_red++; 2368 - green = *p_green++; 2369 - blue = *p_blue++; 2370 - if (red == 0 || green == 0 || blue == 0) 2371 - { 2372 - red = 0; 2373 - green = 0; 2374 - blue = 0; 2375 - } 2376 - else 2377 - { 2378 - p.value = red; 2379 - p.band = LANDSAT_RED; 2380 - landsat_recalibrate (&p); 2381 - red = p.value; 2382 - p.value = green; 2383 - p.band = LANDSAT_GREEN; 2384 - landsat_recalibrate (&p); 2385 - green = p.value; 2386 - p.value = blue; 2387 - p.band = LANDSAT_BLUE; 2388 - landsat_recalibrate (&p); 2389 - blue = p.value; 2390 - } 2391 - *p_rgb++ = red; 2392 - *p_rgb++ = green; 2393 - *p_rgb++ = blue; 2394 - } 2395 - } 2396 -} 2397 - 2398 -#ifdef _WIN32 2399 -static DWORD WINAPI 2400 -#else 2401 -static void * 2402 -#endif 2403 -landsat_rgb_recalibrate (void *arg) 2404 -{ 2405 -/* threaded function: rendering an RGB Landsat sub-strip */ 2406 - struct thread_landsat_recalibrate *params = 2407 - (struct thread_landsat_recalibrate *) arg; 2408 - landsat_rgb (params); 2409 -#ifdef _WIN32 2410 - return 0; 2411 -#else 2412 - pthread_exit (NULL); 2413 -#endif 2414 -} 2415 - 2416 -GGRAPH_DECLARE int 2417 -gGraphLandsatRGB (const void *red_ptr, const void *green_ptr, 2418 - const void *blue_ptr, const void *rgb_ptr, int width, 2419 - int num_rows, gGraphLandsatRecalibrationPtr params, 2420 - int num_threads) 2421 -{ 2422 -/* processing a whole RGB Landsat strip (may be, in a multithreaded way) */ 2423 - 2424 - gGraphStripImagePtr img_red = (gGraphStripImagePtr) red_ptr; 2425 - gGraphStripImagePtr img_green = (gGraphStripImagePtr) green_ptr; 2426 - gGraphStripImagePtr img_blue = (gGraphStripImagePtr) blue_ptr; 2427 - gGraphStripImagePtr img_rgb = (gGraphStripImagePtr) rgb_ptr; 2428 - int nt; 2429 - struct thread_landsat_recalibrate threads[GG_MAX_THREADS]; 2430 -#ifdef _WIN32 2431 - HANDLE thread_handles[GG_MAX_THREADS]; 2432 - DWORD dwThreadIdArray[GG_MAX_THREADS]; 2433 -#else 2434 - pthread_t thread_ids[GG_MAX_THREADS]; 2435 -#endif 2436 - 2437 - if (img_red == NULL || img_green == NULL || img_blue == NULL 2438 - || img_rgb == NULL) 2439 - return GGRAPH_INVALID_IMAGE; 2440 - if (img_red->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2441 - return GGRAPH_INVALID_IMAGE; 2442 - if (img_green->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2443 - return GGRAPH_INVALID_IMAGE; 2444 - if (img_blue->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2445 - return GGRAPH_INVALID_IMAGE; 2446 - if (img_rgb->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2447 - return GGRAPH_INVALID_IMAGE; 2448 - if (img_red->pixel_format == GG_PIXEL_GRAYSCALE 2449 - && img_green->pixel_format == GG_PIXEL_GRAYSCALE 2450 - && img_blue->pixel_format == GG_PIXEL_GRAYSCALE 2451 - && img_rgb->pixel_format == GG_PIXEL_RGB) 2452 - ; 2453 - else 2454 - return GGRAPH_INVALID_IMAGE; 2455 - if (img_red->width == width && img_green->width == width 2456 - && img_blue->width == width && img_rgb->width == width) 2457 - ; 2458 - else 2459 - return GGRAPH_INVALID_IMAGE; 2460 - if (img_red->current_available_rows == num_rows 2461 - && img_green->current_available_rows == num_rows 2462 - && img_blue->current_available_rows == num_rows 2463 - && img_rgb->rows_per_block >= num_rows) 2464 - ; 2465 - else 2466 - return GGRAPH_INVALID_IMAGE; 2467 - 2468 - if (num_threads > GG_MAX_THREADS) 2469 - num_threads = GG_MAX_THREADS; 2470 - if (num_threads < 1) 2471 - num_threads = 1; 2472 - 2473 - for (nt = 0; nt < num_threads; nt++) 2474 - { 2475 - /* setting up the recalibrate struct */ 2476 - threads[nt].img_red = img_red; 2477 - threads[nt].img_green = img_green; 2478 - threads[nt].img_blue = img_blue; 2479 - threads[nt].img_out = img_rgb; 2480 - threads[nt].width = width; 2481 - threads[nt].lmin_red = params->lmin_red; 2482 - threads[nt].lmax_red = params->lmax_red; 2483 - threads[nt].qcalmin_red = params->qcalmin_red; 2484 - threads[nt].qcalmax_red = params->qcalmax_red; 2485 - threads[nt].gain_low_red = params->is_gain_low_red; 2486 - threads[nt].spectral_irradiance_red = params->spectral_irradiance_red; 2487 - threads[nt].low_gain_factor_red = params->low_gain_factor_red; 2488 - threads[nt].high_gain_factor_red = params->high_gain_factor_red; 2489 - threads[nt].recalibration_min_red = params->recalibration_min_red; 2490 - threads[nt].recalibration_max_red = params->recalibration_max_red; 2491 - threads[nt].lmin_green = params->lmin_green; 2492 - threads[nt].lmax_green = params->lmax_green; 2493 - threads[nt].qcalmin_green = params->qcalmin_green; 2494 - threads[nt].qcalmax_green = params->qcalmax_green; 2495 - threads[nt].gain_low_green = params->is_gain_low_green; 2496 - threads[nt].spectral_irradiance_green = 2497 - params->spectral_irradiance_green; 2498 - threads[nt].low_gain_factor_green = params->low_gain_factor_green; 2499 - threads[nt].high_gain_factor_green = params->high_gain_factor_green; 2500 - threads[nt].recalibration_min_green = params->recalibration_min_green; 2501 - threads[nt].recalibration_max_green = params->recalibration_max_green; 2502 - threads[nt].lmin_blue = params->lmin_blue; 2503 - threads[nt].lmax_blue = params->lmax_blue; 2504 - threads[nt].qcalmin_blue = params->qcalmin_blue; 2505 - threads[nt].qcalmax_blue = params->qcalmax_blue; 2506 - threads[nt].gain_low_blue = params->is_gain_low_blue; 2507 - threads[nt].spectral_irradiance_blue = 2508 - params->spectral_irradiance_blue; 2509 - threads[nt].low_gain_factor_blue = params->low_gain_factor_blue; 2510 - threads[nt].high_gain_factor_blue = params->high_gain_factor_blue; 2511 - threads[nt].recalibration_min_blue = params->recalibration_min_blue; 2512 - threads[nt].recalibration_max_blue = params->recalibration_max_blue; 2513 - threads[nt].sun_distance = params->sun_distance; 2514 - threads[nt].sun_elevation = params->sun_elevation; 2515 - } 2516 - 2517 - if (num_threads == 1) 2518 - { 2519 - /* not using concurrent multithreading */ 2520 - threads[0].min_row = 0; 2521 - threads[0].max_row = num_rows; 2522 - landsat_rgb (&(threads[0])); 2523 - } 2524 - else 2525 - { 2526 - /* using concurrent multithreading */ 2527 - int base_row = 0; 2528 - int rows_per_thread = num_rows / num_threads; 2529 - if ((rows_per_thread * num_threads) < num_rows) 2530 - rows_per_thread++; 2531 - for (nt = 0; nt < num_threads; nt++) 2532 - { 2533 - int max_row = base_row + rows_per_thread; 2534 - if (max_row >= num_rows) 2535 - max_row = num_rows; 2536 - threads[nt].min_row = base_row; 2537 - threads[nt].max_row = max_row; 2538 - base_row += rows_per_thread; 2539 -#ifdef _WIN32 2540 - thread_handles[nt] = 2541 - CreateThread (NULL, 0, landsat_rgb_recalibrate, 2542 - &(threads[nt]), 0, &dwThreadIdArray[nt]); 2543 -#else 2544 - pthread_create (&(thread_ids[nt]), NULL, 2545 - landsat_rgb_recalibrate, &(threads[nt])); 2546 -#endif 2547 - } 2548 - /* waiting until any concurrent thread terminates */ 2549 -#ifdef _WIN32 2550 - WaitForMultipleObjects (num_threads, thread_handles, TRUE, INFINITE); 2551 -#else 2552 - for (nt = 0; nt < num_threads; nt++) 2553 - pthread_join (thread_ids[nt], NULL); 2554 -#endif 2555 - } 2556 - 2557 - return GGRAPH_OK; 2558 -} 2559 - 2560 -static void 2561 -landsat_bw (struct thread_landsat_recalibrate *ptr) 2562 -{ 2563 -/* precessing a B&W Landsat sub-strip */ 2564 - int x; 2565 - int y; 2566 - unsigned char gray; 2567 - unsigned char *p_in; 2568 - unsigned char *p_out; 2569 - struct thread_landsat_recalibrate p; 2570 - 2571 -/* setting up the recalibrate struct */ 2572 - p.lmin_panchro = ptr->lmin_panchro; 2573 - p.lmax_panchro = ptr->lmax_panchro; 2574 - p.qcalmin_panchro = ptr->qcalmin_panchro; 2575 - p.qcalmax_panchro = ptr->qcalmax_panchro; 2576 - p.gain_low_panchro = ptr->gain_low_panchro; 2577 - p.spectral_irradiance_panchro = ptr->spectral_irradiance_panchro; 2578 - p.low_gain_factor_panchro = ptr->low_gain_factor_panchro; 2579 - p.high_gain_factor_panchro = ptr->high_gain_factor_panchro; 2580 - p.recalibration_min_panchro = ptr->recalibration_min_panchro; 2581 - p.recalibration_max_panchro = ptr->recalibration_max_panchro; 2582 - p.sun_distance = ptr->sun_distance; 2583 - p.sun_elevation = ptr->sun_elevation; 2584 - 2585 - for (y = ptr->min_row; y < ptr->max_row; y++) 2586 - { 2587 - p_in = ptr->img_red->pixels + (y * ptr->img_red->scanline_width); 2588 - p_out = ptr->img_out->pixels + (y * ptr->img_out->scanline_width); 2589 - for (x = 0; x < ptr->width; x++) 2590 - { 2591 - gray = *p_in++; 2592 - if (gray == 0) 2593 - gray = 0; 2594 - else 2595 - { 2596 - p.value = gray; 2597 - p.band = LANDSAT_PANCHRO; 2598 - landsat_recalibrate (&p); 2599 - gray = p.value; 2600 - } 2601 - *p_out++ = gray; 2602 - } 2603 - } 2604 -} 2605 - 2606 -#ifdef _WIN32 2607 -static DWORD WINAPI 2608 -#else 2609 -static void * 2610 -#endif 2611 -landsat_bw_recalibrate (void *arg) 2612 -{ 2613 -/* threaded function: rendering a B&W Landsat sub-strip */ 2614 - struct thread_landsat_recalibrate *params = 2615 - (struct thread_landsat_recalibrate *) arg; 2616 - landsat_bw (params); 2617 -#ifdef _WIN32 2618 - return 0; 2619 -#else 2620 - pthread_exit (NULL); 2621 -#endif 2622 -} 2623 - 2624 -GGRAPH_DECLARE int 2625 -gGraphLandsatBW (const void *in_ptr, const void *out_ptr, int width, 2626 - int num_rows, gGraphLandsatRecalibrationPtr params, 2627 - int num_threads) 2628 -{ 2629 -/* processing a whole B&W Landsat strip (may be, in a multithreaded way) */ 2630 - gGraphStripImagePtr img_in = (gGraphStripImagePtr) in_ptr; 2631 - gGraphStripImagePtr img_out = (gGraphStripImagePtr) out_ptr; 2632 - int nt; 2633 - struct thread_landsat_recalibrate threads[GG_MAX_THREADS]; 2634 -#ifdef _WIN32 2635 - HANDLE thread_handles[GG_MAX_THREADS]; 2636 - DWORD dwThreadIdArray[GG_MAX_THREADS]; 2637 -#else 2638 - pthread_t thread_ids[GG_MAX_THREADS]; 2639 -#endif 2640 - 2641 - if (img_in == NULL || img_out == NULL) 2642 - return GGRAPH_INVALID_IMAGE; 2643 - if (img_in->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2644 - return GGRAPH_INVALID_IMAGE; 2645 - if (img_out->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2646 - return GGRAPH_INVALID_IMAGE; 2647 - if (img_in->pixel_format == GG_PIXEL_GRAYSCALE 2648 - && img_out->pixel_format == GG_PIXEL_GRAYSCALE) 2649 - ; 2650 - else 2651 - return GGRAPH_INVALID_IMAGE; 2652 - if (img_in->width == width && img_out->width == width) 2653 - ; 2654 - else 2655 - return GGRAPH_INVALID_IMAGE; 2656 - if (img_in->current_available_rows == num_rows 2657 - && img_out->rows_per_block >= num_rows) 2658 - ; 2659 - else 2660 - return GGRAPH_INVALID_IMAGE; 2661 - 2662 - if (num_threads > GG_MAX_THREADS) 2663 - num_threads = GG_MAX_THREADS; 2664 - if (num_threads < 1) 2665 - num_threads = 1; 2666 - 2667 - for (nt = 0; nt < num_threads; nt++) 2668 - { 2669 - /* setting up the recalibrate struct */ 2670 - threads[nt].img_red = img_in; 2671 - threads[nt].img_out = img_out; 2672 - threads[nt].width = width; 2673 - threads[nt].lmin_panchro = params->lmin_panchro; 2674 - threads[nt].lmax_panchro = params->lmax_panchro; 2675 - threads[nt].qcalmin_panchro = params->qcalmin_panchro; 2676 - threads[nt].qcalmax_panchro = params->qcalmax_panchro; 2677 - threads[nt].gain_low_panchro = params->is_gain_low_panchro; 2678 - threads[nt].spectral_irradiance_panchro = 2679 - params->spectral_irradiance_panchro; 2680 - threads[nt].low_gain_factor_panchro = params->low_gain_factor_panchro; 2681 - threads[nt].high_gain_factor_panchro = 2682 - params->high_gain_factor_panchro; 2683 - threads[nt].recalibration_min_panchro = 2684 - params->recalibration_min_panchro; 2685 - threads[nt].recalibration_max_panchro = 2686 - params->recalibration_max_panchro; 2687 - threads[nt].sun_distance = params->sun_distance; 2688 - threads[nt].sun_elevation = params->sun_elevation; 2689 - } 2690 - 2691 - if (num_threads == 1) 2692 - { 2693 - /* not using concurrent multithreading */ 2694 - threads[0].min_row = 0; 2695 - threads[0].max_row = num_rows; 2696 - landsat_bw (&(threads[0])); 2697 - } 2698 - else 2699 - { 2700 - /* using concurrent multithreading */ 2701 - int base_row = 0; 2702 - int rows_per_thread = num_rows / num_threads; 2703 - if ((rows_per_thread * num_threads) < num_rows) 2704 - rows_per_thread++; 2705 - for (nt = 0; nt < num_threads; nt++) 2706 - { 2707 - int max_row = base_row + rows_per_thread; 2708 - if (max_row >= num_rows) 2709 - max_row = num_rows; 2710 - threads[nt].min_row = base_row; 2711 - threads[nt].max_row = max_row; 2712 - base_row += rows_per_thread; 2713 -#ifdef _WIN32 2714 - thread_handles[nt] = 2715 - CreateThread (NULL, 0, landsat_bw_recalibrate, 2716 - &(threads[nt]), 0, &dwThreadIdArray[nt]); 2717 -#else 2718 - pthread_create (&(thread_ids[nt]), NULL, 2719 - landsat_bw_recalibrate, &(threads[nt])); 2720 -#endif 2721 - } 2722 - /* waiting until any concurrent thread terminates */ 2723 -#ifdef _WIN32 2724 - WaitForMultipleObjects (num_threads, thread_handles, TRUE, INFINITE); 2725 -#else 2726 - for (nt = 0; nt < num_threads; nt++) 2727 - pthread_join (thread_ids[nt], NULL); 2728 -#endif 2729 - } 2730 - 2731 - return GGRAPH_OK; 2732 -} 2733 - 2734 -GGRAPH_DECLARE int 2735 -gGraphGetLandsatSceneExtent (const void *ptr, int base_row, double *top_x, 2736 - double *top_y, double *bottom_x, double *bottom_y, 2737 - double *left_x, double *left_y, double *right_x, 2738 - double *right_y) 2739 -{ 2740 -/* determing the actual Landsat scene extent (by strips) */ 2741 - int x; 2742 - int y; 2743 - unsigned char *p_in; 2744 - unsigned char gray; 2745 - unsigned char red; 2746 - unsigned char green; 2747 - unsigned char blue; 2748 - double px; 2749 - double py; 2750 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2751 - 2752 - if (img == NULL) 2753 - return GGRAPH_INVALID_IMAGE; 2754 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2755 - return GGRAPH_INVALID_IMAGE; 2756 - if (img->pixel_format == GG_PIXEL_GRAYSCALE 2757 - || img->pixel_format == GG_PIXEL_RGB) 2758 - ; 2759 - else 2760 - return GGRAPH_INVALID_IMAGE; 2761 - 2762 - *top_x = 0.0 - DBL_MAX; 2763 - *top_y = 0.0 - DBL_MAX; 2764 - *bottom_x = DBL_MAX; 2765 - *bottom_y = DBL_MAX; 2766 - *left_x = DBL_MAX; 2767 - *left_y = DBL_MAX; 2768 - *right_x = 0.0 - DBL_MAX; 2769 - *right_y = 0.0 - DBL_MAX; 2770 - 2771 - for (y = 0; y < img->current_available_rows; y++) 2772 - { 2773 - p_in = img->pixels + (y * img->scanline_width); 2774 - for (x = 0; x < img->width; x++) 2775 - { 2776 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2777 - { 2778 - gray = *p_in++; 2779 - if (gray == 0) 2780 - continue; 2781 - } 2782 - else 2783 - { 2784 - red = *p_in++; 2785 - green = *p_in++; 2786 - blue = *p_in++; 2787 - if (red == 0 || green == 0 || blue == 0) 2788 - continue; 2789 - } 2790 - /* ok, this one is a valid scene's pixel */ 2791 - px = img->upper_left_x + ((double) x * img->pixel_x_size); 2792 - py = img->upper_left_y - 2793 - ((double) (base_row + y) * img->pixel_y_size); 2794 - if (py > *top_y) 2795 - { 2796 - *top_y = py; 2797 - *top_x = px; 2798 - } 2799 - if (py < *bottom_y) 2800 - { 2801 - *bottom_y = py; 2802 - *bottom_x = px; 2803 - } 2804 - if (px < *left_x) 2805 - { 2806 - *left_x = px; 2807 - *left_y = py; 2808 - } 2809 - if (px > *right_x) 2810 - { 2811 - *right_x = px; 2812 - *right_y = py; 2813 - } 2814 - } 2815 - } 2816 - return GGRAPH_OK; 2817 -} 2818 - 2819 -GGRAPH_DECLARE int 2820 -gGraphLandsatMergePixels (const void *ptr_in, int base_row, const void *ptr_out) 2821 -{ 2822 -/* merging pixels between two images by Geographic position */ 2823 - int x; 2824 - int y; 2825 - unsigned char *p_in; 2826 - unsigned char *p_out; 2827 - unsigned char gray; 2828 - unsigned char red; 2829 - unsigned char green; 2830 - unsigned char blue; 2831 - double geo_x; 2832 - double geo_y; 2833 - int out_x; 2834 - int out_y; 2835 - double dout_x; 2836 - double dout_y; 2837 - double diff_x; 2838 - double diff_y; 2839 - gGraphStripImagePtr img_in = (gGraphStripImagePtr) ptr_in; 2840 - gGraphImagePtr img_out = (gGraphImagePtr) ptr_out; 2841 - 2842 - if (img_in == NULL) 2843 - return GGRAPH_INVALID_IMAGE; 2844 - if (img_out == NULL) 2845 - return GGRAPH_INVALID_IMAGE; 2846 - if (img_in->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2847 - return GGRAPH_INVALID_IMAGE; 2848 - if (img_out->signature != GG_IMAGE_MAGIC_SIGNATURE) 2849 - return GGRAPH_INVALID_IMAGE; 2850 - if (img_in->pixel_format == GG_PIXEL_GRAYSCALE 2851 - || img_in->pixel_format == GG_PIXEL_RGB) 2852 - ; 2853 - else 2854 - return GGRAPH_INVALID_IMAGE; 2855 - if (img_in->pixel_format != img_out->pixel_format) 2856 - return GGRAPH_INVALID_IMAGE; 2857 - if (img_in->srid != img_out->srid) 2858 - return GGRAPH_INVALID_IMAGE; 2859 - 2860 - for (y = 0; y < img_in->current_available_rows; y++) 2861 - { 2862 - p_in = img_in->pixels + (y * img_in->scanline_width); 2863 - for (x = 0; x < img_in->width; x++) 2864 - { 2865 - if (img_in->pixel_format == GG_PIXEL_GRAYSCALE) 2866 - { 2867 - gray = *p_in++; 2868 - if (gray == 0) 2869 - continue; 2870 - } 2871 - else 2872 - { 2873 - red = *p_in++; 2874 - green = *p_in++; 2875 - blue = *p_in++; 2876 - if (red == 0 || green == 0 || blue == 0) 2877 - continue; 2878 - } 2879 - /* ok, this one is a valid scene's pixel */ 2880 - geo_x = 2881 - img_in->upper_left_x + ((double) x * img_in->pixel_x_size); 2882 - geo_y = 2883 - img_in->upper_left_y - 2884 - ((double) (base_row + y) * img_in->pixel_y_size); 2885 - dout_x = 2886 - ((geo_x - img_out->upper_left_x) / img_out->pixel_x_size); 2887 - dout_y = 2888 - ((img_out->upper_left_y - geo_y) / img_out->pixel_y_size); 2889 - out_x = (int) dout_x; 2890 - out_y = (int) dout_y; 2891 - diff_x = dout_x - (double) out_x; 2892 - diff_y = dout_y - (double) out_y; 2893 - if (diff_x >= 0.5) 2894 - out_x++; 2895 - if (diff_y >= 0.5) 2896 - out_y++; 2897 - if (out_x < 0 || out_x >= img_out->width) 2898 - continue; 2899 - if (out_y < 0 || out_y >= img_out->height) 2900 - continue; 2901 - /* ok, setting this pixel into the output image */ 2902 - p_out = 2903 - img_out->pixels + (out_y * img_out->scanline_width) + 2904 - (out_x * img_out->pixel_size); 2905 - if (img_out->pixel_format == GG_PIXEL_GRAYSCALE) 2906 - *p_out++ = gray; 2907 - else 2908 - { 2909 - *p_out++ = red; 2910 - *p_out++ = green; 2911 - *p_out++ = blue; 2912 - } 2913 - } 2914 - } 2915 - 2916 - return GGRAPH_OK; 2917 -} 2918 - 2919 -static unsigned char 2920 -to_grayscale3 (unsigned char r, unsigned char g, unsigned char b) 2921 -{ 2922 -/* computing a grayscale value */ 2923 - double dval = 2924 - (0.3 * (double) r) + (0.59 * (double) g) + (0.11 * (double) b); 2925 - int ival = (int) dval; 2926 - if (ival < 0) 2927 - ival = 0; 2928 - if (ival > 255) 2929 - ival = 255; 2930 - return (unsigned char) ival; 2931 -} 2932 - 2933 -static int 2934 -merge_grid (gGraphImagePtr img_in, gGraphImagePtr img_out) 2935 -{ 2936 -/* mergine pixels between two GRIDS by Geographics position */ 2937 - int x; 2938 - int y; 2939 - unsigned char *p_in; 2940 - unsigned char *p_out; 2941 - double value; 2942 - double geo_x; 2943 - double geo_y; 2944 - int out_x; 2945 - int out_y; 2946 - double dout_x; 2947 - double dout_y; 2948 - double diff_x; 2949 - double diff_y; 2950 - for (y = 0; y < img_in->height; y++) 2951 - { 2952 - p_in = img_in->pixels + (y * img_in->scanline_width); 2953 - for (x = 0; x < img_in->width; x++) 2954 - { 2955 - switch (img_in->sample_format) 2956 - { 2957 - case GGRAPH_SAMPLE_INT: 2958 - if (img_in->bits_per_sample == 16) 2959 - { 2960 - short *p = (short *) p_in; 2961 - value = *p; 2962 - p_in += sizeof (short); 2963 - } 2964 - else 2965 - { 2966 - int *p = (int *) p_in; 2967 - value = *p; 2968 - p_in += sizeof (int); 2969 - } 2970 - break; 2971 - case GGRAPH_SAMPLE_UINT: 2972 - if (img_in->bits_per_sample == 16) 2973 - { 2974 - unsigned short *p = (unsigned short *) p_in; 2975 - value = *p; 2976 - p_in += sizeof (unsigned short); 2977 - } 2978 - else 2979 - { 2980 - unsigned int *p = (unsigned int *) p_in; 2981 - value = *p; 2982 - p_in += sizeof (unsigned int); 2983 - } 2984 - break; 2985 - case GGRAPH_SAMPLE_FLOAT: 2986 - if (img_in->bits_per_sample == 32) 2987 - { 2988 - float *p = (float *) p_in; 2989 - value = *p; 2990 - p_in += sizeof (float); 2991 - } 2992 - else 2993 - { 2994 - double *p = (double *) p_in; 2995 - value = *p; 2996 - p_in += sizeof (double); 2997 - } 2998 - break; 2999 - }; 3000 - if (value == img_in->no_data_value) 3001 - { 3002 - /* NoData pixel: skipping */ 3003 - continue; 3004 - } 3005 - /* ok, this one is a valid scene's pixel */ 3006 - geo_x = 3007 - img_in->upper_left_x + ((double) x * img_in->pixel_x_size); 3008 - geo_y = 3009 - img_in->upper_left_y - ((double) y * img_in->pixel_y_size); 3010 - dout_x = 3011 - ((geo_x - img_out->upper_left_x) / img_out->pixel_x_size); 3012 - dout_y = 3013 - ((img_out->upper_left_y - geo_y) / img_out->pixel_y_size); 3014 - out_x = (int) dout_x; 3015 - out_y = (int) dout_y; 3016 - diff_x = dout_x - (double) out_x; 3017 - diff_y = dout_y - (double) out_y; 3018 - if (diff_x >= 0.5) 3019 - out_x++; 3020 - if (diff_y >= 0.5) 3021 - out_y++; 3022 - if (out_x < 0 || out_x >= img_out->width) 3023 - continue; 3024 - if (out_y < 0 || out_y >= img_out->height) 3025 - continue; 3026 - /* ok, setting this pixel into the output image */ 3027 - p_out = 3028 - img_out->pixels + (out_y * img_out->scanline_width) + 3029 - (out_x * img_out->pixel_size); 3030 - switch (img_out->sample_format) 3031 - { 3032 - case GGRAPH_SAMPLE_INT: 3033 - if (img_out->bits_per_sample == 16) 3034 - { 3035 - short *p = (short *) p_out; 3036 - *p = (short) value; 3037 - p_out += sizeof (short); 3038 - } 3039 - else 3040 - { 3041 - int *p = (int *) p_out; 3042 - *p = (int) value; 3043 - p_out += sizeof (int); 3044 - } 3045 - break; 3046 - case GGRAPH_SAMPLE_UINT: 3047 - if (img_out->bits_per_sample == 16) 3048 - { 3049 - unsigned short *p = (unsigned short *) p_out; 3050 - *p = (unsigned short) value; 3051 - p_out += sizeof (unsigned short); 3052 - } 3053 - else 3054 - { 3055 - unsigned int *p = (unsigned int *) p_out; 3056 - *p = (unsigned int) value; 3057 - p_out += sizeof (unsigned int); 3058 - } 3059 - break; 3060 - case GGRAPH_SAMPLE_FLOAT: 3061 - if (img_out->bits_per_sample == 32) 3062 - { 3063 - float *p = (float *) p_out; 3064 - *p = (float) value; 3065 - p_out += sizeof (float); 3066 - } 3067 - else 3068 - { 3069 - double *p = (double *) p_out; 3070 - *p = value; 3071 - p_out += sizeof (double); 3072 - } 3073 - break; 3074 - }; 3075 - } 3076 - } 3077 - return GGRAPH_OK; 3078 -} 3079 - 3080 -GGRAPH_DECLARE int 3081 -gGraphGeoMergePixels (const void *ptr_in, const void *ptr_out) 3082 -{ 3083 -/* merging pixels between two images by Geographic position */ 3084 - int x; 3085 - int y; 3086 - unsigned char *p_in; 3087 - unsigned char *p_out; 3088 - unsigned char gray; 3089 - unsigned char red; 3090 - unsigned char green; 3091 - unsigned char blue; 3092 - double geo_x; 3093 - double geo_y; 3094 - int out_x; 3095 - int out_y; 3096 - double dout_x; 3097 - double dout_y; 3098 - double diff_x; 3099 - double diff_y; 3100 - gGraphImagePtr img_in = (gGraphImagePtr) ptr_in; 3101 - gGraphImagePtr img_out = (gGraphImagePtr) ptr_out; 3102 - 3103 - if (img_in == NULL) 3104 - return GGRAPH_INVALID_IMAGE; 3105 - if (img_out == NULL) 3106 - return GGRAPH_INVALID_IMAGE; 3107 - if (img_in->signature != GG_IMAGE_MAGIC_SIGNATURE) 3108 - return GGRAPH_INVALID_IMAGE; 3109 - if (img_out->signature != GG_IMAGE_MAGIC_SIGNATURE) 3110 - return GGRAPH_INVALID_IMAGE; 3111 - if (img_in->srid != img_out->srid) 3112 - return GGRAPH_INVALID_IMAGE; 3113 - 3114 - if (img_in->pixel_format == GG_PIXEL_GRID) 3115 - { 3116 - if (img_out->pixel_format == GG_PIXEL_GRID) 3117 - return merge_grid (img_in, img_out); 3118 - return GGRAPH_INVALID_IMAGE; 3119 - } 3120 - 3121 - for (y = 0; y < img_in->height; y++) 3122 - { 3123 - p_in = img_in->pixels + (y * img_in->scanline_width); 3124 - for (x = 0; x < img_in->width; x++) 3125 - { 3126 - if (img_in->pixel_format == GG_PIXEL_GRAYSCALE) 3127 - { 3128 - gray = *p_in++; 3129 - red = gray; 3130 - green = gray; 3131 - blue = gray; 3132 - } 3133 - else if (img_in->pixel_format == GG_PIXEL_PALETTE) 3134 - { 3135 - int index = *p_in++; 3136 - red = img_in->palette_red[index]; 3137 - green = img_in->palette_green[index]; 3138 - blue = img_in->palette_blue[index]; 3139 - if (red == green && red == blue) 3140 - gray = red; 3141 - else 3142 - gray = to_grayscale3 (red, green, blue); 3143 - } 3144 - else 3145 - { 3146 - red = *p_in++; 3147 - green = *p_in++; 3148 - blue = *p_in++; 3149 - if (red == green && red == blue) 3150 - gray = red; 3151 - else 3152 - gray = to_grayscale3 (red, green, blue); 3153 - } 3154 - /* ok, this one is a valid scene's pixel */ 3155 - geo_x = 3156 - img_in->upper_left_x + ((double) x * img_in->pixel_x_size); 3157 - geo_y = 3158 - img_in->upper_left_y - ((double) y * img_in->pixel_y_size); 3159 - dout_x = 3160 - ((geo_x - img_out->upper_left_x) / img_out->pixel_x_size); 3161 - dout_y = 3162 - ((img_out->upper_left_y - geo_y) / img_out->pixel_y_size); 3163 - out_x = (int) dout_x; 3164 - out_y = (int) dout_y; 3165 - diff_x = dout_x - (double) out_x; 3166 - diff_y = dout_y - (double) out_y; 3167 - if (diff_x >= 0.5) 3168 - out_x++; 3169 - if (diff_y >= 0.5) 3170 - out_y++; 3171 - if (out_x < 0 || out_x >= img_out->width) 3172 - continue; 3173 - if (out_y < 0 || out_y >= img_out->height) 3174 - continue; 3175 - /* ok, setting this pixel into the output image */ 3176 - p_out = 3177 - img_out->pixels + (out_y * img_out->scanline_width) + 3178 - (out_x * img_out->pixel_size); 3179 - if (img_out->pixel_format == GG_PIXEL_GRAYSCALE) 3180 - *p_out++ = gray; 3181 - else if (img_out->pixel_format == GG_PIXEL_RGBA) 3182 - { 3183 - *p_out++ = red; 3184 - *p_out++ = green; 3185 - *p_out++ = blue; 3186 - *p_out++ = 255; 3187 - } 3188 - else 3189 - { 3190 - *p_out++ = red; 3191 - *p_out++ = green; 3192 - *p_out++ = blue; 3193 - } 3194 - } 3195 - } 3196 - 3197 - return GGRAPH_OK; 3198 -}
Deleted src/gaiagraphics_gif.c.
1 -/* 2 -/ gaiagraphics_gif.c 3 -/ 4 -/ GIF auxiliary helpers 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdio.h> 28 -#include <math.h> 29 -#include <string.h> 30 -#include <stdlib.h> 31 - 32 -#include "gaiagraphics.h" 33 -#include "gaiagraphics_internals.h" 34 - 35 -/* 36 -/ 37 -/ DISCLAIMER: 38 -/ all the following code merely is an 'ad hoc' adaption 39 -/ deriving from the original GD lib code 40 -/ which in turn is based on he following: 41 -/ 42 -** Code drawn from ppmtogif.c, from the pbmplus package 43 -** 44 -** Based on GIFENCOD by David Rowley <mgardi@watdscu.waterloo.edu>. A 45 -** Lempel-Zim compression based on "compress". 46 -** 47 -** Modified by Marcel Wijkstra <wijkstra@fwi.uva.nl> 48 -** 49 -** Copyright (C) 1989 by Jef Poskanzer. 50 -** 51 -** Permission to use, copy, modify, and distribute this software and its 52 -** documentation for any purpose and without fee is hereby granted, provided 53 -** that the above copyright notice appear in all copies and that both that 54 -** copyright notice and this permission notice appear in supporting 55 -** documentation. This software is provided "as is" without express or 56 -** implied warranty. 57 -** 58 -** The Graphics Interchange Format(c) is the Copyright property of 59 -** CompuServe Incorporated. GIF(sm) is a Service Mark property of 60 -** CompuServe Incorporated. 61 -/ 62 -*/ 63 - 64 -typedef int code_int; 65 - 66 -#ifdef SIGNED_COMPARE_SLOW 67 -typedef unsigned long int count_int; 68 -typedef unsigned short int count_short; 69 -#else /*SIGNED_COMPARE_SLOW */ 70 -typedef long int count_int; 71 -#endif /*SIGNED_COMPARE_SLOW */ 72 - 73 -#define GIFBITS 12 74 - 75 -#define maxbits GIFBITS 76 - 77 -#define maxmaxcode ((code_int)1 << GIFBITS) 78 - 79 -#define HSIZE 5003 80 -#define hsize HSIZE 81 - 82 -#ifdef COMPATIBLE 83 -#define MAXCODE(n_bits) ((code_int) 1 << (n_bits) - 1) 84 -#else /*COMPATIBLE*/ 85 -#define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1) 86 -#endif /*COMPATIBLE*/ 87 -#define HashTabOf(i) ctx->htab[i] 88 -#define CodeTabOf(i) ctx->codetab[i] 89 - typedef struct 90 -{ 91 - int Width, Height; 92 - int curx, cury; 93 - long CountDown; 94 - int Pass; 95 - int Interlace; 96 - int n_bits; 97 - code_int maxcode; 98 - count_int htab[HSIZE]; 99 - unsigned short codetab[HSIZE]; 100 - code_int free_ent; 101 - int clear_flg; 102 - int offset; 103 - long int in_count; 104 - long int out_count; 105 - int g_init_bits; 106 - xgdIOCtx *g_outfile; 107 - int ClearCode; 108 - int EOFCode; 109 - unsigned long cur_accum; 110 - int cur_bits; 111 - int a_count; 112 - char accum[256]; 113 -} GifCtx; 114 - 115 -#define MAXCOLORMAPSIZE 256 116 - 117 -#define TRUE 1 118 -#define FALSE 0 119 - 120 -#define CM_RED 0 121 -#define CM_GREEN 1 122 -#define CM_BLUE 2 123 - 124 -#define MAX_LWZ_BITS 12 125 - 126 -#define INTERLACE 0x40 127 -#define LOCALCOLORMAP 0x80 128 - 129 -#define BitSet(byte, bit) (((byte) & (bit)) == (bit)) 130 -#define ReadOK(file,buffer,len) (xgdGetBuf(buffer, len, file) > 0) 131 -#define LM_to_uint(a,b) (((b)<<8)|(a)) 132 - 133 -#define STACK_SIZE ((1<<(MAX_LWZ_BITS))*2) 134 - 135 -typedef struct 136 -{ 137 - unsigned char buf[280]; 138 - int curbit, lastbit, done, last_byte; 139 -} CODE_STATIC_DATA; 140 - 141 -typedef struct 142 -{ 143 - int fresh; 144 - int code_size, set_code_size; 145 - int max_code, max_code_size; 146 - int firstcode, oldcode; 147 - int clear_code, end_code; 148 - int table[2][(1 << MAX_LWZ_BITS)]; 149 - int stack[STACK_SIZE], *sp; 150 - CODE_STATIC_DATA scd; 151 -} LZW_STATIC_DATA; 152 - 153 -static int 154 -GetDataBlock_ (xgdIOCtx * fd, unsigned char *buf, int *ZeroDataBlockP) 155 -{ 156 - unsigned char count; 157 - if (!ReadOK (fd, &count, 1)) 158 - { 159 - return -1; 160 - } 161 - *ZeroDataBlockP = count == 0; 162 - if ((count != 0) && (!ReadOK (fd, buf, count))) 163 - { 164 - return -1; 165 - } 166 - return count; 167 -} 168 - 169 -static int 170 -GetDataBlock (xgdIOCtx * fd, unsigned char *buf, int *ZeroDataBlockP) 171 -{ 172 - int rv; 173 - rv = GetDataBlock_ (fd, buf, ZeroDataBlockP); 174 - return (rv); 175 -} 176 - 177 -static int 178 -ReadColorMap (xgdIOCtx * fd, int number, unsigned char (*buffer)[256]) 179 -{ 180 - int i; 181 - unsigned char rgb[3]; 182 - for (i = 0; i < number; ++i) 183 - { 184 - if (!ReadOK (fd, rgb, sizeof (rgb))) 185 - { 186 - return TRUE; 187 - } 188 - buffer[CM_RED][i] = rgb[0]; 189 - buffer[CM_GREEN][i] = rgb[1]; 190 - buffer[CM_BLUE][i] = rgb[2]; 191 - } 192 - return FALSE; 193 -} 194 - 195 -static int 196 -GetCode_ (xgdIOCtx * fd, CODE_STATIC_DATA * scd, int code_size, int flag, 197 - int *ZeroDataBlockP) 198 -{ 199 - int i, j, ret; 200 - unsigned char count; 201 - if (flag) 202 - { 203 - scd->curbit = 0; 204 - scd->lastbit = 0; 205 - scd->last_byte = 0; 206 - scd->done = FALSE; 207 - return 0; 208 - } 209 - if ((scd->curbit + code_size) >= scd->lastbit) 210 - { 211 - if (scd->done) 212 - { 213 - if (scd->curbit >= scd->lastbit) 214 - { 215 - /* Oh well */ 216 - } 217 - return -1; 218 - } 219 - scd->buf[0] = scd->buf[scd->last_byte - 2]; 220 - scd->buf[1] = scd->buf[scd->last_byte - 1]; 221 - if ((count = GetDataBlock (fd, &scd->buf[2], ZeroDataBlockP)) <= 0) 222 - scd->done = TRUE; 223 - scd->last_byte = 2 + count; 224 - scd->curbit = (scd->curbit - scd->lastbit) + 16; 225 - scd->lastbit = (2 + count) * 8; 226 - } 227 - ret = 0; 228 - for (i = scd->curbit, j = 0; j < code_size; ++i, ++j) 229 - ret |= ((scd->buf[i / 8] & (1 << (i % 8))) != 0) << j; 230 - scd->curbit += code_size; 231 - return ret; 232 -} 233 - 234 -static int 235 -GetCode (xgdIOCtx * fd, CODE_STATIC_DATA * scd, int code_size, int flag, 236 - int *ZeroDataBlockP) 237 -{ 238 - int rv; 239 - rv = GetCode_ (fd, scd, code_size, flag, ZeroDataBlockP); 240 - return (rv); 241 -} 242 - 243 -static int 244 -LWZReadByte_ (xgdIOCtx * fd, LZW_STATIC_DATA * sd, char flag, 245 - int input_code_size, int *ZeroDataBlockP) 246 -{ 247 - int code, incode, i; 248 - if (flag) 249 - { 250 - sd->set_code_size = input_code_size; 251 - sd->code_size = sd->set_code_size + 1; 252 - sd->clear_code = 1 << sd->set_code_size; 253 - sd->end_code = sd->clear_code + 1; 254 - sd->max_code_size = 2 * sd->clear_code; 255 - sd->max_code = sd->clear_code + 2; 256 - GetCode (fd, &sd->scd, 0, TRUE, ZeroDataBlockP); 257 - sd->fresh = TRUE; 258 - for (i = 0; i < sd->clear_code; ++i) 259 - { 260 - sd->table[0][i] = 0; 261 - sd->table[1][i] = i; 262 - } 263 - for (; i < (1 << MAX_LWZ_BITS); ++i) 264 - sd->table[0][i] = sd->table[1][0] = 0; 265 - sd->sp = sd->stack; 266 - return 0; 267 - } 268 - else if (sd->fresh) 269 - { 270 - sd->fresh = FALSE; 271 - do 272 - { 273 - sd->firstcode = sd->oldcode = 274 - GetCode (fd, &sd->scd, sd->code_size, FALSE, 275 - ZeroDataBlockP); 276 - } 277 - while (sd->firstcode == sd->clear_code); 278 - return sd->firstcode; 279 - } 280 - if (sd->sp > sd->stack) 281 - return *--sd->sp; 282 - while ((code = 283 - GetCode (fd, &sd->scd, sd->code_size, FALSE, ZeroDataBlockP)) >= 0) 284 - { 285 - if (code == sd->clear_code) 286 - { 287 - for (i = 0; i < sd->clear_code; ++i) 288 - { 289 - sd->table[0][i] = 0; 290 - sd->table[1][i] = i; 291 - } 292 - for (; i < (1 << MAX_LWZ_BITS); ++i) 293 - sd->table[0][i] = sd->table[1][i] = 0; 294 - sd->code_size = sd->set_code_size + 1; 295 - sd->max_code_size = 2 * sd->clear_code; 296 - sd->max_code = sd->clear_code + 2; 297 - sd->sp = sd->stack; 298 - sd->firstcode = sd->oldcode = 299 - GetCode (fd, &sd->scd, sd->code_size, FALSE, 300 - ZeroDataBlockP); 301 - return sd->firstcode; 302 - } 303 - else if (code == sd->end_code) 304 - { 305 - int count; 306 - unsigned char buf[260]; 307 - if (*ZeroDataBlockP) 308 - return -2; 309 - while ((count = GetDataBlock (fd, buf, ZeroDataBlockP)) > 0) 310 - ; 311 - if (count != 0) 312 - return -2; 313 - } 314 - incode = code; 315 - if (sd->sp == (sd->stack + STACK_SIZE)) 316 - { 317 - return -1; 318 - } 319 - if (code >= sd->max_code) 320 - { 321 - *sd->sp++ = sd->firstcode; 322 - code = sd->oldcode; 323 - } 324 - while (code >= sd->clear_code) 325 - { 326 - if (sd->sp == (sd->stack + STACK_SIZE)) 327 - { 328 - return -1; 329 - } 330 - *sd->sp++ = sd->table[1][code]; 331 - if (code == sd->table[0][code]) 332 - { 333 - /* Oh well */ 334 - } 335 - code = sd->table[0][code]; 336 - } 337 - *sd->sp++ = sd->firstcode = sd->table[1][code]; 338 - if ((code = sd->max_code) < (1 << MAX_LWZ_BITS)) 339 - { 340 - sd->table[0][code] = sd->oldcode; 341 - sd->table[1][code] = sd->firstcode; 342 - ++sd->max_code; 343 - if ((sd->max_code >= sd->max_code_size) && 344 - (sd->max_code_size < (1 << MAX_LWZ_BITS))) 345 - { 346 - sd->max_code_size *= 2; 347 - ++sd->code_size; 348 - } 349 - } 350 - sd->oldcode = incode; 351 - if (sd->sp > sd->stack) 352 - return *--sd->sp; 353 - } 354 - return code; 355 -} 356 - 357 -static int 358 -LWZReadByte (xgdIOCtx * fd, LZW_STATIC_DATA * sd, char flag, 359 - int input_code_size, int *ZeroDataBlockP) 360 -{ 361 - int rv; 362 - rv = LWZReadByte_ (fd, sd, flag, input_code_size, ZeroDataBlockP); 363 - return (rv); 364 -} 365 - 366 -static void 367 -ReadImage (gGraphImagePtr img, xgdIOCtx * fd, 368 - unsigned char (*cmap)[256], int interlace, int *ZeroDataBlockP) 369 -{ 370 - unsigned char c; 371 - int v; 372 - int xpos = 0, ypos = 0, pass = 0; 373 - int i; 374 - int red[256]; 375 - int green[256]; 376 - int blue[256]; 377 - unsigned char *p_out; 378 - int len = img->width; 379 - int height = img->height; 380 - LZW_STATIC_DATA sd; 381 - if (!ReadOK (fd, &c, 1)) 382 - { 383 - return; 384 - } 385 - if (c > MAX_LWZ_BITS) 386 - { 387 - return; 388 - } 389 - for (i = 0; (i < 256); i++) 390 - { 391 - red[i] = cmap[CM_RED][i]; 392 - green[i] = cmap[CM_GREEN][i]; 393 - blue[i] = cmap[CM_BLUE][i]; 394 - } 395 - if (LWZReadByte (fd, &sd, TRUE, c, ZeroDataBlockP) < 0) 396 - { 397 - return; 398 - } 399 - while ((v = LWZReadByte (fd, &sd, FALSE, c, ZeroDataBlockP)) >= 0) 400 - { 401 - if (v >= 256) 402 - { 403 - v = 0; 404 - } 405 - p_out = 406 - img->pixels + (ypos * img->scanline_width) + 407 - (xpos * img->pixel_size); 408 - if (img->pixel_format == GG_PIXEL_PALETTE) 409 - { 410 - /* the output image is expected to be PALETTE-based */ 411 - *p_out++ = v; 412 - if ((v + 1) > img->max_palette) 413 - img->max_palette = v + 1; 414 - img->palette_red[v] = red[v]; 415 - img->palette_green[v] = green[v]; 416 - img->palette_blue[v] = blue[v]; 417 - } 418 - ++xpos; 419 - if (xpos == len) 420 - { 421 - xpos = 0; 422 - if (interlace) 423 - { 424 - switch (pass) 425 - { 426 - case 0: 427 - case 1: 428 - ypos += 8; 429 - break; 430 - case 2: 431 - ypos += 4; 432 - break; 433 - case 3: 434 - ypos += 2; 435 - break; 436 - } 437 - if (ypos >= height) 438 - { 439 - ++pass; 440 - switch (pass) 441 - { 442 - case 1: 443 - ypos = 4; 444 - break; 445 - case 2: 446 - ypos = 2; 447 - break; 448 - case 3: 449 - ypos = 1; 450 - break; 451 - default: 452 - goto fini; 453 - } 454 - } 455 - } 456 - else 457 - { 458 - ++ypos; 459 - } 460 - } 461 - if (ypos >= height) 462 - break; 463 - } 464 - fini: 465 - if (LWZReadByte (fd, &sd, FALSE, c, ZeroDataBlockP) >= 0) 466 - { 467 - /* Ignore extra */ 468 - } 469 -} 470 - 471 -static int 472 -DoExtension (xgdIOCtx * fd, int label, int *Transparent, int *ZeroDataBlockP) 473 -{ 474 - unsigned char buf[256]; 475 - switch (label) 476 - { 477 - case 0xf9: 478 - memset (buf, 0, 4); 479 - (void) GetDataBlock (fd, (unsigned char *) buf, ZeroDataBlockP); 480 - if ((buf[0] & 0x1) != 0) 481 - *Transparent = buf[3]; 482 - while (GetDataBlock (fd, (unsigned char *) buf, ZeroDataBlockP) > 0); 483 - return FALSE; 484 - default: 485 - break; 486 - } 487 - while (GetDataBlock (fd, (unsigned char *) buf, ZeroDataBlockP) > 0) 488 - ; 489 - return FALSE; 490 -} 491 - 492 -static void 493 -BumpPixel (GifCtx * ctx) 494 -{ 495 - ++(ctx->curx); 496 - if (ctx->curx == ctx->Width) 497 - { 498 - ctx->curx = 0; 499 - if (!ctx->Interlace) 500 - ++(ctx->cury); 501 - else 502 - { 503 - switch (ctx->Pass) 504 - { 505 - case 0: 506 - ctx->cury += 8; 507 - if (ctx->cury >= ctx->Height) 508 - { 509 - ++(ctx->Pass); 510 - ctx->cury = 4; 511 - } 512 - break; 513 - case 1: 514 - ctx->cury += 8; 515 - if (ctx->cury >= ctx->Height) 516 - { 517 - ++(ctx->Pass); 518 - ctx->cury = 2; 519 - } 520 - break; 521 - case 2: 522 - ctx->cury += 4; 523 - if (ctx->cury >= ctx->Height) 524 - { 525 - ++(ctx->Pass); 526 - ctx->cury = 1; 527 - } 528 - break; 529 - 530 - case 3: 531 - ctx->cury += 2; 532 - break; 533 - } 534 - } 535 - } 536 -} 537 - 538 -static int 539 -GIFNextPixel (gGraphImagePtr img, GifCtx * ctx) 540 -{ 541 - int pixel = 0; 542 - unsigned char *p_in; 543 - if (ctx->CountDown == 0) 544 - return EOF; 545 - --(ctx->CountDown); 546 - 547 - p_in = 548 - img->pixels + (ctx->cury * img->scanline_width) + 549 - (ctx->curx * img->pixel_size); 550 - if (img->pixel_format == GG_PIXEL_GRAYSCALE 551 - || img->pixel_format == GG_PIXEL_PALETTE) 552 - { 553 - /* the input image is expected to be GRAYSCALE or PALETTE anyway */ 554 - pixel = *p_in; 555 - } 556 - BumpPixel (ctx); 557 - return pixel; 558 -} 559 - 560 -static void 561 -xgdPutC (const unsigned char c, xgdIOCtx * ctx) 562 -{ 563 - (ctx->putC) (ctx, c); 564 -} 565 - 566 -static void 567 -char_init (GifCtx * ctx) 568 -{ 569 - ctx->a_count = 0; 570 -} 571 - 572 -static void 573 -cl_hash (register count_int chsize, GifCtx * ctx) 574 -{ 575 - register count_int *htab_p = ctx->htab + chsize; 576 - register long i; 577 - register long m1 = -1; 578 - i = chsize - 16; 579 - do 580 - { 581 - *(htab_p - 16) = m1; 582 - *(htab_p - 15) = m1; 583 - *(htab_p - 14) = m1; 584 - *(htab_p - 13) = m1; 585 - *(htab_p - 12) = m1; 586 - *(htab_p - 11) = m1; 587 - *(htab_p - 10) = m1; 588 - *(htab_p - 9) = m1; 589 - *(htab_p - 8) = m1; 590 - *(htab_p - 7) = m1; 591 - *(htab_p - 6) = m1; 592 - *(htab_p - 5) = m1; 593 - *(htab_p - 4) = m1; 594 - *(htab_p - 3) = m1; 595 - *(htab_p - 2) = m1; 596 - *(htab_p - 1) = m1; 597 - htab_p -= 16; 598 - } 599 - while ((i -= 16) >= 0); 600 - for (i += 16; i > 0; --i) 601 - *--htab_p = m1; 602 -} 603 - 604 -static void 605 -flush_char (GifCtx * ctx) 606 -{ 607 - if (ctx->a_count > 0) 608 - { 609 - xgdPutC (ctx->a_count, ctx->g_outfile); 610 - xgdPutBuf (ctx->accum, ctx->a_count, ctx->g_outfile); 611 - ctx->a_count = 0; 612 - } 613 -} 614 - 615 -static void 616 -char_out (int c, GifCtx * ctx) 617 -{ 618 - ctx->accum[ctx->a_count++] = c; 619 - if (ctx->a_count >= 254) 620 - flush_char (ctx); 621 -} 622 - 623 -static unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 624 - 0x001F, 0x003F, 0x007F, 0x00FF, 625 - 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 626 - 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF 627 -}; 628 - 629 -static void 630 -output (code_int code, GifCtx * ctx) 631 -{ 632 - ctx->cur_accum &= masks[ctx->cur_bits]; 633 - if (ctx->cur_bits > 0) 634 - ctx->cur_accum |= ((long) code << ctx->cur_bits); 635 - else 636 - ctx->cur_accum = code; 637 - ctx->cur_bits += ctx->n_bits; 638 - while (ctx->cur_bits >= 8) 639 - { 640 - char_out ((unsigned int) (ctx->cur_accum & 0xff), ctx); 641 - ctx->cur_accum >>= 8; 642 - ctx->cur_bits -= 8; 643 - } 644 - if (ctx->free_ent > ctx->maxcode || ctx->clear_flg) 645 - { 646 - 647 - if (ctx->clear_flg) 648 - { 649 - 650 - ctx->maxcode = MAXCODE (ctx->n_bits = ctx->g_init_bits); 651 - ctx->clear_flg = 0; 652 - 653 - } 654 - else 655 - { 656 - 657 - ++(ctx->n_bits); 658 - if (ctx->n_bits == maxbits) 659 - ctx->maxcode = maxmaxcode; 660 - else 661 - ctx->maxcode = MAXCODE (ctx->n_bits); 662 - } 663 - } 664 - if (code == ctx->EOFCode) 665 - { 666 - while (ctx->cur_bits > 0) 667 - { 668 - char_out ((unsigned int) (ctx->cur_accum & 0xff), ctx); 669 - ctx->cur_accum >>= 8; 670 - ctx->cur_bits -= 8; 671 - } 672 - flush_char (ctx); 673 - } 674 -} 675 - 676 -static void 677 -cl_block (GifCtx * ctx) 678 -{ 679 - cl_hash ((count_int) hsize, ctx); 680 - ctx->free_ent = ctx->ClearCode + 2; 681 - ctx->clear_flg = 1; 682 - output ((code_int) ctx->ClearCode, ctx); 683 -} 684 - 685 -static int 686 -gifPutWord (int w, xgdIOCtx * out) 687 -{ 688 - xgdPutC (w & 0xFF, out); 689 - xgdPutC ((w >> 8) & 0xFF, out); 690 - return 0; 691 -} 692 - 693 -static void 694 -GIFcompress (int init_bits, xgdIOCtxPtr outfile, gGraphImagePtr img, 695 - GifCtx * ctx) 696 -{ 697 -/* 698 - * compress stdin to stdout 699 - * 700 - * Algorithm: use open addressing double hashing (no chaining) on the 701 - * prefix code / next character combination. We do a variant of Knuth's 702 - * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime 703 - * secondary probe. Here, the modular division first probe is gives way 704 - * to a faster exclusive-or manipulation. Also do block compression with 705 - * an adaptive reset, whereby the code table is cleared when the compression 706 - * ratio decreases, but after the table fills. The variable-length output 707 - * codes are re-sized at this point, and a special CLEAR code is generated 708 - * for the decompressor. Late addition: construct the table according to 709 - * file size for noticeable speed improvement on small files. Please direct 710 - * questions about this implementation to ames!jaw. 711 - */ 712 - register long fcode; 713 - register code_int i /* = 0 */ ; 714 - register int c; 715 - register code_int ent; 716 - register code_int disp; 717 - register code_int hsize_reg; 718 - register int hshift; 719 - ctx->g_init_bits = init_bits; 720 - ctx->g_outfile = outfile; 721 - ctx->offset = 0; 722 - ctx->out_count = 0; 723 - ctx->clear_flg = 0; 724 - ctx->in_count = 1; 725 - ctx->maxcode = MAXCODE (ctx->n_bits = ctx->g_init_bits); 726 - ctx->ClearCode = (1 << (init_bits - 1)); 727 - ctx->EOFCode = ctx->ClearCode + 1; 728 - ctx->free_ent = ctx->ClearCode + 2; 729 - char_init (ctx); 730 - ent = GIFNextPixel (img, ctx); 731 - hshift = 0; 732 - for (fcode = (long) hsize; fcode < 65536L; fcode *= 2L) 733 - ++hshift; 734 - hshift = 8 - hshift; 735 - hsize_reg = hsize; 736 - cl_hash ((count_int) hsize_reg, ctx); 737 - output ((code_int) ctx->ClearCode, ctx); 738 -#ifdef SIGNED_COMPARE_SLOW 739 - while ((c = GIFNextPixel (img)) != (unsigned) EOF) 740 - { 741 -#else /*SIGNED_COMPARE_SLOW */ 742 - while ((c = GIFNextPixel (img, ctx)) != EOF) 743 - { /* } */ 744 -#endif /*SIGNED_COMPARE_SLOW */ 745 - ++(ctx->in_count); 746 - fcode = (long) (((long) c << maxbits) + ent); 747 - i = (((code_int) c << hshift) ^ ent); 748 - if (HashTabOf (i) == fcode) 749 - { 750 - ent = CodeTabOf (i); 751 - continue; 752 - } 753 - else if ((long) HashTabOf (i) < 0) 754 - goto nomatch; 755 - disp = hsize_reg - i; 756 - if (i == 0) 757 - disp = 1; 758 - probe: 759 - if ((i -= disp) < 0) 760 - i += hsize_reg; 761 - if (HashTabOf (i) == fcode) 762 - { 763 - ent = CodeTabOf (i); 764 - continue; 765 - } 766 - if ((long) HashTabOf (i) > 0) 767 - goto probe; 768 - nomatch: 769 - output ((code_int) ent, ctx); 770 - ++(ctx->out_count); 771 - ent = c; 772 -#ifdef SIGNED_COMPARE_SLOW 773 - if ((unsigned) ctx->free_ent < (unsigned) maxmaxcode) 774 - { 775 -#else /*SIGNED_COMPARE_SLOW */ 776 - if (ctx->free_ent < maxmaxcode) 777 - { 778 -#endif /*SIGNED_COMPARE_SLOW */ 779 - CodeTabOf (i) = ctx->free_ent++; 780 - HashTabOf (i) = fcode; 781 - } 782 - else 783 - cl_block (ctx); 784 - } 785 - output ((code_int) ent, ctx); 786 - ++(ctx->out_count); 787 - output ((code_int) ctx->EOFCode, ctx); 788 -} 789 - 790 -static int 791 -GIFEncode (xgdIOCtxPtr fp, int GInterlace, 792 - int Background, int Transparent, int BitsPerPixel, int *Red, 793 - int *Green, int *Blue, gGraphImagePtr img) 794 -{ 795 - int B; 796 - int RWidth, RHeight; 797 - int LeftOfs, TopOfs; 798 - int Resolution; 799 - int ColorMapSize; 800 - int InitCodeSize; 801 - int i; 802 - int GWidth = img->width; 803 - int GHeight = img->height; 804 - GifCtx ctx; 805 - ctx.Interlace = GInterlace; 806 - ctx.in_count = 1; 807 - memset (&ctx, 0, sizeof (ctx)); 808 - ColorMapSize = 1 << BitsPerPixel; 809 - RWidth = ctx.Width = GWidth; 810 - RHeight = ctx.Height = GHeight; 811 - LeftOfs = TopOfs = 0; 812 - Resolution = BitsPerPixel; 813 - ctx.CountDown = (long) ctx.Width * (long) ctx.Height; 814 - ctx.Pass = 0; 815 - if (BitsPerPixel <= 1) 816 - InitCodeSize = 2; 817 - else 818 - InitCodeSize = BitsPerPixel; 819 - ctx.curx = ctx.cury = 0; 820 - xgdPutBuf (Transparent < 0 ? "GIF87a" : "GIF89a", 6, fp); 821 - gifPutWord (RWidth, fp); 822 - gifPutWord (RHeight, fp); 823 - B = 0x80; 824 - B |= (Resolution - 1) << 5; 825 - B |= (BitsPerPixel - 1); 826 - xgdPutC (B, fp); 827 - xgdPutC (Background, fp); 828 - xgdPutC (0, fp); 829 - for (i = 0; i < ColorMapSize; ++i) 830 - { 831 - xgdPutC (Red[i], fp); 832 - xgdPutC (Green[i], fp); 833 - xgdPutC (Blue[i], fp); 834 - } 835 - if (Transparent >= 0) 836 - { 837 - xgdPutC ('!', fp); 838 - xgdPutC (0xf9, fp); 839 - xgdPutC (4, fp); 840 - xgdPutC (1, fp); 841 - xgdPutC (0, fp); 842 - xgdPutC (0, fp); 843 - xgdPutC ((unsigned char) Transparent, fp); 844 - xgdPutC (0, fp); 845 - } 846 - xgdPutC (',', fp); 847 - gifPutWord (LeftOfs, fp); 848 - gifPutWord (TopOfs, fp); 849 - gifPutWord (ctx.Width, fp); 850 - gifPutWord (ctx.Height, fp); 851 - if (ctx.Interlace) 852 - xgdPutC (0x40, fp); 853 - else 854 - xgdPutC (0x00, fp); 855 - xgdPutC (InitCodeSize, fp); 856 - GIFcompress (InitCodeSize + 1, fp, img, &ctx); 857 - xgdPutC (0, fp); 858 - xgdPutC (';', fp); 859 - return GGRAPH_OK; 860 -} 861 - 862 -static int 863 -colorstobpp (int colors) 864 -{ 865 - int bpp = 0; 866 - 867 - if (colors <= 2) 868 - bpp = 1; 869 - else if (colors <= 4) 870 - bpp = 2; 871 - else if (colors <= 8) 872 - bpp = 3; 873 - else if (colors <= 16) 874 - bpp = 4; 875 - else if (colors <= 32) 876 - bpp = 5; 877 - else if (colors <= 64) 878 - bpp = 6; 879 - else if (colors <= 128) 880 - bpp = 7; 881 - else if (colors <= 256) 882 - bpp = 8; 883 - return bpp; 884 -} 885 - 886 -static gGraphImageInfosPtr 887 -xgdImageInfosFromGifCtx (xgdIOCtxPtr fd, int *errcode) 888 -{ 889 - int BitPixel; 890 - unsigned char buf[16]; 891 - int imw, imh, screen_width, screen_height; 892 - int bitPixel; 893 - gGraphImageInfosPtr infos = NULL; 894 - if (!ReadOK (fd, buf, 6)) 895 - { 896 - *errcode = GGRAPH_GIF_CODEC_ERROR; 897 - return NULL; 898 - } 899 - if (strncmp ((char *) buf, "GIF", 3) != 0) 900 - { 901 - *errcode = GGRAPH_GIF_CODEC_ERROR; 902 - return NULL; 903 - } 904 - if (memcmp ((char *) buf + 3, "87a", 3) == 0 905 - || memcmp ((char *) buf + 3, "89a", 3) == 0) 906 - ; 907 - else 908 - { 909 - *errcode = GGRAPH_GIF_CODEC_ERROR; 910 - return NULL; 911 - } 912 - if (!ReadOK (fd, buf, 7)) 913 - { 914 - *errcode = GGRAPH_GIF_CODEC_ERROR; 915 - return NULL; 916 - } 917 - BitPixel = 2 << (buf[4] & 0x07); 918 - screen_width = imw = LM_to_uint (buf[0], buf[1]); 919 - screen_height = imh = LM_to_uint (buf[2], buf[3]); 920 - bitPixel = colorstobpp (BitPixel); 921 - if (! 922 - (infos = 923 - gg_image_infos_create (GG_PIXEL_PALETTE, screen_width, screen_height, 924 - bitPixel, 1, GGRAPH_SAMPLE_UINT, NULL, NULL))) 925 - { 926 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 927 - return NULL; 928 - } 929 - infos->compression = GGRAPH_TIFF_COMPRESSION_LZW; 930 - if (!infos) 931 - { 932 - *errcode = GGRAPH_GIF_CODEC_ERROR; 933 - return NULL; 934 - } 935 - return infos; 936 -} 937 - 938 -static gGraphImagePtr 939 -xgdImageCreateFromGifCtx (xgdIOCtxPtr fd, int *errcode) 940 -{ 941 - int BitPixel; 942 - int Transparent = (-1); 943 - unsigned char buf[16]; 944 - unsigned char c; 945 - unsigned char ColorMap[3][MAXCOLORMAPSIZE]; 946 - unsigned char localColorMap[3][MAXCOLORMAPSIZE]; 947 - int imw, imh, screen_width, screen_height; 948 - int useGlobalColormap; 949 - int bitPixel; 950 - int ZeroDataBlock = FALSE; 951 - int haveGlobalColormap; 952 - gGraphImagePtr img = NULL; 953 - if (!ReadOK (fd, buf, 6)) 954 - { 955 - *errcode = GGRAPH_GIF_CODEC_ERROR; 956 - return NULL; 957 - } 958 - if (strncmp ((char *) buf, "GIF", 3) != 0) 959 - { 960 - *errcode = GGRAPH_GIF_CODEC_ERROR; 961 - return NULL; 962 - } 963 - if (memcmp ((char *) buf + 3, "87a", 3) == 0 964 - || memcmp ((char *) buf + 3, "89a", 3) == 0) 965 - ; 966 - else 967 - { 968 - *errcode = GGRAPH_GIF_CODEC_ERROR; 969 - return NULL; 970 - } 971 - if (!ReadOK (fd, buf, 7)) 972 - { 973 - *errcode = GGRAPH_GIF_CODEC_ERROR; 974 - return NULL; 975 - } 976 - BitPixel = 2 << (buf[4] & 0x07); 977 - screen_width = imw = LM_to_uint (buf[0], buf[1]); 978 - screen_height = imh = LM_to_uint (buf[2], buf[3]); 979 - haveGlobalColormap = BitSet (buf[4], LOCALCOLORMAP); /* Global Colormap */ 980 - if (haveGlobalColormap) 981 - { 982 - if (ReadColorMap (fd, BitPixel, ColorMap)) 983 - { 984 - *errcode = GGRAPH_GIF_CODEC_ERROR; 985 - return NULL; 986 - } 987 - } 988 - for (;;) 989 - { 990 - int top, left; 991 - int width, height; 992 - if (!ReadOK (fd, &c, 1)) 993 - { 994 - *errcode = GGRAPH_GIF_CODEC_ERROR; 995 - return NULL; 996 - } 997 - if (c == ';') 998 - { 999 - goto terminated; 1000 - } 1001 - 1002 - if (c == '!') 1003 - { 1004 - if (!ReadOK (fd, &c, 1)) 1005 - { 1006 - *errcode = GGRAPH_GIF_CODEC_ERROR; 1007 - return NULL; 1008 - } 1009 - DoExtension (fd, c, &Transparent, &ZeroDataBlock); 1010 - continue; 1011 - } 1012 - 1013 - if (c != ',') 1014 - { 1015 - continue; 1016 - } 1017 - if (!ReadOK (fd, buf, 9)) 1018 - { 1019 - *errcode = GGRAPH_GIF_CODEC_ERROR; 1020 - return NULL; 1021 - } 1022 - useGlobalColormap = !BitSet (buf[8], LOCALCOLORMAP); 1023 - bitPixel = 1 << ((buf[8] & 0x07) + 1); 1024 - left = LM_to_uint (buf[0], buf[1]); 1025 - top = LM_to_uint (buf[2], buf[3]); 1026 - width = LM_to_uint (buf[4], buf[5]); 1027 - height = LM_to_uint (buf[6], buf[7]); 1028 - if (left + width > screen_width || top + height > screen_height) 1029 - { 1030 - *errcode = GGRAPH_GIF_CODEC_ERROR; 1031 - return NULL; 1032 - } 1033 - if (! 1034 - (img = 1035 - gg_image_create (GG_PIXEL_PALETTE, width, height, bitPixel, 1, 1036 - GGRAPH_SAMPLE_UINT, NULL, NULL))) 1037 - { 1038 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 1039 - return NULL; 1040 - } 1041 - if (!useGlobalColormap) 1042 - { 1043 - if (ReadColorMap (fd, bitPixel, localColorMap)) 1044 - { 1045 - gg_image_destroy (img); 1046 - *errcode = GGRAPH_GIF_CODEC_ERROR; 1047 - return NULL; 1048 - } 1049 - ReadImage (img, fd, localColorMap, 1050 - BitSet (buf[8], INTERLACE), &ZeroDataBlock); 1051 - } 1052 - else 1053 - { 1054 - if (!haveGlobalColormap) 1055 - { 1056 - gg_image_destroy (img); 1057 - *errcode = GGRAPH_GIF_CODEC_ERROR; 1058 - return NULL; 1059 - } 1060 - ReadImage (img, fd, 1061 - ColorMap, 1062 - BitSet (buf[8], INTERLACE), &ZeroDataBlock); 1063 - } 1064 - } 1065 - terminated: 1066 - if (!img) 1067 - { 1068 - *errcode = GGRAPH_GIF_CODEC_ERROR; 1069 - return NULL; 1070 - } 1071 - return img; 1072 -} 1073 - 1074 -static int 1075 -xgdImageGifCtx (gGraphImagePtr img, xgdIOCtxPtr out, int is_transparent) 1076 -{ 1077 - int BitsPerPixel; 1078 - int Red[256]; 1079 - int Green[256]; 1080 - int Blue[256]; 1081 - int i, colors; 1082 - int transparent_idx = -1; 1083 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 1084 - { 1085 - /* generating a GRAYSCALE palette */ 1086 - colors = 256; 1087 - for (i = 0; i < 256; i++) 1088 - { 1089 - Red[i] = i; 1090 - Green[i] = i; 1091 - Blue[i] = i; 1092 - } 1093 - } 1094 - else 1095 - { 1096 - /* copying the PALETTE from image */ 1097 - colors = 0; 1098 - for (i = 0; i < img->max_palette; ++i) 1099 - { 1100 - Red[i] = img->palette_red[i]; 1101 - Green[i] = img->palette_green[i]; 1102 - Blue[i] = img->palette_blue[i]; 1103 - colors++; 1104 - } 1105 - } 1106 - BitsPerPixel = colorstobpp (colors); 1107 - if (is_transparent) 1108 - { 1109 - /* identifying the Transparent Color Index */ 1110 - for (i = 0; i < colors; ++i) 1111 - { 1112 - if (Red[i] == img->transparent_red 1113 - && Green[i] == img->transparent_green 1114 - && Blue[i] == img->transparent_blue) 1115 - transparent_idx = i; 1116 - } 1117 - } 1118 - return GIFEncode (out, 0, 0, transparent_idx, BitsPerPixel, Red, Green, 1119 - Blue, img); 1120 -} 1121 - 1122 -GGRAPH_PRIVATE int 1123 -gg_image_to_gif (const gGraphImagePtr img, void **mem_buf, int *mem_buf_size, 1124 - FILE * file, int dest_type, int is_transparent) 1125 -{ 1126 -/* compressing an image as GIF */ 1127 - int ret; 1128 - void *rv; 1129 - int size; 1130 - xgdIOCtx *out; 1131 - 1132 -/* checkings args for validity */ 1133 - if (dest_type == GG_TARGET_IS_FILE) 1134 - { 1135 - if (!file) 1136 - return GGRAPH_ERROR; 1137 - } 1138 - else 1139 - { 1140 - if (!mem_buf || !mem_buf_size) 1141 - return GGRAPH_ERROR; 1142 - *mem_buf = NULL; 1143 - *mem_buf_size = 0; 1144 - } 1145 - 1146 - if (dest_type == GG_TARGET_IS_FILE) 1147 - out = xgdNewDynamicCtx (0, file, dest_type); 1148 - else 1149 - out = xgdNewDynamicCtx (2048, NULL, dest_type); 1150 - ret = xgdImageGifCtx (img, out, is_transparent); 1151 - if (dest_type == GG_TARGET_IS_FILE) 1152 - { 1153 - out->xgd_free (out); 1154 - return ret; 1155 - } 1156 - 1157 - if (ret == GGRAPH_OK) 1158 - rv = xgdDPExtractData (out, &size); 1159 - out->xgd_free (out); 1160 - *mem_buf = rv; 1161 - *mem_buf_size = size; 1162 - return ret; 1163 -} 1164 - 1165 -GGRAPH_PRIVATE int 1166 -gg_image_from_gif (int size, const void *data, int source_type, 1167 - gGraphImagePtr * image_handle) 1168 -{ 1169 -/* uncompressing a GIF */ 1170 - int errcode = GGRAPH_OK; 1171 - gGraphImagePtr img; 1172 - xgdIOCtx *in = 1173 - xgdNewDynamicCtxEx (size, data, XGD_CTX_DONT_FREE, source_type); 1174 - img = xgdImageCreateFromGifCtx (in, &errcode); 1175 - in->xgd_free (in); 1176 - *image_handle = img; 1177 - return errcode; 1178 -} 1179 - 1180 -GGRAPH_PRIVATE int 1181 -gg_image_infos_from_gif (int size, const void *data, int source_type, 1182 - gGraphImageInfosPtr * infos_handle) 1183 -{ 1184 -/* image infos from GIF */ 1185 - int errcode = GGRAPH_OK; 1186 - gGraphImageInfosPtr infos; 1187 - xgdIOCtx *in = 1188 - xgdNewDynamicCtxEx (size, data, XGD_CTX_DONT_FREE, source_type); 1189 - infos = xgdImageInfosFromGifCtx (in, &errcode); 1190 - in->xgd_free (in); 1191 - *infos_handle = infos; 1192 - return errcode; 1193 -}
Deleted src/gaiagraphics_grids.c.
1 -/* 2 -/ gaiagraphics_grids.c 3 -/ 4 -/ GRIDS auxiliary helpers 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdio.h> 28 -#include <math.h> 29 -#include <float.h> 30 -#include <limits.h> 31 -#include <string.h> 32 -#include <stdlib.h> 33 - 34 -#include "gaiagraphics.h" 35 -#include "gaiagraphics_internals.h" 36 - 37 -#define GRID_HGT_3 1 38 -#define GRID_HGT_1 2 39 -#define GRID_BIN_HDR 3 40 -#define GRID_FLT_HDR 4 41 -#define GRID_DEM_HDR 5 42 -#define GRID_ASCII 6 43 - 44 -struct grid_codec_data 45 -{ 46 -/* a struct used by GRID codec */ 47 - int grid_type; 48 - int is_writer; 49 - int little_endian; 50 - void *grid_buffer; 51 - long *row_offsets; 52 -}; 53 - 54 -GGRAPH_PRIVATE int 55 -gg_image_strip_prepare_from_hgt (FILE * in, int lon, int lat, 56 - gGraphStripImagePtr * image_handle) 57 -{ 58 -/* preparing to decode an HGT-GRID [by strips] */ 59 - gGraphStripImagePtr img = NULL; 60 - struct grid_codec_data *grid_codec = NULL; 61 - long file_length; 62 - int type; 63 - int width; 64 - int height; 65 - double pixel_size; 66 - double half_pixel; 67 - int buf_size; 68 - void *grid_buffer = NULL; 69 - int ret = GGRAPH_HGT_CODEC_ERROR; 70 - *image_handle = NULL; 71 - 72 -/* retrieving the HGT dimensions */ 73 - if (fseek (in, 0, SEEK_END) != 0) 74 - return GGRAPH_HGT_CODEC_ERROR; 75 - file_length = ftell (in); 76 - if (file_length == (1201 * 1201 * sizeof (short))) 77 - { 78 - type = GRID_HGT_3; 79 - width = 1201; 80 - height = 1201; 81 - pixel_size = 1.0 / 1200.0; 82 - } 83 - else if (file_length == (3601 * 3601 * sizeof (short))) 84 - { 85 - type = GRID_HGT_1; 86 - width = 3601; 87 - height = 3601; 88 - pixel_size = 1.0 / 3600.0; 89 - } 90 - else 91 - return GGRAPH_HGT_CODEC_ERROR; 92 - 93 - img = 94 - gg_strip_image_create (in, GGRAPH_IMAGE_HGT, GG_PIXEL_GRID, width, 95 - height, 16, 1, GGRAPH_SAMPLE_INT, "WGS 84", 96 - "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"); 97 - if (!img) 98 - { 99 - ret = GGRAPH_INSUFFICIENT_MEMORY; 100 - goto error; 101 - } 102 -/* setting up georeferencing infos */ 103 - half_pixel = pixel_size / 2.0; 104 - img->is_georeferenced = 1; 105 - img->srid = 4326; 106 - img->upper_left_x = (double) lon - half_pixel; 107 - img->upper_left_y = (double) lat + 1.0 + half_pixel; 108 - img->pixel_x_size = pixel_size; 109 - img->pixel_y_size = pixel_size; 110 - img->no_data_value = SHRT_MIN; 111 - 112 -/* setting up the GRID codec struct */ 113 - grid_codec = malloc (sizeof (struct grid_codec_data)); 114 - if (!grid_codec) 115 - goto error; 116 - grid_codec->grid_type = type; 117 - grid_codec->is_writer = 0; 118 - grid_codec->grid_buffer = NULL; 119 - grid_codec->row_offsets = NULL; 120 - img->codec_data = grid_codec; 121 - 122 -/* allocating the GRID read buffer */ 123 - buf_size = sizeof (short) * width; 124 - grid_buffer = malloc (buf_size); 125 - if (!grid_buffer) 126 - goto error; 127 - grid_codec->grid_buffer = grid_buffer; 128 - 129 - *image_handle = img; 130 - return GGRAPH_OK; 131 - 132 - error: 133 - if (img) 134 - gGraphDestroyImage (img); 135 - return ret; 136 -} 137 - 138 -GGRAPH_PRIVATE void 139 -gg_grid_codec_destroy (void *p) 140 -{ 141 -/* destroyng the GRID codec data */ 142 - struct grid_codec_data *codec = (struct grid_codec_data *) p; 143 - if (!codec) 144 - return; 145 - if (codec->grid_buffer) 146 - free (codec->grid_buffer); 147 - if (codec->row_offsets) 148 - free (codec->row_offsets); 149 - free (codec); 150 -} 151 - 152 -static int 153 -read_from_hgt (FILE * in, gGraphStripImagePtr img, void *scanline) 154 -{ 155 -/* decoding an HGT-GRID [by strip] */ 156 - int width = img->width; 157 - int height = img->height; 158 - size_t scan_size = width * 2; 159 - int row; 160 - int incr = 0; 161 - int x; 162 - int endian_arch = gg_endian_arch (); 163 - off_t pos = img->next_row * scan_size; 164 - unsigned char *p_in; 165 - short *p_out; 166 - short cell_value; 167 - 168 -/* positioning on the start scanline */ 169 - if (fseek (in, pos, SEEK_SET) != 0) 170 - return GGRAPH_HGT_CODEC_ERROR; 171 - for (row = 0; row < img->rows_per_block; row++) 172 - { 173 - /* reading the required number of scanlines */ 174 - if ((row + img->next_row) >= height) 175 - break; 176 - if (fread (scanline, 1, scan_size, in) != scan_size) 177 - return GGRAPH_HGT_CODEC_ERROR; 178 - p_in = scanline; 179 - p_out = (short *) (img->pixels); 180 - p_out += (row * width); 181 - for (x = 0; x < width; x++) 182 - { 183 - cell_value = gg_import_int16 (p_in, 0, endian_arch); 184 - *p_out++ = cell_value; 185 - p_in += sizeof (short); 186 - } 187 - incr++; 188 - } 189 - img->next_row += incr; 190 - img->current_available_rows = incr; 191 - return GGRAPH_OK; 192 -} 193 - 194 -GGRAPH_PRIVATE int 195 -gg_image_strip_read_from_hgt (gGraphStripImagePtr img, int *progress) 196 -{ 197 -/* decoding an HGT-GRID [by strip] */ 198 - struct grid_codec_data *grid_codec = 199 - (struct grid_codec_data *) (img->codec_data); 200 - FILE *in = img->file_handle; 201 - 202 - if (grid_codec->grid_type == GRID_HGT_1 203 - || grid_codec->grid_type == GRID_HGT_3) 204 - { 205 - int ret = read_from_hgt (in, img, grid_codec->grid_buffer); 206 - if (ret == GGRAPH_OK && progress != NULL) 207 - *progress = 208 - (int) (((double) (img->next_row + 1) * 100.0) / 209 - (double) (img->height)); 210 - return ret; 211 - } 212 - return GGRAPH_ERROR; 213 -} 214 - 215 -GGRAPH_DECLARE int 216 -gGraphCheckHgtPath (const char *path, int *lat, int *lon) 217 -{ 218 -/* checking for HGT format - retrieving coord from path */ 219 - char file_name[1024]; 220 - char coord_lat[8]; 221 - char coord_lon[8]; 222 - int lat_sign = 1; 223 - int lon_sign = 1; 224 - int i; 225 - int start = 0; 226 - 227 - for (i = strlen (path) - 1; i >= 0; i--) 228 - { 229 - /* attempting to extract the file name */ 230 - if (path[i] == '/' || path[i] == '\\') 231 - { 232 - start = i + 1; 233 - break; 234 - } 235 - } 236 - strcpy (file_name, path + start); 237 - 238 - if (strlen (file_name) != 11) 239 - return GGRAPH_ERROR; 240 - if (file_name[0] == 'N') 241 - ; 242 - else if (file_name[0] == 'S') 243 - lat_sign = -1; 244 - else 245 - return GGRAPH_ERROR; 246 - if (file_name[1] >= '0' && file_name[1] <= '9') 247 - coord_lat[0] = file_name[1]; 248 - else 249 - return GGRAPH_ERROR; 250 - if (file_name[2] >= '0' && file_name[2] <= '9') 251 - { 252 - coord_lat[1] = file_name[2]; 253 - coord_lat[2] = '\0'; 254 - } 255 - else 256 - return GGRAPH_ERROR; 257 - if (file_name[3] == 'E') 258 - ; 259 - else if (file_name[3] == 'W') 260 - lon_sign = -1; 261 - else 262 - return GGRAPH_ERROR; 263 - if (file_name[4] >= '0' && file_name[4] <= '9') 264 - coord_lon[0] = file_name[4]; 265 - else 266 - return GGRAPH_ERROR; 267 - if (file_name[5] >= '0' && file_name[5] <= '9') 268 - coord_lon[1] = file_name[5]; 269 - if (file_name[6] >= '0' && file_name[6] <= '9') 270 - { 271 - coord_lon[2] = file_name[6]; 272 - coord_lon[3] = '\0'; 273 - } 274 - else 275 - return GGRAPH_ERROR; 276 - if (file_name[7] != '.') 277 - return GGRAPH_ERROR; 278 - if (file_name[8] != 'h') 279 - return GGRAPH_ERROR; 280 - if (file_name[9] != 'g') 281 - return GGRAPH_ERROR; 282 - if (file_name[10] != 't') 283 - return GGRAPH_ERROR; 284 -/* ok, it's an HGT file */ 285 - *lat = atoi (coord_lat) * lat_sign; 286 - *lon = atoi (coord_lon) * lon_sign; 287 - return GGRAPH_OK; 288 -} 289 - 290 -GGRAPH_DECLARE int 291 -gGraphImageInfosFromHgtFile (const char *path, int lat, int lon, 292 - const void **infos_handle) 293 -{ 294 -/* retrieving Image infos from HGT file */ 295 - FILE *in = NULL; 296 - gGraphImageInfosPtr infos = NULL; 297 - long file_length; 298 - int width; 299 - int height; 300 - double pixel_size; 301 - double half_pixel; 302 - 303 - *infos_handle = NULL; 304 - 305 -/* attempting to open the image file */ 306 - in = fopen (path, "rb"); 307 - if (in == NULL) 308 - return GGRAPH_FILE_OPEN_ERROR; 309 - 310 -/* retrieving the HGT dimensions */ 311 - if (fseek (in, 0, SEEK_END) != 0) 312 - return GGRAPH_HGT_CODEC_ERROR; 313 - file_length = ftell (in); 314 - if (file_length == (1201 * 1201 * sizeof (short))) 315 - { 316 - width = 1201; 317 - height = 1201; 318 - pixel_size = 1.0 / 1200.0; 319 - } 320 - else if (file_length == (3601 * 3601 * sizeof (short))) 321 - { 322 - width = 3601; 323 - height = 3601; 324 - pixel_size = 1.0 / 3600.0; 325 - } 326 - else 327 - { 328 - fclose (in); 329 - return GGRAPH_HGT_CODEC_ERROR; 330 - } 331 - fclose (in); 332 - 333 - infos = 334 - gg_image_infos_create (GG_PIXEL_GRID, width, height, 16, 1, 335 - GGRAPH_SAMPLE_INT, "WGS 84", 336 - "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"); 337 - if (!infos) 338 - return GGRAPH_INSUFFICIENT_MEMORY; 339 - 340 -/* setting up georeferencing infos */ 341 - half_pixel = pixel_size / 2.0; 342 - infos->is_georeferenced = 1; 343 - infos->srid = 4326; 344 - infos->upper_left_x = (double) lon - half_pixel; 345 - infos->upper_left_y = (double) lat + 1.0 + half_pixel; 346 - infos->pixel_x_size = pixel_size; 347 - infos->pixel_y_size = pixel_size; 348 - infos->no_data_value = SHRT_MIN; 349 - 350 - *infos_handle = infos; 351 - return GGRAPH_OK; 352 -} 353 - 354 -GGRAPH_DECLARE int 355 -gGraphCheckBinPath (const char *path, char *hdr_path, int dont_test) 356 -{ 357 -/* checking for BIN+HDR format */ 358 - char naked_path[1024]; 359 - int i; 360 - int start = 0; 361 - FILE *in; 362 - 363 - *hdr_path = '\0'; 364 - for (i = strlen (path) - 1; i >= 0; i--) 365 - { 366 - /* attempting to extract the file name */ 367 - if (path[i] == '.') 368 - { 369 - start = i; 370 - break; 371 - } 372 - } 373 - strcpy (naked_path, path); 374 - if (strcasecmp (path + start, ".bin") != 0) 375 - return GGRAPH_ERROR; 376 - naked_path[start] = '\0'; 377 - strcat (naked_path, ".hdr"); 378 - if (dont_test) 379 - { 380 - strcpy (hdr_path, naked_path); 381 - return GGRAPH_OK; 382 - } 383 - 384 - in = fopen (naked_path, "rb"); 385 - if (in != NULL) 386 - { 387 - fclose (in); 388 - strcpy (hdr_path, naked_path); 389 - return GGRAPH_OK; 390 - } 391 - naked_path[start] = '\0'; 392 - strcat (naked_path, ".HDR"); 393 - in = fopen (naked_path, "rb"); 394 - if (in != NULL) 395 - { 396 - fclose (in); 397 - strcpy (hdr_path, naked_path); 398 - return GGRAPH_OK; 399 - } 400 - 401 - return GGRAPH_ERROR; 402 -} 403 - 404 -GGRAPH_DECLARE int 405 -gGraphCheckFltPath (const char *path, char *hdr_path, int dont_test) 406 -{ 407 -/* checking for FLT+HDR format */ 408 - char naked_path[1024]; 409 - int i; 410 - int start = 0; 411 - FILE *in; 412 - 413 - *hdr_path = '\0'; 414 - for (i = strlen (path) - 1; i >= 0; i--) 415 - { 416 - /* attempting to extract the file name */ 417 - if (path[i] == '.') 418 - { 419 - start = i; 420 - break; 421 - } 422 - } 423 - strcpy (naked_path, path); 424 - if (strcasecmp (path + start, ".flt") != 0) 425 - return GGRAPH_ERROR; 426 - naked_path[start] = '\0'; 427 - strcat (naked_path, ".hdr"); 428 - if (dont_test) 429 - { 430 - strcpy (hdr_path, naked_path); 431 - return GGRAPH_OK; 432 - } 433 - 434 - in = fopen (naked_path, "rb"); 435 - if (in != NULL) 436 - { 437 - fclose (in); 438 - strcpy (hdr_path, naked_path); 439 - return GGRAPH_OK; 440 - } 441 - naked_path[start] = '\0'; 442 - strcat (naked_path, ".HDR"); 443 - in = fopen (naked_path, "rb"); 444 - if (in != NULL) 445 - { 446 - fclose (in); 447 - strcpy (hdr_path, naked_path); 448 - return GGRAPH_OK; 449 - } 450 - 451 - return GGRAPH_ERROR; 452 -} 453 - 454 -GGRAPH_DECLARE int 455 -gGraphCheckDemPath (const char *path, char *hdr_path, int dont_test) 456 -{ 457 -/* checking for DEM+HDR format */ 458 - char naked_path[1024]; 459 - int i; 460 - int start = 0; 461 - FILE *in; 462 - 463 - *hdr_path = '\0'; 464 - for (i = strlen (path) - 1; i >= 0; i--) 465 - { 466 - /* attempting to extract the file name */ 467 - if (path[i] == '.') 468 - { 469 - start = i; 470 - break; 471 - } 472 - } 473 - strcpy (naked_path, path); 474 - if (strcasecmp (path + start, ".dem") != 0) 475 - return GGRAPH_ERROR; 476 - naked_path[start] = '\0'; 477 - strcat (naked_path, ".hdr"); 478 - if (dont_test) 479 - { 480 - strcpy (hdr_path, naked_path); 481 - return GGRAPH_OK; 482 - } 483 - 484 - in = fopen (naked_path, "rb"); 485 - if (in != NULL) 486 - { 487 - fclose (in); 488 - strcpy (hdr_path, naked_path); 489 - return GGRAPH_OK; 490 - } 491 - naked_path[start] = '\0'; 492 - strcat (naked_path, ".HDR"); 493 - in = fopen (naked_path, "rb"); 494 - if (in != NULL) 495 - { 496 - fclose (in); 497 - strcpy (hdr_path, naked_path); 498 - return GGRAPH_OK; 499 - } 500 - 501 - return GGRAPH_ERROR; 502 -} 503 - 504 -GGRAPH_DECLARE int 505 -gGraphCheckAscPath (const char *path) 506 -{ 507 -/* checking for ASC format */ 508 - int i; 509 - int start = 0; 510 - 511 - for (i = strlen (path) - 1; i >= 0; i--) 512 - { 513 - /* attempting to extract the file name */ 514 - if (path[i] == '.') 515 - { 516 - start = i; 517 - break; 518 - } 519 - } 520 - if (strcasecmp (path + start, ".asc") != 0) 521 - return GGRAPH_ERROR; 522 - return GGRAPH_OK; 523 -} 524 - 525 -static char * 526 -string_tokenizer (char *string, char *delimiters, char **ptr) 527 -{ 528 -/* breaking a string into distinct tokens */ 529 - char *start = NULL; 530 - char *p; 531 - if (*ptr != NULL) 532 - p = *ptr; 533 - else 534 - p = string; 535 - 536 - if (p == NULL) 537 - return NULL; 538 - 539 - while (1) 540 - { 541 - int sep = 0; 542 - char *pd = delimiters; 543 - 544 - if (*p == '\0') 545 - { 546 - /* last token end */ 547 - *ptr = p; 548 - break; 549 - } 550 - 551 - while (*pd != '\0') 552 - { 553 - if (*p == *pd) 554 - { 555 - /* found a separator char */ 556 - sep = 1; 557 - break; 558 - } 559 - pd++; 560 - } 561 - if (sep) 562 - { 563 - if (start) 564 - { 565 - /* token end */ 566 - *p = '\0'; 567 - *ptr = p + 1; 568 - break; 569 - } 570 - } 571 - else 572 - { 573 - if (!start) 574 - { 575 - /* token start */ 576 - start = p; 577 - } 578 - } 579 - p++; 580 - } 581 - 582 - return start; 583 -} 584 - 585 -static int 586 -cvtToInt (const char *str, int *value) 587 -{ 588 -/* attempting to convert from string to int */ 589 - const char *p = str; 590 - int error = 0; 591 - int digits = 0; 592 - int sign = 0; 593 - while (*p != '\0') 594 - { 595 - if (*p >= '0' && *p <= '9') 596 - digits++; 597 - else if (*p == '-' || *p == '+') 598 - { 599 - if (digits == 0) 600 - sign++; 601 - else 602 - error = 1; 603 - } 604 - else 605 - error = 1; 606 - p++; 607 - } 608 - if (digits > 0 && sign < 2 && error == 0) 609 - { 610 - *value = atoi (str); 611 - return 1; 612 - } 613 - return 0; 614 -} 615 - 616 -static int 617 -cvtToDouble (const char *str, double *value) 618 -{ 619 -/* attempting to convert from string to double */ 620 - const char *p = str; 621 - int error = 0; 622 - int digits = 0; 623 - int comma = 0; 624 - int sign = 0; 625 - while (*p != '\0') 626 - { 627 - if (*p >= '0' && *p <= '9') 628 - digits++; 629 - else if (*p == '.') 630 - comma++; 631 - else if (*p == '-' || *p == '+') 632 - { 633 - if (digits == 0) 634 - sign++; 635 - else 636 - error = 1; 637 - } 638 - else 639 - error = 1; 640 - p++; 641 - } 642 - if (digits > 0 && sign < 2 && comma < 2 && error == 0) 643 - { 644 - *value = atof (str); 645 - return 1; 646 - } 647 - return 0; 648 -} 649 - 650 -static int 651 -parse_binflt_hdr (const char *hdr_path, int *width, int *height, 652 - int *bits_per_sample, int *sample, int *endian, 653 - double *no_data, double *min, double *max, double *ulx, 654 - double *uly, double *pixel_x_size, double *pixel_y_size, 655 - int *expected_length) 656 -{ 657 -/* parsing an HDR file [BIN or FLT format] */ 658 - FILE *hdr = NULL; 659 - int s_width = INT_MIN; 660 - int s_height = INT_MIN; 661 - int sample_format = GGRAPH_SAMPLE_UNKNOWN; 662 - int sample_bits = INT_MIN; 663 - double no_data_value = DBL_MAX; 664 - double x_pixel_size = DBL_MAX; 665 - double y_pixel_size = DBL_MAX; 666 - double lower_left_x = DBL_MAX; 667 - double lower_left_y = DBL_MAX; 668 - double min_value = DBL_MAX; 669 - double max_value = DBL_MIN; 670 - int little_endian = 0; 671 - int c; 672 - int i_tk; 673 - char *saveptr; 674 - char hdr_buf[1024]; 675 - char *token; 676 - char keyword[1024]; 677 - char value[1024]; 678 - char *p_hdr; 679 - int cvt_int; 680 - double cvt_dbl; 681 - int x_centered; 682 - int y_centered; 683 - double half_pixel; 684 - 685 -/* opening the HDR header file */ 686 - hdr = fopen (hdr_path, "rb"); 687 - if (hdr == NULL) 688 - return 0; 689 - 690 - p_hdr = hdr_buf; 691 - while ((c = getc (hdr)) != EOF) 692 - { 693 - /* parsing the Header file */ 694 - if (c == '\r') 695 - continue; 696 - if (c == '\n') 697 - { 698 - *p_hdr = '\0'; 699 - if (*hdr_buf == '\0') 700 - { 701 - /* skipping empty lines */ 702 - p_hdr = hdr_buf; 703 - continue; 704 - } 705 - /* breaking the string into separate tokens */ 706 - i_tk = 0; 707 - saveptr = NULL; 708 - while (1) 709 - { 710 - token = string_tokenizer (hdr_buf, " \t", &saveptr); 711 - if (token == NULL) 712 - break; 713 - if (*token == '\0') 714 - continue; 715 - if (i_tk == 0) 716 - { 717 - strcpy (keyword, token); 718 - i_tk++; 719 - continue; 720 - } 721 - 722 - strcpy (value, token); 723 - i_tk++; 724 - } 725 - 726 - if (i_tk != 2) 727 - goto stop; 728 - if (strcasecmp (keyword, "BYTEORDER") == 0) 729 - { 730 - if (strcasecmp (value, "LSBFIRST") == 0) 731 - little_endian = 1; 732 - else 733 - little_endian = 0; 734 - } 735 - else if (strcasecmp (keyword, "NROWS") == 0) 736 - { 737 - if (!cvtToInt (value, &cvt_int)) 738 - goto stop; 739 - s_height = cvt_int; 740 - } 741 - else if (strcasecmp (keyword, "NCOLS") == 0) 742 - { 743 - if (!cvtToInt (value, &cvt_int)) 744 - goto stop; 745 - s_width = cvt_int; 746 - } 747 - else if (strcasecmp (keyword, "NUMBERTYPE") == 0) 748 - { 749 - if (strcasecmp (value, "2_BYTE_INTEGER") == 0) 750 - { 751 - sample_format = GGRAPH_SAMPLE_INT; 752 - sample_bits = 16; 753 - } 754 - else if (strcasecmp (value, "4_BYTE_INTEGER") == 0) 755 - { 756 - sample_format = GGRAPH_SAMPLE_INT; 757 - sample_bits = 32; 758 - } 759 - else if (strcasecmp (value, "4_BYTE_FLOAT") == 0) 760 - { 761 - sample_format = GGRAPH_SAMPLE_FLOAT; 762 - sample_bits = 32; 763 - } 764 - else if (strcasecmp (value, "8_BYTE_FLOAT") == 0) 765 - { 766 - sample_format = GGRAPH_SAMPLE_FLOAT; 767 - sample_bits = 64; 768 - } 769 - else 770 - goto stop; 771 - } 772 - else if (strcasecmp (keyword, "NODATA_VALUE") == 0) 773 - { 774 - if (!cvtToDouble (value, &cvt_dbl)) 775 - goto stop; 776 - no_data_value = cvt_dbl; 777 - } 778 - else if (strcasecmp (keyword, "XLLCENTER") == 0) 779 - { 780 - if (!cvtToDouble (value, &cvt_dbl)) 781 - goto stop; 782 - lower_left_x = cvt_dbl; 783 - x_centered = 1; 784 - } 785 - else if (strcasecmp (keyword, "XLLCORNER") == 0) 786 - { 787 - if (!cvtToDouble (value, &cvt_dbl)) 788 - goto stop; 789 - lower_left_x = cvt_dbl; 790 - x_centered = 0; 791 - } 792 - else if (strcasecmp (keyword, "YLLCENTER") == 0) 793 - { 794 - if (!cvtToDouble (value, &cvt_dbl)) 795 - goto stop; 796 - lower_left_y = cvt_dbl; 797 - y_centered = 1; 798 - } 799 - else if (strcasecmp (keyword, "YLLCORNER") == 0) 800 - { 801 - if (!cvtToDouble (value, &cvt_dbl)) 802 - goto stop; 803 - lower_left_y = cvt_dbl; 804 - y_centered = 0; 805 - } 806 - else if (strcasecmp (keyword, "CELLSIZE") == 0) 807 - { 808 - if (!cvtToDouble (value, &cvt_dbl)) 809 - goto stop; 810 - x_pixel_size = cvt_dbl; 811 - y_pixel_size = cvt_dbl; 812 - } 813 - else if (strcasecmp (keyword, "ZUNITS") == 0) 814 - { 815 - /* ignoring */ 816 - } 817 - else if (strcasecmp (keyword, "MIN_VALUE") == 0) 818 - { 819 - if (!cvtToDouble (value, &cvt_dbl)) 820 - goto stop; 821 - min_value = cvt_dbl; 822 - } 823 - else if (strcasecmp (keyword, "MAX_VALUE") == 0) 824 - { 825 - if (!cvtToDouble (value, &cvt_dbl)) 826 - goto stop; 827 - max_value = cvt_dbl; 828 - } 829 - else 830 - { 831 - /* unrecognized tag */ 832 - goto stop; 833 - } 834 - p_hdr = hdr_buf; 835 - continue; 836 - } 837 - *p_hdr++ = c; 838 - if (p_hdr - hdr_buf > 1024) 839 - goto stop; 840 - } 841 - fclose (hdr); 842 - hdr = NULL; 843 - 844 - if (s_width <= 0 || s_height <= 0 || sample_bits <= 0) 845 - goto stop; 846 - if (sample_format == GGRAPH_SAMPLE_UNKNOWN) 847 - goto stop; 848 - if (no_data_value == INT_MAX) 849 - goto stop; 850 - if (x_pixel_size == DBL_MAX || y_pixel_size == DBL_MAX) 851 - goto stop; 852 - if (lower_left_x == DBL_MAX || lower_left_y == DBL_MAX) 853 - goto stop; 854 - if (min_value == DBL_MAX || max_value == DBL_MIN) 855 - goto stop; 856 - 857 - *width = s_width; 858 - *height = s_height; 859 - *sample = sample_format; 860 - *bits_per_sample = sample_bits; 861 - *endian = little_endian; 862 - *no_data = no_data_value; 863 - *ulx = lower_left_x; 864 - half_pixel = x_pixel_size / 2.0; 865 - if (x_centered) 866 - *ulx -= half_pixel; 867 - *uly = lower_left_y + ((double) s_height * y_pixel_size); 868 - half_pixel = y_pixel_size / 2.0; 869 - if (y_centered) 870 - *uly += half_pixel; 871 - *pixel_x_size = x_pixel_size; 872 - *pixel_y_size = y_pixel_size; 873 - *min = min_value; 874 - *max = max_value; 875 - if (sample_bits == 16) 876 - *expected_length = s_width * s_height * 2; 877 - else if (sample_bits == 32) 878 - *expected_length = s_width * s_height * 4; 879 - else if (sample_bits == 64) 880 - *expected_length = s_width * s_height * 8; 881 - else 882 - *expected_length = -1; 883 - return 1; 884 - 885 - stop: 886 - if (hdr) 887 - fclose (hdr); 888 - return 0; 889 -} 890 - 891 -GGRAPH_DECLARE int 892 -gGraphImageInfosFromBinFile (const char *path, const char *hdr_path, 893 - const void **infos_handle) 894 -{ 895 -/* retrieving Image infos from BIN+HDR file */ 896 - FILE *in = NULL; 897 - gGraphImageInfosPtr infos = NULL; 898 - long file_length; 899 - int expected_length; 900 - int width; 901 - int height; 902 - double ulx; 903 - double uly; 904 - double pixel_x_size; 905 - double pixel_y_size; 906 - int sample; 907 - int bits_per_sample; 908 - int endian; 909 - double no_data; 910 - double min; 911 - double max; 912 - 913 - *infos_handle = NULL; 914 - 915 - if (!parse_binflt_hdr 916 - (hdr_path, &width, &height, &bits_per_sample, &sample, &endian, 917 - &no_data, &min, &max, &ulx, &uly, &pixel_x_size, &pixel_y_size, 918 - &expected_length)) 919 - return GGRAPH_BIN_CODEC_ERROR; 920 - 921 -/* attempting to open the image file */ 922 - in = fopen (path, "rb"); 923 - if (in == NULL) 924 - return GGRAPH_FILE_OPEN_ERROR; 925 - 926 -/* retrieving the BIN dimensions */ 927 - if (fseek (in, 0, SEEK_END) != 0) 928 - return GGRAPH_BIN_CODEC_ERROR; 929 - file_length = ftell (in); 930 - if (file_length != expected_length) 931 - { 932 - fclose (in); 933 - return GGRAPH_BIN_CODEC_ERROR; 934 - } 935 - fclose (in); 936 - 937 - infos = 938 - gg_image_infos_create (GG_PIXEL_GRID, width, height, bits_per_sample, 1, 939 - sample, NULL, NULL); 940 - if (!infos) 941 - return GGRAPH_INSUFFICIENT_MEMORY; 942 - 943 -/* setting up georeferencing infos */ 944 - infos->is_georeferenced = 1; 945 - infos->upper_left_x = ulx; 946 - infos->upper_left_y = uly; 947 - infos->pixel_x_size = pixel_x_size; 948 - infos->pixel_y_size = pixel_y_size; 949 - infos->no_data_value = no_data; 950 - infos->min_value = min; 951 - infos->max_value = max; 952 - 953 - *infos_handle = infos; 954 - return GGRAPH_OK; 955 -} 956 - 957 -GGRAPH_DECLARE int 958 -gGraphImageInfosFromFltFile (const char *path, const char *hdr_path, 959 - const void **infos_handle) 960 -{ 961 -/* retrieving Image infos from FLT+HDR file */ 962 - FILE *in = NULL; 963 - gGraphImageInfosPtr infos = NULL; 964 - long file_length; 965 - int expected_length; 966 - int width; 967 - int height; 968 - double ulx; 969 - double uly; 970 - double pixel_x_size; 971 - double pixel_y_size; 972 - int sample; 973 - int bits_per_sample; 974 - int endian; 975 - double no_data; 976 - double min; 977 - double max; 978 - 979 - *infos_handle = NULL; 980 - 981 - if (!parse_binflt_hdr 982 - (hdr_path, &width, &height, &bits_per_sample, &sample, &endian, 983 - &no_data, &min, &max, &ulx, &uly, &pixel_x_size, &pixel_y_size, 984 - &expected_length)) 985 - return GGRAPH_FLT_CODEC_ERROR; 986 - 987 -/* attempting to open the image file */ 988 - in = fopen (path, "rb"); 989 - if (in == NULL) 990 - return GGRAPH_FILE_OPEN_ERROR; 991 - 992 -/* retrieving the FLT dimensions */ 993 - if (fseek (in, 0, SEEK_END) != 0) 994 - return GGRAPH_FLT_CODEC_ERROR; 995 - file_length = ftell (in); 996 - if (file_length != expected_length) 997 - { 998 - fclose (in); 999 - return GGRAPH_FLT_CODEC_ERROR; 1000 - } 1001 - fclose (in); 1002 - 1003 - infos = 1004 - gg_image_infos_create (GG_PIXEL_GRID, width, height, bits_per_sample, 1, 1005 - sample, NULL, NULL); 1006 - if (!infos) 1007 - return GGRAPH_INSUFFICIENT_MEMORY; 1008 - 1009 -/* setting up georeferencing infos */ 1010 - infos->is_georeferenced = 1; 1011 - infos->upper_left_x = ulx; 1012 - infos->upper_left_y = uly; 1013 - infos->pixel_x_size = pixel_x_size; 1014 - infos->pixel_y_size = pixel_y_size; 1015 - infos->no_data_value = no_data; 1016 - infos->min_value = min; 1017 - infos->max_value = max; 1018 - 1019 - *infos_handle = infos; 1020 - return GGRAPH_OK; 1021 -} 1022 - 1023 -static int 1024 -parse_dem_hdr (const char *hdr_path, int *width, int *height, 1025 - int *bits_per_sample, int *sample, int *endian, double *no_data, 1026 - double *ulx, double *uly, double *pixel_x_size, 1027 - double *pixel_y_size, int *expected_length) 1028 -{ 1029 -/* parsing an HDR file [DEM format] */ 1030 - FILE *hdr = NULL; 1031 - int s_width = INT_MIN; 1032 - int s_height = INT_MIN; 1033 - int sample_format = GGRAPH_SAMPLE_UNKNOWN; 1034 - int sample_bits = INT_MIN; 1035 - double no_data_value = DBL_MAX; 1036 - double x_pixel_size = DBL_MAX; 1037 - double y_pixel_size = DBL_MAX; 1038 - double upper_left_x = DBL_MAX; 1039 - double upper_left_y = DBL_MAX; 1040 - int band_row_bytes = INT_MIN; 1041 - int total_row_bytes = INT_MIN; 1042 - int little_endian = 0; 1043 - int c; 1044 - int i_tk; 1045 - char *saveptr; 1046 - char hdr_buf[1024]; 1047 - char *token; 1048 - char keyword[1024]; 1049 - char value[1024]; 1050 - char *p_hdr; 1051 - int cvt_int; 1052 - double cvt_dbl; 1053 - 1054 -/* opening the HDR header file */ 1055 - hdr = fopen (hdr_path, "rb"); 1056 - if (hdr == NULL) 1057 - return 0; 1058 - 1059 - p_hdr = hdr_buf; 1060 - while ((c = getc (hdr)) != EOF) 1061 - { 1062 - /* parsing the Header file */ 1063 - if (c == '\r' || c == '\n') 1064 - { 1065 - *p_hdr = '\0'; 1066 - if (*hdr_buf == '\0') 1067 - { 1068 - /* skipping empty lines */ 1069 - p_hdr = hdr_buf; 1070 - continue; 1071 - } 1072 - /* breaking the string into separate tokens */ 1073 - i_tk = 0; 1074 - saveptr = NULL; 1075 - while (1) 1076 - { 1077 - token = string_tokenizer (hdr_buf, " \t", &saveptr); 1078 - if (token == NULL) 1079 - break; 1080 - if (*token == '\0') 1081 - continue; 1082 - if (i_tk == 0) 1083 - { 1084 - strcpy (keyword, token); 1085 - i_tk++; 1086 - continue; 1087 - } 1088 - 1089 - strcpy (value, token); 1090 - i_tk++; 1091 - } 1092 - 1093 - if (i_tk != 2) 1094 - goto stop; 1095 - if (strcasecmp (keyword, "BYTEORDER") == 0) 1096 - { 1097 - if (strcasecmp (value, "M") == 0) 1098 - little_endian = 0; 1099 - else 1100 - little_endian = 1; 1101 - } 1102 - else if (strcasecmp (keyword, "LAYOUT") == 0) 1103 - { 1104 - /* Bands organization: only Band Interleave by Line is supported */ 1105 - if (strcasecmp (value, "BIL") != 0) 1106 - goto stop; 1107 - } 1108 - else if (strcasecmp (keyword, "NROWS") == 0) 1109 - { 1110 - if (!cvtToInt (value, &cvt_int)) 1111 - goto stop; 1112 - s_height = cvt_int; 1113 - } 1114 - else if (strcasecmp (keyword, "NCOLS") == 0) 1115 - { 1116 - if (!cvtToInt (value, &cvt_int)) 1117 - goto stop; 1118 - s_width = cvt_int; 1119 - } 1120 - else if (strcasecmp (keyword, "NBANDS") == 0) 1121 - { 1122 - /* expected: 1 band */ 1123 - if (!cvtToInt (value, &cvt_int)) 1124 - goto stop; 1125 - if (cvt_int != 1) 1126 - goto stop; 1127 - } 1128 - else if (strcasecmp (keyword, "NBITS") == 0) 1129 - { 1130 - /* expected: 16 or 32 bit ints */ 1131 - if (!cvtToInt (value, &cvt_int)) 1132 - goto stop; 1133 - if (cvt_int == 16) 1134 - { 1135 - sample_format = GGRAPH_SAMPLE_INT; 1136 - sample_bits = 16; 1137 - } 1138 - else if (cvt_int == 32) 1139 - { 1140 - sample_format = GGRAPH_SAMPLE_INT; 1141 - sample_bits = 32; 1142 - } 1143 - else 1144 - goto stop; 1145 - } 1146 - else if (strcasecmp (keyword, "BANDROWBYTES") == 0) 1147 - { 1148 - if (!cvtToInt (value, &cvt_int)) 1149 - goto stop; 1150 - band_row_bytes = cvt_int; 1151 - } 1152 - else if (strcasecmp (keyword, "TOTALROWBYTES") == 0) 1153 - { 1154 - if (!cvtToInt (value, &cvt_int)) 1155 - goto stop; 1156 - total_row_bytes = cvt_int; 1157 - } 1158 - else if (strcasecmp (keyword, "BANDGAPBYTES") == 0) 1159 - { 1160 - /* expected: 0 bytes between bands */ 1161 - if (!cvtToInt (value, &cvt_int)) 1162 - goto stop; 1163 - if (cvt_int != 0) 1164 - goto stop; 1165 - } 1166 - else if (strcasecmp (keyword, "NODATA") == 0) 1167 - { 1168 - if (!cvtToInt (value, &cvt_int)) 1169 - goto stop; 1170 - no_data_value = cvt_int; 1171 - } 1172 - else if (strcasecmp (keyword, "ULXMAP") == 0) 1173 - { 1174 - if (!cvtToDouble (value, &cvt_dbl)) 1175 - goto stop; 1176 - upper_left_x = cvt_dbl; 1177 - } 1178 - else if (strcasecmp (keyword, "ULYMAP") == 0) 1179 - { 1180 - if (!cvtToDouble (value, &cvt_dbl)) 1181 - goto stop; 1182 - upper_left_y = cvt_dbl; 1183 - } 1184 - else if (strcasecmp (keyword, "XDIM") == 0) 1185 - { 1186 - if (!cvtToDouble (value, &cvt_dbl)) 1187 - goto stop; 1188 - x_pixel_size = cvt_dbl; 1189 - } 1190 - else if (strcasecmp (keyword, "YDIM") == 0) 1191 - { 1192 - if (!cvtToDouble (value, &cvt_dbl)) 1193 - goto stop; 1194 - y_pixel_size = cvt_dbl; 1195 - } 1196 - else 1197 - { 1198 - /* unrecognized tag */ 1199 - goto stop; 1200 - } 1201 - p_hdr = hdr_buf; 1202 - continue; 1203 - } 1204 - *p_hdr++ = c; 1205 - if (p_hdr - hdr_buf > 1024) 1206 - goto stop; 1207 - } 1208 - fclose (hdr); 1209 - hdr = NULL; 1210 - 1211 - if (s_width <= 0 || s_height <= 0 || sample_bits <= 0) 1212 - goto stop; 1213 - if (sample_format == GGRAPH_SAMPLE_UNKNOWN) 1214 - goto stop; 1215 - if (no_data_value == INT_MAX) 1216 - goto stop; 1217 - if (x_pixel_size == DBL_MAX || y_pixel_size == DBL_MAX) 1218 - goto stop; 1219 - if (upper_left_x == DBL_MAX || upper_left_y == DBL_MAX) 1220 - goto stop; 1221 - if (sample_bits == 16) 1222 - { 1223 - if (2 * s_width != band_row_bytes) 1224 - goto stop; 1225 - if (2 * s_width != total_row_bytes) 1226 - goto stop; 1227 - } 1228 - if (sample_bits == 32) 1229 - { 1230 - if (4 * s_width != band_row_bytes) 1231 - goto stop; 1232 - if (4 * s_width != total_row_bytes) 1233 - goto stop; 1234 - } 1235 - *width = s_width; 1236 - *height = s_height; 1237 - *sample = sample_format; 1238 - *bits_per_sample = sample_bits; 1239 - *endian = little_endian; 1240 - *no_data = no_data_value; 1241 - *ulx = upper_left_x; 1242 - *uly = upper_left_y; 1243 - *pixel_x_size = x_pixel_size; 1244 - *pixel_y_size = y_pixel_size; 1245 - if (sample_bits == 16) 1246 - *expected_length = s_width * s_height * 2; 1247 - else if (sample_bits == 32) 1248 - *expected_length = s_width * s_height * 4; 1249 - else 1250 - *expected_length = -1; 1251 - return 1; 1252 - 1253 - stop: 1254 - if (hdr) 1255 - fclose (hdr); 1256 - return 0; 1257 -} 1258 - 1259 -GGRAPH_DECLARE int 1260 -gGraphImageInfosFromDemFile (const char *path, const char *hdr_path, 1261 - const void **infos_handle) 1262 -{ 1263 -/* retrieving Image infos from DEM+HDR file */ 1264 - FILE *in = NULL; 1265 - gGraphImageInfosPtr infos = NULL; 1266 - long file_length; 1267 - int expected_length; 1268 - int width; 1269 - int height; 1270 - double ulx; 1271 - double uly; 1272 - double pixel_x_size; 1273 - double pixel_y_size; 1274 - int sample; 1275 - int bits_per_sample; 1276 - int endian; 1277 - double no_data; 1278 - 1279 - *infos_handle = NULL; 1280 - 1281 - if (!parse_dem_hdr 1282 - (hdr_path, &width, &height, &bits_per_sample, &sample, &endian, 1283 - &no_data, &ulx, &uly, &pixel_x_size, &pixel_y_size, &expected_length)) 1284 - return GGRAPH_FLT_CODEC_ERROR; 1285 - 1286 -/* attempting to open the image file */ 1287 - in = fopen (path, "rb"); 1288 - if (in == NULL) 1289 - return GGRAPH_FILE_OPEN_ERROR; 1290 - 1291 -/* retrieving the FLT dimensions */ 1292 - if (fseek (in, 0, SEEK_END) != 0) 1293 - return GGRAPH_FLT_CODEC_ERROR; 1294 - file_length = ftell (in); 1295 - if (file_length != expected_length) 1296 - { 1297 - fclose (in); 1298 - return GGRAPH_FLT_CODEC_ERROR; 1299 - } 1300 - fclose (in); 1301 - 1302 - infos = 1303 - gg_image_infos_create (GG_PIXEL_GRID, width, height, bits_per_sample, 1, 1304 - sample, NULL, NULL); 1305 - if (!infos) 1306 - return GGRAPH_INSUFFICIENT_MEMORY; 1307 - 1308 -/* setting up georeferencing infos */ 1309 - infos->is_georeferenced = 1; 1310 - infos->upper_left_x = ulx; 1311 - infos->upper_left_y = uly; 1312 - infos->pixel_x_size = pixel_x_size; 1313 - infos->pixel_y_size = pixel_y_size; 1314 - infos->no_data_value = no_data; 1315 - 1316 - *infos_handle = infos; 1317 - return GGRAPH_OK; 1318 -} 1319 - 1320 -static int 1321 -parse_asc_hdr (const char *path, FILE * file, int *width, int *height, 1322 - double *ulx, double *uly, double *pixel_x_size, 1323 - double *pixel_y_size, double *no_data) 1324 -{ 1325 -/* parsing an ASC file [ASCII GRID format] */ 1326 - FILE *hdr = NULL; 1327 - int s_width = INT_MIN; 1328 - int s_height = INT_MIN; 1329 - double x_pixel_size = DBL_MAX; 1330 - double y_pixel_size = DBL_MAX; 1331 - double lower_left_x = DBL_MAX; 1332 - double lower_left_y = DBL_MAX; 1333 - double no_data_value = DBL_MAX; 1334 - int c; 1335 - int i_tk; 1336 - char *saveptr; 1337 - char hdr_buf[1024]; 1338 - char *token; 1339 - char keyword[1024]; 1340 - char value[1024]; 1341 - char *p_hdr; 1342 - int cvt_int; 1343 - double cvt_dbl; 1344 - int x_centered; 1345 - int y_centered; 1346 - double half_pixel; 1347 - int row; 1348 - 1349 - if (path != NULL) 1350 - { 1351 - /* opening the ASC header file */ 1352 - hdr = fopen (path, "rb"); 1353 - } 1354 - else 1355 - hdr = file; 1356 - if (hdr == NULL) 1357 - return 0; 1358 - row = 0; 1359 - p_hdr = hdr_buf; 1360 - while ((c = getc (hdr)) != EOF) 1361 - { 1362 - /* parsing the Header file */ 1363 - if (c == '\r') 1364 - continue; 1365 - if (c == '\n') 1366 - { 1367 - row++; 1368 - *p_hdr = '\0'; 1369 - if (*hdr_buf == '\0') 1370 - { 1371 - /* skipping empty lines */ 1372 - p_hdr = hdr_buf; 1373 - continue; 1374 - } 1375 - /* breaking the string into separate tokens */ 1376 - i_tk = 0; 1377 - saveptr = NULL; 1378 - while (1) 1379 - { 1380 - token = string_tokenizer (hdr_buf, " \t", &saveptr); 1381 - if (token == NULL) 1382 - break; 1383 - if (*token == '\0') 1384 - continue; 1385 - if (i_tk == 0) 1386 - { 1387 - strcpy (keyword, token); 1388 - i_tk++; 1389 - continue; 1390 - } 1391 - 1392 - strcpy (value, token); 1393 - i_tk++; 1394 - } 1395 - 1396 - if (i_tk != 2) 1397 - goto stop; 1398 - if (strcasecmp (keyword, "NROWS") == 0) 1399 - { 1400 - if (!cvtToInt (value, &cvt_int)) 1401 - goto stop; 1402 - s_height = cvt_int; 1403 - } 1404 - else if (strcasecmp (keyword, "NCOLS") == 0) 1405 - { 1406 - if (!cvtToInt (value, &cvt_int)) 1407 - goto stop; 1408 - s_width = cvt_int; 1409 - } 1410 - else if (strcasecmp (keyword, "NODATA_VALUE") == 0) 1411 - { 1412 - if (!cvtToDouble (value, &cvt_dbl)) 1413 - goto stop; 1414 - no_data_value = cvt_dbl; 1415 - } 1416 - else if (strcasecmp (keyword, "XLLCENTER") == 0) 1417 - { 1418 - if (!cvtToDouble (value, &cvt_dbl)) 1419 - goto stop; 1420 - lower_left_x = cvt_dbl; 1421 - x_centered = 1; 1422 - } 1423 - else if (strcasecmp (keyword, "XLLCORNER") == 0) 1424 - { 1425 - if (!cvtToDouble (value, &cvt_dbl)) 1426 - goto stop; 1427 - lower_left_x = cvt_dbl; 1428 - x_centered = 0; 1429 - } 1430 - else if (strcasecmp (keyword, "YLLCENTER") == 0) 1431 - { 1432 - if (!cvtToDouble (value, &cvt_dbl)) 1433 - goto stop; 1434 - lower_left_y = cvt_dbl; 1435 - y_centered = 1; 1436 - } 1437 - else if (strcasecmp (keyword, "YLLCORNER") == 0) 1438 - { 1439 - if (!cvtToDouble (value, &cvt_dbl)) 1440 - goto stop; 1441 - lower_left_y = cvt_dbl; 1442 - y_centered = 0; 1443 - } 1444 - else if (strcasecmp (keyword, "CELLSIZE") == 0) 1445 - { 1446 - if (!cvtToDouble (value, &cvt_dbl)) 1447 - goto stop; 1448 - x_pixel_size = cvt_dbl; 1449 - y_pixel_size = x_pixel_size; 1450 - } 1451 - else 1452 - { 1453 - /* unrecognized tag */ 1454 - goto stop; 1455 - } 1456 - p_hdr = hdr_buf; 1457 - if (row == 6) 1458 - break; 1459 - continue; 1460 - } 1461 - *p_hdr++ = c; 1462 - if (p_hdr - hdr_buf > 1024) 1463 - goto stop; 1464 - } 1465 - if (path != NULL) 1466 - fclose (hdr); 1467 - hdr = NULL; 1468 - 1469 - if (s_width <= 0 || s_height <= 0) 1470 - goto stop; 1471 - if (no_data_value == INT_MAX) 1472 - goto stop; 1473 - if (x_pixel_size == DBL_MAX || y_pixel_size == DBL_MAX) 1474 - goto stop; 1475 - if (lower_left_x == DBL_MAX || lower_left_y == DBL_MAX) 1476 - goto stop; 1477 - *width = s_width; 1478 - *height = s_height; 1479 - *no_data = no_data_value; 1480 - *ulx = lower_left_x; 1481 - half_pixel = x_pixel_size / 2.0; 1482 - if (x_centered) 1483 - *ulx -= half_pixel; 1484 - *uly = lower_left_y + ((double) s_height * y_pixel_size); 1485 - half_pixel = y_pixel_size / 2.0; 1486 - if (y_centered) 1487 - *uly += half_pixel; 1488 - *pixel_x_size = x_pixel_size; 1489 - *pixel_y_size = y_pixel_size; 1490 - return 1; 1491 - 1492 - stop: 1493 - if (path != NULL) 1494 - { 1495 - if (hdr) 1496 - fclose (hdr); 1497 - } 1498 - return 0; 1499 -} 1500 - 1501 -GGRAPH_DECLARE int 1502 -gGraphImageInfosFromAscFile (const char *path, const void **infos_handle) 1503 -{ 1504 -/* retrieving Image infos from ASC file */ 1505 - gGraphImageInfosPtr infos = NULL; 1506 - int width; 1507 - int height; 1508 - double ulx; 1509 - double uly; 1510 - double pixel_x_size; 1511 - double pixel_y_size; 1512 - double no_data; 1513 - 1514 - *infos_handle = NULL; 1515 - 1516 - if (!parse_asc_hdr 1517 - (path, NULL, &width, &height, &ulx, &uly, &pixel_x_size, &pixel_y_size, 1518 - &no_data)) 1519 - return GGRAPH_ASCII_CODEC_ERROR; 1520 - 1521 - infos = 1522 - gg_image_infos_create (GG_PIXEL_GRID, width, height, 32, 1, 1523 - GGRAPH_SAMPLE_FLOAT, NULL, NULL); 1524 - if (!infos) 1525 - return GGRAPH_INSUFFICIENT_MEMORY; 1526 - 1527 -/* setting up georeferencing infos */ 1528 - infos->is_georeferenced = 1; 1529 - infos->upper_left_x = ulx; 1530 - infos->upper_left_y = uly; 1531 - infos->pixel_x_size = pixel_x_size; 1532 - infos->pixel_y_size = pixel_y_size; 1533 - infos->no_data_value = no_data; 1534 - 1535 - *infos_handle = infos; 1536 - return GGRAPH_OK; 1537 -} 1538 - 1539 -GGRAPH_PRIVATE int 1540 -gg_image_strip_prepare_from_bin_hdr (FILE * in, const char *hdr_path, 1541 - gGraphStripImagePtr * image_handle) 1542 -{ 1543 -/* preparing to decode an BIN-GRID [by strips] */ 1544 - gGraphStripImagePtr img = NULL; 1545 - struct grid_codec_data *grid_codec = NULL; 1546 - long file_length; 1547 - int expected_length; 1548 - int width; 1549 - int height; 1550 - double ulx; 1551 - double uly; 1552 - double pixel_x_size; 1553 - double pixel_y_size; 1554 - int sample; 1555 - int bits_per_sample; 1556 - int endian; 1557 - double no_data; 1558 - double min; 1559 - double max; 1560 - int buf_size; 1561 - void *grid_buffer = NULL; 1562 - int ret = GGRAPH_BIN_CODEC_ERROR; 1563 - *image_handle = NULL; 1564 - 1565 - if (!parse_binflt_hdr 1566 - (hdr_path, &width, &height, &bits_per_sample, &sample, &endian, 1567 - &no_data, &min, &max, &ulx, &uly, &pixel_x_size, &pixel_y_size, 1568 - &expected_length)) 1569 - return GGRAPH_BIN_CODEC_ERROR; 1570 - 1571 -/* retrieving the BIN dimensions */ 1572 - if (fseek (in, 0, SEEK_END) != 0) 1573 - return GGRAPH_BIN_CODEC_ERROR; 1574 - file_length = ftell (in); 1575 - if (file_length != expected_length) 1576 - return GGRAPH_BIN_CODEC_ERROR; 1577 - 1578 - img = 1579 - gg_strip_image_create (in, GGRAPH_IMAGE_BIN_HDR, GG_PIXEL_GRID, width, 1580 - height, bits_per_sample, 1, sample, NULL, NULL); 1581 - if (!img) 1582 - { 1583 - ret = GGRAPH_INSUFFICIENT_MEMORY; 1584 - goto error; 1585 - } 1586 - 1587 -/* setting up georeferencing infos */ 1588 - img->is_georeferenced = 1; 1589 - img->upper_left_x = ulx; 1590 - img->upper_left_y = uly; 1591 - img->pixel_x_size = pixel_x_size; 1592 - img->pixel_y_size = pixel_y_size; 1593 - img->no_data_value = no_data; 1594 - img->min_value = min; 1595 - img->max_value = max; 1596 - 1597 -/* setting up the GRID codec struct */ 1598 - grid_codec = malloc (sizeof (struct grid_codec_data)); 1599 - if (!grid_codec) 1600 - goto error; 1601 - grid_codec->grid_type = GRID_BIN_HDR; 1602 - grid_codec->is_writer = 0; 1603 - grid_codec->grid_buffer = NULL; 1604 - grid_codec->row_offsets = NULL; 1605 - grid_codec->little_endian = endian; 1606 - img->codec_data = grid_codec; 1607 - 1608 -/* allocating the GRID read buffer */ 1609 - if (sample == GGRAPH_SAMPLE_INT) 1610 - { 1611 - if (bits_per_sample == 16) 1612 - buf_size = sizeof (short) * width; 1613 - if (bits_per_sample == 32) 1614 - buf_size = sizeof (int) * width; 1615 - } 1616 - if (sample == GGRAPH_SAMPLE_FLOAT) 1617 - { 1618 - if (bits_per_sample == 32) 1619 - buf_size = sizeof (float) * width; 1620 - if (bits_per_sample == 64) 1621 - buf_size = sizeof (double) * width; 1622 - } 1623 - grid_buffer = malloc (buf_size); 1624 - if (!grid_buffer) 1625 - goto error; 1626 - grid_codec->grid_buffer = grid_buffer; 1627 - 1628 - *image_handle = img; 1629 - return GGRAPH_OK; 1630 - 1631 - error: 1632 - if (img) 1633 - gGraphDestroyImage (img); 1634 - return ret; 1635 -} 1636 - 1637 -GGRAPH_PRIVATE int 1638 -gg_image_strip_prepare_from_flt_hdr (FILE * in, const char *hdr_path, 1639 - gGraphStripImagePtr * image_handle) 1640 -{ 1641 -/* preparing to decode an FLT-GRID [by strips] */ 1642 - gGraphStripImagePtr img = NULL; 1643 - struct grid_codec_data *grid_codec = NULL; 1644 - long file_length; 1645 - int expected_length; 1646 - int width; 1647 - int height; 1648 - double ulx; 1649 - double uly; 1650 - double pixel_x_size; 1651 - double pixel_y_size; 1652 - int sample; 1653 - int bits_per_sample; 1654 - int endian; 1655 - double no_data; 1656 - double min; 1657 - double max; 1658 - int buf_size; 1659 - void *grid_buffer = NULL; 1660 - int ret = GGRAPH_FLT_CODEC_ERROR; 1661 - *image_handle = NULL; 1662 - 1663 - if (!parse_binflt_hdr 1664 - (hdr_path, &width, &height, &bits_per_sample, &sample, &endian, 1665 - &no_data, &min, &max, &ulx, &uly, &pixel_x_size, &pixel_y_size, 1666 - &expected_length)) 1667 - return GGRAPH_FLT_CODEC_ERROR; 1668 - 1669 -/* retrieving the FLT dimensions */ 1670 - if (fseek (in, 0, SEEK_END) != 0) 1671 - return GGRAPH_FLT_CODEC_ERROR; 1672 - file_length = ftell (in); 1673 - if (file_length != expected_length) 1674 - return GGRAPH_FLT_CODEC_ERROR; 1675 - 1676 - img = 1677 - gg_strip_image_create (in, GGRAPH_IMAGE_FLT_HDR, GG_PIXEL_GRID, width, 1678 - height, bits_per_sample, 1, sample, NULL, NULL); 1679 - if (!img) 1680 - { 1681 - ret = GGRAPH_INSUFFICIENT_MEMORY; 1682 - goto error; 1683 - } 1684 - 1685 -/* setting up georeferencing infos */ 1686 - img->is_georeferenced = 1; 1687 - img->upper_left_x = ulx; 1688 - img->upper_left_y = uly; 1689 - img->pixel_x_size = pixel_x_size; 1690 - img->pixel_y_size = pixel_y_size; 1691 - img->no_data_value = no_data; 1692 - img->min_value = min; 1693 - img->max_value = max; 1694 - 1695 -/* setting up the GRID codec struct */ 1696 - grid_codec = malloc (sizeof (struct grid_codec_data)); 1697 - if (!grid_codec) 1698 - goto error; 1699 - grid_codec->grid_type = GRID_FLT_HDR; 1700 - grid_codec->is_writer = 0; 1701 - grid_codec->grid_buffer = NULL; 1702 - grid_codec->row_offsets = NULL; 1703 - grid_codec->little_endian = endian; 1704 - img->codec_data = grid_codec; 1705 - 1706 -/* allocating the GRID read buffer */ 1707 - if (sample == GGRAPH_SAMPLE_INT) 1708 - { 1709 - if (bits_per_sample == 16) 1710 - buf_size = sizeof (short) * width; 1711 - if (bits_per_sample == 32) 1712 - buf_size = sizeof (int) * width; 1713 - } 1714 - if (sample == GGRAPH_SAMPLE_FLOAT) 1715 - { 1716 - if (bits_per_sample == 32) 1717 - buf_size = sizeof (float) * width; 1718 - if (bits_per_sample == 64) 1719 - buf_size = sizeof (double) * width; 1720 - } 1721 - grid_buffer = malloc (buf_size); 1722 - if (!grid_buffer) 1723 - goto error; 1724 - grid_codec->grid_buffer = grid_buffer; 1725 - 1726 - *image_handle = img; 1727 - return GGRAPH_OK; 1728 - 1729 - error: 1730 - if (img) 1731 - gGraphDestroyImage (img); 1732 - return ret; 1733 -} 1734 - 1735 -GGRAPH_PRIVATE int 1736 -gg_image_strip_prepare_from_dem_hdr (FILE * in, const char *hdr_path, 1737 - gGraphStripImagePtr * image_handle) 1738 -{ 1739 -/* preparing to decode an DEM-GRID [by strips] */ 1740 - gGraphStripImagePtr img = NULL; 1741 - struct grid_codec_data *grid_codec = NULL; 1742 - long file_length; 1743 - int expected_length; 1744 - int width; 1745 - int height; 1746 - double ulx; 1747 - double uly; 1748 - double pixel_x_size; 1749 - double pixel_y_size; 1750 - int sample; 1751 - int bits_per_sample; 1752 - int endian; 1753 - double no_data; 1754 - int buf_size; 1755 - void *grid_buffer = NULL; 1756 - int ret = GGRAPH_DEM_CODEC_ERROR; 1757 - *image_handle = NULL; 1758 - 1759 - if (!parse_dem_hdr 1760 - (hdr_path, &width, &height, &bits_per_sample, &sample, &endian, 1761 - &no_data, &ulx, &uly, &pixel_x_size, &pixel_y_size, &expected_length)) 1762 - return GGRAPH_DEM_CODEC_ERROR; 1763 - 1764 -/* retrieving the DEM dimensions */ 1765 - if (fseek (in, 0, SEEK_END) != 0) 1766 - return GGRAPH_DEM_CODEC_ERROR; 1767 - file_length = ftell (in); 1768 - if (file_length != expected_length) 1769 - return GGRAPH_DEM_CODEC_ERROR; 1770 - 1771 - img = 1772 - gg_strip_image_create (in, GGRAPH_IMAGE_DEM_HDR, GG_PIXEL_GRID, width, 1773 - height, bits_per_sample, 1, sample, NULL, NULL); 1774 - if (!img) 1775 - { 1776 - ret = GGRAPH_INSUFFICIENT_MEMORY; 1777 - goto error; 1778 - } 1779 - 1780 -/* setting up georeferencing infos */ 1781 - img->is_georeferenced = 1; 1782 - img->upper_left_x = ulx; 1783 - img->upper_left_y = uly; 1784 - img->pixel_x_size = pixel_x_size; 1785 - img->pixel_y_size = pixel_y_size; 1786 - img->no_data_value = no_data; 1787 - 1788 -/* setting up the GRID codec struct */ 1789 - grid_codec = malloc (sizeof (struct grid_codec_data)); 1790 - if (!grid_codec) 1791 - goto error; 1792 - grid_codec->grid_type = GRID_DEM_HDR; 1793 - grid_codec->is_writer = 0; 1794 - grid_codec->grid_buffer = NULL; 1795 - grid_codec->row_offsets = NULL; 1796 - grid_codec->little_endian = endian; 1797 - img->codec_data = grid_codec; 1798 - 1799 -/* allocating the GRID read buffer */ 1800 - if (bits_per_sample == 16) 1801 - buf_size = sizeof (short) * width; 1802 - if (bits_per_sample == 32) 1803 - buf_size = sizeof (int) * width; 1804 - grid_buffer = malloc (buf_size); 1805 - if (!grid_buffer) 1806 - goto error; 1807 - grid_codec->grid_buffer = grid_buffer; 1808 - 1809 - *image_handle = img; 1810 - return GGRAPH_OK; 1811 - 1812 - error: 1813 - if (img) 1814 - gGraphDestroyImage (img); 1815 - return ret; 1816 -} 1817 - 1818 -static int 1819 -parse_asc_offsets (FILE * in, int height, long **row_offsets) 1820 -{ 1821 -/* retrieving row-offsets from an ASC file [ASCII GRID format] */ 1822 - int c; 1823 - int row = 0; 1824 - int ind = 0; 1825 - long *offsets = *row_offsets; 1826 - long current = 0; 1827 - 1828 - rewind (in); 1829 - while ((c = getc (in)) != EOF) 1830 - { 1831 - /* parsing the Header file */ 1832 - if (c == '\n') 1833 - { 1834 - row++; 1835 - if (row >= 6) 1836 - { 1837 - if (ind < height) 1838 - *(offsets + ind) = current; 1839 - ind++; 1840 - } 1841 - } 1842 - current++; 1843 - } 1844 - if (ind != height + 1) 1845 - return 0; 1846 - return 1; 1847 -} 1848 - 1849 -GGRAPH_PRIVATE int 1850 -gg_image_strip_prepare_from_ascii_grid (FILE * in, 1851 - gGraphStripImagePtr * image_handle) 1852 -{ 1853 -/* preparing to decode an ASCII-GRID [by strips] */ 1854 - gGraphStripImagePtr img = NULL; 1855 - struct grid_codec_data *grid_codec = NULL; 1856 - int width; 1857 - int height; 1858 - double ulx; 1859 - double uly; 1860 - double pixel_x_size; 1861 - double pixel_y_size; 1862 - double no_data; 1863 - long *row_offsets = NULL; 1864 - int ret = GGRAPH_ASCII_CODEC_ERROR; 1865 - *image_handle = NULL; 1866 - 1867 - if (!parse_asc_hdr 1868 - (NULL, in, &width, &height, &ulx, &uly, &pixel_x_size, &pixel_y_size, 1869 - &no_data)) 1870 - return GGRAPH_ASCII_CODEC_ERROR; 1871 - 1872 -/* preparing the row-offset array */ 1873 - row_offsets = malloc (sizeof (long) * height); 1874 - if (!row_offsets) 1875 - return GGRAPH_ASCII_CODEC_ERROR; 1876 - if (!parse_asc_offsets (in, height, &row_offsets)) 1877 - { 1878 - free (row_offsets); 1879 - return GGRAPH_ASCII_CODEC_ERROR; 1880 - } 1881 - 1882 - img = 1883 - gg_strip_image_create (in, GGRAPH_IMAGE_ASCII_GRID, GG_PIXEL_GRID, 1884 - width, height, 32, 1, GGRAPH_SAMPLE_FLOAT, NULL, 1885 - NULL); 1886 - if (!img) 1887 - { 1888 - ret = GGRAPH_INSUFFICIENT_MEMORY; 1889 - goto error; 1890 - } 1891 - 1892 -/* setting up georeferencing infos */ 1893 - img->is_georeferenced = 1; 1894 - img->upper_left_x = ulx; 1895 - img->upper_left_y = uly; 1896 - img->pixel_x_size = pixel_x_size; 1897 - img->pixel_y_size = pixel_y_size; 1898 - img->no_data_value = no_data; 1899 - 1900 -/* setting up the GRID codec struct */ 1901 - grid_codec = malloc (sizeof (struct grid_codec_data)); 1902 - if (!grid_codec) 1903 - goto error; 1904 - grid_codec->grid_type = GRID_ASCII; 1905 - grid_codec->is_writer = 0; 1906 - grid_codec->grid_buffer = NULL; 1907 - grid_codec->row_offsets = row_offsets; 1908 - img->codec_data = grid_codec; 1909 - 1910 - *image_handle = img; 1911 - return GGRAPH_OK; 1912 - 1913 - error: 1914 - if (img) 1915 - gGraphDestroyImage (img); 1916 - return ret; 1917 -} 1918 - 1919 -static int 1920 -read_from_bin_grid (FILE * in, gGraphStripImagePtr img, int sample, 1921 - int bits_per_pixel, int type, void *scanline, int endian) 1922 -{ 1923 -/* decoding a BIN-GRID or a FLT-GRID [by strip] */ 1924 - int width = img->width; 1925 - int height = img->height; 1926 - size_t scan_size; 1927 - int row; 1928 - int incr = 0; 1929 - int x; 1930 - int endian_arch = gg_endian_arch (); 1931 - off_t pos; 1932 - unsigned char *p_in; 1933 - short *p_out_short; 1934 - short cell_value_short; 1935 - int *p_out_int; 1936 - int cell_value_int; 1937 - float *p_out_float; 1938 - float cell_value_float; 1939 - double *p_out_double; 1940 - double cell_value_double; 1941 - 1942 - if (bits_per_pixel == 16) 1943 - scan_size = width * 2; 1944 - if (bits_per_pixel == 32) 1945 - scan_size = width * 4; 1946 - if (bits_per_pixel == 64) 1947 - scan_size = width * 8; 1948 - pos = img->next_row * scan_size; 1949 -/* positioning on the start scanline */ 1950 - if (fseek (in, pos, SEEK_SET) != 0) 1951 - { 1952 - if (type == GRID_BIN_HDR) 1953 - return GGRAPH_BIN_CODEC_ERROR; 1954 - if (type == GRID_FLT_HDR) 1955 - return GGRAPH_FLT_CODEC_ERROR; 1956 - if (type == GRID_DEM_HDR) 1957 - return GGRAPH_DEM_CODEC_ERROR; 1958 - } 1959 - for (row = 0; row < img->rows_per_block; row++) 1960 - { 1961 - /* reading the required number of scanlines */ 1962 - if ((row + img->next_row) >= height) 1963 - break; 1964 - if (fread (scanline, 1, scan_size, in) != scan_size) 1965 - return GGRAPH_HGT_CODEC_ERROR; 1966 - p_in = scanline; 1967 - if (sample == GGRAPH_SAMPLE_INT) 1968 - { 1969 - if (bits_per_pixel == 16) 1970 - { 1971 - p_out_short = (short *) (img->pixels); 1972 - p_out_short += (row * width); 1973 - } 1974 - 1975 - if (bits_per_pixel == 32) 1976 - { 1977 - p_out_int = (int *) (img->pixels); 1978 - p_out_int += (row * width); 1979 - } 1980 - } 1981 - if (sample == GGRAPH_SAMPLE_FLOAT) 1982 - { 1983 - if (bits_per_pixel == 32) 1984 - { 1985 - p_out_float = (float *) (img->pixels); 1986 - p_out_float += (row * width); 1987 - } 1988 - 1989 - if (bits_per_pixel == 64) 1990 - { 1991 - p_out_double = (double *) (img->pixels); 1992 - p_out_double += (row * width); 1993 - } 1994 - } 1995 - for (x = 0; x < width; x++) 1996 - { 1997 - if (sample == GGRAPH_SAMPLE_INT) 1998 - { 1999 - if (bits_per_pixel == 16) 2000 - { 2001 - cell_value_short = 2002 - gg_import_int16 (p_in, endian, endian_arch); 2003 - *p_out_short++ = cell_value_short; 2004 - p_in += sizeof (short); 2005 - } 2006 - if (bits_per_pixel == 32) 2007 - { 2008 - cell_value_int = 2009 - gg_import_int32 (p_in, endian, endian_arch); 2010 - *p_out_int++ = cell_value_int; 2011 - p_in += sizeof (int); 2012 - } 2013 - } 2014 - if (sample == GGRAPH_SAMPLE_FLOAT) 2015 - { 2016 - if (bits_per_pixel == 32) 2017 - { 2018 - cell_value_float = 2019 - gg_import_float (p_in, endian, endian_arch); 2020 - *p_out_float++ = cell_value_float; 2021 - p_in += sizeof (float); 2022 - } 2023 - if (bits_per_pixel == 64) 2024 - { 2025 - cell_value_double = 2026 - gg_import_double (p_in, endian, endian_arch); 2027 - *p_out_double++ = cell_value_double; 2028 - p_in += sizeof (double); 2029 - } 2030 - } 2031 - } 2032 - incr++; 2033 - } 2034 - img->next_row += incr; 2035 - img->current_available_rows = incr; 2036 - return GGRAPH_OK; 2037 -} 2038 - 2039 -GGRAPH_PRIVATE int 2040 -gg_image_strip_read_from_bin_grid (gGraphStripImagePtr img, int *progress) 2041 -{ 2042 -/* decoding a BIN-GRID or a FLT-GRID [by strip] */ 2043 - struct grid_codec_data *grid_codec = 2044 - (struct grid_codec_data *) (img->codec_data); 2045 - FILE *in = img->file_handle; 2046 - 2047 - if (grid_codec->grid_type == GRID_BIN_HDR 2048 - || grid_codec->grid_type == GRID_FLT_HDR) 2049 - { 2050 - int ret = read_from_bin_grid (in, img, img->sample_format, 2051 - img->bits_per_sample, 2052 - grid_codec->grid_type, 2053 - grid_codec->grid_buffer, 2054 - grid_codec->little_endian); 2055 - if (ret == GGRAPH_OK && progress != NULL) 2056 - *progress = 2057 - (int) (((double) (img->next_row + 1) * 100.0) / 2058 - (double) (img->height)); 2059 - return ret; 2060 - } 2061 - return GGRAPH_ERROR; 2062 -} 2063 - 2064 -GGRAPH_PRIVATE int 2065 -gg_image_strip_read_from_dem_grid (gGraphStripImagePtr img, int *progress) 2066 -{ 2067 -/* decoding a DEM-GRID [by strip] */ 2068 - struct grid_codec_data *grid_codec = 2069 - (struct grid_codec_data *) (img->codec_data); 2070 - FILE *in = img->file_handle; 2071 - 2072 - if (grid_codec->grid_type == GRID_DEM_HDR) 2073 - { 2074 - int ret = read_from_bin_grid (in, img, img->sample_format, 2075 - img->bits_per_sample, 2076 - grid_codec->grid_type, 2077 - grid_codec->grid_buffer, 2078 - grid_codec->little_endian); 2079 - if (ret == GGRAPH_OK && progress != NULL) 2080 - *progress = 2081 - (int) (((double) (img->next_row + 1) * 100.0) / 2082 - (double) (img->height)); 2083 - return ret; 2084 - } 2085 - return GGRAPH_ERROR; 2086 -} 2087 - 2088 -static int 2089 -read_from_ascii_grid (FILE * in, gGraphStripImagePtr img, long *row_offsets) 2090 -{ 2091 -/* decoding an ASCII-GRID [by strip] */ 2092 - int width = img->width; 2093 - int height = img->height; 2094 - int row; 2095 - int incr = 0; 2096 - int col; 2097 - int c; 2098 - float *p_out; 2099 - float cell_value; 2100 - char buf[256]; 2101 - char *p; 2102 - 2103 -/* positioning on the start scanline */ 2104 - if (fseek (in, row_offsets[img->next_row], SEEK_SET) != 0) 2105 - return GGRAPH_ASCII_CODEC_ERROR; 2106 - if (getc (in) != '\n') 2107 - return GGRAPH_ASCII_CODEC_ERROR; 2108 - 2109 - for (row = 0; row < img->rows_per_block; row++) 2110 - { 2111 - /* reading the required number of scanlines */ 2112 - if ((row + img->next_row) >= height) 2113 - break; 2114 - p_out = (float *) (img->pixels); 2115 - p_out += row * width; 2116 - p = buf; 2117 - col = 0; 2118 - while ((c = getc (in)) != EOF) 2119 - { 2120 - /* parsing cell values */ 2121 - if (c == '\r') 2122 - continue; 2123 - if (c == '\n') 2124 - break; 2125 - if (c == ' ') 2126 - { 2127 - /* cell end */ 2128 - *p = '\0'; 2129 - cell_value = atof (buf); 2130 - if (col >= width) 2131 - return GGRAPH_ASCII_CODEC_ERROR; 2132 - *p_out++ = cell_value; 2133 - col++; 2134 - p = buf; 2135 - continue; 2136 - } 2137 - if ((p - buf) >= 256) 2138 - return GGRAPH_ASCII_CODEC_ERROR; 2139 - *p++ = c; 2140 - } 2141 - if (col != width) 2142 - return GGRAPH_ASCII_CODEC_ERROR; 2143 - incr++; 2144 - } 2145 - img->next_row += incr; 2146 - img->current_available_rows = incr; 2147 - return GGRAPH_OK; 2148 -} 2149 - 2150 -GGRAPH_PRIVATE int 2151 -gg_image_strip_read_from_ascii_grid (gGraphStripImagePtr img, int *progress) 2152 -{ 2153 -/* decoding an ASCII-GRID [by strip] */ 2154 - struct grid_codec_data *grid_codec = 2155 - (struct grid_codec_data *) (img->codec_data); 2156 - FILE *in = img->file_handle; 2157 - 2158 - if (grid_codec->grid_type == GRID_ASCII) 2159 - { 2160 - int ret = read_from_ascii_grid (in, img, grid_codec->row_offsets); 2161 - if (ret == GGRAPH_OK && progress != NULL) 2162 - *progress = 2163 - (int) (((double) (img->next_row + 1) * 100.0) / 2164 - (double) (img->height)); 2165 - return ret; 2166 - } 2167 - return GGRAPH_ERROR; 2168 -} 2169 - 2170 -GGRAPH_PRIVATE int 2171 -gg_image_prepare_to_ascii_grid_by_strip (const gGraphStripImagePtr img, 2172 - FILE * out) 2173 -{ 2174 -/* preparing to export an ASCII GRID [by strips] */ 2175 - char dummy[256]; 2176 - 2177 - fprintf (out, "ncols %d\r\n", img->width); 2178 - fprintf (out, "nrows %d\r\n", img->height); 2179 - gGraphSmartPrintf (img->upper_left_x, dummy); 2180 - fprintf (out, "xllcorner %s\r\n", dummy); 2181 - gGraphSmartPrintf (img->upper_left_y - 2182 - ((double) (img->height) * img->pixel_y_size), dummy); 2183 - fprintf (out, "yllcorner %s\r\n", dummy); 2184 - gGraphSmartPrintf (img->pixel_y_size, dummy); 2185 - fprintf (out, "cellsize %s\r\n", dummy); 2186 - gGraphSmartPrintf (img->no_data_value, dummy); 2187 - fprintf (out, "NODATA_value %s\r\n", dummy); 2188 - 2189 - return GGRAPH_OK; 2190 -} 2191 - 2192 -GGRAPH_PRIVATE int 2193 -gg_image_write_to_ascii_grid_by_strip (const gGraphStripImagePtr img, 2194 - int *progress) 2195 -{ 2196 -/* scanline(s) ASCII GRID export [by strip] */ 2197 - FILE *out = img->file_handle; 2198 - int row; 2199 - int col; 2200 - char *p_in_int8; 2201 - unsigned char *p_in_uint8; 2202 - short *p_in_int16; 2203 - unsigned short *p_in_uint16; 2204 - int *p_in_int32; 2205 - unsigned int *p_in_uint32; 2206 - float *p_in_flt; 2207 - double *p_in_dbl; 2208 - char dummy[256]; 2209 - 2210 - for (row = 0; row < img->current_available_rows; row++) 2211 - { 2212 - switch (img->sample_format) 2213 - { 2214 - case GGRAPH_SAMPLE_UINT: 2215 - switch (img->bits_per_sample) 2216 - { 2217 - case 8: 2218 - p_in_uint8 = (unsigned char *) (img->pixels); 2219 - p_in_uint8 += row * img->width; 2220 - break; 2221 - case 16: 2222 - p_in_uint16 = (unsigned short *) (img->pixels); 2223 - p_in_uint16 += row * img->width; 2224 - break; 2225 - case 32: 2226 - p_in_uint32 = (unsigned int *) (img->pixels); 2227 - p_in_uint32 += row * img->width; 2228 - break; 2229 - }; 2230 - break; 2231 - case GGRAPH_SAMPLE_INT: 2232 - switch (img->bits_per_sample) 2233 - { 2234 - case 8: 2235 - p_in_int8 = (char *) (img->pixels); 2236 - p_in_int8 += row * img->width; 2237 - break; 2238 - case 16: 2239 - p_in_int16 = (short *) (img->pixels); 2240 - p_in_int16 += row * img->width; 2241 - break; 2242 - case 32: 2243 - p_in_int32 = (int *) (img->pixels); 2244 - p_in_int32 += row * img->width; 2245 - break; 2246 - }; 2247 - break; 2248 - case GGRAPH_SAMPLE_FLOAT: 2249 - switch (img->bits_per_sample) 2250 - { 2251 - case 32: 2252 - p_in_flt = (float *) (img->pixels); 2253 - p_in_flt += row * img->width; 2254 - break; 2255 - case 64: 2256 - p_in_dbl = (double *) (img->pixels); 2257 - p_in_dbl += row * img->width; 2258 - break; 2259 - }; 2260 - break; 2261 - }; 2262 - for (col = 0; col < img->width; col++) 2263 - { 2264 - switch (img->sample_format) 2265 - { 2266 - case GGRAPH_SAMPLE_UINT: 2267 - switch (img->bits_per_sample) 2268 - { 2269 - case 8: 2270 - sprintf (dummy, "%u", *p_in_uint8++); 2271 - break; 2272 - case 16: 2273 - sprintf (dummy, "%u", *p_in_uint16++); 2274 - break; 2275 - case 32: 2276 - sprintf (dummy, "%u", *p_in_uint32++); 2277 - break; 2278 - }; 2279 - break; 2280 - case GGRAPH_SAMPLE_INT: 2281 - switch (img->bits_per_sample) 2282 - { 2283 - case 8: 2284 - sprintf (dummy, "%d", *p_in_int8++); 2285 - break; 2286 - case 16: 2287 - sprintf (dummy, "%d", *p_in_int16++); 2288 - break; 2289 - case 32: 2290 - sprintf (dummy, "%d", *p_in_int32++); 2291 - break; 2292 - }; 2293 - break; 2294 - case GGRAPH_SAMPLE_FLOAT: 2295 - switch (img->bits_per_sample) 2296 - { 2297 - case 32: 2298 - gGraphSmartPrintf (*p_in_flt++, dummy); 2299 - break; 2300 - case 64: 2301 - gGraphSmartPrintf (*p_in_dbl++, dummy); 2302 - break; 2303 - }; 2304 - break; 2305 - }; 2306 - fprintf (out, "%s ", dummy); 2307 - } 2308 - /* terminating a full scanline */ 2309 - fprintf (out, "\r\n"); 2310 - } 2311 - img->next_row += img->current_available_rows; 2312 - 2313 - if (progress != NULL) 2314 - *progress = 2315 - (int) (((double) (img->next_row + 1) * 100.0) / 2316 - (double) (img->height)); 2317 - return GGRAPH_OK; 2318 -} 2319 - 2320 -GGRAPH_PRIVATE int 2321 -gg_image_prepare_to_bin_hdr_by_strip (const gGraphStripImagePtr img) 2322 -{ 2323 -/* preparing to export a BIN+HDR GRID [by strips] */ 2324 - struct grid_codec_data *grid_codec = NULL; 2325 - int buf_size; 2326 - void *grid_buffer = NULL; 2327 - 2328 - if (img->sample_format != GGRAPH_SAMPLE_INT) 2329 - return GGRAPH_BIN_CODEC_ERROR; 2330 - if (img->bits_per_sample == 16 || img->bits_per_sample == 32) 2331 - ; 2332 - else 2333 - return GGRAPH_BIN_CODEC_ERROR; 2334 - 2335 -/* setting up the GRID codec struct */ 2336 - grid_codec = malloc (sizeof (struct grid_codec_data)); 2337 - if (!grid_codec) 2338 - return GGRAPH_BIN_CODEC_ERROR; 2339 - grid_codec->grid_type = GRID_BIN_HDR; 2340 - grid_codec->is_writer = 1; 2341 - grid_codec->grid_buffer = NULL; 2342 - grid_codec->row_offsets = NULL; 2343 - 2344 -/* allocating the GRID read buffer */ 2345 - if (img->bits_per_sample == 16) 2346 - buf_size = sizeof (short) * img->width; 2347 - else 2348 - buf_size = sizeof (int) * img->width; 2349 - grid_buffer = malloc (buf_size); 2350 - if (!grid_buffer) 2351 - { 2352 - free (grid_codec); 2353 - return GGRAPH_BIN_CODEC_ERROR; 2354 - } 2355 - grid_codec->grid_buffer = grid_buffer; 2356 - img->codec_data = grid_codec; 2357 - 2358 - return GGRAPH_OK; 2359 -} 2360 - 2361 -GGRAPH_PRIVATE int 2362 -gg_image_prepare_to_flt_hdr_by_strip (const gGraphStripImagePtr img) 2363 -{ 2364 -/* preparing to export a FLT+HDR GRID [by strips] */ 2365 - struct grid_codec_data *grid_codec = NULL; 2366 - int buf_size; 2367 - void *grid_buffer = NULL; 2368 - 2369 - if (img->sample_format != GGRAPH_SAMPLE_FLOAT) 2370 - return GGRAPH_FLT_CODEC_ERROR; 2371 - if (img->bits_per_sample == 32 || img->bits_per_sample == 64) 2372 - ; 2373 - else 2374 - return GGRAPH_FLT_CODEC_ERROR; 2375 - 2376 -/* setting up the GRID codec struct */ 2377 - grid_codec = malloc (sizeof (struct grid_codec_data)); 2378 - if (!grid_codec) 2379 - return GGRAPH_FLT_CODEC_ERROR; 2380 - grid_codec->grid_type = GRID_FLT_HDR; 2381 - grid_codec->is_writer = 1; 2382 - grid_codec->grid_buffer = NULL; 2383 - grid_codec->row_offsets = NULL; 2384 - 2385 -/* allocating the GRID read buffer */ 2386 - if (img->bits_per_sample == 32) 2387 - buf_size = sizeof (float) * img->width; 2388 - else 2389 - buf_size = sizeof (double) * img->width; 2390 - grid_buffer = malloc (buf_size); 2391 - if (!grid_buffer) 2392 - { 2393 - free (grid_codec); 2394 - return GGRAPH_FLT_CODEC_ERROR; 2395 - } 2396 - grid_codec->grid_buffer = grid_buffer; 2397 - img->codec_data = grid_codec; 2398 - 2399 - return GGRAPH_OK; 2400 -} 2401 - 2402 -GGRAPH_PRIVATE int 2403 -gg_image_write_to_bin_hdr_by_strip (const gGraphStripImagePtr img, 2404 - int *progress) 2405 -{ 2406 -/* scanline(s) BIN+HDR GRID export [by strip] */ 2407 - FILE *out = img->file_handle; 2408 - struct grid_codec_data *grid_codec = 2409 - (struct grid_codec_data *) (img->codec_data); 2410 - int row; 2411 - int col; 2412 - short *p_in_int16; 2413 - int *p_in_int32; 2414 - unsigned char *p_out; 2415 - size_t sz; 2416 - int endian_arch = gg_endian_arch (); 2417 - 2418 - for (row = 0; row < img->current_available_rows; row++) 2419 - { 2420 - switch (img->bits_per_sample) 2421 - { 2422 - case 16: 2423 - p_in_int16 = (short *) (img->pixels); 2424 - p_in_int16 += row * img->width; 2425 - sz = img->width * sizeof (short); 2426 - break; 2427 - case 32: 2428 - p_in_int32 = (int *) (img->pixels); 2429 - p_in_int32 += row * img->width; 2430 - sz = img->width * sizeof (int); 2431 - break; 2432 - }; 2433 - p_out = grid_codec->grid_buffer; 2434 - 2435 - for (col = 0; col < img->width; col++) 2436 - { 2437 - switch (img->bits_per_sample) 2438 - { 2439 - case 16: 2440 - if (*p_in_int16 < img->min_value) 2441 - img->min_value = *p_in_int16; 2442 - if (*p_in_int16 > img->max_value) 2443 - img->max_value = *p_in_int16; 2444 - gg_export_int16 (*p_in_int16++, p_out, 1, endian_arch); 2445 - p_out += sizeof (short); 2446 - break; 2447 - case 32: 2448 - if (*p_in_int32 < img->min_value) 2449 - img->min_value = *p_in_int32; 2450 - if (*p_in_int32 > img->max_value) 2451 - img->max_value = *p_in_int32; 2452 - gg_export_int32 (*p_in_int32++, p_out, 1, endian_arch); 2453 - p_out += sizeof (int); 2454 - break; 2455 - }; 2456 - } 2457 - /* terminating a full scanline */ 2458 - if (fwrite (grid_codec->grid_buffer, 1, sz, out) != sz) 2459 - return GGRAPH_BIN_CODEC_ERROR; 2460 - } 2461 - img->next_row += img->current_available_rows; 2462 - 2463 - if (progress != NULL) 2464 - *progress = 2465 - (int) (((double) (img->next_row + 1) * 100.0) / 2466 - (double) (img->height)); 2467 - return GGRAPH_OK; 2468 -} 2469 - 2470 -GGRAPH_PRIVATE int 2471 -gg_image_write_to_flt_hdr_by_strip (const gGraphStripImagePtr img, 2472 - int *progress) 2473 -{ 2474 -/* scanline(s) FLT+HDR GRID export [by strip] */ 2475 - FILE *out = img->file_handle; 2476 - struct grid_codec_data *grid_codec = 2477 - (struct grid_codec_data *) (img->codec_data); 2478 - int row; 2479 - int col; 2480 - float *p_in_float; 2481 - double *p_in_double; 2482 - unsigned char *p_out; 2483 - size_t sz; 2484 - int endian_arch = gg_endian_arch (); 2485 - 2486 - for (row = 0; row < img->current_available_rows; row++) 2487 - { 2488 - switch (img->bits_per_sample) 2489 - { 2490 - case 32: 2491 - p_in_float = (float *) (img->pixels); 2492 - p_in_float += row * img->width; 2493 - sz = img->width * sizeof (float); 2494 - break; 2495 - case 64: 2496 - p_in_double = (double *) (img->pixels); 2497 - p_in_double += row * img->width; 2498 - sz = img->width * sizeof (double); 2499 - break; 2500 - }; 2501 - p_out = grid_codec->grid_buffer; 2502 - 2503 - for (col = 0; col < img->width; col++) 2504 - { 2505 - switch (img->bits_per_sample) 2506 - { 2507 - case 32: 2508 - if (*p_in_float < img->min_value) 2509 - img->min_value = *p_in_float; 2510 - if (*p_in_float > img->max_value) 2511 - img->max_value = *p_in_float; 2512 - gg_export_float (*p_in_float++, p_out, 1, endian_arch); 2513 - p_out += sizeof (float); 2514 - break; 2515 - case 64: 2516 - if (*p_in_double < img->min_value) 2517 - img->min_value = *p_in_double; 2518 - if (*p_in_double > img->max_value) 2519 - img->max_value = *p_in_double; 2520 - gg_export_double (*p_in_double++, p_out, 1, endian_arch); 2521 - p_out += sizeof (float); 2522 - break; 2523 - }; 2524 - } 2525 - /* terminating a full scanline */ 2526 - if (fwrite (grid_codec->grid_buffer, 1, sz, out) != sz) 2527 - return GGRAPH_FLT_CODEC_ERROR; 2528 - } 2529 - img->next_row += img->current_available_rows; 2530 - 2531 - if (progress != NULL) 2532 - *progress = 2533 - (int) (((double) (img->next_row + 1) * 100.0) / 2534 - (double) (img->height)); 2535 - return GGRAPH_OK; 2536 -} 2537 - 2538 -GGRAPH_DECLARE int 2539 -gGraphWriteBinHeader (const char *hdr_path, const void *ptr) 2540 -{ 2541 -/* exporting a BIN Header file */ 2542 - FILE *out = NULL; 2543 - char dummy[256]; 2544 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2545 - 2546 - if (img == NULL) 2547 - return GGRAPH_INVALID_IMAGE; 2548 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2549 - return GGRAPH_INVALID_IMAGE; 2550 - 2551 -/* attempting to open/create the header file */ 2552 - out = fopen (hdr_path, "wb"); 2553 - if (out == NULL) 2554 - return GGRAPH_FILE_OPEN_ERROR; 2555 - 2556 - fprintf (out, "NCOLS %d\r\n", img->width); 2557 - fprintf (out, "NROWS %d\r\n", img->height); 2558 - gGraphSmartPrintf (img->upper_left_x, dummy); 2559 - fprintf (out, "XLLCORNER %s\r\n", dummy); 2560 - gGraphSmartPrintf (img->upper_left_y - 2561 - ((double) (img->height) * img->pixel_y_size), dummy); 2562 - fprintf (out, "YLLCORNER %s\r\n", dummy); 2563 - gGraphSmartPrintf (img->pixel_y_size, dummy); 2564 - fprintf (out, "CELLSIZE %s\r\n", dummy); 2565 - gGraphSmartPrintf (img->no_data_value, dummy); 2566 - fprintf (out, "NODATA_VALUE %s\r\n", dummy); 2567 - fprintf (out, "BYTEORDER LSBFIRST\r\n"); 2568 - if (img->bits_per_sample == 16) 2569 - fprintf (out, "NUMBERTYPE 2_BYTE_INTEGER\r\n"); 2570 - else 2571 - fprintf (out, "NUMBERTYPE 4_BYTE_INTEGER\r\n"); 2572 - fprintf (out, "ZUNITS METERS\r\n"); 2573 - gGraphSmartPrintf (img->min_value, dummy); 2574 - fprintf (out, "MIN_VALUE %s\r\n", dummy); 2575 - gGraphSmartPrintf (img->max_value, dummy); 2576 - fprintf (out, "MAX_VALUE %s\r\n", dummy); 2577 - 2578 - fclose (out); 2579 - 2580 - return GGRAPH_OK; 2581 -} 2582 - 2583 -GGRAPH_DECLARE int 2584 -gGraphWriteFltHeader (const char *hdr_path, const void *ptr) 2585 -{ 2586 -/* exporting a FLT Header file */ 2587 - FILE *out = NULL; 2588 - char dummy[256]; 2589 - gGraphStripImagePtr img = (gGraphStripImagePtr) ptr; 2590 - 2591 - if (img == NULL) 2592 - return GGRAPH_INVALID_IMAGE; 2593 - if (img->signature != GG_STRIP_IMAGE_MAGIC_SIGNATURE) 2594 - return GGRAPH_INVALID_IMAGE; 2595 - 2596 -/* attempting to open/create the header file */ 2597 - out = fopen (hdr_path, "wb"); 2598 - if (out == NULL) 2599 - return GGRAPH_FILE_OPEN_ERROR; 2600 - 2601 - fprintf (out, "ncols %d\r\n", img->width); 2602 - fprintf (out, "nrows %d\r\n", img->height); 2603 - gGraphSmartPrintf (img->upper_left_x, dummy); 2604 - fprintf (out, "xllcorner %s\r\n", dummy); 2605 - gGraphSmartPrintf (img->upper_left_y - 2606 - ((double) (img->height) * img->pixel_y_size), dummy); 2607 - fprintf (out, "yllcorner %s\r\n", dummy); 2608 - gGraphSmartPrintf (img->pixel_y_size, dummy); 2609 - fprintf (out, "cellsize %s\r\n", dummy); 2610 - gGraphSmartPrintf (img->no_data_value, dummy); 2611 - fprintf (out, "NODATA_value %s\r\n", dummy); 2612 - fprintf (out, "byteorder LSBFIRST\r\n"); 2613 - if (img->bits_per_sample == 32) 2614 - fprintf (out, "NUMBERTYPE 4_BYTE_FLOAT\r\n"); 2615 - else 2616 - fprintf (out, "NUMBERTYPE 8_BYTE_FLOAT\r\n"); 2617 - gGraphSmartPrintf (img->min_value, dummy); 2618 - fprintf (out, "MIN_VALUE %s\r\n", dummy); 2619 - gGraphSmartPrintf (img->max_value, dummy); 2620 - fprintf (out, "MAX_VALUE %s\r\n", dummy); 2621 - 2622 - fclose (out); 2623 - 2624 - return GGRAPH_OK; 2625 -}
Deleted src/gaiagraphics_image.c.
1 -/* 2 -/ gaiagraphics_image.c 3 -/ 4 -/ image methods 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdio.h> 28 -#include <stdlib.h> 29 -#include <string.h> 30 -#include <float.h> 31 -#include <math.h> 32 -#include <limits.h> 33 - 34 -#include "gaiagraphics.h" 35 -#include "gaiagraphics_internals.h" 36 - 37 -GGRAPH_PRIVATE gGraphImageInfosPtr 38 -gg_image_infos_create (int pixel_format, int width, int height, 39 - int bits_per_sample, int samples_per_pixel, 40 - int sample_format, const char *srs_name, 41 - const char *proj4text) 42 -{ 43 -/* creating an image infos struct */ 44 - gGraphImageInfosPtr img; 45 - int len; 46 - char *SrsName = NULL; 47 - char *Proj4Text = NULL; 48 - 49 -/* checking PIXEL_FORMAT */ 50 - if (pixel_format == GG_PIXEL_RGB || pixel_format == GG_PIXEL_RGBA 51 - || pixel_format == GG_PIXEL_ARGB || pixel_format == GG_PIXEL_BGR 52 - || pixel_format == GG_PIXEL_GRAYSCALE 53 - || pixel_format == GG_PIXEL_PALETTE || pixel_format == GG_PIXEL_GRID 54 - || pixel_format == GG_PIXEL_UNKNOWN) 55 - ; 56 - else 57 - return NULL; 58 - 59 - if (srs_name) 60 - { 61 - len = strlen (srs_name); 62 - SrsName = malloc (len + 1); 63 - if (!SrsName) 64 - return NULL; 65 - strcpy (SrsName, srs_name); 66 - } 67 - if (proj4text) 68 - { 69 - len = strlen (proj4text); 70 - Proj4Text = malloc (len + 1); 71 - if (!Proj4Text) 72 - { 73 - if (SrsName) 74 - free (SrsName); 75 - return NULL; 76 - } 77 - strcpy (Proj4Text, proj4text); 78 - } 79 - 80 -/* allocating the image INFOS struct */ 81 - img = malloc (sizeof (gGraphImage)); 82 - if (!img) 83 - return NULL; 84 - 85 - img->signature = GG_IMAGE_INFOS_MAGIC_SIGNATURE; 86 - img->width = width; 87 - img->height = height; 88 - img->bits_per_sample = bits_per_sample; 89 - img->samples_per_pixel = samples_per_pixel; 90 - img->sample_format = sample_format; 91 - img->pixel_format = pixel_format; 92 - img->max_palette = 0; 93 - img->is_transparent = 0; 94 - img->tile_width = -1; 95 - img->tile_height = -1; 96 - img->rows_per_strip = -1; 97 - img->compression = GGRAPH_TIFF_COMPRESSION_NONE; 98 - img->scale_1_2 = 0; 99 - img->scale_1_4 = 0; 100 - img->scale_1_8 = 0; 101 - img->is_georeferenced = 0; 102 - img->srid = -1; 103 - img->srs_name = SrsName; 104 - img->proj4text = Proj4Text; 105 - img->upper_left_x = DBL_MAX; 106 - img->upper_left_y = DBL_MAX; 107 - img->pixel_x_size = 0.0; 108 - img->pixel_y_size = 0.0; 109 - img->no_data_value = 0.0 - DBL_MAX; 110 - img->min_value = DBL_MAX; 111 - img->max_value = 0.0 - DBL_MAX; 112 - 113 - return img; 114 -} 115 - 116 -GGRAPH_PRIVATE void 117 -gg_image_infos_destroy (gGraphImageInfosPtr img) 118 -{ 119 -/* destroying an image INFOS struct */ 120 - if (!img) 121 - return; 122 - if (img->srs_name) 123 - free (img->srs_name); 124 - if (img->proj4text) 125 - free (img->proj4text); 126 - free (img); 127 -} 128 - 129 -GGRAPH_PRIVATE gGraphImagePtr 130 -gg_image_create (int pixel_format, int width, int height, int bits_per_sample, 131 - int samples_per_pixel, int sample_format, const char *srs_name, 132 - const char *proj4text) 133 -{ 134 -/* creating a generic image */ 135 - gGraphImagePtr img; 136 - int len; 137 - char *SrsName = NULL; 138 - char *Proj4Text = NULL; 139 - 140 -/* checking PIXEL_FORMAT */ 141 - if (pixel_format == GG_PIXEL_RGB || pixel_format == GG_PIXEL_RGBA 142 - || pixel_format == GG_PIXEL_ARGB || pixel_format == GG_PIXEL_BGR 143 - || pixel_format == GG_PIXEL_GRAYSCALE 144 - || pixel_format == GG_PIXEL_PALETTE || pixel_format == GG_PIXEL_GRID) 145 - ; 146 - else 147 - return NULL; 148 - if (sample_format == GGRAPH_SAMPLE_UINT 149 - || sample_format == GGRAPH_SAMPLE_INT 150 - || sample_format == GGRAPH_SAMPLE_FLOAT) 151 - ; 152 - else 153 - return NULL; 154 - 155 - if (srs_name) 156 - { 157 - len = strlen (srs_name); 158 - if (len > 0) 159 - { 160 - SrsName = malloc (len + 1); 161 - if (!SrsName) 162 - return NULL; 163 - strcpy (SrsName, srs_name); 164 - } 165 - } 166 - if (proj4text) 167 - { 168 - len = strlen (proj4text); 169 - if (len > 0) 170 - { 171 - Proj4Text = malloc (len + 1); 172 - if (!Proj4Text) 173 - { 174 - if (SrsName) 175 - free (SrsName); 176 - return NULL; 177 - } 178 - strcpy (Proj4Text, proj4text); 179 - } 180 - } 181 - 182 -/* allocating the image struct */ 183 - img = malloc (sizeof (gGraphImage)); 184 - if (!img) 185 - return NULL; 186 - 187 - img->signature = GG_IMAGE_MAGIC_SIGNATURE; 188 - img->pixels = NULL; 189 - img->width = width; 190 - img->height = height; 191 - img->bits_per_sample = bits_per_sample; 192 - img->samples_per_pixel = samples_per_pixel; 193 - img->sample_format = sample_format; 194 - img->pixel_format = pixel_format; 195 - img->max_palette = 0; 196 - img->is_transparent = 0; 197 - img->tile_width = -1; 198 - img->tile_height = -1; 199 - img->rows_per_strip = -1; 200 - img->compression = GGRAPH_TIFF_COMPRESSION_NONE; 201 - img->is_georeferenced = 0; 202 - img->srid = -1; 203 - img->srs_name = SrsName; 204 - img->proj4text = Proj4Text; 205 - img->upper_left_x = DBL_MAX; 206 - img->upper_left_y = DBL_MAX; 207 - img->pixel_x_size = 0.0; 208 - img->pixel_y_size = 0.0; 209 - img->no_data_value = 0.0 - DBL_MAX; 210 - img->min_value = DBL_MAX; 211 - img->max_value = 0.0 - DBL_MAX; 212 - 213 -/* computing the scanline size */ 214 - if (pixel_format == GG_PIXEL_GRAYSCALE || pixel_format == GG_PIXEL_PALETTE) 215 - { 216 - img->scanline_width = width; 217 - img->pixel_size = 1; 218 - } 219 - else if (pixel_format == GG_PIXEL_RGB || pixel_format == GG_PIXEL_BGR) 220 - { 221 - img->scanline_width = width * 3; 222 - img->pixel_size = 3; 223 - } 224 - else if (pixel_format == GG_PIXEL_GRID) 225 - { 226 - if (sample_format == GGRAPH_SAMPLE_FLOAT) 227 - { 228 - if (bits_per_sample == 32) 229 - { 230 - /* float */ 231 - img->scanline_width = width * 4; 232 - img->pixel_size = 8; 233 - } 234 - else 235 - { 236 - /* double */ 237 - img->scanline_width = width * 8; 238 - img->pixel_size = 8; 239 - } 240 - } 241 - else 242 - { 243 - /* UINT or INT */ 244 - if (bits_per_sample == 8) 245 - { 246 - /* 8bits int */ 247 - img->scanline_width = width; 248 - img->pixel_size = 1; 249 - } 250 - else if (bits_per_sample == 16) 251 - { 252 - /* 16bits int */ 253 - img->scanline_width = width * 2; 254 - img->pixel_size = 2; 255 - } 256 - else 257 - { 258 - /* 32bits int */ 259 - img->scanline_width = width * 4; 260 - img->pixel_size = 4; 261 - } 262 - } 263 - } 264 - else 265 - { 266 - /* RGBA, ARGB or BGRA */ 267 - img->scanline_width = width * 4; 268 - img->pixel_size = 4; 269 - } 270 - 271 -/* allocating the pixel buffer */ 272 - img->pixels = malloc (img->scanline_width * height); 273 - if (!img->pixels) 274 - { 275 - free (img); 276 - return NULL; 277 - } 278 - return img; 279 -} 280 - 281 -GGRAPH_PRIVATE gGraphImagePtr 282 -gg_image_create_from_bitmap (unsigned char *bitmap, int pixel_format, int width, 283 - int height, int bits_per_sample, 284 - int samples_per_pixel, int sample_format, 285 - const char *srs_name, const char *proj4text) 286 -{ 287 -/* creating a generic image */ 288 - gGraphImagePtr img; 289 - int len; 290 - char *SrsName = NULL; 291 - char *Proj4Text = NULL; 292 - 293 -/* checking PIXEL_FORMAT */ 294 - if (pixel_format == GG_PIXEL_RGB || pixel_format == GG_PIXEL_RGBA 295 - || pixel_format == GG_PIXEL_ARGB || pixel_format == GG_PIXEL_BGR 296 - || pixel_format == GG_PIXEL_GRAYSCALE 297 - || pixel_format == GG_PIXEL_PALETTE || pixel_format == GG_PIXEL_GRID) 298 - ; 299 - else 300 - return NULL; 301 - if (sample_format == GGRAPH_SAMPLE_UINT 302 - || sample_format == GGRAPH_SAMPLE_INT 303 - || sample_format == GGRAPH_SAMPLE_FLOAT) 304 - ; 305 - else 306 - return NULL; 307 - 308 - if (srs_name) 309 - { 310 - len = strlen (srs_name); 311 - if (len > 0) 312 - { 313 - SrsName = malloc (len + 1); 314 - if (!SrsName) 315 - return NULL; 316 - strcpy (SrsName, srs_name); 317 - } 318 - } 319 - if (proj4text) 320 - { 321 - len = strlen (proj4text); 322 - if (len > 0) 323 - { 324 - Proj4Text = malloc (len + 1); 325 - if (!Proj4Text) 326 - { 327 - if (SrsName) 328 - free (SrsName); 329 - return NULL; 330 - } 331 - strcpy (Proj4Text, proj4text); 332 - } 333 - } 334 - 335 -/* allocating the image struct */ 336 - img = malloc (sizeof (gGraphImage)); 337 - if (!img) 338 - return NULL; 339 - 340 - img->signature = GG_IMAGE_MAGIC_SIGNATURE; 341 - img->pixels = NULL; 342 - img->width = width; 343 - img->height = height; 344 - img->bits_per_sample = bits_per_sample; 345 - img->samples_per_pixel = samples_per_pixel; 346 - img->sample_format = sample_format; 347 - img->pixel_format = pixel_format; 348 - img->max_palette = 0; 349 - img->is_transparent = 0; 350 - img->tile_width = -1; 351 - img->tile_height = -1; 352 - img->rows_per_strip = -1; 353 - img->compression = GGRAPH_TIFF_COMPRESSION_NONE; 354 - img->is_georeferenced = 0; 355 - img->srid = -1; 356 - img->srs_name = SrsName; 357 - img->proj4text = Proj4Text; 358 - img->upper_left_x = DBL_MAX; 359 - img->upper_left_y = DBL_MAX; 360 - img->pixel_x_size = 0.0; 361 - img->pixel_y_size = 0.0; 362 - img->no_data_value = 0.0 - DBL_MAX; 363 - img->min_value = DBL_MAX; 364 - img->max_value = 0.0 - DBL_MAX; 365 - 366 -/* computing the scanline size */ 367 - if (pixel_format == GG_PIXEL_GRAYSCALE || pixel_format == GG_PIXEL_PALETTE) 368 - { 369 - img->scanline_width = width; 370 - img->pixel_size = 1; 371 - } 372 - else if (pixel_format == GG_PIXEL_RGB || pixel_format == GG_PIXEL_BGR) 373 - { 374 - img->scanline_width = width * 3; 375 - img->pixel_size = 3; 376 - } 377 - else if (pixel_format == GG_PIXEL_GRID) 378 - { 379 - if (sample_format == GGRAPH_SAMPLE_FLOAT) 380 - { 381 - if (bits_per_sample == 32) 382 - { 383 - /* float */ 384 - img->scanline_width = width * 4; 385 - img->pixel_size = 8; 386 - } 387 - else 388 - { 389 - /* double */ 390 - img->scanline_width = width * 8; 391 - img->pixel_size = 8; 392 - } 393 - } 394 - else 395 - { 396 - /* UINT or INT */ 397 - if (bits_per_sample == 8) 398 - { 399 - /* 8bits int */ 400 - img->scanline_width = width; 401 - img->pixel_size = 1; 402 - } 403 - else if (bits_per_sample == 16) 404 - { 405 - /* 16bits int */ 406 - img->scanline_width = width * 2; 407 - img->pixel_size = 2; 408 - } 409 - else 410 - { 411 - /* 32bits int */ 412 - img->scanline_width = width * 4; 413 - img->pixel_size = 4; 414 - } 415 - } 416 - } 417 - else 418 - { 419 - /* RGBA, ARGB or BGRA */ 420 - img->scanline_width = width * 4; 421 - img->pixel_size = 4; 422 - } 423 - 424 -/* setting up the pixel buffer */ 425 - img->pixels = bitmap; 426 - return img; 427 -} 428 - 429 -GGRAPH_PRIVATE void 430 -gg_image_destroy (gGraphImagePtr img) 431 -{ 432 -/* destroying a generic image */ 433 - if (!img) 434 - return; 435 - if (img->pixels) 436 - free (img->pixels); 437 - if (img->srs_name) 438 - free (img->srs_name); 439 - if (img->proj4text) 440 - free (img->proj4text); 441 - free (img); 442 -} 443 - 444 -GGRAPH_PRIVATE gGraphStripImagePtr 445 -gg_strip_image_create (FILE * file_handle, int codec_id, int pixel_format, 446 - int width, int height, int bits_per_sample, 447 - int samples_per_pixel, int sample_format, 448 - const char *srs_name, const char *proj4text) 449 -{ 450 -/* creating a file-based image implementing access by strips */ 451 - gGraphStripImagePtr img; 452 - int len; 453 - char *SrsName = NULL; 454 - char *Proj4Text = NULL; 455 - 456 -/* checking PIXEL_FORMAT */ 457 - if (pixel_format == GG_PIXEL_RGB || pixel_format == GG_PIXEL_RGBA 458 - || pixel_format == GG_PIXEL_ARGB || pixel_format == GG_PIXEL_BGR 459 - || pixel_format == GG_PIXEL_GRAYSCALE 460 - || pixel_format == GG_PIXEL_PALETTE || pixel_format == GG_PIXEL_GRID) 461 - ; 462 - else 463 - return NULL; 464 - if (sample_format == GGRAPH_SAMPLE_UINT 465 - || sample_format == GGRAPH_SAMPLE_INT 466 - || sample_format == GGRAPH_SAMPLE_FLOAT) 467 - ; 468 - else 469 - return NULL; 470 - 471 - if (srs_name) 472 - { 473 - len = strlen (srs_name); 474 - if (len > 0) 475 - { 476 - SrsName = malloc (len + 1); 477 - if (!SrsName) 478 - return NULL; 479 - strcpy (SrsName, srs_name); 480 - } 481 - } 482 - if (proj4text) 483 - { 484 - len = strlen (proj4text); 485 - if (len > 0) 486 - { 487 - Proj4Text = malloc (len + 1); 488 - if (!Proj4Text) 489 - { 490 - if (SrsName) 491 - free (SrsName); 492 - return NULL; 493 - } 494 - strcpy (Proj4Text, proj4text); 495 - } 496 - } 497 - 498 -/* allocating the image struct */ 499 - img = malloc (sizeof (gGraphStripImage)); 500 - if (!img) 501 - return NULL; 502 - 503 - img->signature = GG_STRIP_IMAGE_MAGIC_SIGNATURE; 504 - img->file_handle = file_handle; 505 - img->codec_id = codec_id; 506 - img->rows_per_block = 0; 507 - img->current_available_rows = 0; 508 - img->codec_data = NULL; 509 - img->pixels = NULL; 510 - img->next_row = 0; 511 - img->codec_data = NULL; 512 - img->width = width; 513 - img->height = height; 514 - img->bits_per_sample = bits_per_sample; 515 - img->samples_per_pixel = samples_per_pixel; 516 - img->sample_format = sample_format; 517 - img->pixel_format = pixel_format; 518 - img->max_palette = 0; 519 - img->is_transparent = 0; 520 - img->tile_width = -1; 521 - img->tile_height = -1; 522 - img->rows_per_strip = -1; 523 - img->compression = GGRAPH_TIFF_COMPRESSION_NONE; 524 - img->is_georeferenced = 0; 525 - img->srid = -1; 526 - img->srs_name = SrsName; 527 - img->proj4text = Proj4Text; 528 - img->upper_left_x = DBL_MAX; 529 - img->upper_left_y = DBL_MAX; 530 - img->pixel_x_size = 0.0; 531 - img->pixel_y_size = 0.0; 532 - img->no_data_value = 0.0 - DBL_MAX; 533 - img->min_value = DBL_MAX; 534 - img->max_value = 0.0 - DBL_MAX; 535 - 536 -/* computing the scanline size */ 537 - if (pixel_format == GG_PIXEL_GRAYSCALE || pixel_format == GG_PIXEL_PALETTE) 538 - { 539 - img->scanline_width = width; 540 - img->pixel_size = 1; 541 - } 542 - else if (pixel_format == GG_PIXEL_RGB || pixel_format == GG_PIXEL_BGR) 543 - { 544 - img->scanline_width = width * 3; 545 - img->pixel_size = 3; 546 - } 547 - else if (pixel_format == GG_PIXEL_GRID) 548 - { 549 - if (sample_format == GGRAPH_SAMPLE_FLOAT) 550 - { 551 - if (bits_per_sample == 32) 552 - { 553 - /* float */ 554 - img->scanline_width = width * 4; 555 - img->pixel_size = 8; 556 - } 557 - else 558 - { 559 - /* double */ 560 - img->scanline_width = width * 8; 561 - img->pixel_size = 8; 562 - } 563 - } 564 - else 565 - { 566 - /* UINT or INT */ 567 - if (bits_per_sample == 8) 568 - { 569 - /* 8bits int */ 570 - img->scanline_width = width; 571 - img->pixel_size = 1; 572 - } 573 - else if (bits_per_sample == 16) 574 - { 575 - /* 16bits int */ 576 - img->scanline_width = width * 2; 577 - img->pixel_size = 2; 578 - } 579 - else 580 - { 581 - /* 32bits int */ 582 - img->scanline_width = width * 4; 583 - img->pixel_size = 4; 584 - } 585 - } 586 - } 587 - else 588 - { 589 - /* RGBA, ARGB or BGRA */ 590 - img->scanline_width = width * 4; 591 - img->pixel_size = 4; 592 - } 593 - 594 - return img; 595 -} 596 - 597 -GGRAPH_PRIVATE void 598 -gg_strip_image_destroy (gGraphStripImagePtr img) 599 -{ 600 -/* destroying a file-based image implementing access by strips */ 601 - if (!img) 602 - return; 603 - if (img->codec_id == GGRAPH_IMAGE_PNG) 604 - gg_png_codec_destroy (img->codec_data); 605 - if (img->codec_id == GGRAPH_IMAGE_JPEG) 606 - gg_jpeg_codec_destroy (img->codec_data); 607 - if (img->codec_id == GGRAPH_IMAGE_TIFF 608 - || img->codec_id == GGRAPH_IMAGE_GEOTIFF) 609 - gg_tiff_codec_destroy (img->codec_data); 610 - if (img->codec_id == GGRAPH_IMAGE_HGT) 611 - gg_grid_codec_destroy (img->codec_data); 612 - if (img->file_handle) 613 - fclose (img->file_handle); 614 - if (img->pixels) 615 - free (img->pixels); 616 - if (img->srs_name) 617 - free (img->srs_name); 618 - if (img->proj4text) 619 - free (img->proj4text); 620 - free (img); 621 -} 622 - 623 -GGRAPH_PRIVATE void 624 -gg_image_clone_georeferencing (const gGraphImagePtr dst, 625 - const gGraphImagePtr src) 626 -{ 627 -/* adjusting georeferencing infos between two images */ 628 - double size_x; 629 - double size_y; 630 - int len; 631 - char *SrsName = NULL; 632 - char *Proj4Text = NULL; 633 - if (src->is_georeferenced) 634 - { 635 - if (src->srs_name) 636 - { 637 - len = strlen (src->srs_name); 638 - if (len > 0) 639 - { 640 - SrsName = malloc (len + 1); 641 - if (SrsName) 642 - strcpy (SrsName, src->srs_name); 643 - } 644 - } 645 - if (src->proj4text) 646 - { 647 - len = strlen (src->proj4text); 648 - if (len > 0) 649 - { 650 - Proj4Text = malloc (len + 1); 651 - if (Proj4Text) 652 - strcpy (Proj4Text, src->proj4text); 653 - } 654 - } 655 - } 656 - 657 -/* cleaning up destination georeferencing */ 658 - dst->is_georeferenced = 0; 659 - dst->srid = -1; 660 - if (dst->srs_name) 661 - free (dst->srs_name); 662 - if (dst->proj4text) 663 - free (dst->proj4text); 664 - dst->srs_name = NULL; 665 - dst->proj4text = NULL; 666 - dst->upper_left_x = DBL_MAX; 667 - dst->upper_left_y = DBL_MAX; 668 - dst->pixel_x_size = 0.0; 669 - dst->pixel_y_size = 0.0; 670 - if (src->is_georeferenced == 0) 671 - return; 672 - 673 -/* setting up destination georeferencing */ 674 - dst->is_georeferenced = 1; 675 - dst->srid = src->srid; 676 - dst->srs_name = SrsName; 677 - dst->proj4text = Proj4Text; 678 - dst->upper_left_x = src->upper_left_x; 679 - dst->upper_left_y = src->upper_left_y; 680 - size_x = (double) (src->width) * src->pixel_x_size; 681 - size_y = (double) (src->height) * src->pixel_y_size; 682 - dst->pixel_x_size = size_x / (double) (dst->width); 683 - dst->pixel_y_size = size_y / (double) (dst->height); 684 - 685 -} 686 - 687 -static void 688 -sub_set_georeferencing (const gGraphImagePtr dst, const gGraphImagePtr src, 689 - int upper_left_x, int upper_left_y) 690 -{ 691 -/* adjusting georeferencing infos between two images [ImageSubSet] */ 692 - int len; 693 - char *SrsName = NULL; 694 - char *Proj4Text = NULL; 695 - if (src->is_georeferenced) 696 - { 697 - if (src->srs_name) 698 - { 699 - len = strlen (src->srs_name); 700 - if (len > 0) 701 - { 702 - SrsName = malloc (len + 1); 703 - if (SrsName) 704 - strcpy (SrsName, src->srs_name); 705 - } 706 - } 707 - if (src->proj4text) 708 - { 709 - len = strlen (src->proj4text); 710 - if (len > 0) 711 - { 712 - Proj4Text = malloc (len + 1); 713 - if (Proj4Text) 714 - strcpy (Proj4Text, src->proj4text); 715 - } 716 - } 717 - } 718 - 719 -/* cleaning up destination georeferencing */ 720 - dst->is_georeferenced = 0; 721 - dst->srid = -1; 722 - if (dst->srs_name) 723 - free (dst->srs_name); 724 - if (dst->proj4text) 725 - free (dst->proj4text); 726 - dst->srs_name = NULL; 727 - dst->proj4text = NULL; 728 - dst->upper_left_x = DBL_MAX; 729 - dst->upper_left_y = DBL_MAX; 730 - dst->pixel_x_size = 0.0; 731 - dst->pixel_y_size = 0.0; 732 - if (src->is_georeferenced == 0) 733 - return; 734 - 735 -/* setting up destination georeferencing */ 736 - dst->is_georeferenced = 1; 737 - dst->srid = src->srid; 738 - dst->srs_name = SrsName; 739 - dst->proj4text = Proj4Text; 740 - dst->upper_left_x = 741 - src->upper_left_x + ((double) upper_left_x * src->pixel_x_size); 742 - dst->upper_left_y = 743 - src->upper_left_y - ((double) upper_left_y * src->pixel_y_size); 744 - dst->pixel_x_size = src->pixel_x_size; 745 - dst->pixel_y_size = src->pixel_y_size; 746 - 747 -} 748 - 749 -GGRAPH_PRIVATE void 750 -gg_image_sub_set (const gGraphImagePtr dst, const gGraphImagePtr src, 751 - int upper_left_x, int upper_left_y) 752 -{ 753 -/* creating an ImageSubSet */ 754 - int x; 755 - int y; 756 - int dx; 757 - int dy = 0; 758 - int c; 759 - unsigned char *p_in; 760 - unsigned char *p_out; 761 - 762 - if (src->pixel_format != dst->pixel_format) 763 - { 764 - /* an absolutely unexpected condition !!!! */ 765 - return; 766 - } 767 - 768 - for (y = upper_left_y; y < src->height; y++, dy++) 769 - { 770 - if (dy >= dst->height) 771 - break; 772 - dx = 0; 773 - p_in = src->pixels + (y * src->scanline_width); 774 - p_in += upper_left_x * src->pixel_size; 775 - p_out = dst->pixels + (dy * dst->scanline_width); 776 - for (x = upper_left_x; x < src->width; x++, dx++) 777 - { 778 - if (dx >= dst->width) 779 - break; 780 - /* copying pixel's components */ 781 - for (c = 0; c < src->pixel_size; c++) 782 - *p_out++ = *p_in++; 783 - } 784 - } 785 - if (src->pixel_format == GG_PIXEL_PALETTE) 786 - { 787 - /* copying palette entries */ 788 - for (x = 0; x < src->max_palette; x++) 789 - { 790 - dst->palette_red[x] = src->palette_red[x]; 791 - dst->palette_green[x] = src->palette_green[x]; 792 - dst->palette_blue[x] = src->palette_blue[x]; 793 - } 794 - dst->max_palette = src->max_palette; 795 - } 796 - 797 -/* computing georeferencing */ 798 - sub_set_georeferencing (dst, src, upper_left_x, upper_left_y); 799 -} 800 - 801 -static unsigned char 802 -to_grayscale (unsigned char r, unsigned char g, unsigned char b) 803 -{ 804 -/* computing a grayscale value */ 805 - double dval = 806 - (0.3 * (double) r) + (0.59 * (double) g) + (0.11 * (double) b); 807 - int ival = (int) dval; 808 - if (ival < 0) 809 - ival = 0; 810 - if (ival > 255) 811 - ival = 255; 812 - return (unsigned char) ival; 813 -} 814 - 815 -GGRAPH_PRIVATE void 816 -gg_image_fill (const gGraphImagePtr img, unsigned char r, unsigned char g, 817 - unsigned char b, unsigned char alpha) 818 -{ 819 -/* filling the image with given color */ 820 - int x; 821 - int y; 822 - unsigned char *p; 823 - unsigned char gray; 824 - 825 -/* resetting the palette anyway */ 826 - img->max_palette = 1; 827 - img->palette_red[0] = r; 828 - img->palette_green[0] = g; 829 - img->palette_blue[0] = b; 830 - 831 -/* precomputing a grayscale value anyway */ 832 - if (r == g && g == b) 833 - gray = r; 834 - else 835 - gray = to_grayscale (r, g, b); 836 - 837 - for (y = 0; y < img->height; y++) 838 - { 839 - /* setting pixels by scanline */ 840 - p = img->pixels + (y * img->scanline_width); 841 - for (x = 0; x < img->width; x++) 842 - { 843 - /* setting pixels */ 844 - if (img->pixel_format == GG_PIXEL_RGB) 845 - { 846 - *p++ = r; 847 - *p++ = g; 848 - *p++ = b; 849 - } 850 - else if (img->pixel_format == GG_PIXEL_RGBA) 851 - { 852 - *p++ = r; 853 - *p++ = g; 854 - *p++ = b; 855 - *p++ = alpha; 856 - } 857 - else if (img->pixel_format == GG_PIXEL_ARGB) 858 - { 859 - *p++ = alpha; 860 - *p++ = r; 861 - *p++ = g; 862 - *p++ = b; 863 - } 864 - else if (img->pixel_format == GG_PIXEL_BGR) 865 - { 866 - *p++ = b; 867 - *p++ = g; 868 - *p++ = r; 869 - } 870 - else if (img->pixel_format == GG_PIXEL_BGRA) 871 - { 872 - *p++ = b; 873 - *p++ = g; 874 - *p++ = r; 875 - *p++ = alpha; 876 - } 877 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 878 - *p++ = gray; 879 - else if (img->pixel_format == GG_PIXEL_PALETTE) 880 - *p++ = 0; 881 - } 882 - } 883 -} 884 - 885 -GGRAPH_PRIVATE unsigned char 886 -gg_match_palette (const gGraphImagePtr img, unsigned char r, unsigned char g, 887 - unsigned char b) 888 -{ 889 -/* handling palette colors */ 890 - int index; 891 - double min_dist = DBL_MAX; 892 - double dist; 893 - int min_index; 894 - for (index = 0; index < img->max_palette; index++) 895 - { 896 - /* searching if already defined */ 897 - if (img->palette_red[index] == r && img->palette_green[index] == g 898 - && img->palette_blue[index] == b) 899 - return (unsigned char) index; 900 - } 901 - if (img->max_palette < 255) 902 - { 903 - /* inserting a new palette entry */ 904 - unsigned char i = img->max_palette; 905 - img->max_palette += 1; 906 - img->palette_red[i] = r; 907 - img->palette_green[i] = g; 908 - img->palette_blue[i] = b; 909 - return i; 910 - } 911 -/* all right, the palette is already fully populated */ 912 - for (index = 0; index < img->max_palette; index++) 913 - { 914 - /* computing the minimal euclidean distance */ 915 - dist = 916 - sqrt (((img->palette_red[index] - r) * (img->palette_red[index] - 917 - r)) + 918 - ((img->palette_green[index] - 919 - g) * (img->palette_green[index] - g)) + 920 - ((img->palette_blue[index] - 921 - b) * (img->palette_blue[index] - b))); 922 - if (dist < min_dist) 923 - { 924 - min_dist = dist; 925 - min_index = index; 926 - } 927 - } 928 - return (unsigned char) min_index; 929 -} 930 - 931 -static void 932 -shrink_by (const gGraphImagePtr dst, const gGraphImagePtr src) 933 -{ 934 -/* 935 -/ this code is widely base upon the original wxWidgets gwxImage wxImage::ShrinkBy(() function 936 -*/ 937 - int xFactor = src->width / dst->width; 938 - int yFactor = src->height / dst->height; 939 - int x; 940 - int y; 941 - int x1; 942 - int y1; 943 - int y_offset; 944 - int x_offset; 945 - unsigned char red; 946 - unsigned char green; 947 - unsigned char blue; 948 - unsigned char gray; 949 - unsigned char *p; 950 - for (y = 0; y < dst->height; y++) 951 - { 952 - for (x = 0; x < dst->width; x++) 953 - { 954 - /* determine average */ 955 - unsigned int avgRed = 0; 956 - unsigned int avgGreen = 0; 957 - unsigned int avgBlue = 0; 958 - unsigned int counter = 0; 959 - for (y1 = 0; y1 < yFactor; ++y1) 960 - { 961 - y_offset = (y * yFactor + y1); 962 - for (x1 = 0; x1 < xFactor; ++x1) 963 - { 964 - x_offset = (x * xFactor) + x1; 965 - p = src->pixels + (y_offset * src->scanline_width); 966 - if (src->pixel_format == GG_PIXEL_RGB) 967 - { 968 - p += x_offset * 3; 969 - red = *p++; 970 - green = *p++; 971 - blue = *p; 972 - } 973 - else if (src->pixel_format == GG_PIXEL_RGBA) 974 - { 975 - p += x_offset * 4; 976 - red = *p++; 977 - green = *p++; 978 - blue = *p; 979 - } 980 - else if (src->pixel_format == GG_PIXEL_ARGB) 981 - { 982 - p += x_offset * 4; 983 - p++; 984 - red = *p++; 985 - green = *p++; 986 - blue = *p; 987 - } 988 - else if (src->pixel_format == GG_PIXEL_BGR) 989 - { 990 - p += x_offset * 3; 991 - blue = *p++; 992 - green = *p++; 993 - red = *p; 994 - } 995 - else if (src->pixel_format == GG_PIXEL_BGRA) 996 - { 997 - p += x_offset * 4; 998 - blue = *p++; 999 - green = *p++; 1000 - red = *p; 1001 - } 1002 - else if (src->pixel_format == GG_PIXEL_GRAYSCALE) 1003 - { 1004 - p += x_offset; 1005 - red = *p; 1006 - green = *p; 1007 - blue = *p; 1008 - } 1009 - else if (src->pixel_format == GG_PIXEL_PALETTE) 1010 - { 1011 - p += x_offset; 1012 - red = src->palette_red[*p]; 1013 - green = src->palette_green[*p]; 1014 - blue = src->palette_blue[*p]; 1015 - } 1016 - avgRed += red; 1017 - avgGreen += green; 1018 - avgBlue += blue; 1019 - counter++; 1020 - } 1021 - } 1022 - /* storing the pixel into destination */ 1023 - red = avgRed / counter; 1024 - green = avgGreen / counter; 1025 - blue = avgBlue / counter; 1026 - p = dst->pixels + (y * dst->scanline_width); 1027 - if (dst->pixel_format == GG_PIXEL_RGB) 1028 - { 1029 - p += x * 3; 1030 - *p++ = red; 1031 - *p++ = green; 1032 - *p = blue; 1033 - } 1034 - else if (dst->pixel_format == GG_PIXEL_RGBA) 1035 - { 1036 - p += x * 4; 1037 - *p++ = red; 1038 - *p++ = green; 1039 - *p++ = blue; 1040 - *p = 255; /* opaque */ 1041 - } 1042 - else if (dst->pixel_format == GG_PIXEL_ARGB) 1043 - { 1044 - p += x * 4; 1045 - *p++ = 255; /* opaque */ 1046 - *p++ = red; 1047 - *p++ = green; 1048 - *p = blue; 1049 - } 1050 - else if (dst->pixel_format == GG_PIXEL_BGR) 1051 - { 1052 - p += x * 3; 1053 - *p++ = blue; 1054 - *p++ = green; 1055 - *p = red; 1056 - } 1057 - else if (dst->pixel_format == GG_PIXEL_BGRA) 1058 - { 1059 - p += x * 4; 1060 - *p++ = blue; 1061 - *p++ = green; 1062 - *p++ = red; 1063 - *p = 255; /* opaque */ 1064 - } 1065 - else if (dst->pixel_format == GG_PIXEL_GRAYSCALE) 1066 - { 1067 - p += x; 1068 - if (red == green && green == blue) 1069 - gray = red; 1070 - else 1071 - gray = to_grayscale (red, green, blue); 1072 - *p = gray; 1073 - } 1074 - else if (dst->pixel_format == GG_PIXEL_PALETTE) 1075 - { 1076 - unsigned char index = 1077 - gg_match_palette (dst, red, green, blue); 1078 - p += x; 1079 - *p = index; 1080 - } 1081 - } 1082 - } 1083 -} 1084 - 1085 -GGRAPH_PRIVATE void 1086 -gg_image_resize (const gGraphImagePtr dst, const gGraphImagePtr src) 1087 -{ 1088 -/* 1089 -/ this function builds an ordinary quality resized image, applying pixel replication 1090 -/ 1091 -/ this code is widely base upon the original wxWidgets gwxImage wxImage::Scale(() function 1092 -/ wxIMAGE_QUALITY_NORMAL 1093 -*/ 1094 - int x_delta; 1095 - int y_delta; 1096 - int y; 1097 - int j; 1098 - int x; 1099 - int i; 1100 - unsigned char red; 1101 - unsigned char green; 1102 - unsigned char blue; 1103 - unsigned char alpha; 1104 - unsigned char gray; 1105 - unsigned char *p; 1106 - 1107 - if ((src->width % dst->width) == 0 && src->width >= dst->width 1108 - && (src->height % dst->height) == 0 && src->height >= dst->height) 1109 - { 1110 - shrink_by (dst, src); 1111 - return; 1112 - } 1113 - x = src->width; 1114 - y = src->height; 1115 - x_delta = (x << 16) / dst->width; 1116 - y_delta = (y << 16) / dst->height; 1117 - y = 0; 1118 - for (j = 0; j < dst->height; j++) 1119 - { 1120 - x = 0; 1121 - for (i = 0; i < dst->width; i++) 1122 - { 1123 - /* retrieving the origin pixel */ 1124 - p = src->pixels + ((y >> 16) * src->scanline_width); 1125 - if (src->pixel_format == GG_PIXEL_RGB) 1126 - { 1127 - p += (x >> 16) * 3; 1128 - red = *p++; 1129 - green = *p++; 1130 - blue = *p; 1131 - alpha = 255; 1132 - } 1133 - else if (src->pixel_format == GG_PIXEL_RGBA) 1134 - { 1135 - p += (x >> 16) * 4; 1136 - red = *p++; 1137 - green = *p++; 1138 - blue = *p++; 1139 - alpha = *p; 1140 - } 1141 - else if (src->pixel_format == GG_PIXEL_ARGB) 1142 - { 1143 - p += (x >> 16) * 4; 1144 - alpha = *p++; 1145 - red = *p++; 1146 - green = *p++; 1147 - blue = *p; 1148 - } 1149 - else if (src->pixel_format == GG_PIXEL_BGR) 1150 - { 1151 - p += (x >> 16) * 3; 1152 - blue = *p++; 1153 - green = *p++; 1154 - red = *p; 1155 - alpha = 255; 1156 - } 1157 - else if (src->pixel_format == GG_PIXEL_BGRA) 1158 - { 1159 - p += (x >> 16) * 4; 1160 - blue = *p++; 1161 - green = *p++; 1162 - red = *p++; 1163 - alpha = *p; 1164 - } 1165 - else if (src->pixel_format == GG_PIXEL_GRAYSCALE) 1166 - { 1167 - p += (x >> 16); 1168 - red = *p; 1169 - green = *p; 1170 - blue = *p; 1171 - alpha = 255; 1172 - } 1173 - else if (src->pixel_format == GG_PIXEL_PALETTE) 1174 - { 1175 - p += (x >> 16); 1176 - red = src->palette_red[*p]; 1177 - green = src->palette_green[*p]; 1178 - blue = src->palette_blue[*p]; 1179 - alpha = 255; 1180 - } 1181 - /* setting the destination pixel */ 1182 - p = dst->pixels + (j * dst->scanline_width); 1183 - if (dst->pixel_format == GG_PIXEL_RGB) 1184 - { 1185 - p += i * 3; 1186 - *p++ = red; 1187 - *p++ = green; 1188 - *p = blue; 1189 - } 1190 - else if (dst->pixel_format == GG_PIXEL_RGBA) 1191 - { 1192 - p += i * 4; 1193 - *p++ = red; 1194 - *p++ = green; 1195 - *p++ = blue; 1196 - *p = alpha; 1197 - } 1198 - else if (dst->pixel_format == GG_PIXEL_ARGB) 1199 - { 1200 - p += i * 4; 1201 - *p++ = alpha; 1202 - *p++ = red; 1203 - *p++ = green; 1204 - *p = blue; 1205 - } 1206 - else if (dst->pixel_format == GG_PIXEL_BGR) 1207 - { 1208 - p += i * 3; 1209 - *p++ = blue; 1210 - *p++ = green; 1211 - *p = red; 1212 - } 1213 - else if (dst->pixel_format == GG_PIXEL_BGRA) 1214 - { 1215 - p += i * 4; 1216 - *p++ = blue; 1217 - *p++ = green; 1218 - *p++ = red; 1219 - *p = alpha; 1220 - } 1221 - else if (dst->pixel_format == GG_PIXEL_GRAYSCALE) 1222 - { 1223 - p += i; 1224 - if (red == green && green == blue) 1225 - gray = red; 1226 - else 1227 - gray = to_grayscale (red, green, blue); 1228 - *p = gray; 1229 - } 1230 - else if (dst->pixel_format == GG_PIXEL_PALETTE) 1231 - { 1232 - unsigned char index = 1233 - gg_match_palette (dst, red, green, blue); 1234 - p += i; 1235 - *p = index; 1236 - } 1237 - x += x_delta; 1238 - } 1239 - y += y_delta; 1240 - } 1241 -} 1242 - 1243 -static void 1244 -shrink_grid_by (const gGraphImagePtr dst, const gGraphImagePtr src) 1245 -{ 1246 -/* 1247 -/ this code is widely base upon the original wxWidgets gwxImage wxImage::ShrinkBy(() function 1248 -*/ 1249 - int xFactor = src->width / dst->width; 1250 - int yFactor = src->height / dst->height; 1251 - int x; 1252 - int y; 1253 - int x1; 1254 - int y1; 1255 - int y_offset; 1256 - int x_offset; 1257 - short short_value; 1258 - unsigned short ushort_value; 1259 - int int_value; 1260 - unsigned int uint_value; 1261 - float float_value; 1262 - double double_value; 1263 - short *p_short; 1264 - unsigned short *p_ushort; 1265 - int *p_int; 1266 - unsigned int *p_uint; 1267 - float *p_float; 1268 - double *p_double; 1269 - for (y = 0; y < dst->height; y++) 1270 - { 1271 - for (x = 0; x < dst->width; x++) 1272 - { 1273 - /* determine average */ 1274 - int is_nodata = 0; 1275 - double avg; 1276 - unsigned int counter = 0; 1277 - unsigned char *p; 1278 - for (y1 = 0; y1 < yFactor; ++y1) 1279 - { 1280 - y_offset = (y * yFactor + y1); 1281 - for (x1 = 0; x1 < xFactor; ++x1) 1282 - { 1283 - x_offset = (x * xFactor) + x1; 1284 - p = src->pixels + (y_offset * src->scanline_width); 1285 - if (src->pixel_format == GG_PIXEL_GRID) 1286 - { 1287 - p += x_offset * (src->bits_per_sample / 8); 1288 - switch (src->sample_format) 1289 - { 1290 - case GGRAPH_SAMPLE_INT: 1291 - if (src->bits_per_sample == 16) 1292 - { 1293 - p_short = (short *) p; 1294 - short_value = *p_short; 1295 - if (short_value == 1296 - src->no_data_value) 1297 - is_nodata = 1; 1298 - if (!is_nodata) 1299 - avg += short_value; 1300 - } 1301 - else 1302 - { 1303 - p_int = (int *) p; 1304 - int_value = *p_int; 1305 - if (int_value == 1306 - src->no_data_value) 1307 - is_nodata = 1; 1308 - if (!is_nodata) 1309 - avg += int_value; 1310 - } 1311 - break; 1312 - case GGRAPH_SAMPLE_UINT: 1313 - if (src->bits_per_sample == 16) 1314 - { 1315 - p_ushort = (unsigned short *) p; 1316 - ushort_value = *p_ushort; 1317 - if (ushort_value == 1318 - src->no_data_value) 1319 - is_nodata = 1; 1320 - if (!is_nodata) 1321 - avg += ushort_value; 1322 - } 1323 - else 1324 - { 1325 - p_uint = (unsigned int *) p; 1326 - uint_value = *p_uint; 1327 - if (uint_value == 1328 - src->no_data_value) 1329 - is_nodata = 1; 1330 - if (!is_nodata) 1331 - avg += uint_value; 1332 - } 1333 - break; 1334 - case GGRAPH_SAMPLE_FLOAT: 1335 - if (src->bits_per_sample == 32) 1336 - { 1337 - p_float = (float *) p; 1338 - float_value = *p_float; 1339 - if (float_value == 1340 - src->no_data_value) 1341 - is_nodata = 1; 1342 - if (!is_nodata) 1343 - avg += float_value; 1344 - } 1345 - else 1346 - { 1347 - p_double = (double *) p; 1348 - double_value = *p_double; 1349 - if (double_value == 1350 - src->no_data_value) 1351 - is_nodata = 1; 1352 - if (!is_nodata) 1353 - avg += double_value; 1354 - } 1355 - break; 1356 - }; 1357 - } 1358 - counter++; 1359 - } 1360 - } 1361 - /* storing the pixel into destination */ 1362 - p = dst->pixels + (y * dst->scanline_width); 1363 - if (dst->pixel_format == GG_PIXEL_GRID) 1364 - { 1365 - p += x * (dst->bits_per_sample / 8); 1366 - switch (dst->sample_format) 1367 - { 1368 - case GGRAPH_SAMPLE_INT: 1369 - if (dst->bits_per_sample == 16) 1370 - { 1371 - p_short = (short *) p; 1372 - if (is_nodata) 1373 - *p_short = (short) (dst->no_data_value); 1374 - else 1375 - *p_short = (short) (avg / counter); 1376 - } 1377 - else 1378 - { 1379 - p_int = (int *) p; 1380 - if (is_nodata) 1381 - *p_int = (int) (dst->no_data_value); 1382 - else 1383 - *p_int = (int) (avg / counter); 1384 - } 1385 - break; 1386 - case GGRAPH_SAMPLE_UINT: 1387 - if (dst->bits_per_sample == 16) 1388 - { 1389 - p_ushort = (unsigned short *) p; 1390 - if (is_nodata) 1391 - *p_ushort = 1392 - (unsigned short) (dst->no_data_value); 1393 - else 1394 - *p_ushort = 1395 - (unsigned short) (avg / counter); 1396 - } 1397 - else 1398 - { 1399 - p_uint = (unsigned int *) p; 1400 - if (is_nodata) 1401 - *p_uint = 1402 - (unsigned int) (dst->no_data_value); 1403 - else 1404 - *p_uint = (unsigned int) (avg / counter); 1405 - } 1406 - break; 1407 - case GGRAPH_SAMPLE_FLOAT: 1408 - if (dst->bits_per_sample == 32) 1409 - { 1410 - p_float = (float *) p; 1411 - if (is_nodata) 1412 - *p_float = (float) (dst->no_data_value); 1413 - else 1414 - *p_float = (float) (avg / counter); 1415 - } 1416 - else 1417 - { 1418 - p_double = (double *) p; 1419 - if (is_nodata) 1420 - *p_double = dst->no_data_value; 1421 - else 1422 - *p_double = avg / counter; 1423 - } 1424 - break; 1425 - }; 1426 - } 1427 - } 1428 - } 1429 -} 1430 - 1431 -GGRAPH_PRIVATE void 1432 -gg_grid_resize (const gGraphImagePtr dst, const gGraphImagePtr src) 1433 -{ 1434 -/* 1435 -/ this function builds an ordinary quality resized GRID, applying pixel replication 1436 -/ 1437 -/ this code is widely base upon the original wxWidgets gwxImage wxImage::Scale(() function 1438 -/ wxIMAGE_QUALITY_NORMAL 1439 -*/ 1440 - int x_delta; 1441 - int y_delta; 1442 - int y; 1443 - int j; 1444 - int x; 1445 - int i; 1446 - short short_value; 1447 - unsigned short ushort_value; 1448 - int int_value; 1449 - unsigned int uint_value; 1450 - float float_value; 1451 - double double_value; 1452 - short *p_short; 1453 - unsigned short *p_ushort; 1454 - int *p_int; 1455 - unsigned int *p_uint; 1456 - float *p_float; 1457 - double *p_double; 1458 - 1459 - if ((src->width % dst->width) == 0 && src->width >= dst->width 1460 - && (src->height % dst->height) == 0 && src->height >= dst->height) 1461 - { 1462 - shrink_grid_by (dst, src); 1463 - return; 1464 - } 1465 - x = src->width; 1466 - y = src->height; 1467 - x_delta = (x << 16) / dst->width; 1468 - y_delta = (y << 16) / dst->height; 1469 - y = 0; 1470 - for (j = 0; j < dst->height; j++) 1471 - { 1472 - x = 0; 1473 - for (i = 0; i < dst->width; i++) 1474 - { 1475 - /* retrieving the origin pixel */ 1476 - unsigned char *p = 1477 - src->pixels + ((y >> 16) * src->scanline_width); 1478 - if (src->pixel_format == GG_PIXEL_GRID) 1479 - { 1480 - p += (x >> 16) * (src->bits_per_sample / 8); 1481 - switch (src->sample_format) 1482 - { 1483 - case GGRAPH_SAMPLE_INT: 1484 - if (src->bits_per_sample == 16) 1485 - { 1486 - p_short = (short *) p; 1487 - short_value = *p_short; 1488 - p += sizeof (short); 1489 - } 1490 - else 1491 - { 1492 - p_int = (int *) p; 1493 - int_value = *p_int; 1494 - p += sizeof (int); 1495 - } 1496 - break; 1497 - case GGRAPH_SAMPLE_UINT: 1498 - if (src->bits_per_sample == 16) 1499 - { 1500 - p_ushort = (unsigned short *) p; 1501 - ushort_value = *p_ushort; 1502 - p += sizeof (unsigned short); 1503 - } 1504 - else 1505 - { 1506 - p_uint = (unsigned int *) p; 1507 - uint_value = *p_uint; 1508 - p += sizeof (unsigned int); 1509 - } 1510 - break; 1511 - case GGRAPH_SAMPLE_FLOAT: 1512 - if (src->bits_per_sample == 32) 1513 - { 1514 - p_float = (float *) p; 1515 - float_value = *p_float; 1516 - p += sizeof (float); 1517 - } 1518 - else 1519 - { 1520 - p_double = (double *) p; 1521 - double_value = *p_double; 1522 - p += sizeof (double); 1523 - } 1524 - break; 1525 - }; 1526 - } 1527 - /* setting the destination pixel */ 1528 - p = dst->pixels + (j * dst->scanline_width); 1529 - if (dst->pixel_format == GG_PIXEL_GRID) 1530 - { 1531 - p += i * (dst->bits_per_sample / 8); 1532 - switch (dst->sample_format) 1533 - { 1534 - case GGRAPH_SAMPLE_INT: 1535 - if (dst->bits_per_sample == 16) 1536 - { 1537 - p_short = (short *) p; 1538 - *p_short = short_value; 1539 - } 1540 - else 1541 - { 1542 - p_int = (int *) p; 1543 - *p_int = int_value; 1544 - } 1545 - break; 1546 - case GGRAPH_SAMPLE_UINT: 1547 - if (dst->bits_per_sample == 16) 1548 - { 1549 - p_ushort = (unsigned short *) p; 1550 - *p_ushort = ushort_value; 1551 - } 1552 - else 1553 - { 1554 - p_uint = (unsigned int *) p; 1555 - *p_uint = uint_value; 1556 - } 1557 - break; 1558 - case GGRAPH_SAMPLE_FLOAT: 1559 - if (dst->bits_per_sample == 32) 1560 - { 1561 - p_float = (float *) p; 1562 - *p_float = float_value; 1563 - } 1564 - else 1565 - { 1566 - p_double = (double *) p; 1567 - *p_double = double_value; 1568 - } 1569 - break; 1570 - }; 1571 - } 1572 - x += x_delta; 1573 - } 1574 - y += y_delta; 1575 - } 1576 -} 1577 - 1578 -#define floor2(exp) ((long) exp) 1579 - 1580 -GGRAPH_PRIVATE void 1581 -gg_make_thumbnail (const gGraphImagePtr thumbnail, const gGraphImagePtr image) 1582 -{ 1583 -/* 1584 -/ this function builds an high quality thumbnail image, applying pixel interpolation 1585 -/ 1586 -/ this code is widely base upon the original GD gdImageCopyResampled() function 1587 -*/ 1588 - int x, y; 1589 - double sy1, sy2, sx1, sx2; 1590 - unsigned char r; 1591 - unsigned char g; 1592 - unsigned char b; 1593 - unsigned char a; 1594 - unsigned char gray; 1595 - unsigned char *p; 1596 - for (y = 0; y < thumbnail->height; y++) 1597 - { 1598 - sy1 = 1599 - ((double) y) * (double) image->height / 1600 - (double) thumbnail->height; 1601 - sy2 = 1602 - ((double) (y + 1)) * (double) image->height / 1603 - (double) thumbnail->height; 1604 - for (x = 0; x < thumbnail->width; x++) 1605 - { 1606 - double sx, sy; 1607 - double spixels = 0; 1608 - double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; 1609 - sx1 = 1610 - ((double) x) * (double) image->width / 1611 - (double) thumbnail->width; 1612 - sx2 = 1613 - ((double) (x + 1)) * (double) image->width / 1614 - (double) thumbnail->width; 1615 - sy = sy1; 1616 - do 1617 - { 1618 - double yportion; 1619 - if (floor2 (sy) == floor2 (sy1)) 1620 - { 1621 - yportion = 1.0 - (sy - floor2 (sy)); 1622 - if (yportion > sy2 - sy1) 1623 - { 1624 - yportion = sy2 - sy1; 1625 - } 1626 - sy = floor2 (sy); 1627 - } 1628 - else if (sy == floor2 (sy2)) 1629 - { 1630 - yportion = sy2 - floor2 (sy2); 1631 - } 1632 - else 1633 - { 1634 - yportion = 1.0; 1635 - } 1636 - sx = sx1; 1637 - do 1638 - { 1639 - double xportion; 1640 - double pcontribution; 1641 - if (floor2 (sx) == floor2 (sx1)) 1642 - { 1643 - xportion = 1.0 - (sx - floor2 (sx)); 1644 - if (xportion > sx2 - sx1) 1645 - { 1646 - xportion = sx2 - sx1; 1647 - } 1648 - sx = floor2 (sx); 1649 - } 1650 - else if (sx == floor2 (sx2)) 1651 - { 1652 - xportion = sx2 - floor2 (sx2); 1653 - } 1654 - else 1655 - { 1656 - xportion = 1.0; 1657 - } 1658 - pcontribution = xportion * yportion; 1659 - /* retrieving the origin pixel */ 1660 - p = image->pixels + 1661 - ((int) sy * image->scanline_width); 1662 - if (image->pixel_format == GG_PIXEL_RGB) 1663 - { 1664 - p += (int) sx *3; 1665 - r = *p++; 1666 - g = *p++; 1667 - b = *p; 1668 - a = 255; 1669 - } 1670 - else if (image->pixel_format == GG_PIXEL_RGBA) 1671 - { 1672 - p += (int) sx *4; 1673 - r = *p++; 1674 - g = *p++; 1675 - b = *p++; 1676 - a = *p; 1677 - } 1678 - else if (image->pixel_format == GG_PIXEL_ARGB) 1679 - { 1680 - p += (int) sx *4; 1681 - a = *p++; 1682 - r = *p++; 1683 - g = *p++; 1684 - b = *p; 1685 - } 1686 - else if (image->pixel_format == GG_PIXEL_BGR) 1687 - { 1688 - p += (int) sx *3; 1689 - b = *p++; 1690 - g = *p++; 1691 - r = *p; 1692 - a = 255; 1693 - } 1694 - else if (image->pixel_format == GG_PIXEL_BGRA) 1695 - { 1696 - p += (int) sx *4; 1697 - b = *p++; 1698 - g = *p++; 1699 - r = *p++; 1700 - a = *p; 1701 - } 1702 - else if (image->pixel_format == GG_PIXEL_GRAYSCALE) 1703 - { 1704 - p += (int) sx; 1705 - r = *p; 1706 - g = *p; 1707 - b = *p; 1708 - a = 255; 1709 - } 1710 - else if (image->pixel_format == GG_PIXEL_PALETTE) 1711 - { 1712 - p += (int) sx; 1713 - r = image->palette_red[*p]; 1714 - g = image->palette_green[*p]; 1715 - b = image->palette_blue[*p]; 1716 - a = 255; 1717 - } 1718 - red += r * pcontribution; 1719 - green += g * pcontribution; 1720 - blue += b * pcontribution; 1721 - alpha += a * pcontribution; 1722 - spixels += xportion * yportion; 1723 - sx += 1.0; 1724 - } 1725 - while (sx < sx2); 1726 - sy += 1.0; 1727 - } 1728 - while (sy < sy2); 1729 - if (spixels != 0.0) 1730 - { 1731 - red /= spixels; 1732 - green /= spixels; 1733 - blue /= spixels; 1734 - alpha /= spixels; 1735 - } 1736 - if (red > 255.0) 1737 - red = 255.0; 1738 - if (green > 255.0) 1739 - green = 255.0; 1740 - if (blue > 255.0) 1741 - blue = 255.0; 1742 - if (alpha > 255.0) 1743 - alpha = 255.0; 1744 - /* setting the destination pixel */ 1745 - p = thumbnail->pixels + (y * thumbnail->scanline_width); 1746 - if (thumbnail->pixel_format == GG_PIXEL_RGB) 1747 - { 1748 - p += x * 3; 1749 - *p++ = (unsigned char) red; 1750 - *p++ = (unsigned char) green; 1751 - *p = (unsigned char) blue; 1752 - } 1753 - else if (thumbnail->pixel_format == GG_PIXEL_RGBA) 1754 - { 1755 - p += x * 4; 1756 - *p++ = (unsigned char) red; 1757 - *p++ = (unsigned char) green; 1758 - *p++ = (unsigned char) blue; 1759 - *p = (unsigned char) alpha; 1760 - } 1761 - else if (thumbnail->pixel_format == GG_PIXEL_ARGB) 1762 - { 1763 - p += x * 4; 1764 - *p++ = (unsigned char) alpha; 1765 - *p++ = (unsigned char) red; 1766 - *p++ = (unsigned char) green; 1767 - *p = (unsigned char) blue; 1768 - } 1769 - else if (thumbnail->pixel_format == GG_PIXEL_BGR) 1770 - { 1771 - p += x * 3; 1772 - *p++ = (unsigned char) blue; 1773 - *p++ = (unsigned char) green; 1774 - *p = (unsigned char) red; 1775 - } 1776 - else if (thumbnail->pixel_format == GG_PIXEL_BGRA) 1777 - { 1778 - p += x * 4; 1779 - *p++ = (unsigned char) blue; 1780 - *p++ = (unsigned char) green; 1781 - *p++ = (unsigned char) red; 1782 - *p = (unsigned char) alpha; 1783 - } 1784 - else if (thumbnail->pixel_format == GG_PIXEL_GRAYSCALE) 1785 - { 1786 - p += x; 1787 - if (red == green && green == blue) 1788 - gray = (unsigned char) red; 1789 - else 1790 - gray = 1791 - to_grayscale ((unsigned char) red, 1792 - (unsigned char) green, 1793 - (unsigned char) blue); 1794 - *p = gray; 1795 - } 1796 - else if (thumbnail->pixel_format == GG_PIXEL_PALETTE) 1797 - { 1798 - unsigned char index = 1799 - gg_match_palette (thumbnail, (unsigned char) red, 1800 - (unsigned char) green, 1801 - (unsigned char) blue); 1802 - p += x; 1803 - *p = index; 1804 - } 1805 - } 1806 - } 1807 -} 1808 - 1809 -GGRAPH_PRIVATE void 1810 -gg_make_grid_thumbnail (const gGraphImagePtr thumbnail, 1811 - const gGraphImagePtr image) 1812 -{ 1813 -/* 1814 -/ this function builds an high quality thumbnail image, applying pixel interpolation 1815 -/ 1816 -/ this code is widely base upon the original GD gdImageCopyResampled() function 1817 -*/ 1818 - int x, y; 1819 - double sy1, sy2, sx1, sx2; 1820 - short short_value; 1821 - unsigned short ushort_value; 1822 - int int_value; 1823 - unsigned int uint_value; 1824 - float float_value; 1825 - double double_value; 1826 - short *p_short; 1827 - unsigned short *p_ushort; 1828 - int *p_int; 1829 - unsigned int *p_uint; 1830 - float *p_float; 1831 - double *p_double; 1832 - unsigned char *p; 1833 - for (y = 0; y < thumbnail->height; y++) 1834 - { 1835 - sy1 = 1836 - ((double) y) * (double) image->height / 1837 - (double) thumbnail->height; 1838 - sy2 = 1839 - ((double) (y + 1)) * (double) image->height / 1840 - (double) thumbnail->height; 1841 - for (x = 0; x < thumbnail->width; x++) 1842 - { 1843 - double sx, sy; 1844 - double spixels = 0; 1845 - double avg = 0.0; 1846 - int is_nodata = 0; 1847 - sx1 = 1848 - ((double) x) * (double) image->width / 1849 - (double) thumbnail->width; 1850 - sx2 = 1851 - ((double) (x + 1)) * (double) image->width / 1852 - (double) thumbnail->width; 1853 - sy = sy1; 1854 - do 1855 - { 1856 - double yportion; 1857 - if (floor2 (sy) == floor2 (sy1)) 1858 - { 1859 - yportion = 1.0 - (sy - floor2 (sy)); 1860 - if (yportion > sy2 - sy1) 1861 - { 1862 - yportion = sy2 - sy1; 1863 - } 1864 - sy = floor2 (sy); 1865 - } 1866 - else if (sy == floor2 (sy2)) 1867 - { 1868 - yportion = sy2 - floor2 (sy2); 1869 - } 1870 - else 1871 - { 1872 - yportion = 1.0; 1873 - } 1874 - sx = sx1; 1875 - do 1876 - { 1877 - double xportion; 1878 - double pcontribution; 1879 - if (floor2 (sx) == floor2 (sx1)) 1880 - { 1881 - xportion = 1.0 - (sx - floor2 (sx)); 1882 - if (xportion > sx2 - sx1) 1883 - { 1884 - xportion = sx2 - sx1; 1885 - } 1886 - sx = floor2 (sx); 1887 - } 1888 - else if (sx == floor2 (sx2)) 1889 - { 1890 - xportion = sx2 - floor2 (sx2); 1891 - } 1892 - else 1893 - { 1894 - xportion = 1.0; 1895 - } 1896 - pcontribution = xportion * yportion; 1897 - /* retrieving the origin pixel */ 1898 - p = image->pixels + 1899 - ((int) sy * image->scanline_width); 1900 - if (image->pixel_format == GG_PIXEL_GRID) 1901 - { 1902 - p += (int) sx *(image->bits_per_sample / 8); 1903 - switch (image->sample_format) 1904 - { 1905 - case GGRAPH_SAMPLE_INT: 1906 - if (image->bits_per_sample == 16) 1907 - { 1908 - p_short = (short *) p; 1909 - short_value = *p_short; 1910 - if (short_value == 1911 - image->no_data_value) 1912 - is_nodata = 1; 1913 - else 1914 - avg += 1915 - (double) short_value 1916 - * pcontribution; 1917 - } 1918 - else 1919 - { 1920 - p_int = (int *) p; 1921 - int_value = *p_int; 1922 - if (int_value == 1923 - image->no_data_value) 1924 - is_nodata = 1; 1925 - else 1926 - avg += 1927 - (double) int_value 1928 - * pcontribution; 1929 - } 1930 - break; 1931 - case GGRAPH_SAMPLE_UINT: 1932 - if (image->bits_per_sample == 16) 1933 - { 1934 - p_ushort = (unsigned short *) p; 1935 - ushort_value = *p_ushort; 1936 - if (ushort_value == 1937 - image->no_data_value) 1938 - is_nodata = 1; 1939 - else 1940 - avg += 1941 - (double) ushort_value 1942 - * pcontribution; 1943 - } 1944 - else 1945 - { 1946 - p_uint = (unsigned int *) p; 1947 - uint_value = *p_uint; 1948 - if (uint_value == 1949 - image->no_data_value) 1950 - is_nodata = 1; 1951 - else 1952 - avg += 1953 - (double) uint_value 1954 - * pcontribution; 1955 - } 1956 - break; 1957 - case GGRAPH_SAMPLE_FLOAT: 1958 - if (image->bits_per_sample == 32) 1959 - { 1960 - p_float = (float *) p; 1961 - float_value = *p_float; 1962 - if (float_value == 1963 - image->no_data_value) 1964 - is_nodata = 1; 1965 - else 1966 - avg += 1967 - (double) float_value 1968 - * pcontribution; 1969 - } 1970 - else 1971 - { 1972 - p_double = (double *) p; 1973 - double_value = *p_double; 1974 - if (double_value == 1975 - image->no_data_value) 1976 - is_nodata = 1; 1977 - else 1978 - avg += 1979 - double_value * 1980 - pcontribution; 1981 - } 1982 - break; 1983 - }; 1984 - } 1985 - spixels += xportion * yportion; 1986 - sx += 1.0; 1987 - } 1988 - while (sx < sx2); 1989 - sy += 1.0; 1990 - } 1991 - while (sy < sy2); 1992 - if (spixels != 0.0) 1993 - { 1994 - if (!is_nodata) 1995 - avg /= spixels; 1996 - } 1997 - /* setting the destination pixel */ 1998 - p = thumbnail->pixels + (y * thumbnail->scanline_width); 1999 - if (thumbnail->pixel_format == GG_PIXEL_GRID) 2000 - { 2001 - p += x * (thumbnail->bits_per_sample / 8); 2002 - switch (thumbnail->sample_format) 2003 - { 2004 - case GGRAPH_SAMPLE_INT: 2005 - if (thumbnail->bits_per_sample == 16) 2006 - { 2007 - p_short = (short *) p; 2008 - if (is_nodata) 2009 - *p_short = 2010 - (short) (thumbnail->no_data_value); 2011 - else 2012 - *p_short = (short) avg; 2013 - } 2014 - else 2015 - { 2016 - p_int = (int *) p; 2017 - if (is_nodata) 2018 - *p_int = (int) (thumbnail->no_data_value); 2019 - else 2020 - *p_int = (int) avg; 2021 - } 2022 - break; 2023 - case GGRAPH_SAMPLE_UINT: 2024 - if (thumbnail->bits_per_sample == 16) 2025 - { 2026 - p_ushort = (unsigned short *) p; 2027 - if (is_nodata) 2028 - *p_ushort = 2029 - (unsigned 2030 - short) (thumbnail->no_data_value); 2031 - else 2032 - *p_ushort = (unsigned short) avg; 2033 - } 2034 - else 2035 - { 2036 - p_uint = (unsigned int *) p; 2037 - if (is_nodata) 2038 - *p_uint = 2039 - (unsigned 2040 - int) (thumbnail->no_data_value); 2041 - else 2042 - *p_uint = (unsigned int) avg; 2043 - } 2044 - break; 2045 - case GGRAPH_SAMPLE_FLOAT: 2046 - if (thumbnail->bits_per_sample == 32) 2047 - { 2048 - p_float = (float *) p; 2049 - if (is_nodata) 2050 - *p_float = 2051 - (float) (thumbnail->no_data_value); 2052 - else 2053 - *p_float = (float) avg; 2054 - } 2055 - else 2056 - { 2057 - p_double = (double *) p; 2058 - if (is_nodata) 2059 - *p_double = thumbnail->no_data_value; 2060 - else 2061 - *p_double = avg; 2062 - } 2063 - break; 2064 - }; 2065 - } 2066 - } 2067 - } 2068 -} 2069 - 2070 -GGRAPH_PRIVATE int 2071 -gg_convert_image_to_grid_int16 (const gGraphImagePtr img) 2072 -{ 2073 -/* converting this grid-image to Int16 */ 2074 - int x; 2075 - int y; 2076 - void *pixels; 2077 - short value; 2078 - unsigned char *p_in; 2079 - short *p_out; 2080 - 2081 - if (img->pixel_format != GG_PIXEL_GRID) 2082 - return GGRAPH_INVALID_IMAGE; 2083 - 2084 - if (img->sample_format == GGRAPH_SAMPLE_INT && img->bits_per_sample == 16) 2085 - return GGRAPH_OK; 2086 - 2087 - pixels = malloc (img->width * img->height * sizeof (short)); 2088 - if (!pixels) 2089 - return GGRAPH_INSUFFICIENT_MEMORY; 2090 - for (y = 0; y < img->height; y++) 2091 - { 2092 - /* processing any scanline */ 2093 - p_in = img->pixels + (y * img->scanline_width); 2094 - p_out = pixels; 2095 - p_out += (y * img->width); 2096 - for (x = 0; x < img->width; x++) 2097 - { 2098 - /* retrieving the origin pixel */ 2099 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2100 - && img->bits_per_sample == 16) 2101 - { 2102 - value = (short) *((unsigned short *) p_in); 2103 - p_in += sizeof (unsigned short); 2104 - } 2105 - if (img->sample_format == GGRAPH_SAMPLE_INT 2106 - && img->bits_per_sample == 32) 2107 - { 2108 - value = (short) *((int *) p_in); 2109 - p_in += sizeof (int); 2110 - } 2111 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2112 - && img->bits_per_sample == 32) 2113 - { 2114 - value = (short) *((unsigned int *) p_in); 2115 - p_in += sizeof (unsigned int); 2116 - } 2117 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2118 - && img->bits_per_sample == 32) 2119 - { 2120 - value = (short) *((float *) p_in); 2121 - p_in += sizeof (float); 2122 - } 2123 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2124 - && img->bits_per_sample == 64) 2125 - { 2126 - value = (short) *((double *) p_in); 2127 - p_in += sizeof (double); 2128 - } 2129 - /* setting the destination pixel */ 2130 - *p_out++ = value; 2131 - } 2132 - } 2133 - 2134 - free (img->pixels); 2135 - img->pixels = pixels; 2136 - img->pixel_format = GG_PIXEL_GRID; 2137 - img->scanline_width = img->width * sizeof (short); 2138 - img->pixel_size = sizeof (short); 2139 - img->sample_format = GGRAPH_SAMPLE_INT; 2140 - img->bits_per_sample = 16; 2141 - return GGRAPH_OK; 2142 -} 2143 - 2144 -GGRAPH_PRIVATE int 2145 -gg_convert_image_to_grid_uint16 (const gGraphImagePtr img) 2146 -{ 2147 -/* converting this grid-image to UInt16 */ 2148 - int x; 2149 - int y; 2150 - void *pixels; 2151 - unsigned short value; 2152 - unsigned char *p_in; 2153 - unsigned short *p_out; 2154 - 2155 - if (img->pixel_format != GG_PIXEL_GRID) 2156 - return GGRAPH_INVALID_IMAGE; 2157 - 2158 - if (img->sample_format == GGRAPH_SAMPLE_UINT && img->bits_per_sample == 16) 2159 - return GGRAPH_OK; 2160 - 2161 - pixels = malloc (img->width * img->height * sizeof (unsigned short)); 2162 - if (!pixels) 2163 - return GGRAPH_INSUFFICIENT_MEMORY; 2164 - for (y = 0; y < img->height; y++) 2165 - { 2166 - /* processing any scanline */ 2167 - p_in = img->pixels + (y * img->scanline_width); 2168 - p_out = pixels; 2169 - p_out += (y * img->width); 2170 - for (x = 0; x < img->width; x++) 2171 - { 2172 - /* retrieving the origin pixel */ 2173 - if (img->sample_format == GGRAPH_SAMPLE_INT 2174 - && img->bits_per_sample == 16) 2175 - { 2176 - value = (unsigned short) *((short *) p_in); 2177 - p_in += sizeof (short); 2178 - } 2179 - if (img->sample_format == GGRAPH_SAMPLE_INT 2180 - && img->bits_per_sample == 32) 2181 - { 2182 - value = (unsigned short) *((int *) p_in); 2183 - p_in += sizeof (int); 2184 - } 2185 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2186 - && img->bits_per_sample == 32) 2187 - { 2188 - value = (unsigned short) *((unsigned int *) p_in); 2189 - p_in += sizeof (unsigned int); 2190 - } 2191 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2192 - && img->bits_per_sample == 32) 2193 - { 2194 - value = (unsigned short) *((float *) p_in); 2195 - p_in += sizeof (float); 2196 - } 2197 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2198 - && img->bits_per_sample == 64) 2199 - { 2200 - value = (unsigned short) *((double *) p_in); 2201 - p_in += sizeof (double); 2202 - } 2203 - /* setting the destination pixel */ 2204 - *p_out++ = value; 2205 - } 2206 - } 2207 - 2208 - free (img->pixels); 2209 - img->pixels = pixels; 2210 - img->pixel_format = GG_PIXEL_GRID; 2211 - img->scanline_width = img->width * sizeof (unsigned short); 2212 - img->pixel_size = sizeof (unsigned short); 2213 - img->sample_format = GGRAPH_SAMPLE_UINT; 2214 - img->bits_per_sample = 16; 2215 - return GGRAPH_OK; 2216 -} 2217 - 2218 -GGRAPH_PRIVATE int 2219 -gg_convert_image_to_grid_int32 (const gGraphImagePtr img) 2220 -{ 2221 -/* converting this grid-image to Int32 */ 2222 - int x; 2223 - int y; 2224 - void *pixels; 2225 - int value; 2226 - unsigned char *p_in; 2227 - int *p_out; 2228 - 2229 - if (img->pixel_format != GG_PIXEL_GRID) 2230 - return GGRAPH_INVALID_IMAGE; 2231 - 2232 - if (img->sample_format == GGRAPH_SAMPLE_INT && img->bits_per_sample == 32) 2233 - return GGRAPH_OK; 2234 - 2235 - pixels = malloc (img->width * img->height * sizeof (int)); 2236 - if (!pixels) 2237 - return GGRAPH_INSUFFICIENT_MEMORY; 2238 - for (y = 0; y < img->height; y++) 2239 - { 2240 - /* processing any scanline */ 2241 - p_in = img->pixels + (y * img->scanline_width); 2242 - p_out = pixels; 2243 - p_out += (y * img->width); 2244 - for (x = 0; x < img->width; x++) 2245 - { 2246 - /* retrieving the origin pixel */ 2247 - if (img->sample_format == GGRAPH_SAMPLE_INT 2248 - && img->bits_per_sample == 16) 2249 - { 2250 - value = (int) *((short *) p_in); 2251 - p_in += sizeof (short); 2252 - } 2253 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2254 - && img->bits_per_sample == 16) 2255 - { 2256 - value = (int) *((unsigned short *) p_in); 2257 - p_in += sizeof (unsigned short); 2258 - } 2259 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2260 - && img->bits_per_sample == 32) 2261 - { 2262 - value = (int) *((unsigned int *) p_in); 2263 - p_in += sizeof (unsigned int); 2264 - } 2265 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2266 - && img->bits_per_sample == 32) 2267 - { 2268 - value = (int) *((float *) p_in); 2269 - p_in += sizeof (float); 2270 - } 2271 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2272 - && img->bits_per_sample == 64) 2273 - { 2274 - value = (int) *((double *) p_in); 2275 - p_in += sizeof (double); 2276 - } 2277 - /* setting the destination pixel */ 2278 - *p_out++ = value; 2279 - } 2280 - } 2281 - 2282 - free (img->pixels); 2283 - img->pixels = pixels; 2284 - img->pixel_format = GG_PIXEL_GRID; 2285 - img->scanline_width = img->width * sizeof (int); 2286 - img->pixel_size = sizeof (int); 2287 - img->sample_format = GGRAPH_SAMPLE_INT; 2288 - img->bits_per_sample = 32; 2289 - return GGRAPH_OK; 2290 -} 2291 - 2292 -GGRAPH_PRIVATE int 2293 -gg_convert_image_to_grid_uint32 (const gGraphImagePtr img) 2294 -{ 2295 -/* converting this grid-image to UInt32 */ 2296 - int x; 2297 - int y; 2298 - void *pixels; 2299 - unsigned int value; 2300 - unsigned char *p_in; 2301 - unsigned int *p_out; 2302 - 2303 - if (img->pixel_format != GG_PIXEL_GRID) 2304 - return GGRAPH_INVALID_IMAGE; 2305 - 2306 - if (img->sample_format == GGRAPH_SAMPLE_UINT && img->bits_per_sample == 32) 2307 - return GGRAPH_OK; 2308 - 2309 - pixels = malloc (img->width * img->height * sizeof (unsigned short)); 2310 - if (!pixels) 2311 - return GGRAPH_INSUFFICIENT_MEMORY; 2312 - for (y = 0; y < img->height; y++) 2313 - { 2314 - /* processing any scanline */ 2315 - p_in = img->pixels + (y * img->scanline_width); 2316 - p_out = pixels; 2317 - p_out += (y * img->width); 2318 - for (x = 0; x < img->width; x++) 2319 - { 2320 - /* retrieving the origin pixel */ 2321 - if (img->sample_format == GGRAPH_SAMPLE_INT 2322 - && img->bits_per_sample == 16) 2323 - { 2324 - value = (unsigned int) *((short *) p_in); 2325 - p_in += sizeof (short); 2326 - } 2327 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2328 - && img->bits_per_sample == 16) 2329 - { 2330 - value = (unsigned int) *((unsigned short *) p_in); 2331 - p_in += sizeof (unsigned short); 2332 - } 2333 - if (img->sample_format == GGRAPH_SAMPLE_INT 2334 - && img->bits_per_sample == 32) 2335 - { 2336 - value = (unsigned int) *((int *) p_in); 2337 - p_in += sizeof (int); 2338 - } 2339 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2340 - && img->bits_per_sample == 32) 2341 - { 2342 - value = (unsigned int) *((float *) p_in); 2343 - p_in += sizeof (float); 2344 - } 2345 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2346 - && img->bits_per_sample == 64) 2347 - { 2348 - value = (unsigned int) *((double *) p_in); 2349 - p_in += sizeof (double); 2350 - } 2351 - /* setting the destination pixel */ 2352 - *p_out++ = value; 2353 - } 2354 - } 2355 - 2356 - free (img->pixels); 2357 - img->pixels = pixels; 2358 - img->pixel_format = GG_PIXEL_GRID; 2359 - img->scanline_width = img->width * sizeof (unsigned int); 2360 - img->pixel_size = sizeof (unsigned int); 2361 - img->sample_format = GGRAPH_SAMPLE_UINT; 2362 - img->bits_per_sample = 32; 2363 - return GGRAPH_OK; 2364 -} 2365 - 2366 -GGRAPH_PRIVATE int 2367 -gg_convert_image_to_grid_float (const gGraphImagePtr img) 2368 -{ 2369 -/* converting this grid-image to Float */ 2370 - int x; 2371 - int y; 2372 - void *pixels; 2373 - float value; 2374 - unsigned char *p_in; 2375 - float *p_out; 2376 - 2377 - if (img->pixel_format != GG_PIXEL_GRID) 2378 - return GGRAPH_INVALID_IMAGE; 2379 - 2380 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT && img->bits_per_sample == 32) 2381 - return GGRAPH_OK; 2382 - 2383 - pixels = malloc (img->width * img->height * sizeof (short)); 2384 - if (!pixels) 2385 - return GGRAPH_INSUFFICIENT_MEMORY; 2386 - for (y = 0; y < img->height; y++) 2387 - { 2388 - /* processing any scanline */ 2389 - p_in = img->pixels + (y * img->scanline_width); 2390 - p_out = pixels; 2391 - p_out += (y * img->width); 2392 - for (x = 0; x < img->width; x++) 2393 - { 2394 - /* retrieving the origin pixel */ 2395 - if (img->sample_format == GGRAPH_SAMPLE_INT 2396 - && img->bits_per_sample == 16) 2397 - { 2398 - value = (float) *((short *) p_in); 2399 - p_in += sizeof (short); 2400 - } 2401 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2402 - && img->bits_per_sample == 16) 2403 - { 2404 - value = (float) *((unsigned short *) p_in); 2405 - p_in += sizeof (unsigned short); 2406 - } 2407 - if (img->sample_format == GGRAPH_SAMPLE_INT 2408 - && img->bits_per_sample == 32) 2409 - { 2410 - value = (float) *((int *) p_in); 2411 - p_in += sizeof (int); 2412 - } 2413 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2414 - && img->bits_per_sample == 32) 2415 - { 2416 - value = (float) *((unsigned int *) p_in); 2417 - p_in += sizeof (unsigned int); 2418 - } 2419 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2420 - && img->bits_per_sample == 64) 2421 - { 2422 - value = (float) *((double *) p_in); 2423 - p_in += sizeof (double); 2424 - } 2425 - /* setting the destination pixel */ 2426 - *p_out++ = value; 2427 - } 2428 - } 2429 - 2430 - free (img->pixels); 2431 - img->pixels = pixels; 2432 - img->pixel_format = GG_PIXEL_GRID; 2433 - img->scanline_width = img->width * sizeof (float); 2434 - img->pixel_size = sizeof (float); 2435 - img->sample_format = GGRAPH_SAMPLE_INT; 2436 - img->bits_per_sample = 32; 2437 - return GGRAPH_OK; 2438 -} 2439 - 2440 -GGRAPH_PRIVATE int 2441 -gg_convert_image_to_grid_double (const gGraphImagePtr img) 2442 -{ 2443 -/* converting this grid-image to Double */ 2444 - int x; 2445 - int y; 2446 - void *pixels; 2447 - double value; 2448 - unsigned char *p_in; 2449 - double *p_out; 2450 - 2451 - if (img->pixel_format != GG_PIXEL_GRID) 2452 - return GGRAPH_INVALID_IMAGE; 2453 - 2454 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT && img->bits_per_sample == 64) 2455 - return GGRAPH_OK; 2456 - 2457 - pixels = malloc (img->width * img->height * sizeof (short)); 2458 - if (!pixels) 2459 - return GGRAPH_INSUFFICIENT_MEMORY; 2460 - for (y = 0; y < img->height; y++) 2461 - { 2462 - /* processing any scanline */ 2463 - p_in = img->pixels + (y * img->scanline_width); 2464 - p_out = pixels; 2465 - p_out += (y * img->width); 2466 - for (x = 0; x < img->width; x++) 2467 - { 2468 - /* retrieving the origin pixel */ 2469 - if (img->sample_format == GGRAPH_SAMPLE_INT 2470 - && img->bits_per_sample == 16) 2471 - { 2472 - value = (double) *((short *) p_in); 2473 - p_in += sizeof (short); 2474 - } 2475 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2476 - && img->bits_per_sample == 16) 2477 - { 2478 - value = (double) *((unsigned short *) p_in); 2479 - p_in += sizeof (unsigned short); 2480 - } 2481 - if (img->sample_format == GGRAPH_SAMPLE_INT 2482 - && img->bits_per_sample == 32) 2483 - { 2484 - value = (double) *((int *) p_in); 2485 - p_in += sizeof (int); 2486 - } 2487 - if (img->sample_format == GGRAPH_SAMPLE_UINT 2488 - && img->bits_per_sample == 32) 2489 - { 2490 - value = (double) *((unsigned int *) p_in); 2491 - p_in += sizeof (unsigned int); 2492 - } 2493 - if (img->sample_format == GGRAPH_SAMPLE_FLOAT 2494 - && img->bits_per_sample == 32) 2495 - { 2496 - value = (double) *((float *) p_in); 2497 - p_in += sizeof (float); 2498 - } 2499 - /* setting the destination pixel */ 2500 - *p_out++ = value; 2501 - } 2502 - } 2503 - 2504 - free (img->pixels); 2505 - img->pixels = pixels; 2506 - img->pixel_format = GG_PIXEL_GRID; 2507 - img->scanline_width = img->width * sizeof (double); 2508 - img->pixel_size = sizeof (double); 2509 - img->sample_format = GGRAPH_SAMPLE_FLOAT; 2510 - img->bits_per_sample = 64; 2511 - return GGRAPH_OK; 2512 -} 2513 - 2514 -GGRAPH_PRIVATE int 2515 -gg_convert_image_to_rgb (const gGraphImagePtr img) 2516 -{ 2517 -/* converting this image to RGB */ 2518 - int x; 2519 - int y; 2520 - void *pixels; 2521 - unsigned char red; 2522 - unsigned char green; 2523 - unsigned char blue; 2524 - unsigned char *p_in; 2525 - unsigned char *p_out; 2526 - 2527 - if (img->pixel_format == GG_PIXEL_RGB || img->pixel_format == GG_PIXEL_RGBA 2528 - || img->pixel_format == GG_PIXEL_ARGB 2529 - || img->pixel_format == GG_PIXEL_BGR 2530 - || img->pixel_format == GG_PIXEL_BGRA 2531 - || img->pixel_format == GG_PIXEL_GRAYSCALE 2532 - || img->pixel_format == GG_PIXEL_PALETTE) 2533 - ; 2534 - else 2535 - return GGRAPH_INVALID_IMAGE; 2536 - 2537 - if (img->pixel_format == GG_PIXEL_RGB) 2538 - return GGRAPH_OK; 2539 - 2540 - pixels = malloc (img->width * img->height * 3); 2541 - if (!pixels) 2542 - return GGRAPH_INSUFFICIENT_MEMORY; 2543 - for (y = 0; y < img->height; y++) 2544 - { 2545 - /* processing any scanline */ 2546 - p_in = img->pixels + (y * img->scanline_width); 2547 - p_out = pixels; 2548 - p_out += (y * img->width * 3); 2549 - for (x = 0; x < img->width; x++) 2550 - { 2551 - /* retrieving the origin pixel */ 2552 - if (img->pixel_format == GG_PIXEL_RGBA) 2553 - { 2554 - red = *p_in++; 2555 - green = *p_in++; 2556 - blue = *p_in++; 2557 - p_in++; /* skipping alpha */ 2558 - } 2559 - else if (img->pixel_format == GG_PIXEL_ARGB) 2560 - { 2561 - p_in++; /* skipping alpha */ 2562 - red = *p_in++; 2563 - green = *p_in++; 2564 - blue = *p_in++; 2565 - } 2566 - else if (img->pixel_format == GG_PIXEL_BGR) 2567 - { 2568 - blue = *p_in++; 2569 - green = *p_in++; 2570 - red = *p_in++; 2571 - } 2572 - else if (img->pixel_format == GG_PIXEL_BGRA) 2573 - { 2574 - blue = *p_in++; 2575 - green = *p_in++; 2576 - red = *p_in++; 2577 - p_in++; /* skipping alpha */ 2578 - } 2579 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2580 - { 2581 - red = *p_in++; 2582 - green = red; 2583 - blue = red; 2584 - 2585 - } 2586 - else if (img->pixel_format == GG_PIXEL_PALETTE) 2587 - { 2588 - int index = *p_in++; 2589 - red = img->palette_red[index]; 2590 - green = img->palette_green[index]; 2591 - blue = img->palette_blue[index]; 2592 - } 2593 - /* setting the destination pixel */ 2594 - *p_out++ = red; 2595 - *p_out++ = green; 2596 - *p_out++ = blue; 2597 - } 2598 - } 2599 - 2600 - free (img->pixels); 2601 - img->pixels = pixels; 2602 - img->pixel_format = GG_PIXEL_RGB; 2603 - img->scanline_width = img->width * 3; 2604 - img->pixel_size = 3; 2605 - img->max_palette = 0; 2606 - return GGRAPH_OK; 2607 -} 2608 - 2609 -GGRAPH_PRIVATE int 2610 -gg_convert_image_to_rgba (const gGraphImagePtr img) 2611 -{ 2612 -/* converting this image to RGBA */ 2613 - int x; 2614 - int y; 2615 - void *pixels; 2616 - unsigned char red; 2617 - unsigned char green; 2618 - unsigned char blue; 2619 - unsigned char alpha; 2620 - unsigned char *p_in; 2621 - unsigned char *p_out; 2622 - 2623 - if (img->pixel_format == GG_PIXEL_RGB || img->pixel_format == GG_PIXEL_RGBA 2624 - || img->pixel_format == GG_PIXEL_ARGB 2625 - || img->pixel_format == GG_PIXEL_BGR 2626 - || img->pixel_format == GG_PIXEL_BGRA 2627 - || img->pixel_format == GG_PIXEL_GRAYSCALE 2628 - || img->pixel_format == GG_PIXEL_PALETTE) 2629 - ; 2630 - else 2631 - return GGRAPH_INVALID_IMAGE; 2632 - 2633 - if (img->pixel_format == GG_PIXEL_RGBA) 2634 - return GGRAPH_OK; 2635 - 2636 - pixels = malloc (img->width * img->height * 4); 2637 - if (!pixels) 2638 - return GGRAPH_INSUFFICIENT_MEMORY; 2639 - for (y = 0; y < img->height; y++) 2640 - { 2641 - /* processing any scanline */ 2642 - p_in = img->pixels + (y * img->scanline_width); 2643 - p_out = pixels; 2644 - p_out += (y * img->width * 4); 2645 - for (x = 0; x < img->width; x++) 2646 - { 2647 - /* retrieving the origin pixel */ 2648 - if (img->pixel_format == GG_PIXEL_RGB) 2649 - { 2650 - red = *p_in++; 2651 - green = *p_in++; 2652 - blue = *p_in++; 2653 - alpha = 255; 2654 - } 2655 - else if (img->pixel_format == GG_PIXEL_ARGB) 2656 - { 2657 - alpha = *p_in++; 2658 - red = *p_in++; 2659 - green = *p_in++; 2660 - blue = *p_in++; 2661 - } 2662 - else if (img->pixel_format == GG_PIXEL_BGR) 2663 - { 2664 - blue = *p_in++; 2665 - green = *p_in++; 2666 - red = *p_in++; 2667 - alpha = 255; 2668 - } 2669 - else if (img->pixel_format == GG_PIXEL_BGRA) 2670 - { 2671 - blue = *p_in++; 2672 - green = *p_in++; 2673 - red = *p_in++; 2674 - alpha = *p_in++; 2675 - } 2676 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2677 - { 2678 - red = *p_in++; 2679 - green = red; 2680 - blue = red; 2681 - alpha = 255; 2682 - } 2683 - else if (img->pixel_format == GG_PIXEL_PALETTE) 2684 - { 2685 - int index = *p_in++; 2686 - red = img->palette_red[index]; 2687 - green = img->palette_green[index]; 2688 - blue = img->palette_blue[index]; 2689 - alpha = 255; 2690 - } 2691 - /* setting the destination pixel */ 2692 - *p_out++ = red; 2693 - *p_out++ = green; 2694 - *p_out++ = blue; 2695 - *p_out++ = alpha; 2696 - } 2697 - } 2698 - 2699 - free (img->pixels); 2700 - img->pixels = pixels; 2701 - img->pixel_format = GG_PIXEL_RGBA; 2702 - img->scanline_width = img->width * 4; 2703 - img->pixel_size = 4; 2704 - img->max_palette = 0; 2705 - return GGRAPH_OK; 2706 -} 2707 - 2708 -GGRAPH_PRIVATE int 2709 -gg_convert_image_to_argb (const gGraphImagePtr img) 2710 -{ 2711 -/* converting this image to ARGB */ 2712 - int x; 2713 - int y; 2714 - void *pixels; 2715 - unsigned char red; 2716 - unsigned char green; 2717 - unsigned char blue; 2718 - unsigned char alpha; 2719 - unsigned char *p_in; 2720 - unsigned char *p_out; 2721 - 2722 - if (img->pixel_format == GG_PIXEL_RGB || img->pixel_format == GG_PIXEL_RGBA 2723 - || img->pixel_format == GG_PIXEL_ARGB 2724 - || img->pixel_format == GG_PIXEL_BGR 2725 - || img->pixel_format == GG_PIXEL_BGRA 2726 - || img->pixel_format == GG_PIXEL_GRAYSCALE 2727 - || img->pixel_format == GG_PIXEL_PALETTE) 2728 - ; 2729 - else 2730 - return GGRAPH_INVALID_IMAGE; 2731 - 2732 - if (img->pixel_format == GG_PIXEL_ARGB) 2733 - return GGRAPH_OK; 2734 - 2735 - pixels = malloc (img->width * img->height * 4); 2736 - if (!pixels) 2737 - return GGRAPH_INSUFFICIENT_MEMORY; 2738 - for (y = 0; y < img->height; y++) 2739 - { 2740 - /* processing any scanline */ 2741 - p_in = img->pixels + (y * img->scanline_width); 2742 - p_out = pixels; 2743 - p_out += (y * img->width * 4); 2744 - for (x = 0; x < img->width; x++) 2745 - { 2746 - /* retrieving the origin pixel */ 2747 - if (img->pixel_format == GG_PIXEL_RGB) 2748 - { 2749 - red = *p_in++; 2750 - green = *p_in++; 2751 - blue = *p_in++; 2752 - alpha = 255; 2753 - } 2754 - else if (img->pixel_format == GG_PIXEL_RGBA) 2755 - { 2756 - red = *p_in++; 2757 - green = *p_in++; 2758 - blue = *p_in++; 2759 - alpha = *p_in++; 2760 - } 2761 - else if (img->pixel_format == GG_PIXEL_BGR) 2762 - { 2763 - blue = *p_in++; 2764 - green = *p_in++; 2765 - red = *p_in++; 2766 - alpha = 255; 2767 - } 2768 - else if (img->pixel_format == GG_PIXEL_BGRA) 2769 - { 2770 - blue = *p_in++; 2771 - green = *p_in++; 2772 - red = *p_in++; 2773 - alpha = *p_in++; 2774 - } 2775 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2776 - { 2777 - red = *p_in++; 2778 - green = red; 2779 - blue = red; 2780 - alpha = 255; 2781 - } 2782 - else if (img->pixel_format == GG_PIXEL_PALETTE) 2783 - { 2784 - int index = *p_in++; 2785 - red = img->palette_red[index]; 2786 - green = img->palette_green[index]; 2787 - blue = img->palette_blue[index]; 2788 - alpha = 255; 2789 - } 2790 - /* setting the destination pixel */ 2791 - *p_out++ = alpha; 2792 - *p_out++ = red; 2793 - *p_out++ = green; 2794 - *p_out++ = blue; 2795 - } 2796 - } 2797 - 2798 - free (img->pixels); 2799 - img->pixels = pixels; 2800 - img->pixel_format = GG_PIXEL_ARGB; 2801 - img->scanline_width = img->width * 4; 2802 - img->pixel_size = 4; 2803 - img->max_palette = 0; 2804 - return GGRAPH_OK; 2805 -} 2806 - 2807 -GGRAPH_PRIVATE int 2808 -gg_convert_image_to_bgr (const gGraphImagePtr img) 2809 -{ 2810 -/* converting this image to BGR */ 2811 - int x; 2812 - int y; 2813 - void *pixels; 2814 - unsigned char red; 2815 - unsigned char green; 2816 - unsigned char blue; 2817 - unsigned char *p_in; 2818 - unsigned char *p_out; 2819 - 2820 - if (img->pixel_format == GG_PIXEL_RGB || img->pixel_format == GG_PIXEL_RGBA 2821 - || img->pixel_format == GG_PIXEL_ARGB 2822 - || img->pixel_format == GG_PIXEL_BGR 2823 - || img->pixel_format == GG_PIXEL_BGRA 2824 - || img->pixel_format == GG_PIXEL_GRAYSCALE 2825 - || img->pixel_format == GG_PIXEL_PALETTE) 2826 - ; 2827 - else 2828 - return GGRAPH_INVALID_IMAGE; 2829 - 2830 - if (img->pixel_format == GG_PIXEL_BGR) 2831 - return GGRAPH_OK; 2832 - 2833 - pixels = malloc (img->width * img->height * 3); 2834 - if (!pixels) 2835 - return GGRAPH_INSUFFICIENT_MEMORY; 2836 - for (y = 0; y < img->height; y++) 2837 - { 2838 - /* processing any scanline */ 2839 - p_in = img->pixels + (y * img->scanline_width); 2840 - p_out = pixels; 2841 - p_out += (y * img->width * 3); 2842 - for (x = 0; x < img->width; x++) 2843 - { 2844 - /* retrieving the origin pixel */ 2845 - if (img->pixel_format == GG_PIXEL_RGB) 2846 - { 2847 - red = *p_in++; 2848 - green = *p_in++; 2849 - blue = *p_in++; 2850 - } 2851 - else if (img->pixel_format == GG_PIXEL_RGBA) 2852 - { 2853 - red = *p_in++; 2854 - green = *p_in++; 2855 - blue = *p_in++; 2856 - p_in++; /* skipping alpha */ 2857 - } 2858 - else if (img->pixel_format == GG_PIXEL_ARGB) 2859 - { 2860 - p_in++; /* skipping alpha */ 2861 - blue = *p_in++; 2862 - green = *p_in++; 2863 - red = *p_in++; 2864 - } 2865 - else if (img->pixel_format == GG_PIXEL_BGRA) 2866 - { 2867 - blue = *p_in++; 2868 - green = *p_in++; 2869 - red = *p_in++; 2870 - p_in++; /* skipping alpha */ 2871 - } 2872 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2873 - { 2874 - red = *p_in++; 2875 - green = red; 2876 - blue = red; 2877 - } 2878 - else if (img->pixel_format == GG_PIXEL_PALETTE) 2879 - { 2880 - int index = *p_in++; 2881 - red = img->palette_red[index]; 2882 - green = img->palette_green[index]; 2883 - blue = img->palette_blue[index]; 2884 - } 2885 - /* setting the destination pixel */ 2886 - *p_out++ = blue; 2887 - *p_out++ = green; 2888 - *p_out++ = red; 2889 - } 2890 - } 2891 - 2892 - free (img->pixels); 2893 - img->pixels = pixels; 2894 - img->pixel_format = GG_PIXEL_BGR; 2895 - img->scanline_width = img->width * 3; 2896 - img->pixel_size = 3; 2897 - img->max_palette = 0; 2898 - return GGRAPH_OK; 2899 -} 2900 - 2901 -GGRAPH_PRIVATE int 2902 -gg_convert_image_to_bgra (const gGraphImagePtr img) 2903 -{ 2904 -/* converting this image to BGRA */ 2905 - int x; 2906 - int y; 2907 - void *pixels; 2908 - unsigned char red; 2909 - unsigned char green; 2910 - unsigned char blue; 2911 - unsigned char alpha; 2912 - unsigned char *p_in; 2913 - unsigned char *p_out; 2914 - 2915 - if (img->pixel_format == GG_PIXEL_RGB || img->pixel_format == GG_PIXEL_RGBA 2916 - || img->pixel_format == GG_PIXEL_ARGB 2917 - || img->pixel_format == GG_PIXEL_BGR 2918 - || img->pixel_format == GG_PIXEL_BGRA 2919 - || img->pixel_format == GG_PIXEL_GRAYSCALE 2920 - || img->pixel_format == GG_PIXEL_PALETTE) 2921 - ; 2922 - else 2923 - return GGRAPH_INVALID_IMAGE; 2924 - 2925 - if (img->pixel_format == GG_PIXEL_ARGB) 2926 - return GGRAPH_OK; 2927 - 2928 - pixels = malloc (img->width * img->height * 4); 2929 - if (!pixels) 2930 - return GGRAPH_INSUFFICIENT_MEMORY; 2931 - for (y = 0; y < img->height; y++) 2932 - { 2933 - /* processing any scanline */ 2934 - p_in = img->pixels + (y * img->scanline_width); 2935 - p_out = pixels; 2936 - p_out += (y * img->width * 4); 2937 - for (x = 0; x < img->width; x++) 2938 - { 2939 - /* retrieving the origin pixel */ 2940 - if (img->pixel_format == GG_PIXEL_RGB) 2941 - { 2942 - red = *p_in++; 2943 - green = *p_in++; 2944 - blue = *p_in++; 2945 - alpha = 255; 2946 - } 2947 - else if (img->pixel_format == GG_PIXEL_RGBA) 2948 - { 2949 - red = *p_in++; 2950 - green = *p_in++; 2951 - blue = *p_in++; 2952 - alpha = *p_in++; 2953 - } 2954 - else if (img->pixel_format == GG_PIXEL_ARGB) 2955 - { 2956 - alpha = *p_in++; 2957 - blue = *p_in++; 2958 - green = *p_in++; 2959 - red = *p_in++; 2960 - } 2961 - else if (img->pixel_format == GG_PIXEL_BGR) 2962 - { 2963 - blue = *p_in++; 2964 - green = *p_in++; 2965 - red = *p_in++; 2966 - alpha = 255; 2967 - } 2968 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2969 - { 2970 - red = *p_in++; 2971 - green = red; 2972 - blue = red; 2973 - alpha = 255; 2974 - } 2975 - else if (img->pixel_format == GG_PIXEL_PALETTE) 2976 - { 2977 - int index = *p_in++; 2978 - red = img->palette_red[index]; 2979 - green = img->palette_green[index]; 2980 - blue = img->palette_blue[index]; 2981 - alpha = 255; 2982 - } 2983 - /* setting the destination pixel */ 2984 - *p_out++ = blue; 2985 - *p_out++ = green; 2986 - *p_out++ = red; 2987 - *p_out++ = alpha; 2988 - } 2989 - } 2990 - 2991 - free (img->pixels); 2992 - img->pixels = pixels; 2993 - img->pixel_format = GG_PIXEL_BGRA; 2994 - img->scanline_width = img->width * 4; 2995 - img->pixel_size = 4; 2996 - img->max_palette = 0; 2997 - return GGRAPH_OK; 2998 -} 2999 - 3000 -GGRAPH_PRIVATE int 3001 -gg_convert_image_to_grayscale (const gGraphImagePtr img) 3002 -{ 3003 -/* converting this image to GRAYSCALE */ 3004 - int x; 3005 - int y; 3006 - void *pixels; 3007 - unsigned char red; 3008 - unsigned char green; 3009 - unsigned char blue; 3010 - unsigned char gray; 3011 - unsigned char *p_in; 3012 - unsigned char *p_out; 3013 - 3014 - if (img->pixel_format == GG_PIXEL_RGB || img->pixel_format == GG_PIXEL_RGBA 3015 - || img->pixel_format == GG_PIXEL_ARGB 3016 - || img->pixel_format == GG_PIXEL_BGR 3017 - || img->pixel_format == GG_PIXEL_BGRA 3018 - || img->pixel_format == GG_PIXEL_GRAYSCALE 3019 - || img->pixel_format == GG_PIXEL_PALETTE) 3020 - ; 3021 - else 3022 - return GGRAPH_INVALID_IMAGE; 3023 - 3024 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 3025 - return GGRAPH_OK; 3026 - 3027 - pixels = malloc (img->width * img->height); 3028 - if (!pixels) 3029 - return GGRAPH_INSUFFICIENT_MEMORY; 3030 - for (y = 0; y < img->height; y++) 3031 - { 3032 - /* processing any scanline */ 3033 - p_in = img->pixels + (y * img->scanline_width); 3034 - p_out = pixels; 3035 - p_out += (y * img->width); 3036 - for (x = 0; x < img->width; x++) 3037 - { 3038 - /* retrieving the origin pixel */ 3039 - if (img->pixel_format == GG_PIXEL_RGB) 3040 - { 3041 - red = *p_in++; 3042 - green = *p_in++; 3043 - blue = *p_in++; 3044 - } 3045 - else if (img->pixel_format == GG_PIXEL_RGBA) 3046 - { 3047 - red = *p_in++; 3048 - green = *p_in++; 3049 - blue = *p_in++; 3050 - p_in++; /* skipping alpha */ 3051 - } 3052 - else if (img->pixel_format == GG_PIXEL_ARGB) 3053 - { 3054 - p_in++; /* skipping alpha */ 3055 - blue = *p_in++; 3056 - green = *p_in++; 3057 - red = *p_in++; 3058 - } 3059 - else if (img->pixel_format == GG_PIXEL_BGR) 3060 - { 3061 - blue = *p_in++; 3062 - green = *p_in++; 3063 - red = *p_in++; 3064 - } 3065 - else if (img->pixel_format == GG_PIXEL_BGRA) 3066 - { 3067 - blue = *p_in++; 3068 - green = *p_in++; 3069 - red = *p_in++; 3070 - p_in++; /* skipping alpha */ 3071 - } 3072 - else if (img->pixel_format == GG_PIXEL_PALETTE) 3073 - { 3074 - int index = *p_in++; 3075 - red = img->palette_red[index]; 3076 - green = img->palette_green[index]; 3077 - blue = img->palette_blue[index]; 3078 - } 3079 - /* setting the destination pixel */ 3080 - gray = to_grayscale (red, green, blue); 3081 - *p_out++ = gray; 3082 - } 3083 - } 3084 - 3085 - free (img->pixels); 3086 - img->pixels = pixels; 3087 - img->pixel_format = GG_PIXEL_GRAYSCALE; 3088 - img->scanline_width = img->width; 3089 - img->pixel_size = 1; 3090 - img->max_palette = 0; 3091 - return GGRAPH_OK; 3092 -} 3093 - 3094 -GGRAPH_PRIVATE int 3095 -gg_convert_image_to_palette (const gGraphImagePtr img) 3096 -{ 3097 -/* converting this image to PALETTE */ 3098 - int x; 3099 - int y; 3100 - void *pixels; 3101 - unsigned char red; 3102 - unsigned char green; 3103 - unsigned char blue; 3104 - unsigned char index; 3105 - unsigned char *p_in; 3106 - unsigned char *p_out; 3107 - 3108 - if (img->pixel_format == GG_PIXEL_RGB || img->pixel_format == GG_PIXEL_RGBA 3109 - || img->pixel_format == GG_PIXEL_ARGB 3110 - || img->pixel_format == GG_PIXEL_BGR 3111 - || img->pixel_format == GG_PIXEL_BGRA 3112 - || img->pixel_format == GG_PIXEL_GRAYSCALE 3113 - || img->pixel_format == GG_PIXEL_PALETTE) 3114 - ; 3115 - else 3116 - return GGRAPH_INVALID_IMAGE; 3117 - 3118 - if (img->pixel_format == GG_PIXEL_PALETTE) 3119 - return GGRAPH_OK; 3120 - 3121 - pixels = malloc (img->width * img->height); 3122 - if (!pixels) 3123 - return GGRAPH_INSUFFICIENT_MEMORY; 3124 - img->max_palette = 0; 3125 - for (y = 0; y < img->height; y++) 3126 - { 3127 - /* processing any scanline */ 3128 - p_in = img->pixels + (y * img->scanline_width); 3129 - p_out = pixels; 3130 - p_out += (y * img->width); 3131 - for (x = 0; x < img->width; x++) 3132 - { 3133 - /* retrieving the origin pixel */ 3134 - if (img->pixel_format == GG_PIXEL_RGB) 3135 - { 3136 - red = *p_in++; 3137 - green = *p_in++; 3138 - blue = *p_in++; 3139 - } 3140 - else if (img->pixel_format == GG_PIXEL_RGBA) 3141 - { 3142 - red = *p_in++; 3143 - green = *p_in++; 3144 - blue = *p_in++; 3145 - p_in++; /* skipping alpha */ 3146 - } 3147 - else if (img->pixel_format == GG_PIXEL_ARGB) 3148 - { 3149 - p_in++; /* skipping alpha */ 3150 - blue = *p_in++; 3151 - green = *p_in++; 3152 - red = *p_in++; 3153 - } 3154 - else if (img->pixel_format == GG_PIXEL_BGR) 3155 - { 3156 - blue = *p_in++; 3157 - green = *p_in++; 3158 - red = *p_in++; 3159 - p_in++; /* skipping alpha */ 3160 - } 3161 - else if (img->pixel_format == GG_PIXEL_BGRA) 3162 - { 3163 - blue = *p_in++; 3164 - green = *p_in++; 3165 - red = *p_in++; 3166 - p_in++; /* skipping alpha */ 3167 - } 3168 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 3169 - { 3170 - red = *p_in++; 3171 - green = red; 3172 - blue = red; 3173 - } 3174 - /* setting the destination pixel */ 3175 - index = gg_match_palette (img, red, green, blue); 3176 - *p_out++ = index; 3177 - } 3178 - } 3179 - 3180 - free (img->pixels); 3181 - img->pixels = pixels; 3182 - img->pixel_format = GG_PIXEL_PALETTE; 3183 - img->scanline_width = img->width; 3184 - img->pixel_size = 1; 3185 - return GGRAPH_OK; 3186 -} 3187 - 3188 -GGRAPH_PRIVATE int 3189 -gg_convert_image_to_monochrome (const gGraphImagePtr img) 3190 -{ 3191 -/* converting this image to MONOCHROME */ 3192 - int x; 3193 - int y; 3194 - void *pixels; 3195 - unsigned char red; 3196 - unsigned char green; 3197 - unsigned char blue; 3198 - unsigned char index; 3199 - unsigned char *p_in; 3200 - unsigned char *p_out; 3201 - 3202 - if (img->pixel_format == GG_PIXEL_RGB || img->pixel_format == GG_PIXEL_RGBA 3203 - || img->pixel_format == GG_PIXEL_ARGB 3204 - || img->pixel_format == GG_PIXEL_BGR 3205 - || img->pixel_format == GG_PIXEL_BGRA 3206 - || img->pixel_format == GG_PIXEL_GRAYSCALE 3207 - || img->pixel_format == GG_PIXEL_PALETTE) 3208 - ; 3209 - else 3210 - return GGRAPH_INVALID_IMAGE; 3211 - 3212 - if (img->pixel_format == GG_PIXEL_PALETTE 3213 - && gg_is_image_monochrome_ready (img) == GGRAPH_TRUE) 3214 - return GGRAPH_OK; 3215 - 3216 - pixels = malloc (img->width * img->height); 3217 - if (!pixels) 3218 - return GGRAPH_INSUFFICIENT_MEMORY; 3219 - for (y = 0; y < img->height; y++) 3220 - { 3221 - /* processing any scanline */ 3222 - p_in = img->pixels + (y * img->scanline_width); 3223 - p_out = pixels; 3224 - p_out += (y * img->width); 3225 - for (x = 0; x < img->width; x++) 3226 - { 3227 - /* retrieving the origin pixel */ 3228 - if (img->pixel_format == GG_PIXEL_RGB) 3229 - { 3230 - red = *p_in++; 3231 - green = *p_in++; 3232 - blue = *p_in++; 3233 - } 3234 - else if (img->pixel_format == GG_PIXEL_RGBA) 3235 - { 3236 - red = *p_in++; 3237 - green = *p_in++; 3238 - blue = *p_in++; 3239 - p_in++; /* skipping alpha */ 3240 - } 3241 - else if (img->pixel_format == GG_PIXEL_ARGB) 3242 - { 3243 - p_in++; /* skipping alpha */ 3244 - blue = *p_in++; 3245 - green = *p_in++; 3246 - red = *p_in++; 3247 - } 3248 - else if (img->pixel_format == GG_PIXEL_BGR) 3249 - { 3250 - blue = *p_in++; 3251 - green = *p_in++; 3252 - red = *p_in++; 3253 - p_in++; /* skipping alpha */ 3254 - } 3255 - else if (img->pixel_format == GG_PIXEL_BGRA) 3256 - { 3257 - blue = *p_in++; 3258 - green = *p_in++; 3259 - red = *p_in++; 3260 - p_in++; /* skipping alpha */ 3261 - } 3262 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 3263 - { 3264 - red = *p_in++; 3265 - green = red; 3266 - blue = red; 3267 - } 3268 - else if (img->pixel_format == GG_PIXEL_PALETTE) 3269 - { 3270 - int index = *p_in++; 3271 - red = img->palette_red[index]; 3272 - green = img->palette_green[index]; 3273 - blue = img->palette_blue[index]; 3274 - } 3275 - /* setting the destination pixel */ 3276 - if (red == 0 && green == 0 && blue == 0) 3277 - index = 0; 3278 - else if (red == 255 && green == 255 && blue == 255) 3279 - index = 1; 3280 - else 3281 - { 3282 - /* neither WHITE nor BLACK */ 3283 - unsigned char gray = to_grayscale (red, green, blue); 3284 - if (gray < 128) 3285 - { 3286 - /* defaulting to BLACK */ 3287 - index = 0; 3288 - } 3289 - else 3290 - { 3291 - /* defaulting to WHITE */ 3292 - index = 1; 3293 - } 3294 - } 3295 - *p_out++ = index; 3296 - } 3297 - } 3298 - 3299 - free (img->pixels); 3300 - img->pixels = pixels; 3301 - img->pixel_format = GG_PIXEL_PALETTE; 3302 - img->scanline_width = img->width; 3303 - img->pixel_size = 1; 3304 - img->max_palette = 2; 3305 - img->palette_red[0] = 0; 3306 - img->palette_green[0] = 0; 3307 - img->palette_blue[0] = 0; 3308 - img->palette_red[1] = 255; 3309 - img->palette_green[1] = 255; 3310 - img->palette_blue[1] = 255; 3311 - return GGRAPH_OK; 3312 -} 3313 - 3314 -GGRAPH_PRIVATE int 3315 -gg_is_image_monochrome_ready (gGraphImagePtr img) 3316 -{ 3317 -/* 3318 -/ checking if this Image is into the Monochrome colorspace and ready to be used 3319 -/ expected: palette, 2 colors, black&white 3320 -*/ 3321 - int i; 3322 - int black = 0; 3323 - int white = 0; 3324 - if (img->pixel_format != GG_PIXEL_PALETTE) 3325 - return GGRAPH_FALSE; 3326 - if (img->max_palette != 2) 3327 - return GGRAPH_FALSE; 3328 - for (i = 0; i < img->max_palette; i++) 3329 - { 3330 - if (img->palette_red[i] == 0 && img->palette_green[i] == 0 3331 - && img->palette_blue[i] == 0) 3332 - black = 1; 3333 - if (img->palette_red[i] == 255 && img->palette_green[i] == 255 3334 - && img->palette_blue[i] == 255) 3335 - white = 1; 3336 - } 3337 - if (black && white) 3338 - return GGRAPH_TRUE; 3339 - return GGRAPH_FALSE; 3340 -} 3341 - 3342 -GGRAPH_PRIVATE int 3343 -gg_is_image_monochrome (gGraphImagePtr img) 3344 -{ 3345 -/* checking if this Image is into the Monochrome colorspace */ 3346 - int x; 3347 - int y; 3348 - unsigned char red; 3349 - unsigned char green; 3350 - unsigned char blue; 3351 - unsigned char *p_in; 3352 - for (y = 0; y < img->height; y++) 3353 - { 3354 - p_in = img->pixels + (y * img->scanline_width); 3355 - for (x = 0; x < img->width; x++) 3356 - { 3357 - /* retrieving a pixel */ 3358 - if (img->pixel_format == GG_PIXEL_RGB) 3359 - { 3360 - red = *p_in++; 3361 - green = *p_in++; 3362 - blue = *p_in++; 3363 - } 3364 - else if (img->pixel_format == GG_PIXEL_RGBA) 3365 - { 3366 - red = *p_in++; 3367 - green = *p_in++; 3368 - blue = *p_in++; 3369 - p_in++; /* skipping alpha */ 3370 - } 3371 - else if (img->pixel_format == GG_PIXEL_ARGB) 3372 - { 3373 - p_in++; /* skipping alpha */ 3374 - blue = *p_in++; 3375 - green = *p_in++; 3376 - red = *p_in++; 3377 - } 3378 - else if (img->pixel_format == GG_PIXEL_BGR) 3379 - { 3380 - blue = *p_in++; 3381 - green = *p_in++; 3382 - red = *p_in++; 3383 - } 3384 - else if (img->pixel_format == GG_PIXEL_BGRA) 3385 - { 3386 - blue = *p_in++; 3387 - green = *p_in++; 3388 - red = *p_in++; 3389 - p_in++; /* skipping alpha */ 3390 - } 3391 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 3392 - { 3393 - red = *p_in++; 3394 - green = red; 3395 - blue = red; 3396 - } 3397 - else if (img->pixel_format == GG_PIXEL_PALETTE) 3398 - { 3399 - int index = *p_in++; 3400 - red = img->palette_red[index]; 3401 - green = img->palette_green[index]; 3402 - blue = img->palette_blue[index]; 3403 - } 3404 - if (red == 0 && green == 0 && blue == 0) 3405 - continue; 3406 - if (red == 255 && green == 255 && blue == 255) 3407 - continue; 3408 - return GGRAPH_FALSE; 3409 - } 3410 - } 3411 - return GGRAPH_TRUE; 3412 -} 3413 - 3414 -GGRAPH_PRIVATE int 3415 -gg_is_image_grayscale (gGraphImagePtr img) 3416 -{ 3417 -/* checking if this Image is into the GrayScale colorspace */ 3418 - int x; 3419 - int y; 3420 - unsigned char red; 3421 - unsigned char green; 3422 - unsigned char blue; 3423 - unsigned char *p_in; 3424 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 3425 - return GGRAPH_TRUE; 3426 - for (y = 0; y < img->height; y++) 3427 - { 3428 - p_in = img->pixels + (y * img->scanline_width); 3429 - for (x = 0; x < img->width; x++) 3430 - { 3431 - /* retrieving a pixel */ 3432 - if (img->pixel_format == GG_PIXEL_RGB) 3433 - { 3434 - red = *p_in++; 3435 - green = *p_in++; 3436 - blue = *p_in++; 3437 - } 3438 - else if (img->pixel_format == GG_PIXEL_RGBA) 3439 - { 3440 - red = *p_in++; 3441 - green = *p_in++; 3442 - blue = *p_in++; 3443 - p_in++; /* skipping alpha */ 3444 - } 3445 - else if (img->pixel_format == GG_PIXEL_ARGB) 3446 - { 3447 - p_in++; /* skipping alpha */ 3448 - blue = *p_in++; 3449 - green = *p_in++; 3450 - red = *p_in++; 3451 - } 3452 - else if (img->pixel_format == GG_PIXEL_BGR) 3453 - { 3454 - blue = *p_in++; 3455 - green = *p_in++; 3456 - red = *p_in++; 3457 - } 3458 - else if (img->pixel_format == GG_PIXEL_BGRA) 3459 - { 3460 - blue = *p_in++; 3461 - green = *p_in++; 3462 - red = *p_in++; 3463 - p_in++; /* skipping alpha */ 3464 - } 3465 - else if (img->pixel_format == GG_PIXEL_PALETTE) 3466 - { 3467 - int index = *p_in++; 3468 - red = img->palette_red[index]; 3469 - green = img->palette_green[index]; 3470 - blue = img->palette_blue[index]; 3471 - } 3472 - if (red == green && green == blue) 3473 - continue; 3474 - return GGRAPH_FALSE; 3475 - } 3476 - } 3477 - return GGRAPH_TRUE; 3478 -} 3479 - 3480 -static int 3481 -palette_check (gGraphImagePtr img, unsigned char r, unsigned char g, 3482 - unsigned char b) 3483 -{ 3484 - unsigned char index; 3485 - for (index = 0; index < img->max_palette; index++) 3486 - { 3487 - /* searching if already defined */ 3488 - if (img->palette_red[index] == r && img->palette_green[index] == g 3489 - && img->palette_blue[index] == b) 3490 - return GGRAPH_TRUE; 3491 - } 3492 - if (img->max_palette < 255) 3493 - { 3494 - /* inserting a new palette entry */ 3495 - unsigned char i = img->max_palette; 3496 - img->max_palette += 1; 3497 - img->palette_red[i] = r; 3498 - img->palette_green[i] = g; 3499 - img->palette_blue[i] = b; 3500 - return GGRAPH_TRUE; 3501 - } 3502 - return GGRAPH_FALSE; 3503 -} 3504 - 3505 -GGRAPH_PRIVATE int 3506 -gg_is_image_palette256 (gGraphImagePtr img) 3507 -{ 3508 -/* checking if this Image may be represented using a 256 colors palette */ 3509 - int x; 3510 - int y; 3511 - unsigned char red; 3512 - unsigned char green; 3513 - unsigned char blue; 3514 - unsigned char *p_in; 3515 - if (img->pixel_format == GG_PIXEL_PALETTE 3516 - || img->pixel_format == GG_PIXEL_GRAYSCALE) 3517 - return GGRAPH_TRUE; 3518 - img->max_palette = 0; 3519 - for (y = 0; y < img->height; y++) 3520 - { 3521 - p_in = img->pixels + (y * img->scanline_width); 3522 - for (x = 0; x < img->width; x++) 3523 - { 3524 - /* retrieving a pixel */ 3525 - if (img->pixel_format == GG_PIXEL_RGB) 3526 - { 3527 - red = *p_in++; 3528 - green = *p_in++; 3529 - blue = *p_in++; 3530 - } 3531 - else if (img->pixel_format == GG_PIXEL_RGBA) 3532 - { 3533 - red = *p_in++; 3534 - green = *p_in++; 3535 - blue = *p_in++; 3536 - p_in++; /* skipping alpha */ 3537 - } 3538 - else if (img->pixel_format == GG_PIXEL_ARGB) 3539 - { 3540 - p_in++; /* skipping alpha */ 3541 - blue = *p_in++; 3542 - green = *p_in++; 3543 - red = *p_in++; 3544 - } 3545 - else if (img->pixel_format == GG_PIXEL_BGR) 3546 - { 3547 - blue = *p_in++; 3548 - green = *p_in++; 3549 - red = *p_in++; 3550 - } 3551 - else if (img->pixel_format == GG_PIXEL_BGRA) 3552 - { 3553 - blue = *p_in++; 3554 - green = *p_in++; 3555 - red = *p_in++; 3556 - p_in++; /* skipping alpha */ 3557 - } 3558 - if (palette_check (img, red, green, blue) == GGRAPH_FALSE) 3559 - return GGRAPH_FALSE; 3560 - } 3561 - } 3562 - return GGRAPH_TRUE; 3563 -} 3564 - 3565 -static gGraphImagePtr 3566 -raw_monochrome (unsigned char *p, int width, int height) 3567 -{ 3568 -/* creating a visible image from RAW MONOCHROME */ 3569 - int x; 3570 - int y; 3571 - int line_width; 3572 - gGraphImagePtr img = gg_image_create (GG_PIXEL_PALETTE, width, height, 8, 1, 3573 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3574 - 3575 - if (!img) 3576 - return NULL; 3577 - 3578 - img->max_palette = 2; 3579 - img->palette_red[0] = 255; 3580 - img->palette_green[0] = 255; 3581 - img->palette_blue[0] = 255; 3582 - img->palette_red[1] = 0; 3583 - img->palette_green[1] = 0; 3584 - img->palette_blue[1] = 0; 3585 - 3586 - line_width = width / 8; 3587 - if ((line_width * 8) < width) 3588 - line_width++; 3589 - 3590 - for (y = 0; y < height; y++) 3591 - { 3592 - unsigned char *p_in = p + (y * line_width); 3593 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3594 - unsigned char byte = 0x00; 3595 - unsigned char px; 3596 - int pixel; 3597 - int pos = 0; 3598 - for (x = 0; x < width; x++) 3599 - { 3600 - if (pos == 0) 3601 - byte = *p_in++; 3602 - pixel = 0; 3603 - switch (pos) 3604 - { 3605 - case 0: 3606 - px = byte & 0x80; 3607 - if (px == 0x80) 3608 - pixel = 1; 3609 - break; 3610 - case 1: 3611 - px = byte & 0x40; 3612 - if (px == 0x40) 3613 - pixel = 1; 3614 - break; 3615 - case 2: 3616 - px = byte & 0x20; 3617 - if (px == 0x20) 3618 - pixel = 1; 3619 - break; 3620 - case 3: 3621 - px = byte & 0x10; 3622 - if (px == 0x10) 3623 - pixel = 1; 3624 - break; 3625 - case 4: 3626 - px = byte & 0x08; 3627 - if (px == 0x08) 3628 - pixel = 1; 3629 - break; 3630 - case 5: 3631 - px = byte & 0x04; 3632 - if (px == 0x04) 3633 - pixel = 1; 3634 - break; 3635 - case 6: 3636 - px = byte & 0x02; 3637 - if (px == 0x02) 3638 - pixel = 1; 3639 - break; 3640 - case 7: 3641 - px = byte & 0x01; 3642 - if (px == 0x01) 3643 - pixel = 1; 3644 - break; 3645 - }; 3646 - *p_out++ = pixel; 3647 - pos++; 3648 - if (pos > 7) 3649 - { 3650 - byte = 0x00; 3651 - pos = 0; 3652 - } 3653 - } 3654 - } 3655 - return img; 3656 -} 3657 - 3658 -static gGraphImagePtr 3659 -raw_rgb (unsigned char *p, int width, int height) 3660 -{ 3661 -/* creating a visible image from RAW RGB */ 3662 - int y; 3663 - gGraphImagePtr img = 3664 - gg_image_create (GG_PIXEL_RGB, width, height, 8, 3, GGRAPH_SAMPLE_UINT, 3665 - NULL, NULL); 3666 - 3667 - if (!img) 3668 - return NULL; 3669 - 3670 - for (y = 0; y < height; y++) 3671 - { 3672 - unsigned char *p_in = p + (y * img->scanline_width); 3673 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3674 - memcpy (p_out, p_in, img->scanline_width); 3675 - } 3676 - return img; 3677 -} 3678 - 3679 -static gGraphImagePtr 3680 -raw_grayscale (unsigned char *p, int width, int height) 3681 -{ 3682 -/* creating a visible image from RAW GRAYSCALE */ 3683 - int y; 3684 - gGraphImagePtr img = 3685 - gg_image_create (GG_PIXEL_GRAYSCALE, width, height, 8, 1, 3686 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3687 - 3688 - if (!img) 3689 - return NULL; 3690 - 3691 - for (y = 0; y < height; y++) 3692 - { 3693 - unsigned char *p_in = p + (y * img->scanline_width); 3694 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3695 - memcpy (p_out, p_in, img->scanline_width); 3696 - } 3697 - return img; 3698 -} 3699 - 3700 -static gGraphImagePtr 3701 -raw_palette (unsigned char *p, int width, int height) 3702 -{ 3703 -/* creating a visible image from RAW PALETTE */ 3704 - int x; 3705 - int y; 3706 - gGraphImagePtr img = gg_image_create (GG_PIXEL_PALETTE, width, height, 8, 1, 3707 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3708 - 3709 - if (!img) 3710 - return NULL; 3711 - 3712 - srand (1); 3713 - for (y = 0; y < height; y++) 3714 - { 3715 - unsigned char *p_in = p + (y * img->scanline_width); 3716 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3717 - for (x = 0; x < width; x++) 3718 - { 3719 - unsigned int col; 3720 - int idx = *p_in++; 3721 - *p_out++ = idx; 3722 - if (img->max_palette < (idx + 1)) 3723 - { 3724 - img->max_palette = idx + 1; 3725 - col = 255 - (unsigned int) rand () % 256; 3726 - img->palette_red[idx] = col; 3727 - col = (unsigned int) rand () % 256; 3728 - img->palette_green[idx] = col; 3729 - col = 255 - (unsigned int) rand () % 256; 3730 - img->palette_blue[idx] = col; 3731 - } 3732 - } 3733 - } 3734 - return img; 3735 -} 3736 - 3737 -static gGraphImagePtr 3738 -raw_int16 (unsigned char *p, int width, int height, int endian) 3739 -{ 3740 -/* creating a visible image from RAW GRID-INT16 */ 3741 - int x; 3742 - int y; 3743 - int endian_arch = gg_endian_arch (); 3744 - unsigned char *p_in; 3745 - short value; 3746 - short min = SHRT_MAX; 3747 - short max = SHRT_MIN; 3748 - double step; 3749 - double gray; 3750 - gGraphImagePtr img = 3751 - gg_image_create (GG_PIXEL_GRAYSCALE, width, height, 8, 1, 3752 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3753 - 3754 - if (!img) 3755 - return NULL; 3756 - 3757 - for (y = 0; y < height; y++) 3758 - { 3759 - /* identifying Min/Max values */ 3760 - p_in = p + (y * width * sizeof (short)); 3761 - for (x = 0; x < width; x++) 3762 - { 3763 - value = gg_import_int16 (p_in, endian, endian_arch); 3764 - p_in += sizeof (short); 3765 - if (value > max) 3766 - max = value; 3767 - if (value < min) 3768 - min = value; 3769 - } 3770 - } 3771 - step = (double) (max - min) / 256.0; 3772 - for (y = 0; y < height; y++) 3773 - { 3774 - /* visualizing as Grayscale */ 3775 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3776 - p_in = p + (y * width * sizeof (short)); 3777 - for (x = 0; x < width; x++) 3778 - { 3779 - value = gg_import_int16 (p_in, endian, endian_arch); 3780 - p_in += sizeof (short); 3781 - gray = (double) (value - min) / step; 3782 - if (gray < 0.0) 3783 - gray = 0.0; 3784 - if (gray > 255) 3785 - gray = 255.0; 3786 - *p_out++ = (short) gray; 3787 - } 3788 - } 3789 - return img; 3790 -} 3791 - 3792 -static gGraphImagePtr 3793 -raw_int32 (unsigned char *p, int width, int height, int endian) 3794 -{ 3795 -/* creating a visible image from RAW GRID-INT32 */ 3796 - int x; 3797 - int y; 3798 - int endian_arch = gg_endian_arch (); 3799 - unsigned char *p_in; 3800 - int value; 3801 - int min = INT_MAX; 3802 - int max = INT_MIN; 3803 - double step; 3804 - double gray; 3805 - gGraphImagePtr img = 3806 - gg_image_create (GG_PIXEL_GRAYSCALE, width, height, 8, 1, 3807 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3808 - 3809 - if (!img) 3810 - return NULL; 3811 - 3812 - for (y = 0; y < height; y++) 3813 - { 3814 - /* identifying Min/Max values */ 3815 - p_in = p + (y * width * sizeof (int)); 3816 - for (x = 0; x < width; x++) 3817 - { 3818 - value = gg_import_int32 (p_in, endian, endian_arch); 3819 - p_in += sizeof (int); 3820 - if (value > max) 3821 - max = value; 3822 - if (value < min) 3823 - min = value; 3824 - } 3825 - } 3826 - step = (double) (max - min) / 256.0; 3827 - for (y = 0; y < height; y++) 3828 - { 3829 - /* visualizing as Grayscale */ 3830 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3831 - p_in = p + (y * width * sizeof (int)); 3832 - for (x = 0; x < width; x++) 3833 - { 3834 - value = gg_import_int32 (p_in, endian, endian_arch); 3835 - p_in += sizeof (int); 3836 - gray = (double) (value - min) / step; 3837 - if (gray < 0.0) 3838 - gray = 0.0; 3839 - if (gray > 255) 3840 - gray = 255.0; 3841 - *p_out++ = (short) gray; 3842 - } 3843 - } 3844 - return img; 3845 -} 3846 - 3847 -static gGraphImagePtr 3848 -raw_uint16 (unsigned char *p, int width, int height, int endian) 3849 -{ 3850 -/* creating a visible image from RAW GRID-UINT16 */ 3851 - int x; 3852 - int y; 3853 - int endian_arch = gg_endian_arch (); 3854 - unsigned char *p_in; 3855 - unsigned short value; 3856 - unsigned short min = USHRT_MAX; 3857 - unsigned short max = 0; 3858 - double step; 3859 - double gray; 3860 - gGraphImagePtr img = 3861 - gg_image_create (GG_PIXEL_GRAYSCALE, width, height, 8, 1, 3862 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3863 - 3864 - if (!img) 3865 - return NULL; 3866 - 3867 - for (y = 0; y < height; y++) 3868 - { 3869 - /* identifying Min/Max values */ 3870 - p_in = p + (y * width * sizeof (unsigned short)); 3871 - for (x = 0; x < width; x++) 3872 - { 3873 - value = gg_import_uint16 (p_in, endian, endian_arch); 3874 - p_in += sizeof (unsigned short); 3875 - if (value > max) 3876 - max = value; 3877 - if (value < min) 3878 - min = value; 3879 - } 3880 - } 3881 - step = (double) (max - min) / 256.0; 3882 - for (y = 0; y < height; y++) 3883 - { 3884 - /* visualizing as Grayscale */ 3885 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3886 - p_in = p + (y * width * sizeof (unsigned short)); 3887 - for (x = 0; x < width; x++) 3888 - { 3889 - value = gg_import_uint16 (p_in, endian, endian_arch); 3890 - p_in += sizeof (unsigned short); 3891 - gray = (double) (value - min) / step; 3892 - if (gray < 0.0) 3893 - gray = 0.0; 3894 - if (gray > 255) 3895 - gray = 255.0; 3896 - *p_out++ = (short) gray; 3897 - } 3898 - } 3899 - return img; 3900 -} 3901 - 3902 -static gGraphImagePtr 3903 -raw_uint32 (unsigned char *p, int width, int height, int endian) 3904 -{ 3905 -/* creating a visible image from RAW GRID-UINT32 */ 3906 - int x; 3907 - int y; 3908 - int endian_arch = gg_endian_arch (); 3909 - unsigned char *p_in; 3910 - unsigned int value; 3911 - unsigned int min = UINT_MAX; 3912 - unsigned int max = 0; 3913 - double step; 3914 - double gray; 3915 - gGraphImagePtr img = 3916 - gg_image_create (GG_PIXEL_GRAYSCALE, width, height, 8, 1, 3917 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3918 - 3919 - if (!img) 3920 - return NULL; 3921 - 3922 - for (y = 0; y < height; y++) 3923 - { 3924 - /* identifying Min/Max values */ 3925 - p_in = p + (y * width * sizeof (int)); 3926 - for (x = 0; x < width; x++) 3927 - { 3928 - value = gg_import_uint32 (p_in, endian, endian_arch); 3929 - p_in += sizeof (unsigned int); 3930 - if (value > max) 3931 - max = value; 3932 - if (value < min) 3933 - min = value; 3934 - } 3935 - } 3936 - step = (double) (max - min) / 256.0; 3937 - for (y = 0; y < height; y++) 3938 - { 3939 - /* visualizing as Grayscale */ 3940 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3941 - p_in = p + (y * width * sizeof (unsigned int)); 3942 - for (x = 0; x < width; x++) 3943 - { 3944 - value = gg_import_uint32 (p_in, endian, endian_arch); 3945 - p_in += sizeof (unsigned int); 3946 - gray = (double) (value - min) / step; 3947 - if (gray < 0.0) 3948 - gray = 0.0; 3949 - if (gray > 255) 3950 - gray = 255.0; 3951 - *p_out++ = (short) gray; 3952 - } 3953 - } 3954 - return img; 3955 -} 3956 - 3957 -static gGraphImagePtr 3958 -raw_float (unsigned char *p, int width, int height, int endian) 3959 -{ 3960 -/* creating a visible image from RAW GRID-FLOAT */ 3961 - int x; 3962 - int y; 3963 - int endian_arch = gg_endian_arch (); 3964 - unsigned char *p_in; 3965 - float value; 3966 - float min = FLT_MAX; 3967 - float max = 0.0 - FLT_MAX; 3968 - double step; 3969 - double gray; 3970 - gGraphImagePtr img = 3971 - gg_image_create (GG_PIXEL_GRAYSCALE, width, height, 8, 1, 3972 - GGRAPH_SAMPLE_UINT, NULL, NULL); 3973 - 3974 - if (!img) 3975 - return NULL; 3976 - 3977 - for (y = 0; y < height; y++) 3978 - { 3979 - /* identifying Min/Max values */ 3980 - p_in = p + (y * width * sizeof (float)); 3981 - for (x = 0; x < width; x++) 3982 - { 3983 - value = gg_import_float (p_in, endian, endian_arch); 3984 - p_in += sizeof (float); 3985 - if (value > max) 3986 - max = value; 3987 - if (value < min) 3988 - min = value; 3989 - } 3990 - } 3991 - step = (double) (max - min) / 256.0; 3992 - for (y = 0; y < height; y++) 3993 - { 3994 - /* visualizing as Grayscale */ 3995 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 3996 - p_in = p + (y * width * sizeof (float)); 3997 - for (x = 0; x < width; x++) 3998 - { 3999 - value = gg_import_float (p_in, endian, endian_arch); 4000 - p_in += sizeof (float); 4001 - gray = (double) (value - min) / step; 4002 - if (gray < 0.0) 4003 - gray = 0.0; 4004 - if (gray > 255) 4005 - gray = 255.0; 4006 - *p_out++ = (short) gray; 4007 - } 4008 - } 4009 - return img; 4010 -} 4011 - 4012 -static gGraphImagePtr 4013 -raw_double (unsigned char *p, int width, int height, int endian) 4014 -{ 4015 -/* creating a visible image from RAW GRID-DOUBLE */ 4016 - int x; 4017 - int y; 4018 - int endian_arch = gg_endian_arch (); 4019 - unsigned char *p_in; 4020 - double value; 4021 - double min = DBL_MAX; 4022 - double max = 0.0 - DBL_MAX; 4023 - double step; 4024 - double gray; 4025 - gGraphImagePtr img = 4026 - gg_image_create (GG_PIXEL_GRAYSCALE, width, height, 8, 1, 4027 - GGRAPH_SAMPLE_UINT, NULL, NULL); 4028 - 4029 - if (!img) 4030 - return NULL; 4031 - 4032 - for (y = 0; y < height; y++) 4033 - { 4034 - /* identifying Min/Max values */ 4035 - p_in = p + (y * width * sizeof (float)); 4036 - for (x = 0; x < width; x++) 4037 - { 4038 - value = gg_import_double (p_in, endian, endian_arch); 4039 - p_in += sizeof (double); 4040 - if (value > max) 4041 - max = value; 4042 - if (value < min) 4043 - min = value; 4044 - } 4045 - } 4046 - step = (double) (max - min) / 256.0; 4047 - for (y = 0; y < height; y++) 4048 - { 4049 - /* visualizing as Grayscale */ 4050 - unsigned char *p_out = img->pixels + (y * img->scanline_width); 4051 - p_in = p + (y * width * sizeof (double)); 4052 - for (x = 0; x < width; x++) 4053 - { 4054 - value = gg_import_double (p_in, endian, endian_arch); 4055 - p_in += sizeof (double); 4056 - gray = (value - min) / step; 4057 - if (gray < 0.0) 4058 - gray = 0.0; 4059 - if (gray > 255) 4060 - gray = 255.0; 4061 - *p_out++ = (short) gray; 4062 - } 4063 - } 4064 - return img; 4065 -} 4066 - 4067 -GGRAPH_PRIVATE int 4068 -gg_image_from_raw (int mem_buf_size, const void *mem_buf, 4069 - gGraphImagePtr * image_handle) 4070 -{ 4071 -/* importing a RAW image */ 4072 - gGraphImagePtr img = NULL; 4073 - int width; 4074 - int height; 4075 - int line_width; 4076 - unsigned char *p = (unsigned char *) mem_buf; 4077 - short start_signature; 4078 - short end_signature; 4079 - int endian_arch = gg_endian_arch (); 4080 - 4081 - *image_handle = NULL; 4082 - if (mem_buf_size < (int) (sizeof (short) * 4)) 4083 - return GGRAPH_ERROR; 4084 - 4085 -/* checking the magic signature */ 4086 - start_signature = gg_import_int16 (p, 1, endian_arch); 4087 - p = (unsigned char *) mem_buf + mem_buf_size - sizeof (short); 4088 - end_signature = gg_import_int16 (p, 1, endian_arch); 4089 - if (start_signature == GG_MONOCHROME_START 4090 - && end_signature == GG_MONOCHROME_END) 4091 - { 4092 - p = (unsigned char *) mem_buf + sizeof (short); 4093 - width = gg_import_int16 (p, 0, endian_arch); 4094 - p += sizeof (short); 4095 - height = gg_import_int16 (p, 0, endian_arch); 4096 - p += sizeof (short); 4097 - line_width = width / 8; 4098 - if ((line_width * 8) < width) 4099 - line_width++; 4100 - if ((line_width * height) != 4101 - (int) (mem_buf_size - (4 * sizeof (short)))) 4102 - return GGRAPH_ERROR; 4103 - img = raw_monochrome (p, width, height); 4104 - if (!img) 4105 - return GGRAPH_ERROR; 4106 - *image_handle = img; 4107 - return GGRAPH_OK; 4108 - } 4109 - if ((start_signature == GG_ADAM7_1_RGB_START 4110 - && end_signature == GG_ADAM7_1_RGB_END) || 4111 - (start_signature == GG_ADAM7_3_RGB_START 4112 - && end_signature == GG_ADAM7_3_RGB_END) || 4113 - (start_signature == GG_ADAM7_5_RGB_START 4114 - && end_signature == GG_ADAM7_5_RGB_END)) 4115 - { 4116 - p = (unsigned char *) mem_buf + sizeof (short); 4117 - width = gg_import_int16 (p, 1, endian_arch); 4118 - p += sizeof (short); 4119 - height = gg_import_int16 (p, 1, endian_arch); 4120 - p += sizeof (short); 4121 - line_width = width * 3; 4122 - if ((line_width * height) != 4123 - (int) (mem_buf_size - (4 * sizeof (short)))) 4124 - return GGRAPH_ERROR; 4125 - img = raw_rgb (p, width, height); 4126 - if (!img) 4127 - return GGRAPH_ERROR; 4128 - *image_handle = img; 4129 - return GGRAPH_OK; 4130 - } 4131 - if ((start_signature == GG_ADAM7_1_GRAYSCALE_START 4132 - && end_signature == GG_ADAM7_1_GRAYSCALE_END) || 4133 - (start_signature == GG_ADAM7_3_GRAYSCALE_START 4134 - && end_signature == GG_ADAM7_3_GRAYSCALE_END) || 4135 - (start_signature == GG_ADAM7_5_GRAYSCALE_START 4136 - && end_signature == GG_ADAM7_5_GRAYSCALE_END)) 4137 - { 4138 - p = (unsigned char *) mem_buf + sizeof (short); 4139 - width = gg_import_int16 (p, 1, endian_arch); 4140 - p += sizeof (short); 4141 - height = gg_import_int16 (p, 1, endian_arch); 4142 - p += sizeof (short); 4143 - line_width = width; 4144 - if ((line_width * height) != 4145 - (int) (mem_buf_size - (4 * sizeof (short)))) 4146 - return GGRAPH_ERROR; 4147 - img = raw_grayscale (p, width, height); 4148 - if (!img) 4149 - return GGRAPH_ERROR; 4150 - *image_handle = img; 4151 - return GGRAPH_OK; 4152 - } 4153 - if ((start_signature == GG_ADAM7_1_PALETTE_START 4154 - && end_signature == GG_ADAM7_1_PALETTE_END) || 4155 - (start_signature == GG_ADAM7_3_PALETTE_START 4156 - && end_signature == GG_ADAM7_3_PALETTE_END) || 4157 - (start_signature == GG_ADAM7_5_PALETTE_START 4158 - && end_signature == GG_ADAM7_5_PALETTE_END)) 4159 - { 4160 - p = (unsigned char *) mem_buf + sizeof (short); 4161 - width = gg_import_int16 (p, 1, endian_arch); 4162 - p += sizeof (short); 4163 - height = gg_import_int16 (p, 1, endian_arch); 4164 - p += sizeof (short); 4165 - line_width = width; 4166 - if ((line_width * height) != 4167 - (int) (mem_buf_size - (4 * sizeof (short)))) 4168 - return GGRAPH_ERROR; 4169 - img = raw_palette (p, width, height); 4170 - if (!img) 4171 - return GGRAPH_ERROR; 4172 - *image_handle = img; 4173 - return GGRAPH_OK; 4174 - } 4175 - if ((start_signature == GG_ADAM7_1_INT16_START 4176 - && end_signature == GG_ADAM7_1_INT16_END) || 4177 - (start_signature == GG_ADAM7_3_INT16_START 4178 - && end_signature == GG_ADAM7_3_INT16_END) || 4179 - (start_signature == GG_ADAM7_5_INT16_START 4180 - && end_signature == GG_ADAM7_5_INT16_END)) 4181 - { 4182 - p = (unsigned char *) mem_buf + sizeof (short); 4183 - width = gg_import_int16 (p, 1, endian_arch); 4184 - p += sizeof (short); 4185 - height = gg_import_int16 (p, 1, endian_arch); 4186 - p += sizeof (short); 4187 - line_width = width * sizeof (short); 4188 - if ((line_width * height) != 4189 - (int) (mem_buf_size - (4 * sizeof (short)))) 4190 - return GGRAPH_ERROR; 4191 - img = raw_int16 (p, width, height, 1); 4192 - if (!img) 4193 - return GGRAPH_ERROR; 4194 - *image_handle = img; 4195 - return GGRAPH_OK; 4196 - } 4197 - if ((start_signature == GG_ADAM7_1_UINT16_START 4198 - && end_signature == GG_ADAM7_1_UINT16_END) || 4199 - (start_signature == GG_ADAM7_3_UINT16_START 4200 - && end_signature == GG_ADAM7_3_UINT16_END) || 4201 - (start_signature == GG_ADAM7_5_UINT16_START 4202 - && end_signature == GG_ADAM7_5_UINT16_END)) 4203 - { 4204 - p = (unsigned char *) mem_buf + sizeof (short); 4205 - width = gg_import_int16 (p, 1, endian_arch); 4206 - p += sizeof (short); 4207 - height = gg_import_int16 (p, 1, endian_arch); 4208 - p += sizeof (short); 4209 - line_width = width * sizeof (unsigned short); 4210 - if ((line_width * height) != 4211 - (int) (mem_buf_size - (4 * sizeof (short)))) 4212 - return GGRAPH_ERROR; 4213 - img = raw_uint16 (p, width, height, 1); 4214 - if (!img) 4215 - return GGRAPH_ERROR; 4216 - *image_handle = img; 4217 - return GGRAPH_OK; 4218 - } 4219 - if ((start_signature == GG_ADAM7_1_INT32_START 4220 - && end_signature == GG_ADAM7_1_INT32_END) || 4221 - (start_signature == GG_ADAM7_3_INT32_START 4222 - && end_signature == GG_ADAM7_3_INT32_END) || 4223 - (start_signature == GG_ADAM7_5_INT32_START 4224 - && end_signature == GG_ADAM7_5_INT32_END)) 4225 - { 4226 - p = (unsigned char *) mem_buf + sizeof (short); 4227 - width = gg_import_int16 (p, 1, endian_arch); 4228 - p += sizeof (short); 4229 - height = gg_import_int16 (p, 1, endian_arch); 4230 - p += sizeof (short); 4231 - line_width = width * sizeof (int); 4232 - if ((line_width * height) != 4233 - (int) (mem_buf_size - (4 * sizeof (short)))) 4234 - return GGRAPH_ERROR; 4235 - img = raw_int32 (p, width, height, 1); 4236 - if (!img) 4237 - return GGRAPH_ERROR; 4238 - *image_handle = img; 4239 - return GGRAPH_OK; 4240 - } 4241 - if ((start_signature == GG_ADAM7_1_UINT32_START 4242 - && end_signature == GG_ADAM7_1_UINT32_END) || 4243 - (start_signature == GG_ADAM7_3_UINT32_START 4244 - && end_signature == GG_ADAM7_3_UINT32_END) || 4245 - (start_signature == GG_ADAM7_5_UINT32_START 4246 - && end_signature == GG_ADAM7_5_UINT32_END)) 4247 - { 4248 - p = (unsigned char *) mem_buf + sizeof (short); 4249 - width = gg_import_int16 (p, 1, endian_arch); 4250 - p += sizeof (short); 4251 - height = gg_import_int16 (p, 1, endian_arch); 4252 - p += sizeof (short); 4253 - line_width = width * sizeof (unsigned int); 4254 - if ((line_width * height) != 4255 - (int) (mem_buf_size - (4 * sizeof (short)))) 4256 - return GGRAPH_ERROR; 4257 - img = raw_uint32 (p, width, height, 1); 4258 - if (!img) 4259 - return GGRAPH_ERROR; 4260 - *image_handle = img; 4261 - return GGRAPH_OK; 4262 - } 4263 - if ((start_signature == GG_ADAM7_1_FLOAT_START 4264 - && end_signature == GG_ADAM7_1_FLOAT_END) || 4265 - (start_signature == GG_ADAM7_3_FLOAT_START 4266 - && end_signature == GG_ADAM7_3_FLOAT_END) || 4267 - (start_signature == GG_ADAM7_5_FLOAT_START 4268 - && end_signature == GG_ADAM7_5_FLOAT_END)) 4269 - { 4270 - p = (unsigned char *) mem_buf + sizeof (short); 4271 - width = gg_import_int16 (p, 1, endian_arch); 4272 - p += sizeof (short); 4273 - height = gg_import_int16 (p, 1, endian_arch); 4274 - p += sizeof (short); 4275 - line_width = width * sizeof (float); 4276 - if ((line_width * height) != 4277 - (int) (mem_buf_size - (4 * sizeof (short)))) 4278 - return GGRAPH_ERROR; 4279 - img = raw_float (p, width, height, 1); 4280 - if (!img) 4281 - return GGRAPH_ERROR; 4282 - *image_handle = img; 4283 - return GGRAPH_OK; 4284 - } 4285 - if ((start_signature == GG_ADAM7_1_DOUBLE_START 4286 - && end_signature == GG_ADAM7_1_DOUBLE_END) || 4287 - (start_signature == GG_ADAM7_3_DOUBLE_START 4288 - && end_signature == GG_ADAM7_3_DOUBLE_END) || 4289 - (start_signature == GG_ADAM7_5_DOUBLE_START 4290 - && end_signature == GG_ADAM7_5_DOUBLE_END)) 4291 - { 4292 - p = (unsigned char *) mem_buf + sizeof (short); 4293 - width = gg_import_int16 (p, 1, endian_arch); 4294 - p += sizeof (short); 4295 - height = gg_import_int16 (p, 1, endian_arch); 4296 - p += sizeof (short); 4297 - line_width = width * sizeof (double); 4298 - if ((line_width * height) != 4299 - (int) (mem_buf_size - (4 * sizeof (short)))) 4300 - return GGRAPH_ERROR; 4301 - img = raw_double (p, width, height, 1); 4302 - if (!img) 4303 - return GGRAPH_ERROR; 4304 - *image_handle = img; 4305 - return GGRAPH_OK; 4306 - } 4307 - 4308 - p = (unsigned char *) mem_buf; 4309 - start_signature = gg_import_int16 (p, 0, endian_arch); 4310 - p = (unsigned char *) mem_buf + mem_buf_size - sizeof (short); 4311 - end_signature = gg_import_int16 (p, 0, endian_arch); 4312 - if ((start_signature == GG_ADAM7_0_RGB_START 4313 - && end_signature == GG_ADAM7_0_RGB_END) || 4314 - (start_signature == GG_ADAM7_2_RGB_START 4315 - && end_signature == GG_ADAM7_2_RGB_END) || 4316 - (start_signature == GG_ADAM7_4_RGB_START 4317 - && end_signature == GG_ADAM7_4_RGB_END) || 4318 - (start_signature == GG_ADAM7_6_RGB_START 4319 - && end_signature == GG_ADAM7_6_RGB_END)) 4320 - { 4321 - p = (unsigned char *) mem_buf + sizeof (short); 4322 - width = gg_import_int16 (p, 0, endian_arch); 4323 - p += sizeof (short); 4324 - height = gg_import_int16 (p, 0, endian_arch); 4325 - p += sizeof (short); 4326 - img = raw_rgb (p, width, height); 4327 - if (!img) 4328 - return GGRAPH_ERROR; 4329 - *image_handle = img; 4330 - return GGRAPH_OK; 4331 - } 4332 - if ((start_signature == GG_ADAM7_0_GRAYSCALE_START 4333 - && end_signature == GG_ADAM7_0_GRAYSCALE_END) || 4334 - (start_signature == GG_ADAM7_2_GRAYSCALE_START 4335 - && end_signature == GG_ADAM7_2_GRAYSCALE_END) || 4336 - (start_signature == GG_ADAM7_4_GRAYSCALE_START 4337 - && end_signature == GG_ADAM7_4_GRAYSCALE_END) || 4338 - (start_signature == GG_ADAM7_6_GRAYSCALE_START 4339 - && end_signature == GG_ADAM7_6_GRAYSCALE_END)) 4340 - { 4341 - p = (unsigned char *) mem_buf + sizeof (short); 4342 - width = gg_import_int16 (p, 0, endian_arch); 4343 - p += sizeof (short); 4344 - height = gg_import_int16 (p, 0, endian_arch); 4345 - p += sizeof (short); 4346 - img = raw_grayscale (p, width, height); 4347 - if (!img) 4348 - return GGRAPH_ERROR; 4349 - *image_handle = img; 4350 - return GGRAPH_OK; 4351 - } 4352 - if ((start_signature == GG_ADAM7_0_PALETTE_START 4353 - && end_signature == GG_ADAM7_0_PALETTE_END) || 4354 - (start_signature == GG_ADAM7_2_PALETTE_START 4355 - && end_signature == GG_ADAM7_2_PALETTE_END) || 4356 - (start_signature == GG_ADAM7_4_PALETTE_START 4357 - && end_signature == GG_ADAM7_4_PALETTE_END) || 4358 - (start_signature == GG_ADAM7_6_PALETTE_START 4359 - && end_signature == GG_ADAM7_6_PALETTE_END)) 4360 - { 4361 - p = (unsigned char *) mem_buf + sizeof (short); 4362 - width = gg_import_int16 (p, 0, endian_arch); 4363 - p += sizeof (short); 4364 - height = gg_import_int16 (p, 0, endian_arch); 4365 - p += sizeof (short); 4366 - img = raw_palette (p, width, height); 4367 - if (!img) 4368 - return GGRAPH_ERROR; 4369 - *image_handle = img; 4370 - return GGRAPH_OK; 4371 - } 4372 - if ((start_signature == GG_ADAM7_0_INT16_START 4373 - && end_signature == GG_ADAM7_0_INT16_END) || 4374 - (start_signature == GG_ADAM7_2_INT16_START 4375 - && end_signature == GG_ADAM7_2_INT16_END) || 4376 - (start_signature == GG_ADAM7_4_INT16_START 4377 - && end_signature == GG_ADAM7_4_INT16_END) || 4378 - (start_signature == GG_ADAM7_6_INT16_START 4379 - && end_signature == GG_ADAM7_6_INT16_END)) 4380 - { 4381 - p = (unsigned char *) mem_buf + sizeof (short); 4382 - width = gg_import_int16 (p, 0, endian_arch); 4383 - p += sizeof (short); 4384 - height = gg_import_int16 (p, 0, endian_arch); 4385 - p += sizeof (short); 4386 - img = raw_int16 (p, width, height, 0); 4387 - if (!img) 4388 - return GGRAPH_ERROR; 4389 - *image_handle = img; 4390 - return GGRAPH_OK; 4391 - } 4392 - if ((start_signature == GG_ADAM7_0_UINT16_START 4393 - && end_signature == GG_ADAM7_0_UINT16_END) || 4394 - (start_signature == GG_ADAM7_2_UINT16_START 4395 - && end_signature == GG_ADAM7_2_UINT16_END) || 4396 - (start_signature == GG_ADAM7_4_UINT16_START 4397 - && end_signature == GG_ADAM7_4_UINT16_END) || 4398 - (start_signature == GG_ADAM7_6_UINT16_START 4399 - && end_signature == GG_ADAM7_6_UINT16_END)) 4400 - { 4401 - p = (unsigned char *) mem_buf + sizeof (short); 4402 - width = gg_import_int16 (p, 0, endian_arch); 4403 - p += sizeof (short); 4404 - height = gg_import_int16 (p, 0, endian_arch); 4405 - p += sizeof (short); 4406 - img = raw_uint16 (p, width, height, 0); 4407 - if (!img) 4408 - return GGRAPH_ERROR; 4409 - *image_handle = img; 4410 - return GGRAPH_OK; 4411 - } 4412 - if ((start_signature == GG_ADAM7_0_INT32_START 4413 - && end_signature == GG_ADAM7_0_INT32_END) || 4414 - (start_signature == GG_ADAM7_2_INT32_START 4415 - && end_signature == GG_ADAM7_2_INT32_END) || 4416 - (start_signature == GG_ADAM7_4_INT32_START 4417 - && end_signature == GG_ADAM7_4_INT32_END) || 4418 - (start_signature == GG_ADAM7_6_INT32_START 4419 - && end_signature == GG_ADAM7_6_INT32_END)) 4420 - { 4421 - p = (unsigned char *) mem_buf + sizeof (short); 4422 - width = gg_import_int16 (p, 0, endian_arch); 4423 - p += sizeof (short); 4424 - height = gg_import_int16 (p, 0, endian_arch); 4425 - p += sizeof (short); 4426 - img = raw_int32 (p, width, height, 0); 4427 - if (!img) 4428 - return GGRAPH_ERROR; 4429 - *image_handle = img; 4430 - return GGRAPH_OK; 4431 - } 4432 - if ((start_signature == GG_ADAM7_0_UINT32_START 4433 - && end_signature == GG_ADAM7_0_UINT32_END) || 4434 - (start_signature == GG_ADAM7_2_UINT32_START 4435 - && end_signature == GG_ADAM7_2_UINT32_END) || 4436 - (start_signature == GG_ADAM7_4_UINT32_START 4437 - && end_signature == GG_ADAM7_4_UINT32_END) || 4438 - (start_signature == GG_ADAM7_6_UINT32_START 4439 - && end_signature == GG_ADAM7_6_UINT32_END)) 4440 - { 4441 - p = (unsigned char *) mem_buf + sizeof (short); 4442 - width = gg_import_int16 (p, 0, endian_arch); 4443 - p += sizeof (short); 4444 - height = gg_import_int16 (p, 0, endian_arch); 4445 - p += sizeof (short); 4446 - img = raw_uint32 (p, width, height, 0); 4447 - if (!img) 4448 - return GGRAPH_ERROR; 4449 - *image_handle = img; 4450 - return GGRAPH_OK; 4451 - } 4452 - if ((start_signature == GG_ADAM7_0_FLOAT_START 4453 - && end_signature == GG_ADAM7_0_FLOAT_END) || 4454 - (start_signature == GG_ADAM7_2_FLOAT_START 4455 - && end_signature == GG_ADAM7_2_FLOAT_END) || 4456 - (start_signature == GG_ADAM7_4_FLOAT_START 4457 - && end_signature == GG_ADAM7_4_FLOAT_END) || 4458 - (start_signature == GG_ADAM7_6_FLOAT_START 4459 - && end_signature == GG_ADAM7_6_FLOAT_END)) 4460 - { 4461 - p = (unsigned char *) mem_buf + sizeof (short); 4462 - width = gg_import_int16 (p, 0, endian_arch); 4463 - p += sizeof (short); 4464 - height = gg_import_int16 (p, 0, endian_arch); 4465 - p += sizeof (short); 4466 - img = raw_float (p, width, height, 0); 4467 - if (!img) 4468 - return GGRAPH_ERROR; 4469 - *image_handle = img; 4470 - return GGRAPH_OK; 4471 - } 4472 - if ((start_signature == GG_ADAM7_0_DOUBLE_START 4473 - && end_signature == GG_ADAM7_0_DOUBLE_END) || 4474 - (start_signature == GG_ADAM7_2_DOUBLE_START 4475 - && end_signature == GG_ADAM7_2_DOUBLE_END) || 4476 - (start_signature == GG_ADAM7_4_DOUBLE_START 4477 - && end_signature == GG_ADAM7_4_DOUBLE_END) || 4478 - (start_signature == GG_ADAM7_6_DOUBLE_START 4479 - && end_signature == GG_ADAM7_6_DOUBLE_END)) 4480 - { 4481 - p = (unsigned char *) mem_buf + sizeof (short); 4482 - width = gg_import_int16 (p, 0, endian_arch); 4483 - p += sizeof (short); 4484 - height = gg_import_int16 (p, 0, endian_arch); 4485 - p += sizeof (short); 4486 - img = raw_double (p, width, height, 0); 4487 - if (!img) 4488 - return GGRAPH_ERROR; 4489 - *image_handle = img; 4490 - return GGRAPH_OK; 4491 - } 4492 - 4493 - return GGRAPH_ERROR; 4494 -} 4495 - 4496 -static int 4497 -is_near_transparent (unsigned char r, unsigned char g, unsigned char b, 4498 - const gGraphImagePtr img) 4499 -{ 4500 -/* checking if this one is a near-transparent value */ 4501 - int diff; 4502 - if (r == img->transparent_red && g == img->transparent_green 4503 - && b == img->transparent_blue) 4504 - return 0; 4505 - diff = r - img->transparent_red; 4506 - if (diff <= 8 && diff >= -8) 4507 - ; 4508 - else 4509 - return 0; 4510 - diff = g - img->transparent_green; 4511 - if (diff <= 8 && diff >= -8) 4512 - ; 4513 - else 4514 - return 0; 4515 - diff = b - img->transparent_blue; 4516 - if (diff <= 8 && diff >= -8) 4517 - ; 4518 - else 4519 - return 0; 4520 - return 1; 4521 -} 4522 - 4523 -GGRAPH_PRIVATE int 4524 -gg_resample_transparent_rgb (const gGraphImagePtr img) 4525 -{ 4526 -/* 4527 -/ resampling colors so to make near-transparent values 4528 -/ to be really transparent 4529 -*/ 4530 - int x; 4531 - int y; 4532 - unsigned char *p_in; 4533 - unsigned char *p_out; 4534 - unsigned char r; 4535 - unsigned char g; 4536 - unsigned char b; 4537 - 4538 - if (img->pixel_format != GG_PIXEL_RGB) 4539 - return GGRAPH_ERROR; 4540 - 4541 - for (y = 0; y < img->height; y++) 4542 - { 4543 - p_in = img->pixels + (y * img->scanline_width); 4544 - p_out = img->pixels + (y * img->scanline_width); 4545 - for (x = 0; x < img->width; x++) 4546 - { 4547 - r = *p_in++; 4548 - g = *p_in++; 4549 - b = *p_in++; 4550 - if (is_near_transparent (r, g, b, img)) 4551 - { 4552 - *p_out++ = img->transparent_red; 4553 - *p_out++ = img->transparent_green; 4554 - *p_out++ = img->transparent_blue; 4555 - } 4556 - else 4557 - p_out += 3; 4558 - } 4559 - } 4560 - return GGRAPH_OK; 4561 -} 4562 - 4563 -GGRAPH_PRIVATE int 4564 -gg_resample_transparent_rgba (const gGraphImagePtr img) 4565 -{ 4566 -/* 4567 -/ resampling colors so to make near-transparent values 4568 -/ to be really transparent 4569 -*/ 4570 - int x; 4571 - int y; 4572 - unsigned char *p_in; 4573 - unsigned char *p_out; 4574 - unsigned char r; 4575 - unsigned char g; 4576 - unsigned char b; 4577 - 4578 - if (img->pixel_format != GG_PIXEL_RGBA) 4579 - return GGRAPH_ERROR; 4580 - 4581 - for (y = 0; y < img->height; y++) 4582 - { 4583 - p_in = img->pixels + (y * img->scanline_width); 4584 - p_out = img->pixels + (y * img->scanline_width); 4585 - for (x = 0; x < img->width; x++) 4586 - { 4587 - r = *p_in++; 4588 - g = *p_in++; 4589 - b = *p_in++; 4590 - p_in++; 4591 - if (is_near_transparent (r, g, b, img)) 4592 - { 4593 - *p_out++ = img->transparent_red; 4594 - *p_out++ = img->transparent_green; 4595 - *p_out++ = img->transparent_blue; 4596 - *p_out++ = 0; 4597 - } 4598 - else 4599 - p_out += 4; 4600 - } 4601 - } 4602 - return GGRAPH_OK; 4603 -} 4604 - 4605 -GGRAPH_PRIVATE int 4606 -gg_resample_transparent_grayscale (const gGraphImagePtr img) 4607 -{ 4608 -/* 4609 -/ resampling colors so to make near-transparent values 4610 -/ to be really transparent 4611 -*/ 4612 - int x; 4613 - int y; 4614 - unsigned char r; 4615 - unsigned char g; 4616 - unsigned char b; 4617 - unsigned char *p_in; 4618 - unsigned char *p_out; 4619 - 4620 - if (img->pixel_format != GG_PIXEL_GRAYSCALE) 4621 - return GGRAPH_ERROR; 4622 - if (img->transparent_red == img->transparent_green 4623 - && img->transparent_red == img->transparent_blue) 4624 - ; 4625 - else 4626 - return GGRAPH_OK; 4627 - 4628 - for (y = 0; y < img->height; y++) 4629 - { 4630 - p_in = img->pixels + (y * img->scanline_width); 4631 - p_out = img->pixels + (y * img->scanline_width); 4632 - for (x = 0; x < img->width; x++) 4633 - { 4634 - r = *p_in++; 4635 - g = r; 4636 - b = r; 4637 - if (is_near_transparent (r, g, b, img)) 4638 - *p_out = img->transparent_red; 4639 - p_out++; 4640 - } 4641 - } 4642 - return GGRAPH_OK; 4643 -} 4644 - 4645 -GGRAPH_PRIVATE int 4646 -gg_resample_transparent_palette (const gGraphImagePtr img) 4647 -{ 4648 -/* 4649 -/ resampling colors so to make near-transparent values 4650 -/ to be really transparent 4651 -*/ 4652 - int x; 4653 - int y; 4654 - int idx; 4655 - unsigned char r; 4656 - unsigned char g; 4657 - unsigned char b; 4658 - int transparent_idx = -1; 4659 - unsigned char *p_in; 4660 - unsigned char *p_out; 4661 - 4662 - if (img->pixel_format != GG_PIXEL_RGB) 4663 - return GGRAPH_ERROR; 4664 - for (idx = 0; idx < img->max_palette; idx++) 4665 - { 4666 - if (img->palette_red[idx] == img->transparent_red && 4667 - img->palette_green[idx] == img->transparent_green && 4668 - img->palette_blue[idx] == img->transparent_blue) 4669 - { 4670 - transparent_idx = idx; 4671 - break; 4672 - } 4673 - } 4674 - if (transparent_idx < 0) 4675 - return GGRAPH_OK; 4676 - 4677 - for (y = 0; y < img->height; y++) 4678 - { 4679 - p_in = img->pixels + (y * img->scanline_width); 4680 - p_out = p_in; 4681 - for (x = 0; x < img->width; x++) 4682 - { 4683 - idx = *p_in++; 4684 - r = img->palette_red[idx]; 4685 - g = img->palette_green[idx]; 4686 - b = img->palette_blue[idx]; 4687 - if (is_near_transparent (r, g, b, img)) 4688 - *p_out = transparent_idx; 4689 - p_out++; 4690 - } 4691 - } 4692 - return GGRAPH_OK; 4693 -}
Deleted src/gaiagraphics_io.c.
1 -/* 2 -/ gaiagraphics_io.c 3 -/ 4 -/ IO helper methods 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2009 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdio.h> 28 -#include <stdlib.h> 29 -#include <string.h> 30 -#include <limits.h> 31 - 32 -#include <tiffio.h> 33 - 34 -#include "gaiagraphics.h" 35 -#include "gaiagraphics_internals.h" 36 - 37 -#define TRUE 1 38 -#define FALSE 0 39 - 40 -GGRAPH_DECLARE void 41 -gGraphSmartPrintf (double value, char *buf) 42 -{ 43 -/* well formatting a decimal number */ 44 - int i; 45 - sprintf (buf, "%1.18f", value); 46 - for (i = strlen (buf) - 1; i >= 0; i--) 47 - { 48 - if (buf[i] == '0') 49 - buf[i] = '\0'; 50 - else 51 - break; 52 - } 53 - i = strlen (buf) - 1; 54 - if (buf[i] == '.') 55 - buf[i] = '\0'; 56 -} 57 - 58 -GGRAPH_PRIVATE int 59 -gg_endian_arch () 60 -{ 61 -/* checking if target CPU is a little-endian one */ 62 - union cvt 63 - { 64 - unsigned char byte[4]; 65 - int int_value; 66 - } convert; 67 - convert.int_value = 1; 68 - if (convert.byte[0] == 0) 69 - return 0; 70 - return 1; 71 -} 72 - 73 -GGRAPH_PRIVATE short 74 -gg_import_int16 (const unsigned char *p, int little_endian, 75 - int little_endian_arch) 76 -{ 77 -/* fetches a signed 16bit int from BLOB respecting declared endiannes */ 78 - union cvt 79 - { 80 - unsigned char byte[2]; 81 - short short_value; 82 - } convert; 83 - if (little_endian_arch) 84 - { 85 - /* Litte-Endian architecture [e.g. x86] */ 86 - if (!little_endian) 87 - { 88 - /* Big Endian data */ 89 - convert.byte[0] = *(p + 1); 90 - convert.byte[1] = *(p + 0); 91 - } 92 - else 93 - { 94 - /* Little Endian data */ 95 - convert.byte[0] = *(p + 0); 96 - convert.byte[1] = *(p + 1); 97 - } 98 - } 99 - else 100 - { 101 - /* Big Endian architecture [e.g. PPC] */ 102 - if (!little_endian) 103 - { 104 - /* Big Endian data */ 105 - convert.byte[0] = *(p + 0); 106 - convert.byte[1] = *(p + 1); 107 - } 108 - else 109 - { 110 - /* Little Endian data */ 111 - convert.byte[0] = *(p + 1); 112 - convert.byte[1] = *(p + 0); 113 - } 114 - } 115 - return convert.short_value; 116 -} 117 - 118 -GGRAPH_PRIVATE unsigned short 119 -gg_import_uint16 (const unsigned char *p, int little_endian, 120 - int little_endian_arch) 121 -{ 122 -/* fetches an unsigned 16bit int from BLOB respecting declared endiannes */ 123 - union cvt 124 - { 125 - unsigned char byte[2]; 126 - unsigned short short_value; 127 - } convert; 128 - if (little_endian_arch) 129 - { 130 - /* Litte-Endian architecture [e.g. x86] */ 131 - if (!little_endian) 132 - { 133 - /* Big Endian data */ 134 - convert.byte[0] = *(p + 1); 135 - convert.byte[1] = *(p + 0); 136 - } 137 - else 138 - { 139 - /* Little Endian data */ 140 - convert.byte[0] = *(p + 0); 141 - convert.byte[1] = *(p + 1); 142 - } 143 - } 144 - else 145 - { 146 - /* Big Endian architecture [e.g. PPC] */ 147 - if (!little_endian) 148 - { 149 - /* Big Endian data */ 150 - convert.byte[0] = *(p + 0); 151 - convert.byte[1] = *(p + 1); 152 - } 153 - else 154 - { 155 - /* Little Endian data */ 156 - convert.byte[0] = *(p + 1); 157 - convert.byte[1] = *(p + 0); 158 - } 159 - } 160 - return convert.short_value; 161 -} 162 - 163 -GGRAPH_PRIVATE int 164 -gg_import_int32 (const unsigned char *p, int little_endian, 165 - int little_endian_arch) 166 -{ 167 -/* fetches a signed 32bit int from BLOB respecting declared endiannes */ 168 - union cvt 169 - { 170 - unsigned char byte[4]; 171 - int int_value; 172 - } convert; 173 - if (little_endian_arch) 174 - { 175 - /* Litte-Endian architecture [e.g. x86] */ 176 - if (!little_endian) 177 - { 178 - /* Big Endian data */ 179 - convert.byte[0] = *(p + 3); 180 - convert.byte[1] = *(p + 2); 181 - convert.byte[2] = *(p + 1); 182 - convert.byte[3] = *(p + 0); 183 - } 184 - else 185 - { 186 - /* Little Endian data */ 187 - convert.byte[0] = *(p + 0); 188 - convert.byte[1] = *(p + 1); 189 - convert.byte[2] = *(p + 2); 190 - convert.byte[3] = *(p + 3); 191 - } 192 - } 193 - else 194 - { 195 - /* Big Endian architecture [e.g. PPC] */ 196 - if (!little_endian) 197 - { 198 - /* Big Endian data */ 199 - convert.byte[0] = *(p + 0); 200 - convert.byte[1] = *(p + 1); 201 - convert.byte[2] = *(p + 2); 202 - convert.byte[3] = *(p + 3); 203 - } 204 - else 205 - { 206 - /* Little Endian data */ 207 - convert.byte[0] = *(p + 3); 208 - convert.byte[1] = *(p + 2); 209 - convert.byte[2] = *(p + 1); 210 - convert.byte[3] = *(p + 0); 211 - } 212 - } 213 - return convert.int_value; 214 -} 215 - 216 -GGRAPH_PRIVATE unsigned int 217 -gg_import_uint32 (const unsigned char *p, int little_endian, 218 - int little_endian_arch) 219 -{ 220 -/* fetches an unsigned 32bit int from BLOB respecting declared endiannes */ 221 - union cvt 222 - { 223 - unsigned char byte[4]; 224 - unsigned int int_value; 225 - } convert; 226 - if (little_endian_arch) 227 - { 228 - /* Litte-Endian architecture [e.g. x86] */ 229 - if (!little_endian) 230 - { 231 - /* Big Endian data */ 232 - convert.byte[0] = *(p + 3); 233 - convert.byte[1] = *(p + 2); 234 - convert.byte[2] = *(p + 1); 235 - convert.byte[3] = *(p + 0); 236 - } 237 - else 238 - { 239 - /* Little Endian data */ 240 - convert.byte[0] = *(p + 0); 241 - convert.byte[1] = *(p + 1); 242 - convert.byte[2] = *(p + 2); 243 - convert.byte[3] = *(p + 3); 244 - } 245 - } 246 - else 247 - { 248 - /* Big Endian architecture [e.g. PPC] */ 249 - if (!little_endian) 250 - { 251 - /* Big Endian data */ 252 - convert.byte[0] = *(p + 0); 253 - convert.byte[1] = *(p + 1); 254 - convert.byte[2] = *(p + 2); 255 - convert.byte[3] = *(p + 3); 256 - } 257 - else 258 - { 259 - /* Little Endian data */ 260 - convert.byte[0] = *(p + 3); 261 - convert.byte[1] = *(p + 2); 262 - convert.byte[2] = *(p + 1); 263 - convert.byte[3] = *(p + 0); 264 - } 265 - } 266 - return convert.int_value; 267 -} 268 - 269 -GGRAPH_PRIVATE float 270 -gg_import_float (const unsigned char *p, int little_endian, 271 - int little_endian_arch) 272 -{ 273 -/* fetches a 32bit float from BLOB respecting declared endiannes */ 274 - union cvt 275 - { 276 - unsigned char byte[4]; 277 - float flt_value; 278 - } convert; 279 - if (little_endian_arch) 280 - { 281 - /* Litte-Endian architecture [e.g. x86] */ 282 - if (!little_endian) 283 - { 284 - /* Big Endian data */ 285 - convert.byte[0] = *(p + 3); 286 - convert.byte[1] = *(p + 2); 287 - convert.byte[2] = *(p + 1); 288 - convert.byte[3] = *(p + 0); 289 - } 290 - else 291 - { 292 - /* Little Endian data */ 293 - convert.byte[0] = *(p + 0); 294 - convert.byte[1] = *(p + 1); 295 - convert.byte[2] = *(p + 2); 296 - convert.byte[3] = *(p + 3); 297 - } 298 - } 299 - else 300 - { 301 - /* Big Endian architecture [e.g. PPC] */ 302 - if (!little_endian) 303 - { 304 - /* Big Endian data */ 305 - convert.byte[0] = *(p + 0); 306 - convert.byte[1] = *(p + 1); 307 - convert.byte[2] = *(p + 2); 308 - convert.byte[3] = *(p + 3); 309 - } 310 - else 311 - { 312 - /* Little Endian data */ 313 - convert.byte[0] = *(p + 3); 314 - convert.byte[1] = *(p + 2); 315 - convert.byte[2] = *(p + 1); 316 - convert.byte[3] = *(p + 0); 317 - } 318 - } 319 - return convert.flt_value; 320 -} 321 - 322 -GGRAPH_PRIVATE double 323 -gg_import_double (const unsigned char *p, int little_endian, 324 - int little_endian_arch) 325 -{ 326 -/* fetches a 64bit double from BLOB respecting declared endiannes */ 327 - union cvt 328 - { 329 - unsigned char byte[8]; 330 - double double_value; 331 - } convert; 332 - if (little_endian_arch) 333 - { 334 -/* Litte-Endian architecture [e.g. x86] */ 335 - if (!little_endian) 336 - { 337 - /* Big Endian data */ 338 - convert.byte[0] = *(p + 7); 339 - convert.byte[1] = *(p + 6); 340 - convert.byte[2] = *(p + 5); 341 - convert.byte[3] = *(p + 4); 342 - convert.byte[4] = *(p + 3); 343 - convert.byte[5] = *(p + 2); 344 - convert.byte[6] = *(p + 1); 345 - convert.byte[7] = *(p + 0); 346 - } 347 - else 348 - { 349 - /* Little Endian data */ 350 - convert.byte[0] = *(p + 0); 351 - convert.byte[1] = *(p + 1); 352 - convert.byte[2] = *(p + 2); 353 - convert.byte[3] = *(p + 3); 354 - convert.byte[4] = *(p + 4); 355 - convert.byte[5] = *(p + 5); 356 - convert.byte[6] = *(p + 6); 357 - convert.byte[7] = *(p + 7); 358 - } 359 - } 360 - else 361 - { 362 - /* Big Endian architecture [e.g. PPC] */ 363 - if (!little_endian) 364 - { 365 - /* Big Endian data */ 366 - convert.byte[0] = *(p + 0); 367 - convert.byte[1] = *(p + 1); 368 - convert.byte[2] = *(p + 2); 369 - convert.byte[3] = *(p + 3); 370 - convert.byte[4] = *(p + 4); 371 - convert.byte[5] = *(p + 5); 372 - convert.byte[6] = *(p + 6); 373 - convert.byte[7] = *(p + 7); 374 - } 375 - else 376 - { 377 - /* Little Endian data */ 378 - convert.byte[0] = *(p + 7); 379 - convert.byte[1] = *(p + 6); 380 - convert.byte[2] = *(p + 5); 381 - convert.byte[3] = *(p + 4); 382 - convert.byte[4] = *(p + 3); 383 - convert.byte[5] = *(p + 2); 384 - convert.byte[6] = *(p + 1); 385 - convert.byte[7] = *(p + 0); 386 - } 387 - } 388 - return convert.double_value; 389 -} 390 - 391 -GGRAPH_PRIVATE void 392 -gg_export_int16 (short value, unsigned char *p, int little_endian, 393 - int little_endian_arch) 394 -{ 395 -/* stores a signed 16bit int into a BLOB respecting declared endiannes */ 396 - union cvt 397 - { 398 - unsigned char byte[2]; 399 - short short_value; 400 - } convert; 401 - convert.short_value = value; 402 - if (little_endian_arch) 403 - { 404 - /* Litte-Endian architecture [e.g. x86] */ 405 - if (!little_endian) 406 - { 407 - /* Big Endian data */ 408 - *(p + 1) = convert.byte[0]; 409 - *(p + 0) = convert.byte[1]; 410 - } 411 - else 412 - { 413 - /* Little Endian data */ 414 - *(p + 0) = convert.byte[0]; 415 - *(p + 1) = convert.byte[1]; 416 - } 417 - } 418 - else 419 - { 420 - /* Big Endian architecture [e.g. PPC] */ 421 - if (!little_endian) 422 - { 423 - /* Big Endian data */ 424 - *(p + 0) = convert.byte[0]; 425 - *(p + 1) = convert.byte[1]; 426 - } 427 - else 428 - { 429 - /* Little Endian data */ 430 - *(p + 1) = convert.byte[0]; 431 - *(p + 0) = convert.byte[1]; 432 - } 433 - } 434 -} 435 - 436 -GGRAPH_PRIVATE void 437 -gg_export_uint16 (unsigned short value, unsigned char *p, int little_endian, 438 - int little_endian_arch) 439 -{ 440 -/* stores an unsigned 16bit int into a BLOB respecting declared endiannes */ 441 - union cvt 442 - { 443 - unsigned char byte[2]; 444 - unsigned short ushort_value; 445 - } convert; 446 - convert.ushort_value = value; 447 - if (little_endian_arch) 448 - { 449 - /* Litte-Endian architecture [e.g. x86] */ 450 - if (!little_endian) 451 - { 452 - /* Big Endian data */ 453 - *(p + 1) = convert.byte[0]; 454 - *(p + 0) = convert.byte[1]; 455 - } 456 - else 457 - { 458 - /* Little Endian data */ 459 - *(p + 0) = convert.byte[0]; 460 - *(p + 1) = convert.byte[1]; 461 - } 462 - } 463 - else 464 - { 465 - /* Big Endian architecture [e.g. PPC] */ 466 - if (!little_endian) 467 - { 468 - /* Big Endian data */ 469 - *(p + 0) = convert.byte[0]; 470 - *(p + 1) = convert.byte[1]; 471 - } 472 - else 473 - { 474 - /* Little Endian data */ 475 - *(p + 1) = convert.byte[0]; 476 - *(p + 0) = convert.byte[1]; 477 - } 478 - } 479 -} 480 - 481 -GGRAPH_PRIVATE void 482 -gg_export_int32 (int value, unsigned char *p, int little_endian, 483 - int little_endian_arch) 484 -{ 485 -/* stores a signed 32bit int into a BLOB respecting declared endiannes */ 486 - union cvt 487 - { 488 - unsigned char byte[4]; 489 - int int_value; 490 - } convert; 491 - convert.int_value = value; 492 - if (little_endian_arch) 493 - { 494 - /* Litte-Endian architecture [e.g. x86] */ 495 - if (!little_endian) 496 - { 497 - /* Big Endian data */ 498 - *(p + 3) = convert.byte[0]; 499 - *(p + 2) = convert.byte[1]; 500 - *(p + 1) = convert.byte[2]; 501 - *(p + 0) = convert.byte[3]; 502 - } 503 - else 504 - { 505 - /* Little Endian data */ 506 - *(p + 0) = convert.byte[0]; 507 - *(p + 1) = convert.byte[1]; 508 - *(p + 2) = convert.byte[2]; 509 - *(p + 3) = convert.byte[3]; 510 - } 511 - } 512 - else 513 - { 514 - /* Big Endian architecture [e.g. PPC] */ 515 - if (!little_endian) 516 - { 517 - /* Big Endian data */ 518 - *(p + 0) = convert.byte[0]; 519 - *(p + 1) = convert.byte[1]; 520 - *(p + 2) = convert.byte[2]; 521 - *(p + 3) = convert.byte[3]; 522 - } 523 - else 524 - { 525 - /* Little Endian data */ 526 - *(p + 3) = convert.byte[0]; 527 - *(p + 2) = convert.byte[1]; 528 - *(p + 1) = convert.byte[2]; 529 - *(p + 0) = convert.byte[3]; 530 - } 531 - } 532 -} 533 - 534 -GGRAPH_PRIVATE void 535 -gg_export_uint32 (unsigned int value, unsigned char *p, int little_endian, 536 - int little_endian_arch) 537 -{ 538 -/* stores an unsigned 32bit int into a BLOB respecting declared endiannes */ 539 - union cvt 540 - { 541 - unsigned char byte[4]; 542 - unsigned int uint_value; 543 - } convert; 544 - convert.uint_value = value; 545 - if (little_endian_arch) 546 - { 547 - /* Litte-Endian architecture [e.g. x86] */ 548 - if (!little_endian) 549 - { 550 - /* Big Endian data */ 551 - *(p + 3) = convert.byte[0]; 552 - *(p + 2) = convert.byte[1]; 553 - *(p + 1) = convert.byte[2]; 554 - *(p + 0) = convert.byte[3]; 555 - } 556 - else 557 - { 558 - /* Little Endian data */ 559 - *(p + 0) = convert.byte[0]; 560 - *(p + 1) = convert.byte[1]; 561 - *(p + 2) = convert.byte[2]; 562 - *(p + 3) = convert.byte[3]; 563 - } 564 - } 565 - else 566 - { 567 - /* Big Endian architecture [e.g. PPC] */ 568 - if (!little_endian) 569 - { 570 - /* Big Endian data */ 571 - *(p + 0) = convert.byte[0]; 572 - *(p + 1) = convert.byte[1]; 573 - *(p + 2) = convert.byte[2]; 574 - *(p + 3) = convert.byte[3]; 575 - } 576 - else 577 - { 578 - /* Little Endian data */ 579 - *(p + 3) = convert.byte[0]; 580 - *(p + 2) = convert.byte[1]; 581 - *(p + 1) = convert.byte[2]; 582 - *(p + 0) = convert.byte[3]; 583 - } 584 - } 585 -} 586 - 587 -GGRAPH_PRIVATE void 588 -gg_export_float (float value, unsigned char *p, int little_endian, 589 - int little_endian_arch) 590 -{ 591 -/* stores a Float into a BLOB respecting declared endiannes */ 592 - union cvt 593 - { 594 - unsigned char byte[4]; 595 - float flt_value; 596 - } convert; 597 - convert.flt_value = value; 598 - if (little_endian_arch) 599 - { 600 - /* Litte-Endian architecture [e.g. x86] */ 601 - if (!little_endian) 602 - { 603 - /* Big Endian data */ 604 - *(p + 3) = convert.byte[0]; 605 - *(p + 2) = convert.byte[1]; 606 - *(p + 1) = convert.byte[2]; 607 - *(p + 0) = convert.byte[3]; 608 - } 609 - else 610 - { 611 - /* Little Endian data */ 612 - *(p + 0) = convert.byte[0]; 613 - *(p + 1) = convert.byte[1]; 614 - *(p + 2) = convert.byte[2]; 615 - *(p + 3) = convert.byte[3]; 616 - } 617 - } 618 - else 619 - { 620 - /* Big Endian architecture [e.g. PPC] */ 621 - if (!little_endian) 622 - { 623 - /* Big Endian data */ 624 - *(p + 0) = convert.byte[0]; 625 - *(p + 1) = convert.byte[1]; 626 - *(p + 2) = convert.byte[2]; 627 - *(p + 3) = convert.byte[3]; 628 - } 629 - else 630 - { 631 - /* Little Endian data */ 632 - *(p + 3) = convert.byte[0]; 633 - *(p + 2) = convert.byte[1]; 634 - *(p + 1) = convert.byte[2]; 635 - *(p + 0) = convert.byte[3]; 636 - } 637 - } 638 -} 639 - 640 -GGRAPH_PRIVATE void 641 -gg_export_double (double value, unsigned char *p, int little_endian, 642 - int little_endian_arch) 643 -{ 644 -/* stores a Double into a BLOB respecting declared endiannes */ 645 - union cvt 646 - { 647 - unsigned char byte[8]; 648 - double dbl_value; 649 - } convert; 650 - convert.dbl_value = value; 651 - if (little_endian_arch) 652 - { 653 - /* Litte-Endian architecture [e.g. x86] */ 654 - if (!little_endian) 655 - { 656 - /* Big Endian data */ 657 - *(p + 7) = convert.byte[0]; 658 - *(p + 6) = convert.byte[1]; 659 - *(p + 5) = convert.byte[2]; 660 - *(p + 4) = convert.byte[3]; 661 - *(p + 3) = convert.byte[4]; 662 - *(p + 2) = convert.byte[5]; 663 - *(p + 1) = convert.byte[6]; 664 - *(p + 0) = convert.byte[7]; 665 - } 666 - else 667 - { 668 - /* Little Endian data */ 669 - *(p + 0) = convert.byte[0]; 670 - *(p + 1) = convert.byte[1]; 671 - *(p + 2) = convert.byte[2]; 672 - *(p + 3) = convert.byte[3]; 673 - *(p + 4) = convert.byte[4]; 674 - *(p + 5) = convert.byte[5]; 675 - *(p + 6) = convert.byte[6]; 676 - *(p + 7) = convert.byte[7]; 677 - } 678 - } 679 - else 680 - { 681 - /* Big Endian architecture [e.g. PPC] */ 682 - if (!little_endian) 683 - { 684 - /* Big Endian data */ 685 - *(p + 0) = convert.byte[0]; 686 - *(p + 1) = convert.byte[1]; 687 - *(p + 2) = convert.byte[2]; 688 - *(p + 3) = convert.byte[3]; 689 - *(p + 4) = convert.byte[4]; 690 - *(p + 5) = convert.byte[5]; 691 - *(p + 6) = convert.byte[6]; 692 - *(p + 7) = convert.byte[7]; 693 - } 694 - else 695 - { 696 - /* Little Endian data */ 697 - *(p + 7) = convert.byte[0]; 698 - *(p + 6) = convert.byte[1]; 699 - *(p + 5) = convert.byte[2]; 700 - *(p + 4) = convert.byte[3]; 701 - *(p + 3) = convert.byte[4]; 702 - *(p + 2) = convert.byte[5]; 703 - *(p + 1) = convert.byte[6]; 704 - *(p + 0) = convert.byte[7]; 705 - } 706 - } 707 -} 708 - 709 -/* 710 -/ 711 -/ DISCLAIMER: 712 -/ all the following code merely is an 'ad hoc' adaption 713 -/ deriving from the original GD lib code 714 -/ 715 -*/ 716 - 717 -static int 718 -xgdReallocMemory (dynamicPtr * dp, int required) 719 -{ 720 - void *newPtr; 721 - if ((newPtr = realloc (dp->data, required))) 722 - { 723 - dp->realSize = required; 724 - dp->data = newPtr; 725 - return TRUE; 726 - } 727 - newPtr = malloc (required); 728 - if (!newPtr) 729 - { 730 - dp->dataGood = FALSE; 731 - return FALSE; 732 - } 733 - memcpy (newPtr, dp->data, dp->logicalSize); 734 - free (dp->data); 735 - dp->data = newPtr; 736 - dp->realSize = required; 737 - return TRUE; 738 -} 739 - 740 -static void 741 -xgdFreeMemoryCtx (struct xgdIOCtx *ctx) 742 -{ 743 - dynamicPtr *dp; 744 - dpIOCtx *dctx; 745 - dctx = (dpIOCtx *) ctx; 746 - dp = dctx->dp; 747 - free (ctx); 748 - if ((dp->data != NULL) && (dp->freeOK)) 749 - { 750 - free (dp->data); 751 - dp->data = NULL; 752 - } 753 - dp->realSize = 0; 754 - dp->logicalSize = 0; 755 - free (dp); 756 -} 757 - 758 -static void 759 -xgdFreeFileCtx (struct xgdIOCtx *ctx) 760 -{ 761 - dynamicPtr *dp; 762 - dpIOCtx *dctx; 763 - dctx = (dpIOCtx *) ctx; 764 - dp = dctx->dp; 765 - free (ctx); 766 - free (dp); 767 -} 768 - 769 -static int 770 -allocMemory (dynamicPtr * dp, int initialSize, const void *data) 771 -{ 772 - if (data == NULL) 773 - { 774 - dp->logicalSize = 0; 775 - dp->dataGood = FALSE; 776 - dp->data = malloc (initialSize); 777 - } 778 - else 779 - { 780 - dp->logicalSize = initialSize; 781 - dp->dataGood = TRUE; 782 - dp->data = (void *) data; 783 - } 784 - if (dp->data != NULL) 785 - { 786 - dp->realSize = initialSize; 787 - dp->dataGood = TRUE; 788 - dp->pos = 0; 789 - return TRUE; 790 - } 791 - else 792 - { 793 - dp->realSize = 0; 794 - return FALSE; 795 - } 796 -} 797 - 798 -static int 799 -appendMemory (dynamicPtr * dp, const void *src, int size) 800 -{ 801 - int bytesNeeded; 802 - char *tmp; 803 - if (!dp->dataGood) 804 - return FALSE; 805 - bytesNeeded = dp->pos + size; 806 - if (bytesNeeded > dp->realSize) 807 - { 808 - if (!dp->freeOK) 809 - return FALSE; 810 - if (overflow2 (dp->realSize, 2)) 811 - return FALSE; 812 - if (!xgdReallocMemory (dp, bytesNeeded * 2)) 813 - { 814 - dp->dataGood = FALSE; 815 - return FALSE; 816 - } 817 - } 818 - tmp = (char *) dp->data; 819 - memcpy ((void *) (tmp + (dp->pos)), src, size); 820 - dp->pos += size; 821 - if (dp->pos > dp->logicalSize) 822 - dp->logicalSize = dp->pos; 823 - return TRUE; 824 -} 825 - 826 -static int 827 -appendFile (dynamicPtr * dp, const void *src, int size) 828 -{ 829 - size_t wr = fwrite (src, 1, size, dp->file); 830 - return (int) wr; 831 -} 832 - 833 -static int 834 -memoryPutbuf (struct xgdIOCtx *ctx, const void *buf, int size) 835 -{ 836 - dpIOCtx *dctx; 837 - dctx = (dpIOCtx *) ctx; 838 - appendMemory (dctx->dp, buf, size); 839 - if (dctx->dp->dataGood) 840 - return size; 841 - else 842 - return -1; 843 -} 844 - 845 -static int 846 -filePutbuf (struct xgdIOCtx *ctx, const void *buf, int size) 847 -{ 848 - dpIOCtx *dctx; 849 - dctx = (dpIOCtx *) ctx; 850 - if (appendFile (dctx->dp, buf, size) == size) 851 - return size; 852 - else 853 - return -1; 854 -} 855 - 856 -static void 857 -memoryPutchar (struct xgdIOCtx *ctx, int a) 858 -{ 859 - unsigned char b; 860 - dpIOCtxPtr dctx; 861 - b = a; 862 - dctx = (dpIOCtxPtr) ctx; 863 - appendMemory (dctx->dp, &b, 1); 864 -} 865 - 866 -static void 867 -filePutchar (struct xgdIOCtx *ctx, int a) 868 -{ 869 - unsigned char b; 870 - dpIOCtxPtr dctx; 871 - b = a; 872 - dctx = (dpIOCtxPtr) ctx; 873 - appendFile (dctx->dp, &b, 1); 874 -} 875 - 876 -static int 877 -memoryGetbuf (xgdIOCtxPtr ctx, void *buf, int len) 878 -{ 879 - int rlen, remain; 880 - dpIOCtxPtr dctx; 881 - dynamicPtr *dp; 882 - dctx = (dpIOCtxPtr) ctx; 883 - dp = dctx->dp; 884 - remain = dp->logicalSize - dp->pos; 885 - if (remain >= len) 886 - rlen = len; 887 - else 888 - { 889 - if (remain == 0) 890 - return 0; 891 - rlen = remain; 892 - } 893 - memcpy (buf, (void *) ((char *) dp->data + dp->pos), rlen); 894 - dp->pos += rlen; 895 - return rlen; 896 -} 897 - 898 -static int 899 -fileGetbuf (xgdIOCtxPtr ctx, void *buf, int len) 900 -{ 901 - dynamicPtr *dp; 902 - dpIOCtxPtr dctx; 903 - dctx = (dpIOCtxPtr) ctx; 904 - dp = dctx->dp; 905 - return fread (buf, 1, len, dp->file); 906 -} 907 - 908 -static int 909 -memoryGetchar (xgdIOCtxPtr ctx) 910 -{ 911 - unsigned char b; 912 - int rv; 913 - rv = memoryGetbuf (ctx, &b, 1); 914 - if (rv != 1) 915 - return EOF; 916 - else 917 - return b; 918 -} 919 - 920 -static int 921 -fileGetchar (xgdIOCtxPtr ctx) 922 -{ 923 - unsigned char b; 924 - int rv; 925 - rv = fileGetbuf (ctx, &b, 1); 926 - if (rv != 1) 927 - return EOF; 928 - else 929 - return b; 930 -} 931 - 932 -static long 933 -memoryTell (struct xgdIOCtx *ctx) 934 -{ 935 - dpIOCtx *dctx; 936 - dctx = (dpIOCtx *) ctx; 937 - return (dctx->dp->pos); 938 -} 939 - 940 -static long 941 -fileTell (struct xgdIOCtx *ctx) 942 -{ 943 - dynamicPtr *dp; 944 - dpIOCtx *dctx; 945 - dctx = (dpIOCtx *) ctx; 946 - dp = dctx->dp; 947 - return ftell (dp->file); 948 -} 949 - 950 -static int 951 -memorySeek (struct xgdIOCtx *ctx, const int pos) 952 -{ 953 - int bytesNeeded; 954 - dynamicPtr *dp; 955 - dpIOCtx *dctx; 956 - dctx = (dpIOCtx *) ctx; 957 - dp = dctx->dp; 958 - if (!dp->dataGood) 959 - return FALSE; 960 - bytesNeeded = pos; 961 - if (bytesNeeded > dp->realSize) 962 - { 963 - if (!dp->freeOK) 964 - return FALSE; 965 - if (overflow2 (dp->realSize, 2)) 966 - return FALSE; 967 - if (!xgdReallocMemory (dp, dp->realSize * 2)) 968 - { 969 - dp->dataGood = FALSE; 970 - return FALSE; 971 - } 972 - } 973 - if (pos > dp->logicalSize) 974 - dp->logicalSize = pos; 975 - dp->pos = pos; 976 - return TRUE; 977 -} 978 - 979 -static int 980 -fileSeek (struct xgdIOCtx *ctx, const int pos) 981 -{ 982 - dynamicPtr *dp; 983 - dpIOCtx *dctx; 984 - dctx = (dpIOCtx *) ctx; 985 - dp = dctx->dp; 986 - if (fseek (dp->file, pos, SEEK_SET) < 0) 987 - return FALSE; 988 - else 989 - return TRUE; 990 -} 991 - 992 -static dynamicPtr * 993 -newMemory (int initialSize, const void *data, int freeOKFlag) 994 -{ 995 - dynamicPtr *dp; 996 - dp = malloc (sizeof (dynamicPtr)); 997 - if (dp == NULL) 998 - return NULL; 999 - if (!allocMemory (dp, initialSize, data)) 1000 - return NULL; 1001 - dp->pos = 0; 1002 - if (freeOKFlag == XGD_CTX_FREE) 1003 - dp->freeOK = 1; 1004 - else 1005 - dp->freeOK = 0; 1006 - return dp; 1007 -} 1008 - 1009 -static dynamicPtr * 1010 -newFile (const void *data) 1011 -{ 1012 - dynamicPtr *dp; 1013 - dp = malloc (sizeof (dynamicPtr)); 1014 - if (dp == NULL) 1015 - return NULL; 1016 - dp->file = (FILE *) data; 1017 - return dp; 1018 -} 1019 - 1020 -static int 1021 -trimMemory (dynamicPtr * dp) 1022 -{ 1023 - if (!dp->freeOK) 1024 - return TRUE; 1025 - return xgdReallocMemory (dp, dp->logicalSize); 1026 -} 1027 - 1028 -GGRAPH_PRIVATE int 1029 -overflow2 (int a, int b) 1030 -{ 1031 - if (a < 0 || b < 0) 1032 - { 1033 - fprintf (stderr, 1034 - "warning: one parameter to a memory allocation multiplication is negative, failing operation gracefully\n"); 1035 - return 1; 1036 - } 1037 - if (b == 0) 1038 - return 0; 1039 - if (a > INT_MAX / b) 1040 - { 1041 - fprintf (stderr, 1042 - "warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n"); 1043 - return 1; 1044 - } 1045 - return 0; 1046 -} 1047 - 1048 -GGRAPH_PRIVATE void * 1049 -xgdDPExtractData (struct xgdIOCtx *ctx, int *size) 1050 -{ 1051 - dynamicPtr *dp; 1052 - dpIOCtx *dctx; 1053 - void *data; 1054 - dctx = (dpIOCtx *) ctx; 1055 - dp = dctx->dp; 1056 - if (dp->dataGood) 1057 - { 1058 - trimMemory (dp); 1059 - *size = dp->logicalSize; 1060 - data = dp->data; 1061 - } 1062 - else 1063 - { 1064 - *size = 0; 1065 - data = NULL; 1066 - if ((dp->data != NULL) && (dp->freeOK)) 1067 - free (dp->data); 1068 - } 1069 - dp->data = NULL; 1070 - dp->realSize = 0; 1071 - dp->logicalSize = 0; 1072 - return data; 1073 -} 1074 - 1075 -GGRAPH_PRIVATE xgdIOCtx * 1076 -xgdNewDynamicCtx (int initialSize, const void *data, int mem_or_file) 1077 -{ 1078 - return xgdNewDynamicCtxEx (initialSize, data, XGD_CTX_FREE, mem_or_file); 1079 -} 1080 - 1081 -GGRAPH_PRIVATE xgdIOCtx * 1082 -xgdNewDynamicCtxEx (int initialSize, const void *data, int freeOKFlag, 1083 - int mem_or_file) 1084 -{ 1085 - dpIOCtx *ctx; 1086 - dynamicPtr *dp; 1087 - ctx = malloc (sizeof (dpIOCtx)); 1088 - if (ctx == NULL) 1089 - { 1090 - return NULL; 1091 - } 1092 - if (mem_or_file == GG_TARGET_IS_FILE) 1093 - { 1094 - dp = newFile (data); 1095 - if (!dp) 1096 - { 1097 - free (ctx); 1098 - return NULL; 1099 - }; 1100 - ctx->dp = dp; 1101 - ctx->ctx.getC = fileGetchar; 1102 - ctx->ctx.putC = filePutchar; 1103 - ctx->ctx.getBuf = fileGetbuf; 1104 - ctx->ctx.putBuf = filePutbuf; 1105 - ctx->ctx.seek = fileSeek; 1106 - ctx->ctx.tell = fileTell; 1107 - ctx->ctx.xgd_free = xgdFreeFileCtx; 1108 - } 1109 - else 1110 - { 1111 - dp = newMemory (initialSize, data, freeOKFlag); 1112 - if (!dp) 1113 - { 1114 - free (ctx); 1115 - return NULL; 1116 - }; 1117 - ctx->dp = dp; 1118 - ctx->ctx.getC = memoryGetchar; 1119 - ctx->ctx.putC = memoryPutchar; 1120 - ctx->ctx.getBuf = memoryGetbuf; 1121 - ctx->ctx.putBuf = memoryPutbuf; 1122 - ctx->ctx.seek = memorySeek; 1123 - ctx->ctx.tell = memoryTell; 1124 - ctx->ctx.xgd_free = xgdFreeMemoryCtx; 1125 - } 1126 - return (xgdIOCtx *) ctx; 1127 -} 1128 - 1129 -GGRAPH_PRIVATE int 1130 -xgdPutBuf (const void *buf, int size, xgdIOCtx * ctx) 1131 -{ 1132 - return (ctx->putBuf) (ctx, buf, size); 1133 -} 1134 - 1135 -GGRAPH_PRIVATE int 1136 -xgdGetBuf (void *buf, int size, xgdIOCtx * ctx) 1137 -{ 1138 - return (ctx->getBuf) (ctx, buf, size); 1139 -}
Deleted src/gaiagraphics_jpeg.c.
1 -/* 2 -/ gaiagraphics_jpeg.c 3 -/ 4 -/ JPEG auxiliary helpers 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdio.h> 28 -#include <stdlib.h> 29 -#include <setjmp.h> 30 -#include <limits.h> 31 -#include <string.h> 32 - 33 -#include <jpeglib.h> 34 -#include <jerror.h> 35 - 36 -#include "gaiagraphics.h" 37 -#include "gaiagraphics_internals.h" 38 - 39 -struct jpeg_codec_data 40 -{ 41 -/* a struct used by JPEG codec */ 42 - int is_writer; 43 - struct jpeg_compress_struct cmp_cinfo; 44 - struct jpeg_decompress_struct dec_cinfo; 45 - JSAMPROW row; 46 - xgdIOCtx *io_ctx; 47 -}; 48 - 49 -/* 50 -/ 51 -/ DISCLAIMER: 52 -/ the following code is vaguely derived from the original GD lib 53 -/ code, which was originally released under a BSD-like license 54 -/ 55 -*/ 56 - 57 -#define OUTPUT_BUF_SIZE 4096 58 - 59 -#ifdef HAVE_BOOLEAN 60 -typedef boolean safeboolean; 61 -#else 62 -typedef int safeboolean; 63 -#endif /* HAVE_BOOLEAN */ 64 - 65 -typedef struct _jmpbuf_wrapper 66 -{ 67 - jmp_buf jmpbuf; 68 -} 69 -jmpbuf_wrapper; 70 - 71 -typedef struct 72 -{ 73 - struct jpeg_destination_mgr pub; 74 - xgdIOCtx *outfile; 75 - unsigned char *buffer; 76 -} 77 -my_destination_mgr; 78 - 79 -typedef struct 80 -{ 81 - struct jpeg_source_mgr pub; 82 - xgdIOCtx *infile; 83 - unsigned char *buffer; 84 - safeboolean start_of_file; 85 -} 86 -my_source_mgr; 87 - 88 -typedef my_source_mgr *my_src_ptr; 89 - 90 -#define INPUT_BUF_SIZE 4096 91 - 92 -typedef my_destination_mgr *my_dest_ptr; 93 - 94 -static void 95 -fatal_jpeg_error (j_common_ptr cinfo) 96 -{ 97 - jmpbuf_wrapper *jmpbufw; 98 - 99 - fprintf (stderr, 100 - "jpeg-wrapper: JPEG library reports unrecoverable error: "); 101 - (*cinfo->err->output_message) (cinfo); 102 - fflush (stderr); 103 - jmpbufw = (jmpbuf_wrapper *) cinfo->client_data; 104 - jpeg_destroy (cinfo); 105 - if (jmpbufw != 0) 106 - { 107 - longjmp (jmpbufw->jmpbuf, 1); 108 - fprintf (stderr, "jpeg-wrappeg: EXTREMELY fatal error: longjmp" 109 - " returned control; terminating\n"); 110 - } 111 - else 112 - { 113 - fprintf (stderr, "jpeg-wrappeg: EXTREMELY fatal error: jmpbuf" 114 - " unrecoverable; terminating\n"); 115 - } 116 - fflush (stderr); 117 - exit (99); 118 -} 119 - 120 -static void 121 -init_source (j_decompress_ptr cinfo) 122 -{ 123 - my_src_ptr src = (my_src_ptr) cinfo->src; 124 - src->start_of_file = TRUE; 125 -} 126 - 127 -#define END_JPEG_SEQUENCE "\r\n[*]--:END JPEG:--[*]\r\n" 128 -static safeboolean 129 -fill_input_buffer (j_decompress_ptr cinfo) 130 -{ 131 - my_src_ptr src = (my_src_ptr) cinfo->src; 132 - int nbytes = 0; 133 - memset (src->buffer, 0, INPUT_BUF_SIZE); 134 - while (nbytes < INPUT_BUF_SIZE) 135 - { 136 - int got = xgdGetBuf (src->buffer + nbytes, 137 - INPUT_BUF_SIZE - nbytes, 138 - src->infile); 139 - if ((got == EOF) || (got == 0)) 140 - { 141 - if (!nbytes) 142 - { 143 - nbytes = -1; 144 - } 145 - break; 146 - } 147 - nbytes += got; 148 - } 149 - if (nbytes <= 0) 150 - { 151 - if (src->start_of_file) 152 - ERREXIT (cinfo, JERR_INPUT_EMPTY); 153 - WARNMS (cinfo, JWRN_JPEG_EOF); 154 - src->buffer[0] = (unsigned char) 0xFF; 155 - src->buffer[1] = (unsigned char) JPEG_EOI; 156 - nbytes = 2; 157 - } 158 - src->pub.next_input_byte = (JOCTET *) (src->buffer); 159 - src->pub.bytes_in_buffer = nbytes; 160 - src->start_of_file = FALSE; 161 - return TRUE; 162 -} 163 - 164 -static void 165 -skip_input_data (j_decompress_ptr cinfo, long num_bytes) 166 -{ 167 - my_src_ptr src = (my_src_ptr) cinfo->src; 168 - if (num_bytes > 0) 169 - { 170 - while (num_bytes > (long) src->pub.bytes_in_buffer) 171 - { 172 - num_bytes -= (long) src->pub.bytes_in_buffer; 173 - (void) fill_input_buffer (cinfo); 174 - } 175 - src->pub.next_input_byte += (size_t) num_bytes; 176 - src->pub.bytes_in_buffer -= (size_t) num_bytes; 177 - } 178 -} 179 - 180 -static void 181 -term_source (j_decompress_ptr cinfo) 182 -{ 183 - if (cinfo) 184 - return; /* does absolutely nothing - required in order to suppress warnings */ 185 -} 186 - 187 -static void 188 -init_destination (j_compress_ptr cinfo) 189 -{ 190 - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; 191 - dest->buffer = (unsigned char *) 192 - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 193 - OUTPUT_BUF_SIZE * sizeof (unsigned char)); 194 - dest->pub.next_output_byte = (JOCTET *) (dest->buffer); 195 - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; 196 -} 197 - 198 -static safeboolean 199 -empty_output_buffer (j_compress_ptr cinfo) 200 -{ 201 - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; 202 - if (xgdPutBuf (dest->buffer, OUTPUT_BUF_SIZE, dest->outfile) != 203 - (size_t) OUTPUT_BUF_SIZE) 204 - ERREXIT (cinfo, JERR_FILE_WRITE); 205 - dest->pub.next_output_byte = (JOCTET *) (dest->buffer); 206 - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; 207 - return TRUE; 208 -} 209 - 210 -static void 211 -term_destination (j_compress_ptr cinfo) 212 -{ 213 - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; 214 - size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; 215 - if (datacount > 0) 216 - { 217 - if (xgdPutBuf (dest->buffer, datacount, dest->outfile) != 218 - (int) datacount) 219 - ERREXIT (cinfo, JERR_FILE_WRITE); 220 - } 221 -} 222 - 223 -static void 224 -jpeg_xgdIOCtx_src (j_decompress_ptr cinfo, xgdIOCtx * infile) 225 -{ 226 - my_src_ptr src; 227 - if (cinfo->src == NULL) 228 - { 229 - cinfo->src = (struct jpeg_source_mgr *) 230 - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 231 - sizeof (my_source_mgr)); 232 - src = (my_src_ptr) cinfo->src; 233 - src->buffer = (unsigned char *) 234 - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 235 - INPUT_BUF_SIZE * 236 - sizeof (unsigned char)); 237 - 238 - } 239 - src = (my_src_ptr) cinfo->src; 240 - src->pub.init_source = init_source; 241 - src->pub.fill_input_buffer = fill_input_buffer; 242 - src->pub.skip_input_data = skip_input_data; 243 - src->pub.resync_to_restart = jpeg_resync_to_restart; 244 - src->pub.term_source = term_source; 245 - src->infile = infile; 246 - src->pub.bytes_in_buffer = 0; 247 - src->pub.next_input_byte = NULL; 248 -} 249 - 250 -static void 251 -jpeg_xgdIOCtx_dest (j_compress_ptr cinfo, xgdIOCtx * outfile) 252 -{ 253 - my_dest_ptr dest; 254 - if (cinfo->dest == NULL) 255 - { 256 - cinfo->dest = (struct jpeg_destination_mgr *) 257 - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 258 - sizeof (my_destination_mgr)); 259 - } 260 - dest = (my_dest_ptr) cinfo->dest; 261 - dest->pub.init_destination = init_destination; 262 - dest->pub.empty_output_buffer = empty_output_buffer; 263 - dest->pub.term_destination = term_destination; 264 - dest->outfile = outfile; 265 -} 266 - 267 -static int 268 -xgdImageJpegCtx (gGraphImagePtr img, xgdIOCtx * outfile, int quality) 269 -{ 270 -/* compressing a JPEG image */ 271 - struct jpeg_compress_struct cinfo; 272 - struct jpeg_error_mgr jerr; 273 - int i, j, jidx; 274 - volatile JSAMPROW row = 0; 275 - JSAMPROW rowptr[1]; 276 - jmpbuf_wrapper jmpbufw; 277 - JDIMENSION nlines; 278 - char comment[255]; 279 - memset (&cinfo, 0, sizeof (cinfo)); 280 - memset (&jerr, 0, sizeof (jerr)); 281 - cinfo.err = jpeg_std_error (&jerr); 282 - cinfo.client_data = &jmpbufw; 283 - if (setjmp (jmpbufw.jmpbuf) != 0) 284 - { 285 - if (row) 286 - free (row); 287 - return GGRAPH_JPEG_CODEC_ERROR; 288 - } 289 - cinfo.err->error_exit = fatal_jpeg_error; 290 - jpeg_create_compress (&cinfo); 291 - cinfo.image_width = img->width; 292 - cinfo.image_height = img->height; 293 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 294 - { 295 - /* GRAYSCALE */ 296 - cinfo.input_components = 1; 297 - cinfo.in_color_space = JCS_GRAYSCALE; 298 - } 299 - else 300 - { 301 - /* RGB */ 302 - cinfo.input_components = 3; 303 - cinfo.in_color_space = JCS_RGB; 304 - } 305 - jpeg_set_defaults (&cinfo); 306 - if (quality >= 0) 307 - jpeg_set_quality (&cinfo, quality, TRUE); 308 - jpeg_xgdIOCtx_dest (&cinfo, outfile); 309 - row = (JSAMPROW) calloc (1, cinfo.image_width * cinfo.input_components 310 - * sizeof (JSAMPLE)); 311 - if (row == 0) 312 - { 313 - jpeg_destroy_compress (&cinfo); 314 - return GGRAPH_INSUFFICIENT_MEMORY; 315 - } 316 - rowptr[0] = row; 317 - jpeg_start_compress (&cinfo, TRUE); 318 - sprintf (comment, "CREATOR: jpeg-wrapper (using IJG JPEG v%d),", 319 - JPEG_LIB_VERSION); 320 - if (quality >= 0) 321 - sprintf (comment + strlen (comment), " quality = %d\n", quality); 322 - else 323 - strcat (comment + strlen (comment), " default quality\n"); 324 - jpeg_write_marker (&cinfo, JPEG_COM, (unsigned char *) comment, 325 - (unsigned int) strlen (comment)); 326 -#if BITS_IN_JSAMPLE == 12 327 - fprintf (stderr, 328 - "jpeg-wrapper: error: jpeg library was compiled for 12-bit\n"); 329 - goto error; 330 -#endif /* BITS_IN_JSAMPLE == 12 */ 331 - for (i = 0; i < img->height; i++) 332 - { 333 - unsigned char *p_in = img->pixels + (i * img->scanline_width); 334 - for (jidx = 0, j = 0; j < img->width; j++) 335 - { 336 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 337 - { 338 - /* GRAYSCALE */ 339 - row[jidx++] = *p_in++; 340 - } 341 - else 342 - { 343 - /* RGB */ 344 - unsigned char r; 345 - unsigned char g; 346 - unsigned char b; 347 - if (img->pixel_format == GG_PIXEL_RGB) 348 - { 349 - r = *p_in++; 350 - g = *p_in++; 351 - b = *p_in++; 352 - } 353 - else if (img->pixel_format == GG_PIXEL_RGBA) 354 - { 355 - r = *p_in++; 356 - g = *p_in++; 357 - b = *p_in++; 358 - p_in++; /* skipping Alpha */ 359 - } 360 - else if (img->pixel_format == GG_PIXEL_ARGB) 361 - { 362 - p_in++; /* skipping Alpha */ 363 - r = *p_in++; 364 - g = *p_in++; 365 - b = *p_in++; 366 - } 367 - else if (img->pixel_format == GG_PIXEL_BGR) 368 - { 369 - b = *p_in++; 370 - g = *p_in++; 371 - r = *p_in++; 372 - } 373 - else if (img->pixel_format == GG_PIXEL_BGRA) 374 - { 375 - b = *p_in++; 376 - g = *p_in++; 377 - r = *p_in++; 378 - p_in++; /* skipping Alpha */ 379 - } 380 - else if (img->pixel_format == GG_PIXEL_PALETTE) 381 - { 382 - int index = *p_in++; 383 - r = img->palette_red[index]; 384 - g = img->palette_green[index]; 385 - b = img->palette_blue[index]; 386 - } 387 - row[jidx++] = r; 388 - row[jidx++] = g; 389 - row[jidx++] = b; 390 - } 391 - } 392 - nlines = jpeg_write_scanlines (&cinfo, rowptr, 1); 393 - if (nlines != 1) 394 - fprintf (stderr, "jpeg-wrapper: warning: jpeg_write_scanlines" 395 - " returns %u -- expected 1\n", nlines); 396 - } 397 - jpeg_finish_compress (&cinfo); 398 - jpeg_destroy_compress (&cinfo); 399 - free (row); 400 - return GGRAPH_OK; 401 -} 402 - 403 -GGRAPH_PRIVATE void 404 -gg_jpeg_codec_destroy (void *p) 405 -{ 406 -/* destroyng the JPEG codec data */ 407 - jmpbuf_wrapper jmpbufw; 408 - struct jpeg_codec_data *codec = (struct jpeg_codec_data *) p; 409 - 410 - if (!codec) 411 - return; 412 - 413 - if (codec->is_writer) 414 - { 415 - codec->cmp_cinfo.client_data = &jmpbufw; 416 - if (setjmp (jmpbufw.jmpbuf) != 0) 417 - { 418 - fprintf (stderr, "SetJump\n"); 419 - fflush (stderr); 420 - return; 421 - } 422 - jpeg_finish_compress (&(codec->cmp_cinfo)); 423 - jpeg_destroy_compress (&(codec->cmp_cinfo)); 424 - } 425 - else 426 - { 427 - codec->dec_cinfo.client_data = &jmpbufw; 428 - if (setjmp (jmpbufw.jmpbuf) != 0) 429 - { 430 - fprintf (stderr, "SetJump\n"); 431 - fflush (stderr); 432 - return; 433 - } 434 - jpeg_destroy_decompress (&(codec->dec_cinfo)); 435 - } 436 - free (codec->row); 437 - codec->io_ctx->xgd_free (codec->io_ctx); 438 - free (codec); 439 -} 440 - 441 -static int 442 -xgdStripImageJpegCtx (gGraphStripImagePtr img, xgdIOCtx * outfile, int quality) 443 -{ 444 -/* preparing to compress a JPEG image (by strip) */ 445 - struct jpeg_compress_struct cinfo; 446 - struct jpeg_error_mgr jerr; 447 - volatile JSAMPROW row = 0; 448 - jmpbuf_wrapper jmpbufw; 449 - char comment[255]; 450 - struct jpeg_codec_data *jpeg_codec; 451 - memset (&cinfo, 0, sizeof (cinfo)); 452 - memset (&jerr, 0, sizeof (jerr)); 453 - cinfo.err = jpeg_std_error (&jerr); 454 - cinfo.client_data = &jmpbufw; 455 - if (setjmp (jmpbufw.jmpbuf) != 0) 456 - { 457 - if (row) 458 - free (row); 459 - return GGRAPH_JPEG_CODEC_ERROR; 460 - } 461 - cinfo.err->error_exit = fatal_jpeg_error; 462 - jpeg_create_compress (&cinfo); 463 - cinfo.image_width = img->width; 464 - cinfo.image_height = img->height; 465 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 466 - { 467 - /* GRAYSCALE */ 468 - cinfo.input_components = 1; 469 - cinfo.in_color_space = JCS_GRAYSCALE; 470 - } 471 - else 472 - { 473 - /* RGB */ 474 - cinfo.input_components = 3; 475 - cinfo.in_color_space = JCS_RGB; 476 - } 477 - jpeg_set_defaults (&cinfo); 478 - if (quality >= 0) 479 - jpeg_set_quality (&cinfo, quality, TRUE); 480 - jpeg_xgdIOCtx_dest (&cinfo, outfile); 481 - row = (JSAMPROW) calloc (1, cinfo.image_width * cinfo.input_components 482 - * sizeof (JSAMPLE)); 483 - if (row == 0) 484 - { 485 - jpeg_destroy_compress (&cinfo); 486 - return GGRAPH_INSUFFICIENT_MEMORY; 487 - } 488 - jpeg_start_compress (&cinfo, TRUE); 489 - sprintf (comment, "CREATOR: jpeg-wrapper (using IJG JPEG v%d),", 490 - JPEG_LIB_VERSION); 491 - if (quality >= 0) 492 - sprintf (comment + strlen (comment), " quality = %d\n", quality); 493 - else 494 - strcat (comment + strlen (comment), " default quality\n"); 495 - jpeg_write_marker (&cinfo, JPEG_COM, (unsigned char *) comment, 496 - (unsigned int) strlen (comment)); 497 - 498 -/* setting up the JPEG codec struct */ 499 - jpeg_codec = malloc (sizeof (struct jpeg_codec_data)); 500 - if (!jpeg_codec) 501 - { 502 - jpeg_destroy_compress (&cinfo); 503 - free (row); 504 - gg_strip_image_destroy (img); 505 - return GGRAPH_INSUFFICIENT_MEMORY; 506 - } 507 - jpeg_codec->is_writer = 1; 508 - memcpy (&(jpeg_codec->cmp_cinfo), &cinfo, 509 - sizeof (struct jpeg_compress_struct)); 510 - jpeg_codec->row = row; 511 - jpeg_codec->io_ctx = outfile; 512 - img->codec_data = jpeg_codec; 513 - 514 - return GGRAPH_OK; 515 -} 516 - 517 -static int 518 -xgdStripImageJpegWriteCtx (gGraphStripImagePtr img) 519 -{ 520 -/* compressing a JPEG image (by strip) */ 521 - int i, j, jidx; 522 - int height; 523 - struct jpeg_codec_data *jpeg_codec = 524 - (struct jpeg_codec_data *) (img->codec_data); 525 - JSAMPROW rowptr[1]; 526 - JDIMENSION nlines; 527 - volatile JSAMPROW row = jpeg_codec->row; 528 - jmpbuf_wrapper jmpbufw; 529 - 530 - rowptr[0] = jpeg_codec->row; 531 - if (img->next_row >= img->height) 532 - { 533 - /* EOF condition */ 534 - fprintf (stderr, "png-wrapper error: attempting to write beyond EOF"); 535 - return GGRAPH_PNG_CODEC_ERROR; 536 - } 537 - height = img->current_available_rows; 538 - 539 - jpeg_codec->cmp_cinfo.client_data = &jmpbufw; 540 - if (setjmp (jmpbufw.jmpbuf) != 0) 541 - return GGRAPH_JPEG_CODEC_ERROR; 542 - for (i = 0; i < height; i++) 543 - { 544 - unsigned char *p_in = img->pixels + (i * img->scanline_width); 545 - for (jidx = 0, j = 0; j < img->width; j++) 546 - { 547 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 548 - { 549 - /* GRAYSCALE */ 550 - row[jidx++] = *p_in++; 551 - } 552 - else 553 - { 554 - /* RGB */ 555 - unsigned char r; 556 - unsigned char g; 557 - unsigned char b; 558 - if (img->pixel_format == GG_PIXEL_RGB) 559 - { 560 - r = *p_in++; 561 - g = *p_in++; 562 - b = *p_in++; 563 - } 564 - else if (img->pixel_format == GG_PIXEL_RGBA) 565 - { 566 - r = *p_in++; 567 - g = *p_in++; 568 - b = *p_in++; 569 - p_in++; /* skipping Alpha */ 570 - } 571 - else if (img->pixel_format == GG_PIXEL_ARGB) 572 - { 573 - p_in++; /* skipping Alpha */ 574 - r = *p_in++; 575 - g = *p_in++; 576 - b = *p_in++; 577 - } 578 - else if (img->pixel_format == GG_PIXEL_BGR) 579 - { 580 - b = *p_in++; 581 - g = *p_in++; 582 - r = *p_in++; 583 - } 584 - else if (img->pixel_format == GG_PIXEL_BGRA) 585 - { 586 - b = *p_in++; 587 - g = *p_in++; 588 - r = *p_in++; 589 - p_in++; /* skipping Alpha */ 590 - } 591 - else if (img->pixel_format == GG_PIXEL_PALETTE) 592 - { 593 - int index = *p_in++; 594 - r = img->palette_red[index]; 595 - g = img->palette_green[index]; 596 - b = img->palette_blue[index]; 597 - } 598 - row[jidx++] = r; 599 - row[jidx++] = g; 600 - row[jidx++] = b; 601 - } 602 - } 603 - nlines = jpeg_write_scanlines (&(jpeg_codec->cmp_cinfo), rowptr, 1); 604 - if (nlines != 1) 605 - fprintf (stderr, "jpeg-wrapper: warning: jpeg_write_scanlines" 606 - " returns %u -- expected 1\n", nlines); 607 - } 608 - img->next_row += height; 609 - return GGRAPH_OK; 610 -} 611 - 612 -static void 613 -CMYKToRGB (int c, int m, int y, int k, int inverted, unsigned char *red, 614 - unsigned char *green, unsigned char *blue) 615 -{ 616 - if (inverted) 617 - { 618 - c = 255 - c; 619 - m = 255 - m; 620 - y = 255 - y; 621 - k = 255 - k; 622 - } 623 - *red = (255 - c) * (255 - k) / 255; 624 - *green = (255 - m) * (255 - k) / 255; 625 - *blue = (255 - y) * (255 - k) / 255; 626 -} 627 - 628 -static gGraphImageInfosPtr 629 -xgdImageInspectJpegCtx (xgdIOCtx * infile, int *errcode) 630 -{ 631 - struct jpeg_decompress_struct cinfo; 632 - struct jpeg_error_mgr jerr; 633 - volatile gGraphImageInfosPtr infos = 0; 634 - int retval; 635 - jmpbuf_wrapper jmpbufw; 636 - memset (&cinfo, 0, sizeof (cinfo)); 637 - memset (&jerr, 0, sizeof (jerr)); 638 - cinfo.err = jpeg_std_error (&jerr); 639 - cinfo.client_data = &jmpbufw; 640 - if (setjmp (jmpbufw.jmpbuf) != 0) 641 - { 642 - if (infos) 643 - gg_image_infos_destroy (infos); 644 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 645 - return NULL; 646 - } 647 - cinfo.err->error_exit = fatal_jpeg_error; 648 - jpeg_create_decompress (&cinfo); 649 - jpeg_xgdIOCtx_src (&cinfo, infile); 650 - jpeg_save_markers (&cinfo, JPEG_APP0 + 14, 256); 651 - retval = jpeg_read_header (&cinfo, TRUE); 652 - if (retval != JPEG_HEADER_OK) 653 - fprintf (stderr, "jpeg-wrapper: warning: jpeg_read_header returns" 654 - " %d, expected %d\n", retval, JPEG_HEADER_OK); 655 - if (cinfo.image_height > INT_MAX) 656 - fprintf (stderr, 657 - "jpeg-wrapper: warning: JPEG image height (%u) is greater than INT_MAX\n", 658 - cinfo.image_height); 659 - if (cinfo.image_width > INT_MAX) 660 - fprintf (stderr, 661 - "jpeg-wrapper: warning: JPEG image width (%u) is greater than INT_MAX\n", 662 - cinfo.image_width); 663 - 664 - if ((cinfo.jpeg_color_space == JCS_CMYK) || 665 - (cinfo.jpeg_color_space == JCS_YCCK)) 666 - cinfo.out_color_space = JCS_CMYK; 667 - else if (cinfo.jpeg_color_space == JCS_GRAYSCALE) 668 - cinfo.out_color_space = JCS_GRAYSCALE; 669 - else 670 - cinfo.out_color_space = JCS_RGB; 671 - 672 - if (cinfo.out_color_space == JCS_GRAYSCALE) 673 - infos = 674 - gg_image_infos_create (GG_PIXEL_GRAYSCALE, (int) cinfo.image_width, 675 - (int) cinfo.image_height, 8, 1, 676 - GGRAPH_SAMPLE_UINT, NULL, NULL); 677 - else 678 - infos = 679 - gg_image_infos_create (GG_PIXEL_RGB, (int) cinfo.image_width, 680 - (int) cinfo.image_height, 8, 3, 681 - GGRAPH_SAMPLE_UINT, NULL, NULL); 682 - if (infos == NULL) 683 - { 684 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 685 - goto error; 686 - } 687 - infos->compression = GGRAPH_TIFF_COMPRESSION_JPEG; 688 - infos->scale_1_2 = 1; 689 - infos->scale_1_4 = 1; 690 - infos->scale_1_8 = 1; 691 - return infos; 692 - error: 693 - if (infos) 694 - gg_image_infos_destroy (infos); 695 - return NULL; 696 -} 697 - 698 -static gGraphImagePtr 699 -xgdImageCreateFromJpegCtx (xgdIOCtx * infile, int *errcode, int scale) 700 -{ 701 -/* decompressing a JPEG image */ 702 - struct jpeg_decompress_struct cinfo; 703 - struct jpeg_error_mgr jerr; 704 - jmpbuf_wrapper jmpbufw; 705 - volatile JSAMPROW row = 0; 706 - volatile gGraphImagePtr img = 0; 707 - JSAMPROW rowptr[1]; 708 - int i, j, retval; 709 - JDIMENSION nrows; 710 - int channels = 3; 711 - int inverted = 0; 712 - unsigned char red; 713 - unsigned char green; 714 - unsigned char blue; 715 - memset (&cinfo, 0, sizeof (cinfo)); 716 - memset (&jerr, 0, sizeof (jerr)); 717 - cinfo.err = jpeg_std_error (&jerr); 718 - cinfo.client_data = &jmpbufw; 719 - if (setjmp (jmpbufw.jmpbuf) != 0) 720 - { 721 - if (row) 722 - free (row); 723 - if (img) 724 - gg_image_destroy (img); 725 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 726 - return NULL; 727 - } 728 - cinfo.err->error_exit = fatal_jpeg_error; 729 - jpeg_create_decompress (&cinfo); 730 - jpeg_xgdIOCtx_src (&cinfo, infile); 731 - jpeg_save_markers (&cinfo, JPEG_APP0 + 14, 256); 732 - retval = jpeg_read_header (&cinfo, TRUE); 733 - if (retval != JPEG_HEADER_OK) 734 - fprintf (stderr, "jpeg-wrapper: warning: jpeg_read_header returns" 735 - " %d, expected %d\n", retval, JPEG_HEADER_OK); 736 - if (cinfo.image_height > INT_MAX) 737 - fprintf (stderr, 738 - "jpeg-wrapper: warning: JPEG image height (%u) is greater than INT_MAX\n", 739 - cinfo.image_height); 740 - if (cinfo.image_width > INT_MAX) 741 - fprintf (stderr, 742 - "jpeg-wrapper: warning: JPEG image width (%u) is greater than INT_MAX\n", 743 - cinfo.image_width); 744 - 745 - if (scale == 8) 746 - { 747 - /* requesting 1:8 scaling */ 748 - cinfo.scale_num = 1; 749 - } 750 - else if (scale == 4) 751 - { 752 - /* requesting 1:4 scaling */ 753 - cinfo.scale_num = 2; 754 - } 755 - else if (scale == 2) 756 - { 757 - /* requesting 1:2 scaling */ 758 - cinfo.scale_num = 4; 759 - } 760 - else 761 - { 762 - /* no scaling, full dimension */ 763 - cinfo.scale_num = 8; 764 - } 765 - cinfo.scale_denom = 8; 766 - if ((cinfo.jpeg_color_space == JCS_CMYK) || 767 - (cinfo.jpeg_color_space == JCS_YCCK)) 768 - cinfo.out_color_space = JCS_CMYK; 769 - else if (cinfo.jpeg_color_space == JCS_GRAYSCALE) 770 - cinfo.out_color_space = JCS_GRAYSCALE; 771 - else 772 - cinfo.out_color_space = JCS_RGB; 773 - 774 - if (jpeg_start_decompress (&cinfo) != TRUE) 775 - fprintf (stderr, 776 - "jpeg-wrapper: warning: jpeg_start_decompress reports suspended data source\n"); 777 - if (cinfo.out_color_space == JCS_GRAYSCALE) 778 - img = 779 - gg_image_create (GG_PIXEL_GRAYSCALE, (int) cinfo.output_width, 780 - (int) cinfo.output_height, 8, 1, 781 - GGRAPH_SAMPLE_UINT, NULL, NULL); 782 - else 783 - img = 784 - gg_image_create (GG_PIXEL_RGB, (int) cinfo.output_width, 785 - (int) cinfo.output_height, 8, 3, 786 - GGRAPH_SAMPLE_UINT, NULL, NULL); 787 - if (img == NULL) 788 - { 789 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 790 - goto error; 791 - } 792 - if (cinfo.out_color_space == JCS_RGB) 793 - { 794 - if (cinfo.output_components != 3) 795 - { 796 - fprintf (stderr, 797 - "jpeg-wrapper: error: JPEG color output_components == %d\n", 798 - cinfo.output_components); 799 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 800 - goto error; 801 - } 802 - channels = 3; 803 - } 804 - else if (cinfo.out_color_space == JCS_GRAYSCALE) 805 - { 806 - if (cinfo.output_components != 1) 807 - { 808 - fprintf (stderr, 809 - "jpeg-wrapper: error: JPEG color output_components == %d\n", 810 - cinfo.output_components); 811 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 812 - goto error; 813 - } 814 - channels = 1; 815 - } 816 - else if (cinfo.out_color_space == JCS_CMYK) 817 - { 818 - jpeg_saved_marker_ptr marker; 819 - if (cinfo.output_components != 4) 820 - { 821 - fprintf (stderr, 822 - "jpeg-wrapper: error: JPEG output_components == %d\n", 823 - cinfo.output_components); 824 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 825 - goto error; 826 - } 827 - channels = 4; 828 - marker = cinfo.marker_list; 829 - while (marker) 830 - { 831 - if ((marker->marker == (JPEG_APP0 + 14)) && 832 - (marker->data_length >= 12) 833 - && (!strncmp ((const char *) marker->data, "Adobe", 5))) 834 - { 835 - inverted = 1; 836 - break; 837 - } 838 - marker = marker->next; 839 - } 840 - } 841 - else 842 - { 843 - fprintf (stderr, "jpeg-wrapper: error: unexpected colorspace\n"); 844 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 845 - goto error; 846 - } 847 -#if BITS_IN_JSAMPLE == 12 848 - fprintf (stderr, 849 - "jpeg-wrapper: error: jpeg library was compiled for 12-bit\n"); 850 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 851 - goto error; 852 -#endif /* BITS_IN_JSAMPLE == 12 */ 853 - row = calloc (cinfo.output_width * channels, sizeof (JSAMPLE)); 854 - if (row == 0) 855 - { 856 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 857 - goto error; 858 - } 859 - rowptr[0] = row; 860 - if (cinfo.out_color_space == JCS_CMYK) 861 - { 862 - for (i = 0; i < (int) cinfo.output_height; i++) 863 - { 864 - register JSAMPROW currow = row; 865 - unsigned char *p_out = img->pixels + (i * img->scanline_width); 866 - nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); 867 - if (nrows != 1) 868 - { 869 - fprintf (stderr, 870 - "jpeg-wrapper: error: jpeg_read_scanlines returns %u, expected 1\n", 871 - nrows); 872 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 873 - goto error; 874 - } 875 - for (j = 0; j < (int) cinfo.output_width; j++, currow += 4) 876 - { 877 - CMYKToRGB (currow[0], currow[1], currow[2], currow[3], 878 - inverted, &red, &green, &blue); 879 - *p_out++ = red; 880 - *p_out++ = green; 881 - *p_out++ = blue; 882 - } 883 - } 884 - } 885 - else if (cinfo.out_color_space == JCS_GRAYSCALE) 886 - { 887 - for (i = 0; i < (int) cinfo.output_height; i++) 888 - { 889 - register JSAMPROW currow = row; 890 - unsigned char *p_out = img->pixels + (i * img->scanline_width); 891 - nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); 892 - if (nrows != 1) 893 - { 894 - fprintf (stderr, 895 - "jpeg-wrapper: error: jpeg_read_scanlines returns %u, expected 1\n", 896 - nrows); 897 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 898 - goto error; 899 - } 900 - for (j = 0; j < (int) cinfo.output_width; j++, currow++) 901 - *p_out++ = currow[0]; 902 - } 903 - } 904 - else 905 - { 906 - for (i = 0; i < (int) cinfo.output_height; i++) 907 - { 908 - register JSAMPROW currow = row; 909 - unsigned char *p_out = img->pixels + (i * img->scanline_width); 910 - nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); 911 - if (nrows != 1) 912 - { 913 - fprintf (stderr, 914 - "jpeg-wrapper: error: jpeg_read_scanlines returns %u, expected 1\n", 915 - nrows); 916 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 917 - goto error; 918 - } 919 - for (j = 0; j < (int) cinfo.output_width; j++, currow += 3) 920 - { 921 - *p_out++ = currow[0]; 922 - *p_out++ = currow[1]; 923 - *p_out++ = currow[2]; 924 - } 925 - } 926 - } 927 - if (jpeg_finish_decompress (&cinfo) != TRUE) 928 - fprintf (stderr, 929 - "jpeg-wrapper: warning: jpeg_finish_decompress reports suspended data source\n"); 930 - jpeg_destroy_decompress (&cinfo); 931 - free (row); 932 - return img; 933 - error: 934 - jpeg_destroy_decompress (&cinfo); 935 - if (row) 936 - free (row); 937 - if (img) 938 - gg_image_destroy (img); 939 - return NULL; 940 -} 941 - 942 -static gGraphStripImagePtr 943 -xgdStripImageCreateFromJpegCtx (xgdIOCtx * infile, int *errcode, FILE * file) 944 -{ 945 -/* preparing to decompress a JPEG image [by strips] */ 946 - struct jpeg_decompress_struct cinfo; 947 - struct jpeg_error_mgr jerr; 948 - jmpbuf_wrapper jmpbufw; 949 - volatile JSAMPROW row = 0; 950 - volatile gGraphStripImagePtr img = 0; 951 - int retval; 952 - int channels = 3; 953 - struct jpeg_codec_data *jpeg_codec; 954 - memset (&cinfo, 0, sizeof (cinfo)); 955 - memset (&jerr, 0, sizeof (jerr)); 956 - cinfo.err = jpeg_std_error (&jerr); 957 - cinfo.client_data = &jmpbufw; 958 - if (setjmp (jmpbufw.jmpbuf) != 0) 959 - { 960 - if (row) 961 - free (row); 962 - if (img) 963 - gg_strip_image_destroy (img); 964 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 965 - return NULL; 966 - } 967 - cinfo.err->error_exit = fatal_jpeg_error; 968 - jpeg_create_decompress (&cinfo); 969 - jpeg_xgdIOCtx_src (&cinfo, infile); 970 - jpeg_save_markers (&cinfo, JPEG_APP0 + 14, 256); 971 - retval = jpeg_read_header (&cinfo, TRUE); 972 - if (retval != JPEG_HEADER_OK) 973 - fprintf (stderr, "jpeg-wrapper: warning: jpeg_read_header returns" 974 - " %d, expected %d\n", retval, JPEG_HEADER_OK); 975 - if (cinfo.image_height > INT_MAX) 976 - fprintf (stderr, 977 - "jpeg-wrapper: warning: JPEG image height (%u) is greater than INT_MAX\n", 978 - cinfo.image_height); 979 - if (cinfo.image_width > INT_MAX) 980 - fprintf (stderr, 981 - "jpeg-wrapper: warning: JPEG image width (%u) is greater than INT_MAX\n", 982 - cinfo.image_width); 983 - cinfo.scale_num = 8; 984 - cinfo.scale_denom = 8; 985 - if ((cinfo.jpeg_color_space == JCS_CMYK) || 986 - (cinfo.jpeg_color_space == JCS_YCCK)) 987 - cinfo.out_color_space = JCS_CMYK; 988 - else if (cinfo.jpeg_color_space == JCS_GRAYSCALE) 989 - cinfo.out_color_space = JCS_GRAYSCALE; 990 - else 991 - cinfo.out_color_space = JCS_RGB; 992 - 993 - if (jpeg_start_decompress (&cinfo) != TRUE) 994 - fprintf (stderr, 995 - "jpeg-wrapper: warning: jpeg_start_decompress reports suspended data source\n"); 996 - if (cinfo.out_color_space == JCS_GRAYSCALE) 997 - img = 998 - gg_strip_image_create (file, GGRAPH_IMAGE_JPEG, GG_PIXEL_GRAYSCALE, 999 - cinfo.output_width, cinfo.output_height, 8, 1000 - 1, GGRAPH_SAMPLE_UINT, NULL, NULL); 1001 - else 1002 - img = 1003 - gg_strip_image_create (file, GGRAPH_IMAGE_JPEG, GG_PIXEL_RGB, 1004 - cinfo.output_width, cinfo.output_height, 8, 1005 - 3, GGRAPH_SAMPLE_UINT, NULL, NULL); 1006 - if (img == NULL) 1007 - { 1008 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 1009 - goto error; 1010 - } 1011 - if (cinfo.out_color_space == JCS_RGB) 1012 - { 1013 - if (cinfo.output_components != 3) 1014 - { 1015 - fprintf (stderr, 1016 - "jpeg-wrapper: error: JPEG color output_components == %d\n", 1017 - cinfo.output_components); 1018 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 1019 - goto error; 1020 - } 1021 - channels = 3; 1022 - } 1023 - else if (cinfo.out_color_space == JCS_GRAYSCALE) 1024 - { 1025 - if (cinfo.output_components != 1) 1026 - { 1027 - fprintf (stderr, 1028 - "jpeg-wrapper: error: JPEG color output_components == %d\n", 1029 - cinfo.output_components); 1030 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 1031 - goto error; 1032 - } 1033 - channels = 1; 1034 - } 1035 - else if (cinfo.out_color_space == JCS_CMYK) 1036 - { 1037 - jpeg_saved_marker_ptr marker; 1038 - if (cinfo.output_components != 4) 1039 - { 1040 - fprintf (stderr, 1041 - "jpeg-wrapper: error: JPEG output_components == %d\n", 1042 - cinfo.output_components); 1043 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 1044 - goto error; 1045 - } 1046 - channels = 4; 1047 - marker = cinfo.marker_list; 1048 - while (marker) 1049 - { 1050 - if ((marker->marker == (JPEG_APP0 + 14)) && 1051 - (marker->data_length >= 12) 1052 - && (!strncmp ((const char *) marker->data, "Adobe", 5))) 1053 - { 1054 - break; 1055 - } 1056 - marker = marker->next; 1057 - } 1058 - } 1059 - else 1060 - { 1061 - fprintf (stderr, "jpeg-wrapper: error: unexpected colorspace\n"); 1062 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 1063 - goto error; 1064 - } 1065 -#if BITS_IN_JSAMPLE == 12 1066 - fprintf (stderr, 1067 - "jpeg-wrapper: error: jpeg library was compiled for 12-bit\n"); 1068 - *errcode = GGRAPH_JPEG_CODEC_ERROR; 1069 - goto error; 1070 -#endif /* BITS_IN_JSAMPLE == 12 */ 1071 - row = calloc (cinfo.output_width * channels, sizeof (JSAMPLE)); 1072 - if (row == 0) 1073 - { 1074 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 1075 - goto error; 1076 - } 1077 - 1078 -/* setting up the JPEG codec struct */ 1079 - jpeg_codec = malloc (sizeof (struct jpeg_codec_data)); 1080 - if (!jpeg_codec) 1081 - { 1082 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 1083 - goto error; 1084 - } 1085 - jpeg_codec->is_writer = 0; 1086 - memcpy (&(jpeg_codec->dec_cinfo), &cinfo, 1087 - sizeof (struct jpeg_decompress_struct)); 1088 - jpeg_codec->row = row; 1089 - jpeg_codec->io_ctx = infile; 1090 - img->codec_data = jpeg_codec; 1091 - 1092 - return img; 1093 - error: 1094 - jpeg_destroy_decompress (&cinfo); 1095 - if (row) 1096 - free (row); 1097 - if (img) 1098 - gg_strip_image_destroy (img); 1099 - return NULL; 1100 -} 1101 - 1102 -static int 1103 -xgdStripImageReadFromJpegCtx (gGraphStripImagePtr img) 1104 -{ 1105 -/* decompressing a JPEG image (by strip) */ 1106 - struct jpeg_codec_data *jpeg_codec = 1107 - (struct jpeg_codec_data *) (img->codec_data); 1108 - jmpbuf_wrapper jmpbufw; 1109 - JSAMPROW rowptr[1]; 1110 - int i, j; 1111 - JDIMENSION nrows; 1112 - int inverted = 0; 1113 - unsigned char red; 1114 - unsigned char green; 1115 - unsigned char blue; 1116 - int height = img->rows_per_block; 1117 - 1118 - if (img->next_row >= img->height) 1119 - { 1120 - /* EOF condition */ 1121 - fprintf (stderr, "jpeg-wrapper error: attempting to read beyond EOF"); 1122 - return GGRAPH_JPEG_CODEC_ERROR; 1123 - } 1124 - if ((img->next_row + img->rows_per_block) >= img->height) 1125 - height = img->height - img->next_row; 1126 - img->current_available_rows = height; 1127 - 1128 - jpeg_codec->dec_cinfo.client_data = &jmpbufw; 1129 - if (setjmp (jmpbufw.jmpbuf) != 0) 1130 - return GGRAPH_JPEG_CODEC_ERROR; 1131 - 1132 - rowptr[0] = jpeg_codec->row; 1133 - if (jpeg_codec->dec_cinfo.out_color_space == JCS_CMYK) 1134 - { 1135 - for (i = 0; i < height; i++) 1136 - { 1137 - register JSAMPROW currow = jpeg_codec->row; 1138 - unsigned char *p_out = img->pixels + (i * img->scanline_width); 1139 - nrows = 1140 - jpeg_read_scanlines (&(jpeg_codec->dec_cinfo), rowptr, 1); 1141 - if (nrows != 1) 1142 - { 1143 - fprintf (stderr, 1144 - "jpeg-wrapper: error: jpeg_read_scanlines returns %u, expected 1\n", 1145 - nrows); 1146 - return GGRAPH_JPEG_CODEC_ERROR; 1147 - } 1148 - for (j = 0; j < (int) jpeg_codec->dec_cinfo.output_width; 1149 - j++, currow += 4) 1150 - { 1151 - CMYKToRGB (currow[0], currow[1], currow[2], currow[3], 1152 - inverted, &red, &green, &blue); 1153 - *p_out++ = red; 1154 - *p_out++ = green; 1155 - *p_out++ = blue; 1156 - } 1157 - } 1158 - } 1159 - else if (jpeg_codec->dec_cinfo.out_color_space == JCS_GRAYSCALE) 1160 - { 1161 - for (i = 0; i < height; i++) 1162 - { 1163 - register JSAMPROW currow = jpeg_codec->row; 1164 - unsigned char *p_out = img->pixels + (i * img->scanline_width); 1165 - nrows = 1166 - jpeg_read_scanlines (&(jpeg_codec->dec_cinfo), rowptr, 1); 1167 - if (nrows != 1) 1168 - { 1169 - fprintf (stderr, 1170 - "jpeg-wrapper: error: jpeg_read_scanlines returns %u, expected 1\n", 1171 - nrows); 1172 - return GGRAPH_JPEG_CODEC_ERROR; 1173 - } 1174 - for (j = 0; j < (int) jpeg_codec->dec_cinfo.output_width; 1175 - j++, currow++) 1176 - *p_out++ = currow[0]; 1177 - } 1178 - } 1179 - else 1180 - { 1181 - for (i = 0; i < height; i++) 1182 - { 1183 - register JSAMPROW currow = jpeg_codec->row; 1184 - unsigned char *p_out = img->pixels + (i * img->scanline_width); 1185 - nrows = 1186 - jpeg_read_scanlines (&(jpeg_codec->dec_cinfo), rowptr, 1); 1187 - if (nrows != 1) 1188 - { 1189 - fprintf (stderr, 1190 - "jpeg-wrapper: error: jpeg_read_scanlines returns %u, expected 1\n", 1191 - nrows); 1192 - return GGRAPH_JPEG_CODEC_ERROR; 1193 - } 1194 - for (j = 0; j < (int) jpeg_codec->dec_cinfo.output_width; 1195 - j++, currow += 3) 1196 - { 1197 - *p_out++ = currow[0]; 1198 - *p_out++ = currow[1]; 1199 - *p_out++ = currow[2]; 1200 - } 1201 - } 1202 - } 1203 - img->next_row += height; 1204 - return GGRAPH_OK; 1205 -} 1206 - 1207 -GGRAPH_PRIVATE int 1208 -gg_image_to_jpeg (const gGraphImagePtr img, void **mem_buf, int *mem_buf_size, 1209 - FILE * file, int dest_type, int quality) 1210 -{ 1211 -/* compressing an image as JPEG */ 1212 - int ret; 1213 - void *rv; 1214 - int size; 1215 - xgdIOCtx *out; 1216 - 1217 -/* checkings args for validity */ 1218 - if (dest_type == GG_TARGET_IS_FILE) 1219 - { 1220 - if (!file) 1221 - return GGRAPH_ERROR; 1222 - } 1223 - else 1224 - { 1225 - if (!mem_buf || !mem_buf_size) 1226 - return GGRAPH_ERROR; 1227 - *mem_buf = NULL; 1228 - *mem_buf_size = 0; 1229 - } 1230 - 1231 - if (dest_type == GG_TARGET_IS_FILE) 1232 - out = xgdNewDynamicCtx (0, file, dest_type); 1233 - else 1234 - out = xgdNewDynamicCtx (2048, NULL, dest_type); 1235 - ret = xgdImageJpegCtx (img, out, quality); 1236 - if (dest_type == GG_TARGET_IS_FILE) 1237 - { 1238 - out->xgd_free (out); 1239 - return ret; 1240 - } 1241 - 1242 - if (ret == GGRAPH_OK) 1243 - rv = xgdDPExtractData (out, &size); 1244 - out->xgd_free (out); 1245 - *mem_buf = rv; 1246 - *mem_buf_size = size; 1247 - return ret; 1248 -} 1249 - 1250 -GGRAPH_PRIVATE int 1251 -gg_image_prepare_to_jpeg_by_strip (const gGraphStripImagePtr img, FILE * file, 1252 - int quality) 1253 -{ 1254 -/* preparing to compress an image as JPEG [by strip] */ 1255 - xgdIOCtx *out; 1256 - 1257 -/* checkings args for validity */ 1258 - if (!file) 1259 - return GGRAPH_ERROR; 1260 - 1261 - out = xgdNewDynamicCtx (0, file, GG_TARGET_IS_FILE); 1262 - return xgdStripImageJpegCtx (img, out, quality); 1263 -} 1264 - 1265 -GGRAPH_PRIVATE int 1266 -gg_image_write_to_jpeg_by_strip (const gGraphStripImagePtr img, int *progress) 1267 -{ 1268 -/* scanline(s) JPEG compression [by strip] */ 1269 - int ret = xgdStripImageJpegWriteCtx (img); 1270 - if (ret == GGRAPH_OK && progress != NULL) 1271 - *progress = 1272 - (int) (((double) (img->next_row + 1) * 100.0) / 1273 - (double) (img->height)); 1274 - return ret; 1275 -} 1276 - 1277 -GGRAPH_PRIVATE int 1278 -gg_image_from_jpeg (int size, const void *data, int source_type, 1279 - gGraphImagePtr * image_handle, int scale) 1280 -{ 1281 -/* uncompressing a JPEG */ 1282 - int errcode = GGRAPH_OK; 1283 - gGraphImagePtr img; 1284 - xgdIOCtx *in = 1285 - xgdNewDynamicCtxEx (size, data, XGD_CTX_DONT_FREE, source_type); 1286 - img = xgdImageCreateFromJpegCtx (in, &errcode, scale); 1287 - in->xgd_free (in); 1288 - *image_handle = img; 1289 - return errcode; 1290 -} 1291 - 1292 -GGRAPH_PRIVATE int 1293 -gg_image_infos_from_jpeg (int size, const void *data, int source_type, 1294 - gGraphImageInfosPtr * infos_handle) 1295 -{ 1296 -/* image infos from JPEG */ 1297 - int errcode = GGRAPH_OK; 1298 - gGraphImageInfosPtr infos; 1299 - xgdIOCtx *in = 1300 - xgdNewDynamicCtxEx (size, data, XGD_CTX_DONT_FREE, source_type); 1301 - infos = xgdImageInspectJpegCtx (in, &errcode); 1302 - in->xgd_free (in); 1303 - *infos_handle = infos; 1304 - return errcode; 1305 -} 1306 - 1307 -GGRAPH_PRIVATE int 1308 -gg_image_strip_prepare_from_jpeg (FILE * file, 1309 - gGraphStripImagePtr * image_handle) 1310 -{ 1311 -/* preparing to uncompress a JPEG [by strips] */ 1312 - int errcode = GGRAPH_OK; 1313 - gGraphStripImagePtr img; 1314 - xgdIOCtx *in = 1315 - xgdNewDynamicCtxEx (0, file, XGD_CTX_DONT_FREE, GG_TARGET_IS_FILE); 1316 - img = xgdStripImageCreateFromJpegCtx (in, &errcode, file); 1317 - *image_handle = img; 1318 - return errcode; 1319 -} 1320 - 1321 -GGRAPH_PRIVATE int 1322 -gg_image_strip_read_from_jpeg (gGraphStripImagePtr img, int *progress) 1323 -{ 1324 -/* uncompressing a JPEG [by strips] */ 1325 - int ret = xgdStripImageReadFromJpegCtx (img); 1326 - if (ret == GGRAPH_OK && progress != NULL) 1327 - *progress = 1328 - (int) (((double) (img->next_row + 1) * 100.0) / 1329 - (double) (img->height)); 1330 - return ret; 1331 -}
Deleted src/gaiagraphics_paint.c.
1 -/* 2 -/ gaiagraphics_paint.c 3 -/ 4 -/ painting helpers 5 -/ 6 -/ version 1.0, 2010 October 19 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2009 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdlib.h> 28 -#include <stdio.h> 29 -#include <string.h> 30 -#include <math.h> 31 - 32 -#include "gaiagraphics.h" 33 -#include "gaiagraphics_internals.h" 34 - 35 -GGRAPH_DECLARE int 36 -gGraphCreateContext (int width, int height, const void **context) 37 -{ 38 -/* creating a Graphics Context */ 39 - gGraphContextPtr ctx; 40 - 41 - *context = NULL; 42 - 43 - ctx = malloc (sizeof (gGraphContext)); 44 - if (!ctx) 45 - return GGRAPH_INSUFFICIENT_MEMORY; 46 - ctx->signature = GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE; 47 - ctx->surface = 48 - cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); 49 - if (cairo_surface_status (ctx->surface) == CAIRO_STATUS_SUCCESS) 50 - ; 51 - else 52 - goto error1; 53 - ctx->cairo = cairo_create (ctx->surface); 54 - if (cairo_status (ctx->cairo) == CAIRO_STATUS_NO_MEMORY) 55 - goto error2; 56 - 57 -/* setting up a default Black Pen */ 58 - ctx->current_pen.red = 0.0; 59 - ctx->current_pen.green = 0.0; 60 - ctx->current_pen.blue = 0.0; 61 - ctx->current_pen.alpha = 1.0; 62 - ctx->current_pen.width = 1.0; 63 - ctx->current_pen.lengths[0] = 1.0; 64 - ctx->current_pen.lengths_count = 1; 65 - 66 -/* setting up a default Black Brush */ 67 - ctx->current_brush.is_solid_color = 1; 68 - ctx->current_brush.is_linear_gradient = 0; 69 - ctx->current_brush.is_pattern = 0; 70 - ctx->current_brush.red = 0.0; 71 - ctx->current_brush.green = 0.0; 72 - ctx->current_brush.blue = 0.0; 73 - ctx->current_brush.alpha = 1.0; 74 - ctx->current_brush.pattern = NULL; 75 - 76 -/* priming a transparent background */ 77 - cairo_rectangle (ctx->cairo, 0, 0, width, height); 78 - cairo_set_source_rgba (ctx->cairo, 0.0, 0.0, 0.0, 0.0); 79 - cairo_fill (ctx->cairo); 80 - 81 -/* setting up default Font options */ 82 - ctx->font_red = 0.0; 83 - ctx->font_green = 0.0; 84 - ctx->font_blue = 0.0; 85 - ctx->font_alpha = 1.0; 86 - ctx->is_font_outlined = 0; 87 - ctx->font_outline_width = 0.0; 88 - 89 - *context = ctx; 90 - return GGRAPH_OK; 91 - error2: 92 - cairo_destroy (ctx->cairo); 93 - cairo_surface_destroy (ctx->surface); 94 - return GGRAPH_ERROR; 95 - error1: 96 - cairo_surface_destroy (ctx->surface); 97 - return GGRAPH_ERROR; 98 -} 99 - 100 -GGRAPH_DECLARE int 101 -gGraphDestroyContext (const void *context) 102 -{ 103 -/* freeing a Graphics Context */ 104 - gGraphContextPtr ctx = (gGraphContextPtr) context; 105 - if (!ctx) 106 - return GGRAPH_INVALID_PAINT_CONTEXT; 107 - if (ctx->signature != GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE) 108 - return GGRAPH_INVALID_PAINT_CONTEXT; 109 - cairo_destroy (ctx->cairo); 110 - cairo_surface_destroy (ctx->surface); 111 - free (ctx); 112 - return GGRAPH_OK; 113 -} 114 - 115 -GGRAPH_DECLARE int 116 -gGraphCreateSvgContext (const char *path, int width, int height, 117 - const void **context) 118 -{ 119 -/* creating an SVG Graphics Context */ 120 - gGraphContextPtr ctx; 121 - 122 - *context = NULL; 123 - 124 - ctx = malloc (sizeof (gGraphContext)); 125 - if (!ctx) 126 - return GGRAPH_INSUFFICIENT_MEMORY; 127 - ctx->signature = GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE; 128 - 129 - ctx->surface = 130 - cairo_svg_surface_create (path, (double) width, (double) height); 131 - 132 - if (cairo_surface_status (ctx->surface) == CAIRO_STATUS_SUCCESS) 133 - ; 134 - else 135 - goto error1; 136 - ctx->cairo = cairo_create (ctx->surface); 137 - if (cairo_status (ctx->cairo) == CAIRO_STATUS_NO_MEMORY) 138 - goto error2; 139 - 140 -/* setting up a default Black Pen */ 141 - ctx->current_pen.red = 0.0; 142 - ctx->current_pen.green = 0.0; 143 - ctx->current_pen.blue = 0.0; 144 - ctx->current_pen.alpha = 1.0; 145 - ctx->current_pen.width = 1.0; 146 - ctx->current_pen.lengths[0] = 1.0; 147 - ctx->current_pen.lengths_count = 1; 148 - 149 -/* setting up a default Black Brush */ 150 - ctx->current_brush.is_solid_color = 1; 151 - ctx->current_brush.is_linear_gradient = 0; 152 - ctx->current_brush.is_pattern = 0; 153 - ctx->current_brush.red = 0.0; 154 - ctx->current_brush.green = 0.0; 155 - ctx->current_brush.blue = 0.0; 156 - ctx->current_brush.alpha = 1.0; 157 - ctx->current_brush.pattern = NULL; 158 - 159 -/* priming a transparent background */ 160 - cairo_rectangle (ctx->cairo, 0, 0, width, height); 161 - cairo_set_source_rgba (ctx->cairo, 0.0, 0.0, 0.0, 0.0); 162 - cairo_fill (ctx->cairo); 163 - 164 -/* setting up default Font options */ 165 - ctx->font_red = 0.0; 166 - ctx->font_green = 0.0; 167 - ctx->font_blue = 0.0; 168 - ctx->font_alpha = 1.0; 169 - ctx->is_font_outlined = 0; 170 - ctx->font_outline_width = 0.0; 171 - 172 - *context = ctx; 173 - return GGRAPH_OK; 174 - error2: 175 - cairo_destroy (ctx->cairo); 176 - cairo_surface_destroy (ctx->surface); 177 - return GGRAPH_ERROR; 178 - error1: 179 - cairo_surface_destroy (ctx->surface); 180 - return GGRAPH_ERROR; 181 -} 182 - 183 -GGRAPH_DECLARE int 184 -gGraphDestroySvgContext (const void *context) 185 -{ 186 -/* freeing an SVG Graphics Context */ 187 - gGraphContextPtr ctx = (gGraphContextPtr) context; 188 - if (!ctx) 189 - return GGRAPH_INVALID_PAINT_CONTEXT; 190 - if (ctx->signature != GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE) 191 - return GGRAPH_INVALID_PAINT_CONTEXT; 192 - cairo_surface_show_page (ctx->surface); 193 - cairo_destroy (ctx->cairo); 194 - cairo_surface_finish (ctx->surface); 195 - cairo_surface_destroy (ctx->surface); 196 - free (ctx); 197 - return GGRAPH_OK; 198 -} 199 - 200 -GGRAPH_DECLARE int 201 -gGraphCreatePdfContext (const char *path, int page_width, int page_height, 202 - int width, int height, const void **context) 203 -{ 204 -/* creating an PDF Graphics Context */ 205 - int base_x = (page_width - width) / 2; 206 - int base_y = (page_height - height) / 2; 207 - gGraphContextPtr ctx; 208 - 209 - *context = NULL; 210 - 211 - ctx = malloc (sizeof (gGraphContext)); 212 - if (!ctx) 213 - return GGRAPH_INSUFFICIENT_MEMORY; 214 - ctx->signature = GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE; 215 - ctx->surface = 216 - cairo_pdf_surface_create (path, (double) page_width, 217 - (double) page_height); 218 - if (cairo_surface_status (ctx->surface) == CAIRO_STATUS_SUCCESS) 219 - ; 220 - else 221 - goto error1; 222 - ctx->cairo = cairo_create (ctx->surface); 223 - if (cairo_status (ctx->cairo) == CAIRO_STATUS_NO_MEMORY) 224 - goto error2; 225 - 226 -/* setting up a default Black Pen */ 227 - ctx->current_pen.red = 0.0; 228 - ctx->current_pen.green = 0.0; 229 - ctx->current_pen.blue = 0.0; 230 - ctx->current_pen.alpha = 1.0; 231 - ctx->current_pen.width = 1.0; 232 - ctx->current_pen.lengths[0] = 1.0; 233 - ctx->current_pen.lengths_count = 1; 234 - 235 -/* setting up a default Black Brush */ 236 - ctx->current_brush.is_solid_color = 1; 237 - ctx->current_brush.is_linear_gradient = 0; 238 - ctx->current_brush.is_pattern = 0; 239 - ctx->current_brush.red = 0.0; 240 - ctx->current_brush.green = 0.0; 241 - ctx->current_brush.blue = 0.0; 242 - ctx->current_brush.alpha = 1.0; 243 - ctx->current_brush.pattern = NULL; 244 - 245 -/* priming a transparent background */ 246 - cairo_rectangle (ctx->cairo, 0, 0, width, height); 247 - cairo_set_source_rgba (ctx->cairo, 0.0, 0.0, 0.0, 0.0); 248 - cairo_fill (ctx->cairo); 249 - 250 -/* setting up default Font options */ 251 - ctx->font_red = 0.0; 252 - ctx->font_green = 0.0; 253 - ctx->font_blue = 0.0; 254 - ctx->font_alpha = 1.0; 255 - ctx->is_font_outlined = 0; 256 - ctx->font_outline_width = 0.0; 257 - 258 - cairo_translate (ctx->cairo, base_x, base_y); 259 - *context = ctx; 260 - return GGRAPH_OK; 261 - error2: 262 - cairo_destroy (ctx->cairo); 263 - cairo_surface_destroy (ctx->surface); 264 - return GGRAPH_ERROR; 265 - error1: 266 - cairo_surface_destroy (ctx->surface); 267 - return GGRAPH_ERROR; 268 -} 269 - 270 -GGRAPH_DECLARE int 271 -gGraphDestroyPdfContext (const void *context) 272 -{ 273 -/* freeing an PDF Graphics Context */ 274 - gGraphContextPtr ctx = (gGraphContextPtr) context; 275 - if (!ctx) 276 - return GGRAPH_INVALID_PAINT_CONTEXT; 277 - if (ctx->signature != GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 278 - return GGRAPH_INVALID_PAINT_CONTEXT; 279 - cairo_surface_show_page (ctx->surface); 280 - cairo_destroy (ctx->cairo); 281 - cairo_surface_finish (ctx->surface); 282 - cairo_surface_destroy (ctx->surface); 283 - free (ctx); 284 - return GGRAPH_OK; 285 -} 286 - 287 -GGRAPH_DECLARE int 288 -gGraphSetPen (const void *context, unsigned char red, unsigned char green, 289 - unsigned char blue, unsigned char alpha, double width, int style) 290 -{ 291 -/* creating a Color Pen */ 292 - double d_red = (double) red / 255.0; 293 - double d_green = (double) green / 255.0; 294 - double d_blue = (double) blue / 255.0; 295 - double d_alpha = (double) alpha / 255.0; 296 - gGraphContextPtr ctx = (gGraphContextPtr) context; 297 - if (!ctx) 298 - return GGRAPH_INVALID_PAINT_CONTEXT; 299 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 300 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 301 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 302 - ; 303 - else 304 - return GGRAPH_INVALID_PAINT_CONTEXT; 305 - 306 - ctx->current_pen.width = width; 307 - ctx->current_pen.red = d_red; 308 - ctx->current_pen.green = d_green; 309 - ctx->current_pen.blue = d_blue; 310 - ctx->current_pen.alpha = d_alpha; 311 - switch (style) 312 - { 313 - case GGRAPH_PENSTYLE_DOT: 314 - ctx->current_pen.lengths[0] = 2; 315 - ctx->current_pen.lengths[1] = 2; 316 - ctx->current_pen.lengths_count = 2; 317 - break; 318 - case GGRAPH_PENSTYLE_LONG_DASH: 319 - ctx->current_pen.lengths[0] = 16; 320 - ctx->current_pen.lengths[1] = 8; 321 - ctx->current_pen.lengths_count = 2; 322 - break; 323 - case GGRAPH_PENSTYLE_SHORT_DASH: 324 - ctx->current_pen.lengths[0] = 8; 325 - ctx->current_pen.lengths[1] = 4; 326 - ctx->current_pen.lengths_count = 2; 327 - break; 328 - case GGRAPH_PENSTYLE_DOT_DASH: 329 - ctx->current_pen.lengths[0] = 8; 330 - ctx->current_pen.lengths[1] = 4; 331 - ctx->current_pen.lengths[2] = 2; 332 - ctx->current_pen.lengths[3] = 4; 333 - ctx->current_pen.lengths_count = 4; 334 - break; 335 - default: 336 - ctx->current_pen.lengths[0] = 1; 337 - ctx->current_pen.lengths[1] = 0; 338 - ctx->current_pen.lengths_count = 2; 339 - }; 340 - return GGRAPH_OK; 341 -} 342 - 343 -GGRAPH_DECLARE int 344 -gGraphSetBrush (const void *context, unsigned char red, unsigned char green, 345 - unsigned char blue, unsigned char alpha) 346 -{ 347 -/* setting up a Color Brush */ 348 - double d_red = (double) red / 255.0; 349 - double d_green = (double) green / 255.0; 350 - double d_blue = (double) blue / 255.0; 351 - double d_alpha = (double) alpha / 255.0; 352 - gGraphContextPtr ctx = (gGraphContextPtr) context; 353 - if (!ctx) 354 - return GGRAPH_INVALID_PAINT_CONTEXT; 355 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 356 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 357 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 358 - ; 359 - else 360 - return GGRAPH_INVALID_PAINT_CONTEXT; 361 - 362 - ctx->current_brush.is_solid_color = 1; 363 - ctx->current_brush.is_linear_gradient = 0; 364 - ctx->current_brush.is_pattern = 0; 365 - ctx->current_brush.red = d_red; 366 - ctx->current_brush.green = d_green; 367 - ctx->current_brush.blue = d_blue; 368 - ctx->current_brush.alpha = d_alpha; 369 - return GGRAPH_OK; 370 -} 371 - 372 -GGRAPH_DECLARE int 373 -gGraphSetLinearGradientBrush (const void *context, double x, double y, 374 - double width, double height, unsigned char red1, 375 - unsigned char green1, unsigned char blue1, 376 - unsigned char alpha1, unsigned char red2, 377 - unsigned char green2, unsigned char blue2, 378 - unsigned char alpha2) 379 -{ 380 -/* setting up a Linear Gradient Brush */ 381 - double d_red = (double) red1 / 255.0; 382 - double d_green = (double) green1 / 255.0; 383 - double d_blue = (double) blue1 / 255.0; 384 - double d_alpha = (double) alpha1 / 255.0; 385 - gGraphContextPtr ctx = (gGraphContextPtr) context; 386 - if (!ctx) 387 - return GGRAPH_INVALID_PAINT_CONTEXT; 388 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 389 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 390 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 391 - ; 392 - else 393 - return GGRAPH_INVALID_PAINT_CONTEXT; 394 - 395 - ctx->current_brush.is_solid_color = 0; 396 - ctx->current_brush.is_linear_gradient = 1; 397 - ctx->current_brush.is_pattern = 0; 398 - ctx->current_brush.red = d_red; 399 - ctx->current_brush.green = d_green; 400 - ctx->current_brush.blue = d_blue; 401 - ctx->current_brush.alpha = d_alpha; 402 - ctx->current_brush.x0 = x; 403 - ctx->current_brush.y0 = y; 404 - ctx->current_brush.x1 = x + width; 405 - ctx->current_brush.y1 = y + height; 406 - d_red = (double) red2 / 255.0; 407 - d_green = (double) green2 / 255.0; 408 - d_blue = (double) blue2 / 255.0; 409 - d_alpha = (double) alpha2 / 255.0; 410 - ctx->current_brush.red2 = d_red; 411 - ctx->current_brush.green2 = d_green; 412 - ctx->current_brush.blue2 = d_blue; 413 - ctx->current_brush.alpha2 = d_alpha; 414 - return GGRAPH_OK; 415 -} 416 - 417 -GGRAPH_DECLARE int 418 -gGraphSetPatternBrush (const void *context, const void *brush) 419 -{ 420 -/* setting up a Pattern Brush */ 421 - gGraphPatternBrushPtr pattern = (gGraphPatternBrushPtr) brush; 422 - gGraphContextPtr ctx = (gGraphContextPtr) context; 423 - 424 - if (!ctx) 425 - return GGRAPH_INVALID_PAINT_CONTEXT; 426 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 427 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 428 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 429 - ; 430 - else 431 - return GGRAPH_INVALID_PAINT_CONTEXT; 432 - 433 - if (!pattern) 434 - return GGRAPH_INVALID_PAINT_BRUSH; 435 - if (pattern->signature != GG_GRAPHICS_BRUSH_MAGIC_SIGNATURE) 436 - return GGRAPH_INVALID_PAINT_BRUSH; 437 - 438 - ctx->current_brush.is_solid_color = 0; 439 - ctx->current_brush.is_linear_gradient = 0; 440 - ctx->current_brush.is_pattern = 1; 441 - 442 - ctx->current_brush.pattern = pattern->pattern; 443 - return GGRAPH_OK; 444 -} 445 - 446 -static void 447 -set_current_brush (gGraphContextPtr ctx) 448 -{ 449 -/* setting up the current Brush */ 450 - if (ctx->current_brush.is_solid_color) 451 - { 452 - /* using a Solid Color Brush */ 453 - cairo_set_source_rgba (ctx->cairo, ctx->current_brush.red, 454 - ctx->current_brush.green, 455 - ctx->current_brush.blue, 456 - ctx->current_brush.alpha); 457 - } 458 - else if (ctx->current_brush.is_linear_gradient) 459 - { 460 - /* using a Linear Gradient Brush */ 461 - cairo_pattern_t *pattern = 462 - cairo_pattern_create_linear (ctx->current_brush.x0, 463 - ctx->current_brush.y0, 464 - ctx->current_brush.x1, 465 - ctx->current_brush.y1); 466 - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 467 - ctx->current_brush.red, 468 - ctx->current_brush.green, 469 - ctx->current_brush.blue, 470 - ctx->current_brush.alpha); 471 - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 472 - ctx->current_brush.red2, 473 - ctx->current_brush.green2, 474 - ctx->current_brush.blue2, 475 - ctx->current_brush.alpha2); 476 - cairo_set_source (ctx->cairo, pattern); 477 - cairo_pattern_destroy (pattern); 478 - } 479 - else if (ctx->current_brush.is_pattern) 480 - { 481 - /* using a Pattern Brush */ 482 - cairo_set_source (ctx->cairo, ctx->current_brush.pattern); 483 - } 484 -} 485 - 486 -GGRAPH_DECLARE int 487 -gGraphFillPath (const void *context, int preserve) 488 -{ 489 -/* Filling a path */ 490 - gGraphContextPtr ctx = (gGraphContextPtr) context; 491 - if (!ctx) 492 - return GGRAPH_INVALID_PAINT_CONTEXT; 493 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 494 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 495 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 496 - ; 497 - else 498 - return GGRAPH_INVALID_PAINT_CONTEXT; 499 - 500 - set_current_brush (ctx); 501 - if (preserve == GGRAPH_PRESERVE_PATH) 502 - cairo_fill_preserve (ctx->cairo); 503 - else 504 - cairo_fill (ctx->cairo); 505 - return GGRAPH_OK; 506 -} 507 - 508 -static void 509 -set_current_pen (gGraphContextPtr ctx) 510 -{ 511 -/* setting up the current Pen */ 512 - cairo_set_line_width (ctx->cairo, ctx->current_pen.width); 513 - cairo_set_source_rgba (ctx->cairo, ctx->current_pen.red, 514 - ctx->current_pen.green, ctx->current_pen.blue, 515 - ctx->current_pen.alpha); 516 - cairo_set_line_cap (ctx->cairo, CAIRO_LINE_CAP_BUTT); 517 - cairo_set_line_join (ctx->cairo, CAIRO_LINE_JOIN_MITER); 518 - cairo_set_dash (ctx->cairo, ctx->current_pen.lengths, 519 - ctx->current_pen.lengths_count, 0.0); 520 -} 521 - 522 -GGRAPH_DECLARE int 523 -gGraphStrokePath (const void *context, int preserve) 524 -{ 525 -/* Stroking a path */ 526 - gGraphContextPtr ctx = (gGraphContextPtr) context; 527 - if (!ctx) 528 - return GGRAPH_INVALID_PAINT_CONTEXT; 529 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 530 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 531 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 532 - ; 533 - else 534 - return GGRAPH_INVALID_PAINT_CONTEXT; 535 - 536 - set_current_pen (ctx); 537 - if (preserve == GGRAPH_PRESERVE_PATH) 538 - cairo_stroke_preserve (ctx->cairo); 539 - else 540 - cairo_stroke (ctx->cairo); 541 - return GGRAPH_OK; 542 -} 543 - 544 -GGRAPH_DECLARE int 545 -gGraphMoveToPoint (const void *context, double x, double y) 546 -{ 547 -/* Moving to a Path Point */ 548 - gGraphContextPtr ctx = (gGraphContextPtr) context; 549 - if (!ctx) 550 - return GGRAPH_INVALID_PAINT_CONTEXT; 551 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 552 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 553 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 554 - ; 555 - else 556 - return GGRAPH_INVALID_PAINT_CONTEXT; 557 - cairo_move_to (ctx->cairo, x, y); 558 - return GGRAPH_OK; 559 -} 560 - 561 -GGRAPH_DECLARE int 562 -gGraphAddLineToPath (const void *context, double x, double y) 563 -{ 564 -/* Adding a Lint to a Path */ 565 - gGraphContextPtr ctx = (gGraphContextPtr) context; 566 - if (!ctx) 567 - return GGRAPH_INVALID_PAINT_CONTEXT; 568 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 569 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 570 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 571 - ; 572 - else 573 - return GGRAPH_INVALID_PAINT_CONTEXT; 574 - cairo_line_to (ctx->cairo, x, y); 575 - return GGRAPH_OK; 576 -} 577 - 578 -GGRAPH_DECLARE int 579 -gGraphCloseSubpath (const void *context) 580 -{ 581 -/* Closing a SubPath */ 582 - gGraphContextPtr ctx = (gGraphContextPtr) context; 583 - if (!ctx) 584 - return GGRAPH_INVALID_PAINT_CONTEXT; 585 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 586 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 587 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 588 - ; 589 - else 590 - return GGRAPH_INVALID_PAINT_CONTEXT; 591 - cairo_close_path (ctx->cairo); 592 - return GGRAPH_OK; 593 -} 594 - 595 -GGRAPH_DECLARE int 596 -gGraphStrokeLine (const void *context, double x0, double y0, double x1, 597 - double y1) 598 -{ 599 -/* Stroking a line */ 600 - gGraphContextPtr ctx = (gGraphContextPtr) context; 601 - if (!ctx) 602 - return GGRAPH_INVALID_PAINT_CONTEXT; 603 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 604 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 605 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 606 - ; 607 - else 608 - return GGRAPH_INVALID_PAINT_CONTEXT; 609 - cairo_move_to (ctx->cairo, x0, y0); 610 - cairo_line_to (ctx->cairo, x1, y1); 611 - set_current_pen (ctx); 612 - cairo_stroke (ctx->cairo); 613 - return GGRAPH_OK; 614 -} 615 - 616 -GGRAPH_DECLARE int 617 -gGraphDrawEllipse (const void *context, double x, double y, double width, 618 - double height) 619 -{ 620 -/* Drawing a filled ellipse */ 621 - gGraphContextPtr ctx = (gGraphContextPtr) context; 622 - if (!ctx) 623 - return GGRAPH_INVALID_PAINT_CONTEXT; 624 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 625 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 626 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 627 - ; 628 - else 629 - return GGRAPH_INVALID_PAINT_CONTEXT; 630 - cairo_save (ctx->cairo); 631 - cairo_translate (ctx->cairo, x + (width / 2.0), y + (height / 2.0)); 632 - cairo_scale (ctx->cairo, width / 2.0, height / 2.0); 633 - cairo_arc (ctx->cairo, 0.0, 0.0, 1.0, 0.0, 2.0 * M_PI); 634 - cairo_restore (ctx->cairo); 635 - set_current_brush (ctx); 636 - cairo_fill_preserve (ctx->cairo); 637 - set_current_pen (ctx); 638 - cairo_stroke (ctx->cairo); 639 - return GGRAPH_OK; 640 -} 641 - 642 -GGRAPH_DECLARE int 643 -gGraphDrawCircleSector (const void *context, double center_x, 644 - double center_y, double radius, double from_angle, 645 - double to_angle) 646 -{ 647 -/* drawing a filled circular sector */ 648 - gGraphContextPtr ctx = (gGraphContextPtr) context; 649 - if (!ctx) 650 - return GGRAPH_INVALID_PAINT_CONTEXT; 651 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 652 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 653 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 654 - ; 655 - else 656 - return GGRAPH_INVALID_PAINT_CONTEXT; 657 - cairo_move_to (ctx->cairo, center_x, center_y); 658 - cairo_arc (ctx->cairo, center_x, center_y, radius, from_angle, to_angle); 659 - cairo_line_to (ctx->cairo, center_x, center_y); 660 - set_current_brush (ctx); 661 - cairo_fill_preserve (ctx->cairo); 662 - set_current_pen (ctx); 663 - cairo_stroke (ctx->cairo); 664 - return GGRAPH_OK; 665 -} 666 - 667 -GGRAPH_DECLARE int 668 -gGraphDrawRectangle (const void *context, double x, double y, double width, 669 - double height) 670 -{ 671 -/* Drawing a filled rectangle */ 672 - gGraphContextPtr ctx = (gGraphContextPtr) context; 673 - if (!ctx) 674 - return GGRAPH_INVALID_PAINT_CONTEXT; 675 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 676 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 677 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 678 - ; 679 - else 680 - return GGRAPH_INVALID_PAINT_CONTEXT; 681 - cairo_rectangle (ctx->cairo, x, y, width, height); 682 - set_current_brush (ctx); 683 - cairo_fill_preserve (ctx->cairo); 684 - set_current_pen (ctx); 685 - cairo_stroke (ctx->cairo); 686 - return GGRAPH_OK; 687 -} 688 - 689 -GGRAPH_DECLARE int 690 -gGraphDrawRoundedRectangle (const void *context, double x, double y, 691 - double width, double height, double radius) 692 -{ 693 -/* Drawing a filled rectangle with rounded corners */ 694 - double degrees = M_PI / 180.0; 695 - gGraphContextPtr ctx = (gGraphContextPtr) context; 696 - if (!ctx) 697 - return GGRAPH_INVALID_PAINT_CONTEXT; 698 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 699 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 700 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 701 - ; 702 - else 703 - return GGRAPH_INVALID_PAINT_CONTEXT; 704 - cairo_new_sub_path (ctx->cairo); 705 - cairo_arc (ctx->cairo, x + width - radius, y + radius, radius, 706 - -90 * degrees, 0 * degrees); 707 - cairo_arc (ctx->cairo, x + width - radius, y + height - radius, radius, 708 - 0 * degrees, 90 * degrees); 709 - cairo_arc (ctx->cairo, x + radius, y + height - radius, radius, 710 - 90 * degrees, 180 * degrees); 711 - cairo_arc (ctx->cairo, x + radius, y + radius, radius, 180 * degrees, 712 - 270 * degrees); 713 - cairo_close_path (ctx->cairo); 714 - set_current_brush (ctx); 715 - cairo_fill_preserve (ctx->cairo); 716 - set_current_pen (ctx); 717 - cairo_stroke (ctx->cairo); 718 - return GGRAPH_OK; 719 -} 720 - 721 -GGRAPH_DECLARE int 722 -gGraphGetContextRgbArray (const void *context, unsigned char **rgbArray) 723 -{ 724 -/* creating an RGB buffer from the given Context */ 725 - int width; 726 - int height; 727 - int x; 728 - int y; 729 - unsigned char *p_in; 730 - unsigned char *p_out; 731 - unsigned char *rgb; 732 - int little_endian = gg_endian_arch (); 733 - gGraphContextPtr ctx = (gGraphContextPtr) context; 734 - 735 - *rgbArray = NULL; 736 - if (!ctx) 737 - return GGRAPH_INVALID_PAINT_CONTEXT; 738 - if (ctx->signature != GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE) 739 - return GGRAPH_INVALID_PAINT_CONTEXT; 740 - 741 - width = cairo_image_surface_get_width (ctx->surface); 742 - height = cairo_image_surface_get_height (ctx->surface); 743 - rgb = malloc (width * height * 3); 744 - if (!rgb) 745 - return GGRAPH_INSUFFICIENT_MEMORY; 746 - 747 - p_in = cairo_image_surface_get_data (ctx->surface); 748 - p_out = rgb; 749 - for (y = 0; y < height; y++) 750 - { 751 - for (x = 0; x < width; x++) 752 - { 753 - unsigned char r; 754 - unsigned char g; 755 - unsigned char b; 756 - if (little_endian) 757 - { 758 - b = *p_in++; 759 - g = *p_in++; 760 - r = *p_in++; 761 - p_in++; /* skipping Alpha */ 762 - } 763 - else 764 - { 765 - p_in++; /* skipping Alpha */ 766 - r = *p_in++; 767 - g = *p_in++; 768 - b = *p_in++; 769 - } 770 - *p_out++ = r; 771 - *p_out++ = g; 772 - *p_out++ = b; 773 - } 774 - } 775 - *rgbArray = rgb; 776 - return GGRAPH_OK; 777 -} 778 - 779 -GGRAPH_DECLARE int 780 -gGraphGetContextAlphaArray (const void *context, unsigned char **alphaArray) 781 -{ 782 -/* creating an Alpha buffer from the given Context */ 783 - int width; 784 - int height; 785 - int x; 786 - int y; 787 - unsigned char *p_in; 788 - unsigned char *p_out; 789 - unsigned char *alpha; 790 - gGraphContextPtr ctx = (gGraphContextPtr) context; 791 - 792 - *alphaArray = NULL; 793 - if (!ctx) 794 - return GGRAPH_INVALID_PAINT_CONTEXT; 795 - if (ctx->signature != GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE) 796 - return GGRAPH_INVALID_PAINT_CONTEXT; 797 - 798 - width = cairo_image_surface_get_width (ctx->surface); 799 - height = cairo_image_surface_get_height (ctx->surface); 800 - alpha = malloc (width * height); 801 - if (!alpha) 802 - return GGRAPH_INSUFFICIENT_MEMORY; 803 - 804 - p_in = cairo_image_surface_get_data (ctx->surface); 805 - p_out = alpha; 806 - for (y = 0; y < height; y++) 807 - { 808 - for (x = 0; x < width; x++) 809 - { 810 - p_in += 3; /* skipping RGB */ 811 - *p_out++ = *p_in++; 812 - } 813 - } 814 - *alphaArray = alpha; 815 - return GGRAPH_OK; 816 -} 817 - 818 -GGRAPH_DECLARE int 819 -gGraphDrawBitmap (const void *context, const void *bitmap, int x, int y) 820 -{ 821 -/* drawing a symbol bitmap */ 822 - gGraphBitmapPtr bmp = (gGraphBitmapPtr) bitmap; 823 - gGraphContextPtr ctx = (gGraphContextPtr) context; 824 - 825 - if (!ctx) 826 - return GGRAPH_INVALID_PAINT_CONTEXT; 827 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 828 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 829 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 830 - ; 831 - else 832 - return GGRAPH_INVALID_PAINT_CONTEXT; 833 - 834 - if (!bmp) 835 - return GGRAPH_INVALID_PAINT_BITMAP; 836 - if (bmp->signature != GG_GRAPHICS_BITMAP_MAGIC_SIGNATURE) 837 - return GGRAPH_INVALID_PAINT_BITMAP; 838 - 839 - cairo_save (ctx->cairo); 840 - cairo_scale (ctx->cairo, 1, 1); 841 - cairo_translate (ctx->cairo, x, y); 842 - cairo_set_source (ctx->cairo, bmp->pattern); 843 - cairo_rectangle (ctx->cairo, 0, 0, bmp->width, bmp->height); 844 - cairo_fill (ctx->cairo); 845 - cairo_restore (ctx->cairo); 846 - return GGRAPH_OK; 847 -} 848 - 849 -static void 850 -adjust_for_endianness (unsigned char *rgbaArray, int width, int height) 851 -{ 852 -/* Adjusting from RGBA to ARGB respecting platform endianness */ 853 - int x; 854 - int y; 855 - unsigned char red; 856 - unsigned char green; 857 - unsigned char blue; 858 - unsigned char alpha; 859 - unsigned char *p_in = rgbaArray; 860 - unsigned char *p_out = rgbaArray; 861 - int little_endian = gg_endian_arch (); 862 - 863 - for (y = 0; y < height; y++) 864 - { 865 - for (x = 0; x < width; x++) 866 - { 867 - red = *p_in++; 868 - green = *p_in++; 869 - blue = *p_in++; 870 - alpha = *p_in++; 871 - if (alpha == 0) 872 - { 873 - *p_out++ = 0; 874 - *p_out++ = 0; 875 - *p_out++ = 0; 876 - *p_out++ = 0; 877 - } 878 - else 879 - { 880 - if (little_endian) 881 - { 882 - *p_out++ = blue; 883 - *p_out++ = green; 884 - *p_out++ = red; 885 - *p_out++ = alpha; 886 - } 887 - else 888 - { 889 - *p_out++ = alpha; 890 - *p_out++ = red; 891 - *p_out++ = green; 892 - *p_out++ = blue; 893 - } 894 - } 895 - } 896 - } 897 -} 898 - 899 -GGRAPH_DECLARE int 900 -gGraphCreateBitmap (unsigned char *rgbaArray, int width, int height, 901 - const void **bitmap) 902 -{ 903 -/* creating a symbol bitmap */ 904 - gGraphBitmapPtr bmp; 905 - 906 - *bitmap = NULL; 907 - if (!rgbaArray) 908 - return GGRAPH_ERROR; 909 - 910 - adjust_for_endianness (rgbaArray, width, height); 911 - bmp = malloc (sizeof (gGraphBitmap)); 912 - if (!bmp) 913 - return GGRAPH_INSUFFICIENT_MEMORY; 914 - bmp->signature = GG_GRAPHICS_BITMAP_MAGIC_SIGNATURE; 915 - bmp->width = width; 916 - bmp->height = height; 917 - bmp->bitmap = 918 - cairo_image_surface_create_for_data (rgbaArray, CAIRO_FORMAT_ARGB32, 919 - width, height, width * 4); 920 - bmp->pattern = cairo_pattern_create_for_surface (bmp->bitmap); 921 - *bitmap = bmp; 922 - return GGRAPH_OK; 923 -} 924 - 925 -GGRAPH_DECLARE int 926 -gGraphDestroyBitmap (const void *bitmap) 927 -{ 928 -/* destroying a symbol bitmap */ 929 - gGraphBitmapPtr bmp = (gGraphBitmapPtr) bitmap; 930 - 931 - if (!bmp) 932 - return GGRAPH_INVALID_PAINT_BITMAP; 933 - if (bmp->signature != GG_GRAPHICS_BITMAP_MAGIC_SIGNATURE) 934 - return GGRAPH_INVALID_PAINT_BITMAP; 935 - 936 - cairo_pattern_destroy (bmp->pattern); 937 - cairo_surface_destroy (bmp->bitmap); 938 - free (bmp); 939 - return GGRAPH_OK; 940 -} 941 - 942 -GGRAPH_DECLARE int 943 -gGraphCreateBrush (unsigned char *rgbaArray, int width, int height, 944 - const void **brush) 945 -{ 946 -/* creating a pattern brush */ 947 - gGraphPatternBrushPtr pattern; 948 - 949 - *brush = NULL; 950 - if (!rgbaArray) 951 - return GGRAPH_ERROR; 952 - 953 - adjust_for_endianness (rgbaArray, width, height); 954 - pattern = malloc (sizeof (gGraphPatternBrush)); 955 - if (!pattern) 956 - return GGRAPH_INSUFFICIENT_MEMORY; 957 - pattern->signature = GG_GRAPHICS_BRUSH_MAGIC_SIGNATURE; 958 - pattern->width = width; 959 - pattern->height = height; 960 - pattern->bitmap = 961 - cairo_image_surface_create_for_data (rgbaArray, CAIRO_FORMAT_ARGB32, 962 - width, height, width * 4); 963 - pattern->pattern = cairo_pattern_create_for_surface (pattern->bitmap); 964 - cairo_pattern_set_extend (pattern->pattern, CAIRO_EXTEND_REPEAT); 965 - *brush = pattern; 966 - return GGRAPH_OK; 967 -} 968 - 969 -GGRAPH_DECLARE int 970 -gGraphDestroyBrush (const void *brush) 971 -{ 972 -/* destroying a pattern brush */ 973 - gGraphPatternBrushPtr pattern = (gGraphPatternBrushPtr) brush; 974 - 975 - if (!pattern) 976 - return GGRAPH_INVALID_PAINT_BRUSH; 977 - if (pattern->signature != GG_GRAPHICS_BRUSH_MAGIC_SIGNATURE) 978 - return GGRAPH_INVALID_PAINT_BRUSH; 979 - 980 - cairo_pattern_destroy (pattern->pattern); 981 - cairo_surface_destroy (pattern->bitmap); 982 - free (pattern); 983 - return GGRAPH_OK; 984 -} 985 - 986 -GGRAPH_DECLARE int 987 -gGraphCreateFont (double size, int style, int weight, const void **font) 988 -{ 989 -/* creating a font */ 990 - gGraphFontPtr fnt; 991 - 992 - *font = NULL; 993 - fnt = malloc (sizeof (gGraphFont)); 994 - if (!fnt) 995 - return GGRAPH_INSUFFICIENT_MEMORY; 996 - fnt->signature = GG_GRAPHICS_FONT_MAGIC_SIGNATURE; 997 - if (size < 1.0) 998 - fnt->size = 1.0; 999 - else if (size > 32.0) 1000 - fnt->size = 32.0; 1001 - else 1002 - fnt->size = size; 1003 - if (style == GGRAPH_FONTSTYLE_ITALIC) 1004 - fnt->style = GGRAPH_FONTSTYLE_ITALIC; 1005 - else 1006 - fnt->style = GGRAPH_FONTSTYLE_NORMAL; 1007 - if (weight == GGRAPH_FONTWEIGHT_BOLD) 1008 - fnt->weight = GGRAPH_FONTWEIGHT_BOLD; 1009 - else 1010 - fnt->weight = GGRAPH_FONTWEIGHT_NORMAL; 1011 - fnt->is_outlined = 0; 1012 - fnt->outline_width = 0.0; 1013 - fnt->red = 0.0; 1014 - fnt->green = 0.0; 1015 - fnt->blue = 0.0; 1016 - fnt->alpha = 1.0; 1017 - *font = fnt; 1018 - return GGRAPH_OK; 1019 -} 1020 - 1021 -GGRAPH_DECLARE int 1022 -gGraphDestroyFont (const void *font) 1023 -{ 1024 -/* destroying a font */ 1025 - gGraphFontPtr fnt = (gGraphFontPtr) font; 1026 - 1027 - if (!fnt) 1028 - return GGRAPH_INVALID_PAINT_FONT; 1029 - if (fnt->signature != GG_GRAPHICS_FONT_MAGIC_SIGNATURE) 1030 - return GGRAPH_INVALID_PAINT_FONT; 1031 - 1032 - free (fnt); 1033 - return GGRAPH_OK; 1034 -} 1035 - 1036 -GGRAPH_DECLARE int 1037 -gGraphFontSetColor (const void *font, unsigned char red, unsigned char green, 1038 - unsigned char blue, unsigned char alpha) 1039 -{ 1040 -/* setting up the font color */ 1041 - gGraphFontPtr fnt = (gGraphFontPtr) font; 1042 - 1043 - if (!fnt) 1044 - return GGRAPH_INVALID_PAINT_FONT; 1045 - if (fnt->signature != GG_GRAPHICS_FONT_MAGIC_SIGNATURE) 1046 - return GGRAPH_INVALID_PAINT_FONT; 1047 - 1048 - fnt->red = (double) red / 255.0; 1049 - fnt->green = (double) green / 255.0; 1050 - fnt->blue = (double) blue / 255.0; 1051 - fnt->alpha = (double) alpha / 255.0; 1052 - return GGRAPH_OK; 1053 -} 1054 - 1055 -GGRAPH_DECLARE int 1056 -gGraphFontSetOutline (const void *font, double width) 1057 -{ 1058 -/* setting up the font outline */ 1059 - gGraphFontPtr fnt = (gGraphFontPtr) font; 1060 - 1061 - if (!fnt) 1062 - return GGRAPH_INVALID_PAINT_FONT; 1063 - if (fnt->signature != GG_GRAPHICS_FONT_MAGIC_SIGNATURE) 1064 - return GGRAPH_INVALID_PAINT_FONT; 1065 - 1066 - if (width <= 0.0) 1067 - { 1068 - fnt->is_outlined = 0; 1069 - fnt->outline_width = 0.0; 1070 - } 1071 - else 1072 - { 1073 - fnt->is_outlined = 1; 1074 - fnt->outline_width = width; 1075 - } 1076 - return GGRAPH_OK; 1077 -} 1078 - 1079 -GGRAPH_DECLARE int 1080 -gGraphSetFont (const void *context, const void *font) 1081 -{ 1082 -/* setting up the current font */ 1083 - int style = CAIRO_FONT_SLANT_NORMAL; 1084 - int weight = CAIRO_FONT_WEIGHT_NORMAL; 1085 - double size; 1086 - gGraphFontPtr fnt = (gGraphFontPtr) font; 1087 - gGraphContextPtr ctx = (gGraphContextPtr) context; 1088 - 1089 - if (!ctx) 1090 - return GGRAPH_INVALID_PAINT_CONTEXT; 1091 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 1092 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 1093 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 1094 - ; 1095 - else 1096 - return GGRAPH_INVALID_PAINT_CONTEXT; 1097 - 1098 - if (!fnt) 1099 - return GGRAPH_INVALID_PAINT_FONT; 1100 - if (fnt->signature != GG_GRAPHICS_FONT_MAGIC_SIGNATURE) 1101 - return GGRAPH_INVALID_PAINT_FONT; 1102 - 1103 - if (fnt->style == GGRAPH_FONTSTYLE_ITALIC) 1104 - style = CAIRO_FONT_SLANT_ITALIC; 1105 - if (fnt->weight == GGRAPH_FONTWEIGHT_BOLD) 1106 - weight = CAIRO_FONT_WEIGHT_BOLD; 1107 - cairo_select_font_face (ctx->cairo, "monospace", style, weight); 1108 - size = fnt->size; 1109 - if (fnt->is_outlined) 1110 - size += fnt->outline_width; 1111 - cairo_set_font_size (ctx->cairo, size); 1112 - ctx->font_red = fnt->red; 1113 - ctx->font_green = fnt->green; 1114 - ctx->font_blue = fnt->blue; 1115 - ctx->font_alpha = fnt->alpha; 1116 - ctx->is_font_outlined = fnt->is_outlined; 1117 - ctx->font_outline_width = fnt->outline_width; 1118 - 1119 - return GGRAPH_OK; 1120 -} 1121 - 1122 -GGRAPH_DECLARE int 1123 -gGraphGetTextExtent (const void *context, const char *text, double *pre_x, 1124 - double *pre_y, double *width, double *height, 1125 - double *post_x, double *post_y) 1126 -{ 1127 -/* measuring the text extent (using the current font) */ 1128 - cairo_text_extents_t extents; 1129 - gGraphContextPtr ctx = (gGraphContextPtr) context; 1130 - 1131 - if (!ctx) 1132 - return GGRAPH_INVALID_PAINT_CONTEXT; 1133 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 1134 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 1135 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 1136 - ; 1137 - else 1138 - return GGRAPH_INVALID_PAINT_CONTEXT; 1139 - 1140 - cairo_text_extents (ctx->cairo, text, &extents); 1141 - *pre_x = extents.x_bearing; 1142 - *pre_y = extents.y_bearing; 1143 - *width = extents.width; 1144 - *height = extents.height; 1145 - *post_x = extents.x_advance; 1146 - *post_y = extents.y_advance; 1147 - return GGRAPH_OK; 1148 -} 1149 - 1150 -GGRAPH_DECLARE int 1151 -gGraphDrawText (const void *context, const char *text, double x, double y, 1152 - double angle) 1153 -{ 1154 -/* drawing a text string (using the current font) */ 1155 - gGraphContextPtr ctx = (gGraphContextPtr) context; 1156 - 1157 - if (!ctx) 1158 - return GGRAPH_INVALID_PAINT_CONTEXT; 1159 - if (ctx->signature == GG_GRAPHICS_CONTEXT_MAGIC_SIGNATURE || 1160 - ctx->signature == GG_GRAPHICS_SVG_CONTEXT_MAGIC_SIGNATURE || 1161 - ctx->signature == GG_GRAPHICS_PDF_CONTEXT_MAGIC_SIGNATURE) 1162 - ; 1163 - else 1164 - return GGRAPH_INVALID_PAINT_CONTEXT; 1165 - 1166 - cairo_save (ctx->cairo); 1167 - cairo_translate (ctx->cairo, x, y); 1168 - cairo_rotate (ctx->cairo, angle); 1169 - if (ctx->is_font_outlined) 1170 - { 1171 - /* outlined font */ 1172 - cairo_move_to (ctx->cairo, 0.0, 0.0); 1173 - cairo_text_path (ctx->cairo, text); 1174 - cairo_set_source_rgba (ctx->cairo, ctx->font_red, ctx->font_green, 1175 - ctx->font_blue, ctx->font_alpha); 1176 - cairo_fill_preserve (ctx->cairo); 1177 - cairo_set_source_rgba (ctx->cairo, 1.0, 1.0, 1.0, ctx->font_alpha); 1178 - cairo_set_line_width (ctx->cairo, ctx->font_outline_width); 1179 - cairo_stroke (ctx->cairo); 1180 - } 1181 - else 1182 - { 1183 - /* no outline */ 1184 - cairo_set_source_rgba (ctx->cairo, ctx->font_red, ctx->font_green, 1185 - ctx->font_blue, ctx->font_alpha); 1186 - cairo_move_to (ctx->cairo, 0.0, 0.0); 1187 - cairo_show_text (ctx->cairo, text); 1188 - } 1189 - cairo_restore (ctx->cairo); 1190 - return GGRAPH_OK; 1191 -}
Deleted src/gaiagraphics_png.c.
1 -/* 2 -/ gaiagraphics_png.c 3 -/ 4 -/ PNG auxiliary helpers 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdio.h> 28 -#include <math.h> 29 -#include <string.h> 30 -#include <stdlib.h> 31 - 32 -#include <png.h> 33 - 34 -#define PNG_TRUE 1 35 -#define PNG_FALSE 0 36 - 37 -#include "gaiagraphics.h" 38 -#include "gaiagraphics_internals.h" 39 - 40 -struct png_codec_data 41 -{ 42 -/* a struct used by PNG codec */ 43 - int is_writer; 44 - png_structp png_ptr; 45 - png_infop info_ptr; 46 - png_bytep row_pointer; 47 - int palette_allocated; 48 - int num_palette; 49 - png_colorp palette; 50 - int bit_depth; 51 - int color_type; 52 - int interlace_type; 53 - int quantization_factor; 54 - xgdIOCtx *io_ctx; 55 -}; 56 - 57 -/* 58 -/ 59 -/ DISCLAIMER: 60 -/ the following code is vaguely derived from the original GD lib 61 -/ code, which was originally released under a BSD-like license 62 -/ 63 -*/ 64 - 65 -#ifndef PNG_SETJMP_NOT_SUPPORTED 66 -typedef struct _jmpbuf_wrapper 67 -{ 68 - jmp_buf jmpbuf; 69 -} 70 -jmpbuf_wrapper; 71 - 72 -static jmpbuf_wrapper xgdPngJmpbufStruct; 73 - 74 -static void 75 -xgdPngErrorHandler (png_structp png_ptr, png_const_charp msg) 76 -{ 77 - jmpbuf_wrapper *jmpbuf_ptr; 78 - fprintf (stderr, "png-wrapper: fatal libpng error: %s\n", msg); 79 - fflush (stderr); 80 - jmpbuf_ptr = png_get_error_ptr (png_ptr); 81 - if (jmpbuf_ptr == NULL) 82 - { 83 - fprintf (stderr, 84 - "png-wrapper: EXTREMELY fatal error: jmpbuf unrecoverable; terminating.\n"); 85 - fflush (stderr); 86 - exit (99); 87 - } 88 - longjmp (jmpbuf_ptr->jmpbuf, 1); 89 -} 90 -#endif 91 - 92 -static void 93 -xgdPngReadData (png_structp png_ptr, png_bytep data, png_size_t length) 94 -{ 95 - int check; 96 - check = xgdGetBuf (data, length, (xgdIOCtx *) png_get_io_ptr (png_ptr)); 97 - if (check != (int) length) 98 - { 99 - png_error (png_ptr, "Read Error: truncated data"); 100 - } 101 -} 102 - 103 -static void 104 -xgdPngWriteData (png_structp png_ptr, png_bytep data, png_size_t length) 105 -{ 106 - xgdPutBuf (data, length, (xgdIOCtx *) png_get_io_ptr (png_ptr)); 107 -} 108 - 109 -static void 110 -xgdPngFlushData (png_structp png_ptr) 111 -{ 112 - if (png_ptr) 113 - return; /* does absolutely nothing - required in order to suppress warnings */ 114 -} 115 - 116 -static gGraphImageInfosPtr 117 -xgdImageInfosFromPngCtx (xgdIOCtx * infile, int *errcode) 118 -{ 119 -/* retrieving general infos from a PNG image */ 120 - png_byte sig[8]; 121 - png_structp png_ptr; 122 - png_infop info_ptr; 123 - png_uint_32 width, height; 124 - int bit_depth, color_type, interlace_type; 125 - int num_palette; 126 - png_colorp palette; 127 - int i; 128 - gGraphImageInfosPtr infos = NULL; 129 - memset (sig, 0, sizeof (sig)); 130 - if (xgdGetBuf (sig, 8, infile) < 8) 131 - { 132 - *errcode = GGRAPH_PNG_CODEC_ERROR; 133 - return NULL; 134 - } 135 - if (png_sig_cmp (sig, 0, 8)) 136 - { 137 - *errcode = GGRAPH_PNG_CODEC_ERROR; 138 - return NULL; 139 - } 140 -#ifndef PNG_SETJMP_NOT_SUPPORTED 141 - png_ptr = 142 - png_create_read_struct (PNG_LIBPNG_VER_STRING, &xgdPngJmpbufStruct, 143 - xgdPngErrorHandler, NULL); 144 -#else 145 - png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 146 -#endif 147 - if (png_ptr == NULL) 148 - { 149 - fprintf (stderr, 150 - "png-wrapper error: cannot allocate libpng main struct\n"); 151 - *errcode = GGRAPH_PNG_CODEC_ERROR; 152 - return NULL; 153 - } 154 - info_ptr = png_create_info_struct (png_ptr); 155 - if (info_ptr == NULL) 156 - { 157 - fprintf (stderr, 158 - "png-wrapper error: cannot allocate libpng info struct\n"); 159 - png_destroy_read_struct (&png_ptr, NULL, NULL); 160 - *errcode = GGRAPH_PNG_CODEC_ERROR; 161 - return NULL; 162 - } 163 -#ifndef PNG_SETJMP_NOT_SUPPORTED 164 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 165 - { 166 - fprintf (stderr, 167 - "png-wrapper error: setjmp returns error condition 1\n"); 168 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 169 - *errcode = GGRAPH_PNG_CODEC_ERROR; 170 - return NULL; 171 - } 172 -#endif 173 - png_set_sig_bytes (png_ptr, 8); 174 - png_set_read_fn (png_ptr, (void *) infile, xgdPngReadData); 175 - png_read_info (png_ptr, info_ptr); 176 - png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 177 - &interlace_type, NULL, NULL); 178 - if (color_type == PNG_COLOR_TYPE_PALETTE) 179 - { 180 - infos = 181 - gg_image_infos_create (GG_PIXEL_PALETTE, (int) width, 182 - (int) height, bit_depth, 1, 183 - GGRAPH_SAMPLE_UINT, NULL, NULL); 184 - png_get_PLTE (png_ptr, info_ptr, &palette, &num_palette); 185 - infos->max_palette = num_palette; 186 - for (i = 0; i < num_palette; i++) 187 - { 188 - infos->palette_red[i] = palette[i].red; 189 - infos->palette_green[i] = palette[i].green; 190 - infos->palette_blue[i] = palette[i].blue; 191 - fprintf (stderr, "plt %d/%d %02x%02x%02x\n", i, num_palette, 192 - infos->palette_red[i], infos->palette_green[i], 193 - infos->palette_blue[i]); 194 - fflush (stderr); 195 - } 196 - } 197 - else if (color_type == PNG_COLOR_TYPE_GRAY 198 - || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 199 - infos = 200 - gg_image_infos_create (GG_PIXEL_GRAYSCALE, (int) width, 201 - (int) height, bit_depth, 1, 202 - GGRAPH_SAMPLE_UINT, NULL, NULL); 203 - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) 204 - infos = 205 - gg_image_infos_create (GG_PIXEL_RGBA, (int) width, (int) height, 206 - bit_depth, 4, GGRAPH_SAMPLE_UINT, NULL, 207 - NULL); 208 - else 209 - infos = 210 - gg_image_infos_create (GG_PIXEL_RGB, (int) width, (int) height, 211 - bit_depth, 3, GGRAPH_SAMPLE_UINT, NULL, 212 - NULL); 213 - if (infos == NULL) 214 - { 215 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 216 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 217 - return NULL; 218 - } 219 - infos->compression = GGRAPH_TIFF_COMPRESSION_DEFLATE; 220 - if (png_get_interlace_type (png_ptr, info_ptr) == PNG_INTERLACE_ADAM7) 221 - { 222 - infos->scale_1_2 = 1; 223 - infos->scale_1_4 = 1; 224 - infos->scale_1_8 = 1; 225 - } 226 - return infos; 227 -} 228 - 229 -static gGraphImagePtr 230 -xgdImageCreateFromPngCtx (xgdIOCtx * infile, int *errcode, int scale) 231 -{ 232 -/* decompressing a PNG image */ 233 - png_byte sig[8]; 234 - png_structp png_ptr; 235 - png_infop info_ptr; 236 - png_uint_32 width, height, rowbytes, w, h; 237 - int img_width, img_height; 238 - int bit_depth, color_type, interlace_type; 239 - int num_palette; 240 - png_colorp palette; 241 - int is_adam7; 242 - png_bytep row_pointer = NULL; 243 - gGraphImagePtr img = NULL; 244 - int i, j; 245 - volatile int palette_allocated = PNG_FALSE; 246 - memset (sig, 0, sizeof (sig)); 247 - if (xgdGetBuf (sig, 8, infile) < 8) 248 - { 249 - *errcode = GGRAPH_PNG_CODEC_ERROR; 250 - return NULL; 251 - } 252 - if (png_sig_cmp (sig, 0, 8)) 253 - { 254 - *errcode = GGRAPH_PNG_CODEC_ERROR; 255 - return NULL; 256 - } 257 -#ifndef PNG_SETJMP_NOT_SUPPORTED 258 - png_ptr = 259 - png_create_read_struct (PNG_LIBPNG_VER_STRING, &xgdPngJmpbufStruct, 260 - xgdPngErrorHandler, NULL); 261 -#else 262 - png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 263 -#endif 264 - if (png_ptr == NULL) 265 - { 266 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 267 - return NULL; 268 - } 269 - info_ptr = png_create_info_struct (png_ptr); 270 - if (info_ptr == NULL) 271 - { 272 - png_destroy_read_struct (&png_ptr, NULL, NULL); 273 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 274 - return NULL; 275 - } 276 -#ifndef PNG_SETJMP_NOT_SUPPORTED 277 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 278 - { 279 - fprintf (stderr, 280 - "png-wrapper error: setjmp returns error condition 1\n"); 281 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 282 - *errcode = GGRAPH_PNG_CODEC_ERROR; 283 - return NULL; 284 - } 285 -#endif 286 - png_set_sig_bytes (png_ptr, 8); 287 - png_set_read_fn (png_ptr, (void *) infile, xgdPngReadData); 288 - png_read_info (png_ptr, info_ptr); 289 - png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 290 - &interlace_type, NULL, NULL); 291 - if (png_get_interlace_type (png_ptr, info_ptr) == PNG_INTERLACE_ADAM7) 292 - { 293 - /* Adam7 interlaced [supporting 1:1, 1:2, 1:4 and 1:8 reduced image] */ 294 - is_adam7 = 1; 295 - if (scale == 8) 296 - { 297 - /* requesting 1:8 scaling */ 298 - img_width = width / 8; 299 - if ((img_width * 8) < (int) width) 300 - img_width++; 301 - img_height = height / 8; 302 - if ((img_height * 8) < (int) height) 303 - img_height++; 304 - } 305 - else if (scale == 4) 306 - { 307 - /* requesting 1:4 scaling */ 308 - img_width = width / 4; 309 - if ((img_width * 4) < (int) width) 310 - img_width++; 311 - img_height = height / 4; 312 - if ((img_height * 4) < (int) height) 313 - img_height++; 314 - } 315 - else if (scale == 2) 316 - { 317 - /* requesting 1:2 scaling */ 318 - img_width = width / 2; 319 - if ((img_width * 2) < (int) width) 320 - img_width++; 321 - img_height = height / 2; 322 - if ((img_height * 2) < (int) height) 323 - img_height++; 324 - } 325 - else 326 - { 327 - /* no scaling, full dimension */ 328 - img_width = width; 329 - img_height = height; 330 - } 331 - } 332 - else 333 - { 334 - /* normal, not Adam7 interlaced */ 335 - is_adam7 = 0; 336 - img_width = width; 337 - img_height = height; 338 - } 339 - 340 - if (color_type == PNG_COLOR_TYPE_PALETTE) 341 - img = 342 - gg_image_create (GG_PIXEL_PALETTE, img_width, img_height, bit_depth, 343 - 1, GGRAPH_SAMPLE_UINT, NULL, NULL); 344 - else if (color_type == PNG_COLOR_TYPE_GRAY 345 - || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 346 - img = 347 - gg_image_create (GG_PIXEL_GRAYSCALE, img_width, img_height, 348 - bit_depth, 1, GGRAPH_SAMPLE_UINT, NULL, NULL); 349 - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) 350 - img = 351 - gg_image_create (GG_PIXEL_RGBA, img_width, img_height, bit_depth, 4, 352 - GGRAPH_SAMPLE_UINT, NULL, NULL); 353 - else 354 - img = 355 - gg_image_create (GG_PIXEL_RGB, img_width, img_height, bit_depth, 3, 356 - GGRAPH_SAMPLE_UINT, NULL, NULL); 357 - if (img == NULL) 358 - { 359 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 360 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 361 - return NULL; 362 - } 363 - 364 - if (bit_depth == 16) 365 - { 366 - png_set_strip_16 (png_ptr); 367 - } 368 - else if (bit_depth < 8) 369 - { 370 - png_set_packing (png_ptr); 371 - } 372 -#ifndef PNG_SETJMP_NOT_SUPPORTED 373 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 374 - { 375 - fprintf (stderr, 376 - "png-wrapper error: setjmp returns error condition 2"); 377 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 378 - free (row_pointer); 379 - if (img) 380 - gg_image_destroy (img); 381 - *errcode = GGRAPH_PNG_CODEC_ERROR; 382 - return NULL; 383 - } 384 -#endif 385 - switch (color_type) 386 - { 387 - case PNG_COLOR_TYPE_PALETTE: 388 - png_get_PLTE (png_ptr, info_ptr, &palette, &num_palette); 389 - img->max_palette = num_palette; 390 - for (i = 0; i < num_palette; i++) 391 - { 392 - img->palette_red[i] = palette[i].red; 393 - img->palette_green[i] = palette[i].green; 394 - img->palette_blue[i] = palette[i].blue; 395 - } 396 - break; 397 - case PNG_COLOR_TYPE_GRAY: 398 - case PNG_COLOR_TYPE_GRAY_ALPHA: 399 - if ((palette = malloc (256 * sizeof (png_color))) == NULL) 400 - { 401 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 402 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 403 - return NULL; 404 - } 405 - palette_allocated = PNG_TRUE; 406 - if (bit_depth < 8) 407 - { 408 - num_palette = 1 << bit_depth; 409 - for (i = 0; i < 256; ++i) 410 - { 411 - j = (255 * i) / (num_palette - 1); 412 - palette[i].red = palette[i].green = palette[i].blue = j; 413 - } 414 - } 415 - else 416 - { 417 - num_palette = 256; 418 - for (i = 0; i < 256; ++i) 419 - { 420 - palette[i].red = palette[i].green = palette[i].blue = i; 421 - } 422 - } 423 - break; 424 - } 425 - png_read_update_info (png_ptr, info_ptr); 426 - rowbytes = png_get_rowbytes (png_ptr, info_ptr); 427 - if (overflow2 (rowbytes, height)) 428 - { 429 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 430 - *errcode = GGRAPH_PNG_CODEC_ERROR; 431 - return NULL; 432 - } 433 - row_pointer = malloc (rowbytes); 434 - if (!row_pointer) 435 - { 436 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 437 - if (img) 438 - gg_image_destroy (img); 439 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 440 - return NULL; 441 - } 442 - if (overflow2 (height, sizeof (png_bytep))) 443 - { 444 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 445 - free (row_pointer); 446 - if (img) 447 - gg_image_destroy (img); 448 - *errcode = GGRAPH_PNG_CODEC_ERROR; 449 - return NULL; 450 - } 451 - if (is_adam7) 452 - { 453 - /* reading an ADAM7 interlaced image */ 454 - int row_no; 455 - int pass; 456 - int y_base, y_step; 457 - png_uint_32 h_limit, w_limit; 458 - for (pass = 0; pass < 7; pass++) 459 - { 460 - /* reading an interlaced image requires 7 passes */ 461 - if (scale == 8 && pass > 0) 462 - { 463 - /* 1:8 reduced image already exctracted */ 464 - break; 465 - } 466 - if (scale == 4 && pass > 2) 467 - { 468 - /* 1:4 reduced image already extracted */ 469 - break; 470 - } 471 - if (scale == 2 && pass > 4) 472 - { 473 - /* 1:2 reduced image already extracted */ 474 - break; 475 - } 476 - 477 - switch (pass) 478 - { 479 - case 0: 480 - y_base = 0; 481 - y_step = 8; 482 - break; 483 - case 1: 484 - y_base = 0; 485 - y_step = 8; 486 - break; 487 - case 2: 488 - y_base = 4; 489 - y_step = 8; 490 - break; 491 - case 3: 492 - y_base = 0; 493 - y_step = 4; 494 - break; 495 - case 4: 496 - y_base = 2; 497 - y_step = 4; 498 - break; 499 - case 5: 500 - y_base = 0; 501 - y_step = 2; 502 - break; 503 - case 6: 504 - y_base = 1; 505 - y_step = 2; 506 - break; 507 - }; 508 - h_limit = (height - y_base) / y_step; 509 - if ((h_limit * y_step) < (height - y_base)) 510 - h_limit++; 511 - row_no = 0; 512 - for (h = 0; h < h_limit; h++) 513 - { 514 - int skip; 515 - int boffset = 0; 516 - int x_base; 517 - int x_step; 518 - unsigned char *p_out; 519 - png_read_row (png_ptr, row_pointer, NULL); 520 - 521 - switch (pass) 522 - { 523 - case 0: 524 - x_base = 0; 525 - x_step = 8; 526 - break; 527 - case 1: 528 - x_base = 4; 529 - x_step = 8; 530 - break; 531 - case 2: 532 - x_base = 0; 533 - x_step = 4; 534 - break; 535 - case 3: 536 - x_base = 4; 537 - x_step = 4; 538 - break; 539 - case 4: 540 - x_base = 0; 541 - x_step = 2; 542 - break; 543 - case 5: 544 - x_base = 1; 545 - x_step = 2; 546 - break; 547 - case 6: 548 - x_base = 0; 549 - x_step = 1; 550 - break; 551 - }; 552 - w_limit = (width - x_base) / x_step; 553 - if ((w_limit * x_step) < (width - x_base)) 554 - w_limit++; 555 - switch (pass) 556 - { 557 - case 0: 558 - p_out = 559 - img->pixels + (row_no * img->scanline_width); 560 - switch (scale) 561 - { 562 - case 8: 563 - skip = 0; 564 - row_no += 1; 565 - break; 566 - case 4: 567 - skip = 1; 568 - row_no += 2; 569 - break; 570 - case 2: 571 - skip = 3; 572 - row_no += 4; 573 - break; 574 - case 1: 575 - skip = 7; 576 - row_no += 8; 577 - break; 578 - }; 579 - break; 580 - case 1: 581 - switch (scale) 582 - { 583 - case 4: 584 - p_out = 585 - img->pixels + 586 - (row_no * img->scanline_width) + 587 - img->pixel_size; 588 - skip = 1; 589 - row_no += 2; 590 - break; 591 - case 2: 592 - p_out = 593 - img->pixels + 594 - (row_no * img->scanline_width) + 595 - (img->pixel_size * 2); 596 - skip = 3; 597 - row_no += 4; 598 - break; 599 - case 1: 600 - p_out = 601 - img->pixels + 602 - (row_no * img->scanline_width) + 603 - (img->pixel_size * 4); 604 - skip = 7; 605 - row_no += 8; 606 - break; 607 - }; 608 - break; 609 - case 2: 610 - switch (scale) 611 - { 612 - case 4: 613 - p_out = 614 - img->pixels + 615 - ((row_no + 1) * img->scanline_width); 616 - skip = 0; 617 - row_no += 2; 618 - break; 619 - case 2: 620 - p_out = 621 - img->pixels + 622 - ((row_no + 2) * img->scanline_width); 623 - skip = 1; 624 - row_no += 4; 625 - break; 626 - case 1: 627 - p_out = 628 - img->pixels + 629 - ((row_no + 4) * img->scanline_width); 630 - skip = 3; 631 - row_no += 8; 632 - break; 633 - }; 634 - break; 635 - case 3: 636 - switch (scale) 637 - { 638 - case 2: 639 - p_out = 640 - img->pixels + 641 - (row_no * img->scanline_width) + 642 - img->pixel_size; 643 - skip = 1; 644 - row_no += 2; 645 - break; 646 - case 1: 647 - p_out = 648 - img->pixels + 649 - (row_no * img->scanline_width) + 650 - (img->pixel_size * 2); 651 - skip = 3; 652 - row_no += 4; 653 - break; 654 - }; 655 - break; 656 - case 4: 657 - switch (scale) 658 - { 659 - case 2: 660 - p_out = 661 - img->pixels + 662 - ((row_no + 1) * img->scanline_width); 663 - skip = 0; 664 - row_no += 2; 665 - break; 666 - case 1: 667 - p_out = 668 - img->pixels + 669 - ((row_no + 2) * img->scanline_width); 670 - skip = 1; 671 - row_no += 4; 672 - break; 673 - }; 674 - break; 675 - case 5: 676 - p_out = 677 - img->pixels + (row_no * img->scanline_width) + 678 - (img->pixel_size); 679 - skip = 1; 680 - row_no += 2; 681 - break; 682 - case 6: 683 - p_out = 684 - img->pixels + 685 - ((row_no + 1) * img->scanline_width); 686 - skip = 0; 687 - row_no += 2; 688 - break; 689 - }; 690 - 691 - switch (color_type) 692 - { 693 - case PNG_COLOR_TYPE_RGB: 694 - for (w = 0; w < w_limit; w++) 695 - { 696 - register png_byte r = row_pointer[boffset++]; 697 - register png_byte g = row_pointer[boffset++]; 698 - register png_byte b = row_pointer[boffset++]; 699 - *p_out++ = r; 700 - *p_out++ = g; 701 - *p_out++ = b; 702 - p_out += skip * 3; 703 - } 704 - break; 705 - case PNG_COLOR_TYPE_RGB_ALPHA: 706 - for (w = 0; w < w_limit; w++) 707 - { 708 - register png_byte r = row_pointer[boffset++]; 709 - register png_byte g = row_pointer[boffset++]; 710 - register png_byte b = row_pointer[boffset++]; 711 - register png_byte alpha = 712 - row_pointer[boffset++]; 713 - *p_out++ = r; 714 - *p_out++ = g; 715 - *p_out++ = b; 716 - *p_out++ = alpha; 717 - p_out += skip * 4; 718 - } 719 - break; 720 - case PNG_COLOR_TYPE_GRAY: 721 - case PNG_COLOR_TYPE_GRAY_ALPHA: 722 - for (w = 0; w < w_limit; w++) 723 - { 724 - register png_byte idx = row_pointer[w]; 725 - *p_out++ = idx; 726 - p_out += skip; 727 - } 728 - break; 729 - default: 730 - for (w = 0; w < w_limit; w++) 731 - { 732 - register png_byte idx = row_pointer[w]; 733 - *p_out++ = idx; 734 - p_out += skip; 735 - } 736 - }; 737 - } 738 - } 739 - } 740 - else 741 - { 742 - /* reading a non-interlaced image */ 743 - for (h = 0; h < height; h++) 744 - { 745 - int boffset = 0; 746 - unsigned char *p_out = img->pixels + (h * img->scanline_width); 747 - png_read_row (png_ptr, row_pointer, NULL); 748 - switch (color_type) 749 - { 750 - case PNG_COLOR_TYPE_RGB: 751 - for (w = 0; w < width; w++) 752 - { 753 - register png_byte r = row_pointer[boffset++]; 754 - register png_byte g = row_pointer[boffset++]; 755 - register png_byte b = row_pointer[boffset++]; 756 - *p_out++ = r; 757 - *p_out++ = g; 758 - *p_out++ = b; 759 - } 760 - break; 761 - case PNG_COLOR_TYPE_RGB_ALPHA: 762 - for (w = 0; w < width; w++) 763 - { 764 - register png_byte r = row_pointer[boffset++]; 765 - register png_byte g = row_pointer[boffset++]; 766 - register png_byte b = row_pointer[boffset++]; 767 - register png_byte alpha = row_pointer[boffset++]; 768 - *p_out++ = r; 769 - *p_out++ = g; 770 - *p_out++ = b; 771 - *p_out++ = alpha; 772 - } 773 - break; 774 - case PNG_COLOR_TYPE_GRAY: 775 - case PNG_COLOR_TYPE_GRAY_ALPHA: 776 - for (w = 0; w < width; ++w) 777 - { 778 - register png_byte idx = row_pointer[w]; 779 - *p_out++ = idx; 780 - } 781 - break; 782 - default: 783 - for (w = 0; w < width; ++w) 784 - { 785 - register png_byte idx = row_pointer[w]; 786 - *p_out++ = idx; 787 - } 788 - } 789 - } 790 - } 791 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 792 - 793 - if (palette_allocated == PNG_TRUE) 794 - free (palette); 795 - free (row_pointer); 796 - return img; 797 -} 798 - 799 -GGRAPH_PRIVATE void 800 -gg_png_codec_destroy (void *p) 801 -{ 802 -/* destroyng the PNG codec data */ 803 - struct png_codec_data *codec = (struct png_codec_data *) p; 804 - if (!codec) 805 - return; 806 - if (codec->is_writer) 807 - { 808 - png_write_end (codec->png_ptr, codec->info_ptr); 809 - png_destroy_write_struct (&(codec->png_ptr), &(codec->info_ptr)); 810 - } 811 - else 812 - { 813 - png_read_end (codec->png_ptr, codec->info_ptr); 814 - png_destroy_read_struct (&(codec->png_ptr), &(codec->info_ptr), NULL); 815 - } 816 - if (codec->palette_allocated == PNG_TRUE) 817 - free (codec->palette); 818 - free (codec->row_pointer); 819 - codec->io_ctx->xgd_free (codec->io_ctx); 820 - free (codec); 821 -} 822 - 823 -static gGraphStripImagePtr 824 -xgdStripImageCreateFromPngCtx (xgdIOCtx * infile, int *errcode, FILE * file) 825 -{ 826 -/* preparing to decompress a PNG image [by strips] */ 827 - png_byte sig[8]; 828 - png_structp png_ptr; 829 - png_infop info_ptr; 830 - png_uint_32 width, height, rowbytes; 831 - int bit_depth, color_type, interlace_type; 832 - int num_palette; 833 - png_colorp palette; 834 - png_bytep row_pointer = NULL; 835 - gGraphStripImagePtr img = NULL; 836 - struct png_codec_data *png_codec; 837 - int i, j; 838 - volatile int palette_allocated = PNG_FALSE; 839 - memset (sig, 0, sizeof (sig)); 840 - if (xgdGetBuf (sig, 8, infile) < 8) 841 - { 842 - *errcode = GGRAPH_PNG_CODEC_ERROR; 843 - return NULL; 844 - } 845 - if (png_sig_cmp (sig, 0, 8)) 846 - { 847 - *errcode = GGRAPH_PNG_CODEC_ERROR; 848 - return NULL; 849 - } 850 -#ifndef PNG_SETJMP_NOT_SUPPORTED 851 - png_ptr = 852 - png_create_read_struct (PNG_LIBPNG_VER_STRING, &xgdPngJmpbufStruct, 853 - xgdPngErrorHandler, NULL); 854 -#else 855 - png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 856 -#endif 857 - if (png_ptr == NULL) 858 - { 859 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 860 - return NULL; 861 - } 862 - info_ptr = png_create_info_struct (png_ptr); 863 - if (info_ptr == NULL) 864 - { 865 - png_destroy_read_struct (&png_ptr, NULL, NULL); 866 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 867 - return NULL; 868 - } 869 -#ifndef PNG_SETJMP_NOT_SUPPORTED 870 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 871 - { 872 - fprintf (stderr, 873 - "png-wrapper error: setjmp returns error condition 1\n"); 874 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 875 - *errcode = GGRAPH_PNG_CODEC_ERROR; 876 - return NULL; 877 - } 878 -#endif 879 - png_set_sig_bytes (png_ptr, 8); 880 - png_set_read_fn (png_ptr, (void *) infile, xgdPngReadData); 881 - png_read_info (png_ptr, info_ptr); 882 - png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 883 - &interlace_type, NULL, NULL); 884 - 885 - if (interlace_type == PNG_INTERLACE_ADAM7) 886 - { 887 - fprintf (stderr, 888 - "png-wrapper error: ADAM7 interlace cannot be accessed by strips\n"); 889 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 890 - *errcode = GGRAPH_PNG_CODEC_ERROR; 891 - return NULL; 892 - } 893 - 894 - if (color_type == PNG_COLOR_TYPE_PALETTE) 895 - { 896 - img = 897 - gg_strip_image_create (file, GGRAPH_IMAGE_PNG, GG_PIXEL_PALETTE, 898 - width, height, bit_depth, 1, 899 - GGRAPH_SAMPLE_UINT, NULL, NULL); 900 - } 901 - else if (color_type == PNG_COLOR_TYPE_GRAY 902 - || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 903 - { 904 - img = 905 - gg_strip_image_create (file, GGRAPH_IMAGE_PNG, GG_PIXEL_GRAYSCALE, 906 - width, height, bit_depth, 1, 907 - GGRAPH_SAMPLE_UINT, NULL, NULL); 908 - } 909 - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) 910 - { 911 - img = 912 - gg_strip_image_create (file, GGRAPH_IMAGE_PNG, GG_PIXEL_RGBA, 913 - width, height, bit_depth, 4, 914 - GGRAPH_SAMPLE_UINT, NULL, NULL); 915 - } 916 - else 917 - { 918 - img = 919 - gg_strip_image_create (file, GGRAPH_IMAGE_PNG, GG_PIXEL_RGB, 920 - width, height, bit_depth, 3, 921 - GGRAPH_SAMPLE_UINT, NULL, NULL); 922 - } 923 - if (img == NULL) 924 - { 925 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 926 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 927 - return NULL; 928 - } 929 - 930 - if (bit_depth == 16) 931 - { 932 - png_set_strip_16 (png_ptr); 933 - } 934 - else if (bit_depth < 8) 935 - { 936 - png_set_packing (png_ptr); 937 - } 938 -#ifndef PNG_SETJMP_NOT_SUPPORTED 939 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 940 - { 941 - fprintf (stderr, 942 - "png-wrapper error: setjmp returns error condition 2"); 943 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 944 - free (row_pointer); 945 - if (img) 946 - gg_strip_image_destroy (img); 947 - *errcode = GGRAPH_PNG_CODEC_ERROR; 948 - return NULL; 949 - } 950 -#endif 951 - switch (color_type) 952 - { 953 - case PNG_COLOR_TYPE_PALETTE: 954 - png_get_PLTE (png_ptr, info_ptr, &palette, &num_palette); 955 - img->max_palette = num_palette; 956 - for (i = 0; i < num_palette; i++) 957 - { 958 - img->palette_red[i] = palette[i].red; 959 - img->palette_green[i] = palette[i].green; 960 - img->palette_blue[i] = palette[i].blue; 961 - } 962 - break; 963 - case PNG_COLOR_TYPE_GRAY: 964 - case PNG_COLOR_TYPE_GRAY_ALPHA: 965 - if ((palette = malloc (256 * sizeof (png_color))) == NULL) 966 - { 967 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 968 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 969 - return NULL; 970 - } 971 - palette_allocated = PNG_TRUE; 972 - if (bit_depth < 8) 973 - { 974 - num_palette = 1 << bit_depth; 975 - for (i = 0; i < 256; ++i) 976 - { 977 - j = (255 * i) / (num_palette - 1); 978 - palette[i].red = palette[i].green = palette[i].blue = j; 979 - } 980 - } 981 - else 982 - { 983 - num_palette = 256; 984 - for (i = 0; i < 256; ++i) 985 - { 986 - palette[i].red = palette[i].green = palette[i].blue = i; 987 - } 988 - } 989 - break; 990 - } 991 - png_read_update_info (png_ptr, info_ptr); 992 - rowbytes = png_get_rowbytes (png_ptr, info_ptr); 993 - if (overflow2 (rowbytes, height)) 994 - { 995 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 996 - *errcode = GGRAPH_PNG_CODEC_ERROR; 997 - return NULL; 998 - } 999 - row_pointer = malloc (rowbytes); 1000 - if (!row_pointer) 1001 - { 1002 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 1003 - if (img) 1004 - gg_strip_image_destroy (img); 1005 - *errcode = GGRAPH_INSUFFICIENT_MEMORY; 1006 - return NULL; 1007 - } 1008 - if (overflow2 (height, sizeof (png_bytep))) 1009 - { 1010 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 1011 - free (row_pointer); 1012 - if (img) 1013 - gg_strip_image_destroy (img); 1014 - *errcode = GGRAPH_PNG_CODEC_ERROR; 1015 - return NULL; 1016 - } 1017 - 1018 -/* setting up the PNG codec struct */ 1019 - png_codec = malloc (sizeof (struct png_codec_data)); 1020 - if (!png_codec) 1021 - { 1022 - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 1023 - free (row_pointer); 1024 - gg_strip_image_destroy (img); 1025 - *errcode = GGRAPH_PNG_CODEC_ERROR; 1026 - return NULL; 1027 - } 1028 - png_codec->is_writer = 0; 1029 - png_codec->row_pointer = row_pointer; 1030 - png_codec->png_ptr = png_ptr; 1031 - png_codec->info_ptr = info_ptr; 1032 - png_codec->palette_allocated = palette_allocated; 1033 - png_codec->num_palette = num_palette; 1034 - png_codec->palette = palette; 1035 - png_codec->bit_depth = bit_depth; 1036 - png_codec->color_type = color_type; 1037 - png_codec->interlace_type = interlace_type; 1038 - png_codec->io_ctx = infile; 1039 - img->codec_data = png_codec; 1040 - 1041 - return img; 1042 -} 1043 - 1044 -static int 1045 -xgdStripImageReadFromPngCtx (gGraphStripImagePtr img) 1046 -{ 1047 -/* decompressing a PNG image [by strip] */ 1048 - png_uint_32 w, h; 1049 - struct png_codec_data *png_codec = 1050 - (struct png_codec_data *) (img->codec_data); 1051 - png_structp png_ptr = png_codec->png_ptr; 1052 - int color_type = png_codec->color_type; 1053 - png_bytep row_pointer = png_codec->row_pointer; 1054 - png_uint_32 width = img->width; 1055 - png_uint_32 height = img->rows_per_block; 1056 - 1057 - if (img->next_row >= img->height) 1058 - { 1059 - /* EOF condition */ 1060 - fprintf (stderr, "png-wrapper error: attempting to read beyond EOF"); 1061 - return GGRAPH_PNG_CODEC_ERROR; 1062 - } 1063 - if ((img->next_row + img->rows_per_block) >= img->height) 1064 - height = img->height - img->next_row; 1065 - img->current_available_rows = height; 1066 - 1067 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1068 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1069 - { 1070 - fprintf (stderr, 1071 - "png-wrapper error: setjmp returns error condition 2"); 1072 - return GGRAPH_PNG_CODEC_ERROR; 1073 - } 1074 -#endif 1075 - 1076 -/* reading a non-interlaced image */ 1077 - for (h = 0; h < height; h++) 1078 - { 1079 - int boffset = 0; 1080 - unsigned char *p_out = img->pixels + (h * img->scanline_width); 1081 - png_read_row (png_ptr, row_pointer, NULL); 1082 - switch (color_type) 1083 - { 1084 - case PNG_COLOR_TYPE_RGB: 1085 - for (w = 0; w < width; w++) 1086 - { 1087 - register png_byte r = row_pointer[boffset++]; 1088 - register png_byte g = row_pointer[boffset++]; 1089 - register png_byte b = row_pointer[boffset++]; 1090 - *p_out++ = r; 1091 - *p_out++ = g; 1092 - *p_out++ = b; 1093 - } 1094 - break; 1095 - case PNG_COLOR_TYPE_RGB_ALPHA: 1096 - for (w = 0; w < width; w++) 1097 - { 1098 - register png_byte r = row_pointer[boffset++]; 1099 - register png_byte g = row_pointer[boffset++]; 1100 - register png_byte b = row_pointer[boffset++]; 1101 - register png_byte alpha = row_pointer[boffset++]; 1102 - *p_out++ = r; 1103 - *p_out++ = g; 1104 - *p_out++ = b; 1105 - *p_out++ = alpha; 1106 - } 1107 - break; 1108 - case PNG_COLOR_TYPE_GRAY: 1109 - case PNG_COLOR_TYPE_GRAY_ALPHA: 1110 - for (w = 0; w < width; ++w) 1111 - { 1112 - register png_byte idx = row_pointer[w]; 1113 - *p_out++ = idx; 1114 - } 1115 - break; 1116 - default: 1117 - for (w = 0; w < width; ++w) 1118 - { 1119 - register png_byte idx = row_pointer[w]; 1120 - *p_out++ = idx; 1121 - } 1122 - } 1123 - } 1124 - img->next_row += height; 1125 - return GGRAPH_OK; 1126 -} 1127 - 1128 -static int 1129 -xgdImagePngCtxPalette (gGraphImagePtr img, xgdIOCtx * outfile, 1130 - int compression_level, int interlaced) 1131 -{ 1132 -/* compressing a PNG image [palette] */ 1133 - int i, j, bit_depth = 0, interlace_type; 1134 - int width = img->width; 1135 - int height = img->height; 1136 - png_color palette[256]; 1137 - int colors = img->max_palette; 1138 - png_structp png_ptr; 1139 - png_infop info_ptr; 1140 - png_bytep row_pointer = NULL; 1141 - int pass; 1142 - int num_passes; 1143 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1144 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 1145 - &xgdPngJmpbufStruct, xgdPngErrorHandler, 1146 - NULL); 1147 -#else 1148 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 1149 -#endif 1150 - if (png_ptr == NULL) 1151 - return GGRAPH_INSUFFICIENT_MEMORY; 1152 - info_ptr = png_create_info_struct (png_ptr); 1153 - if (info_ptr == NULL) 1154 - { 1155 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1156 - return GGRAPH_INSUFFICIENT_MEMORY; 1157 - } 1158 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1159 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1160 - { 1161 - if (row_pointer) 1162 - free (row_pointer); 1163 - png_destroy_write_struct (&png_ptr, &info_ptr); 1164 - return GGRAPH_PNG_CODEC_ERROR; 1165 - } 1166 -#endif 1167 - png_set_write_fn (png_ptr, (void *) outfile, xgdPngWriteData, 1168 - xgdPngFlushData); 1169 - png_set_compression_level (png_ptr, compression_level); 1170 - if (colors <= 2) 1171 - bit_depth = 1; 1172 - else if (colors <= 4) 1173 - bit_depth = 2; 1174 - else if (colors <= 16) 1175 - bit_depth = 4; 1176 - else 1177 - bit_depth = 8; 1178 - if (interlaced) 1179 - interlace_type = PNG_INTERLACE_ADAM7; 1180 - else 1181 - interlace_type = PNG_INTERLACE_NONE; 1182 - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, 1183 - PNG_COLOR_TYPE_PALETTE, interlace_type, 1184 - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 1185 - for (i = 0; i < colors; i++) 1186 - { 1187 - palette[i].red = img->palette_red[i]; 1188 - palette[i].green = img->palette_green[i]; 1189 - palette[i].blue = img->palette_blue[i]; 1190 - } 1191 - png_set_PLTE (png_ptr, info_ptr, palette, colors); 1192 - png_write_info (png_ptr, info_ptr); 1193 - png_set_packing (png_ptr); 1194 - if (overflow2 (sizeof (png_bytep), height)) 1195 - return GGRAPH_PNG_CODEC_ERROR; 1196 - row_pointer = malloc (width); 1197 - if (!row_pointer) 1198 - { 1199 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1200 - return GGRAPH_INSUFFICIENT_MEMORY; 1201 - } 1202 - num_passes = png_set_interlace_handling (png_ptr); 1203 - for (pass = 0; pass < num_passes; pass++) 1204 - { 1205 - /* Adam7 interlacing may require seven distinct images */ 1206 - for (j = 0; j < height; ++j) 1207 - { 1208 - png_bytep p_out = row_pointer; 1209 - unsigned char *p_in = img->pixels + (j * img->scanline_width); 1210 - for (i = 0; i < width; ++i) 1211 - *p_out++ = *p_in++; 1212 - png_write_row (png_ptr, row_pointer); 1213 - } 1214 - } 1215 - png_write_end (png_ptr, info_ptr); 1216 - free (row_pointer); 1217 - png_destroy_write_struct (&png_ptr, &info_ptr); 1218 - return GGRAPH_OK; 1219 -} 1220 - 1221 -static int 1222 -xgdStripImagePngCtxPalette (gGraphStripImagePtr img, xgdIOCtx * outfile, 1223 - int compression_level) 1224 -{ 1225 -/* preparing to compress a PNG image [palette] (by strip) */ 1226 - int i, bit_depth = 0, interlace_type; 1227 - int width = img->width; 1228 - int height = img->height; 1229 - png_color palette[256]; 1230 - int colors = img->max_palette; 1231 - png_structp png_ptr; 1232 - png_infop info_ptr; 1233 - png_bytep row_pointer = NULL; 1234 - struct png_codec_data *png_codec; 1235 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1236 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 1237 - &xgdPngJmpbufStruct, xgdPngErrorHandler, 1238 - NULL); 1239 -#else 1240 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 1241 -#endif 1242 - if (png_ptr == NULL) 1243 - return GGRAPH_INSUFFICIENT_MEMORY; 1244 - info_ptr = png_create_info_struct (png_ptr); 1245 - if (info_ptr == NULL) 1246 - { 1247 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1248 - return GGRAPH_INSUFFICIENT_MEMORY; 1249 - } 1250 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1251 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1252 - { 1253 - if (row_pointer) 1254 - free (row_pointer); 1255 - png_destroy_write_struct (&png_ptr, &info_ptr); 1256 - return GGRAPH_PNG_CODEC_ERROR; 1257 - } 1258 -#endif 1259 - png_set_write_fn (png_ptr, (void *) outfile, xgdPngWriteData, 1260 - xgdPngFlushData); 1261 - png_set_compression_level (png_ptr, compression_level); 1262 - if (colors <= 2) 1263 - bit_depth = 1; 1264 - else if (colors <= 4) 1265 - bit_depth = 2; 1266 - else if (colors <= 16) 1267 - bit_depth = 4; 1268 - else 1269 - bit_depth = 8; 1270 - interlace_type = PNG_INTERLACE_NONE; 1271 - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, 1272 - PNG_COLOR_TYPE_PALETTE, interlace_type, 1273 - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 1274 - for (i = 0; i < colors; i++) 1275 - { 1276 - palette[i].red = img->palette_red[i]; 1277 - palette[i].green = img->palette_green[i]; 1278 - palette[i].blue = img->palette_blue[i]; 1279 - } 1280 - png_set_PLTE (png_ptr, info_ptr, palette, colors); 1281 - png_write_info (png_ptr, info_ptr); 1282 - png_set_packing (png_ptr); 1283 - if (overflow2 (sizeof (png_bytep), height)) 1284 - return GGRAPH_PNG_CODEC_ERROR; 1285 - row_pointer = malloc (width * 3); 1286 - if (!row_pointer) 1287 - { 1288 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1289 - return GGRAPH_INSUFFICIENT_MEMORY; 1290 - } 1291 - 1292 -/* setting up the PNG codec struct */ 1293 - png_codec = malloc (sizeof (struct png_codec_data)); 1294 - if (!png_codec) 1295 - { 1296 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1297 - free (row_pointer); 1298 - gg_strip_image_destroy (img); 1299 - return GGRAPH_INSUFFICIENT_MEMORY; 1300 - } 1301 - png_codec->is_writer = 1; 1302 - png_codec->row_pointer = row_pointer; 1303 - png_codec->png_ptr = png_ptr; 1304 - png_codec->info_ptr = info_ptr; 1305 - png_codec->palette_allocated = PNG_FALSE; 1306 - png_codec->palette = NULL; 1307 - png_codec->bit_depth = bit_depth; 1308 - png_codec->color_type = PNG_COLOR_TYPE_GRAY; 1309 - png_codec->interlace_type = PNG_INTERLACE_NONE; 1310 - png_codec->quantization_factor = 0; 1311 - png_codec->io_ctx = outfile; 1312 - img->codec_data = png_codec; 1313 - 1314 - return GGRAPH_OK; 1315 -} 1316 - 1317 -static int 1318 -xgdImagePngCtxGrayscale (gGraphImagePtr img, xgdIOCtx * outfile, 1319 - int compression_level, int quantization_factor, 1320 - int interlaced) 1321 -{ 1322 -/* compressing a PNG image [grayscale] */ 1323 - int i, j, bit_depth = 0, interlace_type; 1324 - int width = img->width; 1325 - int height = img->height; 1326 - png_structp png_ptr; 1327 - png_infop info_ptr; 1328 - png_bytep row_pointer = NULL; 1329 - int pass; 1330 - int num_passes; 1331 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1332 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 1333 - &xgdPngJmpbufStruct, xgdPngErrorHandler, 1334 - NULL); 1335 -#else 1336 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 1337 -#endif 1338 - if (png_ptr == NULL) 1339 - return GGRAPH_INSUFFICIENT_MEMORY; 1340 - info_ptr = png_create_info_struct (png_ptr); 1341 - if (info_ptr == NULL) 1342 - { 1343 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1344 - return GGRAPH_INSUFFICIENT_MEMORY; 1345 - } 1346 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1347 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1348 - return GGRAPH_PNG_CODEC_ERROR; 1349 -#endif 1350 - png_set_write_fn (png_ptr, (void *) outfile, xgdPngWriteData, 1351 - xgdPngFlushData); 1352 - png_set_compression_level (png_ptr, compression_level); 1353 - bit_depth = 8; 1354 - if (interlaced) 1355 - interlace_type = PNG_INTERLACE_ADAM7; 1356 - else 1357 - interlace_type = PNG_INTERLACE_NONE; 1358 - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, 1359 - PNG_COLOR_TYPE_GRAY, interlace_type, 1360 - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 1361 - png_write_info (png_ptr, info_ptr); 1362 - png_set_packing (png_ptr); 1363 - if (overflow2 (sizeof (png_bytep), height)) 1364 - return GGRAPH_PNG_CODEC_ERROR; 1365 - row_pointer = malloc (width); 1366 - if (!row_pointer) 1367 - { 1368 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1369 - return GGRAPH_INSUFFICIENT_MEMORY; 1370 - } 1371 - num_passes = png_set_interlace_handling (png_ptr); 1372 - for (pass = 0; pass < num_passes; pass++) 1373 - { 1374 - /* Adam7 interlacing may require seven distinct images */ 1375 - for (j = 0; j < height; ++j) 1376 - { 1377 - png_bytep p_out = row_pointer; 1378 - unsigned char *p_in = img->pixels + (j * img->scanline_width); 1379 - for (i = 0; i < width; ++i) 1380 - { 1381 - int gray = *p_in++; 1382 - if (quantization_factor <= 0) 1383 - ; 1384 - else if (quantization_factor == 1) 1385 - gray |= 0x01; 1386 - else if (quantization_factor == 2) 1387 - gray |= 0x03; 1388 - else if (quantization_factor == 3) 1389 - gray |= 0x07; 1390 - else 1391 - gray |= 0x0f; 1392 - *p_out++ = gray; 1393 - } 1394 - png_write_row (png_ptr, row_pointer); 1395 - } 1396 - } 1397 - png_write_end (png_ptr, info_ptr); 1398 - free (row_pointer); 1399 - png_destroy_write_struct (&png_ptr, &info_ptr); 1400 - return GGRAPH_OK; 1401 -} 1402 - 1403 -static int 1404 -xgdStripImagePngCtxGrayscale (gGraphStripImagePtr img, xgdIOCtx * outfile, 1405 - int compression_level, int quantization_factor) 1406 -{ 1407 -/* preparing to compress a PNG image [grayscale] (by strip) */ 1408 - int bit_depth = 0, interlace_type; 1409 - int width = img->width; 1410 - int height = img->height; 1411 - png_structp png_ptr; 1412 - png_infop info_ptr; 1413 - png_bytep row_pointer = NULL; 1414 - struct png_codec_data *png_codec; 1415 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1416 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 1417 - &xgdPngJmpbufStruct, xgdPngErrorHandler, 1418 - NULL); 1419 -#else 1420 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 1421 -#endif 1422 - if (png_ptr == NULL) 1423 - return GGRAPH_INSUFFICIENT_MEMORY; 1424 - info_ptr = png_create_info_struct (png_ptr); 1425 - if (info_ptr == NULL) 1426 - { 1427 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1428 - return GGRAPH_INSUFFICIENT_MEMORY; 1429 - } 1430 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1431 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1432 - { 1433 - if (row_pointer) 1434 - free (row_pointer); 1435 - png_destroy_write_struct (&png_ptr, &info_ptr); 1436 - return GGRAPH_PNG_CODEC_ERROR; 1437 - } 1438 -#endif 1439 - png_set_write_fn (png_ptr, (void *) outfile, xgdPngWriteData, 1440 - xgdPngFlushData); 1441 - png_set_compression_level (png_ptr, compression_level); 1442 - bit_depth = 8; 1443 - interlace_type = PNG_INTERLACE_NONE; 1444 - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, 1445 - PNG_COLOR_TYPE_GRAY, interlace_type, 1446 - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 1447 - png_write_info (png_ptr, info_ptr); 1448 - png_set_packing (png_ptr); 1449 - if (overflow2 (sizeof (png_bytep), height)) 1450 - return GGRAPH_PNG_CODEC_ERROR; 1451 - row_pointer = malloc (width * 3); 1452 - if (!row_pointer) 1453 - { 1454 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1455 - return GGRAPH_INSUFFICIENT_MEMORY; 1456 - } 1457 - 1458 -/* setting up the PNG codec struct */ 1459 - png_codec = malloc (sizeof (struct png_codec_data)); 1460 - if (!png_codec) 1461 - { 1462 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1463 - free (row_pointer); 1464 - gg_strip_image_destroy (img); 1465 - return GGRAPH_INSUFFICIENT_MEMORY; 1466 - } 1467 - png_codec->is_writer = 1; 1468 - png_codec->row_pointer = row_pointer; 1469 - png_codec->png_ptr = png_ptr; 1470 - png_codec->info_ptr = info_ptr; 1471 - png_codec->palette_allocated = PNG_FALSE; 1472 - png_codec->palette = NULL; 1473 - png_codec->bit_depth = bit_depth; 1474 - png_codec->color_type = PNG_COLOR_TYPE_GRAY; 1475 - png_codec->interlace_type = PNG_INTERLACE_NONE; 1476 - png_codec->quantization_factor = quantization_factor; 1477 - png_codec->io_ctx = outfile; 1478 - img->codec_data = png_codec; 1479 - 1480 - return GGRAPH_OK; 1481 -} 1482 - 1483 -static int 1484 -xgdImagePngCtxRgb (gGraphImagePtr img, xgdIOCtx * outfile, 1485 - int compression_level, int quantization_factor, 1486 - int interlaced) 1487 -{ 1488 -/* compressing a PNG image [RGB] */ 1489 - int i, j, bit_depth = 0, interlace_type; 1490 - int width = img->width; 1491 - int height = img->height; 1492 - png_structp png_ptr; 1493 - png_infop info_ptr; 1494 - png_bytep row_pointer = NULL; 1495 - int pass; 1496 - int num_passes; 1497 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1498 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 1499 - &xgdPngJmpbufStruct, xgdPngErrorHandler, 1500 - NULL); 1501 -#else 1502 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 1503 -#endif 1504 - if (png_ptr == NULL) 1505 - return GGRAPH_INSUFFICIENT_MEMORY; 1506 - info_ptr = png_create_info_struct (png_ptr); 1507 - if (info_ptr == NULL) 1508 - { 1509 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1510 - return GGRAPH_INSUFFICIENT_MEMORY; 1511 - } 1512 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1513 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1514 - { 1515 - if (row_pointer) 1516 - free (row_pointer); 1517 - png_destroy_write_struct (&png_ptr, &info_ptr); 1518 - return GGRAPH_PNG_CODEC_ERROR; 1519 - } 1520 -#endif 1521 - png_set_write_fn (png_ptr, (void *) outfile, xgdPngWriteData, 1522 - xgdPngFlushData); 1523 - png_set_compression_level (png_ptr, compression_level); 1524 - bit_depth = 8; 1525 - if (interlaced) 1526 - interlace_type = PNG_INTERLACE_ADAM7; 1527 - else 1528 - interlace_type = PNG_INTERLACE_NONE; 1529 - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, 1530 - PNG_COLOR_TYPE_RGB, interlace_type, 1531 - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 1532 - png_write_info (png_ptr, info_ptr); 1533 - png_set_packing (png_ptr); 1534 - if (overflow2 (sizeof (png_bytep), height)) 1535 - return GGRAPH_PNG_CODEC_ERROR; 1536 - row_pointer = malloc (width * 3); 1537 - if (!row_pointer) 1538 - { 1539 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1540 - return GGRAPH_INSUFFICIENT_MEMORY; 1541 - } 1542 - num_passes = png_set_interlace_handling (png_ptr); 1543 - for (pass = 0; pass < num_passes; pass++) 1544 - { 1545 - /* Adam7 interlacing may require seven distinct images */ 1546 - for (j = 0; j < height; j++) 1547 - { 1548 - png_bytep p_out = row_pointer; 1549 - unsigned char *p_in = img->pixels + (j * img->scanline_width); 1550 - for (i = 0; i < width; ++i) 1551 - { 1552 - unsigned char r; 1553 - unsigned char g; 1554 - unsigned char b; 1555 - if (img->pixel_format == GG_PIXEL_RGB) 1556 - { 1557 - r = *p_in++; 1558 - g = *p_in++; 1559 - b = *p_in++; 1560 - } 1561 - else if (img->pixel_format == GG_PIXEL_BGR) 1562 - { 1563 - b = *p_in++; 1564 - g = *p_in++; 1565 - r = *p_in++; 1566 - } 1567 - if (quantization_factor <= 0) 1568 - ; 1569 - else if (quantization_factor == 1) 1570 - { 1571 - r |= 0x01; 1572 - g |= 0x01; 1573 - b |= 0x01; 1574 - } 1575 - else if (quantization_factor == 2) 1576 - { 1577 - r |= 0x03; 1578 - g |= 0x03; 1579 - b |= 0x03; 1580 - } 1581 - else if (quantization_factor == 3) 1582 - { 1583 - r |= 0x07; 1584 - g |= 0x07; 1585 - b |= 0x07; 1586 - } 1587 - else 1588 - { 1589 - r |= 0x0f; 1590 - g |= 0x0f; 1591 - b |= 0x0f; 1592 - } 1593 - *p_out++ = r; 1594 - *p_out++ = g; 1595 - *p_out++ = b; 1596 - } 1597 - png_write_row (png_ptr, row_pointer); 1598 - } 1599 - } 1600 - png_write_end (png_ptr, info_ptr); 1601 - free (row_pointer); 1602 - png_destroy_write_struct (&png_ptr, &info_ptr); 1603 - return GGRAPH_OK; 1604 -} 1605 - 1606 -static int 1607 -xgdStripImagePngCtxRgb (gGraphStripImagePtr img, xgdIOCtx * outfile, 1608 - int compression_level, int quantization_factor) 1609 -{ 1610 -/* preparing to compress a PNG image [RGB] (by strip) */ 1611 - int bit_depth = 0, interlace_type; 1612 - int width = img->width; 1613 - int height = img->height; 1614 - png_structp png_ptr; 1615 - png_infop info_ptr; 1616 - png_bytep row_pointer = NULL; 1617 - struct png_codec_data *png_codec; 1618 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1619 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 1620 - &xgdPngJmpbufStruct, xgdPngErrorHandler, 1621 - NULL); 1622 -#else 1623 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 1624 -#endif 1625 - if (png_ptr == NULL) 1626 - return GGRAPH_INSUFFICIENT_MEMORY; 1627 - info_ptr = png_create_info_struct (png_ptr); 1628 - if (info_ptr == NULL) 1629 - { 1630 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1631 - return GGRAPH_INSUFFICIENT_MEMORY; 1632 - } 1633 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1634 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1635 - { 1636 - if (row_pointer) 1637 - free (row_pointer); 1638 - png_destroy_write_struct (&png_ptr, &info_ptr); 1639 - return GGRAPH_PNG_CODEC_ERROR; 1640 - } 1641 -#endif 1642 - png_set_write_fn (png_ptr, (void *) outfile, xgdPngWriteData, 1643 - xgdPngFlushData); 1644 - png_set_compression_level (png_ptr, compression_level); 1645 - bit_depth = 8; 1646 - interlace_type = PNG_INTERLACE_NONE; 1647 - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, 1648 - PNG_COLOR_TYPE_RGB, interlace_type, 1649 - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 1650 - png_write_info (png_ptr, info_ptr); 1651 - png_set_packing (png_ptr); 1652 - if (overflow2 (sizeof (png_bytep), height)) 1653 - return GGRAPH_PNG_CODEC_ERROR; 1654 - row_pointer = malloc (width * 3); 1655 - if (!row_pointer) 1656 - { 1657 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1658 - return GGRAPH_INSUFFICIENT_MEMORY; 1659 - } 1660 - 1661 -/* setting up the PNG codec struct */ 1662 - png_codec = malloc (sizeof (struct png_codec_data)); 1663 - if (!png_codec) 1664 - { 1665 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1666 - free (row_pointer); 1667 - gg_strip_image_destroy (img); 1668 - return GGRAPH_INSUFFICIENT_MEMORY; 1669 - } 1670 - png_codec->is_writer = 1; 1671 - png_codec->row_pointer = row_pointer; 1672 - png_codec->png_ptr = png_ptr; 1673 - png_codec->info_ptr = info_ptr; 1674 - png_codec->palette_allocated = PNG_FALSE; 1675 - png_codec->palette = NULL; 1676 - png_codec->bit_depth = bit_depth; 1677 - png_codec->color_type = PNG_COLOR_TYPE_RGB; 1678 - png_codec->interlace_type = PNG_INTERLACE_NONE; 1679 - png_codec->quantization_factor = quantization_factor; 1680 - png_codec->io_ctx = outfile; 1681 - img->codec_data = png_codec; 1682 - 1683 - return GGRAPH_OK; 1684 -} 1685 - 1686 -static int 1687 -xgdImagePngCtxRgbAlpha (gGraphImagePtr img, xgdIOCtx * outfile, 1688 - int compression_level, int quantization_factor, 1689 - int interlaced) 1690 -{ 1691 -/* compressing a PNG image [RGBA] */ 1692 - int i, j, bit_depth = 0, interlace_type; 1693 - int width = img->width; 1694 - int height = img->height; 1695 - png_structp png_ptr; 1696 - png_infop info_ptr; 1697 - png_bytep row_pointer = NULL; 1698 - int pass; 1699 - int num_passes; 1700 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1701 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 1702 - &xgdPngJmpbufStruct, xgdPngErrorHandler, 1703 - NULL); 1704 -#else 1705 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 1706 -#endif 1707 - if (png_ptr == NULL) 1708 - return GGRAPH_INSUFFICIENT_MEMORY; 1709 - info_ptr = png_create_info_struct (png_ptr); 1710 - if (info_ptr == NULL) 1711 - { 1712 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1713 - return GGRAPH_INSUFFICIENT_MEMORY; 1714 - } 1715 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1716 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1717 - { 1718 - if (row_pointer) 1719 - free (row_pointer); 1720 - png_destroy_write_struct (&png_ptr, &info_ptr); 1721 - return GGRAPH_PNG_CODEC_ERROR; 1722 - } 1723 -#endif 1724 - png_set_write_fn (png_ptr, (void *) outfile, xgdPngWriteData, 1725 - xgdPngFlushData); 1726 - png_set_compression_level (png_ptr, compression_level); 1727 - bit_depth = 8; 1728 - if (interlaced) 1729 - interlace_type = PNG_INTERLACE_ADAM7; 1730 - else 1731 - interlace_type = PNG_INTERLACE_NONE; 1732 - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, 1733 - PNG_COLOR_TYPE_RGB_ALPHA, interlace_type, 1734 - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 1735 - png_write_info (png_ptr, info_ptr); 1736 - png_set_packing (png_ptr); 1737 - if (overflow2 (sizeof (png_bytep), height)) 1738 - return GGRAPH_PNG_CODEC_ERROR; 1739 - row_pointer = malloc (width * 4); 1740 - if (!row_pointer) 1741 - { 1742 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1743 - return GGRAPH_INSUFFICIENT_MEMORY; 1744 - } 1745 - num_passes = png_set_interlace_handling (png_ptr); 1746 - for (pass = 0; pass < num_passes; pass++) 1747 - { 1748 - /* Adam7 interlacing may require seven distinct images */ 1749 - for (j = 0; j < height; ++j) 1750 - { 1751 - png_bytep p_out = row_pointer; 1752 - unsigned char *p_in = img->pixels + (j * img->scanline_width); 1753 - for (i = 0; i < width; ++i) 1754 - { 1755 - unsigned char r; 1756 - unsigned char g; 1757 - unsigned char b; 1758 - unsigned char alpha; 1759 - if (img->pixel_format == GG_PIXEL_RGBA) 1760 - { 1761 - r = *p_in++; 1762 - g = *p_in++; 1763 - b = *p_in++; 1764 - alpha = *p_in++; 1765 - } 1766 - else if (img->pixel_format == GG_PIXEL_ARGB) 1767 - { 1768 - alpha = *p_in++; 1769 - r = *p_in++; 1770 - g = *p_in++; 1771 - b = *p_in++; 1772 - } 1773 - else if (img->pixel_format == GG_PIXEL_BGRA) 1774 - { 1775 - b = *p_in++; 1776 - g = *p_in++; 1777 - r = *p_in++; 1778 - alpha = *p_in++; 1779 - } 1780 - else if (img->pixel_format == GG_PIXEL_RGB) 1781 - { 1782 - r = *p_in++; 1783 - g = *p_in++; 1784 - b = *p_in++; 1785 - if (r == img->transparent_red 1786 - && g == img->transparent_green 1787 - && b == img->transparent_blue) 1788 - alpha = 0; 1789 - else 1790 - alpha = 255; 1791 - } 1792 - else if (img->pixel_format == GG_PIXEL_BGR) 1793 - { 1794 - b = *p_in++; 1795 - g = *p_in++; 1796 - r = *p_in++; 1797 - if (r == img->transparent_red 1798 - && g == img->transparent_green 1799 - && b == img->transparent_blue) 1800 - alpha = 0; 1801 - else 1802 - alpha = 255; 1803 - } 1804 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 1805 - { 1806 - r = *p_in++; 1807 - g = r; 1808 - b = r; 1809 - if (r == img->transparent_red 1810 - && g == img->transparent_green 1811 - && b == img->transparent_blue) 1812 - alpha = 0; 1813 - else 1814 - alpha = 255; 1815 - } 1816 - else if (img->pixel_format == GG_PIXEL_PALETTE) 1817 - { 1818 - int idx = *p_in++; 1819 - r = img->palette_red[idx]; 1820 - g = img->palette_green[idx]; 1821 - b = img->palette_blue[idx]; 1822 - if (r == img->transparent_red 1823 - && g == img->transparent_green 1824 - && b == img->transparent_blue) 1825 - alpha = 0; 1826 - else 1827 - alpha = 255; 1828 - } 1829 - if (quantization_factor <= 0) 1830 - ; 1831 - else if (quantization_factor == 1) 1832 - { 1833 - r |= 0x01; 1834 - g |= 0x01; 1835 - b |= 0x01; 1836 - } 1837 - else if (quantization_factor == 2) 1838 - { 1839 - r |= 0x03; 1840 - g |= 0x03; 1841 - b |= 0x03; 1842 - } 1843 - else if (quantization_factor == 3) 1844 - { 1845 - r |= 0x07; 1846 - g |= 0x07; 1847 - b |= 0x07; 1848 - } 1849 - else 1850 - { 1851 - r |= 0x0f; 1852 - g |= 0x0f; 1853 - b |= 0x0f; 1854 - } 1855 - *p_out++ = r; 1856 - *p_out++ = g; 1857 - *p_out++ = b; 1858 - *p_out++ = alpha; 1859 - } 1860 - png_write_row (png_ptr, row_pointer); 1861 - } 1862 - } 1863 - png_write_end (png_ptr, info_ptr); 1864 - free (row_pointer); 1865 - png_destroy_write_struct (&png_ptr, &info_ptr); 1866 - return GGRAPH_OK; 1867 -} 1868 - 1869 -static int 1870 -xgdStripImagePngCtxRgbAlpha (gGraphStripImagePtr img, xgdIOCtx * outfile, 1871 - int compression_level, int quantization_factor) 1872 -{ 1873 -/* preparing to compress a PNG image [RGBA] (by strip) */ 1874 - int bit_depth = 0, interlace_type; 1875 - int width = img->width; 1876 - int height = img->height; 1877 - png_structp png_ptr; 1878 - png_infop info_ptr; 1879 - png_bytep row_pointer = NULL; 1880 - struct png_codec_data *png_codec; 1881 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1882 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 1883 - &xgdPngJmpbufStruct, xgdPngErrorHandler, 1884 - NULL); 1885 -#else 1886 - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 1887 -#endif 1888 - if (png_ptr == NULL) 1889 - return GGRAPH_INSUFFICIENT_MEMORY; 1890 - info_ptr = png_create_info_struct (png_ptr); 1891 - if (info_ptr == NULL) 1892 - { 1893 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1894 - return GGRAPH_INSUFFICIENT_MEMORY; 1895 - } 1896 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1897 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1898 - { 1899 - if (row_pointer) 1900 - free (row_pointer); 1901 - png_destroy_write_struct (&png_ptr, &info_ptr); 1902 - return GGRAPH_PNG_CODEC_ERROR; 1903 - } 1904 -#endif 1905 - png_set_write_fn (png_ptr, (void *) outfile, xgdPngWriteData, 1906 - xgdPngFlushData); 1907 - png_set_compression_level (png_ptr, compression_level); 1908 - bit_depth = 8; 1909 - interlace_type = PNG_INTERLACE_NONE; 1910 - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, 1911 - PNG_COLOR_TYPE_RGB_ALPHA, interlace_type, 1912 - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 1913 - png_write_info (png_ptr, info_ptr); 1914 - png_set_packing (png_ptr); 1915 - if (overflow2 (sizeof (png_bytep), height)) 1916 - return GGRAPH_PNG_CODEC_ERROR; 1917 - row_pointer = malloc (width * 4); 1918 - if (!row_pointer) 1919 - { 1920 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1921 - return GGRAPH_INSUFFICIENT_MEMORY; 1922 - } 1923 - 1924 -/* setting up the PNG codec struct */ 1925 - png_codec = malloc (sizeof (struct png_codec_data)); 1926 - if (!png_codec) 1927 - { 1928 - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 1929 - free (row_pointer); 1930 - gg_strip_image_destroy (img); 1931 - return GGRAPH_INSUFFICIENT_MEMORY; 1932 - } 1933 - png_codec->is_writer = 1; 1934 - png_codec->row_pointer = row_pointer; 1935 - png_codec->png_ptr = png_ptr; 1936 - png_codec->info_ptr = info_ptr; 1937 - png_codec->palette_allocated = PNG_FALSE; 1938 - png_codec->palette = NULL; 1939 - png_codec->bit_depth = bit_depth; 1940 - png_codec->color_type = PNG_COLOR_TYPE_RGB_ALPHA; 1941 - png_codec->interlace_type = PNG_INTERLACE_NONE; 1942 - png_codec->quantization_factor = quantization_factor; 1943 - png_codec->io_ctx = outfile; 1944 - img->codec_data = png_codec; 1945 - 1946 - return GGRAPH_OK; 1947 -} 1948 - 1949 -static int 1950 -xgdStripImagePngCtx (gGraphStripImagePtr img) 1951 -{ 1952 -/* compressing a PNG image [by strip] */ 1953 - int i, j; 1954 - int width = img->width; 1955 - int height = img->height; 1956 - struct png_codec_data *png_codec = 1957 - (struct png_codec_data *) (img->codec_data); 1958 - png_structp png_ptr = png_codec->png_ptr; 1959 - png_bytep row_pointer = png_codec->row_pointer; 1960 - int quantization_factor = png_codec->quantization_factor; 1961 - 1962 - if (img->next_row >= img->height) 1963 - { 1964 - /* EOF condition */ 1965 - fprintf (stderr, "png-wrapper error: attempting to write beyond EOF"); 1966 - return GGRAPH_PNG_CODEC_ERROR; 1967 - } 1968 - height = img->current_available_rows; 1969 - 1970 -#ifndef PNG_SETJMP_NOT_SUPPORTED 1971 - if (setjmp (xgdPngJmpbufStruct.jmpbuf)) 1972 - return GGRAPH_PNG_CODEC_ERROR; 1973 -#endif 1974 - for (j = 0; j < height; ++j) 1975 - { 1976 - png_bytep p_out = row_pointer; 1977 - unsigned char *p_in = img->pixels + (j * img->scanline_width); 1978 - for (i = 0; i < width; ++i) 1979 - { 1980 - unsigned char r; 1981 - unsigned char g; 1982 - unsigned char b; 1983 - unsigned char alpha; 1984 - if (img->pixel_format == GG_PIXEL_PALETTE 1985 - || img->pixel_format == GG_PIXEL_GRAYSCALE) 1986 - { 1987 - /* simply copying pixels */ 1988 - *p_out++ = *p_in++; 1989 - continue; 1990 - } 1991 - 1992 - /* expected to be RGB or RGB-Alpha */ 1993 - if (img->pixel_format == GG_PIXEL_RGBA) 1994 - { 1995 - r = *p_in++; 1996 - g = *p_in++; 1997 - b = *p_in++; 1998 - alpha = *p_in++; 1999 - } 2000 - else 2001 - { 2002 - r = *p_in++; 2003 - g = *p_in++; 2004 - b = *p_in++; 2005 - } 2006 - 2007 - /* applying color quantization (if required) */ 2008 - if (quantization_factor <= 0) 2009 - ; 2010 - else if (quantization_factor == 1) 2011 - { 2012 - r |= 0x01; 2013 - g |= 0x01; 2014 - b |= 0x01; 2015 - } 2016 - else if (quantization_factor == 2) 2017 - { 2018 - r |= 0x03; 2019 - g |= 0x03; 2020 - b |= 0x03; 2021 - } 2022 - else if (quantization_factor == 3) 2023 - { 2024 - r |= 0x07; 2025 - g |= 0x07; 2026 - b |= 0x07; 2027 - } 2028 - else 2029 - { 2030 - r |= 0x0f; 2031 - g |= 0x0f; 2032 - b |= 0x0f; 2033 - } 2034 - 2035 - /* outputting the pixel */ 2036 - if (img->pixel_format == GG_PIXEL_RGBA) 2037 - { 2038 - *p_out++ = r; 2039 - *p_out++ = g; 2040 - *p_out++ = b; 2041 - *p_out++ = alpha; 2042 - } 2043 - else 2044 - { 2045 - *p_out++ = r; 2046 - *p_out++ = g; 2047 - *p_out++ = b; 2048 - } 2049 - } 2050 - png_write_row (png_ptr, row_pointer); 2051 - } 2052 - img->next_row += height; 2053 - return GGRAPH_OK; 2054 -} 2055 - 2056 -static int 2057 -image_to_png_palette (const gGraphImagePtr img, void **mem_buf, 2058 - int *mem_buf_size, FILE * file, int dest_type, 2059 - int compression_level, int interlaced) 2060 -{ 2061 -/* compressing an image as PNG PALETTE */ 2062 - int ret; 2063 - void *rv; 2064 - int size; 2065 - xgdIOCtx *out; 2066 - 2067 -/* checkings args for validity */ 2068 - if (dest_type == GG_TARGET_IS_FILE) 2069 - { 2070 - if (!file) 2071 - return GGRAPH_ERROR; 2072 - } 2073 - else 2074 - { 2075 - if (!mem_buf || !mem_buf_size) 2076 - return GGRAPH_ERROR; 2077 - *mem_buf = NULL; 2078 - *mem_buf_size = 0; 2079 - } 2080 - 2081 - if (dest_type == GG_TARGET_IS_FILE) 2082 - out = xgdNewDynamicCtx (0, file, dest_type); 2083 - else 2084 - out = xgdNewDynamicCtx (2048, NULL, dest_type); 2085 - if (compression_level < 0 || compression_level > 9) 2086 - compression_level = 4; 2087 - ret = xgdImagePngCtxPalette (img, out, compression_level, interlaced); 2088 - if (dest_type == GG_TARGET_IS_FILE) 2089 - { 2090 - out->xgd_free (out); 2091 - return ret; 2092 - } 2093 - 2094 - if (ret == GGRAPH_OK) 2095 - rv = xgdDPExtractData (out, &size); 2096 - out->xgd_free (out); 2097 - *mem_buf = rv; 2098 - *mem_buf_size = size; 2099 - return ret; 2100 -} 2101 - 2102 -static int 2103 -image_prepare_to_png_palette_by_strip (const gGraphStripImagePtr img, 2104 - FILE * file, int compression_level) 2105 -{ 2106 -/* preparing to compress an image as PNG PALETTE [by strip] */ 2107 - xgdIOCtx *out; 2108 - 2109 -/* checkings args for validity */ 2110 - if (!file) 2111 - return GGRAPH_ERROR; 2112 - 2113 - out = xgdNewDynamicCtx (0, file, GG_TARGET_IS_FILE); 2114 - if (compression_level < 0 || compression_level > 9) 2115 - compression_level = 4; 2116 - return xgdStripImagePngCtxPalette (img, out, compression_level); 2117 -} 2118 - 2119 -static int 2120 -image_to_png_grayscale (const gGraphImagePtr img, void **mem_buf, 2121 - int *mem_buf_size, FILE * file, int dest_type, 2122 - int compression_level, int quantization_factor, 2123 - int interlaced) 2124 -{ 2125 -/* compressing an image as PNG GRAYSCALE */ 2126 - int ret; 2127 - void *rv; 2128 - int size; 2129 - xgdIOCtx *out; 2130 - 2131 -/* checkings args for validity */ 2132 - if (dest_type == GG_TARGET_IS_FILE) 2133 - { 2134 - if (!file) 2135 - return GGRAPH_ERROR; 2136 - } 2137 - else 2138 - { 2139 - if (!mem_buf || !mem_buf_size) 2140 - return GGRAPH_ERROR; 2141 - *mem_buf = NULL; 2142 - *mem_buf_size = 0; 2143 - } 2144 - 2145 - if (dest_type == GG_TARGET_IS_FILE) 2146 - out = xgdNewDynamicCtx (0, file, dest_type); 2147 - else 2148 - out = xgdNewDynamicCtx (2048, NULL, dest_type); 2149 - if (compression_level < 0 || compression_level > 9) 2150 - compression_level = 4; 2151 - ret = 2152 - xgdImagePngCtxGrayscale (img, out, compression_level, 2153 - quantization_factor, interlaced); 2154 - if (dest_type == GG_TARGET_IS_FILE) 2155 - { 2156 - out->xgd_free (out); 2157 - return ret; 2158 - } 2159 - 2160 - if (ret == GGRAPH_OK) 2161 - rv = xgdDPExtractData (out, &size); 2162 - out->xgd_free (out); 2163 - *mem_buf = rv; 2164 - *mem_buf_size = size; 2165 - return ret; 2166 -} 2167 - 2168 -static int 2169 -image_prepare_to_png_grayscale_by_strip (const gGraphStripImagePtr img, 2170 - FILE * file, int compression_level, 2171 - int quantization_factor) 2172 -{ 2173 -/* preparing to compress an image as PNG GRAYSCALE [by strip] */ 2174 - xgdIOCtx *out; 2175 - 2176 -/* checkings args for validity */ 2177 - if (!file) 2178 - return GGRAPH_ERROR; 2179 - 2180 - out = xgdNewDynamicCtx (0, file, GG_TARGET_IS_FILE); 2181 - if (compression_level < 0 || compression_level > 9) 2182 - compression_level = 4; 2183 - return xgdStripImagePngCtxGrayscale (img, out, compression_level, 2184 - quantization_factor); 2185 -} 2186 - 2187 -static int 2188 -image_to_png_rgb (const gGraphImagePtr img, void **mem_buf, int *mem_buf_size, 2189 - FILE * file, int dest_type, int compression_level, 2190 - int quantization_factor, int interlaced) 2191 -{ 2192 -/* compressing an image as PNG RGB */ 2193 - int ret; 2194 - void *rv; 2195 - int size; 2196 - xgdIOCtx *out; 2197 - 2198 -/* checkings args for validity */ 2199 - if (dest_type == GG_TARGET_IS_FILE) 2200 - { 2201 - if (!file) 2202 - return GGRAPH_ERROR; 2203 - } 2204 - else 2205 - { 2206 - if (!mem_buf || !mem_buf_size) 2207 - return GGRAPH_ERROR; 2208 - *mem_buf = NULL; 2209 - *mem_buf_size = 0; 2210 - } 2211 - 2212 - if (dest_type == GG_TARGET_IS_FILE) 2213 - out = xgdNewDynamicCtx (0, file, dest_type); 2214 - else 2215 - out = xgdNewDynamicCtx (2048, NULL, dest_type); 2216 - if (compression_level < 0 || compression_level > 9) 2217 - compression_level = 4; 2218 - ret = 2219 - xgdImagePngCtxRgb (img, out, compression_level, quantization_factor, 2220 - interlaced); 2221 - if (dest_type == GG_TARGET_IS_FILE) 2222 - { 2223 - out->xgd_free (out); 2224 - return ret; 2225 - } 2226 - 2227 - if (ret == GGRAPH_OK) 2228 - rv = xgdDPExtractData (out, &size); 2229 - out->xgd_free (out); 2230 - *mem_buf = rv; 2231 - *mem_buf_size = size; 2232 - return ret; 2233 -} 2234 - 2235 -static int 2236 -image_prepare_to_png_rgb_by_strip (const gGraphStripImagePtr img, FILE * file, 2237 - int compression_level, 2238 - int quantization_factor) 2239 -{ 2240 -/* preparing to compress an image as PNG RGB [by strip] */ 2241 - xgdIOCtx *out; 2242 - 2243 -/* checkings args for validity */ 2244 - if (!file) 2245 - return GGRAPH_ERROR; 2246 - 2247 - out = xgdNewDynamicCtx (0, file, GG_TARGET_IS_FILE); 2248 - if (compression_level < 0 || compression_level > 9) 2249 - compression_level = 4; 2250 - return xgdStripImagePngCtxRgb (img, out, compression_level, 2251 - quantization_factor); 2252 -} 2253 - 2254 -static int 2255 -image_to_png_rgba (const gGraphImagePtr img, void **mem_buf, int *mem_buf_size, 2256 - FILE * file, int dest_type, int compression_level, 2257 - int quantization_factor, int interlaced) 2258 -{ 2259 -/* compressing an image as PNG RGBA */ 2260 - int ret; 2261 - void *rv; 2262 - int size; 2263 - xgdIOCtx *out; 2264 - 2265 -/* checkings args for validity */ 2266 - if (dest_type == GG_TARGET_IS_FILE) 2267 - { 2268 - if (!file) 2269 - return GGRAPH_ERROR; 2270 - } 2271 - else 2272 - { 2273 - if (!mem_buf || !mem_buf_size) 2274 - return GGRAPH_ERROR; 2275 - *mem_buf = NULL; 2276 - *mem_buf_size = 0; 2277 - } 2278 - 2279 - if (dest_type == GG_TARGET_IS_FILE) 2280 - out = xgdNewDynamicCtx (0, file, dest_type); 2281 - else 2282 - out = xgdNewDynamicCtx (2048, NULL, dest_type); 2283 - if (compression_level < 0 || compression_level > 9) 2284 - compression_level = 4; 2285 - ret = 2286 - xgdImagePngCtxRgbAlpha (img, out, compression_level, 2287 - quantization_factor, interlaced); 2288 - if (dest_type == GG_TARGET_IS_FILE) 2289 - { 2290 - out->xgd_free (out); 2291 - return ret; 2292 - } 2293 - 2294 - if (ret == GGRAPH_OK) 2295 - rv = xgdDPExtractData (out, &size); 2296 - out->xgd_free (out); 2297 - *mem_buf = rv; 2298 - *mem_buf_size = size; 2299 - return ret; 2300 -} 2301 - 2302 -static int 2303 -image_prepare_to_png_rgba_by_strip (const gGraphStripImagePtr img, FILE * file, 2304 - int compression_level, 2305 - int quantization_factor) 2306 -{ 2307 -/* preparing to compress an image as PNG RGBA [by strip] */ 2308 - xgdIOCtx *out; 2309 - 2310 -/* checkings args for validity */ 2311 - if (!file) 2312 - return GGRAPH_ERROR; 2313 - 2314 - out = xgdNewDynamicCtx (0, file, GG_TARGET_IS_FILE); 2315 - if (compression_level < 0 || compression_level > 9) 2316 - compression_level = 4; 2317 - return xgdStripImagePngCtxRgbAlpha (img, out, compression_level, 2318 - quantization_factor); 2319 -} 2320 - 2321 -GGRAPH_PRIVATE int 2322 -gg_image_to_png (const gGraphImagePtr img, void **mem_buf, int *mem_buf_size, 2323 - FILE * file, int dest_type, int compression_level, 2324 - int quantization_factor, int interlaced, int is_transparent) 2325 -{ 2326 -/* dispatching PNG compression */ 2327 - if (img->pixel_format == GG_PIXEL_RGBA || img->pixel_format == GG_PIXEL_ARGB 2328 - || img->pixel_format == GG_PIXEL_BGRA || is_transparent) 2329 - return image_to_png_rgba (img, mem_buf, mem_buf_size, file, dest_type, 2330 - compression_level, quantization_factor, 2331 - interlaced); 2332 - if (img->pixel_format == GG_PIXEL_PALETTE) 2333 - return image_to_png_palette (img, mem_buf, mem_buf_size, file, 2334 - dest_type, compression_level, interlaced); 2335 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2336 - return image_to_png_grayscale (img, mem_buf, mem_buf_size, file, 2337 - dest_type, compression_level, 2338 - quantization_factor, interlaced); 2339 - return image_to_png_rgb (img, mem_buf, mem_buf_size, file, dest_type, 2340 - compression_level, quantization_factor, 2341 - interlaced); 2342 -} 2343 - 2344 -GGRAPH_PRIVATE int 2345 -gg_image_prepare_to_png_by_strip (const gGraphStripImagePtr img, 2346 - FILE * file, int compression_level, 2347 - int quantization_factor) 2348 -{ 2349 -/* dispatching PNG compression [by strip] */ 2350 - if (img->pixel_format == GG_PIXEL_PALETTE) 2351 - return image_prepare_to_png_palette_by_strip (img, file, 2352 - compression_level); 2353 - if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2354 - return image_prepare_to_png_grayscale_by_strip (img, file, 2355 - compression_level, 2356 - quantization_factor); 2357 - if (img->pixel_format == GG_PIXEL_RGBA || img->pixel_format == GG_PIXEL_ARGB 2358 - || img->pixel_format == GG_PIXEL_BGRA) 2359 - return image_prepare_to_png_rgba_by_strip (img, file, compression_level, 2360 - quantization_factor); 2361 - return image_prepare_to_png_rgb_by_strip (img, file, compression_level, 2362 - quantization_factor); 2363 -} 2364 - 2365 -GGRAPH_PRIVATE int 2366 -gg_image_write_to_png_by_strip (const gGraphStripImagePtr img, int *progress) 2367 -{ 2368 -/* scanline(s) PNG compression [by strip] */ 2369 - int ret = xgdStripImagePngCtx (img); 2370 - if (ret == GGRAPH_OK && progress != NULL) 2371 - *progress = 2372 - (int) (((double) (img->next_row + 1) * 100.0) / 2373 - (double) (img->height)); 2374 - return ret; 2375 -} 2376 - 2377 -GGRAPH_PRIVATE int 2378 -gg_image_from_png (int size, const void *data, int source_type, 2379 - gGraphImagePtr * image_handle, int scale) 2380 -{ 2381 -/* uncompressing a PNG */ 2382 - int errcode = GGRAPH_OK; 2383 - gGraphImagePtr img; 2384 - xgdIOCtx *in = 2385 - xgdNewDynamicCtxEx (size, data, XGD_CTX_DONT_FREE, source_type); 2386 - img = xgdImageCreateFromPngCtx (in, &errcode, scale); 2387 - in->xgd_free (in); 2388 - *image_handle = img; 2389 - return errcode; 2390 -} 2391 - 2392 -GGRAPH_PRIVATE int 2393 -gg_image_infos_from_png (int size, const void *data, int source_type, 2394 - gGraphImageInfosPtr * infos_handle) 2395 -{ 2396 -/* image infos from PNG */ 2397 - int errcode = GGRAPH_OK; 2398 - gGraphImageInfosPtr infos; 2399 - xgdIOCtx *in = 2400 - xgdNewDynamicCtxEx (size, data, XGD_CTX_DONT_FREE, source_type); 2401 - infos = xgdImageInfosFromPngCtx (in, &errcode); 2402 - in->xgd_free (in); 2403 - *infos_handle = infos; 2404 - return errcode; 2405 -} 2406 - 2407 -GGRAPH_PRIVATE int 2408 -gg_image_strip_prepare_from_png (FILE * file, 2409 - gGraphStripImagePtr * image_handle) 2410 -{ 2411 -/* preparing to uncompress a PNG [by strips] */ 2412 - int errcode = GGRAPH_OK; 2413 - gGraphStripImagePtr img; 2414 - xgdIOCtx *in = 2415 - xgdNewDynamicCtxEx (0, file, XGD_CTX_DONT_FREE, GG_TARGET_IS_FILE); 2416 - img = xgdStripImageCreateFromPngCtx (in, &errcode, file); 2417 - *image_handle = img; 2418 - return errcode; 2419 -} 2420 - 2421 -GGRAPH_PRIVATE int 2422 -gg_image_strip_read_from_png (gGraphStripImagePtr img, int *progress) 2423 -{ 2424 -/* uncompressing a PNG [by strips] */ 2425 - int ret = xgdStripImageReadFromPngCtx (img); 2426 - if (ret == GGRAPH_OK && progress != NULL) 2427 - *progress = 2428 - (int) (((double) (img->next_row + 1) * 100.0) / 2429 - (double) (img->height)); 2430 - return ret; 2431 -}
Deleted src/gaiagraphics_quantize.c.
1 -/* 2 -/ gaiagraphics_quantize.c 3 -/ 4 -/ quantization methods 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -/* 28 -/ 29 -/ DISCLAIMER: 30 -/ all the following code merely is an 'ad hoc' adaption 31 -/ of the following LGPLed code: 32 -/ 33 -////////////////////////////////////////////////////////////////////////////// 34 -/ 35 - median.c: median cut - reducing a high color bitmap to certain number of colors 36 - 37 - Copyright (C) 2001, 2002 Martin Weber 38 - 39 - This library is free software; you can redistribute it and/or 40 - modify it under the terms of the GNU Lesser General Public License 41 - as published by the Free Software Foundation; either version 2.1 of 42 - the License, or (at your option) any later version. 43 - 44 - This library is distributed in the hope that it will be useful, but 45 - WITHOUT ANY WARRANTY; without even the implied warranty of 46 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 47 - Lesser General Public License for more details. 48 - 49 - You should have received a copy of the GNU Lesser General Public 50 - License along with this library; if not, write to the Free Software 51 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 52 - USA. 53 -*/ 54 - 55 -#include <stdlib.h> 56 -#include <stdio.h> 57 - 58 -#include "gaiagraphics.h" 59 -#include "gaiagraphics_internals.h" 60 - 61 -#define encode_color(r, g, b) (((r) << 16) + ((g) << 8) + (b)) 62 -#define color_get_red(c) (((c) & 0xFF0000) >> 16) 63 -#define color_get_green(c) (((c) & 0x00FF00) >> 8) 64 -#define color_get_blue(c) ((c) & 0x0000FF) 65 - 66 -#define MAXNUMCOLORS 256 67 - 68 -/* scale RGB distances by *2,*3,*1 */ 69 -#define R_SCALE <<1 70 -#define G_SCALE *3 71 -#define B_SCALE 72 - 73 -#define BITS_IN_SAMPLE 8 74 - 75 -#define R_SHIFT (BITS_IN_SAMPLE - PRECISION_R) 76 -#define G_SHIFT (BITS_IN_SAMPLE - PRECISION_G) 77 -#define B_SHIFT (BITS_IN_SAMPLE - PRECISION_B) 78 - 79 -#define PRECISION_R 7 80 -#define PRECISION_G 7 81 -#define PRECISION_B 7 82 - 83 -#define HIST_R_ELEMS (1<<PRECISION_R) 84 -#define HIST_G_ELEMS (1<<PRECISION_G) 85 -#define HIST_B_ELEMS (1<<PRECISION_B) 86 - 87 -#define MR HIST_G_ELEMS*HIST_B_ELEMS 88 -#define MG HIST_B_ELEMS 89 - 90 -typedef unsigned long ColorFreq; 91 -typedef ColorFreq *Histogram; 92 - 93 -typedef struct 94 -{ 95 - int desired_number_of_colors; /* Number of colors we will allow */ 96 - int actual_number_of_colors; /* Number of colors actually needed */ 97 - int cmap[256]; /* colormap created by quantization */ 98 - int max_cmap; 99 - ColorFreq freq[256]; 100 - Histogram histogram; /* holds the histogram */ 101 -} QuantizeObj; 102 - 103 -typedef struct 104 -{ 105 - /* The bounds of the box (inclusive); expressed as histogram indexes */ 106 - int Rmin, Rmax; 107 - int Gmin, Gmax; 108 - int Bmin, Bmax; 109 - /* The volume (actually 2-norm) of the box */ 110 - int volume; 111 - /* The number of nonzero histogram cells within this box */ 112 - long colorcount; 113 -} box, *boxptr; 114 - 115 -static void 116 -zero_histogram_rgb (Histogram histogram) 117 -{ 118 - int r, g, b; 119 - for (r = 0; r < HIST_R_ELEMS; r++) 120 - for (g = 0; g < HIST_G_ELEMS; g++) 121 - for (b = 0; b < HIST_B_ELEMS; b++) 122 - histogram[r * MR + g * MG + b] = 0; 123 -} 124 - 125 -static void 126 -generate_histogram_rgb (Histogram histogram, gGraphImagePtr img) 127 -{ 128 - int x; 129 - int y; 130 - int red; 131 - int green; 132 - int blue; 133 - unsigned char *p_in; 134 - ColorFreq *col; 135 - 136 - zero_histogram_rgb (histogram); 137 - 138 - for (y = 0; y < img->height; y++) 139 - { 140 - p_in = img->pixels + (y * img->scanline_width); 141 - for (x = 0; x < img->width; x++) 142 - { 143 - /* retrieving a pixel */ 144 - if (img->pixel_format == GG_PIXEL_RGB) 145 - { 146 - red = *p_in++; 147 - green = *p_in++; 148 - blue = *p_in++; 149 - } 150 - else if (img->pixel_format == GG_PIXEL_RGBA) 151 - { 152 - red = *p_in++; 153 - green = *p_in++; 154 - blue = *p_in++; 155 - p_in++; /* skipping alpha */ 156 - } 157 - else if (img->pixel_format == GG_PIXEL_ARGB) 158 - { 159 - p_in++; /* skipping alpha */ 160 - blue = *p_in++; 161 - green = *p_in++; 162 - red = *p_in++; 163 - } 164 - else if (img->pixel_format == GG_PIXEL_BGR) 165 - { 166 - blue = *p_in++; 167 - green = *p_in++; 168 - red = *p_in++; 169 - } 170 - else if (img->pixel_format == GG_PIXEL_BGRA) 171 - { 172 - blue = *p_in++; 173 - green = *p_in++; 174 - red = *p_in++; 175 - p_in++; /* skipping alpha */ 176 - } 177 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 178 - { 179 - red = *p_in++; 180 - green = red; 181 - blue = red; 182 - } 183 - else if (img->pixel_format == GG_PIXEL_PALETTE) 184 - { 185 - int index = *p_in++; 186 - red = img->palette_red[index]; 187 - green = img->palette_green[index]; 188 - blue = img->palette_blue[index]; 189 - } 190 - col = &histogram[(red >> R_SHIFT) * MR 191 - + (green >> G_SHIFT) * MG + (blue >> B_SHIFT)]; 192 - (*col)++; 193 - } 194 - } 195 -} 196 - 197 - 198 -static boxptr 199 -find_biggest_volume (boxptr boxlist, int numboxes) 200 -/* Find the splittable box with the largest (scaled) volume */ 201 -/* Returns 0 if no splittable boxes remain */ 202 -{ 203 - boxptr boxp; 204 - int i; 205 - int maxv = 0; 206 - boxptr which = 0; 207 - 208 - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) 209 - { 210 - if (boxp->volume > maxv) 211 - { 212 - which = boxp; 213 - maxv = boxp->volume; 214 - } 215 - } 216 - 217 - return which; 218 -} 219 - 220 - 221 -static void 222 -update_box_rgb (Histogram histogram, boxptr boxp) 223 -/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ 224 -/* and recompute its volume and population */ 225 -{ 226 - ColorFreq *histp; 227 - int R, G, B; 228 - int Rmin, Rmax, Gmin, Gmax, Bmin, Bmax; 229 - int dist0, dist1, dist2; 230 - long ccount; 231 - 232 - Rmin = boxp->Rmin; 233 - Rmax = boxp->Rmax; 234 - Gmin = boxp->Gmin; 235 - Gmax = boxp->Gmax; 236 - Bmin = boxp->Bmin; 237 - Bmax = boxp->Bmax; 238 - 239 - if (Rmax > Rmin) 240 - for (R = Rmin; R <= Rmax; R++) 241 - for (G = Gmin; G <= Gmax; G++) 242 - { 243 - histp = histogram + R * MR + G * MG + Bmin; 244 - for (B = Bmin; B <= Bmax; B++) 245 - if (*histp++ != 0) 246 - { 247 - boxp->Rmin = Rmin = R; 248 - goto have_Rmin; 249 - } 250 - } 251 - have_Rmin: 252 - if (Rmax > Rmin) 253 - for (R = Rmax; R >= Rmin; R--) 254 - for (G = Gmin; G <= Gmax; G++) 255 - { 256 - histp = histogram + R * MR + G * MG + Bmin; 257 - for (B = Bmin; B <= Bmax; B++) 258 - if (*histp++ != 0) 259 - { 260 - boxp->Rmax = Rmax = R; 261 - goto have_Rmax; 262 - } 263 - } 264 - have_Rmax: 265 - if (Gmax > Gmin) 266 - for (G = Gmin; G <= Gmax; G++) 267 - for (R = Rmin; R <= Rmax; R++) 268 - { 269 - histp = histogram + R * MR + G * MG + Bmin; 270 - for (B = Bmin; B <= Bmax; B++) 271 - if (*histp++ != 0) 272 - { 273 - boxp->Gmin = Gmin = G; 274 - goto have_Gmin; 275 - } 276 - } 277 - have_Gmin: 278 - if (Gmax > Gmin) 279 - for (G = Gmax; G >= Gmin; G--) 280 - for (R = Rmin; R <= Rmax; R++) 281 - { 282 - histp = histogram + R * MR + G * MG + Bmin; 283 - for (B = Bmin; B <= Bmax; B++) 284 - if (*histp++ != 0) 285 - { 286 - boxp->Gmax = Gmax = G; 287 - goto have_Gmax; 288 - } 289 - } 290 - have_Gmax: 291 - if (Bmax > Bmin) 292 - for (B = Bmin; B <= Bmax; B++) 293 - for (R = Rmin; R <= Rmax; R++) 294 - { 295 - histp = histogram + R * MR + Gmin * MG + B; 296 - for (G = Gmin; G <= Gmax; G++, histp += MG) 297 - if (*histp != 0) 298 - { 299 - boxp->Bmin = Bmin = B; 300 - goto have_Bmin; 301 - } 302 - } 303 - have_Bmin: 304 - if (Bmax > Bmin) 305 - for (B = Bmax; B >= Bmin; B--) 306 - for (R = Rmin; R <= Rmax; R++) 307 - { 308 - histp = histogram + R * MR + Gmin * MG + B; 309 - for (G = Gmin; G <= Gmax; G++, histp += MG) 310 - if (*histp != 0) 311 - { 312 - boxp->Bmax = Bmax = B; 313 - goto have_Bmax; 314 - } 315 - } 316 - have_Bmax: 317 - 318 - /* Update box volume. 319 - * We use 2-norm rather than real volume here; this biases the method 320 - * against making long narrow boxes, and it has the side benefit that 321 - * a box is splittable iff norm > 0. 322 - * Since the differences are expressed in histogram-cell units, 323 - * we have to shift back to JSAMPLE units to get consistent distances; 324 - * after which, we scale according to the selected distance scale factors. 325 - */ 326 - dist0 = Rmax - Rmin; 327 - dist1 = Gmax - Gmin; 328 - dist2 = Bmax - Bmin; 329 - boxp->volume = dist0 * dist0 + dist1 * dist1 + dist2 * dist2; 330 - 331 - /* Now scan remaining volume of box and compute population */ 332 - ccount = 0; 333 - for (R = Rmin; R <= Rmax; R++) 334 - for (G = Gmin; G <= Gmax; G++) 335 - { 336 - histp = histogram + R * MR + G * MG + Bmin; 337 - for (B = Bmin; B <= Bmax; B++, histp++) 338 - if (*histp != 0) 339 - { 340 - ccount++; 341 - } 342 - } 343 - 344 - boxp->colorcount = ccount; 345 -} 346 - 347 - 348 -static int 349 -median_cut_rgb (Histogram histogram, boxptr boxlist, int numboxes, 350 - int desired_colors) 351 -/* Repeatedly select and split the largest box until we have enough boxes */ 352 -{ 353 - int n, lb; 354 - int R, G, B, cmax; 355 - boxptr b1, b2; 356 - 357 - while (numboxes < desired_colors) 358 - { 359 - /* Select box to split. 360 - * Current algorithm: by population for first half, then by volume. 361 - */ 362 - b1 = find_biggest_volume (boxlist, numboxes); 363 - 364 - if (b1 == 0) /* no splittable boxes left! */ 365 - break; 366 - b2 = boxlist + numboxes; /* where new box will go */ 367 - /* Copy the color bounds to the new box. */ 368 - b2->Rmax = b1->Rmax; 369 - b2->Gmax = b1->Gmax; 370 - b2->Bmax = b1->Bmax; 371 - b2->Rmin = b1->Rmin; 372 - b2->Gmin = b1->Gmin; 373 - b2->Bmin = b1->Bmin; 374 - /* Choose which axis to split the box on. 375 - * Current algorithm: longest scaled axis. 376 - * See notes in update_box about scaling distances. 377 - */ 378 - R = b1->Rmax - b1->Rmin; 379 - G = b1->Gmax - b1->Gmin; 380 - B = b1->Bmax - b1->Bmin; 381 - /* We want to break any ties in favor of green, then red, blue last. 382 - */ 383 - cmax = G; 384 - n = 1; 385 - if (R > cmax) 386 - { 387 - cmax = R; 388 - n = 0; 389 - } 390 - if (B > cmax) 391 - { 392 - n = 2; 393 - } 394 - /* Choose split point along selected axis, and update box bounds. 395 - * Current algorithm: split at halfway point. 396 - * (Since the box has been shrunk to minimum volume, 397 - * any split will produce two nonempty subboxes.) 398 - * Note that lb value is max for lower box, so must be < old max. 399 - */ 400 - switch (n) 401 - { 402 - case 0: 403 - lb = (b1->Rmax + b1->Rmin) / 2; 404 - b1->Rmax = lb; 405 - b2->Rmin = lb + 1; 406 - break; 407 - case 1: 408 - lb = (b1->Gmax + b1->Gmin) / 2; 409 - b1->Gmax = lb; 410 - b2->Gmin = lb + 1; 411 - break; 412 - case 2: 413 - lb = (b1->Bmax + b1->Bmin) / 2; 414 - b1->Bmax = lb; 415 - b2->Bmin = lb + 1; 416 - break; 417 - } 418 - /* Update stats for boxes */ 419 - update_box_rgb (histogram, b1); 420 - update_box_rgb (histogram, b2); 421 - numboxes++; 422 - } 423 - return numboxes; 424 -} 425 - 426 - 427 -static void 428 -compute_color_rgb (QuantizeObj * quantobj, Histogram histogram, 429 - boxptr boxp, int icolor) 430 -/* Compute representative color for a box, put it in colormap[icolor] */ 431 -{ 432 - /* Current algorithm: mean weighted by pixels (not colors) */ 433 - /* Note it is important to get the rounding correct! */ 434 - ColorFreq *histp; 435 - int R, G, B; 436 - int Rmin, Rmax; 437 - int Gmin, Gmax; 438 - int Bmin, Bmax; 439 - unsigned long count; 440 - unsigned long total = 0; 441 - unsigned long Rtotal = 0; 442 - unsigned long Gtotal = 0; 443 - unsigned long Btotal = 0; 444 - int pixel; 445 - int r; 446 - int g; 447 - int b; 448 - 449 - Rmin = boxp->Rmin; 450 - Rmax = boxp->Rmax; 451 - Gmin = boxp->Gmin; 452 - Gmax = boxp->Gmax; 453 - Bmin = boxp->Bmin; 454 - Bmax = boxp->Bmax; 455 - 456 - for (R = Rmin; R <= Rmax; R++) 457 - for (G = Gmin; G <= Gmax; G++) 458 - { 459 - histp = histogram + R * MR + G * MG + Bmin; 460 - for (B = Bmin; B <= Bmax; B++) 461 - { 462 - if ((count = *histp++) != 0) 463 - { 464 - total += count; 465 - Rtotal += 466 - ((R << R_SHIFT) + ((1 << R_SHIFT) >> 1)) * count; 467 - Gtotal += 468 - ((G << G_SHIFT) + ((1 << G_SHIFT) >> 1)) * count; 469 - Btotal += 470 - ((B << B_SHIFT) + ((1 << B_SHIFT) >> 1)) * count; 471 - } 472 - } 473 - } 474 - 475 - r = (unsigned char) ((Rtotal + (total >> 1)) / total); 476 - g = (unsigned char) ((Gtotal + (total >> 1)) / total); 477 - b = (unsigned char) ((Btotal + (total >> 1)) / total); 478 - pixel = encode_color (r, g, b); 479 - quantobj->cmap[icolor] = pixel; 480 - if ((icolor + 1) > quantobj->max_cmap) 481 - quantobj->max_cmap = (icolor + 1); 482 - quantobj->freq[icolor] = total; 483 -} 484 - 485 - 486 -static void 487 -select_colors_rgb (QuantizeObj * quantobj, Histogram histogram) 488 -/* Master routine for color selection */ 489 -{ 490 - boxptr boxlist; 491 - int numboxes; 492 - int desired = quantobj->desired_number_of_colors; 493 - int i; 494 - 495 - /* Allocate workspace for box list */ 496 - boxlist = malloc (desired * sizeof (box)); 497 - 498 - /* Initialize one box containing whole space */ 499 - numboxes = 1; 500 - boxlist[0].Rmin = 0; 501 - boxlist[0].Rmax = (1 << PRECISION_R) - 1; 502 - boxlist[0].Gmin = 0; 503 - boxlist[0].Gmax = (1 << PRECISION_G) - 1; 504 - boxlist[0].Bmin = 0; 505 - boxlist[0].Bmax = (1 << PRECISION_B) - 1; 506 - /* Shrink it to actually-used volume and set its statistics */ 507 - update_box_rgb (histogram, boxlist); 508 - /* Perform median-cut to produce final box list */ 509 - numboxes = median_cut_rgb (histogram, boxlist, numboxes, desired); 510 - quantobj->actual_number_of_colors = numboxes; 511 - /* Compute the representative color for each box, fill colormap */ 512 - for (i = 0; i < numboxes; i++) 513 - compute_color_rgb (quantobj, histogram, boxlist + i, i); 514 - free (boxlist); 515 -} 516 - 517 - 518 -/* 519 - * These routines are concerned with the time-critical task of mapping input 520 - * colors to the nearest color in the selected colormap. 521 - * 522 - * We re-use the histogram space as an "inverse color map", essentially a 523 - * cache for the results of nearest-color searches. All colors within a 524 - * histogram cell will be mapped to the same colormap entry, namely the one 525 - * closest to the cell's center. This may not be quite the closest entry to 526 - * the actual input color, but it's almost as good. A zero in the cache 527 - * indicates we haven't found the nearest color for that cell yet; the array 528 - * is cleared to zeroes before starting the mapping pass. When we find the 529 - * nearest color for a cell, its colormap index plus one is recorded in the 530 - * cache for future use. The pass2 scanning routines call fill_inverse_cmap 531 - * when they need to use an unfilled entry in the cache. 532 - * 533 - * Our method of efficiently finding nearest colors is based on the "locally 534 - * sorted search" idea described by Heckbert and on the incremental distance 535 - * calculation described by Spencer W. Thomas in chapter III.1 of Graphics 536 - * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that 537 - * the distances from a given colormap entry to each cell of the histogram can 538 - * be computed quickly using an incremental method: the differences between 539 - * distances to adjacent cells themselves differ by a constant. This allows a 540 - * fairly fast implementation of the "brute force" approach of computing the 541 - * distance from every colormap entry to every histogram cell. Unfortunately, 542 - * it needs a work array to hold the best-distance-so-far for each histogram 543 - * cell (because the inner loop has to be over cells, not colormap entries). 544 - * The work array elements have to be ints, so the work array would need 545 - * 256Kb at our recommended precision. This is not feasible in DOS machines. 546 - 547 -[ 256*1024/4 = 65,536 ] 548 - 549 - * To get around these problems, we apply Thomas' method to compute the 550 - * nearest colors for only the cells within a small subbox of the histogram. 551 - * The work array need be only as big as the subbox, so the memory usage 552 - * problem is solved. Furthermore, we need not fill subboxes that are never 553 - * referenced in pass2; many images use only part of the color gamut, so a 554 - * fair amount of work is saved. An additional advantage of this 555 - * approach is that we can apply Heckbert's locality criterion to quickly 556 - * eliminate colormap entries that are far away from the subbox; typically 557 - * three-fourths of the colormap entries are rejected by Heckbert's criterion, 558 - * and we need not compute their distances to individual cells in the subbox. 559 - * The speed of this approach is heavily influenced by the subbox size: too 560 - * small means too much overhead, too big loses because Heckbert's criterion 561 - * can't eliminate as many colormap entries. Empirically the best subbox 562 - * size seems to be about 1/512th of the histogram (1/8th in each direction). 563 - * 564 - * Thomas' article also describes a refined method which is asymptotically 565 - * faster than the brute-force method, but it is also far more complex and 566 - * cannot efficiently be applied to small subboxes. It is therefore not 567 - * useful for programs intended to be portable to DOS machines. On machines 568 - * with plenty of memory, filling the whole histogram in one shot with Thomas' 569 - * refined method might be faster than the present code --- but then again, 570 - * it might not be any faster, and it's certainly more complicated. 571 - */ 572 - 573 -/* log2(histogram cells in update box) for each axis; this can be adjusted */ 574 -#define BOX_R_LOG (PRECISION_R-3) 575 -#define BOX_G_LOG (PRECISION_G-3) 576 -#define BOX_B_LOG (PRECISION_B-3) 577 - 578 -#define BOX_R_ELEMS (1<<BOX_R_LOG) /* # of hist cells in update box */ 579 -#define BOX_G_ELEMS (1<<BOX_G_LOG) 580 -#define BOX_B_ELEMS (1<<BOX_B_LOG) 581 - 582 -#define BOX_R_SHIFT (R_SHIFT + BOX_R_LOG) 583 -#define BOX_G_SHIFT (G_SHIFT + BOX_G_LOG) 584 -#define BOX_B_SHIFT (B_SHIFT + BOX_B_LOG) 585 - 586 -/* 587 - * The next three routines implement inverse colormap filling. They could 588 - * all be folded into one big routine, but splitting them up this way saves 589 - * some stack space (the mindist[] and bestdist[] arrays need not coexist) 590 - * and may allow some compilers to produce better code by registerizing more 591 - * inner-loop variables. 592 - */ 593 - 594 -static int 595 -find_nearby_colors (QuantizeObj * quantobj, int minR, int minG, 596 - int minB, int *colorlist) 597 -/* Locate the colormap entries close enough to an update box to be candidates 598 - * for the nearest entry to some cell(s) in the update box. The update box 599 - * is specified by the center coordinates of its first cell. The number of 600 - * candidate colormap entries is returned, and their colormap indexes are 601 - * placed in colorlist[]. 602 - * This routine uses Heckbert's "locally sorted search" criterion to select 603 - * the colors that need further consideration. 604 - */ 605 -{ 606 - int numcolors = quantobj->actual_number_of_colors; 607 - int maxR, maxG, maxB; 608 - int centerR, centerG, centerB; 609 - int i, x, ncolors; 610 - int minmaxdist, min_dist = 0, max_dist, tdist; 611 - int mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ 612 - int pixel; 613 - int r; 614 - int g; 615 - int b; 616 - 617 - /* Compute TRUE coordinates of update box's upper corner and center. 618 - * Actually we compute the coordinates of the center of the upper-corner 619 - * histogram cell, which are the upper bounds of the volume we care about. 620 - * Note that since ">>" rounds down, the "center" values may be closer to 621 - * min than to max; hence comparisons to them must be "<=", not "<". 622 - */ 623 - maxR = minR + ((1 << BOX_R_SHIFT) - (1 << R_SHIFT)); 624 - centerR = (minR + maxR) >> 1; 625 - maxG = minG + ((1 << BOX_G_SHIFT) - (1 << G_SHIFT)); 626 - centerG = (minG + maxG) >> 1; 627 - maxB = minB + ((1 << BOX_B_SHIFT) - (1 << B_SHIFT)); 628 - centerB = (minB + maxB) >> 1; 629 - 630 - /* For each color in colormap, find: 631 - * 1. its minimum squared-distance to any point in the update box 632 - * (zero if color is within update box); 633 - * 2. its maximum squared-distance to any point in the update box. 634 - * Both of these can be found by considering only the corners of the box. 635 - * We save the minimum distance for each color in mindist[]; 636 - * only the smallest maximum distance is of interest. 637 - */ 638 - minmaxdist = 0x7FFFFFFFL; 639 - 640 - for (i = 0; i < numcolors; i++) 641 - { 642 - /* We compute the squared-R-distance term, then add in the other two. */ 643 - pixel = quantobj->cmap[i]; 644 - r = color_get_red (pixel); 645 - g = color_get_green (pixel); 646 - b = color_get_blue (pixel); 647 - x = r; 648 - if (x < minR) 649 - { 650 - tdist = (x - minR) R_SCALE; 651 - min_dist = tdist * tdist; 652 - tdist = (x - maxR) R_SCALE; 653 - max_dist = tdist * tdist; 654 - } 655 - else if (x > maxR) 656 - { 657 - tdist = (x - maxR) R_SCALE; 658 - min_dist = tdist * tdist; 659 - tdist = (x - minR) R_SCALE; 660 - max_dist = tdist * tdist; 661 - } 662 - else 663 - { 664 - /* within cell range so no contribution to min_dist */ 665 - min_dist = 0; 666 - if (x <= centerR) 667 - { 668 - tdist = (x - maxR) R_SCALE; 669 - max_dist = tdist * tdist; 670 - } 671 - else 672 - { 673 - tdist = (x - minR) R_SCALE; 674 - max_dist = tdist * tdist; 675 - } 676 - } 677 - 678 - x = g; 679 - if (x < minG) 680 - { 681 - tdist = (x - minG) G_SCALE; 682 - min_dist += tdist * tdist; 683 - tdist = (x - maxG) G_SCALE; 684 - max_dist += tdist * tdist; 685 - } 686 - else if (x > maxG) 687 - { 688 - tdist = (x - maxG) G_SCALE; 689 - min_dist += tdist * tdist; 690 - tdist = (x - minG) G_SCALE; 691 - max_dist += tdist * tdist; 692 - } 693 - else 694 - { 695 - /* within cell range so no contribution to min_dist */ 696 - if (x <= centerG) 697 - { 698 - tdist = (x - maxG) G_SCALE; 699 - max_dist += tdist * tdist; 700 - } 701 - else 702 - { 703 - tdist = (x - minG) G_SCALE; 704 - max_dist += tdist * tdist; 705 - } 706 - } 707 - 708 - x = b; 709 - if (x < minB) 710 - { 711 - tdist = (x - minB) B_SCALE; 712 - min_dist += tdist * tdist; 713 - tdist = (x - maxB) B_SCALE; 714 - max_dist += tdist * tdist; 715 - } 716 - else if (x > maxB) 717 - { 718 - tdist = (x - maxB) B_SCALE; 719 - min_dist += tdist * tdist; 720 - tdist = (x - minB) B_SCALE; 721 - max_dist += tdist * tdist; 722 - } 723 - else 724 - { 725 - /* within cell range so no contribution to min_dist */ 726 - if (x <= centerB) 727 - { 728 - tdist = (x - maxB) B_SCALE; 729 - max_dist += tdist * tdist; 730 - } 731 - else 732 - { 733 - tdist = (x - minB) B_SCALE; 734 - max_dist += tdist * tdist; 735 - } 736 - } 737 - 738 - mindist[i] = min_dist; /* save away the results */ 739 - if (max_dist < minmaxdist) 740 - minmaxdist = max_dist; 741 - } 742 - 743 - /* Now we know that no cell in the update box is more than minmaxdist 744 - * away from some colormap entry. Therefore, only colors that are 745 - * within minmaxdist of some part of the box need be considered. 746 - */ 747 - ncolors = 0; 748 - for (i = 0; i < numcolors; i++) 749 - { 750 - if (mindist[i] <= minmaxdist) 751 - colorlist[ncolors++] = i; 752 - } 753 - return ncolors; 754 -} 755 - 756 - 757 -static void 758 -find_best_colors (QuantizeObj * quantobj, int minR, int minG, 759 - int minB, int numcolors, int *colorlist, int *bestcolor) 760 -/* Find the closest colormap entry for each cell in the update box, 761 - given the list of candidate colors prepared by find_nearby_colors. 762 - Return the indexes of the closest entries in the bestcolor[] array. 763 - This routine uses Thomas' incremental distance calculation method to 764 - find the distance from a colormap entry to successive cells in the box. 765 - */ 766 -{ 767 - int iR, iG, iB; 768 - int i, icolor; 769 - int *bptr; /* pointer into bestdist[] array */ 770 - int *cptr; /* pointer into bestcolor[] array */ 771 - int dist0, dist1; /* initial distance values */ 772 - int dist2; /* current distance in inner loop */ 773 - int xx0, xx1; /* distance increments */ 774 - int xx2; 775 - int inR, inG, inB; /* initial values for increments */ 776 - int pixel; 777 - int r; 778 - int g; 779 - int b; 780 - 781 - /* This array holds the distance to the nearest-so-far color for each cell */ 782 - int bestdist[BOX_R_ELEMS * BOX_G_ELEMS * BOX_B_ELEMS]; 783 - 784 - /* Initialize best-distance for each cell of the update box */ 785 - bptr = bestdist; 786 - for (i = BOX_R_ELEMS * BOX_G_ELEMS * BOX_B_ELEMS - 1; i >= 0; i--) 787 - *bptr++ = 0x7FFFFFFFL; 788 - 789 - /* For each color selected by find_nearby_colors, 790 - * compute its distance to the center of each cell in the box. 791 - * If that's less than best-so-far, update best distance and color number. 792 - */ 793 - 794 - /* Nominal steps between cell centers ("x" in Thomas article) */ 795 -#define STEP_R ((1 << R_SHIFT) R_SCALE) 796 -#define STEP_G ((1 << G_SHIFT) G_SCALE) 797 -#define STEP_B ((1 << B_SHIFT) B_SCALE) 798 - 799 - for (i = 0; i < numcolors; i++) 800 - { 801 - icolor = colorlist[i]; 802 - /* Compute (square of) distance from minR/G/B to this color */ 803 - pixel = quantobj->cmap[icolor]; 804 - r = color_get_red (pixel); 805 - g = color_get_green (pixel); 806 - b = color_get_blue (pixel); 807 - inR = (minR - r) R_SCALE; 808 - dist0 = inR * inR; 809 - inG = (minG - g) G_SCALE; 810 - dist0 += inG * inG; 811 - inB = (minB - b) B_SCALE; 812 - dist0 += inB * inB; 813 - /* Form the initial difference increments */ 814 - inR = inR * (2 * STEP_R) + STEP_R * STEP_R; 815 - inG = inG * (2 * STEP_G) + STEP_G * STEP_G; 816 - inB = inB * (2 * STEP_B) + STEP_B * STEP_B; 817 - /* Now loop over all cells in box, updating distance per Thomas method */ 818 - bptr = bestdist; 819 - cptr = bestcolor; 820 - xx0 = inR; 821 - for (iR = BOX_R_ELEMS - 1; iR >= 0; iR--) 822 - { 823 - dist1 = dist0; 824 - xx1 = inG; 825 - for (iG = BOX_G_ELEMS - 1; iG >= 0; iG--) 826 - { 827 - dist2 = dist1; 828 - xx2 = inB; 829 - for (iB = BOX_B_ELEMS - 1; iB >= 0; iB--) 830 - { 831 - if (dist2 < *bptr) 832 - { 833 - *bptr = dist2; 834 - *cptr = icolor; 835 - } 836 - dist2 += xx2; 837 - xx2 += 2 * STEP_B * STEP_B; 838 - bptr++; 839 - cptr++; 840 - } 841 - dist1 += xx1; 842 - xx1 += 2 * STEP_G * STEP_G; 843 - } 844 - dist0 += xx0; 845 - xx0 += 2 * STEP_R * STEP_R; 846 - } 847 - } 848 -} 849 - 850 -static void 851 -fill_inverse_cmap_rgb (QuantizeObj * quantobj, Histogram histogram, 852 - int R, int G, int B) 853 -/* Fill the inverse-colormap entries in the update box that contains 854 - histogram cell R/G/B. (Only that one cell MUST be filled, but 855 - we can fill as many others as we wish.) */ 856 -{ 857 - int minR, minG, minB; /* lower left corner of update box */ 858 - int iR, iG, iB; 859 - int *cptr; /* pointer into bestcolor[] array */ 860 - ColorFreq *cachep; /* pointer into main cache array */ 861 - /* This array lists the candidate colormap indexes. */ 862 - int colorlist[MAXNUMCOLORS]; 863 - int numcolors; /* number of candidate colors */ 864 - /* This array holds the actually closest colormap index for each cell. */ 865 - int bestcolor[BOX_R_ELEMS * BOX_G_ELEMS * BOX_B_ELEMS]; 866 - 867 - /* Convert cell coordinates to update box ID */ 868 - R >>= BOX_R_LOG; 869 - G >>= BOX_G_LOG; 870 - B >>= BOX_B_LOG; 871 - 872 - /* Compute TRUE coordinates of update box's origin corner. 873 - * Actually we compute the coordinates of the center of the corner 874 - * histogram cell, which are the lower bounds of the volume we care about. 875 - */ 876 - minR = (R << BOX_R_SHIFT) + ((1 << R_SHIFT) >> 1); 877 - minG = (G << BOX_G_SHIFT) + ((1 << G_SHIFT) >> 1); 878 - minB = (B << BOX_B_SHIFT) + ((1 << B_SHIFT) >> 1); 879 - 880 - /* Determine which colormap entries are close enough to be candidates 881 - * for the nearest entry to some cell in the update box. 882 - */ 883 - numcolors = find_nearby_colors (quantobj, minR, minG, minB, colorlist); 884 - 885 - /* Determine the actually nearest colors. */ 886 - find_best_colors (quantobj, minR, minG, minB, numcolors, colorlist, 887 - bestcolor); 888 - 889 - /* Save the best color numbers (plus 1) in the main cache array */ 890 - R <<= BOX_R_LOG; /* convert ID back to base cell indexes */ 891 - G <<= BOX_G_LOG; 892 - B <<= BOX_B_LOG; 893 - cptr = bestcolor; 894 - for (iR = 0; iR < BOX_R_ELEMS; iR++) 895 - { 896 - for (iG = 0; iG < BOX_G_ELEMS; iG++) 897 - { 898 - cachep = &histogram[(R + iR) * MR + (G + iG) * MG + B]; 899 - for (iB = 0; iB < BOX_B_ELEMS; iB++) 900 - { 901 - *cachep++ = (*cptr++) + 1; 902 - } 903 - } 904 - } 905 -} 906 - 907 -/* This is pass 1 */ 908 -static void 909 -median_cut_pass1_rgb (QuantizeObj * quantobj, gGraphImagePtr image) 910 -{ 911 - generate_histogram_rgb (quantobj->histogram, image); 912 - select_colors_rgb (quantobj, quantobj->histogram); 913 -} 914 - 915 - 916 -/* Map some rows of pixels to the output colormapped representation. */ 917 -static void 918 -median_cut_pass2_rgb (QuantizeObj * quantobj, gGraphImagePtr img, 919 - void *palette_pixels) 920 - /* This version performs no dithering */ 921 -{ 922 - Histogram histogram = quantobj->histogram; 923 - ColorFreq *cachep; 924 - int R, G, B; 925 - int origR, origG, origB; 926 - int row, col; 927 - int width = img->width; 928 - int height = img->height; 929 - unsigned char red; 930 - unsigned char green; 931 - unsigned char blue; 932 - unsigned char *p_in; 933 - unsigned char *p_out; 934 - 935 - zero_histogram_rgb (histogram); 936 - 937 - for (row = 0; row < height; row++) 938 - { 939 - p_in = img->pixels + (row * img->scanline_width); 940 - p_out = palette_pixels; 941 - p_out += (row * width); 942 - for (col = 0; col < width; col++) 943 - { 944 - /* get pixel value and index into the cache */ 945 - if (img->pixel_format == GG_PIXEL_RGB) 946 - { 947 - red = *p_in++; 948 - green = *p_in++; 949 - blue = *p_in++; 950 - } 951 - else if (img->pixel_format == GG_PIXEL_RGBA) 952 - { 953 - red = *p_in++; 954 - green = *p_in++; 955 - blue = *p_in++; 956 - p_in++; /* skipping alpha */ 957 - } 958 - else if (img->pixel_format == GG_PIXEL_ARGB) 959 - { 960 - p_in++; /* skipping alpha */ 961 - red = *p_in++; 962 - green = *p_in++; 963 - blue = *p_in++; 964 - } 965 - else if (img->pixel_format == GG_PIXEL_BGR) 966 - { 967 - blue = *p_in++; 968 - green = *p_in++; 969 - red = *p_in++; 970 - } 971 - else if (img->pixel_format == GG_PIXEL_BGRA) 972 - { 973 - blue = *p_in++; 974 - green = *p_in++; 975 - red = *p_in++; 976 - p_in++; /* skipping alpha */ 977 - } 978 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 979 - { 980 - red = *p_in++; 981 - green = red; 982 - blue = red; 983 - } 984 - else if (img->pixel_format == GG_PIXEL_PALETTE) 985 - { 986 - int index = *p_in++; 987 - red = img->palette_red[index]; 988 - green = img->palette_green[index]; 989 - blue = img->palette_blue[index]; 990 - } 991 - origR = red; 992 - origG = green; 993 - origB = blue; 994 - 995 - /* get pixel value and index into the cache */ 996 - R = origR >> R_SHIFT; 997 - G = origG >> G_SHIFT; 998 - B = origB >> B_SHIFT; 999 - cachep = &histogram[R * MR + G * MG + B]; 1000 - /* If we have not seen this color before, find nearest 1001 - colormap entry and update the cache */ 1002 - if (*cachep == 0) 1003 - { 1004 - fill_inverse_cmap_rgb (quantobj, histogram, R, G, B); 1005 - } 1006 - /* Now emit the colormap index for this cell */ 1007 - *p_out++ = *cachep - 1; 1008 - } 1009 - } 1010 -} 1011 - 1012 -static QuantizeObj * 1013 -initialize_median_cut (int num_colors) 1014 -{ 1015 - QuantizeObj *quantobj; 1016 - 1017 - /* Initialize the data structures */ 1018 - quantobj = malloc (sizeof (QuantizeObj)); 1019 - if (!quantobj) 1020 - return NULL; 1021 - 1022 - quantobj->histogram = malloc (sizeof (ColorFreq) * 1023 - HIST_R_ELEMS * HIST_G_ELEMS * HIST_B_ELEMS); 1024 - if (quantobj->histogram == NULL) 1025 - { 1026 - free (quantobj); 1027 - return NULL; 1028 - } 1029 - quantobj->desired_number_of_colors = num_colors; 1030 - quantobj->max_cmap = 0; 1031 - 1032 - return quantobj; 1033 -} 1034 - 1035 -static void 1036 -quantize_object_free (QuantizeObj * quantobj) 1037 -{ 1038 - free (quantobj->histogram); 1039 - free (quantobj); 1040 -} 1041 - 1042 -GGRAPH_PRIVATE int 1043 -gg_image_resample_as_palette (const gGraphImagePtr img, int num_colors) 1044 -{ 1045 -/* applies quantization to the current image, so to get 256/16/4 colors */ 1046 - QuantizeObj *quantobj; 1047 - void *palette_pixels; 1048 - int i; 1049 - int safe_num_colors; 1050 - 1051 - if (num_colors > 16) 1052 - safe_num_colors = 256; /* 8 bits_per_sample */ 1053 - else if (num_colors > 4) 1054 - safe_num_colors = 16; /* 4 bits per sample */ 1055 - else 1056 - safe_num_colors = 4; /* 2 bits per sample */ 1057 - 1058 - if (img->pixel_format == GG_PIXEL_GRAYSCALE && safe_num_colors == 256) 1059 - { 1060 - /* useless operation: there are already 256 colors */ 1061 - return GGRAPH_OK; 1062 - } 1063 - if (img->pixel_format == GG_PIXEL_PALETTE 1064 - && img->max_palette <= safe_num_colors) 1065 - { 1066 - /* useless operation */ 1067 - return GGRAPH_OK; 1068 - } 1069 - 1070 - palette_pixels = malloc (img->width * img->height); 1071 - if (!palette_pixels) 1072 - return GGRAPH_INSUFFICIENT_MEMORY; 1073 - 1074 - quantobj = initialize_median_cut (safe_num_colors); 1075 - if (!quantobj) 1076 - return GGRAPH_INSUFFICIENT_MEMORY; 1077 - 1078 - median_cut_pass1_rgb (quantobj, img); 1079 - median_cut_pass2_rgb (quantobj, img, palette_pixels); 1080 - 1081 -/* setting up the palette */ 1082 - for (i = 0; i < quantobj->max_cmap; i++) 1083 - { 1084 - img->palette_red[i] = color_get_red (quantobj->cmap[i]); 1085 - img->palette_green[i] = color_get_green (quantobj->cmap[i]); 1086 - img->palette_blue[i] = color_get_blue (quantobj->cmap[i]); 1087 - img->max_palette = i + 1; 1088 - } 1089 - 1090 - quantize_object_free (quantobj); 1091 - 1092 - free (img->pixels); 1093 - img->pixels = palette_pixels; 1094 - img->pixel_format = GG_PIXEL_PALETTE; 1095 - img->scanline_width = img->width; 1096 - img->pixel_size = 1; 1097 - return GGRAPH_OK; 1098 -}
Deleted src/gaiagraphics_svg.c.
1 -/* 2 -/ gaiagraphics_svg.c 3 -/ 4 -/ SVG renderering 5 -/ 6 -/ version 1.0, 2013 February 10 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2013 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdlib.h> 28 -#include <stdio.h> 29 -#include <string.h> 30 -#include <math.h> 31 -#include <float.h> 32 - 33 -#include "gaiagraphics.h" 34 -#include "gaiagraphics_internals.h" 35 - 36 -#define GG_SVG_PI 3.141592653589793 37 - 38 -struct gg_svg_parent_ref 39 -{ 40 -/* a parent reference (inheritance chain) */ 41 - struct gg_svg_group *parent; 42 - struct gg_svg_parent_ref *next; 43 -}; 44 - 45 -struct gg_svg_parents 46 -{ 47 -/* inheritance chain */ 48 - struct gg_svg_parent_ref *first; 49 - struct gg_svg_parent_ref *last; 50 -}; 51 - 52 -static void 53 -gg_svg_free_parents (struct gg_svg_parents *chain) 54 -{ 55 -/* freeing an inheritance chain */ 56 - struct gg_svg_parent_ref *pp; 57 - struct gg_svg_parent_ref *ppn; 58 - pp = chain->first; 59 - while (pp) 60 - { 61 - ppn = pp->next; 62 - free (pp); 63 - pp = ppn; 64 - } 65 -} 66 - 67 -static void 68 -gg_svg_add_parent (struct gg_svg_parents *chain, struct gg_svg_group *parent) 69 -{ 70 -/* adding an inheritance item into the chain */ 71 - struct gg_svg_parent_ref *p = malloc (sizeof (struct gg_svg_parent_ref)); 72 - p->parent = parent; 73 - p->next = chain->first; 74 -/* updating a reverse-ordered linked list */ 75 - if (chain->last == NULL) 76 - chain->last = p; 77 - chain->first = p; 78 -} 79 - 80 -static void 81 -gg_svg_gradient_transformation (cairo_pattern_t * pattern, 82 - struct gg_svg_transform *trans) 83 -{ 84 -/* applying a single transformation */ 85 - double angle; 86 - double tangent; 87 - struct gg_svg_matrix *mtrx; 88 - struct gg_svg_translate *translate; 89 - struct gg_svg_scale *scale; 90 - struct gg_svg_rotate *rotate; 91 - struct gg_svg_skew *skew; 92 - cairo_matrix_t matrix; 93 - cairo_matrix_t matrix_in; 94 - 95 - if (trans->data == NULL) 96 - return; 97 - switch (trans->type) 98 - { 99 - case GG_SVG_MATRIX: 100 - mtrx = trans->data; 101 - cairo_pattern_get_matrix (pattern, &matrix); 102 - matrix_in.xx = mtrx->a; 103 - matrix_in.yx = mtrx->b; 104 - matrix_in.xy = mtrx->c; 105 - matrix_in.yy = mtrx->d; 106 - matrix_in.x0 = mtrx->e; 107 - matrix_in.y0 = mtrx->f; 108 - cairo_matrix_multiply (&matrix, &matrix, &matrix_in); 109 - cairo_matrix_invert (&matrix); 110 - cairo_pattern_set_matrix (pattern, &matrix); 111 - break; 112 - case GG_SVG_TRANSLATE: 113 - translate = trans->data; 114 - cairo_pattern_get_matrix (pattern, &matrix); 115 - cairo_matrix_translate (&matrix, translate->tx, translate->ty); 116 - cairo_matrix_invert (&matrix); 117 - cairo_pattern_set_matrix (pattern, &matrix); 118 - break; 119 - case GG_SVG_SCALE: 120 - scale = trans->data; 121 - cairo_pattern_get_matrix (pattern, &matrix); 122 - cairo_matrix_scale (&matrix, scale->sx, scale->sy); 123 - cairo_matrix_invert (&matrix); 124 - cairo_pattern_set_matrix (pattern, &matrix); 125 - break; 126 - case GG_SVG_ROTATE: 127 - rotate = trans->data; 128 - cairo_pattern_get_matrix (pattern, &matrix); 129 - angle = rotate->angle * (GG_SVG_PI / 180.0); 130 - cairo_matrix_translate (&matrix, rotate->cx, rotate->cy); 131 - cairo_matrix_rotate (&matrix, angle); 132 - cairo_matrix_translate (&matrix, -1.0 * rotate->cx, 133 - -1.0 * rotate->cy); 134 - cairo_matrix_invert (&matrix); 135 - cairo_pattern_set_matrix (pattern, &matrix); 136 - break; 137 - case GG_SVG_SKEW_X: 138 - skew = trans->data; 139 - cairo_pattern_get_matrix (pattern, &matrix); 140 - angle = skew->angle * (GG_SVG_PI / 180.0); 141 - tangent = tan (angle); 142 - matrix_in.xx = 1.0; 143 - matrix_in.yx = 0.0; 144 - matrix_in.xy = tangent; 145 - matrix_in.yy = 1.0; 146 - matrix_in.x0 = 0.0; 147 - matrix_in.y0 = 0.0; 148 - cairo_matrix_multiply (&matrix, &matrix_in, &matrix); 149 - cairo_matrix_invert (&matrix); 150 - cairo_pattern_set_matrix (pattern, &matrix); 151 - break; 152 - case GG_SVG_SKEW_Y: 153 - skew = trans->data; 154 - cairo_pattern_get_matrix (pattern, &matrix); 155 - angle = skew->angle * (GG_SVG_PI / 180.0); 156 - tangent = tan (angle); 157 - matrix_in.xx = 1.0; 158 - matrix_in.yx = tangent; 159 - matrix_in.xy = 0.0; 160 - matrix_in.yy = 1.0; 161 - matrix_in.x0 = 0.0; 162 - matrix_in.y0 = 0.0; 163 - cairo_matrix_multiply (&matrix, &matrix_in, &matrix); 164 - cairo_matrix_invert (&matrix); 165 - cairo_pattern_set_matrix (pattern, &matrix); 166 - break; 167 - }; 168 -} 169 - 170 -static void 171 -gg_svg_apply_gradient_transformations (cairo_pattern_t * pattern, 172 - struct gg_svg_gradient *grad) 173 -{ 174 -/* applying all Gradient-related transformations */ 175 - struct gg_svg_transform *trans = grad->first_trans; 176 - while (trans) 177 - { 178 - gg_svg_gradient_transformation (pattern, trans); 179 - trans = trans->next; 180 - } 181 -} 182 - 183 -static void 184 -gg_svg_set_pen (cairo_t * cairo, struct gg_svg_style *style) 185 -{ 186 -/* setting up a Pen for Cairo */ 187 - cairo_pattern_t *pattern; 188 - double lengths[4]; 189 - lengths[0] = 1.0; 190 - cairo_set_line_width (cairo, style->stroke_width); 191 - if (style->stroke_url != NULL && style->stroke_pointer != NULL) 192 - { 193 - struct gg_svg_gradient *grad = style->stroke_pointer; 194 - struct gg_svg_gradient_stop *stop; 195 - if (grad->type == GG_SVG_LINEAR_GRADIENT) 196 - { 197 - pattern = 198 - cairo_pattern_create_linear (grad->x1, grad->y1, grad->x2, 199 - grad->y2); 200 - gg_svg_apply_gradient_transformations (pattern, grad); 201 - stop = grad->first_stop; 202 - while (stop) 203 - { 204 - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, 205 - stop->red, stop->green, 206 - stop->blue, 207 - stop->opacity * 208 - style->opacity); 209 - stop = stop->next; 210 - } 211 - cairo_set_source (cairo, pattern); 212 - cairo_set_line_cap (cairo, style->stroke_linecap); 213 - cairo_set_line_join (cairo, style->stroke_linejoin); 214 - cairo_set_miter_limit (cairo, style->stroke_miterlimit); 215 - if (style->stroke_dashitems == 0 216 - || style->stroke_dasharray == NULL) 217 - cairo_set_dash (cairo, lengths, 0, 0.0); 218 - else 219 - cairo_set_dash (cairo, style->stroke_dasharray, 220 - style->stroke_dashitems, 221 - style->stroke_dashoffset); 222 - cairo_pattern_destroy (pattern); 223 - return; 224 - } 225 - else if (grad->type == GG_SVG_RADIAL_GRADIENT) 226 - { 227 - pattern = 228 - cairo_pattern_create_radial (grad->cx, grad->cy, 0.0, 229 - grad->fx, grad->fy, grad->r); 230 - gg_svg_apply_gradient_transformations (pattern, grad); 231 - stop = grad->first_stop; 232 - while (stop) 233 - { 234 - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, 235 - stop->red, stop->green, 236 - stop->blue, 237 - stop->opacity * 238 - style->opacity); 239 - stop = stop->next; 240 - } 241 - cairo_set_source (cairo, pattern); 242 - cairo_set_line_cap (cairo, style->stroke_linecap); 243 - cairo_set_line_join (cairo, style->stroke_linejoin); 244 - cairo_set_miter_limit (cairo, style->stroke_miterlimit); 245 - if (style->stroke_dashitems == 0 246 - || style->stroke_dasharray == NULL) 247 - cairo_set_dash (cairo, lengths, 0, 0.0); 248 - else 249 - cairo_set_dash (cairo, style->stroke_dasharray, 250 - style->stroke_dashitems, 251 - style->stroke_dashoffset); 252 - cairo_pattern_destroy (pattern); 253 - return; 254 - } 255 - } 256 - cairo_set_source_rgba (cairo, style->stroke_red, style->stroke_green, 257 - style->stroke_blue, 258 - style->stroke_opacity * style->opacity); 259 - cairo_set_line_cap (cairo, style->stroke_linecap); 260 - cairo_set_line_join (cairo, style->stroke_linejoin); 261 - cairo_set_miter_limit (cairo, style->stroke_miterlimit); 262 - if (style->stroke_dashitems == 0 || style->stroke_dasharray == NULL) 263 - cairo_set_dash (cairo, lengths, 0, 0.0); 264 - else 265 - cairo_set_dash (cairo, style->stroke_dasharray, style->stroke_dashitems, 266 - style->stroke_dashoffset); 267 -} 268 - 269 -static void 270 -gg_svg_set_brush (cairo_t * cairo, struct gg_svg_style *style) 271 -{ 272 -/* setting up a Brush for Cairo */ 273 - cairo_pattern_t *pattern; 274 - if (style->fill_url != NULL && style->fill_pointer != NULL) 275 - { 276 - struct gg_svg_gradient *grad = style->fill_pointer; 277 - struct gg_svg_gradient_stop *stop; 278 - if (grad->type == GG_SVG_LINEAR_GRADIENT) 279 - { 280 - pattern = 281 - cairo_pattern_create_linear (grad->x1, grad->y1, grad->x2, 282 - grad->y2); 283 - gg_svg_apply_gradient_transformations (pattern, grad); 284 - stop = grad->first_stop; 285 - while (stop) 286 - { 287 - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, 288 - stop->red, stop->green, 289 - stop->blue, 290 - stop->opacity * 291 - style->opacity); 292 - stop = stop->next; 293 - } 294 - cairo_set_source (cairo, pattern); 295 - cairo_pattern_destroy (pattern); 296 - return; 297 - } 298 - else if (grad->type == GG_SVG_RADIAL_GRADIENT) 299 - { 300 - pattern = 301 - cairo_pattern_create_radial (grad->cx, grad->cy, 0.0, 302 - grad->fx, grad->fy, grad->r); 303 - gg_svg_apply_gradient_transformations (pattern, grad); 304 - stop = grad->first_stop; 305 - while (stop) 306 - { 307 - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, 308 - stop->red, stop->green, 309 - stop->blue, 310 - stop->opacity * 311 - style->opacity); 312 - stop = stop->next; 313 - } 314 - cairo_set_source (cairo, pattern); 315 - cairo_pattern_destroy (pattern); 316 - return; 317 - } 318 - } 319 - 320 - cairo_set_source_rgba (cairo, style->fill_red, style->fill_green, 321 - style->fill_blue, 322 - style->fill_opacity * style->opacity); 323 - cairo_set_fill_rule (cairo, style->fill_rule); 324 -} 325 - 326 -static void 327 -gg_svg_draw_rect (cairo_t * cairo, struct gg_svg_shape *shape, 328 - struct gg_svg_style *style) 329 -{ 330 -/* drawing an SVG Rect */ 331 - struct gg_svg_rect *rect = shape->data; 332 - if (rect->width == 0 || rect->height == 0) 333 - return; 334 - if (style->visibility == 0) 335 - return; 336 - if (style->fill == 0 && style->stroke == 0) 337 - return; 338 - 339 - if (rect->rx <= 0 || rect->ry <= 0) 340 - { 341 - /* normal Rect */ 342 - cairo_rectangle (cairo, rect->x, rect->y, rect->width, rect->height); 343 - } 344 - else 345 - { 346 - /* rounded Rect */ 347 - cairo_new_sub_path (cairo); 348 - cairo_save (cairo); 349 - cairo_translate (cairo, rect->x + rect->rx, rect->y + rect->ry); 350 - cairo_scale (cairo, rect->rx, rect->ry); 351 - cairo_arc (cairo, 0.0, 0.0, 1.0, GG_SVG_PI, -1 * GG_SVG_PI / 2.0); 352 - cairo_restore (cairo); 353 - cairo_save (cairo); 354 - cairo_translate (cairo, rect->x + rect->width - rect->rx, 355 - rect->y + rect->ry); 356 - cairo_scale (cairo, rect->rx, rect->ry); 357 - cairo_arc (cairo, 0.0, 0.0, 1.0, -1 * GG_SVG_PI / 2.0, 0.0); 358 - cairo_restore (cairo); 359 - cairo_save (cairo); 360 - cairo_translate (cairo, rect->x + rect->width - rect->rx, 361 - rect->y + rect->height - rect->ry); 362 - cairo_scale (cairo, rect->rx, rect->ry); 363 - cairo_arc (cairo, 0.0, 0.0, 1.0, 0.0, GG_SVG_PI / 2.0); 364 - cairo_restore (cairo); 365 - cairo_save (cairo); 366 - cairo_translate (cairo, rect->x + rect->rx, 367 - rect->y + rect->height - rect->ry); 368 - cairo_scale (cairo, rect->rx, rect->ry); 369 - cairo_arc (cairo, 0.0, 0.0, 1.0, GG_SVG_PI / 2.0, GG_SVG_PI); 370 - cairo_restore (cairo); 371 - cairo_close_path (cairo); 372 - } 373 - 374 -/* drawing the Rect */ 375 - if (style->fill) 376 - { 377 - /* filling */ 378 - gg_svg_set_brush (cairo, style); 379 - if (style->stroke) 380 - cairo_fill_preserve (cairo); 381 - else 382 - cairo_fill (cairo); 383 - } 384 - if (style->stroke) 385 - { 386 - /* stroking */ 387 - gg_svg_set_pen (cairo, style); 388 - cairo_stroke (cairo); 389 - } 390 -} 391 - 392 -static void 393 -gg_svg_clip_rect (cairo_t * cairo, struct gg_svg_shape *shape) 394 -{ 395 -/* clipping an SVG Rect */ 396 - struct gg_svg_rect *rect = shape->data; 397 - if (rect->width == 0 || rect->height == 0) 398 - return; 399 - 400 - if (rect->rx <= 0 || rect->ry <= 0) 401 - { 402 - /* normal Rect */ 403 - cairo_rectangle (cairo, rect->x, rect->y, rect->width, rect->height); 404 - } 405 - else 406 - { 407 - /* rounded Rect */ 408 - cairo_new_sub_path (cairo); 409 - cairo_save (cairo); 410 - cairo_translate (cairo, rect->x + rect->rx, rect->y + rect->ry); 411 - cairo_scale (cairo, rect->rx, rect->ry); 412 - cairo_arc (cairo, 0.0, 0.0, 1.0, GG_SVG_PI, -1 * GG_SVG_PI / 2.0); 413 - cairo_restore (cairo); 414 - cairo_save (cairo); 415 - cairo_translate (cairo, rect->x + rect->width - rect->rx, 416 - rect->y + rect->ry); 417 - cairo_scale (cairo, rect->rx, rect->ry); 418 - cairo_arc (cairo, 0.0, 0.0, 1.0, -1 * GG_SVG_PI / 2.0, 0.0); 419 - cairo_restore (cairo); 420 - cairo_save (cairo); 421 - cairo_translate (cairo, rect->x + rect->width - rect->rx, 422 - rect->y + rect->height - rect->ry); 423 - cairo_scale (cairo, rect->rx, rect->ry); 424 - cairo_arc (cairo, 0.0, 0.0, 1.0, 0.0, GG_SVG_PI / 2.0); 425 - cairo_restore (cairo); 426 - cairo_save (cairo); 427 - cairo_translate (cairo, rect->x + rect->rx, 428 - rect->y + rect->height - rect->ry); 429 - cairo_scale (cairo, rect->rx, rect->ry); 430 - cairo_arc (cairo, 0.0, 0.0, 1.0, GG_SVG_PI / 2.0, GG_SVG_PI); 431 - cairo_restore (cairo); 432 - cairo_close_path (cairo); 433 - } 434 - cairo_clip (cairo); 435 -} 436 - 437 -static void 438 -gg_svg_draw_circle (cairo_t * cairo, struct gg_svg_shape *shape, 439 - struct gg_svg_style *style) 440 -{ 441 -/* drawing an SVG Circle */ 442 - struct gg_svg_circle *circle = shape->data; 443 - if (circle->r <= 0) 444 - return; 445 - if (style->visibility == 0) 446 - return; 447 - if (style->fill == 0 && style->stroke == 0) 448 - return; 449 - 450 -/* drawing the Arc */ 451 - cairo_arc (cairo, circle->cx, circle->cy, circle->r, 0.0, 2.0 * GG_SVG_PI); 452 - if (style->fill) 453 - { 454 - /* filling */ 455 - gg_svg_set_brush (cairo, style); 456 - if (style->stroke) 457 - cairo_fill_preserve (cairo); 458 - else 459 - cairo_fill (cairo); 460 - } 461 - if (style->stroke) 462 - { 463 - /* stroking */ 464 - gg_svg_set_pen (cairo, style); 465 - cairo_stroke (cairo); 466 - } 467 -} 468 - 469 -static void 470 -gg_svg_clip_circle (cairo_t * cairo, struct gg_svg_shape *shape) 471 -{ 472 -/* clipping an SVG Circle */ 473 - struct gg_svg_circle *circle = shape->data; 474 - if (circle->r <= 0) 475 - return; 476 - 477 -/* clipping the Arc */ 478 - cairo_arc (cairo, circle->cx, circle->cy, circle->r, 0.0, 2.0 * GG_SVG_PI); 479 - cairo_clip (cairo); 480 -} 481 - 482 -static void 483 -gg_svg_draw_ellipse (cairo_t * cairo, struct gg_svg_shape *shape, 484 - struct gg_svg_style *style) 485 -{ 486 -/* drawing an SVG Ellipse */ 487 - struct gg_svg_ellipse *ellipse = shape->data; 488 - if (ellipse->rx <= 0 || ellipse->ry <= 0) 489 - return; 490 - if (style->visibility == 0) 491 - return; 492 - if (style->fill == 0 && style->stroke == 0) 493 - return; 494 - 495 -/* drawing the Ellipse */ 496 - cairo_save (cairo); 497 - 498 - cairo_translate (cairo, ellipse->cx + ellipse->rx / 2.0, 499 - ellipse->cy + ellipse->ry / 2.0); 500 - cairo_scale (cairo, ellipse->rx / 2.0, ellipse->ry / 2.0); 501 - cairo_arc (cairo, 0.0, 0.0, 2.0, 0.0, 2.0 * GG_SVG_PI); 502 - cairo_restore (cairo); 503 - if (style->fill) 504 - { 505 - /* filling */ 506 - gg_svg_set_brush (cairo, style); 507 - if (style->stroke) 508 - cairo_fill_preserve (cairo); 509 - else 510 - cairo_fill (cairo); 511 - } 512 - if (style->stroke) 513 - { 514 - /* stroking */ 515 - gg_svg_set_pen (cairo, style); 516 - cairo_stroke (cairo); 517 - } 518 -} 519 - 520 -static void 521 -gg_svg_clip_ellipse (cairo_t * cairo, struct gg_svg_shape *shape) 522 -{ 523 -/* clipping an SVG Ellipse */ 524 - struct gg_svg_ellipse *ellipse = shape->data; 525 - if (ellipse->rx <= 0 || ellipse->ry <= 0) 526 - return; 527 - 528 -/* clipping the Ellipse */ 529 - cairo_save (cairo); 530 - 531 - cairo_translate (cairo, ellipse->cx + ellipse->rx / 2.0, 532 - ellipse->cy + ellipse->ry / 2.0); 533 - cairo_scale (cairo, ellipse->rx / 2.0, ellipse->ry / 2.0); 534 - cairo_arc (cairo, 0.0, 0.0, 2.0, 0.0, 2.0 * GG_SVG_PI); 535 - cairo_restore (cairo); 536 - cairo_clip (cairo); 537 -} 538 - 539 -static void 540 -gg_svg_draw_line (cairo_t * cairo, struct gg_svg_shape *shape, 541 - struct gg_svg_style *style) 542 -{ 543 -/* drawing an SVG Line */ 544 - struct gg_svg_line *line = shape->data; 545 - if (style->visibility == 0) 546 - return; 547 - if (style->fill == 0 && style->stroke == 0) 548 - return; 549 - 550 -/* drawing the Line */ 551 - cairo_move_to (cairo, line->x1, line->y1); 552 - cairo_line_to (cairo, line->x2, line->y2); 553 - if (style->fill) 554 - { 555 - /* filling */ 556 - gg_svg_set_brush (cairo, style); 557 - cairo_fill (cairo); 558 - } 559 - if (style->stroke) 560 - { 561 - /* stroking */ 562 - gg_svg_set_pen (cairo, style); 563 - cairo_stroke (cairo); 564 - } 565 -} 566 - 567 -static void 568 -gg_svg_clip_line (cairo_t * cairo, struct gg_svg_shape *shape) 569 -{ 570 -/* clipping an SVG Line */ 571 - struct gg_svg_line *line = shape->data; 572 - 573 -/* clipping the Line */ 574 - cairo_move_to (cairo, line->x1, line->y1); 575 - cairo_line_to (cairo, line->x2, line->y2); 576 - cairo_clip (cairo); 577 -} 578 - 579 -static void 580 -gg_svg_draw_polyline (cairo_t * cairo, struct gg_svg_shape *shape, 581 - struct gg_svg_style *style) 582 -{ 583 -/* drawing an SVG Polyline */ 584 - int iv; 585 - struct gg_svg_polyline *poly = shape->data; 586 - if (poly->points <= 0 || poly->x == NULL || poly->y == NULL) 587 - return; 588 - if (style->visibility == 0) 589 - return; 590 - if (style->fill == 0 && style->stroke == 0) 591 - return; 592 - 593 -/* drawing the Polyline */ 594 - for (iv = 0; iv < poly->points; iv++) 595 - { 596 - if (iv == 0) 597 - cairo_move_to (cairo, *(poly->x + iv), *(poly->y + iv)); 598 - else 599 - cairo_line_to (cairo, *(poly->x + iv), *(poly->y + iv)); 600 - } 601 - if (style->fill) 602 - { 603 - /* filling */ 604 - gg_svg_set_brush (cairo, style); 605 - if (style->stroke) 606 - cairo_fill_preserve (cairo); 607 - else 608 - cairo_fill (cairo); 609 - } 610 - if (style->stroke) 611 - { 612 - /* stroking */ 613 - gg_svg_set_pen (cairo, style); 614 - cairo_stroke (cairo); 615 - } 616 -} 617 - 618 -static void 619 -gg_svg_clip_polyline (cairo_t * cairo, struct gg_svg_shape *shape) 620 -{ 621 -/* clipping an SVG Polyline */ 622 - int iv; 623 - struct gg_svg_polyline *poly = shape->data; 624 - if (poly->points <= 0 || poly->x == NULL || poly->y == NULL) 625 - return; 626 - 627 -/* clipping the Polyline */ 628 - for (iv = 0; iv < poly->points; iv++) 629 - { 630 - if (iv == 0) 631 - cairo_move_to (cairo, *(poly->x + iv), *(poly->y + iv)); 632 - else 633 - cairo_line_to (cairo, *(poly->x + iv), *(poly->y + iv)); 634 - } 635 - cairo_clip (cairo); 636 -} 637 - 638 -static void 639 -gg_svg_draw_polygon (cairo_t * cairo, struct gg_svg_shape *shape, 640 - struct gg_svg_style *style) 641 -{ 642 -/* drawing an SVG Polygon */ 643 - int iv; 644 - struct gg_svg_polygon *poly = shape->data; 645 - if (poly->points <= 0 || poly->x == NULL || poly->y == NULL) 646 - return; 647 - if (style->visibility == 0) 648 - return; 649 - if (style->fill == 0 && style->stroke == 0) 650 - return; 651 - 652 -/* drawing the Polygon */ 653 - for (iv = 0; iv < poly->points; iv++) 654 - { 655 - if (iv == 0) 656 - cairo_move_to (cairo, *(poly->x + iv), *(poly->y + iv)); 657 - else 658 - cairo_line_to (cairo, *(poly->x + iv), *(poly->y + iv)); 659 - } 660 - cairo_close_path (cairo); 661 - if (style->fill) 662 - { 663 - /* filling */ 664 - gg_svg_set_brush (cairo, style); 665 - if (style->stroke) 666 - cairo_fill_preserve (cairo); 667 - else 668 - cairo_fill (cairo); 669 - } 670 - if (style->stroke) 671 - { 672 - /* stroking */ 673 - gg_svg_set_pen (cairo, style); 674 - cairo_stroke (cairo); 675 - } 676 -} 677 - 678 -static void 679 -gg_svg_clip_polygon (cairo_t * cairo, struct gg_svg_shape *shape) 680 -{ 681 -/* clipping an SVG Polygon */ 682 - int iv; 683 - struct gg_svg_polygon *poly = shape->data; 684 - if (poly->points <= 0 || poly->x == NULL || poly->y == NULL) 685 - return; 686 - 687 -/* clipping the Polygon */ 688 - for (iv = 0; iv < poly->points; iv++) 689 - { 690 - if (iv == 0) 691 - cairo_move_to (cairo, *(poly->x + iv), *(poly->y + iv)); 692 - else 693 - cairo_line_to (cairo, *(poly->x + iv), *(poly->y + iv)); 694 - } 695 - cairo_close_path (cairo); 696 - cairo_clip (cairo); 697 -} 698 - 699 -static void 700 -svg_rotate (double x, double y, double angle, double *rx, double *ry) 701 -{ 702 -/* rotate a point of an angle around the origin point */ 703 - *rx = x * cos (angle) - y * sin (angle); 704 - *ry = y * cos (angle) + x * sin (angle); 705 -} 706 - 707 -static double 708 -gg_svg_point_angle (double cx, double cy, double px, double py) 709 -{ 710 -/* return angle between x axis and point knowing given center */ 711 - return atan2 (py - cy, px - cx); 712 -} 713 - 714 -static void 715 -gg_svg_arc_to_cairo (struct gg_svg_path_ellipt_arc *arc, double x1, double y1, 716 - double *xc, double *yc, double *rx, double *rotation, 717 - double *radii_ratio, double *angle1, double *angle2) 718 -{ 719 -/* 720 -/ computing the arguments for CairoArc starting from an SVG Elliptic Arc 721 -/ (simply a C translation of pyCairo Python code) 722 -*/ 723 - double x3; 724 - double y3; 725 - double ry; 726 - double xe; 727 - double ye; 728 - double angle; 729 -/* converting absolute x3 and y3 to relative */ 730 - x3 = arc->x - x1; 731 - y3 = arc->y - y1; 732 - *rx = arc->rx; 733 - ry = arc->ry; 734 - *radii_ratio = ry / *rx; 735 - *rotation = arc->rotation * (GG_SVG_PI / 180.0); 736 -/* cancel the rotation of the second point */ 737 - svg_rotate (x3, y3, *rotation * -1, &xe, &ye); 738 - ye /= *radii_ratio; 739 -/* find the angle between the second point and the x axis */ 740 - angle = gg_svg_point_angle (0.0, 0.0, xe, ye); 741 -/* put the second point onto the x axis */ 742 - xe = sqrt ((xe * xe) + (ye * ye)); 743 - ye = 0.0; 744 -/* update the x radius if it is too small */ 745 - if (*rx < xe / 2.0) 746 - *rx = xe / 2.0; 747 -/* find one circle centre */ 748 - *xc = xe / 2.0; 749 - *yc = sqrt ((*rx * *rx) - (*xc * *xc)); 750 -/* choose between the two circles according to flags */ 751 - if ((arc->large_arc ^ arc->sweep) == 0) 752 - *yc = *yc * -1.0; 753 -/* put the second point and the center back to their positions */ 754 - svg_rotate (xe, ye, angle, &xe, &ye); 755 - svg_rotate (*xc, *yc, angle, xc, yc); 756 -/* find the drawing angles */ 757 - *angle1 = gg_svg_point_angle (*xc, *yc, 0.0, 0.0); 758 - *angle2 = gg_svg_point_angle (*xc, *yc, xe, ye); 759 -} 760 - 761 -static void 762 -gg_svg_draw_path (cairo_t * cairo, struct gg_svg_shape *shape, 763 - struct gg_svg_style *style) 764 -{ 765 -/* drawing an SVG Path */ 766 - struct gg_svg_path_item *item; 767 - struct gg_svg_path *path = shape->data; 768 - struct gg_svg_path_move *move; 769 - struct gg_svg_path_bezier *bezier; 770 - struct gg_svg_path_ellipt_arc *arc; 771 - double x; 772 - double y; 773 - double x0; 774 - double y0; 775 - double radii_ratio; 776 - double xc; 777 - double yc; 778 - double rx; 779 - double rotation; 780 - double angle1; 781 - double angle2; 782 - int is_new_path = 0; 783 - if (path->error) 784 - return; 785 - if (style->visibility == 0) 786 - return; 787 - if (style->fill == 0 && style->stroke == 0) 788 - return; 789 - 790 -/* drawing the Path */ 791 - item = path->first; 792 - while (item) 793 - { 794 - if (is_new_path && item->type != GG_SVG_MOVE_TO) 795 - { 796 - /* implicit MoveTO */ 797 - cairo_get_current_point (cairo, &x, &y); 798 - cairo_move_to (cairo, x, y); 799 - } 800 - is_new_path = 0; 801 - switch (item->type) 802 - { 803 - case GG_SVG_CLOSE_PATH: 804 - cairo_close_path (cairo); 805 - is_new_path = 1; 806 - break; 807 - case GG_SVG_MOVE_TO: 808 - move = item->data; 809 - cairo_move_to (cairo, move->x, move->y); 810 - break; 811 - case GG_SVG_LINE_TO: 812 - move = item->data; 813 - cairo_line_to (cairo, move->x, move->y); 814 - break; 815 - case GG_SVG_CURVE_3: 816 - bezier = item->data; 817 - cairo_curve_to (cairo, bezier->x1, bezier->y1, bezier->x2, 818 - bezier->y2, bezier->x, bezier->y); 819 - break; 820 - case GG_SVG_CURVE_4: 821 - bezier = item->data; 822 - cairo_get_current_point (cairo, &x0, &y0); 823 - cairo_curve_to (cairo, 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0, 824 - 2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * y0, 825 - 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * bezier->x2, 826 - 2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * bezier->y2, 827 - bezier->y1, bezier->y2); 828 - break; 829 - case GG_SVG_ELLIPT_ARC: 830 - arc = item->data; 831 - cairo_get_current_point (cairo, &x0, &y0); 832 - gg_svg_arc_to_cairo (arc, x0, y0, &xc, &yc, &rx, &rotation, 833 - &radii_ratio, &angle1, &angle2); 834 - cairo_save (cairo); 835 - cairo_translate (cairo, x0, y0); 836 - cairo_rotate (cairo, rotation); 837 - cairo_scale (cairo, 1.0, radii_ratio); 838 - if (arc->sweep == 0) 839 - cairo_arc_negative (cairo, xc, yc, rx, angle1, angle2); 840 - else 841 - cairo_arc (cairo, xc, yc, rx, angle1, angle2); 842 - cairo_restore (cairo); 843 - break; 844 - }; 845 - item = item->next; 846 - } 847 - if (style->fill) 848 - { 849 - /* filling */ 850 - gg_svg_set_brush (cairo, style); 851 - if (style->stroke) 852 - cairo_fill_preserve (cairo); 853 - else 854 - cairo_fill (cairo); 855 - } 856 - if (style->stroke) 857 - { 858 - /* stroking */ 859 - gg_svg_set_pen (cairo, style); 860 - cairo_stroke (cairo); 861 - } 862 -} 863 - 864 -static void 865 -gg_svg_clip_path (cairo_t * cairo, struct gg_svg_shape *shape) 866 -{ 867 -/* clipping an SVG Path */ 868 - struct gg_svg_path_item *item; 869 - struct gg_svg_path *path = shape->data; 870 - struct gg_svg_path_move *move; 871 - struct gg_svg_path_bezier *bezier; 872 - struct gg_svg_path_ellipt_arc *arc; 873 - double x; 874 - double y; 875 - double x0; 876 - double y0; 877 - double radii_ratio; 878 - double xc; 879 - double yc; 880 - double rx; 881 - double rotation; 882 - double angle1; 883 - double angle2; 884 - int is_new_path = 0; 885 - if (path->error) 886 - return; 887 -/* clipping the Path */ 888 - item = path->first; 889 - while (item) 890 - { 891 - if (is_new_path && item->type != GG_SVG_MOVE_TO) 892 - { 893 - /* implicit MoveTO */ 894 - cairo_get_current_point (cairo, &x, &y); 895 - cairo_move_to (cairo, x, y); 896 - } 897 - is_new_path = 0; 898 - switch (item->type) 899 - { 900 - case GG_SVG_CLOSE_PATH: 901 - cairo_close_path (cairo); 902 - is_new_path = 1; 903 - break; 904 - case GG_SVG_MOVE_TO: 905 - move = item->data; 906 - cairo_move_to (cairo, move->x, move->y); 907 - break; 908 - case GG_SVG_LINE_TO: 909 - move = item->data; 910 - cairo_line_to (cairo, move->x, move->y); 911 - break; 912 - case GG_SVG_CURVE_3: 913 - bezier = item->data; 914 - cairo_curve_to (cairo, bezier->x1, bezier->y1, bezier->x2, 915 - bezier->y2, bezier->x, bezier->y); 916 - break; 917 - case GG_SVG_CURVE_4: 918 - bezier = item->data; 919 - cairo_get_current_point (cairo, &x0, &y0); 920 - cairo_curve_to (cairo, 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0, 921 - 2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * y0, 922 - 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * bezier->x2, 923 - 2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * bezier->y2, 924 - bezier->y1, bezier->y2); 925 - break; 926 - case GG_SVG_ELLIPT_ARC: 927 - arc = item->data; 928 - cairo_get_current_point (cairo, &x0, &y0); 929 - gg_svg_arc_to_cairo (arc, x0, y0, &xc, &yc, &rx, &rotation, 930 - &radii_ratio, &angle1, &angle2); 931 - cairo_save (cairo); 932 - cairo_translate (cairo, x0, y0); 933 - cairo_rotate (cairo, rotation); 934 - cairo_scale (cairo, 1.0, radii_ratio); 935 - if (arc->sweep == 0) 936 - cairo_arc_negative (cairo, xc, yc, rx, angle1, angle2); 937 - else 938 - cairo_arc (cairo, xc, yc, rx, angle1, angle2); 939 - cairo_restore (cairo); 940 - break; 941 - }; 942 - item = item->next; 943 - } 944 - cairo_clip (cairo); 945 -} 946 - 947 -static void 948 -gg_svg_draw_shape (cairo_t * cairo, struct gg_svg_shape *shape, 949 - struct gg_svg_style *style) 950 -{ 951 -/* drawing an SVG Shape */ 952 - if (shape->style.visibility == 0) 953 - return; 954 - switch (shape->type) 955 - { 956 - case GG_SVG_RECT: 957 - gg_svg_draw_rect (cairo, shape, style); 958 - break; 959 - case GG_SVG_CIRCLE: 960 - gg_svg_draw_circle (cairo, shape, style); 961 - break; 962 - case GG_SVG_ELLIPSE: 963 - gg_svg_draw_ellipse (cairo, shape, style); 964 - break; 965 - case GG_SVG_LINE: 966 - gg_svg_draw_line (cairo, shape, style); 967 - break; 968 - case GG_SVG_POLYLINE: 969 - gg_svg_draw_polyline (cairo, shape, style); 970 - break; 971 - case GG_SVG_POLYGON: 972 - gg_svg_draw_polygon (cairo, shape, style); 973 - break; 974 - case GG_SVG_PATH: 975 - gg_svg_draw_path (cairo, shape, style); 976 - break; 977 - }; 978 -} 979 - 980 -static void 981 -gg_svg_transformation (cairo_t * cairo, struct gg_svg_transform *trans) 982 -{ 983 -/* applying a single transformation */ 984 - double angle; 985 - double tangent; 986 - struct gg_svg_matrix *mtrx; 987 - struct gg_svg_translate *translate; 988 - struct gg_svg_scale *scale; 989 - struct gg_svg_rotate *rotate; 990 - struct gg_svg_skew *skew; 991 - cairo_matrix_t matrix; 992 - cairo_matrix_t matrix_in; 993 - 994 - if (trans->data == NULL) 995 - return; 996 - switch (trans->type) 997 - { 998 - case GG_SVG_MATRIX: 999 - mtrx = trans->data; 1000 - cairo_get_matrix (cairo, &matrix); 1001 - matrix_in.xx = mtrx->a; 1002 - matrix_in.yx = mtrx->b; 1003 - matrix_in.xy = mtrx->c; 1004 - matrix_in.yy = mtrx->d; 1005 - matrix_in.x0 = mtrx->e; 1006 - matrix_in.y0 = mtrx->f; 1007 - cairo_matrix_multiply (&matrix, &matrix_in, &matrix); 1008 - cairo_set_matrix (cairo, &matrix); 1009 - break; 1010 - case GG_SVG_TRANSLATE: 1011 - translate = trans->data; 1012 - cairo_get_matrix (cairo, &matrix); 1013 - cairo_matrix_translate (&matrix, translate->tx, translate->ty); 1014 - cairo_set_matrix (cairo, &matrix); 1015 - break; 1016 - case GG_SVG_SCALE: 1017 - scale = trans->data; 1018 - cairo_get_matrix (cairo, &matrix); 1019 - cairo_matrix_scale (&matrix, scale->sx, scale->sy); 1020 - cairo_set_matrix (cairo, &matrix); 1021 - break; 1022 - case GG_SVG_ROTATE: 1023 - rotate = trans->data; 1024 - cairo_get_matrix (cairo, &matrix); 1025 - angle = rotate->angle * (GG_SVG_PI / 180.0); 1026 - cairo_matrix_translate (&matrix, rotate->cx, rotate->cy); 1027 - cairo_matrix_rotate (&matrix, angle); 1028 - cairo_matrix_translate (&matrix, -1.0 * rotate->cx, 1029 - -1.0 * rotate->cy); 1030 - cairo_set_matrix (cairo, &matrix); 1031 - break; 1032 - case GG_SVG_SKEW_X: 1033 - skew = trans->data; 1034 - cairo_get_matrix (cairo, &matrix); 1035 - angle = skew->angle * (GG_SVG_PI / 180.0); 1036 - tangent = tan (angle); 1037 - matrix_in.xx = 1.0; 1038 - matrix_in.yx = 0.0; 1039 - matrix_in.xy = tangent; 1040 - matrix_in.yy = 1.0; 1041 - matrix_in.x0 = 0.0; 1042 - matrix_in.y0 = 0.0; 1043 - cairo_matrix_multiply (&matrix, &matrix_in, &matrix); 1044 - cairo_set_matrix (cairo, &matrix); 1045 - break; 1046 - case GG_SVG_SKEW_Y: 1047 - skew = trans->data; 1048 - cairo_get_matrix (cairo, &matrix); 1049 - angle = skew->angle * (GG_SVG_PI / 180.0); 1050 - tangent = tan (angle); 1051 - matrix_in.xx = 1.0; 1052 - matrix_in.yx = tangent; 1053 - matrix_in.xy = 0.0; 1054 - matrix_in.yy = 1.0; 1055 - matrix_in.x0 = 0.0; 1056 - matrix_in.y0 = 0.0; 1057 - cairo_matrix_multiply (&matrix, &matrix_in, &matrix); 1058 - cairo_set_matrix (cairo, &matrix); 1059 - break; 1060 - }; 1061 -} 1062 - 1063 -static void 1064 -gg_svg_apply_transformations (cairo_t * cairo, struct gg_svg_document *svg_doc, 1065 - struct gg_svg_shape *shape) 1066 -{ 1067 -/* applying the whole transformations chain (supporting inheritance) */ 1068 - struct gg_svg_group *parent; 1069 - struct gg_svg_parents chain; 1070 - struct gg_svg_parent_ref *ref; 1071 - struct gg_svg_group *group; 1072 - struct gg_svg_transform *trans; 1073 - cairo_matrix_t matrix; 1074 - 1075 -/* initializing the chain as empty */ 1076 - chain.first = NULL; 1077 - chain.last = NULL; 1078 - 1079 - parent = shape->parent; 1080 - if (parent != NULL) 1081 - { 1082 - /* identifying all direct parents in reverse order */ 1083 - while (parent) 1084 - { 1085 - gg_svg_add_parent (&chain, parent); 1086 - parent = parent->parent; 1087 - } 1088 - } 1089 - 1090 -/* starting from the SVG Document basic transformations */ 1091 - matrix.xx = svg_doc->matrix.xx; 1092 - matrix.yx = svg_doc->matrix.yx; 1093 - matrix.xy = svg_doc->matrix.xy; 1094 - matrix.yy = svg_doc->matrix.yy; 1095 - matrix.x0 = svg_doc->matrix.x0; 1096 - matrix.y0 = svg_doc->matrix.y0; 1097 - cairo_set_matrix (cairo, &matrix); 1098 - 1099 - ref = chain.first; 1100 - while (ref) 1101 - { 1102 - /* chaining all transformations inherited by ancestors */ 1103 - group = ref->parent; 1104 - if (group != NULL) 1105 - { 1106 - trans = group->first_trans; 1107 - while (trans) 1108 - { 1109 - gg_svg_transformation (cairo, trans); 1110 - trans = trans->next; 1111 - } 1112 - } 1113 - ref = ref->next; 1114 - } 1115 - 1116 -/* applying Shape specific transformations */ 1117 - trans = shape->first_trans; 1118 - while (trans) 1119 - { 1120 - gg_svg_transformation (cairo, trans); 1121 - trans = trans->next; 1122 - } 1123 - 1124 - gg_svg_free_parents (&chain); 1125 -} 1126 - 1127 -static void 1128 -gg_svg_apply_style (struct gg_svg_shape *shape, struct gg_svg_style *style) 1129 -{ 1130 -/* applying the final style (supporting inheritance) */ 1131 - struct gg_svg_group *parent; 1132 - struct gg_svg_parents chain; 1133 - struct gg_svg_parent_ref *ref; 1134 - struct gg_svg_group *group; 1135 - 1136 -/* initializing the chain as empty */ 1137 - chain.first = NULL; 1138 - chain.last = NULL; 1139 - 1140 - parent = shape->parent; 1141 - if (parent != NULL) 1142 - { 1143 - /* identifying all parents in reverse order */ 1144 - while (parent) 1145 - { 1146 - gg_svg_add_parent (&chain, parent); 1147 - parent = parent->parent; 1148 - } 1149 - } 1150 - 1151 -/* initializing an Undefined Style */ 1152 - style->visibility = 1; 1153 - style->opacity = 1.0; 1154 - style->fill = 1; 1155 - style->no_fill = 0; 1156 - style->fill_url = NULL; 1157 - style->fill_pointer = NULL; 1158 - style->fill_rule = -1; 1159 - style->fill_red = 0.0; 1160 - style->fill_green = 0.0; 1161 - style->fill_blue = 0.0; 1162 - style->fill_opacity = 1.0; 1163 - style->stroke = -1; 1164 - style->no_stroke = 0; 1165 - style->stroke_url = NULL; 1166 - style->stroke_pointer = NULL; 1167 - style->stroke_width = -1.0; 1168 - style->stroke_linecap = -1; 1169 - style->stroke_linejoin = -1; 1170 - style->stroke_miterlimit = -1.0; 1171 - style->stroke_dashitems = 0; 1172 - style->stroke_dasharray = NULL; 1173 - style->stroke_dashoffset = 0.0; 1174 - style->stroke_red = -1.0; 1175 - style->stroke_green = -1.0; 1176 - style->stroke_blue = -1.0; 1177 - style->stroke_opacity = -1.0; 1178 - style->clip_url = NULL; 1179 - style->clip_pointer = NULL; 1180 - 1181 - ref = chain.first; 1182 - while (ref) 1183 - { 1184 - /* chaining all style definitions inherited by ancestors */ 1185 - group = ref->parent; 1186 - if (group != NULL) 1187 - { 1188 - if (group->style.visibility >= 0) 1189 - style->visibility = group->style.visibility; 1190 - style->opacity = group->style.opacity; 1191 - if (group->style.fill >= 0) 1192 - style->fill = group->style.fill; 1193 - if (group->style.no_fill) 1194 - style->no_fill = group->style.no_fill; 1195 - if (group->style.fill_rule >= 0) 1196 - style->fill_rule = group->style.fill_rule; 1197 - if (group->style.fill_url != NULL) 1198 - gg_svg_add_fill_gradient_url (style, group->style.fill_url); 1199 - if (group->style.fill_red >= 0.0) 1200 - style->fill_red = group->style.fill_red; 1201 - if (group->style.fill_green >= 0.0) 1202 - style->fill_green = group->style.fill_green; 1203 - if (group->style.fill_blue >= 0.0) 1204 - style->fill_blue = group->style.fill_blue; 1205 - if (group->style.fill_opacity >= 0.0) 1206 - style->fill_opacity = group->style.fill_opacity; 1207 - if (group->style.stroke >= 0) 1208 - style->stroke = group->style.stroke; 1209 - if (group->style.no_stroke >= 0) 1210 - style->no_stroke = group->style.no_stroke; 1211 - if (group->style.stroke_width >= 0.0) 1212 - style->stroke_width = group->style.stroke_width; 1213 - if (group->style.stroke_linecap >= 0) 1214 - style->stroke_linecap = group->style.stroke_linecap; 1215 - if (group->style.stroke_linejoin >= 0) 1216 - style->stroke_linejoin = group->style.stroke_linejoin; 1217 - if (group->style.stroke_miterlimit >= 0.0) 1218 - style->stroke_miterlimit = group->style.stroke_miterlimit; 1219 - if (group->style.stroke_dashitems > 0) 1220 - { 1221 - style->stroke_dashitems = group->style.stroke_dashitems; 1222 - if (style->stroke_dasharray != NULL) 1223 - free (style->stroke_dasharray); 1224 - style->stroke_dasharray = NULL; 1225 - if (group->style.stroke_dashitems > 0) 1226 - { 1227 - int i; 1228 - style->stroke_dasharray = 1229 - malloc (sizeof (double) * 1230 - group->style.stroke_dashitems); 1231 - for (i = 0; i < group->style.stroke_dashitems; i++) 1232 - style->stroke_dasharray[i] = 1233 - group->style.stroke_dasharray[i]; 1234 - } 1235 - style->stroke_dashoffset = group->style.stroke_dashoffset; 1236 - } 1237 - if (group->style.stroke_url != NULL) 1238 - gg_svg_add_stroke_gradient_url (style, 1239 - group->style.stroke_url); 1240 - if (group->style.stroke_red >= 0.0) 1241 - style->stroke_red = group->style.stroke_red; 1242 - if (group->style.stroke_green >= 0.0) 1243 - style->stroke_green = group->style.stroke_green; 1244 - if (group->style.stroke_blue >= 0.0) 1245 - style->stroke_blue = group->style.stroke_blue; 1246 - if (group->style.stroke_opacity >= 0.0) 1247 - style->stroke_opacity = group->style.stroke_opacity; 1248 - if (group->style.clip_url != NULL) 1249 - { 1250 - gg_svg_add_clip_url (style, group->style.clip_url); 1251 - style->clip_pointer = group->style.clip_pointer; 1252 - } 1253 - } 1254 - ref = ref->next; 1255 - } 1256 - 1257 -/* applying Shape specific style definitions */ 1258 - if (shape->style.visibility >= 0) 1259 - style->visibility = shape->style.visibility; 1260 - style->opacity = shape->style.opacity; 1261 - if (shape->style.fill >= 0) 1262 - style->fill = shape->style.fill; 1263 - if (shape->style.no_fill >= 0) 1264 - style->no_fill = shape->style.no_fill; 1265 - if (shape->style.fill_rule >= 0) 1266 - style->fill_rule = shape->style.fill_rule; 1267 - if (shape->style.fill_url != NULL) 1268 - gg_svg_add_fill_gradient_url (style, shape->style.fill_url); 1269 - if (shape->style.fill_red >= 0.0) 1270 - style->fill_red = shape->style.fill_red; 1271 - if (shape->style.fill_green >= 0.0) 1272 - style->fill_green = shape->style.fill_green; 1273 - if (shape->style.fill_blue >= 0.0) 1274 - style->fill_blue = shape->style.fill_blue; 1275 - if (shape->style.fill_opacity >= 0.0) 1276 - style->fill_opacity = shape->style.fill_opacity; 1277 - if (shape->style.stroke >= 0) 1278 - style->stroke = shape->style.stroke; 1279 - if (shape->style.no_stroke >= 0) 1280 - style->no_stroke = shape->style.no_stroke; 1281 - if (shape->style.stroke_width >= 0.0) 1282 - style->stroke_width = shape->style.stroke_width; 1283 - if (shape->style.stroke_linecap >= 0) 1284 - style->stroke_linecap = shape->style.stroke_linecap; 1285 - if (shape->style.stroke_linejoin >= 0) 1286 - style->stroke_linejoin = shape->style.stroke_linejoin; 1287 - if (shape->style.stroke_miterlimit >= 0.0) 1288 - style->stroke_miterlimit = shape->style.stroke_miterlimit; 1289 - if (shape->style.stroke_dashitems > 0) 1290 - { 1291 - style->stroke_dashitems = shape->style.stroke_dashitems; 1292 - if (style->stroke_dasharray != NULL) 1293 - free (style->stroke_dasharray); 1294 - style->stroke_dasharray = NULL; 1295 - if (shape->style.stroke_dashitems > 0) 1296 - { 1297 - int i; 1298 - style->stroke_dasharray = 1299 - malloc (sizeof (double) * shape->style.stroke_dashitems); 1300 - for (i = 0; i < shape->style.stroke_dashitems; i++) 1301 - style->stroke_dasharray[i] = 1302 - shape->style.stroke_dasharray[i]; 1303 - } 1304 - style->stroke_dashoffset = shape->style.stroke_dashoffset; 1305 - } 1306 - if (shape->style.stroke_url != NULL) 1307 - gg_svg_add_stroke_gradient_url (style, shape->style.stroke_url); 1308 - if (shape->style.stroke_red >= 0.0) 1309 - style->stroke_red = shape->style.stroke_red; 1310 - if (shape->style.stroke_green >= 0.0) 1311 - style->stroke_green = shape->style.stroke_green; 1312 - if (shape->style.stroke_blue >= 0.0) 1313 - style->stroke_blue = shape->style.stroke_blue; 1314 - if (shape->style.stroke_opacity >= 0.0) 1315 - style->stroke_opacity = shape->style.stroke_opacity; 1316 - if (shape->style.clip_url != NULL) 1317 - { 1318 - gg_svg_add_clip_url (style, shape->style.clip_url); 1319 - style->clip_pointer = shape->style.clip_pointer; 1320 - } 1321 -/* final adjustements */ 1322 - if (style->fill < 0) 1323 - style->fill = 1; 1324 - if (style->stroke < 0) 1325 - style->stroke = 1; 1326 - if (style->no_fill < 0) 1327 - style->no_fill = 0; 1328 - if (style->no_stroke < 0) 1329 - style->no_stroke = 0; 1330 - if (style->fill_red < 0.0 && style->fill_green < 0.0 1331 - && style->fill_blue < 0.0 && style->fill_url == NULL) 1332 - style->no_fill = 1; 1333 - if (style->stroke_red < 0.0 && style->stroke_green < 0.0 1334 - && style->stroke_blue < 0.0 && style->stroke_url == NULL) 1335 - style->no_stroke = 1; 1336 - if (style->no_fill) 1337 - style->fill = 0; 1338 - if (style->no_stroke) 1339 - style->stroke = 0; 1340 - if (style->fill) 1341 - { 1342 - if (style->fill_rule < 0) 1343 - style->fill_rule = CAIRO_FILL_RULE_WINDING; 1344 - if (style->fill_red < 0.0 || style->fill_red > 1.0) 1345 - style->fill_red = 0.0; 1346 - if (style->fill_green < 0.0 || style->fill_green > 1.0) 1347 - style->fill_green = 0.0; 1348 - if (style->fill_blue < 0.0 || style->fill_blue > 1.0) 1349 - style->fill_blue = 0.0; 1350 - if (style->fill_opacity < 0.0 || style->fill_opacity > 1.0) 1351 - style->fill_opacity = 1.0; 1352 - } 1353 - if (style->stroke) 1354 - { 1355 - if (style->stroke_width <= 0.0) 1356 - style->stroke_width = 1.0; 1357 - if (style->stroke_linecap < 0) 1358 - style->stroke_linecap = CAIRO_LINE_CAP_BUTT; 1359 - if (style->stroke_linejoin < 0) 1360 - style->stroke_linejoin = CAIRO_LINE_JOIN_MITER; 1361 - if (style->stroke_miterlimit < 0) 1362 - style->stroke_miterlimit = 4.0; 1363 - if (style->stroke_red < 0.0 || style->stroke_red > 1.0) 1364 - style->stroke_red = 0.0; 1365 - if (style->stroke_green < 0.0 || style->stroke_green > 1.0) 1366 - style->stroke_green = 0.0; 1367 - if (style->stroke_blue < 0.0 || style->stroke_blue > 1.0) 1368 - style->stroke_blue = 0.0; 1369 - if (style->stroke_opacity < 0.0 || style->stroke_opacity > 1.0) 1370 - style->stroke_opacity = 1.0; 1371 - } 1372 - gg_svg_free_parents (&chain); 1373 -} 1374 - 1375 -static void 1376 -gg_svg_resolve_fill_url (struct gg_svg_document *svg_doc, 1377 - struct gg_svg_style *style) 1378 -{ 1379 -/* attempting to resolve a FillGradient by URL */ 1380 - struct gg_svg_gradient *gradient = svg_doc->first_grad; 1381 - while (gradient) 1382 - { 1383 - if (gradient->id != NULL) 1384 - { 1385 - if (strcmp (style->fill_url, gradient->id) == 0) 1386 - { 1387 - style->fill_pointer = gradient; 1388 - return; 1389 - } 1390 - } 1391 - gradient = gradient->next; 1392 - } 1393 - style->fill_pointer = NULL; 1394 - style->fill = 0; 1395 -} 1396 - 1397 -static void 1398 -gg_svg_resolve_stroke_url (struct gg_svg_document *svg_doc, 1399 - struct gg_svg_style *style) 1400 -{ 1401 -/* attempting to resolve a StrokeGradient by URL */ 1402 - struct gg_svg_gradient *gradient = svg_doc->first_grad; 1403 - while (gradient) 1404 - { 1405 - if (gradient->id != NULL) 1406 - { 1407 - if (strcmp (style->stroke_url, gradient->id) == 0) 1408 - { 1409 - style->stroke_pointer = gradient; 1410 - return; 1411 - } 1412 - } 1413 - gradient = gradient->next; 1414 - } 1415 - style->stroke_pointer = NULL; 1416 - style->stroke = 0; 1417 -} 1418 - 1419 -static void 1420 -gg_svg_apply_clip2 (cairo_t * cairo, struct gg_svg_item *clip_path) 1421 -{ 1422 -/* attempting to apply a ClipPath - actuation */ 1423 - struct gg_svg_group *group; 1424 - struct gg_svg_shape *shape; 1425 - struct gg_svg_clip *clip; 1426 - struct gg_svg_item *item = clip_path; 1427 - while (item) 1428 - { 1429 - /* looping on Items */ 1430 - if (item->type == GG_SVG_ITEM_SHAPE && item->pointer != NULL) 1431 - { 1432 - shape = item->pointer; 1433 - switch (shape->type) 1434 - { 1435 - case GG_SVG_RECT: 1436 - gg_svg_clip_rect (cairo, shape); 1437 - break; 1438 - case GG_SVG_CIRCLE: 1439 - gg_svg_clip_circle (cairo, shape); 1440 - break; 1441 - case GG_SVG_ELLIPSE: 1442 - gg_svg_clip_ellipse (cairo, shape); 1443 - break; 1444 - case GG_SVG_LINE: 1445 - gg_svg_clip_line (cairo, shape); 1446 - break; 1447 - case GG_SVG_POLYLINE: 1448 - gg_svg_clip_polyline (cairo, shape); 1449 - break; 1450 - case GG_SVG_POLYGON: 1451 - gg_svg_clip_polygon (cairo, shape); 1452 - break; 1453 - case GG_SVG_PATH: 1454 - gg_svg_clip_path (cairo, shape); 1455 - break; 1456 - }; 1457 - } 1458 - if (item->type == GG_SVG_ITEM_GROUP && item->pointer != NULL) 1459 - { 1460 - group = item->pointer; 1461 - gg_svg_apply_clip2 (cairo, group->first); 1462 - } 1463 - if (item->type == GG_SVG_ITEM_CLIP && item->pointer != NULL) 1464 - { 1465 - clip = item->pointer; 1466 - gg_svg_apply_clip2 (cairo, clip->first); 1467 - } 1468 - item = item->next; 1469 - } 1470 -} 1471 - 1472 -static void 1473 -gg_svg_apply_clip (cairo_t * cairo, struct gg_svg_item *item) 1474 -{ 1475 -/* attempting to apply a ClipPath */ 1476 - if (item->type == GG_SVG_ITEM_CLIP && item->pointer != NULL) 1477 - { 1478 - struct gg_svg_clip *clip = item->pointer; 1479 - gg_svg_apply_clip2 (cairo, clip->first); 1480 - } 1481 -} 1482 - 1483 -static void 1484 -gg_svg_render_item (cairo_t * cairo, struct gg_svg_document *svg_doc, 1485 - struct gg_svg_item *item) 1486 -{ 1487 -/* rendering all SVG Items */ 1488 - struct gg_svg_group *group; 1489 - struct gg_svg_shape *shape; 1490 - struct gg_svg_style style; 1491 - 1492 - while (item) 1493 - { 1494 - /* looping on Items */ 1495 - if (item->type == GG_SVG_ITEM_SHAPE && item->pointer != NULL) 1496 - { 1497 - shape = item->pointer; 1498 - if (shape->is_defs || shape->is_flow_root) 1499 - ; 1500 - else 1501 - { 1502 - gg_svg_apply_transformations (cairo, svg_doc, shape); 1503 - gg_svg_apply_style (shape, &style); 1504 - if (style.visibility) 1505 - { 1506 - if (style.fill_url != NULL) 1507 - gg_svg_resolve_fill_url (svg_doc, &style); 1508 - if (style.stroke_url != NULL) 1509 - gg_svg_resolve_stroke_url (svg_doc, &style); 1510 - if (style.clip_url != NULL 1511 - && style.clip_pointer != NULL) 1512 - gg_svg_apply_clip (cairo, style.clip_pointer); 1513 - gg_svg_draw_shape (cairo, shape, &style); 1514 - cairo_reset_clip (cairo); 1515 - } 1516 - if (style.fill_url != NULL) 1517 - free (style.fill_url); 1518 - if (style.stroke_url != NULL) 1519 - free (style.stroke_url); 1520 - if (style.clip_url != NULL) 1521 - free (style.clip_url); 1522 - } 1523 - } 1524 - if (item->type == GG_SVG_ITEM_GROUP && item->pointer != NULL) 1525 - { 1526 - group = item->pointer; 1527 - if (group->is_defs || group->is_flow_root) 1528 - ; 1529 - else 1530 - gg_svg_render_item (cairo, svg_doc, group->first); 1531 - } 1532 - item = item->next; 1533 - } 1534 -} 1535 - 1536 -static void 1537 -gg_svg_find_href (struct gg_svg_document *svg_doc, struct gg_svg_item *item, 1538 - const char *href, struct gg_svg_item **pointer) 1539 -{ 1540 -/* attempting to recursively resolve an xlink:href reference */ 1541 - struct gg_svg_group *group; 1542 - struct gg_svg_shape *shape; 1543 - 1544 - while (item) 1545 - { 1546 - /* looping on Items */ 1547 - if (item->type == GG_SVG_ITEM_SHAPE && item->pointer != NULL) 1548 - { 1549 - shape = item->pointer; 1550 - if (shape->id != NULL) 1551 - { 1552 - if (strcmp (shape->id, href + 1) == 0) 1553 - { 1554 - *pointer = item; 1555 - return; 1556 - } 1557 - } 1558 - } 1559 - if (item->type == GG_SVG_ITEM_GROUP && item->pointer != NULL) 1560 - { 1561 - group = item->pointer; 1562 - if (group->id != NULL) 1563 - { 1564 - if (strcmp (group->id, href + 1) == 0) 1565 - { 1566 - *pointer = item; 1567 - return; 1568 - } 1569 - } 1570 - gg_svg_find_href (svg_doc, group->first, href, pointer); 1571 - } 1572 - item = item->next; 1573 - } 1574 -} 1575 - 1576 -static void 1577 -gg_svg_replace_use (struct gg_svg_item *item, struct gg_svg_item *repl) 1578 -{ 1579 -/* replacing an Use with the corrensponding resolved item */ 1580 - struct gg_svg_use *use = item->pointer; 1581 - 1582 - if (repl->type == GG_SVG_ITEM_SHAPE && repl->pointer) 1583 - { 1584 - struct gg_svg_shape *shape = repl->pointer; 1585 - item->pointer = gg_svg_clone_shape (shape, use); 1586 - item->type = GG_SVG_ITEM_SHAPE; 1587 - } 1588 - if (repl->type == GG_SVG_ITEM_GROUP && repl->pointer) 1589 - { 1590 - struct gg_svg_group *group = repl->pointer; 1591 - item->pointer = gg_svg_clone_group (group, use); 1592 - item->type = GG_SVG_ITEM_GROUP; 1593 - } 1594 - gg_svg_free_use (use); 1595 -} 1596 - 1597 -static void 1598 -gg_svg_find_gradient_href (struct gg_svg_document *svg_doc, const char *href, 1599 - struct gg_svg_gradient **pointer) 1600 -{ 1601 -/* attempting to recursively resolve an xlink:href reference (Gradients) */ 1602 - struct gg_svg_gradient *grad = svg_doc->first_grad; 1603 - 1604 - while (grad) 1605 - { 1606 - /* looping on Gradients */ 1607 - if (strcmp (grad->id, href + 1) == 0) 1608 - { 1609 - *pointer = grad; 1610 - return; 1611 - } 1612 - grad = grad->next; 1613 - } 1614 -} 1615 - 1616 -static struct gg_svg_gradient * 1617 -gg_svg_replace_gradient (struct gg_svg_document *svg_doc, 1618 - struct gg_svg_gradient *gradient, 1619 - struct gg_svg_gradient *repl) 1620 -{ 1621 -/* replacing a Gradient with the corrensponding resolved item */ 1622 - struct gg_svg_gradient *new_grad = gg_svg_clone_gradient (repl, gradient); 1623 - new_grad->prev = gradient->prev; 1624 - new_grad->next = gradient->next; 1625 - if (gradient->prev != NULL) 1626 - gradient->prev->next = new_grad; 1627 - if (gradient->next != NULL) 1628 - gradient->next->prev = new_grad; 1629 - if (svg_doc->first_grad == gradient) 1630 - svg_doc->first_grad = new_grad; 1631 - if (svg_doc->last_grad == gradient) 1632 - svg_doc->last_grad = new_grad; 1633 - gg_svg_free_gradient (gradient); 1634 - return new_grad; 1635 -} 1636 - 1637 -static void 1638 -gg_svg_resolve_gradients_xlink_href (struct gg_svg_document *svg_doc) 1639 -{ 1640 -/* resolving any indirect reference: Gradient xlink:href */ 1641 - struct gg_svg_gradient *grad = svg_doc->first_grad; 1642 - struct gg_svg_gradient *ret; 1643 - 1644 - while (grad) 1645 - { 1646 - /* looping on Gradients */ 1647 - if (grad->xlink_href != NULL) 1648 - { 1649 - gg_svg_find_gradient_href (svg_doc, grad->xlink_href, &ret); 1650 - if (ret != NULL) 1651 - grad = gg_svg_replace_gradient (svg_doc, grad, ret); 1652 - } 1653 - grad = grad->next; 1654 - } 1655 -} 1656 - 1657 -static void 1658 -gg_svg_resolve_xlink_href (struct gg_svg_document *svg_doc, 1659 - struct gg_svg_item *item) 1660 -{ 1661 -/* recursively resolving any indirect reference: xlink:href */ 1662 - struct gg_svg_group *group; 1663 - struct gg_svg_use *use; 1664 - struct gg_svg_clip *clip; 1665 - struct gg_svg_item *ret; 1666 - 1667 - while (item) 1668 - { 1669 - /* looping on Items */ 1670 - if (item->type == GG_SVG_ITEM_USE && item->pointer != NULL) 1671 - { 1672 - use = item->pointer; 1673 - gg_svg_find_href (svg_doc, svg_doc->first, use->xlink_href, 1674 - &ret); 1675 - if (ret != NULL) 1676 - gg_svg_replace_use (item, ret); 1677 - } 1678 - if (item->type == GG_SVG_ITEM_GROUP && item->pointer != NULL) 1679 - { 1680 - group = item->pointer; 1681 - gg_svg_resolve_xlink_href (svg_doc, group->first); 1682 - } 1683 - if (item->type == GG_SVG_ITEM_CLIP && item->pointer != NULL) 1684 - { 1685 - clip = item->pointer; 1686 - gg_svg_resolve_xlink_href (svg_doc, clip->first); 1687 - } 1688 - item = item->next; 1689 - } 1690 -} 1691 - 1692 -static void 1693 -gg_svg_find_clip_href (struct gg_svg_document *svg_doc, 1694 - struct gg_svg_item *item, const char *href, 1695 - struct gg_svg_item **pointer) 1696 -{ 1697 -/* attempting to recursively resolve an xlink:href reference (ClipPath) */ 1698 - 1699 - struct gg_svg_group *group; 1700 - struct gg_svg_clip *clip; 1701 - 1702 - while (item) 1703 - { 1704 - /* looping on Items */ 1705 - if (item->type == GG_SVG_ITEM_CLIP && item->pointer != NULL) 1706 - { 1707 - clip = item->pointer; 1708 - if (clip->id != NULL) 1709 - { 1710 - if (strcmp (clip->id, href) == 0) 1711 - { 1712 - *pointer = item; 1713 - return; 1714 - } 1715 - } 1716 - } 1717 - if (item->type == GG_SVG_ITEM_GROUP && item->pointer != NULL) 1718 - { 1719 - group = item->pointer; 1720 - if (group->id != NULL) 1721 - { 1722 - if (strcmp (group->id, href + 1) == 0) 1723 - { 1724 - *pointer = item; 1725 - return; 1726 - } 1727 - } 1728 - gg_svg_find_clip_href (svg_doc, group->first, href, pointer); 1729 - } 1730 - item = item->next; 1731 - } 1732 -} 1733 - 1734 -static void 1735 -gg_svg_resolve_clip_xlink_href (struct gg_svg_document *svg_doc, 1736 - struct gg_svg_item *item) 1737 -{ 1738 -/* recursively resolving any indirect reference: ClipPath url */ 1739 - struct gg_svg_group *group; 1740 - struct gg_svg_shape *shape; 1741 - struct gg_svg_use *use; 1742 - struct gg_svg_item *ret = NULL; 1743 - 1744 - while (item) 1745 - { 1746 - /* looping on Items */ 1747 - if (item->type == GG_SVG_ITEM_USE && item->pointer != NULL) 1748 - { 1749 - use = item->pointer; 1750 - if (use->style.clip_url != NULL) 1751 - { 1752 - gg_svg_find_clip_href (svg_doc, svg_doc->first, 1753 - use->style.clip_url, &ret); 1754 - if (ret != NULL) 1755 - use->style.clip_pointer = ret; 1756 - } 1757 - } 1758 - if (item->type == GG_SVG_ITEM_SHAPE && item->pointer != NULL) 1759 - { 1760 - shape = item->pointer; 1761 - if (shape->style.clip_url != NULL) 1762 - { 1763 - gg_svg_find_clip_href (svg_doc, svg_doc->first, 1764 - shape->style.clip_url, &ret); 1765 - if (ret != NULL) 1766 - shape->style.clip_pointer = ret; 1767 - } 1768 - } 1769 - if (item->type == GG_SVG_ITEM_GROUP && item->pointer != NULL) 1770 - { 1771 - group = item->pointer; 1772 - if (group->style.clip_url != NULL) 1773 - { 1774 - gg_svg_find_clip_href (svg_doc, svg_doc->first, 1775 - group->style.clip_url, &ret); 1776 - if (ret != NULL) 1777 - group->style.clip_pointer = ret; 1778 - } 1779 - gg_svg_resolve_clip_xlink_href (svg_doc, group->first); 1780 - } 1781 - item = item->next; 1782 - } 1783 -} 1784 - 1785 -static int 1786 -gg_svg_to_img (const void **img_out, int size, struct gg_svg_document *svg_doc) 1787 -{ 1788 -/* rendering an SVG document as an RGBA image */ 1789 - cairo_surface_t *surface; 1790 - cairo_t *cairo; 1791 - double ratio_x; 1792 - double ratio_y; 1793 - double width; 1794 - double height; 1795 - double shift_x; 1796 - double shift_y; 1797 - int ret = 1; 1798 - gGraphImagePtr img = NULL; 1799 - int w; 1800 - int h; 1801 - int x; 1802 - int y; 1803 - const unsigned char *in_buf; 1804 - unsigned char *out_buf = NULL; 1805 - 1806 - if (svg_doc->viewbox_x != DBL_MIN && svg_doc->viewbox_y != DBL_MIN 1807 - && svg_doc->viewbox_width != DBL_MIN 1808 - && svg_doc->viewbox_height != DBL_MIN) 1809 - { 1810 - /* setting the SVG dimensions from the ViewBox */ 1811 - if (svg_doc->width <= 0) 1812 - svg_doc->width = svg_doc->viewbox_width; 1813 - if (svg_doc->height <= 0) 1814 - svg_doc->height = svg_doc->viewbox_height; 1815 - } 1816 - else 1817 - { 1818 - /* setting the ViewBox from the SVG dimensions */ 1819 - svg_doc->viewbox_x = 0.0; 1820 - svg_doc->viewbox_y = 0.0; 1821 - svg_doc->viewbox_width = svg_doc->width; 1822 - svg_doc->viewbox_height = svg_doc->height; 1823 - } 1824 - if (svg_doc->width <= 0.0 || svg_doc->height <= 0.0) 1825 - return 0; 1826 - 1827 -/* setting the image dimensions */ 1828 - ratio_x = svg_doc->width / (double) size; 1829 - ratio_y = svg_doc->height / (double) size; 1830 - if (ratio_x > ratio_y) 1831 - { 1832 - width = svg_doc->width / ratio_x; 1833 - height = svg_doc->height / ratio_x; 1834 - } 1835 - else 1836 - { 1837 - width = svg_doc->width / ratio_y; 1838 - height = svg_doc->height / ratio_y; 1839 - } 1840 - 1841 - surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); 1842 - if (cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS) 1843 - ; 1844 - else 1845 - return 0; 1846 - cairo = cairo_create (surface); 1847 - if (cairo_status (cairo) == CAIRO_STATUS_NO_MEMORY) 1848 - { 1849 - fprintf (stderr, "CAIRO reports: Insufficient Memory\n"); 1850 - ret = 0; 1851 - goto stop; 1852 - } 1853 - 1854 -/* priming a transparent background */ 1855 - cairo_rectangle (cairo, 0, 0, width, height); 1856 - cairo_set_source_rgba (cairo, 0.0, 0.0, 0.0, 0.0); 1857 - cairo_fill (cairo); 1858 -/* setting the basic document matrix */ 1859 - svg_doc->matrix.xx = 1.0; 1860 - svg_doc->matrix.yx = 0.0; 1861 - svg_doc->matrix.xy = 0.0; 1862 - svg_doc->matrix.yy = 1.0; 1863 - svg_doc->matrix.x0 = 0.0; 1864 - svg_doc->matrix.y0 = 0.0; 1865 - ratio_x = width / svg_doc->viewbox_width; 1866 - ratio_y = height / svg_doc->viewbox_height; 1867 - cairo_matrix_scale (&(svg_doc->matrix), ratio_x, ratio_y); 1868 - shift_x = -1 * svg_doc->viewbox_x; 1869 - shift_y = -1 * svg_doc->viewbox_y; 1870 - cairo_matrix_translate (&(svg_doc->matrix), shift_x, shift_y); 1871 - 1872 -/* resolving any xlink:href */ 1873 - gg_svg_resolve_gradients_xlink_href (svg_doc); 1874 - gg_svg_resolve_clip_xlink_href (svg_doc, svg_doc->first); 1875 - gg_svg_resolve_xlink_href (svg_doc, svg_doc->first); 1876 - 1877 -/* recursively rendering all SVG Items */ 1878 - gg_svg_render_item (cairo, svg_doc, svg_doc->first); 1879 - 1880 -/* accessing the CairoSurface buffer */ 1881 - w = cairo_image_surface_get_width (surface); 1882 - h = cairo_image_surface_get_height (surface); 1883 - cairo_surface_flush (surface); 1884 - in_buf = cairo_image_surface_get_data (surface); 1885 - if (in_buf == NULL) 1886 - { 1887 - ret = 0; 1888 - goto stop; 1889 - } 1890 - 1891 -/* creating the Image buffer */ 1892 - out_buf = malloc (h * w * 4); 1893 - if (out_buf == NULL) 1894 - { 1895 - ret = 0; 1896 - goto stop; 1897 - } 1898 - for (y = 0; y < h; y++) 1899 - { 1900 - /* looping on lines */ double multiplier; 1901 - double r; 1902 - double g; 1903 - double b; 1904 - const unsigned char *p_in = in_buf + (y * w * 4); 1905 - unsigned char *p_out = out_buf + (y * w * 4); 1906 - for (x = 0; x < w; x++) 1907 - { 1908 - /* looping on columns */ 1909 - unsigned char alpha; 1910 - unsigned char red; 1911 - unsigned char green; 1912 - unsigned char blue; 1913 - if (gg_endian_arch ()) 1914 - { 1915 - /* little endian byte order */ 1916 - alpha = *(p_in + 3); 1917 - red = *(p_in + 2); 1918 - green = *(p_in + 1); 1919 - blue = *(p_in + 0); 1920 - } 1921 - else 1922 - { 1923 - /* big endian byte order */ 1924 - alpha = *(p_in + 0); 1925 - red = *(p_in + 1); 1926 - green = *(p_in + 2); 1927 - blue = *(p_in + 3); 1928 - } 1929 - /* Cairo colors are pre-multiplied; normalizing */ 1930 - multiplier = 255.0 / (double) alpha; 1931 - r = (double) red *multiplier; 1932 - g = (double) green *multiplier; 1933 - b = (double) blue *multiplier; 1934 - if (r < 0.0) 1935 - red = 0; 1936 - else if (r > 255.0) 1937 - red = 255; 1938 - else 1939 - red = r; 1940 - if (g < 0.0) 1941 - green = 0; 1942 - else if (g > 255.0) 1943 - green = 255; 1944 - else 1945 - green = g; 1946 - if (b < 0.0) 1947 - blue = 0; 1948 - else if (b > 255.0) 1949 - blue = 255; 1950 - else 1951 - blue = b; 1952 - *(p_out + 0) = red; 1953 - *(p_out + 1) = green; 1954 - *(p_out + 2) = blue; 1955 - *(p_out + 3) = alpha; 1956 - p_in += 4; 1957 - p_out += 4; 1958 - } 1959 - } 1960 - 1961 -/* creating the output image */ 1962 - img = 1963 - gg_image_create_from_bitmap (out_buf, GG_PIXEL_RGBA, w, h, 8, 4, 1964 - GGRAPH_SAMPLE_UINT, NULL, NULL); 1965 -/* releasing ownership on output buffer */ 1966 - out_buf = NULL; 1967 - 1968 - stop: 1969 - if (out_buf != NULL) 1970 - free (out_buf); 1971 - cairo_surface_destroy (surface); 1972 - cairo_destroy (cairo); 1973 - *img_out = img; 1974 - return ret; 1975 -} 1976 - 1977 -GGRAPH_DECLARE int 1978 -gGraphCreateSVG (const unsigned char *svg, int svg_bytes, void **svg_handle) 1979 -{ 1980 -/* parsing the SVG Document and returning an opaque handle */ 1981 - struct gg_svg_document *svg_doc; 1982 - 1983 - *svg_handle = NULL; 1984 - svg_doc = gg_svg_parse_doc (svg, svg_bytes); 1985 - if (svg_doc == NULL) 1986 - { 1987 - /* unable to parse the SVG Document */ 1988 - return GGRAPH_INVALID_SVG; 1989 - } 1990 - *svg_handle = svg_doc; 1991 - return GGRAPH_OK; 1992 -} 1993 - 1994 -GGRAPH_DECLARE int 1995 -gGraphGetSVGDims (void *svg_handle, double *width, double *height) 1996 -{ 1997 -/* destroying the SVG document */ 1998 - struct gg_svg_document *svg_doc = (struct gg_svg_document *) svg_handle; 1999 - if (svg_doc == NULL) 2000 - return GGRAPH_INVALID_SVG; 2001 - if (svg_doc->signature != GG_GRAPHICS_SVG_MAGIC_SIGNATURE) 2002 - return GGRAPH_INVALID_SVG; 2003 - *width = svg_doc->width; 2004 - *height = svg_doc->height; 2005 - return GGRAPH_OK; 2006 -} 2007 - 2008 -GGRAPH_DECLARE int 2009 -gGraphFreeSVG (void *svg_handle) 2010 -{ 2011 -/* parsing the SVG Document */ 2012 - struct gg_svg_document *svg_doc = (struct gg_svg_document *) svg_handle; 2013 - if (svg_doc == NULL) 2014 - return GGRAPH_INVALID_SVG; 2015 - if (svg_doc->signature != GG_GRAPHICS_SVG_MAGIC_SIGNATURE) 2016 - return GGRAPH_INVALID_SVG; 2017 - gg_svg_free_document (svg_doc); 2018 - return GGRAPH_OK; 2019 -} 2020 - 2021 -GGRAPH_DECLARE int 2022 -gGraphImageFromSVG (void *svg_handle, double size, const void **img_out) 2023 -{ 2024 -/* rendering the SVG Document into a raster image */ 2025 - struct gg_svg_document *svg_doc = (struct gg_svg_document *) svg_handle; 2026 - if (svg_doc == NULL) 2027 - return GGRAPH_INVALID_SVG; 2028 - if (svg_doc->signature != GG_GRAPHICS_SVG_MAGIC_SIGNATURE) 2029 - return GGRAPH_INVALID_SVG; 2030 -/* SVG image rendering */ 2031 - if (!gg_svg_to_img (img_out, size, svg_doc)) 2032 - { 2033 - gg_svg_free_document (svg_doc); 2034 - return GGRAPH_INVALID_SVG; 2035 - } 2036 - return GGRAPH_OK; 2037 -}
Deleted src/gaiagraphics_svg_aux.c.
1 -/* 2 -/ gaiagraphics_svg_aux.c 3 -/ 4 -/ SVG auxiliary methods 5 -/ 6 -/ version 1.0, 2013 February 10 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2013 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdlib.h> 28 -#include <stdio.h> 29 -#include <string.h> 30 -#include <math.h> 31 -#include <float.h> 32 - 33 -#include "gaiagraphics.h" 34 -#include "gaiagraphics_internals.h" 35 - 36 -GGRAPH_PRIVATE void 37 -gg_svg_free_transform (struct gg_svg_transform *p) 38 -{ 39 -/* freeing an SVG Transform */ 40 - if (p == NULL) 41 - return; 42 - if (p->data != NULL) 43 - free (p->data); 44 - free (p); 45 -} 46 - 47 -GGRAPH_PRIVATE void 48 -gg_svg_free_polyline (struct gg_svg_polyline *p) 49 -{ 50 -/* freeing an SVG Polyline */ 51 - if (p == NULL) 52 - return; 53 - if (p->x != NULL) 54 - free (p->x); 55 - if (p->y != NULL) 56 - free (p->y); 57 - free (p); 58 -} 59 - 60 -GGRAPH_PRIVATE void 61 -gg_svg_free_polygon (struct gg_svg_polygon *p) 62 -{ 63 -/* freeing an SVG Polygon */ 64 - if (p == NULL) 65 - return; 66 - if (p->x != NULL) 67 - free (p->x); 68 - if (p->y != NULL) 69 - free (p->y); 70 - free (p); 71 -} 72 - 73 -GGRAPH_PRIVATE void 74 -gg_svg_free_path_item (struct gg_svg_path_item *p) 75 -{ 76 -/* freeing an SVG Path item */ 77 - if (p == NULL) 78 - return; 79 - if (p->data != NULL) 80 - free (p->data); 81 - free (p); 82 -} 83 - 84 -GGRAPH_PRIVATE void 85 -gg_svg_free_path (struct gg_svg_path *p) 86 -{ 87 -/* freeing an SVG Path */ 88 - struct gg_svg_path_item *pp; 89 - struct gg_svg_path_item *ppn; 90 - if (p == NULL) 91 - return; 92 - pp = p->first; 93 - while (pp != NULL) 94 - { 95 - ppn = pp->next; 96 - gg_svg_free_path_item (pp); 97 - pp = ppn; 98 - } 99 - free (p); 100 -} 101 - 102 -GGRAPH_PRIVATE void 103 -gg_svg_free_shape (struct gg_svg_shape *p) 104 -{ 105 -/* freeing an SVG Shape */ 106 - struct gg_svg_transform *ptn; 107 - struct gg_svg_transform *pt = p->first_trans; 108 - if (p->id != NULL) 109 - free (p->id); 110 - while (pt) 111 - { 112 - ptn = pt->next; 113 - gg_svg_free_transform (pt); 114 - pt = ptn; 115 - } 116 - switch (p->type) 117 - { 118 - case GG_SVG_POLYLINE: 119 - gg_svg_free_polyline (p->data); 120 - break; 121 - case GG_SVG_POLYGON: 122 - gg_svg_free_polygon (p->data); 123 - break; 124 - case GG_SVG_PATH: 125 - gg_svg_free_path (p->data); 126 - break; 127 - default: 128 - if (p->data) 129 - free (p->data); 130 - break; 131 - }; 132 - if (p->style.stroke_dasharray != NULL) 133 - free (p->style.stroke_dasharray); 134 - if (p->style.fill_url != NULL) 135 - free (p->style.fill_url); 136 - if (p->style.stroke_url != NULL) 137 - free (p->style.stroke_url); 138 - if (p->style.clip_url != NULL) 139 - free (p->style.clip_url); 140 - free (p); 141 -} 142 - 143 -GGRAPH_PRIVATE void 144 -gg_svg_free_use (struct gg_svg_use *p) 145 -{ 146 -/* freeing an SVG Use (xlink:href) */ 147 - struct gg_svg_transform *pt; 148 - struct gg_svg_transform *ptn; 149 - if (p->xlink_href != NULL) 150 - free (p->xlink_href); 151 - pt = p->first_trans; 152 - while (pt) 153 - { 154 - ptn = pt->next; 155 - gg_svg_free_transform (pt); 156 - pt = ptn; 157 - } 158 - if (p->style.stroke_dasharray != NULL) 159 - free (p->style.stroke_dasharray); 160 - if (p->style.fill_url != NULL) 161 - free (p->style.fill_url); 162 - if (p->style.stroke_url != NULL) 163 - free (p->style.stroke_url); 164 - if (p->style.clip_url != NULL) 165 - free (p->style.clip_url); 166 - free (p); 167 -} 168 - 169 -GGRAPH_PRIVATE void 170 -gg_svg_free_item (struct gg_svg_item *p) 171 -{ 172 -/* freeing an SVG Item */ 173 - if (p->type == GG_SVG_ITEM_GROUP) 174 - gg_svg_free_group ((struct gg_svg_group *) (p->pointer)); 175 - if (p->type == GG_SVG_ITEM_SHAPE) 176 - gg_svg_free_shape ((struct gg_svg_shape *) (p->pointer)); 177 - if (p->type == GG_SVG_ITEM_CLIP) 178 - gg_svg_free_clip ((struct gg_svg_clip *) (p->pointer)); 179 - free (p); 180 -} 181 - 182 -GGRAPH_PRIVATE void 183 -gg_svg_free_clip (struct gg_svg_clip *p) 184 -{ 185 -/* freeing an SVG Clip */ 186 - struct gg_svg_item *pi; 187 - struct gg_svg_item *pin; 188 - if (p->id != NULL) 189 - free (p->id); 190 - pi = p->first; 191 - while (pi) 192 - { 193 - pin = pi->next; 194 - gg_svg_free_item (pi); 195 - pi = pin; 196 - } 197 - free (p); 198 -} 199 - 200 -GGRAPH_PRIVATE void 201 -gg_svg_free_group (struct gg_svg_group *p) 202 -{ 203 -/* freeing an SVG Group <g> */ 204 - struct gg_svg_item *pi; 205 - struct gg_svg_item *pin; 206 - struct gg_svg_transform *pt; 207 - struct gg_svg_transform *ptn; 208 - if (p->id != NULL) 209 - free (p->id); 210 - pi = p->first; 211 - while (pi) 212 - { 213 - pin = pi->next; 214 - gg_svg_free_item (pi); 215 - pi = pin; 216 - } 217 - pt = p->first_trans; 218 - while (pt) 219 - { 220 - ptn = pt->next; 221 - gg_svg_free_transform (pt); 222 - pt = ptn; 223 - } 224 - if (p->style.stroke_dasharray != NULL) 225 - free (p->style.stroke_dasharray); 226 - if (p->style.fill_url != NULL) 227 - free (p->style.fill_url); 228 - if (p->style.stroke_url != NULL) 229 - free (p->style.stroke_url); 230 - if (p->style.clip_url != NULL) 231 - free (p->style.clip_url); 232 - free (p); 233 -} 234 - 235 -GGRAPH_PRIVATE void 236 -gg_svg_free_gradient_stop (struct gg_svg_gradient_stop *p) 237 -{ 238 -/* freeing an SVG GradientStop */ 239 - free (p); 240 -} 241 - 242 -GGRAPH_PRIVATE void 243 -gg_svg_free_gradient (struct gg_svg_gradient *p) 244 -{ 245 -/* freeing an SVG Gradient */ 246 - struct gg_svg_transform *pt; 247 - struct gg_svg_transform *ptn; 248 - struct gg_svg_gradient_stop *ps; 249 - struct gg_svg_gradient_stop *psn; 250 - if (p->id != NULL) 251 - free (p->id); 252 - if (p->xlink_href != NULL) 253 - free (p->xlink_href); 254 - pt = p->first_trans; 255 - while (pt) 256 - { 257 - ptn = pt->next; 258 - gg_svg_free_transform (pt); 259 - pt = ptn; 260 - } 261 - ps = p->first_stop; 262 - while (ps) 263 - { 264 - psn = ps->next; 265 - gg_svg_free_gradient_stop (ps); 266 - ps = psn; 267 - } 268 - free (p); 269 -} 270 - 271 -GGRAPH_PRIVATE void 272 -gg_svg_free_document (struct gg_svg_document *p) 273 -{ 274 -/* freeing an SVG Document */ 275 - struct gg_svg_item *pi; 276 - struct gg_svg_item *pin; 277 - struct gg_svg_gradient *pg; 278 - struct gg_svg_gradient *pgn; 279 - pi = p->first; 280 - while (pi) 281 - { 282 - pin = pi->next; 283 - if (pi->type == GG_SVG_ITEM_GROUP) 284 - gg_svg_free_group ((struct gg_svg_group *) (pi->pointer)); 285 - if (pi->type == GG_SVG_ITEM_SHAPE) 286 - gg_svg_free_shape ((struct gg_svg_shape *) (pi->pointer)); 287 - if (pi->type == GG_SVG_ITEM_USE) 288 - gg_svg_free_use ((struct gg_svg_use *) (pi->pointer)); 289 - if (pi->type == GG_SVG_ITEM_CLIP) 290 - gg_svg_free_clip ((struct gg_svg_clip *) (pi->pointer)); 291 - free (pi); 292 - pi = pin; 293 - } 294 - pg = p->first_grad; 295 - while (pg) 296 - { 297 - pgn = pg->next; 298 - gg_svg_free_gradient (pg); 299 - pg = pgn; 300 - } 301 - free (p); 302 -} 303 - 304 -GGRAPH_PRIVATE struct gg_svg_matrix * 305 -gg_svg_alloc_matrix (double a, double b, double c, double d, double e, double f) 306 -{ 307 -/* allocating and initializing an SVG Matrix */ 308 - struct gg_svg_matrix *p = malloc (sizeof (struct gg_svg_matrix)); 309 - p->a = a; 310 - p->b = b; 311 - p->c = c; 312 - p->d = d; 313 - p->e = e; 314 - p->f = f; 315 - return p; 316 -} 317 - 318 -GGRAPH_PRIVATE struct gg_svg_matrix * 319 -gg_svg_clone_matrix (struct gg_svg_matrix *in) 320 -{ 321 -/* cloning an SVG Matrix */ 322 - struct gg_svg_matrix *p = malloc (sizeof (struct gg_svg_matrix)); 323 - p->a = in->a; 324 - p->b = in->b; 325 - p->c = in->c; 326 - p->d = in->d; 327 - p->e = in->e; 328 - p->f = in->f; 329 - return p; 330 -} 331 - 332 -GGRAPH_PRIVATE struct gg_svg_translate * 333 -gg_svg_alloc_translate (double tx, double ty) 334 -{ 335 -/* allocating and initializing an SVG Translate */ 336 - struct gg_svg_translate *p = malloc (sizeof (struct gg_svg_translate)); 337 - p->tx = tx; 338 - p->ty = ty; 339 - return p; 340 -} 341 - 342 -GGRAPH_PRIVATE struct gg_svg_translate * 343 -gg_svg_clone_translate (struct gg_svg_translate *in) 344 -{ 345 -/* cloning an SVG Translate */ 346 - struct gg_svg_translate *p = malloc (sizeof (struct gg_svg_translate)); 347 - p->tx = in->tx; 348 - p->ty = in->ty; 349 - return p; 350 -} 351 - 352 -GGRAPH_PRIVATE struct gg_svg_scale * 353 -gg_svg_alloc_scale (double sx, double sy) 354 -{ 355 -/* allocating and initializing an SVG Scale */ 356 - struct gg_svg_scale *p = malloc (sizeof (struct gg_svg_scale)); 357 - p->sx = sx; 358 - p->sy = sy; 359 - return p; 360 -} 361 - 362 -GGRAPH_PRIVATE struct gg_svg_scale * 363 -gg_svg_clone_scale (struct gg_svg_scale *in) 364 -{ 365 -/* cloning an SVG Scale */ 366 - struct gg_svg_scale *p = malloc (sizeof (struct gg_svg_scale)); 367 - p->sx = in->sx; 368 - p->sy = in->sy; 369 - return p; 370 -} 371 - 372 -GGRAPH_PRIVATE struct gg_svg_rotate * 373 -gg_svg_alloc_rotate (double angle, double cx, double cy) 374 -{ 375 -/* allocating and initializing an SVG Scale */ 376 - struct gg_svg_rotate *p = malloc (sizeof (struct gg_svg_rotate)); 377 - p->angle = angle; 378 - p->cx = cx; 379 - p->cy = cy; 380 - return p; 381 -} 382 - 383 -GGRAPH_PRIVATE struct gg_svg_rotate * 384 -gg_svg_clone_rotate (struct gg_svg_rotate *in) 385 -{ 386 -/* cloning an SVG Scale */ 387 - struct gg_svg_rotate *p = malloc (sizeof (struct gg_svg_rotate)); 388 - p->angle = in->angle; 389 - p->cx = in->cx; 390 - p->cy = in->cy; 391 - return p; 392 -} 393 - 394 -GGRAPH_PRIVATE struct gg_svg_skew * 395 -gg_svg_alloc_skew (double angle) 396 -{ 397 -/* allocating and initializing an SVG Skew */ 398 - struct gg_svg_skew *p = malloc (sizeof (struct gg_svg_skew)); 399 - p->angle = angle; 400 - return p; 401 -} 402 - 403 -GGRAPH_PRIVATE struct gg_svg_skew * 404 -gg_svg_clone_skew (struct gg_svg_skew *in) 405 -{ 406 -/* cloning an SVG Skew */ 407 - struct gg_svg_skew *p = malloc (sizeof (struct gg_svg_skew)); 408 - p->angle = in->angle; 409 - return p; 410 -} 411 - 412 -GGRAPH_PRIVATE struct gg_svg_transform * 413 -gg_svg_alloc_transform (int type, void *data) 414 -{ 415 -/* allocating and initializing an empty SVG Transform */ 416 - struct gg_svg_transform *p = malloc (sizeof (struct gg_svg_transform)); 417 - p->type = type; 418 - p->data = data; 419 - p->next = NULL; 420 - return p; 421 -} 422 - 423 -GGRAPH_PRIVATE struct gg_svg_transform * 424 -gg_svg_clone_transform (struct gg_svg_transform *in) 425 -{ 426 -/* cloning SVG Transform */ 427 - struct gg_svg_matrix *matrix; 428 - struct gg_svg_translate *translate; 429 - struct gg_svg_scale *scale; 430 - struct gg_svg_rotate *rotate; 431 - struct gg_svg_skew *skew; 432 - struct gg_svg_transform *p = malloc (sizeof (struct gg_svg_transform)); 433 - p->type = in->type; 434 - switch (in->type) 435 - { 436 - case GG_SVG_MATRIX: 437 - matrix = in->data; 438 - p->data = gg_svg_clone_matrix (matrix); 439 - break; 440 - case GG_SVG_TRANSLATE: 441 - translate = in->data; 442 - p->data = gg_svg_clone_translate (translate); 443 - break; 444 - case GG_SVG_SCALE: 445 - scale = in->data; 446 - p->data = gg_svg_clone_scale (scale); 447 - break; 448 - case GG_SVG_ROTATE: 449 - rotate = in->data; 450 - p->data = gg_svg_clone_rotate (rotate); 451 - break; 452 - case GG_SVG_SKEW_X: 453 - case GG_SVG_SKEW_Y: 454 - skew = in->data; 455 - p->data = gg_svg_clone_skew (skew); 456 - break; 457 - }; 458 - p->next = NULL; 459 - return p; 460 -} 461 - 462 -GGRAPH_PRIVATE struct gg_svg_rect * 463 -gg_svg_alloc_rect (double x, double y, double width, double height, double rx, 464 - double ry) 465 -{ 466 -/* allocating and initializing an SVG Rect */ 467 - struct gg_svg_rect *p = malloc (sizeof (struct gg_svg_rect)); 468 - p->x = x; 469 - p->y = y; 470 - p->width = width; 471 - p->height = height; 472 - p->rx = rx; 473 - p->ry = ry; 474 - return p; 475 -} 476 - 477 -GGRAPH_PRIVATE struct gg_svg_rect * 478 -gg_svg_clone_rect (struct gg_svg_rect *in) 479 -{ 480 -/* cloning an SVG Rect */ 481 - struct gg_svg_rect *p = malloc (sizeof (struct gg_svg_rect)); 482 - p->x = in->x; 483 - p->y = in->y; 484 - p->width = in->width; 485 - p->height = in->height; 486 - p->rx = in->rx; 487 - p->ry = in->ry; 488 - return p; 489 -} 490 - 491 -GGRAPH_PRIVATE struct gg_svg_circle * 492 -gg_svg_alloc_circle (double cx, double cy, double r) 493 -{ 494 -/* allocating and initializing an SVG Circle */ 495 - struct gg_svg_circle *p = malloc (sizeof (struct gg_svg_circle)); 496 - p->cx = cx; 497 - p->cy = cy; 498 - p->r = r; 499 - return p; 500 -} 501 - 502 -GGRAPH_PRIVATE struct gg_svg_circle * 503 -gg_svg_clone_circle (struct gg_svg_circle *in) 504 -{ 505 -/* cloning an SVG Circle */ 506 - struct gg_svg_circle *p = malloc (sizeof (struct gg_svg_circle)); 507 - p->cx = in->cx; 508 - p->cy = in->cy; 509 - p->r = in->r; 510 - return p; 511 -} 512 - 513 -GGRAPH_PRIVATE struct gg_svg_ellipse * 514 -gg_svg_alloc_ellipse (double cx, double cy, double rx, double ry) 515 -{ 516 -/* allocating and initializing an SVG Ellipse */ 517 - struct gg_svg_ellipse *p = malloc (sizeof (struct gg_svg_ellipse)); 518 - p->cx = cx; 519 - p->cy = cy; 520 - p->rx = rx; 521 - p->ry = ry; 522 - return p; 523 -} 524 - 525 -GGRAPH_PRIVATE struct gg_svg_ellipse * 526 -gg_svg_clone_ellipse (struct gg_svg_ellipse *in) 527 -{ 528 -/* cloning an SVG Ellipse */ 529 - struct gg_svg_ellipse *p = malloc (sizeof (struct gg_svg_ellipse)); 530 - p->cx = in->cx; 531 - p->cy = in->cy; 532 - p->rx = in->rx; 533 - p->ry = in->ry; 534 - return p; 535 -} 536 - 537 -GGRAPH_PRIVATE struct gg_svg_line * 538 -gg_svg_alloc_line (double x1, double y1, double x2, double y2) 539 -{ 540 -/* allocating and initializing an SVG Line */ 541 - struct gg_svg_line *p = malloc (sizeof (struct gg_svg_line)); 542 - p->x1 = x1; 543 - p->y1 = y1; 544 - p->x2 = x2; 545 - p->y2 = y2; 546 - return p; 547 -} 548 - 549 -GGRAPH_PRIVATE struct gg_svg_line * 550 -gg_svg_clone_line (struct gg_svg_line *in) 551 -{ 552 -/* cloning an SVG Line */ 553 - struct gg_svg_line *p = malloc (sizeof (struct gg_svg_line)); 554 - p->x1 = in->x1; 555 - p->y1 = in->y1; 556 - p->x2 = in->x2; 557 - p->y2 = in->y2; 558 - return p; 559 -} 560 - 561 -GGRAPH_PRIVATE struct gg_svg_polyline * 562 -gg_svg_alloc_polyline (int points, double *x, double *y) 563 -{ 564 -/* allocating and initializing an SVG Polyline */ 565 - struct gg_svg_polyline *p = malloc (sizeof (struct gg_svg_polyline)); 566 - p->points = points; 567 - p->x = x; 568 - p->y = y; 569 - return p; 570 -} 571 - 572 -GGRAPH_PRIVATE struct gg_svg_polyline * 573 -gg_svg_clone_polyline (struct gg_svg_polyline *in) 574 -{ 575 -/* cloning an SVG Polyline */ 576 - int iv; 577 - struct gg_svg_polyline *p = malloc (sizeof (struct gg_svg_polyline)); 578 - p->points = in->points; 579 - p->x = malloc (sizeof (double) * in->points); 580 - p->y = malloc (sizeof (double) * in->points); 581 - for (iv = 0; iv < in->points; iv++) 582 - { 583 - *(p->x + iv) = *(in->x + iv); 584 - *(p->y + iv) = *(in->y + iv); 585 - } 586 - return p; 587 -} 588 - 589 -GGRAPH_PRIVATE struct gg_svg_polygon * 590 -gg_svg_alloc_polygon (int points, double *x, double *y) 591 -{ 592 -/* allocating and initializing an SVG Polygon */ 593 - struct gg_svg_polygon *p = malloc (sizeof (struct gg_svg_polygon)); 594 - p->points = points; 595 - p->x = x; 596 - p->y = y; 597 - return p; 598 -} 599 - 600 -GGRAPH_PRIVATE struct gg_svg_polygon * 601 -gg_svg_clone_polygon (struct gg_svg_polygon *in) 602 -{ 603 -/* cloning an SVG Polygon */ 604 - int iv; 605 - struct gg_svg_polygon *p = malloc (sizeof (struct gg_svg_polygon)); 606 - p->points = in->points; 607 - p->x = malloc (sizeof (double) * in->points); 608 - p->y = malloc (sizeof (double) * in->points); 609 - for (iv = 0; iv < in->points; iv++) 610 - { 611 - *(p->x + iv) = *(in->x + iv); 612 - *(p->y + iv) = *(in->y + iv); 613 - } 614 - return p; 615 -} 616 - 617 -GGRAPH_PRIVATE struct gg_svg_path_move * 618 -gg_svg_alloc_path_move (double x, double y) 619 -{ 620 -/* allocating and initializing an SVG Path MoveTo or LineTo */ 621 - struct gg_svg_path_move *p = malloc (sizeof (struct gg_svg_path_move)); 622 - p->x = x; 623 - p->y = y; 624 - return p; 625 -} 626 - 627 -GGRAPH_PRIVATE struct gg_svg_path_move * 628 -gg_svg_clone_path_move (struct gg_svg_path_move *in) 629 -{ 630 -/* cloning an SVG Path MoveTo or LineTo */ 631 - struct gg_svg_path_move *p = malloc (sizeof (struct gg_svg_path_move)); 632 - p->x = in->x; 633 - p->y = in->y; 634 - return p; 635 -} 636 - 637 -GGRAPH_PRIVATE struct gg_svg_path_bezier * 638 -gg_svg_alloc_path_bezier (double x1, double y1, double x2, double y2, double x, 639 - double y) 640 -{ 641 -/* allocating and initializing an SVG Bezier Curve */ 642 - struct gg_svg_path_bezier *p = malloc (sizeof (struct gg_svg_path_bezier)); 643 - p->x1 = x1; 644 - p->y1 = y1; 645 - p->x2 = x2; 646 - p->y2 = y2; 647 - p->x = x; 648 - p->y = y; 649 - return p; 650 -} 651 - 652 -GGRAPH_PRIVATE struct gg_svg_path_bezier * 653 -gg_svg_clone_path_bezier (struct gg_svg_path_bezier *in) 654 -{ 655 -/* cloning an SVG Bezier Curve */ 656 - struct gg_svg_path_bezier *p = malloc (sizeof (struct gg_svg_path_bezier)); 657 - p->x1 = in->x1; 658 - p->y1 = in->y1; 659 - p->x2 = in->x2; 660 - p->y2 = in->y2; 661 - p->x = in->x; 662 - p->y = in->y; 663 - return p; 664 -} 665 - 666 -GGRAPH_PRIVATE struct gg_svg_path_ellipt_arc * 667 -gg_svg_alloc_path_ellipt_arc (double rx, double ry, double rotation, 668 - int large_arc, int sweep, double x, double y) 669 -{ 670 -/* allocating and initializing an SVG Elliptic Arc */ 671 - struct gg_svg_path_ellipt_arc *p = 672 - malloc (sizeof (struct gg_svg_path_ellipt_arc)); 673 - p->rx = rx; 674 - p->ry = ry; 675 - p->rotation = rotation; 676 - if (large_arc == 0) 677 - p->large_arc = 0; 678 - else 679 - p->large_arc = 1; 680 - if (sweep == 0) 681 - p->sweep = 0; 682 - else 683 - p->sweep = 1; 684 - p->x = x; 685 - p->y = y; 686 - return p; 687 -} 688 - 689 -GGRAPH_PRIVATE struct gg_svg_path_ellipt_arc * 690 -gg_svg_clone_path_ellipt_arc (struct gg_svg_path_ellipt_arc *in) 691 -{ 692 -/* cloning an SVG Elliptic Arc */ 693 - struct gg_svg_path_ellipt_arc *p = 694 - malloc (sizeof (struct gg_svg_path_ellipt_arc)); 695 - p->rx = in->rx; 696 - p->ry = in->ry; 697 - p->rotation = in->rotation; 698 - p->large_arc = in->large_arc; 699 - p->sweep = in->sweep; 700 - p->x = in->x; 701 - p->y = in->y; 702 - return p; 703 -} 704 - 705 -GGRAPH_PRIVATE struct gg_svg_path_item * 706 -gg_svg_alloc_path_item (int type, void *data) 707 -{ 708 -/* allocating and initializing an empty SVG Path item */ 709 - struct gg_svg_path_item *p = malloc (sizeof (struct gg_svg_path_item)); 710 - p->type = type; 711 - p->data = data; 712 - p->next = NULL; 713 - return p; 714 -} 715 - 716 -GGRAPH_PRIVATE void 717 -gg_svg_add_path_item (struct gg_svg_path *path, int type, void *data) 718 -{ 719 -/* add a Command to an SVG Path */ 720 - struct gg_svg_path_item *p = gg_svg_alloc_path_item (type, data); 721 - if (path->first == NULL) 722 - path->first = p; 723 - if (path->last != NULL) 724 - path->last->next = p; 725 - path->last = p; 726 -} 727 - 728 -GGRAPH_PRIVATE struct gg_svg_path * 729 -gg_svg_alloc_path (void) 730 -{ 731 -/* allocating and initializing an empty SVG Path */ 732 - struct gg_svg_path *p = malloc (sizeof (struct gg_svg_path)); 733 - p->first = NULL; 734 - p->last = NULL; 735 - p->error = 0; 736 - return p; 737 -} 738 - 739 -GGRAPH_PRIVATE struct gg_svg_path * 740 -gg_svg_clone_path (struct gg_svg_path *in) 741 -{ 742 -/* cloning an empty SVG Path */ 743 - struct gg_svg_path_move *move; 744 - struct gg_svg_path_bezier *bezier; 745 - struct gg_svg_path_ellipt_arc *arc; 746 - struct gg_svg_path_item *pp; 747 - struct gg_svg_path *p = malloc (sizeof (struct gg_svg_path)); 748 - p->first = NULL; 749 - p->last = NULL; 750 - pp = in->first; 751 - while (pp != NULL) 752 - { 753 - switch (pp->type) 754 - { 755 - case GG_SVG_MOVE_TO: 756 - case GG_SVG_LINE_TO: 757 - move = gg_svg_clone_path_move (pp->data); 758 - gg_svg_add_path_item (p, pp->type, move); 759 - break; 760 - case GG_SVG_CURVE_3: 761 - case GG_SVG_CURVE_4: 762 - bezier = gg_svg_clone_path_bezier (pp->data); 763 - gg_svg_add_path_item (p, pp->type, bezier); 764 - break; 765 - case GG_SVG_ELLIPT_ARC: 766 - arc = gg_svg_clone_path_ellipt_arc (pp->data); 767 - gg_svg_add_path_item (p, pp->type, arc); 768 - break; 769 - case GG_SVG_CLOSE_PATH: 770 - gg_svg_add_path_item (p, pp->type, NULL); 771 - break; 772 - }; 773 - pp = pp->next; 774 - } 775 - p->error = in->error; 776 - return p; 777 -} 778 - 779 -GGRAPH_PRIVATE void 780 -gg_svg_add_clip_url (struct gg_svg_style *style, const char *url) 781 -{ 782 -/* adding an URL (ClipPath ref) to some Style */ 783 - int len; 784 - if (style->clip_url != NULL) 785 - free (style->clip_url); 786 - if (url == NULL) 787 - { 788 - style->clip_url = NULL; 789 - return; 790 - } 791 - len = strlen (url); 792 - style->clip_url = malloc (len + 1); 793 - strcpy (style->clip_url, url); 794 -} 795 - 796 -GGRAPH_PRIVATE void 797 -gg_svg_add_fill_gradient_url (struct gg_svg_style *style, const char *url) 798 -{ 799 -/* adding an URL (Fill Gradient ref) to some Style */ 800 - int len; 801 - if (style->fill_url != NULL) 802 - free (style->fill_url); 803 - if (url == NULL) 804 - { 805 - style->fill_url = NULL; 806 - return; 807 - } 808 - len = strlen (url); 809 - style->fill_url = malloc (len + 1); 810 - strcpy (style->fill_url, url); 811 -} 812 - 813 -GGRAPH_PRIVATE void 814 -gg_svg_add_stroke_gradient_url (struct gg_svg_style *style, const char *url) 815 -{ 816 -/* adding an URL (Stroke Gradient ref) to some Style */ 817 - int len; 818 - if (style->stroke_url != NULL) 819 - free (style->stroke_url); 820 - if (url == NULL) 821 - { 822 - style->stroke_url = NULL; 823 - return; 824 - } 825 - len = strlen (url); 826 - style->stroke_url = malloc (len + 1); 827 - strcpy (style->stroke_url, url); 828 -} 829 - 830 -GGRAPH_PRIVATE struct gg_svg_shape * 831 -gg_svg_alloc_shape (int type, void *data, struct gg_svg_group *parent) 832 -{ 833 -/* allocating and initializing an empty SVG Shape */ 834 - struct gg_svg_shape *p = malloc (sizeof (struct gg_svg_shape)); 835 - p->id = NULL; 836 - p->type = type; 837 - p->data = data; 838 - p->parent = parent; 839 - p->style.visibility = -1; 840 - p->style.opacity = 1.0; 841 - p->style.fill = -1; 842 - p->style.no_fill = -1; 843 - p->style.fill_rule = -1; 844 - p->style.fill_url = NULL; 845 - p->style.fill_pointer = NULL; 846 - p->style.fill_red = -1.0; 847 - p->style.fill_green = -1.0; 848 - p->style.fill_blue = -1.0; 849 - p->style.fill_opacity = -1.0; 850 - p->style.stroke = -1; 851 - p->style.no_stroke = -1; 852 - p->style.stroke_width = -1.0; 853 - p->style.stroke_linecap = -1; 854 - p->style.stroke_linejoin = -1; 855 - p->style.stroke_miterlimit = -1.0; 856 - p->style.stroke_dashitems = 0; 857 - p->style.stroke_dasharray = NULL; 858 - p->style.stroke_dashoffset = 0.0; 859 - p->style.stroke_url = NULL; 860 - p->style.stroke_pointer = NULL; 861 - p->style.stroke_red = -1.0; 862 - p->style.stroke_green = -1.0; 863 - p->style.stroke_blue = -1.0; 864 - p->style.stroke_opacity = -1.0; 865 - p->style.clip_url = NULL; 866 - p->style.clip_pointer = NULL; 867 - p->first_trans = NULL; 868 - p->last_trans = NULL; 869 - p->is_defs = 0; 870 - p->is_flow_root = 0; 871 - p->next = NULL; 872 - return p; 873 -} 874 - 875 -GGRAPH_PRIVATE struct gg_svg_shape * 876 -gg_svg_clone_shape (struct gg_svg_shape *in, struct gg_svg_use *use) 877 -{ 878 -/* cloning an SVG Shape */ 879 - struct gg_svg_rect *rect; 880 - struct gg_svg_circle *circle; 881 - struct gg_svg_ellipse *ellipse; 882 - struct gg_svg_line *line; 883 - struct gg_svg_polyline *polyline; 884 - struct gg_svg_polygon *polygon; 885 - struct gg_svg_path *path; 886 - struct gg_svg_transform *pt; 887 - struct gg_svg_transform *trans; 888 - struct gg_svg_shape *out = malloc (sizeof (struct gg_svg_shape)); 889 - out->id = NULL; 890 - out->type = in->type; 891 - switch (in->type) 892 - { 893 - case GG_SVG_RECT: 894 - rect = in->data; 895 - out->data = gg_svg_clone_rect (rect); 896 - break; 897 - case GG_SVG_CIRCLE: 898 - circle = in->data; 899 - out->data = gg_svg_clone_circle (circle); 900 - break; 901 - case GG_SVG_ELLIPSE: 902 - ellipse = in->data; 903 - out->data = gg_svg_clone_ellipse (ellipse); 904 - break; 905 - case GG_SVG_LINE: 906 - line = in->data; 907 - out->data = gg_svg_clone_line (line); 908 - break; 909 - case GG_SVG_POLYLINE: 910 - polyline = in->data; 911 - out->data = gg_svg_clone_polyline (polyline); 912 - break; 913 - case GG_SVG_POLYGON: 914 - polygon = in->data; 915 - out->data = gg_svg_clone_polygon (polygon); 916 - break; 917 - case GG_SVG_PATH: 918 - path = in->data; 919 - out->data = gg_svg_clone_path (path); 920 - break; 921 - } 922 - if (use != NULL) 923 - out->parent = use->parent; 924 - else 925 - out->parent = in->parent; 926 - out->style.visibility = in->style.visibility; 927 - out->style.opacity = in->style.opacity; 928 - out->style.fill = in->style.fill; 929 - out->style.no_fill = in->style.no_fill; 930 - out->style.fill_rule = in->style.fill_rule; 931 - out->style.fill_url = NULL; 932 - out->style.fill_pointer = NULL; 933 - if (in->style.fill_url != NULL) 934 - gg_svg_add_fill_gradient_url (&(out->style), in->style.fill_url); 935 - out->style.fill_red = in->style.fill_red; 936 - out->style.fill_green = in->style.fill_green; 937 - out->style.fill_blue = in->style.fill_blue; 938 - out->style.fill_opacity = in->style.fill_opacity; 939 - out->style.stroke = in->style.stroke; 940 - out->style.no_stroke = in->style.no_stroke; 941 - out->style.stroke_width = in->style.stroke_width; 942 - out->style.stroke_linecap = in->style.stroke_linecap; 943 - out->style.stroke_linejoin = in->style.stroke_linejoin; 944 - out->style.stroke_miterlimit = in->style.stroke_miterlimit; 945 - out->style.stroke_dashitems = 0; 946 - out->style.stroke_dasharray = NULL; 947 - if (in->style.stroke_dashitems > 0) 948 - { 949 - out->style.stroke_dashitems = in->style.stroke_dashitems; 950 - if (out->style.stroke_dasharray != NULL) 951 - free (out->style.stroke_dasharray); 952 - out->style.stroke_dasharray = NULL; 953 - if (in->style.stroke_dashitems > 0) 954 - { 955 - int i; 956 - out->style.stroke_dasharray = 957 - malloc (sizeof (double) * in->style.stroke_dashitems); 958 - for (i = 0; i < in->style.stroke_dashitems; i++) 959 - out->style.stroke_dasharray[i] = 960 - in->style.stroke_dasharray[i]; 961 - } 962 - out->style.stroke_dashoffset = in->style.stroke_dashoffset; 963 - } 964 - out->style.stroke_url = NULL; 965 - out->style.stroke_pointer = NULL; 966 - if (in->style.stroke_url != NULL) 967 - gg_svg_add_stroke_gradient_url (&(out->style), in->style.stroke_url); 968 - out->style.stroke_red = in->style.stroke_red; 969 - out->style.stroke_green = in->style.stroke_green; 970 - out->style.stroke_blue = in->style.stroke_blue; 971 - out->style.stroke_opacity = in->style.stroke_opacity; 972 - out->style.clip_url = NULL; 973 - out->style.clip_pointer = NULL; 974 - if (in->style.clip_url != NULL) 975 - gg_svg_add_clip_url (&(out->style), in->style.clip_url); 976 - out->first_trans = NULL; 977 - out->last_trans = NULL; 978 - pt = in->first_trans; 979 - while (pt) 980 - { 981 - /* clonig all transformations */ 982 - trans = gg_svg_clone_transform (pt); 983 - if (out->first_trans == NULL) 984 - out->first_trans = trans; 985 - if (out->last_trans != NULL) 986 - out->last_trans->next = trans; 987 - out->last_trans = trans; 988 - pt = pt->next; 989 - } 990 - out->is_defs = 0; 991 - out->is_flow_root = 0; 992 - out->next = NULL; 993 - if (use != NULL) 994 - { 995 - /* adding the Use-level defs */ 996 - pt = use->first_trans; 997 - while (pt) 998 - { 999 - /* clonig all Use transformations */ 1000 - trans = gg_svg_clone_transform (pt); 1001 - if (out->first_trans == NULL) 1002 - out->first_trans = trans; 1003 - if (out->last_trans != NULL) 1004 - out->last_trans->next = trans; 1005 - out->last_trans = trans; 1006 - pt = pt->next; 1007 - } 1008 - if (use->x != DBL_MAX || use->y != DBL_MAX) 1009 - { 1010 - /* adding the implict Use Translate transformation */ 1011 - struct gg_svg_translate *translate = NULL; 1012 - if (use->x != DBL_MAX && use->y != DBL_MAX) 1013 - translate = gg_svg_alloc_translate (use->x, use->y); 1014 - else if (use->x != DBL_MAX) 1015 - translate = gg_svg_alloc_translate (use->x, 0.0); 1016 - else if (use->y != DBL_MAX) 1017 - translate = gg_svg_alloc_translate (0.0, use->y); 1018 - trans = gg_svg_alloc_transform (GG_SVG_TRANSLATE, translate); 1019 - if (out->first_trans == NULL) 1020 - out->first_trans = trans; 1021 - if (out->last_trans != NULL) 1022 - out->last_trans->next = trans; 1023 - out->last_trans = trans; 1024 - } 1025 - /* Use-level styles */ 1026 - if (use->style.visibility >= 0) 1027 - out->style.visibility = use->style.visibility; 1028 - out->style.opacity = use->style.opacity; 1029 - if (use->style.fill >= 0) 1030 - out->style.fill = use->style.fill; 1031 - if (use->style.no_fill >= 0) 1032 - out->style.no_fill = use->style.no_fill; 1033 - if (use->style.fill_rule >= 0) 1034 - out->style.fill_rule = use->style.fill_rule; 1035 - if (use->style.fill_url != NULL) 1036 - gg_svg_add_fill_gradient_url (&(out->style), use->style.fill_url); 1037 - if (use->style.fill_red >= 0.0) 1038 - out->style.fill_red = use->style.fill_red; 1039 - if (use->style.fill_green >= 0.0) 1040 - out->style.fill_green = use->style.fill_green; 1041 - if (use->style.fill_blue >= 0.0) 1042 - out->style.fill_blue = use->style.fill_blue; 1043 - if (use->style.fill_opacity >= 0.0) 1044 - out->style.fill_opacity = use->style.fill_opacity; 1045 - if (use->style.stroke >= 0) 1046 - out->style.stroke = use->style.stroke; 1047 - if (use->style.no_stroke >= 0) 1048 - out->style.no_stroke = use->style.no_stroke; 1049 - if (use->style.stroke_width >= 0.0) 1050 - out->style.stroke_width = use->style.stroke_width; 1051 - if (use->style.stroke_linecap >= 0) 1052 - out->style.stroke_linecap = use->style.stroke_linecap; 1053 - if (use->style.stroke_linejoin >= 0) 1054 - out->style.stroke_linejoin = use->style.stroke_linejoin; 1055 - if (use->style.stroke_miterlimit >= 0.0) 1056 - out->style.stroke_miterlimit = use->style.stroke_miterlimit; 1057 - if (use->style.stroke_dashitems > 0) 1058 - { 1059 - out->style.stroke_dashitems = use->style.stroke_dashitems; 1060 - if (out->style.stroke_dasharray != NULL) 1061 - free (out->style.stroke_dasharray); 1062 - out->style.stroke_dasharray = NULL; 1063 - if (use->style.stroke_dashitems > 0) 1064 - { 1065 - int i; 1066 - out->style.stroke_dasharray = 1067 - malloc (sizeof (double) * 1068 - use->style.stroke_dashitems); 1069 - for (i = 0; i < use->style.stroke_dashitems; i++) 1070 - out->style.stroke_dasharray[i] = 1071 - use->style.stroke_dasharray[i]; 1072 - } 1073 - out->style.stroke_dashoffset = use->style.stroke_dashoffset; 1074 - } 1075 - if (use->style.stroke_url != NULL) 1076 - gg_svg_add_stroke_gradient_url (&(out->style), 1077 - use->style.stroke_url); 1078 - if (use->style.stroke_red >= 0.0) 1079 - out->style.stroke_red = use->style.stroke_red; 1080 - if (use->style.stroke_green >= 0.0) 1081 - out->style.stroke_green = use->style.stroke_green; 1082 - if (use->style.stroke_blue >= 0.0) 1083 - out->style.stroke_blue = use->style.stroke_blue; 1084 - if (use->style.stroke_opacity >= 0.0) 1085 - out->style.stroke_opacity = use->style.stroke_opacity; 1086 - if (use->style.clip_url != NULL) 1087 - gg_svg_add_clip_url (&(out->style), use->style.clip_url); 1088 - } 1089 - return out; 1090 -} 1091 - 1092 -GGRAPH_PRIVATE void 1093 -gg_svg_add_shape_id (struct gg_svg_shape *shape, const char *id) 1094 -{ 1095 -/* setting the ID for some Shape */ 1096 - int len = strlen (id); 1097 - if (shape->id != NULL) 1098 - free (shape->id); 1099 - shape->id = malloc (len + 1); 1100 - strcpy (shape->id, id); 1101 -} 1102 - 1103 -GGRAPH_PRIVATE struct gg_svg_use * 1104 -gg_svg_alloc_use (void *parent, const char *xlink_href, double x, double y, 1105 - double width, double height) 1106 -{ 1107 -/* allocating and initializing an empty SVG Use (xlink:href) */ 1108 - int len = strlen (xlink_href); 1109 - struct gg_svg_use *p = malloc (sizeof (struct gg_svg_use)); 1110 - p->xlink_href = malloc (len + 1); 1111 - strcpy (p->xlink_href, xlink_href); 1112 - p->x = x; 1113 - p->y = y; 1114 - p->width = width; 1115 - p->height = height; 1116 - p->parent = parent; 1117 - p->style.visibility = -1; 1118 - p->style.opacity = 1.0; 1119 - p->style.fill = -1; 1120 - p->style.no_fill = -1; 1121 - p->style.fill_rule = -1; 1122 - p->style.fill_url = NULL; 1123 - p->style.fill_pointer = NULL; 1124 - p->style.fill_red = -1.0; 1125 - p->style.fill_green = -1.0; 1126 - p->style.fill_blue = -1.0; 1127 - p->style.fill_opacity = -1.0; 1128 - p->style.stroke = -1; 1129 - p->style.no_stroke = -1; 1130 - p->style.stroke_width = -1.0; 1131 - p->style.stroke_linecap = -1; 1132 - p->style.stroke_linejoin = -1; 1133 - p->style.stroke_miterlimit = -1.0; 1134 - p->style.stroke_dashitems = 0; 1135 - p->style.stroke_dasharray = NULL; 1136 - p->style.stroke_dashoffset = 0.0; 1137 - p->style.stroke_url = NULL; 1138 - p->style.stroke_pointer = NULL; 1139 - p->style.stroke_red = -1.0; 1140 - p->style.stroke_green = -1.0; 1141 - p->style.stroke_blue = -1.0; 1142 - p->style.stroke_opacity = -1.0; 1143 - p->style.clip_url = NULL; 1144 - p->style.clip_pointer = NULL; 1145 - p->first_trans = NULL; 1146 - p->last_trans = NULL; 1147 - p->next = NULL; 1148 - return p; 1149 -} 1150 - 1151 -GGRAPH_PRIVATE struct gg_svg_use * 1152 -gg_svg_clone_use (struct gg_svg_use *in) 1153 -{ 1154 -/* cloning an SVG Use (xlink:href) */ 1155 - struct gg_svg_transform *pt; 1156 - struct gg_svg_transform *trans; 1157 - int len = strlen (in->xlink_href); 1158 - struct gg_svg_use *out = malloc (sizeof (struct gg_svg_use)); 1159 - out->xlink_href = malloc (len + 1); 1160 - strcpy (out->xlink_href, in->xlink_href); 1161 - out->x = in->x; 1162 - out->y = in->y; 1163 - out->width = in->width; 1164 - out->height = in->height; 1165 - out->parent = in->parent; 1166 - out->style.visibility = in->style.visibility; 1167 - out->style.opacity = in->style.opacity; 1168 - out->style.fill = in->style.fill; 1169 - out->style.no_fill = in->style.no_fill; 1170 - out->style.fill_rule = in->style.fill_rule; 1171 - out->style.fill_url = NULL; 1172 - out->style.fill_pointer = NULL; 1173 - if (in->style.fill_url != NULL) 1174 - gg_svg_add_fill_gradient_url (&(out->style), in->style.fill_url); 1175 - out->style.fill_red = in->style.fill_red; 1176 - out->style.fill_green = in->style.fill_green; 1177 - out->style.fill_blue = in->style.fill_blue; 1178 - out->style.fill_opacity = in->style.fill_opacity; 1179 - out->style.stroke = in->style.stroke; 1180 - out->style.no_stroke = in->style.no_stroke; 1181 - out->style.stroke_width = in->style.stroke_width; 1182 - out->style.stroke_linecap = in->style.stroke_linecap; 1183 - out->style.stroke_linejoin = in->style.stroke_linejoin; 1184 - out->style.stroke_miterlimit = in->style.stroke_miterlimit; 1185 - out->style.stroke_dashitems = 0; 1186 - out->style.stroke_dasharray = NULL; 1187 - if (in->style.stroke_dashitems > 0) 1188 - { 1189 - out->style.stroke_dashitems = in->style.stroke_dashitems; 1190 - if (out->style.stroke_dasharray != NULL) 1191 - free (out->style.stroke_dasharray); 1192 - out->style.stroke_dasharray = NULL; 1193 - if (in->style.stroke_dashitems > 0) 1194 - { 1195 - int i; 1196 - out->style.stroke_dasharray = 1197 - malloc (sizeof (double) * in->style.stroke_dashitems); 1198 - for (i = 0; i < in->style.stroke_dashitems; i++) 1199 - out->style.stroke_dasharray[i] = 1200 - in->style.stroke_dasharray[i]; 1201 - } 1202 - out->style.stroke_dashoffset = in->style.stroke_dashoffset; 1203 - } 1204 - out->style.stroke_url = NULL; 1205 - out->style.stroke_pointer = NULL; 1206 - if (in->style.stroke_url != NULL) 1207 - gg_svg_add_stroke_gradient_url (&(out->style), in->style.stroke_url); 1208 - out->style.stroke_red = in->style.stroke_red; 1209 - out->style.stroke_green = in->style.stroke_green; 1210 - out->style.stroke_blue = in->style.stroke_blue; 1211 - out->style.stroke_opacity = in->style.stroke_opacity; 1212 - out->style.clip_url = NULL; 1213 - out->style.clip_pointer = NULL; 1214 - if (in->style.clip_url != NULL) 1215 - gg_svg_add_clip_url (&(out->style), in->style.clip_url); 1216 - out->first_trans = NULL; 1217 - out->last_trans = NULL; 1218 - pt = in->first_trans; 1219 - while (pt) 1220 - { 1221 - /* clonig all transformations */ 1222 - trans = gg_svg_clone_transform (pt); 1223 - if (out->first_trans == NULL) 1224 - out->first_trans = trans; 1225 - if (out->last_trans != NULL) 1226 - out->last_trans->next = trans; 1227 - out->last_trans = trans; 1228 - pt = pt->next; 1229 - } 1230 - out->next = NULL; 1231 - return out; 1232 -} 1233 - 1234 -GGRAPH_PRIVATE struct gg_svg_group * 1235 -gg_svg_alloc_group (void) 1236 -{ 1237 -/* allocating and initializing an empty SVG Group <g> */ 1238 - struct gg_svg_group *p = malloc (sizeof (struct gg_svg_group)); 1239 - p->id = NULL; 1240 - p->style.visibility = -1; 1241 - p->style.opacity = 1.0; 1242 - p->style.fill = -1; 1243 - p->style.no_fill = -1; 1244 - p->style.fill_rule = -1; 1245 - p->style.fill_url = NULL; 1246 - p->style.fill_pointer = NULL; 1247 - p->style.fill_red = -1.0; 1248 - p->style.fill_green = -1.0; 1249 - p->style.fill_blue = -1.0; 1250 - p->style.fill_opacity = -1.0; 1251 - p->style.stroke = -1; 1252 - p->style.no_stroke = -1; 1253 - p->style.stroke_width = -1.0; 1254 - p->style.stroke_linecap = -1; 1255 - p->style.stroke_linejoin = -1; 1256 - p->style.stroke_miterlimit = -1.0; 1257 - p->style.stroke_dashitems = 0; 1258 - p->style.stroke_dasharray = NULL; 1259 - p->style.stroke_dashoffset = 0.0; 1260 - p->style.stroke_url = NULL; 1261 - p->style.stroke_pointer = NULL; 1262 - p->style.stroke_red = -1.0; 1263 - p->style.stroke_green = -1.0; 1264 - p->style.stroke_blue = -1.0; 1265 - p->style.stroke_opacity = -1.0; 1266 - p->style.clip_url = NULL; 1267 - p->style.clip_pointer = NULL; 1268 - p->parent = NULL; 1269 - p->first = NULL; 1270 - p->last = NULL; 1271 - p->first_trans = NULL; 1272 - p->last_trans = NULL; 1273 - p->is_defs = 0; 1274 - p->is_flow_root = 0; 1275 - p->next = NULL; 1276 - return p; 1277 -} 1278 - 1279 -GGRAPH_PRIVATE struct gg_svg_group * 1280 -gg_svg_clone_group (struct gg_svg_group *in, struct gg_svg_use *use) 1281 -{ 1282 -/* cloning an SVG Group */ 1283 - struct gg_svg_transform *pt; 1284 - struct gg_svg_transform *trans; 1285 - struct gg_svg_item *item; 1286 - struct gg_svg_item *itm; 1287 - struct gg_svg_group *out = malloc (sizeof (struct gg_svg_group)); 1288 - out->id = NULL; 1289 - out->style.visibility = in->style.visibility; 1290 - out->style.opacity = in->style.opacity; 1291 - out->style.fill = in->style.fill; 1292 - out->style.no_fill = in->style.no_fill; 1293 - out->style.fill_rule = in->style.fill_rule; 1294 - out->style.fill_url = NULL; 1295 - out->style.fill_pointer = NULL; 1296 - if (in->style.fill_url != NULL) 1297 - gg_svg_add_fill_gradient_url (&(out->style), in->style.fill_url); 1298 - out->style.fill_red = in->style.fill_red; 1299 - out->style.fill_green = in->style.fill_green; 1300 - out->style.fill_blue = in->style.fill_blue; 1301 - out->style.fill_opacity = in->style.fill_opacity; 1302 - out->style.stroke = in->style.stroke; 1303 - out->style.no_stroke = in->style.no_stroke; 1304 - out->style.stroke_width = in->style.stroke_width; 1305 - out->style.stroke_linecap = in->style.stroke_linecap; 1306 - out->style.stroke_linejoin = in->style.stroke_linejoin; 1307 - out->style.stroke_miterlimit = in->style.stroke_miterlimit; 1308 - out->style.stroke_dashitems = 0; 1309 - out->style.stroke_dasharray = NULL; 1310 - if (in->style.stroke_dashitems > 0) 1311 - { 1312 - out->style.stroke_dashitems = in->style.stroke_dashitems; 1313 - if (out->style.stroke_dasharray != NULL) 1314 - free (out->style.stroke_dasharray); 1315 - out->style.stroke_dasharray = NULL; 1316 - if (in->style.stroke_dashitems > 0) 1317 - { 1318 - int i; 1319 - out->style.stroke_dasharray = 1320 - malloc (sizeof (double) * in->style.stroke_dashitems); 1321 - for (i = 0; i < in->style.stroke_dashitems; i++) 1322 - out->style.stroke_dasharray[i] = 1323 - in->style.stroke_dasharray[i]; 1324 - } 1325 - out->style.stroke_dashoffset = in->style.stroke_dashoffset; 1326 - } 1327 - out->style.stroke_url = NULL; 1328 - out->style.stroke_pointer = NULL; 1329 - if (in->style.stroke_url != NULL) 1330 - gg_svg_add_stroke_gradient_url (&(out->style), in->style.stroke_url); 1331 - out->style.stroke_red = in->style.stroke_red; 1332 - out->style.stroke_green = in->style.stroke_green; 1333 - out->style.stroke_blue = in->style.stroke_blue; 1334 - out->style.stroke_opacity = in->style.stroke_opacity; 1335 - out->style.clip_url = NULL; 1336 - out->style.clip_pointer = NULL; 1337 - if (in->style.clip_url != NULL) 1338 - gg_svg_add_clip_url (&(out->style), in->style.clip_url); 1339 - if (use != NULL) 1340 - out->parent = use->parent; 1341 - else 1342 - out->parent = in->parent; 1343 - out->first = NULL; 1344 - out->last = NULL; 1345 - out->is_defs = 0; 1346 - out->is_flow_root = 0; 1347 - item = in->first; 1348 - while (item) 1349 - { 1350 - /* looping on Group Items */ 1351 - itm = gg_svg_clone_item (item); 1352 - gg_svg_set_group_parent (itm, out); 1353 - if (out->first == NULL) 1354 - out->first = itm; 1355 - if (out->last != NULL) 1356 - out->last->next = itm; 1357 - out->last = itm; 1358 - item = item->next; 1359 - } 1360 - out->first_trans = NULL; 1361 - out->last_trans = NULL; 1362 - out->next = NULL; 1363 - if (use != NULL) 1364 - { 1365 - /* adding the Use-level defs */ 1366 - pt = use->first_trans; 1367 - while (pt) 1368 - { 1369 - /* clonig all Use transformations */ 1370 - trans = gg_svg_clone_transform (pt); 1371 - if (out->first_trans == NULL) 1372 - out->first_trans = trans; 1373 - if (out->last_trans != NULL) 1374 - out->last_trans->next = trans; 1375 - out->last_trans = trans; 1376 - pt = pt->next; 1377 - } 1378 - } 1379 - pt = in->first_trans; 1380 - while (pt) 1381 - { 1382 - /* clonig all transformations */ 1383 - trans = gg_svg_clone_transform (pt); 1384 - if (out->first_trans == NULL) 1385 - out->first_trans = trans; 1386 - if (out->last_trans != NULL) 1387 - out->last_trans->next = trans; 1388 - out->last_trans = trans; 1389 - pt = pt->next; 1390 - } 1391 - if (use != NULL) 1392 - { 1393 - /* adding the Use-level defs */ 1394 - if (use->x != DBL_MAX || use->y != DBL_MAX) 1395 - { 1396 - /* adding the implict Use Translate transformation */ 1397 - struct gg_svg_translate *translate = NULL; 1398 - if (use->x != DBL_MAX && use->y != DBL_MAX) 1399 - translate = gg_svg_alloc_translate (use->x, use->y); 1400 - else if (use->x != DBL_MAX) 1401 - translate = gg_svg_alloc_translate (use->x, 0.0); 1402 - else if (use->y != DBL_MAX) 1403 - translate = gg_svg_alloc_translate (0.0, use->y); 1404 - trans = gg_svg_alloc_transform (GG_SVG_TRANSLATE, translate); 1405 - if (out->first_trans == NULL) 1406 - out->first_trans = trans; 1407 - if (out->last_trans != NULL) 1408 - out->last_trans->next = trans; 1409 - out->last_trans = trans; 1410 - } 1411 - /* Use-level styles */ 1412 - if (use->style.visibility >= 0) 1413 - out->style.visibility = use->style.visibility; 1414 - out->style.opacity = use->style.opacity; 1415 - if (use->style.fill >= 0) 1416 - out->style.fill = use->style.fill; 1417 - if (use->style.no_fill >= 0) 1418 - out->style.no_fill = use->style.no_fill; 1419 - if (use->style.fill_rule >= 0) 1420 - out->style.fill_rule = use->style.fill_rule; 1421 - if (use->style.fill_url != NULL) 1422 - gg_svg_add_fill_gradient_url (&(out->style), use->style.fill_url); 1423 - if (use->style.fill_red >= 0.0) 1424 - out->style.fill_red = use->style.fill_red; 1425 - if (use->style.fill_green >= 0.0) 1426 - out->style.fill_green = use->style.fill_green; 1427 - if (use->style.fill_blue >= 0.0) 1428 - out->style.fill_blue = use->style.fill_blue; 1429 - if (use->style.fill_opacity >= 0.0) 1430 - out->style.fill_opacity = use->style.fill_opacity; 1431 - if (use->style.stroke >= 0) 1432 - out->style.stroke = use->style.stroke; 1433 - if (use->style.no_stroke >= 0) 1434 - out->style.no_stroke = use->style.no_stroke; 1435 - if (use->style.stroke_width >= 0.0) 1436 - out->style.stroke_width = use->style.stroke_width; 1437 - if (use->style.stroke_linecap >= 0) 1438 - out->style.stroke_linecap = use->style.stroke_linecap; 1439 - if (use->style.stroke_linejoin >= 0) 1440 - out->style.stroke_linejoin = use->style.stroke_linejoin; 1441 - if (use->style.stroke_miterlimit >= 0.0) 1442 - out->style.stroke_miterlimit = use->style.stroke_miterlimit; 1443 - if (in->style.stroke_dashitems > 0) 1444 - { 1445 - out->style.stroke_dashitems = use->style.stroke_dashitems; 1446 - if (out->style.stroke_dasharray != NULL) 1447 - free (out->style.stroke_dasharray); 1448 - out->style.stroke_dasharray = NULL; 1449 - if (use->style.stroke_dashitems > 0) 1450 - { 1451 - int i; 1452 - out->style.stroke_dasharray = 1453 - malloc (sizeof (double) * 1454 - use->style.stroke_dashitems); 1455 - for (i = 0; i < use->style.stroke_dashitems; i++) 1456 - out->style.stroke_dasharray[i] = 1457 - use->style.stroke_dasharray[i]; 1458 - } 1459 - out->style.stroke_dashoffset = use->style.stroke_dashoffset; 1460 - } 1461 - if (use->style.stroke_url != NULL) 1462 - gg_svg_add_stroke_gradient_url (&(out->style), 1463 - use->style.stroke_url); 1464 - if (use->style.stroke_red >= 0.0) 1465 - out->style.stroke_red = use->style.stroke_red; 1466 - if (use->style.stroke_green >= 0.0) 1467 - out->style.stroke_green = use->style.stroke_green; 1468 - if (use->style.stroke_blue >= 0.0) 1469 - out->style.stroke_blue = use->style.stroke_blue; 1470 - if (use->style.stroke_opacity >= 0.0) 1471 - out->style.stroke_opacity = use->style.stroke_opacity; 1472 - if (use->style.clip_url != NULL) 1473 - gg_svg_add_clip_url (&(out->style), use->style.clip_url); 1474 - } 1475 - out->next = NULL; 1476 - return out; 1477 -} 1478 - 1479 -GGRAPH_PRIVATE struct gg_svg_clip * 1480 -gg_svg_alloc_clip (void) 1481 -{ 1482 -/* allocating and initializing an empty SVG ClipPath */ 1483 - struct gg_svg_clip *p = malloc (sizeof (struct gg_svg_clip)); 1484 - p->id = NULL; 1485 - p->first = NULL; 1486 - p->last = NULL; 1487 - p->next = NULL; 1488 - return p; 1489 -} 1490 - 1491 -GGRAPH_PRIVATE struct gg_svg_clip * 1492 -gg_svg_clone_clip (struct gg_svg_clip *in) 1493 -{ 1494 -/* cloning an SVG ClipPath */ 1495 - struct gg_svg_item *item; 1496 - struct gg_svg_item *itm; 1497 - struct gg_svg_clip *out = malloc (sizeof (struct gg_svg_clip)); 1498 - out->id = NULL; 1499 - out->first = NULL; 1500 - out->last = NULL; 1501 - item = in->first; 1502 - while (item) 1503 - { 1504 - /* looping on Group Items */ 1505 - itm = gg_svg_clone_item (item); 1506 - if (out->first == NULL) 1507 - out->first = itm; 1508 - if (out->last != NULL) 1509 - out->last->next = itm; 1510 - out->last = itm; 1511 - item = item->next; 1512 - } 1513 - out->next = NULL; 1514 - return out; 1515 -} 1516 - 1517 -GGRAPH_PRIVATE void 1518 -gg_svg_add_group_id (struct gg_svg_group *group, const char *id) 1519 -{ 1520 -/* setting the ID for some Group */ 1521 - int len = strlen (id); 1522 - if (group->id != NULL) 1523 - free (group->id); 1524 - group->id = malloc (len + 1); 1525 - strcpy (group->id, id); 1526 -} 1527 - 1528 -GGRAPH_PRIVATE void 1529 -gg_svg_add_clip_id (struct gg_svg_clip *clip, const char *id) 1530 -{ 1531 -/* setting the ID for some ClipPath */ 1532 - int len = strlen (id); 1533 - if (clip->id != NULL) 1534 - free (clip->id); 1535 - clip->id = malloc (len + 1); 1536 - strcpy (clip->id, id); 1537 -} 1538 - 1539 -GGRAPH_PRIVATE struct gg_svg_item * 1540 -gg_svg_alloc_item (int type, void *pointer) 1541 -{ 1542 -/* allocating and initializing an empty SVG item */ 1543 - struct gg_svg_item *p = malloc (sizeof (struct gg_svg_item)); 1544 - p->type = type; 1545 - p->pointer = pointer; 1546 - p->next = NULL; 1547 - return p; 1548 -} 1549 - 1550 -GGRAPH_PRIVATE struct gg_svg_item * 1551 -gg_svg_clone_item (struct gg_svg_item *in) 1552 -{ 1553 -/* cloning an SVG item */ 1554 - struct gg_svg_group *group; 1555 - struct gg_svg_shape *shape; 1556 - struct gg_svg_use *use; 1557 - struct gg_svg_clip *clip; 1558 - struct gg_svg_item *p = malloc (sizeof (struct gg_svg_item)); 1559 - p->type = in->type; 1560 - switch (in->type) 1561 - { 1562 - case GG_SVG_ITEM_GROUP: 1563 - group = in->pointer; 1564 - p->pointer = gg_svg_clone_group (group, NULL); 1565 - break; 1566 - case GG_SVG_ITEM_SHAPE: 1567 - shape = in->pointer; 1568 - p->pointer = gg_svg_clone_shape (shape, NULL); 1569 - break; 1570 - case GG_SVG_ITEM_USE: 1571 - use = in->pointer; 1572 - p->pointer = gg_svg_clone_use (use); 1573 - case GG_SVG_ITEM_CLIP: 1574 - clip = in->pointer; 1575 - p->pointer = gg_svg_clone_clip (clip); 1576 - break; 1577 - }; 1578 - p->next = NULL; 1579 - return p; 1580 -} 1581 - 1582 -GGRAPH_PRIVATE void 1583 -gg_svg_set_group_parent (struct gg_svg_item *item, struct gg_svg_group *grp) 1584 -{ 1585 -/* cloning an SVG item */ 1586 - struct gg_svg_group *group; 1587 - struct gg_svg_shape *shape; 1588 - struct gg_svg_use *use; 1589 - switch (item->type) 1590 - { 1591 - case GG_SVG_ITEM_GROUP: 1592 - group = item->pointer; 1593 - group->parent = grp; 1594 - break; 1595 - case GG_SVG_ITEM_SHAPE: 1596 - shape = item->pointer; 1597 - shape->parent = grp; 1598 - break; 1599 - case GG_SVG_ITEM_USE: 1600 - use = item->pointer; 1601 - use->parent = grp; 1602 - break; 1603 - }; 1604 -} 1605 - 1606 -GGRAPH_PRIVATE struct gg_svg_gradient_stop * 1607 -gg_svg_alloc_gradient_stop (double offset, double red, double green, 1608 - double blue, double opacity) 1609 -{ 1610 -/* allocating and initializing an SVG GradientStop */ 1611 - struct gg_svg_gradient_stop *p = 1612 - malloc (sizeof (struct gg_svg_gradient_stop)); 1613 - p->offset = offset; 1614 - p->red = red; 1615 - p->green = green; 1616 - p->blue = blue; 1617 - p->opacity = opacity; 1618 - p->next = NULL; 1619 - return p; 1620 -} 1621 - 1622 -GGRAPH_PRIVATE struct gg_svg_gradient_stop * 1623 -gg_svg_clone_gradient_stop (struct gg_svg_gradient_stop *in) 1624 -{ 1625 -/* cloning an SVG GradientStop */ 1626 - struct gg_svg_gradient_stop *out = 1627 - malloc (sizeof (struct gg_svg_gradient_stop)); 1628 - out->offset = in->offset; 1629 - out->red = in->red; 1630 - out->green = in->green; 1631 - out->blue = in->blue; 1632 - out->opacity = in->opacity; 1633 - out->next = NULL; 1634 - return out; 1635 -} 1636 - 1637 -GGRAPH_PRIVATE struct gg_svg_gradient * 1638 -gg_svg_alloc_gradient (void) 1639 -{ 1640 -/* allocating and initializing an empty SVG Gradient */ 1641 - struct gg_svg_gradient *p = malloc (sizeof (struct gg_svg_gradient)); 1642 - p->type = -1; 1643 - p->id = NULL; 1644 - p->xlink_href = NULL; 1645 - p->gradient_units = -1; 1646 - p->x1 = DBL_MAX; 1647 - p->y1 = DBL_MAX; 1648 - p->x2 = DBL_MAX; 1649 - p->y2 = DBL_MAX; 1650 - p->cx = DBL_MAX; 1651 - p->cy = DBL_MAX; 1652 - p->fx = DBL_MAX; 1653 - p->fy = DBL_MAX; 1654 - p->r = DBL_MAX; 1655 - p->first_trans = NULL; 1656 - p->last_trans = NULL; 1657 - p->first_stop = NULL; 1658 - p->last_stop = NULL; 1659 - p->next = NULL; 1660 - p->prev = NULL; 1661 - return p; 1662 -} 1663 - 1664 -GGRAPH_PRIVATE struct gg_svg_gradient * 1665 -gg_svg_clone_gradient (struct gg_svg_gradient *in, struct gg_svg_gradient *old) 1666 -{ 1667 -/* cloning an SVG Gradient */ 1668 - struct gg_svg_transform *pt; 1669 - struct gg_svg_transform *trans; 1670 - struct gg_svg_gradient_stop *ps; 1671 - struct gg_svg_gradient_stop *stop; 1672 - int len; 1673 - struct gg_svg_gradient *out = malloc (sizeof (struct gg_svg_gradient)); 1674 - out->type = old->type; 1675 - out->id = NULL; 1676 - out->xlink_href = NULL; 1677 - if (old->id != NULL) 1678 - { 1679 - len = strlen (old->id); 1680 - out->id = malloc (len + 1); 1681 - strcpy (out->id, old->id); 1682 - } 1683 - if (old->xlink_href != NULL) 1684 - { 1685 - len = strlen (old->xlink_href); 1686 - out->xlink_href = malloc (len + 1); 1687 - strcpy (out->xlink_href, old->xlink_href); 1688 - } 1689 - out->gradient_units = in->gradient_units; 1690 - if (old->gradient_units >= 0) 1691 - out->gradient_units = old->gradient_units; 1692 - out->x1 = in->x1; 1693 - if (old->x1 != DBL_MAX) 1694 - out->x1 = old->x1; 1695 - out->y1 = in->y1; 1696 - if (old->y1 != DBL_MAX) 1697 - out->y1 = old->y1; 1698 - out->x2 = in->x2; 1699 - if (old->x2 != DBL_MAX) 1700 - out->x2 = old->x2; 1701 - out->y2 = in->y2; 1702 - if (old->y2 != DBL_MAX) 1703 - out->y2 = old->y2; 1704 - out->cx = in->cx; 1705 - if (old->cx != DBL_MAX) 1706 - out->cx = old->cx; 1707 - out->cy = in->cy; 1708 - if (old->cy != DBL_MAX) 1709 - out->cy = old->cy; 1710 - out->fx = in->fx; 1711 - if (old->fx != DBL_MAX) 1712 - out->fx = old->fx; 1713 - out->fy = in->fy; 1714 - if (old->fy != DBL_MAX) 1715 - out->fy = old->fy; 1716 - out->r = in->r; 1717 - if (old->r != DBL_MAX) 1718 - out->r = old->r; 1719 - out->first_trans = NULL; 1720 - out->last_trans = NULL; 1721 - out->first_stop = NULL; 1722 - out->last_stop = NULL; 1723 - pt = in->first_trans; 1724 - while (pt) 1725 - { 1726 - /* clonig all inherited transformations */ 1727 - trans = gg_svg_clone_transform (pt); 1728 - if (out->first_trans == NULL) 1729 - out->first_trans = trans; 1730 - if (out->last_trans != NULL) 1731 - out->last_trans->next = trans; 1732 - out->last_trans = trans; 1733 - pt = pt->next; 1734 - } 1735 - pt = old->first_trans; 1736 - while (pt) 1737 - { 1738 - /* clonig all direct transformations */ 1739 - trans = gg_svg_clone_transform (pt); 1740 - if (out->first_trans == NULL) 1741 - out->first_trans = trans; 1742 - if (out->last_trans != NULL) 1743 - out->last_trans->next = trans; 1744 - out->last_trans = trans; 1745 - pt = pt->next; 1746 - } 1747 - ps = in->first_stop; 1748 - while (ps) 1749 - { 1750 - /* clonig all inherited Stops */ 1751 - stop = gg_svg_clone_gradient_stop (ps); 1752 - if (out->first_stop == NULL) 1753 - out->first_stop = stop; 1754 - if (out->last_stop != NULL) 1755 - out->last_stop->next = stop; 1756 - out->last_stop = stop; 1757 - ps = ps->next; 1758 - } 1759 - ps = old->first_stop; 1760 - while (ps) 1761 - { 1762 - /* clonig all inherited Stops */ 1763 - stop = gg_svg_clone_gradient_stop (ps); 1764 - if (out->first_stop == NULL) 1765 - out->first_stop = stop; 1766 - if (out->last_stop != NULL) 1767 - out->last_stop->next = stop; 1768 - out->last_stop = stop; 1769 - ps = ps->next; 1770 - } 1771 - out->next = NULL; 1772 - out->prev = NULL; 1773 - return out; 1774 -} 1775 - 1776 -GGRAPH_PRIVATE struct gg_svg_document * 1777 -gg_svg_alloc_document (void) 1778 -{ 1779 -/* allocating and initializing an empty SVG Document */ 1780 - struct gg_svg_document *p = malloc (sizeof (struct gg_svg_document)); 1781 - p->signature = GG_GRAPHICS_SVG_MAGIC_SIGNATURE; 1782 - p->width = 0.0; 1783 - p->height = 0.0; 1784 - p->viewbox_x = DBL_MIN; 1785 - p->viewbox_y = DBL_MIN; 1786 - p->viewbox_width = DBL_MIN; 1787 - p->viewbox_height = DBL_MIN; 1788 - p->first = NULL; 1789 - p->last = NULL; 1790 - p->first_grad = NULL; 1791 - p->last_grad = NULL; 1792 - p->current_group = NULL; 1793 - p->current_shape = NULL; 1794 - p->current_clip = NULL; 1795 - p->defs_count = 0; 1796 - p->flow_root_count = 0; 1797 - return p; 1798 -} 1799 - 1800 -GGRAPH_PRIVATE void 1801 -gg_svg_close_group (struct gg_svg_document *gg_svg_doc) 1802 -{ 1803 -/* closing the current SVG Group */ 1804 - struct gg_svg_group *group = gg_svg_doc->current_group; 1805 - gg_svg_doc->current_group = group->parent; 1806 -} 1807 - 1808 -GGRAPH_PRIVATE void 1809 -gg_svg_insert_group (struct gg_svg_document *gg_svg_doc) 1810 -{ 1811 -/* inserting a new Group into the SVG Document */ 1812 - struct gg_svg_item *item; 1813 - struct gg_svg_group *parent; 1814 - struct gg_svg_group *group = gg_svg_alloc_group (); 1815 - if (gg_svg_doc->current_group != NULL) 1816 - { 1817 - /* nested group */ 1818 - parent = gg_svg_doc->current_group; 1819 - group->parent = parent; 1820 - if (gg_svg_doc->defs_count > 0) 1821 - group->is_defs = 1; 1822 - if (gg_svg_doc->flow_root_count > 0) 1823 - group->is_flow_root = 1; 1824 - item = gg_svg_alloc_item (GG_SVG_ITEM_GROUP, group); 1825 - if (parent->first == NULL) 1826 - parent->first = item; 1827 - if (parent->last != NULL) 1828 - parent->last->next = item; 1829 - parent->last = item; 1830 - gg_svg_doc->current_group = group; 1831 - return; 1832 - } 1833 - if (gg_svg_doc->current_clip != NULL) 1834 - { 1835 - /* ClipPath group */ 1836 - if (gg_svg_doc->defs_count > 0) 1837 - group->is_defs = 1; 1838 - if (gg_svg_doc->flow_root_count > 0) 1839 - group->is_flow_root = 1; 1840 - item = gg_svg_alloc_item (GG_SVG_ITEM_GROUP, group); 1841 - if (gg_svg_doc->current_clip->first == NULL) 1842 - gg_svg_doc->current_clip->first = item; 1843 - if (gg_svg_doc->current_clip->last != NULL) 1844 - gg_svg_doc->current_clip->last->next = item; 1845 - gg_svg_doc->current_clip->last = item; 1846 - gg_svg_doc->current_group = group; 1847 - return; 1848 - } 1849 -/* first level Group */ 1850 - parent = gg_svg_doc->current_group; 1851 - group->parent = parent; 1852 - if (gg_svg_doc->defs_count > 0) 1853 - group->is_defs = 1; 1854 - if (gg_svg_doc->flow_root_count > 0) 1855 - group->is_flow_root = 1; 1856 - item = gg_svg_alloc_item (GG_SVG_ITEM_GROUP, group); 1857 - if (gg_svg_doc->first == NULL) 1858 - gg_svg_doc->first = item; 1859 - if (gg_svg_doc->last != NULL) 1860 - gg_svg_doc->last->next = item; 1861 - gg_svg_doc->last = item; 1862 - gg_svg_doc->current_group = group; 1863 -} 1864 - 1865 -GGRAPH_PRIVATE void 1866 -gg_svg_close_clip (struct gg_svg_document *gg_svg_doc) 1867 -{ 1868 -/* closing the current SVG ClipPath */ 1869 - gg_svg_doc->current_clip = NULL; 1870 -} 1871 - 1872 -GGRAPH_PRIVATE void 1873 -gg_svg_insert_clip (struct gg_svg_document *gg_svg_doc) 1874 -{ 1875 -/* inserting a new ClipPath into the SVG Document */ 1876 - struct gg_svg_item *item; 1877 - struct gg_svg_clip *clip = gg_svg_alloc_clip (); 1878 - item = gg_svg_alloc_item (GG_SVG_ITEM_CLIP, clip); 1879 - if (gg_svg_doc->first == NULL) 1880 - gg_svg_doc->first = item; 1881 - if (gg_svg_doc->last != NULL) 1882 - gg_svg_doc->last->next = item; 1883 - gg_svg_doc->last = item; 1884 - gg_svg_doc->current_clip = clip; 1885 -} 1886 - 1887 -GGRAPH_PRIVATE struct gg_svg_use * 1888 -gg_svg_insert_use (struct gg_svg_document *gg_svg_doc, const char *xlink_href, 1889 - double x, double y, double width, double height) 1890 -{ 1891 -/* inserting a new Use (xlink:href) into the SVG Document */ 1892 - struct gg_svg_use *use; 1893 - struct gg_svg_group *group; 1894 - struct gg_svg_clip *clip; 1895 - struct gg_svg_item *item; 1896 - 1897 - if (gg_svg_doc->current_group == NULL && gg_svg_doc->current_clip == NULL) 1898 - { 1899 - /* inserting directly into the Document */ 1900 - use = gg_svg_alloc_use (NULL, xlink_href, x, y, width, height); 1901 - item = gg_svg_alloc_item (GG_SVG_ITEM_USE, use); 1902 - if (gg_svg_doc->first == NULL) 1903 - gg_svg_doc->first = item; 1904 - if (gg_svg_doc->last != NULL) 1905 - gg_svg_doc->last->next = item; 1906 - gg_svg_doc->last = item; 1907 - } 1908 - else if (gg_svg_doc->current_clip != NULL) 1909 - { 1910 - /* inserting into the current ClipPath */ 1911 - clip = gg_svg_doc->current_clip; 1912 - use = gg_svg_alloc_use (clip, xlink_href, x, y, width, height); 1913 - item = gg_svg_alloc_item (GG_SVG_ITEM_USE, use); 1914 - if (clip->first == NULL) 1915 - clip->first = item; 1916 - if (clip->last != NULL) 1917 - clip->last->next = item; 1918 - clip->last = item; 1919 - } 1920 - else if (gg_svg_doc->current_group != NULL) 1921 - { 1922 - /* inserting into the current Group */ 1923 - group = gg_svg_doc->current_group; 1924 - use = gg_svg_alloc_use (group, xlink_href, x, y, width, height); 1925 - item = gg_svg_alloc_item (GG_SVG_ITEM_USE, use); 1926 - if (group->first == NULL) 1927 - group->first = item; 1928 - if (group->last != NULL) 1929 - group->last->next = item; 1930 - group->last = item; 1931 - } 1932 - return use; 1933 -} 1934 - 1935 -GGRAPH_PRIVATE void 1936 -gg_svg_insert_shape (struct gg_svg_document *gg_svg_doc, int type, void *data) 1937 -{ 1938 -/* inserting a new Shape into the SVG Document */ 1939 - struct gg_svg_group *group; 1940 - struct gg_svg_shape *shape; 1941 - struct gg_svg_clip *clip; 1942 - struct gg_svg_item *item; 1943 - 1944 - if (gg_svg_doc->current_group == NULL && gg_svg_doc->current_clip == NULL) 1945 - { 1946 - /* inserting directly into the Document */ 1947 - shape = gg_svg_alloc_shape (type, data, NULL); 1948 - if (gg_svg_doc->defs_count > 0) 1949 - shape->is_defs = 1; 1950 - if (gg_svg_doc->flow_root_count > 0) 1951 - shape->is_flow_root = 1; 1952 - item = gg_svg_alloc_item (GG_SVG_ITEM_SHAPE, shape); 1953 - if (gg_svg_doc->first == NULL) 1954 - gg_svg_doc->first = item; 1955 - if (gg_svg_doc->last != NULL) 1956 - gg_svg_doc->last->next = item; 1957 - gg_svg_doc->last = item; 1958 - } 1959 - else if (gg_svg_doc->current_group != NULL) 1960 - { 1961 - /* inserting into the current Group */ 1962 - group = gg_svg_doc->current_group; 1963 - shape = gg_svg_alloc_shape (type, data, group); 1964 - if (gg_svg_doc->defs_count > 0) 1965 - shape->is_defs = 1; 1966 - if (gg_svg_doc->flow_root_count > 0) 1967 - shape->is_flow_root = 1; 1968 - item = gg_svg_alloc_item (GG_SVG_ITEM_SHAPE, shape); 1969 - if (group->first == NULL) 1970 - group->first = item; 1971 - if (group->last != NULL) 1972 - group->last->next = item; 1973 - group->last = item; 1974 - } 1975 - else if (gg_svg_doc->current_clip != NULL) 1976 - { 1977 - /* inserting into the current ClipPath */ 1978 - clip = gg_svg_doc->current_clip; 1979 - shape = gg_svg_alloc_shape (type, data, NULL); 1980 - if (gg_svg_doc->defs_count > 0) 1981 - shape->is_defs = 1; 1982 - if (gg_svg_doc->flow_root_count > 0) 1983 - shape->is_flow_root = 1; 1984 - item = gg_svg_alloc_item (GG_SVG_ITEM_SHAPE, shape); 1985 - if (clip->first == NULL) 1986 - clip->first = item; 1987 - if (clip->last != NULL) 1988 - clip->last->next = item; 1989 - clip->last = item; 1990 - } 1991 - gg_svg_doc->current_shape = shape; 1992 -} 1993 - 1994 -GGRAPH_PRIVATE void 1995 -gg_svg_insert_gradient_stop (struct gg_svg_gradient *gradient, 1996 - double offset, double red, double green, 1997 - double blue, double opacity) 1998 -{ 1999 -/* inserting a Stop into a Gradient */ 2000 - struct gg_svg_gradient_stop *stop = 2001 - gg_svg_alloc_gradient_stop (offset, red, green, blue, opacity); 2002 - if (gradient->first_stop == NULL) 2003 - gradient->first_stop = stop; 2004 - if (gradient->last_stop != NULL) 2005 - gradient->last_stop->next = stop; 2006 - gradient->last_stop = stop; 2007 -} 2008 - 2009 -GGRAPH_PRIVATE struct gg_svg_gradient * 2010 -gg_svg_insert_linear_gradient (struct gg_svg_document *gg_svg_doc, 2011 - const char *id, const char *xlink_href, 2012 - double x1, double y1, double x2, double y2, 2013 - int units) 2014 -{ 2015 -/* inserting a new Linear Gradient into the SVG Document */ 2016 - int len; 2017 - struct gg_svg_gradient *gradient = gg_svg_alloc_gradient (); 2018 - gradient->type = GG_SVG_LINEAR_GRADIENT; 2019 - gradient->id = NULL; 2020 - if (id != NULL) 2021 - { 2022 - len = strlen (id); 2023 - gradient->id = malloc (len + 1); 2024 - strcpy (gradient->id, id); 2025 - } 2026 - gradient->xlink_href = NULL; 2027 - if (xlink_href != NULL) 2028 - { 2029 - len = strlen (xlink_href); 2030 - gradient->xlink_href = malloc (len + 1); 2031 - strcpy (gradient->xlink_href, xlink_href); 2032 - } 2033 - gradient->gradient_units = units; 2034 - gradient->x1 = x1; 2035 - gradient->y1 = y1; 2036 - gradient->x2 = x2; 2037 - gradient->y2 = y2; 2038 - gradient->prev = gg_svg_doc->last_grad; 2039 - if (gg_svg_doc->first_grad == NULL) 2040 - gg_svg_doc->first_grad = gradient; 2041 - if (gg_svg_doc->last_grad != NULL) 2042 - gg_svg_doc->last_grad->next = gradient; 2043 - gg_svg_doc->last_grad = gradient; 2044 - return gradient; 2045 -} 2046 - 2047 -GGRAPH_PRIVATE struct gg_svg_gradient * 2048 -gg_svg_insert_radial_gradient (struct gg_svg_document *gg_svg_doc, 2049 - const char *id, const char *xlink_href, 2050 - double cx, double cy, double fx, double fy, 2051 - double r, int units) 2052 -{ 2053 -/* inserting a new Linear Gradient into the SVG Document */ 2054 - int len; 2055 - struct gg_svg_gradient *gradient = gg_svg_alloc_gradient (); 2056 - gradient->type = GG_SVG_RADIAL_GRADIENT; 2057 - gradient->id = NULL; 2058 - if (id != NULL) 2059 - { 2060 - len = strlen (id); 2061 - gradient->id = malloc (len + 1); 2062 - strcpy (gradient->id, id); 2063 - } 2064 - gradient->xlink_href = NULL; 2065 - if (xlink_href != NULL) 2066 - { 2067 - len = strlen (xlink_href); 2068 - gradient->xlink_href = malloc (len + 1); 2069 - strcpy (gradient->xlink_href, xlink_href); 2070 - } 2071 - gradient->gradient_units = units; 2072 - gradient->cx = cx; 2073 - gradient->cy = cy; 2074 - gradient->fx = fx; 2075 - gradient->fy = fy; 2076 - gradient->r = r; 2077 - gradient->prev = gg_svg_doc->last_grad; 2078 - if (gg_svg_doc->first_grad == NULL) 2079 - gg_svg_doc->first_grad = gradient; 2080 - if (gg_svg_doc->last_grad != NULL) 2081 - gg_svg_doc->last_grad->next = gradient; 2082 - gg_svg_doc->last_grad = gradient; 2083 - return gradient; 2084 -}
Deleted src/gaiagraphics_svg_xml.c.
1 -/* 2 -/ gaiagraphics_gg_svg_xml.c 3 -/ 4 -/ SVG - XML parsing methods 5 -/ 6 -/ version 1.0, 2013 February 10 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2013 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdlib.h> 28 -#include <stdio.h> 29 -#include <string.h> 30 -#include <math.h> 31 -#include <float.h> 32 - 33 -#include <libxml/parser.h> 34 - 35 -#include "gaiagraphics.h" 36 -#include "gaiagraphics_internals.h" 37 - 38 -struct gg_svg_dyn_point 39 -{ 40 -/* a temporary struct storing a Point */ 41 - double x; 42 - double y; 43 - struct gg_svg_dyn_point *next; 44 -}; 45 - 46 -struct gg_svg_dyn_points 47 -{ 48 -/* a linked list of temporary Points */ 49 - struct gg_svg_dyn_point *first; 50 - struct gg_svg_dyn_point *last; 51 - int points; 52 -}; 53 - 54 -static void 55 -gg_svg_free_dyn_points (struct gg_svg_dyn_points *dyn) 56 -{ 57 -/* freeing the auxiliary DynPoints */ 58 - struct gg_svg_dyn_point *pn; 59 - struct gg_svg_dyn_point *p = dyn->first; 60 - while (p) 61 - { 62 - pn = p->next; 63 - free (p); 64 - p = pn; 65 - } 66 -} 67 - 68 -static void 69 -gg_svg_add_point (struct gg_svg_dyn_points *dyn, double x, double y) 70 -{ 71 - struct gg_svg_dyn_point *p = malloc (sizeof (struct gg_svg_dyn_point)); 72 - p->x = x; 73 - p->y = y; 74 - p->next = NULL; 75 - if (dyn->first == NULL) 76 - dyn->first = p; 77 - if (dyn->last != NULL) 78 - dyn->last->next = p; 79 - dyn->last = p; 80 - dyn->points += 1; 81 -} 82 - 83 -static void 84 -gg_svg_parse_points (const char *str, int *points, double **p_x, double **p_y) 85 -{ 86 -/* attempting to parse a list of Coordinates */ 87 - char value[1024]; 88 - char *p_out = value; 89 - const char *p_in = str; 90 - double x; 91 - double y; 92 - char xy = 'x'; 93 - struct gg_svg_dyn_points dyn; 94 - 95 - dyn.points = 0; 96 - dyn.first = NULL; 97 - dyn.last = NULL; 98 - 99 - while (1) 100 - { 101 - /* scanning the XML string */ 102 - if (*p_in == '\0') 103 - { 104 - /* string end */ 105 - *p_out = '\0'; 106 - if (*value != '\0') 107 - { 108 - if (xy == 'y') 109 - { 110 - y = atof (value); 111 - gg_svg_add_point (&dyn, x, y); 112 - xy = 'x'; 113 - } 114 - else 115 - x = atof (value); 116 - } 117 - break; 118 - } 119 - if (*p_in == '\n' || *p_in == ' ' || *p_in == '\t' || *p_in == '\r' 120 - || *p_in == ',') 121 - { 122 - /* delimiter */ 123 - *p_out = '\0'; 124 - if (*value != '\0') 125 - { 126 - if (xy == 'y') 127 - { 128 - y = atof (value); 129 - gg_svg_add_point (&dyn, x, y); 130 - xy = 'x'; 131 - } 132 - else 133 - x = atof (value); 134 - } 135 - if (*p_in == ',') 136 - xy = 'y'; 137 - p_out = value; 138 - p_in++; 139 - continue; 140 - } 141 - *p_out++ = *p_in++; 142 - } 143 - 144 - if (dyn.points > 0) 145 - { 146 - /* creating the coord arrays to be returned */ 147 - int iv = 0; 148 - struct gg_svg_dyn_point *p = dyn.first; 149 - double *xx = malloc (sizeof (double) * dyn.points); 150 - double *yy = malloc (sizeof (double) * dyn.points); 151 - while (p) 152 - { 153 - *(xx + iv) = p->x; 154 - *(yy + iv) = p->y; 155 - iv++; 156 - p = p->next; 157 - } 158 - *points = dyn.points; 159 - *p_x = xx; 160 - *p_y = yy; 161 - } 162 - else 163 - { 164 - /* returning an empty list of coords */ 165 - *points = 0; 166 - *p_x = NULL; 167 - *p_y = NULL; 168 - } 169 -/* freeing the DynPoints */ 170 - gg_svg_free_dyn_points (&dyn); 171 -} 172 - 173 -static double 174 -gg_svg_parse_hex_color (char hi, char lo) 175 -{ 176 -/* parsing and hex Color value */ 177 - double color = 0; 178 - switch (hi) 179 - { 180 - case '1': 181 - color = 16; 182 - break; 183 - case '2': 184 - color = 16 * 2; 185 - break; 186 - case '3': 187 - color = 16 * 3; 188 - break; 189 - case '4': 190 - color = 16 * 4; 191 - break; 192 - case '5': 193 - color = 16 * 5; 194 - break; 195 - case '6': 196 - color = 16 * 6; 197 - break; 198 - case '7': 199 - color = 16 * 7; 200 - break; 201 - case '8': 202 - color = 16 * 8; 203 - break; 204 - case '9': 205 - color = 16 * 9; 206 - break; 207 - case 'a': 208 - case 'A': 209 - color = 16 * 10; 210 - break; 211 - case 'b': 212 - case 'B': 213 - color = 16 * 11; 214 - break; 215 - case 'c': 216 - case 'C': 217 - color = 16 * 12; 218 - break; 219 - case 'd': 220 - case 'D': 221 - color = 16 * 13; 222 - break; 223 - case 'e': 224 - case 'E': 225 - color = 16 * 14; 226 - break; 227 - case 'f': 228 - case 'F': 229 - color = 16 * 15; 230 - break; 231 - }; 232 - switch (lo) 233 - { 234 - case '1': 235 - color += 1; 236 - break; 237 - case '2': 238 - color += 2; 239 - break; 240 - case '3': 241 - color += 3; 242 - break; 243 - case '4': 244 - color += 4; 245 - break; 246 - case '5': 247 - color += 5; 248 - break; 249 - case '6': 250 - color += 6; 251 - break; 252 - case '7': 253 - color += 7; 254 - break; 255 - case '8': 256 - color += 8; 257 - break; 258 - case '9': 259 - color += 9; 260 - break; 261 - case 'a': 262 - case 'A': 263 - color += 10; 264 - break; 265 - case 'b': 266 - case 'B': 267 - color += 11; 268 - break; 269 - case 'c': 270 - case 'C': 271 - color += 12; 272 - break; 273 - case 'd': 274 - case 'D': 275 - color += 13; 276 - break; 277 - case 'e': 278 - case 'E': 279 - color += 14; 280 - break; 281 - case 'f': 282 - case 'F': 283 - color += 15; 284 - break; 285 - }; 286 - return color / 255.0; 287 -} 288 - 289 -static void 290 -gg_svg_from_named_color (char *buf, const char *color) 291 -{ 292 -/* translating some CSS name into an hex RGB */ 293 - *buf = '\0'; 294 - if (strcmp (color, "black") == 0) 295 - strcpy (buf, "#000000"); 296 - else if (strcmp (color, "silver") == 0) 297 - strcpy (buf, "#C0C0C0"); 298 - else if (strcmp (color, "gray") == 0) 299 - strcpy (buf, "#808080"); 300 - else if (strcmp (color, "white") == 0) 301 - strcpy (buf, "#FFFFFF"); 302 - else if (strcmp (color, "maroon") == 0) 303 - strcpy (buf, "#800000"); 304 - else if (strcmp (color, "red") == 0) 305 - strcpy (buf, "#FF0000"); 306 - else if (strcmp (color, "purple") == 0) 307 - strcpy (buf, "#800080"); 308 - else if (strcmp (color, "fuchsia") == 0) 309 - strcpy (buf, "#FF00FF"); 310 - else if (strcmp (color, "green") == 0) 311 - strcpy (buf, "#008000"); 312 - else if (strcmp (color, "lime") == 0) 313 - strcpy (buf, "#00FF00"); 314 - else if (strcmp (color, "olive") == 0) 315 - strcpy (buf, "#808000"); 316 - else if (strcmp (color, "yellow") == 0) 317 - strcpy (buf, "#FFFF00"); 318 - else if (strcmp (color, "navy") == 0) 319 - strcpy (buf, "#000080"); 320 - else if (strcmp (color, "blue") == 0) 321 - strcpy (buf, "#0000FF"); 322 - else if (strcmp (color, "teal") == 0) 323 - strcpy (buf, "#008080"); 324 - else if (strcmp (color, "aqua") == 0) 325 - strcpy (buf, "#00FFFF"); 326 -} 327 - 328 -static int 329 -gg_svg_consume_float (const char **ptr, double *value) 330 -{ 331 -/* attempting to parse a Double value from a string */ 332 - char buf[1024]; 333 - char *p_out = buf; 334 - const char *p_in = *ptr; 335 - int count_e = 0; 336 - int count_pt = 0; 337 - if (ptr == NULL) 338 - return 0; 339 - if (*ptr == '\0') 340 - return 0; 341 - 342 - while (1) 343 - { 344 - if (*p_in == '\0') 345 - { 346 - *p_out = '\0'; 347 - *ptr = p_in; 348 - break; 349 - } 350 - if (p_out == buf) 351 - { 352 - if (*p_in == '-' || *p_in == '+') 353 - { 354 - *p_out++ = *p_in++; 355 - continue; 356 - } 357 - if (*p_in == ',' || *p_in == ' ' || *p_in == '\t' 358 - || *p_in == '\r' || *p_in == '\n') 359 - { 360 - p_in++; 361 - continue; 362 - } 363 - } 364 - if (*p_in >= '0' && *p_in <= '9') 365 - { 366 - *p_out++ = *p_in++; 367 - continue; 368 - } 369 - else if (*p_in == 'e' || *p_in == 'E') 370 - { 371 - count_e++; 372 - *p_out++ = *p_in++; 373 - if (*p_in == '-' || *p_in == '+') 374 - *p_out++ = *p_in++; 375 - continue; 376 - } 377 - else if (*p_in == '.') 378 - { 379 - count_pt++; 380 - *p_out++ = *p_in++; 381 - continue; 382 - } 383 - else 384 - { 385 - *p_out = '\0'; 386 - switch (*p_in) 387 - { 388 - /* SVG Path keyword - unput */ 389 - case 'C': 390 - case 'c': 391 - case 'S': 392 - case 's': 393 - case 'Q': 394 - case 'q': 395 - case 'T': 396 - case 't': 397 - case 'M': 398 - case 'm': 399 - case 'L': 400 - case 'l': 401 - case 'H': 402 - case 'h': 403 - case 'V': 404 - case 'v': 405 - case 'A': 406 - case 'a': 407 - case 'Z': 408 - case 'z': 409 - case '+': 410 - case '-': 411 - p_in--; 412 - break; 413 - }; 414 - break; 415 - } 416 - } 417 - if (count_pt > 1 || count_e > 1) 418 - return 0; 419 - if (*buf != '\0') 420 - { 421 - *value = atof (buf); 422 - *ptr = p_in; 423 - return 1; 424 - } 425 - return 0; 426 -} 427 - 428 -static void 429 -gg_svg_parse_path_d (struct gg_svg_path *path, const char *value) 430 -{ 431 -/* parsing an SVG Path <d> */ 432 - char keyword = '\0'; 433 - int count = 0; 434 - const char *p_in = value; 435 - double coord; 436 - double coord_array[7]; 437 - double first_x = DBL_MAX; 438 - double first_y = DBL_MAX; 439 - double last_x = DBL_MAX; 440 - double last_y = DBL_MAX; 441 - double bezier_reflect_x; 442 - double bezier_reflect_y; 443 - double x; 444 - double y; 445 - double x1; 446 - double y1; 447 - double x2; 448 - double y2; 449 - void *data; 450 - int last_m = 0; 451 - 452 - while (1) 453 - { 454 - if (*p_in == '\0') 455 - break; 456 - switch (*p_in) 457 - { 458 - case ' ': 459 - case '\t': 460 - case '\n': 461 - case '\r': 462 - break; 463 - case 'Z': 464 - case 'z': 465 - gg_svg_add_path_item (path, GG_SVG_CLOSE_PATH, NULL); 466 - last_x = first_x; 467 - last_y = first_y; 468 - keyword = '\0'; 469 - break; 470 - case 'C': 471 - case 'c': 472 - case 'S': 473 - case 's': 474 - case 'Q': 475 - case 'q': 476 - case 'T': 477 - case 't': 478 - keyword = *p_in; 479 - break; 480 - case 'M': 481 - case 'm': 482 - case 'L': 483 - case 'l': 484 - case 'H': 485 - case 'h': 486 - case 'V': 487 - case 'v': 488 - case 'A': 489 - case 'a': 490 - bezier_reflect_x = DBL_MAX; 491 - bezier_reflect_y = DBL_MAX; /* invalidating Bezier reflect point */ 492 - keyword = *p_in; 493 - break; 494 - case '0': 495 - case '1': 496 - case '2': 497 - case '3': 498 - case '4': 499 - case '5': 500 - case '6': 501 - case '7': 502 - case '8': 503 - case '9': 504 - case '.': 505 - case '+': 506 - case '-': 507 - if (!gg_svg_consume_float (&p_in, &coord)) 508 - { 509 - path->error = 1; 510 - return; 511 - } 512 - if (count < 7) 513 - coord_array[count] = coord; 514 - count++; 515 - break; 516 - default: 517 - path->error = 1; 518 - break; 519 - }; 520 - if (last_m && keyword == 'M') 521 - keyword = 'L'; 522 - if (last_m && keyword == 'm') 523 - keyword = 'l'; 524 - switch (keyword) 525 - { 526 - case 'M': 527 - if (count == 2) 528 - { 529 - /* SVG Path MoveTo - absolute */ 530 - data = 531 - gg_svg_alloc_path_move (coord_array[0], 532 - coord_array[1]); 533 - gg_svg_add_path_item (path, GG_SVG_MOVE_TO, data); 534 - count = 0; 535 - last_x = coord_array[0]; 536 - last_y = coord_array[1]; 537 - first_x = last_x; 538 - first_y = last_y; 539 - last_m = 1; 540 - } 541 - break; 542 - case 'm': 543 - if (count == 2) 544 - { 545 - /* SVG Path MoveTo - relative */ 546 - if (last_x == DBL_MAX || last_y == DBL_MAX) 547 - { 548 - /* assuming absolute coords */ 549 - x = coord_array[0]; 550 - y = coord_array[1]; 551 - } 552 - else 553 - { 554 - /* transforming relative coords into absolute */ 555 - x = last_x + coord_array[0]; 556 - y = last_y + coord_array[1]; 557 - } 558 - data = gg_svg_alloc_path_move (x, y); 559 - gg_svg_add_path_item (path, GG_SVG_MOVE_TO, data); 560 - count = 0; 561 - last_x = x; 562 - last_y = y; 563 - last_m = 1; 564 - first_x = last_x; 565 - first_y = last_y; 566 - } 567 - break; 568 - case 'L': 569 - if (count == 2) 570 - { 571 - /* SVG Path LineTo - absolute */ 572 - data = 573 - gg_svg_alloc_path_move (coord_array[0], 574 - coord_array[1]); 575 - gg_svg_add_path_item (path, GG_SVG_LINE_TO, data); 576 - count = 0; 577 - last_x = coord_array[0]; 578 - last_y = coord_array[1]; 579 - last_m = 0; 580 - } 581 - break; 582 - case 'l': 583 - if (count == 2) 584 - { 585 - /* SVG Path LineTo - relative */ 586 - if (last_x == DBL_MAX || last_y == DBL_MAX) 587 - { 588 - /* assuming absolute coords */ 589 - x = coord_array[0]; 590 - y = coord_array[1]; 591 - } 592 - else 593 - { 594 - /* transforming relative coords into absolute */ 595 - x = last_x + coord_array[0]; 596 - y = last_y + coord_array[1]; 597 - } 598 - data = gg_svg_alloc_path_move (x, y); 599 - gg_svg_add_path_item (path, GG_SVG_LINE_TO, data); 600 - count = 0; 601 - last_x = x; 602 - last_y = y; 603 - last_m = 0; 604 - } 605 - break; 606 - case 'H': 607 - if (count == 1) 608 - { 609 - /* SVG Path Horizontal LineTo - absolute */ 610 - data = gg_svg_alloc_path_move (coord_array[0], last_y); 611 - gg_svg_add_path_item (path, GG_SVG_LINE_TO, data); 612 - count = 0; 613 - last_x = coord_array[0]; 614 - last_m = 0; 615 - } 616 - break; 617 - case 'h': 618 - if (count == 1) 619 - { 620 - /* SVG Path Horizontal LineTo - relative */ 621 - if (last_x == DBL_MAX) 622 - { 623 - /* assuming absolute coords */ 624 - x = coord_array[0]; 625 - } 626 - else 627 - { 628 - /* transforming relative coords into absolute */ 629 - x = last_x + coord_array[0]; 630 - } 631 - data = gg_svg_alloc_path_move (x, last_y); 632 - gg_svg_add_path_item (path, GG_SVG_LINE_TO, data); 633 - count = 0; 634 - last_x = x; 635 - last_m = 0; 636 - } 637 - break; 638 - case 'V': 639 - if (count == 1) 640 - { 641 - /* SVG Path Vertical LineTo - absolute */ 642 - data = gg_svg_alloc_path_move (last_x, coord_array[0]); 643 - gg_svg_add_path_item (path, GG_SVG_LINE_TO, data); 644 - count = 0; 645 - last_y = coord_array[0]; 646 - last_m = 0; 647 - } 648 - break; 649 - case 'v': 650 - if (count == 1) 651 - { 652 - /* SVG Path Vertical LineTo - relative */ 653 - if (last_y == DBL_MAX) 654 - { 655 - /* assuming absolute coords */ 656 - y = coord_array[0]; 657 - } 658 - else 659 - { 660 - /* transforming relative coords into absolute */ 661 - y = last_y + coord_array[0]; 662 - } 663 - data = gg_svg_alloc_path_move (last_x, y); 664 - gg_svg_add_path_item (path, GG_SVG_LINE_TO, data); 665 - count = 0; 666 - last_y = y; 667 - last_m = 0; 668 - } 669 - break; 670 - case 'C': 671 - if (count == 6) 672 - { 673 - /* SVG Path Cubic Bezier CurveTo - absolute */ 674 - data = 675 - gg_svg_alloc_path_bezier (coord_array[0], 676 - coord_array[1], 677 - coord_array[2], 678 - coord_array[3], 679 - coord_array[4], 680 - coord_array[5]); 681 - gg_svg_add_path_item (path, GG_SVG_CURVE_3, data); 682 - count = 0; 683 - last_x = coord_array[4]; 684 - last_y = coord_array[5]; 685 - /* reflection of the second control point */ 686 - bezier_reflect_x = 687 - coord_array[4] - (coord_array[2] - coord_array[4]); 688 - bezier_reflect_y = 689 - coord_array[5] - (coord_array[3] - coord_array[5]); 690 - last_m = 0; 691 - } 692 - break; 693 - case 'c': 694 - if (count == 6) 695 - { 696 - /* SVG Path Cubic Bezier CurveTo - relative */ 697 - if (last_x == DBL_MAX || last_y == DBL_MAX) 698 - { 699 - /* assuming absolute coords */ 700 - x1 = coord_array[0]; 701 - y1 = coord_array[1]; 702 - x2 = coord_array[2]; 703 - y2 = coord_array[3]; 704 - x = coord_array[4]; 705 - y = coord_array[5]; 706 - } 707 - else 708 - { 709 - /* transforming relative coords into absolute */ 710 - x1 = last_x + coord_array[0]; 711 - y1 = last_y + coord_array[1]; 712 - x2 = last_x + coord_array[2]; 713 - y2 = last_y + coord_array[3]; 714 - x = last_x + coord_array[4]; 715 - y = last_y + coord_array[5]; 716 - } 717 - data = gg_svg_alloc_path_bezier (x1, y1, x2, y2, x, y); 718 - gg_svg_add_path_item (path, GG_SVG_CURVE_3, data); 719 - count = 0; 720 - last_x = x; 721 - last_y = y; 722 - /* reflection of the second control point */ 723 - bezier_reflect_x = x - (x2 - x); 724 - bezier_reflect_y = y - (y2 - y); 725 - last_m = 0; 726 - } 727 - break; 728 - case 'S': 729 - if (count == 4) 730 - { 731 - /* SVG Path Cubic Bezier CurveTo [short] - absolute */ 732 - if (bezier_reflect_x == DBL_MAX 733 - || bezier_reflect_y == DBL_MAX) 734 - { 735 - /* assuming the current point as Bezier reflected point */ 736 - bezier_reflect_x = coord_array[2]; 737 - bezier_reflect_y = coord_array[3]; 738 - } 739 - data = 740 - gg_svg_alloc_path_bezier (bezier_reflect_x, 741 - bezier_reflect_y, 742 - coord_array[0], 743 - coord_array[1], 744 - coord_array[2], 745 - coord_array[3]); 746 - gg_svg_add_path_item (path, GG_SVG_CURVE_3, data); 747 - count = 0; 748 - last_x = coord_array[2]; 749 - last_y = coord_array[3]; 750 - /* reflection of the second control point */ 751 - bezier_reflect_x = 752 - coord_array[2] - (coord_array[0] - coord_array[2]); 753 - bezier_reflect_y = 754 - coord_array[3] - (coord_array[1] - coord_array[3]); 755 - last_m = 0; 756 - } 757 - break; 758 - case 's': 759 - if (count == 4) 760 - { 761 - /* SVG Path Cubic Bezier CurveTo [short] - relative */ 762 - if (last_x == DBL_MAX || last_y == DBL_MAX) 763 - { 764 - /* assuming absolute coords */ 765 - x2 = coord_array[0]; 766 - y2 = coord_array[1]; 767 - x = coord_array[2]; 768 - y = coord_array[3]; 769 - } 770 - else 771 - { 772 - /* transforming relative coords into absolute */ 773 - x2 = last_x + coord_array[0]; 774 - y2 = last_y + coord_array[1]; 775 - x = last_x + coord_array[2]; 776 - y = last_y + coord_array[3]; 777 - } 778 - if (bezier_reflect_x == DBL_MAX 779 - || bezier_reflect_y == DBL_MAX) 780 - { 781 - /* assuming the current point as Bezier reflected point */ 782 - bezier_reflect_x = last_x; 783 - bezier_reflect_y = last_y; 784 - } 785 - data = 786 - gg_svg_alloc_path_bezier (bezier_reflect_x, 787 - bezier_reflect_y, x2, y2, x, 788 - y); 789 - gg_svg_add_path_item (path, GG_SVG_CURVE_3, data); 790 - count = 0; 791 - last_x = x; 792 - last_y = y; 793 - /* reflection of the second control point */ 794 - bezier_reflect_x = x - (x2 - x); 795 - bezier_reflect_y = y - (y2 - y); 796 - last_m = 0; 797 - } 798 - break; 799 - case 'Q': 800 - if (count == 4) 801 - { 802 - /* SVG Path Quadratic Bezier CurveTo - absolute */ 803 - data = 804 - gg_svg_alloc_path_bezier (coord_array[0], 805 - coord_array[1], 806 - coord_array[2], 807 - coord_array[3], 0.0, 0.0); 808 - gg_svg_add_path_item (path, GG_SVG_CURVE_4, data); 809 - count = 0; 810 - last_x = coord_array[2]; 811 - last_y = coord_array[3]; 812 - /* reflection of the control point */ 813 - bezier_reflect_x = 814 - coord_array[2] - (coord_array[0] - coord_array[2]); 815 - bezier_reflect_y = 816 - coord_array[3] - (coord_array[1] - coord_array[3]); 817 - last_m = 0; 818 - } 819 - break; 820 - case 'q': 821 - if (count == 4) 822 - { 823 - /* SVG Path Quadratic Bezier CurveTo - relative */ 824 - if (last_x == DBL_MAX || last_y == DBL_MAX) 825 - { 826 - /* assuming absolute coords */ 827 - x1 = coord_array[0]; 828 - y1 = coord_array[1]; 829 - x = coord_array[2]; 830 - y = coord_array[3]; 831 - } 832 - else 833 - { 834 - /* transforming relative coords into absolute */ 835 - x1 = last_x + coord_array[0]; 836 - y1 = last_y + coord_array[1]; 837 - x = last_x + coord_array[2]; 838 - y = last_y + coord_array[3]; 839 - } 840 - data = gg_svg_alloc_path_bezier (x1, y1, x, y, 0.0, 0.0); 841 - gg_svg_add_path_item (path, GG_SVG_CURVE_4, data); 842 - count = 0; 843 - last_x = x; 844 - last_y = y; 845 - /* reflection of the control point */ 846 - bezier_reflect_x = x - (x1 - x); 847 - bezier_reflect_y = y - (y1 - y); 848 - last_m = 0; 849 - } 850 - break; 851 - case 'T': 852 - if (count == 2) 853 - { 854 - /* SVG Path Quadratic Bezier CurveTo [short] - absolute */ 855 - if (bezier_reflect_x == DBL_MAX 856 - || bezier_reflect_y == DBL_MAX) 857 - { 858 - /* assuming the current point as Bezier reflected point */ 859 - bezier_reflect_x = coord_array[0]; 860 - bezier_reflect_y = coord_array[1]; 861 - } 862 - data = 863 - gg_svg_alloc_path_bezier (bezier_reflect_x, 864 - bezier_reflect_y, 865 - coord_array[0], 866 - coord_array[1], 0.0, 0.0); 867 - gg_svg_add_path_item (path, GG_SVG_CURVE_4, data); 868 - count = 0; 869 - last_x = coord_array[0]; 870 - last_y = coord_array[1]; 871 - /* reflection of the control point */ 872 - bezier_reflect_x = 873 - coord_array[0] - (bezier_reflect_x - coord_array[0]); 874 - bezier_reflect_y = 875 - coord_array[1] - (bezier_reflect_y - coord_array[1]); 876 - last_m = 0; 877 - } 878 - break; 879 - case 't': 880 - if (count == 2) 881 - { 882 - /* SVG Path Quadratic Bezier CurveTo [short] - relative */ 883 - if (last_x == DBL_MAX || last_y == DBL_MAX) 884 - { 885 - /* assuming absolute coords */ 886 - x = coord_array[0]; 887 - y = coord_array[1]; 888 - } 889 - else 890 - { 891 - /* transforming relative coords into absolute */ 892 - x = last_x + coord_array[0]; 893 - y = last_y + coord_array[1]; 894 - } 895 - if (bezier_reflect_x == DBL_MAX 896 - || bezier_reflect_y == DBL_MAX) 897 - { 898 - /* assuming the current point as Bezier reflected point */ 899 - bezier_reflect_x = x; 900 - bezier_reflect_y = y; 901 - } 902 - data = 903 - gg_svg_alloc_path_bezier (bezier_reflect_x, 904 - bezier_reflect_y, x, y, 0.0, 905 - 0.0); 906 - gg_svg_add_path_item (path, GG_SVG_CURVE_4, data); 907 - count = 0; 908 - last_x = x; 909 - last_y = y; 910 - /* reflection of the control point */ 911 - bezier_reflect_x = x - (bezier_reflect_x - x); 912 - bezier_reflect_y = y - (bezier_reflect_y - y); 913 - last_m = 0; 914 - } 915 - break; 916 - case 'A': 917 - if (count == 7) 918 - { 919 - /* SVG Path EllipticalArc - absolute */ 920 - data = 921 - gg_svg_alloc_path_ellipt_arc (coord_array[0], 922 - coord_array[1], 923 - coord_array[2], 924 - coord_array[3], 925 - coord_array[4], 926 - coord_array[5], 927 - coord_array[6]); 928 - gg_svg_add_path_item (path, GG_SVG_ELLIPT_ARC, data); 929 - count = 0; 930 - last_x = coord_array[5]; 931 - last_y = coord_array[6]; 932 - last_m = 0; 933 - } 934 - break; 935 - case 'a': 936 - if (count == 7) 937 - { 938 - /* SVG Path EllipticalArc - relative */ 939 - if (last_x == DBL_MAX || last_y == DBL_MAX) 940 - { 941 - /* assuming absolute coords */ 942 - x = coord_array[5]; 943 - y = coord_array[6]; 944 - } 945 - else 946 - { 947 - /* transforming relative coords into absolute */ 948 - x = last_x + coord_array[5]; 949 - y = last_y + coord_array[6]; 950 - } 951 - if (coord_array[0] == 0.0 || coord_array[1] == 0.0) 952 - { 953 - /* ZERO radius: defaulting to a straight line */ 954 - data = gg_svg_alloc_path_move (x, y); 955 - gg_svg_add_path_item (path, GG_SVG_LINE_TO, data); 956 - } 957 - else 958 - { 959 - data = 960 - gg_svg_alloc_path_ellipt_arc (coord_array[0], 961 - coord_array[1], 962 - coord_array[2], 963 - coord_array[3], 964 - coord_array[4], x, 965 - y); 966 - gg_svg_add_path_item (path, GG_SVG_ELLIPT_ARC, 967 - data); 968 - } 969 - count = 0; 970 - last_x = x; 971 - last_y = y; 972 - last_m = 0; 973 - } 974 - break; 975 - }; 976 - if (path->error) 977 - return; 978 - if (*p_in != '\0') 979 - p_in++; 980 - } 981 -} 982 - 983 -static void 984 -gg_svg_parse_display (struct gg_svg_style *style, const char *value) 985 -{ 986 -/* parsing an SVG Display attribute */ 987 - style->fill = 1; 988 - if (strcmp (value, "none") == 0) 989 - style->visibility = 0; 990 -} 991 - 992 -static void 993 -gg_svg_parse_visibility (struct gg_svg_style *style, const char *value) 994 -{ 995 -/* parsing an SVG Visibility attribute */ 996 - style->fill = 1; 997 - if (strcmp (value, "hidden") == 0) 998 - style->visibility = 0; 999 -} 1000 - 1001 -static int 1002 -gg_svg_parse_fill_gradient_url (struct gg_svg_style *style, const char *color) 1003 -{ 1004 -/* parsing an SVG FillColor attribute (URL) */ 1005 - int len = strlen (color); 1006 - if (strncmp (color, "url(#", 5) == 0 && *(color + len - 1) == ')') 1007 - { 1008 - char buf[1024]; 1009 - strcpy (buf, color + 5); 1010 - len = strlen (buf); 1011 - buf[len - 1] = '\0'; 1012 - gg_svg_add_fill_gradient_url (style, buf); 1013 - style->fill = 1; 1014 - return 1; 1015 - } 1016 - return 0; 1017 -} 1018 - 1019 -static void 1020 -gg_svg_parse_fill_color (struct gg_svg_style *style, const char *color) 1021 -{ 1022 -/* parsing an SVG FillColor attribute */ 1023 - int len = strlen (color); 1024 - char buf[16]; 1025 - const char *p_color = NULL; 1026 - if (strcmp (color, "none") == 0) 1027 - { 1028 - style->no_fill = 1; 1029 - return; 1030 - } 1031 - if (gg_svg_parse_fill_gradient_url (style, color) == 1) 1032 - return; 1033 - style->fill = 1; 1034 - if (*color == '#' && len >= 7) 1035 - p_color = color; 1036 - else if (*color == '#' && len == 4) 1037 - { 1038 - buf[0] = *(color + 0); 1039 - buf[1] = *(color + 1); 1040 - buf[2] = *(color + 1); 1041 - buf[3] = *(color + 2); 1042 - buf[4] = *(color + 2); 1043 - buf[5] = *(color + 3); 1044 - buf[6] = *(color + 3); 1045 - p_color = buf; 1046 - } 1047 - else 1048 - { 1049 - gg_svg_from_named_color (buf, color); 1050 - if (*buf != '\0') 1051 - p_color = buf; 1052 - else 1053 - p_color = NULL; 1054 - } 1055 - if (p_color == NULL) 1056 - p_color = "#000000"; 1057 - style->fill_red = gg_svg_parse_hex_color (*(p_color + 1), *(p_color + 2)); 1058 - style->fill_green = gg_svg_parse_hex_color (*(p_color + 3), *(p_color + 4)); 1059 - style->fill_blue = gg_svg_parse_hex_color (*(p_color + 5), *(p_color + 6)); 1060 -} 1061 - 1062 -static void 1063 -gg_svg_parse_fill_rule (struct gg_svg_style *style, const char *value) 1064 -{ 1065 -/* parsing an SVG FillRule attribute */ 1066 - style->fill = 1; 1067 - if (strcmp (value, "evenodd") == 0) 1068 - style->stroke_linecap = CAIRO_FILL_RULE_EVEN_ODD; 1069 -} 1070 - 1071 -static void 1072 -gg_svg_parse_fill_opacity (struct gg_svg_style *style, const char *value) 1073 -{ 1074 -/* parsing an SVG FillOpacity attribute */ 1075 - style->fill = 1; 1076 - style->fill_opacity = atof (value); 1077 - if (style->fill_opacity <= 0.0 || style->fill_opacity >= 1.0) 1078 - style->fill_opacity = 1.0; 1079 -} 1080 - 1081 -static int 1082 -gg_svg_parse_stroke_gradient_url (struct gg_svg_style *style, const char *color) 1083 -{ 1084 -/* parsing an SVG StrokeColor attribute (URL) */ 1085 - int len = strlen (color); 1086 - if (strncmp (color, "url(#", 5) == 0 && *(color + len - 1) == ')') 1087 - { 1088 - char buf[1024]; 1089 - strcpy (buf, color + 5); 1090 - len = strlen (buf); 1091 - buf[len - 1] = '\0'; 1092 - gg_svg_add_stroke_gradient_url (style, buf); 1093 - return 1; 1094 - } 1095 - return 0; 1096 -} 1097 - 1098 -static void 1099 -gg_svg_parse_stroke_color (struct gg_svg_style *style, const char *color) 1100 -{ 1101 -/* parsing an SVG StrokeColor attribute */ 1102 - int len = strlen (color); 1103 - char buf[16]; 1104 - const char *p_color = NULL; 1105 - style->stroke = 1; 1106 - if (strcmp (color, "none") == 0) 1107 - { 1108 - style->no_stroke = 1; 1109 - return; 1110 - } 1111 - if (gg_svg_parse_stroke_gradient_url (style, color) == 1) 1112 - return; 1113 - if (*color == '#' && len >= 7) 1114 - p_color = color; 1115 - else if (*color == '#' && len == 4) 1116 - { 1117 - buf[0] = *(color + 0); 1118 - buf[1] = *(color + 1); 1119 - buf[2] = *(color + 1); 1120 - buf[3] = *(color + 2); 1121 - buf[4] = *(color + 2); 1122 - buf[5] = *(color + 3); 1123 - buf[6] = *(color + 3); 1124 - p_color = buf; 1125 - } 1126 - else 1127 - { 1128 - gg_svg_from_named_color (buf, color); 1129 - if (*color != '\0') 1130 - p_color = buf; 1131 - } 1132 - if (p_color == NULL) 1133 - p_color = "#000000"; 1134 - style->stroke_red = gg_svg_parse_hex_color (*(p_color + 1), *(p_color + 2)); 1135 - style->stroke_green = 1136 - gg_svg_parse_hex_color (*(p_color + 3), *(p_color + 4)); 1137 - style->stroke_blue = 1138 - gg_svg_parse_hex_color (*(p_color + 5), *(p_color + 6)); 1139 -} 1140 - 1141 -static void 1142 -gg_svg_parse_stop_color (const char *color, double *red, double *green, 1143 - double *blue) 1144 -{ 1145 -/* parsing an SVG StopColor attribute */ 1146 - int len = strlen (color); 1147 - char buf[16]; 1148 - const char *p_color = NULL; 1149 - if (strcmp (color, "none") == 0) 1150 - { 1151 - *red = -1.0; 1152 - *green = -1.0; 1153 - *blue = -1.0; 1154 - return; 1155 - } 1156 - if (*color == '#' && len >= 7) 1157 - p_color = color; 1158 - else if (*color == '#' && len == 4) 1159 - { 1160 - buf[0] = *(color + 0); 1161 - buf[1] = *(color + 1); 1162 - buf[2] = *(color + 1); 1163 - buf[3] = *(color + 2); 1164 - buf[4] = *(color + 2); 1165 - buf[5] = *(color + 3); 1166 - buf[6] = *(color + 3); 1167 - p_color = buf; 1168 - } 1169 - else 1170 - { 1171 - gg_svg_from_named_color (buf, color); 1172 - if (*color != '\0') 1173 - p_color = buf; 1174 - } 1175 - if (p_color == NULL) 1176 - p_color = "#000000"; 1177 - *red = gg_svg_parse_hex_color (*(p_color + 1), *(p_color + 2)); 1178 - *green = gg_svg_parse_hex_color (*(p_color + 3), *(p_color + 4)); 1179 - *blue = gg_svg_parse_hex_color (*(p_color + 5), *(p_color + 6)); 1180 -} 1181 - 1182 -static void 1183 -gg_svg_parse_stroke_width (struct gg_svg_style *style, const char *value) 1184 -{ 1185 -/* parsing an SVG StrokeWidth attribute */ 1186 - style->stroke = 1; 1187 - style->stroke_width = atof (value); 1188 - if (style->stroke_width <= 0.0) 1189 - style->stroke_width = 1.0; 1190 -} 1191 - 1192 -static void 1193 -gg_svg_parse_stroke_linecap (struct gg_svg_style *style, const char *value) 1194 -{ 1195 -/* parsing an SVG StrokeLineCap attribute */ 1196 - style->stroke = 1; 1197 - if (strcmp (value, "round") == 0) 1198 - style->stroke_linecap = CAIRO_LINE_CAP_ROUND; 1199 - if (strcmp (value, "square") == 0) 1200 - style->stroke_linecap = CAIRO_LINE_CAP_SQUARE; 1201 -} 1202 - 1203 -static void 1204 -gg_svg_parse_stroke_linejoin (struct gg_svg_style *style, const char *value) 1205 -{ 1206 -/* parsing an SVG StrokeLineJoin attribute */ 1207 - style->stroke = 1; 1208 - if (strcmp (value, "round") == 0) 1209 - style->stroke_linejoin = CAIRO_LINE_JOIN_ROUND; 1210 - if (strcmp (value, "bevel") == 0) 1211 - style->stroke_linejoin = CAIRO_LINE_JOIN_BEVEL; 1212 -} 1213 - 1214 -static void 1215 -gg_svg_parse_stroke_miterlimit (struct gg_svg_style *style, const char *value) 1216 -{ 1217 -/* parsing an SVG MiterLimit attribute */ 1218 - style->stroke = 1; 1219 - style->stroke_miterlimit = atof (value); 1220 - if (style->stroke_miterlimit <= 0.0) 1221 - style->stroke_miterlimit = 10.0; 1222 -} 1223 - 1224 -static void 1225 -gg_svg_parse_stroke_dashoffset (struct gg_svg_style *style, const char *value) 1226 -{ 1227 -/* parsing an SVG DashOffset attribute */ 1228 - style->stroke = 1; 1229 - style->stroke_dashoffset = atof (value); 1230 -} 1231 - 1232 -static void 1233 -gg_svg_parse_stroke_dasharray (struct gg_svg_style *style, const char *value) 1234 -{ 1235 -/* parsing an SVG DashArray attribute */ 1236 - double dash_list[1024]; 1237 - int items = 0; 1238 - char token[1024]; 1239 - char *p_out = token; 1240 - const char *p_in = value; 1241 - if (style->stroke_dasharray != NULL) 1242 - free (style->stroke_dasharray); 1243 - style->stroke_dasharray = NULL; 1244 - style->stroke_dashitems = 0; 1245 - if (strcmp (value, "none") == 0) 1246 - return; 1247 - fprintf (stderr, "dash=%s\n", value); 1248 - while (1) 1249 - { 1250 - if (*p_in == ' ' || *p_in == ',' || *p_in == '\0') 1251 - { 1252 - *p_out++ = '\0'; 1253 - if (*token != '\0') 1254 - dash_list[items++] = atof (token); 1255 - if (*p_in == '\0') 1256 - break; 1257 - p_out = token; 1258 - p_in++; 1259 - continue; 1260 - } 1261 - *p_out++ = *p_in++; 1262 - } 1263 - if (items > 0) 1264 - { 1265 - int i; 1266 - if (items % 2 == 0) 1267 - { 1268 - /* even number */ 1269 - style->stroke_dashitems = items; 1270 - style->stroke_dasharray = malloc (sizeof (double) * items); 1271 - for (i = 0; i < items; i++) 1272 - style->stroke_dasharray[i] = dash_list[i]; 1273 - } 1274 - else 1275 - { 1276 - /* odd number: doubling */ 1277 - int o = 0; 1278 - style->stroke_dashitems = items * 2; 1279 - style->stroke_dasharray = malloc (sizeof (double) * items * 2); 1280 - for (i = 0; i < items; i++) 1281 - style->stroke_dasharray[o++] = dash_list[i]; 1282 - for (i = 0; i < items; i++) 1283 - style->stroke_dasharray[o++] = dash_list[i]; 1284 - } 1285 - } 1286 - style->stroke = 1; 1287 -} 1288 - 1289 -static void 1290 -gg_svg_parse_opacity (struct gg_svg_style *style, const char *value) 1291 -{ 1292 -/* parsing an SVG Opacity attribute */ 1293 - style->opacity = atof (value); 1294 - if (style->opacity <= 0.0 || style->opacity >= 1.0) 1295 - style->opacity = 1.0; 1296 -} 1297 - 1298 -static void 1299 -gg_svg_parse_stroke_opacity (struct gg_svg_style *style, const char *value) 1300 -{ 1301 -/* parsing an SVG StrokeOpacity attribute */ 1302 - style->stroke = 1; 1303 - style->stroke_opacity = atof (value); 1304 - if (style->stroke_opacity <= 0.0 || style->stroke_opacity >= 1.0) 1305 - style->stroke_opacity = 1.0; 1306 -} 1307 - 1308 -static void 1309 -gg_svg_parse_stop_opacity (const char *value, double *opacity) 1310 -{ 1311 -/* parsing an SVG Stop attribute */ 1312 - *opacity = atof (value); 1313 -} 1314 - 1315 -static void 1316 -gg_svg_split_css_token (struct gg_svg_style *style, char *value) 1317 -{ 1318 -/* parsing an SVG CSS Style definition - single item */ 1319 - char *p = value; 1320 - char *p_value = NULL; 1321 - while (*p != '\0') 1322 - { 1323 - if (*p == ':') 1324 - { 1325 - *p = '\0'; 1326 - p_value = p + 1; 1327 - break; 1328 - } 1329 - p++; 1330 - } 1331 - if (p_value == NULL) 1332 - return; 1333 - if (strcmp (value, "opacity") == 0) 1334 - gg_svg_parse_opacity (style, p_value); 1335 - else if (strcmp (value, "stroke") == 0) 1336 - gg_svg_parse_stroke_color (style, p_value); 1337 - else if (strcmp (value, "stroke-width") == 0) 1338 - gg_svg_parse_stroke_width (style, p_value); 1339 - else if (strcmp (value, "stroke-linecap") == 0) 1340 - gg_svg_parse_stroke_linecap (style, p_value); 1341 - else if (strcmp (value, "stroke-linejoin") == 0) 1342 - gg_svg_parse_stroke_linejoin (style, p_value); 1343 - else if (strcmp (value, "stroke-miterlimit") == 0) 1344 - gg_svg_parse_stroke_miterlimit (style, p_value); 1345 - else if (strcmp (value, "stroke-dasharray") == 0) 1346 - gg_svg_parse_stroke_dasharray (style, p_value); 1347 - else if (strcmp (value, "stroke-dashoffset") == 0) 1348 - gg_svg_parse_stroke_dashoffset (style, p_value); 1349 - else if (strcmp (value, "stroke-opacity") == 0) 1350 - gg_svg_parse_stroke_opacity (style, p_value); 1351 - else if (strcmp (value, "fill") == 0) 1352 - gg_svg_parse_fill_color (style, p_value); 1353 - else if (strcmp (value, "fill-rule") == 0) 1354 - gg_svg_parse_fill_rule (style, p_value); 1355 - else if (strcmp (value, "fill-opacity") == 0) 1356 - gg_svg_parse_fill_opacity (style, p_value); 1357 - else if (strcmp (value, "display") == 0) 1358 - gg_svg_parse_display (style, p_value); 1359 - else if (strcmp (value, "visibility") == 0) 1360 - gg_svg_parse_visibility (style, p_value); 1361 -} 1362 - 1363 -static void 1364 -gg_svg_parse_css (struct gg_svg_style *style, const char *value) 1365 -{ 1366 -/* parsing an SVG CSS Style definition */ 1367 - const char *p_in = value; 1368 - char token[128]; 1369 - char *p_out = token; 1370 - while (1) 1371 - { 1372 - if (*p_in == ' ' || *p_in == '\t' || *p_in == '\r' || *p_in == '\n') 1373 - { 1374 - p_in++; 1375 - continue; 1376 - } 1377 - if (*p_in == '\0') 1378 - { 1379 - *p_out = '\0'; 1380 - gg_svg_split_css_token (style, token); 1381 - break; 1382 - } 1383 - if (*p_in == ';') 1384 - { 1385 - *p_out = '\0'; 1386 - gg_svg_split_css_token (style, token); 1387 - p_out = token; 1388 - p_in++; 1389 - continue; 1390 - } 1391 - *p_out++ = *p_in++; 1392 - } 1393 -} 1394 - 1395 -static void 1396 -gg_svg_split_stop_token (char *value, double *red, double *green, double *blue, 1397 - double *opacity) 1398 -{ 1399 -/* parsing an SVG Stop Style definition - single item */ 1400 - char *p = value; 1401 - char *p_value = NULL; 1402 - while (*p != '\0') 1403 - { 1404 - if (*p == ':') 1405 - { 1406 - *p = '\0'; 1407 - p_value = p + 1; 1408 - break; 1409 - } 1410 - p++; 1411 - } 1412 - if (p_value == NULL) 1413 - return; 1414 - if (strcmp (value, "stop-color") == 0) 1415 - gg_svg_parse_stop_color (p_value, red, green, blue); 1416 - else if (strcmp (value, "stop-opacity") == 0) 1417 - gg_svg_parse_stop_opacity (p_value, opacity); 1418 -} 1419 - 1420 -static void 1421 -gg_svg_parse_stop_style (const char *value, double *red, double *green, 1422 - double *blue, double *opacity) 1423 -{ 1424 -/* parsing an SVG Stop-Style */ 1425 - const char *p_in = value; 1426 - char token[128]; 1427 - char *p_out = token; 1428 - while (1) 1429 - { 1430 - if (*p_in == ' ' || *p_in == '\t' || *p_in == '\r' || *p_in == '\n') 1431 - { 1432 - p_in++; 1433 - continue; 1434 - } 1435 - if (*p_in == '\0') 1436 - { 1437 - *p_out = '\0'; 1438 - gg_svg_split_stop_token (token, red, green, blue, opacity); 1439 - break; 1440 - } 1441 - if (*p_in == ';') 1442 - { 1443 - *p_out = '\0'; 1444 - gg_svg_split_stop_token (token, red, green, blue, opacity); 1445 - p_out = token; 1446 - p_in++; 1447 - continue; 1448 - } 1449 - *p_out++ = *p_in++; 1450 - } 1451 -} 1452 - 1453 -static void 1454 -gg_svg_parse_style (struct gg_svg_group *group, struct gg_svg_shape *shape, 1455 - struct gg_svg_use *use, struct _xmlAttr *attr) 1456 -{ 1457 -/* parsing SVG Style-related definitions */ 1458 - struct gg_svg_style *style = NULL; 1459 - if (group != NULL) 1460 - style = &(group->style); 1461 - else if (use != NULL) 1462 - style = &(use->style); 1463 - else 1464 - style = &(shape->style); 1465 - 1466 - while (attr) 1467 - { 1468 - if (attr->type == XML_ATTRIBUTE_NODE) 1469 - { 1470 - const char *value = NULL; 1471 - const char *name; 1472 - xmlNodePtr child = attr->children; 1473 - name = (const char *) (attr->name); 1474 - if (child) 1475 - value = (const char *) (child->content); 1476 - if (child && value) 1477 - { 1478 - if (strcmp (name, "style") == 0) 1479 - gg_svg_parse_css (style, value); 1480 - else if (strcmp (name, "stroke") == 0) 1481 - gg_svg_parse_stroke_color (style, value); 1482 - else if (strcmp (name, "stroke-width") == 0) 1483 - gg_svg_parse_stroke_width (style, value); 1484 - else if (strcmp (name, "stroke-linecap") == 0) 1485 - gg_svg_parse_stroke_linecap (style, value); 1486 - else if (strcmp (name, "stroke-linejoin") == 0) 1487 - gg_svg_parse_stroke_linejoin (style, value); 1488 - else if (strcmp (name, "stroke-miterlimit") == 0) 1489 - gg_svg_parse_stroke_miterlimit (style, value); 1490 - else if (strcmp (name, "stroke-dasharray") == 0) 1491 - gg_svg_parse_stroke_dasharray (style, value); 1492 - else if (strcmp (name, "stroke-dashoffset") == 0) 1493 - gg_svg_parse_stroke_dashoffset (style, value); 1494 - else if (strcmp (name, "stroke-opacity") == 0) 1495 - gg_svg_parse_stroke_opacity (style, value); 1496 - else if (strcmp (name, "fill") == 0) 1497 - gg_svg_parse_fill_color (style, value); 1498 - else if (strcmp (name, "fill-rule") == 0) 1499 - gg_svg_parse_fill_rule (style, value); 1500 - else if (strcmp (name, "fill-opacity") == 0) 1501 - gg_svg_parse_fill_opacity (style, value); 1502 - else if (strcmp (name, "display") == 0) 1503 - gg_svg_parse_display (style, value); 1504 - else if (strcmp (name, "visibility") == 0) 1505 - gg_svg_parse_visibility (style, value); 1506 - } 1507 - } 1508 - attr = attr->next; 1509 - } 1510 -} 1511 - 1512 -static void 1513 -gg_svg_parse_id (struct gg_svg_group *group, struct gg_svg_clip *clip, 1514 - struct gg_svg_shape *shape, struct _xmlAttr *attr) 1515 -{ 1516 -/* parsing SVG an eventual ID definitions */ 1517 - while (attr) 1518 - { 1519 - if (attr->type == XML_ATTRIBUTE_NODE) 1520 - { 1521 - const char *value = NULL; 1522 - const char *name; 1523 - xmlNodePtr child = attr->children; 1524 - name = (const char *) (attr->name); 1525 - if (child) 1526 - value = (const char *) (child->content); 1527 - if (child && value) 1528 - { 1529 - if (strcmp (name, "id") == 0) 1530 - { 1531 - if (group != NULL) 1532 - gg_svg_add_group_id (group, value); 1533 - if (clip != NULL) 1534 - gg_svg_add_clip_id (clip, value); 1535 - if (shape != NULL) 1536 - gg_svg_add_shape_id (shape, value); 1537 - } 1538 - } 1539 - } 1540 - attr = attr->next; 1541 - } 1542 -} 1543 - 1544 -static void 1545 -gg_svg_consume_whitespace (const char **ptr) 1546 -{ 1547 -/* consuming whitespaces and commas */ 1548 - const char *p = *ptr; 1549 - while (1) 1550 - { 1551 - if (*p == ' ' || *p == ',' || *p == '\t' || *p == '\r' || *p == '\n') 1552 - { 1553 - p++; 1554 - continue; 1555 - } 1556 - break; 1557 - } 1558 - *ptr = p; 1559 -} 1560 - 1561 -static int 1562 -gg_svg_find_transform_mode (const char **ptr) 1563 -{ 1564 - const char *p = *ptr; 1565 - if (strncmp (p, "matrix", 6) == 0) 1566 - { 1567 - *ptr += 6; 1568 - return GG_SVG_MATRIX; 1569 - } 1570 - if (strncmp (p, "translate", 9) == 0) 1571 - { 1572 - *ptr += 9; 1573 - return GG_SVG_TRANSLATE; 1574 - } 1575 - if (strncmp (p, "scale", 5) == 0) 1576 - { 1577 - *ptr += 5; 1578 - return GG_SVG_SCALE; 1579 - } 1580 - if (strncmp (p, "rotate", 6) == 0) 1581 - { 1582 - *ptr += 6; 1583 - return GG_SVG_ROTATE; 1584 - } 1585 - if (strncmp (p, "skewX", 5) == 0) 1586 - { 1587 - *ptr += 5; 1588 - return GG_SVG_SKEW_X; 1589 - } 1590 - if (strncmp (p, "skewY", 5) == 0) 1591 - { 1592 - *ptr += 5; 1593 - return GG_SVG_SKEW_Y; 1594 - } 1595 - return GG_SVG_UNKNOWN; 1596 -} 1597 - 1598 -static void * 1599 -gg_svg_parse_matrix (const char **ptr) 1600 -{ 1601 -/* parsing an SVG Matrix definition */ 1602 - const char *p = *ptr; 1603 - double a; 1604 - double b; 1605 - double c; 1606 - double d; 1607 - double e; 1608 - double f; 1609 - int err = 0; 1610 - if (!gg_svg_consume_float (&p, &a)) 1611 - err = 1; 1612 - gg_svg_consume_whitespace (&p); 1613 - if (!gg_svg_consume_float (&p, &b)) 1614 - err = 1; 1615 - gg_svg_consume_whitespace (&p); 1616 - if (!gg_svg_consume_float (&p, &c)) 1617 - err = 1; 1618 - gg_svg_consume_whitespace (&p); 1619 - if (!gg_svg_consume_float (&p, &d)) 1620 - err = 1; 1621 - gg_svg_consume_whitespace (&p); 1622 - if (!gg_svg_consume_float (&p, &e)) 1623 - err = 1; 1624 - gg_svg_consume_whitespace (&p); 1625 - if (!gg_svg_consume_float (&p, &f)) 1626 - err = 1; 1627 - gg_svg_consume_whitespace (&p); 1628 - if (*p == ')') 1629 - p++; 1630 - else 1631 - err = 1; 1632 - if (!err) 1633 - { 1634 - *ptr = p; 1635 - return gg_svg_alloc_matrix (a, b, c, d, e, f); 1636 - } 1637 - return NULL; 1638 -} 1639 - 1640 -static void * 1641 -gg_svg_parse_translate (const char **ptr) 1642 -{ 1643 -/* parsing an SVG Translate definition */ 1644 - const char *p = *ptr; 1645 - double tx; 1646 - double ty; 1647 - int err = 0; 1648 - if (!gg_svg_consume_float (&p, &tx)) 1649 - err = 1; 1650 - gg_svg_consume_whitespace (&p); 1651 - if (!gg_svg_consume_float (&p, &ty)) 1652 - ty = 0.0; 1653 - gg_svg_consume_whitespace (&p); 1654 - if (*p == ')') 1655 - p++; 1656 - else 1657 - err = 1; 1658 - if (!err) 1659 - { 1660 - *ptr = p; 1661 - return gg_svg_alloc_translate (tx, ty); 1662 - } 1663 - return NULL; 1664 -} 1665 - 1666 -static void * 1667 -gg_svg_parse_scale (const char **ptr) 1668 -{ 1669 -/* parsing an SVG Scale definition */ 1670 - const char *p = *ptr; 1671 - double sx; 1672 - double sy; 1673 - int err = 0; 1674 - if (!gg_svg_consume_float (&p, &sx)) 1675 - err = 1; 1676 - gg_svg_consume_whitespace (&p); 1677 - if (!gg_svg_consume_float (&p, &sy)) 1678 - sy = 0.0; 1679 - gg_svg_consume_whitespace (&p); 1680 - if (*p == ')') 1681 - p++; 1682 - else 1683 - err = 1; 1684 - if (!err) 1685 - { 1686 - *ptr = p; 1687 - if (sy == 0.0) 1688 - sy = sx; 1689 - return gg_svg_alloc_scale (sx, sy); 1690 - } 1691 - return NULL; 1692 -} 1693 - 1694 -static void * 1695 -gg_svg_parse_rotate (const char **ptr) 1696 -{ 1697 -/* parsing an SVG Rotate definition */ 1698 - const char *p = *ptr; 1699 - double angle; 1700 - double cx; 1701 - double cy; 1702 - int err = 0; 1703 - if (!gg_svg_consume_float (&p, &angle)) 1704 - err = 1; 1705 - gg_svg_consume_whitespace (&p); 1706 - if (!gg_svg_consume_float (&p, &cx)) 1707 - cx = 0.0; 1708 - gg_svg_consume_whitespace (&p); 1709 - if (!gg_svg_consume_float (&p, &cy)) 1710 - cy = 0.0; 1711 - gg_svg_consume_whitespace (&p); 1712 - if (*p == ')') 1713 - p++; 1714 - else 1715 - err = 1; 1716 - if (!err) 1717 - { 1718 - *ptr = p; 1719 - return gg_svg_alloc_rotate (angle, cx, cy); 1720 - } 1721 - return NULL; 1722 -} 1723 - 1724 -static void * 1725 -gg_svg_parse_skew (const char **ptr) 1726 -{ 1727 -/* parsing an SVG Skew definition */ 1728 - const char *p = *ptr; 1729 - double skew = 0.0; 1730 - int err = 0; 1731 - if (!gg_svg_consume_float (&p, &skew)) 1732 - err = 1; 1733 - if (!err) 1734 - { 1735 - *ptr = p; 1736 - return gg_svg_alloc_skew (skew); 1737 - } 1738 - return NULL; 1739 -} 1740 - 1741 -static void 1742 -gg_svg_parse_transform_str (struct gg_svg_group *group, 1743 - struct gg_svg_shape *shape, struct gg_svg_use *use, 1744 - struct gg_svg_gradient *gradient, const char *str) 1745 -{ 1746 -/* parsing an SVG Transform string */ 1747 - struct gg_svg_transform *trans; 1748 - const char *p_in = str; 1749 - int type; 1750 - void *data; 1751 - 1752 - while (1) 1753 - { 1754 - gg_svg_consume_whitespace (&p_in); 1755 - if (*p_in == '\0') 1756 - break; 1757 - type = gg_svg_find_transform_mode (&p_in); 1758 - if (type == GG_SVG_UNKNOWN) 1759 - break; 1760 - gg_svg_consume_whitespace (&p_in); 1761 - if (*p_in == '\0') 1762 - break; 1763 - if (*p_in != '(') 1764 - break; 1765 - p_in++; 1766 - switch (type) 1767 - { 1768 - case GG_SVG_MATRIX: 1769 - data = gg_svg_parse_matrix (&p_in); 1770 - break; 1771 - case GG_SVG_TRANSLATE: 1772 - data = gg_svg_parse_translate (&p_in); 1773 - break; 1774 - case GG_SVG_SCALE: 1775 - data = gg_svg_parse_scale (&p_in); 1776 - break; 1777 - case GG_SVG_ROTATE: 1778 - data = gg_svg_parse_rotate (&p_in); 1779 - break; 1780 - case GG_SVG_SKEW_X: 1781 - case GG_SVG_SKEW_Y: 1782 - data = gg_svg_parse_skew (&p_in); 1783 - break; 1784 - default: 1785 - data = NULL; 1786 - break; 1787 - }; 1788 - if (data == NULL) 1789 - { 1790 - fprintf (stderr, "Invalid <transform=\"%s\">\n", str); 1791 - return; 1792 - } 1793 - trans = gg_svg_alloc_transform (type, data); 1794 - if (group != NULL) 1795 - { 1796 - if (group->first_trans == NULL) 1797 - group->first_trans = trans; 1798 - if (group->last_trans != NULL) 1799 - group->last_trans->next = trans; 1800 - group->last_trans = trans; 1801 - } 1802 - else if (shape != NULL) 1803 - { 1804 - if (shape->first_trans == NULL) 1805 - shape->first_trans = trans; 1806 - if (shape->last_trans != NULL) 1807 - shape->last_trans->next = trans; 1808 - shape->last_trans = trans; 1809 - } 1810 - else if (use != NULL) 1811 - { 1812 - if (use->first_trans == NULL) 1813 - use->first_trans = trans; 1814 - if (use->last_trans != NULL) 1815 - use->last_trans->next = trans; 1816 - use->last_trans = trans; 1817 - } 1818 - else if (gradient != NULL) 1819 - { 1820 - if (gradient->first_trans == NULL) 1821 - gradient->first_trans = trans; 1822 - if (gradient->last_trans != NULL) 1823 - gradient->last_trans->next = trans; 1824 - gradient->last_trans = trans; 1825 - } 1826 - } 1827 -} 1828 - 1829 -static void 1830 -gg_svg_parse_transform (struct gg_svg_group *group, struct gg_svg_shape *shape, 1831 - struct gg_svg_use *use, 1832 - struct gg_svg_gradient *gradient, struct _xmlAttr *attr) 1833 -{ 1834 -/* parsing SVG Transform-related definitions */ 1835 - while (attr) 1836 - { 1837 - if (attr->type == XML_ATTRIBUTE_NODE) 1838 - { 1839 - const char *value = NULL; 1840 - const char *name; 1841 - xmlNodePtr child = attr->children; 1842 - name = (const char *) (attr->name); 1843 - if (child) 1844 - value = (const char *) (child->content); 1845 - if (child && value) 1846 - { 1847 - if (gradient == NULL) 1848 - { 1849 - if (strcmp (name, "transform") == 0) 1850 - gg_svg_parse_transform_str (group, shape, use, 1851 - NULL, value); 1852 - } 1853 - else 1854 - { 1855 - if (strcmp (name, "gradientTransform") == 0) 1856 - gg_svg_parse_transform_str (NULL, NULL, NULL, 1857 - gradient, value); 1858 - } 1859 - } 1860 - } 1861 - attr = attr->next; 1862 - } 1863 -} 1864 - 1865 -static void 1866 -gg_svg_parse_clip_url (struct gg_svg_style *style, const char *value) 1867 -{ 1868 -/* parsing an SVG clip-path attribute (URL) */ 1869 - int len = strlen (value); 1870 - if (strncmp (value, "url(#", 5) == 0 && *(value + len - 1) == ')') 1871 - { 1872 - char buf[1024]; 1873 - strcpy (buf, value + 5); 1874 - len = strlen (buf); 1875 - buf[len - 1] = '\0'; 1876 - gg_svg_add_clip_url (style, buf); 1877 - } 1878 -} 1879 - 1880 -static void 1881 -gg_svg_parse_clip_path (struct gg_svg_group *group, struct gg_svg_shape *shape, 1882 - struct gg_svg_use *use, struct _xmlAttr *attr) 1883 -{ 1884 -/* parsing SVG clip-path definitions */ 1885 - while (attr) 1886 - { 1887 - if (attr->type == XML_ATTRIBUTE_NODE) 1888 - { 1889 - const char *value = NULL; 1890 - const char *name; 1891 - xmlNodePtr child = attr->children; 1892 - name = (const char *) (attr->name); 1893 - if (child) 1894 - value = (const char *) (child->content); 1895 - if (child && value) 1896 - { 1897 - if (strcmp (name, "clip-path") == 0) 1898 - { 1899 - if (group != NULL) 1900 - gg_svg_parse_clip_url (&(group->style), value); 1901 - if (shape != NULL) 1902 - gg_svg_parse_clip_url (&(shape->style), value); 1903 - if (use != NULL) 1904 - gg_svg_parse_clip_url (&(use->style), value); 1905 - } 1906 - } 1907 - } 1908 - attr = attr->next; 1909 - } 1910 -} 1911 - 1912 -static void 1913 -gg_svg_parse_rect (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 1914 -{ 1915 -/* creating and initializing an SVG Rect struct */ 1916 - struct gg_svg_rect *rect; 1917 - struct _xmlAttr *attr; 1918 - double x = 0.0; 1919 - double y = 0.0; 1920 - double width = 0.0; 1921 - double height = 0.0; 1922 - double rx = -1.0; 1923 - double ry = -1.0; 1924 - 1925 - attr = node->properties; 1926 - while (attr) 1927 - { 1928 - if (attr->type == XML_ATTRIBUTE_NODE) 1929 - { 1930 - const char *value = NULL; 1931 - const char *name; 1932 - xmlNodePtr child = attr->children; 1933 - name = (const char *) (attr->name); 1934 - if (child) 1935 - value = (const char *) (child->content); 1936 - if (child && value) 1937 - { 1938 - if (strcmp (name, "x") == 0) 1939 - x = atof (value); 1940 - if (strcmp (name, "y") == 0) 1941 - y = atof (value); 1942 - if (strcmp (name, "width") == 0) 1943 - width = atof (value); 1944 - if (strcmp (name, "height") == 0) 1945 - height = atof (value); 1946 - if (strcmp (name, "rx") == 0) 1947 - rx = atof (value); 1948 - if (strcmp (name, "ry") == 0) 1949 - ry = atof (value); 1950 - } 1951 - } 1952 - attr = attr->next; 1953 - } 1954 - if (rx > 0.0 && ry <= 0.0) 1955 - ry = rx; 1956 - if (ry > 0.0 && rx <= 0.0) 1957 - rx = ry; 1958 - rect = gg_svg_alloc_rect (x, y, width, height, rx, ry); 1959 - gg_svg_insert_shape (gg_svg_doc, GG_SVG_RECT, rect); 1960 - gg_svg_parse_id (NULL, NULL, gg_svg_doc->current_shape, node->properties); 1961 - gg_svg_parse_style (NULL, gg_svg_doc->current_shape, NULL, 1962 - node->properties); 1963 - gg_svg_parse_transform (NULL, gg_svg_doc->current_shape, NULL, NULL, 1964 - node->properties); 1965 - gg_svg_parse_clip_path (NULL, gg_svg_doc->current_shape, NULL, 1966 - node->properties); 1967 -} 1968 - 1969 -static void 1970 -gg_svg_parse_circle (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 1971 -{ 1972 -/* creating and initializing an SVG Circle struct */ 1973 - struct gg_svg_circle *circle; 1974 - struct _xmlAttr *attr; 1975 - double cx = 0.0; 1976 - double cy = 0.0; 1977 - double r = 0.0; 1978 - 1979 - attr = node->properties; 1980 - while (attr) 1981 - { 1982 - if (attr->type == XML_ATTRIBUTE_NODE) 1983 - { 1984 - const char *value = NULL; 1985 - const char *name; 1986 - xmlNodePtr child = attr->children; 1987 - name = (const char *) (attr->name); 1988 - if (child) 1989 - value = (const char *) (child->content); 1990 - if (child && value) 1991 - { 1992 - if (strcmp (name, "cx") == 0) 1993 - cx = atof (value); 1994 - if (strcmp (name, "cy") == 0) 1995 - cy = atof (value); 1996 - if (strcmp (name, "r") == 0) 1997 - r = atof (value); 1998 - } 1999 - } 2000 - attr = attr->next; 2001 - } 2002 - circle = gg_svg_alloc_circle (cx, cy, r); 2003 - gg_svg_insert_shape (gg_svg_doc, GG_SVG_CIRCLE, circle); 2004 - gg_svg_parse_id (NULL, NULL, gg_svg_doc->current_shape, node->properties); 2005 - gg_svg_parse_style (NULL, gg_svg_doc->current_shape, NULL, 2006 - node->properties); 2007 - gg_svg_parse_transform (NULL, gg_svg_doc->current_shape, NULL, NULL, 2008 - node->properties); 2009 - gg_svg_parse_clip_path (NULL, gg_svg_doc->current_shape, NULL, 2010 - node->properties); 2011 -} 2012 - 2013 -static void 2014 -gg_svg_parse_ellipse (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2015 -{ 2016 -/* creating and initializing an SVG Ellipse struct */ 2017 - struct gg_svg_ellipse *ellipse; 2018 - struct _xmlAttr *attr; 2019 - double cx = 0.0; 2020 - double cy = 0.0; 2021 - double rx = 0.0; 2022 - double ry = 0.0; 2023 - 2024 - attr = node->properties; 2025 - while (attr) 2026 - { 2027 - if (attr->type == XML_ATTRIBUTE_NODE) 2028 - { 2029 - const char *value = NULL; 2030 - const char *name; 2031 - xmlNodePtr child = attr->children; 2032 - name = (const char *) (attr->name); 2033 - if (child) 2034 - value = (const char *) (child->content); 2035 - if (child && value) 2036 - { 2037 - if (strcmp (name, "cx") == 0) 2038 - cx = atof (value); 2039 - if (strcmp (name, "cy") == 0) 2040 - cy = atof (value); 2041 - if (strcmp (name, "rx") == 0) 2042 - rx = atof (value); 2043 - if (strcmp (name, "ry") == 0) 2044 - ry = atof (value); 2045 - } 2046 - } 2047 - attr = attr->next; 2048 - } 2049 - ellipse = gg_svg_alloc_ellipse (cx, cy, rx, ry); 2050 - gg_svg_insert_shape (gg_svg_doc, GG_SVG_ELLIPSE, ellipse); 2051 - gg_svg_parse_id (NULL, NULL, gg_svg_doc->current_shape, node->properties); 2052 - gg_svg_parse_style (NULL, gg_svg_doc->current_shape, NULL, 2053 - node->properties); 2054 - gg_svg_parse_transform (NULL, gg_svg_doc->current_shape, NULL, NULL, 2055 - node->properties); 2056 - gg_svg_parse_clip_path (NULL, gg_svg_doc->current_shape, NULL, 2057 - node->properties); 2058 -} 2059 - 2060 -static void 2061 -gg_svg_parse_line (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2062 -{ 2063 -/* creating and initializing an SVG Line struct */ 2064 - struct gg_svg_line *line; 2065 - struct _xmlAttr *attr; 2066 - double x1 = 0.0; 2067 - double y1 = 0.0; 2068 - double x2 = 0.0; 2069 - double y2 = 0.0; 2070 - 2071 - attr = node->properties; 2072 - while (attr) 2073 - { 2074 - if (attr->type == XML_ATTRIBUTE_NODE) 2075 - { 2076 - const char *value = NULL; 2077 - const char *name; 2078 - xmlNodePtr child = attr->children; 2079 - name = (const char *) (attr->name); 2080 - if (child) 2081 - value = (const char *) (child->content); 2082 - if (child && value) 2083 - { 2084 - if (strcmp (name, "x1") == 0) 2085 - x1 = atof (value); 2086 - if (strcmp (name, "y1") == 0) 2087 - y1 = atof (value); 2088 - if (strcmp (name, "x2") == 0) 2089 - x2 = atof (value); 2090 - if (strcmp (name, "y2") == 0) 2091 - y2 = atof (value); 2092 - } 2093 - } 2094 - attr = attr->next; 2095 - } 2096 - line = gg_svg_alloc_line (x1, y1, x2, y2); 2097 - gg_svg_insert_shape (gg_svg_doc, GG_SVG_LINE, line); 2098 - gg_svg_parse_id (NULL, NULL, gg_svg_doc->current_shape, node->properties); 2099 - gg_svg_parse_style (NULL, gg_svg_doc->current_shape, NULL, 2100 - node->properties); 2101 - gg_svg_parse_transform (NULL, gg_svg_doc->current_shape, NULL, NULL, 2102 - node->properties); 2103 - gg_svg_parse_clip_path (NULL, gg_svg_doc->current_shape, NULL, 2104 - node->properties); 2105 -} 2106 - 2107 -static void 2108 -gg_svg_parse_polyline (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2109 -{ 2110 -/* creating and initializing an SVG Polyline struct */ 2111 - struct gg_svg_polyline *poly; 2112 - struct _xmlAttr *attr; 2113 - int points = 0; 2114 - double *x = NULL; 2115 - double *y = NULL; 2116 - 2117 - attr = node->properties; 2118 - while (attr) 2119 - { 2120 - if (attr->type == XML_ATTRIBUTE_NODE) 2121 - { 2122 - const char *value = NULL; 2123 - const char *name; 2124 - xmlNodePtr child = attr->children; 2125 - name = (const char *) (attr->name); 2126 - if (child) 2127 - value = (const char *) (child->content); 2128 - if (child && value) 2129 - { 2130 - if (strcmp (name, "points") == 0) 2131 - gg_svg_parse_points (value, &points, &x, &y); 2132 - } 2133 - } 2134 - attr = attr->next; 2135 - } 2136 - poly = gg_svg_alloc_polyline (points, x, y); 2137 - gg_svg_insert_shape (gg_svg_doc, GG_SVG_POLYLINE, poly); 2138 - gg_svg_parse_id (NULL, NULL, gg_svg_doc->current_shape, node->properties); 2139 - gg_svg_parse_style (NULL, gg_svg_doc->current_shape, NULL, 2140 - node->properties); 2141 - gg_svg_parse_transform (NULL, gg_svg_doc->current_shape, NULL, NULL, 2142 - node->properties); 2143 - gg_svg_parse_clip_path (NULL, gg_svg_doc->current_shape, NULL, 2144 - node->properties); 2145 -} 2146 - 2147 -static void 2148 -gg_svg_parse_polygon (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2149 -{ 2150 -/* creating and initializing an SVG Polygon struct */ 2151 - struct gg_svg_polygon *poly; 2152 - struct _xmlAttr *attr; 2153 - int points = 0; 2154 - double *x = NULL; 2155 - double *y = NULL; 2156 - 2157 - attr = node->properties; 2158 - while (attr) 2159 - { 2160 - if (attr->type == XML_ATTRIBUTE_NODE) 2161 - { 2162 - const char *value = NULL; 2163 - const char *name; 2164 - xmlNodePtr child = attr->children; 2165 - name = (const char *) (attr->name); 2166 - if (child) 2167 - value = (const char *) (child->content); 2168 - if (child && value) 2169 - { 2170 - if (strcmp (name, "points") == 0) 2171 - gg_svg_parse_points (value, &points, &x, &y); 2172 - } 2173 - } 2174 - attr = attr->next; 2175 - } 2176 - poly = gg_svg_alloc_polygon (points, x, y); 2177 - gg_svg_insert_shape (gg_svg_doc, GG_SVG_POLYGON, poly); 2178 - gg_svg_parse_id (NULL, NULL, gg_svg_doc->current_shape, node->properties); 2179 - gg_svg_parse_style (NULL, gg_svg_doc->current_shape, NULL, 2180 - node->properties); 2181 - gg_svg_parse_transform (NULL, gg_svg_doc->current_shape, NULL, NULL, 2182 - node->properties); 2183 - gg_svg_parse_clip_path (NULL, gg_svg_doc->current_shape, NULL, 2184 - node->properties); 2185 -} 2186 - 2187 -static void 2188 -gg_svg_parse_path (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2189 -{ 2190 -/* creating and initializing an SVG Path struct */ 2191 - struct gg_svg_path *path = gg_svg_alloc_path (); 2192 - struct _xmlAttr *attr; 2193 - 2194 - attr = node->properties; 2195 - while (attr) 2196 - { 2197 - if (attr->type == XML_ATTRIBUTE_NODE) 2198 - { 2199 - const char *value = NULL; 2200 - const char *name; 2201 - xmlNodePtr child = attr->children; 2202 - name = (const char *) (attr->name); 2203 - if (child) 2204 - value = (const char *) (child->content); 2205 - if (child && value) 2206 - { 2207 - if (strcmp (name, "d") == 0) 2208 - { 2209 - gg_svg_parse_path_d (path, value); 2210 - if (path->first == NULL || path->error) 2211 - { 2212 - /* invalid path */ 2213 - fprintf (stderr, "Invalid path d=\"%s\"\n", 2214 - value); 2215 - gg_svg_free_path (path); 2216 - return; 2217 - } 2218 - } 2219 - } 2220 - } 2221 - attr = attr->next; 2222 - } 2223 - gg_svg_insert_shape (gg_svg_doc, GG_SVG_PATH, path); 2224 - gg_svg_parse_id (NULL, NULL, gg_svg_doc->current_shape, node->properties); 2225 - gg_svg_parse_style (NULL, gg_svg_doc->current_shape, NULL, 2226 - node->properties); 2227 - gg_svg_parse_transform (NULL, gg_svg_doc->current_shape, NULL, NULL, 2228 - node->properties); 2229 - gg_svg_parse_clip_path (NULL, gg_svg_doc->current_shape, NULL, 2230 - node->properties); 2231 -} 2232 - 2233 -static void 2234 -gg_svg_parse_group (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2235 -{ 2236 -/* creating and initializing an SVG Group struct */ 2237 - gg_svg_insert_group (gg_svg_doc); 2238 - gg_svg_parse_id (gg_svg_doc->current_group, NULL, NULL, node->properties); 2239 - gg_svg_parse_style (gg_svg_doc->current_group, NULL, NULL, 2240 - node->properties); 2241 - gg_svg_parse_transform (gg_svg_doc->current_group, NULL, NULL, NULL, 2242 - node->properties); 2243 - gg_svg_parse_clip_path (gg_svg_doc->current_group, NULL, NULL, 2244 - node->properties); 2245 -} 2246 - 2247 -static void 2248 -gg_svg_parse_clip (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2249 -{ 2250 -/* creating and initializing an SVG ClipPath struct */ 2251 - gg_svg_insert_clip (gg_svg_doc); 2252 - gg_svg_parse_id (NULL, gg_svg_doc->current_clip, NULL, node->properties); 2253 -} 2254 - 2255 -static void 2256 -gg_svg_parse_use (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2257 -{ 2258 -/* creating and initializing an SVG Use struct */ 2259 - const char *xlink_href = NULL; 2260 - double x = DBL_MAX; 2261 - double y = DBL_MAX; 2262 - double width = DBL_MAX; 2263 - double height = DBL_MAX; 2264 - struct gg_svg_use *use; 2265 - struct _xmlAttr *attr = node->properties; 2266 - 2267 - while (attr) 2268 - { 2269 - if (attr->type == XML_ATTRIBUTE_NODE) 2270 - { 2271 - const char *value = NULL; 2272 - const char *name; 2273 - xmlNodePtr child = attr->children; 2274 - name = (const char *) (attr->name); 2275 - if (child) 2276 - value = (const char *) (child->content); 2277 - if (child && value) 2278 - { 2279 - if (strcmp (name, "href") == 0) 2280 - xlink_href = value; 2281 - if (strcmp (name, "x") == 0) 2282 - x = atof (value); 2283 - if (strcmp (name, "y") == 0) 2284 - y = atof (value); 2285 - if (strcmp (name, "width") == 0) 2286 - width = atof (value); 2287 - if (strcmp (name, "height") == 0) 2288 - height = atof (value); 2289 - } 2290 - } 2291 - attr = attr->next; 2292 - } 2293 - if (xlink_href == NULL) 2294 - return; 2295 - 2296 - use = gg_svg_insert_use (gg_svg_doc, xlink_href, x, y, width, height); 2297 - gg_svg_parse_style (NULL, NULL, use, node->properties); 2298 - gg_svg_parse_transform (NULL, NULL, use, NULL, node->properties); 2299 - gg_svg_parse_clip_path (NULL, NULL, use, node->properties); 2300 -} 2301 - 2302 -static void 2303 -gg_svg_parse_gradient_stop (struct gg_svg_gradient *gradient, xmlNodePtr node) 2304 -{ 2305 -/* parsing an SVG Node - Gradient - Stop */ 2306 - while (node) 2307 - { 2308 - if (node->type == XML_ELEMENT_NODE) 2309 - { 2310 - const char *name = (const char *) (node->name); 2311 - if (strcmp (name, "stop") == 0) 2312 - { 2313 - double offset = DBL_MAX; 2314 - double red = -1.0; 2315 - double green = -1.0; 2316 - double blue = -1.0; 2317 - double opacity = -1.0; 2318 - struct _xmlAttr *attr = node->properties; 2319 - while (attr) 2320 - { 2321 - if (attr->type == XML_ATTRIBUTE_NODE) 2322 - { 2323 - const char *value = NULL; 2324 - const char *name; 2325 - xmlNodePtr child = attr->children; 2326 - name = (const char *) (attr->name); 2327 - if (child) 2328 - value = (const char *) (child->content); 2329 - if (child && value) 2330 - { 2331 - if (strcmp (name, "offset") == 0) 2332 - { 2333 - int percent = 0; 2334 - int i; 2335 - for (i = 0; 2336 - i < (int) strlen (value); 2337 - i++) 2338 - { 2339 - if (value[i] == '%') 2340 - percent = 1; 2341 - } 2342 - offset = atof (value); 2343 - if (percent) 2344 - offset /= 100.0; 2345 - if (offset < 0.0) 2346 - offset = 0.0; 2347 - if (offset > 1.0) 2348 - offset = 1.0; 2349 - } 2350 - if (strcmp (name, "style") == 0) 2351 - gg_svg_parse_stop_style (value, 2352 - &red, 2353 - &green, 2354 - &blue, 2355 - &opacity); 2356 - if (strcmp (name, "stop-color") == 0) 2357 - { 2358 - opacity = 1.0; 2359 - gg_svg_parse_stop_color (value, 2360 - &red, 2361 - &green, 2362 - &blue); 2363 - } 2364 - } 2365 - } 2366 - attr = attr->next; 2367 - } 2368 - gg_svg_insert_gradient_stop (gradient, offset, red, green, 2369 - blue, opacity); 2370 - } 2371 - } 2372 - node = node->next; 2373 - } 2374 -} 2375 - 2376 -static void 2377 -gg_svg_parse_linear_gradient (struct gg_svg_document *gg_svg_doc, 2378 - xmlNodePtr node) 2379 -{ 2380 -/* creating and initializing an SVG LinearGradient struct */ 2381 - const char *xlink_href = NULL; 2382 - const char *id = NULL; 2383 - double x1 = DBL_MAX; 2384 - double y1 = DBL_MAX; 2385 - double x2 = DBL_MAX; 2386 - double y2 = DBL_MAX; 2387 - int units = GG_SVG_BOUNDING_BOX; 2388 - struct gg_svg_gradient *gradient; 2389 - struct _xmlAttr *attr = node->properties; 2390 - 2391 - while (attr) 2392 - { 2393 - if (attr->type == XML_ATTRIBUTE_NODE) 2394 - { 2395 - const char *value = NULL; 2396 - const char *name; 2397 - xmlNodePtr child = attr->children; 2398 - name = (const char *) (attr->name); 2399 - if (child) 2400 - value = (const char *) (child->content); 2401 - if (child && value) 2402 - { 2403 - if (strcmp (name, "href") == 0) 2404 - xlink_href = value; 2405 - if (strcmp (name, "id") == 0) 2406 - id = value; 2407 - if (strcmp (name, "x1") == 0) 2408 - x1 = atof (value); 2409 - if (strcmp (name, "y1") == 0) 2410 - y1 = atof (value); 2411 - if (strcmp (name, "x2") == 0) 2412 - x2 = atof (value); 2413 - if (strcmp (name, "y2") == 0) 2414 - y2 = atof (value); 2415 - if (strcmp (name, "gradientUnits") == 0) 2416 - { 2417 - if (strcmp (value, "userSpaceOnUse") == 0) 2418 - units = GG_SVG_USER_SPACE; 2419 - } 2420 - } 2421 - } 2422 - attr = attr->next; 2423 - } 2424 - if (x1 == DBL_MAX) 2425 - x1 = gg_svg_doc->viewbox_x; 2426 - if (y1 == DBL_MAX) 2427 - y1 = gg_svg_doc->viewbox_y; 2428 - if (x2 == DBL_MAX) 2429 - x2 = gg_svg_doc->viewbox_width; 2430 - if (y2 == DBL_MAX) 2431 - y2 = y1; 2432 - 2433 - gradient = 2434 - gg_svg_insert_linear_gradient (gg_svg_doc, id, xlink_href, x1, y1, x2, 2435 - y2, units); 2436 - gg_svg_parse_gradient_stop (gradient, node->children); 2437 - gg_svg_parse_transform (NULL, NULL, NULL, gradient, node->properties); 2438 -} 2439 - 2440 -static void 2441 -gg_svg_parse_radial_gradient (struct gg_svg_document *gg_svg_doc, 2442 - xmlNodePtr node) 2443 -{ 2444 -/* creating and initializing an SVG RadialGradient struct */ 2445 - const char *xlink_href = NULL; 2446 - const char *id = NULL; 2447 - double cx = DBL_MAX; 2448 - double cy = DBL_MAX; 2449 - double fx = DBL_MAX; 2450 - double fy = DBL_MAX; 2451 - double r = DBL_MAX; 2452 - int units = GG_SVG_BOUNDING_BOX; 2453 - struct gg_svg_gradient *gradient; 2454 - struct _xmlAttr *attr = node->properties; 2455 - 2456 - while (attr) 2457 - { 2458 - if (attr->type == XML_ATTRIBUTE_NODE) 2459 - { 2460 - const char *value = NULL; 2461 - const char *name; 2462 - xmlNodePtr child = attr->children; 2463 - name = (const char *) (attr->name); 2464 - if (child) 2465 - value = (const char *) (child->content); 2466 - if (child && value) 2467 - { 2468 - if (strcmp (name, "href") == 0) 2469 - xlink_href = value; 2470 - if (strcmp (name, "id") == 0) 2471 - id = value; 2472 - if (strcmp (name, "cx") == 0) 2473 - cx = atof (value); 2474 - if (strcmp (name, "cy") == 0) 2475 - cy = atof (value); 2476 - if (strcmp (name, "fx") == 0) 2477 - fx = atof (value); 2478 - if (strcmp (name, "fy") == 0) 2479 - fy = atof (value); 2480 - if (strcmp (name, "r") == 0) 2481 - r = atof (value); 2482 - if (strcmp (name, "gradientUnits") == 0) 2483 - { 2484 - if (strcmp (value, "userSpaceOnUse") == 0) 2485 - units = GG_SVG_USER_SPACE; 2486 - } 2487 - } 2488 - } 2489 - attr = attr->next; 2490 - } 2491 - if (cx == DBL_MAX) 2492 - cx = gg_svg_doc->viewbox_width / 2.0; 2493 - if (cy == DBL_MAX) 2494 - cy = gg_svg_doc->viewbox_height / 2.0; 2495 - if (r == DBL_MAX) 2496 - r = gg_svg_doc->viewbox_width / 2.0; 2497 - if (fx == DBL_MAX) 2498 - fx = cx; 2499 - if (fy == DBL_MAX) 2500 - fy = cy; 2501 - 2502 - gradient = 2503 - gg_svg_insert_radial_gradient (gg_svg_doc, id, xlink_href, cx, cy, fx, 2504 - fy, r, units); 2505 - gg_svg_parse_gradient_stop (gradient, node->children); 2506 - gg_svg_parse_transform (NULL, NULL, NULL, gradient, node->properties); 2507 -} 2508 - 2509 -static void 2510 -gg_svg_parse_node (struct gg_svg_document *gg_svg_doc, xmlNodePtr node) 2511 -{ 2512 -/* parsing an SVG Node */ 2513 - while (node) 2514 - { 2515 - int is_group = 0; 2516 - int is_defs = 0; 2517 - int is_flow_root = 0; 2518 - int is_clip_path = 0; 2519 - if (node->type == XML_ELEMENT_NODE) 2520 - { 2521 - const char *name = (const char *) (node->name); 2522 - if (strcmp (name, "defs") == 0) 2523 - { 2524 - gg_svg_doc->defs_count += 1; 2525 - is_defs = 1; 2526 - } 2527 - if (strcmp (name, "flowRoot") == 0) 2528 - { 2529 - gg_svg_doc->flow_root_count += 1; 2530 - is_flow_root = 1; 2531 - } 2532 - if (strcmp (name, "clipPath") == 0) 2533 - { 2534 - gg_svg_parse_clip (gg_svg_doc, node); 2535 - is_clip_path = 1; 2536 - } 2537 - if (strcmp (name, "g") == 0) 2538 - { 2539 - gg_svg_parse_group (gg_svg_doc, node); 2540 - is_group = 1; 2541 - } 2542 - if (strcmp (name, "rect") == 0) 2543 - gg_svg_parse_rect (gg_svg_doc, node); 2544 - if (strcmp (name, "circle") == 0) 2545 - gg_svg_parse_circle (gg_svg_doc, node); 2546 - if (strcmp (name, "ellipse") == 0) 2547 - gg_svg_parse_ellipse (gg_svg_doc, node); 2548 - if (strcmp (name, "line") == 0) 2549 - gg_svg_parse_line (gg_svg_doc, node); 2550 - if (strcmp (name, "polyline") == 0) 2551 - gg_svg_parse_polyline (gg_svg_doc, node); 2552 - if (strcmp (name, "polygon") == 0) 2553 - gg_svg_parse_polygon (gg_svg_doc, node); 2554 - if (strcmp (name, "path") == 0) 2555 - gg_svg_parse_path (gg_svg_doc, node); 2556 - if (strcmp (name, "use") == 0) 2557 - gg_svg_parse_use (gg_svg_doc, node); 2558 - if (strcmp (name, "linearGradient") == 0) 2559 - gg_svg_parse_linear_gradient (gg_svg_doc, node); 2560 - if (strcmp (name, "radialGradient") == 0) 2561 - gg_svg_parse_radial_gradient (gg_svg_doc, node); 2562 - } 2563 - gg_svg_parse_node (gg_svg_doc, node->children); 2564 - if (is_group) 2565 - gg_svg_close_group (gg_svg_doc); 2566 - if (is_defs) 2567 - gg_svg_doc->defs_count -= 1; 2568 - if (is_flow_root) 2569 - gg_svg_doc->flow_root_count -= 1; 2570 - if (is_clip_path) 2571 - gg_svg_close_clip (gg_svg_doc); 2572 - node = node->next; 2573 - } 2574 -} 2575 - 2576 -static void 2577 -gg_svg_parse_viewbox (struct gg_svg_document *gg_svg_doc, const char *str) 2578 -{ 2579 -/* parsing an SVG ViewBox */ 2580 - double value; 2581 - const char *p = str; 2582 - if (!gg_svg_consume_float (&p, &value)) 2583 - return; 2584 - gg_svg_doc->viewbox_x = value; 2585 - if (!gg_svg_consume_float (&p, &value)) 2586 - return; 2587 - gg_svg_doc->viewbox_y = value; 2588 - if (!gg_svg_consume_float (&p, &value)) 2589 - return; 2590 - gg_svg_doc->viewbox_width = value; 2591 - if (!gg_svg_consume_float (&p, &value)) 2592 - return; 2593 - gg_svg_doc->viewbox_height = value; 2594 -} 2595 - 2596 -static void 2597 -gg_svg_parse_header (struct gg_svg_document *gg_svg_doc, struct _xmlAttr *attr) 2598 -{ 2599 -/* parsing the SVG header definitions */ 2600 - while (attr) 2601 - { 2602 - if (attr->type == XML_ATTRIBUTE_NODE) 2603 - { 2604 - const char *value = NULL; 2605 - const char *name; 2606 - xmlNodePtr child = attr->children; 2607 - name = (const char *) (attr->name); 2608 - if (child) 2609 - value = (const char *) (child->content); 2610 - if (child && value) 2611 - { 2612 - int len; 2613 - double factor = 1.0; 2614 - if (strcmp (name, "width") == 0) 2615 - { 2616 - len = strlen (value); 2617 - if (len > 3) 2618 - { 2619 - if (strcmp (value + len - 2, "mm") == 0) 2620 - factor = 72.0 / 25.4; 2621 - else if (strcmp (value + len - 2, "cm") == 0) 2622 - factor = 72.0 / 2.54; 2623 - else if (strcmp (value + len - 2, "in") == 0) 2624 - factor = 72.0; 2625 - else if (strcmp (value + len - 2, "pc") == 0) 2626 - factor = 72.0 / 6.0; 2627 - } 2628 - gg_svg_doc->width = atof (value) * factor; 2629 - } 2630 - if (strcmp (name, "height") == 0) 2631 - { 2632 - len = strlen (value); 2633 - if (len > 3) 2634 - { 2635 - if (strcmp (value + len - 2, "mm") == 0) 2636 - factor = 72.0 / 25.4; 2637 - else if (strcmp (value + len - 2, "cm") == 0) 2638 - factor = 72.0 / 2.54; 2639 - else if (strcmp (value + len - 2, "in") == 0) 2640 - factor = 72.0; 2641 - else if (strcmp (value + len - 2, "pc") == 0) 2642 - factor = 72.0 / 6.0; 2643 - } 2644 - gg_svg_doc->height = atof (value) * factor; 2645 - } 2646 - if (strcmp (name, "viewBox") == 0) 2647 - gg_svg_parse_viewbox (gg_svg_doc, value); 2648 - } 2649 - } 2650 - attr = attr->next; 2651 - } 2652 -} 2653 - 2654 -GGRAPH_PRIVATE struct gg_svg_document * 2655 -gg_svg_parse_doc (const unsigned char *svg, int svg_len) 2656 -{ 2657 -/* attempting to parse the SVG Document */ 2658 - struct gg_svg_document *gg_svg_doc; 2659 - xmlNodePtr node; 2660 - xmlDocPtr xml_doc = 2661 - xmlReadMemory ((const char *) svg, svg_len, "noname.svg", NULL, 0); 2662 - if (xml_doc == NULL) 2663 - { 2664 - /* parsing error; not a well-formed XML */ 2665 - fprintf (stderr, "XML parsing error\n"); 2666 - return NULL; 2667 - } 2668 - gg_svg_doc = gg_svg_alloc_document (); 2669 - node = xmlDocGetRootElement (xml_doc); 2670 - gg_svg_parse_header (gg_svg_doc, node->properties); 2671 - gg_svg_parse_node (gg_svg_doc, node); 2672 - xmlFreeDoc (xml_doc); 2673 - return gg_svg_doc; 2674 -}
Deleted src/gaiagraphics_tiff.c.
1 -/* 2 -/ gaiagraphics_tiff.c 3 -/ 4 -/ TIFF auxiliary helpers 5 -/ 6 -/ version 1.0, 2010 July 20 7 -/ 8 -/ Author: Sandro Furieri a.furieri@lqt.it 9 -/ 10 -/ Copyright (C) 2010 Alessandro Furieri 11 -/ 12 -/ This program is free software: you can redistribute it and/or modify 13 -/ it under the terms of the GNU Lesser General Public License as published by 14 -/ the Free Software Foundation, either version 3 of the License, or 15 -/ (at your option) any later version. 16 -/ 17 -/ This program is distributed in the hope that it will be useful, 18 -/ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 -/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 -/ GNU Lesser General Public License for more details. 21 -/ 22 -/ You should have received a copy of the GNU Lesser General Public License 23 -/ along with this program. If not, see <http://www.gnu.org/licenses/>. 24 -/ 25 -*/ 26 - 27 -#include <stdio.h> 28 -#include <math.h> 29 -#include <float.h> 30 -#include <string.h> 31 -#include <stdlib.h> 32 - 33 -/* 34 -/ the following patch supporting GeoTiff headers 35 -/ was kindly contributed by Brad Hards: 2011-09-02 36 -*/ 37 -#ifdef HAVE_GEOTIFF_GEOTIFF_H 38 -#include <geotiff/geotiff.h> 39 -#include <geotiff/xtiffio.h> 40 -#include <geotiff/geo_tiffp.h> 41 -#include <geotiff/geo_keyp.h> 42 -#include <geotiff/geovalues.h> 43 -#include <geotiff/geo_normalize.h> 44 -#elif HAVE_LIBGEOTIFF_GEOTIFF_H 45 -#include <libgeotiff/geotiff.h> 46 -#include <libgeotiff/xtiffio.h> 47 -#include <libgeotiff/geo_tiffp.h> 48 -#include <libgeotiff/geo_keyp.h> 49 -#include <libgeotiff/geovalues.h> 50 -#include <libgeotiff/geo_normalize.h> 51 -#else 52 -#include <geotiff.h> 53 -#include <xtiffio.h> 54 -#include <geo_tiffp.h> 55 -#include <geo_keyp.h> 56 -#include <geovalues.h> 57 -#include <geo_normalize.h> 58 -#endif 59 - 60 -#include "gaiagraphics.h" 61 -#include "gaiagraphics_internals.h" 62 - 63 -#define TIFF_TYPE_MONOCHROME 1 64 -#define TIFF_TYPE_PALETTE 2 65 -#define TIFF_TYPE_GRAYSCALE 3 66 -#define TIFF_TYPE_RGB 4 67 -#define TIFF_TYPE_GRID 5 68 - 69 -struct tiff_codec_data 70 -{ 71 -/* a struct used by TIFF codec */ 72 - int is_geotiff; 73 - int is_writer; 74 - TIFF *tiff_handle; 75 - GTIF *geotiff_handle; 76 - void *tiff_buffer; 77 - int is_tiled; 78 - int tiff_type; 79 -}; 80 - 81 -struct memfile 82 -{ 83 -/* a struct emulating a file [memory mapped] */ 84 - unsigned char *buffer; 85 - int malloc_block; 86 - tsize_t size; 87 - tsize_t eof; 88 - toff_t current; 89 -}; 90 - 91 -static void 92 -memory_realloc (struct memfile *mem, tsize_t req_size) 93 -{ 94 -/* expanding the allocated memory */ 95 - unsigned char *new_buffer; 96 - tsize_t new_size = mem->size; 97 - while (new_size < req_size) 98 - new_size += mem->malloc_block; 99 - new_buffer = realloc (mem->buffer, new_size); 100 - if (!new_buffer) 101 - return; 102 - mem->buffer = new_buffer; 103 - mem->size = new_size; 104 -} 105 - 106 -static tsize_t 107 -memory_readproc (thandle_t clientdata, tdata_t data, tsize_t size) 108 -{ 109 -/* emulating the read() function */ 110 - struct memfile *mem = clientdata; 111 - tsize_t len; 112 - if (mem->current >= (toff_t) mem->eof) 113 - return 0; 114 - len = size; 115 - if ((mem->current + size) >= (toff_t) mem->eof) 116 - len = (tsize_t) (mem->eof - mem->current); 117 - memcpy (data, mem->buffer + mem->current, len); 118 - mem->current += len; 119 - return len; 120 -} 121 - 122 -static tsize_t 123 -memory_writeproc (thandle_t clientdata, tdata_t data, tsize_t size) 124 -{ 125 -/* emulating the write() function */ 126 - struct memfile *mem = clientdata; 127 - if ((mem->current + size) >= (toff_t) mem->size) 128 - memory_realloc (mem, mem->current + size); 129 - if ((mem->current + size) >= (toff_t) mem->size) 130 - return -1; 131 - memcpy (mem->buffer + mem->current, (unsigned char *) data, size); 132 - mem->current += size; 133 - if (mem->current > (toff_t) mem->eof) 134 - mem->eof = (tsize_t) (mem->current); 135 - return size; 136 -} 137 - 138 -static toff_t 139 -memory_seekproc (thandle_t clientdata, toff_t offset, int whence) 140 -{ 141 -/* emulating the lseek() function */ 142 - struct memfile *mem = clientdata; 143 - switch (whence) 144 - { 145 - case SEEK_CUR: 146 - if ((int) (mem->current + offset) < 0) 147 - return (toff_t) - 1; 148 - mem->current += offset; 149 - if ((toff_t) mem->eof < mem->current) 150 - mem->eof = (tsize_t) (mem->current); 151 - break; 152 - case SEEK_END: 153 - if ((int) (mem->eof + offset) < 0) 154 - return (toff_t) - 1; 155 - mem->current = mem->eof + offset; 156 - if ((toff_t) mem->eof < mem->current) 157 - mem->eof = (tsize_t) (mem->current); 158 - break; 159 - case SEEK_SET: 160 - default: 161 - if ((int) offset < 0) 162 - return (toff_t) - 1; 163 - mem->current = offset; 164 - if ((toff_t) mem->eof < mem->current) 165 - mem->eof = (tsize_t) (mem->current); 166 - break; 167 - }; 168 - return mem->current; 169 -} 170 - 171 -static int 172 -closeproc (thandle_t clientdata) 173 -{ 174 -/* emulating the close() function */ 175 - if (clientdata) 176 - return 0; /* does absolutely nothing - required in order to suppress warnings */ 177 - return 0; 178 -} 179 - 180 -static toff_t 181 -memory_sizeproc (thandle_t clientdata) 182 -{ 183 -/* returning the pseudo-file current size */ 184 - struct memfile *mem = clientdata; 185 - return mem->eof; 186 -} 187 - 188 -static int 189 -mapproc (thandle_t clientdata, tdata_t * data, toff_t * offset) 190 -{ 191 - if (clientdata || data || offset) 192 - return 0; /* does absolutely nothing - required in order to suppress warnings */ 193 - return 0; 194 -} 195 - 196 -static void 197 -unmapproc (thandle_t clientdata, tdata_t data, toff_t offset) 198 -{ 199 - if (clientdata || data || offset) 200 - return; /* does absolutely nothing - required in order to suppress warnings */ 201 - return; 202 -} 203 - 204 -GGRAPH_PRIVATE int 205 -gg_image_infos_from_mem_tiff (int size, const void *data, 206 - gGraphImageInfosPtr * infos_handle) 207 -{ 208 -/* image infos from TIFF (memory cached) */ 209 - gGraphImageInfosPtr infos; 210 - uint16 bits_per_sample; 211 - uint16 samples_per_pixel; 212 - uint16 photometric; 213 - uint16 compression; 214 - uint16 sample_format; 215 - uint16 planar_config; 216 - uint32 width = 0; 217 - uint32 height = 0; 218 - uint32 rows_strip = 0; 219 - struct memfile clientdata; 220 - int is_tiled; 221 - uint32 tile_width; 222 - uint32 tile_height; 223 - int type; 224 - int gg_sample_format; 225 - TIFF *in = (TIFF *) 0; 226 - int max_palette = 0; 227 - unsigned char red[256]; 228 - unsigned char green[256]; 229 - unsigned char blue[256]; 230 - int i; 231 - *infos_handle = NULL; 232 - 233 -/* suppressing TIFF warnings */ 234 - TIFFSetWarningHandler (NULL); 235 - 236 -/* reading from memory */ 237 - clientdata.buffer = (unsigned char *) data; 238 - clientdata.size = size; 239 - clientdata.eof = size; 240 - clientdata.current = 0; 241 - in = TIFFClientOpen ("tiff", "r", &clientdata, memory_readproc, 242 - memory_writeproc, memory_seekproc, closeproc, 243 - memory_sizeproc, mapproc, unmapproc); 244 - if (in == NULL) 245 - return GGRAPH_TIFF_CODEC_ERROR; 246 - is_tiled = TIFFIsTiled (in); 247 -/* retrieving the TIFF dimensions */ 248 - TIFFGetField (in, TIFFTAG_IMAGELENGTH, &height); 249 - TIFFGetField (in, TIFFTAG_IMAGEWIDTH, &width); 250 - if (is_tiled) 251 - { 252 - TIFFGetField (in, TIFFTAG_TILEWIDTH, &tile_width); 253 - TIFFGetField (in, TIFFTAG_TILELENGTH, &tile_height); 254 - } 255 - else 256 - TIFFGetField (in, TIFFTAG_ROWSPERSTRIP, &rows_strip); 257 - TIFFGetField (in, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); 258 - if (TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel) == 0) 259 - { 260 - /* attempting to recover badly formatted TIFFs */ 261 - samples_per_pixel = 1; 262 - } 263 - TIFFGetField (in, TIFFTAG_PHOTOMETRIC, &photometric); 264 - TIFFGetField (in, TIFFTAG_COMPRESSION, &compression); 265 - if (TIFFGetField (in, TIFFTAG_PLANARCONFIG, &planar_config) == 0) 266 - { 267 - /* attempting to recover badly formatted TIFFs */ 268 - planar_config = 1; 269 - } 270 - if (TIFFGetField (in, TIFFTAG_SAMPLEFORMAT, &sample_format) == 0) 271 - sample_format = SAMPLEFORMAT_UINT; 272 - if (planar_config == PLANARCONFIG_CONTIG) 273 - { 274 - if (sample_format == SAMPLEFORMAT_UINT) 275 - { 276 - if (bits_per_sample == 1 && samples_per_pixel == 1 277 - && photometric < 2) 278 - { 279 - type = GG_PIXEL_PALETTE; 280 - max_palette = 2; 281 - if (photometric == PHOTOMETRIC_MINISWHITE) 282 - { 283 - red[0] = 255; 284 - green[0] = 255; 285 - blue[0] = 255; 286 - red[1] = 0; 287 - green[1] = 0; 288 - blue[1] = 0; 289 - } 290 - else 291 - { 292 - red[0] = 0; 293 - green[0] = 0; 294 - blue[0] = 0; 295 - red[1] = 255; 296 - green[1] = 255; 297 - blue[1] = 255; 298 - } 299 - } 300 - else if (bits_per_sample == 8 && samples_per_pixel == 1 301 - && photometric == 3) 302 - { 303 - uint16 *plt_red; 304 - uint16 *plt_green; 305 - uint16 *plt_blue; 306 - type = GG_PIXEL_PALETTE; 307 - TIFFGetField (in, TIFFTAG_COLORMAP, &plt_red, &plt_green, 308 - &plt_blue); 309 - max_palette = 256; 310 - for (i = 0; i < max_palette; i++) 311 - { 312 - if (plt_red[i] < 256) 313 - red[i] = plt_red[i]; 314 - else 315 - red[i] = plt_red[i] / 256; 316 - if (plt_green[i] < 256) 317 - green[i] = plt_green[i]; 318 - else 319 - green[i] = plt_green[i] / 256; 320 - if (plt_blue[i] < 256) 321 - blue[i] = plt_blue[i]; 322 - else 323 - blue[i] = plt_blue[i] / 256; 324 - } 325 - } 326 - else if (bits_per_sample == 8 && samples_per_pixel == 1 327 - && photometric < 2) 328 - type = GG_PIXEL_GRAYSCALE; 329 - else if (bits_per_sample == 8 && samples_per_pixel == 3) 330 - type = GG_PIXEL_RGB; 331 - else 332 - type = GG_PIXEL_UNKNOWN; 333 - } 334 - else if (samples_per_pixel == 1) 335 - type = GG_PIXEL_GRID; 336 - else 337 - type = GG_PIXEL_UNKNOWN; 338 - } 339 - else 340 - type = GG_PIXEL_UNKNOWN; 341 - switch (sample_format) 342 - { 343 - case SAMPLEFORMAT_UINT: 344 - gg_sample_format = GGRAPH_SAMPLE_UINT; 345 - break; 346 - case SAMPLEFORMAT_INT: 347 - gg_sample_format = GGRAPH_SAMPLE_INT; 348 - break; 349 - case SAMPLEFORMAT_IEEEFP: 350 - gg_sample_format = GGRAPH_SAMPLE_FLOAT; 351 - break; 352 - default: 353 - gg_sample_format = GGRAPH_SAMPLE_UNKNOWN; 354 - break; 355 - }; 356 - infos = 357 - gg_image_infos_create (type, width, height, bits_per_sample, 358 - samples_per_pixel, gg_sample_format, NULL, NULL); 359 - if (!infos) 360 - return GGRAPH_INSUFFICIENT_MEMORY; 361 - if (is_tiled) 362 - { 363 - infos->tile_width = tile_width; 364 - infos->tile_height = tile_height; 365 - } 366 - else 367 - infos->rows_per_strip = rows_strip; 368 - switch (compression) 369 - { 370 - case COMPRESSION_NONE: 371 - infos->compression = GGRAPH_TIFF_COMPRESSION_NONE; 372 - break; 373 - case COMPRESSION_LZW: 374 - infos->compression = GGRAPH_TIFF_COMPRESSION_LZW; 375 - break; 376 - case COMPRESSION_DEFLATE: 377 - infos->compression = GGRAPH_TIFF_COMPRESSION_DEFLATE; 378 - break; 379 - case COMPRESSION_JPEG: 380 - infos->compression = GGRAPH_TIFF_COMPRESSION_JPEG; 381 - break; 382 - case COMPRESSION_CCITTFAX3: 383 - infos->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX3; 384 - break; 385 - case COMPRESSION_CCITTFAX4: 386 - infos->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX4; 387 - break; 388 - default: 389 - infos->compression = GGRAPH_TIFF_COMPRESSION_UNKNOWN; 390 - break; 391 - }; 392 - for (i = 0; i < max_palette; i++) 393 - { 394 - infos->palette_red[i] = red[i]; 395 - infos->palette_green[i] = green[i]; 396 - infos->palette_blue[i] = blue[i]; 397 - } 398 - infos->max_palette = max_palette; 399 - TIFFClose (in); 400 - *infos_handle = infos; 401 - return GGRAPH_OK; 402 -} 403 - 404 -GGRAPH_PRIVATE int 405 -gg_image_infos_from_tiff (const char *path, gGraphImageInfosPtr * infos_handle) 406 -{ 407 -/* image infos from TIFF */ 408 - gGraphImageInfosPtr infos; 409 - uint16 bits_per_sample; 410 - uint16 samples_per_pixel; 411 - uint16 photometric; 412 - uint16 compression; 413 - uint16 sample_format; 414 - uint16 planar_config; 415 - uint32 width = 0; 416 - uint32 height = 0; 417 - uint32 rows_strip = 0; 418 - int is_tiled; 419 - uint32 tile_width; 420 - uint32 tile_height; 421 - int type; 422 - int gg_sample_format; 423 - TIFF *in = (TIFF *) 0; 424 - int max_palette = 0; 425 - unsigned char red[256]; 426 - unsigned char green[256]; 427 - unsigned char blue[256]; 428 - int i; 429 - *infos_handle = NULL; 430 - 431 -/* suppressing TIFF warnings */ 432 - TIFFSetWarningHandler (NULL); 433 - 434 -/* reading from file */ 435 - in = TIFFOpen (path, "r"); 436 - if (in == NULL) 437 - return GGRAPH_TIFF_CODEC_ERROR; 438 - is_tiled = TIFFIsTiled (in); 439 -/* retrieving the TIFF dimensions */ 440 - TIFFGetField (in, TIFFTAG_IMAGELENGTH, &height); 441 - TIFFGetField (in, TIFFTAG_IMAGEWIDTH, &width); 442 - if (is_tiled) 443 - { 444 - TIFFGetField (in, TIFFTAG_TILEWIDTH, &tile_width); 445 - TIFFGetField (in, TIFFTAG_TILELENGTH, &tile_height); 446 - } 447 - else 448 - TIFFGetField (in, TIFFTAG_ROWSPERSTRIP, &rows_strip); 449 - TIFFGetField (in, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); 450 - if (TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel) == 0) 451 - { 452 - /* attempting to recover badly formatted TIFFs */ 453 - samples_per_pixel = 1; 454 - } 455 - TIFFGetField (in, TIFFTAG_PHOTOMETRIC, &photometric); 456 - TIFFGetField (in, TIFFTAG_COMPRESSION, &compression); 457 - if (TIFFGetField (in, TIFFTAG_PLANARCONFIG, &planar_config) == 0) 458 - { 459 - /* attempting to recover badly formatted TIFFs */ 460 - planar_config = 1; 461 - } 462 - if (TIFFGetField (in, TIFFTAG_SAMPLEFORMAT, &sample_format) == 0) 463 - sample_format = SAMPLEFORMAT_UINT; 464 - if (planar_config == PLANARCONFIG_CONTIG) 465 - { 466 - if (sample_format == SAMPLEFORMAT_UINT) 467 - { 468 - if (bits_per_sample == 1 && samples_per_pixel == 1 469 - && photometric < 2) 470 - { 471 - type = GG_PIXEL_PALETTE; 472 - max_palette = 2; 473 - if (photometric == PHOTOMETRIC_MINISWHITE) 474 - { 475 - red[0] = 255; 476 - green[0] = 255; 477 - blue[0] = 255; 478 - red[1] = 0; 479 - green[1] = 0; 480 - blue[1] = 0; 481 - } 482 - else 483 - { 484 - red[0] = 0; 485 - green[0] = 0; 486 - blue[0] = 0; 487 - red[1] = 255; 488 - green[1] = 255; 489 - blue[1] = 255; 490 - } 491 - } 492 - else if (bits_per_sample == 8 && samples_per_pixel == 1 493 - && photometric == 3) 494 - { 495 - uint16 *plt_red; 496 - uint16 *plt_green; 497 - uint16 *plt_blue; 498 - type = GG_PIXEL_PALETTE; 499 - TIFFGetField (in, TIFFTAG_COLORMAP, &plt_red, &plt_green, 500 - &plt_blue); 501 - max_palette = 256; 502 - for (i = 0; i < max_palette; i++) 503 - { 504 - if (plt_red[i] < 256) 505 - red[i] = plt_red[i]; 506 - else 507 - red[i] = plt_red[i] / 256; 508 - if (plt_green[i] < 256) 509 - green[i] = plt_green[i]; 510 - else 511 - green[i] = plt_green[i] / 256; 512 - if (plt_blue[i] < 256) 513 - blue[i] = plt_blue[i]; 514 - else 515 - blue[i] = plt_blue[i] / 256; 516 - } 517 - } 518 - else if (bits_per_sample == 8 && samples_per_pixel == 1 519 - && photometric < 2) 520 - type = GG_PIXEL_GRAYSCALE; 521 - else if (bits_per_sample == 8 && samples_per_pixel == 3) 522 - type = GG_PIXEL_RGB; 523 - else 524 - type = GG_PIXEL_UNKNOWN; 525 - } 526 - else if (samples_per_pixel == 1) 527 - type = GG_PIXEL_GRID; 528 - else 529 - type = GG_PIXEL_UNKNOWN; 530 - } 531 - else 532 - type = GG_PIXEL_UNKNOWN; 533 - switch (sample_format) 534 - { 535 - case SAMPLEFORMAT_UINT: 536 - gg_sample_format = GGRAPH_SAMPLE_UINT; 537 - break; 538 - case SAMPLEFORMAT_INT: 539 - gg_sample_format = GGRAPH_SAMPLE_INT; 540 - break; 541 - case SAMPLEFORMAT_IEEEFP: 542 - gg_sample_format = GGRAPH_SAMPLE_FLOAT; 543 - break; 544 - default: 545 - gg_sample_format = GGRAPH_SAMPLE_UNKNOWN; 546 - break; 547 - }; 548 - infos = 549 - gg_image_infos_create (type, width, height, bits_per_sample, 550 - samples_per_pixel, gg_sample_format, NULL, NULL); 551 - if (!infos) 552 - return GGRAPH_INSUFFICIENT_MEMORY; 553 - if (is_tiled) 554 - { 555 - infos->tile_width = tile_width; 556 - infos->tile_height = tile_height; 557 - } 558 - else 559 - infos->rows_per_strip = rows_strip; 560 - switch (compression) 561 - { 562 - case COMPRESSION_NONE: 563 - infos->compression = GGRAPH_TIFF_COMPRESSION_NONE; 564 - break; 565 - case COMPRESSION_LZW: 566 - infos->compression = GGRAPH_TIFF_COMPRESSION_LZW; 567 - break; 568 - case COMPRESSION_DEFLATE: 569 - infos->compression = GGRAPH_TIFF_COMPRESSION_DEFLATE; 570 - break; 571 - case COMPRESSION_JPEG: 572 - infos->compression = GGRAPH_TIFF_COMPRESSION_JPEG; 573 - break; 574 - case COMPRESSION_CCITTFAX3: 575 - infos->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX3; 576 - break; 577 - case COMPRESSION_CCITTFAX4: 578 - infos->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX4; 579 - break; 580 - default: 581 - infos->compression = GGRAPH_TIFF_COMPRESSION_UNKNOWN; 582 - break; 583 - }; 584 - for (i = 0; i < max_palette; i++) 585 - { 586 - infos->palette_red[i] = red[i]; 587 - infos->palette_green[i] = green[i]; 588 - infos->palette_blue[i] = blue[i]; 589 - } 590 - infos->max_palette = max_palette; 591 - TIFFClose (in); 592 - *infos_handle = infos; 593 - return GGRAPH_OK; 594 -} 595 - 596 -GGRAPH_PRIVATE int 597 -gg_image_infos_from_geo_tiff (const char *path, 598 - gGraphImageInfosPtr * infos_handle) 599 -{ 600 -/* image infos from GeoTIFF */ 601 - gGraphImageInfosPtr infos; 602 - uint16 bits_per_sample; 603 - uint16 samples_per_pixel; 604 - uint16 photometric; 605 - uint16 compression; 606 - uint16 sample_format; 607 - uint16 planar_config; 608 - uint32 width = 0; 609 - uint32 height = 0; 610 - uint32 rows_strip = 0; 611 - int is_tiled; 612 - uint32 tile_width; 613 - uint32 tile_height; 614 - int type; 615 - int gg_sample_format; 616 - int epsg = -1; 617 - double cx; 618 - double cy; 619 - double upper_left_x; 620 - double upper_left_y; 621 - double upper_right_x; 622 - double lower_left_y; 623 - double pixel_x; 624 - double pixel_y; 625 - char srs_name[1024]; 626 - char proj4text[1024]; 627 - TIFF *in = (TIFF *) 0; 628 - GTIF *gtif = (GTIF *) 0; 629 - GTIFDefn definition; 630 - int max_palette = 0; 631 - unsigned char red[256]; 632 - unsigned char green[256]; 633 - unsigned char blue[256]; 634 - int i; 635 - *infos_handle = NULL; 636 - 637 -/* suppressing TIFF warnings */ 638 - TIFFSetWarningHandler (NULL); 639 - 640 -/* reading from file */ 641 - in = XTIFFOpen (path, "r"); 642 - if (in == NULL) 643 - return GGRAPH_GEOTIFF_CODEC_ERROR; 644 - gtif = GTIFNew (in); 645 - if (gtif == NULL) 646 - goto error; 647 - 648 - if (!GTIFGetDefn (gtif, &definition)) 649 - goto error; 650 -/* retrieving the EPSG code */ 651 - if (definition.PCS == 32767) 652 - { 653 - if (definition.GCS != 32767) 654 - epsg = definition.GCS; 655 - } 656 - else 657 - epsg = definition.PCS; 658 - *srs_name = '\0'; 659 - if (definition.PCS == 32767) 660 - { 661 - /* Get the GCS name if possible */ 662 - char *pszName = NULL; 663 - GTIFGetGCSInfo (definition.GCS, &pszName, NULL, NULL, NULL); 664 - if (pszName != NULL) 665 - strcpy (srs_name, pszName); 666 - CPLFree (pszName); 667 - } 668 - else 669 - { 670 - /* Get the PCS name if possible */ 671 - char *pszPCSName = NULL; 672 - GTIFGetPCSInfo (definition.PCS, &pszPCSName, NULL, NULL, NULL); 673 - if (pszPCSName != NULL) 674 - strcpy (srs_name, pszPCSName); 675 - CPLFree (pszPCSName); 676 - } 677 -/* retrieving the PROJ.4 params */ 678 - strcpy (proj4text, GTIFGetProj4Defn (&definition)); 679 - 680 - is_tiled = TIFFIsTiled (in); 681 -/* retrieving the TIFF dimensions */ 682 - TIFFGetField (in, TIFFTAG_IMAGELENGTH, &height); 683 - TIFFGetField (in, TIFFTAG_IMAGEWIDTH, &width); 684 - if (is_tiled) 685 - { 686 - TIFFGetField (in, TIFFTAG_TILEWIDTH, &tile_width); 687 - TIFFGetField (in, TIFFTAG_TILELENGTH, &tile_height); 688 - } 689 - else 690 - TIFFGetField (in, TIFFTAG_ROWSPERSTRIP, &rows_strip); 691 - TIFFGetField (in, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); 692 - if (TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel) == 0) 693 - { 694 - /* attempting to recover badly formatted TIFFs */ 695 - samples_per_pixel = 1; 696 - } 697 - TIFFGetField (in, TIFFTAG_PHOTOMETRIC, &photometric); 698 - TIFFGetField (in, TIFFTAG_COMPRESSION, &compression); 699 - if (TIFFGetField (in, TIFFTAG_PLANARCONFIG, &planar_config) == 0) 700 - { 701 - /* attempting to recover badly formatted TIFFs */ 702 - planar_config = PLANARCONFIG_CONTIG; 703 - } 704 - if (TIFFGetField (in, TIFFTAG_SAMPLEFORMAT, &sample_format) == 0) 705 - sample_format = SAMPLEFORMAT_UINT; 706 - if (planar_config == PLANARCONFIG_CONTIG) 707 - { 708 - if (sample_format == SAMPLEFORMAT_UINT) 709 - { 710 - if (bits_per_sample == 1 && samples_per_pixel == 1 711 - && photometric < 2) 712 - { 713 - type = GG_PIXEL_PALETTE; 714 - max_palette = 2; 715 - if (photometric == PHOTOMETRIC_MINISWHITE) 716 - { 717 - red[0] = 255; 718 - green[0] = 255; 719 - blue[0] = 255; 720 - red[1] = 0; 721 - green[1] = 0; 722 - blue[1] = 0; 723 - } 724 - else 725 - { 726 - red[0] = 0; 727 - green[0] = 0; 728 - blue[0] = 0; 729 - red[1] = 255; 730 - green[1] = 255; 731 - blue[1] = 255; 732 - } 733 - } 734 - else if (bits_per_sample == 8 && samples_per_pixel == 1 735 - && photometric == 3) 736 - { 737 - uint16 *plt_red; 738 - uint16 *plt_green; 739 - uint16 *plt_blue; 740 - type = GG_PIXEL_PALETTE; 741 - TIFFGetField (in, TIFFTAG_COLORMAP, &plt_red, &plt_green, 742 - &plt_blue); 743 - max_palette = 256; 744 - for (i = 0; i < max_palette; i++) 745 - { 746 - if (plt_red[i] < 256) 747 - red[i] = plt_red[i]; 748 - else 749 - red[i] = plt_red[i] / 256; 750 - if (plt_green[i] < 256) 751 - green[i] = plt_green[i]; 752 - else 753 - green[i] = plt_green[i] / 256; 754 - if (plt_blue[i] < 256) 755 - blue[i] = plt_blue[i]; 756 - else 757 - blue[i] = plt_blue[i] / 256; 758 - } 759 - } 760 - else if (bits_per_sample == 8 && samples_per_pixel == 1 761 - && photometric < 2) 762 - type = GG_PIXEL_GRAYSCALE; 763 - else if (bits_per_sample == 8 && samples_per_pixel == 3) 764 - type = GG_PIXEL_RGB; 765 - else 766 - type = GG_PIXEL_UNKNOWN; 767 - } 768 - else if (samples_per_pixel == 1) 769 - type = GG_PIXEL_GRID; 770 - else 771 - type = GG_PIXEL_UNKNOWN; 772 - } 773 - else 774 - type = GG_PIXEL_UNKNOWN; 775 - switch (sample_format) 776 - { 777 - case SAMPLEFORMAT_UINT: 778 - gg_sample_format = GGRAPH_SAMPLE_UINT; 779 - break; 780 - case SAMPLEFORMAT_INT: 781 - gg_sample_format = GGRAPH_SAMPLE_INT; 782 - break; 783 - case SAMPLEFORMAT_IEEEFP: 784 - gg_sample_format = GGRAPH_SAMPLE_FLOAT; 785 - break; 786 - default: 787 - gg_sample_format = GGRAPH_SAMPLE_UNKNOWN; 788 - break; 789 - }; 790 - 791 -/* computing the corners coords */ 792 - cx = 0.0; 793 - cy = 0.0; 794 - GTIFImageToPCS (gtif, &cx, &cy); 795 - upper_left_x = cx; 796 - upper_left_y = cy; 797 - cx = 0.0; 798 - cy = height; 799 - GTIFImageToPCS (gtif, &cx, &cy); 800 - lower_left_y = cy; 801 - cx = width; 802 - cy = 0.0; 803 - GTIFImageToPCS (gtif, &cx, &cy); 804 - upper_right_x = cx; 805 - cx = width; 806 - cy = height; 807 - GTIFImageToPCS (gtif, &cx, &cy); 808 -/* computing the pixel size */ 809 - pixel_x = (upper_right_x - upper_left_x) / (double) width; 810 - pixel_y = (upper_left_y - lower_left_y) / (double) height; 811 - 812 - infos = 813 - gg_image_infos_create (type, width, height, bits_per_sample, 814 - samples_per_pixel, gg_sample_format, srs_name, 815 - proj4text); 816 - if (!infos) 817 - return GGRAPH_INSUFFICIENT_MEMORY; 818 - if (is_tiled) 819 - { 820 - infos->tile_width = tile_width; 821 - infos->tile_height = tile_height; 822 - } 823 - else 824 - infos->rows_per_strip = rows_strip; 825 - switch (compression) 826 - { 827 - case COMPRESSION_NONE: 828 - infos->compression = GGRAPH_TIFF_COMPRESSION_NONE; 829 - break; 830 - case COMPRESSION_LZW: 831 - infos->compression = GGRAPH_TIFF_COMPRESSION_LZW; 832 - break; 833 - case COMPRESSION_DEFLATE: 834 - infos->compression = GGRAPH_TIFF_COMPRESSION_DEFLATE; 835 - break; 836 - case COMPRESSION_JPEG: 837 - infos->compression = GGRAPH_TIFF_COMPRESSION_JPEG; 838 - break; 839 - case COMPRESSION_CCITTFAX3: 840 - infos->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX3; 841 - break; 842 - case COMPRESSION_CCITTFAX4: 843 - infos->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX4; 844 - break; 845 - default: 846 - infos->compression = GGRAPH_TIFF_COMPRESSION_UNKNOWN; 847 - break; 848 - }; 849 - for (i = 0; i < max_palette; i++) 850 - { 851 - infos->palette_red[i] = red[i]; 852 - infos->palette_green[i] = green[i]; 853 - infos->palette_blue[i] = blue[i]; 854 - } 855 - infos->max_palette = max_palette; 856 - infos->is_georeferenced = 1; 857 - infos->srid = epsg; 858 - infos->upper_left_x = upper_left_x; 859 - infos->upper_left_y = upper_left_y; 860 - infos->pixel_x_size = pixel_x; 861 - infos->pixel_y_size = pixel_y; 862 - TIFFClose (in); 863 - GTIFFree (gtif); 864 - *infos_handle = infos; 865 - return GGRAPH_OK; 866 - 867 - error: 868 - XTIFFClose (in); 869 - if (gtif) 870 - GTIFFree (gtif); 871 - return GGRAPH_GEOTIFF_CODEC_ERROR; 872 -} 873 - 874 -static int 875 -common_read_from_tiff_grid (TIFF * in, gGraphImagePtr img, uint32 width, 876 - uint32 height, int is_tiled, int gg_sample_format, 877 - uint16 bits_per_sample, uint32 tile_width, 878 - uint32 tile_height, uint32 rows_strip) 879 -{ 880 -/* common utility: decoding a TIFF raster [GRID] */ 881 - unsigned char *raster = NULL; 882 - int x; 883 - int y; 884 - int i; 885 - int img_y; 886 - int strip_no; 887 - int effective_strip; 888 - int tile_x; 889 - int tile_y; 890 - unsigned char *p_in; 891 - unsigned char *p_out; 892 - int ret = GGRAPH_TIFF_CODEC_ERROR; 893 - 894 - if (is_tiled) 895 - { 896 - if (gg_sample_format == GGRAPH_SAMPLE_FLOAT) 897 - { 898 - if (bits_per_sample == 32) 899 - { 900 - /* float */ 901 - raster = malloc (4 * tile_width * tile_height); 902 - } 903 - else 904 - { 905 - /* double */ 906 - raster = malloc (8 * tile_width * tile_height); 907 - } 908 - } 909 - else 910 - { 911 - if (bits_per_sample == 8) 912 - { 913 - /* 8bit Int */ 914 - raster = malloc (tile_width * tile_height); 915 - } 916 - else if (bits_per_sample == 16) 917 - { 918 - /* 16bit Int */ 919 - raster = malloc (2 * tile_width * tile_height); 920 - } 921 - else 922 - { 923 - /* 32bit Int */ 924 - raster = malloc (4 * tile_width * tile_height); 925 - } 926 - } 927 - } 928 - else 929 - { 930 - if (gg_sample_format == GGRAPH_SAMPLE_FLOAT) 931 - { 932 - if (bits_per_sample == 32) 933 - { 934 - /* float */ 935 - raster = malloc (4 * width * rows_strip); 936 - } 937 - else 938 - { 939 - /* double */ 940 - raster = malloc (8 * width * rows_strip); 941 - } 942 - } 943 - else 944 - { 945 - if (bits_per_sample == 8) 946 - { 947 - /* 8bit Int */ 948 - raster = malloc (width * rows_strip); 949 - } 950 - else if (bits_per_sample == 16) 951 - { 952 - /* 16bit Int */ 953 - raster = malloc (2 * width * rows_strip); 954 - } 955 - else 956 - { 957 - /* 32bit Int */ 958 - raster = malloc (4 * width * rows_strip); 959 - } 960 - } 961 - } 962 - 963 - ret = GGRAPH_TIFF_CODEC_ERROR; 964 - if (is_tiled) 965 - { 966 - for (tile_y = 0; tile_y < (int) height; tile_y += tile_height) 967 - { 968 - /* scanning tiles by row */ 969 - for (tile_x = 0; tile_x < (int) width; tile_x += tile_width) 970 - { 971 - /* reading a TIFF tile */ 972 - if (!TIFFReadTile (in, raster, tile_x, tile_y, 0, 0)) 973 - goto error; 974 - for (y = 0; y < (int) tile_height; y++) 975 - { 976 - img_y = tile_y + y; 977 - if (img_y >= (int) height) 978 - continue; 979 - p_in = raster + (tile_width * y * img->pixel_size); 980 - p_out = 981 - img->pixels + (img_y * img->scanline_width) + 982 - (tile_x * img->pixel_size); 983 - for (x = 0; x < (int) tile_width; x++) 984 - { 985 - if (tile_x + x >= (int) width) 986 - break; 987 - for (i = 0; i < img->pixel_size; i++) 988 - *p_out++ = *p_in++; 989 - } 990 - } 991 - } 992 - } 993 - } 994 - else 995 - { 996 - for (strip_no = 0; strip_no < (int) height; strip_no += rows_strip) 997 - { 998 - /* reading a TIFF strip */ 999 - if (!TIFFReadScanline (in, raster, strip_no, 0)) 1000 - goto error; 1001 - effective_strip = rows_strip; 1002 - if ((strip_no + rows_strip) > height) 1003 - effective_strip = height - strip_no; 1004 - 1005 - for (y = 0; y < effective_strip; y++) 1006 - { 1007 - img_y = strip_no + y; 1008 - p_in = raster; 1009 - p_out = img->pixels + (img_y * img->scanline_width); 1010 - for (x = 0; x < (int) width; x++) 1011 - { 1012 - for (i = 0; i < img->pixel_size; i++) 1013 - *p_out++ = *p_in++; 1014 - } 1015 - } 1016 - } 1017 - } 1018 - free (raster); 1019 - return GGRAPH_OK; 1020 - 1021 - error: 1022 - if (raster) 1023 - free (raster); 1024 - return ret; 1025 -} 1026 - 1027 -static int 1028 -common_read_from_tiff (TIFF * in, gGraphImagePtr img, uint32 width, 1029 - uint32 height, int is_tiled, int type, 1030 - int gg_sample_format, uint16 bits_per_sample, 1031 - uint32 tile_width, uint32 tile_height, uint32 rows_strip) 1032 -{ 1033 -/* common utility: decoding a TIFF raster */ 1034 - uint32 *raster = NULL; 1035 - uint32 *scanline; 1036 - int x; 1037 - int y; 1038 - int img_y; 1039 - int strip_no; 1040 - int effective_strip; 1041 - uint32 pixel; 1042 - int tile_x; 1043 - int tile_y; 1044 - unsigned char red; 1045 - unsigned char green; 1046 - unsigned char blue; 1047 - unsigned char index; 1048 - unsigned char *p_out; 1049 - int ret = GGRAPH_TIFF_CODEC_ERROR; 1050 - 1051 - if (type == GG_PIXEL_GRID) 1052 - return common_read_from_tiff_grid (in, img, width, height, is_tiled, 1053 - gg_sample_format, bits_per_sample, 1054 - tile_width, tile_height, rows_strip); 1055 - 1056 -/* allocating read buffer [plain ordinary image] */ 1057 - if (is_tiled) 1058 - raster = malloc (sizeof (uint32) * tile_width * tile_height); 1059 - else 1060 - raster = malloc (sizeof (uint32) * width * rows_strip); 1061 - if (!raster) 1062 - { 1063 - gg_image_destroy (img); 1064 - ret = GGRAPH_INSUFFICIENT_MEMORY; 1065 - goto error; 1066 - } 1067 - 1068 - ret = GGRAPH_TIFF_CODEC_ERROR; 1069 - if (is_tiled) 1070 - { 1071 - for (tile_y = 0; tile_y < (int) height; tile_y += tile_height) 1072 - { 1073 - /* scanning tiles by row */ 1074 - for (tile_x = 0; tile_x < (int) width; tile_x += tile_width) 1075 - { 1076 - /* reading a TIFF tile */ 1077 - if (!TIFFReadRGBATile (in, tile_x, tile_y, raster)) 1078 - goto error; 1079 - for (y = 0; y < (int) tile_height; y++) 1080 - { 1081 - img_y = tile_y + (tile_height - y) - 1; 1082 - if (img_y >= (int) height) 1083 - continue; 1084 - scanline = raster + (tile_width * y); 1085 - for (x = 0; x < (int) tile_width; x++) 1086 - { 1087 - if (tile_x + x >= (int) width) 1088 - break; 1089 - p_out = 1090 - img->pixels + 1091 - (img_y * img->scanline_width) + 1092 - ((tile_x + x) * img->pixel_size); 1093 - pixel = scanline[x]; 1094 - red = TIFFGetR (pixel); 1095 - green = TIFFGetG (pixel); 1096 - blue = TIFFGetB (pixel); 1097 - if (img->pixel_format == GG_PIXEL_PALETTE) 1098 - { 1099 - /* PALETTE image */ 1100 - index = 1101 - gg_match_palette (img, red, green, 1102 - blue); 1103 - *p_out++ = index; 1104 - } 1105 - else if (img->pixel_format == 1106 - GG_PIXEL_GRAYSCALE) 1107 - { 1108 - /* GRAYSCALE image */ 1109 - *p_out++ = red; 1110 - } 1111 - else 1112 - { 1113 - /* should be an RGB image */ 1114 - *p_out++ = red; 1115 - *p_out++ = green; 1116 - *p_out++ = blue; 1117 - } 1118 - } 1119 - } 1120 - } 1121 - } 1122 - } 1123 - else 1124 - { 1125 - for (strip_no = 0; strip_no < (int) height; strip_no += rows_strip) 1126 - { 1127 - /* reading a TIFF strip */ 1128 - if (!TIFFReadRGBAStrip (in, strip_no, raster)) 1129 - goto error; 1130 - effective_strip = rows_strip; 1131 - if ((strip_no + rows_strip) > height) 1132 - effective_strip = height - strip_no; 1133 - 1134 - for (y = 0; y < effective_strip; y++) 1135 - { 1136 - img_y = strip_no + ((effective_strip - y) - 1); 1137 - scanline = raster + (width * y); 1138 - p_out = img->pixels + (img_y * img->scanline_width); 1139 - for (x = 0; x < (int) width; x++) 1140 - { 1141 - pixel = scanline[x]; 1142 - red = TIFFGetR (pixel); 1143 - green = TIFFGetG (pixel); 1144 - blue = TIFFGetB (pixel); 1145 - if (img->pixel_format == GG_PIXEL_PALETTE) 1146 - { 1147 - /* PALETTE image */ 1148 - index = 1149 - gg_match_palette (img, red, green, blue); 1150 - *p_out++ = index; 1151 - } 1152 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 1153 - { 1154 - /* GRAYSCALE image */ 1155 - *p_out++ = red; 1156 - } 1157 - else 1158 - { 1159 - /* should be an RGB image */ 1160 - *p_out++ = red; 1161 - *p_out++ = green; 1162 - *p_out++ = blue; 1163 - } 1164 - } 1165 - } 1166 - } 1167 - } 1168 - free (raster); 1169 - return GGRAPH_OK; 1170 - 1171 - error: 1172 - if (raster) 1173 - free (raster); 1174 - return ret; 1175 -} 1176 - 1177 -GGRAPH_PRIVATE int 1178 -gg_image_from_mem_tiff (int size, const void *data, 1179 - gGraphImagePtr * image_handle) 1180 -{ 1181 -/* decoding a TIFF (memory cached) */ 1182 - gGraphImagePtr img = NULL; 1183 - uint16 bits_per_sample; 1184 - uint16 samples_per_pixel; 1185 - uint16 photometric; 1186 - uint16 compression; 1187 - uint16 planar_config; 1188 - uint16 sample_format; 1189 - uint32 width = 0; 1190 - uint32 height = 0; 1191 - uint32 rows_strip = 0; 1192 - struct memfile clientdata; 1193 - int is_tiled; 1194 - uint32 tile_width; 1195 - uint32 tile_height; 1196 - int type; 1197 - int gg_sample_format; 1198 - int ret = GGRAPH_TIFF_CODEC_ERROR; 1199 - TIFF *in = (TIFF *) 0; 1200 - *image_handle = NULL; 1201 - 1202 -/* suppressing TIFF warnings */ 1203 - TIFFSetWarningHandler (NULL); 1204 - 1205 -/* reading from memory */ 1206 - clientdata.buffer = (unsigned char *) data; 1207 - clientdata.size = size; 1208 - clientdata.eof = size; 1209 - clientdata.current = 0; 1210 - in = TIFFClientOpen ("tiff", "r", &clientdata, memory_readproc, 1211 - memory_writeproc, memory_seekproc, closeproc, 1212 - memory_sizeproc, mapproc, unmapproc); 1213 - if (in == NULL) 1214 - return GGRAPH_TIFF_CODEC_ERROR; 1215 - is_tiled = TIFFIsTiled (in); 1216 -/* retrieving the TIFF dimensions */ 1217 - TIFFGetField (in, TIFFTAG_IMAGELENGTH, &height); 1218 - TIFFGetField (in, TIFFTAG_IMAGEWIDTH, &width); 1219 - if (is_tiled) 1220 - { 1221 - TIFFGetField (in, TIFFTAG_TILEWIDTH, &tile_width); 1222 - TIFFGetField (in, TIFFTAG_TILELENGTH, &tile_height); 1223 - } 1224 - else 1225 - TIFFGetField (in, TIFFTAG_ROWSPERSTRIP, &rows_strip); 1226 - TIFFGetField (in, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); 1227 - if (TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel) == 0) 1228 - { 1229 - /* attempting to recover badly formatted TIFFs */ 1230 - samples_per_pixel = 1; 1231 - } 1232 - TIFFGetField (in, TIFFTAG_PHOTOMETRIC, &photometric); 1233 - TIFFGetField (in, TIFFTAG_COMPRESSION, &compression); 1234 - if (TIFFGetField (in, TIFFTAG_PLANARCONFIG, &planar_config) == 0) 1235 - { 1236 - /* attempting to recover badly formatted TIFFs */ 1237 - planar_config = PLANARCONFIG_CONTIG; 1238 - } 1239 - if (TIFFGetField (in, TIFFTAG_SAMPLEFORMAT, &sample_format) == 0) 1240 - sample_format = SAMPLEFORMAT_UINT; 1241 - if (planar_config == PLANARCONFIG_CONTIG) 1242 - { 1243 - if (sample_format == SAMPLEFORMAT_UINT) 1244 - { 1245 - if (bits_per_sample == 1 && samples_per_pixel == 1) 1246 - type = GG_PIXEL_PALETTE; 1247 - else if (bits_per_sample == 8 && samples_per_pixel == 1 1248 - && photometric == 3) 1249 - type = GG_PIXEL_PALETTE; 1250 - else if (bits_per_sample == 8 && samples_per_pixel == 1 1251 - && photometric < 2) 1252 - type = GG_PIXEL_GRAYSCALE; 1253 - else if (bits_per_sample == 8 && samples_per_pixel == 3) 1254 - type = GG_PIXEL_RGB; 1255 - else 1256 - type = GG_PIXEL_UNKNOWN; 1257 - } 1258 - else if (samples_per_pixel == 1) 1259 - type = GG_PIXEL_GRID; 1260 - else 1261 - type = GG_PIXEL_UNKNOWN; 1262 - } 1263 - else 1264 - type = GG_PIXEL_UNKNOWN; 1265 - switch (sample_format) 1266 - { 1267 - case SAMPLEFORMAT_UINT: 1268 - gg_sample_format = GGRAPH_SAMPLE_UINT; 1269 - break; 1270 - case SAMPLEFORMAT_INT: 1271 - gg_sample_format = GGRAPH_SAMPLE_INT; 1272 - break; 1273 - case SAMPLEFORMAT_IEEEFP: 1274 - gg_sample_format = GGRAPH_SAMPLE_FLOAT; 1275 - break; 1276 - default: 1277 - gg_sample_format = GGRAPH_SAMPLE_UNKNOWN; 1278 - break; 1279 - }; 1280 - if (type == GG_PIXEL_UNKNOWN) 1281 - { 1282 - ret = GGRAPH_UNSUPPORTED_TIFF_LAYOUT; 1283 - goto error; 1284 - } 1285 - 1286 - img = 1287 - gg_image_create (type, width, height, bits_per_sample, 1288 - samples_per_pixel, gg_sample_format, NULL, NULL); 1289 - if (!img) 1290 - { 1291 - ret = GGRAPH_INSUFFICIENT_MEMORY; 1292 - goto error; 1293 - } 1294 - if (is_tiled) 1295 - { 1296 - img->tile_width = tile_width; 1297 - img->tile_height = tile_height; 1298 - } 1299 - else 1300 - img->rows_per_strip = rows_strip; 1301 - switch (compression) 1302 - { 1303 - case COMPRESSION_NONE: 1304 - img->compression = GGRAPH_TIFF_COMPRESSION_NONE; 1305 - break; 1306 - case COMPRESSION_LZW: 1307 - img->compression = GGRAPH_TIFF_COMPRESSION_LZW; 1308 - break; 1309 - case COMPRESSION_DEFLATE: 1310 - img->compression = GGRAPH_TIFF_COMPRESSION_DEFLATE; 1311 - break; 1312 - case COMPRESSION_JPEG: 1313 - img->compression = GGRAPH_TIFF_COMPRESSION_JPEG; 1314 - break; 1315 - case COMPRESSION_CCITTFAX3: 1316 - img->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX3; 1317 - break; 1318 - case COMPRESSION_CCITTFAX4: 1319 - img->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX4; 1320 - break; 1321 - default: 1322 - img->compression = GGRAPH_TIFF_COMPRESSION_UNKNOWN; 1323 - break; 1324 - }; 1325 - 1326 - ret = 1327 - common_read_from_tiff (in, img, width, height, is_tiled, type, 1328 - gg_sample_format, bits_per_sample, tile_width, 1329 - tile_height, rows_strip); 1330 - if (ret != GGRAPH_OK) 1331 - goto error; 1332 - 1333 - TIFFClose (in); 1334 - *image_handle = img; 1335 - return GGRAPH_OK; 1336 - 1337 - error: 1338 - TIFFClose (in); 1339 - if (img) 1340 - gGraphDestroyImage (img); 1341 - return ret; 1342 -} 1343 - 1344 -GGRAPH_PRIVATE int 1345 -gg_image_strip_prepare_from_tiff (const char *path, 1346 - gGraphStripImagePtr * image_handle) 1347 -{ 1348 -/* preparing to decode a TIFF [by meta-strips] */ 1349 - gGraphStripImagePtr img = NULL; 1350 - uint16 bits_per_sample; 1351 - uint16 samples_per_pixel; 1352 - uint16 photometric; 1353 - uint16 compression; 1354 - uint16 planar_config; 1355 - uint16 sample_format; 1356 - uint32 width = 0; 1357 - uint32 height = 0; 1358 - uint32 rows_strip = 0; 1359 - int is_tiled; 1360 - uint32 tile_width; 1361 - uint32 tile_height; 1362 - int type; 1363 - int gg_sample_format; 1364 - struct tiff_codec_data *tiff_codec = NULL; 1365 - tsize_t buf_size; 1366 - void *tiff_buffer = NULL; 1367 - int ret = GGRAPH_TIFF_CODEC_ERROR; 1368 - TIFF *in = (TIFF *) 0; 1369 - *image_handle = NULL; 1370 - 1371 -/* suppressing TIFF warnings */ 1372 - TIFFSetWarningHandler (NULL); 1373 - 1374 -/* reading from file */ 1375 - in = TIFFOpen (path, "r"); 1376 - if (in == NULL) 1377 - return GGRAPH_TIFF_CODEC_ERROR; 1378 - is_tiled = TIFFIsTiled (in); 1379 -/* retrieving the TIFF dimensions */ 1380 - TIFFGetField (in, TIFFTAG_IMAGELENGTH, &height); 1381 - TIFFGetField (in, TIFFTAG_IMAGEWIDTH, &width); 1382 - if (is_tiled) 1383 - { 1384 - TIFFGetField (in, TIFFTAG_TILEWIDTH, &tile_width); 1385 - TIFFGetField (in, TIFFTAG_TILELENGTH, &tile_height); 1386 - } 1387 - else 1388 - TIFFGetField (in, TIFFTAG_ROWSPERSTRIP, &rows_strip); 1389 - TIFFGetField (in, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); 1390 - if (TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel) == 0) 1391 - { 1392 - /* attempting to recover badly formatted TIFFs */ 1393 - samples_per_pixel = 1; 1394 - } 1395 - TIFFGetField (in, TIFFTAG_PHOTOMETRIC, &photometric); 1396 - TIFFGetField (in, TIFFTAG_COMPRESSION, &compression); 1397 - if (TIFFGetField (in, TIFFTAG_PLANARCONFIG, &planar_config) == 0) 1398 - { 1399 - /* attempting to recover badly formatted TIFFs */ 1400 - planar_config = PLANARCONFIG_CONTIG; 1401 - } 1402 - if (TIFFGetField (in, TIFFTAG_SAMPLEFORMAT, &sample_format) == 0) 1403 - sample_format = SAMPLEFORMAT_UINT; 1404 - if (planar_config == PLANARCONFIG_CONTIG) 1405 - { 1406 - if (sample_format == SAMPLEFORMAT_UINT) 1407 - { 1408 - if (bits_per_sample == 1 && samples_per_pixel == 1) 1409 - type = GG_PIXEL_PALETTE; 1410 - else if (bits_per_sample == 8 && samples_per_pixel == 1 1411 - && photometric == 3) 1412 - type = GG_PIXEL_PALETTE; 1413 - else if (bits_per_sample == 8 && samples_per_pixel == 1 1414 - && photometric < 2) 1415 - type = GG_PIXEL_GRAYSCALE; 1416 - else if (bits_per_sample == 8 && samples_per_pixel == 3) 1417 - type = GG_PIXEL_RGB; 1418 - else 1419 - type = GG_PIXEL_UNKNOWN; 1420 - } 1421 - else if (samples_per_pixel == 1) 1422 - type = GG_PIXEL_GRID; 1423 - else 1424 - type = GG_PIXEL_UNKNOWN; 1425 - } 1426 - else 1427 - type = GG_PIXEL_UNKNOWN; 1428 - switch (sample_format) 1429 - { 1430 - case SAMPLEFORMAT_UINT: 1431 - gg_sample_format = GGRAPH_SAMPLE_UINT; 1432 - break; 1433 - case SAMPLEFORMAT_INT: 1434 - gg_sample_format = GGRAPH_SAMPLE_INT; 1435 - break; 1436 - case SAMPLEFORMAT_IEEEFP: 1437 - gg_sample_format = GGRAPH_SAMPLE_FLOAT; 1438 - break; 1439 - default: 1440 - gg_sample_format = GGRAPH_SAMPLE_UNKNOWN; 1441 - break; 1442 - }; 1443 - if (type == GG_PIXEL_UNKNOWN) 1444 - { 1445 - ret = GGRAPH_UNSUPPORTED_TIFF_LAYOUT; 1446 - goto error; 1447 - } 1448 - 1449 - img = 1450 - gg_strip_image_create (NULL, GGRAPH_IMAGE_TIFF, type, width, height, 1451 - bits_per_sample, samples_per_pixel, 1452 - gg_sample_format, NULL, NULL); 1453 - if (!img) 1454 - { 1455 - ret = GGRAPH_INSUFFICIENT_MEMORY; 1456 - goto error; 1457 - } 1458 - if (is_tiled) 1459 - { 1460 - img->tile_width = tile_width; 1461 - img->tile_height = tile_height; 1462 - } 1463 - else 1464 - img->rows_per_strip = rows_strip; 1465 - switch (compression) 1466 - { 1467 - case COMPRESSION_NONE: 1468 - img->compression = GGRAPH_TIFF_COMPRESSION_NONE; 1469 - break; 1470 - case COMPRESSION_LZW: 1471 - img->compression = GGRAPH_TIFF_COMPRESSION_LZW; 1472 - break; 1473 - case COMPRESSION_DEFLATE: 1474 - img->compression = GGRAPH_TIFF_COMPRESSION_DEFLATE; 1475 - break; 1476 - case COMPRESSION_JPEG: 1477 - img->compression = GGRAPH_TIFF_COMPRESSION_JPEG; 1478 - break; 1479 - case COMPRESSION_CCITTFAX3: 1480 - img->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX3; 1481 - break; 1482 - case COMPRESSION_CCITTFAX4: 1483 - img->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX4; 1484 - break; 1485 - default: 1486 - img->compression = GGRAPH_TIFF_COMPRESSION_UNKNOWN; 1487 - break; 1488 - }; 1489 - if (photometric == PHOTOMETRIC_PALETTE) 1490 - { 1491 - /* populating the palette */ 1492 - int i; 1493 - uint16 *red; 1494 - uint16 *green; 1495 - uint16 *blue; 1496 - TIFFGetField (in, TIFFTAG_COLORMAP, &red, &green, &blue); 1497 - switch (bits_per_sample) 1498 - { 1499 - case 1: 1500 - img->max_palette = 2; 1501 - break; 1502 - case 2: 1503 - img->max_palette = 4; 1504 - break; 1505 - case 3: 1506 - img->max_palette = 8; 1507 - break; 1508 - case 4: 1509 - img->max_palette = 16; 1510 - break; 1511 - case 5: 1512 - img->max_palette = 32; 1513 - break; 1514 - case 6: 1515 - img->max_palette = 64; 1516 - break; 1517 - case 7: 1518 - img->max_palette = 128; 1519 - break; 1520 - default: 1521 - img->max_palette = 256; 1522 - break; 1523 - }; 1524 - for (i = 0; i < img->max_palette; i++) 1525 - { 1526 - unsigned char r; 1527 - unsigned char g; 1528 - unsigned char b; 1529 - if (red[i] < 256) 1530 - r = red[i]; 1531 - else 1532 - r = red[i] / 256; 1533 - if (green[i] < 256) 1534 - g = green[i]; 1535 - else 1536 - g = green[i] / 256; 1537 - if (blue[i] < 256) 1538 - b = blue[i]; 1539 - else 1540 - b = blue[i] / 256; 1541 - img->palette_red[i] = r; 1542 - img->palette_green[i] = g; 1543 - img->palette_blue[i] = b; 1544 - } 1545 - } 1546 - if (bits_per_sample == 1 && img->max_palette == 0) 1547 - { 1548 - /* populating a monochrome palette */ 1549 - if (photometric == PHOTOMETRIC_MINISBLACK) 1550 - { 1551 - img->palette_red[0] = 0; 1552 - img->palette_green[0] = 0; 1553 - img->palette_blue[0] = 0; 1554 - img->palette_red[1] = 255; 1555 - img->palette_green[1] = 255; 1556 - img->palette_blue[1] = 255; 1557 - img->max_palette = 2; 1558 - } 1559 - else 1560 - { 1561 - img->palette_red[0] = 255; 1562 - img->palette_green[0] = 255; 1563 - img->palette_blue[0] = 255; 1564 - img->palette_red[1] = 0; 1565 - img->palette_green[1] = 0; 1566 - img->palette_blue[1] = 0; 1567 - img->max_palette = 2; 1568 - } 1569 - } 1570 - 1571 -/* setting up the TIFF codec struct */ 1572 - tiff_codec = malloc (sizeof (struct tiff_codec_data)); 1573 - if (!tiff_codec) 1574 - goto error; 1575 - tiff_codec->is_geotiff = 0; 1576 - tiff_codec->is_writer = 0; 1577 - tiff_codec->tiff_handle = in; 1578 - tiff_codec->geotiff_handle = (GTIF *) 0; 1579 - tiff_codec->tiff_buffer = NULL; 1580 - tiff_codec->is_tiled = is_tiled; 1581 - img->codec_data = tiff_codec; 1582 - 1583 -/* allocating the TIFF read buffer */ 1584 - if (type == GG_PIXEL_GRID) 1585 - { 1586 - if (is_tiled) 1587 - buf_size = TIFFTileSize (in); 1588 - else 1589 - buf_size = TIFFScanlineSize (in); 1590 - } 1591 - else 1592 - { 1593 - if (is_tiled) 1594 - buf_size = sizeof (uint32) * tile_width * tile_height; 1595 - else 1596 - buf_size = sizeof (uint32) * width * rows_strip; 1597 - } 1598 - tiff_buffer = malloc (buf_size); 1599 - if (!tiff_buffer) 1600 - goto error; 1601 - tiff_codec->tiff_buffer = tiff_buffer; 1602 - 1603 - *image_handle = img; 1604 - return GGRAPH_OK; 1605 - 1606 - error: 1607 - TIFFClose (in); 1608 - if (img) 1609 - gGraphDestroyImage (img); 1610 - return ret; 1611 -} 1612 - 1613 -GGRAPH_PRIVATE int 1614 -gg_image_strip_prepare_from_geotiff (const char *path, 1615 - gGraphStripImagePtr * image_handle) 1616 -{ 1617 -/* preparing to decode a GeoTIFF [by meta-strips] */ 1618 - gGraphStripImagePtr img = NULL; 1619 - uint16 bits_per_sample; 1620 - uint16 samples_per_pixel; 1621 - uint16 photometric; 1622 - uint16 compression; 1623 - uint16 planar_config; 1624 - uint16 sample_format; 1625 - uint32 width = 0; 1626 - uint32 height = 0; 1627 - uint32 rows_strip = 0; 1628 - int is_tiled; 1629 - uint32 tile_width; 1630 - uint32 tile_height; 1631 - int type; 1632 - int gg_sample_format; 1633 - int epsg = -1; 1634 - double cx; 1635 - double cy; 1636 - double upper_left_x; 1637 - double upper_left_y; 1638 - double upper_right_x; 1639 - double lower_left_y; 1640 - double pixel_x; 1641 - double pixel_y; 1642 - char srs_name[1024]; 1643 - char proj4text[1024]; 1644 - struct tiff_codec_data *tiff_codec = NULL; 1645 - tsize_t buf_size; 1646 - void *tiff_buffer = NULL; 1647 - int ret = GGRAPH_TIFF_CODEC_ERROR; 1648 - TIFF *in = (TIFF *) 0; 1649 - GTIF *gtif = (GTIF *) 0; 1650 - GTIFDefn definition; 1651 - *image_handle = NULL; 1652 - 1653 -/* suppressing TIFF warnings */ 1654 - TIFFSetWarningHandler (NULL); 1655 - 1656 -/* reading from file */ 1657 - in = XTIFFOpen (path, "r"); 1658 - if (in == NULL) 1659 - return GGRAPH_GEOTIFF_CODEC_ERROR; 1660 - gtif = GTIFNew (in); 1661 - if (gtif == NULL) 1662 - goto error; 1663 - 1664 - if (!GTIFGetDefn (gtif, &definition)) 1665 - goto error; 1666 - 1667 -/* retrieving the EPSG code */ 1668 - if (definition.PCS == 32767) 1669 - { 1670 - if (definition.GCS != 32767) 1671 - epsg = definition.GCS; 1672 - } 1673 - else 1674 - epsg = definition.PCS; 1675 - *srs_name = '\0'; 1676 - if (definition.PCS == 32767) 1677 - { 1678 - /* Get the GCS name if possible */ 1679 - char *pszName = NULL; 1680 - GTIFGetGCSInfo (definition.GCS, &pszName, NULL, NULL, NULL); 1681 - if (pszName != NULL) 1682 - strcpy (srs_name, pszName); 1683 - CPLFree (pszName); 1684 - } 1685 - else 1686 - { 1687 - /* Get the PCS name if possible */ 1688 - char *pszPCSName = NULL; 1689 - GTIFGetPCSInfo (definition.PCS, &pszPCSName, NULL, NULL, NULL); 1690 - if (pszPCSName != NULL) 1691 - strcpy (srs_name, pszPCSName); 1692 - CPLFree (pszPCSName); 1693 - } 1694 -/* retrieving the PROJ.4 params */ 1695 - strcpy (proj4text, GTIFGetProj4Defn (&definition)); 1696 - 1697 - is_tiled = TIFFIsTiled (in); 1698 -/* retrieving the TIFF dimensions */ 1699 - TIFFGetField (in, TIFFTAG_IMAGELENGTH, &height); 1700 - TIFFGetField (in, TIFFTAG_IMAGEWIDTH, &width); 1701 - if (is_tiled) 1702 - { 1703 - TIFFGetField (in, TIFFTAG_TILEWIDTH, &tile_width); 1704 - TIFFGetField (in, TIFFTAG_TILELENGTH, &tile_height); 1705 - } 1706 - else 1707 - TIFFGetField (in, TIFFTAG_ROWSPERSTRIP, &rows_strip); 1708 - TIFFGetField (in, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); 1709 - if (TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel) == 0) 1710 - { 1711 - /* attempting to recover badly formatted TIFFs */ 1712 - samples_per_pixel = 1; 1713 - } 1714 - TIFFGetField (in, TIFFTAG_PHOTOMETRIC, &photometric); 1715 - TIFFGetField (in, TIFFTAG_COMPRESSION, &compression); 1716 - if (TIFFGetField (in, TIFFTAG_PLANARCONFIG, &planar_config) == 0) 1717 - { 1718 - /* attempting to recover badly formatted TIFFs */ 1719 - planar_config = PLANARCONFIG_CONTIG; 1720 - } 1721 - if (TIFFGetField (in, TIFFTAG_SAMPLEFORMAT, &sample_format) == 0) 1722 - sample_format = SAMPLEFORMAT_UINT; 1723 - if (planar_config == PLANARCONFIG_CONTIG) 1724 - { 1725 - if (sample_format == SAMPLEFORMAT_UINT) 1726 - { 1727 - if (bits_per_sample == 1 && samples_per_pixel == 1) 1728 - type = GG_PIXEL_PALETTE; 1729 - else if (bits_per_sample == 8 && samples_per_pixel == 1 1730 - && photometric == 3) 1731 - type = GG_PIXEL_PALETTE; 1732 - else if (bits_per_sample == 8 && samples_per_pixel == 1 1733 - && photometric < 2) 1734 - type = GG_PIXEL_GRAYSCALE; 1735 - else if (bits_per_sample == 8 && samples_per_pixel == 3) 1736 - type = GG_PIXEL_RGB; 1737 - else 1738 - type = GG_PIXEL_UNKNOWN; 1739 - } 1740 - else if (samples_per_pixel == 1) 1741 - type = GG_PIXEL_GRID; 1742 - else 1743 - type = GG_PIXEL_UNKNOWN; 1744 - } 1745 - else 1746 - type = GG_PIXEL_UNKNOWN; 1747 - switch (sample_format) 1748 - { 1749 - case SAMPLEFORMAT_UINT: 1750 - gg_sample_format = GGRAPH_SAMPLE_UINT; 1751 - break; 1752 - case SAMPLEFORMAT_INT: 1753 - gg_sample_format = GGRAPH_SAMPLE_INT; 1754 - break; 1755 - case SAMPLEFORMAT_IEEEFP: 1756 - gg_sample_format = GGRAPH_SAMPLE_FLOAT; 1757 - break; 1758 - default: 1759 - gg_sample_format = GGRAPH_SAMPLE_UNKNOWN; 1760 - break; 1761 - }; 1762 - 1763 -/* computing the corners coords */ 1764 - cx = 0.0; 1765 - cy = 0.0; 1766 - GTIFImageToPCS (gtif, &cx, &cy); 1767 - upper_left_x = cx; 1768 - upper_left_y = cy; 1769 - cx = 0.0; 1770 - cy = height; 1771 - GTIFImageToPCS (gtif, &cx, &cy); 1772 - lower_left_y = cy; 1773 - cx = width; 1774 - cy = 0.0; 1775 - GTIFImageToPCS (gtif, &cx, &cy); 1776 - upper_right_x = cx; 1777 - cx = width; 1778 - cy = height; 1779 - GTIFImageToPCS (gtif, &cx, &cy); 1780 -/* computing the pixel size */ 1781 - pixel_x = (upper_right_x - upper_left_x) / (double) width; 1782 - pixel_y = (upper_left_y - lower_left_y) / (double) height; 1783 - if (type == GG_PIXEL_UNKNOWN) 1784 - { 1785 - ret = GGRAPH_UNSUPPORTED_TIFF_LAYOUT; 1786 - goto error; 1787 - } 1788 - 1789 - img = 1790 - gg_strip_image_create (NULL, GGRAPH_IMAGE_TIFF, type, width, height, 1791 - bits_per_sample, samples_per_pixel, 1792 - gg_sample_format, srs_name, proj4text); 1793 - if (!img) 1794 - { 1795 - ret = GGRAPH_INSUFFICIENT_MEMORY; 1796 - goto error; 1797 - } 1798 - if (is_tiled) 1799 - { 1800 - img->tile_width = tile_width; 1801 - img->tile_height = tile_height; 1802 - } 1803 - else 1804 - img->rows_per_strip = rows_strip; 1805 - img->is_georeferenced = 1; 1806 - img->srid = epsg; 1807 - img->upper_left_x = upper_left_x; 1808 - img->upper_left_y = upper_left_y; 1809 - img->pixel_x_size = pixel_x; 1810 - img->pixel_y_size = pixel_y; 1811 - switch (compression) 1812 - { 1813 - case COMPRESSION_NONE: 1814 - img->compression = GGRAPH_TIFF_COMPRESSION_NONE; 1815 - break; 1816 - case COMPRESSION_LZW: 1817 - img->compression = GGRAPH_TIFF_COMPRESSION_LZW; 1818 - break; 1819 - case COMPRESSION_DEFLATE: 1820 - img->compression = GGRAPH_TIFF_COMPRESSION_DEFLATE; 1821 - break; 1822 - case COMPRESSION_JPEG: 1823 - img->compression = GGRAPH_TIFF_COMPRESSION_JPEG; 1824 - break; 1825 - case COMPRESSION_CCITTFAX3: 1826 - img->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX3; 1827 - break; 1828 - case COMPRESSION_CCITTFAX4: 1829 - img->compression = GGRAPH_TIFF_COMPRESSION_CCITTFAX4; 1830 - break; 1831 - default: 1832 - img->compression = GGRAPH_TIFF_COMPRESSION_UNKNOWN; 1833 - break; 1834 - }; 1835 - if (photometric == PHOTOMETRIC_PALETTE) 1836 - { 1837 - /* populating the palette */ 1838 - int i; 1839 - uint16 *red; 1840 - uint16 *green; 1841 - uint16 *blue; 1842 - TIFFGetField (in, TIFFTAG_COLORMAP, &red, &green, &blue); 1843 - switch (bits_per_sample) 1844 - { 1845 - case 2: 1846 - img->max_palette = 4; 1847 - break; 1848 - case 3: 1849 - img->max_palette = 8; 1850 - break; 1851 - case 4: 1852 - img->max_palette = 16; 1853 - break; 1854 - case 5: 1855 - img->max_palette = 32; 1856 - break; 1857 - case 6: 1858 - img->max_palette = 64; 1859 - break; 1860 - case 7: 1861 - img->max_palette = 128; 1862 - break; 1863 - default: 1864 - img->max_palette = 256; 1865 - break; 1866 - }; 1867 - for (i = 0; i < img->max_palette; i++) 1868 - { 1869 - unsigned char r; 1870 - unsigned char g; 1871 - unsigned char b; 1872 - if (red[i] < 256) 1873 - r = red[i]; 1874 - else 1875 - r = red[i] / 256; 1876 - if (green[i] < 256) 1877 - g = green[i]; 1878 - else 1879 - g = green[i] / 256; 1880 - if (blue[i] < 256) 1881 - b = blue[i]; 1882 - else 1883 - b = blue[i] / 256; 1884 - img->palette_red[i] = r; 1885 - img->palette_green[i] = g; 1886 - img->palette_blue[i] = b; 1887 - } 1888 - } 1889 - if (bits_per_sample == 1 && img->max_palette == 0) 1890 - { 1891 - /* populating a monochrome palette */ 1892 - if (photometric == PHOTOMETRIC_MINISBLACK) 1893 - { 1894 - img->palette_red[0] = 0; 1895 - img->palette_green[0] = 0; 1896 - img->palette_blue[0] = 0; 1897 - img->palette_red[1] = 255; 1898 - img->palette_green[1] = 255; 1899 - img->palette_blue[1] = 255; 1900 - img->max_palette = 2; 1901 - } 1902 - else 1903 - { 1904 - img->palette_red[0] = 255; 1905 - img->palette_green[0] = 255; 1906 - img->palette_blue[0] = 255; 1907 - img->palette_red[1] = 0; 1908 - img->palette_green[1] = 0; 1909 - img->palette_blue[1] = 0; 1910 - img->max_palette = 2; 1911 - } 1912 - } 1913 - 1914 -/* setting up the TIFF codec struct */ 1915 - tiff_codec = malloc (sizeof (struct tiff_codec_data)); 1916 - if (!tiff_codec) 1917 - goto error; 1918 - tiff_codec->is_geotiff = 1; 1919 - tiff_codec->is_writer = 0; 1920 - tiff_codec->tiff_handle = in; 1921 - tiff_codec->geotiff_handle = gtif; 1922 - tiff_codec->tiff_buffer = NULL; 1923 - tiff_codec->is_tiled = is_tiled; 1924 - img->codec_data = tiff_codec; 1925 - 1926 -/* allocating the TIFF read buffer */ 1927 - if (type == GG_PIXEL_GRID) 1928 - { 1929 - if (is_tiled) 1930 - buf_size = TIFFTileSize (in); 1931 - else 1932 - buf_size = TIFFScanlineSize (in); 1933 - } 1934 - else 1935 - { 1936 - if (is_tiled) 1937 - buf_size = sizeof (uint32) * tile_width * tile_height; 1938 - else 1939 - buf_size = sizeof (uint32) * width * rows_strip; 1940 - } 1941 - tiff_buffer = malloc (buf_size); 1942 - if (!tiff_buffer) 1943 - goto error; 1944 - tiff_codec->tiff_buffer = tiff_buffer; 1945 - 1946 - *image_handle = img; 1947 - return GGRAPH_OK; 1948 - 1949 - error: 1950 - XTIFFClose (in); 1951 - if (gtif) 1952 - GTIFFree (gtif); 1953 - if (img) 1954 - gGraphDestroyImage (img); 1955 - return ret; 1956 -} 1957 - 1958 -GGRAPH_PRIVATE void 1959 -gg_tiff_codec_destroy (void *p) 1960 -{ 1961 -/* destroyng the TIFF codec data */ 1962 - struct tiff_codec_data *codec = (struct tiff_codec_data *) p; 1963 - if (!codec) 1964 - return; 1965 - if (codec->is_geotiff) 1966 - { 1967 - XTIFFClose (codec->tiff_handle); 1968 - GTIFFree (codec->geotiff_handle); 1969 - } 1970 - else 1971 - TIFFClose (codec->tiff_handle); 1972 - if (codec->tiff_buffer) 1973 - free (codec->tiff_buffer); 1974 - free (codec); 1975 -} 1976 - 1977 -static int 1978 -common_strip_read_from_tiff_grid (TIFF * in, void *tiff_buffer, 1979 - gGraphStripImagePtr img, uint32 width, 1980 - uint32 height, int is_tiled, 1981 - uint32 tile_width, uint32 tile_height) 1982 -{ 1983 -/* common utility: decoding a TIFF raster [GRID] by meta-strip */ 1984 - void *raster = tiff_buffer; 1985 - int x; 1986 - int y; 1987 - int strip_no; 1988 - int tile_x; 1989 - int tile_y; 1990 - char *p_in_int8; 1991 - char *p_out_int8; 1992 - unsigned char *p_in_uint8; 1993 - unsigned char *p_out_uint8; 1994 - short *p_in_int16; 1995 - short *p_out_int16; 1996 - unsigned short *p_in_uint16; 1997 - unsigned short *p_out_uint16; 1998 - int *p_in_int32; 1999 - int *p_out_int32; 2000 - unsigned int *p_in_uint32; 2001 - unsigned int *p_out_uint32; 2002 - float *p_in_flt; 2003 - float *p_out_flt; 2004 - double *p_in_dbl; 2005 - double *p_out_dbl; 2006 - int begin_row = img->next_row; 2007 - int end_row = img->next_row + img->rows_per_block; 2008 - 2009 - if (end_row > img->height) 2010 - end_row = img->height; 2011 - 2012 - if (is_tiled) 2013 - { 2014 - for (tile_y = 0; tile_y < (int) height; tile_y += tile_height) 2015 - { 2016 - /* scanning tiles by row */ 2017 - if ((tile_y + tile_height) <= (uint32) begin_row) 2018 - continue; 2019 - if (tile_y >= end_row) 2020 - break; 2021 - for (tile_x = 0; tile_x < (int) width; tile_x += tile_width) 2022 - { 2023 - /* reading a TIFF tile */ 2024 - if (!TIFFReadTile (in, raster, tile_x, tile_y, 0, 0)) 2025 - return GGRAPH_TIFF_CODEC_ERROR; 2026 - for (y = 0; y < (int) tile_height; y++) 2027 - { 2028 - if ((tile_y + y) < begin_row) 2029 - continue; 2030 - if ((tile_y + y) >= end_row) 2031 - continue; 2032 - switch (img->sample_format) 2033 - { 2034 - case GGRAPH_SAMPLE_INT: 2035 - switch (img->bits_per_sample) 2036 - { 2037 - case 8: 2038 - p_in_int8 = raster; 2039 - p_in_int8 += y * tile_width; 2040 - break; 2041 - case 16: 2042 - p_in_int16 = raster; 2043 - p_in_int16 += y * tile_width; 2044 - break; 2045 - case 32: 2046 - p_in_int32 = raster; 2047 - p_in_int32 += y * tile_width; 2048 - break; 2049 - }; 2050 - break; 2051 - case GGRAPH_SAMPLE_UINT: 2052 - switch (img->bits_per_sample) 2053 - { 2054 - case 8: 2055 - p_in_uint8 = raster; 2056 - p_in_uint8 += y * tile_width; 2057 - break; 2058 - case 16: 2059 - p_in_uint16 = raster; 2060 - p_in_uint16 += y * tile_width; 2061 - break; 2062 - case 32: 2063 - p_in_uint32 = raster; 2064 - p_in_uint32 += y * tile_width; 2065 - break; 2066 - }; 2067 - break; 2068 - case GGRAPH_SAMPLE_FLOAT: 2069 - switch (img->bits_per_sample) 2070 - { 2071 - case 32: 2072 - p_in_flt = raster; 2073 - p_in_flt += y * tile_width; 2074 - break; 2075 - case 64: 2076 - p_in_dbl = raster; 2077 - p_in_dbl += y * tile_width; 2078 - break; 2079 - } 2080 - break; 2081 - }; 2082 - for (x = 0; x < (int) tile_width; x++) 2083 - { 2084 - if (tile_x + x >= (int) width) 2085 - break; 2086 - switch (img->sample_format) 2087 - { 2088 - case GGRAPH_SAMPLE_INT: 2089 - switch (img->bits_per_sample) 2090 - { 2091 - case 8: 2092 - p_out_int8 = 2093 - (char *) (img->pixels); 2094 - p_out_int8 += 2095 - (img->width * 2096 - ((tile_y + y) - begin_row)) + 2097 - (tile_x + x); 2098 - *p_out_int8 = *p_in_int8++; 2099 - break; 2100 - case 16: 2101 - p_out_int16 = 2102 - (short *) (img->pixels); 2103 - p_out_int16 += 2104 - (img->width * 2105 - ((tile_y + y) - begin_row)) + 2106 - (tile_x + x); 2107 - *p_out_int16 = *p_in_int16++; 2108 - break; 2109 - case 32: 2110 - p_out_int32 = 2111 - (int *) (img->pixels); 2112 - p_out_int32 += 2113 - (img->width * 2114 - ((tile_y + y) - begin_row)) + 2115 - (tile_x + x); 2116 - *p_out_int32 = *p_in_int32++; 2117 - break; 2118 - }; 2119 - break; 2120 - case GGRAPH_SAMPLE_UINT: 2121 - switch (img->bits_per_sample) 2122 - { 2123 - case 8: 2124 - p_out_uint8 = 2125 - (unsigned char 2126 - *) (img->pixels); 2127 - p_out_uint8 += 2128 - (img->width * 2129 - ((tile_y + y) - begin_row)) + 2130 - (tile_x + x); 2131 - *p_out_uint8 = *p_in_uint8++; 2132 - break; 2133 - case 16: 2134 - p_out_uint16 = 2135 - (unsigned short 2136 - *) (img->pixels); 2137 - p_out_uint16 += 2138 - (img->width * 2139 - ((tile_y + y) - begin_row)) + 2140 - (tile_x + x); 2141 - *p_out_uint16 = *p_in_uint16++; 2142 - break; 2143 - case 32: 2144 - p_out_uint32 = 2145 - (unsigned int 2146 - *) (img->pixels); 2147 - p_out_uint32 += 2148 - (img->width * 2149 - ((tile_y + y) - begin_row)) + 2150 - (tile_x + x); 2151 - *p_out_uint32 = *p_in_uint32++; 2152 - break; 2153 - } 2154 - break; 2155 - case GGRAPH_SAMPLE_FLOAT: 2156 - switch (img->bits_per_sample) 2157 - { 2158 - case 32: 2159 - p_out_flt = 2160 - (float *) (img->pixels); 2161 - p_out_flt += 2162 - (img->width * 2163 - ((tile_y + y) - begin_row)) + 2164 - (tile_x + x); 2165 - *p_out_flt = *p_in_flt++; 2166 - break; 2167 - case 64: 2168 - p_out_dbl = 2169 - (double *) (img->pixels); 2170 - p_out_dbl += 2171 - (img->width * 2172 - ((tile_y + y) - begin_row)) + 2173 - (tile_x + x); 2174 - *p_out_dbl = *p_in_dbl++; 2175 - break; 2176 - }; 2177 - break; 2178 - }; 2179 - } 2180 - } 2181 - } 2182 - } 2183 - img->next_row += end_row - begin_row; 2184 - img->current_available_rows = end_row - begin_row; 2185 - } 2186 - else 2187 - { 2188 - for (strip_no = begin_row; strip_no < end_row; strip_no++) 2189 - { 2190 - /* reading a TIFF strip */ 2191 - if (!TIFFReadScanline (in, raster, strip_no, 0)) 2192 - return GGRAPH_TIFF_CODEC_ERROR; 2193 - switch (img->sample_format) 2194 - { 2195 - case GGRAPH_SAMPLE_INT: 2196 - switch (img->bits_per_sample) 2197 - { 2198 - case 8: 2199 - p_in_int8 = raster; 2200 - p_out_int8 = (char *) (img->pixels); 2201 - p_out_int8 += img->width * (strip_no - begin_row); 2202 - break; 2203 - case 16: 2204 - p_in_int16 = raster; 2205 - p_out_int16 = (short *) (img->pixels); 2206 - p_out_int16 += img->width * (strip_no - begin_row); 2207 - break; 2208 - case 32: 2209 - p_in_int32 = raster; 2210 - p_out_int32 = (int *) (img->pixels); 2211 - p_out_int32 += img->width * (strip_no - begin_row); 2212 - break; 2213 - }; 2214 - break; 2215 - case GGRAPH_SAMPLE_UINT: 2216 - switch (img->bits_per_sample) 2217 - { 2218 - case 8: 2219 - p_in_uint8 = raster; 2220 - p_out_uint8 = (unsigned char *) (img->pixels); 2221 - p_out_uint8 += img->width * (strip_no - begin_row); 2222 - break; 2223 - case 16: 2224 - p_in_uint16 = raster; 2225 - p_out_uint16 = (unsigned short *) (img->pixels); 2226 - p_out_uint16 += img->width * (strip_no - begin_row); 2227 - break; 2228 - case 32: 2229 - p_in_uint32 = raster; 2230 - p_out_uint32 = (unsigned int *) (img->pixels); 2231 - p_out_uint32 += img->width * (strip_no - begin_row); 2232 - break; 2233 - }; 2234 - break; 2235 - case GGRAPH_SAMPLE_FLOAT: 2236 - switch (img->bits_per_sample) 2237 - { 2238 - case 32: 2239 - p_in_flt = raster; 2240 - p_out_flt = (float *) (img->pixels); 2241 - p_out_flt += img->width * (strip_no - begin_row); 2242 - break; 2243 - case 64: 2244 - p_in_dbl = raster; 2245 - p_out_dbl = (double *) (img->pixels); 2246 - p_out_dbl += img->width * (strip_no - begin_row); 2247 - break; 2248 - } 2249 - break; 2250 - }; 2251 - for (x = 0; x < (int) width; x++) 2252 - { 2253 - switch (img->sample_format) 2254 - { 2255 - case GGRAPH_SAMPLE_INT: 2256 - switch (img->bits_per_sample) 2257 - { 2258 - case 8: 2259 - *p_out_int8++ = *p_in_int8++; 2260 - break; 2261 - case 16: 2262 - *p_out_int16++ = *p_in_int16++; 2263 - break; 2264 - case 32: 2265 - *p_out_int32++ = *p_in_int32++; 2266 - break; 2267 - }; 2268 - break; 2269 - case GGRAPH_SAMPLE_UINT: 2270 - switch (img->bits_per_sample) 2271 - { 2272 - case 8: 2273 - *p_out_uint8++ = *p_in_uint8++; 2274 - break; 2275 - case 16: 2276 - *p_out_uint16++ = *p_in_uint16++; 2277 - break; 2278 - case 32: 2279 - *p_out_uint32++ = *p_in_uint32++; 2280 - break; 2281 - } 2282 - break; 2283 - case GGRAPH_SAMPLE_FLOAT: 2284 - switch (img->bits_per_sample) 2285 - { 2286 - case 32: 2287 - *p_out_flt++ = *p_in_flt++; 2288 - break; 2289 - case 64: 2290 - *p_out_dbl++ = *p_in_dbl++; 2291 - break; 2292 - }; 2293 - break; 2294 - }; 2295 - } 2296 - } 2297 - img->next_row += end_row - begin_row; 2298 - img->current_available_rows = end_row - begin_row; 2299 - } 2300 - return GGRAPH_OK; 2301 -} 2302 - 2303 -GGRAPH_PRIVATE unsigned char 2304 -gg_match_strip_palette (const gGraphStripImagePtr img, unsigned char r, 2305 - unsigned char g, unsigned char b) 2306 -{ 2307 -/* handling palette colors */ 2308 - int index; 2309 - double min_dist = DBL_MAX; 2310 - double dist; 2311 - int min_index; 2312 - for (index = 0; index < img->max_palette; index++) 2313 - { 2314 - /* searching if already defined */ 2315 - if (img->palette_red[index] == r && img->palette_green[index] == g 2316 - && img->palette_blue[index] == b) 2317 - return (unsigned char) index; 2318 - } 2319 - if (img->max_palette < 255) 2320 - { 2321 - /* inserting a new palette entry */ 2322 - unsigned char i = img->max_palette; 2323 - img->max_palette += 1; 2324 - img->palette_red[i] = r; 2325 - img->palette_green[i] = g; 2326 - img->palette_blue[i] = b; 2327 - return i; 2328 - } 2329 -/* all right, the palette is already fully populated */ 2330 - for (index = 0; index < img->max_palette; index++) 2331 - { 2332 - /* computing the minimal euclidean distance */ 2333 - dist = 2334 - sqrt (((img->palette_red[index] - r) * (img->palette_red[index] - 2335 - r)) + 2336 - ((img->palette_green[index] - 2337 - g) * (img->palette_green[index] - g)) + 2338 - ((img->palette_blue[index] - 2339 - b) * (img->palette_blue[index] - b))); 2340 - if (dist < min_dist) 2341 - { 2342 - min_dist = dist; 2343 - min_index = index; 2344 - } 2345 - } 2346 - return (unsigned char) min_index; 2347 -} 2348 - 2349 -static int 2350 -common_strip_read_from_tiff (TIFF * in, void *tiff_buffer, 2351 - gGraphStripImagePtr img, uint32 width, 2352 - uint32 height, int is_tiled, int type, 2353 - uint32 tile_width, uint32 tile_height, 2354 - uint32 rows_strip) 2355 -{ 2356 -/* common utility: decoding a TIFF raster [by meta-strip] */ 2357 - uint32 *raster = tiff_buffer; 2358 - uint32 *scanline; 2359 - int x; 2360 - int y; 2361 - int img_y; 2362 - int strip_no; 2363 - uint32 pixel; 2364 - int tile_x; 2365 - int tile_y; 2366 - unsigned char red; 2367 - unsigned char green; 2368 - unsigned char blue; 2369 - unsigned char index; 2370 - unsigned char *p_out; 2371 - int begin_row = img->next_row; 2372 - int end_row = img->next_row + img->rows_per_block; 2373 - 2374 - if (type == GG_PIXEL_GRID) 2375 - return common_strip_read_from_tiff_grid (in, tiff_buffer, img, width, 2376 - height, is_tiled, tile_width, 2377 - tile_height); 2378 - 2379 - if (end_row > img->height) 2380 - end_row = img->height; 2381 - 2382 - if (is_tiled) 2383 - { 2384 - for (tile_y = 0; tile_y < (int) height; tile_y += tile_height) 2385 - { 2386 - /* scanning tiles by row */ 2387 - if ((tile_y + tile_height) <= (uint32) begin_row) 2388 - continue; 2389 - if (tile_y >= end_row) 2390 - break; 2391 - for (tile_x = 0; tile_x < (int) width; tile_x += tile_width) 2392 - { 2393 - /* reading a TIFF tile */ 2394 - if (!TIFFReadRGBATile (in, tile_x, tile_y, raster)) 2395 - return GGRAPH_TIFF_CODEC_ERROR; 2396 - for (y = 0; y < (int) tile_height; y++) 2397 - { 2398 - img_y = tile_y + (tile_height - y) - 1; 2399 - if (img_y < begin_row) 2400 - continue; 2401 - if (img_y >= end_row) 2402 - continue; 2403 - scanline = raster + (y * tile_width); 2404 - for (x = 0; x < (int) tile_width; x++) 2405 - { 2406 - if (tile_x + x >= (int) width) 2407 - break; 2408 - p_out = 2409 - img->pixels + 2410 - (img->scanline_width * 2411 - (img_y - begin_row)); 2412 - p_out += (tile_x + x) * img->pixel_size; 2413 - pixel = scanline[x]; 2414 - red = TIFFGetR (pixel); 2415 - green = TIFFGetG (pixel); 2416 - blue = TIFFGetB (pixel); 2417 - if (img->pixel_format == GG_PIXEL_PALETTE) 2418 - { 2419 - /* PALETTE image */ 2420 - index = 2421 - gg_match_strip_palette (img, red, 2422 - green, 2423 - blue); 2424 - *p_out++ = index; 2425 - } 2426 - else if (img->pixel_format == 2427 - GG_PIXEL_GRAYSCALE) 2428 - { 2429 - /* GRAYSCALE image */ 2430 - *p_out++ = red; 2431 - } 2432 - else 2433 - { 2434 - /* should be an RGB image */ 2435 - *p_out++ = red; 2436 - *p_out++ = green; 2437 - *p_out++ = blue; 2438 - } 2439 - } 2440 - } 2441 - } 2442 - } 2443 - img->next_row += end_row - begin_row; 2444 - img->current_available_rows = end_row - begin_row; 2445 - } 2446 - else 2447 - { 2448 - for (strip_no = 0; strip_no < (int) height; strip_no += rows_strip) 2449 - { 2450 - /* reading a TIFF strip */ 2451 - int effective_strip = rows_strip; 2452 - if ((strip_no + rows_strip) <= (uint32) begin_row) 2453 - continue; 2454 - if (strip_no >= end_row) 2455 - break; 2456 - if (!TIFFReadRGBAStrip (in, strip_no, raster)) 2457 - return GGRAPH_TIFF_CODEC_ERROR; 2458 - if ((strip_no + rows_strip) > height) 2459 - effective_strip = height - strip_no; 2460 - for (y = 0; y < (int) effective_strip; y++) 2461 - { 2462 - img_y = (strip_no + effective_strip) - (y + 1); 2463 - if (img_y < begin_row) 2464 - continue; 2465 - if (img_y >= end_row) 2466 - continue; 2467 - scanline = raster + (y * width); 2468 - p_out = 2469 - img->pixels + 2470 - (img->scanline_width * (img_y - begin_row)); 2471 - for (x = 0; x < (int) width; x++) 2472 - { 2473 - pixel = scanline[x]; 2474 - red = TIFFGetR (pixel); 2475 - green = TIFFGetG (pixel); 2476 - blue = TIFFGetB (pixel); 2477 - if (img->pixel_format == GG_PIXEL_PALETTE) 2478 - { 2479 - /* PALETTE image */ 2480 - index = 2481 - gg_match_strip_palette (img, red, green, 2482 - blue); 2483 - *p_out++ = index; 2484 - } 2485 - else if (img->pixel_format == GG_PIXEL_GRAYSCALE) 2486 - { 2487 - /* GRAYSCALE image */ 2488 - *p_out++ = red; 2489 - } 2490 - else 2491 - { 2492 - /* should be an RGB image */ 2493 - *p_out++ = red; 2494 - *p_out++ = green; 2495 - *p_out++ = blue; 2496 - } 2497 - } 2498 - } 2499 - } 2500 - img->next_row += end_row - begin_row; 2501 - img->current_available_rows = end_row - begin_row; 2502 - } 2503 - return GGRAPH_OK; 2504 -} 2505 - 2506 -GGRAPH_PRIVATE int 2507 -gg_image_strip_read_from_tiff (gGraphStripImagePtr img, int *progress) 2508 -{ 2509 -/* decoding a TIFF [by meta-strip] */ 2510 - struct tiff_codec_data *tiff_codec = 2511 - (struct tiff_codec_data *) (img->codec_data); 2512 - uint32 width = img->width; 2513 - uint32 height = img->height; 2514 - uint32 rows_strip = img->rows_per_strip; 2515 - int is_tiled = tiff_codec->is_tiled; 2516 - uint32 tile_width = img->tile_width; 2517 - uint32 tile_height = img->tile_height; 2518 - int type = img->pixel_format; 2519 - TIFF *in = tiff_codec->tiff_handle; 2520 - 2521 - int ret = 2522 - common_strip_read_from_tiff (in, tiff_codec->tiff_buffer, img, width, 2523 - height, is_tiled, type, tile_width, 2524 - tile_height, rows_strip); 2525 - 2526 - if (ret == GGRAPH_OK && progress != NULL) 2527 - *progress = 2528 - (int) (((double) (img->next_row + 1) * 100.0) / 2529 - (double) (img->height)); 2530 - return ret; 2531 -} 2532 - 2533 -GGRAPH_PRIVATE int 2534 -gg_image_prepare_to_tiff_by_strip (const gGraphStripImagePtr img, 2535 - const char *path, int layout, int tile_width, 2536 - int tile_height, int rows_per_strip, 2537 - int color_model, int bits_per_sample, 2538 - int sample_format, int num_palette, 2539 - unsigned char *red, unsigned char *green, 2540 - unsigned char *blue, int compression) 2541 -{ 2542 -/* preparing to export a TIFF [by meta-strips] */ 2543 - TIFF *out = (TIFF *) 0; 2544 - uint16 r_plt[256]; 2545 - uint16 g_plt[256]; 2546 - uint16 b_plt[256]; 2547 - int i; 2548 - int tiff_type; 2549 - tsize_t buf_size; 2550 - void *tiff_buffer = NULL; 2551 - struct tiff_codec_data *tiff_codec = NULL; 2552 - 2553 -/* suppressing TIFF warnings */ 2554 - TIFFSetWarningHandler (NULL); 2555 - 2556 -/* writing to file */ 2557 - out = TIFFOpen (path, "w"); 2558 - if (out == NULL) 2559 - goto error; 2560 - 2561 -/* setting up the TIFF headers */ 2562 - TIFFSetField (out, TIFFTAG_SUBFILETYPE, 0); 2563 - TIFFSetField (out, TIFFTAG_IMAGEWIDTH, img->width); 2564 - TIFFSetField (out, TIFFTAG_IMAGELENGTH, img->height); 2565 - TIFFSetField (out, TIFFTAG_XRESOLUTION, 300.0); 2566 - TIFFSetField (out, TIFFTAG_YRESOLUTION, 300.0); 2567 - TIFFSetField (out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); 2568 - TIFFSetField (out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); 2569 - TIFFSetField (out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); 2570 - if (color_model == GGRAPH_COLORSPACE_PALETTE) 2571 - { 2572 - if (num_palette == 2) 2573 - { 2574 - if ((red[0] == 255 && green[0] == 255 && blue[0] == 255 2575 - && red[1] == 0 && green[1] == 0 && blue[1] == 0) 2576 - || (red[0] == 0 && green[0] == 0 && blue[0] == 0 2577 - && red[1] == 255 && green[1] == 255 && blue[1] == 255)) 2578 - { 2579 - /* MONOCHROME */ 2580 - tiff_type = TIFF_TYPE_MONOCHROME; 2581 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, 2582 - SAMPLEFORMAT_UINT); 2583 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 1); 2584 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, 1); 2585 - TIFFSetField (out, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); 2586 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, 2587 - PHOTOMETRIC_MINISWHITE); 2588 - if (compression == GGRAPH_TIFF_COMPRESSION_CCITTFAX3) 2589 - TIFFSetField (out, TIFFTAG_COMPRESSION, 2590 - COMPRESSION_CCITTFAX3); 2591 - else if (compression == GGRAPH_TIFF_COMPRESSION_CCITTFAX4) 2592 - TIFFSetField (out, TIFFTAG_COMPRESSION, 2593 - COMPRESSION_CCITTFAX4); 2594 - else 2595 - TIFFSetField (out, TIFFTAG_COMPRESSION, 2596 - COMPRESSION_NONE); 2597 - goto header_done; 2598 - } 2599 - } 2600 - /* PALETTE */ 2601 - tiff_type = TIFF_TYPE_PALETTE; 2602 - for (i = 0; i < img->max_palette; i++) 2603 - { 2604 - r_plt[i] = img->palette_red[i] * 256; 2605 - g_plt[i] = img->palette_green[i] * 256; 2606 - b_plt[i] = img->palette_blue[i] * 256; 2607 - } 2608 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); 2609 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 1); 2610 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, 8); 2611 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); 2612 - TIFFSetField (out, TIFFTAG_COLORMAP, r_plt, g_plt, b_plt); 2613 - if (compression == GGRAPH_TIFF_COMPRESSION_LZW) 2614 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); 2615 - else if (compression == GGRAPH_TIFF_COMPRESSION_DEFLATE) 2616 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); 2617 - else 2618 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); 2619 - } 2620 - if (color_model == GGRAPH_COLORSPACE_GRAYSCALE) 2621 - { 2622 - /* GRAYSCALE */ 2623 - tiff_type = TIFF_TYPE_GRAYSCALE; 2624 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); 2625 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 1); 2626 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, 8); 2627 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); 2628 - if (compression == GGRAPH_TIFF_COMPRESSION_LZW) 2629 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); 2630 - else if (compression == GGRAPH_TIFF_COMPRESSION_DEFLATE) 2631 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); 2632 - else if (compression == GGRAPH_TIFF_COMPRESSION_JPEG) 2633 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); 2634 - else 2635 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); 2636 - } 2637 - if (color_model == GGRAPH_COLORSPACE_TRUECOLOR 2638 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR_ALPHA) 2639 - { 2640 - /* RGB */ 2641 - tiff_type = TIFF_TYPE_RGB; 2642 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); 2643 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 3); 2644 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, 8); 2645 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); 2646 - if (compression == GGRAPH_TIFF_COMPRESSION_LZW) 2647 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); 2648 - else if (compression == GGRAPH_TIFF_COMPRESSION_DEFLATE) 2649 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); 2650 - else if (compression == GGRAPH_TIFF_COMPRESSION_JPEG) 2651 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); 2652 - else 2653 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); 2654 - } 2655 - if (color_model == GGRAPH_COLORSPACE_GRID) 2656 - { 2657 - /* GRID data */ 2658 - 2659 - tiff_type = TIFF_TYPE_GRID; 2660 - if (sample_format == GGRAPH_SAMPLE_INT) 2661 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); 2662 - if (sample_format == GGRAPH_SAMPLE_UINT) 2663 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); 2664 - if (sample_format == GGRAPH_SAMPLE_FLOAT) 2665 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); 2666 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 1); 2667 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, bits_per_sample); 2668 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); 2669 - if (compression == GGRAPH_TIFF_COMPRESSION_LZW) 2670 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); 2671 - else if (compression == GGRAPH_TIFF_COMPRESSION_DEFLATE) 2672 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); 2673 - else 2674 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); 2675 - } 2676 - 2677 - header_done: 2678 - TIFFSetField (out, TIFFTAG_SOFTWARE, "GaiaGraphics-tools"); 2679 - if (layout == GGRAPH_TIFF_LAYOUT_TILES) 2680 - { 2681 - TIFFSetField (out, TIFFTAG_TILEWIDTH, tile_width); 2682 - TIFFSetField (out, TIFFTAG_TILELENGTH, tile_height); 2683 - } 2684 - else 2685 - TIFFSetField (out, TIFFTAG_ROWSPERSTRIP, rows_per_strip); 2686 - 2687 -/* setting up the TIFF codec struct */ 2688 - tiff_codec = malloc (sizeof (struct tiff_codec_data)); 2689 - if (!tiff_codec) 2690 - goto error; 2691 - tiff_codec->is_geotiff = 0; 2692 - tiff_codec->is_writer = 1; 2693 - tiff_codec->tiff_handle = out; 2694 - tiff_codec->geotiff_handle = (GTIF *) 0; 2695 - tiff_codec->tiff_buffer = NULL; 2696 - if (layout == GGRAPH_TIFF_LAYOUT_TILES) 2697 - tiff_codec->is_tiled = 1; 2698 - else 2699 - tiff_codec->is_tiled = 0; 2700 - tiff_codec->tiff_type = tiff_type; 2701 - img->codec_data = tiff_codec; 2702 - 2703 -/* allocating the TIFF write buffer */ 2704 - if (img->pixel_format == GG_PIXEL_GRID) 2705 - { 2706 - if (tiff_codec->is_tiled) 2707 - buf_size = TIFFTileSize (out); 2708 - else 2709 - buf_size = TIFFScanlineSize (out); 2710 - } 2711 - else 2712 - { 2713 - if (tiff_codec->is_tiled) 2714 - buf_size = TIFFTileSize (out); 2715 - else 2716 - buf_size = TIFFScanlineSize (out); 2717 - } 2718 - tiff_buffer = malloc (buf_size); 2719 - if (!tiff_buffer) 2720 - goto error; 2721 - tiff_codec->tiff_buffer = tiff_buffer; 2722 - 2723 - return GGRAPH_OK; 2724 - 2725 - error: 2726 - if (out) 2727 - TIFFClose (out); 2728 - return GGRAPH_TIFF_CODEC_ERROR; 2729 -} 2730 - 2731 -static int 2732 -is_projected_srs (const char *proj4text) 2733 -{ 2734 -/* checks if this one is a PCS SRS */ 2735 - if (proj4text == NULL) 2736 - return 1; 2737 - if (strlen (proj4text) > 14) 2738 - { 2739 - if (strncmp (proj4text, "+proj=longlat ", 14) == 0) 2740 - return 0; 2741 - } 2742 - return 1; 2743 -} 2744 - 2745 -GGRAPH_PRIVATE int 2746 -gg_image_prepare_to_geotiff_by_strip (const gGraphStripImagePtr img, 2747 - const char *path, int layout, 2748 - int tile_width, int tile_height, 2749 - int rows_per_strip, int color_model, 2750 - int bits_per_sample, int sample_format, 2751 - int num_palette, unsigned char *red, 2752 - unsigned char *green, unsigned char *blue, 2753 - int compression) 2754 -{ 2755 -/* preparing to export a GeoTIFF [by meta-strips] */ 2756 - TIFF *out = (TIFF *) 0; 2757 - GTIF *gtif = (GTIF *) 0; 2758 - double tiepoint[6]; 2759 - double pixsize[3]; 2760 - uint16 r_plt[256]; 2761 - uint16 g_plt[256]; 2762 - uint16 b_plt[256]; 2763 - int i; 2764 - int tiff_type; 2765 - tsize_t buf_size; 2766 - void *tiff_buffer = NULL; 2767 - struct tiff_codec_data *tiff_codec = NULL; 2768 - 2769 -/* suppressing TIFF warnings */ 2770 - TIFFSetWarningHandler (NULL); 2771 - 2772 -/* writing to file */ 2773 - out = XTIFFOpen (path, "w"); 2774 - if (out == NULL) 2775 - goto error; 2776 - gtif = GTIFNew (out); 2777 - if (!gtif) 2778 - goto error; 2779 - 2780 -/* setting up the TIFF headers */ 2781 - TIFFSetField (out, TIFFTAG_SUBFILETYPE, 0); 2782 - TIFFSetField (out, TIFFTAG_IMAGEWIDTH, img->width); 2783 - TIFFSetField (out, TIFFTAG_IMAGELENGTH, img->height); 2784 - TIFFSetField (out, TIFFTAG_XRESOLUTION, 300.0); 2785 - TIFFSetField (out, TIFFTAG_YRESOLUTION, 300.0); 2786 - TIFFSetField (out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); 2787 - TIFFSetField (out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); 2788 - TIFFSetField (out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); 2789 - if (color_model == GGRAPH_COLORSPACE_PALETTE) 2790 - { 2791 - if (num_palette == 2) 2792 - { 2793 - if ((red[0] == 255 && green[0] == 255 && blue[0] == 255 2794 - && red[1] == 0 && green[1] == 0 && blue[1] == 0) 2795 - || (red[0] == 0 && green[0] == 0 && blue[0] == 0 2796 - && red[1] == 255 && green[1] == 255 && blue[1] == 255)) 2797 - { 2798 - /* MONOCHROME */ 2799 - tiff_type = TIFF_TYPE_MONOCHROME; 2800 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, 2801 - SAMPLEFORMAT_UINT); 2802 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 1); 2803 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, 1); 2804 - TIFFSetField (out, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); 2805 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, 2806 - PHOTOMETRIC_MINISWHITE); 2807 - if (compression == GGRAPH_TIFF_COMPRESSION_CCITTFAX3) 2808 - TIFFSetField (out, TIFFTAG_COMPRESSION, 2809 - COMPRESSION_CCITTFAX3); 2810 - else if (compression == GGRAPH_TIFF_COMPRESSION_CCITTFAX4) 2811 - TIFFSetField (out, TIFFTAG_COMPRESSION, 2812 - COMPRESSION_CCITTFAX4); 2813 - else 2814 - TIFFSetField (out, TIFFTAG_COMPRESSION, 2815 - COMPRESSION_NONE); 2816 - goto header_done; 2817 - } 2818 - } 2819 - /* PALETTE */ 2820 - tiff_type = TIFF_TYPE_PALETTE; 2821 - for (i = 0; i < img->max_palette; i++) 2822 - { 2823 - r_plt[i] = img->palette_red[i] * 256; 2824 - g_plt[i] = img->palette_green[i] * 256; 2825 - b_plt[i] = img->palette_blue[i] * 256; 2826 - } 2827 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); 2828 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 1); 2829 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, 8); 2830 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); 2831 - TIFFSetField (out, TIFFTAG_COLORMAP, r_plt, g_plt, b_plt); 2832 - if (compression == GGRAPH_TIFF_COMPRESSION_LZW) 2833 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); 2834 - else if (compression == GGRAPH_TIFF_COMPRESSION_DEFLATE) 2835 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); 2836 - else 2837 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); 2838 - } 2839 - if (color_model == GGRAPH_COLORSPACE_GRAYSCALE) 2840 - { 2841 - /* GRAYSCALE */ 2842 - tiff_type = TIFF_TYPE_GRAYSCALE; 2843 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); 2844 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 1); 2845 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, 8); 2846 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); 2847 - if (compression == GGRAPH_TIFF_COMPRESSION_LZW) 2848 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); 2849 - else if (compression == GGRAPH_TIFF_COMPRESSION_DEFLATE) 2850 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); 2851 - else if (compression == GGRAPH_TIFF_COMPRESSION_JPEG) 2852 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); 2853 - else 2854 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); 2855 - } 2856 - if (color_model == GGRAPH_COLORSPACE_TRUECOLOR 2857 - || color_model == GGRAPH_COLORSPACE_TRUECOLOR_ALPHA) 2858 - { 2859 - /* RGB */ 2860 - tiff_type = TIFF_TYPE_RGB; 2861 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); 2862 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 3); 2863 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, 8); 2864 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); 2865 - if (compression == GGRAPH_TIFF_COMPRESSION_LZW) 2866 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); 2867 - else if (compression == GGRAPH_TIFF_COMPRESSION_DEFLATE) 2868 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); 2869 - else if (compression == GGRAPH_TIFF_COMPRESSION_JPEG) 2870 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); 2871 - else 2872 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); 2873 - } 2874 - if (color_model == GGRAPH_COLORSPACE_GRID) 2875 - { 2876 - /* GRID data */ 2877 - 2878 - tiff_type = TIFF_TYPE_GRID; 2879 - if (sample_format == GGRAPH_SAMPLE_INT) 2880 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); 2881 - if (sample_format == GGRAPH_SAMPLE_UINT) 2882 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); 2883 - if (sample_format == GGRAPH_SAMPLE_FLOAT) 2884 - TIFFSetField (out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); 2885 - TIFFSetField (out, TIFFTAG_SAMPLESPERPIXEL, 1); 2886 - TIFFSetField (out, TIFFTAG_BITSPERSAMPLE, bits_per_sample); 2887 - TIFFSetField (out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); 2888 - if (compression == GGRAPH_TIFF_COMPRESSION_LZW) 2889 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); 2890 - else if (compression == GGRAPH_TIFF_COMPRESSION_DEFLATE) 2891 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); 2892 - else 2893 - TIFFSetField (out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); 2894 - } 2895 - 2896 - header_done: 2897 - TIFFSetField (out, TIFFTAG_SOFTWARE, "GaiaGraphics-tools"); 2898 - if (layout == GGRAPH_TIFF_LAYOUT_TILES) 2899 - { 2900 - TIFFSetField (out, TIFFTAG_TILEWIDTH, tile_width); 2901 - TIFFSetField (out, TIFFTAG_TILELENGTH, tile_height); 2902 - } 2903 - else 2904 - TIFFSetField (out, TIFFTAG_ROWSPERSTRIP, rows_per_strip); 2905 - 2906 -/* setting up the GeoTIFF Tags */ 2907 - pixsize[0] = img->pixel_x_size; 2908 - pixsize[1] = img->pixel_y_size; 2909 - pixsize[2] = 0.0; 2910 - TIFFSetField (out, GTIFF_PIXELSCALE, 3, pixsize); 2911 - tiepoint[0] = 0.0; 2912 - tiepoint[1] = 0.0; 2913 - tiepoint[2] = 0.0; 2914 - tiepoint[3] = img->upper_left_x; 2915 - tiepoint[4] = img->upper_left_y; 2916 - tiepoint[5] = 0.0; 2917 - TIFFSetField (out, GTIFF_TIEPOINTS, 6, tiepoint); 2918 - if (img->srs_name != NULL) 2919 - TIFFSetField (out, GTIFF_ASCIIPARAMS, img->srs_name); 2920 - if (img->proj4text != NULL) 2921 - GTIFSetFromProj4 (gtif, img->proj4text); 2922 - if (img->srs_name != NULL) 2923 - GTIFKeySet (gtif, GTCitationGeoKey, TYPE_ASCII, 0, img->srs_name); 2924 - if (is_projected_srs (img->proj4text)) 2925 - GTIFKeySet (gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1, img->srid); 2926 - GTIFWriteKeys (gtif); 2927 - 2928 -/* setting up the TIFF codec struct */ 2929 - tiff_codec = malloc (sizeof (struct tiff_codec_data)); 2930 - if (!tiff_codec) 2931 - goto error; 2932 - tiff_codec->is_geotiff = 0; 2933 - tiff_codec->is_writer = 1; 2934 - tiff_codec->tiff_handle = out; 2935 - tiff_codec->geotiff_handle = (GTIF *) 0; 2936 - tiff_codec->tiff_buffer = NULL; 2937 - if (layout == GGRAPH_TIFF_LAYOUT_TILES) 2938 - tiff_codec->is_tiled = 1; 2939 - else 2940 - tiff_codec->is_tiled = 0; 2941 - tiff_codec->tiff_type = tiff_type; 2942 - img->codec_data = tiff_codec; 2943 - 2944 -/* allocating the TIFF write buffer */ 2945 - if (img->pixel_format == GG_PIXEL_GRID) 2946 - { 2947 - if (tiff_codec->is_tiled) 2948 - buf_size = TIFFTileSize (out); 2949 - else 2950 - buf_size = TIFFScanlineSize (out); 2951 - } 2952 - else 2953 - { 2954 - if (tiff_codec->is_tiled) 2955 - buf_size = TIFFTileSize (out); 2956 - else 2957 - buf_size = TIFFScanlineSize (out); 2958 - } 2959 - tiff_buffer = malloc (buf_size); 2960 - if (!tiff_buffer) 2961 - goto error; 2962 - tiff_codec->tiff_buffer = tiff_buffer; 2963 - 2964 - return GGRAPH_OK; 2965 - 2966 - error: 2967 - if (gtif) 2968 - GTIFFree (gtif); 2969 - if (out) 2970 - XTIFFClose (out); 2971 - return GGRAPH_TIFF_CODEC_ERROR; 2972 -} 2973 - 2974 -static int 2975 -tiff_write_tile_grid (const gGraphStripImagePtr img) 2976 -{ 2977 -/* scanline(s) TIFF compression [tiles] GRID data */ 2978 - struct tiff_codec_data *tiff_codec = 2979 - (struct tiff_codec_data *) (img->codec_data); 2980 - TIFF *out = tiff_codec->tiff_handle; 2981 - int tile_width = img->tile_width; 2982 - int tile_height = img->tile_height; 2983 - int row; 2984 - int col; 2985 - void *tile = tiff_codec->tiff_buffer; 2986 - char *p_in_int8; 2987 - char *p_out_int8; 2988 - unsigned char *p_in_uint8; 2989 - unsigned char *p_out_uint8; 2990 - short *p_in_int16; 2991 - short *p_out_int16; 2992 - unsigned short *p_in_uint16; 2993 - unsigned short *p_out_uint16; 2994 - int *p_in_int32; 2995 - int *p_out_int32; 2996 - unsigned int *p_in_uint32; 2997 - unsigned int *p_out_uint32; 2998 - float *p_in_flt; 2999 - float *p_out_flt; 3000 - double *p_in_dbl; 3001 - double *p_out_dbl; 3002 - uint32 tile_x; 3003 - uint32 tile_y; 3004 - int num_rows; 3005 - int num_cols; 3006 - 3007 - tile_y = img->next_row; 3008 - if (tile_y + tile_height > (uint32) (img->height)) 3009 - num_rows = img->height - tile_y; 3010 - else 3011 - num_rows = tile_height; 3012 - if (num_rows != img->current_available_rows) 3013 - return GGRAPH_TIFF_CODEC_ERROR; 3014 - 3015 - for (tile_x = 0; tile_x < (uint32) (img->width); tile_x += tile_width) 3016 - { 3017 - /* feeding a tile */ 3018 - if (tile_x + tile_width > (uint32) (img->width)) 3019 - num_cols = img->width - tile_x; 3020 - else 3021 - num_cols = tile_width; 3022 - for (row = 0; row < num_rows; row++) 3023 - { 3024 - switch (img->sample_format) 3025 - { 3026 - case GGRAPH_SAMPLE_UINT: 3027 - switch (img->bits_per_sample) 3028 - { 3029 - case 8: 3030 - p_out_uint8 = tile; 3031 - p_out_uint8 += (row * tile_width); 3032 - p_in_uint8 = (unsigned char *) (img->pixels); 3033 - p_in_uint8 += (row * img->width) + tile_x; 3034 - break; 3035 - case 16: 3036 - p_out_uint16 = tile; 3037 - p_out_uint16 += (row * tile_width); 3038 - p_in_uint16 = (unsigned short *) (img->pixels); 3039 - p_in_uint16 += (row * img->width) + tile_x; 3040 - break; 3041 - case 32: 3042 - p_out_uint32 = tile; 3043 - p_out_uint32 += (row * tile_width); 3044 - p_in_uint32 = (unsigned int *) (img->pixels); 3045 - p_in_uint32 += (row * img->width) + tile_x; 3046 - break; 3047 - }; 3048 - break; 3049 - case GGRAPH_SAMPLE_INT: 3050 - switch (img->bits_per_sample) 3051 - { 3052 - case 8: 3053 - p_out_int8 = tile; 3054 - p_out_int8 += (row * tile_width); 3055 - p_in_int8 = (char *) (img->pixels); 3056 - p_in_int8 += (row * img->width) + tile_x; 3057 - break; 3058 - case 16: 3059 - p_out_int16 = tile; 3060 - p_out_int16 += (row * tile_width); 3061 - p_in_int16 = (short *) (img->pixels); 3062 - p_in_int16 += (row * img->width) + tile_x; 3063 - break; 3064 - case 32: 3065 - p_out_int32 = tile; 3066 - p_out_int32 += (row * tile_width); 3067 - p_in_int32 = (int *) (img->pixels); 3068 - p_in_int32 += (row * img->width) + tile_x; 3069 - break; 3070 - }; 3071 - break; 3072 - case GGRAPH_SAMPLE_FLOAT: 3073 - switch (img->bits_per_sample) 3074 - { 3075 - case 32: 3076 - p_out_flt = tile; 3077 - p_out_flt += (row * tile_width); 3078 - p_in_flt = (float *) (img->pixels); 3079 - p_in_flt += (row * img->width) + tile_x; 3080 - break; 3081 - case 64: 3082 - p_out_dbl = tile; 3083 - p_out_dbl += (row * tile_width); 3084 - p_in_dbl = (double *) (img->pixels); 3085 - p_in_dbl += (row * img->width) + tile_x; 3086 - break; 3087 - }; 3088 - break; 3089 - }; 3090 - for (col = 0; col < num_cols; col++) 3091 - { 3092 - switch (img->sample_format) 3093 - { 3094 - case GGRAPH_SAMPLE_UINT: 3095 - switch (img->bits_per_sample) 3096 - { 3097 - case 8: 3098 - *p_out_uint8++ = *p_in_uint8++; 3099 - break; 3100 - case 16: 3101 - *p_out_uint16++ = *p_in_uint16++; 3102 - break; 3103 - case 32: 3104 - *p_out_uint32++ = *p_in_uint32++; 3105 - break; 3106 - }; 3107 - break; 3108 - case GGRAPH_SAMPLE_INT: 3109 - switch (img->bits_per_sample) 3110 - { 3111 - case 8: 3112 - *p_out_int8++ = *p_in_int8++; 3113 - break; 3114 - case 16: 3115 - *p_out_int16++ = *p_in_int16++; 3116 - break; 3117 - case 32: 3118 - *p_out_int32++ = *p_in_int32++; 3119 - break; 3120 - }; 3121 - break; 3122 - case GGRAPH_SAMPLE_FLOAT: 3123 - switch (img->bits_per_sample) 3124 - { 3125 - case 32: 3126 - *p_out_flt++ = *p_in_flt++; 3127 - break; 3128 - case 16: 3129 - *p_out_dbl++ = *p_in_dbl++; 3130 - break; 3131 - }; 3132 - break; 3133 - }; 3134 - } 3135 - } 3136 - if (TIFFWriteTile (out, tile, tile_x, tile_y, 0, 0) < 0) 3137 - return GGRAPH_TIFF_CODEC_ERROR; 3138 - } 3139 - img->next_row += num_rows; 3140 - return GGRAPH_OK; 3141 -} 3142 - 3143 -static int 3144 -tiff_write_strip_grid (const gGraphStripImagePtr img) 3145 -{ 3146 -/* scanline(s) TIFF compression [strips] GRID data */ 3147 - struct tiff_codec_data *tiff_codec = 3148 - (struct tiff_codec_data *) (img->codec_data); 3149 - TIFF *out = tiff_codec->tiff_handle; 3150 - int row; 3151 - int col; 3152 - void *scanline = tiff_codec->tiff_buffer; 3153 - char *p_in_int8; 3154 - char *p_out_int8; 3155 - unsigned char *p_in_uint8; 3156 - unsigned char *p_out_uint8; 3157 - short *p_in_int16; 3158 - short *p_out_int16; 3159 - unsigned short *p_in_uint16; 3160 - unsigned short *p_out_uint16; 3161 - int *p_in_int32; 3162 - int *p_out_int32; 3163 - unsigned int *p_in_uint32; 3164 - unsigned int *p_out_uint32; 3165 - float *p_in_flt; 3166 - float *p_out_flt; 3167 - double *p_in_dbl; 3168 - double *p_out_dbl; 3169 - 3170 - for (row = 0; row < img->current_available_rows; row++) 3171 - { 3172 - switch (img->sample_format) 3173 - { 3174 - case GGRAPH_SAMPLE_UINT: 3175 - switch (img->bits_per_sample) 3176 - { 3177 - case 8: 3178 - p_in_uint8 = (unsigned char *) (img->pixels); 3179 - p_in_uint8 += row * img->width; 3180 - p_out_uint8 = scanline; 3181 - break; 3182 - case 16: 3183 - p_in_uint16 = (unsigned short *) (img->pixels); 3184 - p_in_uint16 += row * img->width; 3185 - p_out_uint16 = scanline; 3186 - break; 3187 - case 32: 3188 - p_in_uint32 = (unsigned int *) (img->pixels); 3189 - p_in_uint32 += row * img->width; 3190 - p_out_uint32 = scanline; 3191 - break; 3192 - }; 3193 - break; 3194 - case GGRAPH_SAMPLE_INT: 3195 - switch (img->bits_per_sample) 3196 - { 3197 - case 8: 3198 - p_in_int8 = (char *) (img->pixels); 3199 - p_in_int8 += row * img->width; 3200 - p_out_int8 = scanline; 3201 - break; 3202 - case 16: 3203 - p_in_int16 = (short *) (img->pixels); 3204 - p_in_int16 += row * img->width; 3205 - p_out_int16 = scanline; 3206 - break; 3207 - case 32: 3208 - p_in_int32 = (int *) (img->pixels); 3209 - p_in_int32 += row * img->width; 3210 - p_out_int32 = scanline; 3211 - break; 3212 - }; 3213 - break; 3214 - case GGRAPH_SAMPLE_FLOAT: 3215 - switch (img->bits_per_sample) 3216 - { 3217 - case 32: 3218 - p_in_flt = (float *) (img->pixels); 3219 - p_in_flt += row * img->width; 3220 - p_out_flt = scanline; 3221 - break; 3222 - case 64: 3223 - p_in_dbl = (double *) (img->pixels); 3224 - p_in_dbl += row * img->width; 3225 - p_out_dbl = scanline; 3226 - break; 3227 - }; 3228 - break; 3229 - }; 3230 - for (col = 0; col < img->width; col++) 3231 - { 3232 - switch (img->sample_format) 3233 - { 3234 - case GGRAPH_SAMPLE_UINT: 3235 - switch (img->bits_per_sample) 3236 - { 3237 - case 8: 3238 - *p_out_uint8++ = *p_in_uint8++; 3239 - break; 3240 - case 16: 3241 - *p_out_uint16++ = *p_in_uint16++; 3242 - break; 3243 - case 32: 3244 - *p_out_uint32++ = *p_in_uint32++; 3245 - break; 3246 - }; 3247 - break; 3248 - case GGRAPH_SAMPLE_INT: 3249 - switch (img->bits_per_sample) 3250 - { 3251 - case 8: 3252 - *p_out_int8++ = *p_in_int8++; 3253 - break; 3254 - case 16: 3255 - *p_out_int16++ = *p_in_int16++; 3256 - break; 3257 - case 32: 3258 - *p_out_int32++ = *p_in_int32++; 3259 - break; 3260 - }; 3261 - break; 3262 - case GGRAPH_SAMPLE_FLOAT: 3263 - switch (img->bits_per_sample) 3264 - { 3265 - case 32: 3266 - *p_out_flt++ = *p_in_flt++; 3267 - break; 3268 - case 16: 3269 - *p_out_dbl++ = *p_in_dbl++; 3270 - break; 3271 - }; 3272 - break; 3273 - }; 3274 - } 3275 - if (TIFFWriteScanline (out, scanline, img->next_row + row, 0) < 0) 3276 - return GGRAPH_TIFF_CODEC_ERROR; 3277 - } 3278 - img->next_row += img->current_available_rows; 3279 - return GGRAPH_OK; 3280 -} 3281 - 3282 -static int 3283 -tiff_write_tile_monochrome (const gGraphStripImagePtr img) 3284 -{ 3285 -/* scanline(s) TIFF compression [tiles] MONOCHROME */ 3286 - struct tiff_codec_data *tiff_codec = 3287 - (struct tiff_codec_data *) (img->codec_data); 3288 - TIFF *out = tiff_codec->tiff_handle; 3289 - int tile_width = img->tile_width; 3290 - int tile_height = img->tile_height; 3291 - int row; 3292 - int col; 3293 - int pixel; 3294 - unsigned char byte; 3295 - int pos; 3296 - unsigned char *tile = tiff_codec->tiff_buffer; 3297 - unsigned char *line_ptr; 3298 - uint32 tile_x; 3299 - uint32 tile_y; 3300 - int num_rows; 3301 - int num_cols; 3302 - tsize_t scan_bytes = TIFFTileSize (out) / tile_height; 3303 - 3304 - tile_y = img->next_row; 3305 - if (tile_y + tile_height > (uint32) (img->height)) 3306 - num_rows = img->height - tile_y; 3307 - else 3308 - num_rows = tile_height; 3309 - if (num_rows != img->current_available_rows) 3310 - return GGRAPH_TIFF_CODEC_ERROR; 3311 - 3312 - for (tile_x = 0; tile_x < (uint32) (img->width); tile_x += tile_width) 3313 - { 3314 - /* feeding a tile */ 3315 - if (tile_x + tile_width > (uint32) (img->width)) 3316 - num_cols = img->width - tile_x; 3317 - else 3318 - num_cols = tile_width; 3319 - for (row = 0; row < num_rows; row++) 3320 - { 3321 - unsigned char *p_in; 3322 - byte = 0x00; 3323 - pos = 0; 3324 - line_ptr = tile + (row * scan_bytes); 3325 - for (col = 0; col < num_cols; col++) 3326 - { 3327 - p_in = img->pixels + (row * img->scanline_width) + 3328 - ((tile_x + col) * img->pixel_size); 3329 - pixel = img->palette_red[*p_in]; /* expected to be a PALETTE image */ 3330 - if (pixel == 0) 3331 - { 3332 - /* handling a black pixel */ 3333 - switch (pos) 3334 - { 3335 - case 0: 3336 - byte |= 0x80; 3337 - break; 3338 - case 1: 3339 - byte |= 0x40; 3340 - break; 3341 - case 2: 3342 - byte |= 0x20; 3343 - break; 3344 - case 3: 3345 - byte |= 0x10; 3346 - break; 3347 - case 4: 3348 - byte |= 0x08; 3349 - break; 3350 - case 5: 3351 - byte |= 0x04; 3352 - break; 3353 - case 6: 3354 - byte |= 0x02; 3355 - break; 3356 - case 7: 3357 - byte |= 0x01; 3358 - break; 3359 - }; 3360 - } 3361 - pos++; 3362 - if (pos > 7) 3363 - { 3364 - /* exporting an octet */ 3365 - *line_ptr++ = byte; 3366 - byte = 0x00; 3367 - pos = 0; 3368 - } 3369 - } 3370 - if (pos > 0) /* exporting the last octet */ 3371 - *line_ptr++ = byte; 3372 - } 3373 - if (TIFFWriteTile (out, tile, tile_x, tile_y, 0, 0) < 0) 3374 - return GGRAPH_TIFF_CODEC_ERROR; 3375 - } 3376 - img->next_row += num_rows; 3377 - return GGRAPH_OK; 3378 -} 3379 - 3380 -static int 3381 -tiff_write_strip_monochrome (const gGraphStripImagePtr img) 3382 -{ 3383 -/* scanline(s) TIFF compression [strips] MONOCHROME */ 3384 - struct tiff_codec_data *tiff_codec = 3385 - (struct tiff_codec_data *) (img->codec_data); 3386 - TIFF *out = tiff_codec->tiff_handle; 3387 - int row; 3388 - int col; 3389 - int pixel; 3390 - unsigned char byte; 3391 - int pos; 3392 - unsigned char *scanline = tiff_codec->tiff_buffer; 3393 - unsigned char *line_ptr; 3394 - for (row = 0; row < img->current_available_rows; row++) 3395 - { 3396 - unsigned char *p_in = img->pixels + (row * img->scanline_width); 3397 - line_ptr = scanline; 3398 - for (col = 0; col < img->width; col++) 3399 - byte = 0x00; 3400 - pos = 0; 3401 - for (col = 0; col < img->width; col++) 3402 - { 3403 - pixel = img->palette_red[*p_in++]; /* expected to be a PALETTE image */ 3404 - if (pixel == 0) 3405 - { 3406 - /* handling a black pixel */ 3407 - switch (pos) 3408 - { 3409 - case 0: 3410 - byte |= 0x80; 3411 - break; 3412 - case 1: 3413 - byte |= 0x40; 3414 - break; 3415 - case 2: 3416 - byte |= 0x20; 3417 - break; 3418 - case 3: 3419 - byte |= 0x10; 3420 - break; 3421 - case 4: 3422 - byte |= 0x08; 3423 - break; 3424 - case 5: 3425 - byte |= 0x04; 3426 - break; 3427 - case 6: 3428 - byte |= 0x02; 3429 - break; 3430 - case 7: 3431 - byte |= 0x01; 3432 - break; 3433 - }; 3434 - } 3435 - pos++; 3436 - if (pos > 7) 3437 - { 3438 - /* exporting an octet */ 3439 - *line_ptr++ = byte; 3440 - byte = 0x00; 3441 - pos = 0; 3442 - } 3443 - } 3444 - if (pos > 0) /* exporting the last octet */ 3445 - *line_ptr++ = byte; 3446 - if (TIFFWriteScanline (out, scanline, img->next_row + row, 0) < 0) 3447 - return GGRAPH_TIFF_CODEC_ERROR; 3448 - } 3449 - img->next_row += img->current_available_rows; 3450 - return GGRAPH_OK; 3451 -} 3452 - 3453 -static int 3454 -tiff_write_tile_palette (const gGraphStripImagePtr img) 3455 -{ 3456 -/* scanline(s) TIFF compression [tiles] PALETTE */ 3457 - struct tiff_codec_data *tiff_codec = 3458 - (struct tiff_codec_data *) (img->codec_data); 3459 - TIFF *out = tiff_codec->tiff_handle; 3460 - int tile_width = img->tile_width; 3461 - int tile_height = img->tile_height; 3462 - int row; 3463 - int col; 3464 - unsigned char *tile = tiff_codec->tiff_buffer; 3465 - unsigned char *line_ptr; 3466 - uint32 tile_x; 3467 - uint32 tile_y; 3468 - int num_rows; 3469 - int num_cols; 3470 - 3471 - tile_y = img->next_row; 3472 - if (tile_y + tile_height > (uint32) (img->height)) 3473 - num_rows = img->height - tile_y; 3474 - else 3475 - num_rows = tile_height; 3476 - if (num_rows != img->current_available_rows) 3477 - return GGRAPH_TIFF_CODEC_ERROR; 3478 - 3479 - for (tile_x = 0; tile_x < (uint32) (img->width); tile_x += tile_width) 3480 - { 3481 - /* feeding a tile */ 3482 - if (tile_x + tile_width > (uint32) (img->width)) 3483 - num_cols = img->width - tile_x; 3484 - else 3485 - num_cols = tile_width; 3486 - for (row = 0; row < num_rows; row++) 3487 - { 3488 - unsigned char *p_in; 3489 - line_ptr = tile + (row * tile_width); 3490 - for (col = 0; col < num_cols; col++) 3491 - { 3492 - p_in = img->pixels + (row * img->scanline_width) + 3493 - ((tile_x + col) * img->pixel_size); 3494 - *line_ptr++ = *p_in++; /* expected to be a PALETTE image anyway */ 3495 - } 3496 - } 3497 - if (TIFFWriteTile (out, tile, tile_x, tile_y, 0, 0) < 0) 3498 - return GGRAPH_TIFF_CODEC_ERROR; 3499 - } 3500 - img->next_row += num_rows; 3501 - return GGRAPH_OK; 3502 -} 3503 - 3504 -static int 3505 -tiff_write_strip_palette (const gGraphStripImagePtr img) 3506 -{ 3507 -/* scanline(s) TIFF compression [strips] PALETTE */ 3508 - struct tiff_codec_data *tiff_codec = 3509 - (struct tiff_codec_data *) (img->codec_data); 3510 - TIFF *out = tiff_codec->tiff_handle; 3511 - int row; 3512 - int col; 3513 - unsigned char *scanline = tiff_codec->tiff_buffer; 3514 - unsigned char *line_ptr; 3515 - for (row = 0; row < img->current_available_rows; row++) 3516 - { 3517 - unsigned char *p_in = img->pixels + (row * img->scanline_width); 3518 - line_ptr = scanline; 3519 - for (col = 0; col < img->width; col++) 3520 - *line_ptr++ = *p_in++; /* expected to be a PALETTE image anyway */ 3521 - if (TIFFWriteScanline (out, scanline, img->next_row + row, 0) < 0) 3522 - return GGRAPH_TIFF_CODEC_ERROR; 3523 - } 3524 - img->next_row += img->current_available_rows; 3525 - return GGRAPH_OK; 3526 -} 3527 - 3528 -static int 3529 -tiff_write_tile_grayscale (const gGraphStripImagePtr img) 3530 -{ 3531 -/* scanline(s) TIFF compression [tiles] GRAYSCALE */ 3532 - struct tiff_codec_data *tiff_codec = 3533 - (struct tiff_codec_data *) (img->codec_data); 3534 - TIFF *out = tiff_codec->tiff_handle; 3535 - int tile_width = img->tile_width; 3536 - int tile_height = img->tile_height; 3537 - int row; 3538 - int col; 3539 - unsigned char *tile = tiff_codec->tiff_buffer; 3540 - unsigned char *line_ptr; 3541 - uint32 tile_x; 3542 - uint32 tile_y; 3543 - int num_rows; 3544 - int num_cols; 3545 - 3546 - tile_y = img->next_row; 3547 - if (tile_y + tile_height > (uint32) (img->height)) 3548 - num_rows = img->height - tile_y; 3549 - else 3550 - num_rows = tile_height; 3551 - if (num_rows != img->current_available_rows) 3552 - return GGRAPH_TIFF_CODEC_ERROR; 3553 - 3554 - for (tile_x = 0; tile_x < (uint32) (img->width); tile_x += tile_width) 3555 - { 3556 - /* feeding a tile */ 3557 - if (tile_x + tile_width > (uint32) (img->width)) 3558 - num_cols = img->width - tile_x; 3559 - else 3560 - num_cols = tile_width; 3561 - for (row = 0; row < num_rows; row++) 3562 - { 3563 - unsigned char *p_in; 3564 - line_ptr = tile + (row * tile_width); 3565 - for (col = 0; col < num_cols; col++) 3566 - { 3567 - p_in = img->pixels + (row * img->scanline_width) + 3568 - ((tile_x + col) * img->pixel_size); 3569 - *line_ptr++ = *p_in++; /* expected to be a GRAYSCALE image anyway */ 3570 - } 3571 - } 3572 - if (TIFFWriteTile (out, tile, tile_x, tile_y, 0, 0) < 0) 3573 - return GGRAPH_TIFF_CODEC_ERROR; 3574 - } 3575 - img->next_row += num_rows; 3576 - return GGRAPH_OK; 3577 -} 3578 - 3579 -static int 3580 -tiff_write_strip_grayscale (const gGraphStripImagePtr img) 3581 -{ 3582 -/* scanline(s) TIFF compression [strips] GRAYSCALE */ 3583 - struct tiff_codec_data *tiff_codec = 3584 - (struct tiff_codec_data *) (img->codec_data); 3585 - TIFF *out = tiff_codec->tiff_handle; 3586 - int row; 3587 - int col; 3588 - unsigned char *scanline = tiff_codec->tiff_buffer; 3589 - unsigned char *line_ptr; 3590 - 3591 - for (row = 0; row < img->current_available_rows; row++) 3592 - { 3593 - unsigned char *p_in = img->pixels + (row * img->scanline_width); 3594 - line_ptr = scanline; 3595 - for (col = 0; col < img->width; col++) 3596 - *line_ptr++ = *p_in++; /* expected to be a GRAYSCALE image anyway */ 3597 - if (TIFFWriteScanline (out, scanline, img->next_row + row, 0) < 0) 3598 - return GGRAPH_TIFF_CODEC_ERROR; 3599 - } 3600 - img->next_row += img->current_available_rows; 3601 - return GGRAPH_OK; 3602 -} 3603 - 3604 -static int 3605 -tiff_write_tile_rgb (const gGraphStripImagePtr img) 3606 -{ 3607 -/* scanline(s) TIFF compression [tiles] RGB */ 3608 - struct tiff_codec_data *tiff_codec = 3609 - (struct tiff_codec_data *) (img->codec_data); 3610 - TIFF *out = tiff_codec->tiff_handle; 3611 - int tile_width = img->tile_width; 3612 - int tile_height = img->tile_height; 3613 - int row; 3614 - int col; 3615 - unsigned char *tile = tiff_codec->tiff_buffer; 3616 - unsigned char *line_ptr; 3617 - uint32 tile_x; 3618 - uint32 tile_y; 3619 - int num_rows; 3620 - int num_cols; 3621 - 3622 - tile_y = img->next_row; 3623 - if (tile_y + tile_height > (uint32) (img->height)) 3624 - num_rows = img->height - tile_y; 3625 - else 3626 - num_rows = tile_height; 3627 - if (num_rows != img->current_available_rows) 3628 - return GGRAPH_TIFF_CODEC_ERROR; 3629 - 3630 - for (tile_x = 0; tile_x < (uint32) (img->width); tile_x += tile_width) 3631 - { 3632 - /* feeding a tile */ 3633 - if (tile_x + tile_width > (uint32) (img->width)) 3634 - num_cols = img->width - tile_x; 3635 - else 3636 - num_cols = tile_width; 3637 - for (row = 0; row < num_rows; row++) 3638 - { 3639 - unsigned char *p_in; 3640 - unsigned char r; 3641 - unsigned char g; 3642 - unsigned char b; 3643 - line_ptr = tile + (row * tile_width * 3); 3644 - for (col = 0; col < num_cols; col++) 3645 - { 3646 - p_in = 3647 - img->pixels + 3648 - (row * img->scanline_width) + 3649 - ((tile_x + col) * img->pixel_size); 3650 - if (img->pixel_format == GG_PIXEL_RGB) 3651 - { 3652 - r = *p_in++; 3653 - g = *p_in++; 3654 - b = *p_in++; 3655 - } 3656 - else if (img->pixel_format == GG_PIXEL_RGBA) 3657 - { 3658 - r = *p_in++; 3659 - g = *p_in++; 3660 - b = *p_in++; 3661 - p_in++; /* skipping Alpha */ 3662 - } 3663 - else if (img->pixel_format == GG_PIXEL_ARGB) 3664 - { 3665 - p_in++; /* skipping Alpha */ 3666 - r = *p_in++; 3667 - g = *p_in++; 3668 - b = *p_in++; 3669 - } 3670 - else if (img->pixel_format == GG_PIXEL_BGR) 3671 - { 3672 - b = *p_in++; 3673 - g = *p_in++; 3674 - r = *p_in++; 3675 - } 3676 - else if (img->pixel_format == GG_PIXEL_BGRA) 3677 - { 3678 - b = *p_in++; 3679 - g = *p_in++; 3680 - r = *p_in++; 3681 - p_in++; /* skipping Alpha */ 3682 - } 3683 - *line_ptr++ = r; 3684 - *line_ptr++ = g; 3685 - *line_ptr++ = b; 3686 - } 3687 - } 3688 - if (TIFFWriteTile (out, tile, tile_x, tile_y, 0, 0) < 0) 3689 - return GGRAPH_TIFF_CODEC_ERROR; 3690 - } 3691 - img->next_row += num_rows; 3692 - return GGRAPH_OK; 3693 -} 3694 - 3695 -static int 3696 -tiff_write_strip_rgb (const gGraphStripImagePtr img) 3697 -{ 3698 -/* scanline(s) TIFF compression [strips] RGB */ 3699 - struct tiff_codec_data *tiff_codec = 3700 - (struct tiff_codec_data *) (img->codec_data); 3701 - TIFF *out = tiff_codec->tiff_handle; 3702 - int row; 3703 - int col; 3704 - unsigned char *scanline = tiff_codec->tiff_buffer; 3705 - unsigned char *line_ptr; 3706 - 3707 - for (row = 0; row < img->current_available_rows; row++) 3708 - { 3709 - unsigned char *p_in = img->pixels + (row * img->scanline_width); 3710 - unsigned char r; 3711 - unsigned char g; 3712 - unsigned char b; 3713 - line_ptr = scanline; 3714 - for (col = 0; col < img->width; col++) 3715 - { 3716 - if (img->pixel_format == GG_PIXEL_RGB) 3717 - { 3718 - r = *p_in++; 3719 - g = *p_in++; 3720 - b = *p_in++; 3721 - } 3722 - else if (img->pixel_format == GG_PIXEL_RGBA) 3723 - { 3724 - r = *p_in++; 3725 - g = *p_in++; 3726 - b = *p_in++; 3727 - p_in++; /* skipping Alpha */ 3728 - } 3729 - else if (img->pixel_format == GG_PIXEL_ARGB) 3730 - { 3731 - p_in++; /* skipping Alpha */ 3732 - r = *p_in++; 3733 - g = *p_in++; 3734 - b = *p_in++; 3735 - } 3736 - else if (img->pixel_format == GG_PIXEL_BGR) 3737 - { 3738 - b = *p_in++; 3739 - g = *p_in++; 3740 - r = *p_in++; 3741 - } 3742 - else if (img->pixel_format == GG_PIXEL_BGRA) 3743 - { 3744 - b = *p_in++; 3745 - g = *p_in++; 3746 - r = *p_in++; 3747 - p_in++; 3748 - } 3749 - *line_ptr++ = r; 3750 - *line_ptr++ = g; 3751 - *line_ptr++ = b; 3752 - } 3753 - if (TIFFWriteScanline (out, scanline, img->next_row + row, 0) < 0) 3754 - return GGRAPH_TIFF_CODEC_ERROR; 3755 - } 3756 - img->next_row += img->current_available_rows; 3757 - return GGRAPH_OK; 3758 -} 3759 - 3760 -GGRAPH_PRIVATE int 3761 -gg_image_write_to_tiff_by_strip (const gGraphStripImagePtr img, int *progress) 3762 -{ 3763 -/* scanline(s) TIFF compression [by strip] */ 3764 - int ret; 3765 - struct tiff_codec_data *tiff_codec = 3766 - (struct tiff_codec_data *) (img->codec_data); 3767 - if (tiff_codec->tiff_type == TIFF_TYPE_RGB) 3768 - { 3769 - if (tiff_codec->is_tiled) 3770 - ret = tiff_write_tile_rgb (img); 3771 - else 3772 - ret = tiff_write_strip_rgb (img); 3773 - } 3774 - if (tiff_codec->tiff_type == TIFF_TYPE_GRAYSCALE) 3775 - { 3776 - if (tiff_codec->is_tiled) 3777 - ret = tiff_write_tile_grayscale (img); 3778 - else 3779 - ret = tiff_write_strip_grayscale (img); 3780 - } 3781 - if (tiff_codec->tiff_type == TIFF_TYPE_PALETTE) 3782 - { 3783 - if (tiff_codec->is_tiled) 3784 - ret = tiff_write_tile_palette (img); 3785 - else 3786 - ret = tiff_write_strip_palette (img); 3787 - } 3788 - if (tiff_codec->tiff_type == TIFF_TYPE_MONOCHROME) 3789 - { 3790 - if (tiff_codec->is_tiled) 3791 - ret = tiff_write_tile_monochrome (img); 3792 - else 3793 - ret = tiff_write_strip_monochrome (img); 3794 - } 3795 - if (tiff_codec->tiff_type == TIFF_TYPE_GRID) 3796 - { 3797 - if (tiff_codec->is_tiled) 3798 - ret = tiff_write_tile_grid (img); 3799 - else 3800 - ret = tiff_write_strip_grid (img); 3801 - } 3802 - if (ret == GGRAPH_OK && progress != NULL) 3803 - *progress = 3804 - (int) (((double) (img->next_row + 1) * 100.0) / 3805 - (double) (img->height)); 3806 - return ret; 3807 -}