6 changed files with 398 additions and 0 deletions
			
			
		@ -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 <http://www.gnu.org/licenses/>. | 
				
			||||
################################################################################# | 
				
			||||
# | 
				
			||||
# 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 "" | 
				
			||||
@ -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) | 
				
			||||
@ -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 $<TARGET_OBJECTS:${DEVLIB}Obj>) | 
				
			||||
add_library(${DEVLIB}shared SHARED $<TARGET_OBJECTS:${DEVLIB}Obj>) | 
				
			||||
set_target_properties(${DEVLIB}shared PROPERTIES OUTPUT_NAME ${DEVLIB}) | 
				
			||||
 | 
				
			||||
install(TARGETS ${DEVLIB} ${DEVLIB}shared | 
				
			||||
    RUNTIME DESTINATION bin | 
				
			||||
    LIBRARY DESTINATION lib | 
				
			||||
    ARCHIVE DESTINATION lib) | 
				
			||||
@ -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 $<TARGET_OBJECTS:${GPIO}Obj>) | 
				
			||||
add_library(${GPIO}shared SHARED $<TARGET_OBJECTS:${GPIO}Obj>) | 
				
			||||
set_target_properties(${GPIO}shared PROPERTIES OUTPUT_NAME ${GPIO}) | 
				
			||||
 | 
				
			||||
install(TARGETS ${GPIO} ${GPIO}shared | 
				
			||||
    RUNTIME DESTINATION bin | 
				
			||||
    LIBRARY DESTINATION lib | 
				
			||||
    ARCHIVE DESTINATION lib) | 
				
			||||
@ -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 $<TARGET_OBJECTS:${WIRINGPI}Obj>) | 
				
			||||
add_library(${WIRINGPI}shared SHARED $<TARGET_OBJECTS:${WIRINGPI}Obj>) | 
				
			||||
set_target_properties(${WIRINGPI}shared PROPERTIES OUTPUT_NAME ${WIRINGPI}) | 
				
			||||
 | 
				
			||||
install(TARGETS ${WIRINGPI} ${WIRINGPI}shared | 
				
			||||
    RUNTIME DESTINATION bin | 
				
			||||
    LIBRARY DESTINATION lib | 
				
			||||
    ARCHIVE DESTINATION lib) | 
				
			||||
					Loading…
					
					
				
		Reference in new issue