revert revision 1.37; it causes problems when running make(1) on a
crunchgen-created makefile with a partiallly complete build (a situation which is more common than you think...) solving the "parallel build" problem for crunchgen-created makefiles needs to be done a different way... fixes [toolchain/17012] from me.
This commit is contained in:
parent
913276174b
commit
f5aa03d2fa
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: crunchgen.c,v 1.37 2002/05/02 21:18:31 sommerfeld Exp $ */
|
/* $NetBSD: crunchgen.c,v 1.38 2002/05/29 09:41:51 lukem Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 University of Maryland
|
* Copyright (c) 1994 University of Maryland
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
|
@ -29,11 +29,11 @@
|
||||||
* crunchgen.c
|
* crunchgen.c
|
||||||
*
|
*
|
||||||
* Generates a Makefile and main C file for a crunched executable,
|
* Generates a Makefile and main C file for a crunched executable,
|
||||||
* from specs given in a .conf file.
|
* from specs given in a .conf file.
|
||||||
*/
|
*/
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(__RCSID) && !defined(lint)
|
#if defined(__RCSID) && !defined(lint)
|
||||||
__RCSID("$NetBSD: crunchgen.c,v 1.37 2002/05/02 21:18:31 sommerfeld Exp $");
|
__RCSID("$NetBSD: crunchgen.c,v 1.38 2002/05/29 09:41:51 lukem Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
|
@ -114,7 +114,7 @@ int is_nonempty_file(char *pathname);
|
||||||
|
|
||||||
/* helper routines for main() */
|
/* helper routines for main() */
|
||||||
|
|
||||||
void usage(void);
|
void usage(void);
|
||||||
void parse_conf_file(void);
|
void parse_conf_file(void);
|
||||||
void gen_outputs(void);
|
void gen_outputs(void);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ int main(int argc, char **argv)
|
||||||
readcache = 1;
|
readcache = 1;
|
||||||
useobjs = 0;
|
useobjs = 0;
|
||||||
*outmkname = *outcfname = *execfname = '\0';
|
*outmkname = *outcfname = *execfname = '\0';
|
||||||
|
|
||||||
if(argc > 0) pname = argv[0];
|
if(argc > 0) pname = argv[0];
|
||||||
|
|
||||||
while((optc = getopt(argc, argv, "m:c:d:e:foqD:L:")) != -1) {
|
while((optc = getopt(argc, argv, "m:c:d:e:foqD:L:")) != -1) {
|
||||||
|
@ -172,7 +172,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if(argc != 1) usage();
|
if(argc != 1) usage();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* generate filenames
|
* generate filenames
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
void usage(void)
|
void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s [-fq] [-m <makefile>] [-c <c file>] [-e <exec file>] <conffile>\n",
|
"%s [-fq] [-m <makefile>] [-c <c file>] [-e <exec file>] <conffile>\n",
|
||||||
pname);
|
pname);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -218,7 +218,7 @@ void usage(void)
|
||||||
/* helper routines for parse_conf_file */
|
/* helper routines for parse_conf_file */
|
||||||
|
|
||||||
void parse_one_file(char *filename);
|
void parse_one_file(char *filename);
|
||||||
void parse_line(char *line, int *fc, char **fv, int nf);
|
void parse_line(char *line, int *fc, char **fv, int nf);
|
||||||
void add_srcdirs(int argc, char **argv);
|
void add_srcdirs(int argc, char **argv);
|
||||||
void add_progs(int argc, char **argv);
|
void add_progs(int argc, char **argv);
|
||||||
void add_link(int argc, char **argv);
|
void add_link(int argc, char **argv);
|
||||||
|
@ -278,7 +278,7 @@ void parse_one_file(char *filename)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(fieldc < 2) {
|
if(fieldc < 2) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s:%d: %s command needs at least 1 argument, skipping.\n",
|
"%s:%d: %s command needs at least 1 argument, skipping.\n",
|
||||||
curfilename, linenum, fieldv[0]);
|
curfilename, linenum, fieldv[0]);
|
||||||
goterror = 1;
|
goterror = 1;
|
||||||
|
@ -330,7 +330,7 @@ void add_srcdirs(int argc, char **argv)
|
||||||
if(is_dir(tmppath))
|
if(is_dir(tmppath))
|
||||||
add_string(&srcdirs, tmppath);
|
add_string(&srcdirs, tmppath);
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "%s:%d: `%s' is not a directory, skipping it.\n",
|
fprintf(stderr, "%s:%d: `%s' is not a directory, skipping it.\n",
|
||||||
curfilename, linenum, tmppath);
|
curfilename, linenum, tmppath);
|
||||||
goterror = 1;
|
goterror = 1;
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,7 @@ void add_prog(char *progname)
|
||||||
|
|
||||||
p2 = malloc(sizeof(prog_t));
|
p2 = malloc(sizeof(prog_t));
|
||||||
if(p2) p2->name = strdup(progname);
|
if(p2) p2->name = strdup(progname);
|
||||||
if(!p2 || !p2->name)
|
if(!p2 || !p2->name)
|
||||||
out_of_memory();
|
out_of_memory();
|
||||||
|
|
||||||
p2->next = NULL;
|
p2->next = NULL;
|
||||||
|
@ -377,7 +377,7 @@ void add_link(int argc, char **argv)
|
||||||
prog_t *p = find_prog(argv[1]);
|
prog_t *p = find_prog(argv[1]);
|
||||||
|
|
||||||
if(p == NULL) {
|
if(p == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s:%d: no prog %s previously declared, skipping link.\n",
|
"%s:%d: no prog %s previously declared, skipping link.\n",
|
||||||
curfilename, linenum, argv[1]);
|
curfilename, linenum, argv[1]);
|
||||||
goterror = 1;
|
goterror = 1;
|
||||||
|
@ -404,7 +404,7 @@ void add_special(int argc, char **argv)
|
||||||
|
|
||||||
if(p == NULL) {
|
if(p == NULL) {
|
||||||
if(reading_cache) return;
|
if(reading_cache) return;
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s:%d: no prog %s previously declared, skipping special.\n",
|
"%s:%d: no prog %s previously declared, skipping special.\n",
|
||||||
curfilename, linenum, argv[1]);
|
curfilename, linenum, argv[1]);
|
||||||
goterror = 1;
|
goterror = 1;
|
||||||
|
@ -459,7 +459,7 @@ void add_special(int argc, char **argv)
|
||||||
|
|
||||||
|
|
||||||
argcount:
|
argcount:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s:%d: too %s arguments, expected \"special %s %s <string>\".\n",
|
"%s:%d: too %s arguments, expected \"special %s %s <string>\".\n",
|
||||||
curfilename, linenum, argc < 4? "few" : "many", argv[1], argv[2]);
|
curfilename, linenum, argc < 4? "few" : "many", argv[1], argv[2]);
|
||||||
goterror = 1;
|
goterror = 1;
|
||||||
|
@ -511,7 +511,7 @@ void gen_outputs(void)
|
||||||
gen_output_cfile();
|
gen_output_cfile();
|
||||||
gen_output_makefile();
|
gen_output_makefile();
|
||||||
status("");
|
status("");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Run \"make -f %s objs exe\" to build crunched binary.\n",
|
"Run \"make -f %s objs exe\" to build crunched binary.\n",
|
||||||
outmkname);
|
outmkname);
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ void fillin_program(prog_t *p)
|
||||||
(void)snprintf(line, sizeof(line), "filling in parms for %s", p->name);
|
(void)snprintf(line, sizeof(line), "filling in parms for %s", p->name);
|
||||||
status(line);
|
status(line);
|
||||||
|
|
||||||
if(!p->ident)
|
if(!p->ident)
|
||||||
p->ident = genident(p->name);
|
p->ident = genident(p->name);
|
||||||
if(!p->srcdir) {
|
if(!p->srcdir) {
|
||||||
srcparent = dir_search(p->name);
|
srcparent = dir_search(p->name);
|
||||||
|
@ -575,16 +575,16 @@ void fillin_program(prog_t *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!p->srcdir && verbose)
|
if(!p->srcdir && verbose)
|
||||||
fprintf(stderr, "%s: %s: warning: could not find source directory.\n",
|
fprintf(stderr, "%s: %s: warning: could not find source directory.\n",
|
||||||
infilename, p->name);
|
infilename, p->name);
|
||||||
if(!p->objs && verbose)
|
if(!p->objs && verbose)
|
||||||
fprintf(stderr, "%s: %s: warning: could not find any .o files.\n",
|
fprintf(stderr, "%s: %s: warning: could not find any .o files.\n",
|
||||||
infilename, p->name);
|
infilename, p->name);
|
||||||
|
|
||||||
if(!p->objpaths) {
|
if(!p->objpaths) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: %s: error: no objpaths specified or calculated.\n",
|
"%s: %s: error: no objpaths specified or calculated.\n",
|
||||||
infilename, p->name);
|
infilename, p->name);
|
||||||
p->goterror = goterror = 1;
|
p->goterror = goterror = 1;
|
||||||
|
@ -612,7 +612,7 @@ void fillin_program_objs(prog_t *p, char *dirpath)
|
||||||
goterror = 1;
|
goterror = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, ".include \"${.CURDIR}/Makefile\"\n");
|
fprintf(f, ".include \"${.CURDIR}/Makefile\"\n");
|
||||||
fprintf(f, ".if defined(PROG)\n");
|
fprintf(f, ".if defined(PROG)\n");
|
||||||
fprintf(f, "OBJS?= ${PROG}.o\n");
|
fprintf(f, "OBJS?= ${PROG}.o\n");
|
||||||
|
@ -636,7 +636,7 @@ void fillin_program_objs(prog_t *p, char *dirpath)
|
||||||
"sh: warning: running as root with dot in PATH\n") == 0)
|
"sh: warning: running as root with dot in PATH\n") == 0)
|
||||||
continue;
|
continue;
|
||||||
fprintf(stderr, "make error: %s", line);
|
fprintf(stderr, "make error: %s", line);
|
||||||
goterror = 1;
|
goterror = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cp = line + 6;
|
cp = line + 6;
|
||||||
|
@ -660,8 +660,8 @@ void remove_error_progs(void)
|
||||||
{
|
{
|
||||||
prog_t *p1, *p2;
|
prog_t *p1, *p2;
|
||||||
|
|
||||||
p1 = NULL; p2 = progs;
|
p1 = NULL; p2 = progs;
|
||||||
while(p2 != NULL) {
|
while(p2 != NULL) {
|
||||||
if(!p2->goterror)
|
if(!p2->goterror)
|
||||||
p1 = p2, p2 = p2->next;
|
p1 = p2, p2 = p2->next;
|
||||||
else {
|
else {
|
||||||
|
@ -729,7 +729,7 @@ void gen_output_makefile(void)
|
||||||
top_makefile_rules(outmk);
|
top_makefile_rules(outmk);
|
||||||
|
|
||||||
for(p = progs; p != NULL; p = p->next)
|
for(p = progs; p != NULL; p = p->next)
|
||||||
prog_makefile_rules(outmk, p);
|
prog_makefile_rules(outmk, p);
|
||||||
|
|
||||||
fprintf(outmk, "\n.include <bsd.prog.mk>\n");
|
fprintf(outmk, "\n.include <bsd.prog.mk>\n");
|
||||||
fprintf(outmk, "\n# ========\n");
|
fprintf(outmk, "\n# ========\n");
|
||||||
|
@ -753,7 +753,7 @@ void gen_output_cfile(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(outcf,
|
fprintf(outcf,
|
||||||
"/* %s - generated from %s by crunchgen %s */\n",
|
"/* %s - generated from %s by crunchgen %s */\n",
|
||||||
outcfname, infilename, CRUNCH_VERSION);
|
outcfname, infilename, CRUNCH_VERSION);
|
||||||
|
|
||||||
|
@ -772,7 +772,7 @@ void gen_output_cfile(void)
|
||||||
fprintf(outcf, "\t{ \"%s\", _crunched_%s_stub },\n",
|
fprintf(outcf, "\t{ \"%s\", _crunched_%s_stub },\n",
|
||||||
s->str, p->ident);
|
s->str, p->ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(outcf, "\t{ EXECNAME, crunched_main },\n");
|
fprintf(outcf, "\t{ EXECNAME, crunched_main },\n");
|
||||||
fprintf(outcf, "\t{ NULL, NULL }\n};\n");
|
fprintf(outcf, "\t{ NULL, NULL }\n};\n");
|
||||||
fclose(outcf);
|
fclose(outcf);
|
||||||
|
@ -835,7 +835,7 @@ void top_makefile_rules(FILE *outmk)
|
||||||
fprintf(outmk, "LDADD+= ${CRUNCHED_OBJS} ");
|
fprintf(outmk, "LDADD+= ${CRUNCHED_OBJS} ");
|
||||||
output_strlst(outmk, libs);
|
output_strlst(outmk, libs);
|
||||||
fprintf(outmk, "CRUNCHEDOBJSDIRS=${CRUNCHED_OBJS:R}\n\n");
|
fprintf(outmk, "CRUNCHEDOBJSDIRS=${CRUNCHED_OBJS:R}\n\n");
|
||||||
|
|
||||||
fprintf(outmk, "SUBMAKE_TARGETS=");
|
fprintf(outmk, "SUBMAKE_TARGETS=");
|
||||||
for(p = progs; p != NULL; p = p->next)
|
for(p = progs; p != NULL; p = p->next)
|
||||||
fprintf(outmk, " %s_make", p->ident);
|
fprintf(outmk, " %s_make", p->ident);
|
||||||
|
@ -843,7 +843,7 @@ void top_makefile_rules(FILE *outmk)
|
||||||
|
|
||||||
fprintf(outmk, "PROG=%s\n", execfname);
|
fprintf(outmk, "PROG=%s\n", execfname);
|
||||||
fprintf(outmk, "MKMAN=no\n\n");
|
fprintf(outmk, "MKMAN=no\n\n");
|
||||||
|
|
||||||
fprintf(outmk, "all: ${PROG}\n\t${STRIP} ${PROG}\n");
|
fprintf(outmk, "all: ${PROG}\n\t${STRIP} ${PROG}\n");
|
||||||
fprintf(outmk, "objs: $(SUBMAKE_TARGETS)\n");
|
fprintf(outmk, "objs: $(SUBMAKE_TARGETS)\n");
|
||||||
fprintf(outmk, "exe: %s\n", execfname);
|
fprintf(outmk, "exe: %s\n", execfname);
|
||||||
|
@ -865,18 +865,17 @@ void prog_makefile_rules(FILE *outmk, prog_t *p)
|
||||||
fprintf(outmk, "%s_SRCDIR=%s\n", p->ident, p->srcdir);
|
fprintf(outmk, "%s_SRCDIR=%s\n", p->ident, p->srcdir);
|
||||||
fprintf(outmk, "%s_OBJS=", p->ident);
|
fprintf(outmk, "%s_OBJS=", p->ident);
|
||||||
output_strlst(outmk, p->objs);
|
output_strlst(outmk, p->objs);
|
||||||
fprintf(outmk, "%s_directory::\n", p->ident);
|
fprintf(outmk, "%s_make: ${%s_OBJPATHS}\n", p->ident, p->ident);
|
||||||
fprintf(outmk, "\t[ -d %s ] || mkdir %s\n", p->ident, p->ident);
|
fprintf(outmk, "${%s_OBJPATHS}: \n", p->ident);
|
||||||
fprintf(outmk, "%s_make:: .MAKE %s_directory\n", p->ident, p->ident);
|
fprintf(outmk, "\tif [ \\! -d %s ]; then mkdir %s; fi; cd %s; \\\n",
|
||||||
fprintf(outmk, "\tcd %s; \\\n", p->ident);
|
p->ident, p->ident, p->ident);
|
||||||
fprintf(outmk, "\tprintf \".PATH: ${%s_SRCDIR}\\n.CURDIR:= ${%s_SRCDIR}\\n"
|
fprintf(outmk, "\tprintf \".PATH: ${%s_SRCDIR}\\n.CURDIR:= ${%s_SRCDIR}\\n"
|
||||||
".include \\\"\\$${.CURDIR}/Makefile\\\"\\n\" \\\n", p->ident, p->ident);
|
".include \\\"\\$${.CURDIR}/Makefile\\\"\\n\" \\\n", p->ident, p->ident);
|
||||||
fprintf(outmk, "\t| ${MAKE} CRUNCHEDPROG=1 DBG=\"${DBG}\" -f- depend ${%s_OBJS}\n\n",
|
fprintf(outmk, "\t| ${MAKE} CRUNCHEDPROG=1 DBG=\"${DBG}\" -f- depend ${%s_OBJS}\n\n",
|
||||||
p->ident);
|
p->ident);
|
||||||
fprintf(outmk, "${%s_OBJPATHS}:: %s_make\n", p->ident, p->ident);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(outmk, "%s_make:\n\t@echo \"** Using existing objs for %s\"\n\n",
|
fprintf(outmk, "%s_make:\n\t@echo \"** Using existing objs for %s\"\n\n",
|
||||||
p->ident, p->name);
|
p->ident, p->name);
|
||||||
|
|
||||||
|
|
||||||
|
@ -891,7 +890,7 @@ void prog_makefile_rules(FILE *outmk, prog_t *p)
|
||||||
else
|
else
|
||||||
fprintf(outmk, "%s.cro: %s_stub.o ${%s_OBJPATHS}\n",
|
fprintf(outmk, "%s.cro: %s_stub.o ${%s_OBJPATHS}\n",
|
||||||
p->name, p->name, p->ident);
|
p->name, p->name, p->ident);
|
||||||
fprintf(outmk, "\t${LD} -dc -r -o %s.cro %s_stub.o $(%s_OBJPATHS)\n",
|
fprintf(outmk, "\t${LD} -dc -r -o %s.cro %s_stub.o $(%s_OBJPATHS)\n",
|
||||||
p->name, p->name, p->ident);
|
p->name, p->name, p->ident);
|
||||||
#ifdef NEW_TOOLCHAIN
|
#ifdef NEW_TOOLCHAIN
|
||||||
fprintf(outmk, "\t${OBJCOPY} --keep-global-symbol _crunched_%s_stub ",
|
fprintf(outmk, "\t${OBJCOPY} --keep-global-symbol _crunched_%s_stub ",
|
||||||
|
|
Loading…
Reference in New Issue