aboutsummaryrefslogtreecommitdiff
path: root/configure.in
blob: 5dc4b3071380a722f7c47a7afb10c78fdb693832 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
dnl -*- shell-script -*-
dnl Process this file with autoconf to produce a configure script.

dnl we need autoconf >= 2.50
AC_PREREQ(2.50)

AC_INIT(libmpio/src/mpio.c)
dnl AM_CONFIG_HEADER(src/config.h)

AC_CANONICAL_SYSTEM()
AC_MSG_RESULT(Building for a ${host} host.)

AM_INIT_AUTOMAKE(mpio, 0.7.1_pre1-1)

dnl build release variable
RELEASE=`echo $VERSION | cut -d- -f2`
VERSION=`echo $VERSION | cut -d- -f1`
AC_SUBST(RELEASE)

dnl Checks for programs.

AC_PROG_MAKE_SET
AC_PROG_CC
AM_PROG_LIBTOOL

dnl Check for endianess

AC_LANG_C
AC_C_BIGENDIAN

dnl Checks for header files.

AC_CHECK_HEADER(getopt.h,HAVE_GETOPT_H=1,HAVE_GETOPT_H=0)
AC_SUBST(HAVE_GETOPT_H)

dnl --- checking for readline

AC_CHECK_HEADER(readline/readline.h,,
    AC_ERROR(could not find readline header files))

dnl --- include mplib if not disabled manually

AC_DEFUN([TEST_MPLIB],
[AC_ARG_WITH([mplib],
             AC_HELP_STRING([--without-mplib],
                            [disable use of mplib]),
             [ac_cv_use_mplib=$withval], [ac_cv_use_mplib=yes])
AC_CACHE_CHECK([whether to use mplib],
               [ac_cv_use_mplib], [ac_cv_use_mplib=yes])])
TEST_MPLIB

if test "$ac_cv_use_mplib" = yes; then
  MPLIB_INCLUDE=-Implib
  MPLIB_CFLAGS=-DMPLIB
fi

AC_SUBST(MPLIB_INCLUDE)
AC_SUBST(MPLIB_CFLAGS)

dnl -- check for libusb
dnl -- this is stolen from libgphoto2

AC_PATH_PROG(LIBUSB_CONFIG,libusb-config)
if test -n "${LIBUSB_CONFIG}"; then
    CPPFLAGS_save="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS `$LIBUSB_CONFIG --cflags`"
    AC_CHECK_HEADER(usb.h,[
	    LDFLAGS_orig="$LDFLAGS"
	    LDFLAGS="`$LIBUSB_CONFIG --libs`"
	    AC_CHECK_LIB(usb,usb_busses,[
		    usb_msg="yes"
		    IOLIB_SUBDIRS="$IOLIB_SUBDIRS usb"
		    USB_LIBS="`$LIBUSB_CONFIG --libs`"
		    USB_CFLAGS="`$LIBUSB_CONFIG --cflags`"
		    LIBUSB_VER="`$LIBUSB_CONFIG --version`"],[
		    usb_msg="no (available version too old)"])
	    LDFLAGS="$LDFLAGS_orig"])
    CPPFLAGS="$CPPFLAGS_save"
fi

        # This 'test' call uses non-standard syntax and will fail on most
        # systems, but it's just informational so any warning can be ignored.
if test "$LIBUSB_VER" \< "0.1.7"; then
    AC_MSG_WARN([
*** You need at least version 0.1.7 of the libusb library for USB support
*** http://sourceforge.net/projects/libusb/
*** If you cannot find the appropriate version, try CVS
	    ])
    exit 1
fi

case "$usb_msg" in
    yes*) AC_DEFINE(HAVE_USB,1,[Whether you have USB support enabled]);;
       *)    ;;
esac

AC_SUBST(USB_CFLAGS)
AC_SUBST(USB_LIBS)

dnl --- check/set user and permissions for accessing the player

dnl 1. user

AC_DEFUN([TEST_USER],
[AC_ARG_WITH([user],
             AC_HELP_STRING([--with-user=USER],
                            [user to access the player]),
             [ac_cv_use_user=$withval], [ac_cv_use_user=root])
AC_CACHE_CHECK([user to access the player],
               [ac_cv_use_user], [ac_cv_use_user=root])])

TEST_USER
MPIOUSER=$ac_cv_use_user
AC_SUBST(MPIOUSER)

dnl 2. group

AC_DEFUN([TEST_GROUP],
[AC_ARG_WITH([group],
             AC_HELP_STRING([--with-group=GROUP],
                            [group to access the player]),
             [ac_cv_use_group=$withval], [ac_cv_use_group=root])
AC_CACHE_CHECK([group to access the player],
               [ac_cv_use_group], [ac_cv_use_group=root])])

TEST_GROUP
MPIOGROUP=$ac_cv_use_group
AC_SUBST(MPIOGROUP)

dnl 3. permissions

AC_DEFUN([TEST_PERM],
[AC_ARG_WITH([perm],
             AC_HELP_STRING([--with-perm=PERM],
                            [permissions for accessing the player]),
             [ac_cv_use_perm=$withval], [ac_cv_use_perm=0666])
AC_CACHE_CHECK([permissions for accessing the player],
               [ac_cv_use_perm], [ac_cv_use_perm=0666])])

TEST_PERM
MPIOPERM=$ac_cv_use_perm
AC_SUBST(MPIOPERM)

dnl --- only use deprecated kernel module if requested

AC_DEFUN([TEST_KERNEL],
[AC_ARG_WITH([kernel-module],
             AC_HELP_STRING([--with-kernel-module],
                            [enable the deprecated kernel module for 2.2.x and 2.4.x]),
             [ac_cv_use_kernel=$withval], [ac_cv_use_kernel=no])
AC_CACHE_CHECK([whether to build the kernel module],
               [ac_cv_use_kernel], [ac_cv_use_kernel=no])])

TEST_KERNEL

if test "$ac_cv_use_kernel" = yes; then
  MPIO_KERNEL=kernel

dnl --- check for kernel version
kernel_version=`uname -r 2>&1`
echo -n "checking for kernel version ... "
case "$kernel_version" in
    '') kernel_version="?.??"; _k_verc_fail=yes;;
    [[0-1]].[[0-9]].[[0-9]]*|2.[[0-1]].[[0-9]]*|2.[[5-9]].[[0-9]]*|3.[[0-9]]*.[[0-9]]*)
    _k_verc_fail=yes;;
    *) k_ver_fail=no;;
esac
echo $kernel_version
if test "$_k_verc_fail" ; then
  echo "  Your kernel version does not match."
  echo "  The kernel module only works for kernel 2.2.x and 2.4.x."
  AC_ERROR(wrong kernel version)
  unset MPIO_KERNEL
fi

MODULE_PATH="/lib/modules/${kernel_version}"
if test -d "${MODULE_PATH}/kernel/drivers/usb"; then
    MODULE_PATH="${MODULE_PATH}/kernel/drivers/usb"
    SPEC_PATH="kernel/drivers/usb"
else
    MODULE_PATH="${MODULE_PATH}/misc"
    SPEC_PATH="misc"
fi

AC_MSG_RESULT(Using module path ${MODULE_PATH}.)
AC_SUBST(MODULE_PATH)
AC_SUBST(SPEC_PATH)

KERNEL_INCLUDE=
if test -d "/lib/modules/${kernel_version}/build/include"; then
    KERNEL_INCLUDE="/lib/modules/${kernel_version}/build/include"
elif test -d "/usr/src/linux-2.4/include"; then
    KERNEL_INCLUDE="/usr/src/linux-2.4/include"
elif test -d "/usr/include/linux"; then
    KERNEL_INCLUDE="/usr/include/linux"
elif test -d "/usr/src/linux/include"; then
    KERNEL_INCLUDE="/usr/src/linux/include"
fi

if test -z ${KERNEL_INCLUDE}; then
    AC_ERROR(could not find directory of kernel include files)
else
    AC_MSG_RESULT(Using kernel includes from ${KERNEL_INCLUDE})
    AC_DEFINE(USE_KMODULE,1,[Whether you want support for the deprecated kernel module])
fi
AC_SUBST(KERNEL_INCLUDE)

fi

AC_SUBST(MPIO_KERNEL)

dnl ------------------------------------------------------------

AC_OUTPUT(
    Makefile
    libmpio/Makefile
    mpiosh/Makefile
    etc/Makefile
    tools/Makefile
    hotplug/libmpio
    hotplug/Makefile
    mpio.spec
)