aboutsummaryrefslogtreecommitdiff
path: root/configure
blob: 2f485113ace53ed5d8bec77836949bf0563cc97a (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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#!/bin/sh

# Time-stamp: <08/06/07 15:22:19 yeti>

base=`cd \`dirname $0\`; echo $PWD`

configmak=$base/build/Makefiles/gmake/config.mak

write_option() {
  target=`echo $1 | sed -e 's/^[^=]*=//'`
  echo $2 := $3$target >> ${configmak}
}

write_over_option() {
  target=`echo $1 | sed -e 's/^[^=]*=//'`
  echo $2 ?= $target >> ${configmak}
}

print_help() {
  cat <<EOF
Configuration utility.

Usage:

  configure [options]

Available options:

  --prefix=<dir>        base install path (/usr/local/)
  --bindir=<dir>        install path for executables (PREFIX/bin)
  --libdir=<dir>        install path for libraries (PREFIX/lib)
  --includedir=<dir>    install path for headers (PREFIX/include)

  --target=<target>     target platform (cross-compiling)

  --help                print this help message and exit

  --with-stlport=<dir>  use STLport in catalog <dir>
  --without-stlport     compile without STLport
  --with-boost=<dir>    use boost headers in catalog <dir>
  --with-system-boost   use boost installed on this system
  --with-msvc=<dir>     use MS VC from this catalog
  --with-mssdk=<dir>    use MS SDK from this catalog
  --with-extra-cxxflags=<options>
                        pass extra options to C++ compiler
  --with-extra-cflags=<options>
                        pass extra options to C compiler
  --with-extra-ldflags=<options>
                        pass extra options to linker (via C/C++)
  --use-static-gcc      use static gcc libs instead of shared libgcc_s (useful for gcc compiler,
                        that was builded with --enable-shared [default]; if compiler was builded
                        with --disable-shared, static libraries will be used in any case)
  --clean               remove custom settings (file ${configmak})
                        and use default values
  --with-cxx=<name>     use <name> as C++ compiler (use --target= for cross-compilation)
  --with-cc=<name>      use <name> as C compiler (use --target= for cross-compilation)
  --use-compiler-family=<name> use compiler family; one of:
                        gcc      GNU compilers (default)
                        icc      Intel compilers
                        aCC      HP's aCC compilers
                        CC       SunPro's CC compilers
                        bcc      Borland's compilers
  --without-debug       don't build debug variant
  --without-stldebug    don't build STLport's STLP_DEBUG mode
  --enable-static       build static
  --disable-shared      don't build shared 
  --with-lib-motif=<motif>
                        Use this option to customize the generated library name.
                        The motif will be used in the last place before version information,
                        separated by an underscore, ex:
                        stlportd_MOTIF.5.0.lib
                        stlportstld_static_MOTIF.5.1.lib
  --without-thread      Per default STLport libraries are built in order to be usable
                        in a multithreaded context. If you don't need this you can ask
                        for a not thread safe version with this option.
  --without-rtti        Disable RTTI when building libraries.
  --with-static-rtl
  --with-dynamic-rtl
                        Enables usage of static (libc.lib family) or dynamic (msvcrt.lib family)
                        C/C++ runtime library when linking with STLport. If you want your appli/dll
                        to link statically with STLport but using the dynamic C runtime use
                        --with-dynamic-rtl; if you want to link dynamicaly with STLport but using the
                        static C runtime use --with-static-rtl. See README.options for details.
                        Don't forget to signal the link method when building your appli or dll, in
                        stlport/stl/config/host.h set the following macro depending on the configure
                        option:
                        --with-static-rtl  -> _STLP_USE_DYNAMIC_LIB"
                        --with-dynamic-rtl -> _STLP_USE_STATIC_LIB"
  --windows-platform=<name>
                        Targetted OS when building for Windows; one of:
                        win95   Windows 95
                        win98   Windows 98
                        winxp   Windows XP and later (default)

Environment variables:

  \$CXX                 C++ compiler name (use --target= for cross-compilation)
  \$CC                  C compiler name (use --target= for cross-compilation)
  \$CXXFLAGS            pass extra options to C++ compiler
  \$CFLAGS              pass extra options to C compiler
  \$LDFLAGS             pass extra options to linker (via C/C++)

  Options has preference over environment variables.

EOF
}

default_settings () {
  # if [ "$boost_set" = "" ]; then
  #   write_option "${PWD}/external/boost" BOOST_DIR
  # fi

  # if [ -z "${stlport_set}" ]; then
  #   write_over_option "$base" STLPORT_DIR
  # fi

  # Set in Makefiles/gmake/top.mak
  if [ -z "${compiler_family_set}" ]; then
  #  write_option gcc COMPILER_NAME
    echo include gcc.mak > ${base}/build/lib/Makefile
    echo include gcc.mak > ${base}/build/test/unit/Makefile
    echo include gcc.mak > ${base}/build/test/eh/Makefile
  fi

  # Set in Makefiles/gmake/targetdirs.mak
  # if [ -z "${prefix_set}" ]; then
  #   write_option "/usr/local" BASE_INSTALL_DIR '${DESTDIR}'
  # fi
}

[ $# -eq 0 ] && { >${configmak}; default_settings; exit 0; }

for a in $@ ; do
  case $a in
    --help)
      print_help
      exit 0
      ;;
    --clean)
      rm -f ${configmak}
      exit 0
      ;;
  esac
done

>${configmak}

