grub2: fix build when ASLR enabled
[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.81rc4
12 PKG_VERSION:=$(subst test,~~test,$(subst rc,~rc,$(PKG_UPSTREAM_VERSION)))
13 PKG_RELEASE:=3
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_UPSTREAM_VERSION).tar.xz
16 PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq/release-candidates
17 PKG_HASH:=0c4770eb05a0dfe5900d54b115f0f085f08b403fef6e96a8000fbcecc7c6edfa
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 endef
93
94 define Package/dnsmasq-full/config
95 if PACKAGE_dnsmasq-full
96 config PACKAGE_dnsmasq_full_dhcp
97 bool "Build with DHCP support."
98 default y
99 config PACKAGE_dnsmasq_full_dhcpv6
100 bool "Build with DHCPv6 support."
101 depends on IPV6 && PACKAGE_dnsmasq_full_dhcp
102 default y
103 config PACKAGE_dnsmasq_full_dnssec
104 bool "Build with DNSSEC support."
105 default y
106 config PACKAGE_dnsmasq_full_auth
107 bool "Build with the facility to act as an authoritative DNS server."
108 default y
109 config PACKAGE_dnsmasq_full_ipset
110 bool "Build with IPset support."
111 default y
112 config PACKAGE_dnsmasq_full_conntrack
113 bool "Build with Conntrack support."
114 default y
115 config PACKAGE_dnsmasq_full_noid
116 bool "Build with NO_ID. (hide *.bind pseudo domain)"
117 default y
118 config PACKAGE_dnsmasq_full_broken_rtc
119 bool "Build with HAVE_BROKEN_RTC."
120 default n
121 config PACKAGE_dnsmasq_full_tftp
122 bool "Build with TFTP server support."
123 default y
124 endif
125 endef
126
127 Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
128 Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
129
130 TARGET_CFLAGS += -flto
131 TARGET_LDFLAGS += -flto=jobserver
132
133 COPTS = -DHAVE_UBUS -DHAVE_POLL_H \
134 $(if $(CONFIG_IPV6),,-DNO_IPV6)
135
136 ifeq ($(BUILD_VARIANT),nodhcpv6)
137 COPTS += -DNO_DHCP6
138 endif
139
140 ifeq ($(BUILD_VARIANT),full)
141 COPTS += $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcp),,-DNO_DHCP) \
142 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcpv6),,-DNO_DHCP6) \
143 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dnssec),-DHAVE_DNSSEC) \
144 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_auth),,-DNO_AUTH) \
145 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_ipset),,-DNO_IPSET) \
146 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_conntrack),-DHAVE_CONNTRACK,) \
147 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_noid),-DNO_ID,) \
148 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_broken_rtc),-DHAVE_BROKEN_RTC) \
149 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_tftp),,-DNO_TFTP)
150 COPTS += $(if $(CONFIG_LIBNETTLE_MINI),-DNO_GMP,)
151 else
152 COPTS += -DNO_AUTH -DNO_IPSET -DNO_ID
153 endif
154
155 MAKE_FLAGS := \
156 $(TARGET_CONFIGURE_OPTS) \
157 CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
158 LDFLAGS="$(TARGET_LDFLAGS)" \
159 COPTS="$(COPTS)" \
160 PREFIX="/usr"
161
162 define Package/dnsmasq/install
163 $(INSTALL_DIR) $(1)/usr/sbin
164 $(CP) $(PKG_INSTALL_DIR)/usr/sbin/dnsmasq $(1)/usr/sbin/
165 $(INSTALL_DIR) $(1)/etc/config
166 $(INSTALL_CONF) ./files/dhcp.conf $(1)/etc/config/dhcp
167 $(INSTALL_CONF) ./files/dnsmasq.conf $(1)/etc/dnsmasq.conf
168 $(INSTALL_DIR) $(1)/etc/init.d
169 $(INSTALL_BIN) ./files/dnsmasq.init $(1)/etc/init.d/dnsmasq
170 $(INSTALL_DIR) $(1)/etc/hotplug.d/dhcp
171 $(INSTALL_DIR) $(1)/etc/hotplug.d/neigh
172 $(INSTALL_DIR) $(1)/etc/hotplug.d/ntp
173 $(INSTALL_DIR) $(1)/etc/hotplug.d/tftp
174 $(INSTALL_CONF) ./files/dnsmasqsec.hotplug $(1)/etc/hotplug.d/ntp/25-dnsmasqsec
175 $(INSTALL_DIR) $(1)/usr/share/dnsmasq
176 $(INSTALL_CONF) ./files/dhcpbogushostname.conf $(1)/usr/share/dnsmasq/
177 $(INSTALL_CONF) ./files/rfc6761.conf $(1)/usr/share/dnsmasq/
178 $(INSTALL_DIR) $(1)/usr/lib/dnsmasq
179 $(INSTALL_BIN) ./files/dhcp-script.sh $(1)/usr/lib/dnsmasq/dhcp-script.sh
180 $(INSTALL_DIR) $(1)/usr/share/acl.d
181 $(INSTALL_DATA) ./files/dnsmasq_acl.json $(1)/usr/share/acl.d/
182 $(INSTALL_DIR) $(1)/etc/uci-defaults
183 $(INSTALL_BIN) ./files/50-dnsmasq-migrate-resolv-conf-auto.sh $(1)/etc/uci-defaults
184 endef
185
186 Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install)
187
188 define Package/dnsmasq-full/install
189 $(call Package/dnsmasq/install,$(1))
190 ifneq ($(CONFIG_PACKAGE_dnsmasq_full_dnssec),)
191 $(INSTALL_DIR) $(1)/usr/share/dnsmasq
192 $(INSTALL_CONF) $(PKG_BUILD_DIR)/trust-anchors.conf $(1)/usr/share/dnsmasq
193 endif
194 endef
195
196 $(eval $(call BuildPackage,dnsmasq))
197 $(eval $(call BuildPackage,dnsmasq-dhcpv6))
198 $(eval $(call BuildPackage,dnsmasq-full))