octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [changeset] GraphicsMagick++ configuration


From: David Grundberg
Subject: Re: [changeset] GraphicsMagick++ configuration
Date: Tue, 25 Aug 2009 14:07:24 +0200
User-agent: Thunderbird 2.0.0.21 (X11/20090302)

David Grundberg wrote:
Thomas Weber wrote:
On Sun, Aug 16, 2009 at 11:09:09PM +0200, Thomas Weber wrote:
On Thu, Aug 06, 2009 at 04:15:56PM -0400, John W. Eaton wrote:
On  6-Aug-2009, David Grundberg wrote:

| John W. Eaton skrev:
| > On  6-Aug-2009, David Grundberg wrote:
| >
| > | I've rearranged the GraphicsMagick++ configuration. I had some trouble | > | since I'm running a custom GraphicsMagick installation. The Octave build | > | system was running GraphicsMagick++-config during make. It was missing | > | ldflags and using only the basename of the config executable (as opposed | > | to a full path). | > | | > | I've changed it so that GraphicsMagick++-config is only run in the | > | configure script. Also introduced MAGICK_CONFIG as a precious variable.
| >
| > I removed --ldflags to fix the following mysterious problem on my
| > system:
| >
| > https://www-old.cae.wisc.edu/pipermail/octave-maintainers/2009-July/012879.html
| >
| > So I don't think I can put it back without breaking __magick_read__
| > again, at least for me and other Debian users.
| >
| > What are -Wl,-z,relro and -pie doing in the ldflags anyway? Are those | > arguments not present on your system? Maybe they are present on mine | > because of the way Debian builds the graphics magick library package?
| > Perhaps these flags make sense for creating the graphics magick
| > library itself, but I can't see any reason for them to be required to
| > link the graphics magick library with __magick_read__.oct.
| >
| > jwe
| > | So that's why --ldflags was taken away! I don't have that problem. This | is the output from my config (where I'm building): | | $ | octave-patching/dependencies/graphicsmagick-install/bin/GraphicsMagick++-config | --ldflags --libs | -L/Home/staff/davidg/octave-patching/dependencies/graphicsmagick-install/lib | -L/usr/lib -L/usr/lib | -lGraphicsMagick++ -lGraphicsMagick -llcms -ltiff -lfreetype -ljasper | -ljpeg -lpng -lwmflite -lXext -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lm | -lgomp -lpthread | | My ubuntu 9.04 box says this about the managed package (haven't tried | building against it):
| address@hidden:~$ GraphicsMagick++-config --ldflags --libs
| -L/usr/lib -Wl,-Bsymbolic-functions -L/usr/lib/X11 -L/usr/lib -L/usr/lib | -lGraphicsMagick++ -lGraphicsMagick -llcms -ltiff -lfreetype -ljasper | -ljpeg -lpng -lwmflite -lXext -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lm | -lpthread

So what should we do about this?
These are different versions. The Ubuntu version is 1.1.11-something,
your Debian versions is 1.3.5-something.

around it by filtering out everything except -L options from the
--ldflags output, but I'd rather see it fixed in graphics magick.
What should graphics magick really be storing in the config script
for --ldflags?  Should options like -pie and -Wl,-z,relro really
appear there?  Or is this just a Debian packaging problem?
The Debian packaging adds the -pie and -Wl options when building
GraphicsMagick to the LDFLAGS. GraphicsMagick then copies LDFLAGS into its
--ldflags output. Looking at Ubuntu's build logs, the same is already
happening with newer versions of graphicsmagick.

I'll ask the Debian maintainer of GraphicsMagick about it.

Okay, his answer is below. Short version: we should go we with
pkg-config.

============================================================================ Historically, the output of the *Magick*config scripts has been documented as the list of compiler/linker options *Magick was built with. This makes sense when build additional modules, but it's rather nonsensical for anything that just wants to link the C or C++ bindings. I recommend to use pkg-config for these kinds of applications instead. The hardening options aren't included
there.
============================================================================

    Thomas

Thanks a lot for your help!

I made a new changeset, attached to this mail.

At first I tried the pkg-config setup and was disappointed to see (some ubuntu):

$ pkg-config GraphicsMagick++ --libs
-Wl,-Bsymbolic-functions -lGraphicsMagick++ -lGraphicsMagick $ pkg-config GraphicsMagick++ --cflags
-I/usr/include/GraphicsMagick
But then I discovered the --libs-only-l/L arguments (didn't know about these):

$ pkg-config GraphicsMagick++ --libs-only-L

$ pkg-config GraphicsMagick++ --libs-only-l
-lGraphicsMagick++ -lGraphicsMagick

Nice.

David
(responding to self)

Ooops. An invalid email address sneaked into the ChangeLog. Fixed it. Sorry for the noise.

David
# HG changeset patch
# User David Grundberg <address@hidden>
# Date 1251201810 -7200
# Node ID 8c4da26cfd57b54cf4c8b7370610f807e7f57363
# Parent  d280bfa04996fa3bf2e1d02f22dea56fdb6d6d62
Use pkg-config to configure GraphicsMagick++.

diff -r d280bfa04996 -r 8c4da26cfd57 ChangeLog
--- a/ChangeLog Thu Aug 13 20:20:32 2009 +0200
+++ b/ChangeLog Tue Aug 25 14:03:30 2009 +0200
@@ -1,3 +1,15 @@
+2009-08-25  David Grundberg  <address@hidden>
+
+       * configure.in: Run PKG_PROG_PKG_CONFIG earlier. Use pkg-config
+       instead of GraphicsMagick++-config. Determine only -I, -L and -l
+       flags and put them in MAGICK_CPPFLAGS, MAGICK_LDFLAGS and
+       MAGICK_LIBS respectively. Substitute these variables.
+       Remove variables MAGICK_CONFIG and MAGICK_INCFLAGS.
+       Test linking against GraphicsMagick++.
+       * Makeconf.in: Don't run $(MAGICK_CONFIG) here. Use substituted
+       valued from MAGICK_CPPFLAGS, MAGICK_LDFLAGS and MAGICK_LIBS.
+       Remove variables MAGICK_CONFIG and MAGICK_INCFLAGS.
+
 2009-08-24  Jaroslav Hajek  <address@hidden>
 
        * acx_blas_f77_func.m4: Fix typo.
diff -r d280bfa04996 -r 8c4da26cfd57 Makeconf.in
--- a/Makeconf.in       Thu Aug 13 20:20:32 2009 +0200
+++ b/Makeconf.in       Tue Aug 25 14:03:30 2009 +0200
@@ -151,9 +151,9 @@
 
 CARBON_LIBS = @CARBON_LIBS@
 
-MAGICK_CONFIG = @MAGICK_CONFIG@
-MAGICK_INCFLAGS = $(shell $(MAGICK_CONFIG) --cppflags)
-MAGICK_LIBS = $(shell $(MAGICK_CONFIG) --libs)
+MAGICK_CPPFLAGS = @MAGICK_CPPFLAGS@
+MAGICK_LDFLAGS = @MAGICK_LDFLAGS@
+MAGICK_LIBS = @MAGICK_LIBS@
 
 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
 PTHREAD_LIBS = @PTHREAD_LIBS@
@@ -633,7 +633,8 @@
   -e "s|%OCTAVE_CONF_LIBOCTINTERP%|\"${LIBOCTINTERP}\"|" \
   -e "s|%OCTAVE_CONF_LIBS%|\"${LIBS}\"|" \
   -e "s|%OCTAVE_CONF_LN_S%|\"${LN_S}\"|" \
-  -e "s|%OCTAVE_CONF_MAGICK_INCFLAGS%|\"${MAGICK_INCFLAGS}\"|" \
+  -e "s|%OCTAVE_CONF_MAGICK_CPPFLAGS%|\"${MAGICK_CPPFLAGS}\"|" \
+  -e "s|%OCTAVE_CONF_MAGICK_LDFLAGS%|\"${MAGICK_LDFLAGS}\"|" \
   -e "s|%OCTAVE_CONF_MAGICK_LIBS%|\"${MAGICK_LIBS}\"|" \
   -e 's|%OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%|\"@address@hidden"|' \
   -e "s|%OCTAVE_CONF_OCTINCLUDEDIR%|\"${octincludedir}\"|" \
diff -r d280bfa04996 -r 8c4da26cfd57 configure.in
--- a/configure.in      Thu Aug 13 20:20:32 2009 +0200
+++ b/configure.in      Tue Aug 25 14:03:30 2009 +0200
@@ -112,6 +112,10 @@
 OCTAVE_SET_DEFAULT(localveroctfiledir,
   '$(libexecdir)/octave/$(version)/site/oct/$(canonical_host_type)')
 OCTAVE_SET_DEFAULT(imagedir, '$(datadir)/octave/$(version)/imagelib')
+
+### Find pkg-config executable (sets $PKG_CONFIG)
+
+PKG_PROG_PKG_CONFIG
 
 ### Make configure args available for other uses.
 
@@ -562,15 +566,56 @@
 LIBS="$save_LIBS"
 CPPFLAGS="$save_CPPFLAGS"
 
-# GraphicsMagick++
+### GraphicsMagick++
 
-warn_magick=
-AC_CHECK_PROGS(MAGICK_CONFIG, [GraphicsMagick++-config GraphicsMagick-config])
-if test -z "$MAGICK_CONFIG"; then
-  warn_magick="GraphicsMagick++ config script not found.  Assuming 
GraphicsMagic++ library and header files are missing, so imread will not be 
fully functional"
+warn_magick="GraphicsMagick++ library not found.  The imread function for 
reading image files will not be fully functional."
+
+MAGICK_CPPFLAGS=
+MAGICK_LDFLAGS=
+MAGICK_LIBS=
+
+PKG_CHECK_EXISTS([GraphicsMagick++], [
+  ## Make sure we only get -I, -L and -l flags. Some GraphicsMagick++
+  ## packages adds extra flags that are useful when building
+  ## GraphicsMagick++ extentions. These extra flags break the Octave build.
+  MAGICK_LDFLAGS=`$PKG_CONFIG --libs-only-L GraphicsMagick++`
+  MAGICK_LIBS=`$PKG_CONFIG --libs-only-l GraphicsMagick++`
+  MAGICK_CPPFLAGS=`$PKG_CONFIG --cflags-only-I GraphicsMagick++`
+
+  warn_magick="GraphicsMagick++ library fails tests.  The imread function for 
reading image files will not be fully functional."
+
+  save_CPPFLAGS="$CPPFLAGS"
+  save_LDFLAGS="$LDFLAGS"
+  save_LIBS="$LIBS"
+  CPPFLAGS="$CPPFLAGS $MAGICK_CPPFLAGS"
+  LDFLAGS="$LIBS $MAGICK_LDFLAGS"
+  LIBS="$LIBS $MAGICK_LIBS"
+  AC_LANG_PUSH(C++)
+    AC_CHECK_HEADER([Magick++.h], [
+      AC_MSG_CHECKING([for Magick::ColorRGB in Magick++.h])
+      AC_TRY_LINK([#include <Magick++.h>], [Magick::ColorRGB c;], [
+        AC_MSG_RESULT(yes)
+        warn_magick=
+      ], [
+        AC_MSG_RESULT(no)
+      ])
+    ])
+  AC_LANG_POP(C++)
+  CPPFLAGS="$save_CPPFLAGS"
+  LDFLAGS="$save_LDFLAGS"
+  LIBS="$save_LIBS"
+])
+
+if test -z "$warn_magick"; then
+  AC_DEFINE(HAVE_MAGICK, 1, [Define if GraphicsMagick++ is available.])
 else
-  AC_DEFINE(HAVE_MAGICK, 1, [Define if GraphicsMagick++ is available.])
+  MAGICK_CPPFLAGS=
+  MAGICK_LDFLAGS=
+  MAGICK_LIBS=
 fi
+AC_SUBST(MAGICK_CPPFLAGS)
+AC_SUBST(MAGICK_LDFLAGS)
+AC_SUBST(MAGICK_LIBS)
 
 # ---------------------------------------------------------------------
 
@@ -642,7 +687,6 @@
 # fontconfig library
 
 warn_fontconfig=""
-PKG_PROG_PKG_CONFIG
 if test -z "$warn_freetype"; then
   PKG_CHECK_MODULES(FONTCONFIG,[fontconfig],[
     have_fontconfig=yes
@@ -2062,6 +2106,10 @@
   GLPK CPPFLAGS:        $GLPK_CPPFLAGS
   GLPK LDFLAGS:         $GLPK_LDFLAGS
   GLPK libraries:       $GLPK_LIBS
+  GraphicsMagick++
+    CPPFLAGS:           $MAGICK_CPPFLAGS
+    LDFLAGS:            $MAGICK_LDFLAGS
+    libraries:          $MAGICK_LIBS
   HDF5 CPPFLAGS:        $HDF5_CPPFLAGS
   HDF5 LDFLAGS:         $HDF5_LDFLAGS
   HDF5 libraries:       $HDF5_LIBS
@@ -2084,7 +2132,6 @@
 
   Default pager:        $DEFAULT_PAGER
   gnuplot:              $GNUPLOT
-  Magick config:        $MAGICK_CONFIG
 
   Do internal array bounds checking:  $BOUNDS_CHECKING
   Build static libraries:             $STATIC_LIBS
diff -r d280bfa04996 -r 8c4da26cfd57 src/ChangeLog
--- a/src/ChangeLog     Thu Aug 13 20:20:32 2009 +0200
+++ b/src/ChangeLog     Tue Aug 25 14:03:30 2009 +0200
@@ -1,3 +1,10 @@
+2009-08-25  David Grundberg  <address@hidden>
+
+       * DLD-FUNCTIONS/__magick_read__.cc [HAVE_MAGICK]: Include
+       Magick++.h instead of GraphicsMagick/Magic++.h.
+       * Makefile.in: Replace MAGICK_LIBS with MAGICK_LDFLAGS and
+       MAGICK_LIBS. Replace MAGICK_INCFLAGS with MAGICK_CPPFLAGS.
+
 2009-08-24  Jaroslav Hajek  <address@hidden>
 
        * OPERATORS/op-m-m.cc: Install .*= and ./= operators.
diff -r d280bfa04996 -r 8c4da26cfd57 src/DLD-FUNCTIONS/__magick_read__.cc
--- a/src/DLD-FUNCTIONS/__magick_read__.cc      Thu Aug 13 20:20:32 2009 +0200
+++ b/src/DLD-FUNCTIONS/__magick_read__.cc      Tue Aug 25 14:03:30 2009 +0200
@@ -33,7 +33,7 @@
 
 #ifdef HAVE_MAGICK
 
-#include <GraphicsMagick/Magick++.h>
+#include <Magick++.h>
 
 unsigned int
 scale_quantum_to_depth (const Magick::Quantum& quantum, unsigned int depth)
diff -r d280bfa04996 -r 8c4da26cfd57 src/Makefile.in
--- a/src/Makefile.in   Thu Aug 13 20:20:32 2009 +0200
+++ b/src/Makefile.in   Tue Aug 25 14:03:30 2009 +0200
@@ -313,7 +313,7 @@
     $(REGEX_LDFLAGS) $(REGEX_LIBS) \
     $(CURL_LDFLAGS) $(CURL_LIBS) \
     $(GLPK_LDFLAGS) $(GLPK_LIBS) \
-    $(MAGICK_LIBS) \
+    $(MAGICK_LDFLAGS) $(MAGICK_LIBS) \
     $(GRAPHICS_LDFLAGS) $(GRAPHICS_LIBS) \
     $(FT2_LDFLAGS) $(FT2_LIBS) \
     $(HDF5_LDFLAGS) $(HDF5_LIBS) $(Z_LDFLAGS) $(Z_LIBS) \
@@ -679,8 +679,8 @@
 display.d display.df display.o pic/display.o: CPPFLAGS += $(X11_FLAGS)
 
 __magick_read__.d __magick_read__.df __magick_read__.o pic/__magick_read__.o: \
-  CPPFLAGS += $(MAGICK_INCFLAGS)
-__magick_read__.oct: OCT_LINK_DEPS += $(MAGICK_LIBS)
+  CPPFLAGS += $(MAGICK_CPPFLAGS)
+__magick_read__.oct: OCT_LINK_DEPS += $(MAGICK_LDFLAGS) $(MAGICK_LIBS)
 
 convhull.d convhull.df convhull.o pic/convhull.o: CPPFLAGS += $(QHULL_CPPFLAGS)
 convhulln.oct: OCT_LINK_DEPS += $(QHULL_LDFLAGS) $(QHULL_LIBS)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]