#!/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 \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 """qconf: Adding $libdir""" 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 """Run \`make$ncpus\` now. The just-built programs, e.g. \`./http\` can be put to use without \`make install\`."""