ethumb - Thumbnailing Library

New library to generate thumbnails.
There are still some important features to be implemented, like
client-server framework, edje thumbnails and a plugin API to integrate
it with emotion and like.

Please, send comments.



SVN revision: 39805
This commit is contained in:
Rafael Antognolli 2009-03-30 21:22:52 +00:00
parent 81bdbba586
commit 258cfee990
32 changed files with 4691 additions and 0 deletions

1068
legacy/ethumb/ABOUT-NLS Normal file

File diff suppressed because it is too large Load Diff

1
legacy/ethumb/AUTHORS Normal file
View File

@ -0,0 +1 @@
Rafael Antognolli <antognolli@profusion.mobi>

7
legacy/ethumb/BUGS Normal file
View File

@ -0,0 +1,7 @@
Possible error when calculating edje frame size for thumbnails.
Since edje_object_size_min_calc() still doesn't retuns the actual edje object
size, it's possible that a part from the edje frame stay outside the picture.
This should be fixed soon, with a new call to get the current edje object size
or changing something on the API to tell ethumb that the frame has some border.
- antognolli, 30-03-2009

165
legacy/ethumb/COPYING Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

0
legacy/ethumb/ChangeLog Normal file
View File

236
legacy/ethumb/INSTALL Normal file
View File

@ -0,0 +1,236 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). Here is a another example:
/bin/bash ./configure CONFIG_SHELL=/bin/bash
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
configuration-related scripts to be executed by `/bin/bash'.
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

26
legacy/ethumb/Makefile.am Normal file
View File

@ -0,0 +1,26 @@
MAINTAINERCLEANFILES = \
Makefile.in \
aclocal.m4 \
compile \
config.guess \
config.h.in \
config.sub \
configure \
depcomp \
install-sh \
ltmain.sh \
missing
EXTRA_DIST = config.rpath \
m4/Makefile.in \
README \
AUTHORS \
COPYING
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \
ethumb.pc
SUBDIRS = m4 src data
ACLOCAL_AMFLAGS = -I m4

0
legacy/ethumb/NEWS Normal file
View File

0
legacy/ethumb/README Normal file
View File

14
legacy/ethumb/autogen.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
rm -rf autom4te.cache
rm -f aclocal.m4 ltmain.sh
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"
fi

View File

@ -0,0 +1,57 @@
AC_INIT(ethumb, 0.1, antognolli@profusion.mobi)
AC_PREREQ(2.52)
AC_CONFIG_SRCDIR(configure.ac)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_ISC_POSIX
AM_INIT_AUTOMAKE(1.6 dist-bzip2)
AM_CONFIG_HEADER(config.h)
AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
_XTERM_COLORS
AC_PROG_CC
AM_PROG_CC_STDC
AM_PROG_CC_C_O
AC_HEADER_STDC
dnl AC_C_CONST is bogus, its tests fails on -Wall -O1 ( uninitialized values)
dnl AC_C_CONST
define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
AC_PROG_LIBTOOL
VMAJ=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $1);}'`
VMIN=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $2);}'`
version_info=`expr $VMAJ + $VMIN`
AC_SUBST(version_info)
themesdir="${datadir}/ethumb/data/frames"
AC_SUBST(themesdir)
AS_AC_EXPAND(THEMESDIR, $themesdir)
AC_DEFINE_UNQUOTED(THEMESDIR, ["$THEMESDIR"], [Where frame theme files are installed.]
)
AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
AC_DEFINE_UNQUOTED(SYSCONFDIR, ["$SYSCONFDIR"], [Where system configuration is stored])
PKG_CHECK_MODULES(EINA, [eina-0])
PKG_CHECK_MODULES(EVAS, [evas])
PKG_CHECK_MODULES(ECORE, [ecore])
PKG_CHECK_MODULES(ECORE_EVAS, [ecore-evas])
PKG_CHECK_MODULES(ECORE_FILE, [ecore-file])
PKG_CHECK_MODULES(EDJE, [edje])
requirement_ethumb="eina-0 evas ecore ecore-evas ecore-file edje"
AC_SUBST(requirement_ethumb)
AC_OUTPUT([
ethumb.pc
Makefile
src/Makefile
src/bin/Makefile
src/lib/Makefile
data/Makefile
data/frames/Makefile
m4/Makefile
])

View File

@ -0,0 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = frames

View File

@ -0,0 +1,19 @@
MAINTAINERCLEANFILES = Makefile.in
EDJE_CC = edje_cc
EDJE_FLAGS = -v \
-id $(top_srcdir)/data/frames/images
filesdir = $(themesdir)
files_DATA = default.edj
EXTRA_DIST = \
default.edc
default.edj: Makefile $(EXTRADIST)
$(EDJE_CC) $(EDJE_FLAGS) \
$(top_srcdir)/data/frames/default.edc \
$(top_builddir)/data/frames/default.edj
clean-local:
rm -f *.edj

View File

