File: configure.tools

package info (click to toggle)
cctools 3.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 5,704 kB
  • sloc: ansic: 49,398; cpp: 15,568; perl: 12,324; sh: 2,668; python: 1,422; makefile: 632; yacc: 433; lex: 152; xml: 109
file content (485 lines) | stat: -rw-r--r-- 8,207 bytes parent folder | download
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485

save_arguments()
{
cat >configure.rerun <<EOF
#!/bin/sh
$@
EOF
chmod 755 configure.rerun
}

check_file ()
{
	echo -n "checking for $1..."
	if [ -f $1 ]
	then
		echo "yes"
		return 0
	else
		echo "no"
		return 1
	fi
}

check_path ()
{
	echo -n "checking for $1..."
	IFS=":"
	for dir in $PATH
	do
		if [ -x $dir/$1 ]
		then
			echo "$dir/$1"
			IFS=" "
			return 0
		fi
	done
	echo "not found"
	IFS=" "
	return 1
}

check_function()
{
	echo -n "checking for $1 in $2..."
	if grep $1 $2 >/dev/null 2>&1
	then
		echo "yes"
		return 0
	else
		echo "no"
		return 1
	fi
}

require_file ()
{
	if check_file $1
	then
		return 0
	else
		echo "Sorry, I can't proceed without file $1";
		exit 1
	fi
}

require_path ()
{
	if check_path $1
	then
		return 0
	else
		echo "Sorry, I can't proceed without program $1";
		exit 1
	fi
}

require_function ()
{
	if check_function $1 $2
	then
		return 0
	else
		echo "Sorry, I can't proceed without function $1";
		exit 1
	fi
}

library_search_mode=prefer_dynamic

library_search()
{
	if library_search_normal $@;
	then
		return 0
	fi
	if [ X$HOST_MULTIARCH != X ] && library_search_multiarch $@;
	then
		return 0
	fi

	return 1
}

library_search_multiarch()
{
	if [ X$3 = X ];
	then
		library_search_normal $1 $2 $HOST_MULTIARCH
	else
		library_search_normal $1 $2 $HOST_MULTIARCH/$3
	fi
}

library_search_normal()
{
	# If the second argument is root, and we are not careful,
	# we will end up with a path that has two slashes, which
	# means something unintended in Windows

	if [ $2 = / ]
	then
		basedir=
	else
		basedir=$2
	fi

	# If we are running on a 64-bit platform, then the native libraries
	# for compiling will be found in /lib64, if it exists.  The files in
	# /lib are compatibilities libraries for 32-bit.
	
	if [ $build_cpu = X86_64 -a -d $2/lib64 ]
	then
		libdir=$basedir/lib64
	elif [ -d $basedir/lib ]
        then
		libdir=$basedir/lib
	else
		libdir=$basedir
	fi

	# Darwin uses dylib for dynamic libraries, other platforms use .so

	if [ $build_sys = DARWIN ]
	then
		dynamic_suffix=dylib
	else
		dynamic_suffix=so
	fi

	# If a third argument is given, it means libraries are found in
	# a subdirectory of lib, such as "mysql".

	if [ X$3 != X -a -d "$libdir/$3" ]
	then
		libdir="$libdir/$3"
	fi

	# Now check for the library file in all of the known places,
	# and add it to the link line as appropriate for the type and platform.

	if [ $library_search_mode = prefer_static -o $library_search_mode = require_static ]
	then
		if check_file $libdir/lib$1.a
		then
			ldflags="${ldflags} $libdir/lib$1.a"
			return 0
		fi
	fi

	if [ $library_search_mode != require_static ]
	then
		if check_file $libdir/lib$1.$dynamic_suffix
		then
			# If this is not a standard library directory, add it to the library search path.
			# (Adding standard directories to the path has unintended effects.)
			if [ $libdir != /lib -a $libdir != /lib64 -a $libdir != /usr/lib -a $libdir != /usr/lib64 ]
			then
				ldflags="${ldflags} -L$libdir"
			fi
			ldflags="${ldflags} -l$1"
			return 0
		fi
	fi

	if [ $library_search_mode = prefer_dynamic ]
	then
		if check_file $libdir/lib$1.a
		then
			ldflags="${ldflags} $libdir/lib$1.a"
			return 0
		fi
	fi
	
	return 1
}

optional_function()
{
	multiarch_include=`echo $2 | sed "s|include/|include/$HOST_MULTIARCH/|"`

	if check_function $1 $2
	then
		ccflags="${ccflags} -D$3"
		return 0
	elif [ X$HOST_MULTIARCH != X ] && check_function $1 $multiarch_include;
	then
		ccflags="${ccflags} -D$3"
		return 0
	fi
		
	return 1
}

optional_file()
{
	if check_file $1
	then
		ccflags="${ccflags} -D$2"
		return 0
	else
		return 1
	fi
}

optional_include()
{
	multiarch_include=`echo $1 | sed "s|include/|include/$HOST_MULTIARCH/|"`

	if optional_file $1 $2;
	then
		return 0
	elif [ X$HOST_MULTIARCH != X ] && optional_file $multiarch_include $2;
	then
		return 0
	fi

	return 1
}

