Module Name:    src
Committed By:   tsutsui
Date:           Sat May  5 16:03:55 UTC 2012

Modified Files:
        src/sbin/fdisk: Makefile fdisk.c
        src/tools/fdisk: Makefile

Log Message:
Don't use "#if defined(__i386__) || defined(__x86_64__)" conditionals
in C source file to define option features.
Define proper options in each Makefile per ${MACHINE_ARCH} variable instead.

Previously if a host is x86 and it has /usr/mdec/mbr file in its system,
tools fdisk implicitly installs it as mbr bootcode even for !x86 targets.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sbin/fdisk/Makefile
cvs rdiff -u -r1.140 -r1.141 src/sbin/fdisk/fdisk.c
cvs rdiff -u -r1.4 -r1.5 src/tools/fdisk/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/fdisk/Makefile
diff -u src/sbin/fdisk/Makefile:1.41 src/sbin/fdisk/Makefile:1.42
--- src/sbin/fdisk/Makefile:1.41	Fri Nov 27 15:37:32 2009
+++ src/sbin/fdisk/Makefile	Sat May  5 16:03:55 2012
@@ -1,10 +1,17 @@
-#	$NetBSD: Makefile,v 1.41 2009/11/27 15:37:32 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.42 2012/05/05 16:03:55 tsutsui Exp $
 
 PROG=	fdisk 
 SRCS=	fdisk.c
 
 MAN=	fdisk.8
 
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
+CPPFLAGS+= -DBOOTSEL
+.if (${HOSTPROG:U} == "")
+CPPFLAGS+= -DUSE_DISKLIST
+.endif
+.endif
+
 .if ${MACHINE} == "arc"
 CPPFLAGS+= -D_PATH_DEFDISK='"/dev/rsd0d"'
 .endif

Index: src/sbin/fdisk/fdisk.c
diff -u src/sbin/fdisk/fdisk.c:1.140 src/sbin/fdisk/fdisk.c:1.141
--- src/sbin/fdisk/fdisk.c:1.140	Fri Apr  6 20:09:26 2012
+++ src/sbin/fdisk/fdisk.c	Sat May  5 16:03:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdisk.c,v 1.140 2012/04/06 20:09:26 christos Exp $ */
+/*	$NetBSD: fdisk.c,v 1.141 2012/05/05 16:03:55 tsutsui Exp $ */
 
 /*
  * Mach Operating System
@@ -39,7 +39,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: fdisk.c,v 1.140 2012/04/06 20:09:26 christos Exp $");
+__RCSID("$NetBSD: fdisk.c,v 1.141 2012/05/05 16:03:55 tsutsui Exp $");
 #endif /* not lint */
 
 #define MBRPTYPENAMES
@@ -91,13 +91,6 @@ __RCSID("$NetBSD: fdisk.c,v 1.140 2012/0
 #define	LE_MBR_MAGIC		htole16(MBR_MAGIC)
 #define	LE_MBR_BS_MAGIC		htole16(MBR_BS_MAGIC)
 
-#if defined(__i386__) || defined(__x86_64__)
-#if !HAVE_NBTOOL_CONFIG_H
-#include <machine/cpu.h>
-#endif /* !HAVE_NBTOOL_CONFIG_H */
-#define BOOTSEL
-#endif
-
 #ifdef BOOTSEL
 
 #define	DEFAULT_BOOTCODE	"mbr"
@@ -250,8 +243,8 @@ static char *iobuf;		/* buffer for non 5
 static int bootsize;		/* actual size of bootcode */
 static int boot_installed;	/* 1 if we've copied code into the mbr */
 
-#if (defined(__i386__) || defined(__x86_64__)) && !HAVE_NBTOOL_CONFIG_H
-#define USE_DISKLIST
+#if defined(USE_DISKLIST)
+#include <machine/cpu.h>
 static struct disklist *dl;
 #endif
 

Index: src/tools/fdisk/Makefile
diff -u src/tools/fdisk/Makefile:1.4 src/tools/fdisk/Makefile:1.5
--- src/tools/fdisk/Makefile:1.4	Sat Jun 19 23:11:10 2010
+++ src/tools/fdisk/Makefile	Sat May  5 16:03:55 2012
@@ -1,13 +1,9 @@
-#	$NetBSD: Makefile,v 1.4 2010/06/19 23:11:10 riz Exp $
+#	$NetBSD: Makefile,v 1.5 2012/05/05 16:03:55 tsutsui Exp $
 
 HOSTPROGNAME=	${MACHINE_GNU_PLATFORM}-fdisk
 HOST_SRCDIR=	sbin/fdisk
 HOST_SRCS=	getcap.c disklabel.c
 
-.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
-CPPFLAGS+= -DBOOTSEL
-.endif
-
 .include "${.CURDIR}/../Makefile.nbincludes"
 .include "${.CURDIR}/../Makefile.host"
 

Reply via email to