7f70c24
--- mc-4.6.1a/src/charsets.c.etcmc	2005-05-27 05:35:15.000000000 +0200
7f70c24
+++ mc-4.6.1a/src/charsets.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -45,12 +45,17 @@ load_codepages_list (void)
7f70c24
     char *fname;
7f70c24
     char buf[256];
7f70c24
     extern char *mc_home;
7f70c24
+    extern char *mc_home_alt;
7f70c24
     extern int display_codepage;
7f70c24
     char *default_codepage = NULL;
7f70c24
 
7f70c24
     fname = concat_dir_and_file (mc_home, CHARSETS_INDEX);
7f70c24
     if (!(f = fopen (fname, "r"))) {
7f70c24
-	fprintf (stderr, _("Warning: file %s not found\n"), fname);
7f70c24
+        g_free (fname);
7f70c24
+        fname = concat_dir_and_file (mc_home_alt, CHARSETS_INDEX);
7f70c24
+        if (!(f = fopen (fname, "r"))) {
7f70c24
+	    fprintf (stderr, _("Warning: file %s not found\n"), fname);
7f70c24
+        }
7f70c24
 	g_free (fname);
7f70c24
 	return -1;
7f70c24
     }
7f70c24
--- mc-4.6.1a/src/main.h.etcmc	2006-02-24 15:17:05.000000000 +0100
7f70c24
+++ mc-4.6.1a/src/main.h	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -112,7 +112,7 @@ void print_vfs_message(const char *msg, 
7f70c24
 
7f70c24
 extern const char *prompt;
7f70c24
 extern const char *edit_one_file;
7f70c24
-extern char *mc_home;
7f70c24
+extern char *mc_home, *mc_home_alt;
7f70c24
 char *get_mc_lib_dir (void);
7f70c24
 
7f70c24
 int maybe_cd (int move_up_dir);
7f70c24
--- mc-4.6.1a/src/ext.c.etcmc	2005-07-31 22:29:35.000000000 +0200
7f70c24
+++ mc-4.6.1a/src/ext.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -444,6 +444,10 @@ regex_command (const char *filename, con
7f70c24
 	    g_free (extension_file);
7f70c24
 	  check_stock_mc_ext:
7f70c24
 	    extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT);
7f70c24
+	    if (!exist_file (extension_file)) {
7f70c24
+	    	g_free (extension_file);
7f70c24
+	    	extension_file = concat_dir_and_file (mc_home_alt, MC_LIB_EXT);
7f70c24
+	    }
7f70c24
 	    mc_user_ext = 0;
7f70c24
 	}
7f70c24
 	data = load_file (extension_file);
7f70c24
--- mc-4.6.1a/src/setup.c.etcmc	2006-01-29 21:26:05.000000000 +0100
7f70c24
+++ mc-4.6.1a/src/setup.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -481,8 +481,15 @@ setup_init (void)
7f70c24
 	if (exist_file (inifile)){
7f70c24
 	    g_free (profile);
7f70c24
 	    profile = inifile;
7f70c24
-	} else
7f70c24
+	} else {
7f70c24
 	    g_free (inifile);
7f70c24
+	    inifile = concat_dir_and_file (mc_home_alt, "mc.ini");
7f70c24
+	    if (exist_file (inifile)) {
7f70c24
+	        g_free (profile);
7f70c24
+	        profile = inifile;
7f70c24
+	    } else 
7f70c24
+	        g_free (inifile);
7f70c24
+	}
7f70c24
     }
7f70c24
 
7f70c24
     profile_name = profile;
7f70c24
@@ -501,6 +508,11 @@ load_setup (void)
7f70c24
     /* mc.lib is common for all users, but has priority lower than
7f70c24
        ~/.mc/ini.  FIXME: it's only used for keys and treestore now */
7f70c24
     global_profile_name = concat_dir_and_file (mc_home, "mc.lib");
7f70c24
+    
7f70c24
+    if (!exist_file(global_profile_name)) {
7f70c24
+    	g_free (global_profile_name);
7f70c24
+    	global_profile_name = concat_dir_and_file (mc_home_alt, "mc.lib");
7f70c24
+    }
7f70c24
 
7f70c24
     /* Load integer boolean options */
7f70c24
     for (i = 0; int_options[i].opt_name; i++)
7f70c24
--- mc-4.6.1a/src/Makefile.am.etcmc	2006-02-04 12:13:30.000000000 +0100
7f70c24
+++ mc-4.6.1a/src/Makefile.am	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -8,9 +8,11 @@ bin_PROGRAMS = mc mcmfmt
7f70c24
 if CONS_SAVER
7f70c24
 pkglibexec_PROGRAMS = cons.saver
