unix 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. # Copyright (C) Igor Sysoev
  2. # Copyright (C) Nginx, Inc.
  3. NGX_USER=${NGX_USER:-nobody}
  4. if [ -z "$NGX_GROUP" ]; then
  5. if [ $NGX_USER = nobody ]; then
  6. if grep nobody /etc/group 2>&1 >/dev/null; then
  7. echo "checking for nobody group ... found"
  8. NGX_GROUP=nobody
  9. else
  10. echo "checking for nobody group ... not found"
  11. if grep nogroup /etc/group 2>&1 >/dev/null; then
  12. echo "checking for nogroup group ... found"
  13. NGX_GROUP=nogroup
  14. else
  15. echo "checking for nogroup group ... not found"
  16. NGX_GROUP=nobody
  17. fi
  18. fi
  19. else
  20. NGX_GROUP=$NGX_USER
  21. fi
  22. fi
  23. ngx_feature="poll()"
  24. ngx_feature_name=
  25. ngx_feature_run=no
  26. ngx_feature_incs="#include <poll.h>"
  27. ngx_feature_path=
  28. ngx_feature_libs=
  29. ngx_feature_test="int n; struct pollfd pl;
  30. pl.fd = 0;
  31. pl.events = 0;
  32. pl.revents = 0;
  33. n = poll(&pl, 1, 0);
  34. if (n == -1) return 1"
  35. . auto/feature
  36. if [ $ngx_found = no ]; then
  37. EVENT_POLL=NONE
  38. fi
  39. ngx_feature="/dev/poll"
  40. ngx_feature_name="NGX_HAVE_DEVPOLL"
  41. ngx_feature_run=no
  42. ngx_feature_incs="#include <sys/devpoll.h>"
  43. ngx_feature_path=
  44. ngx_feature_libs=
  45. ngx_feature_test="int n, dp; struct dvpoll dvp;
  46. dp = 0;
  47. dvp.dp_fds = NULL;
  48. dvp.dp_nfds = 0;
  49. dvp.dp_timeout = 0;
  50. n = ioctl(dp, DP_POLL, &dvp);
  51. if (n == -1) return 1"
  52. . auto/feature
  53. if [ $ngx_found = yes ]; then
  54. CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
  55. EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
  56. EVENT_FOUND=YES
  57. fi
  58. if test -z "$NGX_KQUEUE_CHECKED"; then
  59. ngx_feature="kqueue"
  60. ngx_feature_name="NGX_HAVE_KQUEUE"
  61. ngx_feature_run=no
  62. ngx_feature_incs="#include <sys/event.h>"
  63. ngx_feature_path=
  64. ngx_feature_libs=
  65. ngx_feature_test="(void) kqueue()"
  66. . auto/feature
  67. if [ $ngx_found = yes ]; then
  68. have=NGX_HAVE_CLEAR_EVENT . auto/have
  69. EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
  70. CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
  71. EVENT_FOUND=YES
  72. ngx_feature="kqueue's NOTE_LOWAT"
  73. ngx_feature_name="NGX_HAVE_LOWAT_EVENT"
  74. ngx_feature_run=no
  75. ngx_feature_incs="#include <sys/event.h>"
  76. ngx_feature_path=
  77. ngx_feature_libs=
  78. ngx_feature_test="struct kevent kev;
  79. kev.fflags = NOTE_LOWAT;
  80. (void) kev"
  81. . auto/feature
  82. ngx_feature="kqueue's EVFILT_TIMER"
  83. ngx_feature_name="NGX_HAVE_TIMER_EVENT"
  84. ngx_feature_run=yes
  85. ngx_feature_incs="#include <sys/event.h>
  86. #include <sys/time.h>"
  87. ngx_feature_path=
  88. ngx_feature_libs=
  89. ngx_feature_test="int kq;
  90. struct kevent kev;
  91. struct timespec ts;
  92. if ((kq = kqueue()) == -1) return 1;
  93. kev.ident = 0;
  94. kev.filter = EVFILT_TIMER;
  95. kev.flags = EV_ADD|EV_ENABLE;
  96. kev.fflags = 0;
  97. kev.data = 1000;
  98. kev.udata = 0;
  99. ts.tv_sec = 0;
  100. ts.tv_nsec = 0;
  101. if (kevent(kq, &kev, 1, &kev, 1, &ts) == -1) return 1;
  102. if (kev.flags & EV_ERROR) return 1;"
  103. . auto/feature
  104. fi
  105. fi
  106. if [ "$NGX_SYSTEM" = "NetBSD" ]; then
  107. # NetBSD 2.0 incompatibly defines kevent.udata as "intptr_t"
  108. cat << END >> $NGX_AUTO_CONFIG_H
  109. #define NGX_KQUEUE_UDATA_T
  110. END
  111. else
  112. cat << END >> $NGX_AUTO_CONFIG_H
  113. #define NGX_KQUEUE_UDATA_T (void *)
  114. END
  115. fi
  116. ngx_feature="crypt()"
  117. ngx_feature_name=
  118. ngx_feature_run=no
  119. ngx_feature_incs=
  120. ngx_feature_path=
  121. ngx_feature_libs=
  122. ngx_feature_test="crypt(\"test\", \"salt\");"
  123. . auto/feature
  124. if [ $ngx_found = no ]; then
  125. ngx_feature="crypt() in libcrypt"
  126. ngx_feature_name=
  127. ngx_feature_run=no
  128. ngx_feature_incs=
  129. ngx_feature_path=
  130. ngx_feature_libs=-lcrypt
  131. . auto/feature
  132. if [ $ngx_found = yes ]; then
  133. CRYPT_LIB="-lcrypt"
  134. fi
  135. fi
  136. ngx_feature="F_READAHEAD"
  137. ngx_feature_name="NGX_HAVE_F_READAHEAD"
  138. ngx_feature_run=no
  139. ngx_feature_incs="#include <fcntl.h>"
  140. ngx_feature_path=
  141. ngx_feature_libs=
  142. ngx_feature_test="fcntl(0, F_READAHEAD, 1);"
  143. . auto/feature
  144. ngx_feature="posix_fadvise()"
  145. ngx_feature_name="NGX_HAVE_POSIX_FADVISE"
  146. ngx_feature_run=no
  147. ngx_feature_incs="#include <fcntl.h>"
  148. ngx_feature_path=
  149. ngx_feature_libs=
  150. ngx_feature_test="posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL);"
  151. . auto/feature
  152. ngx_feature="O_DIRECT"
  153. ngx_feature_name="NGX_HAVE_O_DIRECT"
  154. ngx_feature_run=no
  155. ngx_feature_incs="#include <fcntl.h>"
  156. ngx_feature_path=
  157. ngx_feature_libs=
  158. ngx_feature_test="fcntl(0, F_SETFL, O_DIRECT);"
  159. . auto/feature
  160. if [ $ngx_found = yes -a "$NGX_SYSTEM" = "Linux" ]; then
  161. have=NGX_HAVE_ALIGNED_DIRECTIO . auto/have
  162. fi
  163. ngx_feature="F_NOCACHE"
  164. ngx_feature_name="NGX_HAVE_F_NOCACHE"
  165. ngx_feature_run=no
  166. ngx_feature_incs="#include <fcntl.h>"
  167. ngx_feature_path=
  168. ngx_feature_libs=
  169. ngx_feature_test="fcntl(0, F_NOCACHE, 1);"
  170. . auto/feature
  171. ngx_feature="directio()"
  172. ngx_feature_name="NGX_HAVE_DIRECTIO"
  173. ngx_feature_run=no
  174. ngx_feature_incs="#include <sys/types.h>
  175. #include <sys/fcntl.h>"
  176. ngx_feature_path=
  177. ngx_feature_libs=
  178. ngx_feature_test="directio(0, DIRECTIO_ON);"
  179. . auto/feature
  180. ngx_feature="statfs()"
  181. ngx_feature_name="NGX_HAVE_STATFS"
  182. ngx_feature_run=no
  183. ngx_feature_incs="$NGX_INCLUDE_SYS_PARAM_H
  184. $NGX_INCLUDE_SYS_MOUNT_H
  185. $NGX_INCLUDE_SYS_VFS_H"
  186. ngx_feature_path=
  187. ngx_feature_libs=
  188. ngx_feature_test="struct statfs fs;
  189. statfs(\".\", &fs);"
  190. . auto/feature
  191. ngx_feature="statvfs()"
  192. ngx_feature_name="NGX_HAVE_STATVFS"
  193. ngx_feature_run=no
  194. ngx_feature_incs="#include <sys/types.h>
  195. #include <sys/statvfs.h>"
  196. ngx_feature_path=
  197. ngx_feature_libs=
  198. ngx_feature_test="struct statvfs fs;
  199. statvfs(\".\", &fs);"
  200. . auto/feature
  201. ngx_feature="dlopen()"
  202. ngx_feature_name="NGX_HAVE_DLOPEN"
  203. ngx_feature_run=no
  204. ngx_feature_incs="#include <dlfcn.h>"
  205. ngx_feature_path=
  206. ngx_feature_libs=
  207. ngx_feature_test="dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); dlsym(NULL, \"\")"
  208. . auto/feature
  209. if [ $ngx_found = no ]; then
  210. ngx_feature="dlopen() in libdl"
  211. ngx_feature_libs="-ldl"
  212. . auto/feature
  213. if [ $ngx_found = yes ]; then
  214. CORE_LIBS="$CORE_LIBS -ldl"
  215. NGX_LIBDL="-ldl"
  216. fi
  217. fi
  218. ngx_feature="sched_yield()"
  219. ngx_feature_name="NGX_HAVE_SCHED_YIELD"
  220. ngx_feature_run=no
  221. ngx_feature_incs="#include <sched.h>"
  222. ngx_feature_path=
  223. ngx_feature_libs=
  224. ngx_feature_test="sched_yield()"
  225. . auto/feature
  226. if [ $ngx_found = no ]; then
  227. ngx_feature="sched_yield() in librt"
  228. ngx_feature_libs="-lrt"
  229. . auto/feature
  230. if [ $ngx_found = yes ]; then
  231. CORE_LIBS="$CORE_LIBS -lrt"
  232. fi
  233. fi
  234. ngx_feature="sched_setaffinity()"
  235. ngx_feature_name="NGX_HAVE_SCHED_SETAFFINITY"
  236. ngx_feature_run=no
  237. ngx_feature_incs="#include <sched.h>"
  238. ngx_feature_path=
  239. ngx_feature_libs=
  240. ngx_feature_test="cpu_set_t mask;
  241. CPU_ZERO(&mask);
  242. sched_setaffinity(0, sizeof(cpu_set_t), &mask)"
  243. . auto/feature
  244. ngx_feature="SO_SETFIB"
  245. ngx_feature_name="NGX_HAVE_SETFIB"
  246. ngx_feature_run=no
  247. ngx_feature_incs="#include <sys/socket.h>"
  248. ngx_feature_path=
  249. ngx_feature_libs=
  250. ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_SETFIB, NULL, 0)"
  251. . auto/feature
  252. ngx_feature="SO_REUSEPORT"
  253. ngx_feature_name="NGX_HAVE_REUSEPORT"
  254. ngx_feature_run=no
  255. ngx_feature_incs="#include <sys/socket.h>"
  256. ngx_feature_path=
  257. ngx_feature_libs=
  258. ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_REUSEPORT, NULL, 0)"
  259. . auto/feature
  260. ngx_feature="SO_ACCEPTFILTER"
  261. ngx_feature_name="NGX_HAVE_DEFERRED_ACCEPT"
  262. ngx_feature_run=no
  263. ngx_feature_incs="#include <sys/socket.h>"
  264. ngx_feature_path=
  265. ngx_feature_libs=
  266. ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_ACCEPTFILTER, NULL, 0)"
  267. . auto/feature
  268. # OpenBSD bind to any address for transparent proxying
  269. ngx_feature="SO_BINDANY"
  270. ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
  271. ngx_feature_run=no
  272. ngx_feature_incs="#include <sys/socket.h>"
  273. ngx_feature_path=
  274. ngx_feature_libs=
  275. ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_BINDANY, NULL, 0)"
  276. . auto/feature
  277. # Linux transparent proxying
  278. ngx_feature="IP_TRANSPARENT"
  279. ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
  280. ngx_feature_run=no
  281. ngx_feature_incs="#include <sys/socket.h>
  282. #include <netinet/in.h>"
  283. ngx_feature_path=
  284. ngx_feature_libs=
  285. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_TRANSPARENT, NULL, 0)"
  286. . auto/feature
  287. # FreeBSD bind to any address for transparent proxying
  288. ngx_feature="IP_BINDANY"
  289. ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
  290. ngx_feature_run=no
  291. ngx_feature_incs="#include <sys/socket.h>
  292. #include <netinet/in.h>"
  293. ngx_feature_path=
  294. ngx_feature_libs=
  295. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_BINDANY, NULL, 0)"
  296. . auto/feature
  297. # Linux IP_BIND_ADDRESS_NO_PORT
  298. ngx_feature="IP_BIND_ADDRESS_NO_PORT"
  299. ngx_feature_name="NGX_HAVE_IP_BIND_ADDRESS_NO_PORT"
  300. ngx_feature_run=no
  301. ngx_feature_incs="#include <sys/socket.h>
  302. #include <netinet/in.h>"
  303. ngx_feature_path=
  304. ngx_feature_libs=
  305. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, NULL, 0)"
  306. . auto/feature
  307. # BSD way to get IPv4 datagram destination address
  308. ngx_feature="IP_RECVDSTADDR"
  309. ngx_feature_name="NGX_HAVE_IP_RECVDSTADDR"
  310. ngx_feature_run=no
  311. ngx_feature_incs="#include <sys/socket.h>
  312. #include <netinet/in.h>"
  313. ngx_feature_path=
  314. ngx_feature_libs=
  315. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_RECVDSTADDR, NULL, 0)"
  316. . auto/feature
  317. # BSD way to set IPv4 datagram source address
  318. ngx_feature="IP_SENDSRCADDR"
  319. ngx_feature_name="NGX_HAVE_IP_SENDSRCADDR"
  320. ngx_feature_run=no
  321. ngx_feature_incs="#include <sys/socket.h>
  322. #include <netinet/in.h>"
  323. ngx_feature_path=
  324. ngx_feature_libs=
  325. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_SENDSRCADDR, NULL, 0)"
  326. . auto/feature
  327. # Linux way to get IPv4 datagram destination address
  328. ngx_feature="IP_PKTINFO"
  329. ngx_feature_name="NGX_HAVE_IP_PKTINFO"
  330. ngx_feature_run=no
  331. ngx_feature_incs="#include <sys/socket.h>
  332. #include <netinet/in.h>"
  333. ngx_feature_path=
  334. ngx_feature_libs=
  335. ngx_feature_test="struct in_pktinfo pkt;
  336. pkt.ipi_spec_dst.s_addr = INADDR_ANY;
  337. (void) pkt;
  338. setsockopt(0, IPPROTO_IP, IP_PKTINFO, NULL, 0)"
  339. . auto/feature
  340. # RFC 3542 way to get IPv6 datagram destination address
  341. ngx_feature="IPV6_RECVPKTINFO"
  342. ngx_feature_name="NGX_HAVE_IPV6_RECVPKTINFO"
  343. ngx_feature_run=no
  344. ngx_feature_incs="#include <sys/socket.h>
  345. #include <netinet/in.h>"
  346. ngx_feature_path=
  347. ngx_feature_libs=
  348. ngx_feature_test="setsockopt(0, IPPROTO_IPV6, IPV6_RECVPKTINFO, NULL, 0)"
  349. . auto/feature
  350. ngx_feature="TCP_DEFER_ACCEPT"
  351. ngx_feature_name="NGX_HAVE_DEFERRED_ACCEPT"
  352. ngx_feature_run=no
  353. ngx_feature_incs="#include <sys/socket.h>
  354. #include <netinet/in.h>
  355. #include <netinet/tcp.h>"
  356. ngx_feature_path=
  357. ngx_feature_libs=
  358. ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_DEFER_ACCEPT, NULL, 0)"
  359. . auto/feature
  360. ngx_feature="TCP_KEEPIDLE"
  361. ngx_feature_name="NGX_HAVE_KEEPALIVE_TUNABLE"
  362. ngx_feature_run=no
  363. ngx_feature_incs="#include <sys/socket.h>
  364. #include <netinet/in.h>
  365. #include <netinet/tcp.h>"
  366. ngx_feature_path=
  367. ngx_feature_libs=
  368. ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_KEEPIDLE, NULL, 0);
  369. setsockopt(0, IPPROTO_TCP, TCP_KEEPINTVL, NULL, 0);
  370. setsockopt(0, IPPROTO_TCP, TCP_KEEPCNT, NULL, 0)"
  371. . auto/feature
  372. ngx_feature="TCP_FASTOPEN"
  373. ngx_feature_name="NGX_HAVE_TCP_FASTOPEN"
  374. ngx_feature_run=no
  375. ngx_feature_incs="#include <sys/socket.h>
  376. #include <netinet/in.h>
  377. #include <netinet/tcp.h>"
  378. ngx_feature_path=
  379. ngx_feature_libs=
  380. ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_FASTOPEN, NULL, 0)"
  381. . auto/feature
  382. ngx_feature="TCP_INFO"
  383. ngx_feature_name="NGX_HAVE_TCP_INFO"
  384. ngx_feature_run=no
  385. ngx_feature_incs="#include <sys/socket.h>
  386. #include <netinet/in.h>
  387. #include <netinet/tcp.h>"
  388. ngx_feature_path=
  389. ngx_feature_libs=
  390. ngx_feature_test="socklen_t optlen = sizeof(struct tcp_info);
  391. struct tcp_info ti;
  392. ti.tcpi_rtt = 0;
  393. ti.tcpi_rttvar = 0;
  394. ti.tcpi_snd_cwnd = 0;
  395. ti.tcpi_rcv_space = 0;
  396. getsockopt(0, IPPROTO_TCP, TCP_INFO, &ti, &optlen)"
  397. . auto/feature
  398. ngx_feature="accept4()"
  399. ngx_feature_name="NGX_HAVE_ACCEPT4"
  400. ngx_feature_run=no
  401. ngx_feature_incs="#include <sys/socket.h>"
  402. ngx_feature_path=
  403. ngx_feature_libs=
  404. ngx_feature_test="accept4(0, NULL, NULL, SOCK_NONBLOCK)"
  405. . auto/feature
  406. if [ $NGX_FILE_AIO = YES ]; then
  407. ngx_feature="kqueue AIO support"
  408. ngx_feature_name="NGX_HAVE_FILE_AIO"
  409. ngx_feature_run=no
  410. ngx_feature_incs="#include <aio.h>"
  411. ngx_feature_path=
  412. ngx_feature_libs=
  413. ngx_feature_test="struct aiocb iocb;
  414. iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
  415. (void) aio_read(&iocb)"
  416. . auto/feature
  417. if [ $ngx_found = yes ]; then
  418. CORE_SRCS="$CORE_SRCS $FILE_AIO_SRCS"
  419. fi
  420. if [ $ngx_found = no ]; then
  421. ngx_feature="Linux AIO support"
  422. ngx_feature_name="NGX_HAVE_FILE_AIO"
  423. ngx_feature_run=no
  424. ngx_feature_incs="#include <linux/aio_abi.h>
  425. #include <sys/eventfd.h>"
  426. ngx_feature_path=
  427. ngx_feature_libs=
  428. ngx_feature_test="struct iocb iocb;
  429. iocb.aio_lio_opcode = IOCB_CMD_PREAD;
  430. iocb.aio_flags = IOCB_FLAG_RESFD;
  431. iocb.aio_resfd = -1;
  432. (void) iocb;
  433. (void) eventfd(0, 0)"
  434. . auto/feature
  435. if [ $ngx_found = yes ]; then
  436. have=NGX_HAVE_EVENTFD . auto/have
  437. have=NGX_HAVE_SYS_EVENTFD_H . auto/have
  438. CORE_SRCS="$CORE_SRCS $LINUX_AIO_SRCS"
  439. fi
  440. fi
  441. if [ $ngx_found = no ]; then
  442. ngx_feature="Linux AIO support (SYS_eventfd)"
  443. ngx_feature_incs="#include <linux/aio_abi.h>
  444. #include <sys/syscall.h>"
  445. ngx_feature_test="struct iocb iocb;
  446. iocb.aio_lio_opcode = IOCB_CMD_PREAD;
  447. iocb.aio_flags = IOCB_FLAG_RESFD;
  448. iocb.aio_resfd = -1;
  449. (void) iocb;
  450. (void) SYS_eventfd"
  451. . auto/feature
  452. if [ $ngx_found = yes ]; then
  453. have=NGX_HAVE_EVENTFD . auto/have
  454. CORE_SRCS="$CORE_SRCS $LINUX_AIO_SRCS"
  455. fi
  456. fi
  457. if [ $ngx_found = no ]; then
  458. cat << END
  459. $0: no supported file AIO was found
  460. Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only
  461. END
  462. exit 1
  463. fi
  464. fi
  465. have=NGX_HAVE_UNIX_DOMAIN . auto/have
  466. ngx_feature_libs=
  467. # C types
  468. ngx_type="int"; . auto/types/sizeof
  469. ngx_type="long"; . auto/types/sizeof
  470. ngx_type="long long"; . auto/types/sizeof
  471. ngx_type="void *"; . auto/types/sizeof; ngx_ptr_size=$ngx_size
  472. ngx_param=NGX_PTR_SIZE; ngx_value=$ngx_size; . auto/types/value
  473. # POSIX types
  474. NGX_INCLUDE_AUTO_CONFIG_H="#include \"ngx_auto_config.h\""
  475. ngx_type="uint32_t"; ngx_types="u_int32_t"; . auto/types/typedef
  476. ngx_type="uint64_t"; ngx_types="u_int64_t"; . auto/types/typedef
  477. ngx_type="sig_atomic_t"; ngx_types="int"; . auto/types/typedef
  478. . auto/types/sizeof
  479. ngx_param=NGX_SIG_ATOMIC_T_SIZE; ngx_value=$ngx_size; . auto/types/value
  480. ngx_type="socklen_t"; ngx_types="int"; . auto/types/typedef
  481. ngx_type="in_addr_t"; ngx_types="uint32_t u_int32_t"; . auto/types/typedef
  482. ngx_type="in_port_t"; ngx_types="u_short"; . auto/types/typedef
  483. ngx_type="rlim_t"; ngx_types="int"; . auto/types/typedef
  484. . auto/types/uintptr_t
  485. . auto/endianness
  486. ngx_type="size_t"; . auto/types/sizeof
  487. ngx_param=NGX_MAX_SIZE_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
  488. ngx_param=NGX_SIZE_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
  489. ngx_type="off_t"; . auto/types/sizeof
  490. ngx_param=NGX_MAX_OFF_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
  491. ngx_param=NGX_OFF_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
  492. ngx_type="time_t"; . auto/types/sizeof
  493. ngx_param=NGX_TIME_T_SIZE; ngx_value=$ngx_size; . auto/types/value
  494. ngx_param=NGX_TIME_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
  495. ngx_param=NGX_MAX_TIME_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
  496. # syscalls, libc calls and some features
  497. ngx_feature="AF_INET6"
  498. ngx_feature_name="NGX_HAVE_INET6"
  499. ngx_feature_run=no
  500. ngx_feature_incs="#include <sys/socket.h>
  501. #include <netinet/in.h>
  502. #include <arpa/inet.h>"
  503. ngx_feature_path=
  504. ngx_feature_libs=
  505. ngx_feature_test="struct sockaddr_in6 sin6;
  506. sin6.sin6_family = AF_INET6;
  507. (void) sin6"
  508. . auto/feature
  509. ngx_feature="setproctitle()"
  510. ngx_feature_name="NGX_HAVE_SETPROCTITLE"
  511. ngx_feature_run=no
  512. ngx_feature_incs="#include <stdlib.h>"
  513. ngx_feature_path=
  514. ngx_feature_libs=$NGX_SETPROCTITLE_LIB
  515. ngx_feature_test="setproctitle(\"test\");"
  516. . auto/feature
  517. ngx_feature="pread()"
  518. ngx_feature_name="NGX_HAVE_PREAD"
  519. ngx_feature_run=no
  520. ngx_feature_incs=
  521. ngx_feature_path=
  522. ngx_feature_libs=
  523. ngx_feature_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0);
  524. if (n == -1) return 1"
  525. . auto/feature
  526. ngx_feature="pwrite()"
  527. ngx_feature_name="NGX_HAVE_PWRITE"
  528. ngx_feature_run=no
  529. ngx_feature_incs=
  530. ngx_feature_path=
  531. ngx_feature_libs=
  532. ngx_feature_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0);
  533. if (n == -1) return 1"
  534. . auto/feature
  535. # pwritev() was introduced in FreeBSD 6 and Linux 2.6.30, glibc 2.10
  536. ngx_feature="pwritev()"
  537. ngx_feature_name="NGX_HAVE_PWRITEV"
  538. ngx_feature_run=no
  539. ngx_feature_incs='#include <sys/uio.h>'
  540. ngx_feature_path=
  541. ngx_feature_libs=
  542. ngx_feature_test="char buf[1]; struct iovec vec[1]; ssize_t n;
  543. vec[0].iov_base = buf;
  544. vec[0].iov_len = 1;
  545. n = pwritev(1, vec, 1, 0);
  546. if (n == -1) return 1"
  547. . auto/feature
  548. # strerrordesc_np(), introduced in glibc 2.32
  549. ngx_feature="strerrordesc_np()"
  550. ngx_feature_name="NGX_HAVE_STRERRORDESC_NP"
  551. ngx_feature_run=no
  552. ngx_feature_incs='#include <string.h>'
  553. ngx_feature_path=
  554. ngx_feature_libs=
  555. ngx_feature_test="char *p; p = strerrordesc_np(0);
  556. if (p == NULL) return 1"
  557. . auto/feature
  558. if [ $ngx_found = no ]; then
  559. ngx_feature="sys_nerr"
  560. ngx_feature_name="NGX_SYS_NERR"
  561. ngx_feature_run=value
  562. ngx_feature_incs='#include <errno.h>
  563. #include <stdio.h>'
  564. ngx_feature_path=
  565. ngx_feature_libs=
  566. ngx_feature_test='printf("%d", sys_nerr);'
  567. . auto/feature
  568. fi
  569. if [ $ngx_found = no ]; then
  570. # Cygiwn defines _sys_nerr
  571. ngx_feature="_sys_nerr"
  572. ngx_feature_name="NGX_SYS_NERR"
  573. ngx_feature_run=value
  574. ngx_feature_incs='#include <errno.h>
  575. #include <stdio.h>'
  576. ngx_feature_path=
  577. ngx_feature_libs=
  578. ngx_feature_test='printf("%d", _sys_nerr);'
  579. . auto/feature
  580. fi
  581. ngx_feature="localtime_r()"
  582. ngx_feature_name="NGX_HAVE_LOCALTIME_R"
  583. ngx_feature_run=no
  584. ngx_feature_incs="#include <time.h>"
  585. ngx_feature_path=
  586. ngx_feature_libs=
  587. ngx_feature_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
  588. . auto/feature
  589. ngx_feature="clock_gettime(CLOCK_MONOTONIC)"
  590. ngx_feature_name="NGX_HAVE_CLOCK_MONOTONIC"
  591. ngx_feature_run=no
  592. ngx_feature_incs="#include <time.h>"
  593. ngx_feature_path=
  594. ngx_feature_libs=
  595. ngx_feature_test="struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts)"
  596. . auto/feature
  597. if [ $ngx_found = no ]; then
  598. # Linux before glibc 2.17, notably CentOS 6
  599. ngx_feature="clock_gettime(CLOCK_MONOTONIC) in librt"
  600. ngx_feature_libs="-lrt"
  601. . auto/feature
  602. if [ $ngx_found = yes ]; then
  603. CORE_LIBS="$CORE_LIBS -lrt"
  604. fi
  605. fi
  606. ngx_feature="posix_memalign()"
  607. ngx_feature_name="NGX_HAVE_POSIX_MEMALIGN"
  608. ngx_feature_run=no
  609. ngx_feature_incs="#include <stdlib.h>"
  610. ngx_feature_path=
  611. ngx_feature_libs=
  612. ngx_feature_test="void *p; int n; n = posix_memalign(&p, 4096, 4096);
  613. if (n != 0) return 1"
  614. . auto/feature
  615. ngx_feature="memalign()"
  616. ngx_feature_name="NGX_HAVE_MEMALIGN"
  617. ngx_feature_run=no
  618. ngx_feature_incs="#include <stdlib.h>
  619. #include <malloc.h>"
  620. ngx_feature_path=
  621. ngx_feature_libs=
  622. ngx_feature_test="void *p; p = memalign(4096, 4096);
  623. if (p == NULL) return 1"
  624. . auto/feature
  625. ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
  626. ngx_feature_name="NGX_HAVE_MAP_ANON"
  627. ngx_feature_run=yes
  628. ngx_feature_incs="#include <sys/mman.h>"
  629. ngx_feature_path=
  630. ngx_feature_libs=
  631. ngx_feature_test="void *p;
  632. p = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
  633. MAP_ANON|MAP_SHARED, -1, 0);
  634. if (p == MAP_FAILED) return 1;"
  635. . auto/feature
  636. ngx_feature='mmap("/dev/zero", MAP_SHARED)'
  637. ngx_feature_name="NGX_HAVE_MAP_DEVZERO"
  638. ngx_feature_run=yes
  639. ngx_feature_incs="#include <sys/mman.h>
  640. #include <sys/stat.h>
  641. #include <fcntl.h>"
  642. ngx_feature_path=
  643. ngx_feature_libs=
  644. ngx_feature_test='void *p; int fd;
  645. fd = open("/dev/zero", O_RDWR);
  646. p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  647. if (p == MAP_FAILED) return 1;'
  648. . auto/feature
  649. ngx_feature="System V shared memory"
  650. ngx_feature_name="NGX_HAVE_SYSVSHM"
  651. ngx_feature_run=yes
  652. ngx_feature_incs="#include <sys/ipc.h>
  653. #include <sys/shm.h>"
  654. ngx_feature_path=
  655. ngx_feature_libs=
  656. ngx_feature_test="int id;
  657. id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
  658. if (id == -1) return 1;
  659. shmctl(id, IPC_RMID, NULL);"
  660. . auto/feature
  661. ngx_feature="POSIX semaphores"
  662. ngx_feature_name="NGX_HAVE_POSIX_SEM"
  663. ngx_feature_run=yes
  664. ngx_feature_incs="#include <semaphore.h>"
  665. ngx_feature_path=
  666. ngx_feature_libs=
  667. ngx_feature_test="sem_t sem;
  668. if (sem_init(&sem, 1, 0) == -1) return 1;
  669. sem_destroy(&sem);"
  670. . auto/feature
  671. if [ $ngx_found = no ]; then
  672. # Linux has POSIX semaphores in libpthread
  673. ngx_feature="POSIX semaphores in libpthread"
  674. ngx_feature_libs=-lpthread
  675. . auto/feature
  676. if [ $ngx_found = yes ]; then
  677. CORE_LIBS="$CORE_LIBS -lpthread"
  678. NGX_LIBPTHREAD="-lpthread"
  679. fi
  680. fi
  681. if [ $ngx_found = no ]; then
  682. # Solaris has POSIX semaphores in librt
  683. ngx_feature="POSIX semaphores in librt"
  684. ngx_feature_libs=-lrt
  685. . auto/feature
  686. if [ $ngx_found = yes ]; then
  687. CORE_LIBS="$CORE_LIBS -lrt"
  688. fi
  689. fi
  690. ngx_feature="struct msghdr.msg_control"
  691. ngx_feature_name="NGX_HAVE_MSGHDR_MSG_CONTROL"
  692. ngx_feature_run=no
  693. ngx_feature_incs="#include <sys/socket.h>
  694. #include <stdio.h>"
  695. ngx_feature_path=
  696. ngx_feature_libs=
  697. ngx_feature_test="struct msghdr msg;
  698. printf(\"%d\", (int) sizeof(msg.msg_control))"
  699. . auto/feature
  700. ngx_feature="ioctl(FIONBIO)"
  701. ngx_feature_name="NGX_HAVE_FIONBIO"
  702. ngx_feature_run=no
  703. ngx_feature_incs="#include <sys/ioctl.h>
  704. #include <stdio.h>
  705. $NGX_INCLUDE_SYS_FILIO_H"
  706. ngx_feature_path=
  707. ngx_feature_libs=
  708. ngx_feature_test="int i = FIONBIO; printf(\"%d\", i)"
  709. . auto/feature
  710. ngx_feature="ioctl(FIONREAD)"
  711. ngx_feature_name="NGX_HAVE_FIONREAD"
  712. ngx_feature_run=no
  713. ngx_feature_incs="#include <sys/ioctl.h>
  714. #include <stdio.h>
  715. $NGX_INCLUDE_SYS_FILIO_H"
  716. ngx_feature_path=
  717. ngx_feature_libs=
  718. ngx_feature_test="int i = FIONREAD; printf(\"%d\", i)"
  719. . auto/feature
  720. ngx_feature="struct tm.tm_gmtoff"
  721. ngx_feature_name="NGX_HAVE_GMTOFF"
  722. ngx_feature_run=no
  723. ngx_feature_incs="#include <time.h>
  724. #include <stdio.h>"
  725. ngx_feature_path=
  726. ngx_feature_libs=
  727. ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0;
  728. printf(\"%d\", (int) tm.tm_gmtoff)"
  729. . auto/feature
  730. ngx_feature="struct dirent.d_namlen"
  731. ngx_feature_name="NGX_HAVE_D_NAMLEN"
  732. ngx_feature_run=no
  733. ngx_feature_incs="#include <dirent.h>
  734. #include <stdio.h>"
  735. ngx_feature_path=
  736. ngx_feature_libs=
  737. ngx_feature_test="struct dirent dir; dir.d_namlen = 0;
  738. printf(\"%d\", (int) dir.d_namlen)"
  739. . auto/feature
  740. ngx_feature="struct dirent.d_type"
  741. ngx_feature_name="NGX_HAVE_D_TYPE"
  742. ngx_feature_run=no
  743. ngx_feature_incs="#include <dirent.h>
  744. #include <stdio.h>"
  745. ngx_feature_path=
  746. ngx_feature_libs=
  747. ngx_feature_test="struct dirent dir; dir.d_type = DT_REG;
  748. printf(\"%d\", (int) dir.d_type)"
  749. . auto/feature
  750. ngx_feature="sysconf(_SC_NPROCESSORS_ONLN)"
  751. ngx_feature_name="NGX_HAVE_SC_NPROCESSORS_ONLN"
  752. ngx_feature_run=no
  753. ngx_feature_incs=
  754. ngx_feature_path=
  755. ngx_feature_libs=
  756. ngx_feature_test="sysconf(_SC_NPROCESSORS_ONLN)"
  757. . auto/feature
  758. ngx_feature="sysconf(_SC_LEVEL1_DCACHE_LINESIZE)"
  759. ngx_feature_name="NGX_HAVE_LEVEL1_DCACHE_LINESIZE"
  760. ngx_feature_run=no
  761. ngx_feature_incs=
  762. ngx_feature_path=
  763. ngx_feature_libs=
  764. ngx_feature_test="sysconf(_SC_LEVEL1_DCACHE_LINESIZE)"
  765. . auto/feature
  766. ngx_feature="openat(), fstatat()"
  767. ngx_feature_name="NGX_HAVE_OPENAT"
  768. ngx_feature_run=no
  769. ngx_feature_incs="#include <sys/types.h>
  770. #include <sys/stat.h>
  771. #include <fcntl.h>"
  772. ngx_feature_path=
  773. ngx_feature_libs=
  774. ngx_feature_test="struct stat sb;
  775. openat(AT_FDCWD, \".\", O_RDONLY|O_NOFOLLOW);
  776. fstatat(AT_FDCWD, \".\", &sb, AT_SYMLINK_NOFOLLOW);"
  777. . auto/feature
  778. ngx_feature="getaddrinfo()"
  779. ngx_feature_name="NGX_HAVE_GETADDRINFO"
  780. ngx_feature_run=no
  781. ngx_feature_incs="#include <sys/types.h>
  782. #include <sys/socket.h>
  783. #include <netdb.h>"
  784. ngx_feature_path=
  785. ngx_feature_libs=
  786. ngx_feature_test='struct addrinfo *res;
  787. if (getaddrinfo("localhost", NULL, NULL, &res) != 0) return 1;
  788. freeaddrinfo(res)'
  789. . auto/feature