]> wagnertech.de Git - projects.git/blobdiff - tools/make/mconfigure
gitarre
[projects.git] / tools / make / mconfigure
index dda9b97ffc319ed71f2c56050a378e93271d3757..0d053b1658538a3fb859fdcd1cd303ad5e2028c8 100755 (executable)
@@ -3,7 +3,33 @@ set -e
 
 function echo_usage {
        echo "usage: mconfigure [options] <package>"
-       ./configure -I
+       echo "  -o: old style build (not recommended"
+       ./configure -h
+}
+
+function create_conf {
+       if [ -f "debian/$paket.cmake" ]
+       then
+               echo "compile_type=CMAKE" > debian/$paket.conf
+       elif [ -f "debian/$paket.build" ]
+       then
+               if [ -f "debian/$paket.cpp" ]
+               then
+                       echo "compile_type=CPP" > debian/$paket.conf
+               else
+                       echo "compile_type=ANY" > debian/$paket.conf
+               fi
+       else
+               echo "compile_type=NONE" > debian/$paket.conf
+       fi
+       
+       if [ -f "$paket.control" -a -f "$paket.cp" ]
+       then
+               echo "target_type=DEB" >> debian/$paket.conf
+       else
+               echo "target_type=FILE" >> debian/$paket.conf
+       fi
+       echo "$paket.conf created."
 }
 
 ##############################################################################
@@ -20,9 +46,11 @@ configure=0
 configure_args="-i debian/tmp"
 while [ $OPTIND -le "$#" ]
 do
-       if getopts "c" opt
+       if getopts "o" opt
        then
                case $opt in
+                       o) old_build=1
+                               ;;
                        \?) $confirure_args="$configure_ars -$OPTARG"
                                if [ $OPTARG="a" -o $OPTARG="C" -o $OPTARG="i" -o $OPTARG="v" ]
                                then
@@ -49,9 +77,16 @@ fi
 
 if [ ! -f debian/$paket.conf ]
 then
+       # check if any files for $paket are present
+       if ! ls debian/$paket.* 2>/dev/null
+       then
+               echo "$paket is no build target in this repository."
+               exit 5
+       fi
+       
+       # build conf file
        echo "$paket.conf missing. We create it ..."
-       echo "to be implemented ..."
-       exit 5
+       create_conf
 fi
 
 if [ ! -e configure ]
@@ -67,18 +102,29 @@ then
                rm -rf ~/build
                mkdir ~/build
        fi
+       configure_args="$configure_args -d ~/build"
 fi
 
 # perform configure
 . debian/$paket.conf
-if [ -n "$compile_dir" ]
+if [ -n $old_build ]
 then
-       configure_args="$configure_args -b $compile_dir"
+       rm debian/$paket.conf
 fi
-if [ -z "$compile_type" ]
+
+if [ "$compile_type" != "NONE" ]
 then
-       echo "compile_type required in $paket.conf"
-       exit 51
+       configure_args="$configure_args -b"
+       if [ -n "$compile_dir" ]
+       then
+               configure_args="$configure_args -d $compile_dir"
+       fi
+       if [ -z "$compile_type" ]
+       then
+               echo "compile_type required in $paket.conf"
+               exit 51
+       fi
+       configure_args="$configure_args -c $compile_type"
 fi
 if [ "$target_type" == "FILE" ]
 then
@@ -144,13 +190,21 @@ then
 elif [ "$target_type" == "FILE" ]
 then
        echo "PACK=version" >> debian/rules.pre
-       if [ -z "$compile_target" ]
+       if [ "$compile_type" != "ANY" ]
        then
-               echo "compile_target is needed for target_type FILE"
-               exit 12
+               if [ -z "$compile_target" ]
+               then
+                       echo "compile_target is needed for target_type FILE"
+                       exit 12
+               fi
+               echo "COMPILE_TARGET = $compile_target" >> debian/rules.pre
+               if [ -n "$target_name" ]
+               then
+                       echo "TARGET = $target_name" >> debian/rules.pre
+               else
+                       echo "TARGET = $paket" >> debian/rules.pre
+               fi
        fi
-       echo "TARGET = $compile_target" >> debian/rules.pre
-       
 else
        echo "Unknown target type: $target_type"
        exit 13