aboutsummaryrefslogtreecommitdiffstats
path: root/www/nginx/Makefile
blob: a1edca4d721c87d9a2729790e28b4f65b027095f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
# Created by: Sergey A. Osokin <osa@FreeBSD.org>
# $FreeBSD$

PORTNAME=   nginx
PORTVERSION=    1.2.5
PORTEPOCH=  1
CATEGORIES= www
MASTER_SITES=   http://nginx.org/download/
MASTER_SITES+=  ${MASTER_SITE_LOCAL}
MASTER_SITE_SUBDIR= osa
DISTFILES=  ${DISTNAME}${EXTRACT_SUFX}

MAINTAINER= osa@FreeBSD.org
COMMENT=    Robust and small WWW server

LICENSE=    BSD

NO_OPTIONS_SORT=    yes
OPTIONS_DEFINE= \
    DEBUG \
    DEBUGLOG \
    FILE_AIO \
    IPV6 \
    GOOGLE_PERFTOOLS \
    HTTP \
    HTTP_ADDITION \
    HTTP_CACHE \
    HTTP_DAV \
    HTTP_FLV \
    HTTP_GEOIP \
    HTTP_GZIP_STATIC \
    HTTP_IMAGE_FILTER \
    HTTP_PERL \
    HTTP_RANDOM_INDEX \
    HTTP_REALIP \
    HTTP_REWRITE \
    HTTP_SECURE_LINK \
    HTTP_SSL \
    HTTP_STATUS \
    HTTP_SUB \
    HTTP_XSLT \
    MAIL \
    MAIL_IMAP \
    MAIL_POP3 \
    MAIL_SMTP \
    MAIL_SSL \
    WWW \
    CACHE_PURGE \
    CTPP2 \
    ECHO \
    HEADERS_MORE \
    HTTP_ACCEPT_LANGUAGE \
    HTTP_ACCESSKEY \
    HTTP_AUTH_DIGEST \
    HTTP_AUTH_LDAP \
    HTTP_AUTH_PAM \
    HTTP_AUTH_REQ \
    HTTP_DAV_EXT \
    HTTP_EVAL \
    HTTP_FANCYINDEX \
    HTTP_GUNZIP_FILTER \
    HTTP_MOGILEFS \
    HTTP_NOTICE \
    HTTP_PUSH \
    HTTP_REDIS \
    HTTP_RESPONSE \
    HTTP_SUBS_FILTER \
    HTTP_UPLOAD \
    HTTP_UPLOAD_PROGRESS \
    HTTP_UPSTREAM_FAIR \
    HTTP_UPSTREAM_HASH \
    HTTP_UPSTREAM_STICKY \
    HTTP_ZIP \
    ARRAYVAR \
    CHUNKIN \
    DRIZZLE \
    ENCRYPTSESSION \
    FORMINPUT \
    GRIDFS \
    ICONV \
    LET \
    LUA \
    MEMC \
    NAXSI \
    PASSENGER \
    POSTGRES \
    RDS_CSV \
    RDS_JSON \
    REDIS2 \
    RTMP \
    SET_MISC \
    SFLOW \
    SLOWFS_CACHE \
    SRCACHE \
    SUPERVISORD \
    SYSLOG_SUPPORT \
    TCP_PROXY \
    UDPLOG \
    XRID_HEADER \
    XSS \
    VIDEO

OPTIONS_SINGLE=     VIDEO
OPTIONS_SINGLE_VIDEO=   HTTP_MP4 HTTP_MP4_H264
OPTIONS_DEFAULT=    IPV6 HTTP HTTP_CACHE HTTP_REWRITE HTTP_STATUS WWW

DEBUGLOG_DESC=          Enable debug log (--with-debug)
FILE_AIO_DESC=          Enable file aio
GOOGLE_PERFTOOLS_DESC=      Enable google perftools module
HTTP_DESC=          Enable HTTP module
HTTP_ADDITION_DESC=     Enable http_addition module
HTTP_CACHE_DESC=        Enable http_cache module
HTTP_DAV_DESC=          Enable http_webdav module
HTTP_FLV_DESC=          Enable http_flv module
HTTP_GEOIP_DESC=        Enable http_geoip module
HTTP_GZIP_STATIC_DESC=      Enable http_gzip_static module
HTTP_IMAGE_FILTER_DESC=     Enable http_image_filter module
HTTP_MP4_DESC=          Enable http_mp4 module
HTTP_PERL_DESC=         Enable http_perl module
HTTP_RANDOM_INDEX_DESC=     Enable http_random_index module
HTTP_REALIP_DESC=       Enable http_realip module
HTTP_REWRITE_DESC=      Enable http_rewrite module
HTTP_SECURE_LINK_DESC=      Enable http_secure_link module
HTTP_SSL_DESC=          Enable http_ssl module
HTTP_STATUS_DESC=       Enable http_stub_status module
HTTP_SUB_DESC=          Enable http_sub module
HTTP_XSLT_DESC=         Enable http_xslt module
MAIL_DESC=          Enable IMAP4/POP3/SMTP proxy module
MAIL_IMAP_DESC=         Enable IMAP4 proxy module
MAIL_POP3_DESC=         Enable POP3 proxy module
MAIL_SMTP_DESC=         Enable SMTP proxy module
MAIL_SSL_DESC=          Enable mail_ssl module
WWW_DESC=           Enable html sample files
CACHE_PURGE_DESC=       3rd party cache_purge module
CTPP2_DESC=         3rd party CT++ module
ECHO_DESC=          3rd party echo module
HEADERS_MORE_DESC=      3rd party headers_more module
HTTP_ACCEPT_LANGUAGE_DESC=  3rd party accept_language module
HTTP_ACCESSKEY_DESC=        3rd party http_accesskey module
HTTP_AUTH_DIGEST_DESC=      3rd party http_authdigest module
HTTP_AUTH_LDAP_DESC=        3rd party http_auth_ldap module
HTTP_AUTH_PAM_DESC=     3rd party http_auth_pam module
HTTP_AUTH_REQ_DESC=     3rd party http_auth_request module
HTTP_DAV_EXT_DESC=      3rd party webdav_ext module
HTTP_EVAL_DESC=         3rd party eval module
HTTP_FANCYINDEX_DESC=       3rd party http_fancyindex module
HTTP_GUNZIP_FILTER_DESC=    3rd party http_gunzip_filter module
HTTP_MOGILEFS_DESC=     3rd party mogilefs module
HTTP_MP4_H264_DESC=     3rd party mp4/h264 module
HTTP_NOTICE_DESC=       3rd party notice module
HTTP_PUSH_DESC=         3rd party push module
HTTP_REDIS_DESC=        3rd party http_redis module
HTTP_RESPONSE_DESC=     3rd party http_response module
HTTP_SUBS_FILTER_DESC=      3rd party subs filter module
HTTP_UPLOAD_DESC=       3rd party upload module
HTTP_UPLOAD_PROGRESS_DESC=  3rd party uploadprogress module
HTTP_UPSTREAM_FAIR_DESC=    3rd party upstream fair module
HTTP_UPSTREAM_HASH_DESC=    3rd party upstream hash module
HTTP_UPSTREAM_STICKY_DESC=  3rd party upstream sticky module
HTTP_ZIP_DESC=          3rd party http_zip module
ARRAYVAR_DESC=          3rd party array_var module
CHUNKIN_DESC=           3rd party chunkin module
DRIZZLE_DESC=           3rd party drizzlie module
ENCRYPTSESSION_DESC=        3rd party encrypted_session module
FORMINPUT_DESC=         3rd party form_input module
GRIDFS_DESC=            3rd party gridfs module
ICONV_DESC=         3rd party iconv module
LET_DESC=           3rd party let module
LUA_DESC=           3rd party lua module
MEMC_DESC=          3rd party memc (memcached) module
NAXSI_DESC=         3rd party naxsi module
PASSENGER_DESC=         3rd party passenger module
POSTGRES_DESC=          3rd party postgresql module
RDS_CSV_DESC=           3rd party rds_csv module
RDS_JSON_DESC=          3rd party rds_json module
REDIS2_DESC=            3rd party redis2 module
RTMP_DESC=          3rd party rtmp module
SET_MISC_DESC=          3rd party set_misc module
SFLOW_DESC=         3rd party sflow module
SLOWFS_CACHE_DESC=      3rd party slowfs_cache module
SRCACHE_DESC=           3rd party srcache module
SUPERVISORD_DESC=       3rd party supervisord module
SYSLOG_SUPPORT_DESC=        3rd party syslog support
TCP_PROXY_DESC=         3rd party tcp_proxy module
UDPLOG_DESC=            3rd party udplog (syslog) module
XRID_HEADER_DESC=       3rd party x-rid header module
XSS_DESC=           3rd party xss module
VIDEO_DESC=         Video module support

