$NetBSD: patch-lib_Makefile,v 1.12 2024/03/17 12:39:50 nia Exp $ Make portable (inc. libtoolize). Unlock install target. Use pkgsrc install scripts. --- lib/Makefile.orig 2022-08-15 22:45:31.000000000 +0000 +++ lib/Makefile @@ -34,9 +34,9 @@ SED = sed # Version numbers -LIBVER_MAJOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` -LIBVER_MINOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` -LIBVER_PATCH_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` +LIBVER_MAJOR_SCRIPT:=`awk '$$2=="LZ4_VERSION_MAJOR" {print $$3}' < lz4.h` +LIBVER_MINOR_SCRIPT:=`awk '$$2=="LZ4_VERSION_MINOR" {print $$3}' < lz4.h` +LIBVER_PATCH_SCRIPT:=`awk '$$2=="LZ4_VERSION_RELEASE" {print $$3}' < lz4.h` LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT) LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT)) LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT)) @@ -56,6 +56,7 @@ CFLAGS += $(DEBUGFLAGS) FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) SRCFILES := $(sort $(wildcard *.c)) +OBJFILES := $(patsubst %.c,%.lo,$(SRCFILES)) include ../Makefile.inc @@ -92,10 +93,13 @@ all: lib all32: CFLAGS+=-m32 all32: all -liblz4.a: $(SRCFILES) +.SUFFIXES: .lo +.c.lo: + $(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@ + +liblz4.a: $(OBJFILES) ifeq ($(BUILD_STATIC),yes) # can be disabled on command line @echo compiling static library - $(COMPILE.c) $^ $(AR) rcs $@ *.o endif @@ -117,17 +121,13 @@ $(LIBLZ4): $(SRCFILES) liblz4-dll.o else # not windows -$(LIBLZ4): $(SRCFILES) - @echo compiling dynamic library $(LIBVER) - $(CC) $(FLAGS) -shared $^ -fPIC -fvisibility=hidden $(SONAME_FLAGS) -o $@ - @echo creating versioned links - $(LN_SF) $@ liblz4.$(SHARED_EXT_MAJOR) - $(LN_SF) $@ liblz4.$(SHARED_EXT) - +liblz4.la: $(OBJFILES) + @echo linking dynamic library $(LIBVER) + $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -rpath $(PREFIX)/lib -version-info $(LIBVER_MAJOR):0 $^ -o $@ endif .PHONY: liblz4 -liblz4: $(LIBLZ4) +liblz4: liblz4.la .PHONY: clean clean: @@ -171,20 +171,20 @@ pkgconfigdir ?= $(PKGCONFIGDIR) liblz4.pc: liblz4.pc.in Makefile @echo creating pkgconfig - $(SED) -e 's|@PREFIX@|$(prefix)|' \ - -e 's|@LIBDIR@|$(libdir)|' \ - -e 's|@INCLUDEDIR@|$(includedir)|' \ - -e 's|@VERSION@|$(LIBVER)|' \ - -e 's|=${prefix}/|=$${prefix}/|' \ + $(SED) -e 's|@PREFIX@|$(prefix)|g' \ + -e 's|@LIBDIR@|$(libdir)|g' \ + -e 's|@INCLUDEDIR@|$(includedir)|g' \ + -e 's|@VERSION@|$(LIBVER)|g' \ + -e 's|=${prefix}/|=$${prefix}/|g' \ $< >$@ install: lib liblz4.pc - $(INSTALL_DIR) $(DESTDIR)$(pkgconfigdir)/ $(DESTDIR)$(includedir)/ $(DESTDIR)$(libdir)/ $(DESTDIR)$(bindir)/ - $(INSTALL_DATA) liblz4.pc $(DESTDIR)$(pkgconfigdir)/ + $(BSD_INSTALL_DATA_DIR) $(DESTDIR)$(pkgconfigdir)/ $(DESTDIR)$(includedir)/ $(DESTDIR)$(libdir)/ $(DESTDIR)$(bindir)/ + $(BSD_INSTALL_DATA) liblz4.pc $(DESTDIR)$(pkgconfigdir)/ @echo Installing libraries in $(DESTDIR)$(libdir) ifeq ($(BUILD_STATIC),yes) - $(INSTALL_DATA) liblz4.a $(DESTDIR)$(libdir)/liblz4.a - $(INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(includedir)/lz4frame_static.h + $(BSD_INSTALL_LIB) liblz4.a $(DESTDIR)$(libdir)/liblz4.a + $(BSD_INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(includedir)/lz4frame_static.h endif ifeq ($(BUILD_SHARED),yes) # Traditionally, one installs the DLLs in the bin directory as programs @@ -194,15 +194,13 @@ install: lib liblz4.pc $(INSTALL_PROGRAM) dll/$(LIBLZ4).dll $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) dll/$(LIBLZ4_EXP) $(DESTDIR)$(libdir) else - $(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir) - $(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR) - $(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT) + $(LIBTOOL) --mode install $(BSD_INSTALL_LIB) liblz4.la $(DESTDIR)$(libdir) endif endif @echo Installing headers in $(DESTDIR)$(includedir) - $(INSTALL_DATA) lz4.h $(DESTDIR)$(includedir)/lz4.h - $(INSTALL_DATA) lz4hc.h $(DESTDIR)$(includedir)/lz4hc.h - $(INSTALL_DATA) lz4frame.h $(DESTDIR)$(includedir)/lz4frame.h + $(BSD_INSTALL_DATA) lz4.h $(DESTDIR)$(includedir)/lz4.h + $(BSD_INSTALL_DATA) lz4hc.h $(DESTDIR)$(includedir)/lz4hc.h + $(BSD_INSTALL_DATA) lz4frame.h $(DESTDIR)$(includedir)/lz4frame.h @echo lz4 libraries installed uninstall: