Skip to content

Commit

Permalink
Add pkgconfig support to pppd project
Browse files Browse the repository at this point in the history
This adds pppd.pc into $(INSTROOT)/$(LIBDIR)/pkgconfig. On some distributions
this would be /lib/pkgconfig, or /usr/lib/pkgconfig, but other distributions
may consider specifying --libdir=/usr/lib/x86_x64-linux-gnu/ and the pkgconfig
directory would be under that. Allowing --libdir to be specified at configure
time fixes ppp-project#223, providing pkgconfig support fixes ppp-project#19 and allows third party
packages pickup the plugin directory.

Manually cherry picking parts of two commits by @lkundrak from:
    https://github.com/NetworkManager/ppp/tree/lr/pkgconfig

Mainly, the difference between the original commit is not to replace DESTDIR
with "prefix". Leave DESTDIR alone, and add needed pkgconfig (pppd.pc.in)
as a part of the linux distribution (previously in pppd/plugin directory).

This fixes GitHub issues: ppp-project#19 ppp-project#47 and ppp-project#223

Signed-off-by: Eivind Naess <eivnaes@yahoo.com>
  • Loading branch information
enaess committed Apr 15, 2021
1 parent e609ed8 commit 1ad6027
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
*.o
*.so
*.a
*.pc
*.cat8
Makefile
3 changes: 2 additions & 1 deletion chat/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ CROSS_COMPILE=@CROSS_COMPILE@
CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

DESTDIR = $(INSTROOT)@DESTDIR@
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
BINDIR = $(DESTDIR)/sbin
MANDIR = $(DESTDIR)/share/man/man8

Expand Down
29 changes: 25 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# Where to install stuff by default
DESTDIR=/usr/local
SYSCONF=/etc
LIBDIR='${PREFIX}'/lib
INCDIR='${PREFIX}'/include

VERSION=$(awk -F '"' '/VERSION/ { print $2; }' pppd/patchlevel.h)

# Compile defaults
CROSS_COMPILE=
Expand Down Expand Up @@ -99,7 +103,7 @@ while [ $# -gt 0 ]; do
val=`expr "x$arg" : 'x[^=]*=\(.*\)'`
arg=`expr "x$arg" : 'x\([^=]*\)=.*'`
;;
--prefix|--sysconf)
--prefix|--sysconf|--libdir|--includedir)
if [ $# -eq 0 ]; then
echo "error: the $arg argument requires a value" 1>&2
exit 1
Expand All @@ -111,6 +115,8 @@ while [ $# -gt 0 ]; do
case $arg in
--prefix) DESTDIR=$val ;;
--sysconfdir) SYSCONF=$val ;;
--libdir) LIBDIR=$val ; HAVE_LIBDIR_PARAM=1 ;;
--includedir) INCDIR=$val ; HAVE_INCDIR_PARAM=1 ;;
--cross_compile) CROSS_COMPILE=$val ;;
--cc) CC=$val ;;
--cflags) CFLAGS=$val ;;
Expand All @@ -121,9 +127,14 @@ mkmkf() {
rm -f $2
if [ -f $1 ]; then
echo " $2 <= $1"
sed -e "s,@DESTDIR@,$DESTDIR,g" -e "s,@SYSCONF@,$SYSCONF,g" \
-e "s,@CROSS_COMPILE@,$CROSS_COMPILE,g" -e "s,@CC@,$CC,g" \
-e "s|@CFLAGS@|$CFLAGS|g" $1 >$2
sed -e "s,@DESTDIR@,$DESTDIR,g" \
-e "s,@SYSCONF@,$SYSCONF,g" \
-e "s,@LIBDIR@,$LIBDIR,g" \
-e "s,@INCDIR@,$INCDIR,g" \
-e "s,@CROSS_COMPILE@,$CROSS_COMPILE,g" \
-e "s,@CC@,$CC,g" \
-e "s|@CFLAGS@|$CFLAGS|g" \
-e "s,@VERSION@,$VERSION,g" $1 >$2
fi
}

