summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2000-11-10 15:21:37 +0000
committerjoe <joe@FreeBSD.org>2000-11-10 15:21:37 +0000
commit0797349d74187f5275b90e1975294eb0a93cf6c4 (patch)
treee4a8d4ca7da1b22df1d8d5668fc1974485fceede
parent449468044456ac7a8de4144457fc1010589735b9 (diff)
downloadFreeBSD-src-0797349d74187f5275b90e1975294eb0a93cf6c4.zip
FreeBSD-src-0797349d74187f5275b90e1975294eb0a93cf6c4.tar.gz
Define a new special type: buildopts.
This allows build flags to be specified for a particular program from within the crunch.conf file, eg: prog ppp special ppp buildopts -DNOKLDLOAD -DNOINET6 -DNONAT -DNOATM This adds '-DNOKLDLOAD -DNOINET6 -DNONAT -DNOATM' to make targets related to ppp when determining which object files to build and when calculating dependencies and building the targets.
-rw-r--r--usr.sbin/crunch/crunchgen/crunchgen.111
-rw-r--r--usr.sbin/crunch/crunchgen/crunchgen.c21
2 files changed, 30 insertions, 2 deletions
diff --git a/usr.sbin/crunch/crunchgen/crunchgen.1 b/usr.sbin/crunch/crunchgen/crunchgen.1
index 4356077..e5ec1f9 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 92f7efc..9566d9f 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)
OpenPOWER on IntegriCloud