Hi all,

I'm still working on getting wine going on hpux, and I thought I should 
submit patches for more of the changes I've made.  There were a couple of 
places in winegcc where there were some assumptions made about .so being 
the shared library extension and .exe.so being the executable suffix - 
There was a partial fix to handle .dylib for MacOS, but it wasn't well 
unified...   I've created defines for SHLIBSUFFIX and EXESUFFIX in 
utils.h, and changed the places where .so or .exe.so was used to use the 
right define.

This does slightly change the logic of the code though --- the way it was 
written before, winegcc would have (partially) done the right thing given 
a  .dylib file on linux, or given a .so file on MacOS...   I think this 
was just an unintended side-effect of the way things were implemented- but 
I'm not 100% sure...

I've attached the patches I came up with - does this look reasonable?

Warren


diff -ru clean/wine-20040914/tools/winegcc/utils.c wine-20040914/tools/winegcc/utils.c
--- clean/wine-20040914/tools/winegcc/utils.c   2004-03-22 19:14:54.000000000 -0500
+++ wine-20040914/tools/winegcc/utils.c 2004-10-08 12:02:26.000000000 -0400
@@ -219,8 +219,7 @@
     if (strendswith(filename, ".o")) return file_obj;
     if (strendswith(filename, ".a")) return file_arh;
     if (strendswith(filename, ".res")) return file_res;
-    if (strendswith(filename, ".so")) return file_so;
-    if (strendswith(filename, ".dylib")) return file_so;
+    if (strendswith(filename, SHLIBSUFFIX)) return file_so;
     if (strendswith(filename, ".def")) return file_def;
     if (strendswith(filename, ".spec")) return file_spec;
     if (strendswith(filename, ".rc")) return file_rc;
@@ -246,14 +245,11 @@
 
 static file_type guess_lib_type(const char* dir, const char* library, char** file)
 {
-    /* Unix shared object */
-    if ((*file = try_lib_path(dir, "lib", library, ".so", file_so)))
+    /* Unix shared object or Mach-O (Darwin/Mac OS X) Dynamic Library,
+       which behaves mostly like .so */
+    if ((*file = try_lib_path(dir, "lib", library, SHLIBSUFFIX, file_so)))
        return file_so;
        
-    /* Mach-O (Darwin/Mac OS X) Dynamic Library behaves mostly like .so */
-    if ((*file = try_lib_path(dir, "lib", library, ".dylib", file_so)))
-       return file_so;
-
     /* Windows DLL */
     if ((*file = try_lib_path(dir, "lib", library, ".def", file_def)))
        return file_dll;
diff -ru clean/wine-20040914/tools/winegcc/utils.h wine-20040914/tools/winegcc/utils.h
--- clean/wine-20040914/tools/winegcc/utils.h   2004-03-22 19:14:54.000000000 -0500
+++ wine-20040914/tools/winegcc/utils.h 2004-10-08 11:56:55.000000000 -0400
@@ -65,3 +65,15 @@
 void spawn(const strarray* prefix, const strarray* arr);
 
 extern int verbose;
+
+#ifdef __hpux
+#define EXESUFFIX    ".exe.sl"
+#define SHLIBSUFFIX  ".sl"
+#elif defined(__APPLE__)
+#define EXESUFFIX    ".exe.dylib"
+#define SHLIBSUFFIX  ".dylib"
+#else
+#define EXESUFFIX    ".exe.so"
+#define SHLIBSUFFIX  ".so"
+#endif
+
diff -ru clean/wine-20040914/tools/winegcc/winegcc.c 
wine-20040914/tools/winegcc/winegcc.c
--- clean/wine-20040914/tools/winegcc/winegcc.c 2004-08-18 21:20:45.000000000 -0400
+++ wine-20040914/tools/winegcc/winegcc.c       2004-10-08 12:03:51.000000000 -0400
@@ -354,7 +354,7 @@
      *    -lxxx:  xxx is an unsorted library
      *    -oxxx:  xxx is an object (.o)
      *    -rxxx:  xxx is a resource (.res)
-     *    -sxxx:  xxx is a shared lib (.so)
+     *    -sxxx:  xxx is a shared lib (.so or .sl)
      *    -xlll:  lll is the language (c, c++, etc.)
      */
 
@@ -363,19 +363,20 @@
     output_file = strdup( opts->output_name ? opts->output_name : "a.out" );
 
     /* 'winegcc -o app xxx.exe.so' only creates the load script */
-    if (opts->files->size == 1 && strendswith(opts->files->base[0], ".exe.so"))
+    if (opts->files->size == 1 && strendswith(opts->files->base[0], EXESUFFIX))
     {
        create_file(output_file, 0755, app_loader_template, opts->files->base[0]);
        return;
     }
 
     /* generate app loader only for .exe */
-    if (opts->shared || strendswith(output_file, ".exe.so"))
+    if (opts->shared || strendswith(output_file, EXESUFFIX))
        generate_app_loader = 0;
 
-    /* normalize the filename a bit: strip .so, ensure it has proper ext */
-    if (strendswith(output_file, ".so")) 
-       output_file[strlen(output_file) - 3] = 0;
+    /* normalize the filename a bit: strip shared lib extension 
+       (.so, .sl, or .dylib) and  ensure it has proper ext */
+    if (strendswith(output_file, SHLIBSUFFIX)) 
+      output_file[strlen(output_file) - strlen(SHLIBSUFFIX)] = 0;
     if (opts->shared)
     {
        if ((output_name = strrchr(output_file, '/'))) output_name++;
@@ -545,7 +546,7 @@
     strarray_addall(link_args, strarray_fromstring(LDDLLFLAGS, " "));
 
     strarray_add(link_args, "-o");
-    strarray_add(link_args, strmake("%s.so", output_file));
+    strarray_add(link_args, strmake("%s%s", output_file, SHLIBSUFFIX));
 
     for ( j = 0 ; j < opts->linker_args->size ; j++ ) 
         strarray_add(link_args, opts->linker_args->base[j]);
@@ -584,7 +585,7 @@
     if (generate_app_loader)
     {
         if (strendswith(output_file, ".exe")) output_file[strlen(output_file) - 4] = 
0;
-        create_file(output_file, 0755, app_loader_template, strmake("%s.exe.so", 
output_name));
+        create_file(output_file, 0755, app_loader_template, strmake("%s%s", 
output_name, EXESUFFIX));
     }
 }
 
=

Reply via email to