-
Notifications
You must be signed in to change notification settings - Fork 2
Compilation instructions
In order to build SCSI2Pi from the sources run make in the top-level folder. You may have to install some additional packages first.
sudo apt install -y g++ make protobuf-compiler libspdlog-dev libgmock-dev
git clone https://github.com/uweseimet/scsi2pi
cd scsi2pi
git checkout develop
make
make DEBUG=1
make s2p s2pctl
sudo make install installs the binaries and manpages in /opt/scsi2pi. make help displays information on the available build targets.
SCSI2Pi tries to be as platform independent as possible. While the board hareware requires a Pi, numerous other platforms can be used for development (e.g. with an IDE like Eclipse CDT), for running the unit tests and for testing the SCSI layer with the in-process bus.
SCSI2Pi compiles with g++ and clang++ and supports 32 and 64 bit operating systems. After a successful make you can compile and run the unit tests with make test.
SCSI2Pi also compiles on numerous non-Pi platforms. You can run the unit tests and use some of the binaries for testing purposes. You can even use the in_process_test to execute SCSI commands within the s2p process. Or you run s2pctl on your local PC and connect to your Pi with the -h option.
SCSI2Pi compiles with g++ and/or clang++ on a Linux PC (amd64 or aarch64), on FreeBSD 14.1 and NetBSD 10.0, provided that packages like GNU make, g++/clang++, protobuf and spdlog are installed. In particular with FreeBSD and NetBSD the latest compiler versions have to be used. On macos 15 everything compiles as long as the include and library paths for the required homebrew packages are set correctly.
The clang++ compiler is faster than g++ and needs less memory. You change the compiler like this:
make CXX=clang++
Linkers like "mold", "gold" or "lld" are faster than the regular "bfd" linker. You select the linker with the LDFLAGS, e.g.:
export LDFLAGS="-fuse-ld=lld"
Of the linkers listed above "mold" is the fastest, followed by "lld". On a Pi Zero alternative linkers save several minutes of build time.
The SCSI2Pi binaries can be further optimized/shrunk by enabling link-time optimization:
export EXTRA_FLAGS="-flto"
With this setting the amount of memory and the time needed for compiling and linking increase. On Pis with only 512 MB of main memory this optimization cannot be used. The SCSI2Pi binary packages are built with this optimization.