home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / libsane / plustek / MakeModule.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-07-10  |  2.5 KB  |  114 lines

  1. #!/bin/bash
  2. #******************************************************************************
  3. #
  4. # Bash-Script to create Plustek-Scannerdriver modules for Kernel 2.4 & 2.6
  5. # out of the backend sources...
  6. #
  7.  
  8. BUILD_DIR=$PWD/build
  9. SRC_DIR=$PWD/../../backend
  10. MAKEFILE=$PWD/Makefile.kernel26
  11. KERNEL_V=`uname -r`
  12. OSMINOR=`uname -r | cut -b 3`
  13. OSMAJOR=`uname -r | cut -b 1`
  14.  
  15. #
  16. # some intro ;-)
  17. #
  18. echo "This script will try and build a suitable kernel-module for your system."
  19. echo "If you'd like to make the module WITH debug output, restart this script"
  20. echo "with as follows:"
  21. echo "./MakeModule.sh DEBUG=y"
  22. echo "Press <ENTER> to continue or <CTRL><C> to cancel."
  23. read
  24.  
  25. #
  26. # we need to be root user...
  27. #
  28. echo -n "Check for root..."
  29. if [ $EUID -ne 0 ]; then
  30.     echo -e "\b\b\b - failed"
  31.     echo "Please retry as root user."
  32.     exit -1
  33. fi
  34. echo -e "\b\b\b - done."
  35.  
  36. #
  37. # Version checks...
  38. #
  39. echo -e "\nCheck for kernelversion:"
  40. if [ "$OSMINOR" == "6" ]; then
  41.     echo "Using makefile for kernel 2.6.x"
  42.     MAKEFILE=$PWD/Makefile.kernel26
  43. elif [ "$OSMINOR" == "4" ]; then
  44.     echo "Using makefile for kernel 2.4.x"
  45.     MAKEFILE=$PWD/Makefile.kernel24
  46. else
  47.     echo "Your kernelversion >"$OSMAJOR"."$OSMINOR"< is probably not supported"
  48.     exit -2
  49. fi
  50.  
  51. #
  52. # Setup...
  53. #
  54. echo -e "Build-directory: \n"$BUILD_DIR
  55. echo -n "Removing build-directory..."
  56. rm -rf $BUILD_DIR
  57. echo -e "\b\b\b - done."
  58.  
  59. echo -n "Creating build-directory..."
  60. mkdir $BUILD_DIR
  61. cd $BUILD_DIR
  62. echo -e "\b\b\b - done.\n"
  63.  
  64. echo -n "Linking source files..."
  65. C_FILES=`ls $SRC_DIR/plustek-pp_*.c`
  66. H_FILES=`ls $SRC_DIR/plustek-pp_*.h`
  67.  
  68. for F in $C_FILES $H_FILES $SRC_DIR/plustek-pp.h $SRC_DIR/plustek_pp.c; do
  69.     ln -s $F .
  70. done
  71. echo -e "\b\b\b - done."
  72.  
  73. echo -n "Copying Makefile to build-directory..."
  74. cp $MAKEFILE Makefile
  75. echo -e "\b\b\b - done."
  76.  
  77. #
  78. # Building the module...
  79. #
  80. echo "Making the module..."
  81. if [ "$OSMINOR" == "4" ]; then
  82.     make all $1
  83. else
  84.     make -C /lib/modules/$KERNEL_V/build/ SUBDIRS=$BUILD_DIR modules $1
  85. fi
  86. RES=$?
  87. cd ..
  88. if [ $RES != 0 ]; then
  89.     echo "There were some build errors..."
  90.     exit -1
  91. fi
  92. echo "done."
  93.  
  94. echo "Should I install the module?"
  95. echo "Press <ENTER> to continue or <CTRL><C> to cancel."
  96. read
  97.  
  98. make -C $BUILD_DIR install
  99.  
  100. echo "Should I try and load the module?"
  101. echo "If this step fails, check the kernel-log."
  102. echo "Press <ENTER> to continue or <CTRL><C> to cancel."
  103. read
  104.  
  105. make -C $BUILD_DIR load
  106. echo "done."
  107.  
  108. echo "Should I remove the build directory?"
  109. echo "Press <ENTER> to continue or <CTRL><C> to cancel."
  110. read
  111.  
  112. rm -rf $BUILD_DIR
  113. echo "done."
  114.