summaryrefslogtreecommitdiff
path: root/configure
blob: b32b086c375153245d289618e8bf50b25cd6e9cd (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
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
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
#!/bin/sh

# project-agnostic ./configure script, written by hand.
# this file is covered by COPYING.SOFORT.

set -eu

trap config_failure 1 2 EXIT

# before we begin...
mb_path="$PATH"
mb_script="$0"
mb_success=no

usage()
{
	cat "$mb_project_dir"/config.usage

	if [ _$mb_use_custom_cfgdefs = _yes ]; then
		printf '\n\n%s%s\n' \
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"

		printf '%s%s\n' \
			"| Listed above are configure's common switches " \
			"and environment variables.     |"

		printf '%s%s\n' \
			"| Found below are project-specific variables " \
			"and other customization options. |"

		printf '%s%s\n\n\n' \
			" ___________________________________________" \
			"__________________________________"

		cat "$mb_project_dir"/project/config/cfgdefs.usage
	fi

	exit 0
}

error_msg()
{
	printf '%s\n' "$@" >&2
}

warning_msg()
{
	printf '%s\n' "$@" >&2
}

output_step_prolog()
{
	mb_line_dots='.................................'
	mb_line_dots="${mb_line_dots}.${mb_line_dots}"
	mb_step_desc="${mb_package} : ${1##*/} : ${2}()  "
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"

	printf "configure step: ${2}()\n" >&3
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s  " "${mb_step_desc}" "${mb_line_dots}"
}

output_step_epilog()
{
	printf 'OK.\n'
}

output_script_status()
{
	mb_step_name="${1##*/} : ${2}"
	mb_step_desc="${mb_package} : ${mb_step_name}"

	printf "configure info: ${2}\n" >&3
	printf "%s\n" "${mb_step_desc}"
}

output_section_break()
{
	printf ' ..\n'
}

verify_safe_path()
{
	case "$mb_safe_path_name" in
		-*)
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
			exit 2
			;;

		*\ *)
			error_msg "$mb_safe_path_desc may not contain spaces."
			exit 2
			;;
	esac
}

init_log()
{
	exec 3> config.log

	printf "This is config.log, generated by sofort's configure script.\n\n" >&3
	printf '$ %s' "$mb_script" >&3
}

