1 ################################################################################
3 # Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
7 # This source code is subject to NVIDIA ownership rights under U.S. and
8 # international Copyright laws.
10 # NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
11 # CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
12 # IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
13 # REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
14 # MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
15 # IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
16 # OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
17 # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
18 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
19 # OR PERFORMANCE OF THIS SOURCE CODE.
21 # U.S. Government End Users. This source code is a "commercial item" as
22 # that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
23 # "commercial computer software" and "commercial computer software
24 # documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
25 # and is provided to the U.S. Government only as a commercial end item.
26 # Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
27 # 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
28 # source code with only those rights set forth herein.
30 ################################################################################
32 # findcudalib.mk is used to find the locations for CUDA libraries and other
33 # Unix Platforms. This is supported Mac OS X and Linux.
35 ################################################################################
37 # OS Name (Linux or Darwin)
38 OSUPPER = $(shell uname -s 2>/dev/null | tr "[:lower:]" "[:upper:]")
39 OSLOWER = $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
41 # Flags to detect 32-bit or 64-bit OS platform
42 OS_SIZE = $(shell uname -m | sed -e "s/i.86/32/" -e "s/x86_64/64/" -e "s/armv7l/32/")
43 OS_ARCH = $(shell uname -m | sed -e "s/i386/i686/")
45 # Determine OS platform and unix distribution
46 ifeq ("$(OSLOWER)","linux")
47 # first search lsb_release
48 DISTRO = $(shell lsb_release -i -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
49 DISTVER = $(shell lsb_release -r -s 2>/dev/null)
51 # second search and parse /etc/issue
52 DISTRO = $(shell more /etc/issue | awk '{print $$1}' | sed '1!d' | sed -e "/^$$/d" 2>/dev/null | tr "[:upper:]" "[:lower:]")
53 DISTVER= $(shell more /etc/issue | awk '{print $$2}' | sed '1!d' 2>/dev/null
56 # third, we can search in /etc/os-release or /etc/{distro}-release
57 DISTRO = $(shell awk '/ID/' /etc/*-release | sed 's/ID=//' | grep -v "VERSION" | grep -v "ID" | grep -v "DISTRIB")
58 DISTVER= $(shell awk '/DISTRIB_RELEASE/' /etc/*-release | sed 's/DISTRIB_RELEASE=//' | grep -v "DISTRIB_RELEASE")
62 # search at Darwin (unix based info)
63 DARWIN = $(strip $(findstring DARWIN, $(OSUPPER)))
65 SNOWLEOPARD = $(strip $(findstring 10.6, $(shell egrep "<string>10\.6" /System/Library/CoreServices/SystemVersion.plist)))
66 LION = $(strip $(findstring 10.7, $(shell egrep "<string>10\.7" /System/Library/CoreServices/SystemVersion.plist)))
67 MOUNTAIN = $(strip $(findstring 10.8, $(shell egrep "<string>10\.8" /System/Library/CoreServices/SystemVersion.plist)))
68 MAVERICKS = $(strip $(findstring 10.9, $(shell egrep "<string>10\.9" /System/Library/CoreServices/SystemVersion.plist)))
73 CLANG ?= /usr/bin/clang
75 ifeq ("$(OSUPPER)","LINUX")
76 NVCC ?= $(CUDA_PATH)/bin/nvcc -ccbin $(GCC)
78 # for some newer versions of XCode, CLANG is the default compiler, so we need to include this
80 NVCC ?= $(CUDA_PATH)/bin/nvcc -ccbin $(CLANG)
81 STDLIB ?= -stdlib=libstdc++
83 NVCC ?= $(CUDA_PATH)/bin/nvcc -ccbin $(GCC)
87 # Take command line flags that override any of these settings
101 ifeq ("$(OSUPPER)","LINUX")
102 # Each Linux Distribuion has a set of different paths. This applies especially when using the Linux RPM/debian packages
103 ifeq ("$(DISTRO)","ubuntu")
104 CUDAPATH ?= /usr/lib/nvidia-current
105 CUDALINK ?= -L/usr/lib/nvidia-current
108 ifeq ("$(DISTRO)","kubuntu")
109 CUDAPATH ?= /usr/lib/nvidia-current
110 CUDALINK ?= -L/usr/lib/nvidia-current
113 ifeq ("$(DISTRO)","debian")
114 CUDAPATH ?= /usr/lib/nvidia-current
115 CUDALINK ?= -L/usr/lib/nvidia-current
118 ifeq ("$(DISTRO)","suse")
122 DFLT_PATH = /usr/lib64
129 ifeq ("$(DISTRO)","suse linux")
133 DFLT_PATH = /usr/lib64
140 ifeq ("$(DISTRO)","opensuse")
144 DFLT_PATH = /usr/lib64
151 ifeq ("$(DISTRO)","fedora")
153 CUDAPATH ?= /usr/lib64/nvidia
154 CUDALINK ?= -L/usr/lib64/nvidia
155 DFLT_PATH = /usr/lib64
162 ifeq ("$(DISTRO)","redhat")
164 CUDAPATH ?= /usr/lib64/nvidia
165 CUDALINK ?= -L/usr/lib64/nvidia
166 DFLT_PATH = /usr/lib64
173 ifeq ("$(DISTRO)","red")
175 CUDAPATH ?= /usr/lib64/nvidia
176 CUDALINK ?= -L/usr/lib64/nvidia
177 DFLT_PATH = /usr/lib64
184 ifeq ("$(DISTRO)","redhatenterpriseworkstation")
186 CUDAPATH ?= /usr/lib64/nvidia
187 CUDALINK ?= -L/usr/lib64/nvidia
188 DFLT_PATH ?= /usr/lib64
192 DFLT_PATH ?= /usr/lib
195 ifeq ("$(DISTRO)","centos")
197 CUDAPATH ?= /usr/lib64/nvidia
198 CUDALINK ?= -L/usr/lib64/nvidia
199 DFLT_PATH = /usr/lib64
208 CUDAPATH := /usr/arm-linux-gnueabihf/lib
209 CUDALINK := -L/usr/arm-linux-gnueabihf/lib
210 ifneq ($(TARGET_FS),)
211 CUDAPATH += $(TARGET_FS)/usr/lib/nvidia-current
212 CUDALINK += -L$(TARGET_FS)/usr/lib/nvidia-current
216 # Search for Linux distribution path for libcuda.so
217 CUDALIB ?= $(shell find $(CUDAPATH) $(DFLT_PATH) -name libcuda.so -print 2>/dev/null)
219 ifeq ("$(CUDALIB)",'')
220 $(info >>> WARNING - CUDA Driver libcuda.so is not found. Please check and re-install the NVIDIA driver. <<<)
224 # This would be the Mac OS X path if we had to do anything special