diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2016-10-14 18:51:05 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2016-10-14 18:51:05 +0000 |
commit | 54344def2a6972e91e6b2de09f0c8a84c3a8a3d6 (patch) | |
tree | 1293b0f9422f30ef1a0a7395de57623565498d3f /usr.sbin/config | |
parent | f3a1927a54bcea1c76a87330fdc5cba70894f520 (diff) |
Change the default non -b behaviour of config(8) to operate with the
new compile behaviour:
- create a Makefile including ../Makefile.inc
- run "make obj" to create the obj directory
- run "make config", to use logic in ../Makefile.inc to re-run config
with the correct -b options, thereby creating a layout in obj/
- exit 0.
As a result, the old patterns our fingers are used to continue to work
and there will be fewer curses.
ok natano tb
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/main.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 86fe1d6825d..8e7e60c5597 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.51 2016/09/12 14:33:12 akfaew Exp $ */ +/* $OpenBSD: main.c,v 1.52 2016/10/14 18:51:04 deraadt Exp $ */ /* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */ /* @@ -107,7 +107,7 @@ main(int argc, char *argv[]) int ch, eflag, uflag, fflag; char dirbuffer[PATH_MAX]; - if (pledge("stdio rpath wpath cpath flock", NULL) == -1) + if (pledge("stdio rpath wpath cpath flock proc exec", NULL) == -1) err(1, "pledge"); pflag = eflag = uflag = fflag = 0; @@ -664,6 +664,7 @@ void setupdirs(void) { struct stat st; + FILE *fp; /* srcdir must be specified if builddir is not specified or if * no configuration filename was specified. */ @@ -699,6 +700,33 @@ setupdirs(void) srcdir); exit(2); } + + if (bflag) { + if (pledge("stdio rpath wpath cpath flock", NULL) == -1) + err(1, "pledge"); + return; + } + + if (stat("obj", &st) == 0) + goto reconfig; + + fp = fopen("Makefile", "w"); + if (!fp) { + (void)fprintf(stderr, "config: cannot create Makefile\n"); + exit(2); + } + if (fprintf(fp, ".include \"../Makefile.inc\"\n") < 0) { + (void)fprintf(stderr, "config: cannot create Makefile\n"); + exit(2); + } + fclose(fp); + +reconfig: + if (system("make obj") != 0) + exit(2); + if (system("make config") != 0) + exit(2); + exit(0); } struct opt { |