From 7cb817498e294e4d9ccc981524661be963b7a97f Mon Sep 17 00:00:00 2001
From: Gordon Henderson <projects@drogon.net>
Date: Sat, 31 Jan 2015 16:43:08 +0000
Subject: [PATCH] OK, so an easier way to manage versions. Debian package
 creation - crude, probably violated the Debian policys but it seems to work
 just fine... some other changes.

---
 VERSION                         |   1 +
 build                           |  32 ++++++++++--
 debian/wiringPi/DEBIAN/control  |  10 ++++
 debian/wiringPi/DEBIAN/postinst |   5 ++
 debian/wiringPi/DEBIAN/postrm   |   2 +
 devLib/Makefile                 |  61 +++++++++++-----------
 gpio/Makefile                   |  11 +++-
 gpio/gpio.c                     |   2 +-
 gpio/newVersion                 |  26 ++++++++++
 gpio/version.h                  |   1 +
 wiringPi/Makefile               | 112 ++++++++++++++++------------------------
 wiringPi/wiringPi.c             |   8 +--
 wiringPi/wpiExtensions.c        |  15 +++---
 13 files changed, 169 insertions(+), 117 deletions(-)
 create mode 100644 VERSION
 create mode 100644 debian/wiringPi/DEBIAN/control
 create mode 100755 debian/wiringPi/DEBIAN/postinst
 create mode 100755 debian/wiringPi/DEBIAN/postrm
 create mode 100755 gpio/newVersion
 create mode 100644 gpio/version.h

diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..fd6915c
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+2.24
diff --git a/build b/build
index 377bd16..fb5a8b7 100755
--- a/build
+++ b/build
@@ -73,6 +73,28 @@ if [ x$1 = "xuninstall" ]; then
   exit
 fi
 
+# Only if you know what you're doing!
+
+if [ x$1 = "xdebian" ]; then
+  here=`pwd`
+  cd debian/wiringPi
+  rm -rf usr
+  cd $here/wiringPi
+  make install-deb
+  cd $here/devLib
+  make install-deb
+  cd $here/gpio
+  make install-deb
+  cd $here/debian
+  fakeroot dpkg-deb --build wiringPi
+  mv wiringPi.deb  wiringpi-`cat $here/VERSION`-1.deb
+  exit
+fi
+
+if [ x$1 != "x" ]; then
+  echo "Usage: $0 [clean | uninstall]"
+  exit 1
+fi
 
   echo "wiringPi Build script"
   echo "====================="
@@ -101,11 +123,11 @@ fi
   cd wiringPi
   sudo make uninstall
   if [ x$1 = "xstatic" ]; then
-    make static
+    make -j5 static
     check_make_ok
     sudo make install-static
   else
-    make
+    make -j5
     check_make_ok
     sudo make install
   fi
@@ -116,11 +138,11 @@ fi
   cd ../devLib
   sudo make uninstall
   if [ x$1 = "xstatic" ]; then
-    make static
+    make -j5 static
     check_make_ok
     sudo make install-static
   else
-    make
+    make -j5
     check_make_ok
     sudo make install
   fi
@@ -129,7 +151,7 @@ fi
   echo
   echo "GPIO Utility"
   cd ../gpio
-  make
+  make -j5
   check_make_ok
   sudo make install
   check_make_ok
