Added dependency generator
This commit is contained in:
parent
8d1bb88fc9
commit
bf66a6ade1
|
@ -43,6 +43,23 @@ and at each return to call the routine
|
|||
.BE procexit .
|
||||
These routines are supplied with one parameter, a pointer to a
|
||||
string containing the name of the procedure.
|
||||
.IP -\fBA\fR[\fIfile\fR]
|
||||
.br
|
||||
if \fIfile\fR is not given, generate a list
|
||||
of makefile dependencies and write them to the standard output.
|
||||
If \fIfile\fP is given,
|
||||
generate the list of makefile dependencies on file \fIfile\fP.
|
||||
.IP -\fBs\fR
|
||||
when generating makefile dependencies, do not include files from
|
||||
/usr/include.
|
||||
.IP -\fBm\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.
|
||||
.IP \fB\-R\fR
|
||||
interpret the input as restricted C (according to the language as
|
||||
described in \fIThe C programming language\fR by Kernighan and Ritchie.)
|
||||
|
|
|
@ -263,6 +263,9 @@ do_include()
|
|||
fatal("cannot open include file \"%s\"", filenm);
|
||||
}
|
||||
else {
|
||||
#ifndef NOPP
|
||||
add_dependency(result);
|
||||
#endif NOPP
|
||||
WorkingDir = getwdir(result);
|
||||
File_Inserted = 1;
|
||||
FileName = result;
|
||||
|
|
|
@ -56,4 +56,5 @@ struct mlist {
|
|||
#define K_LINE 9
|
||||
#define K_UNDEF 10
|
||||
#define K_PRAGMA 11
|
||||
#define K_FILE 100 /* for dependency generator */
|
||||
#endif NOPP
|
||||
|
|
|
@ -28,17 +28,24 @@
|
|||
#include "nocross.h"
|
||||
#include "sizes.h"
|
||||
#include "align.h"
|
||||
#include <assert.h>
|
||||
#include "macro.h"
|
||||
|
||||
extern struct tokenname tkidf[], tkother[];
|
||||
extern char *symbol2str();
|
||||
extern char options[128];
|
||||
|
||||
|
||||
#ifndef NOPP
|
||||
int inc_pos = 1; /* place where next -I goes */
|
||||
int inc_total = 0;
|
||||
int inc_max;
|
||||
char **inctable;
|
||||
|
||||
extern int do_dependencies;
|
||||
extern char *dep_file;
|
||||
static File *dep_fd = STDOUT;
|
||||
|
||||
extern char *getwdir();
|
||||
#endif NOPP
|
||||
|
||||
|
@ -122,10 +129,80 @@ main(argc, argv)
|
|||
hash_stat();
|
||||
#endif DEBUG
|
||||
|
||||
#ifndef NOPP
|
||||
if (do_dependencies) {
|
||||
extern char *source;
|
||||
|
||||
list_dependencies(source);
|
||||
}
|
||||
#endif
|
||||
sys_stop(err_occurred ? S_EXIT : S_END);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
#ifndef NOPP
|
||||
|
||||
struct idf *file_head;
|
||||
extern char *strrindex();
|
||||
|
||||
list_dependencies(source)
|
||||
char *source;
|
||||
{
|
||||
register struct idf *p = file_head;
|
||||
|
||||
if (source) {
|
||||
register char *s = strrindex(source, '.');
|
||||
|
||||
if (s && *(s+1)) {
|
||||
s++;
|
||||
*s++ = 'o';
|
||||
*s = '\0';
|
||||
/* the source may be in another directory than the
|
||||
* object generated, so don't include the pathname
|
||||
* leading to it.
|
||||
*/
|
||||
if (s = strrindex(source, '/')) {
|
||||
source = s + 1;
|
||||
}
|
||||
}
|
||||
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);
|
||||
p = (struct idf *) (p->id_file);
|
||||
}
|
||||
}
|
||||
|
||||
add_dependency(s)
|
||||
char *s;
|
||||
{
|
||||
register struct idf *p = str2idf(s, 0);
|
||||
|
||||
if (! p->id_resmac) {
|
||||
p->id_resmac = K_FILE;
|
||||
p->id_file = (char *) file_head;
|
||||
file_head = p;
|
||||
}
|
||||
}
|
||||
|
||||
dependency(s, source)
|
||||
char *s, *source;
|
||||
{
|
||||
if (options['s'] && !strncmp(s, "/usr/include/", 13)) {
|
||||
return;
|
||||
}
|
||||
if (options['m'] && source) {
|
||||
fprint(dep_fd, "%s: %s\n", source, s);
|
||||
}
|
||||
else fprint(dep_fd, "%s\n", s);
|
||||
}
|
||||
|
||||
#endif NOPP
|
||||
|
||||
char *source = 0;
|
||||
|
||||
char *nmlist = 0;
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
User options:
|
||||
A while running preprocessor, generate makefile dependencies
|
||||
C while running preprocessor, copy comment
|
||||
d perform a small dataflow analysis
|
||||
D see identifier following as a macro
|
||||
E run preprocessor only
|
||||
I expand include table with directory name following
|
||||
m generate file.o: file1.h format dependency lines
|
||||
M set identifier length
|
||||
n don't generate register messages
|
||||
L don't generate linenumbers and filename indications
|
||||
p trace
|
||||
P in running the preprocessor do not output '# line' lines
|
||||
R restricted C
|
||||
s suppress /usr/include include files in dependency list
|
||||
T take path following as directory for storing temporary file(s)
|
||||
U undefine predefined name
|
||||
V set objectsize and alignment requirements
|
||||
|
@ -17,11 +21,9 @@ w suppress warning diagnostics
|
|||
|
||||
Debug options:
|
||||
|
||||
d perform a small dataflow analysis
|
||||
f dump whole identifier table, including macros and reserved words
|
||||
h supply hash table statistics
|
||||
i print name of include files
|
||||
m supply memory allocation statistics
|
||||
r right-adjust bitfield
|
||||
t dump table of identifiers
|
||||
u unstack L_UNIVERSAL
|
||||
|
|
|
@ -27,6 +27,9 @@ extern char **inctable;
|
|||
extern int inc_pos;
|
||||
extern int inc_max;
|
||||
extern int inc_total;
|
||||
int do_dependencies = 0;
|
||||
char *dep_file = 0;
|
||||
|
||||
#endif NOPP
|
||||
|
||||
char options[128]; /* one for every char */
|
||||
|
@ -85,6 +88,21 @@ next_option: /* to allow combined one-char options */
|
|||
goto next_option;
|
||||
#endif LINT
|
||||
|
||||
#ifndef LINT
|
||||
#ifndef NOPP
|
||||
case 'A' : /* Amake dependency generation */
|
||||
do_dependencies = 1;
|
||||
if (*text) {
|
||||
dep_file = text;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
case 'm':
|
||||
options[opt] = 1;
|
||||
break;
|
||||
#endif NOPP
|
||||
#endif LINT
|
||||
|
||||
case 'R': /* strict version */
|
||||
#ifndef NOROPTION
|
||||
options[opt] = 1;
|
||||
|
|
Loading…
Reference in a new issue