Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jan 2000 12:21:51 +0100 (CET)
From:      Luigi Rizzo <luigi@info.iet.unipi.it>
To:        Andrzej Bialecki <abial@webgiro.com>
Cc:        small@FreeBSD.ORG
Subject:   Re: crunchgen changes...
Message-ID:  <200001241121.MAA39198@info.iet.unipi.it>
In-Reply-To: <Pine.BSF.4.20.0001241216500.47851-100000@mx.webgiro.com> from Andrzej Bialecki at "Jan 24, 2000 12:17:11 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> > 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;i<argc;i++)
 	    add_string(&p->keeplist, 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001241121.MAA39198>