GHSRC = errout.h idfsize.h ifdepth.h lapbuf.h \
nparams.h numsize.h obufsize.h \
parbufsize.h pathlength.h strsize.h textsize.h \
- botch_free.h debug.h inputtype.h dobits.h line_prefix.h mkdep.h
+ botch_free.h debug.h inputtype.h dobits.h line_prefix.h
# Other generated files, for 'make clean' only
GENERATED = tokenfile.g Lpars.h LLfiles LL.output lint.out \
domacro.o: inputtype.h
domacro.o: interface.h
domacro.o: macro.h
-domacro.o: mkdep.h
domacro.o: nparams.h
domacro.o: parbufsize.h
domacro.o: textsize.h
main.o: idf.h
main.o: idfsize.h
main.o: macro.h
-main.o: mkdep.h
options.o: charoffset.h
options.o: class.h
options.o: idf.h
options.o: idfsize.h
options.o: macro.h
-options.o: mkdep.h
preprocess.o: LLlex.h
preprocess.o: bits.h
preprocess.o: charoffset.h
preprocess.o: input.h
preprocess.o: inputtype.h
preprocess.o: line_prefix.h
-preprocess.o: mkdep.h
preprocess.o: obufsize.h
replace.o: LLlex.h
replace.o: charoffset.h
*/
-!File: mkdep.h
-#undef MKDEP 1 /* if defined, preprocessor only outputs
- names of files included (not finished yet)
- */
-
-
as its replacement text.
.IP -\fBD\fIname\fR
the same as -\fBD\fIname\fR=1.
-.IP
.IP -\fBU\fIname\fR
.br
undefine the macro name
.IP -\fBM\fIn\fR
set maximum identifier length to
.IR n .
+.IP -\fBd\fR[\fIfile\fR]
+.br
+if \fIfile\fR is not given, do not preprocess, but instead generate a list
+of makefile dependencies and write them to the standard output.
+If \fIfile\fP is given, generate preprocessor output on standard output,
+and generate the list of makefile dependencies on file \fIfile\fP.
+.IP -\fBxs\fR
+when generating makefile dependencies, do not include files from
+/usr/include.
+.IP -\fBxm\fR
+when generating makefile dependencies, generate them in the following format:
+.RS
+.IP "file.o: file1.h"
+.RE
+.IP ""
+where "file.o" is derived from the source file name. Normally, only a list
+of files included is generated.
.PP
The following names are always available unless undefined:
-.RS
.IP __FILE__
The input (or #include) file being compiled
(as a quoted string).
.IP __DATE__
The date and time of compilation as
a Unix ctime quoted string (the trailing newline is removed).
-.RE
#include "class.h"
#include "macro.h"
#include "bits.h"
-#include "mkdep.h"
IMPORT char **inctable; /* list of include directories */
IMPORT char *getwdir();
int nestlevel = -1;
int svnestlevel[30] = {-1};
int nestcount;
+extern int do_preprocess;
char *
GetIdentifier()
inctable[0] = WorkingDir;
if (filenm) {
if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){
-#ifndef MKDEP
- error("cannot find include file \"%s\"", filenm);
-#else
- warning("cannot find include file \"%s\"", filenm);
+ if (do_preprocess) error("cannot find include file \"%s\"", filenm);
+ else warning("cannot find include file \"%s\"", filenm);
add_dependency(filenm);
-#endif
}
else {
-#ifdef MKDEP
add_dependency(result);
-#endif
WorkingDir = getwdir(result);
svnestlevel[++nestcount] = nestlevel;
FileName = result;
#include <alloc.h>
#include <em_arith.h>
#include <assert.h>
+#include <system.h>
#include "file_info.h"
#include "idfsize.h"
-#include "mkdep.h"
-#ifdef MKDEP
#include "idf.h"
#include "macro.h"
-#endif
extern char *symbol2str();
extern char *getwdir();
extern int err_occurred;
+extern int do_dependencies;
+extern char *dep_file;
int idfsize = IDFSIZE;
extern char options[];
+static File *dep_fd = STDOUT;
arith ifval;
do_option(par);
argc--, argv++;
}
-#ifdef MKDEP
- options['P'] = 1;
-#endif
compile(argc - 1, &argv[1]);
exit(err_occurred);
}
source ? source : "stdin");
if (source) WorkingDir = getwdir(dummy);
preprocess(source);
-#ifdef MKDEP
- list_dependencies(source);
-#endif
+ if (do_dependencies) list_dependencies(source);
}
-#ifdef MKDEP
struct idf *file_head;
extern char *strrindex();
}
else source = 0;
}
+ if (dep_file && !sys_open(dep_file, OP_WRITE, &dep_fd)) {
+ fatal("could not open %s", dep_file);
+ }
while (p) {
assert(p->id_resmac == K_FILE);
dependency(p->id_text, source);
}
dependency(s, source)
- char *s;
+ char *s, *source;
{
if (options['s'] && !strncmp(s, "/usr/include/", 13)) {
return;
}
- if (options['m'] && source) print("%s: ", source);
- print("%s\n", s);
+ if (options['m'] && source) {
+ fprint(dep_fd, "%s: %s\n", source, s);
+ }
+ else fprint(dep_fd, "%s\n", s);
}
-#endif
#include "class.h"
#include "macro.h"
#include "idf.h"
-#include "mkdep.h"
char options[128]; /* one for every char */
int inc_pos = 1; /* place where next -I goes */
int inc_max;
int inc_total;
+int do_preprocess = 1;
+int do_dependencies = 0;
char **inctable;
+char *dep_file = 0;
extern int idfsize;
int txt2int();
{
switch(*text++) {
case '-':
-#ifdef MKDEP
case 'x':
-#endif
options[*text] = 1;
break;
default:
-#ifndef MKDEP
error("illegal option: %c", text[-1]);
-#endif
break;
case 'C' : /* comment output */
case 'P' : /* run preprocessor stand-alone, without #'s */
options[*(text-1)] = 1;
break;
+ case 'd' : /* dependency generation */
+ do_dependencies = 1;
+ if (*text) {
+ dep_file = text;
+ }
+ else {
+ do_preprocess = 0;
+ }
+ break;
case 'D' : /* -Dname : predefine name */
{
register char *cp = text, *name, *mactext;
#include "idfsize.h"
#include "bits.h"
#include "line_prefix.h"
-#include "mkdep.h"
#ifdef DOBITS
char bits[128];
#endif
-#ifndef MKDEP
char _obuf[OBUFSIZE];
+extern int do_preprocess;
Xflush()
{
- sys_write(STDOUT, _obuf, OBUFSIZE);
+ if (do_preprocess) sys_write(STDOUT, _obuf, OBUFSIZE);
}
-#endif
preprocess(fn)
char *fn;
{
register int c;
-#ifndef MKDEP
register char *op = _obuf;
register char *ob = &_obuf[OBUFSIZE];
-#endif
char Xbuf[256];
int lineno = 0;
extern char options[];
-#ifndef MKDEP
-#define flush(X) (sys_write(STDOUT,_obuf,X))
+#define flush(X) (! do_preprocess || sys_write(STDOUT,_obuf,X))
#define echo(ch) if (op == ob) { Xflush(); op = _obuf; } *op++ = (ch);
#define newline() echo('\n')
-#else
-#define flush(X)
-#define echo(ch) (ch)
-#define newline()
-#endif
if (! options['P']) {
/* Generate a line directive communicating the