makefiles_cleanup

Makefiles cleanup

Factor-out $COPTS and $LDOPTS to allow distributions to easily override
them. Properly use $LDFLAGS when linking and $CFLAGS when compiling.
Do not strip the installed binaries: this should be done by the
packaging system if required.


Gbp-Pq: Name makefiles_cleanup
This commit is contained in:
Ubuntu Developers 2022-05-14 02:43:52 +08:00 committed by openKylinBot
parent 4e1019bb23
commit 0a5e00b3da
9 changed files with 38 additions and 28 deletions

View File

@ -12,20 +12,21 @@ CDEFS= $(CDEF1) $(CDEF2) $(CDEF3) $(CDEF4)
COPTS= -O2 -g -pipe
CFLAGS= $(COPTS) $(CDEFS)
LDFLAGS=$(LDOPTS)
INSTALL= install
all: chat
chat: chat.o
$(CC) -o chat chat.o
$(CC) $(LDFLAGS) -o chat chat.o
chat.o: chat.c
$(CC) -c $(CFLAGS) -o chat.o chat.c
install: chat
mkdir -p $(BINDIR) $(MANDIR)
$(INSTALL) -s -c chat $(BINDIR)
$(INSTALL) -c chat $(BINDIR)
$(INSTALL) -c -m 644 chat.8 $(MANDIR)
clean:

View File

