2020-07-07 19:16:02 +00:00
|
|
|
.DEFAULT_GOAL: all
|
|
|
|
|
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-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-08-28 14:18:02 +00:00
|
|
|
CFLAGS += -O3 -Wall -Werror
|
|
|
|
CXXFLAGS += -O3 -Wall -Werror
|
2020-07-10 22:49:02 +00:00
|
|
|
BUILD_TYPE = Release
|
|
|
|
endif
|
2020-08-28 14:18:02 +00:00
|
|
|
CFLAGS += -iquote .
|
|
|
|
CXXFLAGS += -std=c++14 -iquote .
|
2020-07-07 19:16:02 +00:00
|
|
|
|
2020-07-07 00:23:54 +00:00
|
|
|
# If its not specified, build for STANDARD configuration
|
|
|
|
CONNECT_TYPE ?= STANDARD
|
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-07-09 18:21:59 +00:00
|
|
|
USR_LOCAL_BIN = /usr/local/bin
|
|
|
|
MAN_PAGE_DIR = /usr/share/man/man1
|
|
|
|
DOC_DIR = ../../doc
|
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
OBJDIR := ./obj
|
|
|
|
BINDIR := ./bin
|
|
|
|
|
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-08-28 14:18:02 +00:00
|
|
|
BIN_ALL = $(BINDIR)/$(RASCSI) $(BINDIR)/$(RASCTL)
|
2020-07-07 00:23:54 +00:00
|
|
|
|
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\
|
|
|
|
# os.cpp
|
|
|
|
# rasctl_command.cpp
|
|
|
|
# rascsi_mgr.cpp
|
|
|
|
# command_thread.cpp
|
|
|
|
SRC_RASCSI += $(notdir $(shell find ./controllers -name '*.cpp'))
|
|
|
|
SRC_RASCSI += $(notdir $(shell find ./devices -name '*.cpp'))
|
2018-05-03 13:47:57 +00:00
|
|
|
|
|
|
|
SRC_RASCTL = \
|
|
|
|
rasctl.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 \
|
|
|
|
fileio.cpp
|
|
|
|
|
2020-07-04 14:57:44 +00:00
|
|
|
SRC_SASIDUMP = \
|
|
|
|
sasidump.cpp \
|
|
|
|
scsi.cpp \
|
|
|
|
gpiobus.cpp \
|
|
|
|
filepath.cpp \
|
|
|
|
fileio.cpp
|
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
vpath %.h ./ ./controllers ./devices
|
|
|
|
vpath %.cpp ./ ./controllers ./devices
|
|
|
|
vpath %.o ./$(OBJDIR)
|
|
|
|
vpath ./$(BINDIR)
|
|
|
|
|
|
|
|
|
|
|
|
OBJ_RASCSI := $(SRC_RASCSI:%.cpp=$(OBJDIR)/%.o)
|
|
|
|
OBJ_RASCTL := $(SRC_RASCTL:%.cpp=$(OBJDIR)/%.o)
|
|
|
|
OBJ_RASDUMP := $(SRC_RASDUMP:%.cpp=$(OBJDIR)/%.o)
|
|
|
|
OBJ_SASIDUMP := $(SRC_SASIDUMP:%.cpp=$(OBJDIR)/%.o)
|
|
|
|
OBJ_SCSIMON := $(SRC_SCSIMON:%.cpp=$(OBJDIR)/%.o)
|
2020-07-09 18:21:59 +00:00
|
|
|
#OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP) $(OBJ_SCSIMON)
|
|
|
|
OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP)
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
$(OBJDIR) $(BINDIR):
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
$(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-08-28 14:18:02 +00:00
|
|
|
# $(OBJDIR)/%.o: %.c
|
|
|
|
# $(CXX) $(CXXFLAGS) -c $< -o $@
|
2020-07-09 18:21:59 +00:00
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
# %.o: %.cpp
|
|
|
|
# $(CXX) $(CXXFLAGS) -c $(OBJDIR)/$< -o $@
|
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
|
|
|
|
|
|
|
|
docs: $(DOC_DIR)/rascsi_man_page.txt $(DOC_DIR)/rasctl_man_page.txt
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
$(BINDIR)/$(RASCSI): $(OBJ_RASCSI) $(BINDIR)
|
|
|
|
@echo -- Linking $(RASCSI)
|
2018-05-03 13:47:57 +00:00
|
|
|
$(CXX) -o $@ $(OBJ_RASCSI) -lpthread
|
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
$(BINDIR)/$(RASCTL): $(OBJ_RASCTL) $(BINDIR)
|
|
|
|
@echo -- Linking $(RASCTL)
|
2018-05-03 13:47:57 +00:00
|
|
|
$(CXX) -o $@ $(OBJ_RASCTL)
|
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
$(RASDUMP): $(OBJ_RASDUMP) $(BINDIR)
|
2018-05-03 13:47:57 +00:00
|
|
|
$(CXX) -o $@ $(OBJ_RASDUMP)
|
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
$(SASIDUMP): $(OBJ_SASIDUMP) $(BINDIR)
|
2020-07-04 14:57:44 +00:00
|
|
|
$(CXX) -o $@ $(OBJ_SASIDUMP)
|
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
$(SCSIMON): $(OBJ_SCSIMON) $(BINDIR)
|
2020-07-07 19:16:02 +00:00
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_SCSIMON) -lpthread
|
|
|
|
|
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
|
|
|
|
|
|
|
run:
|
2020-07-09 18:21:59 +00:00
|
|
|
sudo ./$(RASCSI) -ID1 /home/pi/HARDDISK2.hda -ID6 /home/pi/marathon.iso
|
|
|
|
|
|
|
|
install: $(MAN_PAGE_DIR)/rascsi.1 $(MAN_PAGE_DIR)/rasctl.1
|
2020-09-02 06:19:24 +00:00
|
|
|
sudo cp $(BINDIR)/$(RASCTL) $(USR_LOCAL_BIN)
|
|
|
|
sudo cp $(BINDIR)/$(RASCSI) $(USR_LOCAL_BIN)
|
2020-07-09 18:21:59 +00:00
|
|
|
|
|
|
|
$(MAN_PAGE_DIR)/%.1 : $(DOC_DIR)/%.1
|
|
|
|
sudo cp $< $@
|
|
|
|
|
|
|
|
$(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
|
|
|
|
|
|
|
.PHONY: Debug
|
2020-07-09 22:57:13 +00:00
|
|
|
Debug: all
|