From 93707a531320fbf398fdb5ffa69a86af092c798c Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Fri, 29 Oct 2004 00:12:27 +0000 Subject: [PATCH] Add --prefix and --sysconfdir options to configure, and put @DESTDIR@ and @SYSCONF@ tags in various Makefile.linux files. These tags get expanded by configure. --- chat/Makefile.linux | 6 ++- configure | 60 ++++++++++++++++++++-------- linux/Makefile.top | 24 +++++------ pppd/Makefile.linux | 11 ++--- pppd/plugins/Makefile.linux | 9 +++-- pppd/plugins/radius/Makefile.linux | 21 ++++++---- pppd/plugins/rp-pppoe/Makefile.linux | 21 ++++++---- pppdump/Makefile.linux | 8 +++- pppstats/Makefile.linux | 11 +++-- 9 files changed, 111 insertions(+), 60 deletions(-) diff --git a/chat/Makefile.linux b/chat/Makefile.linux index c4d6bf2..c74e197 100644 --- a/chat/Makefile.linux +++ b/chat/Makefile.linux @@ -1,4 +1,8 @@ -# $Id: Makefile.linux,v 1.10 2004/01/13 03:57:55 paulus Exp $ +# $Id: Makefile.linux,v 1.11 2004/10/29 00:12:27 paulus Exp $ + +DESTDIR = @DESTDIR@ +BINDIR = $(DESTDIR)/sbin +MANDIR = $(DESTDIR)/man CDEF1= -DTERMIOS # Use the termios structure CDEF2= -DSIGTYPE=void # Standard definition diff --git a/configure b/configure index 60139fd..2d7ea8d 100755 --- a/configure +++ b/configure @@ -1,12 +1,15 @@ #!/bin/sh -# $Id: configure,v 1.31 2004/01/17 05:47:55 carlsonj Exp $ +# $Id: configure,v 1.32 2004/10/29 00:12:26 paulus Exp $ + +# Where to install stuff by default +DESTDIR=/usr/local +SYSCONF=/etc # if [ -d /NextApps ]; then # system="NeXTStep" # else system=`uname -s` release=`uname -r` - machine=`uname -p` arch=`uname -m` # fi state="unknown" @@ -133,26 +136,49 @@ case $state in echo "Configuring for $system";; esac +# Parse arguments +while [ $# -gt 0 ]; do + arg=$1 + val= + shift + case $arg in + *=*) + val=`expr "x$arg" : 'x[^=]*=\(.*\)'` + arg=`expr "x$arg" : 'x\([^=]*\)=.*'` + ;; + --prefix|--sysconf) + if [ $# -eq 0 ]; then + echo "error: the $arg argument requires a value" 1>&2 + exit 1 + fi + val=$1 + shift + ;; + esac + case $arg in + --prefix) DESTDIR=$val ;; + --sysconfdir) SYSCONF=$val ;; + esac +done + +mkmkf() { + rm -f $2 + echo " $2 <= $1" + sed -e "s,@DESTDIR@,$DESTDIR,g" -e "s,@SYSCONF@,$SYSCONF,g" $1 >$2 +} + if [ -d "$ksrc" ]; then - echo "Creating links to Makefiles." - rm -f Makefile - ln -s $ksrc/Makefile.top Makefile - echo " Makefile -> $ksrc/Makefile.top" - rm -f Makedefs.com - ln -s $ksrc/Makedefs$compiletype Makedefs.com - echo " $ksrc/Makedefs$compiletype -> Makedefs.com" - for dir in pppd pppstats chat pppdump pppd/plugins pppd/plugins/rp-pppoe pppd/plugins/radius; do - rm -f $dir/Makefile + echo "Creating Makefiles." + mkmkf $ksrc/Makefile.top Makefile + mkmkf $ksrc/Makedefs$compiletype Makedefs.com + for dir in pppd pppstats chat pppdump pppd/plugins pppd/plugins/rp-pppoe \ + pppd/plugins/radius; do if [ -f $dir/Makefile.$makext ]; then - ln -s Makefile.$makext $dir/Makefile - echo " $dir/Makefile -> Makefile.$makext" + mkmkf $dir/Makefile.$makext $dir/Makefile fi done if [ "$archvariant" ]; then - makext=$makext$archvariant - rm -f $ksrc/Makefile - ln -s Makefile.$makext $ksrc/Makefile - echo " $ksrc/Makefile -> Makefile.$makext" + mkmkf Makefile.$makext $ksrc/Makefile fi else echo "Unable to locate kernel source $ksrc" diff --git a/linux/Makefile.top b/linux/Makefile.top index 6b209dc..62f5ba2 100644 --- a/linux/Makefile.top +++ b/linux/Makefile.top @@ -1,10 +1,10 @@ # PPP top-level Makefile for Linux. - -BINDIR = $(DESTDIR)/usr/sbin -INCDIR = $(DESTDIR)/usr/include -MANDIR = $(DESTDIR)/usr/man -ETCDIR = $(DESTDIR)/etc/ppp +DESTDIR = @DESTDIR@ +BINDIR = $(DESTDIR)/sbin +INCDIR = $(DESTDIR)/include +MANDIR = $(DESTDIR)/man +ETCDIR = @SYSCONF@/ppp # uid 0 = root INSTALL= install @@ -16,20 +16,20 @@ all: cd pppstats; $(MAKE) $(MFLAGS) all cd pppdump; $(MAKE) $(MFLAGS) all -install: $(BINDIR) $(MANDIR)/man8 install-progs install-etcppp install-devel +install: $(BINDIR) $(MANDIR)/man8 install-progs install-devel install-progs: - cd chat; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install - cd pppd/plugins; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install - cd pppd; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install - cd pppstats; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install - cd pppdump; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install + cd chat; $(MAKE) $(MFLAGS) install + cd pppd/plugins; $(MAKE) $(MFLAGS) install + cd pppd; $(MAKE) $(MFLAGS) install + cd pppstats; $(MAKE) $(MFLAGS) install + cd pppdump; $(MAKE) $(MFLAGS) install install-etcppp: $(ETCDIR) $(ETCDIR)/options $(ETCDIR)/pap-secrets \ $(ETCDIR)/chap-secrets install-devel: - cd pppd; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) INCDIR=$(INCDIR) $(MFLAGS) install-devel + cd pppd; $(MAKE) $(MFLAGS) install-devel $(ETCDIR)/options: $(INSTALL) -c -m 644 etc.ppp/options $@ diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux index e1d95b3..2cdfe9e 100644 --- a/pppd/Makefile.linux +++ b/pppd/Makefile.linux @@ -1,12 +1,13 @@ # # pppd makefile for Linux -# $Id: Makefile.linux,v 1.61 2004/10/28 00:15:08 paulus Exp $ +# $Id: Makefile.linux,v 1.62 2004/10/29 00:12:27 paulus Exp $ # # Default installation locations -BINDIR = $(DESTDIR)/usr/sbin -MANDIR = $(DESTDIR)/usr/man -INCDIR = $(DESTDIR)/usr/include +DESTDIR = @DESTDIR@ +BINDIR = $(DESTDIR)/sbin +MANDIR = $(DESTDIR)/man/man8 +INCDIR = $(DESTDIR)/include TARGETS = pppd @@ -202,7 +203,7 @@ install: pppd $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \ chmod o-rx,u+s $(BINDIR)/pppd; fi - $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8 + $(INSTALL) -c -m 444 pppd.8 $(MANDIR) pppd: $(PPPDOBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS) diff --git a/pppd/plugins/Makefile.linux b/pppd/plugins/Makefile.linux index 2fabeba..c2c9146 100644 --- a/pppd/plugins/Makefile.linux +++ b/pppd/plugins/Makefile.linux @@ -4,6 +4,11 @@ CFLAGS = $(COPTS) -I.. -I../../include -fPIC LDFLAGS = -shared INSTALL = install -o root +DESTDIR = @DESTDIR@ +BINDIR = $(DESTDIR)/sbin +MANDIR = $(DESTDIR)/man +LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) + SUBDIRS := rp-pppoe # Uncomment the next line to include the radius authentication plugin # SUBDIRS += radius @@ -21,13 +26,11 @@ all: $(PLUGINS) $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^ VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h) -LIBDIR = $(DESTDIR)/usr/lib/pppd/$(VERSION) install: $(PLUGINS) $(INSTALL) -d $(LIBDIR) $(INSTALL) $? $(LIBDIR) - for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d INSTALL=$(INSTALL) \ - LIBDIR=$(LIBDIR) install; done + for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d install; done clean: rm -f *.o *.so *.a diff --git a/pppd/plugins/radius/Makefile.linux b/pppd/plugins/radius/Makefile.linux index f8de391..96d5c78 100644 --- a/pppd/plugins/radius/Makefile.linux +++ b/pppd/plugins/radius/Makefile.linux @@ -3,7 +3,12 @@ # Copyright 2002 Roaring Penguin Software Inc. # -MANDIR=/usr/man +DESTDIR = @DESTDIR@ +MANDIR = $(DESTDIR)/man/man8 +LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) + +INSTALL = install -o root + PLUGIN=radius.so radattr.so radrealms.so CFLAGS=-I../.. -I../../../include -Iradiusclient/include -O2 @@ -33,8 +38,8 @@ install: all $(INSTALL) -s -c -m 755 radius.so $(LIBDIR) $(INSTALL) -s -c -m 755 radattr.so $(LIBDIR) $(INSTALL) -s -c -m 755 radrealms.so $(LIBDIR) - $(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR)/man8 - $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)/man8 + $(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR) + $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR) radius.so: radiusclient/lib/.libs/libradiusclient.a radius.o gcc -o radius.so -shared radius.o radiusclient/lib/.libs/libradiusclient.a @@ -55,11 +60,11 @@ radrealms.o: radrealms.c gcc $(CFLAGS) -c -o radrealms.o -fPIC radrealms.c radiusclient/lib/.libs/libradiusclient.a: - test -r radiusclient/Makefile || \ - (cd radiusclient; \ - ./configure --prefix=/usr \ - --sysconfdir=/etc \ - --enable-shared \ + test -r radiusclient/Makefile || \ + (cd radiusclient; \ + ./configure --prefix=@PREFIX@ \ + --sysconfdir=@SYSCONF@ \ + --enable-shared \ --enable-static) $(MAKE) -C radiusclient diff --git a/pppd/plugins/rp-pppoe/Makefile.linux b/pppd/plugins/rp-pppoe/Makefile.linux index bbb8ba9..f1428c5 100644 --- a/pppd/plugins/rp-pppoe/Makefile.linux +++ b/pppd/plugins/rp-pppoe/Makefile.linux @@ -10,9 +10,14 @@ # This program may be distributed according to the terms of the GNU # General Public License, version 2 or (at your option) any later version. # -# $Id: Makefile.linux,v 1.2 2004/01/13 03:57:55 paulus Exp $ +# $Id: Makefile.linux,v 1.3 2004/10/29 00:12:27 paulus Exp $ #*********************************************************************** +DESTDIR = @DESTDIR@ +LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) + +INSTALL = install -o root + # Version is set ONLY IN THE MAKEFILE! Don't delete this! VERSION=3.3 @@ -21,7 +26,7 @@ CFLAGS=$(COPTS) -I../../../include/linux all: rp-pppoe.so rp-pppoe.so: libplugin.a plugin.o - gcc -o rp-pppoe.so -shared plugin.o libplugin.a + $(CC) -o rp-pppoe.so -shared plugin.o libplugin.a install: all $(INSTALL) -d -m 755 $(LIBDIR) @@ -31,20 +36,20 @@ clean: rm -f *.o *.so plugin.o: plugin.c - gcc '-DRP_VERSION="$(VERSION)"' $(CFLAGS) -I../../.. -c -o plugin.o -fPIC plugin.c + $(CC) '-DRP_VERSION="$(VERSION)"' $(CFLAGS) -I../../.. -c -o plugin.o -fPIC plugin.c libplugin.a: discovery.o if.o common.o debug.o - ar -rc $@ $^ + $(AR) -rc $@ $^ discovery.o: discovery.c - gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o discovery.o -fPIC discovery.c + $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o discovery.o -fPIC discovery.c if.o: if.c - gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o if.o -fPIC if.c + $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o if.o -fPIC if.c debug.o: debug.c - gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o debug.o -fPIC debug.c + $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o debug.o -fPIC debug.c common.o: common.c - gcc $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o common.o -fPIC common.c + $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o common.o -fPIC common.c diff --git a/pppdump/Makefile.linux b/pppdump/Makefile.linux index d02fecd..e2e959a 100644 --- a/pppdump/Makefile.linux +++ b/pppdump/Makefile.linux @@ -1,3 +1,7 @@ +DESTDIR = @DESTDIR@ +BINDIR = $(DESTDIR)/sbin +MANDIR = $(DESTDIR)/man/man8 + CFLAGS= -O -I../include/net OBJS = pppdump.o bsd-comp.o deflate.o zlib.o @@ -12,6 +16,6 @@ clean: rm -f pppdump $(OBJS) *~ install: - mkdir -p $(BINDIR) $(MANDIR)/man8 + mkdir -p $(BINDIR) $(MANDIR) $(INSTALL) -s -c pppdump $(BINDIR) - $(INSTALL) -c -m 444 pppdump.8 $(MANDIR)/man8 + $(INSTALL) -c -m 444 pppdump.8 $(MANDIR) diff --git a/pppstats/Makefile.linux b/pppstats/Makefile.linux index 8bb4f9a..9b0a7e8 100644 --- a/pppstats/Makefile.linux +++ b/pppstats/Makefile.linux @@ -1,7 +1,10 @@ # # pppstats makefile -# $Id: Makefile.linux,v 1.5 2002/10/27 12:56:26 fcusack Exp $ +# $Id: Makefile.linux,v 1.6 2004/10/29 00:12:27 paulus Exp $ # +DESTDIR = @DESTDIR@ +BINDIR = $(DESTDIR)/sbin +MANDIR = $(DESTDIR)/man/man8 PPPSTATSRCS = pppstats.c PPPSTATOBJS = pppstats.o @@ -18,9 +21,9 @@ CFLAGS = $(COPTS) $(COMPILE_FLAGS) all: pppstats install: pppstats - -mkdir -p $(MANDIR)/man8 - $(INSTALL) -s -c pppstats $(BINDIR)/pppstats - $(INSTALL) -c -m 444 pppstats.8 $(MANDIR)/man8/pppstats.8 + -mkdir -p $(MANDIR) + $(INSTALL) -s -c pppstats $(BINDIR) + $(INSTALL) -c -m 444 pppstats.8 $(MANDIR) pppstats: $(PPPSTATSRCS) $(CC) $(CFLAGS) -o pppstats pppstats.c $(LIBS) -- 2.39.2