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