xref: /illumos-gate/usr/src/cmd/cron/Makefile (revision 30165b7f6753bc3d48c52319bed7ec7b3ea36b3c)
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
27DEFAULTFILES =	cron.dfl
28
29include		../Makefile.cmd
30
31MANIFEST =	cron.xml
32
33ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
34ROOTMETHOD =	$(ROOTLIBSVCMETHOD)/svc-cron
35
36CPPFLAGS +=	-D_FILE_OFFSET_BITS=64 -I $(SRC)/common/util
37CERRWARN +=	-_gcc=-Wno-parentheses
38CERRWARN +=	-_gcc=-Wno-unused-label
39CERRWARN +=	-_gcc=-Wno-uninitialized
40CERRWARN +=	-_gcc=-Wno-unused-variable
41CERRWARN +=	-_gcc=-Wno-unused-value
42
43# not linted
44SMATCH=off
45
46ROOTVAR =	$(ROOT)/var
47
48ROOTSPCRON =	$(ROOTVAR)/spool/cron
49ROOTCROND =	$(ROOTETC)/cron.d
50ROOTCRONTABS =	$(ROOTSPCRON)/crontabs
51ROOTATJOBS =	$(ROOTSPCRON)/atjobs
52ROOTLIBCRON =	$(ROOTLIB)/cron
53
54PROG1 =		cron
55PROG2 =		at atq atrm crontab
56XPG6PROG =	crontab
57XPG4PROG =	at crontab
58PROG =		$(PROG1) $(PROG2)
59
60SCRIPT =	batch
61XPG4SCRIPT =	batch.xpg4
62
63POFILE=		$(PROG1)_cmd.po
64POFILES1=	at.po crontab.po funcs.po batch.po
65POFILES=	$(POFILES1) atrm.po
66$(POFILES1) :=	XGETFLAGS= -a -x $(PROG1).xcl
67
68ROOTDIRS =	$(ROOTSPCRON) $(ROOTCROND) \
69		$(ROOTCRONTABS) $(ROOTATJOBS)
70
71ROOTPROG =	$(PROG1:%=$(ROOTUSRSBIN)/%) $(PROG2:%=$(ROOTBIN)/%)	\
72		$(SCRIPT:%=$(ROOTBIN)/%) \
73		$(XPG6PROG:%=$(ROOTXPG6BIN)/%) \
74		$(XPG4PROG:%=$(ROOTXPG4BIN)/%) \
75		$(XPG4SCRIPT:%.xpg4=$(ROOTXPG4BIN)/%)
76
77ROOTSYMLINK =	$(ROOTLIBCRON) $(ROOTETC)/cron
78
79GETRESPSRC=	$(SRC)/common/util/getresponse.c
80GETRESPOBJ=	getresponse.o
81COMMONOBJ1=	permit.o
82COMMONOBJ2=	funcs.o
83COMMONOBJS=	$(COMMONOBJ1) $(COMMONOBJ2)
84CRONOBJS=	cron.o elm.o
85ATOBJS=		at.o att1.o att2.o
86XPG4OBJS=	values-xpg4.o
87ATRMOBJS1=	atrm.o
88ATRMOBJS=	$(ATRMOBJS1) $(GETRESPOBJ)
89ATQOBJS=	atq.o
90CRONTABOBJS1=	crontab.o
91CRONTABOBJS=	$(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.
97XPG4COMMONOBJS=	$(COMMONOBJS:%=objs.xpg4/%)
98XPG4CTOBJS=	$(CRONTABOBJS:%=objs.xpg4/%)
99XPG4ATOBJS=	$(ATOBJS:%=objs.xpg4/%) $(XPG4OBJS:%=objs.xpg4/%)
100XPG6COMMONOBJS=	$(COMMONOBJS:%=objs.xpg6/%)
101XPG6CTOBJS=	$(CRONTABOBJS:%=objs.xpg6/%)
102
103cron :=		POBJS = $(CRONOBJS) $(COMMONOBJ2)
104at :=		POBJS = $(ATOBJS) $(COMMONOBJS)
105at.xpg4 :=	POBJS = $(XPG4ATOBJS) $(XPG4COMMONOBJS)
106atrm :=		POBJS = $(ATRMOBJS) $(COMMONOBJS)
107atq :=		POBJS = $(ATQOBJS) $(COMMONOBJS)
108crontab :=	POBJS = $(CRONTABOBJS) $(COMMONOBJS)
109crontab.xpg4 :=	POBJS = $(XPG4CTOBJS) $(XPG4COMMONOBJS)
110crontab.xpg6 :=	POBJS = $(XPG6CTOBJS) $(XPG6COMMONOBJS)
111
112CFLAGS += $(CCVERBOSE)
113
114NOBJS=		$(CRONOBJS) $(ATOBJS) $(ATRMOBJS1) $(ATQOBJS) $(CRONTABOBJS1) \
115		$(COMMONOBJS)
116OBJS =		$(NOBJS) $(XPG4COMMONOBJS) $(XPG4ATOBJS) $(XPG4CTOBJS) \
117		$(XPG6COMMONOBJS) $(XPG6CTOBJS) $(GETRESPOBJ)
118
119SRCS =		$(NOBJS:%.o=%.c) $(GETRESPSRC)
120
121CLOBBERFILES +=	$(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
135LDLIBS +=	-lbsm
136
137at :=		LDLIBS += -lproject -lsecdb
138at.xpg4 :=	LDLIBS += -lproject -lsecdb
139atq :=		LDLIBS += -lsecdb
140atrm :=		LDLIBS += -lsecdb
141cron :=		LDLIBS += -lpam -lproject -lcontract -lzoneinfo
142crontab :=	LDLIBS += -lsecdb -lpam -lzoneinfo
143crontab.xpg6 :=	LDLIBS += -lsecdb -lpam -lzoneinfo
144crontab.xpg4 :=	LDLIBS += -lsecdb -lpam -lzoneinfo
145
146lint :=		LDLIBS += -lproject -lsecdb -lcontract -lpam
147
148$(XPG4) := CFLAGS += -DXPG4
149$(XPG6) := CFLAGS += -DXPG6
150
151LINTFLAGS += -u
152
153$(ROOTSVCSYSTEM)/cron.xml := FILEMODE = 0444
154$(ROOTLIBSVCMETHOD)/svc-cron := FILEMODE = 0555
155
156
157.KEEP_STATE:
158
159all :		$(PROG) $(XPG4) $(XPG6) $(SCRIPT) $(XPG4SCRIPT) $(FILES)
160
161install :	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
176objs.xpg6/%.o:		%.c
177	$(COMPILE.c) -o $@ $<
178
179objs.xpg6:
180	-@mkdir -p $@
181
182objs.xpg4/%.o:		%.c
183	$(COMPILE.c) -o $@ $<
184
185objs.xpg4:
186	-@mkdir -p $@
187
188objs.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
195objs.xpg4/%.o:	$(SRC)/common/util/%.c
196	$(COMPILE.c) -o $@ $<
197	$(POST_PROCESS_O)
198
199objs.xpg6/%.o:	$(SRC)/common/util/%.c
200	$(COMPILE.c) -o $@ $<
201	$(POST_PROCESS_O)
202
203att1.c :	att1.y
204		$(YACC.y) -d att1.y
205		$(MV) y.tab.c att1.c
206		$(MV) y.tab.h att1.h
207
208att2.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
220check:		$(CHKMANIFEST)
221
222$(POFILE):	$(POFILES)
223	$(RM) $@; cat $(POFILES) > $@
224
225clean :
226		$(RM) $(OBJS) att1.h att1.c att2.c
227
228lint :		lint_SRCS
229
230strip :
231		$(STRIP) $(PROG) $(XPG4) $(XPG6)
232
233include		../Makefile.targ
234