Subject: bin/32508: SMALLPROG version installboot(8)
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <tsutsui@ceres.dti.ne.jp>
List: netbsd-bugs
Date: 01/12/2006 13:30:00
>Number:         32508
>Category:       bin
>Synopsis:       SMALLPROG version installboot(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 12 13:30:00 +0000 2006
>Originator:     Izumi Tsutsui
>Release:        NetBSD 3.99.15
>Organization:
>Environment:
System: NetBSD mirage 3.99.15
Architecture: i386
Machine: i386
>Description:
installboot(8) binary includes functions for all supported target
architecutures, but in most case (especially for installer binary)
support for architectures other than target ${MACHINE} is not needed.
It's better to have only the target ${MACHINE} support if SMALLPROG
is defined.

>How-To-Repeat:
Build current installboot(8) binary.

>Fix:
Index: Makefile
===================================================================
RCS file: /cvsroot/src/usr.sbin/installboot/Makefile,v
retrieving revision 1.33
diff -u -r1.33 Makefile
--- Makefile	29 Dec 2005 15:32:20 -0000	1.33
+++ Makefile	12 Jan 2006 13:09:16 -0000
@@ -5,10 +5,58 @@
 
 PROG=	installboot
 SRCS=	installboot.c sum.c machines.c fstypes.c \
-	ffs.c ffs_bswap.c bbinfo.c \
-	alpha.c amiga.c ews4800mips.c hp300.c hp700.c i386.c macppc.c \
-	news.c next68k.c pmax.c \
-	sparc.c sparc64.c sun68k.c vax.c x68k.c
+	ffs.c ffs_bswap.c bbinfo.c
+
+.if defined(SMALLPROG)
+CPPFLAGS+=	-DNOCROSS -DBUILD_${MACHINE}
+.endif
+
+.if (!defined(SMALLPROG) || ${MACHINE} == "alpha")
+SRCS+=	alpha.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "amiga")
+SRCS+=	amiga.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "ews4800mips")
+SRCS+=	ews4800mips.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "hp300")
+SRCS+=	hp300.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "hp700")
+SRCS+=	hp700.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "amd64" || ${MACHINE} == "i386")
+SRCS+=	i386.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "macppc")
+SRCS+=	macppc.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "news68k" || ${MACHINE} == "newsmips")
+SRCS+=	news.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "next68k")
+SRCS+=	next68k.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "pmax")
+SRCS+=	pmax.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "sparc")
+SRCS+=	sparc.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "sparc64")
+SRCS+=	sparc64.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "sun2" || ${MACHINE} == "sun3")
+SRCS+=	sun68k.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "vax")
+SRCS+=	vax.c
+.endif
+.if (!defined(SMALLPROG) || ${MACHINE} == "x68k")
+SRCS+=	x68k.c
+.endif
+
 MAN=	installboot.8
 
 WARNS?=	3
Index: machines.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/installboot/machines.c,v
retrieving revision 1.31
diff -u -r1.31 machines.c
--- machines.c	29 Dec 2005 15:32:20 -0000	1.31
+++ machines.c	12 Jan 2006 13:09:16 -0000
@@ -49,45 +49,84 @@
 #include "installboot.h"
 
 struct ib_mach machines[] = {
+#if !defined(NOCROSS) || defined(BUILD_alpha)
 	{ "alpha",	alpha_setboot,	alpha_clearboot, no_editboot,
 		IB_STAGE1START | IB_ALPHASUM | IB_APPEND | IB_SUNSUM },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_amd64)
 	{ "amd64",	i386_setboot,	no_clearboot,	i386_editboot,
 		IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
 		IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_amiga)
 	{ "amiga",	amiga_setboot,	no_clearboot,	no_editboot,
 		IB_STAGE1START | IB_STAGE2START | IB_COMMAND },
+#endif
+
+#if !defined(NOCROSS) || defined(BUILD_ews4800mips)
 	{ "ews4800mips", ews4800mips_setboot, no_clearboot, no_editboot,
 		0 },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_hp300)
 	{ "hp300",	hp300_setboot,	no_clearboot,	no_editboot,
 		IB_APPEND },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_hp700)
 	{ "hp700",	hp700_setboot,	hp700_clearboot, no_editboot,
 		0 },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_i386)
 	{ "i386",	i386_setboot,	no_clearboot,	i386_editboot,
 		IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
 		IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_macppc)
 	{ "macppc",	macppc_setboot,	macppc_clearboot, no_editboot,
 		IB_STAGE2START },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_news68k)
 	{ "news68k",	news68k_setboot, news68k_clearboot, no_editboot,
 		IB_STAGE2START },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_newsmips)
 	{ "newsmips",	newsmips_setboot, newsmips_clearboot, no_editboot,
 		IB_STAGE2START },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_next68k)
 	{ "next68k",	next68k_setboot, no_clearboot,	no_editboot,
 		0 },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_pmax)
 	{ "pmax",	pmax_setboot,	pmax_clearboot,	no_editboot,
 		IB_STAGE1START | IB_APPEND | IB_SUNSUM },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_shark)
 	{ "shark",	no_setboot,	no_clearboot,	no_editboot,
 		0 },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_sparc)
 	{ "sparc",	sparc_setboot,	sparc_clearboot, no_editboot,
 		IB_STAGE2START },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_sparc64)
 	{ "sparc64",	sparc64_setboot, sparc64_clearboot, no_editboot,
 		0 },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_sun2)
 	{ "sun2",	sun68k_setboot,	sun68k_clearboot, no_editboot,
 		IB_STAGE2START },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_sun3)
 	{ "sun3",	sun68k_setboot,	sun68k_clearboot, no_editboot,
 		IB_STAGE2START },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_vax)
 	{ "vax",	vax_setboot,	vax_clearboot,	no_editboot,
 		IB_STAGE1START | IB_APPEND | IB_SUNSUM },
+#endif
+#if !defined(NOCROSS) || defined(BUILD_x68k)
 	{ "x68k",	x68k_setboot,	x68k_clearboot,	no_editboot,
 		IB_STAGE1START | IB_STAGE2START },
+#endif
 	{ 0, 0, 0, 0 },
 };
Index: arch/news.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/installboot/arch/news.c,v
retrieving revision 1.5
diff -u -r1.5 news.c
--- arch/news.c	27 Oct 2003 00:12:44 -0000	1.5
+++ arch/news.c	12 Jan 2006 13:09:16 -0000
@@ -60,6 +60,7 @@
 static int news_copydisklabel(ib_params *, struct bbinfo_params *, uint8_t *);
 
 
+#if !defined(NOCROSS) || defined(BUILD_news68k)
 /*
  * news68k specific support
  */
@@ -92,8 +93,10 @@
 	return (shared_bbinfo_setboot(params, &news68k_bbparams,
 	    news_copydisklabel));
 }
+#endif /* !defined(NOCROSS) || defined(BUILD_news68k) */
 
 
+#if !defined(NOCROSS) || defined(BUILD_newsmips)
 /*
  * newsmips specific support
  */
@@ -126,6 +129,7 @@
 	return (shared_bbinfo_setboot(params, &newsmips_bbparams,
 	    news_copydisklabel));
 }
+#endif /* !defined(NOCROSS) || defined(BUILD_newsmips) */
 
 
 /*