OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [acsupport/] [acinclude.m4] - Blame information for rev 620

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 unneback
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, 2003 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
       MSVC_SRCDIR=${srcdir}
130
       ECOS_MSVC_PATH(MSVC_SRCDIR)
131
       AC_SUBST(MSVC_SRCDIR)
132
       ecos_INCLUDES="${ecos_INCLUDES} \"-I${MSVC_SRCDIR}\""
133
       ecos_LDADD="-link"
134
       ecos_LIBS="advapi32.lib"
135
    fi
136
    AM_CONDITIONAL(MSVC, test "${MSVC}" = "yes")
137
    if test "${MSVC}" = "yes" ; then
138
        AC_MSG_RESULT([unfortunately yes])
139
    else
140
        AC_MSG_RESULT([no])
141
    fi
142
])
143
 
144
dnl ====================================================================
145
dnl Set up sensible flags for the various different compilers. This
146
dnl is achieved by manipulating AM-CFLAGS and AM-CXXFLAGS via a subst,
147
dnl plus undoing the setting of CFLAGS and CXXFLAGS done by
148
dnl the AC_PROC_CC and AC_PROG_CXX macros (e.g. setting the default
149
dnl compilation flags to -O2). Note that this relies
150
dnl on knowing about the internals of those macros.
151
dnl
152
dnl There is little point in checking the cache: this macro does
153
dnl not do any feature tests so checking the cache would probably
154
dnl be more expensive than doing the work here.
155
dnl
156
dnl For now the only supported compilers are gcc/g++ and VC++. Attempts
157
dnl to use another compiler will result in an error at configure-time.
158
AC_DEFUN(ECOS_PROG_STANDARD_COMPILER_FLAGS, [
159
    AC_REQUIRE([AC_PROG_CC])
160
    AC_REQUIRE([AC_PROG_CXX])
161
    AC_REQUIRE([ECOS_PROG_DEFINE_COMPILER_FLAGS])
162
    AC_REQUIRE([ECOS_PROG_MSVC])
163
 
164
    AC_MSG_CHECKING("the default compiler flags")
165
 
166
    dnl Add a user-settable flag to control whether or debugging info is
167
    dnl incorporated at compile-time.
168
    ecosflags_enable_debug="no"
169
    AC_ARG_ENABLE(debug,[ --enable-debug           do a debug rather than a release build],
170
    [case "${enableval}" in
171
       yes) ecosflags_enable_debug="yes" ;;
172
       *)   ecosflags_enable_debug="no" ;;
173
    esac])
174
 
175
    dnl For VC++ builds also provide a flag for ANSI vs. unicode builds.
176
    dnl For now this does not actually affect the compiler flags.
177
    dnl NOTE: there may also have to be a flag to control whether or
178
    dnl the VC++ multi-threading flags are enabled.
179
    ecosflags_enable_ansi="no"
180
    if test "${MSVC}" = "yes" ; then
181
      AC_ARG_ENABLE(ansi,[ --enable-ansi            do an ANSI rather than a unicode build],
182
      [case "${enableval}" in
183
         yes) ecosflags_enable_ansi="yes" ;;
184
         *)   ecosflags_enable_ansi="no" ;;
185
      esac])
186
    fi
187
 
188
    dnl Now we know what the user is after.
189
    if test "${GCC}" = "yes" ; then
190
        ecos_CFLAGS="${ecos_CFLAGS} -pipe -Wall -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs"
191
        ecos_CXXFLAGS="${ecos_CXXFLAGS} -pipe -Wall -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual"
192
    elif test "${MSVC}" = "yes" ; then
193
        ecos_CFLAGS="${ecos_CFLAGS} -nologo -W3"
194
        ecos_CXXFLAGS="${ecos_CXXFLAGS} -nologo -W3 -GR -GX"
195
    else
196
        AC_MSG_ERROR("default flags for ${CC} are not known")
197
    fi
198
 
199
    dnl Choose between debugging and optimization.
200
    if test "${ecosflags_enable_debug}" = "yes" ; then
201
        if test "${GCC}" = "yes" ; then
202
            ecos_CFLAGS="${ecos_CFLAGS} -g -O0"
203
            ecos_CXXFLAGS="${ecos_CXXFLAGS} -g -O0"
204
        elif test "${MSVC}" = "yes" ; then
205
            ecos_CFLAGS="${ecos_CFLAGS} -MDd -Zi"
206
            ecos_CXXFLAGS="${ecos_CXXFLAGS} -MDd -Zi"
207
        fi
208
    else
209
        dnl For now building with g++ implies -O0 rather than -O2. The
210
        dnl compile-time performance of g++ at -O2 has been disappointing
211
        dnl for quite some time, and the eCos host-side code is not
212
        dnl sufficiently cpu-intensive to require -O2.
213
        if test "${GCC}" = "yes" ; then
214
            ecos_CFLAGS="${ecos_CFLAGS} -O0"
215
            ecos_CXXFLAGS="${ecos_CXXFLAGS} -O0"
216
        elif test "${MSVC}" = "yes" ; then
217
            ecos_CFLAGS="${ecos_CFLAGS} -MD -O2"