diff --git a/debian/wiringPi/DEBIAN/control b/debian/wiringPi/DEBIAN/control
new file mode 100644
index 0000000..73ee094
--- /dev/null
+++ b/debian/wiringPi/DEBIAN/control
@@ -0,0 +1,10 @@
+Package: wiringpi
+Version: 2.24
+Section: libraries
+Priority: optional
+Architecture: armhf
+Depends: libc6
+Maintainer: Gordon Henderson <projects@drogon.net>
+Description: The wiringPi libraries, headers and gpio command
+  Libraries to allow GPIO access on a Raspberry Pi from C and C++
+  programs as well as from the command-line
diff --git a/debian/wiringPi/DEBIAN/postinst b/debian/wiringPi/DEBIAN/postinst
new file mode 100755
index 0000000..4997e98
--- /dev/null
+++ b/debian/wiringPi/DEBIAN/postinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+/bin/chown root.root	/usr/bin/gpio
+/bin/chmod 4755		/usr/bin/gpio
+/sbin/ldconfig
diff --git a/debian/wiringPi/DEBIAN/postrm b/debian/wiringPi/DEBIAN/postrm
new file mode 100755
index 0000000..4be8c58
--- /dev/null
+++ b/debian/wiringPi/DEBIAN/postrm
@@ -0,0 +1,2 @@
+#!/bin/sh
+/sbin/ldconfig
diff --git a/devLib/Makefile b/devLib/Makefile
index 4ba1774..d62b532 100644
--- a/devLib/Makefile
+++ b/devLib/Makefile
@@ -1,7 +1,8 @@
+#
 # Makefile:
 #	wiringPi device - Wiring Compatable library for the Raspberry Pi
 #
-#	Copyright (c) 2012-2013 Gordon Henderson
+#	Copyright (c) 2012-2015 Gordon Henderson
 #################################################################################
 # This file is part of wiringPi:
 #	https://projects.drogon.net/raspberry-pi/wiringpi/
@@ -20,10 +21,7 @@
 #    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
 #################################################################################
 
-DYN_VERS_MAJ=2
-DYN_VERS_MIN=0
-
-VERSION=$(DYN_VERS_MAJ).$(DYN_VERS_MIN)
+VERSION=$(shell cat ../VERSION)
 DESTDIR=/usr
 PREFIX=/local
 
@@ -34,7 +32,8 @@ DYNAMIC=libwiringPiDev.so.$(VERSION)
 DEBUG	= -O2
 CC	= gcc
 INCLUDE	= -I.
-CFLAGS	= $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC
+DEFS	= -D_GNU_SOURCE
+CFLAGS	= $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC
 
 LIBS    =
 
@@ -47,6 +46,8 @@ SRC	=	ds1302.c maxdetect.c  piNes.c		\
 
 OBJ	=	$(SRC:.c=.o)
 
+HEADERS	=	ds1302.h gertboard.h  lcd128x64.h  lcd.h  maxdetect.h piFace.h  piGlow.h  piNes.h  tcs34725.h
+
 all:		$(DYNAMIC)
 
 static:		$(STATIC)
@@ -76,22 +77,11 @@ tags:	$(SRC)
 	@ctags $(SRC)
 
 
-.PHONY:	install-headers
-install-headers:
-	@echo "[Install Headers]"
-	@install -m 0755 -d			$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 ds1302.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 maxdetect.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 piNes.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 gertboard.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 piFace.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 lcd128x64.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 lcd.h			$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 piGlow.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 tcs34725.h $(DESTDIR)$(PREFIX)/include
-
 .PHONY:	install
-install:	$(DYNAMIC) install-headers
+install:	$(DYNAMIC)
+	@echo "[Install Headers]"
+	@install -m 0755 -d						$(DESTDIR)$(PREFIX)/include
+	@install -m 0644 $(HEADERS)					$(DESTDIR)$(PREFIX)/include
 	@echo "[Install Dynamic Lib]"
 	@install -m 0755 -d						$(DESTDIR)$(PREFIX)/lib
 	@install -m 0755 libwiringPiDev.so.$(VERSION)			$(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)
@@ -99,24 +89,29 @@ install:	$(DYNAMIC) install-headers
 	@ldconfig
 
 .PHONY:	install-static
-install-static:	$(STATIC) install-headers
+install-static:	$(STATIC)
+	@echo "[Install Headers]"
+	@install -m 0755 -d						$(DESTDIR)$(PREFIX)/include
+	@install -m 0644 $(HEADERS)					$(DESTDIR)$(PREFIX)/include
 	@echo "[Install Static Lib]"
