
Author: rmh
Status: sent (http://busybox.net/bugs/view.php?id=395)

Index: busybox/Rules.mak
===================================================================
--- busybox/Rules.mak	(revision 11260)
+++ busybox/Rules.mak	(working copy)
@@ -46,7 +46,7 @@
 
 # What OS are you compiling busybox for?  This allows you to include
 # OS specific things, syscall overrides, etc.
-TARGET_OS=linux
+TARGET_OS=$(shell uname | tr "[A-Z]" "[a-z]" | sed -e "s,/,-,g")
 
 # Select the compiler needed to build binaries for your development system
 HOSTCC    = gcc
Index: busybox/libbb/Makefile.in
===================================================================
--- busybox/libbb/Makefile.in	(revision 11260)
+++ busybox/libbb/Makefile.in	(working copy)
@@ -16,6 +16,12 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
+ifndef top_builddir
+top_builddir=$(CURDIR)
+endif
+
+-include $(top_builddir)/Rules.mak # for $(TARGET_OS)
+
 LIBBB_AR:=libbb.a
 ifndef $(LIBBB_DIR)
 LIBBB_DIR:=$(top_builddir)/libbb/
@@ -30,8 +36,8 @@
 	find_pid_by_name.c find_root_device.c fgets_str.c full_read.c \
 	full_write.c get_last_path_component.c get_line_from_file.c get_ug_id.c \
 	get_terminal_width_height.c hash_fd.c herror_msg.c herror_msg_and_die.c \
-	human_readable.c inet_common.c inode_hash.c interface.c isdirectory.c \
-	kernel_version.c last_char_is.c llist_add_to.c login.c loop.c \
+	human_readable.c inet_common.c inode_hash.c isdirectory.c \
+	kernel_version.c last_char_is.c llist_add_to.c login.c \
 	make_directory.c mode_string.c module_syscalls.c mtab.c mtab_file.c \
 	my_getgrgid.c my_getgrnam.c my_getpwnam.c my_getug.c\
 	my_getpwuid.c obscure.c parse_mode.c parse_number.c perror_msg.c \
@@ -49,6 +55,10 @@
 	warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
 	bb_echo.c
 
+ifeq ($(TARGET_OS), linux)
+LIBBB_SRC+= interface.c loop.c
+endif
+
 LIBBB_OBJS=$(patsubst %.c,$(LIBBB_DIR)%.o, $(LIBBB_SRC))
 
 LIBBB_MSRC0:=$(srcdir)/messages.c
Index: busybox/libbb/procps.c
===================================================================
--- busybox/libbb/procps.c	(revision 11260)
+++ busybox/libbb/procps.c	(working copy)
@@ -12,8 +12,20 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <asm/page.h>
 
+/* get page info */  
+#if defined(__linux__)
+#include <asm/page.h>  
+#elif defined(__FreeBSD_kernel__)
+#include <machine/param.h> 
+#endif  
+ 
+/* dynamic sources are preferred, where available */ 
+#if defined(_SC_PAGE_SHIFT)
+#undef PAGE_SHIFT
+#define PAGE_SHIFT sysconf (_SC_PAGE_SHIFT)
+#endif 
+
 #include "libbb.h"
 
 extern procps_status_t * procps_scan(int save_user_arg0)
Index: busybox/libbb/bb_askpass.c
===================================================================
--- busybox/libbb/bb_askpass.c	(revision 11260)
+++ busybox/libbb/bb_askpass.c	(working copy)
@@ -53,6 +53,9 @@
 	fflush(stdout);
 
 	tcgetattr(STDIN_FILENO, &new);
+#ifndef IUCLC
+#define IUCLC 0
+#endif
 	new.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
 	new.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP);
 	tcsetattr(STDIN_FILENO, TCSANOW, &new);
Index: busybox/libbb/syscalls.c
===================================================================
--- busybox/libbb/syscalls.c	(revision 11260)
+++ busybox/libbb/syscalls.c	(working copy)
@@ -31,7 +31,21 @@
 
 int sysfs(int option, unsigned int fs_index, char * buf)
 {
-	return(syscall(__NR_sysfs, option, fs_index, buf));
+#ifndef __NR_sysfs
+#warning This kernel does not support the sysfs syscall
+#warning -> The sysfs system call is being stubbed out...
+    /* BusyBox was compiled against a kernel that did not support
+     *  the sysfs system call.  To make this application work,
+     *  you will need to recompile with a kernel supporting the
+     *  sysfs system call.
+     */
+    bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
+	    "BusyBox with a kernel supporting the sysfs system call.\n");
+    errno=ENOSYS;
+    return -1;
+#else
+    return(syscall(__NR_sysfs, option, fs_index, buf));
+#endif
 }
 
 int pivot_root(const char * new_root,const char * put_old)
Index: busybox/Makefile
===================================================================
--- busybox/Makefile	(revision 11260)
+++ busybox/Makefile	(working copy)
@@ -39,11 +39,15 @@
 
 include $(top_srcdir)/Rules.mak
 
-DIRS:=applets archival archival/libunarchive coreutils console-tools \
-	debianutils editors findutils init miscutils modutils networking \
-	networking/libiproute networking/udhcp procps loginutils shell \
-	sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
+DIRS:=applets archival archival/libunarchive coreutils debianutils editors \
+	findutils init miscutils networking procps loginutils shell util-linux \
+	e2fsprogs libpwdgrp coreutils/libcoreutils libbb
 
+ifeq ($(TARGET_OS), linux)
+DIRS+=console-tools modutils modutils/obj modutils/obj-2.6 \
+	networking/libiproute networking/udhcp sysklogd
+endif
+
 SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
 
 ifeq ($(strip $(CONFIG_SELINUX)),y)
