Go Back

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

53 # LibreSSL 3.8.2

54 # OpenBSD already has libressl

55 if [ "$(uname)" != OpenBSD ] ;

56 then

57 mkdir -p lib

58 mkdir -p build

59 cd build

60 h="6d4b8d5bbb25a1f8336639e56ec5088052d43a95256697a85c4ce91323c25954"

61 ssl_version="3.8.2"

62 remote_dir="https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/"

63 check_hash $h "$remote_dir/libressl-$ssl_version.tar.gz"

64 tar -zxf libressl-$ssl_version.tar.gz

65 cd libressl-$ssl_version

66 if [ "$(uname)" == SunOS ] ;

67 then

68 CC=gcc MAKE=gmake ./configure

69 gmake -j 4

70 else

71 ./configure

72 make -j 4

73 fi

74 cp include/*.h ../../include/

75 cp -R include/compat ../../include/

76 cp -R include/openssl ../../include/

77 cp tls/.libs/libtls.a ../../lib

78 cp crypto/.libs/libcrypto.a ../../lib

79 cp ssl/.libs/libssl.a ../../lib

80 cd ../../

81 fi

82

83 # stb_image 2.28

84 h="38e08c1c5ab8869ae8d605ddaefa85ad3fea24a2964fd63a099c0c0f79c70bcc"

85 check_hash $h "https://raw.githubusercontent.com/nothings/stb/5736b15f7ea0ffb08dd38af21067c314d6a3aae9/stb_image.h"

86 mv stb_image.h include/

87

88 if [ "$(uname)" == SunOS ] ;

89 then

90 sed -i -e "/CC/s/^#//" Makefile

91 sed -i -e "/LIBS/s/^#//" Makefile

92 sed -i -e "/CFLAGS/s/^#//" Makefile

93 fi

94 if [ "$(uname)" == Darwin ] ;

95 then

96 sed -i -e "/CFLAGS/s/^#//" GNUmakefile

97 fi

98 make -j4

99