xref: /illumos-gate/usr/src/cmd/su/Makefile (revision d17be682a2c70b4505d43c830bbd2603da11918d)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21#
22# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
26#
27# build two versions, su and su.static
28# su.static is dynamically linked; the .static suffix is historical.
29
30PROG =		su
31ROOTFS_PROG =	su.static
32DEFAULTFILES =	su.dfl
33
34include		../Makefile.cmd
35
36EMB_PROG =	embedded_su
37ROOTEMB_PROG =	$(ROOTLIB)/$(EMB_PROG)
38
39PROG_STATIC = $(ROOTSBIN)/$(ROOTFS_PROG)
40
41# set /usr/bin/su to 4555; set /sbin/su.static to 0555
42FILEMODE =	04555
43
44$(PROG_STATIC) := FILEMODE = 0555
45
46# A reduced su.static is created, with just enough functionality
47# to satisfy the needs of a single-user login with /usr not mounted.
48# In particular, nss_files.so.1 may be dlopen()'ed at runtime.
49$(ROOTFS_PROG) :=	LDLIBS += -lbsm -lpam
50
51# The standard su is fully functional.
52$(PROG) :=	CPPFLAGS += -DDYNAMIC_SU
53$(PROG) :=	LDLIBS += -lbsm -lpam -lsecdb
54
55CLOBBERFILES	+= $(ROOTFS_PROG) $(EMB_PROG)
56
57.KEEP_STATE:
58
59all:		$(PROG) $(ROOTFS_PROG) $(EMB_PROG)
60
61# install rule for non-setuid /sbin/su.static
62# (exec'd by /sbin/sulogin when booting single user)
63$(ROOTFS_PROG):	$(PROG).c
64		$(LINK.c) $(PROG).c -o $@ $(LDLIBS)
65		$(POST_PROCESS)
66
67install:	all $(PROG_STATIC) $(ROOTPROG) $(ROOTSBINPROG) \
68		$(ROOTETCDEFAULTFILES) $(ROOTEMB_PROG)
69
70$(ROOTSBINPROG): $(ROOTPROG)
71		$(RM) $(ROOTSBINPROG); \
72		$(SYMLINK) ../usr/bin/$(PROG) $(ROOTSBINPROG)
73
74$(ROOTEMB_PROG):
75		$(RM) $(ROOTEMB_PROG); \
76		$(SYMLINK) ../bin/$(PROG) $(ROOTEMB_PROG)
77
78$(EMB_PROG):
79		$(RM) $(EMB_PROG); \
80		$(SYMLINK) $(PROG) $(EMB_PROG)
81
82clean:
83
84include		../Makefile.targ
85