summaryrefslogtreecommitdiff
path: root/itcl/itk/unix/configure.in
blob: 7624fe4b3a294ba5778e5fcb53c7926919847139 (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
dnl	This file is an input file used by the GNU "autoconf" program to
dnl	generate the file "configure", which is run during Tk installation
dnl	to configure the system for the local environment.

AC_INIT(../generic/itk.h)
# RCS: $Id$

ITCL_VERSION=3.0
ITCL_MAJOR_VERSION=3
ITCL_MINOR_VERSION=0
ITCL_RELEASE_LEVEL=0
VERSION=${ITCL_VERSION}

AC_CONFIG_AUX_DIR(../../config)
AC_PREREQ(2.0)

# -----------------------------------------------------------------------
#   Set up a new default --prefix.  If a previous installation of
#   [incr Tcl] can be found searching $PATH use that directory.
# -----------------------------------------------------------------------

AC_PREFIX_DEFAULT(/usr/local)
AC_PREFIX_PROGRAM(tclsh)

if test "${prefix}" = "NONE"; then
    prefix=/usr/local
fi
if test "${exec_prefix}" = "NONE"; then
    exec_prefix=$prefix
fi

AC_PROG_INSTALL
AC_PROG_RANLIB

# -----------------------------------------------------------------------
BUILD_DIR=`pwd`
ITK_SRC_DIR=`cd $srcdir/..; pwd`
cd ${BUILD_DIR}

dnl CYGNUS LOCAL: allow gcc without a special flag
dnl AC_ARG_ENABLE(gcc, [  --enable-gcc            allow use of gcc if available],
dnl     [itk_ok=$enableval], [itk_ok=no])
dnl if test "$itk_ok" = "yes"; then
    AC_PROG_CC
dnl else
dnl     CC=${CC-cc}
dnl AC_SUBST(CC)
dnl fi
# END CYGNUS LOCAL

#--------------------------------------------------------------------
#   See if there was a command-line option for where Tcl is;  if
#   not, search for Tcl.
#   not, assume that its top-level directory is a sibling of ours.
# CYGNUS LOCAL - Actually Tcl & Tk are just called "tcl" & "tk" without the 8.0
#--------------------------------------------------------------------

AC_ARG_WITH(tcl, [  --with-tcl=DIR          use Tcl 8.0 binaries from DIR],
        itcl_search=$withval, itcl_search=`cd ../../..; ls -d \`pwd\`/tcl*/unix`)

TCL_LIB_DIR=""
for dir in $itcl_search $exec_prefix/lib ; do
    if test -r $dir/tclConfig.sh; then
        TCL_LIB_DIR=$dir
        break
    fi
done

if test -z "$TCL_LIB_DIR"; then
    AC_MSG_ERROR(Can't find Tcl libraries.  Use --with-tcl to specify the directory containing tclConfig.sh on your system.)
fi

#--------------------------------------------------------------------
#   Read in configuration information generated by Tcl for shared
#   libraries, and arrange for it to be substituted into our
#   Makefile.
#--------------------------------------------------------------------

file=$TCL_LIB_DIR/tclConfig.sh
. $file
CFLAGS=$TCL_CFLAGS
SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
SHLIB_LD=$TCL_SHLIB_LD
SHLIB_LD_LIBS=$TCL_SHLIB_LD_LIBS
SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
DL_LIBS=$TCL_DL_LIBS
LD_FLAGS=$TCL_LD_FLAGS
LD_SEARCH_FLAGS=$TCL_LD_SEARCH_FLAGS

#--------------------------------------------------------------------
#   Make sure that we can find the Tcl sources, so we can include
#   the "tclInt.h" file.
#--------------------------------------------------------------------

if test ! -d "$TCL_SRC_DIR"; then
    AC_MSG_ERROR(Can't find Tcl source directory "$TCL_SRC_DIR".  Itcl can't be built without this directory.)
fi

#--------------------------------------------------------------------
#   See if there was a command-line option for where Tk is;  if
#   not, search for Tk.
# CYGNUS LOCAL - Actually Tcl & Tk are just called "tcl" & "tk" without the 8.0
#--------------------------------------------------------------------

AC_ARG_WITH(tk, [  --with-tk=DIR           use Tk 8.0 binaries from DIR],
        itcl_search=$withval, itcl_search=`cd ../../..; ls -d \`pwd\`/tk*/unix`)

TK_LIB_DIR=""
for dir in $itcl_search $exec_prefix/lib ; do
    if test -r $dir/tkConfig.sh; then
        TK_LIB_DIR=$dir
        break
    fi
done

if test -z "$TK_LIB_DIR"; then
    AC_MSG_ERROR(Can't find Tk libraries.  Use --with-tk to specify the directory containing tkConfig.sh on your system.)
fi

file=$TK_LIB_DIR/tkConfig.sh
. $file

#--------------------------------------------------------------------
#   See if there was a command-line option for where [incr Tcl] is.
#   If not, assume that its top-level directory is a sibling of ours.
#--------------------------------------------------------------------

AC_ARG_WITH(itcl, [  --with-itcl=DIR          use Itcl 3.0 binaries from DIR],
        ITCL_LIB_DIR=$withval, ITCL_LIB_DIR=`cd ../../itcl; pwd`)

if test ! -r "$ITCL_LIB_DIR/itclConfig.sh"; then
    AC_MSG_ERROR(Can't find Itcl libraries.  Have you built Itcl yet?  Use --with-itcl to specify the directory containing itclConfig.sh on your system.)
fi

file=$ITCL_LIB_DIR/itclConfig.sh
. $file

#--------------------------------------------------------------------
#   If this is gcc, add some extra compile flags.
#--------------------------------------------------------------------

AC_MSG_CHECKING([whether C compiler is gcc])
AC_CACHE_VAL(itcl_cv_prog_gcc, [
    AC_EGREP_CPP(_cc_is_gcc_, [
#ifdef __GNUC__
_cc_is_gcc_
#endif
],      [itcl_cv_prog_gcc=yes], [itcl_cv_prog_gcc=no])])
AC_MSG_RESULT([$itcl_cv_prog_gcc])

# CYGNUS LOCAL - set CFLAGS to -g -O2 for gcc.
if test -z "$CFLAGS" ; then
if test "$itcl_cv_prog_gcc" = "yes" ; then
   CFLAGS="-g -O2"
else
   CFLAGS="-O"
fi
fi

if test "$itcl_cv_prog_gcc" = "yes" ; then
    # leave -Wimplicit-int out, the X libs generate so many of these warnings
    # that they obscure everything else.
    # CYGNUS LOCAL - add -fwritable-strings to CFLAGS for gcc.  Needed 
    # with Tcl8.1
    CFLAGS="$CFLAGS -fwritable-strings -Wshadow -Wtraditional -Wall -Wno-implicit-int"
fi

AC_MSG_CHECKING([default compiler flags])
AC_ARG_WITH(cflags, [  --with-cflags=FLAGS     set compiler flags to FLAGS],
    [CFLAGS="$with_cflags"])

AC_MSG_RESULT([$CFLAGS])

if test "$TCL_CC" != "$CC" ; then
    echo ""
    echo "WARNING:  Compiler is $CC but Tcl was compiled with $TCL_CC"
    echo ""
fi

#--------------------------------------------------------------------
#   The statements below define a collection of symbols related to
#   building libitk as a shared library instead of a static library.
#--------------------------------------------------------------------

AC_ARG_ENABLE(shared,
    [  --enable-shared         build libitk as a shared library],
    [ok=$enableval], [ok=no])
if test "$ok" = "yes"; then
    if test ${TCL_SHARED_BUILD} = 0; then
        AC_MSG_ERROR(Tcl was not built with --enable-shared, so you can't use shared libraries.)
    fi
    SHLIB_CFLAGS="${SHLIB_CFLAGS}"
    eval "ITK_LIB_FILE=libitk${VERSION}${SHLIB_SUFFIX}"
    ITK_PKG_FILE="[[file join [file dirname \$dir] ${ITK_LIB_FILE}]]"
    # CYGNUS LOCAL - don't pass LD_SEARCH_FLAGS to libraries
    MAKE_LIB="\$(SHLIB_LD) -o ${ITK_LIB_FILE} \$(OBJS) "
    # END CYGNUS LOCAL
    RANLIB=":"
else
    SHLIB_CFLAGS=""
    # CYGNUS LOCAL - Strip dots from library name for SunOS4, etc...
    if test ${TCL_LIB_VERSIONS_OK} = "nodots"; then
        ITK_LIB_FILE="libitk`echo ${VERSION} | tr -d .`.a"
    else
        eval "ITK_LIB_FILE=libitk${VERSION}.a"
    fi
    ITK_PKG_FILE=""
    MAKE_LIB="ar cr ${ITK_LIB_FILE} \${OBJS}"
fi

# Note:  in the following variable, it's important to use the absolute
# path name of the Tcl directory rather than "..":  this is because
# AIX remembers this path and will attempt to use it at run-time to look
# up the Tcl library.

if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
    ITK_BUILD_LIB_SPEC="-L`pwd` -litk${VERSION}"
    ITK_LIB_SPEC="-L${exec_prefix}/lib -litk${VERSION}"
else
    ITK_BUILD_LIB_SPEC="-L`pwd` -litk`echo ${VERSION} | tr -d .`"
    ITK_LIB_SPEC="-L${exec_prefix}/lib -litk`echo ${VERSION} | tr -d .`"
fi

ITK_LIB_FULL_PATH="`pwd`/${ITK_LIB_FILE}"

AC_SUBST(CFLAGS)
AC_SUBST(DL_LIBS)
AC_SUBST(LD_FLAGS)
AC_SUBST(MAKE_LIB)
AC_SUBST(SHLIB_CFLAGS)
AC_SUBST(SHLIB_LD)
AC_SUBST(SHLIB_LD_LIBS)
AC_SUBST(SHLIB_SUFFIX)
AC_SUBST(LD_SEARCH_FLAGS)

AC_SUBST(TCL_VERSION)
AC_SUBST(TCL_SRC_DIR)
AC_SUBST(TCL_LIB_SPEC)
AC_SUBST(TCL_BUILD_LIB_SPEC)
AC_SUBST(TCL_LIB_FLAG)
AC_SUBST(TCL_DBGX)
AC_SUBST(TCL_DEFS)
AC_SUBST(TCL_LIBS)
AC_SUBST(TCL_SHLIB_LD_LIBS)
AC_SUBST(TCL_SHLIB_SUFFIX)
AC_SUBST(TCL_COMPAT_OBJS)
AC_SUBST(TCL_CFLAGS)
AC_SUBST(TCL_LIB_FULL_PATH)

AC_SUBST(TK_VERSION)
AC_SUBST(TK_BUILD_LIB_SPEC)
AC_SUBST(TK_LIB_DIR)
AC_SUBST(TK_LIB_SPEC)
AC_SUBST(TK_LIB_FLAG)
AC_SUBST(TK_XINCLUDES)
AC_SUBST(TK_XLIBSW)
AC_SUBST(TK_SRC_DIR)
AC_SUBST(TK_LIB_FULL_PATH)

AC_SUBST(ITCL_VERSION)
AC_SUBST(ITCL_MAJOR_VERSION)
AC_SUBST(ITCL_MINOR_VERSION)
AC_SUBST(ITCL_RELEASE_LEVEL)
AC_SUBST(ITCL_BUILD_LIB_SPEC)
AC_SUBST(ITCL_LIB_FULL_PATH)
AC_SUBST(ITCL_LIB_DIR)
AC_SUBST(ITCL_LIB_SPEC)
AC_SUBST(ITCL_PKG_FILE)
AC_SUBST(ITCL_SRC_DIR)

AC_SUBST(ITK_BUILD_LIB_SPEC)
AC_SUBST(ITK_LIB_FILE)
AC_SUBST(ITK_LIB_SPEC)
AC_SUBST(ITK_PKG_FILE)
AC_SUBST(ITK_SRC_DIR)
AC_SUBST(ITK_LIB_FULL_PATH)

AC_OUTPUT(Makefile pkgIndex.tcl ../itkConfig.sh)