Index: busybox/loginutils/getty.c
===================================================================
--- busybox/loginutils/getty.c	(revision 11260)
+++ busybox/loginutils/getty.c	(working copy)
@@ -107,11 +107,11 @@
 #undef	TCGETA
 #undef	TCSETA
 #undef	TCSETAW
-#define	termio	termios
 #define	TCGETA	TCGETS
 #define	TCSETA	TCSETS
 #define	TCSETAW	TCSETSW
 #endif
+#define	termio	termios
 
  /*
   * This program tries to not use the standard-i/o library.  This keeps the
@@ -605,8 +605,8 @@
 	 * 5 seconds seems to be a good value.
 	 */
 
-	if (ioctl(0, TCGETA, tp) < 0)
-		error("%s: ioctl: %m", tty);
+	if (tcgetattr (0, tp) == -1)
+		error("%s: tcgetattr: %m", tty);
 
 	/*
 	 * It seems to be a terminal. Set proper protections and ownership. Mode
@@ -666,17 +666,18 @@
 	 * reads will be done in raw mode anyway. Errors will be dealt with
 	 * lateron.
 	 */
-#ifdef __linux__
 	/* flush input and output queues, important for modems! */
-	(void) ioctl(0, TCFLSH, TCIOFLUSH);
-#endif
+	tcflush (0, TCIOFLUSH);
 
 	tp->c_cflag = CS8 | HUPCL | CREAD | speed;
 	if (op->flags & F_LOCAL) {
 		tp->c_cflag |= CLOCAL;
 	}
 
-	tp->c_iflag = tp->c_lflag = tp->c_oflag = tp->c_line = 0;
+	tp->c_iflag = tp->c_lflag = tp->c_oflag = 0;
+#ifdef __linux__
+	tp->c_line = 0;
+#endif
 	tp->c_cc[VMIN] = 1;
 	tp->c_cc[VTIME] = 0;
 
@@ -687,7 +688,7 @@
 		tp->c_cflag |= CRTSCTS;
 #endif
 
-	(void) ioctl(0, TCSETA, tp);
+	tcsetattr (0, TCSANOW, tp);
 
 	/* go to blocking input even in local mode */
 	fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~O_NONBLOCK);
@@ -729,7 +730,7 @@
 	tp->c_iflag |= ISTRIP;		/* enable 8th-bit stripping */
 	vmin = tp->c_cc[VMIN];
 	tp->c_cc[VMIN] = 0;			/* don't block if queue empty */
-	(void) ioctl(0, TCSETA, tp);
+	tcsetattr (0, TCSANOW, tp);
 
 	/*
 	 * Wait for a while, then read everything the modem has said so far and
@@ -742,6 +743,9 @@
 		for (bp = buf; bp < buf + nread; bp++) {
 			if (isascii(*bp) && isdigit(*bp)) {
 				if ((speed = bcode(bp))) {
+#ifndef CBAUD
+#define CBAUD 0
+#endif
 					tp->c_cflag &= ~CBAUD;
 					tp->c_cflag |= speed;
 				}
@@ -753,7 +757,7 @@
 
 	tp->c_iflag = iflag;
 	tp->c_cc[VMIN] = vmin;
-	(void) ioctl(0, TCSETA, tp);
+	tcsetattr (0, TCSANOW, tp);
 }
 
 /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */
@@ -773,7 +777,7 @@
 	baud_index = (baud_index + 1) % op->numspeed;
 	tp->c_cflag &= ~CBAUD;
 	tp->c_cflag |= op->speeds[baud_index];
-	(void) ioctl(0, TCSETA, tp);
+	tcsetattr (0, TCSANOW, tp);
 }
 
 /* get_logname - get user name, establish parity, speed, erase, kill, eol */
@@ -800,7 +804,7 @@
 	/* Flush pending input (esp. after parsing or switching the baud rate). */
 
 	(void) sleep(1);
-	(void) ioctl(0, TCFLSH, TCIFLUSH);
+	tcflush (0, TCIFLUSH);
 
 	/* Prompt for and read a login name. */
 
@@ -899,7 +903,9 @@
 	tp->c_cc[VQUIT] = DEF_QUIT;	/* default quit */
 	tp->c_cc[VEOF] = DEF_EOF;	/* default EOF character */
 	tp->c_cc[VEOL] = DEF_EOL;
+#ifdef VSWTC
 	tp->c_cc[VSWTC] = DEF_SWITCH;	/* default switch character */
+#endif
 
 	/* Account for special characters seen in input. */
 
@@ -930,9 +936,15 @@
 	/* Account for upper case without lower case. */
 
 	if (cp->capslock) {
+#ifdef IUCLC
 		tp->c_iflag |= IUCLC;
+#endif
+#ifdef XCASE
 		tp->c_lflag |= XCASE;
+#endif
+#ifdef OLCUC
 		tp->c_oflag |= OLCUC;
+#endif
 	}
 	/* Optionally enable hardware flow control */
 
@@ -943,8 +955,8 @@
 
 	/* Finally, make the new settings effective */
 
-	if (ioctl(0, TCSETA, tp) < 0)
-		error("%s: ioctl: TCSETA: %m", op->tty);
+	if (tcsetattr (0, TCSANOW, tp) == -1)
+		error("%s: tcsetattr: %m", op->tty);
 }
 
 /* caps_lock - string contains upper case without lower case */
