aboutsummaryrefslogtreecommitdiff
path: root/configure.in
blob: 2238b60b758883dc344c545f8ffdf0c0a6b567a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
AC_INIT(lib/fuse.c)
AM_INIT_AUTOMAKE(fuse, 0.99)
AM_CONFIG_HEADER(include/config.h)

AC_PROG_CC
AC_PROG_RANLIB

if test -z "$LD"; then
	LD=ld
fi
AC_SUBST(LD)

CFLAGS="-Wall -W -g -O2"

AC_ARG_ENABLE(kernel-module,
	[  --enable-kernel-module  Compile kernel module, requires --with-kernel option ])
AC_ARG_ENABLE(lib,
	[  --enable-lib            Compile with library ])
AC_ARG_ENABLE(util,
	[  --enable-util           Compile with util ])
AC_ARG_ENABLE(example,
	[  --enable-example        Compile with examples ])

if test "$enable_kernel_module" != "no"; then
	AC_MSG_CHECKING([kernel source directory])
	kernelsrc=
	AC_ARG_WITH(kernel,
		[  --with-kernel           Specify location of kernel source ],
		[kernelsrc="$withval"])

	if test -z "$kernelsrc"; then
		buildlink=/lib/modules/`uname -r`/build
		if test -e $buildlink; then
			kernelsrc=`(cd $buildlink; /bin/pwd)`
		else
			AC_MSG_RESULT([Not found])
			AC_MSG_ERROR([
*** Please specify the location of the kernel source with
*** the '--with-kernel=SRCDIR' option])
		fi
	fi
	AC_MSG_RESULT([$kernelsrc])
fi

oldcc=$CC
oldcross_compiling=$cross_compiling
if test "$cross_compiling" = yes; then
	CC=gcc
	cross_compiling=no
fi

if test "$enable_kernel_module" != "no"; then
	AC_MSG_CHECKING([kernel source version])
	kernsrcver=`sed -ne '/^VERSION = \(.*\)/{s//\1/;p;q;}' $kernelsrc/Makefile`
	kernsrcver="$kernsrcver.`sed -ne '/^PATCHLEVEL = \(.*\)/{s//\1/;p;q;}' $kernelsrc/Makefile`"
	kernsrcver="$kernsrcver.`sed -ne '/^SUBLEVEL = \(.*\)/{s//\1/;p;q;}' $kernelsrc/Makefile`"
	kernsrcver="$kernsrcver`sed -ne '/^EXTRAVERSION = \(.*\)/{s//\1/;p;q;}' $kernelsrc/Makefile`"

	if test -z "$kernsrcver"; then
		AC_MSG_RESULT([Not found])
		AC_MSG_ERROR([
*** Cannot determine the version of the linux kernel source. Please 
*** configure the kernel before running this script])
	fi
	AC_MSG_RESULT([$kernsrcver])
fi

CC=$oldcc
cross_compiling=$oldcross_compiling
subdirs="include patch"

if test "$enable_kernel_module" != "no"; then
	KERNINCLUDE=$kernelsrc/include
	AC_SUBST(KERNINCLUDE)
	kmoduledir=/lib/modules/$kernsrcver
	AC_SUBST(kmoduledir)
	subdirs="$subdirs kernel"
fi

if test "$enable_lib" != "no"; then
	subdirs="$subdirs lib";
fi
if test "$enable_util" != "no"; then
	subdirs="$subdirs util";
fi
if test "$enable_example" != "no"; then
	subdirs="$subdirs example";
fi

AC_SUBST(subdirs)

AC_OUTPUT([Makefile kernel/Makefile lib/Makefile util/Makefile example/Makefile include/Makefile include/linux/Makefile patch/Makefile])