7f70c24
 AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \
7f70c24
-	-DSAVERDIR=\""$(pkglibexecdir)"\"
7f70c24
+	-DSAVERDIR=\""$(pkglibexecdir)"\" \
7f70c24
+	-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
7f70c24
 else
7f70c24
-AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
7f70c24
+AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \
7f70c24
+	-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
7f70c24
 endif
7f70c24
 
7f70c24
 noinst_PROGRAMS = man2hlp
7f70c24
--- mc-4.6.1a/src/util.c.etcmc	2006-02-24 15:17:05.000000000 +0100
7f70c24
+++ mc-4.6.1a/src/util.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -40,7 +40,7 @@
7f70c24
 #include "tty.h"
7f70c24
 #include "global.h"
7f70c24
 #include "profile.h"
7f70c24
-#include "main.h"		/* mc_home */
7f70c24
+#include "main.h"		/* mc_home, mc_home_alt */
7f70c24
 #include "cmd.h"		/* guess_message_value */
7f70c24
 #include "mountlist.h"
7f70c24
 #include "win.h"		/* xterm_flag */
7f70c24
@@ -950,16 +950,25 @@ load_mc_home_file (const char *filename,
7f70c24
 
7f70c24
     if (!data) {
7f70c24
 	g_free (hintfile);
7f70c24
-	/* Fall back to the two-letter language code */
7f70c24
-	if (lang[0] && lang[1])
7f70c24
-	    lang[2] = 0;
7f70c24
+	g_free (hintfile_base);
7f70c24
+
7f70c24
+	hintfile_base = concat_dir_and_file (mc_home_alt, filename);
7f70c24
+
7f70c24
 	hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
7f70c24
 	data = load_file (hintfile);
7f70c24
-
7f70c24
+	
7f70c24
 	if (!data) {
7f70c24
-	    g_free (hintfile);
7f70c24
-	    hintfile = hintfile_base;
7f70c24
-	    data = load_file (hintfile_base);
7f70c24
+	    /* Fall back to the two-letter language code */
7f70c24
+	    if (lang[0] && lang[1])
7f70c24
+	        lang[2] = 0;
7f70c24
+	    hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
7f70c24
+	    data = load_file (hintfile);
7f70c24
+
7f70c24
+	    if (!data) {
7f70c24
+	        g_free (hintfile);
7f70c24
+	        hintfile = hintfile_base;
7f70c24
+	        data = load_file (hintfile_base);
7f70c24
+	    }
7f70c24
 	}
7f70c24
     }
7f70c24
 
7f70c24
--- mc-4.6.1a/src/cmd.c.etcmc	2006-02-04 12:12:28.000000000 +0100
7f70c24
+++ mc-4.6.1a/src/cmd.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -570,8 +570,13 @@ void ext_cmd (void)
7f70c24
 	check_for_default (extdir, buffer);
7f70c24
 	do_edit (buffer);
7f70c24
 	g_free (buffer);
7f70c24
-    } else if (dir == 1)
7f70c24
+    } else if (dir == 1) {
7f70c24
+    	if (!exist_file(extdir)) {
7f70c24
+	    g_free (extdir);
7f70c24
+	    extdir = concat_dir_and_file (mc_home_alt, MC_LIB_EXT);
7f70c24
+	}
7f70c24
 	do_edit (extdir);
7f70c24
+    }
7f70c24
 
7f70c24
    g_free (extdir);
7f70c24
    flush_extension_file ();
7f70c24
@@ -594,6 +599,11 @@ menu_edit_cmd (int where)
7f70c24
     );
7f70c24
 
7f70c24
     menufile = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
7f70c24
+    
7f70c24
+    if (!exist_file(menufile)) {
7f70c24
+    	g_free (menufile);
7f70c24
+    	menufile = concat_dir_and_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
7f70c24
+    }
7f70c24
 
7f70c24
     switch (dir) {
7f70c24
 	case 0:
7f70c24
@@ -608,6 +618,10 @@ menu_edit_cmd (int where)
7f70c24
 	
7f70c24
 	case 2:
7f70c24
 	    buffer = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
7f70c24
+	    if (!exist_file(buffer)) {
7f70c24
+	        g_free (buffer);
7f70c24
+	        buffer = concat_dir_and_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
7f70c24
+	    }
7f70c24
 	    break;
7f70c24
 
7f70c24
 	default:
7f70c24
@@ -666,7 +680,7 @@ edit_syntax_cmd (void)
7f70c24
 			  _(" Which syntax file you want to edit? "), 0, 2,
7f70c24
 			  _("&User"), _("&System Wide"));
7f70c24
     }
7f70c24
-    extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
7f70c24
+    extdir = concat_dir_and_file (mc_home_alt, "syntax" PATH_SEP_STR "Syntax");
7f70c24
 
7f70c24
     if (dir == 0) {
7f70c24
 	buffer = concat_dir_and_file (home_dir, SYNTAX_FILE);
7f70c24
--- mc-4.6.1a/src/main.c.etcmc	2006-02-24 15:17:05.000000000 +0100
7f70c24
+++ mc-4.6.1a/src/main.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -282,9 +282,12 @@ gboolean is_utf8 = FALSE;
7f70c24
 /* The xterm title */
7f70c24
 char *xterm_title_str = NULL;
7f70c24
 
7f70c24
-/* mc_home: The home of MC */
7f70c24
+/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */
7f70c24
 char *mc_home = NULL;
7f70c24
 
7f70c24
+/* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */
7f70c24
+char *mc_home_alt = NULL;
7f70c24
+
7f70c24
 char cmd_buf[512];
7f70c24
 
7f70c24
 static void
7f70c24
@@ -1817,8 +1820,9 @@ OS_Setup (void)
7f70c24
     if ((mc_libdir = getenv ("MC_DATADIR")) != NULL) {
7f70c24
 	mc_home = g_strdup (mc_libdir);
7f70c24
     } else {
7f70c24
-	mc_home = g_strdup (DATADIR);
7f70c24
+	mc_home = g_strdup (SYSCONFDIR);
7f70c24
     }
7f70c24
+    mc_home_alt = mc_libdir != NULL ? g_strdup (SYSCONFDIR) : g_strdup (DATADIR);
7f70c24
 }
7f70c24
 
7f70c24
 static void
7f70c24
@@ -1948,7 +1952,7 @@ process_args (poptContext ctx, int c, co
7f70c24
 	break;
7f70c24
 
7f70c24
     case 'f':
7f70c24
-	printf ("%s\n", mc_home);
7f70c24
+	printf ("%s (%s)\n", mc_home, mc_home_alt);
7f70c24
 	exit (0);
7f70c24
 	break;
7f70c24
 
7f70c24
@@ -2326,6 +2330,7 @@ main (int argc, char *argv[])
7f70c24
     }
7f70c24
     g_free (last_wd_string);
7f70c24
 
7f70c24
+    g_free (mc_home_alt);
7f70c24
     g_free (mc_home);
7f70c24
     done_key ();
7f70c24
 #ifdef HAVE_CHARSET
7f70c24
--- mc-4.6.1a/src/Makefile.in.etcmc	2006-02-15 21:12:44.000000000 +0100
7f70c24
+++ mc-4.6.1a/src/Makefile.in	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -314,9 +314,10 @@ target_alias = @target_alias@
7f70c24
 AM_CFLAGS = $(GLIB_CFLAGS)
7f70c24
 localedir = $(datadir)/locale
7f70c24
 pkglibexecdir = $(libexecdir)/@PACKAGE@
7f70c24
-@CONS_SAVER_FALSE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
7f70c24
+@CONS_SAVER_FALSE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \
7f70c24
+@CONS_SAVER_FALSE@	-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
7f70c24
 @CONS_SAVER_TRUE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \
7f70c24
-@CONS_SAVER_TRUE@	-DSAVERDIR=\""$(pkglibexecdir)"\"
7f70c24
+@CONS_SAVER_TRUE@	-DSAVERDIR=\""$(pkglibexecdir)"\" -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
7f70c24
 
7f70c24
 man2hlp_LDADD = $(GLIB_LIBS)
7f70c24
 mcmfmt_SOURCES = mfmt.c
