xref: /OK3568_Linux_fs/buildroot/package/sudo/sudo.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# sudo
4#
5################################################################################
6
7SUDO_VERSION_MAJOR = 1.9.8
8SUDO_VERSION_MINOR = p2
9SUDO_VERSION = $(SUDO_VERSION_MAJOR)$(SUDO_VERSION_MINOR)
10SUDO_SITE = https://www.sudo.ws/sudo/dist
11SUDO_LICENSE = ISC, BSD-3-Clause
12SUDO_LICENSE_FILES = doc/LICENSE
13SUDO_CPE_ID_VERSION = $(SUDO_VERSION_MAJOR)
14SUDO_CPE_ID_UPDATE = $(SUDO_VERSION_MINOR)
15SUDO_SELINUX_MODULES = sudo
16# This is to avoid sudo's make install from chown()ing files which fails
17SUDO_INSTALL_TARGET_OPTS = INSTALL_OWNER="" DESTDIR="$(TARGET_DIR)" install
18SUDO_CONF_OPTS = \
19	--without-lecture \
20	--without-sendmail \
21	--without-umask \
22	--with-logging=syslog \
23	--without-interfaces \
24	--with-env-editor
25
26ifeq ($(BR2_PACKAGE_LINUX_PAM),y)
27define SUDO_INSTALL_PAM_CONF
28	$(INSTALL) -D -m 0644 package/sudo/sudo.pam $(TARGET_DIR)/etc/pam.d/sudo
29endef
30
31SUDO_DEPENDENCIES += linux-pam
32SUDO_CONF_OPTS += --with-pam
33SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_INSTALL_PAM_CONF
34else
35SUDO_CONF_OPTS += --without-pam
36endif
37
38ifeq ($(BR2_PACKAGE_ZLIB),y)
39SUDO_CONF_OPTS += --enable-zlib
40SUDO_DEPENDENCIES += zlib
41else
42SUDO_CONF_OPTS += --disable-zlib
43endif
44
45ifeq ($(BR2_PACKAGE_OPENLDAP),y)
46SUDO_DEPENDENCIES += openldap
47SUDO_CONF_OPTS += --with-ldap
48# If we are building sudo statically and openldap was linked with openssl, then
49# when we link sudo with openldap we need to specify the openssl libs, otherwise
50# it will fail with "undefined reference" errors.
51ifeq ($(BR2_STATIC_LIBS)$(BR2_PACKAGE_OPENSSL),yy)
52SUDO_DEPENDENCIES += host-pkgconf
53SUDO_CONF_ENV += LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs libssl libcrypto`"
54endif
55else
56SUDO_CONF_OPTS += --without-ldap
57endif
58
59# mksigname/mksiglist needs to run on build host to generate source files
60define SUDO_BUILD_MKSIGNAME_MKSIGLIST_HOST
61	$(MAKE) $(HOST_CONFIGURE_OPTS) \
62		CPPFLAGS="$(HOST_CPPFLAGS) -I../../include -I../.." \
63		-C $(@D)/lib/util mksigname mksiglist
64endef
65
66SUDO_POST_CONFIGURE_HOOKS += SUDO_BUILD_MKSIGNAME_MKSIGLIST_HOST
67
68define SUDO_PERMISSIONS
69	/usr/bin/sudo f 4755 0 0 - - - - -
70endef
71
72define SUDO_REMOVE_DIST_EXAMPLES
73	$(RM) $(TARGET_DIR)/etc/sudoers.dist
74	rmdir --ignore-fail-on-non-empty $(TARGET_DIR)/etc/sudoers.d
75endef
76SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_REMOVE_DIST_EXAMPLES
77
78define SUDO_USERS
79	- - sudo -1 - - - -
80endef
81
82define SUDO_ENABLE_SUDO_GROUP_RULE
83	$(SED) '/^# \%sudo\tALL=(ALL) ALL/s/^# //' $(TARGET_DIR)/etc/sudoers
84endef
85SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_ENABLE_SUDO_GROUP_RULE
86
87$(eval $(autotools-package))
88