1 #!/usr/bin/env bash 2 # Copyright 2017 The TensorFlow Authors. All Rights Reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # ============================================================================== 16 # This sub Makefile compiles the TensorFlow Android Inference library. This is 17 # designed to be used as a sub Makefile with tensorflow/contrib/makefile/Makefile. 18 # 19 # You can build targets in this file by including this sub makefile like: 20 # $ make -f tensorflow/contrib/makefile/Makefile TARGET=ANDROID \ 21 # SUB_MAKEFILES=\ 22 # $(pwd)/tensorflow/contrib/makefile/sub_makefiles/android/Makefile.in \ 23 # (optional: NDK_ROOT=<ndk_root>) libtensorflow_inference.so \ 24 # libtensorflow_demo.so 25 26 27 # libtensorflow_inference.so: 28 # This library provides TensorFlow support on Android via the Java API and 29 # TensorFlowInferenceInterface. 30 # It should be packaged into the Android APK along with the Java counterparts 31 # under tensorflow/java and tensorflow/contrib/android/java. 32 INFERENCE_SRCS := \ 33 tensorflow/c/tf_status_helper.cc \ 34 tensorflow/c/checkpoint_reader.cc \ 35 tensorflow/c/test_op.cc \ 36 tensorflow/c/c_api.cc \ 37 tensorflow/java/src/main/native/exception_jni.cc \ 38 tensorflow/java/src/main/native/graph_jni.cc \ 39 tensorflow/java/src/main/native/operation_builder_jni.cc \ 40 tensorflow/java/src/main/native/operation_jni.cc \ 41 tensorflow/java/src/main/native/session_jni.cc \ 42 tensorflow/java/src/main/native/tensorflow_jni.cc \ 43 tensorflow/java/src/main/native/tensor_jni.cc \ 44 tensorflow/contrib/android/jni/run_stats_jni.cc 45 46 INFERENCE_OBJS := $(addprefix $(OBJDIR), $(INFERENCE_SRCS:.cc=.o)) 47 48 INFERENCE_SO_NAME := libtensorflow_inference.so 49 INFERENCE_SO_PATH := $(LIBDIR)$(INFERENCE_SO_NAME) 50 51 $(INFERENCE_SO_PATH): $(LIB_OBJS) $(INFERENCE_OBJS) $(CUDA_LIB_DEPS) 52 @mkdir -p $(dir $@) 53 $(CXX) $(CXXFLAGS) $(INCLUDES) \ 54 -o $@ $(INFERENCE_OBJS) $(LIB_OBJS) $(TEGRA_LIBS) \ 55 $(LIBFLAGS) $(LDFLAGS) \ 56 -shared -Wl,-soname,$(INFERENCE_SO_NAME) \ 57 $(LIBS) $(CUDA_LIBS) 58 59 $(INFERENCE_SO_NAME): $(INFERENCE_SO_PATH) 60 61 62 # libtensorflow_demo.so: 63 # This library provides the additional native support necessary to run the 64 # Android TensorFlow demo. This includes image colorspace conversion and object 65 # tracking code. It does not provide any TensorFlow functionality itself. 66 DEMO_SRCS := \ 67 tensorflow/examples/android/jni/imageutils_jni.cc \ 68 tensorflow/examples/android/jni/object_tracking/frame_pair.cc \ 69 tensorflow/examples/android/jni/object_tracking/image_neon.cc \ 70 tensorflow/examples/android/jni/object_tracking/keypoint_detector.cc \ 71 tensorflow/examples/android/jni/object_tracking/logging.cc \ 72 tensorflow/examples/android/jni/object_tracking/object_detector.cc \ 73 tensorflow/examples/android/jni/object_tracking/object_tracker.cc \ 74 tensorflow/examples/android/jni/object_tracking/object_tracker_jni.cc \ 75 tensorflow/examples/android/jni/object_tracking/optical_flow.cc \ 76 tensorflow/examples/android/jni/object_tracking/time_log.cc \ 77 tensorflow/examples/android/jni/object_tracking/tracked_object.cc \ 78 tensorflow/examples/android/jni/object_tracking/utils_neon.cc \ 79 tensorflow/examples/android/jni/rgb2yuv.cc \ 80 tensorflow/examples/android/jni/yuv2rgb.cc 81 82 DEMO_OBJS := $(addprefix $(OBJDIR), $(DEMO_SRCS:.cc=.o)) 83 84 DEMO_SO_NAME := libtensorflow_demo.so 85 DEMO_SO_PATH := $(LIBDIR)$(DEMO_SO_NAME) 86 87 CXXFLAGS += -DSTANDALONE_DEMO_LIB 88 $(DEMO_SO_PATH): $(DEMO_OBJS) 89 @mkdir -p $(dir $@) 90 $(CXX) $(CXXFLAGS) \ 91 -o $@ $(DEMO_OBJS) \ 92 $(LIBFLAGS) $(LDFLAGS) -shared $(LIBS) 93 94 $(DEMO_SO_NAME): $(DEMO_SO_PATH) 95