Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -o verbose
- set -o xtrace
- set -o errexit
- # Некоторая информация была почерпнута здесь http://www.hoxnox.com/2011/02/mingw-stlport-boost.html
- MARCH=corei7-avx
- #native corei7-avx corei7
- MTUNE=corei7-avx
- #corei7-avx generic
- ADDRESS_MODEL=64
- #32 64
- #for boost::
- THREADAPI=pthread
- #win32 pthread
- #required: -DBOOST_THREAD_POSIX -DBOOST_THREAD_USE_LIB -lpthreadGC2
- export MINGWDIR="/c/mingw"
- #export STLPORT_ROOT="D:/libs/STLport"
- #STDLIB="stdlib=stlport-5.2.1"
- PATH=/usr/bin:${MINGWDIR}/bin:/c/Windows/system32
- #${MINGWDIR}/x86_64-w64-mingw32/lib32
- SRC_DIR="${PWD}"
- BUILD_DIR="${SRC_DIR}/../build-boost"
- mkdir -p "${BUILD_DIR}"
- INSTALL_DIR="${SRC_DIR}/../boost"
- mkdir -p "${INSTALL_DIR}"
- function colored_echo () {
- echo -e "\e[1;31m${1}\e[0m"
- }
- colored_echo "build boost"
- PATCH_NAME="user-config.patch"
- function on_exit () {
- if test -e "${SRC_DIR}/${PATCH_NAME}"
- then
- colored_echo "revert patch"
- patch --strip=0 --reverse --forward --directory="${SRC_DIR}" --input "${PATCH_NAME}"
- rm -vf "${SRC_DIR}/${PATCH_NAME}"
- fi
- exit "$?"
- }
- trap on_exit ERR EXIT SIGINT SIGTERM
- colored_echo "create patch"
- cat - <<__EOF> "${PATCH_NAME}"
- diff C3 tools/build/v2/user-config.jam tools/build/v2/user-config.jam
- *** tools/build/v2/user-config.jam Fri Sep 21 11:33:22 2012
- --- tools/build/v2/user-config.jam Fri Sep 21 11:54:13 2012
- ***************
- *** 43,49 ****
- # Configure specific gcc version, giving alternative name to use.
- # using gcc : 3.2 : g++-3.2 ;
- !
- # -------------------
- # MSVC configuration.
- --- 43,49 ----
- # Configure specific gcc version, giving alternative name to use.
- # using gcc : 3.2 : g++-3.2 ;
- ! using gcc : : : ;
- # -------------------
- # MSVC configuration.
- ***************
- *** 72,78 ****
- # Configure specifying location of both headers and libraries explicitly.
- # using stlport : : /usr/include/stlport /usr/lib ;
- !
- # -----------------
- # QT configuration.
- --- 72,78 ----
- # Configure specifying location of both headers and libraries explicitly.
- # using stlport : : /usr/include/stlport /usr/lib ;
- ! #using stlport : 5.2.1 : D:/libs/STLport/stlport : D:/libs/STLport/lib ;
- # -----------------
- # QT configuration.
- __EOF
- colored_echo "apply patch"
- patch --strip=0 --forward --directory="${SRC_DIR}" --input "${PATCH_NAME}" || colored_echo "patching is not required"
- : '
- "${SRC_DIR}/b2.exe" --show-libraries
- chrono
- date_time
- exception
- filesystem
- graph
- graph_parallel
- iostreams
- locale
- math
- mpi
- program_options
- python
- random
- regex
- serialization
- signals
- system
- test
- thread
- timer
- wave
- Boost.Filesystem
- Boost.GraphParallel
- Boost.IOStreams
- Boost.MPI
- Boost.ProgramOptions
- Boost.Python (see the Boost.Python build documentation before building and installing it)
- Boost.Regex
- Boost.Serialization
- Boost.Signals
- Boost.System
- Boost.Thread
- Boost.Wave
- '
- LIBRARY_LIST=""
- #"--with-regex --with-test --with-filesystem --with-serialization --with-system --with-thread --with-filesystem"
- if test -z "${LIBRARY_LIST}"
- then
- echo "Will build following libraries: ALL"
- else
- echo -e "Will build following libraries:\n"`echo "${LIBRARY_LIST}" | sed -e "s/--with-//g"`
- fi
- LIBRARY_LIST=`echo "${LIBRARY_LIST}" | tr '\n' ' '`
- CXXSTATIC="-D_STLP_USE_STATIC_LIB=1"
- CXXDYNAMIC="-DBOOST_ALL_DYN_LINK=1 -D_STLP_USE_DYNAMIC_LIB=1 -fno-keep-inline-dllexport"
- #-fkeep-inline-functions for release/debug dyn wave
- if [[ ${ADDRESS_MODEL} -eq 32 ]]
- then
- PATH=${MINGWDIR}/x86_64-w64-mingw32/lib32:${PATH}
- LFLAGS_WIN32="-Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc"
- CFLAGS_WIN32=""
- BIT_CAPACIY="-m32"
- else
- PATH=${MINGWDIR}/i686-w64-mingw32/lib64:${PATH}
- LFLAGS_WIN32=""
- CFLAGS_WIN32=""
- BIT_CAPACIY="-m64"
- fi
- #C:\mingw\x86_64-w64-mingw32\lib32;C:\mingw\i686-w64-mingw32\lib64;
- export PATH
- if [[ "${THREADAPI}" = "win32" ]]
- then
- THREADS="-mthreads -DBOOST_THREAD_WIN32 -DBOOST_THREAD_USE_LIB"
- else
- THREADS="-pthread -DBOOST_THREAD_POSIX -DBOOST_THREAD_USE_LIB"
- fi
- GRAPHITE=
- #"-fgraphite-identity -floop-interchange -floop-block -floop-parallelize-all"
- #The flag -fomit-frame-pointer is enabled at -O1, -O2, -O3 and -Os on arches where it doesn't interfere with debugging, such as AMD64, but not x86. So if you're on x86 you should add it to your CFLAGS. Also don't use -momit-leaf-frame-pointer together with -fomit-frame-pointer. It's pointless as -fomit-frame-pointer already omits all frame pointers. In fact if you use both, -momit-leaf-frame-pointer overrides -fomit-frame-pointer creating less optimized code.
- # -mfpmath=both is experimental
- OPTFLAGS="\
- ${CFLAGS_WIN32} \
- ${GRAPHITE} \
- -fbranch-target-load-optimize2 \
- -fcx-limited-range -fforce-addr \
- -fgcse-las -fgcse-sm -fgcse-after-reload \
- -ftree-loop-im"
- #!!!!!!! http://comments.gmane.org/gmane.comp.gnu.mingw.w64.general/6317
- # my workaround: if you want to use "-mfpmath=both" (or, equivalently, "-mfpmath=sse+387") with "-std=gnu++11" option, then specify "-D__FLT_EVAL_METHOD__=2 -Wp,-w" option to g++ extra
- ARCH="${BIT_CAPACIY} -march=${MARCH}"
- # -mtune=${MTUNE}
- # echo "" | gcc -march=native -v -E - 2>&1 | grep cc1
- USE_RTTI=
- #"-frtti" # configure -rtti
- USE_LTO_CXX="-flto"
- USE_LTO_LINK=
- #"-flto"
- #"-flto -fuse-linker-plugin"
- #-flto=jobserver -fuse-linker-plugin
- #g++: error: -E or -x required when input is from standard input
- COMMON="-v -pipe ${ARCH} ${USE_RTTI} \
- -mtls-dialect=gnu2 \
- -fsignaling-nans -fno-math-errno \
- ${USE_LTO}"
- STLP_CXXOTHER=
- #"-D_REENTRANT=1 -D_STLP_NEW_PLATFORM_SDK=1 -D_STLP_USE_EXCEPTIONS"
- LISTING=""
- #"-Wa,-adhlns=\"\[email protected]\""
- X="-x c++ "
- #"-std=gnu++11 -D__FLT_EVAL_METHOD__=2 -Wp,-w"
- CXXOTHER="${COMMON} \
- ${STLP_CXXOTHER} \
- ${X} \
- ${LISTING} \
- ${USE_LTO_CXX}"
- if [[ "${LINKAGE}"x -ne ""x ]]
- then
- LINKAGE="-${LINKAGE}"
- fi
- LOTHER="${LINKAGE} ${COMMON} \
- ${LFLAGS_WIN32} \
- ${USE_LTO_LINK}"
- STLP_CXXDEBUG=
- #"-D_STLP_DEBUG=1 -D_DEBUG=1 -D_STLP_DEBUG_MODE_THROWS=1 -D_STLP_DEBUG_ALLOC=1 -D_STLP_DEBUG_UNINITIALIZED=1"
- CXXDEBUG="-Og -g -ggdb \
- ${STLP_CXXDEBUG}"
- LDEBUG="-Wl,-O0"
- CXXRELEASE=" \
- -O3 \
- ${OPTFLAGS}"
- LRELEASE="-Wl,-s \
- -Wl,-O3 \
- ${OPTFLAGS}"
- let "NUMBER_OF_PROCESSORS = ${NUMBER_OF_PROCESSORS} + 1"
- colored_echo "release static"
- "${SRC_DIR}/b2.exe" -j${NUMBER_OF_PROCESSORS} -a -d+2 \
- toolset=gcc \
- "${STDLIB}" \
- link=static \
- runtime-link=static \
- target-os=windows \
- threading=multi \
- threadapi="${THREADAPI}" \
- variant=release \
- cxxflags="${CXXRELEASE} ${CXXSTATIC} ${CXXOTHER}" \
- linkflags="${LOTHER} ${LRELEASE}" \
- --disable-icu \
- --without-python \
- --without-mpi \
- -sNO_BZIP2=1 -sNO_ZLIB=1 \
- address-model="${ADDRESS_MODEL}" \
- architecture=x86 \
- ${LIBRARY_LIST} \
- --layout=tagged \
- --build-dir="${BUILD_DIR}" \
- --stagedir=${INSTALL_DIR} \
- stage || colored_echo "Not all targets have been built"
- colored_echo "debug static"
- "${SRC_DIR}/b2.exe" -j${NUMBER_OF_PROCESSORS} -a -d+2 \
- toolset=gcc \
- "${STDLIB}" \
- link=static \
- runtime-link=static \
- target-os=windows \
- threading=multi \
- threadapi="${THREADAPI}" \
- variant=debug \
- cxxflags="${CXXDEBUG} ${CXXSTATIC} ${CXXOTHER}" \
- linkflags="${LOTHER} ${LDEBUG}" \
- --disable-icu \
- --without-python \
- --without-mpi \
- -sNO_BZIP2=1 -sNO_ZLIB=1 \
- address-model="${ADDRESS_MODEL}" \
- architecture=x86 \
- ${LIBRARY_LIST} \
- --layout=tagged \
- --build-dir="${BUILD_DIR}" \
- --stagedir=${INSTALL_DIR} \
- stage || colored_echo "Not all targets have been built"
- colored_echo "release dynamic"
- #cp --force "${STLPORT_ROOT}/lib/libstlport.5.2.dll.a" "${STLPORT_ROOT}/lib/libstlport_gcc.a"
- "${SRC_DIR}/b2.exe" -j${NUMBER_OF_PROCESSORS} -a -d+2 \
- toolset=gcc \
- "${STDLIB}" \
- link=shared \
- runtime-link=shared \
- target-os=windows \
- threading=multi \
- threadapi="${THREADAPI}" \
- variant=release \
- cxxflags="${CXXRELEASE} ${CXXDYNAMIC} ${CXXOTHER}" \
- linkflags="${LOTHER} ${LRELEASE}" \
- --disable-icu \
- --without-python \
- --without-mpi \
- -sNO_BZIP2=1 -sNO_ZLIB=1 \
- address-model="${ADDRESS_MODEL}" \
- architecture=x86 \
- ${LIBRARY_LIST} \
- --layout=tagged \
- --build-dir="${BUILD_DIR}" \
- --stagedir=${INSTALL_DIR} \
- stage || colored_echo "Not all targets have been built"
- colored_echo "debug dynamic"
- #cp --force "${STLPORT_ROOT}/lib/libstlportstlg.5.2.dll.a" "${STLPORT_ROOT}/lib/libstlport_gcc_stldebug.a"
- "${SRC_DIR}/b2.exe" -j${NUMBER_OF_PROCESSORS} -a -d+2 \
- toolset=gcc \
- "${STDLIB}" \
- link=shared \
- runtime-link=shared \
- target-os=windows \
- threading=multi \
- threadapi="${THREADAPI}" \
- variant=debug \
- cxxflags="${CXXDEBUG} ${CXXDYNAMIC} ${CXXOTHER}" \
- linkflags="${LOTHER} ${LDEBUG}" \
- --disable-icu \
- --without-python \
- --without-mpi \
- -sNO_BZIP2=1 -sNO_ZLIB=1 \
- address-model="${ADDRESS_MODEL}" \
- architecture=x86 \
- ${LIBRARY_LIST} \
- --layout=tagged \
- --build-dir="${BUILD_DIR}" \
- --stagedir=${INSTALL_DIR} \
- stage || colored_echo "Not all targets have been built"
- mkdir -p "${INSTALL_DIR}/include"
- cp -vf -R "${SRC_DIR}/boost" "${INSTALL_DIR}/include/"
- #mkdir -p "${INSTALL_DIR}/include/boost"
- #tar --create --verbose --directory="${SRC_DIR}/boost" --file - . | tar --extract --verbose --directory="${INSTALL_DIR}/include/boost" --file -
- mkdir -p "${INSTALL_DIR}/bin/"
- mv -vf "${INSTALL_DIR}/lib/"*".dll" "${INSTALL_DIR}/bin/"
- #mv -vf "${INSTALL_DIR}/lib/*.dll.a" "${INSTALL_DIR}/bin/"
- #mv -vf "${INSTALL_DIR}/lib/*.a" "${INSTALL_DIR}/bin/"
Advertisement
Add Comment
Please, Sign In to add comment