aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: 65ef25dc724562c8509bb655d067989933777eff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
dnl  
dnl This script configures the build machine to have what it needs to
dnl build and test a GNU toolchain.
dnl 

AC_PREREQ(2.59c)
AC_INIT(cbuild, 2.0dev)
AC_CONFIG_SRCDIR([cbuild2.sh])
dnl AC_CONFIG_HEADERS([config.h])
dnl AC_CONFIG_MACRO_DIR([macros])

dnl --------------------------------------------------------
dnl Figure out development tool stuff
dnl --------------------------------------------------------
AC_PROG_CC
AC_PROG_CXX
if test x"${CC}" = x -a x"${CXX}" = x; then
   AC_MSG_ERROR([You need 'gcc' and 'g++' to fully run cbuild!])
fi
AC_PROG_INSTALL
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

AC_PATH_PROG(WGET, wget)
AC_SUBST(WGET)
AC_PATH_PROG(CURL, curl)
AC_SUBST(CURL)
AC_PATH_PROG(SCP, scp)
AC_SUBST(SCP)
AC_PATH_PROG(RSYNC, rsync)
AC_SUBST(RSYNC)
if test x"${RSYNC}" = x; then
   AC_MSG_ERROR([You need 'rsync' to fully run cbuild!])
fi
AC_PATH_PROG(CCACHE, ccache)

dnl AC_PATH_PROG(GITBZR, git-bzr)
AC_PATH_PROG(BASH, bash)
AC_SUBST(BASH)

if test x"${BASH}" = x; then
   AC_MSG_ERROR([You need Bash to run configure properly!])
fi

AC_PATH_PROG(FLEX, flex)
if test x"${FLEX}" = x; then
   AC_MSG_ERROR([You need 'flex' to run configure properly!])
fi

AC_PATH_PROG(BISON, bison)
if test x"${BISON}" = x; then
   AC_MSG_ERROR([You need 'bison' to run configure properly!])
fi

AC_PATH_PROG(AUTOGEN, autogen)
if test x"${AUTOGEN}" = x; then
   AC_MSG_ERROR([You need 'autogen' to run configure properly!])
fi

AC_PATH_PROG(LYNX, lynx)
if test x"${LYNX}" = x; then
   AC_MSG_WARN([You need 'lsync' to fully run cbuild!])
fi

AC_PATH_PROG(WGET, wget)
if test x"${WGET}" = x; then
   AC_MSG_ERROR([You need 'wget' to run configure properly!])
fi

AC_CHECK_LIB(libcurses, beep)

dnl Look for packages that do not have executables, so we are forced
dnl to ask the packaging system if they are installed. This is more
dnl reliable and portble than using pkg-config.
#packages="git-svn bzr-fastimport svn-all-fast-exp libncurses5-dev texinfo"
packages="texinfo gawk"
dpkg="`which dpkg`"
result=$?
missing=""
if test ${result} -eq 0; then
    # add Ubuntu specific packages
    packages="${packages} gcc-multilib g++-multilib zlib1g-dev"
    for i in ${packages}; do
	AC_MSG_CHECKING([if $i is installed])
#	exists=`dpkg --get-selections | grep -c "^$i\[[:space:]\]*install"`
	exists="`dpkg -l $i | tail -1| cut -d ' ' -f 1`"
	if test x"${exists}" != x'ii'; then
	    AC_MSG_RESULT([no, install $i])
	    missing="${missing} $i"
	else
	    AC_MSG_RESULT([yes])
	fi
    done
else
    yum="`which yum`"
    result=$?
    for i in ${packages}; do
	exists="`rpm -q -a $i| grep -c $i`"
	if test ${exists} -eq 0; then
	    AC_MSG_RESULT([no, install $i])
	    missing="${missing} $i"
	else
	    AC_MSG_RESULT([yes])
	fi
    done
fi

dnl FIXME: Look for git-svn and git-bzr, bzr-fastimport svn-all-fast-export

dnl Get build date for helping us debugging
BUILDDATE="`date +%Y%m%d`"
AC_SUBST(BUILDDATE)

