From 34e0226ee083b1cbd6277c0704288cb3c01d85d9 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 29 Oct 2011 16:52:19 +0200 Subject: core: add WEECHAT_HOME option in cmake and configure to setup default WeeChat home (default is "~/.weechat") (task #11266) Syntax for cmake: cmake -DWEECHAT_HOME="~/.weechat" Syntax for configure: ./configure WEECHAT_HOME="~/.weechat" --- CMakeLists.txt | 9 +++++++++ ChangeLog | 2 ++ config.h.cmake | 1 + configure.in | 12 +++++++++++- po/cs.po | 5 ++++- po/de.po | 5 ++++- po/es.po | 5 ++++- po/fr.po | 8 ++++++-- po/hu.po | 5 ++++- po/it.po | 5 ++++- po/pl.po | 5 ++++- po/pt_BR.po | 5 ++++- po/ru.po | 5 ++++- po/weechat.pot | 5 ++++- src/core/weechat.c | 38 ++++++++++++++++++++++++++++++-------- 15 files changed, 95 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8eb2eb63..ecb88d1b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,15 @@ OPTION(ENABLE_GUILE "Enable Scheme (guile) scripting language" ON) OPTION(ENABLE_XFER "Enable Xfer plugin" ON) OPTION(ENABLE_DOC "Enable Documentation" ON) +IF(NOT DEFINED WEECHAT_HOME OR "${WEECHAT_HOME}" STREQUAL "") + SET(WEECHAT_HOME "~/.weechat") +ENDIF(NOT DEFINED WEECHAT_HOME OR "${WEECHAT_HOME}" STREQUAL "") + +SET(WEECHAT_HOME "${WEECHAT_HOME}" CACHE + STRING "WeeChat home directory for config, logs, scripts.. (default is \"~/.weechat\")" + FORCE) +MARK_AS_ADVANCED(CLEAR WEECHAT_HOME) + IF(ENABLE_NLS) ADD_SUBDIRECTORY( po ) ENDIF(ENABLE_NLS) diff --git a/ChangeLog b/ChangeLog index 49f7771fe..26987e040 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ v0.3.7-dev, 2011-10-29 Version 0.3.7 (under dev!) -------------------------- +* core: add WEECHAT_HOME option in cmake and configure to setup default + WeeChat home (default is "~/.weechat") (task #11266) * core: add optional arguments for command /plugin load/reload/autoload * core: fix compilation error with "pid_t" on Mac OS X (bug #34639) * core: enable background process under Cygwin to connect to servers, fix diff --git a/config.h.cmake b/config.h.cmake index 1c1714e59..ea8047e80 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -30,4 +30,5 @@ #define WEECHAT_LIBDIR "@LIBDIR@" #define WEECHAT_SHAREDIR "@SHAREDIR@" #define LOCALEDIR "@LOCALEDIR@" +#define WEECHAT_HOME "@WEECHAT_HOME@" #define _GNU_SOURCE 1 diff --git a/configure.in b/configure.in index 81950d8eb..fe186c8ff 100644 --- a/configure.in +++ b/configure.in @@ -124,6 +124,7 @@ AH_VERBATIM([PLUGIN_TCL], [#undef PLUGIN_TCL]) AH_VERBATIM([PLUGIN_GUILE], [#undef PLUGIN_GUILE]) AH_VERBATIM([PLUGIN_XFER], [#undef PLUGIN_XFER]) AH_VERBATIM([DOC], [#undef DOC]) +AH_VERBATIM([WEECHAT_HOME], [#define WEECHAT_HOME "~/.weechat"]) # Arguments for ./configure @@ -158,6 +159,13 @@ AC_ARG_WITH(tclconfig, [ --with-tclconfig=DIR directory containing tcl AC_ARG_ENABLE(doc, [ --disable-doc turn off documentation (default=built)],enable_doc=$enableval,enable_doc=yes) AC_ARG_WITH(debug, [ --with-debug debugging: 0=no debug, 1=debug compilation (default=1)],debug=$withval,debug=1) +AC_ARG_VAR(WEECHAT_HOME, [WeeChat home directory for config, logs, scripts.. (default is "~/.weechat")]) + +if test "x$WEECHAT_HOME" = "x" ; then + WEECHAT_HOME="~/.weechat" +fi +AC_DEFINE_UNQUOTED(WEECHAT_HOME, "$WEECHAT_HOME") + not_asked="" not_found="" @@ -1223,7 +1231,9 @@ if test "x$not_asked" != "x" || test "x$not_found" != "x"; then fi echo "" -eval echo "WeeChat will be installed in $bindir." +echo "WeeChat home directory is ${WEECHAT_HOME}" +echo "" +eval echo "WeeChat will be installed in $bindir" echo "" echo "configure complete, now type 'make' to build WeeChat $VERSION" echo "" diff --git a/po/cs.po b/po/cs.po index fdcaecd5c..5da5309bf 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: 2011-10-22 12:21+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -88,6 +88,9 @@ msgstr "%s výchozí klávesy:\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "Chyba: chybí argument pro volbu \"%s\"\n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + msgid "Error: unable to get HOME directory\n" msgstr "Chyba: nemohu získat HOME adresář\n" diff --git a/po/de.po b/po/de.po index 159c15d59..4bdbefe9f 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: 2011-10-27 11:56+0200\n" "Last-Translator: Nils Görs\n" "Language-Team: weechat-dev \n" @@ -96,6 +96,9 @@ msgstr "%s Standardtastenbelegungen (Kontext: \"%s\"):\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "Fehler: fehlendes Argument für die Option \"%s\"\n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + msgid "Error: unable to get HOME directory\n" msgstr "Fehler: Das HOME-Verzeichnis kann nicht ermittelt werden\n" diff --git a/po/es.po b/po/es.po index 068eec5cf..8eb74cbad 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: 2011-10-27 11:56+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -89,6 +89,9 @@ msgstr "teclas por defecto de %s (contexto: \"%s\"):\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "Error: falta un argumento para la opción \"%s\"\n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + msgid "Error: unable to get HOME directory\n" msgstr "Error: no ha sido posible obtener el directorio HOME\n" diff --git a/po/fr.po b/po/fr.po index 42bff2882..294e0045a 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" -"PO-Revision-Date: 2011-10-29 11:39+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" +"PO-Revision-Date: 2011-10-29 16:49+0200\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -90,6 +90,10 @@ msgstr "Touches par défaut %s (contexte: \"%s\"):\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "Erreur: paramètre manquant pour l'option \"%s\"\n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" +"Erreur: WEECHAT_HOME n'est pas défini, vérifiez les options de construction\n" + msgid "Error: unable to get HOME directory\n" msgstr "Erreur: impossible de lire le répertoire personnel\n" diff --git a/po/hu.po b/po/hu.po index 010c5a6ac..2b6890d02 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: 2011-10-22 12:21+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -84,6 +84,9 @@ msgstr "%s alapértelmezett billentyűk:\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + #, fuzzy msgid "Error: unable to get HOME directory\n" msgstr "%s nem sikerült a HOME könyvtárat beállítani\n" diff --git a/po/it.po b/po/it.po index 9270f5af6..c1bb99fe0 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: 2011-10-27 11:56+0200\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -88,6 +88,9 @@ msgstr "%s tasti predefiniti (contesto: \"%s\"):\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "Errore: argomento mancante per l'opzione \"%s\"\n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + msgid "Error: unable to get HOME directory\n" msgstr "Errore: impossibile aprire la cartella HOME\n" diff --git a/po/pl.po b/po/pl.po index 507aa4c9b..a73531798 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: 2011-10-27 11:56+0200\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -91,6 +91,9 @@ msgstr "%s domyślne skróty klawiszowe (kontekst: \"%s\"):\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "Błąd: brak argumentu dla opcji \"%s\" \n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + msgid "Error: unable to get HOME directory\n" msgstr "Błąd: nie można pozyskać katalogu domowego\n" diff --git a/po/pt_BR.po b/po/pt_BR.po index 758159a85..f71088e4e 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: 2011-10-26 19:30+0200\n" "Last-Translator: Ivan Sichmann Freitas \n" "Language-Team: weechat-dev \n" @@ -112,6 +112,9 @@ msgstr "%s teclas de atalho padrão:\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "Error: faltando argumento para \"%s\" opção\n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + msgid "Error: unable to get HOME directory\n" msgstr "Erro: incapaz de abrir o diretório padrão\n" diff --git a/po/ru.po b/po/ru.po index 208bd5cd1..b67538735 100644 --- a/po/ru.po +++ b/po/ru.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: 2011-10-22 12:21+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -87,6 +87,9 @@ msgstr "%s клавиши по умолчанию:\n" msgid "Error: missing argument for \"%s\" option\n" msgstr "%s нет аргумента для параметра \"%s\"\n" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + #, fuzzy msgid "Error: unable to get HOME directory\n" msgstr "%s не могу получить домашний каталог\n" diff --git a/po/weechat.pot b/po/weechat.pot index d5e3ced62..37340d83a 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-10-29 11:38+0200\n" +"POT-Creation-Date: 2011-10-29 16:32+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -56,6 +56,9 @@ msgstr "" msgid "Error: missing argument for \"%s\" option\n" msgstr "" +msgid "Error: WEECHAT_HOME is undefined, check build options\n" +msgstr "" + msgid "Error: unable to get HOME directory\n" msgstr "" diff --git a/src/core/weechat.c b/src/core/weechat.c index 735fc15f7..d1cfb0ca2 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -282,23 +282,47 @@ weechat_parse_args (int argc, char *argv[]) void weechat_create_home_dirs () { - char *ptr_home; + char *ptr_home, *config_weechat_home = WEECHAT_HOME; int dir_length; struct stat statinfo; if (!weechat_home) { - ptr_home = getenv ("HOME"); - if (!ptr_home) + if (strlen (config_weechat_home) == 0) { string_iconv_fprintf (stderr, - _("Error: unable to get HOME directory\n")); + _("Error: WEECHAT_HOME is undefined, check " + "build options\n")); weechat_shutdown (EXIT_FAILURE, 0); /* make C static analyzer happy (never executed) */ return; } - dir_length = strlen (ptr_home) + 10; - weechat_home = malloc (dir_length); + + if (config_weechat_home[0] == '~') + { + /* replace leading '~' by $HOME */ + ptr_home = getenv ("HOME"); + if (!ptr_home) + { + string_iconv_fprintf (stderr, + _("Error: unable to get HOME directory\n")); + weechat_shutdown (EXIT_FAILURE, 0); + /* make C static analyzer happy (never executed) */ + return; + } + dir_length = strlen (ptr_home) + strlen (config_weechat_home + 1) + 1; + weechat_home = malloc (dir_length); + if (weechat_home) + { + snprintf (weechat_home, dir_length, + "%s%s", ptr_home, config_weechat_home + 1); + } + } + else + { + weechat_home = strdup (config_weechat_home); + } + if (!weechat_home) { string_iconv_fprintf (stderr, @@ -308,8 +332,6 @@ weechat_create_home_dirs () /* make C static analyzer happy (never executed) */ return; } - snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home, - DIR_SEPARATOR); } /* if home already exists, it has to be a directory */ -- cgit v1.2.3