From fd14dd8316b1317d3ee2ff28b9d013198be40d70 Mon Sep 17 00:00:00 2001 From: Lee Duncan Date: Sun, 20 Mar 2022 16:12:40 -0700 Subject: 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. --- usr/Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'usr') diff --git a/usr/Makefile b/usr/Makefile index fe7430a..e7ba803 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -4,6 +4,11 @@ ifeq ($(TOPDIR),) TOPDIR = .. endif +INSTALL = install + +DESTDR ?= +SBINDIR ?= $(DESTDIR)/sbin + OSNAME=$(shell uname -s) # allow users to override these @@ -46,7 +51,9 @@ LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd) else CFLAGS += -DNO_SYSTEMD endif -PROGRAMS = iscsid iscsiadm iscsistart + +PROGRAMS = iscsid iscsiadm iscsistart +PROGRAMS_DEST = $(addprefix $(SBINDIR)/,$(PROGRAMS)) # libc compat files SYSDEPS_SRCS = $(sort $(wildcard ../utils/sysdeps/*.o)) @@ -77,6 +84,15 @@ iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o mntcheck iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \ iscsistart.o statics.o $(CC) $(CFLAGS) $^ -o $@ -lcrypto -lrt $(LDFLAGS) $(ISCSI_LIB) + +install: $(SBINDIR) $(PROGRAMS_DEST) + +$(SBINDIR): + [ -d $@ ] || $(INSTALL) -d $@ + +$(PROGRAMS_DEST): $(SBINDIR)/%: % + $(INSTALL) -m 755 $? $@ + clean: rm -f *.o $(PROGRAMS) .depend $(LIBSYS) -- cgit v1.2.1