-	@install -m 0755 -d			$(DESTDIR)$(PREFIX)/lib
-	@install -m 0755 libwiringPiDev.a	$(DESTDIR)$(PREFIX)/lib
+	@install -m 0755 -d						$(DESTDIR)$(PREFIX)/lib
+	@install -m 0755 libwiringPiDev.a				$(DESTDIR)$(PREFIX)/lib
+
+.PHONY:	install-deb
+install-deb:	$(DYNAMIC)
+	@echo "[Install Headers: deb]"
+	@install -m 0755 -d							~/wiringPi/debian/wiringPi/usr/include
+	@install -m 0644 $(HEADERS)						~/wiringPi/debian/wiringPi/usr/include
+	@echo "[Install Dynamic Lib: deb]"
+	install -m 0755 -d							~/wiringPi/debian/wiringPi/usr/lib
+	install -m 0755 libwiringPiDev.so.$(VERSION)				~/wiringPi/debian/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION)
+	ln -sf ~/wiringPi/debian/wiringPi/usr/lib/libwiringPi.so.$(VERSION)	~/wiringPi/debian/wiringPi/usr/lib/libwiringPiDev.so
 
 .PHONY:	uninstall
 uninstall:
 	@echo "[UnInstall]"
-	@rm -f $(DESTDIR)$(PREFIX)/include/ds1302.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/maxdetect.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/piNes.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/gertboard.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/piFace.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/lcd128x64.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/lcd.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/piGlow.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/tcs34725.h
-	@rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.*
+	@cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
+	@cd $(DESTDIR)$(PREFIX)/lib/     && rm -f libwiringPiDev.*
 	@ldconfig
 
 
diff --git a/gpio/Makefile b/gpio/Makefile
index 9c8585f..449986e 100644
--- a/gpio/Makefile
+++ b/gpio/Makefile
@@ -44,6 +44,9 @@ OBJ	=	$(SRC:.c=.o)
 
 all:		gpio
 
+version.h:	../VERSION
+	./newVersion
+
 gpio:	$(OBJ)
 	@echo [Link]
 	@$(CC) -o $@ $(OBJ) $(LDFLAGS) $(LIBS)
@@ -63,7 +66,7 @@ tags:	$(SRC)
 	@ctags $(SRC)
 
 .PHONY:	install
-install:
+install: gpio
 	@echo "[Install]"
 	@cp gpio		$(DESTDIR)$(PREFIX)/bin
 	@chown root.root	$(DESTDIR)$(PREFIX)/bin/gpio
@@ -71,6 +74,12 @@ install:
 	@mkdir -p		$(DESTDIR)$(PREFIX)/man/man1
 	@cp gpio.1		$(DESTDIR)$(PREFIX)/man/man1
 
+.PHONY:	install-deb
+install-deb:	gpio
+	@echo "[Install: deb]"
+	@install -m 0755 -d							~/wiringPi/debian/wiringPi/usr/bin
+	@install -m 0755 gpio							~/wiringPi/debian/wiringPi/usr/bin
+
 .PHONY:	uninstall
 uninstall:
 	@echo "[UnInstall]"
diff --git a/gpio/gpio.c b/gpio/gpio.c
index 3cee59f..461274f 100644
--- a/gpio/gpio.c
+++ b/gpio/gpio.c
@@ -40,6 +40,7 @@
 #include <gertboard.h>
 #include <piFace.h>
 
+#include "version.h"
 
 extern int wiringPiDebug ;
 
@@ -53,7 +54,6 @@ extern void doPins       (void) ;
 #  define	FALSE	(1==2)
 #endif
 
-#define	VERSION			"2.23"
 #define	PI_USB_POWER_CONTROL	38
 #define	I2CDETECT		"/usr/sbin/i2cdetect"
 
