Discussion:
Makefile for libgpiod in OpenWRT 19.07.2 providing Python 3 bindings
(too old to reply)
Wojciech M. Zabołotny
2020-05-08 20:50:57 UTC
Permalink
The libgpiod package in OpenWRT 19.07.2 is compiled without the Python
bindings. This archive contains the Makefile with added "python3-gpiod"
package, containing bindings for Python 3.

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.15.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the '#!/bin/sh' line above, then type 'sh FILE'.
#
lock_dir=_sh1518612
# Made on 2020-05-08 22:46 CEST by <***@wzab>.
# Source directory was '/tmp/jjjj'.
#
# Existing files will *not* be overwritten, unless '-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 2831 -rw-r--r-- Makefile
#
MD5SUM=${MD5SUM-md5sum}
f=`${MD5SUM} --version | egrep '^md5sum .*(core|text)utils'`
test -n "${f}" && md5check=true || md5check=false
${md5check} || \
echo 'Note: not verifying md5sums. Consider installing GNU coreutils.'
if test "X$1" = "X-c"
then keep_file=''
else keep_file=true
fi
echo=echo
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=
locale_dir=
set_echo=false

for dir in $PATH
do
if test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
case `$dir/gettext --version 2>&1 | sed 1q` in
*GNU*) gettext_dir=$dir
set_echo=true
break ;;
esac
fi
done

if ${set_echo}
then
set_echo=false
for dir in $PATH
do
if test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
set_echo=true
break
fi
done

if ${set_echo}
then
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
fi
IFS="$save_IFS"
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null
then if (echo -n test; echo 1,2,3) | grep n >/dev/null
then shar_n= shar_c='
'
else shar_n=-n shar_c= ; fi
else shar_n= shar_c='\c' ; fi
f=shar-touch.$$
st1=200112312359.59
st2=123123592001.59
st2tr=123123592001.5 # old SysV 14-char limit
st3=1231235901

if touch -am -t ${st1} ${f} >/dev/null 2>&1 && \
test ! -f ${st1} && test -f ${f}; then
shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'

elif touch -am ${st2} ${f} >/dev/null 2>&1 && \
test ! -f ${st2} && test ! -f ${st2tr} && test -f ${f}; then
shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'

elif touch -am ${st3} ${f} >/dev/null 2>&1 && \
test ! -f ${st3} && test -f ${f}; then
shar_touch='touch -am $3$4$5$6$2 "$8"'

else
shar_touch=:
echo
${echo} 'WARNING: not restoring timestamps. Consider getting and
installing GNU '\''touch'\'', distributed in GNU coreutils...'
echo
fi
rm -f ${st1} ${st2} ${st2tr} ${st3} ${f}
#
if test ! -d ${lock_dir} ; then :
else ${echo} "lock directory ${lock_dir} exists"
exit 1
fi
if mkdir ${lock_dir}
then ${echo} "x - created lock directory ${lock_dir}."
else ${echo} "x - failed to create lock directory ${lock_dir}."
exit 1
fi
# ============= Makefile ==============
if test -n "${keep_file}" && test -f 'Makefile'
then
${echo} "x - SKIPPING Makefile (file already exists)"

else
${echo} "x - extracting Makefile (text)"
sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
#
# Copyright (C) 2018 Michael Heimpold <***@heimpold.de>
# Modified 2020 by Wojciech M. Zabolotny <***@gmail.com> - added python3-gpiod
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
X
include $(TOPDIR)/rules.mk
X
PKG_NAME:=libgpiod
PKG_VERSION:=1.3
PKG_RELEASE:=1
X
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/software/libs/libgpiod/
PKG_HASH:=6ec837f23e8f2196e5976dec4ac81403170830075e7f33ede1394eaf67f2e962
X
PKG_LICENSE:=LGPL-2.1+
PKG_LICENSE_FILES:=COPYING
X
PKG_MAINTAINER:=Michael Heimpold <***@heimpold.de>
X
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
X
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/python/python3-package.mk
X
ifneq ($(CONFIG_PACKAGE_python3-gpiod),)
CONFIGURE_ARGS += --enable-bindings-python
endif
X
ifneq ($(CONFIG_PACKAGE_gpiod-tools),)
CONFIGURE_ARGS += --enable-tools
endif
X
define Package/libgpiod
X SECTION:=libs
X CATEGORY:=Libraries
X URL:=https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
X TITLE:=Library for interacting with Linux's GPIO character device
X DEPENDS:=@GPIO_SUPPORT @(LINUX_4_9||LINUX_4_14)
endef
X
define Package/libgpiod/description
X C library for interacting with the linux GPIO character device
X (gpiod stands for GPIO device).
endef
X
define Package/python3-gpiod
X SECTION:=lang-python
X CATEGORY:=Languages
X SUBMENU:=Python
X TITLE:=Python bindings for GPIO
X DEPENDS:=+libgpiod +python3
endef
X
define Package/python3-gpiod/description
X Python bindings for libgpiod (linux GPIO character device)
endef
X
define Package/gpiod-tools
X SECTION:=utils
X CATEGORY:=Utilities
X TITLE:=Tools for interacting with GPIO pins
X DEPENDS:=+libgpiod
endef
X
define Package/gpiod-tools/description
X Tools for interacting with the linux GPIO character device
X (gpiod stands for GPIO device).
endef
X
define Build/InstallDev
X $(INSTALL_DIR) $(1)/usr/include
X $(CP) $(PKG_INSTALL_DIR)/usr/include/gpiod.h $(1)/usr/include/
X
X $(INSTALL_DIR) $(1)/usr/lib
X $(CP) $(PKG_INSTALL_DIR)/usr/lib/libgpiod.{so*,a} $(1)/usr/lib/
X
X $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
X $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libgpiod.pc $(1)/usr/lib/pkgconfig/
endef
X
define Package/python3-gpiod/install
X $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/
X $(CP) $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/site-packages/gpiod.so $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/
endef
X
define Package/libgpiod/install
X $(INSTALL_DIR) $(1)/usr/lib
X $(CP) $(PKG_INSTALL_DIR)/usr/lib/libgpiod.so* $(1)/usr/lib/
endef
X
define Package/gpiod-tools/install
X $(INSTALL_DIR) $(1)/usr/bin
X $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
endef
X
$(eval $(call BuildPackage,libgpiod))
$(eval $(call BuildPackage,gpiod-tools))
$(eval $(call BuildPackage,python3-gpiod))
SHAR_EOF
(set 20 20 05 08 22 38 29 'Makefile'
eval "${shar_touch}") && \
chmod 0644 'Makefile'
if test $? -ne 0
then ${echo} "restore of Makefile failed"
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'Makefile': 'MD5 check failed'
) << \SHAR_EOF
6cf6e62fd78971b24f1ae3a633cd7697 Makefile
SHAR_EOF

else
test `LC_ALL=C wc -c < 'Makefile'` -ne 2831 && \
${echo} "restoration warning: size of 'Makefile' is not 2831"
fi
fi
if rm -fr ${lock_dir}
then ${echo} "x - removed lock directory ${lock_dir}."
else ${echo} "x - failed to remove lock directory ${lock_dir}."
exit 1
fi
exit 0
w***@gmail.com
2020-05-08 21:06:44 UTC
Permalink
OK. It seems that this modification has been already introduced, however only in a newer version of the libpiod package:

https://github.com/openwrt/packages/issues/11096
https://github.com/openwrt/packages/commit/96c244ea67c43f66365f038b2887c8f730deec44

Regards,
Wojtek
Tarek Ahmed
2020-05-09 03:50:59 UTC
Permalink
I was looking for something like this, thank you.

Loading...