summaryrefslogtreecommitdiff
path: root/mysql-client/mysql/buildfile
blob: 654758d38fb50f97a9978016a3d4d8e8200ae4a3 (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
# file      : mysql/buildfile
# license   : GPLv2 with Universal FOSS Exception; see accompanying LICENSE file

tclass = $c.target.class

windows = ($tclass == 'windows')

# Note that the mysql utility source code directly refers to the
# libmysqlclient's implementations details quite a lot. Thus, we just use the
# libmysqlclient static library in combination with the private headers. Also
# note that the upstream's mysql utility doesn't link the shared
# libmysqlclient either.
#
import libs = libmysqlclient%liba{mysqlclient}

# Note that the mysql utility doesn't use openssl directly. We however import
# libcrypto so that the included by some common headers <openssl/opensslv.h>
# can be found.
#
import libs += libcrypto%lib{crypto}

if! $windows
  import libs += libisocline%liba{isocline}

# Note that some of the include/**.h files are C++ headers and some are C
# headers. We will assume all of them as C headers, which is a bit of a hack
# but doing it properly is too painful.
#
exe{mysql}:     {h c        }{*           } \
         client/{    hxx cxx}{*           } \
     downstream/{h c        }{*  -readline} \
        include/{h          }{**          } \
libbinlogevents/{h          }{**          }

exe{mysql}: downstream/{h c}{readline}: include = (!$windows)

exe{mysql}: $libs

# Build options.
#
# We have dropped the macro definitions that are not used in the package code:
#
#   -DRAPIDJSON_NO_SIZETYPEDEFINE
#   -DUNISTR_FROM_CHAR_EXPLICIT=explicit
#   -DUNISTR_FROM_STRING_EXPLICIT=explicit
#   -DHAVE_LIBEVENT2
#   -DNO_FSEEKO
#
cc.poptions += -DHAVE_CONFIG_H        \
               -DHAVE_OPENSSL         \
               -D__STDC_LIMIT_MACROS  \
               -D__STDC_FORMAT_MACROS \
               -D_USE_MATH_DEFINES    \
               -DDBUG_OFF

switch $tclass
{
  case 'windows'
    cc.poptions += -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -DNOGDI \
                   -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_MBCS

  case 'linux'
    cc.poptions += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE

  default
    cc.poptions += -D_FILE_OFFSET_BITS=64
}

# Note that we add "-I$src_root" for the headers auto-generating machinery to
# work properly.
#
cc.poptions =+ "-I$out_root" "-I$src_root"          \
               "-I$src_base/downstream"             \
               "-I$src_base/include"                \
               "-I$src_base/libbinlogevents/export" \
               "-I$src_base"

switch $c.class
{
  case 'gcc'
  {
    cc.coptions += -ffunction-sections -fdata-sections -fno-omit-frame-pointer
  }
  case 'msvc'
  {
    cc.coptions += /GS /fp:precise /Zc:wchar_t /Zc:forScope

    # Disable warnings that pop up with /W3.
    #
    cc.coptions += /wd4996
  }
}