diff --git a/gpio/newVersion b/gpio/newVersion
new file mode 100755
index 0000000..b8728a5
--- /dev/null
+++ b/gpio/newVersion
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# newVersion:
+#	Utility to create the version.h include file for the gpio command.
+#
+#	Copyright (c) 2012-2015 Gordon Henderson
+#################################################################################
+# This file is part of wiringPi:
+#	Wiring Compatable library for the Raspberry Pi
+#
+#    wiringPi is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Lesser General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    wiringPi is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Lesser General Public License for more details.
+#
+#    You should have received a copy of the GNU Lesser General Public License
+#    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
+#################################################################################
+
+rm -f version.h
+echo "#define VERSION \"`cat ../VERSION`\"" > version.h
diff --git a/gpio/version.h b/gpio/version.h
new file mode 100644
index 0000000..5416bcb
--- /dev/null
+++ b/gpio/version.h
@@ -0,0 +1 @@
+#define VERSION "2.24"
diff --git a/wiringPi/Makefile b/wiringPi/Makefile
index 1a06c35..015a894 100644
--- a/wiringPi/Makefile
+++ b/wiringPi/Makefile
@@ -1,8 +1,8 @@
-# ;
+#
 # Makefile:
 #	wiringPi - Wiring Compatable library for the Raspberry Pi
 #
-#	Copyright (c) 2012 Gordon Henderson
+#	Copyright (c) 2012-2015 Gordon Henderson
 #################################################################################
 # This file is part of wiringPi:
 #	https://projects.drogon.net/raspberry-pi/wiringpi/
@@ -21,10 +21,7 @@
 #    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
 #################################################################################
 
-DYN_VERS_MAJ=2
-DYN_VERS_MIN=0
-
-VERSION=$(DYN_VERS_MAJ).$(DYN_VERS_MIN)
+VERSION=$(shell cat ../VERSION)
 DESTDIR=/usr
 PREFIX=/local
 
@@ -40,7 +37,6 @@ CFLAGS	= $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC
 
 LIBS    =
 
-# Should not alter anything below this line
 ###############################################################################
 
 SRC	=	wiringPi.c						\
@@ -60,6 +56,22 @@ SRC	=	wiringPi.c						\
 		dac7678.c \
 		wpiExtensions.c
 
+HEADERS =	wiringPi.h						\
+		pca9685.h pca9685reg.h dac7678.h \
+		wiringSerial.h wiringShift.h				\
+		wiringPiSPI.h wiringPiI2C.h				\
+		softPwm.h softTone.h					\
+		mcp23008.h mcp23016.h mcp23017.h			\
+		mcp23s08.h mcp23s17.h					\
+		sr595.h							\
+		pcf8574.h pcf8591.h					\
+		mcp3002.h mcp3004.h mcp4802.h mcp3422.h			\
+		max31855.h max5322.h					\
+		sn3218.h						\
+		drcSerial.h						\
+		wpiExtensions.h 
+
+
 OBJ	=	$(SRC:.c=.o)
 
 all:		$(DYNAMIC)
@@ -80,6 +91,7 @@ $(DYNAMIC):	$(OBJ)
 	@echo [Compile] $<
 	@$(CC) -c $(CFLAGS) $< -o $@
 
+
 .PHONY:	clean
 clean:
 	@echo "[Clean]"
@@ -91,40 +103,11 @@ tags:	$(SRC)
 	@ctags $(SRC)
 
 
-.PHONY:	install-headers
-install-headers:
-	@echo "[Install Headers]"
-	@install -m 0755 -d			$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 wiringPi.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 wiringSerial.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 wiringShift.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 softPwm.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 softTone.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 wiringPiSPI.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 wiringPiI2C.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 drcSerial.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp23008.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp23016.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp23017.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp23s08.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp23s17.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 max31855.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 max5322.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp3002.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp3004.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp4802.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 mcp3422.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 sr595.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 pcf8574.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 pcf8591.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 sn3218.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 pca9685.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 pca9685reg.h	$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 dac7678.h		$(DESTDIR)$(PREFIX)/include
-	@install -m 0644 wpiExtensions.h	$(DESTDIR)$(PREFIX)/include
-
 .PHONY:	install
