On Sat, Apr 17, 2010 at 9:48 PM, Nguyen Thai Ngoc Duy <[email protected]> wrote: > How about general features that do not depend on any applets? There > are some features that won't be supported on Windows, should it be > "depends on !PLATFORM_MINGW32" or "depends on PLATFORM_POSIX" for > them?
Hi, I attach the solution I have been working on wrt. selecting appropriate applets for Hurd. Though it's work in progress, you may want to have a look and reuse some of it. In short: * the target OS is detected using preprocessor macros * each OS defines HAVE_* on os/<system>/Config.in to enable the relevant applets/options I guess we might want to merge our two approaches: for instance your TARGET_MINGW32 would cause HAVE_POSIX and HAVE_UNIX variables not to be selected, and you could disable the remaining applets with "depends on !TARGET_MINGW32". This would avoid lists of "!TARGET_X && !TARGET_Y && ..." as dependencies of innocent applets if more systems were to be added. Of course, in any case, I would update my stuff to match whatever is merged in. -- Jérémie Koenig <[email protected]> http://jk.fr.eu.org/
From 56d3ed6acb72a59496dfd1ba665605df9caac882 Mon Sep 17 00:00:00 2001 From: Jeremie Koenig <[email protected]> Date: Thu, 15 Apr 2010 03:08:07 +0200 Subject: [PATCH 1/2] Include os-specific Makefile and Config.in files --- Config.in | 6 +++++- Makefile | 19 +++++++++++++++++-- scripts/target-os | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 scripts/target-os diff --git a/Config.in b/Config.in index 40af911..ea6d40f 100644 --- a/Config.in +++ b/Config.in @@ -528,7 +528,7 @@ config LFS than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'. config CROSS_COMPILER_PREFIX - string "Cross Compiler prefix" + string "Cross Compiler prefix (config restart might be needed)" default "" help If you want to build BusyBox with a cross compiler, then you @@ -537,6 +537,10 @@ config CROSS_COMPILER_PREFIX Note that CROSS_COMPILE environment variable or "make CROSS_COMPILE=xxx ..." will override this selection. + Furthermore, if your target runs an operating system + different from that of the build system, + you should save the configuration and restart it + after you change this value. Native builds leave this empty. diff --git a/Makefile b/Makefile index 1481f01..8364b73 100644 --- a/Makefile +++ b/Makefile @@ -347,6 +347,9 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git +# bbox: detect the target operating system +TARGET_OS ?= $(shell $(srctree)/scripts/target-os $(CPP) $(CPPFLAGS)) + # =========================================================================== # Rules shared between *config targets and build targets @@ -426,9 +429,17 @@ ifeq ($(config-targets),1) # KBUILD_DEFCONFIG may point out an alternative default configuration # used for 'make defconfig' -include $(srctree)/arch/$(ARCH)/Makefile + +# bbox: try a system-specific Makefile as well, and create os/Config.in +-include $(srctree)/os/$(TARGET_OS)/Makefile +os/Config.in: FORCE + $(Q)if [ "$(TARGET_OS)" ] && [ -e "os/$(TARGET_OS)/Config.in" ]; then \ + echo "source os/$(TARGET_OS)/Config.in"; \ + fi >$@ + export KBUILD_DEFCONFIG -config %config: scripts_basic outputmakefile FORCE +config %config: scripts_basic outputmakefile os/Config.in FORCE $(Q)mkdir -p include $(Q)$(MAKE) $(build)=scripts/kconfig $@ $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease @@ -451,6 +462,7 @@ scripts_basic: include/autoconf.h # Objects we will link into busybox / subdirs we need to visit core-y := \ applets/ \ + $(shell find $(srctree)/os -maxdepth 1 -name $(TARGET_OS) -exec basename {}\;) \ libs-y := \ archival/ \ @@ -519,6 +531,8 @@ endif all: busybox doc -include $(srctree)/arch/$(ARCH)/Makefile +# bbox: try a system-specific Makefile as well +-include $(srctree)/os/$(TARGET_OS)/Makefile # arch Makefile may override CC so keep this after arch Makefile is included #bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) @@ -560,7 +574,7 @@ libs-y := $(libs-y1) $(libs-y2) # Build busybox # --------------------------------------------------------------------------- -# busybox is build from the objects selected by $(busybox-init) and +# busybox is built from the objects selected by $(busybox-init) and # $(busybox-main). Most are built-in.o files from top-level directories # in the kernel tree, others are specified in arch/$(ARCH)Makefile. # Ordering when linking is important, and $(busybox-init) must be first. @@ -951,6 +965,7 @@ CLEAN_FILES += busybox busybox_unstripped* busybox.links \ # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 MRPROPER_FILES += .config .config.old include/asm .version .old_version \ + os/Config.in \ include/autoconf.h \ include/bbconfigopts.h \ include/usage_compressed.h \ diff --git a/scripts/target-os b/scripts/target-os new file mode 100755 index 0000000..2550bc2 --- /dev/null +++ b/scripts/target-os @@ -0,0 +1,18 @@ +#!/bin/sh +# Prints out the target OS, using the given preprocessor and flags + +if [ $# -lt 1 ]; then + echo >&2 "Usage: $0 \$(CPP) \$(CPPFLAGS)" + exit 1 +fi + +"$@" - <<EOF | awk '/^"/ { gsub("\"", ""); print $0; }' +#if defined(__linux__) +"linux" +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +"freebsd" +#elif defined(__GNU__) +"hurd" +#endif +EOF + -- 1.7.0.4
From 63379c3c90be786554b22b58bc4c09599b8b7437 Mon Sep 17 00:00:00 2001 From: Jeremie Koenig <[email protected]> Date: Sat, 17 Apr 2010 22:41:25 +0200 Subject: [PATCH 2/2] add HAVE_UNIX and HAVE_LINUX for system-dependant applet selection --- Config.in | 6 ++++++ console-tools/Config.in | 13 +++++++++++++ coreutils/Config.in | 3 +++ libbb/Kbuild | 3 +++ modutils/Config.in | 1 + os/README | 26 ++++++++++++++++++++++++++ os/hurd/Config.in | 5 +++++ os/linux/Config.in | 9 +++++++++ util-linux/Config.in | 30 ++++++++++++++++++++++++++++++ 9 files changed, 96 insertions(+), 0 deletions(-) create mode 100644 os/Config.in create mode 100644 os/README create mode 100644 os/hurd/Config.in create mode 100644 os/linux/Config.in diff --git a/Config.in b/Config.in index ea6d40f..aa92d63 100644 --- a/Config.in +++ b/Config.in @@ -255,6 +255,7 @@ config FEATURE_CLEAN_UP config FEATURE_UTMP bool "Support utmp file" default n + depends on HAVE_UNIX help The file /var/run/utmp is used to track who is currently logged in. With this option on, certain applets (getty, login, telnetd etc) @@ -282,6 +283,7 @@ config FEATURE_PIDFILE config FEATURE_SUID bool "Support for SUID/SGID handling" default n + depends on HAVE_UNIX help With this option you can install the busybox binary belonging to root with the suid bit set, and it will automatically drop @@ -341,6 +343,7 @@ config FEATURE_SUID_CONFIG_QUIET config SELINUX bool "Support NSA Security Enhanced Linux" default n + depends on HAVE_LINUX help Enable support for SELinux in applets ls, ps, and id. Also provide the option of compiling in SELinux applets. @@ -708,6 +711,9 @@ endmenu source libbb/Config.in +# Possibly shows a system-specific menu +source os/Config.in + endmenu comment "Applets" diff --git a/console-tools/Config.in b/console-tools/Config.in index 195685b..7461ef4 100644 --- a/console-tools/Config.in +++ b/console-tools/Config.in @@ -2,12 +2,14 @@ # For a description of the syntax of this configuration file, # see scripts/kbuild/config-language.txt. # +# menu "Console Utilities" config CHVT bool "chvt" default n + depends on HAVE_LINUX help This program is used to change to another terminal. Example: chvt 4 (change to terminal /dev/tty4) @@ -21,12 +23,14 @@ config CLEAR config DEALLOCVT bool "deallocvt" default n + depends on HAVE_LINUX help This program deallocates unused virtual consoles. config DUMPKMAP bool "dumpkmap" default n + depends on HAVE_LINUX help This program dumps the kernel's keyboard translation table to stdout, in binary format. You can then use loadkmap to load it. @@ -34,18 +38,21 @@ config DUMPKMAP config KBD_MODE bool "kbd_mode" default n + depends on HAVE_LINUX help This program reports and sets keyboard mode. config LOADFONT bool "loadfont" default n + depends on HAVE_LINUX help This program loads a console font from standard input. config LOADKMAP bool "loadkmap" default n + depends on HAVE_LINUX help This program loads a keyboard translation table from standard input. @@ -53,6 +60,7 @@ config LOADKMAP config OPENVT bool "openvt" default n + depends on HAVE_LINUX help This program is used to start a command on an unused virtual terminal. @@ -84,6 +92,7 @@ config FEATURE_RESIZE_PRINT config SETCONSOLE bool "setconsole" default n + depends on HAVE_LINUX help This program redirects the system console to another device, like the current tty while logged in via telnet. @@ -98,6 +107,7 @@ config FEATURE_SETCONSOLE_LONG_OPTIONS config SETFONT bool "setfont" default n + depends on HAVE_LINUX help Allows to load console screen map. Useful for i18n. @@ -119,6 +129,7 @@ config DEFAULT_SETFONT_DIR config SETKEYCODES bool "setkeycodes" default n + depends on HAVE_LINUX help This program loads entries into the kernel's scancode-to-keycode map, allowing unusual keyboards to generate usable keycodes. @@ -126,12 +137,14 @@ config SETKEYCODES config SETLOGCONS bool "setlogcons" default n + depends on HAVE_LINUX help This program redirects the output console of kernel messages. config SHOWKEY bool "showkey" default n + depends on HAVE_LINUX help Shows keys pressed. diff --git a/coreutils/Config.in b/coreutils/Config.in index ead632a..12bda23 100644 --- a/coreutils/Config.in +++ b/coreutils/Config.in @@ -445,6 +445,7 @@ config FEATURE_MKDIR_LONG_OPTIONS config MKFIFO bool "mkfifo" default n + depends on HAVE_UNIX help mkfifo is used to create FIFOs (named pipes). The `mknod' program can also create FIFOs. @@ -452,6 +453,7 @@ config MKFIFO config MKNOD bool "mknod" default n + depends on HAVE_UNIX help mknod is used to create FIFOs or block/character special files with the specified names. @@ -650,6 +652,7 @@ config FEATURE_STAT_FORMAT config STTY bool "stty" default n + #depends on HAVE_UNIX ? help stty is used to change and print terminal line settings. diff --git a/libbb/Kbuild b/libbb/Kbuild index 1b11d5d..5c370e2 100644 --- a/libbb/Kbuild +++ b/libbb/Kbuild @@ -6,6 +6,9 @@ lib-y:= +# TODO: separate the system-specific ones into lib-$(CONFIG_HAVE_UNIX) +# and lib-$(CONFIG_HAVE_LINUX), or select them through the applet which make +# use of them, as is done at the end of this file. lib-y += appletlib.o lib-y += ask_confirmation.o lib-y += bb_askpass.o diff --git a/modutils/Config.in b/modutils/Config.in index 83c12b6..e8ccda3 100644 --- a/modutils/Config.in +++ b/modutils/Config.in @@ -4,6 +4,7 @@ # menu "Linux Module Utilities" + depends on HAVE_LINUX config MODPROBE_SMALL bool "Simplified modutils" diff --git a/os/Config.in b/os/Config.in new file mode 100644 index 0000000..e69de29 diff --git a/os/README b/os/README new file mode 100644 index 0000000..d0be271 --- /dev/null +++ b/os/README @@ -0,0 +1,26 @@ +Target system detection is done by scripts/target-os, which uses the target C +preprocessor to identify known systems. System-specific tuning is done by +creating an os/<sys> subdirectory which may contain additional Makefile and +Config.in files. Currently, os/unkown is a symbolic link to os/linux, so that +if the OS detection code fails, the configuration defaults to the "normal" +Linux mode. + +The Config.in file may contain a system-specific configuration menu, and may +activate families of applets by defining the corresponding HAVE_* options. +The following options are currently defined: + + * HAVE_UNIX enables the applets which depend on system calls and behavior + typical of UNIX-like systems: device nodes, mount(), ... + + * HAVE_LINUX enables the applets which are specific to a given operating + system. + +As a starting point, some of the selected applets may be allowed to fail to +build on a given system, especially if they could be made to work by +a system-specific compatibility layer. As some ports become more or less +complete, the set of broad categories could be adjusted, and additional +HAVE_<SYSTEM> variables could be introducted for finer tuning. + +TODO: The Makefile should enable the system-specific code to be linked in, but +I have not tried it yet. + diff --git a/os/hurd/Config.in b/os/hurd/Config.in new file mode 100644 index 0000000..d708e35 --- /dev/null +++ b/os/hurd/Config.in @@ -0,0 +1,5 @@ + +config HAVE_UNIX + bool + default y + diff --git a/os/linux/Config.in b/os/linux/Config.in new file mode 100644 index 0000000..9a7b46f --- /dev/null +++ b/os/linux/Config.in @@ -0,0 +1,9 @@ + +config HAVE_LINUX + bool + default y + +config HAVE_UNIX + bool + default y + diff --git a/util-linux/Config.in b/util-linux/Config.in index a59cc1d..c084075 100644 --- a/util-linux/Config.in +++ b/util-linux/Config.in @@ -8,6 +8,7 @@ menu "Linux System Utilities" config ACPID bool "acpid" default n + depends on HAVE_LINUX help acpid listens to ACPI events coming either in textual form from /proc/acpi/event (though it is marked deprecated it is still widely @@ -30,6 +31,7 @@ config FEATURE_ACPID_COMPAT config BLKID bool "blkid" default n + depends on HAVE_UNIX select VOLUMEID help Lists labels and UUIDs of all filesystems. @@ -39,6 +41,7 @@ config BLKID config DMESG bool "dmesg" default n + depends on HAVE_UNIX help dmesg is used to examine or control the kernel ring buffer. When the Linux kernel prints messages to the system log, they are stored in @@ -72,6 +75,7 @@ config FEATURE_DMESG_PRETTY config FBSET bool "fbset" default n + depends on HAVE_LINUX help fbset is used to show or change the settings of a Linux frame buffer device. The frame buffer device provides a simple and unique @@ -100,6 +104,7 @@ config FEATURE_FBSET_READMODE config FDFLUSH bool "fdflush" default n + depends on HAVE_LINUX help fdflush is only needed when changing media on slightly-broken removable media drives. It is used to make Linux believe that a @@ -112,12 +117,14 @@ config FDFLUSH config FDFORMAT bool "fdformat" default n + depends on HAVE_LINUX help fdformat is used to low-level format a floppy disk. config FDISK bool "fdisk" default n + depends on HAVE_UNIX help The fdisk utility is used to divide hard disks into one or more logical disks, which are generally called partitions. This utility @@ -185,6 +192,7 @@ config FEATURE_FDISK_ADVANCED config FINDFS bool "findfs" default n + depends on HAVE_UNIX select VOLUMEID help Prints the name of a filesystem with given label or UUID. @@ -200,6 +208,7 @@ config FLOCK config FREERAMDISK bool "freeramdisk" default n + depends on HAVE_LINUX help Linux allows you to create ramdisks. This utility allows you to delete them and completely free all memory that was used for the @@ -211,6 +220,7 @@ config FREERAMDISK config FSCK_MINIX bool "fsck_minix" default n + depends on HAVE_UNIX help The minix filesystem is a nice, small, compact, read-write filesystem with little overhead. It is not a journaling filesystem however and @@ -222,12 +232,14 @@ config FSCK_MINIX config MKFS_EXT2 bool "mkfs_ext2" default n + depends on HAVE_UNIX help Utility to create EXT2 filesystems. config MKFS_MINIX bool "mkfs_minix" default n + depends on HAVE_UNIX help The minix filesystem is a nice, small, compact, read-write filesystem with little overhead. If you wish to be able to create minix @@ -248,12 +260,14 @@ config FEATURE_MINIX2 config MKFS_REISER bool "mkfs_reiser" default n + depends on HAVE_UNIX help Utility to create ReiserFS filesystems. config MKFS_VFAT bool "mkfs_vfat" default n + depends on HAVE_UNIX help Utility to create FAT32 filesystems. @@ -302,6 +316,7 @@ config HD config HWCLOCK bool "hwclock" default n + depends on HAVE_LINUX help The hwclock utility is used to read and set the hardware clock on a system. This is primarily used to set the current time on @@ -349,6 +364,7 @@ config IPCS config LOSETUP bool "losetup" default n + depends on HAVE_LINUX help losetup is used to associate or detach a loop device with a regular file or block device, and to query the status of a loop device. This @@ -357,6 +373,7 @@ config LOSETUP config LSPCI bool "lspci" default n + depends on HAVE_LINUX help lspci is a utility for displaying information about PCI buses in the system and devices connected to them. @@ -366,6 +383,7 @@ config LSPCI config LSUSB bool "lsusb" default n + depends on HAVE_LINUX help lsusb is a utility for displaying information about USB buses in the system and devices connected to them. @@ -375,6 +393,7 @@ config LSUSB config MDEV bool "mdev" default n + depends on HAVE_LINUX help mdev is a mini-udev implementation for dynamically creating device nodes in the /dev directory. @@ -432,6 +451,7 @@ config FEATURE_MDEV_LOAD_FIRMWARE config MKSWAP bool "mkswap" default n + depends on HAVE_LINUX help The mkswap utility is used to configure a file or disk partition as Linux swap space. This allows Linux to use the entire file or @@ -472,6 +492,7 @@ config FEATURE_USE_TERMIOS config VOLUMEID bool #No description makes it a hidden option + depends on HAVE_UNIX default n config FEATURE_VOLUMEID_EXT @@ -688,6 +709,7 @@ config FEATURE_VOLUMEID_LINUXRAID config MOUNT bool "mount" default n + depends on HAVE_UNIX help All files and filesystems in Unix are arranged into one big directory tree. The 'mount' utility is used to graft a filesystem onto a @@ -770,6 +792,7 @@ config FEATURE_MOUNT_FSTAB config PIVOT_ROOT bool "pivot_root" default n + depends on HAVE_LINUX help The pivot_root utility swaps the mount points for the root filesystem with some other mounted filesystem. This allows you to do all sorts @@ -791,18 +814,21 @@ config RDATE config RDEV bool "rdev" default n + depends on HAVE_UNIX help Print the device node associated with the filesystem mounted at '/'. config READPROFILE bool "readprofile" default n + depends on HAVE_LINUX help This allows you to parse /proc/profile for basic profiling. config RTCWAKE bool "rtcwake" default n + depends on HAVE_LINUX help Enter a system sleep state until specified wakeup time. @@ -822,6 +848,7 @@ config SCRIPTREPLAY config SETARCH bool "setarch" default n + depends on HAVE_LINUX help The linux32 utility is used to create a 32bit environment for the specified program (usually a shell). It only makes sense to have @@ -831,6 +858,7 @@ config SETARCH config SWAPONOFF bool "swaponoff" default n + depends on HAVE_UNIX #? help This option enables both the 'swapon' and the 'swapoff' utilities. Once you have created some swap space using 'mkswap', you also need @@ -849,6 +877,7 @@ config FEATURE_SWAPON_PRI config SWITCH_ROOT bool "switch_root" default n + depends on HAVE_LINUX help The switch_root utility is used from initramfs to select a new root device. Under initramfs, you have to use this instead of @@ -868,6 +897,7 @@ config SWITCH_ROOT config UMOUNT bool "umount" default n + depends on HAVE_UNIX help When you want to remove a mounted filesystem from its current mount point, for example when you are shutting down the system, the -- 1.7.0.4
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