Expand All @@ -139,6 +150,16 @@ if [ -d "$ksrc" ]; then
if [ -f $ksrc/Makefile.$makext$archvariant ]; then
mkmkf $ksrc/Makefile.$makext$archvariant $ksrc/Makefile
fi
if [ -f "$ksrc/pppd.pc.in" ] ; then
echo "Creating pkg-config file"
if [ ${HAVE_LIBDIR_PARAM:-0} -ne 1 ] ; then
LIBDIR='${prefix}'/lib
fi
if [ ${HAVE_INCDIR_PARAM:-0} -ne 1 ] ; then
INCDIR='${prefix}'/include
fi
mkmkf $ksrc/pppd.pc.in pppd/pppd.pc
fi
else
echo "Unable to locate kernel source $ksrc"
exit 1
Expand Down
11 changes: 11 additions & 0 deletions linux/pppd.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@DESTDIR@
exec_prefix=@DESTDIR@
libdir=@LIBDIR@
includedir=@INCDIR@
version=@VERSION@
plugindir=@LIBDIR@/pppd/${version}

Name: pppd
Description: Point-to-Point Protocol (PPP) daemon
Version: @VERSION@
Cflags: -I${includedir}
12 changes: 9 additions & 3 deletions pppd/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

# Default installation locations
DESTDIR = $(INSTROOT)@DESTDIR@
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
BINDIR = $(DESTDIR)/sbin
MANDIR = $(DESTDIR)/share/man/man8
INCDIR = $(DESTDIR)/include
INCDIR = $(INSTROOT)@INCDIR@
LIBDIR = $(INSTROOT)@LIBDIR@
PKGCONFDIR = $(LIBDIR)/pkgconfig

TARGETS = pppd

Expand Down Expand Up @@ -238,11 +241,14 @@ INSTALL= install
all: $(TARGETS)

install: pppd
mkdir -p $(BINDIR) $(MANDIR)
$(INSTALL) -d $(BINDIR)
$(INSTALL) -d $(MANDIR)
$(INSTALL) -d $(PKGCONFDIR)
$(EXTRAINSTALL)
$(INSTALL) -c -m 755 pppd $(BINDIR)/pppd
if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
chmod o-rx,u+s $(BINDIR)/pppd; fi
$(INSTALL) -c -m 644 pppd.pc $(PKGCONFDIR)
$(INSTALL) -c -m 644 pppd.8 $(MANDIR)

pppd: $(PPPDOBJS)
Expand Down
14 changes: 8 additions & 6 deletions pppd/plugins/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ CROSS_COMPILE=@CROSS_COMPILE@
CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

DESTDIR = $(INSTROOT)@DESTDIR@
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
BINDIR = $(DESTDIR)/sbin
MANDIR = $(DESTDIR)/share/man/man8
LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
LIBDIR = $(INSTROOT)@LIBDIR@
INCDIR = $(INSTROOT)@INCDIR@
VERSION = @VERSION@
PLUGINDIR = $(LIBDIR)/pppd/$(VERSION)

CFLAGS = $(COPTS) -I.. -I../../include -fPIC
LDFLAGS_SHARED = -shared
Expand Down Expand Up @@ -37,11 +41,9 @@ all: $(PLUGINS)
%.so: %.c
$(CC) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) $(CFLAGS) $^

VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h)

install: $(PLUGINS)
$(INSTALL) -d $(LIBDIR)
$(INSTALL) $? $(LIBDIR)
$(INSTALL) -d $(PLUGINDIR)
$(INSTALL) $? $(PLUGINDIR)
for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d install || exit $$?; done

clean:
Expand Down
13 changes: 7 additions & 6 deletions pppd/plugins/pppoatm/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ CROSS_COMPILE=@CROSS_COMPILE@
CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

DESTDIR = $(INSTROOT)@DESTDIR@
LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)

VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
LIBDIR = $(INSTROOT)@LIBDIR@
VERSION = @VERSION@
PLUGINDIR = $(LIBDIR)/pppd/$(VERSION)

CFLAGS = $(COPTS) -I../.. -I../../../include -fPIC
LDFLAGS_SHARED = -shared
Expand Down Expand Up @@ -37,8 +38,8 @@ $(PLUGIN): $(PLUGIN_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LDFLAGS_SHARED) $^ $(LIBS)

install: all
$(INSTALL) -d -m 755 $(LIBDIR)
$(INSTALL) -c -m 755 $(PLUGIN) $(LIBDIR)
$(INSTALL) -d -m 755 $(PLUGINDIR)
$(INSTALL) -c -m 755 $(PLUGIN) $(PLUGINDIR)

clean:
rm -f *.o *.so
Expand Down
15 changes: 8 additions & 7 deletions pppd/plugins/pppoe/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ CROSS_COMPILE=@CROSS_COMPILE@
CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

