diff -Naur util-linux-2.12q.orig/MCONFIG util-linux-2.12q/MCONFIG
--- util-linux-2.12q.orig/MCONFIG	2004-12-13 01:15:48.000000000 +0200
+++ util-linux-2.12q/MCONFIG	2005-06-11 16:00:56.000000000 +0300
@@ -17,7 +17,8 @@
 # Select for CPU i386 if the binaries must be able to run on an intel 386
 # (by default i486 code is generated, see below)
 CPU=$(shell uname -m)
-ARCH=$(shell echo $(CPU) | sed 's/i.86/intel/;s/arm.*/arm/')
+ARCH=$(shell echo $(CPU) | sed 's/i.86.*/intel/;s/arm.*/arm/')
+KERNEL=$(shell uname -s | tr '[:upper:]' '[:lower:]')
 
 # If HAVE_PAM is set to "yes", then login, chfn, chsh, and newgrp
 # will use PAM for authentication. Additionally, passwd will not be
diff -Naur util-linux-2.12q.orig/disk-utils/fsck.minix.c util-linux-2.12q/disk-utils/fsck.minix.c
--- util-linux-2.12q.orig/disk-utils/fsck.minix.c	2004-08-25 01:21:39.000000000 +0300
+++ util-linux-2.12q/disk-utils/fsck.minix.c	2005-06-11 16:00:56.000000000 +0300
@@ -99,10 +99,6 @@
 #include "minix.h"
 #include "nls.h"
 
-#ifndef __linux__
-#define volatile
-#endif
-
 #define ROOT_INO 1
 
 #define UPPER(size,n) ((size+((n)-1))/(n))
diff -Naur util-linux-2.12q.orig/disk-utils/Makefile util-linux-2.12q/disk-utils/Makefile
--- util-linux-2.12q.orig/disk-utils/Makefile	2004-12-21 19:14:16.000000000 +0200
+++ util-linux-2.12q/disk-utils/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -8,24 +8,34 @@
 
 # Where to put man pages?
 
-MAN8= 	blockdev.8 fdformat.8 isosize.8 mkfs.8 mkswap.8 elvtune.8 \
-	fsck.minix.8 mkfs.minix.8 mkfs.bfs.8
+MAN8= 	isosize.8 mkfs.8 mkswap.8 fsck.minix.8 mkfs.minix.8 mkfs.bfs.8
+ifeq "$(KERNEL)" "linux"
+MAN8:=$(MAN8) fdformat.8 blockdev.8 elvtune.8
+endif
 
 # Where to put binaries?
 # See the "install" rule for the links. . .
 
-SBIN= 	mkfs mkswap blockdev elvtune fsck.minix mkfs.minix mkfs.bfs
+SBIN= 	mkfs mkswap fsck.minix mkfs.minix mkfs.bfs
+ifeq "$(KERNEL)" "linux"
+SBIN:=$(SBIN) blockdev elvtune
+endif
 
-USRBIN=	fdformat isosize
+USRBIN=	isosize
+ifeq "$(KERNEL)" "linux"
+USRBIN:=$(USRBIN) fdformat
+endif
 
 ETC=	fdprm
 
 MAYBE=  setfdprm raw fsck.cramfs mkfs.cramfs
 
+ifeq "$(KERNEL)" "linux"
 ifneq "$(HAVE_FDUTILS)" "yes"
 USRBIN:=$(USRBIN) setfdprm
 MAN8:=$(MAN8) setfdprm.8
 endif
+endif
 
 ifeq "$(HAVE_RAW_H)" "yes"
 USRBIN:=$(USRBIN) raw
@@ -57,9 +67,11 @@
 	$(INSTALLDIR) $(SBINDIR) $(USRBINDIR) $(ETCDIR)
 	$(INSTALLBIN) $(SBIN) $(SBINDIR)
 	$(INSTALLBIN) $(USRBIN) $(USRBINDIR)
+ifeq "$(KERNEL)" "linux"
 ifneq "$(HAVE_FDUTILS)" "yes"
 	$(INSTALLDAT) $(ETC) $(ETCDIR)
 endif
+endif
 	$(INSTALLDIR) $(MAN8DIR)
 	$(INSTALLMAN) $(MAN8) $(MAN8DIR)
 
