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 cmake_check {
18 pushd ../build >/dev/null
20 if [ -e debian/$paket.build ]
22 echo "cmake is not compatible with other builds. Remove $paket.build"
25 if [ -e debian/$paket.prebuild ]
27 echo "cmake is not compatible with other builds. Remove $paket.prebuild"
33 # inject cross toolset
34 echo "set (CMAKE_MODULE_PATH $cross)" > CMakeLists.txt
35 echo "include(toolset)" >> CMakeLists.txt
36 cat debian/$paket.cmake >> CMakeLists.txt
38 cp debian/$paket.cmake CMakeLists.txt
41 echo "make" > debian/$paket.build
42 chmod 755 debian/$paket.build
46 function check_unversioned {
47 # has to be called in the projects base directory
48 # result: "M" in stdout or nothing
51 # check if build is running in a sandbox
52 if ! [ -f .cm.ignore ]
55 echo ".cm.ignore" > .cm.ignore
56 echo "debian.*" >> .cm.ignore
57 echo "up.*" >> .cm.ignore
61 project=${project##*/}
63 mCM $project -b -an > /dev/null
64 wc=$(wc $project.batch)
66 if [ "${wc:0:5}" != "0 0 0" ]
80 build="$build$(check_unversioned)"
83 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
86 # try generic "v_" tag
87 tag=$(git describe --tags --match "v_*" 2>/dev/null) || true
93 changes=$(check_unversioned)
96 version=${version%%-*}
99 echo "No configuration system found. Cannot determine version."
104 function check_version {
107 vline=$(head -1 debian/$paket.changelog)
109 clversion=${vline#*(}
110 if [ $version = "0.0" ]
116 # do no check on a modified git repos
117 if [ "${build: -1}" == "M" ]
122 if [ "$clversion" != $version ]
124 echo "version mismatch: git: $version, changelog: $clversion"
129 ##############################################################################
131 ##############################################################################
137 while [ $OPTIND -le "$#" ]
139 if getopts "a:bB:C:i:It:v:V" opt
146 c) compile_dir=$OPTARG
150 i) install_dir=$OPTARG
155 t) compile_type=$OPTARG
157 v) optversion=$OPTARG
161 \?) echo "Invalid option: -$OPTARG"
165 :) echo "Option -$OPTARG requires an argument."
182 # read build configuration, if existing
183 if [ -f debian/$paket.conf ]
188 if [ -n "$ARCH" -a -n "$cross" ]
190 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
196 ln -s /usr/share/mbuild/rules Makefile
199 # delete changelog and control
200 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
202 # mconfigure builds 2 environment files: setenv.sh + rules.pre
203 echo "paket=$paket" > debian/rules.pre
204 echo "INSTALL_DIR=$install_dir" >> debian/rules.pre
205 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
209 if [ ${cross:0:1} != "/" ]
211 cross="/opt/cross/$cross"
214 if [ -f "$cross/setenv.sh" ]
217 cp $cross/setenv.sh debian/setenv.sh
221 # determine architecture
222 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
223 GNU_ARCH=${GNU_ARCH##*/}
224 arch_opt="-t $GNU_ARCH"
232 dpkg-architecture $arch_opt >> debian/setenv.sh
234 echo "paket=$paket" >> debian/setenv.sh
237 if [ -z "$optversion" ]
243 echo "version=$version" >> debian/rules.pre
244 echo "version=$version" >> debian/setenv.sh
245 echo "build=$build" >> debian/rules.pre
246 echo "build=$build" >> debian/setenv.sh
248 # get repository name
252 # echo "pwd=$pwd" >> debian/rules.pre
254 echo "building $paket with version/build=$version-$build"
256 pushd debian >/dev/null
257 # ./debian -------------------------------------
259 ln -sf /usr/share/mbuild/rules .
266 # check for pre/post installation scripts
267 if [ -f $paket.preinst ]
269 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
271 if [ -f $paket.postinst ]
273 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
275 if [ -f $paket.prerm ]
277 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
279 if [ -f $paket.postrm ]
281 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
284 # check for README.debian
285 if [ -f $paket.README.debian ]
287 cp $paket.README.debian README.debian
292 # add export to setenv.sh
293 sed -i "s/^/export /" setenv.sh
296 # ./. ---------------------------------------------
299 if [ -x debian/$paket.prepare ]
302 debian/$paket.prepare
305 if [ "$compile_type" == "NONE" ]
307 echo "BUILD=nobuild" >> debian/rules.pre
309 echo "BUILD=build" >> debian/rules.pre
311 if [ $extern_build -eq 1 ]
314 echo "BUILD_DIR=~/build" >> debian/rules.pre
319 if [ "$compile_type" != "CMAKE" ]
321 cp debian/rules.pre $BUILD_DIR/$compile_dir/make.pre
322 pushd $BUILD_DIR/$compile_dir >/dev/null
323 ln -sf /usr/share/mbuild/makefile .
324 if [ -n "$sources_suffix" ]
326 echo "SOURCES = \\" >> make.pre
327 for suf in $sources_suffix
329 find . -name "*.$suf" -exec echo " "{}" \\" >> make.pre \;
336 if [ -x debian/$paket.build ]
338 if [ -x debian/$paket.prebuild ]
340 pushd $BUILD_DIR >/dev/null
342 debian/$paket.prebuild
348 if [ -e debian/$paket.cmake ]