Index: busybox/sysdeps/gnu-kfreebsd/defconfig
===================================================================
--- busybox/sysdeps/gnu-kfreebsd/defconfig	(revision 0)
+++ busybox/sysdeps/gnu-kfreebsd/defconfig	(revision 0)
@@ -0,0 +1,423 @@
+#
+# Automatically generated make config: don't edit
+#
+HAVE_DOT_CONFIG=y
+
+#
+# General Configuration
+#
+# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set
+CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y
+# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
+CONFIG_FEATURE_VERBOSE_USAGE=y
+# CONFIG_FEATURE_INSTALLER is not set
+# CONFIG_LOCALE_SUPPORT is not set
+# CONFIG_FEATURE_DEVFS is not set
+CONFIG_FEATURE_DEVPTS=y
+# CONFIG_FEATURE_CLEAN_UP is not set
+# CONFIG_FEATURE_SUID is not set
+# CONFIG_SELINUX is not set
+
+#
+# Build Options
+#
+# CONFIG_STATIC is not set
+# CONFIG_LFS is not set
+# USING_CROSS_COMPILER is not set
+EXTRA_CFLAGS_OPTIONS=""
+
+#
+# Installation Options
+#
+# CONFIG_INSTALL_NO_USR is not set
+PREFIX="./_install"
+
+#
+# Archival Utilities
+#
+# CONFIG_AR is not set
+CONFIG_BUNZIP2=y
+# CONFIG_CPIO is not set
+# CONFIG_DPKG is not set
+# CONFIG_DPKG_DEB is not set
+CONFIG_GUNZIP=y
+# CONFIG_FEATURE_GUNZIP_UNCOMPRESS is not set
+CONFIG_GZIP=y
+# CONFIG_RPM2CPIO is not set
+# CONFIG_RPM is not set
+CONFIG_TAR=y
+CONFIG_FEATURE_TAR_CREATE=y
+CONFIG_FEATURE_TAR_BZIP2=y
+# CONFIG_FEATURE_TAR_FROM is not set
+CONFIG_FEATURE_TAR_GZIP=y
+# CONFIG_FEATURE_TAR_COMPRESS is not set
+CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY=y
+CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
+# CONFIG_FEATURE_TAR_LONG_OPTIONS is not set
+# CONFIG_UNCOMPRESS is not set
+CONFIG_UNZIP=y
+
+#
+# Common options for cpio and tar
+#
+# CONFIG_FEATURE_UNARCHIVE_TAPE is not set
+
+#
+# Coreutils
+#
+CONFIG_BASENAME=y
+# CONFIG_CAL is not set
+CONFIG_CAT=y
+CONFIG_CHGRP=y
+CONFIG_CHMOD=y
+CONFIG_CHOWN=y
+CONFIG_CHROOT=y
+CONFIG_CMP=y
+CONFIG_CP=y
+CONFIG_CUT=y
+CONFIG_DATE=y
+CONFIG_FEATURE_DATE_ISOFMT=y
+CONFIG_DD=y
+CONFIG_DF=y
+CONFIG_DIRNAME=y
+# CONFIG_DOS2UNIX is not set
+CONFIG_DU=y
+CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K=y
+CONFIG_ECHO=y
+CONFIG_FEATURE_FANCY_ECHO=y
+CONFIG_ENV=y
+CONFIG_EXPR=y
+CONFIG_FALSE=y
+# CONFIG_FOLD is not set
+CONFIG_HEAD=y
+# CONFIG_FEATURE_FANCY_HEAD is not set
+# CONFIG_HOSTID is not set
+CONFIG_ID=y
+CONFIG_INSTALL=y
+# CONFIG_LENGTH is not set
+CONFIG_LN=y
+# CONFIG_LOGNAME is not set
+CONFIG_LS=y
+CONFIG_FEATURE_LS_FILETYPES=y
+CONFIG_FEATURE_LS_FOLLOWLINKS=y
+CONFIG_FEATURE_LS_RECURSIVE=y
+CONFIG_FEATURE_LS_SORTFILES=y
+CONFIG_FEATURE_LS_TIMESTAMPS=y
+CONFIG_FEATURE_LS_USERNAME=y
+CONFIG_FEATURE_LS_COLOR=y
+# CONFIG_MD5SUM is not set
+CONFIG_MKDIR=y
+# CONFIG_MKFIFO is not set
+CONFIG_MKNOD=y
+CONFIG_MV=y
+# CONFIG_OD is not set
+# CONFIG_PRINTF is not set
+CONFIG_PWD=y
+# CONFIG_REALPATH is not set
+CONFIG_RM=y
+CONFIG_RMDIR=y
+# CONFIG_SEQ is not set
+# CONFIG_SHA1SUM is not set
+CONFIG_SLEEP=y
+# CONFIG_FEATURE_FANCY_SLEEP is not set
+CONFIG_SORT=y
+# CONFIG_STTY is not set
+CONFIG_SYNC=y
+CONFIG_TAIL=y
+CONFIG_FEATURE_FANCY_TAIL=y
+CONFIG_TEE=y
+CONFIG_FEATURE_TEE_USE_BLOCK_IO=y
+CONFIG_TEST=y
+
+#
+# test (forced enabled for use with shell)
+#
+CONFIG_TOUCH=y
+CONFIG_TR=y
+CONFIG_TRUE=y
+CONFIG_TTY=y
+CONFIG_UNAME=y
+CONFIG_UNIQ=y
+CONFIG_USLEEP=y
+# CONFIG_UUDECODE is not set
+# CONFIG_UUENCODE is not set
+# CONFIG_WATCH is not set
+CONFIG_WC=y
+# CONFIG_WHO is not set
+CONFIG_WHOAMI=y
+CONFIG_YES=y
+
+#
+# Common options for cp and mv
+#
+CONFIG_FEATURE_PRESERVE_HARDLINKS=y
+
+#
+# Common options for ls and more
+#
+CONFIG_FEATURE_AUTOWIDTH=y
+
+#
+# Common options for df, du, ls
+#
+CONFIG_FEATURE_HUMAN_READABLE=y
+
+#
+# Console Utilities
+#
+# CONFIG_CHVT is not set
+# CONFIG_CLEAR is not set
+# CONFIG_DEALLOCVT is not set
+# CONFIG_DUMPKMAP is not set
+# CONFIG_LOADFONT is not set
+# CONFIG_LOADKMAP is not set
+# CONFIG_OPENVT is not set
+# CONFIG_RESET is not set
+# CONFIG_SETKEYCODES is not set
+
+#
+# Debian Utilities
+#
+CONFIG_MKTEMP=y
+# CONFIG_PIPE_PROGRESS is not set
+CONFIG_READLINK=y
+# CONFIG_RUN_PARTS is not set
+# CONFIG_START_STOP_DAEMON is not set
+CONFIG_WHICH=y
+
+#
+# Editors
+#
+# CONFIG_AWK is not set
+# CONFIG_PATCH is not set
+CONFIG_SED=y
+CONFIG_VI=y
+CONFIG_FEATURE_VI_COLON=y
+CONFIG_FEATURE_VI_YANKMARK=y
+CONFIG_FEATURE_VI_SEARCH=y
+CONFIG_FEATURE_VI_USE_SIGNALS=y
+CONFIG_FEATURE_VI_DOT_CMD=y
+CONFIG_FEATURE_VI_READONLY=y
+CONFIG_FEATURE_VI_SETOPTS=y
+CONFIG_FEATURE_VI_SET=y
+CONFIG_FEATURE_VI_WIN_RESIZE=y
+CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
+
+#
+# Finding Utilities
+#
+CONFIG_FIND=y
+CONFIG_FEATURE_FIND_MTIME=y
+CONFIG_FEATURE_FIND_PERM=y
+CONFIG_FEATURE_FIND_TYPE=y
+CONFIG_FEATURE_FIND_XDEV=y
+# CONFIG_FEATURE_FIND_NEWER is not set
+# CONFIG_FEATURE_FIND_INUM is not set
+CONFIG_GREP=y
+CONFIG_FEATURE_GREP_EGREP_ALIAS=y
+CONFIG_FEATURE_GREP_FGREP_ALIAS=y
+CONFIG_FEATURE_GREP_CONTEXT=y
+CONFIG_XARGS=y
+# CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION is not set
+CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y
+CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y
+CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
+
+#
+# Init Utilities
+#
+CONFIG_INIT=y
+CONFIG_FEATURE_USE_INITTAB=y
+CONFIG_FEATURE_INITRD=y
+# CONFIG_FEATURE_INIT_COREDUMPS is not set
+CONFIG_FEATURE_EXTRA_QUIET=y
+CONFIG_HALT=y
+CONFIG_POWEROFF=y
+CONFIG_REBOOT=y
+# CONFIG_MESG is not set
+
+#
+# Login/Password Management Utilities
+#
+# CONFIG_USE_BB_PWD_GRP is not set
+# CONFIG_ADDGROUP is not set
+# CONFIG_DELGROUP is not set
+# CONFIG_ADDUSER is not set
+# CONFIG_DELUSER is not set
+# CONFIG_GETTY is not set
+# CONFIG_LOGIN is not set
+# CONFIG_PASSWD is not set
+# CONFIG_SU is not set
+# CONFIG_SULOGIN is not set
+# CONFIG_VLOCK is not set
+
+#
+# Miscellaneous Utilities
+#
+# CONFIG_ADJTIMEX is not set
+# CONFIG_CROND is not set
+# CONFIG_CRONTAB is not set
+# CONFIG_DC is not set
+# CONFIG_DEVFSD is not set
+# CONFIG_LAST is not set
+# CONFIG_HDPARM is not set
+# CONFIG_MAKEDEVS is not set
+# CONFIG_MT is not set
+# CONFIG_RX is not set
+CONFIG_STRINGS=y
+CONFIG_TIME=y
+# CONFIG_WATCHDOG is not set
+
+#
+# Linux Module Utilities
+#
+# CONFIG_INSMOD is not set
+# CONFIG_LSMOD is not set
+# CONFIG_MODPROBE is not set
+# CONFIG_RMMOD is not set
+
+#
+# Networking Utilities
+#
+# CONFIG_FEATURE_IPV6 is not set
+# CONFIG_ARPING is not set
+# CONFIG_FTPGET is not set
+# CONFIG_FTPPUT is not set
+CONFIG_HOSTNAME=y
+# CONFIG_HTTPD is not set
+# CONFIG_IFCONFIG is not set
+# CONFIG_FEATURE_IFCONFIG_STATUS is not set
+# CONFIG_FEATURE_IFCONFIG_SLIP is not set
+# CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set
+# CONFIG_FEATURE_IFCONFIG_HW is not set
+# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set
+# CONFIG_IFUPDOWN is not set
+# CONFIG_INETD is not set
+# CONFIG_IP is not set
+# CONFIG_IPCALC is not set
+# CONFIG_IPADDR is not set
+# CONFIG_IPLINK is not set
+# CONFIG_IPROUTE is not set
+# CONFIG_IPTUNNEL is not set
+# CONFIG_NAMEIF is not set
+# CONFIG_NC is not set
+# CONFIG_NETSTAT is not set
+# CONFIG_NSLOOKUP is not set
+# CONFIG_PING is not set
+CONFIG_FEATURE_FANCY_PING=y
+# CONFIG_ROUTE is not set
+# CONFIG_TELNET is not set
+# CONFIG_TELNETD is not set
+# CONFIG_TFTP is not set
+# CONFIG_TRACEROUTE is not set
+# CONFIG_VCONFIG is not set
+CONFIG_WGET=y
+CONFIG_FEATURE_WGET_STATUSBAR=y
+CONFIG_FEATURE_WGET_AUTHENTICATION=y
+# CONFIG_FEATURE_WGET_IP6_LITERAL is not set
+
+#
+# udhcp Server/Client
+#
+# CONFIG_UDHCPD is not set
+# CONFIG_UDHCPC is not set
+
+#
+# Process Utilities
+#
+CONFIG_FREE=y
+CONFIG_KILL=y
+CONFIG_KILLALL=y
+CONFIG_PIDOF=y
+CONFIG_PS=y
+# CONFIG_RENICE is not set
+# CONFIG_TOP is not set
+# CONFIG_UPTIME is not set
+# CONFIG_SYSCTL is not set
+
+#
+# Another Bourne-like Shell
+#
+CONFIG_FEATURE_SH_IS_ASH=y
+# CONFIG_FEATURE_SH_IS_HUSH is not set
+# CONFIG_FEATURE_SH_IS_LASH is not set
+# CONFIG_FEATURE_SH_IS_MSH is not set
+# CONFIG_FEATURE_SH_IS_NONE is not set
+CONFIG_ASH=y
+
+#
+# Ash Shell Options
+#
+CONFIG_ASH_JOB_CONTROL=y
+CONFIG_ASH_ALIAS=y
+CONFIG_ASH_MATH_SUPPORT=y
+CONFIG_ASH_MATH_SUPPORT_64=y
+# CONFIG_ASH_GETOPTS is not set
+# CONFIG_ASH_CMDCMD is not set
+# CONFIG_ASH_MAIL is not set
+CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
+# CONFIG_ASH_RANDOM_SUPPORT is not set
+# CONFIG_HUSH is not set
+# CONFIG_LASH is not set
+# CONFIG_MSH is not set
+
+#
+# Bourne Shell Options
+#
+# CONFIG_FEATURE_SH_EXTRA_QUIET is not set
+# CONFIG_FEATURE_SH_STANDALONE_SHELL is not set
+CONFIG_FEATURE_COMMAND_EDITING=y
+CONFIG_FEATURE_COMMAND_HISTORY=15
+CONFIG_FEATURE_COMMAND_SAVEHISTORY=y
+CONFIG_FEATURE_COMMAND_TAB_COMPLETION=y
+# CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION is not set
+CONFIG_FEATURE_SH_FANCY_PROMPT=y
+
+#
+# System Logging Utilities
+#
+# CONFIG_SYSLOGD is not set
+CONFIG_FEATURE_ROTATE_LOGFILE=y
+# CONFIG_FEATURE_REMOTE_LOG is not set
+# CONFIG_FEATURE_IPC_SYSLOG is not set
+# CONFIG_KLOGD is not set
+# CONFIG_LOGGER is not set
+
+#
+# Linux System Utilities
+#
+# CONFIG_DMESG is not set
+# CONFIG_FBSET is not set
+# CONFIG_FDFLUSH is not set
+# CONFIG_FDFORMAT is not set
+# CONFIG_FDISK is not set
+# CONFIG_FREERAMDISK is not set
+# CONFIG_FSCK_MINIX is not set
+# CONFIG_MKFS_MINIX is not set
+# CONFIG_GETOPT is not set
+CONFIG_HEXDUMP=y
+# CONFIG_HWCLOCK is not set
+# CONFIG_IPCRM is not set
+# CONFIG_IPCS is not set
+# CONFIG_LOSETUP is not set
+# CONFIG_MKSWAP is not set
+CONFIG_MORE=y
+CONFIG_FEATURE_USE_TERMIOS=y
+CONFIG_PIVOT_ROOT=y
+# CONFIG_RDATE is not set
+# CONFIG_SWAPONOFF is not set
+# CONFIG_MOUNT is not set
+# CONFIG_NFSMOUNT is not set
+# CONFIG_UMOUNT is not set
+# CONFIG_FEATURE_MOUNT_FORCE is not set
+
+#
+# Common options for mount/umount
+#
+CONFIG_FEATURE_MOUNT_LOOP=y
+# CONFIG_FEATURE_MTAB_SUPPORT is not set
+
+#
+# Debugging Options
+#
+# CONFIG_DEBUG is not set
Index: busybox/sysdeps/gnu-kfreebsd/Config.in
===================================================================
--- busybox/sysdeps/gnu-kfreebsd/Config.in	(revision 0)
+++ busybox/sysdeps/gnu-kfreebsd/Config.in	(revision 0)
@@ -0,0 +1,301 @@
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+mainmenu "BusyBox Configuration"
+
+config HAVE_DOT_CONFIG
+	bool
+	default y
+
+menu "General Configuration"
+
+choice
+	prompt "Buffer allocation policy"
+	default CONFIG_FEATURE_BUFFERS_USE_MALLOC
+	help
+	  There are 3 ways BusyBox can handle buffer allocations:
+	  - Use malloc. This costs code size for the call to xmalloc.
+	  - Put them on stack. For some very small machines with limited stack
+	    space, this can be deadly.  For most folks, this works just fine.
+	  - Put them in BSS. This works beautifully for computers with a real
+	    MMU (and OS support), but wastes runtime RAM for uCLinux. This
+	    behavior was the only one available for BusyBox versions 0.48 and
+	    earlier.
+
+config CONFIG_FEATURE_BUFFERS_USE_MALLOC
+	bool "Allocate with Malloc"
+
+config CONFIG_FEATURE_BUFFERS_GO_ON_STACK
+	bool "Allocate on the Stack"
+
+config CONFIG_FEATURE_BUFFERS_GO_IN_BSS
+	bool "Allocate in the .bss section"
+
+endchoice
+
+config CONFIG_FEATURE_VERBOSE_USAGE
+	bool "Show verbose applet usage messages"
+	default n
+	help
+	  All BusyBox applets will show more verbose help messages when
+	  busybox is invoked with --help.  This will add a lot of text to the
+	  busybox binary.  In the default configuration, this will add about
+	  13k, but it can add much more depending on your configuration.
+
+config CONFIG_FEATURE_INSTALLER
+	bool "Support --install [-s] to install applet links at runtime"
+	default n
+	help
+	  Enable 'busybox --install [-s]' support.  This will allow you to use
+	  busybox at runtime to create hard links or symlinks for all the
+	  applets that are compiled into busybox.  This feature requires the
+	  /proc filesystem.
+
+config CONFIG_LOCALE_SUPPORT
+	bool "Enable locale support (system needs locale for this to work)"
+	default n
+	help
+	  Enable this if your system has locale support and you would like
+	  busybox to support locale settings.
+
+config CONFIG_FEATURE_DEVFS
+	bool "Support for devfs"
+	default n
+	help
+	  Enable if you want BusyBox to work with devfs.
+
+config CONFIG_FEATURE_DEVPTS
+	bool "Use the devpts filesystem for Unix98 PTYs"
+	default y if CONFIG_FEATURE_DEVFS
+	help
+	  Enable if you want BusyBox to use Unix98 PTY support. If enabled,
+	  busybox will use /dev/ptmx for the master side of the pseudoterminal
+	  and /dev/pts/<number> for the slave side.  Otherwise, BSD style
+	  /dev/ttyp<number> will be used. To use this option, you should have
+	  devpts or devfs mounted.
+
+config CONFIG_FEATURE_CLEAN_UP
+	bool "Clean up all memory before exiting (usually not needed)"
+	default n
+	help
+	  As a size optimization, busybox by default does not cleanup memory
+	  that is dynamically allocated or close files before exiting. This
+	  saves space and is usually not needed since the OS will clean up for
+	  us.  Don't enable this unless you have a really good reason to clean
+	  things up manually.
+
+config CONFIG_FEATURE_SUID
+	bool "Support for SUID/SGID handling"
+	default n
+	help
+	  Support SUID and SGID binaries.
+
+config CONFIG_FEATURE_SUID_CONFIG
+	bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
+	default n if CONFIG_FEATURE_SUID
+	depends on CONFIG_FEATURE_SUID
+	help
+	  Allow the SUID / SGID state of an applet to be determined runtime by
+	  checking /etc/busybox.conf.  The format of this file is as follows:
+
+	  <applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)
+
+	  An example might help:
+
+	  [SUID]
+	  su = ssx root.0 # applet su can be run by anyone and runs with euid=0/egid=0
+	  su = ssx        # exactly the same
+
+	  mount = sx- root.disk # applet mount can be run by root and members of group disk
+	                        # and runs with euid=0
+
+	  cp = --- # disable applet cp for everyone
+
+	  The file has to be owned by user root, group root and has to be
+	  writeable only by root:
+	  	(chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
+	  The busybox executable has to be owned by user root, group
+	  root and has to be setuid root for this to work:
+	  	(chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
+
+	  Robert 'sandman' Griebl has more information here:
+	  <url: http://www.softforge.de/bb/suid.html >.
+
+config CONFIG_FEATURE_SUID_CONFIG_QUIET
+	bool "Suppress warning message if /etc/busybox.conf is not readable"
+	default n
+	depends on CONFIG_FEATURE_SUID_CONFIG
+	help
+	  /etc/busybox.conf should be readable by the user needing the SUID, check
+	  this option to avoid users to be notified about missing permissions.
+
+config CONFIG_SELINUX
+	bool "Support NSA Security Enhanced Linux"
+	default n
+	help
+	  Enable support for SE Linux in applets ls, ps, and id.  Also provide
+	  the option of compiling in SE Linux applets.
+
+	  If you do not have a complete SE Linux Full Userland installed, this
+	  stuff will not compile.  Go visit
+		http://www.nsa.gov/selinux/index.html
+	  to download the necessary stuff to allow busybox to compile with this
+	  option enabled.
+
+	  Most people will leave this set to 'N'.
+
+endmenu
+
+menu 'Build Options'
+
+config CONFIG_STATIC
+	bool "Build BusyBox as a static binary (no shared libs)"
+	default n
+	help
+	  If you want to build a static BusyBox binary, which does not
+	  use or require any shared libraries, then enable this option.
+	  This can cause BusyBox to be considerably larger, so you should
+	  leave this option false unless you have a good reason (i.e.
+	  your target platform does not support shared libraries, or
+	  you are building an initrd which doesn't need anything but
+	  BusyBox, etc).
+
+	  Most people will leave this set to 'N'.
+
+config CONFIG_LFS
+	bool "Build with Large File Support (for accessing files > 2 GB)"
+	default n
+	select FDISK_SUPPORT_LARGE_DISKS
+	help
+	  If you want to build BusyBox with large file support, then enable
+	  this option.  This will have no effect if your kernel or your C
+	  library lacks large file support for large files.  Some of the
+	  programs that can benefit from large file support include dd, gzip,
+	  cp, mount, tar, and many others.  If you want to access files larger
+	  than 2 Gigabytes, enable this option.  Otherwise, leave it set to 'N'.
+
+config USING_CROSS_COMPILER
+	bool "Do you want to build BusyBox with a Cross Compiler?"
+	default n
+	help
+	  Do you want to build BusyBox with a Cross Compiler?  If so,
+	  then enable this option.  Otherwise leave it set to 'N'.
+
+config CROSS_COMPILER_PREFIX
+	string "Cross Compiler prefix"
+	default "/usr/i386-linux-uclibc/bin/i386-uclibc-"
+	depends on USING_CROSS_COMPILER
+	help
+	  If you want to build BusyBox with a cross compiler, then you
+	  will need to set this to the cross-compiler prefix.  For example,
+	  if my cross-compiler is /usr/i386-linux-uclibc/bin/i386-uclibc-gcc
+	  then I would enter '/usr/i386-linux-uclibc/bin/i386-uclibc-' here,
+	  which will ensure the correct compiler is used.
+
+config EXTRA_CFLAGS_OPTIONS
+	string "Any extra CFLAGS options for the compiler?"
+	default ""
+	help
+	  Do you want to pass any extra CFLAGS options to the compiler as
+	  you build BusyBox? If so, this is the option for you...  For example,
+	  if you want to add some simple compiler switches (like -march=i686),
+	  or check for warnings using -Werror, just those options here.
+
+endmenu
+
+menu 'Installation Options'
+
+config CONFIG_INSTALL_NO_USR
+	bool "Don't use /usr"
+	default n
+	help
+	  Disable use of /usr. Don't activate this option if you don't know
+	  that you really want this behaviour.
+
+config PREFIX
+	string "BusyBox installation prefix"
+	default "./_install"
+	help
+	  Define your directory to install BusyBox files/subdirs in.
+
+
+
+endmenu
+
+source archival/Config.in
+source coreutils/Config.in
+source console-tools/Config.in
+source debianutils/Config.in
+source e2fsprogs/Config.in
+source editors/Config.in
+source findutils/Config.in
+source init/Config.in
+source loginutils/Config.in
+source miscutils/Config.in
+source modutils/Config.in
+source networking/Config.in
+source procps/Config.in
+source shell/Config.in
+source sysklogd/Config.in
+source util-linux/Config.in
+
+menu 'Debugging Options'
+
+config CONFIG_DEBUG
+	bool "Build BusyBox with Debugging symbols"
+	default n
+	help
+	  Say Y here if you wish to compile BusyBox with debugging symbols.
+	  This will allow you to use a debugger to examine BusyBox internals
+	  while applets are running.  This increases the size of the binary
+	  considerably and should only be used when doing development.
+	  If you are doing development and want to debug BusyBox, answer Y.
+
+	  Most people should answer N.
+
+choice
+	prompt "Additional debugging library"
+	default CONFIG_NO_DEBUG_LIB
+	depends on CONFIG_DEBUG
+	help
+	  Using an additional debugging library will make BusyBox become
+	  considerable larger and will cause it to run more slowly.  You
+	  should always leave this option disabled for production use.
+
+	  dmalloc support:
+	  ----------------
+	  This enables compiling with dmalloc ( http://dmalloc.com/ )
+	  which is an excellent public domain mem leak and malloc problem
+	  detector.  To enable dmalloc, before running busybox you will
+	  want to properly set your environment, for example:
+	    export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
+	  The 'debug=' value is generated using the following command
+	    dmalloc -p log-stats -p log-non-free -p log-bad-space -p log-elapsed-time \
+	       -p check-fence -p check-heap -p check-lists -p check-blank \
+	       -p check-funcs -p realloc-copy -p allow-free-null
+
+	  Electric-fence support:
+	  -----------------------
+	  This enables compiling with Electric-fence support.  Electric
+	  fence is another very useful malloc debugging library which uses
+	  your computer's virtual memory hardware to detect illegal memory
+	  accesses.  This support will make BusyBox be considerable larger
+	  and run slower, so you should leave this option disabled unless
+	  you are hunting a hard to find memory problem.
+
+
+config CONFIG_NO_DEBUG_LIB
+	bool "None"
+
+config CONFIG_DMALLOC
+	bool "Dmalloc"
+
+config CONFIG_EFENCE
+	bool "Electric-fence"
+
+endchoice
+
+
+endmenu
Index: busybox/init/init.c
===================================================================
--- busybox/init/init.c	(revision 11260)
+++ busybox/init/init.c	(working copy)
@@ -166,14 +166,28 @@
 #else
 #define MAYBE_CONSOLE	CONSOLE
 #endif
+
+#if !defined(RB_HALT_SYSTEM) && defined(RB_HALT)
+#define RB_HALT_SYSTEM RB_HALT
+#endif
+
+#if defined(__linux__)
 #ifndef RB_HALT_SYSTEM
 static const int RB_HALT_SYSTEM = 0xcdef0123;
+#endif
+#ifndef RB_ENABLE_CAD
 static const int RB_ENABLE_CAD = 0x89abcdef;
+#endif
+#ifndef RB_DISABLE_CAD
 static const int RB_DISABLE_CAD = 0;
-
+#endif
+#ifndef RB_POWER_OFF
 #define RB_POWER_OFF    0x4321fedc
+#endif
+#ifndef RB_AUTOBOOT
 static const int RB_AUTOBOOT = 0x01234567;
 #endif
+#endif
 
 static const char * const environment[] = {
 	"HOME=/",
@@ -287,10 +301,19 @@
 	tty.c_cc[VSTOP] = 19;	/* C-s */
 	tty.c_cc[VSUSP] = 26;	/* C-z */
 
+/* c_line is not POSIX */
+#ifdef __linux__
 	/* use line dicipline 0 */
 	tty.c_line = 0;
+#endif
 
 	/* Make it be sane */
+#ifndef CBAUD
+#define CBAUD 0
+#endif
+#ifndef CBAUDEX
+#define CBAUDEX 0
+#endif
 	tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD;
 	tty.c_cflag |= CREAD | HUPCL | CLOCAL;
 
@@ -313,6 +336,7 @@
    Units are kBytes to avoid overflow on 4GB machines */
 static unsigned int check_free_memory(void)
 {
+#ifdef __linux__
 	struct sysinfo info;
 	unsigned int result, u, s = 10;
 
@@ -336,6 +360,9 @@
 	} else {
 		return(result * u);
 	}
+#else
+	return -1;
+#endif
 }
 #endif /* CONFIG_FEATURE_INIT_SWAPON */
 
@@ -360,10 +387,13 @@
 #endif
 	} else {
 		/* 2.2 kernels: identify the real console backend and try to use it */
+#ifdef TIOCGSERIAL
 		if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
 			/* this is a serial console */
 			snprintf(console, sizeof(console) - 1, SC_FORMAT, sr.line);
-		} else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
+		} else
+#endif
+		if (ioctl(0, VT_GETSTATE, &vt) == 0) {
 			/* this is linux virtual tty */
 			snprintf(console, sizeof(console) - 1, VC_FORMAT, vt.v_active);
 		} else {
@@ -388,6 +418,7 @@
 	} else {
 		s = getenv("TERM");
 		/* check for serial console */
+#if defined(__linux__) && defined(TIOCGSERIAL)
 		if (ioctl(fd, TIOCGSERIAL, &sr) == 0) {
 			/* Force the TERM setting to vt102 for serial console --
 			 * if TERM is set to linux (the default) */
@@ -396,10 +427,16 @@
 #ifndef CONFIG_SYSLOGD
 			log_console = console;
 #endif
-		} else {
-			if (s == NULL)
+		} else
+#endif
+		if (s == NULL)
+#if defined(__linux__)
 				putenv("TERM=linux");
-		}
+#elif defined(__FreeBSD_kernel__)
+				putenv("TERM=cons25");
+#else
+				putenv("TERM=dumb");
+#endif
 		close(fd);
 	}
 	messageD(LOG, "console=%s", console);
