xref: /unit/auto/make (revision 0:a63ceefd6ab0)
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 = 		$CFLAGS $NXT_CFLAGS $NXT_CC_OPT
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
23END
24
25
26# The include paths list.
27
28$echo -n "NXT_LIB_INCS =" >> $NXT_MAKEFILE
29
30for nxt_inc in src $NXT_BUILD_DIR
31do
32    $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE
33done
34
35$echo >> $NXT_MAKEFILE
36$echo >> $NXT_MAKEFILE
37
38
39# The include files dependences list.
40
41$echo "NXT_LIB_DEPS = \\" >> $NXT_MAKEFILE
42
43for nxt_dep in $NXT_LIB_DEPS $NXT_LIB_UNIT_TEST_DEPS $NXT_AUTO_CONFIG_H
44do
45    $echo "	$nxt_dep \\" >> $NXT_MAKEFILE
46done
47
48$echo >> $NXT_MAKEFILE
49$echo >> $NXT_MAKEFILE
50
51
52# Library object files list.
53
54$echo "NXT_LIB_OBJS = \\" >> $NXT_MAKEFILE
55
56for nxt_src in $NXT_LIB_SRCS
57do
58    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
59    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
60done
61
62$echo >> $NXT_MAKEFILE
63
64
65# Shared and static library.
66
67cat << END >> $NXT_MAKEFILE
68
69libnxt:	$NXT_BUILD_DIR/$NXT_LIB_SHARED $NXT_BUILD_DIR/$NXT_LIB_STATIC
70
71$NXT_BUILD_DIR/$NXT_LIB_SHARED:	\$(NXT_LIB_OBJS)
72	\$(NXT_SHARED_LOCAL_LINK) -o $NXT_BUILD_DIR/$NXT_LIB_SHARED \\
73		\$(NXT_LIB_OBJS) \\
74		$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
75
76$NXT_BUILD_DIR/$NXT_LIB_STATIC:	\$(NXT_LIB_OBJS)
77	$NXT_STATIC_LINK $NXT_BUILD_DIR/$NXT_LIB_STATIC \\
78		\$(NXT_LIB_OBJS)
79
80END
81
82
83# Object files.
84
85for nxt_src in $NXT_LIB_SRCS $NXT_LIB_UNIT_TEST_SRCS
86do
87    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
88    cat << END >> $NXT_MAKEFILE
89
90$NXT_BUILD_DIR/$nxt_obj: $nxt_src \$(NXT_LIB_DEPS)
91	\$(CC) -c \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
92	-o $NXT_BUILD_DIR/$nxt_obj \\
93	$nxt_src
94END
95
96done
97
98$echo >> $NXT_MAKEFILE
99
100
101# Unit test object files list.
102
103$echo "NXT_LIB_UNIT_TEST_OBJS = \\" >> $NXT_MAKEFILE
104
105for nxt_src in $NXT_LIB_UNIT_TEST_SRCS
106do
107    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
108    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
109done
110
111
112# Unit test and utf8 test executables.
113
114cat << END >> $NXT_MAKEFILE
115
116$NXT_BUILD_DIR/lib_unit_test: \$(NXT_LIB_UNIT_TEST_OBJS) \\
117			$NXT_BUILD_DIR/$NXT_LIB_STATIC \$(NXT_LIB_DEPS)
118	\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/lib_unit_test \\
119		\$(NXT_LIB_UNIT_TEST_OBJS) \\
120		$NXT_BUILD_DIR/$NXT_LIB_STATIC \\
121		$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
122
123$NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
124			$NXT_BUILD_DIR/$NXT_LIB_STATIC \$(NXT_LIB_DEPS)
125	\$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
126		-o $NXT_BUILD_DIR/utf8_file_name_test \\
127		$NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
128		$NXT_BUILD_DIR/$NXT_LIB_STATIC \\
129		$NXT_LD_OPT $NXT_LIBM $NXT_LIBS
130
131END
132
133
134if [ $NXT_LIB_UNIT_TEST = YES ]; then
135    NXT_UNIT_TEST_TARGETS="$NXT_UNIT_TEST_TARGETS lib_test"
136fi
137
138
139NXT_MAKE_INCS="src $NXT_BUILD_DIR"
140NXT_MAKE_DEPS="\$(NXT_LIB_DEPS) $NXT_DEPS"
141NXT_MAKE_SRCS="$NXT_SRCS"
142
143
144# The include pathes list.
145
146$echo -n "NXT_INCS =" >> $NXT_MAKEFILE
147
148for nxt_inc in $NXT_MAKE_INCS
149do
150    $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE
151done
152
153$echo >> $NXT_MAKEFILE
154$echo >> $NXT_MAKEFILE
155
156
157# The include files dependences list.
158
159$echo "NXT_DEPS = \\" >> $NXT_MAKEFILE
160
161for nxt_dep in $NXT_MAKE_DEPS
162do
163    $echo "	$nxt_dep \\" >> $NXT_MAKEFILE
164done
165
166$echo >> $NXT_MAKEFILE
167$echo >> $NXT_MAKEFILE
168
169
170# Object files list.
171
172nxt_modules_obj=`$echo $NXT_MODULES_SRC | sed -e "s/\.c$/\.o/"`
173
174$echo "NXT_OBJS = \\" >> $NXT_MAKEFILE
175
176for nxt_src in $NXT_MAKE_SRCS $NXT_MODULES_SRCS
177do
178    nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
179    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
180done
181
182$echo "	$nxt_modules_obj" >> $NXT_MAKEFILE
183$echo >> $NXT_MAKEFILE
184
185
186# nginext executable.
187
188NXT_BIN=nginext
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 \\
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# nxt_modules.c.
219
220cat << END >> $NXT_MAKEFILE
221
222$nxt_modules_obj:	$NXT_MODULES_SRC \$(NXT_DEPS)
223	\$(CC) -c \$(CFLAGS) \$(NXT_INCS) \\
224	 	$NXT_LIB_AUX_CFLAGS \\
225		-o $nxt_modules_obj \\
226		$NXT_MODULES_SRC
227END
228
229
230if [ $NXT_PYTHON_MODULE != NO ]; then
231    . auto/modules/python/make
232fi
233
234
235# Makefile.
236# *.dSYM is MacOSX Clang debug information.
237
238cat << END > Makefile
239
240all:	libnxt $NXT_BIN
241
242libnxt:
243	make -f $NXT_MAKEFILE libnxt
244
245lib_test:
246	make -f $NXT_MAKEFILE $NXT_BUILD_DIR/lib_unit_test
247	make -f $NXT_MAKEFILE $NXT_BUILD_DIR/utf8_file_name_test
248
249clean:
250	rm -rf $NXT_BUILD_DIR *.dSYM Makefile
251
252$NXT_BIN:
253	make -f $NXT_MAKEFILE $NXT_BUILD_DIR/$NXT_BIN
254
255END
256