@ -0,0 +1,46 @@
collections {
images {
image: "border-0.jpg" COMP;
}
group {
name: "frame/default";
parts {
part {
name: "img";
type: SWALLOW;
mouse_events: 0;
description {
state: "default" 0.0;
}
} // img
part {
name: "border";
type: IMAGE;
mouse_events: 0;
description {
state: "default" 0.0;
color: 224 224 224 255;
rel1 {
to: "img";
relative: 0.0 0.0;
offset: 0 0;
}
rel2 {
to: "img";
relative: 1.0 1.0;
offset: -1 -1;
}
image {
normal: "border-0.jpg";
border: 2 2 2 2;
middle: 0;
}
}
} // border
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: ethumb
Description: Thumbnail Generator Library
Requires: @requirement_ethumb@
Version: @VERSION@
Libs: -L${libdir} -lethumb
Cflags: -I${includedir}

View File

@ -0,0 +1,11 @@
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = gettext.m4 \
iconv.m4 \
lib-ld.m4 \
lib-link.m4 \
lib-prefix.m4 \
nls.m4 \
po.m4 \
progtest.m4 \
as-expand.m4 \
ac-modules.m4

View File

@ -0,0 +1,169 @@
dnl _XTERM_COLORS
define([_XTERM_COLORS],
[
# Check for XTerm and define some colors
if test "x$TERM" = "xxterm"; then
COLOR_PREF="\0033\0133"
COLOR_H="${COLOR_PREF}1m"
COLOR_HGREEN="${COLOR_PREF}1;32m"
COLOR_HRED="${COLOR_PREF}1;31m"
COLOR_GREEN="${COLOR_PREF}32m"
COLOR_RED="${COLOR_PREF}31m"
COLOR_YELLOW="${COLOR_PREF}1;33m"
COLOR_END="${COLOR_PREF}0m"
else
COLOR_H=""
COLOR_HGREEN=""
COLOR_HRED=""
COLOR_GREEN=""
COLOR_RED=""
COLOR_YELLOW=""
COLOR_END=""
fi
])
dnl AC_TCS_CHECK_PKG(name, lib [>= version], [action-if, [action-not]])
dnl improved version of PKG_CHECK_MODULES, it does the same checking
dnl and defines HAVE_[name]=yes/no and also exports
dnl [name]_CFLAGS and [name]_LIBS.
dnl
dnl if action-not isn't provided, AC_MSG_ERROR will be used.
dnl
dnl Checks:
dnl lib >= version
dnl
dnl Provides:
dnl - HAVE_[name]=yes|no
dnl - [name]_CFLAGS: if HAVE_[name]=yes
dnl - [name]_LIBS: if HAVE_[name]=yes
dnl - [name]_VERSION: if HAVE_[name]=yes
dnl
AC_DEFUN([AC_TCS_CHECK_PKG],
[
# ----------------------------------------------------------------------
# BEGIN: Check library with pkg-config: $1 (pkg-config=$2)
#
PKG_CHECK_MODULES([$1], [$2],
[
HAVE_[$1]=yes
[pkg_name]=$(echo "[$2]" | cut -d\ -f1)
[$1]_VERSION=$($PKG_CONFIG --modversion $pkg_name)
AC_SUBST([$1]_VERSION)
AC_SUBST([$1]_CFLAGS)
AC_SUBST([$1]_LIBS)
ifelse([$3], , :, [$3])
],
[
HAVE_[$1]=no
ifelse([$4], , AC_MSG_ERROR(you need [$2] development installed!), AC_MSG_RESULT(no); [$4])
])
AM_CONDITIONAL(HAVE_[$1], test x$HAVE_[$1] = xyes)
AC_SUBST(HAVE_[$1])
if test x$HAVE_[$1] = xyes; then
AC_DEFINE_UNQUOTED(HAVE_[$1], 1, Package [$1] ($2) found.)
fi
#
# END: Check library with pkg-config: $1 (pkg-config=$2)
# ----------------------------------------------------------------------
])
dnl AC_TCS_OPTIONAL_MODULE(name, [initial-status, [check-if-enabled]])
dnl Defines configure argument --<enable|disable>-[name] to enable an
dnl optional module called 'name'.
dnl
dnl If initial-status is true, then it's enabled by default and option
dnl will be called --disable-[name], otherwise it's disabled and option
dnl is --enable-[name].
dnl
dnl If module is enabled, then check-if-enabled will be executed. This
dnl may change the contents of shell variable NAME (uppercase version of
dnl name, with underscores instead of dashed) to something different than
dnl "true" to disable module.
dnl
dnl Parameters:
dnl - name: module name to use. It will be converted to have dashes (-)
dnl instead of underscores, and will be in lowercase.
dnl - initial-status: true or false, states if module is enabled or
dnl disabled by default.
dnl - check-if-enabled: macro to be expanded inside check for enabled
dnl module.
dnl
dnl Provides:
dnl - USE_MODULE_[name]=true|false [make, shell]
dnl - USE_MODULE_[name]=1 if enabled [config.h]
dnl
AC_DEFUN([AC_TCS_OPTIONAL_MODULE],
[
# ----------------------------------------------------------------------
# BEGIN: Check for optional module: $1 (default: $2)
#
m4_pushdef([MODNAME], [m4_bpatsubst(m4_toupper([$1]), -, _)])dnl
m4_pushdef([modname_opt], [m4_bpatsubst(m4_tolower([$1]), _, -)])
m4_pushdef([INITVAL], [m4_default([$2], [false])])dnl
m4_pushdef([ENABLE_HELP], AS_HELP_STRING([--enable-modname_opt],
[enable optional module modname_opt. Default is disabled.])
)dnl
m4_pushdef([DISABLE_HELP], AS_HELP_STRING([--disable-modname_opt],
[disable optional module modname_opt. Default is enabled.])
)dnl
m4_pushdef([HELP_STR], m4_if(INITVAL, [true], [DISABLE_HELP], [ENABLE_HELP]))dnl
m4_pushdef([NOT_INITVAL], m4_if(INITVAL, [true], [false], [true]))dnl
USING_MODULES=1
MODNAME=INITVAL
AC_ARG_ENABLE(modname_opt, HELP_STR, [MODNAME=${enableval:-NOT_INITVAL}])
if test x[$]MODNAME = xyes || test x[$]MODNAME = x1; then
MODNAME=true
fi
if test x[$]MODNAME = xno || test x[$]MODNAME = x0; then
MODNAME=false
fi
USE_MODULE_[]MODNAME=[$]MODNAME
_XTERM_COLORS
# Check list for optional module $1
if test x[$]MODNAME = xtrue; then
ifelse([$3], , , [
echo
echo "checking optional module modname_opt:"
# BEGIN: User checks
$3
# END: User checks
if test x[$]MODNAME = xfalse; then
echo -e "optional module modname_opt ${COLOR_HRED}failed${COLOR_END} checks."
else
echo -e "optional module modname_opt passed checks."
fi
echo
])
if test x[$]MODNAME = xfalse; then
echo -e "${COLOR_YELLOW}Warning:${COLOR_END} optional module ${COLOR_H}modname_opt${COLOR_END} disabled by extra checks."
fi
fi
# Check if user checks succeeded
if test x[$]MODNAME = xtrue; then
[OPTIONAL_MODULES]="$[OPTIONAL_MODULES] modname_opt"
AC_DEFINE_UNQUOTED(USE_MODULE_[]MODNAME, 1, Use module modname_opt)
else
[UNUSED_OPTIONAL_MODULES]="$[UNUSED_OPTIONAL_MODULES] modname_opt"
fi
AM_CONDITIONAL(USE_MODULE_[]MODNAME, test x[$]MODNAME = xtrue)
AC_SUBST(USE_MODULE_[]MODNAME)
m4_popdef([HELP_STR])dnl
m4_popdef([DISABLE_HELP])dnl
m4_popdef([ENABLE_HELP])dnl
m4_popdef([INITVAL])dnl
m4_popdef([MODNAME])
#
# END: Check for optional module: $1 ($2)
# ----------------------------------------------------------------------
])

View File

@ -0,0 +1,43 @@
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
dnl
dnl example
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
AC_DEFUN([AS_AC_EXPAND],
[
EXP_VAR=[$1]
FROM_VAR=[$2]
dnl first expand prefix and exec_prefix if necessary
prefix_save=$prefix
exec_prefix_save=$exec_prefix
dnl if no prefix given, then use /usr/local, the default prefix
if test "x$prefix" = "xNONE"; then
prefix=$ac_default_prefix
fi
dnl if no exec_prefix given, then use prefix
if test "x$exec_prefix" = "xNONE"; then
exec_prefix=$prefix
fi
full_var="$FROM_VAR"
dnl loop until it doesn't change anymore
while true; do
new_full_var="`eval echo $full_var`"
dnl if test "x$new_full_var" = "x$full_var"; then
if test "x${new_full_var:0:1}" != "x\$"; then
break;
fi
full_var=$new_full_var
done
dnl clean up
full_var=$new_full_var
AC_SUBST([$1], "$full_var")
dnl restore prefix and exec_prefix
prefix=$prefix_save
exec_prefix=$exec_prefix_save
])

180
legacy/ethumb/m4/iconv.m4 Normal file
View File

@ -0,0 +1,180 @@
# iconv.m4 serial AM6 (gettext-0.17)
dnl Copyright (C) 2000-2002, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
[
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([iconv])
])
AC_DEFUN([AM_ICONV_LINK],
[
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
dnl those with the standalone portable GNU libiconv installed).
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
dnl because if the user has installed libiconv and not disabled its use
dnl via --without-libiconv-prefix, he wants to use it. The first
dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
am_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
AC_CACHE_CHECK([for iconv], am_cv_func_iconv, [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_func_iconv=yes)
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_lib_iconv=yes
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
fi
])
if test "$am_cv_func_iconv" = yes; then
AC_CACHE_CHECK([for working iconv], am_cv_func_iconv_works, [
dnl This tests against bugs in AIX 5.1 and HP-UX 11.11.
am_save_LIBS="$LIBS"
if test $am_cv_lib_iconv = yes; then
LIBS="$LIBS $LIBICONV"
fi
AC_TRY_RUN([
#include <iconv.h>
#include <string.h>
int main ()
{
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
returns. */
{
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
if (cd_utf8_to_88591 != (iconv_t)(-1))
{
static const char input[] = "\342\202\254"; /* EURO SIGN */
char buf[10];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_utf8_to_88591,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
return 1;
}
}
#if 0 /* This bug could be worked around by the caller. */
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
{
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
if (cd_88591_to_utf8 != (iconv_t)(-1))
{
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
char buf[50];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_88591_to_utf8,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if ((int)res > 0)
return 1;
}
}
#endif
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
provided. */
if (/* Try standardized names. */
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
/* Try IRIX, OSF/1 names. */
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
/* Try AIX names. */
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
/* Try HP-UX names. */
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
return 1;
return 0;
}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
[case "$host_os" in
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
*) am_cv_func_iconv_works="guessing yes" ;;
esac])
LIBS="$am_save_LIBS"
])
case "$am_cv_func_iconv_works" in
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
*) am_func_iconv=yes ;;
esac
else
am_func_iconv=no am_cv_lib_iconv=no
fi
if test "$am_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1,
[Define if you have the iconv() function and it works.])
fi
if test "$am_cv_lib_iconv" = yes; then
AC_MSG_CHECKING([how to link with libiconv])
AC_MSG_RESULT([$LIBICONV])
else
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
dnl either.
CPPFLAGS="$am_save_CPPFLAGS"
LIBICONV=
LTLIBICONV=
fi
AC_SUBST(LIBICONV)
AC_SUBST(LTLIBICONV)
])
AC_DEFUN([AM_ICONV],
[
AM_ICONV_LINK
if test "$am_cv_func_iconv" = yes; then
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(am_cv_proto_iconv, [
AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:-
}[$]am_cv_proto_iconv)
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
[Define as const if the declaration of iconv() needs const.])
fi
])