optional_pfs_service()
{
	service=$1
	shift 1

	echo -n "including pfs_service_${service}..."

	for lib in $@; do
		if echo $ccflags | grep "$lib" > /dev/null 2>&1
		then
			true
		else
			echo "no"
			return 1
		fi
	done

	echo "yes"
	ccflag="HAS_$(echo ${service} | tr [a-z] [A-Z])"
	if echo $ccflags | grep $ccflag > /dev/null 2>&1
	then
		true
	else
		ccflags="${ccflags} -D${ccflag}"
	fi
	pfs_optional_services="${pfs_optional_services} pfs_service_${service}.o"
	return 0
}

check_gnu_make()
{
	if check_path $1
	then
		echo -n "checking if $1 is GNU make..."
		kind=`$1 -v 2>&1| head -1 | awk '{print $1}'`
		if [ X$kind = XGNU ]
		then
			echo "yes"
			MAKE=$1
			export MAKE
			return 0
		else
			echo "no"
		fi
	fi

	return 1
}

require_gnu_make()
{
	echo "checking for GNU make in several places..."
	if check_gnu_make make
	then
		return 0
	else
		if check_gnu_make gmake
		then
			return 0
		else
			if check_gnu_make gnumake
			then
				return 0
			fi
		fi
	fi

	echo "Sorry, you must have GNU make/gmake/gnumake in your path."
	exit 1
}

check_perl_version()
{
	if check_path "perl"
	then
		echo -n "checking perl version..."
		cat >configure.perl-test <<EOF
print "\$]\n";
 
\$v = \$ARGV[0]+\$ARGV[1]/1000+\$ARGV[2]/1000000;
 
if(\$v>=\$]) {
        exit 1;
} else  {
        exit 0;
} 
EOF
		if perl configure.perl-test $1 $2 $3
		then
			return 0
		else
			return 1
		fi
	fi

	return 1
}

fix_globus_install()
{
	if check_file "${1}/include/${2}/globus_config.h"
	then
		echo "globus source install has been configured properly"
	else
		echo "*** globus source install has not been configured properly"
		echo "*** try running \"gpt-build -nosrc $2\" to set it up properly."
		exit 1
	fi
}

check_for_globus_flavors()
{
	echo "examining the globus installation in $1..."

	if check_perl_version 5 5 0
	then
		echo "perl version is ok"
	else
		echo "*** sorry, the globus build tools require"
		echo "*** perl >= v5.5.0 in order to even examine the installation."
		exit 1
	fi

	#
	# globus-makefile-header seems to move around.
	# Use -f rather than -x, because the AFS acl may
	# not match the UNIX perms.
	#	

	GMH=$1/sbin/globus-makefile-header
	echo "checking for $GMH..."
	if [ ! -f "${GMH}" ]
	then
		GMH=$1/bin/globus-makefile-header
		echo "checking for $GMH..."
		if [ ! -f "${GMH}" ]
		then
			echo "not found"
			return 1
		fi
	fi

	#
	# Some installations have a trailing " " afer the pound-bang
	# line, so we'll try to perl it directly if it looks like
	# a perl script.  However, we don't want to universally assume
	# that it is perl without some evidence.
	#
	 
	if head -1 $GMH | grep perl > /dev/null 2>&1
	then
		GMH="perl ${GMH}"
	fi

	#
	# Now search for any flavor we can think of...
	#

	for compiler in gcc64 gcc32 vendorcc32
	do
		for debug in "" dbg
		do
			if check_for_globus "$1" "$2" "${compiler}${debug}" "${GMH}"
			then
				return 0
			fi
		done
	done

	return 1
}

check_for_globus()
{
	echo -n "checking for globus package $2 flavor $3 in $1..."

	GLOBUS_LOCATION=$1
	export GLOBUS_LOCATION

	#
	# Run globus-makefile-header and dump the output into
	# a Makefile.  Note that the single-dash option form
	# stops working with version > 2.0
	#

	$4 --static --flavor=$3 $2 2> Makefile.config.globus.errors > Makefile.config.globus

	#
	# This script seems to always exit with status zero,
	# even if it detects an error.
	#

	if [ $? -eq 0 ]
	then
		#
		# Some busted versions put error messages
		# in the output Makefile itself.
		#

		if grep ERROR Makefile.config.globus > /dev/null
		then
			#
			# On the other hand, some working versions have
			# the string ERROR in a package name!
			#

			if grep ERROR_VERSION Makefile.config.globus > /dev/null
			then
				echo "tricky, but yes!"
				return 0
			else
				rm Makefile.config.globus
				echo "broken"
				return 1
			fi
		else
			echo "yes"
			return 0
		fi
	else
		#
		# Never seen this happen, but perhaps the script
		# will indicate the package is not present
		#

		echo "no"
		return 1
	fi
}

check_multiarch()
{
	echo -n "checking for multiarch environment..." 
	if [ -r /etc/debian_version ]; then
		HOST_MULTIARCH=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
		echo "$HOST_MULTIARCH"
	else
		HOST_MULTIARCH=
		echo "no"
	fi
}

format_version()
{
	echo "$@" | awk -F. '{printf("%d%03d%03d%03d", $1, $2, $3, $4); }'	
}