dnl While it's a bad idea to store the database access information in an unencrypted
dnl text file, this is useful for cbuild2 development itself. This option should never
dnl be used in a production environment. The default is read-only access. You can also
dnl set DBUSER and DBPASSWD in your environment, but that's also a possible security
dnl risk.
AC_ARG_WITH(dbuser,
  AC_HELP_STRING([--with-dbuser], [set the user name for the database]),
  dbuser=${withval} ; AC_MSG_WARN([The database user name is stored in an unencrypted text file which could be considered a security risk!]),
  dbuser='default')

AC_ARG_WITH(dbpasswd,
  AC_HELP_STRING([--with-dbpasswd], [set the user password for the database]),
  dbpasswd=${withval} ; AC_MSG_WARN([It's a bad idea to set the database password as it's stored in an unencrypted text file!]),
  dbpasswd='default')

AC_ARG_WITH(dbhost,
  AC_HELP_STRING([--with-dbhost], [set the database hostname]),
  dbhost=${withval} ; AC_MSG_WARN([The database hostname is stored in an unencrypted text file which could be considered a security risk!]),
  dbhost='localhost')

dnl The top of the cbuild tree
AC_ARG_WITH(toplevel,
  AC_HELP_STRING([--with-toplevel], []),
  CBUILD_TOP=${withval},
  CBUILD_TOP="${PWD}")
AC_SUBST(CBUILD_TOP)

if test ! -d ${CBUILD_TOP}; then
   AC_MSG_WARN([${CBUILD_TOP} does not exist so creating directory!])
   mkdir -p ${CBUILD_TOP}
fi

dnl The top of the cbuild tree
AC_ARG_WITH(sysroot,
  AC_HELP_STRING([--with-sysroot], []),
  SYSROOTS=${withval},
  SYSROOTS="${CBUILD_TOP}"/sysroots)
AC_SUBST(SYSROOTS)

if test ! -d ${SYSROOTS}; then
   AC_MSG_WARN(${SYSROOTS} does not exist so creating directory!)
   mkdir -p ${SYSROOTS}
fi

dnl The local directory where snapshots are stored
AC_ARG_WITH(local-snapshots,
  AC_HELP_STRING([--with-local-snapshots], [Where downloaded tarballs are stored]),
  LOCAL_SNAPSHOTS=${withval},
  LOCAL_SNAPSHOTS="${CBUILD_TOP}/snapshots")
AC_SUBST(LOCAL_SNAPSHOTS)

if test ! -d ${LOCAL_SNAPSHOTS}; then
   AC_MSG_WARN(${LOCAL_SNAPSHOTS} does not exist so creating directory!)
   mkdir -p ${LOCAL_SNAPSHOTS}
fi

dnl The top directory for make install, also where all the components we build live
AC_ARG_WITH(local-builds,
  AC_HELP_STRING([--with-local-builds], []),
  LOCAL_BUILDS=${withval},
  LOCAL_BUILDS="${CBUILD_TOP}/builds")
AC_SUBST(LOCAL_BUILDS)

if test ! -d ${LOCAL_BUILDS}; then
   AC_MSG_WARN(${LOCAL_BUILDS} does not exist so creating directory!)
   mkdir -p ${LOCAL_BUILDS}
fi

dnl A URL to the remote directory where snapshots are stored
AC_ARG_WITH(remote-snapshots,
  AC_HELP_STRING([--with-remote-snapshots], []),
  REMOTE_SNAPSHOTS=${withval},
  REMOTE_SNAPSHOTS='http://cbuild.validation.linaro.org/snapshots')
AC_SUBST(REMOTE_SNAPSHOTS)

dnl Display the default paths so the user does not need to look in the host.conf file.
echo ""
AC_MSG_NOTICE([Downloaded snapshots will be stored in: ${LOCAL_SNAPSHOTS}])
AC_MSG_NOTICE([My builds will be installed in: ${LOCAL_BUILDS}])
AC_MSG_NOTICE([Sysroots will be installed in: ${SYSROOTS}])
AC_MSG_NOTICE([Remote snapshots will be fetched from: ${REMOTE_SNAPSHOTS}])
echo ""

