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 (c) 2018, Joyent, Inc.
  26 
  27 DEFAULTFILES =  cron.dfl
  28 
  29 include         ../Makefile.cmd
  30 
  31 MANIFEST =      cron.xml
  32 
  33 ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
  34 ROOTMETHOD =    $(ROOTLIBSVCMETHOD)/svc-cron
  35 
  36 CPPFLAGS +=     -D_FILE_OFFSET_BITS=64 -I $(SRC)/common/util
  37 CERRWARN +=     -_gcc=-Wno-parentheses
  38 CERRWARN +=     -_gcc=-Wno-unused-label
  39 CERRWARN +=     -_gcc=-Wno-uninitialized
  40 CERRWARN +=     -_gcc=-Wno-unused-variable
  41 CERRWARN +=     -_gcc=-Wno-unused-value
  42 
  43 # not linted
  44 SMATCH=off
  45 
  46 ROOTVAR =       $(ROOT)/var
  47 
  48 ROOTSPCRON =    $(ROOTVAR)/spool/cron
  49 ROOTCROND =     $(ROOTETC)/cron.d
  50 ROOTCRONTABS =  $(ROOTSPCRON)/crontabs
  51 ROOTATJOBS =    $(ROOTSPCRON)/atjobs
  52 ROOTLIBCRON =   $(ROOTLIB)/cron
  53 
  54 PROG1 =         cron
  55 PROG2 =         at atq atrm crontab
  56 XPG6PROG =      crontab
  57 XPG4PROG =      at crontab
  58 PROG =          $(PROG1) $(PROG2)
  59 
  60 SCRIPT =        batch
  61 XPG4SCRIPT =    batch.xpg4
  62 
  63 POFILE=         $(PROG1)_cmd.po
  64 POFILES1=       at.po crontab.po funcs.po batch.po
  65 POFILES=        $(POFILES1) atrm.po
  66 $(POFILES1) :=  XGETFLAGS= -a -x $(PROG1).xcl
  67 
  68 ROOTDIRS =      $(ROOTSPCRON) $(ROOTCROND) \
  69                 $(ROOTCRONTABS) $(ROOTATJOBS)
  70 
  71 ROOTPROG =      $(PROG1:%=$(ROOTUSRSBIN)/%) $(PROG2:%=$(ROOTBIN)/%)     \
  72                 $(SCRIPT:%=$(ROOTBIN)/%) \
  73                 $(XPG6PROG:%=$(ROOTXPG6BIN)/%) \
  74                 $(XPG4PROG:%=$(ROOTXPG4BIN)/%) \
  75                 $(XPG4SCRIPT:%.xpg4=$(ROOTXPG4BIN)/%)
  76 
  77 ROOTSYMLINK =   $(ROOTLIBCRON) $(ROOTETC)/cron
  78 
  79 GETRESPSRC=     $(SRC)/common/util/getresponse.c
  80 GETRESPOBJ=     getresponse.o
  81 COMMONOBJ1=     permit.o
  82 COMMONOBJ2=     funcs.o
  83 COMMONOBJS=     $(COMMONOBJ1) $(COMMONOBJ2)
  84 CRONOBJS=       cron.o elm.o
  85 ATOBJS=         at.o att1.o att2.o
  86 XPG4OBJS=       values-xpg4.o
  87 ATRMOBJS1=      atrm.o
  88 ATRMOBJS=       $(ATRMOBJS1) $(GETRESPOBJ)
  89 ATQOBJS=        atq.o
  90 CRONTABOBJS1=   crontab.o
  91 CRONTABOBJS=    $(CRONTABOBJS1) $(GETRESPOBJ)
  92 
  93 # /usr/xpg*/bin/crontab isn't linked with values-xpg*.o since it isn't
  94 # required by any specific behavior differences; this makes these
  95 # setuid variants less likely to accidently trip over differences that
  96 # could unintentionally open up a security hole.
  97 XPG4COMMONOBJS= $(COMMONOBJS:%=objs.xpg4/%)
  98 XPG4CTOBJS=     $(CRONTABOBJS:%=objs.xpg4/%)
  99 XPG4ATOBJS=     $(ATOBJS:%=objs.xpg4/%) $(XPG4OBJS:%=objs.xpg4/%)
 100 XPG6COMMONOBJS= $(COMMONOBJS:%=objs.xpg6/%)
 101 XPG6CTOBJS=     $(CRONTABOBJS:%=objs.xpg6/%)
 102 
 103 cron :=         POBJS = $(CRONOBJS) $(COMMONOBJ2)
 104 at :=           POBJS = $(ATOBJS) $(COMMONOBJS)
 105 at.xpg4 :=      POBJS = $(XPG4ATOBJS) $(XPG4COMMONOBJS)
 106 atrm :=         POBJS = $(ATRMOBJS) $(COMMONOBJS)
 107 atq :=          POBJS = $(ATQOBJS) $(COMMONOBJS)
 108 crontab :=      POBJS = $(CRONTABOBJS) $(COMMONOBJS)
 109 crontab.xpg4 := POBJS = $(XPG4CTOBJS) $(XPG4COMMONOBJS)
 110 crontab.xpg6 := POBJS = $(XPG6CTOBJS) $(XPG6COMMONOBJS)
 111 
 112 CFLAGS += $(CCVERBOSE)
 113 
 114 NOBJS=          $(CRONOBJS) $(ATOBJS) $(ATRMOBJS1) $(ATQOBJS) $(CRONTABOBJS1) \
 115                 $(COMMONOBJS)
 116 OBJS =          $(NOBJS) $(XPG4COMMONOBJS) $(XPG4ATOBJS) $(XPG4CTOBJS) \
 117                 $(XPG6COMMONOBJS) $(XPG6CTOBJS) $(GETRESPOBJ)
 118 
 119 SRCS =          $(NOBJS:%.o=%.c) $(GETRESPSRC)
 120 
 121 CLOBBERFILES += $(SCRIPT) $(XPG4SCRIPT)
 122 
 123 $(ROOTLIBCRON) :=               SYMLNKDEST = ../../etc/cron.d
 124 $(ROOTETC)/cron :=              SYMLNKDEST = ../usr/sbin/cron
 125 
 126 $(ROOTBIN)/at :=                FILEMODE = 04755
 127 $(ROOTXPG4BIN)/at :=            FILEMODE = 04755
 128 $(ROOTBIN)/atrm :=              FILEMODE = 04755
 129 $(ROOTBIN)/atq :=               FILEMODE = 04755
 130 $(ROOTBIN)/crontab :=           FILEMODE = 04555
 131 $(ROOTXPG6BIN)/crontab :=       FILEMODE = 04555
 132 $(ROOTXPG4BIN)/crontab :=       FILEMODE = 04555
 133 $(ROOTUSRSBIN)/cron :=          FILEMODE = 0555
 134 
 135 LDLIBS +=       -lbsm
 136 
 137 at :=           LDLIBS += -lproject -lsecdb
 138 at.xpg4 :=      LDLIBS += -lproject -lsecdb
 139 atq :=          LDLIBS += -lsecdb
 140 atrm :=         LDLIBS += -lsecdb
 141 cron :=         LDLIBS += -lpam -lproject -lcontract -lzoneinfo
 142 crontab :=      LDLIBS += -lsecdb -lpam -lzoneinfo
 143 crontab.xpg6 := LDLIBS += -lsecdb -lpam -lzoneinfo
 144 crontab.xpg4 := LDLIBS += -lsecdb -lpam -lzoneinfo
 145 
 146 lint :=         LDLIBS += -lproject -lsecdb -lcontract -lpam
 147 
 148 $(XPG4) := CFLAGS += -DXPG4
 149 $(XPG6) := CFLAGS += -DXPG6
 150 
 151 LINTFLAGS += -u
 152 
 153 $(ROOTSVCSYSTEM)/cron.xml := FILEMODE = 0444
 154 $(ROOTLIBSVCMETHOD)/svc-cron := FILEMODE = 0555
 155 
 156 
 157 .KEEP_STATE:
 158 
 159 all :           $(PROG) $(XPG4) $(XPG6) $(SCRIPT) $(XPG4SCRIPT) $(FILES)
 160 
 161 install :       all $(ROOTPROG) $(ROOTETCDEFAULTFILES) $(ROOTSYMLINK) \
 162                 $(ROOTMANIFEST) $(ROOTMETHOD)
 163 
 164 $(PROG) :       $$(POBJS)
 165                 $(LINK.c) $(POBJS) -o $@ $(LDLIBS)
 166                 $(POST_PROCESS)
 167 
 168 $(XPG4) :       objs.xpg4 $$(POBJS)
 169                 $(LINK.c) $(POBJS) -o $@ $(LDLIBS)
 170                 $(POST_PROCESS)
 171 
 172 $(XPG6) :       objs.xpg6 $$(POBJS)
 173                 $(LINK.c) $(POBJS) -o $@ $(LDLIBS)
 174                 $(POST_PROCESS)
 175 
 176 objs.xpg6/%.o:          %.c
 177         $(COMPILE.c) -o $@ $<
 178 
 179 objs.xpg6:
 180         -@mkdir -p $@
 181 
 182 objs.xpg4/%.o:          %.c
 183         $(COMPILE.c) -o $@ $<
 184 
 185 objs.xpg4:
 186         -@mkdir -p $@
 187 
 188 objs.xpg4/values-xpg4.o:        ../../lib/crt/common/values-xpg4.c
 189         $(COMPILE.c) -o $@ ../../lib/crt/common/values-xpg4.c
 190 
 191 %.o:                    $(SRC)/common/util/%.c
 192         $(COMPILE.c) $(OUTPUT_OPTION) $<
 193         $(POST_PROCESS_O)
 194 
 195 objs.xpg4/%.o:  $(SRC)/common/util/%.c
 196         $(COMPILE.c) -o $@ $<
 197         $(POST_PROCESS_O)
 198 
 199 objs.xpg6/%.o:  $(SRC)/common/util/%.c
 200         $(COMPILE.c) -o $@ $<
 201         $(POST_PROCESS_O)
 202 
 203 att1.c :        att1.y
 204                 $(YACC.y) -d att1.y
 205                 $(MV) y.tab.c att1.c
 206                 $(MV) y.tab.h att1.h
 207 
 208 att2.c :        att2.l att2.ed att1.c
 209                 $(LEX) att2.l
 210                 ed - lex.yy.c < att2.ed
 211                 $(MV) lex.yy.c att2.c
 212 
 213 # Don't re-install directories installed by Targetdirs
 214 #$(ROOTDIRS):
 215 #               $(INS.dir)
 216 
 217 $(ROOTSYMLINK) :
 218                 $(RM) $@; $(SYMLINK) $(SYMLNKDEST) $@
 219 
 220 check:          $(CHKMANIFEST)
 221 
 222 $(POFILE):      $(POFILES)
 223         $(RM) $@; cat $(POFILES) > $@
 224 
 225 clean :
 226                 $(RM) $(OBJS) att1.h att1.c att2.c
 227 
 228 lint :          lint_SRCS
 229 
 230 strip :
 231                 $(STRIP) $(PROG) $(XPG4) $(XPG6)
 232 
 233 include         ../Makefile.targ