cpp-d1064k
[projects.git] / tools / make / mconfigure
index ed40855..691825d 100755 (executable)
@@ -5,6 +5,7 @@ function echo_usage {
        echo "usage: mconfigure [options] <package>"
        echo "  -a <arch>"
        echo "  -c : configure"
+       echo "  -C <cross environment>"
        echo "  -d : compile"
        echo "  -p : pack default: do all"
        echo "  -o : support old Debian 7 format"
@@ -13,8 +14,17 @@ function echo_usage {
 function check_unversioned {
        # has to be called in the projects base directory
        # result: "M" in stdout or nothing
-       
        set -e
+       
+       # check if build is running in a sandbox
+       if ! [ -f .cm.ignore ]
+       then
+               # we create one
+               echo ".cm.ignore" > .cm.ignore
+               echo "debian.*" >> .cm.ignore
+               echo "up.*" >> .cm.ignore
+       fi
+       
        project=$(pwd)
        project=${project##*/}
        pushd .. >/dev/null
@@ -88,7 +98,7 @@ fi
 configure=0
 compile=0
 pack=0
-while getopts "a:cdpo" opt; do
+while getopts "a:cC:dpo" opt; do
        case $opt in
                a) ARCH=$OPTARG
                        ;;
@@ -96,6 +106,8 @@ while getopts "a:cdpo" opt; do
                        ;;
                d)      compile=1
                        ;;
+               C) cross=$OPTARG
+                       ;;
                p)      pack=1
                        ;;
                o)      oldpack="-Zgzip"
@@ -120,6 +132,12 @@ fi
 
 paket=$1
 
+if [ -n "$ARCH" -a -n "$cross" ]
+then
+       echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
+       exit 1
+fi
+
 # if nothing is selected, select all
 if [ $configure -eq 0 -a $compile -eq 0 -a $pack -eq 0 ]
 then
@@ -134,13 +152,23 @@ then
        rm debian/changelog debian/control 2>/dev/null || true
        
        # mconfigure builds 2 environment files: setenv.sh + rules.pre
+       echo "" > debian/rules.pre
+       if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
        
        if [ -n "$ARCH" ]
        then
                arch_opt="-a $ARCH"
        fi
-       dpkg-architecture $arch_opt > debian/setenv.sh
-       echo "" > debian/rules.pre
+       if [ -n "$cross" ]
+       then
+               if [ ${cross:0:1} != "/" ]
+               then
+                       cross="/opt/cross/$cross"
+               fi
+               . "$cross/setenv.sh"
+               cp $cross/setenv.sh debian/setenv.sh
+       fi
+       dpkg-architecture $arch_opt >> debian/setenv.sh
        
        echo "paket=$paket" >> debian/setenv.sh
        echo "oldpack=\"$oldpack\"" >> debian/setenv.sh
@@ -207,8 +235,14 @@ then
        # build prepare
        if [ -x debian/$paket.prepare ]
        then
+               . debian/setenv.sh
                debian/$paket.prepare
        fi
+       if [ -e debian/$paket.cmake ]
+       then
+               # trigger build
+               touch debian/$paket.build
+       fi              
        if [ -e debian/$paket.build ]
        then
                if [ -e ../build ]
@@ -217,21 +251,14 @@ then
                        mkdir ../build
                fi
                if grep -- "-prepare" debian/$paket.build >/dev/null
-               then
-                       debian/rules sync
-                       debian/$paket.build -prepare
+               then                    
+                       echo "prepare in <paket>.build no longer supported. Use <paket>.prebuild"
+                       exit 2
                fi
                # sync build dir
-               . debian/setenv.sh
-               debian/rules sync
+#              . debian/setenv.sh
+#              debian/rules sync
                
-               # executing prebuild
-               if [ -x debian/$paket.prebuild ]
-               then
-                       pushd ~/build >/dev/null
-                       debian/$paket.prebuild
-                       popd >/dev/null
-               fi
        fi
        
        # pack prepare
@@ -261,7 +288,7 @@ then
 fi
 if [ $compile -eq 1 ]
 then
-       # build artefacts
+       # build package 
        . debian/setenv.sh
        debian/rules build
 fi