File: configure

package info (click to toggle)
libt3config 0.2.11-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 524 kB
  • sloc: ansic: 3,753; sh: 828; xml: 172; lex: 87; makefile: 56
file content (812 lines) | stat: -rwxr-xr-x 19,003 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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
#!/bin/sh
# Copyright (C) 2006-2007,2009,2011 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# 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, see <http://www.gnu.org/licenses/>.

# Set zsh to emulate sh (otherwise all kinds of eval's wont work)
[ -n "${ZSH_VERSION}" ] && emulate sh

#==============================
# Functions
#==============================
error() {
	echo "$*"
	[ -n "$DUMP_LOG" ] && cat config.log
	exit 1
}

not() {
	if "$@" ; then
		false
	else
		true
	fi
}

check() {
	if not "$@" ; then
		error "Error executing $*. Aborting."
	fi
}

check_message() {
	printf "$*"
	echo "----------------------------------" >> config.log
	echo "$*" >> config.log
}

check_message_result() {
	echo "$*"
	echo "$*" >> config.log
}

clean() {
	rm -rf "$@" >/dev/null 2>&1
}

test_make() {
	printf "%s" "Running: ${MAKE} -f .Makefile" >> config.log
	for ARG in "$@"
	do
		printf " '%s'" "${ARG}" >> config.log
	done
	echo >> config.log
	"${MAKE}" -f .Makefile "$@"
}

test_install() {
	clean .foo
	check_message "Checking for working install ($*)... "

	if  test_make "INSTALL=$*" "install" >> config.log 2>&1 ; then
		check_message_result "yes"
		true
	else
		check_message_result "no"
		false
	fi
}

test_and_set() {
	SETTING="$4${5+ }$5"
	if $1 "$2${SETTING+ in }${SETTING}" "TESTFLAGS=$4" "TESTLIBS=$5" ; then
		eval "${3}_FLAGS=\"$4\""
		eval "${3}_LIBS=\"$5\""
		true
	else
		false
	fi
}

add_replace_settings() {
	for SETTING
	do
		echo "/^${SETTING%%=*}/s/^/# Disabled by configure: /"
		echo "/\.POSIX/a\\
${SETTING}"
	done
}

replace_default() {
	if [ -n "$2" ] ; then
		echo "/^$1=/c\\
$1=$2"
	fi
}

insert() {
	echo "/^$1/d"
	[ -n "$2" ] && echo "/^\\.POSIX:/a\\
$1=$2"
}

create_makefile() {
	for _INSTALL in ${TEST_INSTALL}
	do
		# Don't test the sun install program, because it is dangerous.
		if [ "`uname`" = "SunOS" ] && [ "$_INSTALL" = "install" ] ; then
			continue
		fi
		test_install "${_INSTALL}" && INSTALL="${_INSTALL}" && break
	done
	if [ -z "${INSTALL}" ] ; then
		check_message_result "!! No working install program found. The install target will not work."
	fi

	{
		echo '/\.POSIX/a\
# Settings from configure script'
		replace_default prefix "${PREFIX}"
		for INSTALLDIR in ${INSTALLDIRS}
		do
			[ -n "`eval echo \\${option_${INSTALLDIR}}`" ] && replace_default "${INSTALLDIR}" "`eval echo \\${option_${INSTALLDIR}}`"
		done
		replace_default INSTALL "${INSTALL}"

		insert LDFLAGS "${LDFLAGS}"
		insert LDLIBS "${LDLIBS}"

		for EXT in ${EXTENSIONS}
		do
			sed_rules_${EXT}
		done

		add_replace_settings "$@"
		[ -n "${SEDEXTRA}" ] && ${SEDEXTRA}
	} > .sedscript
	for MAKEFILE in ${MAKEFILES:-Makefile}
	do
		echo "----------------------------------">> config.log
		check_message_result "Creating ${MAKEFILE}"
		cat ${MAKEFILE}.in | sed -f .sedscript > ${MAKEFILE}
	done
	clean .Makefile .Makefile.in .sedscript .foo .config_base
	for EXT in ${EXTENSIONS}
	do
		clean_${EXT}
	done
	exit 0
}

#==============================
# Setup
#==============================
unset LINKRULE COMPILERULE USERRULES USERHELP EXTENSIONS SWITCHES PRECHECKFUNC INSTALLDIRS DUMP_LOG

