[winegcc10] Search standard libraries last

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is needed for winegcc to build wine itself

Changelog
  + add standard dll path last instead of first
  + Add standard lib path as well
  + Remove . from default library search path
  + -lwine needs passed in -L paths

diff -u -r tools/winegcc.09/Makefile.in tools/winegcc/Makefile.in
--- tools/winegcc.09/Makefile.in	2003-09-16 08:08:11.000000000 +0100
+++ tools/winegcc/Makefile.in	2003-09-17 14:39:00.000000000 +0100
@@ -1,5 +1,5 @@
-DEFS      = -DINCLUDEDIR="\"$(includedir)\"" -DDLLDIR="\"$(dlldir)\""
+DEFS      = -DINCLUDEDIR="\"$(includedir)\"" -DDLLDIR="\"$(dlldir)\"" -DLIBDIR="\"$(libdir)\""
 TOPSRCDIR = @top_srcdir@
 TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
--- tools/winegcc.09/winewrap.c	2003-09-17 14:12:20.000000000 +0100
+++ tools/winegcc/winewrap.c	2003-09-18 11:20:13.000000000 +0100
@@ -211,7 +211,7 @@
 ;
 
 static char *output_name = "a.out";
-static strarray *arh_files, *dll_files, *lib_files, *llib_paths, *lib_paths, *obj_files;
+static strarray *arh_files, *dll_files, *llib_paths, *lib_paths, *obj_files;
 static int keep_generated = 0;
 
 static void rm_temp_file(const char *file)
@@ -280,7 +280,7 @@
     return try_path(path, name, "a");
 }
 
-/* open the .def library for a given dll */
+/* find the .def library for a given dll */
 static char *find_dll(const char *name)
 {
     char *fullname;
@@ -290,13 +290,13 @@
     {
         if ((fullname = try_dll_path( lib_paths->base[i], name ))) return fullname;
     }
-    return try_dll_path( ".", name );
+    return NULL;
 }
 
 /* find a static library */
 static char *find_lib(const char *name)
 {
-    static const char* std_paths[] = { ".", "/usr/lib", "/usr/local/lib" };
+    static const char* std_paths[] = { "/usr/lib", "/usr/local/lib" };
     char *fullname;
     int i;
     
@@ -319,7 +319,7 @@
     strarray_add(llib_paths, strmake("-L%s", path));
 }
 
-static void add_lib_file(const char* library)
+static void sort_lib_file(const char* library)
 {
     char *lib;
     
@@ -329,19 +329,36 @@
     }
     else if ((lib = find_lib(library)))
     {
+	/* winebuild likes the full path for .a files */
         strarray_add(arh_files, lib);
     }
     else
     {
-        strarray_add(lib_files, strmake("-l%s", library));
+        /* Probably one of:
+	 * .def - which winebuild won't find
+	 * .so  - which winebuild doesn't support
+	 * .a   - which gcc won't find 
+	 */
+        fprintf(stderr, "Ignoring library %s\n", library);
+    }
+}
+
+static void sort_lib_files(strarray *lib_files)
+{
+    int i;
+    for (i = 0; i < lib_files->size; i++)
+    {
+        sort_lib_file( lib_files->base[i]);
     }
 }
 
+
 static void create_the_wrapper(char* base_file, char* base_name, char* app_name, int gui_mode)
 {
     char *wrp_temp_name, *wspec_name, *wspec_c_name, *wspec_o_name;
     char *wrap_c_name, *wrap_o_name;
     strarray *wwrap_args, *wspec_args, *wcomp_args, *wlink_args;
+    int i;
 
     wrp_temp_name = tempnam(0, "wwrp");
     wspec_name = strmake("%s.spec", wrp_temp_name);
@@ -376,7 +393,8 @@
     strarray_add(wspec_args, strmake("%s.exe", base_name));
     strarray_add(wspec_args, gui_mode ? "-mgui" : "-mcui");
     strarray_add(wspec_args, wrap_o_name);
-    strarray_add(wspec_args, "-L" DLLDIR);
+    for (i = 0; i < llib_paths->size; i++)
+	strarray_add(wspec_args, llib_paths->base[i]);
     strarray_add(wspec_args, "-lkernel32");
     strarray_add(wspec_args, NULL);
 
@@ -407,6 +425,8 @@
     strarray_add(wlink_args, strmake("%s.exe.so", base_file));
     strarray_add(wlink_args, wspec_o_name);
     strarray_add(wlink_args, wrap_o_name);
+    for (i = 0; i < llib_paths->size; i++)
+	strarray_add(wlink_args, llib_paths->base[i]);
     strarray_add(wlink_args, NULL);
 
     spawn(wlink_args);
@@ -422,6 +442,7 @@
     char *base_name, *base_file, *base_path, *app_temp_name, *app_name = 0;
     char *spec_name, *spec_c_name, *spec_o_name;
     strarray *spec_args, *comp_args, *link_args;
+    strarray *lib_files;
 
     arh_files = strarray_alloc();
     dll_files = strarray_alloc();
@@ -430,9 +451,6 @@
     obj_files = strarray_alloc();
     llib_paths = strarray_alloc();
 
-    /* include the standard DLL path first */
-    add_lib_path(DLLDIR);
-
     for (i = 1; i < argc; i++)
     {
 	if (!no_opt && argv[i][0] == '-')
@@ -462,7 +480,7 @@
 		if (argv[i][2]) library = argv[i] + 2;
 		else if (i + 1 < argc) library = argv[++i];
 		else error("The -l switch takes an argument\n.");
-		add_lib_file(library);
+		strarray_add(lib_files, library);
 		break;
 	    case 'm':
 		if (strcmp("-mgui", argv[i]) == 0) gui_mode = 1;
@@ -501,10 +519,19 @@
     /* create wrapper only in C++ by default */
     if (create_wrapper == -1) create_wrapper = cpp;
     
+    /* include the standard library (for eg libwine.so) and DLL paths last */
+    add_lib_path(DLLDIR);
+    add_lib_path(LIBDIR);
+
     /* link in by default the big three */
-    if (gui_mode) add_lib_file("gdi32");
-    add_lib_file("user32");
-    add_lib_file("kernel32");
+    if (gui_mode)
+	strarray_add(lib_files, "gdi32");
+    strarray_add(lib_files, "user32");
+    strarray_add(lib_files, "kernel32");
+
+    /* Sort out the libraries into .def's and .a's */
+    sort_lib_files(lib_files);
+    strarray_free(lib_files);
 
     app_temp_name = tempnam(0, "wapp");
     /* get base filename by removing the .exe extension, if present */ 

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux