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