diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2016-06-19 05:01:41 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2016-06-19 05:01:41 +0200 |
commit | 55dc14eff1b9d3dfad43136774b0d2f3dbe61fd2 (patch) | |
tree | 46f2fdbabac26fa957d70ba293d5142609c5c88f | |
parent | ce7360bfa4cdf51bf46d5cc645a67c4751b9731a (diff) | |
download | nvtrace-55dc14eff1b9d3dfad43136774b0d2f3dbe61fd2.tar.gz nvtrace-55dc14eff1b9d3dfad43136774b0d2f3dbe61fd2.tar.bz2 nvtrace-55dc14eff1b9d3dfad43136774b0d2f3dbe61fd2.tar.xz nvtrace-55dc14eff1b9d3dfad43136774b0d2f3dbe61fd2.zip |
Add makefile
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 46 |
2 files changed, 46 insertions, 1 deletions
@@ -1,7 +1,6 @@ CMakeCache.txt CMakeFiles CMakeScripts -Makefile cmake_install.cmake install_manifest.txt CTestTestfile.cmake diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2b2668f --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +obj-m := nvtrace.o +kmm-objs := nvtrace.o + +KERNELDIR ?= /lib/modules/$(shell uname -r)/build +INSTALLDIR ?= /lib/modules/$(shell uname -r)/kernel/extra +PWD := $(shell pwd) + +EXTRA_CFLAGS += -I$(M)/.. + +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-$$GCC_MAJOR ;\ + CC=`which $$newCC 2>/dev/null` ;\ + if [ $$? -ne 0 ]; then \ + echo "No compiler of $$GCC_MAJOR series is installed" ;\ + exit 1 ;\ + 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 ;\ + $(MAKE) $(CFLAGS) -C $(KERNELDIR) M=$(PWD) CC=$$CC modules + +test: test.c + /usr/local/cuda/bin/nvcc -o test test.c -lOpenCL + +install: + @mkdir -p $(INSTALLDIR) + @echo "INSTALL $(INSTALLDIR)/nvtrace.ko" + @install -m 755 nvtrace.ko $(INSTALLDIR) + +uninstall: + @echo "UNINSTALL $(INSTALLDIR)/nvtrace.ko" + @rm -f $(INSTALLDIR)/nvtrace.ko + +clean: + rm -rf *.o *.ko *.mod.c .*.o.cmd .*.o.tmp .*.ko.cmd .*.o *.symvers modules.order .tmp_versions test |