From 5e52f10edf41ecf464037ac381413042f09fe27f Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 6 Apr 2016 22:17:39 +0200 Subject: Fix building of driver if pcilib is built out-of-source --- CMakeLists.txt | 22 ++++++----- driver/Makefile | 108 ---------------------------------------------------- driver/Makefile.in | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 118 deletions(-) delete mode 100644 driver/Makefile create mode 100644 driver/Makefile.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ef7d21d..f956d3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,7 +163,8 @@ if (${RELEASE} GREATER 0) else (${RELEASE} GREATER 0) set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}") endif (${RELEASE} GREATER 0) -set(CPACK_SOURCE_IGNORE_FILES "/build/;/.bzr/;CMakeFiles;_CPack_Packages;cmake_install.cmake;CPack.*.cmake;CMakeCache.txt;install_manifest.txt;common.mk;pcilib/config.h$;.pc$;/([^d]|d[^r])[^/]*/Makefile;__pycache__;.pyc$;.tar.bz2$;~$;${CPACK_SOURCE_IGNORE_FILES}") +#set(CPACK_SOURCE_IGNORE_FILES "([^d]|d[^r])[^/]*/Makefile;${CPACK_SOURCE_IGNORE_FILES}") +set(CPACK_SOURCE_IGNORE_FILES "/build/;/.bzr/;CMakeFiles;_CPack_Packages;cmake_install.cmake;CPack.*.cmake;CMakeCache.txt;install_manifest.txt;common.mk;pcilib/config.h$;.pc$;Makefile$;__pycache__;.pyc$;.tar.bz2$;~$;${CPACK_SOURCE_IGNORE_FILES}") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}") include(CPack) @@ -204,16 +205,17 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) ) endif(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcitool.spec.in ${CMAKE_CURRENT_BINARY_DIR}/pcitool.spec) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/misc/dkms.conf.in ${CMAKE_CURRENT_BINARY_DIR}/misc/dkms.conf) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/misc/pcitool.pc.in ${CMAKE_CURRENT_BINARY_DIR}/misc/pcitool.pc) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcilib/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/pcilib/config.h) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcilib/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/pcilib/version.h) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile) +configure_file(${CMAKE_SOURCE_DIR}/driver/Makefile.in ${CMAKE_SOURCE_DIR}/driver/Makefile) +configure_file(${CMAKE_SOURCE_DIR}/pcitool.spec.in ${CMAKE_BINARY_DIR}/pcitool.spec) +configure_file(${CMAKE_SOURCE_DIR}/misc/dkms.conf.in ${CMAKE_BINARY_DIR}/misc/dkms.conf) +configure_file(${CMAKE_SOURCE_DIR}/misc/pcitool.pc.in ${CMAKE_BINARY_DIR}/misc/pcitool.pc) +configure_file(${CMAKE_SOURCE_DIR}/pcilib/config.h.in ${CMAKE_BINARY_DIR}/pcilib/config.h) +configure_file(${CMAKE_SOURCE_DIR}/pcilib/version.h.in ${CMAKE_BINARY_DIR}/pcilib/version.h) +configure_file(${CMAKE_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_BINARY_DIR}/docs/Doxyfile) if (NOT DISABLE_SERVERS) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/misc/pcilib_api.service.in ${CMAKE_CURRENT_BINARY_DIR}/misc/pcilib_api.service) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/misc/pcilib_html.service.in ${CMAKE_CURRENT_BINARY_DIR}/misc/pcilib_html.service) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/misc/pcilib.sysconfig.in ${CMAKE_CURRENT_BINARY_DIR}/misc/pcilib.sysconfig) + configure_file(${CMAKE_SOURCE_DIR}/misc/pcilib_api.service.in ${CMAKE_BINARY_DIR}/misc/pcilib_api.service) + configure_file(${CMAKE_SOURCE_DIR}/misc/pcilib_html.service.in ${CMAKE_BINARY_DIR}/misc/pcilib_html.service) + configure_file(${CMAKE_SOURCE_DIR}/misc/pcilib.sysconfig.in ${CMAKE_BINARY_DIR}/misc/pcilib.sysconfig) endif (NOT DISABLE_SERVERS) PYTHON_CLEAN_LIST("${CMAKE_BINARY_DIR}/xml" XML_PY_FILES) diff --git a/driver/Makefile b/driver/Makefile deleted file mode 100644 index f932693..0000000 --- a/driver/Makefile +++ /dev/null @@ -1,108 +0,0 @@ -CONFIG_MODULE_SIG=n - -obj-m := pciDriver.o -pciDriver-objs := base.o dev.o int.o umem.o kmem.o sysfs.o ioctl.o pcibus.o rdma.o - -KERNELVER ?= $(shell uname -r) -KERNELDIR ?= /lib/modules/$(KERNELVER)/build -INSTALLDIR ?= /lib/modules/$(KERNELVER)/extra -MAININSTALLDIR ?= /lib/modules/$(KERNELVER)/kernel/extra -HEADERDIR ?= /lib/modules/$(KERNELVER)/source/include -PWD := $(shell pwd) - -EXTRA_CFLAGS += -I$(M)/.. - -ifdef DUMMY_DEVICE -ifneq ($(DUMMY_DEVICE), 0) - EXTRA_CFLAGS += -DPCIDRIVER_DUMMY_DEVICE -endif -endif - -default: - @KERNEL_GCC_VERSION=`cat /proc/version | head -n1 | cut -d " " -f 7` ;\ - GCC_VERSION=`$(CC) --version | head -n 1 | tr ' ' '\n' | grep -e "[0-9]\+\.[0-9]" | tail -n 1` ;\ - if [ $$KERNEL_GCC_VERSION != $$GCC_VERSION ]; then \ - echo "Kernel is compiled with gcc $$KERNEL_GCC_VERSION, but you are now using $$GCC_VERSION" ;\ - GCC_MAJOR=`echo $$KERNEL_GCC_VERSION | cut -d "." -f 1-2` ;\ - newCC=gcc-$$KERNEL_GCC_VERSION ;\ - CC=`which $$newCC 2>/dev/null` ;\ - if [ $$? -ne 0 ]; then \ - newCC=gcc-$$GCC_MAJOR ;\ - CC=`which $$newCC 2>/dev/null` ;\ - if [ $$? -ne 0 ]; then \ - newCC=`compgen -ac | grep -E ^gcc-4.6 | head -n 1` ;\ - CC=`which $$newCC 2>/dev/null` ;\ - if [ $$? -ne 0 ]; then \ - echo "No compiler of $$GCC_MAJOR series is installed" ;\ - exit 1 ;\ - fi ; \ - fi ;\ - fi ;\ - GCC_VERSION=`$$CC --version | head -n 1 | tr ' ' '\n' | grep -e "[0-9]\+\.[0-9]" | tail -n 1` ;\ - if [ $$KERNEL_GCC_VERSION != $$GCC_VERSION -a -z "$$RELAXED_GCC_CHECK" ]; then \ - echo "The $$GCC_VERSION of $$GCC_MAJOR series is installed" ;\ - exit 1 ;\ - fi ;\ - echo "Setting CC to $$newCC" ;\ - else \ - CC=$(CC) ;\ - fi ;\ - build_path=`pwd` ;\ - build_lastmod=`find . -type f -name '*.[ch]' -printf '%TY/%Tm/%Td %TH:%TM:%TS %p\n' | grep -E -v 'build.h|mod.c' | sort -n | tail -n 1 | cut -d ' ' -f 1-2 | cut -d '.' -f 1` ;\ - build_user=`whoami` ;\ - build_date=`date "+%Y/%m/%d %H:%M:%S"` ;\ - build="Built at $$build_date by $$build_user" ;\ - bzr=`which bzr 2>/dev/null` ;\ - if [ $$? -eq 0 -a -d ../.bzr ]; then \ - build_revision=`bzr revno` ;\ - build_author=`bzr log -r$$build_revision | grep committer | cut -c 12-` ;\ - build_branch=`bzr nick` ;\ - build_changes=`bzr status -SV | cut -c 5- | tr \\\n " "` ;\ - revision="Revision $$build_revision from $$build_branch by $$build_author at $$build_path, last modification from $$build_lastmod" ;\ - /bin/echo -e "#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES \"$$build_changes\"\\n" > build.h ;\ - else \ - grep "#define PCILIB_RELEASE" ../pcilib/build.h &> /dev/null ;\ - if [ $$? -eq 0 ]; then \ - revision="Release \" PCILIB_RELEASE \" (r\" PCILIB_REVISION \") from \" PCILIB_REVISION_BRANCH \" by \" PCILIB_REVISION_AUTHOR \" at $$build_path, last modification from $$build_lastmod" ;\ - /bin/echo -e "#include \"../pcilib/build.h\"\\n#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES PCILIB_REVISION_MODIFICATIONS\n" > build.h ;\ - else \ - revision="Revision r\" PCILIB_REVISION \" from \" PCILIB_REVISION_BRANCH \" by \" PCILIB_REVISION_AUTHOR \" at $$build_path, last modification from $$build_lastmod" ;\ - /bin/echo -e "#include \"../pcilib/build.h\"\\n#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES PCILIB_REVISION_MODIFICATIONS\n" > build.h ;\ - fi ;\ - fi ;\ - $(MAKE) $(CFLAGS) -C $(KERNELDIR) M=$(PWD) CC=$$CC modules - -install: - @mkdir -p $(INSTALLDIR) - @echo "INSTALL $(INSTALLDIR)/pciDriver.ko" - @install -m 755 pciDriver.ko $(INSTALLDIR) - @echo "INSTALL $(INSTALLDIR)/pciDriver.symvers" - @install -m 644 Module.symvers $(INSTALLDIR)/pciDriver.symvers - @echo "INSTALL $(HEADERDIR)/linux/pcidriver.h" - @install -m 644 pcidriver.h $(HEADERDIR)/linux/ - @echo "INSTALL /usr/include/linux/pcidriver.h" - @mkdir -p /usr/include/linux - @install -m 644 ioctl.h /usr/include/linux/pcidriver.h - -install_symvers: - @mkdir -p $(INSTALLDIR) - @echo "INSTALL $(INSTALLDIR)/pciDriver.symvers" - @install -m 644 Module.symvers $(INSTALLDIR)/pciDriver.symvers - @echo "INSTALL $(HEADERDIR)/linux/pcidriver.h" - @install -m 644 pcidriver.h $(HEADERDIR)/linux/ - - -uninstall: - @echo "UNINSTALL $(INSTALLDIR)/pciDriver.ko" - @rm -f $(INSTALLDIR)/pciDriver.ko - @rm -f $(MAININSTALLDIR)/pciDriver.ko - @rm -f $(INSTALLDIR)/pciDriver.symvers - @rm -f $(MAININSTALLDIR)/pciDriver.symvers - @echo "UNINSTALL /usr/include/linux/pcidriver.h" - @rm -rf /usr/include/pciDriver/ - @rm -rf /usr/include/linux/pcidriver.h - @echo "UNINSTALL $(HEADERDIR)/linux/pcidriver.h" - @rm -rf $(HEADERDIR)/linux/pcidriver.h - -clean: - rm -rf *.o *.ko *.mod.c .*.o.cmd .*.o.tmp .*.ko.cmd .*.o *.symvers modules.order .tmp_versions diff --git a/driver/Makefile.in b/driver/Makefile.in new file mode 100644 index 0000000..eea5a7b --- /dev/null +++ b/driver/Makefile.in @@ -0,0 +1,109 @@ +CONFIG_MODULE_SIG=n + +obj-m := pciDriver.o +pciDriver-objs := base.o dev.o int.o umem.o kmem.o sysfs.o ioctl.o pcibus.o rdma.o + +KERNELVER ?= $(shell uname -r) +KERNELDIR ?= /lib/modules/$(KERNELVER)/build +INSTALLDIR ?= /lib/modules/$(KERNELVER)/extra +MAININSTALLDIR ?= /lib/modules/$(KERNELVER)/kernel/extra +HEADERDIR ?= /lib/modules/$(KERNELVER)/source/include +PWD := $(shell pwd) + +#EXTRA_CFLAGS += -I$(M)/.. +EXTRA_CFLAGS += -I${CMAKE_BINARY_DIR}/driver + +ifdef DUMMY_DEVICE +ifneq ($(DUMMY_DEVICE), 0) + EXTRA_CFLAGS += -DPCIDRIVER_DUMMY_DEVICE +endif +endif + +default: + @KERNEL_GCC_VERSION=`cat /proc/version | head -n1 | cut -d " " -f 7` ;\ + GCC_VERSION=`$(CC) --version | head -n 1 | tr ' ' '\n' | grep -e "[0-9]\+\.[0-9]" | tail -n 1` ;\ + if [ $$KERNEL_GCC_VERSION != $$GCC_VERSION ]; then \ + echo "Kernel is compiled with gcc $$KERNEL_GCC_VERSION, but you are now using $$GCC_VERSION" ;\ + GCC_MAJOR=`echo $$KERNEL_GCC_VERSION | cut -d "." -f 1-2` ;\ + newCC=gcc-$$KERNEL_GCC_VERSION ;\ + CC=`which $$newCC 2>/dev/null` ;\ + if [ $$? -ne 0 ]; then \ + newCC=gcc-$$GCC_MAJOR ;\ + CC=`which $$newCC 2>/dev/null` ;\ + if [ $$? -ne 0 ]; then \ + newCC=`compgen -ac | grep -E ^gcc-4.6 | head -n 1` ;\ + CC=`which $$newCC 2>/dev/null` ;\ + if [ $$? -ne 0 ]; then \ + echo "No compiler of $$GCC_MAJOR series is installed" ;\ + exit 1 ;\ + fi ; \ + fi ;\ + fi ;\ + GCC_VERSION=`$$CC --version | head -n 1 | tr ' ' '\n' | grep -e "[0-9]\+\.[0-9]" | tail -n 1` ;\ + if [ $$KERNEL_GCC_VERSION != $$GCC_VERSION -a -z "$$RELAXED_GCC_CHECK" ]; then \ + echo "The $$GCC_VERSION of $$GCC_MAJOR series is installed" ;\ + exit 1 ;\ + fi ;\ + echo "Setting CC to $$newCC" ;\ + else \ + CC=$(CC) ;\ + fi ;\ + build_path=`pwd` ;\ + build_lastmod=`find . -type f -name '*.[ch]' -printf '%TY/%Tm/%Td %TH:%TM:%TS %p\n' | grep -E -v 'build.h|mod.c' | sort -n | tail -n 1 | cut -d ' ' -f 1-2 | cut -d '.' -f 1` ;\ + build_user=`whoami` ;\ + build_date=`date "+%Y/%m/%d %H:%M:%S"` ;\ + build="Built at $$build_date by $$build_user" ;\ + bzr=`which bzr 2>/dev/null` ;\ + if [ $$? -eq 0 -a -d ../.bzr ]; then \ + build_revision=`bzr revno` ;\ + build_author=`bzr log -r$$build_revision | grep committer | cut -c 12-` ;\ + build_branch=`bzr nick` ;\ + build_changes=`bzr status -SV | cut -c 5- | tr \\\n " "` ;\ + revision="Revision $$build_revision from $$build_branch by $$build_author at $$build_path, last modification from $$build_lastmod" ;\ + /bin/echo -e "#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES \"$$build_changes\"\\n" > build.h ;\ + else \ + grep "#define PCILIB_RELEASE" ../pcilib/build.h &> /dev/null ;\ + if [ $$? -eq 0 ]; then \ + revision="Release \" PCILIB_RELEASE \" (r\" PCILIB_REVISION \") from \" PCILIB_REVISION_BRANCH \" by \" PCILIB_REVISION_AUTHOR \" at $$build_path, last modification from $$build_lastmod" ;\ + /bin/echo -e "#include \"../pcilib/build.h\"\\n#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES PCILIB_REVISION_MODIFICATIONS\n" > build.h ;\ + else \ + revision="Revision r\" PCILIB_REVISION \" from \" PCILIB_REVISION_BRANCH \" by \" PCILIB_REVISION_AUTHOR \" at $$build_path, last modification from $$build_lastmod" ;\ + /bin/echo -e "#include \"../pcilib/build.h\"\\n#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES PCILIB_REVISION_MODIFICATIONS\n" > build.h ;\ + fi ;\ + fi ;\ + $(MAKE) $(CFLAGS) -C $(KERNELDIR) M=$(PWD) CC=$$CC modules + +install: + @mkdir -p $(INSTALLDIR) + @echo "INSTALL $(INSTALLDIR)/pciDriver.ko" + @install -m 755 pciDriver.ko $(INSTALLDIR) + @echo "INSTALL $(INSTALLDIR)/pciDriver.symvers" + @install -m 644 Module.symvers $(INSTALLDIR)/pciDriver.symvers + @echo "INSTALL $(HEADERDIR)/linux/pcidriver.h" + @install -m 644 pcidriver.h $(HEADERDIR)/linux/ + @echo "INSTALL /usr/include/linux/pcidriver.h" + @mkdir -p /usr/include/linux + @install -m 644 ioctl.h /usr/include/linux/pcidriver.h + +install_symvers: + @mkdir -p $(INSTALLDIR) + @echo "INSTALL $(INSTALLDIR)/pciDriver.symvers" + @install -m 644 Module.symvers $(INSTALLDIR)/pciDriver.symvers + @echo "INSTALL $(HEADERDIR)/linux/pcidriver.h" + @install -m 644 pcidriver.h $(HEADERDIR)/linux/ + + +uninstall: + @echo "UNINSTALL $(INSTALLDIR)/pciDriver.ko" + @rm -f $(INSTALLDIR)/pciDriver.ko + @rm -f $(MAININSTALLDIR)/pciDriver.ko + @rm -f $(INSTALLDIR)/pciDriver.symvers + @rm -f $(MAININSTALLDIR)/pciDriver.symvers + @echo "UNINSTALL /usr/include/linux/pcidriver.h" + @rm -rf /usr/include/pciDriver/ + @rm -rf /usr/include/linux/pcidriver.h + @echo "UNINSTALL $(HEADERDIR)/linux/pcidriver.h" + @rm -rf $(HEADERDIR)/linux/pcidriver.h + +clean: + rm -rf *.o *.ko *.mod.c .*.o.cmd .*.o.tmp .*.ko.cmd .*.o *.symvers modules.order .tmp_versions -- cgit v1.2.1