aboutsummaryrefslogtreecommitdiffstats
path: root/security/snort/Makefile
blob: 08be8a45ef1137a14115462d50bed122fe489f3f (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
# New ports collection makefile for:    snort
# Date created:     Mon Aug  2 12:04:08 CEST 1999
# Whom:         Dirk Froemberg <dirk@FreeBSD.org>
#
# $FreeBSD$
#

PORTNAME=   snort
PORTVERSION=    2.8.4.1
CATEGORIES= security
MASTER_SITES=   http://www.snort.org/dl/ \
        http://dl.snort.org/snort-current/

MAINTAINER= clsung@FreeBSD.org
COMMENT=    Lightweight network intrusion detection system

LIB_DEPENDS=    pcre.0:${PORTSDIR}/devel/pcre

CONFLICTS?= snort-1.* snort-2.[0-7].*

OPTIONS=    DYNAMIC "Enable dynamic plugin support" on \
        FLEXRESP "Flexible response to events" off \
        FLEXRESP2 "Flexible response to events (version 2)" off \
        MYSQL "Enable MySQL support" off \
        ODBC "Enable ODBC support" off \
        POSTGRESQL "Enable PostgreSQL support" off \
        PRELUDE "Enable Prelude NIDS integration" off \
        PERPROFILE "Enable Performance Profiling" off
#       SNORTSAM "Enable output plugin to SnortSam" on

USE_RC_SUBR=    snort.sh
SUB_FILES=  pkg-message
GNU_CONFIGURE=  yes
CONFIGURE_ENV=  LDFLAGS="${LDFLAGS}"

CONFIG_DIR?=    ${PREFIX}/etc/snort
CONFIG_FILES=   classification.config gen-msg.map reference.config \
        sid-msg.map snort.conf threshold.conf unicode.map
RULES_DIR=  ${PREFIX}/etc/snort/rules
LOGS_DIR=   /var/log/snort

MAN8=       snort.8
DOCS=       RELEASE.NOTES doc/AUTHORS doc/BUGS doc/CREDITS \
        doc/README* doc/USAGE doc/*.pdf

.include <bsd.port.pre.mk>

.if defined(WITH_FLEXRESP)
LIBNET_CONFIG?=     ${LOCALBASE}/bin/libnet10-config
.elif defined(WITH_FLEXRESP2)
LIBNET_CONFIG?=     ${LOCALBASE}/bin/libnet11-config
.endif

.if exists(${LIBNET_CONFIG})
LIBNET_CFLAGS!= ${LIBNET_CONFIG} --cflags
LIBNET_LIBS!=   ${LIBNET_CONFIG} --libs
LIBNET_INCDIR=  ${LIBNET_CFLAGS:M-I*:S/-I//}
LIBNET_LIBDIR=  ${LIBNET_LIBS:M-L*:S/-L//}
.endif

.if !defined(WITHOUT_DYNAMIC)
USE_AUTOTOOLS=  libtool:22
USE_LDCONFIG=   yes
CONFIGURE_ARGS+=    --enable-dynamicplugin
PLIST_SUB+= DYNAMIC=""
.else
PLIST_SUB+= DYNAMIC="@comment "
.endif

.if defined(WITH_FLEXRESP)
.if defined(WITH_FLEXRESP2)
IGNORE=         options FLEXRESP and FLEXRESP2 are mutually exclusive
.endif
BUILD_DEPENDS+=     ${LIBNET_CONFIG}:${PORTSDIR}/net/libnet10
CONFIGURE_ARGS+=    --enable-flexresp \
            --with-libnet-includes=${LIBNET_INCDIR} \
            --with-libnet-libraries=${LIBNET_LIBDIR}
.endif

.if defined(WITH_FLEXRESP2)
BUILD_DEPENDS+=     ${LIBNET_CONFIG}:${PORTSDIR}/net/libnet \
            libdnet*>=1.10_1:${PORTSDIR}/net/libdnet
CONFIGURE_ARGS+=    --enable-flexresp2 \
            --with-libnet-includes=${LIBNET_INCDIR} \
            --with-libnet-libraries=${LIBNET_LIBDIR}
.endif

.if defined(WITH_MYSQL)
USE_MYSQL=      yes
CONFIGURE_ARGS+=    --with-mysql=${LOCALBASE}
.else
CONFIGURE_ARGS+=    --with-mysql=no
.endif

.if defined(WITH_ODBC)
LIB_DEPENDS+=       odbc.1:${PORTSDIR}/databases/unixODBC
CONFIGURE_ARGS+=    --with-odbc=${LOCALBASE}
LDFLAGS+=       ${PTHREAD_LIBS}
.else
CONFIGURE_ARGS+=    --with-odbc=no
.endif

.if defined(WITH_POSTGRESQL)
USE_PGSQL=      yes
CONFIGURE_ARGS+=    --with-postgresql=${LOCALBASE}
.if exists(/usr/lib/libssl.a) && exists(/usr/lib/libcrypto.a)
LDFLAGS+=       -lssl -lcrypto
.endif
.else
CONFIGURE_ARGS+=    --with-postgresql=no
.endif

.if defined(WITH_PRELUDE)
LIB_DEPENDS+=       prelude.19:${PORTSDIR}/security/libprelude
CONFIGURE_ARGS+=    --enable-prelude
PLIST_SUB+=     PRELUDE=""
.else
CONFIGURE_ARGS+=    --disable-prelude
PLIST_SUB+=     PRELUDE="@comment "
.endif

.if defined(WITH_PERPROFILE)
CONFIGURE_ARGS+=    --enable-perfprofiling
.endif

#.if defined(WITH_SNORTSAM)
#PATCH_SITES+=http://www.freebsdbrasil.com.br/~urisso/files/snort/:snortsam
#PATCHFILES+=snortsam-2.8.2.1.diff:snortsam
#.endif

post-patch:
#.if defined(WITH_SNORTSAM)
#BUILD_DEPENDS+=        automake>=1.10.1:${PORTSDIR}/devel/automake110
#.endif
.if defined(NOPORTDOCS)
    @${REINPLACE_CMD} '/SUBDIRS = /s/doc//' ${WRKSRC}/Makefile.in
.endif

pre-configure:
#.if defined(WITH_SNORTSAM)
#   @cd ${WRKSRC} && ${SH} ${WRKSRC}/autojunk.sh
#.endif
    ${FIND} ${WRKSRC} -name 'Makefile.in' | ${XARGS} ${REINPLACE_CMD} -e \
        's|lib/snort_|lib/snort/|g'
    ${REINPLACE_CMD} "s,/etc/snort.conf,${CONFIG_DIR}/snort.conf," \
        ${WRKSRC}/src/snort.c ${WRKSRC}/snort.8
    ${REINPLACE_CMD} -e 's|lib/snort_|lib/snort/|g' ${WRKSRC}/etc/snort.conf
.if defined(WITH_FLEXRESP) || defined(WITH_FLEXRESP2)
    ${REINPLACE_CMD} -e 's|libnet-config|${LIBNET_CONFIG}|g' ${WRKSRC}/configure
.endif
.if defined(WITHOUT_DYNAMIC)
    ${REINPLACE_CMD} -e "s,-am: install-libLTLIBRARIES,-am:," \
        ${WRKSRC}/src/dynamic-plugins/sf_engine/Makefile.in
    @${CAT} ${PATCHDIR}/pkg-message-dynamicplugin
    @sleep 5
.endif

pre-install:
.if defined(WITH_POSTGRESQL)
    @${REINPLACE_CMD} -e '/REQUIRE:/ s|$$| postgresql|' ${WRKDIR}/snort.sh
.endif
.if defined(WITH_MYSQL)
    @${REINPLACE_CMD} -e '/REQUIRE:/ s|$$| mysql|' ${WRKDIR}/snort.sh
.endif

post-install:
.if !defined(WITHOUT_DYNAMIC)
    @${LIBTOOL} --finish ${LOCALBASE}/snort/dynamicpreprocessor
.endif
    [ -d ${CONFIG_DIR} ] || ${MKDIR} ${CONFIG_DIR}
    [ -d ${EXAMPLESDIR} ] || ${MKDIR} ${EXAMPLESDIR}
    [ -d ${RULES_DIR} ] || ${MKDIR} ${RULES_DIR}
    [ -d ${LOGS_DIR} ] || ${MKDIR} ${LOGS_DIR}
.for f in ${CONFIG_FILES}
    ${INSTALL_DATA} ${WRKSRC}/etc/${f} ${CONFIG_DIR}/${f}-sample
    ${INSTALL_DATA} ${WRKSRC}/etc/${f} ${EXAMPLESDIR}/${f}-sample
    @if [ ! -f ${CONFIG_DIR}/${f} ]; then \
        ${CP} -p ${CONFIG_DIR}/${f}-sample ${CONFIG_DIR}/${f} ; \
    fi
.endfor
    ${INSTALL_DATA} ${WRKSRC}/schemas/create* ${EXAMPLESDIR}
.if !defined(NOPORTDOCS)
    @${MKDIR} ${DOCSDIR}
    cd ${WRKSRC} && ${INSTALL_DATA} ${DOCS} ${DOCSDIR}
.endif
    @${CAT} ${PKGMESSAGE}

.include <bsd.port.post.mk>