(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.
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
# 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'
cp -f $^ $@
endif
-#
+# Distributing
+
.PHONY: dist-source
dist-source: $(src_distgen) $(bld_distgen)
$(tarball) $(TARNAME)-$(VERSION) $(bld_distgen) -C $(srcdir) $(src_distgen) $(src)
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) <$< >$@
"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,
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 */
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.
/* 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@";
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);