ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
BuildSmart

ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by BuildSmart »

I'm trying to buid ImageMagic with ghostscript however it always fails the lib test.

Unfortuantely the source wont autoreconf for me due to version issues and the errors/reasons aren't worth the time since anything I do will probably render the source un-useable.

I do have a real developer environment where it is possible to build for multiple Mac architectures (this is not the cause of the failure) and I have several machines that I could permit a developer access if he wishes/requires to perform some tests.

For some library details

Code: Select all

amavis-stats:~/ root# otool -L  /usr/local/lib/libgs.dylib /System/Library/Frameworks/Ghostscript.framework/Ghostscript
/usr/local/lib/libgs.dylib:
        /System/Library/Frameworks/Ghostscript.framework/Ghostscript (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.2)
        /usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 92.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.0.0)
/System/Library/Frameworks/Ghostscript.framework/Ghostscript:
        /System/Library/Frameworks/Ghostscript.framework/Ghostscript (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.2)
        /usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 92.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.0.0)
amavis-stats:~/ root# 
Ultimately I could just hack the configure script to achieve my results however I believe that this should be fixed globally for all Mac users.

I'm able to assist I will try to put together a valid lib test while I'm waiting for someone to contact me.

-- BuildSmart
BuildSmart

Re: ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by BuildSmart »

...FUNCTIONALITY SOLVED...

This should be failrly self explanatory, this goes in "aclocal.m4"

Code: Select all

m4_include([m4/framework.m4])
file: m4/framework.m4

Code: Select all

# AC_CHECK_FRAMEWORK(FRAMEWORK, FUNCTION,
#              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
#              [OTHER-LIBRARIES])
# ------------------------------------------------------
#
# Use a cache variable name containing both the framework and function name,
# because the test really is for framework $1 defining function $2, not
# just for framework $1.  Separate tests with the same $1 and different $2s
# may have different results.
#
# Note that using directly AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1_$2])
# is asking for troubles, since AC_CHECK_FRAMEWORK($framework, fun) would give
# ac_cv_framework_$framework_fun, which is definitely not what was meant.  Hence
# the AS_LITERAL_IF indirection.
#
# FIXME: This macro is extremely suspicious.  It DEFINEs unconditionally,
# whatever the FUNCTION, in addition to not being a *S macro.  Note
# that the cache does depend upon the function we are looking for.
#
# It is on purpose we used `ac_check_framework_save_LIBS' and not just
# `ac_save_LIBS': there are many macros which don't want to see `LIBS'
# changed but still want to use AC_CHECK_FRAMEWORK, so they save `LIBS'.
# And ``ac_save_LIBS' is too tempting a name, so let's leave them some
# freedom.
AC_DEFUN([AC_CHECK_FRAMEWORK],
[m4_ifval([$3], , [AH_CHECK_FRAMEWORK([$1])])dnl
AS_LITERAL_IF([$1],
	      [AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1_$2])],
	      [AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1''_$2])])dnl
AC_CACHE_CHECK([for $2 in $1 framework], ac_Framework,
[ac_check_framework_save_LIBS=$LIBS
LIBS="-framework $1 $5 $LIBS"
AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
	       [AS_VAR_SET(ac_Framework, yes)],
	       [AS_VAR_SET(ac_Framework, no)])
LIBS=$ac_check_framework_save_LIBS])
AS_IF([test AS_VAR_GET(ac_Framework) = yes],
      [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FRAMEWORK_$1))
  LIBS="-framework $1 $LIBS"
])],
      [$4])dnl
AS_VAR_POPDEF([ac_Framework])dnl
])# AC_CHECK_FRAMEWORK

