💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Vgmi › files › 5ebe2ba2191058a38e34f6b3b8e62… captured on 2023-01-29 at 03:05:34. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
0 #!/bin/sh
1
2 download=wget
3 if ! hash $download 2>/dev/null; then # FreeBSD
4 download=fetch
5 fi
6 if ! hash $download 2>/dev/null; then # OpenBSD
7 download=ftp
8 fi
9 if ! hash $download 2>/dev/null; then
10 download=curl
11 if ! hash $download 2>/dev/null; then
12 echo "No download program found"
13 exit
14 fi
15 download="curl -O"
16 fi
17
18 hash_file () {
19 file=$1
20 if command -v sha256 > /dev/null # OpenBSD, FreeBSD
21 then
22 actual_hash="$(sha256 $file | rev | cut -d ' ' -f 1 | rev)"
23 return 1
24 fi
25 if command -v shasum > /dev/null # NetBSD, MacOS
26 then
27 actual_hash="$(shasum -a 256 $file | cut -d ' ' -f 1)"
28 return 1
29 fi
30 if command -v sha256sum > /dev/null # Linux, Illumos
31 then
32 actual_hash="$(sha256sum $file | cut -d ' ' -f 1)"
33 return 1
34 fi
35 echo "No sha256 program found"
36 exit
37 }
38
39 check_hash () {
40 expected_hash=$1
41 url=$2
42 $download $url
43 hash_file "$(echo $url | rev | cut -d '/' -f 1 | rev)"
44 if [ "$actual_hash" != "$expected_hash" ]; then
45 echo "$file: unexpected hash"
46 echo "$actual_hash != $expected_hash"
47 exit
48 fi
49 }
50
51 mkdir -p include
52 mkdir -p build
53 cd build
54 mkdir -p ../lib
55
56 # LibreSSL 3.6.1
57 # OpenBSD already has libressl
58 if [ "$(uname)" != OpenBSD ] ;
59 then
60 h="acfac61316e93b919c28d62d53037ca734de85c46b4d703f19fd8395cf006774"
61 check_hash $h "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.6.1.tar.gz"
62 tar -zxf libressl-3.6.1.tar.gz
63 cd libressl-3.6.1
64 if [ "$(uname)" == SunOS ] ;
65 then
66 CC=gcc MAKE=gmake ./configure
67 gmake -j 4
68 else
69 ./configure
70 make -j 4
71 fi
72 cp include/*.h ../../include/
73 cp -R include/compat ../../include/
74 cp -R include/openssl ../../include/
75 cp tls/.libs/libtls.a ../../lib
76 cp crypto/.libs/libcrypto.a ../../lib
77 cp ssl/.libs/libssl.a ../../lib
78 cd ../
79 fi
80
81 # Termbox2 2.0.0
82 h="0ebef83bf8acfacea1cfc8ed78886eb46bd28f915e1217c07577bf08801a95b8"
83 check_hash $h "https://raw.githubusercontent.com/termbox/termbox2/9627635ca71cd0378b58c2305e3f731faa26132b/termbox.h"
84 cp termbox.h ../include/
85
86 # stb_image 2.27
87 h="91f435e0fc6a620018b878b9859c74dff60d28046f87e649191ad6f35a98c722"
88 check_hash $h "https://raw.githubusercontent.com/nothings/stb/8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55/stb_image.h"
89 cp stb_image.h ../include/
90
91 cd ../
92 if [ "$(uname)" == SunOS ] ;
93 then
94 sed -i -e "/CC/s/^#//" Makefile
95 sed -i -e "/LIBS/s/^#//" Makefile
96 sed -i -e "/CFLAGS/s/^#//" Makefile
97 fi
98 if [ "$(uname)" == Darwin ] ;
99 then
100 sed -i -e "/LDFLAGS/s/^#//" GNUmakefile
101 sed -i -e "/CFLAGS/s/^#//" GNUmakefile
102 fi
103 make
104