DESTDIR = $(INSTROOT)@DESTDIR@
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
BINDIR = $(DESTDIR)/sbin
MANDIR = $(DESTDIR)/share/man/man8
LIBDIR = $(DESTDIR)/lib/pppd/$(PPPDVERSION)

PPPDVERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
LIBDIR = $(INSTROOT)@LIBDIR@
VERSION = @VERSION@
PLUGINDIR= $(LIBDIR)/pppd/$(VERSION)

INSTALL = install
LN_S = ln -sf
Expand All @@ -42,10 +43,10 @@ pppoe.so: plugin.o discovery.o if.o common.o
$(CC) $(LDFLAGS) -o pppoe.so -shared plugin.o discovery.o if.o common.o

install: all
$(INSTALL) -d -m 755 $(LIBDIR)
$(INSTALL) -c -m 755 pppoe.so $(LIBDIR)
$(INSTALL) -d -m 755 $(PLUGINDIR)
$(INSTALL) -c -m 755 pppoe.so $(PLUGINDIR)
# Symlink for backward compatibility
$(LN_S) pppoe.so $(LIBDIR)/rp-pppoe.so
$(LN_S) pppoe.so $(PLUGINDIR)/rp-pppoe.so
$(INSTALL) -d -m 755 $(BINDIR)
$(INSTALL) -c -m 755 pppoe-discovery $(BINDIR)
$(INSTALL) -c -m 644 pppoe-discovery.8 $(MANDIR)
Expand Down
13 changes: 7 additions & 6 deletions pppd/plugins/pppol2tp/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ CROSS_COMPILE=@CROSS_COMPILE@
CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

DESTDIR = $(INSTROOT)/@DESTDIR@
LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)

VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
LIBDIR = $(INSTROOT)@LIBDIR@
VERSION = @VERSION@
PLUGINDIR = $(LIBDIR)/pppd/$(VERSION)

CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC
LDFLAGS_SHARED = -shared
Expand All @@ -20,8 +21,8 @@ all: $(PLUGINS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LDFLAGS_SHARED) $^ $(LIBS)

install: all
$(INSTALL) -d -m 755 $(LIBDIR)
$(INSTALL) -c -m 755 $(PLUGINS) $(LIBDIR)
$(INSTALL) -d -m 755 $(PLUGINDIR)
$(INSTALL) -c -m 755 $(PLUGINS) $(PLUGINDIR)

clean:
rm -f *.o *.so
Expand Down
17 changes: 9 additions & 8 deletions pppd/plugins/radius/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ CROSS_COMPILE=@CROSS_COMPILE@
CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

DESTDIR = $(INSTROOT)@DESTDIR@
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
MANDIR = $(DESTDIR)/share/man/man8
LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)

VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
LIBDIR = $(INSTROOT)@LIBDIR@
VERSION = @VERSION@
PLUGINDIR = $(LIBDIR)/pppd/$(VERSION)

INSTALL = install

Expand Down Expand Up @@ -39,10 +40,10 @@ endif
all: $(PLUGIN)

install: all
$(INSTALL) -d -m 755 $(LIBDIR)
$(INSTALL) -c -m 755 radius.so $(LIBDIR)
$(INSTALL) -c -m 755 radattr.so $(LIBDIR)
$(INSTALL) -c -m 755 radrealms.so $(LIBDIR)
$(INSTALL) -d -m 755 $(PLUGINDIR)
$(INSTALL) -c -m 755 radius.so $(PLUGINDIR)
$(INSTALL) -c -m 755 radattr.so $(PLUGINDIR)
$(INSTALL) -c -m 755 radrealms.so $(PLUGINDIR)
$(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR)
$(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)

Expand Down
3 changes: 2 additions & 1 deletion pppdump/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ CROSS_COMPILE=@CROSS_COMPILE@
CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

DESTDIR = $(INSTROOT)@DESTDIR@
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
BINDIR = $(DESTDIR)/sbin
MANDIR = $(DESTDIR)/share/man/man8

Expand Down
3 changes: 2 additions & 1 deletion pppstats/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ CROSS_COMPILE=@CROSS_COMPILE@
CC=$(CROSS_COMPILE)@CC@
COPTS=@CFLAGS@

DESTDIR = $(INSTROOT)@DESTDIR@
PREFIX = @DESTDIR@
DESTDIR = $(INSTROOT)$(PREFIX)
BINDIR = $(DESTDIR)/sbin
MANDIR = $(DESTDIR)/share/man/man8

Expand Down

0 comments on commit 1ad6027

Please sign in to comment.