make 11 KB

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