fb336c66d610b4db49e5711fb57ab6387564c2ed
[blender.git] / extern / libmv / bundle.sh
1 #!/bin/sh
2
3 #BRANCH="keir"
4 BRANCH="Matthias-Fauconneau"
5
6 if [ -d ./.svn ]; then
7   echo "This script is supposed to work only when using git-svn"
8   exit 1
9 fi
10
11 repo="git://github.com/${BRANCH}/libmv.git"
12 tmp=`mktemp -d`
13
14 git clone $repo $tmp/libmv
15
16 #git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log --since="1 month ago" > ChangeLog
17 git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log -n 50 > ChangeLog
18
19 for p in `cat ./patches/series`; do
20   echo "Applying patch $p..."
21   cat ./patches/$p | patch -d $tmp/libmv -p1
22 done
23
24 rm -rf libmv
25 rm -rf third_party
26
27 cat "files.txt" | while f=`line`; do
28   mkdir -p `dirname $f`
29   cp $tmp/libmv/src/$f $f
30 done
31
32 rm -rf $tmp
33
34 chmod 664 ./third_party/glog/src/windows/*.cc ./third_party/glog/src/windows/*.h ./third_party/glog/src/windows/glog/*.h
35
36 sources=`find ./libmv -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t/'`
37 headers=`find ./libmv -type f -iname '*.h' | sed -r 's/^\.\//\t/'`
38
39 third_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep -v glog | sed -r 's/^\.\//\t/'`
40 third_headers=`find ./third_party -type f -iname '*.h' | grep -v glog | sed -r 's/^\.\//\t/'`
41
42 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/'`
43 third_glog_headers=`find ./third_party -type f -iname '*.h' | grep glog | grep -v windows | sed -r 's/^\.\//\t\t/'`
44
45 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 | uniq`
46 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 | uniq`
47 src=""
48 win_src=""
49 for x in $src_dir $src_third_dir; do
50   t=""
51
52   if test  `echo "$x" | grep -c glog ` -eq 1; then
53     continue;
54   fi
55
56   if stat $x/*.cpp > /dev/null 2>&1; then
57     t="src += env.Glob('`echo $x'/*.cpp'`')"
58   fi
59
60   if stat $x/*.c > /dev/null 2>&1; then
61     if [ -z "$t" ]; then
62       t="src += env.Glob('`echo $x'/*.c'`')"
63     else
64       t="$t + env.Glob('`echo $x'/*.c'`')"
65     fi
66   fi
67
68   if stat $x/*.cc > /dev/null 2>&1; then
69     if [ -z "$t" ]; then
70       t="src += env.Glob('`echo $x'/*.cc'`')"
71     else
72       t="$t + env.Glob('`echo $x'/*.cc'`')"
73     fi
74   fi
75
76   if test `echo $x | grep -c windows ` -eq 0; then
77     if [ -z "$src" ]; then
78       src=$t
79     else
80       src=`echo "$src\n$t"`
81     fi
82   else
83     if [ -z "$win_src" ]; then
84       win_src=`echo "    $t"`
85     else
86       win_src=`echo "$win_src\n    $t"`
87     fi
88   fi
89 done
90
91 cat > CMakeLists.txt << EOF
92 # \$Id\$
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 set(INC
118         .
119         ../Eigen3
120         ./third_party/ssba
121         ./third_party/ldl/Include
122         ../colamd/Include
123 )
124
125 set(INC_SYS
126         ${PNG_INCLUDE_DIR}
127         ${ZLIB_INCLUDE_DIRS}
128 )
129
130 set(SRC
131         libmv-capi.cpp
132 ${sources}
133
134 ${third_sources}
135
136         libmv-capi.h
137 ${headers}
138
139 ${third_headers}
140 )
141
142 IF(WIN32)
143         list(APPEND SRC
144                 third_party/glog/src/logging.cc
145                 third_party/glog/src/raw_logging.cc
146                 third_party/glog/src/utilities.cc
147                 third_party/glog/src/vlog_is_on.cc
148                 third_party/glog/src/windows/port.cc
149
150                 third_party/glog/src/utilities.h
151                 third_party/glog/src/stacktrace_generic-inl.h
152                 third_party/glog/src/stacktrace.h
153                 third_party/glog/src/stacktrace_x86_64-inl.h
154                 third_party/glog/src/base/googleinit.h
155                 third_party/glog/src/base/mutex.h
156                 third_party/glog/src/base/commandlineflags.h
157                 third_party/glog/src/stacktrace_powerpc-inl.h
158                 third_party/glog/src/stacktrace_x86-inl.h
159                 third_party/glog/src/config.h
160                 third_party/glog/src/stacktrace_libunwind-inl.h
161                 third_party/glog/src/windows/glog/raw_logging.h
162                 third_party/glog/src/windows/glog/vlog_is_on.h
163                 third_party/glog/src/windows/glog/logging.h
164                 third_party/glog/src/windows/glog/log_severity.h
165                 third_party/glog/src/windows/port.h
166                 third_party/glog/src/windows/config.h
167         )
168
169         list(APPEND INC
170                 ./third_party/glog/src/windows
171         )
172
173         IF(NOT MINGW)
174                 list(APPEND INC
175                         ./third_party/msinttypes
176                 )
177         ENDIF(MINGW)
178
179         list(APPEND INC
180                 ./third_party/glog/src/windows
181                 ./third_party/msinttypes
182         )
183
184         IF(MSVC)
185                 set(MSVC_OFLAGS O1 O2 Ox)
186                 foreach(FLAG \${MSVC_OFLAGS})
187                         string(REPLACE "\${FLAG}" "Od" CMAKE_CXX_FLAGS_RELEASE "\${CMAKE_CXX_FLAGS_RELEASE}")
188                         string(REPLACE "\${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "\${CMAKE_C_FLAGS_RELWITHDEBINFO}")
189                 endforeach()
190         ENDIF(MSVC)
191 ELSE(WIN32)
192         list(APPEND SRC
193 ${third_glog_sources}
194
195 ${third_glog_headers}
196         )
197
198         list(APPEND INC
199                 ./third_party/glog/src
200         )
201 ENDIF(WIN32)
202
203 add_definitions(-DV3DLIB_ENABLE_SUITESPARSE -DGOOGLE_GLOG_DLL_DECL=)
204
205 blender_add_lib(extern_libmv "\${SRC}" "\${INC}" "\${INC_SYS}")
206 EOF
207
208 cat > SConscript << EOF
209 #!/usr/bin/python
210 import sys
211 import os
212
213 Import('env')
214
215 defs = []
216
217 cflags_libmv = Split(env['CFLAGS'])
218 ccflags_libmv = Split(env['CCFLAGS'])
219 cxxflags_libmv = Split(env['CXXFLAGS'])
220
221 defs.append('V3DLIB_ENABLE_SUITESPARSE')
222 defs.append('GOOGLE_GLOG_DLL_DECL=')
223
224 src = env.Glob("*.cpp")
225 $src
226
227 incs = '. ../Eigen3'
228 incs += ' ' + env['BF_PNG_INC']
229 incs += ' ' + env['BF_ZLIB_INC']
230
231 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
232     incs += ' ./third_party/glog/src/windows ./third_party/glog/src/windows/glog'
233     incs += ' ./third_party/glog/src/windows ./third_party/glog/src/windows/glog'
234     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
235         incs += ' ./third_party/msinttypes'
236 ${win_src}
237     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']
238     src += ['./third_party/glog/src/windows/port.cc']
239
240     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
241         cflags_libmv.append('/Od')
242         ccflags_libmv.append('/Od')
243         cxxflags_libmv.append('/Od')
244
245         if not env['BF_DEBUG']:
246             defs.append('NDEBUG')
247     else:
248         if not env['BF_DEBUG']:
249             cflags_libmv = Split(env['REL_CFLAGS'])
250             ccflags_libmv = Split(env['REL_CCFLAGS'])
251             cxxflags_libmv = Split(env['REL_CXXFLAGS'])
252 else:
253     src += env.Glob("third_party/glog/src/*.cc")
254     incs += ' ./third_party/glog/src'
255     if not env['BF_DEBUG']:
256         cflags_libmv = Split(env['REL_CFLAGS'])
257         ccflags_libmv = Split(env['REL_CCFLAGS'])
258         cxxflags_libmv = Split(env['REL_CXXFLAGS'])
259
260 incs += ' ./third_party/ssba ./third_party/ldl/Include ../colamd/Include'
261
262 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 )
263 EOF