forked from wdlkmpx/cdimage2iso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·1325 lines (1171 loc) · 30.3 KB
/
configure
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
#!/bin/sh
# Public Domain
#
WCURDIR=$(pwd)
export WCONF_SCRIPTDIR=$(cd "$(dirname "$0")" ; pwd -P)
export WCONF_CONFIGURE=${WCONF_SCRIPTDIR}/$(basename "$0")
if [ "$WCURDIR" != "$WCONF_SCRIPTDIR" ] ; then
echo "Current dir: $WCURDIR"
echo "Wconf dir : $WCONF_SCRIPTDIR"
echo "Out-of-tree builds are not supported..."
exit 1
fi
if ! [ -f Makefile ] ; then
echo 'Main Makefile is missing, cannot continue'
exit 1
fi
## env vars must not change important variables
host=
build=
static_link=''
apps_to_check=''
extra_env_vars=''
make_extra_flags='' # config_mk_extra
config_h_extra=''
config_sh_extra=''
extra_configure_opts=''
config_h_have=
config_mk_flags=
w_files_in=
sysroot=
unset VERSION PACKAGE PACKAGE_URL PROJECT_TYPE
unset PROJECT_CFLAGS PROJECT_CXXFLAGS PROJECT_CPPFLAGS PROJECT_LDFLAGS PROJECT_LXXFLAGS PROJECT_LIBS
#==========================================================
uppercase() {
echo "$@" | tr '[:lower:]' '[:upper:]'
}
if [ -n "$BASH_VERSION" ] ; then
case $BASH_VERSION in
3.*|2.*|1.*) BASH_NO_CASE=1 ;;
*) eval 'uppercase() { echo "${@^^}" ; }' ;;
esac
fi
add_env_help() {
extra_env_vars="$extra_env_vars $@"
}
w_new_option() # $1=opt [$2=env_variable]
{
w_opts_configure="$w_opts_configure $1"
w_opts_check="$w_opts_check $1"
if [ -n "$2" ] ; then
add_env_help "$2"
fi
}
w_new_option_with()
{
extra_packages_opts="$extra_packages_opts $1"
w_opts_check="$w_opts_check $1"
}
exit_error() {
test "$1" && echo "$@"
if [ -f config.log ] ; then
echo "See config.log, there might be some clues there"
fi
rm -f config.h config.mk
exit 1
}
cmdecho()
{
echo "# $@"
"$@"
}
getvalue()
{
zzval="$@"
zzres="${zzval#*=}"
if [ -n "$zzres" ] ; then
echo "$zzres"
else
echo "$zzval" | cut -f 2 -d '='
fi
}
include()
{
. ${WCONF_SCRIPTDIR}/w_conf/${1} || exit 1
}
#==========================================================
if [ -f ${WCONF_SCRIPTDIR}/configure.project ] ; then
. ${WCONF_SCRIPTDIR}/configure.project
elif [ -f ${WCONF_SCRIPTDIR}/wconf.project ] ; then
. ${WCONF_SCRIPTDIR}/wconf.project
else
echo "Need configure.project or wconf.project"
exit 1
fi
if [ -z "$PROJECT_TYPE" ] ; then
PROJECT_TYPE="C++"
fi
PACKAGE_NAME="${PACKAGE}"
PACKAGE_STRING="${PACKAGE} ${VERSION}"
PACKAGE_TARNAME="${PACKAGE}"
PACKAGE_BUGREPORT="${PACKAGE_URL}"
PACKAGE_VERSION="${VERSION}"
#==========================================================
# ./configure release [xz|gz|lz|bz2|zst]
if [ "$1" = "release" ] || [ "$1" = "dist" ] ; then
srcdir=${WCONF_SCRIPTDIR}
outdir=${PACKAGE}-${VERSION}
if [ ! -d .git ] ; then
echo "Warning: no .git directory, will not be able to perform 'git clean'"
fi
if [ ! -d .git ] ; then
echo "Warning: no .gitignore file, it contains rules to delete unwanted files, the release tarball may not be suitable for release"
fi
if [ "$outdir" = "$(basename $srcdir)" ] ; then
echo "ERROR: output dir ($outdir) is the also input directory"
exit 1
fi
cmdecho cd ..
cmdecho rm -rf ${outdir}
cmdecho cp -rf ${srcdir} ${outdir}
cmdecho mkdir -p ${outdir}
cmdecho cd ${outdir}
if command -v git >/dev/null; then
cmdecho git clean -dfx
fi
rm -rf .[a-z]* .[A-Z]* .[0-9]*
cmdecho cd ..
#--
echo "# tar -vcf ${outdir}.tar ${outdir}"
tar -vcf ${outdir}.tar ${outdir}
comp=$2
if [ -z "$comp" ] ; then
comp=xz
fi
case $comp in
gz) cmd=gzip ;;
lz) cmd=lzip ;;
bz2) cmd=bzip2 ;;
zst) cmd=zstd ;;
*) cmd=${comp} ;;
esac
rm -f ${outdir}.tar.${comp}
if cmdecho ${cmd} ${outdir}.tar ; then
echo "*** ${outdir}.tar.${comp} has been created..."
exit 0
fi
rm -f ${outdir}.tar
exit 1
fi
#==========================================================
check_command() # 1:<cmd> finds $1 in $PATH
{
if [ -z "$xxpath" ] ; then
if [ "$BASH_VERSION" ] ; then
xxpath=${PATH//:/ }
else
# dash doesn't support ${//}
xxpath="$(echo "$PATH" | tr ':' ' ')"
fi
fi
for xcmdx in $@
do
case "${xcmdx}" in /*)
# a full path, check if file is executable
if [ -x "${xcmdx}" ] ; then
echo "${xcmdx}"
return 0
fi
continue
;;
esac
#--
for zpathz in ${xxpath}
do
if [ -x "${zpathz}/${xcmdx}" ] ; then
echo "${zpathz}/${xcmdx}"
return 0
fi
done
done
return 1
}
set_cc()
{
CC_IS_FULL_PATH=''
case $PROJECT_TYPE in
C|C++) okw=1;;
*) [ -z "$CC" ] && CC="cc"
return ;;
esac
case $CC in /*)
CC_IS_FULL_PATH=1 ;;
esac
GCC="no"
printf "Checking for C compiler... "
ZCC="$(check_command ${CC:-cc gcc clang})"
if [ -z "$ZCC" ] ; then
exit_error "$CC not found"
fi
CC="$ZCC"
echo "$CC"
if [ -n "$CC" ] && [ -z "$CC_IS_FULL_PATH" ] ; then
CC="$(basename $CC)" # not a full path, keep binary name
fi
}
set_cxx()
{
CXX_IS_FULL_PATH=''
if [ "$PROJECT_TYPE" != "C++" ] ; then
[ -z "$CXX" ] && CXX="c++"
return
fi
case $CXX in /*)
CXX_IS_FULL_PATH=1 ;;
esac
#--
printf "Checking for C++ compiler... "
ZXX="$(check_command ${CXX:-c++ g++ clang++})"
if [ -z "$ZXX" ] ; then
exit_error "$CXX not found"
fi
CXX="$ZXX"
echo "$CXX"
if [ -n "$CXX" ] && [ -z "$CXX_IS_FULL_PATH" ] ; then
CXX="$(basename $CXX)" # not a full path, keep binary name
fi
}
set_w_pkg_config()
{
printf "Checking for pkg-config... "
W_PKG_CONFIG="$PKG_CONFIG"
if [ -z "${W_PKG_CONFIG}" ] ; then
W_PKG_CONFIG="$(check_command pkg-config pkgconf)"
fi
if [ -z "${W_PKG_CONFIG}" ] ; then
echo "no"
return
fi
echo "$W_PKG_CONFIG [$($W_PKG_CONFIG --version 2>/dev/null)]"
if [ -n "$static_link" ] ; then #force static
case ${W_PKG_CONFIG} in
*--static*) ok=1 ;;
*) W_PKG_CONFIG="$W_PKG_CONFIG --static" ;;
esac
fi
}
run_pkg_config() {
${W_PKG_CONFIG:-pkg-config} "$@"
}
w_pkgconfig_run() {
run_pkg_config "$@"
}
w_pkgconfig_check() # $1=<pkg> $2=[min-version]
{
# returns 0=ok, use pkg-config
pc_pkg="$1"
pc_pkg_min_ver="$2"
if [ -n "$pc_pkg_min_ver" ] ; then
printf "Checking for %s >= %s... " "${pc_pkg}.pc" "$pc_pkg_min_ver"
else
printf "Checking for %s... " "${pc_pkg}.pc"
fi
if [ -z "$W_PKG_CONFIG" ] ; then
echo "no (!!pkg-config is missing!!)"
return 1 #error
fi
#--
run_pkg_config ${pc_pkg} --exists
if [ $? -ne 0 ] ; then
echo "no"
return 1 #error
fi
xpkgverx="$(run_pkg_config ${pc_pkg} --modversion 2>/dev/null)"
if [ -n "$pc_pkg_min_ver" ] ; then
run_pkg_config ${pc_pkg} --atleast-version=${pc_pkg_min_ver}
if [ $? -ne 0 ] ; then
if [ -n "$xpkgverx" ] ; then
echo "no [found $xpkgverx]"
return 1 #error
else
echo "no"
return 1 #error
fi
fi
fi
if [ -n "$xpkgverx" ] ; then
echo "yes [${xpkgverx}]"
else
echo "yes"
fi
return 0 #ok
}
w_compile_c_code() # $1:code $2:extra-CFLAGS $3:extra-LDFLAGS
{
if [ -z "$1" ] ; then
exit_error 'w_compile: code to compile is an empty string'
fi
conftest=.wxconftest$$
printf "$1" > ${conftest}.c
printf "\n$1" >> config.log
echo "$CC $CFLAGS ${2} ${conftest}.c -o ${conftest}.o $LDFLAGS ${3}" >>config.log
$CC $CFLAGS ${2} ${conftest}.c -o ${conftest}.o $LDFLAGS ${3} 2>>config.log
zzzzretxx=$?
rm -f ${conftest}.c ${conftest}.o ${conftest}.exe
return ${zzzzretxx}
}
w_check_header_and_libs() # <header1> [header2..] [libs] is optional
{
xheaderx=$1
shift
xlibsx=$@
xretval=1
#--
include_headersw="#include <${xheaderx}>"
for header1 in "$@" ; do
case $header1 in
*.h) include_headersw="$include_headersw
#include <${header1}>"
shift
;;
*) xlibsx="$@" ; break ;;
esac
done
if [ -n "$xlibsx" ] ; then
printf "Checking for ${xheaderx} + ${xlibsx}... "
else
printf "Checking for ${xheaderx}... "
fi
ccode="#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
${include_headersw}
int main (int argc, char **argv) { return 0; }
"
w_compile_c_code "$ccode" "" "${xlibsx}"
if [ $? -eq 0 ] ; then
w_headers="$w_headers ${xheaderx}"
echo "yes"
xretval=0
else
echo "no"
xretval=1
fi
return ${xretval}
}
w_check_header_and_libs_required()
{
zzheaderzz=$1
if [ -z "$2" ] ; then
exit_error "w_check_header_and_libs_required: 2nd paramater <libs> is required"
fi
shift
zzlibszz=$@
w_check_header_and_libs ${zzheaderzz} ${zzlibszz}
if [ $? -eq 0 ] ; then
LIBS="$LIBS ${zzlibszz}"
else
exit_error "ERROR: ${zzheaderzz} + ${zzlibszz} is required"
fi
}
w_check_headers()
{
for zzheaderzz in $@
do
w_check_header_and_libs ${zzheaderzz}
done
}
w_check_headers_required()
{
for zzheaderzz in $@
do
w_check_header_and_libs ${zzheaderzz}
if [ $? -ne 0 ] ; then
exit_error "ERROR: ${zzheaderzz} is required"
fi
done
}
w_check_cflag()
{
printf "Checking if $1 is supported... "
c_code='int main (int argc, char **argv) { return 0; }'
w_compile_c_code "$ccode" ${1}
if [ $? -eq 0 ] ; then
echo "yes"
return 0
else
echo "no"
return 1
fi
}
w_check_command() # sets $wtmp_cmd
{
printf "Checking for $1... "
wtmp_cmd="$(check_command "$1")"
if [ -n "$wtmp_cmd" ] ; then
echo "$wtmp_cmd"
return 0
else
echo "no"
return 1
fi
}
w_check_commands()
{
for wcmdw in $@ ; do
w_check_command ${wcmdw}
done
}
w_check_commands_required()
{
for wcmdw in $@ ; do
w_check_command ${wcmdw}
if [ $? -ne 0 ] ; then
exit_error "ERROR: $wcmdw is required"
fi
done
}
w_check_command_find_first() # sets $wtmp_cmd
{
wtmp_cmd=''
for wcmdw in $@
do
w_check_command ${wcmdw}
if [ $? -eq 0 ] ; then
return
fi
done
wtmp_cmd=''
return 1
}
w_prefer_gnu_make() # param: require
{
printf "Checking for GNU make... "
if [ -n "$MAKE" ] && "$MAKE" --version 1>/dev/null 2>&1 ; then
echo "$MAKE (environment)"
W_GNU_MAKE="MAKE=$MAKE"
elif make --version 1>/dev/null 2>&1 ; then
echo "make"
W_GNU_MAKE='MAKE=make'
elif gmake --version 1>/dev/null 2>&1 ; then
echo "gmake"
W_GNU_MAKE='MAKE=gmake'
else
echo "no"
if [ -n "$1" ] ; then
exit_error "ERROR: GNU make is required"
fi
fi
}
w_require_gnu_make()
{
w_prefer_gnu_make require
}
generate_pkgconfig()
{
(
unset name description version libs cflags filebase
unset requires requires_private libraries libraries_private
for i in "$@" ; do
case "$i" in
*=*)
field=$(echo "$i" | cut -f 1 -d '=')
value=$(echo "$i" | cut -f 2 -d '=')
eval ${field}='${value}'
;;
*) echo "generate_pkgconfig: $i: invalid parameter"
return -1 ;;
esac
done
if [ -z "$filebase" ] ; then
echo "generate_pkgconfig: filebase was not especified"
return -1
fi
if [ -z "$name" ] ; then
name="$filebase"
fi
if [ -z "$version" ] ; then
version="$VERSION"
fi
echo 'prefix='${prefix}'
exec_prefix=${prefix}
libdir='${libdir}'
includedir='${includedir}'
Name: '${name}'
Description: '${description}'
Version: '${version}'' > ${filebase}.pc
if [ -n "${requires}" ] ; then
echo "Requires: ${requires}" >> ${filebase}.pc
fi
if [ -n "${requires_private}" ] ; then
echo "Requires.private: ${requires_private}" >> ${filebase}.pc
fi
if [ -n "${libraries}" ] ; then
echo 'Libs: -L${libdir} '${libraries}'' >> ${filebase}.pc
fi
if [ -n "${libraries_private}" ] ; then
echo "Libs.private: ${libraries_private}" >> ${filebase}.pc
fi
echo 'Cflags: -I${includedir} '${cflags}'' >> ${filebase}.pc
)
if [ $? -ne 0 ] ; then
exit 1
fi
}
w_add_to_list_var() # <VAR> <newitem>
{
zcurlist=$(eval echo \$${1})
for zzitem in ${zcurlist} ; do
if [ "$2" = "$zzitem" ] ; then
return
fi
done
eval "${1}='$zcurlist $2'"
}
w_add_config_h_have()
{
for zzhave in ${config_h_have} ; do
if [ "$1" = "$zzhave" ] ; then
return
fi
done
config_h_have="$config_h_have $1"
}
w_add_config_mk_flags()
{
for zzmkh in ${config_mk_flags} ; do
if [ "$1" = "$zzmkh" ] ; then
return
fi
done
config_mk_flags="$config_mk_flags $1"
}
set_env_flags() # PREFIX [libs] [cflags]
{
eval ${1}_LIBS='${2}'
eval ${1}_CFLAGS='${3}'
eval ${1}_FOUND=1
w_add_config_h_have ${1}
w_add_config_mk_flags ${1}
}
find_pkgconfig()
{
unset WLAST_PC WLAST_LIBS WLAST_CFLAGS
unset fenv fpc fminver frequired
frequired='true'
for zzarg in "$@" ; do
case "$zzarg" in
env=*) fenv=$(getvalue "$zzarg") ;;
pc=*) fpc=$(getvalue "$zzarg") ;;
minver=*) fminver=$(getvalue "$zzarg") ;;
required=*) frequired=$(getvalue "$zzarg") ;;
esac
done
if [ -z "$fenv" ] || [ -z "$fpc" ] ; then
echo "syntax: find_pkgconfig env=PREFIX pc=pcfiles [minver=minver required=false]"
exit 1
fi
for zzzpc in ${fpc} ; do
if w_pkgconfig_check ${zzzpc} ${fminver} ; then
WLAST_PC=${zzzpc}
break
fi
done
if [ -z "$WLAST_PC" ] ; then
if [ "$frequired" = "true" ] ; then
echo "* $fpc is required"
exit 1
fi
return -1
fi
WLAST_LIBS="$(run_pkg_config ${WLAST_PC} --libs 2>/dev/null)"
WLAST_CFLAGS="$(run_pkg_config ${WLAST_PC} --cflags 2>/dev/null)"
set_env_flags "${fenv}" "${WLAST_LIBS}" "${WLAST_CFLAGS}"
eval ${fenv}_PC='${WLAST_PC}'
}
find_customconfig() # env config1 [config2...]
{
unset fenv WLAST_CONFIG WLAST_LIBS WLAST_CFLAGS
fenv="$1"
shift
printf "Checking for $fenv... "
WLAST_CONFIG="$(check_command "$@")"
if [ -n "$WLAST_CONFIG" ] ; then
echo "yes [$WLAST_CONFIG]"
WLAST_CFLAGS="$(${WLAST_CONFIG} --cflags 2>/dev/null)"
WLAST_LIBS="$(${WLAST_CONFIG} --libs 2>/dev/null)"
set_env_flags "${fenv}" "${WLAST_LIBS}" "${WLAST_CFLAGS}"
return 0
else
echo "no"
return -1
fi
}
find_lib()
{
unset fenv flibs fheaders frequired
frequired='true'
for zzarg in "$@" ; do
case "$zzarg" in
env=*) fenv=$(getvalue "$zzarg") ;;
libs=*) flibs=$(getvalue "$zzarg") ;;
headers=*) fheaders=$(getvalue "$zzarg") ;;
required=*) frequired=$(getvalue "$zzarg") ;;
esac
done
if [ -z "$fenv" ] || [ -z "$flibs" ] || [ -z "$fheaders" ] ; then
echo "syntax: find_lib env=PREFIX libs=-lib headers=lib.h [required=false]"
exit 1
fi
w_check_header_and_libs ${fheaders} ${flibs}
if [ $? -eq 0 ] ; then
set_env_flags ${fenv} "$flibs" ""
else
if [ "$frequired" = "true" ] ; then
echo "* $fenv is required"
exit_error
fi
fi
}
#==========================================================
#test "$CC" || CC='cc'
#test "$CXX" || CXX='c++'
test "$STRIP" || STRIP='strip'
test "$AR" || AR='ar'
test "$AS" || AS='as'
test "$NM" || NM='nm'
test "$RANLIB" || RANLIB='ranlib'
test "$OBJCOPY" || OBJCOPY='objcopy'
test "$OBJDUMP" || OBJDUMP='objdump'
# mingw
test "$DLLTOOL" || DLLTOOL='dlltool'
test "$WINDRES" || WINDRES='windres'
test "$WINDMC" || WINDMC='windmc'
prefix=/usr/local
exec_prefix='${prefix}'
libdir='${exec_prefix}/lib'
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
includedir='${prefix}/include'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
localstatedir='${prefix}/var'
sysconfdir='${prefix}/etc'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
mandir='${datarootdir}/man'
localedir='${datarootdir}/locale'
runstatedir='${localstatedir}/run'
top_builddir="${WCONF_SCRIPTDIR}"
top_srcdir="${WCONF_SCRIPTDIR}"
builddir=.
srcdir=.
#==========================================================
help()
{
echo "
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[${prefix}]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[${exec_prefix}]
By default, 'make install' will install all the files in
'/usr/local/bin', '/usr/local/lib' etc. You can specify
an installation prefix other than '/usr/local' using '--prefix',
for instance '--prefix=\$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [${bindir}]
--sbindir=DIR system admin executables [${sbindir}]
--libexecdir=DIR program executables [${libexecdir}]
--sysconfdir=DIR read-only single-machine data [${sysconfdir}]
--localstatedir=DIR modifiable single-machine data [${localstatedir}]
--runstatedir=DIR modifiable per-process data [${runstatedir}]
--libdir=DIR object code libraries [${libdir}]
--includedir=DIR C header files [${includedir}]
--datarootdir=DIR read-only arch.-independent data root [${datarootdir}]
--datadir=DIR read-only architecture-independent data [${datadir}]
--infodir=DIR info documentation [${infodir}]
--localedir=DIR locale-dependent data [${localedir}]
--mandir=DIR man documentation [${mandir}]
--docdir=DIR documentation root [${docdir}]
Optional Features:
(Use --disable-FEATURE or --enable-FEATURE)
$(print_optional_features)
Optional Packages:
(Use --without-PACKAGE or --with-PACKAGE[=ARG] )
--with-sysroot[=DIR] Set DIR as the compiler's sysroot directory
for headers and libraries
$(print_optional_packages)
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
CXXFLAGS C++ compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
$(print_extra_env_variables)
Use these variables to override the choices made by 'configure' or to help
it to find libraries and programs with nonstandard names/locations.
"
exit
}
#==========================================================
print_optional_features()
{
for confx in ${w_opts_configure} ${extra_configure_opts}
do
opt_print_${confx}
done
if [ -n "${extra_configure_opts}" ] || [ -n "${w_opts_configure}" ] ; then
printf " \n"
fi
}
print_optional_packages()
{
for confx in ${extra_packages_opts}
do
opt_pkg_print_${confx}
done
printf " \n"
}
print_extra_env_variables()
{
for evar in ${extra_env_vars}
do
echo " ${evar}_CFLAGS compiler flags for ${evar}, overriding pkg-config"
echo " ${evar}_LIBS linker flags for ${evar}, overriding pkg-config"
done
}
#==========================================================
for i in "$@"
do
case $i in
--build=*) build="$(getvalue $i)" ;;
--host=*) host="$(getvalue $i)" ;;
CFLAGS=*) CFLAGS="$CFLAGS $(getvalue $i)" ;;
CPPFLAGS=*) CPPFLAGS="$CPPFLAGS $(getvalue $i)" ;;
LDFLAGS=*) LDFLAGS="$LDFLAGS $(getvalue $i)" ;;
LXXFLAGS=*) LXXFLAGS="$LXXFLAGS $(getvalue $i)" ;;
CXXFLAGS=*) CXXFLAGS="$CXXFLAGS $(getvalue $i)" ;;
LIBS=*) LIBS="$LIBS $(getvalue $i)" ;;
CC=*) CC="$(getvalue $i)" ;;
CXX=*) CXX="$(getvalue $i)" ;;
STRIP=*) STRIP="$(getvalue $i)" ;;
AR=*) AR="$(getvalue $i)" ;;
AS=*) AS="$(getvalue $i)" ;;
NM=*) NM="$(getvalue $i)" ;;
DLLTOOL=*) DLLTOOL="$(getvalue $i)" ;;
WINDRES=*) WINDRES="$(getvalue $i)" ;;
WINDMC=*) WINDMC="$(getvalue $i)" ;;
--prefix=*) prefix="$(getvalue $i)" ;;
--exec_prefix=*) exec_prefix="$(getvalue $i)" ;;
--libdir=*) libdir="$(getvalue $i)" ;;
--bindir=*) bindir="$(getvalue $i)" ;;
--sbindir=*) sbindir="$(getvalue $i)" ;;
--libexecdir=*) libexecdir="$(getvalue $i)" ;;
--includedir=*) includedi="$(getvalue $i)" ;;
--datarootdir=*) datarootdir="$(getvalue $i)" ;;
--datadir=*) datadir="$(getvalue $i)" ;;
--localstatedir=*) localstatedir="$(getvalue $i)" ;;
--sysconfdir=*) sysconfdir="$(getvalue $i)" ;;
--docdir=*) docdir="$(getvalue $i)" ;;
--infodir=*) infodir="$(getvalue $i)" ;;
--mandir=*) mandir="$(getvalue $i)" ;;
--localedir=*) localedir="$(getvalue $i)" ;;
--runstatedir=*) runstatedir="$(getvalue $i)" ;;
--with-sysroot=*) sysroot="$(getvalue $i)" ;;
--with-sysroot) sysroot='-print-sysroot' ;;
--without-sysroot) sysroot='' ;;
--enable-static-link) static_link=1 ;;
--disable-static-link) static_link= ;;
---*) exit_error "Invalid opt: $i" ;;
-h|--help) help ;;
esac
done
for confx in ${w_opts_configure} ${extra_configure_opts} ${extra_packages_opts}
do
opt_configure_${confx} "$@"
done
# ====================================================
echo
set_cc
set_cxx
set_w_pkg_config
OS_BUILD=$(uname -s)
OS_CROSS=''
OS_TARGET=''
MACHINE_CC=$($CC -dumpmachine 2>/dev/null)
if [ -z "$build" ] ; then
build=${MACHINE_CC}
fi
if [ -n "$host" ] ; then
if [ "$host" = "$build" ] ; then
host=
fi
fi
if [ -n "$host" ] ; then
printf "Checking cross-compiler... "
CROSS_IS_FULL_PATH=''
CROSS_BASE_DIR=''
OS_CROSS="$host"
case $host in /*)
CROSS_IS_FULL_PATH=1
CROSS_BASE_DIR="$(dirname $host)/"
OS_CROSS="$(basename $host)"
;;
esac
cross_base_dir=''
w_c_cross_ok=$(check_command ${host}-cc ${host}-gcc ${host}-clang)
w_cpp_cross_ok=
if [ -n "$w_c_cross_ok" ] ; then
CC="$w_c_cross_ok";
fi
#--
if [ "$PROJECT_TYPE" = "C++" ] ; then
w_cpp_cross_ok=$(check_command ${host}-c++ ${host}-g++ ${host}-clang++)
if [ "$w_cpp_cross_ok" ] ; then
CXX="$w_cpp_cross_ok";
fi
else
w_cpp_cross_ok=1
CXX=${CROSS_BASE_DIR}${host}-c++
fi
#--
if [ -n "$w_c_cross_ok" ] && [ -n "$w_cpp_cross_ok" ]; then
LD=${CROSS_BASE_DIR}${host}-${LD}
STRIP=${CROSS_BASE_DIR}${host}-${STRIP}
AR=${CROSS_BASE_DIR}${host}-${AR}
AS=${CROSS_BASE_DIR}${host}-${AS}
NM=${CROSS_BASE_DIR}${host}-${NM}
RANLIB=${CROSS_BASE_DIR}${host}-${RANLIB}
OBJCOPY=${CROSS_BASE_DIR}${host}-${OBJCOPY}
OBJDUMP=${CROSS_BASE_DIR}${host}-${OBJDUMP}
#--
DLLTOOL=${CROSS_BASE_DIR}${host}-${DLLTOOL}
WINDRES=${CROSS_BASE_DIR}${host}-${WINDRES}
WINDMC=${CROSS_BASE_DIR}${host}-${WINDMC}
#--
echo "$host"
else
exit_error "not found"
fi
if [ -z "$CROSS_IS_FULL_PATH" ] ; then
# cross compiler is not a full path
CC="$(basename $CC)"
if [ -n "$CXX" ] ; then
CXX="$(basename $CXX)"
fi
fi
fi
if [ -n "$static_link" ] ; then
CC="$CC -static"
CXX="$CXX -static"
fi
if [ -n "${sysroot}" ] ; then
if [ "${sysroot}" = "-print-sysroot" ] ; then
sysroot="$($CC -print-sysroot)"
if [ -z "$sysroot" ] ; then
exit_error "--with-sysroot ERROR: compiler doesn't support -print-sysroot"
fi
fi
if ! [ -d "$sysroot" ] ; then
exit_error "--with-sysroot ERROR: $sysroot is not a directory"
fi
CC="$CC --sysroot=${sysroot}"
CXX="$CXX --sysroot=${sysroot}"
if [ -n "$W_SYSROOT_EXTRA" ] ; then
if [ -d ${sysroot}/include ] ; then
CFLAGS="-I${sysroot}/include $CFLAGS"
CXXFLAGS="-I${sysroot}/include $CXXFLAGS"
fi
if [ -d ${sysroot}/lib ] ; then
LDFLAGS="-L${sysroot}/lib $LDFLAGS"
LXXFLAGS="-L${sysroot}/lib $LXXFLAGS"
fi
fi
fi
#==========================================================
EXE=''
case ${OS_BUILD} in
CYGWIN*) OS_BUILD="Cygwin" ; EXE='.exe' ;;
MINGW*|MSYS*) OS_BUILD="MinGW" ; EXE='.exe' ;;
UWIN*|Windows*)OS_BUILD="MinGW" ; EXE='.exe' ;;
MS-DOS*) OS_BUILD="MSDOS" ; EXE='.exe' ;;
esac
OS_TARGET=${OS_BUILD}
if [ -n "$OS_CROSS" ] ; then
# cross-compiling, reset OS_TARGET
EXE=''
OS_TARGET=''