diff -Naur util-linux-2.12q.orig/disk-utils/mkswap.c util-linux-2.12q/disk-utils/mkswap.c
--- util-linux-2.12q.orig/disk-utils/mkswap.c	2004-12-21 19:21:24.000000000 +0200
+++ util-linux-2.12q/disk-utils/mkswap.c	2005-06-11 16:00:56.000000000 +0300
@@ -75,6 +70,7 @@
 static int check = 0;
 static int version = -1;
 
+#ifdef __linux__
 #define MAKE_VERSION(p,q,r)	(65536*(p) + 256*(q) + (r))
 
 static int
@@ -90,6 +86,7 @@
 	}
 	return 0;
 }
+#endif /* __linux__ */
 
 #ifdef __sparc__
 # ifdef __arch64__
@@ -604,8 +569,10 @@
 		/* use version 1 as default, if possible */
 		if (PAGES <= V0_MAX_PAGES && PAGES > V1_MAX_PAGES)
 			version = 0;
+#ifdef __linux__
 		else if (linux_version_code() < MAKE_VERSION(2,1,117))
 			version = 0;
+#endif
 		else if (pagesize < 2048)
 			version = 0;
 		else
@@ -626,12 +593,17 @@
 
 	if (version == 0)
 		maxpages = V0_MAX_PAGES;
+#ifdef __linux__
 	else if (linux_version_code() >= MAKE_VERSION(2,3,4))
 		maxpages = PAGES;
 	else if (linux_version_code() >= MAKE_VERSION(2,2,1))
 		maxpages = V1_MAX_PAGES;
-	else
+#endif
+	else {
 		maxpages = V1_OLD_MAX_PAGES;
+		if (maxpages > V1_MAX_PAGES)
+			maxpages = V1_MAX_PAGES;
+	}
 
 	if (PAGES > maxpages) {
 		PAGES = maxpages;
diff -Naur util-linux-2.12q.orig/fdisk/fdisksgilabel.c util-linux-2.12q/fdisk/fdisksgilabel.c
--- util-linux-2.12q.orig/fdisk/fdisksgilabel.c	2004-12-18 03:53:45.000000000 +0200
+++ util-linux-2.12q/fdisk/fdisksgilabel.c	2005-06-11 16:00:56.000000000 +0300
@@ -16,6 +16,7 @@
 
 #include <endian.h>
 #include "nls.h"
-#include <linux/major.h>        /* FLOPPY_MAJOR */
 
 #include "common.h"
 #include "fdisk.h"
diff -Naur util-linux-2.12q.orig/fdisk/fdisksunlabel.c util-linux-2.12q/fdisk/fdisksunlabel.c
--- util-linux-2.12q.orig/fdisk/fdisksunlabel.c	2004-12-22 17:36:24.000000000 +0200
+++ util-linux-2.12q/fdisk/fdisksunlabel.c	2005-06-11 16:00:56.000000000 +0300
@@ -27,7 +27,9 @@
 #include <scsi/scsi.h>		/* SCSI_IOCTL_GET_IDLUN */
 #undef u_char
 #endif
+#ifdef __linux__
 #include <linux/major.h>	/* FLOPPY_MAJOR */
+#endif
 
 #include "common.h"
 #include "fdisk.h"
@@ -71,18 +73,21 @@
 	return SSWAP32(p.num_sectors);
 }
 
+#ifdef __linux__
 #ifndef IDE0_MAJOR
 #define IDE0_MAJOR 3
 #endif
 #ifndef IDE1_MAJOR
 #define IDE1_MAJOR 22
 #endif
