summaryrefslogtreecommitdiff
path: root/openssl/openssl/buildfile
blob: 5d87cd04094d9e953e146ba244ece2d857777750 (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
93
94
95
96
97
98
# file      : openssl/buildfile
# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd
# license   : OpenSSL and SSLeay Licenses; see accompanying LICENSE file

import libs  = libssl%lib{ssl}
import libs += libcrypto%lib{crypto}

exe{openssl}: {h c}{** -vms_* -apps/win32_init} $libs

tclass = $c.target.class

i686 = ($c.target.cpu == 'i686')

linux   = ($tclass == 'linux')
bsd     = ($tclass == 'bsd')
windows = ($tclass == 'windows')

msvc_runtime = ($c.target.system == 'win32-msvc')

gcc   = ($c.class == 'gcc')
msvc  = ($c.class == 'msvc')

exe{openssl}: apps/c{win32_init}: include = $windows

# Build options.
#
if! $windows
{
  # Note that the upstream package uses -pthread compiler/linker option on
  # Linux and FreeBSD. The option is currently unsupported by build2, so we
  # use -D_REENTRANT and -lpthread preprocessor/linker options instead.
  #
  # Also note that on FreeBSD and Mac OS the upstream package passes
  # -D_REENTRANT.
  #
  c.poptions += -D_REENTRANT

  if $bsd
    c.poptions += -D_THREAD_SAFE
}
else
{
  c.poptions += -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE

  # Note that upstream also passes -DOPENSSL_USE_APPLINK if compiled with VC.
  # We drop this option (see libcrypto/buildfile) for details.
  #
  if $msvc_runtime
    c.poptions += -DOPENSSL_SYS_WIN32 -D_CRT_SECURE_NO_DEPRECATE \
                  -D_WINSOCK_DEPRECATED_NO_WARNINGS

  if $msvc
    c.coptions += /Gs0 /GF /Gy
  else
    c.poptions += -D_MT
}

if ($i686 && $gcc)
  c.coptions += -fomit-frame-pointer

# Disable compiler warnings.
#
if $msvc
{
  # Disable warnings that pop up with /W3.
  #
  c.coptions += /wd4090 /wd4244 /wd4267
}
elif $gcc
{
  # Disable warnings that pop up with -Wall -Wextra. Upstream doesn't seem to
  # care about these and it is not easy to disable specific warnings in a way
  # that works across compilers/versions (some -Wno-* options are only
  # recognized in newer versions). There are still some warnings left that
  # appear for certain platforms/compilers. We pass them through but disable
  # treating them as errors.
  #
  c.coptions += -Wno-all -Wno-extra -Wno-error
}

c.poptions =+ "-I$src_base"

if! $windows
{
  if $linux
    c.libs += -ldl

  if ($linux || $bsd)
    c.libs += -lpthread
}
else
{
  c.libs += $regex.apply(ws2_32 gdi32 crypt32,      \
                         '(.+)',                    \
                         $msvc_runtime ? '\1.lib' : '-l\1')
  if $msvc_runtime
    c.libs += advapi32.lib
}