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
78 # add auto created files to .cm.ignore
79 if ! grep Makefile .cm.ignore >/dev/null ; then echo "Makefile" >>.cm.ignore; fi
80 if ! grep configure .cm.ignore >/dev/null ; then echo "configure" >>.cm.ignore; fi
81 if ! grep debian/rules .cm.ignore >/dev/null ; then echo "debian/rules" >>.cm.ignore; fi
82 if ! grep debian/rules.pre .cm.ignore >/dev/null ; then echo "debian/rules.pre" >>.cm.ignore; fi
83 if ! grep debian/setenv.sh .cm.ignore >/dev/null ; then echo "debian/setenv.sh" >>.cm.ignore; fi
84 if ! grep debian/tmp .cm.ignore >/dev/null ; then echo "debian/tmp" >>.cm.ignore; fi
87 project=${project##*/}
89 mCM $project -b -an > /dev/null
90 wc=$(wc $project.batch)
92 if [ "${wc:0:1}" != "1" ]
106 build="$build$(check_unversioned)"
109 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
112 # try generic "v_" tag
113 tag=$(git describe --tags --match "v_*" 2>/dev/null) || true
119 changes=$(check_unversioned)
122 version=${version%%-*}
125 echo "No configuration system found. Cannot determine version."
130 function check_version {
133 vline=$(head -1 debian/$paket.changelog)
135 clversion=${vline#*(}
136 if [ $version = "0.0" ]
142 # do no check on a modified git repos
143 if [ "${build: -1}" == "M" ]
148 if [ "$clversion" != $version ]
150 echo "version mismatch: git: $version, changelog: $clversion"
155 function add_sources {
159 find . -name "*.$suf" -exec echo " "{}" \\" >> make.pre \;
164 find . -name "*.$2" -exec echo {} >> make.tmp \;
167 echo " ${line/\.$2/\.$1} \\" >> make.pre
172 ##############################################################################
174 ##############################################################################
180 while [ $OPTIND -le "$#" ]
182 if getopts "ha:bc:C:d:e:i:n:t:v:V" opt
192 c) compile_type=$OPTARG
196 d) compile_dir=$OPTARG
198 e) compile_target=$OPTARG
200 i) install_dir=$OPTARG
202 n) target_name=$OPTARG
204 t) target_type=$OPTARG
206 v) optversion=$OPTARG
210 \?) echo "Invalid option: -$OPTARG"
214 :) echo "Option -$OPTARG requires an argument."
231 if [ -n "$ARCH" -a -n "$cross" ]
233 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
239 ln -s /usr/share/mbuild/rules Makefile
242 # delete changelog and control
243 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
245 # mconfigure builds 2 environment files: setenv.sh + rules.pre
246 echo "paket=$paket" > debian/rules.pre
247 echo "INSTALL_DIR=$install_dir" >> debian/rules.pre
248 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
252 if [ ${cross:0:1} != "/" ]
254 cross="/opt/cross/$cross"
257 if [ -f "$cross/setenv.sh" ]
260 cp $cross/setenv.sh debian/setenv.sh
264 # determine architecture
265 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
266 GNU_ARCH=${GNU_ARCH##*/}
267 arch_opt="-t $GNU_ARCH"
275 dpkg-architecture $arch_opt >> debian/setenv.sh
277 echo "paket=$paket" >> debian/setenv.sh
280 if [ -z "$optversion" ]
286 echo "version=$version" >> debian/rules.pre
287 echo "version=$version" >> debian/setenv.sh
288 echo "build=$build" >> debian/rules.pre
289 echo "build=$build" >> debian/setenv.sh
291 # get repository name
295 # echo "pwd=$pwd" >> debian/rules.pre
297 echo "building $paket with version/build=$version-$build"
299 pushd debian >/dev/null
300 # ./debian -------------------------------------
302 ln -sf /usr/share/mbuild/rules .
309 # check for pre/post installation scripts
310 if [ -f $paket.preinst ]
312 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
314 if [ -f $paket.postinst ]
316 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
318 if [ -f $paket.prerm ]
320 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
322 if [ -f $paket.postrm ]
324 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
327 # check for README.debian
328 if [ -f $paket.README.debian ]
330 cp $paket.README.debian README.debian
335 # add export to setenv.sh
336 sed -i "s/^/export /" setenv.sh
339 # ./. ---------------------------------------------
342 if [ -x debian/$paket.prepare ]
345 debian/$paket.prepare
348 if [ "$compile_type" == "NONE" ]
350 echo "BUILD=nobuild" >> debian/rules.pre
352 echo "BUILD=build" >> debian/rules.pre
354 if [ $extern_build -eq 1 ]
357 echo "BUILD_DIR=~/build" >> debian/rules.pre
362 if [ "$compile_type" != "CMAKE" -a "$compile_type" != "ANY" ]
364 cp debian/rules.pre $BUILD_DIR/$compile_dir/make.pre
365 pushd $BUILD_DIR/$compile_dir >/dev/null
366 ln -sf /usr/share/mbuild/makefile .
367 if [ -n "$sources_suffix" ]
369 echo "SOURCES = \\" >> make.pre
370 for suf in $sources_suffix
372 find . -name "*.$suf" -exec echo " "{}" \\" >> make.pre \;
379 if [ "$compile_type" == "PDF" ]
381 pushd $BUILD_DIR/$compile_dir >/dev/null
382 echo "SOURCES = \\" >> make.pre
387 if [ -x debian/$paket.prebuild ]
389 pushd $BUILD_DIR >/dev/null
391 debian/$paket.prebuild
394 if ! [ -x debian/$paket.build -o -f debian/$paket.cmake ]
400 if [ -e debian/$paket.cmake ]