218
            ecos_CXXFLAGS="${ecos_CXXFLAGS} -MD -O2"
219
        fi
220
    fi
221
 
222
    CFLAGS="${ac_save_CFLAGS}"
223
    CXXFLAGS="${ac_save_CXXFLAGS}"
224
 
225
    AC_MSG_RESULT(done)
226
])
227
 
228
dnl --------------------------------------------------------------------
229
dnl User-settable options for assertions and tracing.
230
dnl
231
dnl The settable options are:
232
dnl   --disable-asserts
233
dnl   --disable-preconditions
234
dnl   --disable-postconditions
235
dnl   --disable-invariants
236
dnl   --disable-loopinvariants
237
dnl   --disable-tracing
238
dnl   --disable-fntracing
239
 
240
AC_DEFUN(ECOS_ARG_INFRASTRUCTURE, [
241
 
242
    AC_REQUIRE([ECOS_PROG_STANDARD_COMPILER_FLAGS])
243
 
244
    if test "${ecosflags_enable_debug}" = "yes" ; then
245
        ecosinfra_asserts="yes"
246
        ecosinfra_preconditions="yes"
247
        ecosinfra_postconditions="yes"
248
        ecosinfra_invariants="yes"
249
        ecosinfra_loopinvariants="yes"
250
        ecosinfra_tracing="yes"
251
        ecosinfra_fntracing="yes"
252
    else
253
        ecosinfra_asserts="no"
254
        ecosinfra_preconditions="no"
255
        ecosinfra_postconditions="no"
256
        ecosinfra_invariants="no"
257
        ecosinfra_loopinvariants="no"
258
        ecosinfra_tracing="no"
259
        ecosinfra_fntracing="no"
260
    fi
261
 
262
    AC_ARG_ENABLE(asserts,[ --disable-asserts        disable all assertions],
263
        [case "${enableval}" in
264
            yes) ecosinfra_asserts="yes" ;;
265
            no)  ecosinfra_asserts="no"  ;;
266
            *)   AC_MSG_ERROR([bad value ${enableval} for disable-asserts option]) ;;
267
        esac])
268
    if test "${ecosinfra_asserts}" = "yes"; then
269
        AC_DEFINE(CYGDBG_USE_ASSERTS)
270
    fi
271
 
272
    AC_ARG_ENABLE(preconditions, [ --disable-preconditions  disable a subset of the assertions],
273
        [case "${enableval}" in
274
            yes) ecosinfra_preconditions="yes" ;;
275
            no)  ecosinfra_preconditions="no"  ;;
276
            *)   AC_MSG_ERROR([bad value ${enableval} for disable-preconditions option]) ;;
277
        esac])
278
    if test "${ecosinfra_preconditions}" = "yes"; then
279
        AC_DEFINE(CYGDBG_INFRA_DEBUG_PRECONDITIONS)
280
    fi
281
 
282
    AC_ARG_ENABLE(postconditions, [ --disable-postconditions disable a subset of the assertions],
283
        [case "${enableval}" in
284
            yes) ecosinfra_postconditions="yes" ;;
285
            no)  ecosinfra_postconditions="no"  ;;
286
            *)   AC_MSG_ERROR([bad value ${enableval} for disable-postconditions option]) ;;
287
        esac])
288
    if test "${ecosinfra_postconditions}" = "yes"; then
289
        AC_DEFINE(CYGDBG_INFRA_DEBUG_POSTCONDITIONS)
290
    fi
291
 
292
    AC_ARG_ENABLE(invariants, [ --disable-invariants     disable a subset of the assertions],
293
        [case "${enableval}" in
294
            yes) ecosinfra_invariants="yes" ;;
295
            no)  ecosinfra_invariants="no"  ;;
296
            *)   AC_MSG_ERROR([bad value ${enableval} for disable-invariants option]) ;;
297
        esac])
298
    if test "${ecosinfra_invariants}" = "yes"; then
299
        AC_DEFINE(CYGDBG_INFRA_DEBUG_INVARIANTS)
300
    fi
301
 
302
    AC_ARG_ENABLE(loopinvariants, [ --disable-loopinvariants disable a subset of the assertions],
303
        [case "${enableval}" in
304
            yes) ecosinfra_loopinvariants="yes" ;;
305
            no)  ecosinfra_loopinvariants="no"  ;;
306
            *)   AC_MSG_ERROR([bad value ${enableval} for disable-loopinvariants option]) ;;
307
        esac])
308
    if test "${ecosinfra_loopinvariants}" = "yes"; then
309
        AC_DEFINE(CYGDBG_INFRA_DEBUG_LOOP_INVARIANTS)
310
    fi
311
 
312
    AC_ARG_ENABLE(tracing,[ --disable-tracing        disable tracing],
313
        [case "${enableval}" in
314
            yes) ecosinfra_tracing="yes" ;;
315
            no)  ecosinfra_tracing="no"  ;;
316
            *)   AC_MSG_ERROR([bad value ${enableval} for disable-tracing option]) ;;
317
        esac])
318
    if test "${ecosinfra_tracing}" = "yes"; then
319
        AC_DEFINE(CYGDBG_USE_TRACING)
320
    fi
321
 
