make 10 KB

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