[PATCH libaio 02/16] build: Fix DESTDIR and pathname variables handling
authorGuillem Jover <guillem@hadrons.org>
Sun, 12 Apr 2020 01:58:12 +0000 (03:58 +0200)
committerGuillem Jover <guillem@debian.org>
Sun, 6 Aug 2023 19:12:34 +0000 (20:12 +0100)
The convention for DESTDIR is that it is only prefixed during the
install target. In this case we postpone that to the inner Makefile
so that it can be invoked directly while preserving the expected
semantics. We should also prefer the user specified pathname variables
if already set in any way, and do not need to pass them explicitly
to the sub-make.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Gbp-Pq: Name 0002-build-Fix-DESTDIR-and-pathname-variables-handling.patch

Makefile
src/Makefile

index c1fb831bc6e72db9af0332966d8c6dd9af6290cc..c194d9efa0efe421df6b7521bce38e95c96b0a70 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,17 +4,13 @@ VERSION=$(shell awk '/Version:/ { print $$2 }' $(SPECFILE))
 TAG = $(NAME)-$(VERSION)
 RPMBUILD=$(shell `which rpmbuild >&/dev/null` && echo "rpmbuild" || echo "rpm")
 
-prefix=/usr
-includedir=$(prefix)/include
-libdir=$(prefix)/lib
-
 default: all
 
 all:
        @$(MAKE) -C src
 
 install:
-       @$(MAKE) -C src install prefix=$(DESTDIR)$(prefix) includedir=$(DESTDIR)$(includedir) libdir=$(DESTDIR)$(libdir)
+       @$(MAKE) -C src install
 
 check:
        @$(MAKE) -C harness check
index d080a1b32a883586efc726187adada6dc1ea0563..9a36d0d03fba1fb91c263f8d4927a53e5395af82 100644 (file)
@@ -1,6 +1,6 @@
-prefix=/usr
-includedir=$(prefix)/include
-libdir=$(prefix)/lib
+prefix ?= /usr
+includedir ?= $(prefix)/include
+libdir ?= $(prefix)/lib
 
 CFLAGS ?= -g -fomit-frame-pointer -O2
 CFLAGS += -Wall -I. -fPIC
@@ -59,12 +59,12 @@ $(libname): $(libaio_sobjs) libaio.map
        $(CC) $(SO_CFLAGS) -Wl,--version-script=libaio.map -Wl,-soname=$(soname) -o $@ $(libaio_sobjs) $(LINK_FLAGS)
 
 install: $(all_targets)
-       install -D -m 644 libaio.h $(includedir)/libaio.h
-       install -D -m 644 libaio.a $(libdir)/libaio.a
+       install -D -m 644 libaio.h $(DESTDIR)$(includedir)/libaio.h
+       install -D -m 644 libaio.a $(DESTDIR)$(libdir)/libaio.a
 ifeq ($(ENABLE_SHARED),1)
-       install -D -m 755 $(libname) $(libdir)/$(libname)
-       ln -sf $(libname) $(libdir)/$(soname)
-       ln -sf $(libname) $(libdir)/libaio.so
+       install -D -m 755 $(libname) $(DESTDIR)$(libdir)/$(libname)
+       ln -sf $(libname) $(DESTDIR)$(libdir)/$(soname)
+       ln -sf $(libname) $(DESTDIR)$(libdir)/libaio.so
 endif
 
 $(libaio_objs): libaio.h