322
    AC_ARG_ENABLE(fntracing,[ --disable-fntracing      disable function entry/exit tracing],
323
        [case "${enableval}" in
324
            yes) ecosinfra_fntracing="yes" ;;
325
            no)  ecosinfra_fntracing=no  ;;
326
            *)   AC_MSG_ERROR([bad value ${enableval} for disable-fntracing option]) ;;
327
    esac])
328
    if test "${ecosinfra_fntracing}" = "yes"; then
329
        AC_DEFINE(CYGDBG_INFRA_DEBUG_FUNCTION_REPORTS)
330
    fi
331
])
332
 
333
dnl ====================================================================
334
dnl Inspired by KDE's autoconfig
335
dnl This macro takes three Arguments like this:
336
dnl AC_FIND_FILE(foo.h, $incdirs, incdir)
337
dnl the filename to look for, the list of paths to check and
338
dnl the variable with the result.
339
 
340
AC_DEFUN(AC_FIND_FILE,[
341
    $3=""
342
    for i in $2; do
343
        if test -r "$i/$1"; then
344
            $3=$i
345
            break
346
        fi
347
    done
348
])
349
 
350
dnl ====================================================================
351
dnl Variation of the above.
352
dnl This macro takes three Arguments like this:
353
dnl AC_FIND_DIR(infra, $incdirs, incdir)
354
dnl the directory name to look for, the list of paths to check and
355
dnl the variable with the result.
356
 
357
AC_DEFUN(AC_FIND_DIR,[
358
    $3=""
359
    for i in $2; do
360
        if test -d "$i/$1"; then
361
            $3=$i
362
            break
363
        fi
364
    done
365
])
366
 
367
dnl ====================================================================
368
dnl Work out details of the Tcl/tk installation that should be used.
369
dnl In theory this is simple: when Tcl is installed in <tcl_prefix>
370
dnl (usually /usr) there should be a file <tcl_prefix>/lib/tclConfig.sh
371
dnl which defines exactly how to build Tcl-based applications. Of course
372
dnl Tcl may be installed anywhere, not just in /usr, so it is necessary
373
dnl to do some searching. There is a command-line argument
374
dnl --with-tcl=<path> to specify the Tcl installation, so the macro
375
dnl can search for <with_tcl>/lib/tclConfig.sh, <prefix>/lib/tclConfig.sh
376
dnl and /usr/lib/tclConfig.sh
377
dnl
378
dnl Unfortunately not all systems use this convention. For example,
379
dnl at the time of writing Debian installs tclConfig.sh in a versioned
380
dnl subdirectory /usr/lib/tcl8.3/tclConfig.sh. Hence there is an
381
dnl additional argument --with-tcl-version=<vsn> which is used to
382
dnl extend the search path.
383
dnl
384
dnl For VC++ builds the situation is different again. Tcl may be
385
dnl installed anywhere, so the data in tclConfig.sh is not useful
386
dnl (and that file may not be provided at all). Instead --with-tcl
387
dnl must be used to specify the path. Alternatively separate paths
388
dnl for headers and libraries can be specified using --with-tcl-header
389
dnl and --with-tcl-lib. Usually it will also be necessary to specify
390
dnl the library version number using --with-tcl-version.
391
 
392
dnl This adds two main command-line options, --with-tcl=<prefix> to
393
dnl specify the Tcl install directory, and --with-tcl-version=<vsn>
394
dnl to control which version of Tcl should be used. For finer-grained
395
dnl control there are additional options --with-tcl-header and
396
dnl --with-tcl-version. It is assumed that Tcl and Tk are installed
397
dnl in the same place.
398
dnl
399
dnl On Unix systems and under cygwin there should be a file
400
dnl $(tcl_prefix)/lib/tclConfig.sh containing all the information
401
dnl needed for Tcl. This file is consulted and the appropriate
402
dnl variables extracted. Similar information for Tk lives in
403
dnl tkConfig.sh. As a useful side effect all variables defined
404
dnl in those scripts can be accessed.
405
dnl
406
dnl To confuse matters, subtly different naming conventions are used
407
dnl under Unix and NT. Under Unix the Tcl library will be called
408
dnl libtcl8.0.a, libtcl8.1.a, etc. with a dot between the major and
409
dnl minor version. Under NT (including cygwin) the library will be
410
dnl called tcl80.lib, tcl81.lib, libtcl80.a, libtcl81.a, etc.
411
dnl without a dot.
412
dnl
413
dnl Currently this macro assumes that Tcl is preinstalled, and not
414
dnl built alongside eCos. Specifically the macro checks that
415
dnl tcl.h  can be found, plus on Unix systems tclConfig.sh and
416
dnl tkConfig.sh as well.
417
dnl
418
dnl This macro updates the build-related variables ecos_INCLUDES,
419
dnl ecos_LDADD, and ecos_LIBS. The latter assumes the application
420
dnl only needs Tcl. If Tk is needed as well then the variable
421
dnl ecos_tklibs should be used in addition.
422
 