-install:	$(DYNAMIC) install-headers
+install:	$(DYNAMIC)
+	@echo "[Install Headers]"
+	@install -m 0755 -d						$(DESTDIR)$(PREFIX)/include
+	@install -m 0644 $(HEADERS)					$(DESTDIR)$(PREFIX)/include
 	@echo "[Install Dynamic Lib]"
 	@install -m 0755 -d						$(DESTDIR)$(PREFIX)/lib
 	@install -m 0755 libwiringPi.so.$(VERSION)			$(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
@@ -132,42 +113,29 @@ install:	$(DYNAMIC) install-headers
 	@ldconfig
 
 .PHONY:	install-static
-install-static:	$(STATIC) install-headers
+install-static:	$(STATIC)
+	@echo "[Install Headers]"
+	@install -m 0755 -d						$(DESTDIR)$(PREFIX)/include
+	@install -m 0644 $(HEADERS)					$(DESTDIR)$(PREFIX)/include
 	@echo "[Install Static Lib]"
-	@install -m 0755 -d			$(DESTDIR)$(PREFIX)/lib
-	@install -m 0755 libwiringPi.a		$(DESTDIR)$(PREFIX)/lib
+	@install -m 0755 -d						$(DESTDIR)$(PREFIX)/lib
+	@install -m 0755 libwiringPi.a					$(DESTDIR)$(PREFIX)/lib
+
+.PHONY:	install-deb
+install-deb:	$(DYNAMIC)
+	@echo "[Install Headers: deb]"
+	@install -m 0755 -d							~/wiringPi/debian/wiringPi/usr/include
+	@install -m 0644 $(HEADERS)						~/wiringPi/debian/wiringPi/usr/include
+	@echo "[Install Dynamic Lib: deb]"
+	install -m 0755 -d							~/wiringPi/debian/wiringPi/usr/lib
+	install -m 0755 libwiringPi.so.$(VERSION)				~/wiringPi/debian/wiringPi/usr/lib/libwiringPi.so.$(VERSION)
+	ln -sf ~/wiringPi/debian/wiringPi/usr/lib/libwiringPi.so.$(VERSION)	~/wiringPi/debian/wiringPi/usr/lib/libwiringPi.so
 
 .PHONY:	uninstall
 uninstall:
 	@echo "[UnInstall]"
-	@rm -f $(DESTDIR)$(PREFIX)/include/wiringPi.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/wiringSerial.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/wiringShift.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/softPwm.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/softTone.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/wiringPiSPI.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/wiringPiI2C.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/drcSerial.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp23008.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp23016.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp23017.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp23s08.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp23s17.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/max31855.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/max5322.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp3002.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp3004.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp4802.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/mcp3422.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/sr595.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/pcf8574.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/pcf8591.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/sn3218.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/pca9685.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/pca9685reg.h
-	@rm -f $(DESTDIR)$(PREFIX)/include/dac7678.h
-	@rm -f $(DESTDIR)$(PREFIX)/includewpiExtensions.h
-	@rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPi.*
+	@cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
+	@cd $(DESTDIR)$(PREFIX)/lib/     && rm -f libwiringPi.*
 	@ldconfig
 
 
@@ -205,6 +171,6 @@ max5322.o: wiringPi.h wiringPiSPI.h max5322.h
 pca9685.o: wiringPi.h pca9685.h pca9685reg.h
 dac7678.o: wiringPi.h wiringPiI2C.h dac7678.h
 wpiExtensions.o: wiringPi.h mcp23008.h mcp23016.h mcp23017.h mcp23s08.h
-wpiExtensions.o: mcp23s17.h sr595.h pcf8591.h pcf8574.h max31855.h max5322.h
-wpiExtensions.o: mcp3002.h mcp3004.h mcp4802.h mcp3422.h sn3218.h drcSerial.h
-wpiExtensions.o: wpiExtensions.h
+wpiExtensions.o: mcp23s17.h sr595.h pcf8574.h pcf8591.h mcp3002.h mcp3004.h
+wpiExtensions.o: mcp4802.h mcp3422.h max31855.h max5322.h sn3218.h
+wpiExtensions.o: drcSerial.h wpiExtensions.h
diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c
index 990c641..e36af8a 100644
--- a/wiringPi/wiringPi.c
+++ b/wiringPi/wiringPi.c
@@ -1,7 +1,7 @@
 /*
  * wiringPi:
- *	Arduino compatable (ish) Wiring library for the Raspberry Pi
- *	Copyright (c) 2012 Gordon Henderson
+ *	Arduino look-a-like Wiring library for the Raspberry Pi
+ *	Copyright (c) 2012-2015 Gordon Henderson
  *	Additional code for pwmSetClock by Chris Hall <chris@kchall.plus.com>
  *
  *	Thanks to code samples from Gert Jan van Loo and the
@@ -131,7 +131,7 @@ struct wiringPiNodeStruct *wiringPiNodes = NULL ;
 //	Taken from Gert/Doms code. Some of this is not in the manual
 //	that I can find )-:
 
-static volatile unsigned int	BCM2708_PERI_BASE =  0x20000000 ;
+static volatile unsigned int	 BCM2708_PERI_BASE = 0x20000000 ;	// Variable for Pi2
 #define GPIO_PADS		(BCM2708_PERI_BASE + 0x00100000)
 #define CLOCK_BASE		(BCM2708_PERI_BASE + 0x00101000)
 #define GPIO_BASE		(BCM2708_PERI_BASE + 0x00200000)
@@ -607,7 +607,7 @@ int wiringPiFailure (int fatal, const char *message, ...)
  *
  *	Revision 1 really means the early Model B's.
  *	Revision 2 is everything else - it covers the B, B+ and CM.
- *		... and the quad core Pi 2 - which is a B+ ++  ...
+ *		... and the Pi 2 - which is a B+ ++  ...
  *
  *	Seems there are some boards with 0000 in them (mistake in manufacture)
  *	So the distinction between boards that I can see is:
diff --git a/wiringPi/wpiExtensions.c b/wiringPi/wpiExtensions.c
index da41f29..4cae9c4 100644
--- a/wiringPi/wpiExtensions.c
+++ b/wiringPi/wpiExtensions.c
@@ -44,14 +44,14 @@
 #include "mcp23s08.h"
 #include "mcp23s17.h"
 #include "sr595.h"
-#include "pcf8591.h"
 #include "pcf8574.h"
-#include "max31855.h"
-#include "max5322.h"
+#include "pcf8591.h"
 #include "mcp3002.h"
 #include "mcp3004.h"
 #include "mcp4802.h"
 #include "mcp3422.h"
+#include "max31855.h"
+#include "max5322.h"
 #include "sn3218.h"
 #include "drcSerial.h"
 
@@ -664,6 +664,8 @@ static struct extensionFunctionStruct extensionFunctions [] =
 /*
  * loadWPiExtension:
  *	Load in a wiringPi extension
+ *	The extensionData always starts with the name, a colon then the pinBase
+ *	number. Other parameters after that are decoded by the module in question.
  *********************************************************************************
  */
 
@@ -676,7 +678,7 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
 
   verbose = printErrors ;
 
-// Get the extension extension name by finding the first colon
+// Get the extension name by finding the first colon
 
   p = extension ;
   while (*p != ':')
@@ -688,9 +690,10 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
     }
     ++p ;
   }
-
   *p++ = 0 ;
 
+// Simple ATOI code
+
   if (!isdigit (*p))
   {
     verbError ("%s: pinBase number expected after extension name", progName) ;
@@ -699,7 +702,7 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
 
   while (isdigit (*p))
   {
-    if (pinBase > 1000000000)
+    if (pinBase > 1000000000) // Lets be realistic here...
     {
       verbError ("%s: pinBase too large", progName) ;
       return FALSE ;
-- 
2.0.0.GIT

