Glib/cygwin minor changes
- From: Stefan Ondrejicka <ondrej idata sk>
- To: gtk-devel-list gnome org
- Subject: Glib/cygwin minor changes
- Date: Wed, 6 Nov 2002 11:13:43 +0100 (CET)
Hello,
Here is patch which I made while building glib-2.0.7 on cygwin:
* configure.in: use AC_TRY_LINK instead of AC_TRY_COMPILE when testing
nl_langinfo(CODESET) because cygwin contains langinfo.h with
nl_langinfo() declaration but the function doesn't exist in cygwin
runtime. Add /lib/w32api to library search path on cygwin.
* glib/gutils.c (_glib_get_local_dir): on cygwin conditionaly returns
locale dir with win32 or unix path depend on glib instalation
* glib/gutils.h (G_WIN32_DLLMAIN_FOR_DLL_NAME): set posix path on
cygwin, don't define when compiling static glib
* glib/gthread.c:
* glib/gstrfuncs.c:
* glib/gmain.c: don't dllexport global variables when compiling static
glib library
* gmodule/gmodule-win32.c: on cygwin set "cyg" prefix for modules instead
of "lib" prefix used on mingw
I hope, that someone with CVS write access will apply this patch. When
building DLLs on cygwin there is problem with libtool when there is
missing option -mdll or -shared when linking the DLL and gcc complains
about undefined reference to WinMain 16, but it is probably problem with
used particular libtool version.
Best regards,
Stevo.
--
/> | Stefan Ondrejicka <ondrej idata sk>
/< | http://www.idata.sk/~ondrej/
[XXXXXX( O):::<===================================-
\<
\>
diff -ruN ../glib-2.0.7/configure.in ./configure.in
--- ../glib-2.0.7/configure.in 2002-11-04 21:17:05.000000000 +0100
+++ ./configure.in 2002-11-06 10:04:30.000000000 +0100
@@ -805,7 +805,7 @@
dnl Check for nl_langinfo and CODESET
AC_MSG_CHECKING([for nl_langinfo (CODESET)])
-AC_TRY_COMPILE([#include <langinfo.h>],
+AC_TRY_LINK([#include <langinfo.h>],
[char *codeset = nl_langinfo (CODESET);],
AC_DEFINE(HAVE_CODESET,1,[Have nl_langinfo (CODESET)])
have_codeset=yes,
@@ -1653,7 +1653,7 @@
case $host in
*-*-cygwin*)
- G_LIBS_EXTRA="-luser32 -lkernel32"
+ G_LIBS_EXTRA="-L/lib/w32api -luser32 -lkernel32"
;;
*-*-mingw*)
G_LIBS_EXTRA="-lwsock32"
diff -ruN ../glib-2.0.7/glib/gmain.c ./glib/gmain.c
--- ../glib-2.0.7/glib/gmain.c 2002-11-04 21:01:46.000000000 +0100
+++ ./glib/gmain.c 2002-11-06 10:05:42.000000000 +0100
@@ -221,7 +221,7 @@
static GMainContext *default_main_context;
static GSList *main_contexts_without_pipe = NULL;
-#if defined(G_PLATFORM_WIN32) && defined(__GNUC__)
+#if defined(G_PLATFORM_WIN32) && defined(__GNUC__) && !defined(GLIB_STATIC_COMPILATION)
__declspec(dllexport)
#endif
GSourceFuncs g_timeout_funcs =
@@ -232,7 +232,7 @@
NULL
};
-#if defined(G_PLATFORM_WIN32) && defined(__GNUC__)
+#if defined(G_PLATFORM_WIN32) && defined(__GNUC__) && !defined(GLIB_STATIC_COMPILATION)
__declspec(dllexport)
#endif
GSourceFuncs g_idle_funcs =
diff -ruN ../glib-2.0.7/glib/gstrfuncs.c ./glib/gstrfuncs.c
--- ../glib-2.0.7/glib/gstrfuncs.c 2002-11-04 21:01:46.000000000 +0100
+++ ./glib/gstrfuncs.c 2002-11-06 10:05:42.000000000 +0100
@@ -74,7 +74,7 @@
/* the upper 128 are all zeroes */
};
-#if defined(G_PLATFORM_WIN32) && defined(__GNUC__)
+#if defined(G_PLATFORM_WIN32) && defined(__GNUC__) && !defined(GLIB_STATIC_COMPILATION)
__declspec(dllexport)
#endif
const guint16 * const g_ascii_table = ascii_table_data;
diff -ruN ../glib-2.0.7/glib/gthread.c ./glib/gthread.c
--- ../glib-2.0.7/glib/gthread.c 2002-11-04 21:01:46.000000000 +0100
+++ ./glib/gthread.c 2002-11-06 10:05:42.000000000 +0100
@@ -116,7 +116,7 @@
gboolean g_thread_use_default_impl = TRUE;
gboolean g_threads_got_initialized = FALSE;
-#if defined(G_PLATFORM_WIN32) && defined(__GNUC__)
+#if defined(G_PLATFORM_WIN32) && defined(__GNUC__) && !defined(GLIB_STATIC_COMPILATION)
__declspec(dllexport)
#endif
GThreadFunctions g_thread_functions_for_glib_use = {
diff -ruN ../glib-2.0.7/glib/gutils.c ./glib/gutils.c
--- ../glib-2.0.7/glib/gutils.c 2002-03-08 06:48:03.000000000 +0100
+++ ./glib/gutils.c 2002-11-06 10:05:42.000000000 +0100
@@ -76,6 +76,10 @@
# include <direct.h>
#endif
+#ifdef G_WITH_CYGWIN
+# include <sys/cygwin.h>
+#endif
+
#ifdef HAVE_CODESET
#include <langinfo.h>
#endif
@@ -1075,8 +1079,20 @@
{
static const gchar *cache = NULL;
if (cache == NULL)
+#ifdef G_WITH_CYGWIN
+ {
+ cache = g_win32_get_package_installation_subdirectory
+ (GETTEXT_PACKAGE, dll_name, "lib/locale");
+ if (!g_file_test(cache, G_FILE_TEST_IS_DIR))
+ {
+ g_free(cache);
+ cache=g_strdup(GLIB_LOCALE_DIR);
+ }
+ }
+#else /* !G_WITH_CYGWIN */
cache = g_win32_get_package_installation_subdirectory
(GETTEXT_PACKAGE, dll_name, "lib\\locale");
+#endif /* !G_WITH_CYGWIN */
return cache;
}
diff -ruN ../glib-2.0.7/glib/gutils.h ./glib/gutils.h
--- ../glib-2.0.7/glib/gutils.h 2002-11-04 21:01:46.000000000 +0100
+++ ./glib/gutils.h 2002-11-06 10:05:42.000000000 +0100
@@ -335,14 +335,38 @@
* actual DLL name that the code being compiled will be included in.
* STATIC should be empty or 'static'. DLL_NAME is the name of the
* (pointer to the) char array where the DLL name will be stored. If
- * this is used, you must also include <windows.h>. If you need a more complex
- * DLL entry point function, you cannot use this.
+ * this is used, you must also include <windows.h> and for cygwin
+ * also <sys/cygwin.h>.
+ * If you need a more complex DLL entry point function, you cannot
+ * use this.
*
* On non-Windows platforms, expands to nothing.
*/
-#ifndef G_PLATFORM_WIN32
+#if !defined(G_PLATFORM_WIN32) && !defined(GLIB_STATIC_COMPILATION)
# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
+#elif defined(G_WITH_CYGWIN)
+# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) \
+static char *dll_name; \
+ \
+BOOL WINAPI \
+DllMain (HINSTANCE hinstDLL, \
+ DWORD fdwReason, \
+ LPVOID lpvReserved) \
+{ \
+ char bfr[MAX_PATH]; \
+ char bfrp[MAX_PATH]; \
+ switch (fdwReason) \
+ { \
+ case DLL_PROCESS_ATTACH: \
+ GetModuleFileName ((HMODULE) hinstDLL, bfr, sizeof (bfr)); \
+ cygwin_conv_to_posix_path(bfr, bfrp); \
+ dll_name = g_path_get_basename (bfrp); \
+ break; \
+ } \
+ \
+ return TRUE; \
+}
#else
# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) \
static char *dll_name; \
@@ -363,6 +387,6 @@
\
return TRUE; \
}
-#endif /* G_PLATFORM_WIN32 */
+#endif /* G_PLATFORM_WIN32 && !G_WITH_CYGWIN */
#endif /* __G_UTILS_H__ */
diff -ruN ../glib-2.0.7/gmodule/gmodule-win32.c ./gmodule/gmodule-win32.c
--- ../glib-2.0.7/gmodule/gmodule-win32.c 2001-11-24 19:53:01.000000000 +0100
+++ ./gmodule/gmodule-win32.c 2002-11-06 10:06:10.000000000 +0100
@@ -218,6 +218,12 @@
return p;
}
+#ifdef G_WITH_CYGWIN
+#define MODULE_PREFIX "cyg"
+#else
+#define MODULE_PREFIX "lib"
+#endif
+
static gchar*
_g_module_build_path (const gchar *directory,
const gchar *module_name)
@@ -229,14 +235,14 @@
if (directory && *directory)
if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, NULL);
- else if (strncmp (module_name, "lib", 3) == 0)
+ else if (strncmp (module_name, MODULE_PREFIX, 3) == 0)
return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, ".dll", NULL);
else
- return g_strconcat (directory, G_DIR_SEPARATOR_S, "lib", module_name, ".dll", NULL);
+ return g_strconcat (directory, G_DIR_SEPARATOR_S, MODULE_PREFIX, module_name, ".dll", NULL);
else if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
return g_strdup (module_name);
- else if (strncmp (module_name, "lib", 3) == 0)
+ else if (strncmp (module_name, MODULE_PREFIX, 3) == 0)
return g_strconcat (module_name, ".dll", NULL);
else
- return g_strconcat ("lib", module_name, ".dll", NULL);
+ return g_strconcat (MODULE_PREFIX, module_name, ".dll", NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]