Changeset 251

Show
Ignore:
Timestamp:
06/04/08 21:38:28 (4 years ago)
Author:
ath
Message:

Fix the binary relocation heuristics, at least on Linux.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/fm_gui/src/global.c

    r202 r251  
     1#include <string.h> 
    12#include <glib.h> 
    23#ifdef G_OS_WIN32 
     
    1314#include "binreloc.h" 
    1415 
     16#define LIBDIR_SUFFIX ".libs" 
     17 
    1518 
    1619static gchar *prefix; 
    17 static gchar *exe_path; 
    1820static gchar *bin_path; 
    1921//static gchar *lib_path; 
     
    2527{ 
    2628        GError *err = NULL; 
     29        gchar *prefix_temp; 
    2730 
    2831#ifdef G_OS_WIN32 
    29         TCHAR path[MAX_PATH]; 
     32        TCHAR exe_filename[MAX_PATH]; 
    3033         
    31         GetModuleFileName (NULL, path, MAX_PATH); 
     34        GetModuleFileName (NULL, exe_filename, MAX_PATH); 
    3235         
    3336        exe_path = g_path_get_dirname (path); 
     37        g_print ("Executable is %s\n", exe_filename); 
     38        prefix_temp = g_strdup (prefix_temp); 
    3439#else 
     40 
     41        gboolean in_source_dir; 
     42 
    3543        if (gbr_init (&err)) 
    3644                g_print("binreloc available!\n"); 
     
    4149        if (!exe_filename) 
    4250                g_warning ("Can't determine installation prefix!"); 
     51        else 
     52                g_print ("Executable is %s\n", exe_filename); 
    4353 
    44         exe_path = g_path_get_dirname (exe_filename);    
    45         g_free (exe_filename); 
     54        prefix_temp = g_path_get_dirname (exe_filename); 
     55        g_print ("prefix_temp %s\n", prefix_temp); 
     56        gchar *basename = g_path_get_basename (prefix_temp); 
     57        g_print ("basename %s\n", basename); 
     58 
     59        if (strcmp (basename, LIBDIR_SUFFIX) == 0) { 
     60                g_print ("we are in a libtool temporary directory, adjusting path...\n"); 
     61 
     62                prefix_temp = g_strdup (prefix_temp); 
     63                prefix_temp[strlen (prefix_temp) - strlen (LIBDIR_SUFFIX) - 1] = '\0'; 
     64        } 
     65 
     66        g_free (basename); 
     67 
     68        basename = g_path_get_basename (prefix_temp); 
     69 
     70        if (strcmp (basename, "src") == 0) 
     71                in_source_dir = TRUE; 
     72        else 
     73                in_source_dir = FALSE; 
     74 
     75        prefix_temp[strlen (prefix_temp) - strlen (basename)] = '\0'; 
     76 
     77        g_free (basename); 
     78 
     79 
    4680#endif 
    4781 
    48         gchar *makefile_name = g_build_filename (exe_path, "Makefile.am", NULL); 
    49         gchar *data_path_temp = NULL; 
    50         if (g_file_test (makefile_name, G_FILE_TEST_EXISTS)) { 
    51                 g_print ("%s exists, we are in the source directory\n", makefile_name); 
     82        g_print ("base path %s --- ", prefix_temp); 
     83        if (in_source_dir) { 
     84                g_print ("source directory\n"); 
    5285 
    53                 prefix = g_path_get_dirname (exe_path); 
    54                 bin_path = g_strdup (exe_path); 
     86                prefix = g_strdup (prefix_temp); 
     87                bin_path = g_build_path (G_DIR_SEPARATOR_S, prefix, "src", NULL); 
    5588                data_path = g_build_path (G_DIR_SEPARATOR_S, prefix, "data", NULL); 
     89 
    5690        } else { 
    57                 prefix = gbr_find_prefix (PREFIX); 
     91                g_print ("installation directory\n"); 
    5892 
    59 #ifdef G_OS_WIN32        
    60                 bin_path = g_build_path (G_DIR_SEPARATOR_S, path, "bin", NULL); 
    61 //              lib_path = g_build_path (G_DIR_SEPARATOR_S, path, "lib", NULL); 
    62                 data_path_temp = g_build_path (G_DIR_SEPARATOR_S, path, "share", NULL); 
    63 #else 
    64                 bin_path = gbr_find_lib_dir (PREFIX "/bin"); 
    65 //              lib_path = gbr_find_lib_dir (PREFIX "/lib"); 
    66                 data_path_temp = gbr_find_data_dir (PREFIX "/share/fm_gui"); 
    67 #endif 
    68                 data_path = g_build_path (G_DIR_SEPARATOR_S, data_path_temp, "fm_gui", NULL); 
     93                prefix = g_strdup (prefix_temp); 
     94                bin_path = g_build_path (G_DIR_SEPARATOR_S, prefix, "bin", NULL); 
     95                data_path = g_build_path (G_DIR_SEPARATOR_S, prefix, "share", PACKAGE, NULL); 
     96 
    6997        } 
    70  
    71  
    7298         
    73         g_free (makefile_name); 
     99        g_free (prefix_temp); 
    74100 
    75101        g_print ("prefix %s\n", prefix); 
    76         g_print ("exe_path %s\n", exe_path); 
     102        g_print ("bin_path %s\n", bin_path); 
    77103        g_print ("data_path %s\n", data_path); 
    78104}