File: check

package info (click to toggle)
ifd-gempc 1.0.7-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 596 kB
  • sloc: ansic: 3,138; sh: 279; makefile: 147
file content (206 lines) | stat: -rwxr-xr-x 5,017 bytes parent folder | download | duplicates (6)
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
#!/bin/sh

#    check: verify all the needed parts are present
#    Copyright (C) 2002-2004  Ludovic Rousseau
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# this code is greatly inspired by configure scripts generated by autoconf
# $Id: check,v 1.10 2006/02/09 13:28:25 rousseau Exp $

exec 5>./config.log

CHECK_CFLAGS=`pkg-config libpcsclite --cflags`

ac_ext=c
ac_cpp='cpp $CFLAGS $CHECK_CFLAGS'
ac_cc=cc
ac_compile='${CC-cc} -c $CFLAGS $CHECK_CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CHECK_CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'

# test the presence of a .h file
# the filename to check is fetched from $ac_hdr
check_h()
{
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo -n "checking for $ac_hdr""... "
echo "checking for $ac_hdr""... " >&5
cat > conftest.${ac_ext} << EOF
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
  rm -rf conftest*
  eval "ac_cv_header_$ac_safe=yes"
else
  echo "$ac_err" >&5
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  echo $ac_try >& 5
  cat conftest.out >& 5
  rm -rf conftest*
  eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
  echo "yes"
else
  echo "no"
fi
}

# check the presence of pcsclite.h
ac_hdr="pcsclite.h"
check_h
if [ "$ac_cv_header_pcsclite_h" = "no" ]
then
cat << EOF

FILE MISSING!
You must install the pcsc-lite software before compiling this software
You can get it from http://pcsclite.alioth.debian.org/ or from a package of
your operating system distribution

If pcsc-lite is already installed but not in /usr/ or /usr/local/ you must
edit GemPC4?0/Makefile and change the definition of INCS.
EOF
		exit 1
fi

# check the version of pcsc-lite
ac_version=\"1.2.9-beta7\"
ac_hdr=pcsclite.h
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo -n "checking for pcsc-lite version >= $ac_version... "
echo "checking for pcsc-lite version >= $ac_version... " >&5
cat > conftest.${ac_ext} << EOF
#include <string.h>
#include <$ac_hdr>
int main() {
if (strcmp(PCSCLITE_VERSION_NUMBER, $ac_version) < 0)
{
	char cpcsc[] = PCSCLITE_VERSION_NUMBER;
	char cdriver[] = $ac_version;

	/* compare "1.2.9-beta" */
	if (strncmp(cpcsc, cdriver, 10) == 0)
	{
		int p, v;
		p = atoi(cpcsc+10);
		v = atoi(cdriver+10);

		if (v<=p)
			return 0;
	}
	return 1;
}
else
	return 0;
}
EOF
if { (eval $ac_link) 2>&5; } && ./conftest; then
  eval "ac_cv_pcsc_version=yes"
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "ac_cv_pcsc_version=no"
fi
rm -f conftest*

if eval "test \"`echo '$ac_cv_'pcsc_version`\" = yes"; then
  echo "yes"
  :
else
  echo "no"
fi

if [ $ac_cv_pcsc_version = "no" ]
then
	cat << EOF

WRONG VERSION OF PCSC-LITE!
You can get it from http://pcsclite.alioth.debian.org/ or from a package of
your operating system distribution
EOF
	exit 1
fi

# if we test for a GemPC410 we stop here
if [ "$1" = 410 ]
then
	exit 0
fi

# check the presence of usb.h
ac_hdr=usb.h
check_h
if [ $ac_cv_header_usb_h = "no" ]
then
	cat << EOF

FILE MISSING!
You must install the libusb library before compiling this software
You can get it from http://libusb.sourceforge.net/ or from a package of
your operating system distribution
EOF
	exit 1
fi

# check the presence of usb_get_busses()
LDFLAGS="$LDFLAGS -lusb"
echo -n "checking for usb_get_busses... "
echo "checking for usb_get_busses... " >&5
cat > conftest.$ac_ext <<EOF
char usb_get_busses();

int main() {

usb_get_busses();

; return 0; }
EOF
if { (eval $ac_link) 2>&5; } && test -s conftest; then
  eval "ac_cv_func_usb_get_busses=yes"
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "ac_cv_func_usb_get_busses=no"
fi
rm -f conftest*

if eval "test \"`echo '$ac_cv_func_'usb_get_busses`\" = yes"; then
  echo "yes"
  :
else
  echo "no"
fi

if [ $ac_cv_func_usb_get_busses = "no" ]
then
	cat << EOF

WRONG VERSION OF LIBUSB!
Your version of libusb is not correct (too old?). You must use version
0.1.6a or superior.
You can get it from http://libusb.sourceforge.net/ or from a package of
your operating system distribution
EOF
	exit 1
fi

exit 0