[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Maintaining kernel module packages?



On Mon, May 21, 2001 at 08:50:12PM +1000, Herbert Xu wrote:
> 
> You don't need the .config file as the headers package have already
> gone through a make oldconfig + make dep.  And since we're talking
> about Debian packages here, architecture, cross-compilation prefix,
> toolchains etc. are meaningless.

Yes, we're talking about Debian packages (or potential Debian
packages), but such the build systems already existing extract
this information from the kernel.  From my perspective, it seems
as though changing working code to use a system that is less
capable and potentially broken is, well, dumb.

You still need the .config file, in order to extract necessary
details like CONFIG_M486, CONFIG_X86, CONFIG_PROC_FS, CONFIG_PCI,
CONFIG_PCMCIA, etc.  In source files, these can of course be
extracted from linux/config.h, but they are also necessary at
the configuration and Makefile level.

> Anyway, it wouldn't be hard to provide them in some
> meaningful way, perhaps as a Makefile include file.  I might look into
> that for the next release.

I'd be happy to help and/or test.  Currently, there is a wide
gap between between what is required for most module packages
(i.e., upstream packages, not Debian packages).  I've done quite
a bit of work from the upstream side, particularily with RTAI,
but I can see lots of potential problems with that system.  In
particular, the file rtai/scripts/realtime-config could be useful.
It is slightly misnamed, since it's really "kernel-config", similar
to kde-config or gtk-config.  RTAI source is at http://www.aero.polimi.it/RTAI/.
I've also attached it.




dave...

#!/bin/sh

prefix=/usr/realtime

version=0.0.0

#use_installed=yes

usage()
{
	cat <<EOF
Usage: realtime-config [OPTIONS] [LIBRARIES]
Options:
	[--prefix]
	[--linuxdir=DIR]
	[--version]
	[--uts-version]
	[--arch]
	[--cross-compile]
	[--cflags]
	[--cflags-fp]
	[--c++flags]
	[--c++flags-fp]
Libraries:
EOF
	exit $1
}

get_arch()
{
	# get ARCH from kernel file tree (include/asm)
	echo $(/bin/ls -l $linuxdir/include/asm | \
	       awk '{sub(/^asm-/,"",$NF); print $NF}')      
}

gcc_cross_compile()
{
	# I don't understand awk well enough to know why the following
	# doesn't work, so I replaced it. --ds
	#echo $(awk -F "=" '/[[:space:]]*CROSS_COMPILE[[:space:]]*=[[:space:]]*/ \
        #       {gsub(/[[:space:]]*/,"",$2); print $2}' $linuxdir/Makefile)
	grep '^CROSS_COMPILE[[:space:]]*=' ${linuxdir}/Makefile| \
		sed 's/^CROSS_COMPILE[[:space:]]*=[[:space:]]*//'
}

gcc_test_opt()
{
	if ${GCC} $1 -S -o /dev/null -xc /dev/null >/dev/null 2>&1 ; then
		echo $1
	fi
}

kernel_cflags_i386()
{
	arch_cflags="-pipe"

	# wacky test for strength reduction bug
	if [ ! "$(gcc_test_opt -march=i486 )" ];then
		arch_cflags="${arch_cflags} -fno-strength-reduce"
	fi

	if [ "$CONFIG_M386" ];then
		if [ "$(gcc_test_opt -march=i386 )" ];then
			arch_cflags="${arch_cflags} -march=i386"
		else
			arch_cflags="${arch_cflags} -m386"
		fi
	fi
	if [ "$CONFIG_M486" ];then
		if [ "$(gcc_test_opt -march=i486 )" ];then
			arch_cflags="${arch_cflags} -march=i486"
		else
			arch_cflags="${arch_cflags} -m486"
		fi
	fi
	if [ "$CONFIG_M586" -o "$CONFIG_M586TSC" -o "$CONFIG_M586MMX" -o "$CONFIG_MCRUSOE" ];then
		arch_cflags="${arch_cflags} $(gcc_test_opt -march=i586 )"
	fi
	if [ "$CONFIG_M686" -o "$CONFIG_M686FXSR" -o "$CONFIG_MWINCHIPC6" -o "$CONFIG_MWINCHIP2" -o "$CONFIG_MWINCHIP3D" ];then
		arch_cflags="${arch_cflags} $(gcc_test_opt -march=i686 )"
	fi
	if [ "$CONFIG_MK6" ];then
		arch_cflags="${arch_cflags} $(gcc_test_opt -march=k6 )"
	fi
	if [ "$CONFIG_MK7" ];then
		if [ "$(gcc_test_opt -march=athlon )" ];then
			arch_cflags="${arch_cflags} -march=athlon"
		elif [ "$(gcc_test_opt -march=i686 )" ];then
			arch_cflags="${arch_cflags} -march=i686 -malign-functions=4"
		fi
	fi
	arch_cflags_fp=
	arch_cflags_nfp=
}

