1##################################################
2#
3# chronyd/chronyc - Programs for keeping computer clocks accurate.
4#
5# Copyright (C) Richard P. Curnow  1997-2003
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of version 2 of the GNU General Public License as
9# published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19#
20# =======================================================================
21#
22# Makefile template
23
24SYSCONFDIR = @SYSCONFDIR@
25BINDIR = @BINDIR@
26SBINDIR = @SBINDIR@
27LOCALSTATEDIR = @LOCALSTATEDIR@
28CHRONYVARDIR = @CHRONYVARDIR@
29DESTDIR =
30
31CC = @CC@
32CFLAGS = @CFLAGS@
33CPPFLAGS = @CPPFLAGS@
34LDFLAGS = @LDFLAGS@
35
36EXTRA_OBJS = @EXTRA_OBJS@
37
38OBJS = array.o cmdparse.o conf.o local.o logging.o main.o memory.o \
39       reference.o regress.o rtc.o samplefilt.o sched.o socket.o sources.o sourcestats.o \
40       stubs.o smooth.o sys.o sys_null.o tempcomp.o util.o $(EXTRA_OBJS)
41
42EXTRA_CLI_OBJS = @EXTRA_CLI_OBJS@
43
44CLI_OBJS = array.o client.o cmdparse.o getdate.o memory.o nameserv.o \
45           pktlength.o socket.o util.o $(EXTRA_CLI_OBJS)
46
47ALL_OBJS = $(OBJS) $(CLI_OBJS)
48
49LIBS = @LIBS@
50EXTRA_LIBS = @EXTRA_LIBS@
51EXTRA_CLI_LIBS = @EXTRA_CLI_LIBS@
52
53# Until we have a main procedure we can link, just build object files
54# to test compilation
55
56all : chronyd chronyc
57
58chronyd : $(OBJS)
59	$(CC) $(CFLAGS) -o chronyd $(OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS)
60
61chronyc : $(CLI_OBJS)
62	$(CC) $(CFLAGS) -o chronyc $(CLI_OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_CLI_LIBS)
63
64distclean : clean
65	$(MAKE) -C doc distclean
66	$(MAKE) -C test/unit distclean
67	-rm -f .DS_Store
68	-rm -f Makefile config.h config.log
69
70clean :
71	$(MAKE) -C test/unit clean
72	-rm -f *.o *.s chronyc chronyd core.* *~
73	-rm -f *.gcda *.gcno
74	-rm -rf .deps
75	-rm -rf *.dSYM
76
77getdate.c : getdate.y
78	bison -o getdate.c getdate.y
79
80# This can be used to force regeneration of getdate.c
81getdate :
82	bison -o getdate.c getdate.y
83
84# For install, don't use the install command, because its switches
85# seem to vary between systems.
86
87install: chronyd chronyc
88	[ -d $(DESTDIR)$(SYSCONFDIR) ] || mkdir -p $(DESTDIR)$(SYSCONFDIR)
89	[ -d $(DESTDIR)$(SBINDIR) ] || mkdir -p $(DESTDIR)$(SBINDIR)
90	[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
91	[ -d $(DESTDIR)$(CHRONYVARDIR) ] || mkdir -p $(DESTDIR)$(CHRONYVARDIR)
92	if [ -f $(DESTDIR)$(SBINDIR)/chronyd ]; then rm -f $(DESTDIR)$(SBINDIR)/chronyd ; fi
93	if [ -f $(DESTDIR)$(BINDIR)/chronyc ]; then rm -f $(DESTDIR)$(BINDIR)/chronyc ; fi
94	cp chronyd $(DESTDIR)$(SBINDIR)/chronyd
95	chmod 755 $(DESTDIR)$(SBINDIR)/chronyd
96	cp chronyc $(DESTDIR)$(BINDIR)/chronyc
97	chmod 755 $(DESTDIR)$(BINDIR)/chronyc
98	$(MAKE) -C doc install
99
100docs :
101	$(MAKE) -C doc docs
102
103install-docs :
104	$(MAKE) -C doc install-docs
105
106%.o : %.c
107	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
108
109%.s : %.c
110	$(CC) $(CFLAGS) $(CPPFLAGS) -S $<
111
112quickcheck : chronyd chronyc
113	$(MAKE) -C test/unit check
114	cd test/simulation && ./run
115	cd test/system && ./run
116
117check : chronyd chronyc
118	$(MAKE) -C test/unit check
119	cd test/simulation && ./run -i 20 -m 2
120	cd test/system && ./run
121
122print-chronyd-objects :
123	@echo $(OBJS)
124
125Makefile : Makefile.in configure
126	@echo
127	@echo Makefile needs to be regenerated, run ./configure
128	@echo
129	@exit 1
130
131.deps:
132	@mkdir .deps
133
134.deps/%.d: %.c | .deps
135	@$(CC) -MM $(CPPFLAGS) -MT '$(<:%.c=%.o) $@' $< -o $@
136
137ifndef NODEPS
138-include $(ALL_OBJS:%.o=.deps/%.d)
139endif
140