forked from freewilll/wcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·84 lines (67 loc) · 2.11 KB
/
configure
File metadata and controls
executable file
·84 lines (67 loc) · 2.11 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
#!/bin/sh
set -e
# Configure:
# - C library: musl or glibc
# - as binary
# - ld binary
#
# The results are written to config.h
USE_MUSL=0
DEFAULT_AS_COMMAND="${AS:-$(command -v as || true)}" # Default assembler.
DEFAULT_LD_COMMAND="${LD:-$(command -v ld || true)}" # Default linker.
# Show the help
help() {
cat <<END
Usage: ./configure [options]
Flags:
--use-musl Use MUSL libc instead of glibc
--as=PATH Use assembler binary (detected: $DEFAULT_AS_COMMAND)
--ld=PATH Use linker binary (detected: $DEFAULT_LD_COMMAND)
-h, --help Print this help text.
END
exit 0
}
# Parse args
for arg in "$@"; do
case $arg in
--use-musl) USE_MUSL=1 ;;
--as=*) DEFAULT_AS_COMMAND="${arg#*=}" ;;
--ld=*) DEFAULT_LD_COMMAND="${arg#*=}" ;;
-h|--help) help ;;
*) echo "Unknown arg: $arg" >&2; exit 1 ;;
esac
shift || true
done
# gcc C runtime files
GCC_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9
GCC_CRTBEGIN=/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o
GCC_CRTEND=/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o
# Configure libc
if [ $USE_MUSL -eq 0 ]
then
echo Using glibc
DYNAMIC_LINKER=/lib64/ld-linux-x86-64.so.2
LIBC_LIBRARY_PATH=/usr/lib
STARTFILES="/usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o $GCC_CRTBEGIN"
ENDFILES="$GCC_CRTEND /usr/lib/x86_64-linux-gnu/crtn.o"
else
echo Using musl libc
DYNAMIC_LINKER=/lib/ld-musl-x86_64.so.1
LIBC_LIBRARY_PATH=/usr/lib/x86_64-linux-musl
STARTFILES="/usr/lib/x86_64-linux-musl/Scrt1.o /usr/lib/x86_64-linux-musl/crti.o $GCC_CRTBEGIN"
ENDFILES="$GCC_CRTEND /usr/lib/x86_64-linux-musl/crtn.o"
fi
echo Using assembler $DEFAULT_AS_COMMAND
echo Using linker $DEFAULT_LD_COMMAND
# Write out config.h
CONFIG_H_PATH=config.h
cat > $CONFIG_H_PATH <<END
// This file is auto generated. Do not edit.
#define DEFAULT_AS_COMMAND "$DEFAULT_AS_COMMAND"
#define DEFAULT_LD_COMMAND "$DEFAULT_LD_COMMAND"
#define DYNAMIC_LINKER "$DYNAMIC_LINKER"
#define LIBC_LIBRARY_PATH "$LIBC_LIBRARY_PATH"
#define GCC_LIBRARY_PATH "$GCC_LIBRARY_PATH"
#define STARTFILES "$STARTFILES"
#define ENDFILES "$ENDFILES"
END