dnl if you have SSH access to the remote machine
AC_ARG_ENABLE(ssh, AC_HELP_STRING([--enable-ssh], [If you have SSH access to remote build host]),
[case "${enableval}" in
  yes) ENABLE_SSH=yes ;;
  no)  ENABLE_SSH=no ;;
  *)   AC_MSG_ERROR([bad value ${enableval} for enable-ssh option]) ;;
esac], ENABLE_SSH=no)
AC_SUBST(ENABLE_SSH)

dnl AC_ARG_WITH(snapshots,
dnl   AC_HELP_STRING([--with-snapshots], []),
dnl   snapshots=${withval},
dnl   snapshots='cbuild')

dnl Since the configure script is actually checked in, a developer
dnl does not need to have the GNU Autotools installed. However,
dnl installing these is a good idea anyway.
dnl AC_MSG_NOTICE([These are needed by everything to rebuild configure scripts and Makefiles])
AC_CHECK_PROGS(autoconf_prog,autoconf)
AC_CHECK_PROGS(automake_prog,automake)
AC_CHECK_PROGS(libtool_prog,libtool)
if test x"${autoconf_prog}" = x -o x"${automake_prog}" = x -o x"${libtool_prog}" = x; then
   AC_MSG_WARN([You should install autoconf, automake, and libtool])
fi

dnl DejaGnu is used for testing
AC_PATH_PROG(DEJAGNU,runtest)
if test x"${DEJAGNU}" = x; then
   AC_MSG_WARN([You should install dejagnu so you can run tests])
fi

dnl dnl The GNU toolchain, GCC specifically needs these libraries to build.
dnl AC_MSG_NOTICE([These are needed by GCC to compile and link])
dnl AC_CHECK_LIB(isl, isl_version)	dnl at least version 0.11.1
dnl isl_good=
dnl if test x"${ac_cv_lib_isl_isl_version}" = xyes; then
dnl   AC_MSG_CHECKING([if libisl is a high enough version])
dnl   AC_RUN_IFELSE([AC_LANG_SOURCE([
dnl   #include <isl/version.h>
dnl   #include <stdlib.h>
dnl   int main() {
dnl     if (strtof(isl_version()+4, NULL) >= 0.10)
dnl       { return 0; } else { return 1;}
dnl   }
dnl   ])],[isl_good="yes"], [isl_good="no"],[isl_good="cross"])
dnl   AC_MSG_RESULT(${isl_good})
dnl   if test x"${isl_good}" == xno; then
dnl      AC_MSG_WARN([libisl needs to be higher than or equal to 0.11.1])
dnl   fi
dnl fi

dnl AC_CHECK_LIB(cloog-isl, cloog_version)	dnl at least version 0.18.0
dnl cloog_good=
dnl if test x"${ac_cv_lib_cloog_isl_cloog_version}" = xyes; then
dnl   AC_MSG_CHECKING([if libcloog is a high enough version])
dnl   AC_RUN_IFELSE([AC_LANG_SOURCE([
dnl   #include <cloog/version.h>
dnl   #include <stdlib.h>
dnl   int main() {
dnl     if (strtof(cloog_version()+6, NULL) >= 0.18)
dnl       { return 0; } else { return 1;}
dnl   }
dnl   ])],[cloog_good="yes"], [cloog_good="no"],[cloog_good="cross"])
dnl   AC_MSG_RESULT(${cloog_good})
dnl   if test x"${cloog_good}" == xno; then
dnl      AC_MSG_WARN([libcloog-isl needs to be higher than 0.18])
dnl   fi
dnl fi

