Date: Thu, 31 Mar 2005 22:56:33 -0700 (MST) From: "M. Warner Losh" <imp@bsdimp.com> To: arch@freebsd.org Subject: small change to config Message-ID: <20050331.225633.125544617.imp@bsdimp.com>
next in thread | raw e-mail | index | archive | help
I'd like to make a small change to config, and use that change to improve the pc98 port. Right now, the machine line in config looks like: machine pc98 This causes compile/FOO/machine to be linked to pc98/include. We have similar logic for modules. NetBSD's machine line, on some architecutres, has two arguments, which correspond to $MACHINE and $MACHINE_ARCH respectively. I'd like to pull this concept into FreeBSD. The only machine that this impacts is pc98. pc98 config files would change to: machine pc98 i386 config creates the machine link, as now. In addition, a link is made from i386 to sys/i386/include. This allows the majority of the .h files that are shared amoung ports that have the same CPU to live in one place, and the machine/foo.h files with minor tweaks. I'd like to move to this model on FreeBSD, and use it to reduce the number of #ifdef PC98 in the tree, while allowing a cleaner separation of pc98 from i386. This should reduce the maintanence impact of having pc98 in the tree, as well as being cleaner. This idea can be extended for whole families of CPUs. So in theory we could also add an x86 directory as well, and share that among i386, amd64 and pc98. However, that's beyond the scope of the work that I'm doing at the moment. There's a number of other things in the tree which need to be changed as well, which will follow in suit. This is just the first step. I have buildworld running on pc98, and am working on installworld and kernel targets. Comments? Warner P.S. I just noitced that I didn't bump the version of config... diff -u /home/imp/FreeBSD/src/usr.sbin/config/config.h /u2/imp/p4/src/usr.sbin/config/config.h --- /home/imp/FreeBSD/src/usr.sbin/config/config.h Fri Sep 3 21:29:01 2004 +++ /u2/imp/p4/src/usr.sbin/config/config.h Thu Mar 31 11:21:26 2005 @@ -91,9 +91,11 @@ * being used. It uses the name of the machine in choosing * files and directories. Thus if the name of the machine is ``i386'', * it will build from ``Makefile.i386'' and use ``../i386/inline'' - * in the makerules, etc. + * in the makerules, etc. machinearc is the global notion of the + * MACHINE_ARCH for this MACHINE. */ char *machinename; +char *machinearch; /* * For each machine, a set of CPU's may be specified as supported. diff -u /home/imp/FreeBSD/src/usr.sbin/config/config.y /u2/imp/p4/src/usr.sbin/config/config.y --- /home/imp/FreeBSD/src/usr.sbin/config/config.y Sun Nov 14 23:05:56 2004 +++ /u2/imp/p4/src/usr.sbin/config/config.y Thu Mar 31 11:21:26 2005 @@ -138,6 +138,15 @@ errx(1, "%s:%d: only one machine directive is allowed", yyfile, yyline); machinename = $2; + machinearch = $2; + } | + ARCH Save_id Save_id + = { + if (machinename != NULL) + errx(1, "%s:%d: only one machine directive is allowed", + yyfile, yyline); + machinename = $2; + machinearch = $3; } | CPU Save_id = { diff -u /home/imp/FreeBSD/src/usr.sbin/config/main.c /u2/imp/p4/src/usr.sbin/config/main.c --- /home/imp/FreeBSD/src/usr.sbin/config/main.c Wed Mar 30 14:45:08 2005 +++ /u2/imp/p4/src/usr.sbin/config/main.c Thu Mar 31 12:15:30 2005 @@ -163,6 +163,20 @@ srcdir, machinename); (void) unlink(path("machine")); (void) symlink(xxx, path("machine")); + if (strcmp(machinename, machinearch) != 0) { + /* + * make symbolic links in compilation directory for + * machinearch, if it is different than machinename. + */ + if (*srcdir == '\0') + (void)snprintf(xxx, sizeof(xxx), "../../../%s/include", + machinearch); + else + (void)snprintf(xxx, sizeof(xxx), "%s/%s/include", + srcdir, machinearch); + (void) unlink(path(machinearch)); + (void) symlink(xxx, path(machinearch)); + } options(); /* make options .h files */ makefile(); /* build Makefile */ headers(); /* make a lot of .h files */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050331.225633.125544617.imp>