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