Skip to content

Commit

Permalink
Stop installing multiple copies of the shared library.
Browse files Browse the repository at this point in the history
This is never linked into programs by ld, so the symlink redirections from .so
and soname are not required.  Moreover, the Debian package was ending up with
three copies of the same file (rather than one file and two symlinks).

The only copy will be installed as libnss_cache.so.2, to meet the API for NSS
which expects to load libnss_<service>.so.<x>, where x is 2 for glibc 2.1 and
later (see nsswitch.conf(5)).
  • Loading branch information
bodea committed Dec 5, 2024
1 parent 915c7e6 commit 5824715
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
CC ?= gcc
CFLAGS ?= -Wall -Wstrict-prototypes
CFLAGS += -fPIC
LIBRARY=libnss_cache.so
LIBRARY=libnss_cache.so.2
PREFIX=$(DESTDIR)/usr
LIBDIR=$(PREFIX)/lib
SONAME=libnss_cache.so.2
LD_SONAME=-Wl,-soname,$(SONAME)
TESTDATA=.testdata

LIBNSSCACHE = nss_cache.o compat/getpwent_r.o compat/getgrent_r.o
Expand Down Expand Up @@ -119,24 +117,18 @@ $(GETENT_DATA_TOUCH): scripts/gentestdata.sh

last_pw_errno_test: test/last_pw_errno_test.c

$(LIBRARY): LDFLAGS += -shared $(LD_SONAME)
$(LIBRARY): LDFLAGS += -shared
$(LIBRARY): $(LIBNSSCACHE)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(LIBRARY) $+

$(SONAME): $(LIBRARY)
ln -sf $(LIBRARY) $(SONAME)
ln -sf $(LIBRARY) $(SONAME).0

.PHONY: install
install: $(SONAME)
install: $(LIBRARY)
install -d $(LIBDIR)
install $(LIBRARY) $(LIBDIR)
install $(SONAME) $(LIBDIR)
install $(SONAME).0 $(LIBDIR)

.PHONY: clean
clean:
rm -f $(LIBRARY)* *.o compat/*.o *.gcov *.gcda *.gcno compat/*.gcda compat/*.gcno lookup gen_getent last_pw_errno_test
rm -f $(LIBRARY) *.o compat/*.o *.gcov *.gcda *.gcno compat/*.gcda compat/*.gcno lookup gen_getent last_pw_errno_test

.PHONY: veryclean
veryclean: clean
Expand Down

0 comments on commit 5824715

Please sign in to comment.