d329219f5b79ca33db3c0b818df916f7dc31c971
[projects.git] / tools / make / mconfigure
1 #!/bin/bash
2 set -e
3
4 function echo_usage {
5         echo "usage: mconfigure <package> [options]"
6         echo "  -a <arch>"
7 }
8
9 function set_build {
10         if [ -e .svn ]
11         then
12                 build=$(svnversion)
13         elif [ -e .git ]
14         then
15                 build=$(git describe --tags 2>/dev/null) || true
16                 if test -z "$build"
17                 then
18                         build="0.0-TOP"
19                 fi
20                 changes=$(git status -s |grep "^ *M") || true
21                 if test -z "$changes"
22                 then
23                         build="${build}M"
24                 fi
25         fi
26 }
27
28 # to build a package you need ...
29 # <package>.cp (optional): copy step for package production
30 # <package>.cpp.sh (optional): commands to setup the C++ compile environment
31
32 if [ $# -lt 1 ]
33 then
34         echo_usage
35         exit 1
36 fi
37
38 if [ ! -d debian ]
39 then
40         echo "run mconfigure in the project base directory!"
41         exit 2
42 fi
43
44 export paket=$1
45 shift
46 ARCH=""
47 cpp_build=0
48
49 set_build
50 export build
51
52 # get repository name
53 tmp=$(pwd)
54 export pwd=${tmp##*/}
55
56 echo "building $paket with build $build"
57
58 #while getopts ":a" opt; do
59 #       case $opt in
60 #               a) ARCH=$OPTARG
61 #                       ;;
62 #               \?) echo "Invalid option: -$OPTARG"
63 #                       echo_usage
64 #                       exit 1
65 #                       ;;
66 #               :) echo "Option -$OPTARG requires an argument."
67 #                       echo_usage
68 #                       exit 1
69 #                       ;;
70 #       esac
71 #done
72 #
73 ## clean dirs and check out
74 #if [ -d build -a $delete_src -eq 1 ]
75 #then
76 #       rm -rf build
77 #fi
78 #
79
80 pushd debian >/dev/null
81
82 ln -sf /usr/share/mbuild/rules .
83
84 #if [ -e tmp ]
85 #then
86 #       rm -rf tmp
87 #fi
88 #rm *.stamp 2>/dev/null || true
89 #rm make.pre 2>/dev/null || true
90
91 mkdir -p tmp/DEBIAN
92
93 # load util functions for C/C++ - build
94 if [ -f $paket.cpp.sh ]
95 then
96         cpp_build=1
97         . projects/tools/make/c_configure.sh
98         . $paket.cpp.sh
99 fi
100
101 # copy package control
102 #control=$(find .. -name $paket.control)
103 #build_number=${build#*_}
104 #if [ -z "$control" ]
105 #then
106 #       echo "warning: control file not found"
107 #       echo "  this file is necessary for any package production."
108 #else   
109 #       sed "s/%BUILD%/$build_number/" $control |sed "s/%ARCH%/$ARCH/" >$paket.control
110 #       echo "$paket.control written."
111 #
112 #       # extract version
113 #       version=$(grep Version $paket.control |sed "s/Version: //")
114 #fi
115
116 popd >/dev/null
117
118 # build package
119 debian/rules binary
120
121 ## check for copy file
122 #if [ ! -f $paket.cp ]
123 #then
124 #       # search for copy file
125 #       copy=$(find .. -name $paket.cp)
126 #       if [ -n "$copy" ]
127 #       then
128 #               ln -sf $copy .
129 #       else
130 #               echo "warning: file $paket.cp missing or not executable:"
131 #               echo "  this file is necessary for any package production."
132 #       fi
133 #fi
134 #
135 ## check for installation scripts
136 #files=$(find .. -name $paket.preinst)
137 #files="$files $(find .. -name $paket.postinst)"
138 #files="$files $(find .. -name $paket.prerm)"
139 #files="$files $(find .. -name $paket.postrm)"
140 #for file in $files
141 #do
142 #       ln -sf $file .
143 #done
144
145 # create generic make.pre, if not existing
146 #if [ ! -f make.pre ]
147 #then
148 #       cat  >>make.pre <<MAKE_PRE
149 ## mBuild make.pre script (auto generated)
150 #project = $paket
151 #COPY = ./$paket.cp
152 #MAKE_PRE
153 #       if [ -n "$ARCH" ]
154 #       then
155 #               echo "arch = $ARCH" >>make.pre
156 #               echo "_arch = _${ARCH}" >>make.pre
157 #       fi
158 #       echo "make.pre written."
159 #fi
160 #
161 ## append version to make.pre
162 #echo "version = $version" >> make.pre
163 #echo "build = $build" >> make.pre
164