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