Deleted Added
full compact
crunchgen.c (68286) crunchgen.c (68569)
1/*
2 * Copyright (c) 1994 University of Maryland
3 * All Rights Reserved.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting

--- 9 unchanged lines hidden (view full) ---

18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 *
22 * Author: James da Silva, Systems Design and Analysis Group
23 * Computer Science Department
24 * University of Maryland at College Park
25 *
1/*
2 * Copyright (c) 1994 University of Maryland
3 * All Rights Reserved.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting

--- 9 unchanged lines hidden (view full) ---

18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 *
22 * Author: James da Silva, Systems Design and Analysis Group
23 * Computer Science Department
24 * University of Maryland at College Park
25 *
26 * $FreeBSD: head/usr.sbin/crunch/crunchgen/crunchgen.c 68286 2000-11-03 15:48:58Z joe $
26 * $FreeBSD: head/usr.sbin/crunch/crunchgen/crunchgen.c 68569 2000-11-10 15:21:37Z joe $
27 */
28/*
29 * ========================================================================
30 * crunchgen.c
31 *
32 * Generates a Makefile and main C file for a crunched executable,
33 * from specs given in a .conf file.
34 */

--- 28 unchanged lines hidden (view full) ---

63typedef struct prog {
64 struct prog *next; /* link field */
65 char *name; /* program name */
66 char *ident; /* C identifier for the program name */
67 char *srcdir;
68 char *objdir;
69 char *objvar; /* Makefile variable to replace OBJS */
70 strlst_t *objs, *objpaths;
27 */
28/*
29 * ========================================================================
30 * crunchgen.c
31 *
32 * Generates a Makefile and main C file for a crunched executable,
33 * from specs given in a .conf file.
34 */

--- 28 unchanged lines hidden (view full) ---

63typedef struct prog {
64 struct prog *next; /* link field */
65 char *name; /* program name */
66 char *ident; /* C identifier for the program name */
67 char *srcdir;
68 char *objdir;
69 char *objvar; /* Makefile variable to replace OBJS */
70 strlst_t *objs, *objpaths;
71 strlst_t *buildopts;
71 strlst_t *keeplist;
72 strlst_t *links;
73 int goterror;
74} prog_t;
75
76
77/* global state */
78

--- 248 unchanged lines hidden (view full) ---

327 out_of_memory();
328
329 p2->next = NULL;
330 if(p1 == NULL) progs = p2;
331 else p1->next = p2;
332
333 p2->ident = p2->srcdir = p2->objdir = NULL;
334 p2->links = p2->objs = p2->keeplist = NULL;
72 strlst_t *keeplist;
73 strlst_t *links;
74 int goterror;
75} prog_t;
76
77
78/* global state */
79

--- 248 unchanged lines hidden (view full) ---

328 out_of_memory();
329
330 p2->next = NULL;
331 if(p1 == NULL) progs = p2;
332 else p1->next = p2;
333
334 p2->ident = p2->srcdir = p2->objdir = NULL;
335 p2->links = p2->objs = p2->keeplist = NULL;
336 p2->buildopts = NULL;
335 p2->goterror = 0;
336 if (list_mode)
337 printf("%s\n",progname);
338}
339
340
341void add_link(int argc, char **argv)
342{

--- 67 unchanged lines hidden (view full) ---

410 add_string(&p->keeplist, argv[i]);
411 }
412 else if(!strcmp(argv[2], "objvar")) {
413 if(argc != 4)
414 goto argcount;
415 if((p->objvar = strdup(argv[3])) == NULL)
416 out_of_memory();
417 }
337 p2->goterror = 0;
338 if (list_mode)
339 printf("%s\n",progname);
340}
341
342
343void add_link(int argc, char **argv)
344{

--- 67 unchanged lines hidden (view full) ---

412 add_string(&p->keeplist, argv[i]);
413 }
414 else if(!strcmp(argv[2], "objvar")) {
415 if(argc != 4)
416 goto argcount;
417 if((p->objvar = strdup(argv[3])) == NULL)
418 out_of_memory();
419 }
420 else if (!strcmp(argv[2], "buildopts")) {
421 p->buildopts = NULL;
422 for (i = 3; i < argc; i++)
423 add_string(&p->buildopts, argv[i]);
424 }
418 else {
419 warnx("%s:%d: bad parameter name `%s', skipping line",
420 curfilename, linenum, argv[2]);
421 goterror = 1;
422 }
423 return;
424
425

--- 123 unchanged lines hidden (view full) ---

549}
550
551void fillin_program_objs(prog_t *p, char *path)
552{
553 char *obj, *cp;
554 int rc;
555 FILE *f;
556 char *objvar="OBJS";
425 else {
426 warnx("%s:%d: bad parameter name `%s', skipping line",
427 curfilename, linenum, argv[2]);
428 goterror = 1;
429 }
430 return;
431
432

--- 123 unchanged lines hidden (view full) ---

556}
557
558void fillin_program_objs(prog_t *p, char *path)
559{
560 char *obj, *cp;
561 int rc;
562 FILE *f;
563 char *objvar="OBJS";
564 strlst_t *s;
557
558 /* discover the objs from the srcdir Makefile */
559
560 if((f = fopen(tempfname, "w")) == NULL) {
561 warn("%s", tempfname);
562 goterror = 1;
563 return;
564 }

--- 5 unchanged lines hidden (view full) ---

570 */
571 if (outhdrname[0] != '\0')
572 fprintf(f, ".include \"%s\"\n", outhdrname);
573 fprintf(f, ".include \"%s\"\n", path);
574 fprintf(f, ".if defined(PROG) && !defined(%s)\n", objvar);
575 fprintf(f, "%s=${PROG}.o\n", objvar);
576 fprintf(f, ".endif\n");
577 fprintf(f, "loop:\n\t@echo 'OBJS= '${%s}\n", objvar);
565
566 /* discover the objs from the srcdir Makefile */
567
568 if((f = fopen(tempfname, "w")) == NULL) {
569 warn("%s", tempfname);
570 goterror = 1;
571 return;
572 }

--- 5 unchanged lines hidden (view full) ---

578 */
579 if (outhdrname[0] != '\0')
580 fprintf(f, ".include \"%s\"\n", outhdrname);
581 fprintf(f, ".include \"%s\"\n", path);
582 fprintf(f, ".if defined(PROG) && !defined(%s)\n", objvar);
583 fprintf(f, "%s=${PROG}.o\n", objvar);
584 fprintf(f, ".endif\n");
585 fprintf(f, "loop:\n\t@echo 'OBJS= '${%s}\n", objvar);
578 fprintf(f, "crunchgen_objs:\n\t@make -f %s $(OPTS) $(%s_OPTS) loop\n",
579 tempfname, p->ident);
586
587 fprintf(f, "crunchgen_objs:\n\t@make -f %s $(OPTS) $(%s_OPTS)",
588 tempfname, p->ident);
589 for (s = p->buildopts; s != NULL; s = s->next)
590 fprintf(f, " %s", s->str);
591 fprintf(f, " loop\n");
592
580 fclose(f);
581
582 sprintf(line, "make -f %s crunchgen_objs 2>&1", tempfname);
583 if((f = popen(line, "r")) == NULL) {
584 warn("submake pipe");
585 goterror = 1;
586 return;
587 }

--- 219 unchanged lines hidden (view full) ---

807 strlst_t *lst;
808
809 fprintf(outmk, "\n# -------- %s\n\n", p->name);
810
811 if(p->srcdir && p->objs) {
812 fprintf(outmk, "%s_SRCDIR=%s\n", p->ident, p->srcdir);
813 fprintf(outmk, "%s_OBJS=", p->ident);
814 output_strlst(outmk, p->objs);
593 fclose(f);
594
595 sprintf(line, "make -f %s crunchgen_objs 2>&1", tempfname);
596 if((f = popen(line, "r")) == NULL) {
597 warn("submake pipe");
598 goterror = 1;
599 return;
600 }

--- 219 unchanged lines hidden (view full) ---

820 strlst_t *lst;
821
822 fprintf(outmk, "\n# -------- %s\n\n", p->name);
823
824 if(p->srcdir && p->objs) {
825 fprintf(outmk, "%s_SRCDIR=%s\n", p->ident, p->srcdir);
826 fprintf(outmk, "%s_OBJS=", p->ident);
827 output_strlst(outmk, p->objs);
828 if (p->buildopts != NULL) {
829 fprintf(outmk, "%s_OPTS+=", p->ident);
830 output_strlst(outmk, p->buildopts);
831 }
815 fprintf(outmk, "%s_make:\n", p->ident);
816 fprintf(outmk, "\t(cd $(%s_SRCDIR) && ", p->ident);
817 if (makeobj)
818 fprintf(outmk, "make obj && ");
819 fprintf(outmk, "\\\n");
820 fprintf(outmk, "\t\tmake $(OPTS) $(%s_OPTS) depend && \\\n"
821 "\t\tmake $(OPTS) $(%s_OPTS) $(%s_OBJS))\n",
822 p->ident, p->ident, p->ident);

--- 103 unchanged lines hidden ---
832 fprintf(outmk, "%s_make:\n", p->ident);
833 fprintf(outmk, "\t(cd $(%s_SRCDIR) && ", p->ident);
834 if (makeobj)
835 fprintf(outmk, "make obj && ");
836 fprintf(outmk, "\\\n");
837 fprintf(outmk, "\t\tmake $(OPTS) $(%s_OPTS) depend && \\\n"
838 "\t\tmake $(OPTS) $(%s_OPTS) $(%s_OBJS))\n",
839 p->ident, p->ident, p->ident);

--- 103 unchanged lines hidden ---