summaryrefslogtreecommitdiff
path: root/libcurl/libcurl/buildfile
blob: 450bcf98aa68beb823920570b2fbba101ebd7111 (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
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
# file      : libcurl/buildfile
# license   : curl License; see accompanying COPYING file

# Version script.
#
define vsc: file
vsc{*}: extension = vers

# Exported symbols.
#
define esm: file
esm{*}: extension = expsym

import imp_libs  = libssl%lib{ssl}
import imp_libs += libcrypto%lib{crypto}
import imp_libs += libz%lib{z}

lib{curl}: {h c}{**} $imp_libs

tclass = $c.target.class
tsys   = $c.target.system

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

libs{curl}: vsc{libcurl}: include = ($linux || $bsd ? adhoc : false)
libs{curl}: esm{libcurl}: include = ($macos         ? adhoc : false)

vsc{libcurl}: lib/in{libcurl}
{
  in.symbol = '@'

  CURL_LT_SHLIB_VERSIONED_FLAVOUR = 'OPENSSL_'
}

# Generate the exported symbol list file using the interface headers.
#
# Note that upstream auto-generate this file (named as libcurl-symbols.expsym)
# by using the nm utility, dumping symbols from object files and processing
# the output. This, in particular, results in the _curl_jmpenv symbol which
# causes 'cannot export hidden symbol' linker warning.
#
esm{libcurl}: include/curl/h{** -stdcheaders -typecheck-gcc}
{{
  diag sed $> # @@ TMP

  # Examples of the function declarations we need to match:
  #
  # CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
  #                                     size_t *n);
  #
  # CURL_EXTERN const struct curl_easyoption *
  # curl_easy_option_by_id (CURLoption id);
  #
  # Note that we need to avoid matching the function calls in macro expansions
  # and mentioning functions in comments. Thus, we disallow the leading
  # spaces, unless the leading CURL_EXTERN specifier is also present in the
  # line.
  #
  cat $path($<) | \
  sed -n -e 's/^(\s*CURL_EXTERN\b.+\b)?(curl_\w+)\s*\(.*/_\2/p' >$path($>)
}}

# Build options.
#
c.poptions += -DBUILDING_LIBCURL -DHAVE_CONFIG_H \
              -DOS="\"$c.target\"" -DVERSION="\"$version.project_id\""

if! $windows
  c.poptions += -DCURL_HIDDEN_SYMBOLS

# Note that the upstream package uses the -pthread compiler/linker option on
# Linux and FreeBSD. The option is unsupported by build2 so we pass
# -D_REENTRANT and -lpthread preprocessor/linker options instead.
#
switch $tclass, $tsys
{
  case 'linux' | 'bsd'
    c.poptions += -D_REENTRANT

  case 'windows', 'win32-msvc'
    c.poptions += -DWIN32
}

c.poptions =+ "-I$src_base" "-I$src_base/include" "-I$src_base/lib"

obja{*}: c.poptions += -DCURL_STATICLIB

if! $windows
  c.coptions += -fvisibility=hidden

switch $c.class
{
  case '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/version (some -Wno-* options are only
    # recognized in newer versions).
    #
    c.coptions += -Wno-all -Wno-extra -Wno-deprecated-declarations
  }
  case 'msvc'
  {
    # Disable warnings that pop up with /W3.
    #
    c.coptions += /wd4028 /wd4996
  }
}

switch $tclass, $tsys
{
  case 'linux' | 'bsd'
  {
    # Make sure all symbols are resolvable.
    #
    c.loptions += -Wl,--no-undefined

    c.loptions += "-Wl,--version-script=$out_base/libcurl.vers"
    c.libs     += -lpthread
  }
  case 'macos'
  {
    c.loptions += "-Wl,-exported_symbols_list,$out_base/libcurl.expsym"

# @@ TMP Until erroneous -framework option suppression is fixed in build2.
#
#    c.libs     += -framework CoreFoundation -framework Security
    c.libs     += -Wl,-framework,CoreFoundation -Wl,-framework,Security
  }
  case 'windows', 'mingw32'
  {
    c.loptions += -Wl,--enable-auto-image-base
    c.libs     += -lws2_32 -lcrypt32
  }
  case 'windows'
  {
    c.libs += ws2_32.lib crypt32.lib normaliz.lib advapi32.lib
  }
}

# Export options.
#
lib{curl}:  cc.export.poptions  = "-I$src_base/include"
liba{curl}: cc.export.poptions += -DCURL_STATICLIB

# See bootstrap.build for details.
#
if $version.pre_release
  lib{curl}: bin.lib.version = @"-$version.project_id"
else
  lib{curl}: bin.lib.version = @"-$abi_version_major" linux@"$abi_version"

# Install headers from the include/curl/ subdirectory only.
#
h{*}:              install = false
include/curl/h{*}: install = include/curl/