 -CC	= gcc
 -INCLUDE	= -I/usr/local/include
 -CFLAGS	= $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
+-
+-LDFLAGS	= -L/usr/local/lib
+-LDLIBS    = -lwiringPi -lwiringPiDev -lpthread -lm
 +DESTDIR?=/usr
 +PREFIX?=/local
- 
--LDFLAGS	= -L/usr/local/lib
--LDLIBS    = -lwiringPi -lwiringPiDev -lpthread -lm
++
 +INCLUDE_DIR?=$(DESTDIR)$(PREFIX)/include
 +LIB_DIR?=$(DESTDIR)$(PREFIX)/lib
 +

 
 .PHONY:	depend
diff --git a/wiringPi/Makefile b/wiringPi/Makefile
index e1868b9..e39f75a 100644
--- a/wiringPi/Makefile
+++ b/wiringPi/Makefile
@@ -25,19 +25,23 @@ VERSION=$(shell cat ../VERSION)
 DESTDIR?=/usr
 PREFIX?=/local
 

+CC	?= gcc
+INCLUDE	?= -I.
 DEFS	= -D_GNU_SOURCE
-CFLAGS	= $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC
+CFLAGS	= $(DEBUG) $(DEFS) $(INCLUDE) -Wformat=2 -Wall -Wextra -Winline -pipe -fPIC
 
 LIBS    = -lm -lpthread -lrt -lcrypt
 
@@ -78,17 +82,17 @@ $(STATIC):	$(OBJ)
 
 $(DYNAMIC):	$(OBJ)
 	$Q echo "[Link (Dynamic)]"
-	$Q $(CC) -shared -Wl,-soname,libwiringPi.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPi.so.$(VERSION) $(LIBS) $(OBJ)
+	$Q $(CC) $(LDFLAGS) -shared -Wl,-soname,$(BASE_NAME).so.$(DYN_VERS_MAJ) -o $(BASE_NAME).so $(OBJ) $(LIBS)
 
 .c.o:
 	$Q echo [Compile] $<
-	$Q $(CC) -c $(CFLAGS) $< -o $@
+	$Q $(CC) $(CFLAGS) $(LIBS) -c $< -o $@
 
 
 .PHONY:	clean
