#!/bin/bash ARGS=$@ MODULE_NAME=windrvr6 LINUX_USB_SUPPORT=yes USE_KBUILD=no KERNEL_DIR="" ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac case $ac_option in --disable-usb-support) LINUX_USB_SUPPORT=no ;; --enable-usb-support=no) LINUX_USB_SUPPORT=no ;; --with-kernel-source) ac_prev=$ac_option ;; --with-kernel-source=*) KERNEL_DIR=$ac_optarg ;; --enable-kbuild) USE_KBUILD=yes ;; esac done VER=`uname -r` VER_BASE=`echo $VER | cut -c 1-3` VER_SUBMINOR=`echo $VER | cut -f 3 -d "." | cut -f 1 -d "-"` if test -z $KERNEL_DIR ; then KERNEL_DIR=/lib/modules/$VER/build KERNEL_SRC=/lib/modules/$VER/source fi if test ! -d $KERNEL_DIR ; then KERNEL_DIR=/usr/src/linux if test ! -d $KERNEL_DIR ; then echo "$ac_t""not found" 1>&6 { echo "configure: error: please install the kernel source or \ specify alternate location" 1>&2; exit 1; } fi fi if test -d $KERNEL_SRC/include ; then INCLUDEDIRS="-I$KERNEL_SRC/include" else if test -d $KERNEL_DIR/include ; then INCLUDEDIRS="-I$KERNEL_DIR/include" fi fi if test $USE_KBUILD = "no" -a $VER_BASE = "2.6" -a $VER_SUBMINOR -ge 26; then USE_KBUILD=yes ARGS="$ARGS --enable-kbuild" fi echo "USE_KBUILD = $USE_KBUILD" if test $VER_BASE = "2.2" ; then LINUX_USB_SUPPORT=no else if test $LINUX_USB_SUPPORT = yes ; then # Verify that USB is supported in this kernel mkdir -p .tmp_driver cd .tmp_driver if test $VER_BASE = "2.6" -a $VER_SUBMINOR -ge 33; then echo "#include " >> hello.c else if test $VER_BASE = "2.6" -a $VER_SUBMINOR -ge 17; then echo "#include " >> hello.c else echo "#include " >> hello.c fi fi echo "#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)" >> hello.c echo "int usb_support;" >> hello.c echo "#endif" >> hello.c echo "int init_module(void) { return 0; }" >> hello.c echo "void cleanup_module(void) {}" >> hello.c USB_SUPPORT=`gcc -E -D__KERNEL__ hello.c $INCLUDEDIRS | grep -c usb_support` if test $USB_SUPPORT = 0; then LINUX_USB_SUPPORT=no fi cd .. rm -rf .tmp_driver fi fi cat makefile.in | sed "s/@MODULE_NAME@/$MODULE_NAME/g" | \ sed "s/@LINUX_USB_SUPPORT@/$LINUX_USB_SUPPORT/g" | \ sed "s/@USE_KBUILD@/$USE_KBUILD/g" > makefile if test $LINUX_USB_SUPPORT = yes ; then ./configure.usb $ARGS ARGS="$ARGS --enable-usb-support" else ARGS="$ARGS --disable-usb-support" fi ./configure.wd $ARGS