aboutsummaryrefslogtreecommitdiffstats
path: root/ftp/vsftpd/Makefile
blob: b53a56b863b4e678393875640946b63baead18e8 (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
# Created by: Neil Blakey-Milner
# $FreeBSD$

PORTNAME=   vsftpd
PORTVERSION=    3.0.2
CATEGORIES= ftp ipv6
MASTER_SITES=   https://security.appspot.com/downloads/ \
        ${MASTER_SITE_GENTOO}
MASTER_SITE_SUBDIR= distfiles
PKGNAMESUFFIX?= ${SSL_SUFFIX}${PKGNAMESUFFIX2}

MAINTAINER= dinoex@FreeBSD.org
COMMENT=    A FTP daemon that aims to be "very secure"

LICENSE=    GPLv2

ALL_TARGET= vsftpd
MAN5=       vsftpd.conf.5
MAN8=       vsftpd.8
USE_RC_SUBR=    vsftpd
DOCFILES=   AUDIT BENCHMARKS BUGS Changelog FAQ INSTALL LICENSE \
        README README.security README.ssl REFS REWARD \
        SIZE SPEED TODO TUNING

OPTIONS_DEFINE= VSFTPD_SSL PIDFILE STACKPROTECTOR
OPTIONS_DEFAULT?=   VSFTPD_SSL STACKPROTECTOR
NO_OPTIONS_SORT=yes

VSFTPD_SSL_DESC=Include support for SSL
PIDFILE_DESC=   Unofficial support for pidfile
STACKPROTECTOR_DESC=    Build with stack-protector

.include <bsd.port.pre.mk>

.if ${PORT_OPTIONS:MVSFTPD_SSL} && !defined(WITHOUT_SSL)
.include "${PORTSDIR}/Mk/bsd.openssl.mk"
SSL_SUFFIX= -ssl
CFLAGS+=    -I${OPENSSLINC}
LDFLAGS+=   -L${OPENSSLLIB}
.endif

.if ${PORT_OPTIONS:MPIDFILE}
EXTRA_PATCHES+= ${FILESDIR}/pidfile.patch
.endif

VSFTPD_OPTIMIZED=   ${CFLAGS:M-O*}
.if defined(CFLAGS) && !empty(VSFTPD_OPTIMIZED)
VSFTPD_NO_OPTIMIZED=    -e "s|-O2 ||"
.endif

.if ${PORT_OPTIONS:MSTACKPROTECTOR}
# BROKEN on FreeBSD with undefined reference to `__stack_chk_fail_local'
VSFTPD_LIBS=    -lssp_nonshared
.else
VSFTPD_NO_SSP=  -e "s|-fstack-protector --param=ssp-buffer-size=4 ||"
.endif

do-configure:
.if !defined(WITHOUT_SSL) && ${PORT_OPTIONS:MVSFTPD_SSL}
    ${REINPLACE_CMD} -e \
        "s|#undef VSF_BUILD_TCPWRAPPERS|#define VSF_BUILD_TCPWRAPPERS 1|" \
        -e "s|#undef VSF_BUILD_SSL|#define VSF_BUILD_SSL 1|" \
        ${WRKSRC}/builddefs.h
.else
    ${REINPLACE_CMD} -e \
        "s|#undef VSF_BUILD_TCPWRAPPERS|#define VSF_BUILD_TCPWRAPPERS 1|" \
        ${WRKSRC}/builddefs.h
.endif
    ${REINPLACE_CMD} -e "s|^listen=.*|listen=NO|" \
        -e "s|/etc/vsftpd.conf|${PREFIX}/etc/vsftpd.conf|" \
        ${WRKSRC}/defs.h ${WRKSRC}/vsftpd.conf
    ${REINPLACE_CMD} -e "s|/etc/v|${PREFIX}/etc/v|" \
        ${WRKSRC}/vsftpd.8 ${WRKSRC}/vsftpd.conf.5 ${WRKSRC}/tunables.c
    ${REINPLACE_CMD} ${VSFTPD_NO_OPTIMIZED} ${VSFTPD_NO_SSP} \
        -e "s|^CC   =   gcc|CC  =   ${CC}|" \
        -e "s|^CFLAGS   =   |CFLAGS =   ${CFLAGS} |" \
        -e "s|^LDFLAGS  =   |LDFLAGS    =   ${LDFLAGS} |" \
        -e "s|  -Wl,-s| ${VSFTPD_LIBS}|" \
        ${WRKSRC}/Makefile
    ${REINPLACE_CMD} -e '/-lutil/d' ${WRKSRC}/vsf_findlibs.sh
    @${ECHO_CMD} "secure_chroot_dir=${PREFIX}/share/vsftpd/empty" >> \
        ${WRKSRC}/vsftpd.conf
    @${ECHO_CMD} >>${WRKSRC}/vsftpd.conf ""
    @${ECHO_CMD} >>${WRKSRC}/vsftpd.conf \
        "# If using vsftpd in standalone mode, uncomment the next two lines:"
    @${ECHO_CMD} >>${WRKSRC}/vsftpd.conf "# listen=YES"
    @${ECHO_CMD} >>${WRKSRC}/vsftpd.conf "# background=YES"

pre-install:
    ${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL

do-install:
    ${INSTALL_PROGRAM} ${WRKSRC}/vsftpd ${PREFIX}/libexec/
    ${INSTALL_DATA} ${WRKSRC}/vsftpd.conf ${PREFIX}/etc/vsftpd.conf.dist
    ${INSTALL} -d ${PREFIX}/share/vsftpd/empty
    @if [ ! -e ${PREFIX}/etc/vsftpd.conf ]; then \
        ${INSTALL_DATA} ${WRKSRC}/vsftpd.conf ${PREFIX}/etc/ ; \
    fi
    ${MKDIR} ${PREFIX}/share/vsftpd/empty
    @for i in ${MAN8} ; do \
        ${INSTALL_MAN} -m 644 ${WRKSRC}/$${i} ${MANPREFIX}/man/man8/ ; \
        done
    @for i in ${MAN5} ; do \
        ${INSTALL_MAN} -m 644 ${WRKSRC}/$${i} ${MANPREFIX}/man/man5/ ; \
        done
    ${MKDIR} /var/ftp
.if ${PORT_OPTIONS:MDOCS}
    ${MKDIR} ${DOCSDIR}
.for i in ${DOCFILES}
    ${INSTALL_DATA} -m 644 ${WRKSRC}/${i} ${DOCSDIR}
.endfor
.for i in EXAMPLE SECURITY
    ${MKDIR} ${DOCSDIR}/${i}
    ${CP} -p -R -L ${WRKSRC}/${i}/./ ${DOCSDIR}/${i}/
    ${CHMOD} -R -L a+rX,go-w ${DOCSDIR}/${i}/
.endfor
.endif

.include <bsd.port.post.mk>