build: Clean up build script and do uninstall/clean before install

This because to make sure removing legacy files that could occurs
library conflicts.

Signed-off-by: Yang Deokgyu <secugyu@gmail.com>
Change-Id: Id795969241ba925104d374b99b496c799b9ed1df
This commit is contained in:
Yang Deokgyu
2019-12-24 10:36:18 +09:00
parent 8bea63643a
commit 868f262b5d

189
build
View File

@@ -31,6 +31,13 @@
# back into education!
#################################################################################
sudo=${WIRINGPI_SUDO-sudo}
make="make -j $(( $(nproc) + 1 ))"
hardware=$(fgrep -a Hardware /proc/cpuinfo | head -1 | awk '{ printf("%s %s %s\n", $3, $4, $5) }' | xargs)
[ "$hardware",, != *"odroid"* ] \
&& [ -f "/sys/firmware/devicetree/base/model" ] \
&& hardware=$(cat /sys/firmware/devicetree/base/model)
check_make_ok() {
if [ $? != 0 ]; then
echo ""
@@ -74,92 +81,11 @@ configure_gpiomem() {
fi
}
sudo=${WIRINGPI_SUDO-sudo}
make="make -j $(( $(nproc) + 1 ))"
hardware=$(fgrep -a Hardware /proc/cpuinfo | head -1 | awk '{ printf("%s %s %s\n", $3, $4, $5) }' | xargs)
[ "$hardware",, != *"odroid"* ] \
&& [ -f "/sys/firmware/devicetree/base/model" ] \
&& hardware=$(cat /sys/firmware/devicetree/base/model)
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
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
cd ..
echo -n "Deconfigure /dev/gpiomem" ; configure_gpiomem uninstall
echo
exit
fi
# Only if you know what you're doing!
if [ x$1 = "xdebian" ]; then
here=`pwd`
cd debian-template/wiringPi
rm -rf usr
cd $here/wiringPi
$make install-deb
cd $here/devLib
$make install-deb INCLUDE='-I. -I../wiringPi'
cd $here/gpio
$make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
cd $here/debian-template
fakeroot dpkg-deb --build wiringPi
mv wiringPi.deb odroid-wiringpi-`cat $here/VERSION`.deb
exit
fi
if [ x$1 != "x" ]; then
echo "Usage: $0 [clean | uninstall]"
exit 1
fi
install() {
echo "wiringPi Build script"
echo "====================="
echo
# 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
@@ -203,27 +129,82 @@ fi
cd ..
configure_gpiomem
# echo
# echo "wiringPi Daemon"
# cd ../wiringPiD
# make
# check_make_ok
# $sudo $make install
# check_make_ok
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 ""
}
# echo
# echo "Examples"
# cd ../examples
# make
# cd ..
uninstall() {
cd wiringPi
echo -n "wiringPi: " ; $sudo $make uninstall
cd ../devLib
echo -n "DevLib: " ; $sudo $make uninstall
cd ../gpio
echo -n "gpio: " ; $sudo $make uninstall
cd ..
echo -n "Deconfigure /dev/gpiomem" ; configure_gpiomem uninstall
echo
}
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 ""
clean() {
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 ../..
}
if [ x$1 = "xclean" ]; then
clean
exit
fi
if [ x$1 = "xuninstall" ]; then
uninstall
exit
fi
# Only if you know what you're doing!
if [ x$1 = "xdebian" ]; then
here=`pwd`
cd debian-template/wiringPi
rm -rf usr
cd $here/wiringPi
$make install-deb
cd $here/devLib
$make install-deb INCLUDE='-I. -I../wiringPi'
cd $here/gpio
$make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
cd $here/debian-template
fakeroot dpkg-deb --build wiringPi
mv wiringPi.deb odroid-wiringpi-`cat $here/VERSION`.deb
exit
fi
if [ x$1 != "x" ]; then
echo "Usage: $0 [clean | uninstall]"
exit 1
fi
uninstall; clean; install