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 
  30 PROG=           finger rdate ruptime rwho whois
  31 SUIDPROG=       rcp rlogin rsh
  32 ALL=            $(PROG) $(SUIDPROG)
  33 SRCS=           $(ALL:%=%.c)
  34 KCMDPROGS=      rcp rlogin rsh
  35 
  36 SUBDIRS=        chat dns-sd ftp nc nca netstat \
  37                 pppd pppdump pppstats rdist talk telnet tftp
  38 SUBDIR1=        talk
  39 MSGSUBDIRS=     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.
  43 LINTCLEAN=      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.
  49 LINTSUBDIRS=    nca netstat pppd pppstats tftp
  50 
  51 include ../../Makefile.cmd
  52 include ../Makefile.cmd-inet
  53 
  54 COMMONOBJS=     kcmd.o
  55 COMMONPOFILES=  $(COMMONOBJS:.o=.po)
  56 COMMONSRCS=     $(CMDINETCOMMONDIR)/$(COMMONOBJS:.o=.c)
  57 
  58 POFILES=        rlogin.po rsh.po rcp.po $(COMMONPOFILES)
  59 POFILE=         usr.bin.po
  60 
  61 CLOBBERFILES += $(ALL)
  62 CLEANFILES +=   kcmd.o rcp.o rlogin.o rsh.o
  63 
  64 all:=           TARGET= all
  65 install:=       TARGET= install
  66 clean:=         TARGET= clean
  67 clobber:=       TARGET= clobber
  68 lint:=          TARGET= lint
  69 _msg:=          TARGET= _msg
  70 
  71 ROOTSUIDPROG=   $(SUIDPROG:%=$(ROOTBIN)/%)
  72 $(ROOTSUIDPROG) :=      FILEMODE=       04555
  73 
  74 CPPFLAGS +=     -DSYSV -DSTRNET -DBSD_COMP -I$(CMDINETCOMMONDIR)
  75 CERRWARN +=     -_gcc=-Wno-parentheses
  76 CERRWARN +=     -_gcc=-Wno-uninitialized
  77 CERRWARN +=     -_gcc=-Wno-unused-function
  78 
  79 ruptime :=     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 
  85 finger :=       CFLAGS += $(CCVERBOSE)
  86 # Enable large file support for reading the lastlog file.
  87 finger :=       CPPFLAGS += -D_FILE_OFFSET_BITS=64
  88 
  89 finger :=               LDLIBS += -lnsl -lcurses -lsocket
  90 rcp lint-rcp :=         LDLIBS += -lsocket -lsec -lsendfile
  91 rdate lint-rdate:=      LDLIBS += -lsocket
  92 rlogin lint-rlogin :=   LDLIBS += -lnsl -lsocket
  93 rsh lint-rsh :=         LDLIBS += -lsocket
  94 whois lint-whois :=     LDLIBS += -lsocket
  95 
  96 include  $(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)
 101 KCMDLINTS=      $(KCMDPROGS:%=lint-%)
 102 
 103 $(COMMONPOFILES) \
 104 rlogin.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
 120 LINTXTRA=
 121 $(KCMDLINTS)    :=      LINTXTRA += $(COMMONSRCS)
 122 
 123 ROOTSUNWRCP=    $(ROOT)/usr/lib/sunw,rcp
 124 ROOTRSHSYMLINK= $(ROOT)/usr/ucb/rsh
 125 ROOTREMSHSYMLINK=$(ROOT)/usr/bin/remsh
 126 
 127 .KEEP_STATE:
 128 
 129 all: $(ALL) $(SUBDIRS)
 130 
 131 install: 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 
 151 rlogin: rlogin.o $(COMMONOBJS)
 152         $(LINK.c) $@.o $(COMMONOBJS) -o $@ $(LDLIBS)
 153         $(POST_PROCESS)
 154 
 155 rcp: rcp.o $(COMMONOBJS)
 156         $(LINK.c) $@.o $(COMMONOBJS) -o $@ $(LDLIBS)
 157         $(POST_PROCESS)
 158 
 159 rsh: 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) $(MFLAGS) $(TARGET)
 174 
 175 FRC:
 176 
 177 clean: $(SUBDIRS) clean_local
 178 clean_local:
 179         $(RM) $(CLEANFILES)
 180 
 181 clobber: $(SUBDIRS) clobber_local
 182 clobber_local: clean_local
 183         $(RM) $(CLOBBERFILES)
 184 
 185 LINTLOCALS=     $(LINTCLEAN:%.c=lint-%)
 186 
 187 lint:   $(LINTSUBDIRS) $(LINTLOCALS)
 188 
 189 $(LINTLOCALS):
 190         $(LINT.c) $(@:lint-%=%.c) $(LINTXTRA) $(LDLIBS)