5 echo "usage: configure [options] <package>"
6 echo "--- general options ---"
7 echo " -h : print this info"
8 echo "--- compile options ---"
10 echo " -c <compile type: NONE|CPP|CMAKE|PDF|ANY> default: NONE"
11 echo " -C <cross environment>"
12 echo " -d <compile_dir>"
13 echo " -e <compile_target>"
14 echo "--- build target options ---"
15 echo " -i : install dir. default: /, nec. for make install"
16 echo " -n <target_name>: default: <package>"
17 echo " -t <target_type: FILE|DEB|ZIP>, nec. for make pack"
18 echo " -v : set version"
19 echo " -V : version set by project"
22 function create_build {
23 pushd $BUILD_DIR >/dev/null
24 if [ "$compile_type" == "PDF" ]
26 echo "cd $compile_dir" > debian/$paket.build
27 echo "make $compile_target" >> debian/$paket.build
28 chmod 755 debian/$paket.build
30 echo "build for compile_type not implemented."
35 function cmake_check {
36 pushd ../build >/dev/null
38 if [ -e debian/$paket.build ]
40 echo "cmake is not compatible with other builds. Remove $paket.build"
43 if [ -e debian/$paket.prebuild ]
45 echo "cmake is not compatible with other builds. Remove $paket.prebuild"
51 # inject cross toolset
52 echo "set (CMAKE_MODULE_PATH $cross)" > CMakeLists.txt
53 echo "include(toolset)" >> CMakeLists.txt
54 cat debian/$paket.cmake >> CMakeLists.txt
56 cp debian/$paket.cmake CMakeLists.txt
59 echo "make" > debian/$paket.build
60 chmod 755 debian/$paket.build
64 function check_unversioned {
65 # has to be called in the projects base directory
66 # result: "M" in stdout or nothing
69 # check if build is running in a sandbox
70 if ! [ -f .cm.ignore ]
73 echo ".cm.ignore" > .cm.ignore
74 echo "debian.*" >> .cm.ignore
75 echo "up.*" >> .cm.ignore
79 project=${project##*/}
81 mCM $project -b -an > /dev/null
82 wc=$(wc $project.batch)
84 if [ "${wc:0:5}" != "0 0 0" ]
98 build="$build$(check_unversioned)"
101 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
104 # try generic "v_" tag
105 tag=$(git describe --tags --match "v_*" 2>/dev/null) || true
111 changes=$(check_unversioned)
114 version=${version%%-*}
117 echo "No configuration system found. Cannot determine version."
122 function check_version {
125 vline=$(head -1 debian/$paket.changelog)
127 clversion=${vline#*(}
128 if [ $version = "0.0" ]
134 # do no check on a modified git repos
135 if [ "${build: -1}" == "M" ]
140 if [ "$clversion" != $version ]
142 echo "version mismatch: git: $version, changelog: $clversion"
147 function add_sources {
151 find . -name "*.$suf" -exec echo " "{}" \\" >> make.pre \;
156 find . -name "*.$2" -exec echo {} >> make.tmp \;
159 echo " ${line/\.$2/\.$1} \\" >> make.pre
164 ##############################################################################
166 ##############################################################################
172 while [ $OPTIND -le "$#" ]
174 if getopts "ha:bc:C:d:e:i:n:t:v:V" opt
184 c) compile_type=$OPTARG
188 d) compile_dir=$OPTARG
190 d) compile_target=$OPTARG
192 i) install_dir=$OPTARG
194 n) target_name=$OPTARG
196 t) target_type=$OPTARG
198 v) optversion=$OPTARG
202 \?) echo "Invalid option: -$OPTARG"
206 :) echo "Option -$OPTARG requires an argument."
223 # read build configuration, if existing
224 if [ -f debian/$paket.conf ]
229 if [ -n "$ARCH" -a -n "$cross" ]
231 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
237 ln -s /usr/share/mbuild/rules Makefile
240 # delete changelog and control
241 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
243 # mconfigure builds 2 environment files: setenv.sh + rules.pre
244 echo "paket=$paket" > debian/rules.pre
245 echo "INSTALL_DIR=$install_dir" >> debian/rules.pre
246 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
250 if [ ${cross:0:1} != "/" ]
252 cross="/opt/cross/$cross"
255 if [ -f "$cross/setenv.sh" ]
258 cp $cross/setenv.sh debian/setenv.sh
262 # determine architecture
263 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
264 GNU_ARCH=${GNU_ARCH##*/}
265 arch_opt="-t $GNU_ARCH"
273 dpkg-architecture $arch_opt >> debian/setenv.sh
275 echo "paket=$paket" >> debian/setenv.sh
278 if [ -z "$optversion" ]
284 echo "version=$version" >> debian/rules.pre
285 echo "version=$version" >> debian/setenv.sh
286 echo "build=$build" >> debian/rules.pre
287 echo "build=$build" >> debian/setenv.sh
289 # get repository name
293 # echo "pwd=$pwd" >> debian/rules.pre
295 echo "building $paket with version/build=$version-$build"
297 pushd debian >/dev/null
298 # ./debian -------------------------------------
300 ln -sf /usr/share/mbuild/rules .
307 # check for pre/post installation scripts
308 if [ -f $paket.preinst ]
310 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
312 if [ -f $paket.postinst ]
314 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
316 if [ -f $paket.prerm ]
318 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
320 if [ -f $paket.postrm ]
322 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
325 # check for README.debian
326 if [ -f $paket.README.debian ]
328 cp $paket.README.debian README.debian
333 # add export to setenv.sh
334 sed -i "s/^/export /" setenv.sh
337 # ./. ---------------------------------------------
340 if [ -x debian/$paket.prepare ]
343 debian/$paket.prepare
346 if [ "$compile_type" == "NONE" ]
348 echo "BUILD=nobuild" >> debian/rules.pre
350 echo "BUILD=build" >> debian/rules.pre
352 if [ $extern_build -eq 1 ]
355 echo "BUILD_DIR=~/build" >> debian/rules.pre
360 if [ "$compile_type" != "CMAKE" -a "$compile_type" != "ANY" ]
362 cp debian/rules.pre $BUILD_DIR/$compile_dir/make.pre
363 pushd $BUILD_DIR/$compile_dir >/dev/null
364 ln -sf /usr/share/mbuild/makefile .
365 # if [ -n "$sources_suffix" ]
367 # echo "SOURCES = \\" >> make.pre
368 # for suf in $sources_suffix
370 # find . -name "*.$suf" -exec echo " "{}" \\" >> make.pre \;
377 if [ "$compile_type" == "PDF" ]
379 pushd $BUILD_DIR/$compile_dir >/dev/null
380 echo "SOURCES = \\" >> make.pre
384 if [ -x debian/$paket.prebuild ]
386 pushd $BUILD_DIR >/dev/null
388 debian/$paket.prebuild
391 if ! [ -x debian/$paket.build -o -f debian/$paket.cmake ]
397 if [ -e debian/$paket.cmake ]