423
AC_DEFUN(ECOS_PATH_TCL, [
424
 
425
    AC_REQUIRE([ECOS_PROG_MSVC])
426
    AC_REQUIRE([AC_CYGWIN])
427
 
428
    ecos_tk_libs=""
429
    ecos_tk_libdir=""
430
 
431
    dnl Where is the Tcl installation, and what version should be used?
432
    AC_MSG_CHECKING(for Tcl installation)
433
    AC_ARG_WITH(tcl,[ --with-tcl=<path>        location of Tcl header and libraries])
434
    AC_ARG_WITH(tcl-version,[ --with-tcl-version=<vsn> version of Tcl to be used])
435
 
436
    dnl If using VC++ then there are no sensible default directories
437
    dnl to search for a Tcl installation. Instead the user must
438
    dnl supply either --with-tcl, or both --with-tcl-header and
439
    dnl --with-tcl-lib.
440
    dnl
441
    dnl Also when using VC++ there is no tclConfig.sh file to
442
    dnl consult about which libraries are needed. Instead that
443
    dnl information is hard-wired here.
444
    if test "${MSVC}" = "yes" ; then
445
        AC_ARG_WITH(tcl-header,[ --with-tcl-header=<path> location of Tcl header])
446
        AC_ARG_WITH(tcl-lib,[ --with-tcl-lib=<path>    location of Tcl libraries])
447
        ecos_tcl_incdir=""
448
        ecos_tcl_libdir=""
449
        if test "${with_tcl_version+set}" != set ; then
450
            AC_MSG_ERROR(You must specify a Tcl version using --with-tcl-version=<vsn>)
451
        fi
452
        if test "${with_tcl_header+set}" = set ; then
453
            ecos_tcl_incdir=${with_tcl_header}
454
        elif test "${with_tcl+set}" = set ; then
455
            ecos_tcl_incdir="${with_tcl}/include"
456
        else
457
            AC_MSG_ERROR(You must specify a Tcl installation with either --with-tcl=<path> or --with-tcl-header=<path>)
458
        fi
459
        if test "${with_tcl_lib+set}" = set; then
460
            ecos_tcl_libdir=${with_tcl_lib}
461
        elif test "${with_tcl+set}" = set; then
462
            ecos_tcl_libdir="${with_tcl}/lib"
463
        else
464
            AC_MSG_ERROR(You must specify a Tcl installation with either --with-tcl=<path> or --with-tcl-lib=<path>)
465
        fi
466
 
467
        dnl Sanity check, make sure that there is a tcl.h header file.
468
        dnl If not then there is no point in proceeding.
469
        if test \! -r "${ecos_tcl_incdir}/tcl.h" ; then
470
            AC_MSG_ERROR([unable to locate Tcl header file tcl.h])
471
        fi
472
 
473
        ECOS_MSVC_PATH(ecos_tcl_incdir)
474
        ECOS_MSVC_PATH(ecos_tcl_libdir)
475
        ecos_INCLUDES="${ecos_INCLUDES} \"-I${ecos_tcl_incdir}\""
476
        ecos_LIBS="${ecos_LIBS} tcl${with_tcl_version}.lib"
477
        ecos_LDADD="${ecos_LDADD} \"-libpath=${ecos_tcl_libdir}\""
478
 
479
        dnl FIXME: what libraries are needed for a tk application under VC++?
480
        dnl        and can the version be determined more accurately?
481
        ecos_tk_libs=""
482
 
483
    else
484
        dnl Try to find tclConfig.sh
485
        possibles=""
486
        if test "${with_tcl+set}" = set ; then
487
            possibles="${with_tcl}/lib"
488
            if test "${with_tcl_version+set}" = set ; then
489
                possibles="${possibles} ${with_tcl}/lib/tcl${with_tcl_version}"
490
            fi
491
        fi
492
        possibles="${possibles} ${prefix}/lib"
493
        if test "${with_tcl_version+set}" = set ; then
494
            possibles="${possibles} ${prefix}/lib/tcl${with_tcl_version}"
495
        fi
496
        possibles="${possibles} /usr/lib"
497
        if test "${with_tcl_version+set}" = set ; then
498
            possibles="${possibles} /usr/lib/tcl${with_tcl_version}"
499
        fi
500
        AC_FIND_FILE("tclConfig.sh", ${possibles}, tclconfig)
501
        if test \! -r "${tclconfig}/tclConfig.sh" ; then
502
            AC_MSG_ERROR(unable to locate Tcl configuration file tclConfig.sh)
503
        else
504
            . ${tclconfig}/tclConfig.sh
505
 
506
            dnl Now we need to figure out where to find the Tcl header files.
507
            dnl tclConfig.sh may define a variable TCL_INC_DIR, otherwise
508
            dnl use TCL_PREFIX/include
509
            if test -z "${TCL_INC_DIR}" ; then
510
                ecos_tcl_incdir="${TCL_PREFIX}/include"
511
            else
512
                ecos_tcl_incdir="${TCL_INC_DIR}"
513
            fi
514
            if test \! -r "${ecos_tcl_incdir}/tcl.h" ; then
515
                AC_MSG_ERROR(unable to locate Tcl header file tcl.h)
516
            else
517
                dnl On Unix systems -I/usr/include is unnecessary, and can
518
                dnl cause problems on hosts where gcc is not the platform's
519
                dnl default compiler because of the use of unfixed headers.
520
                dnl Hence it is explicitly removed here.
521
                if test "${ecos_tcl_incdir}" != "/usr/include" ; then
522
                    ecos_INCLUDES="${ecos_INCLUDES} -I${ecos_tcl_incdir}"
523
                fi
524
            fi
525
 
526
            dnl There should be a variable TCL_LIB_SPEC which defines
527
            dnl exactly how to link with Tcl. Unfortunately this is not
528
            dnl 100% guaranteed, so a backup solution is still needed.
529
            dnl NOTE: there is also TCL_LIBS defining additional libraries
530
            dnl such as -ldl. That may have to be added to ecos_LIBS.
531
            if test -z "${TCL_LIB_SPEC}" -a "${with_tcl_version+set}" = set ; then
532
                AC_FIND_FILE("libtcl${with_tcl_version}.a", ${possibles}, libtcl)
533
                if test -r "${libtcl}/libtcl${with_tcl_version}.a" ; then
534
                    TCL_LIB_SPEC="-L${libtcl} -ltcl${with_tcl_version}"
535
                fi
536
            fi
537
            if test -z "${TCL_LIB_SPEC}" ; then
538
                AC_FIND_FILE("libtcl.a", ${possibles}, libtcl)
539
                if test -r "${libtcl}/libtcl.a" ; then
540
                    TCL_LIB_SPEC="-L${libtcl} -ltcl"
541
                fi
542
            fi
543
            if test -z "${TCL_LIB_SPEC}" ; then
544
                AC_MSG_ERROR(${tclconfig}/tclConfig.sh does not define TCL_LIB_SPEC, and unable to find libtcl.a)
545
            fi
546
            ecos_LIBS="${ecos_LIBS} ${TCL_LIB_SPEC}"
547
 
548
            dnl Next, look for tkConfig.sh
549
            possibles=`echo ${possibles} | sed -e 's,tcl,tk,g'`
550
            AC_FIND_FILE("tkConfig.sh", ${possibles}, tkconfig)
551
            if test \! -r "${tkconfig}/tkConfig.sh" ; then
552
                AC_MSG_ERROR(unable to locate Tk config file tkConfig.sh)
553
            else
554
                . ${tkconfig}/tkConfig.sh
555
                if test -z "${TK_INC_DIR}" ; then
556
                    if test "${TK_PREFIX}" = "/usr" ; then
557
                        ecos_tk_includes="${TK_XINCLUDES}"
558
                    else
559
                        ecos_tk_includes="-I${TK_PREFIX}/include ${TK_XINCLUDES}"
560
                    fi
561
                else
562
                    ecos_tk_includes="-I${TK_INC_DIR} ${TK_XINCLUDES}"
563
                fi
564
 
565
                dnl As with TCL_LIB_SPEC, TK_LIB_SPEC may be empty
566
                if test -z "${TK_LIB_SPEC}" -a "${with_tcl_version+set}" = set ; then
567
                    AC_FIND_FILE("libtk${with_tcl_version}.a", ${possibles}, libtk)
568
                    if test -r "${libtk}/libtk${with_tcl_version}.a" ; then
569
                        TK_LIB_SPEC="-L${libtk} -ltk${with_tcl_version}"
570
                    fi
571
                fi
572
                if test -z "${TK_LIB_SPEC}" ; then
573
                    AC_FIND_FILE("libtk.a", ${possibles}, libtk)
574
                    if test -r "${libtk}/libtk.a" ; then
575
                        TK_LIB_SPEC="-L${libtk} -ltk"
576
                    fi
577
                fi
578
                if test -z "${TK_LIB_SPEC}" ; then
579
                    AC_MSG_ERROR(${tkconfig}/tkConfig.sh does not define TK_LIB_SPEC, and unable to find libtk.a)
580
                fi
581
                ecos_tk_libs="${TK_LIB_SPEC} ${TK_LIBS}"
582
            fi
583
        fi
584
    fi
585
 
586
    AC_MSG_RESULT([-I${ecos_tcl_incdir} ${TCL_LIB_SPEC}])
587
    AC_SUBST(ecos_tk_includes)
588
    AC_SUBST(ecos_tk_libs)
589
])
590
 