. ./config.pkg

for MAKEFILE in ${MAKEFILES:-Makefile}
do
	[ -f ${MAKEFILE}.in ] || error "${MAKEFILE}.in does not exist"
	grep "^\\.POSIX:" ${MAKEFILE}.in > /dev/null || error "${MAKEFILE}.in does not contain .POSIX target"
done

#@INCLUDE_START
[ "${EXTENSIONS}" = "c libtool pkgconfig verbose_compile gettext lfs" ] || error "EXTENSIONS changed after running merge_config. Run merge_config again."
SUFFIXES="${SUFFIXES} .c .o"
[ -z "${LINKRULE}" ] && LINKRULE='$(CC) $(CFLAGS) $(LDFLAGS) -o $@ .config.o $(LDLIBS) $(TESTLIBS)'
[ -z "${COMPILERULE}" ] && COMPILERULE='$(CC) $(CFLAGS) $(TESTFLAGS) -c -o $@ $<'

clean_c() {
	clean .config .config.o .config.c
}

show_help_c() {
	if [ "$1" = VARIABLES ] ; then
		cat <<EOF
  CC          C compiler to use (defaults to search gcc, clang and make default)
  CFLAGS      C-compiler flags to use [-O2]
EOF
	fi
}

print_rules_c() {
	if [ -n "${CC}" ] ; then
		echo "CC=${CC}"
	fi
	[ -z "${CFLAGS}" ] && CFLAGS=-O2
	cat <<EOF
CFLAGS=${CFLAGS}

.config:.config.o
	${LINKRULE}

.c.o:
	${COMPILERULE}

EOF
}

basic_test_c() {
	cat > .config.c <<EOF
int main(int argc, char *argv[]) {
	return 0;
}
EOF
	if [ -z "$CC" ] ; then
		for COMPILER in gcc clang
		do
			if test_link "working C compiler (${COMPILER})" CC="${COMPILER}" ; then
				CC="${COMPILER}"
				return
			fi
		done
	fi
	test_link "working C compiler (${CC-${MAKE} default})" || error "No working C compiler found. See config.log for errors."
}

sed_rules_c() {
	insert CFLAGS "${CFLAGS}"
	[ -n "${CC}" ] && insert CC "${CC}"
}

test_compile() {
	clean .config.o
	check_message "Checking for $1... "
	shift

	if test_make "$@" .config.o >> config.log 2>&1 ; then
		check_message_result "yes"
		true
	else
		check_message_result "no"
		echo "Source of the failed compile:" >> config.log
		nl -ba .config.c >> config.log
		false
	fi
}

test_link() {
	clean .config
	check_message "Checking for $1... "
	shift

	if test_make "$@" .config >> config.log 2>&1 ; then
		check_message_result "yes"
		true
	else
		check_message_result "no"
		echo "Source of the failed compile:" >> config.log
		nl -ba .config.c >> config.log
		false
	fi
}

touch_c() {
	[ -f .config.c ] && touch .config.c
}
SUFFIXES="${SUFFIXES} .lo .la"
[ -z "${LTLINKRULE}" ] && LTLINKRULE='$(LIBTOOL) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) -o $@ .configlt.lo $(LDLIBS) $(TESTLIBS) -rpath /usr/lib'
[ -z "${LTCOMPILERULE}" ] && LTCOMPILERULE='$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) $(TESTFLAGS) -c -o $@ $<'

clean_libtool() {
	clean .configlt.la libconfiglt.la .configlt.c .configlt.lo .configlt.o .libs
}

show_help_libtool() {
	if [ "$1" = VARIABLES ] ; then
		cat <<EOF
  LIBTOOL     libtool executable [libtool]
EOF
	fi
}

print_rules_libtool() {
	[ -z "${LIBTOOL}" ] && LIBTOOL="libtool"
	cat <<EOF
LIBTOOL=${LIBTOOL}

.configlt.la:libconfiglt.la
	mv libconfiglt.la .configlt.la

libconfiglt.la:.configlt.lo
	${LTLINKRULE} ${LTSHARED+-shared}

.c.lo:
	${LTCOMPILERULE} ${LTSHARED+-shared}
EOF
}

basic_test_libtool() {
	cat > .configlt.c <<EOF
int main(int argc, char *argv[]) {
	return 0;
}
EOF
	test_link_libtool "working libtool C compile" || {
		if ${LIBTOOL} -V 2>&1 | grep Apple >/dev/null ; then
			error "libtool command appears to be Apple libtool, not GNU libtool. Use LIBTOOL=<path to GNU libtool> if you do have GNU libtool installed."
		else
			error "libtool not working for C. See config.log for errors."
		fi
	}
}

sed_rules_libtool() {
	replace_default LIBTOOL "${LIBTOOL}"
}

test_compile_libtool() {
	clean .configlt.lo
	check_message "Checking for $1... "
	shift

	if test_make "$@" .configlt.lo >> config.log 2>&1 ; then
		check_message_result "yes"
		true
	else
		check_message_result "no"
		echo "Source of the failed compile:" >> config.log
		nl -ba .configlt.c >> config.log
		false
	fi
}

test_link_libtool() {
	clean .configlt.la
	check_message "Checking for $1... "
	shift

	if test_make "$@" .configlt.la >> config.log 2>&1 ; then
		check_message_result "yes"
		true
	else
		check_message_result "no"
		echo "Source of the failed compile:" >> config.log
		nl -ba .configlt.c >> config.log
		false
	fi
}

unset pkgconfigdir HASPKGCONFIG

OPTIONS="${OPTIONS} pkgconfigdir"

PKGCONFIGLIBDIR=no
for INSTALLDIR in ${INSTALLDIRS}
do
	if [ "${INSTALLDIR}" = libdir ] ; then
		PKGCONFIGLIBDIR=yes
		break
	fi
done
if [ "${PKGCONFIGLIBDIR}" = no ] ; then
	INSTALLDIRS="${INSTALLDIRS} libdir"
fi

show_help_pkgconfig() {
	if [ "$1" = OPTIONS ] ; then
		cat <<EOF
  --pkgconfigdir=<dir>   Set pkg-config data dir [<libdir>/pkgconfig]
EOF
	fi
}

print_rules_pkgconfig() {
	:
}

clean_pkgconfig() {
	:
}

basic_test_pkgconfig() {
	check_message "Checking for pkg-config... "
	echo "Running: pkg-config --variable pc_path pkg-config" >> config.log
	PKGCONFIGPATH="`pkg-config --variable pc_path pkg-config 2>> config.log`"
	if [ $? -eq 0 ] ; then
		check_message_result "yes"
		HASPKGCONFIG=yes

		if [ -n "${option_pkgconfigdir}" ] ; then
			pkgconfigdir="${option_pkgconfigdir}"
			EXPANDED_PKGCONFIGDIR="${option_pkgconfigdir}"
		else
			pkgconfigdir='$(libdir)/pkgconfig'
			EXPANDED_PKGCONFIGDIR="${option_libdir:-${PREFIX:-/usr/local}/lib}/pkgconfig"
		fi

		IFS=':'
		PKGCONFIGDIR_FOUND=no
		for DIR in ${PKGCONFIGPATH}
		do
			if [ "${DIR}" = "${EXPANDED_PKGCONFIGDIR}" ] ; then
				PKGCONFIGDIR_FOUND=yes
				break
			fi
		done
		unset IFS
		[ "${PKGCONFIGDIR_FOUND}" = no ] && check_message_result "WARNING: ${EXPANDED_PKGCONFIGDIR} is not in the pkg-config path"

	else
		HASPKGCONFIG=no
		check_message_result "no"
	fi
}

sed_rules_pkgconfig() {
	replace_default pkgconfigdir "${pkgconfigdir}"
}