kernel_cflags_ppc()
{
	x="-D__powerpc__ -fsigned-char -pipe -ffixed-r2 -Wno-uninitialized -mmultiple -mstring"
	if [ "$CONFIG_4xx" ];then
		x="${x} -mcpu=403"
	fi
	if [ "$CONFIG_8xx" ];then
		x="${x} -mcpu=860"
	fi
	if [ "$CONFIG_PPC64BRIDGE" ];then
		x="${x} -Wa,-mppc64bridge"
	fi
	arch_cflags=$x
	arch_cflags_fp="-mhard-float"
	#arch_cflags_nfp="-msoft-float"
}

kernel_cflags_mips()
{
	x="-EL -I ${linuxdir}/include/asm/gcc -G 0 -mno-abicalls -fno-pic -mcpu=r4600 -mips2 -Wa,--trap -pipe"
	arch_cflags=$x
	arch_cflags_fp="-mhard-float"
}

get_rt_extension()
{
	# figure out which rt extension is applied

	if [ -f "$linuxdir/include/asm/rt_irq.h" ];then
		rt_type=rtl_v1
	elif [ "$CONFIG_RTLINUX" = "y" -o "$CONFIG_RTL" = "y" ];then
		rt_type=rtl
	elif [ "$CONFIG_RTHAL" = "y" ];then
		rt_type=rtai
	else
		rt_type=none
	fi
}



if test $# -eq 0; then
	usage 1 1>&2
fi

while test $# -gt 0; do
	case "$1" in
	-*=*) optarg=$(echo "$1" |sed 's/[-_a-zA-Z0-9]*=//' ) ;;
	*) optarg= ;;
	esac

	case $1 in
		--prefix)
			echo_prefix=yes
			;;
		--arch)
			echo_arch=yes
			;;
		--cross-compile)
			echo_cross_compile=yes
			;;
		--cflags)
			echo_cflags=yes
			;;
		--cflags-fp)
			echo_cflags_fp=yes
			;;
		--c++flags)
			echo_cplusplusflags=yes
			;;
		--c++flags-fp)
			echo_cplusplusflags_fp=yes
			;;
		--version)
			echo $version
			;;
		--linuxdir=*)
			linuxdir=$optarg
			;;
		--uts-version)
			echo_uts_version=yes
			;;
		--dump)
			echo_dump=yes
			;;
		--use-installed)
			use_installed=yes
			;;
		--no-use-installed)
			use_installed=
			;;
		--cache=*)
			cachefile=$optarg
			;;
		--arch=*)
			arch=$optarg
			;;
		*)
			usage 1 1>&2
			;;
	esac
	shift
done

if [ ! "$cachefile" -o ! -f "$cachefile" ];then

# do some linux dep things

: ${linuxdir:=$LINUXDIR}
: ${linuxdir:=/usr/src/linux}

if [ ! -f ${linuxdir}/.config ];then
	echo Kernel source tree $LINUXDIR not configured! >&2
	exit 1
fi

. ${linuxdir}/.config

# find cross compile prefix

