xref: /illumos-gate/usr/src/cmd/su/Makefile (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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# build two versions, su and su.static
26# su.static is dynamically linked; the .static suffix is historical.
27
28PROG =		su
29ROOTFS_PROG =	su.static
30DEFAULTFILES =	su.dfl
31
32include		../Makefile.cmd
33
34EMB_PROG =	embedded_su
35ROOTEMB_PROG =	$(ROOTLIB)/$(EMB_PROG)
36
37PROG_STATIC = $(ROOTSBIN)/$(ROOTFS_PROG)
38
39# set /usr/bin/su to 4555; set /sbin/su.static to 0555
40FILEMODE =	04555
41
42$(PROG_STATIC) := FILEMODE = 0555
43
44# A reduced su.static is created, with just enough functionality
45# to satisfy the needs of a single-user login with /usr not mounted.
46# In particular, nss_files.so.1 may be dlopen()'ed at runtime.
47$(ROOTFS_PROG) :=	LDLIBS += -lbsm -lpam -lsecdb
48
49# The standard su is fully functional.
50$(PROG) :=	CPPFLAGS += -DDYNAMIC_SU
51$(PROG) :=	LDLIBS += -lbsm -lpam -lsecdb
52
53LINTFLAGS += -DDYNAMIC_SU
54
55CLOBBERFILES	+= $(ROOTFS_PROG) $(EMB_PROG)
56
57lint :=		LDLIBS += -lbsm -lpam -lsecdb
58
59.KEEP_STATE:
60
61all:		$(PROG) $(ROOTFS_PROG) $(EMB_PROG)
62
63# install rule for non-setuid /sbin/su.static
64# (exec'd by /sbin/sulogin when booting single user)
65$(ROOTFS_PROG):	$(PROG).c
66		$(LINK.c) $(PROG).c -o $@ $(LDLIBS)
67		$(POST_PROCESS)
68
69install:	all $(PROG_STATIC) $(ROOTPROG) $(ROOTSBINPROG) \
70		$(ROOTETCDEFAULTFILES) $(ROOTEMB_PROG)
71
72$(ROOTSBINPROG): $(ROOTPROG)
73		$(RM) $(ROOTSBINPROG); \
74		$(SYMLINK) ../usr/bin/$(PROG) $(ROOTSBINPROG)
75
76$(ROOTEMB_PROG):
77		$(RM) $(ROOTEMB_PROG); \
78		$(SYMLINK) ../bin/$(PROG) $(ROOTEMB_PROG)
79
80$(EMB_PROG):
81		$(RM) $(EMB_PROG); \
82		$(SYMLINK) $(PROG) $(EMB_PROG)
83
84clean:
85
86lint:		lint_PROG
87
88include		../Makefile.targ
89