c092a6e by ptr at 2003-11-14 1
#!/bin/sh
2
2c796b4 by Petr Ovtchenkov at 2009-01-09 3
# Time-stamp: <09/01/09 12:08:03 ptr>
c092a6e by ptr at 2003-11-14 4
18b4328 by Petr Ovtchenkov at 2010-06-02 5
#
6
# Copyright (c) 2003-2010
7
# Petr Ovtchenkov
8
#
9
# This material is provided "as is", with absolutely no warranty expressed# or implied. Any use is at your own risk.
10
#
11
# Permission to use or copy this software for any purpose is hereby granted
12
# without fee, provided the above notices are retained on all copies.
13
# Permission to modify the code and to distribute modified code is granted,
14
# provided the above notices are retained, and a notice that the code was
15
# modified is included with the above copyright notice.
16
#
17
5aca496 by complement at 2008-06-06 18
base=`cd \`dirname $0\`; echo $PWD`
c092a6e by ptr at 2003-11-14 19
a30f1c8 by complement at 2008-09-23 20
configmak=$base/Makefiles/gmake/config.mak
25a4884 by ptr at 2004-03-11 21
22
write_option() {
23
  target=`echo $1 | sed -e 's/^[^=]*=//'`
68d221f by complement at 2008-02-28 24
  echo $2 := $3$target >> ${configmak}
25a4884 by ptr at 2004-03-11 25
}
c092a6e by ptr at 2003-11-14 26
bb762f7 by complement at 2008-01-16 27
write_over_option() {
28
  target=`echo $1 | sed -e 's/^[^=]*=//'`
29
  echo $2 ?= $target >> ${configmak}
30
}
31
2c796b4 by Petr Ovtchenkov at 2009-01-09 32
write_raw_option() {
33
  echo $2 := $3$1 >> ${configmak}
34
}
35
7fe9a66 by ptr at 2005-04-18 36
print_help() {
37
  cat <<EOF
25a4884 by ptr at 2004-03-11 38
Configuration utility.
39
40
Usage:
41
42
  configure [options]
43
44
Available options:
45
9ddd5ea by complement at 2007-11-23 46
  --prefix=<dir>        base install path (/usr/local/)
47
  --bindir=<dir>        install path for executables (PREFIX/bin)
48
  --libdir=<dir>        install path for libraries (PREFIX/lib)
49
  --includedir=<dir>    install path for headers (PREFIX/include)
4c79b56 by dums at 2006-01-13 50
9ddd5ea by complement at 2007-11-23 51
  --target=<target>     target platform (cross-compiling)
4c79b56 by dums at 2006-01-13 52
9ddd5ea by complement at 2007-11-23 53
  --help                print this help message and exit
4c79b56 by dums at 2006-01-13 54
9ddd5ea by complement at 2007-11-23 55
  --with-stlport=<dir>  use STLport in catalog <dir>
56
  --without-stlport     compile without STLport
57
  --with-boost=<dir>    use boost headers in catalog <dir>
58
  --with-system-boost   use boost installed on this system
59
  --with-msvc=<dir>     use MS VC from this catalog
60
  --with-mssdk=<dir>    use MS SDK from this catalog
7fe9a66 by ptr at 2005-04-18 61
  --with-extra-cxxflags=<options>
9ddd5ea by complement at 2007-11-23 62
                        pass extra options to C++ compiler
4cf8f74 by complement at 2008-04-22 63
  --with-extra-cflags=<options>
64
                        pass extra options to C compiler
29df3b0 by complement at 2008-06-06 65
  --with-extra-ldflags=<options>
66
                        pass extra options to linker (via C/C++)
134ca82 by complement at 2006-01-24 67
  --use-static-gcc      use static gcc libs instead of shared libgcc_s (useful for gcc compiler,
68
                        that was builded with --enable-shared [default]; if compiler was builded
69
                        with --disable-shared, static libraries will be used in any case)
25a4884 by ptr at 2004-03-11 70
  --clean               remove custom settings (file ${configmak})
71
                        and use default values
9ddd5ea by complement at 2007-11-23 72
  --with-cxx=<name>     use <name> as C++ compiler (use --target= for cross-compilation)
73
  --with-cc=<name>      use <name> as C compiler (use --target= for cross-compilation)
74
  --use-compiler-family=<name> use compiler family; one of:
75
                        gcc      GNU compilers (default)
76
                        icc      Intel compilers
77
                        aCC      HP's aCC compilers
78
                        CC       SunPro's CC compilers
ab09624 by dums at 2008-06-18 79
                        bcc      Borland's compilers
9ddd5ea by complement at 2007-11-23 80
  --without-debug       don't build debug variant
81
  --without-stldebug    don't build STLport's STLP_DEBUG mode
82
  --enable-static       build static
83
  --disable-shared      don't build shared 
84
  --with-lib-motif=<motif>
85
                        Use this option to customize the generated library name.
86
                        The motif will be used in the last place before version information,
87
                        separated by an underscore, ex:
88
                        stlportd_MOTIF.5.0.lib
89
                        stlportstld_static_MOTIF.5.1.lib
c24514a by dums at 2008-03-08 90
  --without-thread      Per default STLport libraries are built in order to be usable
9ddd5ea by complement at 2007-11-23 91
                        in a multithreaded context. If you don't need this you can ask
92
                        for a not thread safe version with this option.
952ecd0 by dums at 2008-02-29 93
  --without-rtti        Disable RTTI when building libraries.
0713d09 by dums at 2008-03-10 94
  --with-static-rtl
95
  --with-dynamic-rtl
96
                        Enables usage of static (libc.lib family) or dynamic (msvcrt.lib family)
97
                        C/C++ runtime library when linking with STLport. If you want your appli/dll
98
                        to link statically with STLport but using the dynamic C runtime use
99
                        --with-dynamic-rtl; if you want to link dynamicaly with STLport but using the
100
                        static C runtime use --with-static-rtl. See README.options for details.
101
                        Don't forget to signal the link method when building your appli or dll, in
102
                        stlport/stl/config/host.h set the following macro depending on the configure
103
                        option:
abc9c46 by complement at 2008-06-24 104
                        --with-static-rtl  -> _STLP_USE_DYNAMIC_LIB"
105
                        --with-dynamic-rtl -> _STLP_USE_STATIC_LIB"
110c88c by dums at 2008-04-18 106
  --windows-platform=<name>
59c9c2f by dums at 2008-04-21 107
                        Targetted OS when building for Windows; one of:
110c88c by dums at 2008-04-18 108
                        win95   Windows 95
109
                        win98   Windows 98
59c9c2f by dums at 2008-04-21 110
                        winxp   Windows XP and later (default)
9ddd5ea by complement at 2007-11-23 111
112
Environment variables:
113
114
  \$CXX                 C++ compiler name (use --target= for cross-compilation)
115
  \$CC                  C compiler name (use --target= for cross-compilation)
116
  \$CXXFLAGS            pass extra options to C++ compiler
29df3b0 by complement at 2008-06-06 117
  \$CFLAGS              pass extra options to C compiler
118
  \$LDFLAGS             pass extra options to linker (via C/C++)
9ddd5ea by complement at 2007-11-23 119
120
  Options has preference over environment variables.
25a4884 by ptr at 2004-03-11 121
122
EOF
7fe9a66 by ptr at 2005-04-18 123
}
124
9ddd5ea by complement at 2007-11-23 125
default_settings () {
126
  # if [ "$boost_set" = "" ]; then
127
  #   write_option "${PWD}/external/boost" BOOST_DIR
128
  # fi
129
ab09624 by dums at 2008-06-18 130
  # if [ -z "${stlport_set}" ]; then
131
  #   write_over_option "$base" STLPORT_DIR
132
  # fi
9c3a5ff by complement at 2008-06-07 133
134
  # Set in Makefiles/gmake/top.mak
ab09624 by dums at 2008-06-18 135
  if [ -z "${compiler_family_set}" ]; then
136
  #  write_option gcc COMPILER_NAME
fae039f by complement at 2008-09-23 137
    ln -sf Makefiles/gcc.mak ${base}/src/Makefile
6d81ac0 by Petr Ovtchenkov at 2008-11-26 138
    ln -sf Makefiles/gcc.mak ${base}/test/cmp_unit/Makefile
692a233 by complement at 2008-09-23 139
    ln -sf Makefiles/gcc.mak ${base}/test/unit/Makefile
bfc7183 by complement at 2008-09-23 140
    ln -sf Makefiles/gcc.mak ${base}/test/eh/Makefile
ab09624 by dums at 2008-06-18 141
  fi
9c3a5ff by complement at 2008-06-07 142
143
  # Set in Makefiles/gmake/targetdirs.mak
144
  # if [ -z "${prefix_set}" ]; then
145
  #   write_option "/usr/local" BASE_INSTALL_DIR '${DESTDIR}'
146
  # fi
9ddd5ea by complement at 2007-11-23 147
}
148
149
for a in $@ ; do
150
  case $a in
151
    --help)
152
      print_help
153
      exit 0
154
      ;;
155
    --clean)
156
      rm -f ${configmak}
157
      exit 0
158
      ;;
159
  esac
160
done
7fe9a66 by ptr at 2005-04-18 161
9c3a5ff by complement at 2008-06-07 162
>${configmak}
7fe9a66 by ptr at 2005-04-18 163
164
while :
165
do
166
  case $# in
167
    0)
168
      break
25a4884 by ptr at 2004-03-11 169
      ;;
7fe9a66 by ptr at 2005-04-18 170
  esac
9ddd5ea by complement at 2007-11-23 171
  option="$1"
7fe9a66 by ptr at 2005-04-18 172
  shift
173
  case $option in
c092a6e by ptr at 2003-11-14 174
    --target=*)
25a4884 by ptr at 2004-03-11 175
      write_option "$option" TARGET_OS
9ddd5ea by complement at 2007-11-23 176
      target_set=y
25a4884 by ptr at 2004-03-11 177
      ;;
178
    --with-stlport=*)
179
      write_option "$option" STLPORT_DIR
9ddd5ea by complement at 2007-11-23 180
      stlport_set=y
25a4884 by ptr at 2004-03-11 181
      ;;
9ddd5ea by complement at 2007-11-23 182
    --without-stlport)
c24514a by dums at 2008-03-08 183
      write_option 1 WITHOUT_STLPORT
9ddd5ea by complement at 2007-11-23 184
      stlport_set=y
7fe9a66 by ptr at 2005-04-18 185
      ;;
9ddd5ea by complement at 2007-11-23 186
    --with-boost=*)
187
      write_option "$option" BOOST_DIR
d26635e by complement at 2005-11-01 188
      ;;
9ddd5ea by complement at 2007-11-23 189
    --with-system-boost)
c24514a by dums at 2008-03-08 190
      write_option 1 USE_SYSTEM_BOOST
d26635e by complement at 2005-11-01 191
      ;;
9ddd5ea by complement at 2007-11-23 192
    --with-msvc=*)
193
      write_option "$option" MSVC_DIR
d26635e by complement at 2005-11-01 194
      ;;
9ddd5ea by complement at 2007-11-23 195
    --with-mssdk=*)
196
      write_option "$option" MSSDK_DIR
4c79b56 by dums at 2006-01-13 197
      ;;
9ddd5ea by complement at 2007-11-23 198
    --with-extra-cxxflags=*)
199
      write_option "$option" EXTRA_CXXFLAGS
200
      cxxflags_set=y
97ba790 by dums at 2005-11-26 201
      ;;
4cf8f74 by complement at 2008-04-22 202
    --with-extra-cflags=*)
203
      write_option "$option" EXTRA_CFLAGS
204
      cflags_set=y
205
      ;;
29df3b0 by complement at 2008-06-06 206
    --with-extra-ldflags=*)
207
      write_option "$option" EXTRA_LDFLAGS
208
      ldflags_set=y
209
      ;;
9876ffc by dums at 2006-07-26 210
    --with-lib-motif=*)
211
      echo "Using $option in generated library names"
c24514a by dums at 2008-03-08 212
      write_option "$option" LIB_MOTIF
9876ffc by dums at 2006-07-26 213
      ;;
c24514a by dums at 2008-03-08 214
    --without-thread)
215
      write_option 1 WITHOUT_THREAD
9ddd5ea by complement at 2007-11-23 216
      ;;
952ecd0 by dums at 2008-02-29 217
    --without-rtti)
c24514a by dums at 2008-03-08 218
      write_option 1 WITHOUT_RTTI
952ecd0 by dums at 2008-02-29 219
      ;;
0713d09 by dums at 2008-03-10 220
    --with-dynamic-rtl)
221
      write_option 1 WITH_DYNAMIC_RTL
222
      ;;
223
    --with-static-rtl)
224
      write_option 1 WITH_STATIC_RTL
225
      ;;
134ca82 by complement at 2006-01-24 226
    --use-static-gcc)
c24514a by dums at 2008-03-08 227
      write_option 1 USE_STATIC_LIBGCC
9ddd5ea by complement at 2007-11-23 228
      ;;
229
    --without-debug)
c24514a by dums at 2008-03-08 230
      write_option 1 _NO_DBG_BUILD
9ddd5ea by complement at 2007-11-23 231
      ;;
232
    --without-stldebug)
c24514a by dums at 2008-03-08 233
      write_option 1 _NO_STLDBG_BUILD
9ddd5ea by complement at 2007-11-23 234
      ;;
235
    --enable-static)
c24514a by dums at 2008-03-08 236
      write_option 1 _STATIC_BUILD
9ddd5ea by complement at 2007-11-23 237
      ;;
238
    --disable-shared)
c24514a by dums at 2008-03-08 239
      write_option 1 _NO_SHARED_BUILD
9ddd5ea by complement at 2007-11-23 240
      ;;
241
    --with-cxx=*)
242
      write_option "$option" _FORCE_CXX
243
      cxx_set=y
244
      ;;
245
    --with-cc=*)
246
      write_option "$option" _FORCE_CC
247
      cc_set=y
248
      ;;
249
    --use-compiler-family=*)
250
      case `echo $option | sed -e 's/^[^=]*=//'` in
ab09624 by dums at 2008-06-18 251
        gcc|icc|aCC|CC|bcc|dmc)
252
          target=`echo $option | sed -e 's/^[^=]*=//'`
253
          echo COMPILER_NAME := $target >> ${configmak}
fae039f by complement at 2008-09-23 254
          ln -sf Makefiles/$target.mak ${base}/src/Makefile
6d81ac0 by Petr Ovtchenkov at 2008-11-26 255
          ln -sf Makefiles/$target.mak ${base}/test/cmp_unit/Makefile
bfc7183 by complement at 2008-09-23 256
          ln -sf Makefiles/$target.mak ${base}/test/unit/Makefile
257
          ln -sf Makefiles/$target.mak ${base}/test/eh/Makefile
9ddd5ea by complement at 2007-11-23 258
          ;;
259
        *)
260
          echo "Not supported compilers family"
261
          exit -1
262
          ;;
263
      esac
264
      compiler_family_set=y
265
      ;;
266
    --prefix=*)
68d221f by complement at 2008-02-28 267
      write_option "$option" BASE_INSTALL_DIR '${DESTDIR}'
9c3a5ff by complement at 2008-06-07 268
      prefix_set=y
9ddd5ea by complement at 2007-11-23 269
      ;;
270
    --bindir=*)
68d221f by complement at 2008-02-28 271
      write_option "$option" INSTALL_BIN_DIR '${DESTDIR}'
9ddd5ea by complement at 2007-11-23 272
      ;;
273
    --libdir=*)
68d221f by complement at 2008-02-28 274
      write_option "$option" INSTALL_LIB_DIR '${DESTDIR}'
