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