110
legacy/ethumb/m4/lib-ld.m4 Normal file
View File

@ -0,0 +1,110 @@
# lib-ld.m4 serial 3 (gettext-0.13)
dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl Subroutines of libtool.m4,
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
dnl with libtool.m4.
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
AC_DEFUN([AC_LIB_PROG_LD_GNU],
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
case `$LD -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
acl_cv_prog_gnu_ld=yes ;;
*)
acl_cv_prog_gnu_ld=no ;;
esac])
with_gnu_ld=$acl_cv_prog_gnu_ld
])
dnl From libtool-1.4. Sets the variable LD.
AC_DEFUN([AC_LIB_PROG_LD],
[AC_ARG_WITH(gnu-ld,
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
# Prepare PATH_SEPARATOR.
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by GCC])
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case $ac_prog in
# Accept absolute paths.
[[\\/]* | [A-Za-z]:[\\/]*)]
[re_direlt='/[^/][^/]*/\.\./']
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(acl_cv_path_LD,
[if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH; do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
acl_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
*GNU* | *'with BFD'*)
test "$with_gnu_ld" != no && break ;;
*)
test "$with_gnu_ld" != yes && break ;;
esac
fi
done
IFS="$ac_save_ifs"
else
acl_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$acl_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_LIB_PROG_LD_GNU
])

View File

@ -0,0 +1,709 @@
# lib-link.m4 serial 13 (gettext-0.17)
dnl Copyright (C) 2001-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_PREREQ(2.54)
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
dnl augments the CPPFLAGS variable.
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
define([Name],[translit([$1],[./-], [___])])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
AC_LIB_LINKFLAGS_BODY([$1], [$2])
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
])
LIB[]NAME="$ac_cv_lib[]Name[]_libs"
LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
AC_SUBST([LIB]NAME[_PREFIX])
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
dnl results of this search when this library appears as a dependency.
HAVE_LIB[]NAME=yes
undefine([Name])
undefine([NAME])
])
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
dnl searches for libname and the libraries corresponding to explicit and
dnl implicit dependencies, together with the specified include files and
dnl the ability to compile and link the specified testcode. If found, it
dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
define([Name],[translit([$1],[./-], [___])])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([$1], [$2])
dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
dnl because if the user has installed lib[]Name and not disabled its use
dnl via --without-lib[]Name-prefix, he wants to use it.
ac_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
LIBS="$LIBS $LIB[]NAME"
AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
LIBS="$ac_save_LIBS"
])
if test "$ac_cv_lib[]Name" = yes; then
HAVE_LIB[]NAME=yes
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
AC_MSG_CHECKING([how to link with lib[]$1])
AC_MSG_RESULT([$LIB[]NAME])
else
HAVE_LIB[]NAME=no
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
dnl $INC[]NAME either.
CPPFLAGS="$ac_save_CPPFLAGS"
LIB[]NAME=
LTLIB[]NAME=
LIB[]NAME[]_PREFIX=
fi
AC_SUBST([HAVE_LIB]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
AC_SUBST([LIB]NAME[_PREFIX])
undefine([Name])
undefine([NAME])
])
dnl Determine the platform dependent parameters needed to use rpath:
dnl acl_libext,
dnl acl_shlibext,
dnl acl_hardcode_libdir_flag_spec,
dnl acl_hardcode_libdir_separator,
dnl acl_hardcode_direct,
dnl acl_hardcode_minus_L.
AC_DEFUN([AC_LIB_RPATH],
[
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
. ./conftest.sh
rm -f ./conftest.sh
acl_cv_rpath=done
])
wl="$acl_cv_wl"
acl_libext="$acl_cv_libext"
acl_shlibext="$acl_cv_shlibext"
acl_libname_spec="$acl_cv_libname_spec"
acl_library_names_spec="$acl_cv_library_names_spec"
acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
acl_hardcode_direct="$acl_cv_hardcode_direct"
acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
dnl Determine whether the user wants rpath handling at all.
AC_ARG_ENABLE(rpath,
[ --disable-rpath do not hardcode runtime library paths],
:, enable_rpath=yes)
])
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
[
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
dnl Autoconf >= 2.61 supports dots in --with options.
define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix],
[ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
--without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
fi
fi
])
dnl Search the library and its dependencies in $additional_libdir and
dnl $LDFLAGS. Using breadth-first-seach.
LIB[]NAME=
LTLIB[]NAME=
INC[]NAME=
LIB[]NAME[]_PREFIX=
rpathdirs=
ltrpathdirs=
names_already_handled=
names_next_round='$1 $2'
while test -n "$names_next_round"; do
names_this_round="$names_next_round"
names_next_round=
for name in $names_this_round; do
already_handled=
for n in $names_already_handled; do
if test "$n" = "$name"; then
already_handled=yes
break
fi
done
if test -z "$already_handled"; then
names_already_handled="$names_already_handled $name"
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
dnl or AC_LIB_HAVE_LINKFLAGS call.
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
eval value=\"\$HAVE_LIB$uppername\"
if test -n "$value"; then
if test "$value" = yes; then
eval value=\"\$LIB$uppername\"
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
eval value=\"\$LTLIB$uppername\"
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
else
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
dnl that this library doesn't exist. So just drop it.
:
fi
else
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
dnl and the already constructed $LIBNAME/$LTLIBNAME.
found_dir=
found_la=
found_so=
found_a=
eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
if test -n "$acl_shlibext"; then
shrext=".$acl_shlibext" # typically: shrext=.so
else
shrext=
fi
if test $use_additional = yes; then
dir="$additional_libdir"
dnl The same code as in the loop below:
dnl First look for a shared library.
if test -n "$acl_shlibext"; then
if test -f "$dir/$libname$shrext"; then
found_dir="$dir"
found_so="$dir/$libname$shrext"
else
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
ver=`(cd "$dir" && \
for f in "$libname$shrext".*; do echo "$f"; done \
| sed -e "s,^$libname$shrext\\\\.,," \
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
| sed 1q ) 2>/dev/null`
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
found_dir="$dir"
found_so="$dir/$libname$shrext.$ver"
fi
else
eval library_names=\"$acl_library_names_spec\"
for f in $library_names; do
if test -f "$dir/$f"; then
found_dir="$dir"
found_so="$dir/$f"
break
fi
done
fi
fi
fi
dnl Then look for a static library.
if test "X$found_dir" = "X"; then
if test -f "$dir/$libname.$acl_libext"; then
found_dir="$dir"
found_a="$dir/$libname.$acl_libext"
fi
fi
if test "X$found_dir" != "X"; then
if test -f "$dir/$libname.la"; then
found_la="$dir/$libname.la"
fi
fi
fi
if test "X$found_dir" = "X"; then
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
dnl First look for a shared library.
if test -n "$acl_shlibext"; then
if test -f "$dir/$libname$shrext"; then
found_dir="$dir"
found_so="$dir/$libname$shrext"
else
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
ver=`(cd "$dir" && \
for f in "$libname$shrext".*; do echo "$f"; done \
| sed -e "s,^$libname$shrext\\\\.,," \
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
| sed 1q ) 2>/dev/null`
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
found_dir="$dir"
found_so="$dir/$libname$shrext.$ver"
fi
else
eval library_names=\"$acl_library_names_spec\"
for f in $library_names; do
if test -f "$dir/$f"; then
found_dir="$dir"
found_so="$dir/$f"
break
fi
done
fi
fi
fi
dnl Then look for a static library.
if test "X$found_dir" = "X"; then
if test -f "$dir/$libname.$acl_libext"; then
found_dir="$dir"
found_a="$dir/$libname.$acl_libext"
fi
fi
if test "X$found_dir" != "X"; then
if test -f "$dir/$libname.la"; then
found_la="$dir/$libname.la"
fi
fi
;;
esac
if test "X$found_dir" != "X"; then
break
fi
done
fi
if test "X$found_dir" != "X"; then
dnl Found the library.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
if test "X$found_so" != "X"; then
dnl Linking with a shared library. We attempt to hardcode its
dnl directory into the executable's runpath, unless it's the
dnl standard /usr/lib.
if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
dnl No hardcoding is needed.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $found_dir"
fi
dnl The hardcoding into $LIBNAME is system dependent.
if test "$acl_hardcode_direct" = yes; then
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
dnl resulting binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $found_dir"
fi
else
dnl Rely on "-L$found_dir".
dnl But don't add it if it's already contained in the LDFLAGS
dnl or the already constructed $LIBNAME
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
fi
if test "$acl_hardcode_minus_L" != no; then
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
dnl here, because this doesn't fit in flags passed to the
dnl compiler. So give up. No hardcoding. This affects only
dnl very old systems.
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
fi
fi
fi
fi
else
if test "X$found_a" != "X"; then
dnl Linking with a static library.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
else
dnl We shouldn't come here, but anyway it's good to have a
dnl fallback.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
fi
fi
dnl Assume the include files are nearby.
additional_includedir=
case "$found_dir" in
*/$acl_libdirstem | */$acl_libdirstem/)
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
LIB[]NAME[]_PREFIX="$basedir"
additional_includedir="$basedir/include"
;;
esac
if test "X$additional_includedir" != "X"; then
dnl Potentially add $additional_includedir to $INCNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
dnl 3. if it's already present in $CPPFLAGS or the already
dnl constructed $INCNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
for x in $CPPFLAGS $INC[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $INCNAME.
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
fi
fi
fi
fi
fi
dnl Look for dependencies.
if test -n "$found_la"; then
dnl Read the .la file. It defines the variables
dnl dlname, library_names, old_library, dependency_libs, current,
dnl age, revision, installed, dlopen, dlpreopen, libdir.
save_libdir="$libdir"
case "$found_la" in
*/* | *\\*) . "$found_la" ;;
*) . "./$found_la" ;;
esac
libdir="$save_libdir"
dnl We use only dependency_libs.
for dep in $dependency_libs; do
case "$dep" in
-L*)
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
dnl 3. if it's already present in $LDFLAGS or the already
dnl constructed $LIBNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
haveit=
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LIBNAME.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
fi
fi
haveit=
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LTLIBNAME.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
fi
fi
fi
fi
;;
-R*)
dir=`echo "X$dep" | sed -e 's/^X-R//'`
if test "$enable_rpath" != no; then
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $dir"
fi
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $dir"
fi
fi
;;
-l*)
dnl Handle this in the next round.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
;;
*.la)
dnl Handle this in the next round. Throw away the .la's
dnl directory; it is already contained in a preceding -L
dnl option.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
;;
*)
dnl Most likely an immediate library name.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
;;
esac
done
fi
else
dnl Didn't find the library; assume it is in the system directories
dnl known to the linker and runtime loader. (All the system
dnl directories known to the linker should also be known to the
dnl runtime loader, otherwise the system is severely misconfigured.)
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
fi
fi
fi
done
done
if test "X$rpathdirs" != "X"; then
if test -n "$acl_hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user must
dnl pass all path elements in one option. We can arrange that for a
dnl single library, but not when more than one $LIBNAMEs are used.
alldirs=
for found_dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
done
dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
else
dnl The -rpath options are cumulative.
for found_dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$found_dir"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
done
fi
fi
if test "X$ltrpathdirs" != "X"; then
dnl When using libtool, the option that works for both libraries and
dnl executables is -R. The -R options are cumulative.
for found_dir in $ltrpathdirs; do
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
done
fi
])
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
dnl unless already present in VAR.
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
dnl contains two or three consecutive elements that belong together.
AC_DEFUN([AC_LIB_APPENDTOVAR],
[
for element in [$2]; do
haveit=
for x in $[$1]; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X$element"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
[$1]="${[$1]}${[$1]:+ }$element"
fi
done
])
dnl For those cases where a variable contains several -L and -l options
dnl referring to unknown libraries and directories, this macro determines the
dnl necessary additional linker options for the runtime path.
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
dnl otherwise linking without libtool is assumed.
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
[
AC_REQUIRE([AC_LIB_RPATH])
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
$1=
if test "$enable_rpath" != no; then
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode directories into the resulting
dnl binary.
rpathdirs=
next=
for opt in $2; do
if test -n "$next"; then
dir="$next"
dnl No need to hardcode the standard /usr/lib.
if test "X$dir" != "X/usr/$acl_libdirstem"; then
rpathdirs="$rpathdirs $dir"
fi
next=
else
case $opt in
-L) next=yes ;;
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
dnl No need to hardcode the standard /usr/lib.
if test "X$dir" != "X/usr/$acl_libdirstem"; then
rpathdirs="$rpathdirs $dir"
fi
next= ;;
*) next= ;;
esac
fi
done
if test "X$rpathdirs" != "X"; then
if test -n ""$3""; then
dnl libtool is used for linking. Use -R options.
for dir in $rpathdirs; do
$1="${$1}${$1:+ }-R$dir"
done
else
dnl The linker is used for linking directly.
if test -n "$acl_hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user
dnl must pass all path elements in one option.
alldirs=
for dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
done
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
$1="$flag"
else
dnl The -rpath options are cumulative.
for dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$dir"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
$1="${$1}${$1:+ }$flag"
done
fi
fi
fi
fi
fi
AC_SUBST([$1])
])

View File

@ -0,0 +1,185 @@
# lib-prefix.m4 serial 5 (gettext-0.15)
dnl Copyright (C) 2001-2005 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
dnl require excessive bracketing.
ifdef([AC_HELP_STRING],
[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
dnl to access previously installed libraries. The basic assumption is that
dnl a user will want packages to use other packages he previously installed
dnl with the same --prefix option.
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
dnl libraries, but is otherwise very convenient.
AC_DEFUN([AC_LIB_PREFIX],
[
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_LIB_ARG_WITH([lib-prefix],
[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
--without-lib-prefix don't search for libraries in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
fi
fi
])
if test $use_additional = yes; then
dnl Potentially add $additional_includedir to $CPPFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's already present in $CPPFLAGS,
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
for x in $CPPFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $CPPFLAGS.
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
fi
fi
fi
fi
dnl Potentially add $additional_libdir to $LDFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's already present in $LDFLAGS,
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
haveit=
for x in $LDFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LDFLAGS.
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
fi
fi
fi
fi
fi
])
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
dnl acl_final_exec_prefix, containing the values to which $prefix and
dnl $exec_prefix will expand at the end of the configure script.
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
[
dnl Unfortunately, prefix and exec_prefix get only finally determined
dnl at the end of configure.
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
else
acl_final_prefix="$prefix"
fi
if test "X$exec_prefix" = "XNONE"; then
acl_final_exec_prefix='${prefix}'
else
acl_final_exec_prefix="$exec_prefix"
fi
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
prefix="$acl_save_prefix"
])
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
dnl variables prefix and exec_prefix bound to the values they will have
dnl at the end of the configure script.
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
[
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
acl_save_exec_prefix="$exec_prefix"
exec_prefix="$acl_final_exec_prefix"
$1
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
])
dnl AC_LIB_PREPARE_MULTILIB creates a variable acl_libdirstem, containing
dnl the basename of the libdir, either "lib" or "lib64".
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
[
dnl There is no formal standard regarding lib and lib64. The current
dnl practice is that on a system supporting 32-bit and 64-bit instruction
dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit
dnl libraries go under $prefix/lib. We determine the compiler's default
dnl mode by looking at the compiler's library search path. If at least
dnl of its elements ends in /lib64 or points to a directory whose absolute
dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the
dnl default, namely "lib".
acl_libdirstem=lib
searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
if test -n "$searchpath"; then
acl_save_IFS="${IFS= }"; IFS=":"
for searchdir in $searchpath; do
if test -d "$searchdir"; then
case "$searchdir" in
*/lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
*) searchdir=`cd "$searchdir" && pwd`
case "$searchdir" in
*/lib64 ) acl_libdirstem=lib64 ;;
esac ;;
esac
fi
done
IFS="$acl_save_IFS"
fi
])

View File

@ -0,0 +1,92 @@
# progtest.m4 serial 4 (gettext-0.14.2)
dnl Copyright (C) 1996-2003, 2005 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Authors:
dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
AC_PREREQ(2.50)
# Search path for a program which passes the given test.
dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
AC_DEFUN([AM_PATH_PROG_WITH_TEST],
[
# Prepare PATH_SEPARATOR.
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
# Find out how to test for executable files. Don't use a zero-byte file,
# as systems may use methods other than mode bits to determine executability.
cat >conf$$.file <<_ASEOF
#! /bin/sh
exit 0
_ASEOF
chmod +x conf$$.file
if test -x conf$$.file >/dev/null 2>&1; then
ac_executable_p="test -x"
else
ac_executable_p="test -f"
fi
rm -f conf$$.file
# Extract the first word of "$2", so it can be a program name with args.
set dummy $2; ac_word=[$]2
AC_MSG_CHECKING([for $ac_word])
AC_CACHE_VAL(ac_cv_path_$1,
[case "[$]$1" in
[[\\/]]* | ?:[[\\/]]*)
ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
;;
*)
ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
for ac_dir in ifelse([$5], , $PATH, [$5]); do
IFS="$ac_save_IFS"
test -z "$ac_dir" && ac_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD
if [$3]; then
ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
break 2
fi
fi
done
done
IFS="$ac_save_IFS"
dnl If no 4th arg is given, leave the cache variable unset,
dnl so AC_PATH_PROGS will keep looking.
ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
])dnl
;;
esac])dnl
$1="$ac_cv_path_$1"
if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
AC_MSG_RESULT([$]$1)
else
AC_MSG_RESULT(no)
fi
AC_SUBST($1)dnl
])

View File

@ -0,0 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = lib bin

View File

@ -0,0 +1,15 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
@EINA_CFLAGS@ @EVAS_CFLAGS@ @ECORE_CFLAGS@ @ECORE_EVAS_CFLAGS@ \
@EDJE_CFLAGS@ @ECORE_FILE_CFLAGS@
bin_PROGRAMS = ethumb
ethumb_SOURCES = ethumb.c
ethumb_LDADD = \
@EINA_LIBS@ @EVAS_LIBS@ @ECORE_LIBS@ @ECORE_EVAS_LIBS@ @EDJE_LIBS@ \
@ECORE_FILE_LIBS@ \
$(top_builddir)/src/lib/libethumb.la
ethumb_DEPENDENCIES = $(top_builddir)/config.h

View File

@ -0,0 +1,359 @@
/**
* @file
*
* Copyright (C) 2009 by ProFUSION embedded systems
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* @author Rafael Antognolli <antognolli@profusion.mobi>
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <Ethumb.h>
#include <Eina.h>
static const char short_options[] = "s:f:a:d:c:t:h";
static const struct option long_options[] = {
{"size", 1, NULL, 's'},
{"format", 1, NULL, 'f'},
{"aspect", 1, NULL, 'a'},
{"directory", 1, NULL, 'd'},
{"category", 1, NULL, 'c'},
{"theme", 1, NULL, 't'},
{"help", 0, NULL, 'h'},
{NULL, 0, 0, 0}
};
static const char *help_texts[] = {
"size expected",
"file format to save",
"original image aspect ratio",
"directory to save thumbnails",
"thumbnails category",
"path to theme file, group and swallow part",
"this message",
NULL
};
static void
show_help(const char *prg_name)
{
const struct option *lo;
const char **help;
int largest;
fprintf(stderr,
"\nUsage:\n"
"\t%s [options] <image> [thumbnail path]\n"
"where options are:\n",
prg_name);
lo = long_options;
largest = 0;
for (; lo->name != NULL; lo++)
{
int len = strlen(lo->name) + 9;
if (lo->has_arg)
len += sizeof("=ARG") - 1;
if (largest < len)
largest = len;
}
lo = long_options;
help = help_texts;
for (; lo->name != NULL; lo++, help++)
{
int len, i;
fprintf(stderr, "\t-%c, --%s", lo->val, lo->name);
len = strlen(lo->name) + 7;
if (lo->has_arg)
{
fputs("=ARG", stderr);
len += sizeof("=ARG") - 1;
}
for (i = len; i < largest; i++)
fputc(' ', stderr);
fputs(" ", stderr);
fputs(*help, stderr);
fputc('\n', stderr);
}
fputc('\n', stderr);
}
static int
parse_size(const char *text, int *w, int *h)
{
const char *sep;
char *p;
sep = strchr(text, 'x');
if (!sep)
{
fprintf(stderr,
"ERROR: invalid size format, must be WIDTHxHEIGHT, got '%s'\n",
text);
return 0;
}
sep++;
*w = strtol(text, &p, 10);
if (text == p)
{
fprintf(stderr, "ERROR: could not parse size width '%s'\n", text);
return 0;
}
*h = strtol(sep, &p, 10);
if (sep == p)
{
fprintf(stderr, "ERROR: could not parse size height '%s'\n", text);
return 0;
}
return 1;
}
static int
parse_format(const char *text, int *f)
{
if (!strncmp(text, "png", 3))
*f = ETHUMB_THUMB_FDO;
else if (!strncmp(text, "jpg", 3))
*f = ETHUMB_THUMB_JPEG;
else
{
fprintf(stderr, "ERROR: invalid format specified: %s\n", text);
fprintf(stderr, "valid options: \"png\" and \"jpg\"\n");
return 0;
}
return 1;
}
static int
parse_aspect(const char *text, int *a)
{
if (!strncmp(text, "keep", sizeof("keep")))
*a = ETHUMB_THUMB_KEEP_ASPECT;
else if (!strncmp(text, "ignore", sizeof("ignore")))
*a = ETHUMB_THUMB_IGNORE_ASPECT;
else if (!strncmp(text, "crop", sizeof("crop")))
*a = ETHUMB_THUMB_CROP;
else
{
fprintf(stderr, "ERROR: invalid aspect option: %s\n", text);
fprintf(stderr, "valid options: \"keep\", \"ignore\" and \"crop\"\n");
return 0;
}
return 1;
}
static int
parse_theme(const char *text, const char **file, const char **group, const char **swallow)
{
char *sep;
const char *tfile, *tgroup, *tswallow;
tfile = NULL;
tgroup = NULL;
tswallow = NULL;
sep = strchr(text, ':');
if (!sep)
{
fprintf(stderr, "ERROR: invalid theme: %s\n"
"format: '<filename>:<group>:<swallow part>'\n",
text);
goto error;
}
*sep = '\0';
tfile = eina_stringshare_add(text);
sep++;
text = sep;
sep = strchr(text, ':');
if (!sep)
{
fprintf(stderr, "ERROR: invalid theme: %s\n"
"format: '<filename>:<group>:<swallow part>'\n",
text);
goto error;
}
*sep = '\0';
tgroup = eina_stringshare_add(text);
sep++;
tswallow = eina_stringshare_add(sep);
*file = tfile;
*group = tgroup;
*swallow = tswallow;
return 1;
error:
eina_stringshare_del(tfile);
return 0;
}
static int
parse_options(Ethumb *e, int argc, char *argv[])
{
int opt_index;
const char *size, *format, *aspect, *directory;
const char *category, *theme;
int r;
size = NULL;
format = NULL;
aspect = NULL;
directory = NULL;
category = NULL;
theme = NULL;
optind = 0;
opterr = 0;
opt_index = 0;
while (1)
{
int c;
c = getopt_long(argc, argv, short_options, long_options, &opt_index);
if (c == -1)
break;
switch (c)
{
case 's':
size = optarg;
break;
case 'f':
format = optarg;
break;
case 'a':
aspect = optarg;
break;
case 'd':
directory = optarg;
break;
case 'c':
category = optarg;
break;
case 't':
theme = optarg;
break;
default:
break;
}
}
if (size)
{
int w, h;
r = parse_size(size, &w, &h);
if (r)
ethumb_thumb_size_set(e, w, h);
else
return 0;
}
if (format)
{
int f;
r = parse_format(format, &f);
if (r)
ethumb_thumb_format_set(e, f);
else
return 0;
}
if (aspect)
{
int a;
r = parse_aspect(aspect, &a);
if (r)
ethumb_thumb_aspect_set(e, a);
else
return 0;
}
if (directory)
ethumb_thumb_dir_path_set(e, directory);
if (category)
ethumb_thumb_category_set(e, category);
if (theme)
{
const char *file, *group, *swallow;
r = parse_theme(theme, &file, &group, &swallow);
if (r)
{
ethumb_frame_set(e, file, group, swallow);
eina_stringshare_del(file);
eina_stringshare_del(group);
eina_stringshare_del(swallow);
}
else
return 0;
}
return 1;
}
int
main(int argc, char *argv[])
{
Ethumb *e;
Ethumb_File *ef;
int r;
ef = NULL;
ethumb_init();
e = ethumb_new();
r = parse_options(e, argc, argv);
if (r && optind < argc)
ef = ethumb_file_new(e, argv[optind++]);
if (ef && optind < argc)
ethumb_file_thumb_path_set(ef, argv[optind++]);
if (ef)
ethumb_file_generate(ef);
else
show_help(argv[0]);
ethumb_file_free(ef);
ethumb_free(e);
ethumb_shutdown();
return 0;
}

View File

@ -0,0 +1,731 @@
/**
* @file
*
* Copyright (C) 2009 by ProFUSION embedded systems
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* @author Rafael Antognolli <antognolli@profusion.mobi>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Ethumb.h"
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "md5.h"
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
#include <Ecore_File.h>
#include <Edje.h>
static int initcount = 0;
static const int THUMB_SIZE_NORMAL = 128;
static const int THUMB_SIZE_LARGE = 256;
EAPI int
ethumb_init(void)
{
if (initcount)
return ++initcount;
eina_stringshare_init();
evas_init();
ecore_init();
ecore_evas_init();
edje_init();
return ++initcount;
}
EAPI int
ethumb_shutdown(void)
{
initcount--;
if (initcount == 0)
{
eina_stringshare_shutdown();
eina_stringshare_init();
evas_init();
ecore_init();
ecore_evas_init();
edje_init();
}
return initcount;
}
EAPI Ethumb *
ethumb_new(void)
{
Ethumb *ethumb;
Ecore_Evas *ee, *sub_ee;
Evas *e, *sub_e;
Evas_Object *o, *img;
ethumb = calloc(1, sizeof(Ethumb));
if (!ethumb)
return NULL;
ethumb->tw = THUMB_SIZE_NORMAL;
ethumb->th = THUMB_SIZE_NORMAL;
ethumb->crop_x = 0.5;
ethumb->crop_y = 0.5;
ee = ecore_evas_buffer_new(1, 1);
e = ecore_evas_get(ee);
if (!e)
{
fputs("ERROR: could not create ecore evas buffer\n", stderr);
return NULL;
}
evas_image_cache_set(e, 0);
evas_font_cache_set(e, 0);
o = ecore_evas_object_image_new(ee);
if (!o)
{
fputs("ERROR: could not create sub ecore evas buffer\n", stderr);
ecore_evas_free(ee);
free(ethumb);
return NULL;
}
sub_ee = evas_object_data_get(o, "Ecore_Evas");
sub_e = ecore_evas_get(sub_ee);
evas_image_cache_set(sub_e, 0);
evas_font_cache_set(sub_e, 0);
img = evas_object_image_add(sub_e);
if (!img)
{
fputs("ERROR: could not create source objects.\n", stderr);
ecore_evas_free(ee);
free(ethumb);
return NULL;
}
ethumb->ee = ee;
ethumb->e = e;
ethumb->sub_ee = sub_ee;
ethumb->sub_e = sub_e;
ethumb->o = o;
ethumb->img = img;
return ethumb;
}
static void
_ethumb_frame_free(Ethumb_Frame *frame)
{
Evas_Object *o;
if (!frame)
return;
if (frame->swallow && frame->edje)
o = edje_object_part_swallow_get(frame->edje, frame->swallow);
if (o)
edje_object_part_unswallow(frame->edje, o);
eina_stringshare_del(frame->file);
eina_stringshare_del(frame->group);
eina_stringshare_del(frame->swallow);
if (frame->edje)
evas_object_del(frame->edje);
free(frame);
}
EAPI void
ethumb_free(Ethumb *ethumb)
{
if (!ethumb)
return;
if (ethumb->frame)
_ethumb_frame_free(ethumb->frame);
ecore_evas_free(ethumb->ee);
eina_stringshare_del(ethumb->thumb_dir);
eina_stringshare_del(ethumb->category);
free(ethumb);
}
EAPI void
ethumb_thumb_fdo_set(Ethumb *e, Ethumb_Thumb_Size s)
{
if (!e || (s != ETHUMB_THUMB_NORMAL && s != ETHUMB_THUMB_LARGE))
return;
if (s == ETHUMB_THUMB_NORMAL)
{
e->tw = THUMB_SIZE_NORMAL;
e->th = THUMB_SIZE_NORMAL;
}
else
{
e->tw = THUMB_SIZE_LARGE;
e->th = THUMB_SIZE_LARGE;
}
e->format = ETHUMB_THUMB_FDO;
e->aspect = ETHUMB_THUMB_KEEP_ASPECT;
_ethumb_frame_free(e->frame);
e->frame = NULL;
eina_stringshare_del(e->thumb_dir);
eina_stringshare_del(e->category);
e->thumb_dir = NULL;
e->category = NULL;
}
EAPI void
ethumb_thumb_size_set(Ethumb *e, int tw, int th)
{
if (e && tw > 0 && th > 0)
{
e->tw = tw;
e->th = th;
}
}
EAPI void
ethumb_thumb_size_get(const Ethumb *e, int *tw, int *th)
{
if (e)
{
*tw = e->tw;
*th = e->th;
}
}
EAPI void
ethumb_thumb_format_set(Ethumb *e, Ethumb_Thumb_Format f)
{
if (e && (f == ETHUMB_THUMB_FDO || f == ETHUMB_THUMB_JPEG))
e->format = f;
}
EAPI Ethumb_Thumb_Format
ethumb_thumb_format_get(const Ethumb *e)
{
if (e)
return e->format;
else
return 0;
}
EAPI void
ethumb_thumb_aspect_set(Ethumb *e, Ethumb_Thumb_Aspect a)
{
if (e && (a == ETHUMB_THUMB_KEEP_ASPECT || a == ETHUMB_THUMB_IGNORE_ASPECT
|| a == ETHUMB_THUMB_CROP))
e->aspect = a;
}
EAPI Ethumb_Thumb_Aspect
ethumb_thumb_aspect_get(const Ethumb *e)
{
if (e)
return e->aspect;
else
return 0;
}
EAPI void
ethumb_thumb_crop_align_set(Ethumb *e, float x, float y)
{
if (e)
{
e->crop_x = x;
e->crop_y = y;
}
}
EAPI void
ethumb_thumb_crop_align_get(Ethumb *e, float *x, float *y)
{
if (e)
{
*x = e->crop_x;
*y = e->crop_y;
}
}
EAPI int
ethumb_frame_set(Ethumb *e, const char *theme_file, const char *group, const char *swallow)
{
if (!e)
return 0;
Ethumb_Frame *frame;
frame = e->frame;
if (frame)
edje_object_part_unswallow(frame->edje, e->img);
else
{
frame = calloc(1, sizeof(Ethumb_Frame));
if (!frame)
{
fputs("ERROR: could not allocate Ethumb_Frame structure.\n",
stderr);
return 0;
}
frame->edje = edje_object_add(e->sub_e);
if (!frame->edje)
{
fputs("ERROR: could not create edje frame object.\n", stderr);
_ethumb_frame_free(frame);
return 0;
}
}
if (!edje_object_file_set(frame->edje, theme_file, group))
{
fputs("ERROR: could not load frame theme.\n", stderr);
_ethumb_frame_free(frame);
return 0;
}
edje_object_part_swallow(frame->edje, swallow, e->img);
if (!edje_object_part_swallow_get(frame->edje, swallow))
{
fputs("ERROR: could not swallow image to edje frame.\n", stderr);
_ethumb_frame_free(frame);
return 0;
}
theme_file = eina_stringshare_add(theme_file);
group = eina_stringshare_add(group);
swallow = eina_stringshare_add(swallow);
eina_stringshare_del(frame->file);
eina_stringshare_del(frame->group);
eina_stringshare_del(frame->swallow);
frame->file = theme_file;
frame->group = group;
frame->swallow = swallow;
e->frame = frame;
return 1;
}
EAPI void
ethumb_thumb_dir_path_set(Ethumb *e, const char *path)
{
if (!e)
return;
path = eina_stringshare_add(path);
eina_stringshare_del(e->thumb_dir);
e->thumb_dir = path;
}
EAPI const char *
ethumb_thumb_dir_path_get(Ethumb *e)
{
if (!e)
return NULL;
return e->thumb_dir;
}
EAPI void
ethumb_thumb_category_set(Ethumb *e, const char *category)
{
if (!e)
return;
category = eina_stringshare_add(category);
eina_stringshare_del(e->category);
e->category = category;
}
EAPI const char *
ethumb_thumb_category_get(Ethumb *e)
{
if (!e)
return NULL;
return e->category;
}
EAPI Ethumb_File *
ethumb_file_new(Ethumb *e, const char *path)
{
Ethumb_File *ef;
if (!e)
return NULL;
if (access(path, R_OK))
{
fprintf(stderr, "ERROR: couldn't access file \"%s\"\n", path);
return NULL;
}
ef = calloc(1, sizeof(Ethumb_File));
ef->ethumb = e;
ef->src_path = eina_stringshare_add(path);
return ef;
}
static const char *
_ethumb_generate_hash(const char *file)
{
int n;
MD5_CTX ctx;
char md5out[(2 * MD5_HASHBYTES) + 1];
unsigned char hash[MD5_HASHBYTES];
static const char hex[] = "0123456789abcdef";
char uri[PATH_MAX];
if (!file)
return NULL;
snprintf (uri, sizeof(uri), "file://%s", file);
MD5Init (&ctx);
MD5Update (&ctx, (unsigned char const*)uri, (unsigned)strlen (uri));
MD5Final (hash, &ctx);
for (n = 0; n < MD5_HASHBYTES; n++)
{
md5out[2 * n] = hex[hash[n] >> 4];
md5out[2 * n + 1] = hex[hash[n] & 0x0f];
}
md5out[2 * n] = '\0';
return eina_stringshare_add(md5out);
}
static int
_ethumb_file_check_fdo(Ethumb *e)
{
if (!((e->tw == THUMB_SIZE_NORMAL && e->th == THUMB_SIZE_NORMAL) ||
(e->tw == THUMB_SIZE_LARGE && e->th == THUMB_SIZE_LARGE)))
return 0;
if (e->format != ETHUMB_THUMB_FDO)
return 0;
if (e->aspect != ETHUMB_THUMB_KEEP_ASPECT)
return 0;
if (e->frame)
return 0;
return 1;
}
static const char *
_ethumb_file_generate_custom_category(Ethumb_File *ef)
{
char buf[PATH_MAX];
const char *aspect, *format;
const char *frame;
Ethumb *e = ef->ethumb;
if (e->aspect == ETHUMB_THUMB_KEEP_ASPECT)
aspect = eina_stringshare_add("keep_aspect");
else if (e->aspect == ETHUMB_THUMB_IGNORE_ASPECT)
aspect = eina_stringshare_add("ignore_aspect");
else
aspect = eina_stringshare_add("crop");
if (e->format == ETHUMB_THUMB_FDO)
format = eina_stringshare_add("png");
else
format = eina_stringshare_add("jpg");
if (e->frame)
frame = eina_stringshare_add("-framed");
else
frame = eina_stringshare_add("");
snprintf(buf, sizeof(buf), "%dx%d-%s%s-%s",
e->tw, e->th, aspect, frame, format);
eina_stringshare_del(aspect);
eina_stringshare_del(format);
eina_stringshare_del(frame);
return eina_stringshare_add(buf);
}
static void
_ethumb_file_generate_path(Ethumb_File *ef)
{
char buf[PATH_MAX];
char *fullname;
const char *hash;
const char *thumb_dir, *category;
const char *ext;
Ethumb *e;
int fdo_format;
e = ef->ethumb;
fdo_format = _ethumb_file_check_fdo(e);
if (e->thumb_dir)
thumb_dir = eina_stringshare_add(e->thumb_dir);
else
{
const char *home;
home = getenv("HOME");
snprintf(buf, sizeof(buf), "%s/.thumbnails", home);
thumb_dir = eina_stringshare_add(buf);
}
if (e->category)
category = eina_stringshare_add(e->category);
else if (!fdo_format)
category = _ethumb_file_generate_custom_category(ef);
else
{
if (e->tw == THUMB_SIZE_NORMAL)
category = eina_stringshare_add("normal");
else if (e->tw == THUMB_SIZE_LARGE)
category = eina_stringshare_add("large");
}
if (e->format == ETHUMB_THUMB_FDO)
ext = eina_stringshare_add("png");
else
ext = eina_stringshare_add("jpg");
fullname = ecore_file_realpath(ef->src_path);
hash = _ethumb_generate_hash(fullname);
snprintf(buf, sizeof(buf), "%s/%s/%s.%s", thumb_dir, category, hash, ext);
free(fullname);
if (ef->thumb_path)
eina_stringshare_del(ef->thumb_path);
ef->thumb_path = eina_stringshare_add(buf);
eina_stringshare_del(thumb_dir);
eina_stringshare_del(category);
eina_stringshare_del(ext);
eina_stringshare_del(hash);
}
EAPI void
ethumb_file_free(Ethumb_File *ef)
{
if (!ef)
return;
eina_stringshare_del(ef->src_path);
eina_stringshare_del(ef->thumb_path);
free(ef);
}
EAPI void
ethumb_file_thumb_path_set(Ethumb_File *ef, const char *path)
{
char *real_path;
char buf[PATH_MAX];
if (ef->thumb_path)
eina_stringshare_del(ef->thumb_path);
real_path = realpath(path, buf);
if (errno == ENOENT || errno == ENOTDIR || real_path)
ef->thumb_path = eina_stringshare_add(buf);
else
fprintf(stderr, "could not set thumbnail path: %s\n", strerror(errno));
}
EAPI const char *
ethumb_file_thumb_path_get(Ethumb_File *ef)
{
if (!ef->thumb_path)
_ethumb_file_generate_path(ef);
return ef->thumb_path;
}
static void
_ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h)
{
*w = e->tw;
*h = e->th;
if (e->aspect == ETHUMB_THUMB_KEEP_ASPECT)
{
if ((iw > ih && e->tw > 0) || e->th <= 0)
*h = (e->tw * ih) / iw;
else
*w = (e->th * iw) / ih;
}
}
static void
_ethumb_calculate_fill(Ethumb *e, int iw, int ih, int *fx, int *fy, int *fw, int *fh)
{
*fw = e->tw;
*fh = e->th;
*fx = 0;
*fy = 0;
if (e->aspect == ETHUMB_THUMB_CROP)
{
if ((iw > ih && e->tw > 0) || e->th <= 0)
*fw = (e->th * iw) / ih;
else
*fh = (e->tw * ih) / iw;
*fx = - e->crop_x * (*fw - iw);
*fy = - e->crop_y * (*fh - ih);
}
else if (e->aspect == ETHUMB_THUMB_KEEP_ASPECT)
{
if ((iw > ih && e->tw > 0) || e->th <= 0)
*fh = (e->tw * ih) / iw;
else
*fw = (e->th * iw) / ih;
}
}
static int
_ethumb_image_load(Ethumb_File *ef)
{
Ethumb *eth;
int error;
Evas_Coord w, h, ww, hh, fx, fy, fw, fh;
Evas_Object *img;
eth = ef->ethumb;
img = eth->img;
if (eth->frame)
evas_object_hide(eth->frame->edje);
else
evas_object_hide(img);
evas_object_image_file_set(img, NULL, NULL);
evas_object_image_load_size_set(img, eth->tw, eth->th);
evas_object_image_file_set(img, ef->src_path, NULL);
if (eth->frame)
evas_object_show(eth->frame->edje);
else
evas_object_show(img);
error = evas_object_image_load_error_get(img);
if (error != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "ERROR: could not load image '%s': %d\n",
ef->src_path, error);
return 0;
}
evas_object_image_size_get(img, &w, &h);
if ((w <= 0) || (h <= 0))
return 0;
_ethumb_calculate_aspect(eth, w, h, &ww, &hh);
if (eth->frame)
{
edje_extern_object_min_size_set(img, ww, hh);
edje_extern_object_max_size_set(img, ww, hh);
edje_object_calc_force(eth->frame->edje);
evas_object_move(eth->frame->edje, 0, 0);
evas_object_resize(eth->frame->edje, ww, hh);
}
else
{
evas_object_move(img, 0, 0);
evas_object_resize(img, ww, hh);
}
_ethumb_calculate_fill(eth, w, h, &fx, &fy, &fw, &fh);
evas_object_image_fill_set(img, fx, fy, fw, fh);
evas_object_image_size_set(eth->o, ww, hh);
ecore_evas_resize(eth->sub_ee, ww, hh);
evas_damage_rectangle_add(eth->sub_e, 0, 0, ww, hh);
ef->w = ww;
ef->h = hh;
return 1;
}
EAPI int
ethumb_file_generate(Ethumb_File *ef)
{
Ethumb *eth;
int r;
char *dname;
if (!ef)
return 0;
eth = ef->ethumb;
if (!_ethumb_image_load(ef))
{
fputs("ERROR: could not load input image.\n", stderr);
return 0;
}
evas_render(eth->sub_e);
if (!ef->thumb_path)
_ethumb_file_generate_path(ef);
if (!ef->thumb_path)
{
fputs("ERROR: could not create file path...\n", stderr);
return 0;
}
dname = ecore_file_dir_get(ef->thumb_path);
r = ecore_file_mkpath(dname);
free(dname);
if (!r)
{
fprintf(stderr, "ERROR: could not create directory '%s'\n", dname);
return 0;
}
r = evas_object_image_save(eth->o, ef->thumb_path, NULL, "quality=85");
if (!r)
{
fputs("ERROR: could not save image.\n", stderr);
return 0;
}
return 1;
}

View File

@ -0,0 +1,140 @@
#ifndef __ETHUMB_H__
#define __ETHUMB_H__ 1
#ifndef EAPI
#ifdef _WIN32
# ifdef EFL_EVAS_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# define GNUC_NULL_TERMINATED
# else
# define EAPI
# define GNUC_NULL_TERMINATED
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# define GNUC_NULL_TERMINATED
# endif /* ! EFL_EVAS_BUILD */
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# define GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define EAPI
# define GNUC_NULL_TERMINATED
# endif
# else
# define EAPI
# define GNUC_NULL_TERMINATED
# endif
#endif /* ! _WIN32 */
#endif /* EAPI */
#include <Ecore_Evas.h>
#include <Evas.h>
#ifdef __cplusplus
extern "C" {
#endif
enum _Ethumb_Thumb_Size
{
ETHUMB_THUMB_NORMAL,
ETHUMB_THUMB_LARGE
};
typedef enum _Ethumb_Thumb_Size Ethumb_Thumb_Size;
enum _Ethumb_Thumb_Format
{
ETHUMB_THUMB_FDO,
ETHUMB_THUMB_JPEG
};
typedef enum _Ethumb_Thumb_Format Ethumb_Thumb_Format;
enum _Ethumb_Thumb_Aspect
{
ETHUMB_THUMB_KEEP_ASPECT,
ETHUMB_THUMB_IGNORE_ASPECT,
ETHUMB_THUMB_CROP
};
typedef enum _Ethumb_Thumb_Aspect Ethumb_Thumb_Aspect;
struct _Ethumb_Frame
{
const char *file;
const char *group;
const char *swallow;
Evas_Object *edje;
};
typedef struct _Ethumb_Frame Ethumb_Frame;
struct _Ethumb
{
const char *thumb_dir;
const char *category;
int tw, th;
int format;
int aspect;
float crop_x, crop_y;
Ethumb_Frame *frame;
Ecore_Evas *ee, *sub_ee;
Evas *e, *sub_e;
Evas_Object *o, *img;
};
typedef struct _Ethumb Ethumb;
struct _Ethumb_File
{
Ethumb *ethumb;
const char *src_path;
const char *thumb_path;
int w, h;
};
typedef struct _Ethumb_File Ethumb_File;
EAPI int ethumb_init(void);
EAPI int ethumb_shutdown(void);
EAPI Ethumb * ethumb_new(void);
EAPI void ethumb_free(Ethumb *e);
EAPI void ethumb_thumb_fdo_set(Ethumb *e, Ethumb_Thumb_Size s);
EAPI void ethumb_thumb_size_set(Ethumb *e, int tw, int th);
EAPI void ethumb_thumb_size_get(const Ethumb *e, int *tw, int *th);
EAPI void ethumb_thumb_format_set(Ethumb *e, Ethumb_Thumb_Format f);
EAPI Ethumb_Thumb_Format ethumb_thumb_format_get(const Ethumb *e);
EAPI void ethumb_thumb_aspect_set(Ethumb *e, Ethumb_Thumb_Aspect a);
EAPI Ethumb_Thumb_Aspect ethumb_thumb_aspect_get(const Ethumb *e);
EAPI void ethumb_thumb_crop_align_set(Ethumb *e, float x, float y);
EAPI void ethumb_thumb_crop_align_get(Ethumb *e, float *x, float *y);
EAPI int ethumb_frame_set(Ethumb *e, const char *theme_file, const char *group, const char *swallow);
EAPI void ethumb_thumb_dir_path_set(Ethumb *e, const char *path);
EAPI const char * ethumb_thumb_dir_path_get(Ethumb *e);
EAPI void ethumb_thumb_category_set(Ethumb *e, const char *category);
EAPI const char * ethumb_thumb_category_get(Ethumb *e);
EAPI Ethumb_File * ethumb_file_new(Ethumb *e, const char *path);
EAPI void ethumb_file_free(Ethumb_File *ef);
EAPI void ethumb_file_thumb_path_set(Ethumb_File *ef, const char *path);
EAPI const char * ethumb_file_thumb_path_get(Ethumb_File *ef);
EAPI int ethumb_file_generate(Ethumb_File *ef);
#ifdef __cplusplus
}
#endif
#endif /* __ETHUMB_H__ */

View File

@ -0,0 +1,20 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
@EVAS_CFLAGS@ @ECORE_EVAS_CFLAGS@ @ECORE_FILE_CFLAGS@ @EDJE_CFLAGS@
include_HEADERS = Ethumb.h
noinst_HEADERS = md5.h
lib_LTLIBRARIES = libethumb.la
libethumb_la_SOURCES = \
Ethumb.c \
md5.c
libethumb_la_DEPENDENCIES = $(top_builddir)/config.h
libethumb_la_LIBADD = \
@EVAS_LIBS@ @ECORE_EVAS_LIBS@ @ECORE_FILE_LIBS@ @EDJE_LIBS@
libethumb_la_LDFLAGS = -version-info @version_info@

247
legacy/ethumb/src/lib/md5.c Normal file
View File

@ -0,0 +1,247 @@
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
#include <string.h> /* for memcpy() */
#include "md5.h"
#if (__BYTE_ORDER == 1234)
#define byteReverse(buf, len) /* Nothing */
#else
void byteReverse(unsigned char *buf, unsigned longs);
/*
* Note: this code is harmless on little-endian machines.
*/
void byteReverse(unsigned char *buf, unsigned longs)
{
uint32_t t;
do {
t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
((unsigned) buf[1] << 8 | buf[0]);
*(uint32_t *) buf = t;
buf += 4;
} while (--longs);
}
#endif
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
void MD5Init(MD5_CTX *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len)
{
uint32_t t;
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = (unsigned char *) ctx->in + t;
t = 64 - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
memcpy(ctx->in, buf, len);
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(unsigned char digest[16], MD5_CTX *ctx)
{
unsigned count;
unsigned char *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count - 8);
}
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
((uint32_t *) ctx->in)[14] = ctx->bits[0];
((uint32_t *) ctx->in)[15] = ctx->bits[1];
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset((char *) ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
/* The four core functions - F1 is optimized somewhat */
/* #define F1(x, y, z) (x & y | ~x & z) */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void MD5Transform(uint32_t buf[4], uint32_t const in[16])
{
register uint32_t a, b, c, d;
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}

View File

@ -0,0 +1,24 @@
#ifndef _MD5_H_
#define _MD5_H_
#include <stdint.h>
#include <sys/types.h>
#define MD5_HASHBYTES 16
typedef struct MD5Context {
uint32_t buf[4];
uint32_t bits[2];
unsigned char in[64];
} MD5_CTX;
extern void MD5Init(MD5_CTX *context);
extern void MD5Update(MD5_CTX *context,unsigned char const *buf,unsigned len);
extern void MD5Final(unsigned char digest[MD5_HASHBYTES], MD5_CTX *context);
extern void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
extern char *MD5End(MD5_CTX *, char *);
extern char *MD5File(const char *, char *);
extern char *MD5Data (const unsigned char *, unsigned int, char *);
#endif