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