591
dnl ====================================================================
592
dnl Search for the infrastructure headers. Usually these can be picked
593
dnl up from host/infra in the build tree. This macro updates
594
dnl ecos_INCLUDES, ecos_LDADD and ecos_LIBS appropriately. In addition
595
dnl it defines new variables ecos_infra_incdir and ecos_infra_libdir,
596
dnl useful for listing explicit dependencies.
597
dnl
598
dnl This macro should only be used in configure scripts that run after
599
dnl the infrastructure has been configured because it relies on the
600
dnl infra directory already having been created in the build tree.
601
 
602
AC_DEFUN(ECOS_PATH_INFRA, [
603
    AC_MSG_CHECKING([for eCos host-side infrastructure])
604
 
605
    dnl Where are we in the build tree? First assume that we are in the host
606
    dnl tree, thus allowing configury of just the host-side. If that fails
607
    dnl assume we can be anywhere.
608
    infra_builddir=""
609
    possibles=".. ../.. ../../.. ../../../.. ../../../../.."
610
    AC_FIND_DIR("infra", ${possibles}, infra_builddir)
611
    if test "${infra_builddir}" = "" ; then
612
      possibles="../host ../../host ../../../host ../../../../host ../../../../../host ../../../../../../host"
613
      AC_FIND_DIR("infra", ${possibles}, infra_builddir)
614
    fi
615
    if test "${infra_builddir}" != "" ; then
616
        infra_builddir="${infra_builddir}/infra"
617
        infra_builddir=`cd ${infra_builddir} && /bin/pwd`
618
    fi
619
 
620
    ecos_infra_incdir=""
621
    ecos_infra_libdir=""
622
    ecos_infra_libs=""
623
 
624
    AC_ARG_WITH(infra-header,[ --with-infra-header=<path> location of eCos infrastructure headers])
625
    AC_ARG_WITH(infra-lib,[ --with-infra-lib=<path>    location of eCos infrastructure library])
626
    AC_ARG_WITH(infra,[ --with-infra=<path>        location of eCos infrastructure installation])
627
 
628
    if test "${with_infra_header+set}" = "set"; then
629
        ecos_infra_incdir="${with_infra_header}"
630
    elif test "${with_infra+set}" = "set"; then
631
        ecos_infra_incdir="${with_infra}/include"
632
    elif test "${infra_builddir}" != "" ; then
633
        ecos_infra_incdir="${infra_builddir}"
634
    else
635
        AC_MSG_ERROR([infrastructure headers not found])
636
    fi
637
    if test "${MSVC}" = "yes" ; then
638
        ecos_msvc_infra_incdir=${ecos_infra_incdir}
639
        ECOS_MSVC_PATH(ecos_msvc_infra_incdir)
640
        ecos_INCLUDES="${ecos_INCLUDES} \"-I${ecos_msvc_infra_incdir}\""
641
    else
642
        ecos_INCLUDES="${ecos_INCLUDES} -I${ecos_infra_incdir}"
643
    fi
644
 
645
    if test "${with_infra_lib+set}" = "set"; then
646
        ecos_infra_libdir="${with_infra_lib}"
647
    elif test "${with_infra+set}" = "set"; then
648
        ecos_infra_libdir="${with_infra}/lib"
649
    elif test "${infra_builddir}" != "" ; then
650
        ecos_infra_libdir="${infra_builddir}"
651
    else
652
        AC_MSG_ERROR([infrastructure library not found])
653
    fi
654
    if test "${MSVC}" = "yes" ; then
655
        ecos_msvc_infra_libdir=${ecos_infra_libdir}
656
        ECOS_MSVC_PATH(ecos_msvc_infra_libdir)
657
        ecos_LIBS="${ecos_LIBS} cyginfra.lib"
658
        ecos_LDADD="${ecos_LDADD} \"-libpath=${ecos_msvc_infra_libdir}\""
659
    else
660
        ecos_LIBS="${ecos_LIBS} -lcyginfra"
661
        ecos_LDADD="${ecos_LDADD} -L${ecos_infra_libdir}"
662
    fi
663
 
664
    AC_SUBST(ecos_infra_incdir)
665
    AC_SUBST(ecos_infra_libdir)
666
    AC_MSG_RESULT(-I[${ecos_infra_incdir} -L${ecos_infra_libdir}])
667
])
668
 
