]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - tidl/tidl-api.git/blob - tidl_api/make.inc
classification: Support different network models
[tidl/tidl-api.git] / tidl_api / make.inc
1 # Copyright (c) 2018 Texas Instruments Incorporated - http://www.ti.com/
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
11 # * Neither the name of Texas Instruments Incorporated nor the
12 # names of its contributors may be used to endorse or promote products
13 # derived from this software without specific prior written permission.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 # THE POSSIBILITY OF SUCH DAMAGE.
27 # ------------------------------------------------------------------------------
28 #
29 # If making on x86 assume cross compile for ARM target
30 #
31 # Environment:
32 # - PSDK_LINUX : Target Linux Processor SDK for automatic configuration. If not
33 #   set, must specify paths in overridable variables.
34 # - PSDK_RTOS : Target RTOS Processor SDK for automatic configuration. If not
35 #   set and required (for persistent examples), must specify paths in
36 #   overridable variables.
37 #
38 # Overrides:
39 # - TARGET_ROOTDIR : ARM Linux devkit/filesystem
40 # - HOST_ROOTDIR : x86_64 Linux devkit
41 # - TI_OCL_INSTALL : TI OpenCL installation prefix if not from PSDK or target
42 #   devkit/filesystem
43 # - TI_OCL_CGT_INSTALL : TI C6x CGT installation directory if not from PSDK or
44 #   host devkit
45 # - CXX : C++ cross-compiler if not from PSDK or host devkit
46 # - CLOCL : clocl if not from PSDK, host devkit, or TI_OCL_INSTALL
47 #
48 # ------------------------------------------------------------------------------
49 #
50 # If making on the ARM target, use native compilation
51 #
52 # Overrides:
53 # - TI_OCL_INSTALL : TI OpenCL installation prefix if not system package
54 # - TI_OCL_CGT_INSTALL : TI C6x CGT installation directory if not system package
55 #
56 # ------------------------------------------------------------------------------
57 #
58 # PYBIND11_INC_DIR : Path to pybind11 include files used to generate Python
59 #                    bindings for TIDL API. E.g. pybind11.git/include
60 #
61 # ------------------------------------------------------------------------------
63 PYBIND11_INC_DIR ?= pybind11/include
65 ifeq ($(MAKECMDGOALS),clean)
66     # config not required for clean
68 else
69 ifneq (,$(findstring 86, $(shell uname -m)))
70     # --------------------------------------------------------------------------
71     # host cross-compilation
73     ifeq ($(PSDK_LINUX),)
74         ifeq ($(TARGET_ROOTDIR),)
75             $(error Environment variable PSDK_LINUX is not defined; set it to point at the target Linux PSDK for automatic configuration or set TARGET_ROOTDIR to the ARM Linux devkit/filesystem)
76         endif
77     endif
79     export TARGET_ROOTDIR?=$(PSDK_LINUX)/linux-devkit/sysroots/armv7ahf-neon-linux-gnueabi
80     export HOST_ROOTDIR?=$(PSDK_LINUX)/linux-devkit/sysroots/x86_64-arago-linux
81     export TI_OCL_INSTALL?=$(TARGET_ROOTDIR)
82     export TI_OCL_CGT_INSTALL?=$(HOST_ROOTDIR)/usr/share/ti/cgt-c6x
84     # --------------------------------------------------------------------------
85     # ARM GCC
87     ifeq ($(origin CXX),default)
88         CXX=
89     endif
90     ifeq ($(CXX),)
91         ifneq ($(wildcard $(HOST_ROOTDIR)/usr/bin/arm-linux-gnueabihf-g++),)
92             CXX=$(HOST_ROOTDIR)/usr/bin/arm-linux-gnueabihf-g++
93         else
94             CXX=arm-linux-gnueabihf-g++
95         endif
96     endif
98     ifneq ($(shell which $(firstword $(CXX)) >/dev/null 2>/dev/null; echo $$?),0)
99         $(error C++ cross-compiler $(CXX) not found. Set PSDK_LINUX to point to the target Linux PSDK for automatic configuration, set HOST_ROOTDIR to the x86_64 Linux devkit, or add the compiler bin directory to PATH.)
100     endif
102     # --------------------------------------------------------------------------
103     # clocl
105     ifeq ($(CLOCL),)
106         ifneq ($(wildcard $(TI_OCL_INSTALL)/usr/share/ti/opencl/bin/x86/clocl),)
107             CLOCL=$(TI_OCL_INSTALL)/usr/share/ti/opencl/bin/x86/clocl
108         else
109             ifneq ($(wildcard $(HOST_ROOTDIR)/usr/bin/clocl),)
110                 CLOCL=$(HOST_ROOTDIR)/usr/bin/clocl
111             else
112                 CLOCL=clocl
113             endif
114         endif
115     endif
117     ifneq ($(shell which $(firstword $(CLOCL)) >/dev/null 2>/dev/null; echo $$?),0)
118         $(error CLOCL $(CLOCL) not found. Set PSDK_LINUX to point to the target Linux PSDK for automatic configuration, set HOST_ROOTDIR to the x86_64 Linux devkit, or add the clocl bin directory to PATH.)
119     endif
121     # --------------------------------------------------------------------------
122     # cl6x
124     ifeq ($(CL6X),)
125         ifneq ($(wildcard $(TI_OCL_CGT_INSTALL)/bin/cl6x),)
126             CL6X_BIN=$(TI_OCL_CGT_INSTALL)/bin
127             CL6X=$(TI_OCL_CGT_INSTALL)/bin/cl6x
128         else
129             ifneq ($(wildcard $(HOST_ROOTDIR)/usr/bin/cl6x),)
130                 CL6X_BIN=$(HOST_ROOTDIR)/usr/bin
131                 CL6X=$(HOST_ROOTDIR)/usr/bin/cl6x
132             else
133                 CL6X=cl6x
134             endif
135         endif
136     endif
138     ifneq ($(shell which $(firstword $(CL6X)) >/dev/null 2>/dev/null; echo $$?),0)
139         $(error $(CL6X) not found. Set PSDK_LINUX to point to the target Linux PSDK for automatic configuration, set HOST_ROOTDIR to the x86_64 Linux devkit, or set TI_OCL_CGT_INSTALL to a TI C6x CGT installation.)
140     endif
142     # --------------------------------------------------------------------------
144     # gcc ARM cross compiler will not, by default, search the host's
145     # /usr/include.  Explicitly specify here to find dependent vendor headers
146     # Do not use /usr/include on host machine, it might have different gcc
147     # versions and could cause problems.
148     CXXFLAGS += "--sysroot=$(TARGET_ROOTDIR)"
149     CXXFLAGS += -I$(TI_OCL_INSTALL)/usr/include
150     CXXFLAGS += -I$(TARGET_ROOTDIR)/usr/include
152     # If cross-compiling, provide path to dependent ARM libraries on the
153     # target filesystem
154     LDFLAGS += "--sysroot=$(TARGET_ROOTDIR)"
156     LDFLAGS += -L$(TI_OCL_INSTALL)/usr/lib -L$(TARGET_ROOTDIR)/lib -L$(TARGET_ROOTDIR)/usr/lib -Wl,-rpath-link,$(TARGET_ROOTDIR)/lib -Wl,-rpath-link,$(TARGET_ROOTDIR)/usr/lib
158 else
159     # --------------------------------------------------------------------------
160     # target native compilation
162     CXX      = g++
163     CXXFLAGS += -I$(TI_OCL_INSTALL)/usr/include
164     LDFLAGS  += -L$(TI_OCL_INSTALL)/usr/lib
165     LIBS     += -lbfd
167     # --------------------------------------------------------------------------
168     # clocl
170     ifeq ($(CLOCL),)
171         ifneq ($(wildcard $(TI_OCL_INSTALL)/usr/bin/clocl),)
172             CLOCL=$(TI_OCL_INSTALL)/usr/bin/clocl
173         else
174             CLOCL=clocl
175         endif
176     endif
178     ifneq ($(shell which $(firstword $(CLOCL)) >/dev/null 2>/dev/null; echo $$?),0)
179         $(error CLOCL $(CLOCL) not found. Set TI_OCL_INSTALL to a valid TI OpenCL installation prefix.)
180     endif
182     # --------------------------------------------------------------------------
183     # cl6x
185     ifeq ($(CL6X),)
186         ifneq ($(wildcard $(TI_OCL_CGT_INSTALL)/bin/cl6x),)
187             CL6X_BIN=$(TI_OCL_CGT_INSTALL)/bin
188             CL6X=$(TI_OCL_CGT_INSTALL)/bin/cl6x
189         else
190             CL6X=cl6x
191         endif
192     endif
194     ifneq ($(shell which $(firstword $(CL6X)) >/dev/null 2>/dev/null; echo $$?),0)
195         $(error $(CL6X) not found. Set TI_OCL_CGT_INSTALL to a TI C6x CGT installation.)
196     endif
197 endif
199 # --------------------------------------------------------------------------
200 # RTOS components
201 # Used by persistent_* examples
203 ifeq ($(USE_RTOS),1)
204     ifeq ($(PSDK_RTOS),)
205         tmp_NEED_RTOS=
206         ifeq ($(XDC_DIR),)
207             tmp_NEED_RTOS += XDC_DIR
208         endif
210         ifneq ($(tmp_NEED_RTOS),)
211             $(error Environment variable PSDK_RTOS is not defined; set PSDK_RTOS to point at the target RTOS PSDK for automatic configuration or set $(tmp_NEED_RTOS) to the corresponding package directories)
212         endif
213     endif
215     XDC_DIR   ?= $(wildcard $(PSDK_RTOS)/xdc*)/packages
216     BIOS_DIR  ?= $(TARGET_ROOTDIR)/usr/share/ti/ti-sysbios-tree/packages
217     IPC_DIR   ?= $(TARGET_ROOTDIR)/usr/share/ti/ti-ipc-tree/packages
219     DSP_INCLUDE += -I$(BIOS_DIR) -I$(XDC_DIR) -I$(IPC_DIR)
220 endif
222 endif
224 # --------------------------------------------------------------------------
226 # clocl executes "cl6x" directly; make sure it uses the selected CGT
227 ifneq ($(CL6X_BIN),)
228     CLOCL:=env PATH=$(CL6X_BIN):$(PATH) $(CLOCL)
229 endif
231 ifneq ($(TI_OCL_CGT_INSTALL),)
232     DSP_INCLUDE += -I$(TI_OCL_CGT_INSTALL)/include
233 endif
235 DSP_INCLUDE += -I$(TI_OCL_INSTALL)/usr/share/ti/opencl
236 DSP_INCLUDE += -I$(TARGET_ROOTDIR)/usr/share/ti/opencl
237 DSP_INCLUDE += -I$(TARGET_ROOTDIR)/usr/share/ti/cgt-c6x/include
239 CL6X += -mv6600 --abi=eabi $(DSP_INCLUDE)
241 LIBS  = -lOpenCL -locl_util
243 %.o: %.cpp
244         @echo Compiling $<
245         $(CXX) -c $(CXXFLAGS) $<
247 %.o: %.c
248         @echo Compiling $<
249         $(CXX) -c $(CXXFLAGS) $<
251 %.obj: %.c
252         @echo Compiling $<
253         $(CL6X) -c $(CL6XFLAGS) $<
255 $(EXE):
257 clean::
258         @$(RM) -f $(EXE) *.o *.obj *.out *.asm *.if *.opt *.bc *.objc *.map *.bin *.dsp_h
260 test: clean $(EXE)
261         @echo Running   $(EXE)
262         @./$(EXE) >/dev/null || echo "FAILED!!!"