WANT_GNOME= yes
MAKE_JOBS_SAFE= yes

.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MPASSENGER}
CATEGORIES+=    ruby
USE_RUBY=   yes
USE_RAKE=   yes
.endif

NGINX_VARDIR?=  /var
NGINX_LOGDIR?=  ${NGINX_VARDIR}/log
NGINX_RUNDIR?=  ${NGINX_VARDIR}/run
NGINX_TMPDIR?=  ${NGINX_VARDIR}/tmp/nginx
HTTP_PORT?= 80

NGINX_ACCESSLOG?=   ${NGINX_LOGDIR}/nginx-access.log
NGINX_ERRORLOG?=    ${NGINX_LOGDIR}/nginx-error.log

CONFLICTS?= nginx-devel-1.*
USE_RC_SUBR=    nginx
SUB_LIST+=  WWWOWN=${WWWOWN} \
        WWWGRP=${WWWGRP} \
        NGINX_RUNDIR=${NGINX_RUNDIR} \
        NGINX_TMPDIR=${NGINX_TMPDIR}
.if !defined(NO_INSTALL_MANPAGES)
MAN8=       nginx.8
.endif

HAS_CONFIGURE=  yes
CONFIGURE_ARGS+=--prefix=${ETCDIR} \
        --with-cc-opt="-I ${LOCALBASE}/include" \
        --with-ld-opt="-L ${LOCALBASE}/lib" \
        --conf-path=${ETCDIR}/nginx.conf \
        --sbin-path=${PREFIX}/sbin/nginx \
        --pid-path=${NGINX_RUNDIR}/nginx.pid \
        --error-log-path=${NGINX_ERRORLOG} \
        --user=${WWWOWN} --group=${WWWGRP}

.if empty(PORT_OPTIONS:MHTTP) && empty(PORT_OPTIONS:MMAIL)
IGNORE=     requires at least HTTP or MAIL to \
        be defined.  Please do 'make config' again
.endif

.if ${PORT_OPTIONS:MDEBUG}
CFLAGS+=    -g
STRIP=      #do not strip if nginx with debug information
.endif

.if ${PORT_OPTIONS:MDEBUGLOG}
CONFIGURE_ARGS+=--with-debug
.endif

.if ${PORT_OPTIONS:MFILE_AIO}
CONFIGURE_ARGS+=--with-file-aio
.endif

.if ${PORT_OPTIONS:MIPV6}
CONFIGURE_ARGS+=--with-ipv6
CATEGORIES+=    ipv6
.endif

.if ${PORT_OPTIONS:MGOOGLE_PERFTOOLS}
LIB_DEPENDS+=   profiler:${PORTSDIR}/devel/google-perftools
CONFIGURE_ARGS+=--with-google_perftools_module
.endif

.if ${PORT_OPTIONS:MHTTP}
CONFIGURE_ARGS+=--http-client-body-temp-path=${NGINX_TMPDIR}/client_body_temp \
        --http-fastcgi-temp-path=${NGINX_TMPDIR}/fastcgi_temp \
        --http-proxy-temp-path=${NGINX_TMPDIR}/proxy_temp \
        --http-scgi-temp-path=${NGINX_TMPDIR}/scgi_temp \
        --http-uwsgi-temp-path=${NGINX_TMPDIR}/uwsgi_temp \
        --http-log-path=${NGINX_ACCESSLOG}

.if ${PORT_OPTIONS:MHTTP_ACCEPT_LANGUAGE}
GIT_ACCEPT_LANGUAGE_VERSION=    02262ce
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/giom/nginx_accept_language_module/tarball/master/:accept_language
DISTFILES+= giom-nginx_accept_language_module-${GIT_ACCEPT_LANGUAGE_VERSION}.tar.gz:accept_language
CONFIGURE_ARGS+=--add-module=${WRKDIR}/giom-nginx_accept_language_module-${GIT_ACCEPT_LANGUAGE_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_ACCESSKEY}
NGINX_ACCESSKEY_VERSION=    2.0.3
MASTER_SITES+=  ${MASTER_SITE_LOCAL:S/$/:accesskey/}
MASTER_SITE_SUBDIR+=    osa/:accesskey
DISTFILES+= nginx-accesskey-${NGINX_ACCESSKEY_VERSION}.tar.gz:accesskey
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx-accesskey-${NGINX_ACCESSKEY_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_ADDITION}
CONFIGURE_ARGS+=--with-http_addition_module
.endif

.if ${PORT_OPTIONS:MHTTP_AUTH_DIGEST}
GIT_AUTH_DIGEST_VERSION=    bd1c86a
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/samizdatco/nginx-http-auth-digest/tarball/master/:auth_digest
DISTFILES+= samizdatco-nginx-http-auth-digest-${GIT_AUTH_DIGEST_VERSION}.tar.gz:auth_digest
CONFIGURE_ARGS+=--add-module=${WRKDIR}/samizdatco-nginx-http-auth-digest-${GIT_AUTH_DIGEST_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_AUTH_LDAP}
GIT_HTTP_AUTH_LDAP_VERSION= c2c3d5ea4919
MASTER_SITES+=  LOCAL/rm:http_auth_ldap
DISTFILES+= http_auth_ldap-${GIT_HTTP_AUTH_LDAP_VERSION}.tar.gz:http_auth_ldap
CONFIGURE_ARGS+=--add-module=${WRKDIR}/http_auth_ldap-${GIT_HTTP_AUTH_LDAP_VERSION}
USE_OPENLDAP=   yes
.endif

