$NetBSD: patch-librhash_Makefile,v 1.5 2024/10/14 13:04:00 adam Exp $

libtoolize.

--- librhash/Makefile.orig	2024-10-13 23:43:50.000000000 +0000
+++ librhash/Makefile
@@ -4,7 +4,7 @@ include config.mak
 
 HEADERS = algorithms.h byte_order.h plug_openssl.h rhash.h rhash_torrent.h aich.h blake2b.h blake2s.h crc32.h ed2k.h edonr.h hex.h md4.h md5.h sha1.h sha256.h sha512.h sha3.h ripemd-160.h gost12.h gost94.h has160.h snefru.h tiger.h tth.h torrent.h ustd.h util.h whirlpool.h
 SOURCES = algorithms.c byte_order.c plug_openssl.c rhash.c rhash_torrent.c aich.c blake2b.c blake2s.c crc32.c ed2k.c edonr.c hex.c md4.c md5.c sha1.c sha256.c sha512.c sha3.c ripemd-160.c gost12.c gost94.c has160.c snefru.c tiger.c tiger_sbox.c tth.c torrent.c util.c whirlpool.c whirlpool_sbox.c
-OBJECTS = $(SOURCES:.c=.o)
+OBJECTS = $(SOURCES:.c=.lo)
 LIB_HEADERS = rhash.h rhash_torrent.h
 TEST_STATIC = test_static$(EXEC_EXT)
 TEST_SHARED = test_shared$(EXEC_EXT)
@@ -26,10 +26,7 @@ install-lib-static: $(LIBRHASH_STATIC)
 
 install-lib-shared: $(LIBRHASH_SHARED) $(EXTRA_INSTALL_LIBSHARED)
 	$(INSTALL) -d $(SO_DIR)
-	$(INSTALL_SHARED) $(LIBRHASH_SHARED) $(SO_DIR)/
-	test "x$(LIBRHASH_SO_MAJ)" = "x$(LIBRHASH_SHARED)" || ( \
-	  rm -f $(LIBDIR)/$(LIBRHASH_SO_MAJ) && \
-	  ln -s $(LIBRHASH_SHARED) $(LIBDIR)/$(LIBRHASH_SO_MAJ) )
+	$(LIBTOOL) --mode=install --tag=CC $(INSTALL_SHARED) $(LIBRHASH_SHARED) $(SO_DIR)/
 
 install-implib:
 	$(INSTALL) -d $(LIBDIR)
@@ -63,111 +60,10 @@ uninstall-lib-headers:
 #%.o: %.c
 #	$(CC) -c $(CFLAGS) $< -o $@
 
-# NOTE: dependences were generated by 'gcc -MM -DUSE_OPENSSL *.c'
-# we are using plain old makefile style to support BSD make
-aich.o: aich.c aich.h algorithms.h rhash.h byte_order.h ustd.h sha1.h \
- util.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-algorithms.o: algorithms.c algorithms.h rhash.h byte_order.h ustd.h \
- aich.h sha1.h blake2b.h blake2s.h crc32.h ed2k.h md4.h edonr.h gost12.h \
- gost94.h has160.h md5.h ripemd-160.h snefru.h sha256.h sha512.h sha3.h \
- tiger.h torrent.h tth.h whirlpool.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-blake2b.o: blake2b.c blake2b.h ustd.h byte_order.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-blake2s.o: blake2s.c blake2s.h ustd.h byte_order.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-byte_order.o: byte_order.c byte_order.h ustd.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-crc32.o: crc32.c byte_order.h ustd.h crc32.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-ed2k.o: ed2k.c ed2k.h md4.h ustd.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-edonr.o: edonr.c byte_order.h ustd.h edonr.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-gost12.o: gost12.c gost12.h ustd.h byte_order.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-gost94.o: gost94.c gost94.h ustd.h byte_order.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-has160.o: has160.c byte_order.h ustd.h has160.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-hex.o: hex.c hex.h ustd.h util.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-md4.o: md4.c byte_order.h ustd.h md4.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-md5.o: md5.c byte_order.h ustd.h md5.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-plug_openssl.o: plug_openssl.c
-	$(CC) -c $(CFLAGS) $< -o $@
-
-rhash.o: rhash.c rhash.h algorithms.h byte_order.h ustd.h hex.h \
- plug_openssl.h torrent.h sha1.h util.h
-	$(CC) -c $(CFLAGS) $(VERSION_CFLAGS) $< -o $@
-
-rhash_torrent.o: rhash_torrent.c rhash_torrent.h algorithms.h rhash.h \
- byte_order.h ustd.h torrent.h sha1.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-ripemd-160.o: ripemd-160.c byte_order.h ustd.h ripemd-160.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-sha1.o: sha1.c byte_order.h ustd.h sha1.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-sha256.o: sha256.c byte_order.h ustd.h sha256.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-sha3.o: sha3.c byte_order.h ustd.h sha3.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-sha512.o: sha512.c byte_order.h ustd.h sha512.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-snefru.o: snefru.c byte_order.h ustd.h snefru.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-test_lib.o: test_lib.c byte_order.h ustd.h rhash_torrent.h test_utils.h \
- rhash.h test_lib.h util.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-test_utils.o: test_utils.c test_utils.h byte_order.h ustd.h rhash.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-tiger.o: tiger.c byte_order.h ustd.h tiger.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-tiger_sbox.o: tiger_sbox.c byte_order.h ustd.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-torrent.o: torrent.c torrent.h algorithms.h rhash.h byte_order.h ustd.h \
- sha1.h hex.h util.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-tth.o: tth.c tth.h ustd.h tiger.h byte_order.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-util.o: util.c util.h
-	$(CC) -c $(CFLAGS) $< -o $@
-
-whirlpool.o: whirlpool.c byte_order.h ustd.h whirlpool.h
-	$(CC) -c $(CFLAGS) $< -o $@
+.SUFFIXES: .lo
 
-whirlpool_sbox.o: whirlpool_sbox.c byte_order.h ustd.h
-	$(CC) -c $(CFLAGS) $< -o $@
+.c.lo:
+	$(LIBTOOL) --mode=compile --tag=CC $(CC) -c $(CFLAGS) $(VERSION_CFLAGS) $< -o $@
 
 # build shared library
 $(EXPORTS_FILE): $(LIB_HEADERS)
@@ -181,8 +77,8 @@ $(LIBRHASH_SOLINK):
 	rm -f $(LIBRHASH_SOLINK)
 	ln -s $(LIBRHASH_SO_MAJ) $(LIBRHASH_SOLINK)
 
-$(LIBRHASH_SHARED): $(SOURCES) $(EXPORTS_TARGET) $(SOLINK_TARGET)
-	$(CC) $(SHARED_CFLAGS) $(VERSION_CFLAGS) $(SOURCES) $(SHARED_LDFLAGS) -o $@
+$(LIBRHASH_SHARED): $(OBJECTS)
+	$(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(OBJECTS) -rpath $(PREFIX)/lib -version-info 1:0 -o $@
 
 # build static library
 $(LIBRHASH_STATIC): $(OBJECTS)
