1#   Anacron - run commands periodically
2#   Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
3#
4#   This program is free software; you can redistribute it and/or modify
5#   it under the terms of the GNU General Public License as published by
6#   the Free Software Foundation; either version 2 of the License, or
7#   (at your option) any later version.
8#
9#   This program is distributed in the hope that it will be useful,
10#   but WITHOUT ANY WARRANTY; without even the implied warranty of
11#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12#   GNU General Public License for more details.
13#
14#   You should have received a copy of the GNU General Public License
15#   along with this program; if not, write to the Free Software
16#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17#
18#   The GNU General Public License can also be found in the file
19#   `COPYING' that comes with the Anacron source distribution.
20
21
22PREFIX =
23BINDIR = $(PREFIX)/usr/sbin
24MANDIR = $(PREFIX)/usr/man
25
26#CFLAGS = -Wall -O2 -g -DDEBUG
27
28# If you change these, please update the man-pages too
29# Only absolute paths here, please
30SPOOLDIR = /var/spool/anacron
31ANACRONTAB = /usr/local/etc/anacrontab
32
33RELEASE = 2.3
34package_name = anacron-$(RELEASE)
35distfiles = ChangeLog COPYING README TODO anacron.8 anacrontab.5 Makefile *.h *.c
36
37SHELL = /bin/sh
38INSTALL = install
39INSTALL_PROGRAM = $(INSTALL)
40INSTALL_DATA = $(INSTALL)
41INSTALL_DIR = $(INSTALL) -d
42GZIP = gzip -9 -f
43ALL_CPPFLAGS = -DSPOOLDIR=\"$(SPOOLDIR)\" -DRELEASE=\"$(RELEASE)\" \
44	-DANACRONTAB=\"$(ANACRONTAB)\" $(CPPFLAGS)
45
46csources := $(wildcard *.c)
47objects = $(csources:.c=.o)
48
49.PHONY: all
50all: anacron
51
52# This makefile generates header file dependencies auto-magically
53%.d: %.c
54	$(SHELL) -ec "$(CC) -MM $(ALL_CPPFLAGS) $< \
55	| sed '1s/^\(.*\)\.o[ :]*/\1.d &/1' > $@"
56
57include $(csources:.c=.d)
58
59anacron: $(objects)
60	$(CC) $(LDFLAGS) $^ $(LOADLIBES) -o $@
61
62%.o : %.c
63	$(CC) -c $(ALL_CPPFLAGS) $(CFLAGS) $< -o $@
64
65.PHONY: installdirs
66installdirs:
67	$(INSTALL_DIR) $(BINDIR) $(PREFIX)$(SPOOLDIR) \
68		$(MANDIR)/man5 $(MANDIR)/man8
69
70.PHONY: install
71install: installdirs
72	$(INSTALL_PROGRAM) anacron $(BINDIR)/anacron
73	$(INSTALL_DATA) anacrontab.5 $(MANDIR)/man5/anacrontab.5
74	$(INSTALL_DATA) anacron.8 $(MANDIR)/man8/anacron.8
75
76.PHONY: clean
77clean:
78	rm -f *.o *.d anacron
79
80distclean: clean
81	rm -f *~
82
83.PHONY: dist
84dist: $(package_name).tar.gz
85
86$(package_name).tar.gz: $(distfiles)
87	mkdir $(package_name)
88	ln $(distfiles) $(package_name)
89	chmod 0644 $(package_name)/*
90	chmod 0755 $(package_name)
91	tar cf $(package_name).tar $(package_name)
92	$(GZIP) $(package_name).tar
93	rm -r $(package_name)
94
95release: distclean $(package_name).tar.gz
96