blob: a52c7662ab1375c1b0a9778b025e16a38b72383a [file] [log] [blame]
Scott Ettinger399f7d02013-09-09 12:54:43 -07001# Ceres Solver - A fast non-linear least squares minimizer
2# Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
3# http://code.google.com/p/ceres-solver/
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7#
8# * Redistributions of source code must retain the above copyright notice,
9# this list of conditions and the following disclaimer.
10# * Redistributions in binary form must reproduce the above copyright notice,
11# this list of conditions and the following disclaimer in the documentation
12# and/or other materials provided with the distribution.
13# * Neither the name of Google Inc. nor the names of its contributors may be
14# used to endorse or promote products derived from this software without
15# specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27# POSSIBILITY OF SUCH DAMAGE.
28#
29# Author: settinger@google.com (Scott Ettinger)
30# keir@google.com (Keir Mierle)
31#
Carlos Hernandez79397c22014-08-07 17:51:38 -070032# Builds Ceres for Android, using the standard toolchain (not
33# standalone). It uses LLVM's libc++ as the standard library. It is a
34# modern BSD licensed implementation of the standard c++ library. We
35# do this to avoid any licensing issues that may arise from using
36# GCC's libstdc++ which is licensed under GPL3.
Scott Ettinger399f7d02013-09-09 12:54:43 -070037#
Carlos Hernandez79397c22014-08-07 17:51:38 -070038# Building
39# --------
Scott Ettinger399f7d02013-09-09 12:54:43 -070040#
Carlos Hernandez79397c22014-08-07 17:51:38 -070041# You will have to specify the environment EIGEN_PATH to point to the
42# Eigen sources when building. For example:
43#
44# EIGEN_PATH=/home/keir/src/eigen-3.0.5 ndk-build -j
45#
46# It is also possible to specify CERES_EXTRA_DEFINES, in case you need
47# to pass more definitions to the C compiler.
48#
49# Using the library
50# -----------------
51# Copy the static library:
52#
53# ../obj/local/armeabi-v7a/libceres.a
54#
55# into your own project, then link it into your binary in your
56# Android.mk file.
57#
58# Reducing binary size
59# --------------------
60# This build includes the Schur specializations, which increase the
61# size of the binary. If you don't need them for your application,
62# consider adding:
Scott Ettinger399f7d02013-09-09 12:54:43 -070063#
64# -DCERES_RESTRICT_SCHUR_SPECIALIZATION
65#
Carlos Hernandez79397c22014-08-07 17:51:38 -070066# to the LOCAL_CFLAGS variable below.
Scott Ettinger399f7d02013-09-09 12:54:43 -070067#
Carlos Hernandez79397c22014-08-07 17:51:38 -070068# Changing the logging library
69# ----------------------------
70# Ceres Solver ships with a replacement for glog that provides a
71# simple and small implementation that builds on Android. However, if
72# you wish to supply a header only version yourself, then you may
73# define CERES_GLOG_DIR to point to it.
Scott Ettinger399f7d02013-09-09 12:54:43 -070074
Angus Kong0ae28bd2013-02-13 14:56:04 -080075LOCAL_PATH := $(call my-dir)
Angus Kong0ae28bd2013-02-13 14:56:04 -080076
Carlos Hernandez79397c22014-08-07 17:51:38 -070077EIGEN_PATH := external/eigen
78CERES_INCLUDE_PATHS := $(CERES_EXTRA_INCLUDES)
79CERES_INCLUDE_PATHS += $(LOCAL_PATH)/internal
80CERES_INCLUDE_PATHS += $(LOCAL_PATH)/internal/ceres
81CERES_INCLUDE_PATHS += $(LOCAL_PATH)/include
82CERES_INCLUDE_PATHS += $(LOCAL_PATH)/config
83
84# Use the alternate glog implementation if provided by the user.
85ifdef CERES_GLOG_DIR
86 CERES_INCLUDE_PATHS += $(CERES_GLOG_DIR)
87else
88 CERES_INCLUDE_PATHS += $(LOCAL_PATH)/internal/ceres/miniglog
89endif
90CERES_SRC_PATH := internal/ceres
91
92
93include $(CLEAR_VARS)
94LOCAL_C_INCLUDES := $(CERES_INCLUDE_PATHS)
95LOCAL_C_INCLUDES += $(EIGEN_PATH)
Angus Kong0ae28bd2013-02-13 14:56:04 -080096
97LOCAL_SDK_VERSION := 17
Carlos Hernandezad78e582014-08-01 14:33:19 -070098LOCAL_NDK_STL_VARIANT := c++_static
Angus Kong0ae28bd2013-02-13 14:56:04 -080099
Angus Kong0ae28bd2013-02-13 14:56:04 -0800100LOCAL_CPP_EXTENSION := .cc
Carlos Hernandez79397c22014-08-07 17:51:38 -0700101LOCAL_CFLAGS := $(CERES_EXTRA_DEFINES) \
102 -DCERES_NO_LAPACK \
103 -DCERES_NO_SUITESPARSE \
104 -DCERES_NO_THREADS \
105 -DCERES_NO_CXSPARSE \
106 -DCERES_STD_UNORDERED_MAP
107
108# The default relase optimization level is O2, but we want O3.
109LOCAL_CFLAGS += -O3 -w
110
111# Set the logging max level to 1.
112LOCAL_CFLAGS += -DMAX_LOG_LEVEL=-1
Angus Kong0ae28bd2013-02-13 14:56:04 -0800113
114# On Android NDK 8b, GCC gives spurrious warnings about ABI incompatibility for
115# which there is no solution. Hide the warning instead.
Scott Ettinger399f7d02013-09-09 12:54:43 -0700116LOCAL_CFLAGS += -Wno-psabi
Angus Kong0ae28bd2013-02-13 14:56:04 -0800117
Carlos Hernandez79397c22014-08-07 17:51:38 -0700118LOCAL_SRC_FILES := $(CERES_SRC_PATH)/array_utils.cc \
119 $(CERES_SRC_PATH)/blas.cc \
120 $(CERES_SRC_PATH)/block_evaluate_preparer.cc \
121 $(CERES_SRC_PATH)/block_jacobian_writer.cc \
122 $(CERES_SRC_PATH)/block_jacobi_preconditioner.cc \
123 $(CERES_SRC_PATH)/block_random_access_dense_matrix.cc \
124 $(CERES_SRC_PATH)/block_random_access_diagonal_matrix.cc \
125 $(CERES_SRC_PATH)/block_random_access_matrix.cc \
126 $(CERES_SRC_PATH)/block_random_access_sparse_matrix.cc \
127 $(CERES_SRC_PATH)/block_sparse_matrix.cc \
128 $(CERES_SRC_PATH)/block_structure.cc \
129 $(CERES_SRC_PATH)/callbacks.cc \
130 $(CERES_SRC_PATH)/canonical_views_clustering.cc \
131 $(CERES_SRC_PATH)/cgnr_solver.cc \
132 $(CERES_SRC_PATH)/compressed_row_jacobian_writer.cc \
133 $(CERES_SRC_PATH)/compressed_row_sparse_matrix.cc \
134 $(CERES_SRC_PATH)/conditioned_cost_function.cc \
135 $(CERES_SRC_PATH)/conjugate_gradients_solver.cc \
136 $(CERES_SRC_PATH)/coordinate_descent_minimizer.cc \
137 $(CERES_SRC_PATH)/corrector.cc \
138 $(CERES_SRC_PATH)/dense_normal_cholesky_solver.cc \
139 $(CERES_SRC_PATH)/dense_qr_solver.cc \
140 $(CERES_SRC_PATH)/dense_sparse_matrix.cc \
141 $(CERES_SRC_PATH)/detect_structure.cc \
142 $(CERES_SRC_PATH)/dogleg_strategy.cc \
143 $(CERES_SRC_PATH)/dynamic_compressed_row_jacobian_writer.cc \
144 $(CERES_SRC_PATH)/dynamic_compressed_row_sparse_matrix.cc \
145 $(CERES_SRC_PATH)/evaluator.cc \
146 $(CERES_SRC_PATH)/file.cc \
147 $(CERES_SRC_PATH)/gradient_checking_cost_function.cc \
148 $(CERES_SRC_PATH)/implicit_schur_complement.cc \
149 $(CERES_SRC_PATH)/iterative_schur_complement_solver.cc \
150 $(CERES_SRC_PATH)/lapack.cc \
151 $(CERES_SRC_PATH)/levenberg_marquardt_strategy.cc \
152 $(CERES_SRC_PATH)/line_search.cc \
153 $(CERES_SRC_PATH)/line_search_direction.cc \
154 $(CERES_SRC_PATH)/line_search_minimizer.cc \
155 $(CERES_SRC_PATH)/linear_least_squares_problems.cc \
156 $(CERES_SRC_PATH)/linear_operator.cc \
157 $(CERES_SRC_PATH)/linear_solver.cc \
158 $(CERES_SRC_PATH)/local_parameterization.cc \
159 $(CERES_SRC_PATH)/loss_function.cc \
160 $(CERES_SRC_PATH)/low_rank_inverse_hessian.cc \
161 $(CERES_SRC_PATH)/minimizer.cc \
162 $(CERES_SRC_PATH)/normal_prior.cc \
163 $(CERES_SRC_PATH)/parameter_block_ordering.cc \
164 $(CERES_SRC_PATH)/partitioned_matrix_view.cc \
165 $(CERES_SRC_PATH)/polynomial.cc \
166 $(CERES_SRC_PATH)/preconditioner.cc \
167 $(CERES_SRC_PATH)/problem.cc \
168 $(CERES_SRC_PATH)/problem_impl.cc \
169 $(CERES_SRC_PATH)/program.cc \
170 $(CERES_SRC_PATH)/reorder_program.cc \
171 $(CERES_SRC_PATH)/residual_block.cc \
172 $(CERES_SRC_PATH)/residual_block_utils.cc \
173 $(CERES_SRC_PATH)/schur_complement_solver.cc \
174 $(CERES_SRC_PATH)/schur_eliminator.cc \
175 $(CERES_SRC_PATH)/schur_jacobi_preconditioner.cc \
176 $(CERES_SRC_PATH)/scratch_evaluate_preparer.cc \
177 $(CERES_SRC_PATH)/solver.cc \
178 $(CERES_SRC_PATH)/solver_impl.cc \
179 $(CERES_SRC_PATH)/sparse_matrix.cc \
180 $(CERES_SRC_PATH)/sparse_normal_cholesky_solver.cc \
181 $(CERES_SRC_PATH)/split.cc \
182 $(CERES_SRC_PATH)/stringprintf.cc \
183 $(CERES_SRC_PATH)/summary_utils.cc \
184 $(CERES_SRC_PATH)/suitesparse.cc \
185 $(CERES_SRC_PATH)/triplet_sparse_matrix.cc \
186 $(CERES_SRC_PATH)/trust_region_minimizer.cc \
187 $(CERES_SRC_PATH)/trust_region_strategy.cc \
188 $(CERES_SRC_PATH)/types.cc \
189 $(CERES_SRC_PATH)/visibility_based_preconditioner.cc \
190 $(CERES_SRC_PATH)/visibility.cc \
191 $(CERES_SRC_PATH)/wall_time.cc \
192 $(CERES_SRC_PATH)/generated/schur_eliminator_d_d_d.cc \
193 $(CERES_SRC_PATH)/generated/schur_eliminator_2_2_2.cc \
194 $(CERES_SRC_PATH)/generated/schur_eliminator_2_2_3.cc \
195 $(CERES_SRC_PATH)/generated/schur_eliminator_2_2_4.cc \
196 $(CERES_SRC_PATH)/generated/schur_eliminator_2_2_d.cc \
197 $(CERES_SRC_PATH)/generated/schur_eliminator_2_3_3.cc \
198 $(CERES_SRC_PATH)/generated/schur_eliminator_2_3_4.cc \
199 $(CERES_SRC_PATH)/generated/schur_eliminator_2_3_9.cc \
200 $(CERES_SRC_PATH)/generated/schur_eliminator_2_3_d.cc \
201 $(CERES_SRC_PATH)/generated/schur_eliminator_2_4_3.cc \
202 $(CERES_SRC_PATH)/generated/schur_eliminator_2_4_4.cc \
203 $(CERES_SRC_PATH)/generated/schur_eliminator_2_4_8.cc \
204 $(CERES_SRC_PATH)/generated/schur_eliminator_2_4_9.cc \
205 $(CERES_SRC_PATH)/generated/schur_eliminator_2_4_d.cc \
206 $(CERES_SRC_PATH)/generated/schur_eliminator_2_d_d.cc \
207 $(CERES_SRC_PATH)/generated/schur_eliminator_4_4_2.cc \
208 $(CERES_SRC_PATH)/generated/schur_eliminator_4_4_3.cc \
209 $(CERES_SRC_PATH)/generated/schur_eliminator_4_4_4.cc \
210 $(CERES_SRC_PATH)/generated/schur_eliminator_4_4_d.cc \
211 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_d_d_d.cc \
212 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_2.cc \
213 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_3.cc \
214 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_4.cc \
215 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_d.cc \
216 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_3.cc \
217 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_4.cc \
218 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_9.cc \
219 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_d.cc \
220 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_3.cc \
221 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_4.cc \
222 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_8.cc \
223 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_9.cc \
224 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_d.cc \
225 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_d_d.cc \
226 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_4_4_2.cc \
227 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_4_4_3.cc \
228 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_4_4_4.cc \
229 $(CERES_SRC_PATH)/generated/partitioned_matrix_view_4_4_d.cc
Angus Kong0ae28bd2013-02-13 14:56:04 -0800230
Carlos Hernandez79397c22014-08-07 17:51:38 -0700231ifndef CERES_GLOG_DIR
232LOCAL_SRC_FILES += $(CERES_SRC_PATH)/miniglog/glog/logging.cc
233endif
234
235LOCAL_MODULE := libceres
Angus Kong0ae28bd2013-02-13 14:56:04 -0800236include $(BUILD_STATIC_LIBRARY)