--- ppp-2.4.5.orig/pppd/plugins/pppoatm/Makefile.linux	2009-11-16 23:26:07.000000000 +0100
+++ ppp-2.4.5/pppd/plugins/pppoatm/Makefile.linux	2013-03-04 12:31:16.000000000 +0100
@@ -1,15 +1,16 @@
-#CC	= gcc
-COPTS	= -O2 -g
-CFLAGS	= $(COPTS) -I../.. -I../../../include -fPIC
-LDFLAGS	= -shared
-INSTALL	= install
+VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
 
-#***********************************************************************
+include ../../../Makedefs.com
 
-DESTDIR = $(INSTROOT)@DESTDIR@
-LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
+CPPFLAGS += -I../.. -I../../../include
+ifeq (,$(filter -fPIC,$(CFLAGS)))
+CFLAGS += -fPIC
+endif
+ifeq (,$(filter -shared,$(LDFLAGS)))
+LDFLAGS += -shared
+endif
 
-VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
+#***********************************************************************
 
 PLUGIN := pppoatm.so
 PLUGIN_OBJS := pppoatm.o 
@@ -22,25 +23,22 @@ PLUGIN_OBJS := pppoatm.o
 #HAVE_LIBATM=yes
 
 ifdef HAVE_LIBATM
-LIBS := -latm
+LIBS += -latm
 else
-CFLAGS += -I.
+CPPFLAGS += -I.
 PLUGIN_OBJS += text2qos.o text2atm.o misc.o ans.o
-LIBS := -lresolv
+LIBS += -lresolv
 endif
 
 #*********
 all: $(PLUGIN)
 
 $(PLUGIN): $(PLUGIN_OBJS)
-	$(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
 
-install: all
+install: $(PLUGIN)
 	$(INSTALL) -d -m 755 $(LIBDIR)
-	$(INSTALL) -c -m 4550 $(PLUGIN) $(LIBDIR)
+	$(INSTALL) $(STRIP) -c -m 4550 $(PLUGIN) $(LIBDIR)
 
 clean:
 	rm -f *.o *.so
-
-%.o: %.c
-	$(CC) $(CFLAGS) -c -o $@ $<
