-
Notifications
You must be signed in to change notification settings - Fork 118
/
jinx-config
143 lines (122 loc) · 4.02 KB
/
jinx-config
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
#! /bin/sh
JINX_MAJOR_VER=0.4
HOST_CFLAGS="-O2 -pipe -fstack-clash-protection"
HOST_CXXFLAGS="${HOST_CFLAGS} -Wp,-D_GLIBCXX_ASSERTIONS"
HOST_LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now"
TARGET_CFLAGS="$HOST_CFLAGS"
TARGET_CXXFLAGS="$HOST_CXXFLAGS"
TARGET_LDFLAGS="$HOST_LDFLAGS"
if [ -z "$ARCHITECTURE" ]; then
ARCHITECTURE=x86_64
fi
OS_TRIPLET=$ARCHITECTURE-vinix-mlibc
case "$ARCHITECTURE" in
x86_64)
TARGET_CFLAGS="$TARGET_CFLAGS -march=x86-64 -mtune=generic -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
TARGET_CXXFLAGS="$TARGET_CXXFLAGS -march=x86-64 -mtune=generic -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-z,pack-relative-relocs"
;;
esac
post_package_strip() {
if [ -z "$strip_command" ]; then
strip_command="${OS_TRIPLET}-strip"
fi
for f in $(find "${dest_dir}"); do
if file "$f" | grep 'not stripped' >/dev/null; then
echo "* stripping '$f'..."
stripped_file="$(mktemp)"
${strip_command} "$f" -o "$stripped_file"
chmod --reference="$f" "$stripped_file"
mv -f "$stripped_file" "$f"
fi
done
}
autotools_configure() {
CFLAGS="$TARGET_CFLAGS" \
CXXFLAGS="$TARGET_CXXFLAGS" \
LDFLAGS="$TARGET_LDFLAGS" \
autotools_configure_noflags "$@"
}
autotools_configure_noflags() {
if [ -z "${configure_script_path}" ]; then
configure_script_path="${source_dir}/configure"
fi
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_calloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \
${configure_script_path} \
--host=${OS_TRIPLET} \
--with-sysroot=${sysroot_dir} \
--prefix=${prefix} \
--sysconfdir=/etc \
--localstatedir=/var \
--bindir=${prefix}/bin \
--sbindir=${prefix}/bin \
--libdir=${prefix}/lib \
--disable-static \
--enable-shared \
--disable-malloc0returnsnull \
"$@"
}
autotools_recursive_regen() {
ACLOCAL_INCLUDE=""
if [ -d ${sysroot_dir}/usr/share/aclocal ]; then
ACLOCAL_INCLUDE="-I${sysroot_dir}/usr/share/aclocal"
fi
for f in $(find . -name configure.ac -o -name configure.in -type f | sort); do
echo "* autotools regen in '$(dirname $f)'..."
( cd "$(dirname "$f")" && autoreconf -fvi "$@" $ACLOCAL_INCLUDE )
done
}
meson_configure() {
CFLAGS="$TARGET_CFLAGS" \
CXXFLAGS="$TARGET_CXXFLAGS" \
LDFLAGS="$TARGET_LDFLAGS" \
meson_configure_noflags "$@"
}
meson_configure_noflags() {
if [ -z "${meson_source_dir}" ]; then
meson_source_dir="${source_dir}"
fi
meson setup "${meson_source_dir}" \
--cross-file "${base_dir}/build-support/cross_file-$ARCHITECTURE.txt" \
--prefix=${prefix} \
--sysconfdir=/etc \
--localstatedir=/var \
--libdir=lib \
--sbindir=bin \
--buildtype=release \
-Ddefault_library=shared \
"$@"
}
cmake_configure() {
CFLAGS="$TARGET_CFLAGS" \
CXXFLAGS="$TARGET_CXXFLAGS" \
LDFLAGS="$TARGET_LDFLAGS" \
cmake_configure_noflags \
"$@"
}
cmake_configure_noflags() {
if [ -z "${cmake_source_dir}" ]; then
cmake_source_dir="${source_dir}"
fi
cmake "${cmake_source_dir}" \
-DCMAKE_TOOLCHAIN_FILE="${base_dir}/build-support/CMakeToolchain-$ARCHITECTURE.txt" \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_SBINDIR=bin \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=True \
-DENABLE_STATIC=False \
-DPKG_CONFIG_EXECUTABLE="/usr/local/bin/$OS_TRIPLET-pkg-config" \
-GNinja \
"$@"
}
if [ "$in_container" = true ]; then
export VMODULES="/tmp/.vmodules"
mkdir -p "${VMODULES}"/cache
mkdir -p /tmp/v_$(id -u)
fi
PROD=true