2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * doconfig.c: Generates the gamesdef.h file used to build the game, and
29 * the various make include files needed to build correctly.
31 * Known contributors to this file:
32 * Steve McClure, 1996-2000
36 #include <sys/types.h>
48 static void wrmakesrc(char *pathname);
49 static void wripglob(char *filename);
50 static void wrauth(char *filename);
51 static void wrgamesdef(char *filename);
53 char *_c_copyright_header =
54 "/*\n * Empire - A multi-player, client/server Internet based war game.\n * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,\n * Ken Stevens, Steve McClure\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * ---\n *\n * See the \"LEGAL\", \"LICENSE\", \"CREDITS\" and \"README\" files for all the\n * related information and legal notices. It is expected that any future\n * projects/authors will amend these files as needed.\n *\n * ---\n *\n * gamesdef.h: This is an auto-generated file.\n * \n * Known contributors to this file:\n * Automatically generated by doconfig.c\n */\n\n";
56 char *_ipglob_copyright_header =
57 "/*\n * Empire - A multi-player, client/server Internet based war game.\n * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,\n * Ken Stevens, Steve McClure\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * ---\n *\n * See the \"LEGAL\", \"LICENSE\", \"CREDITS\" and \"README\" files for all the\n * related information and legal notices. It is expected that any future\n * projects/authors will amend these files as needed.\n *\n * ---\n *\n * ipglob.c: This is an auto-generated file.\n * \n * Known contributors to this file:\n * Automatically generated by doconfig.c\n */\n\n";
60 #if defined(__GLIBC__) || defined(FBSD) || defined(__APPLE_) || defined(_WIN32)
61 #define safe_getcwd() getcwd(NULL, 0)
69 char *buf = malloc(size);
72 if (getcwd (buf, size))
89 if ((pathname = safe_getcwd()) == NULL) {
90 printf("Can't get current path!\n");
94 cp = strrchr(pathname, '/');
96 cp = strrchr(pathname, '/');
99 cp = strrchr(pathname, '\\');
101 cp = strrchr(pathname, '\\');
104 printf("Configuring...\n");
106 sprintf(buf, "%s/include/gamesdef.h", pathname);
108 sprintf(buf, "%s/src/client/ipglob.c", pathname);
112 printf("making directory %s\n", EP);
113 if (mkdir(EP, 0755)) {
114 printf("mkdir failed on %s, exiting.\n", EP);
118 sprintf(buf, "%s/data", EP);
119 if (access(buf, 0)) {
120 printf("making directory %s\n", buf);
121 if (mkdir(buf, 0755)) {
122 printf("mkdir failed on %s, exiting.\n", buf);
126 sprintf(buf, "%s/data/auth", EP);
132 wrmakesrc(char *pathname)
137 sprintf(buf, "%s/src/make.src", pathname);
138 if ((fp = fopen(buf, "w")) == NULL) {
139 printf("Cannot open %s for writing, exiting.\n", buf);
142 fprintf(fp, "# make.src - Wolfpack, 1996-2000\n");
144 "# Source tree absolute pathname - auto generated.\n\n");
145 fprintf(fp, "SRCDIR = %s\n", pathname);
150 wripglob(char *filename)
154 printf("Writing %s\n", filename);
155 if ((fp = fopen(filename, "w")) == NULL) {
156 printf("Cannot open %s for writing, exiting.\n", filename);
159 fprintf(fp, _ipglob_copyright_header);
160 fprintf(fp, "#include \"misc.h\"\n");
161 fprintf(fp, "s_char empirehost[] = \"%s\";\n", HN);
162 fprintf(fp, "s_char empireport[] = \"%d\";\n", PN);
167 wrauth(char *filename)
171 printf("Writing %s\n", filename);
172 if ((fp = fopen(filename, "w")) == NULL) {
173 printf("Cannot open %s for writing, exiting.\n", filename);
177 fprintf(fp, "# Wolfpack, 1996-2000\n#\n");
179 "# Empire Authorization File - Users listed will be allowed to log in as deities.\n#\n");
180 fprintf(fp, "# Format is:\n");
181 fprintf(fp, "# hostname that authorized user uses on a line\n");
182 fprintf(fp, "# username that authorized user uses on a line\n#\n");
183 fprintf(fp, "# REMEMBER TO USE PAIRS OF LINES!\n#\n");
184 fprintf(fp, "# Example:\n#\n");
185 fprintf(fp, "#nowhere.land.edu\n#nowhereman\n");
186 fprintf(fp, "%s\n%s\n", HN, UN);
187 fprintf(fp, "%s\n%s\n", IP, UN);
188 fprintf(fp, "127.0.0.1\n%s\n", UN);
193 wrgamesdef(char *filename)
204 for (i = 0; i < strlen(EP); i++) {
213 c = buf[strlen(buf) - 1];
214 if (strchr("dhm", c) && strlen(buf) > 0) {
218 (((double)s_p_etu * 60.0 * 60.0 * 24.0) / (double)ET);
220 s_p_etu = (((double)s_p_etu * 60.0 * 60.0) / (double)ET);
222 s_p_etu = (((double)s_p_etu * 60.0) / (double)ET);
224 printf("ETU frequency is bad - using 10 minutes.\n");
228 printf("Writing %s\n", filename);
229 if ((fp = fopen(filename, "w")) == NULL) {
230 printf("Cannot open %s for writing, exiting.\n", filename);
233 fprintf(fp, _c_copyright_header);
234 fprintf(fp, "/*\n * Wolfpack, 1996-2000\n *\n");
236 " * gamesdef.h - generated automatically by doconfig. Feel\n");
238 " * free to change these, but if you rebuild with overwrite on\n");
239 fprintf(fp, " * this file will be overwritten again.\n");
240 fprintf(fp, " */\n\n");
241 fprintf(fp, "#ifndef _GAMESDEF_H_\n");
242 fprintf(fp, "#define _GAMESDEF_H_\n\n");
243 fprintf(fp, "#define EMPDIR \"%s\"\n", EP);
244 fprintf(fp, "#define PRVNAM \"%s\"\n", PV);
245 fprintf(fp, "#define PRVLOG \"%s\"\n", EM);
246 fprintf(fp, "#define GET_SOURCE \"using:\\n ftp://ftp.wolfpackempire.com/pub/empire/server or \\n http://www.wolfpackempire.com/\"\n");
247 fprintf(fp, "#define EMP_HOST \"%s\"\n", IP);
248 fprintf(fp, "#define EMP_PORT \"%d\"\n\n", PN);
249 fprintf(fp, "#define MAXNOC %d\n\n", MC);
250 fprintf(fp, "#define DEF_WORLD_X %d\n", WX);
251 fprintf(fp, "#define DEF_WORLD_Y %d\n\n", WY);
252 fprintf(fp, "#define DEF_S_P_ETU %d\n", s_p_etu);
253 fprintf(fp, "#define ETUS %d\n\n", ET);
255 fprintf(fp, "#define BLITZ 1\n\n");
256 fprintf(fp, "#endif /* _GAMESDEF_H_ */\n");