while :
do
  case $# in
    0)
      break
      ;;
  esac
  option="$1"
  shift
  case $option in
    --target=*)
      write_option "$option" TARGET_OS
      target_set=y
      ;;
    --with-stlport=*)
      write_option "$option" STLPORT_DIR
      stlport_set=y
      ;;
    --without-stlport)
      write_option 1 WITHOUT_STLPORT
      stlport_set=y
      ;;
    --with-boost=*)
      write_option "$option" BOOST_DIR
      ;;
    --with-system-boost)
      write_option 1 USE_SYSTEM_BOOST
      ;;
    --with-msvc=*)
      write_option "$option" MSVC_DIR
      ;;
    --with-mssdk=*)
      write_option "$option" MSSDK_DIR
      ;;
    --with-extra-cxxflags=*)
      write_option "$option" EXTRA_CXXFLAGS
      cxxflags_set=y
      ;;
    --with-extra-cflags=*)
      write_option "$option" EXTRA_CFLAGS
      cflags_set=y
      ;;
    --with-extra-ldflags=*)
      write_option "$option" EXTRA_LDFLAGS
      ldflags_set=y
      ;;
    --with-lib-motif=*)
      echo "Using $option in generated library names"
      write_option "$option" LIB_MOTIF
      ;;
    --without-thread)
      write_option 1 WITHOUT_THREAD
      ;;
    --without-rtti)
      write_option 1 WITHOUT_RTTI
      ;;
    --with-dynamic-rtl)
      write_option 1 WITH_DYNAMIC_RTL
      ;;
    --with-static-rtl)
      write_option 1 WITH_STATIC_RTL
      ;;
    --use-static-gcc)
      write_option 1 USE_STATIC_LIBGCC
      ;;
    --without-debug)
      write_option 1 _NO_DBG_BUILD
      ;;
    --without-stldebug)
      write_option 1 _NO_STLDBG_BUILD
      ;;
    --enable-static)
      write_option 1 _STATIC_BUILD
      ;;
    --disable-shared)
      write_option 1 _NO_SHARED_BUILD
      ;;
    --with-cxx=*)
      write_option "$option" _FORCE_CXX
      cxx_set=y
      ;;
    --with-cc=*)
      write_option "$option" _FORCE_CC
      cc_set=y
      ;;
    --use-compiler-family=*)
      case `echo $option | sed -e 's/^[^=]*=//'` in
        gcc|icc|aCC|CC|bcc|dmc)
          target=`echo $option | sed -e 's/^[^=]*=//'`
          echo COMPILER_NAME := $target >> ${configmak}
          echo include $target.mak > ${base}/build/lib/Makefile
          echo include $target.mak > ${base}/build/test/unit/Makefile
          echo include $target.mak > ${base}/build/test/eh/Makefile
          ;;
        *)
          echo "Not supported compilers family"
          exit -1
          ;;
      esac
      compiler_family_set=y
      ;;
    --prefix=*)
      write_option "$option" BASE_INSTALL_DIR '${DESTDIR}'
      prefix_set=y
      ;;
    --bindir=*)
      write_option "$option" INSTALL_BIN_DIR '${DESTDIR}'
      ;;
    --libdir=*)
      write_option "$option" INSTALL_LIB_DIR '${DESTDIR}'
      ;;
    --includedir=*)
      write_option "$option" INSTALL_HDR_DIR '${DESTDIR}'
      ;;
    --windows-platform=*)
      case `echo $option | sed -e 's/^[^=]*=//'` in
        win95)
          write_option 0x0400 WINVER
          ;;
        win98)
          write_option 0x0410 WINVER
          ;;
        winxp)
          write_option 0x0501 WINVER
          ;;
        *)
          echo "Not supported windows platform"
          exit -1
          ;;
      esac
      ;;
    *)
      echo "Unknown configuration option '$option'"
      exit -1
      ;;
  esac
done

if [ -n "${CXX}" ]; then
  if [ -n "${cxx_set}" ]; then
    echo "Both --with-cxx and \$CXX set, using the first"
  elif [ -z "${target_set}" ]; then
    write_option "${CXX}" _FORCE_CXX
  else
    echo "For cross-compilation with gcc use --target option only"
  fi
  if [ -z "${CC}" -a -z "${cc_set}" ]; then
    echo "\$CXX set, but I don't see \$CC!"
  fi
fi

if [ -n "${CC}" ]; then
  if [ -n "${cxx_set}" ]; then
    echo "Both --with-cc and \$CC set, using the first"
  else
    write_option "${CC}" _FORCE_CC
  fi
fi

if [ -n "${CXXFLAGS}" ]; then
  if [ -z "${cxxflags_set}" ]; then
    write_option "${CXXFLAGS}" EXTRA_CXXFLAGS
  else
    echo "Both --with-extra-cxxflags and \$CXXFLAGS set, using the first"
  fi
fi

if [ -n "${CFLAGS}" ]; then
  if [ -z "${cflags_set}" ]; then
    write_option "${CFLAGS}" EXTRA_CFLAGS
  else
    echo "Both --with-extra-cflags and \$CFLAGS set, using the first"
  fi
fi

if [ -n "${LDFLAGS}" ]; then
  if [ -z "${ldflags_set}" ]; then
    write_option "${LDFLAGS}" EXTRA_LDFLAGS
  else
    echo "Both --with-extra-ldflags and \$LDFLAGS set, using the first"
  fi
fi

# default settings

default_settings