@@ -714,8 +751,10 @@
 	sigaddset(&block_signals, SIGTSTP);
 	sigprocmask(SIG_BLOCK, &block_signals, NULL);
 
+#ifdef RB_ENABLE_CAD
 	/* Allow Ctrl-Alt-Del to reboot system. */
 	init_reboot(RB_ENABLE_CAD);
+#endif
 
 	message(CONSOLE | LOG, "The system is going down NOW !!");
 	sync();
@@ -1121,10 +1160,12 @@
 	signal(SIGSTOP, stop_handler);
 	signal(SIGTSTP, stop_handler);
 
+#ifdef RB_DISABLE_CAD
 	/* Turn off rebooting via CTL-ALT-DEL -- we get a
 	 * SIGINT on CAD so we can shut things down gracefully... */
 	init_reboot(RB_DISABLE_CAD);
 #endif
+#endif
 
 	/* Figure out where the default console should be */
 	console_init();
Index: busybox/procps/free.c
===================================================================
--- busybox/procps/free.c	(revision 11260)
+++ busybox/procps/free.c	(working copy)
@@ -29,6 +29,7 @@
 
 extern int free_main(int argc, char **argv)
 {
+#ifdef __linux__
 	struct sysinfo info;
 	sysinfo(&info);
 
@@ -80,5 +81,8 @@
 			info.freeram+info.freeswap);
 #endif
 	return EXIT_SUCCESS;
+#else
+	return EXIT_FAILURE;
+#endif
 }
 
Index: busybox/procps/top.c
===================================================================
--- busybox/procps/top.c	(revision 11260)
+++ busybox/procps/top.c	(working copy)
@@ -33,8 +33,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/ioctl.h>
-/* get page info */
-#include <asm/page.h>
 #include "busybox.h"
 
 //#define FEATURE_CPU_USAGE_PERCENTAGE  /* + 2k */
Index: busybox/procps/uptime.c
===================================================================
--- busybox/procps/uptime.c	(revision 11260)
+++ busybox/procps/uptime.c	(working copy)
@@ -35,7 +35,9 @@
 #include <stdlib.h>
 #include "busybox.h"
 
+#ifndef FSHIFT
 static const int FSHIFT = 16;              /* nr of bits of precision */
+#endif
 #define FIXED_1         (1<<FSHIFT)     /* 1.0 as fixed-point */
 #define LOAD_INT(x) ((x) >> FSHIFT)
 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
Index: busybox/util-linux/mkswap.c
===================================================================
--- busybox/util-linux/mkswap.c	(revision 11260)
+++ busybox/util-linux/mkswap.c	(working copy)
@@ -42,8 +42,23 @@
 #include <stdlib.h>
 #include <sys/ioctl.h>			/* for _IO */
 #include <sys/utsname.h>
-#include <asm/page.h>			/* for PAGE_SIZE and PAGE_SHIFT */
-				/* we also get PAGE_SIZE via getpagesize() */
+
+/* get page info */ 
+#if defined(__linux__)
+#include <asm/page.h> 
+#elif defined(__FreeBSD_kernel__)
+#include <machine/param.h>
+#endif 
+ 
+/* dynamic sources are preferred, where available */
+#if defined(__GLIBC__)
+#undef PAGE_SIZE
+#define PAGE_SIZE getpagesize ()
+#elif defined(_SC_PAGE_SIZE)
+#undef PAGE_SIZE
+#define PAGE_SIZE sysconf (_SC_PAGE_SIZE)
+#endif 
+
 #include "busybox.h"
 
 #ifndef _IO
Index: busybox/util-linux/swaponoff.c
===================================================================
--- busybox/util-linux/swaponoff.c	(revision 11260)
+++ busybox/util-linux/swaponoff.c	(working copy)
@@ -54,7 +54,11 @@
 	}
 
 	if (whichApp == SWAPON_APP)
+#ifdef __linux__
 		status = swapon(device, 0);
+#else
+		status = swapon(device);
+#endif
 	else
 		status = swapoff(device);
 
