5 echo "usage: configure [options] <package>"
7 echo " -b : extern build in ../build directory"
8 echo " -c <compile_dir>"
9 echo " -C <cross environment>"
10 echo " -i : install dir. default: /"
11 echo " -I : print this info"
12 echo " -t <compile type: NONE, CPP, CMAKE, PDF> default: NONE"
13 echo " -v : set version"
14 echo " -V : version set by project"
17 function create_build {
18 pushd $BUILD_DIR >/dev/null
19 if [ "$compile_type" == "PDF" ]
21 echo "make $compile_target" > debian/$paket.build
22 chmod 755 debian/$paket.build
24 echo "build for compile_type not implemented."
29 function cmake_check {
30 pushd ../build >/dev/null
32 if [ -e debian/$paket.build ]
34 echo "cmake is not compatible with other builds. Remove $paket.build"
37 if [ -e debian/$paket.prebuild ]
39 echo "cmake is not compatible with other builds. Remove $paket.prebuild"
45 # inject cross toolset
46 echo "set (CMAKE_MODULE_PATH $cross)" > CMakeLists.txt
47 echo "include(toolset)" >> CMakeLists.txt
48 cat debian/$paket.cmake >> CMakeLists.txt
50 cp debian/$paket.cmake CMakeLists.txt
53 echo "make" > debian/$paket.build
54 chmod 755 debian/$paket.build
58 function check_unversioned {
59 # has to be called in the projects base directory
60 # result: "M" in stdout or nothing
63 # check if build is running in a sandbox
64 if ! [ -f .cm.ignore ]
67 echo ".cm.ignore" > .cm.ignore
68 echo "debian.*" >> .cm.ignore
69 echo "up.*" >> .cm.ignore
73 project=${project##*/}
75 mCM $project -b -an > /dev/null
76 wc=$(wc $project.batch)
78 if [ "${wc:0:5}" != "0 0 0" ]
92 build="$build$(check_unversioned)"
95 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
98 # try generic "v_" tag
99 tag=$(git describe --tags --match "v_*" 2>/dev/null) || true
105 changes=$(check_unversioned)
108 version=${version%%-*}
111 echo "No configuration system found. Cannot determine version."
116 function check_version {
119 vline=$(head -1 debian/$paket.changelog)
121 clversion=${vline#*(}
122 if [ $version = "0.0" ]
128 # do no check on a modified git repos
129 if [ "${build: -1}" == "M" ]
134 if [ "$clversion" != $version ]
136 echo "version mismatch: git: $version, changelog: $clversion"
141 ##############################################################################
143 ##############################################################################
149 while [ $OPTIND -le "$#" ]
151 if getopts "a:bB:C:i:It:v:V" opt
158 c) compile_dir=$OPTARG
162 i) install_dir=$OPTARG
167 t) compile_type=$OPTARG
169 v) optversion=$OPTARG
173 \?) echo "Invalid option: -$OPTARG"
177 :) echo "Option -$OPTARG requires an argument."
194 # read build configuration, if existing
195 if [ -f debian/$paket.conf ]
200 if [ -n "$ARCH" -a -n "$cross" ]
202 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
208 ln -s /usr/share/mbuild/rules Makefile
211 # delete changelog and control
212 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
214 # mconfigure builds 2 environment files: setenv.sh + rules.pre
215 echo "paket=$paket" > debian/rules.pre
216 echo "INSTALL_DIR=$install_dir" >> debian/rules.pre
217 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
221 if [ ${cross:0:1} != "/" ]
223 cross="/opt/cross/$cross"
226 if [ -f "$cross/setenv.sh" ]
229 cp $cross/setenv.sh debian/setenv.sh
233 # determine architecture
234 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
235 GNU_ARCH=${GNU_ARCH##*/}
236 arch_opt="-t $GNU_ARCH"
244 dpkg-architecture $arch_opt >> debian/setenv.sh
246 echo "paket=$paket" >> debian/setenv.sh
249 if [ -z "$optversion" ]
255 echo "version=$version" >> debian/rules.pre
256 echo "version=$version" >> debian/setenv.sh
257 echo "build=$build" >> debian/rules.pre
258 echo "build=$build" >> debian/setenv.sh
260 # get repository name
264 # echo "pwd=$pwd" >> debian/rules.pre
266 echo "building $paket with version/build=$version-$build"
268 pushd debian >/dev/null
269 # ./debian -------------------------------------
271 ln -sf /usr/share/mbuild/rules .
278 # check for pre/post installation scripts
279 if [ -f $paket.preinst ]
281 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
283 if [ -f $paket.postinst ]
285 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
287 if [ -f $paket.prerm ]
289 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
291 if [ -f $paket.postrm ]
293 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
296 # check for README.debian
297 if [ -f $paket.README.debian ]
299 cp $paket.README.debian README.debian
304 # add export to setenv.sh
305 sed -i "s/^/export /" setenv.sh
308 # ./. ---------------------------------------------
311 if [ -x debian/$paket.prepare ]
314 debian/$paket.prepare
317 if [ "$compile_type" == "NONE" ]
319 echo "BUILD=nobuild" >> debian/rules.pre
321 echo "BUILD=build" >> debian/rules.pre
323 if [ $extern_build -eq 1 ]
326 echo "BUILD_DIR=~/build" >> debian/rules.pre
331 if [ "$compile_type" != "CMAKE" -a "$compile_type" != "OLD" ]
333 cp debian/rules.pre $BUILD_DIR/$compile_dir/make.pre
334 pushd $BUILD_DIR/$compile_dir >/dev/null
335 ln -sf /usr/share/mbuild/makefile .
336 if [ -n "$sources_suffix" ]
338 echo "SOURCES = \\" >> make.pre
339 for suf in $sources_suffix
341 find . -name "*.$suf" -exec echo " "{}" \\" >> make.pre \;
348 if [ -x debian/$paket.prebuild ]
350 pushd $BUILD_DIR >/dev/null
352 debian/$paket.prebuild
355 if ! [ -x debian/$paket.build -o -f debian/$paket.cmake ]
361 if [ -e debian/$paket.cmake ]