Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Jan 2003 15:31:16 -0800
From:      Juli Mallett <jmallett@FreeBSD.org>
To:        current@FreeBSD.org
Cc:        Peter Wemm <peter@FreeBSD.org>
Subject:   Patch to teach config(8) about "platforms".
Message-ID:  <20030125153116.A25743@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
This patch is needed for the MIPS port's infrastructure, and will be
needed for the PowerPC one, as given ports may support any number of
platforms, on those architectures (and arguably, the same applies to
i386 vs. pc98, but historically...).  What it does is it sets up a
build-time (and install-time, given right MACHINE_ARCH vs. MACHINE)
<platform> include directory as an analogue to <machine>, where we
need it.  For kernels with a "platform" setting, it also sets the
appropriate option for it.  For example "platform sgimips" implies
"options SGIMIPS".  Below are patches to makefile glue and config(8)
itself.

For clarity, this is used in cases where the platform may define its
own values that a header needs, and as such, you might see something
in <machine/endian.h> like:
#include <platform/endian.h>

To let the platform determine the endianness, as the port may support
many such configurations with different values.

And note that while it is tempting to have <platform> be <machine> on
systems with MACHINE == MACHINE_ARCH, this breaks things like mkioctl.

%%%
diff -dur src/include/Makefile mips/include/Makefile
--- src/include/Makefile	Fri Jan 24 00:34:40 2003
+++ src/include/Makefile	Thu Jan 23 22:46:13 2003
@@ -80,7 +80,7 @@
 .endfor
 
 copies:
-.for i in ${LDIRS} ${LSYMSUBDIRS} machine crypto
+.for i in ${LDIRS} ${LSYMSUBDIRS} platform machine crypto
 	if [ -L ${DESTDIR}/usr/include/$i ]; then \
 		rm -f ${DESTDIR}/usr/include/$i; \
 	fi
@@ -95,6 +95,11 @@
 	cd ${.CURDIR}/../sys; \
 		${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 opencrypto/*.h \
 		${DESTDIR}/usr/include/crypto
+.if ${MACHINE_ARCH} != ${MACHINE} && exists(${.CURDIR}/../sys/${MACHINE_ARCH}/${MACHINE})
+	cd ${.CURDIR}/../sys/${MACHINE_ARCH}/${MACHINE}; \
+		${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+		${DESTDIR}/usr/include/platform
+.endif
 .if exists(${.CURDIR}/../sys/${MACHINE_ARCH}/include)
 	cd ${.CURDIR}/../sys/${MACHINE_ARCH}/include; \
 		${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
@@ -118,6 +123,10 @@
 	rm -rf ${DESTDIR}/usr/include/$i
 	ln -s ../../../sys/$i ${DESTDIR}/usr/include/$i
 .endfor
+	rm -rf ${DESTDIR}/usr/include/platform
+.if ${MACHINE_ARCH} != ${MACHINE} && exists(../../sys/${MACHINE_ARCH}/${MACHINE})
+	ln -s ../../sys/${MACHINE_ARCH}/${MACHINE} ${DESTDIR}/usr/include/platform
+.endif
 	rm -rf ${DESTDIR}/usr/include/machine
 	ln -s ../../sys/${MACHINE_ARCH}/include ${DESTDIR}/usr/include/machine
 
diff -dur src/sys/conf/kmod.mk mips/sys/conf/kmod.mk
--- src/sys/conf/kmod.mk	Fri Jan 24 00:35:37 2003
+++ src/sys/conf/kmod.mk	Thu Jan 23 22:47:11 2003
@@ -145,7 +145,7 @@
 .endif
 .endif
 
-_ILINKS=@ machine
+_ILINKS=@ machine platform
 
 all: objwarn ${PROG}
 
@@ -170,10 +170,18 @@
 .error "can't find kernel source tree"
 .endif
 
+.if ${MACHINE_ARCH} != ${MACHINE} && exists(${SYSDIR}/${MACHINE_ARCH}/${MACHINE})
+PLATFORMPATH=	${SYSDIR}/${MACHINE_ARCH}/${MACHINE}
+.else
+PLATFORMPATH=	machine
+.endif
+
 ${_ILINKS}:
 	@case ${.TARGET} in \
 	machine) \
 		path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
+	platform) \
+		path=${PLATFORMPATH} ;; \
 	@) \
 		path=${SYSDIR} ;; \
 	esac ; \
diff -dur src/usr.sbin/config/config.h mips/usr.sbin/config/config.h
--- src/usr.sbin/config/config.h	Thu Nov  7 21:00:20 2002
+++ src/usr.sbin/config/config.h	Fri Nov  1 11:16:59 2002
@@ -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.  It also *may* know about a platform, which
+ * is a superconfiguration of a given machine.
  */
 char	*machinename;
+char	*platformname;
 
 /*
  * For each machine, a set of CPU's may be specified as supported.
Only in mips/usr.sbin/config: config.o
diff -dur src/usr.sbin/config/config.y mips/usr.sbin/config/config.y
--- src/usr.sbin/config/config.y	Thu Nov  7 21:00:20 2002
+++ src/usr.sbin/config/config.y	Fri Nov  1 11:16:59 2002
@@ -14,6 +14,7 @@
 %token	HINTS
 %token	IDENT
 %token	MAXUSERS
+%token	PLATFORM
 %token	PROFILE
 %token	OPTIONS
 %token	MAKEOPTIONS
@@ -135,6 +136,10 @@
 		cp->cpu_name = $2;
 		cp->cpu_next = cputype;
 		cputype = cp;
+	      } |
+	PLATFORM Save_id
+	    = {
+		platformname = $2;
 	      } |
 	OPTIONS Opt_list
 		|
Only in mips/usr.sbin/config: lang.c
diff -dur src/usr.sbin/config/lang.l mips/usr.sbin/config/lang.l
--- src/usr.sbin/config/lang.l	Thu Nov  7 21:00:20 2002
+++ src/usr.sbin/config/lang.l	Fri Nov  1 11:16:59 2002
@@ -73,6 +73,7 @@
 	{ "machine",	ARCH }, /* MACHINE is defined in /sys/param.h */
 	{ "makeoptions", MAKEOPTIONS },
 	{ "maxusers",	MAXUSERS },
+	{ "platform",	PLATFORM },
 	{ "profile",	PROFILE },
 	{ "option",	OPTIONS },
 	{ "options",	OPTIONS },
Only in mips/usr.sbin/config: lang.o
diff -dur src/usr.sbin/config/main.c mips/usr.sbin/config/main.c
--- src/usr.sbin/config/main.c	Thu Nov  7 21:00:20 2002
+++ src/usr.sbin/config/main.c	Fri Nov  1 11:16:59 2002
@@ -164,6 +164,22 @@
 		    srcdir, machinename);
 	(void) unlink(path("machine"));
 	(void) symlink(xxx, path("machine"));
