From: openKylin Developers <packaging@lists.openkylin.top>
Date: Tue, 30 Apr 2024 15:49:33 +0800
Subject: pppdump_use_zlib

support building pppdump with the system zlib

Forwarded: https://github.com/paulusmack/ppp/pull/189
but nacked: "it caused compile failures (on Fedora at least), which
reminded me that the zlib.c here is not the same as upstream; it has
extra functions that I added a long time ago."
---
 pppdump/Makefile.linux | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/pppdump/Makefile.linux b/pppdump/Makefile.linux
index a94187f..de7e574 100644
--- a/pppdump/Makefile.linux
+++ b/pppdump/Makefile.linux
@@ -6,15 +6,39 @@ DESTDIR = $(INSTROOT)@DESTDIR@
 BINDIR = $(DESTDIR)/sbin
 MANDIR = $(DESTDIR)/share/man/man8
 
+DO_DEFLATE=y
+DO_BSD_COMPRESS=y
+HAVE_ZLIB=n
+
 CFLAGS = $(COPTS) -I../include/net
-OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
+OBJS = pppdump.o
+LIBS =
+
+ifdef DO_DEFLATE
+CFLAGS += -DDO_DEFLATE=1
+OBJS += deflate.o
+ifdef HAVE_ZLIB
+LIBS += -lz
+else
+OBJS += zlib.o
+endif
+else
+CFLAGS += -DDO_DEFLATE=0
+endif
 
+ifdef DO_BSD_COMPRESS
+CFLAGS += -DDO_BSD_COMPRESS=1
+OBJS += bsd-comp.o
+else
+CFLAGS += -DDO_BSD_COMPRESS=0
+endif
+ 
 INSTALL= install
 
 all:	pppdump
 
 pppdump: $(OBJS)
-	$(CC) $(LDFLAGS) -o pppdump $(OBJS)
+	$(CC) $(LDFLAGS) -o pppdump $(OBJS) $(LIBS)
 
 clean:
 	rm -f pppdump $(OBJS) *~
