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.
This commit is contained in:
tsutsui 2012-05-05 16:03:55 +00:00
parent a4deae0de5
commit 56ed3d51fc
3 changed files with 13 additions and 17 deletions

View File

@ -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

View File

@ -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/04/06 20:09:26 christos Exp $");
#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 512 sector I/O */
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

View File

@ -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"