OSDN Git Service

Merge pull request #40011 (phonohawk/hengband/with-varpath into master).
authordeskull <deskull@users.osdn.me>
Sun, 16 Feb 2020 13:04:35 +0000 (22:04 +0900)
committerdeskull <deskull@users.osdn.me>
Sun, 16 Feb 2020 13:04:35 +0000 (22:04 +0900)
19 files changed:
configure.ac
lib/apex/Makefile.am
lib/bone/Makefile.am
lib/data/Makefile.am
lib/edit/Makefile.am
lib/file/Makefile.am
lib/help/Makefile.am
lib/info/Makefile.am
lib/pref/Makefile.am
lib/save/Makefile.am
lib/script/Makefile.am
lib/user/Makefile.am
lib/xtra/graf/Makefile.am
src/externs.h
src/init2.c
src/main-mac.c
src/main-win.c
src/main.c
src/z-config.h

index 7f05c3c..814ea46 100644 (file)
@@ -19,20 +19,29 @@ AC_LANG_C
 
 dnl generate the installation path for the ./lib/ folder
 if test "$GAMEGROUP" != ""; then
-  MY_EXPAND_DIR(game_datadir, "$datadir/games/$PACKAGE/lib/")
+  MY_EXPAND_DIR(game_libpath, "$datadir/games/$PACKAGE/lib/")
 else
-  MY_EXPAND_DIR(game_datadir, "./lib/")
+  MY_EXPAND_DIR(game_libpath, "./lib/")
   bindir=".."
 fi
 
 dnl overwrite the path with an user-specified value
 AC_ARG_WITH(libpath,
 [  --with-libpath=path     specify the path to the Hengband lib folder],
-[game_datadir="$withval"])
+[game_libpath="$withval"])
 
-AC_DEFINE_UNQUOTED(DEFAULT_PATH, "$game_datadir", [Path to the Hengband lib folder])
-DEFAULT_PATH="$game_datadir"
-AC_SUBST(DEFAULT_PATH)
+AC_ARG_WITH(varpath,
+[  --with-varpath=path     specify the path to the Hengband var folder],
+[game_varpath="$withval"],
+[game_varpath="$game_libpath"])
+
+AC_DEFINE_UNQUOTED(DEFAULT_LIB_PATH, "$game_libpath", [Path to the Hengband lib folder])
+DEFAULT_LIB_PATH="$game_libpath"
+AC_SUBST(DEFAULT_LIB_PATH)
+
+AC_DEFINE_UNQUOTED(DEFAULT_VAR_PATH, "$game_varpath", [Path to the Hengband var folder])
+DEFAULT_VAR_PATH="$game_varpath"
+AC_SUBST(DEFAULT_VAR_PATH)
 
 dnl Checks for programs.
 AC_PROG_CC
index 81ca89c..d5e771a 100644 (file)
@@ -7,7 +7,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@apex
+angbanddir = @DEFAULT_VAR_PATH@/apex
 
 angband_DATA = \
   $(angband_files)
index 3a23eda..e7c6cac 100644 (file)
@@ -7,7 +7,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@bone
+angbanddir = @DEFAULT_VAR_PATH@/bone
 
 angband_DATA = \
   $(angband_files)
index 2835820..adf8564 100644 (file)
@@ -7,7 +7,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@data
+angbanddir = @DEFAULT_VAR_PATH@/data
 
 angband_DATA = \
   $(angband_files)
index c26d9a3..71511fe 100644 (file)
@@ -22,7 +22,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@edit
+angbanddir = @DEFAULT_LIB_PATH@/edit
 
 angband_DATA = \
   $(angband_files)
index e96b497..142b9de 100644 (file)
@@ -20,7 +20,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@file
+angbanddir = @DEFAULT_LIB_PATH@/file
 
 angband_DATA = \
   $(angband_files)
index 49c859f..25b99f1 100644 (file)
@@ -26,7 +26,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@help
+angbanddir = @DEFAULT_LIB_PATH@/help
 
 angband_DATA = \
   $(angband_files)
index 8a6b5ef..e7d0eed 100644 (file)
@@ -7,7 +7,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@info
+angbanddir = @DEFAULT_LIB_PATH@/info
 
 angband_DATA = \
   $(angband_files)
index 34772e7..65e6bf0 100644 (file)
@@ -18,7 +18,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@pref
+angbanddir = @DEFAULT_LIB_PATH@/pref
 
 angband_DATA = \
   $(angband_files)
index c92fde5..d967ae9 100644 (file)
@@ -7,7 +7,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@save
+angbanddir = @DEFAULT_VAR_PATH@/save
 
 angband_DATA = \
   $(angband_files)
