-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure
1370 lines (1282 loc) · 47 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/bash
#
# Deemon Configure file
#
shopt -s extglob
BLD_ROOT="$(readlink -f "$(pwd)")"
SRC_ROOT="$(dirname "$(readlink -f "$0")")"
BIN_PATH=""
BLD_PATH=""
CONFIG_CROSS_PREFIX=""
CONFIG_CC=""
CONFIG_CXX=""
CONFIG_EXE=""
CONFIG_DLL=""
CONFIG_CFLAGS=""
CONFIG_LDFLAGS=""
CONFIG_LIBS=""
CONFIG_LIBM=""
CONFIG_LIBDL=""
CONFIG_LIBSOCKET=""
CONFIG_DEX_CC=""
CONFIG_DEX_CFLAGS="-shared"
CONFIG_DEX_LDFLAGS="-shared"
CONFIG_DEX_LIBS=""
CONFIG_DEX_CTYPES_CC=""
CONFIG_DEX_CTYPES_CFLAGS=""
CONFIG_DEX_CTYPES_LDFLAGS=""
CONFIG_DEX_CTYPES_LIBS=""
CONFIG_CORE_CFLAGS=""
CONFIG_CORE_LDFLAGS=""
CONFIG_CORE_LIBS=""
LIBFFI_TARGET=""
TARGET=""
TARGET_IS_AUTO=""
TARGET_CPU=""
FEATURES=""
WITH_ASSEMBLY_INTERPRETER=""
WITH_DEX=""
WITHOUT_DEX_SPECIFIC=""
WITH_DEBUG=""
WITH_THREADS=""
WITH_LIBFFI=""
WITH_SYSTEM_LIBFFI=""
WITH_OPTIMIZE=""
CONFIG_PTHREAD=""
WITH_KOS_SYSTEM_HEADERS=""
# del_feature(MACRO_NAME)
del_feature() {
FEATURES="$(for feat in $FEATURES; do
if [[ "$feat" != "$1" ]]; then
printf " $feat"
fi
done)"
if ! [ -z "$FEATURES" ]; then
FEATURES="${FEATURES:1}"
fi
}
# del_feature_startswith(MACRO_NAME_START)
del_feature_startswith() {
FEATURES="$(for feat in $FEATURES; do
if [[ "$feat" != "$1"* ]]; then
printf " $feat"
fi
done)"
if ! [ -z "$FEATURES" ]; then
FEATURES="${FEATURES:1}"
fi
}
# add_feature(MACRO_NAME)
add_feature() {
del_feature "$1"
FEATURES="$FEATURES $1"
}
# set_feature_pair(ON_MACRO_NAME, OFF_MACRO_NAME, STATE={0,1})
set_feature_pair() {
if [[ "$3" == "1" ]]; then
if ! [ -z "$2" ]; then del_feature "$2"; fi
if ! [ -z "$1" ]; then add_feature "$1"; fi
else
if ! [ -z "$1" ]; then del_feature "$1"; fi
if ! [ -z "$2" ]; then add_feature "$2"; fi
fi
}
# add_dex_specific(DEX_NAME)
add_dex_specific() {
WITHOUT_DEX_SPECIFIC="$(for name in $WITHOUT_DEX_SPECIFIC; do
if [[ "$name" != "$1" ]]; then
printf " $name"
fi
done)"
if ! [ -z "$WITHOUT_DEX_SPECIFIC" ]; then
WITHOUT_DEX_SPECIFIC="${WITHOUT_DEX_SPECIFIC:1}"
fi
}
# del_dex_specific(DEX_NAME)
del_dex_specific() {
del_feature "$1"
WITHOUT_DEX_SPECIFIC="$WITHOUT_DEX_SPECIFIC $1"
}
# set_dex_specific(DEX_NAME, STATE={0,1})
set_dex_specific() {
if [[ "$2" == "1" ]]; then
add_dex_specific "$1"
else
del_dex_specific "$1"
fi
}
set_with_feature() {
case "$1" in
assembly-interpreter) WITH_ASSEMBLY_INTERPRETER="$2" ;;
dex) WITH_DEX="$2" ;;
dex-ctypes) set_dex_specific "CTYPES" "$2" ;;
dex-net) set_dex_specific "NET" "$2" ;;
dex-posix) set_dex_specific "POSIX" "$2" ;;
dex-math) set_dex_specific "MATH" "$2" ;;
dex-ipc) set_dex_specific "IPC" "$2" ;;
dex-threading) set_dex_specific "THREADING" "$2" ;;
dex-time) set_dex_specific "TIME" "$2" ;;
dex-win32) set_dex_specific "WIN32" "$2" ;;
dex-json) set_dex_specific "JSON" "$2" ;;
kos-system-headers) WITH_KOS_SYSTEM_HEADERS="$2" ;;
debug) WITH_DEBUG="$2" ;;
optimize=*) WITH_OPTIMIZE="$(echo "$1" | cut -d '=' -f 2)" ;;
threads) WITH_THREADS="$2" ;;
libffi) WITH_LIBFFI="$2" ;;
system-libffi) WITH_SYSTEM_LIBFFI="$2" ;;
trace-refchanges) set_feature_pair "CONFIG_TRACE_REFCHANGES" "CONFIG_NO_TRACE_REFCHANGES" "$2" ;;
badrefcnt-checks) set_feature_pair "CONFIG_BADREFCNT_CHECKS" "CONFIG_NO_BADREFCNT_CHECKS" "$2" ;;
calltuple-optimizations) set_feature_pair "CONFIG_HAVE_CALLTUPLE_OPTIMIZATIONS" "CONFIG_NO_CALLTUPLE_OPTIMIZATIONS" "$2" ;;
object-slabs) set_feature_pair "" "CONFIG_NO_OBJECT_SLABS" "$2" ;;
nobase-optimized-class-operators) set_feature_pair "CONFIG_HAVE_NOBASE_OPTIMIZED_CLASS_OPERATORS" "CONFIG_NO_NOBASE_OPTIMIZED_CLASS_OPERATORS" "$2" ;;
deemon-home-environ)
set_feature_pair "" "CONFIG_NO_DEEMON_HOME_ENVIRON" "$2"
;;
deemon-home-environ=*)
del_feature "CONFIG_NO_DEEMON_HOME_ENVIRON"
del_feature_startswith "CONFIG_DEEMON_HOME_ENVIRON="
add_feature "CONFIG_DEEMON_HOME_ENVIRON=$(echo "$1" | cut -d '=' -f 2)"
;;
deemon-home=*)
del_feature_startswith "CONFIG_DEEMON_HOME="
add_feature "CONFIG_DEEMON_HOME=\"$(echo "$1" | cut -d '=' -f 2)\""
;;
deemon-path-environ)
set_feature_pair "" "CONFIG_NO_DEEMON_PATH_ENVIRON" "$2"
;;
deemon-path-environ=*)
del_feature "CONFIG_NO_DEEMON_PATH_ENVIRON"
del_feature_startswith "CONFIG_DEEMON_PATH_ENVIRON="
add_feature "CONFIG_DEEMON_PATH_ENVIRON=$(echo "$1" | cut -d '=' -f 2)"
;;
deemon-path=*)
del_feature_startswith "CONFIG_DEEMON_PATH="
local PATH_EXPR=""
# https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash
IFS=';' read -ra PATH_LIST <<< "$(echo "$1" | cut -d '=' -f 2)"
for p in "${PATH_LIST[@]}"; do
PATH_EXPR="${PATH_EXPR}p(\"${p}\")"
done
add_feature "CONFIG_DEEMON_PATH=(p)$PATH_EXPR"
;;
*)
echo "Unknown with-feature $1"
exit 1
;;
esac
}
print_help_features() {
echo "Features:"
echo " assembly-interpreter Make use of hand-optimized assembly for running deemon bytecode (default:yes, if available for the target)"
echo " dex Support native libraries as deemon extensions (default: yes)"
echo " dex-ctypes Provide the native deemon extension module: 'ctypes' (default: yes)"
echo " dex-net Provide the native deemon extension module: 'net' (default: yes)"
echo " dex-posix Provide the native deemon extension module: 'posix' (default: yes)"
echo " dex-math Provide the native deemon extension module: 'math' (default: yes)"
echo " dex-ipc Provide the native deemon extension module: 'ipc' (default: yes)"
echo " dex-threading Provide the native deemon extension module: 'threading' (default: yes)"
echo " dex-time Provide the native deemon extension module: 'time' (default: yes)"
echo " dex-win32 Provide the native deemon extension module: 'win32' (default: yes)"
echo " dex-json Provide the native deemon extension module: 'json' (default: yes)"
echo " kos-system-headers Use the deemon-provided copies of KOS's hybrid system headers (default: auto)"
echo " debug Include debug informations (default: yes)"
echo " optimize=* Additional compiler options for optimization (default: '-O2')"
echo " threads Multi-threading support (default: yes)"
echo " libffi Use libffi to allow ctypes to perform native function calls"
echo " system-libffi Use a system-provided libffi instead of our own, static one (default: no)"
echo ""
echo "Features controlling config options:"
echo " trace-refchanges [def:#if !0]"
echo " Trace the origins of all inc-/decref operations to aid in narrowing"
echo " down the origins of reference leaks (highly resource intensive)"
echo " When enabled, the refcnt-history of leaked objects is dumped during shutdown"
echo " with: --conf=CONFIG_TRACE_REFCHANGES"
echo " without: --conf=CONFIG_NO_TRACE_REFCHANGES"
echo ""
echo " badrefcnt-checks [def:#if !NDEBUG]"
echo " Perform runtime checking to guard against bad use of reference counters"
echo " with: --conf=CONFIG_BADREFCNT_CHECKS"
echo " without: --conf=CONFIG_NO_BADREFCNT_CHECKS"
echo ""
echo " calltuple-optimizations [def:#if !__OPTIMIZE_SIZE__]"
echo " Provide optimized code paths for function calls with packed arguments (e.g. 'foo(args...)')"
echo " with: --conf=CONFIG_CALLTUPLE_OPTIMIZATIONS"
echo " without: --conf=CONFIG_NO_CALLTUPLE_OPTIMIZATIONS"
echo ""
echo " object-slabs [def:#if <available-for-target>]"
echo " Use custom slab allocators allocating heap memory for objects"
echo " with: -"
echo " without: --conf=CONFIG_NO_OBJECT_SLABS"
echo ""
echo " nobase-optimized-class-operators"
echo " [def:#if !__OPTIMIZE_SIZE__]"
echo " Define optimized operators for user-classes without bases"
echo " with: --conf=CONFIG_NOBASE_OPTIMIZED_CLASS_OPERATORS"
echo " without: --conf=CONFIG_NO_NOBASE_OPTIMIZED_CLASS_OPERATORS"
echo ""
echo " deemon-home-environ [def:#if 1]"
echo " Enable/disable recognition of an environment variable to"
echo " override the deemon ~home~ location at runtime"
echo " with: -"
echo " without: --conf=CONFIG_NO_DEEMON_HOME_ENVIRON"
echo ""
echo " deemon-home-environ=* [def:DEEMON_HOME]"
echo " Set the name of the environment variable to check at runtime"
echo " in order to find library files (s.a. 'DeeExec_GetHome()')"
echo " with: --config=CONFIG_DEEMON_HOME_ENVIRON=*"
echo " without: -"
echo ""
echo " deemon-home=* [def:<determine-at-runtime>]"
echo " Specify the path where deemon is ~home~. By default, this"
echo " path is determined at runtime, and is the directory in which"
echo " the deemon core executable is located:"
echo " 'fs.headof(fs.readlink(\"/proc/self/exe\"))'"
echo " Note that when building for cygwin, this must be a windows-style path!"
echo " with: --config=CONFIG_DEEMON_HOME=*"
echo " without: -"
echo ""
echo " deemon-path-environ [def:#if 1]"
echo " Enable/disable recognition of an environment variable to"
echo " override the deemon library path location list at runtime"
echo " with: -"
echo " without: --conf=CONFIG_NO_DEEMON_PATH_ENVIRON"
echo ""
echo " deemon-path-environ=* [def:DEEMON_PATH]"
echo " Set the name of the environment variable to check at runtime"
echo " for specifying deemon system library paths. When not specified,"
echo " either use the override provided by '--with-deemon-path=*', or"
echo " default to '[ \"<DEEMON_HOME>/lib\" ]'"
echo " with: --config=CONFIG_DEEMON_PATH_ENVIRON=*"
echo " without: -"
echo ""
echo " deemon-path=* [def:<unset>]"
echo " Specify an override for recognized deemon system library locations"
echo " to be used when 'DEEMON_PATH' isn't set at runtime. This feature"
echo " takes a ;-seperated list of absolute paths that will be hard-coded"
echo " into the deemon core."
echo " with: --config=CONFIG_DEEMON_PATH=..."
echo " without: -"
}
print_help() {
echo "Usage: ./configure [Options...]"
echo "NOTE: This configure script will setup the caller's PWD as build root, allowing for out-of-source builds"
echo "Options (target):"
echo " --cross-prefix=* Compiler prefix when cross-compiling"
echo " --target=* Specify the target name (e.g. 'i386-kos', 'x86_64-linux-gnu' or 'x86_64-pc-cygwin')"
echo " When not specified, the target will be automatically determined through 'cc -v'"
echo " --libffi-target=* The target name to use for libffi (defaults to the same as --target)"
echo " --build-root=* The root directory where build files should be generated ($BLD_ROOT)"
echo " --source-root=* The directory where deemon source files are found ($SRC_ROOT)"
echo " --bin-path=* The path where the deemon core and its lib file should be placed"
echo " --build-path=* The path where object files should be placed"
echo "Options (extended build options):"
echo " --config-exe-extension=* File extension for executable files"
echo " --config-dll-extension=* File extension for shared library files"
echo " --config-cc=* Name of the C compiler to use"
echo " --config-cxx=* Name of the C++ compiler to use"
echo " --config-cflags=* Additional flags to pass to the compiler during compilation"
echo " --config-ldflags=* Additional flags to pass to the compiler during linking"
echo " --config-libs=* Additional libraries to include during linking"
echo " --config-libm=* Additional libraries to include to get access to <math.h> functions"
echo " --config-libdl=* Additional libraries to include to get access to <dlfcn.h> functions"
echo " --config-libsocket=* Additional libraries to include to get access to <sys/socket.h> functions"
echo " --config-dex-cc=* The C/C++ compiler to use when building dex modules (defaults to --config-cxx)"
echo " --config-dex-cflags=* Additional flags to pass to the dex-compiler during compilation"
echo " --config-dex-ldflags=* Additional flags to pass to the dex-compiler during linking"
echo " --config-dex-libs=* Additional libraries to include during linking of dex modules"
echo " --config-core-cflags=* Additional flags to pass to the deemon-core-compiler during compilation"
echo " --config-core-ldflags=* Additional flags to pass to the deemon-core-compiler during linking"
echo " --config-core-libs=* Additional libraries to include during linking of the deemon-core"
echo " --config-pthread=* Additional C flags to pass when multi-threading support is enabled"
echo " --conf=NAME=VALUE Add a configuration override '#define NAME VALUE' to <deemon/config.h>"
echo " --conf=NAME Same as --conf=NAME=1"
echo " --with-host=unix For multi-host systems (cygwin): build against unix APIs"
echo " --with-host=windows For multi-host systems (cygwin): build against windows APIs"
echo " --with-FEATURE Enable the specified FEATURE (s.a. --help=features)"
echo " --without-FEATURE Disable the specified FEATURE (s.a. --help=features)"
echo " --help Display this help"
echo " --help=features Disable available options for --with-FEATURE and --without-FEATURE"
}
while [[ $# -gt 0 ]]; do
case "$1" in
--target=*)
## e.g. i386-kos
## e.g. x86_64-linux-gnu
## e.g. x86_64-pc-cygwin
TARGET="$(echo "$1" | cut -d '=' -f 2)"
;;
--libffi-target=*)
LIBFFI_TARGET="$(echo "$1" | cut -d '=' -f 2)"
;;
--build-root=*) BLD_ROOT="$(echo "$1" | cut -d '=' -f 2)" ;;
--source-root=*) SRC_ROOT="$(echo "$1" | cut -d '=' -f 2)" ;;
--bin-path=*) BIN_PATH="$(echo "$1" | cut -d '=' -f 2)" ;;
--build-path=*) BLD_PATH="$(echo "$1" | cut -d '=' -f 2)" ;;
--cross-prefix=*) CONFIG_CROSS_PREFIX="$(echo "$1" | cut -d '=' -f 2)" ;;
--config-exe-extension=*) CONFIG_EXE="$(echo "$1" | cut -d '=' -f 2)" ;;
--config-dll-extension=*) CONFIG_DLL="$(echo "$1" | cut -d '=' -f 2)" ;;
--config-cc=*) CONFIG_CC="$(echo "$1" | cut -d '=' -f 2)" ;;
--config-cxx=*) CONFIG_CXX="$(echo "$1" | cut -d '=' -f 2)" ;;
--config-cflags=*) CONFIG_CFLAGS="$CONFIG_CFLAGS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-ldflags=*) CONFIG_LDFLAGS="$CONFIG_LDFLAGS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-libs=*) CONFIG_LIBS="$CONFIG_LIBS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-libm=*) CONFIG_LIBM="$CONFIG_LIBM $(echo "$1" | cut -d '=' -f 2)" ;;
--config-libdl=*) CONFIG_LIBDL="$CONFIG_LIBDL $(echo "$1" | cut -d '=' -f 2)" ;;
--config-libsocket=*) CONFIG_LIBSOCKET="$CONFIG_LIBSOCKET $(echo "$1" | cut -d '=' -f 2)" ;;
--config-dex-cc=*) CONFIG_DEX_CC="$(echo "$1" | cut -d '=' -f 2)" ;;
--config-dex-cflags=*) CONFIG_DEX_CFLAGS="$CONFIG_DEX_CFLAGS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-dex-ldflags=*) CONFIG_DEX_LDFLAGS="$CONFIG_DEX_LDFLAGS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-dex-libs=*) CONFIG_DEX_LIBS="$CONFIG_DEX_LIBS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-core-cflags=*) CONFIG_CORE_CFLAGS="$CONFIG_CORE_CFLAGS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-core-ldflags=*) CONFIG_CORE_LDFLAGS="$CONFIG_CORE_LDFLAGS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-core-libs=*) CONFIG_CORE_LIBS="$CONFIG_CORE_LIBS $(echo "$1" | cut -d '=' -f 2)" ;;
--config-pthread=*) CONFIG_PTHREAD="$CONFIG_PTHREAD $(echo "$1" | cut -d '=' -f 2)" ;;
--conf=*) FEATURES="$FEATURES $(echo "$1" | cut -d '=' -f 2)" ;;
--with-host=unix)
del_feature "CONFIG_FORCE_HOST_WINDOWS"
add_feature "CONFIG_FORCE_HOST_UNIX"
;;
--with-host=windows)
del_feature "CONFIG_FORCE_HOST_UNIX"
add_feature "CONFIG_FORCE_HOST_WINDOWS"
;;
--with-*) set_with_feature "${1:7}" "1" ;;
--without-*) set_with_feature "${1:10}" "0" ;;
--help) print_help; exit 1 ;;
--help=features) print_help_features; exit 1 ;;
*)
echo "Invalid argument $1 (run './configure --help' for options)"
exit 1
;;
esac
shift
done
########################################################################################
## Automatically configure options
########################################################################################
if [ -z "$BIN_PATH" ]; then BIN_PATH="$BLD_ROOT"; fi
if [ -z "$BLD_PATH" ]; then BLD_PATH="$BLD_ROOT/build/deemon"; fi
if [ -z "$CONFIG_CC" ]; then CONFIG_CC="${CONFIG_CROSS_PREFIX}gcc"; fi
if [ -z "$CONFIG_CXX" ]; then CONFIG_CXX="${CONFIG_CROSS_PREFIX}g++"; fi
if [ -z "$WITH_DEBUG" ]; then WITH_DEBUG="1"; fi
if [ -z "$WITH_OPTIMIZE" ]; then WITH_OPTIMIZE="-O2"; fi
if [ -z "$WITH_THREADS" ]; then WITH_THREADS="1"; fi
if [ -z "$WITH_LIBFFI" ]; then WITH_LIBFFI="1"; fi
if [ -z "$WITH_SYSTEM_LIBFFI" ]; then WITH_SYSTEM_LIBFFI="0"; fi
########################################################################################
## Setup configure logging
########################################################################################
CONFIG_LOG="$BLD_PATH/config.log"
cmd() {
echo "exec: $*" >> "$CONFIG_LOG"
$* | tee -a "$CONFIG_LOG"
local error=${PIPESTATUS[0]}
if ! test $error -eq 0; then
echo "ERROR: Command failed '$*' -> '$error'" | tee -a "$CONFIG_LOG"
exit $error
fi
}
trycmd() {
echo "exec: $*" >> "$CONFIG_LOG"
$* | tee -a "$CONFIG_LOG"
local error=${PIPESTATUS[0]}
if ! test $error -eq 0; then
echo "ERROR: Command failed '$*' -> '$error'" | tee -a "$CONFIG_LOG"
fi
return $error
}
mkdir -p "$BLD_PATH"
unlink "$CONFIG_LOG" > /dev/null 2>&1
########################################################################################
## Automatically determine the target from the given compiler
########################################################################################
if [ -z "$TARGET" ]; then
TARGET=$("$CONFIG_CC" -v 2>&1 | while read line; do
if [[ "$line" == *"Target: "* ]]; then
TARGET="$(echo "$line" | cut -d ':' -f 2)"
TARGET="$(echo "${TARGET}" | sed -e 's/^[ \t]*//')"
echo "$TARGET"
break
fi
done)
if [ -z "$TARGET" ]; then
echo "Error: Unable to determine target triplet (must manually specific '--target=...')" | tee -a "$CONFIG_LOG"
exit 1
fi
TARGET_IS_AUTO="yes"
fi
########################################################################################
## Automatically extract the target CPU name
########################################################################################
if [ -z "$TARGET_CPU" ]; then
# Assume a triplet format that begins with
# the target CPU name, followed by a dash ('-')
TARGET_CPU="$(echo "$TARGET" | cut -d '-' -f 1)"
fi
########################################################################################
## Automatically determine the compiler used for the dex
########################################################################################
if [ -z "$CONFIG_DEX_CC" ]; then
CONFIG_DEX_CC="$CONFIG_CC"
case "$TARGET" in
*CYGWIN* | *Cygwin* | *cygwin*)
# Need to use a c++ compiler on windows (actually: Need to do so on any PE-platform)
CONFIG_DEX_CC="$CONFIG_CXX"
;;
*)
;;
esac
fi
########################################################################################
## Automatically enable DEX support
########################################################################################
if [ -z "$WITH_DEX" ]; then
case "$TARGET" in
# Blacklist of targets without dex goes here
*)
WITH_DEX="1"
;;
esac
fi
########################################################################################
## Automatically test if we can provide an assembly interpreter
########################################################################################
if [ -z "$WITH_ASSEMBLY_INTERPRETER" ]; then
WITH_ASSEMBLY_INTERPRETER="0"
case "$TARGET_CPU" in
i?86)
printf "checking if one can compile an AT&T assembly source file..."
unlink "$BLD_ROOT/test.o" > /dev/null 2>&1
unlink "$BLD_ROOT/test.S" > /dev/null 2>&1
cat > "$BLD_ROOT/test.S" <<EOF
foo:
movl $42, %eax
lodsl
stosl
ret $8
EOF
if "$CONFIG_CC" -c -o "$BLD_ROOT/test.o" "$BLD_ROOT/test.S" > /dev/null 2>&1; then
printf " yes\n"
WITH_ASSEMBLY_INTERPRETER="1"
else
printf " no\n"
fi
unlink "$BLD_ROOT/test.o" > /dev/null 2>&1
unlink "$BLD_ROOT/test.S" > /dev/null 2>&1
;;
*)
;;
esac
fi
########################################################################################
## Select the used assembly interpreter source file (if any)
########################################################################################
if [[ "$WITH_ASSEMBLY_INTERPRETER" == "1" ]]; then
case "$TARGET_CPU" in
i?86)
WITH_ASSEMBLY_INTERPRETER="$BLD_PATH/core/src/deemon/execute/asm/exec.gas-386.o"
;;
*)
echo "Error: No assembly interpreter exists for this platform" | tee -a "$CONFIG_LOG"
exit 1
;;
esac
else
WITH_ASSEMBLY_INTERPRETER=""
fi
if ! [ -z "$WITH_ASSEMBLY_INTERPRETER" ]; then
add_feature "CONFIG_HAVE_EXEC_ASM"
fi
########################################################################################
## Figure out if we need to provide KOS system headers
########################################################################################
if [ -z "$WITH_KOS_SYSTEM_HEADERS" ]; then
case "$TARGET" in
*-kos | *-kos-*)
# The system already provides the needed headers
WITH_KOS_SYSTEM_HEADERS="0"
;;
*)
WITH_KOS_SYSTEM_HEADERS="1"
;;
esac
fi
########################################################################################
## Do some additional target-specific configurations
########################################################################################
if ! [ -z "$TARGET_IS_AUTO" ]; then
case "$TARGET" in
*CYGWIN* | *Cygwin* | *cygwin*)
CONFIG_CORE_LDFLAGS="$CONFIG_CORE_LDFLAGS -Wl,--out-implib=${BIN_PATH}/libdeemon.dll.a"
case "$TARGET_CPU" in
i?86)
CONFIG_CORE_LDFLAGS="$CONFIG_CORE_LDFLAGS -Wl,${SRC_ROOT}/src/deemon/linker-scripts/link-deemon-gcc-i386-cygwin.def"
CONFIG_CORE_LDFLAGS="$CONFIG_CORE_LDFLAGS -Wl,--stack,4194304"
;;
*x86_64* | *x86-64*)
CONFIG_CORE_LDFLAGS="$CONFIG_CORE_LDFLAGS -Wl,--stack,8388608"
;;
*)
;;
esac
;;
*)
;;
esac
fi
########################################################################################
## Automatically determine how to link against libm and libdl
########################################################################################
if [ -z "$CONFIG_LIBM" ]; then
case "$TARGET" in
*-kos | *-kos-*)
# KOS includes libm as part of libc
;;
*)
CONFIG_LIBM="-lm"
;;
esac
fi
if [ -z "$CONFIG_LIBDL" ]; then
case "$TARGET" in
*CYGWIN* | *Cygwin* | *cygwin*)
# Cygwin includes libdl as part of libc
;;
*)
CONFIG_LIBDL="-ldl"
;;
esac
fi
if [ -z "$CONFIG_LIBSOCKET" ]; then
case "$TARGET" in
*CYGWIN* | *Cygwin* | *cygwin*)
CONFIG_LIBSOCKET="-lWs2_32"
;;
*)
CONFIG_LIBSOCKET=""
;;
esac
fi
if [ -z "$CONFIG_PTHREAD" ] && [[ "$WITH_THREADS" == "1" ]]; then
CONFIG_PTHREAD="-pthread";
fi
########################################################################################
## Apply configuration options
if [[ "$WITH_DEBUG" == "1" ]]; then CONFIG_CFLAGS="$CONFIG_CFLAGS -g"; fi
if [[ "$WITH_THREADS" == "0" ]]; then add_feature "CONFIG_NO_THREADS"; fi
if ! [ -z "$WITH_OPTIMIZE" ]; then CONFIG_CFLAGS="$CONFIG_CFLAGS $WITH_OPTIMIZE"; fi
if ! [ -z "$CONFIG_PTHREAD" ]; then
CONFIG_CFLAGS="$CONFIG_CFLAGS $CONFIG_PTHREAD";
CONFIG_LDFLAGS="$CONFIG_LDFLAGS $CONFIG_PTHREAD";
fi
case "$TARGET" in
*CYGWIN* | *Cygwin* | *cygwin*)
CONFIG_EXE=".exe"
CONFIG_DLL=".dll"
if [[ "$WITH_DEX" == "1" ]]; then
CONFIG_DEX_LDFLAGS="$CONFIG_DEX_LDFLAGS -L${BIN_PATH}"
CONFIG_DEX_LIBS="$CONFIG_DEX_LIBS -ldeemon"
fi
;;
*)
CONFIG_EXE=""
CONFIG_DLL=".so"
if [[ "$WITH_DEX" == "1" ]]; then
CONFIG_CORE_LDFLAGS="$CONFIG_CORE_LDFLAGS -Wl,--export-dynamic"
CONFIG_DEX_LDFLAGS="$CONFIG_DEX_LDFLAGS -Wl,--allow-shlib-undefined"
CONFIG_DEX_CFLAGS="$CONFIG_DEX_CFLAGS -fPIC"
fi
;;
esac
cmd mkdir -p "$BLD_ROOT/build"
cmd mkdir -p "$BLD_ROOT/lib"
if [ "$BLD_ROOT" != "$SRC_ROOT" ]; then
unlink "$BLD_ROOT/Makefile" > /dev/null 2>&1
cmd cp "$SRC_ROOT/Makefile" "$BLD_ROOT/Makefile"
fi
mv "$BLD_ROOT/include/deemon/config.h" "$BLD_ROOT/include/deemon/config.h.old" > /dev/null 2>&1
if ! [ -z "$FEATURES" ]; then
cmd mkdir -p "$BLD_ROOT/include/deemon"
cat > "$BLD_ROOT/include/deemon/config.h" <<EOF
/* Automatically generated file (by ./configure). - Do not edit! */
EOF
for feat in $FEATURES; do
feat="$(echo "${feat}" | sed -e 's/^[ \t]*//')"
if [[ "$feat" == *"="* ]]; then
N="$(echo "$feat" | cut -d '=' -f 1)"
V="$(echo "$feat" | cut -d '=' -f 2)"
if [[ "$V" == "("* ]]; then
echo "#define $N$V" >> "$BLD_ROOT/include/deemon/config.h"
else
echo "#define $N $V" >> "$BLD_ROOT/include/deemon/config.h"
fi
elif ! [ -z "$feat" ]; then
echo "#define $feat" >> "$BLD_ROOT/include/deemon/config.h"
fi
done
fi
########################################################################################
## Probe system features
CONFINC="$BLD_ROOT/include/deemon/config.h"
if ! [ -f "$CONFINC" ]; then
cmd mkdir -p "$BLD_ROOT/include/deemon"
cat > "$CONFINC" <<EOF
/* Automatically generated file (by ./configure). - Do not edit! */
EOF
fi
CONFTEST_H="$BLD_ROOT/conftest.h"
CONFTEST="$BLD_ROOT/conftest.c"
CONFTEST_OUT="$BLD_ROOT/conftest.o"
CONFTEST_EXE="$BLD_ROOT/conftest"
CONFTEST_MAIN="int main()"
cat > "$CONFTEST_H" <<EOF
#define _ATFILE_SOURCE 1
#define _KOS_SOURCE 1
#define _GNU_SOURCE 1
#define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 200809L
#define _LARGEFILE_SOURCE 1
#define _LARGEFILE64_SOURCE 1
#define _CTYPE_MACRO_SOURCE 1
#define _TIME64_SOURCE 1
#define _BSD_SOURCE 1
#define _SVID_SOURCE 1
#define _DEFAULT_SOURCE 1
#define _XOPEN_SOURCE_EXTENDED 1
#define _DOS_SOURCE 1
#define _MEMMEM_EMPTY_NEEDLE_NULL_SOURCE 1
#define __EXTENSIONS__ 1
EOF
CONFTEST_H_MODIFIED=yes
CC_HAS_GCH=yes
# Try to compile the current conftest
try_compile() {
echo "exec: $CONFIG_CC $CONFIG_CFLAGS -Werror -include $CONFTEST_H -include $CONFINC -c -o $CONFTEST_OUT $CONFTEST" >> "$CONFIG_LOG"
if test x"$CC_HAS_GCH" = xyes; then
if test x"$CONFTEST_H_MODIFIED" = xyes; then
if "$CONFIG_CC" $CONFIG_CFLAGS -Werror -o "${CONFTEST_H}.gch" "$CONFTEST_H" > /dev/null 2>&1; then
CONFTEST_H_MODIFIED=no
else
CC_HAS_GCH=no
fi
fi
if test x"$CONFTEST_H_MODIFIED" = xno; then
"$CONFIG_CC" $CONFIG_CFLAGS -Werror \
-include "$CONFTEST_H" -include "$CONFINC" \
-c -o "$CONFTEST_OUT" "$CONFTEST" >> "$CONFIG_LOG" 2>&1
return $?
fi
fi
"$CONFIG_CC" $CONFIG_CFLAGS -Werror \
-include "$CONFTEST_H" -include "$CONFINC" \
-c -o "$CONFTEST_OUT" "$CONFTEST" >> "$CONFIG_LOG" 2>&1
return $?
}
try_compile_raw() {
echo "exec: $CONFIG_CC $CONFIG_CFLAGS -Werror -include $CONFINC -c -o $CONFTEST_OUT $CONFTEST" >> "$CONFIG_LOG"
"$CONFIG_CC" $CONFIG_CFLAGS -Werror -include "$CONFINC" \
-c -o "$CONFTEST_OUT" "$CONFTEST" >> "$CONFIG_LOG" 2>&1
return $?
}
try_link_raw() {
local extra_flags="$1"
echo "exec: $CONFIG_CC $CONFIG_CFLAGS -Werror -o $CONFTEST_EXE $CONFTEST_OUT $extra_flags" >> "$CONFIG_LOG"
"$CONFIG_CC" $CONFIG_CFLAGS -Werror -o "$CONFTEST_EXE" "$CONFTEST_OUT" $extra_flags >> "$CONFIG_LOG" 2>&1
return $?
}
try_compile_minimal() {
echo "exec: $CONFIG_CC $CONFIG_CFLAGS -Werror -c -o $CONFTEST_OUT $CONFTEST" >> "$CONFIG_LOG"
"$CONFIG_CC" $CONFIG_CFLAGS -Werror -c -o "$CONFTEST_OUT" "$CONFTEST" >> "$CONFIG_LOG" 2>&1
return $?
}
# log_checking_begin $message
CURRENT_CHECK_MESSAGE=""
log_checking_begin() {
echo -n "[ ] $1..."
echo "$1..." >> "$CONFIG_LOG"
CURRENT_CHECK_MESSAGE="$1"
}
# log_checking_yes
# log_checking_yes $status
log_checking_yes() {
local status="$1"
if test -z "$status"; then
status="yes"
fi
echo -e "\r[+] $CURRENT_CHECK_MESSAGE... ($status)"
echo "$CURRENT_CHECK_MESSAGE... ($status)" >> "$CONFIG_LOG"
}
# log_checking_no
# log_checking_no $status
log_checking_no() {
local status="$1"
if test -z "$status"; then
status="no"
fi
echo -e "\r[-] $CURRENT_CHECK_MESSAGE... ($status)"
echo "$CURRENT_CHECK_MESSAGE... ($status)" >> "$CONFIG_LOG"
}
# e.g. try_check_feature "STDIO_H" "header <$1>"
try_check_feature() {
log_checking_begin "Checking for $2"
if try_compile; then
log_checking_yes
return 0
else
log_checking_no
local FPROC=$(cat "$CONFTEST")
FPROC="| ${FPROC//
/
| }"
cat >> "$CONFIG_LOG" <<EOF
The failing program was:
$FPROC
--------------------------------------------------------------------------------
EOF
return 1
fi
}
try_check_feature_raw() {
log_checking_begin "Checking for $2"
if try_compile_raw; then
log_checking_yes
return 0
else
log_checking_no
local FPROC=$(cat "$CONFTEST")
FPROC="| ${FPROC//
/
| }"
cat >> "$CONFIG_LOG" <<EOF
The failing program was:
$FPROC
--------------------------------------------------------------------------------
EOF
return 1
fi
}
# e.g. check_feature "STDIO_H" "header <$1>"
# Will write either CONFIG_HAVE_STDIO_H, or CONFIG_NO_STDIO_H
check_feature() {
if try_check_feature "$1" "$2"; then
echo "#define CONFIG_HAVE_$1" >> "$CONFINC"
return 0
else
echo "#define CONFIG_NO_$1 /* Missing! */" >> "$CONFINC"
return 1
fi
}
check_feature_raw() {
if try_check_feature_raw "$1" "$2"; then
echo "#define CONFIG_HAVE_$1" >> "$CONFINC"
return 0
else
echo "#define CONFIG_NO_$1 /* Missing! */" >> "$CONFINC"
return 1
fi
}
# e.g. check_header "stdio.h"
check_header() {
cat > "$CONFTEST" <<EOF
#include <$1>
$CONFTEST_MAIN{return 0;}
EOF
local FN="${1^^}"
FN="${FN////_}"
FN="${FN//./_}"
if check_feature_raw "$FN" "header <$1>"; then
echo "#include <$1>" >> "$CONFTEST_H"
CONFTEST_H_MODIFIED=yes
return 0
fi
return 1
}
# e.g. check_generic "_Exit" "_Exit(0);"
check_generic() {
cat > "$CONFTEST" <<EOF
$CONFTEST_MAIN{${2}}
EOF
check_feature "$1" "$1"
return $?
}
# Check if we need to add argc/argv to conftest files
log_checking_begin "Checking how to compile a simple source file"
cat > "$CONFTEST" <<EOF
$CONFTEST_MAIN{return 0;}
EOF
if ! try_compile_raw; then
CONFTEST_MAIN="int main(int argc, char *argv[])"
cat > "$CONFTEST" <<EOF
$CONFTEST_MAIN{return 0;}
EOF
if ! try_compile_raw; then
log_checking_no "Cannot compile a simple source file"
exit 1
fi
fi
log_checking_yes "'$CONFTEST_MAIN { ... }'"
########################################################################################
## Also configure libffi (if needed)
########################################################################################
if [[ "$WITHOUT_DEX_SPECIFIC" == *"CTYPES"* ]]; then
# The ctypes dex is disabled, so we don't even need libffi
CONFIG_DEX_CTYPES_CC="$CONFIG_DEX_CC"
CONFIG_DEX_CTYPES_CFLAGS=""
CONFIG_DEX_CTYPES_LDFLAGS=""
CONFIG_DEX_CTYPES_LIBS=""
else
if [[ "$WITH_LIBFFI" != "1" ]]; then
CONFIG_DEX_CTYPES_CFLAGS="-DCONFIG_NO_CFUNCTION"
CONFIG_DEX_CTYPES_LDFLAGS=""
CONFIG_DEX_CTYPES_LIBS=""
elif [[ "$WITH_SYSTEM_LIBFFI" == "1" ]]; then
CONFIG_DEX_CTYPES_CFLAGS=""
CONFIG_DEX_CTYPES_LDFLAGS=""
CONFIG_DEX_CTYPES_LIBS="-lffi"
else
_STATIC_LIBFFY_BUILD_ERROR=""
if ! [ -f "$BLD_PATH/libffi/include/ffi.h" ]; then
echo "Configuring libffi (for dex.ctypes)..." | tee -a "$CONFIG_LOG"
rm -rf "$BLD_PATH/libffi" > /dev/null 2>&1
cmd mkdir -p "$BLD_PATH/libffi"
cd "$BLD_PATH/libffi"
if [ -z "$LIBFFI_TARGET" ]; then
case "$TARGET" in
*-kos | *-kos-*)
# libffi doesn't know KOS, but it's close
# enough to linux, so we just use that
LIBFFI_TARGET="$TARGET_CPU-linux-gnu"
;;
*)
LIBFFI_TARGET="$TARGET"
;;
esac
fi
(
export CROSS_PREFIX="$CONFIG_CROSS_PREFIX"
export CC="$CONFIG_CC"
export CXX="$CONFIG_CXX"
export CPP="${CONFIG_CROSS_PREFIX}cpp"
export AS="${CONFIG_CROSS_PREFIX}as"
export AR="${CONFIG_CROSS_PREFIX}ar"
export NM="${CONFIG_CROSS_PREFIX}nm"
export TARGET="$LIBFFI_TARGET"
if [[ "$TARGET" == "i686-w64-mingw32" ]]; then
# Workaround for a configure-detection-bug:
# https://bugzilla.mozilla.org/show_bug.cgi?id=1336569
export CFLAGS="$CFLAGS -DSYMBOL_UNDERSCORE";
export CXXFLAGS="$CXXFLAGS -DSYMBOL_UNDERSCORE";
fi
case "$TARGET" in
*CYGWIN* | *Cygwin* | *cygwin*)
;;
*)
# Force libffi to be built as position-independent,
# thus preventing DT_TEXTREL in ctypes.so
export CFLAGS="$CFLAGS -fPIC";
export CXXFLAGS="$CXXFLAGS -fPIC";
;;
esac
cmd bash "$SRC_ROOT/src/dex/ctypes/ffi/libffi/configure" \
--host="$LIBFFI_TARGET" \
--target="$LIBFFI_TARGET" \
--enable-static \
--prefix "$BLD_PATH/libffi"
) || {
_STATIC_LIBFFY_BUILD_ERROR="$?"
}
fi
if test -z "$_STATIC_LIBFFY_BUILD_ERROR" && ! [ -f "${BLD_PATH}/libffi/.libs/libffi.a" ]; then
echo "Building libffi (for dex.ctypes)..." | tee -a "$CONFIG_LOG"
cd "$BLD_PATH/libffi"
trycmd make -j $(grep -c ^processor /proc/cpuinfo) || {
_STATIC_LIBFFY_BUILD_ERROR=$?
# libffi relies on libtool, which in turn contains some bashism,
# though rather than being called by /bin/bash, it's called by
# /bin/sh instead. So if you've just seen errors like this:
# >> ./libtool: 1578: ./libtool: preserve_args+= --tag CC: not found
# then the problem is that '[$(readlink /bin/sh) != "bash"]'
# s.a. https://github.com/JuliaPackaging/BinaryBuilder.jl/issues/77
# Though for libffi the problem isn't a miss-configured kernel,
# but it unconditionally assuming that the /bin/sh-shell has
# support for all of the bashism it wants to throw at it...
if [ "$(readlink "/bin/sh")" != "bash" ]; then
echo "" | tee -a "$CONFIG_LOG"
echo "" | tee -a "$CONFIG_LOG"
echo "" | tee -a "$CONFIG_LOG"
echo "Building libffi likely failed because you're using a custom shell in '/bin/sh'" | tee -a "$CONFIG_LOG"
echo "Libffi relies on libtool, which in turn contains some bashism that may not be" | tee -a "$CONFIG_LOG"
echo "supported by other shells. If you're seeing errors like:" | tee -a "$CONFIG_LOG"
echo ">> ./libtool: 1578: ./libtool: preserve_args+= --tag CC: not found" | tee -a "$CONFIG_LOG"
echo "then consider fixing this problem by install bash and running:" | tee -a "$CONFIG_LOG"
echo " 'unlink /bin/sh; ln -s \"bash\" /bin/sh'" | tee -a "$CONFIG_LOG"
echo "as root" | tee -a "$CONFIG_LOG"
echo "" | tee -a "$CONFIG_LOG"
fi
}
fi
cd "$BLD_PATH"
if test -z "$_STATIC_LIBFFY_BUILD_ERROR"; then
CONFIG_DEX_CTYPES_CFLAGS="-I${BLD_PATH}/libffi/include"
CONFIG_DEX_CTYPES_LDFLAGS=""
CONFIG_DEX_CTYPES_LIBS="${BLD_PATH}/libffi/.libs/libffi.a"
else
echo "" | tee -a "$CONFIG_LOG"
echo "" | tee -a "$CONFIG_LOG"
echo "" | tee -a "$CONFIG_LOG"
echo "[!] Error building libffi (host might not be supported by built-in version of libffi)" | tee -a "$CONFIG_LOG"
log_checking_begin "Checking if a system version of libffi is installed"
cat > "$CONFTEST" <<EOF
#include <ffi.h>
#include <ffitarget.h>
$CONFTEST_MAIN{extern ffi_type a; extern ffi_cif b;return 0;}
EOF
if try_compile_raw && try_link_raw "-lffi"; then
log_checking_yes
echo "[!] Using system version of libffi (implicit '--with-system-libffi')" | tee -a "$CONFIG_LOG"
CONFIG_DEX_CTYPES_CFLAGS=""