dnl AC_CHECK_LIB(gmp, __gmpz_size)	dnl at least version 4.3.2
dnl AC_CHECK_HEADER(gmp.h, has_gmp_h=yes, has_gmp_h=no, )	dnl at least version 4.3.2
dnl gmp_good=
dnl if test x"${ac_cv_header_gmp_h}" = xyes; then
dnl   AC_MSG_CHECKING([if libgmp is a high enough version])
dnl   AC_RUN_IFELSE([AC_LANG_SOURCE([
dnl   #include <gmp.h>
dnl   int main() {
dnl     if (__GNU_MP_VERSION >= 4)
dnl       { return 0; } else { return 1;}
dnl   }
dnl   ])],[gmp_good="yes"], [gmp_good="no"],[gmp_good="cross"])
dnl   AC_MSG_RESULT(${gmp_good})
dnl   if test x"${gmp_good}" = xno; then
dnl      AC_MSG_WARN([libgmp needs to be higher than 4.3.2])
dnl   fi
dnl fi

dnl AC_CHECK_HEADER(mpc.h)	dnl at least version 0.8.1
dnl AC_CHECK_LIB(mpc, mpc_init2)	dnl at least version 0.8.1
dnl mpc_good=
dnl if test x"${ac_cv_header_mpc_h}" = xyes; then
dnl   AC_MSG_CHECKING([if libmpc is a high enough version])
dnl   AC_RUN_IFELSE([AC_LANG_SOURCE([
dnl   #include <mpc.h>
dnl   #include <stdlib.h>
dnl   int main() {
dnl     if (strtof(MPC_VERSION_STRING, NULL) >= 0.8)
dnl       { return 0; } else { return 1;}
dnl   }
dnl   ])],[mpc_good="yes"], [mpc_good="no"],[mpc_good="cross"])
dnl   AC_MSG_RESULT(${mpc_good})
dnl   if test x"${mpc_good}" = xno; then
dnl      AC_MSG_WARN([libmpc needs to be higher than 0.8])
dnl   fi
dnl fi

dnl AC_CHECK_HEADER(mpfr.h)	dnl at least version 2.4.2
dnl AC_CHECK_LIB(mpfr, mpfr_cmp)   dnl at least version 2.4.2
dnl mpfr_good=
dnl if test x"${ac_cv_header_mpfr_h}" = xyes; then
dnl   AC_MSG_CHECKING([if libmpfr is a high enough version])
dnl   AC_RUN_IFELSE([AC_LANG_SOURCE([
dnl   #include <mpfr.h>
dnl   int main() {
dnl     if (__GNU_MP_VERSION >= 2)
dnl       { return 0; } else { return 1;}
dnl   }
dnl   ])],[mpfr_good="yes"], [mpfr_good="no"],[mpfr_good="cross"])
dnl   AC_MSG_RESULT(${mpfr_good})
dnl   if test x"${mpfr_good}" = xno; then
dnl      AC_MSG_WARN([libmpfr needs to be higher than 2.4.2])
dnl   fi
dnl fi

dnl Get and store often used information on this build machine
BUILDHOST=${build}
AC_SUBST(BUILDHOST)
DBUSER=${dbuser}
AC_SUBST(DBUSER)
DBPASSWD=${dbpasswd}
AC_SUBST(DBPASSWD)
DBHOST=${dbhost}
AC_SUBST(DBHOST)

CPUS="`getconf _NPROCESSORS_ONLN`"
AC_SUBST(CPUS)
LIBC="`getconf GNU_LIBC_VERSION`"
AC_SUBST(LIBC)
KERNEL="`uname -r`"
AC_SUBST(KERNEL)
BUILD_ARCH="`uname -p`"
AC_SUBST(BUILD_ARCH)
HOSTNAME="`uname -n`"
AC_SUBST(HOSTNAME)
DISTRIBUTION="`lsb_release -sc`"
AC_SUBST(DISTRIBUTION)

AC_OUTPUT(host.conf)

if test x"${missing}" != x; then
    AC_MSG_ERROR([You need to install these packages: ${missing}])
fi

rm -f Makefile
cat<<EOF > Makefile
check:
	${srcdir}/testsuite/test.sh
EOF

# Local Variables:
# c-basic-offset: 2
# tab-width: 2
# indent-tabs-mode: nil
# End: