Made collections port compatible with MSVC2008
[blender.git] / extern / libmv / third_party / ceres / bundle.sh
1 #!/bin/sh
2
3 if [ "x$1" = "x--i-really-know-what-im-doing" ] ; then
4   echo Proceeding as requested by command line ...
5 else
6   echo "*** Please run again with --i-really-know-what-im-doing ..."
7   exit 1
8 fi
9
10 repo="https://ceres-solver.googlesource.com/ceres-solver"
11 branch="master"
12 #tag="1.4.0"
13 tag=""
14 tmp=`mktemp -d`
15 checkout="$tmp/ceres"
16
17 GIT="git --git-dir $tmp/ceres/.git --work-tree $checkout"
18
19 git clone $repo $checkout
20
21 if [ $branch != "master" ]; then
22     $GIT checkout -t remotes/origin/$branch
23 else
24   if [ "x$tag" != "x" ]; then
25       $GIT checkout $tag
26   fi
27 fi
28
29 $GIT log -n 50 > ChangeLog
30
31 for p in `cat ./patches/series`; do
32   echo "Applying patch $p..."
33   cat ./patches/$p | patch -d $tmp/ceres -p1
34 done
35
36 find include -type f -not -iwholename '*.svn*' -exec rm -rf {} \;
37 find internal -type f -not -iwholename '*.svn*' -exec rm -rf {} \;
38
39 cat "files.txt" | while read f; do
40   mkdir -p `dirname $f`
41   cp $tmp/ceres/$f $f
42 done
43
44 rm -rf $tmp
45
46 sources=`find ./include ./internal -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t/' | \
47   grep -v -E 'schur_eliminator_[0-9]_[0-9d]_[0-9d].cc' | \
48   grep -v -E 'partitioned_matrix_view_[0-9]_[0-9d]_[0-9d].cc' | sort -d`
49 generated_sources=`find ./include ./internal -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//#\t\t/' | \
50   grep -E 'schur_eliminator_[0-9]_[0-9d]_[0-9d].cc|partitioned_matrix_view_[0-9]_[0-9d]_[0-9d].cc' | sort -d`
51 headers=`find ./include ./internal -type f -iname '*.h' | sed -r 's/^\.\//\t/' | sort -d`
52
53 src_dir=`find ./internal -type f -iname '*.cc' -exec dirname {} \; -or -iname '*.cpp' -exec dirname {} \; -or -iname '*.c' -exec dirname {} \; | sed -r 's/^\.\//\t/' | sort -d | uniq`
54 src=""
55 for x in $src_dir $src_third_dir; do
56   t=""
57
58   if test  `echo "$x" | grep -c glog ` -eq 1; then
59     continue;
60   fi
61
62   if test  `echo "$x" | grep -c generated` -eq 1; then
63     continue;
64   fi
65
66   if stat $x/*.cpp > /dev/null 2>&1; then
67     t="src += env.Glob('`echo $x'/*.cpp'`')"
68   fi
69
70   if stat $x/*.c > /dev/null 2>&1; then
71     if [ -z "$t" ]; then
72       t="src += env.Glob('`echo $x'/*.c'`')"
73     else
74       t="$t + env.Glob('`echo $x'/*.c'`')"
75     fi
76   fi
77
78   if stat $x/*.cc > /dev/null 2>&1; then
79     if [ -z "$t" ]; then
80       t="src += env.Glob('`echo $x'/*.cc'`')"
81     else
82       t="$t + env.Glob('`echo $x'/*.cc'`')"
83     fi
84   fi
85
86   if [ -z "$src" ]; then
87     src=$t
88   else
89     src=`echo "$src\n$t"`
90   fi
91 done
92
93 cat > CMakeLists.txt << EOF
94 # ***** BEGIN GPL LICENSE BLOCK *****
95 #
96 # This program is free software; you can redistribute it and/or
97 # modify it under the terms of the GNU General Public License
98 # as published by the Free Software Foundation; either version 2
99 # of the License, or (at your option) any later version.
100 #
101 # This program is distributed in the hope that it will be useful,
102 # but WITHOUT ANY WARRANTY; without even the implied warranty of
103 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
104 # GNU General Public License for more details.
105 #
106 # You should have received a copy of the GNU General Public License
107 # along with this program; if not, write to the Free Software Foundation,
108 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
109 #
110 # The Original Code is Copyright (C) 2012, Blender Foundation
111 # All rights reserved.
112 #
113 # Contributor(s): Blender Foundation,
114 #                 Sergey Sharybin
115 #
116 # ***** END GPL LICENSE BLOCK *****
117
118 # NOTE: This file is automatically generated by bundle.sh script
119 #       If you're doing changes in this file, please update template
120 #       in that script too
121
122 set(INC
123         .
124         include
125         internal
126         ../gflags
127         ../../
128 )
129
130 set(INC_SYS
131         ../../../Eigen3
132 )
133
134 set(SRC
135 ${sources}
136
137 ${headers}
138 )
139
140 #if(FALSE)
141 #       list(APPEND SRC
142 ${generated_sources}
143 #       )
144 #endif()
145
146 if(WIN32)
147         list(APPEND INC
148                 ../glog/src/windows
149         )
150
151         if(NOT MINGW)
152                 list(APPEND INC
153                         ../msinttypes
154                 )
155         endif()
156 else()
157         list(APPEND INC
158                 ../glog/src
159         )
160 endif()
161
162 add_definitions(
163         -DCERES_HAVE_PTHREAD
164         -DCERES_NO_SUITESPARSE
165         -DCERES_NO_CXSPARSE
166         -DCERES_NO_LAPACK
167         -DCERES_RESTRICT_SCHUR_SPECIALIZATION
168         -DCERES_HAVE_RWLOCK
169 )
170
171 if(WITH_OPENMP)
172         add_definitions(
173                 -DCERES_USE_OPENMP
174         )
175 endif()
176
177 include(CheckIncludeFileCXX)
178 CHECK_INCLUDE_FILE_CXX(unordered_map HAVE_STD_UNORDERED_MAP_HEADER)
179 if(HAVE_STD_UNORDERED_MAP_HEADER)
180         INCLUDE (CheckCXXSourceCompiles)
181         CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>
182                                   int main() {
183                                     std::unordered_map<int, int> map;
184                                     return 0;
185                                   }"
186                                   HAVE_UNURDERED_MAP_IN_STD_NAMESPACE)
187         if(HAVE_UNURDERED_MAP_IN_STD_NAMESPACE)
188                 ADD_DEFINITIONS(-DCERES_STD_UNORDERED_MAP)
189         else()
190                 CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>
191                                           int main() {
192                                             std::tr1::unordered_map<int, int> map;
193                                             return 0;
194                                           }"
195                                           HAVE_UNURDERED_MAP_IN_TR1_NAMESPACE)
196                 if(HAVE_UNURDERED_MAP_IN_TR1_NAMESPACE)
197                         ADD_DEFINITIONS(-DCERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)
198                 else()
199                         MESSAGE("-- Found <unordered_map> but can not find neither std::unordered_map "
200                                 "nor std::tr1::unordered_map.")
201                         MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!)")
202                         ADD_DEFINITIONS(-DCERES_NO_UNORDERED_MAP)
203                 endif()
204         endif()
205 else()
206         CHECK_INCLUDE_FILE_CXX("tr1/unordered_map" UNORDERED_MAP_IN_TR1_NAMESPACE)
207         if(UNORDERED_MAP_IN_TR1_NAMESPACE)
208                 ADD_DEFINITIONS(-DCERES_TR1_UNORDERED_MAP)
209         else()
210                 MESSAGE("-- Unable to find <unordered_map> or <tr1/unordered_map>. ")
211                 MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!)")
212                 ADD_DEFINITIONS(-DCERES_NO_UNORDERED_MAP)
213         endif()
214 endif()
215
216 blender_add_lib(extern_ceres "\${SRC}" "\${INC}" "\${INC_SYS}")
217 EOF
218
219 cat > SConscript << EOF
220 #!/usr/bin/python
221
222 # NOTE: This file is automatically generated by bundle.sh script
223 #       If you're doing changes in this file, please update template
224 #       in that script too
225
226 import sys
227 import os
228
229 Import('env')
230
231 src = []
232 defs = []
233
234 $src
235 src += env.Glob('internal/ceres/generated/schur_eliminator_d_d_d.cc')
236 src += env.Glob('internal/ceres/generated/partitioned_matrix_view_d_d_d.cc')
237 #src += env.Glob('internal/ceres/generated/*.cc')
238
239 defs.append('CERES_HAVE_PTHREAD')
240 defs.append('CERES_NO_SUITESPARSE')
241 defs.append('CERES_NO_CXSPARSE')
242 defs.append('CERES_NO_LAPACK')
243 defs.append('CERES_RESTRICT_SCHUR_SPECIALIZATION')
244 defs.append('CERES_HAVE_RWLOCK')
245
246 if env['WITH_BF_OPENMP']:
247     defs.append('CERES_USE_OPENMP')
248
249 conf = Configure(env)
250 if conf.CheckCXXHeader("unordered_map"):
251     if conf.CheckType('std::unordered_map<int, int>', language = 'CXX', includes="#include <unordered_map>"):
252         defs.append('CERES_STD_UNORDERED_MAP')
253     elif conf.CheckType('std::tr1::unordered_map<int, int>', language = 'CXX', includes="#include <unordered_map>"):
254         defs.append('CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE')
255     else:
256         print("-- Found <unordered_map> but can not find neither std::unordered_map nor std::tr1::unordered_map.")
257         print("-- Replacing unordered_map/set with map/set (warning: slower!)")
258         defs.append('CERES_NO_UNORDERED_MAP')
259 elif conf.CheckCXXHeader("tr1/unordered_map"):
260     defs.append('CERES_TR1_UNORDERED_MAP')
261 else:
262     print("-- Unable to find <unordered_map> or <tr1/unordered_map>. ")
263     print("-- Replacing unordered_map/set with map/set (warning: slower!)")
264     defs.append('CERES_NO_UNORDERED_MAP')
265
266 env = conf.Finish()
267
268 incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags'
269
270 # work around broken hashtable in 10.5 SDK
271 if env['OURPLATFORM'] == 'darwin' and env['WITH_BF_BOOST']:
272     incs += ' ' + env['BF_BOOST_INC']
273     defs.append('CERES_HASH_BOOST')
274
275 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
276     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
277         incs += ' ../msinttypes'
278
279     incs += ' ../glog/src/windows'
280 else:
281     incs += ' ../glog/src'
282
283 env.BlenderLib ( libname = 'extern_ceres', sources=src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137])
284 EOF