669
dnl ====================================================================
670
dnl And a very similar macro for libcdl, but note that the headers
671
dnl are in the source tree rather than the build tree.
672
 
673
AC_DEFUN(ECOS_PATH_LIBCDL, [
674
    AC_MSG_CHECKING([for libcdl])
675
 
676
    dnl Where are we in the source tree?
677
    libcdl_srcdir=""
678
    possibles="${srcdir}/.. ${srcdir}/../.. ${srcdir}/../../.. ${srcdir}/../../../.. ${srcdir}/../../../../.."
679
    AC_FIND_DIR("libcdl", ${possibles}, libcdl_srcdir)
680
    if test "${libcdl_srcdir}" = "" ; then
681
      possibles="${srcdir}/../host ${srcdir}/../../host ${srcdir}/../../../host ${srcdir}/../../../../host ${srcdir}/../../../../../host ${srcdir}/../../../../../../host"
682
      AC_FIND_DIR("libcdl", ${possibles}, libcdl_srcdir)
683
    fi
684
    if test "${libcdl_srcdir}" != "" ; then
685
        libcdl_srcdir="${libcdl_srcdir}/libcdl"
686
        libcdl_srcdir=`cd ${libcdl_srcdir} && /bin/pwd`
687
    fi
688
 
689
    dnl And where are we in the build tree?
690
    libcdl_builddir=""
691
    possibles=".. ../.. ../../.. ../../../.. ../../../../.."
692
    AC_FIND_DIR("libcdl", ${possibles}, libcdl_builddir)
693
    if test "${libcdl_builddir}" = "" ; then
694
      possibles="../host ../../host ../../../host ../../../../host ../../../../../host ../../../../../../host"
695
      AC_FIND_DIR("libcdl", ${possibles}, libcdl_builddir)
696
    fi
697
    if test "${libcdl_builddir}" != "" ; then
698
        libcdl_builddir="${libcdl_builddir}/libcdl"
699
        libcdl_builddir=`cd ${libcdl_builddir} && /bin/pwd`
700
    fi
701
 
702
    ecos_libcdl_incdir=""
703
    ecos_libcdl_libdir=""
704
    ecos_libcdl_libs=""
705
 
706
    AC_ARG_WITH(libcdl-header,[ --with-libcdl-header=<path> location of eCos libcdl headers])
707
    AC_ARG_WITH(libcdl-lib,[ --with-libcdl-lib=<path>    location of eCos libcdl library])
708
    AC_ARG_WITH(libcdl,[ --with-libcdl=<path>        location of eCos libcdl installation])
709
 
710
    if test "${with_libcdl_header+set}" = "set"; then
711
        ecos_libcdl_incdir="${with_libcdl_header}"
712
    elif test "${with_libcdl+set}" = "set"; then
713
        ecos_libcdl_incdir="${with_libcdl}/include"
714
    elif test "${libcdl_srcdir}" != "" ; then
715
        ecos_libcdl_incdir="${libcdl_srcdir}"
716
    fi
717
    if test \! -r "${ecos_libcdl_incdir}/cdl.hxx" ; then
718
        AC_MSG_ERROR([libcdl headers not found])
719
    fi
720
    if test "${MSVC}" = "yes" ; then
721
        ecos_msvc_libcdl_incdir="${ecos_libcdl_incdir}"
722
        ECOS_MSVC_PATH(ecos_msvc_libcdl_incdir)
723
        ecos_INCLUDES="${ecos_INCLUDES} \"-I${ecos_msvc_libcdl_incdir}\""
724
    else
725
        ecos_INCLUDES="${ecos_INCLUDES} -I${ecos_libcdl_incdir}"
726
    fi
727
 
728
    if test "${with_libcdl_lib+set}" = "set"; then
729
        ecos_libcdl_libdir="${with_libcdl_lib}"
730
    elif test "${with_libcdl+set}" = "set"; then
731
        ecos_libcdl_libdir="${with_libcdl}/lib"
732
    elif test "${libcdl_builddir}" != "" ; then
733
        ecos_libcdl_libdir="${libcdl_builddir}"
734
    else
735
        AC_MSG_ERROR([libcdl library not found])
736
    fi
737
    if test "${MSVC}" = "yes" ; then
738
        ecos_msvc_libcdl_libdir=${ecos_libcdl_libdir}
739
        ECOS_MSVC_PATH(ecos_msvc_libcdl_libdir)
740
        ecos_LIBS="${ecos_LIBS} cdl.lib"
741
        ecos_LDADD="${ecos_LDADD} \"-libpath=${ecos_msvc_libcdl_libdir}\""
742
    else
743
        ecos_LIBS="${ecos_LIBS} -lcdl"
744
        ecos_LDADD="${ecos_LDADD} -L${ecos_libcdl_libdir}"
745
    fi
746
 
747
    AC_SUBST(ecos_libcdl_incdir)
748
    AC_SUBST(ecos_libcdl_libdir)
749
    AC_MSG_RESULT([-I${ecos_libcdl_incdir} -L${ecos_libcdl_libdir}])
750
])
751
 
