-
Notifications
You must be signed in to change notification settings - Fork 41
/
qconf
executable file
·42 lines (42 loc) · 1.18 KB
/
qconf
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
#!/bin/sh -e
topdir="${0%/*}"
if [ "$topdir" = "$0" ]; then
topdir=.
fi
abstopdir=$(readlink -f "$topdir")
if [ ! -e "${topdir}/configure" ]; then
cd "$topdir"
autoreconf -fi
cd -
fi
case "$(uname -s)" in
OpenBSD)
set -x
"$topdir/configure" --sysconfdir=/etc --prefix=/usr/local --localstatedir=/var \
CFLAGS="-O0 -g" CXXFLAGS="-O0 -g" "$@"
set +x
ncpus=$(sysctl hw.ncpuonline 2>/dev/zero | cut -b15-)
;;
*)
echo -en '#include <libHX/string.h>\nint main(void) { HXmc_free(NULL); }' >conftest.c
libdir=""
if gcc -o conftest conftest.c $(pkg-config --cflags --libs libHX) >/dev/null 2>/dev/null; then
libdir=$(ldd conftest 2>/dev/null | perl -lne 'if(m{(\S+)/libc.so.}){print$1;exit}')
if [ -n "$libdir" ]; then
libdir="--libdir=$libdir"
echo "[33m""qconf: Adding $libdir""[0m"
fi
fi
set -x
"$topdir/configure" --sysconfdir=/etc --localstatedir=/var $libdir \
CFLAGS="-O0 -g" CXXFLAGS="-O0 -g" "$@"
set +x
ncpus=$(lscpu -b --parse=cpu 2>/dev/null | grep -Ec '[0-9]' || :)
;;
esac
if [ "$ncpus" != "0" ]; then
ncpus=" -j$ncpus"
else
ncpus=""
fi
echo "[32m""Run \`make$ncpus\` now. The just-built programs, e.g. \`./http\` can be put to use without \`make install\`.""[0m"