gen_pkgconfig() {
	if [ -z "$PKGCONFIG_DESC" ] || [ -z "$PKGCONFIG_VERSION" ] ; then
		error "gen_pkgconfig requires PKGCONFIG_DESC and PKGCONFIG_VERSION"
	fi

	[ -z "$PKGCONFIG_NAME" ] && PKGCONFIG_NAME="$1"

	echo "----------------------------------">> config.log
	check_message_result "Creating $1.pc"
	{
		echo "prefix=${PREFIX:-/usr/local}"
		DEFAULT_DIR="\${prefix}/lib"
		echo "libdir=${option_libdir:-$DEFAULT_DIR}"
		DEFAULT_DIR="\${prefix}/include"
		echo "includedir=${option_includedir:-$DEFAULT_DIR}"
		echo
		echo "Name: $PKGCONFIG_NAME"
		echo "Description: $PKGCONFIG_DESC"
		echo "Version: $PKGCONFIG_VERSION"
		[ -n "$PKGCONFIG_URL" ] && echo "URL: $PKGCONFIG_URL"
		[ -n "$PKGCONFIG_REQUIRES" ] && echo "Requires: $PKGCONFIG_REQUIRES"
		[ -n "$PKGCONFIG_REQUIRES_PRIVATE" ] && echo "Requires.private: $PKGCONFIG_REQUIRES_PRIVATE"
		echo "Libs: -L\${libdir} $PKGCONFIG_LIBS"
		[ -n "$GETTEXTLIBS" ] && PKGCONFIG_LIBS_PRIVATE="$PKGCONFIG_LIBS_PRIVATE $GETTEXTLIBS"
		[ -n "$PKGCONFIG_LIBS_PRIVATE" ] && echo "Libs.private: $PKGCONFIG_LIBS_PRIVATE"
		[ -n "$PKGCONFIG_CFLAGS" ] && echo "Cflags: $PKGCONFIG_CFLAGS"
	} > "$1.pc"
}

append_pkgconfig() {
	eval $1="\"\${$1:+\${$1}, }$2\""
}
SWITCHES="${SWITCHES} -verbose-compile"

clean_verbose_compile() {
	:
}

show_help_verbose_compile() {
	if [ "$1" = OPTIONS ] ; then
		cat <<EOF
  --with-verbose-compile   Echo all commands during compile
EOF
	fi
}

print_rules_verbose_compile() {
	:
}

basic_test_verbose_compile() {
	:
}

sed_rules_verbose_compile() {
	[ yes = "${with_verbose_compile}" ] && echo '/^SILEN\(CE\|T\)/d'
}
SWITCHES="${SWITCHES} +gettext"
OPTIONS="${OPTIONS} localedir"
SUFFIXES="${SUFFIXES} .mo .po"

[ -z "${DEFAULT_LINGUAS}" ] && error "!! DEFAULT_LINGUAS not set"

show_help_gettext() {
	if [ "$1" = OPTIONS ] ; then
		echo "  --without-gettext      Disable gettext translations"
		echo "  --localedir=<dir>      Install directory for locales [prefix/share/locale]"
	fi
}

print_rules_gettext() {
	cat <<EOF
.po.mo:
	msgfmt -o \$@ \$<
EOF
}

clean_gettext() {
	clean .config.po .config.mo
}

sed_rules_gettext() {
	replace_default GETTEXTFLAGS "${GETTEXTFLAGS}"
	replace_default GETTEXTLIBS "${GETTEXTLIBS}"
	[ -n "${option_localedir}" ] &&	replace_default LOCALEDIR "${option_localedir}"
	replace_default LINGUAS "${linguas}"
}

basic_test_gettext() {
	unset GETTEXTFLAGS GETTEXTLIBS linguas LOCALEDIR
	# Check for gettext functionality
	if [ "yes" = "${with_gettext}" ] ; then
		cat > .config.c <<EOF
#include <locale.h>
#include <libintl.h>

int main(int argc, char *argv[]) {
	setlocale(LC_ALL, "");
	bindtextdomain("package", "/usr/share/locale");
	dgettext("package", "string");
	textdomain("package");
	gettext("package");
	return 0;
}
EOF
		{
			test_compile "gettext and related functions" && {
				test_link "gettext in standard library" ||
				{ test_link "gettext in -lintl" TESTLIBS=-lintl && GETTEXTLIBS=-lintl ; } ||
				{ test_link "gettext in -lintl -liconv" "TESTLIBS=-lintl -liconv" && GETTEXTLIBS="-lintl -liconv" ; }
			} && {
				GETTEXTFLAGS="-DUSE_GETTEXT"

				clean .config.po .config.mo
				cat > .config.po <<EOF
msgid  "msg"
msgstr "translation"
EOF
				check_message "Checking for msgfmt... "
				if test_make .config.mo >> config.log 2>&1 ; then
					check_message_result "yes"
					true
				else
					check_message_result "no"
					false
				fi
			}
		} || {
			error "!! Could not compile with gettext. Try configuring with --without-gettext."
		}
		GETTEXTFLAGS="-DUSE_GETTEXT"

		if [ -n "${LINGUAS+set}" ] ; then
			check_message "Checking for available selected translations... "
			for lingua in ${LINGUAS}
			do
				found=0
				for test_lingua in ${DEFAULT_LINGUAS}
				do
					if [ "${test_lingua}" = "${lingua}" ] ; then
						found=1
						break
					fi
				done
				[ "${found}" = 1 ] && linguas="${linguas}${linguas+ }${lingua}"
			done
			check_message_result "done [${linguas}]"
		else
			linguas="${DEFAULT_LINGUAS}"
		fi
	fi
}
show_help_lfs() {
	if [ "$1" = VARIABLES ] ; then
		cat <<EOF
  LFSFLAGS   C(++) compiler flags to use to enable Large File Support
  LFSLIBS    C(++) link flags to use to enable Large File Support
EOF
	fi
}

