From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Thu, 27 Oct 2022 22:18:22 +0200 Subject: [PATCH] multipath-tools: Makefiles: move common code to rules.mk The library Makefiles contain a lot of similar rules. Just maintain them in a single file. Signed-off-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- libmpathcmd/Makefile | 13 +------------ libmpathpersist/Makefile | 13 +------------ libmpathutil/Makefile | 13 +------------ libmpathvalid/Makefile | 13 ++----------- libmultipath/Makefile | 16 ++-------------- rules.mk | 15 +++++++++++++++ 6 files changed, 22 insertions(+), 61 deletions(-) create mode 100644 rules.mk diff --git a/libmpathcmd/Makefile b/libmpathcmd/Makefile index f705c7f0..cfb202b8 100644 --- a/libmpathcmd/Makefile +++ b/libmpathcmd/Makefile @@ -6,18 +6,7 @@ OBJS := mpath_cmd.o all: $(DEVLIB) -$(LIBS): $(OBJS) $(VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -$(LIBS:%.so.$(SONAME)=%-nv.so): $(OBJS) $(NV_VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(NV_VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -abi: $(LIBS:%.so.$(SONAME)=%-nv.abi) - -$(DEVLIB): $(LIBS) - $(LN) $(LIBS) $@ +include $(TOPDIR)/rules.mk install: all $(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir) diff --git a/libmpathpersist/Makefile b/libmpathpersist/Makefile index 6f69168f..94672556 100644 --- a/libmpathpersist/Makefile +++ b/libmpathpersist/Makefile @@ -9,18 +9,7 @@ OBJS := mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o mpath_persist_int.o all: $(DEVLIB) -$(LIBS): $(OBJS) $(VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -$(LIBS:%.so.$(SONAME)=%-nv.so): $(OBJS) $(NV_VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(NV_VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -abi: $(LIBS:%.so.$(SONAME)=%-nv.abi) - -$(DEVLIB): $(LIBS) - $(LN) $(LIBS) $@ +include $(TOPDIR)/rules.mk install: all $(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir) diff --git a/libmpathutil/Makefile b/libmpathutil/Makefile index 5665af28..5ab33c09 100644 --- a/libmpathutil/Makefile +++ b/libmpathutil/Makefile @@ -17,18 +17,7 @@ OBJS := parser.o vector.o util.o debug.o time-util.o \ all: $(DEVLIB) -$(LIBS): $(OBJS) $(VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -$(DEVLIB): $(LIBS) - $(LN) $(LIBS) $@ - -$(LIBS:%.so.$(SONAME)=%-nv.so): $(OBJS) $(NV_VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(NV_VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -abi: $(LIBS:%.so.$(SONAME)=%-nv.abi) +include $(TOPDIR)/rules.mk install: all $(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir) diff --git a/libmpathvalid/Makefile b/libmpathvalid/Makefile index bd4ccc0d..88034df3 100644 --- a/libmpathvalid/Makefile +++ b/libmpathvalid/Makefile @@ -8,18 +8,9 @@ LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath \ OBJS := mpath_valid.o -all: $(LIBS) +all: $(DEVLIB) -$(LIBS): $(OBJS) $(VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ -o $@ $(OBJS) $(LIBDEPS) \ - -Wl,--version-script=$(VERSION_SCRIPT) - $(LN) $(LIBS) $(DEVLIB) - -$(LIBS:%.so.$(SONAME)=%-nv.so): $(OBJS) $(NV_VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(NV_VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -abi: $(LIBS:%.so.$(SONAME)=%-nv.abi) +include $(TOPDIR)/rules.mk install: $(LIBS) $(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)$(syslibdir) diff --git a/libmultipath/Makefile b/libmultipath/Makefile index 9dc229ae..e24eab8a 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -56,6 +56,8 @@ OBJS := $(OBJS-O) $(OBJS-U) all: $(DEVLIB) +include $(TOPDIR)/rules.mk + nvme-lib.o: nvme-lib.c nvme-ioctl.c nvme-ioctl.h $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused-function -c -o $@ $< @@ -72,20 +74,6 @@ nvme-ioctl.c: nvme/nvme-ioctl.c nvme-ioctl.h: nvme/nvme-ioctl.h $(call make_static,$<,$@) - -$(LIBS): $(OBJS) $(VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -$(DEVLIB): $(LIBS) - $(LN) $(LIBS) $@ - -$(LIBS:%.so.$(SONAME)=%-nv.so): $(OBJS) $(NV_VERSION_SCRIPT) - $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ - -Wl,--version-script=$(NV_VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) - -abi: $(LIBS:%.so.$(SONAME)=%-nv.abi) - ../tests/$(LIBS): $(OBJS-O) $(OBJS-T) $(VERSION_SCRIPT) $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=`basename $@` \ -o $@ $(OBJS-O) $(OBJS-T) $(LIBDEPS) diff --git a/rules.mk b/rules.mk new file mode 100644 index 00000000..c1d80820 --- /dev/null +++ b/rules.mk @@ -0,0 +1,15 @@ +# Copyright (c) SUSE LLC +# SPDX-License-Identifier: GPL-2.0-or-later + +$(DEVLIB): $(LIBS) + $(LN) $(LIBS) $@ + +$(LIBS): $(OBJS) $(VERSION_SCRIPT) + $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ + -Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) + +$(LIBS:%.so.$(SONAME)=%-nv.so): $(OBJS) $(NV_VERSION_SCRIPT) + $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ + -Wl,--version-script=$(NV_VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) + +abi: $(LIBS:%.so.$(SONAME)=%-nv.abi)