• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision2b48189880587ab83bd24ef58bd145a690e46280 (tree)
Time2020-02-08 15:09:30
AuthorPHO <pho@ciel...>
CommiterPHO

Log Message

[Feature] Add ./configure option "--with-varpath=PATH"

On Unix-like platforms, it is often desirable to install files that
will be modified after installation under a separate directory tree
from that containing read-only data files. This is so that read-only
files can reside in a read-only file system, and also package managers
can update or remove read-only files without worrying about removing
user data.

The new option "--with-varpath=PATH", when specified, configures the
game so that certain directories, namely apex, bone, data, edit, user,
and save, will be created under the given path, as opposed to the path
specified with "--with-libpath=PATH". When the option is not given,
those directories will be created under the lib directory as before.

Change Summary

Incremental Difference

--- a/configure.ac
+++ b/configure.ac
@@ -19,20 +19,29 @@ AC_LANG_C
1919
2020 dnl generate the installation path for the ./lib/ folder
2121 if test "$GAMEGROUP" != ""; then
22- MY_EXPAND_DIR(game_datadir, "$datadir/games/$PACKAGE/lib/")
22+ MY_EXPAND_DIR(game_libpath, "$datadir/games/$PACKAGE/lib/")
2323 else
24- MY_EXPAND_DIR(game_datadir, "./lib/")
24+ MY_EXPAND_DIR(game_libpath, "./lib/")
2525 bindir=".."
2626 fi
2727
2828 dnl overwrite the path with an user-specified value
2929 AC_ARG_WITH(libpath,
3030 [ --with-libpath=path specify the path to the Hengband lib folder],
31-[game_datadir="$withval"])
31+[game_libpath="$withval"])
3232
33-AC_DEFINE_UNQUOTED(DEFAULT_PATH, "$game_datadir", [Path to the Hengband lib folder])
34-DEFAULT_PATH="$game_datadir"
35-AC_SUBST(DEFAULT_PATH)
33+AC_ARG_WITH(varpath,
34+[ --with-varpath=path specify the path to the Hengband var folder],
35+[game_varpath="$withval"],
36+[game_varpath="$game_libpath"])
37+
38+AC_DEFINE_UNQUOTED(DEFAULT_LIB_PATH, "$game_libpath", [Path to the Hengband lib folder])
39+DEFAULT_LIB_PATH="$game_libpath"
40+AC_SUBST(DEFAULT_LIB_PATH)
41+
42+AC_DEFINE_UNQUOTED(DEFAULT_VAR_PATH, "$game_varpath", [Path to the Hengband var folder])
43+DEFAULT_VAR_PATH="$game_varpath"
44+AC_SUBST(DEFAULT_VAR_PATH)
3645
3746 dnl Checks for programs.
3847 AC_PROG_CC
--- a/lib/apex/Makefile.am
+++ b/lib/apex/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
77 $(angband_files)
88
99 if SET_GID
10-angbanddir = @DEFAULT_PATH@apex
10+angbanddir = @DEFAULT_VAR_PATH@/apex
1111
1212 angband_DATA = \
1313 $(angband_files)
--- a/lib/bone/Makefile.am
+++ b/lib/bone/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
77 $(angband_files)
88
99 if SET_GID
10-angbanddir = @DEFAULT_PATH@bone
10+angbanddir = @DEFAULT_VAR_PATH@/bone
1111
1212 angband_DATA = \
1313 $(angband_files)
--- a/lib/data/Makefile.am
+++ b/lib/data/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
77 $(angband_files)
88
99 if SET_GID
10-angbanddir = @DEFAULT_PATH@data
10+angbanddir = @DEFAULT_VAR_PATH@/data
1111
1212 angband_DATA = \
1313 $(angband_files)
--- a/lib/edit/Makefile.am
+++ b/lib/edit/Makefile.am
@@ -22,7 +22,7 @@ EXTRA_DIST = \
2222 $(angband_files)
2323
2424 if SET_GID
25-angbanddir = @DEFAULT_PATH@edit
25+angbanddir = @DEFAULT_LIB_PATH@/edit
2626
2727 angband_DATA = \
2828 $(angband_files)
--- a/lib/file/Makefile.am
+++ b/lib/file/Makefile.am
@@ -20,7 +20,7 @@ EXTRA_DIST = \
2020 $(angband_files)
2121
2222 if SET_GID
23-angbanddir = @DEFAULT_PATH@file
23+angbanddir = @DEFAULT_LIB_PATH@/file
2424
2525 angband_DATA = \
2626 $(angband_files)
--- a/lib/help/Makefile.am
+++ b/lib/help/Makefile.am
@@ -26,7 +26,7 @@ EXTRA_DIST = \
2626 $(angband_files)
2727
2828 if SET_GID
29-angbanddir = @DEFAULT_PATH@help
29+angbanddir = @DEFAULT_LIB_PATH@/help
3030
3131 angband_DATA = \
3232 $(angband_files)
--- a/lib/info/Makefile.am
+++ b/lib/info/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
77 $(angband_files)
88
99 if SET_GID
10-angbanddir = @DEFAULT_PATH@info
10+angbanddir = @DEFAULT_LIB_PATH@/info
1111
1212 angband_DATA = \
1313 $(angband_files)
--- a/lib/pref/Makefile.am
+++ b/lib/pref/Makefile.am
@@ -18,7 +18,7 @@ EXTRA_DIST = \
1818 $(angband_files)
1919
2020 if SET_GID
21-angbanddir = @DEFAULT_PATH@pref
21+angbanddir = @DEFAULT_LIB_PATH@/pref
2222
2323 angband_DATA = \
2424 $(angband_files)
--- a/lib/save/Makefile.am
+++ b/lib/save/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
77 $(angband_files)
88
99 if SET_GID
10-angbanddir = @DEFAULT_PATH@save
10+angbanddir = @DEFAULT_VAR_PATH@/save
1111
1212 angband_DATA = \
1313 $(angband_files)
--- a/lib/script/Makefile.am
+++ b/lib/script/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
77 $(angband_files)
88
99 if SET_GID
10-angbanddir = @DEFAULT_PATH@script
10+angbanddir = @DEFAULT_LIB_PATH@/script
1111
1212 angband_DATA = \
1313 $(angband_files)
--- a/lib/user/Makefile.am
+++ b/lib/user/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
77 $(angband_files)
88
99 if SET_GID
10-angbanddir = @DEFAULT_PATH@user
10+angbanddir = @DEFAULT_VAR_PATH@/user
1111
1212 angband_DATA = \
1313 $(angband_files)
--- a/lib/xtra/graf/Makefile.am
+++ b/lib/xtra/graf/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
77 $(angband_files)
88
99 if SET_GID
10-angbanddir = @DEFAULT_PATH@xtra/graf
10+angbanddir = @DEFAULT_LIB_PATH@/xtra/graf
1111
1212 angband_DATA = \
1313 $(angband_files)
--- a/src/externs.h
+++ b/src/externs.h
@@ -618,7 +618,7 @@ extern s16b f_tag_to_index(concptr str);
618618 extern errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax);
619619
620620 /* init2.c */
621-extern void init_file_paths(char *path);
621+extern void init_file_paths(char *libpath, char *varpath);
622622 extern concptr err_str[PARSE_ERROR_MAX];
623623 extern errr init_v_info(void);
624624 extern errr init_buildings(void);
--- a/src/init2.c
+++ b/src/init2.c
@@ -81,9 +81,9 @@ static void put_title(void);
8181 * try several base "path" values until a good one is found.
8282 * </pre>
8383 */
84-void init_file_paths(char *path)
84+void init_file_paths(char *libpath, char *varpath)
8585 {
86- char *tail;
86+ char *libtail, *vartail;
8787
8888 #ifdef PRIVATE_USER_PATH
8989 char buf[1024];
@@ -111,52 +111,53 @@ void init_file_paths(char *path)
111111 /*** Prepare the "path" ***/
112112
113113 /* Hack -- save the main directory */
114- ANGBAND_DIR = string_make(path);
114+ ANGBAND_DIR = string_make(libpath);
115115
116- /* Prepare to append to the Base Path */
117- tail = path + strlen(path);
116+ /* Prepare to append to the Base Paths */
117+ libtail = libpath + strlen(libpath);
118+ vartail = varpath + strlen(varpath);
118119
119120 /*** Build the sub-directory names ***/
120121
121122 /* Build a path name */
122- strcpy(tail, "apex");
123- ANGBAND_DIR_APEX = string_make(path);
123+ strcpy(vartail, "apex");
124+ ANGBAND_DIR_APEX = string_make(varpath);
124125
125126 /* Build a path name */
126- strcpy(tail, "bone");
127- ANGBAND_DIR_BONE = string_make(path);
127+ strcpy(vartail, "bone");
128+ ANGBAND_DIR_BONE = string_make(varpath);
128129
129130 /* Build a path name */
130- strcpy(tail, "data");
131- ANGBAND_DIR_DATA = string_make(path);
131+ strcpy(vartail, "data");
132+ ANGBAND_DIR_DATA = string_make(varpath);
132133
133134 /* Build a path name */
134- strcpy(tail, "edit");
135- ANGBAND_DIR_EDIT = string_make(path);
135+ strcpy(libtail, "edit");
136+ ANGBAND_DIR_EDIT = string_make(libpath);
136137
137138 /* Build a path name */
138- strcpy(tail, "script");
139- ANGBAND_DIR_SCRIPT = string_make(path);
139+ strcpy(libtail, "script");
140+ ANGBAND_DIR_SCRIPT = string_make(libpath);
140141
141142 /* Build a path name */
142- strcpy(tail, "file");
143- ANGBAND_DIR_FILE = string_make(path);
143+ strcpy(libtail, "file");
144+ ANGBAND_DIR_FILE = string_make(libpath);
144145
145146 /* Build a path name */
146- strcpy(tail, "help");
147- ANGBAND_DIR_HELP = string_make(path);
147+ strcpy(libtail, "help");
148+ ANGBAND_DIR_HELP = string_make(libpath);
148149
149150 /* Build a path name */
150- strcpy(tail, "info");
151- ANGBAND_DIR_INFO = string_make(path);
151+ strcpy(libtail, "info");
152+ ANGBAND_DIR_INFO = string_make(libpath);
152153
153154 /* Build a path name */
154- strcpy(tail, "pref");
155- ANGBAND_DIR_PREF = string_make(path);
155+ strcpy(libtail, "pref");
156+ ANGBAND_DIR_PREF = string_make(libpath);
156157
157158 /* Build a path name */
158- strcpy(tail, "save");
159- ANGBAND_DIR_SAVE = string_make(path);
159+ strcpy(vartail, "save");
160+ ANGBAND_DIR_SAVE = string_make(varpath);
160161
161162 #ifdef PRIVATE_USER_PATH
162163
@@ -169,14 +170,14 @@ void init_file_paths(char *path)
169170 #else /* PRIVATE_USER_PATH */
170171
171172 /* Build a path name */
172- strcpy(tail, "user");
173- ANGBAND_DIR_USER = string_make(path);
173+ strcpy(vartail, "user");
174+ ANGBAND_DIR_USER = string_make(varpath);
174175
175176 #endif /* PRIVATE_USER_PATH */
176177
177178 /* Build a path name */
178- strcpy(tail, "xtra");
179- ANGBAND_DIR_XTRA = string_make(path);
179+ strcpy(libtail, "xtra");
180+ ANGBAND_DIR_XTRA = string_make(libpath);
180181
181182
182183 #ifdef NeXT
@@ -209,8 +210,8 @@ void init_file_paths(char *path)
209210 string_free(ANGBAND_DIR_DATA);
210211
211212 /* Build a new path name */
212- sprintf(tail, "data-%s", next);
213- ANGBAND_DIR_DATA = string_make(path);
213+ sprintf(vartail, "data-%s", next);
214+ ANGBAND_DIR_DATA = string_make(varpath);
214215 }
215216 }
216217
--- a/src/main-mac.c
+++ b/src/main-mac.c
@@ -7016,7 +7016,7 @@ static void init_stuff(void)
70167016 while (1)
70177017 {
70187018 /* Prepare the paths */
7019- init_file_paths(path);
7019+ init_file_paths(path, path);
70207020
70217021 /* Build the filename */
70227022 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
--- a/src/main-win.c
+++ b/src/main-win.c
@@ -5440,7 +5440,7 @@ static void init_stuff(void)
54405440 validate_dir(path, TRUE);
54415441
54425442 /* Init the file paths */
5443- init_file_paths(path);
5443+ init_file_paths(path, path);
54445444
54455445 /* Hack -- Validate the paths */
54465446 validate_dir(ANGBAND_DIR_APEX, FALSE);
--- a/src/main.c
+++ b/src/main.c
@@ -80,12 +80,13 @@ static void create_user_dir(void)
8080 * Initialize and verify the file paths, and the score file.
8181 *
8282 * Use the ANGBAND_PATH environment var if possible, else use
83- * DEFAULT_PATH, and in either case, branch off appropriately.
83+ * DEFAULT_(LIB|VAR)_PATH, and in either case, branch off
84+ * appropriately.
8485 *
8586 * First, we'll look for the ANGBAND_PATH environment variable,
8687 * and then look for the files in there. If that doesn't work,
87- * we'll try the DEFAULT_PATH constant. So be sure that one of
88- * these two things works...
88+ * we'll try the DEFAULT_(LIB|VAR)_PATH constants. So be sure
89+ * that one of these two things works...
8990 *
9091 * We must ensure that the path ends with "PATH_SEP" if needed,
9192 * since the "init_file_paths()" function will simply append the
@@ -97,7 +98,7 @@ static void create_user_dir(void)
9798 */
9899 static void init_stuff(void)
99100 {
100- char path[1024];
101+ char libpath[1024], varpath[1024];
101102
102103 concptr tail;
103104
@@ -105,16 +106,19 @@ static void init_stuff(void)
105106 tail = getenv("ANGBAND_PATH");
106107
107108 /* Use the angband_path, or a default */
108- strncpy(path, tail ? tail : DEFAULT_PATH, 511);
109+ strncpy(libpath, tail ? tail : DEFAULT_LIB_PATH, 511);
110+ strncpy(varpath, tail ? tail : DEFAULT_VAR_PATH, 511);
109111
110- /* Make sure it's terminated */
111- path[511] = '\0';
112+ /* Make sure they're terminated */
113+ libpath[511] = '\0';
114+ varpath[511] = '\0';
112115
113116 /* Hack -- Add a path separator (only if needed) */
114- if (!suffix(path, PATH_SEP)) strcat(path, PATH_SEP);
117+ if (!suffix(libpath, PATH_SEP)) strcat(libpath, PATH_SEP);
118+ if (!suffix(varpath, PATH_SEP)) strcat(varpath, PATH_SEP);
115119
116120 /* Initialize */
117- init_file_paths(path);
121+ init_file_paths(libpath, varpath);
118122 }
119123
120124
--- a/src/z-config.h
+++ b/src/z-config.h
@@ -308,8 +308,19 @@
308308 * actual location of the "lib" folder, for example, "/tmp/angband/lib/"
309309 * or "/usr/games/lib/angband/", or "/pkg/angband/lib".
310310 */
311-#ifndef DEFAULT_PATH
312-# define DEFAULT_PATH "./lib/"
311+#ifndef DEFAULT_LIB_PATH
312+# define DEFAULT_LIB_PATH "./lib/"
313+#endif
314+
315+
316+/*
317+ * OPTION: Set the "default" path to the angband "var" directory.
318+ *
319+ * This is like DEFAULT_LIB_PATH, but is for files that will be
320+ * modified after installation.
321+ */
322+#ifndef DEFAULT_VAR_PATH
323+# define DEFAULT_VAR_PATH DEFAULT_LIB_PATH
313324 #endif
314325
315326