Fix non-Linux builds

Various tools are Linuxish and should thus only attempted to build on
Linux only. Some features are also Linux-only.

Also, libresolv is used on all GNU platforms, notably GNU/Hurd and
GNU/kfreeBSD.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Samuel Thibault 2022-10-16 02:04:59 +02:00 committed by Denys Vlasenko
parent 75fbff1326
commit 77216c368f
56 changed files with 89 additions and 3 deletions

View File

@ -184,7 +184,7 @@ LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%
endif
ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y)
ifneq (,$(findstring linux,$(shell $(CC) $(CFLAGS) -dumpmachine)))
ifneq (,$(findstring gnu,$(shell $(CC) $(CFLAGS) -dumpmachine)))
LDLIBS += resolv
endif
endif

View File

@ -12,6 +12,7 @@
//config:config LOADFONT
//config: bool "loadfont (5.2 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: This program loads a console font from standard input.
//config:

View File

@ -10,6 +10,7 @@
//config:config OPENVT
//config: bool "openvt (7.2 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: This program is used to start a command on an unused
//config: virtual terminal.

View File

@ -200,6 +200,7 @@ static void dd_output_status(int UNUSED_PARAM cur_signal)
}
#if ENABLE_FEATURE_DD_IBS_OBS
# ifdef O_DIRECT
static int clear_O_DIRECT(int fd)
{
if (errno == EINVAL) {
@ -212,6 +213,7 @@ static int clear_O_DIRECT(int fd)
return 0;
}
# endif
#endif
static ssize_t dd_read(void *ibuf, size_t ibs)
{
@ -225,8 +227,10 @@ static ssize_t dd_read(void *ibuf, size_t ibs)
#endif
n = safe_read(ifd, ibuf, ibs);
#if ENABLE_FEATURE_DD_IBS_OBS
# ifdef O_DIRECT
if (n < 0 && (G.flags & FLAG_IDIRECT) && clear_O_DIRECT(ifd))
goto read_again;
# endif
#endif
return n;
}
@ -239,9 +243,11 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
IF_FEATURE_DD_IBS_OBS(write_again:)
n = full_write(ofd, buf, len);
#if ENABLE_FEATURE_DD_IBS_OBS
# ifdef O_DIRECT
if (n < 0 && (G.flags & FLAG_ODIRECT) && clear_O_DIRECT(ofd))
goto write_again;
# endif
#endif
#if ENABLE_FEATURE_DD_THIRD_STATUS_LINE
if (n > 0)
@ -501,8 +507,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
if (infile) {
int iflag = O_RDONLY;
#if ENABLE_FEATURE_DD_IBS_OBS
if (G.flags & FLAG_IDIRECT)
if (G.flags & FLAG_IDIRECT) {
# ifdef O_DIRECT
iflag |= O_DIRECT;
# else
bb_error_msg_and_die("O_DIRECT not supported on this platform");
# endif
}
#endif
xmove_fd(xopen(infile, iflag), ifd);
} else {
@ -516,8 +527,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
if (G.flags & FLAG_APPEND)
oflag |= O_APPEND;
#if ENABLE_FEATURE_DD_IBS_OBS
if (G.flags & FLAG_ODIRECT)
if (G.flags & FLAG_ODIRECT) {
# ifdef O_DIRECT
oflag |= O_DIRECT;
# else
bb_error_msg_and_die("O_DIRECT not supported on this platform");
# endif
}
#endif
xmove_fd(xopen(outfile, oflag), ofd);

View File

@ -8,6 +8,7 @@
//config:config RUN_INIT
//config: bool "run-init (7.7 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: The run-init utility is used from initramfs to select a new
//config: root device. Under initramfs, you have to use this instead of

View File

@ -13,6 +13,7 @@
//config:config ADJTIMEX
//config: bool "adjtimex (4.7 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Adjtimex reads and optionally sets adjustment parameters for
//config: the Linux clock adjustment algorithm.

View File

@ -11,30 +11,35 @@
//config:config I2CGET
//config: bool "i2cget (5.5 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Read from I2C/SMBus chip registers.
//config:
//config:config I2CSET
//config: bool "i2cset (6.7 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Set I2C registers.
//config:
//config:config I2CDUMP
//config: bool "i2cdump (7.1 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Examine I2C registers.
//config:
//config:config I2CDETECT
//config: bool "i2cdetect (7.1 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Detect I2C chips.
//config:
//config:config I2CTRANSFER
//config: bool "i2ctransfer (4.0 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Send user-defined I2C messages in one transfer.
//config:

View File

@ -7,6 +7,7 @@
//config:config PARTPROBE
//config: bool "partprobe (3.5 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Ask kernel to rescan partition table.

View File

@ -9,6 +9,7 @@
//config:config UBIRENAME
//config: bool "ubirename (2.4 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Utility to rename UBI volumes

View File

@ -11,6 +11,7 @@
//config:config WATCHDOG
//config: bool "watchdog (5.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: The watchdog utility is used with hardware or software watchdog
//config: device drivers. It opens the specified watchdog device special file

View File

@ -8,6 +8,7 @@ menu "Linux Module Utilities"
config MODPROBE_SMALL
bool "Simplified modutils"
default y
select PLATFORM_LINUX
help
Build smaller (~1.5 kbytes), simplified module tools.

View File

@ -10,6 +10,7 @@
//config:config DEPMOD
//config: bool "depmod (27 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: depmod generates modules.dep (and potentially modules.alias
//config: and modules.symbols) that contain dependency information

View File

@ -9,6 +9,7 @@
//config:config INSMOD
//config: bool "insmod (22 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: insmod is used to load specified modules in the running kernel.

View File

@ -10,6 +10,7 @@
//config:config LSMOD
//config: bool "lsmod (1.9 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: lsmod is used to display a list of loaded modules.
//config:

View File

@ -8,6 +8,7 @@
//config:config MODINFO
//config: bool "modinfo (24 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Show information about a Linux Kernel module

View File

@ -10,6 +10,7 @@
//config:config MODPROBE
//config: bool "modprobe (28 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Handle the loading of modules, and their dependencies on a high
//config: level.

View File

@ -10,6 +10,7 @@
//config:config RMMOD
//config: bool "rmmod (3.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: rmmod is used to unload specified modules from the kernel.

View File

@ -15,6 +15,7 @@
//config:config ARP
//config: bool "arp (10 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Manipulate the system ARP cache.

View File

@ -8,6 +8,7 @@
//config:config ARPING
//config: bool "arping (9 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Ping hosts by ARP packets.

View File

@ -12,6 +12,7 @@
//config:config BRCTL
//config: bool "brctl (4.7 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Manage ethernet bridges.
//config: Supports addbr/delbr and addif/delif.

View File

@ -27,6 +27,7 @@
//config:config IFCONFIG
//config: bool "ifconfig (12 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Ifconfig is used to configure the kernel-resident network interfaces.
//config:

View File

@ -9,6 +9,7 @@
//config:config IFPLUGD
//config: bool "ifplugd (10 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Network interface plug detection daemon.

View File

@ -11,6 +11,7 @@
//config:config IP
//config: bool "ip (35 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: The "ip" applet is a TCP/IP interface configuration and routing
//config: utility.
@ -21,6 +22,7 @@
//config:config IPADDR
//config: bool "ipaddr (14 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select FEATURE_IP_ADDRESS
//config: help
//config: Short form of "ip addr"
@ -28,6 +30,7 @@
//config:config IPLINK
//config: bool "iplink (17 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select FEATURE_IP_LINK
//config: help
//config: Short form of "ip link"
@ -35,6 +38,7 @@
//config:config IPROUTE
//config: bool "iproute (15 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select FEATURE_IP_ROUTE
//config: help
//config: Short form of "ip route"
@ -49,6 +53,7 @@
//config:config IPRULE
//config: bool "iprule (10 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select FEATURE_IP_RULE
//config: help
//config: Short form of "ip rule"
@ -56,6 +61,7 @@
//config:config IPNEIGH
//config: bool "ipneigh (8.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select FEATURE_IP_NEIGH
//config: help
//config: Short form of "ip neigh"

View File

@ -12,6 +12,7 @@
//config:config NAMEIF
//config: bool "nameif (6.6 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select FEATURE_SYSLOG
//config: help
//config: nameif is used to rename network interface by its MAC address.

View File

@ -27,6 +27,7 @@
//config:config ROUTE
//config: bool "route (8.7 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Route displays or manipulates the kernel's IP routing tables.

View File

@ -9,6 +9,7 @@
//config:config TC
//config: bool "tc (8.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Show / manipulate traffic control settings
//config:

View File

@ -963,8 +963,10 @@ traceroute_init(int op, char **argv)
if (af == AF_INET) {
xmove_fd(xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP), rcvsock);
#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
# ifdef IP_PKTINFO
/* want recvmsg to report target local address (for -v) */
setsockopt_1(rcvsock, IPPROTO_IP, IP_PKTINFO);
# endif
#endif
}
#if ENABLE_TRACEROUTE6

View File

@ -12,6 +12,7 @@
//config:config TUNCTL
//config: bool "tunctl (6.2 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: tunctl creates or deletes tun devices.
//config:

View File

@ -6,6 +6,7 @@
config UDHCPD
bool "udhcpd (21 kb)"
default y
select PLATFORM_LINUX
help
udhcpd is a DHCP server geared primarily toward embedded systems,
while striving to be fully functional and RFC compliant.
@ -53,6 +54,7 @@ config DUMPLEASES
config DHCPRELAY
bool "dhcprelay (5.2 kb)"
default y
select PLATFORM_LINUX
help
dhcprelay listens for DHCP requests on one or more interfaces
and forwards these requests to a different interface or DHCP
@ -61,6 +63,7 @@ config DHCPRELAY
config UDHCPC
bool "udhcpc (24 kb)"
default y
select PLATFORM_LINUX
help
udhcpc is a DHCP client geared primarily toward embedded systems,
while striving to be fully functional and RFC compliant.

View File

@ -9,6 +9,7 @@
//config:config FREE
//config: bool "free (3.1 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: free displays the total amount of free and used physical and swap
//config: memory in the system, as well as the buffers used by the kernel.

View File

@ -14,6 +14,7 @@
//config:config UPTIME
//config: bool "uptime (3.7 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: uptime gives a one line display of the current time, how long
//config: the system has been running, how many users are currently logged

View File

@ -19,6 +19,7 @@
//config:config KLOGD
//config: bool "klogd (5.7 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: klogd is a utility which intercepts and logs all
//config: messages from the Linux kernel and sends the messages

View File

@ -9,6 +9,7 @@
//config:config ACPID
//config: bool "acpid (9 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: acpid listens to ACPI events coming either in textual form from
//config: /proc/acpi/event (though it is marked deprecated it is still widely

View File

@ -8,6 +8,7 @@
//config:config BLKDISCARD
//config: bool "blkdiscard (4.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: blkdiscard discards sectors on a given device.

View File

@ -9,6 +9,7 @@
//config:config BLKID
//config: bool "blkid (12 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select VOLUMEID
//config: help
//config: Lists labels and UUIDs of all filesystems.

View File

@ -11,6 +11,7 @@
//config:config DMESG
//config: bool "dmesg (3.7 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: dmesg is used to examine or control the kernel ring buffer. When the
//config: Linux kernel prints messages to the system log, they are stored in

View File

@ -10,6 +10,7 @@
//config:config FDISK
//config: bool "fdisk (37 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: The fdisk utility is used to divide hard disks into one or more
//config: logical disks, which are generally called partitions. This utility

View File

@ -10,6 +10,7 @@
//config:config FINDFS
//config: bool "findfs (12 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select VOLUMEID
//config: help
//config: Prints the name of a filesystem with given label or UUID.

View File

@ -11,6 +11,7 @@
//config:config FDFLUSH
//config: bool "fdflush (1.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: fdflush is only needed when changing media on slightly-broken
//config: removable media drives. It is used to make Linux believe that a
@ -23,6 +24,7 @@
//config:config FREERAMDISK
//config: bool "freeramdisk (1.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Linux allows you to create ramdisks. This utility allows you to
//config: delete them and completely free all memory that was used for the

View File

@ -7,6 +7,7 @@
//config:config FSFREEZE
//config: bool "fsfreeze (3.5 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select LONG_OPTS
//config: help
//config: Halt new accesses and flush writes on a mounted filesystem.

View File

@ -10,6 +10,7 @@
//config:config FSTRIM
//config: bool "fstrim (4.4 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Discard unused blocks on a mounted filesystem.

View File

@ -9,6 +9,7 @@
//config:config HWCLOCK
//config: bool "hwclock (5.8 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: The hwclock utility is used to read and set the hardware clock
//config: on a system. This is primarily used to set the current time on

View File

@ -9,6 +9,7 @@
//config:config IONICE
//config: bool "ionice (3.8 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Set/set program io scheduling class and priority
//config: Requires kernel >= 2.6.13

View File

@ -9,6 +9,7 @@
//config:config LOSETUP
//config: bool "losetup (5.5 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: losetup is used to associate or detach a loop device with a regular
//config: file or block device, and to query the status of a loop device. This

View File

@ -10,6 +10,7 @@
//config:config MDEV
//config: bool "mdev (17 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: mdev is a mini-udev implementation for dynamically creating device
//config: nodes in the /dev directory.

View File

@ -10,6 +10,7 @@
//config:config MKE2FS
//config: bool "mke2fs (10 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Utility to create EXT2 filesystems.
//config:

View File

@ -10,6 +10,7 @@
//config:config MKDOSFS
//config: bool "mkdosfs (7.2 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Utility to create FAT32 filesystems.
//config:

View File

@ -20,6 +20,7 @@
//config:config MOUNT
//config: bool "mount (23 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: All files and filesystems in Unix are arranged into one big directory
//config: tree. The 'mount' utility is used to graft a filesystem onto a

View File

@ -9,6 +9,7 @@
//config:config NSENTER
//config: bool "nsenter (6.5 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Run program with namespaces of other processes.

View File

@ -11,6 +11,7 @@
//config:config PIVOT_ROOT
//config: bool "pivot_root (1.1 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: The pivot_root utility swaps the mount points for the root filesystem
//config: with some other mounted filesystem. This allows you to do all sorts

View File

@ -9,6 +9,7 @@
//config:config SETARCH
//config: bool "setarch (3.6 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: The linux32 utility is used to create a 32bit environment for the
//config: specified program (usually a shell). It only makes sense to have
@ -18,12 +19,14 @@
//config:config LINUX32
//config: bool "linux32 (3.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Alias to "setarch linux32".
//config:
//config:config LINUX64
//config: bool "linux64 (3.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Alias to "setarch linux64".

View File

@ -9,6 +9,7 @@
//config:config SETPRIV
//config: bool "setpriv (6.6 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: select LONG_OPTS
//config: help
//config: Run a program with different Linux privilege settings.

View File

@ -9,6 +9,7 @@
//config:config SWAPON
//config: bool "swapon (15 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Once you have created some swap space using 'mkswap', you also need
//config: to enable your swap space with the 'swapon' utility. The 'swapoff'
@ -35,6 +36,7 @@
//config:config SWAPOFF
//config: bool "swapoff (14 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config:
//config:config FEATURE_SWAPONOFF_LABEL
//config: bool "Support specifying devices by label or UUID"

View File

@ -9,6 +9,7 @@
//config:config SWITCH_ROOT
//config: bool "switch_root (5.5 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: The switch_root utility is used from initramfs to select a new
//config: root device. Under initramfs, you have to use this instead of

View File

@ -6,6 +6,7 @@
//config:config UEVENT
//config: bool "uevent (3.1 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: uevent is a netlink listener for kernel uevent notifications
//config: sent via netlink. It is usually used for dynamic device creation.

View File

@ -9,6 +9,7 @@
//config:config UNSHARE
//config: bool "unshare (7.2 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: depends on !NOMMU
//config: select LONG_OPTS
//config: help