]> granicus.if.org Git - fcron/blob - Makefile.in
Fixed bug in logging to a file and made file closure more robust
[fcron] / Makefile.in
1 ############################
2 # fcron's Makefile  ########
3 ############################
4
5 # @configure_input@
6
7
8 # The following should not be edited manually (use configure options)
9 # If you must do it, BEWARE : some of the following is also defined
10 # in config.h, so you must modify config.h AND Makefile in order
11 # to set the same values in the two files.
12
13 FCRON_ALLOW     = fcron.allow
14 FCRON_DENY      = fcron.deny
15 FCRON_CONF      = fcron.conf
16
17 SRCDIR          := @srcdir@
18 # Useful to build packages
19 # you may want to use this var with a : 'make DESTDIR=dir install'
20 DESTDIR         :=
21
22 # Where should we install it ?
23 prefix          = @prefix@
24 exec_prefix     = @exec_prefix@
25 DESTSBIN        = @sbindir@
26 DESTBIN         = @bindir@
27 ETC             = @sysconfdir@
28 FCRONTABS       = @FCRONTABS@
29 PIDDIR          = @PIDDIR@
30 FIFODIR         = @FIFODIR@
31 PIDFILE         = @PIDFILE@
32 REBOOT_LOCK     = @REBOOT_LOCK@
33 FIFOFILE        = @FIFOFILE@
34 FCRON_SHELL     = @FCRON_SHELL@
35 SENDMAIL        = @SENDMAIL@
36 FCRON_EDITOR    = @FCRON_EDITOR@
37 OPTIM           := @CFLAGS@
38 LDFLAGS         := @LDFLAGS@
39 CPPFLAGS        := @CPPFLAGS@ -I. -I${SRCDIR}
40 LIBS            := @LIBS@
41 LIBOBJS         := @LIBOBJS@
42 DEFS            := @DEFS@ 
43 CC              := @CC@
44 INSTALL         := @INSTALL@
45 STRIP           := @STRIP@
46 ROOTNAME        := @ROOTNAME@
47 ROOTGROUP       := @ROOTGROUP@
48 USERNAME        := @USERNAME@
49 GROUPNAME       := @GROUPNAME@
50 SYSFCRONTAB     := @SYSFCRONTAB@
51 DEBUG           := @DEBUG@
52 BOOTINSTALL     := @BOOTINSTALL@
53 ANSWERALL       := @ANSWERALL@
54 USEPAM          := @USEPAM@
55 FCRONDYN        := @FCRONDYN@
56 SYSTEMD_DIR     := @SYSTEMD_DIR@
57
58 # Options
59 #       -DDEBUG         even more verbose
60 #       -DCHECKJOBS     send a mail containing the exact shell command
61 #                       for each execution of each job.
62 #       -DFOREGROUND=[0|1]    default run in foreground ?
63 #OPTION=        -DCHECKJOBS
64 #OPTION=        -O3 -mcpu=i686
65 OPTION := 
66
67
68 ####################################
69 # Should not be changed under this #
70 ####################################
71
72 VERSION := @VERSION@
73 CFLAGS += $(OPTIM) $(OPTION) $(DEFS) $(CPPFLAGS)
74 ifeq ($(FCRONDYN), 1)
75 LIBOBJS := socket.o $(LIBOBJS)
76 endif
77 OBJSD := fcron.o cl.o subs.o mem.o save.o temp_file.o log.o database.o job.o conf.o u_list.o exe_list.o lavg_list.o env_list.o fcronconf.o filesubs.o $(LIBOBJS)
78 OBJSTAB := fcrontab.o cl.o subs.o mem.o save.o temp_file.o  log.o fileconf.o allow.o read_string.o u_list.o env_list.o fcronconf.o filesubs.o
79 OBJSDYN := fcrondyn.o subs.o mem.o log.o allow.o read_string.o fcronconf.o filesubs.o
80 OBJCONV := convert-fcrontab.o cl.o subs.o mem.o save.o log.o u_list.o env_list.o fcronconf.o filesubs.o
81 OBJSIG := fcronsighup.o subs.o mem.o log.o allow.o fcronconf.o filesubs.o
82 HEADERSALL := config.h $(SRCDIR)/global.h $(SRCDIR)/cl.h $(SRCDIR)/log.h $(SRCDIR)/subs.h $(SRCDIR)/mem.h $(SRCDIR)/save.h $(SRCDIR)/option.h $(SRCDIR)/dyncom.h
83
84 # this is a regular expression :
85 # do not ci automaticaly generated files and doc (done by doc's Makefile)
86 RCSNOCI:=.*\(.html\|VERSION\|MANIFEST\|configure\|install.sh\|config.log\|config.status\|config.h\|config.cache\|Makefile\|doc.*\|CVS.*\|.git.*\)
87
88 RUN_NON_PRIVILEGED := @RUN_NON_PRIVILEGED@
89 ifeq ($(RUN_NON_PRIVILEGED), 1)
90         BINMODE:=111
91         BINMODESIGHUP:=111
92 else
93         BINMODE:=6111
94         BINMODESIGHUP:=4110
95 endif
96
97 ifeq ($(FCRONDYN), 1)
98 all: fcron fcrontab fcrondyn convert-fcrontab files/fcron.conf initscripts documentation
99 else
100 all: fcron fcrontab convert-fcrontab files/fcron.conf
101 endif
102
103 fcron: $(OBJSD)
104         $(CC) $(CFLAGS) -o $@ $(OBJSD) $(LIBS)
105
106 fcrontab: fcronsighup $(OBJSTAB)
107         $(CC) $(CFLAGS) -o $@ $(OBJSTAB) $(LIBS)
108
109 fcrondyn: $(OBJSDYN)
110         $(CC) $(CFLAGS) -o $@ $(OBJSDYN) $(LIBS)
111
112 fcronsighup: $(OBJSIG)
113         $(CC) $(CFLAGS) -o $@ $(OBJSIG) $(LIBS)
114
115 convert-fcrontab: $(OBJCONV)
116         $(CC) $(CFLAGS) -o $@ $(OBJCONV) $(LIBS)
117
118 exe_list_test: exe_list.o u_list.o exe_list_test.o log.o subs.o
119         $(CC) $(CFLAGS) -o $@  exe_list.o u_list.o exe_list_test.o log.o subs.o $(LIBS)
120
121 %.o: $(SRCDIR)/%.c $(HEADERSALL) $(SRCDIR)/%.h
122         $(CC) $(CFLAGS) -DPIDFILE="\"${PIDFILE}\"" -DREBOOT_LOCK="\"${REBOOT_LOCK}\"" \
123         -DFIFOFILE="\"${FIFOFILE}\"" -DETC="\"${ETC}\"" \
124         -DFCRON_SHELL="\"${FCRON_SHELL}\"" -DFCRON_CONF="\"${FCRON_CONF}\"" \
125         -DFCRONTABS="\"${FCRONTABS}\"" \
126         -DFCRON_ALLOW="\"${FCRON_ALLOW}\"" -DFCRON_DENY="\"${FCRON_DENY}\"" \
127         -DFCRON_SHELL="\"${FCRON_SHELL}\"" -DSENDMAIL="\"${SENDMAIL}\"" \
128         -DFCRON_EDITOR="\"${FCRON_EDITOR}\"" -DBINDIREX="\"${DESTBIN}\"" \
129         -c $<
130
131 initscripts:
132         @(if test ! -d script; then mkdir script ; fi ; \
133                 for F in sysVinit-launcher fcron.sh fcron.init.suse fcron.init.systemd ; do \
134                         $(SRCDIR)/script/gen-in.pl $(SRCDIR)/script/$${F}.in script/$${F} ./ ; \
135                 done)
136
137 documentation:
138         $(MAKE) -C doc doc-if-none
139
140 install: install-staged strip perms 
141 ifeq ($(BOOTINSTALL), 1)
142         $(SRCDIR)/script/boot-install "$(INSTALL) -o $(ROOTNAME)" $(DESTSBIN) $(DEBUG) $(FCRONTABS) $(ANSWERALL) $(SRCDIR)
143 endif
144 ifneq ($(SYSTEMD_DIR), no)
145         if test ! -d $(DESTDIR)$(SYSTEMD_DIR); then $(INSTALL) -m 755 -d $(DESTDIR)$(SYSTEMD_DIR) ; fi
146         $(INSTALL) -m 644 script/fcron.init.systemd $(DESTDIR)$(SYSTEMD_DIR)/fcron.service
147 endif
148
149 install-staged: all
150
151 # needed by boot-install script :
152         echo `fcron -V 2>&1 | grep "^fcron "` > PREVIOUS_VERSION && chmod a+rw PREVIOUS_VERSION
153
154         $(SRCDIR)/script/user-group $(USERNAME) $(GROUPNAME) $(ANSWERALL) $(SRCDIR)
155
156 # check if the directories we use exist, and if not, create them
157         if test ! -d $(DESTDIR)$(DESTSBIN); then $(INSTALL) -m 755 -d $(DESTDIR)$(DESTSBIN) ; fi
158         if test ! -d $(DESTDIR)$(DESTBIN); then $(INSTALL) -m 755 -d $(DESTDIR)$(DESTBIN) ; fi
159         if test ! -d $(DESTDIR)$(ETC); then $(INSTALL) -m 755 -d $(DESTDIR)$(ETC) ; fi
160         if test ! -d $(DESTDIR)$(PIDDIR); then $(INSTALL) -m 755 -d $(DESTDIR)$(PIDDIR) ; fi
161         if test ! -d $(DESTDIR)$(FIFODIR); then $(INSTALL) -m 755 -d $(DESTDIR)$(FIFODIR) ; fi
162 # create the spool dir
163         $(INSTALL) -m 755 -d $(DESTDIR)$(FCRONTABS)
164
165         $(INSTALL) -m 755 fcron $(DESTDIR)$(DESTSBIN)
166         $(INSTALL) -m 755 fcrontab $(DESTDIR)$(DESTBIN)
167         $(INSTALL) -m 755 fcronsighup $(DESTDIR)$(DESTBIN)
168 ifeq ($(FCRONDYN), 1)
169         $(INSTALL) -m 755 fcrondyn $(DESTDIR)$(DESTBIN)
170 endif
171         if test ! -f $(DESTDIR)$(ETC)/fcron.allow -a ! -f $(DESTDIR)$(ETC)/fcron.deny ; then $(INSTALL) -m 644 $(SRCDIR)/files/fcron.allow $(DESTDIR)$(ETC) ; $(INSTALL) -m 644 $(SRCDIR)/files/fcron.deny $(DESTDIR)$(ETC) ; fi
172         test -f $(DESTDIR)$(ETC)/fcron.conf || $(INSTALL) -m 644 files/fcron.conf $(DESTDIR)$(ETC)
173
174         $(MAKE) -C doc install-staged
175
176
177 perms: install-staged strip
178 # Note : we don't use "chown user:group file" because some systems use ":"
179 #        and others "." as separator.
180         chown $(ROOTNAME) $(DESTDIR)$(DESTSBIN) 
181         chgrp $(ROOTGROUP) $(DESTDIR)$(DESTSBIN) 
182         chown $(ROOTNAME) $(DESTDIR)$(DESTBIN) 
183         chgrp $(ROOTGROUP) $(DESTDIR)$(DESTBIN) 
184         chown $(ROOTNAME) $(DESTDIR)$(ETC) 
185         chgrp $(ROOTGROUP) $(DESTDIR)$(ETC) 
186         chown $(ROOTNAME) $(DESTDIR)$(FIFODIR) 
187         chgrp $(ROOTGROUP) $(DESTDIR)$(FIFODIR) 
188         chown $(ROOTNAME) $(DESTDIR)$(PIDDIR) 
189         chgrp $(ROOTGROUP) $(DESTDIR)$(PIDDIR) 
190
191 # change spool dir mode
192         chown $(USERNAME) $(DESTDIR)$(FCRONTABS)
193         chgrp $(GROUPNAME) $(DESTDIR)$(FCRONTABS)
194         chmod 770 $(DESTDIR)$(FCRONTABS)
195
196         chown $(ROOTNAME) $(DESTDIR)$(DESTSBIN)/fcron
197         chgrp $(ROOTGROUP) $(DESTDIR)$(DESTSBIN)/fcron
198         chmod 110 $(DESTDIR)$(DESTSBIN)/fcron
199
200         chown $(USERNAME) $(DESTDIR)$(DESTBIN)/fcrontab
201         chgrp $(GROUPNAME) $(DESTDIR)$(DESTBIN)/fcrontab
202         chmod $(BINMODE) $(DESTDIR)$(DESTBIN)/fcrontab
203
204         chown $(ROOTNAME) $(DESTDIR)$(DESTBIN)/fcronsighup
205         chgrp $(GROUPNAME) $(DESTDIR)$(DESTBIN)/fcronsighup
206         chmod $(BINMODESIGHUP) $(DESTDIR)$(DESTBIN)/fcronsighup
207
208 ifeq ($(FCRONDYN), 1)
209         chown $(USERNAME) $(DESTDIR)$(DESTBIN)/fcrondyn
210         chgrp $(GROUPNAME) $(DESTDIR)$(DESTBIN)/fcrondyn
211         chmod $(BINMODE) $(DESTDIR)$(DESTBIN)/fcrondyn
212 endif
213         chown $(ROOTNAME) $(DESTDIR)$(ETC)/fcron.allow $(DESTDIR)$(ETC)/fcron.deny
214         chgrp $(GROUPNAME) $(DESTDIR)$(ETC)/fcron.allow $(DESTDIR)$(ETC)/fcron.deny
215         chmod 640 $(DESTDIR)$(ETC)/fcron.allow $(DESTDIR)$(ETC)/fcron.deny
216
217         chown $(ROOTNAME) $(DESTDIR)$(ETC)/fcron.conf
218         chgrp $(GROUPNAME) $(DESTDIR)$(ETC)/fcron.conf
219         chmod 640 $(DESTDIR)$(ETC)/fcron.conf
220 ifeq ($(USEPAM), 1)
221         $(SRCDIR)/script/install-pam-conf $(SRCDIR) $(DESTDIR)$(ETC) $(ROOTNAME) $(ROOTGROUP) "$(INSTALL)"
222 endif
223
224 # in order to get correct rights when upgrading :
225
226         find $(DESTDIR)$(FCRONTABS) -type f \( -name "*.orig" -a ! -name "$(ROOTNAME).orig" -a ! -name "$(SYSFCRONTAB).orig" \) -exec chown $(USERNAME) {} \; -exec chgrp $(GROUPNAME) {} \; -exec chmod 640 {} \;
227         find $(DESTDIR)$(FCRONTABS) -type f \( -name "$(ROOTNAME).orig" -o -name "$(SYSFCRONTAB).orig" \) -exec chown $(ROOTNAME) {} \; -exec chgrp $(GROUPNAME) {} \; -exec chmod 600 {} \;
228         # First, remove the potential fcrontab.sig, or it could not get removed by fcronsighup if it becomes root:root 600
229         rm -f $(DESTDIR)$(FCRONTABS)/fcrontab.sig
230         find $(DESTDIR)$(FCRONTABS) -type f ! -name "*.orig" -exec chown $(ROOTNAME) {} \; -exec chgrp $(ROOTGROUP) {} \; -exec chmod 600 {} \;
231
232         $(MAKE) -C doc perms
233
234 # strip executables
235 strip: install-staged
236         strip $(DESTDIR)$(DESTSBIN)/fcron
237         strip $(DESTDIR)$(DESTBIN)/fcrontab
238         strip $(DESTDIR)$(DESTBIN)/fcronsighup
239 ifeq ($(FCRONDYN), 1)
240         strip $(DESTDIR)$(DESTBIN)/fcrondyn
241 endif
242
243 install-boot: install 
244         $(SRCDIR)/script/boot-install "$(INSTALL) -o $(ROOTNAME)" $(DESTSBIN) $(DEBUG) $(FCRONTABS)  $(ANSWERALL) $(SRCDIR)
245
246 install-restart: install
247 ifeq ($(DEBUG), 1)
248         kill -TERM `pidof fcron` || exit 0
249         /etc/init.d/fcron restart
250 endif
251
252 uninstall:
253         rm -f $(DESTDIR)$(DESTSBIN)/fcron
254         rm -f $(DESTDIR)$(DESTBIN)/fcrontab
255         rm -f $(DESTDIR)$(DESTBIN)/fcronsighup
256         rm -f $(DESTDIR)$(DESTBIN)/fcrondyn
257         $(MAKE) -C doc uninstall
258         $(SRCDIR)/script/boot-uninstall
259
260 clean:
261         rm -f *.o core
262         rm -f fcron fcrontab fcrondyn fcronsighup convert-fcrontab files/fcron.conf
263         $(MAKE) -C doc clean
264
265 ciclean: clean
266         find ./ -name "*~" -exec rm -f {} \;
267         rm -fR autom4te*
268
269 vclean: ciclean
270         rm -f config.log config.status config.h config.cache Makefile PREVIOUS_VERSION \
271             files/fcron.conf script/fcron.init.suse script/fcron.init.systemd \
272             script/fcron.sh script/sysVinit-launcher
273         $(MAKE) -C doc clean
274
275
276 files/fcron.conf: $(SRCDIR)/files/fcron.conf.in config.h
277         if test ! -d files; then mkdir files ; fi
278         $(SRCDIR)/script/gen-in.pl $(SRCDIR)/files/fcron.conf.in files/fcron.conf ./
279
280 updatedoc:
281         $(MAKE) -C doc doc
282
283 indent:
284         indent -linux -i4 --no-tabs --leave-optional-blank-lines \
285             --start-left-side-of-comments --procnames-start-lines \
286             --dont-cuddle-else *.c *.h
287
288 configure: configure.in
289 # update configure script, then Makefile and config.h, and finally 
290 # run make tar using the new Makefile (needed because the version
291 # is set in the configure.in file)
292         autoconf
293         ./configure
294         @($(MAKE) tar && \
295                 echo "---------------------------------------------" && \
296                 echo "Success !" && \
297                 echo "(Please ignore the following make error" && \
298                 echo " and run your latest make command again)" && \
299                 echo "---------------------------------------------" && \
300                 exit 999)
301
302 ci: ciclean
303 # the symbolic links verX_X_X has been created since version 2.9.4
304         @(find ./ -type f ! -regex '.*RCS.*' ! -regex "$(RCSNOCI)" \
305           -exec ci -l -Nver`echo $(VERSION) | tr '.' '_'` {} \;)
306 # ci the doc files
307         $(MAKE) -C doc ci
308
309 tar: configure updatedoc vclean ciclean
310
311         echo $(VERSION) > ./VERSION
312
313         $(MAKE) -C doc tarclean
314
315         @(find ./ -type f ! -regex '.*RCS.*' ! -regex '.*CVS.*' ! -regex '.*\.git.*'| \
316              sed -e "s:^\./:fcron-$(VERSION)/:" > MANIFEST)
317         @(cd ..; ln -s fcron fcron-$(VERSION))
318         (cd ..; tar -czvf fcron-$(VERSION).src.tar.gz `cat fcron/MANIFEST`)
319         @(cd ..; rm -f fcron-$(VERSION))
320
321         @(cd ..; mv -f fcron-$(VERSION).src.tar.gz old-fcron-pkg/)