cleanup: shebang lines
[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="master"
11
12 repo="git://git.blender.org/libmv.git"
13 tmp=`mktemp -d`
14
15 git clone -b $BRANCH $repo $tmp/libmv
16
17 git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log -n 50 > ChangeLog
18
19 find libmv -type f -not -iwholename '*.svn*' -exec rm -rf {} \;
20 find third_party -type f -not -iwholename '*.svn*' -not -iwholename '*third_party/ceres*' \
21     -not -iwholename '*third_party/SConscript*' -not -iwholename '*third_party/CMakeLists.txt*' \
22     -exec rm -rf {} \;
23
24 cat "files.txt" | while read f; do
25   mkdir -p `dirname $f`
26   cp $tmp/libmv/src/$f $f
27 done
28
29 rm -rf $tmp
30
31 chmod 664 ./third_party/glog/src/windows/*.cc ./third_party/glog/src/windows/*.h ./third_party/glog/src/windows/glog/*.h
32
33 sources=`find ./libmv -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep -v _test.cc | grep -v test_data_sets | sed -r 's/^\.\//\t\t/' | sort -d`
34 headers=`find ./libmv -type f -iname '*.h' | grep -v test_data_sets | sed -r 's/^\.\//\t\t/' | sort -d`
35
36 third_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep -v glog | grep -v gflags | grep -v ceres | sed -r 's/^\.\//\t\t/' | sort -d`
37 third_headers=`find ./third_party -type f -iname '*.h' | grep -v glog | grep -v gflags | grep -v ceres | sed -r 's/^\.\//\t\t/' | sort -d`
38
39 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`
40 third_glog_headers=`find ./third_party -type f -iname '*.h' | grep glog | grep -v windows | sed -r 's/^\.\//\t\t\t/' | sort -d`
41
42 third_gflags_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep gflags | grep -v windows | sed -r 's/^\.\//\t\t/' | sort -d`
43 third_gflags_headers=`find ./third_party -type f -iname '*.h' | grep gflags | grep -v windows | sed -r 's/^\.\//\t\t/' | sort -d`
44
45 tests=`find ./libmv -type f -iname '*_test.cc' | sort -d | awk ' { name=gensub(".*/([A-Za-z_]+)_test.cc", "\\\\1", $1); printf("\t\tBLENDER_SRC_GTEST(\"libmv_%s\" \"%s\" \"libmv_test_dataset;extern_libmv;extern_ceres\")\n", name, $1) } '`
46
47 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`
48 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`
49 src=""
50 win_src=""
51 for x in $src_dir $src_third_dir; do
52   t=""
53
54   if test  `echo "$x" | grep -c glog ` -eq 1; then
55     continue;
56   fi
57
58   if stat $x/*.cpp > /dev/null 2>&1; then
59     t="    src += env.Glob('`echo $x'/*.cpp'`')"
60   fi
61
62   if stat $x/*.c > /dev/null 2>&1; then
63     if [ -z "$t" ]; then
64       t="    src += env.Glob('`echo $x'/*.c'`')"
65     else
66       t="$t + env.Glob('`echo $x'/*.c'`')"
67     fi
68   fi
69
70   if stat $x/*.cc > /dev/null 2>&1; then
71     if [ -z "$t" ]; then
72       t="    src += env.Glob('`echo $x'/*.cc'`')"
73     else
74       t="$t + env.Glob('`echo $x'/*.cc'`')"
75     fi
76   fi
77
78   if test `echo $x | grep -c "windows\|gflags" ` -eq 0; then
79     if [ -z "$src" ]; then
80       src=$t
81     else
82       src=`echo "$src\n$t"`
83     fi
84   else
85     if [ -z "$win_src" ]; then
86       win_src=`echo "    $t"`
87     else
88       win_src=`echo "$win_src\n    $t"`
89     fi
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) 2011, 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 )
125
126 set(INC_SYS
127 )
128
129 set(SRC
130         libmv-capi.h
131 )
132
133 if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
134         list(APPEND INC
135                 third_party/gflags
136                 third_party/gflags/gflags
137                 third_party/glog/src
138                 third_party/ceres/include
139                 third_party/ceres/config
140                 ../../intern/guardedalloc
141         )
142
143         list(APPEND INC_SYS
144                 ../Eigen3
145                 \${PNG_INCLUDE_DIRS}
146                 \${ZLIB_INCLUDE_DIRS}
147         )
148
149         if(WIN32)
150                 list(APPEND INC
151                         third_party/glog/src/windows
152                 )
153
154                 if(NOT MINGW)
155                         list(APPEND INC
156                                 third_party/msinttypes
157                         )
158                 endif()
159         endif()
160
161         add_definitions(
162                 -DWITH_LIBMV_GUARDED_ALLOC
163                 -DGOOGLE_GLOG_DLL_DECL=
164                 -DLIBMV_NO_FAST_DETECTOR=
165         )
166 endif()
167
168 if(WITH_LIBMV)
169         TEST_SHARED_PTR_SUPPORT()
170         if(SHARED_PTR_FOUND)
171                 if(SHARED_PTR_TR1_MEMORY_HEADER)
172                         add_definitions(-DCERES_TR1_MEMORY_HEADER)
173                 endif()
174                 if(SHARED_PTR_TR1_NAMESPACE)
175                         add_definitions(-DCERES_TR1_SHARED_PTR)
176                 endif()
177         else()
178                 message(FATAL_ERROR "Unable to find shared_ptr.")
179         endif()
180
181         list(APPEND SRC
182                 intern/autotrack.cc
183                 intern/camera_intrinsics.cc
184                 intern/detector.cc
185                 intern/frame_accessor.cc
186                 intern/homography.cc
187                 intern/image.cc
188                 intern/logging.cc
189                 intern/reconstruction.cc
190                 intern/track_region.cc
191                 intern/tracks.cc
192                 intern/tracksN.cc
193 ${sources}
194 ${third_sources}
195
196                 intern/autotrack.h
197                 intern/camera_intrinsics.h
198                 intern/detector.h
199                 intern/frame_accessor.h
200                 intern/homography.h
201                 intern/image.h
202                 intern/logging.h
203                 intern/reconstruction.h
204                 intern/track_region.h
205                 intern/tracks.h
206                 intern/tracksN.h
207 ${headers}
208
209 ${third_headers}
210         )
211
212
213         if(WITH_GTESTS)
214                 blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "${INC}" "${INC_SYS}")
215
216 ${tests}
217         endif()
218 else()
219         list(APPEND SRC
220                 intern/stub.cc
221         )
222 endif()
223
224 blender_add_lib(extern_libmv "\${SRC}" "\${INC}" "\${INC_SYS}")
225
226 if(WITH_LIBMV)
227         add_subdirectory(third_party)
228 endif()
229
230 # make GLog a separate target, so it can be used for gtest as well.
231 if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
232         # We compile GLog together with GFlag so we don't worry about
233         # adding extra lib to linker.
234         set(GLOG_SRC
235 ${third_gflags_sources}
236
237 ${third_gflags_headers}
238         )
239
240         if(WIN32)
241                 list(APPEND GLOG_SRC
242                         third_party/glog/src/logging.cc
243                         third_party/glog/src/raw_logging.cc
244                         third_party/glog/src/utilities.cc
245                         third_party/glog/src/vlog_is_on.cc
246                         third_party/glog/src/windows/port.cc
247
248                         third_party/glog/src/utilities.h
249                         third_party/glog/src/stacktrace_generic-inl.h
250                         third_party/glog/src/stacktrace.h
251                         third_party/glog/src/stacktrace_x86_64-inl.h
252                         third_party/glog/src/base/googleinit.h
253                         third_party/glog/src/base/mutex.h
254                         third_party/glog/src/base/commandlineflags.h
255                         third_party/glog/src/stacktrace_powerpc-inl.h
256                         third_party/glog/src/stacktrace_x86-inl.h
257                         third_party/glog/src/config.h
258                         third_party/glog/src/stacktrace_libunwind-inl.h
259                         third_party/glog/src/windows/glog/raw_logging.h
260                         third_party/glog/src/windows/glog/vlog_is_on.h
261                         third_party/glog/src/windows/glog/logging.h
262                         third_party/glog/src/windows/glog/log_severity.h
263                         third_party/glog/src/windows/port.h
264                         third_party/glog/src/windows/config.h
265
266                         third_party/gflags/windows_port.cc
267                         third_party/gflags/windows_port.h
268                 )
269         else()
270                 list(APPEND GLOG_SRC
271 ${third_glog_sources}
272
273 ${third_glog_headers}
274                 )
275         endif()
276
277         blender_add_lib(extern_glog "\${GLOG_SRC}" "\${INC}" "\${INC_SYS}")
278 endif()
279 EOF
280
281 cat > SConscript << EOF
282 # NOTE: This file is automatically generated by bundle.sh script
283 #       If you're doing changes in this file, please update template
284 #       in that script too
285
286 import sys
287 import os
288
289 Import('env')
290
291 defs = []
292 incs = '.'
293
294 if env['WITH_BF_LIBMV'] or (env['WITH_BF_CYCLES'] and env['WITH_BF_CYCLES_LOGGING']):
295     defs.append('GOOGLE_GLOG_DLL_DECL=')
296     defs.append('WITH_LIBMV_GUARDED_ALLOC')
297     defs.append('LIBMV_NO_FAST_DETECTOR')
298
299     incs += ' ../Eigen3 third_party/gflags third_party/gflags/gflags third_party/glog/src third_party/ceres/include third_party/ceres/config ../../intern/guardedalloc'
300     incs += ' ' + env['BF_PNG_INC']
301     incs += ' ' + env['BF_ZLIB_INC']
302
303     if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
304         incs += ' ./third_party/glog/src/windows ./third_party/glog/src/windows/glog'
305         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
306             incs += ' ./third_party/msinttypes'
307     else:
308         incs += ' ./third_party/glog/src'
309
310 if env['WITH_BF_LIBMV']:
311     if not env['WITH_SHARED_PTR_SUPPORT']:
312         print("-- Unable to find shared_ptr which is required for compilation.")
313         exit(1)
314
315     if env['SHARED_PTR_HEADER'] == 'tr1/memory':
316         defs.append('CERES_TR1_MEMORY_HEADER')
317     if env['SHARED_PTR_NAMESPACE'] == 'std::tr1':
318         defs.append('CERES_TR1_SHARED_PTR')
319
320     src = env.Glob('intern/*.cc')
321     src.remove('intern' + os.sep + 'stub.cc')
322 $src
323 else:
324     src = env.Glob("intern/stub.cc")
325
326 src = [src for src in src if src.find('_test.cc') == -1]
327
328 env.BlenderLib(libname = 'extern_libmv', sources=src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137])
329
330 if env['WITH_BF_LIBMV'] or (env['WITH_BF_CYCLES'] and env['WITH_BF_CYCLES_LOGGING']):
331     glog_src = []
332     glog_src += env.Glob("third_party/gflags/*.cc")
333     if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
334         glog_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']
335         glog_src += ['./third_party/glog/src/windows/port.cc']
336     else:
337         glog_src.remove('third_party/gflags/windows_port.cc')
338         glog_src += env.Glob("third_party/glog/src/*.cc")
339
340     env.BlenderLib(libname = 'extern_glog', sources=glog_src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137])
341
342 if env['WITH_BF_LIBMV']:
343     SConscript(['third_party/SConscript'])
344 EOF