Advertisement
ananas

Remove ltdl dependency from GraphicsMagick

Jun 12th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 13.90 KB | None | 0 0
  1. diff -urNp GraphicsMagick-1.3.23-orig/configure.ac GraphicsMagick-1.3.23/configure.ac
  2. --- GraphicsMagick-1.3.23-orig/configure.ac 2015-11-08 00:19:15.000000000 +0200
  3. +++ GraphicsMagick-1.3.23/configure.ac  2016-03-19 13:54:19.086982876 +0200
  4. @@ -1497,45 +1497,45 @@ AC_SUBST(LIB_TRIO)
  5.  
  6.  
  7.  #
  8. -# Optionally check for libltdl if using it is still enabled
  9. +# Optionally check for libdl if using it is still enabled
  10.  #
  11. -# Only use/depend on libtdl if we are building modules.  This is a
  12. +# Only use/depend on libdl if we are building modules.  This is a
  13.  # change from previous releases (prior to 1.3.17) which supported
  14. -# loaded modules via libtdl if shared libraries were built.  of
  15. +# loaded modules via libdl if shared libraries were built.  of
  16.  # whether modules are built or not.
  17. -have_ltdl='no'
  18. -LIB_LTDL=''
  19. +have_dl='no'
  20. +LIB_DL=''
  21.  if test "$build_modules" != 'no'
  22.  then
  23. -  AC_MSG_CHECKING([for libltdl ])
  24. +  AC_MSG_CHECKING([for libdl ])
  25.    AC_MSG_RESULT()
  26.    failed=0
  27.    passed=0
  28. -  AC_CHECK_HEADER([ltdl.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
  29. -  AC_CHECK_LIB([ltdl],[lt_dlinit],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
  30. -  AC_MSG_CHECKING([if libltdl package is complete])
  31. +  AC_CHECK_HEADER([dlfcn.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
  32. +  AC_CHECK_LIB([dl],[dlopen],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
  33. +  AC_MSG_CHECKING([if libdl package is complete])
  34.    if test $passed -gt 0
  35.    then
  36.      if test $failed -gt 0
  37.      then
  38.        AC_MSG_RESULT([no -- some components failed test])
  39. -      have_ltdl='no (failed tests)'
  40. +      have_dl='no (failed tests)'
  41.      else
  42. -      LIB_LTDL='-lltdl'
  43. -      LIBS="$LIB_LTDL $LIBS"
  44. -      AC_DEFINE(HasLTDL,1,[Define if using libltdl to support dynamically loadable modules])
  45. +      LIB_DL='-ldl'
  46. +      LIBS="$LIB_DL $LIBS"
  47. +      AC_DEFINE(HasDL,1,[Define if using libdl to support dynamically loadable modules])
  48.        AC_MSG_RESULT([yes])
  49. -      have_ltdl='yes'
  50. +      have_dl='yes'
  51.      fi
  52.    else
  53.      AC_MSG_RESULT([no])
  54.    fi
  55. -  if test "$have_ltdl" != 'yes'
  56. +  if test "$have_dl" != 'yes'
  57.    then
  58. -    AC_MSG_FAILURE([libltdl is required by modules build],[1])
  59. +    AC_MSG_FAILURE([libdl is required by modules build],[1])
  60.    fi
  61.  fi
  62. -AM_CONDITIONAL(WITH_LTDL, test "$have_ltdl" != 'no')
  63. +AM_CONDITIONAL(WITH_DL, test "$have_dl" != 'no')
  64.  
  65.  #
  66.  # Check for ZLIB
  67. @@ -3439,11 +3439,11 @@ fi
  68.  #
  69.  
  70.  # The build_modules variable is set to 'yes' if coders and filters are
  71. -# to be built as modules.  This requires libltdl ($LIB_LTDL).
  72. +# to be built as modules.  This requires libdl ($LIB_DL).
  73.  
  74.  if test "$build_modules" != 'no'
  75.  then
  76. -  MAGICK_DEP_LIBS="$LIBS_USER $LIB_LCMS $LIB_TTF $LIB_GS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_ZLIB $LIB_LTDL $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_OMP $LIB_UMEM $LIB_THREAD"
  77. +  MAGICK_DEP_LIBS="$LIBS_USER $LIB_LCMS $LIB_TTF $LIB_GS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_ZLIB $LIB_DL $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_OMP $LIB_UMEM $LIB_THREAD"
  78.  else
  79.    MAGICK_DEP_LIBS="$LIBS_USER $LIB_JBIG $LIB_WEBP $LIB_LCMS $LIB_TIFF $LIB_TTF $LIB_JP2 $LIB_JPEG $LIB_GS $LIB_PNG $LIB_FPX $LIB_WMF $LIB_DPS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_XML $LIB_ZLIB $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_OMP $LIB_UMEM $LIB_THREAD"
  80.  fi
  81. diff -urNp GraphicsMagick-1.3.23-orig/magick/magick_config.h.in GraphicsMagick-1.3.23/magick/magick_config.h.in
  82. --- GraphicsMagick-1.3.23-orig/magick/magick_config.h.in    2015-11-08 00:19:47.000000000 +0200
  83. +++ GraphicsMagick-1.3.23/magick/magick_config.h.in 2016-03-19 13:54:19.087983003 +0200
  84. @@ -391,7 +391,7 @@
  85.  #undef HasLCMS
  86.  
  87.  /* Define if using libltdl to support dynamically loadable modules */
  88. -#undef HasLTDL
  89. +#undef HasDL
  90.  
  91.  /* Define if you have lzma compression library */
  92.  #undef HasLZMA
  93. diff -urNp GraphicsMagick-1.3.23-orig/magick/module.c GraphicsMagick-1.3.23/magick/module.c
  94. --- GraphicsMagick-1.3.23-orig/magick/module.c  2015-10-04 22:35:34.000000000 +0300
  95. +++ GraphicsMagick-1.3.23/magick/module.c   2016-03-19 13:54:57.705891141 +0200
  96. @@ -47,20 +47,18 @@
  97.  #include "magick/map.h"
  98.  #include "magick/module.h"
  99.  #include "magick/utility.h"
  100. -#if defined(HasLTDL)
  101. -#  include "ltdl.h"
  102. -   typedef lt_dlhandle ModuleHandle;
  103. -#else
  104. -   typedef void *ModuleHandle;
  105. +#if defined(HasDL)
  106. +#  include <dlfcn.h>
  107.  #endif
  108. +typedef void *ModuleHandle;
  109.  
  110.  /*
  111.    Define declarations.
  112.  */
  113.  #define MAX_MODULES 511 /* Maximum number of modules supported by build. */
  114.  #define ModuleFilename  "modules.mgk"
  115. -#if defined(HasLTDL)
  116. -#  define ModuleGlobExpression "*.la"
  117. +#if defined(HasDL)
  118. +#  define ModuleGlobExpression "*.so"
  119.  #else
  120.  #  if defined(_DEBUG)
  121.  #    define ModuleGlobExpression "IM_MOD_DB_*.dll"
  122. @@ -261,11 +259,6 @@ static MagickMap
  123.  static MagickMap
  124.    filter_path_map = (MagickMap) NULL;
  125.  
  126. -/*
  127. -  Set to True if libltdl has been initialized.
  128. -*/
  129. -static unsigned int
  130. -  ltdl_initialized=False;
  131.  
  132.  /*
  133.    Forward declarations.
  134. @@ -411,18 +404,6 @@ DestroyModuleInfo(void)
  135.      DestroyModuleInfoEntry(module_info);
  136.    }
  137.    module_list=(ModuleInfo *) NULL;
  138. -  /*
  139. -    Destroy the libltdl environment unless Jasper is used since Jasper
  140. -    sometimes registers an atexit() handler to destroy itself and this
  141. -    causes a crash if the Jasper library is already unloaded.
  142. -  */
  143. -  if (ltdl_initialized)
  144. -    {
  145. -#if !defined(HasJP2)
  146. -      (void) lt_dlexit();
  147. -#endif
  148. -      ltdl_initialized=False;
  149. -    }
  150.  }
  151.  
  152.  /*
  153. @@ -496,13 +477,13 @@ ExecuteModuleProcess(const char *tag,Ima
  154.        return(MagickFail);
  155.  
  156.      /* Open the module */
  157. -    handle=lt_dlopen(module_path);
  158. +    handle=dlopen(module_path, RTLD_LAZY | RTLD_NOW);
  159.      if (handle == (ModuleHandle) NULL)
  160.        {
  161.          char
  162.            message[MaxTextExtent];
  163.          
  164. -        FormatString(message,"\"%.256s: %.256s\"",module_path,lt_dlerror());
  165. +        FormatString(message,"\"%.256s: %.256s\"",module_path,dlerror());
  166.          ThrowException(&(*image)->exception,ModuleError,UnableToLoadModule,
  167.            message);
  168.          return(status);
  169. @@ -522,7 +503,7 @@ ExecuteModuleProcess(const char *tag,Ima
  170.      FormatString(method_name,"%.64sImage",tag);
  171.  #endif
  172.      method=(unsigned int (*)(Image **,const int,char **))
  173. -      lt_dlsym(handle,method_name);
  174. +      dlsym(handle,method_name);
  175.  
  176.      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
  177.                            "Invoking \"%.1024s\" filter module",tag);
  178. @@ -536,7 +517,7 @@ ExecuteModuleProcess(const char *tag,Ima
  179.  
  180.    }
  181.    /* Close the module */
  182. -  (void) lt_dlclose(handle);
  183. +  dlclose(handle);
  184.    return(status);
  185.  }
  186.  
  187. @@ -923,13 +904,6 @@ InitializeMagickModules(void)
  188.        /*
  189.          Read module aliases file.
  190.        */
  191. -      if (!ltdl_initialized)
  192. -        {
  193. -          if (lt_dlinit() != 0)
  194. -            MagickFatalError(ModuleFatalError,
  195. -              UnableToInitializeModuleLoader,lt_dlerror());
  196. -          ltdl_initialized=True;
  197. -        }
  198.        (void) ReadModuleConfigureFile(ModuleFilename,0,&exception);
  199.      }
  200.    (void) InitializeModuleSearchPath(MagickCoderModule,&exception);
  201. @@ -1476,10 +1450,10 @@ OpenModule(const char *module,ExceptionI
  202.      (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
  203.        "Opening module at path \"%s\" ...", path);
  204.  
  205. -    handle=lt_dlopen(path);
  206. +    handle=dlopen(path, RTLD_LAZY|RTLD_NOW);
  207.      if (handle == (ModuleHandle) NULL)
  208.        {
  209. -        FormatString(message,"\"%.1024s: %.1024s\"",path,lt_dlerror());
  210. +        FormatString(message,"\"%.1024s: %.1024s\"",path,dlerror());
  211.          ThrowException(exception,ModuleError,UnableToLoadModule,message);
  212.          return(MagickFail);
  213.        }
  214. @@ -1489,7 +1463,7 @@ OpenModule(const char *module,ExceptionI
  215.      coder_info=SetCoderInfo(module_name);
  216.      if (coder_info == (CoderInfo*) NULL)
  217.        {
  218. -        (void) lt_dlclose(handle);
  219. +        (void) dlclose(handle);
  220.          return(MagickFail);
  221.        }
  222.      coder_info->handle=handle;
  223. @@ -1500,10 +1474,10 @@ OpenModule(const char *module,ExceptionI
  224.        Locate and record RegisterFORMATImage function
  225.      */
  226.      TagToFunctionName(module_name,"Register%sImage",name);
  227. -    coder_info->register_function=(void (*)(void)) lt_dlsym(handle,name);
  228. +    coder_info->register_function=(void (*)(void)) dlsym(handle,name);
  229.      if (coder_info->register_function == (void (*)(void)) NULL)
  230.        {
  231. -        FormatString(message,"\"%.1024s: %.1024s\"",module_name,lt_dlerror());
  232. +        FormatString(message,"\"%.1024s: %.1024s\"",module_name,dlerror());
  233.          ThrowException(exception,ModuleError,UnableToRegisterImageFormat,
  234.            message);
  235.          return(MagickFail);
  236. @@ -1517,10 +1491,10 @@ OpenModule(const char *module,ExceptionI
  237.        Locate and record UnregisterFORMATImage function
  238.      */
  239.      TagToFunctionName(module_name,"Unregister%sImage",name);
  240. -    coder_info->unregister_function=(void (*)(void)) lt_dlsym(handle,name);
  241. +    coder_info->unregister_function=(void (*)(void)) dlsym(handle,name);
  242.      if (coder_info->unregister_function == (void (*)(void)) NULL)
  243.        {
  244. -        FormatString(message,"\"%.1024s: %.1024s\"",module_name,lt_dlerror());
  245. +        FormatString(message,"\"%.1024s: %.1024s\"",module_name,dlerror());
  246.          ThrowException(exception,ModuleError,UnableToRegisterImageFormat,
  247.            message);
  248.          return(MagickFail);
  249. @@ -2037,8 +2011,8 @@ TagToCoderModuleName(const char *tag,cha
  250.  {
  251.    assert(tag != (char *) NULL);
  252.    assert(module_name != (char *) NULL);
  253. -#if defined(HasLTDL)
  254. -  (void) FormatString(module_name,"%.1024s.la",tag);
  255. +#if defined(HasDL)
  256. +  (void) FormatString(module_name,"%.1024s.so",tag);
  257.    (void) LocaleLower(module_name);
  258.  #else
  259.  #if defined(MSWINDOWS)
  260. @@ -2053,7 +2027,7 @@ TagToCoderModuleName(const char *tag,cha
  261.  #  endif /* defined(_DEBUG) */
  262.      }
  263.  #endif  /* defined(MSWINDOWS) */
  264. -#endif /* defined(HasLTDL) */
  265. +#endif /* defined(HasDL) */
  266.  }
  267.  
  268.  /*
  269. @@ -2084,8 +2058,8 @@ TagToFilterModuleName(const char *tag, c
  270.  {
  271.    assert(tag != (char *) NULL);
  272.    assert(module_name != (char *) NULL);
  273. -#if defined(HasLTDL)
  274. -  (void) FormatString(module_name,"%.1024s.la",tag);
  275. +#if defined(HasDL)
  276. +  (void) FormatString(module_name,"%.1024s.so",tag);
  277.    (void) LocaleLower(module_name);
  278.  #else
  279.    (void) FormatString(module_name,"%.1024s.dll",tag);
  280. @@ -2106,7 +2080,7 @@ TagToFilterModuleName(const char *tag, c
  281.  %  TagToFunctionName() formats the module tag name to a string using the
  282.  %  upper-case tag name as the input string, and a user-provided format.
  283.  %  This function is used to prepare the RegisterTAGImage and UnregisterTAGImage
  284. -%  function names passed lt_dlsym.
  285. +%  function names passed dlsym.
  286.  %
  287.  %  The format of the TagToFunctionName method is:
  288.  %
  289. @@ -2197,10 +2171,9 @@ UnloadModule(const CoderInfo *coder_info
  290.    */
  291.    if ( strcmp("JP2",coder_info->tag) != 0 )
  292.      {
  293. -      if (lt_dlclose((ModuleHandle) coder_info->handle))
  294. +      if (dlclose((ModuleHandle) coder_info->handle))
  295.          {
  296. -          FormatString(message,"\"%.1024s: %.1024s\"",coder_info->tag,
  297. -                       lt_dlerror());
  298. +          FormatString(message,"\"%.1024s: %.1024s\"",coder_info->tag,dlerror());
  299.            ThrowException(exception,ModuleError,FailedToCloseModule,message);
  300.            status=False;
  301.          }
  302. diff -urNp GraphicsMagick-1.3.23-orig/magick/nt_base.c GraphicsMagick-1.3.23/magick/nt_base.c
  303. --- GraphicsMagick-1.3.23-orig/magick/nt_base.c 2015-10-04 22:35:34.000000000 +0300
  304. +++ GraphicsMagick-1.3.23/magick/nt_base.c  2016-03-19 13:54:19.090983385 +0200
  305. @@ -40,15 +40,15 @@
  306.  #include "magick/magick.h"
  307.  #include "magick/utility.h"
  308.  #include "magick/version.h"
  309. -#if defined(HasLTDL)
  310. -#  include "ltdl.h"
  311. +#if defined(HasDL)
  312. +#  include "dlfcn.h"
  313.  #endif /* defined(HasLTDL) */
  314.  #include "magick/nt_base.h"
  315.  
  316.  /*
  317.    Static declarations.
  318.  */
  319. -#if !defined(HasLTDL)
  320. +#if !defined(HasDL)
  321.  static char
  322.    *NTslsearchpath = (char *) NULL;
  323.  #endif
  324. @@ -556,7 +556,7 @@ NTInitializeExceptionHandlers()
  325.    (void) SetUnhandledExceptionFilter(MagickUnhandledExceptionFilter);
  326.  }
  327.  
  328. -#if !defined(HasLTDL)
  329. +#if !defined(HasDL)
  330.  /*
  331.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  332.  %                                                                             %
  333. @@ -829,7 +829,7 @@ MagickExport void *NTdlsym(void *handle,
  334.      return((void *) NULL);
  335.    return((void *) lpfnDllFunc1);
  336.  }
  337. -#endif /* !defined(HasLTDL) */
  338. +#endif /* !defined(HasDL) */
  339.  
  340.  /*
  341.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  342. diff -urNp GraphicsMagick-1.3.23-orig/magick/nt_base.h GraphicsMagick-1.3.23/magick/nt_base.h
  343. --- GraphicsMagick-1.3.23-orig/magick/nt_base.h 2015-10-04 22:35:34.000000000 +0300
  344. +++ GraphicsMagick-1.3.23/magick/nt_base.h  2016-03-19 13:54:19.090983385 +0200
  345. @@ -366,7 +366,7 @@ extern MagickExport int
  346.  /*
  347.    libltdl-like module loader wrappers
  348.  */
  349. -#if !defined(HasLTDL)
  350. +#if !defined(HasDL)
  351.  extern MagickExport void
  352.    *NTdlopen(const char *filename),
  353.    *NTdlsym(void *handle, const char *name);
  354. @@ -387,7 +387,7 @@ extern MagickExport const char
  355.  #define lt_dlopen(filename) NTdlopen(filename)
  356.  #define lt_dlsetsearchpath(path) NTdlsetsearchpath(path)
  357.  #define lt_dlsym(handle,name) NTdlsym(handle,name)
  358. -#endif /* !defined(HasLTDL) */
  359. +#endif /* !defined(HasDL) */
  360.    
  361.  extern MagickExport unsigned char
  362.    *NTResourceToBlob(const char *);
  363. diff -urNp GraphicsMagick-1.3.23-orig/magick/studio.h GraphicsMagick-1.3.23/magick/studio.h
  364. --- GraphicsMagick-1.3.23-orig/magick/studio.h  2015-11-08 00:19:15.000000000 +0200
  365. +++ GraphicsMagick-1.3.23/magick/studio.h   2016-03-19 13:54:19.091983512 +0200
  366. @@ -409,7 +409,7 @@ extern int vsnprintf(char *s, size_t n,
  367.  #  define PATH_MAX 4096
  368.  #endif
  369.  
  370. -#if defined(HasLTDL) || ( defined(MSWINDOWS) && defined(_DLL) )
  371. +#if defined(HasDL) || ( defined(MSWINDOWS) && defined(_DLL) )
  372.  #  define SupportMagickModules
  373.  #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement