OSDN Git Service

modified: utilsrc/src/Admin/Makefile
[eos/others.git] / utiltools / X86MAC64 / cuda / samples / 6_Advanced / scalarProd / findcudalib.mk
1 ################################################################################
2 #
3 # Copyright 1993-2013 NVIDIA Corporation.  All rights reserved.
4 #
5 # NOTICE TO USER:   
6 #
7 # This source code is subject to NVIDIA ownership rights under U.S. and 
8 # international Copyright laws.  
9 #
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.  
20 #
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.
29 #
30 ################################################################################
31 #
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.
34 #
35 ################################################################################
36
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:]")
40
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/")
44
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)
50    ifeq ("$(DISTRO)",'') 
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
54    endif
55    ifeq ("$(DISTRO)",'') 
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")
59    endif
60 endif
61
62 # search at Darwin (unix based info)
63 DARWIN = $(strip $(findstring DARWIN, $(OSUPPER)))
64 ifneq ($(DARWIN),)
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)))
69 endif 
70
71 # Common binaries
72 GCC   ?= g++
73 CLANG ?= /usr/bin/clang
74
75 ifeq ("$(OSUPPER)","LINUX")
76      NVCC ?= $(CUDA_PATH)/bin/nvcc -ccbin $(GCC)
77 else
78   # for some newer versions of XCode, CLANG is the default compiler, so we need to include this
79   ifneq ($(MAVERICKS),)
80         NVCC   ?= $(CUDA_PATH)/bin/nvcc -ccbin $(CLANG)
81         STDLIB ?= -stdlib=libstdc++
82   else
83         NVCC   ?= $(CUDA_PATH)/bin/nvcc -ccbin $(GCC)
84   endif
85 endif
86
87 # Take command line flags that override any of these settings
88 ifeq ($(i386),1)
89         OS_SIZE = 32
90         OS_ARCH = i686
91 endif
92 ifeq ($(x86_64),1)
93         OS_SIZE = 64
94         OS_ARCH = x86_64
95 endif
96 ifeq ($(ARMv7),1)
97         OS_SIZE = 32
98         OS_ARCH = armv7l
99 endif
100
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
106         DFLT_PATH  = /usr/lib
107     endif
108     ifeq ("$(DISTRO)","kubuntu")
109         CUDAPATH  ?= /usr/lib/nvidia-current
110         CUDALINK  ?= -L/usr/lib/nvidia-current
111         DFLT_PATH  = /usr/lib
112     endif
113     ifeq ("$(DISTRO)","debian")
114         CUDAPATH  ?= /usr/lib/nvidia-current
115         CUDALINK  ?= -L/usr/lib/nvidia-current
116         DFLT_PATH  = /usr/lib
117     endif
118     ifeq ("$(DISTRO)","suse")
119       ifeq ($(OS_SIZE),64)
120         CUDAPATH  ?=
121         CUDALINK  ?=
122         DFLT_PATH  = /usr/lib64
123       else
124         CUDAPATH  ?=
125         CUDALINK  ?=
126         DFLT_PATH  = /usr/lib
127       endif
128     endif
129     ifeq ("$(DISTRO)","suse linux")
130       ifeq ($(OS_SIZE),64)
131         CUDAPATH  ?=
132         CUDALINK  ?=
133         DFLT_PATH  = /usr/lib64
134       else
135         CUDAPATH  ?=
136         CUDALINK  ?=
137         DFLT_PATH  = /usr/lib
138       endif
139     endif
140     ifeq ("$(DISTRO)","opensuse")
141       ifeq ($(OS_SIZE),64)
142         CUDAPATH  ?=
143         CUDALINK  ?=
144         DFLT_PATH  = /usr/lib64
145       else
146         CUDAPATH  ?=
147         CUDALINK  ?=
148         DFLT_PATH  = /usr/lib
149       endif
150     endif
151     ifeq ("$(DISTRO)","fedora")
152       ifeq ($(OS_SIZE),64)
153         CUDAPATH  ?= /usr/lib64/nvidia
154         CUDALINK  ?= -L/usr/lib64/nvidia
155         DFLT_PATH  = /usr/lib64
156       else
157         CUDAPATH  ?=
158         CUDALINK  ?=
159         DFLT_PATH  = /usr/lib
160       endif
161     endif
162     ifeq ("$(DISTRO)","redhat")
163       ifeq ($(OS_SIZE),64)
164         CUDAPATH  ?= /usr/lib64/nvidia
165         CUDALINK  ?= -L/usr/lib64/nvidia
166         DFLT_PATH  = /usr/lib64
167       else
168         CUDAPATH  ?=
169         CUDALINK  ?=
170         DFLT_PATH  = /usr/lib
171       endif
172     endif
173     ifeq ("$(DISTRO)","red")
174       ifeq ($(OS_SIZE),64)
175         CUDAPATH  ?= /usr/lib64/nvidia
176         CUDALINK  ?= -L/usr/lib64/nvidia
177         DFLT_PATH  = /usr/lib64
178       else
179         CUDAPATH  ?=
180         CUDALINK  ?=
181         DFLT_PATH  = /usr/lib
182       endif
183     endif
184     ifeq ("$(DISTRO)","redhatenterpriseworkstation")
185       ifeq ($(OS_SIZE),64)
186         CUDAPATH  ?= /usr/lib64/nvidia
187         CUDALINK  ?= -L/usr/lib64/nvidia
188         DFLT_PATH ?= /usr/lib64
189       else
190         CUDAPATH  ?=
191         CUDALINK  ?=
192         DFLT_PATH ?= /usr/lib
193       endif
194     endif
195     ifeq ("$(DISTRO)","centos")
196       ifeq ($(OS_SIZE),64)
197         CUDAPATH  ?= /usr/lib64/nvidia
198         CUDALINK  ?= -L/usr/lib64/nvidia
199         DFLT_PATH  = /usr/lib64
200       else
201         CUDAPATH  ?=
202         CUDALINK  ?=
203         DFLT_PATH  = /usr/lib
204       endif
205     endif
206   
207     ifeq ($(ARMv7),1)
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
213       endif 
214     endif
215
216   # Search for Linux distribution path for libcuda.so
217   CUDALIB ?= $(shell find $(CUDAPATH) $(DFLT_PATH) -name libcuda.so -print 2>/dev/null)
218
219   ifeq ("$(CUDALIB)",'')
220       $(info >>> WARNING - CUDA Driver libcuda.so is not found.  Please check and re-install the NVIDIA driver. <<<)
221       EXEC=@echo "[@]"
222   endif
223 else
224   # This would be the Mac OS X path if we had to do anything special
225 endif
226