add i2c-utils package (found in old openwrt svn)

not sure why it was removed from openwrt mainline, it is very
useful to be able to do raw i2c operations from the shell.
This commit is contained in:
Harald Welte 2015-02-21 19:46:26 +01:00 committed by Harald Welte
parent 931bb20e63
commit c8cd9a10ce
1 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,110 @@
#
# Copyright (C) 2007-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=i2c-tools
PKG_VERSION:=2013-12-15
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=svn
PKG_SOURCE_URL:=http://lm-sensors.org/svn/i2c-tools/trunk
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=r6204
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=PACKAGE_python-smbus:python
include $(INCLUDE_DIR)/package.mk
$(call include_mk, python-package.mk)
define Package/i2c/Default
URL:=http://lm-sensors.org/wiki/I2CTools
TITLE:=I2C
endef
define Package/libi2c
$(call Package/i2c/Default)
SECTION:=libs
CATEGORY:=Libraries
TITLE+=library
endef
define Package/i2c-tools
$(call Package/i2c/Default)
SECTION:=utils
CATEGORY:=Utilities
TITLE+=tools for Linux
DEPENDS:=+libi2c
endef
define Package/python-smbus
$(call Package/i2c/Default)
SUBMENU:=Python
SECTION:=lang
CATEGORY:=Languages
TITLE:=Python bindings for the SMBUS
DEPENDS:=+PACKAGE_python-smbus:python-mini +i2c-tools
endef
define Package/i2c-tools/description
This package contains an heterogeneous set of I2C tools for Linux. These tools
were originally part of the lm-sensors package.
endef
define Package/python-smbus/description
This package contain the python bindings for Linux SMBus access through i2c-dev.
endef
TARGET_CPPFLAGS += -I$(PKG_BUILD_DIR)/include
ifdef CONFIG_PACKAGE_python-smbus
define Build/Compile/python-smbus
$(if $(Build/Compile/PyMod),,@echo Python packaging code not found.; false)
$(call Build/Compile/PyMod,./py-smbus/, \
install --prefix="$(PKG_INSTALL_DIR)/usr", \
)
endef
endif
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
LINUX="$(LINUX_DIR)" \
CC="$(TARGET_CC)" \
STAGING_DIR="$(STAGING_DIR)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
CFLAGS="$(TARGET_CFLAGS)"
$(Build/Compile/python-smbus)
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/lib/libi2c.so* $(1)/usr/lib/
endef
define Package/libi2c/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/lib/libi2c.so* $(1)/usr/lib/
endef
define Package/i2c-tools/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/i2cdetect $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/i2cdump $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/i2cset $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/i2cget $(1)/usr/sbin/
endef
define PyPackage/python-smbus/filespec
+|$(PYTHON_PKG_DIR)/smbus.so
endef
$(eval $(call BuildPackage,libi2c))
$(eval $(call BuildPackage,i2c-tools))
$(eval $(call PyPackage,python-smbus))
$(eval $(call BuildPackage,python-smbus))