1local arch = config.target.platform:match('[^-]*')
2local archflags = {
3 x86_64='-D SANDBOX_SECCOMP_FILTER=1 -D SECCOMP_AUDIT_ARCH=AUDIT_ARCH_X86_64',
4 aarch64='-D SANDBOX_SECCOMP_FILTER=1 -D SECCOMP_AUDIT_ARCH=AUDIT_ARCH_AARCH64',
5}
6cflags{
7 '-Wall', '-Wno-pointer-sign', '-Wno-format-truncation', '-Wno-stringop-truncation',
8 '-D _XOPEN_SOURCE=600',
9 '-D _DEFAULT_SOURCE',
10 archflags[arch] or '-D SANDBOX_RLIMIT=1',
11 '-I $outdir',
12 '-I $srcdir',
13 '-I $dir/include',
14 '-isystem $basedir/pkg/openbsd/include',
15 '-isystem $builddir/pkg/bearssl/include',
16 '-isystem $builddir/pkg/libfido2/include',
17 '-isystem $builddir/pkg/linux-headers/include',
18 '-isystem $builddir/pkg/zlib/include',
19}
20
21pkg.deps = {
22 'pkg/bearssl/headers',
23 'pkg/libfido2/headers',
24 'pkg/linux-headers/headers',
25 'pkg/zlib/headers',
26 '$outdir/config.h',
27}
28
29build('cat', '$outdir/config.h', {
30 '$builddir/probe/HAVE___BUILTIN_POPCOUNT',
31 '$builddir/probe/SIZEOF_LONG',
32 '$builddir/probe/SIZEOF_TIME_T',
33 '$dir/config.h',
34})
35
36lib('libopenbsd-compat.a', [[openbsd-compat/(
37 base64.c basename.c bcrypt_pbkdf.c bindresvport.c blowfish.c daemon.c
38 dirname.c explicit_bzero.c fmt_scaled.c freezero.c getcwd.c
39 getgrouplist.c getopt_long.c getrrsetbyname.c glob.c inet_aton.c
40 inet_ntoa.c inet_ntop.c md5.c memmem.c mktemp.c pwcache.c
41 readpassphrase.c reallocarray.c recallocarray.c rresvport.c setenv.c
42 setproctitle.c sha1.c sha2.c sigact.c strcasestr.c strlcat.c strlcpy.c
43 strmode.c strndup.c strnlen.c strptime.c strsep.c strtoll.c strtonum.c
44 strtoull.c strtoul.c timingsafe_bcmp.c vis.c
45
46 arc4random.c bsd-asprintf.c bsd-closefrom.c bsd-cygwin_util.c bsd-err.c
47 bsd-flock.c bsd-getpagesize.c bsd-getpeereid.c bsd-malloc.c bsd-misc.c
48 bsd-nextstep.c bsd-openpty.c bsd-poll.c bsd-setres_id.c bsd-signal.c
49 bsd-snprintf.c bsd-statvfs.c bsd-waitpid.c fake-rfc2553.c
50 getrrsetbyname-ldns.c kludge-fd_set.c
51 xcrypt.c
52
53 port-aix.c port-irix.c port-linux.c port-solaris.c port-net.c port-uw.c
54)]])
55
56-- port-tun.c from openbsd-compat depends on sshbuf-getput-basic.c and ssherr.c
57-- from libssh.a, so just include it in libssh.a.
58lib('libssh.a', [[
59 ssh_api.c
60 ssherr.c
61 sshbuf.c
62 sshkey.c
63 sshbuf-getput-basic.c
64 sshbuf-misc.c
65 krl.c
66 bitmap.c
67
68 authfd.c authfile.c
69 canohost.c channels.c cipher.c cipher-aes.c cipher-aesctr.c
70 cleanup.c
71 compat.c fatal.c hostfile.c
72 log.c match.c moduli.c nchan.c packet.c
73 readpass.c ttymodes.c xmalloc.c addr.c addrmatch.c
74 atomicio.c dispatch.c mac.c misc.c utf8.c
75 monitor_fdpass.c rijndael.c ssh-ecdsa.c ssh-ecdsa-sk.c
76 ssh-ed25519-sk.c ssh-rsa.c dh.c
77 msg.c dns.c entropy.c gss-genr.c umac.c umac128.c
78 smult_curve25519_ref.c
79 poly1305.c chacha.c cipher-chachapoly.c cipher-chachapoly-bearssl.c
80 ssh-ed25519.c digest-bearssl.c digest-libc.c
81 hmac.c ed25519.c
82 kex.c kex-names.c kexdh.c kexgex.c kexecdh.c kexc25519.c
83 kexgexc.c kexgexs.c
84 kexsntrup761x25519.c kexmlkem768x25519.c sntrup761.c kexgen.c
85 sftp-realpath.c platform-pledge.c platform-tracing.c platform-misc.c
86 sshbuf-io.c misc-agent.c ssherr-libcrypto.c
87
88 ssh-pkcs11-client.c
89 ssh-sk-client.c
90
91 libopenbsd-compat.a
92 $builddir/pkg/bearssl/libbearssl.a
93 $builddir/pkg/libfido2/libfido2.a.d
94 $builddir/pkg/zlib/libz.a
95]])
96
97lib('sftp-client.a', [[
98 sftp-common.c
99 sftp-client.c
100 sftp-glob.c
101
102 progressmeter.c
103]])
104
105lib('sftp-server.a', [[
106 sftp-common.c.o
107 sftp-server.c
108]])
109
110exe('ssh', [[
111 ssh.c readconf.c clientloop.c sshtty.c
112 sshconnect.c sshconnect2.c mux.c
113 libssh.a.d
114]])
115file('bin/ssh', '755', '$outdir/ssh')
116
117exe('sshd', [[
118 sshd.c
119 platform-listen.c
120 servconf.c sshpty.c srclimit.c groupaccess.c auth2-methods.c
121 libssh.a.d
122]])
123file('bin/sshd', '755', '$outdir/sshd')
124
125-- used by sshd-session and sshd-auth
126lib('sshd-common.a', [[
127 auth-rhosts.c auth-passwd.c
128 audit.c audit-bsm.c audit-linux.c platform.c
129 sshpty.c.o sshlogin.c servconf.c.o serverloop.c
130 auth.c auth2.c auth2-methods.c.o auth-options.c session.c
131 auth2-chall.c groupaccess.c.o
132 auth-bsdauth.c auth2-hostbased.c auth2-kbdint.c
133 auth2-none.c auth2-passwd.c auth2-pubkey.c auth2-pubkeyfile.c
134 monitor_wrap.c auth-krb5.c
135 auth2-gss.c gss-serv.c gss-serv-krb5.c
136 loginrec.c auth-pam.c auth-shadow.c auth-sia.c
137 uidswap.c
138]])
139
140exe('sshd-session', [[
141 sshd-session.c
142 monitor.c platform-listen.c.o
143 sshd-common.a
144 sftp-server.a
145 libssh.a.d
146]])
147file('libexec/sshd-session', '755', '$outdir/sshd-session')
148
149exe('sshd-auth', [[
150 sshd-auth.c
151 sandbox-null.c sandbox-rlimit.c sandbox-darwin.c
152 sandbox-seccomp-filter.c sandbox-capsicum.c sandbox-solaris.c
153 sshd-common.a
154 sftp-server.a
155 libssh.a.d
156]])
157file('libexec/sshd-auth', '755', '$outdir/sshd-auth')
158
159exe('scp', {'scp.c', 'sftp-client.a', 'libssh.a.d'})
160file('bin/scp', '755', '$outdir/scp')
161
162exe('ssh-add', {'ssh-add.c', 'libssh.a.d'})
163file('bin/ssh-add', '755', '$outdir/ssh-add')
164
165exe('ssh-agent', {'ssh-agent.c', 'libssh.a.d'})
166file('bin/ssh-agent', '755', '$outdir/ssh-agent')
167
168exe('ssh-keygen', {'ssh-keygen.c', 'sshsig.c', 'libssh.a.d'})
169file('bin/ssh-keygen', '755', '$outdir/ssh-keygen')
170
171exe('ssh-keyscan', {'ssh-keyscan.c', 'libssh.a.d'})
172file('bin/ssh-keyscan', '755', '$outdir/ssh-keyscan')
173
174exe('ssh-sk-helper', {'ssh-sk-helper.c', 'ssh-sk.c', 'sk-usbhid.c', 'libssh.a.d'})
175file('libexec/ssh-sk-helper', '755', '$outdir/ssh-sk-helper')
176
177exe('sftp-server', {'sftp-server-main.c', 'sftp-server.a', 'libssh.a.d'})
178file('libexec/sftp-server', '755', '$outdir/sftp-server')
179
180exe('sftp', {'sftp.c', 'sftp-usergroup.c', 'sftp-client.a', 'libssh.a.d'})
181file('bin/sftp', '755', '$outdir/sftp')
182
183man{
184 'ssh.1',
185 'scp.1',
186 'ssh-add.1',
187 'ssh-agent.1',
188 'ssh-keygen.1',
189 'ssh-keyscan.1',
190 'ssh_config.5',
191 'sshd_config.5',
192 'sshd.8',
193 'sftp-server.8',
194 'sftp.1',
195}
196
197fetch 'git'