d0eea97a9c89e86f135616b280bf4f3b84b4b1c1
[openwrt/staging/yousong.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.76
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
16 PKG_MD5SUM:=00f5ee66b4e4b7f14538bf62ae3c9461
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
31 include $(INCLUDE_DIR)/package.mk
32
33 define Package/dnsmasq/Default
34 SECTION:=net
35 CATEGORY:=Base system
36 TITLE:=DNS and DHCP server
37 URL:=http://www.thekelleys.org.uk/dnsmasq/
38 USERID:=dnsmasq=453:dnsmasq=453
39 endef
40
41 define Package/dnsmasq
42 $(call Package/dnsmasq/Default)
43 VARIANT:=nodhcpv6
44 endef
45
46 define Package/dnsmasq-dhcpv6
47 $(call Package/dnsmasq/Default)
48 TITLE += (with DHCPv6 support)
49 DEPENDS:=@IPV6
50 VARIANT:=dhcpv6
51 endef
52
53 define Package/dnsmasq-full
54 $(call Package/dnsmasq/Default)
55 TITLE += (with DNSSEC, DHCPv6, Auth DNS, IPset, Conntrack enabled by default)
56 DEPENDS:=+PACKAGE_dnsmasq_full_dnssec:libnettle \
57 +PACKAGE_dnsmasq_full_ipset:kmod-ipt-ipset \
58 +PACKAGE_dnsmasq_full_conntrack:libnetfilter-conntrack
59 VARIANT:=full
60 endef
61
62 define Package/dnsmasq/description
63 It is intended to provide coupled DNS and DHCP service to a LAN.
64 endef
65
66 define Package/dnsmasq-dhcpv6/description
67 $(call Package/dnsmasq/description)
68
69 This is a variant with DHCPv6 support
70 endef
71
72 define Package/dnsmasq-full/description
73 $(call Package/dnsmasq/description)
74
75 This is a fully configurable variant with DHCPv6, DNSSEC, Authoritative DNS and
76 IPset, Conntrack support enabled by default.
77 endef
78
79 define Package/dnsmasq/conffiles
80 /etc/config/dhcp
81 /etc/dnsmasq.conf
82 endef
83
84 define Package/dnsmasq-full/config
85 if PACKAGE_dnsmasq-full
86 config PACKAGE_dnsmasq_full_dhcpv6
87 bool "Build with DHCPv6 support."
88 depends on IPV6
89 default y
90 config PACKAGE_dnsmasq_full_dnssec
91 bool "Build with DNSSEC support."
92 default y
93 config PACKAGE_dnsmasq_full_auth
94 bool "Build with the facility to act as an authoritative DNS server."
95 default y
96 config PACKAGE_dnsmasq_full_ipset
97 bool "Build with IPset support."
98 default y
99 config PACKAGE_dnsmasq_full_conntrack
100 bool "Build with Conntrack support."
101 default y
102 endif
103 endef
104
105 Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
106 Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
107
108 TARGET_CFLAGS += -ffunction-sections -fdata-sections
109 TARGET_LDFLAGS += -Wl,--gc-sections
110
111 COPTS = $(if $(CONFIG_IPV6),,-DNO_IPV6)
112
113 ifeq ($(BUILD_VARIANT),nodhcpv6)
114 COPTS += -DNO_DHCP6
115 endif
116
117 ifeq ($(BUILD_VARIANT),full)
118 COPTS += $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcpv6),,-DNO_DHCP6) \
119 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dnssec),-DHAVE_DNSSEC) \
120 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_auth),,-DNO_AUTH) \
121 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_ipset),,-DNO_IPSET) \
122 $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_conntrack),-DHAVE_CONNTRACK,)
123 COPTS += $(if $(CONFIG_LIBNETTLE_MINI),-DNO_GMP,)
124 else
125 COPTS += -DNO_AUTH -DNO_IPSET
126 endif
127
128 MAKE_FLAGS := \
129 $(TARGET_CONFIGURE_OPTS) \
130 CFLAGS="$(TARGET_CFLAGS)" \
131 LDFLAGS="$(TARGET_LDFLAGS)" \
132 COPTS="$(COPTS)" \
133 PREFIX="/usr"
134
135 define Package/dnsmasq/install
136 $(INSTALL_DIR) $(1)/usr/sbin
137 $(CP) $(PKG_INSTALL_DIR)/usr/sbin/dnsmasq $(1)/usr/sbin/
138 $(INSTALL_DIR) $(1)/etc/config
139 $(INSTALL_DATA) ./files/dhcp.conf $(1)/etc/config/dhcp
140 $(INSTALL_DATA) ./files/dnsmasq.conf $(1)/etc/dnsmasq.conf
141 $(INSTALL_DIR) $(1)/etc/init.d
142 $(INSTALL_BIN) ./files/dnsmasq.init $(1)/etc/init.d/dnsmasq
143 $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
144 $(INSTALL_DATA) ./files/dnsmasq.hotplug $(1)/etc/hotplug.d/iface/25-dnsmasq
145 endef
146
147 Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install)
148
149 define Package/dnsmasq-full/install
150 $(call Package/dnsmasq/install,$(1))
151 ifneq ($(CONFIG_PACKAGE_dnsmasq_full_dnssec),)
152 $(INSTALL_DIR) $(1)/usr/share/dnsmasq
153 $(INSTALL_DATA) $(PKG_BUILD_DIR)/trust-anchors.conf $(1)/usr/share/dnsmasq
154 $(INSTALL_DIR) $(1)/lib/upgrade
155 $(INSTALL_BIN) ./files/dnsmasqsec-add-conffiles.sh $(1)/lib/upgrade
156 endif
157 endef
158
159 $(eval $(call BuildPackage,dnsmasq))
160 $(eval $(call BuildPackage,dnsmasq-dhcpv6))
161 $(eval $(call BuildPackage,dnsmasq-full))