dnsmasq: fix ipv6 ipset bug
[openwrt/openwrt.git] / package / network / services / dnsmasq / Makefile
1 #
2 # Copyright (C) 2006-2016 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=dnsmasq
11 PKG_VERSION:=2.80
12 PKG_RELEASE:=4
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
16 PKG_HASH:=cdaba2785e92665cf090646cba6f94812760b9d7d8c8d0cfb07ac819377a63bb
17
18 PKG_LICENSE:=GPL-2.0
19 PKG_LICENSE_FILES:=COPYING
20 PKG_CPE_ID:=cpe:/a:thekelleys:dnsmasq
21
22 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
23
24 PKG_INSTALL:=1
25 PKG_BUILD_PARALLEL:=1
26 PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcp \
27 CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcpv6 \
28 CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dnssec \
29 CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_auth \
30 CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_ipset \
31 CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_conntrack \
32 CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_noid \
33 CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_broken_rtc
34
35 include $(INCLUDE_DIR)/package.mk
36
37 define Package/dnsmasq/Default
38 SECTION:=net
39 CATEGORY:=Base system
40 TITLE:=DNS and DHCP server
41 URL:=http://www.thekelleys.org.uk/dnsmasq/
42 DEPENDS:=+libubus
43 USERID:=dnsmasq=453:dnsmasq=453
44 endef
45
46 define Package/dnsmasq
47 $(call Package/dnsmasq/Default)
48 VARIANT:=nodhcpv6
49 endef
50
51 define Package/dnsmasq-dhcpv6
52 $(call Package/dnsmasq/Default)
53 TITLE += (with DHCPv6 support)
54 DEPENDS+=@IPV6
55 VARIANT:=dhcpv6
56 PROVIDES:=dnsmasq
57 endef
58
59 define Package/dnsmasq-full
60 $(call Package/dnsmasq/Default)
61 TITLE += (with DNSSEC, DHCPv6, Auth DNS, IPset, Conntrack, NO_ID enabled by default)
62 DEPENDS+=+PACKAGE_dnsmasq_full_dnssec:libnettle \
63 +PACKAGE_dnsmasq_full_ipset:kmod-ipt-ipset \
64 +PACKAGE_dnsmasq_full_conntrack:libnetfilter-conntrack
65 VARIANT:=full
66 PROVIDES:=dnsmasq
67 endef
68
69 define Package/dnsmasq/description
70 It is intended to provide coupled DNS and DHCP service to a LAN.
71 endef
72
73 define Package/dnsmasq-dhcpv6/description
74 $(call Package/dnsmasq/description)
75
76 This is a variant with DHCPv6 support
77 endef
78
79 define Package/dnsmasq-full/description
80 $(call Package/dnsmasq/description)
81
82 This is a fully configurable variant with DHCPv4, DHCPv6, DNSSEC, Authoritative DNS
83 and IPset, Conntrack support & NO_ID enabled by default.
84 endef
85
86 define Package/dnsmasq/conffiles
87 /etc/config/dhcp
88 /etc/dnsmasq.conf
89 endef
90
91 define Package/dnsmasq-full/config
92 if PACKAGE_dnsmasq-full
93 config PACKAGE_dnsmasq_full_dhcp
94 bool "Build with DHCP support."
95 default y
96 config PACKAGE_dnsmasq_full_dhcpv6
97 bool "Build with DHCPv6 support."
98 depends on IPV6 && PACKAGE_dnsmasq_full_dhcp
99 default y
100 config PACKAGE_dnsmasq_full_dnssec
101 bool "Build with DNSSEC support."
102 default y
103 config PACKAGE_dnsmasq_full_auth
104 bool "Build with the facility to act as an authoritative DNS server."
105 default y
106 config PACKAGE_dnsmasq_full_ipset
107 bool "Build with IPset support."
108 default y
109 config PACKAGE_dnsmasq_full_conntrack
110 bool "Build with Conntrack support."
111 default y
112 config PACKAGE_dnsmasq_full_noid
113 bool "Build with NO_ID. (hide *.bind pseudo domain)"
114 default y
115 config PACKAGE_dnsmasq_full_broken_rtc
116 bool "Build with HAVE_BROKEN_RTC."
117 default n
118 endif
119 endef
120
121 Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
122 Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
123
124 TARGET_CFLAGS += -ffunction-sections -fdata-sections
125 TARGET_LDFLAGS += -Wl,--gc-sections
126
127 COPTS = -DHAVE_UBUS \
128 $(if $(CONFIG_IPV6),,-DNO_IPV6)
129
130 ifeq ($(BUILD_VARIANT),nodhcpv6)
131 COPTS += -DNO_DHCP6
132 endif
133
134 ifeq ($(BUILD_VARIANT),full)
135 COPTS += $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcp),,-DNO_DHCP) \
136 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcpv6),,-DNO_DHCP6) \
137 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dnssec),-DHAVE_DNSSEC) \
138 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_auth),,-DNO_AUTH) \
139 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_ipset),,-DNO_IPSET) \
140 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_conntrack),-DHAVE_CONNTRACK,) \
141 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_noid),-DNO_ID,) \
142 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_broken_rtc),-DHAVE_BROKEN_RTC)
143 COPTS += $(if $(CONFIG_LIBNETTLE_MINI),-DNO_GMP,)
144 else
145 COPTS += -DNO_AUTH -DNO_IPSET -DNO_ID
146 endif
147
148 MAKE_FLAGS := \
149 $(TARGET_CONFIGURE_OPTS) \
150 CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
151 LDFLAGS="$(TARGET_LDFLAGS)" \
152 COPTS="$(COPTS)" \
153 PREFIX="/usr"
154
155 define Package/dnsmasq/install
156 $(INSTALL_DIR) $(1)/usr/sbin
157 $(CP) $(PKG_INSTALL_DIR)/usr/sbin/dnsmasq $(1)/usr/sbin/
158 $(INSTALL_DIR) $(1)/etc/config
159 $(INSTALL_CONF) ./files/dhcp.conf $(1)/etc/config/dhcp
160 $(INSTALL_CONF) ./files/dnsmasq.conf $(1)/etc/dnsmasq.conf
161 $(INSTALL_DIR) $(1)/etc/init.d
162 $(INSTALL_BIN) ./files/dnsmasq.init $(1)/etc/init.d/dnsmasq
163 $(INSTALL_DIR) $(1)/etc/hotplug.d/dhcp
164 $(INSTALL_DIR) $(1)/etc/hotplug.d/neigh
165 $(INSTALL_DIR) $(1)/etc/hotplug.d/ntp
166 $(INSTALL_DIR) $(1)/etc/hotplug.d/tftp
167 $(INSTALL_CONF) ./files/dnsmasqsec.hotplug $(1)/etc/hotplug.d/ntp/25-dnsmasqsec
168 $(INSTALL_DIR) $(1)/usr/share/dnsmasq
169 $(INSTALL_CONF) ./files/dhcpbogushostname.conf $(1)/usr/share/dnsmasq/
170 $(INSTALL_CONF) ./files/rfc6761.conf $(1)/usr/share/dnsmasq/
171 $(INSTALL_DIR) $(1)/usr/lib/dnsmasq
172 $(INSTALL_BIN) ./files/dhcp-script.sh $(1)/usr/lib/dnsmasq/dhcp-script.sh
173 $(INSTALL_DIR) $(1)/usr/share/acl.d
174 $(INSTALL_DATA) ./files/dnsmasq_acl.json $(1)/usr/share/acl.d/
175 endef
176
177 Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install)
178
179 define Package/dnsmasq-full/install
180 $(call Package/dnsmasq/install,$(1))
181 ifneq ($(CONFIG_PACKAGE_dnsmasq_full_dnssec),)
182 $(INSTALL_DIR) $(1)/usr/share/dnsmasq
183 $(INSTALL_CONF) $(PKG_BUILD_DIR)/trust-anchors.conf $(1)/usr/share/dnsmasq
184 endif
185 endef
186
187 $(eval $(call BuildPackage,dnsmasq))
188 $(eval $(call BuildPackage,dnsmasq-dhcpv6))
189 $(eval $(call BuildPackage,dnsmasq-full))