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