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 MAJOR_VER=0
28 MINOR_VER=1
29 PATCH_VER=0
31 ifeq ($(shell git rev-parse --short HEAD 2>&1 1>/dev/null; echo $$?),0)
32 BUILD_SHA?=$(shell git rev-parse --short HEAD)
33 endif
35 LIB_NAME = tidl_api.a
36 DSP_SRCFILE = dsp/ocl_wrapper.cl
37 DSP_OUTFILE = dsp/ocl_wrapper.dsp_h
38 LIB_IMGUTIL_NAME = tidl_imgutil.a
40 all: $(LIB_NAME) $(LIB_IMGUTIL_NAME)
42 include make.inc
43 RM = rm
44 AR = ar
47 SRCS = ocl_device.cpp configuration_parser.cpp configuration.cpp\
48 executor.cpp execution_object.cpp trace.cpp util.cpp
49 SRCS_IMGUTIL = imgutil.cpp
51 OBJS = $(SRCS:.cpp=.o)
52 OBJS_IMGUTIL = $(SRCS_IMGUTIL:.cpp=.o)
54 HOST_SRC_FILES = $(addprefix src/,$(SRCS))
55 HOST_OBJ_FILES = $(addprefix obj/,$(OBJS))
56 HOST_SRC_IMGUTIL_FILES = $(addprefix src/,$(SRCS_IMGUTIL))
57 HOST_OBJ_IMGUTIL_FILES = $(addprefix obj/,$(OBJS_IMGUTIL))
59 HEADERS = src/common_defines.h src/executor_impl.h src/ocl_device.h
60 HEADERS += src/parameters.h src/tidl_create_params.h src/trace.h src/util.h
61 HEADERS += inc/configuration.h inc/execution_object.h inc/executor.h
62 HEADERS += inc/imgutil.h
64 .PHONY: $(BUILD_ID)
65 BUILD_ID := -D_BUILD_VER=$(shell echo "" | \
66 awk '{ printf ("%02d.%02d.%02d", $(MAJOR_VER), \
67 $(MINOR_VER), $(PATCH_VER)); }') \
68 -D_BUILD_SHA=$(BUILD_SHA)
71 ifeq ($(BUILD), debug)
72 CXXFLAGS += -Og -g -ggdb
73 else
74 CXXFLAGS += -O3
75 endif
77 CXXFLAGS += -std=c++11 -Wall -Werror -Wno-error=ignored-attributes
78 CXXFLAGS += -I$(TI_OCL_INSTALL)/usr/share/ti/opencl
79 CXXFLAGS += -I$(TARGET_ROOTDIR)/usr/share/ti/opencl
80 CXXFLAGS += -Isrc -Iinc
81 CXXFLAGS += $(BUILD_ID)
83 $(DSP_OUTFILE): $(DSP_SRCFILE)
84 $(MAKE) -C dsp
86 src/ocl_device.cpp: $(DSP_OUTFILE)
87 touch $@
89 obj/%.o: src/%.cpp $(HEADERS)
90 @mkdir -p obj
91 @echo Compiling $< ...
92 $(CXX) -c $(CXXFLAGS) $< -o $@
94 $(LIB_NAME): $(HOST_OBJ_FILES)
95 $(AR) cr $@ $(HOST_OBJ_FILES)
98 $(LIB_IMGUTIL_NAME): CXXFLAGS += $(shell pkg-config --cflags opencv)
100 $(LIB_IMGUTIL_NAME): $(HOST_OBJ_IMGUTIL_FILES)
101 $(AR) cr $@ $(HOST_OBJ_IMGUTIL_FILES)
103 clean::
104 $(MAKE) -C dsp clean
105 $(RM) -f $(LIB_NAME) $(HOST_OBJ_FILES)
106 $(RM) -f $(LIB_IMGUTIL_NAME) $(HOST_OBJ_IMGUTIL_FILES)
107 $(RM) -rf obj