xref: /unit/configure (revision 953:00d8049418cf)
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_MODULES="modules"
39NXT_STATE="state"
40NXT_PID="unit.pid"
41NXT_LOG="unit.log"
42NXT_CONTROL="unix:control.unit.sock"
43NXT_USER="nobody"
44NXT_GROUP=
45
46nxt_module=${1:-""}
47
48case $nxt_module in
49    --help)
50        . auto/help
51        exit 0
52    ;;
53
54    ""|--*)
55    ;;
56
57    unit)
58        shift
59    ;;
60
61    *)
62        . auto/modules/conf
63        exit 0
64    ;;
65esac
66
67
68. auto/os/test
69. auto/options
70
71test -d $NXT_BUILD_DIR || mkdir $NXT_BUILD_DIR
72
73> $NXT_AUTOCONF_ERR
74> $NXT_AUTO_CONFIG_H
75
76. auto/cc/test
77
78
79cat << END >> $NXT_AUTO_CONFIG_H
80
81#define NXT_CONFIGURE_OPTIONS  "$NXT_CONFIGURE_OPTIONS"
82#define NXT_SYSTEM_VERSION     "$NXT_SYSTEM $NXT_SYSTEM_VERSION $NXT_SYSTEM_PLATFORM"
83#define NXT_COMPILER_VERSION   "$NXT_CC_VERSION"
84
85#define NXT_PID                "$NXT_PID"
86#define NXT_LOG                "$NXT_LOG"
87#define NXT_MODULES            "$NXT_MODULES"
88#define NXT_STATE              "$NXT_STATE"
89
90#define NXT_CONTROL_SOCK       "$NXT_CONTROL"
91
92#define NXT_USER               "$NXT_USER"
93#define NXT_GROUP              "$NXT_GROUP"
94
95END
96
97
98if [ $echo = echo ]; then
99    # Build a portable "echo" program that supports only "-n" option.
100    # This also tests C compiler ability to create executables.
101    . auto/echo/build
102fi
103
104
105nxt_have=NXT_UNIX . auto/have
106
107if [ $NXT_UNIX_DOMAIN = YES ]; then
108    nxt_have=NXT_HAVE_UNIX_DOMAIN . auto/have
109fi
110
111NXT_LIBRT=
112
113. auto/types
114. auto/clang
115. auto/atomic
116. auto/malloc
117. auto/mmap
118. auto/shmem
119. auto/time
120. auto/threads
121. auto/events
122. auto/sockets
123. auto/sendfile
124. auto/files
125. auto/unix
126. auto/os/conf
127. auto/ssltls
128. auto/pcre
129
130
131case "$NXT_SYSTEM_PLATFORM" in
132    i386 | amd64 | x86_64)
133        nxt_have=NXT_HAVE_LITTLE_ENDIAN . auto/have
134        nxt_have=NXT_HAVE_NONALIGNED . auto/have
135    ;;
136esac
137
138
139if [ $NXT_DEBUG = YES ]; then
140    nxt_debug=1
141else
142    nxt_debug=0
143fi
144
145cat << END >> $NXT_AUTO_CONFIG_H
146
147#ifndef NXT_DEBUG
148#define NXT_DEBUG  $nxt_debug
149#endif
150
151#define NXT_SHM_PREFIX  "$NXT_SHM_PREFIX"
152
153END
154
155. auto/test_build
156. auto/sources
157. auto/save
158
159# LOOK
160
161NXT_LIB_AUX_CFLAGS="$NXT_OPENSSL_CFLAGS $NXT_GNUTLS_CFLAGS \\
162                    $NXT_CYASSL_CFLAGS $NXT_POLARSSL_CFLAGS \\
163                    $NXT_PCRE_CFLAGS"
164
165NXT_LIB_AUX_LIBS="$NXT_OPENSSL_LIBS $NXT_GNUTLS_LIBS \\
166                    $NXT_CYASSL_LIBS $NXT_POLARSSL_LIBS \\
167                    $NXT_PCRE_LIB"
168
169. auto/make
170. auto/summary
171