-
Notifications
You must be signed in to change notification settings - Fork 8
/
configure
executable file
·1096 lines (959 loc) · 24.8 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
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <http://unlicense.org/>
#
if ! [ -f Makefile ] ; then
echo 'Main Makefile is missing, cannot continue'
exit 1
fi
if ! cd $(dirname "$0") ; then
exit 1
fi
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=
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
extra_env_vars="$extra_env_vars $2"
fi
}
w_new_option_with()
{
extra_packages_opts="$extra_packages_opts $1"
w_opts_check="$w_opts_check $1"
}
if [ -f configure.project ] ; then
. ./configure.project
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" ] ; then
srcdir=$(pwd)
outdir=${PACKAGE}-${VERSION}
cd ..
rm -rf ${outdir}
if [ "$2" = "dist" ] ; then
# force creation of tarfile, copy the whole dir
shift
shift
cp -rf ${srcdir} ${outdir}
cd ${outdir}
git clean -dfx
rm -rf .*
cd ..
else
if command -v git >/dev/null; then
printf "Run 'git clean -dfx'? [y/N]: "
read anzwer
case $anzwer in y|Y)
cd ${srcdir}
echo '# git clean -dfx'
git clean -dfx
cd ..
;;
esac
fi
mkdir -p ${outdir}
cp -rf ${srcdir}/* ${outdir}/
fi
#--
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}
echo "# ${cmd} ${outdir}.tar"
if ${cmd} ${outdir}.tar ; then
echo "*** ${outdir}.tar.${comp} has been created..."
fi
rm -f ${outdir}.tar
exit
fi
# w_conf/gettext: ./configure po|pot
#==========================================================
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
}
check_command() # 1:<cmd> finds $1 in $PATH
{
if [ -z "$xxpath" ] ; then
xxpath="$(echo "$PATH" | tr ':' ' ')"
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"
if [ -n "$CC" ] ; then
zz_list="$CC"
else
zz_list="cc gcc clang"
fi
printf "Checking for C compiler... "
ZCC="$(check_command ${zz_list})"
if test -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... "
if [ -n "$CXX" ] ; then
zz_list="$CXX"
else
zz_list="c++ g++ clang++"
fi
ZXX="$(check_command ${zz_list})"
if test -z "$ZXX" ; then
if [ -z "$CXX" ] ; then
echo "not found" # not a fatal error
else
exit_error "$CXX not found"
fi
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=''
if [ -n "${PKG_CONFIG}" ] ; then
W_PKG_CONFIG="$(check_command ${PKG_CONFIG})"
if [ -n "$W_PKG_CONFIG" ] ; then
echo "$W_PKG_CONFIG (environment)"
return 0
fi
fi
W_PKG_CONFIG="$(check_command pkg-config pkgconf)"
if [ -n "$W_PKG_CONFIG" ] ; then
echo "$W_PKG_CONFIG [$($W_PKG_CONFIG --version 2>/dev/null)]"
else
echo "no"
echo "WARNING: missing pkg-config: this a potentially fatal error"
fi
}
run_pkg_config()
{
if [ -n "$static_link" ] ; then
pkgconfig_s='--static'
else
pkgconfig_s=''
fi
if test -n "$W_PKG_CONFIG" ; then
${W_PKG_CONFIG} ${pkgconfig_s} "$@"
else
pkg-config ${pkgconfig_s} "$@"
fi
}
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
fi
#--
if [ -n "$pc_pkg_min_ver" ] ; then
run_pkg_config ${pc_pkg} --exists --atleast-version=${pc_pkg_min_ver}
else
run_pkg_config ${pc_pkg} --exists
fi
xret=$?
if [ $xret -eq 0 ] ; then
echo "yes [$(run_pkg_config ${pc_pkg} --modversion)]"
else
if [ -n "$pc_pkg_min_ver" ] ; then
xxzzfound=$(run_pkg_config ${pc_pkg} --modversion 2>/dev/null)
if [ -n "$xxzzfound" ] ; then
echo "no [found $xxzzfound]"
else
echo "no"
fi
else
echo "no"
fi
fi
return $xret
}
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
return ${zzzzretxx}
}
w_check_header_and_libs() # 1:<header> 2-:[libs] is optional
{
xheaderx=$1
shift
xlibsx=$@
xretval=1
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 <${xheaderx}>
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
}
#==========================================================
#test "$CC" || CC='gcc'
#test "$CXX" || CXX='g++'
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'
static_link=''
# 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="$(pwd)"
top_srcdir="$(pwd)"
builddir=.
srcdir=.
print_eval_var()
{
zzvareval=
for i in $@ # perform up to 2 evals
do
zzvareval="$(eval echo $i)"
zzvareval="$(eval echo $zzvareval)"
done
echo "$zzvareval"
}
#==========================================================
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
test -n "${extra_configure_opts}" || \
test -n "${w_opts_configure}" && printf " \n"
}
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
}
#==========================================================
getvalue() {
echo $1 | cut -f 2 -d '='
}
for i in $@
do
case $i in
--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
if [ -n "$W_PKG_CONFIG_STATIC" ] ; then
static_link=1
fi
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=''
if test -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
#==========================================================
case ${OS_BUILD} in
CYGWIN*) OS_BUILD="Cygwin" ;;
MINGW*) OS_BUILD="MinGW" ;;
MSYS*) OS_BUILD="MinGW" ;;
esac
OS_TARGET=${OS_BUILD}
if [ -n "$OS_CROSS" ] ; then
# cross-compiling, reset OS_TARGET
OS_TARGET=''
# determine OS_TARGET again
case $OS_CROSS in
*-mingw*) OS_TARGET='MinGW' ;;
*-darwin*) OS_TARGET='Darwin' ;;
*-linux-*) OS_TARGET='Linux' ;;
*-freebsd*) OS_TARGET='FreeBSD' ;;
esac
fi
case $OS_TARGET in
Linux) SYSDEFINE='__linux__=1' ;;
MinGW) SYSDEFINE='__MINGW32__=1' ;;
FreeBSD) SYSDEFINE='__FreeBSD__=1' ;;
Darwub) SYSDEFINE='__APPLE__=1' ;;
esac
TARGET_OS="$OS_TARGET"
#==========================================================
CFLAGS="$CFLAGS $PROJECT_CFLAGS"
CPPFLAGS="$CPPFLAGS $PROJECT_CPPFLAGS"
CXXFLAGS="$CXXFLAGS $PROJECT_CXXFLAGS"
LDFLAGS="$LDFLAGS $PROJECT_LDFLAGS"
LXXFLAGS="$LXXFLAGS $PROJECT_LXXFLAGS"
LIBS="$LIBS $PROJECT_LIBS"
#==========================================================
echo > config.log
case $PROJECT_TYPE in
C) WCVERW=$($CC --version 2>>config.log) ;;
C++) WCVERW=$($CXX --version 2>>config.log) ;;
esac
echo "$WCVERW" >> config.log
if [ -n "$(echo "$WCVERW" | grep "Free Software Foundation")" ] ; then
printf "\n- GCC has been detected\n" >>config.log
GCC='yes'
fi
w_headers=''
#----------
w_main_func # main function where the user performs all sorts of tasks
#----------
# apps to check, see configure.project (XXX_CFLAGS, XXX_LIBS)
for appx in ${w_opts_check} ${apps_to_check}
do
opt_check_${appx}
done
# custom checks
for xcheckx in ${w_opts_after_check} ${w_custom_checks}
do
${xcheckx}
done
#==========================================================
# config.mk
#==========================================================
# ensure -DHAVE_CONFIG_H
CFLAGS="-DHAVE_CONFIG_H $CFLAGS "
CXXFLAGS="-DHAVE_CONFIG_H $CXXFLAGS"
cat > config.mk <<EOF
# generated by ./configure
${W_GNU_MAKE}
prefix = ${prefix}
exec_prefix = ${exec_prefix}
libdir = ${libdir}
bindir = ${bindir}
sbindir = ${sbindir}
libexecdir = ${libexecdir}
includedir = ${includedir}
datarootdir = ${datarootdir}
datadir = ${datadir}
localstatedir = ${localstatedir}
sysconfdir = ${sysconfdir}
docdir = ${docdir}
infodir = ${infodir}
mandir = ${mandir}
localedir = ${localedir}
runstatedir = ${runstatedir}
top_builddir = ${top_builddir}
top_srcdir = ${top_srcdir}
builddir = ${builddir}
srcdir = ${srcdir}
#=================================================
INSTALL = install -c
INSTALL_DATA = install -c -m 644
PACKAGE = ${PACKAGE}
VERSION = ${VERSION}
PACKAGE_URL = ${PACKAGE_URL}
PACKAGE_NAME = ${PACKAGE_NAME}
PACKAGE_STRING = ${PACKAGE_STRING}
PACKAGE_TARNAME = ${PACKAGE_TARNAME}
PACKAGE_BUGREPORT = ${PACKAGE_BUGREPORT}
PACKAGE_VERSION = ${PACKAGE_VERSION}
OS_BUILD = ${OS_BUILD}
OS_CROSS = ${OS_CROSS}
OS_TARGET = ${OS_TARGET}
TARGET_OS = ${TARGET_OS}
#=================================================
CC = ${CC}
CXX = ${CXX}
STRIP = ${STRIP}
AR = ${AR}
AS = ${AS}
NM = ${NM}
RANLIB = ${RANLIB}
OBJCOPY = ${OBJCOPY}
OBJDUMP = ${OBJDUMP}
DLLTOOL = ${DLLTOOL}
WINDRES = ${WINDRES}
WINDMC = ${WINDMC}
CFLAGS = ${CFLAGS}
CPPFLAGS = ${CPPFLAGS}
CXXFLAGS = ${CXXFLAGS}
LXXFLAGS = ${LXXFLAGS}
LDFLAGS = ${LDFLAGS}
LIBS = ${LIBS}
#=================================================
${SYSDEFINE}
${make_extra_flags}
${w_config_mk_extra_lines}
EOF
#==========================================================
# config.sh (=config.mk)
#==========================================================
cat > config.sh <<EOF
#generated by ./configure
prefix="${prefix}"
exec_prefix="${exec_prefix}"
libdir="${libdir}"
bindir="${bindir}"
sbindir="${sbindir}"
libexecdir="${libexecdir}"
includedir="${includedir}"
datarootdir="${datarootdir}"
datadir="${datadir}"
localstatedir="${localstatedir}"
sysconfdir="${sysconfdir}"
docdir="${docdir}"
infodir="${infodir}"
mandir="${mandir}"
localedir="${localedir}"
runstatedir="${runstatedir}"
top_builddir="${top_builddir}"
top_srcdir="${top_srcdir}"
builddir="${builddir}"
srcdir="${srcdir}"
#=================================================
INSTALL="install -c"
INSTALL_DATA="install -c -m 644"
PACKAGE="${PACKAGE}"
VERSION="${VERSION}"
PACKAGE_URL="${PACKAGE_URL}"
PACKAGE_NAME="${PACKAGE_NAME}"
PACKAGE_STRING="${PACKAGE_STRING}"
PACKAGE_TARNAME="${PACKAGE_TARNAME}"
PACKAGE_BUGREPORT="${PACKAGE_BUGREPORT}"
PACKAGE_VERSION="${PACKAGE_VERSION}"
OS_BUILD="${OS_BUILD}"
OS_CROSS="${OS_CROSS}"
OS_TARGET="${OS_TARGET}"
TARGET_OS="${TARGET_OS}"
#=================================================
CC="${CC}"
CXX="${CXX}"
STRIP="${STRIP}"
AR="${AR}"
AS="${AS}"
NM="${NM}"
RANLIB="${RANLIB}"
OBJCOPY="${OBJCOPY}"
OBJDUMP="${OBJDUMP}"
DLLTOOL="${DLLTOOL}"
WINDRES="${WINDRES}"
WINDMC="${WINDMC}"
CFLAGS="${CFLAGS}"
CPPFLAGS="${CPPFLAGS}"
CXXFLAGS="${CXXFLAGS}"
LXXFLAGS="${LXXFLAGS}"
LDFLAGS="${LDFLAGS}"
LIBS="${LIBS}"
#=================================================
${SYSDEFINE}
${config_sh_extra}
EOF