kumquat-buildroot/package/nmap/nmap.mk
Carlos Santos 55ec9b4e40 nmap: add sub-options for ncat, nping and ndiff
The forthcoming "libvirt" package will need a "nc" command with support
for Unix domain sockets in order to permit remote management using the
virt-manager utility. netcat-openbsd provides such command but requires
glibc, so we would not have remote management on uClibc-based systems.

Ncat is a much-improved reimplementation of the venerable Netcat and is
compatible with uClibc and musl. It provides features not available in
the ancient GNU netcat and its Busybox double like IPv6, proxies, and
Unix sockets.

Since 'nmap' itself is a fairly big program (~2.3 MB), we want to be
able to install only ncat. In addition, nmap requires an external
library, pcre.

So this commit adds sub-options to selectively enable/disable the
different programs part of nmap: nmap, nping, ndiff and ncat.

Finally, we symlink 'nc' to ncat if neiter netcat nor netcat-openbsd
is selected, even though ncat does not have the same interface as
netcat-openbsd.  However, since Fedora/RHEL install nmap-ncat as 'nc',
it can be assumed that packages that depend on 'nc' know how to deal
with this diversity.  For example, the virt-manager package does
that. Also user-supplied scripts can be assumed to do the right thing,
since the user also selects whether nmap-ncat, netcat or
netcat-openbsd is installed.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[Thomas:
 - don't just handle the ncat case in a special way: create
   sub-options for all nmap tools, and use <pkg>_MAKE_OPTS and
   <pkg>_INSTALL_TARGET_OPTS to select which ones should be
   built/installed.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-04-02 15:28:05 +02:00

102 lines
2.9 KiB
Makefile

################################################################################
#
# nmap
#
################################################################################
NMAP_VERSION = 7.60
NMAP_SITE = https://nmap.org/dist
NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2
NMAP_DEPENDENCIES = libpcap host-autoconf
NMAP_CONF_OPTS = --without-liblua --without-zenmap \
--with-libdnet=included --with-liblinear=included
NMAP_LICENSE = GPL-2.0
NMAP_LICENSE_FILES = COPYING
# nmap doesn't autoreconf properly, so we just re-generate the
# top-level configure script, since we are patching configure.ac.
define NMAP_DO_AUTOCONF
(cd $(@D); $(HOST_DIR)/bin/autoconf)
endef
NMAP_PRE_CONFIGURE_HOOKS += NMAP_DO_AUTOCONF
# needed by libpcap
NMAP_LIBS_FOR_STATIC_LINK += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
ifeq ($(BR2_STATIC_LIBS),y)
NMAP_CONF_ENV += LIBS="$(NMAP_LIBS_FOR_STATIC_LINK)"
endif
# for 0001-libdnet-wrapper-configure.patch
define NMAP_WRAPPER_EXEC
chmod +x $(@D)/libdnet-stripped/configure.gnu
endef
NMAP_POST_PATCH_HOOKS += NMAP_WRAPPER_EXEC
ifeq ($(BR2_PACKAGE_LIBSSH2),y)
NMAP_CONF_OPTS += --with-libssh2="$(STAGING_DIR)/usr"
NMAP_DEPENDENCIES += libssh2
NMAP_LIBS_FOR_STATIC_LINK += `$(PKG_CONFIG_HOST_BINARY) --libs libssh2`
else
NMAP_CONF_OPTS += --without-libssh2
endif
ifeq ($(BR2_PACKAGE_OPENSSL),y)
NMAP_CONF_OPTS += --with-openssl="$(STAGING_DIR)/usr"
NMAP_DEPENDENCIES += host-pkgconf openssl
NMAP_LIBS_FOR_STATIC_LINK += `$(PKG_CONFIG_HOST_BINARY) --libs openssl`
else
NMAP_CONF_OPTS += --without-openssl
endif
NMAP_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR)
ifeq ($(BR2_PACKAGE_NMAP_NCAT),y)
NMAP_CONF_OPTS += --with-ncat
NMAP_MAKE_OPTS += build-ncat
NMAP_INSTALL_TARGET_OPTS += install-ncat
else
NMAP_CONF_OPTS += --without-ncat
endif
ifeq ($(BR2_PACKAGE_NMAP_NDIFF),y)
NMAP_DEPENDENCIES += python
NMAP_CONF_OPTS += --with-ndiff
NMAP_MAKE_OPTS += build-ndiff
NMAP_INSTALL_TARGET_OPTS += install-ndiff
else
NMAP_CONF_OPTS += --without-ndiff
endif
ifeq ($(BR2_PACKAGE_NMAP_NMAP),y)
NMAP_DEPENDENCIES += pcre
NMAP_CONF_OPTS += --with-libpcre="$(STAGING_DIR)/usr"
NMAP_MAKE_OPTS += nmap
NMAP_INSTALL_TARGET_OPTS += install-nmap
endif
ifeq ($(BR2_PACKAGE_NMAP_NPING),y)
NMAP_CONF_OPTS += --with-nping
NMAP_MAKE_OPTS += build-nping
NMAP_INSTALL_TARGET_OPTS += install-nping
else
NMAP_CONF_OPTS += --without-nping
endif
# If we are going to install ncat, ensure Busybox gets built/installed
# before, so that this package overrides Busybox nc.
ifeq ($(BR2_PACKAGE_NMAP_NCAT)$(BR2_PACKAGE_BUSYBOX),yy)
NMAP_DEPENDENCIES += busybox
endif
# Add a symlink to "nc" if none of the competing netcats is selected
ifeq ($(BR2_PACKAGE_NMAP_NCAT):$(BR2_PACKAGE_NETCAT)$(BR2_PACKAGE_NETCAT_OPENBSD),y:)
define NMAP_INSTALL_NCAT_SYMLINK
ln -fs ncat $(TARGET_DIR)/usr/bin/nc
endef
NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK
endif
$(eval $(autotools-package))