#!/bin/sh

# Copyright (C) Igor Sysoev
# Copyright (C) NGINX, Inc.


# Disable localized program messages.
LC_ALL=C
export LC_ALL

# Stop on error exit status.
set -e
# Stop on uninitialized variable.
set -u


# Initialize variables with null values if they are not defined.
CFLAGS=${CFLAGS=}
NJS_TEST_CFLAGS=${NJS_TEST_CFLAGS=}
NJS_TEST_LIBS=${NJS_TEST_LIBS=}


# Initialize variables with default if they are not defined.
CC=${CC:-cc}
AR=${AR:-ar}
NJS_CFLAGS=${NJS_CFLAGS=}

NJS_BUILD_DIR=${NJS_BUILD_DIR:-build}

NJS_AUTOTEST=$NJS_BUILD_DIR/autotest
NJS_AUTOCONF_ERR=$NJS_BUILD_DIR/autoconf.err
NJS_AUTO_CONFIG_H=$NJS_BUILD_DIR/njs_auto_config.h
NJS_MAKEFILE=$NJS_BUILD_DIR/Makefile

test -d $NJS_BUILD_DIR || mkdir $NJS_BUILD_DIR

> $NJS_AUTOCONF_ERR

cat << END > $NJS_AUTO_CONFIG_H

/* This file is auto-generated by configure */

END

NJS_LIBRT=

. auto/os
. auto/options
. auto/cc
. auto/types
. auto/clang
. auto/time
. auto/memalign
. auto/getrandom
. auto/explicit_bzero
. auto/pcre
. auto/readline
. auto/sources

NJS_LIB_AUX_CFLAGS="$NJS_PCRE_CFLAGS"

NJS_LIBS="$NJS_LIBRT"
NJS_LIB_AUX_LIBS="$NJS_PCRE_LIB"

. auto/make

. auto/expect

. auto/summary