init_vars()
{
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
	mb_pwd=$(pwd -P)

	mb_safe_path_desc='project directory'
	mb_safe_path_name="$mb_project_dir"
	verify_safe_path

	mb_safe_path_desc='working directory'
	mb_safe_path_name="$mb_pwd"
	verify_safe_path

	mb_custom_cfgdefs_args=''
	mb_custom_cfgdefs_space=''

	mb_srcinfo='$(PROJECT_DIR)/project/srcdist/srcinfo.in'
	mb_srcsite='localhost'

	mb_pgprkey='!!VARIABLE_NOT_SET!!'
	mb_pgpskey='!!VARIABLE_NOT_SET!!'

	sfrt_impl_dir=$mb_project_dir/sofort
	sfrt_config_dir=$sfrt_impl_dir/config
	sfrt_core_dir=$sfrt_impl_dir/core
	sfrt_config_vars=$sfrt_config_dir/config.vars
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
	sfrt_opt_vars=$sfrt_config_dir/opt.vars
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in

	mb_make_vars=$(< "$sfrt_config_vars" \
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')

	mb_impl_vars=$(< "$sfrt_config_vars" \
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')

	mb_proj_vars=$(< "$sfrt_config_vars" \
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')

	mb_flag_vars=$(< "$sfrt_flag_vars" \
		grep -v -e '^#' -e '^$')

	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"

	for mb_var in $(printf '%s' "$mb_vars") ; do
		mb_expr=$mb_var='${'$mb_var':-}'
		eval "$mb_expr"
	done

	# cfgtest
	. $mb_project_dir/sofort/cfgtest/cfgtest.sh

	# ccenv
	. $mb_project_dir/sofort/ccenv/ccenv.sh

	if ! [ -L ./ccenv ]; then
		if [ -d ./ccenv ]; then
			rm -f ./ccenv/host.mk
			rm -f ./ccenv/native.mk
			rmdir ./ccenv
		fi
	fi

	# config.project
	if [ -z "$mb_config" ]; then
		mb_config="$mb_project_dir/config.project"
	fi

	. "$mb_config"

	# config.project make preferences
	if [ -z "${MAKE}" ]; then
		MAKE="$mb_make"
	fi

	if [ -z "${MAKEMODE}" ]; then
		MAKEMODE="$mb_makemode"
	fi


	if [ -z "$mb_makefile" ]; then
		mb_makefile='Makefile'
	fi

	# pkgconf (host)
	if [ -z "${PKGCONF}" ]; then
		PKGCONF="$mb_pkgconf"
	fi

	if [ -z "${PKGCONF}" ]; then
		PKGCONF="${PKGCONFIG}"
	fi

	# pkgconf (native)
	if [ -z "${NATIVE_PKGCONF}" ]; then
		NATIVE_PKGCONF="$mb_native_pkgconf"
	fi

	if [ -z "${NATIVE_PKGCONF}" ]; then
		NATIVE_PKGCONF="${NATIVE_PKGCONFIG}"
	fi

	# project-specific initialization
	if [ _$mb_use_custom_cfginit = _yes ]; then
		. "$mb_project_dir/project/config/cfginit.sh"
	fi

	# package
	if [ -z "$mb_package" ]; then
		error_msg "$mb_script: incomplete information in $mb_config."
		error_msg "$mb_script: \$mb_package not set."
		exit 1
	fi

	if [ -z "${NICKNAME}" ]; then
		NICKNAME="$mb_nickname"
	fi

	# srcinfo
	if [ -n "$SOURCE_DIR" ]; then
		mb_source_dir_set=yes
	fi

	# cchost
	if [ -n "$CCHOST" ]; then
		mb_cchost_set=yes
	fi

	# step prolog
	output_step_prolog ${mb_script} 'init_vars'

	# project
	mb_nickname=$NICKNAME
	mb_source_dir=$SOURCE_DIR

	# dirs
	mb_prefix=$PREFIX
	mb_exec_prefix=$EXEC_PREFIX
	mb_bindir=$BINDIR
	mb_sbindir=$SBINDIR
	mb_libdir=$LIBDIR
	mb_includedir=$INCLUDEDIR
	mb_oldincludedir=$OLDINCLUDEDIR
	mb_mandir=$MANDIR
	mb_docdir=$DOCDIR
	mb_libexecdir=$LIBEXECDIR

	mb_sysconfdir=$SYSCONFDIR
	mb_sharedstatedir=$SHAREDSTATEDIR
	mb_localstatedir=$LOCALSTATEDIR
	mb_runstatedir=$RUNSTATEDIR
	mb_datarootdir=$DATAROOTDIR
	mb_datadir=$DATADIR
	mb_infodir=$INFODIR
	mb_localedir=$LOCALEDIR
	mb_htmldir=$HTMLDIR
	mb_dvidir=$DVIDIR
	mb_pdfdir=$PDFDIR
	mb_psdir=$PSDIR

	# make
	mb_make=$MAKE
	mb_makemode=$MAKEMODE

	# build
	mb_build=$BUILD
	mb_cchost=$CCHOST
	mb_cfghost=$CFGHOST
	mb_arch=$ARCH
	mb_compiler=$COMPILER
	mb_toolchain=$TOOLCHAIN
	mb_sysroot=$SYSROOT
	mb_cross_compile=$CROSS_COMPILE
	mb_shell=$SHELL

	# pkgconf
	mb_pkgconf=$PKGCONF

	# switches
	mb_cflags=$CFLAGS
	mb_cflags_debug=$CFLAGS_DEBUG
	mb_cflags_common=$CFLAGS_COMMON
	mb_cflags_cmdline=$CFLAGS_CMDLINE
	mb_cflags_config=$CFLAGS_CONFIG
	mb_cflags_sysroot=$CFLAGS_SYSROOT
	mb_cflags_os=$CFLAGS_OS
	mb_cflags_site=$CFLAGS_SITE
	mb_cflags_path=$CFLAGS_PATH
	mb_cflags_strict=$CFLAGS_STRICT
	mb_cflags_util=$CFLAGS_UTIL
	mb_cflags_last=$CFLAGS_LAST
	mb_cflags_once=$CFLAGS_ONCE

	mb_ldflags=$LDFLAGS
	mb_ldflags_debug=$LDFLAGS_DEBUG
	mb_ldflags_common=$LDFLAGS_COMMON
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
	mb_ldflags_config=$LDFLAGS_CONFIG
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
	mb_ldflags_path=$LDFLAGS_PATH
	mb_ldflags_strict=$LDFLAGS_STRICT
	mb_ldflags_util=$LDFLAGS_UTIL
	mb_ldflags_last=$LDFLAGS_LAST
	mb_ldflags_once=$LDFLAGS_ONCE

	mb_pe_subsystem=$PE_SUBSYSTEM
	mb_pe_image_base=$PE_IMAGE_BASE

	# overrides
	mb_user_cc=$CC
	mb_user_cpp=$CPP
	mb_user_cxx=$CXX

	mb_native_cc=$NATIVE_CC
	mb_native_cpp=$NATIVE_CPP
	mb_native_cxx=$NATIVE_CXX

	mb_native_host=$NATIVE_HOST
	mb_native_cfghost=$NATIVE_CFGHOST
	mb_native_cflags=$NATIVE_CFLAGS
	mb_native_ldflags=$NATIVE_LDFLAGS

	mb_native_pkgconf=$NATIVE_PKGCONF

	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE

	# step epilog
	output_step_epilog
}


verify_build_directory()
{
	output_step_prolog ${mb_script} 'verify_build_directory'

	if [ "$mb_project_dir" = "$mb_pwd" ]; then
		if [ _$mb_require_out_of_tree = _yes ]; then
			error_msg "$mb_package: out-of-tree builds are required."
			error_msg "please invoke configure again from a clean build directory."
			exit 1
		else
			mb_project_dir='.'
		fi
	fi

	if [ -f "$mb_pwd/Makefile.common" ]; then
		error_msg
		error_msg "$mb_package: the file-name Makefile.common is reserved for bootstrapping projects."
		error_msg "$mb_package: please remove or rename the file manually and then re-run configure."
		exit 1
	fi

	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed $mb_makefile

	output_step_epilog
}


verify_source_directory()
{
	output_step_prolog ${mb_script} 'verify_source_directory'

	if [ _"$mb_source_dir" != _${mb_source_dir##* } ]; then
		error_msg "source directory path contains spaces, aborting."
		exit 1
	fi

	eval mb_source_dir=$(printf '%s' "$mb_source_dir")

	if [ -z "$mb_source_dir" ]; then
		if [ _$mb_require_source_dir = _yes ]; then
			error_msg "$mb_package: specifying an external source directory is required."
			error_msg "you can set the source directory either via --source-dir=<path>,"
			error_msg "or by setting the SOURCE_DIR variable."
			exit 1
		fi
	fi

	output_step_epilog
}


verify_source_info()
{
	output_step_prolog ${mb_script} 'verify_source_info'

	if [ "${mb_source_dir_set:-}" = yes ]; then
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ] || [ -n "$mb_srcball" ]; then
			error_msg "$mb_package: conflicting arguments: --rawball/--modball/--srcball arguments"
			error_msg "may not be used together with an explicit source-dir argument or variable."
			exit 1
		fi
	fi

	if [ -n "$mb_srcball" ]; then
		eval mb_srcball=$(printf '%s' "$mb_srcball")

		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ]; then
			error_msg "$mb_package: conflicting arguments: --rawball and/or --modball arguments"
			error_msg "may not be used together with an explicitly --srcball argument."
			exit 1
		fi

		if [ -z "$mb_srcball_sha256" ]; then
			error_msg "$mb_package: --srcball-sha256 must be provided"
			error_msg "in conjunction with --srcball."
			exit 1
		fi

		mb_srcball_sha256_test=$(sha256sum "$mb_srcball")
		mb_srcball_sha256_test="${mb_srcball_sha256_test%% *}"

		if [ "$mb_srcball_sha256_test" != "$mb_srcball_sha256" ]; then
			error_msg "$mb_package: sha256 signature of srcball $mb_srcball does not match!"
			exit 1
		fi

		mb_srcball_topdir=$(xz -c -d "$mb_srcball" | pax | sed -n '1,1p')
		mb_source_dir="./srctree/$mb_package/${mb_srcball_topdir%/}"

		mb_srcball_dirname=$(cd -- "${mb_srcball%/*}" ; pwd -P)
		mb_srcball_basename=${mb_srcball##*/}
		mb_srcball="$mb_srcball_dirname/$mb_srcball_basename"

		mkdir -p "./srctree/$mb_package"
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_srcball" | pax -r)
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
	fi

	if [ -z "$mb_rawball" ] && [ -n "$mb_modball" ]; then
		error_msg "$mb_package: conflicting arguments: --modball argument may only be used"
		error_msg "together with an explicit --rawball argument."
		exit 1
	fi

	if [ -n "$mb_modball" ]; then
		eval mb_modball=$(printf '%s' "$mb_modball")

		if [ -z "$mb_modball_sha256" ]; then
			error_msg "$mb_package: --modball-sha256 must be provided"
			error_msg "in conjunction with --modball."
			exit 1
		fi

		mb_modball_sha256_test=$(sha256sum "$mb_modball")
		mb_modball_sha256_test="${mb_modball_sha256_test%% *}"

		if [ "$mb_modball_sha256_test" != "$mb_modball_sha256" ]; then
			error_msg "$mb_package: sha256 signature of modball $mb_modball does not match!"
			exit 1
		fi
	fi

	if [ -n "$mb_rawball" ]; then
		eval mb_rawball=$(printf '%s' "$mb_rawball")

		if [ -z "$mb_rawball_sha256" ]; then
			error_msg "$mb_package: --rawball-sha256 must be provided."
			error_msg "in conjunction with --rawball."
			exit 1
		fi

		mb_rawball_sha256_test=$(sha256sum "$mb_rawball")
		mb_rawball_sha256_test="${mb_rawball_sha256_test%% *}"

		if [ "$mb_rawball_sha256_test" != "$mb_rawball_sha256" ]; then
			error_msg "$mb_package: sha256 signature of rawball $mb_rawball does not match!"
			exit 1
		fi

		mb_rawball_topdir=$(xz -c -d "$mb_rawball" | pax | sed -n '1,1p')
		mb_source_dir="./srctree/$mb_package/${mb_rawball_topdir%/}"

		mb_rawball_dirname=$(cd -- "${mb_rawball%/*}" ; pwd -P)
		mb_rawball_basename=${mb_rawball##*/}
		mb_rawball="$mb_rawball_dirname/$mb_rawball_basename"

		mkdir -p "./srctree/$mb_package"
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_rawball" | pax -r)
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
	fi

	if [ -n "$mb_modball" ]; then
		mb_modball_dirname=$(cd -- "${mb_modball%/*}" ; pwd -P)
		mb_modball_basename=${mb_modball##*/}
		mb_modball="$mb_modball_dirname/$mb_modball_basename"

		mb_modball_topdir="./modtree/$mb_package/$mb_modball_sha256"
		mkdir -p "$mb_modball_topdir"
		mb_modball_topdir=$(cd -- $mb_modball_topdir; pwd -P)
		mb_dummy=$(cd -- "$mb_modball_topdir"; xz -c -d "$mb_modball" | pax -r)

		if [ -d "$mb_modball_topdir/overlay" ]; then
			mb_dummy=$(cd -- "$mb_modball_topdir/overlay"; \
				cp -p -P -R . "$mb_source_dir")
		fi

		if [ -d "$mb_modball_topdir/patches" ]; then
			mb_dummy=$(cd -- "$mb_source_dir";                        \
				for p in $mb_modball_topdir/patches/*.patch; do  \
					patch -p1 < $p;                         \
				done);
		fi
	fi

	output_step_epilog
}


common_defaults()
{
	# step prolog
	output_step_prolog ${mb_script} 'common_defaults'

	# project-specific config definitions
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
		cat $sfrt_cfgdefs_in > cfgdefs.mk
	else
		printf '%s %s\n\n' \
				'# this project does not include' \
				'a custom config step.'           \
			> cfgdefs.mk
		cat $sfrt_cfgdefs_in >> cfgdefs.mk

		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
		fi
	fi

	# user build-time overrides
	touch usrdefs.mk

	# git
	if [ -n "$mb_source_dir" ]; then
		if [ -d "$mb_source_dir/.git" ]; then
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
		fi
	elif [ -d "$mb_project_dir/.git" ]; then
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
	fi

	# project
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'

	# pkgconfig
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
	[ -n "$mb_pkgbugs" ]		|| mb_pkgbugs="$mb_default_pkgbugs"
	[ -n "$mb_pkghome" ]		|| mb_pkghome="$mb_default_pkghome"
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"

	# srcinfo
	[ -n "$mb_rawball" ]		|| mb_rawball="$mb_default_rawball"
	[ -n "$mb_rawball_url" ]	|| mb_rawball_url="$mb_default_rawball_url"
	[ -n "$mb_rawball_sha256" ]	|| mb_rawball_sha256="$mb_default_rawball_sha256"
	[ -n "$mb_modball" ]		|| mb_modball="$mb_default_modball"
	[ -n "$mb_modball_url" ]	|| mb_modball_url="$mb_default_modball_url"
	[ -n "$mb_modball_sha256" ]	|| mb_modball_sha256="$mb_default_modball_sha256"
	[ -n "$mb_srcball" ]		|| mb_srcball="$mb_default_srcball"
	[ -n "$mb_srcball_url" ]	|| mb_srcball_url="$mb_default_srcball_url"
	[ -n "$mb_srcball_sha256" ]	|| mb_srcball_sha256="$mb_default_srcball_sha256"

	# dirs
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
					|| mb_prefix='/usr/local'

	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
					|| mb_exec_prefix=$mb_prefix

	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
					|| [ -n "$mb_bindir_basename" ] \
					|| mb_bindir=$mb_exec_prefix/bin

	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename

	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc/'$(PACKAGE)'
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec

	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir

	# switches
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once

	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once

	# native switches
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags

	# config
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'

	# host/target
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
	[ -n "$mb_target" ] 		|| mb_target=$mb_host

	# sysroot
	if [ -n "$mb_sysroot" ]; then
		if [ -z "$mb_cflags_sysroot" ]; then
			mb_cflags_sysroot='$(_CFLAGS_SYSROOT)'
		fi

		if [ -z "$mb_ldflags_sysroot" ]; then
			mb_ldflags_sysroot='$(_LDFLAGS_SYSROOT)'
		fi
	fi

	# debug
	if [ _$mb_debug = _yes ]; then
		if [ -z "$mb_cflags_debug" ]; then
			mb_cflags_debug='$(_CFLAGS_g3) $(_CFLAGS_O0)'
		fi
	fi

	# make
	if [ -z "$mb_make" ]; then
		mb_make='make'
	fi

	if [ -z "$mb_makemode" ]; then
		mb_makemode='posix'

		printf '%s\n%s\n%s\n\n%s\n\n'        \
				'ifeq (a,b)'          \
				'VAR = val'            \
				'endif'                 \
				'all:'                   \
			| ${mb_make} -s -f - 2>/dev/null  \
		&& mb_makemode='modern'

	fi

	# shell
	if [ -z "$mb_shell" ]; then
		mb_shell='/bin/sh'
	fi

	# inherited cflags & ldflags
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"

	# step epilog
	output_step_epilog
}


config_flags()
{
	# step prolog
	output_step_prolog ${mb_script} 'config_flags'

	mb_ldflags_tmp=" $mb_ldflags "
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')

	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
		mb_ldflags="$mb_ldflags_libs"
		mb_ldflags_util="$mb_ldflags_util -static"
	fi

	# ccstrict
	if [ _$mb_ccstrict = _yes ]; then
		mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef)'
	fi

	# ldstrict
	if [ _$mb_ldstrict = _yes ]; then
		mb_ldflags_strict='$(_CFLAGS_Wl___no_undefined)'
	fi

	# step epilog
	output_step_epilog
}


config_opts()
{
	if [ "$mb_avoid_version" = 'yes' ]; then
		mb_version_opt='none'
	else
		mb_version_opt='used'
	fi

	if [ "$mb_custom_install_headers" = 'yes' ]; then
		mb_install_headers_opt='custom'
	else
		mb_install_headers_opt='default'
	fi

	if [ "$mb_disable_static" = 'yes' ]; then
		mb_static_library_opt='disabled'
	else
		mb_static_library_opt='enabled'
	fi

	if [ "$mb_disable_shared" = 'yes' ]; then
		mb_shared_library_opt='disabled'
	else
		mb_shared_library_opt='enabled'
	fi

	if [ "$mb_disable_frontend" = 'yes' ]; then
		mb_app_frontend_opt='disabled'
	else
		mb_app_frontend_opt='enabled'
	fi

	if [ "$mb_all_static" = 'yes' ]; then
		mb_app_linking_opt='all_static'

	elif [ "$mb_all_shared" = 'yes' ]; then
		mb_app_linking_opt='all_shared'

	else
		mb_app_linking_opt='default'
	fi
}

config_copy()
{
	output_step_prolog ${mb_script} 'config_copy'

	mb_var_defs=
	mb_sed_substs=
	mb_template="${1:-$mb_project_dir/Makefile.in}"

	mb_vars=$(cut -d'=' -f1 "$sfrt_config_vars" "$sfrt_opt_vars" \
		| grep -v '^#');

	for __var in $(printf '%s' "$mb_vars"); do
		mb_sed_subst=$(printf '%s %s%s%s'  \
				'-e' "'s^@$__var@"  \
				"^___${__var}___"    \
				"^g'")

		mb_sed_substs="$mb_sed_substs $mb_sed_subst"

		mb_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "mb_${__var}")
		eval mb_var_defs='"$mb_var_defs "$mb_var_def'
	done

	eval sed $mb_sed_substs $mb_template         \
			| eval m4 $mb_var_defs -      \
			| sed -e 's/[[:blank:]]*$//g'  \
		> $mb_pwd/Makefile.tmp

	output_step_epilog
}


config_ccenv()
{
	mkdir -p ./ccenv
	touch ./ccenv/host.mk
	touch ./ccenv/native.mk

	output_section_break
	ccenv_set_host_variables

	output_section_break
	ccenv_set_native_variables

	# implicit --sysroot for use with pkgconf and friends
	if [ -z "$mb_sysroot" ]; then
		mb_sysroot="$ccenv_host_sysroot"
	fi

	# require --sysroot when cross-compiling
	if [ "$mb_cchost" != "$mb_native_cchost" ]                   \
			&& [ "$ccenv_host_cc" != "$ccenv_native_cc" ] \
			&& [ -z "$mb_sysroot" ]; then
		mb_pretty=$(printf "%-${#mb_package}s" '')

		error_msg ' !!'
		error_msg "$mb_package: host machine:    $mb_cchost"
		error_msg "$mb_package: host compiler:   $ccenv_host_cc"

		error_msg ' !!'
		error_msg "$mb_package: native machine:  $mb_native_cchost"
		error_msg "$mb_package: native compiler: $ccenv_native_cc"

		error_msg ' !!'
		error_msg "$mb_package: detected host machine and native machine differ, assuming cross-compilation."

		error_msg ' !!'
		error_msg "$mb_package: native compilation mode can be forced via --cchost=$mb_native_cchost"
		error_msg "${mb_pretty}  or otherwise by setting the NATIVE_CC environment variable to '$ccenv_host_cc',"
		error_msg "${mb_pretty}  however that should almost never be necessary; then again,"
		error_msg "${mb_pretty}  forcing native mode when cross-building is strictly prohibited."

		error_msg ' !!'
		error_msg "$mb_package: error: --sysroot is required when cross-compiling."
		exit 2
	fi

	# add the library directory to the linker library path
	if [ "$mb_cchost" = "$mb_native_cchost" ]; then
		mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
	else
		case "$mb_libdir" in
			/*)
				mb_ldflags_last="$mb_ldflags_last -L$mb_sysroot/.$mb_libdir"
				;;
			*)
				mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
		esac
	fi

	# re-generate Makefile.tmp
	output_section_break
	config_copy

}

config_custom_cfgdefs()
{
	. $mb_project_dir/project/config/cfgdefs.sh
}

config_custom()
{
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
		output_section_break
		output_script_status ${mb_script} \
			'invoking project-specific cfgdefs.sh'

		eval config_custom_cfgdefs "$mb_custom_cfgdefs_args"

		output_section_break

		if [ -f "$mb_project_dir/project/config/Makefile.in" ]; then
			config_copy "$mb_project_dir/project/config/Makefile.in"
			mv $mb_pwd/Makefile.tmp Makefile
		fi

		config_copy
	fi

	if [ _$mb_use_custom_usrdefs = _yes ]; then
		output_section_break
		output_script_status ${mb_scirpt} \
			'invoking project-specific usrdefs.sh'

		. $mb_project_dir/project/usrdefs.sh
		output_section_break
	fi
}


config_cfghost()
{
	output_step_prolog ${mb_script} 'config_cfghost'

	if [ -z "$mb_cfghost" ]; then
		mb_cfghost=$mb_cchost
	fi

	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host

	rm  $mb_pwd/Makefile.tmp
	mv  $mb_pwd/Makefile.host $mb_pwd/$mb_makefile

	output_step_epilog
}


config_host()
{
	# init
	output_step_prolog ${mb_script} 'config_host'

	mb_cfghost_cc="$ccenv_host_cc"
	mb_cfghost_tmpname='ccenv/c3RyaWN0X21vZGUK.c'

	mb_cfghost_cflags=$(${mb_make} -n -f "$mb_makefile" \
		.cflags-host)

	mb_cfghost_cflags="${mb_cfghost_cflags#*: }"

	if [ "$mb_cc_environment" = 'freestanding' ]; then
		if [ -z "mb_cc_underscore" ]; then
			mb_cfghost_start_fn='_start'
		else
			mb_cfghost_start_fn='start'
		fi

		printf 'int %s(void){return 0;}' "$mb_cfghost_start_fn" \
			> "$mb_cfghost_tmpname"

		mb_cfghost_cflags="$mb_cfghost_cflags -ffreestanding"
		mb_cfghost_cflags="$mb_cfghost_cflags -nostdlib"
	else
		printf 'int main(void){return 0;}' \
			> "$mb_cfghost_tmpname"
	fi

	# log
	printf '\n' >&3

	printf '%s\n'                                         \
		'#'                                           \
		'# verify that that following combination of' \
		'# host compiler and host cflags is working.' \
		'#'                                           \
		>&3

	printf '\n%s' "$mb_cfghost_cc $ccenv_tmpname -o a.out" >&3

	for mb_cfghost_cflag in $(printf '%s' "$mb_cfghost_cflags"); do
		printf ' \\\n\t%s' "$mb_cfghost_cflag" >&3
	done

	printf '\n\n' >&3

	# execute
	if eval $mb_cfghost_cc "$ccenv_tmpname" -o a.out    \
			$(printf '%s' "$mb_cfghost_cflags") \
			2>&3; then
		rm a.out
		rm $mb_cfghost_tmpname
		mb_cfghost_ret=0
	else
		mb_cfghost_ret=1
	fi

	if [ $mb_cfghost_ret = 0 ]; then
		output_step_epilog
		return 0
	fi

	# should never happen
	error_msg
	error_msg "configure was able to generate a Makefile for the selected host,"
	error_msg "however the host-targeting compiler was found to be missing"
	error_msg "at least one of the required headers or features."
	exit 2
}


config_fini()
{
	# project-specific post-configuration steps
	if [ _$mb_use_custom_cfgfini = _yes ]; then
		. "$mb_project_dir/project/config/cfgfini.sh"
	fi
}


config_status()
{
	output_script_status ${mb_script} \
		'configuration completed successfully.'
	printf '\n'
}


config_failure()
{
	if [ _$mb_success = _yes ]; then
		return 0
	fi

	printf 'configure info: exiting due to an error.\n' >&3

	exit 2
}


config_success()
{
	trap '' EXIT
	mb_success=yes
	exit 0
}


# one: init
mb_args_defs=
mb_args_text=
mb_args_idx=0

init_log

for arg ; do
	mb_args_idx=$((mb_args_idx+1))

	mb_arg_def=$(printf '%s%s="${%s}"' "-D_" "${mb_args_idx}" "${mb_args_idx}")
	eval mb_args_defs='"$mb_args_defs "$mb_arg_def'

	mb_args_text="$mb_args_text '_$((mb_args_idx))'"
done

printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3

if [ $mb_args_idx -gt 1 ]; then
	printf '$ %s' "$mb_script" >&3

	mb_args_idx=0
	mb_args_text=

	for arg; do
		mb_args_idx=$((mb_args_idx+1))
		mb_args_text="$mb_args_text"$(printf ' \\\\\n\t%s_%d%s' "'" "$mb_args_idx" "'")
	done

	printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
fi

init_vars
verify_build_directory


# two: args
for arg ; do
	case "$arg" in
		--help)
			usage
			;;
		--help=ccenv)
			ccenv_usage
			;;

		# ccenv
		--cross-compile=*)
			mb_cross_compile=${arg#*=}
			;;
		--compiler=*)
			mb_compiler=${arg#*=}
			;;
		--toolchain=*)
			mb_toolchain=${arg#*=}
			;;
		--zealous)
			mb_agnostic=yes
			mb_zealous=
			;;
		--zealous=*)
			mb_zealous=${arg#*=}
			;;
		--ccenv=*)
			mb_ccenv=${arg#*=}
			;;

		# dirs
		--prefix=*)
			mb_prefix_set=yes
			mb_prefix=${arg#*=}
			;;
		--exec-prefix=*)
			mb_exec_prefix_set=yes
			mb_exec_prefix=${arg#*=}
			;;
		--bindir=*)
			mb_bindir_set=yes
			mb_bindir=${arg#*=}
			;;
		--sbindir=*)
			mb_sbindir=${arg#*=}
			;;
		--libdir=*)
			mb_libdir=${arg#*=}
			;;
		--includedir=*)
			mb_includedir=${arg#*=}
			;;
		--oldincludedir=*)
			mb_oldincludedir=${arg#*=}
			;;
		--mandir=*)
			mb_mandir=${arg#*=}
			;;
		--libexecdir=*)
			mb_libexecdir=${arg#*=}
			;;


		--sysconfdir=*)
			mb_sysconfdir=${arg#*=}
			;;
		--sharedstatedir=*)
			mb_sharedstatedir=${arg#*=}
			;;
		--localstatedir=*)
			mb_localstatedir=${arg#*=}
			;;
		--runstatedir=*)
			mb_runstatedir=${arg#*=}
			;;
		--datarootdir=*)
			mb_datarootdir=${arg#*=}
			;;
		--datadir=*)
			mb_datadir=${arg#*=}
			;;
		--infodir=*)
			mb_infodir=${arg#*=}
			;;
		--localedir=*)
			mb_localedir=${arg#*=}
			;;
		--htmldir=*)
			mb_htmldir=${arg#*=}
			;;
		--dvidir=*)
			mb_dvidir=${arg#*=}
			;;
		--pdfdir=*)
			mb_pdfdir=${arg#*=}
			;;
		--psdir=*)
			mb_psdir=${arg#*=}
			;;

		#make
		--make=*)
			mb_make=${arg#*=}
			;;

		--makemode=*)
			mb_makemode=${arg#*=}
			;;

		#pkgconf[ig]
		--pkgconf=*)
			mb_pkgconf=${arg#*=}
			;;

		--pkgconfig=*)
			mb_pkgconf=${arg#*=}
			;;

		# build
		--build=*)
			mb_build=${arg#*=}
			;;
		--host=*)
			mb_host=${arg#*=}
			;;
		--cchost=*)
			mb_cchost=${arg#*=}
			mb_cchost_set=yes
			;;
		--cfghost=*)
			mb_cfghost=${arg#*=}
			;;
		--target=*)
			mb_target=${arg#*=}
			;;
		--arch=*)
			mb_arch=${arg#*=}
			;;
		--sysroot=*)
			mb_sysroot=${arg#*=}
			;;
		--shell=*)
			mb_shell=${arg#*=}
			;;
		--debug)
			mb_debug=yes
			;;

		# config
		--all-static)
			mb_all_static=yes
			mb_all_shared=no
			;;
		--all-shared)
			mb_all_shared=yes
			mb_all_static=no
			;;
		--disable-frontend)
			mb_disable_frontend=yes
			;;
		--disable-app)
			mb_disable_frontend=yes
			;;
		--enable-frontend)
			mb_disable_frontend='no'
			;;
		--enable-app)
			mb_disable_frontend='no'
			;;
		--disable-static)
			mb_disable_static=yes
			;;
		--disable-shared)
			mb_disable_shared=yes
			;;
		--enable-static)
			mb_disable_static='no'
			;;
		--enable-shared)
			mb_disable_shared='no'
			;;

		# convenience
		--strict)
			mb_ccstrict=yes
			mb_ldstrict=yes
			;;
		--ccstrict)
			mb_ccstrict=yes
			;;
		--ldstrict)
			mb_ldstrict=yes
			;;

		# project
		--nickname=*)
			mb_nickname=${arg#*=}
			;;
		--program-prefix=*)
			mb_program_prefix=${arg#*=}
			;;
		--avoid-version)
			mb_avoid_version=yes
			;;
		--source-dir=*)
			mb_source_dir=${arg#*=}
			mb_source_dir_set=yes
			;;
		--srcdir=*)
			mb_source_dir=${arg#*=}
			mb_source_dir_set=yes
			;;

		# pkgconfig
		--pkgname=*)
			mb_pkgname=${arg#*=}
			;;

		--pkgdesc=*)
			mb_pkgdesc=${arg#*=}
			;;

		--pkgusrc=*)
			mb_pkgusrc=${arg#*=}
			;;

		--pkgrepo=*)
			mb_pkgrepo=${arg#*=}
			;;

		--pkgpsrc=*)
			mb_pkgpsrc=${arg#*=}
			;;

		--pkgdurl=*)
			mb_pkgdurl=${arg#*=}
			;;

		--pkgbugs=*)
			mb_pkgbugs=${arg#*=}
			;;

		--pkghome=*)
			mb_pkghome=${arg#*=}
			;;

		--pkgdefs=*)
			mb_pkgdefs=${arg#*=}
			;;

		--pkglibs=*)
			mb_pkglibs=${arg#*=}
			;;

		# srcinfo
		--srcinfo=*)
			mb_srcinfo=${arg#*=}
			;;

		--srcsite=*)
			mb_srcsite=${arg#*=}
			;;

		--pgprkey=*)
			mb_pgprkey=${arg#*=}
			;;

		--pgpskey=*)
			mb_pgpskey=${arg#*=}
			;;

		--rawball=*)
			mb_rawball=${arg#*=}
			;;

		--rawball-url=*)
			mb_rawball_url=${arg#*=}
			;;

		--rawball-sha256=*)
			mb_rawball_sha256=${arg#*=}
			;;

		--modball=*)
			mb_modball=${arg#*=}
			;;

		--modball-url=*)
			mb_modball_url=${arg#*=}
			;;

		--modball-sha256=*)
			mb_modball_sha256=${arg#*=}
			;;

		--srcball=*)
			mb_srcball=${arg#*=}
			;;

		--srcball-url=*)
			mb_srcball_url=${arg#*=}
			;;

		--srcball-sha256=*)
			mb_srcball_sha256=${arg#*=}
			;;

		# compatibility
		--enable-dependency-tracking)
			;;
		--disable-dependency-tracking)
			;;

		*)
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
				mb_custom_cfgdefs_space=' '
			else
				error_msg ${arg#}: "unsupported config argument."
				exit 2
			fi
			;;
	esac

	mb_safe_path_desc='source directory'
	mb_safe_path_name="$mb_source_dir"
	verify_safe_path
done



# three: validation
verify_source_directory
verify_source_info

if ! [ -z "$mb_program_prefix" ]; then
	error_msg "--program-prefix is not yet fully support (must be null)."
fi



# four: defaults
common_defaults


# five: config
config_flags
config_opts
config_copy
config_ccenv
config_custom
config_cfghost
config_host
config_fini
config_status


# all done
config_success