cleanup specfile for packaging
[profile/ivi/gpsd.git] / autogen.sh
1 #!/bin/sh
2
3 # Automakeversion
4 AM_1=1
5 AM_2=7
6 AM_3=6
7
8 # Autoconfversion
9 AC_1=2
10 AC_2=57
11
12 # Libtoolversion
13 LT_1=1
14 LT_2=5
15
16 # Check automake version
17 AM_VERSION=`automake --version | sed -n -e 's#[^0-9]* \([0-9]*\)\.\([0-9]*\)\.*\([0-9]*\).*$#\1 \2 \3#p'`
18 AM_V1=`echo $AM_VERSION | awk '{print $1}'`
19 AM_V2=`echo $AM_VERSION | awk '{print $2}'`
20 AM_V3=`echo $AM_VERSION | awk '{print $3}'`
21
22 if [ "$AM_1" -gt "$AM_V1" ]; then
23         AM_ERROR=1 
24 else
25         if [ "$AM_1" -eq "$AM_V1" ]; then
26                 if [ "$AM_2" -gt "$AM_V2" ]; then
27                         AM_ERROR=1 
28                 else
29                         if [ "$AM_2" -eq "$AM_V2" ]; then
30                                 if [ -n "$AM_V3" -o "$AM_3" -gt "$AM_V3" ]; then
31                                         AM_ERROR=1 
32                                 fi
33                         fi
34                 fi
35         fi
36 fi
37
38 if [ "$AM_ERROR" = "1" ]; then
39         echo -n "Your automake version `automake --version | sed -n -e 's#[^0-9]* \([0-9]*\.[0-9]*\.[0-9]*\).*#\1#p'`"
40         echo " is older than the suggested one, $AM_1.$AM_2.$AM_3"
41         echo "Go on at your own risk. :-)"
42         echo
43 fi
44
45 # Check autoconf version
46 AC_VERSION=`autoconf --version | sed -n -e 's#[^0-9]* \([0-9]*\)\.\([0-9]*\).*$#\1 \2#p'`
47 AC_V1=`echo $AC_VERSION | awk '{print $1}'`
48 AC_V2=`echo $AC_VERSION | awk '{print $2}'`
49
50 if [ "$AC_1" -gt "$AC_V1" ]; then
51         AC_ERROR=1 
52 else
53         if [ "$AC_1" -eq "$AC_V1" ]; then
54                 if [ "$AC_2" -gt "$AC_V2" ]; then
55                         AC_ERROR=1 
56                 fi
57         fi
58 fi
59
60 if [ "$AC_ERROR" = "1" ]; then
61         echo -n "Your autoconf version `autoconf --version | sed -n -e 's#[^0-9]* \([0-9]*\.[0-9]*\).*#\1#p'`"
62         echo " is older than the suggested one, $AC_1.$AC_2"
63         echo "Go on at your own risk. :-)"
64         echo
65 fi
66
67 #Check for pkg-config
68 if which pkg-config 1>/dev/null 2>&1; then
69         #pkg-config seems to be installed. Check for m4 macros:
70         tmpdir=`mktemp -d "./autogenXXXXXX"`
71         if [ -z ${tmpdir} ]; then
72                 echo -n "Creating a temporary directory failed. "
73                 echo 'Is mktemp in $PATH?'
74                 echo
75                 exit 1
76         fi
77
78         oldpwd=`pwd`
79         cd "${tmpdir}"
80         cat > configure.ac << _EOF_
81 AC_INIT
82 PKG_CHECK_MODULES(QtNetwork, [QtNetwork >= 4.4],  ac_qt="yes", ac_qt="no")
83 _EOF_
84         aclocal
85         autoconf --force
86         grep -q PKG_CHECK_MODULES configure
87         PKG_MACRO_AVAILABLE=$?
88         cd "${oldpwd}"
89         rm -rf "${tmpdir}"
90         if [ ${PKG_MACRO_AVAILABLE} -eq 0 ]; then
91                 echo -n "pkg-config installed, but autoconf is not able to find pkg.m4. "
92                 echo "Unfortunately the generated configure would not work, so we stop here."
93                 echo
94                 exit 1
95         fi
96 else
97         echo -n "pkg-config not found. "
98         echo "pkg-config is required to create a working configure, so we stop here."
99         echo
100         exit 1
101 fi
102
103
104 # Check libtool version
105 if [ -z "$LIBTOOL" ] ; then
106         LIBTOOL="libtool"
107 fi
108 LT_VERSION=`${LIBTOOL} --version | sed -n -e 's#[^0-9]* \([0-9]*\)\.\([0-9]*\).*$#\1 \2#p'`
109 LT_V1=`echo $LT_VERSION | awk '{print $1}'`
110 LT_V2=`echo $LT_VERSION | awk '{print $2}'`
111
112 if [ "$LT_1" -gt "$LT_V1" ]; then
113         LT_ERROR=1 
114 else
115         if [ "$LT_1" -eq "$LT_V1" ]; then
116                 if [ "$LT_2" -gt "$LT_V2" ]; then
117                         LT_ERROR=1 
118                 fi
119         fi
120 fi
121
122 if [ "$LT_ERROR" = "1" ]; then
123         echo -n "Your libtool version `libtool --version | sed -n -e 's#[^0-9]* \([0-9]*\.[0-9]*\).*#\1#p'`"
124         echo " is older than the suggested one, $LT_1.$LT_2"
125         echo "Go on at your own risk. :-)"
126         echo
127 fi
128
129 if [ -z "$LIBTOOLIZE" ] ; then
130         LIBTOOLIZE="libtoolize"
131 fi
132 echo Configuring build environment for gpsd
133 aclocal \
134   && ${LIBTOOLIZE} --force --copy \
135   && autoheader --force \
136   && automake --add-missing --foreign --copy  --include-deps \
137   && autoconf --force \
138   && echo Now running configure to configure gpsd \
139   && echo "./configure $@" \
140   && ./configure "$@"