+#endif
 void guess_device_type(int fd) {
 	struct stat bootstat;
 
 	if (fstat (fd, &bootstat) < 0) {
                 scsi_disk = 0;
                 floppy = 0;
+#ifdef __linux__
 	} else if (S_ISBLK(bootstat.st_mode)
 		   && (major(bootstat.st_rdev) == IDE0_MAJOR ||
 		       major(bootstat.st_rdev) == IDE1_MAJOR)) {
@@ -92,6 +97,7 @@
 		   && major(bootstat.st_rdev) == FLOPPY_MAJOR) {
                 scsi_disk = 0;
                 floppy = 1;
+#endif
 	} else {
                 scsi_disk = 1;
                 floppy = 0;
diff -Naur util-linux-2.12q.orig/fdisk/sfdisk.c util-linux-2.12q/fdisk/sfdisk.c
--- util-linux-2.12q.orig/fdisk/sfdisk.c	2005-01-05 00:31:57.000000000 +0200
+++ util-linux-2.12q/fdisk/sfdisk.c	2005-06-11 16:59:10.000000000 +0300
@@ -45,13 +45,18 @@
 #include <string.h>		/* index() */
 #include <ctype.h>
 #include <getopt.h>
-#include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <sys/utsname.h>
-#include <linux/unistd.h>	/* _syscall */
 #include "nls.h"
+#include "disk_geom.h"
+#include "disk_size.h"
 #include "common.h"
 
+extern long long ext2_llseek(unsigned int fd, long long offset,
+			     unsigned int origin);
+
 #define SIZE(a)	(sizeof(a)/sizeof(a[0]))
 
 /*
@@ -166,21 +172,11 @@
  *
  * For >4GB disks lseek needs a > 32bit arg, and we have to use llseek.
  * On the other hand, a 32 bit sector number is OK until 2TB.
- * The routines _llseek and sseek below are the only ones that
+ * The routines ext2_llseek and sseek below are the only ones that
  * know about the loff_t type.
  *
  * Note: we use 512-byte sectors here, irrespective of the hardware ss.
  */
-#undef use_lseek
-#if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (__s390x__)
-#define use_lseek
-#endif
-
-#ifndef use_lseek
-static __attribute__used
-_syscall5(int,  _llseek,  unsigned int,  fd, ulong, hi, ulong, lo,
-       loff_t *, res, unsigned int, wh);
-#endif
 
 static int
 sseek(char *dev, unsigned int fd, unsigned long s) {
@@ -188,11 +184,7 @@
     in = ((loff_t) s << 9);
     out = 1;
 
-#ifndef use_lseek
-    if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0) {
-#else
-    if ((out = lseek(fd, in, SEEK_SET)) != in) {
-#endif
+    if ((out = ext2_llseek(fd, in, SEEK_SET)) != in) {
 	perror("llseek");
 	error(_("seek error on %s - cannot seek to %lu\n"), dev, s);
 	return 0;
@@ -1501,6 +1468,7 @@
 	z->partno = pno;
 }
 
+#ifdef __linux__
 #define MAKE_VERSION(p,q,r)     (65536*(p) + 256*(q) + (r))
 
 static int
@@ -1516,6 +1484,7 @@
         }
         return 0;
 }
+#endif
 
 static int
 msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
@@ -1525,7 +1494,11 @@
     struct sector *s;
     struct part_desc *partitions = &(z->partitions[0]);
     int pno = z->partno;
+#ifdef __linux__
     int bsd_later = (linux_version_code() >= MAKE_VERSION(2,3,40));
+#else
+    int bsd_later = 0;
+#endif
 
     if (!(s = get_sector(dev, fd, start)))
 	return 0;
diff -Naur util-linux-2.12q.orig/hwclock/Makefile util-linux-2.12q/hwclock/Makefile
--- util-linux-2.12q.orig/hwclock/Makefile	2004-12-15 21:11:59.000000000 +0200
+++ util-linux-2.12q/hwclock/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -3,6 +3,7 @@
 include ../make_include
 include ../MCONFIG
 
+ifeq "$(KERNEL)" "linux"
 # Where to put man pages?
 
 MAN8= 		hwclock.8
@@ -11,6 +12,7 @@
 # See the "install" rule for the links. . .
 
 SBIN= 		hwclock
+endif
 
 
 all: $(SBIN)
diff -Naur util-linux-2.12q.orig/login-utils/checktty.c util-linux-2.12q/login-utils/checktty.c
--- util-linux-2.12q.orig/login-utils/checktty.c	2001-05-20 00:53:18.000000000 +0300
+++ util-linux-2.12q/login-utils/checktty.c	2005-06-11 16:00:56.000000000 +0300
@@ -138,7 +138,9 @@
 isapty(const char *tty)
 {
     char devname[100];
+#if defined(__linux__)
     struct stat stb;
+#endif
 
     /* avoid snprintf - old systems do not have it */
     if (strlen(tty) + 6 > sizeof(devname))
diff -Naur util-linux-2.12q.orig/login-utils/login.c util-linux-2.12q/login-utils/login.c
--- util-linux-2.12q.orig/login-utils/login.c	2004-12-05 04:37:12.000000000 +0200
+++ util-linux-2.12q/login-utils/login.c	2005-06-11 16:00:56.000000000 +0300
@@ -288,6 +285,7 @@
 	}
 }
 
+#ifdef CHOWNVCS
 /* true if the filedescriptor fd is a console tty, very Linux specific */
 static int
 consoletty(int fd) {
@@ -302,6 +300,7 @@
 #endif
     return 0;
 }
+#endif
 
 #if USE_PAM
 /*
diff -Naur util-linux-2.12q.orig/login-utils/Makefile util-linux-2.12q/login-utils/Makefile
--- util-linux-2.12q.orig/login-utils/Makefile	2004-11-23 18:06:57.000000000 +0200
+++ util-linux-2.12q/login-utils/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -18,8 +18,10 @@
 
 MAN8.GETTY=	agetty.8
 
-MAN8.INIT=	fastboot.8 fasthalt.8 halt.8 reboot.8 simpleinit.8 shutdown.8 \
-		initctl.8
+MAN8.INIT=	simpleinit.8 initctl.8
+ifeq "$(KERNEL)" "linux"
+MAN8.INIT:=	$(MAN8.INIT) fastboot.8 fasthalt.8 halt.8 reboot.8 shutdown.8
+endif
 
 MAN8.PUTILS=	vipw.8 vigr.8
 
@@ -28,7 +30,10 @@
 
 SBIN.GETTY=	agetty
 
-SBIN.INIT=	simpleinit shutdown initctl
+SBIN.INIT=	simpleinit initctl
+ifeq "$(KERNEL)" "linux"
+SBIN.INIT:=	$(SBIN.INIT) shutdown
+endif
 
 BIN.PUTILS=	login
 
diff -Naur util-linux-2.12q.orig/login-utils/Makefile util-linux-2.12q/login-utils/Makefile
--- util-linux-2.12q.orig/login-utils/Makefile	2004-11-23 18:06:57.000000000 +0200
+++ util-linux-2.12q/login-utils/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -134,9 +140,11 @@
 ifeq "$(USE_TTY_GROUP)" "yes"
 	LOGINFLAGS += -DUSE_TTY_GROUP
 endif
+ifeq "$(KERNEL)" "linux"
 ifeq "$(ALLOW_VCS_USE)" "yes"
 	LOGINFLAGS += -DCHOWNVCS
 endif
+endif
 ifeq "$(DO_STAT_MAIL)" "yes"
 	LOGINFLAGS += -DDO_STAT_MAIL
 endif
@@ -195,10 +205,12 @@
 	$(INSTALLDIR) $(MAN8DIR)
 	$(INSTALLMAN) $(MAN8.INIT) $(MAN8DIR)
 	# Make *relative* links for these
+ifeq "$(KERNEL)" "linux"
 	(cd $(SHUTDOWNDIR); ln -sf shutdown reboot)
 	(cd $(SHUTDOWNDIR); ln -sf shutdown fastboot)
 	(cd $(SHUTDOWNDIR); ln -sf shutdown halt)
 	(cd $(SHUTDOWNDIR); ln -sf shutdown fasthalt)
+endif
 	(cd $(SHUTDOWNDIR); ln -sf initctl need)
 	(cd $(SHUTDOWNDIR); ln -sf initctl display-services)
 	(cd $(SHUTDOWNDIR); ln -sf initctl provide)
diff -Naur util-linux-2.12q.orig/login-utils/simpleinit.h util-linux-2.12q/login-utils/simpleinit.h
--- util-linux-2.12q.orig/login-utils/simpleinit.h	2000-11-05 14:41:35.000000000 +0200
+++ util-linux-2.12q/login-utils/simpleinit.h	2005-06-11 16:00:56.000000000 +0300
@@ -3,7 +3,7 @@
 
 
 #define ERRSTRING strerror (errno)
-#define COMMAND_SIZE  (PIPE_BUF - 4)
+#define COMMAND_SIZE  (_POSIX_PIPE_BUF - 4)
 
 
 #define COMMAND_TEST       0  /*  No wait, signal                            */
diff -Naur util-linux-2.12q.orig/MCONFIG util-linux-2.12q/MCONFIG
diff -Naur util-linux-2.12q.orig/misc-utils/script.c util-linux-2.12q/misc-utils/script.c
--- util-linux-2.12q.orig/misc-utils/script.c	2004-03-26 19:07:16.000000000 +0200
+++ util-linux-2.12q/misc-utils/script.c	2005-06-11 16:00:56.000000000 +0300
@@ -54,10 +54,8 @@
 #include <sys/signal.h>
 #include "nls.h"
 
-#ifdef __linux__
 #include <unistd.h>
 #include <string.h>
-#endif
 
 #include "../defines.h"
 #ifdef HAVE_openpty
diff -Naur util-linux-2.12q.orig/misc-utils/setterm.c util-linux-2.12q/misc-utils/setterm.c
--- util-linux-2.12q.orig/misc-utils/setterm.c	2003-10-17 19:17:51.000000000 +0300
+++ util-linux-2.12q/misc-utils/setterm.c	2005-06-11 16:00:56.000000000 +0300
@@ -107,16 +107,14 @@
 #else
 #include <curses.h>
 #endif
+#ifdef __linux__
 #include <sys/param.h>		/* for MAXPATHLEN */
+#endif
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include "nls.h"
 
 #ifndef TCGETS
 /* TCGETS is either defined in termios.h, or here: */
 #include <asm/ioctls.h>
 #endif
 
+#ifdef __linux__
 #if __GNU_LIBRARY__ < 5
 #ifndef __alpha__
 # include <linux/unistd.h>
@@ -127,6 +125,7 @@
 #endif
 #endif
 extern int klogctl(int type, char *buf, int len);
+#endif /* __linux__ */
 
 /* Constants. */
 
@@ -165,19 +164,24 @@
 int opt_term, opt_reset, opt_initialize, opt_cursor;
 int opt_linewrap, opt_snow, opt_softscroll, opt_default, opt_foreground;
 int opt_background, opt_bold, opt_blink, opt_reverse, opt_underline;
-int opt_store, opt_clear, opt_blank, opt_snap, opt_snapfile, opt_standout;
-int opt_append, opt_ulcolor, opt_hbcolor, opt_halfbright, opt_repeat;
+int opt_store, opt_clear, opt_blank, opt_standout;
+int opt_ulcolor, opt_hbcolor, opt_halfbright, opt_repeat;
 int opt_tabs, opt_clrtabs, opt_regtabs, opt_appcursorkeys, opt_inversescreen;
-int opt_msg, opt_msglevel, opt_powersave, opt_powerdown;
+int opt_powerdown;
 int opt_blength, opt_bfreq;
+#ifdef __linux__
+int opt_append, opt_snap, opt_snapfile;
+int opt_powersave;
+int opt_msg, opt_msglevel;
+#endif /* __linux__ */
 
 /* Option controls.  The variable names have been contracted to ensure
  * uniqueness.
  */
 char *opt_te_terminal_name;	/* Terminal name. */
-int opt_cu_on, opt_li_on, opt_sn_on, opt_so_on, opt_bo_on, opt_hb_on, opt_bl_on;
-int opt_re_on, opt_un_on, opt_rep_on, opt_appck_on, opt_invsc_on;
-int opt_msg_on;			/* Boolean switches. */
+int opt_cu_on, opt_li_on, opt_sn_on, opt_so_on, opt_bo_on, opt_hb_on;
+int opt_bl_on, opt_re_on, opt_un_on, opt_rep_on, opt_appck_on;
+int opt_invsc_on;		/* Boolean switches. */
 int opt_ke_type;		/* Keyboard type. */
 int opt_fo_color, opt_ba_color;	/* Colors. */
 int opt_ul_color, opt_hb_color;
@@ -185,16 +189,20 @@
 int opt_bl_min;			/* Blank screen. */
 int opt_blength_l;
 int opt_bfreq_f;
-int opt_sn_num;			/* Snap screen. */
 int opt_st_attr;
 int opt_rt_len;			/* regular tab length */
 int opt_tb_array[161];		/* Array for tab list */
-int opt_msglevel_num;
 int opt_ps_mode, opt_pd_min;	/* powersave mode/powerdown time */
 
+#ifdef __linux__
+int opt_msg_on;
+int opt_msglevel_num;
+
+int opt_sn_num;			/* Snap screen. */
 char opt_sn_name[200] = "screen.dump";
 
 static void screendump(int vcnum, FILE *F);
+#endif /* __linux__ */
 
 /* Command line parsing routines.
  *
@@ -402,6 +410,7 @@
 	}
 }
 
+#ifdef __linux__
 static void
 parse_powersave(int argc, char **argv, int *option, int *opt_mode, int *bad_arg) {
 	/* argc: Number of arguments for this option. */
@@ -432,6 +441,7 @@
 		*opt_mode = 0;
 	}
 }
