Add snort package, with experimental -custom package for build-time package customiza...
[openwrt/svn-archive/archive.git] / openwrt / package / snort / Makefile
1 # $Id$
2
3 include $(TOPDIR)/rules.mk
4
5 PKG_NAME:=snort
6 PKG_VERSION:=2.3.2
7 PKG_RELEASE:=1
8 PKG_MD5SUM:=692602827ce9d1a611630149f8e50ec8
9
10 PKG_SOURCE_URL:= \
11 http://www.snort.org/dl/current/ \
12 http://nthill.free.fr/openwrt/sources/$(PKG_NAME)/
13 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
14 PKG_CAT:=zcat
15
16 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
17 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
18
19 include $(TOPDIR)/package/templates.mk
20
21 PKG_CONFIGURE_OPTS := \
22 --target=$(GNU_TARGET_NAME) \
23 --host=$(GNU_TARGET_NAME) \
24 --build=$(GNU_HOST_NAME) \
25 --program-prefix="" \
26 --program-suffix="" \
27 --prefix=/usr \
28 --exec-prefix=/usr \
29 --bindir=/usr/sbin \
30 --datadir=/usr/share \
31 --includedir=/usr/include \
32 --infodir=/usr/share/info \
33 --libdir=/usr/lib \
34 --libexecdir=/usr/lib/locate \
35 --localstatedir=/var/lib \
36 --mandir=/usr/share/man \
37 --sbindir=/usr/sbin \
38 --sysconfdir=/etc \
39 $(DISABLE_LARGEFILE) \
40 $(DISABLE_NLS) \
41 --enable-shared \
42 --disable-static \
43 --enable-flexresp \
44 --disable-smbalerts \
45 --with-libnet-includes="$(STAGING_DIR)/usr/include" \
46 --with-libnet-libraries="$(STAGING_DIR)/usr/lib" \
47 --with-libpcap-includes="$(STAGING_DIR)/usr/include" \
48 --with-libpcap-libraries="$(STAGING_DIR)/usr/lib" \
49 --with-libpcre-includes="$(STAGING_DIR)/usr/include" \
50 --with-libpcre-libraries="$(STAGING_DIR)/usr/lib" \
51 --without-odbc \
52 --without-openssl \
53 --without-oracle \
54 --without-snmp \
55
56 SNORT_BASIC_CONFIGURE_OPTS := \
57 --without-mysql \
58 --without-postgresql \
59
60 SNORT_MYSQL_CONFIGURE_OPTS := \
61 --with-mysql=$(STAGING_DIR)/usr \
62 --without-postgresql \
63
64 SNORT_PGSQL_CONFIGURE_OPTS := \
65 --without-mysql \
66 --with-postgresql=$(STAGING_DIR)/usr \
67
68 SNORT_CUSTOM_CONFIGURE_OPTS := \
69
70 ifeq ($(BR2_PACKAGE_SNORT_WITH_MYSQL),y)
71 SNORT_CUSTOM_CONFIGURE_OPTS += --with-mysql="$(STAGING_DIR)/usr"
72 else
73 SNORT_CUSTOM_CONFIGURE_OPTS += --without-mysql
74 endif
75 ifeq ($(BR2_PACKAGE_SNORT_WITH_PGSQL),y)
76 SNORT_CUSTOM_CONFIGURE_OPTS += --with-postgresql="$(STAGING_DIR)/usr"
77 else
78 SNORT_CUSTOM_CONFIGURE_OPTS += --without-postgresql
79 endif
80
81 define PKG_build
82
83 ifneq ($(BR2_PACKAGE_$(1)),)
84 BUILD_TARGETS += $(PKG_BUILD_DIR)/$(2)
85 endif
86
87 $(PKG_BUILD_DIR)/$(2): $(PKG_BUILD_DIR)/.prepared
88 -$(MAKE) -C $(PKG_BUILD_DIR) distclean
89 (cd $(PKG_BUILD_DIR); rm -rf config.{cache,status} ; \
90 $(TARGET_CONFIGURE_OPTS) \
91 CFLAGS="$(TARGET_CFLAGS)" \
92 CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/usr/include/mysql" \
93 LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/usr/lib/mysql" \
94 ./configure \
95 $(PKG_CONFIGURE_OPTS) \
96 $$($(1)_CONFIGURE_OPTS) \
97 );
98 $(MAKE) -C $(PKG_BUILD_DIR)
99 mv $(PKG_BUILD_DIR)/src/snort $(PKG_BUILD_DIR)/$(2)
100
101 $(PKG_INSTALL_DIR)/usr/sbin/$(2): $(PKG_BUILD_DIR)/$(2)
102 install -m0755 $(PKG_BUILD_DIR)/$(2) $(PKG_INSTALL_DIR)/usr/sbin/
103
104 $$(IPKG_$(1)): $(PKG_BUILD_DIR)/.installed $(PKG_INSTALL_DIR)/usr/sbin/$(2)
105 rm -rf $$(IDIR_$(1))
106 $(SCRIPT_DIR)/make-ipkg-dir.sh $$(IDIR_$(1)) ./ipkg/$(2).control $(3) $(4)
107 install -m0644 ./ipkg/snort.conffiles $$(IDIR_$(1))/CONTROL/conffiles
108 install -d -m0755 $$(IDIR_$(1))/etc/default
109 install -m0644 ./ipkg/snort.default $$(IDIR_$(1))/etc/default/snort
110 install -d -m0755 $$(IDIR_$(1))/etc/init.d
111 install -m0755 ./ipkg/snort.init $$(IDIR_$(1))/etc/init.d/snort
112 install -d -m0755 $$(IDIR_$(1))/etc/snort
113 install -m0644 $(PKG_BUILD_DIR)/etc/snort.conf $$(IDIR_$(1))/etc/snort/
114 install -m0644 $(PKG_BUILD_DIR)/etc/classification.config $$(IDIR_$(1))/etc/snort/
115 install -m0644 $(PKG_BUILD_DIR)/etc/gen-msg.map $$(IDIR_$(1))/etc/snort/
116 install -m0644 $(PKG_BUILD_DIR)/etc/reference.config $$(IDIR_$(1))/etc/snort/
117 install -m0644 $(PKG_BUILD_DIR)/etc/sid-msg.map $$(IDIR_$(1))/etc/snort/
118 install -m0644 $(PKG_BUILD_DIR)/etc/threshold.conf $$(IDIR_$(1))/etc/snort/
119 install -m0644 $(PKG_BUILD_DIR)/etc/unicode.map $$(IDIR_$(1))/etc/snort/
120 install -d -m0755 $$(IDIR_$(1))/usr/sbin
121 cp -fpR $(PKG_INSTALL_DIR)/usr/sbin/$(2) $$(IDIR_$(1))/usr/sbin/snort
122 $(RSTRIP) $$(IDIR_$(1))
123 mkdir -p $(PACKAGE_DIR)
124 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
125
126 endef
127
128 $(eval $(call PKG_template,SNORT_BASIC,snort,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
129 $(eval $(call PKG_template,SNORT_MYSQL,snort-mysql,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
130 $(eval $(call PKG_template,SNORT_PGSQL,snort-pgsql,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
131 $(eval $(call PKG_template,SNORT_CUSTOM,snort-custom,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
132
133 $(eval $(call PKG_build,SNORT_BASIC,snort,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
134 $(eval $(call PKG_build,SNORT_MYSQL,snort-mysql,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
135 $(eval $(call PKG_build,SNORT_PGSQL,snort-pgsql,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
136 $(eval $(call PKG_build,SNORT_CUSTOM,snort-custom,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
137
138 include $(TOPDIR)/package/rules.mk
139
140 $(PKG_BUILD_DIR)/.built: $(BUILD_TARGETS)
141 touch $(PKG_BUILD_DIR)/.built
142
143 $(PKG_BUILD_DIR)/.installed: $(PKG_BUILD_DIR)/.built
144 mkdir -p $(PKG_INSTALL_DIR)
145 $(MAKE) -C $(PKG_BUILD_DIR) \
146 DESTDIR="$(PKG_INSTALL_DIR)" \
147 install
148 touch $(PKG_BUILD_DIR)/.installed
149