diff mbox

help please

Message ID CAAfO8NyXP5-PFMoC3bN7v8NRD+jzcvgtBfgZZXKijGquARhU8Q@mail.gmail.com
State Not Applicable
Headers show

Commit Message

Mike King July 12, 2016, 7:06 p.m. UTC
I am hoping someone will help me.  I am trying to create a package for
linux-gpib.  I can get it to configure and build but not install.  I
have listed below the package files that I have created.  I am not an
autotools expert.


###Config.in FILE###
config BR2_PACKAGE_LINUX_GPIB
bool "linux-gpib"
help
 The Linux GPIB Package is a support package for GPIB (IEEE 488) hardware.
 The package contains kernel driver modules, and a C user-space library with
 Guile, Perl, PHP, Python and TCL bindings. The API of the C library is intended
 to be compatible with National Instrument's GPIB library.

 http://linux-gpib.sourceforge.net

###linux-gpib.mk FILE###
################################################################################
#
# linux-gpib
#
################################################################################

LINUX_GPIB_VERSION = 4.0.3
LINUX_GPIB_SITE =
http://downloads.sourceforge.net/project/linux-gpib/linux-gpib%20for%203.x.x%20and%202.6.x%20kernels/$(LINUX_GPIB_VERSION)
LINUX_GPIB_SOURCE = linux-gpib-$(LINUX_GPIB_VERSION).tar.gz
LINUX_GPIB_LICENSE = GPLv2
LINUX_GPIB_LICENSE_FILES = COPYING
LINUX_GPIB_INSTALL_STAGING = YES
LINUX_GPIB_AUTORECONF = YES
LINUX_GPIB_CONF_OPTS = --with-linux-srcdir=$(LINUX_DIR)/

$(eval $(autotools-package))


###PATCH FILE###

Comments

Yann E. MORIN July 12, 2016, 8:44 p.m. UTC | #1
Mike, All,

On 2016-07-12 15:06 -0400, Mike King spake thusly:
> I am hoping someone will help me.  I am trying to create a package for
> linux-gpib.

Reminds me of something... ;-)

> I can get it to configure and build but not install. I
> have listed below the package files that I have created. I am not an
> autotools expert.

Pease also paste the build log (what you see in the console) starting
with the message:

    >>> linux-gpib 4.0.3 Configuring

up until the bottom.

> ###Config.in FILE###
> config BR2_PACKAGE_LINUX_GPIB
> bool "linux-gpib"

It also probably needs to depend on BR2_LINUX_KERNEL since it builds a
kernel module.

> help
>  The Linux GPIB Package is a support package for GPIB (IEEE 488) hardware.
>  The package contains kernel driver modules, and a C user-space library with
>  Guile, Perl, PHP, Python and TCL bindings. The API of the C library is intended
>  to be compatible with National Instrument's GPIB library.
> 
>  http://linux-gpib.sourceforge.net
> 
> ###linux-gpib.mk FILE###
> ################################################################################
> #
> # linux-gpib
> #
> ################################################################################
> 
> LINUX_GPIB_VERSION = 4.0.3
> LINUX_GPIB_SITE = http://downloads.sourceforge.net/project/linux-gpib/linux-gpib%20for%203.x.x%20and%202.6.x%20kernels/$(LINUX_GPIB_VERSION)
> LINUX_GPIB_SOURCE = linux-gpib-$(LINUX_GPIB_VERSION).tar.gz
> LINUX_GPIB_LICENSE = GPLv2
> LINUX_GPIB_LICENSE_FILES = COPYING
> LINUX_GPIB_INSTALL_STAGING = YES
> LINUX_GPIB_AUTORECONF = YES
> LINUX_GPIB_CONF_OPTS = --with-linux-srcdir=$(LINUX_DIR)/
> 
> $(eval $(autotools-package))

Nothing really awfull here. Looks sane.

> ###PATCH FILE###
> --- linux-gpib-4.0.3/configure.ac 2016-04-09 13:34:55.000000000 +0000
> +++ linux-gpib-4.0.3/configure.ac.new 2016-07-05 01:37:47.524290832 +0000
> @@ -30,9 +30,10 @@
>  [ISODATE=`date +%Y-%m-%d`]
>  AC_SUBST([ISODATE])
> 
> -AC_CHECK_FILE([util/.scm_version.tmp],
> -  [SCM_VERSION=[$VERSION"\ [r"`cat util/.scm_version.tmp`"]"]],
> -  [SCM_VERSION=$VERSION])
> +#AC_CHECK_FILE([util/.scm_version.tmp],
> +#  [SCM_VERSION=[$VERSION"\ [r"`cat util/.scm_version.tmp`"]"]],
> +#  [SCM_VERSION=$VERSION])
> +SCM_VERSION=4.0.3
> 
>  AC_SUBST(SCM_VERSION)
> 
> --- linux-gpib-4.0.3/drivers/Makefile.am 2016-04-09 09:33:14.000000000 -0400
> +++ linux-gpib-4.0.3/drivers/Makefile.am.new 2016-07-09 11:13:37.356298300 -0400
> @@ -28,7 +28,7 @@
>   CC="$(LINUX_CC) -I@abs_top_srcdir@
> -I@abs_top_srcdir@/drivers/gpib/include -I@abs_top_srcdir@/include" \
>   SUBDIRS="$(GPIB_ABS_MODULE_SUBDIR)"
> 
> -install-data-hook: device-file-check /etc/gpib.conf
> +install-data-hook:
>   $(MAKE) -C $(LINUX_SRCDIR) V=1 modules_install\
>   CC="$(LINUX_CC) -I@abs_top_srcdir@ -I@abs_top_srcdir@/driver/include
> -I@abs_top_srcdir@/include" \
>   SUBDIRS="$(GPIB_ABS_MODULE_SUBDIR)" INSTALL_MOD_DIR="gpib"

Hmm... If this command is actually executed at install time, then it
looks like it is trying to install in the build machine's modules dir,
since it does not specify INSTALL_MOD_PATH

Is that the command that fails?

As stated above, please post the full build log, starting with the
configure message. It will easier to help if we can *see* the actual
error.

Otherwise, we also have an infrastructure to build a kernel module,
similar to the other package infras. Look for 'kernel-module' in the
manual.

Regards,
Yann E. MORIN.

> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Yann E. MORIN July 13, 2016, 6:21 p.m. UTC | #2
Mike, All,

On 2016-07-12 17:05 -0400, Mike King spake thusly:
> I have attached the build log.  I am now having compile errors.
> Before it was using the host kernel headers.  I "fixed" that by adding
> _CONF_OPTS line.

OK, so I've had a quick look at your build log, and it looks like
linux-gpib is quite a mess and will be difficult to package properly.

So, first, let's look at the configure log:

    Checking Linux kernel directory... ok
    checking Linux kernel compile flags... FATAL: /home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/util/linux_flags/fake.o has no symtab?
    make[3]: *** [__modpost] Error 1
    make[2]: *** [modules] Error 2
    configure: WARNING: Failed to get compile flags from Linux kernel directory.
    ok
    checking for arm-buildroot-linux-uclibcgnueabihf-gcc... /home/vagrant/buildroot-2016.05/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-gcc

This sounds like it is incorrectly looking for Linux directory for the
build system and/or kernel-land headers. Besides, it did not already
checked for the cross-compiler, as we can see that it does so *after*,
so it is probably using the host compiler at that point (and this will
be confirmed later during the build, see below...).

That one will be very difficult to fix, especially since their
configure.ac is very badly written:

   90 dnl get compile flags for modules from linux kernel source tree
   91 AC_MSG_CHECKING([Linux kernel compile flags])
   92 FLAGDIR=$(pwd)/util/linux_flags
   93 env LDFLAGS="" CFLAGS="" make --quiet -C ${LINUX_SRCDIR} V=1 SUBDIRS=${FLAGDIR} LINUXDIR=${LINUX_SRCDIR} modules > /dev/null
   94 if [[ $? != 0 ]]; then
   95     AC_MSG_WARN([Failed to get compile flags from Linux kernel directory.])
   96 fi
   97 AC_MSG_RESULT([ok])