.if ${PORT_OPTIONS:MHTTP_AUTH_PAM}
NGINX_AUTH_PAM_VERSION= 1.2
MASTER_SITES+=  http://web.iti.upv.es/~sto/nginx/:auth_pam
DISTFILES+= ngx_http_auth_pam_module-${NGINX_AUTH_PAM_VERSION}.tar.gz:auth_pam
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_http_auth_pam_module-${NGINX_AUTH_PAM_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_AUTH_REQ}
NGINX_AUTH_REQ_VERSION= 0.2
MASTER_SITES+=  http://mdounin.ru/files/:auth_request
DISTFILES+= ngx_http_auth_request_module-${NGINX_AUTH_REQ_VERSION}.tar.gz:auth_request
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_http_auth_request_module-${NGINX_AUTH_REQ_VERSION}
.endif

.if empty(PORT_OPTIONS:MHTTP_CACHE)
CONFIGURE_ARGS+=--without-http-cache
.endif

.if ${PORT_OPTIONS:MCACHE_PURGE}
NGINX_CACHE_PURGE_VERSION=  1.6
MASTER_SITES+=  http://labs.frickle.com/files/:cache_purge
DISTFILES+= ngx_cache_purge-${NGINX_CACHE_PURGE_VERSION}.tar.gz:cache_purge
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_cache_purge-${NGINX_CACHE_PURGE_VERSION}
.endif

.if ${PORT_OPTIONS:MCTPP2}
LIB_DEPENDS+=   ctpp2:${PORTSDIR}/textproc/ctpp2
NGINX_CTPP2_VERSION=    0.5
MASTER_SITES+=  http://dl.vbart.ru/ngx-ctpp/:ctpp2
DISTFILES+= ngx_ctpp2-${NGINX_CTPP2_VERSION}.tar.gz:ctpp2
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_ctpp2-${NGINX_CTPP2_VERSION}
.endif

.if ${PORT_OPTIONS:MECHO}
NGINX_ECHO_VERSION= 0.41
GIT_ECHO_VERSION=   0-gd3eb42d
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/echo-nginx-module/tarball/v${NGINX_ECHO_VERSION}/:echo
DISTFILES+= agentzh-echo-nginx-module-v${NGINX_ECHO_VERSION}-${GIT_ECHO_VERSION}.tar.gz:echo
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-echo-nginx-module-${GIT_ECHO_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MHEADERS_MORE}
NGINX_HEADERS_MORE_VERSION= 0.18
GIT_HEADERS_MORE_VERSION=   0-g6586984
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/headers-more-nginx-module/tarball/v${NGINX_HEADERS_MORE_VERSION}/:headers_more
DISTFILES+= agentzh-headers-more-nginx-module-v${NGINX_HEADERS_MORE_VERSION}-${GIT_HEADERS_MORE_VERSION}.tar.gz:headers_more
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-headers-more-nginx-module-${GIT_HEADERS_MORE_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MHTTP_DAV} || defined(USE_HTTP_DAV)
CONFIGURE_ARGS+=--with-http_dav_module
.endif

.if ${PORT_OPTIONS:MHTTP_DAV_EXT}
USE_HTTP_DAV=   yes
LIB_DEPENDS+=   expat:${PORTSDIR}/textproc/expat2
NGINX_DAV_EXT_VERSION=  0.0.2
GIT_DAV_EXT_VERSION=    0-g0e07a3e
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/arut/nginx-dav-ext-module/tarball/v${NGINX_DAV_EXT_VERSION}/:dav_ext
DISTFILES+= arut-nginx-dav-ext-module-v${NGINX_DAV_EXT_VERSION}-${GIT_DAV_EXT_VERSION}.tar.gz:dav_ext
CONFIGURE_ARGS+=--add-module=${WRKDIR}/arut-nginx-dav-ext-module-${GIT_DAV_EXT_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MHTTP_EVAL}
NGINX_EVAL_VERSION= 1.0.3
GIT_EVAL_VERSION=   0-g125fa2e
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/vkholodkov/nginx-eval-module/tarball/${NGINX_EVAL_VERSION}/:eval
DISTFILES+= vkholodkov-nginx-eval-module-${NGINX_EVAL_VERSION}-${GIT_EVAL_VERSION}.tar.gz:eval
CONFIGURE_ARGS+=--add-module=${WRKDIR}/vkholodkov-nginx-eval-module-${GIT_EVAL_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MHTTP_FANCYINDEX}
NGINX_FANCYINDEX_VERSION=   0.3.1
MASTER_SITES+=  ${MASTER_SITE_LOCAL:S/$/:fancyindex/}
MASTER_SITE_SUBDIR+=    osa/:fancyindex
DISTFILES+= ngx-fancyindex-${NGINX_FANCYINDEX_VERSION}.tar.gz:fancyindex
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx-fancyindex-${NGINX_FANCYINDEX_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_GUNZIP_FILTER}
NGINX_GUNZIP_FILTER_VERSION=    0.4
MASTER_SITES+=  http://mdounin.ru/files/:gunzipfilter
DISTFILES+= ngx_http_gunzip_filter_module-${NGINX_GUNZIP_FILTER_VERSION}.tar.gz:gunzipfilter
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_http_gunzip_filter_module-${NGINX_GUNZIP_FILTER_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_FLV}
CONFIGURE_ARGS+=--with-http_flv_module
.endif

.if ${PORT_OPTIONS:MHTTP_GEOIP}
CONFIGURE_ARGS+=--with-http_geoip_module
LIB_DEPENDS+=   GeoIP:${PORTSDIR}/net/GeoIP
.endif

.if ${PORT_OPTIONS:MHTTP_GZIP_STATIC}
CONFIGURE_ARGS+=--with-http_gzip_static_module
.endif

.if ${PORT_OPTIONS:MHTTP_IMAGE_FILTER}
LIB_DEPENDS+=   gd:${PORTSDIR}/graphics/gd
CONFIGURE_ARGS+=--with-http_image_filter_module
.endif

.if ${PORT_OPTIONS:MHTTP_MP4}
CONFIGURE_ARGS+=--with-http_mp4_module
.endif