cross_compile="$(gcc_cross_compile)"

# find gcc

: ${GCC:=${cross_compile}gcc}
gccincdir="$(${GCC} -print-search-dirs|grep ^install|sed 's/install..//')include"

# find arch

if [ ! "$arch" ];then
	arch="$(get_arch)"
fi

read dummy dummy dummy2 <$linuxdir/include/linux/version.h
uts_version=`echo $dummy2|sed 's/"//g'`

kernel_cflags="-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer"
kernel_cflags="${kernel_cflags} $(gcc_test_opt -fnostrict-aliasing)"

if [ "$CONFIG_MODVERSIONS" ];then
	kernel_cflags="${kernel_cflags} -DMODVERSIONS -include $linuxdir/include/linux/modversions.h"
fi

# generate arch flags
case "$arch" in
  i386)
	kernel_cflags_i386
	;;
  ppc)
	kernel_cflags_ppc
	;;
  mips)
  	kernel_cflags_mips
	;;
  *)
  	echo "Fix realtime_config!"
	exit 1
	;;
esac

get_rt_extension

# create CFLAGS

cflags="-D__KERNEL__ -DMODULE"
cflags="${cflags} -I${linuxdir}/include $kernel_cflags $arch_cflags"

cplusplusflags="-fno-rtti $(gcc_test_opt -fnoexceptions)"

cflags_nfp="$cflags $arch_cflags_nfp"
cflags_fp="$cflags $arch_cflags_fp"

cplusplusflags_nfp="$cflags_nfp $cplusplusflags"
cplusplusflags_fp="$cflags_fp $cplusplusflags"

fi

if [ "$cachefile" ];then
	if [ -f $cachefile ];then
		. $cachefile
	else
		write_cache=yes;
	fi
fi


if [ "$use_installed" ];then
	cflags="${cflags} -I${prefix}/include"
fi

if [ "$use_nostdinc" ];then
	cflags="${cflags} -nostdinc -I${gccincdir}"
fi

if [ "$echo_prefix" = "yes" ];then
	echo $prefix
fi

if test "$echo_arch" = "yes";then
	echo $arch
fi

if test "$echo_cross_compile" = "yes";then
	echo $cross_compile
fi

if test "$echo_cflags" = "yes";then
	echo $cflags_nfp
fi

if test "$echo_cflags_fp" = "yes";then
	echo $cflags_fp
fi

if test "$echo_cplusplusflags" = "yes";then
	echo $cplusplusflags_nfp
fi

if test "$echo_cflags_fp" = "yes";then
	echo $cplusplusflags_fp
fi

if test "$echo_uts_version" = "yes";then
	echo $uts_version
fi

if test "$echo_rt_type" = "yes";then
	echo $rt_type
fi

if [ "$echo_dump" = "yes" ];then
	echo prefix=\"$prefix\"
	echo linuxdir=\"$linuxdir\"
	echo uts_version=\"$uts_version\"
	echo arch=\"$arch\"
	echo cross_compile=\"$cross_compile\"
	echo rt_type=\"$rt_type\"
	echo cflags_nfp=\"$cflags_nfp\"
	echo cflags_fp=\"$cflags_fp\"
	echo cplusplusflags_nfp=\"$cplusplusflags_nfp\"
	echo cplusplusflags_fp=\"$cplusplusflags_fp\"
fi

if [ "$write_cache" = yes  ];then
	( echo prefix=\"$prefix\"
	echo linuxdir=\"$linuxdir\"
	echo uts_version=\"$uts_version\"
	echo arch=\"$arch\"
	echo cross_compile=\"$cross_compile\"
	echo rt_type=\"$rt_type\"
	echo cflags_nfp=\"$cflags_nfp\"
	echo cflags_fp=\"$cflags_fp\"
	echo cplusplusflags_nfp=\"$cplusplusflags_nfp\"
	echo cplusplusflags_fp=\"$cplusplusflags_fp\" ) >$cachefile
fi


Reply to: