diff --git a/usr.sbin/crunch/crunchgen/crunchgen.1 b/usr.sbin/crunch/crunchgen/crunchgen.1 index 4356077dc6a7..e5ec1f996220 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.1 +++ b/usr.sbin/crunch/crunchgen/crunchgen.1 @@ -197,6 +197,10 @@ and if that is not found, the .Ar srcdir itself becomes the .Ar objdir . +.It Nm special Ar progname Nm buildopts Ar buildopts +Define a set of build options that should be added to make targets +when processing +.Ar progname . .It Nm special Ar progname Nm objs Ar object-file-name ... Set the list of object files for program .Ar progname . @@ -272,11 +276,14 @@ input conf file, named srcdirs /usr/src/bin /usr/src/sbin progs test cp echo sh fsck halt init mount umount myinstall + progs anotherprog ln test [ # test can be invoked via [ ln sh -sh # init invokes the shell with "-sh" in argv[0] special myprog objpaths /homes/leroy/src/myinstall.o # no sources + special anotherprog -DNO_FOO WITHOUT_BAR=YES + libs -lutil -lcrypt .fi .Pp @@ -287,6 +294,10 @@ specified directly with the .Nm special line. .Pp +Additionally when ``anotherprog'' is built the arguments +.Ar -DNO_FOO WITHOUT_BAR=YES +are added to all build targets. +.Pp The crunched binary ``kcopy'' can be built as follows: .Pp .nf diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c index 92f7efc1f665..9566d9fe8ae8 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.c +++ b/usr.sbin/crunch/crunchgen/crunchgen.c @@ -68,6 +68,7 @@ typedef struct prog { char *objdir; char *objvar; /* Makefile variable to replace OBJS */ strlst_t *objs, *objpaths; + strlst_t *buildopts; strlst_t *keeplist; strlst_t *links; int goterror; @@ -332,6 +333,7 @@ void add_prog(char *progname) p2->ident = p2->srcdir = p2->objdir = NULL; p2->links = p2->objs = p2->keeplist = NULL; + p2->buildopts = NULL; p2->goterror = 0; if (list_mode) printf("%s\n",progname); @@ -415,6 +417,11 @@ void add_special(int argc, char **argv) if((p->objvar = strdup(argv[3])) == NULL) out_of_memory(); } + else if (!strcmp(argv[2], "buildopts")) { + p->buildopts = NULL; + for (i = 3; i < argc; i++) + add_string(&p->buildopts, argv[i]); + } else { warnx("%s:%d: bad parameter name `%s', skipping line", curfilename, linenum, argv[2]); @@ -554,6 +561,7 @@ void fillin_program_objs(prog_t *p, char *path) int rc; FILE *f; char *objvar="OBJS"; + strlst_t *s; /* discover the objs from the srcdir Makefile */ @@ -575,8 +583,13 @@ void fillin_program_objs(prog_t *p, char *path) fprintf(f, "%s=${PROG}.o\n", objvar); fprintf(f, ".endif\n"); fprintf(f, "loop:\n\t@echo 'OBJS= '${%s}\n", objvar); - fprintf(f, "crunchgen_objs:\n\t@make -f %s $(OPTS) $(%s_OPTS) loop\n", - tempfname, p->ident); + + fprintf(f, "crunchgen_objs:\n\t@make -f %s $(OPTS) $(%s_OPTS)", + tempfname, p->ident); + for (s = p->buildopts; s != NULL; s = s->next) + fprintf(f, " %s", s->str); + fprintf(f, " loop\n"); + fclose(f); sprintf(line, "make -f %s crunchgen_objs 2>&1", tempfname); @@ -812,6 +825,10 @@ void prog_makefile_rules(FILE *outmk, prog_t *p) fprintf(outmk, "%s_SRCDIR=%s\n", p->ident, p->srcdir); fprintf(outmk, "%s_OBJS=", p->ident); output_strlst(outmk, p->objs); + if (p->buildopts != NULL) { + fprintf(outmk, "%s_OPTS+=", p->ident); + output_strlst(outmk, p->buildopts); + } fprintf(outmk, "%s_make:\n", p->ident); fprintf(outmk, "\t(cd $(%s_SRCDIR) && ", p->ident); if (makeobj)