PATCH: GD - don't add libs to global LIBS for shared gd.so
| From: | Petr Cech | Date: | Thu, 07 Dec 2000 23:26:33 +0000 |
| Subject: | PATCH: GD - don't add libs to global LIBS for shared gd.so | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-40503@lists.php.net to get a copy of this message | ||
Hi,
it's pretty annoying, that if you build gd extension shared, then the main
libphp4.so is also linked with png, X11, Xpm, zlib and probaly other
libraries. This patch should fix it.
Petr Cech
--
Debian GNU/Linux maintainer - www.debian.{org,cz}
cech@atrey.karlin.mff.cuni.cz
--- php4-4.0.4.orig/ext/gd/config.m4 +++ php4-4.0.4/ext/gd/config.m4 @@ -6,12 +6,16 @@ if test "$withval" = "yes"; then withval="/usr/local" fi - old_LIBS=$LIBS + jold_LIBS=$LIBS LIBS="$LIBS -L$withval/lib" AC_CHECK_LIB(jpeg,jpeg_read_header, [LIBS="$LIBS -ljpeg"],[AC_MSG_RESULT(no)],) - LIBS=$old_LIBS - AC_ADD_LIBRARY_WITH_PATH(jpeg, $withval/lib) - LIBS="$LIBS -L$withval/lib -ljpeg" + LIBS=$jold_LIBS + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -ljpeg" + GD_LFLAGS="$GD_LFLAGS -L$withval/lib" + else + AC_ADD_LIBRARY_WITH_PATH(jpeg, $withval/lib) + fi ],[ AC_MSG_RESULT(no) AC_MSG_WARN(If configure fails try --with-jpeg-dir=<DIR>) @@ -31,9 +35,13 @@ LIBS="$LIBS -L$withval/lib -lX11" AC_CHECK_LIB(Xpm,XpmFreeXpmImage, [LIBS="$LIBS -L$withval/lib -lXpm"],[AC_MSG_RESULT(no)],) LIBS=$old_LIBS - AC_ADD_LIBRARY_WITH_PATH(Xpm, $withval/lib) - AC_ADD_LIBRARY_WITH_PATH(X11, $withval/lib) - LIBS="$LIBS -L$withval/lib -lXpm -L$withval/lib -lX11" + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -lXpm -lX11" + GD_LFLAGS="$GD_LFLAGS -L$withval/lib" + else + AC_ADD_LIBRARY_WITH_PATH(Xpm, $withval/lib) + AC_ADD_LIBRARY_WITH_PATH(X11, $withval/lib) + fi ],[ AC_MSG_RESULT(no) AC_MSG_WARN(If configure fails try --with-xpm-dir=<DIR>) @@ -58,7 +66,7 @@ AC_MSG_CHECKING(whether to enable truetype string function in gd) AC_ARG_ENABLE(gd-native-ttf, -[ --enable-gd-imgstrttf Enable TrueType string function in gd],[ +[ --enable-gd-imgstrttf Enable TrueType string function in gd],[ if test "$enableval" = "yes" ; then AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ]) AC_MSG_RESULT(yes) @@ -72,8 +80,7 @@ shared=no AC_ARG_WITH(gd, -[ - --with-gd[=DIR] Include GD support (DIR is GD's install dir). +[ --with-gd[=DIR] Include GD support (DIR is GD's install dir). Set DIR to "shared" to build as a dl, or "shared,DIR" to build as a dl and still specify DIR.], [ @@ -93,7 +100,7 @@ AC_DEFINE(HAVE_LIBGD,1,[ ]) if test "$shared" = "yes"; then AC_MSG_RESULT(yes (shared)) - GD_LIBS="-lgd" + GD_LIBS="-lgd $GD_LIBS" else AC_MSG_RESULT(yes (static)) AC_ADD_LIBRARY(gd) @@ -108,8 +115,12 @@ LIBS=$old_LIBS LDFLAGS=$old_LDFLAGS if test "$ac_cv_lib_gd_gdImageCreateFromPng" = "yes"; then - AC_ADD_LIBRARY(png) - AC_ADD_LIBRARY(z) + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -lpng -lz" + else + AC_ADD_LIBRARY(png) + AC_ADD_LIBRARY(z) + fi fi ac_cv_lib_gd_gdImageLine=yes @@ -142,8 +153,8 @@ AC_DEFINE(HAVE_LIBGD,1,[ ]) if test "$shared" = "yes"; then AC_MSG_RESULT(yes (shared)) - GD_LIBS="-lgd" - GD_LFLAGS="-L$GD_LIB" + GD_LIBS="-lgd $GD_LIBS" + GD_LFLAGS="-L$GD_LIB $GD_LFLAGS" else AC_MSG_RESULT(yes (static)) AC_ADD_LIBRARY_WITH_PATH(gd, $GD_LIB) @@ -158,8 +169,12 @@ LIBS=$old_LIBS LDFLAGS=$old_LDFLAGS if test "$ac_cv_lib_gd_gdImageCreateFromPng" = "yes"; then - AC_ADD_LIBRARY(z) - AC_ADD_LIBRARY(png) + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -lpng -lz" + else + AC_ADD_LIBRARY(z) + AC_ADD_LIBRARY(png) + fi fi ac_cv_lib_gd_gdImageLine=yes @@ -222,16 +237,26 @@ if test "$withval" = "yes"; then for i in /usr/local /usr; do if test -f "$i/include/t1lib.h"; then - AC_ADD_LIBRARY_WITH_PATH(t1, "$i/lib") - AC_ADD_INCLUDE("$i/include") + T1_DIR="$i" fi done else if test -f "$withval/include/t1lib.h"; then - AC_ADD_LIBRARY_WITH_PATH(t1, "$withval/lib") - AC_ADD_INCLUDE("$withval/include") + T1_DIR="$withval" fi fi + + if test "$T1_DIR" != "no"; then + AC_ADD_INCLUDE("$T1_DIR/include") + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -lt1" + GD_LFLAGS="$GD_LFLAGS -L$T1_DIR/lib" + else + AC_ADD_LIBRARY_WITH_PATH(t1, "$T1_DIR/lib") + fi +# LIBS="$LIBS -L$T1_DIR/lib -lt1" + fi + AC_MSG_RESULT(yes) AC_CHECK_LIB(t1, T1_GetExtend, [AC_DEFINE(HAVE_LIBT1,1,[ ])]) else
--- php4-4.0.4.orig/ext/gd/config.m4 +++ php4-4.0.4/ext/gd/config.m4 @@ -6,12 +6,16 @@ if test "$withval" = "yes"; then withval="/usr/local" fi - old_LIBS=$LIBS + jold_LIBS=$LIBS LIBS="$LIBS -L$withval/lib" AC_CHECK_LIB(jpeg,jpeg_read_header, [LIBS="$LIBS -ljpeg"],[AC_MSG_RESULT(no)],) - LIBS=$old_LIBS - AC_ADD_LIBRARY_WITH_PATH(jpeg, $withval/lib) - LIBS="$LIBS -L$withval/lib -ljpeg" + LIBS=$jold_LIBS + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -ljpeg" + GD_LFLAGS="$GD_LFLAGS -L$withval/lib" + else + AC_ADD_LIBRARY_WITH_PATH(jpeg, $withval/lib) + fi ],[ AC_MSG_RESULT(no) AC_MSG_WARN(If configure fails try --with-jpeg-dir=<DIR>) @@ -31,9 +35,13 @@ LIBS="$LIBS -L$withval/lib -lX11" AC_CHECK_LIB(Xpm,XpmFreeXpmImage, [LIBS="$LIBS -L$withval/lib -lXpm"],[AC_MSG_RESULT(no)],) LIBS=$old_LIBS - AC_ADD_LIBRARY_WITH_PATH(Xpm, $withval/lib) - AC_ADD_LIBRARY_WITH_PATH(X11, $withval/lib) - LIBS="$LIBS -L$withval/lib -lXpm -L$withval/lib -lX11" + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -lXpm -lX11" + GD_LFLAGS="$GD_LFLAGS -L$withval/lib" + else + AC_ADD_LIBRARY_WITH_PATH(Xpm, $withval/lib) + AC_ADD_LIBRARY_WITH_PATH(X11, $withval/lib) + fi ],[ AC_MSG_RESULT(no) AC_MSG_WARN(If configure fails try --with-xpm-dir=<DIR>) @@ -58,7 +66,7 @@ AC_MSG_CHECKING(whether to enable truetype string function in gd) AC_ARG_ENABLE(gd-native-ttf, -[ --enable-gd-imgstrttf Enable TrueType string function in gd],[ +[ --enable-gd-imgstrttf Enable TrueType string function in gd],[ if test "$enableval" = "yes" ; then AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ]) AC_MSG_RESULT(yes) @@ -72,8 +80,7 @@ shared=no AC_ARG_WITH(gd, -[ - --with-gd[=DIR] Include GD support (DIR is GD's install dir). +[ --with-gd[=DIR] Include GD support (DIR is GD's install dir). Set DIR to "shared" to build as a dl, or "shared,DIR" to build as a dl and still specify DIR.], [ @@ -93,7 +100,7 @@ AC_DEFINE(HAVE_LIBGD,1,[ ]) if test "$shared" = "yes"; then AC_MSG_RESULT(yes (shared)) - GD_LIBS="-lgd" + GD_LIBS="-lgd $GD_LIBS" else AC_MSG_RESULT(yes (static)) AC_ADD_LIBRARY(gd) @@ -108,8 +115,12 @@ LIBS=$old_LIBS LDFLAGS=$old_LDFLAGS if test "$ac_cv_lib_gd_gdImageCreateFromPng" = "yes"; then - AC_ADD_LIBRARY(png) - AC_ADD_LIBRARY(z) + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -lpng -lz" + else + AC_ADD_LIBRARY(png) + AC_ADD_LIBRARY(z) + fi fi ac_cv_lib_gd_gdImageLine=yes @@ -142,8 +153,8 @@ AC_DEFINE(HAVE_LIBGD,1,[ ]) if test "$shared" = "yes"; then AC_MSG_RESULT(yes (shared)) - GD_LIBS="-lgd" - GD_LFLAGS="-L$GD_LIB" + GD_LIBS="-lgd $GD_LIBS" + GD_LFLAGS="-L$GD_LIB $GD_LFLAGS" else AC_MSG_RESULT(yes (static)) AC_ADD_LIBRARY_WITH_PATH(gd, $GD_LIB) @@ -158,8 +169,12 @@ LIBS=$old_LIBS LDFLAGS=$old_LDFLAGS if test "$ac_cv_lib_gd_gdImageCreateFromPng" = "yes"; then - AC_ADD_LIBRARY(z) - AC_ADD_LIBRARY(png) + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -lpng -lz" + else + AC_ADD_LIBRARY(z) + AC_ADD_LIBRARY(png) + fi fi ac_cv_lib_gd_gdImageLine=yes @@ -222,16 +237,26 @@ if test "$withval" = "yes"; then for i in /usr/local /usr; do if test -f "$i/include/t1lib.h"; then - AC_ADD_LIBRARY_WITH_PATH(t1, "$i/lib") - AC_ADD_INCLUDE("$i/include") + T1_DIR="$i" fi done else if test -f "$withval/include/t1lib.h"; then - AC_ADD_LIBRARY_WITH_PATH(t1, "$withval/lib") - AC_ADD_INCLUDE("$withval/include") + T1_DIR="$withval" fi fi + + if test "$T1_DIR" != "no"; then + AC_ADD_INCLUDE("$T1_DIR/include") + if test "$shared" = "yes"; then + GD_LIBS="$GD_LIBS -lt1" + GD_LFLAGS="$GD_LFLAGS -L$T1_DIR/lib" + else + AC_ADD_LIBRARY_WITH_PATH(t1, "$T1_DIR/lib") + fi +# LIBS="$LIBS -L$T1_DIR/lib -lt1" + fi + AC_MSG_RESULT(yes) AC_CHECK_LIB(t1, T1_GetExtend, [AC_DEFINE(HAVE_LIBT1,1,[ ])]) else