(builtindir): New econfig key, variable and make variable.
(subst.in): Substitute it. Fix prerequisites. (read_builtin_tables): New. (main): Call it. This doesn't do anything, because no builtin tables have been defined.
This commit is contained in:
parent
ac0263d2ae
commit
9a30f30107
6 changed files with 49 additions and 3 deletions
9
Make.mk
9
Make.mk
|
@ -66,6 +66,7 @@ depcomp = $(SHELL) $(srcdir)/depcomp
|
|||
tarball = $(SHELL) $(scripts)/tarball
|
||||
econfig := $(sysconfdir)/empire/econfig
|
||||
gamedir := $(localstatedir)/empire
|
||||
builtindir := $(datadir)/empire/builtin
|
||||
einfodir := $(datadir)/empire/info.nr
|
||||
ehtmldir := $(datadir)/empire/info.html
|
||||
|
||||
|
@ -73,9 +74,10 @@ ehtmldir := $(datadir)/empire/info.html
|
|||
# Recursively expanded so that $@ and $< work.
|
||||
subst.in = sed \
|
||||
-e 's?@configure_input\@?$(notdir $@). Generated from $(notdir $<) by GNUmakefile.?g' \
|
||||
-e 's?@builtindir\@?$(builtindir)?g' \
|
||||
-e 's?@econfig\@?$(econfig)?g' \
|
||||
-e 's?@gamedir\@?$(gamedir)?g' \
|
||||
-e 's?@einfodir\@?$(einfodir)?g' \
|
||||
-e 's?@gamedir\@?$(gamedir)?g' \
|
||||
-e 's/@EMPIREHOST\@/$(EMPIREHOST)/g' \
|
||||
-e 's/@EMPIREPORT\@/$(EMPIREPORT)/g'
|
||||
|
||||
|
@ -291,7 +293,8 @@ sources.mk: $(srcdir)/sources.mk
|
|||
cp -f $^ $@
|
||||
endif
|
||||
|
||||
#
|
||||
# Distributing
|
||||
|
||||
.PHONY: dist-source
|
||||
dist-source: $(src_distgen) $(bld_distgen)
|
||||
$(tarball) $(TARNAME)-$(VERSION) $(bld_distgen) -C $(srcdir) $(src_distgen) $(src)
|
||||
|
@ -342,7 +345,7 @@ GNUmakefile: GNUmakefile.in config.status
|
|||
config.status: configure
|
||||
./config.status --recheck
|
||||
|
||||
src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile
|
||||
src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile Make.mk
|
||||
$(subst.in) <$< >$@
|
||||
|
||||
|
||||
|
|
|
@ -73,6 +73,10 @@ EMPCFBOTH("data", gamedir, char *, NSC_STRING, KM_INTERNAL,
|
|||
"Directory where this game's data is stored")
|
||||
EMPCFBOTH("info", infodir, char *, NSC_STRING, KM_INTERNAL,
|
||||
"Directory where info pages are stored, can be shared among games")
|
||||
EMPCFBOTH("builtin", builtindir, char *, NSC_STRING, KM_INTERNAL,
|
||||
"Directory where builtin files are stored")
|
||||
EMPCF_COMMENT("# Set this to your source tree's src/lib/global to run the server\n"
|
||||
"# without installing it, else leave it alone.")
|
||||
EMPCFBOTH("listen_addr", listen_addr, char *, NSC_STRING, KM_INTERNAL,
|
||||
"Local IP address the server should listen on. \"\" listens on all.")
|
||||
EMPCFBOTH("port", loginport, char *, NSC_STRING, KM_INTERNAL,
|
||||
|
|
|
@ -284,6 +284,7 @@ extern int check_comm_ok(struct comstr *);
|
|||
extern int check_loan_ok(struct lonstr *);
|
||||
extern int check_trade_ok(struct trdstr *);
|
||||
/* conftab.c */
|
||||
extern int read_builtin_tables(void);
|
||||
extern int read_config_tables(void);
|
||||
/* ef_verify.c */
|
||||
/* in file.h */
|
||||
|
|
|
@ -44,6 +44,35 @@
|
|||
|
||||
static int read_config_table_file(char *);
|
||||
|
||||
int
|
||||
read_builtin_tables(void)
|
||||
{
|
||||
struct empfile *ep;
|
||||
FILE *fp;
|
||||
int res;
|
||||
|
||||
for (ep = empfile; ep->name; ep++) {
|
||||
if (!EF_IS_GAME_STATE(ep->uid) && ep->file) {
|
||||
if ((fp = fopen(ep->file, "r")) == NULL) {
|
||||
fprintf(stderr, "Can't open %s for reading (%s)\n",
|
||||
ep->file, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
res = xundump(fp, ep->name, ep->uid);
|
||||
if (res >= 0 && getc(fp) != EOF) {
|
||||
fprintf(stderr, "%s: Junk after the table\n",
|
||||
ep->file);
|
||||
res = EF_BAD;
|
||||
}
|
||||
fclose(fp);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read user configuration tables.
|
||||
* Return 0 on success, -1 on failure.
|
||||
|
|
|
@ -46,6 +46,9 @@ char *configdir;
|
|||
/* User configuration tables to load, relative to configdir */
|
||||
char *config_tables = "";
|
||||
|
||||
/* Where to find built-in configuration tables */
|
||||
char *builtindir = "@builtindir@";
|
||||
|
||||
/* Where to find info pages */
|
||||
char *infodir = "@einfodir@";
|
||||
|
||||
|
|
|
@ -203,6 +203,12 @@ main(int argc, char **argv)
|
|||
if (emp_config(config_file) < 0)
|
||||
exit(EXIT_FAILURE);
|
||||
ef_init();
|
||||
if (chdir(builtindir)) {
|
||||
fprintf(stderr, "Can't chdir to %s (%s)\n", builtindir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (read_builtin_tables() < 0)
|
||||
exit(EXIT_FAILURE);
|
||||
if (chdir(configdir)) {
|
||||
fprintf(stderr, "Can't chdir to %s (%s)\n", configdir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue