Makefile : réécriture
This commit is contained in:
parent
58473c78ab
commit
801939096d
1 changed files with 27 additions and 50 deletions
77
Makefile
77
Makefile
|
@ -1,65 +1,42 @@
|
||||||
|
# SRC = source
|
||||||
|
# DST = destination
|
||||||
|
# *D = folder containing *
|
||||||
|
|
||||||
NAME := qemush
|
NAME := qemush
|
||||||
|
|
||||||
# qemu Unix user
|
|
||||||
QEMU_USER := qemu
|
QEMU_USER := qemu
|
||||||
# sudo as qemu
|
|
||||||
SUDO_QEMU := sudo -u $(QEMU_USER)
|
|
||||||
|
|
||||||
QEMUSH := /usr/local/bin/$(NAME)
|
SRC_BIN := bin/$(NAME)
|
||||||
SRC_QEMUSH := bin/$(NAME)
|
DST_BIN := /usr/local/$(SRC_BIN)
|
||||||
SRCD := src
|
|
||||||
|
|
||||||
# This repo's equivalent of effective qemu Unix user home
|
SRC_HOME := $(QEMU_USER)
|
||||||
SRC_QEMU_HOME := qemu
|
DST_HOME := $(shell echo ~$(QEMU_USER))
|
||||||
SRC_QEMU_BIN := $(SRC_QEMU_HOME)/bin
|
|
||||||
SRC_LAUNCHERSD := $(SRC_QEMU_HOME)/launchers
|
|
||||||
# Actual qemu Unix user home
|
|
||||||
QEMU_HOME := $(shell echo ~$(QEMU_USER))
|
|
||||||
QEMU_BIN := $(QEMU_HOME)/bin
|
|
||||||
LAUNCHERSD := $(QEMU_HOME)/launchers
|
|
||||||
|
|
||||||
# Names of all qemush modules
|
SRC_BIND := $(SRC_HOME)/bin
|
||||||
SRC_MODULES_NAMES := $(notdir $(wildcard $(SRC_QEMU_BIN)/*))
|
SRC_LAUNCHERSD := $(SRC_HOME)/launchers
|
||||||
# Target location of modules
|
DST_BIND := $(DST_HOME)/bin
|
||||||
MODULES := $(addprefix $(QEMU_BIN)/,$(SRC_MODULES_NAMES))
|
DST_LAUNCHERSD := $(DST_HOME)/launchers
|
||||||
# Names of launchers scripts
|
|
||||||
SRC_LAUNCHERS_NAMES := $(notdir $(wildcard $(SRC_LAUNCHERSD)/*))
|
|
||||||
# Target location of launchers
|
|
||||||
LAUNCHERS := $(addprefix $(LAUNCHERSD)/,$(SRC_LAUNCHERS_NAMES))
|
|
||||||
# Mode to apply
|
|
||||||
BINS_MODE := 740
|
|
||||||
|
|
||||||
# Compiler options
|
MODULES_NAMES := $(notdir $(wildcard $(SRC_BIND)/*))
|
||||||
CC := cc
|
LAUNCHERS_NAMES := $(notdir $(wildcard $(SRC_LAUNCHERSD)/*))
|
||||||
CC_OPTIONS = -O2
|
|
||||||
# C sources file format
|
|
||||||
SRC_FMT := .c
|
|
||||||
# Names of C programs to compile
|
|
||||||
SRC_C_SOURCES_NAMES := $(notdir $(basename $(wildcard $(SRCD)/*$(SRC_FMT))))
|
|
||||||
# Location of C binaries
|
|
||||||
C_BINARIES := $(addprefix $(QEMU_BIN)/,$(SRC_C_SOURCES_NAMES))
|
|
||||||
|
|
||||||
# Directories in ~qemu necessary for qemush to work
|
DST_MODULES := $(addprefix $(DST_BIND)/,$(MODULES_NAMES))
|
||||||
QEMUSH_DIRS_NAMES := bin launchers disks sockets/monitors sockets/spice
|
DST_LAUNCHERS := $(addprefix $(DST_LAUNCHERSD)/,$(LAUNCHERS_NAMES))
|
||||||
QEMUSH_DIRS := $(addprefix $(QEMU_HOME)/,$(QEMUSH_DIRS_NAMES))
|
|
||||||
|
QEMUSH_DIRS := $(addprefix $(DST_HOME)/,bin launchers disks sockets/monitors sockets/spice)
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
|
|
||||||
install: $(QEMUSH_DIRS) $(MODULES) $(C_BINARIES) $(QEMUSH) $(LAUNCHERS)
|
install: $(QEMUSH_DIRS) $(DST_MODULES) $(DST_BIN) $(DST_LAUNCHERS)
|
||||||
|
|
||||||
$(QEMUSH_DIRS):
|
$(QEMUSH_DIRS):
|
||||||
$(SUDO_QEMU) mkdir -p $@
|
sudo -u $(QEMU_USER) mkdir -p -- $@
|
||||||
$(SUDO_QEMU) chmod 750 $@
|
sudo -u $(QEMU_USER) chmod -- 750 $@
|
||||||
|
|
||||||
$(QEMUSH): $(SRC_QEMUSH)
|
$(DST_BIN): $(SRC_BIN)
|
||||||
sudo install -m 755 $^ $@
|
sudo install -m 755 -- $^ $@
|
||||||
|
|
||||||
$(MODULES): $(QEMU_HOME)%: $(SRC_QEMU_HOME)%
|
$(DST_MODULES): $(DST_HOME)%: $(SRC_HOME)%
|
||||||
$(SUDO_QEMU) install -m $(BINS_MODE) $^ $@
|
sudo -u $(QEMU_USER) install -m 740 -- $^ $@
|
||||||
|
|
||||||
$(C_BINARIES): $(QEMU_BIN)%: $(SRCD)%$(SRC_FMT)
|
$(LAUNCHERS): $(DST_LAUNCHERSD)%: $(SRC_LAUNCHERSD)%
|
||||||
$(SUDO_QEMU) $(CC) $(CC_OPTIONS) -o $@ $^
|
sudo -u $(QEMU_USER) install -m 740 -- $^ $@
|
||||||
$(SUDO_QEMU) chmod $(BINS_MODE) $@
|
|
||||||
|
|
||||||
$(LAUNCHERS): $(LAUNCHERSD)%: $(SRC_LAUNCHERSD)%
|
|
||||||
$(SUDO_QEMU) install -m $(BINS_MODE) $^ $@
|
|
||||||
|
|
Loading…
Reference in a new issue