From d0a9b9a03fc7ae74ef8a64593ac6b592526ec4d5 Mon Sep 17 00:00:00 2001 From: pp Date: Wed, 19 May 2004 04:59:31 +0000 Subject: - initial import git-svn-id: https://siedziba.pl:790/svn/repos/php-imlib/trunk@7 455248ca-bdda-0310-9134-f4ebb693071a --- .deps | 0 .libs/imlib.lai | 35 + .libs/imlib.so | Bin 0 -> 209651 bytes CHANGES | 69 + CREDITS | 25 + INSTALL | 75 + LICENSE | 75 + Makefile | 126 + Makefile.fragments | 0 Makefile.global | 82 + Makefile.objects | 8 + README | 78 + TODO | 1 + acinclude.m4 | 1847 +++ aclocal.m4 | 7708 +++++++++++++ autom4te-2.53.cache/output.0 | 8940 +++++++++++++++ autom4te-2.53.cache/requests | 94 + autom4te-2.53.cache/traces.0 | 172 + autom4te.cache/output.0 | 19730 +++++++++++++++++++++++++++++++++ autom4te.cache/requests | 111 + autom4te.cache/traces.0 | 249 + build/mkdep.awk | 75 + build/scan_makefile_in.awk | 32 + build/shtool | 1046 ++ config.guess | 1407 +++ config.h | 62 + config.h.in | 61 + config.log | 356 + config.m4 | 50 + config.nice | 8 + config.status | 611 + config.sub | 1504 +++ configure | 19730 +++++++++++++++++++++++++++++++++ configure.in | 116 + docs/api.txt | 442 + docs/class.ImlibCliprect.php | 132 + docs/class.ImlibColor.php | 94 + docs/class.ImlibColorRange.php | 141 + docs/class.ImlibDraw.php | 167 + docs/class.ImlibImage.php | 436 + docs/class.ImlibPoly.php | 190 + docs/class.ImlibText.php | 147 + docs/package.Imlib.php | 11 + examples/draw.php | 69 + examples/flip.php | 91 + examples/gradtest.php | 57 + examples/imlib_ext_filters.php | 17 + examples/imlib_filter.php | 58 + examples/pstext.php | 10 + examples/scale.php | 30 + examples/test.jpg | Bin 0 -> 16921 bytes examples/text.php | 17 + filters/Makefile.in | 18 + filters/autom4te.cache/output.0 | 3798 +++++++ filters/autom4te.cache/requests | 110 + filters/autom4te.cache/traces.0 | 91 + filters/config.h.in | 28 + filters/configure.ac | 27 + filters/php_bumpmap.c | 183 + filters/php_colormatrix.c | 450 + filters/php_colormod.c | 147 + filters/php_hsbcolor.c | 235 + filters/php_testfilter.c | 130 + include/php_php_imlib_filter_path.h | 1 + install-sh | 0 libs.mk | 7 + libtool | 6939 ++++++++++++ ltmain.sh | 6303 +++++++++++ missing | 0 mkinstalldirs | 0 modules/imlib.so | Bin 0 -> 209651 bytes php_imlib.c | 3210 ++++++ php_imlib.h | 211 + phpdoc/ImlibCliprect.html | 756 ++ phpdoc/ImlibColor.html | 562 + phpdoc/ImlibColorRange.html | 797 ++ phpdoc/ImlibDraw.html | 1110 ++ phpdoc/ImlibImage.html | 2254 ++++ phpdoc/ImlibPoly.html | 880 ++ phpdoc/ImlibText.html | 754 ++ phpdoc/frame_packagelist.html | 23 + phpdoc/packageelementlist_Imlib.html | 66 + phpdoc/phpdoc.css | 92 + phpdoc/phpdoc_classtree.html | 74 + phpdoc/phpdoc_elementlist.html | 884 ++ phpdoc/phpdoc_packagelist.html | 125 + phpdoc/phpdoc_warnings.html | 96 + phpdoc/phpdoc_xmlfiles.html | 63 + scan_makefile_in.awk | 32 + 89 files changed, 97048 insertions(+) create mode 100644 .deps create mode 100644 .libs/imlib.lai create mode 100755 .libs/imlib.so create mode 100644 CHANGES create mode 100644 CREDITS create mode 100644 INSTALL create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 Makefile.fragments create mode 100644 Makefile.global create mode 100644 Makefile.objects create mode 100644 README create mode 100644 TODO create mode 100644 acinclude.m4 create mode 100644 aclocal.m4 create mode 100644 autom4te-2.53.cache/output.0 create mode 100644 autom4te-2.53.cache/requests create mode 100644 autom4te-2.53.cache/traces.0 create mode 100644 autom4te.cache/output.0 create mode 100644 autom4te.cache/requests create mode 100644 autom4te.cache/traces.0 create mode 100644 build/mkdep.awk create mode 100755 build/scan_makefile_in.awk create mode 100755 build/shtool create mode 100755 config.guess create mode 100644 config.h create mode 100644 config.h.in create mode 100644 config.log create mode 100644 config.m4 create mode 100755 config.nice create mode 100755 config.status create mode 100755 config.sub create mode 100755 configure create mode 100644 configure.in create mode 100644 docs/api.txt create mode 100644 docs/class.ImlibCliprect.php create mode 100644 docs/class.ImlibColor.php create mode 100644 docs/class.ImlibColorRange.php create mode 100644 docs/class.ImlibDraw.php create mode 100644 docs/class.ImlibImage.php create mode 100644 docs/class.ImlibPoly.php create mode 100644 docs/class.ImlibText.php create mode 100644 docs/package.Imlib.php create mode 100644 examples/draw.php create mode 100644 examples/flip.php create mode 100644 examples/gradtest.php create mode 100644 examples/imlib_ext_filters.php create mode 100644 examples/imlib_filter.php create mode 100644 examples/pstext.php create mode 100644 examples/scale.php create mode 100644 examples/test.jpg create mode 100644 examples/text.php create mode 100644 filters/Makefile.in create mode 100644 filters/autom4te.cache/output.0 create mode 100644 filters/autom4te.cache/requests create mode 100644 filters/autom4te.cache/traces.0 create mode 100644 filters/config.h.in create mode 100644 filters/configure.ac create mode 100644 filters/php_bumpmap.c create mode 100644 filters/php_colormatrix.c create mode 100644 filters/php_colormod.c create mode 100644 filters/php_hsbcolor.c create mode 100644 filters/php_testfilter.c create mode 100644 include/php_php_imlib_filter_path.h create mode 100644 install-sh create mode 100644 libs.mk create mode 100755 libtool create mode 100755 ltmain.sh create mode 100644 missing create mode 100644 mkinstalldirs create mode 100755 modules/imlib.so create mode 100644 php_imlib.c create mode 100644 php_imlib.h create mode 100644 phpdoc/ImlibCliprect.html create mode 100644 phpdoc/ImlibColor.html create mode 100644 phpdoc/ImlibColorRange.html create mode 100644 phpdoc/ImlibDraw.html create mode 100644 phpdoc/ImlibImage.html create mode 100644 phpdoc/ImlibPoly.html create mode 100644 phpdoc/ImlibText.html create mode 100644 phpdoc/frame_packagelist.html create mode 100644 phpdoc/packageelementlist_Imlib.html create mode 100644 phpdoc/phpdoc.css create mode 100644 phpdoc/phpdoc_classtree.html create mode 100644 phpdoc/phpdoc_elementlist.html create mode 100644 phpdoc/phpdoc_packagelist.html create mode 100644 phpdoc/phpdoc_warnings.html create mode 100644 phpdoc/phpdoc_xmlfiles.html create mode 100644 scan_makefile_in.awk diff --git a/.deps b/.deps new file mode 100644 index 0000000..e69de29 diff --git a/.libs/imlib.lai b/.libs/imlib.lai new file mode 100644 index 0000000..3fbe07b --- /dev/null +++ b/.libs/imlib.lai @@ -0,0 +1,35 @@ +# imlib.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5 (1.1220 2003/04/05 19:32:58) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='imlib.so' + +# Names of this library. +library_names='imlib.so imlib.so imlib.so' + +# The name of the static archive. +old_library='' + +# Libraries that this one depends upon. +dependency_libs=' /usr/lib/libt1.la -L/usr/X11R6/lib /usr/X11R6/lib/libImlib2.la /usr/lib/libltdl.la /usr/lib/libttf.la -lm -ldl -lXext -lX11' + +# Version information for imlib. +current=0 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=yes + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/home/pp/php-imlib-0.4pre2/modules' diff --git a/.libs/imlib.so b/.libs/imlib.so new file mode 100755 index 0000000..03e30fd Binary files /dev/null and b/.libs/imlib.so differ diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..bcccaf3 --- /dev/null +++ b/CHANGES @@ -0,0 +1,69 @@ +2001-01-10 + + * Version 0.3 released + +2001-01-09 + + * imlib.c, php_imlib.h, docs/class.ImlibImage.php: Matt McClanahan + Added blur/sharpen support + +2001-01-07 + + * imlib.c: Steve Langasek + Implemented pass-by-ref arguments according to current standard. + +2000-12-26 + + * imlib.c, docs/class.ImlibImage.php: Matt McClanahan + Added image quality/compression setting to imlib_save_image and + imlib_dump_image + +2000-12-22 + + * imlib.c: Steve Langasek + include php_config.h explicitly. Module now works with PHP 4.0.4. + +2000-11-17 + + * imlib.c, php_imlib.h, docs/class.ColorRange.php: Matt McClanahan + Added Imlib_Color_Range support. + +2000-11-01 + + * Version 0.2 released + +2000-10-20 + + * docs/class.*.php: Matt McClanahan + Added a set of PHP classes that provide a nice OOP wrapper around + php_imlib's functions. + +2000-10-16 + + * imlib.c, php_imlib.h: Matt McClanahan + Added ImlibPolygon-related functions + +2000-10-15 + + * imlib.c: Matt McClanahan + Added optional param to all drawing routines: an array of (x,y,w,h) which + is used to define a cliprect to be used for that function call + +2000-10-09 + + * imlib.c, php_imlib.h: Matt McClanahan + Added _flip_ and _tile_ functions, which all use _php_imlib_single_arg() + +2000-10-08 + + * imlib.c, php_imlib.h: Matt McClanahan + Added _draw_rectangle, _draw_ellipse, and _draw_line + +2000-10-07 + + * imlib.c, php_imlib.h: Steve Langasek + Move resource type handles to static int's in imlib.c + +2000-10-05 + + * Version 0.1 released diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..52ed80d --- /dev/null +++ b/CREDITS @@ -0,0 +1,25 @@ +The Obligatory Credits File +=========================== + + +Contributors +------------ +Matt McClanahan +* Project maintainer + +Steve Langasek +* Feedback, debugging, patches +* Configurable font path, imlib_dump_image, other good stuff. + +Piotr Pawlow +* Filters, color modifiers, type 1 font support + +Thanks to +--------- +The Rasterman (Carsten Haitzler) +Mandrake (Geoff Harrison) +and all the folks in imlib2's AUTHORS file +* Imlib2 + +Tom Gilbert (gilbrit, giblet, grubby) +* feh, a great reference for how the heck you make Imlib2 work diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..a8c5308 --- /dev/null +++ b/INSTALL @@ -0,0 +1,75 @@ +PHP Imlib2 Extension (php_imlib) +================================ + +Dependency Libraries +-------------------- +Before building this extension, Imlib2 will need to be installed somewhere +on the system. Imlib2 itself depends on freetype for rendering text and the +relevant underlying image libraries for the desired image formats. At the +very least Imlib2 needs libpng and libjpeg. Lastly, Imlib2 needs a DB +loader, edb. + +Sources for these libraries can be found at: + +Imlib2, edb: http://download.sourceforge.net/enlightenment/ +freetype: http://freetype.sourceforge.net +libjpeg: http://www.ijg.org +libpng: http://www.libpng.org/pub/png/libpng.html + +You may want to look first on your distribution CD/FTP or http://rpmfind.net +for binary packages. Please note that you will also need -devel packages! + +Standalone Installation +----------------------- +To avoid recompiling PHP itself, build php_imlib as a self-contained +extension (imlib.so) and reference it via the extensions directive +in php.ini. Use of the dl() function is discouraged! + +tar -zxvf php_imlib-0.4pre1.tar.gz +cd imlib +phpize +./configure [--with-imlib=/path/to/Imlib2] [other args] +make +make install + + +Built-in Extension Installation +------------------------------- +To build php_imlib into PHP, extract the extension into the ext/ +subdirectory of the PHP source tree, run buildconf, and recompile. + +tar -C /path/to/php_src/ext -zxvf php_imlib-0.4pre1.tar.gz +cd /path/to/php_src +./buildconf +./configure --with-imlib[=/path/to/Imlib2] [other args] +make +make install + + +Configuration +------------- +The only relevant configuration parameter that php_imlib recognizes is +imlib.font_path, used to define which directories are automatically checked +for fonts. It can be set at a system or directory level, or if it isn't +defined, the default value is /usr/local/share/fonts. + +php.ini example: + +[Imlib] +imlib.font_path = /usr/local/share/fonts:/web/www.domain.com/fonts + +httpd.conf example: + +php_value imlib.font_path /web/www.domain.com/fonts + + +Troubleshooting +--------------- +* phpinfo() does not show any filters + - upgrade Imlib2 to version 1.0.5 or later +* PHP segfaults while trying to use filters + - try to apply this patch: + http://pp.siedziba.pl/PLD/imlib2-filters-bugfix.patch +* TGA loader does not work + - apply this patch: + http://pp.siedziba.pl/PLD/imlib2-loader_tga-bugfix.patch diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5f6658e --- /dev/null +++ b/LICENSE @@ -0,0 +1,75 @@ +-------------------------------------------------------------------- + The PHP License, version 2.02 +Copyright (c) 1999, 2000 The PHP Group. All rights reserved. +-------------------------------------------------------------------- + +Redistribution and use in source and binary forms, with or without +modification, is permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + 3. The name "PHP" must not be used to endorse or promote products + derived from this software without prior permission from the + PHP Group. This does not apply to add-on libraries or tools + that work in conjunction with PHP. In such a case the PHP + name may be used to indicate that the product supports PHP. + + 4. The PHP Group may publish revised and/or new versions of the + license from time to time. Each version will be given a + distinguishing version number. + Once covered code has been published under a particular version + of the license, you may always continue to use it under the + terms of that version. You may also choose to use such covered + code under the terms of any subsequent version of the license + published by the PHP Group. No one other than the PHP Group has + the right to modify the terms applicable to covered code created + under this License. + + 5. Redistributions of any form whatsoever must retain the following + acknowledgment: + "This product includes PHP, freely available from + http://www.php.net/". + + 6. The software incorporates the Zend Engine, a product of Zend + Technologies, Ltd. ("Zend"). The Zend Engine is licensed to the + PHP Association (pursuant to a grant from Zend that can be + found at http://www.php.net/license/ZendGrant/) for + distribution to you under this license agreement, only as a + part of PHP. In the event that you separate the Zend Engine + (or any portion thereof) from the rest of the software, or + modify the Zend Engine, or any portion thereof, your use of the + separated or modified Zend Engine software shall not be governed + by this license, and instead shall be governed by the license + set forth at http://www.zend.com/license/ZendLicense/. + + + +THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND +ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP +DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------- + +This software consists of voluntary contributions made by many +individuals on behalf of the PHP Group. + +The PHP Group can be contacted via Email at group@php.net. + +For more information on the PHP Group and the PHP project, +please see . diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c38e990 --- /dev/null +++ b/Makefile @@ -0,0 +1,126 @@ +srcdir = /home/pp/php-imlib-0.4pre2 +builddir = /home/pp/php-imlib-0.4pre2 +top_srcdir = /home/pp/php-imlib-0.4pre2 +top_builddir = /home/pp/php-imlib-0.4pre2 +SHLIB_SUFFIX_NAME = so +IMLIB_SHARED_LIBADD = -lt1 -Wl,-rpath,/usr/X11R6/lib -L/usr/X11R6/lib -Wl,-rpath,/usr/X11R6/lib -L/usr/X11R6/lib -lImlib2 -lttf -lm -ldl -lXext -lXext -lX11 +shared_objects_imlib = php_imlib.lo +PHP_MODULES = $(phplibdir)/imlib.la +all_targets = $(PHP_MODULES) +install_targets = install-modules +prefix = /usr +exec_prefix = $(prefix) +libdir = ${exec_prefix}/lib +prefix = /usr +phplibdir = /home/pp/php-imlib-0.4pre2/modules +PHP_COMPILE = +CC = gcc +CFLAGS = -g -O2 +CFLAGS_CLEAN = $(CFLAGS) +CPP = gcc -E +CPPFLAGS = -DPHP_IMLIB_FILTER_PATH="\"/usr/lib/php/php_imlib_filters\"" -DHAVE_CONFIG_H +CXX = g++ +DEFS = +EXTENSION_DIR = /usr/lib/php +EXTRA_LDFLAGS = +EXTRA_LIBS = +INCLUDES = -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/Zend -I/usr/include/php/TSRM -I/usr/X11R6/include +LEX = +LEX_OUTPUT_ROOT = +LFLAGS = +LDFLAGS = -lm +SHARED_LIBTOOL = +LIBTOOL = $(SHELL) $(top_builddir)/libtool +SHELL = /bin/sh +AWK = awk +RE2C = exit 0; +mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p +INSTALL = $(top_srcdir)/build/shtool install -c +INSTALL_DATA = $(INSTALL) -m 644 + +DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir) +COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH) + + +all: $(all_targets) + @echo + @echo "Build complete." + @echo "(It is safe to ignore warnings about tempnam and tmpnam)." + @echo + +build-modules: $(PHP_MODULES) + +libphp_common.la: $(PHP_GLOBAL_OBJS) + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) -avoid-version $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ -release $(PHP_VERSION) + +libphp4.la: libphp_common.la $(PHP_SAPI_OBJS) + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) libphp_common.la $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ + +libs/libphp4.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) + $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp4.so + +install: $(all_targets) $(install_targets) + +install-sapi: $(OVERALL_TARGET) + @echo "Installing PHP SAPI module: $(PHP_SAPI)" + -@$(LIBTOOL) --silent --mode=install cp libphp_common.la $(phptempdir)/libphp_common.la >/dev/null 2>&1 + -@$(LIBTOOL) --silent --mode=install cp libphp4.la $(phptempdir)/libphp4.la >/dev/null 2>&1 + -@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) + -@if test ! -r $(phptempdir)/libphp_common.$(SHLIB_SUFFIX_NAME); then \ + for i in 0.0.0 0.0 0; do \ + if test -r $(phptempdir)/libphp_common.$(SHLIB_SUFFIX_NAME).$$i; then \ + $(LN_S) $(phptempdir)/libphp_common.$(SHLIB_SUFFIX_NAME).$$i $(phptempdir)/libphp_common.$(SHLIB_SUFFIX_NAME); \ + break; \ + fi; \ + done; \ + fi + @$(INSTALL_IT) + +install-modules: build-modules + @test -d modules && \ + $(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR) && \ + echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/" && \ + rm -f modules/*.la && \ + $(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR) >/dev/null 2>&1 || true + +install-tester: + @echo "Installing regression tester: $(INSTALL_ROOT)$(PEAR_INSTALLDIR)/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(PEAR_INSTALLDIR) + @$(INSTALL) -m 755 $(top_srcdir)/run-tests.php $(INSTALL_ROOT)$(PEAR_INSTALLDIR) + +install-su: install-pear install-tester + +test: + -@if test -x $(SAPI_CLI_PATH) && test ! -z $(SAPI_CLI_PATH); then \ + TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \ + TEST_PHP_SRCDIR=$(top_srcdir) \ + CC="$(CC)" \ + $(top_builddir)/$(SAPI_CLI_PATH) -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' $(top_srcdir)/run-tests.php $(TESTS); \ + else \ + echo "ERROR: Cannot run tests without CLI sapi."; \ + fi + +clean: + find . -name \*.lo | xargs rm -f + find . -name \*.o | xargs rm -f + find . -name \*.la | xargs rm -f + find . -name \*.a | xargs rm -f + find . -name \*.so | xargs rm -f + find . -name .libs -a -type d|xargs rm -rf + rm -f libphp4.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/* + +distclean: clean + rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php4.spec sapi/apache/libphp4.module buildmk.stamp + egrep define'.*include/php' configure|sed 's/.*>//'|xargs rm -f + find . -name Makefile | xargs rm -f + +.PHONY: all clean install distclean test +.NOEXPORT: +php_imlib.lo: /home/pp/php-imlib-0.4pre2/php_imlib.c + $(LIBTOOL) --mode=compile $(CC) -I. -I/home/pp/php-imlib-0.4pre2 $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -prefer-pic -c /home/pp/php-imlib-0.4pre2/php_imlib.c -o php_imlib.lo +$(phplibdir)/imlib.la: ./imlib.la + $(LIBTOOL) --mode=install cp ./imlib.la $(phplibdir) + +./imlib.la: $(shared_objects_imlib) $(IMLIB_SHARED_DEPENDENCIES) + $(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_imlib) $(IMLIB_SHARED_LIBADD) + diff --git a/Makefile.fragments b/Makefile.fragments new file mode 100644 index 0000000..e69de29 diff --git a/Makefile.global b/Makefile.global new file mode 100644 index 0000000..df6d109 --- /dev/null +++ b/Makefile.global @@ -0,0 +1,82 @@ +mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p +INSTALL = $(top_srcdir)/build/shtool install -c +INSTALL_DATA = $(INSTALL) -m 644 + +DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir) +COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH) + + +all: $(all_targets) + @echo + @echo "Build complete." + @echo "(It is safe to ignore warnings about tempnam and tmpnam)." + @echo + +build-modules: $(PHP_MODULES) + +libphp_common.la: $(PHP_GLOBAL_OBJS) + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) -avoid-version $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ -release $(PHP_VERSION) + +libphp4.la: libphp_common.la $(PHP_SAPI_OBJS) + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) libphp_common.la $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ + +libs/libphp4.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) + $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp4.so + +install: $(all_targets) $(install_targets) + +install-sapi: $(OVERALL_TARGET) + @echo "Installing PHP SAPI module: $(PHP_SAPI)" + -@$(LIBTOOL) --silent --mode=install cp libphp_common.la $(phptempdir)/libphp_common.la >/dev/null 2>&1 + -@$(LIBTOOL) --silent --mode=install cp libphp4.la $(phptempdir)/libphp4.la >/dev/null 2>&1 + -@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) + -@if test ! -r $(phptempdir)/libphp_common.$(SHLIB_SUFFIX_NAME); then \ + for i in 0.0.0 0.0 0; do \ + if test -r $(phptempdir)/libphp_common.$(SHLIB_SUFFIX_NAME).$$i; then \ + $(LN_S) $(phptempdir)/libphp_common.$(SHLIB_SUFFIX_NAME).$$i $(phptempdir)/libphp_common.$(SHLIB_SUFFIX_NAME); \ + break; \ + fi; \ + done; \ + fi + @$(INSTALL_IT) + +install-modules: build-modules + @test -d modules && \ + $(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR) && \ + echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/" && \ + rm -f modules/*.la && \ + $(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR) >/dev/null 2>&1 || true + +install-tester: + @echo "Installing regression tester: $(INSTALL_ROOT)$(PEAR_INSTALLDIR)/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(PEAR_INSTALLDIR) + @$(INSTALL) -m 755 $(top_srcdir)/run-tests.php $(INSTALL_ROOT)$(PEAR_INSTALLDIR) + +install-su: install-pear install-tester + +test: + -@if test -x $(SAPI_CLI_PATH) && test ! -z $(SAPI_CLI_PATH); then \ + TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \ + TEST_PHP_SRCDIR=$(top_srcdir) \ + CC="$(CC)" \ + $(top_builddir)/$(SAPI_CLI_PATH) -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' $(top_srcdir)/run-tests.php $(TESTS); \ + else \ + echo "ERROR: Cannot run tests without CLI sapi."; \ + fi + +clean: + find . -name \*.lo | xargs rm -f + find . -name \*.o | xargs rm -f + find . -name \*.la | xargs rm -f + find . -name \*.a | xargs rm -f + find . -name \*.so | xargs rm -f + find . -name .libs -a -type d|xargs rm -rf + rm -f libphp4.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/* + +distclean: clean + rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php4.spec sapi/apache/libphp4.module buildmk.stamp + egrep define'.*include/php' configure|sed 's/.*>//'|xargs rm -f + find . -name Makefile | xargs rm -f + +.PHONY: all clean install distclean test +.NOEXPORT: diff --git a/Makefile.objects b/Makefile.objects new file mode 100644 index 0000000..00f882c --- /dev/null +++ b/Makefile.objects @@ -0,0 +1,8 @@ +php_imlib.lo: /home/pp/php-imlib-0.4pre2/php_imlib.c + $(LIBTOOL) --mode=compile $(CC) -I. -I/home/pp/php-imlib-0.4pre2 $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -prefer-pic -c /home/pp/php-imlib-0.4pre2/php_imlib.c -o php_imlib.lo +$(phplibdir)/imlib.la: ./imlib.la + $(LIBTOOL) --mode=install cp ./imlib.la $(phplibdir) + +./imlib.la: $(shared_objects_imlib) $(IMLIB_SHARED_DEPENDENCIES) + $(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_imlib) $(IMLIB_SHARED_LIBADD) + diff --git a/README b/README new file mode 100644 index 0000000..097905d --- /dev/null +++ b/README @@ -0,0 +1,78 @@ +PHP Imlib2 Extension (php_imlib) +================================ + +This extension, as one might expect, provides access to Rasterman's +excellent image library, Imlib2. The extension is coming together fairly +well, with probably four fifths of the Imlib2 API ported which I've been +aiming for (There are parts of Imlib2 used specifically for X applications, +which of course, we don't need in a PHP extension). See "About php_imlib" +below and the contents of the docs directory for more information on the +extension. + + +Requirements +------------ +See INSTALL for where to get the required libraries. Imlib2, freetype, +libjpeg, and libpng should work on most Unices, I don't know how portable +edb is. + +Briefly, the requirements are: + +A Unix or Linux OS +PHP >= 4.0.1 (4.0.4 recommended) +Imlib2 >= 1.0.0 +edb >= 1.0 +freetype >= 1.3.1 +libjpeg +libpng + + +What's Wrong With GD? +--------------------- +There's nothing wrong with GD, I just wanted an alternative. Aside from +that, Imlib2 is a faster, more powerful library. + + +Caveats +------- +Imlib2 is not thread safe. While this isn't a large concern at the +moment, it will become a more important issue as Apache 2 develops and +threaded httpd installations become more common. + + +About php_imlib +--------------- +The general idea behind php_imlib is to mimick the function names and their +parameters as closely as possible at the extension level. However since +Imlib2 uses a singleton context that I'd rather not duplicate in the +extension, most functions will require extra parameters to establish context. +As we've developed php_imlib, a few needs have also come up which Imlib2 +doesn't address. In those cases we've defined functions in php_imlib which +aren't present in Imlib2. So far we've added three functions: +imlib_dump_image, for outputting an image to stdout (Comporable to GD's +ImagePng($im)), imlib_image_modify_alpha, and imlib_create_scaled_image, a +shortcut of imlib_create_cropped_scaled_image, which is ideal for creating a +scaled copy of the whole image quickly, such as for generating thumbnails. + +To combat the need to have a large number parameters for some of the more +complex functions, I had written a single PHP class to wrap the extension in +version 0.1. However as I developed 0.2, that clearly became insufficent. So, +starting with 0.2 I've included a handful of more reasonably sized classes +that spread things out nicely. I'm fairly pleased with how they've turned +out, but as always, feedback is encouraged. More extensive documentation on +the classes is available in the phpdoc directory. + +In the first release, I had also included an abstract image class that +allowed the use of GD and php_imlib with the same code. At least for the +time being, that's been scrapped, since it was never implemented fully at +the time, and would've occupied far more time than it was worth this time +around. So, I filed that one away under "bad idea". + + +Function Reference +------------------ +The extension functions are covered in docs/api.txt, the class files are +covered in the phpdoc directory (html only). Both are available online: + +http://mmcc.cx/php_imlib/documentation.php +http://mmcc.cx/php_imlib/phpdoc/ diff --git a/TODO b/TODO new file mode 100644 index 0000000..14ec1fa --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +* update documentation, examples and PHP classes diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..a2ce632 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,1847 @@ +dnl $Id: acinclude.m4,v 1.218.2.31 2003/10/03 04:29:24 sniper Exp $ +dnl +dnl This file contains local autoconf functions. + +dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile[, ext_srcdir[, ext_builddir]]]) +dnl +dnl Processes a file called Makefile.frag in the source directory +dnl of the most recently added extension. $(srcdir) and $(builddir) +dnl are substituted with the proper paths. Can be used to supply +dnl custom rules and/or additional targets. +dnl +AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[ + ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1) + ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2) + ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3) + sed -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments +]) + +AC_DEFUN(PHP_PROG_RE2C,[ + AC_CHECK_PROG(RE2C, re2c, re2c, [exit 0;]) +]) + +dnl PHP_DEFINE(WHAT[, value]) +dnl +dnl Creates builddir/include/what.h and in there #define WHAT value +dnl +AC_DEFUN([PHP_DEFINE],[ + [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > include/php_]translit($1,A-Z,a-z)[.h] +]) + +dnl PHP_INIT_BUILD_SYSTEM +dnl +AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[ +test -d include || mkdir include +> Makefile.objects +> Makefile.fragments +dnl We need to play tricks here to avoid matching the egrep line itself +pattern=define +egrep $pattern'.*include/php' $srcdir/configure|sed 's/.*>//'|xargs touch 2>/dev/null +]) + +dnl PHP_GEN_GLOBAL_MAKEFILE +dnl +dnl Generates the global makefile. +dnl +AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[ + cat >Makefile <> Makefile + done + + cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile +]) + +dnl PHP_ADD_SOURCES(source-path, sources[, special-flags[, type]]) +dnl +dnl Adds sources which are located relative to source-path to the +dnl array of type type. Sources are processed with optional +dnl special-flags which are passed to the compiler. Sources +dnl can be either written in C or C++ (filenames shall end in .c +dnl or .cpp, respectively). +dnl +dnl Note: If source-path begins with a "/", the "/" is removed and +dnl the path is interpreted relative to the top build-directory. +dnl +dnl which array to append to? +AC_DEFUN([PHP_ADD_SOURCES],[ + PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,cli,PHP_CLI_OBJS,ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS))) +]) +dnl +dnl _PHP_ASSIGN_BUILD_VARS(type) +dnl internal, don't use +AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[ +ifelse($1,shared,[ + b_c_pre=$shared_c_pre + b_cxx_pre=$shared_cxx_pre + b_c_meta=$shared_c_meta + b_cxx_meta=$shared_cxx_meta + b_c_post=$shared_c_post + b_cxx_post=$shared_cxx_post +],[ + b_c_pre=$php_c_pre + b_cxx_pre=$php_cxx_pre + b_c_meta=$php_c_meta + b_cxx_meta=$php_cxx_meta + b_c_post=$php_c_post + b_cxx_post=$php_cxx_post +])dnl + b_lo=[$]$1_lo +]) + +dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]]) +dnl +dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the +dnl name of the array target-var directly, as well as whether +dnl shared objects will be built from the sources. Should not be +dnl used directly. +dnl +AC_DEFUN([PHP_ADD_SOURCES_X],[ +dnl relative to source- or build-directory? +dnl ac_srcdir/ac_bdir include trailing slash + case $1 in + ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;; + /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;; + *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;; + esac + +dnl how to build .. shared or static? + ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php)) + +dnl iterate over the sources + old_IFS=[$]IFS + for ac_src in $2; do + +dnl remove the suffix + IFS=. + set $ac_src + ac_obj=[$]1 + IFS=$old_IFS + +dnl append to the array which has been dynamically chosen at m4 time + $4="[$]$4 [$]ac_bdir[$]ac_obj.lo" + +dnl choose the right compiler/flags/etc. for the source-file + case $ac_src in + *.c[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;; + *.cpp[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;; + esac + +dnl create a rule for the object/source combo + cat >>Makefile.objects< +#include + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +main() { + DIR *dir; + char entry[sizeof(struct dirent)+PATH_MAX]; + struct dirent *pentry = (struct dirent *) &entry; + + dir = opendir("/"); + if (!dir) + exit(1); + if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) + exit(0); + exit(1); +} + ],[ + ac_cv_what_readdir_r=POSIX + ],[ + AC_TRY_CPP([ +#define _REENTRANT +#include +#include +int readdir_r(DIR *, struct dirent *); + ],[ + ac_cv_what_readdir_r=old-style + ],[ + ac_cv_what_readdir_r=none + ]) + ],[ + ac_cv_what_readdir_r=none + ]) + ]) + case $ac_cv_what_readdir_r in + POSIX) + AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);; + old-style) + AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);; + esac + fi +]) + +AC_DEFUN([PHP_SHLIB_SUFFIX_NAME],[ + PHP_SUBST(SHLIB_SUFFIX_NAME) + SHLIB_SUFFIX_NAME=so + case $host_alias in + *hpux*[)] + SHLIB_SUFFIX_NAME=sl + ;; + *darwin*[)] + SHLIB_SUFFIX_NAME=dylib + ;; + esac +]) + +AC_DEFUN([PHP_DEBUG_MACRO],[ + DEBUG_LOG=$1 + cat >$1 <conftest.$ac_ext <>$1 2>&1 + rm -fr conftest* +]) + +AC_DEFUN([PHP_DOES_PWRITE_WORK],[ + AC_TRY_RUN([ +#include +#include +#include +#include +#include +$1 + main() { + int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600); + + if (fd < 0) exit(1); + if (pwrite(fd, "text", 4, 0) != 4) exit(1); + /* Linux glibc breakage until 2.2.5 */ + if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1); + exit(0); + } + + ],[ + ac_cv_pwrite=yes + ],[ + ac_cv_pwrite=no + ],[ + ac_cv_pwrite=no + ]) +]) + +AC_DEFUN([PHP_DOES_PREAD_WORK],[ + echo test > conftest_in + AC_TRY_RUN([ +#include +#include +#include +#include +#include +$1 + main() { + char buf[3]; + int fd = open("conftest_in", O_RDONLY); + if (fd < 0) exit(1); + if (pread(fd, buf, 2, 0) != 2) exit(1); + /* Linux glibc breakage until 2.2.5 */ + if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1); + exit(0); + } + ],[ + ac_cv_pread=yes + ],[ + ac_cv_pread=no + ],[ + ac_cv_pread=no + ]) + rm -f conftest_in +]) + +AC_DEFUN([PHP_PWRITE_TEST],[ + AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[ + PHP_DOES_PWRITE_WORK + if test "$ac_cv_pwrite" = "no"; then + PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) + if test "$ac_cv_pwrite" = "yes"; then + ac_cv_pwrite=64 + fi + fi + ]) + + if test "$ac_cv_pwrite" != "no"; then + AC_DEFINE(HAVE_PWRITE, 1, [ ]) + if test "$ac_cv_pwrite" = "64"; then + AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]) + fi + fi +]) + +AC_DEFUN([PHP_PREAD_TEST],[ + AC_CACHE_CHECK(whether pread works,ac_cv_pread,[ + PHP_DOES_PREAD_WORK + if test "$ac_cv_pread" = "no"; then + PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) + if test "$ac_cv_pread" = "yes"; then + ac_cv_pread=64 + fi + fi + ]) + + if test "$ac_cv_pread" != "no"; then + AC_DEFINE(HAVE_PREAD, 1, [ ]) + if test "$ac_cv_pread" = "64"; then + AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]) + fi + fi +]) + +AC_DEFUN([PHP_MISSING_TIME_R_DECL],[ + AC_MSG_CHECKING([for missing declarations of reentrant functions]) + AC_TRY_COMPILE([#include ],[struct tm *(*func)() = localtime_r],[ + : + ],[ + AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared]) + ]) + AC_TRY_COMPILE([#include ],[struct tm *(*func)() = gmtime_r],[ + : + ],[ + AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared]) + ]) + AC_TRY_COMPILE([#include ],[char *(*func)() = asctime_r],[ + : + ],[ + AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared]) + ]) + AC_TRY_COMPILE([#include ],[char *(*func)() = ctime_r],[ + : + ],[ + AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared]) + ]) + AC_TRY_COMPILE([#include ],[char *(*func)() = strtok_r],[ + : + ],[ + AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared]) + ]) + AC_MSG_RESULT([done]) +]) + +dnl +dnl PHP_LIBGCC_LIBPATH(gcc) +dnl Stores the location of libgcc in libgcc_libpath +dnl +AC_DEFUN([PHP_LIBGCC_LIBPATH],[ + changequote({,}) + libgcc_libpath=`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'` + changequote([,]) +]) + +AC_DEFUN([PHP_ARG_ANALYZE_EX],[ +ext_output="yes, shared" +ext_shared=yes +case [$]$1 in +shared,*[)] + $1=`echo "[$]$1"|sed 's/^shared,//'` + ;; +shared[)] + $1=yes + ;; +no[)] + ext_output=no + ext_shared=no + ;; +*[)] + ext_output=yes + ext_shared=no + ;; +esac + +PHP_ALWAYS_SHARED([$1]) +]) + +AC_DEFUN([PHP_ARG_ANALYZE],[ +ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)]) +ifelse([$2],,,[AC_MSG_RESULT([$ext_output])]) +]) + +dnl +dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]]) +dnl Sets PHP_ARG_NAME either to the user value or to the default value. +dnl default-val defaults to no. This will also set the variable ext_shared, +dnl and will overwrite any previous variable of that name. +dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run +dnl the PHP_ARG_ANALYZE_EX. +dnl +AC_DEFUN([PHP_ARG_WITH],[ +PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)]) +]) + +AC_DEFUN([PHP_REAL_ARG_WITH],[ +ifelse([$2],,,[AC_MSG_CHECKING([$2])]) +AC_ARG_WITH($1,[$3],$5=[$]withval, +[ + $5=ifelse($4,,no,$4) + + if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then + $5=$PHP_ENABLE_ALL + fi +]) +PHP_ARG_ANALYZE($5,[$2],$6) +]) + +dnl +dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]]) +dnl Sets PHP_ARG_NAME either to the user value or to the default value. +dnl default-val defaults to no. This will also set the variable ext_shared, +dnl and will overwrite any previous variable of that name. +dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run +dnl the PHP_ARG_ANALYZE_EX. +dnl +AC_DEFUN([PHP_ARG_ENABLE],[ +PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_),[ifelse($5,,yes,$5)]) +]) + +AC_DEFUN([PHP_REAL_ARG_ENABLE],[ +ifelse([$2],,,[AC_MSG_CHECKING([$2])]) +AC_ARG_ENABLE($1,[$3],$5=[$]enableval, +[ + $5=ifelse($4,,no,$4) + + if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then + $5=$PHP_ENABLE_ALL + fi +]) +PHP_ARG_ANALYZE($5,[$2],$6) +]) + +AC_DEFUN([PHP_MODULE_PTR],[ + EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1," +]) + +AC_DEFUN([PHP_CONFIG_NICE],[ + test -f $1 && mv $1 $1.old + rm -f $1.old + cat >$1<> $1 + fi + done + + for arg in [$]0 "[$]@"; do + echo "'[$]arg' \\" >> $1 + done + echo '"[$]@"' >> $1 + chmod +x $1 +]) + +AC_DEFUN([PHP_TIME_R_TYPE],[ +AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[ +AC_TRY_RUN([ +#include + +main() { +char buf[27]; +struct tm t; +time_t old = 0; +int r, s; + +s = gmtime_r(&old, &t); +r = (int) asctime_r(&t, buf, 26); +if (r == s && s == 0) return (0); +return (1); +} +],[ + ac_cv_time_r_type=hpux +],[ + AC_TRY_RUN([ +#include +main() { + struct tm t, *s; + time_t old = 0; + char buf[27], *p; + + s = gmtime_r(&old, &t); + p = asctime_r(&t, buf, 26); + if (p == buf && s == &t) return (0); + return (1); +} + ],[ + ac_cv_time_r_type=irix + ],[ + ac_cv_time_r_type=POSIX + ]) +],[ + ac_cv_time_r_type=POSIX +]) +]) + case $ac_cv_time_r_type in + hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;; + irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;; + esac +]) + +AC_DEFUN([PHP_SUBST],[ + PHP_VAR_SUBST="$PHP_VAR_SUBST $1" +]) + +AC_DEFUN([PHP_SUBST_OLD],[ + PHP_SUBST($1) + AC_SUBST($1) +]) + +AC_DEFUN([PHP_TM_GMTOFF],[ +AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff, +[AC_TRY_COMPILE([#include +#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;], + ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)]) + +if test "$ac_cv_struct_tm_gmtoff" = yes; then + AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm]) +fi +]) + +dnl PHP_CONFIGURE_PART(MESSAGE) +dnl Idea borrowed from mm +AC_DEFUN([PHP_CONFIGURE_PART],[ + AC_MSG_RESULT() + AC_MSG_RESULT([${T_MD}$1${T_ME}]) +]) + +AC_DEFUN([PHP_PROG_SENDMAIL],[ +PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib +AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH) +if test -n "$PROG_SENDMAIL"; then + AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail]) +fi +]) + +AC_DEFUN([PHP_RUNPATH_SWITCH],[ +dnl check for -R, etc. switch +AC_MSG_CHECKING([if compiler supports -R]) +AC_CACHE_VAL(php_cv_cc_dashr,[ + SAVE_LIBS=$LIBS + LIBS="-R /usr/lib $LIBS" + AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no) + LIBS=$SAVE_LIBS]) +AC_MSG_RESULT([$php_cv_cc_dashr]) +if test $php_cv_cc_dashr = "yes"; then + ld_runpath_switch=-R +else + AC_MSG_CHECKING([if compiler supports -Wl,-rpath,]) + AC_CACHE_VAL(php_cv_cc_rpath,[ + SAVE_LIBS=$LIBS + LIBS="-Wl,-rpath,/usr/lib $LIBS" + AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no) + LIBS=$SAVE_LIBS]) + AC_MSG_RESULT([$php_cv_cc_rpath]) + if test $php_cv_cc_rpath = "yes"; then + ld_runpath_switch=-Wl,-rpath, + else + dnl something innocuous + ld_runpath_switch=-L + fi +fi +]) + +AC_DEFUN([PHP_STRUCT_FLOCK],[ +AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock, + AC_TRY_COMPILE([ +#include +#include + ], + [struct flock x;], + [ + ac_cv_struct_flock=yes + ],[ + ac_cv_struct_flock=no + ]) +) +if test "$ac_cv_struct_flock" = "yes" ; then + AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock]) +fi +]) + +AC_DEFUN([PHP_SOCKLEN_T],[ +AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t, + AC_TRY_COMPILE([ +#include +#include +],[ +socklen_t x; +],[ + ac_cv_socklen_t=yes +],[ + ac_cv_socklen_t=no +])) +if test "$ac_cv_socklen_t" = "yes"; then + AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t]) +fi +]) + +dnl +dnl PHP_SET_SYM_FILE(path) +dnl +dnl set the path of the file which contains the symbol export list +dnl +AC_DEFUN([PHP_SET_SYM_FILE], +[ + PHP_SYM_FILE=$1 +]) + +dnl +dnl PHP_BUILD_THREAD_SAFE +dnl +AC_DEFUN([PHP_BUILD_THREAD_SAFE],[ + enable_experimental_zts=yes + if test "$pthreads_working" != "yes"; then + AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.]) + fi +]) + +AC_DEFUN([PHP_REQUIRE_CXX],[ + if test -z "$php_cxx_done"; then + AC_PROG_CXX + AC_PROG_CXXCPP + php_cxx_done=yes + fi +]) + +dnl +dnl PHP_BUILD_SHARED +dnl +AC_DEFUN([PHP_BUILD_SHARED],[ + PHP_BUILD_PROGRAM + OVERALL_TARGET=libphp4.la + php_build_target=shared + + php_c_pre=$shared_c_pre + php_c_meta=$shared_c_meta + php_c_post=$shared_c_post + php_cxx_pre=$shared_cxx_pre + php_cxx_meta=$shared_cxx_meta + php_cxx_post=$shared_cxx_post + php_lo=$shared_lo +]) + +dnl +dnl PHP_BUILD_STATIC +dnl +AC_DEFUN([PHP_BUILD_STATIC],[ + PHP_BUILD_PROGRAM + OVERALL_TARGET=libphp4.la + php_build_target=static +]) + +dnl +dnl PHP_BUILD_BUNDLE +dnl +AC_DEFUN([PHP_BUILD_BUNDLE],[ + PHP_BUILD_PROGRAM + OVERALL_TARGET=libs/libphp4.bundle + php_build_target=static +]) + +dnl +dnl PHP_BUILD_PROGRAM +dnl +AC_DEFUN([PHP_BUILD_PROGRAM],[ + OVERALL_TARGET=[]ifelse($1,,php,$1) + php_c_pre='$(LIBTOOL) --mode=compile $(CC)' + php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)' + php_c_post= + php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)' + php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)' + php_cxx_post= + php_lo=lo + + shared_c_pre='$(LIBTOOL) --mode=compile $(CC)' + shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -prefer-pic' + shared_c_post= + shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)' + shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) -prefer-pic' + shared_cxx_post= + shared_lo=lo + + php_build_target=program +]) + +dnl +dnl PHP_RUN_ONCE(namespace, variable, code) +dnl +dnl execute code, if variable is not set in namespace +dnl +AC_DEFUN([PHP_RUN_ONCE],[ + changequote({,}) + unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'` + changequote([,]) + cmd="echo $ac_n \"\$$1$unique$ac_c\"" + if test -n "$unique" && test "`eval $cmd`" = "" ; then + eval "$1$unique=set" + $3 + fi +]) + +dnl +dnl PHP_EXPAND_PATH(path, variable) +dnl +dnl expands path to an absolute path and assigns it to variable +dnl +AC_DEFUN([PHP_EXPAND_PATH],[ + if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then + $2=$1 + else + changequote({,}) + ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`" + changequote([,]) + ep_realdir="`(cd \"$ep_dir\" && pwd)`" + $2="$ep_realdir/`basename \"$1\"`" + fi +]) +dnl +dnl internal, don't use +AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[ + PHP_RUN_ONCE(LIBPATH, $1, [ + test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1" + LDFLAGS="$LDFLAGS -L$1" + PHP_RPATHS="$PHP_RPATHS $1" + ]) +])dnl +dnl +dnl +dnl +dnl PHP_ADD_LIBPATH(path[, shared-libadd]) +dnl +dnl add a library to linkpath/runpath +dnl +AC_DEFUN([PHP_ADD_LIBPATH],[ + if test "$1" != "/usr/lib"; then + PHP_EXPAND_PATH($1, ai_p) + ifelse([$2],,[ + _PHP_ADD_LIBPATH_GLOBAL([$ai_p]) + ],[ + if test "$ext_shared" = "yes"; then + $2="$ld_runpath_switch$ai_p -L$ai_p [$]$2" + else + _PHP_ADD_LIBPATH_GLOBAL([$ai_p]) + fi + ]) + fi +]) + +dnl +dnl PHP_UTILIZE_RPATHS() +dnl +dnl builds RPATHS/LDFLAGS from PHP_RPATHS +dnl +AC_DEFUN([PHP_UTILIZE_RPATHS],[ + OLD_RPATHS=$PHP_RPATHS + unset PHP_RPATHS + + for i in $OLD_RPATHS; do +dnl Can be passed to native cc/libtool + PHP_LDFLAGS="$PHP_LDFLAGS -L$i" +dnl Libtool-specific + PHP_RPATHS="$PHP_RPATHS -R $i" +dnl cc-specific + NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i" + done + + if test "$PHP_RPATH" = "no"; then + unset PHP_RPATHS + unset NATIVE_RPATHS + fi +]) + +dnl +dnl PHP_ADD_INCLUDE(path [,before]) +dnl +dnl add an include path. +dnl if before is 1, add in the beginning of INCLUDES. +dnl +AC_DEFUN([PHP_ADD_INCLUDE],[ + if test "$1" != "/usr/include"; then + PHP_EXPAND_PATH($1, ai_p) + PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [ + if test "$2"; then + INCLUDES="-I$ai_p $INCLUDES" + else + INCLUDES="$INCLUDES -I$ai_p" + fi + ]) + fi +]) +dnl +dnl internal, don't use +AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl + ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl +])dnl +dnl +dnl internal, don't use +AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[ + case $1 in + c|c_r|pthread*[)] ;; + *[)] ifelse($3,,[ + _PHP_X_ADD_LIBRARY($1,$2,$5) + ],[ + if test "$ext_shared" = "yes"; then + _PHP_X_ADD_LIBRARY($1,$2,$3) + else + $4($1,$2) + fi + ]) ;; + esac +])dnl +dnl +dnl +dnl +dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]]) +dnl +dnl add a library to the link line +dnl +AC_DEFUN([PHP_ADD_LIBRARY],[ + _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS]) +]) + +dnl +dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]]) +dnl +dnl add a library to the link line (deferred) +dnl +AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[ + _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS]) +]) + +dnl +dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd]) +dnl +dnl add a library to the link line and path to linkpath/runpath. +dnl if shared-libadd is not empty and $ext_shared is yes, +dnl shared-libadd will be assigned the library information +dnl +AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[ +ifelse($3,,[ + if test -n "$2"; then + PHP_ADD_LIBPATH($2) + fi + PHP_ADD_LIBRARY($1) +],[ + if test "$ext_shared" = "yes"; then + $3="-l$1 [$]$3" + if test -n "$2"; then + PHP_ADD_LIBPATH($2,$3) + fi + else + PHP_ADD_LIBRARY_WITH_PATH($1,$2) + fi +]) +]) + +dnl +dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd]) +dnl +dnl add a library to the link line (deferred) +dnl and path to linkpath/runpath (not deferred) +dnl if shared-libadd is not empty and $ext_shared is yes, +dnl shared-libadd will be assigned the library information +dnl +AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[ +ifelse($3,,[ + if test -n "$2"; then + PHP_ADD_LIBPATH($2) + fi + PHP_ADD_LIBRARY_DEFER($1) +],[ + if test "$ext_shared" = "yes"; then + $3="-l$1 [$]$3" + if test -n "$2"; then + PHP_ADD_LIBPATH($2,$3) + fi + else + PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2) + fi +]) +]) + +dnl +dnl PHP_ADD_FRAMEWORK(framework [,before]) +dnl +dnl add a (Darwin / Mac OS X) framework to the link +dnl line. if before is 1, the framework is added +dnl to the beginning of the line. + +AC_DEFUN([PHP_ADD_FRAMEWORK], [ + PHP_RUN_ONCE(FRAMEWORKS, $1, [ + if test "$2"; then + PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS" + else + PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1" + fi + ]) +]) + +dnl +dnl PHP_ADD_FRAMEWORKPATH(path [,before]) +dnl +dnl add a (Darwin / Mac OS X) framework path to the link +dnl and include lines. default paths include (but are +dnl not limited to) /Local/Library/Frameworks and +dnl /System/Library/Frameworks, so these don't need +dnl to be specifically added. if before is 1, the +dnl framework path is added to the beginning of the +dnl relevant lines. + +AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [ + PHP_EXPAND_PATH($1, ai_p) + PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [ + if test "$2"; then + PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH" + else + PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p" + fi + ]) +]) + +dnl +dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path) +dnl +dnl add a (Darwin / Mac OS X) framework path and the +dnl framework itself to the link and include lines. +AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [ + PHP_ADD_FRAMEWORKPATH($2) + PHP_ADD_FRAMEWORK($1) +]) + +dnl +dnl Set libtool variable +dnl +AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[ + if test -z "$LIBTOOL"; then + LIBTOOL='$(SHELL) $(top_builddir)/libtool $1' + else + LIBTOOL="$LIBTOOL $1" + fi +]) + +dnl +dnl Check for cc option +dnl +AC_DEFUN([PHP_CHECK_CC_OPTION],[ + echo "main(){return 0;}" > conftest.$ac_ext + opt=$1 + changequote({,}) + var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'` + changequote([,]) + AC_MSG_CHECKING([if compiler supports -$1 really]) + ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1" + if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then + eval php_cc_$var=no + AC_MSG_RESULT([no]) + else + if eval ./conftest 2>/dev/null ; then + eval php_cc_$var=yes + AC_MSG_RESULT([yes]) + else + eval php_cc_$var=no + AC_MSG_RESULT([no]) + fi + fi + rm -rf conftest* +]) + +AC_DEFUN([PHP_REGEX],[ + +if test "$REGEX_TYPE" = "php"; then + AC_DEFINE(HSREGEX,1,[ ]) + AC_DEFINE(REGEX,1,[ ]) + PHP_ADD_SOURCES(regex, regcomp.c regexec.c regerror.c regfree.c) +elif test "$REGEX_TYPE" = "system"; then + AC_DEFINE(REGEX,0,[ ]) +fi + +AC_MSG_CHECKING([which regex library to use]) +AC_MSG_RESULT([$REGEX_TYPE]) +]) + +dnl +dnl See if we have broken header files like SunOS has. +dnl +AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[ + AC_MSG_CHECKING([for fclose declaration]) + AC_TRY_COMPILE([#include ],[int (*func)() = fclose],[ + AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ]) + AC_MSG_RESULT([ok]) + ],[ + AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ]) + AC_MSG_RESULT([missing]) + ]) +]) + +dnl +dnl Check for broken sprintf(), C99 conformance +dnl +AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[ + AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[ + AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[ + ac_cv_broken_sprintf=no + ],[ + ac_cv_broken_sprintf=yes + ],[ + ac_cv_broken_sprintf=no + ]) + ]) + if test "$ac_cv_broken_sprintf" = "yes"; then + AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform]) + else + AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform]) + fi +]) + +dnl +dnl Check for broken snprintf(), C99 conformance +dnl +AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[ + AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[ + AC_TRY_RUN([ +#define NULL (0L) +main() { + char buf[20]; + int res = 0; + res = res || (snprintf(buf, 2, "marcus") != 6); + res = res || (buf[1] != '\0'); + /* Implementations may consider this as an encoding error */ + snprintf(buf, 0, "boerger"); + /* However, they MUST ignore the pointer */ + res = res || (buf[0] != 'm'); + res = res || (snprintf(NULL, 0, "boerger") != 7); + res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8); + exit(res); +} + ],[ + ac_cv_broken_snprintf=no + ],[ + ac_cv_broken_snprintf=yes + ],[ + ac_cv_broken_snprintf=no + ]) + ]) + if test "$ac_cv_broken_snprintf" = "yes"; then + AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform]) + else + AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform]) + fi +]) + +dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx) +dnl +dnl Basically sets up the link-stage for building module-name +dnl from object_var in build-dir. +dnl +AC_DEFUN([PHP_SHARED_MODULE],[ + PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.la" + PHP_SUBST($2) + cat >>Makefile.objects</dev/