diff --git a/.gitignore b/.gitignore
index e6ad4ba..4ea6884 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@ debian-template/wiringpi-*.deb
gpio/gpio
examples/speed
examples/blink
+build/
\ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..e62f18f
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,298 @@
+#!/bin/bash -e
+
+# build
+# Simple wiringPi build and install script
+#
+# Copyright (c) 2012-2015 Gordon Henderson
+#################################################################################
+# This file is part of wiringPi:
+# A "wiring" 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 .
+#################################################################################
+#
+# wiringPi is designed to run on a Raspberry Pi only.
+# However if you're clever enough to actually look at this script to
+# see why it's not building for you, then good luck.
+#
+# To everyone else: Stop using cheap alternatives. Support the
+# Raspberry Pi Foundation as they're the only ones putting money
+# back into education!
+#################################################################################
+
+check_make_ok() {
+ if [ $? != 0 ]; then
+ echo ""
+ echo "Make Failed..."
+ echo "Please check the messages and fix any problems. If you're still stuck,"
+ echo "then please email all the output and as many details as you can to"
+ echo " projects@drogon.net"
+ echo ""
+ exit 1
+ fi
+}
+
+select_boards()
+{
+ local cnt=0
+ local choice
+ local call=${1}
+
+ boards=("orangepir1"
+ "orangepizero"
+ "orangepizero-lts"
+ "orangepipc"
+ "orangepipch5"
+ "orangepipcplus"
+ "orangepiplus2e"
+ "orangepione"
+ "orangepioneh5"
+ "orangepilite"
+ "orangepiplus"
+ "orangepizeroplus2h3"
+ "orangepizeroplus"
+ "orangepipc2"
+ "orangepiprime"
+ "orangepizeroplus2h5"
+ "orangepiwin"
+ "orangepiwinplus"
+ "orangepi3"
+ "orangepi3-lts"
+ "orangepilite2"
+ "orangepioneplus"
+ "orangepi4"
+ "orangepi4-lts"
+ "orangepirk3399"
+ "orangepi800"
+ "orangepizero2"
+ "orangepizero2-lts"
+ "orangepizero2-b"
+ "orangepir1plus-lts"
+ "orangepir1plus")
+
+ if [[ -f /etc/orangepi-release ]]; then
+
+ source /etc/orangepi-release
+
+ elif [[ -f /etc/armbian-release ]]; then
+
+ source /etc/armbian-release
+ [[ $BOARD == orangepi-r1 ]] && BOARD=orangepir1
+ [[ $BOARD == orangepi-rk3399 ]] && BOARD=orangepirk3399
+ [[ $BOARD == orangepizeroplus2-h3 ]] && BOARD=orangepizeroplus2h3
+ [[ $BOARD == orangepizeroplus2-h5 ]] && BOARD=orangepizeroplus2h5
+
+ else
+
+ printf "All available boards:\n"
+ for var in ${boards[@]} ; do
+ printf "%4d. %s\n" $cnt ${boards[$cnt]}
+ ((cnt+=1))
+ done
+
+ while true ; do
+ read -p "Choice: " choice
+ if [ -z "${choice}" ] ; then
+ continue
+ fi
+ if [ -z "${choice//[0-9]/}" ] ; then
+ if [ $choice -ge 0 -a $choice -lt $cnt ] ; then
+ export BOARD="${boards[$choice]}"
+ break
+ fi
+ fi
+ printf "Invalid input ...\n"
+ done
+ fi
+
+ [[ $BOARD == orangepir1 ]] && BOARD=orangepir1-h2
+ [[ $BOARD == orangepizero ]] && BOARD=orangepizero-h2
+ [[ $BOARD == orangepizero-lts ]] && BOARD=orangepizero-h2
+ [[ $BOARD == orangepipc ]] && BOARD=orangepipc-h3
+ [[ $BOARD == orangepipch5 ]] && BOARD=orangepipc-h3
+ [[ $BOARD == orangepipcplus ]] && BOARD=orangepipcplus-h3
+ [[ $BOARD == orangepiplus2e ]] && BOARD=orangepiplus2e-h3
+ [[ $BOARD == orangepione ]] && BOARD=orangepione-h3
+ [[ $BOARD == orangepioneh5 ]] && BOARD=orangepione-h3
+ [[ $BOARD == orangepilite ]] && BOARD=orangepilite-h3
+ [[ $BOARD == orangepiplus ]] && BOARD=orangepiplus-h3
+ [[ $BOARD == orangepizeroplus ]] && BOARD=orangepizeroplus-h5
+ [[ $BOARD == orangepipc2 ]] && BOARD=orangepipc2-h5
+ [[ $BOARD == orangepiprime ]] && BOARD=orangepiprime-h5
+ [[ $BOARD == orangepiwin ]] && BOARD=orangepiwin-a64
+ [[ $BOARD == orangepiwinplus ]] && BOARD=orangepiwinplus-a64
+ [[ $BOARD == orangepi3 ]] && BOARD=orangepi3-h6
+ [[ $BOARD == orangepi3-lts ]] && BOARD=orangepi3-h6
+ [[ $BOARD == orangepilite2 ]] && BOARD=orangepilite2-h6
+ [[ $BOARD == orangepioneplus ]] && BOARD=orangepioneplus-h6
+ [[ $BOARD == orangepizero2 ]] && BOARD=orangepizero2-h616
+ [[ $BOARD == orangepizero2-lts ]] && BOARD=orangepizero2-h616
+ [[ $BOARD == orangepizero2-b ]] && BOARD=orangepizero2-h616
+ [[ $BOARD == orangepir1plus ]] && BOARD=orangepir1plus-rk3328
+ [[ $BOARD == orangepir1plus-lts ]] && BOARD=orangepir1plus-rk3328
+
+ export BOARD="${BOARD}"
+}
+
+sudo=${WIRINGPI_SUDO-sudo}
+
+if [ x$1 = "xclean" ]; then
+ cd wiringPi
+ echo -n "wiringPi: " ; make clean
+ cd ../devLib
+ echo -n "DevLib: " ; make clean
+ cd ../gpio
+ echo -n "gpio: " ; make clean
+ cd ../examples
+ echo -n "Examples: " ; make clean
+ cd Gertboard
+ echo -n "Gertboard: " ; make clean
+ cd ../PiFace
+ echo -n "PiFace: " ; make clean
+ cd ../q2w
+ echo -n "Quick2Wire: " ; make clean
+ cd ../PiGlow
+ echo -n "PiGlow: " ; make clean
+ cd ../scrollPhat
+ echo -n "scrollPhat: " ; make clean
+ cd ../..
+ echo -n "Deb: " ; rm -f debian-template/wiringpi*.deb
+ echo
+ exit
+fi
+
+if [ x$1 = "xuninstall" ]; then
+ cd wiringPi
+ echo -n "wiringPi: " ; $sudo make uninstall
+ cd ../devLib
+ echo -n "DevLib: " ; $sudo make uninstall
+ cd ../gpio
+ echo -n "gpio: " ; $sudo make uninstall
+ exit
+fi
+
+# Only if you know what you're doing!
+
+if [ x$1 = "xdebian" ]; then
+ here=`pwd`
+ echo "removing old libs"
+ cd debian-template/wiringPi
+ rm -rf usr
+ echo "building wiringPi"
+ cd $here/wiringPi
+ make install-deb
+ echo "building devLib"
+ cd $here/devLib
+ make install-deb INCLUDE='-I. -I../wiringPi'
+ echo "building gpio"
+ cd $here/gpio
+ make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
+ echo "Building deb package"
+ cd $here/debian-template
+ 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
+
+ select_boards
+
+ echo "wiringPi Build script"
+ echo "====================="
+ echo
+
+ hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
+
+# if [ x$hardware != "xBCM2708" ]; then
+# echo ""
+# echo " +------------------------------------------------------------+"
+# echo " | wiringPi is designed to run on the Raspberry Pi only. |"
+# echo " | This processor does not appear to be a Raspberry Pi. |"
+# echo " +------------------------------------------------------------+"
+# echo " | In the unlikely event that you think it is a Raspberry Pi, |"
+# echo " | then please accept my apologies and email the contents of |"
+# echo " | /proc/cpuinfo to projects@drogon.net. |"
+# echo " | - Thanks, Gordon |"
+# echo " +------------------------------------------------------------+"
+# echo ""
+# exit 1
+# fi
+
+
+ echo
+ echo "WiringPi Library"
+ cd wiringPi
+ $sudo make uninstall
+ if [ x$1 = "xstatic" ]; then
+ make -j5 static
+ check_make_ok
+ $sudo make install-static
+ else
+ make -j5
+ check_make_ok
+ $sudo make install
+ fi
+ check_make_ok
+
+ echo
+ echo "WiringPi Devices Library"
+ cd ../devLib
+ $sudo make uninstall
+ if [ x$1 = "xstatic" ]; then
+ make -j5 static
+ check_make_ok
+ $sudo make install-static
+ else
+ make -j5
+ check_make_ok
+ $sudo make install
+ fi
+ check_make_ok
+
+ echo
+ echo "GPIO Utility"
+ cd ../gpio
+ make -j5
+ check_make_ok
+ $sudo make install
+ check_make_ok
+
+# echo
+# echo "wiringPi Daemon"
+# cd ../wiringPiD
+# make -j5
+# check_make_ok
+# $sudo make install
+# check_make_ok
+
+# echo
+# echo "Examples"
+# cd ../examples
+# make
+# cd ..
+
+echo
+echo All Done.
+echo ""
+echo "NOTE: To compile programs with wiringPi, you need to add:"
+echo " -lwiringPi"
+echo " to your compile line(s) To use the Gertboard, MaxDetect, etc."
+echo " code (the devLib), you need to also add:"
+echo " -lwiringPiDev"
+echo " to your compile line(s)."
+echo ""
diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake
new file mode 100644
index 0000000..931f783
--- /dev/null
+++ b/cmake/toolchain.cmake
@@ -0,0 +1,9 @@
+set(CMAKE_AR /usr/bin/arm-linux-gnueabihf-ar)
+set(CMAKE_ASM_COMPILER /usr/bin/arm-linux-gnueabihf-as)
+set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
+set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)
+set(CMAKE_LINKER /usr/bin/arm-linux-gnueabihf-ld)
+set(CMAKE_OBJCOPY /usr/bin/arm-linux-gnueabihf-objcopy)
+set(CMAKE_RANLIB /usr/bin/arm-linux-gnueabihf-ranlib)
+set(CMAKE_SIZE /usr/bin/arm-linux-gnueabihf-size)
+set(CMAKE_STRIP /usr/bin/arm-linux-gnueabihf-strip)
\ No newline at end of file
diff --git a/devLib/CMakeLists.txt b/devLib/CMakeLists.txt
new file mode 100644
index 0000000..0f205e2
--- /dev/null
+++ b/devLib/CMakeLists.txt
@@ -0,0 +1,23 @@
+set(DEVLIB devLib)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+add_library(${DEVLIB}Obj OBJECT
+ ds1302.c
+ maxdetect.c
+ piNes.c
+ gertboard.c
+ piFace.c
+ lcd128x64.c
+ lcd.c
+ scrollPhat.c
+ piGlow.c)
+
+add_library(${DEVLIB} STATIC $)
+add_library(${DEVLIB}shared SHARED $)
+set_target_properties(${DEVLIB}shared PROPERTIES OUTPUT_NAME ${DEVLIB})
+
+install(TARGETS ${DEVLIB} ${DEVLIB}shared
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
\ No newline at end of file
diff --git a/gpio/CMakeLists.txt b/gpio/CMakeLists.txt
new file mode 100644
index 0000000..5130255
--- /dev/null
+++ b/gpio/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(GPIO gpio)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+add_library(${GPIO}Obj OBJECT
+ gpio.c
+ readall.c
+ OrangePi.c)
+
+add_library(${GPIO} STATIC $)
+add_library(${GPIO}shared SHARED $)
+set_target_properties(${GPIO}shared PROPERTIES OUTPUT_NAME ${GPIO})
+
+install(TARGETS ${GPIO} ${GPIO}shared
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
\ No newline at end of file
diff --git a/wiringPi/CMakeLists.txt b/wiringPi/CMakeLists.txt
new file mode 100644
index 0000000..f37dda8
--- /dev/null
+++ b/wiringPi/CMakeLists.txt
@@ -0,0 +1,50 @@
+set(WIRINGPI wiringPi)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+add_library(${WIRINGPI}Obj OBJECT
+ wiringPi.c
+ wiringSerial.c
+ wiringShift.c
+ piHiPri.c
+ piThread.c
+ wiringPiSPI.c
+ wiringPiI2C.c
+ softPwm.c
+ softTone.c
+ mcp23008.c
+ mcp23016.c
+ mcp23017.c
+ mcp23s08.c
+ mcp23s17.c
+ sr595.c
+ pcf8574.c
+ pcf8591.c
+ mcp3002.c
+ mcp3004.c
+ mcp4802.c
+ mcp3422.c
+ max31855.c
+ max5322.c
+ ads1115.c
+ sn3218.c
+ bmp180.c
+ htu21d.c
+ ds18b20.c
+ rht03.c
+ drcSerial.c
+ drcNet.c
+ pseudoPins.c
+ wpiExtensions.c
+ w25q64.c
+ oled.c
+ OrangePi.c)
+
+add_library(${WIRINGPI} STATIC $)
+add_library(${WIRINGPI}shared SHARED $)
+set_target_properties(${WIRINGPI}shared PROPERTIES OUTPUT_NAME ${WIRINGPI})
+
+install(TARGETS ${WIRINGPI} ${WIRINGPI}shared
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
\ No newline at end of file