print_rules_lfs() {
	:
}

clean_lfs() {
	:
}

basic_test_lfs() {
	clean_c
	cat > .config.c <<EOF
#include <sys/types.h>
int off_t_assert[sizeof(off_t) > 4 ? 1 : -1];
int main(int argc, char *argv[]) {
	(void) argc; (void) argv;
	return 0;
}
EOF
	if not test_link "Large File Support as default" TESTFLAGS="$LFSFLAGS" TESTLIBS="$LFSLIBS" ; then
		LFSFLAGS=$(getconf LFS_CFLAGS 2>/dev/null)
		LFSLIBS=$(getconf LFS_LDFLAGS 2>/dev/null ; getconf LFSLIBS 2>/dev/null)
		if [ -n "$LFSFLAGS" ] || [ -n "$LFSLIBS" ] ; then
			touch_c
			if not test_link "Large File Support with getconf LFS_XXX flags" \
						TESTFLAGS="$LFSFLAGS" TESTLIBS="$LFSLIBS" ; then
				unset LFSFLAGS
				unset LFSLIBS
			fi
		fi

		if [ -z "$LFSFLAGS" ] && [ -z "$LFSLIBS" ] ; then
			check_message_result "WARNING: no Large File Support (LFS) found. If your \
system does have LFS, compiling without LFS may cause problems opening files on certain file systems."
		fi
	fi

	# Set both CFLAGS and CXXFLAGS, as either may be in use
	[ -n "$LFSFLAGS" ] && CFLAGS="$CFLAGS $LFSFLAGS" CXXFLAGS="$CXXFLAGS $LFSFLAGS"
	[ -n "$LFSLIBS" ] && LDLIBS="$LDLIBS $LFSLIBS"
	true
}

sed_rules_lfs() {
	:
}
#@INCLUDE_END

for _switch in ${SWITCHES}
do
	_name=`echo "${_switch}" | sed -e 's/^[+-]//' -e 's/-/_/g'`
	_pm="${_switch%%[!-+]*}"
	if [ "${_pm}" = "+" ] ; then
		eval with_${_name}="yes"
	else
		eval with_${_name}="no"
	fi
done
_SWITCHES=`echo " ${SWITCHES}" | sed 's/ [+-]/ /g'`

for PARAM
do
	case "${PARAM}" in
		-h|--help)
			cat <<EOF
Usage: configure [--prefix=<dir>] [<var>=<value>]

  --dump-log             Dump config.log to stdout on error
  --prefix=<dir>         Prefix for installation [/usr/local]
EOF
			for INSTALLDIR in ${INSTALLDIRS}
			do
				case "${INSTALLDIR}" in
					bindir)        echo '  --bindir=<dir>         Binaries directory [<prefix>/bin]' ;;
					sbindir)       echo '  --sbindir=<dir>        System binaries directory [<prefix>/sbin]' ;;
					libdir)        echo '  --libdir=<dir>         Library directory [<prefix>/lib]' ;;
					includedir)    echo '  --includedir=<dir>     Include file directory [<prefix>/include]' ;;
					datadir)       echo '  --datadir=<dir>        Directory for data [<prefix>/share]' ;;
					mandir)        echo '  --mandir=<dir>         Manual page directory [<prefix>/share/man]' ;;
					infodir)       echo '  --infodir=<dir>        Info page directory [<prefix>/share/man]' ;;
					docdir)        echo '  --docdir=<dir>         Document dir [<prefix>/share/doc/<name>-<version>]' ;;
				esac
			done
			[ -n "${USERINSTALLDIRSHELP}" ] && echo "${USERINSTALLDIRSHELP}"

			for EXT in ${EXTENSIONS}
			do
				show_help_$EXT OPTIONS
			done
