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