busybox: add SRV support to nslookup_lede.c patch
[openwrt/openwrt.git] / package / utils / busybox / Makefile
1 #
2 # Copyright (C) 2006-2020 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:=busybox
11 PKG_VERSION:=1.33.0
12 PKG_RELEASE:=4
13 PKG_FLAGS:=essential
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
16 PKG_SOURCE_URL:=https://www.busybox.net/downloads \
17 http://sources.buildroot.net
18 PKG_HASH:=d568681c91a85edc6710770cebc1e80e042ad74d305b5c2e6d57a5f3de3b8fbd
19
20 PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam
21 PKG_BUILD_PARALLEL:=1
22 PKG_CHECK_FORMAT_SECURITY:=0
23
24 #Busybox use it's own PIE config flag and LDFLAGS are used with ld, not gcc.
25 PKG_ASLR_PIE:=0
26
27 PKG_LICENSE:=GPL-2.0
28 PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
29 PKG_CPE_ID:=cpe:/a:busybox:busybox
30
31 BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
32 BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
33
34 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_FEATURE_SUID),)
35 PKG_FILE_MODES:=/bin/busybox:root:root:4755
36 endif
37
38 include $(INCLUDE_DIR)/package.mk
39
40 ifeq ($(DUMP),)
41 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | mkhash md5)
42 endif
43
44 # All files provided by busybox will serve as fallback alternatives by opkg.
45 # There should be no need to enumerate ALTERNATIVES entries here
46 define Package/busybox/Default
47 SECTION:=base
48 CATEGORY:=Base system
49 MAINTAINER:=Felix Fietkau <nbd@nbd.name>
50 TITLE:=Core utilities for embedded Linux
51 URL:=http://busybox.net/
52 DEPENDS:=+BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
53 USERID:=ntp=123:ntp=123
54 endef
55
56 define Package/busybox
57 $(call Package/busybox/Default)
58 CONFLICTS:=busybox-selinux
59 VARIANT:=default
60 endef
61
62 define Package/busybox-selinux
63 $(call Package/busybox/Default)
64 TITLE += with SELinux support
65 DEPENDS += +libselinux
66 VARIANT:=selinux
67 PROVIDES:=busybox
68 endef
69
70 define Package/busybox/description
71 The Swiss Army Knife of embedded Linux.
72 It slices, it dices, it makes Julian Fries.
73 endef
74
75 define Package/busybox/config
76 source "$(SOURCE)/Config.in"
77 endef
78
79 ifdef CONFIG_BUSYBOX_CONFIG_FEATURE_SYSLOG
80 define Package/busybox/conffiles
81 /etc/syslog.conf
82 endef
83
84 Package/busybox-selinux/conffiles = $(Package/busybox/conffiles)
85 endif
86
87 # don't create a version string containing the actual timestamp
88 export KCONFIG_NOTIMESTAMP=1
89
90
91 ifndef CONFIG_USE_MUSL
92 LDLIBS:=m crypt
93 endif
94
95 LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
96 ifeq ($(CONFIG_USE_GLIBC),y)
97 LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
98 endif
99
100 ifeq ($(BUILD_VARIANT),selinux)
101 LDLIBS += selinux sepol
102 endif
103
104 TARGET_CFLAGS += -flto
105 TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
106
107 MAKE_VARS :=
108 MAKE_FLAGS += \
109 EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
110 EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
111 LDLIBS="$(LDLIBS)" \
112 LD="$(TARGET_CC)" \
113 SKIP_STRIP=y
114 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
115 MAKE_FLAGS += V=1
116 endif
117
118 define Build/Configure
119 rm -f $(PKG_BUILD_DIR)/.config
120 touch $(PKG_BUILD_DIR)/.config
121 ifeq ($(DEVICE_TYPE),nas)
122 echo "CONFIG_HDPARM=y" >> $(PKG_BUILD_DIR)/.config
123 endif
124 ifeq ($(BUILD_VARIANT),selinux)
125 cat $(TOPDIR)/$(SOURCE)/selinux.config >> $(PKG_BUILD_DIR)/.config
126 endif
127 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" >> $(PKG_BUILD_DIR)/.config
128 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
129 endef
130
131 define Build/Compile
132 $(call Build/Compile/Default, \
133 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
134 all install \
135 )
136 endef
137
138 define Package/busybox/install
139 $(INSTALL_DIR) $(1)/etc/init.d
140 $(INSTALL_DIR) $(1)/usr/sbin
141 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
142 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
143 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
144 endif
145 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
146 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
147 $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
148 $(INSTALL_DIR) $(1)/etc/capabilities $(1)/usr/share/acl.d
149 $(INSTALL_DATA) ./files/ntpd.capabilities $(1)/etc/capabilities/ntpd.json
150 $(INSTALL_DATA) ./files/ntpd_acl.json $(1)/usr/share/acl.d/ntpd.json
151 endif
152 -rm -rf $(1)/lib64
153 endef
154
155 Package/busybox-selinux/install = $(Package/busybox/install)
156
157 $(eval $(call BuildPackage,busybox))
158 $(eval $(call BuildPackage,busybox-selinux))