xref: /illumos-gate/usr/src/cmd/cron/Makefile (revision 2570281cf351044b6936651ce26dbe1f801dcbd8)
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
44SMOFF +=	signed_integer_overflow_check,all_func_returns
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)
59PARSETEST =	parsetest
60
61SCRIPT =	batch
62XPG4SCRIPT =	batch.xpg4
63
64POFILE=		$(PROG1)_cmd.po
65POFILES1=	at.po crontab.po funcs.po batch.po
66POFILES=	$(POFILES1) atrm.po
67$(POFILES1) :=	XGETFLAGS= -a -x $(PROG1).xcl
68
69ROOTDIRS =	$(ROOTSPCRON) $(ROOTCROND) \
70		$(ROOTCRONTABS) $(ROOTATJOBS)
71
72ROOTPROG =	$(PROG1:%=$(ROOTUSRSBIN)/%) $(PROG2:%=$(ROOTBIN)/%)	\
73		$(SCRIPT:%=$(ROOTBIN)/%) \
74		$(XPG6PROG:%=$(ROOTXPG6BIN)/%) \
75		$(XPG4PROG:%=$(ROOTXPG4BIN)/%) \
76		$(XPG4SCRIPT:%.xpg4=$(ROOTXPG4BIN)/%)
77
78ROOTSYMLINK =	$(ROOTLIBCRON) $(ROOTETC)/cron
79
80GETRESPSRC=	$(SRC)/common/util/getresponse.c
81GETRESPOBJ=	getresponse.o
82COMMONOBJ1=	permit.o
83COMMONOBJ2=	funcs.o
84COMMONOBJS=	$(COMMONOBJ1) $(COMMONOBJ2)
85CRONOBJS=	cron.o elm.o parse.o
86ATOBJS=		at.o att1.o att2.o
87XPG4OBJS=	values-xpg4.o
88ATRMOBJS1=	atrm.o
89ATRMOBJS=	$(ATRMOBJS1) $(GETRESPOBJ)
90ATQOBJS=	atq.o
91CRONTABOBJS1=	crontab.o parse.o
92CRONTABOBJS=	$(CRONTABOBJS1) $(GETRESPOBJ)
93PARSETESTOBJS=	parse.o
94
95# /usr/xpg*/bin/crontab isn't linked with values-xpg*.o since it isn't
96# required by any specific behavior differences; this makes these
97# setuid variants less likely to accidently trip over differences that
98# could unintentionally open up a security hole.
99XPG4COMMONOBJS=	$(COMMONOBJS:%=objs.xpg4/%)
100XPG4CTOBJS=	$(CRONTABOBJS:%=objs.xpg4/%)
101XPG4ATOBJS=	$(ATOBJS:%=objs.xpg4/%) $(XPG4OBJS:%=objs.xpg4/%)
102XPG6COMMONOBJS=	$(COMMONOBJS:%=objs.xpg6/%)
103XPG6CTOBJS=	$(CRONTABOBJS:%=objs.xpg6/%)
104
105cron :=		POBJS = $(CRONOBJS) $(COMMONOBJ2)
106at :=		POBJS = $(ATOBJS) $(COMMONOBJS)
107at.xpg4 :=	POBJS = $(XPG4ATOBJS) $(XPG4COMMONOBJS)
108atrm :=		POBJS = $(ATRMOBJS) $(COMMONOBJS)
109atq :=		POBJS = $(ATQOBJS) $(COMMONOBJS)
110crontab :=	POBJS = $(CRONTABOBJS) $(COMMONOBJS)
111crontab.xpg4 :=	POBJS = $(XPG4CTOBJS) $(XPG4COMMONOBJS)
112crontab.xpg6 :=	POBJS = $(XPG6CTOBJS) $(XPG6COMMONOBJS)
113parsetest :=	POBJS = $(PARSETESTOBJS)
114
115CFLAGS += $(CCVERBOSE)
116
117NOBJS=		$(CRONOBJS) $(ATOBJS) $(ATRMOBJS1) $(ATQOBJS) $(CRONTABOBJS1) \
118		$(COMMONOBJS)
119OBJS =		$(NOBJS) $(XPG4COMMONOBJS) $(XPG4ATOBJS) $(XPG4CTOBJS) \
120		$(XPG6COMMONOBJS) $(XPG6CTOBJS) $(GETRESPOBJ)
121
122SRCS =		$(NOBJS:%.o=%.c) $(GETRESPSRC)
123
124CLOBBERFILES +=	$(SCRIPT) $(XPG4SCRIPT)
125
126$(ROOTLIBCRON) :=		SYMLNKDEST = ../../etc/cron.d
127$(ROOTETC)/cron :=		SYMLNKDEST = ../usr/sbin/cron
128
129$(ROOTBIN)/at :=		FILEMODE = 04755
130$(ROOTXPG4BIN)/at :=		FILEMODE = 04755
131$(ROOTBIN)/atrm :=		FILEMODE = 04755
132$(ROOTBIN)/atq :=		FILEMODE = 04755
133$(ROOTBIN)/crontab :=		FILEMODE = 04555
134$(ROOTXPG6BIN)/crontab :=	FILEMODE = 04555
135$(ROOTXPG4BIN)/crontab :=	FILEMODE = 04555
136$(ROOTUSRSBIN)/cron :=		FILEMODE = 0555
137
138at :=		LDLIBS += -lbsm -lproject -lsecdb
139at.xpg4 :=	LDLIBS += -lbsm -lproject -lsecdb
140atq :=		LDLIBS += -lbsm -lsecdb
141atrm :=		LDLIBS += -lbsm -lsecdb
142cron :=		LDLIBS += -lbsm -lpam -lproject -lcontract -lzoneinfo -lcustr
143crontab :=	LDLIBS += -lbsm -lsecdb -lpam -lzoneinfo -lcustr
144crontab.xpg6 :=	LDLIBS += -lbsm -lsecdb -lpam -lzoneinfo -lcustr
145crontab.xpg4 :=	LDLIBS += -lbsm -lsecdb -lpam -lzoneinfo -lcustr
146parsetest :=	LDLIBS += -lcustr
147
148$(XPG4) :=	CFLAGS += -DXPG4
149$(XPG6) :=	CFLAGS += -DXPG6
150parsetest :=	CFLAGS += -DPARSETEST
151
152$(ROOTSVCSYSTEM)/cron.xml := FILEMODE = 0444
153$(ROOTLIBSVCMETHOD)/svc-cron := FILEMODE = 0555
154
155
156.KEEP_STATE:
157
158all :		$(PROG) $(XPG4) $(XPG6) $(SCRIPT) $(XPG4SCRIPT) $(FILES) \
159		$(PARSETEST)
160
161install :	all $(ROOTPROG) $(ROOTETCDEFAULTFILES) $(ROOTSYMLINK) \
162		$(ROOTMANIFEST) $(ROOTMETHOD)
163
164$(PROG) $(PARSETEST):	$$(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
228strip :
229		$(STRIP) $(PROG) $(XPG4) $(XPG6)
230
231include		../Makefile.targ
232