1#!/bin/sh
2
3if [ "x$1" = "x--i-really-know-what-im-doing" ] ; then
4  echo Proceeding as requested by command line ...
5else
6  echo "*** Please run again with --i-really-know-what-im-doing ..."
7  exit 1
8fi
9
10BRANCH="master"
11
12repo="git://git.blender.org/libmv.git"
13tmp=`mktemp -d`
14
15git clone -b $BRANCH $repo $tmp/libmv
16
17git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log -n 50 > ChangeLog
18
19find libmv -type f -exec rm -rf {} \;
20find third_party -type f -exec rm -rf {} \;
21
22cat "files.txt" | while read f; do
23  mkdir -p `dirname $f`
24  cp $tmp/libmv/src/$f $f
25done
26
27rm -rf $tmp
28
29sources=`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`
30headers=`find ./libmv -type f -iname '*.h' | grep -v test_data_sets | sed -r 's/^\.\//\t\t/' | sort -d`
31
32third_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t\t/' | sort -d`
33third_headers=`find ./third_party -type f -iname '*.h' | sed -r 's/^\.\//\t\t/' | sort -d`
34
35tests=`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;bf_intern_libmv;extern_ceres\")\n", name, $1) } '`
36
37src_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`
38src_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\t/'  | sort -d | uniq`
39src=""
40win_src=""
41for x in $src_dir $src_third_dir; do
42  t=""
43
44  if stat $x/*.cpp > /dev/null 2>&1; then
45    t="    src += env.Glob('`echo $x'/*.cpp'`')"
46  fi
47
48  if stat $x/*.c > /dev/null 2>&1; then
49    if [ -z "$t" ]; then
50      t="    src += env.Glob('`echo $x'/*.c'`')"
51    else
52      t="$t + env.Glob('`echo $x'/*.c'`')"
53    fi
54  fi
55
56  if stat $x/*.cc > /dev/null 2>&1; then
57    if [ -z "$t" ]; then
58      t="    src += env.Glob('`echo $x'/*.cc'`')"
59    else
60      t="$t + env.Glob('`echo $x'/*.cc'`')"
61    fi
62  fi
63
64  if test `echo $x | grep -c "windows\|gflags" ` -eq 0; then
65    if [ -z "$src" ]; then
66      src=$t
67    else
68      src=`echo "$src\n$t"`
69    fi
70  else
71    if [ -z "$win_src" ]; then
72      win_src=`echo "    $t"`
73    else
74      win_src=`echo "$win_src\n    $t"`
75    fi
76  fi
77done
78
79cat > CMakeLists.txt << EOF
80# ***** BEGIN GPL LICENSE BLOCK *****
81#
82# This program is free software; you can redistribute it and/or
83# modify it under the terms of the GNU General Public License
84# as published by the Free Software Foundation; either version 2
85# of the License, or (at your option) any later version.
86#
87# This program is distributed in the hope that it will be useful,
88# but WITHOUT ANY WARRANTY; without even the implied warranty of
89# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
90# GNU General Public License for more details.
91#
92# You should have received a copy of the GNU General Public License
93# along with this program; if not, write to the Free Software Foundation,
94# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
95#
96# The Original Code is Copyright (C) 2011, Blender Foundation
97# All rights reserved.
98# ***** END GPL LICENSE BLOCK *****
99
100# NOTE: This file is automatically generated by bundle.sh script
101#       If you're doing changes in this file, please update template
102#       in that script too
103
104set(INC
105  .
106)
107
108set(INC_SYS
109)
110
111set(SRC
112  libmv-capi.h
113)
114
115set(LIB
116
117)
118
119if(WITH_LIBMV)
120  setup_libdirs()
121
122  add_definitions(\${GFLAGS_DEFINES})
123  add_definitions(\${GLOG_DEFINES})
124  add_definitions(\${CERES_DEFINES})
125  add_definitions(-DLIBMV_GFLAGS_NAMESPACE=\${GFLAGS_NAMESPACE})
126
127  list(APPEND INC
128    \${GFLAGS_INCLUDE_DIRS}
129    \${GLOG_INCLUDE_DIRS}
130    ../../extern/ceres/include
131    ../../extern/ceres/config
132    ../guardedalloc
133  )
134
135  list(APPEND INC_SYS
136    \${EIGEN3_INCLUDE_DIRS}
137    \${PNG_INCLUDE_DIRS}
138    \${ZLIB_INCLUDE_DIRS}
139  )
140
141  list(APPEND LIB
142    extern_ceres
143
144    \${GLOG_LIBRARIES}
145    \${GFLAGS_LIBRARIES}
146    \${PNG_LIBRARIES}
147  )
148
149  add_definitions(
150    -DWITH_LIBMV_GUARDED_ALLOC
151    -DLIBMV_NO_FAST_DETECTOR=
152  )
153
154  list(APPEND SRC
155    intern/autotrack.cc
156    intern/camera_intrinsics.cc
157    intern/detector.cc
158    intern/frame_accessor.cc
159    intern/homography.cc
160    intern/image.cc
161    intern/logging.cc
162    intern/reconstruction.cc
163    intern/track_region.cc
164    intern/tracks.cc
165    intern/tracksN.cc
166${sources}
167${third_sources}
168
169    intern/autotrack.h
170    intern/camera_intrinsics.h
171    intern/detector.h
172    intern/frame_accessor.h
173    intern/homography.h
174    intern/image.h
175    intern/logging.h
176    intern/reconstruction.h
177    intern/region.h
178    intern/track_region.h
179    intern/tracks.h
180    intern/tracksN.h
181    intern/utildefines.h
182${headers}
183
184${third_headers}
185  )
186
187
188  if(WITH_GTESTS)
189    blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "${INC}" "${INC_SYS}" "")
190
191${tests}
192  endif()
193else()
194  list(APPEND SRC
195    intern/stub.cc
196  )
197endif()
198
199blender_add_lib(bf_intern_libmv "\${SRC}" "\${INC}" "\${INC_SYS}" "\${LIB}")
200EOF
201