Fix work keepalive and rewrite to named location
[nginx-catap.git] / auto / make
blob27f71ecdccb2cb25f28cd04dadb66a54bc2987ef
2 # Copyright (C) Igor Sysoev
5 echo "creating $NGX_MAKEFILE"
7 mkdir -p $NGX_OBJS/src/core $NGX_OBJS/src/event $NGX_OBJS/src/event/modules \
8          $NGX_OBJS/src/os/unix $NGX_OBJS/src/os/win32 \
9          $NGX_OBJS/src/http $NGX_OBJS/src/http/modules \
10          $NGX_OBJS/src/http/modules/perl \
11          $NGX_OBJS/src/mail \
12          $NGX_OBJS/src/misc
15 ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
16 ngx_use_pch=`echo $NGX_USE_PCH | sed -e "s/\//$ngx_regex_dirsep/g"`
19 cat << END                                                     > $NGX_MAKEFILE
21 CC =    $CC
22 CFLAGS = $CFLAGS
23 CPP =   $CPP
24 LINK =  $LINK
26 END
29 if test -n "$NGX_PERL_CFLAGS"; then
30     echo NGX_PERL_CFLAGS = $NGX_PERL_CFLAGS                   >> $NGX_MAKEFILE
31     echo NGX_PM_CFLAGS = $NGX_PM_CFLAGS                       >> $NGX_MAKEFILE
35 # ALL_INCS, required by the addons and by OpenWatcom C precompiled headers
37 ngx_incs=`echo $CORE_INCS $NGX_OBJS $HTTP_INCS $MAIL_INCS\
38     | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
39           -e "s/\//$ngx_regex_dirsep/g"`
41 cat << END                                                    >> $NGX_MAKEFILE
43 ALL_INCS = $ngx_include_opt$ngx_incs
45 END
48 ngx_all_srcs="$CORE_SRCS"
51 # the core dependences and include pathes
53 ngx_deps=`echo $CORE_DEPS $NGX_AUTO_CONFIG_H $NGX_PCH \
54     | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
55           -e "s/\//$ngx_regex_dirsep/g"`
57 ngx_incs=`echo $CORE_INCS $NGX_OBJS \
58     | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
59           -e "s/\//$ngx_regex_dirsep/g"`
61 cat << END                                                    >> $NGX_MAKEFILE
63 CORE_DEPS = $ngx_deps
66 CORE_INCS = $ngx_include_opt$ngx_incs
68 END
71 # the http dependences and include pathes
73 if [ $HTTP = YES ]; then
75     ngx_all_srcs="$ngx_all_srcs $HTTP_SRCS"
77     ngx_deps=`echo $HTTP_DEPS \
78         | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
79               -e "s/\//$ngx_regex_dirsep/g"`
81     ngx_incs=`echo $HTTP_INCS \
82         | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
83               -e "s/\//$ngx_regex_dirsep/g"`
85     cat << END                                                >> $NGX_MAKEFILE
87 HTTP_DEPS = $ngx_deps
90 HTTP_INCS = $ngx_include_opt$ngx_incs
92 END
97 # the mail dependences and include pathes
99 if [ $MAIL = YES ]; then
101     ngx_all_srcs="$ngx_all_srcs $MAIL_SRCS"
103     ngx_deps=`echo $MAIL_DEPS \
104         | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
105               -e "s/\//$ngx_regex_dirsep/g"`
107     ngx_incs=`echo $MAIL_INCS \
108         | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
109               -e "s/\//$ngx_regex_dirsep/g"`
111     cat << END                                                >> $NGX_MAKEFILE
113 MAIL_DEPS = $ngx_deps
116 MAIL_INCS = $ngx_include_opt$ngx_incs
123 ngx_all_srcs="$ngx_all_srcs $NGX_MISC_SRCS"
126 if test -n "$NGX_ADDON_SRCS"; then
128 cat << END                                                >> $NGX_MAKEFILE
130 ADDON_DEPS = \$(CORE_DEPS) $NGX_ADDON_DEPS
137 # nginx
139 ngx_all_srcs=`echo $ngx_all_srcs | sed -e "s/\//$ngx_regex_dirsep/g"`
141 for ngx_src in $NGX_ADDON_SRCS
143     ngx_obj="addon/`basename \`dirname $ngx_src\``"
145     test -d $NGX_OBJS/$ngx_obj || mkdir -p $NGX_OBJS/$ngx_obj
147     ngx_obj=`echo $ngx_obj/\`basename $ngx_src\` \
148         | sed -e "s/\//$ngx_regex_dirsep/g"`
150     ngx_all_srcs="$ngx_all_srcs $ngx_obj"
151 done
153 ngx_all_objs=`echo $ngx_all_srcs \
154     | sed -e "s#\([^ ]*\.\)cpp#$NGX_OBJS\/\1$ngx_objext#g" \
155           -e "s#\([^ ]*\.\)cc#$NGX_OBJS\/\1$ngx_objext#g" \
156           -e "s#\([^ ]*\.\)c#$NGX_OBJS\/\1$ngx_objext#g" \
157           -e "s#\([^ ]*\.\)S#$NGX_OBJS\/\1$ngx_objext#g"`
159 ngx_modules_c=`echo $NGX_MODULES_C | sed -e "s/\//$ngx_regex_dirsep/g"`
161 ngx_modules_obj=`echo $ngx_modules_c | sed -e "s/\(.*\.\)c/\1$ngx_objext/"`
164 if test -n "$NGX_RES"; then
165    ngx_res=$NGX_RES
166 else
167    ngx_res="$NGX_RC $NGX_ICONS"
168    ngx_rcc=`echo $NGX_RCC | sed -e "s/\//$ngx_regex_dirsep/g"`
171 ngx_deps=`echo $ngx_all_objs $ngx_modules_obj $ngx_res $LINK_DEPS \
172     | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
173           -e "s/\//$ngx_regex_dirsep/g"`
175 ngx_objs=`echo $ngx_all_objs $ngx_modules_obj \
176     | sed -e "s/  *\([^ ][^ ]*\)/$ngx_long_regex_cont\1/g" \
177           -e "s/\//$ngx_regex_dirsep/g"`
179 if test -n "$NGX_LD_OPT$CORE_LIBS"; then
180     ngx_libs=`echo $NGX_LD_OPT $CORE_LIBS \
181         | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`
184 ngx_link=${CORE_LINK:+`echo $CORE_LINK \
185     | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}
188 cat << END                                                    >> $NGX_MAKEFILE
190 $NGX_OBJS${ngx_dirsep}nginx${ngx_binext}:       $ngx_deps$ngx_spacer
191         \$(LINK) ${ngx_long_start}${ngx_binout}$NGX_OBJS${ngx_dirsep}nginx$ngx_long_cont$ngx_objs$ngx_libs$ngx_link
192         $ngx_rcc
193 ${ngx_long_end}
197 # ngx_modules.c
199 if test -n "$NGX_PCH"; then
200     ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
201 else
202     ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS)"
205 cat << END                                                    >> $NGX_MAKEFILE
207 $ngx_modules_obj:       \$(CORE_DEPS)$ngx_cont$ngx_modules_c
208         $ngx_cc$ngx_tab$ngx_objout$ngx_modules_obj$ngx_tab$ngx_modules_c$NGX_AUX
213 # the core sources
215 for ngx_src in $CORE_SRCS
217     ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
218     ngx_obj=`echo $ngx_src \
219         | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
220               -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
221               -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
222               -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
224     cat << END                                                >> $NGX_MAKEFILE
226 $ngx_obj:       \$(CORE_DEPS)$ngx_cont$ngx_src
227         $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
231 done
234 # the http sources
236 if [ $HTTP = YES ]; then
238     if test -n "$NGX_PCH"; then
239         ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
240     else
241         ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)"
242         ngx_perl_cc="\$(CC) $ngx_compile_opt \$(NGX_PERL_CFLAGS) "
243         ngx_perl_cc="$ngx_perl_cc \$(CORE_INCS) \$(HTTP_INCS)"
244     fi
246     for ngx_source in $HTTP_SRCS
247     do
248         ngx_src=`echo $ngx_source | sed -e "s/\//$ngx_regex_dirsep/g"`
249         ngx_obj=`echo $ngx_src \
250             | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
251                   -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
252                   -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
253                   -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
255         if [ $ngx_source = src/http/modules/perl/ngx_http_perl_module.c ]; then
257             cat << END                                        >> $NGX_MAKEFILE
259 $ngx_obj:       \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src
260         $ngx_perl_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
263         else
265             cat << END                                        >> $NGX_MAKEFILE
267 $ngx_obj:       \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src
268         $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
272         fi
273      done
278 # the mail sources
280 if [ $MAIL = YES ]; then
282     if test -n "$NGX_PCH"; then
283         ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
284     else
285         ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(MAIL_INCS)"
286     fi
288     for ngx_src in $MAIL_SRCS
289     do
290         ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
291         ngx_obj=`echo $ngx_src \
292             | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
293                   -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
294                   -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
295                   -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
297         cat << END                                            >> $NGX_MAKEFILE
299 $ngx_obj:       \$(CORE_DEPS) \$(MAIL_DEPS)$ngx_cont$ngx_src
300         $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
303      done
308 # the misc sources
310 if test -n "$NGX_MISC_SRCS"; then
312     ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
314     for ngx_src in $NGX_MISC_SRCS
315     do
316         ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
317         ngx_obj=`echo $ngx_src \
318             | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
319                   -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
320                   -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
321                   -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
323         cat << END                                            >> $NGX_MAKEFILE
325 $ngx_obj:       \$(CORE_DEPS) $ngx_cont$ngx_src
326         $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
329      done
334 # the addons sources
336 if test -n "$NGX_ADDON_SRCS"; then
338     ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
340     for ngx_src in $NGX_ADDON_SRCS
341     do
342         ngx_obj="addon/`basename \`dirname $ngx_src\``"
344         ngx_obj=`echo $ngx_obj/\`basename $ngx_src\` \
345             | sed -e "s/\//$ngx_regex_dirsep/g"`
347         ngx_obj=`echo $ngx_obj \
348             | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
349                   -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
350                   -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
351                   -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
353         ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
355         cat << END                                            >> $NGX_MAKEFILE
357 $ngx_obj:       \$(ADDON_DEPS)$ngx_cont$ngx_src
358         $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
361      done
366 # the addons config.make
368 if test -n "$NGX_ADDONS"; then
370     for ngx_addon_dir in $NGX_ADDONS
371     do
372         if test -f $ngx_addon_dir/config.make; then
373             . $ngx_addon_dir/config.make
374         fi
375     done
379 # Win32 resource file
381 if test -n "$NGX_RES"; then
383     ngx_res=`echo "$NGX_RES:    $NGX_RC $NGX_ICONS" \
384                  | sed -e "s/\//$ngx_regex_dirsep/g"`
385     ngx_rcc=`echo $NGX_RCC | sed -e "s/\//$ngx_regex_dirsep/g"`
387     cat << END                                                >> $NGX_MAKEFILE
389 $ngx_res
390         $ngx_rcc
397 # the precompiled headers
399 if test -n "$NGX_PCH"; then
400     echo "#include <ngx_config.h>" > $NGX_OBJS/ngx_pch.c
402     ngx_pch="src/core/ngx_config.h $OS_CONFIG $NGX_OBJS/ngx_auto_config.h"
403     ngx_pch=`echo "$NGX_PCH:    $ngx_pch" | sed -e "s/\//$ngx_regex_dirsep/g"`
405     ngx_src="\$(CC) \$(CFLAGS) $NGX_BUILD_PCH $ngx_compile_opt \$(ALL_INCS)"
406     ngx_src="$ngx_src $ngx_objout$NGX_OBJS/ngx_pch.obj $NGX_OBJS/ngx_pch.c"
407     ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
409     cat << END                                                >> $NGX_MAKEFILE
411 $ngx_pch
412         $ngx_src