index ce5ddb5..aef9b0a 100644 (file)
@@ -7,7 +7,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@script
+angbanddir = @DEFAULT_LIB_PATH@/script
 
 angband_DATA = \
   $(angband_files)
index 0d34a7c..263c2c5 100644 (file)
@@ -7,7 +7,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@user
+angbanddir = @DEFAULT_VAR_PATH@/user
 
 angband_DATA = \
   $(angband_files)
index 7098ee0..bbd77a4 100644 (file)
@@ -7,7 +7,7 @@ EXTRA_DIST = \
   $(angband_files)
 
 if SET_GID
-angbanddir = @DEFAULT_PATH@xtra/graf
+angbanddir = @DEFAULT_LIB_PATH@/xtra/graf
 
 angband_DATA = \
   $(angband_files)
index 7339cc3..01beb6b 100644 (file)
@@ -618,7 +618,7 @@ extern s16b f_tag_to_index(concptr str);
 extern errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax);
 
 /* init2.c */
-extern void init_file_paths(char *path);
+extern void init_file_paths(char *libpath, char *varpath);
 extern concptr err_str[PARSE_ERROR_MAX];
 extern errr init_v_info(void);
 extern errr init_buildings(void);
index 09d76f2..48e5f2d 100644 (file)
@@ -81,9 +81,9 @@ static void put_title(void);
  * try several base "path" values until a good one is found.
  * </pre>
  */
-void init_file_paths(char *path)
+void init_file_paths(char *libpath, char *varpath)
 {
-       char *tail;
+       char *libtail, *vartail;
 
 #ifdef PRIVATE_USER_PATH
        char buf[1024];
@@ -111,52 +111,53 @@ void init_file_paths(char *path)
        /*** Prepare the "path" ***/
 
        /* Hack -- save the main directory */
-       ANGBAND_DIR = string_make(path);
+       ANGBAND_DIR = string_make(libpath);
 
-       /* Prepare to append to the Base Path */
-       tail = path + strlen(path);
+       /* Prepare to append to the Base Paths */
+       libtail = libpath + strlen(libpath);
+       vartail = varpath + strlen(varpath);
 
        /*** Build the sub-directory names ***/
 
        /* Build a path name */
-       strcpy(tail, "apex");
-       ANGBAND_DIR_APEX = string_make(path);
+       strcpy(vartail, "apex");
+       ANGBAND_DIR_APEX = string_make(varpath);
 
        /* Build a path name */
-       strcpy(tail, "bone");
-       ANGBAND_DIR_BONE = string_make(path);
+       strcpy(vartail, "bone");
+       ANGBAND_DIR_BONE = string_make(varpath);
 
        /* Build a path name */
-       strcpy(tail, "data");
-       ANGBAND_DIR_DATA = string_make(path);
+       strcpy(vartail, "data");
+       ANGBAND_DIR_DATA = string_make(varpath);
 
        /* Build a path name */
-       strcpy(tail, "edit");
-       ANGBAND_DIR_EDIT = string_make(path);
+       strcpy(libtail, "edit");
+       ANGBAND_DIR_EDIT = string_make(libpath);
 
        /* Build a path name */
-       strcpy(tail, "script");
-       ANGBAND_DIR_SCRIPT = string_make(path);
+       strcpy(libtail, "script");
+       ANGBAND_DIR_SCRIPT = string_make(libpath);
 
        /* Build a path name */
-       strcpy(tail, "file");
-       ANGBAND_DIR_FILE = string_make(path);
+       strcpy(libtail, "file");
+       ANGBAND_DIR_FILE = string_make(libpath);
 
        /* Build a path name */
-       strcpy(tail, "help");
-       ANGBAND_DIR_HELP = string_make(path);
+       strcpy(libtail, "help");
+       ANGBAND_DIR_HELP = string_make(libpath);
 
        /* Build a path name */
-       strcpy(tail, "info");
-       ANGBAND_DIR_INFO = string_make(path);
+       strcpy(libtail, "info");
+       ANGBAND_DIR_INFO = string_make(libpath);
 
        /* Build a path name */
-       strcpy(tail, "pref");
-       ANGBAND_DIR_PREF = string_make(path);
+       strcpy(libtail, "pref");
+       ANGBAND_DIR_PREF = string_make(libpath);
 
        /* Build a path name */
-       strcpy(tail, "save");
-       ANGBAND_DIR_SAVE = string_make(path);
+       strcpy(vartail, "save");
+       ANGBAND_DIR_SAVE = string_make(varpath);
 
 #ifdef PRIVATE_USER_PATH
 
@@ -169,14 +170,14 @@ void init_file_paths(char *path)
 #else /* PRIVATE_USER_PATH */
 
        /* Build a path name */
-       strcpy(tail, "user");
-       ANGBAND_DIR_USER = string_make(path);
+       strcpy(vartail, "user");
+       ANGBAND_DIR_USER = string_make(varpath);
 
 #endif /* PRIVATE_USER_PATH */
 
        /* Build a path name */
-       strcpy(tail, "xtra");
-       ANGBAND_DIR_XTRA = string_make(path);
+       strcpy(libtail, "xtra");
+       ANGBAND_DIR_XTRA = string_make(libpath);
 
 
 #ifdef NeXT
@@ -209,8 +210,8 @@ void init_file_paths(char *path)
                        string_free(ANGBAND_DIR_DATA);
 
                        /* Build a new path name */
-                       sprintf(tail, "data-%s", next);
-                       ANGBAND_DIR_DATA = string_make(path);
+                       sprintf(vartail, "data-%s", next);
+                       ANGBAND_DIR_DATA = string_make(varpath);
                }
        }
 