# AH_CHECK_FRAMEWORK(FRAMEWORK)
# ---------------------
m4_define([AH_CHECK_FRAMEWORK],
[AH_TEMPLATE(AS_TR_CPP(HAVE_FRAMEWORK_$1),
	     [Define to 1 if you have the `]$1[' framework (-framework ]$1[).])])
This goes in "configure.ac"

Code: Select all

#
# Check for Ghostscript library or framework.
#
# Test for iapi.h & test for gsapi_new_instance in -lgs
# or -framework Ghostscript
have_gslib='no'
GS_LIBS=''
if test "$with_gslib" != 'no'
then
  AC_MSG_RESULT()
  AC_MSG_RESULT(--------------------------------)
  AC_MSG_RESULT(Checking for Ghostscript support)
  AC_MSG_RESULT(--------------------------------)
  framework=0;
  failed=0;
  passed=0;
  AC_CHECK_HEADER(ghostscript/iapi.h,passed=`expr $passed + 1`,
    failed=`expr $failed + 1`,)
  AC_CHECK_HEADER(ghostscript/ierrors.h,passed=`expr $passed + 1`,
    failed=`expr $failed + 1`,)
  AC_CHECK_FRAMEWORK(Ghostscript,gsapi_new_instance,framework=`expr $framework + 1`,
    AC_CHECK_LIB(gs,gsapi_new_instance,passed=`expr $passed + 1`,failed=`expr $failed + 1`,),)
  AC_MSG_CHECKING(if Ghostscript package is complete)
  if test $passed -gt 0
	then
    if test $failed -gt 0
    then
      AC_MSG_RESULT(no -- some components failed test)
      have_gslib='no (failed tests)'
    else
      if test $framework -gt 0
      then
        GS_LIBS='-framework Ghostscript'
        AC_MSG_RESULT([yes, using framework.])
      else
       AC_MSG_RESULT([yes, using library.])
       GS_LIBS='-lgs'
      fi
      LIBS="$GS_LIBS $LIBS"
      AC_DEFINE(HasGS,1,Define if you have Ghostscript library or framework)
      have_gslib='yes'
    fi
  else
    AC_MSG_RESULT(no)
  fi
  AC_MSG_RESULT()
fi
I ran this in RH9, Darwin and Mac OSX with no issues (the only three OS's I have).

I would be sadly disappointed if this isn't included in future builds since the impact is beneficial to the Mac community not to mention the ability to use the framework in other OS's that support them.

I am also looking at increasing the Mac functionality since too many features are turned off.

-- BuildSmart
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by magick »

Your patches are in ImageMagick 6.3.3 Beta available sometime tommorrow. Thanks.
BuildSmart

Re: ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by BuildSmart »

magick wrote: Your patches are in ImageMagick 6.3.3 Beta available sometime tommorrow. Thanks.

WOW!!! You guys are pretty painless, I look forward to contributing more.

My intention is to obtain a build that is equally as function in OSX as it is on other OS's so I have a couple of questions.

Due to the Ghostcript.framework, Mac OSX / Darwin's binary of ghostscript is "gsc" and not "gs", can detection for this be included, currently I use the following kludge (I was in a hurry and this was a quick hack to obtain a working test result but isn't IMHO a production solution)

Code: Select all

if test "$native_win32_build" = 'yes' ; then
  PSDelegateDefault='gswin32c'
else
  if test $framework -gt 0
  then
    PSDelegateDefault='gsc'
  else
    PSDelegateDefault='gs'
  fi
fi
I notice it doesn't seem to recognize pcl6 (it's installed in /usr/local/bin).

Code: Select all

Usage: pcl6 [option* file]+...
Options: -dNOPAUSE -E[#] -h -C -L<PCL|PCLXL> -n -K<maxK> -P<PCL5C|PCL5E|RTL> -Z...
         -sDEVICE=<dev> -g<W>x<H> -r<X>[x<Y>] -d{First|Last}Page=<#>
         -sOutputFile=<file> (-s<option>=<string> | -d<option>[=<value>])*
         -J<PJL commands>Version: 1.41
Build date: Thu Mar  1 16:27:36 2007
Devices: x11 x11alpha x11mono x11cmyk ljet4 djet500 cljet5pr cljet5c
 bitcmyk bitrgb bitrgbtags tr_rgb pcxmono pcxgray pcxcmyk pswrite pdfwrite
 pxlmono pxlcolor bmpmono bmpsep8 pbmraw pgmraw ppmraw jpeg bmpamono
 bmpa16m bbox nullpage
Here is the current reported build info:

Code: Select all

Host system type : multi-apple-darwin8.0.0

                  Option                        Value
-------------------------------------------------------------------------
Shared libraries  --enable-shared=yes           yes
Static libraries  --enable-static=yes           yes
Module support    --with-modules=yes            yes
GNU ld            --with-gnu-ld=no              no
Quantum depth     --with-quantum-depth=16       16

Delegate Configuration:
BZLIB             --with-bzlib=yes              yes
DJVU              --with-djvu=yes               no
DPS               --with-dps=yes                yes
FlashPIX          --with-fpx=yes                        no
FontConfig        --with-fontconfig=yes         no
FreeType          --with-freetype=yes           yes
GhostPCL          None                          pcl6 (unknown)
Ghostscript       None                          gsc (8.54)
Ghostscript fonts --with-gs-font-dir=default    /usr/local/share/ghostscript/fontsc/
Ghostscript lib   --with-gslib=yes              yes
Graphviz          --with-gvc=yes                no
JBIG              --with-jbig=yes               no
JPEG v1           --with-jpeg=yes               yes
JPEG-2000         --with-jp2=yes                no
LCMS              --with-lcms=yes               no
Magick++          --with-magick-plus-plus=yes   yes
PERL              --with-perl=yes               /usr/bin/perl
PNG               --with-png=yes                yes
RSVG              --with-rsvg=yes               no
TIFF              --with-tiff=yes               yes
Windows fonts     --with-windows-font-dir=/windows/fonts        /windows/fonts/
WMF               --with-wmf=yes                no
X11               --with-x=yes                  yes
XML               --with-xml=yes                yes
ZLIB              --with-zlib=yes               yes

X11 Configuration:
  X_CFLAGS     = -I/usr/X11R6/include
  X_PRE_LIBS   = -lSM -lICE
  X_LIBS       = -L/usr/X11R6/lib
  X_EXTRA_LIBS = 

Options used to compile and link:
  PREFIX      = /usr/local/imagemagick
  EXEC-PREFIX = /usr/local/imagemagick
  VERSION     = 6.3.2
  CC          = gcc
  CFLAGS      = -ftest-coverage -fprofile-arcs -pg -p -arch ppc -arch i386 -Os -pipe -no-cpp-precomp -pipe -no-cpp-precomp -arch ppc -arch i386 -Wall -W -D_THREAD_SAFE
  CPPFLAGS    = -I/usr/local/imagemagick/include
  PCFLAGS     = 
  DEFS        = -DHAVE_CONFIG_H
  LDFLAGS     = -L/usr/local/imagemagick/lib -ftest-coverage -fprofile-arcs -pg -p -arch ppc -arch i386 -bind_at_load -L/usr/X11R6/lib -L/usr/X11R6/lib -lfreetype
  LIBS        = -lMagick -ltiff -lfreetype -ljpeg -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lpthread -lm -lpthread
  CXX         = g++
  CXXFLAGS    = -ftest-coverage -fprofile-arcs -pg -p -arch ppc -arch i386 -Os -pipe -Wall -W -D_THREAD_SAFE
Is this configuration functional enough for x-window support or should I shoot for more (maybe add libwmf)?

Also to note, fontconfig is very alive and useable however, this test always fails on Darwin / Mac OSX and I believe your only tests are against the fontconfig script, if someone can post a typical output or even e-mail the script to me I can work on an acceptable Darwin / Mac OSX solution for this.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by magick »

We added a patch to ImageMagick 6.3.3 Beta to use gsc for a Ghostscript framework as you suggested. 6.3.3 is scheduled for release within a week or two. Thanks.
BuildSmart

Re: ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by BuildSmart »

magick wrote: We added a patch to ImageMagick 6.3.3 Beta to use gsc for a Ghostscript framework as you suggested. 6.3.3 is scheduled for release within a week or two. Thanks.
That little hack isn't conplete, I also had to make some other changes to get the font directory correct:

Code: Select all

AC_PATH_PROGS(PSDelegate, gsx gsc $PSDelegateDefault,$PSDelegateDefault)
(You'll notice I check for "gsx" as well as "gsc", I'm rewritting some of the Ghostscript code to enhance functionlity and make use of the already available graphic environment so I'd like to have support already included.)
& (here we make sure the font path is correct for our binary which might not be in bin)

Code: Select all

ghostscript_font_dir=`echo "$PSDelegate" | sed -e 's:/'$(basename $(dirname $PSDelegate))'/'$(basename $PSDelegate)':/share/ghostscript/fonts:'`"/"
If the font paths are searchable (multiple paths like /usr/local/share/ghostscript/fonts:/System/Library/Frameworks/Ghostscript.framework/Resources/fonts) then I think it would be safe to include the Framework font diretory if detected or maybe this be the deault?

What still has not beed addressed is the 'pcl6' detection issue
As I said, my intention is to generate something that is as fully functional in Darwin / Mac OSX as it is on other platforms as I can possibly make it.

I have generated the first truly universal 10.4.x installation of Ghostscript (I have succeeded where others have failed) for Darwin / Mac OSX making the binaries multiple architecture to support intel and ppc in the same binary package.

Current build:

Code: Select all

Host system type : multi-apple-darwin8.0.0

                  Option                        Value
-------------------------------------------------------------------------
Shared libraries  --enable-shared=yes           yes
Static libraries  --enable-static=yes           yes
Module support    --with-modules=yes            yes
GNU ld            --with-gnu-ld=no              no
Quantum depth     --with-quantum-depth=16       16

Delegate Configuration:
BZLIB             --with-bzlib=yes              yes
DJVU              --with-djvu=yes               no
DPS               --with-dps=yes                yes
FlashPIX          --with-fpx=no                 no
FontConfig        --with-fontconfig=yes         no
FreeType          --with-freetype=yes           yes
GhostPCL          None                          pcl6 (unknown)
Ghostscript       None                          gsc (8.54)
Ghostscript fonts --with-gs-font-dir=default    /usr/local/share/ghostscript/fonts/
Ghostscript lib   --with-gslib=yes              yes
Graphviz          --with-gvc=yes                no
JBIG              --with-jbig=yes               no
JPEG v1           --with-jpeg=yes               yes
JPEG-2000         --with-jp2=yes                no
LCMS              --with-lcms=yes               no
Magick++          --with-magick-plus-plus=yes   yes
PERL              --with-perl=yes               /usr/bin/perl
PNG               --with-png=yes                yes
RSVG              --with-rsvg=yes               no
TIFF              --with-tiff=yes               yes
Windows fonts     --with-windows-font-dir=/System/Library/Frameworks/Ghostscript.framework/Resources/windows/fonts      /System/Library/Frameworks/Ghostscript.framework/Resources/windows/fonts/
WMF               --with-wmf=yes                yes
X11               --with-x=yes                  yes
XML               --with-xml=yes                yes
ZLIB              --with-zlib=yes               yes

X11 Configuration:
  X_CFLAGS     = -I/usr/X11R6/include
  X_PRE_LIBS   = -lSM -lICE
  X_LIBS       = -L/usr/X11R6/lib
  X_EXTRA_LIBS = 

Options used to compile and link:
  PREFIX      = /usr/local/ghostscript
  EXEC-PREFIX = /usr/local/ghostscript
  VERSION     = 6.3.2
  CC          = cc
  CFLAGS      = -arch ppc -arch i386 -Os -pipe -no-cpp-precomp -pipe -no-cpp-precomp -arch ppc -arch i386 -Wall -W -D_THREAD_SAFE
  CPPFLAGS    = -I/usr/local/ghostscript/include
  PCFLAGS     = 
  DEFS        = -DHAVE_CONFIG_H
  LDFLAGS     = -L/usr/local/ghostscript/lib -arch ppc -arch i386 -bind_at_load -L/usr/X11R6/lib -L/usr/X11R6/lib -lfreetype
  LIBS        = -lMagick -ltiff -lfreetype -ljpeg -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lpthread -lm -lpthread
  CXX         = g++
  CXXFLAGS    = -arch ppc -arch i386 -Os -pipe -Wall -W -D_THREAD_SAFE
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by magick »

Good work. We will have your patches in ImageMagick 6.3.3 by tommorrow. Thanks.
BuildSmart

Re: ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by BuildSmart »

Well, someone made some mistakes when entering the changes

Code: Select all

checking for gsx... gsc
&

Code: Select all

checking for Ghostscript fonts directory... gsc/
Syntax is critical in checks, especially when checking for different apps

Code: Select all

AC_PATH_PROG(PSDelegate, gsx gsc $PSDelegateDefault,$PSDelegateDefault)
is invalid and should be:

Code: Select all

AC_PATH_PROGS(PSDelegate, gsx gsc $PSDelegateDefault,$PSDelegateDefault)
Actually, let's make it:

Code: Select all

AC_PATH_PROGS(PSDelegate, gsx gsc gs gswin32c,$PSDelegateDefault)
and then change:

Code: Select all

if test "$PSDelegate" != 'gs'
to:

Code: Select all

if test "$PSDelegate" != "$PSDelegateDefault"
There are also issue in the jpeg check code that has been carried over from previous versions that should also be addressed:

Code: Select all

checking for jpeg_read_header in -ljpeg... yes
checking for JPEG library is version 6b or later... yes
yes
checking if JPEG package is complete... yes
If you examine the macro you will see the macro already prints the results so attempting to print the results again is an error in logic.

Another issue is that you use "GSCMYKDevice=pam" and this options doesn't appear to be available:

Code: Select all

Default output device: png16m
Available devices:
   bbox epswrite jpeg jpegcmyk jpeggray nullpage pbm pbmraw pdfwrite
   pdfwrite pgm pgmraw pgnm pgnmraw pkm pkmraw pksm pksmraw png16 png16m
   png256 pngalpha pnggray pngmono pnm pnmraw ppm ppmraw ps2write pswrite
   pxlcolor pxlmono
maybe something from this list can be substituted or perhaps a different configure flag in GhostScript is required???

Now it appears to recognize the libraries or frameworks in OSX (depending on the build method used) but we have a build issue:

Code: Select all

ld: Undefined symbols:
___gcov_init
___gcov_merge_add
/usr/bin/libtool: internal link edit command failed
I don't believe this is anything serious, looks like it's not adding "-lgcov" if it's available so changing

Code: Select all

# Add '-ftest-coverage -fprofile-arcs' if gcov source profiling support enabled
# This is a gcc-specific feature
if test "$with_gcov" = 'yes'
then
  CFLAGS="-ftest-coverage -fprofile-arcs  $CFLAGS"
  CXXFLAGS="-ftest-coverage -fprofile-arcs  $CXXFLAGS"
  LDFLAGS="-ftest-coverage -fprofile-arcs $LDFLAGS"
fi
to:

Code: Select all

# Add '-ftest-coverage -fprofile-arcs' if gcov source profiling support enabled
# This is a gcc-specific feature
if test "$with_gcov" = 'yes'
then
  AC_CHECK_LIB(gcov,__gcov_init)
  CFLAGS="-ftest-coverage -fprofile-arcs  $CFLAGS"
  CXXFLAGS="-ftest-coverage -fprofile-arcs  $CXXFLAGS"
  LDFLAGS="-ftest-coverage -fprofile-arcs $LDFLAGS"
fi
resolves the issue and with systems that don't have, need or require libgcov it doesn't affect them.

Now that I can configure using the the Ghostscript library or framework, I've run into another issue which has to do with building the dynamic library with "--enable-gcov" in that it also requires "-single_module" to be supplied during the link stage when generating the shared libraries.

If gone through and cleaned up the configure.ac script and fixed some cosmetic issues with some of the macros as well so if I can get someone to work with me for a couple of minutes and regenerate a configure script based on the updated configure.ac and macro files I've been working on it would help expedite matters significantly (only because I can't do it due to the version and environment issues).

I can be reached on aim at "mrdalewalsh@aol.com" if you'd like to help me work out these minor glitches and it shouldn't take more than a few minutes of yor time.

-- Dale
BuildSmart

Re: ImageMagick-6.3.2 / ghostscript-8.54 on Mac OSX

Post by BuildSmart »

A new thread has been started to reflect the new ImageMagick version http://redux.imagemagick.org/discussion ... f=2&t=8620 so this one can be locked.
Post Reply