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