View | Details | Raw Unified | Return to bug 145694
Collapse All | Expand All

(-)mkoptions.c (-2 / +11 lines)
Lines 294-300 read_options(void) Link Here
294
	char genopt[MAXPATHLEN];
294
	char genopt[MAXPATHLEN];
295
295
296
	SLIST_INIT(&otab);
296
	SLIST_INIT(&otab);
297
	(void) snprintf(fname, sizeof(fname), "../../conf/options");
297
	if ( *ksrcdir != '\0' )
298
		(void) snprintf(fname, sizeof(fname), "%s/conf/options", 
299
		    ksrcdir);
300
	else
301
		(void) snprintf(fname, sizeof(fname), "../../conf/options");
298
openit:
302
openit:
299
	fp = fopen(fname, "r");
303
	fp = fopen(fname, "r");
300
	if (fp == 0) {
304
	if (fp == 0) {
Lines 306-312 next: Link Here
306
		(void) fclose(fp);
310
		(void) fclose(fp);
307
		if (first == 1) {
311
		if (first == 1) {
308
			first++;
312
			first++;
309
			(void) snprintf(fname, sizeof fname, "../../conf/options.%s", machinename);
313
			if ( *ksrcdir != '\0' )
314
				(void) snprintf(fname, sizeof fname, 
315
				    "%s/conf/options.%s", ksrcdir, machinename);
316
			else
317
				(void) snprintf(fname, sizeof fname, 
318
				    "../../conf/options.%s", machinename);
310
			fp = fopen(fname, "r");
319
			fp = fopen(fname, "r");
311
			if (fp != 0)
320
			if (fp != 0)
312
				goto next;
321
				goto next;
(-)main.c (-10 / +25 lines)
Lines 72-77 static const char rcsid[] = Link Here
72
72
73
char *	PREFIX;
73
char *	PREFIX;
74
char 	destdir[MAXPATHLEN];
74
char 	destdir[MAXPATHLEN];
75
char 	ksrcdir[MAXPATHLEN];
75
char 	srcdir[MAXPATHLEN];
76
char 	srcdir[MAXPATHLEN];
76
77
77
int	debugging;
78
int	debugging;
Lines 110-117 main(int argc, char **argv) Link Here
110
	char xxx[MAXPATHLEN];
111
	char xxx[MAXPATHLEN];
111
	char *kernfile;
112
	char *kernfile;
112
113
114
	*ksrcdir = '\0';
113
	kernfile = NULL;
115
	kernfile = NULL;
114
	while ((ch = getopt(argc, argv, "Cd:gpVx:")) != -1)
116
	while ((ch = getopt(argc, argv, "Cd:gk:pVx:")) != -1)
115
		switch (ch) {
117
		switch (ch) {
116
		case 'C':
118
		case 'C':
117
			filebased = 1;
119
			filebased = 1;
Lines 125-130 main(int argc, char **argv) Link Here
125
		case 'g':
127
		case 'g':
126
			debugging++;
128
			debugging++;
127
			break;
129
			break;
130
		case 'k':
131
			if (*ksrcdir == '\0')
132
				strlcpy(ksrcdir, optarg, sizeof(ksrcdir));
133
			else
134
				errx(EXIT_FAILURE, "Kernel ksrcdir already set");
135
			break;
128
		case 'p':
136
		case 'p':
129
			profiling++;
137
			profiling++;
130
			break;
138
			break;
Lines 164-170 main(int argc, char **argv) Link Here
164
		len = strlen(destdir);
172
		len = strlen(destdir);
165
		while (len > 1 && destdir[len - 1] == '/')
173
		while (len > 1 && destdir[len - 1] == '/')
166
			destdir[--len] = '\0';
174
			destdir[--len] = '\0';
167
		get_srcdir();
175
		if (*ksrcdir == '\0')
176
			get_srcdir();
168
	} else {
177
	} else {
169
		strlcpy(destdir, CDIR, sizeof(destdir));
178
		strlcpy(destdir, CDIR, sizeof(destdir));
170
		strlcat(destdir, PREFIX, sizeof(destdir));
179
		strlcat(destdir, PREFIX, sizeof(destdir));
Lines 210-220 main(int argc, char **argv) Link Here
210
	 * for "sys" (to make genassym.c work along with #include <sys/xxx>)
219
	 * for "sys" (to make genassym.c work along with #include <sys/xxx>)
211
	 * and similarly for "machine".
220
	 * and similarly for "machine".
212
	 */
221
	 */
213
	if (*srcdir == '\0')
222
	if (*ksrcdir != '\0')
214
		(void)snprintf(xxx, sizeof(xxx), "../../include");
215
	else
216
		(void)snprintf(xxx, sizeof(xxx), "%s/%s/include",
223
		(void)snprintf(xxx, sizeof(xxx), "%s/%s/include",
224
		    ksrcdir, machinename);
225
	else if (*srcdir != '\0')
226
		(void)snprintf(xxx, sizeof(xxx), "%s/%s/include",
217
		    srcdir, machinename);
227
		    srcdir, machinename);
228
	else
229
		(void)snprintf(xxx, sizeof(xxx), "../../include");
218
	(void) unlink(path("machine"));
230
	(void) unlink(path("machine"));
219
	(void) symlink(xxx, path("machine"));
231
	(void) symlink(xxx, path("machine"));
220
	if (strcmp(machinename, machinearch) != 0) {
232
	if (strcmp(machinename, machinearch) != 0) {
Lines 222-233 main(int argc, char **argv) Link Here
222
		 * make symbolic links in compilation directory for
234
		 * make symbolic links in compilation directory for
223
		 * machinearch, if it is different than machinename.
235
		 * machinearch, if it is different than machinename.
224
		 */
236
		 */
225
		if (*srcdir == '\0')
237
		if (*ksrcdir != '\0')
238
			(void)snprintf(xxx, sizeof(xxx), "%s/%s/include",
239
			    ksrcdir, machinearch);
240
		else if (*srcdir != '\0')
241
			(void)snprintf(xxx, sizeof(xxx), "%s/%s/include",
242
			    srcdir, machinearch);
243
		else
226
			(void)snprintf(xxx, sizeof(xxx), "../../../%s/include",
244
			(void)snprintf(xxx, sizeof(xxx), "../../../%s/include",
227
			    machinearch);
245
			    machinearch);
228
		else
229
			(void)snprintf(xxx, sizeof(xxx), "%s/%s/include",
230
			    srcdir, machinearch);
231
		(void) unlink(path(machinearch));
246
		(void) unlink(path(machinearch));
232
		(void) symlink(xxx, path(machinearch));
247
		(void) symlink(xxx, path(machinearch));
233
	}
248
	}
Lines 278-284 static void Link Here
278
usage(void)
293
usage(void)
279
{
294
{
280
295
281
	fprintf(stderr, "usage: config [-CgpV] [-d destdir] sysname\n");
296
	fprintf(stderr, "usage: config [-CgpV] [-k srcdir] [-d destdir] sysname\n");
282
	fprintf(stderr, "       config -x kernel\n");
297
	fprintf(stderr, "       config -x kernel\n");
283
	exit(EX_USAGE);
298
	exit(EX_USAGE);
284
}
299
}
(-)mkmakefile.c (-5 / +25 lines)
Lines 116-122 makefile(void) Link Here
116
	int versreq;
116
	int versreq;
117
117
118
	read_files();
118
	read_files();
119
	snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename);
119
	if (*ksrcdir != '\0')
120
		snprintf(line, sizeof(line), "%s/conf/Makefile.%s", 
121
		    ksrcdir, machinename);
122
	else
123
		snprintf(line, sizeof(line), "../../conf/Makefile.%s", 
124
		    machinename);
120
	ifp = fopen(line, "r");
125
	ifp = fopen(line, "r");
121
	if (ifp == 0) {
126
	if (ifp == 0) {
122
		snprintf(line, sizeof(line), "Makefile.%s", machinename);
127
		snprintf(line, sizeof(line), "Makefile.%s", machinename);
Lines 139-145 makefile(void) Link Here
139
		fprintf(ofp, "DEBUG=-g\n");
144
		fprintf(ofp, "DEBUG=-g\n");
140
	if (profiling)
145
	if (profiling)
141
		fprintf(ofp, "PROFLEVEL=%d\n", profiling);
146
		fprintf(ofp, "PROFLEVEL=%d\n", profiling);
142
	if (*srcdir != '\0')
147
	if (*ksrcdir != '\0')
148
		fprintf(ofp,"S=%s\n", ksrcdir);
149
	else if (*srcdir != '\0')
143
		fprintf(ofp,"S=%s\n", srcdir);
150
		fprintf(ofp,"S=%s\n", srcdir);
144
	while (fgets(line, BUFSIZ, ifp) != 0) {
151
	while (fgets(line, BUFSIZ, ifp) != 0) {
145
		if (*line != '%') {
152
		if (*line != '%') {
Lines 347-353 next: Link Here
347
			printf("%s: missing include filename.\n", fname);
354
			printf("%s: missing include filename.\n", fname);
348
			exit(1);
355
			exit(1);
349
		}
356
		}
350
		(void) snprintf(ifname, sizeof(ifname), "../../%s", wd);
357
		if (*ksrcdir != '\0')
358
			(void) snprintf(ifname, sizeof(ifname), "%s/%s", 
359
			    ksrcdir, wd);
360
		else
361
			(void) snprintf(ifname, sizeof(ifname), "../../%s", 
362
			    wd);
351
		read_file(ifname);
363
		read_file(ifname);
352
		while (((wd = get_word(fp)) != (char *)EOF) && wd)
364
		while (((wd = get_word(fp)) != (char *)EOF) && wd)
353
			;
365
			;
Lines 544-552 read_files(void) Link Here
544
	char fname[MAXPATHLEN];
556
	char fname[MAXPATHLEN];
545
	struct files_name *nl, *tnl;
557
	struct files_name *nl, *tnl;
546
	
558
	
547
	(void) snprintf(fname, sizeof(fname), "../../conf/files");
559
	if (*ksrcdir != '\0')
560
		(void) snprintf(fname, sizeof(fname), "%s/conf/files", 
561
		    ksrcdir);
562
	else
563
		(void) snprintf(fname, sizeof(fname), "../../conf/files");
548
	read_file(fname);
564
	read_file(fname);
549
	(void) snprintf(fname, sizeof(fname),
565
	if (*ksrcdir != '\0')
566
		(void) snprintf(fname, sizeof(fname),
567
		       	"%s/conf/files.%s", ksrcdir, machinename);
568
	else
569
		(void) snprintf(fname, sizeof(fname),
550
		       	"../../conf/files.%s", machinename);
570
		       	"../../conf/files.%s", machinename);
551
	read_file(fname);
571
	read_file(fname);
552
	for (nl = STAILQ_FIRST(&fntab); nl != NULL; nl = tnl) {
572
	for (nl = STAILQ_FIRST(&fntab); nl != NULL; nl = tnl) {
(-)config.8 (+5 lines)
Lines 38-43 Link Here
38
.Nm
38
.Nm
39
.Op Fl CVgp
39
.Op Fl CVgp
40
.Op Fl d Ar destdir
40
.Op Fl d Ar destdir
41
.Op Fl k Ar ksrcdir
41
.Ar SYSTEM_NAME
42
.Ar SYSTEM_NAME
42
.Nm
43
.Nm
43
.Op Fl x Ar kernel
44
.Op Fl x Ar kernel
Lines 78-83 Note that Link Here
78
does not append
79
does not append
79
.Ar SYSTEM_NAME
80
.Ar SYSTEM_NAME
80
to the directory given.
81
to the directory given.
82
.It Fl k Ar ksrcdir
83
Use
84
.Ar ksrcdir
85
as the kernel source tree directory, instead of the default one.
81
.It Fl g
86
.It Fl g
82
Configure a system for debugging.
87
Configure a system for debugging.
83
.It Fl x Ar kernel
88
.It Fl x Ar kernel
(-)config.h (+2 lines)
Lines 196-201 extern int maxusers; Link Here
196
196
197
extern char *PREFIX;		/* Config file name - for error messages */
197
extern char *PREFIX;		/* Config file name - for error messages */
198
extern char srcdir[];		/* root of the kernel source tree */
198
extern char srcdir[];		/* root of the kernel source tree */
199
extern char ksrcdir[];		/* root of the kernel source tree 
200
				 * set by -k flag */
199
201
200
#define eq(a,b)	(!strcmp(a,b))
202
#define eq(a,b)	(!strcmp(a,b))
201
#define ns(s)	strdup(s)
203
#define ns(s)	strdup(s)
(-)lang.l (-1 / +4 lines)
Lines 259-265 include(const char *fname, int ateof) Link Here
259
	fnamebuf = NULL;
259
	fnamebuf = NULL;
260
	fp = fopen(fname, "r");
260
	fp = fopen(fname, "r");
261
	if (fp == NULL && fname[0] != '.' && fname[0] != '/') {
261
	if (fp == NULL && fname[0] != '.' && fname[0] != '/') {
262
		asprintf(&fnamebuf, "../../conf/%s", fname);
262
		if (*ksrcdir != '\0')
263
			asprintf(&fnamebuf, "%s/conf/%s", ksrcdir, fname);
264
		else
265
			asprintf(&fnamebuf, "../../conf/%s", fname);
263
		if (fnamebuf != NULL) {
266
		if (fnamebuf != NULL) {
264
			fp = fopen(fnamebuf, "r");
267
			fp = fopen(fnamebuf, "r");
265
			free(fnamebuf);
268
			free(fnamebuf);

Return to bug 145694