7f70c24
--- mc-4.6.1a/src/user.c.etcmc	2006-02-04 15:41:42.000000000 +0100
7f70c24
+++ mc-4.6.1a/src/user.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -726,6 +726,11 @@ user_menu_cmd (struct WEdit *edit_widget
7f70c24
 	    g_free (menu);
7f70c24
 	    menu = concat_dir_and_file \
7f70c24
                         (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
7f70c24
+	    if (!exist_file (menu)) {
7f70c24
+	        g_free (menu);
7f70c24
+	        menu = concat_dir_and_file \
7f70c24
+                        (mc_home_alt, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
7f70c24
+	    }
7f70c24
 	}
7f70c24
     }
7f70c24
 
7f70c24
--- mc-4.6.1a/edit/editcmd.c.etcmc	2006-02-24 15:17:05.000000000 +0100
7f70c24
+++ mc-4.6.1a/edit/editcmd.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -49,7 +49,7 @@
7f70c24
 #include "../src/tty.h"		/* LINES */
7f70c24
 #include "../src/widget.h"	/* listbox_new() */
7f70c24
 #include "../src/layout.h"	/* clr_scr() */
7f70c24
-#include "../src/main.h"	/* mc_home */
7f70c24
+#include "../src/main.h"	/* mc_home, mc_home_alt */
7f70c24
 #include "../src/help.h"	/* interactive_display() */
7f70c24
 #include "../src/key.h"		/* XCTRL */
7f70c24
 #include "../src/dialog.h"	/* do_refresh() */
7f70c24
@@ -2790,12 +2790,15 @@ edit_block_process_cmd (WEdit *edit, con
7f70c24
 	    return;
7f70c24
 	}
7f70c24
 	if (!(script_src = fopen (o, "r"))) {
7f70c24
-	    fclose (script_home);
7f70c24
-	    unlink (h);
7f70c24
-	    edit_error_dialog ("", get_sys_error (catstrs
7f70c24
-						  (_("Error reading script:"),
7f70c24
-						   o, (char *) NULL)));
7f70c24
-	    return;
7f70c24
+	    o = catstrs (mc_home_alt, shell_cmd, (char *) NULL);
7f70c24
+	    if (!(script_src = fopen (o, "r"))) {
7f70c24
+	        fclose (script_home);
7f70c24
+	        unlink (h);
7f70c24
+	        edit_error_dialog ("", get_sys_error (catstrs
7f70c24
+						      (_("Error reading script:"),
7f70c24
+						      o, (char *) NULL)));
7f70c24
+	        return;
7f70c24
+	    }
7f70c24
 	}
7f70c24
 	while (fgets (buf, sizeof (buf), script_src))
7f70c24
 	    fputs (buf, script_home);
7f70c24
--- mc-4.6.1a/edit/syntax.c.etcmc	2006-02-04 15:41:42.000000000 +0100
7f70c24
+++ mc-4.6.1a/edit/syntax.c	2006-02-24 15:17:05.000000000 +0100
7f70c24
@@ -37,7 +37,7 @@
7f70c24
 #include "edit.h"
7f70c24
 #include "edit-widget.h"
7f70c24
 #include "../src/color.h"	/* use_colors */
7f70c24
-#include "../src/main.h"	/* mc_home */
7f70c24
+#include "../src/main.h"	/* mc_home, mc_home_alt */
7f70c24
 #include "../src/wtools.h"	/* message() */
7f70c24
 
7f70c24
 /* bytes */
7f70c24
@@ -680,6 +680,12 @@ static FILE *open_include_file (const ch
7f70c24
     g_free (error_file_name);
7f70c24
     error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR,
7f70c24
 				   filename, (char *) NULL);
7f70c24
+    if (!(f = fopen (error_file_name, "r"))) {
7f70c24
+        g_free (error_file_name);
7f70c24
+        error_file_name = g_strconcat (mc_home_alt, PATH_SEP_STR "syntax" PATH_SEP_STR,
7f70c24
+				       filename, (char *) NULL);
7f70c24
+    } else return f;
7f70c24
+    
7f70c24
     return fopen (error_file_name, "r");
7f70c24
 }
7f70c24
 
7f70c24
--- mc-4.6.1a/vfs/extfs.c.etcmc	2005-09-05 02:52:57.000000000 +0200
7f70c24
+++ mc-4.6.1a/vfs/extfs.c	2006-02-24 15:22:16.000000000 +0100
7f70c24
@@ -242,7 +242,7 @@ extfs_open_archive (int fstype, const ch
7f70c24
 	tmp = name_quote (name, 0);
7f70c24
     }
7f70c24
 
7f70c24
-    mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
7f70c24
+    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR);
7f70c24
     cmd =
7f70c24
 	g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ",
7f70c24
 		     local_name ? local_name : tmp, (char *) NULL);
7f70c24
@@ -617,7 +617,7 @@ extfs_cmd (const char *extfs_cmd, struct
7f70c24
     archive_name = name_quote (extfs_get_archive_name (archive), 0);
7f70c24
     quoted_localname = name_quote (localname, 0);
7f70c24
 
7f70c24
-    mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
7f70c24
+    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR);
7f70c24
     cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
7f70c24
 		       extfs_cmd, archive_name, " ", quoted_file, " ",
7f70c24
 		       quoted_localname, (char *) NULL);
7f70c24
@@ -646,7 +646,7 @@ extfs_run (struct vfs_class *me, const c
7f70c24
     g_free (p);
7f70c24
 
7f70c24
     archive_name = name_quote (extfs_get_archive_name (archive), 0);
7f70c24
-    mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
7f70c24
+    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR);
7f70c24
     cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
7f70c24
 		       " run ", archive_name, " ", q, (char *) NULL);
7f70c24
     g_free (mc_extfsdir);