linux-gpib-4.0.3-r1.ebuild 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit readme.gentoo-r1 versionator eutils linux-mod autotools perl-functions python-single-r1 toolchain-funcs udev user
  6. DESCRIPTION="Kernel module and driver library for GPIB (IEEE 488.2) hardware"
  7. HOMEPAGE="http://linux-gpib.sourceforge.net/"
  8. SRC_URI="mirror://sourceforge/linux-gpib/${P}.tar.gz
  9. firmware? ( http://linux-gpib.sourceforge.net/firmware/gpib_firmware-2006-11-12.tar.gz )
  10. "
  11. LICENSE="GPL-2"
  12. SLOT="0"
  13. KEYWORDS="amd64 ~arm ~x86"
  14. IUSE="isa pcmcia static debug guile perl php python tcl doc firmware"
  15. COMMONDEPEND="
  16. tcl? ( dev-lang/tcl:0= )
  17. guile? ( dev-scheme/guile:12 )
  18. perl? ( dev-lang/perl:= )
  19. php? ( dev-lang/php:= )
  20. python? ( ${PYTHON_DEPS} )
  21. firmware? ( sys-apps/fxload )"
  22. RDEPEND="${COMMONDEPEND}"
  23. DEPEND="${COMMONDEPEND}
  24. virtual/pkgconfig
  25. doc? ( app-text/docbook-sgml-utils )
  26. perl? ( virtual/perl-ExtUtils-MakeMaker )"
  27. REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
  28. PATCHES=(
  29. "${FILESDIR}"/${PN}-3.2.21-build.patch
  30. "${FILESDIR}"/${PN}-3.2.16-perl.patch
  31. "${FILESDIR}"/${PN}-4.0.3-reallydie.patch
  32. )
  33. pkg_setup () {
  34. use perl && perl_set_version
  35. use python && python_setup
  36. linux-mod_pkg_setup
  37. if kernel_is -lt 2 6 8; then
  38. die "Kernel versions older than 2.6.8 are not supported."
  39. fi
  40. # https://sourceforge.net/tracker/?func=detail&aid=3285657&group_id=42378&atid=432940
  41. if use pcmcia && kernel_is -ge 2 6 38; then
  42. die "pcmcia support is broken on kernels newer 2.6.38"
  43. fi
  44. }
  45. src_prepare () {
  46. default
  47. eautoreconf
  48. }
  49. src_configure() {
  50. set_arch_to_kernel
  51. econf \
  52. $(use_enable isa) \
  53. $(use_enable pcmcia) \
  54. $(use_enable static) \
  55. $(use_enable debug driver-debug) \
  56. $(use_enable guile guile-binding) \
  57. $(use_enable perl perl-binding) \
  58. $(use_enable php php-binding) \
  59. $(use_enable python python-binding) \
  60. $(use_enable tcl tcl-binding) \
  61. $(use_enable doc documentation) \
  62. --with-linux-srcdir=${KV_DIR}
  63. }
  64. src_compile() {
  65. set_arch_to_kernel
  66. FIRM_DIR=/usr/share/usb
  67. emake \
  68. DESTDIR="${D}" \
  69. INSTALL_MOD_PATH="${D}" \
  70. HOTPLUG_USB_CONF_DIR="${D}"/etc/hotplug/usb \
  71. UDEV_RULES_DIR="${D}$(get_udevdir)"/rules.d \
  72. USB_FIRMWARE_DIR="${D}"${FIRM_DIR} \
  73. docdir=/usr/share/doc/${PF}/html
  74. }
  75. src_install() {
  76. set_arch_to_kernel
  77. FIRM_DIR=/usr/share/usb
  78. emake \
  79. DESTDIR="${D}" \
  80. INSTALL_MOD_PATH="${D}" \
  81. HOTPLUG_USB_CONF_DIR="${D}"/etc/hotplug/usb \
  82. UDEV_RULES_DIR="${D}/$(get_udevdir)"/rules.d \
  83. USB_FIRMWARE_DIR="${D}"${FIRM_DIR} \
  84. docdir=/usr/share/doc/${PF}/html install
  85. if use perl; then
  86. einfo "Installing perl module"
  87. cd "${S}"/language/perl || die
  88. DESTDIR=${D} emake install
  89. perl_fix_packlist
  90. perl_delete_emptybsdir
  91. cd "${S}" || die
  92. fi
  93. echo "KERNEL==\"gpib[0-9]*\", MODE=\"0660\", GROUP=\"gpib\"" >> 99-gpib.rules
  94. udev_dorules 99-gpib.rules
  95. dodoc doc/linux-gpib.pdf ChangeLog AUTHORS README* NEWS
  96. insinto /etc
  97. newins util/templates/gpib.conf gpib.conf
  98. newins util/templates/gpib.conf gpib.conf.example
  99. if use pcmcia; then
  100. dodir /etc/pcmcia
  101. insinto /etc/pcmcia
  102. doins "${S}"/etc/pcmcia/*
  103. fi
  104. if use firmware; then
  105. insinto "${FIRM_DIR}"/agilent_82357a
  106. doins "${WORKDIR}"/gpib_firmware-2006-11-12/agilent_82357a/*
  107. insinto "${FIRM_DIR}"/ni_gpib_usb_b
  108. doins "${WORKDIR}"/gpib_firmware-2006-11-12/ni_gpib_usb_b/*
  109. insinto /usr/share/linux-gpib/hp_82341
  110. # do not install precompiled generate_firmware
  111. doins "${WORKDIR}"/gpib_firmware-2006-11-12/hp_82341/{*.bin,README}
  112. fi
  113. # fix rules files
  114. local f
  115. find "${D}$(get_udevdir)"/rules.d -type f -print0 | while read -rd '' f ; do
  116. grep -q "${D}" "${f}" && einfo "File ${f} contains a temporary path, fixing."
  117. sed -i -e "s:${D}:/:g" "${f}"
  118. done
  119. DOC_CONTENTS="
  120. You need to run the 'gpib_config' utility to setup the driver before
  121. you can use it. In order to do it automatically you can add to your
  122. start script something like this (supposing the appropriate driver
  123. is loaded on the startup):
  124. \n
  125. gpib_config --minor 0
  126. \n
  127. To give a user access to the computer's gpib board you will have to add
  128. them to the group 'gpib' or, you could change the permissions on the device
  129. files /dev/gpib[0-15] to something you like better, using 'chmod'
  130. \n
  131. Edit /etc/gpib.conf to match your interface board, and any devices you wish
  132. to open via ibfind(). See the documentation in /usr/share/linux-gpib/html for
  133. more information.
  134. \n
  135. "
  136. if use pcmcia; then
  137. DOC_CONTENTS+='
  138. For PCMCIA cards:\n
  139. All files needed for a PCMCIA board were copied to /etc/pcmcia.
  140. You may wish to edit the options passed to the gpib_config call in the
  141. /etc/pcmcia/linux-gpib-pcmcia script.
  142. You may need to send a SIGHUP signal to the cardmgr daemon to force it
  143. to reload the files in /etc/pcmcia \(alternatively you could use your
  144. pcmcia init.d script to restart the cardmgr, or you could just reboot\).
  145. The driver module will be loaded as needed by the cardmgr.
  146. '
  147. fi
  148. if use firmware; then
  149. DOC_CONTENTS+='
  150. For Agilent \(HP\) 82341C and 82341D cards:
  151. The firmware for these boards is uploaded by passing the appropriate
  152. firmware file from /usr/share/linux-gpib/hp_82341 directory to
  153. gpib_config using the -I or --init-data command line option. Example:\n
  154. gpib_config --minor 0 --init-data /usr/share/linux-gpib/hp_82341/hp_82341c_fw.bin
  155. '
  156. fi
  157. readme.gentoo_create_doc
  158. }
  159. pkg_preinst () {
  160. linux-mod_pkg_preinst
  161. use perl && perl_set_version
  162. enewgroup gpib
  163. }
  164. pkg_postinst () {
  165. linux-mod_pkg_postinst
  166. readme.gentoo_print_elog
  167. local v
  168. for v in ${REPLACING_VERSIONS}; do
  169. if ! version_is_at_least 3.2.21-r1 ${v}; then
  170. ewarn "sci-libs/linux-gpib-3.2.21-r1 introduces incompatible changes to the kernel"
  171. ewarn "interface. You may need to reboot to make sure the newly built driver modules"
  172. ewarn "are used (some of the driver modules cannot be unloaded)."
  173. ewarn "If you do not do this, every gpib call will just result in an error message."
  174. break
  175. fi
  176. done
  177. }