configure.ac 14.4 KB
Newer Older
O
oceanbase-admin 已提交
1
    AC_INIT([OceanBase],
W
Feature  
Wesley Wang 已提交
2 3
            [3.2.0],
            [wgs13579@gmail.com],
O
oceanbase-admin 已提交
4 5 6
            [obproxy],
            [http://oceanbase.taobao.org/])

W
Feature  
Wesley Wang 已提交
7
    obapi_version="3.2.0"
O
oceanbase-admin 已提交
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 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
    AC_SUBST(obapi_version)

    AC_DISABLE_STATIC
    AC_PROG_RANLIB
    AC_PROG_LIBTOOL
    AM_INIT_AUTOMAKE([subdir-objects silent-rules])
    ac_default_prefix=${HOME}/oceanbase_bin # for convenience
    AC_PROG_CXX
    AC_LANG([C++])
    AC_SUBST([host_cpu])
    AC_PROG_CC
    AC_CANONICAL_HOST

    dnl configure compiler flags
    AC_ARG_WITH([release],
    AS_HELP_STRING([--with-release],
    [use optimize (default is NO)]),
    [
    if test "$withval" = "yes"; then
      case "$host_cpu" in
        *aarch64* )
          AM_CXXFLAGS="-g -O2 -D_OB_VERSION=1000 -D_NO_EXCEPTION -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wextra -Wunused-parameter -Wformat -Wconversion -Wno-deprecated -Wno-invalid-offsetof -finline-functions -fno-strict-aliasing -mtune=generic -Wno-psabi -Wno-sign-compare"
          AM_CFLAGS="-g -O2 -D_OB_VERSION=1000 -DCOMPATIBLE -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNDEBUG -finline-functions -fno-strict-aliasing -Wall -mtune=generic -Wno-psabi -Wno-sign-compare"
        ;;
        * )
          AM_CXXFLAGS="-g -O2 -D_OB_VERSION=1000 -D_NO_EXCEPTION -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wextra -Wunused-parameter -Wformat -Wconversion -Wno-deprecated -Wno-invalid-offsetof -finline-functions -fno-strict-aliasing -mtune=core2 -Wno-psabi -Wno-sign-compare"
          AM_CFLAGS="-g -O2 -D_OB_VERSION=1000 -DCOMPATIBLE -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNDEBUG -finline-functions -fno-strict-aliasing -Wall -mtune=core2 -Wno-psabi -Wno-sign-compare"
        ;;
      esac
    fi
    ],
    [ AM_CXXFLAGS="-D__STDC_LIMIT_MACROS -D_OB_VERSION=1000 -D__STDC_CONSTANT_MACROS -D_NO_EXCEPTION -g -Wall -Wextra -Wunused-parameter -Wformat -Wconversion -Wno-invalid-offsetof -Wno-deprecated -fno-strict-aliasing -fno-omit-frame-pointer -mtune=generic -Wno-psabi  -Wno-sign-compare"
      AM_CFLAGS="-D_OB_VERSION=1000 -DCOMPATIBLE -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-omit-frame-pointer -g -Wall -Wno-psabi  -Wno-sign-compare"
        ]
    )

    #check gcc version, add -Wno-ignored-qualifiers flag for gcc version greater than 4.3.0
    GCC_VERSION=`$CC -dumpversion`
    if test $? -eq 0; then
        major=`echo $GCC_VERSION | cut -d. -f1`
        minor=`echo $GCC_VERSION | cut -d. -f2`
    fi
    if test $major -eq 4 -a $minor -ge 3 ; then
        AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-ignored-qualifiers"
    else test $major -eq 5 -a $minor -eq 2;
        AM_CXXFLAGS="${AM_CXXFLAGS} -DGCC_52"
    fi

    gcc_version="4.4.4"
    dnl condition OPT_GCC_VERSION
    AC_ARG_WITH([gcc-version],
        AS_HELP_STRING([--with-gcc-version],
                       [opt gcc version (default is 4.4.4)]),
                       [
                           if test ! -z $withval; then
                               gcc_version=$withval
                           fi
                       ],
                       [gcc_version="4.4.4"])

    if test "X$gcc_version" !=  "X$GCC_VERSION"; then
      echo "you choice gcc: ${gcc_version}, but now gcc is: $GCC_VERSION"
      exit 127
    fi

    OSVER=`cat /etc/issue|head -1|awk -F. '{print $1}' | awk '{print $NF}'`
    if test $OSVER -le 6; then
        AM_CXXFLAGS="${AM_CXXFLAGS} -DUSE_POSIX_FALLOCATE"
    fi

    support_sse4_2=`cat /proc/cpuinfo|grep flags|head -1|grep -oE sse4_2`
    if test "$support_sse4_2" = "sse4_2" ; then
        AM_CXXFLAGS="${AM_CXXFLAGS} -DSUPPORT_SSE4_2"
    fi

    AC_ARG_WITH([atomic-time],
        AS_HELP_STRING([--with-atomic-time],
                       [record atomic instructions time (default is NO)]),
        [
            if test "$withval" == "yes"; then
                AM_CXXFLAGS="${AM_CXXFLAGS} -DATOMIC_TIME_PERF"
            fi
        ],
        [])
    AC_ARG_WITH([memory-check],
        AS_HELP_STRING([--with-memory-check],
                       [memory check (defualt is NO)]),
        [
            if test "$withval" = "yes"; then
                AM_CXXFLAGS="${AM_CXXFLAGS} -DMEMCHK_LEVEL=1"
            fi
        ],
        [])

    AC_ARG_WITH([perf],
           AS_HELP_STRING([--with-perf],
                          [with perf (default is NO)]),
                          [
                            if test "$withval" = "yes"; then
                                test_perf=yes
                                AM_CXXFLAGS="${AM_CXXFLAGS} -D__NEED_PERF__"
                                AM_LDFLAGS="${AM_LDFLAGS} -lprofiler"
                            fi
                          ],
                          [with_perf=no]
           )

    AC_ARG_WITH([5u-support],
           AS_HELP_STRING([--with-5u-support],
                          [with 5u support (default is NO)]),
                          [
                            if test "$withval" = "yes"; then
                                support5u=yes
                            fi
                          ],
                          [support5u=no]
           )
    if test $support5u = "no"
    then
      AM_CXXFLAGS="${AM_CXXFLAGS} -DHAVE_SCHED_GETCPU -DHAVE_REALTIME_COARSE -DOB_HAVE_EVENTFD -DHAVE_FALLOCATE"
    fi
    AM_CONDITIONAL([SUPPORT5U], test x$support5u = xno )

    AC_ARG_WITH([preload],
           AS_HELP_STRING([--with-preload],
                          [with preload (default is NO)]),
                          [
                            if test "$withval" = "yes"; then
                                with_preload=yes
                                AM_CXXFLAGS="${AM_CXXFLAGS} -D__ENABLE_PRELOAD__"
                            fi
                          ],
                          [
                          with_preload=no
                          ]
           )
    AC_ARG_WITH([mem-trace],
           AS_HELP_STRING([--with-mem-trace],
                          [with memory trace (default is NO)]),
                          [
                            if test "$withval" = "yes"; then
                                memtrace=yes
                            fi
                          ],
                          [memtrace=no]
           )
    if test $memtrace = "yes"
    then
        AM_CXXFLAGS="${AM_CXXFLAGS}  -D__OB_MTRACE__ -rdynamic"
    fi
    AM_CONDITIONAL([MEMTRACE], test x$memtrace = xyes )

    AC_ARG_WITH([mem-debug],
           AS_HELP_STRING([--with-mem-debug],
                          [with memory debug features (default is NO)]),
                          [
                            if test "$withval" = "yes"; then
                                memdebug=yes
                            fi
                          ],
                          [memdebug=no]
           )
    if test $memdebug = "yes"
    then
        AM_CXXFLAGS="${AM_CXXFLAGS}  -D__OB_MDEBUG__"
    fi
    AM_CONDITIONAL([MEMDEBUG], test x$memdebug = xyes )

    AM_LDFLAGS="${AM_LDFLAGS} -L${DEP_DIR}/lib -L${DEP_DIR}/lib/mysql"

    dnl global default INCLUDES
    AM_CPPFLAGS="${AM_CPPFLAGS} -I${DEP_DIR}/include -I${DEP_DIR}/include/mysql"

    if test "X${CXXFLAGS}" = "X-g -O2"; then
        CXXFLAGS=""
    fi
    if test "X${CFLAGS}" = "X-g -O2"; then
        CFLAGS=""
    fi

    dnl condition COVERAGE
    AC_ARG_WITH([coverage],
           AS_HELP_STRING([--with-coverage],
                          [with coverage (default is NO)]),
                          [case "${withval}" in
			   yes) coverage=true ;;
		           no)  coverage=false ;;
		           *) AC_MSG_ERROR([bad value ${withval} for --with-coverage]) ;;
		           esac
                          ],
                          [coverage=false]
           )
    AM_CONDITIONAL([COVERAGE], test x$coverage = xtrue )
    if test "X$coverage" = X"true"; then
        AM_CXXFLAGS="${AM_CXXFLAGS} -fprofile-arcs -ftest-coverage -DTEST_COVER"
        AM_CFLAGS="${AM_CFLAGS} -fprofile-arcs -ftest-coverage -DTEST_COVER"
        AM_LDFLAGS="${AM_LDFLAGS} -lgcov"
    fi

    dnl define global flags
    AC_SUBST([AM_CPPFLAGS])
    AC_SUBST([AM_LDFLAGS])
    AC_SUBST([AM_CXXFLAGS])
    AC_SUBST([AM_CFLAGS])
    AC_SUBST([AM_CXXFLAGS_WITH_ARCH])
    AC_SUBST([AM_CFLAGS_WITH_ARCH])

    dnl condition WITH_TEST_CASE
    AC_ARG_WITH([test_case],
           AS_HELP_STRING([--with-test-case],
                          [with test case (default is YES)]),
                          [
                            if test "$withval" = "no"; then
                                test_case=no
                            fi
                          ],
                          [ test_case=yes ]
           )
    AM_CONDITIONAL([WITH_TEST_CASE], test x$test_case = xyes )

    AC_ARG_WITH([simplify_verification],
           AS_HELP_STRING([--with-simplify-verification],
                          [with simplify verification (default is NO)]),
                          [
                            if test "$withval" = "yes"; then
                                AC_DEFINE(SIMPLIFY_VERIFICATION)
                            fi
                          ],
                          [ echo "simplify-verification is no" ]
           )

    dnl strip_ut
    AC_ARG_ENABLE([strip_ut],
    AS_HELP_STRING([--enable-strip-ut], [strip unit test binaries. (default is NO)]),
    [case "${enableval}" in
      yes) strip_ut=true ;;
      no)  strip_ut=false ;;
      *) AC_MSG_ERROR([bad value ${enableval} for --enable-strip-ut]) ;;
    esac],
    [strip_ut=false])
    AM_CONDITIONAL([STRIP_UT], [test x$strip_ut = xtrue])

    dnl dlink_observer
    AC_ARG_ENABLE([dlink_observer],
    AS_HELP_STRING([--enable-dlink-observer], [unit test dynamic link observer. (default is NO)]),
    [case "${enableval}" in
      yes) dlink_observer=true ;;
      no)  dlink_observer=false ;;
      *) AC_MSG_ERROR([bad value ${enableval} for --enable-dlink-observer]) ;;
    esac],
    [dlink_observer=false])
    AM_CONDITIONAL([DLINK_OBSERVER], [test x$dlink_observer = xtrue])

    dnl build_version.mk related:
    dnl see whether git is installed
    AC_PATH_PROG(svnversioncommand, git)
    AC_ARG_WITH([svnfile],
           AS_HELP_STRING([--with-svnfile],
                          [use svnfile svn_dist_version instead of running git (default is NO)]),
                          [
                            if test "$withval" = "yes"; then
                                use_svnfile=yes
                            fi
                          ],
                          [use_svnfile=no]
           )
    dnl use git to record the current repository revision only if
    dnl git is installed and we are in a working copy
    if test "X$use_svnfile" = "Xyes"; then
        revision="cat \$(top_srcdir)/svn_dist_version"
        build_num="$($revision)"
        AM_CONDITIONAL([HAVESVNWC], false)
    elif test "X$svnversioncommand" = "X"; then
        revision="-"
        build_num="$($revision)"
        AM_CONDITIONAL([HAVESVNWC], true)
    elif test "X$AONE_BUILD_NUMBER" != "X"; then
        build_num="$AONE_BUILD_NUMBER"
        revision="(cd \$(top_srcdir) && echo $AONE_BUILD_NUMBER-$(git rev-parse HEAD))"
        AM_CONDITIONAL([HAVESVNWC], true)
    else
        build_num="$(git rev-list --all | wc -l)"
        revision="(cd \$(top_srcdir) && echo $build_num-local-$(git rev-parse HEAD))"
        AM_CONDITIONAL([HAVESVNWC], true)
    fi
    dnl substitute revision in build_version.mk
    AC_SUBST(revision)

    dnl define RELEASEID
    AC_ARG_VAR([RELEASEID], [release number when building in Taobao ABS])
    if test "X$RELEASEID" = "X"; then
      RELEASEID="$build_num.el$(cat /etc/redhat-release | cut -d " " -f 7 | cut -d "." -f 1)"
    fi
    AC_DEFINE_UNQUOTED([RELEASEID], "$RELEASEID")

    dnl LDADD
    AM_LDFLAGS="${AM_LDFLAGS} -Wl,--allow-multiple-definition"
    BIN_LDFLAGS="-lc -lrt"

    if test "X5.2.0" = "X$GCC_VERSION"; then
        AM_LDFLAGS="${AM_LDFLAGS} -static-libstdc++ -static-libgcc"
        BIN_LDFLAGS="${BIN_LDFLAGS} ${TOOLS_DIR}/lib64/libstdc++.a"
        postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
    fi

    AC_SUBST(BIN_LDFLAGS)

    dnl with-buildtime
    AC_ARG_ENABLE([buildtime],
    AS_HELP_STRING([--enable-buildtime], [auto-update build_time, build_version etc. (default is YES)]),
    [case "${enableval}" in
      yes) buildtime=true ;;
      no)  buildtime=false ;;
      *) AC_MSG_ERROR([bad value ${enableval} for --enable-buildtime]) ;;
    esac],
    [buildtime=true])
    AM_CONDITIONAL([UPDATE_BUILDTIME], [test x$buildtime = xtrue])

    dnl condition WITH_MYSQLTEST
    AC_ARG_WITH([mysqltest],
        AS_HELP_STRING([--with-mysqltest],
                [whether to build mysqltest (default is NO)]),
                 [],
                 [with_mysqltest="no"])
    AM_CONDITIONAL([WITH_MYSQLTEST], test x$with_mysqltest = xyes)

    dnl condition 7U_SUPPORT
    AC_ARG_WITH([7u-support],
        AS_HELP_STRING([--with-7u-support],
                       [with 7u support (default is NO)]),
                       [
                           if test "$withval" == "yes"; then
                               BIN_LDFLAGS="-lc -lrt -pthread ${TOOLS_DIR}/lib64/libstdc++.a"
                           fi
                       ],
                       [])


    AC_CONFIG_FILES([\
                     Makefile \
                     src/Makefile \
                     unittest/Makefile \
                     unittest/obproxy/Makefile
    ])

    AM_CXXFLAGS_WITH_ARCH="${AM_CXXFLAGS}"
    AM_CFLAGS_WITH_ARCH="${AM_CFLAGS}"
    if test $OSVER -gt 6; then
      AM_CXXFLAGS_WITH_ARCH="${AM_CXXFLAGS_WITH_ARCH} -Werror"
      AM_CFLAGS_WITH_ARCH="${AM_CFLAGS_WITH_ARCH} -Werror"
    fi
    AM_CXXFLAGS="${AM_CXXFLAGS} -Werror"
    AM_CFLAGS="${AM_CFLAGS} -Werror"

    AC_OUTPUT

    dnl print global flags
    AC_MSG_RESULT([Global Compile Flags:])
    AC_MSG_RESULT([DEP_DIR=${DEP_DIR}])
    AC_MSG_RESULT([TOOLS_DIR=${TOOLS_DIR}])
    AC_MSG_RESULT([RUNTIME_DIR=${RUNTIME_DIR}])
    AC_MSG_RESULT([AM_CPPFLAGS=${AM_CPPFLAGS}])
    AC_MSG_RESULT([AM_LDFLAGS=${AM_LDFLAGS}])
    AC_MSG_RESULT([AM_CXXFLAGS=${AM_CXXFLAGS}])
    AC_MSG_RESULT([AM_CFLAGS=${AM_CFLAGS}])
    AC_MSG_RESULT([AM_CXXFLAGS_WITH_ARCH=${AM_CXXFLAGS_WITH_ARCH}])
    AC_MSG_RESULT([AM_CFLAGS_WITH_ARCH=${AM_CFLAGS_WITH_ARCH}])
    AC_MSG_RESULT([BIN_LDFLAGS=${BIN_LDFLAGS}])