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! # 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() { check_make_ok() {
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "" echo ""
@@ -74,92 +81,11 @@ configure_gpiomem() {
fi fi
} }
sudo=${WIRINGPI_SUDO-sudo} install() {
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
echo "wiringPi Build script" echo "wiringPi Build script"
echo "=====================" echo "====================="
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
echo "WiringPi Library" echo "WiringPi Library"
cd wiringPi cd wiringPi
@@ -203,27 +129,82 @@ fi
cd .. cd ..
configure_gpiomem configure_gpiomem
# echo echo
# echo "wiringPi Daemon" echo All Done.
# cd ../wiringPiD echo ""
# make echo "NOTE: To compile programs with wiringPi, you need to add:"
# check_make_ok echo " -lwiringPi"
# $sudo $make install echo " to your compile line(s) To use the Gertboard, MaxDetect, etc."
# check_make_ok echo " code (the devLib), you need to also add:"
echo " -lwiringPiDev"
echo " to your compile line(s)."
echo ""
}
# echo uninstall() {
# echo "Examples" cd wiringPi
# cd ../examples echo -n "wiringPi: " ; $sudo $make uninstall
# make cd ../devLib
# cd .. 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 clean() {
echo All Done. cd wiringPi
echo "" echo -n "wiringPi: " ; $make clean
echo "NOTE: To compile programs with wiringPi, you need to add:" cd ../devLib
echo " -lwiringPi" echo -n "DevLib: " ; $make clean
echo " to your compile line(s) To use the Gertboard, MaxDetect, etc." cd ../gpio
echo " code (the devLib), you need to also add:" echo -n "gpio: " ; $make clean
echo " -lwiringPiDev" cd ../examples
echo " to your compile line(s)." echo -n "Examples: " ; $make clean
echo "" 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