tautogen.sh - vaccinewars - be a doctor and try to vaccinate the world
(HTM) git clone git://src.adamsgaard.dk/vaccinewars
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
tautogen.sh (4119B)
---
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
3
4 DIE=0
5 package=dopewars
6 srcfile=src/dopewars.c
7
8 # Uncomment the line below to debug this file
9 #DEBUG=defined
10
11 debug ()
12 # print out a debug message if DEBUG is a defined variable
13 {
14 if test ! -z "$DEBUG"
15 then
16 echo "DEBUG: $1"
17 fi
18 }
19
20 version_check ()
21 # check the version of a package
22 # first argument : package name (executable)
23 # second argument : source download url
24 # rest of arguments : major, minor, micro version
25 {
26 EXACT_VERSION=$1
27 PACKAGE=$2
28 URL=$3
29 MAJOR=$4
30 MINOR=$5
31 MICRO=$6
32
33 WRONG=
34
35 debug "major $MAJOR minor $MINOR micro $MICRO"
36 VERSION=$MAJOR
37 if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi
38 if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
39
40 debug "version $VERSION"
41 if [ "$EXACT_VERSION" -eq 0 ]; then
42 echo -n "+ checking for $PACKAGE >= $VERSION ... "
43 else
44 echo -n "+ checking for $PACKAGE == $VERSION ... "
45 fi
46
47 ($PACKAGE --version) < /dev/null > /dev/null 2>&1 ||
48 {
49 echo
50 echo "You must have $PACKAGE installed to compile $package."
51 echo "Download the appropriate package for your distribution,"
52 echo "or get the source tarball at $URL"
53 return 1
54 }
55 # the following line is carefully crafted sed magic
56 pkg_version=`$PACKAGE --version|head -n 1|sed 's/^[a-zA-Z\.\ ()]*//;s/^.* //'`
57 debug "pkg_version $pkg_version"
58 pkg_major=`echo $pkg_version | cut -d. -f1`
59 pkg_minor=`echo $pkg_version | sed s/[-,a-z,A-Z].*// | cut -d. -f2`
60 pkg_micro=`echo $pkg_version | sed s/[-,a-z,A-Z].*// | cut -d. -f3`
61 test -z "$pkg_minor" && pkg_minor=0
62 test -z "$pkg_micro" && pkg_micro=0
63
64 debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
65
66 #start checking the version
67 if [ "$EXACT_VERSION" -eq 0 ]; then
68 debug "version check >="
69 if [ "$pkg_major" -lt "$MAJOR" ]; then
70 WRONG=1
71 elif [ "$pkg_major" -eq "$MAJOR" ]; then
72 if [ "$pkg_minor" -lt "$MINOR" ]; then
73 WRONG=1
74 elif [ "$pkg_minor" -eq "$MINOR" -a "$pkg_minor" -lt "$MINOR" ]; then
75 WRONG=1
76 fi
77 fi
78 else
79 debug "version check =="
80 if [ "$MAJOR" -ne "$pkg_major" -o \
81 "$MINOR" -ne "$pkg_minor" -o \
82 "$MICRO" -ne "$pkg_micro" ]; then
83 WRONG=1
84 fi
85 fi
86
87 if test ! -z "$WRONG"; then
88 echo "found $pkg_version, not ok !"
89 echo
90 if [ "$EXACT_VERSION" -eq 0 ]; then
91 echo "You must have $PACKAGE $VERSION or greater to compile $package."
92 echo "Get the latest version from <$URL>."
93 else
94 echo "You must have exactly $PACKAGE $VERSION to compile $package."
95 echo "Get this version from <$URL>."
96 fi
97 return 1
98 else
99 echo "found $pkg_version, ok."
100 fi
101 }
102
103 version_check 0 "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 13 || DIE=1
104 version_check 0 "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 4 || DIE=1
105 #version_check 0 "xgettext" "ftp://ftp.gnu.org/pub/gnu/gettext/" 0 10 38 || DIE=1
106 #version_check 0 "msgfmt" "ftp://ftp.gnu.org/pub/gnu/gettext/" 0 10 38 || DIE=1
107
108 if test "$DIE" -eq 1; then
109 exit 1
110 fi
111
112 test -f $srcfile || {
113 echo "You must run this script in the top-level $package directory"
114 exit 1
115 }
116
117 if test -z "$*"; then
118 echo "I am going to run ./configure with no arguments - if you wish "
119 echo "to pass any to it, please specify them on the $0 command line."
120 fi
121
122 echo "+ running aclocal ..."
123 aclocal -I m4 $ACLOCAL_FLAGS || {
124 echo
125 echo "aclocal failed - check that all needed development files are present on system"
126 exit 1
127 }
128
129 echo "+ running autoheader ... "
130 autoheader || {
131 echo
132 echo "autoheader failed"
133 exit 1
134 }
135 echo "+ running autoconf ... "
136 autoconf || {
137 echo
138 echo "autoconf failed"
139 exit 1
140 }
141 echo "+ running automake ... "
142 automake -a -c || {
143 echo
144 echo "automake failed"
145 exit 1
146 }
147
148 # now remove the cache, because it can be considered dangerous in this case
149 echo "+ removing config.cache ... "
150 rm -f config.cache
151
152 echo "+ running configure ... "
153 if test -n "$*"; then
154 echo "using: $@"
155 fi
156 echo
157
158 ./configure "$@" || {
159 echo
160 echo "configure failed"
161 exit 1
162 }
163
164 echo
165 echo "Now type 'make' to compile $package."