index d19c59a..b7586bb 100644 (file)
@@ -7016,7 +7016,7 @@ static void init_stuff(void)
        while (1)
        {
                /* Prepare the paths */
-               init_file_paths(path);
+               init_file_paths(path, path);
 
                /* Build the filename */
                path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
index a4489a9..992722c 100644 (file)
@@ -5440,7 +5440,7 @@ static void init_stuff(void)
        validate_dir(path, TRUE);
 
        /* Init the file paths */
-       init_file_paths(path);
+       init_file_paths(path, path);
 
        /* Hack -- Validate the paths */
        validate_dir(ANGBAND_DIR_APEX, FALSE);
index 5738716..c57ba18 100644 (file)
@@ -80,12 +80,13 @@ static void create_user_dir(void)
  * Initialize and verify the file paths, and the score file.
  *
  * Use the ANGBAND_PATH environment var if possible, else use
- * DEFAULT_PATH, and in either case, branch off appropriately.
+ * DEFAULT_(LIB|VAR)_PATH, and in either case, branch off
+ * appropriately.
  *
  * First, we'll look for the ANGBAND_PATH environment variable,
  * and then look for the files in there.  If that doesn't work,
- * we'll try the DEFAULT_PATH constant.  So be sure that one of
- * these two things works...
+ * we'll try the DEFAULT_(LIB|VAR)_PATH constants.  So be sure
+ * that one of these two things works...
  *
  * We must ensure that the path ends with "PATH_SEP" if needed,
  * since the "init_file_paths()" function will simply append the
@@ -97,7 +98,7 @@ static void create_user_dir(void)
  */
 static void init_stuff(void)
 {
-       char path[1024];
+       char libpath[1024], varpath[1024];
 
        concptr tail;
 
@@ -105,16 +106,19 @@ static void init_stuff(void)
        tail = getenv("ANGBAND_PATH");
 
        /* Use the angband_path, or a default */
-       strncpy(path, tail ? tail : DEFAULT_PATH, 511);
+       strncpy(libpath, tail ? tail : DEFAULT_LIB_PATH, 511);
+       strncpy(varpath, tail ? tail : DEFAULT_VAR_PATH, 511);
 
-       /* Make sure it's terminated */
-       path[511] = '\0';
+       /* Make sure they're terminated */
+       libpath[511] = '\0';
+       varpath[511] = '\0';
 
        /* Hack -- Add a path separator (only if needed) */
-       if (!suffix(path, PATH_SEP)) strcat(path, PATH_SEP);
+       if (!suffix(libpath, PATH_SEP)) strcat(libpath, PATH_SEP);
+       if (!suffix(varpath, PATH_SEP)) strcat(varpath, PATH_SEP);
 
        /* Initialize */
-       init_file_paths(path);
+       init_file_paths(libpath, varpath);
 }
 
 
index b320004..8f6beca 100644 (file)
  * actual location of the "lib" folder, for example, "/tmp/angband/lib/"
  * or "/usr/games/lib/angband/", or "/pkg/angband/lib".
  */
-#ifndef DEFAULT_PATH
-# define DEFAULT_PATH "./lib/"
+#ifndef DEFAULT_LIB_PATH
+# define DEFAULT_LIB_PATH "./lib/"
+#endif
+
+
+/*
+ * OPTION: Set the "default" path to the angband "var" directory.
+ *
+ * This is like DEFAULT_LIB_PATH, but is for files that will be
+ * modified after installation.
+ */
+#ifndef DEFAULT_VAR_PATH
+# define DEFAULT_VAR_PATH DEFAULT_LIB_PATH
 #endif