+	/*
+	 * make symbolic link for the platform, if we have one.
+	 * otherwise, just fall back to using the machine (symlink).
+	 */
+	if (platformname != NULL) {
+		if (*srcdir == '\0')
+			(void)snprintf(xxx, sizeof(xxx), "../../%s",
+			    platformname);
+		else
+			(void)snprintf(xxx, sizeof(xxx), "%s/%s/%s",
+			    srcdir, machinename, platformname);
+	} else {
+		(void)snprintf(xxx, sizeof(xxx), "machine");
+	}
+	(void) unlink(path("platform"));
+	(void) symlink(xxx, path("platform"));
 	options();			/* make options .h files */
 	makefile();			/* build Makefile */
 	headers();			/* make a lot of .h files */
Only in mips/usr.sbin/config: main.o
Only in mips/usr.sbin/config: mkheaders.o
Only in mips/usr.sbin/config: mkmakefile.o
diff -dur src/usr.sbin/config/mkoptions.c mips/usr.sbin/config/mkoptions.c
--- src/usr.sbin/config/mkoptions.c	Thu Nov  7 21:00:20 2002
+++ src/usr.sbin/config/mkoptions.c	Sat Jan 25 02:29:58 2003
@@ -78,7 +78,20 @@
 		op->op_name = ns(cp->cpu_name);
 		op->op_next = opt;
 		opt = op;
-	}	
+	}
+
+	/* Fake the platform as an option. */
+	if (platformname != NULL) {
+		char *p;
+
+		op = (struct opt *)malloc(sizeof(*op));
+		memset(op, 0, sizeof(*op));
+		op->op_name = ns(platformname);
+		for (p = op->op_name; *p != '\0'; p++)
+			*p = toupper((unsigned char)*p);
+		op->op_next = opt;
+		opt = op;
+	}
 
 	if (maxusers == 0) {
 		/* printf("maxusers not specified; will auto-size\n"); */

%%%

Thanx,
juli.
-- 
Juli Mallett <jmallett@FreeBSD.org>
AIM: BSDFlata -- IRC: juli on EFnet.
OpenDarwin, Mono, FreeBSD Developer.
ircd-hybrid Developer, EFnet addict.
FreeBSD on MIPS-Anything on FreeBSD.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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