-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·63 lines (57 loc) · 2.05 KB
/
build.sh
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
# Copyright Supranational LLC
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#!/bin/bash
set -e
set -x
[ -d libft4222 ] || mkdir libft4222
# Fetch the FTDI driver
case `uname -s` in
Linux)
if [ ! -f libft4222/libft4222.h ]; then
wget -O - https://ftdichip.com/wp-content/uploads/2022/06/libft4222-linux-1.4.4.170.tgz \
| (cd libft4222; tar zxf -)
fi
case `uname -p` in
x86_64) ftdi_path=libft4222/build-x86_64;;
aarch64) ftdi_path=libft4222/build-arm-v8;;
*) echo "Usupported platform"; exit 1;;
esac
extra_ldflags='-static-libstdc++'
if (grep -q -e '^flags.*\badx\b' /proc/cpuinfo) 2>/dev/null; then
CFLAGS="-D__ADX__"
fi
;;
Darwin)
if [ ! -f libft4222/libft4222.h ]; then
curl -sSf https://ftdichip.com/wp-content/uploads/2022/06/LibFT4222-mac-v1.4.4.170.zip \
| tar xf -
hdiutil attach libft4222.1.4.4.170.dmg -mountroot . -nobrowse
rm -f libft4222.1.4.4.170.dmg
cp -r ft4222/ libft4222/
hdiutil detach ft4222
fi
ftdi_path=libft4222/build
extra_ldflags='-framework Foundation -framework IOKit'
if [ -f libft4222/build/libgmp.a ]; then
CFLAGS="-arch x86_64 -arch arm64"
CXXFLAGS="-arch x86_64 -arch arm64"
elif [ `sysctl -n hw.optional.adx 2>/dev/null` = "1" ]; then
CFLAGS="-D__ADX__"
fi
;;
*) echo "Unsupported OS"; exit 1
;;
esac
if [ ! -d sloth-pasta/src ]; then
git submodule init
git submodule update
fi
${CC:-cc} ${CFLAGS} -g -O -c sloth-pasta/src/pasta_vdf.c sloth-pasta/src/assembly.S
trap 'rm -f pasta_vdf.o assembly.o' 0
rm -f minroot
${CXX:-c++} ${CXXFLAGS} -std=c++11 -pthread -g -O -o minroot -Wall -Wextra \
-Ilibft4222 -Isrc \
src/main.cpp src/driver.cpp src/ftdi_driver.cpp \
pasta_vdf.o assembly.o \
-L$ftdi_path -lft4222 -lgmp $extra_ldflags