xref: /unit/configure (revision 2051:a61d948c8027)
1#!/bin/sh
2
3# Copyright (C) Igor Sysoev
4# Copyright (C) NGINX, Inc.
5
6
7# Disable localized program messages.
8LC_ALL=C
9export LC_ALL
10
11# Stop on error exit status.
12set -e
13
14# Stop on uninitialized variable.
15set -u
16
17# Initialize variables with null values if they are not defined.
18CFLAGS=${CFLAGS=}
19NXT_TEST_CFLAGS=${NXT_TEST_CFLAGS=}
20NXT_TEST_LIBS=${NXT_TEST_LIBS=}
21
22NXT_BUILD_DIR=${NXT_BUILD_DIR:-build}
23
24NXT_AUTOTEST=$NXT_BUILD_DIR/autotest
25NXT_AUTOCONF_ERR=$NXT_BUILD_DIR/autoconf.err
26NXT_AUTOCONF_DATA=$NXT_BUILD_DIR/autoconf.data
27NXT_AUTO_CONFIG_H=$NXT_BUILD_DIR/nxt_auto_config.h
28NXT_VERSION_H=$NXT_BUILD_DIR/nxt_version.h
29NXT_MAKEFILE=$NXT_BUILD_DIR/Makefile
30
31CC=${CC:-cc}
32
33NXT_DAEMON=unitd
34NXT_BINDIR="bin"
35NXT_SBINDIR="sbin"
36NXT_LIBDIR="lib"
37NXT_INCDIR="include"
38NXT_MANDIR="share/man"
39NXT_MODULES="modules"
40NXT_STATE="state"
41NXT_TMP="tmp"
42NXT_PID="unit.pid"
43NXT_LOG="unit.log"
44NXT_CONTROL="unix:control.unit.sock"
45NXT_USER="nobody"
46NXT_GROUP=
47
48nxt_module=${1:-""}
49
50case $nxt_module in
51    --help)
52        . auto/help
53        exit 0
54    ;;
55
56    ""|--*)
57    ;;
58
59    unit)
60        shift
61    ;;
62
63    *)
64        . auto/modules/conf
65        exit 0
66    ;;
67esac
68
69
70. ./version
71. auto/os/test
72. auto/options
73
74test -d $NXT_BUILD_DIR || mkdir $NXT_BUILD_DIR
75
76> $NXT_AUTOCONF_ERR
77> $NXT_AUTO_CONFIG_H
78
79. auto/cc/test
80
81
82cat << END >> $NXT_AUTO_CONFIG_H
83
84#define NXT_CONFIGURE_OPTIONS  "$NXT_CONFIGURE_OPTIONS"
85#define NXT_SYSTEM_VERSION     "$NXT_SYSTEM $NXT_SYSTEM_VERSION $NXT_SYSTEM_PLATFORM"
86#define NXT_COMPILER_VERSION   "$NXT_CC_VERSION"
87
88#define NXT_PID                "$NXT_PID"
89#define NXT_LOG                "$NXT_LOG"
90#define NXT_MODULES            "$NXT_MODULES"
91#define NXT_STATE              "$NXT_STATE"
92#define NXT_TMP                "$NXT_TMP"
93
94#define NXT_CONTROL_SOCK       "$NXT_CONTROL"
95
96#define NXT_USER               "$NXT_USER"
97#define NXT_GROUP              "$NXT_GROUP"
98
99END
100
101
102if [ $echo = echo ]; then
103    # Build a portable "echo" program that supports only "-n" option.
104    # This also tests C compiler ability to create executables.
105    . auto/echo/build
106fi
107
108
109nxt_have=NXT_UNIX . auto/have
110
111if [ $NXT_UNIX_DOMAIN = YES ]; then
112    nxt_have=NXT_HAVE_UNIX_DOMAIN . auto/have
113fi
114
115NXT_LIBRT=
116
117. auto/types
118. auto/clang
119. auto/atomic
120. auto/malloc
121. auto/mmap
122. auto/shmem
123. auto/time
124. auto/threads
125. auto/events
126. auto/sockets
127. auto/sendfile
128. auto/files
129. auto/unix
130. auto/os/conf
131. auto/ssltls
132
133if [ $NXT_REGEX = YES ]; then
134    . auto/pcre
135fi
136
137. auto/isolation
138. auto/capability
139
140
141case "$NXT_SYSTEM_PLATFORM" in
142    i386 | amd64 | x86_64)
143        nxt_have=NXT_HAVE_LITTLE_ENDIAN . auto/have
144        nxt_have=NXT_HAVE_NONALIGNED . auto/have
145    ;;
146esac
147
148
149if [ $NXT_DEBUG = YES ]; then
150    nxt_debug=1
151else
152    nxt_debug=0
153fi
154
155cat << END >> $NXT_AUTO_CONFIG_H
156
157#ifndef NXT_DEBUG
158#define NXT_DEBUG  $nxt_debug
159#endif
160
161#define NXT_SHM_PREFIX  "$NXT_SHM_PREFIX"
162
163END
164
165. auto/test_build
166. auto/sources
167. auto/save
168
169# LOOK
170
171NXT_LIB_AUX_CFLAGS="$NXT_OPENSSL_CFLAGS $NXT_GNUTLS_CFLAGS \\
172                    $NXT_CYASSL_CFLAGS $NXT_POLARSSL_CFLAGS \\
173                    $NXT_PCRE_CFLAGS"
174
175NXT_LIB_AUX_LIBS="$NXT_OPENSSL_LIBS $NXT_GNUTLS_LIBS \\
176                    $NXT_CYASSL_LIBS $NXT_POLARSSL_LIBS \\
177                    $NXT_PCRE_LIB"
178
179. auto/make
180. auto/summary
181