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