yann@1: --- uClibc-0.9.28/extra/scripts/fix_includes.sh.orig 2006-12-13 05:44:21.000000000 -0700 yann@1: +++ uClibc-0.9.28/extra/scripts/fix_includes.sh 2006-12-13 05:44:35.000000000 -0700 yann@1: @@ -1,183 +1,155 @@ yann@1: #!/bin/sh yann@1: -# Copyright (C) 2003 Erik Andersen yann@1: # yann@1: -# This program is free software; you can redistribute it and/or yann@1: -# modify it under the terms of the GNU Library General Public yann@1: -# License as published by the Free Software Foundation; either yann@1: -# version 2 of the License, or (at your option) any later yann@1: -# version. yann@1: -# yann@1: -# This program is distributed in the hope that it will be useful, yann@1: -# but WITHOUT ANY WARRANTY; without even the implied warranty of yann@1: -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the yann@1: -# GNU Library General Public License for more details. yann@1: -# yann@1: -# You should have received a copy of the GNU Library General yann@1: -# Public License along with this program; if not, write to the yann@1: -# Free Software Foundation, Inc., 59 Temple Place, Suite 330, yann@1: -# Boston, MA 02111-1307 USA yann@1: - yann@1: -usage () { yann@1: - echo "" yann@1: - echo "usage: "`basename $0`" -k KERNEL_SOURCE_DIRECTORY -t TARGET_ARCH" yann@1: - echo "" yann@1: - echo "This utility scans the KERNEL_SOURCE_DIRECTORY directory and" yann@1: - echo "checks that it contains well formed kernel headers suitable" yann@1: - echo "for inclusion as the include/linux/ directory provided by" yann@1: - echo "uClibc." yann@1: - echo "" yann@1: - echo "If the specified kernel headers are present and already" yann@1: - echo "configured for the architecture specified by TARGET_ARCH," yann@1: - echo "they will be used as-is." yann@1: - echo "" yann@1: - echo "If the specified kernel headers are missing entirely, this" yann@1: - echo "script will return an error." yann@1: - echo "" yann@1: - echo "If the specified kernel headers are present, but are either" yann@1: - echo "not yet configured or are configured for an architecture" yann@1: - echo "different than that specified by TARGET_ARCH, this script" yann@1: - echo "will attempt to 'fix' the kernel headers and make them" yann@1: - echo "suitable for use by uClibc. This fixing process may fail." yann@1: - echo "It is therefore best to always provide kernel headers that" yann@1: - echo "are already configured for the selected architecture." yann@1: - echo "" yann@1: - echo "Most Linux distributions provide 'kernel-headers' packages" yann@1: - echo "that are suitable for use by uClibc." yann@1: - echo "" yann@1: - echo "" yann@1: - exit 1; yann@1: +# Copyright (C) 2000-2005 Erik Andersen yann@1: +# yann@1: +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. yann@1: +# yann@1: + yann@1: +usage() { yann@1: + echo "" yann@1: + echo "usage: "`basename $0`" -k KERNEL_SOURCE_DIRECTORY -t TARGET_ARCH" yann@1: + echo "" yann@1: + echo "This utility scans the KERNEL_SOURCE_DIRECTORY directory and" yann@1: + echo "checks that it contains well formed kernel headers suitable" yann@1: + echo "for inclusion as the include/linux/ directory provided by" yann@1: + echo "uClibc." yann@1: + echo "" yann@1: + echo "If the specified kernel headers are present and already" yann@1: + echo "configured for the architecture specified by TARGET_ARCH," yann@1: + echo "they will be used as-is." yann@1: + echo "" yann@1: + echo "If the specified kernel headers are missing entirely, this" yann@1: + echo "script will return an error." yann@1: + echo "" yann@1: + echo "If the specified kernel headers are present, but are either" yann@1: + echo "not yet configured or are configured for an architecture" yann@1: + echo "different than that specified by TARGET_ARCH, this script" yann@1: + echo "will attempt to 'fix' the kernel headers and make them" yann@1: + echo "suitable for use by uClibc. This fixing process may fail." yann@1: + echo "It is therefore best to always provide kernel headers that" yann@1: + echo "are already configured for the selected architecture." yann@1: + echo "" yann@1: + echo "Most Linux distributions provide 'kernel-headers' packages" yann@1: + echo "that are suitable for use by uClibc." yann@1: + echo "" yann@1: + echo "" yann@1: + exit 1 yann@1: } yann@1: yann@1: -HAS_MMU="y"; yann@1: + yann@1: +# yann@1: +# Parse our arguments yann@1: +# yann@1: +HAS_MMU="y" yann@1: while [ -n "$1" ]; do yann@1: - case $1 in yann@1: - -k ) shift; if [ -n "$1" ]; then KERNEL_SOURCE=$1; shift; else usage; fi; ;; yann@1: - -t ) shift; if [ -n "$1" ]; then TARGET_ARCH=$1; shift; else usage; fi; ;; yann@1: - -n ) shift; HAS_MMU="n"; ;; yann@1: - -* ) usage; ;; yann@1: - * ) usage; ;; yann@1: - esac; yann@1: -done; yann@1: + case $1 in yann@1: + -k ) shift; if [ -n "$1" ]; then KERNEL_SOURCE=$1; shift; else usage; fi; ;; yann@1: + -t ) shift; if [ -n "$1" ]; then TARGET_ARCH=$1; shift; else usage; fi; ;; yann@1: + -n ) shift; HAS_MMU="n"; ;; yann@1: + -* ) usage; ;; yann@1: + * ) usage; ;; yann@1: + esac yann@1: +done yann@1: yann@1: -if [ ! -f "$KERNEL_SOURCE/Makefile" -a ! -f "$KERNEL_SOURCE/include/linux/version.h" ]; then yann@1: - echo ""; yann@1: - echo ""; yann@1: - echo "The file $KERNEL_SOURCE/Makefile or $KERNEL_SOURCE/include/linux/version.h is missing!"; yann@1: - echo "Perhaps your kernel source is broken?" yann@1: - echo ""; yann@1: - echo ""; yann@1: - exit 1; yann@1: -fi; yann@1: yann@1: -if [ ! -d "$KERNEL_SOURCE" ]; then yann@1: - echo ""; yann@1: - echo ""; yann@1: - echo "$KERNEL_SOURCE is not a directory"; yann@1: - echo ""; yann@1: - echo ""; yann@1: - exit 1; yann@1: -fi; yann@1: - yann@1: -if [ -f "$KERNEL_SOURCE/Makefile" ] ; then yann@1: -# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION yann@1: -eval `sed -n -e 's/^\([A-Z]*\) = \([0-9]*\)$/\1=\2/p' -e 's/^\([A-Z]*\) = \(-[-a-z0-9]*\)$/\1=\2/p' $KERNEL_SOURCE/Makefile` yann@1: -else yann@1: -ver=`grep UTS_RELEASE $KERNEL_SOURCE/include/linux/version.h | cut -d '"' -f 2` yann@1: -VERSION=`echo "$ver" | cut -d '.' -f 1` yann@1: -PATCHLEVEL=`echo "$ver" | cut -d '.' -f 2` yann@1: -if echo "$ver" | grep -q '-' ; then yann@1: -SUBLEVEL=`echo "$ver" | sed "s/${VERSION}.${PATCHLEVEL}.//" | cut -d '-' -f 1` yann@1: -EXTRAVERSION=`echo "$ver" | sed "s/${VERSION}.${PATCHLEVEL}.${SUBLEVEL}-//"` yann@1: -else yann@1: -SUBLEVEL=`echo "$ver" | cut -d '.' -f 3` yann@1: -#EXTRAVERSION= yann@1: -fi yann@1: +# yann@1: +# Perform some sanity checks on our kernel sources yann@1: +# yann@1: +if [ ! -f "$KERNEL_SOURCE/Makefile" -a ! -f "$KERNEL_SOURCE/include/linux/version.h" ]; then yann@1: + echo "" yann@1: + echo "" yann@1: + echo "The file $KERNEL_SOURCE/Makefile or $KERNEL_SOURCE/include/linux/version.h is missing!" yann@1: + echo "Perhaps your kernel source is broken?" yann@1: + echo "" yann@1: + echo "" yann@1: + exit 1 yann@1: fi yann@1: -if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ] yann@1: -then yann@1: - echo "Unable to determine version for kernel headers" yann@1: - echo -e "\tprovided in directory $KERNEL_SOURCE" yann@1: - exit 1 yann@1: +if [ ! -d "$KERNEL_SOURCE" ]; then yann@1: + echo "" yann@1: + echo "" yann@1: + echo "$KERNEL_SOURCE is not a directory" yann@1: + echo "" yann@1: + echo "" yann@1: + exit 1 yann@1: fi yann@1: yann@1: -if [ "$MAKE_IS_SILENT" != "y" ]; then yann@1: -echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION}" yann@1: -echo -e "\n" yann@1: -echo "Using kernel headers from $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} for architecture '$TARGET_ARCH'" yann@1: -echo -e "\tprovided in directory $KERNEL_SOURCE" yann@1: -echo -e "\n" yann@1: -fi yann@1: yann@1: +# yann@1: # Create a symlink to include/asm yann@1: - yann@1: +# yann@1: rm -f include/asm* yann@1: if [ ! -d "$KERNEL_SOURCE/include/asm" ]; then yann@1: - echo ""; yann@1: - echo ""; yann@1: - echo "The symlink $KERNEL_SOURCE/include/asm is missing\!"; yann@1: - echo "Perhaps you forgot to configure your kernel source?"; yann@1: - echo "You really should configure your kernel source tree so I"; yann@1: - echo "do not have to try and guess about this sort of thing."; yann@1: - echo "" yann@1: - echo "Attempting to guess a usable value...."; yann@1: - echo "" yann@1: - echo ""; yann@1: - sleep 1; yann@1: - yann@1: - if [ "$TARGET_ARCH" = "powerpc" ];then yann@1: - set -x; yann@1: - ln -fs $KERNEL_SOURCE/include/asm-ppc include/asm; yann@1: - set +x; yann@1: - elif [ "$TARGET_ARCH" = "mips" ];then yann@1: - set -x; yann@1: - ln -fs $KERNEL_SOURCE/include/asm-mips include/asm; yann@1: - set +x; yann@1: - elif [ "$TARGET_ARCH" = "arm" ];then yann@1: - set -x; yann@1: - ln -fs $KERNEL_SOURCE/include/asm-arm include/asm; yann@1: - set +x; yann@1: - if [ ! -L $KERNEL_SOURCE/include/asm-arm/proc ] ; then yann@1: - if [ ! -L proc ] ; then yann@1: - (cd include/asm; yann@1: - ln -fs proc-armv proc; yann@1: - ln -fs arch-ebsa285 arch); yann@1: - fi yann@1: + echo "" yann@1: + echo "" yann@1: + echo "The symlink $KERNEL_SOURCE/include/asm is missing\!" yann@1: + echo "Perhaps you forgot to configure your kernel source?" yann@1: + echo "You really should configure your kernel source tree so I" yann@1: + echo "do not have to try and guess about this sort of thing." yann@1: + echo "" yann@1: + echo "Attempting to guess a usable value...." yann@1: + echo "" yann@1: + echo "" yann@1: + sleep 1 yann@1: + yann@1: + if [ "$TARGET_ARCH" = "powerpc" ]; then yann@1: + set -x yann@1: + ln -fs $KERNEL_SOURCE/include/asm-ppc include/asm yann@1: + set +x yann@1: + elif [ "$TARGET_ARCH" = "mips" ]; then yann@1: + set -x yann@1: + ln -fs $KERNEL_SOURCE/include/asm-mips include/asm yann@1: + set +x yann@1: + elif [ "$TARGET_ARCH" = "arm" ]; then yann@1: + set -x yann@1: + ln -fs $KERNEL_SOURCE/include/asm-arm include/asm yann@1: + set +x yann@1: + if [ ! -L $KERNEL_SOURCE/include/asm-arm/proc ]; then yann@1: + if [ ! -L proc ]; then yann@1: + ( yann@1: + cd include/asm yann@1: + ln -fs proc-armv proc yann@1: + ln -fs arch-ebsa285 arch yann@1: + ) yann@1: + fi yann@1: + fi yann@1: + elif [ "$TARGET_ARCH" = "cris" ]; then yann@1: + set -x yann@1: + ln -fs $KERNEL_SOURCE/include/asm-cris include/asm yann@1: + set +x yann@1: + elif [ "$HAS_MMU" != "y" ]; then yann@1: + if [ -d $KERNEL_SOURCE/include/asm-${TARGET_ARCH}nommu ]; then yann@1: + set -x yann@1: + ln -fs $KERNEL_SOURCE/include/asm-${TARGET_ARCH}nommu include/asm yann@1: + set +x yann@1: + else yann@1: + set -x yann@1: + ln -fs $KERNEL_SOURCE/include/asm-$TARGET_ARCH include/asm yann@1: + set +x yann@1: + fi yann@1: + else yann@1: + set -x yann@1: + ln -fs $KERNEL_SOURCE/include/asm-$TARGET_ARCH include/asm yann@1: + set +x yann@1: fi; yann@1: - elif [ "$TARGET_ARCH" = "cris" ]; then yann@1: - set -x; yann@1: - ln -fs $KERNEL_SOURCE/include/asm-cris include/asm; yann@1: - set +x; yann@1: - elif [ "$HAS_MMU" != "y" ]; then yann@1: - if [ -d $KERNEL_SOURCE/include/asm-${TARGET_ARCH}nommu ] ; then yann@1: - set -x; yann@1: - ln -fs $KERNEL_SOURCE/include/asm-${TARGET_ARCH}nommu include/asm; yann@1: - set +x; yann@1: - else yann@1: - set -x; yann@1: - ln -fs $KERNEL_SOURCE/include/asm-$TARGET_ARCH include/asm; yann@1: - set +x; yann@1: - fi; yann@1: - else yann@1: - set -x; yann@1: - ln -fs $KERNEL_SOURCE/include/asm-$TARGET_ARCH include/asm; yann@1: - set +x; yann@1: - fi; yann@1: else yann@1: -# No guessing required..... yann@1: -ln -fs $KERNEL_SOURCE/include/asm include/asm yann@1: -if [ -e $KERNEL_SOURCE/include/asm-$TARGET_ARCH ] ; then yann@1: -ln -fs $KERNEL_SOURCE/include/asm-$TARGET_ARCH include/asm-$TARGET_ARCH yann@1: + # No guessing required..... yann@1: + for x in $KERNEL_SOURCE/include/asm* ; do yann@1: + ln -fs ${x} include/ yann@1: + done yann@1: fi yann@1: -fi; yann@1: yann@1: yann@1: +# yann@1: # Annoyingly, 2.6.x kernel headers also need an include/asm-generic/ directory yann@1: -if [ $VERSION -eq 2 ] && [ $PATCHLEVEL -ge 6 ] ; then yann@1: - ln -fs $KERNEL_SOURCE/include/asm-generic include/asm-generic yann@1: -fi; yann@1: +# yann@1: +if [ -e $KERNEL_SOURCE/include/asm-generic ]; then yann@1: + rm -f include/asm-generic yann@1: + ln -fs $KERNEL_SOURCE/include/asm-generic include/asm-generic yann@1: +fi yann@1: yann@1: yann@1: +# yann@1: # Create the include/linux symlink. yann@1: +# yann@1: rm -f include/linux yann@1: ln -fs $KERNEL_SOURCE/include/linux include/linux yann@1: -