@ -83,6 +83,7 @@ INCLUDE_DIRS= -I../include
COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"'
LDFLAGS=$(LDOPTS)
ifdef CHAPMS
CFLAGS += -DCHAPMS=1
@ -102,7 +103,7 @@ ifdef USE_SRP
CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
TARGETS += srp-entry
EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
EXTRAINSTALL = $(INSTALL) -c -m 555 srp-entry $(BINDIR)/srp-entry
MANPAGES += srp-entry.8
EXTRACLEAN += srp-entry.o
NEEDDES=y
@ -208,13 +209,13 @@ all: $(TARGETS)
install: pppd
mkdir -p $(BINDIR) $(MANDIR)
$(EXTRAINSTALL)
$(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
$(INSTALL) -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)
pppd: $(PPPDOBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
$(CC) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
srp-entry: srp-entry.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ srp-entry.c $(LIBS)

View File

@ -1,7 +1,7 @@
#CC = gcc
COPTS = -O2 -g
CFLAGS = $(COPTS) -I.. -I../../include -fPIC
LDFLAGS = -shared
LDFLAGS = $(LDOPTS)
INSTALL = install
DESTDIR = $(INSTROOT)@DESTDIR@
@ -30,7 +30,7 @@ all: $(PLUGINS)
for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d all || exit $$?; done
%.so: %.c
$(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^
$(CC) -o $@ $(LDFLAGS) -shared $(CFLAGS) $^
VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h)

View File

@ -1,7 +1,7 @@
#CC = gcc
COPTS = -O2 -g
CFLAGS = $(COPTS) -I../.. -I../../../include -fPIC
LDFLAGS = -shared
LDFLAGS = $(LDOPTS)
INSTALL = install
#***********************************************************************
@ -33,7 +33,7 @@ endif
all: $(PLUGIN)
$(PLUGIN): $(PLUGIN_OBJS)
$(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
$(CC) $(LDFLAGS) -o $@ -shared $^ $(LIBS)
install: all
$(INSTALL) -d -m 755 $(LIBDIR)

View File

@ -1,7 +1,7 @@
#CC = gcc
COPTS = -O2 -g
CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC
LDFLAGS = -shared
LDFLAGS = $(LDOPTS)
INSTALL = install
#***********************************************************************
@ -16,7 +16,7 @@ PLUGINS := pppol2tp.so openl2tp.so
all: $(PLUGINS)
%.so: %.o
$(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
$(CC) $(LDFLAGS) -o $@ -shared $^ $(LIBS)
install: all
$(INSTALL) -d -m 755 $(LIBDIR)

View File

@ -12,7 +12,9 @@ VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
INSTALL = install
PLUGIN=radius.so radattr.so radrealms.so
CFLAGS=-I. -I../.. -I../../../include -O2 -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
COPTS=-g -O2
CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
LDFLAGS= $(LDOPTS)
# Uncomment the next line to include support for Microsoft's
# MS-CHAP authentication protocol.
@ -36,20 +38,20 @@ all: $(PLUGIN)
install: all
$(INSTALL) -d -m 755 $(LIBDIR)
$(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 755 radius.so $(LIBDIR)
$(INSTALL) -c -m 755 radattr.so $(LIBDIR)
$(INSTALL) -c -m 755 radrealms.so $(LIBDIR)
$(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR)
$(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
radius.so: radius.o libradiusclient.a
$(CC) -o radius.so -shared radius.o libradiusclient.a
$(CC) $(LDFLAGS) -o radius.so -shared radius.o libradiusclient.a
radattr.so: radattr.o
$(CC) -o radattr.so -shared radattr.o
$(CC) $(LDFLAGS) -o radattr.so -shared radattr.o
radrealms.so: radrealms.o
$(CC) -o radrealms.so -shared radrealms.o
$(CC) $(LDFLAGS) -o radrealms.so -shared radrealms.o
CLIENTOBJS = avpair.o buildreq.o config.o dict.o ip_util.o \
clientid.o sendserver.o lock.o util.o md5.o

View File

@ -27,10 +27,12 @@ RP_VERSION=3.8p
COPTS=-O2 -g
CFLAGS=$(COPTS) -I../../../include '-DRP_VERSION="$(RP_VERSION)"'
LDFLAGS=$(LDOPTS)
all: rp-pppoe.so pppoe-discovery
pppoe-discovery: pppoe-discovery.o debug.o
$(CC) -o pppoe-discovery pppoe-discovery.o debug.o
$(CC) $(LDFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o
pppoe-discovery.o: pppoe-discovery.c
$(CC) $(CFLAGS) -c -o pppoe-discovery.o pppoe-discovery.c
@ -39,13 +41,13 @@ debug.o: debug.c
$(CC) $(CFLAGS) -c -o debug.o debug.c
rp-pppoe.so: plugin.o discovery.o if.o common.o
$(CC) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
$(CC) $(LDFLAGS) -o rp-pppoe.so -shared $^
install: all
$(INSTALL) -d -m 755 $(LIBDIR)
$(INSTALL) -s -c -m 4550 rp-pppoe.so $(LIBDIR)
$(INSTALL) -c -m 4550 rp-pppoe.so $(LIBDIR)
$(INSTALL) -d -m 755 $(BINDIR)
$(INSTALL) -s -c -m 555 pppoe-discovery $(BINDIR)
$(INSTALL) -c -m 555 pppoe-discovery $(BINDIR)
clean:
rm -f *.o *.so pppoe-discovery

View File

@ -2,7 +2,10 @@ DESTDIR = $(INSTROOT)@DESTDIR@
BINDIR = $(DESTDIR)/sbin
MANDIR = $(DESTDIR)/share/man/man8
CFLAGS= -O -I../include/net
COPTS=-O2 -g
CFLAGS= $(COPTS) -I../include/net
LDFLAGS=$(LDOPTS)
OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
INSTALL= install
@ -10,12 +13,12 @@ INSTALL= install
all: pppdump
pppdump: $(OBJS)
$(CC) -o pppdump $(OBJS)
$(CC) $(LDFLAGS) -o pppdump $(OBJS)
clean:
rm -f pppdump $(OBJS) *~
install:
mkdir -p $(BINDIR) $(MANDIR)
$(INSTALL) -s -c pppdump $(BINDIR)
$(INSTALL) -c pppdump $(BINDIR)
$(INSTALL) -c -m 444 pppdump.8 $(MANDIR)

View File

@ -10,23 +10,24 @@ PPPSTATSRCS = pppstats.c
PPPSTATOBJS = pppstats.o
#CC = gcc
COPTS = -O
COPTS = -O2 -g
COMPILE_FLAGS = -I../include
LIBS =
INSTALL= install
CFLAGS = $(COPTS) $(COMPILE_FLAGS)
LDFLAGS= $(LDOPTS)
all: pppstats
install: pppstats
-mkdir -p $(MANDIR)
$(INSTALL) -s -c pppstats $(BINDIR)
$(INSTALL) -c pppstats $(BINDIR)
$(INSTALL) -c -m 444 pppstats.8 $(MANDIR)
pppstats: $(PPPSTATSRCS)
$(CC) $(CFLAGS) -o pppstats pppstats.c $(LIBS)
$(CC) $(LDFLAGS) $(CFLAGS) -o pppstats pppstats.c $(LIBS)
clean:
rm -f pppstats *~ #* core