From owner-freebsd-small Mon Jan 24 3:23:41 2000 Delivered-To: freebsd-small@freebsd.org Received: from info.iet.unipi.it (info.iet.unipi.it [131.114.9.184]) by hub.freebsd.org (Postfix) with ESMTP id B7EF215092 for ; Mon, 24 Jan 2000 03:23:29 -0800 (PST) (envelope-from luigi@info.iet.unipi.it) Received: (from luigi@localhost) by info.iet.unipi.it (8.9.3/8.9.3) id MAA39198; Mon, 24 Jan 2000 12:21:51 +0100 (CET) (envelope-from luigi) From: Luigi Rizzo Message-Id: <200001241121.MAA39198@info.iet.unipi.it> Subject: Re: crunchgen changes... In-Reply-To: from Andrzej Bialecki at "Jan 24, 2000 12:17:11 pm" To: Andrzej Bialecki Date: Mon, 24 Jan 2000 12:21:51 +0100 (CET) Cc: small@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL61 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-small@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > Would people agree to have these changes incorporated into > > crunchgen after the feature freeze ? > > It's really < 10 lines of code and manpage... > > Where are the patches? below. code+manpage, /usr/src/usr.sbin/crunch/crunchgen have fun luigi --- crunchgen.c.orig Mon Sep 14 13:33:38 1998 +++ crunchgen.c Mon Jan 24 11:36:56 2000 @@ -59,9 +59,12 @@ /* progs have structure, each field can be set with "special" or calculated */ typedef struct prog { - struct prog *next; - char *name, *ident; - char *srcdir, *objdir; + struct prog *next; /* link field */ + char *name; /* program name */ + char *ident; /* C identifier for the program name */ + char *srcdir; + char *objdir; + char *objvar; /* Makefile variable to replace OBJS */ strlst_t *objs, *objpaths; strlst_t *keeplist; strlst_t *links; @@ -400,6 +403,11 @@ for(i=3;ikeeplist, argv[i]); } + else if(!strcmp(argv[2], "objvar")) { + if(argc != 4) goto argcount; + if((p->objvar = strdup(argv[3])) == NULL) + out_of_memory(); + } else { warnx("%s:%d: bad parameter name `%s', skipping line", curfilename, linenum, argv[2]); @@ -465,7 +473,9 @@ outmkname); } - +/* + * run the makefile for the program to find which objects are necessary + */ void fillin_program(prog_t *p) { char path[MAXPATHLEN]; @@ -498,7 +508,15 @@ } } } - +/* + * XXX look for a Makefile.{name} in local directory first. + * This lets us override the original Makefile. + */ + sprintf(path, "Makefile.%s", p->name); + if (is_nonempty_file(path)) { + sprintf(line, "Using %s for %s", path, p->name); + status(line); + } else if(p->srcdir) sprintf(path, "%s/Makefile", p->srcdir); if(!p->objs && p->srcdir && is_nonempty_file(path)) fillin_program_objs(p, path); @@ -528,6 +546,7 @@ char *obj, *cp; int rc; FILE *f; + char *objvar="OBJS"; /* discover the objs from the srcdir Makefile */ @@ -536,12 +555,14 @@ goterror = 1; return; } + if (p->objvar) + objvar = p->objvar ; fprintf(f, ".include \"%s\"\n", path); - fprintf(f, ".if defined(PROG) && !defined(OBJS)\n"); - fprintf(f, "OBJS=${PROG}.o\n"); + fprintf(f, ".if defined(PROG) && !defined(%s)\n", objvar); + fprintf(f, "%s=${PROG}.o\n", objvar); fprintf(f, ".endif\n"); - fprintf(f, "crunchgen_objs:\n\t@echo 'OBJS= '${OBJS}\n"); + fprintf(f, "crunchgen_objs:\n\t@echo 'OBJS= '${%s}\n", objvar); fclose(f); sprintf(line, "make -f %s crunchgen_objs 2>&1", tempfname); --- crunchgen.1.orig Mon Mar 23 09:21:55 1998 +++ crunchgen.1 Mon Jan 24 11:42:07 2000 @@ -178,6 +178,15 @@ pathname to each file in the .Nm objs list. +.It Nm special Ar progname Nm objvar Ar variable_name +Sets the name of the Make variable which holds the list of +object files for program +.Ar progname . +This is normally +.Nm OBJS +but some Makefiles might like to use other conventions or +prepend the program's name to the variable, e.g. +.Nm SSHD_OBJS . .It Nm special Ar progname Nm keep Ar symbol-name ... Add specified list of symbols to the keep list for program .Ar progname . To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-small" in the body of the message