mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +00:00
Updated makefile to automatically configure systemd and rsyslog (#32)
* Corrected rascsi service and rsyslog configs. Updated makefile to install these configs * Removed systemd service commands. Added a 'help' target that prints information about how to use this Makefile Co-authored-by: akuker <akuker@gmail.com>
This commit is contained in:
parent
bb379b8274
commit
a50fcbde5c
@ -1,11 +1,23 @@
|
||||
.DEFAULT_GOAL: all
|
||||
|
||||
## 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
|
||||
ARCH ?= arm
|
||||
CROSS_COMPILE ?= arm-linux-gnueabihf-
|
||||
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
|
||||
## DEBUG=1 : A Debug build includes the debugger symbols
|
||||
## and disables compiler optimization. Typically,
|
||||
## this is only used by developers.
|
||||
DEBUG ?= 0
|
||||
ifeq ($(DEBUG), 1)
|
||||
# Debug CFLAGS
|
||||
@ -21,6 +33,11 @@ endif
|
||||
CFLAGS += -iquote . -MD -MP
|
||||
CXXFLAGS += -std=c++14 -iquote . -MD -MP
|
||||
|
||||
## CONNECT_TYPE=STANDARD : Specify the type of RaSCSI board type
|
||||
## that you are using. The typical options are
|
||||
## STANDARD or FULLSPEC. The default is STANDARD
|
||||
## * THIS IS TYPICALLY THE ONLY COMPILE OPTION YOU
|
||||
## * NEED TO SPECIFY
|
||||
# If its not specified, build for STANDARD configuration
|
||||
CONNECT_TYPE ?= STANDARD
|
||||
|
||||
@ -35,9 +52,14 @@ RASDUMP = rasdump
|
||||
SASIDUMP = sasidump
|
||||
SCSIMON = scsimon
|
||||
|
||||
SYSTEMD_CONF = /etc/systemd/system/rascsi.service
|
||||
RSYSLOG_CONF = /etc/rsyslog.d/rascsi.conf
|
||||
RSYSLOG_LOG = /var/log/rascsi.log
|
||||
|
||||
USR_LOCAL_BIN = /usr/local/bin
|
||||
MAN_PAGE_DIR = /usr/share/man/man1
|
||||
DOC_DIR = ../../doc
|
||||
OS_FILES = ./os_integration
|
||||
|
||||
OBJDIR := ./obj/$(shell echo $(CONNECT_TYPE) | tr '[:upper:]' '[:lower:]')
|
||||
BINDIR := ./bin/$(shell echo $(CONNECT_TYPE) | tr '[:upper:]' '[:lower:]')
|
||||
@ -100,12 +122,16 @@ ALL_DEPS := $(patsubst %.o,%.d,$(OBJ_RASCSI) $(OBJ_RASCTL))
|
||||
-include $(ALL_DEPS)
|
||||
|
||||
$(OBJDIR) $(BINDIR):
|
||||
echo Creating directory $@
|
||||
echo "-- Creating directory $@"
|
||||
mkdir -p $@
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp | $(OBJDIR)
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
## 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
|
||||
.DEFAULT_GOAL := all
|
||||
.PHONY: all ALL docs
|
||||
all: $(BIN_ALL) docs
|
||||
@ -128,23 +154,69 @@ $(SASIDUMP): $(OBJ_SASIDUMP) $(BINDIR)
|
||||
$(SCSIMON): $(OBJ_SCSIMON) $(BINDIR)
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_SCSIMON) -lpthread
|
||||
|
||||
## clean : Remove all of the object files, intermediate
|
||||
## compiler files and executable files
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(OBJDIR) $(BINDIR)
|
||||
|
||||
## run : Launches RaSCSI using some pre-defined drive
|
||||
## images. Useful for debugging when you're building
|
||||
## and re-launching over and over.
|
||||
.PHONY: run
|
||||
run:
|
||||
sudo ./$(RASCSI) -ID1 /home/pi/HARDDISK2.hda -ID6 /home/pi/marathon.iso
|
||||
sudo $(BINDIR)/$(RASCSI) -ID1 /home/pi/HARDDISK2.hda -ID6 /home/pi/marathon.iso
|
||||
|
||||
install: $(MAN_PAGE_DIR)/rascsi.1 $(MAN_PAGE_DIR)/rasctl.1
|
||||
sudo cp $(BINDIR)/$(RASCTL) $(USR_LOCAL_BIN)
|
||||
sudo cp $(BINDIR)/$(RASCSI) $(USR_LOCAL_BIN)
|
||||
## 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
|
||||
install: $(MAN_PAGE_DIR)/rascsi.1 $(MAN_PAGE_DIR)/rasctl.1 $(USR_LOCAL_BIN)/$(RASCTL) $(USR_LOCAL_BIN)/$(RASCSI) $(SYSTEMD_CONF) $(RSYSLOG_CONF) $(RSYSLOG_LOG)
|
||||
@echo "-- Done installing!"
|
||||
|
||||
$(USR_LOCAL_BIN)% : $(BINDIR)/%
|
||||
@echo "-- Copying $@"
|
||||
cp $< $@
|
||||
|
||||
$(MAN_PAGE_DIR)/%.1 : $(DOC_DIR)/%.1
|
||||
sudo cp $< $@
|
||||
@echo "-- Copying $@"
|
||||
cp $< $@
|
||||
|
||||
$(DOC_DIR)/%_man_page.txt : $(DOC_DIR)/%.1
|
||||
@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 >> $@
|
||||
|
||||
$(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.
|
||||
.PHONY: Debug
|
||||
Debug: all
|
||||
|
||||
|
2
src/raspberrypi/os_integration/rascsi.conf
Normal file
2
src/raspberrypi/os_integration/rascsi.conf
Normal file
@ -0,0 +1,2 @@
|
||||
if $programname == 'RASCSI' then /var/log/rascsi.log
|
||||
& stop
|
19
src/raspberrypi/os_integration/rascsi.service
Normal file
19
src/raspberrypi/os_integration/rascsi.service
Normal file
@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=RaSCSI service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecStart=/usr/local/bin/rascsi
|
||||
# Example: If you want to automatically attach a hard disk at startup, change
|
||||
# the ExecStart line to:
|
||||
# ExecStart=/usr/local/bin/rascsi -ID1 /home/pi/images/harddisk.hda
|
||||
ExecStop=/usr/local/bin/rasctl -stop
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=RASCSI
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
Reference in New Issue
Block a user