#!/usr/bin/env bash # Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== # This sub Makefile compiles the TensorFlow Android Inference library. This is # designed to be used as a sub Makefile with tensorflow/contrib/makefile/Makefile. # # You can build targets in this file by including this sub makefile like: # $ make -f tensorflow/contrib/makefile/Makefile TARGET=ANDROID \ # SUB_MAKEFILES=\ # $(pwd)/tensorflow/contrib/makefile/sub_makefiles/android/Makefile.in \ # (optional: NDK_ROOT=) libtensorflow_inference.so \ # libtensorflow_demo.so # libtensorflow_inference.so: # This library provides TensorFlow support on Android via the Java API and # TensorFlowInferenceInterface. # It should be packaged into the Android APK along with the Java counterparts # under tensorflow/java and tensorflow/contrib/android/java. INFERENCE_SRCS := \ tensorflow/c/tf_status_helper.cc \ tensorflow/c/checkpoint_reader.cc \ tensorflow/c/test_op.cc \ tensorflow/c/c_api.cc \ tensorflow/java/src/main/native/exception_jni.cc \ tensorflow/java/src/main/native/graph_jni.cc \ tensorflow/java/src/main/native/operation_builder_jni.cc \ tensorflow/java/src/main/native/operation_jni.cc \ tensorflow/java/src/main/native/session_jni.cc \ tensorflow/java/src/main/native/tensorflow_jni.cc \ tensorflow/java/src/main/native/tensor_jni.cc \ tensorflow/contrib/android/jni/run_stats_jni.cc INFERENCE_OBJS := $(addprefix $(OBJDIR), $(INFERENCE_SRCS:.cc=.o)) INFERENCE_SO_NAME := libtensorflow_inference.so INFERENCE_SO_PATH := $(LIBDIR)$(INFERENCE_SO_NAME) $(INFERENCE_SO_PATH): $(LIB_OBJS) $(INFERENCE_OBJS) $(CUDA_LIB_DEPS) @mkdir -p $(dir $@) $(CXX) $(CXXFLAGS) $(INCLUDES) \ -o $@ $(INFERENCE_OBJS) $(LIB_OBJS) $(TEGRA_LIBS) \ $(LIBFLAGS) $(LDFLAGS) \ -shared -Wl,-soname,$(INFERENCE_SO_NAME) \ $(LIBS) $(CUDA_LIBS) $(INFERENCE_SO_NAME): $(INFERENCE_SO_PATH) # libtensorflow_demo.so: # This library provides the additional native support necessary to run the # Android TensorFlow demo. This includes image colorspace conversion and object # tracking code. It does not provide any TensorFlow functionality itself. DEMO_SRCS := \ tensorflow/examples/android/jni/imageutils_jni.cc \ tensorflow/examples/android/jni/object_tracking/frame_pair.cc \ tensorflow/examples/android/jni/object_tracking/image_neon.cc \ tensorflow/examples/android/jni/object_tracking/keypoint_detector.cc \ tensorflow/examples/android/jni/object_tracking/logging.cc \ tensorflow/examples/android/jni/object_tracking/object_detector.cc \ tensorflow/examples/android/jni/object_tracking/object_tracker.cc \ tensorflow/examples/android/jni/object_tracking/object_tracker_jni.cc \ tensorflow/examples/android/jni/object_tracking/optical_flow.cc \ tensorflow/examples/android/jni/object_tracking/time_log.cc \ tensorflow/examples/android/jni/object_tracking/tracked_object.cc \ tensorflow/examples/android/jni/object_tracking/utils_neon.cc \ tensorflow/examples/android/jni/rgb2yuv.cc \ tensorflow/examples/android/jni/yuv2rgb.cc DEMO_OBJS := $(addprefix $(OBJDIR), $(DEMO_SRCS:.cc=.o)) DEMO_SO_NAME := libtensorflow_demo.so DEMO_SO_PATH := $(LIBDIR)$(DEMO_SO_NAME) CXXFLAGS += -DSTANDALONE_DEMO_LIB $(DEMO_SO_PATH): $(DEMO_OBJS) @mkdir -p $(dir $@) $(CXX) $(CXXFLAGS) \ -o $@ $(DEMO_OBJS) \ $(LIBFLAGS) $(LDFLAGS) -shared $(LIBS) $(DEMO_SO_NAME): $(DEMO_SO_PATH)