Public bug reported: When building alsa-source using:
$ sudo fakeroot debian/rules binary_modules which causes configure to set the module destination as: checking for directory to store kernel modules... /lib/modules/#define The build fails: /usr/bin/make DESTDIR=/usr/src/modules/alsa-driver/debian/alsa-modules-#define LINUX_VERSION_CODE 132630 install-modules make[1]: Entering directory `/usr/src/modules/alsa-driver' make[1]: *** No rule to make target `LINUX_VERSION_CODE'. Stop. make[1]: Leaving directory `/usr/src/modules/alsa-driver' make: *** [install-stamp] Error 2 debian/rules tries to work out the source kernel version by using sed to strip text from line 1 of $(KSRC)/include/linux/version.h but that entry is LINUX_VERSION_CODE, a numeric of the form "123456" not a version string as uname -r reports of the form "2.6.22-14-generic". As a result: $ fakeroot debian/rules echo-vars I've been configured using: - Kernel source of /usr/src/linux - Kernel version of #define LINUX_VERSION_CODE 132630 - Kernel revision of unknown - C compiler of gcc - Make options of - Version of 1.0.14-1ubuntu2 KVERS "#define LINUX_VERSION_CODE 132630" is inserted into many settings during configure and make. ----- /usr/src/linux/include/linux/version.h ----- #define LINUX_VERSION_CODE 132630 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) ----- ----- /usr/src/modules/alsa-driver/debian/rules ----- # If they didn't set $(KVERS), see if we can do it for them. ifeq ($(KVERS),unknown) ifneq "$(wildcard $(KSRC)/include/linux/version.h)" "" KVERS = $(shell head -1 $(KSRC)/include/linux/version.h | sed 's/.*"\(.*\)"$$/\1/') endif endif ----- An alternative method would be to read the target of the /usr/src/linux symbolic link, although this won't work if the user over-rides KSRC: ifeq ($(origin KSRC),file) KVERS = $(shell ls -ld $(KSRC) | sed 's/.*linux-headers-\(.*\)$$/\1/') endif If the symbolic link isn't available then the script needs to convert LINUX_VERSION_CODE to KVERS format. GNU 'make' doesn't provide built-in math functions required to do that (bitwise-AND and bitwise-shift) and we can't rely on the shell being BASH in order to use its math functions. The solution seems to be to incorporate both methods, using the sym-link if KSRC hasn't been over-ridden, and otherwise use LINUX_VERSION_CODE by compiling and calling a small conversion utility (lvc2kvers). The modification to debian/rules: ----- debian/rules ----- # If they didn't set $(KVERS), see if we can do it for them. ifeq ($(KVERS),unknown) ifneq "$(wildcard $(KSRC)/include/linux/version.h)" "" # if source directory hasn't been over-ridden ifeq ($(origin KSRC),file) # attempt to get symbolic link target LNKVERS = $(shell ls -ld $(KSRC) | sed 's/.*linux-headers-\(.*\)$$/\1/') # test whether directory exists ifeq ($(shell sh -c "test -e /lib/modules/$(LNKVERS) && echo \"EXISTS\""),EXISTS) # correct to use directory name as kernel version KVERS = $(LNKVERS) endif endif ifeq ($(KVERS),unknown) # KVERS still not set, so use LINUX_VERSION_CODE to determine KVERS # extract the LINUX_VERSION_CODE LVC = $(shell head -1 $(KSRC)/include/linux/version.h | sed 's/.* \([0-9]*\)$$/\1/') # compile the converter source code CONV = $(shell $(CC) debian/lvc2kvers.c -o debian/lvc2kvers ) # call the converter LVCKVERS = $(shell debian/lvc2kvers $(LVC) ) # only set KVERS if LVCKVERS isn't empty ifneq ($(LVCKVERS)unset,unset) KVERS = $(LVCKVERS) endif # NOTE: KVERS might not exist as a directory in /lib/modules/ endif endif endif ----- The lvc2kvers utility to do the conversion that is compiled when debian/rules runs: ----- debian/lvc2kvers.c ----- /* Convert LINUX_VERSION_CODE to KVERS format Copyright 2008 TJ <[EMAIL PROTECTED]> Licensed under the GNU GPL. See debian/copyright for license terms. */ #include <stdlib.h> #include <stdio.h> #include <errno.h> int main(int argc, char **argv, char **env) { int ret = 1; // default is to report an error long linux_version_code = 0; int major, minor, step; if (argc > 1) { linux_version_code = strtol(argv[1], NULL, 10); if (errno != ERANGE && errno != EINVAL) { ret = 0; step = linux_version_code & 0xff; minor = (linux_version_code & 0xff00) >> 8; major = (linux_version_code & 0xff0000) >> 16; printf("%d.%d.%d", major, minor, step); } } if (ret != 0) printf("ERROR"); return ret; } ----- To test/debug add additional reports to the echo-vars target: echo-vars: @echo "I've been configured using:" @echo " - Kernel source of $(KSRC)" @echo " - LN Kernel version of $(LNKVERS)" @echo " - LVC Kernel version of $(LVCKVERS)" @echo " - Kernel version of $(KVERS)" @echo " - Kernel revision of $(KDREV)" @echo " - C compiler of $(CC)" @echo " - Make options of $(MAKE_OPT)" @echo " - Version of $(VERSION)" With the directory existing: $ fakeroot debian/rules echo-vars I've been configured using: - Kernel source of /usr/src/linux - LN Kernel version of 2.6.22-14-generic - LVC Kernel version of - Kernel version of 2.6.22-14-generic - Kernel revision of unknown - C compiler of gcc - Make options of - Version of 1.0.14-1ubuntu2 If the directory doesn't exist: $ fakeroot debian/rules echo-vars I've been configured using: - Kernel source of /usr/src/linux - LN Kernel version of - LVC Kernel version of 2.6.22 - Kernel version of 2.6.22 - Kernel revision of unknown - C compiler of gcc - Make options of - Version of 1.0.14-1ubuntu2 ** Affects: alsa-driver (Ubuntu) Importance: Undecided Status: New -- FTBFS: debian/rules fails to set correct KVERS from include/linux/version.h https://bugs.launchpad.net/bugs/212816 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs