xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.bin/Makefile (revision d48be21240dfd051b689384ce2b23479d757f2d8)
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 2011 Nexenta Systems, Inc. All rights reserved.
26# Copyright 2016 Toomas Soome <tsoome@me.com>
27# Copyright (c) 2018, Joyent, Inc.
28# Copyright 2022 Garrett D'Amore
29#
30
31PROG=		finger rdate ruptime rwho whois
32SUIDPROG=	rcp rlogin rsh
33ALL=		$(PROG) $(SUIDPROG)
34SRCS=		$(ALL:%=%.c)
35KCMDPROGS=	rcp rlogin rsh
36
37SUBDIRS=	chat dns-sd ftp nc netstat \
38		pppd pppdump pppstats rdist talk telnet tftp
39SUBDIR1=	talk
40MSGSUBDIRS=	talk
41
42# As programs get lint-clean, add them here.  Eventually.
43# This hack should go away, and all in PROG should be lint-clean.
44LINTCLEAN=	rlogin.c rsh.c rcp.c rdate.c rwho.c whois.c
45
46# Likewise, as subdirs get lint-clean, add them here.  Once
47# they're all clean, replace the dependency of the lint target
48# with SUBDIRS.  Also (sigh) deal with the commented-out build lines
49# for the lint rule.
50LINTSUBDIRS=	netstat pppd pppstats tftp
51
52include ../../Makefile.cmd
53include ../Makefile.cmd-inet
54
55COMMONOBJS=	kcmd.o
56COMMONPOFILES=	$(COMMONOBJS:.o=.po)
57COMMONSRCS=	$(CMDINETCOMMONDIR)/$(COMMONOBJS:.o=.c)
58
59POFILES=	rlogin.po rsh.po rcp.po $(COMMONPOFILES)
60POFILE=		usr.bin.po
61
62CLOBBERFILES +=	$(ALL)
63CLEANFILES +=	kcmd.o rcp.o rlogin.o rsh.o
64
65all:=		TARGET= all
66install:=	TARGET= install
67clean:=		TARGET= clean
68clobber:=	TARGET= clobber
69lint:=		TARGET= lint
70_msg:=		TARGET= _msg
71
72ROOTSUIDPROG=	$(SUIDPROG:%=$(ROOTBIN)/%)
73$(ROOTSUIDPROG)	:=	FILEMODE=	04555
74
75CPPFLAGS +=	-DSYSV -DSTRNET -DBSD_COMP -I$(CMDINETCOMMONDIR)
76CERRWARN +=	-_gcc=-Wno-parentheses
77CERRWARN +=	$(CNOWARN_UNINIT)
78CERRWARN +=	-_gcc=-Wno-unused-function
79
80ruptime :=     SMOFF += leaks
81
82# Eventually just plain CFLAGS should be += -v, but not until all in
83# PROGS are lint clean.
84$(LINTCLEAN)	:=	CFLAGS += $(CCVERBOSE)
85
86finger :=	CFLAGS += $(CCVERBOSE)
87# Enable large file support for reading the lastlog file.
88finger :=	CPPFLAGS += -D_FILE_OFFSET_BITS=64
89
90finger :=		LDLIBS += -lnsl -lcurses -lsocket
91rcp lint-rcp :=		LDLIBS += -lsocket -lsec -lsendfile
92rdate lint-rdate:=	LDLIBS += -lsocket
93rlogin lint-rlogin :=	LDLIBS += -lnsl -lsocket
94rsh lint-rsh :=		LDLIBS += -lsocket
95whois lint-whois :=	LDLIBS += -lsocket
96
97include  $(SRC)/lib/gss_mechs/mech_krb5/Makefile.mech_krb5
98$(KCMDPROGS)	:=	LDLIBS += -lnsl -lmech_krb5
99$(KCMDPROGS)	:=	LDFLAGS += $(ZIGNORE) $(KRUNPATH) \
100				-L$(ROOT)$(KLIBDIR_DO) \
101				-L$(ROOT)$(KLIBDIR_GL)
102KCMDLINTS=	$(KCMDPROGS:%=lint-%)
103
104$(COMMONPOFILES) \
105rlogin.po rcp.po rsh.po \
106$(KCMDPROGS) \
107$(KCMDLINTS)	:=	CPPFLAGS += -DKERBEROS \
108			-I$(CMDINETCOMMONDIR) \
109			-I$(SRC)/lib/gss_mechs/mech_krb5 \
110			-I$(SRC)/uts/common/gssapi/mechs/krb5/include \
111			-I$(SRC)/lib/gss_mechs/mech_krb5/include \
112			-I$(SRC)/lib/gss_mechs/mech_krb5/include/krb5
113
114# "-erroff=E_NAME_USED_NOT_DEF2" and "-erroff=E_NAME_DEF_NOT_USED2"
115# are required because lint problems in the Kerberos 5 framework.
116$(KCMDLINTS)	:=	LINTFLAGS += -lnsl \
117			-erroff=E_NAME_USED_NOT_DEF2 \
118			-erroff=E_NAME_DEF_NOT_USED2
119
120# Extra source files to lint with
121LINTXTRA=
122$(KCMDLINTS)	:=	LINTXTRA += $(COMMONSRCS)
123
124ROOTSUNWRCP=	$(ROOT)/usr/lib/sunw,rcp
125ROOTRSHSYMLINK=	$(ROOT)/usr/ucb/rsh
126ROOTREMSHSYMLINK=$(ROOT)/usr/bin/remsh
127
128.KEEP_STATE:
129
130all: $(ALL) $(SUBDIRS)
131
132install: all .WAIT $(ROOTPROG) $(ROOTSUIDPROG) \
133	$(SUBDIRS) $(ROOTSUNWRCP) $(ROOTRSHSYMLINK) $(ROOTREMSHSYMLINK)
134
135# Messaging - copy $POFILES to $POFILE to work with the parent directory
136# Makefile's '_msg' target.
137#
138_msg: $(MSGSUBDIRS) $(POFILES)
139	$(RM) $(POFILE)
140	$(CAT) $(POFILES)	> $(POFILE)
141
142$(COMMONPOFILES): $(COMMONSRCS)
143	$(COMPILE.cpp) $(COMMONSRCS) > $(@:.po=.c).i
144	$(XGETTEXT) $(XGETFLAGS) $(@:.po=.c).i
145	$(RM) $@
146	sed "/^domain/d" < messages.po  > $@
147	$(RM) messages.po $(@:.po=.c).i
148
149$(COMMONOBJS): $(COMMONSRCS)
150	$(COMPILE.c) $(COMMONSRCS)
151
152rlogin: rlogin.o $(COMMONOBJS)
153	$(LINK.c) $@.o $(COMMONOBJS) -o $@ $(LDLIBS)
154	$(POST_PROCESS)
155
156rcp: rcp.o $(COMMONOBJS)
157	$(LINK.c) $@.o $(COMMONOBJS) -o $@ $(LDLIBS)
158	$(POST_PROCESS)
159
160rsh: rsh.o $(COMMONOBJS)
161	$(LINK.c) $@.o $(COMMONOBJS) -o $@ $(LDLIBS)
162	$(POST_PROCESS)
163
164$(ROOTSUNWRCP):
165	$(RM) $@; $(SYMLINK) ../bin/rcp $@
166
167$(ROOTRSHSYMLINK):
168	$(RM) $@; $(SYMLINK) ../bin/rsh $@
169
170$(ROOTREMSHSYMLINK):
171	$(RM) $@; $(SYMLINK) rsh $@
172
173$(SUBDIRS): FRC
174	@cd $@; pwd; $(MAKE) $(TARGET)
175
176FRC:
177
178clean: $(SUBDIRS) clean_local
179clean_local:
180	$(RM) $(CLEANFILES)
181
182clobber: $(SUBDIRS) clobber_local
183clobber_local: clean_local
184	$(RM) $(CLOBBERFILES)
185
186LINTLOCALS=	$(LINTCLEAN:%.c=lint-%)
187
188lint:	$(LINTSUBDIRS) $(LINTLOCALS)
189
190$(LINTLOCALS):
191	$(LINT.c) $(@:lint-%=%.c) $(LINTXTRA) $(LDLIBS)
192