make 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. # Copyright (C) Igor Sysoev
  2. echo "creating $NGX_MAKEFILE"
  3. mkdir -p $NGX_OBJS/src/core $NGX_OBJS/src/event $NGX_OBJS/src/event/modules \
  4. $NGX_OBJS/src/os/unix $NGX_OBJS/src/os/win32 \
  5. $NGX_OBJS/src/http $NGX_OBJS/src/http/modules \
  6. $NGX_OBJS/src/http/modules/perl \
  7. $NGX_OBJS/src/mail \
  8. $NGX_OBJS/src/misc
  9. ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
  10. ngx_use_pch=`echo $NGX_USE_PCH | sed -e "s/\//$ngx_regex_dirsep/g"`
  11. cat << END > $NGX_MAKEFILE
  12. CC = $CC
  13. CFLAGS = $CFLAGS
  14. CPP = $CPP
  15. LINK = $LINK
  16. END
  17. if test -n "$NGX_PERL_CFLAGS"; then
  18. echo NGX_PERL_CFLAGS = $NGX_PERL_CFLAGS >> $NGX_MAKEFILE
  19. echo NGX_PM_CFLAGS = $NGX_PM_CFLAGS >> $NGX_MAKEFILE
  20. fi
  21. # ALL_INCS, required by the addons and by OpenWatcom C precompiled headers
  22. ngx_incs=`echo $CORE_INCS $NGX_OBJS $HTTP_INCS $MAIL_INCS\
  23. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
  24. -e "s/\//$ngx_regex_dirsep/g"`
  25. cat << END >> $NGX_MAKEFILE
  26. ALL_INCS = $ngx_include_opt$ngx_incs
  27. END
  28. ngx_all_srcs="$CORE_SRCS"
  29. # the core dependences and include pathes
  30. ngx_deps=`echo $CORE_DEPS $NGX_AUTO_CONFIG_H $NGX_PCH \
  31. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
  32. -e "s/\//$ngx_regex_dirsep/g"`
  33. ngx_incs=`echo $CORE_INCS $NGX_OBJS \
  34. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
  35. -e "s/\//$ngx_regex_dirsep/g"`
  36. cat << END >> $NGX_MAKEFILE
  37. CORE_DEPS = $ngx_deps
  38. CORE_INCS = $ngx_include_opt$ngx_incs
  39. END
  40. # the http dependences and include pathes
  41. if [ $HTTP = YES ]; then
  42. ngx_all_srcs="$ngx_all_srcs $HTTP_SRCS"
  43. ngx_deps=`echo $HTTP_DEPS \
  44. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
  45. -e "s/\//$ngx_regex_dirsep/g"`
  46. ngx_incs=`echo $HTTP_INCS \
  47. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
  48. -e "s/\//$ngx_regex_dirsep/g"`
  49. cat << END >> $NGX_MAKEFILE
  50. HTTP_DEPS = $ngx_deps
  51. HTTP_INCS = $ngx_include_opt$ngx_incs
  52. END
  53. fi
  54. # the mail dependences and include pathes
  55. if [ $MAIL = YES ]; then
  56. ngx_all_srcs="$ngx_all_srcs $MAIL_SRCS"
  57. ngx_deps=`echo $MAIL_DEPS \
  58. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
  59. -e "s/\//$ngx_regex_dirsep/g"`
  60. ngx_incs=`echo $MAIL_INCS \
  61. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
  62. -e "s/\//$ngx_regex_dirsep/g"`
  63. cat << END >> $NGX_MAKEFILE
  64. MAIL_DEPS = $ngx_deps
  65. MAIL_INCS = $ngx_include_opt$ngx_incs
  66. END
  67. fi
  68. ngx_all_srcs="$ngx_all_srcs $NGX_MISC_SRCS"
  69. if test -n "$NGX_ADDON_SRCS"; then
  70. cat << END >> $NGX_MAKEFILE
  71. ADDON_DEPS = \$(CORE_DEPS) $NGX_ADDON_DEPS
  72. END
  73. fi
  74. # nginx
  75. ngx_all_srcs=`echo $ngx_all_srcs | sed -e "s/\//$ngx_regex_dirsep/g"`
  76. for ngx_src in $NGX_ADDON_SRCS
  77. do
  78. ngx_obj="addon/`basename \`dirname $ngx_src\``"
  79. test -d $NGX_OBJS/$ngx_obj || mkdir -p $NGX_OBJS/$ngx_obj
  80. ngx_obj=`echo $ngx_obj/\`basename $ngx_src\` \
  81. | sed -e "s/\//$ngx_regex_dirsep/g"`
  82. ngx_all_srcs="$ngx_all_srcs $ngx_obj"
  83. done
  84. ngx_all_objs=`echo $ngx_all_srcs \
  85. | sed -e "s#\([^ ]*\.\)cpp#$NGX_OBJS\/\1$ngx_objext#g" \
  86. -e "s#\([^ ]*\.\)cc#$NGX_OBJS\/\1$ngx_objext#g" \
  87. -e "s#\([^ ]*\.\)c#$NGX_OBJS\/\1$ngx_objext#g" \
  88. -e "s#\([^ ]*\.\)S#$NGX_OBJS\/\1$ngx_objext#g"`
  89. ngx_modules_c=`echo $NGX_MODULES_C | sed -e "s/\//$ngx_regex_dirsep/g"`
  90. ngx_modules_obj=`echo $ngx_modules_c | sed -e "s/\(.*\.\)c/\1$ngx_objext/"`
  91. if test -n "$NGX_RES"; then
  92. ngx_res=$NGX_RES
  93. else
  94. ngx_res="$NGX_RC $NGX_ICONS"
  95. ngx_rcc=`echo $NGX_RCC | sed -e "s/\//$ngx_regex_dirsep/g"`
  96. fi
  97. ngx_deps=`echo $ngx_all_objs $ngx_modules_obj $ngx_res $LINK_DEPS \
  98. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
  99. -e "s/\//$ngx_regex_dirsep/g"`
  100. ngx_objs=`echo $ngx_all_objs $ngx_modules_obj \
  101. | sed -e "s/ *\([^ ][^ ]*\)/$ngx_long_regex_cont\1/g" \
  102. -e "s/\//$ngx_regex_dirsep/g"`
  103. if test -n "$NGX_LD_OPT$CORE_LIBS"; then
  104. ngx_libs=`echo $NGX_LD_OPT $CORE_LIBS \
  105. | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`
  106. fi
  107. ngx_link=${CORE_LINK:+`echo $CORE_LINK \
  108. | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}
  109. cat << END >> $NGX_MAKEFILE
  110. $NGX_OBJS${ngx_dirsep}nginx${ngx_binext}: $ngx_deps$ngx_spacer
  111. \$(LINK) ${ngx_long_start}${ngx_binout}$NGX_OBJS${ngx_dirsep}nginx$ngx_long_cont$ngx_objs$ngx_libs$ngx_link
  112. $ngx_rcc
  113. ${ngx_long_end}
  114. END
  115. # ngx_modules.c
  116. if test -n "$NGX_PCH"; then
  117. ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
  118. else
  119. ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS)"
  120. fi
  121. cat << END >> $NGX_MAKEFILE
  122. $ngx_modules_obj: \$(CORE_DEPS)$ngx_cont$ngx_modules_c
  123. $ngx_cc$ngx_tab$ngx_objout$ngx_modules_obj$ngx_tab$ngx_modules_c$NGX_AUX
  124. END
  125. # the core sources
  126. for ngx_src in $CORE_SRCS
  127. do
  128. ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
  129. ngx_obj=`echo $ngx_src \
  130. | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
  131. -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
  132. -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
  133. -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
  134. cat << END >> $NGX_MAKEFILE
  135. $ngx_obj: \$(CORE_DEPS)$ngx_cont$ngx_src
  136. $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
  137. END
  138. done
  139. # the http sources
  140. if [ $HTTP = YES ]; then
  141. if test -n "$NGX_PCH"; then
  142. ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
  143. else
  144. ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)"
  145. ngx_perl_cc="\$(CC) $ngx_compile_opt \$(NGX_PERL_CFLAGS) "
  146. ngx_perl_cc="$ngx_perl_cc \$(CORE_INCS) \$(HTTP_INCS)"
  147. fi
  148. for ngx_source in $HTTP_SRCS
  149. do
  150. ngx_src=`echo $ngx_source | sed -e "s/\//$ngx_regex_dirsep/g"`
  151. ngx_obj=`echo $ngx_src \
  152. | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
  153. -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
  154. -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
  155. -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
  156. if [ $ngx_source = src/http/modules/perl/ngx_http_perl_module.c ]; then
  157. cat << END >> $NGX_MAKEFILE
  158. $ngx_obj: \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src
  159. $ngx_perl_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
  160. END
  161. else
  162. cat << END >> $NGX_MAKEFILE
  163. $ngx_obj: \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src
  164. $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
  165. END
  166. fi
  167. done
  168. fi
  169. # the mail sources
  170. if [ $MAIL = YES ]; then
  171. if test -n "$NGX_PCH"; then
  172. ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
  173. else
  174. ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(MAIL_INCS)"
  175. fi
  176. for ngx_src in $MAIL_SRCS
  177. do
  178. ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
  179. ngx_obj=`echo $ngx_src \
  180. | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
  181. -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
  182. -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
  183. -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
  184. cat << END >> $NGX_MAKEFILE
  185. $ngx_obj: \$(CORE_DEPS) \$(MAIL_DEPS)$ngx_cont$ngx_src
  186. $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
  187. END
  188. done
  189. fi
  190. # the misc sources
  191. if test -n "$NGX_MISC_SRCS"; then
  192. ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
  193. for ngx_src in $NGX_MISC_SRCS
  194. do
  195. ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
  196. ngx_obj=`echo $ngx_src \
  197. | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
  198. -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
  199. -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
  200. -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
  201. cat << END >> $NGX_MAKEFILE
  202. $ngx_obj: \$(CORE_DEPS) $ngx_cont$ngx_src
  203. $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
  204. END
  205. done
  206. fi
  207. # the addons sources
  208. if test -n "$NGX_ADDON_SRCS"; then
  209. ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
  210. for ngx_src in $NGX_ADDON_SRCS
  211. do
  212. ngx_obj="addon/`basename \`dirname $ngx_src\``"
  213. ngx_obj=`echo $ngx_obj/\`basename $ngx_src\` \
  214. | sed -e "s/\//$ngx_regex_dirsep/g"`
  215. ngx_obj=`echo $ngx_obj \
  216. | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
  217. -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
  218. -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
  219. -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
  220. ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
  221. cat << END >> $NGX_MAKEFILE
  222. $ngx_obj: \$(ADDON_DEPS)$ngx_cont$ngx_src
  223. $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
  224. END
  225. done
  226. fi
  227. # the addons config.make
  228. if test -n "$NGX_ADDONS"; then
  229. for ngx_addon_dir in $NGX_ADDONS
  230. do
  231. if test -f $ngx_addon_dir/config.make; then
  232. . $ngx_addon_dir/config.make
  233. fi
  234. done
  235. fi
  236. # Win32 resource file
  237. if test -n "$NGX_RES"; then
  238. ngx_res=`echo "$NGX_RES: $NGX_RC $NGX_ICONS" \
  239. | sed -e "s/\//$ngx_regex_dirsep/g"`
  240. ngx_rcc=`echo $NGX_RCC | sed -e "s/\//$ngx_regex_dirsep/g"`
  241. cat << END >> $NGX_MAKEFILE
  242. $ngx_res
  243. $ngx_rcc
  244. END
  245. fi
  246. # the precompiled headers
  247. if test -n "$NGX_PCH"; then
  248. echo "#include <ngx_config.h>" > $NGX_OBJS/ngx_pch.c
  249. ngx_pch="src/core/ngx_config.h $OS_CONFIG $NGX_OBJS/ngx_auto_config.h"
  250. ngx_pch=`echo "$NGX_PCH: $ngx_pch" | sed -e "s/\//$ngx_regex_dirsep/g"`
  251. ngx_src="\$(CC) \$(CFLAGS) $NGX_BUILD_PCH $ngx_compile_opt \$(ALL_INCS)"
  252. ngx_src="$ngx_src $ngx_objout$NGX_OBJS/ngx_pch.obj $NGX_OBJS/ngx_pch.c"
  253. ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
  254. cat << END >> $NGX_MAKEFILE
  255. $ngx_pch
  256. $ngx_src
  257. END
  258. fi