summaryrefslogtreecommitdiff
path: root/utils/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'utils/Makefile')
-rw-r--r--utils/Makefile27
1 files changed, 15 insertions, 12 deletions
diff --git a/utils/Makefile b/utils/Makefile
index 92af01e..250b77e 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -12,33 +12,35 @@ INSTALL = install
CHMOD = chmod
DESTDIR ?=
-SBINDIR ?= $(DESTDIR)/sbin
+SBINDIR ?= /sbin
+etcdir = /etc
+HOMEDIR ?= $(etcdir)/iscsi
-ETCDIR = $(DESTDIR)/etc
+ETCDIR = /etc
RULESDIR = $(ETCDIR)/udev/rules.d
CFLAGS ?= -O2 -fno-inline -g
CFLAGS += -Wall -Wextra -Wstrict-prototypes
PROGRAMS = iscsi-iname
-PROGRAMS_DEST = $(addprefix $(SBINDIR)/,$(PROGRAMS))
+PROGRAMS_DEST = $(addprefix $(DESTDIR)$(SBINDIR)/,$(PROGRAMS))
SCRIPTS_SOURCES = iscsi_discovery.sh iscsi_offload.sh
SCRIPTS_TEMPLATES = iscsi_fw_login.sh.template iscsi-gen-initiatorname.sh.template
SCRIPTS_GENERATED = $(SCRIPTS_TEMPLATES:.template=)
-SCRIPTS_DEST = $(addprefix $(SBINDIR)/,$(basename $(SCRIPTS_GENERATED))) \
- $(addprefix $(SBINDIR)/,$(basename $(SCRIPTS_SOURCES)))
+SCRIPTS_DEST = $(addprefix $(DESTDIR)$(SBINDIR)/,$(basename $(SCRIPTS_GENERATED))) \
+ $(addprefix $(DESTDIR)$(SBINDIR)/,$(basename $(SCRIPTS_SOURCES)))
RULESFILES_TEMPLATES = 50-iscsi-firmware-login.rules.template
RULESFILES_GENERATED = $(RULESFILES_TEMPLATES:.template=)
-RULESFILES_DEST = $(addprefix $(RULESDIR)/,$(RULESFILES_GENERATED))
+RULESFILES_DEST = $(addprefix $(DESTDIR)$(RULESDIR)/,$(RULESFILES_GENERATED))
OBJS = iscsi-iname.o md5.o
all: $(PROGRAMS) $(SCRIPTS_GENERATED) $(RULESFILES_GENERATED)
$(SCRIPTS_GENERATED): %.sh: %.sh.template
- $(SED) -e 's:@SBINDIR@:$(SBINDIR):' $? > $@
+ $(SED) -e 's:@SBINDIR@:$(SBINDIR):' -e 's:@HOMEDIR@:$(HOMEDIR):' $? > $@
$(CHMOD) 755 $@
$(RULESFILES_GENERATED): %.rules: %.rules.template
@@ -47,20 +49,21 @@ $(RULESFILES_GENERATED): %.rules: %.rules.template
iscsi-iname: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(DBM_LIB) -o $@
-install: $(SBINDIR) $(RULESDIR) $(PROGRAMS_DEST) $(SCRIPTS_DEST) $(RULESFILES_DEST)
+install: $(DESTDIR)$(SBINDIR) $(DESTDIR)$(RULESDIR) \
+ $(PROGRAMS_DEST) $(SCRIPTS_DEST) $(RULESFILES_DEST)
-$(PROGRAMS_DEST): $(SBINDIR)/%: %
+$(PROGRAMS_DEST): $(DESTDIR)$(SBINDIR)/%: %
$(INSTALL) -m 755 $? $@
-$(SCRIPTS_DEST): $(SBINDIR)/%: %.sh
+$(SCRIPTS_DEST): $(DESTDIR)$(SBINDIR)/%: %.sh
$(INSTALL) -m 755 $? $@
install_udev_rules: $(RULESFILES_DEST)
-$(RULESFILES_DEST): $(RULESDIR)/%: %
+$(RULESFILES_DEST): $(DESTDIR)$(RULESDIR)/%: %
$(INSTALL) -m 644 $? $@
-$(SBINDIR) $(RULESDIR):
+$(DESTDIR)$(SBINDIR) $(DESTDIR)$(RULESDIR):
[ -d $@ ] || $(INSTALL) -d $@
clean: