forked from freebsd/pkg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
auto.def
314 lines (273 loc) · 7.59 KB
/
auto.def
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
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
# vim:se syn=tcl:
#
use cc cc-lib cc-shared pkg-config
set maj_ver 1
set med_ver 12
set min_ver 99
set dev_ver 0
define PKG_API [expr $maj_ver * 1000000 + $med_ver * 1000 + $min_ver]
define VERSION $maj_ver.$med_ver.$min_ver[expr {$dev_ver ? ".$dev_ver" : ""}]
# Add any user options here
options {
pkgconfigdir:WHERE => "path to the directory where to install pc files"
with-ldns => "add support for libldns"
with-libarchive.pc => "build with libarchive getting flags via pc files"
with-coverage => "build with llvm coverage support"
}
if {[opt-str pkgconfigdir dir]} {
define pkgconfigdir $dir
} else {
if {[string match *-freebsd* [get-define host]]} {
define pkgconfigdir [get-define prefix]/libdata/pkgconfig
} else {
define pkgconfigdir [get-define prefix]/lib/pkgconfig
}
}
cc-check-tools ar ranlib strip
define EXTRA_LIBS ""
define LIBVERSION 4
define LIBSOEXT [format [get-define SH_SOEXTVER] [get-define LIBVERSION]]
define GITHASH ""
if {[cc-check-progs git] && [file exists .git]} {
catch {exec git rev-parse --short HEAD} gitrev
catch {exec git diff-index -m --name-only HEAD} gitdirty
define GITHASH -$gitrev[expr {$gitdirty eq {} ? {} : {-dirty}}]
}
if {[string match *-linux* [get-define host]]} {
cc-with { -libs { -lbsd }} {
if {[cc-check-functions getprogname]} {
define-append EXTRA_LIBS -lbsd
define-feature libbsd
} else {
user-error "Unable to find libbsd"
}
}
} else {
define-feature static
}
if {![opt-bool with-libarchive.pc]} {
cc-with { -libs { -larchive }} {
if {![cc-check-functions archive_read_open]} {
user-error "Unable to find libarchive"
}
}
}
cc-with { -libs { -lz }} {
if {![cc-check-functions zlibVersion]} {
user-error "Unable to find zlib"
}
}
cc-with { -libs { -lbz2 }} {
if {![cc-check-functions BZ2_bzReadOpen]} {
user-error "Unable to find bzip2"
}
}
cc-with { -libs { -llzma }} {
if {![cc-check-functions lzma_version_string]} {
user-error "Unable to find liblzma"
}
}
define ZSTDLIB ""
cc-with { -libs { -lprivatezstd }} {
if {[cc-check-functions ZSTD_versionNumber]} {
define ZSTDLIB "-lprivatezstd"
}
}
# Atomics
msg-checking "Checking for atomic builtins... "
if {[cctest -code {
volatile unsigned long val = 1;
__sync_synchronize();
__sync_val_compare_and_swap(&val, 1, 0);
__sync_add_and_fetch(&val, 1);
__sync_sub_and_fetch(&val, 1);
return 0;
}
]} {
msg-result ok
define-feature atomic_builtins
} else {
msg-result no
define-feature atomic_builtins 0
}
msg-checking "Checking for /proc/self/fd support... "
if {[file exists /proc/self/fd]} {
msg-result ok
define-feature proc-pid
} else {
msg-result no
define-feature proc-pid 0
}
foreach fct [list memmove usleep pread pwrite] {
if {![cc-check-functions $fct]} {
user-error "Cannot find $fct"
}
}
cc-with { -includes fcntl.h } {
cc-check-decls F_CLOSEM
}
cc-with { -includes sys/socket.h } {
cc-check-decls SOCK_SEQPACKET
}
cc-with { -includes netinet/in.h } {
cc-check-members "struct sockaddr_in.sin_len"
}
cc-with { -includes sys/stat.h } {
cc-check-members "struct stat.st_mtim" "struct stat.st_flags"
}
# check for sqlite
cc-check-functions gmtime_r isnan localtime_r strchrnul strerror_r
cc-check-includes stdint.h inttypes.h
# check for pkg itself
cc-check-functions arc4random arc4random_stir basename_r chflagsat \
closefrom dirfd eaccess fopencookie fstatfs funopen strnstr \
strtofflags strtonum sysconf utimensat __res_setservers unlinkat \
faccessat fstatat openat readlinkat fflagstostr
cc-with { -includes { libutil.h }} {
if {[cc-check-decls humanize_number]} {
}
}
if {![cc-check-functions fts_open]} {
cc-with { -libs { -lfts }} {
if {[cc-check-functions fts_open]} {
define-feature LIBFTS
}
}
}
if {[get-define HAVE_DECL_HUMANIZE_NUMBER] eq 1} {
cc-with { -libs { -lutil }} {
if {[cc-check-functions humanize_number]} {
define-feature LIBUTIL
}
}
}
if {![cc-check-functions dlclose]} {
cc-with { -libs { -ldl }} {
if {[cc-check-functions dlclose]} {
define-feature LIBDL
}
}
}
if {![cc-check-functions __res_query]} {
cc-with { -libs { -lresolv }} {
if {[cc-check-functions __res_query]} {
define-feature LIBRESOLV
}
}
}
cc-check-includes link.h machine/endian.h osreldate.h readpassphrase.h \
sys/procctl.h sys/statfs.h sys/statvfs.h libutil.h
# for compat
cc-check-includes dirent.h
#endian stuff
foreach header [list endian.h sys/endian.h] {
if {[cc-check-includes $header]} {
cc-with [list -includes $header] {
cc-check-decls be16dec be16enc be32dec be32enc be64dec be64enc \
le16dec le16enc le32dec le32enc le64dec le64enc
}
}
}
if {[string match *-darwin* [get-define host]]} {
define libabidir libmachista
define waflags ""
define nowaflags ""
} else {
# libelf
define waflags "-Wl,-whole-archive"
define nowaflags "-Wl,-no-whole-archive"
cc-with { -includes { sys/types.h }} {
cc-check-includes elf-hints.h sys/elf_common.h
}
if {[cc-check-includes gelf.h libelf.h]} {
cc-with { -libs { -lelf } } {
if {[cc-check-functions gelf_getehdr]} {
define-feature libelf
define-append EXTRA_LIBS -lelf
define libabidir ""
cc-check-types Elf_Note
} else {
define-feature libelf 0
define libabidir "libelf"
}
}
} else {
define-feature libelf 0
define libabidir "libelf"
}
}
cc-with { -libs { -ljail} } {
if {[cc-check-functions jail_getid]} {
define-feature libjail
define-append EXTRA_LIBS -ljail
}
}
# libbsd
cc-check-includes bsd/err.h bsd/libutil.h bsd/readpassphrase.h \
bsd/stdio.h bsd/strlib.h bsd/string.h bsd/sys/cdefs.h \
bsd/unistd.h
if {[opt-bool with-coverage]} {
define-append COVERAGE_CFLAGS -O0 -ggdb -fprofile-instr-generate -fcoverage-mapping
define-append COVERAGE_LDFLAGS -fprofile-instr-generate -fuse-ld=/usr/local/bin/ld.lld
define CC /usr/local/bin/clang
define CC_FOR_BUILD /usr/local/bin/clang
define coverage 1
# disable capsicum when coverage is used because coverage does not work in
# capsicum mode
} else {
# capsicum
if {[cc-check-functions cap_sandboxed]} {
define-feature capsicum
cc-check-includes sys/capsicum.h
}
}
define testsdir ""
if {[pkg-config-init 0]} {
# atf
if {[pkg-config atf-c] && [cc-check-progs kyua]} {
define testsdir tests
puts "test suite will be built"
} else {
puts "Skipping test suite"
}
if {[opt-bool with-ldns]} {
if {![pkg-config libldns]} {
user-error "Unable to find libldns"
} else {
define PKG_LIBDNS_LIBS_STATIC [exec pkg-config --static --libs-only-l libldns]
}
}
if {[opt-bool with-libarchive.pc]} {
if {![pkg-config libarchive]} {
user-error "Unable to find libarchive"
} else {
define PKG_LIBARCHIVE_LIBS_STATIC [exec pkg-config --static --libs-only-l libarchive]
cc-with { -libs { -larchive }} {
cc-check-functions archive_write_add_filter_zstd
}
}
}
}
foreach repo [list binary] {
define-append REPOS $repo
define-append REPOS_LDFLAGS -L\$(top_builddir)/libpkg/repo/${repo} -lrepo-${repo}_pic
define-append REPOS_STATIC_LIBS \$(top_builddir)/libpkg/repo/${repo}/librepo-${repo}.a
}
# ccache
if {[get-define CCACHE] ne {none}} {
define CC "[get-define CCACHE] [get-define CC]"
}
make-config-header pkg_config.h
make-config-header external/sqlite/config.h
make-template mk/defs.mk.in
make-template libpkg/pkg.h.in
make-template libpkg/pkg.pc.in
make-template tests/frontend/test_environment.sh.in
make-template Makefile.autosetup Makefile
foreach dir [list external/expat external/blake2 external/picosat \
external/linenoise external/libfetch external/sqlite \
external compat libpkg libpkg/repo libpkg/repo/binary src \
external/libucl external/libelf external/libmachista tests docs \
external/liblua scripts] {
make-template $dir/Makefile.autosetup $dir/Makefile
}