.if ${PORT_OPTIONS:MHTTP_MOGILEFS}
NGINX_MOGILEFS_VERSION= 1.0.4
MASTER_SITES+=  http://www.grid.net.ru/nginx/download/:mogilefs
DISTFILES+= nginx_mogilefs_module-${NGINX_MOGILEFS_VERSION}.tar.gz:mogilefs
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_mogilefs_module-${NGINX_MOGILEFS_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_MP4_H264}
NGINX_H264_VERSION= 2.2.7
MASTER_SITES+=  http://h264.code-shop.com/download/:mp4streaming
DISTFILES+= nginx_mod_h264_streaming-${NGINX_H264_VERSION}.tar.gz:mp4streaming
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_mod_h264_streaming-${NGINX_H264_VERSION}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-ngx_http_streaming_module.c
.endif

.if ${PORT_OPTIONS:MHTTP_NOTICE}
GIT_NOTICE_VERSION= 0-g3c95966
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/kr/nginx-notice/tarball/master/:notice
DISTFILES+= kr-nginx-notice-${GIT_NOTICE_VERSION}.tar.gz:notice
CONFIGURE_ARGS+=--add-module=${WRKDIR}/kr-nginx-notice-${GIT_NOTICE_VERSION:S/^0-g//}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-ngx_http_notice_module.c
.endif

.if ${PORT_OPTIONS:MHTTP_PERL}
CATEGORIES+=    perl5
CONFIGURE_ARGS+=--with-http_perl_module
USE_PERL5=  yes
.endif

.if ${PORT_OPTIONS:MHTTP_PUSH}
NGINX_PUSH_VERSION= 0.692
MASTER_SITES+=  http://pushmodule.slact.net/downloads/:push
DISTFILES+= nginx_http_push_module-${NGINX_PUSH_VERSION}.tar.gz:push
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_http_push_module-${NGINX_PUSH_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_RANDOM_INDEX}
CONFIGURE_ARGS+=--with-http_random_index_module
.endif

.if ${PORT_OPTIONS:MHTTP_REALIP}
CONFIGURE_ARGS+=--with-http_realip_module
.endif

.if ${PORT_OPTIONS:MHTTP_REDIS}
NGINX_REDIS_VERSION=    0.3.6
MASTER_SITES+=  ${MASTER_SITE_LOCAL:S/$/:redis/}
MASTER_SITE_SUBDIR+=    osa/:redis
DISTFILES+= ngx_http_redis-${NGINX_REDIS_VERSION}.tar.gz:redis
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_http_redis-${NGINX_REDIS_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_RESPONSE}
NGINX_RESPONSE_VERSION= 0.3
MASTER_SITES+=  http://catap.ru/downloads/nginx/:response
DISTFILES+= ngx_http_response-${NGINX_RESPONSE_VERSION}.tar.gz:response
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_http_response-${NGINX_RESPONSE_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_SUBS_FILTER}
USE_HTTP_REWRITE=   yes
NGINX_HTTP_SUBS_FILTER_VERSION= 0.6.2
GIT_HTTP_SUBS_FILTER_VERSION=   0-g27a01b3
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/yaoweibin/ngx_http_substitutions_filter_module/tarball/${NGINX_HTTP_SUBS_FILTER_VERSION}/:subs_filter
DISTFILES+= yaoweibin-ngx_http_substitutions_filter_module-${NGINX_HTTP_SUBS_FILTER_VERSION}-${GIT_HTTP_SUBS_FILTER_VERSION}.tar.gz:subs_filter
CONFIGURE_ARGS+=--add-module=${WRKDIR}/yaoweibin-ngx_http_substitutions_filter_module-${GIT_HTTP_SUBS_FILTER_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MHTTP_SECURE_LINK}
CONFIGURE_ARGS+=--with-http_secure_link_module
.endif

.if ${PORT_OPTIONS:MHTTP_STATUS}
CONFIGURE_ARGS+=--with-http_stub_status_module
.endif

.if ${PORT_OPTIONS:MHTTP_SUB}
CONFIGURE_ARGS+=--with-http_sub_module
.endif

.if ${PORT_OPTIONS:MHTTP_UPLOAD}
NGINX_UPLOAD_VERSION=   2.2.0
MASTER_SITES+=  http://www.grid.net.ru/nginx/download/:upload
DISTFILES+= nginx_upload_module-${NGINX_UPLOAD_VERSION}.tar.gz:upload
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_upload_module-${NGINX_UPLOAD_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_UPLOAD_PROGRESS}
NGINX_UPLOADPROGRESS_VERSION=   0.9.0
GIT_UPLOADPROGRESS_VERSION= 0-ga788dea
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/masterzen/nginx-upload-progress-module/tarball/v${NGINX_UPLOADPROGRESS_VERSION}/:uploadprogress
DISTFILES+= masterzen-nginx-upload-progress-module-v${NGINX_UPLOADPROGRESS_VERSION}-${GIT_UPLOADPROGRESS_VERSION}.tar.gz:uploadprogress
CONFIGURE_ARGS+=--add-module=${WRKDIR}/masterzen-nginx-upload-progress-module-${GIT_UPLOADPROGRESS_VERSION:S/^0-g//}
.endif

.if !empty(PORT_OPTIONS:MHTTP_UPSTREAM_FAIR) || !empty(PORT_OPTIONS:MSUPERVISORD)
NGINX_UPSTREAM_FAIR_VERSION=    20090923
MASTER_SITES+=  ${MASTER_SITE_LOCAL:S/$/:upstreamfair/}
MASTER_SITE_SUBDIR+=    osa/:upstreamfair
DISTFILES+= nginx_upstream_fair-${NGINX_UPSTREAM_FAIR_VERSION}.tar.gz:upstreamfair
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_upstream_fair-${NGINX_UPSTREAM_FAIR_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_UPSTREAM_HASH}
NGINX_UPSTREAM_HASH_VERSION=    0.3.1
MASTER_SITES+=  http://wiki.nginx.org/images/1/11/:upstreamhash
DISTFILES+= Nginx_upstream_hash-${NGINX_UPSTREAM_HASH_VERSION}.tar.gz:upstreamhash
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_upstream_hash-${NGINX_UPSTREAM_HASH_VERSION}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-ngx_http_upstream.h
.endif

.if ${PORT_OPTIONS:MHTTP_UPSTREAM_STICKY}
USE_HTTP_SSL=   yes
NGINX_UPSTREAM_STICKY_VERSION=  1.0
MASTER_SITES+=  http://nginx-sticky-module.googlecode.com/files/:upstreamsticky
DISTFILES+= nginx-sticky-module-${NGINX_UPSTREAM_STICKY_VERSION}.tar.gz:upstreamsticky
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx-sticky-module-${NGINX_UPSTREAM_STICKY_VERSION}
.endif

.if ${PORT_OPTIONS:MHTTP_XSLT}
USE_GNOME=  libxml2 libxslt
CONFIGURE_ARGS+=--with-http_xslt_module
.endif

.if ${PORT_OPTIONS:MHTTP_ZIP}
NGINX_ZIP_VERSION=  1.1.6
MASTER_SITES+=  http://mod-zip.googlecode.com/files/:zip
DISTFILES+= mod_zip-${NGINX_ZIP_VERSION}.tar.gz:zip
CONFIGURE_ARGS+=--add-module=${WRKDIR}/mod_zip-${NGINX_ZIP_VERSION}
.endif

.if ${PORT_OPTIONS:MCHUNKIN}
NGINX_CHUNKIN_VERSION=  0.22rc1
GIT_CHUNKIN_VERSION=    0-gb0a3ee3
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/chunkin-nginx-module/tarball/v${NGINX_CHUNKIN_VERSION}/:chunkin
DISTFILES+= agentzh-chunkin-nginx-module-v${NGINX_CHUNKIN_VERSION}-${GIT_CHUNKIN_VERSION}.tar.gz:chunkin
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-chunkin-nginx-module-${GIT_CHUNKIN_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MDRIZZLE}
LIB_DEPENDS+=   drizzle:${PORTSDIR}/databases/drizzle
NGINX_DRIZZLE_VERSION=  0.1.4
GIT_DRIZZLE_VERSION=    0-g59e12ad
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/chaoslawful/drizzle-nginx-module/tarball/v${NGINX_DRIZZLE_VERSION}/:drizzle
DISTFILES+= chaoslawful-drizzle-nginx-module-v${NGINX_DRIZZLE_VERSION}-${GIT_DRIZZLE_VERSION}.tar.gz:drizzle
CONFIGURE_ARGS+=--add-module=${WRKDIR}/chaoslawful-drizzle-nginx-module-${GIT_DRIZZLE_VERSION:S/^0-g//}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-chaoslawful-drizzle-nginx-module-config
.endif

.if ${PORT_OPTIONS:MENCRYPTSESSION}
USE_NGINX_DEVEL_KIT=    yes
NGINX_ENCRYPTSESSION_VERSION=   0.02
GIT_ENCRYPTSESSION_VERSION= 0-gc752861
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/encrypted-session-nginx-module/tarball/v${NGINX_ENCRYPTSESSION_VERSION}/:encryptsession
DISTFILES+= agentzh-encrypted-session-nginx-module-v${NGINX_ENCRYPTSESSION_VERSION}-${GIT_ENCRYPTSESSION_VERSION}.tar.gz:encryptsession
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-encrypted-session-nginx-module-${GIT_ENCRYPTSESSION_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MGRIDFS}
NGINX_GRIDFS_VERSION=   0.8
GIT_GRIDFS_VERSION= 0-gb5f8113
MONGO_C_DRIVER_VERSION=     0.3.1
GIT_MONGO_C_DRIVER_VERSION= 0-g9b4b232
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/mdirolf/nginx-gridfs/tarball/v${NGINX_GRIDFS_VERSION}/:gridfs
MASTER_SITES+=  https://github.com/mongodb/mongo-c-driver/tarball/v${MONGO_C_DRIVER_VERSION}/:mongo_c
DISTFILES+= mdirolf-nginx-gridfs-v${NGINX_GRIDFS_VERSION}-${GIT_GRIDFS_VERSION}.tar.gz:gridfs
DISTFILES+= mongodb-mongo-c-driver-v${MONGO_C_DRIVER_VERSION}-${GIT_MONGO_C_DRIVER_VERSION}.tar.gz:mongo_c
CONFIGURE_ARGS+=--add-module=${WRKDIR}/mdirolf-nginx-gridfs-${GIT_GRIDFS_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MLET}
NGINX_LET_VERSION=  0.0.4
GIT_LET_VERSION=    0-ga5e1dc5
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/arut/nginx-let-module/tarball/v${NGINX_LET_VERSION}/:let
DISTFILES+= arut-nginx-let-module-v${NGINX_LET_VERSION}-${GIT_LET_VERSION}.tar.gz:let
CONFIGURE_ARGS+=--add-module=${WRKDIR}/arut-nginx-let-module-${GIT_LET_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MLUA}
LIB_DEPENDS+=   luajit-5.1:${PORTSDIR}/lang/luajit
CONFIGURE_ENV+= "LUAJIT_INC=${LOCALBASE}/include/luajit-2.0"
CONFIGURE_ENV+= "LUAJIT_LIB=${LOCALBASE}/lib"
USE_NGINX_DEVEL_KIT=    yes
NGINX_LUA_VERSION=  0.6.10
GIT_LUA_VERSION=    0-g73d8dd2
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/chaoslawful/lua-nginx-module/tarball/v${NGINX_LUA_VERSION}/:lua
DISTFILES+= chaoslawful-lua-nginx-module-v${NGINX_LUA_VERSION}-${GIT_LUA_VERSION}.tar.gz:lua
CONFIGURE_ARGS+=--add-module=${WRKDIR}/chaoslawful-lua-nginx-module-${GIT_LUA_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MMEMC}
NGINX_MEMC_VERSION= 0.13rc3
GIT_MEMC_VERSION=   0-g4007350
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/memc-nginx-module/tarball/v${NGINX_MEMC_VERSION}/:memc
DISTFILES+= agentzh-memc-nginx-module-v${NGINX_MEMC_VERSION}-${GIT_MEMC_VERSION}.tar.gz:memc
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-memc-nginx-module-${GIT_MEMC_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MNAXSI}
NGINX_NAXSI_VERSION=    0.46-1
MASTER_SITES+=  http://naxsi.googlecode.com/files/:naxsi
DISTFILES+= naxsi-${NGINX_NAXSI_VERSION}.tgz:naxsi
CONFIGURE_ARGS+=--add-module=${WRKDIR}/naxsi-${NGINX_NAXSI_VERSION}/naxsi_src
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-naxsi_runtime.c
.endif

.if ${PORT_OPTIONS:MHTTP_REWRITE} || defined(USE_HTTP_REWRITE)
LIB_DEPENDS+=   pcre:${PORTSDIR}/devel/pcre
CONFIGURE_ARGS+=--with-pcre
.else
PKGNAMESUFFIX:= ${PKGNAMESUFFIX}-nopcre
CONFIGURE_ARGS+=--without-http_rewrite_module \
        --without-pcre
.endif

.if ${PORT_OPTIONS:MPASSENGER}
PASSENGER_VERSION=  3.0.17
MASTER_SITES+=  RF/passenger/:passenger
DISTFILES+= passenger-${PASSENGER_VERSION}.tar.gz:passenger
CONFIGURE_ARGS+=--add-module=${WRKDIR}/passenger-${PASSENGER_VERSION}/ext/nginx
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-passenger-build-nginx.rb
.if empty(PORT_OPTIONS:MDEBUG)
CONFIGURE_ENV+= OPTIMIZE="yes"
CFLAGS+=    -DNDEBUG
.endif
.endif

.if ${PORT_OPTIONS:MPOSTGRES}
USE_PGSQL=  yes
NGINX_POSTGRES_VERSION= 0.9
MASTER_SITES+=  http://labs.frickle.com/files/:postgres
DISTFILES+= ngx_postgres-${NGINX_POSTGRES_VERSION}.tar.gz:postgres
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_postgres-${NGINX_POSTGRES_VERSION}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-ngx_postgres-config
.endif

.if ${PORT_OPTIONS:MRDS_CSV}
NGINX_RDS_CSV_VERSION=  0.05rc2
GIT_RDS_CSV_VERSION=    0-gc15d3a4
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/rds-csv-nginx-module/tarball/v${NGINX_RDS_CSV_VERSION}/:rdscsv
DISTFILES+= agentzh-rds-csv-nginx-module-v${NGINX_RDS_CSV_VERSION}-${GIT_RDS_CSV_VERSION}.tar.gz:rdscsv
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-rds-csv-nginx-module-${GIT_RDS_CSV_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MRDS_JSON}
NGINX_RDS_JSON_VERSION= 0.12rc10
GIT_RDS_JSON_VERSION=   0-g74c21b3
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/rds-json-nginx-module/tarball/v${NGINX_RDS_JSON_VERSION}/:rdsjson
DISTFILES+= agentzh-rds-json-nginx-module-v${NGINX_RDS_JSON_VERSION}-${GIT_RDS_JSON_VERSION}.tar.gz:rdsjson
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-rds-json-nginx-module-${GIT_RDS_JSON_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MREDIS2}
NGINX_REDIS2_VERSION=   0.09
GIT_REDIS2_VERSION= 0-g279beee
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/redis2-nginx-module/tarball/v${NGINX_REDIS2_VERSION}/:redis2
DISTFILES+= agentzh-redis2-nginx-module-v${NGINX_REDIS2_VERSION}-${GIT_REDIS2_VERSION}.tar.gz:redis2
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-redis2-nginx-module-${GIT_REDIS2_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MRTMP}
NGINX_RTMP_VERSION= 0.6.1
GIT_RTMP_VERSION=   0-gf1eeb39
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/arut/nginx-rtmp-module/tarball/v${NGINX_RTMP_VERSION}/:rtmp
DISTFILES+= arut-rtmp-nginx-module-v${NGINX_RTMP_VERSION}-${GIT_RTMP_VERSION}.tar.gz:rtmp
CONFIGURE_ARGS+=--add-module=${WRKDIR}/arut-nginx-rtmp-module-${GIT_RTMP_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MSET_MISC}
USE_NGINX_DEVEL_KIT=    yes
NGINX_SET_MISC_VERSION= 0.22rc8
GIT_SET_MISC_VERSION=   0-g658c235
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/set-misc-nginx-module/tarball/v${NGINX_SET_MISC_VERSION}/:setmisc
DISTFILES+= agentzh-set-misc-nginx-module-v${NGINX_SET_MISC_VERSION}-${GIT_SET_MISC_VERSION}.tar.gz:setmisc
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-set-misc-nginx-module-${GIT_SET_MISC_VERSION:S/^0-g//}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-agentzh-set-misc-nginx-module-config
.endif

.if ${PORT_OPTIONS:MSFLOW}
NGINX_SFLOW_VERSION=    0.9.6
MASTER_SITES+=  http://nginx-sflow-module.googlecode.com/files/:sflow
DISTFILES+= nginx-sflow-module-${NGINX_SFLOW_VERSION}.tar.gz:sflow
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx-sflow-module-${NGINX_SFLOW_VERSION}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-ngx_http_sflow_config.c \
        ${PATCHDIR}/extra-patch-ngx_http_sflow_config.h
.endif

.if ${PORT_OPTIONS:MSLOWFS_CACHE}
NGINX_SLOWFS_CACHE_VERSION= 1.9
MASTER_SITES+=  http://labs.frickle.com/files/:slowfs_cache
DISTFILES+= ngx_slowfs_cache-${NGINX_SLOWFS_CACHE_VERSION}.tar.gz:slowfs_cache
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_slowfs_cache-${NGINX_SLOWFS_CACHE_VERSION}
.endif

.if ${PORT_OPTIONS:MSRCACHE}
NGINX_SRCACHE_VERSION=  0.16
GIT_SRCACHE_VERSION=    0-g9350a49
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/srcache-nginx-module/tarball/v${NGINX_SRCACHE_VERSION}/:srcache
DISTFILES+= agentzh-srcache-nginx-module-v${NGINX_SRCACHE_VERSION}-${GIT_SRCACHE_VERSION}.tar.gz:srcache
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-srcache-nginx-module-${GIT_SRCACHE_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MSUPERVISORD}
NGINX_SUPERVISORD_VERSION=  1.4
MASTER_SITES+=  http://labs.frickle.com/files/:supervisord
DISTFILES+= ngx_supervisord-${NGINX_SUPERVISORD_VERSION}.tar.gz:supervisord
CONFIGURE_ARGS+=--add-module=${WRKDIR}/ngx_supervisord-${NGINX_SUPERVISORD_VERSION}
.endif

.if ${PORT_OPTIONS:MSYSLOG_SUPPORT}
NGINX_SYSLOG_SUPPORT_FACILITY?= LOG_DAEMON
CONFIGURE_ARGS+=--with-syslog --with-syslog-facility=${NGINX_SYSLOG_SUPPORT_FACILITY}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-syslog_support
.endif

.if ${PORT_OPTIONS:MTCP_PROXY}
NGINX_TCP_PROXY_VERSION=    0.26
GIT_TCP_PROXY_VERSION=  0-gb83e5a6
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/yaoweibin/nginx_tcp_proxy_module/tarball/v${NGINX_TCP_PROXY_VERSION}/:tcp_proxy
DISTFILES+= yaoweibin-nginx_tcp_proxy_module-v${NGINX_TCP_PROXY_VERSION}-${GIT_TCP_PROXY_VERSION}.tar.gz:tcp_proxy
CONFIGURE_ARGS+=--add-module=${WRKDIR}/yaoweibin-nginx_tcp_proxy_module-${GIT_TCP_PROXY_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MUDPLOG}
NGINX_UDPLOG_VERSION=   1.0.0
MASTER_SITES+=  http://www.grid.net.ru/nginx/download/:udplog
DISTFILES+= nginx_udplog_module-${NGINX_UDPLOG_VERSION}.tar.gz:udplog
CONFIGURE_ARGS+=--add-module=${WRKDIR}/nginx_udplog_module-${NGINX_UDPLOG_VERSION}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-ngx_http_udplog_module.c
.endif

.if ${PORT_OPTIONS:MXRID_HEADER}
GIT_XRID_VERSION=   0daa3cc
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/gabor/nginx-x-rid-header/tarball/master/:xrid
DISTFILES+= gabor-nginx-x-rid-header-${GIT_XRID_VERSION}.tar.gz:xrid
CONFIGURE_ARGS+=--add-module=${WRKDIR}/gabor-nginx-x-rid-header-${GIT_XRID_VERSION}
.endif

.if ${PORT_OPTIONS:MXSS}
NGINX_XSS_VERSION=  0.03rc9
GIT_XSS_VERSION=    0-gbeddbe1
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/xss-nginx-module/tarball/v${NGINX_XSS_VERSION}/:xss
DISTFILES+= agentzh-xss-nginx-module-v${NGINX_XSS_VERSION}-${GIT_XSS_VERSION}.tar.gz:xss
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-xss-nginx-module-${GIT_XSS_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MWWW}
PLIST_SUB+= WWWDATA=""
.else
PLIST_SUB+= WWWDATA="@comment "
.endif

.else
CONFIGURE_ARGS+=--without-http
PLIST_SUB+= WWWDATA="@comment "
.endif      # WITH_HTTP

.if ${PORT_OPTIONS:MMAIL}
CONFIGURE_ARGS+=--with-mail
.if empty(PORT_OPTIONS:MMAIL_IMAP)
CONFIGURE_ARGS+=--without-mail_imap_module
.endif
.if empty(PORT_OPTIONS:MMAIL_POP3)
CONFIGURE_ARGS+=--without-mail_pop3_module
.endif
.if empty(PORT_OPTIONS:MMAIL_SMTP)
CONFIGURE_ARGS+=--without-mail_smtp_module
.endif
.if ${PORT_OPTIONS:MMAIL_SSL}
NGINX_OPENSSL=  yes
CONFIGURE_ARGS+=--with-mail_ssl_module
.endif
.endif      # WITH_MAIL

.if ${PORT_OPTIONS:MHTTP_SSL} || defined(USE_HTTP_SSL)
NGINX_OPENSSL=  yes
CONFIGURE_ARGS+=--with-http_ssl_module
.endif

.if defined(USE_NGINX_DEVEL_KIT)
NGINX_DEVEL_KIT_VERSION=    0.2.17
GIT_DEVEL_KIT_VERSION=  0-gbc97eea
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/simpl/ngx_devel_kit/tarball/v${NGINX_DEVEL_KIT_VERSION}/:devel_kit
DISTFILES+= simpl-ngx_devel_kit-v${NGINX_DEVEL_KIT_VERSION}-${GIT_DEVEL_KIT_VERSION}.tar.gz:devel_kit
CONFIGURE_ARGS+=--add-module=${WRKDIR}/simpl-ngx_devel_kit-${GIT_DEVEL_KIT_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MARRAYVAR}
USE_NGINX_DEVEL_KIT=    yes
NGINX_ARRAYVAR_VERSION= 0.03rc1
GIT_ARRAYVAR_VERSION=   0-gfed751a
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/agentzh/array-var-nginx-module/tarball/v${NGINX_ARRAYVAR_VERSION}/:arrayvar
DISTFILES+= agentzh-array-var-nginx-module-v${NGINX_ARRAYVAR_VERSION}-${GIT_ARRAYVAR_VERSION}.tar.gz:arrayvar
CONFIGURE_ARGS+=--add-module=${WRKDIR}/agentzh-array-var-nginx-module-${GIT_ARRAYVAR_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MFORMINPUT}
USE_NGINX_DEVEL_KIT=    yes
NGINX_FORMINPUT_VERSION=    0.07rc5
GIT_FORMINPUT_VERSION=  0-gd41681d
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/calio/form-input-nginx-module/tarball/v${NGINX_FORMINPUT_VERSION}/:forminput
DISTFILES+= calio-form-input-nginx-module-v${NGINX_FORMINPUT_VERSION}-${GIT_FORMINPUT_VERSION}.tar.gz:forminput
CONFIGURE_ARGS+=--add-module=${WRKDIR}/calio-form-input-nginx-module-${GIT_FORMINPUT_VERSION:S/^0-g//}
.endif

.if ${PORT_OPTIONS:MICONV}
LIB_DEPENDS+=   iconv:${PORTSDIR}/converters/libiconv
USE_NGINX_DEVEL_KIT=    yes
NGINX_ICONV_VERSION=    0.10rc7
GIT_ICONV_VERSION=  0-gabdac17
FETCH_ARGS= -pRr
MASTER_SITES+=  https://github.com/calio/iconv-nginx-module/tarball/v${NGINX_ICONV_VERSION}/:iconv
DISTFILES+= calio-iconv-nginx-module-v${NGINX_ICONV_VERSION}-${GIT_ICONV_VERSION}.tar.gz:iconv
CONFIGURE_ARGS+=--add-module=${WRKDIR}/calio-iconv-nginx-module-${GIT_ICONV_VERSION:S/^0-g//}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-calio-iconv-nginx-module-config
.endif

PLIST_SUB+= NGINX_TMPDIR=${NGINX_TMPDIR} WWWOWN=${WWWOWN} WWWGRP=${WWWGRP}

USERS?= ${WWWOWN}
GROUPS?=${WWWGRP}

.if defined(NGINX_OPENSSL)
USE_OPENSSL=    yes
.endif

pre-everything::
    @${ECHO_MSG}
.if ${PORT_OPTIONS:MHTTP_UPSTREAM_FAIR}
    @${ECHO_MSG} "Enable http_ssl module to build upstream_fair with SSL support"
.endif
.if ${PORT_OPTIONS:MPASSENGER}
    @${ECHO_MSG} "This port install Passenger module only"
.endif
    @${ECHO_MSG}

post-extract:
.if ${PORT_OPTIONS:MGRIDFS}
    @${RMDIR} ${WRKDIR}/mdirolf-nginx-gridfs-${GIT_GRIDFS_VERSION:S/^0-g//}/mongo-c-driver/
    @${MV} \
    ${WRKDIR}/mongodb-mongo-c-driver-${GIT_MONGO_C_DRIVER_VERSION:S/^0-g//}/ \
    ${WRKDIR}/mdirolf-nginx-gridfs-${GIT_GRIDFS_VERSION:S/^0-g//}/mongo-c-driver/
.endif

post-patch:
    @${REINPLACE_CMD} 's!%%HTTP_PORT%%!${HTTP_PORT}!; \
        s!%%PREFIX%%!${PREFIX}!' \
        ${WRKSRC}/conf/nginx.conf
.if ${PORT_OPTIONS:MHTTP_ACCESSKEY}
    @${REINPLACE_CMD} \
        's!$$HTTP_ACCESSKEY_MODULE!ngx_http_accesskey_module!' \
        ${WRKDIR}/nginx-accesskey-${NGINX_ACCESSKEY_VERSION}/config
.endif
# linker error acquire if --std=c99 defined, add "static" to inline function
.if ${PORT_OPTIONS:MHTTP_ZIP}
    @${REINPLACE_CMD} \
        's!^inline!static inline!' \
        ${WRKDIR}/mod_zip-${NGINX_ZIP_VERSION}/ngx_http_zip_parsers.*
.endif
.if ${PORT_OPTIONS:MDRIZZLE}
    @${REINPLACE_CMD} \
        's!%%PREFIX%%!${LOCALBASE}!g' \
        ${WRKDIR}/chaoslawful-drizzle-nginx-module-${GIT_DRIZZLE_VERSION:S/^0-g//}/config
.endif
# Respect CFLAGS by remove needless --std=c99 flag
.if ${PORT_OPTIONS:MGRIDFS}
    @${REINPLACE_CMD} \
        's!--std=c99!-DMONGO_HAVE_STDINT!' \
        ${WRKDIR}/mdirolf-nginx-gridfs-${GIT_GRIDFS_VERSION:S/^0-g//}/config
.endif
.if ${PORT_OPTIONS:MPASSENGER}
    @${REINPLACE_CMD} 's!-lpthread!${PTHREAD_LIBS}!g' \
        ${WRKDIR}/passenger-${PASSENGER_VERSION}/ext/nginx/config
    @${REINPLACE_CMD} 's!-Wall!!g; \
        s!#{PlatformInfo.debugging_cflags}!${CFLAGS}!g; \
        s!-O2!!g; \
        42s!true!false!' \
        ${WRKDIR}/passenger-${PASSENGER_VERSION}/build/config.rb
    @${REINPLACE_CMD} \
        's!-I/usr/include/libev!!; \
        s!-lev!!; \
        s!-Iext/libev!!' \
        ${WRKDIR}/passenger-${PASSENGER_VERSION}/build/common_library.rb
    @${REINPLACE_CMD} 's!-lpthread!${PTHREAD_LIBS}!g' \
        ${WRKDIR}/passenger-${PASSENGER_VERSION}/lib/phusion_passenger/platform_info/compiler.rb
.endif
.if ${PORT_OPTIONS:MPOSTGRES}
    @${REINPLACE_CMD} \
        's!%%PREFIX%%!${LOCALBASE}!g' \
        ${WRKDIR}/ngx_postgres-${NGINX_POSTGRES_VERSION}/config
.endif
.if ${PORT_OPTIONS:MSFLOW}
    @${REINPLACE_CMD} \
        's!%%PREFIX%%!${LOCALBASE}!g' \
        ${WRKDIR}/nginx-sflow-module-${NGINX_SFLOW_VERSION}/ngx_http_sflow_config.h
.endif
.if ${PORT_OPTIONS:MSUPERVISORD}
    ( cd ${WRKDIR}/nginx_upstream_fair-${NGINX_UPSTREAM_FAIR_VERSION} && \
        ${PATCH} -p0 < \
            ${WRKDIR}/ngx_supervisord-${NGINX_SUPERVISORD_VERSION}/patches/ngx_http_upstream_fair_module.patch )
    ( cd ${WRKSRC} && \
        ${PATCH} -p0 < \
            ${WRKDIR}/ngx_supervisord-${NGINX_SUPERVISORD_VERSION}/patches/ngx_http_upstream_init_busy-0.8.17.patch )
.endif
.if ${PORT_OPTIONS:MTCP_PROXY}
    ( cd ${WRKSRC} && \
        ${PATCH} -p1 < \
            ${WRKDIR}/yaoweibin-nginx_tcp_proxy_module-${GIT_TCP_PROXY_VERSION:S/^0-g//}/tcp.patch )
.endif
.if ${PORT_OPTIONS:MICONV}
    @${REINPLACE_CMD} \
        's!%%PREFIX%%!${LOCALBASE}!g' \
        ${WRKDIR}/calio-iconv-nginx-module-${GIT_ICONV_VERSION:S/^0-g//}/config
.endif

do-build:
    @cd ${WRKSRC} && ${MAKE}

do-install:
    ${MKDIR} ${ETCDIR}
    ${INSTALL_PROGRAM} ${WRKSRC}/objs/nginx ${PREFIX}/sbin
.for i in koi-utf koi-win win-utf
    ${INSTALL_DATA} ${WRKSRC}/conf/${i} ${ETCDIR}
.endfor
.for i in fastcgi_params mime.types nginx.conf scgi_params uwsgi_params
    [ -f ${ETCDIR}/${i} ] || \
        ${INSTALL_DATA} ${WRKSRC}/conf/${i} ${ETCDIR}
    ${INSTALL_DATA} ${WRKSRC}/conf/${i} ${ETCDIR}/${i}-dist
.endfor
.if !empty(PORT_OPTIONS:MHTTP) && !empty(PORT_OPTIONS:MWWW)
    ${MKDIR} ${PREFIX}/www/nginx-dist
.for i in index.html 50x.html
    ${INSTALL_DATA} ${WRKSRC}/html/${i} ${PREFIX}/www/nginx-dist
.endfor
    ${ECHO_CMD} "" >>${PREFIX}/www/nginx-dist/EXAMPLE_DIRECTORY-DONT_ADD_OR_TOUCH_ANYTHING
    [ -e ${PREFIX}/www/nginx ] || \
        ${LN} -sf ${PREFIX}/www/nginx-dist ${PREFIX}/www/nginx
.endif

.if !empty(PORT_OPTIONS:MHTTP) && !empty(PORT_OPTIONS:MHTTP_PERL)
    ${MKDIR} ${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH}/auto/nginx
    ${INSTALL_PROGRAM} ${WRKSRC}/objs/src/http/modules/perl/blib/arch/auto/nginx/nginx.so \
        ${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH}/auto/nginx
    ${INSTALL_DATA} ${WRKSRC}/objs/src/http/modules/perl/blib/arch/auto/nginx/nginx.bs \
        ${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH}/auto/nginx
    ${INSTALL_DATA} ${WRKSRC}/objs/src/http/modules/perl/blib/lib/nginx.pm \
        ${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH}/
.endif

.if ${PORT_OPTIONS:MNAXSI}
    ${INSTALL_DATA} \
    ${WRKDIR}/naxsi-${NGINX_NAXSI_VERSION}/naxsi_config/naxsi_core.rules \
    ${ETCDIR}
.endif

post-install:
.if !empty(PORT_OPTIONS:MHTTP) && !empty(PORT_OPTIONS:MHTTP_PERL)
    ${ECHO_CMD} ${SITE_PERL_REL}/${PERL_ARCH}/auto/nginx/nginx.so >> ${TMPPLIST}
    ${ECHO_CMD} ${SITE_PERL_REL}/${PERL_ARCH}/auto/nginx/nginx.bs >> ${TMPPLIST}
    ${ECHO_CMD} ${SITE_PERL_REL}/${PERL_ARCH}/nginx.pm >> ${TMPPLIST}
    ${ECHO_CMD} @dirrm ${SITE_PERL_REL}/${PERL_ARCH}/auto/nginx >> ${TMPPLIST}
.endif
.if !defined(NO_INSTALL_MANPAGES)
    @${INSTALL_MAN} ${WRKSRC}/objs/nginx.8 ${MAN8PREFIX}/man/man8
.endif

.if ${PORT_OPTIONS:MNAXSI}
    ${ECHO_CMD} etc/nginx/naxsi_core.rules >> ${TMPPLIST}
.endif

.include <bsd.port.mk>