Tomato: re-integrate ceres library with updates needed for tracking improvement
[blender.git] / extern / libmv / bundle.sh
1 #!/bin/sh
2
3 #BRANCH="keir"
4 #BRANCH="Matthias-Fauconneau"
5 BRANCH="Nazg-Gul"
6
7 if [ -d ./.svn ]; then
8   echo "This script is supposed to work only when using git-svn"
9   exit 1
10 fi
11
12 repo="git://github.com/${BRANCH}/libmv.git"
13 tmp=`mktemp -d`
14
15 git clone $repo $tmp/libmv
16
17 #git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log --since="1 month ago" > ChangeLog
18 git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log -n 50 > ChangeLog
19
20 for p in `cat ./patches/series`; do
21   echo "Applying patch $p..."
22   cat ./patches/$p | patch -d $tmp/libmv -p1
23 done
24
25 rm -rf libmv
26 rm -rf `find third_party/ -mindepth 1 -maxdepth 1 | grep -v ceres | grep -v CMake | grep -c SCons`
27
28 cat "files.txt" | while read f; do
29   mkdir -p `dirname $f`
30   cp $tmp/libmv/src/$f $f
31 done
32
33 rm -rf $tmp
34
35 chmod 664 ./third_party/glog/src/windows/*.cc ./third_party/glog/src/windows/*.h ./third_party/glog/src/windows/glog/*.h
36
37 sources=`find ./libmv -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t/' | sort -d`
38 headers=`find ./libmv -type f -iname '*.h' | sed -r 's/^\.\//\t/' | sort -d`
39
40 third_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep -v glog | grep -v ceres | sed -r 's/^\.\//\t/' | sort -d`
41 third_headers=`find ./third_party -type f -iname '*.h' | grep -v glog | grep -v ceres | sed -r 's/^\.\//\t/' | sort -d`
42
43 third_glog_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep glog | grep -v windows | sed -r 's/^\.\//\t\t/' | sort -d`
44 third_glog_headers=`find ./third_party -type f -iname '*.h' | grep glog | grep -v windows | sed -r 's/^\.\//\t\t/' | sort -d`
45
46 src_dir=`find ./libmv -type f -iname '*.cc' -exec dirname {} \; -or -iname '*.cpp' -exec dirname {} \; -or -iname '*.c' -exec dirname {} \; | sed -r 's/^\.\//\t/' | sort -d | uniq`
47 src_third_dir=`find ./third_party -type f -iname '*.cc' -exec dirname {} \; -or -iname '*.cpp' -exec dirname {} \; -or -iname '*.c' -exec dirname {} \;  | grep -v ceres | sed -r 's/^\.\//\t/'  | sort -d | uniq`
48 src=""
49 win_src=""
50 for x in $src_dir $src_third_dir; do
51   t=""
52
53   if test  `echo "$x" | grep -c glog ` -eq 1; then
54     continue;
55   fi
56
57   if stat $x/*.cpp > /dev/null 2>&1; then
58     t="src += env.Glob('`echo $x'/*.cpp'`')"
59   fi
60
61   if stat $x/*.c > /dev/null 2>&1; then
62     if [ -z "$t" ]; then
63       t="src += env.Glob('`echo $x'/*.c'`')"
64     else
65       t="$t + env.Glob('`echo $x'/*.c'`')"
66     fi
67   fi
68
69   if stat $x/*.cc > /dev/null 2>&1; then
70     if [ -z "$t" ]; then
71       t="src += env.Glob('`echo $x'/*.cc'`')"
72     else
73       t="$t + env.Glob('`echo $x'/*.cc'`')"
74     fi
75   fi
76
77   if test `echo $x | grep -c windows ` -eq 0; then
78     if [ -z "$src" ]; then
79       src=$t
80     else
81       src=`echo "$src\n$t"`
82     fi
83   else
84     if [ -z "$win_src" ]; then
85       win_src=`echo "    $t"`
86     else
87       win_src=`echo "$win_src\n    $t"`
88     fi
89   fi
90 done
91
92 cat > CMakeLists.txt << EOF
93 # ***** BEGIN GPL LICENSE BLOCK *****
94 #
95 # This program is free software; you can redistribute it and/or
96 # modify it under the terms of the GNU General Public License
97 # as published by the Free Software Foundation; either version 2
98 # of the License, or (at your option) any later version.
99 #
100 # This program is distributed in the hope that it will be useful,
101 # but WITHOUT ANY WARRANTY; without even the implied warranty of
102 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
103 # GNU General Public License for more details.
104 #
105 # You should have received a copy of the GNU General Public License
106 # along with this program; if not, write to the Free Software Foundation,
107 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
108 #
109 # The Original Code is Copyright (C) 2011, Blender Foundation
110 # All rights reserved.
111 #
112 # Contributor(s): Blender Foundation,
113 #                 Sergey Sharybin
114 #
115 # ***** END GPL LICENSE BLOCK *****
116
117 # NOTE: This file is automatically generated by bundle.sh script
118 #       If you're doing changes in this file, please update template
119 #       in that script too
120
121 set(INC
122         .
123         ../Eigen3
124         third_party/ssba
125         third_party/ldl/Include
126         ../colamd/Include
127         third_party/ceres/include
128 )
129
130 set(INC_SYS
131         \${PNG_INCLUDE_DIR}
132         \${ZLIB_INCLUDE_DIRS}
133 )
134
135
136 # XXX - FIXME
137 # this is a momentary hack to find unwind.h in 10.6.sdk
138 if(APPLE)
139         if(\${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.6")
140                 list(APPEND INC_SYS
141                         \${CMAKE_OSX_SYSROOT}/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include
142                 )
143         endif()
144 endif()
145 # XXX - END
146
147
148 set(SRC
149         libmv-capi.cpp
150 ${sources}
151
152 ${third_sources}
153
154         libmv-capi.h
155 ${headers}
156
157 ${third_headers}
158 )
159
160 if(WIN32)
161         list(APPEND SRC
162                 third_party/glog/src/logging.cc
163                 third_party/glog/src/raw_logging.cc
164                 third_party/glog/src/utilities.cc
165                 third_party/glog/src/vlog_is_on.cc
166                 third_party/glog/src/windows/port.cc
167
168                 third_party/glog/src/utilities.h
169                 third_party/glog/src/stacktrace_generic-inl.h
170                 third_party/glog/src/stacktrace.h
171                 third_party/glog/src/stacktrace_x86_64-inl.h
172                 third_party/glog/src/base/googleinit.h
173                 third_party/glog/src/base/mutex.h
174                 third_party/glog/src/base/commandlineflags.h
175                 third_party/glog/src/stacktrace_powerpc-inl.h
176                 third_party/glog/src/stacktrace_x86-inl.h
177                 third_party/glog/src/config.h
178                 third_party/glog/src/stacktrace_libunwind-inl.h
179                 third_party/glog/src/windows/glog/raw_logging.h
180                 third_party/glog/src/windows/glog/vlog_is_on.h
181                 third_party/glog/src/windows/glog/logging.h
182                 third_party/glog/src/windows/glog/log_severity.h
183                 third_party/glog/src/windows/port.h
184                 third_party/glog/src/windows/config.h
185         )
186
187         list(APPEND INC
188                 third_party/glog/src/windows
189         )
190
191         if(NOT MINGW)
192                 list(APPEND INC
193                         third_party/msinttypes
194                 )
195         endif()
196
197         if(MSVC)
198                 set(MSVC_OFLAGS O1 O2 Ox)
199                 foreach(FLAG \${MSVC_OFLAGS})
200                         string(REPLACE "\${FLAG}" "Od" CMAKE_CXX_FLAGS_RELEASE "\${CMAKE_CXX_FLAGS_RELEASE}")
201                         string(REPLACE "\${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "\${CMAKE_C_FLAGS_RELWITHDEBINFO}")
202                 endforeach()
203         endif()
204 else()
205         list(APPEND SRC
206 ${third_glog_sources}
207
208 ${third_glog_headers}
209         )
210
211         list(APPEND INC
212                 third_party/glog/src
213         )
214 endif()
215
216 add_definitions(
217         -DV3DLIB_ENABLE_SUITESPARSE
218         -DGOOGLE_GLOG_DLL_DECL=
219 )
220
221 blender_add_lib(extern_libmv "\${SRC}" "\${INC}" "\${INC_SYS}")
222
223 add_subdirectory(third_party)
224 EOF
225
226 cat > SConscript << EOF
227 #!/usr/bin/python
228
229 # NOTE: This file is automatically generated by bundle.sh script
230 #       If you're doing changes in this file, please update template
231 #       in that script too
232
233 import sys
234 import os
235
236 Import('env')
237
238 defs = []
239
240 cflags_libmv = Split(env['CFLAGS'])
241 ccflags_libmv = Split(env['CCFLAGS'])
242 cxxflags_libmv = Split(env['CXXFLAGS'])
243
244 defs.append('V3DLIB_ENABLE_SUITESPARSE')
245 defs.append('GOOGLE_GLOG_DLL_DECL=')
246
247 src = env.Glob("*.cpp")
248 $src
249
250 incs = '. ../Eigen3 third_party/ceres/include'
251 incs += ' ' + env['BF_PNG_INC']
252 incs += ' ' + env['BF_ZLIB_INC']
253
254 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
255     incs += ' ./third_party/glog/src/windows ./third_party/glog/src/windows/glog'
256     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
257         incs += ' ./third_party/msinttypes'
258 ${win_src}
259     src += ['./third_party/glog/src/logging.cc', './third_party/glog/src/raw_logging.cc', './third_party/glog/src/utilities.cc', './third_party/glog/src/vlog_is_on.cc']
260     src += ['./third_party/glog/src/windows/port.cc']
261
262     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
263         cflags_libmv.append('/Od')
264         ccflags_libmv.append('/Od')
265         cxxflags_libmv.append('/Od')
266
267         if not env['BF_DEBUG']:
268             defs.append('NDEBUG')
269     else:
270         if not env['BF_DEBUG']:
271             cflags_libmv += Split(env['REL_CFLAGS'])
272             ccflags_libmv += Split(env['REL_CCFLAGS'])
273             cxxflags_libmv += Split(env['REL_CXXFLAGS'])
274 else:
275     src += env.Glob("third_party/glog/src/*.cc")
276     incs += ' ./third_party/glog/src'
277     if not env['BF_DEBUG']:
278         cflags_libmv += Split(env['REL_CFLAGS'])
279         ccflags_libmv += Split(env['REL_CCFLAGS'])
280         cxxflags_libmv += Split(env['REL_CXXFLAGS'])
281
282 incs += ' ./third_party/ssba ./third_party/ldl/Include ../colamd/Include'
283
284 env.BlenderLib ( libname = 'extern_libmv', sources=src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137], compileflags=cflags_libmv, cc_compileflags=ccflags_libmv, cxx_compileflags=cxxflags_libmv )
285
286 SConscript(['third_party/SConscript'])
287 EOF