xref: /unit/auto/make (revision 216:07257705cd64)
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) Valentin V. Bartenev
4# Copyright (C) NGINX, Inc.
5
6
7$echo "creating $NXT_MAKEFILE"
8
9mkdir -p $NXT_BUILD_DIR/src \
10         $NXT_BUILD_DIR/test
11
12
13cat << END > $NXT_MAKEFILE
14
15CC =			$CC
16
17CFLAGS = 		$NXT_CFLAGS $NXT_CC_OPT $CFLAGS
18
19NXT_EXEC_LINK =		$NXT_EXEC_LINK $NXT_LD_OPT
20NXT_SHARED_LOCAL_LINK =	$NXT_SHARED_LOCAL_LINK $NXT_LD_OPT
21NXT_MODULE_LINK =	$NXT_MODULE_LINK $NXT_LD_OPT
22
23.PHONY:			$NXT_BIN
24$NXT_BIN:		$NXT_BUILD_DIR/$NXT_BIN
25
26all:			$NXT_BIN
27
28END
29
30
31# The include paths list.
32
33$echo -n "NXT_LIB_INCS =" >> $NXT_MAKEFILE
34
35for nxt_inc in src $NXT_BUILD_DIR
36do
37    $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE
38done
39
40$echo >> $NXT_MAKEFILE
41$echo >> $NXT_MAKEFILE
42
43
44# The include files dependences list.
45
46$echo "NXT_LIB_DEPS = \\" >> $NXT_MAKEFILE
47
48for nxt_dep in $NXT_LIB_DEPS $NXT_LIB_UNIT_TEST_DEPS $NXT_AUTO_CONFIG_H
49do
50    $echo "	$nxt_dep \\" >> $NXT_MAKEFILE
51done
52
53$echo >> $NXT_MAKEFILE
54$echo >> $NXT_MAKEFILE
55
56
57# Library object files list.
58
59$echo "NXT_LIB_OBJS = \\" >> $NXT_MAKEFILE
60
61for nxt_src in $NXT_LIB_SRCS
62do
63    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
64    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
65done
66
67$echo >> $NXT_MAKEFILE
68
69
70# Shared and static library.
71
72cat << END >> $NXT_MAKEFILE
73
74libnxt:	$NXT_BUILD_DIR/$NXT_LIB_SHARED $NXT_BUILD_DIR/$NXT_LIB_STATIC
75
76$NXT_BUILD_DIR/$NXT_LIB_SHARED:	\$(NXT_LIB_OBJS)
77	\$(NXT_SHARED_LOCAL_LINK) -o $NXT_BUILD_DIR/$NXT_LIB_SHARED \\
78		\$(NXT_LIB_OBJS) \\
79		$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
80
81$NXT_BUILD_DIR/$NXT_LIB_STATIC:	\$(NXT_LIB_OBJS)
82	$NXT_STATIC_LINK $NXT_BUILD_DIR/$NXT_LIB_STATIC \\
83		\$(NXT_LIB_OBJS)
84
85END
86
87
88# Object files.
89
90for nxt_src in $NXT_LIB_SRCS $NXT_LIB_UNIT_TEST_SRCS
91do
92    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
93    cat << END >> $NXT_MAKEFILE
94
95$NXT_BUILD_DIR/$nxt_obj: $nxt_src \$(NXT_LIB_DEPS)
96	\$(CC) -c \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
97	-o $NXT_BUILD_DIR/$nxt_obj \\
98	$nxt_src
99END
100
101done
102
103$echo >> $NXT_MAKEFILE
104
105
106# Unit test object files list.
107
108$echo "NXT_LIB_UNIT_TEST_OBJS = \\" >> $NXT_MAKEFILE
109
110for nxt_src in $NXT_LIB_UNIT_TEST_SRCS
111do
112    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
113    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
114done
115
116
117# Unit test and utf8 test executables.
118
119cat << END >> $NXT_MAKEFILE
120
121$NXT_BUILD_DIR/lib_unit_test: \$(NXT_LIB_UNIT_TEST_OBJS) \\
122			$NXT_BUILD_DIR/$NXT_LIB_STATIC \$(NXT_LIB_DEPS)
123	\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/lib_unit_test \\
124		\$(CFLAGS) \$(NXT_LIB_UNIT_TEST_OBJS) \\
125		$NXT_BUILD_DIR/$NXT_LIB_STATIC \\
126		$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
127
128$NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
129			$NXT_BUILD_DIR/$NXT_LIB_STATIC \$(NXT_LIB_DEPS)
130	\$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
131		-o $NXT_BUILD_DIR/utf8_file_name_test \\
132		$NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
133		$NXT_BUILD_DIR/$NXT_LIB_STATIC \\
134		$NXT_LD_OPT $NXT_LIBM $NXT_LIBS
135
136END
137
138
139if [ $NXT_LIB_UNIT_TEST = YES ]; then
140    NXT_UNIT_TEST_TARGETS="$NXT_UNIT_TEST_TARGETS lib_test"
141fi
142
143
144NXT_MAKE_INCS="src $NXT_BUILD_DIR"
145NXT_MAKE_DEPS="\$(NXT_LIB_DEPS) $NXT_DEPS"
146NXT_MAKE_SRCS="$NXT_SRCS"
147
148
149# The include pathes list.
150
151$echo -n "NXT_INCS =" >> $NXT_MAKEFILE
152
153for nxt_inc in $NXT_MAKE_INCS
154do
155    $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE
156done
157
158$echo >> $NXT_MAKEFILE
159$echo >> $NXT_MAKEFILE
160
161
162# The include files dependences list.
163
164$echo "NXT_DEPS = \\" >> $NXT_MAKEFILE
165
166for nxt_dep in $NXT_MAKE_DEPS
167do
168    $echo "	$nxt_dep \\" >> $NXT_MAKEFILE
169done
170
171$echo >> $NXT_MAKEFILE
172$echo >> $NXT_MAKEFILE
173
174
175# Object files list.
176
177$echo "NXT_OBJS = \\" >> $NXT_MAKEFILE
178
179for nxt_src in $NXT_MAKE_SRCS
180do
181    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
182    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
183done
184
185$echo >> $NXT_MAKEFILE
186
187
188# nginext executable.
189
190cat << END >> $NXT_MAKEFILE
191
192$NXT_BUILD_DIR/$NXT_BIN:	$NXT_BUILD_DIR/$NXT_LIB_STATIC \\
193				\$(NXT_OBJS)
194	\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/$NXT_BIN \$(CFLAGS) \\
195		\$(NXT_OBJS) $NXT_BUILD_DIR/$NXT_LIB_STATIC \\
196		$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
197
198END
199
200
201# nginext object files.
202
203for nxt_src in $NXT_MAKE_SRCS
204do
205    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
206    cat << END >> $NXT_MAKEFILE
207
208$NXT_BUILD_DIR/$nxt_obj:	$nxt_src \$(NXT_DEPS)
209	\$(CC) -c \$(CFLAGS) \$(NXT_INCS) \\
210		$NXT_LIB_AUX_CFLAGS \\
211		-o $NXT_BUILD_DIR/$nxt_obj \\
212		$nxt_src
213END
214
215done
216
217
218# Makefile.
219# *.dSYM is MacOSX Clang debug information.
220
221cat << END > Makefile
222
223include $NXT_MAKEFILE
224
225.PHONY:		lib_test
226lib_test:	$NXT_BUILD_DIR/lib_unit_test $NXT_BUILD_DIR/utf8_file_name_test
227
228clean:
229		rm -rf $NXT_BUILD_DIR *.dSYM Makefile
230
231END
232