+#endif /* __linux__ */
 
 #if 0
 static void
@@ -454,6 +464,7 @@
 }
 #endif
 
+#ifdef __linux__
 static void
 parse_msglevel(int argc, char **argv, int *option, int *opt_all, int *bad_arg) {
 	/* argc: Number of arguments for this option. */
@@ -512,6 +523,7 @@
 	if (argc == 1)
 		strcpy((char *)opt_all, argv[0]);
 }
+#endif /* __linux__ */
 
 static void
 parse_tabs(int argc, char **argv, int *option, int *tab_array, int *bad_arg) {
@@ -709,6 +721,7 @@
 		parse_regtabs(argc, argv, &opt_regtabs, &opt_rt_len, bad_arg);
 	else if (STRCMP(option, "blank") == 0)
 		parse_blank(argc, argv, &opt_blank, &opt_bl_min, bad_arg);
+#ifdef __linux__
 	else if (STRCMP(option, "dump") == 0)
 		parse_snap(argc, argv, &opt_snap, &opt_sn_num, bad_arg);
 	else if (STRCMP(option, "append") == 0)
@@ -721,6 +734,7 @@
 		parse_msglevel(argc, argv, &opt_msglevel, &opt_msglevel_num, bad_arg);
 	else if (STRCMP(option, "powersave") == 0)
 		parse_powersave(argc, argv, &opt_powersave, &opt_ps_mode, bad_arg);
+#endif /* __linux__ */
 	else if (STRCMP(option, "powerdown") == 0)
 		parse_blank(argc, argv, &opt_powerdown, &opt_pd_min, bad_arg);
 	else if (STRCMP(option, "blength") == 0)
@@ -783,12 +797,14 @@
 	fprintf(stderr, _("  [ -clrtabs [ tab1 tab2 tab3 ... ] ]   (tabn = 1-160)\n"));
 	fprintf(stderr, _("  [ -regtabs [1-160] ]\n"));
 	fprintf(stderr, _("  [ -blank [0-60] ]\n"));
+#ifdef __linux__
 	fprintf(stderr, _("  [ -dump   [1-NR_CONSOLES] ]\n"));
 	fprintf(stderr, _("  [ -append [1-NR_CONSOLES] ]\n"));
 	fprintf(stderr, _("  [ -file dumpfilename ]\n"));
 	fprintf(stderr, _("  [ -msg [on|off] ]\n"));
 	fprintf(stderr, _("  [ -msglevel [0-8] ]\n"));
 	fprintf(stderr, _("  [ -powersave [on|vsync|hsync|powerdown|off] ]\n"));
+#endif /* __linux__ */
 	fprintf(stderr, _("  [ -powerdown [0-60] ]\n"));
 	fprintf(stderr, _("  [ -blength [0-2000] ]\n"));
 	fprintf(stderr, _("  [ -bfreq freqnumber ]\n"));
@@ -811,8 +827,9 @@
 static void
 perform_sequence(int vcterm) {
 	/* vcterm: Set if terminal is a virtual console. */
-
+#ifdef __linux__
 	int result;
+#endif
 /* Perform the selected options. */
 
 	/* -reset. */
@@ -1040,6 +1057,7 @@
 	if (opt_blank && vcterm) 
 		printf("\033[9;%d]", opt_bl_min);
     
+#ifdef __linux__
 	/* -powersave [on|vsync|hsync|powerdown|off] (console) */
 	if (opt_powersave) {
 		char ioctlarg[2];
@@ -1048,6 +1066,7 @@
 		if (ioctl(0,TIOCLINUX,ioctlarg))
 			fprintf(stderr,_("cannot (un)set powersave mode\n"));
 	}
+#endif /* __linux__ */
 
 	/* -powerdown [0-60]. */
 	if (opt_powerdown) {
@@ -1060,6 +1079,7 @@
 		/* nothing */;
 #endif
 
+#ifdef __linux__
 	/* -snap [1-NR_CONS]. */
 	if (opt_snap || opt_append) {
 		FILE *F;
@@ -1095,6 +1115,7 @@
 		if (result != 0)
 			printf(_("klogctl error: %s\n"), strerror(errno));
 	}
+#endif /* __linux__ */
 
 	/* -blength [0-2000] */
 	if (opt_blength && vcterm) {
@@ -1108,6 +1129,7 @@
 
 }
 
+#ifdef __linux__
 static void
 screendump(int vcnum, FILE *F) {
     char infile[MAXPATHLEN];
@@ -1193,6 +1215,7 @@
 	}
     }
 }
+#endif /* __linux__ */
 
 int
 main(int argc, char **argv) {
diff -Naur util-linux-2.12q.orig/mount/Makefile util-linux-2.12q/mount/Makefile
--- util-linux-2.12q.orig/mount/Makefile	2004-12-22 11:32:08.000000000 +0200
+++ util-linux-2.12q/mount/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -10,10 +10,12 @@
 COMPILE = $(CC) -c $(CFLAGS) $(DEFINES)
 LINK = $(CC) $(LDFLAGS)
 
+ifeq "$(KERNEL)" "linux"
 SUID_PROGS = mount umount
 NOSUID_PROGS = swapon losetup
 MAN5 = fstab.5 nfs.5
 MAN8 = mount.8 swapoff.8 swapon.8 umount.8 losetup.8
+endif
 
 ifeq "$(HAVE_PIVOT_ROOT)" "yes"
 NOSUID_PROGS := $(NOSUID_PROGS) pivot_root
diff -Naur util-linux-2.12q.orig/sys-utils/Makefile util-linux-2.12q/sys-utils/Makefile
--- util-linux-2.12q.orig/sys-utils/Makefile	2004-11-15 19:47:47.000000000 +0200
+++ util-linux-2.12q/sys-utils/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -8,22 +8,34 @@
 
 # Where to put man pages?
 
-MAN1=		arch.1 flock.1 readprofile.1
+MAN1=		arch.1 flock.1
 
-MAN8= 		ctrlaltdel.8 cytune.8 dmesg.8 \
-		ipcrm.8 ipcs.8 renice.8 \
-		setsid.8 sln.8 tunelp.8
+MAN8=		ipcrm.8 ipcs.8 renice.8 \
+		setsid.8 sln.8
+
+ifeq "$(KERNEL)" "linux"
+MAN1:= $(MAN1) readprofile.1
+MAN8:= $(MAN8) ctrlaltdel.8 cytune.8 dmesg.8 tunelp.8
+endif
 
 # Where to put binaries?
 # See the "install" rule for the links. . .
 
-BIN=            arch dmesg
+BIN=            arch
+
+ifeq "$(KERNEL)" "linux"
+BIN:= $(BIN) dmesg
+endif
+
+USRBIN=		flock ipcrm ipcs renice setsid
 
-USRBIN=		cytune flock ipcrm ipcs renice setsid
+ifeq "$(KERNEL)" "linux"
+USRBIN:= $(USRBIN) cytune
 
 USRSBIN=	readprofile tunelp
 
 SBIN= 		ctrlaltdel
+endif
 
 NOTMADE=
 
@@ -37,7 +49,7 @@
 endif
 endif
 
-ifeq "$(ARCH)" "intel"
+ifeq "$(KERNEL):$(ARCH)" "linux:intel"
 MAN8:=$(MAN8) rdev.8 ramsize.8 rootflags.8 vidmode.8
 USRSBIN:=$(USRSBIN) rdev
 endif
@@ -87,7 +99,7 @@
 	$(INSTALLBIN) $(BIN) $(BINDIR)
 	$(INSTALLBIN) $(USRBIN) $(USRBINDIR)
 	$(INSTALLBIN) $(USRSBIN) $(USRSBINDIR)
-ifeq "$(ARCH)" "intel"
+ifeq "$(KERNEL):$(ARCH)" "linux:intel"
 	(cd $(USRSBINDIR); ln -sf rdev ramsize)
 	(cd $(USRSBINDIR); ln -sf rdev vidmode)
 	(cd $(USRSBINDIR); ln -sf rdev rootflags)
diff -Naur util-linux-2.12q.orig/fdisk/fdiskbsdlabel.c util-linux-2.12q/fdisk/fdiskbsdlabel.c
--- util-linux-2.12q.orig/fdisk/fdiskbsdlabel.c	2003-07-14 00:12:47.000000000 +0300
+++ util-linux-2.12q/fdisk/fdiskbsdlabel.c	2005-06-11 16:00:56.000000000 +0300
@@ -52,7 +52,6 @@
 #include <errno.h>
 #include "nls.h"
 
-#include <sys/ioctl.h>
 #include <sys/param.h>
 
 #include "common.h"
diff -Naur util-linux-2.12q.orig/sys-utils/ipcrm.c util-linux-2.12q/sys-utils/ipcrm.c
--- util-linux-2.12q.orig/sys-utils/ipcrm.c	2002-04-24 17:42:54.000000000 +0300
+++ util-linux-2.12q/sys-utils/ipcrm.c	2005-06-11 16:00:56.000000000 +0300
@@ -26,7 +26,8 @@
 /* for tolower and isupper */
 #include <ctype.h>
 
-#if defined (__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
+#if (defined (__GNU_LIBRARY__) || defined (__GLIBC__)) && \
+    !defined(_SEM_SEMUN_UNDEFINED)
 /* union semun is defined by including <sys/sem.h> */
 #else
 /* according to X/OPEN we have to define it ourselves */
diff -Naur util-linux-2.12q.orig/sys-utils/ipcs.c util-linux-2.12q/sys-utils/ipcs.c
--- util-linux-2.12q.orig/sys-utils/ipcs.c	2004-03-04 21:28:42.000000000 +0200
+++ util-linux-2.12q/sys-utils/ipcs.c	2005-06-11 16:00:56.000000000 +0300
@@ -78,7 +78,8 @@
 /* The last arg of semctl is a union semun, but where is it defined?
    X/OPEN tells us to define it ourselves, but until recently
    Linux include files would also define it. */
-#if defined (__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
+#if (defined (__GNU_LIBRARY__) || defined (__GLIBC__)) && \
+    !defined(_SEM_SEMUN_UNDEFINED)
 /* union semun is defined by including <sys/sem.h> */
 #else
 /* according to X/OPEN we have to define it ourselves */
@@ -95,7 +96,8 @@
    <linux/ipc.h>, which defines a struct ipc_perm with such fields.
    glibc-1.09 has no support for sysv ipc.
    glibc 2 uses __key, __seq */
-#if defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
+#if (defined (__GNU_LIBRARY__) && __GNU_LIBRARY > 1) || \
+    (defined (__GLIBC__) && __GLIBC__ > 1)
 #define KEY __key
 #else
 #define KEY key
diff -Naur util-linux-2.12q.orig/text-utils/more.c util-linux-2.12q/text-utils/more.c
--- util-linux-2.12q.orig/text-utils/more.c	2004-12-22 12:46:25.000000000 +0200
+++ util-linux-2.12q/text-utils/more.c	2005-06-11 16:00:56.000000000 +0300
@@ -1560,7 +1568,7 @@
     }
     if (feof (file)) {
 	if (!no_intty) {
-#ifndef __linux__
+#ifdef STDIO_S_EOF_SEEN
 				/* No longer in libc 4.5.8. . . */
 	    file->_flags &= ~STDIO_S_EOF_SEEN; /* why doesn't fseek do this ??!!??! */
 #endif
diff -Naur util-linux-2.12q.orig/login-utils/login.c util-linux-2.12q/login-utils/login.c
--- util-linux-2.12q.orig/login-utils/login.c	2004-12-05 04:37:12.000000000 +0200
+++ util-linux-2.12q/login-utils/login.c	2005-06-11 16:00:56.000000000 +0300
@@ -149,7 +150,7 @@
 }
 #endif
 
-#ifndef __linux__
+#if !defined(__GLIBC__)
 #  include <tzfile.h>
 #endif
 #include <lastlog.h>
@@ -202,7 +202,7 @@
  * This bounds the time given to login.  Not a define so it can
  * be patched on machines where it's too small.
  */
-#ifndef __linux__
+#if !defined(__GLIBC__)
 int	timeout = 300;
 #else
 int     timeout = 60;		/* used in cryptocard.c */
diff -Naur util-linux-2.12q.orig/login-utils/simpleinit.c util-linux-2.12q/login-utils/simpleinit.c
--- util-linux-2.12q.orig/login-utils/simpleinit.c	2004-12-15 22:23:25.000000000 +0200
+++ util-linux-2.12q/login-utils/simpleinit.c	2005-06-11 16:00:56.000000000 +0300
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <fcntl.h>
+#include <time.h>
 #include <string.h>
 #include <signal.h>
 #include <errno.h>
