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