Since it is not using standard and not passing the compiler, we can't
override it will configure flags or any ac_cv_* variable. :-(

That will be tough to fix. Unless this is not really needed in fact, and
we can in fact pass the expected values in the environment or some such
afterwards. And it seems we could do that, as the intermediate file
generated in this command (util/linux_flags/flags) is only used later to
actually build the driver. So we don;t need it at configure time, and
the check can very well fail, we don;t care (but it is nonetheless
completely borked).

And then, it means we can also probably use our kernel-module infra as
well to build the kernel module instead of letting their weirdly borked
buildsystem do it.

Then not much of interest, until it starts trying to build the kernel
module. And there, everything goes down hill pretty quick (lines slightly
reformatted by me):

    /usr/bin/make -C /home/vagrant/buildroot-2016.05/output/build/linux-26f3b72a9c049be10e6af196252283e1f6ab9d1f/ V=1 modules\
        CC="gcc -I/home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3 
                -I/home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/drivers/gpib/include
                -I/home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/include" \
        CONFIG_GPIB_ISA="no" \
        SUBDIRS="/home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/drivers/gpib"

Bing, it uses the host compiler! That's just so utterly broken... :-/

And then (again, reformatted and elided by me):

    gcc -I/home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3
        -I/home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/drivers/gpib/include
        -I/home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/include
        -Wp,-MD,/home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/drivers/gpib/ni_usb/.ni_usb_gpib.o.d
        [--SNIP--]
        -DMODULE  -D"KBUILD_STR(s)=#s"
        -D"KBUILD_BASENAME=KBUILD_STR(ni_usb_gpib)"
        -D"KBUILD_MODNAME=KBUILD_STR(ni_usb_gpib)" -c -o
        /home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/drivers/gpib/ni_usb/.tmp_ni_usb_gpib.o
        /home/vagrant/buildroot-2016.05/output/build/linux-gpib-4.0.3/drivers/gpib/ni_usb/ni_usb_gpib.c

So, really, it *is* using the host compiler, and there is no way, with
their infrastructure, to tell them to use another one. Definitely broken
beyond repair...

So, all we have to do is:
  - convince it not to try to build the kernel module,
  - build it ourselves with our kernel-module infra.

I'll try to have a deeper look latter... Dinner now. :-)

If you hang around on IRC tonight UTC+2, we can talk about it, too.

Regards,
Yann E. MORIN.
Yann E. MORIN July 14, 2016, 6:07 p.m. UTC | #3
Mike, All,

[Please, keep the list in Cc: when you reply]

On 2016-07-14 02:11 -0400, Mike King spake thusly:
> Buildroot can now build and install the package minus the drivers of
> course.  Thanks again!

So, I've done some work to build the kernel modules, too. It works now,
but it was far from being easy.

linux-gpib uses such a weird, deviously-twisted buildsystem, that
building the kernel modules, especially in cross-compilation, is not
trivial:

  - they forget to pass correct include paths;

  - they override standard kernel headers because they want to provide
    legacy handling (but even fail at that).

I've done a few patches to fix that (and the rest of the install
procedure, btw) so that linux-gpib now should work, except for the
language bindings, that are yet another challenge to address... :-/

You'll find my branch updated there:

    https://github.com/yann-morin-1998/buildroot/commits/yem/linux-gpib

Regards,
Yann E. MORIN.
diff mbox

Patch

--- linux-gpib-4.0.3/configure.ac 2016-04-09 13:34:55.000000000 +0000
+++ linux-gpib-4.0.3/configure.ac.new 2016-07-05 01:37:47.524290832 +0000
@@ -30,9 +30,10 @@ 
 [ISODATE=`date +%Y-%m-%d`]
 AC_SUBST([ISODATE])

-AC_CHECK_FILE([util/.scm_version.tmp],
-  [SCM_VERSION=[$VERSION"\ [r"`cat util/.scm_version.tmp`"]"]],
-  [SCM_VERSION=$VERSION])
+#AC_CHECK_FILE([util/.scm_version.tmp],
+#  [SCM_VERSION=[$VERSION"\ [r"`cat util/.scm_version.tmp`"]"]],
+#  [SCM_VERSION=$VERSION])
+SCM_VERSION=4.0.3

 AC_SUBST(SCM_VERSION)

--- linux-gpib-4.0.3/drivers/Makefile.am 2016-04-09 09:33:14.000000000 -0400
+++ linux-gpib-4.0.3/drivers/Makefile.am.new 2016-07-09 11:13:37.356298300 -0400
@@ -28,7 +28,7 @@ 
  CC="$(LINUX_CC) -I@abs_top_srcdir@
-I@abs_top_srcdir@/drivers/gpib/include -I@abs_top_srcdir@/include" \
  SUBDIRS="$(GPIB_ABS_MODULE_SUBDIR)"

-install-data-hook: device-file-check /etc/gpib.conf
+install-data-hook:
  $(MAKE) -C $(LINUX_SRCDIR) V=1 modules_install\
  CC="$(LINUX_CC) -I@abs_top_srcdir@ -I@abs_top_srcdir@/driver/include
-I@abs_top_srcdir@/include" \
  SUBDIRS="$(GPIB_ABS_MODULE_SUBDIR)" INSTALL_MOD_DIR="gpib"