annotate lib-src/ellcc.c @ 438:84b14dcb0985 r21-2-27

Import from CVS: tag r21-2-27
author cvs
date Mon, 13 Aug 2007 11:32:25 +0200
parents 3ecd8885ac67
children 8de8e3f6228a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* ellcc.c - front-end for compiling Emacs modules
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1998, 1999 J. Kean Johnston.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 Author: J. Kean Johnston (jkj@sco.com).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 Please mail bugs and suggestions to the XEmacs maintainer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 Here's the scoop. We would really like this to be a shell script, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 the various Windows platforms don't have reliable scripting that suits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 our needs. We don't want to rely on perl or some other such language
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 so we have to roll our own executable to act as a front-end for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 compiler.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 This program is used to invoke the compiler, the linker and to generate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 the module specific documentation and initialization code. We assume we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 are in 'compile' mode unless we encounter an argument which tells us
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 that we're not. We take all arguments and pass them on directly to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 compiler, except for a few which are specific to this program:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 --mode=VALUE This sets the program mode. VALUE can be one of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 compile, link, init or verbose.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 --mod-name=NAME Sets the module name to the string NAME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 --mod-title=TITLE Sets the module title to the string TITLE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 --mod-version=VER Sets the module version to the string VER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 The idea is that Makefiles will use ellcc as the compiler for making
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 dynamic Emacs modules, and life should be as simple as:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 make CC=ellcc LD='ellcc --mode=link'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 The only additional requirement is an entry in the Makefile to produce
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 the module initialization file, which will usually be something along
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 the lines of:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 modinit.c: $(SRCS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 ellcc --mode=init --mod-name=\"$(MODNAME)\" \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 --mod-title=\"$(MODTITLE)\" --mod-version=\"$(MODVERSION)\" \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 -o $@ $(SRCS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 See the samples for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
61 #include <config.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #include <errno.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 #ifdef HAVE_UNISTD_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 # include <unistd.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #endif /* HAVE_UNISTD_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 #define EMODULES_GATHER_VERSION
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
74
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
75 #include <emodules.h>
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
76 #include <ellcc.h> /* Generated files must be included using <...> */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 #define DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #ifndef HAVE_SHLIB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 main (int argc, char *argv[])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 fprintf (stderr, "Dynamic modules not supported on this platform\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 return EXIT_FAILURE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 * Try to figure out the commands we need to use to create shared objects,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 * and how to compile for PIC mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 * xnew, xrnew -- allocate, reallocate storage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 * SYNOPSIS: Type *xnew (int n, Type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 * Type *xrnew (OldPointer, int n, Type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 #ifdef chkmalloc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 # include "chkmalloc.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 # define xrnew(op,n,Type) ((Type *) trace_realloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (op), (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 static void *xmalloc (size_t);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 static void fatal (char *, char *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 static void add_to_argv (CONST char *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 static void do_compile_mode (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 static void do_link_mode (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 static void do_init_mode (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 #define SSTR(S) ((S)?(S):"")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 #define ELLCC_COMPILE_MODE 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 #define ELLCC_LINK_MODE 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 #define ELLCC_INIT_MODE 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 int ellcc_mode = ELLCC_COMPILE_MODE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 char *progname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 char *mod_name = (char *)0, *mod_version = (char *)0, *mod_title = (char *)0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 char *mod_output = (char *)0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 int verbose = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 char **exec_argv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 int exec_argc = 1, *exec_args;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 int real_argc = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 int prog_argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 char **prog_argv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 * We allow the user to over-ride things in the environment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 char *ellcc, *ellld, *ellcflags, *ellldflags, *ellpicflags, *elldllflags;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 #define OVERENV(STR,EVAR,DFLT) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 STR = getenv(EVAR); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 if ((STR) == (char *)0) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 STR = DFLT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 main (int argc, char *argv[])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 char *tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 int i, done_mode = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 prog_argc = argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 prog_argv = argv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 #if defined(MSDOS) || defined(WINDOWSNT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 tmp = strrchr (argv[0], '\\');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 if (tmp != (char *)0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 tmp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 #elif !defined (VMS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 tmp = strrchr (argv[0], '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 if (tmp != (char *)0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 tmp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 tmp = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 if (tmp != (char *)0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 progname = tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 progname = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 tmp = &progname[strlen(progname)-2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 if (strcmp (tmp, "cc") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 ellcc_mode = ELLCC_COMPILE_MODE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 else if (strcmp (tmp, "ld") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 ellcc_mode = ELLCC_LINK_MODE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 else if (strcmp (tmp, "it") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 ellcc_mode = ELLCC_INIT_MODE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 exec_argv = xnew(argc + 20, char *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 exec_args = xnew(argc, int);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 for (i = 0; i < argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 exec_args[i] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 if (argc < 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 fatal ("too few arguments", (char *)0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 exec_args[0] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 for (i = 1; i < argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 if (strncmp (argv[i], "--mode=", 7) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 char *modeopt = argv[i] + 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 if (done_mode && strcmp (modeopt, "verbose"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 fatal ("more than one mode specified", (char *) 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 if (strcmp (modeopt, "link") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 done_mode++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 ellcc_mode = ELLCC_LINK_MODE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 else if (strcmp (modeopt, "compile") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 done_mode++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 ellcc_mode = ELLCC_COMPILE_MODE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 else if (strcmp (modeopt, "init") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 done_mode++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 ellcc_mode = ELLCC_INIT_MODE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 else if (strcmp (modeopt, "verbose") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 verbose += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 else if (strcmp (argv[i], "--mod-location") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 printf ("%s\n", ELLCC_MODDIR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 else if (strcmp (argv[i], "--mod-site-location") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 printf ("%s\n", ELLCC_SITEMODS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 else if (strcmp (argv[i], "--mod-archdir") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 printf ("%s\n", ELLCC_ARCHDIR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 else if (strcmp (argv[i], "--mod-config") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 printf ("%s\n", ELLCC_CONFIG);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 else if (strncmp (argv[i], "--mod-name=", 11) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 mod_name = argv[i] + 11;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 else if (strncmp (argv[i], "--mod-title=", 12) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 mod_title = argv[i] + 12;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 else if (strncmp (argv[i], "--mod-version=", 14) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 mod_version = argv[i] + 14;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 else if (strncmp (argv[i], "--mod-output=", 13) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 mod_output = argv[i] + 13;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 exec_args[exec_argc] = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 exec_argc++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 if (ellcc_mode == ELLCC_LINK_MODE && mod_output == (char *)0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 fatal ("must specify --mod-output when linking", (char *)0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 if (ellcc_mode == ELLCC_INIT_MODE && mod_output == (char *)0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 fatal ("must specify --mod-output when creating init file", (char *)0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 if (ellcc_mode == ELLCC_INIT_MODE && mod_name == (char *)0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 fatal ("must specify --mod-name when creating init file", (char *)0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 * We now have the list of arguments to pass to the compiler or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 * linker (or to process for doc files). We can do the real work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 * now.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 if (verbose)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 printf ("ellcc driver version %s for EMODULES version %s (%ld)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 ELLCC_EMACS_VER, EMODULES_VERSION, EMODULES_REVISION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 if (verbose >= 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 printf (" mode = %d (%s)\n", ellcc_mode,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 ellcc_mode == ELLCC_COMPILE_MODE ? "compile" :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 ellcc_mode == ELLCC_LINK_MODE ? "link" : "init");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 printf (" module_name = \"%s\"\n", SSTR(mod_name));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 printf (" module_title = \"%s\"\n", SSTR(mod_title));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 printf (" module_version = \"%s\"\n", SSTR(mod_version));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 printf (" CC = %s\n", ELLCC_CC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 printf (" CFLAGS = %s\n", ELLCC_CFLAGS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 printf (" CC PIC flags = %s\n", ELLCC_DLL_CFLAGS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 printf (" LD = %s\n", ELLCC_DLL_LD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 printf (" LDFLAGS = %s\n", ELLCC_DLL_LDFLAGS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 printf (" architecture = %s\n", ELLCC_CONFIG);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 printf (" Include directory = %s/include\n", ELLCC_ARCHDIR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 printf ("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 if (exec_argc < 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 fatal ("too few arguments", (char *) 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 * Get the over-rides from the environment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 OVERENV(ellcc, "ELLCC", ELLCC_CC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 OVERENV(ellld, "ELLLD", ELLCC_DLL_LD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 OVERENV(ellcflags, "ELLCFLAGS", ELLCC_CFLAGS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 OVERENV(ellldflags, "ELLLDFLAGS", ELLCC_LDFLAGS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 OVERENV(elldllflags, "ELLDLLFLAGS", ELLCC_DLL_LDFLAGS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 OVERENV(ellpicflags, "ELLPICFLAGS", ELLCC_DLL_CFLAGS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 if (ellcc_mode == ELLCC_COMPILE_MODE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 do_compile_mode();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 else if (ellcc_mode == ELLCC_LINK_MODE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 do_link_mode();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 do_init_mode();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 * The arguments to pass on to the desired program have now been set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 * up and we can run the program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 if (verbose)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 for (i = 0; i < real_argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 printf ("%s ", exec_argv[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 printf ("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 fflush (stdout);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 exec_argv[real_argc] = (char *)0; /* Terminate argument list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 i = execvp (exec_argv[0], exec_argv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 if (verbose)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 printf ("%s exited with status %d\n", exec_argv[0], i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 return i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 /* Like malloc but get fatal error if memory is exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 static void *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 xmalloc (size_t size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 void *result = malloc (size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 fatal ("virtual memory exhausted", (char *)0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 /* Print error message and exit. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 fatal (char *s1, char *s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 fprintf (stderr, "%s: ", progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 fprintf (stderr, "\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 exit (EXIT_FAILURE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 * Add a string to the argument vector list that will be passed on down
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 * to the compiler or linker. We need to split individual words into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 * arguments, taking quoting into account. This can get ugly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 add_to_argv (CONST char *str)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 int sm = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 CONST char *s = (CONST char *)0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 if ((str == (CONST char *)0) || (str[0] == '\0'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 while (*str)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 switch (sm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 case 0: /* Start of case - string leading whitespace */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 if (isspace (*str))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 str++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 sm = 1; /* Change state to non-whitespace */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 s = str; /* Mark the start of THIS argument */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 case 1: /* Non-whitespace character. Mark the start */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 if (isspace (*str))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 /* Reached the end of the argument. Add it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 int l = str-s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 exec_argv[real_argc] = xnew (l+2, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 strncpy (exec_argv[real_argc], s, l);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 exec_argv[real_argc][l] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 real_argc++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 sm = 0; /* Back to start state */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 s = (CONST char *)0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 else if (*str == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 sm = 2; /* Escaped character */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 str++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 else if (*str == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 /* Start of quoted string (single quotes) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 sm = 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 else if (*str == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 /* Start of quoted string (double quotes) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 sm = 4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 /* This was just a normal character. Advance the pointer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 str++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 case 2: /* Escaped character */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 str++; /* Preserve the quoted character */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 sm = 1; /* Go back to gathering state */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 case 3: /* Inside single quoted string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 if (*str == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 sm = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 str++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 case 4: /* inside double quoted string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 if (*str == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 sm = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 str++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 if (s != (CONST char *)0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 int l = str-s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 exec_argv[real_argc] = xnew (l+2, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 strncpy (exec_argv[real_argc], s, l);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 exec_argv[real_argc][l] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 real_argc++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 s = (CONST char *)0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 * For compile mode, things are pretty straight forward. All we need to do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 * is build up the argument vector and exec() it. We must just make sure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 * that we get all of the required arguments in place.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 do_compile_mode (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 char ts[4096]; /* Plenty big enough */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 add_to_argv (ellcc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 add_to_argv (ellcflags);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 add_to_argv (ellpicflags);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 add_to_argv ("-DPIC");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 add_to_argv ("-DEMACS_MODULE");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 #ifdef XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 add_to_argv ("-DXEMACS_MODULE"); /* Cover both cases */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 add_to_argv ("-Dxemacs");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 add_to_argv ("-Demacs");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 sprintf (ts, "-I%s/include", ELLCC_ARCHDIR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 add_to_argv (ts);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 add_to_argv (ELLCC_CF_ALL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 for (i = 1; i < exec_argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 exec_argv[real_argc++] = strdup (prog_argv[exec_args[i]]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 * For link mode, things are a little bit more complicated. We need to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 * insert the linker commands first, replace any occurrence of ELLSONAME
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 * with the desired output file name, insert the output arguments, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 * all of the provided arguments, then the final post arguments. Once
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 * all of this has been done, the argument vector is ready to run.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 do_link_mode (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 int i,x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 char *t, ts[4096]; /* Plenty big enough */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 add_to_argv (ellld);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 add_to_argv (ellldflags);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 add_to_argv (elldllflags);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 add_to_argv (ELLCC_DLL_LDO);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 add_to_argv (mod_output);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 for (i = 1; i < exec_argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 exec_argv[real_argc++] = strdup (prog_argv[exec_args[i]]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 add_to_argv (ELLCC_DLL_POST);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 * Now go through each argument and replace ELLSONAME with mod_output.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 for (i = 0; i < real_argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 ts[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 t = exec_argv[i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 while (*t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 if (*t == 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 if (strncmp (t, "ELLSONAME", 9) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 strcat (ts, mod_output);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 t += 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 x += strlen (mod_output);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 ts[x] = *t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 x++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 ts[x] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 ts[x] = *t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 x++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 ts[x] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 t++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 free (exec_argv[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 exec_argv[i] = strdup (ts);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 * In init mode, things are a bit easier. We assume that the only things
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 * passed on the command line are the names of source files which the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 * make-doc program will be processing. We prepare the output file with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 * the header information first, as make-doc will append to the file by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 * special dispensation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 do_init_mode (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 char ts[4096]; /* Plenty big enough */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 char *mdocprog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 FILE *mout = fopen (mod_output, "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 if (mout == (FILE *)0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 fatal ("failed to open output file", mod_output);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 fprintf (mout, "/* DO NOT EDIT - AUTOMATICALLY GENERATED */\n\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 fprintf (mout, "#include <emodules.h>\n\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 fprintf (mout, "const long emodule_compiler = %ld;\n", EMODULES_REVISION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 fprintf (mout, "const char *emodule_name = \"%s\";\n", SSTR(mod_name));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 fprintf (mout, "const char *emodule_version = \"%s\";\n", SSTR(mod_version));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 fprintf (mout, "const char *emodule_title = \"%s\";\n", SSTR(mod_title));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 fprintf (mout, "\n\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 fprintf (mout, "void docs_of_%s()\n", SSTR(mod_name));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 fclose (mout);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 sprintf (ts, "%s/make-docfile", ELLCC_ARCHDIR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 OVERENV(mdocprog, "ELLMAKEDOC", ts);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 add_to_argv (mdocprog);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 sprintf (ts, "-E %s", mod_output);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 add_to_argv (ts);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 for (i = 1; i < exec_argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 exec_argv[real_argc++] = strdup (prog_argv[exec_args[i]]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 #endif /* HAVE_SHLIB */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563