comparison acsupport/acinclude.m4 @ 283:f58bc1b2c2bc

Reorganization of the host-side autoconfiscation support, and a couple of minor bug fixes. The main goal is to support per-package host-side software in addition to the generic host-side tools. For example, the synthetic target HAL and device driver packages can now have host subdirectories with support code.
author bartv
date Sun, 11 Aug 2002 21:40:50 +0000
parents
children c0ffaecb376e
comparison
equal deleted inserted replaced
282:a29ee6c2dd3c 283:f58bc1b2c2bc
1 dnl Process this file with aclocal to get an aclocal.m4 file. Then
2 dnl process that with autoconf.
3 dnl ====================================================================
4 dnl
5 dnl acinclude.m4
6 dnl
7 dnl Various autoconf macros that are shared between different
8 dnl eCos packages.
9 dnl
10 dnl ====================================================================
11 dnl ####ECOSHOSTGPLCOPYRIGHTBEGIN####
12 dnl ----------------------------------------------------------------------------
13 dnl Copyright (C) 2002 Bart Veer
14 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15 dnl
16 dnl This file is part of the eCos host tools.
17 dnl
18 dnl This program is free software; you can redistribute it and/or modify it
19 dnl under the terms of the GNU General Public License as published by the Free
20 dnl Software Foundation; either version 2 of the License, or (at your option)
21 dnl any later version.
22 dnl
23 dnl This program is distributed in the hope that it will be useful, but WITHOUT
24 dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
26 dnl more details.
27 dnl
28 dnl You should have received a copy of the GNU General Public License along with
29 dnl this program; if not, write to the Free Software Foundation, Inc.,
30 dnl 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 dnl
32 dnl ----------------------------------------------------------------------------
33 dnl ####ECOSHOSTGPLCOPYRIGHTEND####
34 dnl ====================================================================
35 dnl#####DESCRIPTIONBEGIN####
36 dnl
37 dnl Author(s): bartv
38 dnl Contact(s): bartv
39 dnl Date: 1998/12/16
40 dnl Version: 0.01
41 dnl
42 dnl####DESCRIPTIONEND####
43 dnl ====================================================================
44
45 dnl ====================================================================
46 dnl Ensure that configure is not being run in the source tree, i.e.
47 dnl that a separate build tree has been created. This is not absolutely
48 dnl necessary at the time of writing but may become so in future, and
49 dnl is good practice.
50
51 AC_DEFUN(ECOS_CHECK_BUILD_ne_SRC,[
52 AC_MSG_CHECKING([that a separate build tree is being used])
53 ecos_cwd=`/bin/pwd`
54 if test "${srcdir}" = "." ; then
55 srcdir=${ecos_cwd}
56 fi
57 if test "${ecos_cwd}" = "${srcdir}" ; then
58 AC_MSG_RESULT([no])
59 AC_MSG_ERROR([This configure script should not be run inside the source tree. Instead please use a separate build tree])
60 else
61 AC_MSG_RESULT(yes)
62 fi
63 ])
64
65 dnl ====================================================================
66 dnl The AM_INIT_AUTOMAKE() will define a symbol VERSION for the
67 dnl package's version number. Unfortunately this symbol is rather
68 dnl hard to share if several different packages are involved, so this
69 dnl macro is used to define an alternative symbol
70
71 AC_DEFUN(ECOS_SUBST_VERSION,[
72 AC_REQUIRE([AM_INIT_AUTOMAKE])
73 ifelse($#,1,,AC_MSG_ERROR([Invalid number of arguments passed to ECOS SUBST_VERSION]))
74 AC_DEFINE_UNQUOTED($1, "$VERSION")
75 ])
76
77 dnl --------------------------------------------------------------------
78 dnl Convert a cygwin pathname to something acceptable to VC++ (but
79 dnl still invoked from bash and cygwin's make). This means using
80 dnl the cygpath utility and then translating any backslashes into
81 dnl forward slashes to avoid confusing make.
82
83 AC_DEFUN(ECOS_MSVC_PATH, [
84 AC_REQUIRE([ECOS_PROG_MSVC])
85 ifelse($#, 1, , AC_MSG_ERROR("Invalid number of arguments passed to ECOS MSVC_PATH"))
86 if test "${MSVC}" = "yes" ; then
87 $1=`cygpath -w ${$1} | tr \\\\\\\\ /`
88 fi
89 ])
90
91 dnl ====================================================================
92 dnl An internal utility to define eCos variants of various compilation
93 dnl related flags. The aim is to avoid messing with CFLAGS, LIBS, and
94 dnl so on because those are used for feature tests as well as for
95 dnl passing on to the application.
96 AC_DEFUN(ECOS_PROG_DEFINE_COMPILER_FLAGS,[
97 ecos_CFLAGS=""
98 ecos_CXXFLAGS=""
99 ecos_LDADD=""
100 ecos_INCLUDES=""
101 ecos_LIBS=""
102 AC_SUBST(ecos_CFLAGS)
103 AC_SUBST(ecos_CXXFLAGS)
104 AC_SUBST(ecos_LDADD)
105 AC_SUBST(ecos_INCLUDES)
106 AC_SUBST(ecos_LIBS)
107 ])
108
109 dnl For historical reasons some of the eCos host-side software can be
110 dnl built with Visual C++ as well as g++. The user can specify this
111 dnl at configure time using CC=cl, where cl.exe is the compiler driver.
112 dnl This macro will set the variable MSVC to "yes" or to "no" depending
113 dnl on whether or not VC++ is being used, analogous to the variable
114 dnl GCC set by AC_PROG_CC. It provides support for an automake
115 dnl conditional thus allowing the makefile to adapt somewhat to the
116 dnl compiler being used. Finally it fills in the ECOS_INCLUDES,
117 dnl ECOS_LIBS and ECOS_LDADD variables with suitable initial values.
118
119 AC_DEFUN(ECOS_PROG_MSVC,[
120 AC_REQUIRE([AC_PROG_CC])
121 AC_REQUIRE([AC_PROG_CXX])
122 AC_REQUIRE([ECOS_PROG_DEFINE_COMPILER_FLAGS])
123
124 AC_MSG_CHECKING("for Visual C++")
125 MSVC="no";
126 if test "${CC}" = "cl" ; then
127 MSVC="yes"
128 CXX="cl"
129 ECOS_MSVC_PATH(MSVC_SRCDIR)
130 AC_SUBST(MSVC_SRCDIR)
131 ecos_INCLUDES="${ecos_INCLUDES} \"-I${msvc_srcdir}\""
132 ecos_LDADD="-link"
133 ecos_LIBS="advapi32.lib"
134 fi
135 AM_CONDITIONAL(MSVC, test "${MSVC}" = "yes")
136 if test "${MSVC}" = "yes" ; then
137 AC_MSG_RESULT([unfortunately yes])
138 else
139 AC_MSG_RESULT([no])
140 fi
141 ])
142
143 dnl ====================================================================
144 dnl Set up sensible flags for the various different compilers. This
145 dnl is achieved by manipulating AM-CFLAGS and AM-CXXFLAGS via a subst,
146 dnl plus undoing the setting of CFLAGS and CXXFLAGS done by
147 dnl the AC_PROC_CC and AC_PROG_CXX macros (e.g. setting the default
148 dnl compilation flags to -O2). Note that this relies
149 dnl on knowing about the internals of those macros.
150 dnl
151 dnl There is little point in checking the cache: this macro does
152 dnl not do any feature tests so checking the cache would probably
153 dnl be more expensive than doing the work here.
154 dnl
155 dnl For now the only supported compilers are gcc/g++ and VC++. Attempts
156 dnl to use another compiler will result in an error at configure-time.
157 AC_DEFUN(ECOS_PROG_STANDARD_COMPILER_FLAGS, [
158 AC_REQUIRE([AC_PROG_CC])
159 AC_REQUIRE([AC_PROG_CXX])
160 AC_REQUIRE([ECOS_PROG_DEFINE_COMPILER_FLAGS])
161 AC_REQUIRE([ECOS_PROG_MSVC])
162
163 AC_MSG_CHECKING("the default compiler flags")
164
165 dnl Add a user-settable flag to control whether or debugging info is
166 dnl incorporated at compile-time.
167 ecosflags_enable_debug="no"
168 AC_ARG_ENABLE(debug,[ --enable-debug do a debug rather than a release build],
169 [case "${enableval}" in
170 yes) ecosflags_enable_debug="yes" ;;
171 *) ecosflags_enable_debug="no" ;;
172 esac])
173
174 dnl For VC++ builds also provide a flag for ANSI vs. unicode builds.
175 dnl For now this does not actually affect the compiler flags.
176 dnl NOTE: there may also have to be a flag to control whether or
177 dnl the VC++ multi-threading flags are enabled.
178 ecosflags_enable_ansi="no"
179 if test "${MSVC}" = "yes" ; then
180 AC_ARG_ENABLE(ansi,[ --enable-ansi do an ANSI rather than a unicode build],
181 [case "${enableval}" in
182 yes) ecosflags_enable_ansi="yes" ;;
183 *) ecosflags_enable_ansi="no" ;;
184 esac])
185 fi
186
187 dnl Now we know what the user is after.
188 if test "${GCC}" = "yes" ; then
189 ecos_CFLAGS="${ecos_CFLAGS} -pipe -Wall -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs"
190 ecos_CXXFLAGS="${ecos_CXXFLAGS} -pipe -Wall -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual"
191 elif test "${MSVC}" = "yes" ; then
192 ecos_CFLAGS="${ecos_CFLAGS} -nologo -W3"
193 ecos_CXXFLAGS="${ecos_CXXFLAGS} -nologo -W3 -GR -GX"
194 else
195 AC_MSG_ERROR("default flags for ${CC} are not known")
196 fi
197
198 dnl Choose between debugging and optimization.
199 if test "${ecosflags_enable_debug}" = "yes" ; then
200 if test "${GCC}" = "yes" ; then
201 ecos_CFLAGS="${ecos_CFLAGS} -g -O0"
202 ecos_CXXFLAGS="${ecos_CXXFLAGS} -g -O0"
203 elif test "${MSVC}" = "yes" ; then
204 ecos_CFLAGS="${ecos_CFLAGS} -MDd -Zi"
205 ecos_CXXFLAGS="${ecos_CXXFLAGS} -MDd -Zi"
206 fi
207 else
208 dnl For now building with g++ implies -O0 rather than -O2. The
209 dnl compile-time performance of g++ at -O2 has been disappointing
210 dnl for quite some time, and the eCos host-side code is not
211 dnl sufficiently cpu-intensive to require -O2.
212 if test "${GCC}" = "yes" ; then
213 ecos_CFLAGS="${ecos_CFLAGS} -O0"
214 ecos_CXXFLAGS="${ecos_CXXFLAGS} -O0"
215 elif test "${MSVC}" = "yes" ; then
216 ecos_CFLAGS="${ecos_CFLAGS} -MD -O2"
217 ecos_CXXFLAGS="${ecos_CXXFLAGS} -MD -O2"
218 fi
219 fi
220
221 CFLAGS="${ac_save_CFLAGS}"
222 CXXFLAGS="${ac_save_CXXFLAGS}"
223
224 AC_MSG_RESULT(done)
225 ])
226
227 dnl --------------------------------------------------------------------
228 dnl User-settable options for assertions and tracing.
229 dnl
230 dnl The settable options are:
231 dnl --disable-asserts
232 dnl --disable-preconditions
233 dnl --disable-postconditions
234 dnl --disable-invariants
235 dnl --disable-loopinvariants
236 dnl --disable-tracing
237 dnl --disable-fntracing
238
239 AC_DEFUN(ECOS_ARG_INFRASTRUCTURE, [
240
241 AC_REQUIRE([ECOS_PROG_STANDARD_COMPILER_FLAGS])
242
243 if test "${ecosflags_enable_debug}" = "yes" ; then
244 ecosinfra_asserts="yes"
245 ecosinfra_preconditions="yes"
246 ecosinfra_postconditions="yes"
247 ecosinfra_invariants="yes"
248 ecosinfra_loopinvariants="yes"
249 ecosinfra_tracing="yes"
250 ecosinfra_fntracing="yes"
251 else
252 ecosinfra_asserts="no"
253 ecosinfra_preconditions="no"
254 ecosinfra_postconditions="no"
255 ecosinfra_invariants="no"
256 ecosinfra_loopinvariants="no"
257 ecosinfra_tracing="no"
258 ecosinfra_fntracing="no"
259 fi
260
261 AC_ARG_ENABLE(asserts,[ --disable-asserts disable all assertions],
262 [case "${enableval}" in
263 yes) ecosinfra_asserts="yes" ;;
264 no) ecosinfra_asserts="no" ;;
265 *) AC_MSG_ERROR([bad value ${enableval} for disable-asserts option]) ;;
266 esac])
267 if test "${ecosinfra_asserts}" = "yes"; then
268 AC_DEFINE(CYGDBG_USE_ASSERTS)
269 fi
270
271 AC_ARG_ENABLE(preconditions, [ --disable-preconditions disable a subset of the assertions],
272 [case "${enableval}" in
273 yes) ecosinfra_preconditions="yes" ;;
274 no) ecosinfra_preconditions="no" ;;
275 *) AC_MSG_ERROR([bad value ${enableval} for disable-preconditions option]) ;;
276 esac])
277 if test "${ecosinfra_preconditions}" = "yes"; then
278 AC_DEFINE(CYGDBG_INFRA_DEBUG_PRECONDITIONS)
279 fi
280
281 AC_ARG_ENABLE(postconditions, [ --disable-postconditions disable a subset of the assertions],
282 [case "${enableval}" in
283 yes) ecosinfra_postconditions="yes" ;;
284 no) ecosinfra_postconditions="no" ;;
285 *) AC_MSG_ERROR([bad value ${enableval} for disable-postconditions option]) ;;
286 esac])
287 if test "${ecosinfra_postconditions}" = "yes"; then
288 AC_DEFINE(CYGDBG_INFRA_DEBUG_POSTCONDITIONS)
289 fi
290
291 AC_ARG_ENABLE(invariants, [ --disable-invariants disable a subset of the assertions],
292 [case "${enableval}" in
293 yes) ecosinfra_invariants="yes" ;;
294 no) ecosinfra_invariants="no" ;;
295 *) AC_MSG_ERROR([bad value ${enableval} for disable-invariants option]) ;;
296 esac])
297 if test "${ecosinfra_invariants}" = "yes"; then
298 AC_DEFINE(CYGDBG_INFRA_DEBUG_INVARIANTS)
299 fi
300
301 AC_ARG_ENABLE(loopinvariants, [ --disable-loopinvariants disable a subset of the assertions],
302 [case "${enableval}" in
303 yes) ecosinfra_loopinvariants="yes" ;;
304 no) ecosinfra_loopinvariants="no" ;;
305 *) AC_MSG_ERROR([bad value ${enableval} for disable-loopinvariants option]) ;;
306 esac])
307 if test "${ecosinfra_loopinvariants}" = "yes"; then
308 AC_DEFINE(CYGDBG_INFRA_DEBUG_LOOP_INVARIANTS)
309 fi
310
311 AC_ARG_ENABLE(tracing,[ --disable-tracing disable tracing],
312 [case "${enableval}" in
313 yes) ecosinfra_tracing="yes" ;;
314 no) ecosinfra_tracing="no" ;;
315 *) AC_MSG_ERROR([bad value ${enableval} for disable-tracing option]) ;;
316 esac])
317 if test "${ecosinfra_tracing}" = "yes"; then
318 AC_DEFINE(CYGDBG_USE_TRACING)
319 fi
320
321 AC_ARG_ENABLE(fntracing,[ --disable-fntracing disable function entry/exit tracing],
322 [case "${enableval}" in
323 yes) ecosinfra_fntracing="yes" ;;
324 no) ecosinfra_fntracing=no ;;
325 *) AC_MSG_ERROR([bad value ${enableval} for disable-fntracing option]) ;;
326 esac])
327 if test "${ecosinfra_fntracing}" = "yes"; then
328 AC_DEFINE(CYGDBG_INFRA_DEBUG_FUNCTION_REPORTS)
329 fi
330 ])
331
332 dnl ====================================================================
333 dnl Inspired by KDE's autoconfig
334 dnl This macro takes three Arguments like this:
335 dnl AC_FIND_FILE(foo.h, $incdirs, incdir)
336 dnl the filename to look for, the list of paths to check and
337 dnl the variable with the result.
338
339 AC_DEFUN(AC_FIND_FILE,[
340 $3=""
341 for i in $2; do
342 if test -r "$i/$1"; then
343 $3=$i
344 break
345 fi
346 done
347 ])
348
349 dnl ====================================================================
350 dnl Variation of the above.
351 dnl This macro takes three Arguments like this:
352 dnl AC_FIND_DIR(infra, $incdirs, incdir)
353 dnl the directory name to look for, the list of paths to check and
354 dnl the variable with the result.
355
356 AC_DEFUN(AC_FIND_DIR,[
357 $3=""
358 for i in $2; do
359 if test -d "$i/$1"; then
360 $3=$i
361 break
362 fi
363 done
364 ])
365
366 dnl ====================================================================
367 dnl Work out details of the Tcl/tk installation that should be used.
368 dnl This adds two main command-line options, --with-tcl=<prefix> to
369 dnl specify the Tcl install directory, and --with-tcl-version=<vsn>
370 dnl to control which version of Tcl should be used. For finer-grained
371 dnl control there are additional options --with-tcl-header and
372 dnl --with-tcl-version. It is assumed that Tcl and Tk are installed
373 dnl in the same place.
374 dnl
375 dnl On Unix systems and under cygwin there should be a file
376 dnl $(tcl_prefix)/lib/tclConfig.sh containing all the information
377 dnl needed for Tcl. This file is consulted and the appropriate
378 dnl variables extracted. Similar information for Tk lives in
379 dnl tkConfig.sh. As a useful side effect all variables defined
380 dnl in those scripts can be accessed.
381 dnl
382 dnl To confuse matters, subtly different naming conventions are used
383 dnl under Unix and NT. Under Unix the Tcl library will be called
384 dnl libtcl8.0.a, libtcl8.1.a, etc. with a dot between the major and
385 dnl minor version. Under NT (including cygwin) the library will be
386 dnl called tcl80.lib, tcl81.lib, libtcl80.a, libtcl81.a, etc.
387 dnl without a dot.
388 dnl
389 dnl Currently this macro assumes that Tcl is preinstalled, and not
390 dnl built alongside eCos. Specifically the macro checks that
391 dnl tcl.h can be found, plus on Unix systems tclConfig.sh and
392 dnl tkConfig.sh as well.
393 dnl
394 dnl This macro updates the build-related variables ecos_INCLUDES,
395 dnl ecos_LDADD, and ecos_LIBS. The latter assumes the application
396 dnl only needs Tcl. If Tk is needed as well then the variable
397 dnl ecos_tklibs should be used in addition.
398
399 AC_DEFUN(ECOS_PATH_TCL, [
400
401 AC_REQUIRE([ECOS_PROG_MSVC])
402 AC_REQUIRE([AC_CYGWIN])
403
404 ecos_tcl_version=""
405 ecos_tcl_incdir=""
406 ecos_tcl_libdir=""
407 ecos_tk_libs=""
408
409 dnl Look for the version of Tcl. If none is specified, default to
410 dnl 8.0 under VC++ and cygwin, nothing under Unix. A version has to be
411 dnl specified under NT because there is no symbolic link from libtcl.a
412 dnl to whatever happens to be the most recent installed version.
413
414 AC_MSG_CHECKING([for Tcl version])
415 AC_ARG_WITH(tcl-version,[ --with-tcl-version=<vsn> version of Tcl to be used],[
416 ecos_tcl_version=${with_tcl_version}
417 ],[
418 if test "${MSVC}" = "yes" ; then
419 ecos_tcl_version=80
420 elif test "${ac_cv_cygwin}" = "yes" ; then
421 ecos_tcl_version=80
422 else
423 ecos_tcl_version=""
424 fi
425 ])
426 AC_MSG_RESULT([${ecos_tcl_version}])
427
428 dnl Where is the Tcl installation?
429 AC_MSG_CHECKING(for Tcl installation)
430
431 AC_ARG_WITH(tcl-header,[ --with-tcl-header=<path> location of Tcl header])
432 AC_ARG_WITH(tcl-lib,[ --with-tcl-lib=<path> location of Tcl libraries])
433 AC_ARG_WITH(tcl,[ --with-tcl=<path> location of Tcl header and libraries])
434
435 dnl If using VC++ then there are no sensible default directories
436 dnl to search for a Tcl installation. Instead the user must
437 dnl supply either --with-tcl, or both --with-tcl-header and
438 dnl --with-tcl-lib.
439 dnl
440 dnl Also when using VC++ there is no tclConfig.sh file to
441 dnl consult about which libraries are needed. Instead that
442 dnl information is hard-wired here.
443
444 if test "${MSVC}" = "yes" ; then
445
446 if test "${with_tcl_header+set}" = set ; then
447 ecos_tcl_incdir=${with_tcl_header}
448 elif test "${with_tcl+set}" = set ; then
449 ecos_tcl_incdir="${with_tcl}/include"
450 else
451 AC_MSG_ERROR(You must specify a Tcl installation with either --with-tcl=<path> or --with-tcl-header=<path>)
452 fi
453
454 dnl Sanity check, make sure that there is a tcl.h header file.
455 dnl If not then there is no point in proceeding.
456 if test \! -r "${ecos_tcl_incdir}/tcl.h" ; then
457 AC_MSG_ERROR([unable to locate Tcl header file tcl.h])
458 fi
459 ecos_msvc_tcl_incdir="${ecos_tcl_incdir}"
460 ECOS_MSVC_PATH(ecos_msvc_tcl_incdir)
461 ecos_INCLUDES="${ecos_INCLUDES} \"-I${ecos_msvc_tcl_incdir}\""
462
463 if test "${with_tcl_lib+set}" = set; then
464 ecos_tcl_libdir=${with_tcl_lib}
465 elif test "${with_tcl+set}" = set; then
466 ecos_tcl_libdir="${with_tcl}/lib"
467 else
468 AC_MSG_ERROR(You must specify a Tcl installation with either --with-tcl=<path> or --with-tcl-lib=<path>)
469 fi
470 ECOS_MSVC_PATH(ecos_tcl_libdir)
471 ecos_LIBS="${ecos_LIBS} tcl${ecos_tcl_version}.lib"
472 ecos_LDADD="${ecos_LDADD} \"-libpath=${ecos_tcl_libdir}\""
473
474 dnl FIXME: what libraries are needed for a tk application under VC++?
475 dnl and can the version be determined more accurately?
476 ecos_tk_libs=""
477
478 else
479 dnl Depending on the installation there are a number of reasonable locations for tcl.h
480 dnl so this code performs a search.
481 possibles="${with_tcl_header} ${with_tcl}/include ${prefix}/include /usr/include/tcl${ecos_tcl_version} /usr/include"
482 AC_FIND_FILE("tcl.h", ${possibles}, ecos_tcl_incdir)
483 if test \! -r "${ecos_tcl_incdir}/tcl.h" ; then
484 AC_MSG_ERROR(unable to locate Tcl header file tcl.h)
485 else
486 dnl On Unix systems -I/usr/include is unnecessary, and can cause problems on hosts
487 dnl where gcc is not the platform's default compiler because of the use of
488 dnl unfixed headers. Hence it is explicitly removed here. Similarly
489 dnl -I/usr/lib serves no purpose, although it should be harmless.
490 dnl Under cygwin this check may be wrong, should the mount table
491 dnl be set up such that /usr/include points at the main cygwin
492 dnl headers. That assumes that gcc under cygwin does not have
493 dnl /usr/include in its default path, an untested assumption.
494 if test "${ecos_tcl_incdir}" != "/usr/include" ; then
495 ecos_INCLUDES="${ecos_INCLUDES} -I${ecos_tcl_incdir}"
496 fi
497 fi
498 possibles="${with_tcl_lib} ${with_tcl}/lib ${libdir} ${prefix}/lib /usr/lib/tcl$${ecos_tcl_version} /usr/lib"
499 AC_FIND_FILE("tclConfig.sh", ${possibles}, ecos_tcl_libdir)
500 if test \! -r "${ecos_tcl_libdir}/tclConfig.sh" ; then
501 AC_MSG_ERROR(unable to locate Tcl config file tclConfig.sh)
502 else
503 . ${ecos_tcl_libdir}/tclConfig.sh
504 ecos_LIBS="${ecos_LIBS} -ltcl${ecos_tcl_version} ${TCL_LIBS}"
505 fi
506
507 if test \! -r "${ecos_tcl_libdir}/tkConfig.sh" ; then
508 AC_MSG_ERROR(unable to locate Tk config file tkConfig.sh)
509 else
510 . ${ecos_tcl_libdir}/tkConfig.sh
511 ecos_tk_libs="-ltk${ecos_tcl_version} ${TK_LIBS}"
512 dnl Remove any library duplicates. It is not quite clear why,
513 dnl but they seem to cause problems.
514 for lib in ${TCL_LIBS} ; do
515 ecos_tk_libs=`echo ${ecos_tk_libs} | sed -e "s!${lib}!!"`
516 done
517 fi
518 fi
519
520 AC_MSG_RESULT([-I${ecos_tcl_incdir} -L${ecos_tcl_libdir}])
521
522 AC_SUBST(ecos_tk_libs)
523 ])
524
525 dnl ====================================================================
526 dnl Search for the infrastructure headers. Usually these can be picked
527 dnl up from host/infra in the build tree. This macro updates
528 dnl ecos_INCLUDES, ecos_LDADD and ecos_LIBS appropriately. In addition
529 dnl it defines new variables ecos_infra_incdir and ecos_infra_libdir,
530 dnl useful for listing explicit dependencies.
531 dnl
532 dnl This macro should only be used in configure scripts that run after
533 dnl the infrastructure has been configured because it relies on the
534 dnl infra directory already having been created in the build tree.
535
536 AC_DEFUN(ECOS_PATH_INFRA, [
537 AC_MSG_CHECKING([for eCos host-side infrastructure])
538
539 dnl Where are we in the build tree? First assume that we are in the host
540 dnl tree, thus allowing configury of just the host-side. If that fails
541 dnl assume we can be anywhere.
542 infra_builddir=""
543 possibles=".. ../.. ../../.. ../../../.. ../../../../.."
544 AC_FIND_DIR("infra", ${possibles}, infra_builddir)
545 if test "${infra_builddir}" = "" ; then
546 possibles="../host ../../host ../../../host ../../../../host ../../../../../host ../../../../../../host"
547 AC_FIND_DIR("infra", ${possibles}, infra_builddir)
548 fi
549 if test "${infra_builddir}" != "" ; then
550 infra_builddir="${infra_builddir}/infra"
551 infra_builddir=`cd ${infra_builddir} && /bin/pwd`
552 fi
553
554 ecos_infra_incdir=""
555 ecos_infra_libdir=""
556 ecos_infra_libs=""
557
558 AC_ARG_WITH(infra-header,[ --with-infra-header=<path> location of eCos infrastructure headers])
559 AC_ARG_WITH(infra-lib,[ --with-infra-lib=<path> location of eCos infrastructure library])
560 AC_ARG_WITH(infra,[ --with-infra=<path> location of eCos infrastructure installation])
561
562 if test "${with_infra_header+set}" = "set"; then
563 ecos_infra_incdir="${with_infra_header}"
564 elif test "${with_infra+set}" = "set"; then
565 ecos_infra_incdir="${with_infra}/include"
566 elif test "${infra_builddir}" != "" ; then
567 ecos_infra_incdir="${infra_builddir}"
568 else
569 AC_MSG_ERROR([infrastructure headers not found])
570 fi
571 if test "${MSVC}" = "yes" ; then
572 ecos_msvc_infra_incdir = ${ecos_infra_incdir}
573 ECOS_MSVC_PATH(ecos_msvc_infra_incdir)
574 ecos_INCLUDES="${ecos_INCLUDES} \"-I${ecos_msvc_infra_incdir}\""
575 else
576 ecos_INCLUDES="${ecos_INCLUDES} -I${ecos_infra_incdir}"
577 fi
578
579 if test "${with_infra_lib+set}" = "set"; then
580 ecos_infra_libdir="${with_infra_lib}"
581 elif test "${with_infra+set}" = "set"; then
582 ecos_infra_libdir="${with_infra}/lib"
583 elif test "${infra_builddir}" != "" ; then
584 ecos_infra_libdir="${infra_builddir}"
585 else
586 AC_MSG_ERROR([infrastructure library not found])
587 fi
588 if test "${MSVC}" = "yes" ; then
589 ecos_msvc_infra_libdir=${ecos_infra_libdir}
590 ECOS_MSVC_PATH(ecos_msvc_infra_libdir)
591 ecos_LIBS="${ecos_LIBS} cyginfra.lib"
592 ecos_LDADD="${ecos_LDADD} \"-libpath=${ecos_msvc_infra_libdir}\""
593 else
594 ecos_LIBS="${ecos_LIBS} -lcyginfra"
595 ecos_LDADD="${ecos_LDADD} -L${ecos_infra_libdir}"
596 fi
597
598 AC_SUBST(ecos_infra_incdir)
599 AC_SUBST(ecos_infra_libdir)
600 AC_MSG_RESULT(-I[${ecos_infra_incdir} -L${ecos_infra_libdir}])
601 ])
602
603 dnl ====================================================================
604 dnl And a very similar macro for libcdl, but note that the headers
605 dnl are in the source tree rather than the build tree.
606
607 AC_DEFUN(ECOS_PATH_LIBCDL, [
608 AC_MSG_CHECKING([for libcdl])
609
610 dnl Where are we in the source tree?
611 libcdl_srcdir=""
612 possibles="${srcdir}/.. ${srcdir}/../.. ${srcdir}/../../.. ${srcdir}/../../../.. ${srcdir}/../../../../.."
613 AC_FIND_DIR("libcdl", ${possibles}, libcdl_srcdir)
614 if test "${libcdl_srcdir}" = "" ; then
615 possibles="${srcdir}/../host ${srcdir}/../../host ${srcdir}/../../../host ${srcdir}/../../../../host ${srcdir}/../../../../../host ${srcdir}/../../../../../../host"
616 AC_FIND_DIR("libcdl", ${possibles}, libcdl_srcdir)
617 fi
618 if test "${libcdl_srcdir}" != "" ; then
619 libcdl_srcdir="${libcdl_srcdir}/libcdl"
620 libcdl_srcdir=`cd ${libcdl_srcdir} && /bin/pwd`
621 fi
622
623 dnl And where are we in the build tree?
624 libcdl_builddir=""
625 possibles=".. ../.. ../../.. ../../../.. ../../../../.."
626 AC_FIND_DIR("libcdl", ${possibles}, libcdl_builddir)
627 if test "${libcdl_builddir}" = "" ; then
628 possibles="../host ../../host ../../../host ../../../../host ../../../../../host ../../../../../../host"
629 AC_FIND_DIR("libcdl", ${possibles}, libcdl_builddir)
630 fi
631 if test "${libcdl_builddir}" != "" ; then
632 libcdl_builddir="${libcdl_builddir}/libcdl"
633 libcdl_builddir=`cd ${libcdl_builddir} && /bin/pwd`
634 fi
635
636 ecos_libcdl_incdir=""
637 ecos_libcdl_libdir=""
638 ecos_libcdl_libs=""
639
640 AC_ARG_WITH(libcdl-header,[ --with-libcdl-header=<path> location of eCos libcdl headers])
641 AC_ARG_WITH(libcdl-lib,[ --with-libcdl-lib=<path> location of eCos libcdl library])
642 AC_ARG_WITH(libcdl,[ --with-libcdl=<path> location of eCos libcdl installation])
643
644 if test "${with_libcdl_header+set}" = "set"; then
645 ecos_libcdl_incdir="${with_libcdl_header}"
646 elif test "${with_libcdl+set}" = "set"; then
647 ecos_libcdl_incdir="${with_libcdl}/include"
648 elif test "${libcdl_srcdir}" != "" ; then
649 ecos_libcdl_incdir="${libcdl_srcdir}"
650 fi
651 if test \! -r "${ecos_libcdl_incdir}/cdl.hxx" ; then
652 AC_MSG_ERROR([libcdl headers not found])
653 fi
654 if test "${MSVC}" = "yes" ; then
655 ecos_msvc_libcdl_incdir = "${ecos_libcdl_incdir}"
656 ECOS_MSVC_PATH(ecos_msvc_libcdl_incdir)
657 ecos_INCLUDES="${ecos_INCLUDES} \"-I${ecos_msvc_libcdl_incdir}\""
658 else
659 ecos_INCLUDES="${ecos_INCLUDES} -I${ecos_libcdl_incdir}"
660 fi
661
662 if test "${with_libcdl_lib+set}" = "set"; then
663 ecos_libcdl_libdir="${with_libcdl_lib}"
664 elif test "${with_libcdl+set}" = "set"; then
665 ecos_libcdl_libdir="${with_libcdl}/lib"
666 elif test "${libcdl_builddir}" != "" ; then
667 ecos_libcdl_libdir="${libcdl_builddir}"
668 else
669 AC_MSG_ERROR([libcdl library not found])
670 fi
671 if test "${MSVC}" = "yes" ; then
672 ecos_msvc_libcdl_libdir=${ecos_libcdl_libdir}
673 ECOS_MSVC_PATH(ecos_msvc_libcdl_libdir)
674 ecos_LIBS="${ecos_LIBS} cdl.lib"
675 ecos_LDADD="${ecos_LDADD} \"-libpath=${ecos_msvc_libcdl_libdir}\""
676 else
677 ecos_LIBS="${ecos_LIBS} -lcdl"
678 ecos_LDADD="${ecos_LDADD} -L${ecos_libcdl_libdir}"
679 fi
680
681 AC_SUBST(ecos_libcdl_incdir)
682 AC_SUBST(ecos_libcdl_libdir)
683 AC_MSG_RESULT([-I${ecos_libcdl_incdir} -L${ecos_libcdl_libdir}])
684 ])
685
686 dnl ====================================================================
687 dnl Look for a 64 bit data type. It is necessary to check both C and C++
688 dnl compilers.
689 dnl
690 dnl A better implementation would check whether or not AC_PROG_CC and
691 dnl AC_PROG_CXX have been invoked and only test the appropriate
692 dnl compiler.
693 dnl
694 dnl When cross-compiling, default to long long on the assumption that
695 dnl gcc/g++ must be used and long long is likely to be the 64 bit data
696 dnl type. This is not guaranteed, but sufficiently likely to meet
697 dnl the requirements for the time being. The CHECK_SIZEOF() macro
698 dnl might be another way to get the desired information.
699
700 AC_DEFUN(ECOS_TYPE_64bit, [
701 AC_REQUIRE([AC_PROG_CC])
702 AC_REQUIRE([AC_PROG_CXX])
703
704 AC_CACHE_CHECK("for a 64 bit data type",ecos_cv_type_64bit,[
705 for type in "long" "long long" "__int64"; do
706 AC_LANG_SAVE
707 AC_LANG_C
708 AC_TRY_RUN([
709 main() {
710 return 8 != sizeof($type);
711 }
712 ],ctype_64bit=$type,ctype_64bit="unknown",ctype_64bit="long long")
713 AC_LANG_CPLUSPLUS
714 AC_TRY_RUN([
715 int main(int argc, char ** argv) {
716 return 8 != sizeof($type);
717 }
718 ],cxxtype_64bit=$type,cxxtype_64bit="unknown",cxxtype_64bit="long long")
719 AC_LANG_RESTORE
720 if test "${ctype_64bit}" = "${type}" -a "${cxxtype_64bit}" = "${type}"; then
721 ecos_cv_type_64bit="${type}"
722 break
723 fi
724 done
725 ])
726 if test "${ecos_cv_type_64bit}" = ""; then
727 AC_MSG_ERROR(Unable to figure out how to do 64 bit arithmetic)
728 else
729 if test "${ecos_cv_type_64bit}" != "long long"; then
730 AC_DEFINE_UNQUOTED(cyg_halint64,${ecos_cv_type_64bit})
731 AC_DEFINE_UNQUOTED(cyg_halcount64,${ecos_cv_type_64bit})
732 fi
733 fi
734 ])
735
736 dnl ====================================================================
737 dnl Check that both the C and C++ compilers support __PRETTY_FUNCTION__
738
739 AC_DEFUN(ECOS_C_PRETTY_FUNCTION,[
740 AC_REQUIRE([AC_PROG_CC])
741 AC_REQUIRE([AC_PROG_CXX])
742
743 AC_CACHE_CHECK("for __PRETTY_FUNCTION__ support",ecos_cv_c_pretty_function,[
744 AC_LANG_SAVE
745 AC_LANG_C
746 AC_TRY_LINK(
747 [#include <stdio.h>],
748 [puts(__PRETTY_FUNCTION__);],
749 c_ok="yes",
750 c_ok="no"
751 )
752 AC_LANG_CPLUSPLUS
753 AC_TRY_LINK(
754 [#include <cstdio>],
755 [puts(__PRETTY_FUNCTION__);],
756 cxx_ok="yes",
757 cxx_ok="no"
758 )
759 AC_LANG_RESTORE
760 if test "${c_ok}" = "yes" -a "${cxx_ok}" = "yes"; then
761 ecos_cv_c_pretty_function="yes"
762 fi
763 ])
764 if test "${ecos_cv_c_pretty_function}" = "yes"; then
765 AC_DEFINE(CYGDBG_INFRA_DEBUG_FUNCTION_PSEUDOMACRO)
766 fi
767 ])
768
769 dnl ====================================================================
770 dnl During installation eCos package-specific host-side code should be
771 dnl versioned in the same way as the packages themselves, allowing
772 dnl different versions to coexist in one installation. This is analogous
773 dnl to having multiple versions of a shared library installed so that
774 dnl applications can load whichever one they were linked with.
775 dnl
776 dnl To support all this the host-side code needs access to a number
777 dnl of directory names:
778 dnl ECOS_REPOSITORY e.g. ~/ecc/ecc
779 dnl PACKAGE_DIR e.g. hal/synth/arch
780 dnl PACKAGE_VERSION e.g. current
781 dnl PACKAGE_INSTALL e.g. hal/synth/arch/current
782 dnl
783 dnl These, together with the standard variable libexecdir, allow
784 dnl the host-side code to navigate around both source and install
785 dnl trees.
786
787 AC_DEFUN(ECOS_PACKAGE_DIRS,[
788
789 dnl srcdir will be something like <path>/packages/<package_path>/<version>/host
790 package_dir=`cd ${srcdir} && /bin/pwd`
791 PACKAGE_VERSION=`dirname ${package_dir}`
792 PACKAGE_VERSION=`basename ${PACKAGE_VERSION}`
793
794 dnl Now look for an "acsupport" directory as a good way of identifying
795 dnl the root of the repository. Assume that this does not clash with
796 dnl any real packages in the repository. Also assume that no silly games
797 dnl are being played with symlinks.
798 package_dir=`dirname ${package_dir}`
799 package_dir=`dirname ${package_dir}`
800
801 possibles="${package_dir}/.. ${package_dir}/../.. ${package_dir}/../../.. ${package_dir}/../../../.. ${package_dir}/../../../../../.."
802 AC_FIND_DIR("acsupport", ${possibles}, repository_root)
803 if test "${repository_root}" = "" ; then
804 AC_MSG_ERROR([Failed to identify this package's position within the eCos repository])
805 fi
806 dnl repository_root will still contain the ..'s, instead of an absolute path
807 ECOS_REPOSITORY=`cd "${repository_root}/packages/pkgconf/.." && /bin/pwd`
808
809 dnl Now we have two absolute paths, so just remove one from the other
810 PACKAGE_DIR=`echo ${package_dir} | sed -e "s:${ECOS_REPOSITORY}/::"`
811
812 dnl To avoid creating too many subdirectories on the host-side, turn
813 dnl e.g. hal/synth/arch into hal_synth_arch. Theoretically this could
814 dnl go wrong because multiple packages could map onto the same string,
815 dnl but in practice there should be a net reduction in complexity.
816 dnl bartv: / to _ conversion disabled for now, 5 March 2002
817 PACKAGE_INSTALL="${PACKAGE_DIR}/${PACKAGE_VERSION}"
818 dnl PACKAGE_INSTALL=`echo ${PACKAGE_INSTALL} | sed -e "s:/:_:g"`
819
820 AC_SUBST(ECOS_REPOSITORY)
821 AC_SUBST(PACKAGE_DIR)
822 AC_SUBST(PACKAGE_VERSION)
823 AC_SUBST(PACKAGE_INSTALL)
824 ])