Added note that cmake/scons rules are automatically generated for extern/libmv
[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/' | sort -d`
37 headers=`find ./libmv -type f -iname '*.h' | sed -r 's/^\.\//\t/' | sort -d`
38
39 third_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep -v glog | sed -r 's/^\.\//\t/' | sort`
40 third_headers=`find ./third_party -type f -iname '*.h' | grep -v glog | sed -r 's/^\.\//\t/' | sort`
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/' | sort`
43 third_glog_headers=`find ./third_party -type f -iname '*.h' | grep glog | grep -v windows | sed -r 's/^\.\//\t\t/' | sort`
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 # ***** BEGIN GPL LICENSE BLOCK *****
93 #
94 # This program is free software; you can redistribute it and/or
95 # modify it under the terms of the GNU General Public License
96 # as published by the Free Software Foundation; either version 2
97 # of the License, or (at your option) any later version.
98 #
99 # This program is distributed in the hope that it will be useful,
100 # but WITHOUT ANY WARRANTY; without even the implied warranty of
101 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
102 # GNU General Public License for more details.
103 #
104 # You should have received a copy of the GNU General Public License
105 # along with this program; if not, write to the Free Software Foundation,
106 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
107 #
108 # The Original Code is Copyright (C) 2011, Blender Foundation
109 # All rights reserved.
110 #
111 # Contributor(s): Blender Foundation,
112 #                 Sergey Sharybin
113 #
114 # ***** END GPL LICENSE BLOCK *****
115
116 # NOTEL This file is automatically generated by bundle.sh script
117 #       If you're doing changes in this file, please update template
118 #       in that script too
119
120 set(INC
121         .
122         ../Eigen3
123         third_party/ssba
124         third_party/ldl/Include
125         ../colamd/Include
126 )
127
128 set(INC_SYS
129         \${PNG_INCLUDE_DIR}
130         \${ZLIB_INCLUDE_DIRS}
131 )
132
133 set(SRC
134         libmv-capi.cpp
135 ${sources}
136
137 ${third_sources}
138
139         libmv-capi.h
140 ${headers}
141
142 ${third_headers}
143 )
144
145 if(WIN32)
146         list(APPEND SRC
147                 third_party/glog/src/logging.cc
148                 third_party/glog/src/raw_logging.cc
149                 third_party/glog/src/utilities.cc
150                 third_party/glog/src/vlog_is_on.cc
151                 third_party/glog/src/windows/port.cc
152
153                 third_party/glog/src/utilities.h
154                 third_party/glog/src/stacktrace_generic-inl.h
155                 third_party/glog/src/stacktrace.h
156                 third_party/glog/src/stacktrace_x86_64-inl.h
157                 third_party/glog/src/base/googleinit.h
158                 third_party/glog/src/base/mutex.h
159                 third_party/glog/src/base/commandlineflags.h
160                 third_party/glog/src/stacktrace_powerpc-inl.h
161                 third_party/glog/src/stacktrace_x86-inl.h
162                 third_party/glog/src/config.h
163                 third_party/glog/src/stacktrace_libunwind-inl.h
164                 third_party/glog/src/windows/glog/raw_logging.h
165                 third_party/glog/src/windows/glog/vlog_is_on.h
166                 third_party/glog/src/windows/glog/logging.h
167                 third_party/glog/src/windows/glog/log_severity.h
168                 third_party/glog/src/windows/port.h
169                 third_party/glog/src/windows/config.h
170         )
171
172         list(APPEND INC
173                 third_party/glog/src/windows
174         )
175
176         if(NOT MINGW)
177                 list(APPEND INC
178                         third_party/msinttypes
179                 )
180         endif()
181
182         if(MSVC)
183                 set(MSVC_OFLAGS O1 O2 Ox)
184                 foreach(FLAG \${MSVC_OFLAGS})
185                         string(REPLACE "\${FLAG}" "Od" CMAKE_CXX_FLAGS_RELEASE "\${CMAKE_CXX_FLAGS_RELEASE}")
186                         string(REPLACE "\${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "\${CMAKE_C_FLAGS_RELWITHDEBINFO}")
187                 endforeach()
188         endif()
189 else()
190         list(APPEND SRC
191 ${third_glog_sources}
192
193 ${third_glog_headers}
194         )
195
196         list(APPEND INC
197                 third_party/glog/src
198         )
199 endif()
200
201 add_definitions(
202         -DV3DLIB_ENABLE_SUITESPARSE
203         -DGOOGLE_GLOG_DLL_DECL=
204 )
205
206 blender_add_lib(extern_libmv "\${SRC}" "\${INC}" "\${INC_SYS}")
207 EOF
208
209 cat > SConscript << EOF
210 #!/usr/bin/python
211
212 # NOTEL This file is automatically generated by bundle.sh script
213 #       If you're doing changes in this file, please update template
214 #       in that script too
215
216 import sys
217 import os
218
219 Import('env')
220
221 defs = []
222
223 cflags_libmv = Split(env['CFLAGS'])
224 ccflags_libmv = Split(env['CCFLAGS'])
225 cxxflags_libmv = Split(env['CXXFLAGS'])
226
227 defs.append('V3DLIB_ENABLE_SUITESPARSE')
228 defs.append('GOOGLE_GLOG_DLL_DECL=')
229
230 src = env.Glob("*.cpp")
231 $src
232
233 incs = '. ../Eigen3'
234 incs += ' ' + env['BF_PNG_INC']
235 incs += ' ' + env['BF_ZLIB_INC']
236
237 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
238     incs += ' ./third_party/glog/src/windows ./third_party/glog/src/windows/glog'
239     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
240         incs += ' ./third_party/msinttypes'
241 ${win_src}
242     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']
243     src += ['./third_party/glog/src/windows/port.cc']
244
245     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
246         cflags_libmv.append('/Od')
247         ccflags_libmv.append('/Od')
248         cxxflags_libmv.append('/Od')
249
250         if not env['BF_DEBUG']:
251             defs.append('NDEBUG')
252     else:
253         if not env['BF_DEBUG']:
254             cflags_libmv += Split(env['REL_CFLAGS'])
255             ccflags_libmv += Split(env['REL_CCFLAGS'])
256             cxxflags_libmv += Split(env['REL_CXXFLAGS'])
257 else:
258     src += env.Glob("third_party/glog/src/*.cc")
259     incs += ' ./third_party/glog/src'
260     if not env['BF_DEBUG']:
261         cflags_libmv += Split(env['REL_CFLAGS'])
262         ccflags_libmv += Split(env['REL_CCFLAGS'])
263         cxxflags_libmv += Split(env['REL_CXXFLAGS'])
264
265 incs += ' ./third_party/ssba ./third_party/ldl/Include ../colamd/Include'
266
267 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 )
268 EOF