2023-12-10 17:36:13 +01:00
|
|
|
NAME := qemush
|
|
|
|
|
|
|
|
# qemu Unix user
|
|
|
|
QEMU_USER := qemu
|
|
|
|
# sudo as qemu
|
|
|
|
SUDO_QEMU := sudo -u $(QEMU_USER)
|
|
|
|
|
|
|
|
QEMUSH := /usr/local/bin/$(NAME)
|
|
|
|
SRC_QEMUSH := bin/$(NAME)
|
2023-12-12 12:45:14 +01:00
|
|
|
SRCD := src
|
2023-12-10 17:36:13 +01:00
|
|
|
|
|
|
|
# This repo's equivalent of effective qemu Unix user home
|
|
|
|
SRC_QEMU_HOME := qemu
|
|
|
|
SRC_QEMU_BIN := $(SRC_QEMU_HOME)/bin
|
2023-12-13 13:00:20 +01:00
|
|
|
SRC_LAUNCHERSD := $(SRC_QEMU_HOME)/launchers
|
2023-12-10 17:36:13 +01:00
|
|
|
# Actual qemu Unix user home
|
|
|
|
QEMU_HOME := $(shell echo ~$(QEMU_USER))
|
|
|
|
QEMU_BIN := $(QEMU_HOME)/bin
|
2023-12-13 13:00:20 +01:00
|
|
|
LAUNCHERSD := $(QEMU_HOME)/launchers
|
2023-12-10 17:36:13 +01:00
|
|
|
|
|
|
|
# Names of all qemush modules
|
|
|
|
SRC_MODULES_NAMES := $(notdir $(wildcard $(SRC_QEMU_BIN)/*))
|
|
|
|
# Target location of modules
|
|
|
|
MODULES := $(addprefix $(QEMU_BIN)/,$(SRC_MODULES_NAMES))
|
2023-12-13 13:00:20 +01:00
|
|
|
# Names of launchers scripts
|
|
|
|
SRC_LAUNCHERS_NAMES := $(notdir $(wildcard $(SRC_LAUNCHERSD)/*))
|
|
|
|
# Target location of launchers
|
|
|
|
LAUNCHERS := $(addprefix $(LAUNCHERSD)/,$(SRC_LAUNCHERS_NAMES))
|
2023-12-10 17:36:13 +01:00
|
|
|
# Mode to apply
|
|
|
|
BINS_MODE := 740
|
|
|
|
|
|
|
|
# Compiler options
|
|
|
|
CC := cc
|
2024-01-21 00:22:04 +01:00
|
|
|
CC_OPTIONS = -O2
|
2023-12-10 17:36:13 +01:00
|
|
|
# C sources file format
|
2023-12-12 12:45:14 +01:00
|
|
|
SRC_FMT := .c
|
2023-12-10 17:36:13 +01:00
|
|
|
# Names of C programs to compile
|
2023-12-12 12:45:14 +01:00
|
|
|
SRC_C_SOURCES_NAMES := $(notdir $(basename $(wildcard $(SRCD)/*$(SRC_FMT))))
|
2023-12-10 17:36:13 +01:00
|
|
|
# Location of C binaries
|
|
|
|
C_BINARIES := $(addprefix $(QEMU_BIN)/,$(SRC_C_SOURCES_NAMES))
|
|
|
|
|
2023-12-10 17:56:27 +01:00
|
|
|
# Directories in ~qemu necessary for qemush to work
|
|
|
|
QEMUSH_DIRS_NAMES := bin launchers images
|
|
|
|
QEMUSH_DIRS := $(addprefix $(QEMU_HOME)/,$(QEMUSH_DIRS_NAMES))
|
|
|
|
|
2023-12-13 13:00:20 +01:00
|
|
|
install: $(QEMUSH_DIRS) $(MODULES) $(C_BINARIES) $(QEMUSH) $(LAUNCHERS)
|
2023-12-10 17:56:27 +01:00
|
|
|
|
|
|
|
$(QEMUSH_DIRS):
|
|
|
|
$(SUDO_QEMU) mkdir -p $@
|
2023-12-12 12:45:14 +01:00
|
|
|
$(SUDO_QEMU) chmod 750 $@
|
2023-12-10 17:36:13 +01:00
|
|
|
|
|
|
|
$(QEMUSH): $(SRC_QEMUSH)
|
|
|
|
sudo install -m 755 $^ $@
|
|
|
|
|
|
|
|
$(MODULES): $(QEMU_HOME)%: $(SRC_QEMU_HOME)%
|
|
|
|
$(SUDO_QEMU) install -m $(BINS_MODE) $^ $@
|
|
|
|
|
2023-12-12 12:45:14 +01:00
|
|
|
$(C_BINARIES): $(QEMU_BIN)%: $(SRCD)%$(SRC_FMT)
|
|
|
|
$(SUDO_QEMU) $(CC) $(CC_OPTIONS) -o $@ $^
|
2023-12-10 17:36:13 +01:00
|
|
|
$(SUDO_QEMU) chmod $(BINS_MODE) $@
|
2023-12-13 13:00:20 +01:00
|
|
|
|
|
|
|
$(LAUNCHERS): $(LAUNCHERSD)%: $(SRC_LAUNCHERSD)%
|
|
|
|
$(SUDO_QEMU) install -m $(BINS_MODE) $^ $@
|