Hello,
I ported IMLIB2 to Mingw+msys and I also included some fixes for Cygwin.
List of Changes:
1) Added test for mmap support. This test is required because TGA needs it (but
why???). By conseguence, the TGA support becomes configurable.
2) Added test for sigjmp_buf support. If it is not supported, it will fall to
usual jmp_buf support (libjpeg for win32/win64 is compiled in that manner).
3) Added the ability to configure the flags to libtool with LT_LDFLAGS
variable. For generating a DLL with "--enable-shared" option it is required to
add "-no-undefined" to the link stage.
4) Added symbol IMLIB2_IS_COMPILING: if it's declared, it means that we are
compiling the sources of IMLIB2 (used into Imlib2.h).
5) ImLib2.H has also been fixed because dllimport/dllexport stuff was wrong.
6) Added dlfcn-win32.c and dlfcn-win32.h for supporting shared modules support.
Unfortunately the usual dlfcn package does not work... libtool complains with a
message like "libtool has no real life with library -ldl".
7) Added test if mkstemp() exists; if it does not, now there is the chance to
describe a replacement into common.h
8) Added test if pwd.h exists and file.h has been fixed with HAVE_PWD_H.
9) If S_IRGRP or S_IROTH do not exists, they will fall to S_IRUSR.
10) Some OS2 fixes are good for WIN32 too, so I added support for it too into
file.c and loader_gif.c
11) If ELOOP do not exist, the compilation is fixes by an #ifdef...#endif.
12) Since support for the dlfcn.h was already tested, I added the checks on
HAVE_DLFCN_H into image.h and script.h. In the future it will be possible to
add support for other dynamic loaders in the same manner I did for Win32.
I hope you will find it useful.
Sincerely,
Carlo Bramini.
diff -r -u imlib2-1.4.1-old/configure.in imlib2-1.4.1-new/configure.in
--- imlib2-1.4.1-old/configure.in 2008-06-06 03:43:19 +0000
+++ imlib2-1.4.1-new/configure.in 2008-10-14 17:28:02 +0000
@@ -86,6 +86,9 @@
]
)
+dnl Used for DLL import/export stuff.
+AC_DEFINE(IMLIB2_IS_COMPILING, 1, [Always defined])
+
AC_MSG_CHECKING(whether to enable x86 mmx support)
if test x$mmx = xyes; then
AC_DEFINE(DO_MMX_ASM, 1, [enabling MMX Assembly])
@@ -510,10 +513,62 @@
AM_CONDITIONAL(BUILD_ID3_LOADER, test "$id3_ok" = yes)
AC_SUBST(ID3LIBS)
+dnl Test if mmap is supported
+AC_FUNC_MMAP
+
+AC_MSG_CHECKING(whether to enable tga support)
+AC_ARG_WITH([tga],
+ [AC_HELP_STRING([--without-tga], [Disable TGA loader])],
+ [
+ if test "$withval" = no ; then
+ tga_loader=no
+ else
+ tga_loader=yes
+ fi
+ ],
+ [ tga_loader=auto ]
+)
+AC_MSG_RESULT($tga_loader)
+
+if test "$tga_loader" != no ; then
+ if test "x$HAVE_MMAP" = "xyes" ; then
+ tga_ok=yes
+ else
+ tga_ok=no
+ fi
+fi
+AM_CONDITIONAL(BUILD_TGA_LOADER, test "$tga_ok" = yes)
+
if test "x$enable_visibility_hiding" = xyes ; then
CPPFLAGS="$CPPFLAGS -fvisibility=hidden"
fi
+dnl Check which jump code is supported
+AC_TRY_COMPILE(
+ [#include <setjmp.h>],
+ [sigjmp_buf env;
+ while (! sigsetjmp (env, 1))
+ siglongjmp (env, 1);
+ ],
+ [AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available.])])
+
+dnl Check some standard(?) functions
+AC_CHECK_FUNCS([mkstemp])
+
+dnl Check some standard header files
+AC_CHECK_HEADERS([pwd.h windows.h])
+
+dnl Check for platform dependant flags for libtool
+case $host_os in
+ *mingw* | *cygwin*)
+ LT_LDFLAGS="-no-undefined"
+ ;;
+ *)
+ LT_LDFLAGS=""
+ ;;
+esac
+AC_SUBST(LT_LDFLAGS)
+
AC_OUTPUT([
Makefile
imlib2.pc
@@ -556,6 +611,7 @@
echo " ZLIB....................: $zlib_ok"
echo " BZIP2...................: $bz2_ok"
echo " ID3.....................: $id3_ok"
+echo " TGA.....................: $tga_ok"
echo " X.......................: $have_x"
echo
echo
diff -r -u imlib2-1.4.1-old/src/lib/Imlib2.h imlib2-1.4.1-new/src/lib/Imlib2.h
--- imlib2-1.4.1-old/src/lib/Imlib2.h 2007-11-05 08:02:28 +0000
+++ imlib2-1.4.1-new/src/lib/Imlib2.h 2008-10-14 17:49:30 +0000
@@ -5,8 +5,12 @@
# undef EAPI
# endif
# ifdef WIN32
-# ifdef BUILDING_DLL
-# define EAPI __declspec(dllexport)
+# ifdef IMLIB2_IS_COMPILING
+# ifdef DLL_EXPORT
+# define EAPI __declspec(dllexport)
+# else
+# define EAPI
+# endif
# else
# define EAPI __declspec(dllimport)
# endif
diff -r -u imlib2-1.4.1-old/src/lib/Makefile.am
imlib2-1.4.1-new/src/lib/Makefile.am
--- imlib2-1.4.1-old/src/lib/Makefile.am 2008-06-06 03:42:29 +0000
+++ imlib2-1.4.1-new/src/lib/Makefile.am 2008-10-14 17:29:58 +0000
@@ -18,6 +18,7 @@
common.h \
context.c \
context.h \
+dlfcn-win32.c \
draw.c \
draw.h \
dynamic_filters.c \
@@ -98,5 +99,5 @@
libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h
endif
endif
-libImlib2_la_LDFLAGS = -version-info @lt_version@
+libImlib2_la_LDFLAGS = -version-info @lt_version@ $(LT_LDFLAGS)
diff -r -u imlib2-1.4.1-old/src/lib/common.h imlib2-1.4.1-new/src/lib/common.h
--- imlib2-1.4.1-old/src/lib/common.h 2007-11-05 08:02:28 +0000
+++ imlib2-1.4.1-new/src/lib/common.h 2008-10-14 17:39:08 +0000
@@ -16,6 +16,15 @@
#include <sys/types.h>
#endif
+#ifndef HAVE_MKSTEMP
+# ifdef WIN32
+# include <fcntl.h>
+# define mkstemp(p) _open(_mktemp(p), _O_CREAT | _O_SHORT_LIVED | _O_EXCL)
+# else
+# error Missing mkstemp() function.
+# endif
+#endif
+
#if defined(__GNUC__) && (__GNUC__ >= 4)
#define __hidden __attribute__((visibility("hidden")))
#else
diff -r -u imlib2-1.4.1-old/src/lib/dlfcn-win32.c
imlib2-1.4.1-new/src/lib/dlfcn-win32.c
--- imlib2-1.4.1-old/src/lib/dlfcn-win32.c 2008-10-14 18:04:52 +0000
+++ imlib2-1.4.1-new/src/lib/dlfcn-win32.c 2008-10-14 16:18:02 +0000
@@ -0,0 +1,29 @@
+#include "config.h"
+
+#if defined WIN32 && !defined HAVE_DLFCN_H
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+void *win32_dlopen (const char *file, int mode)
+{
+ return (void *)LoadLibraryA(file);
+}
+
+int win32_dlclose(void *handle)
+{
+ FreeLibrary((HANDLE)(handle));
+ return 0;
+}
+
+void *win32_dlsym(void *handle, const char *name)
+{
+ return (void *)GetProcAddress((HANDLE)(handle), name);
+}
+
+char *win32_dlerror(void)
+{
+ return "Unknown";
+}
+
+#endif
diff -r -u imlib2-1.4.1-old/src/lib/dlfcn-win32.h
imlib2-1.4.1-new/src/lib/dlfcn-win32.h
--- imlib2-1.4.1-old/src/lib/dlfcn-win32.h 2008-10-14 18:05:10 +0000
+++ imlib2-1.4.1-new/src/lib/dlfcn-win32.h 2008-10-14 17:55:18 +0000
@@ -0,0 +1,23 @@
+#ifndef __DLFCN_WIN32_H__
+#define __DLFCN_WIN32_H__
+
+#define RTLD_LAZY 0
+#define RTLD_NOW 0
+
+#define RTLD_GLOBAL 0
+#define RTLD_LOCAL 0
+
+#define RTLD_DEFAULT 0
+#define RTLD_NEXT 0
+
+void *win32_dlopen (const char *file, int mode);
+int win32_dlclose(void *handle);
+void *win32_dlsym(void *handle, const char *name);
+char *win32_dlerror(void);
+
+#define dlopen(_file, _mode) win32_dlopen(_file, _mode)
+#define dlclose(_handle) win32_dlclose(_handle)
+#define dlsym(_handle, _name) win32_dlsym(_handle, _name)
+#define dlerror() win32_dlerror()
+
+#endif
diff -r -u imlib2-1.4.1-old/src/lib/file.c imlib2-1.4.1-new/src/lib/file.c
--- imlib2-1.4.1-old/src/lib/file.c 2004-11-01 09:45:31 +0000
+++ imlib2-1.4.1-new/src/lib/file.c 2008-10-14 17:51:54 +0000
@@ -10,11 +10,21 @@
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_PWD_H
#include <pwd.h>
+#endif
#include "file.h"
static void __imlib_FileFieldWord(char *s, int num, char *wd);
+#ifndef S_IRGRP
+# define S_IRGRP S_IRUSR
+#endif
+
+#ifndef S_IROTH
+# define S_IROTH S_IRUSR
+#endif
+
char *
__imlib_FileKey(const char *file)
{
@@ -372,9 +382,15 @@
static int usr_uid = -1;
static char *usr_s = NULL;
char *s;
+
+#if defined __EMX__ || defined WIN32
+ if ((s = getenv("HOME")) != NULL)
+ return strdup(s);
+ else if ((s = getenv("TMP")) != NULL)
+ return strdup(s);
+#else
struct passwd *pwd;
-#ifndef __EMX__
s = getenv("HOME");
if (s)
return strdup(s);
@@ -392,11 +408,6 @@
usr_s = strdup(s);
return (s);
}
-#else
- if ((s = getenv("HOME")) != NULL)
- return strdup(s);
- else if ((s = getenv("TMP")) != NULL)
- return strdup(s);
#endif
return NULL;
}
diff -r -u imlib2-1.4.1-old/src/lib/image.c imlib2-1.4.1-new/src/lib/image.c
--- imlib2-1.4.1-old/src/lib/image.c 2007-05-20 13:26:25 +0000
+++ imlib2-1.4.1-new/src/lib/image.c 2008-10-14 17:53:25 +0000
@@ -1093,8 +1093,10 @@
*er = IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY;
else if (errno == EFAULT)
*er = IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE;
+#ifdef ELOOP
else if (errno == ELOOP)
*er = IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS;
+#endif
else if (errno == ENOMEM)
*er = IMLIB_LOAD_ERROR_OUT_OF_MEMORY;
else if (errno == EMFILE)
@@ -1305,8 +1307,10 @@
*er = IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY;
else if (errno == EFAULT)
*er = IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE;
+#ifdef ELOOP
else if (errno == ELOOP)
*er = IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS;
+#endif
else if (errno == ENOMEM)
*er = IMLIB_LOAD_ERROR_OUT_OF_MEMORY;
else if (errno == EMFILE)
diff -r -u imlib2-1.4.1-old/src/lib/image.h imlib2-1.4.1-new/src/lib/image.h
--- imlib2-1.4.1-old/src/lib/image.h 2007-04-09 12:55:29 +0000
+++ imlib2-1.4.1-new/src/lib/image.h 2008-10-14 17:37:04 +0000
@@ -8,7 +8,13 @@
# define X_DISPLAY_MISSING
# endif
-# include <dlfcn.h>
+# ifdef HAVE_DLFCN_H
+# include <dlfcn.h>
+# elif defined HAVE_WINDOWS_H
+# include <dlfcn-win32.h>
+# else
+# error Missing DL engine.
+# endif
# include <Imlib2.h>
# ifndef RTLD_LOCAL
diff -r -u imlib2-1.4.1-old/src/lib/script.h imlib2-1.4.1-new/src/lib/script.h
--- imlib2-1.4.1-old/src/lib/script.h 2006-04-09 08:12:51 +0000
+++ imlib2-1.4.1-new/src/lib/script.h 2008-10-14 17:37:32 +0000
@@ -1,7 +1,13 @@
#ifndef _DYN_FUNCTION_H_
#define _DYN_FUNCTION_H_
-#include <dlfcn.h>
+# ifdef HAVE_DLFCN_H
+# include <dlfcn.h>
+# elif defined HAVE_WINDOWS_H
+# include <dlfcn-win32.h>
+# else
+# error Missing DL engine.
+# endif
#ifndef BUILD_X11
# ifndef X_DISPLAY_MISSING
diff -r -u imlib2-1.4.1-old/src/modules/loaders/Makefile.am
imlib2-1.4.1-new/src/modules/loaders/Makefile.am
--- imlib2-1.4.1-old/src/modules/loaders/Makefile.am 2007-12-09 05:43:20
+0000
+++ imlib2-1.4.1-new/src/modules/loaders/Makefile.am 2008-10-14 17:31:16
+0000
@@ -30,6 +30,9 @@
if BUILD_ID3_LOADER
ID3_L = id3.la
endif
+if BUILD_TGA_LOADER
+TGA_L = tga.la
+endif
pkg_LTLIBRARIES = \
$(JPEG_L) \
@@ -43,59 +46,59 @@
argb.la \
bmp.la \
xpm.la \
-tga.la \
+$(TGA_L) \
lbm.la
EXTRA_DIST = loader_common.h
jpeg_la_SOURCES = loader_jpeg.c
-jpeg_la_LDFLAGS = -module -avoid-version
+jpeg_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
jpeg_la_LIBADD = @JPEGLIBS@ $(top_builddir)/src/lib/libImlib2.la
png_la_SOURCES = loader_png.c
-png_la_LDFLAGS = -module -avoid-version
+png_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
png_la_LIBADD = @PNG_LIBS@ $(top_builddir)/src/lib/libImlib2.la
tiff_la_SOURCES = loader_tiff.c
-tiff_la_LDFLAGS = -module -avoid-version
+tiff_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
tiff_la_LIBADD = @TIFFLIBS@ $(top_builddir)/src/lib/libImlib2.la
gif_la_SOURCES = loader_gif.c
-gif_la_LDFLAGS = -module -avoid-version
+gif_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
gif_la_LIBADD = @GIFLIBS@ $(top_builddir)/src/lib/libImlib2.la
zlib_la_SOURCES = loader_zlib.c
-zlib_la_LDFLAGS = -module -avoid-version
+zlib_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
zlib_la_LIBADD = @ZLIBLIBS@ $(top_builddir)/src/lib/libImlib2.la
bz2_la_SOURCES = loader_bz2.c
-bz2_la_LDFLAGS = -module -avoid-version
+bz2_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
bz2_la_LIBADD = @BZ2LIBS@ $(top_builddir)/src/lib/libImlib2.la
id3_la_SOURCES = loader_id3.c
-id3_la_LDFLAGS = -module -avoid-version
+id3_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
id3_la_LIBADD = @ID3LIBS@ $(top_builddir)/src/lib/libImlib2.la
pnm_la_SOURCES = loader_pnm.c
-pnm_la_LDFLAGS = -module -avoid-version
+pnm_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
pnm_la_LIBADD = $(top_builddir)/src/lib/libImlib2.la
argb_la_SOURCES = loader_argb.c
-argb_la_LDFLAGS = -module -avoid-version
+argb_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
argb_la_LIBADD = $(top_builddir)/src/lib/libImlib2.la
bmp_la_SOURCES = loader_bmp.c
-bmp_la_LDFLAGS = -module -avoid-version
+bmp_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
bmp_la_LIBADD = $(top_builddir)/src/lib/libImlib2.la
xpm_la_SOURCES = loader_xpm.c
-xpm_la_LDFLAGS = -module -avoid-version
+xpm_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
xpm_la_LIBADD = $(top_builddir)/src/lib/libImlib2.la
tga_la_SOURCES = loader_tga.c
-tga_la_LDFLAGS = -module -avoid-version
+tga_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
tga_la_LIBADD = $(top_builddir)/src/lib/libImlib2.la
lbm_la_SOURCES = loader_lbm.c
-lbm_la_LDFLAGS = -module -avoid-version
+lbm_la_LDFLAGS = -module -avoid-version $(LT_LDFLAGS)
lbm_la_LIBADD = $(top_builddir)/src/lib/libImlib2.la
diff -r -u imlib2-1.4.1-old/src/modules/loaders/loader_gif.c
imlib2-1.4.1-new/src/modules/loaders/loader_gif.c
--- imlib2-1.4.1-old/src/modules/loaders/loader_gif.c 2007-04-09 12:55:29
+0000
+++ imlib2-1.4.1-new/src/modules/loaders/loader_gif.c 2008-10-14 17:42:37
+0000
@@ -29,10 +29,10 @@
/* already data in this image - dont load it again */
if (im->data)
return 0;
-#ifndef __EMX__
- fd = open(im->real_file, O_RDONLY);
+#if defined __EMX__ || defined WIN32
+ fd = open(im->real_file, O_RDONLY | O_BINARY);
#else
- fd = open(im->real_file, O_RDONLY | O_BINARY);
+ fd = open(im->real_file, O_RDONLY);
#endif
if (fd < 0)
return 0;
diff -r -u imlib2-1.4.1-old/src/modules/loaders/loader_jpeg.c
imlib2-1.4.1-new/src/modules/loaders/loader_jpeg.c
--- imlib2-1.4.1-old/src/modules/loaders/loader_jpeg.c 2007-04-09 12:55:29
+0000
+++ imlib2-1.4.1-new/src/modules/loaders/loader_jpeg.c 2008-10-14 17:41:54
+0000
@@ -4,7 +4,11 @@
struct ImLib_JPEG_error_mgr {
struct jpeg_error_mgr pub;
+#ifdef HAVE_SIGJMP_BUF
sigjmp_buf setjmp_buffer;
+#else
+ jmp_buf jmp_buffer;
+#endif
};
typedef struct ImLib_JPEG_error_mgr *emptr;
@@ -15,7 +19,11 @@
errmgr = (emptr) cinfo->err;
/* cinfo->err->output_message(cinfo);*/
+#ifdef HAVE_SIGJMP_BUF
siglongjmp(errmgr->setjmp_buffer, 1);
+#else
+ longjmp(errmgr->jmp_buffer, 1);
+#endif
return;
}
@@ -60,7 +68,11 @@
jerr.pub.error_exit = _JPEGFatalErrorHandler;
jerr.pub.emit_message = _JPEGErrorHandler2;
jerr.pub.output_message = _JPEGErrorHandler;
+#ifdef HAVE_SIGJMP_BUF
if (sigsetjmp(jerr.setjmp_buffer, 1))
+#else
+ if (setjmp(jerr.jmp_buffer))
+#endif
{
jpeg_destroy_decompress(&cinfo);
fclose(f);
@@ -250,7 +262,11 @@
jerr.pub.emit_message = _JPEGErrorHandler2;
jerr.pub.output_message = _JPEGErrorHandler;
cinfo.err = jpeg_std_error(&(jerr.pub));
+#ifdef HAVE_SIGJMP_BUF
if (sigsetjmp(jerr.setjmp_buffer, 1))
+#else
+ if (setjmp(jerr.jmp_buffer))
+#endif
{
jpeg_destroy_compress(&cinfo);
free(buf);
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel