packages/net/usbip/Makefile
Eneas U de Queiroz 633fe0dbdf usbip: adapt package to new kernel/libudev
The sources for usbip are within the kernel.  A patch that was included
with the package, which changed the old signal name SIGCLD to the new
one, SIGCHLD, was merged upstream.  However, different targets use
different kernel versions.  Current version 4.14 and 4.9 are fine, but
older versions do not have the patch applied.  So, I used
-DSIGCLD=SIGCHLD to please both worlds.

libudev-fbsd currently used by openwrt does not implement the
udev_device_get_devpath function.  eudev's implementation of libudev
sets it as (src/libudev/libudev-device.c):
udev_device->devpath = udev_device->syspath + strlen("/sys");
I used a command-line define to use the same logic, as it works with
new and old versions of the kernel--the use of ..devpath is quite
recent.

I also linked with libbsd, when using glibc.

Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
2018-05-23 14:18:17 -03:00

114 lines
2.9 KiB
Makefile

#
# Copyright (C) 2010-2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=usbip
PKG_RELEASE:=10
PKG_LICENSE:=GPL-2.0
# Since kernel 2.6.39.1 userspace tools are inside the kernel tree
# Package Automatic match version in kernel
# MD5SUM is not useful kernel package already check it
PKG_VERSION:=$(shell sed -n -e '/^AC_INIT/s/.*\[\([[:digit:]\.]*\)\].*/\1/gp' $(LINUX_DIR)/tools/usb/usbip/configure.ac)
PKG_SOURCE:=
PKG_SOURCE_URL:=
PKG_MD5SUM:=unknown
PKG_MAINTAINER:=Nuno Goncalves <nunojpg@gmail.com>
PATCH_DIR:=./patches-$(PKG_VERSION)
define prepare_source_directory
rm -rf $(PKG_BUILD_DIR)
$(CP) $(LINUX_DIR)/tools/usb/usbip $(PKG_BUILD_DIR)
endef
Hooks/Prepare/Pre += prepare_source_directory
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk
define Package/usbip/Common
TITLE:=USB-over-IP
URL:=http://usbip.sourceforge.net/
DEPENDS:=@USB_SUPPORT
endef
define Package/usbip/Default
$(call Package/usbip/Common)
SECTION:=net
CATEGORY:=Network
endef
define Package/usbip
$(call Package/usbip/Default)
TITLE+= (common)
DEPENDS+= +libwrap +kmod-usbip +libudev-fbsd +USE_GLIBC:libbsd
endef
define Package/usbip-client
$(call Package/usbip/Default)
TITLE+= (client)
DEPENDS+= usbip +kmod-usbip-client
endef
define Package/usbip-server
$(call Package/usbip/Default)
TITLE+= (server)
DEPENDS+= usbip +kmod-usbip-server
endef
CONFIGURE_PATH:=.
MAKE_PATH:=.
LIBTOOL_PATHS:=.
MAKE_FLAGS+=CFLAGS='-Dudev_device_get_devpath\(x\)=udev_device_get_syspath\(x\)+strlen\(\"/sys\"\) \
-DSIGCLD=SIGCHLD'
CONFIGURE_ARGS+= --disable-silent-rules
define Build/Configure
(cd $(PKG_BUILD_DIR); ./autogen.sh );
$(call Build/Configure/Default)
endef
CONFIGURE_VARS+= $(if $(CONFIG_USE_GLIBC),LIBS='-lbsd -lpthread')
CFLAGS+="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include"
USB_IDS_REV:=0a6be488b4c1485d30c9efee1cc895af5d4a1383
USB_IDS_FILE:=usb.ids.$(USB_IDS_REV)
define Download/usb.ids
FILE:=$(USB_IDS_FILE)
URL_FILE:=usb.ids
URL:=@GITHUB/gentoo/hwids/$(USB_IDS_REV)
HASH:=2d0403ffccc0ff7150e32c0bf8e2878816b76ba08d2c3bb1059f33627a3da30f
endef
define Package/usbip/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libusbip.so.* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/share/hwdata
$(CP) $(DL_DIR)/usb.ids.$(USB_IDS_REV) $(1)/usr/share/hwdata/usb.ids
endef
define Package/usbip-client/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/usbip $(1)/usr/sbin/
endef
define Package/usbip-server/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/usbipd $(1)/usr/sbin/
endef
$(eval $(call Download,usb.ids))
$(eval $(call BuildPackage,usbip))
$(eval $(call BuildPackage,usbip-client))
$(eval $(call BuildPackage,usbip-server))