~pbxt-core/pbxt/rc4

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
AC_INIT(src/ha_pbxt.cc)
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
# ----- Version number must also be set in src/strutil_xt.cc! */
AM_INIT_AUTOMAKE(pbxt, 1.0.10-rc)

AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --preserve-dup-deps"
AC_SUBST(LIBTOOL)dnl

sinclude(config/ac_mysql.m4)

MYSQL_SRC_TEST
get_variable_value()
{
  pbxt_mysql_op=`awk "
  BEGIN {
    want_var=\"$1\";
    len=length(want_var);
  }
  /^$1 = / {
    result = substr(\\$0, len+4);
  }
  END { print result; }"\
  $ENG_MYSQL_SRC/Makefile`
}
MYSQL_SRC_CONFIG

# ----- AC_SUBST(ENG_MYSQL_INC)
AC_SUBST(ENG_MYSQL_INC)

SYSTEM_TYPE="$host_vendor-$host_os"

# ----- Build type
MAX_C_OPTIMIZE="-O3"
MAX_CXX_OPTIMIZE="-O3"

# Build optimized or debug version ?
# First check for gcc and g++
if test "$ac_cv_prog_gcc" = "yes"
then
  DEBUG_CFLAGS="-g"
  OPTIMIZE_CFLAGS="$MAX_C_OPTIMIZE"
  PROFILE_CFLAGS="$MAX_C_OPTIMIZE -pg"
else
  DEBUG_CFLAGS="-g"
  OPTIMIZE_CFLAGS="-O"
  PROFILE_CFLAGS="-O -pg"
fi
if test "$ac_cv_prog_cxx_g" = "yes"
then
  DEBUG_CXXFLAGS="-g"
  OPTIMIZE_CXXFLAGS="$MAX_CXX_OPTIMIZE"
  PROFILE_CXXFLAGS="$MAX_CXX_OPTIMIZE -pg"
else
  DEBUG_CXXFLAGS="-g"
  OPTIMIZE_CXXFLAGS="-O"
  PROFILE_CXXFLAGS="-O -pg"
fi

if expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null; then
  DEBUG_CFLAGS="-g -sym internal,codeview4"
  DEBUG_CXXFLAGS="-g -sym internal,codeview4"
  OPTIMIZE_CFLAGS="-O3"
  OPTIMIZE_CXXFLAGS="-O3"
fi

strip_mysql_opt_dbg_flags()
{
  MYSQL_CFLAGS=`echo "$MYSQL_CFLAGS" | sed "s/-Os//" | sed "s/-O3//" | sed "s/-O2//" | sed "s/-O//" | sed "s/-g[[A-Za-z0-9]]*//g"`
  MYSQL_CXXFLAGS=`echo "$MYSQL_CXXFLAGS" | sed "s/-Os//" | sed "s/-O3//" | sed "s/-O2//" | sed "s/-O//" | sed "s/-g[[A-Za-z0-9]]*//g"`
}

# ----- AC_ARG_WITH(debug
AC_ARG_WITH(debug,
    [  --with-debug            include debug symbols and code (yes/no/prof), the
                          default depends on --with-debug used to build MySQL],
    [with_debug=$withval],
    [with_debug="undefined"])
if test "$with_debug" = "yes"
then
  # Medium debug, debug symbols without optimization (no assertions).
  strip_mysql_opt_dbg_flags
  CFLAGS="$DEBUG_CFLAGS -DNDEBUG $MYSQL_CFLAGS"
  CXXFLAGS="$DEBUG_CXXFLAGS -DNDEBUG $MYSQL_CXXFLAGS"
elif test "$with_debug" = "full"
then
  # Full debug. Very slow in some cases
  strip_mysql_opt_dbg_flags
  CFLAGS="$DEBUG_CFLAGS -DDEBUG $MYSQL_CFLAGS"
  CXXFLAGS="$DEBUG_CXXFLAGS -DDEBUG $MYSQL_CXXFLAGS"
elif test "$with_debug" = "only"
then
  # Only add debug symbols (use mysql optimizations)
  CFLAGS="$DEBUG_CFLAGS -DNDEBUG $MYSQL_CFLAGS"
  CXXFLAGS="$DEBUG_CXXFLAGS -DNDEBUG $MYSQL_CXXFLAGS"
elif test "$with_debug" = "prof"
then
  # Profile version. No debug
  strip_mysql_opt_dbg_flags
  CFLAGS="$PROFILE_CFLAGS -DNDEBUG $MYSQL_CFLAGS"
  CXXFLAGS="$PROFILE_CXXFLAGS -DNDEBUG $MYSQL_CXXFLAGS"
elif test "$with_debug" = "no"
then
  # Optimized version. No debug
  strip_mysql_opt_dbg_flags
  CFLAGS="$OPTIMIZE_CFLAGS -DNDEBUG $MYSQL_CFLAGS"
  CXXFLAGS="$OPTIMIZE_CXXFLAGS -DNDEBUG $MYSQL_CXXFLAGS"
else
  # Use the MySQL settings (but add the XT debug flag)
  if test "$MYSQL_DEBUG_LEVEL" = "full"
  then
    CFLAGS="$MYSQL_CFLAGS -DDEBUG"
    CXXFLAGS="$MYSQL_CXXFLAGS -DDEBUG"
  else
    CFLAGS="$MYSQL_CFLAGS -DNDEBUG"
    CXXFLAGS="$MYSQL_CXXFLAGS -DNDEBUG"
  fi
fi

AC_ARG_WITH(plugindir,
  [[  --with-plugindir[=DIR]  directory to install the engine, the default
                          depends on the MySQL libdir setting]],
  [ENG_PLUGIN_DIR="$withval"],
  [ENG_PLUGIN_DIR=""])
if test "$ENG_PLUGIN_DIR" = "no" -o "$ENG_PLUGIN_DIR" = ""
then
	# For backward compatibility:
	# if libdir ends with plugin, then assume
	# the plugin dir was specified using --libdir
	tmp_libdir=`echo "$libdir" | grep "plugin$"`
	if test "$libdir" = "$tmp_libdir"
	then
	    ENG_PLUGIN_DIR="$libdir"
	else
	    ENG_PLUGIN_DIR="$libdir/mysql/plugin"
    fi
fi
AC_SUBST(ENG_PLUGIN_DIR)
AC_SUBST(ENG_MYSQL_SRC)

echo "$ENG_MYSQL_SRC" > mysql-src-root

AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_HEADERS(limits.h syslimits.h)
AC_OUTPUT(Makefile src/Makefile test/Makefile bin/Makefile)