2020-07-07 19:16:02 +00:00
|
|
|
.DEFAULT_GOAL: all
|
|
|
|
|
2020-09-05 15:25:05 +00:00
|
|
|
## Optional build flags:
|
|
|
|
## ARCH=arm : Specify which target platform you're compiling
|
|
|
|
## for. This will default to arm, which is typical
|
|
|
|
## on a Raspberry Pi.
|
|
|
|
## CROSS_COMPILE=arm-linux-gnueabihf- : Specify which compiler
|
|
|
|
## toolchain to use. This will default to arm-linux-
|
|
|
|
## gnueabihf-, which is typical on a Raspberry Pi.
|
|
|
|
## To cross compile on a x86_64 system set these to:
|
|
|
|
## ARM=x86_64 CROSS_COMPILE=x86_64-linux-gnu-cpp
|
2020-08-28 04:16:23 +00:00
|
|
|
ARCH ?= arm
|
|
|
|
CROSS_COMPILE ?= arm-linux-gnueabihf-
|
|
|
|
|
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
CXX = $(CROSS_COMPILE)g++
|
2020-07-07 19:16:02 +00:00
|
|
|
|
2020-09-05 15:25:05 +00:00
|
|
|
## DEBUG=1 : A Debug build includes the debugger symbols
|
|
|
|
## and disables compiler optimization. Typically,
|
|
|
|
## this is only used by developers.
|
2020-07-10 22:49:02 +00:00
|
|
|
DEBUG ?= 0
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
# Debug CFLAGS
|
2020-08-28 14:18:02 +00:00
|
|
|
CFLAGS += -DDISK_LOG -O0 -g -Wall -DDEBUG
|
|
|
|
CXXFLAGS += -DDISK_LOG -O0 -g -Wall -DDEBUG
|
2020-07-10 22:49:02 +00:00
|
|
|
BUILD_TYPE = Debug
|
|
|
|
else
|
|
|
|
# Release CFLAGS
|
2020-12-29 00:53:00 +00:00
|
|
|
CFLAGS += -O3 -Wall -Werror -DNDEBUG
|
|
|
|
CXXFLAGS += -O3 -Wall -Werror -DNDEBUG
|
2020-07-10 22:49:02 +00:00
|
|
|
BUILD_TYPE = Release
|
|
|
|
endif
|
2020-09-04 00:39:10 +00:00
|
|
|
CFLAGS += -iquote . -MD -MP
|
|
|
|
CXXFLAGS += -std=c++14 -iquote . -MD -MP
|
2020-07-07 19:16:02 +00:00
|
|
|
|
2021-02-07 19:00:48 +00:00
|
|
|
## CONNECT_TYPE=FULLSPEC : Specify the type of RaSCSI board type
|
2020-09-05 15:25:05 +00:00
|
|
|
## that you are using. The typical options are
|
2021-02-07 19:00:48 +00:00
|
|
|
## STANDARD or FULLSPEC. The default is FULLSPEC
|
2020-09-05 15:25:05 +00:00
|
|
|
## * THIS IS TYPICALLY THE ONLY COMPILE OPTION YOU
|
|
|
|
## * NEED TO SPECIFY
|
2020-10-19 12:31:06 +00:00
|
|
|
# If its not specified, build for FULLSPEC configuration
|
|
|
|
CONNECT_TYPE ?= FULLSPEC
|
2020-07-04 14:57:44 +00:00
|
|
|
|
|
|
|
ifdef CONNECT_TYPE
|
|
|
|
CFLAGS += -DCONNECT_TYPE_$(CONNECT_TYPE)
|
|
|
|
CXXFLAGS += -DCONNECT_TYPE_$(CONNECT_TYPE)
|
|
|
|
endif
|
2018-05-03 13:47:57 +00:00
|
|
|
|
|
|
|
RASCSI = rascsi
|
|
|
|
RASCTL = rasctl
|
|
|
|
RASDUMP = rasdump
|
2020-07-04 14:57:44 +00:00
|
|
|
SASIDUMP = sasidump
|
2020-07-07 19:16:02 +00:00
|
|
|
SCSIMON = scsimon
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-09-05 15:25:05 +00:00
|
|
|
SYSTEMD_CONF = /etc/systemd/system/rascsi.service
|
|
|
|
RSYSLOG_CONF = /etc/rsyslog.d/rascsi.conf
|
|
|
|
RSYSLOG_LOG = /var/log/rascsi.log
|
|
|
|
|
2020-07-09 18:21:59 +00:00
|
|
|
USR_LOCAL_BIN = /usr/local/bin
|
|
|
|
MAN_PAGE_DIR = /usr/share/man/man1
|
|
|
|
DOC_DIR = ../../doc
|
2020-09-05 15:25:05 +00:00
|
|
|
OS_FILES = ./os_integration
|
2020-07-09 18:21:59 +00:00
|
|
|
|
2020-09-04 00:39:10 +00:00
|
|
|
OBJDIR := ./obj/$(shell echo $(CONNECT_TYPE) | tr '[:upper:]' '[:lower:]')
|
|
|
|
BINDIR := ./bin/$(shell echo $(CONNECT_TYPE) | tr '[:upper:]' '[:lower:]')
|
2020-08-28 14:18:02 +00:00
|
|
|
|
2020-07-07 19:16:02 +00:00
|
|
|
#BIN_ALL = $(RASCSI) $(RASCTL) $(RASDUMP) $(SASIDUMP) $(SCSIMON)
|
|
|
|
# Temporarily remove the RASDUMP and RASDUMP tools, since they're not needed
|
|
|
|
# for my specific use case. If you need them - add them back in!
|
2020-10-19 12:31:06 +00:00
|
|
|
BIN_ALL = $(BINDIR)/$(RASCSI) $(BINDIR)/$(RASCTL) $(BINDIR)/$(SCSIMON)
|
2018-05-03 13:47:57 +00:00
|
|
|
|
|
|
|
SRC_RASCSI = \
|
|
|
|
rascsi.cpp \
|
|
|
|
scsi.cpp \
|
|
|
|
gpiobus.cpp \
|
|
|
|
filepath.cpp \
|
2020-08-28 14:18:02 +00:00
|
|
|
fileio.cpp\
|
2021-01-25 16:07:30 +00:00
|
|
|
rascsi_version.cpp
|
2020-08-28 14:18:02 +00:00
|
|
|
# os.cpp
|
|
|
|
# rasctl_command.cpp
|
|
|
|
# rascsi_mgr.cpp
|
|
|
|
# command_thread.cpp
|
2020-09-04 00:39:10 +00:00
|
|
|
SRC_RASCSI += $(shell find ./controllers -name '*.cpp')
|
|
|
|
SRC_RASCSI += $(shell find ./devices -name '*.cpp')
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-10-19 12:31:06 +00:00
|
|
|
SRC_SCSIMON = \
|
|
|
|
scsimon.cpp \
|
|
|
|
scsi.cpp \
|
|
|
|
gpiobus.cpp \
|
|
|
|
filepath.cpp \
|
2021-02-07 19:00:48 +00:00
|
|
|
fileio.cpp \
|
2021-01-25 16:07:30 +00:00
|
|
|
rascsi_version.cpp
|
2020-10-19 12:31:06 +00:00
|
|
|
|
2018-05-03 13:47:57 +00:00
|
|
|
SRC_RASCTL = \
|
2021-01-25 16:07:30 +00:00
|
|
|
rasctl.cpp\
|
|
|
|
rascsi_version.cpp
|
2020-08-28 14:18:02 +00:00
|
|
|
# rasctl_command.cpp
|
2018-05-03 13:47:57 +00:00
|
|
|
|
|
|
|
SRC_RASDUMP = \
|
|
|
|
rasdump.cpp \
|
|
|
|
scsi.cpp \
|
|
|
|
gpiobus.cpp \
|
|
|
|
filepath.cpp \
|
2021-01-25 16:07:30 +00:00
|
|
|
fileio.cpp\
|
|
|
|
rascsi_version.cpp
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-07-04 14:57:44 +00:00
|
|
|
SRC_SASIDUMP = \
|
|
|
|
sasidump.cpp \
|
|
|
|
scsi.cpp \
|
|
|
|
gpiobus.cpp \
|
|
|
|
filepath.cpp \
|
2021-01-25 16:07:30 +00:00
|
|
|
fileio.cpp\
|
|
|
|
rascsi_version.cpp
|
2020-07-04 14:57:44 +00:00
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
vpath %.h ./ ./controllers ./devices
|
|
|
|
vpath %.cpp ./ ./controllers ./devices
|
|
|
|
vpath %.o ./$(OBJDIR)
|
|
|
|
vpath ./$(BINDIR)
|
|
|
|
|
|
|
|
|
2020-09-04 00:39:10 +00:00
|
|
|
OBJ_RASCSI := $(addprefix $(OBJDIR)/,$(notdir $(SRC_RASCSI:%.cpp=%.o)))
|
|
|
|
OBJ_RASCTL := $(addprefix $(OBJDIR)/,$(notdir $(SRC_RASCTL:%.cpp=%.o)))
|
|
|
|
OBJ_RASDUMP := $(addprefix $(OBJDIR)/,$(notdir $(SRC_RASDUMP:%.cpp=%.o)))
|
|
|
|
OBJ_SASIDUMP := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SASIDUMP:%.cpp=%.o)))
|
|
|
|
OBJ_SCSIMON := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSIMON:%.cpp=%.o)))
|
2020-07-09 18:21:59 +00:00
|
|
|
#OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP) $(OBJ_SCSIMON)
|
2020-10-19 12:31:06 +00:00
|
|
|
OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP) $(OBJ_SCSIMON)
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-09-04 00:39:10 +00:00
|
|
|
|
|
|
|
# The following will include all of the auto-generated dependency files (*.d)
|
|
|
|
# if they exist. This will trigger a rebuild of a source file if a header changes
|
2020-10-19 12:31:06 +00:00
|
|
|
ALL_DEPS := $(patsubst %.o,%.d,$(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_SCSIMON))
|
2020-09-04 00:39:10 +00:00
|
|
|
-include $(ALL_DEPS)
|
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
$(OBJDIR) $(BINDIR):
|
2020-09-05 15:25:05 +00:00
|
|
|
echo "-- Creating directory $@"
|
2020-08-28 14:18:02 +00:00
|
|
|
mkdir -p $@
|
|
|
|
|
2020-09-04 00:39:10 +00:00
|
|
|
$(OBJDIR)/%.o: %.cpp | $(OBJDIR)
|
2020-07-04 14:57:44 +00:00
|
|
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-09-05 15:25:05 +00:00
|
|
|
## Build Targets:
|
|
|
|
## all : Rebuild all of the executable files and re-generate
|
|
|
|
## the text versions of the manpages
|
|
|
|
## docs : Re-generate the text versions of the man pages
|
2020-07-10 22:49:02 +00:00
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
.PHONY: all ALL docs
|
2020-07-09 18:21:59 +00:00
|
|
|
all: $(BIN_ALL) docs
|
2020-07-10 22:49:02 +00:00
|
|
|
ALL: all
|
|
|
|
|
2020-10-19 12:31:06 +00:00
|
|
|
docs: $(DOC_DIR)/rascsi_man_page.txt $(DOC_DIR)/rasctl_man_page.txt $(DOC_DIR)/scsimon_man_page.txt
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-09-04 00:39:10 +00:00
|
|
|
$(BINDIR)/$(RASCSI): $(OBJ_RASCSI) | $(BINDIR)
|
2021-04-03 19:02:20 +00:00
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_RASCSI) -lpthread -lz -lpcap
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-10-19 12:31:06 +00:00
|
|
|
$(BINDIR)/$(RASCTL): $(OBJ_RASCTL) | $(BINDIR)
|
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_RASCTL)
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-10-19 12:31:06 +00:00
|
|
|
$(BINDIR)/$(RASDUMP): $(OBJ_RASDUMP) | $(BINDIR)
|
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_RASDUMP)
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-10-19 12:31:06 +00:00
|
|
|
$(BINDIR)/$(SASIDUMP): $(OBJ_SASIDUMP) | $(BINDIR)
|
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_SASIDUMP)
|
2020-07-04 14:57:44 +00:00
|
|
|
|
2020-10-19 12:31:06 +00:00
|
|
|
$(BINDIR)/$(SCSIMON): $(OBJ_SCSIMON) | $(BINDIR)
|
2020-07-07 19:16:02 +00:00
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_SCSIMON) -lpthread
|
|
|
|
|
2020-09-05 15:25:05 +00:00
|
|
|
## clean : Remove all of the object files, intermediate
|
|
|
|
## compiler files and executable files
|
|
|
|
.PHONY: clean
|
2018-05-03 13:47:57 +00:00
|
|
|
clean:
|
2020-08-28 14:18:02 +00:00
|
|
|
rm -rf $(OBJDIR) $(BINDIR)
|
2020-07-07 00:23:54 +00:00
|
|
|
|
2020-09-05 15:25:05 +00:00
|
|
|
## run : Launches RaSCSI using some pre-defined drive
|
|
|
|
## images. Useful for debugging when you're building
|
|
|
|
## and re-launching over and over.
|
|
|
|
.PHONY: run
|
2020-07-07 00:23:54 +00:00
|
|
|
run:
|
2020-09-05 15:25:05 +00:00
|
|
|
sudo $(BINDIR)/$(RASCSI) -ID1 /home/pi/HARDDISK2.hda -ID6 /home/pi/marathon.iso
|
|
|
|
|
|
|
|
## install : Copies all of the man pages to the correct location
|
|
|
|
## Copies the binaries to a global install location
|
|
|
|
## Configures the Systemd and RSyslog services to auto-run RaSCSI
|
|
|
|
## * This target needs to be run with sudo (ex: sudo make install)
|
|
|
|
## * Before running this, you need to stop the rascsi service if
|
|
|
|
## * it is already running:
|
|
|
|
## * sudo systemctl stop rascsi
|
|
|
|
## * After running this, you will need to reboot or run:
|
|
|
|
## * sudo systemctl daemon-reload
|
|
|
|
## * sudo systemctl restart rsyslog
|
|
|
|
## * sudo systemctl enable rascsi
|
|
|
|
## * sudo systemctl start rascsi
|
|
|
|
.PHONY: install
|
2020-10-19 12:31:06 +00:00
|
|
|
install: $(MAN_PAGE_DIR)/rascsi.1 $(MAN_PAGE_DIR)/rasctl.1 $(MAN_PAGE_DIR)/scsimon.1 $(USR_LOCAL_BIN)/$(RASCTL) $(USR_LOCAL_BIN)/$(RASCSI) $(USR_LOCAL_BIN)/$(SCSIMON) $(SYSTEMD_CONF) $(RSYSLOG_CONF) $(RSYSLOG_LOG)
|
2020-09-05 15:25:05 +00:00
|
|
|
@echo "-- Done installing!"
|
|
|
|
|
|
|
|
$(USR_LOCAL_BIN)% : $(BINDIR)/%
|
|
|
|
@echo "-- Copying $@"
|
|
|
|
cp $< $@
|
2020-07-09 18:21:59 +00:00
|
|
|
|
|
|
|
$(MAN_PAGE_DIR)/%.1 : $(DOC_DIR)/%.1
|
2020-09-05 15:25:05 +00:00
|
|
|
@echo "-- Copying $@"
|
|
|
|
cp $< $@
|
2020-07-09 18:21:59 +00:00
|
|
|
|
|
|
|
$(DOC_DIR)/%_man_page.txt : $(DOC_DIR)/%.1
|
2020-07-09 18:28:17 +00:00
|
|
|
@echo "!! ------ THIS FILE IS AUTO_GENERATED! DO NOT MANUALLY UPDATE!!!" > $@
|
|
|
|
@echo "!! ------ The native file is $(notdir $<). Re-run 'make docs' after updating\n\n" >> $@
|
|
|
|
man -l $< | col -bx >> $@
|
2020-07-07 19:16:02 +00:00
|
|
|
|
2020-09-05 15:25:05 +00:00
|
|
|
$(SYSTEMD_CONF) : $(OS_FILES)/$(notdir $(SYSTEMD_CONF))
|
|
|
|
@echo "-- Copying $@"
|
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
$(RSYSLOG_CONF) : $(OS_FILES)/$(notdir $(RSYSLOG_CONF))
|
|
|
|
@echo "-- Copying $@"
|
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
$(RSYSLOG_LOG) :
|
|
|
|
@echo "-- Creating $@"
|
|
|
|
touch /var/log/rascsi.log
|
|
|
|
chown root:adm /var/log/rascsi.log
|
|
|
|
|
|
|
|
## help : Lists information about how to use the makefile
|
|
|
|
# The help rule is based upon the approach from:
|
|
|
|
# https://swcarpentry.github.io/make-novice/08-self-doc/index.html
|
|
|
|
.PHONY: help
|
|
|
|
help : Makefile
|
|
|
|
@sed -n 's/^##//p' $<
|
|
|
|
|
|
|
|
## Debug : Same as 'all'. Useful when using a debugger.
|
2020-07-07 19:16:02 +00:00
|
|
|
.PHONY: Debug
|
2020-07-09 22:57:13 +00:00
|
|
|
Debug: all
|
2020-09-05 15:25:05 +00:00
|
|
|
|