diff options
author | Lee Duncan <lduncan@suse.com> | 2022-03-20 16:12:40 -0700 |
---|---|---|
committer | Lee Duncan <lduncan@suse.com> | 2022-03-20 16:12:40 -0700 |
commit | fd14dd8316b1317d3ee2ff28b9d013198be40d70 (patch) | |
tree | 285dc501850dd360dbd88dca962ec96059213ca8 /etc/Makefile | |
parent | f64890f2b90b53389e528559115a726072f71844 (diff) | |
download | open-iscsi-fd14dd8316b1317d3ee2ff28b9d013198be40d70.tar.gz |
Clean up Makefile build system.
A major overdue overhaul of the Make layout, including
moving lots of lower-level things out of the top-level
Makefile into the Makefiles for the appropriate subdirectory,
renaming the template files (where @SBINDIR@ gets translated)
so that their purpose is more obvious, making the build more
idempotent (no need to install a file if it's not newer).
Should be no functional change, as no script or C file changed.
Main difference from before: now the udev rules gets made and
installed by default (as part of "make"/"make install"), and
the iscsiuio daemon is now installed for "make install".
One should now be able to go into any subdirectory and type
"make"/"make install" to build and install the targets from
that directory, at least for the etc, utils, and usr
subdirectories.
This change is in preparation for more template translations
coming.
Diffstat (limited to 'etc/Makefile')
-rw-r--r-- | etc/Makefile | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/etc/Makefile b/etc/Makefile new file mode 100644 index 0000000..8a7d7c0 --- /dev/null +++ b/etc/Makefile @@ -0,0 +1,81 @@ +# +# gnu Makefile for the etc subdirectory, including +# initd and systemd subdirectories +# + +prefix = /usr +DESTDIR ?= +SBINDIR ?= $(DESTDIR)/sbin + +systemddir ?= $(DESTDIR)$(prefix)/lib/systemd +etcdir = $(DESTDIR)/etc +initddir ?= $(etcdir)/init.d + +HOMEDIR ?= $(etcdir)/iscsi + +SED = /usr/bin/sed +INSTALL = install + +SYSTEMD_SOURCE_FILES = iscsid.socket iscsiuio.socket +SYSTEMD_SOURCES = $(addprefix systemd/,$(SYSTEMD_SOURCE_FILES)) +SYSTEMD_TEMPLATE_FILES = iscsi-init.service.template \ + iscsid.service.template \ + iscsi.service.template \ + iscsiuio.service.template +SYSTEMD_TEMPLATES = $(addprefix systemd/,$(SYSTEMD_TEMPLATE_FILES)) +SYSTEMD_GENERATED_SERVICE_FILES = $(SYSTEMD_TEMPLATES:.template=) +SYSTEMD_DEST_FILES = $(addprefix $(systemddir)/system/,$(notdir $(SYSTEMD_SOURCES))) \ + $(addprefix $(systemddir)/system/,$(notdir $(SYSTEMD_GENERATED_SERVICE_FILES))) +IFACE_FILES = iface.example +IFACE_DEST_FILES = $(addprefix $(HOMEDIR)/ifaces/,$(IFACE_FILES)) +ETC_FILES = iscsid.conf +ETC_DEST_FILES = $(addprefix $(HOMEDIR)/,$(ETC_FILES)) + +all: $(SYSTEMD_SOURCES) $(SYSTEMD_GENERATED_SERVICE_FILES) + +$(SYSTEMD_GENERATED_SERVICE_FILES): systemd/%.service: systemd/%.service.template + $(SED) -e 's:@SBINDIR@:$(SBINDIR):' $? > $@ + +install: install_systemd install_iface install_etc + +install_iface: $(IFACE_DEST_FILES) + +$(IFACE_DEST_FILES): $(HOMEDIR)/ifaces/%: % + $(INSTALL) -m 644 $? $@ + +install_etc: $(ETC_DEST_FILES) + +$(ETC_DEST_FILES): $(HOMEDIR)/%: % + $(INSTALL) -m 644 $? $@ + +install_initd_distro = $(INSTALL) -m 755 $(1) $(initddir)/open-iscsi/ + +install_initd: $(initddir)/open-iscsi + @if [ -f /etc/debian_version ]; then \ + $(call install_initd_distro,initd/initd.redhat) ; \ + elif [ -f /etc/redhat-release ]; then \ + $(call install_initd_distro,initd/initd.debian) ; \ + fi + +$(initddir)/open-iscsi: + [ -d $@ ] || $(INSTALL) -d $@ + +install_initd_redhat: $(initddir)/open-iscsi + $(call install_initd_distro,initd/initd.redhat) + +install_initd_debian: $(initddir)/open-iscsi + $(call install_initd_distro,initd/initd.debian) + +install_systemd: $(systemddir)/system $(SYSTEMD_DEST_FILES) + +$(systemddir)/system: + [ -d $@ ] || $(INSTALL) -d -m 775 $@ + +$(SYSTEMD_DEST_FILES): $(systemddir)/system/%: systemd/% + $(INSTALL) $? $@ + +clean: + $(RM) $(SYSTEMD_GENERATED_SERVICE_FILES) + +.PHONY: all clean install install_iface install_initd install_initd_redhat \ + install_initd_debian install_systemd |