-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·2546 lines (2246 loc) · 73.3 KB
/
Copy pathconfigure
File metadata and controls
executable file
·2546 lines (2246 loc) · 73.3 KB
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/bash
#
# configure -- Build configuration script for Embedthis Products
#
# Copyright (c) Embedthis Software LLC, 2003-2011. All Rights Reserved.
#
# This script creates the buildConfig.h, buildConfig.make and buildConfig.sh
# configuration files. buildConfig.h is included in every C/C++ source file,
# buildConfig.make is included by all makefiles and buildConfig.sh is included
# by the bld program and some other scripts.
#
# The initial default settings are derrived from configuration files in the build directory.
#
###############################################################################
unset CDPATH
# export CYGWIN=nodosfilewarning
#
# Prefix for configuration files generated by configure
#
CONFIG_ARGS=.buildConfig.args
CONFIG_SH=build/bin/buildConfig.sh
CONFIG_MAKE=./buildConfig.make
if [ -d src/include ] ; then
CONFIG_H=src/include/buildConfig.h
else
CONFIG_H=buildConfig.h
fi
#
# This programs version
#
CONFIGURE_VERSION=4.2.1
#
# Default settings
#
BLD_DEFAULTS=standard
#
# O/S has cygpath (Windows)
#
HAS_CYGPATH=0
#
# Product name to configure
#
PRODUCT=
#
# Flags prefixes
#
FLAGS="C D I LD J CPP"
#
# Set preferred make
#
if which gnumake >/dev/null 2>&1 ; then
MAKE=`which gnumake`
elif which gmake >/dev/null 2>&1 ; then
MAKE=`which gmake`
else
MAKE=make
fi
###############################################################################
#
# Check the software installation and O/S
#
checkSetup() {
#
# Windows path conversion utility
#
type -p cygpath >/dev/null 2>&1
if [ $? = 0 ] ; then
HAS_CYGPATH=1
else
HAS_CYGPATH=0
fi
#
# Ensure we can write to key directories
#
for d in . build build/bin bin obj lib
do
if [ ! -d $d ] ; then
echo "Missing required directory \"$d\"" 1>&2
echo "Create this directory and retry" 1>&2
exit 255
fi
echo 2>/dev/null >$d/.test
if [ $? != 0 ] ; then
echo "Can't write to $d" 1>&2
echo "You do not have write permission for the $d directory." 1>&2
echo "Log in as root or modify the permissions of this directory" 1>&2
echo "and all its files." 1>&2
exit 255
fi
rm -f $d/.test
done
if [ ! -f ./configure -o ! -d build ] ; then
echo "configure: You must be in the top source directory." 1>&2
exit 255
fi
#
# Convert paths to be absolute with a drive spec on windows
#
BLD_TOP=`canonPath .`
BLD_TOOLS_DIR=${BLD_TOP}/build/bin
#
# Sleuth the product. By convention products put a configure.PRODUCT file under the build directory.
#
PRODUCT_LIST=`echo build/configure.* | sed 's/[^. ]*\.//g'`
if [ "${PRODUCT_LIST%\*}" != "${PRODUCT_LIST}" ] ; then
echo "Can't find required file: build/configure.*" 1>&2
echo "Install this file and retry." 1>&2
exit 255
fi
if [ -d ../packages ] ; then
rm -f extensions
ln -s ../packages extensions
fi
}
#
# Link a file. If that fails, copy.
#
linkFile()
{
source=$1
dir=`dirname $2`
base=`basename $2`
rm -f $2
if [ "$base" != "$2" ] ; then
source=`echo $source | sed -e "s^${dir}/^^"`
fi
ln -s $source $2 2>/dev/null
if [ $? != 0 ] ; then
cp $1 $2
fi
}
setSystemConfiguration() {
[ "$BLD_HOST_SYSTEM" = "" ] && BLD_HOST_SYSTEM=`bash build/bin/config.guess`
[ "$BLD_BUILD_SYSTEM" = "" ] && BLD_BUILD_SYSTEM=`bash build/bin/config.guess`
parseSystemConfiguration HOST
parseSystemConfiguration BUILD
if [ "${BLD_HOST_SYSTEM}" != "${BLD_BUILD_SYSTEM}" ] ; then
BLD_CROSS=1
BLD_HOST_DIST=Unknown
BLD_HOST_DIST_VER=Unknown
else
BLD_CROSS=0
fi
}
#
# Parse the system configuration. This is called for the host and build configurations.
#
parseSystemConfiguration() {
local cpu dist os rel system version unused value prefix
#
# Parse the host system configuration
#
kind=$1
parseSystem BLD_${kind}_SYSTEM $system BLD_${kind}_CPU unused BLD_${kind}_OS
eval os=\$BLD_${kind}_OS
case $os in
WIN|WINCE)
eval BLD_${kind}_UNIX=0
eval BLD_${kind}_WIN=1
;;
CYGWIN)
eval BLD_${kind}_UNIX=1
eval BLD_${kind}_WIN=0
;;
FREEBSD)
eval BLD_${kind}_UNIX=1
eval BLD_${kind}_WIN=0
;;
LINUX)
eval BLD_${kind}_UNIX=1
eval BLD_${kind}_WIN=0
;;
SOLARIS*)
eval BLD_${kind}_UNIX=1
eval ${os}=SOLARIS
eval BLD_${kind}_WIN=0
;;
MACOSX)
eval BLD_${kind}_UNIX=1
eval BLD_${kind}_WIN=0
;;
VXWORKS)
eval BLD_${kind}_UNIX=0
eval BLD_${kind}_WIN=0
;;
*)
eval BLD_${kind}_UNIX=0
eval BLD_${kind}_WIN=0
;;
esac
#
# Determine the CPU family
#
eval cpu=\$BLD_${kind}_CPU
case ${cpu} in
amd64)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_IX64
prefix=amd64
;;
arm*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_ARM
prefix=arm
;;
i?86*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_IX86
prefix="i?86"
;;
m68k**)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_68K
prefix=m68k
;;
mips*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_MIPS
prefix=mips
;;
powerpc*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_PPC
eval BLD_${kind}_CPU=ppc
cpu=ppc
prefix=ppc
;;
ppc*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_PPC
prefix=ppc
;;
sparc*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SPARC
prefix=sparc
;;
strongarm*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_ARM
prefix=strongarm
;;
x86_64*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_IX64
prefix=x86_64
;;
x86*|i?86*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_IX86
;;
xscale*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_XSCALE
prefix=xscale
;;
sim)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SIMNT
prefix=sim
;;
simnt)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SIMNT
prefix=simnt
;;
simsparc)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SIMSPARC
prefix=simsparc
;;
sh*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SH4
prefix=sh
;;
universal)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_UNIVERSAL
prefix=universal
;;
xscale*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_ARM
prefix="xscale"
;;
*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_UNKNOWN
echo "configure: CPU architecture unknown. Porting $BLD_PRODUCT is required. " 1>&2
exit 2
;;
esac
eval value=\$BLD_${kind}_CPU
eval BLD_${kind}_CPU_MODEL=`echo $value | sed s/$prefix//`
#
# Determine the O/S distribution. This is quite a bit of spelunking.
#
# /etc/debian_version
# /etc/redhat-release
# /etc/fedora-release
# /etc/gentoo-release
# /etc/SuSE-release
# /etc/slackware-release, /etc/slackware-version
# /etc/debian-release, /etc/debian-version
# /etc/release # Solars
# /etc/yellowdog-release
# /etc/mandrake-release
dist="unspecified"
version="unspecified"
if [ $os = WIN -o $os = CYGWIN ] ; then
# Microsoft Windows XP [Version 5.1.2600]
# Microsoft Windows [Version 6.0.6000]
rel=`cmd /c ver | tail -1`
version=`echo $rel | sed 's/.*Version //;s/]//' | awk '{ print $1 }'`
version=${version%%.*}
# if [ "$version" = 6 ] ; then
# dist=vista
# elif [ "$version" = 5 ] ; then
# dist=xp
# fi
dist=MS
elif [ $os = LINUX ] ; then
if [ -f /etc/redhat-release ] ; then
case `cat /etc/redhat-release` in
Fedora*)
# Fedora Core release 4 (Stentz)
# Fedora Core release 6 (Zod)
# Fedora Core release 5.9 (FC6 Test3)
version=`cat /etc/redhat-release | awk '{ print $4 }'`
dist="fedora"
;;
"Red Hat Linux"*)
# Red Hat Linux release 9 (Shrike)
version=`cat /etc/redhat-release | awk '{ print $5 }'`
dist="rhl"
;;
"Red Hat Enterprise"*)
# Red Hat Enterprise Linux ES release 3 (Taroon Update 7)
# Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
version=`cat /etc/redhat-release | awk '{ print $7 }'`
dist="rhel"
;;
esac
fi
if [ -f /etc/SuSE-release ] ; then
dist=suse
version=`cat /etc/SuSE-release | head -1 | awk '{ print $2 }'`
fi
if [ -f /etc/gentoo-release ] ; then
dist=suse
version=`cat /etc/gentoo-release | head -1 | awk '{ print $5 }'`
fi
if [ -f /etc/debian_version ] ; then
if [ -f /etc/issue ] ; then
cat /etc/issue | grep -i ubuntu >/dev/null 2>&1
if [ $? = 0 ] ; then
dist=ubuntu
else
dist=debian
fi
fi
if [ -f /etc/lsb-release ] ; then
version=`cat /etc/lsb-release | grep RELEASE | sed 's/.*=//'`
elif [ -f /etc/issue ] ; then
version=`cat /etc/issue | awk '{ print $2 }'`
fi
fi
elif [ $os = MACOSX ] ; then
version=`sw_vers | grep ProductVersion | awk '{ print $2 }'`
dist="Apple"
elif [ $os = VXWORKS ] ; then
dist="vxworks"
elif [ $os = WINCE ] ; then
dist="wince"
fi
eval BLD_${kind}_DIST=\"${dist}\"
eval BLD_${kind}_DIST_VER=\"`echo ${version}`\"
}
#
# Parse any user defined environment variables
#
parseEnvVars() {
[ $quiet = 0 ] && echo -e " # Parse environment variables ..."
#
# If the user is overriding CC but doesn't set CXX, set it to the same
#
if [ "$CC" != "" -a "$CXX" = "" ] ; then
CXX="$CC"
fi
if [ "$LD" != "" -a "$LDXX" = "" ] ; then
LDXX="$CC"
fi
if [ -f "${BLD_TOP}/.embedthis" ] ; then
BLD_EMBEDTHIS=1
else
BLD_EMBEDTHIS=0
fi
#
# Set default tool value if corresponding environment variable is defined
#
for t in ANT AR BREW CC DOXYGEN CXX JAVAC JDK JAR LD LDXX MT MUNCH NM RANLIB RC STRIP
do
eval value="\$${t}"
if [ "$value" != "" ] ; then
if [ $BLD_CROSS = 1 ] ; then
eval BLD_HOST_${t}=\"$value\"
eval CFG_HOST_${t}=\"$value\"
else
eval BLD_BUILD_${t}=\"$value\"
eval CFG_BUILD_${t}=\"$value\"
fi
fi
done
for t in AR CC CXX LD LDXX MT NM RANLIB RC STRIP
do
eval value="\$BUILD_${t}"
if [ "$value" != "" ] ; then
eval BLD_BUILD_${t}=\"$value\"
eval CFG_BUILD_${t}=\"$value\"
fi
done
for t in $FLAGS
do
eval value="\$BUILD_${t}FLAGS"
if [ "$value" != "" ] ; then
eval BLD_BUILD_${t}FLAGS=\"$value\"
fi
eval value="\$${t}FLAGS"
if [ "$value" != "" ] ; then
eval BLD_HOST_${t}FLAGS=\"$value\"
if [ "${BLD_HOST_SYSTEM}" = "${BLD_BUILD_SYSTEM}" ] ; then
eval BLD_BUILD_${t}FLAGS=\"$value\"
fi
fi
done
if [ "$BLD_BUILD_CPPFLAGS" != "" ] ; then
BLD_BUILD_DFLAGS="$BLD_BUILD_CPPFLAGS $BLD_BUILD_DFLAGS"
BLD_BUILD_CPPFLAGS=
fi
if [ "$BLD_HOST_CPPFLAGS" != "" ] ; then
BLD_HOST_DFLAGS="$BLD_HOST_CPPFLAGS $BLD_HOST_DFLAGS"
BLD_HOST_CPPFLAGS=
fi
}
#
# Usage: parseSystem in-system out-cpu out-vendor out-os
#
parseSystem() {
local system cpu vendor kernel os lowOS
eval system=\$${1}
cpu=${system%%-*}
vendor=${system##${cpu}-}
vendor=${vendor%%-*}
kernel=${system##${cpu}-${vendor}-}
os=${kernel##*-}
kernel=${kernel%%-*}
if [ "$kernel" != "" ] ; then
os=$kernel
fi
os=`upper $os`
case "${os}" in
CYGWIN*|WIN)
os=CYGWIN
if [ "$CL_FOUND" = 1 ] ; then
os=WIN
elif [ ! -x /bin/cc.exe -o "$BLD_CC_CYGWIN" != 1 ] ; then
BLD_BUILD_OS=WIN
[ $quiet = 0 ] && echo -e " # Search for MS compiler ..."
. build/search.config
search=`convertSearchPath "$BUILD_SEARCH_PATH"`:$PATH
if [ "`probe --partial cl --search "$search" cl`" != "" ] ; then
os=WIN
CL_FOUND=1
fi
fi
;;
VXWORKS*)
os=VXWORKS
;;
DARWIN*)
os=MACOSX
;;
FREEBSD*)
os=FREEBSD
;;
SOLARIS*)
os=SOLARIS
;;
WINCE)
os=WINCE
;;
esac
lowOS=`lower $os`
eval ${2}=$cpu
eval ${3}=$vendor
eval ${4}=$os
eval ${1}="${cpu}-${vendor}-${lowOS}"
[ "$verbose" -gt 2 ] && echo System set to "${cpu}-${vendor}-${lowOS}" >&2
}
#
# Convert a path to a canonical form: absolute (Windows: with drive spec)
#
canonPath() {
local path
path="$1"
if [ "$path" = "" ] ; then
echo "$path"
return
fi
if [ $HAS_CYGPATH = 1 ] ; then
#
# These conversions will ensure we get a drive spec and that we have
# forward slashes instead of back slashes
#
d=`cygpath -am "${path}"`
d=`cygpath -u "${d}"`
cygpath -am "${d}"
return
fi
if [ "${path##..}" != "${path}" ] ; then
cd .. ; echo `pwd`${path##..} ; cd - >/dev/null 2>&1
elif [ "${path##.}" != "${path}" ] ; then
echo `pwd`${path##.}
elif [ "${path##/}" != "${path}" ] ; then
# Absolute
echo "$path"
else
# Relative
echo `pwd`/${path#/}
fi
}
#
# Convert a path to be relative to $BLD_TOP. Used because gnu make on windows can't handle drive specs in dependencies.
#
relativePath() {
local base home dir i d c oldd parents
local count ccount seg commonDir commonLevels
home="$PWD"
dir="$1"
if [ "BLD_HOST_OS" = "WIN" -o "$BLD_HOST_OS" = "WINCE" ] ; then
dir=`canonPath "$dir" | tr '[A-Z]' '[a-z]'`
cwd=`canonPath "$PWD" | tr '[A-Z]' '[a-z]'`
else
dir=`canonPath "$dir"`
cwd=`canonPath "$PWD"`
fi
if [ "$dir" = "$cwd" ] ; then
echo "\${BLD_TOP}"
return
fi
if [ "$dir" != "${dir/BLD_TOP/}" ] ; then
echo "$dir"
return
fi
#
# Find longest common dir portion
#
declare -a dseg
d="$dir"
i=0
while [ "$d" != "${d##*/}" ] ; do
seg=${d%%/*} # Extract first path segment
dseg[$i]="${seg}"
d=${d#*/} # Strip first path segment
i=$((i + 1))
done
dseg[$i]="${d}"
declare -a cseg
c="$cwd"
i=0
while [ "$c" != "${c##*/}" ] ; do
seg=${c%%/*} # Extract first path segment
cseg[$i]="${seg}"
c=${c#*/} # Strip first path segment
i=$((i + 1))
done
cseg[$i]="${c}"
count=${#dseg[*]}
ccount=${#cseg[*]}
if [ $count -gt $ccount ] ; then
count=$ccount
fi
if [ "${BLD_HOST_OS}" = "WIN" -o "$BLD_HOST_OS" = "WINCE" ] ; then
if [ "${dseg[0]}" != "${cseg[0]}" ] ; then
echo "Path ${dir} on different drive" 1>&2
echo "to the current drive" 1>&2
echo "This configuration is not supported. Aborting." 1>&2
exit 255
fi
fi
#
# Find common parent dirs
#
commonDir=""
i=0
while [ $i -lt $count ] ; do
[ "${dseg[$i]}" != "${cseg[$i]}" ] && break
commonDir="$commonDir/${dseg[$i]}"
i=$((i + 1))
done
commonDir="${commonDir#/*}"
commonLevels=$i
#
# Find how many levels up to common parent for cwd
#
parents=""
i=$commonLevels
while [ $i -lt ${#cseg[*]} ] ; do
parents="../$parents"
i=$((i + 1))
done
base=`echo $dir | sed "s!^$commonDir!!"`
echo "\${BLD_TOP}/${parents}$base" | sed 's!\/\/!\/!g'
}
#
# Remove an old prefix from a path and prepend a new prefix
#
# remapDir dir oldPath newPath
#
remapDir() {
local dir oldPrefix newPrefix
dir="$1"
oldPrefix="$2"
newPrefix="$3"
if [ $HAS_CYGPATH = 1 ] ; then
dir=`cygpath -m "$dir"`
oldPrefix=`cygpath -m "$oldPrefix"`
newPrefix=`cygpath -m "$newPrefix"`
fi
if [ "${dir##$oldPrefix}" != "$dir" ] ; then
echo "${newPrefix}${dir##$oldPrefix}"
else
echo "${dir}"
fi
}
#
# Convert the search path into a normal PATH style with ":" separators
# On windows, this requires cygwin paths in searchPath.
#
convertSearchPath()
{
local x
if [ "$1" != "" ] ; then
[ "$verbose" -gt 2 ] && echo "ConvertPath expanding $1" 1>&2
echo $1 | sed "s/[ ]'/=/g" | tr "=" "\n" | sed "s/'//g" |
sed "s/[() ]/?/g" | grep -v '^$' | while read x
do
[ "$x" = "" ] && continue
if [ "$BLD_BUILD_OS" = WIN ] ; then
eval ls -d1 "$x" 2>/dev/null | sort | while read f
do
cygpath "$f"
done
else
eval ls -d1 "$x" 2>/dev/null | sort
fi
done | grep -v '^$' | tr '\n' : | sed 's/:$//'
fi
}
findComponents() {
local with build host mandatory name path upperName os
[ $quiet = 0 ] && echo -e " # Finding components ..."
for kind in BUILD HOST ; do
[ $quiet = 0 ] && echo -e " #\n # Search for `lower $kind` components"
eval SEARCH_PATH=\$${kind}_SEARCH_PATH
if [ "$verbose" -gt 0 ] ; then
echo -n -e "\nSearch for $kind components using $kind search path:\n "
echo $SEARCH_PATH | sed -e 's/:/ /g'
fi
for name in $BLD_COMPONENTS ; do
upperName=`upper ${name}`
eval with=\$CFG_${kind}_${upperName}_WITH
[ "$with" != 1 ] && continue
if [ ! -f "${BLD_TOP}/build/components/${name}" ] ; then
echo "Missing component file: build/components/$name"
continue
fi
eval BLD_UNIX_LIKE=\$BLD_${kind}_UNIX
eval BLD_WIN_LIKE=\$BLD_${kind}_WIN
[ "$verbose" -gt 0 ] && echo -e "\nSearch for component \"${name}\" using script \"build/components/${name}\""
. "${BLD_TOP}/build/components/${name}"
eval path="\$CFG_${kind}_${upperName}"
eval mandatory=\$CFG_${kind}_${upperName}_MANDATORY
[ "$BLD_DISABLE_ALL" = 1 -a $mandatory != 1 ] && continue
if [ "$verbose" = 0 ] ; then
[ $quiet = 0 ] && printf " # Scanning for %-12s" "${name}:"
fi
#
# Invoke the component definition function
#
unset MSG
eval os=\$BLD_${kind}_OS
OS=$os NAME=$name KIND=$kind defineComponent "$path"
# eval path="\$CFG_${kind}_${upperName}"
# if [ "$mandatory" = 1 -a "$path" = "" ] ; then
# eval realName=\$BLD_${kind}_${upperName}
# [ "$realName" != "" ] && name=$realName
# echo -e "\nconfigure: Can't find mandatory component: $name" 1>&2
# exit 255
# fi
#
# if [ "$path" != "" ] ; then
# eval ${kind}_COMPONENTS=\"\$${kind}_COMPONENTS ${name}\"
# [ $quiet = 0 -a $verbose = 0 ] && echo "$path"
# else
# if [ "$MSG" != "" ] ; then
# [ $quiet = 0 ] && echo $MSG
# else
# [ $quiet = 0 ] && echo "optional component not included"
# fi
# fi
done
[ $BLD_CROSS = 0 ] && break
done
[ "$verbose" -gt 0 ] && echo
}
warnComponent() {
local kind upper actual
kind=$KIND
name=$1
actual=$2
if [ "$actual" = "" ] ; then
actual="$name"
fi
upper=`upper ${name}`
eval mandatory="\$CFG_${kind}_${upper}_MANDATORY"
if [ "$mandatory" = 1 ] ; then
echo -e "\n\nCan't find required component: $name\n" >&2
echo -e "$*\n" >&2
exit 255
fi
if [ "$verbose" != 0 ] ; then
echo -e " optional component $name not included"
elif [ $quiet = 0 ] ; then
echo "optional component not included"
fi
}
#
# Return true if not builtin
#
isExternal() {
local path dir
dir=`canonPath "$PWD"`
path=`canonPath "$1"`
if [ "$path" != "." -a "$path" = "${path#$dir}" ] ; then
return 0
fi
return 1
}
#
# Configure a component. Called by build/components/*
#
configureComponent() {
local cflags dflags dependencies kind iflags imports jflags ldflags libpaths libs name upperDep new
local path withlibs withpaths upper builtin priorMandatory priorPath emitter disable optional extra
kind=$KIND
builtin=0
libpaths=
[ "$verbose" != 0 ] && echo -e " configureComponent $@"
while [ "${1#--}" != "$1" ] ; do
case ${1#--} in
builtin)
builtin=1
;;
cflags)
shift ; cflags="$1"
;;
dependencies)
shift ; dependencies="$1"
;;
dflags)
shift ; dflags="$1"
;;
disable)
shift ; disable="$1"
;;
emitter)
shift ; emitter="$1"
;;
iflags)
shift ; iflags="$1"
;;
imports)
shift ; imports="$1"
;;
jflags)
shift ; jflags="$1"
;;
ldflags)
shift ; ldflags="$1"
;;
libpaths)
shift ; libpaths=`canonPath "$1"`
;;
libs)
shift ; libs="$1"
;;
optional-dependencies)
shift ; optional="$1"
;;
path)
shift ; path="$1"
;;
withlibs)
shift ; withlibs="$1"
;;
withpaths)
shift ; withpaths=`canonPath "$1"`
;;
*)
;;
esac
shift
done
name=$1
if [ "$name" = "" ] ; then
echo "configureComponent: component missing name" 1>&2
exit 255
fi
if [ "$disable" != "" ] ; then
echo "configureComponent: component missing name" 1>&2
return 0
fi
if [ "$HAS_CYGPATH" = 1 ] ; then
local p1 cpwd
p1=`canonPath "$path"`
cpwd=`canonPath "$PWD"`
[ "$p1" != "${p1#$cpwd}" ] && builtin=1
else
[ "$path" != "${path#$PWD}" ] && builtin=1
fi
[ $BLD_CROSS = 0 ] && kind=BUILD
upper=`upper ${name}`
eval mandatory="\$CFG_${kind}_${upper}_MANDATORY"
eval priorPath="\$CFG_${upper}"
if [ "$priorPath" != "" ] ; then
path="$priorPath"
fi
eval unset CFG_${kind}_${upper}
for dep in $dependencies
do
upperDep=`upper ${dep}`
if [ "`compath $dep`" = "" ] ; then
if [ "$mandatory" = 1 ] ; then
echo "configureComponent: Missing dependency \"${dep}\" for mandatory component: ${name}" 1>&2
exit 255
fi
fi
done
if [ "$BLD_FEATURE_STATIC" = 1 ] ; then
for dep in $optional $dependencies
do
udep=`upper ${dep}`
eval present=\$CFG_${kind}_${udep}
if [ "$present" != "" ] ; then
eval extra=\$CFG_${kind}_${udep}_LIBPATHS
[ "$extra" != "" ] && libpaths="$libpaths $extra"
eval extra=\$CFG_${kind}_${udep}_LIBS
[ "$extra" != "" ] && libs="$libs $extra"
fi
done
else
for dep in $optional $dependencies
do
udep=`upper ${dep}`
eval present=\$CFG_${kind}_${udep}
if [ "$present" != "" ] ; then
eval extra=\$CFG_${kind}_${udep}_LIBPATHS
[ "$extra" != "" ] && libpaths="$libpaths $extra"
[ "$extra" != "" ] && withpaths="$withpaths $extra"
eval extra=\$CFG_${kind}_${udep}_LIBS
[ "$extra" != "" ] && libs="$libs $extra"
[ "$extra" != "" ] && withlibs="$withlibs $extra"
fi
done
fi
#
# Cleanup leading spaces
#
libs=${libs# *}
libpaths=${libpaths# *}
withlibs=${withlibs# *}
withpaths=${withpaths# *}
#
# Imports must be relative because they are used as targets
#
new=""
for i in $imports ; do
new="$new `relativePath "$i"`"
done
imports="$new"
#
# Don't make unique if static on Linux. ld does not rescan.