From owner-freebsd-bugs Fri Jan 11 15: 0:18 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id E89FE37B400 for ; Fri, 11 Jan 2002 15:00:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g0BN02H71107; Fri, 11 Jan 2002 15:00:02 -0800 (PST) (envelope-from gnats) Date: Fri, 11 Jan 2002 15:00:02 -0800 (PST) Message-Id: <200201112300.g0BN02H71107@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Sam Leffler" Subject: Re: misc/33778: crunchgen enhancements Reply-To: "Sam Leffler" Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR misc/33778; it has been noted by GNATS. From: "Sam Leffler" To: "Josef Karthauser" Cc: Subject: Re: misc/33778: crunchgen enhancements Date: Fri, 11 Jan 2002 14:51:05 -0800 This is a multi-part message in MIME format. ------=_NextPart_000_1A08_01C19AAF.652CBE70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit cvs diff -u is attached. ------=_NextPart_000_1A08_01C19AAF.652CBE70 Content-Type: application/octet-stream; name="crunch.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="crunch.diff" Index: crunchgen.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /usr/ncvs/src/usr.sbin/crunch/crunchgen/crunchgen.c,v=0A= retrieving revision 1.12.2.9=0A= diff -u -r1.12.2.9 crunchgen.c=0A= --- crunchgen.c 19 Aug 2001 10:41:57 -0000 1.12.2.9=0A= +++ crunchgen.c 11 Jan 2002 01:52:58 -0000=0A= @@ -73,6 +73,7 @@=0A= strlst_t *buildopts;=0A= strlst_t *keeplist;=0A= strlst_t *links;=0A= + strlst_t *libs;=0A= int goterror;=0A= } prog_t;=0A= =0A= @@ -83,6 +84,7 @@=0A= strlst_t *srcdirs =3D NULL;=0A= strlst_t *libs =3D NULL;=0A= prog_t *progs =3D NULL;=0A= +strlst_t *vars =3D NULL;=0A= =0A= char confname[MAXPATHLEN], infilename[MAXPATHLEN];=0A= char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN], = execfname[MAXPATHLEN];=0A= @@ -239,6 +241,7 @@=0A= void add_libs(int argc, char **argv);=0A= void add_buildopts(int argc, char **argv);=0A= void add_special(int argc, char **argv);=0A= +void add_var(int argc, char **argv);=0A= =0A= prog_t *find_prog(char *str);=0A= void add_prog(char *progname);=0A= @@ -293,6 +296,8 @@=0A= f =3D add_libs;=0A= else if(!strcmp(fieldv[0], "buildopts"))=0A= f =3D add_buildopts;=0A= + else if(!strcmp(fieldv[0], "var"))=0A= + f =3D add_var;=0A= else if(!strcmp(fieldv[0], "special"))=0A= f =3D add_special;=0A= else {=0A= @@ -409,6 +414,7 @@=0A= p2->objs =3D NULL;=0A= p2->keeplist =3D NULL;=0A= p2->buildopts =3D NULL;=0A= + p2->libs =3D NULL;=0A= p2->goterror =3D 0;=0A= =0A= if (list_mode)=0A= @@ -455,6 +461,15 @@=0A= }=0A= =0A= =0A= +void add_var(int argc, char **argv)=0A= +{=0A= + int i;=0A= +=0A= + for (i =3D 1; i < argc; i++) =0A= + add_string(&vars, argv[i]);=0A= +}=0A= +=0A= +=0A= void add_special(int argc, char **argv)=0A= {=0A= int i;=0A= @@ -506,6 +521,9 @@=0A= p->buildopts =3D NULL;=0A= for (i =3D 3; i < argc; i++)=0A= add_string(&p->buildopts, argv[i]);=0A= + } else if (!strcmp(argv[2], "lib")) {=0A= + for (i =3D 3; i < argc; i++)=0A= + add_string(&p->libs, argv[i]);=0A= } else {=0A= warnx("%s:%d: bad parameter name `%s', skipping line",=0A= curfilename, linenum, argv[2]);=0A= @@ -578,6 +596,7 @@=0A= char path[MAXPATHLEN];=0A= char line[MAXLINELEN];=0A= FILE *f;=0A= + strlst_t *s;=0A= =0A= snprintf(line, MAXLINELEN, "filling in parms for %s", p->name);=0A= status(line);=0A= @@ -592,7 +611,13 @@=0A= =0A= /* Determine the actual srcdir (maybe symlinked). */=0A= if (p->srcdir) {=0A= - snprintf(line, MAXLINELEN, "cd %s && echo -n `/bin/pwd`",=0A= + char *cp =3D line;=0A= + for (s =3D vars; s !=3D NULL; s =3D s->next) {=0A= + snprintf(cp, MAXLINELEN - (cp-line), "%s;", s->str);=0A= + cp =3D strchr(cp, '\0');=0A= + }=0A= + snprintf(cp, MAXLINELEN - (cp-line),=0A= + "cd %s && echo -n `/bin/pwd`",=0A= p->srcdir);=0A= f =3D popen(line,"r");=0A= if (!f)=0A= @@ -632,7 +657,7 @@=0A= status(line);=0A= } else=0A= if (p->srcdir)=0A= - snprintf(path, sizeof(path), "%s/Makefile", p->srcdir);=0A= + snprintf(path, sizeof(path), "%s/Makefile", p->realsrcdir);=0A= if (!p->objs && p->srcdir && is_nonempty_file(path))=0A= fillin_program_objs(p, path);=0A= =0A= @@ -677,6 +702,8 @@=0A= if (outhdrname[0] !=3D '\0')=0A= fprintf(f, ".include \"%s\"\n", outhdrname);=0A= fprintf(f, ".include \"%s\"\n", path);=0A= + for (s =3D vars; s !=3D NULL; s =3D s->next)=0A= + fprintf(f, "%s\n", s->str);=0A= if (buildopts) {=0A= fprintf(f, "BUILDOPTS+=3D");=0A= output_strlst(f, buildopts);=0A= @@ -914,6 +941,10 @@=0A= void top_makefile_rules(FILE *outmk)=0A= {=0A= prog_t *p;=0A= + strlst_t *s;=0A= +=0A= + for (s =3D vars; s !=3D NULL; s =3D s->next)=0A= + fprintf(outmk, "%s\n", s->str);=0A= =0A= fprintf(outmk, "LIBS+=3D");=0A= output_strlst(outmk, libs);=0A= @@ -1010,16 +1041,26 @@=0A= }=0A= fprintf(outmk, "\n");=0A= }=0A= + if (p->libs) {=0A= + fprintf(outmk, "%s_LIBS=3D", p->ident);=0A= + output_strlst(outmk, p->libs);=0A= + }=0A= =0A= fprintf(outmk, "%s_stub.c:\n", p->name);=0A= fprintf(outmk, "\techo \""=0A= "int _crunched_%s_stub(int argc, char **argv, char **envp)"=0A= "{return main(argc,argv,envp);}\" >%s_stub.c\n",=0A= p->ident, p->name);=0A= - fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS)\n",=0A= + fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS)",=0A= p->name, p->name, p->ident);=0A= - fprintf(outmk, "\tld -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS)\n",=0A= + if (p->libs)=0A= + fprintf(outmk, " $(%s_LIBS)", p->ident);=0A= + fprintf(outmk, "\n");=0A= + fprintf(outmk, "\tld -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS)",=0A= p->name, p->name, p->ident);=0A= + if (p->libs)=0A= + fprintf(outmk, " $(%s_LIBS)", p->ident);=0A= + fprintf(outmk, "\n");=0A= fprintf(outmk, "\tcrunchide -k _crunched_%s_stub ", p->ident);=0A= for (lst =3D p->keeplist; lst !=3D NULL; lst =3D lst->next)=0A= fprintf(outmk, "-k _%s ", lst->str);=0A= ------=_NextPart_000_1A08_01C19AAF.652CBE70-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message