9ddd5ea by complement at 2007-11-23 275
      ;;
276
    --includedir=*)
68d221f by complement at 2008-02-28 277
      write_option "$option" INSTALL_HDR_DIR '${DESTDIR}'
134ca82 by complement at 2006-01-24 278
      ;;
110c88c by dums at 2008-04-18 279
    --windows-platform=*)
280
      case `echo $option | sed -e 's/^[^=]*=//'` in
281
        win95)
282
          write_option 0x0400 WINVER
283
          ;;
284
        win98)
285
          write_option 0x0410 WINVER
286
          ;;
287
        winxp)
288
          write_option 0x0501 WINVER
289
          ;;
290
        *)
291
          echo "Not supported windows platform"
292
          exit -1
293
          ;;
294
      esac
295
      ;;
189cfae by Petr Ovtchenkov at 2009-02-10 296
    '')
297
      ;;
59c9c2f by dums at 2008-04-21 298
    *)
299
      echo "Unknown configuration option '$option'"
300
      exit -1
301
      ;;
c092a6e by ptr at 2003-11-14 302
  esac
303
done
304
9c3a5ff by complement at 2008-06-07 305
if [ -n "${CXX}" ]; then
306
  if [ -n "${cxx_set}" ]; then
9ddd5ea by complement at 2007-11-23 307
    echo "Both --with-cxx and \$CXX set, using the first"
9c3a5ff by complement at 2008-06-07 308
  elif [ -z "${target_set}" ]; then
2c796b4 by Petr Ovtchenkov at 2009-01-09 309
    write_raw_option "${CXX}" _FORCE_CXX
9ddd5ea by complement at 2007-11-23 310
  else
311
    echo "For cross-compilation with gcc use --target option only"
312
  fi
9c3a5ff by complement at 2008-06-07 313
  if [ -z "${CC}" -a -z "${cc_set}" ]; then
9ddd5ea by complement at 2007-11-23 314
    echo "\$CXX set, but I don't see \$CC!"
315
  fi
316
fi
317
9c3a5ff by complement at 2008-06-07 318
if [ -n "${CC}" ]; then
319
  if [ -n "${cxx_set}" ]; then
9ddd5ea by complement at 2007-11-23 320
    echo "Both --with-cc and \$CC set, using the first"
321
  else
2c796b4 by Petr Ovtchenkov at 2009-01-09 322
    write_raw_option "${CC}" _FORCE_CC
9ddd5ea by complement at 2007-11-23 323
  fi
324
fi
325
9c3a5ff by complement at 2008-06-07 326
if [ -n "${CXXFLAGS}" ]; then
327
  if [ -z "${cxxflags_set}" ]; then
2c796b4 by Petr Ovtchenkov at 2009-01-09 328
    write_raw_option "${CXXFLAGS}" EXTRA_CXXFLAGS
9ddd5ea by complement at 2007-11-23 329
  else
330
    echo "Both --with-extra-cxxflags and \$CXXFLAGS set, using the first"
331
  fi
332
fi
333
9c3a5ff by complement at 2008-06-07 334
if [ -n "${CFLAGS}" ]; then
335
  if [ -z "${cflags_set}" ]; then
2c796b4 by Petr Ovtchenkov at 2009-01-09 336
    write_raw_option "${CFLAGS}" EXTRA_CFLAGS
4cf8f74 by complement at 2008-04-22 337
  else
338
    echo "Both --with-extra-cflags and \$CFLAGS set, using the first"
339
  fi
340
fi
341
9c3a5ff by complement at 2008-06-07 342
if [ -n "${LDFLAGS}" ]; then
343
  if [ -z "${ldflags_set}" ]; then
2c796b4 by Petr Ovtchenkov at 2009-01-09 344
    write_raw_option "${LDFLAGS}" EXTRA_LDFLAGS
29df3b0 by complement at 2008-06-06 345
  else
346
    echo "Both --with-extra-ldflags and \$LDFLAGS set, using the first"
347
  fi
348
fi
349
9ddd5ea by complement at 2007-11-23 350
default_settings