cat <<EOF

Environment variables that tune the build:
  MAKE        Make program to use [make]
  PREFIX      See --prefix=<dir>
  INSTALL     The install program to use
  LDFLAGS     Linker flags to use (default determined by make)
  LDLIBS      Extra libraries to link
EOF
			for EXT in ${EXTENSIONS}
			do
				show_help_$EXT VARIABLES
			done

			[ -n "${USERHELP}" ] && { echo ; echo "Package specific settings" ; ${USERHELP} ; }

			cat <<EOF

Note: Environment variables may also be specified as parameters.
EOF
		exit 0
		;;
		--prefix=*)
			PREFIX="${PARAM#--prefix=}"
		;;
		--dump-log)
			DUMP_LOG=1
		;;
		--*=*)
			unset _match
			for _option in ${OPTIONS} ${INSTALLDIRS}
			do
				case "${PARAM}" in
					--${_option}=*)
						_name=`echo "${_option}" | sed 's/-/_/g'`
						_value="${PARAM#*=}"
						eval option_${_name}="'${_value}'"
						_match="1"
						break
					;;
				esac
			done
			[ -z "${_match}" ] && echo "WARNING: ignoring unknown parameter: ${PARAM}" >&2
		;;
		--*)
			unset _match
			for _switch in ${_SWITCHES}
			do
				case "${PARAM}" in
					--with-${_switch})
						_name=`echo "${_switch}" | sed 's/-/_/g'`
						eval with_${_name}="yes"
						_match="1"
						break
					;;
					--without-${_switch})
						_name=`echo "${_switch}" | sed 's/-/_/g'`
						eval with_${_name}="no"
						_match="1"
						break
					;;
				esac
			done
			[ -z "${_match}" ] && echo "WARNING: ignoring unknown parameter: ${PARAM}" >&2
		;;
		*=*)
			name="${PARAM%%=*}"
			value="${PARAM#*=}"
			eval "${name}"="\"${value}\""
		;;
		*)
			error "Error on commandline: ${PARAM}"
		;;
	esac
done

if [ -n "${INSTALL}" ] ; then
	TEST_INSTALL="${INSTALL}"
	unset INSTALL
else
	TEST_INSTALL="install ./install.sh"
fi

echo "Configuration test log created at `date`" > config.log
echo "-- configure called with $0 $@" >> config.log

clean config.log .Makefile .Makefile.in .sedscript .foo .config_base
for EXT in ${EXTENSIONS}
do
	clean_${EXT}
done

{
	echo ".POSIX:"
	[ -z "${LDFLAGS}" ] || echo "LDFLAGS=${LDFLAGS}"
	[ -z "${LDLIBS}" ] || echo "LDLIBS=${LDLIBS}"

	[ -z "${SUFFIXES}" ] || echo ".SUFFIXES: ${SUFFIXES}"

	[ -z "${USERRULES}" ] || ${USERRULES}

	cat <<EOF
install:
	\$(INSTALL) -d .foo/bar
	\$(INSTALL) -m 755 configure .foo/bar
	test -x .foo/bar/configure

.config_base:
	touch \$@

EOF

	for EXT in ${EXTENSIONS}
	do
		print_rules_${EXT}
	done
} > .Makefile.in

cp .Makefile.in .Makefile

echo "Using settings:" >> config.log
grep '^[[:upper:]_]\+=' .Makefile >> config.log

[ -n "${MAKE}" ] ||	MAKE=make

[ -z "${PRECHECKFUNC}" ] || ${PRECHECKFUNC}

check_message "Checking for working make (${MAKE})... "
if test_make .config_base >> config.log 2>&1 ; then
	check_message_result "yes"
else
	check_message_result "no"
	error "${MAKE} failed. See config.log for errors."
fi

for EXT in ${EXTENSIONS}
do
	basic_test_${EXT}
	sed_rules_${EXT} >> .sedscript
	sed -f .sedscript .Makefile.in > .Makefile
done

config
error "Error in config.pkg. Cannot continue."