752
dnl ====================================================================
753
dnl Look for a 64 bit data type. It is necessary to check both C and C++
754
dnl compilers.
755
dnl
756
dnl A better implementation would check whether or not AC_PROG_CC and
757
dnl AC_PROG_CXX have been invoked and only test the appropriate
758
dnl compiler.
759
dnl
760
dnl When cross-compiling, default to long long on the assumption that
761
dnl gcc/g++ must be used and long long is likely to be the 64 bit data
762
dnl type. This is not guaranteed, but sufficiently likely to meet
763
dnl the requirements for the time being. The CHECK_SIZEOF() macro
764
dnl might be another way to get the desired information.
765
 
766
AC_DEFUN(ECOS_TYPE_64bit, [
767
    AC_REQUIRE([AC_PROG_CC])
768
    AC_REQUIRE([AC_PROG_CXX])
769
 
770
    AC_CACHE_CHECK("for a 64 bit data type",ecos_cv_type_64bit,[
771
        for type in "long" "long long" "__int64"; do
772
            AC_LANG_SAVE
773
            AC_LANG_C
774
            AC_TRY_RUN([
775
                main() {
776
                    return 8 != sizeof($type);
777
                }
778
            ],ctype_64bit=$type,ctype_64bit="unknown",ctype_64bit="long long")
779
            AC_LANG_CPLUSPLUS
780
            AC_TRY_RUN([
781
                int main(int argc, char ** argv) {
782
                    return 8 != sizeof($type);
783
                }
784
            ],cxxtype_64bit=$type,cxxtype_64bit="unknown",cxxtype_64bit="long long")
785
            AC_LANG_RESTORE
786
            if test "${ctype_64bit}" = "${type}" -a "${cxxtype_64bit}" = "${type}"; then
787
                ecos_cv_type_64bit="${type}"
788
                break
789
            fi
790
        done
791
    ])
792
    if test "${ecos_cv_type_64bit}" = ""; then
793
        AC_MSG_ERROR(Unable to figure out how to do 64 bit arithmetic)
794
    else
795
        if test "${ecos_cv_type_64bit}" != "long long"; then
796
            AC_DEFINE_UNQUOTED(cyg_halint64,${ecos_cv_type_64bit})
797
            AC_DEFINE_UNQUOTED(cyg_halcount64,${ecos_cv_type_64bit})
798
        fi
799
    fi
800
])
801
 
