💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Vgmi › files › 60d32ec5aae9ae63d3774ac8ce54b… captured on 2023-11-04 at 12:16:26. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
0 #!/bin/sh
1
2 download=wget
3 if ! hash $download 2>/dev/null; then # FreeBSD
4 download=fetch
5 fi
6 if [ "$(uname)" == OpenBSD ] ; 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.8.0
57 # OpenBSD already has libressl
58 if [ "$(uname)" != OpenBSD ] ;
59 then
60 ssl_version="3.8.0"
61 h="12531c1ec808c5c6abeb311899664b0cfed04d4648f456dc959bb93c5f21acac"
62 check_hash $h "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-$ssl_version.tar.gz"
63 tar -zxf libressl-$ssl_version.tar.gz
64 cd libressl-$ssl_version
65 if [ "$(uname)" == SunOS ] ;
66 then
67 CC=gcc MAKE=gmake ./configure
68 gmake -j 4
69 else
70 ./configure
71 make -j 4
72 fi
73 cp include/*.h ../../include/
74 cp -R include/compat ../../include/
75 cp -R include/openssl ../../include/
76 cp tls/.libs/libtls.a ../../lib
77 cp crypto/.libs/libcrypto.a ../../lib
78 cp ssl/.libs/libssl.a ../../lib
79 cd ../
80 fi
81
82 # Termbox2 2.0.0
83 h="0ebef83bf8acfacea1cfc8ed78886eb46bd28f915e1217c07577bf08801a95b8"
84 check_hash $h "https://raw.githubusercontent.com/termbox/termbox2/9627635ca71cd0378b58c2305e3f731faa26132b/termbox.h"
85 cp termbox.h ../include/
86
87 # stb_image 2.28
88 h="38e08c1c5ab8869ae8d605ddaefa85ad3fea24a2964fd63a099c0c0f79c70bcc"
89 check_hash $h "https://raw.githubusercontent.com/nothings/stb/5736b15f7ea0ffb08dd38af21067c314d6a3aae9/stb_image.h"
90 cp stb_image.h ../include/
91
92 cd ../
93 if [ "$(uname)" == SunOS ] ;
94 then
95 sed -i -e "/CC/s/^#//" Makefile
96 sed -i -e "/LIBS/s/^#//" Makefile
97 sed -i -e "/CFLAGS/s/^#//" Makefile
98 fi
99 if [ "$(uname)" == Darwin ] ;
100 then
101 sed -i -e "/LDFLAGS/s/^#//" GNUmakefile
102 sed -i -e "/CFLAGS/s/^#//" GNUmakefile
103 fi
104 make
105