diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index 549e150..f2a102a 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -30,6 +30,13 @@ BUSYBOX_CFLAGS += -I$(STAGING_DIR)/usr/include/tirpc/
 BUSYBOX_LDFLAGS += -ltirpc
 endif
 
+# linux-pam must be built first if user has custom
+# BusyBox .config file and that file has also login
+# applet (CONFIG_LOGIN) enabled.
+ifeq ($(shell sed -n "s/CONFIG_LOGIN=\(y\)/\1/p" $(BR2_PACKAGE_BUSYBOX_CONFIG)),y)
+BUSYBOX_DEPENDENCIES += linux-pam
+endif
+
 BUSYBOX_BUILD_CONFIG = $(BUSYBOX_DIR)/.config
 # Allows the build system to tweak CFLAGS
 BUSYBOX_MAKE_ENV = $(TARGET_MAKE_ENV) CFLAGS="$(BUSYBOX_CFLAGS)"