802
dnl ====================================================================
803
dnl Check that both the C and C++ compilers support __PRETTY_FUNCTION__
804
 
805
AC_DEFUN(ECOS_C_PRETTY_FUNCTION,[
806
    AC_REQUIRE([AC_PROG_CC])
807
    AC_REQUIRE([AC_PROG_CXX])
808
 
809
    AC_CACHE_CHECK("for __PRETTY_FUNCTION__ support",ecos_cv_c_pretty_function,[
810
        AC_LANG_SAVE
811
        AC_LANG_C
812
        AC_TRY_LINK(
813
            [#include <stdio.h>],
814
            [puts(__PRETTY_FUNCTION__);],
815
            c_ok="yes",
816
            c_ok="no"
817
        )
818
        AC_LANG_CPLUSPLUS
819
        AC_TRY_LINK(
820
            [#include <cstdio>],
821
            [puts(__PRETTY_FUNCTION__);],
822
            cxx_ok="yes",
823
            cxx_ok="no"
824
        )
825
        AC_LANG_RESTORE
826
        if test "${c_ok}" = "yes" -a "${cxx_ok}" = "yes"; then
827
            ecos_cv_c_pretty_function="yes"
828
        fi
829
    ])
830
    if test "${ecos_cv_c_pretty_function}" = "yes"; then
831
        AC_DEFINE(CYGDBG_INFRA_DEBUG_FUNCTION_PSEUDOMACRO)
832
    fi
833
])
834
 
835
dnl ====================================================================
836
dnl During installation eCos package-specific host-side code should be
837
dnl versioned in the same way as the packages themselves, allowing
838
dnl different versions to coexist in one installation. This is analogous
839
dnl to having multiple versions of a shared library installed so that
840
dnl applications can load whichever one they were linked with.
841
dnl
842
dnl To support all this the host-side code needs access to a number
843
dnl of directory names:
844
dnl     ECOS_REPOSITORY    e.g. ~/ecc/ecc
845
dnl     PACKAGE_DIR        e.g. hal/synth/arch
846
dnl     PACKAGE_VERSION    e.g. current
847
dnl     PACKAGE_INSTALL    e.g. hal/synth/arch/current
848
dnl
849
dnl These, together with the standard variable libexecdir, allow
850
dnl the host-side code to navigate around both source and install
851
dnl trees.
852
 
853
AC_DEFUN(ECOS_PACKAGE_DIRS,[
854
 
855
    dnl srcdir will be something like <path>/packages/<package_path>/<version>/host
856
    package_dir=`cd ${srcdir} && /bin/pwd`
857
    PACKAGE_VERSION=`dirname ${package_dir}`
858
    PACKAGE_VERSION=`basename ${PACKAGE_VERSION}`
859
 
860
    dnl Now look for an "acsupport" directory as a good way of identifying
861
    dnl the root of the repository. Assume that this does not clash with
862
    dnl any real packages in the repository. Also assume that no silly games
863
    dnl are being played with symlinks.
864
    package_dir=`dirname ${package_dir}`
865
    package_dir=`dirname ${package_dir}`
866
 
867
    possibles="${package_dir}/.. ${package_dir}/../.. ${package_dir}/../../.. ${package_dir}/../../../.."
868
    possibles="${possibles} ${package_dir}/../../../../.. ${package_dir}/../../../../../.."
869
    AC_FIND_DIR("acsupport", ${possibles}, repository_root)
870
    if test "${repository_root}" = "" ; then
871
        AC_MSG_ERROR([Failed to identify this package's position within the eCos repository])
872
    fi
873
    dnl repository_root will still contain the ..'s, instead of an absolute path
874
    ECOS_REPOSITORY=`cd "${repository_root}/packages/pkgconf/.." && /bin/pwd`
875
 
876
    dnl Now we have two absolute paths, so just remove one from the other
877
    PACKAGE_DIR=`echo ${package_dir} | sed -e "s:${ECOS_REPOSITORY}/::"`
878
 
879
    dnl To avoid creating too many subdirectories on the host-side, turn
880
    dnl e.g. hal/synth/arch into hal_synth_arch. Theoretically this could
881
    dnl go wrong because multiple packages could map onto the same string,
882
    dnl but in practice there should be a net reduction in complexity.
883
    dnl bartv: / to _ conversion disabled for now, 5 March 2002
884
    PACKAGE_INSTALL="${PACKAGE_DIR}/${PACKAGE_VERSION}"
885
    dnl PACKAGE_INSTALL=`echo ${PACKAGE_INSTALL} | sed -e "s:/:_:g"`
886
 
887
    AC_SUBST(ECOS_REPOSITORY)
888
    AC_SUBST(PACKAGE_DIR)
889
    AC_SUBST(PACKAGE_VERSION)
890
    AC_SUBST(PACKAGE_INSTALL)
891
])

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.